Add MCP servers and custom tools for bots
Two new settings pages, MCPs and Tools. Super admins define them; super
admins and admins attach them to bots, to workspaces (every bot there),
or to every bot. Bots get them in chat replies and tasks.
- Custom tools: a JSON-schema of arguments plus an HTTP request, a script
on the bot's computer, or a prompt, templated with {{args.x}} and
{{env.KEY}}, secrets redacted from results.
- MCP servers: remote (URL and headers) or stdio commands run on the host
with a setup command and an isolated env, in a per-process pool. Tools
are listed into a cache and connect on first call.
- Add, edit, access and try open in modals.
- Markdown, JSON and command fields use twui's AceEditor (CodeEditor),
its scripts loaded on demand.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* What a custom tool does when a bot calls it. `http` calls an API from the
|
||||
* app, `script` runs code on the run's computer, `prompt` runs one model
|
||||
* turn with a filled-in prompt.
|
||||
*/
|
||||
export const CustomToolKinds = [
|
||||
{
|
||||
title: "HTTP request",
|
||||
value: "http",
|
||||
description: "Calls an API from the app and returns the response.",
|
||||
},
|
||||
{
|
||||
title: "Script on a computer",
|
||||
value: "script",
|
||||
description: "Runs code on the bot's computer and returns what it prints.",
|
||||
},
|
||||
{
|
||||
title: "Prompt",
|
||||
value: "prompt",
|
||||
description: "Runs one model turn with a filled-in prompt and returns the answer.",
|
||||
},
|
||||
] as const;
|
||||
|
||||
export type CustomToolKind = (typeof CustomToolKinds)[number]["value"];
|
||||
|
||||
export const CustomToolHttpMethods = ["GET", "POST", "PUT", "PATCH", "DELETE"] as const;
|
||||
|
||||
export type CustomToolHttpMethod = (typeof CustomToolHttpMethods)[number];
|
||||
|
||||
/**
|
||||
* Languages a script tool runs in, with the interpreter on the computer
|
||||
* and the code editor's mode.
|
||||
*/
|
||||
export const CustomToolScriptLanguages = [
|
||||
{ title: "Bash", value: "bash", interpreter: "bash", extension: "sh", editor_mode: "sh" },
|
||||
{ title: "Python", value: "python", interpreter: "python3", extension: "py", editor_mode: "python" },
|
||||
{ title: "JavaScript", value: "javascript", interpreter: "node", extension: "js", editor_mode: "javascript" },
|
||||
] as const;
|
||||
|
||||
export type CustomToolScriptLanguage = (typeof CustomToolScriptLanguages)[number]["value"];
|
||||
|
||||
/**
|
||||
* Names the built-in bot tools use. A custom tool can't take one, and
|
||||
* names starting with a computer's tool prefixes are kept for them too.
|
||||
*/
|
||||
export const ReservedToolNames = [
|
||||
"add_bot_to_workspace",
|
||||
"ask_user_to_take_over",
|
||||
"assign_computer",
|
||||
"create_bot",
|
||||
"create_schedule",
|
||||
"create_workspace",
|
||||
"delegate_task",
|
||||
"delete_schedule",
|
||||
"list_schedules",
|
||||
"search_computers",
|
||||
"set_bot_workspace_instructions",
|
||||
"set_workspace_computer",
|
||||
"start_task",
|
||||
"update_instructions",
|
||||
"update_memory",
|
||||
"update_schedule",
|
||||
"update_workspace",
|
||||
] as const;
|
||||
|
||||
export const ReservedToolPrefixes = ["sandbox_", "browser_"] as const;
|
||||
Reference in New Issue
Block a user