UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

48 lines (47 loc) • 4.07 kB
/** * The run's seat for `inherit_env.names_withheld`: the person whose run drives the engine's shell tool is told which * variables of the engine's environment that shell does not receive. * * ONE FACT, ONE MINT. Which entries a shell child loses is decided by the execution environment's one composition * (`inheritedHostEnv(policy, findings)` and the adapter's explicit grants), and the environment hands the result over as * the read `ExecutionEnv.withheldEnv`. This seat reads that answer and tells it; it never recomputes it (the policy and * the grants are the adapter's, not the run's). The split into the scrub's half and the engine's own credentials is * the one the operator notice uses (`withheldEnvNames`). * * WHEN. At the start of every call to the engine's own shell tool (its mount, judged by the catalog's mount judge), on EVERY * leg — a delegated child's shell loses the same entries, and a session whose root only hands work out and whose children run * the shell would otherwise never be told. The notice goes where the leg's notices go (`Prepared.legNotice`): a top-level * leg's to its own session, a delegated leg's to the delegation tree's root, naming the leg whose shell it is about. The answer * is read at each such call because it can grow during a run — a credential the engine takes in when it first routes a * model, dials a peer or builds a seat is withheld from the next child — and a call follows at least one model request. * Told once per SESSION per fact — each leg's own session, so a delegated child tells it once for its shell: the digest of the fact the * mint reports beside the sentence (`mintWithheldEnvUserNotice`'s `fact`: the names under their reasons, the ways out offered, the leg — so * a notice that now names the leg's own entry, or a way out the host now takes, is told again, and the same facts worded otherwise are not) * rides the session's announced record (`advisories`), and a run-time record write is parked for the leg's flush like every other * run-time arm of that record. * * An answer of `"unknown"` is told as unknown, never as silence. A value that is neither a list of findings nor * `"unknown"` (or a read that throws) is a wiring fault: it is announced to the operator under the existing * capability-shape code, once per run, and the person is told nothing — no reading defaults to `"unknown"`. * * The same seat relays the environment's two other disclosures about what its shell gets (`relayLateDeclaration`, * `relayModelShellDropped`, below). */ import { type EngineNotice } from "../engine-notice.js"; import { type PeerEntriesTaken } from "../secret-env.js"; import type { ExecutionEnv } from "../../internal/harness.js"; import type { Prepared } from "./contracts.js"; export type WithheldShellEnvSeatInput = Pick<Prepared, "runId" | "sessionId" | "legNotice" | "toolRosterDeltas" | "announcedListingsRef" | "frameReceipts"> & { readonly harness: { readonly env: Pick<ExecutionEnv, "withheldEnv" | "inheritEnvForms" | "lateDeclarationNotice" | "modelShellDropped">; }; }; /** The seat, per run. `onToolStart` and `onToolEnd` never throw: a diagnostic may not be what fails a call. `peerEntries` = the (variable, * entry) pairs the leg's receipt took in (leg-receipt.ts `LegReceipt.peerEntries`) and `isolationScope` = the leg's isolation scope * (isolation-scope.ts `legIdentityOf`): the entries its notice names, each for its variable, are those pairs and the ones the host declared * to every leg or to the scope of the session the notice is delivered to — read off the leg's one notice route (`Prepared.legNotice`: * a delegated leg's root address carries its scope), by the notice's own reading (secret-env.ts `withheldEnvUserNotice`). */ export declare function createWithheldShellEnvSeat(prepared: WithheldShellEnvSeatInput, onNotice: ((notice: EngineNotice) => void) | undefined, peerEntries: PeerEntriesTaken | undefined, isolationScope?: string): { onToolStart(toolName: string): void; onToolEnd(): void; };