/** * Transport interfaces — the boundary between `edsger-tools` and any * specific runtime (CLI auth-store, agents worker, web session, mock). * * `edsger-tools` makes zero assumptions about how a request reaches the * backend. A consumer constructs an `McpTransport` (and, where relevant, * an `AgentsApiTransport`) and hands it to a server factory. The factory * binds the transport into every `tool()` handler via closure. * * This keeps `edsger-tools` deployable in any context: CLI, worker, web, * test harness — only the transport implementation differs. */ /** * Calls an MCP edge-function endpoint over JSON-RPC. * * Implementations are expected to: * - resolve the server URL and auth token from their own configuration, * - POST `{ jsonrpc, method, params, id }` to the MCP endpoint, * - throw a descriptive `Error` on transport failure or `data.error`, * - return `data.result` on success. * * Cross-cutting concerns like circuit breakers, retries, or rate limits * are an implementation detail of the transport. */ export interface McpTransport { call(method: string, params: unknown): Promise; } /** * Calls an Agents API method (the agent-specific edge function). Same * contract as `McpTransport` but routes to a different backend. * * Optional — only `agent`-category tools require it. */ export interface AgentsApiTransport { call(method: string, params: unknown): Promise; } /** * Records a single tool invocation. Wired into the agent worker for * tool-call accounting; defaults to a no-op for one-shot consumers. */ export interface ToolTracker { (name: string, input: unknown, output: unknown, success: boolean): void; } /** * Per-invocation context surfaced to handlers (e.g. agent ID, product ID, * session ID). Servers cherry-pick what they need; missing values are * left as `undefined`. */ export type ToolContext = Record; /** * Bundle of dependencies handed to every server factory. Most servers * only need `mcp` + `tracker`; agent-facing servers also need * `agentsApi`. `context` carries identity / scoping values consumed by * `mapArgs` callbacks in the bindings. */ export interface ToolDeps { /** MCP transport — required by every server. */ mcp: McpTransport; /** Agents-API transport — required only by `agent`-category bindings. */ agentsApi?: AgentsApiTransport; /** Optional observability hook. Defaults to no-op when omitted. */ tracker?: ToolTracker; /** Per-invocation identity / scoping. Consumed by binding `mapArgs`. */ context?: ToolContext; /** * Override the per-result truncation cap (in characters). Defaults * to {@link DEFAULT_MAX_RESULT_CHARS} when omitted. Useful for * detail-heavy reads (issue full body, test report) that would * otherwise truncate; or for setting tighter caps on listing tools. */ maxResultChars?: number; } /** * Resolve a tracker, defaulting to no-op. Internal helper used by `wrap`. */ export declare function resolveTracker(deps: ToolDeps): ToolTracker;