@sema-agent/core
Version:
Stateless, task-oriented AI agent core
834 lines • 60.7 kB
TypeScript
import { Type, type Static, type TSchema } from "typebox";
import type { AgentTool } from "../internal/harness-types.js";
import { type ToolContractFace } from "../prompt-assembly/tool-catalog.js";
import { ToolMountLedger, type ToolMountPlan, type ToolMountPlanExecutionEnv, type ToolMountSource } from "./tool-mount-plan.js";
import { type ReservedApprovalCard, type ToolApprovalCard, type ToolCatalogEntry, type ToolFamily, type ToolHostTarget, type ToolRosterPathTarget, type ToolMountTag, type ToolPathTarget, type ToolRenderHints, type ToolRuleFace } from "./tool-face.js";
import type { ToolContentOrigin, ToolEffect } from "./tool-spec.js";
/**
* The most rows one tool roster carries — the ONE bound on its size: the schema's `entries.maxItems` reads it, and the
* builder refuses a set that would mint more at both places a roster takes its shape (the prepare-time mint and the run-time
* domain swap, {@link rosterEntryCountProblem}). A row is one distinct tool NAME (two mounts under a name are one row; an
* alias is no row; a deferred tool is a row — it rides the frame as one). A set over it is refused where it forms, never cut:
* which source would lose its tools is a priority nothing declares. A host that wants to know before it asks reads this.
*/
export declare const TOOL_ROSTER_MAX_ENTRIES = 2048;
export declare const ROSTER_SOURCES: readonly ["builtin", "caller", "host", "mcp", "a2a", "external", "synthetic"];
export type RosterSource = (typeof ROSTER_SOURCES)[number];
export declare const ToolRosterRenderHints: Type.TObject<{
userFacingName: Type.TOptional<Type.TString>;
activity: Type.TOptional<Type.TString>;
summaryParams: Type.TOptional<Type.TArray<Type.TString>>;
resultCards: Type.TOptional<Type.TArray<Type.TString>>;
approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">, Type.TLiteral<"computer-access">, Type.TLiteral<"computer-control">, Type.TLiteral<"network">]>>;
}>;
export declare const ToolRosterEntry: Type.TObject<{
name: Type.TString;
/** Always present (empty when the tool answers to no other name). */
aliases: Type.TArray<Type.TString>;
source: Type.TUnion<[Type.TLiteral<"builtin">, Type.TLiteral<"caller">, Type.TLiteral<"host">, Type.TLiteral<"mcp">, Type.TLiteral<"a2a">, Type.TLiteral<"external">, Type.TLiteral<"synthetic">]>;
/** Present iff `source` ∈ {mcp, a2a, external} (run-time validated at the mint). */
origin: Type.TOptional<Type.TObject<{
peer: Type.TString;
declaredBy: Type.TOptional<Type.TUnion<[Type.TLiteral<"center">, Type.TLiteral<"file">, Type.TLiteral<"request">]>>;
}>>;
/** The name the MCP server lists the tool under and a call is sent under, byte-exact — present iff `name` does not spell it
* (its protocol segment is the provider-charset fold, or the clamp, of another spelling: `foo.bar` and `foo_bar` both mount
* as `mcp__<server>__foo_bar`). Absent, the server's name IS that segment. An identity member ({@link mintCapabilityId}). */
remoteName: Type.TOptional<Type.TString>;
/** Undeclared ⇒ `legacy:<shapeDigest>` / `unversioned`. */
contract: Type.TObject<{
contractId: Type.TString;
implementationRevision: Type.TString;
}>;
shapeDigest: Type.TString;
wireSchemaDigest: Type.TString;
/** `builtin:<name>` | `caller:<contractId>` | `mcp:<peer>/<tool>` | `a2a:<peer>/<skill>` | `external:<contractId>`. */
cardId: Type.TString;
/** ENGINE-minted: sha256 prefix over the canonical tuple {source, peer, name, contractId, remote?} (`remote` = `remoteName`,
* only when the row carries it); unique per leg. */
capabilityId: Type.TString;
/** The materialized schema's top-level properties (name + coarse type). */
inputKeys: Type.TArray<Type.TObject<{
name: Type.TString;
type: Type.TUnion<[Type.TLiteral<"string">, Type.TLiteral<"number">, Type.TLiteral<"integer">, Type.TLiteral<"boolean">, Type.TLiteral<"object">, Type.TLiteral<"array">, Type.TLiteral<"null">, Type.TLiteral<"mixed">]>;
}>>;
effect: Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"write">, Type.TLiteral<"idempotent">]>;
effectProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"caller">, Type.TLiteral<"synthetic">, Type.TLiteral<"default">]>;
offload: Type.TBoolean;
offloadThresholdChars: Type.TOptional<Type.TInteger>;
compactable: Type.TBoolean;
budgetExempt: Type.TBoolean;
egress: Type.TBoolean;
egressProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"caller">, Type.TLiteral<"default">]>;
irreversibility: Type.TOptional<Type.TUnion<[Type.TLiteral<"never">, Type.TLiteral<"maybe">, Type.TLiteral<"always">]>>;
reversibilityProbe: Type.TBoolean;
contentOrigin: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"execution">, Type.TLiteral<"external">]>;
contentOriginProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"server">, Type.TLiteral<"exempted">, Type.TLiteral<"default">]>;
family: Type.TUnion<[Type.TLiteral<"shell">, Type.TLiteral<"file-read">, Type.TLiteral<"file-write">, Type.TLiteral<"search">, Type.TLiteral<"web">, Type.TLiteral<"delegate">, Type.TLiteral<"plan">, Type.TLiteral<"scaffold">, Type.TLiteral<"memory">, Type.TLiteral<"protocol">, Type.TLiteral<"other">]>;
/** The legs a call of this tool travels (`BOUNDARY_LEGS`), or `"per_call"` when its dispatch gives them per call: the engine's own
* definitions and the protocol tools state them, every other row follows its `effect` (`rosterBoundaryLegs`). */
boundaryLegs: Type.TUnion<[Type.TLiteral<"per_call">, Type.TArray<Type.TUnion<[Type.TLiteral<"env">, Type.TLiteral<"outside_read">, Type.TLiteral<"outside_write">]>>]>;
pathTarget: Type.TOptional<Type.TObject<{
param: Type.TString;
aliases: Type.TArray<Type.TString>;
access: Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"create">, Type.TLiteral<"edit">]>;
skillScopeEligible: Type.TBoolean;
base: Type.TOptional<Type.TUnion<[Type.TLiteral<"cwd">, Type.TLiteral<"root">]>>;
absent: Type.TOptional<Type.TUnion<[Type.TLiteral<"none">, Type.TLiteral<"base">]>>;
patternParam: Type.TOptional<Type.TString>;
each: Type.TOptional<Type.TLiteral<true>>;
}>>;
/** The URL slot a host rule of the row's name is read on, as the definition declared it ({@link ToolHostTarget}); absent when
* it declares none. Exclusive with `pathTarget`. */
hostTarget: Type.TOptional<Type.TObject<{
param: Type.TString;
}>>;
/** `nameValues`: the values the mounted tool takes for the argument its name rules are read against (`ToolRuleFace.nameValues`,
* the delegation tool's offered agent types) — present exactly when the definition declares them, copied as declared. */
ruleFace: Type.TObject<{
primaryParams: Type.TArray<Type.TString>;
params: Type.TArray<Type.TString>;
nameValues: Type.TOptional<Type.TArray<Type.TString>>;
}>;
approvalPreview: Type.TBoolean;
validateInput: Type.TBoolean;
deferred: Type.TBoolean;
alwaysLoad: Type.TBoolean;
/** Present iff the definition carries a model-gate class and survived the gate. */
modelGate: Type.TOptional<Type.TString>;
renderHints: Type.TOptional<Type.TObject<{
userFacingName: Type.TOptional<Type.TString>;
activity: Type.TOptional<Type.TString>;
summaryParams: Type.TOptional<Type.TArray<Type.TString>>;
resultCards: Type.TOptional<Type.TArray<Type.TString>>;
approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">, Type.TLiteral<"computer-access">, Type.TLiteral<"computer-control">, Type.TLiteral<"network">]>>;
}>>;
/** Present iff the tool runs its command text on a shell other than bash (`ToolSpec.startedShell`); absent ⇒ bash. */
startedShell: Type.TOptional<Type.TUnion<[Type.TLiteral<"zsh">]>>;
/** The ONE mount condition that fired for this instance. */
mountedBy: Type.TUnion<[Type.TLiteral<"hands">, Type.TLiteral<"backgroundTasks">, Type.TLiteral<"workflow">, Type.TLiteral<"delegation">, Type.TLiteral<"hostInternals">, Type.TLiteral<"peerLane">, Type.TLiteral<"scheduler">, Type.TLiteral<"memory">, Type.TLiteral<"scenario">, Type.TLiteral<"always">, Type.TLiteral<"optional">]>;
}>;
export type ToolRosterEntry = Static<typeof ToolRosterEntry>;
export declare const ToolRoster: Type.TObject<{
schemaVersion: Type.TLiteral<1>;
/** Run-time asserted equal to `entries.length`. */
count: Type.TInteger;
/** The model's `tools[]` order, a function of the mounted set alone: the stable segment (the engine's tools and the caller's),
* then the protocol segment (the peers' tools, the engine tools mounted only because the leg declares MCP servers, then
* ToolSearch), then the per-turn segment (every caller tool declaring `ToolSpec.perTurn`) — by name inside each, in UTF-16
* code units; names unique (run-time asserted); at most {@link TOOL_ROSTER_MAX_ENTRIES} rows (run-time asserted where the
* roster forms). */
entries: Type.TArray<Type.TObject<{
name: Type.TString;
/** Always present (empty when the tool answers to no other name). */
aliases: Type.TArray<Type.TString>;
source: Type.TUnion<[Type.TLiteral<"builtin">, Type.TLiteral<"caller">, Type.TLiteral<"host">, Type.TLiteral<"mcp">, Type.TLiteral<"a2a">, Type.TLiteral<"external">, Type.TLiteral<"synthetic">]>;
/** Present iff `source` ∈ {mcp, a2a, external} (run-time validated at the mint). */
origin: Type.TOptional<Type.TObject<{
peer: Type.TString;
declaredBy: Type.TOptional<Type.TUnion<[Type.TLiteral<"center">, Type.TLiteral<"file">, Type.TLiteral<"request">]>>;
}>>;
/** The name the MCP server lists the tool under and a call is sent under, byte-exact — present iff `name` does not spell it
* (its protocol segment is the provider-charset fold, or the clamp, of another spelling: `foo.bar` and `foo_bar` both mount
* as `mcp__<server>__foo_bar`). Absent, the server's name IS that segment. An identity member ({@link mintCapabilityId}). */
remoteName: Type.TOptional<Type.TString>;
/** Undeclared ⇒ `legacy:<shapeDigest>` / `unversioned`. */
contract: Type.TObject<{
contractId: Type.TString;
implementationRevision: Type.TString;
}>;
shapeDigest: Type.TString;
wireSchemaDigest: Type.TString;
/** `builtin:<name>` | `caller:<contractId>` | `mcp:<peer>/<tool>` | `a2a:<peer>/<skill>` | `external:<contractId>`. */
cardId: Type.TString;
/** ENGINE-minted: sha256 prefix over the canonical tuple {source, peer, name, contractId, remote?} (`remote` = `remoteName`,
* only when the row carries it); unique per leg. */
capabilityId: Type.TString;
/** The materialized schema's top-level properties (name + coarse type). */
inputKeys: Type.TArray<Type.TObject<{
name: Type.TString;
type: Type.TUnion<[Type.TLiteral<"string">, Type.TLiteral<"number">, Type.TLiteral<"integer">, Type.TLiteral<"boolean">, Type.TLiteral<"object">, Type.TLiteral<"array">, Type.TLiteral<"null">, Type.TLiteral<"mixed">]>;
}>>;
effect: Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"write">, Type.TLiteral<"idempotent">]>;
effectProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"caller">, Type.TLiteral<"synthetic">, Type.TLiteral<"default">]>;
offload: Type.TBoolean;
offloadThresholdChars: Type.TOptional<Type.TInteger>;
compactable: Type.TBoolean;
budgetExempt: Type.TBoolean;
egress: Type.TBoolean;
egressProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"caller">, Type.TLiteral<"default">]>;
irreversibility: Type.TOptional<Type.TUnion<[Type.TLiteral<"never">, Type.TLiteral<"maybe">, Type.TLiteral<"always">]>>;
reversibilityProbe: Type.TBoolean;
contentOrigin: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"execution">, Type.TLiteral<"external">]>;
contentOriginProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"server">, Type.TLiteral<"exempted">, Type.TLiteral<"default">]>;
family: Type.TUnion<[Type.TLiteral<"shell">, Type.TLiteral<"file-read">, Type.TLiteral<"file-write">, Type.TLiteral<"search">, Type.TLiteral<"web">, Type.TLiteral<"delegate">, Type.TLiteral<"plan">, Type.TLiteral<"scaffold">, Type.TLiteral<"memory">, Type.TLiteral<"protocol">, Type.TLiteral<"other">]>;
/** The legs a call of this tool travels (`BOUNDARY_LEGS`), or `"per_call"` when its dispatch gives them per call: the engine's own
* definitions and the protocol tools state them, every other row follows its `effect` (`rosterBoundaryLegs`). */
boundaryLegs: Type.TUnion<[Type.TLiteral<"per_call">, Type.TArray<Type.TUnion<[Type.TLiteral<"env">, Type.TLiteral<"outside_read">, Type.TLiteral<"outside_write">]>>]>;
pathTarget: Type.TOptional<Type.TObject<{
param: Type.TString;
aliases: Type.TArray<Type.TString>;
access: Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"create">, Type.TLiteral<"edit">]>;
skillScopeEligible: Type.TBoolean;
base: Type.TOptional<Type.TUnion<[Type.TLiteral<"cwd">, Type.TLiteral<"root">]>>;
absent: Type.TOptional<Type.TUnion<[Type.TLiteral<"none">, Type.TLiteral<"base">]>>;
patternParam: Type.TOptional<Type.TString>;
each: Type.TOptional<Type.TLiteral<true>>;
}>>;
/** The URL slot a host rule of the row's name is read on, as the definition declared it ({@link ToolHostTarget}); absent when
* it declares none. Exclusive with `pathTarget`. */
hostTarget: Type.TOptional<Type.TObject<{
param: Type.TString;
}>>;
/** `nameValues`: the values the mounted tool takes for the argument its name rules are read against (`ToolRuleFace.nameValues`,
* the delegation tool's offered agent types) — present exactly when the definition declares them, copied as declared. */
ruleFace: Type.TObject<{
primaryParams: Type.TArray<Type.TString>;
params: Type.TArray<Type.TString>;
nameValues: Type.TOptional<Type.TArray<Type.TString>>;
}>;
approvalPreview: Type.TBoolean;
validateInput: Type.TBoolean;
deferred: Type.TBoolean;
alwaysLoad: Type.TBoolean;
/** Present iff the definition carries a model-gate class and survived the gate. */
modelGate: Type.TOptional<Type.TString>;
renderHints: Type.TOptional<Type.TObject<{
userFacingName: Type.TOptional<Type.TString>;
activity: Type.TOptional<Type.TString>;
summaryParams: Type.TOptional<Type.TArray<Type.TString>>;
resultCards: Type.TOptional<Type.TArray<Type.TString>>;
approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">, Type.TLiteral<"computer-access">, Type.TLiteral<"computer-control">, Type.TLiteral<"network">]>>;
}>>;
/** Present iff the tool runs its command text on a shell other than bash (`ToolSpec.startedShell`); absent ⇒ bash. */
startedShell: Type.TOptional<Type.TUnion<[Type.TLiteral<"zsh">]>>;
/** The ONE mount condition that fired for this instance. */
mountedBy: Type.TUnion<[Type.TLiteral<"hands">, Type.TLiteral<"backgroundTasks">, Type.TLiteral<"workflow">, Type.TLiteral<"delegation">, Type.TLiteral<"hostInternals">, Type.TLiteral<"peerLane">, Type.TLiteral<"scheduler">, Type.TLiteral<"memory">, Type.TLiteral<"scenario">, Type.TLiteral<"always">, Type.TLiteral<"optional">]>;
}>>;
/** sha256 prefix over the canonical COMPLETE rows — any axis / hint / contract / alias change moves it. The canonical form is the engine's one
* JSON (`canonicalJsonStringify`: keys sorted, a member holding `undefined` reads as absent). */
digest: Type.TString;
}>;
export type ToolRoster = Static<typeof ToolRoster>;
export declare const ToolRosterDelta: Type.TObject<{
/** The digest the consumer is expected to hold. A mismatch is NOT a rejection: the carried `roster` is the
* new state regardless, only `summary` becomes unusable (the consumer records a skew and re-syncs). */
fromDigest: Type.TString;
/** The whole post-change roster; positions come from it, never from the summary. */
roster: Type.TObject<{
schemaVersion: Type.TLiteral<1>;
/** Run-time asserted equal to `entries.length`. */
count: Type.TInteger;
/** The model's `tools[]` order, a function of the mounted set alone: the stable segment (the engine's tools and the caller's),
* then the protocol segment (the peers' tools, the engine tools mounted only because the leg declares MCP servers, then
* ToolSearch), then the per-turn segment (every caller tool declaring `ToolSpec.perTurn`) — by name inside each, in UTF-16
* code units; names unique (run-time asserted); at most {@link TOOL_ROSTER_MAX_ENTRIES} rows (run-time asserted where the
* roster forms). */
entries: Type.TArray<Type.TObject<{
name: Type.TString;
/** Always present (empty when the tool answers to no other name). */
aliases: Type.TArray<Type.TString>;
source: Type.TUnion<[Type.TLiteral<"builtin">, Type.TLiteral<"caller">, Type.TLiteral<"host">, Type.TLiteral<"mcp">, Type.TLiteral<"a2a">, Type.TLiteral<"external">, Type.TLiteral<"synthetic">]>;
/** Present iff `source` ∈ {mcp, a2a, external} (run-time validated at the mint). */
origin: Type.TOptional<Type.TObject<{
peer: Type.TString;
declaredBy: Type.TOptional<Type.TUnion<[Type.TLiteral<"center">, Type.TLiteral<"file">, Type.TLiteral<"request">]>>;
}>>;
/** The name the MCP server lists the tool under and a call is sent under, byte-exact — present iff `name` does not spell it
* (its protocol segment is the provider-charset fold, or the clamp, of another spelling: `foo.bar` and `foo_bar` both mount
* as `mcp__<server>__foo_bar`). Absent, the server's name IS that segment. An identity member ({@link mintCapabilityId}). */
remoteName: Type.TOptional<Type.TString>;
/** Undeclared ⇒ `legacy:<shapeDigest>` / `unversioned`. */
contract: Type.TObject<{
contractId: Type.TString;
implementationRevision: Type.TString;
}>;
shapeDigest: Type.TString;
wireSchemaDigest: Type.TString;
/** `builtin:<name>` | `caller:<contractId>` | `mcp:<peer>/<tool>` | `a2a:<peer>/<skill>` | `external:<contractId>`. */
cardId: Type.TString;
/** ENGINE-minted: sha256 prefix over the canonical tuple {source, peer, name, contractId, remote?} (`remote` = `remoteName`,
* only when the row carries it); unique per leg. */
capabilityId: Type.TString;
/** The materialized schema's top-level properties (name + coarse type). */
inputKeys: Type.TArray<Type.TObject<{
name: Type.TString;
type: Type.TUnion<[Type.TLiteral<"string">, Type.TLiteral<"number">, Type.TLiteral<"integer">, Type.TLiteral<"boolean">, Type.TLiteral<"object">, Type.TLiteral<"array">, Type.TLiteral<"null">, Type.TLiteral<"mixed">]>;
}>>;
effect: Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"write">, Type.TLiteral<"idempotent">]>;
effectProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"caller">, Type.TLiteral<"synthetic">, Type.TLiteral<"default">]>;
offload: Type.TBoolean;
offloadThresholdChars: Type.TOptional<Type.TInteger>;
compactable: Type.TBoolean;
budgetExempt: Type.TBoolean;
egress: Type.TBoolean;
egressProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"caller">, Type.TLiteral<"default">]>;
irreversibility: Type.TOptional<Type.TUnion<[Type.TLiteral<"never">, Type.TLiteral<"maybe">, Type.TLiteral<"always">]>>;
reversibilityProbe: Type.TBoolean;
contentOrigin: Type.TUnion<[Type.TLiteral<"local">, Type.TLiteral<"execution">, Type.TLiteral<"external">]>;
contentOriginProvenance: Type.TUnion<[Type.TLiteral<"declared">, Type.TLiteral<"server">, Type.TLiteral<"exempted">, Type.TLiteral<"default">]>;
family: Type.TUnion<[Type.TLiteral<"shell">, Type.TLiteral<"file-read">, Type.TLiteral<"file-write">, Type.TLiteral<"search">, Type.TLiteral<"web">, Type.TLiteral<"delegate">, Type.TLiteral<"plan">, Type.TLiteral<"scaffold">, Type.TLiteral<"memory">, Type.TLiteral<"protocol">, Type.TLiteral<"other">]>;
/** The legs a call of this tool travels (`BOUNDARY_LEGS`), or `"per_call"` when its dispatch gives them per call: the engine's own
* definitions and the protocol tools state them, every other row follows its `effect` (`rosterBoundaryLegs`). */
boundaryLegs: Type.TUnion<[Type.TLiteral<"per_call">, Type.TArray<Type.TUnion<[Type.TLiteral<"env">, Type.TLiteral<"outside_read">, Type.TLiteral<"outside_write">]>>]>;
pathTarget: Type.TOptional<Type.TObject<{
param: Type.TString;
aliases: Type.TArray<Type.TString>;
access: Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"create">, Type.TLiteral<"edit">]>;
skillScopeEligible: Type.TBoolean;
base: Type.TOptional<Type.TUnion<[Type.TLiteral<"cwd">, Type.TLiteral<"root">]>>;
absent: Type.TOptional<Type.TUnion<[Type.TLiteral<"none">, Type.TLiteral<"base">]>>;
patternParam: Type.TOptional<Type.TString>;
each: Type.TOptional<Type.TLiteral<true>>;
}>>;
/** The URL slot a host rule of the row's name is read on, as the definition declared it ({@link ToolHostTarget}); absent when
* it declares none. Exclusive with `pathTarget`. */
hostTarget: Type.TOptional<Type.TObject<{
param: Type.TString;
}>>;
/** `nameValues`: the values the mounted tool takes for the argument its name rules are read against (`ToolRuleFace.nameValues`,
* the delegation tool's offered agent types) — present exactly when the definition declares them, copied as declared. */
ruleFace: Type.TObject<{
primaryParams: Type.TArray<Type.TString>;
params: Type.TArray<Type.TString>;
nameValues: Type.TOptional<Type.TArray<Type.TString>>;
}>;
approvalPreview: Type.TBoolean;
validateInput: Type.TBoolean;
deferred: Type.TBoolean;
alwaysLoad: Type.TBoolean;
/** Present iff the definition carries a model-gate class and survived the gate. */
modelGate: Type.TOptional<Type.TString>;
renderHints: Type.TOptional<Type.TObject<{
userFacingName: Type.TOptional<Type.TString>;
activity: Type.TOptional<Type.TString>;
summaryParams: Type.TOptional<Type.TArray<Type.TString>>;
resultCards: Type.TOptional<Type.TArray<Type.TString>>;
approvalCard: Type.TOptional<Type.TUnion<[Type.TLiteral<"file-edit">, Type.TLiteral<"file-write">, Type.TLiteral<"notebook-edit">, Type.TLiteral<"shell">, Type.TLiteral<"fetch">, Type.TLiteral<"skill">, Type.TLiteral<"workflow">, Type.TLiteral<"plan">, Type.TLiteral<"question">, Type.TLiteral<"generic">, Type.TLiteral<"computer-access">, Type.TLiteral<"computer-control">, Type.TLiteral<"network">]>>;
}>>;
/** Present iff the tool runs its command text on a shell other than bash (`ToolSpec.startedShell`); absent ⇒ bash. */
startedShell: Type.TOptional<Type.TUnion<[Type.TLiteral<"zsh">]>>;
/** The ONE mount condition that fired for this instance. */
mountedBy: Type.TUnion<[Type.TLiteral<"hands">, Type.TLiteral<"backgroundTasks">, Type.TLiteral<"workflow">, Type.TLiteral<"delegation">, Type.TLiteral<"hostInternals">, Type.TLiteral<"peerLane">, Type.TLiteral<"scheduler">, Type.TLiteral<"memory">, Type.TLiteral<"scenario">, Type.TLiteral<"always">, Type.TLiteral<"optional">]>;
}>>;
/** sha256 prefix over the canonical COMPLETE rows — any axis / hint / contract / alias change moves it. The canonical form is the engine's one
* JSON (`canonicalJsonStringify`: keys sorted, a member holding `undefined` reads as absent). */
digest: Type.TString;
}>;
/** Three pairwise-disjoint name lists; a `changed` name's new row is in `roster`. */
summary: Type.TObject<{
added: Type.TArray<Type.TString>;
removed: Type.TArray<Type.TString>;
changed: Type.TArray<Type.TString>;
}>;
/** Present iff this change is an MCP server landing whose manifest row read `pending` (the leg's wait budget ran out before its
* attempt settled): that server's row as it reads now — `connected` with its tools, or `failed` — in the manifest row's own form. */
mcp: Type.TOptional<Type.TArray<Type.TUnsafe<import("./wiring-manifest.js").WiringManifestMcpEntry>>>;
}>;
export type ToolRosterDelta = Static<typeof ToolRosterDelta>;
/** The ONE name→row resolution every per-call reader shares (the call face, the park identity): the wire name first,
* then an alias — the same order the dispatcher resolves a model's call. */
export declare function rosterEntryNamed(roster: ToolRoster, toolName: string): ToolRosterEntry | undefined;
/**
* The ONE tool-name canonicalization: the wire name of the row `name` resolves to on the roster ({@link rosterEntryNamed}
* — the wire name first, then an alias, the dispatcher's order), or `name` itself when no row answers to it. The gate
* reads a call's name through it before any policy runs, and a rule's tool name reaches a call exactly when it
* canonicalizes to the same wire name (`ToolCallFace.names` is that set, minted here) — so a rule written against
* an alias and one written against the wire name are one rule.
*/
export declare function rosterToolName(roster: ToolRoster | undefined, name: string): string;
export { ruleNamesOf } from "./tool-name-readings.js";
/** The reserved card a call owns, judged from its wire name alone — the ONE read of "is this the engine's question /
* plan tool": the card minted on a call's face, the park's question mark and the decide's answer binding all ask it. */
export declare function engineCardOf(call: {
readonly toolName: string;
}): ReservedApprovalCard | undefined;
/** The approval card a call renders under: a reserved card only for the engine tool that owns it (whatever a row
* declares), otherwise the row's declared card, else `generic`. */
export declare function approvalCardOf(call: {
readonly toolName: string;
}, declared: ToolApprovalCard | undefined): ToolApprovalCard;
/** The ask / gate member that carries a call's card: copied off the face the gate stamped, absent on a bare request. */
export declare function approvalCardMemberOf(call: {
readonly face?: {
readonly approvalCard?: ToolApprovalCard;
} | undefined;
}): {
approvalCard?: ToolApprovalCard;
};
/** design/388 B6 — the per-call face a gated request carries, read off a roster snapshot by name (aliases resolve).
* `names` leads with the name the face was minted under (the model's spelling at the gate), then the wire name and the
* other aliases — the ONE order of a call's names: a reader that must pick one of them by position (a `member` seat)
* picks the spelling first, as the same call was judged before name resolution. */
export declare function toolCallFaceOf(roster: ToolRoster | undefined, toolName: string): import("./tool-policy.js").ToolCallFace | undefined;
/** design/388 B18 — the identity members a park row carries (the tool member of its approval object,
* `approval-object.ts`), read off a roster snapshot by name; an empty object when the name is not on the snapshot
* (the row then carries no tool member, and the claim refuses its approval: no tool is bound by a name alone). */
export declare function parkedToolIdentity(roster: ToolRoster | undefined, toolName: string): Partial<ToolIdentity>;
/** design/388 B6 × B18 — the FACE members a park row carries beside its identity: the display family, the declared
* path target or URL slot, and the names the parked call was judged under. `names` is copied from the face the gate stamped on the
* request (the model's spelling first — the row carries the judged fact, it is not re-derived); a request with no face
* takes the roster's names for its row. The mount site (`engineMounted`) is the roster entry's, as the identity and face members
* beside it are: a fact of the tool, not of the call, and never read off the request's face, which the policy that judges the call
* can write. A recheck that runs before the leg's roster exists (the pre-CAS resume-edit
* re-adjudication) rebuilds the call face from the row through {@link parkedCallFaceOf}, so it judges the members the row
* recorded (identity, family, targets, names, mount site) — not the live face's rule name values or approval card. An empty object
* when the name is not on the snapshot (no tool member: the claim refuses the row's approval before any recheck). */
export declare function parkedToolFace(roster: ToolRoster | undefined, req: {
readonly toolName: string;
readonly face?: {
readonly names?: readonly string[];
} | undefined;
}): {
family?: ToolFamily;
pathTarget?: ToolRosterEntry["pathTarget"];
hostTarget?: ToolHostTarget;
names?: readonly string[];
declarationDigest?: string;
engineMounted?: true;
startedShell?: "zsh";
};
/** The live face a resumed park row is re-judged under: minted under the row's recorded spelling (`names[0]`) when that
* spelling still resolves to the row's own tool on this roster, else under the row's wire name — a spelling that no
* longer resolves, or that another row now owns, never lends the row another tool's face. */
export declare function parkedRowLiveFace(roster: ToolRoster | undefined, row: {
readonly toolName: string;
readonly names?: readonly string[];
}): import("./tool-policy.js").ToolCallFace | undefined;
/** The call face a park row carries — present iff the row was minted with BOTH its face members and its four
* identity members (one mint writes all of them; a row missing any yields undefined, never a partial face, and its
* approval is refused at the claim before any recheck reads it). This is the face every recheck of the row judges under, roster or no roster. */
export declare function parkedCallFaceOf(pending: {
family?: ToolFamily;
pathTarget?: ToolRosterPathTarget;
hostTarget?: ToolHostTarget;
names?: readonly string[];
capabilityId?: string;
contractId?: string;
shapeDigest?: string;
implementationRevision?: string;
engineMounted?: true;
startedShell?: "zsh";
}): import("./tool-policy.js").ToolCallFace | undefined;
/** The optional `face` seat of a ToolCallRequest: present iff a face was read (a bare request carries no key). */
export declare function callFaceSeat(face: import("./tool-policy.js").ToolCallFace | undefined): {
face?: import("./tool-policy.js").ToolCallFace;
};
/** The four-tuple that decides "still the same tool" across a park (design/388 §2.5 boundary ②). */
export interface ToolIdentity {
capabilityId: string;
contractId: string;
shapeDigest: string;
implementationRevision: string;
}
export declare function toolIdentityOf(entry: ToolRosterEntry): ToolIdentity;
/** How a parked approval binds one member of the roster row it was asked under: `identity` (the row member that carries it —
* a live row that differs is another tool, the row reopens), `face` (carried by value — a face that differs vetoes the call),
* `declaration` (hashed into the row's `declarationDigest` — a declaration that differs vetoes the call), or `unbound` (why the
* approval does not cover it). */
export type RosterApprovalBinding = {
readonly identity: readonly (keyof ToolIdentity | "engineMounted")[];
} | "face" | "declaration" | {
readonly unbound: string;
};
/** THE classification of every roster member for the approval of a parked call (#639 / #2345): typed over every key of the row,
* so a member added to the row is a compile error here until it is classified, and two fences hold the approval object's judge
* to it (`approval-object.ts`: the identity carriers and the face members it compares are exactly the table's). */
export declare const ROSTER_APPROVAL_BINDING: Readonly<{
readonly name: {
readonly identity: readonly ["capabilityId"];
};
readonly aliases: {
readonly unbound: "the names a call answers to are the call's own (the row's `names`); a resumed belt judges under the live names";
};
readonly source: {
readonly identity: readonly ["capabilityId"];
};
readonly origin: {
readonly unbound: "the peer is the identity's (capabilityId); who declared the server is provenance no decision reads";
};
readonly remoteName: {
readonly identity: readonly ["capabilityId"];
};
readonly contract: {
readonly identity: readonly ["contractId", "implementationRevision"];
};
readonly shapeDigest: {
readonly identity: readonly ["shapeDigest"];
};
readonly wireSchemaDigest: {
readonly unbound: "the schema with its description prose for the model; the shape a call is validated against is the identity's (shapeDigest)";
};
readonly cardId: {
readonly unbound: "derived from the source, peer, name and contract, all identity";
};
readonly capabilityId: {
readonly identity: readonly ["capabilityId"];
};
readonly inputKeys: {
readonly unbound: "derived from the schema, whose shape is the identity's (shapeDigest)";
};
readonly effect: "declaration";
readonly effectProvenance: "declaration";
readonly offload: {
readonly unbound: "where the engine keeps the call's result (the deployment's own store), not what the call does or reaches";
};
readonly offloadThresholdChars: {
readonly unbound: "where the engine keeps the call's result (the deployment's own store), not what the call does or reaches";
};
readonly compactable: {
readonly unbound: "how the transcript keeps the result, not what the call does";
};
readonly budgetExempt: {
readonly unbound: "how the result counts against the context budget, not what the call does";
};
readonly egress: "declaration";
readonly egressProvenance: {
readonly unbound: "where the egress value came from; the value is the declaration's (egress), no decision reads its provenance";
};
readonly irreversibility: "declaration";
readonly reversibilityProbe: "declaration";
readonly contentOrigin: "declaration";
readonly contentOriginProvenance: {
readonly unbound: "where the content-origin value came from; the value is the declaration's, no decision reads its provenance";
};
readonly family: "face";
readonly boundaryLegs: "declaration";
readonly pathTarget: "face";
readonly hostTarget: "face";
readonly ruleFace: "declaration";
readonly approvalPreview: {
readonly unbound: "whether the card had a preview, shown when it was asked";
};
readonly validateInput: {
readonly unbound: "the live tool validates the bytes it runs, whatever the row says";
};
readonly deferred: {
readonly unbound: "when the schema is loaded into the model's context, not what the call does";
};
readonly alwaysLoad: {
readonly unbound: "when the schema is loaded into the model's context, not what the call does";
};
readonly modelGate: "declaration";
readonly renderHints: {
readonly unbound: "display, shown when the card was asked";
};
readonly startedShell: "face";
readonly mountedBy: {
readonly identity: readonly ["engineMounted"];
};
}>;
type ApprovalTable = typeof ROSTER_APPROVAL_BINDING;
/** The roster members the table binds as the tool's FACE. */
export type RosterFaceMember = {
[K in keyof ApprovalTable]: ApprovalTable[K] extends "face" ? K : never;
}[keyof ApprovalTable];
/** The row members that carry the roster's IDENTITY members. */
export type RosterIdentityCarrier = {
[K in keyof ApprovalTable]: ApprovalTable[K] extends {
readonly identity: readonly (infer I)[];
} ? I : never;
}[keyof ApprovalTable];
/** The declaration a parked approval binds: the digest of the row's `declaration` members ({@link ROSTER_APPROVAL_BINDING}) — plus,
* for a protocol row (`mcp` / `a2a`) backed by a live tool instance ({@link rowMember}), the peer-registration digest its
* `peerRegistration` reader returns (under the key `registration`; a missing backing instance or reader, a non-string reading, or a
* throwing getter or call adds nothing). One mint for the park row and for the live row it is compared with. */
export declare function toolDeclarationDigestOf(entry: ToolRosterEntry): string;
/** The engine-minted capability identity: a STRUCTURED tuple (never a joined string — `a:b`+`c` and `a`+`b:c`
* must not collide). Stable across legs for the same source/peer/name/contract — and, for a tool whose server lists it under a
* name the wire name does not spell (`remote`, the row's `remoteName`), that server name: two server tools folded onto one wire
* name are two capabilities. `remote` is a key of the tuple only when given, so the identity of every tool whose wire name spells
* its server's name is the one minted from the four members alone. */
export declare function mintCapabilityId(t: {
source: RosterSource;
peer: string | null;
name: string;
contractId: string;
remote?: string | undefined;
}): string;
/** Whether a mount of `source` names a peer (its `origin`): a protocol tool's server or agent, an external tool's. ONE reading — the
* mount's admission and {@link identityHoldsNoServerName} ask it. */
export declare function rosterSourceNamesPeer(source: RosterSource): boolean;
/**
* Whether a parked approval's tool identity, read off the row's own members, holds no name an MCP server lists a tool under: its
* `capabilityId` is the identity {@link mintCapabilityId} mints over the row's own `toolName` and `contractId` for a source that names
* no peer. Only the MCP listing hands a tool a server's name, and every MCP mount names its server as the peer, so such an identity has
* no `remote` member under any reading — the identity an engine that minted no server name wrote for the tool is the one this engine
* mints. A row of an MCP tool never answers yes, nor does one whose three members do not recompute (a member changed, a name other than
* the wire name the identity was minted over). A pure function of the record's own members; total over a record.
*/
export declare function identityHoldsNoServerName(pending: object): boolean;
export declare function rosterDigestOf(entries: readonly ToolRosterEntry[]): string;
/** The materialized schema's top-level properties, in declaration order. */
export declare function inputKeysOf(schema: TSchema | undefined): {
keys: ToolRosterEntry["inputKeys"];
scalar: Set<string>;
};
/** The roster's KEY bounds over a schema (design/388 B20): a problem sentence, or undefined when every top-level key fits.
* Shared by the caller declaration door (typed refusal) and the MCP intake (disclosed drop) — a key is never truncated. */
export declare function schemaKeyBoundProblem(schema: TSchema | undefined): string | undefined;
/** The identity members of one roster row the wire bounds hold, as a DECLARATION (the door) or a MINTED row hands them. */
export interface RosterBoundMembers {
name: string;
aliases?: readonly string[];
/** An MCP/A2A mount's peer (the row's `origin.peer`) — a NAME on the roster, held to the wire name bound. */
peer?: string;
/** The server's own name for an MCP tool the row carries as `remoteName` — a NAME on the roster, held to the same bound, and to
* {@link NOT_IN_A_SERVER_TOOL_NAME}. */
remoteName?: string;
contractId?: string;
implementationRevision?: string;
modelGate?: string;
cardId?: string;
}
/** The typed refusal a member over its bound mints — the door's two codes, and the mint's own for the members no
* declaration door names (`modelGate`, the derived `cardId`). Spelled out as literals (a consumer's tooling reads
* the words); each is a member of {@link ToolDeclarationCode}, which every mint below satisfies. */
export type RosterBoundCode = "config.tool_name_too_long" | "config.tool_contract_too_long" | "config.tool_roster_bound";
/**
* design/388 B20 / #626 ① — the ONE bound judge over a row's identity members: a problem `{ code, message }`, or
* undefined when every member fits. Read by the declaration door (a `TaskSpec.tools` entry, refused before session
* acquire) and by the row mint (every source — an MCP/A2A peer, a definition that reached the mint by a route the
* door does not cover — refused before the row exists). A member over its bound is NEVER truncated onto the row: a
* truncated identity is a different identity (`judgeApprovalObject` compares it across a park; the card
* namespace door reads it), and the schema's own bounds would then describe a row the mint never made.
*/
export declare function rosterMemberBoundProblem(m: RosterBoundMembers): {
code: RosterBoundCode;
message: string;
} | undefined;
/** Did one of the ENGINE's own mount sites mount this row — a built-in or synthetic tool the engine minted for the leg — rather than a
* caller's `TaskSpec.tools` entry (`scenario`) or a protocol peer's tool? The one identity a caller cannot declare: a name, a contract
* id and a source word all can be worn, the mount site cannot. Read onto the call's face ({@link toolCallFaceOf}, `engineMounted`). */
export declare function engineMountedRow(e: Pick<ToolRosterEntry, "source" | "mountedBy">): boolean;
/**
* The rule vocabulary of ONE mounted instance (design/388 §2.2 ③ / D-3): DERIVED = the scalar top-level
* keys ∪ the path target's `param` + aliases; a declared `params` list can only NARROW it (a declared
* name outside the derived set is dropped — the L6 gate names it for a built-in); `primaryParams` =
* declared, else the path target's `param` + aliases.
*/
export declare function ruleFaceOfInstance(schema: TSchema | undefined, declared: ToolRuleFace | undefined, pathTarget: ToolPathTarget | undefined): {
primaryParams: string[];
params: string[];
};
/** The instance `row` describes: what runs when a call is judged by that row. A row no snapshot minted has none. */
export declare function rowMember(row: ToolRosterEntry): AgentTool | undefined;
/** The instance each NAME dispatches to when several are mounted under it: the LATER mount (the harness keeps the
* later one). The one selection — the roster's snapshot and every table keyed by a caller tool's name read it here. */
export declare function survivorsByName<T extends {
readonly name: string;
}>(mounted: readonly T[]): Map<string, T>;
/** What a mount site knows that the instance does not: where the tool came from and which condition fired. */
export interface RosterMountMeta {
source: RosterSource;
mountedBy: ToolMountTag;
/** Required for `mcp` / `a2a` / `external`; refused otherwise. */
origin?: {
peer: string;
declaredBy?: "center" | "file" | "request";
};
/** The caller's tool declares `ToolSpec.perTurn`: the mount takes the per-turn segment ({@link RosterBuilder.perTurnStart}). */
perTurn?: true;
/** An engine tool mounted only because the leg declares MCP servers: its presence follows the dial, so it takes the protocol
* segment beside the peers' tools ({@link segmentOf}). */
followsDial?: true;
}
/** The face a mounted instance carries (forwarded by `defineTool`; read here by the same untyped-carry convention
* every other axis reader in the runner uses). */
export interface MountedToolFace {
effect?: ToolEffect;
egress?: true;
irreversibility?: "never" | "maybe" | "always";
reversibilityProbe?: unknown;
contentOrigin?: ToolContentOrigin;
offload?: boolean;
offloadThresholdChars?: number;
defer?: boolean;
alwaysLoad?: boolean;
mcpAlwaysLoad?: boolean;
family?: ToolFamily;
pathTarget?: ToolPathTarget;
hostTarget?: ToolHostTarget;
ruleFace?: ToolRuleFace;
renderHints?: ToolRenderHints;
compactable?: true;
budgetExempt?: true;
modelGate?: string;
boundaryLegs?: unknown;
startedShell?: unknown;
}
export declare const faceOf: (t: AgentTool) => MountedToolFace;
/** The leg facts the snapshot reads beside the instances — the safety scan's folds and the per-task knobs. */
export interface RosterSnapshotFacts {
/** The leg's by-name effect map (the builder writes it at every mount and unmount; the protocol folds write a protocol member's). */
effects: ReadonlyMap<string, ToolEffect>;
egress: ReadonlySet<string>;
irreversibilityTier: ReadonlyMap<string, "never" | "maybe" | "always">;
reversibilityProbes: ReadonlyMap<string, unknown>;
/** Names the defer classification ships as placeholders. */
deferred: ReadonlySet<string>;
/** `TaskSpec.memory.trustedTools` — the exemption channel for an undeclared content class. */
trustedTools: ReadonlySet<string>;
}
/** A tool as a mount plan names it: the catalog definition it is (by its name and its contract) and its plan source. The one
* reading the leg's effective plan and the static plan's caller members both go through. */
export declare function planIdentityOf(tool: ToolContractFace, source: RosterSource | undefined): {
readonly id?: string;
readonly source: ToolMountSource;
};
export declare class RosterBuilder {
#private;
/** `effects` — the leg's by-name effect map, which the builder keeps equal to the mounted set's answering members. The leg's
* safety-axis tables are not the builder's: their marks live under the names they were laid on, and a call reads them under
* the names it answers to. */
constructor(effects: Map<string, ToolEffect>);
/** The leg's mount ledger: every mount site asks it before it mounts, and {@link settleMountPlan} checks the
* mounted set against it. */
readonly mounts: ToolMountLedger<AgentTool<Type.TSchema, unknown>>;
/** Check the mounted set (the mount array and the engine lane) against the mount table and return the leg's effective plan,
* carrying the leg's reading of whether it needs an execution environment as it was made before the environment started.
* Runs once, after the last mount and before the snapshot. */
settleMountPlan(executionEnv: ToolMountPlanExecutionEnv): ToolMountPlan;
/** The mount array as a READ face, in segment order and by name inside each ({@link segmentOf}). The order is the wire order;
* the engine lane enters it at {@link perTurnStart}. */
get tools(): readonly AgentTool[];
/**
* Where the per-turn segment of the mount array starts — its length when it has none. The segment is every instance mounted
* with {@link RosterMountMeta.perTurn}; it is the last segment ({@link segmentOf}), so a suffix. The one reading of the
* boundary: the snapshot, and the wire list and prompt manifest (which put the engine lane — ToolSearch — here, at the end of
* the protocol segment) all ask it.
*/
get perTurnStart(): number;
get length(): number;
metaOf(tool: AgentTool): RosterMountMeta | undefined;
/** The catalog row a tool on this roster is, when one of the engine's own mount sites mounted it ({@link engineMountedRow}) — the
* identity a caller's product cannot take, whatever name, schema or contract descriptor it carries; `undefined` for any other tool. */
engineDefinitionOf(tool: object): ToolCatalogEntry | undefined;
/** Mount one instance at its place ({@link segmentOf}); the leg's effect map then follows the mounted set (`#settleEffects`). The
* later mount under a name is the one the harness dispatches to (`snapshot`'s yield rule). */
mount(tool: AgentTool, meta: RosterMountMeta): void;
/** An ENGINE-INJECTED instance the harness list carries outside the mount array (the ToolSearch lane): a roster
* row — the model can call it — never a mount-array element (the disclosure lane owns that list and appends the
* instance itself). Its row follows the mount array's rows in the snapshot, ahead of the per-turn segment's
* ({@link perTurnStart}); the same admission rules apply. */
mountEngineLane(tool: AgentTool, meta: RosterMountMeta): void;
mountAll(tools: readonly AgentTool[], meta: RosterMountMeta): void;
/** Mount instances on a RUNNING roster, each at its place: judged before it touches anything, as {@link replaceDomain} is — a set that
* would put the roster over {@link TOOL_ROSTER_MAX_ENTRIES} rows throws `config.tool_roster_bound` and leaves the builder as it was. */
mountLive(tools: readonly AgentTool[], meta: (tool: AgentTool) => RosterMountMeta): void;
/** Remove every instance the predicate selects; returns them in mount order. */
unmountWhere(pred: (tool: AgentTool, index: number) => boolean): AgentTool[];
/** Swap the instance at `index` for another object standing for the SAME mount (a presentation re-render, a
* wrapper): the mount meta carries over. */
replaceAt(index: number, tool: AgentTool): void;
/**
* Swap a NAME-PREFIX domain (the RefreshMcpTools seam): every instance whose name starts with `prefix` is removed and each of
* `fresh` mounted at its place ({@link segmentOf}) — so a listing that did not change is the same array, and one that did
* changes the table from its first changed tool on.
*
* The swap is judged before it touches anything: a domain whose fresh tools would put the roster over
* {@link TOOL_ROSTER_MAX_ENTRIES} rows throws `config.tool_roster_bound` and leaves the builder as it was (the
* re-mint after the swap is the publish, which runs after the harness is rebuilt — too late to refuse at). An
* empty `fresh` only shrinks the set and always passes.
*/
replaceDomain(prefix: string, fresh: readonly AgentTool[], meta: RosterMountMeta): void;
/** Mint the roster: one row per mounted NAME, in order. Two mounted instances under one name follow the
* harness's own yield (the LATER mount is the one the model dispatches to — design/141 Q4, the
* `auditToolCollisions` "yield" record): the roster carries the surviving instance's row at the
* yielded instance's position and never a row per object. A set that would mint more than
* {@link TOOL_ROSTER_MAX_ENTRIES} rows is refused (`config.tool_roster_bound`) before any row is minted. */
snapshot(facts: RosterSnapshotFacts): ToolRoster;
}
/**
* The roster's one declaration rule on engine names: a row whose names (its wire name and the aliases that resolve to it,
* {@link namesResolvingTo}) belong to TWO or more engine tools is refused — one tool answering as two engine tools would
* have every per-call seat keyed on engine names choose between two definitions of the call. A row answering to one engine
* tool under several of that tool's names, and an alias another row owns, are not counted twice. Undefined ⇒ none.
*/
export declare function rosterEngineNamesProblem(roster: ToolRoster): string | undefined;
/** Which source a `TaskSpec.tools` entry mounts as: a definition carrying a CORE contract is a built-in the host chose
* to mount; anything else is the caller's own tool. Identity follows the object, never the name. */
export declare function callerMountSource(tool: ToolContractFace): RosterSource;
/** The card namespace a roster row owns (design/388 §2.2 ④) — ONE mint, read by the row and by the prepare door that
* judges a caller's `renderHints.resultCards` against it: `builtin:<name>` for engine-owned definitions,
* `<mcp|a2a>:<peer>/<tool>` for protocol tools, `<caller|external>:<contractId>` for everything the caller mounts. */
export declare function rosterCardId(source: RosterSource, toolName: string, peer: string | null, protocolTool: string, contractId: string): string;
/** The card namespace a `TaskSpec.tools` entry will own once mounted — the same mint the row makes, so the prepare
* door and the roster row cannot disagree about which namespace a caller card must live under. */
export declare function callerCardIdOf(tool: Pick<AgentTool, "name" | "parameters">): string;
/** The protocol segment of a mounted protocol tool's name (`mcp__srv__write_file` ⇒ `write_file`): the name itself when no protocol owns it.
* ONE reading, asked by the row's mint below and by the judge that holds an MCP face's cards to the namespace that row will own. */
export declare function protocolToolOf(toolName: string): string;
/** The `remoteName` member a row minted under wire name `toolName` carries for a tool its server lists as `remote`: `remote`
* when the wire name's protocol segment does not spell it, else nothing (the segment is the server's name). ONE reading, asked by
* the row's mint and by the MCP intake that drops a listing entry whose member could not ride a row. */
export declare function rosterRemoteNameOf(toolName: string, remote: string | undefined): string | undefined;
/** The refusal of a `boundaryLegs` declaration that is not one — the ONE sentence the roster's declaration door and the row mint both
* throw (`config.tool_face_invalid`, the code a caller tool's bad face has). */
export declare function boundaryLegsRefusal(toolName: unknown): Error & {
code: string;
};
/** The judge of a caller roster's `boundaryLegs` where the roster enters, every entry the caller handed, mounted or not: the config-door
* phase over the snapshot's faces and a resume's screen before its claim over the entries it is handed (one function, so the row stays
* pending). A declaration that is not one is refused. Not judged here — the snapshot reads it, and only by running the caller's code:
* an entry or a list of another prototype (its prototype chain answers), a Proxy, an accessor (or a non-enumerable member the receipt
* does not take) as the name, the declaration or a slot of the list. The row mint judges every other source. */
export declare function assertToolBoundaryLegs(tools: unknown): void;
/** Is this roster entry the delegation tool — does it carry the `withAgents` rebuild seam the per-task agents rebuild keys on? The
* one reading of it: the doors' rebuild, the receipt below, and a leg's mount plan (a leg that can delegate keeps its execution
* environment: its children are placed from its seat). */
export declare function entryDelegates<T extends {
readonly withAgents?: unknown;
}>(entry: T): entry is T & {
readonly withAgents: NonNullable<T["withAgents"]>;
};
/** Whether a caller roster mounts a delegation tool — an entry carrying the `withAgents` rebuild seam — read as the one receipt reads
* the roster (no getter or trap runs): `false` when there is no roster, or every entry is a plain record the receipt took whole and none
* carries a function `withAgents`; `true` when one does; `undefined` when an entry could carry it only by running the caller's code (an
* entry of another prototype — its prototype chain answers —, a Proxy, an accessor or a member the receipt does not take). A resume's
* screen asks it before the claim; the `undefined` remainder is answered by the leg's own live read, after the claim. */
export declare function rosterMountsDelegation(tools: unknown): boolean | undefined;
/** One row (design/388 §2.5). Every axis is read off the instance or the leg facts; nothing off a name table. */
export declare function mintRosterEntry(tool: AgentTool, meta: RosterMountMeta, facts: RosterSnapshotFacts): ToolRosterEntry;
/**
* The run-time delta seat: armed with the leg's minted roster and a re-snapshot closure at prepare, it
* re-mints the roster after every run-time roster change (the RefreshMcpTools seam), diffs it against the
* last published one and hands the delta to the stream (`tool_roster_delta`). Deltas published before a
* sink subscribes are buffered (bounded) and flushed at subscription, so the first consumer sees them.
*/
export declare class ToolRosterDeltaSeat {
#private;
arm(current: ToolRoster, snapshot: () => ToolRoster): void;
/** The last minted roster (the prepared one until a run-time change re-mints it). */
get current(): ToolRoster | undefined;
/** Re-mint after a run-time change; publishes and returns the delta (undefined before arming). A
* byte-identical re-mint still publishes: the consumer's summary is empty and its digest unchanged. `mcp`: the rows of the MCP servers
* this change landed, carried on the delta ({@link ToolRosterDelta}). */
republish(mcp?: readonly import("./wiring-manifest.js").WiringManifestMcpEntry[]): ToolRosterDelta | undefined;
/** Install the stream sink; anything published before is flushed in order. */
subscribe(sink: (delta: ToolRosterDelta) => void): void;
/** The leg ended: drop the sink so a late republish never reaches a closed stream (it buffers, bounded, unread). */
unsubscribe(): void;
/** Take the buffered deltas (a consumer that polls instead of subscribing). */
drain(): ToolRosterDelta[];
}
/**
* design/388 B15 — the rule-face resolver a leg hands the rule compiler: every roster row answers with its
* derived vocabulary, the carried-but-non-scalar keys (so `Edit(edits:x)` reads `param_non_scalar`, not
* `param_unknown`) and the values a name rule of it is resolved against when the definition declares them (`nameValues`);
* a name off the roster answers undefined. Which lane a rule takes is the rule name's grammar, not the row's: the resolver
* says which parameters the mounted tool carries and which name values it declares.
*/
export declare function ruleFacesFromRoster(roster: ToolRoster): (toolName: string) => {
primaryParams: readonly string[];
params: readonly string[];
nonScalar: readonly string[];
nameValues?: readonly string[];
} | undefined;
/** The delta between two snapshots (design/388 §2.5): the whole `next` roster plus the name summary. */
export declare function diffToolRoster(prev: ToolRoster, next: ToolRoster): ToolRosterDelta;
/** The card-namespace check a CALLER declaration must pass at prepare (design/388 §2.2 ④): a `resultCards`
* entry must live under the tool's own `cardId`; naming an engine card (`builtin:*`, or a bare engine card
* type) is refused. Returns the offending entry, or undefined. */
export declare function offendingResultCard(hints: ToolRenderHints | undefined, cardId: string, engineCards: ReadonlySet<string>): string | undefined;