UNPKG

agentfootprint

Version:

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

125 lines • 10.5 kB
"use strict"; /** * tool-providers — chainable tool dispatch + tool sources. * * Two layers under one subpath: * * 1. Tool dispatch (this folder) * - `staticTools(arr)` — wrap a flat tool list * - `gatedTools(inner, predicate)` — decorator that filters * - `ToolProvider` interface — the contract * - `ToolDispatchContext` — read-only context per iteration * * 2. Tool sources (re-exported from existing modules) * - `mcpClient(opts)` — connect to an MCP server (real) * - `mockMcpClient({ tools })` — in-memory MCP source for dev / tests * - `gatewayTransport({ url, credentials, service })` — an MCP * transport whose auth headers are vended PER REQUEST by a * `CredentialProvider`, for endpoints behind a token with an * expiry. The token is used once and never stored. * * 3. Tool sink — the other direction * - `mcpServe(tools, opts)` — expose your own `Tool[]` AS an MCP * server, so any MCP client can call them. The served tool is the * SAME object you pass in, so whatever governance you composed * around it still runs. * * Compose freely. The dispatch layer is decorator-shaped (mirroring * `withRetry` / `withFallback` over LLMProvider). Tool sources produce * `Tool[]` that flow into a `staticTools(arr)` provider, which can * then be wrapped by `gatedTools(...)` for permission gating or * per-skill filtering. * * @example Static (90% case — what `agent.tools(arr)` does today) * const provider = staticTools([weatherTool, lookupTool]); * * @example Read-only enforcement * const readOnly = gatedTools( * staticTools(allTools), * (name) => policy.isAllowed(name), * ); * * @example MCP source + permission gate * const slack = await mcpClient({ transport: ... }); * const slackTools = await slack.tools(); * const provider = gatedTools(staticTools(slackTools), (name) => allowed(name)); * * Not an import path of its own since 9.0.0. This is the implementation barrel * behind `agentfootprint/providers`, which re-exports every name here — same * symbols, one door. Import from the door. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.AGENTCORE_RUNTIME_SESSION_HEADER = exports.agentCoreRuntimeUrl = exports.agentCoreRuntimeMcpTransport = exports.AGENTCORE_SIGV4_SERVICE = exports.AGENTCORE_POLICY_SESSION_HEADER = exports.AGENTCORE_GATEWAY_SEARCH_TOOL = exports.hasGatewaySearch = exports.gatewaySearchTool = exports.agentCoreGatewayUrl = exports.agentCoreGatewayTransport = exports.PoolFullError = exports.McpPoolRefusedError = exports.MAX_SHARED_TOOLS = exports.MAX_DEFINITION_ENTRIES = exports.MCP_POOL_DEFAULTS = exports.mcpClientPool = exports.canTerminate = exports.retryingFetch = exports.MCP_TOOL_EXTRAS_KEY = exports.McpOutputUncheckedError = exports.McpToolListIncompleteError = exports.McpReplayUnavailableError = exports.GatewayAuthorizationRequiredError = exports.gatewayTransport = exports.mockMcpClient = exports.mcpServe = exports.mcpClient = exports.SKILL_SCOPED_TOOLS_ID_PREFIX = exports.skillScopedToolsTarget = exports.skillScopedTools = exports.gatedTools = exports.staticTools = void 0; var staticTools_js_1 = require("./staticTools.js"); Object.defineProperty(exports, "staticTools", { enumerable: true, get: function () { return staticTools_js_1.staticTools; } }); var gatedTools_js_1 = require("./gatedTools.js"); Object.defineProperty(exports, "gatedTools", { enumerable: true, get: function () { return gatedTools_js_1.gatedTools; } }); var skillScopedTools_js_1 = require("../tools/skillScopedTools.js"); Object.defineProperty(exports, "skillScopedTools", { enumerable: true, get: function () { return skillScopedTools_js_1.skillScopedTools; } }); // 8.7.0 — the provider-id convention, readable by anyone composing providers (and // by the agent builder, which uses it to name a redundant pairing at build time). Object.defineProperty(exports, "skillScopedToolsTarget", { enumerable: true, get: function () { return skillScopedTools_js_1.skillScopedToolsTarget; } }); Object.defineProperty(exports, "SKILL_SCOPED_TOOLS_ID_PREFIX", { enumerable: true, get: function () { return skillScopedTools_js_1.SKILL_SCOPED_TOOLS_ID_PREFIX; } }); // Re-export tool sources from the MCP module so consumers find them in // one place. This subpath is the ONLY place `mcpClient` is public — the // top-level barrel does not re-export it. var index_js_1 = require("../mcp/index.js"); Object.defineProperty(exports, "mcpClient", { enumerable: true, get: function () { return index_js_1.mcpClient; } }); Object.defineProperty(exports, "mcpServe", { enumerable: true, get: function () { return index_js_1.mcpServe; } }); Object.defineProperty(exports, "mockMcpClient", { enumerable: true, get: function () { return index_js_1.mockMcpClient; } }); Object.defineProperty(exports, "gatewayTransport", { enumerable: true, get: function () { return index_js_1.gatewayTransport; } }); Object.defineProperty(exports, "GatewayAuthorizationRequiredError", { enumerable: true, get: function () { return index_js_1.GatewayAuthorizationRequiredError; } }); // A call under `replay: { policy: 'app-authorized' }` that the connection // cannot honour (its requests unmatched, or its answers unseen) is refused // before it is sent, with this error and a typed reason. Object.defineProperty(exports, "McpReplayUnavailableError", { enumerable: true, get: function () { return index_js_1.McpReplayUnavailableError; } }); // A server's tool list that could not be read to its end — past 100 requests, // or a cursor it already sent — is refused with this error and a typed // reason; what was listed travels on it, never as a list cut short. Object.defineProperty(exports, "McpToolListIncompleteError", { enumerable: true, get: function () { return index_js_1.McpToolListIncompleteError; } }); // A tool whose list the SDK no longer holds, and whose output this connection // cannot check (no JSON Schema validator reachable), is refused, never // answered unchecked. Object.defineProperty(exports, "McpOutputUncheckedError", { enumerable: true, get: function () { return index_js_1.McpOutputUncheckedError; } }); // The `_meta` key agentfootprint's tool declarations travel under, in both // directions (9.71.0). Public so a server this library did not write can // speak it, and so a client can read a bag it received. Object.defineProperty(exports, "MCP_TOOL_EXTRAS_KEY", { enumerable: true, get: function () { return index_js_1.MCP_TOOL_EXTRAS_KEY; } }); // The 429 retry `mcpClient({ transport })` applies for you (9.81.0). Public // so `mcpClient({ connection })` — the arm a browser takes, where the library // builds no transport — can wrap its own `fetch` with the same code rather // than quietly doing without it. Object.defineProperty(exports, "retryingFetch", { enumerable: true, get: function () { return index_js_1.retryingFetch; } }); // Ending a client's remote session — a capability `terminate?()` a client may // have; ask before calling it. Object.defineProperty(exports, "canTerminate", { enumerable: true, get: function () { return index_js_1.canTerminate; } }); // A client per conversation for one MCP server: bounded, ended remotely, its // tool definitions per client incarnation unless the app declares sharing. Object.defineProperty(exports, "mcpClientPool", { enumerable: true, get: function () { return index_js_1.mcpClientPool; } }); Object.defineProperty(exports, "MCP_POOL_DEFAULTS", { enumerable: true, get: function () { return index_js_1.MCP_POOL_DEFAULTS; } }); Object.defineProperty(exports, "MAX_DEFINITION_ENTRIES", { enumerable: true, get: function () { return index_js_1.MAX_DEFINITION_ENTRIES; } }); Object.defineProperty(exports, "MAX_SHARED_TOOLS", { enumerable: true, get: function () { return index_js_1.MAX_SHARED_TOOLS; } }); Object.defineProperty(exports, "McpPoolRefusedError", { enumerable: true, get: function () { return index_js_1.McpPoolRefusedError; } }); Object.defineProperty(exports, "PoolFullError", { enumerable: true, get: function () { return index_js_1.PoolFullError; } }); // Reaching an AWS Bedrock AgentCore Gateway (9.66.0). A configuration of // `gatewayTransport` plus the four facts that are AgentCore's alone — kept in // the vendor's own file so the transport above stays able to say, truthfully, // that nothing in it is vendor-specific. var agentcore_js_1 = require("../adapters/mcp/agentcore.js"); Object.defineProperty(exports, "agentCoreGatewayTransport", { enumerable: true, get: function () { return agentcore_js_1.agentCoreGatewayTransport; } }); Object.defineProperty(exports, "agentCoreGatewayUrl", { enumerable: true, get: function () { return agentcore_js_1.agentCoreGatewayUrl; } }); Object.defineProperty(exports, "gatewaySearchTool", { enumerable: true, get: function () { return agentcore_js_1.gatewaySearchTool; } }); Object.defineProperty(exports, "hasGatewaySearch", { enumerable: true, get: function () { return agentcore_js_1.hasGatewaySearch; } }); Object.defineProperty(exports, "AGENTCORE_GATEWAY_SEARCH_TOOL", { enumerable: true, get: function () { return agentcore_js_1.AGENTCORE_GATEWAY_SEARCH_TOOL; } }); Object.defineProperty(exports, "AGENTCORE_POLICY_SESSION_HEADER", { enumerable: true, get: function () { return agentcore_js_1.AGENTCORE_POLICY_SESSION_HEADER; } }); Object.defineProperty(exports, "AGENTCORE_SIGV4_SERVICE", { enumerable: true, get: function () { return agentcore_js_1.AGENTCORE_SIGV4_SERVICE; } }); // An MCP server HOSTED ON AgentCore Runtime — an `http` transport whose fetch // carries the runtime's session, its session-busy retry and its auth (SigV4 // through InvokeAgentRuntime, or a bearer token over HTTPS). `mcpClient` sees an // ordinary Streamable HTTP server. var transport_js_1 = require("../adapters/mcp/agentcoreRuntime/transport.js"); Object.defineProperty(exports, "agentCoreRuntimeMcpTransport", { enumerable: true, get: function () { return transport_js_1.agentCoreRuntimeMcpTransport; } }); Object.defineProperty(exports, "agentCoreRuntimeUrl", { enumerable: true, get: function () { return transport_js_1.agentCoreRuntimeUrl; } }); var session_js_1 = require("../adapters/mcp/agentcoreRuntime/session.js"); Object.defineProperty(exports, "AGENTCORE_RUNTIME_SESSION_HEADER", { enumerable: true, get: function () { return session_js_1.AGENTCORE_RUNTIME_SESSION_HEADER; } }); //# sourceMappingURL=index.js.map