fix: use parameters + content[] format per OpenClaw plugin spec
- inputSchema → parameters
- { result: text } → { content: [{ type: "text", text }] }
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,7 @@ export function registerPromptRulesTool(
|
||||
"test (preview which prompts would be injected for an agent), " +
|
||||
"reload-routers (hot-reload all router functions), " +
|
||||
"list-routers (show loaded routers).",
|
||||
inputSchema: {
|
||||
parameters: {
|
||||
type: "object",
|
||||
properties: {
|
||||
action: {
|
||||
@@ -55,51 +55,45 @@ export function registerPromptRulesTool(
|
||||
switch (action) {
|
||||
case "add": {
|
||||
if (!router || !key || !file) {
|
||||
return { result: "Error: add requires router, key, and file" };
|
||||
return { content: [{ type: "text", text: "Error: add requires router, key, and file" }] };
|
||||
}
|
||||
addRule(router, key, file);
|
||||
return { result: `Rule added: ${router}:${key} → ${file}` };
|
||||
return { content: [{ type: "text", text: `Rule added: ${router}:${key} → ${file}` }] };
|
||||
}
|
||||
case "remove": {
|
||||
if (!router || !key) {
|
||||
return { result: "Error: remove requires router and key" };
|
||||
return { content: [{ type: "text", text: "Error: remove requires router and key" }] };
|
||||
}
|
||||
const removed = removeRule(router, key);
|
||||
return {
|
||||
result: removed
|
||||
? `Rule removed: ${router}:${key}`
|
||||
: `Rule not found: ${router}:${key}`,
|
||||
};
|
||||
const msg = removed ? `Rule removed: ${router}:${key}` : `Rule not found: ${router}:${key}`;
|
||||
return { content: [{ type: "text", text: msg }] };
|
||||
}
|
||||
case "list": {
|
||||
const rules = listRules();
|
||||
const entries = Object.entries(rules);
|
||||
if (entries.length === 0) return { result: "No rules registered." };
|
||||
return { result: entries.map(([k, v]) => `${k} → ${v}`).join("\n") };
|
||||
if (entries.length === 0) return { content: [{ type: "text", text: "No rules registered." }] };
|
||||
return { content: [{ type: "text", text: entries.map(([k, v]) => `${k} → ${v}`).join("\n") }] };
|
||||
}
|
||||
case "test": {
|
||||
if (!agent) return { result: "Error: test requires agent" };
|
||||
if (!agent) return { content: [{ type: "text", text: "Error: test requires agent" }] };
|
||||
const result = await resolveInjection({ agentId: agent }, api.logger);
|
||||
if (!result.appendSystemContext) {
|
||||
return { result: `No prompts matched for agent: ${agent}` };
|
||||
return { content: [{ type: "text", text: `No prompts matched for agent: ${agent}` }] };
|
||||
}
|
||||
return { result: `Matched prompts for ${agent}:\n\n${result.appendSystemContext}` };
|
||||
return { content: [{ type: "text", text: `Matched prompts for ${agent}:\n\n${result.appendSystemContext}` }] };
|
||||
}
|
||||
case "reload-routers": {
|
||||
await loadRouters(routersDir, api.logger);
|
||||
const names = getRouterNames();
|
||||
return { result: `Routers reloaded: ${names.join(", ") || "(none)"}` };
|
||||
return { content: [{ type: "text", text: `Routers reloaded: ${names.join(", ") || "(none)"}` }] };
|
||||
}
|
||||
case "list-routers": {
|
||||
const names = getRouterNames();
|
||||
return {
|
||||
result: names.length > 0
|
||||
? `Loaded routers: ${names.join(", ")}`
|
||||
: "No routers loaded.",
|
||||
};
|
||||
const msg = names.length > 0 ? `Loaded routers: ${names.join(", ")}` : "No routers loaded.";
|
||||
return { content: [{ type: "text", text: msg }] };
|
||||
}
|
||||
default:
|
||||
return { result: `Unknown action: ${action}` };
|
||||
return { content: [{ type: "text", text: `Unknown action: ${action}` }] };
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user