Give the coordinator working crew management tools

- Resolve the crew and workspaces fresh inside each tool run, so a bot or
  workspace created earlier in the same reply is usable: create_bot,
  assign_computer, add_bot_to_workspace, delegate_task and
  set_bot_workspace_instructions.
- Add coordinator-only update_bot, find_bot, find_workspace, delete_bot,
  delete_workspace and remove_bot_from_workspace tools.
- Push server:workspace-removed when a workspace is deleted, and
  workspace_ids on server:bot-updated so a workspace's crew drops a bot
  that was taken out of it.
This commit is contained in:
2026-10-19 20:34:51 +01:00
parent b79cebf397
commit 139b3e443d
20 changed files with 648 additions and 39 deletions
@@ -1,6 +1,7 @@
import { z } from "zod";
import type { BUN_SQLITE_COBBLE_BOTS } from "@/db/types/db";
import { AppData } from "@/src/data/app-data";
import grabCrewWorkers from "@/src/functions/backend/db/bots/grab-crew-workers";
import updateWorkspaceBot from "@/src/functions/backend/db/workspaces/update-workspace-bot";
import type { HarnessTool } from "../../types";
@@ -37,10 +38,15 @@ export default function setWorkspaceInstructionsTool({
instructions: z.string().trim().max(AppData.PromptMaxLength),
}),
run: async ({ args }) => {
const worker = workers.find((bot) => bot.id == args.bot_id);
const fresh = await grabCrewWorkers({ workspace_id });
const worker = fresh.find((bot) => bot.id == args.bot_id);
if (!worker?.id) {
throw new Error(`No crew member here has id ${args.bot_id}. Crew here: ${crew}.`);
throw new Error(
`No crew member here has id ${args.bot_id}. Crew here: ${fresh
.map((bot) => `${bot.id}: ${bot.name}`)
.join("; ") || "none"}.`,
);
}
await updateWorkspaceBot({