Let the coordinator manage skills, MCP servers and tools, behind a confirm card
- Coordinator tools in its own chat (super admin only): list_extensions,
set_extension_access, delete_extension, and update_skill /
update_mcp_server / update_custom_tool for what can't change where
anything is sent (on/off, names, arguments, left-out tools)
- Adding a skill, MCP server or tool, or changing a skill's words, a
server's URL or headers or a tool's kind or config, goes through
propose_skill / propose_mcp_server / propose_custom_tool: stored in
extension_proposals with the bot's background check, shown as a
[proposal:ID] chip that opens a card with Confirm and Reject
- The card's facts are worked out by the app from what Confirm saves: the
host, every {{env.KEY}} and whether it's saved, the config; for a skill
its links, hosts, tool names, mentions of secrets and a diff against
the saved runbook
- Confirming decides once and checks again; a server or tool missing a key
is saved switched off, and the outcome is posted to the bot in chat
- Never from a bot: stdio servers, a URL whose host a template decides,
envs in a prompt tool, a key's value
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
import { z } from "zod";
|
||||
import grabCustomTool from "@/src/functions/backend/db/extensions/grab-custom-tool";
|
||||
import saveCustomTool from "@/src/functions/backend/db/extensions/save-custom-tool";
|
||||
import testCustomTool from "@/src/functions/backend/db/extensions/test-custom-tool";
|
||||
import logEvent from "@/src/functions/backend/logger";
|
||||
import type { HarnessTool } from "../../../types";
|
||||
import assertSuperAdminRun from "./assert-super-admin-run";
|
||||
import mergeCustomToolChanges from "./merge-custom-tool-changes";
|
||||
|
||||
type Params = {
|
||||
user_id: number | string;
|
||||
};
|
||||
|
||||
type Args = {
|
||||
custom_tool_id: number;
|
||||
name?: string;
|
||||
description?: string;
|
||||
parameters?: Record<string, unknown>;
|
||||
enabled?: boolean;
|
||||
all_bots?: boolean;
|
||||
test_args?: Record<string, unknown>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Lets the coordinator change a custom tool's name, description, arguments
|
||||
* and whether it's on, and try it. What it runs and where it sends (its
|
||||
* kind and config) are never changed here: those go through
|
||||
* `propose_custom_tool`, which the super admin confirms.
|
||||
*/
|
||||
export default function updateCustomToolTool({ user_id }: Params): HarnessTool<Args> {
|
||||
return {
|
||||
name: "update_custom_tool",
|
||||
description: `Change a custom tool's name, description, parameters (the JSON schema of its arguments), enabled or all_bots (gives it to every bot now and every new one). Every field you leave out stays. Give test_args to run it once afterwards (a script on the main computer) and see what a bot would get back; test_args alone just tries it. To add a tool, or change its kind or config (what it runs, where it sends), use propose_custom_tool: the user confirms those.`,
|
||||
schema: z.object({
|
||||
custom_tool_id: z.number().int().positive(),
|
||||
name: z.string().trim().max(80).optional(),
|
||||
description: z.string().trim().max(2000).optional(),
|
||||
parameters: z.record(z.string(), z.unknown()).optional().describe("JSON schema of the arguments object"),
|
||||
enabled: z.boolean().optional(),
|
||||
all_bots: z.boolean().optional(),
|
||||
test_args: z.record(z.string(), z.unknown()).optional().describe("Arguments to try it with"),
|
||||
}),
|
||||
run: async ({ args }) => {
|
||||
await assertSuperAdminRun({ user_id });
|
||||
|
||||
const { custom_tool_id, test_args, ...changes } = args;
|
||||
const current = await grabCustomTool({ custom_tool_id });
|
||||
const changing = Object.values(changes).some((value) => value !== undefined);
|
||||
|
||||
if (changing) {
|
||||
await saveCustomTool({ user_id, data: mergeCustomToolChanges({ current, changes }) });
|
||||
|
||||
await logEvent({
|
||||
title: "Tool changed",
|
||||
category: "system",
|
||||
user_id: Number(user_id),
|
||||
plain_text: `The coordinator changed the tool ${changes.name || current.name} (#${custom_tool_id}).`,
|
||||
metadata: { custom_tool_id },
|
||||
});
|
||||
}
|
||||
|
||||
const saved = await grabCustomTool({ custom_tool_id });
|
||||
const head = changing
|
||||
? `Tool #${custom_tool_id} ${saved.name} is saved and ${saved.enabled ? "on" : "off"}.`
|
||||
: `Tool #${custom_tool_id} ${saved.name} is unchanged.`;
|
||||
|
||||
if (!test_args) return changing ? `${head} It wasn't tried: give test_args to try it.` : head;
|
||||
|
||||
const test = await testCustomTool({ custom_tool_id, args: test_args });
|
||||
|
||||
return `${head} Tried it: ${test.ok ? "it worked" : "it failed"}. What a bot would get back:\n${test.output}`;
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user