import { Cause, Context, Effect, Layer, Schema, Stream } from "effect"; import type { Prompt } from "effect/unstable/ai"; import { type DriverCheckpoint, type DriverOperation, type OperationOutcome, type ReplayPolicy, type DriverOperationKind } from "./driver-contract.js"; import { DriverError, DriverStateInvalid, type DurableAgentDriver } from "./durable-driver.js"; import { type BudgetLimits, type RunBudget, RunBudgetExhausted, type RunBudgetGrantWidened } from "./run-budget.js"; import type { Agent, RunOptions } from "../agent/agent.js"; import type { HandoffControlState } from "../agent/handoff-state.js"; /** @experimental Operation scheduled at one agent-loop effect boundary. */ export interface OperationSpec { readonly kind: DriverOperationKind; readonly key: string; readonly input: unknown; readonly replayPolicy: ReplayPolicy; readonly turn?: number; } /** @experimental Recorded operation for tests and future runtime journaling. */ export interface RecordedOperation { readonly operation: DriverOperation; readonly outcome: OperationOutcome; readonly checkpoint: DriverCheckpoint; } /** @experimental Host hook surface for durable operation journaling without runtime imports. */ export interface DriverJournal { readonly onScheduled: (operation: DriverOperation, checkpoint: DriverCheckpoint) => Effect.Effect; readonly onCompleted: (operation: DriverOperation, outcome: OperationOutcome, checkpoint: DriverCheckpoint) => Effect.Effect; readonly onCheckpoint: (checkpoint: DriverCheckpoint) => Effect.Effect; } declare const DriverJournalService_base: Context.ServiceClass; /** @experimental Optional host journal service merged into Agent.stream driver layers. */ export declare class DriverJournalService extends DriverJournalService_base { } /** @experimental Caller-owned successful stream result and replay codec. */ export interface StreamSuccessCodec { readonly observe: (value: A) => void; /** Whether the source reached its authored semantic terminal value rather than a downstream consumer stopping early. */ readonly isComplete?: () => boolean; readonly complete: () => Success; readonly replay: (success: Success) => Stream.Stream; } type OperationError = E | DriverError | DriverStateInvalid | DriverUnknownReplay | RunBudgetExhausted; /** @experimental Inline interpreter executing driver operations through Effect services. */ export interface Interface { readonly checkpoint: Effect.Effect; readonly run: (spec: OperationSpec, effect: Effect.Effect) => Effect.Effect, R>; readonly runStream: { (spec: OperationSpec, stream: Stream.Stream): Stream.Stream, R>; (spec: OperationSpec, stream: Stream.Stream, options: { readonly successCodec: StreamSuccessCodec; }): Stream.Stream | ReplayError, R | ReplayServices>; }; readonly recordSuspension: (input: { readonly waitId: string; readonly reason: string; readonly token: string; }) => Effect.Effect; readonly bindResume: (token: string) => Effect.Effect; readonly recorded: Effect.Effect>; readonly abortPending: (error: unknown) => Effect.Effect; readonly chargeUsage: (usage: BudgetLimits) => Effect.Effect; readonly setBudget: (budget: RunBudget) => Effect.Effect; readonly reserveChild: (grant: BudgetLimits) => Effect.Effect; readonly refundChild: (child: RunBudget) => Effect.Effect; readonly setHandoffState: (state: HandoffControlState) => Effect.Effect; } declare const DriverUnknownReplay_base: Schema.Class, Cause.YieldableError>; /** @experimental */ export declare class DriverUnknownReplay extends DriverUnknownReplay_base { } declare const DriverInterpreter_base: Context.ServiceClass; /** @experimental */ export declare class DriverInterpreter extends DriverInterpreter_base { } /** @experimental */ export declare const guardUnknownNeverReplay: { (outcome: OperationOutcome): (operation: DriverOperation) => Effect.Effect; (operation: DriverOperation, outcome: OperationOutcome): Effect.Effect; }; /** @experimental */ export declare const makeInline: (input: { readonly driver: DurableAgentDriver; readonly journal?: DriverJournal; readonly initial: DriverCheckpoint; }) => Effect.Effect; /** @experimental */ export declare const layerInline: (input: { readonly driver: DurableAgentDriver; readonly journal?: DriverJournal; readonly initial: DriverCheckpoint; }) => Layer.Layer; /** @experimental */ export declare const layerForRun: { , R>(options: RunOptions, prompt: Prompt.Prompt, budget?: RunBudget): (agent: Agent) => Layer.Layer; , R>(agent: Agent, options: RunOptions, prompt: Prompt.Prompt, budget?: RunBudget): Layer.Layer; }; /** @experimental */ export declare const layerTest: (input: { readonly driver: DurableAgentDriver; readonly initial: DriverCheckpoint; readonly journal?: DriverJournal; }) => Layer.Layer; /** @experimental */ export declare const operationKey: (logicalOperationId: string, ...parts: ReadonlyArray) => string; export {};