UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

88 lines (87 loc) 4.1 kB
import type { DeliverPayload, SessionAuthContext } from "#channel/types.js"; import type { HarnessSession, StepInput } from "#harness/types.js"; import type { TokenUsage } from "#shared/token-usage.js"; import type { JsonObject } from "#shared/json.js"; import type { RunMode } from "#shared/run-mode.js"; import { type DurableSessionState } from "#execution/durable-session-store.js"; import { type TurnStepInput, type TurnWorkflowDispatchInput } from "#execution/durable-session-migrations/turn-workflow.js"; /** * Result of one durable harness step, consumed by the turn workflow. * * `park` carries `hasPendingInputBatch`, `hasPendingAuthorization`, and * `pendingRuntimeActionKeys` so the turn workflow can pick the right * {@link import("#execution/next-driver-action.js").NextDriverAction} * arm without re-reading the session. * * `cancelled` converts the harness's cancellation throw into a *returned* * result so workflow-core never classifies the abort as a step failure or * retries it; the epilogue runs in `settleCancelledTurnStep`. */ export type DurableStepResult = { readonly action: "continue" | "done"; readonly output?: unknown; readonly isError?: boolean; readonly serializedContext: Record<string, unknown>; readonly sessionState: DurableSessionState; /** Session-total token usage; set on `done` when the session spent any. */ readonly usage?: TokenUsage; } | { readonly action: "cancelled"; readonly serializedContext: Record<string, unknown>; readonly sessionState: DurableSessionState; } | { readonly action: "park"; readonly authorizationNames?: readonly string[]; readonly hasPendingAuthorization: boolean; readonly hasPendingInputBatch: boolean; readonly pendingRuntimeActionKeys?: readonly string[]; readonly serializedContext: Record<string, unknown>; readonly sessionState: DurableSessionState; } | { readonly action: "dispatch-workflow-runtime-actions"; readonly pendingRuntimeActionKeys: readonly string[]; readonly serializedContext: Record<string, unknown>; readonly sessionState: DurableSessionState; }; export type { TurnStepInput }; /** * Runs one atomic harness step inside a durable `"use step"` boundary. */ export declare function turnStep(rawInput: TurnStepInput): Promise<DurableStepResult>; /** * Resolves the single output schema in effect for this turn, decoupling schema * enforcement from {@link RunMode}: downstream the harness reads * `session.outputSchema` unconditionally and never re-derives it from mode. * * A run-scoped (client-supplied) schema on the turn's {@link StepInput} always * wins. With no run-scoped schema, a task run adopts the agent's declared * return schema — its function-output contract, which only applies when the * agent is invoked as a function (subagent / schedule / job), i.e. task mode. * A conversation run with no run-scoped schema enforces nothing. Continuation * steps (no new `StepInput`) preserve whatever is already in effect. */ export declare function resolveEffectiveOutputSchema(input: { readonly agentOutputSchema: JsonObject | undefined; readonly input: StepInput | undefined; readonly mode: RunMode; readonly session: HarnessSession; }): HarnessSession; export interface RoutedDeliverResult { /** `undefined` when the entire payload was routed to descendants. */ readonly remainder: DeliverPayload | undefined; } /** * Splits an inbound deliver payload into parent-local and * proxied-child buckets and forwards the child buckets via * `resumeHook`. Read-only: never appends a snapshot. */ export declare function routeProxiedDeliverStep(input: { readonly auth?: SessionAuthContext | null; readonly parentWritable: WritableStream<Uint8Array>; readonly payload: DeliverPayload; readonly sessionState: DurableSessionState; }): Promise<RoutedDeliverResult>; /** Starts a per-turn child workflow for the current driver session. */ export declare function dispatchTurnStep(input: TurnWorkflowDispatchInput): Promise<{ readonly runId: string; }>;