orkestrator 2.37.3-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.",
@@ -866,6 +876,7 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
866
876
  "agent-tools.unavailable": "OpenCode agent tools remain unavailable for a session.",
867
877
  "coordinator-servers.unavailable": "OpenCode coordinator research servers are unavailable.",
868
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.",
869
880
  "worker-limit.reached": "The bounded request workers are full, so the stream restarts and a snapshot reconciles.",
870
881
  "request.failed": "Handling a request event failed, so the stream restarts. Error class only.",
871
882
  "credential-plugin.skipped": "A host OpenCode server started without the credential plugin, so its tools inherit its password; `reason` says why.",
@@ -888,6 +899,7 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
888
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.",
889
900
  "container-server.launched": "The start script of a container environment's 2.x server was run. Container port only.",
890
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.",
891
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.",
892
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.",
893
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.",
@@ -1122,6 +1134,7 @@ var TMUX_LOG_AREAS = defineLogAreas({
1122
1134
  "cleanup.skipped": "Environment tmux cleanup was skipped because tmux could not be reached and nothing required it.",
1123
1135
  "cleanup.environments-load-failed": "Environments could not be loaded during tmux cleanup, so it stays incomplete.",
1124
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.",
1125
1138
  "hooks.uninstall-failed": "Workspace hooks could not be uninstalled.",
1126
1139
  "hooks.git-exclude-failed": "The git exclude for Claude's local settings could not be set.",
1127
1140
  "naming.prepare-failed": "First-prompt naming could not be prepared; the prompt still goes ahead.",
@@ -1251,6 +1264,7 @@ var STORAGE_LOG_AREAS = defineLogAreas({
1251
1264
  "config.restrict-mode-failed": "A config file holding provider secrets could not be set to owner-only; the backend carries on.",
1252
1265
  "legacy-json.moved": "JSON store files written after the SQLite migration were archived, not imported.",
1253
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.",
1254
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.",
1255
1269
  "lease.heartbeat-failed": "A held lease's heartbeat failed, which shortens the lease; the next one retries.",
1256
1270
  "scrub.vacuum-failed": "Deleted-content page reclamation failed; the checkpoint is attempted independently.",
@@ -1300,6 +1314,7 @@ var BUILD_PIPELINE_LOG_AREAS = defineLogAreas({
1300
1314
  "transcripts.maintenance-failed": "Migrating or sweeping stage transcripts failed; the next start retries.",
1301
1315
  "restore.skipped": "A pipeline could not be restored at startup and was skipped.",
1302
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.",
1303
1318
  "workspace.waiting": "A pipeline is waiting for its workspace; written once per reason.",
1304
1319
  "rewind.pending": "A pipeline's code rewind has not finished; written once per reason.",
1305
1320
  "kanban.status-failed": "A restarted pipeline's Kanban status could not be set; it retries shortly.",
@@ -1341,6 +1356,8 @@ var CHANGE_TRACKING_LOG_AREAS = defineLogAreas({
1341
1356
  "dispatch.record-failed": "Recording a turn's dispatch outcome failed.",
1342
1357
  "turn.finalize-failed": "Finalizing a turn failed.",
1343
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.",
1344
1361
  "evidence.pull-failed": "Pulling change evidence from a bridge failed; a later pull retries.",
1345
1362
  "measurement.failed": "Recomputing a tool's measurement failed."
1346
1363
  }
@@ -1409,6 +1426,7 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
1409
1426
  "node-release.no-coordinator": "Work closed on a released node belonged to a coordinator that no longer exists, so nobody was told.",
1410
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.",
1411
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.",
1412
1430
  "checkout.merge-followed": "After an environment's PR merged, the project checkout was fast-forwarded, or `outcome` says why not.",
1413
1431
  "checkout.merge-follow-failed": "Fast-forwarding the project checkout failed, after an environment's PR merged or before mail woke the main coordinator.",
1414
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`).",
@@ -1461,7 +1479,8 @@ var REVIEW_LOG_AREAS = defineLogAreas({
1461
1479
  "monitor.task-store-failed": "A pull request could not be recorded on its Kanban task.",
1462
1480
  "monitor.merged-tickets-closed": "The startup sweep moved Kanban tickets whose pull request had merged to done (`count`).",
1463
1481
  "monitor.merged-tickets-close-failed": "The startup sweep closing Kanban tickets whose pull request merged failed; the next backend start retries.",
1464
- "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`)."
1465
1484
  }
1466
1485
  }
1467
1486
  });
@@ -1493,6 +1512,8 @@ var AGENT_ACCOUNTS_LOG_AREAS = defineLogAreas({
1493
1512
  "kept-note.failed": "Recording why a limit stop found no account to move to failed; the stop stands.",
1494
1513
  "container-sync.failed": "Handing a login or account to a container failed; `step` says which part.",
1495
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.",
1496
1517
  "login-cleanup.failed": "A temporary login could not be cleaned up.",
1497
1518
  "login-renewal.failed": "Renewing an idle account's sign-in to read its usage failed; it is retried after a backoff.",
1498
1519
  "login-renewal.not-extended": "Claude Code ran to renew an idle account's sign-in, but its token is still lapsed.",
@@ -1510,6 +1531,7 @@ var DOCKER_LOG_AREAS = defineLogAreas({
1510
1531
  "git-mirror.mount-unavailable": "A new container gets no project Git mirror, so its clone goes to the remote.",
1511
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.",
1512
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.",
1513
1535
  "git-mirror.seeded": "A project's Git mirror was built from its host checkout and only what the remote added to it.",
1514
1536
  "git-mirror.seed-skipped": "A project's host checkout could not seed its Git mirror, so the build downloads everything.",
1515
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.",
@@ -1523,6 +1545,9 @@ var DOCKER_LOG_AREAS = defineLogAreas({
1523
1545
  "git-mirror.clone-fallback": "A new environment could not clone from its project's Git mirror and cloned from the remote.",
1524
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.",
1525
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.",
1526
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.",
1527
1552
  "lifecycle-event.reconcile-failed": "Reconciling an environment after a container start or stop event failed; the next status read retries.",
1528
1553
  "login-keeper.pass-failed": "A Claude login keeper pass failed; the next interval retries.",
@@ -1557,6 +1582,17 @@ var DOCKER_LOG_AREAS = defineLogAreas({
1557
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.",
1558
1583
  essential: true,
1559
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" }
1560
1596
  }
1561
1597
  }
1562
1598
  },
@@ -1611,7 +1647,8 @@ var MCP_LOG_AREAS = defineLogAreas({
1611
1647
  "listener.port-free": "The Control MCP's fixed port is free again, so it is listening.",
1612
1648
  "state-listener.failed": "A Control MCP state listener threw; the others still run.",
1613
1649
  "delegation.remote-open-failed": "A delegation could not be opened on another node.",
1614
- "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."
1615
1652
  }
1616
1653
  },
1617
1654
  "mcp-management": {
@@ -1696,6 +1733,7 @@ var NODES_LOG_AREAS = defineLogAreas({
1696
1733
  "ticket-sync.failed": "A Kanban sync with a node failed; it is retried.",
1697
1734
  "ticket-sync.unknown-project": "A node sent ticket changes for a project that no longer exists here.",
1698
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.",
1699
1737
  "fleet-update.requested": "The update policy asked an older leaf to install the command node's version.",
1700
1738
  "fleet-update.failed": "The update policy could not read or update a leaf; it retries later.",
1701
1739
  "fleet-update.policy-load-failed": "The stored update policy could not be read; it is off."
@@ -1787,6 +1825,20 @@ var SCHEDULER_LOG_AREAS = defineLogAreas({
1787
1825
  }
1788
1826
  });
1789
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
+
1790
1842
  // ../protocol/src/log-vocabulary/web-app.ts
1791
1843
  var WEB_APP_LOG_AREAS = defineLogAreas({
1792
1844
  "web.app": {
@@ -2122,6 +2174,10 @@ var WEB_SETTINGS_LOG_AREAS = defineLogAreas({
2122
2174
  "web.settings": {
2123
2175
  description: "The settings screens.",
2124
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.",
2125
2181
  "config.save-failed": "Global settings could not be saved.",
2126
2182
  "config.load-failed": "The settings page could not load the config.",
2127
2183
  "config.reload-failed": "Re-reading the workspace config after a save failed.",
@@ -2291,6 +2347,7 @@ var LOG_VOCABULARY = {
2291
2347
  ...HOST_LOG_AREAS,
2292
2348
  ...TRANSCRIPT_ARTIFACTS_LOG_AREAS,
2293
2349
  ...SCHEDULER_LOG_AREAS,
2350
+ ...SELF_IMPROVEMENT_LOG_AREAS,
2294
2351
  ...WEB_APP_LOG_AREAS,
2295
2352
  ...WEB_BUILD_PIPELINE_LOG_AREAS,
2296
2353
  ...WEB_CHAT_LOG_AREAS,
@@ -2591,6 +2648,14 @@ var SIGNALS = new Set([
2591
2648
  "SIGXFSZ"
2592
2649
  ]);
2593
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
+ ]);
2594
2659
  var UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
2595
2660
  var SOURCE = new RegExp(`^(?:claude|codex|opencode|cursor|grok|acp|pi):${UUID}$`, "i");
2596
2661
  var STORAGE_DATABASES = new Set(["main", "ledger", "other"]);
@@ -5553,6 +5618,54 @@ health.get("/health", (c) => {
5553
5618
  });
5554
5619
  var health_default = health;
5555
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
+
5556
5669
  // ../protocol/src/agent-platforms.ts
5557
5670
  var AGENT_PLATFORMS = Object.freeze([
5558
5671
  "claude",
@@ -5745,6 +5858,58 @@ var PROTECTED_SEGMENTS = new Set([
5745
5858
  ".mcp.json"
5746
5859
  ]);
5747
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
+
5748
5913
  // ../protocol/src/review-evidence-frames.ts
5749
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.";
5750
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.";
@@ -5874,6 +6039,21 @@ var MCP_TOOL_ANNOTATION_KEYS = Object.freeze({
5874
6039
  idempotent: "idempotentHint",
5875
6040
  openWorld: "openWorldHint"
5876
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
+ }
5877
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.";
5878
6058
  var INTERACTIVE_AGENT_INTERACTION_POLICY = Object.freeze({
5879
6059
  version: AGENT_INTERACTION_POLICY_VERSION,
@@ -6389,6 +6569,11 @@ var BACKGROUND_CAPABLE_SHELL_TOOL_NAMES = new Set([
6389
6569
  "run_terminal_cmd",
6390
6570
  "execute_command"
6391
6571
  ]);
6572
+ var NATIVE_AGENT_BRANCH_LIST_LIMITS = Object.freeze({
6573
+ branches: 50,
6574
+ promptChars: 280,
6575
+ entryIdChars: 512
6576
+ });
6392
6577
  var NATIVE_AGENT_COMMAND_EXECUTION_KINDS = [
6393
6578
  "provider-prompt",
6394
6579
  "provider-command",
@@ -6658,6 +6843,7 @@ function sessionHealth(session) {
6658
6843
  }
6659
6844
 
6660
6845
  // ../protocol/src/plan-usage.ts
6846
+ var PLAN_USAGE_DISPLAY_STALE_MS = 30 * 60000;
6661
6847
  var WEEK_MINUTES = 7 * 24 * 60;
6662
6848
  var CLAUDE_PLAN_WINDOW_LABELS = {
6663
6849
  five_hour: { label: "5-hour limit", windowMinutes: 300 },
@@ -6886,8 +7072,18 @@ function revisedRowsReconciliationToken(overflowVersion, omitted) {
6886
7072
  }
6887
7073
 
6888
7074
  // ../../bridges/claude-bridge/src/services/session-preferences.ts
6889
- import { mkdir, open, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
6890
- 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";
6891
7087
 
6892
7088
  // ../../bridges/claude-bridge/src/services/claude-home.ts
6893
7089
  import { homedir } from "node:os";
@@ -7147,6 +7343,41 @@ function lockMetadata() {
7147
7343
  const identity = currentProcessIdentity();
7148
7344
  return JSON.stringify({ token: crypto.randomUUID(), ...identity });
7149
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
+ }
7150
7381
  function parseLockMetadata(raw) {
7151
7382
  try {
7152
7383
  const parsed = JSON.parse(raw);
@@ -7199,15 +7430,7 @@ async function recoverStaleLock(lockPath, candidate) {
7199
7430
  const recoveryPath = `${lockPath}.recover-${candidate.dev}-${candidate.ino}`;
7200
7431
  let recoveryHandle;
7201
7432
  try {
7202
- recoveryHandle = await open(recoveryPath, "wx", 384);
7203
- try {
7204
- await recoveryHandle.writeFile(lockMetadata());
7205
- } catch (error) {
7206
- await recoveryHandle.close().catch(() => {});
7207
- recoveryHandle = undefined;
7208
- await rm(recoveryPath, { force: true }).catch(() => {});
7209
- throw error;
7210
- }
7433
+ recoveryHandle = await createOwnedFile(recoveryPath);
7211
7434
  } catch (error) {
7212
7435
  if (errorCode(error) === "EEXIST") {
7213
7436
  const abandoned = await readLockSnapshot(recoveryPath);
@@ -7239,22 +7462,31 @@ async function recoverStaleLock(lockPath, candidate) {
7239
7462
  } catch {}
7240
7463
  }
7241
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
+ }
7242
7481
  async function withPreferenceFileLock(path, operation) {
7243
7482
  await mkdir(claudeSessionPreferencesDir(), { recursive: true });
7244
7483
  const lockPath = `${path}.lock`;
7484
+ await reclaimOwnerStagingFiles(lockPath);
7245
7485
  const startedAt = Date.now();
7246
7486
  let handle;
7247
7487
  while (!handle) {
7248
7488
  try {
7249
- handle = await open(lockPath, "wx", 384);
7250
- try {
7251
- await handle.writeFile(lockMetadata());
7252
- } catch (error) {
7253
- await handle.close().catch(() => {});
7254
- handle = undefined;
7255
- await rm(lockPath, { force: true }).catch(() => {});
7256
- throw error;
7257
- }
7489
+ handle = await createOwnedFile(lockPath);
7258
7490
  } catch (error) {
7259
7491
  if (errorCode(error) !== "EEXIST")
7260
7492
  throw error;
@@ -7425,6 +7657,10 @@ async function readSessionPreferences(sdkSessionId) {
7425
7657
  return parsePreferences(raw) ?? unavailablePreferences();
7426
7658
  }
7427
7659
  async function writePreferencesFile(path, preferences) {
7660
+ if (Object.values(preferences).every((value) => value === undefined)) {
7661
+ await rm(path, { force: true });
7662
+ return;
7663
+ }
7428
7664
  await mkdir(claudeSessionPreferencesDir(), { recursive: true });
7429
7665
  const tempPath = `${path}.${process.pid}.tmp`;
7430
7666
  try {
@@ -7523,18 +7759,8 @@ class ContextUsageRequestTimeoutError extends Error {
7523
7759
  this.name = "ContextUsageRequestTimeoutError";
7524
7760
  }
7525
7761
  }
7526
- async function withControlRequestTimeout(request, timeoutMs, createTimeoutError) {
7527
- let timeout;
7528
- const timeoutPromise = new Promise((_, reject) => {
7529
- timeout = setTimeout(() => reject(createTimeoutError()), timeoutMs);
7530
- timeout.unref?.();
7531
- });
7532
- try {
7533
- return await Promise.race([request, timeoutPromise]);
7534
- } finally {
7535
- if (timeout)
7536
- clearTimeout(timeout);
7537
- }
7762
+ function withControlRequestTimeout(request, timeoutMs, createTimeoutError) {
7763
+ return boundedWaitOrThrow(request, timeoutMs, createTimeoutError);
7538
7764
  }
7539
7765
  function touchSession(session) {
7540
7766
  session.lastAccessedAt = Date.now();
@@ -8568,7 +8794,7 @@ function withReadOnlyGitConfig(turnPolicy, environment) {
8568
8794
  import { createHash as createHash4, randomBytes } from "node:crypto";
8569
8795
  import {
8570
8796
  mkdir as mkdir2,
8571
- readdir,
8797
+ readdir as readdir2,
8572
8798
  readFile as readFile3,
8573
8799
  realpath,
8574
8800
  rename as rename2,
@@ -8739,7 +8965,7 @@ async function mirrorSkillSource(source, root) {
8739
8965
  return { path, names: skills.map((skill) => skill.name) };
8740
8966
  }
8741
8967
  async function readSkills(dir) {
8742
- const entries = (await readdir(dir)).filter((name) => !name.startsWith(".")).sort();
8968
+ const entries = (await readdir2(dir)).filter((name) => !name.startsWith(".")).sort();
8743
8969
  const skills = [];
8744
8970
  const names = new Set;
8745
8971
  for (const entry of entries) {
@@ -8761,7 +8987,7 @@ async function readSkills(dir) {
8761
8987
  return skills;
8762
8988
  }
8763
8989
  async function readSkill(skillDir, dirName) {
8764
- const entries = await readdir(skillDir);
8990
+ const entries = await readdir2(skillDir);
8765
8991
  const skillFile = entries.find((entry) => entry === "SKILL.md");
8766
8992
  if (!skillFile)
8767
8993
  return;
@@ -8862,7 +9088,7 @@ async function writeMirror(root, path, plugin, skills) {
8862
9088
  }
8863
9089
  async function pruneOldMirrors(root, plugin, current) {
8864
9090
  try {
8865
- 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) => ({
8866
9092
  path: join3(root, name),
8867
9093
  mtimeMs: (await stat2(join3(root, name)).catch(() => {
8868
9094
  return;
@@ -8876,7 +9102,7 @@ async function pruneOldMirrors(root, plugin, current) {
8876
9102
  }
8877
9103
 
8878
9104
  // ../../bridges/claude-bridge/src/services/plugin-config.ts
8879
- import { readdir as readdir2, access } from "node:fs/promises";
9105
+ import { readdir as readdir3, access } from "node:fs/promises";
8880
9106
  import { join as join4 } from "node:path";
8881
9107
 
8882
9108
  // ../protocol/src/node/claude-plugin-set.ts
@@ -9084,7 +9310,7 @@ async function scanCliPluginsDirectory(pluginsDir) {
9084
9310
  return [];
9085
9311
  }
9086
9312
  try {
9087
- const entries = await readdir2(pluginsDir, { withFileTypes: true });
9313
+ const entries = await readdir3(pluginsDir, { withFileTypes: true });
9088
9314
  const plugins = [];
9089
9315
  for (const entry of entries) {
9090
9316
  if (!entry.isDirectory()) {
@@ -9326,7 +9552,7 @@ import { join as join6 } from "node:path";
9326
9552
  // ../protocol/src/node/coordinator-read-boundary.ts
9327
9553
  import { realpathSync } from "node:fs";
9328
9554
  import { homedir as homedir2 } from "node:os";
9329
- 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";
9330
9556
  function canonicalPath(path) {
9331
9557
  let existing = path;
9332
9558
  const tail = [];
@@ -9334,7 +9560,7 @@ function canonicalPath(path) {
9334
9560
  try {
9335
9561
  return join5(realpathSync.native(existing), ...tail.reverse());
9336
9562
  } catch {
9337
- const parent = dirname(existing);
9563
+ const parent = dirname2(existing);
9338
9564
  if (parent === existing)
9339
9565
  return path;
9340
9566
  tail.push(existing.slice(parent.length).replace(/^[/\\]+/, ""));
@@ -10143,17 +10369,22 @@ function probeDetail(stderr) {
10143
10369
  `).map((entry) => entry.trim()).find(Boolean) ?? "no error output";
10144
10370
  return line.length > 200 ? `${line.slice(0, 199)}…` : line;
10145
10371
  }
10146
- var UNAVAILABLE = "Claude's command sandbox cannot run commands on this host";
10372
+ function runningInContainer() {
10373
+ return existsSync("/.dockerenv") || existsSync("/run/.containerenv");
10374
+ }
10147
10375
  function probeClaudeLinuxSandbox(dependencies = {}) {
10148
10376
  const onPath = dependencies.onPath ?? ((name) => executableOnPath(name));
10149
10377
  const run = dependencies.run ?? runProbeCommand;
10150
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"}`;
10151
10381
  const missing = CLAUDE_LINUX_SANDBOX_PROGRAMS.filter((name) => !onPath(name));
10152
10382
  if (missing.length > 0) {
10383
+ const absent = `${missing.join(" and ")} ${missing.length === 1 ? "is" : "are"}`;
10153
10384
  return {
10154
10385
  available: false,
10155
10386
  failure: "missing-programs",
10156
- 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.`
10157
10388
  };
10158
10389
  }
10159
10390
  if (!onPath("unshare")) {
@@ -12719,13 +12950,18 @@ async function assertClaudeRuntimeAccepts(session, options, resources, readOnlyC
12719
12950
  }
12720
12951
  var MAX_RUNTIME_TOOL_OWNERS = 4096;
12721
12952
  var DRAINING_RUNTIME_EXIT_WAIT_MS = 5000;
12953
+ var lastClaudeRuntimeGeneration = 0;
12722
12954
  function createClaudeRuntime(input) {
12723
12955
  let markEnded;
12724
12956
  const ended = new Promise((resolve) => {
12725
12957
  markEnded = resolve;
12726
12958
  });
12959
+ lastClaudeRuntimeGeneration += 1;
12960
+ const generation = lastClaudeRuntimeGeneration;
12961
+ input.session.claudeRuntimeGeneration = generation;
12727
12962
  const runtime = {
12728
12963
  session: input.session,
12964
+ generation,
12729
12965
  control: input.control,
12730
12966
  input: input.heldInput,
12731
12967
  abortController: input.abortController,
@@ -12838,20 +13074,7 @@ async function retireDrainingClaudeRuntime(session, waitMs = DRAINING_RUNTIME_EX
12838
13074
  return;
12839
13075
  if (runtime.state === "open")
12840
13076
  drainClaudeRuntime(runtime);
12841
- const waitForEnd = async () => {
12842
- let timer;
12843
- try {
12844
- return await Promise.race([
12845
- runtime.ended.then(() => true),
12846
- new Promise((resolve) => {
12847
- timer = setTimeout(() => resolve(false), waitMs);
12848
- timer.unref?.();
12849
- })
12850
- ]);
12851
- } finally {
12852
- clearTimeout(timer);
12853
- }
12854
- };
13077
+ const waitForEnd = async () => (await boundedWait(runtime.ended, waitMs)).settled;
12855
13078
  if (await waitForEnd())
12856
13079
  return;
12857
13080
  try {
@@ -12919,7 +13142,7 @@ import { isAbsolute as isAbsolute4, join as join12, relative, resolve as resolve
12919
13142
 
12920
13143
  // ../protocol/src/node/command-change-journal.ts
12921
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";
12922
- import { dirname as dirname2 } from "node:path";
13145
+ import { dirname as dirname3 } from "node:path";
12923
13146
  var MAX_JOURNAL_ENTRIES = 1000;
12924
13147
  var MAX_JOURNAL_FILES_PER_ENTRY = 20;
12925
13148
  var MAX_JOURNAL_PATH_LENGTH = 1024;
@@ -12992,7 +13215,7 @@ class CommandChangeJournal {
12992
13215
  const line = `${JSON.stringify({ id, change: bounded })}
12993
13216
  `;
12994
13217
  this.writes = this.writes.then(async () => {
12995
- await mkdir3(dirname2(this.path), { recursive: true, mode: 448 });
13218
+ await mkdir3(dirname3(this.path), { recursive: true, mode: 448 });
12996
13219
  if (!this.sizeChecked) {
12997
13220
  this.sizeChecked = true;
12998
13221
  const existing = await stat4(this.path).catch(() => {
@@ -16538,19 +16761,11 @@ async function closeTransientRewindQuery(control, onShutdown) {
16538
16761
  await control.return();
16539
16762
  onShutdown();
16540
16763
  });
16541
- let shutdownTimeout;
16542
16764
  try {
16543
- await Promise.race([
16544
- shutdown,
16545
- new Promise((_, reject) => {
16546
- shutdownTimeout = setTimeout(() => reject(new Error("shutdown pending")), REWIND_SHUTDOWN_TIMEOUT_MS);
16547
- })
16548
- ]);
16765
+ await boundedWaitOrThrow(shutdown, REWIND_SHUTDOWN_TIMEOUT_MS, () => new Error("shutdown pending"));
16549
16766
  } catch (error) {
16550
16767
  debugLog("[session-manager] Failed to confirm rewind query shutdown:", error);
16551
16768
  throw sessionOperationError("conflict", "Claude file rewind shutdown is pending; retry after it stops");
16552
- } finally {
16553
- clearTimeout(shutdownTimeout);
16554
16769
  }
16555
16770
  }
16556
16771
  async function rewindViaTransientQuery(sdkSessionId, persistedMessageId, dryRun, onShutdown = () => {
@@ -18308,58 +18523,6 @@ import { query as query2 } from "@anthropic-ai/claude-agent-sdk";
18308
18523
  import { createHash as createHash9 } from "node:crypto";
18309
18524
  import { join as join13 } from "node:path";
18310
18525
 
18311
- // ../protocol/src/agent-mail.ts
18312
- var AGENT_MAIL_MAX_BODY_BYTES = 32 * 1024;
18313
- var AGENT_MAIL_MAX_STORE_BYTES = 32 * 1024 * 1024;
18314
- var AGENT_MAIL_DEFAULT_RETENTION_DAYS = 14;
18315
- var AGENT_MAIL_MAX_ATTACHMENT_BYTES = 8 * 1024 * 1024;
18316
- var AGENT_MAIL_MAX_TOTAL_ATTACHMENT_BYTES = 32 * 1024 * 1024;
18317
- var AGENT_MAIL_DEFAULT_AUTONOMOUS_WAKE_BUDGET = 16;
18318
- var AGENT_MAIL_DEFAULT_HOURLY_WAKE_LIMIT = 40;
18319
- var AGENT_MAIL_TOOL_NAMES = Object.freeze([
18320
- "list_mailboxes",
18321
- "send_message",
18322
- "check_inbox",
18323
- "read_message",
18324
- "ack_message",
18325
- "reply_message",
18326
- "get_message_status"
18327
- ]);
18328
- var DEFAULT_AGENT_MESSAGING_SETTINGS = Object.freeze({
18329
- enabled: true,
18330
- allowCrossProject: false,
18331
- defaultInjectPolicy: "off",
18332
- wakePeers: false,
18333
- autonomousWakeBudget: AGENT_MAIL_DEFAULT_AUTONOMOUS_WAKE_BUDGET,
18334
- hourlyWakeLimit: AGENT_MAIL_DEFAULT_HOURLY_WAKE_LIMIT,
18335
- coordinatorStatusWakes: "settled",
18336
- retentionDays: AGENT_MAIL_DEFAULT_RETENTION_DAYS,
18337
- paused: false
18338
- });
18339
- function agentMailCapabilities(tabType, agent, locked = true) {
18340
- if (tabType === "agent-native") {
18341
- if (!locked || !agent)
18342
- return { canPull: false, canSend: false, canInject: false };
18343
- if (agent === "claude" || agent === "codex" || agent === "opencode" || agent === "pi" || agent === "cursor" || agent === "grok") {
18344
- return { canPull: true, canSend: true, canInject: true };
18345
- }
18346
- return { canPull: false, canSend: false, canInject: false };
18347
- }
18348
- if (tabType === "claude-tmux")
18349
- return { canPull: true, canSend: true, canInject: true };
18350
- if (tabType === "pipeline-worker") {
18351
- return agent ? { canPull: true, canSend: true, canInject: true } : { canPull: false, canSend: false, canInject: false };
18352
- }
18353
- if (["claude", "codex", "opencode"].includes(tabType)) {
18354
- return { canPull: true, canSend: true, canInject: false };
18355
- }
18356
- if (["cursor", "grok", "pi"].includes(tabType)) {
18357
- return { canPull: false, canSend: false, canInject: false };
18358
- }
18359
- return { canPull: false, canSend: false, canInject: false };
18360
- }
18361
- var NATIVE_AGENT_MAIL_CAPABILITIES = Object.freeze(Object.fromEntries(AGENT_PLATFORMS.map((agent) => [agent, agentMailCapabilities("agent-native", agent)])));
18362
-
18363
18526
  // ../protocol/src/transcript-artifacts.ts
18364
18527
  var ARTIFACT_TOOL_NAMES = Object.freeze([
18365
18528
  "create_artifact",
@@ -18657,27 +18820,15 @@ function liveClaudeControls() {
18657
18820
  }
18658
18821
  async function readFromLiveClaude(read, timeoutMs = LIVE_CLAUDE_READ_TIMEOUT_MS) {
18659
18822
  for (const control of liveClaudeControls()) {
18660
- let timer;
18661
18823
  try {
18662
18824
  const answer = read(control);
18663
18825
  if (answer === undefined)
18664
18826
  continue;
18665
- answer.catch(() => {
18666
- return;
18667
- });
18668
- const value = await Promise.race([
18669
- answer,
18670
- new Promise((resolve) => {
18671
- timer = setTimeout(() => resolve(undefined), timeoutMs);
18672
- timer.unref?.();
18673
- })
18674
- ]);
18675
- if (value !== undefined)
18676
- return value;
18827
+ const outcome = await boundedWait(answer, timeoutMs);
18828
+ if (outcome.settled && outcome.value !== undefined)
18829
+ return outcome.value;
18677
18830
  } catch (error) {
18678
18831
  debugLog("[live-claude-control] A running CLI could not answer:", error);
18679
- } finally {
18680
- clearTimeout(timer);
18681
18832
  }
18682
18833
  }
18683
18834
  return;
@@ -18977,7 +19128,6 @@ function fallbackCatalog() {
18977
19128
  }
18978
19129
  async function probeModels(at) {
18979
19130
  let q;
18980
- let timer;
18981
19131
  try {
18982
19132
  const cwd = process.env.CWD || process.cwd();
18983
19133
  debugLog("[session-manager] Fetching supported models", { cwd });
@@ -18996,13 +19146,7 @@ async function probeModels(at) {
18996
19146
  answer.catch(() => {
18997
19147
  return;
18998
19148
  });
18999
- const [models, account] = await Promise.race([
19000
- answer,
19001
- new Promise((_resolve, reject) => {
19002
- timer = setTimeout(() => reject(new Error("The model probe did not answer in time")), CLAUDE_MODEL_PROBE_TIMEOUT_MS);
19003
- timer.unref?.();
19004
- })
19005
- ]);
19149
+ const [models, account] = await boundedWaitOrThrow(answer, CLAUDE_MODEL_PROBE_TIMEOUT_MS, () => new Error("The model probe did not answer in time"));
19006
19150
  debugLog("[session-manager] Supported models fetched", { count: models.length });
19007
19151
  await rememberModels(models, account, at);
19008
19152
  return { source: "sdk", models: catalogModels(models) };
@@ -19010,7 +19154,6 @@ async function probeModels(at) {
19010
19154
  log11.warn("models.fetch-failed", { error: formatLogError(error) });
19011
19155
  return fallbackCatalog();
19012
19156
  } finally {
19013
- clearTimeout(timer);
19014
19157
  if (q?.return) {
19015
19158
  try {
19016
19159
  await q.return();
@@ -20181,7 +20324,6 @@ async function probeCommands(session, force) {
20181
20324
  async function runDiscoveryProbe(config) {
20182
20325
  const env = await runtimeEnvironmentForAgentQuery();
20183
20326
  let probe;
20184
- let timer;
20185
20327
  try {
20186
20328
  probe = controlOnlyQuery({
20187
20329
  cwd: config.cwd,
@@ -20195,18 +20337,12 @@ async function runDiscoveryProbe(config) {
20195
20337
  const version = typeof probe.initializationResult === "function" ? probe.initializationResult().then((result) => result?.claude_code_version).catch(() => {
20196
20338
  return;
20197
20339
  }) : Promise.resolve(undefined);
20198
- const timeout = new Promise((_, reject) => {
20199
- timer = setTimeout(() => reject(new Error("Claude command discovery timed out")), COMMAND_PROBE_TIMEOUT_MS);
20200
- timer.unref?.();
20201
- });
20202
20340
  read.catch(() => {
20203
20341
  return;
20204
20342
  });
20205
- 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"));
20206
20344
  return { commands: sdkRows(commands), ...cliVersion ? { cliVersion } : {} };
20207
20345
  } finally {
20208
- if (timer)
20209
- clearTimeout(timer);
20210
20346
  await Promise.resolve(probe?.close()).catch(() => {
20211
20347
  return;
20212
20348
  });
@@ -21650,7 +21786,7 @@ function webFetchHost(input) {
21650
21786
  return;
21651
21787
  }
21652
21788
  }
21653
- async function requestClaudeToolApproval(sessionId, toolName, input, permissionContext) {
21789
+ async function requestClaudeToolApproval(sessionId, toolName, input, permissionContext, toolHints) {
21654
21790
  const now = Date.now();
21655
21791
  const path = bounded2(input.file_path ?? input.notebook_path);
21656
21792
  const command = bounded2(input.command);
@@ -21703,6 +21839,7 @@ async function requestClaudeToolApproval(sessionId, toolName, input, permissionC
21703
21839
  ...networkHost ? { networkHost } : {},
21704
21840
  ...ruleEligible ? { ruleEligible: true } : {},
21705
21841
  ...humanRequired ? { humanRequired: true } : {},
21842
+ ...toolHints && mcpServer && toolName.startsWith("mcp__") ? { toolHints } : {},
21706
21843
  ...proposedCommandPrefix ? { proposedCommandPrefix } : {}
21707
21844
  };
21708
21845
  const outcome = await parkInteraction(request, permissionContext?.signal);
@@ -23398,6 +23535,46 @@ async function handleTurnMessage(turn, message) {
23398
23535
  await handled;
23399
23536
  }
23400
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
+
23401
23578
  // ../../bridges/claude-bridge/src/services/session-manager-prompt-can-use-tool.ts
23402
23579
  var log16 = createLogger("bridge.claude");
23403
23580
  function boundedPlan(content) {
@@ -23636,7 +23813,8 @@ async function turnCanUseTool(turn, toolName, input, permissionContext) {
23636
23813
  const approvals = turnPolicy?.approvals;
23637
23814
  if (claudeAsksForApproval(turnPolicy, turn.options)) {
23638
23815
  recordClaudeToolAwaitingApproval(sessionId, permissionContext?.toolUseID, toolName, input);
23639
- 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);
23640
23818
  }
23641
23819
  if (approvals === "deny") {
23642
23820
  return {
@@ -24288,16 +24466,7 @@ async function closeQueryControls(controls, deadline) {
24288
24466
  return failed;
24289
24467
  }
24290
24468
  async function settlesBy(work, deadline) {
24291
- let timer;
24292
- const expired = new Promise((resolve) => {
24293
- timer = setTimeout(() => resolve(false), Math.max(0, deadline - Date.now()));
24294
- timer.unref?.();
24295
- });
24296
- try {
24297
- return await Promise.race([work.then(() => true), expired]);
24298
- } finally {
24299
- clearTimeout(timer);
24300
- }
24469
+ return (await boundedWait(work, Math.max(0, deadline - Date.now()))).settled;
24301
24470
  }
24302
24471
  // ../../bridges/claude-bridge/src/routes/config.ts
24303
24472
  var log21 = createLogger("bridge.claude");
@@ -24322,6 +24491,11 @@ config2.get("/models", async (c) => {
24322
24491
  });
24323
24492
  var config_default = config2;
24324
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
+
24325
24499
  // ../protocol/src/human-prompts.ts
24326
24500
  var HUMAN_PROMPT_SCAN_BYTES = 16 * 1024;
24327
24501
  var HUMAN_PROMPT_KINDS = new Set([
@@ -24429,6 +24603,27 @@ var bodyLimit = (options) => {
24429
24603
  };
24430
24604
  };
24431
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
+
24432
24627
  // ../protocol/src/mcp-management.ts
24433
24628
  var MCP_CONFIG_REPORTING_VERSION = 1;
24434
24629
  var MCP_MANAGEMENT_LIMITS = {
@@ -24489,10 +24684,12 @@ function sessionRuntimeHealthBody(session) {
24489
24684
  if (!session)
24490
24685
  return { ...emptyRuntimeHealth(), ...mcpConfig };
24491
24686
  const state = openClaudeRuntime(session) ? "attached" : "detached";
24687
+ const generation = session.claudeRuntimeGeneration;
24688
+ const base = { state, ...generation ? { runtimeGeneration: generation } : {} };
24492
24689
  if (!session.health)
24493
- return { ...emptyRuntimeHealth(), summary: { state }, ...mcpConfig };
24690
+ return { ...emptyRuntimeHealth(), summary: base, ...mcpConfig };
24494
24691
  const { drift, notices } = session.health.snapshot();
24495
- return { summary: { state, ...drift ? { drift } : {} }, notices, ...mcpConfig };
24692
+ return { summary: { ...base, ...drift ? { drift } : {} }, notices, ...mcpConfig };
24496
24693
  }
24497
24694
 
24498
24695
  // ../protocol/src/node/transcript-window.ts