openmausbot 0.1.96 → 0.1.97

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist/assets/{DesktopViewer-DsnA23KM.js → DesktopViewer-CPidMCtt.js} +1 -1
  2. package/dist/assets/{abnfDiagram-O67JEVCF-Dkbd2hcj.js → abnfDiagram-O67JEVCF-k1UCNXb7.js} +1 -1
  3. package/dist/assets/{arc-Duj5Coy2.js → arc-BUWGa9UU.js} +1 -1
  4. package/dist/assets/{architectureDiagram-NJMV4G6O-uYUsDawP.js → architectureDiagram-NJMV4G6O-DiPor3UT.js} +1 -1
  5. package/dist/assets/{blockDiagram-BEXU5L5S-CWDlTpXe.js → blockDiagram-BEXU5L5S-Ag9nLW4H.js} +1 -1
  6. package/dist/assets/{c4Diagram-YGBWAQC7-B0t15PDc.js → c4Diagram-YGBWAQC7-Bh0sjgUa.js} +1 -1
  7. package/dist/assets/channel-DR8eD6QW.js +1 -0
  8. package/dist/assets/{chunk-2Q5K7J3B-BJSCL-HV.js → chunk-2Q5K7J3B-BFBcIIqu.js} +1 -1
  9. package/dist/assets/{chunk-3FUC2YCW-D3_ILccd.js → chunk-3FUC2YCW-Dvfpex-f.js} +2 -2
  10. package/dist/assets/{chunk-5VM5RSS4-D3dmwT_S.js → chunk-5VM5RSS4-CMjP2YZW.js} +1 -1
  11. package/dist/assets/{chunk-GTNCS2PH-Br73HFPD.js → chunk-GTNCS2PH-BryoeTc7.js} +1 -1
  12. package/dist/assets/{chunk-GWA4HPMP-uSsjxubC.js → chunk-GWA4HPMP-BhfvcchO.js} +1 -1
  13. package/dist/assets/{chunk-JWPE2WC7-C40VWFyr.js → chunk-JWPE2WC7-bcCVp8rp.js} +1 -1
  14. package/dist/assets/{chunk-NETBCI7D-D6WNNYwU.js → chunk-NETBCI7D-yKIjIlkQ.js} +1 -1
  15. package/dist/assets/{chunk-WEXAMYUT-DOEhq64P.js → chunk-WEXAMYUT-D3Zqbmup.js} +1 -1
  16. package/dist/assets/{chunk-XXDRQBXY-BqJEi6Pi.js → chunk-XXDRQBXY-CjVoIMG6.js} +1 -1
  17. package/dist/assets/{classDiagram-v2-NBCMYWYE-ByU_GnxT.js → classDiagram-v2-NBCMYWYE-mUCWdVyH.js} +1 -1
  18. package/dist/assets/{cose-bilkent-JH36ORCC-D-Uglxqq.js → cose-bilkent-JH36ORCC-BBmR1bbX.js} +1 -1
  19. package/dist/assets/{cynefin-OW5HDTMX-CZWO7aYj.js → cynefin-OW5HDTMX-BpRrxoO4.js} +1 -1
  20. package/dist/assets/{cynefinDiagram-VND7K2PF-C70-w0la.js → cynefinDiagram-VND7K2PF-D3VBWCPK.js} +1 -1
  21. package/dist/assets/{dagre-6A5THRUB-CnhjhExB.js → dagre-6A5THRUB-DxEIACOO.js} +1 -1
  22. package/dist/assets/{diagram-22UHCM2B-bnjWCNb4.js → diagram-22UHCM2B-BANgZEOS.js} +1 -1
  23. package/dist/assets/{diagram-3UASUU5V-A4uTWoFV.js → diagram-3UASUU5V-Cnq7nJir.js} +1 -1
  24. package/dist/assets/{diagram-ATOU4E4O-Zi6m3NUl.js → diagram-ATOU4E4O-4TBDIWnz.js} +1 -1
  25. package/dist/assets/{diagram-CDSNMT55-DtCcmd5k.js → diagram-CDSNMT55-CD_B39D4.js} +1 -1
  26. package/dist/assets/{diagram-MLGK6HIB-DofuETS3.js → diagram-MLGK6HIB-CzvnFhEC.js} +1 -1
  27. package/dist/assets/{diagram-MPIPVDR6-Dw2T9PuU.js → diagram-MPIPVDR6-C4w2SNml.js} +1 -1
  28. package/dist/assets/{ebnfDiagram-ZINNZB2B-DbrwPiem.js → ebnfDiagram-ZINNZB2B-gkUEBm2s.js} +1 -1
  29. package/dist/assets/{elk-276RUBZZ-BvCt1dCb.js → elk-276RUBZZ-B_56X6mw.js} +1 -1
  30. package/dist/assets/{erDiagram-OPXOYQCR-Y-QKqPnU.js → erDiagram-OPXOYQCR-C_oByoDS.js} +1 -1
  31. package/dist/assets/{flowDiagram-KWPJA3E3-CDkL1B5w.js → flowDiagram-KWPJA3E3-CR9xXJkC.js} +1 -1
  32. package/dist/assets/{ganttDiagram-FUAMR5RP-CKV5D2F6.js → ganttDiagram-FUAMR5RP-gtYBTu0B.js} +1 -1
  33. package/dist/assets/{gitGraphDiagram-X574FWY7-nL9iFTCv.js → gitGraphDiagram-X574FWY7-VJ6-Tp_p.js} +1 -1
  34. package/dist/assets/{index-DreDnjOu.js → index-Cp4S4NOL.js} +1 -1
  35. package/dist/assets/index-CpaIXRLp.js +614 -0
  36. package/dist/assets/index-Z81SMsgR.css +1 -0
  37. package/dist/assets/{infoDiagram-VRGFBTTK-C7aHjzsf.js → infoDiagram-VRGFBTTK-2Lu9te4D.js} +1 -1
  38. package/dist/assets/{ishikawaDiagram-OU5B5YK6-KUZsNBTh.js → ishikawaDiagram-OU5B5YK6-DR49XY-e.js} +1 -1
  39. package/dist/assets/{journeyDiagram-ZHPQQLJL-CGUuodFl.js → journeyDiagram-ZHPQQLJL-ZoR0M305.js} +1 -1
  40. package/dist/assets/{kanban-definition-PNTS6WVX-Cy6r868Z.js → kanban-definition-PNTS6WVX-DLKHxrO-.js} +1 -1
  41. package/dist/assets/{linear-Bl669148.js → linear-BASsfWly.js} +1 -1
  42. package/dist/assets/{mermaid.core-86Xqz5Mr.js → mermaid.core-BVidiPkk.js} +5 -5
  43. package/dist/assets/{mindmap-definition-NLK3R4M7-G4DzHLrd.js → mindmap-definition-NLK3R4M7-g_Qx0U5C.js} +1 -1
  44. package/dist/assets/{pegDiagram-GJSIUBJH-K4eruzY0.js → pegDiagram-GJSIUBJH-DI9Cjs8w.js} +1 -1
  45. package/dist/assets/{pieDiagram-5QR66LMP-DYdR9PPq.js → pieDiagram-5QR66LMP-sRI0Uhr5.js} +1 -1
  46. package/dist/assets/{quadrantDiagram-O4NWA36T-BCAh0nEy.js → quadrantDiagram-O4NWA36T-CamKTby3.js} +1 -1
  47. package/dist/assets/{railroadDiagram-XR7U4H2S-p0dGRc4g.js → railroadDiagram-XR7U4H2S-DOLlkbf3.js} +1 -1
  48. package/dist/assets/{requirementDiagram-PLB6GJNP-tLeBG0aL.js → requirementDiagram-PLB6GJNP-DrRQ5r97.js} +1 -1
  49. package/dist/assets/{sankeyDiagram-IPEJSGJF-QRuN16rV.js → sankeyDiagram-IPEJSGJF-DGS_lXcX.js} +1 -1
  50. package/dist/assets/{sequenceDiagram-PO4LG4MO-ueT1nVoa.js → sequenceDiagram-PO4LG4MO-CkjWqwtf.js} +1 -1
  51. package/dist/assets/{sizeCapture-INFHLROL-wRS2zWg2.js → sizeCapture-INFHLROL-CepRgful.js} +1 -1
  52. package/dist/assets/{stateDiagram-v2-GCMORJYK-CYzA_hE1.js → stateDiagram-v2-GCMORJYK-hykr-9RS.js} +1 -1
  53. package/dist/assets/{swimlanes-2SLR337P-kDnv6LMc.js → swimlanes-2SLR337P-CKOHEZbI.js} +1 -1
  54. package/dist/assets/swimlanesDiagram-TC7HE7FX-D-8vqZ4-.js +8 -0
  55. package/dist/assets/{timeline-definition-EJHVYXUP-D1y2UbbH.js → timeline-definition-EJHVYXUP-CB8pJ6AC.js} +1 -1
  56. package/dist/assets/{usecaseDiagram-POWQR4AR-IqB4v9HX.js → usecaseDiagram-POWQR4AR-DrclJHdl.js} +1 -1
  57. package/dist/assets/{vennDiagram-UO4OBE2U-BEi7KYVF.js → vennDiagram-UO4OBE2U-zS23qjv8.js} +1 -1
  58. package/dist/assets/{wardleyDiagram-VNRHLVJA-Dkybo-Yf.js → wardleyDiagram-VNRHLVJA-52jgeKxz.js} +1 -1
  59. package/dist/assets/{xychartDiagram-PMCCYNJV-BAPFJLpg.js → xychartDiagram-PMCCYNJV-DSdl9rQ8.js} +1 -1
  60. package/dist/index.html +2 -2
  61. package/dist-server/cloud-home-start.js +1 -1
  62. package/dist-server/drivers/agents-proxy.js +5 -5
  63. package/dist-server/index.js +2379 -1596
  64. package/dist-server/openmausbot.js +857 -1012
  65. package/dist-server/pair-cli.js +857 -1012
  66. package/dist-server/permission-proxy.js +0 -4
  67. package/dist-server/server/auto-approve.js +1 -1
  68. package/dist-server/server/auto-vm-claims.js +13 -1
  69. package/dist-server/server/automatic-recovery.js +1 -2
  70. package/dist-server/server/boat.js +68 -84
  71. package/dist-server/server/bot-overview.js +1 -1
  72. package/dist-server/server/browser-engine.js +38 -1
  73. package/dist-server/server/browser-live.js +112 -25
  74. package/dist-server/server/browser-runtime.js +31 -1
  75. package/dist-server/server/checkpoints.js +275 -44
  76. package/dist-server/server/cli-setup.js +3 -3
  77. package/dist-server/server/cloud-computer-tools.js +11 -4
  78. package/dist-server/server/cloud-home-start.js +1 -1
  79. package/dist-server/server/cloud-home.js +3 -9
  80. package/dist-server/server/cloud-owner.js +1 -1
  81. package/dist-server/server/computer-engine-removal.js +70 -0
  82. package/dist-server/server/computer-selection.js +18 -0
  83. package/dist-server/server/config.js +7 -11
  84. package/dist-server/server/connector-scope-hint.js +83 -0
  85. package/dist-server/server/default-model-selection.js +20 -14
  86. package/dist-server/server/delegations.js +11 -5
  87. package/dist-server/server/delta-context.js +6 -1
  88. package/dist-server/server/drivers/acp/core.js +1 -1
  89. package/dist-server/server/drivers/acp/opencode-go.js +16 -21
  90. package/dist-server/server/drivers/agents-call.js +1 -1
  91. package/dist-server/server/drivers/agents-catalog.js +3 -3
  92. package/dist-server/server/drivers/builtIn.js +0 -2
  93. package/dist-server/server/drivers/claude.js +49 -30
  94. package/dist-server/server/drivers/codex.js +2 -2
  95. package/dist-server/server/drivers/openai-chat.js +98 -6
  96. package/dist-server/server/drivers/pi.js +184 -49
  97. package/dist-server/server/index.js +555 -279
  98. package/dist-server/server/live-call.js +11 -6
  99. package/dist-server/server/managed-policy.js +1 -1
  100. package/dist-server/server/model-catalog/presets.js +8 -0
  101. package/dist-server/server/peer-roster.js +10 -2
  102. package/dist-server/server/room-turn-end.js +15 -0
  103. package/dist-server/server/routes/live.js +3 -3
  104. package/dist-server/server/routine-requests.js +1 -1
  105. package/dist-server/server/routines.js +1 -1
  106. package/dist-server/server/screen-frame-gate.js +1 -3
  107. package/dist-server/server/store.js +125 -1
  108. package/dist-server/server/surface.js +29 -49
  109. package/dist-server/server/system-prompt.js +10 -10
  110. package/dist-server/server/turn-continuation.js +162 -0
  111. package/dist-server/server/workspace.js +1 -1
  112. package/dist-server/shared/ask-question.js +0 -70
  113. package/dist-server/shared/cloud-computer.js +4 -6
  114. package/dist-server/shared/credential-request.js +1 -1
  115. package/dist-server/shared/failed-turn.js +1 -4
  116. package/dist-server/shared/place-view.js +409 -0
  117. package/dist-server/shared/tool-scope-support.js +1 -2
  118. package/package.json +1 -1
  119. package/dist/assets/channel-BZxwC-Gw.js +0 -1
  120. package/dist/assets/index-Du7o6Dsf.js +0 -610
  121. package/dist/assets/index-KxG4bWSr.css +0 -1
  122. package/dist/assets/swimlanesDiagram-TC7HE7FX-C7voMDle.js +0 -8
  123. package/dist-server/server/drivers/boatagent.js +0 -443
@@ -8,7 +8,6 @@ var MAX_OPTIONS = 12;
8
8
  var MAX_QUESTION_TEXT = 8e3;
9
9
  var MAX_LABEL = 120;
10
10
  var MAX_DESCRIPTION = 400;
11
- var MAX_CUSTOM_ANSWER = 2e3;
12
11
  function text(value, limit) {
13
12
  if (typeof value !== "string") return void 0;
14
13
  const trimmed = value.trim();
@@ -60,9 +59,6 @@ function parseAskQuestions(input) {
60
59
  }
61
60
  return questions.length ? questions : null;
62
61
  }
63
- var OMB_ASK_FENCE = /(^|\n)[ \t]{0,3}(`{3,}|~{3,})[ \t]*omb-ask[ \t]*\r?\n([\s\S]*?)\r?\n[ \t]{0,3}\2[ \t]*(?=\r?\n|$)/;
64
- var OMB_ASK_FENCE_GLOBAL = new RegExp(OMB_ASK_FENCE.source, OMB_ASK_FENCE.flags + "g");
65
- var MAX_ANSWER_ECHO = 6 * MAX_CUSTOM_ANSWER;
66
62
  function questionAnswersByQuestion(message, questions) {
67
63
  return questionAnswersById(message, questions.map((question) => ({ id: question.question, question })));
68
64
  }
@@ -79,7 +79,7 @@ export function delegatedApprovalMode(input) {
79
79
  // the permission path in permission-proxy). Approving it there does not
80
80
  // produce an answer: the CLI runs the tool with none and the model is told
81
81
  // "The user did not answer the questions." — a question silently lost.
82
- const ASKS_A_PERSON = new Set(["askuserquestion", "ask_user", "omb-ask"]);
82
+ const ASKS_A_PERSON = new Set(["askuserquestion", "ask_user"]);
83
83
  // A web search is a low-level read. Approve for me allows these names and
84
84
  // nothing wider: a bare search, a page fetch, and every other tool stay a
85
85
  // prompt. The name is the same shape as a question — one mcp__<server>__
@@ -18,6 +18,18 @@ export function startAutoVmClaim(table, threadId, generation) {
18
18
  slot.begin = slot.claim().then(() => { slot.claimed = true; }, (error) => {
19
19
  slot.failed = true;
20
20
  slot.failure = error instanceof Error ? error.message : String(error);
21
- slot.onRejected?.(slot.failure);
21
+ slot.onRejected?.(slot.failure, error);
22
22
  });
23
23
  }
24
+ /** How long a computer call should wait on its thread's lazy claim, or null
25
+ * when it should not wait: the first call waits while the claim it fires
26
+ * lands; a slow claim (graceMs) is waited on by every call until it settles. */
27
+ export function lazyClaimWaitMs(slot, defaultGraceMs) {
28
+ if (!slot?.lazy)
29
+ return null;
30
+ if (!slot.begin)
31
+ return slot.graceMs ?? defaultGraceMs;
32
+ if (slot.graceMs !== undefined && !slot.claimed && !slot.failed)
33
+ return slot.graceMs;
34
+ return null;
35
+ }
@@ -3,8 +3,7 @@ import { supportsWorkspaceFiles } from "./workspace.js";
3
3
  * its filesystem to another machine. Approval and organisation policy are
4
4
  * checked by the ordinary model-switch and turn-admission gates. */
5
5
  export function recoveryCapabilityError(from, to) {
6
- if (from.capabilities.remoteAgent || to.capabilities.remoteAgent ||
7
- supportsWorkspaceFiles(from.driverKind) !== supportsWorkspaceFiles(to.driverKind)) {
6
+ if (supportsWorkspaceFiles(from.driverKind) !== supportsWorkspaceFiles(to.driverKind)) {
8
7
  return "The backup cannot use the same workspace.";
9
8
  }
10
9
  const tools = ["agentsMcp", "computerMcp", "composioMcp",
@@ -86,13 +86,12 @@ function scopedBoatPrefix() {
86
86
  scopedBoatPrefixCache = `ogb-${scope}-`;
87
87
  return scopedBoatPrefixCache;
88
88
  }
89
- /** Decide lifecycle work before a turn mounts Boat. Auto may observe and
90
- * attach an already-ready Boat, but only explicit Cloud may create or wake. */
91
- export function boatTurnLifecycleAction({ explicitCloud, state, }) {
89
+ /** Decide lifecycle work before a turn mounts Boat. Only a turn whose place
90
+ * is Cloud gets here (Auto never reads the Boat account), so a missing Boat
91
+ * is created and a sleeping one woken. */
92
+ export function boatTurnLifecycleAction(state) {
92
93
  if (state && READY.has(state))
93
94
  return "attach";
94
- if (!explicitCloud)
95
- return "none";
96
95
  return state ? "wake" : "provision";
97
96
  }
98
97
  /** Keep one provider account for the whole logical operation. Settings may
@@ -346,36 +345,46 @@ async function mintDesktopUrl(cfg, boxId, { vncBudgetMs = 60_000 } = {}) {
346
345
  }
347
346
  async function waitReady(cfg, boxId, budgetMs = 90_000) {
348
347
  assertBoatNotDeleting(boxId);
349
- const t0 = Date.now();
348
+ const deadline = Date.now() + budgetMs;
349
+ // Every request ends with the budget: a relay that accepts the connection
350
+ // and then stalls must not hold a turn's start past it.
351
+ const untilDeadline = () => AbortSignal.timeout(Math.max(1, deadline - Date.now()));
352
+ const outOfTime = (error) => error instanceof Error && error.name === "TimeoutError";
350
353
  // Boat's words for the last failed resume, if the wait runs out on them.
351
354
  let resumeFailure = null;
352
- while (Date.now() - t0 < budgetMs) {
353
- assertBoatNotDeleting(boxId);
354
- const { body } = await boatJson(cfg, `/boxes/${boxId}`);
355
- const state = body?.box?.state;
356
- if (READY.has(state))
357
- return body.box;
358
- if (state === "error")
359
- return null;
360
- // an archiving boat can't resume until the snapshot lands — nudge after.
361
- // A refusal (a plan limit, say) is final: report it now. A server error
362
- // is retried on the next poll, as Boat asks; 409 is a state race with a
363
- // wake already under way.
364
- if (state === "archived") {
365
- const resumed = await boatJson(cfg, `/boxes/${boxId}/resume`, { method: "POST" });
366
- if (resumed.ok)
367
- resumeFailure = null;
368
- else if (resumed.status !== 409) {
369
- const message = boatErrorMessage(resumed.status, "waking the cloud computer", resumed.body, usesIncludedBoat(cfg));
370
- if (resumed.status < 500)
371
- throw new Error(message);
372
- resumeFailure = message;
355
+ try {
356
+ while (Date.now() < deadline) {
357
+ assertBoatNotDeleting(boxId);
358
+ const { body } = await boatJson(cfg, `/boxes/${boxId}`, { signal: untilDeadline() });
359
+ const state = body?.box?.state;
360
+ if (READY.has(state))
361
+ return body.box;
362
+ if (state === "error")
363
+ return null;
364
+ // an archiving boat can't resume until the snapshot lands — nudge after.
365
+ // A refusal (a plan limit, say) is final: report it now. A server error
366
+ // is retried on the next poll, as Boat asks; 409 is a state race with a
367
+ // wake already under way.
368
+ if (state === "archived") {
369
+ const resumed = await boatJson(cfg, `/boxes/${boxId}/resume`, { method: "POST", signal: untilDeadline() });
370
+ if (resumed.ok)
371
+ resumeFailure = null;
372
+ else if (resumed.status !== 409) {
373
+ const refusal = boatRefusal(resumed.status, "waking the cloud computer", resumed.body, usesIncludedBoat(cfg));
374
+ if (resumed.status < 500)
375
+ throw refusal;
376
+ resumeFailure = refusal;
377
+ }
373
378
  }
379
+ await new Promise((r) => setTimeout(r, Math.min(2500, Math.max(0, deadline - Date.now()))));
374
380
  }
375
- await new Promise((r) => setTimeout(r, 2500));
381
+ }
382
+ catch (error) {
383
+ if (!outOfTime(error))
384
+ throw error;
376
385
  }
377
386
  if (resumeFailure)
378
- throw new Error(resumeFailure);
387
+ throw resumeFailure;
379
388
  return null;
380
389
  }
381
390
  // Resolving a bot's boat means LISTing every boat in the account, so it is
@@ -948,6 +957,17 @@ export function boatErrorMessage(status, what, body, included = false) {
948
957
  }
949
958
  return theirs ? `${what} failed: ${theirs}` : `${what} failed (${status})`;
950
959
  }
960
+ /** A refused start as an error that keeps the provider's status and code
961
+ * (the Admin's own, such as subscription_inactive), so a failed place is
962
+ * read from the code first and from the words only until every refusal
963
+ * has one (shared/place-view.ts cloudRefusal). Named apart from `status`,
964
+ * which a route would answer with. */
965
+ export function boatRefusal(status, what, body, included = false) {
966
+ const code = body?.error?.code ?? body?.code;
967
+ return Object.assign(new Error(boatErrorMessage(status, what, body, included)), {
968
+ boatStatus: status, ...(typeof code === "string" && /^[a-z0-9_]{1,64}$/.test(code) ? { boatCode: code } : {}),
969
+ });
970
+ }
951
971
  /** boat.dev trial accounts reject the normal eight-hour auto-stop with a
952
972
  * structured `trial_auto_stop_required` refusal. Retry that one condition
953
973
  * once at the provider's advertised maximum (or the documented two-hour
@@ -967,44 +987,13 @@ function idempotentCreateInProgress(result) {
967
987
  const code = result.body?.error?.code ?? result.body?.code;
968
988
  return result.status === 409 && code === "idempotency_in_progress";
969
989
  }
970
- /** The keys this OpenMausBot already holds, as the environment its bots'
971
- * agents read on the boat. The boat is created with `noEnv: true`, so the
972
- * boat.dev account's own logins never land in the guest: the boat has exactly
973
- * these and nothing else (see "Whose keys" in the Boat integrated-agents docs). */
974
- export function boatCredentialEnv(cfg, env = process.env) {
975
- const out = {};
976
- const put = (name, value) => {
977
- if (typeof value === "string" && value.trim())
978
- out[name] = value.trim();
979
- };
980
- // The workspace key only: an ANTHROPIC_API_KEY in the server's own env is
981
- // never the workspace key (see loadConfig), so it is not forwarded either.
982
- put("ANTHROPIC_API_KEY", cfg.anthropic?.key);
983
- for (const name of BOAT_FORWARDED_CREDENTIAL_ENV)
984
- put(name, env[name]);
985
- return out;
986
- }
987
- /** Names the boat's agents read (Claude Code, Codex, pi, OpenCode, Prime
988
- * Agent, Kimi), forwarded verbatim from this server's environment when set. */
989
- const BOAT_FORWARDED_CREDENTIAL_ENV = [
990
- "CLAUDE_CODE_OAUTH_TOKEN",
991
- "OPENAI_API_KEY",
992
- "OPENROUTER_API_KEY",
993
- "LLMGATEWAY_API_KEY",
994
- "DEEPSEEK_API_KEY",
995
- "MOONSHOT_API_KEY",
996
- "KIMI_CODE_ACCESS_TOKEN",
997
- "KIMI_CODE_REFRESH_TOKEN",
998
- ];
999
- async function requestBoatCreate(cfg, botId, ttlSeconds, env) {
1000
- // The computer needs the user's desktop session, not the account owner's
1001
- // host credentials. Keep provider-side env injection off; the only keys the
1002
- // guest ever has are the ones this OpenMausBot forwards (`env`), which its
1003
- // agents need now that the turn runs on the boat. The idempotency identity
1004
- // stays the secret-free part: a trial-TTL retry must receive a different
1005
- // key, and the journal on disk never carries a credential.
990
+ async function requestBoatCreate(cfg, botId, ttlSeconds) {
991
+ // The computer is a desktop the bot's own engine drives from here, so it
992
+ // needs no AI sign-in of its own: provider-side env injection stays off and
993
+ // no key this OpenMausBot holds is ever sent to it. A trial-TTL retry must
994
+ // receive a different idempotency key, and the journal on disk never
995
+ // carries a credential.
1006
996
  const body = JSON.stringify({ ttlSeconds, noEnv: true });
1007
- const wireBody = JSON.stringify({ ttlSeconds, noEnv: true, ...(Object.keys(env).length ? { env } : {}) });
1008
997
  let attempt = beginBoatCreate(botId, body);
1009
998
  let request = attempt.request;
1010
999
  let createdThisAttempt = attempt.startedNow;
@@ -1034,7 +1023,7 @@ async function requestBoatCreate(cfg, botId, ttlSeconds, env) {
1034
1023
  method: "POST",
1035
1024
  headers: { "Idempotency-Key": request.idempotencyKey },
1036
1025
  signal: AbortSignal.timeout(45_000),
1037
- body: wireBody,
1026
+ body,
1038
1027
  });
1039
1028
  }
1040
1029
  catch (error) {
@@ -1067,12 +1056,12 @@ async function requestBoatCreate(cfg, botId, ttlSeconds, env) {
1067
1056
  return { ...last, request, createdThisAttempt };
1068
1057
  }
1069
1058
  }
1070
- async function createBoat(cfg, botId, env) {
1071
- const first = await requestBoatCreate(cfg, botId, DEFAULT_BOAT_TTL_SECONDS, env);
1059
+ async function createBoat(cfg, botId) {
1060
+ const first = await requestBoatCreate(cfg, botId, DEFAULT_BOAT_TTL_SECONDS);
1072
1061
  if (first.ok)
1073
1062
  return first;
1074
1063
  const trialTtl = trialBoatTtlSeconds(first.body);
1075
- return trialTtl === null ? first : requestBoatCreate(cfg, botId, trialTtl, env);
1064
+ return trialTtl === null ? first : requestBoatCreate(cfg, botId, trialTtl);
1076
1065
  }
1077
1066
  /** A prior explicit delete always wins over provisioning. Reconcile/retry the
1078
1067
  * old immutable target, then require a fresh provision request so one click
@@ -1111,10 +1100,9 @@ export async function boatStatus(cfg, botId) {
1111
1100
  }
1112
1101
  /**
1113
1102
  * Find-or-create the bot's persistent boat, wait for ready, and mint a fresh
1114
- * desktop URL. The boat ships its own computer-use driver and agent runner.
1103
+ * desktop URL. The boat ships its own computer-use driver.
1115
1104
  */
1116
1105
  export async function provisionBoat(cfg, botId, _botName) {
1117
- const credentialEnv = boatCredentialEnv(cfg);
1118
1106
  cfg = snapshotBoatConfig(cfg);
1119
1107
  if (!boatConfigured(cfg)) {
1120
1108
  throw new Error('box provider not enabled — add {"box":{"token":"…"}} to ~/.openmausbot/config.json');
@@ -1132,9 +1120,9 @@ export async function provisionBoat(cfg, botId, _botName) {
1132
1120
  // Provider-side backstop: archives itself (billing pauses, disk
1133
1121
  // survives) if every stop path dies. Trial accounts get one narrower
1134
1122
  // retry when boat.dev reports their shorter TTL ceiling.
1135
- const createRes = await createBoat(cfg, botId, credentialEnv);
1123
+ const createRes = await createBoat(cfg, botId);
1136
1124
  if (!createRes.ok || !createRes.body?.box?.id) {
1137
- throw new Error(boatErrorMessage(createRes.status, "boat create", createRes.body, usesIncludedBoat(cfg)));
1125
+ throw boatRefusal(createRes.status, "boat create", createRes.body, usesIncludedBoat(cfg));
1138
1126
  }
1139
1127
  boat = createRes.body.box;
1140
1128
  createRequest = createRes.request;
@@ -1151,8 +1139,7 @@ export async function provisionBoat(cfg, botId, _botName) {
1151
1139
  const ready = await waitReady(cfg, boat.id);
1152
1140
  if (!ready)
1153
1141
  throw new Error("box did not become ready within 90s — retry in a minute");
1154
- // Nothing to install: every boat ships its own computer-use driver and
1155
- // registers it with every harness it runs.
1142
+ // Nothing to install: every boat ships its own computer-use driver.
1156
1143
  const joinUrl = await mintDesktopUrl(cfg, boat.id);
1157
1144
  if (!joinUrl)
1158
1145
  throw new Error("box desktop link could not be created");
@@ -1249,14 +1236,11 @@ export async function execOnBoat(cfg, botId, command) {
1249
1236
  //
1250
1237
  // The frame is for a person: it fills the panel and opens in the chat's
1251
1238
  // image viewer, so it keeps the desktop's native size up to 1080p and a
1252
- // quality where page text stays legible. (Sizing it is now the only say
1253
- // OpenMausBot has over any frame off this box: the turn runs on the boat's
1254
- // own agent, so the model's own captures never pass through here.) Only
1255
- // wider displays are scaled down, with -resize rather than -thumbnail so
1256
- // the resample is not the fast-and-blurry kind meant for icons. The
1257
- // pointer is drawn into the frame (scrot --pointer, ffmpeg -draw_mouse):
1258
- // watching the bot work means seeing where its cursor is, and X11
1259
- // captures leave it out by default.
1239
+ // quality where page text stays legible. Only wider displays are scaled
1240
+ // down, with -resize rather than -thumbnail so the resample is not the
1241
+ // fast-and-blurry kind meant for icons. The pointer is drawn into the frame
1242
+ // (scrot --pointer, ffmpeg -draw_mouse): watching the bot work means seeing
1243
+ // where its cursor is, and X11 captures leave it out by default.
1260
1244
  const PANEL_PATH = "/tmp/ogb-panel.jpg";
1261
1245
  export const PANEL_FRAME_WIDTH = 1920;
1262
1246
  export const PANEL_FRAME_QUALITY = 85;
@@ -147,7 +147,7 @@ export function grantsSummary(connectorTools) {
147
147
  function computerReach(computer, cloudHome = false) {
148
148
  // A Cloud home never offers either; say so rather than list a preference
149
149
  // that every task there refuses.
150
- const unavailable = cloudHome ? ", which isn't available on OMB Cloud" : "";
150
+ const unavailable = cloudHome ? ", which isn't available on My Cloud" : "";
151
151
  switch (computer) {
152
152
  case "cloud":
153
153
  return "Computer preference: cloud computer.";
@@ -16,7 +16,7 @@ import { delimiter, dirname, join, resolve } from "node:path";
16
16
  import { writeFileAtomic } from "./atomic.js";
17
17
  import { DATA_DIR } from "./config.js";
18
18
  import { browserBundlePaths } from "./browser-bundle-release.js";
19
- import { browserRuntimeEnv } from "./browser-runtime.js";
19
+ import { BROWSER_VIEWPORT_ARGS, browserRuntimeEnv, ownsBrowserViewport } from "./browser-runtime.js";
20
20
  import { SIGN_IN_PROMPT } from "./system-prompt.js";
21
21
  import { AGENT_BROWSER_VERSION, agentBrowserReleaseUrl, agentBrowserReleaseVersion, resolveAgentBrowserReleaseAsset, } from "./browser-engine-release.js";
22
22
  const ENGINE_DIR = "tools/agent-browser";
@@ -467,6 +467,43 @@ export function agentBrowserIntegration(input) {
467
467
  }
468
468
  return { command: input.binaryPath, args: ["mcp", "--tools", "core", "--no-webmcp"], env };
469
469
  }
470
+ /** Give the session's browser the standard page size, launching it with the
471
+ * session's own launch environment if it is not running yet. Best effort:
472
+ * false (and the page keeps whatever size it had) on any failure. */
473
+ export function setBrowserViewport(binaryPath, env, timeoutMs = 30_000) {
474
+ if (!ownsBrowserViewport(env))
475
+ return Promise.resolve(true);
476
+ return new Promise((settle) => {
477
+ let child;
478
+ try {
479
+ child = spawn(binaryPath, [...BROWSER_VIEWPORT_ARGS, "--json", "--no-webmcp"], { env: browserRuntimeEnv(env), stdio: ["ignore", "pipe", "ignore"], windowsHide: true });
480
+ }
481
+ catch {
482
+ settle(false);
483
+ return;
484
+ }
485
+ let output = "";
486
+ let settled = false;
487
+ const finish = (ok) => { if (!settled) {
488
+ settled = true;
489
+ clearTimeout(timer);
490
+ settle(ok);
491
+ } };
492
+ const timer = setTimeout(() => { child.kill("SIGKILL"); finish(false); }, timeoutMs);
493
+ timer.unref?.();
494
+ child.stdout?.on("data", (chunk) => { if (output.length < 65_536)
495
+ output += String(chunk); });
496
+ child.on("error", () => finish(false));
497
+ child.on("close", (code) => {
498
+ try {
499
+ finish(code === 0 && JSON.parse(output)?.success === true);
500
+ }
501
+ catch {
502
+ finish(false);
503
+ }
504
+ });
505
+ });
506
+ }
470
507
  /** How long a settled-frame capture may take before the turn gives up on it.
471
508
  * The poller runs beside a live turn, so a hung browser must not hold the
472
509
  * transcript open; a missing picture is better than a stuck fold. */
@@ -1,12 +1,22 @@
1
1
  import { execFile } from "node:child_process";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { promisify } from "node:util";
4
- import { browserRuntimeEnv } from "./browser-runtime.js";
4
+ import { BROWSER_VIEWPORT_ARGS, browserRuntimeEnv, ownsBrowserViewport } from "./browser-runtime.js";
5
5
  import { closeBrowserSession } from "./browser-engine.js";
6
6
  const execute = promisify(execFile);
7
7
  const MAX_FRAME = 3 * 1024 * 1024;
8
8
  const MAX_BUFFER = 4 * 1024 * 1024;
9
9
  const HEARTBEAT_MS = 10_000;
10
+ const COMMAND_TIMEOUT_MS = 30_000;
11
+ const VIEWPORT_TIMEOUT_MS = 5_000;
12
+ // Opening a view while the bot's own command holds the session: each stream
13
+ // probe waits up to STATUS_PROBE_MS (it may also have to launch the browser),
14
+ // then the view shows that it is waiting and probes again with a bounded
15
+ // backoff for as long as the viewer stays, up to a limit. A probe that is
16
+ // waiting in line answers as soon as the bot's command finishes.
17
+ const STATUS_PROBE_MS = 10_000;
18
+ const BUSY_RETRY_MS = [1_000, 2_000, 5_000];
19
+ const BUSY_LIMIT_MS = 10 * 60_000;
10
20
  // The native press resolver supplies the virtual key codes and Enter/Tab text
11
21
  // that its raw input_keyboard relay omits. Keep unknown keys literal.
12
22
  const DISCRETE_KEYS = new Set(["Backspace", "Enter", "Tab", "Escape", "Delete", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Home", "End", "PageUp", "PageDown"]);
@@ -17,6 +27,20 @@ export class BrowserLiveError extends Error {
17
27
  status;
18
28
  constructor(message, status = 400) { super(message); this.name = "BrowserLiveError"; this.status = status; }
19
29
  }
30
+ /** The engine is there but did not answer in time: another command, usually
31
+ * the bot's own, holds the same browser session. Not a missing engine. */
32
+ export class BrowserBusyError extends BrowserLiveError {
33
+ constructor(message = "The browser is busy with another action and did not answer in time. Try again shortly.") {
34
+ super(message, 503);
35
+ this.name = "BrowserBusyError";
36
+ }
37
+ }
38
+ /** execFile's own timeout: it killed a command that had not exited, as
39
+ * opposed to a missing binary, a failed command, an abort or an overflow. */
40
+ function timedOut(error) {
41
+ const failure = error;
42
+ return failure?.killed === true && failure.signal === "SIGKILL" && failure.code == null;
43
+ }
20
44
  function object(value) {
21
45
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
22
46
  }
@@ -183,6 +207,8 @@ export class BrowserLive {
183
207
  }
184
208
  if (!viewer.res.headersSent)
185
209
  return; // A peer can change control while this viewer is still starting.
210
+ if (viewer.waiting && message.type !== "waiting" && message.type !== "error")
211
+ return;
186
212
  if (viewer.res.writableLength > MAX_BUFFER) {
187
213
  this.close(viewer);
188
214
  return;
@@ -279,6 +305,7 @@ export class BrowserLive {
279
305
  if (viewer.closed)
280
306
  return;
281
307
  viewer.closed = true;
308
+ viewer.abort.abort();
282
309
  this.viewers.delete(viewer.id);
283
310
  clearTimeout(viewer.heartbeat);
284
311
  clearTimeout(viewer.drainTimer);
@@ -303,13 +330,14 @@ export class BrowserLive {
303
330
  if (viewer.pressedKeys.size || viewer.pressedButtons.size)
304
331
  this.runtime.abandonHumanInput(viewer.session, viewer.id);
305
332
  }
306
- async command(viewer, args) {
333
+ async command(viewer, args, timeout = COMMAND_TIMEOUT_MS) {
307
334
  if (!this.current(viewer))
308
335
  throw new BrowserLiveError("This browser view is no longer available.", 409);
309
336
  const env = browserRuntimeEnv({ ...viewer.spec.env, AGENT_BROWSER_SESSION: viewer.session });
310
337
  try {
311
338
  const { stdout } = await execute(viewer.spec.command, [...args, "--json", "--no-webmcp"], {
312
- env, timeout: 30_000, killSignal: "SIGKILL", maxBuffer: 1024 * 1024, encoding: "utf8", windowsHide: true,
339
+ env, timeout, killSignal: "SIGKILL", maxBuffer: 1024 * 1024, encoding: "utf8", windowsHide: true,
340
+ signal: viewer.abort.signal,
313
341
  });
314
342
  if (!this.current(viewer))
315
343
  throw new Error("stale viewer");
@@ -324,6 +352,8 @@ export class BrowserLive {
324
352
  return data;
325
353
  }
326
354
  catch (error) {
355
+ if (timedOut(error))
356
+ throw new BrowserBusyError();
327
357
  console.warn("browser-live:", error);
328
358
  if (browserLaunchFailure(error)) {
329
359
  // The daemon is alive but holding a launch configuration Chrome
@@ -349,6 +379,73 @@ export class BrowserLive {
349
379
  throw new BrowserLiveError("The browser could not complete this action. Check that the browser engine is installed, then reconnect.", 503);
350
380
  }
351
381
  }
382
+ /** Find (or start) the session's stream and make sure its browser runs. */
383
+ async connect(viewer) {
384
+ // A failed launch already started this session's daemon teardown; wait
385
+ // for it so the status probe meets a fresh daemon, not the stuck one.
386
+ // Checked on every attempt: a reset can start while the view waits.
387
+ const resetting = this.sessionResets.get(viewer.session);
388
+ if (resetting)
389
+ await resetting;
390
+ let status = await this.command(viewer, ["stream", "status"], STATUS_PROBE_MS);
391
+ if (status.enabled !== true) {
392
+ try {
393
+ status = await this.command(viewer, ["stream", "enable"]);
394
+ }
395
+ catch (error) {
396
+ if (error instanceof BrowserBusyError)
397
+ throw error;
398
+ status = await this.command(viewer, ["stream", "status"]); // Another view may have enabled the same session.
399
+ }
400
+ }
401
+ const port = browserStreamPort(status);
402
+ // `open` without a URL is an idempotent launch, never navigation away from the bot's page.
403
+ if (status.connected !== true)
404
+ await this.command(viewer, ["open"]);
405
+ // The status probe itself may have launched the browser. Give its page the
406
+ // standard size, as the bot's runtime does, so the page, the frames and
407
+ // the clicks share one geometry; at that size this changes nothing. Best
408
+ // effort and brief: a failure or a busy session keeps the current size.
409
+ if (ownsBrowserViewport(viewer.spec.env ?? {})) {
410
+ await this.command(viewer, [...BROWSER_VIEWPORT_ARGS], VIEWPORT_TIMEOUT_MS).catch(() => undefined);
411
+ }
412
+ return port;
413
+ }
414
+ /** While another command holds the session, keep the view open and waiting
415
+ * instead of failing it: start the event stream, say so, and retry with a
416
+ * bounded backoff until the browser answers, the viewer leaves, or the
417
+ * limit passes. */
418
+ async connectWhenFree(viewer) {
419
+ const deadline = Date.now() + BUSY_LIMIT_MS;
420
+ for (let attempt = 0;; attempt++) {
421
+ try {
422
+ return await this.connect(viewer);
423
+ }
424
+ catch (error) {
425
+ if (!(error instanceof BrowserBusyError) || !this.current(viewer))
426
+ throw error;
427
+ if (Date.now() >= deadline)
428
+ throw new BrowserBusyError("The bot is still using this browser. Reconnect when it has finished.");
429
+ }
430
+ viewer.waiting = true;
431
+ this.startEvents(viewer);
432
+ this.send(viewer, { type: "waiting", reason: "busy" });
433
+ await new Promise((resolve) => {
434
+ const done = () => { clearTimeout(timer); viewer.abort.signal.removeEventListener("abort", done); resolve(); };
435
+ const timer = setTimeout(done, BUSY_RETRY_MS[Math.min(attempt, BUSY_RETRY_MS.length - 1)]);
436
+ timer.unref?.();
437
+ viewer.abort.signal.addEventListener("abort", done, { once: true });
438
+ });
439
+ if (!this.current(viewer))
440
+ throw new BrowserLiveError("This browser view is no longer available.", 409);
441
+ }
442
+ }
443
+ startEvents(viewer) {
444
+ if (viewer.res.headersSent)
445
+ return;
446
+ viewer.res.writeHead(200, { "Content-Type": "text/event-stream", "Cache-Control": "no-store", "X-Accel-Buffering": "no", Connection: "keep-alive" });
447
+ viewer.res.flushHeaders();
448
+ }
352
449
  async input(viewer, message) {
353
450
  if (!viewer.port)
354
451
  throw new BrowserLiveError("The browser stream is not connected.", 409);
@@ -415,36 +512,23 @@ export class BrowserLive {
415
512
  if (this.viewers.size >= 8 || [...this.viewers.values()].filter((v) => v.session === options.session).length >= 2) {
416
513
  throw new BrowserLiveError("Too many browser views are open. Close another browser panel first.", 429);
417
514
  }
418
- const viewer = { ...options, id: randomUUID(), closed: false, blocked: false, pendingActions: 0, restarting: false, pressedKeys: new Set(), pressedButtons: new Set() };
515
+ const viewer = { ...options, id: randomUUID(), closed: false, blocked: false, pendingActions: 0, restarting: false, pressedKeys: new Set(), pressedButtons: new Set(), waiting: false, abort: new AbortController() };
419
516
  if (!this.current(viewer))
420
517
  throw new BrowserLiveError("This browser view is no longer available.", 409);
421
518
  this.viewers.set(viewer.id, viewer);
422
519
  options.res.once("close", () => this.close(viewer));
423
520
  options.res.once("error", () => this.close(viewer));
424
521
  try {
425
- // A failed launch already started this session's daemon teardown; wait
426
- // for it so the status probe meets a fresh daemon, not the stuck one.
427
- const resetting = this.sessionResets.get(viewer.session);
428
- if (resetting)
429
- await resetting;
430
- let status = await this.command(viewer, ["stream", "status"]);
431
- if (status.enabled !== true) {
432
- try {
433
- status = await this.command(viewer, ["stream", "enable"]);
434
- }
435
- catch {
436
- status = await this.command(viewer, ["stream", "status"]);
437
- } // Another view may have enabled the same session.
438
- }
439
- const port = browserStreamPort(status);
522
+ const port = await this.connectWhenFree(viewer);
523
+ // Best-effort steps of the startup swallow their own failures, an abort
524
+ // by close() included; a viewer closed meanwhile gets no socket.
525
+ if (!this.current(viewer))
526
+ throw new BrowserLiveError("This browser view is no longer available.", 409);
440
527
  viewer.port = port;
441
- // `open` without a URL is an idempotent launch, never navigation away from the bot's page.
442
- if (status.connected !== true)
443
- await this.command(viewer, ["open"]);
444
528
  const socket = new WebSocket(`ws://127.0.0.1:${port}/?pacing=ack&maxFps=15`);
445
529
  viewer.socket = socket;
446
- options.res.writeHead(200, { "Content-Type": "text/event-stream", "Cache-Control": "no-store", "X-Accel-Buffering": "no", Connection: "keep-alive" });
447
- options.res.flushHeaders();
530
+ this.startEvents(viewer);
531
+ viewer.waiting = false;
448
532
  this.send(viewer, { type: "ready", viewerId: viewer.id });
449
533
  this.control(viewer.session);
450
534
  socket.addEventListener("message", (event) => {
@@ -511,7 +595,10 @@ export class BrowserLive {
511
595
  catch (error) {
512
596
  console.warn("browser-live:", error);
513
597
  if (options.res.headersSent) {
514
- this.send(viewer, { type: "error", retryable: true, message: "The browser stream could not start." });
598
+ // A view that waited out a busy browser gets the reason, and no
599
+ // automatic retry loop on top of the wait it already did.
600
+ const busy = error instanceof BrowserBusyError;
601
+ this.send(viewer, { type: "error", retryable: !busy, message: busy ? error.message : "The browser stream could not start." });
515
602
  this.close(viewer);
516
603
  return;
517
604
  }
@@ -23,6 +23,24 @@ export function browserRuntimeEnv(overrides) {
23
23
  const env = Object.fromEntries(HOST_ENV.flatMap((key) => process.env[key] === undefined ? [] : [[key, process.env[key]]]));
24
24
  return { ...env, ...overrides };
25
25
  }
26
+ /** The page size of a headless browser OMB launches, in CSS pixels.
27
+ *
28
+ * agent-browser sizes the Chrome *window* (`--window-size=1280,720`). Full
29
+ * Chrome in headless mode (Chrome for Testing, as the Docker image installs)
30
+ * takes its emulated browser UI out of that window, so the page itself comes
31
+ * out 1280×577 while the screencast metadata still reports 1280×720, and the
32
+ * live view aimed clicks at the wrong place. chrome-headless-shell has no such
33
+ * UI, so there this changes nothing. agent-browser has no launch option for
34
+ * the page size; `set viewport` sets it and resizes the window's content area,
35
+ * which the browser's later tabs inherit. */
36
+ export const BROWSER_VIEWPORT = { width: 1280, height: 720 };
37
+ export const BROWSER_VIEWPORT_ARGS = ["set", "viewport", String(BROWSER_VIEWPORT.width), String(BROWSER_VIEWPORT.height)];
38
+ /** Only a headless browser this server launches is OMB's to size. A browser
39
+ * attached over CDP is someone's own Chrome, and a headed window is the
40
+ * user's to size. */
41
+ export function ownsBrowserViewport(env) {
42
+ return env.AGENT_BROWSER_HEADLESS === "1" && !env.AGENT_BROWSER_CDP;
43
+ }
26
44
  export class TransportError extends Error {
27
45
  }
28
46
  /** A server-owned JSONL client. Neither child stderr nor its environment is
@@ -215,9 +233,11 @@ export class BrowserRuntime {
215
233
  toolLists = new Map();
216
234
  options;
217
235
  closeBrowser;
218
- constructor({ closeBrowser, ...options } = {}) {
236
+ applyViewport;
237
+ constructor({ closeBrowser, applyViewport, ...options } = {}) {
219
238
  this.options = { requestTimeoutMs: 120_000, takeoverTimeoutMs: 15_000, idleMs: 60_000, maxPending: 16, resultBudget: DEFAULT_BROWSER_RESULT_BUDGET, ...options };
220
239
  this.closeBrowser = closeBrowser ?? (async () => false);
240
+ this.applyViewport = applyViewport;
221
241
  }
222
242
  gate(session) {
223
243
  let gate = this.gates.get(session);
@@ -300,6 +320,16 @@ export class BrowserRuntime {
300
320
  beforeDispatch?.();
301
321
  if (method === "tools/call" && this.gate(session).owner !== null)
302
322
  throw new Error(BROWSER_CONTROL_REFUSAL);
323
+ if (method === "tools/call" && this.applyViewport) {
324
+ // The bot's first call on a transport may launch the browser. Size its
325
+ // page first, once per transport, so the page, the bot's screenshots
326
+ // and the live view agree. Failure only leaves the engine's default.
327
+ entry.viewport ??= this.applyViewport(spec).catch(() => undefined);
328
+ await entry.viewport;
329
+ beforeDispatch?.();
330
+ if (this.gate(session).owner !== null)
331
+ throw new Error(BROWSER_CONTROL_REFUSAL);
332
+ }
303
333
  try {
304
334
  // The model sees slimmed schemas and text-only, bounded results; the
305
335
  // launch/session parameters OMB owns never reach the engine from a call.