import type { CreateAgentSessionOptions } from "@bastani/atomic"; import type { TSchema } from "typebox"; export type { Static, TSchema } from "typebox"; export type { ObserveRunJournalRead, OpenRunJournal, RunJournalConformanceRunner, RunJournalReadObservation, } from "./durable/journal/conformance.js"; export { registerRunJournalConformance } from "./durable/journal/conformance.js"; export { MemoryRunJournal } from "./durable/journal/memory-run-journal.js"; export type { RunJournalOption, RunJournalSettings } from "./durable/journal/resolution.js"; export { resolveRunJournal } from "./durable/journal/resolution.js"; export { openSqlRunJournal, SqlRunJournal } from "./durable/journal/sqlite-run-journal.js"; export * from "./durable/journal/types.js"; export type { AgentSessionAdapter, CompleteAdapter, CompleteStageOpts, EffectiveBudget, GitWorktreeSetupOptions, GitWorktreeSetupResult, PromptAdapter, PromptOptions, ResolvedInputs, RunResult, RunStatus, StageAdapters, StageContext, StageExecutionMeta, StageMcpOptions, StageOptions, StageOutputOptions, StagePromptOptions, StageSendUserMessageOptions, StageSessionCreateOptions, StageSessionCreateResult, StageSessionEvent, StageSessionRuntime, StageSnapshot, StageStatus, StageUserMessageContent, StageUserMessageDelivery, ToolNodeSnapshot, WorkflowAction, WorkflowArtifact, WorkflowBudget, WorkflowChainOptions, WorkflowChildResult, WorkflowContextMode, WorkflowControlEvent, WorkflowCustomToolDefinition, WorkflowCustomUiComponent, WorkflowCustomUiFactory, WorkflowCustomUiKeybindings, WorkflowCustomUiOptions, WorkflowCustomUiOverlayHandle, WorkflowCustomUiOverlayOptions, WorkflowCustomUiTheme, WorkflowCustomUiTui, WorkflowDetails, WorkflowDetailsMode, WorkflowDetailsStatus, WorkflowExecutionMode, WorkflowExecutionPolicy, WorkflowExitOptions, WorkflowExitStatus, WorkflowInputBindings, WorkflowInputSchema, WorkflowInputSchemaMap, WorkflowInputValues, WorkflowIntercomSummary, WorkflowMaxOutput, WorkflowMcpPort, WorkflowModelAttempt, WorkflowModelCatalogPort, WorkflowModelFallbackFields, WorkflowModelInfo, WorkflowModelUsage, WorkflowModelValue, WorkflowOutputMode, WorkflowOutputSchema, WorkflowOutputSchemaMap, WorkflowOutputValues, WorkflowParallelFailure, WorkflowParallelOptions, WorkflowPersistencePort, WorkflowProgressSummary, WorkflowProviderRateLimit, WorkflowRunChildArgs, WorkflowRunChildOptions, WorkflowRunChildOptionsArgument, WorkflowRunOutput, WorkflowRuntimeConfig, WorkflowSerializableObject, WorkflowSerializablePrimitive, WorkflowSerializableValue, WorkflowSharedTaskDefaults, WorkflowTaskContext, WorkflowTaskContextInput, WorkflowTaskOptions, WorkflowTaskResult, WorkflowTaskSessionFields, WorkflowTaskSessionOptions, WorkflowTaskStep, WorkflowThinkingLevel, WorkflowToolContext, WorkflowToolError, WorkflowToolFailure, WorkflowToolOptions, WorkflowToolOutcome, WorkflowToolPrimitive, WorkflowToolReturnOptions, WorkflowToolSuccess, WorkflowToolThrowOptions, WorkflowUIAdapter, WorkflowUIContext, WorkflowWorktreeInputBinding, } from "./shared/authoring-contract.js"; import type * as AuthoringContract from "./shared/authoring-contract.js"; import type { AuthoredWorkflowSpec as SharedAuthoredWorkflowSpec, WorkflowInputsFromSchemas, WorkflowOutputsFromSchemas, WorkflowProvidedInputsFromSchemas } from "./shared/workflow-authoring-types.js"; export type { WorkflowInputsFromSchemas, WorkflowOutputsFromSchemas, WorkflowProvidedInputsFromSchemas, } from "./shared/workflow-authoring-types.js"; export type { WorkflowHeartbeatEvent, WorkflowHeartbeatEventDetails, WorkflowHeartbeatIdentity, } from "./shared/workflow-heartbeat-contract.js"; import type { GitWorktreeSetupOptions, GitWorktreeSetupResult, ResolvedInputs, RunResult, RunStatus, StageSnapshot, WorkflowDefinition as WorkflowContractDefinition, WorkflowExecutionPolicy, WorkflowInputSchemaMap, WorkflowInputValues, WorkflowOutputSchemaMap, WorkflowOutputValues, WorkflowSerializableObject } from "./shared/authoring-contract.js"; declare const workflowDefinitionBrand: unique symbol; type WorkflowDefinitionBrand = { readonly [workflowDefinitionBrand]: true; }; export interface WorkflowDefinition extends WorkflowContractDefinition, WorkflowDefinitionBrand { } export type AuthoredWorkflowDefinition = WorkflowDefinition, WorkflowOutputsFromSchemas, WorkflowProvidedInputsFromSchemas> & { readonly outputs: Readonly; }; export type WorkflowRunContext = AuthoringContract.WorkflowRunContext; export type WorkflowRunFn = AuthoringContract.WorkflowRunFn; type WorkflowRunInputArgument = [keyof TInputs] extends [never] ? Readonly> : TInputs; export type AuthoredWorkflowSpec, TOutputs extends WorkflowOutputSchemaMap = WorkflowOutputSchemaMap, TActualOutputs extends WorkflowOutputsFromSchemas = WorkflowOutputsFromSchemas> = SharedAuthoredWorkflowSpec, WorkflowOutputsFromSchemas>>; export type AnyWorkflowDefinition = WorkflowDefinition; export type RunContinuationOpts = AuthoringContract.RunContinuationOpts; export type WorkflowParentRunLink = AuthoringContract.WorkflowParentRunLink; export type RunOpts = Omit & { readonly registry?: WorkflowRegistry; }; export declare const INTERACTIVE_WORKFLOW_POLICY: WorkflowExecutionPolicy; export declare const NON_INTERACTIVE_WORKFLOW_POLICY: WorkflowExecutionPolicy; export declare function run(definition: WorkflowDefinition, inputs: Readonly>>, opts?: RunOpts): Promise>; export type { WorkflowInfrastructureFault } from "./shared/workflow-infrastructure-error.js"; export { isRetryableWorkflowError, WorkflowInfrastructureError } from "./shared/workflow-infrastructure-error.js"; export declare function loadWorkerWorkflow(path: string, exportName?: string): Promise; export type { LocalWorkerOptions, WorkflowAdmissionOptions } from "./workers/public-options.js"; /** * Build the default stage-session adapter: each stage runs an in-process Atomic * `createAgentSession` session. `baseOptions` apply to every stage; stage options * override them. Each stage gets its own session manager, in-memory unless the * stage sets `sessionDir` or resumes or forks a session. */ export declare function createAgentSessionAdapter(baseOptions?: Omit): AuthoringContract.AgentSessionAdapter; export declare function resolveInputs(schema: Readonly>, provided: Partial): ResolvedInputs; export declare function setupGitWorktree(options: GitWorktreeSetupOptions): GitWorktreeSetupResult; export interface WorkflowRegistry { register(definition: WorkflowDefinition): WorkflowRegistry; merge(other: WorkflowRegistry): WorkflowRegistry; get(name: string): AnyWorkflowDefinition | undefined; has(name: string): boolean; remove(name: string): WorkflowRegistry; names(): string[]; all(): AnyWorkflowDefinition[]; } export declare function workflow, const TOutputs extends WorkflowOutputSchemaMap = WorkflowOutputSchemaMap, TActualOutputs extends WorkflowOutputsFromSchemas = WorkflowOutputsFromSchemas>(spec: AuthoredWorkflowSpec): AuthoredWorkflowDefinition; /** * Wrap prompt text so compaction protects it verbatim, regardless of the compression ratio. * * Reserve it for text whose loss silently changes behavior: role constraints, acceptance * criteria and immutable contracts, explicit prohibitions, and identifiers a stage must not * lose. Do not wrap bulk context — protected lines count against the keep target rather than * raising it, so a large span makes the surrounding transcript compress harder. */ export declare function keepContext(text: string): string; export declare const KEEP_CONTEXT_OPEN_TAG: string; export declare const KEEP_CONTEXT_CLOSE_TAG: string; export declare const DEFAULT_WORKFLOW_HEARTBEAT_INTERVAL_MINUTES: 15; export declare const WORKFLOW_HEARTBEAT_CUSTOM_TYPE: "workflows:workflow-heartbeat"; export declare function createRegistry(initial?: TDefinitions): WorkflowRegistry; export declare function normalizeWorkflowName(name: string): string; export declare function workflowNamesEqual(a: string, b: string): boolean; export declare class GraphFrontierTracker { onSpawn(stageId: string, stageName: string): string[]; currentParents(): string[]; replaceParents(stageId: string, parentIds: readonly string[]): void; onSettle(stageId: string): void; getNodes(): StageNode[]; getParents(stageId: string): string[]; reset(): void; } export interface StageNode extends WorkflowSerializableObject { readonly id: string; readonly name: string; readonly parentIds: readonly string[]; } export type NoticeLevel = "info" | "warning" | "error"; export type PromptKind = "input" | "confirm" | "select" | "editor" | "custom"; export type CustomPromptIdentitySource = "caller" | "factory" | "callsite"; export interface PendingPrompt extends WorkflowSerializableObject { readonly id: string; readonly kind: PromptKind; readonly message: string; readonly choices?: readonly string[]; readonly initial?: string; readonly customIdentityHash?: string; readonly customIdentitySource?: CustomPromptIdentitySource; readonly createdAt: number; } export interface ToolEvent { readonly name: string; readonly input?: Record; readonly output?: string; readonly startedAt?: number; readonly endedAt?: number; } export interface WorkflowNotice extends WorkflowSerializableObject { readonly id: string; readonly runId?: string; readonly stageId?: string; readonly level: NoticeLevel; readonly message: string; readonly createdAt: number; readonly requiresAck?: boolean; readonly ackedAt?: number; } export interface WorkflowOverlayAdapter { show(notice: WorkflowNotice): void; hide(): void; } export interface RunSnapshot { readonly id: string; readonly name: string; readonly status: RunStatus; readonly stages: readonly StageSnapshot[]; /** First-class durable ctx.tool nodes; populated by the runtime. */ readonly toolNodes: readonly import("./shared/authoring-contract.js").ToolNodeSnapshot[]; readonly startedAt: number; readonly endedAt?: number; readonly durationMs?: number; readonly result?: WorkflowOutputValues; readonly error?: string; /** Tool node whose rejection supplied the selected terminal failure. */ readonly failedToolNodeId?: string; /** True when the run reached its terminal status through ctx.exit(). */ readonly exited?: boolean; readonly exitReason?: string; readonly pendingPrompt?: PendingPrompt; } export interface StoreSnapshot { readonly runs: readonly RunSnapshot[]; readonly notices: readonly WorkflowNotice[]; readonly version: number; } export interface Store { runs(): readonly RunSnapshot[]; notices(): readonly WorkflowNotice[]; activeRunId(): string | null; recordRunStart(run: RunSnapshot): void; recordStageStart(runId: string, stage: StageSnapshot): void; recordToolStart(runId: string, stageId: string, evt: ToolEvent): void; recordToolEnd(runId: string, stageId: string, evt: ToolEvent): void; recordStageEnd(runId: string, stage: StageSnapshot): void; recordRunEnd(runId: string, status: RunStatus, result?: WorkflowOutputValues, error?: string): boolean; removeRun(runId: string): boolean; recordNotice(notice: WorkflowNotice): void; ackNotice(id: string): boolean; /** JSON copy of every run and notice at the current store version. */ snapshot(): StoreSnapshot; /** Cached, payload-bounded projection for graph rendering; one object per store version. */ graphSnapshot(): StoreSnapshot; /** Calls `listener` with a fresh `snapshot()` after each store change. Returns an unsubscribe function. */ subscribe(listener: (snapshot: StoreSnapshot) => void): () => void; } export declare function createStore(): Store; export declare const store: Store; export interface ActiveRunEntry { readonly controller: AbortController; readonly children: readonly AbortController[]; } export interface CancellationRegistry { register(runId: string, controller: AbortController): void; registerChild(runId: string, controller: AbortController): void; abort(runId: string, reason?: unknown): boolean; abortAll(reason?: unknown): number; unregister(runId: string): void; isAborted(runId: string): boolean; } export declare function createCancellationRegistry(): CancellationRegistry; export declare const cancellationRegistry: CancellationRegistry;