@sema-agent/core
Version:
Stateless, task-oriented AI agent core
47 lines (46 loc) • 2.74 kB
TypeScript
/**
* One declared server, as far as its names go: `McpServerSpec` fits as it is. `tools` are the server's REMOTE tool names the asker
* already knows (a listing, a host's reading of one — never the minted `mcp__…` names); absent means none are known.
*/
export interface McpNameSetServer {
readonly name: string;
readonly tools?: readonly string[];
}
/**
* One contention: `names` are the two sources, the earlier one first (server names for `server_name`; the remote tool names for
* `tool_name`, where `server` says whose); `shared` is the name they mint — the prefix for `server_name`, the wire name for `tool_name`.
*/
export type McpNameConflict = {
readonly kind: "server_name";
readonly names: readonly [string, string];
readonly shared: string;
} | {
readonly kind: "tool_name";
readonly server: string;
readonly names: readonly [string, string];
readonly shared: string;
};
/** The judge's answer: `ok`, or EVERY contention in the set — server rows first, then tool rows, each in declaration order; never empty. */
export type McpNameVerdict = {
readonly ok: true;
} | {
readonly ok: false;
readonly conflicts: readonly [McpNameConflict, ...McpNameConflict[]];
};
/** Judge a declared set. Pure: reads nothing but the names it is handed; a malformed set is refused (`config.invalid_argument`), never read as clean. */
export declare function judgeMcpNames(servers: readonly McpNameSetServer[]): McpNameVerdict;
/**
* The sentence that says why a tool of one server is not mounted under its own name: `heldBy` is the raw name that took the wire
* name `minted` first, `tool` the raw name that came after. TWO FACTS, TWO SENTENCES (a fixed label must not head more than one
* cause): the same raw name listed again, where namespacing folded nothing, and two different raw names that fold onto one name.
* It carries no raw name — the caller's own field says which tool.
*/
export declare function mcpToolDropReason(minted: string, heldBy: string, tool: string): string;
/** One row as a sentence — the one the engine refuses a run with (`server_name`) or discloses a drop with (`tool_name`). Names are quoted single-line and bounded. */
export declare function describeMcpNameConflict(conflict: McpNameConflict): string;
/**
* The refusal of a declared set whose server names do not each own a namespace domain — thrown by the mount and by the no-run probe,
* so one set is refused with one code and one sentence wherever it is asked. It takes the NAMES only (a run's refusal reads no
* tool list); the FIRST `server_name` row speaks, naming both raw spellings.
*/
export declare function refuseCollidingMcpServerNames(serverNames: readonly string[]): void;