eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
66 lines (65 loc) • 3.12 kB
TypeScript
/** Continuation delivery for task-owned agent sessions. */
import type { ActivityObserverConfig, 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;
};
/**
* Where the callee reports its result. A new turn replies to the caller's
* hook; steering an active turn keeps that turn's original reply target.
*/
export type AgentReplyTarget = {
readonly kind: "reply";
readonly parentToken: string;
readonly taskId?: string;
} | {
readonly kind: "steer";
};
/** Delivers a continuation after the session handle store atomically claimed it for one owner. */
export declare function dispatchToClaimedAgentAddress(input: {
readonly activityObserver?: ActivityObserverConfig;
readonly action: RuntimeAgentHandleAction;
readonly auth: SessionAuthContext | null;
readonly bundle: CompiledBundle;
readonly currentSession: RuntimeSession;
readonly handle: Extract<TaskOwnedAgentHandle, {
phase: "claimed";
}>;
readonly reply: AgentReplyTarget;
}): Promise<DispatchOutcome>;
export declare function createAgentErrorResult(input: {
readonly action: RuntimeAgentHandleAction;
readonly code: string;
readonly message: string;
}): RuntimeSubagentDispatchFailure;