import type { CompiledGraph } from "../core/graph.js"; import { type ArtifactReference, type ExecutionLimits, type GraphCheckpointRef, type GraphEvent, type GraphExecutionState, type SideEffectExecutionState } from "../core/scheduler.js"; export interface GraphExecutionCursor { graphId: string; graphVersion: string; nodeId: string; state: State; step: number; } export interface NodeResult { event: Event; output?: Output; evidence?: Record; usage?: { observedCostUsd: number | "unknown"; inputTokens: number | "unknown"; outputTokens: number | "unknown"; }; } export interface GraphRuntime { reduce(state: State, event: Event): State; resolveEdge(previous: State, event: Event, next: State): string; stateNode(state: State): string; runNode(nodeId: string, state: State, context: Context): Promise>; isCurrent(cursor: Readonly>, context: Context): boolean; } export declare function executeGraphStep(graph: CompiledGraph, cursor: Readonly>, runtime: GraphRuntime, context: Context): Promise>; export interface ScheduledSideEffect { class: SideEffectExecutionState["class"]; requestRef: string; idempotencyKey: string; checkpointRef?: GraphCheckpointRef; routingDecisionId?: string; estimatedUsage?: { estimatedCostUsd: number | "unknown"; inputTokens?: number | "unknown"; outputTokens?: number | "unknown"; }; persistResult(result: Readonly>): Promise; recoverResult(reference: Readonly): Promise>; reconcileIntent?(persisted: Readonly): Promise<{ outcome: "succeeded"; resultRef: ArtifactReference; result: NodeResult; } | { outcome: "failed" | "unknown"; }>; } export interface ScheduledGraphPersistence { checkpoint(current: Readonly, event: Readonly): Promise; } export interface ScheduledGraphStepOptions { schedulerState: Readonly; limits: ExecutionLimits; unattended: boolean; now(): string; persistence: ScheduledGraphPersistence; prepareSideEffect?(nodeId: string, state: Readonly, context: Context): Promise> | ScheduledSideEffect; completion?(result: Readonly>): { artifactRefs: ArtifactReference[]; validatorResult?: GraphEvent["validatorResult"]; }; } export interface ScheduledGraphStepResult { cursor: GraphExecutionCursor; schedulerState: GraphExecutionState; } /** * Durable additive runner. The caller owns immutable artifact persistence and * append-before-snapshot checkpointing; this function owns admission order and * refuses to repeat an ambiguous effect. */ export declare function executeScheduledGraphStep(graph: CompiledGraph, cursor: Readonly>, runtime: GraphRuntime, context: Context, options: ScheduledGraphStepOptions): Promise>;