Add workspaces, computers, bot memory and the bots queue

- Schema: workspaces (+ workspace_bots, workspace_computers), containers,
  computers, bot_computers, bots.memory, workspaces.system_prompt, and
  bots_queue as a bun-sqlite isQueue table
- Main computer (and its container record) ensured with the coordinator on
  signup, seed and /admin/bots; the coordinator's access to it is locked
- Effective computer access: direct grants plus workspace computers
- Full bot prompt: core instructions, workspace prompts, then memory;
  bots can rewrite their memory and system prompt
- Queue helpers on the native BunSQLite.queue API, plus a handler that
  heartbeats, serializes per computer, recovers after restarts, reports
  lost jobs, supports cancelling and pushes outcomes over the WebSocket
- Enable SQLite foreign keys at startup so schema cascades fire
- Prune finished jobs daily

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-18 18:33:54 +01:00
co-authored by Claude Opus 5.5
parent 694c83346f
commit d49f524fe8
72 changed files with 2961 additions and 31 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ import ensureCoordinatorBot from "@/src/functions/backend/db/bots/ensure-coordin
/**
* Seeds the sample crew from the approved chat design into one user's
* workspace. The coordinator already exists (it's made with the account),
* crew. The coordinator already exists (it's made with the account),
* so its sample messages go onto it. Idempotent: skips a user who already
* has worker bots.
*
+7
View File
@@ -7,6 +7,7 @@ import type {
import setUserPassword from "@/src/functions/backend/auth/set-user-password";
import validatePassword from "@/src/utils/validate-password";
import ensureCoordinatorBot from "@/src/functions/backend/db/bots/ensure-coordinator-bot";
import ensureMainComputer from "@/src/functions/backend/db/computers/ensure-main-computer";
const FIRST_NAME = process.env.SEED_SUPER_ADMIN_FIRST_NAME || "Super";
const LAST_NAME = process.env.SEED_SUPER_ADMIN_LAST_NAME || "Admin";
@@ -97,6 +98,12 @@ async function seedSuperAdmin() {
const coordinator_id = await ensureCoordinatorBot({ user_id });
console.log(`Coordinator bot is #${coordinator_id}.`);
const main_computer_id = await ensureMainComputer({
user_id,
coordinator_id,
});
console.log(`Main computer is #${main_computer_id}.`);
if (has_super_admin) {
console.log(`User #${user_id} already has the super_admin type.`);
return;