Files
yinx-cli/lib/plugins/registry.js
2025-12-22 12:07:12 +08:00

24 lines
467 B
JavaScript

const tools = [];
export function registerTool(definition) {
const { id, name, desc, run } = definition || {};
if (!id || !name || !run) {
throw new Error("Tool definition must include id, name and run");
}
const existing = tools.findIndex(t => t.id === id);
const tool = { ...definition };
if (existing >= 0) {
tools[existing] = tool;
} else {
tools.push(tool);
}
return tool;
}
export function getTools() {
return [...tools];
}