Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Burst mode: the bot's tool, /burst, and a burst run end to end

Milind Soni00d2515fb657
diff --git a/server/activity.ts b/server/activity.ts
index 8d07962fd3..42887e3607 100644
--- a/server/activity.ts
+++ b/server/activity.ts
@@ -133,6 +133,7 @@ const TEAM_ACTION_KEYS: Record<string, string> = {
skill_manage: "activity.tool.team.skillManage",
skills_list: "activity.tool.team.skillsList",
start_thread: "activity.tool.team.startThread",
+ burst: "activity.tool.team.burst",
tool_result_read: "activity.tool.team.toolResultRead",
unpublish_page: "activity.tool.team.unpublishPage",
update_html: "activity.tool.team.updateHtml",
diff --git a/server/burst/burst.e2e.test.ts b/server/burst/burst.e2e.test.ts
new file mode 100644
index 0000000000..4746f12cd3
--- /dev/null
+++ b/server/burst/burst.e2e.test.ts
@@ -0,0 +1,56 @@
+// A burst end to end on the scripted engine: proposed by the bot's tool, started only by the person's press, fanned out, and merged in the parent chat.
+import { existsSync, readFileSync, writeFileSync } from "node:fs";
+import { join } from "node:path";
+import { expect, it } from "vitest";
+import { launchVerificationServer, runControlOmb } from "../../scripts/control-omb.ts";
+import { request } from "../../scripts/mcp-server.ts";
+
+const PARTS = ["Acme", "Globex", "Initech"];
+
+it("previews, runs only on Run, and writes one merged result", async () => {
+ const session = await launchVerificationServer(process.env, undefined, undefined, undefined, undefined, { scripted: true });
+ const cli = (...args: string[]) => runControlOmb(args, { env: { OPENMAUSBOT_URL: session.info.url } }) as Promise<any>;
+ const api = (path: string, body?: unknown, method = "POST") =>
+ request(path, body === undefined ? {} : { method, body: JSON.stringify(body) }, session.info.url) as Promise<any>;
+ try {
+ const bot = (await cli("new-bot", "--name", "Researcher")).bot;
+ const planPath = join(session.info.dataDir, "room-plan.json");
+ writeFileSync(planPath, JSON.stringify({
+ [bot.id]: { script: [
+ { key: "MERGE", match: ["The burst you ran"], reply: "MERGED: Acme, Globex and Initech." },
+ ...PARTS.map((name) => ({ key: `PART-${name}`, match: [`This part: ${name}`], reply: `${name} was founded in 1990.` })),
+ { key: "PROPOSE", match: ["BURST-JOB"], steps: [{ tool: "burst", arguments: { task: "Research companies", instructions: "Find when it was founded.", items: PARTS } }], reply: "Press Run to start." },
+ ] },
+ }));
+ const evidence = (): any[] => existsSync(`${planPath}.evidence.jsonl`)
+ ? readFileSync(`${planPath}.evidence.jsonl`, "utf8").trim().split("\n").filter(Boolean).map((line) => JSON.parse(line)) : [];
+ const lines = async () => (await api(`/api/threads/${bot.activeTaskId}/messages?limit=200`, undefined, "GET")).messages as any[];
+ const card = async () => (await lines()).find((message) => message.kind === "burst")?.burst;
+
+ await cli("send", "--bot", bot.id, "--task", bot.activeTaskId, "--text", "BURST-JOB: research these three");
+ await expect.poll(async () => (await card())?.phase, { timeout: 20_000 }).toBe("preview");
+ const preview = await card();
+ expect(preview).toMatchObject({ total: 3, requested: 3, parallel: 3, counts: { queued: 3 } });
+ expect(preview.sample).toEqual(PARTS);
+ expect(evidence().some((turn) => String(turn.planKey).startsWith("PART-"))).toBe(false);
+ const before = (await api("/api/bots", undefined, "GET")).bots.find((one: any) => one.id === bot.id).tasks.length;
+
+ expect(await api(`/api/bursts/${preview.burstId}/run`, {})).toMatchObject({ phase: "running", total: 3 });
+ expect(await api(`/api/bursts/${preview.burstId}/run`, {}).catch((error: Error) => error.message)).toContain("already started");
+ await expect.poll(async () => (await card())?.phase, { timeout: 30_000 }).toBe("done");
+
+ const view = await api(`/api/bursts/${preview.burstId}`, undefined, "GET");
+ expect(view.children.map((row: any) => row.status)).toEqual(["done", "done", "done"]);
+ const bots = (await api("/api/bots", undefined, "GET")).bots.find((one: any) => one.id === bot.id).tasks as any[];
+ expect(bots.length).toBe(before + 3);
+ expect(bots.filter((task) => task.openedBy?.burstId === preview.burstId)).toHaveLength(3);
+ for (const name of PARTS) expect(evidence().some((turn) => turn.planKey === `PART-${name}`)).toBe(true);
+
+ const replies = (await lines()).filter((message) => message.role === "bot" && message.kind === "text").map((message) => message.text);
+ expect(replies).toContain("MERGED: Acme, Globex and Initech.");
+ const inbox = await api("/api/inbox", undefined, "GET");
+ expect(JSON.stringify(inbox)).toContain("MERGED: Acme, Globex and Initech.");
+ } finally {
+ await session.close();
+ }
+}, 120_000);
diff --git a/server/burst/command.test.ts b/server/burst/command.test.ts
new file mode 100644
index 0000000000..14e7e81bbe
--- /dev/null
+++ b/server/burst/command.test.ts
@@ -0,0 +1,26 @@
+import { describe, expect, it } from "vitest";
+
+import { expandBurstTurnText, parseBurstCommand } from "./command.ts";
+
+describe("/burst", () => {
+ it("reads a request", () => {
+ expect(parseBurstCommand("/burst research these 20 companies")).toEqual({ request: "research these 20 companies" });
+ expect(parseBurstCommand(" /BURST\nline one\nline two ")).toEqual({ request: "line one\nline two" });
+ });
+
+ it("leaves other text alone", () => {
+ expect(parseBurstCommand("burst this")).toBeNull();
+ expect(parseBurstCommand("/burstable")).toBeNull();
+ expect(expandBurstTurnText("hello")).toBe("hello");
+ });
+
+ it("tells the bot to propose and not to do the work", () => {
+ const text = expandBurstTurnText("/burst research Acme and Globex");
+ expect(text).toContain("research Acme and Globex");
+ expect(text).toContain("Call the burst tool");
+ });
+
+ it("asks when there is nothing to run", () => {
+ expect(expandBurstTurnText("/burst")).toContain("without a request");
+ });
+});
diff --git a/server/burst/command.ts b/server/burst/command.ts
new file mode 100644
index 0000000000..58b2c38e02
--- /dev/null
+++ b/server/burst/command.ts
@@ -0,0 +1,15 @@
+// `/burst <task>`: like /setup, a rewrite of this turn's text only; the transcript keeps what the person typed.
+const BURST_COMMAND = /^\/burst(?:\s+|$)([\s\S]*)$/i;
+
+export function parseBurstCommand(text: string): { request: string } | null {
+ const match = BURST_COMMAND.exec(text.trim());
+ return match ? { request: match[1]!.trim() } : null;
+}
+
+export function expandBurstTurnText(userText: string): string {
+ const burst = parseBurstCommand(userText);
+ if (!burst) return userText;
+ return burst.request
+ ? `The person used /burst for this request: ${burst.request}\n\nCall the burst tool now with it: their list as items when they gave one, otherwise split it into one item per independent part yourself. Do none of the work here.`
+ : "The person used /burst without a request. Ask them, in one short line, what they want run in parallel.";
+}
diff --git a/server/burst/manager.ts b/server/burst/manager.ts
index 63ba480a5c..411a97e9de 100644
--- a/server/burst/manager.ts
+++ b/server/burst/manager.ts
@@ -30,7 +30,7 @@ export interface BurstTurnOutcome {
/** The server's refusal to start a turn now, for a reason that passes (the thread is busy, the account is settling). */
export const startsLater = (error: unknown): boolean => (error as { status?: number })?.status === 409
- && ["thread_busy", "settling", "thread_limit"].includes((error as { code?: string }).code ?? "");
+ && ["thread_busy", "settling", "thread_limit", "moved"].includes((error as { code?: string }).code ?? "");
export interface BurstManagerDeps {
store: BurstStore;
diff --git a/server/config.ts b/server/config.ts
index 6fceaf3cff..0685c42325 100644
--- a/server/config.ts
+++ b/server/config.ts
@@ -419,7 +419,7 @@ const appConfigSchema = z.object({
/** Local hour (0-23) after which the nightly tidy-up runs. */
tidyHour: z.number().int().min(0).max(23).optional(),
}).strict().optional(),
- threads: threadsConfigSchema.optional(),
+ threads: threadsConfigSchema.optional(), /** Burst mode on an open-source install; a Cloud's plan sets it instead. `maxParallel`: burst threads running at once (default 10). */ burst: z.object({ maxParallel: z.number().int().min(1).max(100).optional() }).strict().optional(),
/** Minimum days of decision-log month files kept; OMB_DECISION_RETENTION_DAYS wins. */
decisions: z.object({ retentionDays: z.number().int().min(1).max(3650).optional() }).strict().optional(),
loopGuard: loopGuardConfigSchema.optional(),
@@ -496,7 +496,7 @@ export interface AppConfig extends HelperConfig {
profile?: { name?: string; email?: string; aboutMe?: string; avatarUrl?: string }; everyBotRules?: string;
rooms?: { turnTimeoutMinutes: number };
mcp?: { callTimeoutMinutes?: number };
- threads?: { maxConcurrentPerBot: number; eventLogMaxBytes?: number; eventLogRetentionDays?: number };
+ threads?: { maxConcurrentPerBot: number; eventLogMaxBytes?: number; eventLogRetentionDays?: number }; burst?: { maxParallel?: number };
context?: { rebuildBytes?: number; compactAt?: number; autoCompact?: boolean; roomCompactAt?: number; roomSessions?: boolean; replayToolHistory?: boolean };
memory?: { captureQuietMs?: number; tidyHour?: number };
localVm?: { mode?: "shared" | "per-bot" | "pool"; maxInstances?: number; idleTimeoutMinutes?: number; preserveInstalledApps?: boolean };
diff --git a/server/drivers/agents-burst-tool.ts b/server/drivers/agents-burst-tool.ts
new file mode 100644
index 0000000000..81919091fa
--- /dev/null
+++ b/server/drivers/agents-burst-tool.ts
@@ -0,0 +1,12 @@
+type BurstApi = (path: string, init: { method: string; body: string }) => Promise<Record<string, unknown>>;
+
+export async function callBurstTool(args: Record<string, unknown>, api: BurstApi): Promise<{ text: string; isError?: boolean }> {
+ const task = String(args.task ?? "").trim();
+ const instructions = String(args.instructions ?? "").trim();
+ const items = Array.isArray(args.items) ? args.items.map((item) => String(item ?? "").trim()).filter(Boolean) : [];
+ if (!task || !instructions || items.length === 0) return { text: "burst needs task, instructions and items, one item per part.", isError: true };
+ const r = await api("/api/internal/bursts", { method: "POST", body: JSON.stringify({ task, instructions, items }) });
+ if (r.error) return { text: `Couldn't propose that burst: ${String(r.error)}`, isError: true };
+ const cut = Number(r.requested) > Number(r.total) ? ` The plan runs ${String(r.total)} of the ${String(r.requested)} you listed.` : "";
+ return { text: `Burst proposed: ${String(r.total)} parts, ${String(r.parallel)} at once, on ${String(r.modelName)}.${cut} A card with Run, Edit and Cancel is in the chat. Nothing runs until the person presses Run: say so in one short line and end your turn; do not do the work here.` };
+}
diff --git a/server/drivers/agents-call.ts b/server/drivers/agents-call.ts
index de223bffa5..01072cb2fb 100644
--- a/server/drivers/agents-call.ts
+++ b/server/drivers/agents-call.ts
@@ -19,6 +19,7 @@ import { callResearchTool, RESEARCH_TOOL_NAMES } from "./agents-research-tools.t
import { callHelperTool, HELPER_TOOL_NAMES } from "./agents-helper-tools.ts";
import { callUsageLimitsTool, USAGE_LIMITS_TOOL } from "./agents-usage-tool.ts";
import { callWaitTool, WAIT_TOOL_NAMES } from "./agents-wait-tools.ts";
+import { callBurstTool } from "./agents-burst-tool.ts";
import { callComputerAskTool, COMPUTER_ASK_TOOL_NAMES } from "./agents-computer-ask-tool.ts";
import { callImageTool, IMAGE_TOOL_NAMES } from "./agents-image-tools.ts";
import { callMeetingTool, MEETING_TOOL_NAMES } from "./agents-meeting-tools.ts";
@@ -503,6 +504,7 @@ export async function callTool(called: string, input: Json, context: ToolCallCon
text: `${opened}${timing}${approval} Its result will be delivered to this conversation automatically (assignment id: ${assignmentId || "unknown"}). Acknowledge it, mention it to the person as #${threadTitle}, and finish your turn; do not check or wait for it in this turn.`,
};
}
+ if (name === "burst") return callBurstTool(args, api);
if (name === "list_models") {
const search = typeof args.search === "string" ? args.search.trim() : "";
const r = await api(`/api/internal/models${search ? `?search=${encodeURIComponent(search)}` : ""}`);
diff --git a/server/drivers/agents-catalog-goldens/full.tools-list.json b/server/drivers/agents-catalog-goldens/full.tools-list.json
index 812b48978c..773c77597b 100644
--- a/server/drivers/agents-catalog-goldens/full.tools-list.json
+++ b/server/drivers/agents-catalog-goldens/full.tools-list.json
@@ -378,6 +378,37 @@
]
}
},
+ {
+ "name": "burst",
+ "description": "Propose running many independent parts of one job in parallel threads of yours, with one merged result back here. Use it when the person says to burst something, or a request is clearly many independent items. Split the job into items yourself unless they gave a list. A card shows the plan; nothing runs until the person presses Run, so end your turn after calling this.",
+ "inputSchema": {
+ "type": "object",
+ "additionalProperties": false,
+ "properties": {
+ "task": {
+ "type": "string",
+ "description": "What this burst is for, one short line."
+ },
+ "instructions": {
+ "type": "string",
+ "description": "Complete instructions every part gets; a part does not see this conversation."
+ },
+ "items": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "minItems": 2,
+ "description": "One entry per part: its slice of the job."
+ }
+ },
+ "required": [
+ "task",
+ "instructions",
+ "items"
+ ]
+ }
+ },
{
"name": "list_models",
"description": "The ids start_thread's model_selection takes, a short list per engine; current is yours. more counts what search finds. unusable says why not; unavailable engines can't run now. Copy ids exactly.",
diff --git a/server/drivers/agents-catalog-goldens/profiles.json b/server/drivers/agents-catalog-goldens/profiles.json
index 6a56b9b9f7..5695c3a2f4 100644
--- a/server/drivers/agents-catalog-goldens/profiles.json
+++ b/server/drivers/agents-catalog-goldens/profiles.json
@@ -1,7 +1,7 @@
{
"default": {
- "bytes": 60593,
- "sha256": "55ced026331f1b75fbbba42600c9265a5c361283d556cdf1e90b6c15b63f7344",
+ "bytes": 61447,
+ "sha256": "ef21a3602ee69cc4ad6ade6538dca59ce6dd127b8eef13858d537c038b2c9d19",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -14,6 +14,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -52,8 +53,8 @@
]
},
"voice": {
- "bytes": 61374,
- "sha256": "90a6960ff21502a97074b7765e5a8ed5ae46bd40e2cdcc5503eb14528b68d47c",
+ "bytes": 62228,
+ "sha256": "191cabdbb234566a139d38e9b1e5bfea126f357cb3f198c1f91c69b207e81c02",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -66,6 +67,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -105,8 +107,8 @@
]
},
"shared": {
- "bytes": 62858,
- "sha256": "d68681e4be4574fc2af5ceff9b1d72589fef027bd14b1fe216410bd2ba5df437",
+ "bytes": 63712,
+ "sha256": "1bcdfce568cc536c2fd2455a9733df7d01ee26e80c69c2520293a30d01197498",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -121,6 +123,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -159,8 +162,8 @@
]
},
"shared+voice": {
- "bytes": 63639,
- "sha256": "7a7e5c55a97f9a3484e7aa452e72f0592f4c19118b78b35546a9d9ccdfd2fc24",
+ "bytes": 64493,
+ "sha256": "0f7ee4706aa7356750901ebfd2940e674f53b2e8ff8b9ef86ffb45e6b788506b",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -175,6 +178,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -214,8 +218,8 @@
]
},
"skills": {
- "bytes": 63669,
- "sha256": "08223f4f821765723e1412911d22c3b6d8c8a3fb77480064d6a2f9297cba971f",
+ "bytes": 64523,
+ "sha256": "aef764f77bc8c9a0b15ba8fbbba787cef9879cad937e2403174f21b038910972",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -228,6 +232,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -268,8 +273,8 @@
]
},
"skills+voice": {
- "bytes": 64450,
- "sha256": "b0bdc6325a9fdcb9fa1c968f4be7f0df41ff125dfc770cf9f7511f1f7eb34391",
+ "bytes": 65304,
+ "sha256": "60db45941779f25f4c1763135a3827b04fee635abf828a0f3696668ef75e49fd",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -282,6 +287,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -323,8 +329,8 @@
]
},
"skills+shared": {
- "bytes": 65934,
- "sha256": "61c4c69356ddb97c25cbd3a4ee4386122c7519b2152d824a9a3b4cd5b7196b25",
+ "bytes": 66788,
+ "sha256": "6f538510f3defacc152b8886e140735df461f85ebefae0ee3a743d997a72ff27",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -339,6 +345,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -379,8 +386,8 @@
]
},
"skills+shared+voice": {
- "bytes": 66715,
- "sha256": "d6f458d442a4e513312fe886a17a5d9c12871141cdc5afc66ff989e16aaa02e8",
+ "bytes": 67569,
+ "sha256": "29736f98419a5d55425bee62615bb45182eeb8dc6aabd351f4068f0266938dd4",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -395,6 +402,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -436,8 +444,8 @@
]
},
"non-chief": {
- "bytes": 51377,
- "sha256": "5f56e88a0db5823f72dd6fb760b83f7a7ee42a5bace969c3475a1f54ee97365a",
+ "bytes": 52231,
+ "sha256": "79fd9272aa238e0e686cf0b7576e29ca3c223d1d2c7327504e414247caca4cb8",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -450,6 +458,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -481,8 +490,8 @@
]
},
"voice+non-chief": {
- "bytes": 52158,
- "sha256": "a7cd287606e0e420bb7b6773de9ee94e397b4b8e5948e57a3052c2bcd82779df",
+ "bytes": 53012,
+ "sha256": "cfc937eeb7c9ae11722dda12838f1277d858f1ed8069d88ed3174498e17f80fe",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -495,6 +504,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -527,8 +537,8 @@
]
},
"shared+non-chief": {
- "bytes": 53642,
- "sha256": "6b8904c38bf76abe4298abb4ae78fe72f1da9f7bb3e0f91019bfec6d195674cf",
+ "bytes": 54496,
+ "sha256": "578efa0933de3c25e19192c4c26a7ddb6128757a9e8cf02b24d82d61af5ea94f",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -543,6 +553,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -574,8 +585,8 @@
]
},
"shared+voice+non-chief": {
- "bytes": 54423,
- "sha256": "ce5c212734e8454b9a71c108120faf87b3d5f1b8d5495142b58c1801db2f54be",
+ "bytes": 55277,
+ "sha256": "25471ce58719094371d82a4f398b64a99e24f0c62743378979c0394a645f5e69",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -590,6 +601,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -622,8 +634,8 @@
]
},
"skills+non-chief": {
- "bytes": 54453,
- "sha256": "c7e062952246a0c2bc4f6760ee557aeb9e108fb55b818c8d041dd61ad37740cb",
+ "bytes": 55307,
+ "sha256": "ea3d6eae71e3b86d37c99153e6dcae422db7e470ffb1ce61c3afc9191e383740",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -636,6 +648,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -669,8 +682,8 @@
]
},
"skills+voice+non-chief": {
- "bytes": 55234,
- "sha256": "60d47c6e43b5c6c001058e2d205cbfd732f2528768e5511aced8f88c514ec174",
+ "bytes": 56088,
+ "sha256": "2eab906ac314849db05875eeefe6a4de2ec40a75a82d2eef87ee1023fbf82cef",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -683,6 +696,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -717,8 +731,8 @@
]
},
"skills+shared+non-chief": {
- "bytes": 56718,
- "sha256": "313d0c5da1c27d6235c390149a724d6b7b34e86ab910c284e6a49b0c6771336e",
+ "bytes": 57572,
+ "sha256": "43a905143784f26591c93ed284d73ad4c67371bc45fbc27b765b680515395af7",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -733,6 +747,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -766,8 +781,8 @@
]
},
"skills+shared+voice+non-chief": {
- "bytes": 57499,
- "sha256": "73c3979e2b9ae64255cda1dbb059bc1d2b9a14b663f37c0adeb0b5fa81b68ba5",
+ "bytes": 58353,
+ "sha256": "fe291bcde74da49087f82e9125f12b762e9113e1ab26273c7d463e7c84ef73d7",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -782,6 +797,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -816,8 +832,8 @@
]
},
"skills+shared+voice+cloud-home": {
- "bytes": 66481,
- "sha256": "20a0f7c84bac83382bbdbd1bbd8dd7df7ad172ff4247c89943df640bfbb53217",
+ "bytes": 67335,
+ "sha256": "3a8fc0861964ebb6d167ab7c5f51975a322c6b772cec1e547e4a289503edb1f9",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -832,6 +848,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"attach_file",
"show_widget",
@@ -873,8 +890,8 @@
]
},
"skills+shared+voice+non-chief+cloud-home": {
- "bytes": 57265,
- "sha256": "76c23c7b2cd5b3e01850f594e5eefe6565028b68c356cb9f035762cfe15a744b",
+ "bytes": 58119,
+ "sha256": "047c01c4451985e8333e9079ce4beadba3614699cb90d9c16ed21f8a88179aa8",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -889,6 +906,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"attach_file",
"show_widget",
@@ -923,8 +941,8 @@
]
},
"skills+shared+voice+escalations": {
- "bytes": 67545,
- "sha256": "873706628daff60d623c17efc4ed8cbc4a93dbd92d3cc944ab7784a038b50f28",
+ "bytes": 68399,
+ "sha256": "115bbdc7170c3b26654d52e5e2836fc8359cd15b00c5efb332902e5c9ac36f89",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -940,6 +958,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -981,8 +1000,8 @@
]
},
"skills+shared+voice+escalations+x": {
- "bytes": 71384,
- "sha256": "150fbf477009989d1eb78061d99c0be07d81c5fb865dfa94ee7bfa05849572b0",
+ "bytes": 72238,
+ "sha256": "dd9c6b8351b4c720b58b971b040e15f31211195628b0c2112e32b69f4baf8a38",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -998,6 +1017,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -1043,8 +1063,8 @@
]
},
"skills+shared+voice+escalations+x+team": {
- "bytes": 71384,
- "sha256": "150fbf477009989d1eb78061d99c0be07d81c5fb865dfa94ee7bfa05849572b0",
+ "bytes": 72238,
+ "sha256": "dd9c6b8351b4c720b58b971b040e15f31211195628b0c2112e32b69f4baf8a38",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1060,6 +1080,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -1105,8 +1126,8 @@
]
},
"skills+shared+voice+escalations+x+team+images": {
- "bytes": 72157,
- "sha256": "49bb2b7ea83243d27f4ae7865ae1de0232e51060b7881361115cb9027fc1bfa4",
+ "bytes": 73011,
+ "sha256": "f0b8813e54df453883b40a108c57106274f76264b7dd3a182fe952dcdf313cdb",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1122,6 +1143,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -1168,8 +1190,8 @@
]
},
"default+legacy-switches": {
- "bytes": 60593,
- "sha256": "55ced026331f1b75fbbba42600c9265a5c361283d556cdf1e90b6c15b63f7344",
+ "bytes": 61447,
+ "sha256": "ef21a3602ee69cc4ad6ade6538dca59ce6dd127b8eef13858d537c038b2c9d19",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1182,6 +1204,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -1220,8 +1243,8 @@
]
},
"default+mausbot": {
- "bytes": 61244,
- "sha256": "a0a415783fb518c1d700b3e18c06a8669e875890eec442d7d24261f175ede714",
+ "bytes": 62098,
+ "sha256": "c3e4eb3f70be2e94d280ffb4777638c374180e0821a65714f65dced0a4449a62",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1234,6 +1257,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -1274,8 +1298,8 @@
]
},
"skills+shared+voice+mausbot": {
- "bytes": 67366,
- "sha256": "975adc0f77ca1ca1678b5986a10132e2d34b46e998ad1fd9be6d5cf6cd1f38a6",
+ "bytes": 68220,
+ "sha256": "9947f399d88f609f4e68e03268d141e58b5d7a4acd79e9992d93ff435daf160a",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1290,6 +1314,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -1333,8 +1358,8 @@
]
},
"default+no-computer-pick": {
- "bytes": 59381,
- "sha256": "f5760141459eaf5a8b1464b829825411fb0e2d915ae3bb4a6e69e56dc06cd129",
+ "bytes": 60235,
+ "sha256": "631b0778fdece533d20dcd7d6bed02551db69feed8642a4ce02c22c4448b6f28",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1346,6 +1371,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
@@ -1473,8 +1499,8 @@
]
},
"default+images": {
- "bytes": 61366,
- "sha256": "b0dcf42f3de84a34921166cfad05bce2d5321c3875908ab82b15986629954594",
+ "bytes": 62220,
+ "sha256": "6f4980d3f562c098ad448132bb9ec448943ba63ce292efa29bb7a11b141c1aa9",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1487,6 +1513,7 @@
"list_threads",
"close_thread",
"start_thread",
+ "burst",
"list_models",
"vm_exec",
"attach_file",
diff --git a/server/drivers/agents-catalog-wire.test.ts b/server/drivers/agents-catalog-wire.test.ts
index f608a9439a..230b782c1d 100644
--- a/server/drivers/agents-catalog-wire.test.ts
+++ b/server/drivers/agents-catalog-wire.test.ts
@@ -335,7 +335,7 @@ describe("agents proxy tools/list golden", () => {
const names = (name: string) => toolsOf(wires[name]!).map((tool) => tool.name);
expect(names("default+no-computer-pick")).toEqual(names("default").filter((tool) => tool !== "select_computer"));
for (const name of ["default", "non-chief"]) {
- expect(names(`${name}+room`), name).toEqual(names(name).filter((tool) => !["select_computer", "wait_until", "list_waits", "cancel_wait"].includes(tool)));
+ expect(names(`${name}+room`), name).toEqual(names(name).filter((tool) => !["select_computer", "wait_until", "list_waits", "cancel_wait", "burst"].includes(tool)));
}
for (const [name, profile] of Object.entries(PROFILES)) {
expect(names(name).includes("select_computer"), name).toBe(profile.env.OMB_COMPUTER_SELECTION === "1");
diff --git a/server/drivers/agents-catalog.ts b/server/drivers/agents-catalog.ts
index 005ea520c3..5eed5db835 100644
--- a/server/drivers/agents-catalog.ts
+++ b/server/drivers/agents-catalog.ts
@@ -316,6 +316,20 @@ const TOOL_DEFINITIONS = [
required: ["title", "message"],
},
},
+ {
+ name: "burst",
+ description: "Propose running many independent parts of one job in parallel threads of yours, with one merged result back here. Use it when the person says to burst something, or a request is clearly many independent items. Split the job into items yourself unless they gave a list. A card shows the plan; nothing runs until the person presses Run, so end your turn after calling this.",
+ inputSchema: {
+ type: "object",
+ additionalProperties: false,
+ properties: {
+ task: { type: "string", description: "What this burst is for, one short line." },
+ instructions: { type: "string", description: "Complete instructions every part gets; a part does not see this conversation." },
+ items: { type: "array", items: { type: "string" }, minItems: 2, description: "One entry per part: its slice of the job." },
+ },
+ required: ["task", "instructions", "items"],
+ },
+ },
{
name: "list_models",
description: "The ids start_thread's model_selection takes, a short list per engine; current is yours. more counts what search finds. unusable says why not; unavailable engines can't run now. Copy ids exactly.",
@@ -903,7 +917,7 @@ const WATCHER_TOOL_NAMES = new Set(["create_options_card"]);
const LOCAL_VM_TOOL_NAMES = new Set(["vm_exec"]);
/** Refused in a room's thread (routes/waits.ts), and list_waits, since a room holds no wait. */
-const ROOM_REFUSED_TOOL_NAMES = WAIT_TOOL_NAMES;
+const ROOM_REFUSED_TOOL_NAMES = new Set([...WAIT_TOOL_NAMES, "burst"]);
const CLOUD_HOME_SURFACE = {
type: "string", enum: ["auto", "cloud", "browser"],
description: "auto = suitable configured computer, cloud = the bot's cloud computer, browser = built-in browser. Omit to list. This server runs in the cloud: the user's own computer and a Local VM are not places here.",
diff --git a/server/host/burst-host.test.ts b/server/host/burst-host.test.ts
new file mode 100644
index 0000000000..6bcf36a107
--- /dev/null
+++ b/server/host/burst-host.test.ts
@@ -0,0 +1,100 @@
+import { afterEach, describe, expect, it } from "vitest";
+
+import type { BurstCardData } from "../../shared/burst.ts";
+import type { Notification } from "../../shared/notification.ts";
+import type { ModelSelection } from "../../shared/wire.ts";
+import type { ModelCatalog } from "../contracts.ts";
+import { burstDefaultModel, burstProposalRefusal, createBurstHost, BURST_OUTSIDE_REFUSAL, BURST_ROOM_REFUSAL, type BurstHost, type BurstHostDeps } from "./burst-host.ts";
+
+const hosts: BurstHost[] = [];
+afterEach(() => { for (const host of hosts.splice(0)) host.close(); });
+
+function host(over: Partial<BurstHostDeps> = {}) {
+ const messages = new Map<string, Record<string, unknown>>();
+ const routed: Notification[] = [];
+ const announced: Notification[] = [];
+ const bot = { id: "bot", name: "Researcher", color: "blue", notifications: true, modelSelection: { instanceId: "i", model: "big" } };
+ const made = createBurstHost({
+ dataDir: ":memory:", cloudHome: true, tier: () => "starter", maxParallel: () => undefined, hasRoom: () => true,
+ store: {
+ bot: () => bot, taskByThread: () => undefined,
+ createTask: () => ({ threadId: `t-${messages.size}` }) as never,
+ appendMessage: (_threadId: string, message: Record<string, unknown>) => { const id = `m-${messages.size}`; messages.set(id, message); return { id, ...message }; },
+ patchMessage: (_threadId: string, id: string, patch: Record<string, unknown>) => { messages.set(id, { ...messages.get(id), ...patch }); return null; },
+ } as unknown as BurstHostDeps["store"],
+ language: () => "en", startTurn: async () => undefined, stop: () => {}, threadBusy: () => false, opened: () => {}, origin: () => ({ kind: "user", request: "x" }),
+ approval: () => undefined, defaultModel: () => ({ instanceId: "i", model: "fast" }), modelName: (selection) => selection.model,
+ route: (notification) => { routed.push(notification); return notification; }, announce: (notification) => { announced.push(notification); }, log: () => {},
+ ...over,
+ });
+ hosts.push(made);
+ return { made, messages, routed, announced };
+}
+
+const propose = (made: BurstHost, items: readonly string[]) => made.propose({ botId: "bot", threadId: "parent", task: "Research", instructions: "Do it.", items, model: { instanceId: "i", model: "fast" }, modelName: "fast" });
+
+describe("burst host", () => {
+ it("cuts the list to the Starter limit on the server and draws one card", () => {
+ const { made, messages } = host();
+ const card = propose(made, Array.from({ length: 20 }, (_, i) => `Item ${i}`)) as BurstCardData;
+ expect(card).toMatchObject({ total: 10, requested: 20, parallel: 2, taskLimit: 10, smallPlan: true });
+ expect([...messages.values()]).toHaveLength(1);
+ expect(messages.get("m-0")).toMatchObject({ kind: "burst", role: "bot", burst: { total: 10 }, text: "Burst ready: 10 tasks. Press Run on its card to start." });
+ made.cancel(card.burstId);
+ expect([...messages.values()]).toHaveLength(1);
+ expect(messages.get("m-0")).toMatchObject({ burst: { phase: "cancelled" }, text: "Burst cancelled." });
+ });
+
+ it("gives an open-source install its own number with no plan check", () => {
+ const { made } = host({ cloudHome: false, tier: () => undefined, maxParallel: () => 7 });
+ expect(propose(made, ["a", "b"])).toMatchObject({ parallel: 2, total: 2 });
+ const big = propose(made, Array.from({ length: 30 }, (_, i) => `Item ${i}`)) as BurstCardData;
+ expect(big).toMatchObject({ parallel: 7, total: 30, requested: 30 });
+ expect(big.smallPlan).toBeUndefined();
+ });
+
+ it("puts the whole result in the Inbox line and a short one in the notification", async () => {
+ const parts: Array<(text: string) => void> = [];
+ let finishMerge = (_ok: string) => {};
+ const { made, routed, announced } = host({
+ startTurn: async (_bot, _text, opts) => {
+ if (opts.cardContinuation) finishMerge = (text) => opts.onSettled({ ok: true, text });
+ else parts.push((text) => opts.onSettled({ ok: true, text }));
+ },
+ });
+ const card = propose(made, ["a", "b"]) as BurstCardData;
+ made.run(card.burstId);
+ parts[0]!("part one");
+ parts[1]!("part two");
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ const merged = "x".repeat(3_000);
+ finishMerge(merged);
+ expect(routed[0]!.body).toHaveLength(2_000);
+ expect(announced[0]!.body.length).toBeLessThanOrEqual(140);
+ });
+});
+
+describe("burstDefaultModel", () => {
+ const catalog: ModelCatalog = { default: "big", options: [{ id: "big", label: "Big" }, { id: "small-mini", label: "Small" }] };
+ const own: ModelSelection = { instanceId: "i", model: "big" };
+
+ it("takes the engine's fast model when there is one this bot may use", () => {
+ expect(burstDefaultModel({ own, catalog: () => catalog, refused: () => new Set(), usable: () => true })).toEqual({ instanceId: "i", model: "small-mini" });
+ });
+
+ it("stays on the bot's own model otherwise", () => {
+ expect(burstDefaultModel({ own, catalog: () => catalog, refused: () => new Set(["small-mini"]), usable: () => true })).toEqual(own);
+ expect(burstDefaultModel({ own, catalog: () => catalog, refused: () => new Set(), usable: () => false })).toEqual(own);
+ expect(burstDefaultModel({ own, catalog: () => undefined, refused: () => new Set(), usable: () => true })).toEqual(own);
+ });
+});
+
+describe("who may open a burst", () => {
+ it("is a person's own request in a bot's own chat", () => {
+ expect(burstProposalRefusal({ owner: { group: undefined }, outside: false, self: undefined })).toBeNull();
+ expect(burstProposalRefusal({ owner: null, outside: false, self: undefined })).toContain("does not belong");
+ expect(burstProposalRefusal({ owner: { group: { id: "room" } }, outside: false, self: undefined })).toBe(BURST_ROOM_REFUSAL);
+ expect(burstProposalRefusal({ owner: { group: undefined }, outside: true, self: undefined })).toBe(BURST_OUTSIDE_REFUSAL);
+ expect(burstProposalRefusal({ owner: { group: undefined }, outside: false, self: "Only a person's own request" })).toBe("Only a person's own request");
+ });
+});
diff --git a/server/host/burst-host.ts b/server/host/burst-host.ts
new file mode 100644
index 0000000000..7423880731
--- /dev/null
+++ b/server/host/burst-host.ts
@@ -0,0 +1,160 @@
+// Burst mode's host: the lane's threads are ordinary threads of the bot, started through the same turn start any turn uses,
+// so a burst thread gets the memory gate, the budget check and every other guard of a normal turn. The seam for a thread's
+// own computer is `openThread`: each part is one thread with one model today, and the same place can ask for a computer.
+import { fastModelFor } from "../turn-route.ts";
+import { buildNotification, summarize, type NotifyBot } from "../notify.ts";
+import type { BurstCardData, BurstPhase } from "../../shared/burst.ts";
+import type { Notification } from "../../shared/notification.ts";
+import { redactSecretsInText } from "../../shared/redact.ts";
+import type { ModelSelection } from "../../shared/wire.ts";
+import type { ModelCatalog } from "../contracts.ts";
+import { burstLimits, type BurstLimits } from "../burst/limits.ts";
+import { createBurstManager, type BurstManager, type BurstTurnOutcome } from "../burst/manager.ts";
+import { openBurstStore, type BurstRecord, type BurstStore } from "../burst/store.ts";
+import type { HostTurnResult } from "../coordinator.ts";
+import type { WorkOrigin } from "../peer-provenance.ts";
+import { serverLine, type ServerLineKey } from "../server-lines.ts";
+import type { BotRecord, Message, Store } from "../store.ts";
+
+const INBOX_TEXT_MAX = 2_000;
+const CARD_LINE: Record<BurstPhase, ServerLineKey> = {
+ preview: "server.burst.preview",
+ running: "server.burst.running",
+ merging: "server.burst.merging",
+ done: "server.burst.done",
+ cancelled: "server.burst.cancelled",
+};
+
+/** A turn start, as `startTurn` takes it for a part or a merge. */
+export interface BurstTurnOptions {
+ threadId: string;
+ peerAsk?: { botId: string; name: string };
+ cardContinuation?: true;
+ requestMessageId?: string;
+ origin?: WorkOrigin;
+ allowRoomTurnElsewhere: true;
+ onSettled: (outcome: HostTurnResult) => void;
+ onDispatchError: (message: string) => void;
+}
+
+export interface BurstHostDeps {
+ dataDir: string;
+ cloudHome: boolean;
+ tier(): string | undefined;
+ maxParallel(): number | undefined;
+ hasRoom(): boolean;
+ store: Pick<Store, "bot" | "taskByThread" | "createTask" | "appendMessage" | "patchMessage">;
+ language(threadId: string): string | undefined;
+ startTurn(botId: string, text: string, opts: BurstTurnOptions): Promise<unknown>;
+ stop(botId: string, threadId: string, cause: string): void;
+ threadBusy(botId: string, threadId: string): boolean;
+ /** Records who opened a part's thread: the same person as the parent chat. */
+ opened(threadId: string, parentThreadId: string): void;
+ /** Whom this request came from, in the record's words, for what a turn may reach. */
+ origin(burst: BurstRecord): WorkOrigin;
+ approval(bot: BotRecord, selection: ModelSelection): "ask" | undefined;
+ /** The model a burst defaults to: the bot's own engine's fast model, or the model of the chat that asked. */
+ defaultModel(bot: BotRecord, threadId: string): ModelSelection;
+ modelName(selection: ModelSelection): string;
+ route(notification: Notification): Notification | null;
+ announce(notification: Notification): void;
+ log?: (line: string) => void;
+}
+
+const outcomeOf = (result: HostTurnResult): BurstTurnOutcome => ({ ok: result.ok && !result.stalled, text: result.text, asked: Boolean(result.cards?.ids.length) });
+
+export function createBurstHost(deps: BurstHostDeps): BurstManager & { model(bot: BotRecord, threadId: string): { selection: ModelSelection; name: string } } {
+ const { store } = deps;
+ const burstStore: BurstStore = openBurstStore(deps.dataDir);
+ const limits = (): BurstLimits => burstLimits({ cloudHome: deps.cloudHome, tier: deps.tier(), maxParallel: deps.maxParallel() });
+
+ function cardLine(burst: BurstRecord, card: BurstCardData): string {
+ const language = deps.language(burst.threadId);
+ return serverLine(language, CARD_LINE[card.phase], { count: card.total, done: card.counts.done, total: card.total, failed: card.counts.failed });
+ }
+
+ const manager = createBurstManager({
+ store: burstStore,
+ limits,
+ hasRoom: deps.hasRoom,
+ openThread(burst, child) {
+ const bot = store.bot(burst.botId);
+ if (!bot) return null;
+ const task = store.createTask(bot.id, child.title, false, undefined,
+ { botId: bot.id, name: bot.name, threadId: burst.threadId, burstId: burst.id, at: Date.now() }, deps.approval(bot, burst.model), burst.model);
+ if (!task) return null;
+ deps.opened(task.threadId, burst.threadId);
+ return task.threadId;
+ },
+ startChild(burst, child, text, done) {
+ const bot = store.bot(burst.botId);
+ if (!bot) return Promise.reject(new Error("The bot is no longer here."));
+ return deps.startTurn(bot.id, text, { threadId: child.threadId, peerAsk: { botId: bot.id, name: bot.name }, origin: deps.origin(burst), allowRoomTurnElsewhere: true,
+ onSettled: (result) => { done(outcomeOf(result)); }, onDispatchError: (message) => { done({ ok: false, text: message }); } }).then(() => undefined);
+ },
+ stopChild(burst, child) {
+ if (child.threadId) deps.stop(burst.botId, child.threadId, "The person cancelled this burst.");
+ },
+ async startMerge(burst, text, done) {
+ if (!store.bot(burst.botId) || deps.threadBusy(burst.botId, burst.threadId)) return false;
+ await deps.startTurn(burst.botId, text(), { threadId: burst.threadId, cardContinuation: true, ...(burst.cardMessageId ? { requestMessageId: burst.cardMessageId } : {}), origin: deps.origin(burst), allowRoomTurnElsewhere: true,
+ onSettled: (result) => { done(outcomeOf(result)); }, onDispatchError: (message) => { done({ ok: false, text: message }); } });
+ return true;
+ },
+ draw(burst, card) {
+ const bot = store.bot(burst.botId);
+ const line = cardLine(burst, card);
+ if (!burst.cardMessageId) return store.appendMessage(burst.threadId, { role: "bot", kind: "burst", text: line, burst: card, ...(bot ? { from: { botId: bot.id, name: bot.name, color: bot.color } } : {}) } as Omit<Message, "id" | "at">).id;
+ store.patchMessage(burst.threadId, burst.cardMessageId, { text: line, burst: card });
+ return burst.cardMessageId;
+ },
+ postParts(burst, parts) {
+ const language = deps.language(burst.threadId);
+ const body = parts.map((child) => child.status === "done"
+ ? `**${child.title}**\n\n${child.result ?? ""}`
+ : `**${child.title}**: ${serverLine(language, "server.burst.partFailed", { reason: child.error ?? "" })}`).join("\n\n");
+ const text = `${serverLine(language, "server.burst.partsHeader", { task: burst.task })}\n\n${body}`;
+ store.appendMessage(burst.threadId, { role: "bot", kind: "text", text: redactSecretsInText(text) });
+ return text;
+ },
+ deliver(burst, text) {
+ const bot = store.bot(burst.botId);
+ if (!bot) return;
+ const notifiable: NotifyBot = { id: bot.id, name: bot.name, threadId: burst.threadId, notifications: bot.notifications };
+ const short = buildNotification("done", notifiable, burst.threadId, text, { avatarUrl: bot.avatarUrl });
+ if (!short) return;
+ const clean = redactSecretsInText(text);
+ const routed = deps.route({ ...short, body: clean.length > INBOX_TEXT_MAX ? `${clean.slice(0, INBOX_TEXT_MAX - 1).trimEnd()}…` : clean });
+ if (routed) deps.announce({ ...routed, body: summarize(clean) });
+ },
+ ...(deps.log ? { log: deps.log } : {}),
+ });
+
+ return Object.assign(manager, {
+ model(bot: BotRecord, threadId: string) {
+ const selection = deps.defaultModel(bot, threadId);
+ return { selection, name: deps.modelName(selection) };
+ },
+ });
+}
+
+export type BurstHost = ReturnType<typeof createBurstHost>;
+
+/** The bot's own engine's fast model when it has one this bot may use; otherwise the chat's own model. */
+export function burstDefaultModel(input: { own: ModelSelection; catalog(instanceId: string): ModelCatalog | undefined; refused(instanceId: string): ReadonlySet<string>; usable(selection: ModelSelection): boolean }): ModelSelection {
+ const fast = fastModelFor(input.catalog(input.own.instanceId), input.own.model, input.refused(input.own.instanceId));
+ if (!fast || fast === input.own.model) return input.own;
+ const selection = { instanceId: input.own.instanceId, model: fast };
+ return input.usable(selection) ? selection : input.own;
+}
+
+export const BURST_ROOM_REFUSAL = "A burst runs from a bot's own chat, not a room. Ask the person to start it there.";
+export const BURST_OUTSIDE_REFUSAL = "This work came in from outside, so it can't open a burst. Finish it here.";
+
+/** Who may open a burst: a person's own request in the bot's own chat, the same rule as opening a thread on yourself. */
+export function burstProposalRefusal(input: { owner: { group?: unknown } | null | undefined; outside: boolean; self: string | undefined }): string | null {
+ if (!input.owner) return "source conversation does not belong to sender";
+ if (input.owner.group) return BURST_ROOM_REFUSAL;
+ if (input.outside) return BURST_OUTSIDE_REFUSAL;
+ return input.self ?? null;
+}
diff --git a/server/host/own-threads.ts b/server/host/own-threads.ts
index 3ce77d4adf..6939d639d1 100644
--- a/server/host/own-threads.ts
+++ b/server/host/own-threads.ts
@@ -43,6 +43,10 @@ export function createOwnThreads(deps: {
const requester = asked?.parentId === undefined ? undefined : deps.node(asked.parentId);
return Boolean(asked && requester && requester.botId === botId && own(requester, asked));
},
+ /** "ask" when running on `selection` crosses to an engine where this bot's permission level does not carry over. */
+ approvalFor(bot: BotRecord, selection: ModelSelection): "ask" | undefined {
+ return modelSwitchNeedsAsk(approvalModeFor(bot), deps.registry.cliTarget(bot.modelSelection.instanceId)?.driverKind, deps.registry.cliTarget(selection.instanceId)?.driverKind) ? "ask" : undefined;
+ },
inherited(botId: string, parentThreadId: string): { modelSelection?: ModelSelection; approvalMode?: "ask" } {
const bot = store.bot(botId);
const modelSelection = bot && store.taskByThread(bot.id, parentThreadId)?.modelSelection;
diff --git a/server/host/starter-caps.ts b/server/host/starter-caps.ts
index 4a73fad5ae..d6a04329c6 100644
--- a/server/host/starter-caps.ts
+++ b/server/host/starter-caps.ts
@@ -25,6 +25,8 @@ export function createStarterCaps(deps: {
awake: StarterAwake;
/** Whether this thread's running turn waits on hand-offs it made. */
waitsOnOthers(threadId: string): boolean;
+ /** Whether a burst's lane runs this thread: it has a limit of its own. */
+ laneOwned?(threadId: string): boolean;
botName(botId: string): string | undefined;
/** The paused bot's line in this language. */
pausedLine(language: string | undefined, limit: number): string;
@@ -40,7 +42,7 @@ export function createStarterCaps(deps: {
return words;
};
return {
- engine: { most: () => (deps.starter() ? STARTER_RUNNING_TURNS : undefined), waitsOnOthers: deps.waitsOnOthers },
+ engine: { most: () => (deps.starter() ? STARTER_RUNNING_TURNS : undefined), waitsOnOthers: deps.waitsOnOthers, ...(deps.laneOwned ? { laneOwned: deps.laneOwned } : {}) },
handoffs: {
refusal(botId, open) {
if (!deps.starter()) return null;
diff --git a/server/index.ts b/server/index.ts
index 2aee79bbd3..5c52107d82 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -602,7 +602,7 @@ import { createInternalThreadRoutes } from "./routes/internal-threads.ts";
import { createBrowserEvidenceRoutes } from "./routes/browser-evidence.ts";
import { createSignInCardRoutes } from "./routes/sign-in-cards.ts";
import { createInternalEscalateRoutes } from "./routes/internal-escalate.ts";
-import { createInternalChiefTeamRoutes } from "./routes/internal-chief-team.ts"; import { createInternalModelRoutes } from "./routes/internal-models.ts"; import { createOwnThreads } from "./host/own-threads.ts";
+import { createInternalChiefTeamRoutes } from "./routes/internal-chief-team.ts"; import { createInternalModelRoutes } from "./routes/internal-models.ts"; import { createOwnThreads } from "./host/own-threads.ts"; import { burstDefaultModel, burstProposalRefusal, createBurstHost } from "./host/burst-host.ts"; import { expandBurstTurnText } from "./burst/command.ts"; import { createBurstProposalRoutes, createBurstRoutes } from "./routes/burst.ts"; import { quoteInNote } from "./peer-provenance.ts";
import { createRoomHoldRoutes } from "./routes/room-holds.ts";
import { checkedGroupResponder, createGroupRoutes } from "./routes/groups.ts";
import { createChannelRoutes } from "./routes/channels.ts";
@@ -2218,7 +2218,7 @@ function parksBehindCoordination(botId: string, threadId: string): boolean {
function botAtThreadCapacity(botId: string, personThreadId?: string, startedByABot = false): boolean {
// The person's main chat is never at capacity. threadBusy, not the stored flag: a reservation holds its slot after an early completion clears the flag.
- return (!personThreadId || personThreadId !== botMainThread(botId)) && store.tasks(botId).filter((task) => threadBusy(botId, task.threadId) && (startedByABot || !cloudPlanTier.starter() || directRequestOwners.get(task.threadId)?.kind !== "handoff")).length >= (startedByABot ? maxConcurrentChildThreads : maxConcurrentBotThreads)(cfg, botThreadsHost(cloudPlanTier.starter()));
+ return !(personThreadId && burst.laneOwned(personThreadId)) && (!personThreadId || personThreadId !== botMainThread(botId)) && store.tasks(botId).filter((task) => threadBusy(botId, task.threadId) && !burst.laneOwned(task.threadId) && (startedByABot || !cloudPlanTier.starter() || directRequestOwners.get(task.threadId)?.kind !== "handoff")).length >= (startedByABot ? maxConcurrentChildThreads : maxConcurrentBotThreads)(cfg, botThreadsHost(cloudPlanTier.starter()));
}
function hasDirectDispatch(botId: string): boolean {
@@ -2839,7 +2839,7 @@ const phones = createPhones({
mint: (botId, turn) => mintInternalCapability({ botId, ...turn, kind: "device", depth: 0, skillAuthoring: false, createdBots: 0, openedThreads: 0 }),
active: (turn) => internalCapabilityIsActive(turn as InternalCapability),
});
-const cloudPlanTier = createCloudPlanTier({ dataDir: DATA_DIR, cloudHome: Boolean(CLOUD_HOME), changed: () => broadcast({ kind: "config", ...configStatus() }) }); const botLimit = createBotLimit({ starter: () => cloudPlanTier.starter(), bots: () => store.bots }); const starterAwake = createStarterAwake({ dataDir: DATA_DIR, starter: () => cloudPlanTier.starter(), bots: () => store.bots, changed: () => broadcast({ kind: "config", ...configStatus() }) }); const starterCaps = createStarterCaps({ starter: () => cloudPlanTier.starter(), awake: starterAwake, waitsOnOthers: (threadId) => coordinator.outstandingFor(threadId).length > 0, botName: (botId) => store.bot(botId)?.name, pausedLine: (language, limit) => serverLine(language, "server.botPaused", { limit }), refused: () => broadcast({ kind: "config", ...configStatus() }) }); engineMemory.useCap(starterCaps.engine); let cloudPower: CloudPower | null = null; // The sleep handshake of a plan that sleeps (server/cloud-power.ts), made just before the server listens.
+const cloudPlanTier = createCloudPlanTier({ dataDir: DATA_DIR, cloudHome: Boolean(CLOUD_HOME), changed: () => broadcast({ kind: "config", ...configStatus() }) }); const botLimit = createBotLimit({ starter: () => cloudPlanTier.starter(), bots: () => store.bots }); const starterAwake = createStarterAwake({ dataDir: DATA_DIR, starter: () => cloudPlanTier.starter(), bots: () => store.bots, changed: () => broadcast({ kind: "config", ...configStatus() }) }); const starterCaps = createStarterCaps({ starter: () => cloudPlanTier.starter(), awake: starterAwake, waitsOnOthers: (threadId) => coordinator.outstandingFor(threadId).length > 0, laneOwned: (threadId) => burst.laneOwned(threadId), botName: (botId) => store.bot(botId)?.name, pausedLine: (language, limit) => serverLine(language, "server.botPaused", { limit }), refused: () => broadcast({ kind: "config", ...configStatus() }) }); engineMemory.useCap(starterCaps.engine); let cloudPower: CloudPower | null = null; // The sleep handshake of a plan that sleeps (server/cloud-power.ts), made just before the server listens.
const { cloudHealth, cloudSigned } = createCloudSignedHost({ cloudHome: CLOUD_HOME, sessions, power: () => cloudPower, box: () => botBox.report(), teamAdmin: teamAdminHost(), policyChanged: nudgeCloudTeamPolicy, plan: (cancelled) => routineHolds?.plan(cancelled), planTier: (tier) => cloudPlanTier.set(tier), memberLeft: (email) => leaveTeam ? leaveTeam(email).then((result) => { botApi.manager.revokeMintedBy(personKey({ id: "", email })); teamOwners.left(email); teamMessages.inbox.forget(personKey({ id: "", email })); forgetSetupPresser(store, personKey({ id: "", email })); devsReports.forget(personKey({ id: "", email })); return result; }) : Promise.reject(new Error("not a team")), health: { store, bus, dataDir: DATA_DIR, eventsDir: EVENTS_DIR, version: serverVersion(), image: process.env.OMB_CLOUD_IMAGE,
engines: () => registry.instances().map((instance) => ({ instanceId: instance.instanceId, driverKind: instance.driverKind, snapshot: registry.knownSnapshot(instance.instanceId) })),
connectors: () => emailHost.health(composio.configured(cfg) ? composio.connectedServices(cfg) : null),
@@ -7853,7 +7853,7 @@ async function beginTurn(
const skillCommandText = supportsWorkspaceFiles(instance.driverKind)
? skillsHost.expandSkillCommand(bot, threadId, providerText, instance, personLine ? activeMessages.filter((line) => skipTranscript.has(line.id)) : [], (personLine && !userMessage.relayed && !startedOutside(threadId)) || ["schedule", "manual", "startup"].includes(opts?.automationSource ?? ""))
: providerText;
- const setupText = agentsMounted ? expandSetupTurnText(skillCommandText) : skillCommandText;
+ const setupText = agentsMounted ? expandBurstTurnText(expandSetupTurnText(skillCommandText)) : skillCommandText;
const userTurnText = (opts?.app?.context ?? "") + (opts?.cardContinuation ? "" : routineRunNote(threadId, opts?.automationSource)) + labelledLine(personLine && !opts?.excludeMessageIds ? userMessage : {}, withReactionNotes(promptWithReply(
skillAuthoring ? expandLearnTurnText(setupText) : setupText,
opts?.replyTo,
@@ -9210,7 +9210,7 @@ const validateModelProposal = (selection: ModelSelection, current?: BotRecord):
}
return null;
};
-const ownThreads = createOwnThreads({ store, registry, node: (id) => coordinator.node(id), current: turnSelection, proposalRefusal: validateModelProposal, givesWay: modelGivesWay, modelName });
+const ownThreads = createOwnThreads({ store, registry, node: (id) => coordinator.node(id), current: turnSelection, proposalRefusal: validateModelProposal, givesWay: modelGivesWay, modelName }); const burst = createBurstHost({ dataDir: DATA_DIR, cloudHome: Boolean(CLOUD_HOME), tier: () => cloudPlanTier.tier(), maxParallel: () => cfg.burst?.maxParallel, hasRoom: () => engineMemory.laneHasRoom(), store, language: (threadId) => threadLanguage(threadId), startTurn: (botId, text, opts) => startTurn(botId, text, opts), stop: (botId, threadId, cause) => { void interruptDirectThread(botId, threadId, cause).catch(() => {}); }, threadBusy, opened: (threadId, parent) => threadStarters.set(threadId, openerFrom(parent)), origin: (run) => withPerson({ kind: "user", request: quoteInNote(run.task, 400) }, threadPersonKey(run.threadId)), approval: (bot, selection) => ownThreads.approvalFor(bot, selection), defaultModel: (bot, threadId) => burstDefaultModel({ own: store.taskByThread(bot.id, threadId)?.modelSelection ?? bot.modelSelection, catalog: (id) => registry.get(id)?.models, refused: (id) => quickFallback.refused(id), usable: (selection) => ownThreads.refusal(selection, bot) === null }), modelName, route: (notification) => teamMessages.route(notification, { routine: true }), announce: (notification) => { broadcast({ kind: "notify", notification: logNotification(notification) }); } });
const teamMemory = new TeamMemory(join(DATA_DIR, "team-memory.json"));
const teamMemoryRequests = createTeamMemoryRequests({ teamMemory, store, sectionKey: sectionContextKey, decide: (row) => appendDecision(DATA_DIR, row) });
const outsideWrites = createOutsideWrites({ store, notify, language: (threadId) => threadLanguage(threadId), decide: (row) => appendDecision(DATA_DIR, row),
@@ -11543,7 +11543,7 @@ function claimPhoneSecretBotDeletion(botId: string): (() => void) | null {
}
const secretCards = createSecretCards({ store, cfg, botLogins, vaultStore: logins, phoneSecrets, phoneSecretSubmissions, connectorThread, answerCardNode, followCard: (threadId, from, to) => coordinator.followCard(threadId, from, to), threadLanguage, email: { connect: (request, reading) => emailService.connect(request, reading), refusal: () => emailService.status().reason, connected: (address) => { const one = emailService.store.get(address); return Boolean(one && !one.problem); }, sendingProblem: (address) => emailService.sendingProblem(address), account: (address) => emailService.status().accounts.find((one) => one.address.toLowerCase() === address.toLowerCase()), checkOutgoing: (address, fields) => emailService.checkOutgoing(address, fields), profileAddress: () => cfg.profile?.email?.trim() || undefined }, dataDir: DATA_DIR, providerKeysRefused: Boolean(hostedModels), layerFolder: (botId, threadId) => workspaceDir(teamHost.layer(botId, threadId)), turnVm: (threadId) => localVmThreadTargets.get(threadId)?.key });
-ROUTES.push(createSecretCardRoutes({ cards: secretCards, phoneSecretSubmissions, threadVisible: (auth, threadId) => visibleTo(viewerFor(auth)).thread(threadId), answerContext: (auth, botId, threadId) => ({ personalCloud: Boolean(CLOUD_PERSONAL), shared: sharedMembership(), owner: (CLOUD_TEAM ? teamOwners.routing.askedPerson(botId, threadId) : null) ?? threadStarters.get(threadId) ?? null, person: auth.kind === "session" ? personKey(auth.session) : null }) }));
+ROUTES.push(createBurstRoutes({ owner: (id) => burst.owner(id), sees: (auth, threadId) => visibleTo(viewerFor(auth)).thread(threadId), refusal: (auth, threadId, id) => cardAnswerRefusal(auth, threadId, id, "allow"), view: (id) => burst.view(id), run: (id) => burst.run(id), cancel: (id) => burst.cancel(id), retry: (id) => burst.retryFailed(id), edit: (id, plan) => burst.edit(id, plan) })); ROUTES.push(createSecretCardRoutes({ cards: secretCards, phoneSecretSubmissions, threadVisible: (auth, threadId) => visibleTo(viewerFor(auth)).thread(threadId), answerContext: (auth, botId, threadId) => ({ personalCloud: Boolean(CLOUD_PERSONAL), shared: sharedMembership(), owner: (CLOUD_TEAM ? teamOwners.routing.askedPerson(botId, threadId) : null) ?? threadStarters.get(threadId) ?? null, person: auth.kind === "session" ? personKey(auth.session) : null }) }));
// By design OpenMausBot never receives a website password: the person signs in where the bot works, and the bot uses that session.
@@ -13519,7 +13519,7 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {
});
return json(res, 201, proposed);
}
- if (await dispatchRoutes([createInternalChiefTeamRoutes({ bot: () => store.bot(internalCapability.botId), requireActive: requireActiveInternalCapability,
+ if (await dispatchRoutes([createBurstProposalRoutes({ requireActive: requireActiveInternalCapability, readBody: readInternalBody, refusal: () => burstProposalRefusal({ owner: connectorThread(internalSender.id, internalCapability.threadId), outside: outsideWorkStaysHere(internalCapability.threadId), self: selfThreadRefusal({ handoff: Boolean(internalCapability.roomHandoffId), requestLine: store.activePath(internalCapability.threadId).findLast((line) => line.role === "user" && line.kind === "text") }) }), model: () => burst.model(internalSender, internalCapability.threadId), propose: (plan) => burst.propose({ ...plan, botId: internalSender.id, threadId: internalCapability.threadId }) }), createInternalChiefTeamRoutes({ bot: () => store.bot(internalCapability.botId), requireActive: requireActiveInternalCapability,
teams: teamSetupTeams, bots: () => store.bots, instances: () => registry.describe() }), createInternalModelRoutes({ requireActive: requireActiveInternalCapability, menu: (search) => ownThreads.menu(internalCapability.botId, internalCapability.threadId, search) })], { req, res, url, path, method, auth, json, readBody })) return;
if (method === "POST" && path === "/api/internal/team-setup-requests") {
const parsed = z.object({ fromBotId: z.string().optional(), fromThreadId: z.string().optional(), plan: z.unknown() }).strict().safeParse(await readInternalBody());
@@ -15513,7 +15513,7 @@ server.listen(PORT, listenHost(server), async () => {
}
// Only once every registry is initialized and the endpoint listens: earlier dispatch can hit uninitialized bindings.
moveFreeze.hold(() => { routines!.start(); botWaits.start(); proactive.start(); }, () => { routines!.stop(); botWaits.stop(); proactive.stop(); });
- limitClock.start();
+ limitClock.start(); burst.recover();
moveFreeze.hold(() => memoryUpkeep.start(), () => memoryUpkeep.stop());
});
diff --git a/server/request-auth.ts b/server/request-auth.ts
index b4e677282d..53098a460a 100644
--- a/server/request-auth.ts
+++ b/server/request-auth.ts
@@ -362,6 +362,8 @@ export const CLIENT_ALLOW: ReadonlyArray<{ methods: readonly string[]; path: Reg
{ methods: ["POST"], path: /^\/api\/bots\/[\w-]+\/respond$/ },
{ methods: ["POST"], path: /^\/api\/threads\/[\w-]+\/respond$/ },
{ methods: ["POST"], path: /^\/api\/threads\/[\w-]+\/undo$/ }, // whoever may answer the card: see the handler
+ { methods: ["GET"], path: /^\/api\/bursts\/[\w-]+$/ }, // whoever sees the chat: see the handler
+ { methods: ["POST"], path: /^\/api\/bursts\/[\w-]+\/(?:run|cancel|retry|edit)$/ }, // whoever may answer the card: see the handler
{ methods: ["PATCH"], path: /^\/api\/bots\/[\w-]+\/cards\/[\w-]+$/ },
{ methods: ["POST"], path: /^\/api\/bots\/[\w-]+\/secret-cards\/[\w-]+\/(?:resume|dismiss)$/ },
// A secret only the conversation's own person may type in: kept behind the card, never in Settings (routes/secret-cards.ts).
diff --git a/server/routes/burst.test.ts b/server/routes/burst.test.ts
new file mode 100644
index 0000000000..8b59ab276d
--- /dev/null
+++ b/server/routes/burst.test.ts
@@ -0,0 +1,94 @@
+import { describe, expect, it } from "vitest";
+
+import type { RequestAuth } from "../request-auth.ts";
+import { createBurstProposalRoutes, createBurstRoutes, type BurstProposalDeps, type BurstRoutesDeps } from "./burst.ts";
+import { PASS, type RouteContext } from "./table.ts";
+
+const auth = { kind: "loopback", scopes: ["admin", "client"] } as RequestAuth;
+
+function ctx(path: string, method: string, body?: unknown) {
+ const sent: { status?: number; body?: unknown } = {};
+ const context = { req: {} as RouteContext["req"], res: {} as RouteContext["res"], url: new URL(`http://x${path}`), path, method, auth,
+ json: ((_res: unknown, status: number, value: unknown) => { sent.status = status; sent.body = value; }) as unknown as RouteContext["json"],
+ readBody: (async () => body) as unknown as RouteContext["readBody"] } as RouteContext;
+ return { context, sent };
+}
+
+function deps(over: Partial<BurstRoutesDeps> = {}): BurstRoutesDeps {
+ const card = { burstId: "b1" } as never;
+ return { owner: () => ({ botId: "bot", threadId: "t" }), sees: () => true, refusal: () => null, view: () => ({ burstId: "b1" }), run: () => card, cancel: () => card, retry: () => card, edit: () => card, ...over };
+}
+
+describe("burst card routes", () => {
+ it("passes other paths", async () => {
+ const { context } = ctx("/api/bots", "GET");
+ expect(await createBurstRoutes(deps())(context)).toBe(PASS);
+ });
+
+ it("answers 404 to someone who can't see the chat", async () => {
+ const { context, sent } = ctx("/api/bursts/b1/run", "POST");
+ await createBurstRoutes(deps({ sees: () => false, run: () => { throw new Error("must not run"); } }))(context);
+ expect(sent.status).toBe(404);
+ });
+
+ it("refuses a press from someone who may not answer this chat's cards", async () => {
+ const { context, sent } = ctx("/api/bursts/b1/run", "POST");
+ await createBurstRoutes(deps({ refusal: () => "Only the owner of this Cloud can answer this card.", run: () => { throw new Error("must not run"); } }))(context);
+ expect(sent).toEqual({ status: 403, body: { error: "Only the owner of this Cloud can answer this card." } });
+ });
+
+ it("runs, cancels and retries on a press", async () => {
+ const pressed: string[] = [];
+ const routes = createBurstRoutes(deps({ run: () => { pressed.push("run"); return {} as never; }, cancel: () => { pressed.push("cancel"); return {} as never; }, retry: () => { pressed.push("retry"); return {} as never; } }));
+ for (const action of ["run", "cancel", "retry"]) await routes(ctx(`/api/bursts/b1/${action}`, "POST").context);
+ expect(pressed).toEqual(["run", "cancel", "retry"]);
+ });
+
+ it("sends a refusal back as a conflict", async () => {
+ const { context, sent } = ctx("/api/bursts/b1/run", "POST");
+ await createBurstRoutes(deps({ run: () => ({ refused: "This burst has already started." }) }))(context);
+ expect(sent).toEqual({ status: 409, body: { error: "This burst has already started." } });
+ });
+
+ it("validates an edit", async () => {
+ const edits: unknown[] = [];
+ const routes = createBurstRoutes(deps({ edit: (_id, plan) => { edits.push(plan); return {} as never; } }));
+ const good = ctx("/api/bursts/b1/edit", "POST", { items: ["a", "b"], instructions: "x" });
+ await routes(good.context);
+ expect(edits).toEqual([{ items: ["a", "b"], instructions: "x" }]);
+ const bad = ctx("/api/bursts/b1/edit", "POST", { items: [""] });
+ await routes(bad.context);
+ expect(bad.sent.status).toBe(400);
+ });
+
+ it("reads the rows for the card", async () => {
+ const { context, sent } = ctx("/api/bursts/b1", "GET");
+ await createBurstRoutes(deps())(context);
+ expect(sent.body).toEqual({ burstId: "b1" });
+ });
+});
+
+describe("the burst tool's route", () => {
+ const base: BurstProposalDeps = {
+ requireActive: () => {}, refusal: () => null, readBody: async () => ({ task: "t", instructions: "i", items: ["a", "b"] }),
+ model: () => ({ selection: { instanceId: "i", model: "m" }, name: "m" }), propose: () => ({ burstId: "b1" }) as never,
+ };
+
+ it("shows a preview and nothing else: it can't start a burst", async () => {
+ const { context, sent } = ctx("/api/internal/bursts", "POST");
+ await createBurstProposalRoutes(base)(context);
+ expect(sent).toEqual({ status: 201, body: { burstId: "b1" } });
+ });
+
+ it("refuses a room or a hand-off", async () => {
+ const { context, sent } = ctx("/api/internal/bursts", "POST");
+ await createBurstProposalRoutes({ ...base, refusal: () => "A burst runs from a bot's own chat, not a room." })(context);
+ expect(sent.status).toBe(403);
+ });
+
+ it("refuses a malformed proposal", async () => {
+ const { context, sent } = ctx("/api/internal/bursts", "POST");
+ await createBurstProposalRoutes({ ...base, readBody: async () => ({ task: "t" }) })(context);
+ expect(sent.status).toBe(400);
+ });
+});
diff --git a/server/routes/burst.ts b/server/routes/burst.ts
new file mode 100644
index 0000000000..90d65b8b1e
--- /dev/null
+++ b/server/routes/burst.ts
@@ -0,0 +1,83 @@
+import { z } from "zod";
+
+import type { BurstCardData } from "../../shared/burst.ts";
+import type { ModelSelection } from "../../shared/wire.ts";
+import { INSTRUCTIONS_MAX, ITEM_MAX, type BurstRefusal } from "../burst/manager.ts";
+import type { RequestAuth } from "../request-auth.ts";
+import { PASS, type RouteHandler } from "./table.ts";
+
+const LIST_MAX = 1_000;
+const itemsSchema = z.array(z.string().min(1).max(ITEM_MAX)).max(LIST_MAX);
+const editSchema = z.object({ instructions: z.string().max(INSTRUCTIONS_MAX).optional(), items: itemsSchema.optional() }).strict();
+
+export interface BurstRoutesDeps {
+ owner(id: string): { botId: string; threadId: string } | null;
+ /** Whether this person may see the chat this burst belongs to. */
+ sees(auth: RequestAuth, threadId: string): boolean;
+ /** Why this person may not press the card's buttons; the same rule as answering any card in that chat. */
+ refusal(auth: RequestAuth, threadId: string, burstId: string): string | null;
+ view(id: string): unknown;
+ run(id: string): BurstCardData | BurstRefusal;
+ cancel(id: string): BurstCardData | BurstRefusal;
+ retry(id: string): BurstCardData | BurstRefusal;
+ edit(id: string, plan: { instructions?: string; items?: readonly string[] }): BurstCardData | BurstRefusal;
+}
+
+/** A burst's card reads its rows here and acts here. Run is reachable only from a person's press: no bot tool can call it. */
+export function createBurstRoutes(deps: BurstRoutesDeps): RouteHandler {
+ return async ({ req, res, path, method, auth, json, readBody }) => {
+ const match = /^\/api\/bursts\/([\w-]+)(?:\/(run|cancel|retry|edit))?$/.exec(path);
+ if (!match) return PASS;
+ const [, id, action] = match;
+ const owner = deps.owner(id!);
+ if (!owner || !deps.sees(auth, owner.threadId)) return json(res, 404, { error: "That burst is gone." });
+ if (!action) {
+ if (method !== "GET") return json(res, 405, { error: "method not allowed" });
+ return json(res, 200, deps.view(id!));
+ }
+ if (method !== "POST") return json(res, 405, { error: "method not allowed" });
+ const refused = deps.refusal(auth, owner.threadId, id!);
+ if (refused) return json(res, 403, { error: refused });
+ let result: BurstCardData | BurstRefusal;
+ if (action === "edit") {
+ const parsed = editSchema.safeParse(await readBody(req));
+ if (!parsed.success) return json(res, 400, { error: "That edit doesn't fit." });
+ result = deps.edit(id!, parsed.data);
+ } else {
+ result = deps[action as "run" | "cancel" | "retry"](id!);
+ }
+ return "refused" in result ? json(res, 409, { error: result.refused }) : json(res, 200, result);
+ };
+}
+
+const proposalSchema = z.object({
+ task: z.string().min(1).max(4_000),
+ instructions: z.string().max(INSTRUCTIONS_MAX),
+ items: itemsSchema.min(1),
+}).strict();
+
+export interface BurstProposalDeps {
+ requireActive(): void;
+ /** Why this turn may not open a burst (a room, a hand-off, work that came in from outside); null when it may. */
+ refusal(): string | null;
+ /** The model the parts run on, and its name. */
+ model(): { selection: ModelSelection; name: string };
+ propose(input: { task: string; instructions: string; items: readonly string[]; model: ModelSelection; modelName: string }): BurstCardData | BurstRefusal;
+ readBody(): Promise<unknown>;
+}
+
+/** The burst tool: a preview card and nothing more. */
+export function createBurstProposalRoutes(deps: BurstProposalDeps): RouteHandler {
+ return async ({ res, path, method, json }) => {
+ if (path !== "/api/internal/bursts") return PASS;
+ if (method !== "POST") return json(res, 405, { error: "method not allowed" });
+ deps.requireActive();
+ const refused = deps.refusal();
+ if (refused) return json(res, 403, { error: refused });
+ const parsed = proposalSchema.safeParse(await deps.readBody());
+ if (!parsed.success) return json(res, 400, { error: "A burst needs a task, instructions and a list of items." });
+ const model = deps.model();
+ const card = deps.propose({ ...parsed.data, model: model.selection, modelName: model.name });
+ return "refused" in card ? json(res, 400, { error: card.refused }) : json(res, 201, card);
+ };
+}
diff --git a/server/system-prompt.ts b/server/system-prompt.ts
index 41b5b509c4..0940e56a9d 100644
--- a/server/system-prompt.ts
+++ b/server/system-prompt.ts
@@ -259,7 +259,7 @@ export function longCommandsPrompt(computer: ComputerPromptKind | null): string
return LONG_COMMANDS_TEXT + (computer === "vm-private" || computer === "vm-shared" ? VM_LONG_COMMANDS_TEXT : "");
}
export const THREADS_PROMPT =
- " A thread is one conversation with its own history and its own run; a bot can have several running at once, and the person sees them as rows under that bot. Use start_thread to open one on yourself for separate work; to hand a teammate a job in a fresh thread of its own, use coordinate_bots with thread \"new\". Use list_threads to see how the ones you opened are going. When you mention a thread to the person, write its title as #Title so it links. Do not use a ticket comment, a note, or a room post as a stand-in for a thread.";
+ " A thread is one conversation with its own history and its own run; a bot can have several running at once, and the person sees them as rows under that bot. Use start_thread to open one on yourself for separate work; to hand a teammate a job in a fresh thread of its own, use coordinate_bots with thread \"new\". Use list_threads to see how the ones you opened are going. When you mention a thread to the person, write its title as #Title so it links. When the person says to burst something, or a request is clearly many independent items worked in parallel, use the burst tool: it shows a card, nothing runs until they press Run, and the results come back here as one merged reply. Do not use a ticket comment, a note, or a room post as a stand-in for a thread.";
export const WIDGET_PROMPT =
" Ask only what you cannot find or sensibly default yourself, and one thing at a time. When the answer is a pick from a few options (a time, a day, one of a few choices), offer them with show_widget as tap-to-answer choices instead of asking the person to type: a Card with a Row of Buttons, one per option, whose onClickAction sends that option in one tap, at most six; the caption can say they may also just type an answer. When the person wants to change something that already exists, such as a routine, a reminder, a booking or a setting, show it as a form prefilled with its current values (each field's defaultValue), say in the caption that this is how it is set now, and give it a confirm button that saves the change, so they edit what is there instead of describing it again. Use a form with several fields only for that, or when several required details truly cannot be defaulted. A plain yes or no, such as whether to go ahead, needs no widget: ask it in one short sentence; the person answers in a word or with 👍 or 👎 on your message, and either comes back to you as their reply. Put data and comparisons in a markdown table in your message, not in a widget.";
const APPLIED_RESULT_PROMPT =
diff --git a/shared/skill-command.ts b/shared/skill-command.ts
index d96862a04f..5b85952e68 100644
--- a/shared/skill-command.ts
+++ b/shared/skill-command.ts
@@ -9,7 +9,7 @@ import { isSkillName } from "./skill-md.ts";
/** Commands the app already owns. A skill with one of these names keeps
* working through the prompt index, but `/name` stays the built-in. */
-export const BUILT_IN_SLASH_COMMANDS: readonly string[] = ["goal", "learn", "setup"];
+export const BUILT_IN_SLASH_COMMANDS: readonly string[] = ["goal", "learn", "setup", "burst"];
export interface SkillCommand {
name: string;
diff --git a/src/locales/de.json b/src/locales/de.json
index e067bd6265..3f24038a07 100644
--- a/src/locales/de.json
+++ b/src/locales/de.json
@@ -249,6 +249,13 @@
"server.teammates.teammateWork": "Arbeit für ein Teammitglied",
"server.teammates.goalCoordinating": "{bot} koordiniert dieses Ziel.",
"server.teammates.goal.working": "Ziel in Arbeit: {detail}",
+ "server.burst.preview": "Burst bereit: {count} Aufgaben. Tippe auf der Karte auf Starten, um loszulegen.",
+ "server.burst.running": "Burst läuft: {done} von {total} fertig, {failed} fehlgeschlagen.",
+ "server.burst.merging": "Burst fertig: Ein Ergebnis wird geschrieben.",
+ "server.burst.done": "Burst fertig: {done} von {total} erledigt, {failed} fehlgeschlagen.",
+ "server.burst.cancelled": "Burst abgebrochen.",
+ "server.burst.partFailed": "nicht fertig geworden ({reason})",
+ "server.burst.partsHeader": "Die Teile dieses Bursts, wie sie kamen: {task}",
"server.teammates.goal.completed": "Ziel erreicht: {detail}",
"server.teammates.goal.needsInput": "Ziel braucht deine Eingabe: {detail}",
"server.teammates.goal.blocked": "Ziel blockiert: {detail}",
diff --git a/src/locales/en.json b/src/locales/en.json
index 1354da1a07..ab028b5e07 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -376,6 +376,13 @@
"server.teammates.teammateWork": "Teammate work",
"server.teammates.goalCoordinating": "{bot} is coordinating this goal.",
"server.teammates.goal.working": "Goal in progress: {detail}",
+ "server.burst.preview": "Burst ready: {count} tasks. Press Run on its card to start.",
+ "server.burst.running": "Burst running: {done} of {total} done, {failed} failed.",
+ "server.burst.merging": "Burst finished: writing one result.",
+ "server.burst.done": "Burst finished: {done} of {total} done, {failed} failed.",
+ "server.burst.cancelled": "Burst cancelled.",
+ "server.burst.partFailed": "did not finish ({reason})",
+ "server.burst.partsHeader": "The parts of this burst, as they came: {task}",
"server.teammates.goal.completed": "Goal completed: {detail}",
"server.teammates.goal.needsInput": "Goal needs your input: {detail}",
"server.teammates.goal.blocked": "Goal blocked: {detail}",
@@ -8880,6 +8887,7 @@
"activity.tool.team.skillManage": "Skill manage",
"activity.tool.team.skillsList": "Skills list",
"activity.tool.team.startThread": "Start thread",
+ "activity.tool.team.burst": "Burst",
"activity.tool.team.toolResultRead": "Tool result read",
"activity.tool.team.unpublishPage": "Unpublish page",
"activity.tool.team.updateHtml": "Update html",
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index 3cc07ce43b..b87fd69dcc 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -359,6 +359,13 @@
"server.teammates.teammateWork": "Trabalho do colega",
"server.teammates.goalCoordinating": "{bot} está coordenando este objetivo.",
"server.teammates.goal.working": "Objetivo em andamento: {detail}",
+ "server.burst.preview": "Burst pronto: {count} tarefas. Toque em Executar no cartão para começar.",
+ "server.burst.running": "Burst em andamento: {done} de {total} concluídas, {failed} com falha.",
+ "server.burst.merging": "Burst terminado: escrevendo um único resultado.",
+ "server.burst.done": "Burst terminado: {done} de {total} concluídas, {failed} com falha.",
+ "server.burst.cancelled": "Burst cancelado.",
+ "server.burst.partFailed": "não terminou ({reason})",
+ "server.burst.partsHeader": "As partes deste burst, como vieram: {task}",
"server.teammates.goal.completed": "Objetivo concluído: {detail}",
"server.teammates.goal.needsInput": "O objetivo precisa da sua resposta: {detail}",
"server.teammates.goal.blocked": "Objetivo bloqueado: {detail}",
@@ -8856,6 +8863,7 @@
"activity.tool.team.skillManage": "Gerenciar habilidade",
"activity.tool.team.skillsList": "Listar habilidades",
"activity.tool.team.startThread": "Iniciar conversa",
+ "activity.tool.team.burst": "Burst",
"activity.tool.team.toolResultRead": "Ler resultado de ferramenta",
"activity.tool.team.unpublishPage": "Despublicar página",
"activity.tool.team.updateHtml": "Atualizar HTML",