UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

26 lines (25 loc) • 1.61 kB
import type { CommandSandboxInstruction } from "./command-sandbox.js"; /** One call's command sandbox plan, minted where the gate lets the call go, on the input it lets go: * · `command` — every start of the call carries `instruction` to its environment (`ignoreViolations`: what of the sandbox's * reports the requirement says not to show for it); * · `unsandboxed` — the call's starts run outside the run's sandbox: by the call's own `dangerouslyDisableSandbox`, which the * run lets take effect (`escape`), or because the run's sandbox stopped working and the task does not require it (`lapsed`); * · `refused` — no start of the call can be had in the sandbox the run requires (`reason` says why): each is refused; * · `none` — the call is not one the run sandboxes. */ export type CommandSandboxPlan = { readonly kind: "none"; } | { readonly kind: "command"; readonly instruction: CommandSandboxInstruction; readonly ignoreViolations?: Readonly<Record<string, readonly string[]>>; } | { readonly kind: "unsandboxed"; readonly by: "escape" | "lapsed"; } | { readonly kind: "refused"; readonly reason: string; }; /** Run one call's execution under its plan. An execution handed no plan runs under none, never under an enclosing call's. */ export declare function runWithCommandSandboxPlan<T>(plan: CommandSandboxPlan | undefined, execute: () => T): T; /** The plan of the call whose execution is running here, or `undefined` when no dispatch put one there. */ export declare function commandSandboxPlanInForce(): CommandSandboxPlan | undefined;