orkestrator 2.35.4-beta → 2.36.0

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.
@@ -13,7 +13,16 @@ var AGENT_MAIL_LOG_AREAS = defineLogAreas({
13
13
  "agent-mail": {
14
14
  description: "Delivering agent mail into waiting agent sessions.",
15
15
  events: {
16
- "delivery.waiting": "The drain passed over a pending message, for a reason it had not yet logged."
16
+ "delivery.waiting": "The drain passed over a pending message, for a reason it had not yet logged.",
17
+ "drain.new-mail-failed": "Draining newly received mail failed; the next sweep delivers it.",
18
+ "presence.sync-failed": "Mailboxes could not be synchronized.",
19
+ "inject.verified": "An injected message's delivery was checked. Ids and decisions only.",
20
+ "inject.dispatched": "Messages were dispatched into a session. Ids and decisions only.",
21
+ "stopped-worker.action-failed": "Nothing could act on mail for a stopped worker.",
22
+ "coordinator.start-failed": "The main coordinator could not be started for a new message.",
23
+ "message.placed": "A message was placed in a mailbox. Ids and decisions only, never subjects or bodies.",
24
+ "budget.hold-notify-failed": "The coordinator could not be told about held worker mail.",
25
+ "budget.reset-failed": "The mail budget could not be reset for a prompted tab."
17
26
  }
18
27
  }
19
28
  });
@@ -35,6 +44,30 @@ var BACKEND_LOG_AREAS = defineLogAreas({
35
44
  "job.failed": "One pass of the job named in `scope` failed; its next pass retries.",
36
45
  ...THROTTLE_LOG_EVENTS
37
46
  }
47
+ },
48
+ backend: {
49
+ description: "The backend process: startup, background notices and shutdown.",
50
+ events: {
51
+ starting: "The backend process is starting.",
52
+ "ssh-socket.resolved": "An SSH agent socket was found.",
53
+ "ssh-socket.missing": "No usable SSH agent socket was found.",
54
+ "standalone-updater.mismatch": "--standalone-updater does not match --data-dir, so self-update is off.",
55
+ "instance.publish-failed": "The instance descriptor could not be published.",
56
+ "instance.republish-failed": "The instance descriptor could not be republished; a later pass retries.",
57
+ "parent.exited": "The parent process exited, so local servers are shutting down.",
58
+ "startup.step-failed": "One part of startup failed and the backend carried on; `step` says which.",
59
+ "startup.setup-fence-failed": "An environment's interrupted setup could not be fenced.",
60
+ "startup.setup-adopt-failed": "An environment's pending setup could not be adopted.",
61
+ "startup.deletion-pending": "An interrupted environment deletion stays pending. Its owning step logged the detail.",
62
+ "startup.looped-review-pending": "Cleanup of the retired Looped Review stays pending.",
63
+ "notice.failed": "A background notice after a turn or prompt failed; `step` says which.",
64
+ "artifacts.live-unavailable": "Live interactive artifacts are unavailable.",
65
+ "shutdown.step-failed": "One part of shutdown failed and the rest went on; `step` says which.",
66
+ "shutdown.signal-received": "A signal started shutdown, which tells a clean quit from the backend being killed.",
67
+ "shutdown.finished": "Shutdown finished, and the process exits with `code`.",
68
+ "port-policy.second-backend": "Another backend serves the default data directory, so this one avoids its ports.",
69
+ "port-policy.serve-on-free-port": "--tailscale-serve is on a free gateway port; pass --port with --strict-gateway-port to keep one."
70
+ }
38
71
  }
39
72
  });
40
73
 
@@ -42,11 +75,12 @@ var BACKEND_LOG_AREAS = defineLogAreas({
42
75
  var MAX_BRIDGE_DIAGNOSTIC_BYTES = 8192;
43
76
  var BRIDGE_LOG_AREAS = defineLogAreas({
44
77
  "bridge.diagnostics": {
45
- description: "Metadata snapshots of bridge turns and processes, written while Save Logs for Debugging is on. docs/architecture/bridge-diagnostics.md reads them.",
78
+ description: "Metadata snapshots of bridge turns and processes: lifecycle, stalls and a keepalive at info, every minute at debug, and each change at trace. docs/architecture/bridge-diagnostics.md reads them.",
46
79
  tag: "bridge-diagnostics",
47
80
  maxStringChars: MAX_BRIDGE_DIAGNOSTIC_BYTES,
48
81
  events: {
49
- heartbeat: "The once-a-minute snapshot of a turn or process that is still open.",
82
+ heartbeat: "A periodic snapshot of an open turn or process: every minute at debug; at info only as stall evidence (a stall starting or clearing, a late timer, a change during a silent stall) or the ten-minute keepalive.",
83
+ change: "At trace only: a snapshot written as soon as the phase, the pending tools or a counter past its threshold changes.",
50
84
  "send-started": "A turn or process diagnostic scope began.",
51
85
  "send-resolved": "The provider accepted a dispatch.",
52
86
  "cancel-requested": "Cancellation of a turn was requested.",
@@ -127,6 +161,7 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
127
161
  "session.created": "A session was created or recovered.",
128
162
  "session.delete-failed": "Deleting a session failed.",
129
163
  "session.fork-failed": "Forking a session failed.",
164
+ "session.policy-widening-refused": "A config request tried to widen a live session's execution policy and was refused; widened names the axes.",
130
165
  "session.rename-failed": "Renaming a session failed.",
131
166
  "session.resolve-failed": "A session could not be found or loaded for a request; action names the request.",
132
167
  "session.rewind-failed": "Rewinding session files failed.",
@@ -259,6 +294,7 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
259
294
  "backend.keychain-link-remove-failed": "An agent-test profile kept a legacy link to the host keychain.",
260
295
  "backend.start-failed": "The Local backend did not start; continuing with remote machines.",
261
296
  "clipboard.write-failed": "Writing text to the system clipboard failed.",
297
+ "dev-mode.ignored-packaged": "A packaged app was launched with ELECTRON_DEV=1 and ignored it; it loads its bundled renderer.",
262
298
  "instance.already-running": "Another instance holds this data directory; this one will quit.",
263
299
  "main-thread.stalled": "A timer fired late, so windows, IPC and the stdout reader waited.",
264
300
  "quit.stopping-backend": "The app is quitting and has asked the Local backend to stop.",
@@ -331,7 +367,8 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
331
367
  description: "Preparing the pinned agent toolchain at desktop startup.",
332
368
  events: {
333
369
  "bootstrap-progress.show-failed": "The toolchain progress window could not be shown.",
334
- "prepare.failed": "Preparing the pinned agent tools failed."
370
+ "prepare.failed": "Preparing the pinned agent tools failed.",
371
+ "prepare.ready": "The pinned agent tools were verified and activated; durationMs is how long startup waited."
335
372
  }
336
373
  },
337
374
  "artifact-host": {
@@ -345,7 +382,7 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
345
382
  // ../protocol/src/log-vocabulary/environment.ts
346
383
  var ENVIRONMENT_LOG_AREAS = defineLogAreas({
347
384
  environment: {
348
- description: "Environment naming, held setup and cleanup after deletion.",
385
+ description: "Environment naming, setup, status, moves, deletion and cleanup afterwards.",
349
386
  events: {
350
387
  "cleanup.branch-kept": "A deleted environment's local branch was kept, as it may hold unmerged work.",
351
388
  "rename.failed": "Naming an environment from its pending prompt failed for the first time.",
@@ -354,6 +391,40 @@ var ENVIRONMENT_LOG_AREAS = defineLogAreas({
354
391
  "setup.attention-not-recorded": "Held setup could not be recorded as needing the user's attention.",
355
392
  "setup.coordinator-not-notified": "The worker's coordinator could not be told that its setup is held for approval.",
356
393
  "setup.unknown-environment": "The renderer was asked to act on the setup of an environment it does not hold.",
394
+ "cleanup.rearmed": "A deleted environment's stopped cleanup is retried once under a new backend version.",
395
+ "cleanup.exhausted": "A deleted environment's cleanup keeps failing after its attempts; written once per environment.",
396
+ "cleanup.retry-not-admitted": "A cleanup retry was not admitted; the entry stays for the next start.",
397
+ "cleanup.step-failed": "One step of a deleted environment's cleanup failed; a later reconcile retries it.",
398
+ "cleanup.record-failed": "A finished cleanup step could not be recorded, so it may run again.",
399
+ "cleanup.sweep-failed": "A cleanup sweep failed; written once per sweep.",
400
+ "cleanup.reconcile-failed": "A cleanup reconcile pass failed; the next one retries.",
401
+ "orphan-state.remove-failed": "An orphaned environment state directory could not be removed.",
402
+ "orphan-state.removed": "Orphaned environment state directories were removed.",
403
+ "orphan-state.sweep-failed": "Sweeping orphaned environment state failed.",
404
+ "orphan-canvas.removed": "Orphaned design canvases were removed.",
405
+ "orphan-canvas.sweep-failed": "Sweeping orphaned design canvases failed.",
406
+ "orphan-branches.swept": "Orphaned environment branches were deleted, or kept as they may hold unmerged work.",
407
+ "stray-workspace.remove-failed": "A stray workspace directory could not be removed.",
408
+ "stray-workspace.removed": "Stray workspace directories were removed.",
409
+ "stray-workspace.kept": "Unowned workspace directories that hold files were kept; remove them by hand if unneeded.",
410
+ "temp-files.removed": "Abandoned temp files were removed.",
411
+ "status.ownership-probe-failed": "A strict container ownership probe failed, so the stored status is kept.",
412
+ "status.docker-error": "A transient Docker error stopped a status read, so the stored status is kept.",
413
+ "setup.clear-launch-failed": "A pending agent launch could not be cleared after setup failed.",
414
+ "setup.record-failure-failed": "A setup failure before its first attempt could not be recorded.",
415
+ "lifecycle.failed": "Starting, rebuilding or recreating an environment failed; `operation` says which.",
416
+ "tab-teardown.pending": "A tab's teardown failed and stays pending; the reconcile sweep retries.",
417
+ "tab-reconcile.skipped": "Orphaned tab reconciliation was skipped because pane layouts are unreadable.",
418
+ "orphan-session.reaped": "A native session no tab references was torn down.",
419
+ "handoff-sweep.failed": "Sweeping transferred transcripts no tab references failed.",
420
+ "delete.terminals-survived": "Terminal process trees outlived termination, so the deletion stops.",
421
+ "delete.artifacts-left": "Graph run artifact directories were not removed.",
422
+ "delete.worktrees-kept": "Graph runs kept branch worktrees.",
423
+ "delete.step-failed": "One best-effort part of deleting an environment failed; `step` says which, and the rest goes on.",
424
+ "merge-cleanup.resume-failed": "A merge cleanup interrupted by a restart could not be resumed.",
425
+ "move.sessions-not-moved": "A provider's sessions could not follow a moved environment.",
426
+ "move.recovery-failed": "Recovering an interrupted environment move failed.",
427
+ "stop.settle-activity-failed": "Agent activity could not be settled after a runtime stopped.",
357
428
  ...THROTTLE_LOG_EVENTS
358
429
  }
359
430
  }
@@ -362,10 +433,50 @@ var ENVIRONMENT_LOG_AREAS = defineLogAreas({
362
433
  // ../protocol/src/log-vocabulary/gateway.ts
363
434
  var GATEWAY_LOG_AREAS = defineLogAreas({
364
435
  gateway: {
365
- description: "The remote gateway other devices and browsers connect through.",
436
+ description: "The gateway other devices, browsers and the desktop connect through.",
366
437
  events: {
367
438
  "remote.start-failed": "The desktop could not start the remote gateway.",
368
- "remote.stop-failed": "The desktop could not stop the remote gateway cleanly."
439
+ "remote.stop-failed": "The desktop could not stop the remote gateway cleanly.",
440
+ disabled: "The gateway is disabled by its environment variable.",
441
+ "tailscale.no-address": "No Tailscale address was found, so the gateway did not start.",
442
+ "tailscale.no-address-fallback": "No Tailscale address was found, so the gateway binds its fallback address.",
443
+ "control.listening": "The backend control listener is up.",
444
+ "browser.listening": "The browser listener is up.",
445
+ "browser.unavailable": "The browser listener could not start; control remains if started, or loopback is attempted.",
446
+ "browser.unavailable-degraded": "No browser listener was started (`reason=no-tailscale-address`); control remains if started, or loopback is attempted.",
447
+ "loopback.listening": "The loopback client listener is up.",
448
+ "loopback.unavailable": "The loopback client listener could not start.",
449
+ "auth-token.stored": "The gateway token's file was written. The path only, never the token.",
450
+ "auth-token.persist-failed": "The gateway token could not be saved.",
451
+ "port.fallback": "The preferred port was taken, so a nearby one is used.",
452
+ "port.fallback-distant": "The preferred port and those nearby were taken, so another is used.",
453
+ "request.failed": "A gateway request failed. Throttled: repeats are counted, not written.",
454
+ "websocket.upgrade-failed": "A WebSocket upgrade failed.",
455
+ "events.client-dropped": "An event-stream client buffered too much and was dropped; it reconnects and refetches.",
456
+ "proxy.client-disconnected": "A proxy client went away, so its upstream request was aborted.",
457
+ "throttle.suppressed": "Repeats of the throttled `site` were counted over a window, not written.",
458
+ "throttle.recovered": "The throttled `site` succeeded again, so its fault has cleared.",
459
+ "throttle.evicted": "The tracked-key limit dropped the `site`, so no recovered line follows unless it fails again."
460
+ }
461
+ },
462
+ "gateway.terminal": {
463
+ description: "The gateway's terminal WebSocket.",
464
+ events: {
465
+ "upgrade-rejected": "A terminal WebSocket upgrade was refused.",
466
+ "socket-error": "A terminal WebSocket reported an error.",
467
+ "subscription-failed": "A terminal subscription failed.",
468
+ "operation-failed": "A terminal operation failed. Fixed text: the operation can hold terminal input."
469
+ }
470
+ },
471
+ "gateway.tailscale": {
472
+ description: "Tailscale Serve for desktop web access and a standalone backend.",
473
+ events: {
474
+ "web-access.disable-failed": "Desktop web access could not be turned off.",
475
+ "web-access.enable-failed": "Desktop web access could not be turned on.",
476
+ "web-access.cleanup-failed": "Cleaning up after a failed enable also failed.",
477
+ "web-access.reset-failed": "Desktop web access could not be reset.",
478
+ "startup.init-failed": "Desktop web access could not be initialized at startup.",
479
+ available: "Tailscale Serve is publishing the gateway."
369
480
  }
370
481
  }
371
482
  });
@@ -376,6 +487,18 @@ var LOCAL_SERVER_LOG_AREAS = defineLogAreas({
376
487
  description: "Agent bridge processes the backend runs on the host.",
377
488
  events: {
378
489
  "bridge.not-answering": "A bridge with work in progress fails health checks, so it is not restarted yet.",
490
+ "bridge-runtime.installing": "A bridge runtime is being installed.",
491
+ "bridge-runtime.installed": "A bridge runtime finished installing.",
492
+ "opencode.database-lost-retrying": "OpenCode lost its shared database at startup, so it is retried.",
493
+ "server.stopping": "A local server is being stopped, for the fixed `reason` given.",
494
+ "reaper.tmux-list-failed": "Orphaned claude-tmux sessions could not be listed.",
495
+ "reaper.tmux-kill-failed": "An orphaned tmux session could not be killed.",
496
+ "reaper.tmux-reaped": "Orphaned claude-tmux sessions of a deleted environment were killed.",
497
+ "reaper.runtime-root-remove-failed": "A claude-tmux runtime root could not be removed; it stays for a retry.",
498
+ "reaper.server-unidentified": "An orphan candidate could not be identified, so its record is kept.",
499
+ "reaper.server-refused": "An orphan candidate leads no process group, so it was not reaped.",
500
+ "reaper.server-reaping": "An orphaned server is being stopped.",
501
+ "reaper.server-kill-failed": "An orphaned server did not exit.",
379
502
  ...THROTTLE_LOG_EVENTS
380
503
  }
381
504
  }
@@ -417,7 +540,12 @@ var MODEL_LOG_AREAS = defineLogAreas({
417
540
  models: {
418
541
  description: "Agent model catalogues and their persistent caches.",
419
542
  events: {
420
- "cache.write-failed": "A successful catalogue refresh could not update the host cache."
543
+ "cache.write-failed": "A successful catalogue refresh could not update the host cache.",
544
+ "seed.pi-failed": "The host Pi model catalogue could not be seeded; the next launch retries.",
545
+ "bridge.not-ready": "The first-use catalogue bridge did not become ready.",
546
+ "bridge.start-failed": "The first-use catalogue bridge failed to start.",
547
+ "probe.exit-unclean": "A catalogue probe or sign-in server did not exit cleanly.",
548
+ "download.deferred": "A model catalogue could not be downloaded yet."
421
549
  }
422
550
  }
423
551
  });
@@ -428,8 +556,62 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
428
556
  description: "Native agent sessions and what the backend reads from their bridges.",
429
557
  events: {
430
558
  "catalogue.outdated-bridge": "A bridge predates the command catalogue, so its commands stay unavailable.",
559
+ "compact.instructions-ignored": "A bridge compacted without confirming the instructions sent with /compact: it predates them.",
560
+ "handoff.summary-read-failed": "Change summaries could not be read for a handoff, so the carrier says they are unmeasured.",
561
+ "handoff.consume-failed": "A delivered handoff could not be marked consumed.",
562
+ "job.pr-refresh-rollback-failed": "Rolling back a pull request refresh for a job failed.",
563
+ "job.resend-queue-failed": "A resend could not be queued for a job.",
564
+ "interaction.requests-dropped": "Interaction requests that could not be mapped were dropped.",
565
+ "interaction.observe-failed": "Observing a session's interactions failed. Error class only.",
566
+ "human-prompt.listener-failed": "A human prompt listener threw; the others still run.",
567
+ "question.attention-record-failed": "Attention for an async question could not be recorded; the transcript stays readable.",
568
+ "activity.reconcile-failed": "Reconciling an environment's activity failed. Error class only.",
569
+ "activity.persist-failed": "An environment's activity could not be saved.",
570
+ "pr-refresh.schedule-failed": "A pull request refresh after completion could not be scheduled.",
571
+ "launch.startup-failed": "A startup launch failed; it retries unless `permanent`.",
572
+ "queue.failing": "A native prompt queue keeps failing. The key and reason only, never the prompt.",
573
+ "provider.retire-failed": "Retiring an obsolete provider failed.",
574
+ "workflow-result.store-unavailable": "The workflow result store is unavailable, so the provider's result is used.",
575
+ "catalogue.refresh-failed": "A provider's command catalogue could not be refreshed.",
576
+ "dispatch.attach-failed": "Attaching an agent before dispatch failed; the prompt request answers authoritatively.",
577
+ "coordinator-context.ack-failed": "Coordinator repository context could not be acknowledged.",
578
+ "naming.prepare-failed": "First-prompt naming could not be prepared; the prompt still goes ahead.",
579
+ "interrupt.persist-failed": "A turn interrupt could not be saved, so automatic publication stays fenced.",
580
+ "resume.close-replaced-failed": "The session a resume replaced could not be closed.",
581
+ "sign-in.check-failed": "A turn could not be checked for a login refusal.",
582
+ "sign-in.resend-failed": "Sending refused prompts after sign-in failed.",
583
+ "sign-in.prompt-resend-failed": "One refused prompt could not be sent again after sign-in. Error class only.",
584
+ "shutdown.checkpoints-skipped": "Shutdown skipped display-tail checkpoints; provider history stays authoritative. Count only.",
585
+ "turn-recovery.failed": "Recovering an incomplete turn failed.",
586
+ "turn-recovery.exhausted": "A turn failed again after automatic recovery and is left for the user.",
587
+ "turn-recovery.retrying": "An incomplete or provider-failed turn is being retried automatically.",
588
+ "usage-limit.resend-failed": "Resending after a usage limit failed. An unknown send stays in the journal.",
589
+ "title.strategy-failed": "A session title strategy failed, so the next is tried. Content-free: the error can quote the prompt.",
431
590
  ...THROTTLE_LOG_EVENTS
432
591
  }
592
+ },
593
+ "native-agent.goal": {
594
+ description: "The /goal loop: advancing goals and their verifiers.",
595
+ events: {
596
+ "advance.failed": "A goal could not advance; the next sweep retries.",
597
+ "attention.record-failed": "Attention for a goal could not be recorded.",
598
+ "turn-end.settle-failed": "Turn-end work for a goal could not be settled.",
599
+ "verifier.finish-failed": "A verifier failed to finish; the goal stays verifying, so the next sweep runs it again.",
600
+ "verifier.stop-failed": "An earlier verifier could not be stopped.",
601
+ "recover.failed": "Goals could not be recovered at startup."
602
+ }
603
+ },
604
+ "native-agent.opencode": {
605
+ description: "The OpenCode provider: its request monitor, retries and agent tools.",
606
+ events: {
607
+ "retry.abort-failed": "Aborting an automatic retry failed. Error class only.",
608
+ "retry.abort-not-scheduled": "An automatic retry abort could not be scheduled. Error class only.",
609
+ "agent-tools.unavailable": "OpenCode agent tools remain unavailable for a session.",
610
+ "coordinator-servers.unavailable": "OpenCode coordinator research servers are unavailable.",
611
+ "monitor.reconnecting": "The request monitor lost its stream and is reconnecting. Error class only.",
612
+ "worker-limit.reached": "The bounded request workers are full, so the stream restarts and a snapshot reconciles.",
613
+ "request.failed": "Handling a request event failed, so the stream restarts. Error class only."
614
+ }
433
615
  }
434
616
  });
435
617
 
@@ -452,6 +634,17 @@ var PREVIEW_LOG_AREAS = defineLogAreas({
452
634
  "partitions.retry-forgotten-failed": "Retrying a forgotten preview cleanup failed.",
453
635
  "port-hints.persist-failed": "Preview port hints could not be saved.",
454
636
  "transport.close-failed": "A preview transport could not be closed.",
637
+ "ca-bundle.read-failed": "The upstream CA bundle could not be read.",
638
+ "publication.start-failed": "Private preview publication did not start.",
639
+ "publication.reconfigure-failed": "Preview publication could not be reconfigured.",
640
+ "publication.listening": "Private preview origins are listening.",
641
+ "certificate.reloaded": "The preview certificate was reloaded.",
642
+ "access.revoked-close-failed": "A revoked preview resource could not be closed. Error class only.",
643
+ "registry.invalid-definition": "An invalid stored preview service definition was ignored.",
644
+ "registry.environment-reconcile-failed": "An environment's preview services could not be reconciled.",
645
+ "registry.resolver-failed": "A preview resolver failed. Error class only.",
646
+ "registry.revocation-listener-failed": "A preview revocation listener threw. Error class only.",
647
+ "registry.change-emit-failed": "A preview change event could not be emitted. Error class only.",
455
648
  ...THROTTLE_LOG_EVENTS
456
649
  }
457
650
  }
@@ -470,9 +663,33 @@ var RUNTIME_LOG_AREAS = defineLogAreas({
470
663
  // ../protocol/src/log-vocabulary/terminal.ts
471
664
  var TERMINAL_LOG_AREAS = defineLogAreas({
472
665
  terminal: {
473
- description: "The renderer's terminal. Its lines stay in the browser console, never the saved log.",
666
+ description: "Terminals. The renderer's lines stay in the browser console; the backend's reach the saved log.",
474
667
  events: {
475
668
  "input.undelivered": "A keystroke did not reach a shell: `no-session` or `not-delivered`.",
669
+ "orphan.reaped": "A terminal no tab references was closed.",
670
+ "agent-completion.notify-failed": "A terminal agent's completion could not be reported.",
671
+ "activity.record-failed": "Terminal environment activity could not be recorded.",
672
+ "pty.exit-listener-failed": "A terminal exit listener threw; the others still run.",
673
+ "pty.exit-notify-failed": "Notifying a terminal's exit failed.",
674
+ "pty.late-exit-listener-failed": "A listener added after a terminal exited threw.",
675
+ "setup.pty-reused": "A setup terminal reused its existing PTY.",
676
+ "setup.pty-spawning": "A setup terminal is spawning its PTY. The argument count only, never the arguments.",
677
+ "setup.pty-spawned": "A setup terminal's PTY started.",
678
+ "setup.pty-exited": "A setup terminal's PTY exited.",
679
+ "setup.preparing": "Workspace preparation started in the setup terminal.",
680
+ "setup.session-creating": "A setup session is being created.",
681
+ "setup.intro-emitted": "The setup intro was written to the terminal.",
682
+ "setup.completed": "Setup finished.",
683
+ "setup.failed": "Setup failed.",
684
+ "setup.already-complete": "Setup was requested but had already finished.",
685
+ "setup.renderer-ensured": "The renderer asked for setup to be running.",
686
+ "setup.renderer-requested": "The renderer asked for the setup session.",
687
+ "setup.renderer-requested-none": "The renderer asked for a setup session that does not exist.",
688
+ "setup.no-commands": "An environment has no setup commands to run.",
689
+ "setup.already-running": "Setup was requested while it was already running.",
690
+ "setup.held-for-approval": "Setup is held until its commands are approved.",
691
+ "setup.renderer-checked-session": "The renderer asked whether a setup terminal session exists.",
692
+ "setup.renderer-requested-buffer": "The renderer asked for a setup terminal's output buffer. A size only, never its contents.",
476
693
  "input.resume-failed": "Asking the backend to resume refused terminal input failed.",
477
694
  "input.write-failed": "Writing input to a terminal session threw.",
478
695
  "listener.remove-failed": "Removing a terminal output listener threw.",
@@ -572,13 +789,41 @@ var TERMINAL_LOG_AREAS = defineLogAreas({
572
789
  // ../protocol/src/log-vocabulary/tmux.ts
573
790
  var TMUX_LOG_AREAS = defineLogAreas({
574
791
  tmux: {
575
- description: "The poll loop behind a Claude tmux tab.",
792
+ description: "Claude tmux tabs: launch, the poll loop, cleanup and the tmux prompt queue.",
576
793
  events: {
577
794
  "poll.discovery-failed": "Finding the session's transcript failed; a later tick retries.",
578
795
  "poll.snapshot-failed": "Reading the hook and transcript state failed; the next tick retries.",
579
796
  "poll.drain-pending-failed": "Delivering pending hook events failed; the next tick retries.",
580
797
  "poll.drain-timeouts-failed": "Delivering hook timeouts failed; the next tick retries.",
581
798
  "poll.tail-failed": "Reading new transcript lines failed; the next tick retries.",
799
+ "cleanup.session-stop-failed": "A tmux session could not be stopped while cleaning up an environment.",
800
+ "cleanup.skipped": "Environment tmux cleanup was skipped because tmux could not be reached and nothing required it.",
801
+ "cleanup.environments-load-failed": "Environments could not be loaded during tmux cleanup, so it stays incomplete.",
802
+ "cleanup.kill-failed": "An environment's tmux sessions could not be killed.",
803
+ "hooks.uninstall-failed": "Workspace hooks could not be uninstalled.",
804
+ "hooks.git-exclude-failed": "The git exclude for Claude's local settings could not be set.",
805
+ "naming.prepare-failed": "First-prompt naming could not be prepared; the prompt still goes ahead.",
806
+ "orphans.skipped": "Orphan reconciliation was skipped because pane layouts are unreadable.",
807
+ "orphan.reaped": "A tmux session no tab references was killed.",
808
+ "orphan.kill-skipped": "An orphan tmux kill was skipped because the tmux server could not be reached.",
809
+ "cli.thinking-display-probe-failed": "Probing the CLI for --thinking-display failed, so it launches without it.",
810
+ "cli.fast-mode-unsupported": "The claude CLI lacks --settings, so it launches without fast mode.",
811
+ "cli.effort-unsupported": "The claude CLI lacks --effort, so it launches without it.",
812
+ "interactive.snapshot-failed": "An interactive snapshot failed; expected while a pane is closing.",
813
+ "signal.arm-failed": "The Claude state signal could not be armed.",
814
+ "signal.degraded": "The Claude state signal missed a change or rang too often, so polling stays at one second until it is re-armed.",
815
+ "hook-signal.arm-failed": "The tmux hook doorbell could not be armed.",
816
+ "hook-signal.degraded": "The tmux hook doorbell missed a hook, so idle tabs poll every second until it is re-armed.",
817
+ "pr-refresh.schedule-failed": "A pull request refresh after a turn could not be scheduled.",
818
+ "pr-probe.failed": "Probing for a pull request an agent created failed.",
819
+ "activity.persist-failed": "Tmux tab activity could not be saved.",
820
+ "fast-mode.persist-failed": "The launch fast mode could not be saved.",
821
+ "fast-mode.repair-failed": "Fast mode metadata could not be repaired on a reattached session.",
822
+ "pane.observe-failed": "A pane observation failed. Error class only: pane contents are sensitive.",
823
+ "turn.failure-record-failed": "A failed turn could not be recorded.",
824
+ "slash-command.settle-timeout": "Timed out waiting for a Claude slash command to settle.",
825
+ "queue.failing": "A tmux prompt queue keeps failing to dispatch.",
826
+ "queue.rename-failed": "An environment could not be named from its first prompt; the prompt still goes ahead.",
582
827
  ...THROTTLE_LOG_EVENTS
583
828
  }
584
829
  }
@@ -605,7 +850,8 @@ var UPDATER_LOG_AREAS = defineLogAreas({
605
850
  "remote.unavailable": "Updates requested by remote clients are unavailable in this session.",
606
851
  "restart-prompt.failed": "The restart prompt for a downloaded update failed.",
607
852
  unavailable: "Auto-update could not be set up in this session.",
608
- "update.failed": "electron-updater reported an update error."
853
+ "update.failed": "electron-updater reported an update error.",
854
+ "standalone.restarting": "A standalone backend is restarting into a new version."
609
855
  }
610
856
  }
611
857
  });
@@ -616,11 +862,473 @@ var WEB_ANNOTATIONS_LOG_AREAS = defineLogAreas({
616
862
  description: "Web annotation requests and their background reconciler.",
617
863
  events: {
618
864
  "reconcile.failed": "A background reconcile pass failed; the next one retries.",
865
+ "legacy.degraded": "Legacy annotation storage is damaged, so the previous committed copy is served read-only.",
866
+ "legacy.draft-index-problem": "The legacy draft index could not be used; `status` says why.",
867
+ "legacy.unreadable-records": "The legacy import found unreadable records; they stay unread.",
868
+ "legacy.unavailable": "Legacy annotation storage could not be read.",
869
+ "legacy.unreadable": "An environment's legacy annotation storage is unreadable.",
870
+ "legacy.archive-failed": "Imported legacy annotation files could not be archived.",
871
+ "legacy.files-archived": "Legacy files beside an imported environment were archived, not imported.",
872
+ "migration.draft-failed": "Migrating one draft failed.",
873
+ "draft-reconcile.deferred": "Draft reconciliation was deferred; a later pass retries.",
874
+ "request.handoff-deferred": "A request's handoff was deferred; a later pass retries.",
875
+ "evidence.materialize-failed": "Materializing a request's evidence failed; it backs off and retries.",
876
+ "queue.publish-deferred": "Publishing a request to the queue was deferred; it retries under the same id.",
877
+ "request.reconcile-failed": "Reconciling a request failed; the next pass retries.",
878
+ "turn-end.reconcile-failed": "Reconciling a request at the end of a turn failed; the next pass retries.",
879
+ "gc.failed": "Annotation garbage collection failed; the next pass retries.",
880
+ "record.unavailable": "An annotation record is unavailable; written once per record.",
881
+ "storage.unavailable": "An environment's annotation store is unreadable.",
882
+ "change-hint.listener-failed": "A change hint listener threw.",
883
+ "orphan.remove-failed": "An orphaned environment's annotation storage could not be removed.",
884
+ "storage.load-failed": "An environment's annotation storage could not be loaded.",
619
885
  ...THROTTLE_LOG_EVENTS
620
886
  }
621
887
  }
622
888
  });
623
889
 
890
+ // ../protocol/src/log-vocabulary/storage.ts
891
+ var STORAGE_LOG_AREAS = defineLogAreas({
892
+ storage: {
893
+ description: "The SQLite-backed stores, their snapshots and imports from older formats.",
894
+ events: {
895
+ "usage.environment-label-failed": "Usage labels could not be retained for a removed environment; deletion continues.",
896
+ "snapshot.integrity-failed": "An hourly database snapshot failed its integrity check and was discarded.",
897
+ "snapshot.skipped-low-disk": "The hourly database snapshot was skipped because the disk lacks room; `retryAt` says when it tries again.",
898
+ "snapshot.failed": "The hourly database snapshot failed; `retryAt` says when it tries again, if known.",
899
+ "listener.attention-failed": "An environment attention listener threw; the committed mutation stands.",
900
+ "listener.change-failed": "A resource change listener threw; the committed mutation stands.",
901
+ "kanban.image-cleanup-failed": "An orphaned Kanban image could not be removed after its retries; it is safe to remove later.",
902
+ "nodes.entries-dropped": "Unreadable node registry entries were ignored.",
903
+ "preview-identity.reminted": "The data directory moved or was copied, so previews get a new backend identity.",
904
+ "machine-profile.invalid": "The stored machine profile was invalid and the default was restored.",
905
+ "permission-rules.cleanup-failed": "A deleted project's permission rules could not be removed.",
906
+ "retired.turn-cleanup-pending": "Cleanup of a retired Looped Review turn did not finish and stays pending.",
907
+ "handoffs.prune-failed": "Pruning agent handoffs that nothing references failed; a later prune retries.",
908
+ "desktop-connections.malformed": "Stored desktop connection settings were malformed, so the local connection is used.",
909
+ "legacy-json.moved": "JSON store files written after the SQLite migration were archived, not imported.",
910
+ "legacy-json.archive-failed": "Imported JSON store files could not be archived."
911
+ }
912
+ }
913
+ });
914
+
915
+ // ../protocol/src/log-vocabulary/build-pipeline.ts
916
+ var BUILD_PIPELINE_LOG_AREAS = defineLogAreas({
917
+ "build-pipeline": {
918
+ description: "Build pipelines: their supervision, stages, transcripts and sidebar state.",
919
+ events: {
920
+ "sidebar.reconcile-failed": "Sidebar activity for pipelines could not be reconciled.",
921
+ "sidebar.update-failed": "The sidebar could not be updated for one pipeline.",
922
+ "result.consume-deferred": "Consuming a stage's workflow result failed; it stays staged and is retried.",
923
+ "consolidation.consume-deferred": "Consuming a review consolidation result failed; it stays pending and is retried.",
924
+ "dispatch.prepare-failed": "Attaching the agent before dispatch failed; the prompt request does the same work and answers authoritatively.",
925
+ "interaction.resolved": "A human interaction on a pipeline stage resolved. Metadata only.",
926
+ "transcripts.migrated": "A transcript migration pass moved stage transcripts; counts only.",
927
+ "transcripts.maintenance-failed": "Migrating or sweeping stage transcripts failed; the next start retries.",
928
+ "restore.skipped": "A pipeline could not be restored at startup and was skipped.",
929
+ "criteria.record-failed": "Acceptance criteria results could not be recorded on the ticket.",
930
+ "workspace.waiting": "A pipeline is waiting for its workspace; written once per reason.",
931
+ "rewind.pending": "A pipeline's code rewind has not finished; written once per reason.",
932
+ "kanban.status-failed": "A restarted pipeline's Kanban status could not be set; it retries shortly.",
933
+ "usage.read-failed": "Reading a stage session's token usage failed.",
934
+ "checkpoint.deferred": "A stage transcript checkpoint could not be written yet; the provider's history stands.",
935
+ "checkpoint.not-committed": "A stage transcript checkpoint was reverted in the commit that should have kept it.",
936
+ "legacy-transcript.deferred": "Moving a legacy inline transcript failed; the inline body stays readable."
937
+ }
938
+ }
939
+ });
940
+
941
+ // ../protocol/src/log-vocabulary/agent-branch.ts
942
+ var AGENT_BRANCH_LOG_AREAS = defineLogAreas({
943
+ "agent-branch": {
944
+ description: "Agent branches shared by review fan-outs, graph agents and goal verifiers; `owner` names which.",
945
+ events: {
946
+ "observation.checkpoint-failed": "Checkpointing reviewer observations failed; the next pass retries.",
947
+ "transcript.mirror-failed": "Mirroring a reviewer transcript failed.",
948
+ "usage.read-failed": "Reading a reviewer's token usage failed.",
949
+ "result.nudge-failed": "An agent with an uncommitted result could not be nudged.",
950
+ "dispatch.prepare-failed": "Attaching the agent before dispatch failed; the prompt request answers authoritatively.",
951
+ "result.consume-deferred": "Consuming a branch's workflow result failed; it stays staged and is retried."
952
+ }
953
+ }
954
+ });
955
+
956
+ // ../protocol/src/log-vocabulary/change-tracking.ts
957
+ var CHANGE_TRACKING_LOG_AREAS = defineLogAreas({
958
+ "change-tracking": {
959
+ description: "Change tracking: turn capture, evidence pulls and measurements.",
960
+ events: {
961
+ "journal-import.failed": "Importing surviving OpenCode command journals as legacy summaries failed.",
962
+ "projection.failed": "Projecting a change event onto its environment failed.",
963
+ "startup.reconcile-failed": "Reconciling change tracking at startup failed.",
964
+ "turn-start.capture-failed": "Capturing a turn's start failed, so the turn is untracked.",
965
+ "dispatch.record-failed": "Recording a turn's dispatch outcome failed.",
966
+ "turn.finalize-failed": "Finalizing a turn failed.",
967
+ "turn.settle-failed": "Settling a late interrupted turn failed.",
968
+ "evidence.pull-failed": "Pulling change evidence from a bridge failed; a later pull retries.",
969
+ "measurement.failed": "Recomputing a tool's measurement failed."
970
+ }
971
+ },
972
+ "diff-stats": {
973
+ description: "Environment diff stats and the worktree signals that drive them.",
974
+ events: {
975
+ "baseline.update-failed": "An environment's diff baseline could not be updated.",
976
+ "scan.watcher-failed": "An environment's diff watcher failed; its scans fall back to polling.",
977
+ "scan.failed": "A diff scan failed; the last results stay, marked stale, and the scan is retried.",
978
+ "scan.freshness-read-failed": "Reading whether an environment's remote is fresh failed.",
979
+ "scan.listener-failed": "A change-tracking scan listener threw; the scan itself stands.",
980
+ "emit.diff-stats-failed": "A diff stats change could not be emitted to its sink.",
981
+ "emit.worktree-snapshot-failed": "A worktree snapshot could not be emitted to its sink.",
982
+ "signal.demoted": "A worktree signal stopped being trusted, so scans fall back to timers until it is re-armed."
983
+ }
984
+ }
985
+ });
986
+
987
+ // ../protocol/src/log-vocabulary/coordinator.ts
988
+ var COORDINATOR_LOG_AREAS = defineLogAreas({
989
+ coordinator: {
990
+ description: "Coordinators: delegations, status wakes and their store.",
991
+ events: {
992
+ "delegation.open-failed": "A delegation could not be opened; `source` says for what.",
993
+ "deliver-now.drain-failed": "The mail delivery pass after deliverNow failed; the next sweep delivers.",
994
+ "mail.move-failed": "Mail could not move to the new main coordinator.",
995
+ "work.move-failed": "Work could not move to the main coordinator.",
996
+ "wake.observe-remote-workflow-failed": "A remote workflow could not be observed for status wakes.",
997
+ "wake.observe-pull-request-failed": "A pull request could not be observed for status wakes.",
998
+ "wake.observe-feature-plan-failed": "A feature plan could not be observed for status wakes.",
999
+ "wake.observe-workflow-failed": "A workflow could not be observed for status wakes.",
1000
+ "wake.deliver-failed": "A workflow status wake could not be delivered; the next pass retries.",
1001
+ "wake.waiting-check-failed": "A waiting worker could not be checked; the next pass retries.",
1002
+ "wake.resolve-report-failed": "A finished Resolve tab could not be reported.",
1003
+ "wake.waiting-report-failed": "A waiting worker could not be reported.",
1004
+ "wake.worker-outcomes-failed": "Coordinator-owned workers' merges and deletions could not be checked; the next sweep retries.",
1005
+ "store.malformed": "The coordinator store was malformed and is treated as empty.",
1006
+ "store.unsupported-version": "The coordinator store has an unsupported version and is treated as empty.",
1007
+ "store.invalid-workspace": "An invalid coordinator workspace record was ignored.",
1008
+ "store.workflows-cleared": "The workflow store was full, so a batch of its oldest finished records was removed.",
1009
+ "store.workflows-in-use": "The workflow store was full and every record was still in use, so new work was refused.",
1010
+ "remote-worker.settle-failed": "A remote worker could not be settled.",
1011
+ "checkout.merge-followed": "After an environment's PR merged, the project checkout was fast-forwarded, or `outcome` says why not.",
1012
+ "checkout.merge-follow-failed": "Fast-forwarding the project checkout failed, after an environment's PR merged or before mail woke the main coordinator.",
1013
+ "checkout.mail-follow": "Before mail woke the main coordinator, the project checkout was fast-forwarded, or `outcome` says why not (`timed-out`, `failed`).",
1014
+ "checkout.mail-follow-failed": "Before mail woke the main coordinator, checking whether to fast-forward the project checkout failed; the mail was delivered anyway."
1015
+ }
1016
+ }
1017
+ });
1018
+
1019
+ // ../protocol/src/log-vocabulary/review.ts
1020
+ var REVIEW_LOG_AREAS = defineLogAreas({
1021
+ review: {
1022
+ description: "Multi Review workflows: scheduling, graph runs and interactive fix sessions.",
1023
+ events: {
1024
+ "fix-tab.publish-failed": "A fix request was delivered but its tab could not be opened; the user is told.",
1025
+ "graph-run.not-started": "A workflow's graph run did not start.",
1026
+ "reconcile.scan-failed": "A reconciliation scan failed; the next scan retries.",
1027
+ "graph-engine.unavailable": "The graph engine is selected but unavailable, so the bespoke engine runs.",
1028
+ "graph-run.cancel-failed": "Cancelling a graph run failed; the next pass projects how it ended.",
1029
+ "delete.cleanup-failed": "A cleanup step after deleting a workflow failed; stale tabs reconcile away on hydration.",
1030
+ "fix-session.read-failed": "Reading an interactive fix session's state failed.",
1031
+ "fix-outcome.read-failed": "Reading an interactive fix's outcome failed; it stays pending.",
1032
+ "fix-usage.read-failed": "Reading a fix session's token usage failed.",
1033
+ "result.consume-deferred": "Consuming a workflow result failed; it stays staged and is retried.",
1034
+ "failure-triage.failed": "Classifying a review package's failing tests failed; the package is sealed without the triage and says so."
1035
+ }
1036
+ },
1037
+ "pull-request": {
1038
+ description: "Pull request monitoring, auto-merge and the `gh` reads behind them.",
1039
+ events: {
1040
+ "merged-state.persist-failed": "A merged pull request's state could not be saved; GitHub stays authoritative and cleanup goes on.",
1041
+ "refresh.failed": "A pull request could not be refreshed; the armed flag stands.",
1042
+ "arm.track-failed": "An armed environment could not be tracked; the monitor's next sync retries.",
1043
+ "gh.pr-list-unparseable": "`gh pr list` returned nothing that parses. Sizes only, never the output.",
1044
+ "monitor.start-failed": "Monitoring could not start for a newly opened pull request.",
1045
+ "cleanup-scheduler.missing": "A merged pull request was seen, but this runtime has no merge cleanup scheduler.",
1046
+ "checkout.follow-merge-lookup-failed": "A merged pull request's project could not be read, so its checkout was not fast-forwarded.",
1047
+ "auto-merge.evaluation-failed": "Evaluating an environment for auto-merge failed.",
1048
+ "auto-merge.merge-failed": "Auto-merge could not merge a pull request; the attempt is held and retried.",
1049
+ "auto-merge.resolve-failed": "Auto-merge could not launch Resolve for a pull request; the attempt is held and retried.",
1050
+ "monitor.detection-failed": "Checking an environment for its pull request failed.",
1051
+ "monitor.detection-admission-failed": "A pull request check could not be admitted to the work pool.",
1052
+ "monitor.terminal-repair-failed": "Repairing a merged or closed pull request's side effects failed.",
1053
+ "monitor.terminal-resume-failed": "Resuming a merged or closed pull request's side effects failed.",
1054
+ "monitor.stale-reading-ignored": "A non-merged reading (`state`) for a pull request already merged was ignored as stale.",
1055
+ "monitor.state-persist-failed": "A pull request's observed state could not be saved.",
1056
+ "monitor.state-clear-failed": "A pull request's saved state could not be cleared.",
1057
+ "monitor.task-reconcile-failed": "Updating the Kanban task of a merged or closed (`state`) pull request failed.",
1058
+ "monitor.task-store-failed": "A pull request could not be recorded on its Kanban task.",
1059
+ "monitor.emit-failed": "A pull request monitor event could not be emitted to its sink."
1060
+ }
1061
+ }
1062
+ });
1063
+
1064
+ // ../protocol/src/log-vocabulary/public-api.ts
1065
+ var PUBLIC_API_LOG_AREAS = defineLogAreas({
1066
+ "public-api": {
1067
+ description: "The public CLI's operations: their outcomes, reconciliation and exec workers.",
1068
+ events: {
1069
+ "outcome.record-failed": "A background operation's outcome could not be recorded; reconciliation settles it.",
1070
+ "goal-checks.stop-failed": "Goal checks could not be stopped.",
1071
+ "exec.list-failed": "Exec workers could not be listed.",
1072
+ "exec.cancel-failed": "An exec could not be cancelled.",
1073
+ "goal-workers.list-failed": "Goal check workers could not be listed.",
1074
+ "operation.reconcile-failed": "Reconciling one operation failed; the next pass retries.",
1075
+ "reconcile.pass-failed": "A reconciliation pass failed; the next one retries."
1076
+ }
1077
+ }
1078
+ });
1079
+
1080
+ // ../protocol/src/log-vocabulary/agent-accounts.ts
1081
+ var AGENT_ACCOUNTS_LOG_AREAS = defineLogAreas({
1082
+ "agent-accounts": {
1083
+ description: "Agent accounts: automatic switching, staged logins and plan usage.",
1084
+ events: {
1085
+ "switch-notice.failed": "A notice about an automatic account switch failed; the switch stands. `audience` says whose.",
1086
+ "auto-switch.check-failed": "An automatic account check failed; the next nudge retries.",
1087
+ "container-sync.failed": "Handing a login or account to a container failed; `step` says which part.",
1088
+ "last-usage.save-failed": "The last plan usage reading could not be saved; the next save retries.",
1089
+ "login-cleanup.failed": "A temporary login could not be cleaned up.",
1090
+ "login-renewal.failed": "Renewing an idle account's sign-in to read its usage failed; it is retried after a backoff.",
1091
+ "login-renewal.not-extended": "Claude Code ran to renew an idle account's sign-in, but its token is still lapsed.",
1092
+ "login-refresh.deferred": "Containers were not told to refresh their login now; they reconcile from its durable generation."
1093
+ }
1094
+ }
1095
+ });
1096
+
1097
+ // ../protocol/src/log-vocabulary/docker.ts
1098
+ var DOCKER_LOG_AREAS = defineLogAreas({
1099
+ docker: {
1100
+ description: "Docker containers: lifecycle, starts, staged inputs and the login files they hold.",
1101
+ events: {
1102
+ "portable-inputs.relay-missing": "Docker is rootless and the image predates the staged-input relay, so the container cannot read them until rebuilt.",
1103
+ "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.",
1104
+ "opencode.warm-incomplete": "OpenCode did not finish loading /workspace in a container.",
1105
+ "lifecycle-event.reconcile-failed": "Reconciling an environment after a container start or stop event failed; the next status read retries.",
1106
+ "login-keeper.pass-failed": "A Claude login keeper pass failed; the next interval retries.",
1107
+ "login-keeper.refresh-failed": "Refreshing the host Claude login failed. Fixed text: CLI output can hold credentials.",
1108
+ "login-keeper.refresh-not-extended": "Refreshing the host Claude login did not extend its expiry.",
1109
+ "login-keeper.refresh-check-failed": "Checking the host Claude login after a refresh failed.",
1110
+ "login-watcher.pass-failed": "A container login file watcher pass failed; the next one retries.",
1111
+ "lifecycle.record-failure-failed": "A failed container operation could not be recorded.",
1112
+ "lifecycle.reconcile-failed": "Reconciling one environment's container operation failed; the next pass retries.",
1113
+ "replacement.clear-terminals-failed": "Terminal sessions could not be cleared after a container replacement.",
1114
+ "recovery.clear-terminals-failed": "Terminal sessions could not be cleared after a recovery restore.",
1115
+ "github-ranges.seed-not-copied": "The GitHub ranges seed could not be copied into a container, so its firewall fetches them.",
1116
+ "availability.probe-failed": "Docker is not available; written when the diagnostic changes. Fixed-shape metadata only: messages can hold daemon endpoints.",
1117
+ "start.port-collision-retrying": "An automatic host port collided on start, so it is retried once with fresh ports."
1118
+ }
1119
+ },
1120
+ "docker.reachability": {
1121
+ description: "Whether agents in containers can reach the backend's agent tools server.",
1122
+ events: {
1123
+ "check.crashed": "A reachability check crashed.",
1124
+ "check.started": "A reachability check started.",
1125
+ "check.finished": "A reachability check finished.",
1126
+ "check.probe": "One probe of a finished check.",
1127
+ "check.summary": "Content-free status and reason for a check that did not find the host reachable.",
1128
+ "check.remediation": "One command the user can run to unblock containers.",
1129
+ "shutdown.awaiting-network": "Shutdown is waiting for probe network preparation.",
1130
+ "shutdown.cleanup-deferred": "Probe network cleanup waits until its preparation settles.",
1131
+ "shutdown.removing-resources": "Shutdown is removing probe resources.",
1132
+ "shutdown.container-remove-failed": "A probe container could not be removed at shutdown.",
1133
+ "shutdown.network-remove-failed": "The probe network could not be removed at shutdown.",
1134
+ "probe.skipped": "A container probe was skipped because the agent tools server is not listening.",
1135
+ "preflight.refused": "A stage was refused because its container cannot reach the host.",
1136
+ "probe.prepare-failed": "A container could not be prepared for a probe.",
1137
+ "probe.result": "The outcome of probing one container.",
1138
+ "probe.contradicts-host": "A container probe disagrees with the host status, so the host is rechecked.",
1139
+ "topology.detected": "The Docker topology was read.",
1140
+ "firewall.detected": "The host firewall was read.",
1141
+ "probe-network.remove-failed": "The probe network could not be removed.",
1142
+ "probe-network.create-failed": "The probe network could not be created, so only the default bridge is checked.",
1143
+ "event.emit-failed": "A reachability event could not be emitted.",
1144
+ "host-addresses.list-failed": "Host addresses could not be listed.",
1145
+ "probe-image.present": "The probe image is already present.",
1146
+ "probe-image.pulling": "The probe image is being pulled.",
1147
+ "probe-image.pulled": "The probe image was pulled.",
1148
+ "probe-image.pull-failed": "The probe image could not be pulled.",
1149
+ "probe-image.fallback": "The environment image is used as the probe image.",
1150
+ "probe-image.missing": "No probe image is available.",
1151
+ "network.list-failed": "Docker networks could not be listed.",
1152
+ "network.inspect-failed": "A Docker network could not be inspected.",
1153
+ "stale-containers.removing": "Stale probe containers are being removed.",
1154
+ "stale-networks.removing": "Stale probe networks are being removed."
1155
+ }
1156
+ }
1157
+ });
1158
+
1159
+ // ../protocol/src/log-vocabulary/mcp.ts
1160
+ var MCP_LOG_AREAS = defineLogAreas({
1161
+ "control-mcp": {
1162
+ description: "The Control MCP server other agents and devices reach Orkestrator through.",
1163
+ events: {
1164
+ "listener.port-free": "The Control MCP's fixed port is free again, so it is listening.",
1165
+ "state-listener.failed": "A Control MCP state listener threw; the others still run.",
1166
+ "delegation.remote-open-failed": "A delegation could not be opened on another node.",
1167
+ "delegation.open-failed": "A coordinator delegation could not be opened."
1168
+ }
1169
+ },
1170
+ "mcp-management": {
1171
+ description: "Managed MCP configuration: its commands, overlays and apply loop.",
1172
+ events: {
1173
+ "command.failed": "An MCP management command failed; `ref` is the correlation id shown to the user.",
1174
+ "overlay.materialise-failed": "An MCP overlay could not be written.",
1175
+ "apply.tick-failed": "An MCP apply tick failed; the next one retries."
1176
+ }
1177
+ }
1178
+ });
1179
+
1180
+ // ../protocol/src/log-vocabulary/design.ts
1181
+ var DESIGN_LOG_AREAS = defineLogAreas({
1182
+ design: {
1183
+ description: "The design canvas: its library, renderer and session links.",
1184
+ events: {
1185
+ "change-signal.failed": "A design change signal failed.",
1186
+ "library.index-write-failed": "The design library index could not be written.",
1187
+ "library.refresh-failed": "The design library could not be refreshed.",
1188
+ "renderer.problem": "The renderer hit a limit or lost a browser; `problem` is a fixed name.",
1189
+ "task.failed": "A design background task failed.",
1190
+ "canvas.needs-recovery": "A design canvas is unreadable and marked for recovery.",
1191
+ "startup.step-failed": "One part of design startup failed; `step` says which.",
1192
+ "legacy.retire-failed": "A migrated legacy design could not be retired.",
1193
+ "profiles.swept": "Design startup removed stale browser profiles.",
1194
+ "session-link.record-failed": "A closing conversation could not be recorded on a design link."
1195
+ }
1196
+ }
1197
+ });
1198
+
1199
+ // ../protocol/src/log-vocabulary/graph.ts
1200
+ var GRAPH_LOG_AREAS = defineLogAreas({
1201
+ graph: {
1202
+ description: "Graph runs: launches, passes, rewinds, system actions and templates.",
1203
+ events: {
1204
+ "describe.pass-failed": "A graph describe pass failed. Content-free: never the description or draft.",
1205
+ "system.stop-failed": "A system action's work could not be stopped.",
1206
+ "system.action-failed": "A system action failed; `cause` is its fixed failure cause.",
1207
+ "attention.update-failed": "The sidebar could not be updated for a run.",
1208
+ "launch.ticket-link-failed": "A launched run's ticket could not be linked.",
1209
+ "launch.started": "A graph run was launched.",
1210
+ "launch.swept": "Runs that ended without an environment were removed.",
1211
+ "rewind.pending": "A run's code rewind has not finished.",
1212
+ "rewind.applied": "A run was restarted or rewound.",
1213
+ "rewind.waiting": "A run waits for its code rewind to finish.",
1214
+ "history.pruned": "Finished runs beyond an environment's history were removed.",
1215
+ "history.prune-failed": "Pruning an environment's run history failed.",
1216
+ "worktree.cleanup-failed": "A run's branch worktree cleanup failed.",
1217
+ "run.unreadable": "A run is unreadable, so it is not scheduled.",
1218
+ "run.pass-failed": "A pass over a run failed.",
1219
+ "transcript.capture-failed": "A run's transcript capture failed.",
1220
+ "ticket.link-failed": "A run's ticket could not be linked to its environment.",
1221
+ "template.skipped": "A built-in template was skipped as invalid or a duplicate."
1222
+ }
1223
+ }
1224
+ });
1225
+
1226
+ // ../protocol/src/log-vocabulary/nodes.ts
1227
+ var NODES_LOG_AREAS = defineLogAreas({
1228
+ nodes: {
1229
+ description: "Command nodes: links, handovers, leaf mail, ticket sync and project copies.",
1230
+ events: {
1231
+ "actions.resume-failed": "Approved actions could not be resumed; a later pass retries.",
1232
+ "project-copy.notify-failed": "The coordinator could not be told a project copy finished.",
1233
+ "mail.delivery-deferred": "Leaf mail could not reach a coordinator yet.",
1234
+ "command.post-step-failed": "A step after a routed command failed.",
1235
+ "seed-files.incomplete": "Seed files for a leaf environment were not all copied.",
1236
+ "contact.record-failed": "The latest controller contact could not be recorded.",
1237
+ "settings.send-failed": "Settings could not be sent to a node.",
1238
+ "verification.record-failed": "A node verification could not be recorded.",
1239
+ "profile.record-failed": "A node profile could not be recorded.",
1240
+ "detach.unconfirmed": "A forgotten node has not confirmed the detach yet.",
1241
+ "handover.recovery-pending": "Command handover recovery is still pending.",
1242
+ "ticket-sync.work-record-failed": "A remote build started but its ticket work location could not be saved.",
1243
+ "ticket-sync.failed": "A Kanban sync with a node failed; it is retried.",
1244
+ "ticket-sync.unknown-project": "A node sent ticket changes for a project that no longer exists here.",
1245
+ "ticket-sync.forget-failed": "A detached command node's ticket copies could not be released."
1246
+ }
1247
+ }
1248
+ });
1249
+
1250
+ // ../protocol/src/log-vocabulary/linear.ts
1251
+ var LINEAR_LOG_AREAS = defineLogAreas({
1252
+ linear: {
1253
+ description: "Linear issues read for build actions.",
1254
+ events: {
1255
+ "comments.load-failed": "An issue's comments could not be loaded; the issue still renders without them."
1256
+ }
1257
+ }
1258
+ });
1259
+
1260
+ // ../protocol/src/log-vocabulary/usage-history.ts
1261
+ var USAGE_HISTORY_LOG_AREAS = defineLogAreas({
1262
+ "usage-history": {
1263
+ description: "Recorded agent token usage.",
1264
+ events: {
1265
+ "record.failed": "Agent usage could not be recorded; a later read counts it.",
1266
+ "prune.failed": "Pruning recorded usage failed; the next prune retries."
1267
+ }
1268
+ }
1269
+ });
1270
+
1271
+ // ../protocol/src/log-vocabulary/feature.ts
1272
+ var FEATURE_LOG_AREAS = defineLogAreas({
1273
+ feature: {
1274
+ description: "Pipeline environments started from a feature, and feature planning.",
1275
+ events: {
1276
+ "naming.fallback": "Automatic naming failed, so a local fallback name is used. Error kind only: the description stays out.",
1277
+ "planning.legacy-adopt-failed": "Legacy planning conversations could not be adopted.",
1278
+ "planning.tick-retrying": "A planning tick failed on a transient error; the next tick retries."
1279
+ }
1280
+ }
1281
+ });
1282
+
1283
+ // ../protocol/src/log-vocabulary/host.ts
1284
+ var HOST_LOG_AREAS = defineLogAreas({
1285
+ host: {
1286
+ description: "The host machine: its executables, load, suspends and maintenance.",
1287
+ events: {
1288
+ "path.discovered": "Executable discovery finished. Counts and booleans only: PATH entries can hold private directory names.",
1289
+ "tool.available": "A host tool's availability was read.",
1290
+ "tool.missing": "A host tool was not found.",
1291
+ "maintenance.listener-failed": "A host maintenance listener threw; the others still run.",
1292
+ "suspend.reconcile-failed": "Reconciling due work after a host suspension failed.",
1293
+ "load.sample-failed": "Sampling machine load failed; the next sample retries."
1294
+ }
1295
+ }
1296
+ });
1297
+
1298
+ // ../protocol/src/log-vocabulary/transcript-artifacts.ts
1299
+ var TRANSCRIPT_ARTIFACTS_LOG_AREAS = defineLogAreas({
1300
+ "transcript-artifacts": {
1301
+ description: "Transcript artifacts: previews, printing, grants and their ledger. Ids, kinds, sizes and reason codes only.",
1302
+ events: {
1303
+ "announce-failed": "An artifact change could not be announced.",
1304
+ "cleanup-failed": "An artifact cleanup failed.",
1305
+ "grant-revocation-failed": "A grant could not be revoked.",
1306
+ "ledger-listener-failed": "A ledger listener threw.",
1307
+ "ledger-read-failed": "The ledger could not be read.",
1308
+ "operation-executor-failed": "A preview operation's executor failed.",
1309
+ "operation-failed": "A preview operation failed.",
1310
+ "pdf-preview": "A PDF preview was served.",
1311
+ "pdf-preview-failed": "A PDF preview failed.",
1312
+ "pdf-print-failed": "Printing an artifact to PDF failed.",
1313
+ "pdf-printed": "An artifact was printed to PDF.",
1314
+ "runtime-unavailable": "The artifact runtime could not be created."
1315
+ }
1316
+ }
1317
+ });
1318
+
1319
+ // ../protocol/src/log-vocabulary/scheduler.ts
1320
+ var SCHEDULER_LOG_AREAS = defineLogAreas({
1321
+ scheduler: {
1322
+ description: "Scheduled jobs and the backend-owned timing that fires them.",
1323
+ events: {
1324
+ "tick.failed": "A scheduler tick failed; the next tick retries.",
1325
+ "job.claim-failed": "A due job could not be claimed.",
1326
+ "fire.heartbeat-failed": "A running fire's heartbeat could not be recorded.",
1327
+ "fire.outcome-record-failed": "A finished fire's outcome could not be recorded."
1328
+ }
1329
+ }
1330
+ });
1331
+
624
1332
  // ../protocol/src/log-vocabulary/web-app.ts
625
1333
  var WEB_APP_LOG_AREAS = defineLogAreas({
626
1334
  "web.app": {
@@ -788,7 +1496,7 @@ var WEB_ENVIRONMENT_LOG_AREAS = defineLogAreas({
788
1496
  "models.pi-seed-failed": "The create dialog could not seed the Pi model catalogue.",
789
1497
  "models.opencode-cache-load-failed": "The create dialog could not read cached OpenCode models.",
790
1498
  "github-credential.check-failed": "The GitHub credential check before creating failed.",
791
- "feature-build.start-failed": "Starting a feature build from the dialog failed.",
1499
+ "feature-build.start-failed": "Starting a pipeline environment from the dialog failed.",
792
1500
  "settings.extensions-load-failed": "The settings dialog could not load extensions.",
793
1501
  "settings.container-reset-failed": "The settings dialog could not reset the container.",
794
1502
  "settings.save-failed": "The settings dialog could not save.",
@@ -1080,6 +1788,25 @@ var LOG_VOCABULARY = {
1080
1788
  ...TMUX_LOG_AREAS,
1081
1789
  ...UPDATER_LOG_AREAS,
1082
1790
  ...WEB_ANNOTATIONS_LOG_AREAS,
1791
+ ...STORAGE_LOG_AREAS,
1792
+ ...BUILD_PIPELINE_LOG_AREAS,
1793
+ ...AGENT_BRANCH_LOG_AREAS,
1794
+ ...CHANGE_TRACKING_LOG_AREAS,
1795
+ ...COORDINATOR_LOG_AREAS,
1796
+ ...REVIEW_LOG_AREAS,
1797
+ ...PUBLIC_API_LOG_AREAS,
1798
+ ...AGENT_ACCOUNTS_LOG_AREAS,
1799
+ ...DOCKER_LOG_AREAS,
1800
+ ...MCP_LOG_AREAS,
1801
+ ...DESIGN_LOG_AREAS,
1802
+ ...GRAPH_LOG_AREAS,
1803
+ ...NODES_LOG_AREAS,
1804
+ ...LINEAR_LOG_AREAS,
1805
+ ...USAGE_HISTORY_LOG_AREAS,
1806
+ ...FEATURE_LOG_AREAS,
1807
+ ...HOST_LOG_AREAS,
1808
+ ...TRANSCRIPT_ARTIFACTS_LOG_AREAS,
1809
+ ...SCHEDULER_LOG_AREAS,
1083
1810
  ...WEB_APP_LOG_AREAS,
1084
1811
  ...WEB_BUILD_PIPELINE_LOG_AREAS,
1085
1812
  ...WEB_CHAT_LOG_AREAS,
@@ -1098,7 +1825,7 @@ var LOG_VOCABULARY = {
1098
1825
  // ../protocol/src/secret-redaction.ts
1099
1826
  var TEXT_RULES = [
1100
1827
  {
1101
- pattern: /([a-z][a-z0-9+.-]*:\/\/)[^/\s:@]+(?::[^/\s@]*)?@/gi,
1828
+ pattern: /(?<![a-z0-9+.-])([a-z][a-z0-9+.-]*:\/\/)[^/\s:@]+(?::[^/\s@]*)?@/gi,
1102
1829
  replacement: "$1[redacted]@"
1103
1830
  },
1104
1831
  {
@@ -1118,7 +1845,7 @@ var TEXT_RULES = [
1118
1845
  { pattern: /\bAKIA[0-9A-Z]{12,}/g, replacement: "[redacted]" },
1119
1846
  { pattern: /\bAIza[0-9A-Za-z_-]{20,}/g, replacement: "[redacted]" },
1120
1847
  {
1121
- pattern: /\b((?:[A-Za-z0-9]+[_-])*(?:api[_-]?key|apikey|access[_-]?token|refresh[_-]?token|auth[_-]?token|token|secret|client[_-]?secret|password|passwd|passphrase|authorization))("?\s*[:=]\s*)("?)(?!Bearer\b|Basic\b|\[redacted\])[^\s"',;)&]{6,}\3/gi,
1848
+ pattern: /(?<![A-Za-z0-9_-])(-*\b(?:[A-Za-z0-9]+[_-])*(?:api[_-]?key|apikey|access[_-]?token|refresh[_-]?token|auth[_-]?token|token|secret|client[_-]?secret|password|passwd|passphrase|authorization))("?\s*[:=]\s*)("?)(?!Bearer\b|Basic\b|\[redacted\])[^\s"',;)&]{6,}\3/gi,
1122
1849
  replacement: "$1$2[redacted]"
1123
1850
  }
1124
1851
  ];
@@ -1202,8 +1929,10 @@ function stackFrames(target, message) {
1202
1929
  `).filter((line) => /^\s*at\s/.test(line)).slice(0, MAX_STACK_FRAMES).map((line) => boundedText(relativeFrame(line), MAX_FRAME_CHARS));
1203
1930
  return frames.length > 0 ? frames : undefined;
1204
1931
  }
1205
- function describe(error, includeStack, depth) {
1932
+ function describe(error, includeStack, includeMessage, depth) {
1206
1933
  if (typeof error !== "object" || error === null) {
1934
+ if (!includeMessage)
1935
+ return { name: "NonError" };
1207
1936
  return {
1208
1937
  name: "NonError",
1209
1938
  message: typeof error === "string" ? boundedText(error, MAX_MESSAGE_CHARS) : `[${typeof error}]`
@@ -1220,7 +1949,7 @@ function describe(error, includeStack, depth) {
1220
1949
  const details = { name };
1221
1950
  if (commandFailure)
1222
1951
  details.outputOmitted = true;
1223
- else if (message)
1952
+ else if (message && includeMessage)
1224
1953
  details.message = boundedText(message, MAX_MESSAGE_CHARS);
1225
1954
  const code = read(error, "code");
1226
1955
  const safeCode = finite(code) ?? matching(code, CODE_PATTERN);
@@ -1248,13 +1977,13 @@ function describe(error, includeStack, depth) {
1248
1977
  details.errorCount = members.length;
1249
1978
  const cause = read(error, "cause") ?? (Array.isArray(members) ? members[0] : undefined);
1250
1979
  if (cause !== undefined && cause !== null && depth < MAX_CAUSE_DEPTH) {
1251
- details.cause = describe(cause, false, depth + 1);
1980
+ details.cause = describe(cause, false, includeMessage, depth + 1);
1252
1981
  }
1253
1982
  return details;
1254
1983
  }
1255
1984
  function formatLogError(error, options = {}) {
1256
1985
  try {
1257
- return brand(describe(error, options.stack !== false, 0));
1986
+ return brand(describe(error, options.stack !== false, options.message !== false, 0));
1258
1987
  } catch {
1259
1988
  return brand({ name: "Error", message: "[unreadable]" });
1260
1989
  }
@@ -1433,7 +2162,10 @@ function deliver(record) {
1433
2162
  line: config.format === "json" ? renderJson(record) : renderText(record),
1434
2163
  record
1435
2164
  });
1436
- } catch {}
2165
+ return true;
2166
+ } catch {
2167
+ return false;
2168
+ }
1437
2169
  }
1438
2170
  function buildRecord(level, area, event, fields) {
1439
2171
  const clean = fields ? sanitizeFields(fields, areaSpec(area)?.maxStringChars ?? MAX_FIELD_CHARS) : undefined;
@@ -1589,6 +2321,19 @@ function resolveFields(fields) {
1589
2321
  return { fieldsFailed: true };
1590
2322
  }
1591
2323
  }
2324
+ function deliverEvent(level, area, event, fields) {
2325
+ const spec = areaSpec(area);
2326
+ if (!spec)
2327
+ return deliver(buildRecord(level, "logging", "unknown-area", undefined));
2328
+ if (!Object.hasOwn(spec.events, event))
2329
+ return deliver(buildRecord(level, area, "invalid-event", undefined));
2330
+ return deliver(buildRecord(level, area, event, fields));
2331
+ }
2332
+ function tryWriteLog(level, area, event, fields) {
2333
+ if (LEVEL_RANK[level] > thresholdRank(area))
2334
+ return false;
2335
+ return deliverEvent(level, area, event, resolveFields(fields));
2336
+ }
1592
2337
  function createLogger(area) {
1593
2338
  const spec = areaSpec(area);
1594
2339
  let seenGeneration = -1;
@@ -1601,13 +2346,7 @@ function createLogger(area) {
1601
2346
  return LEVEL_RANK[level] <= rank;
1602
2347
  };
1603
2348
  const writeResolved = (level, event, resolved) => {
1604
- if (!spec) {
1605
- deliver(buildRecord(level, "logging", "unknown-area", undefined));
1606
- } else if (Object.hasOwn(spec.events, event)) {
1607
- deliver(buildRecord(level, area, event, resolved));
1608
- } else {
1609
- deliver(buildRecord(level, area, "invalid-event", undefined));
1610
- }
2349
+ deliverEvent(level, area, event, resolved);
1611
2350
  };
1612
2351
  const write = (level, event, fields) => {
1613
2352
  if (!enabled(level))
@@ -1782,8 +2521,19 @@ function applyLogDetail(detail, env = process.env) {
1782
2521
 
1783
2522
  // ../protocol/src/node/bridge-diagnostics.ts
1784
2523
  import { createHash } from "node:crypto";
1785
- var log = createLogger("bridge.diagnostics");
1786
- var INTERVAL_MS = 60000;
2524
+
2525
+ // ../protocol/src/event-loop-stall-monitor.ts
2526
+ var log = createLogger("event-loop");
2527
+ var EVENT_LOOP_STALL_ALWAYS_LOG_MS = 1e4;
2528
+
2529
+ // ../protocol/src/node/bridge-diagnostics.ts
2530
+ var log2 = createLogger("bridge.diagnostics");
2531
+ var BRIDGE_DIAGNOSTICS_INTERVAL_MS = 60000;
2532
+ var INTERVAL_MS = BRIDGE_DIAGNOSTICS_INTERVAL_MS;
2533
+ var STALL_NO_DELTA_MS = 2 * INTERVAL_MS;
2534
+ var STALL_TOOL_PENDING_MS = 10 * 60000;
2535
+ var STALL_TICK_DELAY_MS = EVENT_LOOP_STALL_ALWAYS_LOG_MS;
2536
+ var BRIDGE_DIAGNOSTICS_KEEPALIVE_MS = 10 * 60000;
1787
2537
  var MAX_PENDING_TOOLS = 128;
1788
2538
  var MAX_REPORTED_TOOLS = 8;
1789
2539
  var MAX_ID_LENGTH = 1024;
@@ -1844,6 +2594,28 @@ var UPDATE_KINDS = new Set([
1844
2594
  "step-started",
1845
2595
  "step-completed"
1846
2596
  ]);
2597
+ var COUNTER_CHANGE_THRESHOLDS = {
2598
+ stderrBytes: 4096,
2599
+ requestsSent: 1,
2600
+ responsesReceived: 1,
2601
+ timeouts: 1,
2602
+ notificationsReceived: Number.POSITIVE_INFINITY,
2603
+ protocolErrors: 1
2604
+ };
2605
+ var WAITING_PHASES = new Set([
2606
+ "sending",
2607
+ "following",
2608
+ "draining",
2609
+ "cancelling"
2610
+ ]);
2611
+ function sameSet(a, b) {
2612
+ if (a.size !== b.size)
2613
+ return false;
2614
+ for (const value of a)
2615
+ if (!b.has(value))
2616
+ return false;
2617
+ return true;
2618
+ }
1847
2619
  function identity(value) {
1848
2620
  if (typeof value !== "string" || !value || value.length > MAX_ID_LENGTH)
1849
2621
  return;
@@ -1919,26 +2691,35 @@ function safeDiagnosticMetrics(value) {
1919
2691
  result.state = value.state;
1920
2692
  return result;
1921
2693
  }
2694
+ function bridgeDiagnosticsChangesEnabled() {
2695
+ return log2.isEnabled("trace");
2696
+ }
1922
2697
  function writeBridgeDiagnostic({ bridge, event, payload }) {
1923
- log.info(event, { bridge, payload });
2698
+ return tryWriteLog("info", "bridge.diagnostics", event, { bridge, payload });
1924
2699
  }
1925
2700
  function bridgeDiagnosticsActive() {
1926
- return log.isEnabled("info");
2701
+ return log2.isEnabled("info");
2702
+ }
2703
+ function bridgeDiagnosticsStreamEnabled(bridge) {
2704
+ return bridgeDebugEnabled(bridge) || log2.isEnabled("debug");
1927
2705
  }
1928
2706
  function writeDiagnostic(bridge, event, payload, write) {
1929
2707
  try {
1930
2708
  const json = JSON.stringify({ bridge, event, ...payload });
1931
2709
  const bytes = Buffer.byteLength(json);
1932
2710
  if (bytes <= MAX_BRIDGE_DIAGNOSTIC_BYTES) {
1933
- write({ bridge, event, payload: json });
1934
- return;
2711
+ const accepted = write({ bridge, event, payload: json });
2712
+ return accepted !== false;
1935
2713
  }
1936
- write({
2714
+ const accepted = write({
1937
2715
  bridge,
1938
2716
  event: "snapshot-overflow",
1939
2717
  payload: JSON.stringify({ bridge, event: "snapshot-overflow", omittedBytes: bytes })
1940
2718
  });
1941
- } catch {}
2719
+ return accepted !== false;
2720
+ } catch {
2721
+ return false;
2722
+ }
1942
2723
  }
1943
2724
 
1944
2725
  class BridgeRunDiagnostics {
@@ -1970,6 +2751,7 @@ class BridgeRunDiagnostics {
1970
2751
  completedTools = 0;
1971
2752
  pending = new Map;
1972
2753
  phase = "sending";
2754
+ processScope = false;
1973
2755
  terminal = "pending";
1974
2756
  stream = "pending";
1975
2757
  cancellation = "none";
@@ -1977,6 +2759,8 @@ class BridgeRunDiagnostics {
1977
2759
  run;
1978
2760
  closed = false;
1979
2761
  wasActive;
2762
+ baseline;
2763
+ changeQueued = false;
1980
2764
  timer;
1981
2765
  constructor(bridge, state, now = Date.now, write = writeBridgeDiagnostic, intervalMs = INTERVAL_MS, metrics = () => ({}), active = () => true) {
1982
2766
  this.bridge = bridge;
@@ -2022,7 +2806,8 @@ class BridgeRunDiagnostics {
2022
2806
  return;
2023
2807
  }
2024
2808
  if (stage === "completed") {
2025
- this.pending.delete(key);
2809
+ if (this.pending.delete(key))
2810
+ this.changed();
2026
2811
  this.completedTools++;
2027
2812
  return;
2028
2813
  }
@@ -2037,13 +2822,23 @@ class BridgeRunDiagnostics {
2037
2822
  stage: stage === "started" || existing?.stage === "started" ? "started" : "partial",
2038
2823
  nested
2039
2824
  });
2825
+ if (!existing)
2826
+ this.changed();
2040
2827
  }
2041
2828
  checkpoint(phase) {
2829
+ if (phase === "attached")
2830
+ this.processScope = true;
2831
+ if (phase === this.phase)
2832
+ return;
2042
2833
  this.phase = phase;
2834
+ this.changed();
2043
2835
  }
2044
2836
  count(key, amount = 1) {
2045
- if (!this.closed && Number.isSafeInteger(amount) && amount >= 0)
2046
- this.counters[key] += amount;
2837
+ if (this.closed || !Number.isSafeInteger(amount) || amount < 0)
2838
+ return;
2839
+ this.counters[key] += amount;
2840
+ if (amount > 0 && Number.isFinite(COUNTER_CHANGE_THRESHOLDS[key]))
2841
+ this.changed();
2047
2842
  }
2048
2843
  translationFailed() {
2049
2844
  this.translationFailures++;
@@ -2059,8 +2854,10 @@ class BridgeRunDiagnostics {
2059
2854
  }
2060
2855
  terminalSettled(outcome) {
2061
2856
  this.terminal = outcome;
2062
- if (outcome === "resolved")
2857
+ if (outcome === "resolved" && this.phase !== "draining") {
2063
2858
  this.phase = "draining";
2859
+ this.changed();
2860
+ }
2064
2861
  }
2065
2862
  requestCancellation(reason = "user") {
2066
2863
  this.cancellation = "pending";
@@ -2082,12 +2879,38 @@ class BridgeRunDiagnostics {
2082
2879
  if (this.closed)
2083
2880
  return;
2084
2881
  const now = this.now();
2085
- const age = (time) => time === undefined ? null : Math.max(0, now - time);
2086
2882
  const tickDelayMs = event === "heartbeat" ? Math.max(0, now - this.lastTick - this.intervalMs) : 0;
2087
2883
  if (event === "heartbeat")
2088
2884
  this.lastTick = now;
2089
- if (!this.active() || !bridgeDiagnosticsActive())
2885
+ if (!bridgeDiagnosticsActive())
2090
2886
  return;
2887
+ const stall = this.stallState(now, tickDelayMs);
2888
+ if (event === "heartbeat" && !this.active() && !this.periodicDue(now, stall))
2889
+ return;
2890
+ this.writeSnapshot(event, now, tickDelayMs, stall);
2891
+ }
2892
+ changed() {
2893
+ if (this.closed || this.changeQueued || !bridgeDiagnosticsChangesEnabled())
2894
+ return;
2895
+ this.changeQueued = true;
2896
+ queueMicrotask(() => {
2897
+ this.changeQueued = false;
2898
+ this.reportChange();
2899
+ });
2900
+ }
2901
+ reportChange() {
2902
+ if (this.closed || !bridgeDiagnosticsChangesEnabled() || !bridgeDiagnosticsActive())
2903
+ return;
2904
+ const last = this.baseline;
2905
+ if (last && !this.changedSince(last))
2906
+ return;
2907
+ const now = this.now();
2908
+ try {
2909
+ this.writeSnapshot("change", now, 0, this.stallState(now, 0));
2910
+ } catch {}
2911
+ }
2912
+ writeSnapshot(event, now, tickDelayMs, stall) {
2913
+ const age = (time) => time === undefined ? null : Math.max(0, now - time);
2091
2914
  const pendingTools = Array.from(this.pending.entries()).slice(0, MAX_REPORTED_TOOLS).map(([id, tool]) => ({
2092
2915
  id,
2093
2916
  kind: tool.kind,
@@ -2096,7 +2919,7 @@ class BridgeRunDiagnostics {
2096
2919
  ageMs: age(tool.since)
2097
2920
  }));
2098
2921
  try {
2099
- writeDiagnostic(this.bridge, event, {
2922
+ const written = writeDiagnostic(this.bridge, event, {
2100
2923
  session: identity(this.state.id),
2101
2924
  run: this.run,
2102
2925
  phase: this.phase,
@@ -2123,8 +2946,64 @@ class BridgeRunDiagnostics {
2123
2946
  completedTools: this.completedTools,
2124
2947
  tickDelayMs
2125
2948
  }, this.write);
2949
+ if (!written)
2950
+ return;
2951
+ this.baseline = {
2952
+ at: now,
2953
+ phase: this.phase,
2954
+ pending: new Set(this.pending.keys()),
2955
+ counters: { ...this.counters },
2956
+ stall
2957
+ };
2126
2958
  } catch {}
2127
2959
  }
2960
+ periodicDue(now, stall) {
2961
+ if (stall.signals.has("tick-delay"))
2962
+ return true;
2963
+ const last = this.baseline;
2964
+ if (!last)
2965
+ return true;
2966
+ if (!sameSet(stall.signals, last.stall.signals) || !sameSet(stall.tools, last.stall.tools))
2967
+ return true;
2968
+ if (stall.signals.has("no-delta") && this.changedSince(last))
2969
+ return true;
2970
+ return now - last.at >= BRIDGE_DIAGNOSTICS_KEEPALIVE_MS;
2971
+ }
2972
+ changedSince(last) {
2973
+ if (this.phase !== last.phase)
2974
+ return true;
2975
+ if (this.pending.size !== last.pending.size)
2976
+ return true;
2977
+ for (const key of this.pending.keys())
2978
+ if (!last.pending.has(key))
2979
+ return true;
2980
+ for (const key of Object.keys(this.counters))
2981
+ if (this.counters[key] - last.counters[key] >= COUNTER_CHANGE_THRESHOLDS[key])
2982
+ return true;
2983
+ return false;
2984
+ }
2985
+ stallState(now, tickDelayMs) {
2986
+ const signals = new Set;
2987
+ const tools = new Set;
2988
+ let oldestPending;
2989
+ for (const [key, tool] of this.pending) {
2990
+ if (oldestPending === undefined || tool.since < oldestPending)
2991
+ oldestPending = tool.since;
2992
+ if (now - tool.since >= STALL_TOOL_PENDING_MS)
2993
+ tools.add(key);
2994
+ }
2995
+ const waitingSince = this.processScope ? oldestPending : WAITING_PHASES.has(this.phase) ? this.startedAt : undefined;
2996
+ if (waitingSince !== undefined) {
2997
+ const quietSince = Math.max(this.lastDelta ?? waitingSince, waitingSince);
2998
+ if (now - quietSince >= STALL_NO_DELTA_MS)
2999
+ signals.add("no-delta");
3000
+ }
3001
+ if (tools.size > 0)
3002
+ signals.add("tool-pending");
3003
+ if (tickDelayMs >= STALL_TICK_DELAY_MS)
3004
+ signals.add("tick-delay");
3005
+ return { signals, tools };
3006
+ }
2128
3007
  close(phase = "finished") {
2129
3008
  if (this.closed)
2130
3009
  return;
@@ -2137,8 +3016,9 @@ class BridgeRunDiagnostics {
2137
3016
  }
2138
3017
  }
2139
3018
  function createBridgeDiagnostics(bridge, state, metrics) {
2140
- return new BridgeRunDiagnostics(bridge, state, undefined, undefined, undefined, metrics, () => bridgeDebugEnabled(bridge));
3019
+ return new BridgeRunDiagnostics(bridge, state, undefined, undefined, undefined, metrics, () => bridgeDiagnosticsStreamEnabled(bridge));
2141
3020
  }
3021
+ var bufferedFlushes = new Set;
2142
3022
 
2143
3023
  // ../protocol/src/node/bridge-log-policy.ts
2144
3024
  var MAX_BRIDGE_LOG_POLICY_BYTES = 64 * 1024;
@@ -2186,7 +3066,7 @@ async function readBridgeLogPolicyBody(request) {
2186
3066
  import { execFile as execFileCallback2 } from "node:child_process";
2187
3067
  import { randomBytes, timingSafeEqual } from "node:crypto";
2188
3068
  import { appendFile as appendFile5, mkdir as mkdir9, readFile as readFile7, writeFile as writeFile6 } from "node:fs/promises";
2189
- import { join as join22 } from "node:path";
3069
+ import { join as join23 } from "node:path";
2190
3070
  import { promisify as promisify2 } from "node:util";
2191
3071
 
2192
3072
  // ../../node_modules/.bun/@hono+node-server@2.1.5+c539cad7f494f5c9/node_modules/@hono/node-server/dist/constants-BLSFu_RU.mjs
@@ -13105,7 +13985,7 @@ async function deriveTranscriptSubagentPartsForTurn({
13105
13985
 
13106
13986
  // ../../bridges/codex-bridge/src/history/rollout.ts
13107
13987
  import { createHash as createHash7 } from "node:crypto";
13108
- import { readFile as readFile4, readdir, stat as stat4 } from "node:fs/promises";
13988
+ import { readdir, stat as stat5 } from "node:fs/promises";
13109
13989
  import { homedir } from "node:os";
13110
13990
  import { basename as basename2, join as join11 } from "node:path";
13111
13991
 
@@ -15026,6 +15906,7 @@ var COORDINATOR_CONTROL_TOOL_NAMES = Object.freeze([
15026
15906
  "update_schedule",
15027
15907
  "update_ticket"
15028
15908
  ]);
15909
+ var COORDINATOR_PROJECT_HOME_MESSAGE_WINDOW_MS = 3 * 60 * 60000;
15029
15910
  var COORDINATOR_CONTEXT_OPEN_TAG = "<orkestrator-coordinator-context>";
15030
15911
  var COORDINATOR_CONTEXT_CLOSE_TAG = "</orkestrator-coordinator-context>";
15031
15912
  function stripCoordinatorContext(text) {
@@ -15109,8 +15990,308 @@ function parseCapacityRetryContinuation(text) {
15109
15990
  return { attempt: Number(match[1]), maxAttempts: Number(match[2]) };
15110
15991
  }
15111
15992
 
15993
+ // ../../bridges/codex-bridge/src/history/session-index-cache.ts
15994
+ import { open as open4, readFile as readFile4, stat as stat4 } from "node:fs/promises";
15995
+ var MAX_SESSION_INDEX_CACHE_ENTRIES = 50000;
15996
+ var MAX_SESSION_INDEX_CACHE_BYTES = 16 * 1024 * 1024;
15997
+ var MAX_SESSION_INDEX_CACHE_PATHS = 4;
15998
+ var ENTRY_OVERHEAD_BYTES2 = 96;
15999
+ var INDEX_OVERHEAD_BYTES = 512;
16000
+ var ANCHOR_BYTES2 = 64;
16001
+ var NEWLINE2 = 10;
16002
+ var DEFAULT_LIMITS2 = {
16003
+ maxEntries: MAX_SESSION_INDEX_CACHE_ENTRIES,
16004
+ maxBytes: MAX_SESSION_INDEX_CACHE_BYTES,
16005
+ maxPaths: MAX_SESSION_INDEX_CACHE_PATHS
16006
+ };
16007
+ var limits2 = DEFAULT_LIMITS2;
16008
+ var EMPTY_SNAPSHOT = { entries: () => [], last: () => {
16009
+ return;
16010
+ } };
16011
+ var cache = new Map;
16012
+ var locks = new Map;
16013
+ var counters2 = { fullReads: 0, tailReads: 0, uncachedReads: 0, bytesRead: 0 };
16014
+ function entryBytes2(entry) {
16015
+ return ENTRY_OVERHEAD_BYTES2 + 2 * (entry.id.length + (entry.threadName?.length ?? 0) + (entry.updatedAt?.length ?? 0));
16016
+ }
16017
+ function fitsAlone(entryCount, bytes) {
16018
+ return entryCount <= limits2.maxEntries && bytes <= limits2.maxBytes;
16019
+ }
16020
+ function touch2(index) {
16021
+ cache.delete(index.path);
16022
+ cache.set(index.path, index);
16023
+ }
16024
+ function enforceBudgets2() {
16025
+ let entries = 0;
16026
+ let bytes = 0;
16027
+ for (const index of cache.values()) {
16028
+ entries += index.entries.length;
16029
+ bytes += index.estimatedBytes;
16030
+ }
16031
+ for (const index of Array.from(cache.values())) {
16032
+ if (cache.size <= limits2.maxPaths && entries <= limits2.maxEntries && bytes <= limits2.maxBytes) {
16033
+ return;
16034
+ }
16035
+ cache.delete(index.path);
16036
+ entries -= index.entries.length;
16037
+ bytes -= index.estimatedBytes;
16038
+ }
16039
+ }
16040
+ function parseIndexLine(line) {
16041
+ const text = line.trim();
16042
+ if (!text)
16043
+ return;
16044
+ let parsed;
16045
+ try {
16046
+ parsed = JSON.parse(text);
16047
+ } catch {
16048
+ return;
16049
+ }
16050
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
16051
+ return;
16052
+ const record = parsed;
16053
+ if (typeof record.id !== "string")
16054
+ return;
16055
+ return {
16056
+ id: record.id,
16057
+ ...typeof record.thread_name === "string" ? { threadName: record.thread_name } : {},
16058
+ ...typeof record.updated_at === "string" ? { updatedAt: record.updated_at } : {}
16059
+ };
16060
+ }
16061
+ function parseChunk(bytes) {
16062
+ const lastNewline = bytes.lastIndexOf(NEWLINE2);
16063
+ const committedBytes = lastNewline + 1;
16064
+ const entries = [];
16065
+ if (committedBytes > 0) {
16066
+ for (const line of bytes.subarray(0, committedBytes).toString("utf8").split(`
16067
+ `)) {
16068
+ const entry = parseIndexLine(line);
16069
+ if (entry)
16070
+ entries.push(entry);
16071
+ }
16072
+ }
16073
+ const pendingTail = committedBytes < bytes.length ? parseIndexLine(bytes.subarray(committedBytes).toString("utf8")) : undefined;
16074
+ return { entries, committedBytes, ...pendingTail ? { pendingTail } : {} };
16075
+ }
16076
+ function snapshotOf2(index) {
16077
+ const { entries, lastById, pendingTail } = index;
16078
+ const length = entries.length;
16079
+ return {
16080
+ entries: () => {
16081
+ const committed = entries.slice(0, length);
16082
+ if (pendingTail)
16083
+ committed.push(pendingTail);
16084
+ return committed;
16085
+ },
16086
+ last(id) {
16087
+ if (pendingTail?.id === id)
16088
+ return pendingTail;
16089
+ const position = lastById.get(id);
16090
+ if (position === undefined)
16091
+ return;
16092
+ if (position < length)
16093
+ return entries[position];
16094
+ for (let at = length - 1;at >= 0; at -= 1) {
16095
+ if (entries[at].id === id)
16096
+ return entries[at];
16097
+ }
16098
+ return;
16099
+ }
16100
+ };
16101
+ }
16102
+ function lookupSnapshot(entries) {
16103
+ let lastById;
16104
+ return {
16105
+ entries: () => entries,
16106
+ last(id) {
16107
+ if (!lastById) {
16108
+ lastById = new Map;
16109
+ for (const entry of entries)
16110
+ lastById.set(entry.id, entry);
16111
+ }
16112
+ return lastById.get(id);
16113
+ }
16114
+ };
16115
+ }
16116
+ function sameStats2(index, stats) {
16117
+ return index.fileId === `${stats.dev}:${stats.ino}` && Number(stats.size) === index.size && stats.mtimeNs === index.mtimeNs && stats.ctimeNs === index.ctimeNs;
16118
+ }
16119
+ async function readRange(handle, start, end) {
16120
+ const length = end - start;
16121
+ if (length <= 0)
16122
+ return Buffer.alloc(0);
16123
+ const buffer = Buffer.alloc(length);
16124
+ let filled = 0;
16125
+ while (filled < length) {
16126
+ const { bytesRead } = await handle.read(buffer, filled, length - filled, start + filled);
16127
+ if (bytesRead === 0)
16128
+ return null;
16129
+ filled += bytesRead;
16130
+ }
16131
+ counters2.bytesRead += length;
16132
+ return buffer;
16133
+ }
16134
+ async function readAnchor2(handle, end) {
16135
+ return readRange(handle, Math.max(0, end - ANCHOR_BYTES2), end);
16136
+ }
16137
+ var RETRY2 = Symbol("retry");
16138
+ async function fullRead(path, handle, stats) {
16139
+ const size = Number(stats.size);
16140
+ const bytes = await readRange(handle, 0, size);
16141
+ if (!bytes)
16142
+ return RETRY2;
16143
+ const { entries, committedBytes, pendingTail } = parseChunk(bytes);
16144
+ let estimatedBytes = INDEX_OVERHEAD_BYTES;
16145
+ for (const entry of entries)
16146
+ estimatedBytes += entryBytes2(entry);
16147
+ if (pendingTail)
16148
+ estimatedBytes += entryBytes2(pendingTail);
16149
+ if (!fitsAlone(entries.length, estimatedBytes)) {
16150
+ cache.delete(path);
16151
+ counters2.uncachedReads += 1;
16152
+ return lookupSnapshot(pendingTail ? [...entries, pendingTail] : entries);
16153
+ }
16154
+ counters2.fullReads += 1;
16155
+ const lastById = new Map;
16156
+ entries.forEach((entry, position) => lastById.set(entry.id, position));
16157
+ const index = {
16158
+ path,
16159
+ fileId: `${stats.dev}:${stats.ino}`,
16160
+ size,
16161
+ mtimeNs: stats.mtimeNs,
16162
+ ctimeNs: stats.ctimeNs,
16163
+ consumedEnd: committedBytes,
16164
+ anchor: Buffer.from(bytes.subarray(Math.max(0, committedBytes - ANCHOR_BYTES2), committedBytes)),
16165
+ entries,
16166
+ lastById,
16167
+ ...pendingTail ? { pendingTail } : {},
16168
+ estimatedBytes
16169
+ };
16170
+ touch2(index);
16171
+ enforceBudgets2();
16172
+ return snapshotOf2(index);
16173
+ }
16174
+ async function tailRead(index, handle, stats) {
16175
+ const size = Number(stats.size);
16176
+ const anchor = await readAnchor2(handle, index.consumedEnd);
16177
+ if (!anchor?.equals(index.anchor))
16178
+ return false;
16179
+ const bytes = await readRange(handle, index.consumedEnd, size);
16180
+ if (!bytes)
16181
+ return false;
16182
+ const { entries, committedBytes, pendingTail } = parseChunk(bytes);
16183
+ let estimatedBytes = index.estimatedBytes - (index.pendingTail ? entryBytes2(index.pendingTail) : 0);
16184
+ for (const entry of entries)
16185
+ estimatedBytes += entryBytes2(entry);
16186
+ if (pendingTail)
16187
+ estimatedBytes += entryBytes2(pendingTail);
16188
+ if (!fitsAlone(index.entries.length + entries.length, estimatedBytes))
16189
+ return false;
16190
+ counters2.tailReads += 1;
16191
+ for (const entry of entries) {
16192
+ index.lastById.set(entry.id, index.entries.length);
16193
+ index.entries.push(entry);
16194
+ }
16195
+ if (committedBytes > 0) {
16196
+ const committed = bytes.subarray(0, committedBytes);
16197
+ index.anchor = Buffer.from((committedBytes >= ANCHOR_BYTES2 ? committed : Buffer.concat([index.anchor, committed])).subarray(-ANCHOR_BYTES2));
16198
+ index.consumedEnd += committedBytes;
16199
+ }
16200
+ index.pendingTail = pendingTail;
16201
+ index.size = size;
16202
+ index.mtimeNs = stats.mtimeNs;
16203
+ index.ctimeNs = stats.ctimeNs;
16204
+ index.estimatedBytes = estimatedBytes;
16205
+ touch2(index);
16206
+ enforceBudgets2();
16207
+ return snapshotOf2(index);
16208
+ }
16209
+ async function refreshOnce2(path) {
16210
+ const cached = cache.get(path);
16211
+ let pathStats;
16212
+ try {
16213
+ pathStats = await stat4(path, { bigint: true });
16214
+ } catch {
16215
+ cache.delete(path);
16216
+ return EMPTY_SNAPSHOT;
16217
+ }
16218
+ if (!pathStats.isFile()) {
16219
+ cache.delete(path);
16220
+ return EMPTY_SNAPSHOT;
16221
+ }
16222
+ if (cached && sameStats2(cached, pathStats)) {
16223
+ touch2(cached);
16224
+ return snapshotOf2(cached);
16225
+ }
16226
+ let handle;
16227
+ try {
16228
+ handle = await open4(path, "r");
16229
+ } catch {
16230
+ cache.delete(path);
16231
+ return EMPTY_SNAPSHOT;
16232
+ }
16233
+ try {
16234
+ const stats = await handle.stat({ bigint: true });
16235
+ const index = cache.get(path);
16236
+ if (index && sameStats2(index, stats)) {
16237
+ touch2(index);
16238
+ return snapshotOf2(index);
16239
+ }
16240
+ if (index && index.fileId === `${stats.dev}:${stats.ino}` && Number(stats.size) > index.size) {
16241
+ const extended = await tailRead(index, handle, stats);
16242
+ if (extended)
16243
+ return extended;
16244
+ }
16245
+ cache.delete(path);
16246
+ return await fullRead(path, handle, stats);
16247
+ } finally {
16248
+ await handle.close().catch(() => {
16249
+ return;
16250
+ });
16251
+ }
16252
+ }
16253
+ async function refreshLocked2(path) {
16254
+ for (let attempt = 0;attempt < 2; attempt += 1) {
16255
+ try {
16256
+ const snapshot = await refreshOnce2(path);
16257
+ if (snapshot !== RETRY2)
16258
+ return snapshot;
16259
+ } catch {
16260
+ cache.delete(path);
16261
+ break;
16262
+ }
16263
+ }
16264
+ cache.delete(path);
16265
+ return uncachedRead(path);
16266
+ }
16267
+ async function uncachedRead(path) {
16268
+ counters2.uncachedReads += 1;
16269
+ try {
16270
+ const raw = await readFile4(path);
16271
+ counters2.bytesRead += raw.length;
16272
+ const { entries, pendingTail } = parseChunk(raw);
16273
+ return lookupSnapshot(pendingTail ? [...entries, pendingTail] : entries);
16274
+ } catch {
16275
+ return EMPTY_SNAPSHOT;
16276
+ }
16277
+ }
16278
+ async function readSessionIndex(path) {
16279
+ const previous = locks.get(path) ?? Promise.resolve();
16280
+ const run = previous.then(() => refreshLocked2(path), () => refreshLocked2(path));
16281
+ const settled = run.catch(() => {
16282
+ return;
16283
+ });
16284
+ locks.set(path, settled);
16285
+ try {
16286
+ return await run;
16287
+ } finally {
16288
+ if (locks.get(path) === settled)
16289
+ locks.delete(path);
16290
+ }
16291
+ }
16292
+
15112
16293
  // ../../bridges/codex-bridge/src/history/rollout.ts
15113
- var log2 = createLogger("bridge.codex");
16294
+ var log3 = createLogger("bridge.codex");
15114
16295
  function getCodexHomeDir() {
15115
16296
  return process.env.CODEX_HOME || join11(homedir(), ".codex");
15116
16297
  }
@@ -15182,7 +16363,7 @@ async function findTranscriptPath(threadId, transcriptPaths, options) {
15182
16363
  if (cached) {
15183
16364
  if (cached.path !== null) {
15184
16365
  try {
15185
- await stat4(cached.path);
16366
+ await stat5(cached.path);
15186
16367
  return cached.path;
15187
16368
  } catch {
15188
16369
  cachedTranscriptPaths.delete(key);
@@ -15196,15 +16377,6 @@ async function findTranscriptPath(threadId, transcriptPaths, options) {
15196
16377
  rememberTranscriptPath(threadId, found);
15197
16378
  return found;
15198
16379
  }
15199
- async function readTranscriptLines(path) {
15200
- try {
15201
- const raw = await readFile4(path, "utf8");
15202
- return raw.split(`
15203
- `).map((line) => line.trim()).filter((line) => line.length > 0);
15204
- } catch {
15205
- return [];
15206
- }
15207
- }
15208
16380
  async function getSessionMetaFromTranscriptPath(transcriptPath, fallbackTitle, fallbackUpdatedAt) {
15209
16381
  const { records } = await readTranscriptHead(transcriptPath);
15210
16382
  const sessionMetaRecord = records.find((record) => record.type === "session_meta");
@@ -15483,21 +16655,13 @@ async function listPersistedSessionsForCwd(cwd, options) {
15483
16655
  return (await listPersistedSessionsWithTitlesForCwd(cwd, options)).sessions;
15484
16656
  }
15485
16657
  async function listPersistedSessionsWithTitlesForCwd(cwd, options) {
15486
- const indexPath = join11(getCodexHomeDir(), "session_index.jsonl");
15487
- const lines = await readTranscriptLines(indexPath);
16658
+ const index = await readSessionIndex(sessionIndexPath());
15488
16659
  const sessions = new Map;
15489
16660
  const transcriptCatalog = await buildTranscriptCatalogCached(options?.mustContainThreadId);
15490
- for (const line of lines) {
15491
- let entry;
15492
- try {
15493
- entry = JSON.parse(line);
15494
- } catch {
15495
- continue;
15496
- }
15497
- const id = typeof entry.id === "string" ? entry.id : undefined;
15498
- if (!id)
16661
+ for (const entry of index.entries()) {
16662
+ if (!entry.id)
15499
16663
  continue;
15500
- const meta = await getPersistedSessionMeta(id, typeof entry.thread_name === "string" ? entry.thread_name : undefined, typeof entry.updated_at === "string" ? entry.updated_at : undefined, transcriptCatalog);
16664
+ const meta = await getPersistedSessionMeta(entry.id, entry.threadName, entry.updatedAt, transcriptCatalog);
15501
16665
  if (!meta || meta.cwd !== cwd) {
15502
16666
  continue;
15503
16667
  }
@@ -15641,27 +16805,11 @@ function createPersistedToolParts(payload, cwd, callId) {
15641
16805
  function persistedOutputState(payloadType, part, output) {
15642
16806
  return payloadType === "custom_tool_call_output" ? resolveTranscriptToolOutputState(part.toolName, output, part.toolState ?? null) : null;
15643
16807
  }
16808
+ function sessionIndexPath() {
16809
+ return join11(getCodexHomeDir(), "session_index.jsonl");
16810
+ }
15644
16811
  async function findSessionIndexEntry(threadId) {
15645
- const lines = await readTranscriptLines(join11(getCodexHomeDir(), "session_index.jsonl"));
15646
- let match = null;
15647
- for (const line of lines) {
15648
- let parsed;
15649
- try {
15650
- parsed = JSON.parse(line);
15651
- } catch {
15652
- continue;
15653
- }
15654
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
15655
- continue;
15656
- const entry = parsed;
15657
- if (entry.id !== threadId)
15658
- continue;
15659
- match = {
15660
- threadName: typeof entry.thread_name === "string" ? entry.thread_name : undefined,
15661
- updatedAt: typeof entry.updated_at === "string" ? entry.updated_at : undefined
15662
- };
15663
- }
15664
- return match;
16812
+ return (await readSessionIndex(sessionIndexPath())).last(threadId) ?? null;
15665
16813
  }
15666
16814
  async function resolvePersistedSessionMetaForThread(threadId) {
15667
16815
  const indexed = await findSessionIndexEntry(threadId);
@@ -15712,7 +16860,7 @@ async function hydrateMessagesFromPersistedSession(threadId, options = {}) {
15712
16860
  };
15713
16861
  }
15714
16862
  }
15715
- log2.warn("rollout.hydrate-failed", { threadId });
16863
+ log3.warn("rollout.hydrate-failed", { threadId });
15716
16864
  return {
15717
16865
  messages: [],
15718
16866
  title: meta.title,
@@ -16201,7 +17349,7 @@ async function replayPersistedRollout(threadId, snapshot, meta, structuredTurns)
16201
17349
  }
16202
17350
 
16203
17351
  // ../../bridges/codex-bridge/src/messages/render-turn.ts
16204
- var log3 = createLogger("bridge.codex");
17352
+ var log4 = createLogger("bridge.codex");
16205
17353
  var TRUNCATION_NOTICE = `
16206
17354
  … output truncated`;
16207
17355
  var SUBAGENT_TRANSCRIPT_PROBE_INTERVAL_MS = 2000;
@@ -16618,7 +17766,7 @@ async function renderTurn(turn, options) {
16618
17766
  loadSnapshot = latestSnapshot;
16619
17767
  }
16620
17768
  } catch (error) {
16621
- log3.warn("subagent.activity-load-failed", { error: formatLogError(error) });
17769
+ log4.warn("subagent.activity-load-failed", { error: formatLogError(error) });
16622
17770
  }
16623
17771
  }
16624
17772
  const { items, itemsByKey, accumulatorsByKey, itemKeys } = collectTurnItems(turn, options.segment);
@@ -17057,7 +18205,7 @@ function repositoryInstructionsBlock(path, content, truncated) {
17057
18205
  }
17058
18206
 
17059
18207
  // ../protocol/src/node/repository-instructions.ts
17060
- import { open as open4, realpath } from "node:fs/promises";
18208
+ import { open as open5, realpath } from "node:fs/promises";
17061
18209
  import { join as join12, relative as relative2, isAbsolute as isAbsolute7 } from "node:path";
17062
18210
  var MAX_REPOSITORY_INSTRUCTIONS_BYTES = 256 * 1024;
17063
18211
  async function readRepositoryInstructions(cwd, maxBytes = MAX_REPOSITORY_INSTRUCTIONS_BYTES) {
@@ -17067,7 +18215,7 @@ async function readRepositoryInstructions(cwd, maxBytes = MAX_REPOSITORY_INSTRUC
17067
18215
  const inside = relative2(root, target);
17068
18216
  if (!inside || inside.startsWith("..") || isAbsolute7(inside))
17069
18217
  return;
17070
- const handle = await open4(target, "r");
18218
+ const handle = await open5(target, "r");
17071
18219
  try {
17072
18220
  const buffer = Buffer.alloc(maxBytes + 1);
17073
18221
  const { bytesRead } = await handle.read(buffer, 0, maxBytes + 1, 0);
@@ -17125,9 +18273,9 @@ var ORKESTRATOR_ARTIFACT_MCP_SERVER_NAME = "orkestrator-artifacts";
17125
18273
  var ORKESTRATOR_ARTIFACT_MCP_PATH = "/artifact-mcp";
17126
18274
 
17127
18275
  // ../../bridges/codex-bridge/src/engine/app-server-engine.ts
17128
- import { open as open8 } from "node:fs/promises";
18276
+ import { open as open9 } from "node:fs/promises";
17129
18277
  import { createHash as createHash11 } from "node:crypto";
17130
- import { isAbsolute as isAbsolute9, join as join19 } from "node:path";
18278
+ import { isAbsolute as isAbsolute9, join as join20 } from "node:path";
17131
18279
 
17132
18280
  // ../../bridges/codex-bridge/src/app-server/process-supervisor.ts
17133
18281
  import { execFile as execFile3, spawn as spawn2 } from "node:child_process";
@@ -17135,12 +18283,12 @@ import { randomUUID as randomUUID6 } from "node:crypto";
17135
18283
  import {
17136
18284
  link,
17137
18285
  mkdir as mkdir6,
17138
- open as open5,
18286
+ open as open6,
17139
18287
  readFile as readFile5,
17140
18288
  readlink,
17141
18289
  rename as rename4,
17142
18290
  rm as rm5,
17143
- stat as stat5
18291
+ stat as stat6
17144
18292
  } from "node:fs/promises";
17145
18293
  import { join as join14 } from "node:path";
17146
18294
 
@@ -17396,7 +18544,7 @@ function extractThreadId(params) {
17396
18544
  }
17397
18545
 
17398
18546
  // ../../bridges/codex-bridge/src/app-server/jsonl-rpc-client.ts
17399
- var log4 = createLogger("bridge.codex");
18547
+ var log5 = createLogger("bridge.codex");
17400
18548
  var DEFAULT_MAX_INBOUND_LINE_BYTES = 64 * 1024 * 1024;
17401
18549
  var DEFAULT_MAX_OUTBOUND_LINE_BYTES = 32 * 1024 * 1024;
17402
18550
  var DEFAULT_REQUEST_TIMEOUT_MS = 60000;
@@ -17508,7 +18656,7 @@ class JsonlRpcClient {
17508
18656
  try {
17509
18657
  this.options.recordInboundLine(line);
17510
18658
  } catch (error) {
17511
- log4.error("recorder.threw", { error: formatLogError(error) });
18659
+ log5.error("recorder.threw", { error: formatLogError(error) });
17512
18660
  }
17513
18661
  }
17514
18662
  const message = parseInboundLine(line);
@@ -17540,7 +18688,7 @@ class JsonlRpcClient {
17540
18688
  try {
17541
18689
  this.options.onServerRequest(message);
17542
18690
  } catch (error) {
17543
- log4.error("server-request.handoff-failed", { error: formatLogError(error) });
18691
+ log5.error("server-request.handoff-failed", { error: formatLogError(error) });
17544
18692
  }
17545
18693
  return;
17546
18694
  }
@@ -17549,7 +18697,7 @@ class JsonlRpcClient {
17549
18697
  try {
17550
18698
  this.options.onNotification(message, extractThreadId(message.params));
17551
18699
  } catch (error) {
17552
- log4.error("notification.enqueue-failed", { error: formatLogError(error) });
18700
+ log5.error("notification.enqueue-failed", { error: formatLogError(error) });
17553
18701
  }
17554
18702
  return;
17555
18703
  }
@@ -17721,7 +18869,7 @@ class SerialQueue {
17721
18869
  this.maxObservedDepth = Math.max(this.maxObservedDepth, this.depth);
17722
18870
  const previous = this.chains.get(key) ?? Promise.resolve();
17723
18871
  const next = previous.then(() => task()).catch((error) => {
17724
- log4.error("queue.task-failed", { key, error: formatLogError(error) });
18872
+ log5.error("queue.task-failed", { key, error: formatLogError(error) });
17725
18873
  }).finally(() => {
17726
18874
  this.depth -= 1;
17727
18875
  if (this.chains.get(key) === next)
@@ -17744,9 +18892,9 @@ class SerialQueue {
17744
18892
  // ../../bridges/codex-bridge/src/app-server/notification-recorder.ts
17745
18893
  import { appendFile as appendFile4, mkdir as mkdir5 } from "node:fs/promises";
17746
18894
  import { join as join13 } from "node:path";
17747
- var log5 = createLogger("bridge.codex");
18895
+ var log6 = createLogger("bridge.codex");
17748
18896
  function recorderNotice(message) {
17749
- log5.warn("recorder.notice", { detail: message });
18897
+ log6.warn("recorder.notice", { detail: message });
17750
18898
  }
17751
18899
  var DEFAULT_MAX_RECORDING_BYTES = 64 * 1024 * 1024;
17752
18900
  var DEFAULT_FLUSH_INTERVAL_MS = 250;
@@ -17859,7 +19007,7 @@ class NotificationRecorder {
17859
19007
  } catch (error) {
17860
19008
  this.stats.writeErrors += 1;
17861
19009
  this.stats.linesDropped += pending.length;
17862
- log5.error("recorder.write-failed", { error: formatLogError(error, { stack: false }) });
19010
+ log6.error("recorder.write-failed", { error: formatLogError(error, { stack: false }) });
17863
19011
  }
17864
19012
  }
17865
19013
  async close() {
@@ -17894,7 +19042,7 @@ function createRecorderFromEnv(options) {
17894
19042
  import { execFile as execFileCallback } from "node:child_process";
17895
19043
  import { createHash as createHash8 } from "node:crypto";
17896
19044
  import { promisify } from "node:util";
17897
- var log6 = createLogger("bridge.codex");
19045
+ var log7 = createLogger("bridge.codex");
17898
19046
  var execFile2 = promisify(execFileCallback);
17899
19047
  var RUNTIME_ENV_SCRIPT_ENV = "ORKESTRATOR_RUNTIME_ENV_SCRIPT";
17900
19048
  var DEFAULT_RUNTIME_ENV_SCRIPT = "/usr/local/bin/orkestrator-runtime-env.sh";
@@ -17972,10 +19120,10 @@ async function refreshRuntimeEnvironment(run = execFile2) {
17972
19120
  });
17973
19121
  const updated = applyRuntimeEnvironmentOutput(stdout);
17974
19122
  if (updated.length > 0) {
17975
- log6.info("runtime-env.refreshed", { names: updated.join(", ") });
19123
+ log7.info("runtime-env.refreshed", { names: updated.join(", ") });
17976
19124
  }
17977
19125
  } catch (error) {
17978
- log6.warn("runtime-env.refresh-failed", { error: formatLogError(error) });
19126
+ log7.warn("runtime-env.refresh-failed", { error: formatLogError(error) });
17979
19127
  }
17980
19128
  }
17981
19129
  function fingerprintRuntimeEnvironment(env = process.env) {
@@ -17995,7 +19143,7 @@ function runtimeEnvironmentSnapshot(env = process.env) {
17995
19143
  }
17996
19144
 
17997
19145
  // ../../bridges/codex-bridge/src/app-server/process-supervisor.ts
17998
- var log7 = createLogger("bridge.codex");
19146
+ var log8 = createLogger("bridge.codex");
17999
19147
 
18000
19148
  class AppServerOwnershipUnavailableError extends AppServerUnavailableError {
18001
19149
  ownershipContention = true;
@@ -18276,7 +19424,7 @@ class AppServerSupervisor {
18276
19424
  if (describedLines >= STDERR_METADATA_LINE_BUDGET)
18277
19425
  return;
18278
19426
  describedLines += 1;
18279
- log7.info("app-server.stderr", () => ({
19427
+ log8.info("app-server.stderr", () => ({
18280
19428
  generation: generationId,
18281
19429
  detail: describeChildStderrLine(line)
18282
19430
  }));
@@ -18300,7 +19448,7 @@ class AppServerSupervisor {
18300
19448
  stderrTail = "";
18301
19449
  if (suppressedLines === 0)
18302
19450
  return;
18303
- log7.info("app-server.stderr-suppressed", {
19451
+ log8.info("app-server.stderr-suppressed", {
18304
19452
  generation: generationId,
18305
19453
  lines: suppressedLines,
18306
19454
  payloadBytes: suppressedBytes
@@ -18310,7 +19458,7 @@ class AppServerSupervisor {
18310
19458
  };
18311
19459
  const recorder = (this.options.createRecorder ?? ((generation) => createRecorderFromEnv({ generation })))(generationId);
18312
19460
  if (recorder) {
18313
- log7.warn("app-server.recording", {
19461
+ log8.warn("app-server.recording", {
18314
19462
  generation: generationId,
18315
19463
  fileName: recorder.getStats().fileName
18316
19464
  });
@@ -18323,7 +19471,7 @@ class AppServerSupervisor {
18323
19471
  onServerRequest: (request) => this.options.onServerRequest(request, generationId),
18324
19472
  onProtocolViolation: (detail) => {
18325
19473
  this.unknownNotifications += 1;
18326
- log7.warn("app-server.protocol-violation", { generation: generationId, detail });
19474
+ log8.warn("app-server.protocol-violation", { generation: generationId, detail });
18327
19475
  },
18328
19476
  ...recorder ? { recordInboundLine: (line) => recorder.record(line) } : {}
18329
19477
  });
@@ -18401,7 +19549,7 @@ class AppServerSupervisor {
18401
19549
  return;
18402
19550
  const exited = this.current;
18403
19551
  this.current = null;
18404
- log7.warn("app-server.exited", {
19552
+ log8.warn("app-server.exited", {
18405
19553
  generation: generationId,
18406
19554
  code,
18407
19555
  signal,
@@ -18561,7 +19709,7 @@ class AppServerSupervisor {
18561
19709
  instanceId
18562
19710
  }), "utf8");
18563
19711
  const temporary = `${path}.${this.pidOwnerToken}.update`;
18564
- const handle = await open5(temporary, "wx", 384);
19712
+ const handle = await open6(temporary, "wx", 384);
18565
19713
  try {
18566
19714
  await handle.write(payload, 0, payload.length, 0);
18567
19715
  await handle.sync();
@@ -18585,7 +19733,7 @@ class AppServerSupervisor {
18585
19733
  await mkdir6(this.pidFileDir(), { recursive: true });
18586
19734
  for (let attempt = 0;attempt < PID_ACQUISITION_MAX_ATTEMPTS; attempt += 1) {
18587
19735
  try {
18588
- const handle = await open5(this.pidFilePath(), "wx", 384);
19736
+ const handle = await open6(this.pidFilePath(), "wx", 384);
18589
19737
  try {
18590
19738
  const record = {
18591
19739
  ownerToken: this.pidOwnerToken,
@@ -18637,7 +19785,7 @@ class AppServerSupervisor {
18637
19785
  return false;
18638
19786
  } else {
18639
19787
  try {
18640
- const metadata = await stat5(path);
19788
+ const metadata = await stat6(path);
18641
19789
  if (Date.now() - metadata.mtimeMs < INCOMPLETE_PIDFILE_GRACE_MS)
18642
19790
  return false;
18643
19791
  } catch {
@@ -18665,7 +19813,7 @@ class AppServerSupervisor {
18665
19813
  if (outcome === "contended")
18666
19814
  return true;
18667
19815
  if (matches && pid !== null) {
18668
- log7.info("app-server.stale-reaped", { pid });
19816
+ log8.info("app-server.stale-reaped", { pid });
18669
19817
  (this.options.signalPidFileProcess ?? signalStaleProcessTree)(pid);
18670
19818
  }
18671
19819
  return true;
@@ -18762,7 +19910,7 @@ class AppServerSupervisor {
18762
19910
  }
18763
19911
  let moved = null;
18764
19912
  try {
18765
- moved = await stat5(quarantinePath, { bigint: true });
19913
+ moved = await stat6(quarantinePath, { bigint: true });
18766
19914
  } catch {
18767
19915
  moved = null;
18768
19916
  }
@@ -19342,7 +20490,7 @@ function buildInteractionResponse(request, answer) {
19342
20490
  }
19343
20491
 
19344
20492
  // ../../bridges/codex-bridge/src/app-server/server-request-router.ts
19345
- var log8 = createLogger("bridge.codex");
20493
+ var log9 = createLogger("bridge.codex");
19346
20494
  var DEFAULT_RESPONSE_TIMEOUT_MS = 1e4;
19347
20495
  var DEFAULT_APPROVAL_TIMEOUT_MS = AGENT_INTERACTION_DEFAULT_TIMEOUT_MS;
19348
20496
 
@@ -19502,7 +20650,7 @@ class ServerRequestRouter {
19502
20650
  record.timedOut = true;
19503
20651
  this.counts.timedOut += 1;
19504
20652
  if (this.sendStarted.has(key)) {
19505
- log8.error("server-request.flush-timeout", {
20653
+ log9.error("server-request.flush-timeout", {
19506
20654
  method: record.method,
19507
20655
  timeoutMs: this.responseTimeoutMs
19508
20656
  });
@@ -19606,7 +20754,7 @@ class ServerRequestRouter {
19606
20754
  accepted = this.options.presentApproval?.(approval) === true;
19607
20755
  } catch (error) {
19608
20756
  deadline.settle();
19609
- log8.error("approval.present-failed", { error: formatLogError(error) });
20757
+ log9.error("approval.present-failed", { error: formatLogError(error) });
19610
20758
  return false;
19611
20759
  }
19612
20760
  if (!accepted) {
@@ -19643,7 +20791,7 @@ class ServerRequestRouter {
19643
20791
  try {
19644
20792
  this.options.onApprovalResolved?.(parked.request, decision, resolution);
19645
20793
  } catch (error) {
19646
- log8.error("approval.resolved-callback-failed", { error: formatLogError(error) });
20794
+ log9.error("approval.resolved-callback-failed", { error: formatLogError(error) });
19647
20795
  }
19648
20796
  if (options.skipSend) {
19649
20797
  this.pending.delete(parked.key);
@@ -19664,7 +20812,7 @@ class ServerRequestRouter {
19664
20812
  try {
19665
20813
  this.options.onApprovalResolved?.(parked.request, "withdrawn", "withdrawn");
19666
20814
  } catch (error) {
19667
- log8.error("approval.resolved-callback-failed", { error: formatLogError(error) });
20815
+ log9.error("approval.resolved-callback-failed", { error: formatLogError(error) });
19668
20816
  }
19669
20817
  this.pending.delete(parked.key);
19670
20818
  this.sendStarted.delete(parked.key);
@@ -19706,7 +20854,7 @@ class ServerRequestRouter {
19706
20854
  accepted = this.options.presentInteraction?.(interaction) === true;
19707
20855
  } catch (error) {
19708
20856
  deadline?.settle();
19709
- log8.error("interaction.present-failed", { error: formatLogError(error) });
20857
+ log9.error("interaction.present-failed", { error: formatLogError(error) });
19710
20858
  return false;
19711
20859
  }
19712
20860
  if (!accepted) {
@@ -19742,7 +20890,7 @@ class ServerRequestRouter {
19742
20890
  try {
19743
20891
  this.options.onInteractionResolved?.(parked.request, answer, resolution);
19744
20892
  } catch (error) {
19745
- log8.error("interaction.resolved-callback-failed", { error: formatLogError(error) });
20893
+ log9.error("interaction.resolved-callback-failed", { error: formatLogError(error) });
19746
20894
  }
19747
20895
  if (options.skipSend) {
19748
20896
  this.pending.delete(parked.key);
@@ -19775,7 +20923,7 @@ class ServerRequestRouter {
19775
20923
  try {
19776
20924
  await send();
19777
20925
  } catch (error) {
19778
- log8.error("server-request.answer-failed", {
20926
+ log9.error("server-request.answer-failed", {
19779
20927
  method: record.method,
19780
20928
  error: formatLogError(error, { stack: false })
19781
20929
  });
@@ -19792,7 +20940,7 @@ class ServerRequestRouter {
19792
20940
  }
19793
20941
  violation(method, detail) {
19794
20942
  this.options.onInvariantViolation?.(method, detail);
19795
- log8.error("app-server.invariant-violation", { method, detail });
20943
+ log9.error("app-server.invariant-violation", { method, detail });
19796
20944
  }
19797
20945
  explain(record, message) {
19798
20946
  this.options.reportToTranscript?.({
@@ -20379,7 +21527,7 @@ function reduceHistoricalTurns(turns, generation, threadId, handle) {
20379
21527
 
20380
21528
  // ../../bridges/codex-bridge/src/sessions/dispatch-journal.ts
20381
21529
  import { createHash as createHash10 } from "node:crypto";
20382
- import { mkdir as mkdir8, open as open6, rename as rename6, rm as rm7, writeFile as writeFile5 } from "node:fs/promises";
21530
+ import { mkdir as mkdir8, open as open7, rename as rename6, rm as rm7, writeFile as writeFile5 } from "node:fs/promises";
20383
21531
  import { join as join16 } from "node:path";
20384
21532
 
20385
21533
  // ../../bridges/codex-bridge/src/sessions/persistence.ts
@@ -20392,11 +21540,11 @@ import {
20392
21540
  readdir as readdir2,
20393
21541
  rename as rename5,
20394
21542
  rm as rm6,
20395
- stat as stat6,
21543
+ stat as stat7,
20396
21544
  writeFile as writeFile4
20397
21545
  } from "node:fs/promises";
20398
21546
  import { join as join15 } from "node:path";
20399
- var log9 = createLogger("bridge.codex");
21547
+ var log10 = createLogger("bridge.codex");
20400
21548
  var BRIDGE_SESSION_REGISTRY_VERSION = 2;
20401
21549
  var SESSION_TITLE_SOURCES = new Set([
20402
21550
  "codex",
@@ -20481,6 +21629,7 @@ function hashCwd(cwd) {
20481
21629
  return createHash9("sha256").update(cwd).digest("hex").slice(0, 16);
20482
21630
  }
20483
21631
  var DEFAULT_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
21632
+ var RECORD_FILE_MISSING = Symbol("record-file-missing");
20484
21633
  var TEMP_FILE_GRACE_MS = 60 * 60 * 1000;
20485
21634
  var PRIVATE_DIRECTORY_MODE = 448;
20486
21635
  var PRIVATE_FILE_MODE = 384;
@@ -20571,9 +21720,40 @@ class BridgeSessionStore {
20571
21720
  const loaded = records.filter((record) => record !== null);
20572
21721
  return migrationFailed && loaded.length === 0 ? legacy : loaded;
20573
21722
  }
21723
+ async loadRecord(bridgeSessionId) {
21724
+ const cutoff = this.now() - this.retentionMs;
21725
+ const key = `${this.recordKey(bridgeSessionId)}.json`;
21726
+ const record = await this.readRecordFile(join15(this.recordsDir(), key), bridgeSessionId, cutoff);
21727
+ if (record !== RECORD_FILE_MISSING)
21728
+ return record;
21729
+ const legacy = (await this.readLegacy(cutoff)).find((session) => session.bridgeSessionId === bridgeSessionId);
21730
+ if (legacy)
21731
+ return legacy;
21732
+ const loginRecords = this.loginRecordsDir();
21733
+ if (!loginRecords)
21734
+ return null;
21735
+ const adoptable = await this.readRecordFile(join15(loginRecords, key), bridgeSessionId, cutoff);
21736
+ return adoptable === RECORD_FILE_MISSING ? null : adoptable;
21737
+ }
21738
+ async readRecordFile(path, bridgeSessionId, cutoff) {
21739
+ let raw;
21740
+ try {
21741
+ raw = await readFile6(path, "utf8");
21742
+ } catch (error) {
21743
+ return error.code === "ENOENT" ? RECORD_FILE_MISSING : null;
21744
+ }
21745
+ try {
21746
+ const value = JSON.parse(raw);
21747
+ if (isPersistedSessionTombstone(value))
21748
+ return null;
21749
+ return isPersistedBridgeSession(value, this.cwdHash, cutoff) && value.bridgeSessionId === bridgeSessionId ? value : null;
21750
+ } catch {
21751
+ return null;
21752
+ }
21753
+ }
20574
21754
  async collectStaleTemporary(path) {
20575
21755
  try {
20576
- const info = await stat6(path);
21756
+ const info = await stat7(path);
20577
21757
  if (this.now() - info.mtimeMs < TEMP_FILE_GRACE_MS)
20578
21758
  return;
20579
21759
  await rm6(path, { force: true });
@@ -20609,6 +21789,13 @@ class BridgeSessionStore {
20609
21789
  try {
20610
21790
  await chmod(this.dir(), PRIVATE_DIRECTORY_MODE);
20611
21791
  await chmod(this.path(), PRIVATE_FILE_MODE);
21792
+ } catch {
21793
+ return [];
21794
+ }
21795
+ return this.readLegacy(cutoff);
21796
+ }
21797
+ async readLegacy(cutoff) {
21798
+ try {
20612
21799
  const parsed = JSON.parse(await readFile6(this.path(), "utf8"));
20613
21800
  if (parsed.version !== BRIDGE_SESSION_REGISTRY_VERSION)
20614
21801
  return [];
@@ -20696,7 +21883,7 @@ class BridgeSessionStore {
20696
21883
  await chmod(path, PRIVATE_FILE_MODE);
20697
21884
  }
20698
21885
  warnPersistenceFailure(error) {
20699
- log9.warn("registry.persist-failed", { error: formatLogError(error, { stack: false }) });
21886
+ log10.warn("registry.persist-failed", { error: formatLogError(error, { stack: false }) });
20700
21887
  }
20701
21888
  toRecord(options) {
20702
21889
  const { agentMcp: _agentMcp, ...persistedConfig } = options.config;
@@ -20720,7 +21907,7 @@ class BridgeSessionStore {
20720
21907
  }
20721
21908
 
20722
21909
  // ../../bridges/codex-bridge/src/sessions/dispatch-journal.ts
20723
- var log10 = createLogger("bridge.codex");
21910
+ var log11 = createLogger("bridge.codex");
20724
21911
  var DISPATCH_JOURNAL_VERSION = 1;
20725
21912
  var DISPATCH_COMPLETENESS_VERSION = 1;
20726
21913
  var MAX_FRESH_SESSION_MARKERS = 256;
@@ -20901,7 +22088,7 @@ class DispatchJournal {
20901
22088
  return true;
20902
22089
  }
20903
22090
  async readBounded(path) {
20904
- const handle = await open6(path, "r");
22091
+ const handle = await open7(path, "r");
20905
22092
  try {
20906
22093
  const metadata = await handle.stat();
20907
22094
  if (!metadata.isFile() || metadata.size > this.maxBytes) {
@@ -21259,7 +22446,7 @@ class DispatchJournal {
21259
22446
  throw error;
21260
22447
  });
21261
22448
  } catch (error) {
21262
- log10.warn("journal.persist-failed", { error: formatLogError(error, { stack: false }) });
22449
+ log11.warn("journal.persist-failed", { error: formatLogError(error, { stack: false }) });
21263
22450
  if (options.failClosed)
21264
22451
  throw error;
21265
22452
  }
@@ -21376,8 +22563,80 @@ function coordinatorCapabilityPolicy(mode) {
21376
22563
 
21377
22564
  // ../../bridges/codex-bridge/src/codex-config.ts
21378
22565
  import { existsSync as existsSync3, readdirSync as readdirSync3, realpathSync, statSync as statSync2 } from "node:fs";
22566
+ import { homedir as homedir3 } from "node:os";
22567
+ import { isAbsolute as isAbsolute8, join as join18, relative as relative3, sep } from "node:path";
22568
+
22569
+ // ../../bridges/codex-bridge/src/shell-exclusions.ts
22570
+ import { closeSync, openSync, readSync, fstatSync } from "node:fs";
21379
22571
  import { homedir as homedir2 } from "node:os";
21380
- import { isAbsolute as isAbsolute8, join as join17, relative as relative3, sep } from "node:path";
22572
+ import { dirname as dirname3, join as join17, resolve as resolve3 } from "node:path";
22573
+ function configuredShellExclusions(env) {
22574
+ const paths = new Set([
22575
+ "/etc/codex/config.toml",
22576
+ join17(env.CODEX_HOME || join17(env.HOME || homedir2(), ".codex"), "config.toml")
22577
+ ]);
22578
+ {
22579
+ let directory = resolve3(env.CWD || process.cwd());
22580
+ for (;; ) {
22581
+ paths.add(join17(directory, ".codex", "config.toml"));
22582
+ const parent = dirname3(directory);
22583
+ if (parent === directory)
22584
+ break;
22585
+ directory = parent;
22586
+ }
22587
+ }
22588
+ const exclusions = new Set;
22589
+ for (const path of paths) {
22590
+ let fd;
22591
+ try {
22592
+ fd = openSync(path, "r");
22593
+ } catch (error) {
22594
+ if (error.code === "ENOENT")
22595
+ continue;
22596
+ throw new Error("Cannot read Codex shell exclusions");
22597
+ }
22598
+ try {
22599
+ const stat = fstatSync(fd);
22600
+ if (!stat.isFile() || stat.size > 1024 * 1024) {
22601
+ throw new Error("Invalid Codex configuration file");
22602
+ }
22603
+ const buffer = Buffer.alloc(1024 * 1024 + 1);
22604
+ let length = 0;
22605
+ while (length < buffer.length) {
22606
+ const count = readSync(fd, buffer, length, buffer.length - length, null);
22607
+ if (count === 0)
22608
+ break;
22609
+ length += count;
22610
+ }
22611
+ if (length > 1024 * 1024)
22612
+ throw new Error("Codex configuration too large");
22613
+ const config = Bun.TOML.parse(buffer.subarray(0, length).toString("utf8"));
22614
+ collect(config, exclusions);
22615
+ } catch {
22616
+ throw new Error("Cannot load Codex shell exclusions");
22617
+ } finally {
22618
+ closeSync(fd);
22619
+ }
22620
+ }
22621
+ return [...exclusions];
22622
+ }
22623
+ function collect(config, exclusions) {
22624
+ if (!config || typeof config !== "object" || Array.isArray(config))
22625
+ return;
22626
+ const table = config;
22627
+ const policy = table.shell_environment_policy;
22628
+ if (policy && Object.hasOwn(policy, "exclude")) {
22629
+ if (!Array.isArray(policy.exclude) || policy.exclude.some((item) => typeof item !== "string")) {
22630
+ throw new Error("Invalid Codex shell exclusions");
22631
+ }
22632
+ for (const pattern of policy.exclude)
22633
+ exclusions.add(pattern);
22634
+ }
22635
+ if (table.profiles && typeof table.profiles === "object") {
22636
+ for (const profile of Object.values(table.profiles))
22637
+ collect(profile, exclusions);
22638
+ }
22639
+ }
21381
22640
 
21382
22641
  // ../../bridges/codex-bridge/src/engine/mcp-tool-availability.ts
21383
22642
  var ORKESTRATOR_MCP_STARTUP_TIMEOUT_SEC = 15;
@@ -21489,7 +22748,7 @@ function codexCoordinatorSkillExtraRoots(env = process.env, cwd = env.CWD?.trim(
21489
22748
  const userDir = env[COORDINATOR_CODEX_USER_SKILLS_DIR_ENV]?.trim();
21490
22749
  return [
21491
22750
  ...userDir && isAbsolute8(userDir) ? [userDir] : [],
21492
- ...cwd && isAbsolute8(cwd) ? [join17(cwd, ".claude", "skills")] : []
22751
+ ...cwd && isAbsolute8(cwd) ? [join18(cwd, ".claude", "skills")] : []
21493
22752
  ].filter((dir) => existsSync3(dir));
21494
22753
  }
21495
22754
  var MAX_SKILL_READ_GRANTS = 256;
@@ -21497,11 +22756,11 @@ function isWithin(parent, child) {
21497
22756
  const path = relative3(parent, child);
21498
22757
  return path === "" || !path.startsWith(`..${sep}`) && path !== ".." && !isAbsolute8(path);
21499
22758
  }
21500
- function codexCoordinatorSkillReadRoots(env = process.env, home = env.HOME?.trim() || homedir2()) {
22759
+ function codexCoordinatorSkillReadRoots(env = process.env, home = env.HOME?.trim() || homedir3()) {
21501
22760
  const userDir = env[COORDINATOR_CODEX_USER_SKILLS_DIR_ENV]?.trim();
21502
22761
  const roots = [
21503
22762
  ...userDir && isAbsolute8(userDir) ? [userDir] : [],
21504
- join17(home, ".agents", "skills")
22763
+ join18(home, ".agents", "skills")
21505
22764
  ];
21506
22765
  const homeReal = (() => {
21507
22766
  try {
@@ -21535,8 +22794,8 @@ function codexCoordinatorSkillReadRoots(env = process.env, home = env.HOME?.trim
21535
22794
  break;
21536
22795
  let target;
21537
22796
  try {
21538
- target = realpathSync(join17(real, entry));
21539
- if (!statSync2(target).isDirectory() || !existsSync3(join17(target, "SKILL.md")))
22797
+ target = realpathSync(join18(real, entry));
22798
+ if (!statSync2(target).isDirectory() || !existsSync3(join18(target, "SKILL.md")))
21540
22799
  continue;
21541
22800
  } catch {
21542
22801
  continue;
@@ -21675,13 +22934,35 @@ function resolveCodexMaxConcurrentThreads(value) {
21675
22934
  const parsed = Number(value);
21676
22935
  return Number.isSafeInteger(parsed) && parsed >= 1 && parsed <= MAX_CODEX_CONCURRENT_THREADS ? parsed : DEFAULT_CODEX_MAX_CONCURRENT_THREADS;
21677
22936
  }
22937
+ var CODEX_SESSION_SHELL_EXCLUDE = Object.freeze([
22938
+ "CODEX_BRIDGE_TOKEN",
22939
+ "*_BRIDGE_TOKEN",
22940
+ ORKESTRATOR_AGENT_MCP_TOKEN_ENV,
22941
+ ORKESTRATOR_AGENT_MCP_URL_ENV,
22942
+ "CODEX_API_KEY"
22943
+ ]);
22944
+ var CODEX_COORDINATOR_SHELL_EXCLUDE = Object.freeze([
22945
+ ...new Set([
22946
+ "*_KEY",
22947
+ "*_SECRET",
22948
+ "*_TOKEN",
22949
+ "CODEX_HOME",
22950
+ ...CODEX_SESSION_SHELL_EXCLUDE,
22951
+ "CODEX_BRIDGE_PERMISSION_PROFILE",
22952
+ "CODEX_BRIDGE_READABLE_RUNTIME_ROOT"
22953
+ ])
22954
+ ]);
21678
22955
  function codexAppServerConfigOverrides(env = process.env) {
22956
+ const userExclusions = configuredShellExclusions(env);
21679
22957
  const childLimit = resolveCodexMaxConcurrentThreads(env[CODEX_MAX_CONCURRENT_THREADS_ENV]);
21680
22958
  const overrides = {
21681
22959
  "agents.max_concurrent_threads_per_session": String(childLimit),
21682
22960
  "features.multi_agent_v2.max_concurrent_threads_per_session": String(childLimit + 1),
21683
22961
  "features.incremental_tools": "false",
21684
- "features.goals": "false"
22962
+ "features.goals": "false",
22963
+ "shell_environment_policy.exclude": JSON.stringify([
22964
+ ...new Set([...userExclusions, ...CODEX_SESSION_SHELL_EXCLUDE])
22965
+ ])
21685
22966
  };
21686
22967
  const rawUrl = env[ORKESTRATOR_AGENT_MCP_URL_ENV]?.trim();
21687
22968
  const token = env[ORKESTRATOR_AGENT_MCP_TOKEN_ENV]?.trim();
@@ -21729,15 +23010,7 @@ function codexAppServerConfigOverrides(env = process.env) {
21729
23010
  overrides["shell_environment_policy.inherit"] = JSON.stringify("core");
21730
23011
  overrides["shell_environment_policy.ignore_default_excludes"] = "false";
21731
23012
  overrides["shell_environment_policy.exclude"] = JSON.stringify([
21732
- "*_KEY",
21733
- "*_SECRET",
21734
- "*_TOKEN",
21735
- "CODEX_HOME",
21736
- "CODEX_BRIDGE_TOKEN",
21737
- "CODEX_BRIDGE_PERMISSION_PROFILE",
21738
- "CODEX_BRIDGE_READABLE_RUNTIME_ROOT",
21739
- ORKESTRATOR_AGENT_MCP_TOKEN_ENV,
21740
- ORKESTRATOR_AGENT_MCP_URL_ENV
23013
+ ...new Set([...userExclusions, ...CODEX_COORDINATOR_SHELL_EXCLUDE])
21741
23014
  ]);
21742
23015
  }
21743
23016
  if (rawUrl && token) {
@@ -21769,7 +23042,7 @@ function codexAppServerConfigOverrides(env = process.env) {
21769
23042
  // ../../bridges/codex-bridge/src/github-credential-config.ts
21770
23043
  import { mkdtemp as mkdtemp2 } from "node:fs/promises";
21771
23044
  import { tmpdir as tmpdir2 } from "node:os";
21772
- import { join as join18 } from "node:path";
23045
+ import { join as join19 } from "node:path";
21773
23046
  var CODEX_INHERITED_GIT_CONFIG_PATTERNS = Object.freeze([
21774
23047
  "GIT_CONFIG_COUNT",
21775
23048
  "GIT_CONFIG_KEY_*",
@@ -21804,7 +23077,7 @@ function codexGitHubCredentialThreadConfig(policy, options) {
21804
23077
  }
21805
23078
  var withheldGhConfigDir;
21806
23079
  function emptyGhConfigDir() {
21807
- withheldGhConfigDir ??= mkdtemp2(join18(tmpdir2(), "orkestrator-gh-withheld-")).catch((error) => {
23080
+ withheldGhConfigDir ??= mkdtemp2(join19(tmpdir2(), "orkestrator-gh-withheld-")).catch((error) => {
21808
23081
  withheldGhConfigDir = undefined;
21809
23082
  throw error;
21810
23083
  });
@@ -21812,11 +23085,11 @@ function emptyGhConfigDir() {
21812
23085
  }
21813
23086
 
21814
23087
  // ../../bridges/codex-bridge/src/sessions/tool-history-guard.ts
21815
- import { open as open7 } from "node:fs/promises";
23088
+ import { open as open8 } from "node:fs/promises";
21816
23089
  var TOOL_HISTORY_MARKER = '"type":"additional_tools"';
21817
23090
  var MAX_TOOL_HISTORY_LINEAGE_DEPTH = 32;
21818
23091
  async function rolloutDeclaresToolHistory(path, end) {
21819
- const handle = await open7(path, "r");
23092
+ const handle = await open8(path, "r");
21820
23093
  try {
21821
23094
  const size = (await handle.stat()).size;
21822
23095
  const limit = end === undefined ? size : Math.min(end, size);
@@ -21841,7 +23114,7 @@ async function rolloutDeclaresToolHistory(path, end) {
21841
23114
  }
21842
23115
  }
21843
23116
  async function historyBase(path) {
21844
- const handle = await open7(path, "r");
23117
+ const handle = await open8(path, "r");
21845
23118
  try {
21846
23119
  const chunks = [];
21847
23120
  let filled = 0;
@@ -21924,7 +23197,7 @@ var APP_SERVER_CAPABILITIES = {
21924
23197
  };
21925
23198
 
21926
23199
  // ../../bridges/codex-bridge/src/engine/app-server-engine.ts
21927
- var log11 = createLogger("bridge.codex");
23200
+ var log12 = createLogger("bridge.codex");
21928
23201
  var AGENT_MAIL_TOOL_APPROVALS = Object.fromEntries([
21929
23202
  ...AGENT_MAIL_TOOL_NAMES,
21930
23203
  ...ARTIFACT_TOOL_NAMES,
@@ -22281,7 +23554,7 @@ function signedOutAccountRead(error) {
22281
23554
  }
22282
23555
  async function readStoredLoginFingerprint(codexHome) {
22283
23556
  try {
22284
- const file = await open8(join19(codexHome, "auth.json"), "r");
23557
+ const file = await open9(join20(codexHome, "auth.json"), "r");
22285
23558
  let raw;
22286
23559
  try {
22287
23560
  const bytes = Buffer.alloc(65537);
@@ -22508,7 +23781,7 @@ class AppServerEngine {
22508
23781
  try {
22509
23782
  listener(event);
22510
23783
  } catch (error) {
22511
- log11.error("engine.listener-failed", { error: formatLogError(error) });
23784
+ log12.error("engine.listener-failed", { error: formatLogError(error) });
22512
23785
  }
22513
23786
  }
22514
23787
  }
@@ -22633,7 +23906,7 @@ class AppServerEngine {
22633
23906
  const sequence = ++this.accountCheckSequence;
22634
23907
  const generation = this.supervisor.getGeneration();
22635
23908
  this.supervisor.request("account/read", { refreshToken }).catch(signedOutAccountRead).then((response) => this.applyAccountRead(response, sequence, generation, accountReplaced)).catch((error) => {
22636
- log11.warn("account.sign-in-check-failed", {
23909
+ log12.warn("account.sign-in-check-failed", {
22637
23910
  error: formatLogError(error, { stack: false })
22638
23911
  });
22639
23912
  });
@@ -23220,7 +24493,7 @@ class AppServerEngine {
23220
24493
  const generation = this.supervisor.getGeneration();
23221
24494
  const response = await this.supervisor.request("account/read", { refreshToken: false }).catch(signedOutAccountRead);
23222
24495
  this.applyAccountRead(response, sequence, generation, false).catch((error) => {
23223
- log11.warn("account.connector-recovery-failed", {
24496
+ log12.warn("account.connector-recovery-failed", {
23224
24497
  error: formatLogError(error, { stack: false })
23225
24498
  });
23226
24499
  });
@@ -23433,7 +24706,7 @@ class AppServerEngine {
23433
24706
  await this.supervisor.request("thread/name/set", { threadId, name });
23434
24707
  return true;
23435
24708
  } catch (error) {
23436
- log11.warn("thread.rename-failed", { error: formatLogError(error, { stack: false }) });
24709
+ log12.warn("thread.rename-failed", { error: formatLogError(error, { stack: false }) });
23437
24710
  return false;
23438
24711
  }
23439
24712
  }
@@ -23453,7 +24726,7 @@ class AppServerEngine {
23453
24726
  } catch (error) {
23454
24727
  if (requireConfirmation)
23455
24728
  throw error;
23456
- log11.warn("thread.unsubscribe-failed", { error: formatLogError(error, { stack: false }) });
24729
+ log12.warn("thread.unsubscribe-failed", { error: formatLogError(error, { stack: false }) });
23457
24730
  }
23458
24731
  this.accountProofTurns.delete(threadId);
23459
24732
  this.rolloutPaths.delete(threadId);
@@ -23995,7 +25268,7 @@ function externalRevertCut(messages, survivingTurnIds, running) {
23995
25268
  }
23996
25269
 
23997
25270
  // ../../bridges/codex-bridge/src/app-server-runtime-sessions.ts
23998
- var log12 = createLogger("bridge.codex");
25271
+ var log13 = createLogger("bridge.codex");
23999
25272
  var SESSION_CLOSING_ERROR = "Session is closing";
24000
25273
  var ACTIVITY_PROCESS = randomUUID8();
24001
25274
 
@@ -24122,7 +25395,7 @@ class CodexRuntimeSessions {
24122
25395
  try {
24123
25396
  fork = await this.ctx.options.engine.forkThread(parent.threadId, parent.config, lastTurnId);
24124
25397
  } catch (error) {
24125
- log12.warn("thread.fork-failed", {
25398
+ log13.warn("thread.fork-failed", {
24126
25399
  threadId: parent.threadId,
24127
25400
  error: formatLogError(error, { stack: false })
24128
25401
  });
@@ -24174,7 +25447,7 @@ class CodexRuntimeSessions {
24174
25447
  await this.ctx.callbacks.deleteSession(child.id).catch(() => {
24175
25448
  return;
24176
25449
  });
24177
- log12.warn("thread.fork-hydrate-failed", {
25450
+ log13.warn("thread.fork-hydrate-failed", {
24178
25451
  threadId: parent.threadId,
24179
25452
  error: formatLogError(error, { stack: false })
24180
25453
  });
@@ -24189,7 +25462,7 @@ class CodexRuntimeSessions {
24189
25462
  });
24190
25463
  turns = thread?.turns;
24191
25464
  } catch (error) {
24192
- log12.warn("thread.turns-read-failed", {
25465
+ log13.warn("thread.turns-read-failed", {
24193
25466
  threadId: context.threadId,
24194
25467
  error: formatLogError(error, { stack: false })
24195
25468
  });
@@ -24680,7 +25953,7 @@ class CodexRuntimeSessions {
24680
25953
  try {
24681
25954
  turns = (await this.ctx.options.engine.readThread(context.threadId, { includeTurns: true }))?.turns;
24682
25955
  } catch (error) {
24683
- log12.warn("thread.turns-read-after-revert-failed", {
25956
+ log13.warn("thread.turns-read-after-revert-failed", {
24684
25957
  threadId: context.threadId,
24685
25958
  error: formatLogError(error, { stack: false })
24686
25959
  });
@@ -24771,7 +26044,7 @@ class CodexRuntimeSessions {
24771
26044
  if (attached && requestedModelChanged) {
24772
26045
  attached.modelId = previousConfirmedModel;
24773
26046
  }
24774
- log12.warn("session.config-apply-failed", {
26047
+ log13.warn("session.config-apply-failed", {
24775
26048
  sessionId,
24776
26049
  error: formatLogError(error, { stack: false })
24777
26050
  });
@@ -24794,7 +26067,7 @@ class CodexRuntimeSessions {
24794
26067
  try {
24795
26068
  context = await this.ctx.callbacks.ensureAttached(sessionId);
24796
26069
  } catch (error) {
24797
- log12.warn("transcript.serving-last-known", {
26070
+ log13.warn("transcript.serving-last-known", {
24798
26071
  sessionId,
24799
26072
  error: formatLogError(error, { stack: false })
24800
26073
  });
@@ -24996,7 +26269,7 @@ class CodexRuntimeSessions {
24996
26269
  }
24997
26270
  return "unpublished";
24998
26271
  }
24999
- log12.warn("registry.persist-failed", { error: formatLogError(error, { stack: false }) });
26272
+ log13.warn("registry.persist-failed", { error: formatLogError(error, { stack: false }) });
25000
26273
  }
25001
26274
  if (this.ctx.registry.getSession(sessionId) !== session)
25002
26275
  return "released";
@@ -25052,7 +26325,7 @@ class CodexRuntimeSessions {
25052
26325
  if (!session.threadId)
25053
26326
  return true;
25054
26327
  try {
25055
- const persisted = (await this.ctx.store.load()).find((record) => record.bridgeSessionId === session.id);
26328
+ const persisted = await this.ctx.store.loadRecord(session.id);
25056
26329
  if (!persisted)
25057
26330
  return false;
25058
26331
  const { agentMcp: _agentMcp, ...persistableConfig } = session.config;
@@ -25090,7 +26363,7 @@ class CodexRuntimeSessions {
25090
26363
  }
25091
26364
  }
25092
26365
  // ../../bridges/codex-bridge/src/app-server-runtime-approvals.ts
25093
- var log13 = createLogger("bridge.codex");
26366
+ var log14 = createLogger("bridge.codex");
25094
26367
 
25095
26368
  class CodexRuntimeApprovals {
25096
26369
  ctx;
@@ -25181,7 +26454,7 @@ class CodexRuntimeApprovals {
25181
26454
  if (this.ctx.options.engine.resolveApproval(approvalId, decision)) {
25182
26455
  if (decision === "cancel") {
25183
26456
  this.ctx.callbacks.abort(sessionId).catch((error) => {
25184
- log13.error("approval.cancel-failed", { error: formatLogError(error) });
26457
+ log14.error("approval.cancel-failed", { error: formatLogError(error) });
25185
26458
  });
25186
26459
  }
25187
26460
  return "applied";
@@ -25303,8 +26576,8 @@ function parseCommandToken(text, sigils = ["/"]) {
25303
26576
 
25304
26577
  // ../../bridges/codex-bridge/src/prompts/template-discovery.ts
25305
26578
  import { createHash as createHash13 } from "node:crypto";
25306
- import { open as open9, readdir as readdir3, stat as stat7 } from "node:fs/promises";
25307
- import { join as join20 } from "node:path";
26579
+ import { open as open10, readdir as readdir3, stat as stat8 } from "node:fs/promises";
26580
+ import { join as join21 } from "node:path";
25308
26581
  var TEMPLATE_LIMITS = Object.freeze({
25309
26582
  maxTemplates: 512,
25310
26583
  maxVisitedEntries: 2048,
@@ -25324,8 +26597,8 @@ var RESERVED_TEMPLATE_PREFIXES = ["/skill:", "/prompts:"];
25324
26597
  var TEMPLATE_ID_PREFIX = "codex-template:";
25325
26598
  function templateRoots(cwd, codexHome = getCodexHomeDir()) {
25326
26599
  return [
25327
- { origin: "project", dir: join20(cwd, ".codex", "prompts") },
25328
- { origin: "user", dir: join20(codexHome, "prompts") }
26600
+ { origin: "project", dir: join21(cwd, ".codex", "prompts") },
26601
+ { origin: "user", dir: join21(codexHome, "prompts") }
25329
26602
  ];
25330
26603
  }
25331
26604
  function templateCommandId(origin, relativePath) {
@@ -25350,7 +26623,7 @@ function isReservedName(name) {
25350
26623
  var metadataCache = new Map;
25351
26624
  var METADATA_CACHE_MAX = 1024;
25352
26625
  async function readBounded2(absolutePath, maxBytes) {
25353
- const handle = await open9(absolutePath, "r");
26626
+ const handle = await open10(absolutePath, "r");
25354
26627
  try {
25355
26628
  const info = await handle.stat();
25356
26629
  if (!info.isFile())
@@ -25430,7 +26703,7 @@ async function scanPromptTemplates(roots, limits = TEMPLATE_LIMITS) {
25430
26703
  return;
25431
26704
  }
25432
26705
  visited += 1;
25433
- const absolutePath = join20(dir, entry.name);
26706
+ const absolutePath = join21(dir, entry.name);
25434
26707
  const relativePath = relative ? `${relative}/${entry.name}` : entry.name;
25435
26708
  if (entry.isDirectory()) {
25436
26709
  if (depth + 1 > limits.maxDepth) {
@@ -25447,7 +26720,7 @@ async function scanPromptTemplates(roots, limits = TEMPLATE_LIMITS) {
25447
26720
  continue;
25448
26721
  let info;
25449
26722
  try {
25450
- info = await stat7(absolutePath);
26723
+ info = await stat8(absolutePath);
25451
26724
  } catch {
25452
26725
  skipped += 1;
25453
26726
  continue;
@@ -25734,6 +27007,11 @@ function skillCommandRow(binding, projectResources = true) {
25734
27007
  ...unavailable ? { availability: { state: "unavailable", ...unavailable } } : {}
25735
27008
  };
25736
27009
  }
27010
+ function realSettleTimer(fire, delayMs) {
27011
+ const timer = setTimeout(fire, delayMs);
27012
+ timer.unref?.();
27013
+ return () => clearTimeout(timer);
27014
+ }
25737
27015
 
25738
27016
  class SkillInventory {
25739
27017
  deps;
@@ -25745,7 +27023,7 @@ class SkillInventory {
25745
27023
  settledGeneration = null;
25746
27024
  settling = null;
25747
27025
  answeredGeneration = null;
25748
- settleTimer = null;
27026
+ cancelSettle = null;
25749
27027
  disposed = false;
25750
27028
  stats = { invalidations: 0, reads: 0, scheduledRefreshes: 0, settlingReads: 0 };
25751
27029
  constructor(deps) {
@@ -25863,10 +27141,10 @@ class SkillInventory {
25863
27141
  armSettle(snapshot, round) {
25864
27142
  const { generation } = snapshot;
25865
27143
  const baseline = snapshotSignature(snapshot);
25866
- if (this.settleTimer)
25867
- clearTimeout(this.settleTimer);
25868
- this.settleTimer = setTimeout(() => {
25869
- this.settleTimer = null;
27144
+ this.cancelSettle?.();
27145
+ const setSettleTimer = this.deps.setSettleTimer ?? realSettleTimer;
27146
+ this.cancelSettle = setSettleTimer(() => {
27147
+ this.cancelSettle = null;
25870
27148
  if (this.disposed || this.deps.generation() !== generation)
25871
27149
  return;
25872
27150
  this.invalidationSerial += 1;
@@ -25891,16 +27169,14 @@ class SkillInventory {
25891
27169
  return;
25892
27170
  });
25893
27171
  }, this.coldSettleMs());
25894
- this.settleTimer.unref?.();
25895
27172
  }
25896
27173
  dispose() {
25897
27174
  this.disposed = true;
25898
27175
  if (this.refreshTimer)
25899
27176
  clearTimeout(this.refreshTimer);
25900
27177
  this.refreshTimer = null;
25901
- if (this.settleTimer)
25902
- clearTimeout(this.settleTimer);
25903
- this.settleTimer = null;
27178
+ this.cancelSettle?.();
27179
+ this.cancelSettle = null;
25904
27180
  this.settling = null;
25905
27181
  }
25906
27182
  }
@@ -25990,6 +27266,7 @@ class CodexCommandCatalogue {
25990
27266
  ...options.skillTtlMs !== undefined ? { ttlMs: options.skillTtlMs } : {},
25991
27267
  ...options.skillRefreshDebounceMs !== undefined ? { refreshDebounceMs: options.skillRefreshDebounceMs } : {},
25992
27268
  ...options.skillColdSettleMs !== undefined ? { coldSettleMs: options.skillColdSettleMs } : {},
27269
+ ...options.skillSettleTimer ? { setSettleTimer: options.skillSettleTimer } : {},
25993
27270
  onRefreshed: (read) => {
25994
27271
  this.skillsDigest = commandBindingRevision([
25995
27272
  String(read.fresh),
@@ -26583,8 +27860,8 @@ class UpdateCoalescer {
26583
27860
  }
26584
27861
 
26585
27862
  // ../../bridges/codex-bridge/src/app-server-runtime-capacity-retry.ts
26586
- import { stat as stat8 } from "node:fs/promises";
26587
- var log14 = createLogger("bridge.codex");
27863
+ import { stat as stat9 } from "node:fs/promises";
27864
+ var log15 = createLogger("bridge.codex");
26588
27865
 
26589
27866
  class CodexCapacityRetry {
26590
27867
  ctx;
@@ -26698,7 +27975,7 @@ class CodexCapacityRetry {
26698
27975
  }
26699
27976
  entry.stage = "starting";
26700
27977
  const work = this.startContinuation(context, turn, entry).catch((error) => {
26701
- log14.error("turn.capacity-retry-failed", {
27978
+ log15.error("turn.capacity-retry-failed", {
26702
27979
  turnId: turn.turnId,
26703
27980
  error: formatLogError(error, { stack: false })
26704
27981
  });
@@ -26725,7 +28002,7 @@ class CodexCapacityRetry {
26725
28002
  await this.ctx.journal.markContinuation(requestId, clientId);
26726
28003
  plan.attempt = entry.attempt;
26727
28004
  const path = engine.rolloutPath(context.threadId);
26728
- const offset = path ? await stat8(path).then((stats) => stats.size, () => {
28005
+ const offset = path ? await stat9(path).then((stats) => stats.size, () => {
26729
28006
  return;
26730
28007
  }) : undefined;
26731
28008
  this.lifecycle.stateFor(context.threadId).refusedCellOffset = offset;
@@ -26770,7 +28047,7 @@ class CodexCapacityRetry {
26770
28047
  });
26771
28048
  return;
26772
28049
  }
26773
- await this.ctx.journal.markAccepted(requestId, { threadId: context.threadId, turnId: started.turnId }).catch((error) => log14.warn("turn.capacity-retry-journal-failed", {
28050
+ await this.ctx.journal.markAccepted(requestId, { threadId: context.threadId, turnId: started.turnId }).catch((error) => log15.warn("turn.capacity-retry-journal-failed", {
26774
28051
  requestId,
26775
28052
  error: formatLogError(error, { stack: false })
26776
28053
  }));
@@ -26841,7 +28118,7 @@ class CodexCapacityRetry {
26841
28118
  }
26842
28119
 
26843
28120
  // ../../bridges/codex-bridge/src/app-server-runtime-lifecycle.ts
26844
- var log15 = createLogger("bridge.codex");
28121
+ var log16 = createLogger("bridge.codex");
26845
28122
  function artifactConnectionToken(value) {
26846
28123
  if (!value || typeof value !== "object" || Array.isArray(value))
26847
28124
  return;
@@ -27025,7 +28302,7 @@ class CodexRuntimeLifecycle {
27025
28302
  this.ctx.registry.setPhase(existing, "recovering");
27026
28303
  this.emitStatus(existing);
27027
28304
  this.ctx.callbacks.scheduleRecoveryBackstop(existing);
27028
- log15.warn("dispatch.restore-failed", {
28305
+ log16.warn("dispatch.restore-failed", {
27029
28306
  requestId: record.requestId,
27030
28307
  error: formatLogError(error, { stack: false })
27031
28308
  });
@@ -27204,7 +28481,7 @@ class CodexRuntimeLifecycle {
27204
28481
  });
27205
28482
  }));
27206
28483
  }
27207
- log15.warn("thread.reattach-failed", {
28484
+ log16.warn("thread.reattach-failed", {
27208
28485
  threadId,
27209
28486
  rolloutMissing: isMissingRolloutError(error),
27210
28487
  error: formatLogError(error, { stack: false })
@@ -27285,7 +28562,7 @@ class CodexRuntimeLifecycle {
27285
28562
  coalescer: new UpdateCoalescer({
27286
28563
  intervalMs: this.ctx.options.coalesceIntervalMs ?? (() => messageSnapshotIntervalMs(this.ctx.threadState.get(threadId)?.lastPublishedSnapshotChars ?? 0)),
27287
28564
  publish: () => this.ctx.callbacks.publishAssistantMessage(threadId),
27288
- onError: (error) => log15.error("message.publish-failed", { error: formatLogError(error) })
28565
+ onError: (error) => log16.error("message.publish-failed", { error: formatLogError(error) })
27289
28566
  })
27290
28567
  };
27291
28568
  this.ctx.threadState.set(threadId, state);
@@ -27321,7 +28598,7 @@ class CodexRuntimeLifecycle {
27321
28598
  this.ctx.commandCatalogue.withdrawGeneration(event.generation);
27322
28599
  const recovery = this.ctx.generationRecovery.then(() => this.ctx.callbacks.recoverAfterGenerationChange(event.generation));
27323
28600
  this.ctx.generationRecovery = recovery.catch((error) => {
27324
- log15.error("generation.recovery-failed", { error: formatLogError(error) });
28601
+ log16.error("generation.recovery-failed", { error: formatLogError(error) });
27325
28602
  });
27326
28603
  return;
27327
28604
  }
@@ -27341,7 +28618,7 @@ class CodexRuntimeLifecycle {
27341
28618
  }
27342
28619
  if (event.kind === "account.reload.requested") {
27343
28620
  this.ctx.callbacks.reloadStoredAccountLogin().catch((error) => {
27344
- log15.warn("account.login-reload-failed", { error: formatLogError(error, { stack: false }) });
28621
+ log16.warn("account.login-reload-failed", { error: formatLogError(error, { stack: false }) });
27345
28622
  });
27346
28623
  return;
27347
28624
  }
@@ -27644,7 +28921,7 @@ class CodexRuntimeLifecycle {
27644
28921
  }
27645
28922
  this.ctx.options.changeEvidence?.turn(this.evidenceSource(context, turn), event.status);
27646
28923
  const finalize = () => this.runFinalization(context, turn).catch((error) => {
27647
- log15.error("turn.finalize-failed", {
28924
+ log16.error("turn.finalize-failed", {
27648
28925
  turnId: turn.turnId,
27649
28926
  error: formatLogError(error, { stack: false })
27650
28927
  });
@@ -27862,7 +29139,7 @@ class CodexRuntimeLifecycle {
27862
29139
  }
27863
29140
  trackCommandChangeWork(work) {
27864
29141
  const tracked = work.catch((error) => {
27865
- log15.warn("command-changes.record-failed", { error: formatLogError(error, { stack: false }) });
29142
+ log16.warn("command-changes.record-failed", { error: formatLogError(error, { stack: false }) });
27866
29143
  });
27867
29144
  this.ctx.pendingCommandChanges.add(tracked);
27868
29145
  tracked.finally(() => this.ctx.pendingCommandChanges.delete(tracked));
@@ -28305,7 +29582,7 @@ class CodexRuntimeLifecycle {
28305
29582
  try {
28306
29583
  await state.coalescer.flushNow();
28307
29584
  } catch (error) {
28308
- log15.error("ordered-events.flush-failed", { error: formatLogError(error) });
29585
+ log16.error("ordered-events.flush-failed", { error: formatLogError(error) });
28309
29586
  }
28310
29587
  state.orderedReconcilePending = false;
28311
29588
  for (const sessionId of this.ctx.sessionIdsForThread(threadId)) {
@@ -28324,7 +29601,7 @@ class CodexRuntimeLifecycle {
28324
29601
  await state.coalescer.flushNow();
28325
29602
  event.publish();
28326
29603
  } catch (error) {
28327
- log15.error("ordered-events.publish-failed", { error: formatLogError(error) });
29604
+ log16.error("ordered-events.publish-failed", { error: formatLogError(error) });
28328
29605
  state.orderedEvents.length = 0;
28329
29606
  state.orderedEventBytes = 0;
28330
29607
  state.orderedReconcilePending = true;
@@ -28333,7 +29610,7 @@ class CodexRuntimeLifecycle {
28333
29610
  }
28334
29611
  }
28335
29612
  } catch (error) {
28336
- log15.error("ordered-events.reconcile-failed", { error: formatLogError(error) });
29613
+ log16.error("ordered-events.reconcile-failed", { error: formatLogError(error) });
28337
29614
  } finally {
28338
29615
  state.orderedEventDraining = false;
28339
29616
  if ((state.orderedReconcilePending || state.orderedEvents.length > 0) && this.ctx.threadState.get(threadId) === state) {
@@ -28441,7 +29718,7 @@ function requiredCoordinatorPermissionProfile() {
28441
29718
  }
28442
29719
 
28443
29720
  // ../../bridges/codex-bridge/src/app-server-runtime-prompt.ts
28444
- import { stat as stat9 } from "node:fs/promises";
29721
+ import { stat as stat10 } from "node:fs/promises";
28445
29722
  // ../protocol/src/tab-initial-prompt.ts
28446
29723
  var TAB_INITIAL_PROMPT_REQUEST_PREFIX = "initial-prompt:";
28447
29724
  function isTabInitialPromptRequestId(requestId) {
@@ -28449,7 +29726,7 @@ function isTabInitialPromptRequestId(requestId) {
28449
29726
  }
28450
29727
 
28451
29728
  // ../../bridges/codex-bridge/src/app-server-runtime-prompt.ts
28452
- var log16 = createLogger("bridge.codex");
29729
+ var log17 = createLogger("bridge.codex");
28453
29730
  function commandRefusal(message) {
28454
29731
  return { ok: false, status: 422, error: message, kind: "command-unavailable" };
28455
29732
  }
@@ -28816,7 +30093,7 @@ class CodexRuntimePrompt {
28816
30093
  let refusedCellOffset;
28817
30094
  const startTurn = async () => {
28818
30095
  const path = this.ctx.options.engine.rolloutPath(context.threadId);
28819
- refusedCellOffset = path ? await stat9(path).then((stats) => stats.size, (error) => error.code === "ENOENT" ? 0 : undefined) : undefined;
30096
+ refusedCellOffset = path ? await stat10(path).then((stats) => stats.size, (error) => error.code === "ENOENT" ? 0 : undefined) : undefined;
28820
30097
  return this.ctx.options.engine.startTurn({
28821
30098
  handle: context.engineHandle,
28822
30099
  input: engineInput,
@@ -29110,7 +30387,7 @@ class CodexRuntimePrompt {
29110
30387
  try {
29111
30388
  outcome = await this.ctx.options.engine.reconcileRequest(context.threadId, accumulator.providerRequestId);
29112
30389
  } catch (error) {
29113
- log16.warn("dispatch.reconcile-failed", {
30390
+ log17.warn("dispatch.reconcile-failed", {
29114
30391
  requestId,
29115
30392
  threadId: context.threadId,
29116
30393
  error: formatLogError(error, { stack: false })
@@ -29385,7 +30662,7 @@ class CodexRuntimePrompt {
29385
30662
  if (this.ctx.stopping || this.shouldAbandonDrain(expectedGeneration))
29386
30663
  return;
29387
30664
  if (Date.now() >= deadline) {
29388
- log16.warn("app-server.drain-expired");
30665
+ log17.warn("app-server.drain-expired");
29389
30666
  return;
29390
30667
  }
29391
30668
  await this.waitForThreadActivity();
@@ -29418,8 +30695,8 @@ class CodexRuntimePrompt {
29418
30695
  }
29419
30696
 
29420
30697
  // ../../bridges/codex-bridge/src/app-server-runtime-tail.ts
29421
- import { join as join21, relative as relative4, isAbsolute as isAbsolute11 } from "node:path";
29422
- var log17 = createLogger("bridge.codex");
30698
+ import { join as join22, relative as relative4, isAbsolute as isAbsolute11 } from "node:path";
30699
+ var log18 = createLogger("bridge.codex");
29423
30700
 
29424
30701
  class CodexRuntimeTail {
29425
30702
  ctx;
@@ -29568,7 +30845,7 @@ class CodexRuntimeTail {
29568
30845
  };
29569
30846
  }
29570
30847
  } catch (error) {
29571
- log17.warn("models.list-failed", { error: formatLogError(error, { stack: false }) });
30848
+ log18.warn("models.list-failed", { error: formatLogError(error, { stack: false }) });
29572
30849
  }
29573
30850
  return this.ctx.options.loadCachedModels();
29574
30851
  }
@@ -29594,7 +30871,7 @@ class CodexRuntimeTail {
29594
30871
  });
29595
30872
  }
29596
30873
  } catch (error) {
29597
- log17.warn("threads.list-failed", { error: formatLogError(error, { stack: false }) });
30874
+ log18.warn("threads.list-failed", { error: formatLogError(error, { stack: false }) });
29598
30875
  }
29599
30876
  const archived = new Set;
29600
30877
  try {
@@ -29618,7 +30895,7 @@ class CodexRuntimeTail {
29618
30895
  cursor = page.nextCursor ?? undefined;
29619
30896
  } while (cursor);
29620
30897
  } catch {}
29621
- const archivedRoot = join21(this.ctx.options.codexHome, "archived_sessions");
30898
+ const archivedRoot = join22(this.ctx.options.codexHome, "archived_sessions");
29622
30899
  const isArchived = (meta) => {
29623
30900
  if (archived.has(meta.id))
29624
30901
  return true;
@@ -29679,7 +30956,7 @@ class CodexRuntimeTail {
29679
30956
  else
29680
30957
  await this.ctx.options.engine.unarchiveThread(threadId);
29681
30958
  } catch (error) {
29682
- log17.warn("thread.archive-failed", {
30959
+ log18.warn("thread.archive-failed", {
29683
30960
  archived,
29684
30961
  error: formatLogError(error, { stack: false })
29685
30962
  });
@@ -30314,7 +31591,7 @@ var CODEX_FALLBACK_MODEL_CATALOG = [
30314
31591
  ];
30315
31592
 
30316
31593
  // ../../bridges/codex-bridge/src/models-cache.ts
30317
- var log18 = createLogger("bridge.codex");
31594
+ var log19 = createLogger("bridge.codex");
30318
31595
  var MODEL_REASONING_EFFORTS = new Set([
30319
31596
  "minimal",
30320
31597
  "low",
@@ -30461,13 +31738,13 @@ class ModelCatalogCache {
30461
31738
  await this.opts.writePersistedCache(models);
30462
31739
  }
30463
31740
  } catch (error) {
30464
- log18.warn("models.refresh-failed", { error: formatLogError(error, { stack: false }) });
31741
+ log19.warn("models.refresh-failed", { error: formatLogError(error, { stack: false }) });
30465
31742
  }
30466
31743
  }
30467
31744
  }
30468
31745
 
30469
31746
  // ../../bridges/codex-bridge/src/index.ts
30470
- var log19 = createLogger("bridge.codex");
31747
+ var log20 = createLogger("bridge.codex");
30471
31748
  configureBridgeLogger();
30472
31749
  var WORKFLOW_RESULT_TOOL_NAMES2 = new Set(WORKFLOW_RESULT_KINDS.map(workflowResultToolName));
30473
31750
  function isWorkflowResultTool(value) {
@@ -30500,7 +31777,7 @@ app.onError((error, c) => {
30500
31777
  const response = error.getResponse();
30501
31778
  return c.newResponse(response.body, response);
30502
31779
  }
30503
- log19.error("http.request-failed", {
31780
+ log20.error("http.request-failed", {
30504
31781
  method: c.req.method,
30505
31782
  path: c.req.path,
30506
31783
  error: formatLogError(error)
@@ -30515,6 +31792,7 @@ function boundCodexTranscriptResponse(messages, tailMessages) {
30515
31792
  var BRIDGE_TOKEN_ENV = "CODEX_BRIDGE_TOKEN";
30516
31793
  var BRIDGE_ALLOWED_ORIGINS_ENV = "CODEX_BRIDGE_ALLOWED_ORIGINS";
30517
31794
  var bridgeAuthToken = process.env[BRIDGE_TOKEN_ENV]?.trim() || randomBytes(32).toString("base64url");
31795
+ delete process.env[BRIDGE_TOKEN_ENV];
30518
31796
  var bridgeAuthEnabledOverrideForTesting = null;
30519
31797
  var sseRouteTestHooks = null;
30520
31798
  var BRIDGE_VERSION = "1.0.0";
@@ -30528,10 +31806,10 @@ function notifyObservers(event, revision) {
30528
31806
  for (const observer of observers) {
30529
31807
  try {
30530
31808
  Promise.resolve(observer(event, revision, "{}")).catch((error) => {
30531
- log19.warn("sse.observer-failed", { error: formatLogError(error) });
31809
+ log20.warn("sse.observer-failed", { error: formatLogError(error) });
30532
31810
  });
30533
31811
  } catch (error) {
30534
- log19.warn("sse.observer-failed", { error: formatLogError(error) });
31812
+ log20.warn("sse.observer-failed", { error: formatLogError(error) });
30535
31813
  }
30536
31814
  }
30537
31815
  }
@@ -30657,14 +31935,14 @@ async function writeCodexRawLog(sessionId, entry, logDir = codexRawLogDir) {
30657
31935
  try {
30658
31936
  await mkdir9(logDir, { recursive: true });
30659
31937
  const filename = `${sanitizeLogFileComponent(sessionId)}.jsonl`;
30660
- await appendFile5(join22(logDir, filename), `${JSON.stringify({
31938
+ await appendFile5(join23(logDir, filename), `${JSON.stringify({
30661
31939
  timestamp: new Date().toISOString(),
30662
31940
  sessionId,
30663
31941
  ...entry
30664
31942
  })}
30665
31943
  `, "utf8");
30666
31944
  } catch (error) {
30667
- log19.warn("raw-log.write-failed", { error: formatLogError(error) });
31945
+ log20.warn("raw-log.write-failed", { error: formatLogError(error) });
30668
31946
  }
30669
31947
  }
30670
31948
  function createShutdownHandler(timer, clearTimer = clearInterval, exit = (code) => process.exit(code), stopEngine = () => stopSelectedEngine()) {
@@ -30675,12 +31953,12 @@ function createShutdownHandler(timer, clearTimer = clearInterval, exit = (code)
30675
31953
  shuttingDown = true;
30676
31954
  clearTimer(timer);
30677
31955
  stopEngine().catch((error) => {
30678
- log19.warn("engine.stop-failed", { error: formatLogError(error) });
31956
+ log20.warn("engine.stop-failed", { error: formatLogError(error) });
30679
31957
  }).finally(() => exit(0));
30680
31958
  };
30681
31959
  }
30682
31960
  function createParentExitHandler(interrupt, shutdown, report = (turns, ms) => {
30683
- log19.info("turns.stopped", { turns, elapsedMs: ms });
31961
+ log20.info("turns.stopped", { turns, elapsedMs: ms });
30684
31962
  }) {
30685
31963
  return async () => {
30686
31964
  const detectedAt = performance.now();
@@ -30711,7 +31989,7 @@ function serializeSseEventData(event) {
30711
31989
  ...event.data
30712
31990
  });
30713
31991
  } catch {
30714
- log19.error("sse.payload-serialize-failed");
31992
+ log20.error("sse.payload-serialize-failed");
30715
31993
  return JSON.stringify({
30716
31994
  sessionId: event.sessionId,
30717
31995
  error: "payload could not be serialized"
@@ -30776,7 +32054,7 @@ function emit(event) {
30776
32054
  messageId = retainedMessageId(event.type, payload);
30777
32055
  bytes = eager === null ? estimateSsePayloadBytes(payload) : Buffer.byteLength(eager, "utf8");
30778
32056
  } catch {
30779
- log19.error("sse.payload-snapshot-failed");
32057
+ log20.error("sse.payload-snapshot-failed");
30780
32058
  payload = { error: "payload could not be serialized" };
30781
32059
  eager = subscribers.size > 0 ? serializeSseEventData({ sessionId, data: payload }) : null;
30782
32060
  messageId = undefined;
@@ -30793,18 +32071,18 @@ function emit(event) {
30793
32071
  for (const subscriber of subscribers) {
30794
32072
  try {
30795
32073
  Promise.resolve(subscriber(event, revision, eager ?? "{}")).catch((error) => {
30796
- log19.warn("sse.subscriber-failed", { error: formatLogError(error) });
32074
+ log20.warn("sse.subscriber-failed", { error: formatLogError(error) });
30797
32075
  });
30798
32076
  } catch (error) {
30799
- log19.warn("sse.subscriber-failed", { error: formatLogError(error) });
32077
+ log20.warn("sse.subscriber-failed", { error: formatLogError(error) });
30800
32078
  }
30801
32079
  }
30802
32080
  }
30803
32081
  function bridgeCacheDir() {
30804
- return join22(getCodexHomeDir(), "orkestrator-bridge");
32082
+ return join23(getCodexHomeDir(), "orkestrator-bridge");
30805
32083
  }
30806
32084
  function bridgeCachePath() {
30807
- return join22(bridgeCacheDir(), "models-cache.json");
32085
+ return join23(bridgeCacheDir(), "models-cache.json");
30808
32086
  }
30809
32087
  var BRIDGE_MODEL_CACHE_VERSION = 2;
30810
32088
  async function readPersistedBridgeCache() {
@@ -30823,12 +32101,12 @@ async function writePersistedBridgeCache(models) {
30823
32101
  await mkdir9(bridgeCacheDir(), { recursive: true });
30824
32102
  await writeFile6(bridgeCachePath(), JSON.stringify({ version: BRIDGE_MODEL_CACHE_VERSION, at: Date.now(), models }, null, 2));
30825
32103
  } catch (error) {
30826
- log19.warn("models.cache-persist-failed", { error: formatLogError(error, { stack: false }) });
32104
+ log20.warn("models.cache-persist-failed", { error: formatLogError(error, { stack: false }) });
30827
32105
  }
30828
32106
  }
30829
32107
  async function readCodexCliModelCache() {
30830
32108
  try {
30831
- const raw = await readFile7(join22(getCodexHomeDir(), "models_cache.json"), "utf8");
32109
+ const raw = await readFile7(join23(getCodexHomeDir(), "models_cache.json"), "utf8");
30832
32110
  const models = parseModelCatalog(raw);
30833
32111
  return models.length > 0 ? models : null;
30834
32112
  } catch {
@@ -30845,7 +32123,7 @@ async function fetchLiveModelsFromCli(run = execFile4, env = process.env) {
30845
32123
  const models = parseModelCatalog(stdout);
30846
32124
  return models.length > 0 ? models : null;
30847
32125
  } catch (error) {
30848
- log19.warn("models.debug-read-failed", { error: formatLogError(error, { stack: false }) });
32126
+ log20.warn("models.debug-read-failed", { error: formatLogError(error, { stack: false }) });
30849
32127
  return null;
30850
32128
  }
30851
32129
  }
@@ -30890,7 +32168,7 @@ async function sweepIdleThreads(runtime = appServerRuntime) {
30890
32168
  try {
30891
32169
  await runtime.sweepIdle();
30892
32170
  } catch (error) {
30893
- log19.warn("idle-sweep.failed", { error: formatLogError(error) });
32171
+ log20.warn("idle-sweep.failed", { error: formatLogError(error) });
30894
32172
  }
30895
32173
  }
30896
32174
  function createCodexProcessDiagnostics(runtime = appServerRuntime) {
@@ -30926,9 +32204,9 @@ async function startSelectedEngine(env = process.env, runtime = appServerRuntime
30926
32204
  }
30927
32205
  try {
30928
32206
  await runtime.start();
30929
- log19.info("engine.ready", { codexVersion: runtime.getHealth().codexVersion ?? "unknown" });
32207
+ log20.info("engine.ready", { codexVersion: runtime.getHealth().codexVersion ?? "unknown" });
30930
32208
  } catch (error) {
30931
- log19.error("engine.start-failed", { error: formatLogError(error, { stack: false }) });
32209
+ log20.error("engine.start-failed", { error: formatLogError(error, { stack: false }) });
30932
32210
  }
30933
32211
  }
30934
32212
  var __testing = {
@@ -31014,7 +32292,7 @@ function startSseKeepalive(writeSSE, intervalMs = 5000, shouldSendAtActiveCadenc
31014
32292
  id: String(eventRing.latestRevision),
31015
32293
  data: "{}"
31016
32294
  }).catch((error) => {
31017
- log19.warn("sse.keepalive-failed", { error: formatLogError(error, { stack: false }) });
32295
+ log20.warn("sse.keepalive-failed", { error: formatLogError(error, { stack: false }) });
31018
32296
  });
31019
32297
  }, intervalMs);
31020
32298
  }
@@ -31268,7 +32546,7 @@ app.get("/session/:id/usage", async (c) => {
31268
32546
  return c.json({ error: "Session not found" }, 404);
31269
32547
  return c.json({ contextUsage });
31270
32548
  } catch (error) {
31271
- log19.warn("account.usage-read-failed", { error: formatLogError(error, { stack: false }) });
32549
+ log20.warn("account.usage-read-failed", { error: formatLogError(error, { stack: false }) });
31272
32550
  return c.json({ error: "Account usage is temporarily unavailable" }, 503);
31273
32551
  }
31274
32552
  });
@@ -31678,7 +32956,7 @@ app.get("/event/subscribe", (c) => {
31678
32956
  if (!open)
31679
32957
  return;
31680
32958
  open = false;
31681
- log19.info("sse.closed", { reason });
32959
+ log20.info("sse.closed", { reason });
31682
32960
  resolveConnectionClosed();
31683
32961
  };
31684
32962
  const writeWhileOpen = createSerializedSseWriter(createOpenSseWriter(() => open, (event) => stream.writeSSE(event)), { onOverflow: () => failSlowSubscriber("write backlog exceeded its cap") });
@@ -31826,7 +33104,7 @@ if (parentPid !== null) {
31826
33104
  startParentWatchdog({
31827
33105
  parentPid,
31828
33106
  onParentExit: () => {
31829
- log19.warn("parent.gone", { parentPid });
33107
+ log20.warn("parent.gone", { parentPid });
31830
33108
  createParentExitHandler((budgetMs) => appServerRuntime.interruptForParentExit(budgetMs), shutdownHandler)();
31831
33109
  }
31832
33110
  });