UNPKG

eve

Version:

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

62 lines (61 loc) 3.66 kB
import type { RuntimeToolResultActionResult } from "#shared/action-types.js"; import type { SessionStateMap } from "#harness/types.js"; import { type ActivityWorkIdentityV1 } from "#protocol/activity.js"; import { type TaskMetadata, type TaskView } from "#tasks/types.js"; import type { DurableDynamicSubagentSelection, SessionAuth } from "#context/keys.js"; export declare const WORKFLOW_TOOL_RUNS_STATE_KEY = "eve.workflowTool"; export interface WorkflowTaskPayload { readonly taskId: string; readonly metadata: TaskMetadata; readonly dispatchContext: TaskAgentDispatchContext; readonly activityWorkIdentity?: ActivityWorkIdentityV1; readonly cohortId?: string; /** Parent-owned outcome. Read through readWorkflowTaskView before consuming it. */ readonly outcome?: unknown; } interface WorkflowToolRunBase { readonly callId: string; readonly toolName: string; readonly origin: { readonly turnId: string; readonly stepIndex: number; }; readonly address: { readonly runId: string; readonly hookToken: string; }; } export type BlockingWorkflowToolRun = WorkflowToolRunBase & { readonly lifetime: "turn"; }; export type BackgroundWorkflowToolRun = WorkflowToolRunBase & { readonly lifetime: "session"; readonly task: WorkflowTaskPayload; }; export type WorkflowToolRun = BlockingWorkflowToolRun | BackgroundWorkflowToolRun; export interface TaskAgentDispatchContext { readonly auth: SessionAuth; readonly sessionDynamicSubagentSelections?: Readonly<Record<string, DurableDynamicSubagentSelection>>; readonly turnDynamicSubagentSelections?: Readonly<Record<string, DurableDynamicSubagentSelection>>; } /** Decode retained output only when it is consumed, independently of ownership reads. */ export declare function readWorkflowTaskView(task: WorkflowTaskPayload): TaskView | undefined; export declare function getWorkflowToolRuns(state: SessionStateMap | undefined): readonly WorkflowToolRun[]; export declare function getBackgroundWorkflowToolRuns(state: SessionStateMap | undefined): readonly BackgroundWorkflowToolRun[]; export declare function getBlockingWorkflowToolRuns(state: SessionStateMap | undefined, turnId?: string): readonly BlockingWorkflowToolRun[]; export declare function findBackgroundWorkflowToolRun(state: SessionStateMap | undefined, taskId: string): BackgroundWorkflowToolRun | undefined; /** Registration is idempotent by originating turn and call; retained task facts survive replay. */ export declare function registerWorkflowToolRun<T extends { readonly state?: SessionStateMap; }>(session: T, entry: WorkflowToolRun): T; /** Task payloads remain available for the session lifetime, including after report delivery. */ export declare function recordWorkflowTaskView(state: SessionStateMap | undefined, view: TaskView): SessionStateMap | undefined; /** Removes only this turn's waiting calls. Session-owned task payloads are never pruned here. */ export declare function removeBlockingWorkflowToolRuns<T extends { readonly state?: SessionStateMap; }>(session: T, turnId: string, callId?: string): T; /** Results without an originating turn may bind only when exactly one recorded turn owns the call. */ export declare function findBlockingWorkflowToolRun(state: SessionStateMap | undefined, callId: string, turnId?: string): BlockingWorkflowToolRun | undefined; /** The turn inbox is shared; a result settles a call only if the turn recorded that run. */ export declare function isInboxToolResultFromRecordedWorkflowToolRun(state: SessionStateMap | undefined, result: RuntimeToolResultActionResult): boolean; export {};