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]>
22 lines
759 B
TypeScript
22 lines
759 B
TypeScript
type Params = {
|
|
/**
|
|
* The tool's JSON schema.
|
|
*/
|
|
parameters: Record<string, unknown>;
|
|
args: Record<string, unknown>;
|
|
};
|
|
|
|
/**
|
|
* Throws when the model left out an argument the tool's schema requires.
|
|
* The rest of the schema is the model's to follow: custom tools fill
|
|
* templates, so a wrong type does no harm the call wouldn't show.
|
|
*/
|
|
export default function checkRequiredArgs({ parameters, args }: Params) {
|
|
const required = Array.isArray(parameters.required) ? parameters.required.map(String) : [];
|
|
const missing = required.filter((key) => args[key] === undefined || args[key] === null || args[key] === "");
|
|
|
|
if (missing.length) {
|
|
throw new Error(`Missing required arguments: ${missing.join(", ")}.`);
|
|
}
|
|
}
|