UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

47 lines (46 loc) • 3.03 kB
/** * The leg's gate for the one call the engine itself makes: the `Workflow` call that continues a finished run a person decided * a card of (`orchestration/workflow-park-adoption.ts`). It is not a second gate — it is the leg's one gate pass * (`judgeToolCall`, `prepare-gate-stations.ts`) handed two seats of its own; the model's calls reach the same pass with none. */ import type { PermissionResult, ResolvedAsk } from "../tool-policy.js"; import type { GateDeliveredCall } from "../unavailable-landing.js"; import type { AskUnresolvableCause } from "../ask-unresolvable-notice.js"; import type { WorkflowContinuationGate } from "../../orchestration/workflow-park-adoption.js"; import type { Prepared } from "./contracts.js"; export type { WorkflowContinuationGate }; /** The `tool_call` event one gate pass reads (the harness's own event, as the handler receives it). */ export type GateCallEvent = { readonly type: "tool_call"; readonly toolCallId: string; readonly toolName: string; readonly input: Record<string, unknown>; readonly signal?: AbortSignal; readonly readArguments?: (args: unknown) => unknown; }; /** What the engine's continuation substitutes in one gate pass: the ask's resolver (handed the gate's delivered call, whose landing is * `close` — the pass has no park route) and the unresolvable ask's account. */ export interface ContinuationJudgeSeats { readonly resolveAsk: (decision: PermissionResult, req: GateDeliveredCall, callSignal?: AbortSignal) => Promise<ResolvedAsk>; readonly onAskUnresolvable: (facts: { readonly cause: AskUnresolvableCause; }) => void; } /** * This leg's gate for the `Workflow` call the engine makes to continue a finished run a person decided a card of * (`WorkflowContinuationGate`). The call is judged by the leg's one gate pass (`judgeToolCall`) with two seats swapped: an * ask whose class set is exactly `ordinary` is answered by the person's decision (when the decision is a person's) — a * person's allow, its note naming the continuation — and an ask of any other class goes to the leg's own resolver, which * puts it to the person where a live face exists; with nobody to put it to, the call is refused `ask_unanswerable`. The pass * never parks and raises no halt; its occurrence is closed when the pass ends (no frame of the loop's announces it). */ export declare function continuationGateOf(input: { judgeToolCall: (called: GateCallEvent, seats?: ContinuationJudgeSeats) => Promise<unknown>; resolveAskBound: (decision: PermissionResult, req: GateDeliveredCall, callSignal?: AbortSignal) => Promise<ResolvedAsk>; toolOccurrences: Prepared["toolOccurrences"]; preToolContexts: Map<string, string[]>; blockedToolCalls: Set<string>; /** The calls this gate is judging now: the leg's one fact "no park route for this call" for the pass (its station and its inherited stations read it). */ continuationCalls: Set<string>; now: () => number; }): WorkflowContinuationGate;