@sema-agent/core
Version:
Stateless, task-oriented AI agent core
60 lines (59 loc) • 4.7 kB
TypeScript
import type { Model } from "../../internal/llm.js";
import type { MaterializedA2a } from "../a2a.js";
import type { MaterializedMcp } from "../mcp.js";
import type { RunnerDeps, TaskSpec } from "../types.js";
import type { AnnounceOnceSink, ToolFaceSnapshot } from "./contracts.js";
import { RosterBuilder } from "../tool-roster.js";
export interface PrepareDeferClassifyInput {
/** borrowed-readonly — the REBOUND spec (`spec′`); only `tools` is read (names for the full-schema filter, specs for the `defer` declarations). */
spec: Pick<TaskSpec, "tools" | "excludeAllTools">;
/** borrowed-readonly — deps; `deferMode` (candidate widening) and `toolSearch` (rule ②'s gate) are the only seats read. */
deps: Pick<RunnerDeps, "deferMode" | "toolSearch">;
/** borrowed-mutable — the shared mount array (later refs alias it; in-place contract, never
* re-created). Mutated here, in order: `splice` of every excluded name; element REPLACEMENT with a
* shallow copy for the classic-profile description swap (the caller's ToolSpec object is never
* mutated); `splice` of a retracted memory group. After this phase: the content-origin wrap
* (element replacement with the wrapped object), the disclosure mount, the MCP refresh re-splice. Since
* Every one of those writes is a builder verb (`unmountWhere` / `replaceAt`). */
roster: RosterBuilder;
/** borrowed-readonly — the frozen task-start tool face: `exclude` (the valve), `defer` (operator defers, exact wire names), `alwaysLoad` (the pins). */
toolFaceSnapshot: Pick<ToolFaceSnapshot, "exclude" | "defer" | "alwaysLoad">;
/** borrowed-readonly — whether a real execution env is mounted (the full-shell invariant runs only where a shell could be on the roster). */
handsEnabled: boolean;
/** borrowed-readonly — the spec-time precomputation the invariant checks the post-exclusion roster against: a mismatch is an engine bug, thrown. */
fullShellReachable: boolean;
/** borrowed-readonly — the resolved prompt profile (`classic` swaps in `descriptionClassic`). */
promptProfile: "simple" | "classic";
/** borrowed-readonly — the resolved model (the deferral gate's threshold reads its context window). */
model: Model;
/** borrowed-readonly — the materialized MCP roster; only `tools` is read (protocol names; `mcpAlwaysLoad` self-declarations lose to an operator defer). */
mcp: Pick<MaterializedMcp, "tools">;
/** borrowed-readonly — the materialized A2A roster; only `tools` is read (protocol names). */
a2a: Pick<MaterializedA2a, "tools">;
/** borrowed-readonly — whether the shared-memory pair mounted (project-context phase). */
sharedMemoryPairMounted: boolean;
/** borrowed-readonly — whether the engine-memory pair mounted (project-context phase). */
memoryEnginePairMounted: boolean;
/** borrowed-readonly — the memory block as the project-context phase left it; the engine pair's retraction strips the recall paragraph and returns the
* stripped value as {@link PrepareDeferClassifyResult.memoryBlock}. The input is never mutated. */
memoryBlock: string | undefined;
/** borrowed-readonly — the exact recall-discipline segment the memory phase composed (the strip removes THIS string, never a re-composition). */
memoryRecallSegment: string | undefined;
/** borrowed-readonly — the once-per-session ledger's deduplicated operator sink (a retraction is announced once per session). */
onceLedger: AnnounceOnceSink;
/** borrowed-readonly — the acquired session's id (operator-line context). */
sessionId: string;
}
export interface PrepareDeferClassifyResult {
/** owned — the FINAL deferred set over the post-exclusion, post-retraction roster: the disclosure
* mount, the deferred registry and `Prepared.deferredToolNames` all read this one set (there is
* deliberately no second classification). Empty ⇒ nothing is deferred. */
deferred: Set<string>;
/** owned — the memory block after the engine pair's retraction strip (unchanged when no retraction
* ran). The driver binds it under the name the prompt assembly reads. */
memoryBlock: string | undefined;
/** owned — the gate policy this classification was MEASURED under; the census reports it from here, never a second reading of the seat. */
toolSearch: import("../tool-search-setting.js").ResolvedToolSearch;
}
/** The M11 phase body — prepareTask's tool-face fold + deferred classification, verbatim (module header). */
export declare function prepareDeferClassify(input: PrepareDeferClassifyInput): PrepareDeferClassifyResult;