UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

57 lines (56 loc) • 4.99 kB
/** * A protocol peer's account of itself, read without the credentials its connection's requests carried — the MCP server's `serverInfo`, * its instructions and its tool, prompt and resource listings (a resource template listing reads as the resource listing), the A2A peer's agent card. The needle is the connection's credentials (`PeerCarrier.credentials`: * what the seat answered that the withheld table holds) and the one eraser is `eraseSentCredentials` (protocol-http-auth.ts, beside the * failure text's). Free text holding the needle is erased in place; a NAME holding it (a tool's name or input schema, the server's own * name, a skill's id, the card's name) is never rewritten — what it names is refused instead. Either way the site is announced, once per * (materialization, peer, site), as `mcp.credential_echoed` (operator) through {@link credentialEchoNotice}. */ import { type EngineNotice } from "./engine-notice.js"; import type { PeerCarrier } from "./peer-seat.js"; /** Where a peer echoed its connection's credentials into what it said about itself — the closed set `mcp.credential_echoed` names * (`detail.where`). */ export declare const CREDENTIAL_ECHO_SITES: readonly ["server_info", "instructions", "tool_listing", "prompt_listing", "resource_listing", "agent_card"]; export type CredentialEchoSite = (typeof CREDENTIAL_ECHO_SITES)[number]; /** What a peer's account is read with: the needle, and who hears that a site held it. */ export interface CredentialEcho { readonly credentials: readonly string[]; readonly announce: (where: CredentialEchoSite) => void; } export declare const NO_CREDENTIAL_ECHO: CredentialEcho; /** The drop reason of a tool whose name or input schema holds its connection's credential. */ export declare const CREDENTIAL_ECHO_DROP_REASON = "its name or input schema holds a credential this connection's requests carried (the server echoed it back); neither is rewritten, so the tool is not mounted"; /** A free text of the peer's with the needle erased in place (absent stays absent); a text that held it announces `where`. */ export declare function erasedEcho(text: string | undefined, echo: CredentialEcho, where: CredentialEchoSite): string | undefined; /** Whether a NAME the peer gave holds the needle (announced as `where` when it does): such a name is refused, never rewritten. */ export declare function nameEchoes(name: string, echo: CredentialEcho, where: CredentialEchoSite): boolean; /** A listed input schema as one text for the needle (its keys and values, JSON-escaped as the echo spellings expect); a schema JSON cannot * carry reads as nothing (the schema gate refuses it on its own). */ export declare function schemaText(schema: unknown): string; /** A listed tool the needle refuses — named with it, or its input schema holding it (the schema is the tool's structure: its property * names are what the model sends, not prose to edit) — or named with a value its requests carry (`declared`): the name IS the value, * at any length; or the name holds a value that can name a secret (`namesASecret`, the floor a remote's words are read with) — a * short value such as a version `2` inside `read_v2` names nothing; a value of HTTP white space only names nothing — as its drop * record, the name erased; `undefined` for a tool the needle leaves. A name it refuses reaches no face the intake feeds: not the * mount, not a probe row, not a hint. */ export declare function echoedToolDrop(name: string, inputSchema: unknown, echo: CredentialEcho, declared: readonly string[]): { tool: string; reason: string; } | undefined; /** How a connection's account is read: its carrier's credentials, a site that held one announced through `announce`. */ export declare function carrierEcho(carrier: { readonly credentials: PeerCarrier["credentials"] | readonly string[]; }, announce: ((where: CredentialEchoSite) => void) | undefined): CredentialEcho; /** The server's `serverInfo` as its status projects it: `name` is a name (holding the needle, the record is not projected — never * rewritten), `version` free text (erased in place). */ export declare function serverInfoOf(info: { name: string; version: string; } | undefined, echo: CredentialEcho): { name: string; version: string; } | undefined; /** One materialization's announcer: each (peer, site) heard once, a throwing listener never a fault of the dial it describes. */ export declare function echoAnnouncer(onCredentialEchoed: ((peer: string, where: CredentialEchoSite) => void) | undefined): (peer: string, where: CredentialEchoSite) => void; /** The runner's listener → `mcp.credential_echoed` (engine-notice.ts): the peer and the site, never a value; operator audience. */ export declare function credentialEchoNotice(onNotice: ((notice: EngineNotice) => void) | undefined, sessionId: string, runId: string, protocol: "mcp" | "a2a"): (server: string, where: CredentialEchoSite) => void;