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:
2026-10-19 04:44:35 +01:00
co-authored by Claude Opus 5.5
parent 6a2665dae9
commit 7b580d782e
64 changed files with 1792 additions and 86 deletions
+8 -1
View File
@@ -3,9 +3,11 @@ import { AppData } from "@/src/data/app-data";
import { ChatReplyNote, CoordinatorReplyNote } from "@/src/data/harness-prompts";
import grabBotMessages from "@/src/functions/backend/db/bots/grab-bot-messages";
import grabBotPrompt from "@/src/functions/backend/db/bots/grab-bot-prompt";
import grabBotComputers from "@/src/functions/backend/db/computers/grab-bot-computers";
import runTextLoop from "@/src/harness/text/run-text-loop";
import grabBotChatTools from "@/src/harness/tools/bot/grab-bot-chat-tools";
import botMessagesToHarness from "./bot-messages-to-harness";
import composeComputersNote from "./compose-computers-note";
import loadAttachmentParts from "./load-attachment-parts";
import type { BotJobContext, BotJobOutcome } from "./types";
@@ -16,7 +18,7 @@ type Params = BotJobContext & {
/**
* Answers the user in chat: the bot reads the recent conversation (and
* the files of the latest messages, `loadAttachmentParts`) and
* replies, with its chat tools (memory, instructions, start_task, and for
* replies, knowing its computers (`composeComputersNote`), with its chat tools (memory, instructions, start_task, and for
* the coordinator delegate_task). Finishes silently when the last message
* is already the bot's, i.e. an earlier reply answered everything.
*/
@@ -24,6 +26,7 @@ export default async function runBotReply({
bot,
job,
signal,
report,
}: Params): Promise<BotJobOutcome> {
const history = await grabBotMessages({
bot_id: bot.id,
@@ -35,11 +38,13 @@ export default async function runBotReply({
}
const prompt = await grabBotPrompt({ bot_id: bot.id, user_id: bot.user_id });
const computers = await grabBotComputers({ bot_id: bot.id, user_id: bot.user_id });
const result = await runTextLoop({
system: [
prompt,
ChatReplyNote,
composeComputersNote({ computers, is_coordinator: bot.kind == "coordinator" }),
bot.kind == "coordinator" ? CoordinatorReplyNote : "",
`Now: ${new Date().toUTCString()}.`,
]
@@ -52,11 +57,13 @@ export default async function runBotReply({
tools: await grabBotChatTools({
bot,
user_id: bot.user_id,
computers,
message_id: job.message_id || undefined,
}),
max_steps: AppData.BotReplyMaxToolSteps,
bot_id: bot.id,
signal,
onStep: report,
});
return { result: result.text };