Let the coordinator create bots and put them in workspaces

The coordinator had no tool to add a worker, so a request to create one
fell back to update_workspace and wrote a bot that did not exist into the
workspace context. create_bot now adds a worker with its name, role and
instructions and joins it to a workspace, and add_bot_to_workspace puts an
existing worker in one. Both are coordinator-only and chat-replies-only,
and createBot still enforces the crew-manager check.

The coordinator's prompts now say how a bot gets created, and that one
which does not exist is never written into workspace context.

pick-free-hue moves to utils so the tool can pick a hue without importing
from layouts.
This commit is contained in:
2026-10-19 12:11:04 +01:00
parent e45d54d30b
commit 981a180d19
9 changed files with 190 additions and 9 deletions
+14 -4
View File
@@ -4,7 +4,9 @@ import grabBotComputers from "@/src/functions/backend/db/computers/grab-bot-comp
import type { HarnessTool } from "../../types";
import askToTakeOverTool from "../computer/ask-to-take-over-tool";
import searchComputersTool from "../computer/search-computers-tool";
import addBotToWorkspaceTool from "./add-bot-to-workspace-tool";
import assignComputerTool from "./assign-computer-tool";
import createBotTool from "./create-bot-tool";
import delegateTaskTool from "./delegate-task-tool";
import grabBotTools from "./grab-bot-tools";
import updateWorkspaceTool from "./update-workspace-tool";
@@ -43,10 +45,12 @@ type Params = {
* in a workspace switching its default computer), start_task for longer
* work, search_computers to find what's on its computers,
* ask_user_to_take_over when only the user can do something on one, and
* for the coordinator (the super admin's alone) delegate_task to every
* worker (the workspace's in a workspace) plus, in its own chat, assign_computer (which computers each
* crew member can use) or, in a workspace, set_bot_workspace_instructions.
* Anything else on a computer goes through a task, never mid-reply.
* for the coordinator (the super admin's alone) create_bot to grow the
* crew, delegate_task to every worker (the workspace's in a workspace)
* plus, in its own chat, add_bot_to_workspace and assign_computer (which
* workspace and which computers each crew member gets) or, in a
* workspace, set_bot_workspace_instructions. Anything else on a computer
* goes through a task, never mid-reply.
*/
export default async function grabBotChatTools({
bot,
@@ -83,6 +87,8 @@ export default async function grabBotChatTools({
tools.push(updateWorkspaceTool({ user_id, workspaces, workspace_id }));
}
tools.push(createBotTool({ user_id, workspaces, workspace_id }));
const workers =
(
await BunSQLite.sql<BUN_SQLITE_COBBLE_BOTS>({
@@ -125,5 +131,9 @@ export default async function grabBotChatTools({
tools.push(assignComputerTool({ user_id, workers, computers, access }));
}
if (workspaces.length) {
tools.push(addBotToWorkspaceTool({ user_id, workers, workspaces }));
}
return tools;
}