temp
This commit is contained in:
23
dist/tools/registry.js
vendored
Normal file
23
dist/tools/registry.js
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ALL_TOOLS = void 0;
|
||||
exports.registerTool = registerTool;
|
||||
exports.executeTool = executeTool;
|
||||
/** Live registry — grows as domain files are imported. */
|
||||
const _registry = new Map();
|
||||
/**
|
||||
* Mutable array kept in sync with the registry.
|
||||
* Used by agents.ts to pick tool subsets by name (backwards-compatible with ALL_TOOLS).
|
||||
*/
|
||||
exports.ALL_TOOLS = [];
|
||||
function registerTool(tool) {
|
||||
_registry.set(tool.name, tool);
|
||||
exports.ALL_TOOLS.push(tool);
|
||||
}
|
||||
/** Dispatch a tool call by name — O(1) map lookup, no switch needed. */
|
||||
async function executeTool(name, args, ctx) {
|
||||
const tool = _registry.get(name);
|
||||
if (!tool)
|
||||
return { error: `Unknown tool: ${name}` };
|
||||
return tool.handler(args, ctx);
|
||||
}
|
||||
Reference in New Issue
Block a user