- 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]>
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
type Params = {
|
|
/**
|
|
* The sandbox's REST address (no `/mcp`).
|
|
*/
|
|
base_url: string;
|
|
command: string;
|
|
timeout_ms: number;
|
|
signal?: AbortSignal;
|
|
};
|
|
|
|
/**
|
|
* Runs one shell command on a computer over the sandbox's REST API
|
|
* (`/v1/shell/exec`), outside any MCP session. Throws when the computer
|
|
* can't be reached or refuses the command.
|
|
*/
|
|
export default async function runComputerCommand({
|
|
base_url,
|
|
command,
|
|
timeout_ms,
|
|
signal,
|
|
}: Params): Promise<{ output: string; exit_code: number | null }> {
|
|
const res = await fetch(`${base_url}/v1/shell/exec`, {
|
|
method: "POST",
|
|
headers: { "content-type": "application/json" },
|
|
body: JSON.stringify({ command }),
|
|
signal: AbortSignal.any([
|
|
...(signal ? [signal] : []),
|
|
AbortSignal.timeout(timeout_ms),
|
|
]),
|
|
});
|
|
const body: any = await res.json().catch(() => ({}));
|
|
|
|
if (!res.ok || body?.success === false) {
|
|
throw new Error(`The computer refused the command: ${body?.message || res.status}`);
|
|
}
|
|
|
|
return {
|
|
output: String(body?.data?.output ?? ""),
|
|
exit_code: typeof body?.data?.exit_code == "number" ? body.data.exit_code : null,
|
|
};
|
|
}
|