UNPKG

agentfootprint

Version:

The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.

75 lines • 2.91 kB
/** * record — what the pool says about itself: one event per use in a run, and a * report for what happens outside one. * * Pattern: facts gathered while a use runs, filed once; reports delivered to the * app's `onEvent`, which can never break the pool. * Role: § 8 of the design. The record holds ids and outcomes. It never holds * identity values, remote session ids or handles, header values, tool * arguments, results, definitions, or a server's error text. In a run, * every listing and every call files one `agentfootprint.tools.mcp_client` * (`tools/mcpClientUse.ts`). Outside a run — idle ends, evictions, * terminations, revoked leases, deferred ends and work that settled * after its deadline — the pool reports to `onEvent`. * * Local settlement and remote resolution are different facts, reported apart: * an ending can settle here and stay unresolved there. */ /** Delivers reports to the app; a throwing handler is swallowed and changes nothing. */ export class Reporter { server; onEvent; constructor(server, onEvent) { this.server = server; this.onEvent = onEvent; } report(report) { if (this.onEvent === undefined) return; try { this.onEvent({ server: this.server, ...report }); } catch { // The app's handler is not the pool's work: it changes nothing. } } } /** The facts one pool use gathers while it runs, filed once when it settles. */ export class UseFacts { server; at; keyHash; clientId; generation; client = 'refused'; previous; evidence; refusal; initMs; definitions; definitionsAgeMs; revalidated; constructor(server, at) { this.server = server; this.at = at; } /** The use, as `tools/mcpClientUse.ts` files it. */ toUse() { return { server: this.server, at: this.at, client: this.client, ...(this.keyHash !== undefined && { keyHash: this.keyHash }), ...(this.clientId !== undefined && { clientId: this.clientId }), ...(this.generation !== undefined && { generation: this.generation }), ...(this.previous !== undefined && { previous: this.previous }), ...(this.evidence !== undefined && { evidence: this.evidence }), ...(this.refusal !== undefined && { refusal: this.refusal }), ...(this.initMs !== undefined && { initMs: this.initMs }), ...(this.definitions !== undefined && { definitions: this.definitions }), ...(this.definitionsAgeMs !== undefined && { definitionsAgeMs: this.definitionsAgeMs }), ...(this.revalidated !== undefined && { revalidated: this.revalidated }), }; } } //# sourceMappingURL=record.js.map