Skip to content

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

A bot page that fills its window keeps a page's height in the chat

milind-soni44045b9b5a2c
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 9d8b67adda..ef97941a80 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -548,7 +548,7 @@ jobs:
env:
OMB_UI_E2E: "1"
OMB_UI_EVIDENCE_DIR: .omb-scratch/verify-evidence
- run: pnpm exec vitest run scripts/testing/control-omb-ui.e2e.test.ts scripts/testing/bot-tools-ui.e2e.test.ts scripts/testing/thinking-timer-ui.e2e.test.ts scripts/testing/team-share-ui.e2e.test.ts scripts/testing/org-library-ui.e2e.test.ts scripts/testing/presets-ui.e2e.test.ts scripts/testing/browser-evidence.e2e.test.ts scripts/testing/browser-fill.e2e.test.ts scripts/testing/rich-table-composer-ui.e2e.test.ts scripts/testing/computer-panel-focus-ui.e2e.test.ts scripts/testing/mobile-code-blocks-ui.e2e.test.ts
+ run: pnpm exec vitest run scripts/testing/control-omb-ui.e2e.test.ts scripts/testing/bot-tools-ui.e2e.test.ts scripts/testing/thinking-timer-ui.e2e.test.ts scripts/testing/team-share-ui.e2e.test.ts scripts/testing/org-library-ui.e2e.test.ts scripts/testing/presets-ui.e2e.test.ts scripts/testing/browser-evidence.e2e.test.ts scripts/testing/browser-fill.e2e.test.ts scripts/testing/rich-table-composer-ui.e2e.test.ts scripts/testing/computer-panel-focus-ui.e2e.test.ts scripts/testing/mobile-code-blocks-ui.e2e.test.ts scripts/testing/inline-page-height-ui.e2e.test.ts
- name: Upload the renderer screenshot
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
@@ -559,6 +559,7 @@ jobs:
.omb-scratch/verify-evidence/thinking-timer-anchored.png
.omb-scratch/verify-evidence/share-team-dialog.png
.omb-scratch/verify-evidence/mobile-code-blocks/
+ .omb-scratch/verify-evidence/inline-page-height/
if-no-files-found: warn
retention-days: 7
diff --git a/scripts/testing/inline-page-height-ui.e2e.test.ts b/scripts/testing/inline-page-height-ui.e2e.test.ts
new file mode 100644
index 0000000000..2d91712895
--- /dev/null
+++ b/scripts/testing/inline-page-height-ui.e2e.test.ts
@@ -0,0 +1,136 @@
+// Bot pages in the real <App/> through `control-omb ui`: a page drawn to its window keeps a page's height in the chat,
+// and a page that flows keeps sizing to its content. Needs the pinned agent-browser binary: runs when one resolves or
+// OMB_UI_E2E=1 asks for the verified download; otherwise skipped.
+import { spawn } from "node:child_process";
+import { mkdirSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join, resolve } from "node:path";
+import { fileURLToPath } from "node:url";
+import { afterAll, expect, it } from "vitest";
+
+import { resolveAgentBrowserBinary } from "../../server/browser-engine.ts";
+import { removeTempDir, waitForExit } from "../../server/testing/cleanup.ts";
+import { runControlOmb } from "../control-omb.ts";
+import { UI_TOOLS_DIR, agentBrowser, sessionEnv, type UiHandle } from "./control-omb-ui.ts";
+
+const ROOT = fileURLToPath(new URL("../..", import.meta.url));
+const forced = process.env.OMB_UI_E2E === "1";
+const enabled = forced || Boolean(resolveAgentBrowserBinary({ dataDir: UI_TOOLS_DIR, env: process.env }));
+if (!enabled) console.log("skipping inline page height UI e2e: set OMB_UI_E2E=1 to install the pinned browser");
+const LAUNCH_TIMEOUT_MS = forced ? 600_000 : 180_000;
+const evidenceDir = process.env.OMB_UI_EVIDENCE_DIR
+ ? join(resolve(ROOT, process.env.OMB_UI_EVIDENCE_DIR), "inline-page-height")
+ : mkdtempSync(join(tmpdir(), "omb-page-height-"));
+const ownsEvidenceDir = !process.env.OMB_UI_EVIDENCE_DIR;
+
+const SIZE_LABEL = "c.fillStyle='#1d3557';c.font='bold 13px sans-serif';c.fillText('frame '+w+' x '+h,w-150,22);";
+
+const MAP_LAYER = `<!DOCTYPE html><html><head><meta charset="utf-8"><style>
+html,body{height:100%;margin:0;overflow:hidden;font-family:var(--font-sans)}
+#map{position:absolute;inset:0}
+#map canvas{position:absolute;inset:0;width:100%;height:100%}
+.card{position:absolute;left:16px;bottom:16px;width:230px;padding:12px 14px;border-radius:12px;background:#fff;color:#1d1d1f;box-shadow:0 6px 20px rgba(0,0,0,.2);font-size:13px;line-height:18px}
+</style></head><body>
+<div id="map"><canvas></canvas></div>
+<div class="card"><strong>Harbour ferries</strong><br>Three routes. Next boat 14:20.</div>
+<script>
+var canvas=document.querySelector("canvas");
+var draw=function(){var w=innerWidth,h=innerHeight;canvas.width=w;canvas.height=h;var c=canvas.getContext("2d");
+c.fillStyle="#cfe3ee";c.fillRect(0,0,w,h);c.fillStyle="#a8cf9a";
+c.beginPath();c.ellipse(w*0.2,h*0.3,w*0.18,h*0.22,0,0,7);c.fill();c.beginPath();c.ellipse(w*0.78,h*0.68,w*0.2,h*0.25,0,0,7);c.fill();
+c.strokeStyle="rgba(29,53,87,.18)";for(var x=0;x<w;x+=40){c.beginPath();c.moveTo(x,0);c.lineTo(x,h);c.stroke()}
+for(var y=0;y<h;y+=40){c.beginPath();c.moveTo(0,y);c.lineTo(w,y);c.stroke()}
+c.strokeStyle="#e63946";c.lineWidth=3;c.setLineDash([8,6]);c.beginPath();c.moveTo(w*0.25,h*0.35);c.lineTo(w*0.5,h*0.5);c.lineTo(w*0.75,h*0.62);c.stroke();
+${SIZE_LABEL}};
+addEventListener("resize",draw);draw();
+</script></body></html>`;
+
+const MAP_PERCENT = `<!DOCTYPE html><html><head><meta charset="utf-8"><style>
+html,body,#map{height:100%;margin:0}
+#map{position:relative;overflow:hidden;background:repeating-linear-gradient(45deg,#e9f1e4 0 24px,#dfeadb 24px 48px)}
+.pin{position:absolute;left:45%;top:40%;width:18px;height:18px;border-radius:50% 50% 50% 0;background:#e63946;transform:rotate(-45deg)}
+.label{position:absolute;left:12px;top:12px;font:bold 13px sans-serif;color:#1d3557}
+</style></head><body><div id="map"><div class="pin"></div><div class="label">html, body, #map { height: 100% }</div></div></body></html>`;
+
+const FLOWING = `<!DOCTYPE html><html><head><meta charset="utf-8"><style>
+body{margin:0;padding:16px;font-family:var(--font-sans);color:var(--color-text-primary)}
+h2{margin:0;height:40px;font-size:18px;line-height:24px}
+.row{height:56px;box-sizing:border-box;border-top:1px solid var(--color-border-primary);display:flex;align-items:center}
+</style></head><body><h2>This week</h2>
+<div class="row">Monday: design review</div><div class="row">Tuesday: ship the beta</div>
+<div class="row">Wednesday: customer calls</div><div class="row">Thursday: retro</div></body></html>`;
+const FLOWING_HEIGHT = 16 + 40 + 4 * 56 + 16;
+
+const PAGES = [
+ { key: "map-layer", input: { title: "Ferry map", html: MAP_LAYER } },
+ { key: "map-layer-400", input: { title: "Ferry map at 400", html: MAP_LAYER, height: 400 } },
+ { key: "map-percent", input: { title: "Percent map", html: MAP_PERCENT } },
+ { key: "flowing", input: { title: "This week", html: FLOWING } },
+] as const;
+
+const ui = (verb: string, handle: string, ...args: string[]) =>
+ runControlOmb(["ui", verb, "--ui", handle, ...args]) as Promise<Record<string, any>>;
+
+let child: ReturnType<typeof spawn> | undefined;
+afterAll(async () => {
+ if (child && child.exitCode === null && child.signalCode === null) await waitForExit(child, { signal: "SIGINT", graceMs: 30_000 });
+ if (ownsEvidenceDir) await removeTempDir(evidenceDir);
+});
+
+(enabled ? it : it.skip)("keeps a window-filling page at a page's height and a flowing page at its content's", async () => {
+ mkdirSync(evidenceDir, { recursive: true });
+ const calls = join(evidenceDir, "tool-calls.json");
+ child = spawn(process.execPath, ["--experimental-strip-types", join(ROOT, "scripts/control-omb.ts"), "ui", "launch"], {
+ cwd: ROOT, env: { ...process.env, FAKE_CLAUDE_TOOL_CALLS_FILE: calls }, stdio: ["ignore", "pipe", "pipe"],
+ });
+ let stdout = "", stderr = "";
+ child.stdout!.on("data", (chunk: Buffer) => { stdout += String(chunk); });
+ child.stderr!.on("data", (chunk: Buffer) => { stderr += String(chunk); });
+ let info: { ui: string; url: string; botId: string } | undefined;
+ await expect.poll(() => {
+ if (child!.exitCode !== null) throw new Error(`ui launch exited: ${stderr}`);
+ try { info = JSON.parse(stdout.slice(stdout.indexOf("{"))); return Boolean(info?.ui); } catch { return false; }
+ }, { timeout: LAUNCH_TIMEOUT_MS, interval: 250 }).toBe(true);
+ const { ui: handle, url, botId } = info!;
+ const browser = JSON.parse(readFileSync(handle, "utf8")) as UiHandle;
+ await agentBrowser(browser.binary, sessionEnv(browser), ["set", "viewport", "1280", "900"], 60_000);
+ const newest = async () => (await ui("eval", handle, "--js", `(() => {
+ const rows = document.querySelectorAll('[data-app]');
+ const row = rows[rows.length - 1];
+ if (!row) return null;
+ row.scrollIntoView({ block: 'center' });
+ return {
+ rows: rows.length,
+ title: row.getAttribute('aria-label'),
+ state: row.dataset.appState,
+ box: Math.round(row.querySelector('[data-app-box]')?.getBoundingClientRect().height ?? 0),
+ frame: Math.round(row.querySelector('iframe[data-app-frame]')?.getBoundingClientRect().height ?? 0),
+ };
+ })()`)).result as { rows: number; title: string; state: string; box: number; frame: number } | null;
+
+ const measured: Record<string, { box: number; frame: number }> = {};
+ for (const [index, page] of PAGES.entries()) {
+ writeFileSync(calls, JSON.stringify([{ name: "show_html", server: "agents", input: page.input }]));
+ await runControlOmb(["send", "--bot", botId, "--text", `Show ${page.input.title}.`, "--url", url]);
+ expect((await runControlOmb(["wait", "--bot", botId, "--timeout", "60", "--url", url]) as { status: string }).status).toBe("settled");
+ // A page drawn to its window never changes the frame's height: steady means the same for three seconds.
+ const seen: string[] = [];
+ await expect.poll(async () => {
+ seen.push(JSON.stringify(await newest()));
+ const last = seen.slice(-4);
+ const latest = JSON.parse(last[0]!) as Awaited<ReturnType<typeof newest>>;
+ return last.length === 4 && new Set(last).size === 1 && latest?.rows === index + 1 && latest.state === "live";
+ }, { timeout: 30_000, interval: 1_000 }).toBe(true);
+ const { box, frame } = (await newest())!;
+ measured[page.key] = { box, frame };
+ await ui("screenshot", handle, "--out", join(evidenceDir, `${page.key}.png`));
+ }
+ writeFileSync(join(evidenceDir, "heights.json"), `${JSON.stringify(measured, null, 2)}\n`);
+
+ expect(measured).toEqual({
+ "map-layer": { box: 520, frame: 520 },
+ "map-layer-400": { box: 400, frame: 400 },
+ "map-percent": { box: 520, frame: 520 },
+ flowing: { box: FLOWING_HEIGHT, frame: FLOWING_HEIGHT },
+ });
+}, LAUNCH_TIMEOUT_MS + 240_000);
diff --git a/server/drivers/agents-app-tools.ts b/server/drivers/agents-app-tools.ts
index 791a609d98..6acb2e3ccf 100644
--- a/server/drivers/agents-app-tools.ts
+++ b/server/drivers/agents-app-tools.ts
@@ -2,7 +2,7 @@ export const APP_TOOL_DEFINITIONS = [
{
name: "show_html",
description:
- "Show a small self-contained web page in this chat, where the person watches it appear and can point at a part to change: a mini app, a game, a chart, a calculator, a report. For forms and choices use show_widget instead, and for plain data a markdown table. Send `html`, one HTML document (a fragment is wrapped) with inline style and script, or `jsx`, one React component file with a default export: it can import react, lucide-react icons, echarts, and Chart and useTheme from \"mausbot\", and style with Tailwind classes. Or send `path`, a folder in your working folder with index.html and its files (scripts, data, csv or parquet, images; up to 5 MB). It runs in a locked sandbox: no network requests, cookies, storage, popups or form posts. Scripts, styles and fonts load only from cdnjs.cloudflare.com, cdn.jsdelivr.net, unpkg.com and Google Fonts; images must be data: URLs or come from those CDNs. Embed the data you need. Use the CSS variables --color-text-primary, --color-background-primary, --color-border-primary and --font-sans to match the person's theme. In the page, mausbot.send(text) sends text as the person's next message (only after they click in it), mausbot.open(url) opens a link, and mausbot.setContext(text) tells you what they see, with their next message. At most 256 KB. To replace a page you showed, in place, call this again with the app_id it returned and new html, jsx or path (was update_html); it reloads, so anything the person did in it is lost. Never put secrets in it. Not available in rooms. For a data dashboard, follow the data-dashboards skill.",
+ "Show a small self-contained web page in this chat, where the person watches it appear and can point at a part to change: a mini app, a game, a chart, a calculator, a report. For maps, canvases, games or anything that fills the window, pass `height`. For forms and choices use show_widget instead, and for plain data a markdown table. Send `html`, one HTML document (a fragment is wrapped) with inline style and script, or `jsx`, one React component file with a default export: it can import react, lucide-react icons, echarts, and Chart and useTheme from \"mausbot\", and style with Tailwind classes. Or send `path`, a folder in your working folder with index.html and its files (scripts, data, csv or parquet, images; up to 5 MB). It runs in a locked sandbox: no network requests, cookies, storage, popups or form posts. Scripts, styles and fonts load only from cdnjs.cloudflare.com, cdn.jsdelivr.net, unpkg.com and Google Fonts; images must be data: URLs or come from those CDNs. Embed the data you need. Use the CSS variables --color-text-primary, --color-background-primary, --color-border-primary and --font-sans to match the person's theme. In the page, mausbot.send(text) sends text as the person's next message (only after they click in it), mausbot.open(url) opens a link, and mausbot.setContext(text) tells you what they see, with their next message. At most 256 KB. To replace a page you showed, in place, call this again with the app_id it returned and new html, jsx or path (was update_html); it reloads, so anything the person did in it is lost. Never put secrets in it. Not available in rooms. For a data dashboard, follow the data-dashboards skill.",
inputSchema: {
type: "object",
additionalProperties: false,
diff --git a/server/drivers/agents-catalog-goldens/full.tools-list.json b/server/drivers/agents-catalog-goldens/full.tools-list.json
index 206cdde69e..25179b6d02 100644
--- a/server/drivers/agents-catalog-goldens/full.tools-list.json
+++ b/server/drivers/agents-catalog-goldens/full.tools-list.json
@@ -441,7 +441,7 @@
},
{
"name": "show_html",
- "description": "Show a small self-contained web page in this chat, where the person watches it appear and can point at a part to change: a mini app, a game, a chart, a calculator, a report. For forms and choices use show_widget instead, and for plain data a markdown table. Send `html`, one HTML document (a fragment is wrapped) with inline style and script, or `jsx`, one React component file with a default export: it can import react, lucide-react icons, echarts, and Chart and useTheme from \"mausbot\", and style with Tailwind classes. Or send `path`, a folder in your working folder with index.html and its files (scripts, data, csv or parquet, images; up to 5 MB). It runs in a locked sandbox: no network requests, cookies, storage, popups or form posts. Scripts, styles and fonts load only from cdnjs.cloudflare.com, cdn.jsdelivr.net, unpkg.com and Google Fonts; images must be data: URLs or come from those CDNs. Embed the data you need. Use the CSS variables --color-text-primary, --color-background-primary, --color-border-primary and --font-sans to match the person's theme. In the page, mausbot.send(text) sends text as the person's next message (only after they click in it), mausbot.open(url) opens a link, and mausbot.setContext(text) tells you what they see, with their next message. At most 256 KB. To replace a page you showed, in place, call this again with the app_id it returned and new html, jsx or path (was update_html); it reloads, so anything the person did in it is lost. Never put secrets in it. Not available in rooms. For a data dashboard, follow the data-dashboards skill.",
+ "description": "Show a small self-contained web page in this chat, where the person watches it appear and can point at a part to change: a mini app, a game, a chart, a calculator, a report. For maps, canvases, games or anything that fills the window, pass `height`. For forms and choices use show_widget instead, and for plain data a markdown table. Send `html`, one HTML document (a fragment is wrapped) with inline style and script, or `jsx`, one React component file with a default export: it can import react, lucide-react icons, echarts, and Chart and useTheme from \"mausbot\", and style with Tailwind classes. Or send `path`, a folder in your working folder with index.html and its files (scripts, data, csv or parquet, images; up to 5 MB). It runs in a locked sandbox: no network requests, cookies, storage, popups or form posts. Scripts, styles and fonts load only from cdnjs.cloudflare.com, cdn.jsdelivr.net, unpkg.com and Google Fonts; images must be data: URLs or come from those CDNs. Embed the data you need. Use the CSS variables --color-text-primary, --color-background-primary, --color-border-primary and --font-sans to match the person's theme. In the page, mausbot.send(text) sends text as the person's next message (only after they click in it), mausbot.open(url) opens a link, and mausbot.setContext(text) tells you what they see, with their next message. At most 256 KB. To replace a page you showed, in place, call this again with the app_id it returned and new html, jsx or path (was update_html); it reloads, so anything the person did in it is lost. Never put secrets in it. Not available in rooms. For a data dashboard, follow the data-dashboards skill.",
"inputSchema": {
"type": "object",
"additionalProperties": false,
diff --git a/server/drivers/agents-catalog-goldens/profiles.json b/server/drivers/agents-catalog-goldens/profiles.json
index 9a062a1526..2e8461e32b 100644
--- a/server/drivers/agents-catalog-goldens/profiles.json
+++ b/server/drivers/agents-catalog-goldens/profiles.json
@@ -1,7 +1,7 @@
{
"default": {
- "bytes": 59340,
- "sha256": "65d2d72264da0bb12933526d00f03a59d3ba967620701fc789fd9bebfe21f8ad",
+ "bytes": 59416,
+ "sha256": "a3b1ef7653b4d1c7e28c1fdd3511f2136150923694400b6b2a92d3c9ebb3aaaa",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -51,8 +51,8 @@
]
},
"voice": {
- "bytes": 60121,
- "sha256": "d4f551d4b173db1affb0926e8636e1a4ac37d1649bf2097197d3fd6e0163faa7",
+ "bytes": 60197,
+ "sha256": "2a4e954495ee3140fc960dad407c11e7d985876561f40f98f053953e22e4d394",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -103,8 +103,8 @@
]
},
"shared": {
- "bytes": 61605,
- "sha256": "fd9928ed2b6b442cdaf8ab55140e7092964a8d46c971e04e973292f2dad9d019",
+ "bytes": 61681,
+ "sha256": "f6e4d4992bc747ebdc1d85d66ba7c80ddf35d00cb668bc644bc54aa2f6cae249",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -156,8 +156,8 @@
]
},
"shared+voice": {
- "bytes": 62386,
- "sha256": "36e5ff149ad0b93c6b5c497eb9f3bff8652aaf860f97cf8bebe97dcf9f8a563f",
+ "bytes": 62462,
+ "sha256": "b35168196f87eeef2cab3bd45242c9300ec5aa4b8fa9485ba79e7e6c186b57b4",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -210,8 +210,8 @@
]
},
"skills": {
- "bytes": 62267,
- "sha256": "6135fd2608e4d49a9e231f5e636ffd86e3a8720088a7ca7aba23a13e5b3662db",
+ "bytes": 62343,
+ "sha256": "4368d4f508208a87b3bc109fb87b8d39ec743abaf5931ed9ddae76fd7abbe20c",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -263,8 +263,8 @@
]
},
"skills+voice": {
- "bytes": 63048,
- "sha256": "66252617bb7029d34ef24820f18f48b8691236c0c74ac34911beb06765493210",
+ "bytes": 63124,
+ "sha256": "71f89468d2ab5bf423983da2988da4ac8039112cc4815c3f0d8a06e6bea96ca1",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -317,8 +317,8 @@
]
},
"skills+shared": {
- "bytes": 64532,
- "sha256": "60145540ec7ff1c02e64d87bae1c93dcdf5bca1446fc90c5c18d7f90f1271c3d",
+ "bytes": 64608,
+ "sha256": "fefd3ba8b66a92659e8c1d8435b316f64cd9ce4b28c5bd775b4352424f7e0246",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -372,8 +372,8 @@
]
},
"skills+shared+voice": {
- "bytes": 65313,
- "sha256": "ac0555dbd0032ef3c12614a36d087d63950c955d306a030b3cacd1e8b3e83ec1",
+ "bytes": 65389,
+ "sha256": "13622fc5d3189bbaa87ea03c5ff7a823fa31f81cf93a53976a98f8b47576182d",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -428,8 +428,8 @@
]
},
"non-chief": {
- "bytes": 50124,
- "sha256": "adeb52d81654ce85904d77c4d615590845236af686cfa5bbad250144e0fb3997",
+ "bytes": 50200,
+ "sha256": "5536c0b5d5eb9dde7ce9e77d9124586dcbbeaf50818c6e894b3bd886aee17043",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -472,8 +472,8 @@
]
},
"voice+non-chief": {
- "bytes": 50905,
- "sha256": "6b97feae5be74344a3d1d90bb56afc5e1ce8966650e0fb74984381e8959feaf8",
+ "bytes": 50981,
+ "sha256": "71713f79fc0766fd38f7cf9a04344e3366963148248c12264b5eabdf38582708",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -517,8 +517,8 @@
]
},
"shared+non-chief": {
- "bytes": 52389,
- "sha256": "f1822146db8afe5c8f8a946b4a63ca9967e762a1190f17364b8178b4f924158e",
+ "bytes": 52465,
+ "sha256": "d7e50b4f4403c56d837016f072c6f48f488936cf6b617ded3bf2d075f5ef4577",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -563,8 +563,8 @@
]
},
"shared+voice+non-chief": {
- "bytes": 53170,
- "sha256": "94f805eb579b87ef9753c967f95cd8a12a734bb18d9f113f30ed05f7b931225a",
+ "bytes": 53246,
+ "sha256": "fcd028c4e5acffa4f7fc5ea96aab920ea10bc62407bef38b1c4e8dafd1e59c93",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -610,8 +610,8 @@
]
},
"skills+non-chief": {
- "bytes": 53051,
- "sha256": "24f66bc798e102712896fb3b86461901d5b8738cec45113ef7e599b16f9058d1",
+ "bytes": 53127,
+ "sha256": "36d15d809793d91649d6adaa29d7fb8d2d73dea2488e013b2404159c96aca5a3",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -656,8 +656,8 @@
]
},
"skills+voice+non-chief": {
- "bytes": 53832,
- "sha256": "20c008bdb7ade399b3e391e1d474e969ede68cf5cb3bb8ee698cddc2ae57f4d6",
+ "bytes": 53908,
+ "sha256": "4bb81ea83e8d9cfd40efeda355f13dc9e9bb72e8047b8e5e8b7680bbe7fa0db5",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -703,8 +703,8 @@
]
},
"skills+shared+non-chief": {
- "bytes": 55316,
- "sha256": "db965becc32ce7aa75339f0cb93ead0e911e8a3d8a4b5570271cf1708b4e340e",
+ "bytes": 55392,
+ "sha256": "c93abec16d9be00bce91d8356b0f4983ca31429aabb74f1b652d6fd972934448",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -751,8 +751,8 @@
]
},
"skills+shared+voice+non-chief": {
- "bytes": 56097,
- "sha256": "03d6a0d9a39b0b0cf5e18550c52810548f39809e9b622b6ba0fca4911f3b4d92",
+ "bytes": 56173,
+ "sha256": "76f5b13cfefa8dbdea324847957854eea038c32adcd126b353bba487d88003b4",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -800,8 +800,8 @@
]
},
"skills+shared+voice+cloud-home": {
- "bytes": 65079,
- "sha256": "a5a0d5849e250c33b63bb04b914fe8c14bfbfe41ca1c163128202399e24f7975",
+ "bytes": 65155,
+ "sha256": "6c21f018e41877e0795f31f8013ade0e5765e144a4debc62846e802ac9135b89",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -856,8 +856,8 @@
]
},
"skills+shared+voice+non-chief+cloud-home": {
- "bytes": 55863,
- "sha256": "1a659071281088ad5aa9d7e5116c2c62f0cbf4ba7068e0f61edcaf70c15d9a7c",
+ "bytes": 55939,
+ "sha256": "a94780d4ed094941fb499eeb1387b5e3a8772902925edff70afc24c67b36587a",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -905,8 +905,8 @@
]
},
"skills+shared+voice+escalations": {
- "bytes": 66143,
- "sha256": "bb56189a11306e2b4636f108135aee82b52fcc3be1cb4b6b616fc680aaaa3287",
+ "bytes": 66219,
+ "sha256": "a6f739b6c4c4fbe808b61edaac5cb2f77591754e5e0ec6cc30db6f4050dac719",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -962,8 +962,8 @@
]
},
"skills+shared+voice+escalations+x": {
- "bytes": 69982,
- "sha256": "018968d7f08733f6d23945eff608f5c41937d078de5d9e95f96ab59f06267a95",
+ "bytes": 70058,
+ "sha256": "5d47018f394bde78975cdccf63d54d466c9018e148acc1e493cc43b4a22abdbf",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1023,8 +1023,8 @@
]
},
"skills+shared+voice+escalations+x+team": {
- "bytes": 69982,
- "sha256": "018968d7f08733f6d23945eff608f5c41937d078de5d9e95f96ab59f06267a95",
+ "bytes": 70058,
+ "sha256": "5d47018f394bde78975cdccf63d54d466c9018e148acc1e493cc43b4a22abdbf",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1084,8 +1084,8 @@
]
},
"skills+shared+voice+escalations+x+team+images": {
- "bytes": 70755,
- "sha256": "66dec6f1a6ea0a4750f5d3bd9293306b19640998e0aaa9d1e0c319590fcd5374",
+ "bytes": 70831,
+ "sha256": "db13877378cf9547ec745106984178532080d51e6c3aa6615c083f91a95afdf2",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1146,8 +1146,8 @@
]
},
"default+legacy-switches": {
- "bytes": 59340,
- "sha256": "65d2d72264da0bb12933526d00f03a59d3ba967620701fc789fd9bebfe21f8ad",
+ "bytes": 59416,
+ "sha256": "a3b1ef7653b4d1c7e28c1fdd3511f2136150923694400b6b2a92d3c9ebb3aaaa",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1197,8 +1197,8 @@
]
},
"default+mausbot": {
- "bytes": 59991,
- "sha256": "e1edab1ae4b38a0cec81b901df0cbe413f0f7e7790d9918d9fd3b50926112fbc",
+ "bytes": 60067,
+ "sha256": "598d4b9d789976a1c2c393dc7cc790b2a2367a0fab7687255248dc0aa99e3b97",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1250,8 +1250,8 @@
]
},
"skills+shared+voice+mausbot": {
- "bytes": 65964,
- "sha256": "eac49bb7dd495ff29c5ea3ea1d63d8c0c580b7686ea7a2f13408647ce7612b0a",
+ "bytes": 66040,
+ "sha256": "b23565cbb2b9305df6a5d6362f62b9073b6ef9903e93ea905ce00905bc78f6f5",
"tools": [
"tool_result_read",
"list_shared_computers",
@@ -1308,8 +1308,8 @@
]
},
"default+no-computer-pick": {
- "bytes": 58128,
- "sha256": "9009c1ff16258622aca14cb953ddda86042c1d3cb29a00128a4342989ca1a6e0",
+ "bytes": 58204,
+ "sha256": "f2f7627eedf5428d9bfb87fe4117f7fdeaf41ab399c72ff882139f0429d18bbd",
"tools": [
"tool_result_read",
"list_room_targets",
@@ -1441,8 +1441,8 @@
]
},
"default+images": {
- "bytes": 60113,
- "sha256": "600ec9e8c705f967f2bc4869d472fd0e52249ad6d7d13159c39571869b8ecf19",
+ "bytes": 60189,
+ "sha256": "5d9aea4b941a6ef6020b7747d4154480f7566c5ca6ef87f07051487f8b0e6381",
"tools": [
"tool_result_read",
"list_room_targets",
diff --git a/server/drivers/agents-catalog-wire.test.ts b/server/drivers/agents-catalog-wire.test.ts
index 3b987208fb..83a93b577e 100644
--- a/server/drivers/agents-catalog-wire.test.ts
+++ b/server/drivers/agents-catalog-wire.test.ts
@@ -83,31 +83,31 @@ const FULL = "skills+shared+voice+escalations+x+team+images";
/** Bytes when the budget was last set; a profile may move at most 2% either way (lower it to lock in a win). */
const BUDGET_BASELINE: Record<string, number> = {
- "default": 58250,
+ "default": 59416,
"voice": 59031,
"shared": 60515,
"shared+voice": 61296,
- "skills": 61069,
- "skills+voice": 61850,
- "skills+shared": 63334,
+ "skills": 62343,
+ "skills+voice": 63124,
+ "skills+shared": 64608,
"skills+shared+voice": 64115,
"non-chief": 49935,
"voice+non-chief": 50716,
"shared+non-chief": 52200,
"shared+voice+non-chief": 52981,
"skills+non-chief": 52754,
- "skills+voice+non-chief": 52793,
+ "skills+voice+non-chief": 53908,
"skills+shared+non-chief": 55212,
- "skills+shared+voice+non-chief": 55058,
+ "skills+shared+voice+non-chief": 56173,
"skills+shared+voice+cloud-home": 64782,
"skills+shared+voice+non-chief+cloud-home": 55566,
- "default+legacy-switches": 58250,
+ "default+legacy-switches": 59416,
"default+mausbot": 58901,
"skills+shared+voice+mausbot": 64766,
"skills+shared+voice+escalations": 64945,
"skills+shared+voice+escalations+x": 68784,
"skills+shared+voice+escalations+x+team": 69416,
- "default+no-computer-pick": 57038,
+ "default+no-computer-pick": 58204,
"default+room": 50849,
"non-chief+room": 41633,
"skills+shared+voice+escalations+x+team+images": 70755,
diff --git a/shared/app-frame/helper.test.ts b/shared/app-frame/helper.test.ts
index 6e1d9e79c4..d32f096199 100644
--- a/shared/app-frame/helper.test.ts
+++ b/shared/app-frame/helper.test.ts
@@ -16,10 +16,19 @@ type Listener = (event: { source: unknown; data: unknown }) => void;
const pages: Window[] = [];
afterEach(async () => { for (const page of pages.splice(0)) await page.happyDOM.close(); });
-function boot(engaged = true) {
+/** What the fake frame's layout answers: the page's flow when html and body are freed, at a frame of `height`, and the
+ * elements under the frame's middle. "window" follows the frame; `freed` is an element's height in the freed layout. */
+interface Scene {
+ flow: (height: number) => number;
+ under?: Array<{ position?: "absolute" | "fixed"; width: number | "window"; height: number | "window"; freed?: number }>;
+}
+
+function boot(engaged = true, options: { scene?: Scene; start?: number; loaded?: boolean } = {}) {
const page = new Window();
pages.push(page);
const listeners = new Set<Listener>();
+ const loads = new Set<() => void>();
+ const observers = new Set<() => void>();
let bridge: AppBridge;
const parent = {
postMessage(data: unknown) {
@@ -27,14 +36,43 @@ function boot(engaged = true) {
setTimeout(() => bridge.handleMessage({ source: frame, data: copy }), 0);
},
};
+ const positions = new Map<unknown, string>();
const frame: Record<string, unknown> = {
parent,
- addEventListener(type: string, listener: Listener) { if (type === "message") listeners.add(listener); },
+ innerWidth: 760,
+ innerHeight: options.start ?? 520,
+ addEventListener(type: string, listener: Listener) {
+ if (type === "message") listeners.add(listener);
+ if (type === "load") loads.add(listener as unknown as () => void);
+ },
postMessage(data: unknown) {
const copy = structuredClone(data);
setTimeout(() => { for (const listener of listeners) listener({ source: parent, data: copy }); }, 0);
},
+ getComputedStyle: (element: unknown) => ({ position: positions.get(element) ?? "static" }),
};
+ const document = page.document;
+ const root = document.documentElement;
+ Object.defineProperty(document, "readyState", { configurable: true, get: () => (options.loaded === false ? "loading" : "complete") });
+ const scene = options.scene;
+ if (scene) {
+ const freed = () => root.style.getPropertyValue("height") === "max-content";
+ const size = (value: number | "window", window: number) => (value === "window" ? window : value);
+ const rect = (width: number, height: number) => ({ width, height, top: 0, left: 0, right: width, bottom: height, x: 0, y: 0, toJSON() {} }) as DOMRect;
+ root.getBoundingClientRect = () => rect(frame.innerWidth as number, freed() ? scene.flow(frame.innerHeight as number) : frame.innerHeight as number);
+ const under = (scene.under ?? []).map((layer) => {
+ const element = document.createElement("div");
+ document.body.appendChild(element);
+ if (layer.position) positions.set(element, layer.position);
+ element.getBoundingClientRect = () => {
+ const width = size(layer.width, frame.innerWidth as number);
+ const height = size(layer.height, frame.innerHeight as number);
+ return rect(width, freed() && layer.freed !== undefined ? layer.freed : height);
+ };
+ return element;
+ });
+ (document as unknown as { elementsFromPoint(): Element[] }).elementsFromPoint = () => [...under, document.body, root];
+ }
const seen = { messages: [] as string[], links: [] as string[], contexts: [] as unknown[], heights: [] as number[] };
bridge = createAppBridge({
doc: DOC,
@@ -47,18 +85,43 @@ function boot(engaged = true) {
sendMessage: async (text) => { seen.messages.push(text); },
openLink: (url) => { seen.links.push(url); },
setContext: (update) => { seen.contexts.push(update); },
- resize: (height) => { seen.heights.push(height); },
+ resize: (height) => {
+ seen.heights.push(height);
+ frame.innerHeight = height;
+ for (const observed of observers) setTimeout(observed, 0);
+ },
engaged: () => engaged,
teardownRequested: () => {},
now: () => Date.now(),
},
});
+ class FakeResizeObserver {
+ constructor(callback: () => void) { observers.add(callback); }
+ observe() {}
+ }
// The helper's free names, bound to this fake frame: it runs exactly as written.
const run = new Function("window", "document", "ResizeObserver", "requestAnimationFrame", APP_HELPER_SOURCE);
- run(frame, page.document, undefined, (callback: () => void) => setTimeout(callback, 0));
- return { bridge, seen, frame, root: page.document.documentElement, mausbot: () => frame.mausbot as {
- send(text: string): Promise<void>; open(url: string): Promise<void>; setContext(text: string): Promise<void>; theme: string;
- } };
+ run(frame, document, scene ? FakeResizeObserver : undefined, (callback: () => void) => setTimeout(callback, 0));
+ return {
+ bridge, seen, frame, root,
+ load: () => { options.loaded = true; for (const listener of loads) listener(); },
+ reflow: () => { for (const observed of observers) setTimeout(observed, 0); },
+ mausbot: () => frame.mausbot as {
+ send(text: string): Promise<void>; open(url: string): Promise<void>; setContext(text: string): Promise<void>; theme: string;
+ },
+ };
+}
+
+/** The heights reported once the frame has stopped changing, or after 20 rounds of a frame that never does. */
+async function settled(page: ReturnType<typeof boot>) {
+ await expect.poll(() => page.seen.heights.length).toBeGreaterThan(0);
+ let count = -1;
+ for (let round = 0; round < 20 && count !== page.seen.heights.length; round++) {
+ count = page.seen.heights.length;
+ page.reflow();
+ await new Promise((resolve) => setTimeout(resolve, 30));
+ }
+ return page.seen.heights;
}
describe("the bot-page helper", () => {
@@ -104,3 +167,65 @@ describe("the bot-page helper", () => {
expect(page.mausbot()).toBe(original);
});
});
+
+describe("the height a bot page reports", () => {
+ const flow = (height: number) => () => height;
+
+ it("is its content's for a page that flows, with or without a small layer over it", async () => {
+ expect(await settled(boot(true, { scene: { flow: flow(296) } }))).toEqual([296]);
+ expect(await settled(boot(true, { scene: { flow: flow(60), under: [{ position: "absolute", width: 240, height: 90 }] } }))).toEqual([60]);
+ });
+
+ it("is the frame's starting height for a page drawn by a layer the size of the window", async () => {
+ for (const position of ["absolute", "fixed"] as const) {
+ expect(await settled(boot(true, { scene: { flow: flow(0), under: [{ position, width: "window", height: "window" }] } }))).toEqual([520]);
+ }
+ expect(await settled(boot(true, { start: 400, scene: { flow: flow(30), under: [{ position: "absolute", width: "window", height: "window" }] } }))).toEqual([400]);
+ });
+
+ it("is the starting height for a map sized by percentages with nothing in its flow", async () => {
+ const map = { width: "window", height: "window", freed: 0 } as const;
+ expect(await settled(boot(true, { scene: { flow: flow(0), under: [map] } }))).toEqual([520]);
+ });
+
+ it("is the content's for an element stretched to the window around content of its own", async () => {
+ const stretched = { width: "window", height: "window", freed: 80 } as const;
+ expect(await settled(boot(true, { scene: { flow: flow(80), under: [stretched] } }))).toEqual([80]);
+ });
+
+ it("is the content's when the flow is taller than a small page, even over a window layer", async () => {
+ expect(await settled(boot(true, { scene: { flow: flow(300), under: [{ position: "absolute", width: "window", height: "window" }] } }))).toEqual([300]);
+ });
+
+ it("leaves the starting height once the flow needs more", async () => {
+ let content = 0;
+ const page = boot(true, { scene: { flow: () => content, under: [{ position: "absolute", width: "window", height: "window" }] } });
+ expect(await settled(page)).toEqual([520]);
+ content = 300;
+ page.reflow();
+ expect(await settled(page)).toEqual([520]);
+ content = 610;
+ page.reflow();
+ expect(await settled(page)).toEqual([520, 610]);
+ });
+
+ it("settles when the layer covers the window only once the frame is small", async () => {
+ const toolbar = { position: "absolute", width: "window", height: 44 } as const;
+ expect(await settled(boot(true, { scene: { flow: flow(0), under: [toolbar] } }))).toEqual([48, 520]);
+ });
+
+ it("settles when the flow is sized from the window", async () => {
+ const page = boot(true, { scene: { flow: (height) => Math.round(height * 0.3), under: [{ position: "absolute", width: "window", height: "window" }] } });
+ expect(await settled(page)).toEqual([156, 520]);
+ });
+
+ it("waits for the page to load", async () => {
+ const page = boot(true, { loaded: false, scene: { flow: flow(0), under: [{ position: "absolute", width: "window", height: "window" }] } });
+ await expect.poll(() => page.bridge.initialized).toBe(true);
+ page.reflow();
+ await new Promise((resolve) => setTimeout(resolve, 50));
+ expect(page.seen.heights).toEqual([]);
+ page.load();
+ expect(await settled(page)).toEqual([520]);
+ });
+});
diff --git a/shared/app-frame/helper.ts b/shared/app-frame/helper.ts
index f5f6f670c3..1c77dfa2c3 100644
--- a/shared/app-frame/helper.ts
+++ b/shared/app-frame/helper.ts
@@ -76,7 +76,7 @@ export const APP_HELPER_SOURCE = `(function () {
// in it, which in a frame that sizes to its content only ever reports the
// frame's current height while the content spills out above and below.
// Both are freed for the measurement and put back before the next paint.
- var measure = function () {
+ var freedHeights = function (elements) {
var body = document.body;
var boxes = body ? [root, body] : [root];
var saved = boxes.map(function (box) { return [box.style.height, box.style.minHeight, box.style.maxHeight]; });
@@ -85,7 +85,7 @@ export const APP_HELPER_SOURCE = `(function () {
box.style.setProperty("min-height", "0", "important");
box.style.setProperty("max-height", "none", "important");
});
- var height = Math.ceil(root.getBoundingClientRect().height);
+ var heights = elements.map(function (element) { return element.getBoundingClientRect().height; });
boxes.forEach(function (box, index) {
box.style.removeProperty("height");
box.style.removeProperty("min-height");
@@ -94,18 +94,46 @@ export const APP_HELPER_SOURCE = `(function () {
if (saved[index][1]) box.style.minHeight = saved[index][1];
if (saved[index][2]) box.style.maxHeight = saved[index][2];
});
- return height;
+ return heights;
+ };
+ var isLayer = function (element) {
+ var position = window.getComputedStyle(element).position;
+ return position === "absolute" || position === "fixed";
+ };
+ var drawsToWindow = function () {
+ var width = window.innerWidth;
+ var height = window.innerHeight;
+ if (!width || !height || typeof document.elementsFromPoint !== "function") return false;
+ var large = document.elementsFromPoint(width / 2, height / 2).filter(function (element) {
+ var box = element.getBoundingClientRect();
+ return element !== root && element !== document.body && box.width >= width / 2 && box.height >= height / 2;
+ });
+ if (large.some(isLayer)) return true;
+ // Sized from the window with no flow of its own: a map in html, body, #map { height: 100% }.
+ return large.length > 0 && freedHeights(large).some(function (freed) { return freed < 1; });
+ };
+ // A page drawn to its window keeps the frame's starting height until its
+ // flow needs more: its layers follow the frame, so what it reports must not.
+ var SHORT_FLOW = 120;
+ var start = 0;
+ var filling = false;
+ var heightToReport = function () {
+ var flow = Math.ceil(freedHeights([root])[0]);
+ if (!start) start = Math.round(window.innerHeight) || 0;
+ if (filling && flow < Math.max(start, SHORT_FLOW)) return start;
+ filling = start > 0 && flow < SHORT_FLOW && drawsToWindow();
+ return filling ? start : flow;
};
var watchSize = function () {
var last = -1;
var queued = false;
var later = typeof requestAnimationFrame === "function" ? requestAnimationFrame : function (fn) { return setTimeout(fn, 16); };
var report = function () {
- if (queued) return;
+ if (queued || document.readyState !== "complete") return;
queued = true;
later(function () {
queued = false;
- var height = measure();
+ var height = heightToReport();
if (height !== last) { last = height; notify("ui/notifications/size-changed", { height: height }); }
});
};
diff --git a/shared/app-frame/jsx-page.ts b/shared/app-frame/jsx-page.ts
index 04a79d0906..65224359ed 100644
--- a/shared/app-frame/jsx-page.ts
+++ b/shared/app-frame/jsx-page.ts
@@ -234,7 +234,7 @@ const BASE_STYLE = [
"html,body{margin:0}",
"body{font-family:var(--font-sans,system-ui,sans-serif);color:var(--color-text-primary,#1d1d1f);",
"background:var(--color-background-primary,#fff);-webkit-font-smoothing:antialiased}",
- "#mausbot-root:empty::before{content:\"Loading\\2026\";display:block;padding:24px;font:14px/20px system-ui,sans-serif;opacity:.6}",
+ "#mausbot-root:empty::before{content:\"Loading\\2026\";display:block;box-sizing:border-box;min-height:100vh;padding:24px;font:14px/20px system-ui,sans-serif;opacity:.6}",
".mausbot-problem{position:fixed;inset:12px;overflow:auto;z-index:2147483646;border-radius:12px;padding:16px 18px;",
"font:14px/1.5 system-ui,sans-serif;background:#fff6f5;color:#5c1712;border:1px solid #f3c2bd;box-shadow:0 8px 24px rgba(0,0,0,.12)}",
"[data-theme=dark] .mausbot-problem{background:#2a1513;color:#ffd9d4;border-color:#6b2a24}",