openmausbot 0.1.91 → 0.1.92

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 (150) hide show
  1. package/dist/assets/DesktopViewer-Do6lBa4C.js +5 -0
  2. package/dist/assets/{abnfDiagram-O67JEVCF-yP-w8pRq.js → abnfDiagram-O67JEVCF-Cd3X7Hxc.js} +1 -1
  3. package/dist/assets/{arc-DsivfZEh.js → arc-DIYc7Ymx.js} +1 -1
  4. package/dist/assets/{architectureDiagram-NJMV4G6O-CILw7lzT.js → architectureDiagram-NJMV4G6O-DBmRGVyP.js} +1 -1
  5. package/dist/assets/{blockDiagram-BEXU5L5S-DEQUV3HF.js → blockDiagram-BEXU5L5S-CPFePSEE.js} +1 -1
  6. package/dist/assets/{c4Diagram-YGBWAQC7-lSXCZoKA.js → c4Diagram-YGBWAQC7-DD_DO1qy.js} +1 -1
  7. package/dist/assets/channel-Dtk5Mtic.js +1 -0
  8. package/dist/assets/{chunk-2Q5K7J3B-QCD5bgWP.js → chunk-2Q5K7J3B-BNEeNSjX.js} +1 -1
  9. package/dist/assets/{chunk-3FUC2YCW-C5-iZJuL.js → chunk-3FUC2YCW-BbinLaqH.js} +2 -2
  10. package/dist/assets/{chunk-5VM5RSS4-cxsawMpY.js → chunk-5VM5RSS4-BBgYrgDR.js} +1 -1
  11. package/dist/assets/{chunk-GTNCS2PH-DV8tV8H7.js → chunk-GTNCS2PH-ezXj-kA-.js} +1 -1
  12. package/dist/assets/{chunk-GWA4HPMP-CJFZyfbW.js → chunk-GWA4HPMP-9FxZ3diV.js} +1 -1
  13. package/dist/assets/{chunk-JWPE2WC7-BigbMXco.js → chunk-JWPE2WC7-CO-40JpI.js} +1 -1
  14. package/dist/assets/{chunk-NETBCI7D-oVxTfpDy.js → chunk-NETBCI7D-BEhjslYE.js} +1 -1
  15. package/dist/assets/{chunk-WEXAMYUT-CH4BiroW.js → chunk-WEXAMYUT-CNeq4n7_.js} +1 -1
  16. package/dist/assets/{chunk-XXDRQBXY-KEDa6gax.js → chunk-XXDRQBXY-OsCY7KSi.js} +1 -1
  17. package/dist/assets/{classDiagram-v2-NBCMYWYE-BiPjfqVv.js → classDiagram-v2-NBCMYWYE-CloRUEtk.js} +1 -1
  18. package/dist/assets/{cose-bilkent-JH36ORCC-Caxew3OY.js → cose-bilkent-JH36ORCC-D1BGZhp4.js} +1 -1
  19. package/dist/assets/{cynefin-OW5HDTMX-B_Pui369.js → cynefin-OW5HDTMX-CUf4T2CN.js} +1 -1
  20. package/dist/assets/{cynefinDiagram-VND7K2PF-X64ydIhP.js → cynefinDiagram-VND7K2PF-DPEZrFGA.js} +1 -1
  21. package/dist/assets/{dagre-6A5THRUB-TqYCI1E1.js → dagre-6A5THRUB-bDe6GIv5.js} +1 -1
  22. package/dist/assets/{diagram-22UHCM2B-TeOt3rAQ.js → diagram-22UHCM2B-CdcUQz55.js} +1 -1
  23. package/dist/assets/{diagram-3UASUU5V-D70BLhDA.js → diagram-3UASUU5V-BZpqGg7c.js} +1 -1
  24. package/dist/assets/{diagram-ATOU4E4O-BbQDLwUC.js → diagram-ATOU4E4O-DvGM6ugp.js} +1 -1
  25. package/dist/assets/{diagram-CDSNMT55-ChNJZ1u-.js → diagram-CDSNMT55-DSTmMm0s.js} +1 -1
  26. package/dist/assets/{diagram-MLGK6HIB-DMBl2APa.js → diagram-MLGK6HIB-15cucnMn.js} +1 -1
  27. package/dist/assets/{diagram-MPIPVDR6-CEqDchOp.js → diagram-MPIPVDR6-tMbuaE6n.js} +1 -1
  28. package/dist/assets/{ebnfDiagram-ZINNZB2B-BVDKRp_-.js → ebnfDiagram-ZINNZB2B-BYxYzjHI.js} +1 -1
  29. package/dist/assets/{elk-276RUBZZ-CRkofO9B.js → elk-276RUBZZ-v6bj852W.js} +1 -1
  30. package/dist/assets/{erDiagram-OPXOYQCR-DruOMh5e.js → erDiagram-OPXOYQCR-5lBBlnd2.js} +1 -1
  31. package/dist/assets/{flowDiagram-KWPJA3E3-8GMQeB7t.js → flowDiagram-KWPJA3E3-CZyl1zIj.js} +1 -1
  32. package/dist/assets/{ganttDiagram-FUAMR5RP-ORE9jcsM.js → ganttDiagram-FUAMR5RP-BiAI-ltZ.js} +1 -1
  33. package/dist/assets/{gitGraphDiagram-X574FWY7-BmsedsWh.js → gitGraphDiagram-X574FWY7-BAZISkj3.js} +1 -1
  34. package/dist/assets/index-Cdmjrl28.css +1 -0
  35. package/dist/assets/{index-DKNEM8Q6.js → index-DGBaEXrM.js} +1 -1
  36. package/dist/assets/index-DR7YPMkW.js +597 -0
  37. package/dist/assets/{infoDiagram-VRGFBTTK-E_p7AooJ.js → infoDiagram-VRGFBTTK-B6ooOy-Z.js} +1 -1
  38. package/dist/assets/{ishikawaDiagram-OU5B5YK6-Y-B2mKda.js → ishikawaDiagram-OU5B5YK6-BZ9ksi-B.js} +1 -1
  39. package/dist/assets/{journeyDiagram-ZHPQQLJL-eA8RELcK.js → journeyDiagram-ZHPQQLJL-DWqlzIEe.js} +1 -1
  40. package/dist/assets/{kanban-definition-PNTS6WVX-DqIL2e8e.js → kanban-definition-PNTS6WVX-JX6piDwL.js} +1 -1
  41. package/dist/assets/{linear-yC_29R6e.js → linear-CmOWzX0P.js} +1 -1
  42. package/dist/assets/{mermaid.core-VhEMkSND.js → mermaid.core-CF1zwoQ-.js} +5 -5
  43. package/dist/assets/{mindmap-definition-NLK3R4M7-oJ7kyQZy.js → mindmap-definition-NLK3R4M7-CGh2K4fW.js} +1 -1
  44. package/dist/assets/{pegDiagram-GJSIUBJH-BmfYcY0O.js → pegDiagram-GJSIUBJH-CDwYN0s7.js} +1 -1
  45. package/dist/assets/{pieDiagram-5QR66LMP-DKvgP7w9.js → pieDiagram-5QR66LMP-1rfjJocB.js} +1 -1
  46. package/dist/assets/{quadrantDiagram-O4NWA36T-BEKL3W0L.js → quadrantDiagram-O4NWA36T-tKPvPiok.js} +1 -1
  47. package/dist/assets/{railroadDiagram-XR7U4H2S-BEsiqR5s.js → railroadDiagram-XR7U4H2S-BHLm5vXR.js} +1 -1
  48. package/dist/assets/{requirementDiagram-PLB6GJNP-DWBcWvAP.js → requirementDiagram-PLB6GJNP-CB45STp7.js} +1 -1
  49. package/dist/assets/{sankeyDiagram-IPEJSGJF-rpZ2_O4s.js → sankeyDiagram-IPEJSGJF-55QA_huC.js} +1 -1
  50. package/dist/assets/{sequenceDiagram-PO4LG4MO-B99HQdJR.js → sequenceDiagram-PO4LG4MO-BckFmQHn.js} +1 -1
  51. package/dist/assets/{sizeCapture-INFHLROL-BjN0qT5T.js → sizeCapture-INFHLROL-BFCOJF11.js} +1 -1
  52. package/dist/assets/{stateDiagram-v2-GCMORJYK-BbsVgGsC.js → stateDiagram-v2-GCMORJYK-CZvmiVVN.js} +1 -1
  53. package/dist/assets/{swimlanes-2SLR337P-DG3gKkeR.js → swimlanes-2SLR337P-BpDUCEKy.js} +1 -1
  54. package/dist/assets/swimlanesDiagram-TC7HE7FX-M0GYW9Y3.js +8 -0
  55. package/dist/assets/{timeline-definition-EJHVYXUP-BTHOdtF_.js → timeline-definition-EJHVYXUP-BpxHq6IK.js} +1 -1
  56. package/dist/assets/{usecaseDiagram-POWQR4AR-acLSLFwc.js → usecaseDiagram-POWQR4AR-Cj66vm02.js} +1 -1
  57. package/dist/assets/{vennDiagram-UO4OBE2U-C5JzNX9G.js → vennDiagram-UO4OBE2U-C9nRkWE_.js} +1 -1
  58. package/dist/assets/{wardleyDiagram-VNRHLVJA-DL1-PrR_.js → wardleyDiagram-VNRHLVJA-D-me_nWj.js} +1 -1
  59. package/dist/assets/{xychartDiagram-PMCCYNJV-Bvr1477p.js → xychartDiagram-PMCCYNJV-Dc_fL4mk.js} +1 -1
  60. package/dist/index.html +2 -2
  61. package/dist/novnc-NOTICE.txt +118 -0
  62. package/dist-server/cloud-home-start.js +112 -14
  63. package/dist-server/container-mcp.js +195 -15
  64. package/dist-server/drivers/agents-proxy.js +5 -4
  65. package/dist-server/enterprise/server/index.js +5 -1
  66. package/dist-server/index.js +9300 -4155
  67. package/dist-server/local-computer-proxy.js +128 -7
  68. package/dist-server/mcp-gate.js +11 -5
  69. package/dist-server/model-catalog/models-dev.snapshot.json +7299 -0
  70. package/dist-server/openmausbot.js +3910 -1182
  71. package/dist-server/pair-cli.js +3910 -1182
  72. package/dist-server/server/boat.js +2 -2
  73. package/dist-server/server/browser-engine.js +10 -1
  74. package/dist-server/server/browser-live.js +46 -2
  75. package/dist-server/server/browser-runtime.js +74 -8
  76. package/dist-server/server/browser-tool-shape.js +6 -4
  77. package/dist-server/server/chief-of-staff.js +1 -1
  78. package/dist-server/server/cloud-home-start.js +118 -26
  79. package/dist-server/server/cloud-home.js +39 -3
  80. package/dist-server/server/cloud-lending.js +74 -10
  81. package/dist-server/server/cloud-owner.js +196 -0
  82. package/dist-server/server/cloud-secrets-boot.js +6 -0
  83. package/dist-server/server/cloud-secrets.js +65 -0
  84. package/dist-server/server/config.js +174 -14
  85. package/dist-server/server/container-computer.js +3 -2
  86. package/dist-server/server/desktop-viewer-targets.js +26 -0
  87. package/dist-server/server/drivers/acp/core.js +167 -21
  88. package/dist-server/server/drivers/acp/opencode-go.js +614 -85
  89. package/dist-server/server/drivers/agents-catalog.js +6 -6
  90. package/dist-server/server/drivers/antigravity-acp.js +69 -11
  91. package/dist-server/server/drivers/antigravity-temp.js +360 -0
  92. package/dist-server/server/drivers/antigravity.js +21 -0
  93. package/dist-server/server/drivers/chatgpt-plan-auth.js +481 -0
  94. package/dist-server/server/drivers/claude.js +312 -34
  95. package/dist-server/server/drivers/codex.js +228 -18
  96. package/dist-server/server/drivers/grok.js +2 -2
  97. package/dist-server/server/drivers/mistral.js +4 -3
  98. package/dist-server/server/drivers/openai-chat-protocol.js +4 -3
  99. package/dist-server/server/drivers/openai-chat.js +41 -3
  100. package/dist-server/server/drivers/openai-compat.js +73 -23
  101. package/dist-server/server/engine-install.js +46 -12
  102. package/dist-server/server/env-path.js +15 -3
  103. package/dist-server/server/harness/registry.js +2 -2
  104. package/dist-server/server/index.js +1338 -184
  105. package/dist-server/server/lending-memory.js +479 -0
  106. package/dist-server/server/local-vm-idle.js +24 -6
  107. package/dist-server/server/managed-desktop.js +3 -0
  108. package/dist-server/server/mcp-bridge.js +5 -3
  109. package/dist-server/server/mcp-http.js +6 -3
  110. package/dist-server/server/mcp-oauth-discovery.js +133 -0
  111. package/dist-server/server/mcp-oauth-store.js +70 -0
  112. package/dist-server/server/mcp-oauth.js +550 -0
  113. package/dist-server/server/mcp-probe.js +14 -1
  114. package/dist-server/server/mcp-registry.js +43 -0
  115. package/dist-server/server/memory-upkeep.js +94 -84
  116. package/dist-server/server/model-catalog/catalog.js +374 -0
  117. package/dist-server/server/model-catalog/presets.js +176 -0
  118. package/dist-server/server/model-catalog/trim.js +219 -0
  119. package/dist-server/server/provider-key-check.js +4 -2
  120. package/dist-server/server/recent-work.js +1 -1
  121. package/dist-server/server/request-auth.js +23 -0
  122. package/dist-server/server/routes/antigravity-leftovers.js +45 -0
  123. package/dist-server/server/routes/bot-memory.js +31 -6
  124. package/dist-server/server/routes/desktop-viewer.js +194 -0
  125. package/dist-server/server/routine-requests.js +1 -1
  126. package/dist-server/server/routines.js +1 -1
  127. package/dist-server/server/sessions.js +56 -9
  128. package/dist-server/server/skills.js +25 -10
  129. package/dist-server/server/store.js +62 -122
  130. package/dist-server/server/thread-events.js +2 -0
  131. package/dist-server/server/thread-starters.js +33 -0
  132. package/dist-server/server/thread-title.js +46 -0
  133. package/dist-server/server/tts/fish.js +4 -5
  134. package/dist-server/server/tts/index.js +5 -3
  135. package/dist-server/server/vps-computer.js +79 -12
  136. package/dist-server/server/webhooks.js +18 -1
  137. package/dist-server/server/workspace-backup-policy.js +3 -0
  138. package/dist-server/server/workspace-backup.js +3 -0
  139. package/dist-server/server/workspace.js +65 -15
  140. package/dist-server/shared/workspace-backup-client.js +1 -0
  141. package/dist-server/src/lib/citations.js +177 -0
  142. package/dist-server/src/lib/composer-attachments.js +7 -1
  143. package/dist-server/vps-container-mcp.js +196 -15
  144. package/dist-server/workspace-backup.worker.js +73 -9
  145. package/enterprise/server/index.js +5 -1
  146. package/package.json +1 -1
  147. package/dist/assets/channel-DrfGMu7X.js +0 -1
  148. package/dist/assets/index-BlnCEcU6.js +0 -588
  149. package/dist/assets/index-DVxjOvID.css +0 -1
  150. package/dist/assets/swimlanesDiagram-TC7HE7FX-BCZhxl7e.js +0 -8
@@ -8,7 +8,7 @@
8
8
  // - Composio Sessions (connected apps → tools) over streamable HTTP
9
9
  // - the bot's cloud computer (boat.dev) via server/computer-proxy.ts
10
10
  // — screenshot/exec/open_url, the CUA-on-the-boat bridge
11
- import { createHash, randomBytes } from "node:crypto";
11
+ import { createHash, randomBytes, randomUUID } from "node:crypto";
12
12
  import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
13
13
  import { createServer as createNetServer } from "node:net";
14
14
  import { homedir, tmpdir } from "node:os";
@@ -150,7 +150,7 @@ function claudeEnvironment(model, source = process.env, configDir, instanceEnvir
150
150
  // env-injected at boot); none of them are this CLI's to see.
151
151
  stripWorkspaceCredentialEnv(env);
152
152
  const applied = applyClaudeInject(env, model);
153
- // A key set on purpose for this workspace (Settings → Connections, carried
153
+ // A key set on purpose for this workspace (Settings → API keys, carried
154
154
  // in the instance environment) stays. One riding along in the parent's
155
155
  // env never does: it would flip a subscription login to pay-as-you-go.
156
156
  if (!applied.injected && !instanceEnvironment.ANTHROPIC_API_KEY)
@@ -279,11 +279,38 @@ export const CLAUDE_FLAG_FLOORS = {
279
279
  // 2.1.267 is the first CLI that accepts it; below that the recorded prompt
280
280
  // simply is not refreshed, which is the pre-existing behaviour.
281
281
  "--system-prompt-snapshot": [2, 1, 267],
282
+ // A guest's turn on a Cloud home (GUEST_CLAUDE_TOOLS): 2.1.248 takes
283
+ // --restricted, 2.1.257 honours blockReadsOutsideWorkingDirectories.
284
+ "--restricted": [2, 1, 257],
285
+ };
286
+ /** The only built-in tools a guest's turn on a Cloud home gets
287
+ * (SendTurnInput.guestConfined): no Bash, PowerShell or WebFetch, so nothing
288
+ * runs a command, and with --restricted plus the settings below every read
289
+ * outside its own folder is refused outright, never asked. Probed against
290
+ * Claude Code 2.1.284 in `default` mode: without this, a built-in list of
291
+ * "read-only" Bash commands runs unasked, and `xargs head` reads any file. */
292
+ /** A refusal of a confined turn, and why it is confined (SendTurnInput.confinedWhy). */
293
+ const withWhy = (refusal, why) => why ? `${refusal} ${why}` : refusal;
294
+ export const GUEST_CLAUDE_TOOLS = ["Read", "Grep", "Glob", "Edit", "Write", "WebSearch"];
295
+ /** Tools a guest's session must never report in its init frame. */
296
+ const GUEST_FORBIDDEN_TOOLS = new Set(["Bash", "PowerShell", "WebFetch", "BashOutput", "KillShell", "KillBash", "NotebookEdit", "Task", "Agent"]);
297
+ /** The permission block a guest's session runs under, as a second layer. */
298
+ export const GUEST_CLAUDE_PERMISSIONS = {
299
+ blockReadsOutsideWorkingDirectories: true,
300
+ deny: ["Bash", "PowerShell", "WebFetch", "Read(//proc/**)"],
282
301
  };
283
302
  /** The newest floor above: a CLI at or past it accepts everything the
284
303
  * harness sends. Below it the engine still works, minus the flags the CLI
285
304
  * predates, and the Engines page suggests an update. */
286
305
  export const CLAUDE_CONTEXT_CONTROL_MIN_VERSION = CLAUDE_FLAG_FLOORS["--system-prompt-snapshot"];
306
+ /** The first CLI this driver has seen echo a stdin user message, with the
307
+ * uuid it was sent with, as a model call takes it in (`--replay-user-messages`,
308
+ * checked on 2.1.282): a steer written during a tool call is echoed right
309
+ * after that tool's result, one written during the turn's last model call
310
+ * only after the turn's `result`, as its own turn starts. That tells a folded
311
+ * steer from one that runs next. Below it, every steer holds its turn's
312
+ * result for the grace. */
313
+ export const CLAUDE_REPLAY_FLOOR = [2, 1, 282];
287
314
  /** `claude --version` prints "2.1.232 (Claude Code)"; the first dotted triple
288
315
  * is the version. Null when nothing parses, e.g. a wrapper that prints its
289
316
  * own banner first — see claudeCliSupports for how that is treated. */
@@ -320,6 +347,7 @@ export function claudeCliUpdate(version, cli) {
320
347
  };
321
348
  }
322
349
  const DRIVER_KIND = "claudeAgent";
350
+ const NO_ANTHROPIC_KEY = "No Anthropic API key — open Settings → API keys.";
323
351
  // model catalog ported from upstream packages/contracts/src/model.ts
324
352
  export const STATIC_CLAUDE_MODELS = {
325
353
  default: "claude-sonnet-5",
@@ -334,6 +362,8 @@ export const STATIC_CLAUDE_MODELS = {
334
362
  ],
335
363
  };
336
364
  const CLAUDE_MODEL_ID = /^[a-z0-9][a-z0-9._:/-]*$/i;
365
+ /** Official Anthropic model ids, e.g. claude-sonnet-5-5 (no host:: inject prefix). */
366
+ const OFFICIAL_CLAUDE_ID = /^claude-[a-z0-9.-]+$/;
337
367
  /** Rewrite a leftover API slug (`orcarouter/Qwen…`) to `host::model` when a
338
368
  * local host is serving it, so the turn injects instead of asking for /login.
339
369
  * Official cloud ids and already-encoded inject ids skip the probe. */
@@ -360,7 +390,7 @@ function extrasFromUnknown(value) {
360
390
  return [{ id, label: label || id }];
361
391
  });
362
392
  }
363
- /** Extra ids from ~/.claude/settings.json. Official cloud rows stay untagged.
393
+ /** Extra ids from ~/.claude/settings.json. Official extraModels stay untagged.
364
394
  * `model` is Claude Code's last-used slug, not a catalog — listing it as
365
395
  * Custom put a non-inject id in the picker and the turn then had no
366
396
  * ANTHROPIC_API_KEY ("Not logged in · Please run /login"). Live injects
@@ -377,21 +407,25 @@ export function readClaudeModelCatalog(env = process.env) {
377
407
  settings = {};
378
408
  }
379
409
  const extras = [
380
- ...extrasFromUnknown(settings.availableModels),
381
- ...extrasFromUnknown(settings.customModels),
382
- ...extrasFromUnknown(settings.extraModels),
410
+ ...extrasFromUnknown(settings.availableModels).map((extra) => ({ ...extra, custom: true })),
411
+ ...extrasFromUnknown(settings.customModels).map((extra) => ({ ...extra, custom: true })),
412
+ ...extrasFromUnknown(settings.extraModels).map((extra) => ({ ...extra, custom: !OFFICIAL_CLAUDE_ID.test(extra.id) })),
383
413
  ];
384
414
  const nestedEnv = settings.env && typeof settings.env === "object" ? settings.env : {};
385
415
  const envModel = nestedEnv.ANTHROPIC_MODEL ?? env.ANTHROPIC_MODEL;
386
416
  if (typeof envModel === "string")
387
- extras.push(...extrasFromUnknown([envModel]));
417
+ extras.push(...extrasFromUnknown([envModel]).map((extra) => ({ ...extra, custom: true })));
388
418
  const options = STATIC_CLAUDE_MODELS.options.map((option) => ({ ...option }));
389
419
  const seen = new Set(options.map((option) => option.id));
390
420
  for (const extra of extras) {
391
421
  if (seen.has(extra.id))
392
422
  continue;
393
423
  seen.add(extra.id);
394
- options.push({ id: extra.id, label: extra.label, custom: true });
424
+ // Only extraModels adds official cloud rows. An explicit endpoint model
425
+ // override stays custom even when its id also appears in that list.
426
+ options.push(extra.custom || extra.id === envModel
427
+ ? { id: extra.id, label: extra.label, custom: true }
428
+ : { id: extra.id, label: extra.label });
395
429
  }
396
430
  return { default: STATIC_CLAUDE_MODELS.default, options };
397
431
  }
@@ -439,6 +473,51 @@ function askSummary(ask) {
439
473
  return askQuestionSummary(questions);
440
474
  return askInputSummary(ask.input) ?? ask.tool ?? "tool";
441
475
  }
476
+ /** A logical turn made of several native turns: any failed half fails it,
477
+ * the last stop reason stands, per-turn token usage adds up, and the cost is
478
+ * the latest figure — the CLI reports total_cost_usd as the process's running
479
+ * total ("cumulative across turns in streaming-input sessions … read the
480
+ * latest result rather than summing", 2.1.282), so adding would double-bill.
481
+ * A figure missing on one side leaves the other side's alone. */
482
+ export function sumNativeTurnResults(earlier, latest) {
483
+ if (!earlier)
484
+ return latest;
485
+ const usage = earlier.usage && latest.usage
486
+ ? {
487
+ input: earlier.usage.input + latest.usage.input,
488
+ output: earlier.usage.output + latest.usage.output,
489
+ ...(earlier.usage.cachedInput !== undefined || latest.usage.cachedInput !== undefined
490
+ ? { cachedInput: (earlier.usage.cachedInput ?? 0) + (latest.usage.cachedInput ?? 0) }
491
+ : {}),
492
+ }
493
+ : latest.usage ?? earlier.usage;
494
+ return {
495
+ ok: earlier.ok && latest.ok,
496
+ stopReason: latest.stopReason ?? earlier.stopReason,
497
+ cost: latest.cost ?? earlier.cost,
498
+ ...(usage ? { usage } : {}),
499
+ };
500
+ }
501
+ /** How long after a native `result` the CLI gets to announce, with `init`,
502
+ * the turn it starts for a user message steered in after this turn's last
503
+ * model call. The message is already buffered on its stdin, so this takes
504
+ * milliseconds (about 60 ms on 2.1.282). If nothing comes, the message was
505
+ * folded into one of this turn's model calls after all, and the held result
506
+ * is the turn's: every result with a steer outstanding waits this long. */
507
+ export const STEERED_CONTINUATION_GRACE_MS = 2_000;
508
+ /** How long a steered continuation may stay silent after its `init` before
509
+ * the driver stops waiting and closes the turn on the held result. 2.1.282
510
+ * follows `init` with a `status` frame within milliseconds and every CLI
511
+ * streams once the model answers; a continuation that never speaks would
512
+ * otherwise keep the turn — and its internal tool pass — open until the
513
+ * stall watchdog. */
514
+ export const STEERED_CONTINUATION_SILENCE_MS = 30_000;
515
+ /** Tests scale each steer timer on its own, the way FAKE_CLAUDE_RETRY_SCALE
516
+ * scales the retry backoff — a test that shortens the silence bound must not
517
+ * also shorten the grace `init` has to arrive in. Production runs at 1. */
518
+ const fakeTimerScale = (name) => Number(process.env[name] ?? "1") || 1;
519
+ const steerGraceScale = () => fakeTimerScale("FAKE_CLAUDE_STEER_GRACE_SCALE");
520
+ const steerSilenceScale = () => fakeTimerScale("FAKE_CLAUDE_STEER_SILENCE_SCALE");
442
521
  /** Where the hook helper reads this thread's current turn token. Stable per
443
522
  * thread (so the CLI's environment can name it once) and private. */
444
523
  export function hookTokenFile(threadId, botId) {
@@ -740,6 +819,7 @@ function decodeConfig(raw) {
740
819
  permissionMode: mode ?? "acceptEdits",
741
820
  ...(tools !== undefined ? { tools } : {}),
742
821
  ...(disallowedTools !== undefined ? { disallowedTools } : {}),
822
+ ...(o.requireApiKey === true ? { requireApiKey: true } : {}),
743
823
  };
744
824
  }
745
825
  function firstText(content) {
@@ -1042,6 +1122,8 @@ export const ClaudeDriver = {
1042
1122
  const sendTurn = async (turn, logicalTurnId) => {
1043
1123
  if (config.managedModels && (!turn.model || !config.managedModels.includes(turn.model)))
1044
1124
  throw new Error("This model is not assigned to this workspace.");
1125
+ if (config.requireApiKey && !input.environment.ANTHROPIC_API_KEY)
1126
+ throw new Error(NO_ANTHROPIC_KEY);
1045
1127
  if (config.managed && (!turn.model || turn.model.includes("::") || !config.configDir ||
1046
1128
  !input.environment.ANTHROPIC_API_KEY || !input.environment.ANTHROPIC_BASE_URL)) {
1047
1129
  throw new Error("Company model access is unavailable. Reconnect your organization; personal billing will not be used.");
@@ -1098,19 +1180,34 @@ export const ClaudeDriver = {
1098
1180
  "--include-partial-messages",
1099
1181
  "--permission-mode", permissionMode,
1100
1182
  ];
1101
- if (config.tools !== undefined)
1183
+ // A guest's turn: no command-running tool at all, and no read outside
1184
+ // its own folder (GUEST_CLAUDE_TOOLS). It only ever runs in Ask.
1185
+ if (turn.guestConfined && permissionMode !== "default") {
1186
+ throw new Error("A guest's turn on this Cloud runs only in Ask.");
1187
+ }
1188
+ if (turn.guestConfined)
1189
+ args.push("--restricted", "--tools", GUEST_CLAUDE_TOOLS.join(","));
1190
+ else if (config.tools !== undefined)
1102
1191
  args.push("--tools", config.tools.join(","));
1103
1192
  if (config.disallowedTools?.length) {
1104
1193
  args.push("--disallowedTools", config.disallowedTools.join(","));
1105
1194
  }
1106
1195
  const turnEnvironment = environment();
1107
- if (turn.refreshSystemPrompt && !cliVersionChecked) {
1196
+ if ((turn.refreshSystemPrompt || turn.guestConfined) && !cliVersionChecked) {
1108
1197
  const version = await readCliVersion(turnEnvironment);
1109
1198
  if (version) {
1110
1199
  cliVersion = parseClaudeCliVersion(version);
1111
1200
  cliVersionChecked = true;
1112
1201
  }
1113
1202
  }
1203
+ if (turn.guestConfined && !claudeCliSupports(cliVersion, "--restricted")) {
1204
+ throw new Error(withWhy("This Claude Code is too old to run this turn without a shell. Update Claude Code.", turn.confinedWhy));
1205
+ }
1206
+ // Each stdin message echoed as a model call takes it in: how a turn
1207
+ // tells a folded steer from one that runs next (CLAUDE_REPLAY_FLOOR).
1208
+ const replaysUserMessages = cliVersion === null || versionAtLeast(cliVersion, CLAUDE_REPLAY_FLOOR);
1209
+ if (replaysUserMessages)
1210
+ args.push("--replay-user-messages");
1114
1211
  const isolated = !inheritsUserConfig(turnEnvironment);
1115
1212
  if (isolated) {
1116
1213
  // A bot gets the tools and instructions its owner gave it, not
@@ -1228,7 +1325,9 @@ export const ClaudeDriver = {
1228
1325
  // of MCP servers, so a server the bot's OWN project declares would
1229
1326
  // otherwise vanish with the machine's. Merge it last: a project file
1230
1327
  // can add servers but never shadow a harness-owned mount.
1231
- if (isolated && turn.cwd) {
1328
+ // Never for a guest's turn: its folder is its own to write, and a
1329
+ // server declared there would run a command.
1330
+ if (isolated && turn.cwd && !turn.guestConfined) {
1232
1331
  for (const [name, server] of Object.entries(projectMcpServers(turn.cwd))) {
1233
1332
  if (Object.hasOwn(mcpServers, name))
1234
1333
  continue;
@@ -1258,6 +1357,10 @@ export const ClaudeDriver = {
1258
1357
  }
1259
1358
  mcpServers.ogb = { command: process.execPath, args: [PERM_PROXY_PATH, socketPath], env: { ...NODE_ENV_FLAG }, alwaysLoad: true };
1260
1359
  allowed.push("mcp__ogb");
1360
+ // A guest's turn pre-allows only the harness's own tools: anything
1361
+ // else (the browser can open a file: address) asks the owner first.
1362
+ if (turn.guestConfined)
1363
+ allowed.splice(0, allowed.length, ...allowed.filter((name) => name === "mcp__ogb" || name === "mcp__agents"));
1261
1364
  // The MCP config carries credentials — a Composio consumer key in a
1262
1365
  // header, the boat token in the computer proxy's env, the comms token in
1263
1366
  // the agents proxy's env. On argv every one of those is world-readable
@@ -1294,6 +1397,8 @@ export const ClaudeDriver = {
1294
1397
  const settings = { ...authSettings };
1295
1398
  if (hooks)
1296
1399
  settings.hooks = claudeHookSettings(HOOK_HELPER_PATH);
1400
+ if (turn.guestConfined)
1401
+ settings.permissions = GUEST_CLAUDE_PERMISSIONS;
1297
1402
  const authSettingsPath = mcpConfigPath && Object.keys(settings).length
1298
1403
  ? join(dirname(mcpConfigPath), "auth-settings.json") : null;
1299
1404
  if (authSettingsPath)
@@ -1333,7 +1438,7 @@ export const ClaudeDriver = {
1333
1438
  if (!turn.sessionReset && live && !live.turn && !live.closing && live.child.exitCode === null && live.argsKey === argsKey && (!sessionId || sessionId === live.sessionId)) {
1334
1439
  if (live.idleTimer)
1335
1440
  clearTimeout(live.idleTimer);
1336
- live.turn = { turnId, input: turn, retryAbort, settled: false, sawStreamDelta: false };
1441
+ live.turn = { turnId, input: turn, retryAbort, settled: false, sawStreamDelta: false, pendingSteers: new Set(), deferred: null, continuationGrace: null, continuationSilence: null };
1337
1442
  active.set(threadId, { stop: () => {
1338
1443
  if (live.turn)
1339
1444
  live.turn.stopRequested = true;
@@ -1514,7 +1619,8 @@ export const ClaudeDriver = {
1514
1619
  sessionId: sessionId ?? newSessionId,
1515
1620
  sawInit: false,
1516
1621
  nativePermissionMode: null,
1517
- turn: { turnId, input: turn, retryAbort, settled: false, sawStreamDelta: false },
1622
+ replaysUserMessages,
1623
+ turn: { turnId, input: turn, retryAbort, settled: false, sawStreamDelta: false, pendingSteers: new Set(), deferred: null, continuationGrace: null, continuationSilence: null },
1518
1624
  idleTimer: null,
1519
1625
  closing: false,
1520
1626
  stderr: "",
@@ -1528,6 +1634,14 @@ export const ClaudeDriver = {
1528
1634
  if (!t || t.settled)
1529
1635
  return;
1530
1636
  t.settled = true;
1637
+ if (t.continuationGrace) {
1638
+ clearTimeout(t.continuationGrace);
1639
+ t.continuationGrace = null;
1640
+ }
1641
+ if (t.continuationSilence) {
1642
+ clearTimeout(t.continuationSilence);
1643
+ t.continuationSilence = null;
1644
+ }
1531
1645
  // Resolve any ask still open for this turn, but keep the broker
1532
1646
  // listening for the next turn on the retained process. Between turns
1533
1647
  // isActive() rejects late background asks without creating cards.
@@ -1564,6 +1678,7 @@ export const ClaudeDriver = {
1564
1678
  if (session.child.exitCode === null && !session.closing)
1565
1679
  armIdle(threadId);
1566
1680
  };
1681
+ const settleResult = (result) => settle(result.ok, result.stopReason, result.cost, result.usage);
1567
1682
  const currentTurnId = () => session.turn?.turnId ?? turnId;
1568
1683
  // The process's first result with a cost says what --resume restored,
1569
1684
  // which its turns are measured from; every result is kept for a later
@@ -1590,14 +1705,58 @@ export const ClaudeDriver = {
1590
1705
  catch {
1591
1706
  return;
1592
1707
  }
1593
- appendNative(threadId, { dir: "in", source: "claude.sdk.message", msg: o });
1708
+ // A stdin message echoed back (--replay-user-messages) carries its
1709
+ // images again: keep their bytes out of the log, as when it was sent.
1710
+ appendNative(threadId, { dir: "in", source: "claude.sdk.message", msg: o?.type === "user" && o.isReplay === true && o.message ? diagnosticClaudeUserMessage(o) : o });
1711
+ // The continuation a held result waits for has spoken: any frame
1712
+ // after its `init` — status, thinking, text, its own result. The
1713
+ // echo of its own message is not speech: it comes before the call.
1714
+ if (session.turn?.continuationSilence && !(o.type === "system" && o.subtype === "init") && !(o.type === "user" && o.isReplay === true)) {
1715
+ clearTimeout(session.turn.continuationSilence);
1716
+ session.turn.continuationSilence = null;
1717
+ }
1594
1718
  switch (o.type) {
1595
1719
  case "system":
1596
1720
  if (o.subtype === "init") {
1721
+ // A guest's session proves its tool set before it does anything:
1722
+ // a CLI that kept a command-running tool is stopped here.
1723
+ const tools = Array.isArray(o.tools) ? o.tools : [];
1724
+ if (session.turn?.input.guestConfined && (o.permissionMode !== "default" || tools.some((tool) => typeof tool === "string" && GUEST_FORBIDDEN_TOOLS.has(tool)))) {
1725
+ emit({ ...base(threadId, currentTurnId()), type: "runtime.error", message: withWhy("This Claude Code kept its shell, so it can't run this turn. Update Claude Code.", session.turn?.input.confinedWhy) });
1726
+ session.closing = true;
1727
+ stopSession(session);
1728
+ break;
1729
+ }
1597
1730
  session.sawInit = true;
1598
1731
  session.nativePermissionMode = typeof o.permissionMode === "string" ? o.permissionMode : null;
1599
1732
  if (typeof o.session_id === "string")
1600
1733
  session.sessionId = o.session_id;
1734
+ // The turn the CLI starts for a steered message it could not
1735
+ // fold (see `result`): the held result now waits for this one's
1736
+ // — bounded, so a continuation that announces itself and then
1737
+ // never speaks cannot keep the turn's pass open indefinitely.
1738
+ const held = session.turn;
1739
+ if (held?.continuationGrace) {
1740
+ clearTimeout(held.continuationGrace);
1741
+ held.continuationGrace = null;
1742
+ if (held.continuationSilence)
1743
+ clearTimeout(held.continuationSilence);
1744
+ held.continuationSilence = setTimeout(() => {
1745
+ if (session.turn !== held || held.settled || !held.deferred)
1746
+ return;
1747
+ // A Stop or a close settles the turn in finalizeClose.
1748
+ if (held.stopRequested || session.closing)
1749
+ return;
1750
+ held.continuationSilence = null;
1751
+ emit({
1752
+ ...base(threadId, held.turnId),
1753
+ type: "runtime.error",
1754
+ message: "Claude began a steered message but went silent; the turn was closed.",
1755
+ });
1756
+ settleResult(held.deferred);
1757
+ }, STEERED_CONTINUATION_SILENCE_MS * steerSilenceScale());
1758
+ held.continuationSilence.unref?.();
1759
+ }
1601
1760
  emit({ ...base(threadId, currentTurnId()), type: "session.started", sessionId: o.session_id, model: o.model, ...(retry.rebuilt ? { rebuilt: true } : {}) });
1602
1761
  }
1603
1762
  else if (o.subtype === "thinking_tokens") {
@@ -1684,7 +1843,14 @@ export const ClaudeDriver = {
1684
1843
  }
1685
1844
  break;
1686
1845
  }
1687
- case "user":
1846
+ case "user": {
1847
+ // --replay-user-messages: a model call took this stdin message in.
1848
+ // A steer echoed before its turn's `result` was folded into it.
1849
+ if (o.isReplay === true) {
1850
+ if (typeof o.uuid === "string")
1851
+ session.turn?.pendingSteers.delete(o.uuid);
1852
+ break;
1853
+ }
1688
1854
  for (const b of Array.isArray(o.message?.content) ? o.message.content : []) {
1689
1855
  if (b.type === "tool_result") {
1690
1856
  emit({ ...base(threadId, currentTurnId()), type: "item.completed", itemType: "tool", itemId: b.tool_use_id, ok: !b.is_error, output: toolDetailPreview(b.content) });
@@ -1694,7 +1860,8 @@ export const ClaudeDriver = {
1694
1860
  }
1695
1861
  }
1696
1862
  break;
1697
- case "result":
1863
+ }
1864
+ case "result": {
1698
1865
  // A synthetic background completion is not the result of the
1699
1866
  // submitted user turn. Settling it would revoke browser access
1700
1867
  // and deny approvals while that user turn is still running.
@@ -1713,20 +1880,84 @@ export const ClaudeDriver = {
1713
1880
  cacheWrite: o.usage?.cache_creation_input_tokens || 0,
1714
1881
  output: o.usage?.output_tokens || 0,
1715
1882
  });
1716
- settle(o.is_error !== true, session.turn?.authFailed
1717
- ? "auth_required"
1718
- : session.turn?.updateRequired
1719
- ? "update_required"
1720
- : o.stop_reason ?? o.terminal_reason ?? null, o.total_cost_usd ?? null, o.usage
1721
- ? {
1722
- input: (o.usage.input_tokens || 0) + (o.usage.cache_read_input_tokens || 0) + (o.usage.cache_creation_input_tokens || 0),
1723
- output: o.usage.output_tokens || 0,
1724
- ...(typeof o.usage.cache_read_input_tokens === "number"
1725
- ? { cachedInput: o.usage.cache_read_input_tokens }
1726
- : {}),
1727
- }
1728
- : undefined);
1883
+ const native = {
1884
+ ok: o.is_error !== true,
1885
+ stopReason: session.turn?.authFailed
1886
+ ? "auth_required"
1887
+ : session.turn?.updateRequired
1888
+ ? "update_required"
1889
+ : o.stop_reason ?? o.terminal_reason ?? null,
1890
+ cost: o.total_cost_usd ?? null,
1891
+ ...(o.usage
1892
+ ? {
1893
+ usage: {
1894
+ input: (o.usage.input_tokens || 0) + (o.usage.cache_read_input_tokens || 0) + (o.usage.cache_creation_input_tokens || 0),
1895
+ output: o.usage.output_tokens || 0,
1896
+ ...(typeof o.usage.cache_read_input_tokens === "number"
1897
+ ? { cachedInput: o.usage.cache_read_input_tokens }
1898
+ : {}),
1899
+ },
1900
+ }
1901
+ : {}),
1902
+ };
1903
+ const t = session.turn;
1904
+ // Does another user turn follow this result without more input?
1905
+ // The CLI says so itself when it can: queued_turn_count ("greater
1906
+ // than 0 means at least one more user turn (and result) follows",
1907
+ // 2.1.282) counts its command queue. A message steered in over
1908
+ // stdin is not in that queue when the result is written — the
1909
+ // incident's result said 0 and the CLI ran the message 58 ms later
1910
+ // — so 0, like an absent field, decides nothing; the steers the
1911
+ // driver has not seen taken in do. With --replay-user-messages the
1912
+ // CLI echoes a steer as a model call takes it in, so one still
1913
+ // pending here runs next. Without it (an older CLI), nothing says
1914
+ // whether a steer was folded in or runs next (the time a tool
1915
+ // result is read proves nothing about when stdin was taken), so
1916
+ // any steer holds the result: if no `init` follows within the
1917
+ // grace, it was folded, and the held result is the turn's. A steer
1918
+ // landing while a result is held extends the hold.
1919
+ const queuedTurns = typeof o.queued_turn_count === "number" ? o.queued_turn_count : 0;
1920
+ if (t && !t.settled && (queuedTurns > 0 || t.pendingSteers.size > 0)) {
1921
+ // The CLI runs the queued message next, in this process, with
1922
+ // this turn's tools, and the harness recorded it as part of this
1923
+ // turn. A `turn.completed` now would revoke the turn's
1924
+ // capabilities under that continuation (its internal tools would
1925
+ // answer 401) and show the bot idle while it works. Hold this
1926
+ // result until the continuation's own arrives.
1927
+ // Echoed steers leave the set as their turn takes them in;
1928
+ // without the echo, this hold answers for every steer so far.
1929
+ if (!session.replaysUserMessages)
1930
+ t.pendingSteers.clear();
1931
+ t.deferred = sumNativeTurnResults(t.deferred, native);
1932
+ t.armGrace = () => {
1933
+ if (t.continuationGrace)
1934
+ clearTimeout(t.continuationGrace);
1935
+ t.continuationGrace = setTimeout(() => {
1936
+ // No `init` came: the message was folded into the call that
1937
+ // just finished after all (or a queued send was cancelled),
1938
+ // and the held result is the turn's.
1939
+ if (session.turn !== t || t.settled)
1940
+ return;
1941
+ // A Stop or a close settles the turn in finalizeClose: as
1942
+ // interrupted after a Stop, else on the held result, which
1943
+ // the grace still being set tells it the turn owns. (taskkill
1944
+ // is asynchronous on Windows, so the CLI can outlive a Stop
1945
+ // by longer than this grace.)
1946
+ if (t.stopRequested || session.closing)
1947
+ return;
1948
+ t.continuationGrace = null;
1949
+ if (t.deferred)
1950
+ settleResult(t.deferred);
1951
+ }, STEERED_CONTINUATION_GRACE_MS * steerGraceScale());
1952
+ t.continuationGrace.unref?.();
1953
+ };
1954
+ t.armGrace();
1955
+ appendNative(threadId, { dir: "out", source: "claude.session", msg: { hold: `result: a steered message is still queued (queued_turn_count ${o.queued_turn_count ?? "absent"})` } });
1956
+ break;
1957
+ }
1958
+ settleResult(sumNativeTurnResults(t?.deferred ?? null, native));
1729
1959
  break;
1960
+ }
1730
1961
  }
1731
1962
  };
1732
1963
  let buf = "";
@@ -1774,6 +2005,24 @@ export const ClaudeDriver = {
1774
2005
  if (session.turn?.stopRequested && !session.turn.settled) {
1775
2006
  settle(false, "interrupted");
1776
2007
  }
2008
+ else if (session.turn?.deferred && !session.turn.settled) {
2009
+ // The prompt was answered — a native result is held for a steered
2010
+ // continuation — and the process went away. Never relaunch: the
2011
+ // prompt already ran. Before the continuation announced itself the
2012
+ // held result is the turn's; once it had begun, its words are lost.
2013
+ const held = session.turn.deferred;
2014
+ if (session.turn.continuationGrace) {
2015
+ settleResult(held);
2016
+ }
2017
+ else {
2018
+ emit({
2019
+ ...base(threadId, currentTurnId()),
2020
+ type: "runtime.error",
2021
+ message: `claude exited ${code} before result${session.stderr ? `: ${session.stderr.trim().slice(-300)}` : ""}`,
2022
+ });
2023
+ settleResult({ ...held, ok: false, stopReason: "exit_before_result" });
2024
+ }
2025
+ }
1777
2026
  else if (session.turn && !session.turn.settled) {
1778
2027
  // A retained process may be running a later user turn. Its close
1779
2028
  // handler must retry that request, not the process's first prompt.
@@ -1980,13 +2229,29 @@ export const ClaudeDriver = {
1980
2229
  return { turnId };
1981
2230
  };
1982
2231
  /** A user message into the running turn: the CLI delivers it before its
1983
- * next model call. "refused" when nothing is running here to steer or
1984
- * the stdin write provably failed; the caller queues those words. */
2232
+ * next model call, or — when no call is left in this turn — as its next
2233
+ * native turn, which this driver keeps inside the same logical turn.
2234
+ * "refused" when nothing is running here to steer or the stdin write
2235
+ * provably failed; the caller queues those words. */
1985
2236
  const steer = async (threadId, text) => {
1986
2237
  const s = sessions.get(threadId);
1987
2238
  if (!s || !s.turn || s.turn.settled || s.closing || s.child.exitCode !== null)
1988
2239
  return "refused";
1989
- return (await writeUser(s, threadId, claudeUserMessage(text, undefined))) ? "steered" : "refused";
2240
+ const turn = s.turn;
2241
+ // Counted before the write: a `result` read while the words are still
2242
+ // on their way must hold for them too. A failed write takes it back.
2243
+ // The uuid is what the CLI's echo names when a model call takes it in.
2244
+ const id = randomUUID();
2245
+ turn.pendingSteers.add(id);
2246
+ if (!(await writeUser(s, threadId, { ...claudeUserMessage(text, undefined), uuid: id }))) {
2247
+ turn.pendingSteers.delete(id);
2248
+ return "refused";
2249
+ }
2250
+ // Written while a held result waits for a continuation's `init`: these
2251
+ // words get the whole grace to be announced too.
2252
+ if (!turn.settled && turn.continuationGrace)
2253
+ turn.armGrace?.();
2254
+ return "steered";
1990
2255
  };
1991
2256
  // Sign in from Settings: the unmodified CLI's own login, driven over pipes
1992
2257
  // (server/drivers/claude-login-auth.ts). Same environment as every turn.
@@ -1998,12 +2263,18 @@ export const ClaudeDriver = {
1998
2263
  return { state: "unavailable", reason: `\`${config.cli}\` CLI not found` };
1999
2264
  cliVersion = parseClaudeCliVersion(version);
2000
2265
  cliVersionChecked = true;
2266
+ const update = claudeCliUpdate(version, config.cli);
2267
+ const warning = claudeInheritWarning(env);
2268
+ if (config.requireApiKey) {
2269
+ // Never falls back to a login: without the key it is not set up.
2270
+ if (!input.environment.ANTHROPIC_API_KEY)
2271
+ return { state: "unavailable", version, reason: NO_ANTHROPIC_KEY };
2272
+ return { state: "available", version, authenticated: true, account: { method: "api-key" }, ...(update ? { update } : {}), ...(warning ? { warning } : {}), billing: "metered" };
2273
+ }
2001
2274
  const auth = await claudeAuthStatus(config.cli, env);
2002
2275
  // claudeEnvironment strips ANTHROPIC_API_KEY, so turns run on the
2003
2276
  // CLI's own login (Pro/Max): the cost it reports is what the call
2004
2277
  // WOULD bill, not a charge
2005
- const update = claudeCliUpdate(version, config.cli);
2006
- const warning = claudeInheritWarning(env);
2007
2278
  return { state: "available", version, ...auth, ...(update ? { update } : {}), ...(warning ? { warning } : {}), billing: "subscription" };
2008
2279
  };
2009
2280
  /** One-shot Claude call with the prompt on stdin, never argv. Approval
@@ -2011,6 +2282,10 @@ export const ClaudeDriver = {
2011
2282
  * `claude -p "prompt"` shape is not safe for review. No tools or MCP
2012
2283
  * servers are mounted in this isolated process. */
2013
2284
  const generateReview = (prompt, signal, onUsage) => new Promise((resolve, reject) => {
2285
+ if (config.requireApiKey && !input.environment.ANTHROPIC_API_KEY) {
2286
+ reject(new Error(NO_ANTHROPIC_KEY));
2287
+ return;
2288
+ }
2014
2289
  const model = config.managedModels?.[0] ?? "claude-haiku-4-5";
2015
2290
  const child = spawnCli(config.cli, ["-p", "--model", model, "--output-format", onUsage ? "json" : "text"], {
2016
2291
  stdio: ["pipe", "pipe", "pipe"],
@@ -2115,6 +2390,9 @@ export const ClaudeDriver = {
2115
2390
  provider: DRIVER_KIND,
2116
2391
  capabilities: {
2117
2392
  sessionModelSwitch: "in-session",
2393
+ // A guest's turn runs with no command-running tool and no read
2394
+ // outside its folder (guestConfined, GUEST_CLAUDE_TOOLS).
2395
+ guestTurns: "confined",
2118
2396
  agentsMcp: true,
2119
2397
  customMcp: true,
2120
2398
  computerMcp: true,