orkestrator 2.36.1 → 2.36.3-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.
@@ -180,6 +180,16 @@ function logErrorKind(error) {
180
180
  }
181
181
 
182
182
  // ../protocol/src/log-vocabulary/define.ts
183
+ var ESSENTIAL_ERROR_FIELDS = {
184
+ "error.name": "label",
185
+ "error.code": "label",
186
+ "error.errno": "number",
187
+ "error.syscall": "label",
188
+ "error.exitCode": "number",
189
+ "error.signal": "label",
190
+ "error.outputOmitted": "boolean",
191
+ "error.errorCount": "number"
192
+ };
183
193
  var THROTTLE_LOG_EVENTS = {
184
194
  "throttle.suppressed": "Repeats of the throttled `site` were counted over a window, not written.",
185
195
  "throttle.recovered": "The throttled `site` succeeded again, so its fault has cleared.",
@@ -229,7 +239,11 @@ var BACKEND_LOG_AREAS = defineLogAreas({
229
239
  backend: {
230
240
  description: "The backend process: startup, background notices and shutdown.",
231
241
  events: {
232
- starting: "The backend process is starting.",
242
+ starting: {
243
+ description: "The backend process is starting.",
244
+ essential: true,
245
+ fields: { version: "label" }
246
+ },
233
247
  "ssh-socket.resolved": "An SSH agent socket was found.",
234
248
  "ssh-socket.missing": "No usable SSH agent socket was found.",
235
249
  "standalone-updater.mismatch": "--standalone-updater does not match --data-dir, so self-update is off.",
@@ -244,8 +258,16 @@ var BACKEND_LOG_AREAS = defineLogAreas({
244
258
  "notice.failed": "A background notice after a turn or prompt failed; `step` says which.",
245
259
  "artifacts.live-unavailable": "Live interactive artifacts are unavailable.",
246
260
  "shutdown.step-failed": "One part of shutdown failed and the rest went on; `step` says which.",
247
- "shutdown.signal-received": "A signal started shutdown, which tells a clean quit from the backend being killed.",
248
- "shutdown.finished": "Shutdown finished, and the process exits with `code`.",
261
+ "shutdown.signal-received": {
262
+ description: "A signal started shutdown, which tells a clean quit from the backend being killed.",
263
+ essential: true,
264
+ fields: { signal: "label" }
265
+ },
266
+ "shutdown.finished": {
267
+ description: "Shutdown finished, and the process exits with `code`.",
268
+ essential: true,
269
+ fields: { code: "number" }
270
+ },
249
271
  "port-policy.second-backend": "Another backend serves the default data directory, so this one avoids its ports.",
250
272
  "port-policy.serve-on-free-port": "--tailscale-serve is on a free gateway port; pass --port with --strict-gateway-port to keep one."
251
273
  }
@@ -288,7 +310,10 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
288
310
  "evidence.record-failed": "Change evidence could not be recorded; the read loop carries on.",
289
311
  "evidence.shell-record-failed": "A shell observation could not be recorded.",
290
312
  "evidence.turn-record-failed": "Turn change evidence could not be recorded.",
313
+ "agent.exited": "An ACP agent process exited, with its `code` and `signal`, always at `warn`. `requested` is true when the bridge closed it normally, false for an unrequested or fault-driven exit.",
314
+ "http.route-failed": "An HTTP route answered 500; its error message is not logged because it can hold content.",
291
315
  "server.listening": "The HTTP server is listening.",
316
+ "session.policy-widening-refused": "A request tried to widen a live session's execution policy and was refused; widened names the axes.",
292
317
  "state.composer-reset": "A saved composer state was malformed and was reset.",
293
318
  "state.discarded": "Saved bridge state could not be used and was discarded.",
294
319
  "state.persist-failed": "Saving bridge state failed; a later write retries.",
@@ -342,7 +367,7 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
342
367
  "session.created": "A session was created or recovered.",
343
368
  "session.delete-failed": "Deleting a session failed.",
344
369
  "session.fork-failed": "Forking a session failed.",
345
- "session.policy-widening-refused": "A config request tried to widen a live session's execution policy and was refused; widened names the axes.",
370
+ "session.policy-widening-refused": "A request tried to widen a live session's execution policy and was refused; widened names the axes.",
346
371
  "session.rename-failed": "Renaming a session failed.",
347
372
  "session.resolve-failed": "A session could not be found or loaded for a request; action names the request.",
348
373
  "session.rewind-failed": "Rewinding session files failed.",
@@ -376,6 +401,7 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
376
401
  "app-server.exited": "app-server exited unexpectedly; the code and signal say how.",
377
402
  "app-server.invariant-violation": "app-server asked for something its configuration forbids.",
378
403
  "app-server.protocol-violation": "app-server wrote a line that is not valid protocol; it was ignored.",
404
+ "app-server.overflow-restart-failed": "Replacing the child after a notification queue overflow failed; the next request tries again.",
379
405
  "app-server.recording": "Notification recording is on; recordings hold content.",
380
406
  "app-server.stale-reaped": "A stale app-server left by an earlier bridge was stopped.",
381
407
  "app-server.stderr": "Metadata of an app-server stderr line, never its content.",
@@ -406,6 +432,7 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
406
432
  "ordered-events.publish-failed": "Publishing an ordered event failed; clients are told to rehydrate.",
407
433
  "ordered-events.reconcile-failed": "Reconciling ordered events failed.",
408
434
  "parent.gone": "The backend that launched this bridge has gone; stopping turns and shutting down.",
435
+ "queue.overflow": "The notification queue passed a bound and dropped its backlog.",
409
436
  "queue.task-failed": "A task on a per-thread queue failed.",
410
437
  "raw-log.write-failed": "Appending to the raw Codex log failed.",
411
438
  "recorder.notice": "The notification recorder needs attention: it is on, or was asked for without its confirmation.",
@@ -419,6 +446,7 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
419
446
  "server-request.flush-timeout": "An answer to a server request did not flush in time.",
420
447
  "server-request.handoff-failed": "Handing a server request to the router threw.",
421
448
  "session.config-apply-failed": "Applying session configuration failed; the route answers unavailable.",
449
+ "session.policy-widening-refused": "A request tried to widen a live session's execution policy and was refused; widened names the axes.",
422
450
  "sse.closed": "An event stream was closed by the bridge; the client reconnects and replays.",
423
451
  "sse.keepalive-failed": "An event stream keepalive failed.",
424
452
  "sse.observer-failed": "An event stream observer failed; it reconnects.",
@@ -447,19 +475,39 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
447
475
  events: {
448
476
  "agent.archive-failed": "Archiving or unarchiving an agent failed.",
449
477
  "http.route-failed": "An HTTP route failed unexpectedly; its error is not logged because it can hold content.",
478
+ "session.policy-widening-refused": "A request tried to widen a live session's execution policy and was refused; widened names the axes.",
450
479
  "startup.closes-failed": "Finishing closes a previous process left behind failed at startup.",
451
480
  "startup.closes-incomplete": "Some closes a previous process left behind did not finish at startup; a retried close finishes them.",
452
481
  "state.publication-failing": "Saving bridge state is failing; new prompts and steers are refused until it recovers.",
453
482
  "state.publication-recovered": "Saving bridge state recovered.",
454
- "state.transcripts-shortened": "The state file reached its limit, so some sessions were saved with a shortened transcript copy."
483
+ "state.transcripts-shortened": "The state file reached its limit, so some sessions were saved with a shortened transcript copy.",
484
+ "session.resume-fell-back": {
485
+ description: "A saved conversation could not be resumed, so a new one started; its error message is not logged because it can hold content.",
486
+ essential: true,
487
+ fields: ESSENTIAL_ERROR_FIELDS
488
+ },
489
+ "turn.failed": "A turn failed; its error message is not logged because it can hold content. A cancelled turn is not a failure.",
490
+ "turn.recovery-failed": "A run recovered after a bridge restart ended in failure, or could not be followed. A cancelled run is not a failure.",
491
+ "turn.send-failed": "Sending a prompt to Cursor failed, so whether its run started is unknown; its error message is not logged because it can hold content.",
492
+ "turn.timed-out": "A turn outlived its time budget, so its run was asked to cancel; `turn.failed` follows if it never stops."
455
493
  }
456
494
  },
457
495
  "bridge.pi": {
458
496
  description: "The Pi bridge: its routes, sessions and saved state.",
459
497
  events: {
460
498
  "http.route-failed": "An HTTP route failed unexpectedly; its error is not logged because it can hold content.",
499
+ "session.policy-widening-refused": "A request tried to widen a live session's execution policy and was refused; widened names the axes.",
500
+ "session-list.failed": "Reading the resumable sessions failed, so none were offered; its error message is not logged because it can hold content.",
461
501
  "state.over-budget": "The state file stayed over budget after shedding transcripts, so the write was skipped.",
462
- "state.transcripts-shed": "The state file was over budget, so some sessions were saved without their transcript."
502
+ "state.transcripts-shed": "The state file was over budget, so some sessions were saved without their transcript.",
503
+ "session.resume-fell-back": {
504
+ description: "A saved conversation could not be reopened, so a new one started; its error message is not logged because it can hold content.",
505
+ essential: true,
506
+ fields: ESSENTIAL_ERROR_FIELDS
507
+ },
508
+ "turn.failed": "A turn failed; its error message is not logged because it can hold content. A cancelled turn is not a failure.",
509
+ "turn.refused": "Pi refused a prompt before starting a run, so nothing ran; its error message is not logged because it can hold content.",
510
+ "turn.startup-timed-out": "Pi did not start a turn within its startup deadline, so the prompt was abandoned."
463
511
  }
464
512
  }
465
513
  });
@@ -470,14 +518,31 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
470
518
  description: "The Electron main process: startup, windows, quit and the Local backend's life.",
471
519
  events: {
472
520
  "backend.docker-context-seed-failed": "An agent-test profile fell back to the default Docker context.",
473
- "backend.exited": "The Local backend exited unexpectedly; Local work is unavailable.",
474
- "backend.exited-recovering": "The Local backend exited just after a remote update; relaunching unattended.",
521
+ "backend.exited": {
522
+ description: "The Local backend exited unexpectedly; Local work is unavailable. `error.exitCode` and `error.signal` say how.",
523
+ essential: true,
524
+ fields: ESSENTIAL_ERROR_FIELDS
525
+ },
526
+ "backend.exited-recovering": {
527
+ description: "The Local backend exited just after a remote update; relaunching unattended. `error.exitCode` and `error.signal` say how.",
528
+ essential: true,
529
+ fields: ESSENTIAL_ERROR_FIELDS
530
+ },
475
531
  "backend.keychain-link-remove-failed": "An agent-test profile kept a legacy link to the host keychain.",
476
- "backend.start-failed": "The Local backend did not start; continuing with remote machines.",
532
+ "backend.start-failed": {
533
+ description: "The Local backend did not start; continuing with remote machines.",
534
+ essential: true,
535
+ fields: ESSENTIAL_ERROR_FIELDS
536
+ },
477
537
  "clipboard.write-failed": "Writing text to the system clipboard failed.",
478
538
  "dev-mode.ignored-packaged": "A packaged app was launched with ELECTRON_DEV=1 and ignored it; it loads its bundled renderer.",
479
539
  "instance.already-running": "Another instance holds this data directory; this one will quit.",
480
- "main-thread.stalled": "A timer fired late, so windows, IPC and the stdout reader waited.",
540
+ "main-thread.stalled": {
541
+ description: "A timer fired late, so windows, IPC and the stdout reader waited.",
542
+ essential: true,
543
+ minLevel: "error",
544
+ fields: { lagMs: "number", intervalMs: "number" }
545
+ },
481
546
  "quit.stopping-backend": "The app is quitting and has asked the Local backend to stop.",
482
547
  "relaunch.schedule-failed": "The AppImage relaunch waiter failed; using Electron's relauncher.",
483
548
  "relaunch.service-register-failed": "The AppImage relaunch service was refused; using a detached waiter.",
@@ -488,7 +553,11 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
488
553
  "saved-machines.attach-failed": "Saved machines were not imported into the command node yet.",
489
554
  "saved-machines.attached": "Saved machines were imported into the local command node.",
490
555
  "startup.failed": "The application failed to start.",
491
- "uncaught-exception": "The main process hit an uncaught exception.",
556
+ "uncaught-exception": {
557
+ description: "The main process hit an uncaught exception.",
558
+ essential: true,
559
+ fields: ESSENTIAL_ERROR_FIELDS
560
+ },
492
561
  "uncaught-exception.dialog-failed": "The uncaught exception sheet could not be shown.",
493
562
  "window.create-failed": "A menu-driven new window could not be created.",
494
563
  "window.recreate-failed": "The main window could not be recreated on activation.",
@@ -511,6 +580,12 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
511
580
  "unhandled-rejection": "An unhandled rejection occurred while the renderer was starting."
512
581
  }
513
582
  },
583
+ "desktop.permissions": {
584
+ description: "Permission requests refused on the renderer and workspace realm sessions.",
585
+ events: {
586
+ denied: "A renderer asked for a permission the policy does not grant."
587
+ }
588
+ },
514
589
  "desktop.dialog": {
515
590
  description: "Native dialogs, whose modal loops hold the main thread while they are open.",
516
591
  events: {
@@ -593,6 +668,7 @@ var ENVIRONMENT_LOG_AREAS = defineLogAreas({
593
668
  "status.docker-error": "A transient Docker error stopped a status read, so the stored status is kept.",
594
669
  "setup.clear-launch-failed": "A pending agent launch could not be cleared after setup failed.",
595
670
  "setup.record-failure-failed": "A setup failure before its first attempt could not be recorded.",
671
+ "setup.tab-publish-failed": "The setup terminal's tab could not be published.",
596
672
  "lifecycle.failed": "Starting, rebuilding or recreating an environment failed; `operation` says which.",
597
673
  "tab-teardown.pending": "A tab's teardown failed and stays pending; the reconcile sweep retries.",
598
674
  "tab-reconcile.skipped": "Orphaned tab reconciliation was skipped because pane layouts are unreadable.",
@@ -629,6 +705,8 @@ var GATEWAY_LOG_AREAS = defineLogAreas({
629
705
  "loopback.unavailable": "The loopback client listener could not start.",
630
706
  "auth-token.stored": "The gateway token's file was written. The path only, never the token.",
631
707
  "auth-token.persist-failed": "The gateway token could not be saved.",
708
+ "auth-guess.throttled": "A listener saw enough different wrong tokens that it now pauses new ones. Never the values.",
709
+ "host.refused": "A request named a host this gateway does not answer to. Logged once per name, up to a limit.",
632
710
  "port.fallback": "The preferred port was taken, so a nearby one is used.",
633
711
  "port.fallback-distant": "The preferred port and those nearby were taken, so another is used.",
634
712
  "request.failed": "A gateway request failed. Throttled: repeats are counted, not written.",
@@ -672,6 +750,22 @@ var LOCAL_SERVER_LOG_AREAS = defineLogAreas({
672
750
  "bridge-runtime.installed": "A bridge runtime finished installing.",
673
751
  "opencode.database-lost-retrying": "OpenCode lost its shared database at startup, so it is retried.",
674
752
  "server.stopping": "A local server is being stopped, for the fixed `reason` given.",
753
+ "bridge.started": {
754
+ description: "A local bridge process was spawned; `key` names its kind and environment.",
755
+ essential: true,
756
+ fields: { key: "label", pid: "number" }
757
+ },
758
+ "bridge.exited": {
759
+ description: "A local bridge process exited, with its `code` and `signal`. `warn` when nothing asked it to, whatever the code; `info` when the backend stopped it, which `server.stopping` explains.",
760
+ essential: true,
761
+ fields: {
762
+ key: "label",
763
+ pid: "number",
764
+ code: "number",
765
+ signal: "label",
766
+ requested: "boolean"
767
+ }
768
+ },
675
769
  "reaper.tmux-list-failed": "Orphaned claude-tmux sessions could not be listed.",
676
770
  "reaper.tmux-kill-failed": "An orphaned tmux session could not be killed.",
677
771
  "reaper.tmux-reaped": "Orphaned claude-tmux sessions of a deleted environment were killed.",
@@ -705,13 +799,29 @@ var LOGGING_LOG_AREAS = defineLogAreas({
705
799
  "capture.started": "Saving logs to disk began for this process.",
706
800
  "capture.stopped": "Saving logs to disk stopped for this process.",
707
801
  "config.invalid": "A logging environment variable held a value that was ignored.",
708
- "entries.dropped": "The log queue was full, so entries were dropped and counted.",
802
+ "entries.dropped": {
803
+ description: "Entries were dropped and counted, for the fixed `reason` given: the queue was full, a write failed or, in the essential log, one event was repeating too fast.",
804
+ essential: true,
805
+ fields: { entries: "number", bytes: "number", reason: "label" }
806
+ },
807
+ "essential.started": {
808
+ description: "This process began writing the essential log. One with no `essential.stopped` before it means the last writer died.",
809
+ essential: true,
810
+ fields: { owner: "label" }
811
+ },
812
+ "essential.stopped": {
813
+ description: "This process stopped writing the essential log, in an orderly exit.",
814
+ essential: true,
815
+ fields: { owner: "label" }
816
+ },
817
+ "essential.write-failed": "Writing the essential log failed. Its entries are counted, and a marker reports them at the next write that works.",
709
818
  "policy.changed": "The logging settings changed: saving, retention and levels, with no content.",
710
819
  "policy.bridge-predates-route": "A running bridge has no logging settings route; it applies them at its next start.",
711
820
  "policy.push-failed": "A running bridge did not take the logging settings after retries; its next start resends them.",
712
821
  "prune.failed": "Removing expired log files failed; the next sweep retries.",
713
822
  "write.failed": "Appending to the log file failed.",
714
- "unknown-area": "Code outside the type checker asked for an area that is not listed."
823
+ "unknown-area": "Code outside the type checker asked for an area that is not listed.",
824
+ ...THROTTLE_LOG_EVENTS
715
825
  }
716
826
  }
717
827
  });
@@ -766,6 +876,7 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
766
876
  "turn-recovery.failed": "Recovering an incomplete turn failed.",
767
877
  "turn-recovery.exhausted": "A turn failed again after automatic recovery and is left for the user.",
768
878
  "turn-recovery.retrying": "An incomplete or provider-failed turn is being retried automatically.",
879
+ "usage-limit.notice-failed": "A usage-limit stop's outcome could not be read for its notice.",
769
880
  "usage-limit.resend-failed": "Resending after a usage limit failed. An unknown send stays in the journal.",
770
881
  "title.strategy-failed": "A session title strategy failed, so the next is tried. Content-free: the error can quote the prompt.",
771
882
  ...THROTTLE_LOG_EVENTS
@@ -782,6 +893,15 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
782
893
  "recover.failed": "Goals could not be recovered at startup."
783
894
  }
784
895
  },
896
+ "native-agent.subork": {
897
+ description: "Suborks: the ask_agents calls a native agent makes. Content-free.",
898
+ events: {
899
+ "pass.failed": "A pass over a call failed, so a later pass retries. Counts only.",
900
+ "delivery.failed": "A call's answers could not be placed in the caller's mailbox yet. Error class only.",
901
+ "retention.failed": "An old call could not be removed.",
902
+ "sweep.failed": "A running call's caller could not be checked; the next sweep looks again."
903
+ }
904
+ },
785
905
  "native-agent.opencode": {
786
906
  description: "The OpenCode provider: its request monitor, retries and agent tools.",
787
907
  events: {
@@ -836,7 +956,28 @@ var RUNTIME_LOG_AREAS = defineLogAreas({
836
956
  "event-loop": {
837
957
  description: "This process's event loop. A stall of 10 seconds or more is written at error, so no level hides it.",
838
958
  events: {
839
- stalled: "A timer fired late, so every request in that window waited."
959
+ stalled: {
960
+ description: "A timer fired late, so every request in that window waited.",
961
+ essential: true,
962
+ minLevel: "error",
963
+ fields: { lagMs: "number", intervalMs: "number" }
964
+ }
965
+ }
966
+ },
967
+ process: {
968
+ description: "Failures of a whole process that nothing in it handled.",
969
+ events: {
970
+ "rejection.unhandled": {
971
+ description: "A promise rejection reached the fatal rejection guard, which keeps the process running.",
972
+ essential: true,
973
+ fields: { kind: "label", ...ESSENTIAL_ERROR_FIELDS }
974
+ },
975
+ "uncaught-exception": {
976
+ description: "An exception reached the top of the backend, which is about to die with it. `origin` says whether it was thrown or a rejected top-level await.",
977
+ essential: true,
978
+ fields: { origin: "label", ...ESSENTIAL_ERROR_FIELDS }
979
+ },
980
+ ...THROTTLE_LOG_EVENTS
840
981
  }
841
982
  }
842
983
  });
@@ -1074,21 +1215,43 @@ var STORAGE_LOG_AREAS = defineLogAreas({
1074
1215
  description: "The SQLite-backed stores, their snapshots and imports from older formats.",
1075
1216
  events: {
1076
1217
  "usage.environment-label-failed": "Usage labels could not be retained for a removed environment; deletion continues.",
1077
- "snapshot.integrity-failed": "An hourly database snapshot failed its integrity check and was discarded.",
1218
+ "migration.failed": {
1219
+ description: "The database could not be brought to this build's schema, so it did not open; `step` says whether the safety copy or the migration itself failed.",
1220
+ essential: true,
1221
+ fields: {
1222
+ fromVersion: "number",
1223
+ toVersion: "number",
1224
+ step: "label",
1225
+ ...ESSENTIAL_ERROR_FIELDS
1226
+ }
1227
+ },
1228
+ "snapshot.integrity-failed": {
1229
+ description: "A database snapshot failed its integrity check and was discarded.",
1230
+ essential: true,
1231
+ fields: {}
1232
+ },
1078
1233
  "snapshot.skipped-low-disk": "The hourly database snapshot was skipped because the disk lacks room; `retryAt` says when it tries again.",
1079
- "snapshot.failed": "The hourly database snapshot failed; `retryAt` says when it tries again, if known.",
1234
+ "snapshot.failed": {
1235
+ description: "The hourly database snapshot failed; `retryAt` says when it tries again, if known.",
1236
+ essential: true,
1237
+ fields: { retryAt: "label", ...ESSENTIAL_ERROR_FIELDS }
1238
+ },
1080
1239
  "listener.attention-failed": "An environment attention listener threw; the committed mutation stands.",
1081
1240
  "listener.change-failed": "A resource change listener threw; the committed mutation stands.",
1082
1241
  "kanban.image-cleanup-failed": "An orphaned Kanban image could not be removed after its retries; it is safe to remove later.",
1083
1242
  "nodes.entries-dropped": "Unreadable node registry entries were ignored.",
1084
1243
  "preview-identity.reminted": "The data directory moved or was copied, so previews get a new backend identity.",
1244
+ "preview-settings.invalid": "Invalid preview settings disabled transport and relay.",
1085
1245
  "machine-profile.invalid": "The stored machine profile was invalid and the default was restored.",
1086
1246
  "permission-rules.cleanup-failed": "A deleted project's permission rules could not be removed.",
1087
1247
  "retired.turn-cleanup-pending": "Cleanup of a retired Looped Review turn did not finish and stays pending.",
1088
1248
  "handoffs.prune-failed": "Pruning agent handoffs that nothing references failed; a later prune retries.",
1089
1249
  "desktop-connections.malformed": "Stored desktop connection settings were malformed, so the local connection is used.",
1090
1250
  "legacy-json.moved": "JSON store files written after the SQLite migration were archived, not imported.",
1091
- "legacy-json.archive-failed": "Imported JSON store files could not be archived."
1251
+ "legacy-json.archive-failed": "Imported JSON store files could not be archived.",
1252
+ "lease.heartbeat-failed": "A held lease's heartbeat failed, which shortens the lease; the next one retries.",
1253
+ "scrub.checkpoint-failed": "Deleted content could not be scrubbed from the WAL because the truncating checkpoint failed or was blocked; the next checkpoint retries.",
1254
+ ...THROTTLE_LOG_EVENTS
1092
1255
  }
1093
1256
  }
1094
1257
  });
@@ -1179,6 +1342,11 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
1179
1342
  "wake.observe-pull-request-failed": "A pull request could not be observed for status wakes.",
1180
1343
  "wake.observe-feature-plan-failed": "A feature plan could not be observed for status wakes.",
1181
1344
  "wake.observe-workflow-failed": "A workflow could not be observed for status wakes.",
1345
+ "notice.outbox-refused": "A leaf's outbox refused a coordinator notice, so its own coordinator takes it.",
1346
+ "notice.start-main-failed": "A coordinator notice could not start a main coordinator; it waits for one to open.",
1347
+ "notice.take-back-unread": "A notice handed back from a command node found no open coordinator here.",
1348
+ "limit-stop.own": "A coordinator's own usage-limit stop attempted to move it off the account.",
1349
+ "limit-stop.notice-failed": "A usage-limit notice could not be sent; it stays in the ledger for the next attempt.",
1182
1350
  "wake.deliver-failed": "A workflow status wake could not be delivered; the next pass retries.",
1183
1351
  "wake.waiting-check-failed": "A waiting worker could not be checked; the next pass retries.",
1184
1352
  "wake.resolve-report-failed": "A finished Resolve tab could not be reported.",
@@ -1196,8 +1364,10 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
1196
1364
  "remote-worker.settle-failed": "A remote worker could not be settled.",
1197
1365
  "checkout.merge-followed": "After an environment's PR merged, the project checkout was fast-forwarded, or `outcome` says why not.",
1198
1366
  "checkout.merge-follow-failed": "Fast-forwarding the project checkout failed, after an environment's PR merged or before mail woke the main coordinator.",
1199
- "checkout.mail-follow": "Before mail woke the main coordinator, the project checkout was fast-forwarded, or `outcome` says why not (`timed-out`, `failed`).",
1200
- "checkout.mail-follow-failed": "Before mail woke the main coordinator, checking whether to fast-forward the project checkout failed; the mail was delivered anyway."
1367
+ "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`).",
1368
+ "checkout.mail-follow-failed": "Before mail woke the main coordinator, checking whether to fast-forward the project checkout failed; the mail was delivered anyway.",
1369
+ "checkout.message-check": "Before a typed message to the main coordinator, the backend answered whether to fast-forward the project checkout: `outcome` (`offer`, `fast-forwarded`, `turn-running`, `not-behind`, `blocked`, `no-status`), `fetch` (`fetched`, `failed`, `timed-out`, `skipped`) and `durationMs`.",
1370
+ "checkout.message-check-failed": "Before a typed message to the main coordinator, fast-forwarding to the upstream commit already fetched failed after a slow or failed fetch; the message was sent anyway."
1201
1371
  }
1202
1372
  }
1203
1373
  });
@@ -1207,15 +1377,15 @@ var REVIEW_LOG_AREAS = defineLogAreas({
1207
1377
  review: {
1208
1378
  description: "Multi Review workflows: scheduling, graph runs and interactive fix sessions.",
1209
1379
  events: {
1210
- "fix-tab.publish-failed": "A fix request was delivered but its tab could not be opened; the user is told.",
1380
+ "fix-tab.publish-failed": "A Address Findings request was delivered but its tab could not be opened; the user is told.",
1211
1381
  "graph-run.not-started": "A workflow's graph run did not start.",
1212
1382
  "reconcile.scan-failed": "A reconciliation scan failed; the next scan retries.",
1213
1383
  "graph-engine.unavailable": "The graph engine is selected but unavailable, so the bespoke engine runs.",
1214
1384
  "graph-run.cancel-failed": "Cancelling a graph run failed; the next pass projects how it ended.",
1215
1385
  "delete.cleanup-failed": "A cleanup step after deleting a workflow failed; stale tabs reconcile away on hydration.",
1216
- "fix-session.read-failed": "Reading an interactive fix session's state failed.",
1386
+ "fix-session.read-failed": "Reading an interactive Address Findings session's state failed.",
1217
1387
  "fix-outcome.read-failed": "Reading an interactive fix's outcome failed; it stays pending.",
1218
- "fix-usage.read-failed": "Reading a fix session's token usage failed.",
1388
+ "fix-usage.read-failed": "Reading an Address Findings session's token usage failed.",
1219
1389
  "result.consume-deferred": "Consuming a workflow result failed; it stays staged and is retried.",
1220
1390
  "failure-triage.failed": "Classifying a review package's failing tests failed; the package is sealed without the triage and says so."
1221
1391
  }
@@ -1268,6 +1438,7 @@ var AGENT_ACCOUNTS_LOG_AREAS = defineLogAreas({
1268
1438
  "agent-accounts": {
1269
1439
  description: "Agent accounts: automatic switching, staged logins and plan usage.",
1270
1440
  events: {
1441
+ "limit-stop-notice.failed": "A session's usage-limit stop could not be reported.",
1271
1442
  "switch-notice.failed": "A notice about an automatic account switch failed; the switch stands. `audience` says whose.",
1272
1443
  "auto-switch.check-failed": "An automatic account check failed; the next nudge retries.",
1273
1444
  "container-sync.failed": "Handing a login or account to a container failed; `step` says which part.",
@@ -1286,6 +1457,17 @@ var DOCKER_LOG_AREAS = defineLogAreas({
1286
1457
  description: "Docker containers: lifecycle, starts, staged inputs and the login files they hold.",
1287
1458
  events: {
1288
1459
  "portable-inputs.relay-missing": "Docker is rootless and the image predates the staged-input relay, so the container cannot read them until rebuilt.",
1460
+ "git-mirror.mount-unavailable": "A new container gets no project Git mirror, so its clone goes to the remote.",
1461
+ "git-mirror.refreshed": "A project's Git mirror was built or updated.",
1462
+ "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.",
1463
+ "git-mirror.low-disk": "A project's Git mirror was not updated: the disk is nearly full.",
1464
+ "git-mirror.oversized": "A project's repository is too large for a Git mirror, so its environments keep the blobless clone.",
1465
+ "git-mirror.compact-failed": "A project's Git mirror could not be compacted.",
1466
+ "git-mirror.state-write-failed": "A project's Git mirror could not be marked for checking.",
1467
+ "git-mirror.remove-failed": "A project's Git mirror could not be removed; a sweep retries.",
1468
+ "git-mirror.orphans-removed": "Git mirrors of removed projects were removed.",
1469
+ "git-mirror.clone-used": "A new environment cloned from its project's Git mirror.",
1470
+ "git-mirror.clone-fallback": "A new environment could not clone from its project's Git mirror and cloned from the remote.",
1289
1471
  "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.",
1290
1472
  "opencode.warm-incomplete": "OpenCode did not finish loading /workspace in a container.",
1291
1473
  "lifecycle-event.reconcile-failed": "Reconciling an environment after a container start or stop event failed; the next status read retries.",
@@ -1300,7 +1482,27 @@ var DOCKER_LOG_AREAS = defineLogAreas({
1300
1482
  "recovery.clear-terminals-failed": "Terminal sessions could not be cleared after a recovery restore.",
1301
1483
  "github-ranges.seed-not-copied": "The GitHub ranges seed could not be copied into a container, so its firewall fetches them.",
1302
1484
  "availability.probe-failed": "Docker is not available; written when the diagnostic changes. Fixed-shape metadata only: messages can hold daemon endpoints.",
1303
- "start.port-collision-retrying": "An automatic host port collided on start, so it is retried once with fresh ports."
1485
+ "start.port-collision-retrying": "An automatic host port collided on start, so it is retried once with fresh ports.",
1486
+ "writer-lease.lost": {
1487
+ description: "This backend lost the registry writer lease, for the fixed `reason` given. Schedules stop and container changes are refused until it restarts.",
1488
+ essential: true,
1489
+ fields: { reason: "label" }
1490
+ },
1491
+ "writer-lease.regained": {
1492
+ description: "This backend took the registry writer lease over from a holder that stopped refreshing it (it crashed, was killed or stalled), `staleForMs` after its last refresh. The counterpart of that holder's `writer-lease.lost` with reason `reclaimed`; a lease left by a clean shutdown is acquired silently.",
1493
+ essential: true,
1494
+ fields: { staleForMs: "number" }
1495
+ },
1496
+ "writer-lease.not-acquired": {
1497
+ description: "This backend started without the registry writer lease, for the fixed `reason` given. A second backend on one data directory is normal: it serves reads, runs no schedules and refuses container changes.",
1498
+ essential: true,
1499
+ fields: { reason: "label" }
1500
+ },
1501
+ "bridge.launched": {
1502
+ 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.",
1503
+ essential: true,
1504
+ fields: { provider: "label", containerPort: "number" }
1505
+ }
1304
1506
  }
1305
1507
  },
1306
1508
  "docker.reachability": {
@@ -1414,8 +1616,12 @@ var NODES_LOG_AREAS = defineLogAreas({
1414
1616
  nodes: {
1415
1617
  description: "Command nodes: links, handovers, leaf mail, ticket sync and project copies.",
1416
1618
  events: {
1619
+ ...THROTTLE_LOG_EVENTS,
1417
1620
  "actions.resume-failed": "Approved actions could not be resumed; a later pass retries.",
1418
1621
  "project-copy.notify-failed": "The coordinator could not be told a project copy finished.",
1622
+ "mail.return-deferred": "The leaf refused returned mail; it remains queued for retry.",
1623
+ "notices.take-back-failed": "A notice for this node's coordinator stayed in the outbox.",
1624
+ "notice.collected-retired": "A detached controller owned a notice with ambiguous delivery; retired without redelivery.",
1419
1625
  "mail.delivery-deferred": "Leaf mail could not reach a coordinator yet.",
1420
1626
  "command.post-step-failed": "A step after a routed command failed.",
1421
1627
  "seed-files.incomplete": "Seed files for a leaf environment were not all copied.",
@@ -1931,6 +2137,7 @@ var WEB_SYNC_LOG_AREAS = defineLogAreas({
1931
2137
  "web.read-coordinator": {
1932
2138
  description: "The renderer's coalesced, bounded backend reads.",
1933
2139
  events: {
2140
+ "poll.read-failed": "A coordinated poll's read failed; it stays on its interval.",
1934
2141
  "listener.threw": "A read state listener threw.",
1935
2142
  "read.settle-failed": "Applying a finished read's result threw."
1936
2143
  }
@@ -2008,6 +2215,146 @@ var LOG_VOCABULARY = {
2008
2215
  ...WEB_SYNC_LOG_AREAS
2009
2216
  };
2010
2217
 
2218
+ // ../protocol/src/log-essential-labels.ts
2219
+ var ERROR_NAMES = new Set([
2220
+ "Error",
2221
+ "TypeError",
2222
+ "RangeError",
2223
+ "ReferenceError",
2224
+ "SyntaxError",
2225
+ "URIError",
2226
+ "EvalError",
2227
+ "AggregateError",
2228
+ "AbortError",
2229
+ "TimeoutError",
2230
+ "SystemError"
2231
+ ]);
2232
+ var ERROR_CODES = new Set([
2233
+ "EACCES",
2234
+ "EADDRINUSE",
2235
+ "EADDRNOTAVAIL",
2236
+ "EAGAIN",
2237
+ "EBADF",
2238
+ "EBUSY",
2239
+ "ECANCELED",
2240
+ "ECONNABORTED",
2241
+ "ECONNREFUSED",
2242
+ "ECONNRESET",
2243
+ "EEXIST",
2244
+ "EHOSTUNREACH",
2245
+ "EINTR",
2246
+ "EINVAL",
2247
+ "EIO",
2248
+ "EISDIR",
2249
+ "EMFILE",
2250
+ "ENETUNREACH",
2251
+ "ENFILE",
2252
+ "ENOENT",
2253
+ "ENOMEM",
2254
+ "ENOSPC",
2255
+ "ENOSYS",
2256
+ "ENOTDIR",
2257
+ "ENOTEMPTY",
2258
+ "ENOTFOUND",
2259
+ "EPERM",
2260
+ "EPIPE",
2261
+ "EROFS",
2262
+ "ETIMEDOUT",
2263
+ "EXDEV",
2264
+ "SQLITE_BUSY",
2265
+ "SQLITE_CORRUPT",
2266
+ "SQLITE_FULL",
2267
+ "SQLITE_IOERR",
2268
+ "SQLITE_NOTADB",
2269
+ "SQLITE_READONLY",
2270
+ "ERR_CANCELED",
2271
+ "ERR_STREAM_DESTROYED"
2272
+ ]);
2273
+ var SYSCALLS = new Set([
2274
+ "open",
2275
+ "read",
2276
+ "write",
2277
+ "stat",
2278
+ "lstat",
2279
+ "mkdir",
2280
+ "rmdir",
2281
+ "readdir",
2282
+ "rename",
2283
+ "unlink",
2284
+ "fsync",
2285
+ "fdatasync",
2286
+ "close",
2287
+ "access",
2288
+ "chmod",
2289
+ "copyfile",
2290
+ "connect",
2291
+ "listen",
2292
+ "bind",
2293
+ "spawn",
2294
+ "kill",
2295
+ "getaddrinfo"
2296
+ ]);
2297
+ var SIGNALS = new Set([
2298
+ "SIGABRT",
2299
+ "SIGALRM",
2300
+ "SIGBUS",
2301
+ "SIGCHLD",
2302
+ "SIGCONT",
2303
+ "SIGFPE",
2304
+ "SIGHUP",
2305
+ "SIGILL",
2306
+ "SIGINT",
2307
+ "SIGKILL",
2308
+ "SIGPIPE",
2309
+ "SIGQUIT",
2310
+ "SIGSEGV",
2311
+ "SIGSTOP",
2312
+ "SIGTERM",
2313
+ "SIGTRAP",
2314
+ "SIGTSTP",
2315
+ "SIGTTIN",
2316
+ "SIGTTOU",
2317
+ "SIGUSR1",
2318
+ "SIGUSR2",
2319
+ "SIGWINCH",
2320
+ "SIGXCPU",
2321
+ "SIGXFSZ"
2322
+ ]);
2323
+ var PROVIDERS = new Set(["claude", "codex", "opencode", "cursor", "grok", "acp", "pi"]);
2324
+ var UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
2325
+ var SOURCE = new RegExp(`^(?:claude|codex|opencode|cursor|grok|acp|pi):${UUID}$`, "i");
2326
+
2327
+ // ../protocol/src/log-essential.ts
2328
+ var vocabulary = LOG_VOCABULARY;
2329
+ var UNDECLARED_ERROR_LABELS = new Set([
2330
+ "site",
2331
+ "kind",
2332
+ "step",
2333
+ "reason",
2334
+ "signal",
2335
+ "code"
2336
+ ]);
2337
+ function eventSpec(area, event) {
2338
+ const spec = Object.hasOwn(vocabulary, area) ? vocabulary[area] : undefined;
2339
+ if (!spec || !Object.hasOwn(spec.events, event))
2340
+ return null;
2341
+ const definition = spec.events[event];
2342
+ return typeof definition === "object" && definition.essential ? definition : null;
2343
+ }
2344
+ function declaredEssential(area, event, level) {
2345
+ const spec = eventSpec(area, event);
2346
+ return spec && (spec.minLevel !== "error" || level === "error") ? spec : null;
2347
+ }
2348
+ function hasEssentialEvents(area) {
2349
+ const spec = Object.hasOwn(vocabulary, area) ? vocabulary[area] : undefined;
2350
+ return spec !== undefined && Object.values(spec.events).some((event) => typeof event === "object" && event.essential);
2351
+ }
2352
+ function isEssentialEntry(area, event, level) {
2353
+ if (area === "logging" && event === "essential.write-failed")
2354
+ return false;
2355
+ return level === "error" || declaredEssential(area, event, level) !== null;
2356
+ }
2357
+
2011
2358
  // ../protocol/src/logger.ts
2012
2359
  var LOG_LEVELS = ["error", "warn", "info", "debug", "trace"];
2013
2360
  var MAX_FIELD_CHARS = 2048;
@@ -2052,7 +2399,9 @@ var DEFAULT_CONFIG = {
2052
2399
  level: "info",
2053
2400
  areaLevels: {},
2054
2401
  format: "text",
2055
- sink: consoleSink
2402
+ sink: consoleSink,
2403
+ essentialSink: null,
2404
+ relayEssential: false
2056
2405
  };
2057
2406
  var config = DEFAULT_CONFIG;
2058
2407
  var generation = 0;
@@ -2163,17 +2512,38 @@ function renderText(record) {
2163
2512
  function renderJson(record) {
2164
2513
  return escapeLogLine(JSON.stringify(record));
2165
2514
  }
2515
+ function offerEssential(record) {
2516
+ if (!config.essentialSink || !isEssentialEntry(record.area, record.event, record.level))
2517
+ return;
2518
+ try {
2519
+ config.essentialSink(record);
2520
+ } catch {}
2521
+ }
2166
2522
  function deliver(record) {
2523
+ let delivered = true;
2167
2524
  try {
2168
2525
  config.sink({
2169
2526
  method: OUTPUT_METHOD[record.level],
2170
2527
  line: config.format === "json" ? renderJson(record) : renderText(record),
2171
2528
  record
2172
2529
  });
2173
- return true;
2174
2530
  } catch {
2175
- return false;
2531
+ delivered = false;
2176
2532
  }
2533
+ offerEssential(record);
2534
+ return delivered;
2535
+ }
2536
+ function deliverEssentialOnly(record) {
2537
+ if (config.essentialSink) {
2538
+ offerEssential(record);
2539
+ return;
2540
+ }
2541
+ if (!config.relayEssential)
2542
+ return;
2543
+ const marked = { ...record, essentialOnly: true };
2544
+ try {
2545
+ config.sink({ method: OUTPUT_METHOD[record.level], line: renderJson(marked), record: marked });
2546
+ } catch {}
2177
2547
  }
2178
2548
  function buildRecord(level, area, event, fields) {
2179
2549
  const clean = fields ? sanitizeFields(fields, areaSpec(area)?.maxStringChars ?? MAX_FIELD_CHARS) : undefined;
@@ -2338,12 +2708,17 @@ function deliverEvent(level, area, event, fields) {
2338
2708
  return deliver(buildRecord(level, area, event, fields));
2339
2709
  }
2340
2710
  function tryWriteLog(level, area, event, fields) {
2341
- if (LEVEL_RANK[level] > thresholdRank(area))
2711
+ if (LEVEL_RANK[level] > thresholdRank(area)) {
2712
+ if (isEssentialEntry(area, event, level)) {
2713
+ deliverEssentialOnly(buildRecord(level, area, event, resolveFields(fields)));
2714
+ }
2342
2715
  return false;
2716
+ }
2343
2717
  return deliverEvent(level, area, event, resolveFields(fields));
2344
2718
  }
2345
2719
  function createLogger(area) {
2346
2720
  const spec = areaSpec(area);
2721
+ const mayHoldEssential = hasEssentialEvents(area);
2347
2722
  let seenGeneration = -1;
2348
2723
  let rank = 0;
2349
2724
  const enabled = (level) => {
@@ -2356,9 +2731,16 @@ function createLogger(area) {
2356
2731
  const writeResolved = (level, event, resolved) => {
2357
2732
  deliverEvent(level, area, event, resolved);
2358
2733
  };
2734
+ const writeFiltered = (level, event, fields) => {
2735
+ if (!mayHoldEssential || !isEssentialEntry(area, event, level))
2736
+ return;
2737
+ deliverEssentialOnly(buildRecord(level, area, event, resolveFields(fields)));
2738
+ };
2359
2739
  const write = (level, event, fields) => {
2360
- if (!enabled(level))
2740
+ if (!enabled(level)) {
2741
+ writeFiltered(level, event, fields);
2361
2742
  return;
2743
+ }
2362
2744
  writeResolved(level, event, resolveFields(fields));
2363
2745
  };
2364
2746
  return {
@@ -2369,8 +2751,10 @@ function createLogger(area) {
2369
2751
  trace: (event, fields) => write("trace", event, fields),
2370
2752
  throttled: (level, event, options) => {
2371
2753
  syncThrottleLevels();
2372
- if (!enabled(level))
2754
+ if (!enabled(level)) {
2755
+ writeFiltered(level, event, options.fields);
2373
2756
  return;
2757
+ }
2374
2758
  if (!spec || !Object.hasOwn(spec.events, event) || event.startsWith("throttle.") || !Object.hasOwn(spec.events, "throttle.recovered")) {
2375
2759
  deliver(buildRecord(level, spec ? area : "logging", spec ? "invalid-event" : "unknown-area", undefined));
2376
2760
  return;
@@ -10596,7 +10980,7 @@ var PERMISSION_RULE_PROVIDERS = [
10596
10980
  "grok",
10597
10981
  "pi"
10598
10982
  ];
10599
- var PROVIDERS = new Set(PERMISSION_RULE_PROVIDERS);
10983
+ var PROVIDERS2 = new Set(PERMISSION_RULE_PROVIDERS);
10600
10984
  var KINDS = new Set(PERMISSION_RULE_KINDS);
10601
10985
  var SCOPES = new Set(PERMISSION_RULE_SCOPES);
10602
10986
  var UNQUOTED_REFUSED = new Set([
@@ -10855,7 +11239,7 @@ var AGENT_INTERACTION_AUTHORIZATION_KINDS = [
10855
11239
  ];
10856
11240
  var INPUT_KINDS = new Set(AGENT_INTERACTION_INPUT_KINDS);
10857
11241
  var AUTHORIZATION_KINDS = new Set(AGENT_INTERACTION_AUTHORIZATION_KINDS);
10858
- var PROVIDERS2 = new Set(AGENT_INTERACTION_PROVIDERS);
11242
+ var PROVIDERS3 = new Set(AGENT_INTERACTION_PROVIDERS);
10859
11243
  var KINDS2 = new Set(AGENT_INTERACTION_KINDS);
10860
11244
  var ORIGINS = new Set(AGENT_INTERACTION_ORIGINS);
10861
11245
  var STATES = new Set(AGENT_INTERACTION_STATES);
@@ -11042,6 +11426,13 @@ var NATIVE_AGENT_USER_MCP_SERVERS_MAX = 32;
11042
11426
  function isNativeAgentUserMcpServerList(value) {
11043
11427
  return Array.isArray(value) && value.length <= NATIVE_AGENT_USER_MCP_SERVERS_MAX && value.every(isNativeAgentMcpServerName) && new Set(value).size === value.length;
11044
11428
  }
11429
+ function nativeAgentUserMcpGrant(policy) {
11430
+ const listed = policy?.capabilityPolicy?.userMcpServers;
11431
+ if (!isNativeAgentUserMcpServerList(listed))
11432
+ return;
11433
+ const denied = new Set(nativeAgentDeniedCapabilities(policy).map(nativeAgentMcpServer).filter((name) => name !== undefined));
11434
+ return listed.filter((name) => !denied.has(name));
11435
+ }
11045
11436
  var NATIVE_AGENT_USER_MCP_SELECTION = Object.freeze({
11046
11437
  claude: Object.freeze({ ordinary: true, readOnly: true }),
11047
11438
  codex: Object.freeze({ ordinary: true, readOnly: true }),
@@ -11303,6 +11694,7 @@ var PROJECTION_FIELD_SET = new Set([
11303
11694
  "asyncQuestionResponses",
11304
11695
  "contextUsage",
11305
11696
  "goal",
11697
+ "suborks",
11306
11698
  "rateLimits",
11307
11699
  "runtime",
11308
11700
  "runtimeHealthAuthoritative",
@@ -11328,6 +11720,7 @@ var OPTIONAL_PROJECTION_FIELD_SET = new Set([
11328
11720
  "asyncQuestionResponses",
11329
11721
  "contextUsage",
11330
11722
  "goal",
11723
+ "suborks",
11331
11724
  "rateLimits",
11332
11725
  "runtime",
11333
11726
  "runtimeHealthAuthoritative",
@@ -11391,6 +11784,8 @@ function startParentWatchdog(options) {
11391
11784
  var AGENT_MAIL_MAX_BODY_BYTES = 32 * 1024;
11392
11785
  var AGENT_MAIL_MAX_STORE_BYTES = 32 * 1024 * 1024;
11393
11786
  var AGENT_MAIL_DEFAULT_RETENTION_DAYS = 14;
11787
+ var AGENT_MAIL_MAX_ATTACHMENT_BYTES = 8 * 1024 * 1024;
11788
+ var AGENT_MAIL_MAX_TOTAL_ATTACHMENT_BYTES = 32 * 1024 * 1024;
11394
11789
  var AGENT_MAIL_DEFAULT_AUTONOMOUS_WAKE_BUDGET = 16;
11395
11790
  var AGENT_MAIL_DEFAULT_HOURLY_WAKE_LIMIT = 40;
11396
11791
  var ORKESTRATOR_MCP_SERVER_NAME = "orkestrator";
@@ -11485,7 +11880,7 @@ function truncateErrorUtf8(value, maximumBytes) {
11485
11880
  }
11486
11881
  function normalizedBillingError(text, status, provider) {
11487
11882
  const grok = provider === "grok" || /\bgrok build\b/i.test(text);
11488
- const label = grok ? "Grok Build" : provider === "cursor" ? "Cursor Agent" : "The agent";
11883
+ const label = grok ? "Grok Build" : "The agent";
11489
11884
  if (GROK_USAGE_EXHAUSTED.test(text) || USAGE_EXHAUSTED.test(text)) {
11490
11885
  return grok ? GROK_USAGE_EXHAUSTED_MESSAGE : `${label} usage balance is exhausted. Add usage credits, then retry this message.`;
11491
11886
  }
@@ -11600,6 +11995,51 @@ function formatAcpRpcError(error, provider) {
11600
11995
  return primary ?? detail ?? "ACP request failed";
11601
11996
  }
11602
11997
 
11998
+ // ../../bridges/acp-bridge/src/acp-jsonl-framer.ts
11999
+ class JsonlLineFramer {
12000
+ #maxLineBytes;
12001
+ #held = [];
12002
+ #heldBytes = 0;
12003
+ constructor(maxLineBytes) {
12004
+ this.#maxLineBytes = maxLineBytes;
12005
+ }
12006
+ accept(chunk, onLine) {
12007
+ let start = 0;
12008
+ let newline = chunk.indexOf(10, start);
12009
+ while (newline >= 0) {
12010
+ const lineBytes = this.#heldBytes + newline - start;
12011
+ if (lineBytes > this.#maxLineBytes) {
12012
+ this.discard();
12013
+ return "oversized";
12014
+ }
12015
+ onLine(this.#takeLine(chunk.subarray(start, newline), lineBytes));
12016
+ start = newline + 1;
12017
+ newline = chunk.indexOf(10, start);
12018
+ }
12019
+ if (start < chunk.length) {
12020
+ this.#held.push(start === 0 ? chunk : chunk.subarray(start));
12021
+ this.#heldBytes += chunk.length - start;
12022
+ }
12023
+ if (this.#heldBytes > this.#maxLineBytes) {
12024
+ this.discard();
12025
+ return "unterminated-oversized";
12026
+ }
12027
+ return;
12028
+ }
12029
+ discard() {
12030
+ this.#held = [];
12031
+ this.#heldBytes = 0;
12032
+ }
12033
+ #takeLine(tail, lineBytes) {
12034
+ if (this.#held.length === 0)
12035
+ return tail.toString("utf8");
12036
+ this.#held.push(tail);
12037
+ const line = Buffer.concat(this.#held, lineBytes).toString("utf8");
12038
+ this.discard();
12039
+ return line;
12040
+ }
12041
+ }
12042
+
11603
12043
  // ../../bridges/acp-bridge/src/acp-credentials.ts
11604
12044
  import { promises as fs } from "node:fs";
11605
12045
  import { homedir } from "node:os";
@@ -11702,6 +12142,9 @@ function effectiveExecutionPolicy(requested, env = process.env) {
11702
12142
  return requested;
11703
12143
  return coordinatorProcessPolicy();
11704
12144
  }
12145
+ function liveExecutionPolicy(state) {
12146
+ return state.policyPending ? undefined : state.policy;
12147
+ }
11705
12148
  function effectiveTurnExecutionPolicy(input) {
11706
12149
  return input.readOnly ? coordinatorProcessPolicy() : effectiveExecutionPolicy(input.policy);
11707
12150
  }
@@ -12633,6 +13076,7 @@ function grokMcpConfigStatus(loaded, current) {
12633
13076
  }
12634
13077
 
12635
13078
  // ../../bridges/acp-bridge/src/acp-context.ts
13079
+ var log3 = createLogger("bridge.acp");
12636
13080
  var CURSOR_TODO_STATUSES = ["pending", "in_progress", "completed", "cancelled"];
12637
13081
  var providerConfig = loadAcpProviderConfig();
12638
13082
  var provider = providerConfig.id;
@@ -12659,8 +13103,6 @@ var clientSessionKeys = new Map;
12659
13103
  var sessionCreations = new Map;
12660
13104
  var sessionResumes = new Map;
12661
13105
  var anonymousSessionCreations = 0;
12662
- var activeCursorToolReplays = 0;
12663
- var cursorToolReplayProcesses = new Set;
12664
13106
  var sessionListProbe = null;
12665
13107
  var persistenceTail = Promise.resolve();
12666
13108
  var persistenceScheduled = false;
@@ -12745,10 +13187,6 @@ var MAX_MODEL_ID_BYTES = 1024;
12745
13187
  var MAX_TOOL_NAME_BYTES = 256;
12746
13188
  var MAX_TOOL_TITLE_BYTES = 4 * 1024;
12747
13189
  var MAX_TOOL_PATH_BYTES = 16 * 1024;
12748
- var MAX_REPLAY_RECONCILE_TOOLS = 4096;
12749
- var MAX_CURSOR_TOOL_REPLAY_PROCESSES = 8;
12750
- var CURSOR_TOOL_REPLAY_DELAY_MS = 500;
12751
- var MAX_LIVE_CURSOR_TOOL_REPLAYS_PER_TURN = parseBoundedInteger(process.env.ACP_MAX_LIVE_CURSOR_TOOL_REPLAYS, 8, 0, 64);
12752
13190
  var MAX_DIFF_EDIT_DISTANCE = 512;
12753
13191
  var DIFF_CONTEXT_LINES = 3;
12754
13192
  var MAX_SESSIONS = parseBoundedInteger(process.env.ACP_MAX_SESSIONS, 256, 1, 256);
@@ -12807,7 +13245,7 @@ class AcpProcess {
12807
13245
  #closed = false;
12808
13246
  #readOnlyProfile;
12809
13247
  #terminationOutcome;
12810
- #stdoutBuffer = Buffer.alloc(0);
13248
+ #stdoutFramer = new JsonlLineFramer(MAX_LINE_BYTES);
12811
13249
  onUpdate = unattachedUpdate;
12812
13250
  earlyCommandsUpdate = null;
12813
13251
  onVendor = () => {
@@ -12877,6 +13315,13 @@ class AcpProcess {
12877
13315
  }
12878
13316
  this.child.once("error", (error) => this.#close(error));
12879
13317
  this.child.once("exit", (code, signal) => {
13318
+ log3.warn("agent.exited", {
13319
+ provider,
13320
+ pid: this.child.pid ?? null,
13321
+ code,
13322
+ signal,
13323
+ requested: this.#terminationOutcome === "resolved"
13324
+ });
12880
13325
  this.#close(new Error(`${provider} ACP process exited (code ${code ?? "null"}, signal ${signal ?? "null"})`), this.#terminationOutcome ?? (code === 0 ? "resolved" : "rejected"));
12881
13326
  });
12882
13327
  }
@@ -13010,24 +13455,11 @@ class AcpProcess {
13010
13455
  #acceptChunk(chunk) {
13011
13456
  if (this.#closed)
13012
13457
  return;
13013
- this.#stdoutBuffer = Buffer.concat([this.#stdoutBuffer, chunk]);
13014
- while (true) {
13015
- const newline = this.#stdoutBuffer.indexOf(10);
13016
- if (newline < 0)
13017
- break;
13018
- if (newline > MAX_LINE_BYTES) {
13019
- this.#close(new Error(`${provider} ACP emitted an oversized JSONL frame`));
13020
- this.#terminateChild("rejected");
13021
- return;
13022
- }
13023
- const line = this.#stdoutBuffer.subarray(0, newline).toString("utf8");
13024
- this.#stdoutBuffer = this.#stdoutBuffer.subarray(newline + 1);
13025
- this.#acceptLine(line);
13026
- }
13027
- if (this.#stdoutBuffer.length > MAX_LINE_BYTES) {
13028
- this.#close(new Error(`${provider} ACP emitted an unterminated oversized JSONL frame`));
13029
- this.#terminateChild("rejected");
13030
- }
13458
+ const failure = this.#stdoutFramer.accept(chunk, (line) => this.#acceptLine(line));
13459
+ if (!failure)
13460
+ return;
13461
+ this.#close(new Error(failure === "oversized" ? `${provider} ACP emitted an oversized JSONL frame` : `${provider} ACP emitted an unterminated oversized JSONL frame`));
13462
+ this.#terminateChild("rejected");
13031
13463
  }
13032
13464
  #acceptLine(line) {
13033
13465
  if (!line.trim())
@@ -13328,9 +13760,6 @@ function setSessionListProbe(value) {
13328
13760
  function adjustAnonymousSessionCreations(delta) {
13329
13761
  anonymousSessionCreations += delta;
13330
13762
  }
13331
- function adjustActiveCursorToolReplays(delta) {
13332
- activeCursorToolReplays += delta;
13333
- }
13334
13763
  function setPersistenceScheduled(value) {
13335
13764
  persistenceScheduled = value;
13336
13765
  }
@@ -13343,6 +13772,115 @@ function setShuttingDown(value) {
13343
13772
  function setCatalogProbe(value) {
13344
13773
  catalogProbe = value;
13345
13774
  }
13775
+ // ../protocol/src/execution-policy-narrowing.ts
13776
+ var APPROVALS_STRICTNESS = {
13777
+ "auto-approve": 0,
13778
+ ask: 1,
13779
+ deny: 2
13780
+ };
13781
+ var SANDBOX_STRICTNESS = {
13782
+ none: 0,
13783
+ container: 1,
13784
+ provider: 2
13785
+ };
13786
+ function networkStrictness(value) {
13787
+ return value === "restricted" ? 1 : 0;
13788
+ }
13789
+ function isSubset(candidate, of) {
13790
+ const allowed = new Set(of);
13791
+ return candidate.every((item) => allowed.has(item));
13792
+ }
13793
+ function rawCapabilityDenials(policy) {
13794
+ return [
13795
+ ...policy.capabilityPolicy?.deny ?? [],
13796
+ ...policy.capabilityPolicy?.extendedDeny ?? []
13797
+ ];
13798
+ }
13799
+ function executionPolicyWidenings(current, next) {
13800
+ if (!current)
13801
+ return [];
13802
+ const widened = [];
13803
+ if (next.id !== current.id)
13804
+ widened.push("id");
13805
+ if (APPROVALS_STRICTNESS[next.approvals] < APPROVALS_STRICTNESS[current.approvals]) {
13806
+ widened.push("approvals");
13807
+ }
13808
+ if (SANDBOX_STRICTNESS[next.sandbox] < SANDBOX_STRICTNESS[current.sandbox]) {
13809
+ widened.push("sandbox");
13810
+ }
13811
+ if (next.projectResources && !current.projectResources)
13812
+ widened.push("projectResources");
13813
+ if (networkStrictness(next.networkAccess) < networkStrictness(current.networkAccess)) {
13814
+ widened.push("networkAccess");
13815
+ }
13816
+ if (networkStrictness(next.containerNetworkAccess) < networkStrictness(current.containerNetworkAccess)) {
13817
+ widened.push("containerNetworkAccess");
13818
+ }
13819
+ const currentAllow = current.toolPolicy?.allow;
13820
+ const nextAllow = next.toolPolicy?.allow;
13821
+ const allowNarrows = currentAllow === undefined ? nextAllow === undefined || nextAllow.length === 0 : nextAllow !== undefined && isSubset(nextAllow, currentAllow);
13822
+ if (!allowNarrows)
13823
+ widened.push("toolPolicy.allow");
13824
+ if (!isSubset(current.toolPolicy?.deny ?? [], next.toolPolicy?.deny ?? [])) {
13825
+ widened.push("toolPolicy.deny");
13826
+ }
13827
+ if (!isSubset(rawCapabilityDenials(current), rawCapabilityDenials(next))) {
13828
+ widened.push("capabilityPolicy.deny");
13829
+ }
13830
+ if (!isSubset(next.capabilityPolicy?.allow ?? [], current.capabilityPolicy?.allow ?? [])) {
13831
+ widened.push("capabilityPolicy.allow");
13832
+ }
13833
+ const currentServers = nativeAgentUserMcpGrant(current);
13834
+ const nextServers = nativeAgentUserMcpGrant(next);
13835
+ if (currentServers !== undefined && (nextServers === undefined || !isSubset(nextServers, currentServers))) {
13836
+ widened.push("capabilityPolicy.userMcpServers");
13837
+ }
13838
+ return widened;
13839
+ }
13840
+ var POLICY_WIDENING_REFUSED_CODE = "policy-widening-refused";
13841
+ function policyWideningRefusal(widened) {
13842
+ return {
13843
+ error: "Execution policy can only be narrowed on a live session; a wider policy applies after the agent bridge restarts.",
13844
+ code: POLICY_WIDENING_REFUSED_CODE,
13845
+ widened
13846
+ };
13847
+ }
13848
+
13849
+ class PolicyWideningRefusedError extends Error {
13850
+ widened;
13851
+ constructor(widened) {
13852
+ super(policyWideningRefusal(widened).error);
13853
+ this.widened = widened;
13854
+ this.name = "PolicyWideningRefusedError";
13855
+ }
13856
+ refusal() {
13857
+ return policyWideningRefusal(this.widened);
13858
+ }
13859
+ }
13860
+ function assertExecutionPolicyNotWidened(current, next) {
13861
+ const widened = executionPolicyWidenings(current, next);
13862
+ if (widened.length > 0)
13863
+ throw new PolicyWideningRefusedError(widened);
13864
+ }
13865
+
13866
+ // ../protocol/src/suborks.ts
13867
+ var SUBORK_TOOL_NAME = "ask_agents";
13868
+ var AGENT_SUBORK_TOOL_NAMES = Object.freeze([SUBORK_TOOL_NAME]);
13869
+ var SUBORK_LIMITS = Object.freeze({
13870
+ targetsPerCall: 4,
13871
+ activePerSession: 8,
13872
+ totalPerSession: 64,
13873
+ retainedBatchesPerSession: 16,
13874
+ promptMaxBytes: 64 * 1024,
13875
+ nameMaxChars: 80,
13876
+ targetTextMaxChars: 200,
13877
+ storedAnswerMaxBytes: 64 * 1024,
13878
+ deliveredAnswersMaxBytes: AGENT_MAIL_MAX_BODY_BYTES - 2 * 1024,
13879
+ lineMaxChars: 240,
13880
+ errorMaxChars: 1024,
13881
+ deadlineMs: 45 * 60000
13882
+ });
13883
+
13346
13884
  // ../protocol/src/web-annotations-errors.ts
13347
13885
  var WEB_ANNOTATION_ERROR_CODES = Object.freeze([
13348
13886
  "conflict",
@@ -13606,9 +14144,6 @@ var WEB_ANNOTATION_BLOCKED_REASON_LABELS = Object.freeze({
13606
14144
  "dispatch-rejected": "Held — the agent rejected this request; retry or cancel"
13607
14145
  });
13608
14146
 
13609
- // ../../bridges/acp-bridge/src/acp-tools.ts
13610
- import { createHash as createHash4 } from "node:crypto";
13611
-
13612
14147
  // ../protocol/src/node/bridge-transcript-text.ts
13613
14148
  import { Buffer as Buffer2 } from "node:buffer";
13614
14149
  function sliceUtf8(value, maximumBytes) {
@@ -13975,7 +14510,7 @@ function boundTranscriptResponse(messages, maximumBytes, options = {}) {
13975
14510
  }
13976
14511
 
13977
14512
  // ../../bridges/acp-bridge/src/acp-persist-writer.ts
13978
- var log3 = createLogger("bridge.acp");
14513
+ var log4 = createLogger("bridge.acp");
13979
14514
  function boundPersistedSnapshot(snapshot) {
13980
14515
  const bounded = {
13981
14516
  ...snapshot,
@@ -14172,7 +14707,7 @@ function schedulePersist() {
14172
14707
  await writePersistedState();
14173
14708
  });
14174
14709
  setPersistenceTail(operation.catch((error) => {
14175
- log3.warn("state.persist-failed", { error: formatLogError(error, { stack: false }) });
14710
+ log4.warn("state.persist-failed", { error: formatLogError(error, { stack: false }) });
14176
14711
  }));
14177
14712
  }
14178
14713
  function persistState() {
@@ -15048,9 +15583,6 @@ function applyToolCallUpdate(state, update, isInitial) {
15048
15583
  syncActiveSubagentTool(state, part);
15049
15584
  if (!commitToolPartMutation(state, part, source))
15050
15585
  return;
15051
- if (state.historyReplay === false && state.status === "running" && !turnRequiresCompleteOutput(state) && isSettledToolPart(part) && isGenericCursorToolPart(part)) {
15052
- scheduleCursorToolMetadataReconcile(state);
15053
- }
15054
15586
  return part;
15055
15587
  }
15056
15588
  function namesAnotherCall(update, part) {
@@ -15065,303 +15597,9 @@ function continuesAcrossTurns(state, part, isInitial) {
15065
15597
  }
15066
15598
  return !isInitial && !isSettledToolPart(part);
15067
15599
  }
15068
- function collectReplayToolMetadata(collector, update, isInitial) {
15069
- const id = boundedString2(update.toolCallId, MAX_TOOL_ID_BYTES)?.trim();
15070
- if (!id)
15071
- return;
15072
- let call = collector.byId.get(id);
15073
- if (!call && isInitial) {
15074
- call = { id, retainedBytes: 0 };
15075
- call.retainedBytes = replayToolMetadataBytes(call);
15076
- while (collector.byId.size >= collector.capacity) {
15077
- if (!evictOldestReplayTool(collector, id))
15078
- break;
15079
- }
15080
- if (!makeReplayToolRoom(collector, call.retainedBytes, id))
15081
- return;
15082
- collector.retainedBytes += call.retainedBytes;
15083
- collector.byId.set(id, call);
15084
- }
15085
- if (!call)
15086
- return;
15087
- const candidate = { ...call };
15088
- if ("title" in update) {
15089
- candidate.title = boundedNullableString(update.title, MAX_TOOL_TITLE_BYTES);
15090
- }
15091
- if ("name" in update) {
15092
- candidate.toolName = boundedNullableString(update.name, MAX_TOOL_NAME_BYTES);
15093
- }
15094
- if ("kind" in update && !candidate.toolName) {
15095
- candidate.toolName = boundedNullableString(update.kind, MAX_TOOL_NAME_BYTES);
15096
- }
15097
- if ("rawInput" in update && isObject3(update.rawInput)) {
15098
- candidate.toolName ??= boundedString2(update.rawInput._toolName, MAX_TOOL_NAME_BYTES);
15099
- candidate.toolArgs = boundedToolArguments(update.rawInput);
15100
- }
15101
- if ("content" in update) {
15102
- candidate.contentOutputHash = replayOutputHash(toolCallContentText(update.content));
15103
- }
15104
- if ("rawOutput" in update) {
15105
- const rawOutput = update.rawOutput === null ? undefined : stringifyToolPayload(update.rawOutput);
15106
- candidate.rawOutputHash = replayOutputHash(rawOutput);
15107
- }
15108
- candidate.retainedBytes = replayToolMetadataBytes(candidate);
15109
- const growth = candidate.retainedBytes - call.retainedBytes;
15110
- if (growth > 0 && !makeReplayToolRoom(collector, growth, id))
15111
- return;
15112
- collector.retainedBytes += growth;
15113
- Object.assign(call, candidate);
15114
- }
15115
- function evictOldestReplayTool(collector, keepId) {
15116
- for (const [id, call] of collector.byId) {
15117
- if (id === keepId)
15118
- continue;
15119
- collector.byId.delete(id);
15120
- collector.retainedBytes -= call.retainedBytes;
15121
- return true;
15122
- }
15123
- return false;
15124
- }
15125
- function makeReplayToolRoom(collector, bytes, keepId) {
15126
- while (collector.retainedBytes + bytes > collector.maximumBytes) {
15127
- if (!evictOldestReplayTool(collector, keepId))
15128
- break;
15129
- }
15130
- return collector.retainedBytes + bytes <= collector.maximumBytes;
15131
- }
15132
- function replayOutputHash(value) {
15133
- return value === undefined ? undefined : createHash4("sha256").update(value).digest("hex");
15134
- }
15135
- function replayToolMetadataBytes(call) {
15136
- return Buffer.byteLength(JSON.stringify({
15137
- id: call.id,
15138
- title: call.title,
15139
- toolName: call.toolName,
15140
- toolArgs: call.toolArgs,
15141
- contentOutputHash: call.contentOutputHash,
15142
- rawOutputHash: call.rawOutputHash
15143
- }));
15144
- }
15145
- function orderedReplayTools(collector) {
15146
- return [...collector.byId.values()];
15147
- }
15148
- function transcriptToolParts(state) {
15149
- return state.messages.flatMap((message) => message.parts.flatMap((part) => part.type === "tool-invocation" ? [part] : []));
15150
- }
15151
- function normalizedToolKind(value) {
15152
- const normalized = value?.trim().toLowerCase();
15153
- return normalized || undefined;
15154
- }
15155
- function hasToolArguments(value) {
15156
- return value !== undefined && Object.keys(value).length > 0;
15157
- }
15158
- function isGenericCursorToolTitle(value) {
15159
- const normalized = value?.trim().toLowerCase();
15160
- return normalized === "read file" || normalized === "read lints" || normalized === "edit file" || normalized === "grep" || normalized === "find";
15161
- }
15162
15600
  function isSettledToolPart(part) {
15163
15601
  return part.toolState === "success" || part.toolState === "failure";
15164
15602
  }
15165
- function isGenericCursorToolPart(part) {
15166
- return isGenericCursorToolTitle(part.toolTitle) && !hasToolArguments(part.toolArgs);
15167
- }
15168
- function cursorToolReplayTargets(state, options = {}) {
15169
- if (provider !== "cursor")
15170
- return [];
15171
- const parts = transcriptToolParts(state).slice(-MAX_REPLAY_RECONCILE_TOOLS);
15172
- const firstGeneric = parts.findIndex((part) => isGenericCursorToolPart(part));
15173
- if (firstGeneric === -1)
15174
- return [];
15175
- const targets = parts.slice(firstGeneric);
15176
- if (!options.requireSettled)
15177
- return targets;
15178
- const settled = targets.filter((part) => isSettledToolPart(part));
15179
- if (!settled.some((part) => isGenericCursorToolPart(part)))
15180
- return [];
15181
- return settled;
15182
- }
15183
- function applyReplayToolMetadata(state, capturedTargets, collector, options = {}) {
15184
- const liveToolParts = new Set(transcriptToolParts(state));
15185
- const targets = capturedTargets.filter((part) => liveToolParts.has(part));
15186
- const replayed = orderedReplayTools(collector);
15187
- if (targets.length === 0 || replayed.length === 0)
15188
- return false;
15189
- const unused = new Set(replayed.keys());
15190
- const allowKindFallback = options.allowKindFallback !== false;
15191
- let changed = false;
15192
- for (const part of targets) {
15193
- const targetKind = normalizedToolKind(part.toolName);
15194
- const targetOutputHash = replayOutputHash(part.toolOutput);
15195
- const sameKind = [...unused].filter((index) => {
15196
- const replay = replayed[index];
15197
- if (normalizedToolKind(replay?.toolName) !== targetKind)
15198
- return false;
15199
- const replayHash = replay?.contentOutputHash ?? replay?.rawOutputHash;
15200
- return !(targetOutputHash !== undefined && replayHash !== undefined && replayHash !== targetOutputHash);
15201
- });
15202
- const targetPath = part.toolDiff?.filePath ?? toolArgumentPath(part.toolArgs);
15203
- const pathMatches = targetPath ? sameKind.filter((index) => toolArgumentPath(replayed[index]?.toolArgs) === targetPath) : [];
15204
- const outputMatches = targetOutputHash ? sameKind.filter((index) => {
15205
- const replay = replayed[index];
15206
- const replayHash = replay?.contentOutputHash ?? replay?.rawOutputHash;
15207
- return replayHash !== undefined && replayHash === targetOutputHash;
15208
- }) : [];
15209
- const candidateIndexes = pathMatches.length > 0 ? pathMatches : outputMatches;
15210
- const replayIndex = candidateIndexes.length === 1 ? candidateIndexes[0] : allowKindFallback && sameKind.length === 1 ? sameKind[0] : undefined;
15211
- if (replayIndex === undefined)
15212
- continue;
15213
- const replay = replayed[replayIndex];
15214
- if (!replay)
15215
- continue;
15216
- unused.delete(replayIndex);
15217
- let partChanged = false;
15218
- if (!part.toolName && replay.toolName) {
15219
- part.toolName = replay.toolName;
15220
- partChanged = true;
15221
- }
15222
- if (!hasToolArguments(part.toolArgs) && hasToolArguments(replay.toolArgs)) {
15223
- part.toolArgs = replay.toolArgs;
15224
- partChanged = true;
15225
- }
15226
- if (replay.title && isGenericCursorToolTitle(part.toolTitle) && replay.title !== part.toolTitle) {
15227
- const previousTitle = part.toolTitle;
15228
- part.toolTitle = replay.title;
15229
- if (!part.content || part.content === previousTitle)
15230
- part.content = replay.title;
15231
- partChanged = true;
15232
- }
15233
- if (partChanged) {
15234
- changed = true;
15235
- acpToolSourceStates.delete(part);
15236
- notePartMutation(state, part);
15237
- }
15238
- }
15239
- if (changed)
15240
- boundTranscript(state);
15241
- return changed;
15242
- }
15243
- async function reconcileCursorToolMetadata(state, child, targets, promptSequence, options = {}) {
15244
- if (provider !== "cursor" || shuttingDown || state.closing !== undefined || sessions.get(state.id) !== state || state.child !== child || state.promptSequence !== promptSequence || targets.length === 0)
15245
- return;
15246
- if (activeCursorToolReplays >= MAX_CURSOR_TOOL_REPLAY_PROCESSES)
15247
- return;
15248
- const capacity = Math.min(targets.length, MAX_REPLAY_RECONCILE_TOOLS);
15249
- if (capacity === 0)
15250
- return;
15251
- const collector = {
15252
- capacity,
15253
- maximumBytes: MAX_TRANSCRIPT_BYTES,
15254
- retainedBytes: 0,
15255
- byId: new Map
15256
- };
15257
- adjustActiveCursorToolReplays(1);
15258
- let replayChild;
15259
- try {
15260
- replayChild = new AcpProcess;
15261
- cursorToolReplayProcesses.add(replayChild);
15262
- (state.cursorToolReplayChildren ??= new Set).add(replayChild);
15263
- replayChild.onUpdate = (params) => {
15264
- if (params.sessionId !== state.acpSessionId || !isObject3(params.update))
15265
- return;
15266
- const update = params.update;
15267
- const kind = typeof update.sessionUpdate === "string" ? update.sessionUpdate : typeof update.type === "string" ? update.type : "";
15268
- if (kind === "tool_call" || kind === "tool_call_update") {
15269
- collectReplayToolMetadata(collector, update, kind === "tool_call");
15270
- }
15271
- };
15272
- const initialized = await replayChild.initialize();
15273
- const capabilities = isObject3(initialized.agentCapabilities) ? initialized.agentCapabilities : undefined;
15274
- if (capabilities?.loadSession !== true)
15275
- return;
15276
- await replayChild.request("session/load", {
15277
- cwd: workingDirectory,
15278
- additionalDirectories: [],
15279
- mcpServers: configuredAcpMcpServers(state.agentMcp),
15280
- sessionId: state.acpSessionId
15281
- });
15282
- if (!shuttingDown && sessions.get(state.id) === state && state.child === child && state.promptSequence === promptSequence && applyReplayToolMetadata(state, targets, collector, options)) {
15283
- state.revision += 1;
15284
- schedulePersist();
15285
- }
15286
- } catch {} finally {
15287
- try {
15288
- await replayChild?.close();
15289
- } finally {
15290
- if (replayChild) {
15291
- cursorToolReplayProcesses.delete(replayChild);
15292
- state.cursorToolReplayChildren?.delete(replayChild);
15293
- }
15294
- adjustActiveCursorToolReplays(-1);
15295
- }
15296
- }
15297
- }
15298
- function liveCursorReplayBudgetExhausted(state) {
15299
- const used = state.cursorToolReplayTurn === state.promptSequence ? state.cursorToolReplayRuns ?? 0 : 0;
15300
- return used >= MAX_LIVE_CURSOR_TOOL_REPLAYS_PER_TURN;
15301
- }
15302
- function recordCursorToolReplayRun(state) {
15303
- if (state.cursorToolReplayTurn !== state.promptSequence) {
15304
- state.cursorToolReplayTurn = state.promptSequence;
15305
- state.cursorToolReplayRuns = 0;
15306
- }
15307
- state.cursorToolReplayRuns = (state.cursorToolReplayRuns ?? 0) + 1;
15308
- }
15309
- function scheduleCursorToolMetadataReconcile(state, options = {}) {
15310
- if (provider !== "cursor" || shuttingDown || sessions.get(state.id) !== state || state.closing) {
15311
- return;
15312
- }
15313
- if (!options.final && liveCursorReplayBudgetExhausted(state))
15314
- return;
15315
- if (options.final || !state.cursorToolReplayPending) {
15316
- state.cursorToolReplayPending = options.final ? "final" : "live";
15317
- }
15318
- if (state.cursorToolReplayRunning)
15319
- return;
15320
- if (state.cursorToolReplayTimer) {
15321
- if (!options.final)
15322
- return;
15323
- clearTimeout(state.cursorToolReplayTimer);
15324
- state.cursorToolReplayTimer = undefined;
15325
- }
15326
- const run = () => {
15327
- state.cursorToolReplayTimer = undefined;
15328
- if (shuttingDown || sessions.get(state.id) !== state || state.closing)
15329
- return;
15330
- const mode = state.cursorToolReplayPending;
15331
- state.cursorToolReplayPending = undefined;
15332
- if (!mode)
15333
- return;
15334
- if (turnRequiresCompleteOutput(state))
15335
- return;
15336
- const child = state.child;
15337
- const targets = cursorToolReplayTargets(state, { requireSettled: mode === "live" });
15338
- if (!child || targets.length === 0)
15339
- return;
15340
- const promptSequence = state.promptSequence;
15341
- recordCursorToolReplayRun(state);
15342
- state.cursorToolReplayRunning = true;
15343
- reconcileCursorToolMetadata(state, child, targets, promptSequence, {
15344
- allowKindFallback: mode === "final"
15345
- }).catch(() => {
15346
- return;
15347
- }).finally(() => {
15348
- state.cursorToolReplayRunning = false;
15349
- if (state.cursorToolReplayPending) {
15350
- scheduleCursorToolMetadataReconcile(state, {
15351
- final: state.cursorToolReplayPending === "final"
15352
- });
15353
- }
15354
- });
15355
- };
15356
- state.cursorToolReplayTimer = setTimeout(run, options.final ? 0 : CURSOR_TOOL_REPLAY_DELAY_MS);
15357
- state.cursorToolReplayTimer.unref();
15358
- }
15359
- function cancelCursorToolMetadataReconcile(state) {
15360
- if (state.cursorToolReplayTimer)
15361
- clearTimeout(state.cursorToolReplayTimer);
15362
- state.cursorToolReplayTimer = undefined;
15363
- state.cursorToolReplayPending = undefined;
15364
- }
15365
15603
  function acpParentTaskUseId(update) {
15366
15604
  const candidates = [update.parentToolCallId, update.parent_tool_call_id];
15367
15605
  if (isObject3(update._meta)) {
@@ -16272,6 +16510,7 @@ var WORKFLOW_RESULT_KINDS = [
16272
16510
  "fix-result",
16273
16511
  "verification-result",
16274
16512
  "pr-result",
16513
+ "subork-answer",
16275
16514
  "graph-output",
16276
16515
  "graph-template"
16277
16516
  ];
@@ -16287,7 +16526,8 @@ var WORKFLOW_RESULT_TOOL_NAMES = {
16287
16526
  "verification-result": "submit_verification_result",
16288
16527
  "pr-result": "submit_pr_result",
16289
16528
  "graph-output": "submit_graph_output",
16290
- "graph-template": "submit_graph_template"
16529
+ "graph-template": "submit_graph_template",
16530
+ "subork-answer": "submit_subork_answer"
16291
16531
  };
16292
16532
  var WORKFLOW_RESULT_VALIDATION_TOOL_NAME = "validate_workflow_result";
16293
16533
  var REPORT_FINDING_TOOL_NAME = "report_finding";
@@ -16471,7 +16711,7 @@ function providerLabel(provider) {
16471
16711
  const configured = loadAcpProviderConfig();
16472
16712
  return configured.id === provider ? configured.name : provider;
16473
16713
  } catch {
16474
- return provider === "grok" ? "Grok" : provider === "cursor" ? "Cursor" : provider;
16714
+ return provider === "grok" ? "Grok" : provider;
16475
16715
  }
16476
16716
  }
16477
16717
  var CONVERSATION_MODES = [
@@ -17690,7 +17930,7 @@ async function readJournal(path, maxEntries) {
17690
17930
  }
17691
17931
 
17692
17932
  // ../../bridges/acp-bridge/src/grok-interjection.ts
17693
- import { createHash as createHash5, randomBytes as randomBytes5 } from "node:crypto";
17933
+ import { createHash as createHash4, randomBytes as randomBytes5 } from "node:crypto";
17694
17934
  var GROK_INTERJECT_METHOD = "_x.ai/interject";
17695
17935
  var GROK_INTERJECTION_NOTIFICATION = "_x.ai/session/interjection";
17696
17936
  var MAX_GROK_INTERJECTION_JOURNAL = 256;
@@ -17701,7 +17941,7 @@ function grokRunId(promptSequence) {
17701
17941
  return `grok:${grokBridgeGeneration}:${promptSequence}`;
17702
17942
  }
17703
17943
  function grokInterjectionDigest(text) {
17704
- return createHash5("sha256").update(text).digest("hex");
17944
+ return createHash4("sha256").update(text).digest("hex");
17705
17945
  }
17706
17946
  function parseGrokInterjectResult(value) {
17707
17947
  if (!isObject6(value) || value.status !== "queued")
@@ -17860,7 +18100,7 @@ var SOURCES = new Set([
17860
18100
  var EXECUTION_KINDS = new Set(NATIVE_AGENT_COMMAND_EXECUTION_KINDS);
17861
18101
  var ORIGINS2 = new Set(NATIVE_AGENT_COMMAND_ORIGINS);
17862
18102
  var UNAVAILABLE_REASONS = new Set(NATIVE_AGENT_COMMAND_UNAVAILABLE_REASONS);
17863
- var ERROR_CODES = new Set(NATIVE_AGENT_COMMAND_CATALOGUE_ERROR_CODES);
18103
+ var ERROR_CODES2 = new Set(NATIVE_AGENT_COMMAND_CATALOGUE_ERROR_CODES);
17864
18104
  var encoder = new TextEncoder;
17865
18105
  function utf8ByteLength(value) {
17866
18106
  if (/^[\x00-\x7f]*$/.test(value))
@@ -18132,7 +18372,7 @@ function compactCommandSelection(state) {
18132
18372
  }
18133
18373
 
18134
18374
  // ../../bridges/acp-bridge/src/acp-persistence.ts
18135
- var log4 = createLogger("bridge.acp");
18375
+ var log5 = createLogger("bridge.acp");
18136
18376
  async function listNormalizedModels(signal) {
18137
18377
  const live = mergeComposerCatalog(provider, [
18138
18378
  ...catalogCache ? [catalogCache] : [],
@@ -18180,14 +18420,14 @@ function restoreSessionConfig(candidate) {
18180
18420
  const restored = parsePersistedAcpSessionConfig(provider, candidate.sessionConfig);
18181
18421
  if (restored)
18182
18422
  return restored;
18183
- log4.warn("state.session-config-reset");
18423
+ log5.warn("state.session-config-reset");
18184
18424
  return emptySessionConfig();
18185
18425
  }
18186
18426
  if (candidate.composer !== undefined) {
18187
18427
  const composer = parsePersistedComposerState(provider, candidate.composer);
18188
18428
  if (composer)
18189
18429
  return { ...emptySessionConfig(), composer };
18190
- log4.warn("state.composer-reset");
18430
+ log5.warn("state.composer-reset");
18191
18431
  }
18192
18432
  return emptySessionConfig();
18193
18433
  }
@@ -18270,7 +18510,7 @@ async function restorePersistedState() {
18270
18510
  sessions.clear();
18271
18511
  bumpCursorDiscoveryRevision();
18272
18512
  clientSessionKeys.clear();
18273
- log4.warn("state.discarded", { error: formatLogError(error, { stack: false }) });
18513
+ log5.warn("state.discarded", { error: formatLogError(error, { stack: false }) });
18274
18514
  const file = stateFile;
18275
18515
  if (!file)
18276
18516
  return;
@@ -18343,6 +18583,7 @@ async function loadPersistedState() {
18343
18583
  transcriptTruncated: candidate.transcriptTruncated === true || Number.isSafeInteger(candidate.droppedMessages) && Number(candidate.droppedMessages) > 0 || Number.isSafeInteger(candidate.droppedParts) && Number(candidate.droppedParts) > 0,
18344
18584
  sessionConfig: restoreSessionConfig(candidate),
18345
18585
  policy: restorePersistedPolicy(candidate.policy),
18586
+ policyPending: true,
18346
18587
  ...typeof candidate.readOnly === "boolean" ? { readOnly: candidate.readOnly } : {},
18347
18588
  dispatching: false,
18348
18589
  historyReplay: false,
@@ -18797,7 +19038,7 @@ class InteractionDeadline {
18797
19038
  }
18798
19039
 
18799
19040
  // ../../bridges/acp-bridge/src/acp-command-changes.ts
18800
- import { createHash as createHash7 } from "node:crypto";
19041
+ import { createHash as createHash6 } from "node:crypto";
18801
19042
  import { resolve as resolve6 } from "node:path";
18802
19043
 
18803
19044
  // ../protocol/src/node/workspace-change-probe.ts
@@ -19799,7 +20040,7 @@ function workspaceObservationReportIssues(value) {
19799
20040
  }
19800
20041
 
19801
20042
  // ../protocol/src/node/change-tracking/evidence-spool.ts
19802
- import { createHash as createHash6, randomUUID as randomUUID2 } from "node:crypto";
20043
+ import { createHash as createHash5, randomUUID as randomUUID2 } from "node:crypto";
19803
20044
  import { readdirSync, readFileSync as readFileSync2 } from "node:fs";
19804
20045
  import { appendFile as appendFile2, mkdir as mkdir2, rename as rename2, rm as rm3, writeFile as writeFile2 } from "node:fs/promises";
19805
20046
  import { join as join7 } from "node:path";
@@ -19815,10 +20056,10 @@ var DEFAULT_EVIDENCE_SPOOL_LIMITS = {
19815
20056
  var ENTRIES_FILE = "entries.jsonl";
19816
20057
  var BODY_DIRECTORY = "bodies";
19817
20058
  function evidenceBodyId(bytes) {
19818
- return `sha256:${createHash6("sha256").update(bytes).digest("hex")}`;
20059
+ return `sha256:${createHash5("sha256").update(bytes).digest("hex")}`;
19819
20060
  }
19820
20061
  function stableEvidenceId(...parts) {
19821
- const hash = createHash6("sha256");
20062
+ const hash = createHash5("sha256");
19822
20063
  for (const part of parts)
19823
20064
  hash.update(`${part ?? ""}\x00`);
19824
20065
  return hash.digest("hex").slice(0, 40);
@@ -20461,7 +20702,7 @@ function canonicalEvidence(evidence) {
20461
20702
  }
20462
20703
 
20463
20704
  // ../../bridges/acp-bridge/src/change-evidence.ts
20464
- var log5 = createLogger("bridge.acp");
20705
+ var log6 = createLogger("bridge.acp");
20465
20706
  var MAX_DIFF_BLOCKS_PER_CALL = 100;
20466
20707
  var MAX_HELD_DIFF_BYTES = 32 * 1024 * 1024;
20467
20708
  var MAX_SEEN_CALL_IDS = 8192;
@@ -20760,7 +21001,7 @@ function recordAcpToolEvidence(state, part, update) {
20760
21001
  if (isTerminal(phase))
20761
21002
  settleRecord(state, part, record);
20762
21003
  } catch (error) {
20763
- log5.warn("evidence.record-failed", {
21004
+ log6.warn("evidence.record-failed", {
20764
21005
  errorClass: error instanceof Error ? error.name : "unknown"
20765
21006
  });
20766
21007
  }
@@ -20804,7 +21045,7 @@ function recordAcpShellObservation(state, toolUseId, observation) {
20804
21045
  ...observation.unavailableReason ? { unavailableReason: observation.unavailableReason } : {}
20805
21046
  });
20806
21047
  } catch (error) {
20807
- log5.warn("evidence.shell-record-failed", {
21048
+ log6.warn("evidence.shell-record-failed", {
20808
21049
  errorClass: error instanceof Error ? error.name : "unknown"
20809
21050
  });
20810
21051
  }
@@ -20836,14 +21077,14 @@ function endAcpTurnEvidence(state, outcome) {
20836
21077
  const writers = state.activeSubagentToolIds.size > 0 || turn.backgroundLaunched ? "may-write" : "quiescent";
20837
21078
  changeEvidenceRecorder().turn({ conversationId: state.id, turnId: turn.turnId }, outcome, writers);
20838
21079
  } catch (error) {
20839
- log5.warn("evidence.turn-record-failed", {
21080
+ log6.warn("evidence.turn-record-failed", {
20840
21081
  errorClass: error instanceof Error ? error.name : "unknown"
20841
21082
  });
20842
21083
  }
20843
21084
  }
20844
21085
 
20845
21086
  // ../../bridges/acp-bridge/src/acp-command-changes.ts
20846
- var log6 = createLogger("bridge.acp");
21087
+ var log7 = createLogger("bridge.acp");
20847
21088
  var MAX_WINDOWS_PER_SESSION = 256;
20848
21089
  var MAX_CACHED_JOURNALS = MAX_RESUMABLE_SESSIONS;
20849
21090
  var probe;
@@ -20957,7 +21198,7 @@ function closeWindow(active, state, toolUseId, role) {
20957
21198
  recordAcpShellObservation(state, toolUseId, observation);
20958
21199
  recordCommandChange(state, toolUseId, legacyCommandChange(observation));
20959
21200
  }).catch((error) => {
20960
- log6.warn("command-change.record-failed", {
21201
+ log7.warn("command-change.record-failed", {
20961
21202
  errorClass: error instanceof Error ? error.name : "unknown"
20962
21203
  });
20963
21204
  });
@@ -21016,7 +21257,7 @@ async function applyJournaledCommandChanges(state) {
21016
21257
  function journalFor(acpSessionId) {
21017
21258
  if (!journalDirectory || !acpSessionId)
21018
21259
  return;
21019
- const name = createHash7("sha256").update(acpSessionId).digest("hex").slice(0, 40);
21260
+ const name = createHash6("sha256").update(acpSessionId).digest("hex").slice(0, 40);
21020
21261
  const path = resolve6(journalDirectory, `${name}.jsonl`);
21021
21262
  let journal = journals.get(path);
21022
21263
  if (journal) {
@@ -21132,9 +21373,21 @@ async function adoptAcpSession(acpSessionId, signal, patch, policy, agentMcp) {
21132
21373
  operation.then(clear, clear);
21133
21374
  return signal ? raceAbort(operation, signal) : operation;
21134
21375
  }
21376
+ async function replaceSessionPolicy(state, policy) {
21377
+ state.policyPending = false;
21378
+ if (JSON.stringify(state.policy) === JSON.stringify(policy))
21379
+ return;
21380
+ const previous = state.child;
21381
+ state.child = null;
21382
+ clearApprovals(state);
21383
+ state.policy = policy;
21384
+ await previous?.close();
21385
+ }
21135
21386
  async function resumeExistingSession(state, signal, patch, policy, agentMcp) {
21136
21387
  if (state.closing)
21137
21388
  throw new HttpError(409, SESSION_CLOSING_ERROR);
21389
+ if (policy)
21390
+ assertExecutionPolicyNotWidened(liveExecutionPolicy(state), policy);
21138
21391
  if (state.status === "running" || state.dispatching) {
21139
21392
  throw new HttpError(409, "Session is already running");
21140
21393
  }
@@ -21142,13 +21395,8 @@ async function resumeExistingSession(state, signal, patch, policy, agentMcp) {
21142
21395
  state.agentMcp = agentMcp;
21143
21396
  state.dispatching = true;
21144
21397
  try {
21145
- if (policy && JSON.stringify(state.policy) !== JSON.stringify(policy)) {
21146
- const previous = state.child;
21147
- state.child = null;
21148
- clearApprovals(state);
21149
- state.policy = policy;
21150
- await previous?.close();
21151
- }
21398
+ if (policy)
21399
+ await replaceSessionPolicy(state, policy);
21152
21400
  await ensureSessionProcess(state, signal);
21153
21401
  if (patch)
21154
21402
  await applyComposerPatch(state, patch, signal);
@@ -21253,6 +21501,15 @@ async function createSession(clientSessionKey, signal, spawnOptions = {}) {
21253
21501
  if (existing) {
21254
21502
  if (existing.closing)
21255
21503
  throw new HttpError(409, SESSION_CLOSING_ERROR);
21504
+ const policy = spawnOptions.policy;
21505
+ if (policy) {
21506
+ assertExecutionPolicyNotWidened(liveExecutionPolicy(existing), policy);
21507
+ if (JSON.stringify(existing.policy) !== JSON.stringify(policy) && (existing.status === "running" || existing.dispatching)) {
21508
+ throw new HttpError(409, "Session is already running");
21509
+ }
21510
+ await replaceSessionPolicy(existing, policy);
21511
+ schedulePersist();
21512
+ }
21256
21513
  if (typeof spawnOptions.readOnly === "boolean") {
21257
21514
  if (existing.readOnly === true !== spawnOptions.readOnly && (existing.status === "running" || existing.dispatching)) {
21258
21515
  throw new HttpError(409, "Session is already running");
@@ -21266,8 +21523,10 @@ async function createSession(clientSessionKey, signal, spawnOptions = {}) {
21266
21523
  }
21267
21524
  }
21268
21525
  const pending = sessionCreations.get(clientSessionKey);
21269
- if (pending)
21270
- return pending;
21526
+ if (pending) {
21527
+ await pending;
21528
+ return createSession(clientSessionKey, signal, spawnOptions);
21529
+ }
21271
21530
  }
21272
21531
  if (activeSessionReservations() >= MAX_SESSIONS)
21273
21532
  throw new HttpError(429, "ACP session limit reached");
@@ -21467,6 +21726,7 @@ async function startDeferredSession(state) {
21467
21726
  var ORKESTRATOR_AUTO_ALLOWED_TOOL_NAMES = [
21468
21727
  ...AGENT_MAIL_TOOL_NAMES,
21469
21728
  ...AGENT_GOAL_TOOL_NAMES,
21729
+ ...AGENT_SUBORK_TOOL_NAMES,
21470
21730
  ...WEB_ANNOTATION_TOOL_NAMES,
21471
21731
  ...ARTIFACT_TOOL_NAMES
21472
21732
  ];
@@ -23044,7 +23304,8 @@ function configureLoggerFromEnvironment(env, options = {}) {
23044
23304
  configureLogger({
23045
23305
  ...levels.level ? { level: levels.level } : {},
23046
23306
  areaLevels: levels.areaLevels,
23047
- format
23307
+ format,
23308
+ relayEssential: options.relayToSupervisor === true
23048
23309
  });
23049
23310
  const log = createLogger("logging");
23050
23311
  if (levels.invalid.length > 0) {
@@ -23692,7 +23953,7 @@ var DEFAULT_MCP_MANAGEMENT_ROLLOUT = Object.freeze({
23692
23953
 
23693
23954
  // ../protocol/src/node/bridge-transcript-summary.ts
23694
23955
  import { Buffer as Buffer5 } from "node:buffer";
23695
- import { createHash as createHash8 } from "node:crypto";
23956
+ import { createHash as createHash7 } from "node:crypto";
23696
23957
 
23697
23958
  // ../protocol/src/node/progressive-transcript.ts
23698
23959
  var BRIDGE_TRANSCRIPT_MAX_MESSAGES = 100;
@@ -23858,7 +24119,7 @@ function digestPayload(payload) {
23858
24119
  const serialized = JSON.stringify(payload);
23859
24120
  return {
23860
24121
  bytes: Buffer5.byteLength(serialized),
23861
- digest: createHash8("sha256").update(serialized).digest("base64url").slice(0, 32)
24122
+ digest: createHash7("sha256").update(serialized).digest("base64url").slice(0, 32)
23862
24123
  };
23863
24124
  }
23864
24125
  function topLevelKey(part, index) {
@@ -24258,7 +24519,6 @@ function closeSessionRetaining(state) {
24258
24519
  async function runClose(state) {
24259
24520
  state.closing = "fenced";
24260
24521
  denyPendingRequests(state);
24261
- cancelCursorToolMetadataReconcile(state);
24262
24522
  if (state.status === "running" || state.dispatching) {
24263
24523
  state.retryCancelledPromptSequence = state.dispatching ? state.promptSequence + 1 : state.promptSequence;
24264
24524
  state.child?.notify("session/cancel", { sessionId: state.acpSessionId });
@@ -24283,8 +24543,6 @@ async function runClose(state) {
24283
24543
  }
24284
24544
  if (state.child)
24285
24545
  children.add(state.child);
24286
- for (const child of state.cursorToolReplayChildren ?? [])
24287
- children.add(child);
24288
24546
  for (const child of children)
24289
24547
  await child.close();
24290
24548
  if (Array.from(children).some((child) => !exited(child)))
@@ -24889,6 +25147,9 @@ async function route(request, response, clientSignal) {
24889
25147
  }
24890
25148
  if ((action === "prompt" || action === "compact") && request.method === "POST") {
24891
25149
  let body = await readJson(request);
25150
+ if (isNativeAgentExecutionPolicy(body.policy)) {
25151
+ assertExecutionPolicyNotWidened(liveExecutionPolicy(state), effectiveExecutionPolicy(body.policy) ?? body.policy);
25152
+ }
24892
25153
  if (action === "compact") {
24893
25154
  body = {
24894
25155
  prompt: "/compact",
@@ -24953,6 +25214,7 @@ async function route(request, response, clientSignal) {
24953
25214
  if (state.status === "running" || state.dispatching) {
24954
25215
  return json(response, 409, { error: "Session is already running" });
24955
25216
  }
25217
+ state.policyPending = false;
24956
25218
  if (selectedCommand && state.commandsLive) {
24957
25219
  const resolved = resolveSelectedCommand(state, selectedCommand);
24958
25220
  if (!resolved.ok)
@@ -25164,7 +25426,6 @@ ${structuredPromptInstruction(schema)}` : prompt;
25164
25426
  }
25165
25427
  state.revision += 1;
25166
25428
  schedulePersist();
25167
- scheduleCursorToolMetadataReconcile(state, { final: true });
25168
25429
  }, (error) => {
25169
25430
  state.status = "error";
25170
25431
  state.error = error instanceof Error ? error.message : String(error);
@@ -25175,7 +25436,6 @@ ${structuredPromptInstruction(schema)}` : prompt;
25175
25436
  state.completedAttemptUsage = undefined;
25176
25437
  state.currentTurnRequestId = undefined;
25177
25438
  state.currentTurnSawVendorUsage = undefined;
25178
- cancelCursorToolMetadataReconcile(state);
25179
25439
  reconcileStaleToolParts(state, true);
25180
25440
  settleCommandChangeWindows(state);
25181
25441
  endAcpTurnEvidence(state, "failed");
@@ -25219,7 +25479,6 @@ ${structuredPromptInstruction(schema)}` : prompt;
25219
25479
  return await closeSessionRetaining(state) === "closed" ? json(response, 200, { deleted: true }) : json(response, 503, { error: "Session close did not complete" });
25220
25480
  }
25221
25481
  denyPendingRequests(state);
25222
- cancelCursorToolMetadataReconcile(state);
25223
25482
  await state.child?.close();
25224
25483
  sessions.delete(state.id);
25225
25484
  if (state.clientSessionKey)
@@ -25501,6 +25760,9 @@ function installFatalRejectionGuard(options) {
25501
25760
  try {
25502
25761
  warn(`${options.label} Unhandled promise rejection (continuing): ${describe(reason)}`);
25503
25762
  } catch {}
25763
+ try {
25764
+ options.onRejection?.(reason);
25765
+ } catch {}
25504
25766
  };
25505
25767
  target.on("unhandledRejection", handler);
25506
25768
  return () => {
@@ -25508,6 +25770,15 @@ function installFatalRejectionGuard(options) {
25508
25770
  };
25509
25771
  }
25510
25772
 
25773
+ // ../protocol/src/node/process-failure-log.ts
25774
+ var log8 = createLogger("process");
25775
+ function logUnhandledRejection(reason) {
25776
+ log8.throttled("error", "rejection.unhandled", {
25777
+ error: reason,
25778
+ fields: () => ({ error: formatLogError(reason, { message: false }) })
25779
+ });
25780
+ }
25781
+
25511
25782
  // ../../bridges/acp-bridge/src/acp-client-disconnect.ts
25512
25783
  function watchClientDisconnect(request, response, onDisconnect) {
25513
25784
  const socket = request.socket;
@@ -25535,7 +25806,7 @@ function watchClientDisconnect(request, response, onDisconnect) {
25535
25806
  }
25536
25807
 
25537
25808
  // ../../bridges/acp-bridge/src/acp-server.ts
25538
- var log7 = createLogger("bridge.acp");
25809
+ var log9 = createLogger("bridge.acp");
25539
25810
  configureBridgeLogger();
25540
25811
  await restorePersistedState();
25541
25812
  var server = createServer((request, response) => {
@@ -25549,11 +25820,22 @@ var server = createServer((request, response) => {
25549
25820
  json(response, 401, { error: error.message, kind: "authentication-required" });
25550
25821
  return;
25551
25822
  }
25823
+ if (error instanceof PolicyWideningRefusedError) {
25824
+ log9.warn("session.policy-widening-refused", { widened: error.widened.join(",") });
25825
+ json(response, 403, error.refusal());
25826
+ return;
25827
+ }
25552
25828
  const status = error instanceof HttpError ? error.status : 500;
25829
+ if (status === 500 && !controller.signal.aborted) {
25830
+ log9.warn("http.route-failed", {
25831
+ method: request.method,
25832
+ error: formatLogError(error, { message: false })
25833
+ });
25834
+ }
25553
25835
  json(response, status, { error: error instanceof Error ? error.message : String(error) });
25554
25836
  }).finally(stopWatchingClient);
25555
25837
  });
25556
- server.listen(port, hostname, () => log7.info("server.listening", { provider, hostname, port }));
25838
+ server.listen(port, hostname, () => log9.info("server.listening", { provider, hostname, port }));
25557
25839
  var shutdownPromise = null;
25558
25840
  function shutdown() {
25559
25841
  if (shutdownPromise)
@@ -25563,18 +25845,14 @@ function shutdown() {
25563
25845
  for (const state of sessions.values()) {
25564
25846
  for (const approval of Array.from(state.approvals.values()))
25565
25847
  approval.respond();
25566
- cancelCursorToolMetadataReconcile(state);
25567
25848
  }
25568
- await Promise.allSettled([
25569
- ...[...sessions.values()].map((state) => state.child?.close()),
25570
- ...[...cursorToolReplayProcesses].map((child) => child.close())
25571
- ]);
25849
+ await Promise.allSettled([...sessions.values()].map((state) => state.child?.close()));
25572
25850
  await flushStreamingPersist();
25573
25851
  await new Promise((resolvePromise) => server.close(() => resolvePromise()));
25574
25852
  })();
25575
25853
  return shutdownPromise;
25576
25854
  }
25577
- installFatalRejectionGuard({ label: "[acp-bridge]" });
25855
+ installFatalRejectionGuard({ label: "[acp-bridge]", onRejection: logUnhandledRejection });
25578
25856
  var parentPid = parseParentPid(process.env[PARENT_PID_ENV]);
25579
25857
  if (parentPid !== null) {
25580
25858
  startParentWatchdog({
@@ -25604,7 +25882,6 @@ export {
25604
25882
  CURSOR_CHILD_DISCOVERY_SKEW_MS,
25605
25883
  CURSOR_JSONL_SOURCE_PREFIX,
25606
25884
  CURSOR_TODO_STATUSES,
25607
- CURSOR_TOOL_REPLAY_DELAY_MS,
25608
25885
  DIFF_CONTEXT_LINES,
25609
25886
  EXTERNAL_SESSION_PREFIX,
25610
25887
  FLATTENED_RETRIABLE_PROVIDER_SUFFIX,
@@ -25627,7 +25904,6 @@ export {
25627
25904
  MAX_CURSOR_TASK_PROMPT_BYTES,
25628
25905
  MAX_CURSOR_TODOS,
25629
25906
  MAX_CURSOR_TODO_CANDIDATES,
25630
- MAX_CURSOR_TOOL_REPLAY_PROCESSES,
25631
25907
  MAX_CURSOR_TRANSCRIPT_HYDRATE_CHILDREN,
25632
25908
  MAX_DIFF_EDIT_DISTANCE,
25633
25909
  MAX_EVICTED_TOOL_CALL_IDS,
@@ -25636,7 +25912,6 @@ export {
25636
25912
  MAX_GROK_INTERJECTION_TEXT_BYTES,
25637
25913
  MAX_HISTORY_MESSAGE_IDS,
25638
25914
  MAX_LINE_BYTES,
25639
- MAX_LIVE_CURSOR_TOOL_REPLAYS_PER_TURN,
25640
25915
  MAX_MESSAGES,
25641
25916
  MAX_MESSAGE_TEXT_BYTES,
25642
25917
  MAX_MODEL_ID_BYTES,
@@ -25646,7 +25921,6 @@ export {
25646
25921
  MAX_PERSISTED_SESSION_CONFIG_BYTES,
25647
25922
  MAX_PERSISTED_STRUCTURED_BYTES,
25648
25923
  MAX_PROMPT_JOURNAL,
25649
- MAX_REPLAY_RECONCILE_TOOLS,
25650
25924
  MAX_RESUMABLE_SESSIONS,
25651
25925
  MAX_SESSIONS,
25652
25926
  MAX_SESSION_LIST_PAGES,
@@ -25688,9 +25962,7 @@ export {
25688
25962
  acpToolSourceStates,
25689
25963
  acpTurnTokenCount,
25690
25964
  activateSubagent,
25691
- activeCursorToolReplays,
25692
25965
  activeSessionReservations,
25693
- adjustActiveCursorToolReplays,
25694
25966
  adjustAnonymousSessionCreations,
25695
25967
  adoptAcpSession,
25696
25968
  agentRuntime,
@@ -25705,7 +25977,6 @@ export {
25705
25977
  applyCursorUpdateTodos,
25706
25978
  applyGrokInterjectionBroadcast,
25707
25979
  applyOriginPolicy,
25708
- applyReplayToolMetadata,
25709
25980
  applySessionUpdate,
25710
25981
  applySubagentFinished,
25711
25982
  applySubagentSpawned,
@@ -25726,13 +25997,11 @@ export {
25726
25997
  boundedString2 as boundedString,
25727
25998
  boundedToolArguments,
25728
25999
  bumpCursorDiscoveryRevision,
25729
- cancelCursorToolMetadataReconcile,
25730
26000
  catalogCache,
25731
26001
  catalogProbe,
25732
26002
  clearApprovals,
25733
26003
  clearInteractions,
25734
26004
  clientSessionKeys,
25735
- collectReplayToolMetadata,
25736
26005
  commitToolPartMutation,
25737
26006
  composerPatchFromSpawn,
25738
26007
  configuredAcpMcpServers,
@@ -25746,14 +26015,11 @@ export {
25746
26015
  currentCursorDiscoveryRevision,
25747
26016
  cursorSubagentTypeLabel,
25748
26017
  cursorTaskNamedState,
25749
- cursorToolReplayProcesses,
25750
- cursorToolReplayTargets,
25751
26018
  diffFileLines,
25752
26019
  dispatchAcpPrompt,
25753
26020
  emptySessionConfig,
25754
26021
  ensureAcpToolSource,
25755
26022
  ensureSessionProcess,
25756
- evictOldestReplayTool,
25757
26023
  executable,
25758
26024
  externalSessionToken,
25759
26025
  failAllActiveSubagents,
@@ -25770,7 +26036,6 @@ export {
25770
26036
  grokQuestionTimeoutMs,
25771
26037
  grokRunId,
25772
26038
  grokWrappedToolCall,
25773
- hasToolArguments,
25774
26039
  hostname,
25775
26040
  indexActiveSubagentsFromTranscript,
25776
26041
  isAcpTodosToolName,
@@ -25779,8 +26044,6 @@ export {
25779
26044
  isCursorTaskMethod,
25780
26045
  isCursorTodosToolName,
25781
26046
  isCursorUpdateTodosMethod,
25782
- isGenericCursorToolPart,
25783
- isGenericCursorToolTitle,
25784
26047
  isGrokTodoWriteToolName,
25785
26048
  isObject3 as isObject,
25786
26049
  isSettledToolPart,
@@ -25794,9 +26057,7 @@ export {
25794
26057
  listNormalizedModels,
25795
26058
  listResumableSessions,
25796
26059
  listResumableSessionsReserved,
25797
- liveCursorReplayBudgetExhausted,
25798
26060
  loadPersistedState,
25799
- makeReplayToolRoom,
25800
26061
  mapAcpToolState,
25801
26062
  markGrokInterjectionQueued,
25802
26063
  mcpConnectionKey,
@@ -25807,9 +26068,7 @@ export {
25807
26068
  normalizeBridgeMessage,
25808
26069
  normalizeBridgePart,
25809
26070
  normalizeBridgeToolDiff,
25810
- normalizedToolKind,
25811
26071
  omitActiveSpawnDuration,
25812
- orderedReplayTools,
25813
26072
  orkestratorToolPermissionOption,
25814
26073
  parkGrokElicitation,
25815
26074
  parkGrokInteraction,
@@ -25853,10 +26112,8 @@ export {
25853
26112
  pushToolPart,
25854
26113
  raceAbort,
25855
26114
  readJson,
25856
- reconcileCursorToolMetadata,
25857
26115
  reconcileStaleToolParts,
25858
26116
  recordCursorTaskPrompt,
25859
- recordCursorToolReplayRun,
25860
26117
  recordTurnUsage,
25861
26118
  rememberCatalog,
25862
26119
  rememberHistoryMessage,
@@ -25864,8 +26121,6 @@ export {
25864
26121
  rememberTrimmedToolCalls,
25865
26122
  renderAcpToolSource,
25866
26123
  renderDiffHunks,
25867
- replayOutputHash,
25868
- replayToolMetadataBytes,
25869
26124
  requestGrokInterjection,
25870
26125
  requestPathname,
25871
26126
  requestPromptWithRetriableProviderRetries,
@@ -25884,7 +26139,6 @@ export {
25884
26139
  route,
25885
26140
  safeDiffPath,
25886
26141
  saturatedText,
25887
- scheduleCursorToolMetadataReconcile,
25888
26142
  schedulePersist,
25889
26143
  scheduleStreamingPersist,
25890
26144
  sendJson,
@@ -25925,7 +26179,6 @@ export {
25925
26179
  toolCallLifecycle,
25926
26180
  toolCallLocationPath,
25927
26181
  toolPartAgentId,
25928
- transcriptToolParts,
25929
26182
  trimNoticePartId,
25930
26183
  trimPartsTo,
25931
26184
  trimmedToolCalls,