"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ALWAYS_LOAD_META_KEY = void 0;
exports.eagerTool = eagerTool;
/**
 * MCP eager-load helper.
 *
 * The Claude Code SDK marks every MCP tool as deferred-by-default: the model
 * cannot invoke an MCP tool until it has first called `ToolSearch` to load
 * the schema, which costs one extra turn per unique schema. The SDK's per-
 * tool override is `_meta["anthropic/alwaysLoad"]: true` on the tool's
 * `tools/list` entry, which `isDeferredTool` reads to flip the default.
 *
 * The MCP SDK exposes that channel only via `server.registerTool(name,
 * config, handler)`; the older `server.tool(name, desc, schema, handler)`
 * has no `_meta` parameter. This helper wraps the registerTool call so
 * every plugin's index.ts can opt a tool into eager-load with one line
 * matching the shape of the existing four-arg `server.tool` overload.
 *
 * Use for every tool that appears in `ADMIN_CORE_TOOLS` — the permission
 * allow-list IS the curation per the CEO review. Tools the
 * admin should not see should be removed from the allow-list, not merely
 * left deferred.
 */
/** Wire-format metadata key the Claude Code SDK reads. */
exports.ALWAYS_LOAD_META_KEY = "anthropic/alwaysLoad";
/**
 * Register an MCP tool that the Claude Code SDK eager-loads into the
 * model's prompt at session boot, bypassing the ToolSearch round-trip.
 *
 * Mirrors the four-arg `server.tool(name, description, inputSchema, handler)`
 * call shape — the only overload in use across our plugins — so callers
 * replace `server.tool(` with `eagerTool(server, ` mechanically.
 *
 * The helper deliberately does not constrain handler-arg types itself; the
 * downstream `server.registerTool` invocation inside this function passes
 * the shape through, and the upstream MCP SDK's overload (resolved against
 * the consumer's own zod version) infers the handler args.
 */
function eagerTool(server, name, description, inputSchema, 
// eslint-disable-next-line @typescript-eslint/no-explicit-any
handler) {
    server.registerTool(name, {
        description,
        inputSchema,
        _meta: { [exports.ALWAYS_LOAD_META_KEY]: true },
    }, handler);
}
//# sourceMappingURL=index.js.map