Files
cobble/src/harness/tools/custom/run-prompt-tool.ts
T
tbenandClaude Opus 5.5 c6ec7d77a2 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]>
2026-10-19 15:01:39 +01:00

31 lines
935 B
TypeScript

import type { CustomToolPromptConfig } from "@/src/types";
import fillTemplate from "@/src/utils/fill-template";
import generateText from "../../text/generate-text";
type Params = {
config: CustomToolPromptConfig;
args: Record<string, unknown>;
envs: { key: string; value: string }[];
/**
* Its models are used, like the run's.
*/
bot_id?: number | string;
workspace_id?: number | string | null;
signal: AbortSignal;
};
/**
* Fills the tool's prompt in and answers it with one text model turn (no
* tools). Returns the answer.
*/
export default async function runPromptTool({ config, args, envs, bot_id, workspace_id, signal }: Params) {
const result = await generateText({
messages: [{ role: "user", content: fillTemplate({ template: config.prompt || "", args, envs }) }],
bot_id,
workspace_id,
signal,
});
return result.text || "(no answer)";
}