@sema-agent/core
Version:
Stateless, task-oriented AI agent core
54 lines (53 loc) • 3.7 kB
TypeScript
import type { RunnerDeps, ToolEffect } from "../types.js";
import type { IrreversibilityTier, ReversibilityProbes } from "./contracts.js";
import type { ToolMarkSource } from "../ask-origin.js";
import { type CallerRosterSpec } from "./caller-roster.js";
export interface PrepareSafetyScanInput {
/** borrowed-readonly — the REBOUND spec (`spec′`, the config-doors result). The scan reads
* `tools`, `handsReadOnly` and `enablePlanMode`; it never mutates. Typed as a spec whose roster is snapshot faces (it reads no
* `durableApproval`, so the snapshot's own type is its input's). */
spec: CallerRosterSpec;
/** borrowed-readonly — read only for the hands-enablement fact (`executionEnvFactory`/
* `executionEnv` presence puts the hand band among the wake candidates). */
deps: RunnerDeps;
}
/**
* The scan's outputs. Ownership annotations (four-class form):
*
* The six collections are **borrowed-mutable**: the driver and later phases fold into them IN
* PLACE (identity is part of the contract — closures alias these exact objects). Mutation owners
* after this phase, in driver order:
* · the roster builder (`toolEffects`: every mount and unmount);
* · the MCP/A2A materialize fold + the runtime refresh seam (protocol-axis tighten registration and a protocol tool's effect;
* on refresh, `toolEffects.delete` resets a replaced tool's effect record for the fresh fold —
* the irreversible/egress sets deliberately KEEP their entries, the tighten-only residue);
* · the hands/read-face block's shellGate fold (Bash/Monitor tier escalation + probe seeding).
*/
export interface PrepareSafetyScanResult {
/** borrowed-mutable — per-tool effect registry (alias-complete), the path-policy / gate read. Minted EMPTY here: the roster
* builder writes every entry, a caller tool's included, from the member that answers to the name after each mount or unmount. */
toolEffects: Map<string, ToolEffect>;
/** owned, read once — the wake reconcile's reading (`wakeEffectsOf`): the caller tools' own declarations (each name's kept
* instance, each alias's first claimer), with every catalog definition this leg may still mount (`engineCandidatesOf`) folded
* in as a candidate. Built before any mount; no later phase writes it. */
wakeEffects: Map<string, ToolEffect>;
/** borrowed-mutable — egress-marked tools (external writes; the gate never auto-allows them). */
egressTools: Set<string>;
/** borrowed-mutable — tools whose effect is irreversible (`always`, or `maybe` incl. by probe). */
irreversibleTools: Set<string>;
/** borrowed-mutable — static per-tool irreversibility tier (prepare-time resolution). */
irreversibilityTier: IrreversibilityTier;
/** borrowed-mutable — explicit NEGATIVE axis judgments (report-face only; `riskAxesOf` reads). */
axisExplicitNegatives: Map<string, {
irreversible?: false;
egress?: false;
}>;
/** borrowed-mutable — declared reversibility probes by tool name. */
reversibilityProbes: ReversibilityProbes;
/** borrowed-mutable — WHO put each tool's egress / irreversibility mark on its seat (the caller roster's marks are
* the deployment's own; the protocol fold adds `mcp_annotation` / `a2a_default`). Read by the gate's class
* derivation: a mark with no recorded source reads as the deployment's (fail-closed). */
toolMarkSources: Map<string, Set<ToolMarkSource>>;
}
/** The B-2 phase body — the safety-scan slice, verbatim (see the module header for the contract). */
export declare function prepareSafetyScan(input: PrepareSafetyScanInput): PrepareSafetyScanResult;