Add computer switching, crew reporting, job steps and markdown chat
- Bots have a current computer (bots.computer_id), switched from the chat header beside the model button or by clicking a computer the bot names ([computer:ID]); tasks run on it by default - search_computers runs one read-only command on all of a bot's computers; chat replies know their computers (compose-computers-note) - The coordinator can use every computer and grants or revokes crew access with assign_computer - Delegated jobs record requested_by_bot_id; the worker's result or failure is reported back in the coordinator's conversation - bots_queue_updates records each model turn of a job, pushed live and shown in the working-on panel - Live relay: every process pushes new messages, job steps and bot changes from the database to its own sockets, so work done elsewhere shows live - Bot messages render as markdown (react-markdown + remark-gfm, no raw HTML) with twui components; rail previews are plain text - Fix header button overflow in the model and computer selects - Bump @moduletrace/twui to 0.1.2 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import BunSQLite from "@moduletrace/bun-sqlite";
|
||||
import type { BotJobUpdateData } from "@/src/types";
|
||||
import { sendToUser } from "@/src/websocket/(functions)/send-to-user";
|
||||
|
||||
type Params = {
|
||||
after_id: number;
|
||||
users: Set<string>;
|
||||
};
|
||||
|
||||
/**
|
||||
* Pushes `server:bot-job-update` for every job step newer than `after_id`
|
||||
* to its owner's sockets on this process. Returns the newest id read.
|
||||
*/
|
||||
export default async function relayNewJobUpdates({ after_id, users }: Params) {
|
||||
const rows =
|
||||
(
|
||||
await BunSQLite.sql<BotJobUpdateData & { user_id: number }>({
|
||||
sql: `SELECT u.*, q.task_id, b.user_id FROM bots_queue_updates u
|
||||
JOIN bots_queue q ON q.id = u.bots_queue_id
|
||||
JOIN bots b ON b.id = u.bot_id
|
||||
WHERE u.id > ? ORDER BY u.id ASC LIMIT 500`,
|
||||
values: [after_id],
|
||||
})
|
||||
).payload || [];
|
||||
|
||||
for (const { user_id, ...update } of rows) {
|
||||
if (users.has(String(user_id))) {
|
||||
sendToUser({ user_id, data: { event: "server:bot-job-update", data: update } });
|
||||
}
|
||||
}
|
||||
|
||||
return Number(rows[rows.length - 1]?.id) || after_id;
|
||||
}
|
||||
Reference in New Issue
Block a user