orkestrator 2.37.1-beta → 2.37.4-beta

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.
@@ -505,12 +505,22 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
505
505
  denied: "A renderer asked for a permission the policy does not grant."
506
506
  }
507
507
  },
508
+ "desktop.webrequest": {
509
+ description: "Main-process webRequest listeners on Electron sessions. Listener names only; never a URL, header or error message.",
510
+ events: {
511
+ "listener.failed-closed": "A listener's decision threw or rejected, so it answered with its fail-closed response.",
512
+ "observer.failed": "A listener with no callback (a redirect observer) threw; its fallback ran.",
513
+ "callback.failed": "Electron's webRequest callback threw while a listener answered.",
514
+ ...THROTTLE_LOG_EVENTS
515
+ }
516
+ },
508
517
  "desktop.dialog": {
509
518
  description: "Native dialogs, whose modal loops hold the main thread while they are open.",
510
519
  events: {
511
520
  "attention-failed": "A dialog could not ask for the user's attention.",
512
521
  closed: "A native dialog closed.",
513
522
  "hidden-cancelled": "A hidden profile cancelled a dialog without opening native UI.",
523
+ "no-display-cancelled": "A headless Electron with no display cancelled a dialog instead of opening native UI.",
514
524
  "open-failed": "A dialog could not open; it was answered as cancelled.",
515
525
  opening: "A native dialog is opening.",
516
526
  "preview-beforeunload-ignored": "A browser preview's beforeunload handler was ignored.",
@@ -593,6 +603,9 @@ var ENVIRONMENT_LOG_AREAS = defineLogAreas({
593
603
  "setup.record-failure-failed": "A setup failure before its first attempt could not be recorded.",
594
604
  "setup.tab-publish-failed": "The setup terminal's tab could not be published.",
595
605
  "lifecycle.failed": "Starting, rebuilding or recreating an environment failed; `operation` says which.",
606
+ "git-https-probe.failed": "Checking whether a project's GitHub remote works over HTTPS failed; `reason` says why.",
607
+ "git-https-remedy.failed": "Deciding whether to offer HTTPS after an SSH failure threw; no remedy is offered.",
608
+ "git-origin.switched-to-https": "A project's origin remote was switched from GitHub SSH to HTTPS at the user's request.",
596
609
  "tab-teardown.pending": "A tab's teardown failed and stays pending; the reconcile sweep retries.",
597
610
  "tab-reconcile.skipped": "Orphaned tab reconciliation was skipped because pane layouts are unreadable.",
598
611
  "orphan-session.reaped": "A native session no tab references was torn down.",
@@ -863,11 +876,38 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
863
876
  "agent-tools.unavailable": "OpenCode agent tools remain unavailable for a session.",
864
877
  "coordinator-servers.unavailable": "OpenCode coordinator research servers are unavailable.",
865
878
  "monitor.reconnecting": "The request monitor lost its stream and is reconnecting. Error class only.",
879
+ "monitor.silent": "The request monitor's stream stopped heartbeating, so it is replaced. `silenceMs` only.",
866
880
  "worker-limit.reached": "The bounded request workers are full, so the stream restarts and a snapshot reconciles.",
867
881
  "request.failed": "Handling a request event failed, so the stream restarts. Error class only.",
868
882
  "credential-plugin.skipped": "A host OpenCode server started without the credential plugin, so its tools inherit its password; `reason` says why.",
869
883
  "host-database.separated": "Host OpenCode uses Orkestrator's own database because the shared one has no `session` table (an OpenCode 2 database); `reason` says why.",
870
- "host-database.unreadable": "The shared OpenCode database could not be inspected, so host OpenCode opens it as usual. Error class only."
884
+ "host-database.unreadable": "The shared OpenCode database could not be inspected, so host OpenCode opens it as usual. Error class only.",
885
+ "login.opencode2-mirror-failed": "A provider sign-in change reached OpenCode 1 but could not be copied into the OpenCode 2 database; the user is told to retry. Error class only."
886
+ }
887
+ },
888
+ "native-agent.opencode2": {
889
+ description: "The OpenCode 2.x provider: its event monitor, steering, routing, host and container servers.",
890
+ events: {
891
+ "events.dropped": "The 2.x event stream ended or failed, so reads go to the server until it reconnects. Error class only.",
892
+ "steer.unconfirmed": "A 2.x steer got no definite answer, so its delivery is reconciled from history. Error class only.",
893
+ "provider.dispose-failed": "Disposing the 2.x provider of a replaced server failed. Error class only.",
894
+ "transcript.unknown-row": "A 2.x history row of a kind the transcript does not know was dropped (a newer server). Its kind name only, once per kind.",
895
+ "mcp.remove-failed": "Removing a closed session's Orkestrator MCP server from the 2.x server failed. Error class only.",
896
+ "protocol.select-failed": "A workflow could not read the OpenCode line setting, so its new session takes 1.x. Error class only.",
897
+ "host-server.ready": "A local environment's (or a coordinator conversation's) 2.x server answered `/api/info` as 2.x. Environment id, pid and whether it is a coordinator's only.",
898
+ "coordinator-research.unavailable": "A coordinator's 2.x server could not register its research servers, so the conversation runs without them until the server restarts. Error class only.",
899
+ "host-server.terminate-failed": "A 2.x server that did not become ready could not be stopped; its process entry is kept for shutdown. Error class only.",
900
+ "container-server.launched": "The start script of a container environment's 2.x server was run. Container port only.",
901
+ "container-server.ready": "A container environment's 2.x server this backend started answered `/api/info` as 2.x. Environment id only.",
902
+ "container-server.cleanup-failed": "Cleanup after OpenCode startup failed; step names only, while the original startup error is preserved.",
903
+ "container-server.warm-incomplete": "The first workspace request to a container's new 2.x server failed, so its plugins load on the next one. Error class only.",
904
+ "resume-list.unavailable": "The 2.x sessions could not be listed for the resume picker, so it shows the 1.x list alone. Error class only.",
905
+ "credential.mirrored": "A provider sign-in change was copied into the 2.x database. `outcome` (written, removed, unchanged, skipped) only; never a provider id or value.",
906
+ "credential.server-exit-unclean": "The private 2.x server started to copy a sign-in did not stop cleanly. Error class only.",
907
+ "user-config.mirror-failed": "The user's global OpenCode configuration could not be mirrored for a host 2.x server, which starts without it. Error class only.",
908
+ "user-config.unreadable": "A file of the user's OpenCode configuration could not be read for the 2.x mirror. `source`, the file's name and the error code only.",
909
+ "user-config.rejected": "Files of the user's OpenCode configuration are not a JSONC object, so the 2.x mirror leaves them out. `source` and file names only, never contents.",
910
+ "user-config.plugins-withheld": "The user's OpenCode configuration lists plugins, which the 2.x mirror leaves out (1.x plugins do not run on 2.x). `source` only."
871
911
  }
872
912
  }
873
913
  });
@@ -1094,6 +1134,7 @@ var TMUX_LOG_AREAS = defineLogAreas({
1094
1134
  "cleanup.skipped": "Environment tmux cleanup was skipped because tmux could not be reached and nothing required it.",
1095
1135
  "cleanup.environments-load-failed": "Environments could not be loaded during tmux cleanup, so it stays incomplete.",
1096
1136
  "cleanup.kill-failed": "An environment's tmux sessions could not be killed.",
1137
+ "cleanup.kill-incomplete": "An environment's tmux sessions could not all be shown gone (a session survived, or the socket was unreachable while another tmux process might own it), so cleanup stays incomplete.",
1097
1138
  "hooks.uninstall-failed": "Workspace hooks could not be uninstalled.",
1098
1139
  "hooks.git-exclude-failed": "The git exclude for Claude's local settings could not be set.",
1099
1140
  "naming.prepare-failed": "First-prompt naming could not be prepared; the prompt still goes ahead.",
@@ -1223,6 +1264,7 @@ var STORAGE_LOG_AREAS = defineLogAreas({
1223
1264
  "config.restrict-mode-failed": "A config file holding provider secrets could not be set to owner-only; the backend carries on.",
1224
1265
  "legacy-json.moved": "JSON store files written after the SQLite migration were archived, not imported.",
1225
1266
  "legacy-json.archive-failed": "Imported JSON store files could not be archived.",
1267
+ "native-session-owners.backfill-failed": "Native-session rows could not be given their environment as owner at open; an environment delete then parses those rows instead, and the next open retries.",
1226
1268
  "lease.timed-out": "A waiter gave up on a lease; `lease` and `family` name it, `holderAgeMs` is the time since its holder's last heartbeat (null when the holder had just gone), `waitedMs` how long the waiter waited.",
1227
1269
  "lease.heartbeat-failed": "A held lease's heartbeat failed, which shortens the lease; the next one retries.",
1228
1270
  "scrub.vacuum-failed": "Deleted-content page reclamation failed; the checkpoint is attempted independently.",
@@ -1272,6 +1314,7 @@ var BUILD_PIPELINE_LOG_AREAS = defineLogAreas({
1272
1314
  "transcripts.maintenance-failed": "Migrating or sweeping stage transcripts failed; the next start retries.",
1273
1315
  "restore.skipped": "A pipeline could not be restored at startup and was skipped.",
1274
1316
  "criteria.record-failed": "Acceptance criteria results could not be recorded on the ticket.",
1317
+ "completion-notes.publish-failed": "A finished pipeline's notes tab could not be added to the layout; the run stays complete.",
1275
1318
  "workspace.waiting": "A pipeline is waiting for its workspace; written once per reason.",
1276
1319
  "rewind.pending": "A pipeline's code rewind has not finished; written once per reason.",
1277
1320
  "kanban.status-failed": "A restarted pipeline's Kanban status could not be set; it retries shortly.",
@@ -1313,6 +1356,8 @@ var CHANGE_TRACKING_LOG_AREAS = defineLogAreas({
1313
1356
  "dispatch.record-failed": "Recording a turn's dispatch outcome failed.",
1314
1357
  "turn.finalize-failed": "Finalizing a turn failed.",
1315
1358
  "turn.settle-failed": "Settling a late interrupted turn failed.",
1359
+ "turn.end-recovery": "A background retry of a turn end capture that timed out finished: recovered, done (no longer eligible) or exhausted.",
1360
+ "turn.end-recovery-failed": "A background retry of a turn end capture threw; it counts as a failed attempt.",
1316
1361
  "evidence.pull-failed": "Pulling change evidence from a bridge failed; a later pull retries.",
1317
1362
  "measurement.failed": "Recomputing a tool's measurement failed."
1318
1363
  }
@@ -1381,6 +1426,7 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
1381
1426
  "node-release.no-coordinator": "Work closed on a released node belonged to a coordinator that no longer exists, so nobody was told.",
1382
1427
  "node-offline.notice-failed": "The notice that a node has been unreachable for a day could not be sent; the next failed read retries.",
1383
1428
  "node-offline.check-failed": "Whether a long-unreachable node's coordinators were told could not be checked; the next read retries.",
1429
+ "node-reconnect.notice-failed": "The message that a node a coordinator tried while it was disconnected is back could not be sent; it is not retried, since the coordinator already holds the refusal.",
1384
1430
  "checkout.merge-followed": "After an environment's PR merged, the project checkout was fast-forwarded, or `outcome` says why not.",
1385
1431
  "checkout.merge-follow-failed": "Fast-forwarding the project checkout failed, after an environment's PR merged or before mail woke the main coordinator.",
1386
1432
  "checkout.mail-follow": "Before mail woke the main coordinator, the project checkout was fast-forwarded (`fast-forwarded-fetched` when the fetch was slow or failed and the upstream commit already fetched was merged), or `outcome` says why not (`timed-out`, `failed`).",
@@ -1433,7 +1479,8 @@ var REVIEW_LOG_AREAS = defineLogAreas({
1433
1479
  "monitor.task-store-failed": "A pull request could not be recorded on its Kanban task.",
1434
1480
  "monitor.merged-tickets-closed": "The startup sweep moved Kanban tickets whose pull request had merged to done (`count`).",
1435
1481
  "monitor.merged-tickets-close-failed": "The startup sweep closing Kanban tickets whose pull request merged failed; the next backend start retries.",
1436
- "monitor.emit-failed": "A pull request monitor event could not be emitted to its sink."
1482
+ "monitor.emit-failed": "A pull request monitor event could not be emitted to its sink.",
1483
+ "branch-cleanup.kept": "A merge or cleanup kept a pull request's head branch because it is not the branch created for the environment (`reason`)."
1437
1484
  }
1438
1485
  }
1439
1486
  });
@@ -1465,6 +1512,8 @@ var AGENT_ACCOUNTS_LOG_AREAS = defineLogAreas({
1465
1512
  "kept-note.failed": "Recording why a limit stop found no account to move to failed; the stop stands.",
1466
1513
  "container-sync.failed": "Handing a login or account to a container failed; `step` says which part.",
1467
1514
  "last-usage.save-failed": "The last plan usage reading could not be saved; the next save retries.",
1515
+ "shared-usage.save-failed": "The shared usage readings could not be saved; they stay in memory and the next reading saves them.",
1516
+ "shared-usage.record-failed": "A fresh usage reading could not be kept for sharing with other machines; the account's own reading stands.",
1468
1517
  "login-cleanup.failed": "A temporary login could not be cleaned up.",
1469
1518
  "login-renewal.failed": "Renewing an idle account's sign-in to read its usage failed; it is retried after a backoff.",
1470
1519
  "login-renewal.not-extended": "Claude Code ran to renew an idle account's sign-in, but its token is still lapsed.",
@@ -1482,6 +1531,7 @@ var DOCKER_LOG_AREAS = defineLogAreas({
1482
1531
  "git-mirror.mount-unavailable": "A new container gets no project Git mirror, so its clone goes to the remote.",
1483
1532
  "git-mirror.mount-withheld": "A new restricted container gets no project Git mirror because its firewall would not let it reach the project's remote, so it cannot read what the remote serves through the mirror either.",
1484
1533
  "git-mirror.refreshed": "A project's Git mirror was built or updated.",
1534
+ "git-mirror.access-changed": "A project's Git mirror was withdrawn because containers are now given a different credential (another access kind, or a token acting as another or an unreadable account), so no reader keeps what it could not fetch itself.",
1485
1535
  "git-mirror.seeded": "A project's Git mirror was built from its host checkout and only what the remote added to it.",
1486
1536
  "git-mirror.seed-skipped": "A project's host checkout could not seed its Git mirror, so the build downloads everything.",
1487
1537
  "git-mirror.refresh-failed": "A project's Git mirror could not be updated. New clones still work, from the mirror as it was or from the remote.",
@@ -1495,6 +1545,9 @@ var DOCKER_LOG_AREAS = defineLogAreas({
1495
1545
  "git-mirror.clone-fallback": "A new environment could not clone from its project's Git mirror and cloned from the remote.",
1496
1546
  "project-seed.refused": "A project .env, .env.local or opencode.json was not copied into a new container: a link, not a regular file, outside the project, too large or unreadable.",
1497
1547
  "opencode.warm-incomplete": "OpenCode did not finish loading /workspace in a container.",
1548
+ "opencode.listener-replaced": "The process on a container's OpenCode port (`provider`: `opencode` or `opencode2`) is not the server the backend launched and recorded, so its password was withheld and the next start replaces it. `stage` is `request` when the re-check after a refused connection or an unexpected answer found it (to-do 7550); that connection then sends nothing more.",
1549
+ "opencode.project-config-too-large": "A checkout's opencode.json or opencode.jsonc was larger than the limit, so a launched OpenCode server does not read it. File name only.",
1550
+ "opencode.project-config-filtered": "Values were left out of a checkout's OpenCode configuration before a launched server reads it (to-do 7550): counts of plugin keys, `{env:}` and `{file:}` references and dropped instructions (including separate instructionGlob and instructionUrl counts), and the names of files that were not a JSONC object. Never values.",
1498
1551
  "log-driver.unbounded": "The Docker daemon offers neither the local nor the json-file log driver, so new containers keep its default driver, whose log may be uncapped. Written once per backend.",
1499
1552
  "lifecycle-event.reconcile-failed": "Reconciling an environment after a container start or stop event failed; the next status read retries.",
1500
1553
  "login-keeper.pass-failed": "A Claude login keeper pass failed; the next interval retries.",
@@ -1529,6 +1582,17 @@ var DOCKER_LOG_AREAS = defineLogAreas({
1529
1582
  description: "A bridge process was launched in a container, for the first time there or as a relaunch; `provider` names it. A relaunch keeps the run before it in the previous log.",
1530
1583
  essential: true,
1531
1584
  fields: { provider: "label", containerPort: "number" }
1585
+ },
1586
+ "bridge.listener-refused": {
1587
+ description: "The socket listening on a container bridge's port is not the one the bridge the backend started opened (to-do 7250), so its token is not handed out and the next start replaces it. `reason` is a fixed label: `different-socket`, `several-sockets`, `pending` (a start has not recorded its bridge yet, or failed before it did) or `scan-incomplete`.",
1588
+ essential: true,
1589
+ fields: { provider: "label", reason: "label" }
1590
+ },
1591
+ "bridge.listener-adopted": "A running container bridge had no listener record, because a backend from before the record started it, so the socket on its port was recorded as the bridge's; `provider` names it.",
1592
+ "bridge.listener-unrecorded": {
1593
+ description: "A bridge the backend just launched could not be recorded as its port's listener, for the fixed `reason` given (`no-listener`, `several-sockets`, `launch-exited` or `scan-incomplete`); what listens on the port is stopped and the start fails.",
1594
+ essential: true,
1595
+ fields: { provider: "label", reason: "label" }
1532
1596
  }
1533
1597
  }
1534
1598
  },
@@ -1583,7 +1647,8 @@ var MCP_LOG_AREAS = defineLogAreas({
1583
1647
  "listener.port-free": "The Control MCP's fixed port is free again, so it is listening.",
1584
1648
  "state-listener.failed": "A Control MCP state listener threw; the others still run.",
1585
1649
  "delegation.remote-open-failed": "A delegation could not be opened on another node.",
1586
- "delegation.open-failed": "A coordinator delegation could not be opened."
1650
+ "delegation.open-failed": "A coordinator delegation could not be opened.",
1651
+ "delegation.turn-origin-unreadable": "A coordinator's last turn origin could not be read, so its delegated prompt is marked as arising from agent mail."
1587
1652
  }
1588
1653
  },
1589
1654
  "mcp-management": {
@@ -1668,6 +1733,7 @@ var NODES_LOG_AREAS = defineLogAreas({
1668
1733
  "ticket-sync.failed": "A Kanban sync with a node failed; it is retried.",
1669
1734
  "ticket-sync.unknown-project": "A node sent ticket changes for a project that no longer exists here.",
1670
1735
  "ticket-sync.forget-failed": "A detached command node's ticket copies could not be released.",
1736
+ "usage-sync.failed": "Sharing usage readings with a node failed; the next reading or reconnect retries.",
1671
1737
  "fleet-update.requested": "The update policy asked an older leaf to install the command node's version.",
1672
1738
  "fleet-update.failed": "The update policy could not read or update a leaf; it retries later.",
1673
1739
  "fleet-update.policy-load-failed": "The stored update policy could not be read; it is off."
@@ -1759,6 +1825,20 @@ var SCHEDULER_LOG_AREAS = defineLogAreas({
1759
1825
  }
1760
1826
  });
1761
1827
 
1828
+ // ../protocol/src/log-vocabulary/self-improvement.ts
1829
+ var SELF_IMPROVEMENT_LOG_AREAS = defineLogAreas({
1830
+ "self-improvement": {
1831
+ description: "Self-improvement runs: diagnostics and conversation review turned into tickets. Counts and steps only, never conversation text.",
1832
+ events: {
1833
+ "run.started": "A run started; `trigger` is manual, daily or dry-run.",
1834
+ "run.finished": "A run finished; `created`, `verified`, `fixFailed` and `parts` count its tickets, confirmed fixes, failed fixes and conversation parts read.",
1835
+ "run.failed": "A run stopped before it finished; `reason` is a fixed label.",
1836
+ "review.call-failed": "One conversation review call failed; the run carries on and the part is read again next run.",
1837
+ "daily.check-failed": "The daily run check failed; the next check retries."
1838
+ }
1839
+ }
1840
+ });
1841
+
1762
1842
  // ../protocol/src/log-vocabulary/web-app.ts
1763
1843
  var WEB_APP_LOG_AREAS = defineLogAreas({
1764
1844
  "web.app": {
@@ -2094,6 +2174,10 @@ var WEB_SETTINGS_LOG_AREAS = defineLogAreas({
2094
2174
  "web.settings": {
2095
2175
  description: "The settings screens.",
2096
2176
  events: {
2177
+ "self-improvement.status-failed": "Settings → Self-improvement could not read the status.",
2178
+ "self-improvement.projects-failed": "Settings → Self-improvement could not list the projects.",
2179
+ "self-improvement.save-failed": "Settings → Self-improvement could not save a setting.",
2180
+ "self-improvement.run-failed": "Settings → Self-improvement could not start a run.",
2097
2181
  "config.save-failed": "Global settings could not be saved.",
2098
2182
  "config.load-failed": "The settings page could not load the config.",
2099
2183
  "config.reload-failed": "Re-reading the workspace config after a save failed.",
@@ -2263,6 +2347,7 @@ var LOG_VOCABULARY = {
2263
2347
  ...HOST_LOG_AREAS,
2264
2348
  ...TRANSCRIPT_ARTIFACTS_LOG_AREAS,
2265
2349
  ...SCHEDULER_LOG_AREAS,
2350
+ ...SELF_IMPROVEMENT_LOG_AREAS,
2266
2351
  ...WEB_APP_LOG_AREAS,
2267
2352
  ...WEB_BUILD_PIPELINE_LOG_AREAS,
2268
2353
  ...WEB_CHAT_LOG_AREAS,
@@ -2563,6 +2648,14 @@ var SIGNALS = new Set([
2563
2648
  "SIGXFSZ"
2564
2649
  ]);
2565
2650
  var PROVIDERS = new Set(["claude", "codex", "opencode", "cursor", "grok", "acp", "pi"]);
2651
+ var BRIDGE_LISTENER_REASONS = new Set([
2652
+ "different-socket",
2653
+ "several-sockets",
2654
+ "pending",
2655
+ "scan-incomplete",
2656
+ "no-listener",
2657
+ "launch-exited"
2658
+ ]);
2566
2659
  var UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
2567
2660
  var SOURCE = new RegExp(`^(?:claude|codex|opencode|cursor|grok|acp|pi):${UUID}$`, "i");
2568
2661
  var STORAGE_DATABASES = new Set(["main", "ledger", "other"]);
@@ -5525,6 +5618,54 @@ health.get("/health", (c) => {
5525
5618
  });
5526
5619
  var health_default = health;
5527
5620
 
5621
+ // ../protocol/src/node/bounded-wait.ts
5622
+ function boundedWait(work, timeoutMs, options = {}) {
5623
+ return new Promise((resolve, reject) => {
5624
+ let timedOut = false;
5625
+ const timer = setTimeout(() => {
5626
+ timedOut = true;
5627
+ resolve({ settled: false });
5628
+ }, timeoutMs);
5629
+ unrefTimer(timer);
5630
+ Promise.resolve(work).then((value) => {
5631
+ if (!timedOut) {
5632
+ clearTimeout(timer);
5633
+ resolve({ settled: true, value });
5634
+ return;
5635
+ }
5636
+ disposeLate(options.onLate, value);
5637
+ }, (error) => {
5638
+ if (!timedOut) {
5639
+ clearTimeout(timer);
5640
+ reject(error);
5641
+ }
5642
+ });
5643
+ });
5644
+ }
5645
+ async function boundedWaitOrThrow(work, timeoutMs, timeoutError, options = {}) {
5646
+ const result = await boundedWait(work, timeoutMs, options);
5647
+ if (!result.settled)
5648
+ throw timeoutError();
5649
+ return result.value;
5650
+ }
5651
+ function unrefTimer(timer) {
5652
+ const handle = timer;
5653
+ if (typeof handle === "object" && typeof handle.unref === "function")
5654
+ handle.unref();
5655
+ }
5656
+ function disposeLate(onLate, value) {
5657
+ if (!onLate)
5658
+ return;
5659
+ try {
5660
+ const disposal = onLate(value);
5661
+ if (disposal && typeof disposal.then === "function") {
5662
+ Promise.resolve(disposal).catch(() => {
5663
+ return;
5664
+ });
5665
+ }
5666
+ } catch {}
5667
+ }
5668
+
5528
5669
  // ../protocol/src/agent-platforms.ts
5529
5670
  var AGENT_PLATFORMS = Object.freeze([
5530
5671
  "claude",
@@ -5717,6 +5858,58 @@ var PROTECTED_SEGMENTS = new Set([
5717
5858
  ".mcp.json"
5718
5859
  ]);
5719
5860
 
5861
+ // ../protocol/src/agent-mail.ts
5862
+ var AGENT_MAIL_MAX_BODY_BYTES = 32 * 1024;
5863
+ var AGENT_MAIL_MAX_STORE_BYTES = 32 * 1024 * 1024;
5864
+ var AGENT_MAIL_DEFAULT_RETENTION_DAYS = 14;
5865
+ var AGENT_MAIL_MAX_ATTACHMENT_BYTES = 8 * 1024 * 1024;
5866
+ var AGENT_MAIL_MAX_TOTAL_ATTACHMENT_BYTES = 32 * 1024 * 1024;
5867
+ var AGENT_MAIL_DEFAULT_AUTONOMOUS_WAKE_BUDGET = 16;
5868
+ var AGENT_MAIL_DEFAULT_HOURLY_WAKE_LIMIT = 40;
5869
+ var AGENT_MAIL_TOOL_NAMES = Object.freeze([
5870
+ "list_mailboxes",
5871
+ "send_message",
5872
+ "check_inbox",
5873
+ "read_message",
5874
+ "ack_message",
5875
+ "reply_message",
5876
+ "get_message_status"
5877
+ ]);
5878
+ var DEFAULT_AGENT_MESSAGING_SETTINGS = Object.freeze({
5879
+ enabled: true,
5880
+ allowCrossProject: false,
5881
+ defaultInjectPolicy: "off",
5882
+ wakePeers: false,
5883
+ autonomousWakeBudget: AGENT_MAIL_DEFAULT_AUTONOMOUS_WAKE_BUDGET,
5884
+ hourlyWakeLimit: AGENT_MAIL_DEFAULT_HOURLY_WAKE_LIMIT,
5885
+ coordinatorStatusWakes: "settled",
5886
+ retentionDays: AGENT_MAIL_DEFAULT_RETENTION_DAYS,
5887
+ paused: false
5888
+ });
5889
+ function agentMailCapabilities(tabType, agent, locked = true) {
5890
+ if (tabType === "agent-native") {
5891
+ if (!locked || !agent)
5892
+ return { canPull: false, canSend: false, canInject: false };
5893
+ if (agent === "claude" || agent === "codex" || agent === "opencode" || agent === "pi" || agent === "cursor" || agent === "grok") {
5894
+ return { canPull: true, canSend: true, canInject: true };
5895
+ }
5896
+ return { canPull: false, canSend: false, canInject: false };
5897
+ }
5898
+ if (tabType === "claude-tmux")
5899
+ return { canPull: true, canSend: true, canInject: true };
5900
+ if (tabType === "pipeline-worker") {
5901
+ return agent ? { canPull: true, canSend: true, canInject: true } : { canPull: false, canSend: false, canInject: false };
5902
+ }
5903
+ if (["claude", "codex", "opencode"].includes(tabType)) {
5904
+ return { canPull: true, canSend: true, canInject: false };
5905
+ }
5906
+ if (["cursor", "grok", "pi"].includes(tabType)) {
5907
+ return { canPull: false, canSend: false, canInject: false };
5908
+ }
5909
+ return { canPull: false, canSend: false, canInject: false };
5910
+ }
5911
+ var NATIVE_AGENT_MAIL_CAPABILITIES = Object.freeze(Object.fromEntries(AGENT_PLATFORMS.map((agent) => [agent, agentMailCapabilities("agent-native", agent)])));
5912
+
5720
5913
  // ../protocol/src/review-evidence-frames.ts
5721
5914
  var COORDINATOR_WORKER_NO_PR_INSTRUCTION = "Do not open a pull request, even if the prompt below asks you to: commit your work and report back. Orkestrator raises the pull request from a PR tab once the work has been reviewed.";
5722
5915
  var COORDINATOR_WORKER_VALIDATION_INSTRUCTION = "Run the focused checks your changes need and report them. When the prompt below says review follows, leave the required full test suite, typecheck, lint and build passes to review preparation unless it explicitly asks you to run them. When no review follows or the prompt does not say, follow the repository's validation requirements before handoff. Report any required full validation you did not run; do not assume a later review will run it.";
@@ -5846,6 +6039,21 @@ var MCP_TOOL_ANNOTATION_KEYS = Object.freeze({
5846
6039
  idempotent: "idempotentHint",
5847
6040
  openWorld: "openWorldHint"
5848
6041
  });
6042
+ function toolHintsFrom(value, keyFor) {
6043
+ if (typeof value !== "object" || value === null || Array.isArray(value))
6044
+ return;
6045
+ const source = value;
6046
+ const hints = {};
6047
+ for (const key of TOOL_HINT_KEYS) {
6048
+ const declared = source[keyFor(key)];
6049
+ if (typeof declared === "boolean")
6050
+ hints[key] = declared;
6051
+ }
6052
+ return Object.keys(hints).length > 0 ? hints : undefined;
6053
+ }
6054
+ function parseAgentInteractionToolHints(value) {
6055
+ return toolHintsFrom(value, (key) => key);
6056
+ }
5849
6057
  var UNATTENDED_POLICY_INSTRUCTION = "This is a non-interactive build session: no user can answer a provider input request. " + "If input is unavailable or declined, choose the safest likely assumption yourself, " + "state that assumption, and continue. Never treat the absence of a person as authorization.";
5850
6058
  var INTERACTIVE_AGENT_INTERACTION_POLICY = Object.freeze({
5851
6059
  version: AGENT_INTERACTION_POLICY_VERSION,
@@ -6361,6 +6569,11 @@ var BACKGROUND_CAPABLE_SHELL_TOOL_NAMES = new Set([
6361
6569
  "run_terminal_cmd",
6362
6570
  "execute_command"
6363
6571
  ]);
6572
+ var NATIVE_AGENT_BRANCH_LIST_LIMITS = Object.freeze({
6573
+ branches: 50,
6574
+ promptChars: 280,
6575
+ entryIdChars: 512
6576
+ });
6364
6577
  var NATIVE_AGENT_COMMAND_EXECUTION_KINDS = [
6365
6578
  "provider-prompt",
6366
6579
  "provider-command",
@@ -6630,6 +6843,7 @@ function sessionHealth(session) {
6630
6843
  }
6631
6844
 
6632
6845
  // ../protocol/src/plan-usage.ts
6846
+ var PLAN_USAGE_DISPLAY_STALE_MS = 30 * 60000;
6633
6847
  var WEEK_MINUTES = 7 * 24 * 60;
6634
6848
  var CLAUDE_PLAN_WINDOW_LABELS = {
6635
6849
  five_hour: { label: "5-hour limit", windowMinutes: 300 },
@@ -6858,8 +7072,18 @@ function revisedRowsReconciliationToken(overflowVersion, omitted) {
6858
7072
  }
6859
7073
 
6860
7074
  // ../../bridges/claude-bridge/src/services/session-preferences.ts
6861
- import { mkdir, open, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
6862
- import { join as join2 } from "node:path";
7075
+ import {
7076
+ link,
7077
+ mkdir,
7078
+ open,
7079
+ readFile,
7080
+ readdir,
7081
+ rename,
7082
+ rm,
7083
+ stat,
7084
+ writeFile
7085
+ } from "node:fs/promises";
7086
+ import { basename, dirname, join as join2 } from "node:path";
6863
7087
 
6864
7088
  // ../../bridges/claude-bridge/src/services/claude-home.ts
6865
7089
  import { homedir } from "node:os";
@@ -7119,6 +7343,41 @@ function lockMetadata() {
7119
7343
  const identity = currentProcessIdentity();
7120
7344
  return JSON.stringify({ token: crypto.randomUUID(), ...identity });
7121
7345
  }
7346
+ var beforeOwnedFilePublishForTesting = null;
7347
+ var LINK_UNSUPPORTED_CODES = new Set(["ENOTSUP", "EOPNOTSUPP", "ENOSYS", "EPERM"]);
7348
+ async function createOwnedFile(path) {
7349
+ const staging = `${path}.${crypto.randomUUID()}.owner`;
7350
+ const handle = await open(staging, "wx", 384);
7351
+ try {
7352
+ await handle.writeFile(lockMetadata());
7353
+ await beforeOwnedFilePublishForTesting?.();
7354
+ try {
7355
+ await link(staging, path);
7356
+ } catch (error) {
7357
+ if (!LINK_UNSUPPORTED_CODES.has(errorCode(error) ?? ""))
7358
+ throw error;
7359
+ await handle.close().catch(() => {});
7360
+ return await createOwnedFileInPlace(path);
7361
+ }
7362
+ return handle;
7363
+ } catch (error) {
7364
+ await handle.close().catch(() => {});
7365
+ throw error;
7366
+ } finally {
7367
+ await rm(staging, { force: true }).catch(() => {});
7368
+ }
7369
+ }
7370
+ async function createOwnedFileInPlace(path) {
7371
+ const handle = await open(path, "wx", 384);
7372
+ try {
7373
+ await handle.writeFile(lockMetadata());
7374
+ return handle;
7375
+ } catch (error) {
7376
+ await handle.close().catch(() => {});
7377
+ await rm(path, { force: true }).catch(() => {});
7378
+ throw error;
7379
+ }
7380
+ }
7122
7381
  function parseLockMetadata(raw) {
7123
7382
  try {
7124
7383
  const parsed = JSON.parse(raw);
@@ -7171,15 +7430,7 @@ async function recoverStaleLock(lockPath, candidate) {
7171
7430
  const recoveryPath = `${lockPath}.recover-${candidate.dev}-${candidate.ino}`;
7172
7431
  let recoveryHandle;
7173
7432
  try {
7174
- recoveryHandle = await open(recoveryPath, "wx", 384);
7175
- try {
7176
- await recoveryHandle.writeFile(lockMetadata());
7177
- } catch (error) {
7178
- await recoveryHandle.close().catch(() => {});
7179
- recoveryHandle = undefined;
7180
- await rm(recoveryPath, { force: true }).catch(() => {});
7181
- throw error;
7182
- }
7433
+ recoveryHandle = await createOwnedFile(recoveryPath);
7183
7434
  } catch (error) {
7184
7435
  if (errorCode(error) === "EEXIST") {
7185
7436
  const abandoned = await readLockSnapshot(recoveryPath);
@@ -7211,22 +7462,31 @@ async function recoverStaleLock(lockPath, candidate) {
7211
7462
  } catch {}
7212
7463
  }
7213
7464
  }
7465
+ async function reclaimOwnerStagingFiles(lockPath) {
7466
+ const directory = dirname(lockPath);
7467
+ const prefix = `${basename(lockPath)}.`;
7468
+ for (const name of await readdir(directory)) {
7469
+ if (!name.startsWith(prefix) || !/\.[0-9a-f-]{36}\.owner$/.test(name))
7470
+ continue;
7471
+ const path = join2(directory, name);
7472
+ const candidate = await readLockSnapshot(path);
7473
+ if (!candidate || !snapshotIsRecoverable(candidate))
7474
+ continue;
7475
+ const current = await readLockSnapshot(path);
7476
+ if (current && current.dev === candidate.dev && current.ino === candidate.ino && snapshotIsRecoverable(current)) {
7477
+ await rm(path, { force: true });
7478
+ }
7479
+ }
7480
+ }
7214
7481
  async function withPreferenceFileLock(path, operation) {
7215
7482
  await mkdir(claudeSessionPreferencesDir(), { recursive: true });
7216
7483
  const lockPath = `${path}.lock`;
7484
+ await reclaimOwnerStagingFiles(lockPath);
7217
7485
  const startedAt = Date.now();
7218
7486
  let handle;
7219
7487
  while (!handle) {
7220
7488
  try {
7221
- handle = await open(lockPath, "wx", 384);
7222
- try {
7223
- await handle.writeFile(lockMetadata());
7224
- } catch (error) {
7225
- await handle.close().catch(() => {});
7226
- handle = undefined;
7227
- await rm(lockPath, { force: true }).catch(() => {});
7228
- throw error;
7229
- }
7489
+ handle = await createOwnedFile(lockPath);
7230
7490
  } catch (error) {
7231
7491
  if (errorCode(error) !== "EEXIST")
7232
7492
  throw error;
@@ -7397,6 +7657,10 @@ async function readSessionPreferences(sdkSessionId) {
7397
7657
  return parsePreferences(raw) ?? unavailablePreferences();
7398
7658
  }
7399
7659
  async function writePreferencesFile(path, preferences) {
7660
+ if (Object.values(preferences).every((value) => value === undefined)) {
7661
+ await rm(path, { force: true });
7662
+ return;
7663
+ }
7400
7664
  await mkdir(claudeSessionPreferencesDir(), { recursive: true });
7401
7665
  const tempPath = `${path}.${process.pid}.tmp`;
7402
7666
  try {
@@ -7495,18 +7759,8 @@ class ContextUsageRequestTimeoutError extends Error {
7495
7759
  this.name = "ContextUsageRequestTimeoutError";
7496
7760
  }
7497
7761
  }
7498
- async function withControlRequestTimeout(request, timeoutMs, createTimeoutError) {
7499
- let timeout;
7500
- const timeoutPromise = new Promise((_, reject) => {
7501
- timeout = setTimeout(() => reject(createTimeoutError()), timeoutMs);
7502
- timeout.unref?.();
7503
- });
7504
- try {
7505
- return await Promise.race([request, timeoutPromise]);
7506
- } finally {
7507
- if (timeout)
7508
- clearTimeout(timeout);
7509
- }
7762
+ function withControlRequestTimeout(request, timeoutMs, createTimeoutError) {
7763
+ return boundedWaitOrThrow(request, timeoutMs, createTimeoutError);
7510
7764
  }
7511
7765
  function touchSession(session) {
7512
7766
  session.lastAccessedAt = Date.now();
@@ -8540,7 +8794,7 @@ function withReadOnlyGitConfig(turnPolicy, environment) {
8540
8794
  import { createHash as createHash4, randomBytes } from "node:crypto";
8541
8795
  import {
8542
8796
  mkdir as mkdir2,
8543
- readdir,
8797
+ readdir as readdir2,
8544
8798
  readFile as readFile3,
8545
8799
  realpath,
8546
8800
  rename as rename2,
@@ -8711,7 +8965,7 @@ async function mirrorSkillSource(source, root) {
8711
8965
  return { path, names: skills.map((skill) => skill.name) };
8712
8966
  }
8713
8967
  async function readSkills(dir) {
8714
- const entries = (await readdir(dir)).filter((name) => !name.startsWith(".")).sort();
8968
+ const entries = (await readdir2(dir)).filter((name) => !name.startsWith(".")).sort();
8715
8969
  const skills = [];
8716
8970
  const names = new Set;
8717
8971
  for (const entry of entries) {
@@ -8733,7 +8987,7 @@ async function readSkills(dir) {
8733
8987
  return skills;
8734
8988
  }
8735
8989
  async function readSkill(skillDir, dirName) {
8736
- const entries = await readdir(skillDir);
8990
+ const entries = await readdir2(skillDir);
8737
8991
  const skillFile = entries.find((entry) => entry === "SKILL.md");
8738
8992
  if (!skillFile)
8739
8993
  return;
@@ -8834,7 +9088,7 @@ async function writeMirror(root, path, plugin, skills) {
8834
9088
  }
8835
9089
  async function pruneOldMirrors(root, plugin, current) {
8836
9090
  try {
8837
- const old = await Promise.all((await readdir(root)).filter((name) => name.startsWith(`${plugin}-`) && join3(root, name) !== current).map(async (name) => ({
9091
+ const old = await Promise.all((await readdir2(root)).filter((name) => name.startsWith(`${plugin}-`) && join3(root, name) !== current).map(async (name) => ({
8838
9092
  path: join3(root, name),
8839
9093
  mtimeMs: (await stat2(join3(root, name)).catch(() => {
8840
9094
  return;
@@ -8848,7 +9102,7 @@ async function pruneOldMirrors(root, plugin, current) {
8848
9102
  }
8849
9103
 
8850
9104
  // ../../bridges/claude-bridge/src/services/plugin-config.ts
8851
- import { readdir as readdir2, access } from "node:fs/promises";
9105
+ import { readdir as readdir3, access } from "node:fs/promises";
8852
9106
  import { join as join4 } from "node:path";
8853
9107
 
8854
9108
  // ../protocol/src/node/claude-plugin-set.ts
@@ -9056,7 +9310,7 @@ async function scanCliPluginsDirectory(pluginsDir) {
9056
9310
  return [];
9057
9311
  }
9058
9312
  try {
9059
- const entries = await readdir2(pluginsDir, { withFileTypes: true });
9313
+ const entries = await readdir3(pluginsDir, { withFileTypes: true });
9060
9314
  const plugins = [];
9061
9315
  for (const entry of entries) {
9062
9316
  if (!entry.isDirectory()) {
@@ -9298,7 +9552,7 @@ import { join as join6 } from "node:path";
9298
9552
  // ../protocol/src/node/coordinator-read-boundary.ts
9299
9553
  import { realpathSync } from "node:fs";
9300
9554
  import { homedir as homedir2 } from "node:os";
9301
- import { dirname, isAbsolute as isAbsolute2, join as join5, parse, resolve as resolve2, sep } from "node:path";
9555
+ import { dirname as dirname2, isAbsolute as isAbsolute2, join as join5, parse, resolve as resolve2, sep } from "node:path";
9302
9556
  function canonicalPath(path) {
9303
9557
  let existing = path;
9304
9558
  const tail = [];
@@ -9306,7 +9560,7 @@ function canonicalPath(path) {
9306
9560
  try {
9307
9561
  return join5(realpathSync.native(existing), ...tail.reverse());
9308
9562
  } catch {
9309
- const parent = dirname(existing);
9563
+ const parent = dirname2(existing);
9310
9564
  if (parent === existing)
9311
9565
  return path;
9312
9566
  tail.push(existing.slice(parent.length).replace(/^[/\\]+/, ""));
@@ -10115,17 +10369,22 @@ function probeDetail(stderr) {
10115
10369
  `).map((entry) => entry.trim()).find(Boolean) ?? "no error output";
10116
10370
  return line.length > 200 ? `${line.slice(0, 199)}…` : line;
10117
10371
  }
10118
- var UNAVAILABLE = "Claude's command sandbox cannot run commands on this host";
10372
+ function runningInContainer() {
10373
+ return existsSync("/.dockerenv") || existsSync("/run/.containerenv");
10374
+ }
10119
10375
  function probeClaudeLinuxSandbox(dependencies = {}) {
10120
10376
  const onPath = dependencies.onPath ?? ((name) => executableOnPath(name));
10121
10377
  const run = dependencies.run ?? runProbeCommand;
10122
10378
  const appArmorBwrapProfile = dependencies.appArmorBwrapProfile ?? appArmorBwrapProfileInstalled;
10379
+ const container = (dependencies.inContainer ?? runningInContainer)();
10380
+ const UNAVAILABLE = `Claude's command sandbox cannot run commands ${container ? "in this container" : "on this host"}`;
10123
10381
  const missing = CLAUDE_LINUX_SANDBOX_PROGRAMS.filter((name) => !onPath(name));
10124
10382
  if (missing.length > 0) {
10383
+ const absent = `${missing.join(" and ")} ${missing.length === 1 ? "is" : "are"}`;
10125
10384
  return {
10126
10385
  available: false,
10127
10386
  failure: "missing-programs",
10128
- reason: `${UNAVAILABLE}: the Claude CLI's Linux sandbox needs bubblewrap and socat on PATH, and ${missing.join(" and ")} ${missing.length === 1 ? "is" : "are"} missing. Install the bubblewrap and socat packages.`
10387
+ reason: container ? `${UNAVAILABLE}: the Claude CLI's Linux sandbox needs bubblewrap and socat on PATH, and ${absent} not in this container's image.` : `${UNAVAILABLE}: the Claude CLI's Linux sandbox needs bubblewrap and socat on PATH, and ${absent} missing. Install the bubblewrap and socat packages.`
10129
10388
  };
10130
10389
  }
10131
10390
  if (!onPath("unshare")) {
@@ -12691,13 +12950,18 @@ async function assertClaudeRuntimeAccepts(session, options, resources, readOnlyC
12691
12950
  }
12692
12951
  var MAX_RUNTIME_TOOL_OWNERS = 4096;
12693
12952
  var DRAINING_RUNTIME_EXIT_WAIT_MS = 5000;
12953
+ var lastClaudeRuntimeGeneration = 0;
12694
12954
  function createClaudeRuntime(input) {
12695
12955
  let markEnded;
12696
12956
  const ended = new Promise((resolve) => {
12697
12957
  markEnded = resolve;
12698
12958
  });
12959
+ lastClaudeRuntimeGeneration += 1;
12960
+ const generation = lastClaudeRuntimeGeneration;
12961
+ input.session.claudeRuntimeGeneration = generation;
12699
12962
  const runtime = {
12700
12963
  session: input.session,
12964
+ generation,
12701
12965
  control: input.control,
12702
12966
  input: input.heldInput,
12703
12967
  abortController: input.abortController,
@@ -12810,20 +13074,7 @@ async function retireDrainingClaudeRuntime(session, waitMs = DRAINING_RUNTIME_EX
12810
13074
  return;
12811
13075
  if (runtime.state === "open")
12812
13076
  drainClaudeRuntime(runtime);
12813
- const waitForEnd = async () => {
12814
- let timer;
12815
- try {
12816
- return await Promise.race([
12817
- runtime.ended.then(() => true),
12818
- new Promise((resolve) => {
12819
- timer = setTimeout(() => resolve(false), waitMs);
12820
- timer.unref?.();
12821
- })
12822
- ]);
12823
- } finally {
12824
- clearTimeout(timer);
12825
- }
12826
- };
13077
+ const waitForEnd = async () => (await boundedWait(runtime.ended, waitMs)).settled;
12827
13078
  if (await waitForEnd())
12828
13079
  return;
12829
13080
  try {
@@ -12891,7 +13142,7 @@ import { isAbsolute as isAbsolute4, join as join12, relative, resolve as resolve
12891
13142
 
12892
13143
  // ../protocol/src/node/command-change-journal.ts
12893
13144
  import { appendFile, mkdir as mkdir3, readFile as readFile5, rename as rename3, rm as rm3, stat as stat4, writeFile as writeFile3 } from "node:fs/promises";
12894
- import { dirname as dirname2 } from "node:path";
13145
+ import { dirname as dirname3 } from "node:path";
12895
13146
  var MAX_JOURNAL_ENTRIES = 1000;
12896
13147
  var MAX_JOURNAL_FILES_PER_ENTRY = 20;
12897
13148
  var MAX_JOURNAL_PATH_LENGTH = 1024;
@@ -12964,7 +13215,7 @@ class CommandChangeJournal {
12964
13215
  const line = `${JSON.stringify({ id, change: bounded })}
12965
13216
  `;
12966
13217
  this.writes = this.writes.then(async () => {
12967
- await mkdir3(dirname2(this.path), { recursive: true, mode: 448 });
13218
+ await mkdir3(dirname3(this.path), { recursive: true, mode: 448 });
12968
13219
  if (!this.sizeChecked) {
12969
13220
  this.sizeChecked = true;
12970
13221
  const existing = await stat4(this.path).catch(() => {
@@ -13135,7 +13386,8 @@ var SHARED_RULES = [
13135
13386
  ["auth-failed", /terminal prompts disabled|invalid username or password|bad credentials/i],
13136
13387
  ["auth-failed", /permission denied \(|permission to \S+ denied|host key verification failed/i],
13137
13388
  ["auth-failed", /gh auth login|not logged in|unauthorized|http 401|returned error: 40[13]/i],
13138
- ["network-failed", /could not resolve host|connection (?:timed out|refused|reset)/i],
13389
+ ["network-failed", /could not resolve host|(?:connection|operation) timed out/i],
13390
+ ["network-failed", /connection (?:refused|reset)/i],
13139
13391
  ["network-failed", /network is unreachable|no route to host|temporary failure in name/i],
13140
13392
  ["network-failed", /early eof|failed to connect|remote end hung up/i],
13141
13393
  ["network-failed", /unable to access ['"]?https?:\/\//i],
@@ -16509,19 +16761,11 @@ async function closeTransientRewindQuery(control, onShutdown) {
16509
16761
  await control.return();
16510
16762
  onShutdown();
16511
16763
  });
16512
- let shutdownTimeout;
16513
16764
  try {
16514
- await Promise.race([
16515
- shutdown,
16516
- new Promise((_, reject) => {
16517
- shutdownTimeout = setTimeout(() => reject(new Error("shutdown pending")), REWIND_SHUTDOWN_TIMEOUT_MS);
16518
- })
16519
- ]);
16765
+ await boundedWaitOrThrow(shutdown, REWIND_SHUTDOWN_TIMEOUT_MS, () => new Error("shutdown pending"));
16520
16766
  } catch (error) {
16521
16767
  debugLog("[session-manager] Failed to confirm rewind query shutdown:", error);
16522
16768
  throw sessionOperationError("conflict", "Claude file rewind shutdown is pending; retry after it stops");
16523
- } finally {
16524
- clearTimeout(shutdownTimeout);
16525
16769
  }
16526
16770
  }
16527
16771
  async function rewindViaTransientQuery(sdkSessionId, persistedMessageId, dryRun, onShutdown = () => {
@@ -18279,58 +18523,6 @@ import { query as query2 } from "@anthropic-ai/claude-agent-sdk";
18279
18523
  import { createHash as createHash9 } from "node:crypto";
18280
18524
  import { join as join13 } from "node:path";
18281
18525
 
18282
- // ../protocol/src/agent-mail.ts
18283
- var AGENT_MAIL_MAX_BODY_BYTES = 32 * 1024;
18284
- var AGENT_MAIL_MAX_STORE_BYTES = 32 * 1024 * 1024;
18285
- var AGENT_MAIL_DEFAULT_RETENTION_DAYS = 14;
18286
- var AGENT_MAIL_MAX_ATTACHMENT_BYTES = 8 * 1024 * 1024;
18287
- var AGENT_MAIL_MAX_TOTAL_ATTACHMENT_BYTES = 32 * 1024 * 1024;
18288
- var AGENT_MAIL_DEFAULT_AUTONOMOUS_WAKE_BUDGET = 16;
18289
- var AGENT_MAIL_DEFAULT_HOURLY_WAKE_LIMIT = 40;
18290
- var AGENT_MAIL_TOOL_NAMES = Object.freeze([
18291
- "list_mailboxes",
18292
- "send_message",
18293
- "check_inbox",
18294
- "read_message",
18295
- "ack_message",
18296
- "reply_message",
18297
- "get_message_status"
18298
- ]);
18299
- var DEFAULT_AGENT_MESSAGING_SETTINGS = Object.freeze({
18300
- enabled: true,
18301
- allowCrossProject: false,
18302
- defaultInjectPolicy: "off",
18303
- wakePeers: false,
18304
- autonomousWakeBudget: AGENT_MAIL_DEFAULT_AUTONOMOUS_WAKE_BUDGET,
18305
- hourlyWakeLimit: AGENT_MAIL_DEFAULT_HOURLY_WAKE_LIMIT,
18306
- coordinatorStatusWakes: "settled",
18307
- retentionDays: AGENT_MAIL_DEFAULT_RETENTION_DAYS,
18308
- paused: false
18309
- });
18310
- function agentMailCapabilities(tabType, agent, locked = true) {
18311
- if (tabType === "agent-native") {
18312
- if (!locked || !agent)
18313
- return { canPull: false, canSend: false, canInject: false };
18314
- if (agent === "claude" || agent === "codex" || agent === "opencode" || agent === "pi" || agent === "cursor" || agent === "grok") {
18315
- return { canPull: true, canSend: true, canInject: true };
18316
- }
18317
- return { canPull: false, canSend: false, canInject: false };
18318
- }
18319
- if (tabType === "claude-tmux")
18320
- return { canPull: true, canSend: true, canInject: true };
18321
- if (tabType === "pipeline-worker") {
18322
- return agent ? { canPull: true, canSend: true, canInject: true } : { canPull: false, canSend: false, canInject: false };
18323
- }
18324
- if (["claude", "codex", "opencode"].includes(tabType)) {
18325
- return { canPull: true, canSend: true, canInject: false };
18326
- }
18327
- if (["cursor", "grok", "pi"].includes(tabType)) {
18328
- return { canPull: false, canSend: false, canInject: false };
18329
- }
18330
- return { canPull: false, canSend: false, canInject: false };
18331
- }
18332
- var NATIVE_AGENT_MAIL_CAPABILITIES = Object.freeze(Object.fromEntries(AGENT_PLATFORMS.map((agent) => [agent, agentMailCapabilities("agent-native", agent)])));
18333
-
18334
18526
  // ../protocol/src/transcript-artifacts.ts
18335
18527
  var ARTIFACT_TOOL_NAMES = Object.freeze([
18336
18528
  "create_artifact",
@@ -18628,27 +18820,15 @@ function liveClaudeControls() {
18628
18820
  }
18629
18821
  async function readFromLiveClaude(read, timeoutMs = LIVE_CLAUDE_READ_TIMEOUT_MS) {
18630
18822
  for (const control of liveClaudeControls()) {
18631
- let timer;
18632
18823
  try {
18633
18824
  const answer = read(control);
18634
18825
  if (answer === undefined)
18635
18826
  continue;
18636
- answer.catch(() => {
18637
- return;
18638
- });
18639
- const value = await Promise.race([
18640
- answer,
18641
- new Promise((resolve) => {
18642
- timer = setTimeout(() => resolve(undefined), timeoutMs);
18643
- timer.unref?.();
18644
- })
18645
- ]);
18646
- if (value !== undefined)
18647
- return value;
18827
+ const outcome = await boundedWait(answer, timeoutMs);
18828
+ if (outcome.settled && outcome.value !== undefined)
18829
+ return outcome.value;
18648
18830
  } catch (error) {
18649
18831
  debugLog("[live-claude-control] A running CLI could not answer:", error);
18650
- } finally {
18651
- clearTimeout(timer);
18652
18832
  }
18653
18833
  }
18654
18834
  return;
@@ -18948,7 +19128,6 @@ function fallbackCatalog() {
18948
19128
  }
18949
19129
  async function probeModels(at) {
18950
19130
  let q;
18951
- let timer;
18952
19131
  try {
18953
19132
  const cwd = process.env.CWD || process.cwd();
18954
19133
  debugLog("[session-manager] Fetching supported models", { cwd });
@@ -18967,13 +19146,7 @@ async function probeModels(at) {
18967
19146
  answer.catch(() => {
18968
19147
  return;
18969
19148
  });
18970
- const [models, account] = await Promise.race([
18971
- answer,
18972
- new Promise((_resolve, reject) => {
18973
- timer = setTimeout(() => reject(new Error("The model probe did not answer in time")), CLAUDE_MODEL_PROBE_TIMEOUT_MS);
18974
- timer.unref?.();
18975
- })
18976
- ]);
19149
+ const [models, account] = await boundedWaitOrThrow(answer, CLAUDE_MODEL_PROBE_TIMEOUT_MS, () => new Error("The model probe did not answer in time"));
18977
19150
  debugLog("[session-manager] Supported models fetched", { count: models.length });
18978
19151
  await rememberModels(models, account, at);
18979
19152
  return { source: "sdk", models: catalogModels(models) };
@@ -18981,7 +19154,6 @@ async function probeModels(at) {
18981
19154
  log11.warn("models.fetch-failed", { error: formatLogError(error) });
18982
19155
  return fallbackCatalog();
18983
19156
  } finally {
18984
- clearTimeout(timer);
18985
19157
  if (q?.return) {
18986
19158
  try {
18987
19159
  await q.return();
@@ -20152,7 +20324,6 @@ async function probeCommands(session, force) {
20152
20324
  async function runDiscoveryProbe(config) {
20153
20325
  const env = await runtimeEnvironmentForAgentQuery();
20154
20326
  let probe;
20155
- let timer;
20156
20327
  try {
20157
20328
  probe = controlOnlyQuery({
20158
20329
  cwd: config.cwd,
@@ -20166,18 +20337,12 @@ async function runDiscoveryProbe(config) {
20166
20337
  const version = typeof probe.initializationResult === "function" ? probe.initializationResult().then((result) => result?.claude_code_version).catch(() => {
20167
20338
  return;
20168
20339
  }) : Promise.resolve(undefined);
20169
- const timeout = new Promise((_, reject) => {
20170
- timer = setTimeout(() => reject(new Error("Claude command discovery timed out")), COMMAND_PROBE_TIMEOUT_MS);
20171
- timer.unref?.();
20172
- });
20173
20340
  read.catch(() => {
20174
20341
  return;
20175
20342
  });
20176
- const [commands, cliVersion] = await Promise.race([Promise.all([read, version]), timeout]);
20343
+ const [commands, cliVersion] = await boundedWaitOrThrow(Promise.all([read, version]), COMMAND_PROBE_TIMEOUT_MS, () => new Error("Claude command discovery timed out"));
20177
20344
  return { commands: sdkRows(commands), ...cliVersion ? { cliVersion } : {} };
20178
20345
  } finally {
20179
- if (timer)
20180
- clearTimeout(timer);
20181
20346
  await Promise.resolve(probe?.close()).catch(() => {
20182
20347
  return;
20183
20348
  });
@@ -21621,7 +21786,7 @@ function webFetchHost(input) {
21621
21786
  return;
21622
21787
  }
21623
21788
  }
21624
- async function requestClaudeToolApproval(sessionId, toolName, input, permissionContext) {
21789
+ async function requestClaudeToolApproval(sessionId, toolName, input, permissionContext, toolHints) {
21625
21790
  const now = Date.now();
21626
21791
  const path = bounded2(input.file_path ?? input.notebook_path);
21627
21792
  const command = bounded2(input.command);
@@ -21674,6 +21839,7 @@ async function requestClaudeToolApproval(sessionId, toolName, input, permissionC
21674
21839
  ...networkHost ? { networkHost } : {},
21675
21840
  ...ruleEligible ? { ruleEligible: true } : {},
21676
21841
  ...humanRequired ? { humanRequired: true } : {},
21842
+ ...toolHints && mcpServer && toolName.startsWith("mcp__") ? { toolHints } : {},
21677
21843
  ...proposedCommandPrefix ? { proposedCommandPrefix } : {}
21678
21844
  };
21679
21845
  const outcome = await parkInteraction(request, permissionContext?.signal);
@@ -23369,6 +23535,46 @@ async function handleTurnMessage(turn, message) {
23369
23535
  await handled;
23370
23536
  }
23371
23537
 
23538
+ // ../../bridges/claude-bridge/src/services/claude-mcp-tool-hints.ts
23539
+ var CLAUDE_MCP_TOOL_HINTS_TIMEOUT_MS = 2000;
23540
+ function claudeMcpNameSegment(name) {
23541
+ return name.replace(/[^A-Za-z0-9_-]/g, "_");
23542
+ }
23543
+ function claudeMcpToolHintsFromStatus(statuses, serverName, toolName) {
23544
+ if (!toolName.startsWith("mcp__") || serverName.length === 0)
23545
+ return;
23546
+ const servers = statuses.filter((status) => status?.name === serverName);
23547
+ if (servers.length !== 1)
23548
+ return;
23549
+ const prefix = `mcp__${claudeMcpNameSegment(serverName)}__`;
23550
+ if (!toolName.startsWith(prefix))
23551
+ return;
23552
+ const tools = Array.isArray(servers[0].tools) ? servers[0].tools : [];
23553
+ const matches = tools.filter((tool) => typeof tool?.name === "string" && tool.name.length > 0 && prefix + claudeMcpNameSegment(tool.name) === toolName);
23554
+ if (matches.length !== 1)
23555
+ return;
23556
+ return parseAgentInteractionToolHints(matches[0].annotations);
23557
+ }
23558
+ async function readClaudeMcpToolHints(control, serverName, toolName, timeoutMs = CLAUDE_MCP_TOOL_HINTS_TIMEOUT_MS) {
23559
+ if (!control?.mcpServerStatus || !serverName || !toolName.startsWith("mcp__"))
23560
+ return;
23561
+ let timer;
23562
+ try {
23563
+ const statuses = await Promise.race([
23564
+ control.mcpServerStatus(),
23565
+ new Promise((resolve) => {
23566
+ timer = setTimeout(() => resolve(undefined), timeoutMs);
23567
+ })
23568
+ ]);
23569
+ return Array.isArray(statuses) ? claudeMcpToolHintsFromStatus(statuses, serverName, toolName) : undefined;
23570
+ } catch {
23571
+ return;
23572
+ } finally {
23573
+ if (timer)
23574
+ clearTimeout(timer);
23575
+ }
23576
+ }
23577
+
23372
23578
  // ../../bridges/claude-bridge/src/services/session-manager-prompt-can-use-tool.ts
23373
23579
  var log16 = createLogger("bridge.claude");
23374
23580
  function boundedPlan(content) {
@@ -23607,7 +23813,8 @@ async function turnCanUseTool(turn, toolName, input, permissionContext) {
23607
23813
  const approvals = turnPolicy?.approvals;
23608
23814
  if (claudeAsksForApproval(turnPolicy, turn.options)) {
23609
23815
  recordClaudeToolAwaitingApproval(sessionId, permissionContext?.toolUseID, toolName, input);
23610
- return requestClaudeToolApproval(sessionId, toolName, input, permissionContext);
23816
+ const toolHints = await readClaudeMcpToolHints(readableControl(session), permissionContext?.mcpServer?.name, toolName);
23817
+ return requestClaudeToolApproval(sessionId, toolName, input, permissionContext, toolHints);
23611
23818
  }
23612
23819
  if (approvals === "deny") {
23613
23820
  return {
@@ -24259,16 +24466,7 @@ async function closeQueryControls(controls, deadline) {
24259
24466
  return failed;
24260
24467
  }
24261
24468
  async function settlesBy(work, deadline) {
24262
- let timer;
24263
- const expired = new Promise((resolve) => {
24264
- timer = setTimeout(() => resolve(false), Math.max(0, deadline - Date.now()));
24265
- timer.unref?.();
24266
- });
24267
- try {
24268
- return await Promise.race([work.then(() => true), expired]);
24269
- } finally {
24270
- clearTimeout(timer);
24271
- }
24469
+ return (await boundedWait(work, Math.max(0, deadline - Date.now()))).settled;
24272
24470
  }
24273
24471
  // ../../bridges/claude-bridge/src/routes/config.ts
24274
24472
  var log21 = createLogger("bridge.claude");
@@ -24293,6 +24491,11 @@ config2.get("/models", async (c) => {
24293
24491
  });
24294
24492
  var config_default = config2;
24295
24493
 
24494
+ // ../protocol/src/terminal-text.ts
24495
+ var MAX_STRING_LENGTH = 8 * 1024;
24496
+ var BUDGET_FLOOR = 4 * 1024;
24497
+ var MAX_MOVE = 4 * 1024;
24498
+
24296
24499
  // ../protocol/src/human-prompts.ts
24297
24500
  var HUMAN_PROMPT_SCAN_BYTES = 16 * 1024;
24298
24501
  var HUMAN_PROMPT_KINDS = new Set([
@@ -24400,6 +24603,27 @@ var bodyLimit = (options) => {
24400
24603
  };
24401
24604
  };
24402
24605
 
24606
+ // ../protocol/src/contract/ipc-error.ts
24607
+ var REGISTERED_ERROR_CODES = {
24608
+ "unknown-command": { domain: "text", command: "text" },
24609
+ "unsupported-version": { domain: "text", range: "range", command: "text" },
24610
+ "unsupported-field": { domain: "text", field: "text", command: "text" },
24611
+ "kanban-request-id-conflict": { record: "text" },
24612
+ "native-job-receipt-capacity": { limit: "count" },
24613
+ "native-agent-provider-session-missing": {},
24614
+ "container-lifecycle": { reason: "text" },
24615
+ "mcp-management": { reason: "text" },
24616
+ "pane-layout-revision-conflict": {},
24617
+ "design-revision-conflict": {},
24618
+ "prompt-queue-message-conflict": {},
24619
+ "unknown-node": {},
24620
+ "node-admin-refused": {},
24621
+ "node-scope-closed": {},
24622
+ "node-unavailable": {}
24623
+ };
24624
+ var REGISTERED_ERROR_CODE_LIST = Object.keys(REGISTERED_ERROR_CODES);
24625
+ var MAX_COUNT = 2 ** 31 - 1;
24626
+
24403
24627
  // ../protocol/src/mcp-management.ts
24404
24628
  var MCP_CONFIG_REPORTING_VERSION = 1;
24405
24629
  var MCP_MANAGEMENT_LIMITS = {
@@ -24460,10 +24684,12 @@ function sessionRuntimeHealthBody(session) {
24460
24684
  if (!session)
24461
24685
  return { ...emptyRuntimeHealth(), ...mcpConfig };
24462
24686
  const state = openClaudeRuntime(session) ? "attached" : "detached";
24687
+ const generation = session.claudeRuntimeGeneration;
24688
+ const base = { state, ...generation ? { runtimeGeneration: generation } : {} };
24463
24689
  if (!session.health)
24464
- return { ...emptyRuntimeHealth(), summary: { state }, ...mcpConfig };
24690
+ return { ...emptyRuntimeHealth(), summary: base, ...mcpConfig };
24465
24691
  const { drift, notices } = session.health.snapshot();
24466
- return { summary: { state, ...drift ? { drift } : {} }, notices, ...mcpConfig };
24692
+ return { summary: { ...base, ...drift ? { drift } : {} }, notices, ...mcpConfig };
24467
24693
  }
24468
24694
 
24469
24695
  // ../protocol/src/node/transcript-window.ts