UNPKG

agentfootprint

Version:

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

96 lines • 4.27 kB
"use strict"; /** * errors — the pool's two refusals, each one fixed sentence. * * Pattern: typed errors whose message reaches the model and whose fields reach * the app. * Role: A refusal comes before the `tools/call` is sent, and says so * (`sent: false`) for the record of what that attempt did. Control * requests made on the way — the `initialize` of a replacement client, * a revalidating `tools/list` — may already have reached the server; * `sent` describes the `tools/call` only. * * A message is a fixed sentence per reason. It names no identity, no key, no * session and no count: the counts ride typed fields the app reads, and the * original error of a failed open rides `cause`, for the app, never composed * into the message. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.PoolFullError = exports.POOL_FULL_SENTENCE = exports.McpPoolRefusedError = exports.MCP_POOL_REFUSAL_SENTENCES = void 0; /** The sentence each refusal reaches the model as. */ exports.MCP_POOL_REFUSAL_SENTENCES = Object.freeze({ 'no-identity': "This tool needs the caller's identity and none was named, so the call this result answers was not sent.", 'incomplete-identity': 'This tool needs a complete caller identity and the one named is incomplete, so the call this result answers was not sent.', 'identity-mismatch': 'This tool was listed for another conversation, so the tool call was not sent.', 'init-timeout': 'The connection to this server did not open in time, so the tool call was not sent.', 'init-failed': 'The connection to this server could not be opened, so the tool call was not sent.', 'stale-tools': "This tool's definition is no longer current, so the tool call was not sent. List the tools again.", 'binding-changed': 'This tool was listed for another configuration of this server, so the tool call was not sent. List the tools again.', 'request-unmatched': "The pool could not check this tool's request against its listing before sending it, so the tool call was not sent.", 'lease-expired': 'This connection lease has expired, so the tool call was not sent.', closed: 'The connection pool for this server is closed, so the tool call was not sent.', }); /** * The pool refused before the `tools/call` was sent — by `reason`. * * `init-failed` keeps the open's own error as `cause`, for the app; its text is * never in the message. */ class McpPoolRefusedError extends Error { reason; server; code = 'ERR_MCP_POOL_REFUSED'; /** The `tools/call` was not sent. Control requests on the way may have been. */ sent = false; constructor(reason, /** The pool's name: the server. */ server, options = {}) { super(exports.MCP_POOL_REFUSAL_SENTENCES[reason], { ...(options.cause !== undefined && { cause: options.cause }), }); this.reason = reason; this.server = server; this.name = 'McpPoolRefusedError'; } } exports.McpPoolRefusedError = McpPoolRefusedError; /** The one sentence a full pool reaches the model as. */ exports.POOL_FULL_SENTENCE = 'The connection pool for this server was full, so the tool call was not sent.'; /** * A budget was full, so the work was refused at once — there is no queue. Its * scope is the `tools/call`, as with `sent: false`. The counts ride typed fields. */ class PoolFullError extends Error { server; limit; max; busy; ending; operations; code = 'ERR_MCP_POOL_FULL'; sent = false; constructor( /** The pool's name: the server. */ server, /** Which budget was full. */ limit, /** That budget's size. */ max, /** Busy clients when it was refused. */ busy, /** Clients being ended when it was refused. */ ending, /** Operations charged when it was refused. */ operations) { super(exports.POOL_FULL_SENTENCE); this.server = server; this.limit = limit; this.max = max; this.busy = busy; this.ending = ending; this.operations = operations; this.name = 'PoolFullError'; } } exports.PoolFullError = PoolFullError; //# sourceMappingURL=errors.js.map