/** * exec/step — per-node handlers for the event-sourced kernel (RFC §6.3, S2). * * Kernel covers `EVENT_KERNEL_PHASE_TYPES` (PHASE_TYPES minus `race`/`expand` — * currently 10 kinds). Complex paths live in `./step-kinds.ts`. Does **not** * import `runtime.ts` (avoids circular deps with the strangler). */ import type { Phase, Taskflow } from "../schema.ts"; import { PHASE_TYPES } from "../schema.ts"; import type { RunState } from "../store.ts"; import type { DirectoryIdentity } from "../cwd-bridge.ts"; import type { AgentConfig } from "../agents.ts"; import type { RunOptions, RunResult } from "../host/runner-types.ts"; import type { Event } from "./events.ts"; import { type UsageStats } from "../usage.ts"; import { type InterpolationContext } from "../interpolate.ts"; /** All DSL phase types — S2 kernel is complete. */ /** Kernel kinds: original 10. Horizon B `race`/`expand` run on the imperative * path until dedicated step handlers land (canUseEventKernel excludes them). */ export declare const EVENT_KERNEL_PHASE_TYPES: readonly (typeof PHASE_TYPES)[number][]; export type EventKernelPhaseType = (typeof EVENT_KERNEL_PHASE_TYPES)[number]; export type RunTaskFn = (cwd: string, agents: AgentConfig[], agentName: string, task: string, opts: RunOptions, globalThinking?: string) => Promise; /** Mirrors runtime ApprovalRequest — kept local to avoid step↔runtime cycles. */ export interface KernelApprovalRequest { phaseId: string; message: string; upstream?: string; } export interface KernelApprovalDecision { decision: "approve" | "reject" | "edit"; note?: string; } export interface NestedFlowResult { finalOutput: string; ok: boolean; usage: UsageStats; events: Event[]; blocked?: boolean; } export interface StepDeps { cwd: string; agents: AgentConfig[]; runTask: RunTaskFn; signal?: AbortSignal; globalThinking?: string; requestApproval?: (req: KernelApprovalRequest) => Promise; loadFlow?: (name: string) => Taskflow | undefined; loadSavedFlow?: (name: string) => { def: Taskflow; filePath?: string; sourceDirIdentity?: DirectoryIdentity; } | undefined; /** Sub-flow call stack (recursion guard). */ stack?: string[]; /** Nested flow runner (driver injects runEventKernel). */ runNested?: (opts: { def: Taskflow; args: Record; stack: string[]; dynamic?: boolean; flowSourceFile?: string; flowSourceDirIdentity?: DirectoryIdentity; }) => Promise; } export interface StepContext { state: RunState; deps: StepDeps; steps: InterpolationContext["steps"]; args: Record; /** Successful interpolation reads captured during this phase. The driver * persists them as PhaseState.reads for event-kernel provenance parity. */ readRefs?: string[]; /** Exact prompt for every actual subagent attempt in this phase. */ promptCalls?: string[]; } export interface StepResult { events: Event[]; output?: string; partialOutput?: true; status: "done" | "failed" | "skipped" | "timedOut"; error?: string; /** Token/cost usage for this phase (empty for script / skipped). */ usage: UsageStats; /** Total runner attempts, including automatic transient retries. */ attempts?: number; gate?: { verdict: "pass" | "block"; reason?: string; }; approval?: { decision: "approve" | "reject" | "edit"; note?: string; auto?: boolean; }; warnings?: string[]; /** Prompt-size diagnostics for the kernel path (parity with the imperative * PhaseState.promptStats). `calls` has one entry per resolved subagent * prompt; `reduceInputs` carries aggregate stats for reduce phases. */ promptStats?: { calls: Array<{ bytes: number; chars: number; estTokens: number; }>; reduceInputs?: { count: number; totalBytes: number; totalChars: number; totalEstTokens: number; }; }; } /** Accumulate usage from subagent-call events in a result. */ export declare function usageFromEvents(events: readonly Event[]): UsageStats; /** Run a shell script phase (no LLM). Captures stdout. */ export declare function stepScript(phase: Phase, ctx: StepContext): Promise; /** Run a single agent phase via the injected runner. */ export declare function stepAgent(phase: Phase, ctx: StepContext): Promise; /** * Dispatch one phase kind. Returns null if kind is not handled by this slice. * Emits phase-start → optional when-guard decision → work → phase-end. */ export declare function stepPhase(phase: Phase, ctx: StepContext): Promise; //# sourceMappingURL=step.d.ts.map