UNPKG

agentfootprint

Version:

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

98 lines • 5.46 kB
/** * 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. */ export { staticTools } from './staticTools.js'; export { gatedTools } from './gatedTools.js'; export { 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). skillScopedToolsTarget, SKILL_SCOPED_TOOLS_ID_PREFIX, } from '../tools/skillScopedTools.js'; // 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. export { mcpClient, mcpServe, mockMcpClient, gatewayTransport, 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. 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. 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. 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. 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. retryingFetch, // Ending a client's remote session — a capability `terminate?()` a client may // have; ask before calling it. canTerminate, // A client per conversation for one MCP server: bounded, ended remotely, its // tool definitions per client incarnation unless the app declares sharing. mcpClientPool, MCP_POOL_DEFAULTS, MAX_DEFINITION_ENTRIES, MAX_SHARED_TOOLS, McpPoolRefusedError, PoolFullError, } from '../mcp/index.js'; // 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. export { agentCoreGatewayTransport, agentCoreGatewayUrl, gatewaySearchTool, hasGatewaySearch, AGENTCORE_GATEWAY_SEARCH_TOOL, AGENTCORE_POLICY_SESSION_HEADER, AGENTCORE_SIGV4_SERVICE, } from '../adapters/mcp/agentcore.js'; // 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. export { agentCoreRuntimeMcpTransport, agentCoreRuntimeUrl, } from '../adapters/mcp/agentcoreRuntime/transport.js'; export { AGENTCORE_RUNTIME_SESSION_HEADER } from '../adapters/mcp/agentcoreRuntime/session.js'; //# sourceMappingURL=index.js.map