import { type AgentState, type GraphNode, type SkillGraph } from "./graph.ts"; import { JevClient } from "./jev/client.ts"; import type { JevConfig } from "./jev/types.ts"; import { type TrustedPilotContext } from "./jev/ownership.ts"; import { aggregateJevReceiptSpend, type JevAggregatedSpend } from "./jev/budget.ts"; import { type StagePreparation } from "./preparation.ts"; export interface PrepareStageOptions { promptOverride?: string; root: string; kernel: string; graph: SkillGraph; state: AgentState; nodeId?: string; includeOptional?: boolean; jevConfig?: JevConfig; jevClient?: JevClient; /** Mock or custom transport used when this function constructs the client. Not a prebuilt client. */ jevFetch?: typeof fetch; signal?: AbortSignal; /** Kernel-issued pilot context. Never loaded from site jev.json. */ pilotContext?: TrustedPilotContext; kernelRevision?: string; } export interface PrepareStageResult { status: "prepared" | "no_eligible_node" | "already_complete" | "awaiting_user" | "repair_required"; node?: GraphNode; preparation?: StagePreparation; reused?: boolean; previewReady: boolean; instructions?: string; } export interface CompleteStageOptions { evaluate?: () => { failures: string[]; }; executionFailures?: string[]; invocationId?: string; root: string; kernel: string; graph: SkillGraph; state: AgentState; preparationId: string; nodeId?: string; jevConfig?: JevConfig; durationMs?: number; agentUsage?: { inputTokens?: number; outputTokens?: number; measured: boolean; rawEvidencePath?: string; }; visualToolEvents?: Array<{ tool: string; path: string; success: boolean; hash?: string; }>; environment?: string; crashInjection?: "before_journal" | "before_state" | "after_journal" | "after_state" | "after_prep"; } export interface CompleteStageResult { ok: boolean; nodeId: string; preparationId: string; failures: string[]; state: AgentState; preparation: StagePreparation; idempotentReplay?: boolean; } export interface ExecuteToolOptions { root: string; kernel: string; graph: SkillGraph; state: AgentState; node: GraphNode; timeoutMs?: number; signal?: AbortSignal; injectedExecutor?: () => Promise; } export interface ExecuteToolResult { ok: boolean; nodeId: string; exitCode: number; failures: string[]; durationMs: number; stdout: string; stderr: string; } /** Enrich prompt with kernel commands, requests, memory, and review scopes. */ export declare function enrichPrompt(root: string, kernel: string, node: GraphNode, base: string): string; /** * Pure state transition function: computes the target state in memory * without performing any disk mutations. */ export { computeNextState } from "./state-transition.ts"; export type { JevAggregatedSpend }; export { aggregateJevReceiptSpend }; /** * Prepares the next stage in the workflow. * Atomic, durable, and idempotent: if inputs have not changed, returns the existing preparation. * Does not increment attempts or mutate STATE.json. */ export declare function prepareStage(opts: PrepareStageOptions): Promise; /** * Executes a deterministic tool stage locally without any model adapter. * Validates eligibility, checks capture and allowed writes boundaries, * handles abort signals, and updates state via two-phase commit journal. */ export declare function executeToolStage(opts: ExecuteToolOptions): Promise; /** * Completes a prepared stage with strict provenance, allowed-writes enforcement, * manifest and partition verification, and crash-safe two-phase commit journaling. */ export declare function completeStage(opts: CompleteStageOptions): Promise; /** Cancels an active stage preparation and releases its durable lease without consuming attempts. */ export declare function cancelStage(opts: { root: string; preparationId: string; reason?: string; }): void; /** Read-only status inspection. */ export declare function inspectStatus(opts: { root: string; kernel: string; graph: SkillGraph; state: AgentState; }): { state: AgentState; nextNode: string | undefined; previewReady: boolean; activePreparation: { id: string; nodeId: string; preparedAt: string; } | null; };