Open computers from the chat, let bots ask for a take-over, show task progress

- Serve each computer to its owner under /computers/<id>/ (HTTP and
  websockets proxied to the AIO sandbox) and show it in a shared
  ComputerView with browser, terminal and code modes, opened from the
  computers modal or a take-over button in the thread.
- ask_user_to_take_over lets a bot hand a computer to the user for a
  login or captcha; the message gets a take-over button and needs-you,
  and the viewer hands it back with a chat message.
- While a task runs the thread shows "<bot> is working..." with the
  task's latest step; steps read as plain words, not tool names.
- A coordinator with no workers no longer claims to delegate, and bots
  describe started tasks in the first person.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-19 05:35:44 +01:00
co-authored by Claude Opus 5.5
parent b1023ba8ff
commit 56daf0c462
44 changed files with 1289 additions and 75 deletions
+7
View File
@@ -10,6 +10,7 @@ import type { WebSocketDataType } from "@/src/types";
import { wsSendData } from "./(functions)/ws-send-data";
import checkSessionAccess from "./(functions)/check-session-access";
import logEvent from "@/src/functions/backend/logger";
import { computerProxySocket } from "@/src/functions/server/computers/computer-proxy-socket";
/**
* The twui `useWebSocket` hook sends a raw keepalive string to keep the
@@ -27,6 +28,8 @@ function parseMessage(message: string | Buffer): WebSocketDataType | undefined {
export const websocket = {
open(ws: ServerWebSocket<WebSocketSession>) {
if (ws.data.proxy) return computerProxySocket.open(ws);
const { user } = ws.data;
joinRoom(ws, "public");
@@ -54,6 +57,8 @@ export const websocket = {
ws: ServerWebSocket<WebSocketSession>,
message: string | Buffer,
) {
if (ws.data.proxy) return computerProxySocket.message(ws, message);
const data = parseMessage(message);
if (!data) return;
@@ -73,6 +78,8 @@ export const websocket = {
},
close(ws: ServerWebSocket<WebSocketSession>) {
if (ws.data.proxy) return computerProxySocket.close(ws);
leaveAllRooms(ws);
},
+17 -1
View File
@@ -4,4 +4,20 @@ import type { BUN_SQLITE_COBBLE_USER_TYPES } from "@/db/types/db";
export type WebSocketSession = {
user: User;
user_types: BUN_SQLITE_COBBLE_USER_TYPES[];
};
/**
* Set on a socket bridged to a computer, never on the app's own `/ws`.
*/
proxy?: ComputerProxySession;
};
/**
* A websocket bridged to a computer (`computerProxySocket`): the address
* on the computer and the headers to open it with. `upstream` and
* `pending` are filled once it opens.
*/
export type ComputerProxySession = {
url: string;
headers: Record<string, string>;
protocols: string[];
upstream?: WebSocket;
pending?: (string | Buffer)[];
};