import type { ModelMessage, TranscriptionModel } from 'ai'; import { type UserInputContent } from './userInput.js'; import type { Session } from '../types/session.js'; import type { SessionStore } from '../session/SessionStore.js'; import type { AgentConfig } from '../types/agentConfig.js'; import type { SignalDelivery } from './durable/types.js'; import { type RunKind, type RunState } from './durable/types.js'; import { type RunStore } from './durable/RunStore.js'; import type { ResolvedSelection } from '../types/selection.js'; export interface OpenRunOptions { sessionId: string; userId?: string; input?: UserInputContent; selection?: ResolvedSelection; /** Agent-initiated turn: no user input; a wake note is appended instead. */ wake?: { reason: string; payload?: Record; }; agentId?: string; seedMessages?: ModelMessage[]; historyDelta?: ModelMessage[]; /** See `RunOptions.callerInstructions`. */ callerInstructions?: string; signalDelivery?: SignalDelivery; /** Stable key for this inbound user message; duplicate webhook retries are ignored (H2). */ idempotencyKey?: string; transcriptionModel?: TranscriptionModel; defaultAgentId: string; sessionStore: SessionStore; /** * Address an existing run. Unknown and cross-session values throw. * Omit to open the session's conversation run, or to mint a new flow run * when `kind` is `'flow'`. */ runId?: string; /** When minting a new run (no `runId`), its kind. Default `'conversation'`. */ kind?: RunKind; /** * Creation-only: enter this flow on a newly minted `kind: 'flow'` run. * Ignored on resume so a caller cannot retarget another flow. */ flowName?: string; /** * Server-side id source for a newly minted flow run. Pass a journaled * `ctx.uuid` binding so replay yields the same run id. Caller-supplied * resume ids go on `runId`, not here. */ mint?: () => string; /** Override the default SessionRunStore for this open. */ runStore?: RunStore; /** Execution-lease holder. Runtime passes a stable per-instance id. */ leaseHolder?: string; leaseTtlMs?: number; } export declare function resolveRunStore(sessionStore: SessionStore, sessionId: string, override?: RunStore): RunStore; export interface OpenRunResult { session: Session; runState: RunState; runStore: RunStore; agent: AgentConfig; } export declare function mintRunId(uuid?: () => string): string; export interface ResolvedRunTarget { runId?: string; lockKind: RunKind; } export declare function resolveTargetRunId(sessionStore: SessionStore, sessionId: string, opts: { runId?: string; signalDelivery?: SignalDelivery; kind?: RunKind; }): Promise; export declare function openRun(agentsById: Map, options: OpenRunOptions): Promise; export declare function newSessionId(): string;