@sema-agent/core
Version:
Stateless, task-oriented AI agent core
38 lines (37 loc) • 3.02 kB
TypeScript
/**
* THE account of a tool-name list entry no tool of its universe answers to ({@link UNMATCHED_TOOL_NAMES_CODE}): the code, the shape of
* the warning that carries it, and the person's half of it. One mint of the sentence (`judgeToolNameList`, `runner/sub-agent-deny-lists.ts`,
* and the policy name audit in `runner/prepare-policy-chain.ts` for a tool policy's lists); this module holds the code, the facts a
* list-entry warning carries and the notice read off it, and reads no list.
*
* One code, two faces (the shape `mcp.server_unavailable` has: an operator warning on `onError` and the person's half of the SAME
* warning as a notice): the operator reads the coded warning on the config channel whoever wrote the list; the notice — audience
* `user`, the person who wrote the entry believes it guards or grants a tool — is derived from the warning and goes out only where the
* run's own request wrote the list. A list the deployment wrote (a delegation tool's own lists, a deployment's tool policy) is told to
* the operator alone: the person talking to the run did not write it and cannot rewrite it.
*/
import type { EngineNotice } from "./engine-notice.js";
/** The code of the unmatched-name warning (operator, `onError`) and of its notice (user): one word, two faces. */
export declare const UNMATCHED_TOOL_NAMES_CODE: "config.toolpolicy.unmatched_names";
/** What a list-entry warning says besides its sentence: whose list, which side, the entry as written (clipped for a sentence) and the
* nearest name a tool of the universe answers to, when one stands within two edits. */
export interface UnmatchedNameFacts {
readonly where: string;
readonly side: "allowed" | "denied";
readonly entry: string;
readonly nearest?: string;
/** The identity of the (list, side, entry) as written, UNclipped — what a once-per-session record keys on (`where` / `entry` above are clipped for a sentence). */
readonly identity: string;
}
/** What {@link unmatchedNameWarning} mints: the operator warning, carrying the facts its notice is read from. */
export type UnmatchedNameWarning = Error & {
code: typeof UNMATCHED_TOOL_NAMES_CODE;
unmatched: UnmatchedNameFacts;
};
/** The key of a notice's once-per-session record: the identity of the entry the warning was minted for, not of its sentence (the sentence differs per pool). */
export declare function unmatchedNameIdentity(warning: Error): string | undefined;
/** The coded warning of one list entry that no tool of the universe answers to. */
export declare function unmatchedNameWarning(message: string, unmatched: UnmatchedNameFacts): UnmatchedNameWarning;
/** The notice a list-entry warning stands for, or `undefined` when it stands for none (a warning of another code, or the policy name
* audit's, which carries no facts of one entry). The sentence is the warning's own — one text, two channels. */
export declare function unmatchedNamesNotice(warning: Error, sessionId: string): EngineNotice | undefined;