UNPKG

eve

Version:

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

55 lines (54 loc) 2.75 kB
/** Continuation delivery for task-owned agent sessions. */ import type { SessionAuthContext } from "#channel/types.js"; import type { AgentAddress } from "#subagents/handles/store.js"; import type { RuntimeAgentDispatchRequest, RuntimeRemoteAgentDispatchRequest, RuntimeSubagentDispatchRequest, RuntimeSubagentDispatchFailure } from "#shared/action-types.js"; import type { CompiledBundle } from "#runtime/sessions/runtime-context-keys.js"; import type { hydrateDurableSession } from "#execution/session.js"; import type { TaskOwnedAgentHandle } from "#subagents/handles/store.js"; /** Agent-task requests that may address an agent handle via `agentId`. */ export type RuntimeAgentHandleAction = RuntimeRemoteAgentDispatchRequest | RuntimeSubagentDispatchRequest; /** Narrows an action to the kinds that may carry an `agentId` continuation. */ export declare function isAgentHandleAction(action: RuntimeAgentDispatchRequest): action is RuntimeAgentHandleAction; /** Hydrated parent session snapshot threaded through dispatch. */ export type RuntimeSession = ReturnType<typeof hydrateDurableSession>; /** * Outcome of dispatching one planned agent task: an adopted child ready for * the `subagent.called` emission tail, or a per-task error result. * Either way the (possibly updated) session snapshot rides along. * * `address` is the same confirmed {@link AgentAddress} recorded on the * child's running handle; consumers project it into wire shapes (e.g. the * flat `childSessionId` / `remote` fields of `subagent.called`) at the * emission site instead of this type re-encoding them. */ export type DispatchOutcome = { readonly address: AgentAddress; readonly callId: string; readonly kind: "called"; readonly name: string; readonly session: RuntimeSession; readonly toolName: string; } | { readonly deliveryAmbiguous?: boolean; readonly deliveryPermanent?: boolean; readonly kind: "error"; readonly result: RuntimeSubagentDispatchFailure; readonly session: RuntimeSession; }; /** Delivers a continuation after the session handle store atomically claimed it for one owner. */ export declare function dispatchToClaimedAgentAddress(input: { readonly action: RuntimeAgentHandleAction; readonly auth: SessionAuthContext | null; readonly bundle: CompiledBundle; readonly currentSession: RuntimeSession; readonly parentToken: string; readonly handle: Extract<TaskOwnedAgentHandle, { phase: "claimed"; }>; readonly taskId?: string; }): Promise<DispatchOutcome>; export declare function createAgentErrorResult(input: { readonly action: RuntimeAgentHandleAction; readonly code: string; readonly message: string; }): RuntimeSubagentDispatchFailure;