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:
2026-10-25 06:08:09 +01:00
co-authored by Claude Opus 5.5
parent e6c278198b
commit fefc295d15
77 changed files with 3307 additions and 12 deletions
@@ -0,0 +1,71 @@
import type { CustomToolHttpMethods, CustomToolKind, CustomToolScriptLanguage } from "@/src/dict/custom-tool-dict";
import { SaveCustomToolRequestSchema, type SaveCustomToolRequest } from "@/src/schemas/extension-schema";
import type { CustomToolRecord } from "@/src/types";
import parseWithSchema from "@/src/utils/parse-with-schema";
import mergeTemplateMap from "./merge-template-map";
export type CustomToolConfigChanges = {
method?: (typeof CustomToolHttpMethods)[number];
url?: string;
/**
* Entries to set, a null removing one.
*/
headers?: Record<string, string | null>;
body?: string;
timeout_ms?: number;
language?: CustomToolScriptLanguage;
code?: string;
prompt?: string;
};
export type CustomToolChanges = {
name?: string;
description?: string;
kind?: CustomToolKind;
parameters?: Record<string, unknown>;
config?: CustomToolConfigChanges;
enabled?: boolean;
all_bots?: boolean;
};
type Params = {
/**
* The tool being changed, null for a new one.
*/
current: CustomToolRecord | null;
changes: CustomToolChanges;
};
/**
* A custom tool as a bot's changes would leave it: every field it leaves
* out kept (config fields too while the kind stays), an HTTP tool's
* headers changed entry by entry, then checked like the settings page's
* form (`SaveCustomToolRequestSchema`).
*/
export default function mergeCustomToolChanges({ current, changes }: Params): SaveCustomToolRequest {
const kind = changes.kind ?? current?.kind;
const kept: Record<string, unknown> = current && current.kind == kind ? { ...current.config } : {};
const { headers, ...config_changes } = changes.config || {};
const config: Record<string, unknown> = { ...kept, ...config_changes };
if (kind == "http") {
config.headers = mergeTemplateMap({
current: (kept.headers as Record<string, string>) || {},
changes: headers,
});
}
return parseWithSchema({
schema: SaveCustomToolRequestSchema,
data: {
custom_tool_id: current?.id,
name: changes.name ?? current?.name,
description: changes.description ?? current?.description,
kind,
parameters: changes.parameters ?? current?.parameters ?? { type: "object", properties: {} },
config,
enabled: changes.enabled ?? current?.enabled ?? true,
all_bots: changes.all_bots ?? current?.all_bots ?? false,
},
});
}