import type { ThreadRecord, AgentSlotConfig, AgentSlotId, AgentStep, TransitionResult } from '../../core/types/thread-types.js'; export declare function createThread(channel: string, options: { templateName?: string | null; agentName?: string | null; userMessage: string; userMessageTs: string; platformThreadId?: string | null; projectId?: string; metadata?: import('../../core/types/thread-types.js').ThreadMetadata | null; }): ThreadRecord; export declare function addAgentToThread(threadId: string, agentName: string, userMessage?: string | null): Promise; interface NextStepInfo { agentSlotId: AgentSlotId; agentConfig: AgentSlotConfig; isFirstStep: boolean; stage: string | null; } export declare function resolveNextStep(threadId: string): NextStepInfo | null; interface StepResultInput { sessionId?: string | null; sessionName?: string | null; executionId?: string | null; input?: string | null; startedAt?: string | null; output: string | null; costUsd: number | null; numTurns: number | null; durationS: number | null; stage?: string | null; } export declare function recordStepResult(threadId: string, agentSlotId: AgentSlotId, result: StepResultInput): Promise; export declare function evaluateTransitions(threadId: string): TransitionResult; export declare function cancelThread(threadId: string): Promise; export type PendingControl = NonNullable['pendingControl']; /** Peek the thread's pending control signal (does NOT clear it). Returns null when none set. */ export declare function peekPendingControl(threadId: string): PendingControl | null; /** Clear the thread's pending control signal so an intent fires exactly once. */ export declare function clearPendingControl(threadId: string): Promise; /** Derive a split detection from a thread's pending control signal — the dispatch path's * injected `detect` (replaces the old artifact-scanning detectSplitMarker). The subtask array * was validated as a typed tool argument, so the only "error" case is an empty array. */ export declare function detectSplitFromControl(threadId: string): SplitDetection; /** Try to suspend the thread until its waited-on children finish. Inside a single mutate * (serialized with the callback side via the store mutex), filter waitingOn down to * children that still exist and are non-terminal; additionally (DR-0014 §8) snapshot live * child TASKS (parent === metadata.taskId) into waitingOnTasks. If either list is * non-empty, set status='waiting'. Returns true iff the thread entered waiting. * Either interleaving with the completion callback converges: callback-first → nothing * left to wait on (results already in pendingMessages); runner-first → callback sees * waiting and resumes when both lists empty. The task-side race (a child completing * between the snapshot and the waiting persist, its event missed) is closed by * reconcileWaitingTasks right after suspension. */ export declare function tryEnterWaiting(threadId: string): Promise; export interface SplitDetection { split: boolean; subtasks: any[] | null; error: string | null; } /** Terminate the thread with status='aborted'. Idempotent — returns false if thread is already terminal. */ export declare function abortThread(threadId: string, reason: string | null): Promise; export declare function completeThread(threadId: string): Promise; export declare function failThread(threadId: string, error: string): Promise; /** Pause a thread that was interrupted mid-run by an API rate limit. Non-terminal: the * thread keeps its currentStepIndex/agents and is re-entered (from the interrupted step) * by the resume-dispatcher when the rate-limit window resets. Does NOT set endedAt. * Idempotent. */ export declare function markThreadRateLimited(threadId: string, note?: string): Promise; export {};