import * as z from "zod/mini"; //#region src/lib/config.d.ts /** * Strict schema for a config object (a file's contents or the merged result). * Unknown keys and out-of-range values are errors, not warnings. These schemas * are the source of truth for the config domain types (types.ts re-exports the * z.infer'd types). */ declare const engineSchema: z.ZodMiniEnum<{ codex: "codex"; claude: "claude"; }>; declare const agentSchema: z.ZodMiniEnum<{ codex: "codex"; claude: "claude"; custom: "custom"; }>; declare const effortSchema: z.ZodMiniEnum<{ low: "low"; medium: "medium"; high: "high"; }>; declare const permissionSchema: z.ZodMiniEnum<{ "read-only": "read-only"; "workspace-write": "workspace-write"; auto: "auto"; }>; declare const customModelSchema: z.ZodMiniObject<{ baseUrl: z.ZodMiniURL; model: z.ZodMiniString; envKey: z.ZodMiniOptional>; wireApi: z.ZodMiniOptional>; disabled: z.ZodMiniOptional>; }, z.core.$strict>; /** The merged, effective shape (everything present after DEFAULT_CONFIG). */ declare const effectiveConfigSchema: z.ZodMiniObject<{ chain: z.ZodMiniArray>; agents: z.ZodMiniObject<{ codex: z.ZodMiniOptional>; effort: z.ZodMiniOptional>; permissions: z.ZodMiniOptional>; }, z.core.$strict>>; claude: z.ZodMiniOptional>; effort: z.ZodMiniOptional>; permissions: z.ZodMiniOptional>; }, z.core.$strict>>; custom: z.ZodMiniOptional>; effort: z.ZodMiniOptional>; permissions: z.ZodMiniOptional>; }, z.core.$strict>>; }, z.core.$strict>; models: z.ZodMiniOptional, z.ZodMiniUnion; envKey: z.ZodMiniOptional>; wireApi: z.ZodMiniOptional>; disabled: z.ZodMiniOptional>; }, z.core.$strict>, z.ZodMiniObject<{ provider: z.ZodMiniEnum<{ codex: "codex"; claude: "claude"; }>; model: z.ZodMiniString; effort: z.ZodMiniOptional>; disabled: z.ZodMiniOptional>; }, z.core.$strict>, z.ZodMiniObject<{ disabled: z.ZodMiniBoolean; }, z.core.$strict>]>>>; approvals: z.ZodMiniObject<{ escalationTimeoutMs: z.ZodMiniNumber; allowedNetworkHosts: z.ZodMiniArray>; }, z.core.$strict>; }, z.core.$strict>; type Engine = z.infer; type Agent = z.infer; type Effort = z.infer; type Permission = z.infer; type CustomModelConfig = z.infer; type CoderConfig = z.infer; //#endregion //#region src/lib/types.d.ts type JobKind = 'task'; type JobStatus = 'queued' | 'running' | 'completed' | 'failed' | 'cancelled'; /** A persisted job record (job.json). Most fields accrete over the lifecycle. */ interface Job { id: string; createdAt: string; updatedAt?: string; status: JobStatus; kind?: JobKind; name?: string | null; agent?: Agent; engine?: Engine; prompt?: string; currentPrompt?: string | null; system?: string | null; model?: string | null; effort?: Effort | null; permissions?: Permission; resumeThreadId?: string | null; cwd?: string; background?: boolean; pid?: number | null; threadId?: string | null; turnId?: string | null; steerEndpoint?: string | null; completedAt?: string; resumedAt?: string; error?: string; archived?: boolean; archivedAt?: string; simulateApproval?: boolean; flowRunId?: string; } /** Normalized token usage for one turn, summed across the engine's threads. */ interface TokenUsage { input: number; cachedInput: number; output: number; total: number; } /** The outcome of running one engine turn. status 0 == success. */ interface TurnResult { status: number; threadId: string | null; turnId?: string | null; finalMessage?: string; touchedFiles?: string[]; tokens?: TokenUsage | null; /** The model that ran the turn (tokens are only comparable per model). */ model?: string | null; error?: { message?: string; } | null; [key: string]: unknown; } /** Whether an engine binary is installed and usable. */ interface Availability { available: boolean; detail: string; } /** A persisted approval escalation and its answer, if any. */ interface Approval { id: string; summary: string; createdAt?: string; response?: { decision: string; } | null; [key: string]: unknown; } //#endregion //#region src/flow/types.d.ts /** Anything with zod's parse shape; the flow runtime never imports zod itself. */ interface FlowSchema { parse(value: unknown): T; } interface FlowTaskResult { taskId: string; status: string; output: string; data?: T; tokens: TokenUsage | null; model: string | null; } interface GateResult { ok: boolean; code: number; output: string; } /** Options shared with `coder run`, plus `returns`. */ interface FlowTaskOptions { agent?: string; model?: string; effort?: string; permissions?: string; name?: string; system?: string; resume?: string; cwd?: string; returns?: FlowSchema; } type FlowRunStatus = 'queued' | 'running' | 'completed' | 'failed' | 'stopped'; /** * One line of a run's events.jsonl: a hook payload tagged with its kind. The * attached orchestrator appends these; `flow stream` / `flow.stream()` replay * and follow them. */ type FlowEvent = { kind: 'task-start'; taskId: string; name?: string; prompt: string; agent?: string; depth?: number; } | { kind: 'task-end'; taskId: string; status: string; tokens: TokenUsage | null; } | { kind: 'gate-start'; gateId: string; cmd: string; depth?: number; } | { kind: 'gate'; gateId?: string; cmd: string; ok: boolean; code: number; depth?: number; } | { kind: 'log'; message: string; depth?: number; } | { kind: 'flow-start'; name: string; depth: number; } | { kind: 'replay'; count: number; }; /** flow.json: the persisted run record. */ interface FlowRecord { runId: string; name: string; script: string; args: unknown; status: FlowRunStatus; startedAt: string; endedAt?: string; /** Orchestrator process while status is running; cleared on every terminal write. */ pid?: number; pidStartedAt?: string; concurrency: number; maxTasks: number; taskCount: number; ledger: Record; result?: unknown; error?: string; /** Hidden from the default list; set by auto-archive or `flow archive`. */ archived?: boolean; archivedAt?: string; } /** One `flow result` step row: a journaled task with its current status. */ interface FlowStep { taskId: string | null; name: string | null; status: string; tokens: TokenUsage | null; } interface DiscoveredFlow { name: string; path: string; scope: 'workspace' | 'global'; } //#endregion //#region src/flow/runtime.d.ts /** * Dispatch one coder task and await its result. With a `returns` schema the * reply is validated and `data` is guaranteed (validation failure throws). * Inside a flow run, results are journaled and replayed on resume. */ declare function task(prompt: string, opts: FlowTaskOptions & { returns: FlowSchema; }): Promise & { data: T; }>; /** Dispatch one coder task and await its result. Mirrors `coder run`. */ declare function task(prompt: string, opts?: FlowTaskOptions): Promise; /** * Run a shell command as a checkpoint. Never throws — inspect `ok`/`code`; * output is captured (capped) and journaled for resume. */ declare function gate(cmd: string, opts?: { cwd?: string; }): Promise; type Stage = (prev: any, item: any, index: number) => unknown; type S = (prev: P, item: T, index: number) => R | Promise; /** * Run each item through the stages independently, with no barrier between * stages. Each stage receives `(prev, item, index)`; a thrown stage drops * that item to `null` and skips its remaining stages. */ declare function pipeline(items: T[], s1: S): Promise<(A | null)[]>; declare function pipeline(items: T[], s1: S, s2: S): Promise<(B | null)[]>; declare function pipeline(items: T[], s1: S, s2: S, s3: S): Promise<(C | null)[]>; declare function pipeline(items: T[], s1: S, s2: S, s3: S, s4: S): Promise<(D | null)[]>; declare function pipeline(items: T[], ...stages: Stage[]): Promise; /** Emit a progress line: appended to the run's flow.log and streamed to watchers. */ declare function log(msg: string): void; /** * Run another flow inline as a sub-step and return its result. Nesting is one * level deep — a sub-flow cannot call `flow()` itself. */ declare function flow(name: string, args?: unknown): Promise; interface RunOptions { args?: unknown; concurrency?: number; maxTasks?: number; dryRun?: boolean; cwd?: string; } interface RunSummary { runId: string; name: string; status: 'completed'; result: unknown; tokens: Record; taskCount: number; } interface StopSummary { runId: string; status: FlowRecord['status']; stoppedTasks: string[]; keptTasks: string[]; } //#endregion //#region src/lib/state.d.ts interface JobLogEntry { at?: string; message?: string; kind?: string; [key: string]: unknown; } interface TurnResultEntry { at?: string; prompt?: string | null; finalMessage?: string; status?: number; [key: string]: unknown; } //#endregion //#region src/lib/dispatch.d.ts /** The run-native-subagent fallback payload the CLI prints on exit 3. */ interface FallbackPayload { error: string; fallback: { action: 'run-native-subagent'; reason: 'no-engine-available'; permissions: string; note: string; system?: string; task: string; }; } /** * Any coder operation that fails in a way the caller can act on throws a * CoderError; `code` says why. The CLI maps codes to exit codes (chain-exhausted * -> 3, approval-pending -> 4, the rest -> 1). */ type CoderErrorCode = 'nested-dispatch' | 'invalid-option' | 'read-only-unavailable' | 'startup-failed' | 'chain-exhausted' | 'approval-pending' | 'task-failed' | 'flow-failed'; declare class CoderError extends Error { code: CoderErrorCode; hint?: string | string[]; taskId?: string; /** chain-exhausted: the run-native-subagent payload the CLI prints on exit 3. */ payload?: FallbackPayload; /** approval-pending: the approval to answer. */ approval?: { id: string; summary: string; }; /** task-failed (flow task()): the failed task's result. */ result?: unknown; /** flow-failed: the run to resume. */ runId?: string; constructor(code: CoderErrorCode, message: string, extra?: { hint?: string | string[]; taskId?: string; payload?: FallbackPayload; approval?: { id: string; summary: string; }; result?: unknown; runId?: string; }); } interface TaskResult { taskId: string; status: JobStatus; result: TurnResult | null; /** The last `tail` progress-log entries; [] at the default tail of 0. */ steps: JobLogEntry[]; /** One entry per finished turn (a steered task accretes turns). */ turns: TurnResultEntry[]; job: Job; } //#endregion //#region src/flow/index.d.ts /** * The flow's `--args` value. A Proxy over the ALS-bound current args, so a * top-level `import { args }` reflects whichever run is executing. */ declare const args: Record; /** Run and inspect flows programmatically; mirrors `coder flow`. */ declare const flowSdk: { /** Run a flow and await its result. */ run(nameOrPath: string, opts?: RunOptions): Promise; /** Recent flow runs (mirrors `coder flow list`). */ list(opts?: { archived?: boolean; limit?: number; }): FlowRecord[]; /** Flows discoverable from a directory (workspace + global). */ discover(cwd?: string): DiscoveredFlow[]; /** A run's record plus its step rows (omit the id for the most recent run). `tail` caps steps (default 'all'; 0 → []). */ result(runId?: string, opts?: { tail?: number | "all"; }): (FlowRecord & { steps: FlowStep[]; }) | null; /** Follow a run live: an async iterable of flow events, ending when the run is terminal. `tail` replays only the last n (default 'all'). */ stream(runId?: string, opts?: { tail?: number | "all"; }): AsyncGenerator; /** Stop a running flow (and, by default, its still-running tasks). */ stop(runId?: string, opts?: { keepTasks?: boolean; }): Promise; /** Continue a stopped or edited run from its journal and await the result. */ resume(runId?: string, opts?: RunOptions): Promise; /** Archive a run (hide it from the default list). A running run must be stopped first. */ archive(runId: string): { runId: string; archived: true; }; /** Delete a run's record from disk (its tasks are left alone). A running run must be stopped first. */ delete(runId: string): { runId: string; deleted: boolean; }; }; //#endregion export { Job as C, CustomModelConfig as E, Availability as S, CoderConfig as T, FlowStep as _, JobLogEntry as a, GateResult as b, StopSummary as c, log as d, pipeline as f, FlowRecord as g, FlowEvent as h, TaskResult as i, flow as l, DiscoveredFlow as m, flowSdk as n, RunOptions as o, task as p, CoderError as r, RunSummary as s, args as t, gate as u, FlowTaskOptions as v, TurnResult as w, Approval as x, FlowTaskResult as y };