优化第一阶段

This commit is contained in:
yinsx
2025-12-22 12:07:12 +08:00
parent dd99e932b4
commit 1df41ac4ab
38 changed files with 340 additions and 300 deletions

23
lib/plugins/registry.js Normal file
View File

@ -0,0 +1,23 @@
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];
}