UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

54 lines (53 loc) • 4.62 kB
/** * A protocol peer's REGISTRATION as a person's yes binds it: the declaration as the host wrote it — the facts it states about where a * call to the peer's tools goes, as whom and with which identity, each as written (no spelling is judged equal to another: the * deployment's peer seat is handed the spelling and may answer each differently), read off the declaration the dial judged by that * protocol's materializer (`a2aPeerRegistration`, `mcpPeerRegistration`), never off the peer. The one equality is a default the * declaration type itself states (`boundary` absent is `outside`, `callerMeta` absent is `false`), which the materializer writes out. * * A tool carries only a reader returning their digest (`AgentTool.peerRegistration`), minted here once and omitted from JSON; the * roster row carries no registration member and no frame digest depends on it. `toolDeclarationDigestOf` reads the digest off the * live backing tool instance for protocol rows (`mcp` / `a2a`), so a parked approval's declaration digest covers the registration and * a resume whose registration moved — another spelling included — vetoes the approved call (`resume.target_moved`). The digest is * deterministic and unsalted: one registration has one digest across processes and deployments. The facts never ride the tool object: * it is handed whole to a host's model adapter and counted by the spend meter. */ import type { CredentialRef } from "@sema-agent/primitives"; import type { A2aServerSpec, McpServerSpec, McpTransportKind } from "./mcp-server-spec.js"; /** The facts of one registration: JSON data (strings, lists of strings, a credential reference record), an absent fact not a key. */ export type PeerRegistrationFacts = { readonly [fact: string]: unknown; }; /** The digest a tool carries for its peer's registration, keyed by protocol (an MCP server's facts and an A2A peer's never read as one * another's). The one mint of `AgentTool.peerRegistration`. */ export declare function peerRegistrationDigestOf(source: "mcp" | "a2a", facts: PeerRegistrationFacts): string; /** * A credential reference as a registration fact, by its content (`CREDENTIAL_REF_KINDS`): its kind always — declaring none and * declaring one are two registrations — and, for a reference that IS its own content, the rest as written: `env` (header → variable * names), `vault` (the stored entry it names), `assertion` (the audience it is requested for). A `handle`'s id is not content: an opaque * id the deployment minted, which a deployment may mint again per process for the same credential, so a handle enters as its kind * alone (KL-5333-c). The one reading both protocols take. */ export declare function credentialReferenceFact(ref: CredentialRef | undefined): { credentials?: CredentialRef | { readonly kind: "handle"; }; }; /** * An A2A peer's registration facts, each as the host wrote it: its addresses (`url`, `cardUrl`), its side of the trust boundary (absent * is `outside`, the declaration type's own default), its owning team, its identity stamp, its credential reference when that is its own * content ({@link credentialReferenceFact}) and the header the end user's identity rides under. Not among them: its display name (the * card's label for people, as a row's render hints are) and which skills it exposes (`allowSkills` says whether a tool is there at all — * a skill no longer mounted is `resume.tool_unavailable`). Read off the declaration the dial judged, never off the card. */ export declare function a2aPeerRegistration(spec: A2aServerSpec): PeerRegistrationFacts; /** * An MCP server's registration facts, each as the host wrote it: its transport as the peer seat is asked about it ({@link mcpPeerTarget}: * the endpoint, or the whole start command, each with its credential reference when that is its own content; or the host's own pipe), * the header the end user's identity rides under, its mount identity stamp, and what its requests disclose of the caller * (`sessionMetaKey`, `callerMeta` — absent is `false`, the declaration type's own default). A host pipe has no address: what is compared * is its stamp and the two caller settings (KL-5333-b). Not among them: which tools it exposes (`allowTools` — a tool no longer mounted * is `resume.tool_unavailable`), its startup bound, and the axes the roster row already carries as declaration members. `kind` is the * dial's one read of the transport's kind. */ export declare function mcpPeerRegistration(spec: McpServerSpec, kind: McpTransportKind | undefined): PeerRegistrationFacts;