/** * The execution frame each action invocation runs in, and the evidence a * dispatcher vouched for that one invocation. Not in the package exports: the * action entry exposes no frame-evidence helpers, and request input or * `ActionRunContext` fields never become evidence. Trusted server dispatcher * APIs (`executeAgentToolCall`, `runAgentLoop`) can still supply approval and * attribution. Nothing here imports `action.ts` at runtime, so `action.ts` and * the audit helpers import it without a cycle. */ import type { ActionCallRecord, ActionExecutionOutcome, ActionRunContext } from "./action.js"; import type { AuditOverride } from "./audit/attribution.js"; /** * Carries an action's execution-frame key across `{ ...entry, run }` wrappers * and the registry rebuilds that copy named fields (`preserveActionFlags`). */ export declare const ACTION_EXECUTION_KEY: unique symbol; export type ActionExecutionRun = (args: any, ctx?: ActionRunContext) => Promise; /** * What vouched for one invocation, and the ids its audit rows record in place * of its run's own. Only the dispatcher that opens the invocation's frame sets * it, and a child runs in a frame of its own, so no other invocation has it, * whatever context it is given. */ export type ActionInvocationEvidence = { approvedToolCallKey?: string; /** The MCP client accepted this exact call's approval elicitation. */ mcpClientAccepted?: true; auditOverride?: AuditOverride; }; export type ActionExecutionFrame = { key: object; run: ActionExecutionRun; parent?: ActionExecutionFrame; handlerEntered: boolean; /** A write entered its handler in this call or in one nested in it. */ writeEntered: boolean; /** One of those writes publishes action changes. */ changeEntered: boolean; /** This call's classification, once validated arguments set it. */ writes?: boolean; emitsChange?: boolean; boundaryPending?: boolean; /** The call's record, and the context it ran with, once validated. */ record?: ActionCallRecord; context?: ActionRunContext; nestedWriteEntered?: boolean; raised?: unknown; /** The dispatcher's outcome, which takes the record as it is made. */ outcome?: ActionExecutionOutcome; }; export type ActionExecutionState = { frame?: ActionExecutionFrame; failures: WeakMap; }; export declare const actionExecutionStorage: import("async_hooks").AsyncLocalStorage | undefined; /** * Vouch for the one call a dispatcher runs with `outcome`: the frame that run * opens holds `evidence` until the promise `run` returned settles, not until a * stream or iterator it returned is consumed. */ export declare function vouchedOutcome(outcome: T, evidence: ActionInvocationEvidence | undefined): T; /** The evidence vouched for the run observed by `outcome`, taken once. */ export declare function takeVouchedEvidence(outcome: object): ActionInvocationEvidence | undefined; export declare function holdInvocationEvidence(frame: ActionExecutionFrame, evidence: ActionInvocationEvidence | undefined): void; export declare function endInvocationEvidence(frame: ActionExecutionFrame): void; /** The evidence of the invocation running now, never a caller's or a settled one's. */ export declare function currentInvocationEvidence(): ActionInvocationEvidence | undefined; /** * Run a dispatcher's own work outside the invocation it runs inside. A frame's * evidence belongs only to rows about that frame's own call, so a row about * another call is recorded here. */ export declare function runOutsideActionInvocation(fn: () => T): T;