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:
@@ -0,0 +1,34 @@
|
||||
import type { BUN_SQLITE_COBBLE_BOTS_QUEUE } from "@/db/types/db";
|
||||
|
||||
export type BotJobContext = {
|
||||
job: BUN_SQLITE_COBBLE_BOTS_QUEUE;
|
||||
params: Record<string, unknown>;
|
||||
/**
|
||||
* Saved by an earlier attempt, if the job was picked up again.
|
||||
*/
|
||||
checkpoint: Record<string, unknown> | null;
|
||||
/**
|
||||
* Aborted when the job is cancelled or lost to another handler. Stop
|
||||
* work and return; the result is discarded.
|
||||
*/
|
||||
signal: AbortSignal;
|
||||
/**
|
||||
* Save progress and a checkpoint. The lock is renewed on a timer
|
||||
* already, so call this for meaningful steps. False once the job is
|
||||
* cancelled or lost.
|
||||
*/
|
||||
update: (params: {
|
||||
progress?: string;
|
||||
checkpoint?: Record<string, unknown>;
|
||||
}) => Promise<boolean>;
|
||||
};
|
||||
|
||||
export type BotJobOutcome = {
|
||||
/**
|
||||
* The completion message for the user (markdown).
|
||||
*/
|
||||
result: string;
|
||||
needs_you?: boolean;
|
||||
};
|
||||
|
||||
export type BotJobRunner = (context: BotJobContext) => Promise<BotJobOutcome>;
|
||||
Reference in New Issue
Block a user