@sema-agent/core
Version:
Stateless, task-oriented AI agent core
43 lines (42 loc) • 3.63 kB
TypeScript
/**
* THE account of an entry in a DEFINITION's tool-name list that no tool name can be ({@link DEFINITION_ENTRY_REASON}: `"Bash("`,
* `"a b"`, `""`, `"a b(x)"`): the code, the shape of the warning that carries it, and the person's half of it. A definition is a
* delegation target's own lists — an agent definition in `TaskSpec.agents`, an authored face of a delegation tool a deployment mounts —
* and is written somewhere the run's caller often cannot reach (a plugin's agent file, a deployment's roster). One entry of it
* cannot take the whole run down: the run goes on, this account says the definition cannot be delegated to, and the delegation to
* it (`Agent`'s spawn, a workflow agent launch) is refused with the same code and the same word — the use is where it fails.
*
* One code, two faces (the shape `config.toolpolicy.unmatched_names` has): the operator reads the coded warning on the config
* channel whoever wrote the definition; the notice — audience `user`, the person who wrote the entry believes it bounds the
* agent — is derived from the warning and goes out only where the run's own request wrote the definition. A face of a delegation tool
* the deployment mounted is told to the operator alone: the person talking to the run did not write it and cannot rewrite it. This
* module reads no list: `judgeToolNameList` (`runner/sub-agent-deny-lists.ts`) mints the warning, one sentence for every moment.
*/
import type { EngineNotice } from "./engine-notice.js";
/** The code of the warning (operator, `onError`), of its notice (user) and of the refusal of a delegation to the definition: one word, three moments. */
export declare const DEFINITION_ENTRY_CODE: "config.agent.unknown_tool";
/** The `detail.reason` of a definition's entry no tool name can be — the rule syntax's own word for it (`grammar`, as the allow layer's sentences spell it). */
export type DefinitionEntryReason = "grammar";
export declare const DEFINITION_ENTRY_REASON: DefinitionEntryReason;
/** What the warning says besides its sentence: whose list, which side, the entry as written (clipped for a sentence). */
export interface DefinitionEntryFacts {
readonly where: string;
readonly side: "allowed" | "denied";
readonly entry: string;
/** The identity of the (list, side, entry) as written, UNclipped — what a once-per-session record keys on (`where` / `entry` are clipped for a sentence). Not on the wire. */
readonly identity: string;
}
/** What {@link definitionEntryWarning} mints: the operator warning, its `detail` the notice's facts and the reason word; the identity rides beside it, not in it. */
export type DefinitionEntryWarning = Error & {
code: typeof DEFINITION_ENTRY_CODE;
detail: Omit<DefinitionEntryFacts, "identity"> & {
reason: DefinitionEntryReason;
};
identity: string;
};
/** The coded warning of one entry of a definition's list that no tool name can be. */
export declare function definitionEntryWarning(message: string, facts: DefinitionEntryFacts): DefinitionEntryWarning;
/** The key of a notice's once-per-session record: the identity of the entry the warning was minted for, or `undefined` for a warning of another account. */
export declare function definitionEntryIdentity(warning: Error): string | undefined;
/** The notice a definition-entry warning stands for, or `undefined` when it stands for none (a warning of another code or another account). The sentence is the warning's own — one text, two channels. */
export declare function definitionEntryNotice(warning: Error, sessionId: string): EngineNotice | undefined;