orkestrator 2.35.3-beta → 2.35.5-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,2520 @@
1
+ // ../protocol/src/log-vocabulary/define.ts
2
+ var THROTTLE_LOG_EVENTS = {
3
+ "throttle.suppressed": "Repeats of the throttled `site` were counted over a window, not written.",
4
+ "throttle.recovered": "The throttled `site` succeeded again, so its fault has cleared.",
5
+ "throttle.evicted": "The tracked-key limit dropped the `site`, so no recovered line follows unless it fails again."
6
+ };
7
+ function defineLogAreas(areas) {
8
+ return areas;
9
+ }
10
+
11
+ // ../protocol/src/log-vocabulary/agent-mail.ts
12
+ var AGENT_MAIL_LOG_AREAS = defineLogAreas({
13
+ "agent-mail": {
14
+ description: "Delivering agent mail into waiting agent sessions.",
15
+ events: {
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."
26
+ }
27
+ }
28
+ });
29
+
30
+ // ../protocol/src/log-vocabulary/backend.ts
31
+ var BACKEND_LOG_AREAS = defineLogAreas({
32
+ "build.pipeline": {
33
+ description: "Build delivery, ticket reconciliation and persisted pipeline recovery.",
34
+ events: {
35
+ "delivery-policy.failed": "A ticket delivery edit could not be reconciled with the running build.",
36
+ "criteria.failed": "Verify could not record criterion results on the ticket.",
37
+ "transcript-maintenance.failed": "Pipeline transcript maintenance failed.",
38
+ "hydrate.failed": "The renderer could not load the authoritative pipeline snapshot."
39
+ }
40
+ },
41
+ "backend.activity": {
42
+ description: "The backend's recurring activity and maintenance jobs.",
43
+ events: {
44
+ "job.failed": "One pass of the job named in `scope` failed; its next pass retries.",
45
+ ...THROTTLE_LOG_EVENTS
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
+ }
71
+ }
72
+ });
73
+
74
+ // ../protocol/src/log-vocabulary/bridge.ts
75
+ var MAX_BRIDGE_DIAGNOSTIC_BYTES = 8192;
76
+ var BRIDGE_LOG_AREAS = defineLogAreas({
77
+ "bridge.diagnostics": {
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.",
79
+ tag: "bridge-diagnostics",
80
+ maxStringChars: MAX_BRIDGE_DIAGNOSTIC_BYTES,
81
+ events: {
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.",
84
+ "send-started": "A turn or process diagnostic scope began.",
85
+ "send-resolved": "The provider accepted a dispatch.",
86
+ "cancel-requested": "Cancellation of a turn was requested.",
87
+ "cancel-settled": "The provider's cancel call returned or failed.",
88
+ closed: "A diagnostic scope ended, with its final counters.",
89
+ "snapshot-overflow": "A snapshot exceeded the bound, so only its size was written.",
90
+ "debug-events": "A batch of allowlisted debug labels with their counts.",
91
+ "setup-failed": "A Cursor setup step failed and swallowed its error.",
92
+ "sdk-snapshot": "Cursor's SDK transports and executions at a boundary.",
93
+ "sdk-snapshot-overflow": "A Cursor SDK snapshot exceeded the bound, so it was omitted."
94
+ }
95
+ },
96
+ "bridge.lifecycle": {
97
+ description: "What every long-lived bridge does the same way: its sweep and its shutdown.",
98
+ events: {
99
+ "idle-sweep.failed": "An idle sweep threw; the next tick retries.",
100
+ "shutdown.failed": "Releasing the bridge failed during shutdown; it still exits."
101
+ }
102
+ },
103
+ "bridge.acp": {
104
+ description: "The ACP bridge behind Grok: its routes, sessions, saved state and change evidence.",
105
+ events: {
106
+ "command-change.record-failed": "A measured command change could not be recorded.",
107
+ "evidence.record-failed": "Change evidence could not be recorded; the read loop carries on.",
108
+ "evidence.shell-record-failed": "A shell observation could not be recorded.",
109
+ "evidence.turn-record-failed": "Turn change evidence could not be recorded.",
110
+ "server.listening": "The HTTP server is listening.",
111
+ "state.composer-reset": "A saved composer state was malformed and was reset.",
112
+ "state.discarded": "Saved bridge state could not be used and was discarded.",
113
+ "state.persist-failed": "Saving bridge state failed; a later write retries.",
114
+ "state.session-config-reset": "A saved session configuration was malformed and was reset."
115
+ }
116
+ },
117
+ "bridge.claude": {
118
+ description: "The Claude bridge: its routes, sessions, parked interactions and the Agent SDK turn loop.",
119
+ events: {
120
+ "commands.read-failed": "The command catalogue read failed; the cached answer stands.",
121
+ "context-usage.read-failed": "The detailed context usage read failed; the route falls back.",
122
+ "dispatch.rollback-failed": "Rolling back a prompt dispatch claim failed.",
123
+ "event-subscriber.failed": "An event subscriber threw; other subscribers still ran.",
124
+ "http.request-failed": "An HTTP route threw; it answered 500.",
125
+ "mcp.config-ignored": "An MCP server configuration of an unsupported shape was ignored.",
126
+ "mcp.read-failed": "Listing MCP servers failed; the route answered 500.",
127
+ "models.fetch-failed": "Reading the supported models failed; the fallback catalogue is served.",
128
+ "models.requested": "The model catalogue route was called.",
129
+ "models.responded": "The model catalogue route answered.",
130
+ "parent.gone": "The backend that launched this bridge has gone; shutting down.",
131
+ "plan-approval.responding": "Answering a parked plan approval.",
132
+ "plan-approval.response-failed": "The plan approval route failed.",
133
+ "plan-approval.response-received": "The route received a plan approval answer.",
134
+ "plan-approval.result": "A parked plan approval was answered.",
135
+ "plan-approval.wait-failed": "A parked plan approval ended without an answer: cancelled, timed out or closed.",
136
+ "plan-exit.failure-overridden": "ExitPlanMode failed after the user approved; treated as success with a continuation re-prompt.",
137
+ "plan-mode.record-failed": "Plan mode from a status frame could not be recorded.",
138
+ "plan.reprompt-approved-failed": "Re-prompting after an approved plan failed.",
139
+ "plan.reprompt-feedback-failed": "Re-prompting with plan rejection feedback failed.",
140
+ "plugin.path-missing": "A configured plugin was skipped because its path does not exist.",
141
+ "plugin.unsafe-path": "An installed plugin was skipped because its install path is unsafe.",
142
+ "plugins.read-failed": "Listing plugins failed; the route answered 500.",
143
+ "prompt.accepted": "The route accepted a prompt and answered 202.",
144
+ "prompt.failed": "A prompt turn failed; the session reports the error.",
145
+ "prompt.processing-failed": "A prompt accepted by the route failed while processing.",
146
+ "prompt.received": "A prompt reached the bridge; only its length is logged.",
147
+ "prompt.send-failed": "A prompt request failed; the route answered with an error.",
148
+ "query.close-failed": "Stopping the Claude query failed while closing a tab; the close stays pending.",
149
+ "query.failed": "A Claude query ended with an error result.",
150
+ "question.answer-failed": "The answer-question route failed.",
151
+ "question.answering": "Answering a parked question.",
152
+ "question.answers-prepared": "The route prepared a question answer for the session.",
153
+ "question.answers-received": "A parked question received its answers.",
154
+ "question.stale": "An answer arrived for a question no longer pending; the route answered stale.",
155
+ "question.wait-failed": "A parked question ended without an answer: cancelled, timed out or closed.",
156
+ "runtime.ended-under-resumed-turn": "The Claude runtime ended while a resumed root turn was still open.",
157
+ "server.listening": "The HTTP server is listening.",
158
+ "server.starting": "The HTTP server is about to bind.",
159
+ "session.compact-failed": "A requested compaction failed.",
160
+ "session.create-failed": "Creating a session failed; the route answered with an error.",
161
+ "session.created": "A session was created or recovered.",
162
+ "session.delete-failed": "Deleting a session failed.",
163
+ "session.fork-failed": "Forking a session failed.",
164
+ "session.rename-failed": "Renaming a session failed.",
165
+ "session.resolve-failed": "A session could not be found or loaded for a request; action names the request.",
166
+ "session.rewind-failed": "Rewinding session files failed.",
167
+ "session.task-state-hydrate-failed": "Hydrating session task state failed; the route answered with an error.",
168
+ "sessions.reconcile-failed": "Reconciling persisted sessions failed; the sessions already known are listed.",
169
+ "sse.aborted": "The client closed an event stream.",
170
+ "sse.cleanup": "An event stream connection was released.",
171
+ "sse.closed": "An event stream was closed by the bridge; the client reconnects and replays.",
172
+ "sse.handshake-failed": "An event stream failed during its handshake; the client reconnects.",
173
+ "sse.keepalive-failed": "An event stream keepalive failed, usually a client that has gone; the connection closes.",
174
+ "sse.opened": "An event stream connection opened.",
175
+ "sse.subscribe-requested": "A client asked to subscribe to the event stream.",
176
+ "sse.write-failed": "Writing to an event stream failed; the connection closes and the client reconnects.",
177
+ "task.candidate-bound-reached": "An unresolved Bash call was not tracked as a background task: the candidate bound is full.",
178
+ "task.details-persist-failed": "Shell task details could not be saved; the task carries on.",
179
+ "task.settling-bound-reached": "A settling task was not tracked: the settling bound is full.",
180
+ "task.stop-failed": "Stopping a background task failed on a control channel that had closed.",
181
+ "task.stop-route-failed": "The stop-task route failed.",
182
+ "transcript.background-hydrate-failed": "Hydrating a transcript in the background failed; the next read retries.",
183
+ "transcript.hydrate-failed": "Hydrating a transcript before a prompt failed; the prompt runs and a later read retries."
184
+ }
185
+ },
186
+ "bridge.codex": {
187
+ description: "The Codex bridge: its routes, sessions and the app-server child it supervises.",
188
+ events: {
189
+ "account.connector-recovery-failed": "Recovering account connectors failed; the account answer stands.",
190
+ "account.login-reload-failed": "Reloading the stored account login failed.",
191
+ "account.sign-in-check-failed": "An account sign-in check failed; admission is left unchanged.",
192
+ "account.usage-read-failed": "Reading account usage failed; the route answers 503.",
193
+ "app-server.drain-expired": "The drain deadline expired, so app-server restarted with turns still in flight.",
194
+ "app-server.exited": "app-server exited unexpectedly; the code and signal say how.",
195
+ "app-server.invariant-violation": "app-server asked for something its configuration forbids.",
196
+ "app-server.protocol-violation": "app-server wrote a line that is not valid protocol; it was ignored.",
197
+ "app-server.recording": "Notification recording is on; recordings hold content.",
198
+ "app-server.stale-reaped": "A stale app-server left by an earlier bridge was stopped.",
199
+ "app-server.stderr": "Metadata of an app-server stderr line, never its content.",
200
+ "app-server.stderr-suppressed": "app-server stderr lines beyond the budget were counted, not described.",
201
+ "approval.cancel-failed": "Cancelling a turn after an approval answer failed.",
202
+ "approval.present-failed": "Presenting an approval threw; it is auto-declined.",
203
+ "approval.resolved-callback-failed": "An approval resolved callback threw.",
204
+ "command-changes.record-failed": "Recording line changes for a command failed; the turn carries on.",
205
+ "dispatch.reconcile-failed": "A dispatch could not be reconciled against its thread; it stays recovering.",
206
+ "dispatch.restore-failed": "A journaled dispatch could not be restored after a restart; recovery retries.",
207
+ "engine.listener-failed": "An engine event listener threw; the others still ran.",
208
+ "engine.ready": "The app-server engine started.",
209
+ "engine.start-failed": "The app-server engine failed to start; reported through health.",
210
+ "engine.stop-failed": "Stopping the Codex engine failed during shutdown; the bridge exits anyway.",
211
+ "generation.recovery-failed": "Recovering sessions after an app-server generation change failed.",
212
+ "http.request-failed": "An HTTP route threw; it answered 500.",
213
+ "idle-sweep.failed": "An idle sweep failed; the next one retries.",
214
+ "interaction.present-failed": "Presenting an interaction threw; it is cancelled.",
215
+ "interaction.resolved-callback-failed": "An interaction resolved callback threw.",
216
+ "journal.persist-failed": "Saving the dispatch journal failed.",
217
+ "message.publish-failed": "Publishing a message update failed.",
218
+ "models.cache-persist-failed": "Saving the model cache failed.",
219
+ "models.debug-read-failed": "`codex debug models` failed; another source is used.",
220
+ "models.list-failed": "model/list failed; the cached models are served.",
221
+ "models.refresh-failed": "A background model refresh failed; the cache stands.",
222
+ "notification.enqueue-failed": "Queueing a notification threw.",
223
+ "ordered-events.flush-failed": "Flushing before ordered-event reconciliation failed.",
224
+ "ordered-events.publish-failed": "Publishing an ordered event failed; clients are told to rehydrate.",
225
+ "ordered-events.reconcile-failed": "Reconciling ordered events failed.",
226
+ "parent.gone": "The backend that launched this bridge has gone; stopping turns and shutting down.",
227
+ "queue.task-failed": "A task on a per-thread queue failed.",
228
+ "raw-log.write-failed": "Appending to the raw Codex log failed.",
229
+ "recorder.notice": "The notification recorder needs attention: it is on, or was asked for without its confirmation.",
230
+ "recorder.threw": "The notification recorder threw.",
231
+ "recorder.write-failed": "Writing a notification recording failed; its lines were dropped.",
232
+ "registry.persist-failed": "Saving the session registry failed; a later write retries.",
233
+ "rollout.hydrate-failed": "A rollout could not be read to hydrate a thread.",
234
+ "runtime-env.refresh-failed": "Refreshing the runtime environment failed; the last values stay.",
235
+ "runtime-env.refreshed": "Runtime environment variables changed; names only, never values.",
236
+ "server-request.answer-failed": "Answering a server request failed.",
237
+ "server-request.flush-timeout": "An answer to a server request did not flush in time.",
238
+ "server-request.handoff-failed": "Handing a server request to the router threw.",
239
+ "session.config-apply-failed": "Applying session configuration failed; the route answers unavailable.",
240
+ "sse.closed": "An event stream was closed by the bridge; the client reconnects and replays.",
241
+ "sse.keepalive-failed": "An event stream keepalive failed.",
242
+ "sse.observer-failed": "An event stream observer failed; it reconnects.",
243
+ "sse.payload-serialize-failed": "An event payload could not be serialized; a placeholder was sent.",
244
+ "sse.payload-snapshot-failed": "An event payload could not be snapshotted; a placeholder was sent.",
245
+ "sse.subscriber-failed": "An event stream subscriber failed; it reconnects and replays.",
246
+ "subagent.activity-load-failed": "Sub-agent activity could not be loaded; the transcript renders without it.",
247
+ "thread.archive-failed": "Archiving or unarchiving a thread failed.",
248
+ "thread.fork-failed": "thread/fork failed; the route answers 503.",
249
+ "thread.fork-hydrate-failed": "A forked thread could not be hydrated and was closed.",
250
+ "thread.reattach-failed": "A thread could not be re-attached.",
251
+ "thread.rename-failed": "thread/name/set failed; the bridge title index stays authoritative.",
252
+ "thread.turns-read-after-revert-failed": "A thread's turns could not be read after a revert.",
253
+ "thread.turns-read-failed": "A thread's turns could not be read.",
254
+ "thread.unsubscribe-failed": "thread/unsubscribe failed; the binding is kept so a retry can unsubscribe.",
255
+ "threads.list-failed": "thread/list failed; sessions come from the rollout parser.",
256
+ "transcript.serving-last-known": "A thread read failed, so the last known transcript is served.",
257
+ "turn.capacity-retry-failed": "Retrying a turn after a capacity failure failed.",
258
+ "turn.capacity-retry-journal-failed": "A capacity retry could not be journaled.",
259
+ "turn.finalize-failed": "Finalizing a turn failed.",
260
+ "turns.stopped": "Running turns were stopped because the backend went away."
261
+ }
262
+ },
263
+ "bridge.cursor": {
264
+ description: "The Cursor bridge: its routes, sessions and saved state.",
265
+ events: {
266
+ "agent.archive-failed": "Archiving or unarchiving an agent failed.",
267
+ "http.route-failed": "An HTTP route failed unexpectedly; its error is not logged because it can hold content.",
268
+ "startup.closes-failed": "Finishing closes a previous process left behind failed at startup.",
269
+ "startup.closes-incomplete": "Some closes a previous process left behind did not finish at startup; a retried close finishes them.",
270
+ "state.publication-failing": "Saving bridge state is failing; new prompts and steers are refused until it recovers.",
271
+ "state.publication-recovered": "Saving bridge state recovered.",
272
+ "state.transcripts-shortened": "The state file reached its limit, so some sessions were saved with a shortened transcript copy."
273
+ }
274
+ },
275
+ "bridge.pi": {
276
+ description: "The Pi bridge: its routes, sessions and saved state.",
277
+ events: {
278
+ "http.route-failed": "An HTTP route failed unexpectedly; its error is not logged because it can hold content.",
279
+ "state.over-budget": "The state file stayed over budget after shedding transcripts, so the write was skipped.",
280
+ "state.transcripts-shed": "The state file was over budget, so some sessions were saved without their transcript."
281
+ }
282
+ }
283
+ });
284
+
285
+ // ../protocol/src/log-vocabulary/desktop.ts
286
+ var DESKTOP_LOG_AREAS = defineLogAreas({
287
+ desktop: {
288
+ description: "The Electron main process: startup, windows, quit and the Local backend's life.",
289
+ events: {
290
+ "backend.docker-context-seed-failed": "An agent-test profile fell back to the default Docker context.",
291
+ "backend.exited": "The Local backend exited unexpectedly; Local work is unavailable.",
292
+ "backend.exited-recovering": "The Local backend exited just after a remote update; relaunching unattended.",
293
+ "backend.keychain-link-remove-failed": "An agent-test profile kept a legacy link to the host keychain.",
294
+ "backend.start-failed": "The Local backend did not start; continuing with remote machines.",
295
+ "clipboard.write-failed": "Writing text to the system clipboard failed.",
296
+ "instance.already-running": "Another instance holds this data directory; this one will quit.",
297
+ "main-thread.stalled": "A timer fired late, so windows, IPC and the stdout reader waited.",
298
+ "quit.stopping-backend": "The app is quitting and has asked the Local backend to stop.",
299
+ "relaunch.schedule-failed": "The AppImage relaunch waiter failed; using Electron's relauncher.",
300
+ "relaunch.service-register-failed": "The AppImage relaunch service was refused; using a detached waiter.",
301
+ "renderer.gone-giving-up": "A renderer kept dying, so the window is no longer reloaded.",
302
+ "renderer.gone-reloading": "A renderer died and the window is being reloaded.",
303
+ "renderer.reload-failed": "Reloading a window after its renderer died failed.",
304
+ "restart-prompt.failed": "A native restart prompt could not be shown.",
305
+ "saved-machines.attach-failed": "Saved machines were not imported into the command node yet.",
306
+ "saved-machines.attached": "Saved machines were imported into the local command node.",
307
+ "startup.failed": "The application failed to start.",
308
+ "uncaught-exception": "The main process hit an uncaught exception.",
309
+ "uncaught-exception.dialog-failed": "The uncaught exception sheet could not be shown.",
310
+ "window.create-failed": "A menu-driven new window could not be created.",
311
+ "window.recreate-failed": "The main window could not be recreated on activation.",
312
+ "window.second-launch-failed": "A second launch could not open a window."
313
+ }
314
+ },
315
+ "desktop.startup": {
316
+ description: "Renderer startup markers and renderer process failures. These are the only events the renderer can place in the persistent log.",
317
+ tag: "DesktopStartup",
318
+ events: {
319
+ "backend-unavailable": "The renderer could not complete a Local backend read in time.",
320
+ "bridge-unavailable": "The preload API or connection-list IPC did not answer.",
321
+ checking: "The renderer began waiting for the desktop connection.",
322
+ "page-load-failed": "Chromium failed to load the main document.",
323
+ "preload-failed": "Electron rejected the preload script.",
324
+ ready: "The renderer reached the desktop connection and may mount the workspace.",
325
+ "renderer-error": "An uncaught error occurred while the renderer was starting.",
326
+ "renderer-gone": "A renderer process exited.",
327
+ "renderer-load-failed": "Importing or mounting the application failed.",
328
+ "unhandled-rejection": "An unhandled rejection occurred while the renderer was starting."
329
+ }
330
+ },
331
+ "desktop.dialog": {
332
+ description: "Native dialogs, whose modal loops hold the main thread while they are open.",
333
+ events: {
334
+ "attention-failed": "A dialog could not ask for the user's attention.",
335
+ closed: "A native dialog closed.",
336
+ "open-failed": "A dialog could not open; it was answered as cancelled.",
337
+ opening: "A native dialog is opening.",
338
+ "preview-beforeunload-ignored": "A browser preview's beforeunload handler was ignored.",
339
+ "renderer-beforeunload-cancelled": "A renderer's beforeunload handler cancelled an unload."
340
+ }
341
+ },
342
+ "backend.client": {
343
+ description: "The desktop's HTTP and event stream client for a backend.",
344
+ events: {
345
+ "event-stream.disconnected": "The event stream dropped; the client reconnects with backoff.",
346
+ "event-stream.malformed-frame": "An event stream frame could not be parsed and was dropped."
347
+ }
348
+ },
349
+ connections: {
350
+ description: "The desktop's saved machines and active connection.",
351
+ events: {
352
+ "catalogue.legacy-read-failed": "The previous connection list could not be read to migrate.",
353
+ "catalogue.restored-from-backup": "The device catalogue was unreadable; the backup was used.",
354
+ "restore.failed": "The previous remote connection could not be restored; using Local.",
355
+ "secure-storage.waiting": "Startup is waiting on an operating system keychain prompt."
356
+ }
357
+ },
358
+ workspaces: {
359
+ description: "Workspace realms the desktop holds on other machines.",
360
+ events: {
361
+ "route.moved-direct": "A relayed workspace moved to its direct route."
362
+ }
363
+ },
364
+ toolchain: {
365
+ description: "Preparing the pinned agent toolchain at desktop startup.",
366
+ events: {
367
+ "bootstrap-progress.show-failed": "The toolchain progress window could not be shown.",
368
+ "prepare.failed": "Preparing the pinned agent tools failed."
369
+ }
370
+ },
371
+ "artifact-host": {
372
+ description: "Live artifact hosts in the desktop app.",
373
+ events: {
374
+ "host.ended": "A host ended; fields count its blocked and rejected requests by reason."
375
+ }
376
+ }
377
+ });
378
+
379
+ // ../protocol/src/log-vocabulary/environment.ts
380
+ var ENVIRONMENT_LOG_AREAS = defineLogAreas({
381
+ environment: {
382
+ description: "Environment naming, setup, status, moves, deletion and cleanup afterwards.",
383
+ events: {
384
+ "cleanup.branch-kept": "A deleted environment's local branch was kept, as it may hold unmerged work.",
385
+ "rename.failed": "Naming an environment from its pending prompt failed for the first time.",
386
+ "rename.still-failing": "That rename is still failing; written at the 2nd, 4th, 8th... failure.",
387
+ "rename.recovered": "A rename from a pending prompt succeeded after failing.",
388
+ "setup.attention-not-recorded": "Held setup could not be recorded as needing the user's attention.",
389
+ "setup.coordinator-not-notified": "The worker's coordinator could not be told that its setup is held for approval.",
390
+ "setup.unknown-environment": "The renderer was asked to act on the setup of an environment it does not hold.",
391
+ "cleanup.rearmed": "A deleted environment's stopped cleanup is retried once under a new backend version.",
392
+ "cleanup.exhausted": "A deleted environment's cleanup keeps failing after its attempts; written once per environment.",
393
+ "cleanup.retry-not-admitted": "A cleanup retry was not admitted; the entry stays for the next start.",
394
+ "cleanup.step-failed": "One step of a deleted environment's cleanup failed; a later reconcile retries it.",
395
+ "cleanup.record-failed": "A finished cleanup step could not be recorded, so it may run again.",
396
+ "cleanup.sweep-failed": "A cleanup sweep failed; written once per sweep.",
397
+ "cleanup.reconcile-failed": "A cleanup reconcile pass failed; the next one retries.",
398
+ "orphan-state.remove-failed": "An orphaned environment state directory could not be removed.",
399
+ "orphan-state.removed": "Orphaned environment state directories were removed.",
400
+ "orphan-state.sweep-failed": "Sweeping orphaned environment state failed.",
401
+ "orphan-canvas.removed": "Orphaned design canvases were removed.",
402
+ "orphan-canvas.sweep-failed": "Sweeping orphaned design canvases failed.",
403
+ "orphan-branches.swept": "Orphaned environment branches were deleted, or kept as they may hold unmerged work.",
404
+ "stray-workspace.remove-failed": "A stray workspace directory could not be removed.",
405
+ "stray-workspace.removed": "Stray workspace directories were removed.",
406
+ "stray-workspace.kept": "Unowned workspace directories that hold files were kept; remove them by hand if unneeded.",
407
+ "temp-files.removed": "Abandoned temp files were removed.",
408
+ "status.ownership-probe-failed": "A strict container ownership probe failed, so the stored status is kept.",
409
+ "status.docker-error": "A transient Docker error stopped a status read, so the stored status is kept.",
410
+ "setup.clear-launch-failed": "A pending agent launch could not be cleared after setup failed.",
411
+ "setup.record-failure-failed": "A setup failure before its first attempt could not be recorded.",
412
+ "lifecycle.failed": "Starting, rebuilding or recreating an environment failed; `operation` says which.",
413
+ "tab-teardown.pending": "A tab's teardown failed and stays pending; the reconcile sweep retries.",
414
+ "tab-reconcile.skipped": "Orphaned tab reconciliation was skipped because pane layouts are unreadable.",
415
+ "orphan-session.reaped": "A native session no tab references was torn down.",
416
+ "handoff-sweep.failed": "Sweeping transferred transcripts no tab references failed.",
417
+ "delete.terminals-survived": "Terminal process trees outlived termination, so the deletion stops.",
418
+ "delete.artifacts-left": "Graph run artifact directories were not removed.",
419
+ "delete.worktrees-kept": "Graph runs kept branch worktrees.",
420
+ "delete.step-failed": "One best-effort part of deleting an environment failed; `step` says which, and the rest goes on.",
421
+ "merge-cleanup.resume-failed": "A merge cleanup interrupted by a restart could not be resumed.",
422
+ "move.sessions-not-moved": "A provider's sessions could not follow a moved environment.",
423
+ "move.recovery-failed": "Recovering an interrupted environment move failed.",
424
+ "stop.settle-activity-failed": "Agent activity could not be settled after a runtime stopped.",
425
+ ...THROTTLE_LOG_EVENTS
426
+ }
427
+ }
428
+ });
429
+
430
+ // ../protocol/src/log-vocabulary/gateway.ts
431
+ var GATEWAY_LOG_AREAS = defineLogAreas({
432
+ gateway: {
433
+ description: "The gateway other devices, browsers and the desktop connect through.",
434
+ events: {
435
+ "remote.start-failed": "The desktop could not start the remote gateway.",
436
+ "remote.stop-failed": "The desktop could not stop the remote gateway cleanly.",
437
+ disabled: "The gateway is disabled by its environment variable.",
438
+ "tailscale.no-address": "No Tailscale address was found, so the gateway did not start.",
439
+ "tailscale.no-address-fallback": "No Tailscale address was found, so the gateway binds its fallback address.",
440
+ "control.listening": "The backend control listener is up.",
441
+ "browser.listening": "The browser listener is up.",
442
+ "browser.unavailable": "The browser listener could not start; control remains if started, or loopback is attempted.",
443
+ "browser.unavailable-degraded": "No browser listener was started (`reason=no-tailscale-address`); control remains if started, or loopback is attempted.",
444
+ "loopback.listening": "The loopback client listener is up.",
445
+ "loopback.unavailable": "The loopback client listener could not start.",
446
+ "auth-token.stored": "The gateway token's file was written. The path only, never the token.",
447
+ "auth-token.persist-failed": "The gateway token could not be saved.",
448
+ "port.fallback": "The preferred port was taken, so a nearby one is used.",
449
+ "port.fallback-distant": "The preferred port and those nearby were taken, so another is used.",
450
+ "request.failed": "A gateway request failed. Throttled: repeats are counted, not written.",
451
+ "websocket.upgrade-failed": "A WebSocket upgrade failed.",
452
+ "events.client-dropped": "An event-stream client buffered too much and was dropped; it reconnects and refetches.",
453
+ "proxy.client-disconnected": "A proxy client went away, so its upstream request was aborted.",
454
+ "throttle.suppressed": "Repeats of the throttled `site` were counted over a window, not written.",
455
+ "throttle.recovered": "The throttled `site` succeeded again, so its fault has cleared.",
456
+ "throttle.evicted": "The tracked-key limit dropped the `site`, so no recovered line follows unless it fails again."
457
+ }
458
+ },
459
+ "gateway.terminal": {
460
+ description: "The gateway's terminal WebSocket.",
461
+ events: {
462
+ "upgrade-rejected": "A terminal WebSocket upgrade was refused.",
463
+ "socket-error": "A terminal WebSocket reported an error.",
464
+ "subscription-failed": "A terminal subscription failed.",
465
+ "operation-failed": "A terminal operation failed. Fixed text: the operation can hold terminal input."
466
+ }
467
+ },
468
+ "gateway.tailscale": {
469
+ description: "Tailscale Serve for desktop web access and a standalone backend.",
470
+ events: {
471
+ "web-access.disable-failed": "Desktop web access could not be turned off.",
472
+ "web-access.enable-failed": "Desktop web access could not be turned on.",
473
+ "web-access.cleanup-failed": "Cleaning up after a failed enable also failed.",
474
+ "web-access.reset-failed": "Desktop web access could not be reset.",
475
+ "startup.init-failed": "Desktop web access could not be initialized at startup.",
476
+ available: "Tailscale Serve is publishing the gateway."
477
+ }
478
+ }
479
+ });
480
+
481
+ // ../protocol/src/log-vocabulary/local-server.ts
482
+ var LOCAL_SERVER_LOG_AREAS = defineLogAreas({
483
+ "local-server": {
484
+ description: "Agent bridge processes the backend runs on the host.",
485
+ events: {
486
+ "bridge.not-answering": "A bridge with work in progress fails health checks, so it is not restarted yet.",
487
+ "bridge-runtime.installing": "A bridge runtime is being installed.",
488
+ "bridge-runtime.installed": "A bridge runtime finished installing.",
489
+ "opencode.database-lost-retrying": "OpenCode lost its shared database at startup, so it is retried.",
490
+ "server.stopping": "A local server is being stopped, for the fixed `reason` given.",
491
+ "reaper.tmux-list-failed": "Orphaned claude-tmux sessions could not be listed.",
492
+ "reaper.tmux-kill-failed": "An orphaned tmux session could not be killed.",
493
+ "reaper.tmux-reaped": "Orphaned claude-tmux sessions of a deleted environment were killed.",
494
+ "reaper.runtime-root-remove-failed": "A claude-tmux runtime root could not be removed; it stays for a retry.",
495
+ "reaper.server-unidentified": "An orphan candidate could not be identified, so its record is kept.",
496
+ "reaper.server-refused": "An orphan candidate leads no process group, so it was not reaped.",
497
+ "reaper.server-reaping": "An orphaned server is being stopped.",
498
+ "reaper.server-kill-failed": "An orphaned server did not exit.",
499
+ ...THROTTLE_LOG_EVENTS
500
+ }
501
+ }
502
+ });
503
+
504
+ // ../protocol/src/log-vocabulary/git.ts
505
+ var GIT_LOG_AREAS = defineLogAreas({
506
+ git: {
507
+ description: "Git operations the backend runs in environment worktrees and containers.",
508
+ events: {
509
+ "branch.rename-failed": "Renaming an environment's branch failed; the stored name is kept.",
510
+ "branch.push-config-failed": "A branch was renamed but its push settings could not be written; the rename is undone.",
511
+ "branch.rollback-failed": "Undoing a branch rename failed; the stored name follows whichever branch now exists."
512
+ }
513
+ }
514
+ });
515
+
516
+ // ../protocol/src/log-vocabulary/logging.ts
517
+ var LOGGING_LOG_AREAS = defineLogAreas({
518
+ logging: {
519
+ description: "The logger and the on-disk application log themselves.",
520
+ events: {
521
+ "capture.started": "Saving logs to disk began for this process.",
522
+ "capture.stopped": "Saving logs to disk stopped for this process.",
523
+ "config.invalid": "A logging environment variable held a value that was ignored.",
524
+ "entries.dropped": "The log queue was full, so entries were dropped and counted.",
525
+ "policy.changed": "The logging settings changed: saving, retention and levels, with no content.",
526
+ "policy.bridge-predates-route": "A running bridge has no logging settings route; it applies them at its next start.",
527
+ "policy.push-failed": "A running bridge did not take the logging settings after retries; its next start resends them.",
528
+ "prune.failed": "Removing expired log files failed; the next sweep retries.",
529
+ "write.failed": "Appending to the log file failed.",
530
+ "unknown-area": "Code outside the type checker asked for an area that is not listed."
531
+ }
532
+ }
533
+ });
534
+
535
+ // ../protocol/src/log-vocabulary/models.ts
536
+ var MODEL_LOG_AREAS = defineLogAreas({
537
+ models: {
538
+ description: "Agent model catalogues and their persistent caches.",
539
+ events: {
540
+ "cache.write-failed": "A successful catalogue refresh could not update the host cache.",
541
+ "seed.pi-failed": "The host Pi model catalogue could not be seeded; the next launch retries.",
542
+ "bridge.not-ready": "The first-use catalogue bridge did not become ready.",
543
+ "bridge.start-failed": "The first-use catalogue bridge failed to start.",
544
+ "probe.exit-unclean": "A catalogue probe or sign-in server did not exit cleanly.",
545
+ "download.deferred": "A model catalogue could not be downloaded yet."
546
+ }
547
+ }
548
+ });
549
+
550
+ // ../protocol/src/log-vocabulary/native-agent.ts
551
+ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
552
+ "native-agent": {
553
+ description: "Native agent sessions and what the backend reads from their bridges.",
554
+ events: {
555
+ "catalogue.outdated-bridge": "A bridge predates the command catalogue, so its commands stay unavailable.",
556
+ "handoff.summary-read-failed": "Change summaries could not be read for a handoff, so the carrier says they are unmeasured.",
557
+ "handoff.consume-failed": "A delivered handoff could not be marked consumed.",
558
+ "job.pr-refresh-rollback-failed": "Rolling back a pull request refresh for a job failed.",
559
+ "job.resend-queue-failed": "A resend could not be queued for a job.",
560
+ "interaction.requests-dropped": "Interaction requests that could not be mapped were dropped.",
561
+ "interaction.observe-failed": "Observing a session's interactions failed. Error class only.",
562
+ "human-prompt.listener-failed": "A human prompt listener threw; the others still run.",
563
+ "question.attention-record-failed": "Attention for an async question could not be recorded; the transcript stays readable.",
564
+ "activity.reconcile-failed": "Reconciling an environment's activity failed. Error class only.",
565
+ "activity.persist-failed": "An environment's activity could not be saved.",
566
+ "pr-refresh.schedule-failed": "A pull request refresh after completion could not be scheduled.",
567
+ "launch.startup-failed": "A startup launch failed; it retries unless `permanent`.",
568
+ "queue.failing": "A native prompt queue keeps failing. The key and reason only, never the prompt.",
569
+ "provider.retire-failed": "Retiring an obsolete provider failed.",
570
+ "workflow-result.store-unavailable": "The workflow result store is unavailable, so the provider's result is used.",
571
+ "catalogue.refresh-failed": "A provider's command catalogue could not be refreshed.",
572
+ "dispatch.attach-failed": "Attaching an agent before dispatch failed; the prompt request answers authoritatively.",
573
+ "coordinator-context.ack-failed": "Coordinator repository context could not be acknowledged.",
574
+ "naming.prepare-failed": "First-prompt naming could not be prepared; the prompt still goes ahead.",
575
+ "interrupt.persist-failed": "A turn interrupt could not be saved, so automatic publication stays fenced.",
576
+ "resume.close-replaced-failed": "The session a resume replaced could not be closed.",
577
+ "sign-in.check-failed": "A turn could not be checked for a login refusal.",
578
+ "sign-in.resend-failed": "Sending refused prompts after sign-in failed.",
579
+ "sign-in.prompt-resend-failed": "One refused prompt could not be sent again after sign-in. Error class only.",
580
+ "shutdown.checkpoints-skipped": "Shutdown skipped display-tail checkpoints; provider history stays authoritative. Count only.",
581
+ "turn-recovery.failed": "Recovering an incomplete turn failed.",
582
+ "turn-recovery.exhausted": "A turn failed again after automatic recovery and is left for the user.",
583
+ "turn-recovery.retrying": "An incomplete or provider-failed turn is being retried automatically.",
584
+ "usage-limit.resend-failed": "Resending after a usage limit failed. An unknown send stays in the journal.",
585
+ "title.strategy-failed": "A session title strategy failed, so the next is tried. Content-free: the error can quote the prompt.",
586
+ ...THROTTLE_LOG_EVENTS
587
+ }
588
+ },
589
+ "native-agent.goal": {
590
+ description: "The /goal loop: advancing goals and their verifiers.",
591
+ events: {
592
+ "advance.failed": "A goal could not advance; the next sweep retries.",
593
+ "attention.record-failed": "Attention for a goal could not be recorded.",
594
+ "turn-end.settle-failed": "Turn-end work for a goal could not be settled.",
595
+ "verifier.finish-failed": "A verifier failed to finish; the goal stays verifying, so the next sweep runs it again.",
596
+ "verifier.stop-failed": "An earlier verifier could not be stopped.",
597
+ "recover.failed": "Goals could not be recovered at startup."
598
+ }
599
+ },
600
+ "native-agent.opencode": {
601
+ description: "The OpenCode provider: its request monitor, retries and agent tools.",
602
+ events: {
603
+ "retry.abort-failed": "Aborting an automatic retry failed. Error class only.",
604
+ "retry.abort-not-scheduled": "An automatic retry abort could not be scheduled. Error class only.",
605
+ "agent-tools.unavailable": "OpenCode agent tools remain unavailable for a session.",
606
+ "coordinator-servers.unavailable": "OpenCode coordinator research servers are unavailable.",
607
+ "monitor.reconnecting": "The request monitor lost its stream and is reconnecting. Error class only.",
608
+ "worker-limit.reached": "The bounded request workers are full, so the stream restarts and a snapshot reconciles.",
609
+ "request.failed": "Handling a request event failed, so the stream restarts. Error class only."
610
+ }
611
+ }
612
+ });
613
+
614
+ // ../protocol/src/log-vocabulary/preview.ts
615
+ var PREVIEW_LOG_AREAS = defineLogAreas({
616
+ preview: {
617
+ description: "Browser and service previews: transports, partitions and captures.",
618
+ events: {
619
+ "attachment.release-failed": "Releasing a preview attachment failed; its lease expires it.",
620
+ "capture-spool.load-failed": "The pending browser capture spool could not be loaded.",
621
+ "certificate.refresh-failed": "Re-reading the preview certificate failed; the next check retries.",
622
+ "certificate.renewal-refused": "A renewed certificate does not cover the preview hosts, so it was ignored.",
623
+ "connection-cleanup.record-failed": "A forgotten connection's cleanup could not be recorded.",
624
+ "link.open-external-failed": "A preview link could not be opened in the system browser.",
625
+ "node.record-failed": "A node that owns preview partitions could not be recorded.",
626
+ "partition.clear-failed": "A preview partition could not be cleared.",
627
+ "partitions.record-cleared-failed": "Cleared preview partitions could not be recorded.",
628
+ "partitions.record-nodes-failed": "The nodes that own preview partitions could not be saved.",
629
+ "partitions.remove-failed": "Cleared preview partition directories could not be removed.",
630
+ "partitions.retry-forgotten-failed": "Retrying a forgotten preview cleanup failed.",
631
+ "port-hints.persist-failed": "Preview port hints could not be saved.",
632
+ "transport.close-failed": "A preview transport could not be closed.",
633
+ "ca-bundle.read-failed": "The upstream CA bundle could not be read.",
634
+ "publication.start-failed": "Private preview publication did not start.",
635
+ "publication.reconfigure-failed": "Preview publication could not be reconfigured.",
636
+ "publication.listening": "Private preview origins are listening.",
637
+ "certificate.reloaded": "The preview certificate was reloaded.",
638
+ "access.revoked-close-failed": "A revoked preview resource could not be closed. Error class only.",
639
+ "registry.invalid-definition": "An invalid stored preview service definition was ignored.",
640
+ "registry.environment-reconcile-failed": "An environment's preview services could not be reconciled.",
641
+ "registry.resolver-failed": "A preview resolver failed. Error class only.",
642
+ "registry.revocation-listener-failed": "A preview revocation listener threw. Error class only.",
643
+ "registry.change-emit-failed": "A preview change event could not be emitted. Error class only.",
644
+ ...THROTTLE_LOG_EVENTS
645
+ }
646
+ }
647
+ });
648
+
649
+ // ../protocol/src/log-vocabulary/runtime.ts
650
+ var RUNTIME_LOG_AREAS = defineLogAreas({
651
+ "event-loop": {
652
+ description: "This process's event loop. A stall of 10 seconds or more is written at error, so no level hides it.",
653
+ events: {
654
+ stalled: "A timer fired late, so every request in that window waited."
655
+ }
656
+ }
657
+ });
658
+
659
+ // ../protocol/src/log-vocabulary/terminal.ts
660
+ var TERMINAL_LOG_AREAS = defineLogAreas({
661
+ terminal: {
662
+ description: "Terminals. The renderer's lines stay in the browser console; the backend's reach the saved log.",
663
+ events: {
664
+ "input.undelivered": "A keystroke did not reach a shell: `no-session` or `not-delivered`.",
665
+ "orphan.reaped": "A terminal no tab references was closed.",
666
+ "agent-completion.notify-failed": "A terminal agent's completion could not be reported.",
667
+ "activity.record-failed": "Terminal environment activity could not be recorded.",
668
+ "pty.exit-listener-failed": "A terminal exit listener threw; the others still run.",
669
+ "pty.exit-notify-failed": "Notifying a terminal's exit failed.",
670
+ "pty.late-exit-listener-failed": "A listener added after a terminal exited threw.",
671
+ "setup.pty-reused": "A setup terminal reused its existing PTY.",
672
+ "setup.pty-spawning": "A setup terminal is spawning its PTY. The argument count only, never the arguments.",
673
+ "setup.pty-spawned": "A setup terminal's PTY started.",
674
+ "setup.pty-exited": "A setup terminal's PTY exited.",
675
+ "setup.preparing": "Workspace preparation started in the setup terminal.",
676
+ "setup.session-creating": "A setup session is being created.",
677
+ "setup.intro-emitted": "The setup intro was written to the terminal.",
678
+ "setup.completed": "Setup finished.",
679
+ "setup.failed": "Setup failed.",
680
+ "setup.already-complete": "Setup was requested but had already finished.",
681
+ "setup.renderer-ensured": "The renderer asked for setup to be running.",
682
+ "setup.renderer-requested": "The renderer asked for the setup session.",
683
+ "setup.renderer-requested-none": "The renderer asked for a setup session that does not exist.",
684
+ "setup.no-commands": "An environment has no setup commands to run.",
685
+ "setup.already-running": "Setup was requested while it was already running.",
686
+ "setup.held-for-approval": "Setup is held until its commands are approved.",
687
+ "setup.renderer-checked-session": "The renderer asked whether a setup terminal session exists.",
688
+ "setup.renderer-requested-buffer": "The renderer asked for a setup terminal's output buffer. A size only, never its contents.",
689
+ "input.resume-failed": "Asking the backend to resume refused terminal input failed.",
690
+ "input.write-failed": "Writing input to a terminal session threw.",
691
+ "listener.remove-failed": "Removing a terminal output listener threw.",
692
+ "listener.released": "A terminal hook unmounted and dropped its output listener.",
693
+ "session.unmounted": "A terminal hook unmounted; the shell keeps running.",
694
+ "connect.called": "A terminal hook began connecting to a session.",
695
+ "output.reconcile-failed": "Output could not be reconciled against the backend snapshot.",
696
+ "session.stopped-while-disconnected": "A session ended while its event stream was down.",
697
+ "session.disconnect-failed": "Closing or detaching a terminal session failed.",
698
+ "session.resize-failed": "Resizing a terminal session failed, other than for a gone session.",
699
+ "session.id-stored": "A new backend session id was saved for a terminal tab.",
700
+ "session-key.environment-missing": "A local session key was built with no environment id.",
701
+ "clipboard.image-failed": "An image pasted into a terminal could not be saved.",
702
+ "clipboard.copy-failed": "Copying a terminal selection to the clipboard failed.",
703
+ "clipboard.paste-failed": "A paste into a terminal failed; `target` says which path.",
704
+ "clipboard.process-failed": "Reading or storing clipboard data for a paste failed.",
705
+ "clipboard.image-save-failed": "An image from a paste event could not be written to disk.",
706
+ "environment.ready-detected": "A first tab's output showed that the workspace is ready.",
707
+ "shell.ready-detected": "A later tab's output showed that its shell is ready.",
708
+ "setup.scripts-completed": "A setup tab's scripts reported their end by an escape code.",
709
+ "setup.marked-complete": "The user marked a setup tab complete by hand.",
710
+ "setup.awaiting-detection": "A first tab connected and is watching output for readiness.",
711
+ "reconnect.setup-marker-found": "A reconnected tab's buffer already held the setup marker.",
712
+ "reconnect.setup-marker-absent": "A reconnected first tab's buffer lacked the setup marker.",
713
+ "reconnect.completed": "A terminal tab finished reconnecting to its session.",
714
+ "restore.setup-marker-found": "A restored tab's buffer already held the setup marker.",
715
+ "persistent-sessions.load-failed": "Listing an environment's saved sessions failed.",
716
+ "persistent-session.restoring": "A tab began restoring from its saved session.",
717
+ "persistent-session.found": "A tab found its saved session already recorded.",
718
+ "persistent-session.creating": "A tab began recording a saved session for the sidebar.",
719
+ "persistent-session.created": "A saved session for the sidebar was recorded.",
720
+ "persistent-session.create-failed": "Recording a saved session for the sidebar failed.",
721
+ "persistent-session.status-update-failed": "Marking a saved session connected failed.",
722
+ "persistent-session.activity-update-failed": "Updating a saved session's activity failed.",
723
+ "persistent-buffer.loaded": "A saved session's buffer loaded; only its length is logged.",
724
+ "persistent-buffer.load-failed": "A saved session's buffer could not be loaded.",
725
+ "persistent-buffer.save-failed": "Saving a session's buffer during cleanup failed.",
726
+ "buffer.restore-failed": "Writing a saved buffer back into a terminal threw.",
727
+ "buffer.serialize-failed": "Serializing a terminal's buffer during cleanup threw.",
728
+ "command.launching": "A tab began launching its command in a new session.",
729
+ "bootstrap.failed": "A launch request for a new session failed; it may retry.",
730
+ "setup-session.bind-failed": "Looking up or binding the backend setup session failed.",
731
+ "setup-tab.stale-removed": "A setup placeholder tab with no session was removed.",
732
+ "multi-reviews.restore-failed": "Multi-review tabs could not be restored for an environment.",
733
+ "pane-layout.restore-failed": "An environment's saved pane layout could not be read.",
734
+ "pane-layout.history-migrate-failed": "Stripping private browser history fields failed.",
735
+ "pane-layout.snapshot-remove-failed": "Removing an unusable pane layout snapshot failed.",
736
+ "pane-layout.selection-migrate-failed": "Saving a migrated legacy pane selection failed.",
737
+ "panes.reset": "An environment's panes were reset: its container changed or stopped.",
738
+ "tabs.limit-reached": "A new tab was refused because the tab limit was reached.",
739
+ "tab.created": "A new tab was added to a pane; `tabType` says which kind.",
740
+ "tab.activated": "Opening a file selected the tab that already held it.",
741
+ "tab.duplicate-refused": "A new tab was refused because its requested id is in use.",
742
+ "tab.multi-review-refused": "A multi-review tab was refused for lack of a workflow id.",
743
+ "tab.split-at-edge": "A dragged tab split a pane at one of its edges.",
744
+ "tab.reordered": "A dragged tab moved within its pane.",
745
+ "tab.moved": "A dragged tab moved to another pane.",
746
+ "drag.ended": "A tab drag ended, whether or not it landed on a target.",
747
+ "display.state": "The terminal container's overlays and tab count, on each dev render.",
748
+ "compose.draft-restore-failed": "A saved compose draft could not be read.",
749
+ "compose.draft-persist-failed": "A compose draft could not be saved or discarded.",
750
+ "compose.image-too-large": "A pasted image stayed over the attachment limit after resizing.",
751
+ "compose.image-add-failed": "Adding a pasted image to the compose bar failed.",
752
+ "compose.image-save-failed": "Saving one compose image for sending failed; the rest proceed.",
753
+ "compose.send-failed": "Sending from the compose bar failed.",
754
+ "init-logs.load-failed": "A container's initialization logs could not be loaded.",
755
+ "init-logs.refresh-stopped": "A container's initialization logs stopped refreshing.",
756
+ "portal.terminal-created": "The portal host created a terminal for a new tab.",
757
+ "portal.terminal-disposed": "The portal host disposed a terminal for a removed tab.",
758
+ "link.open-failed": "Opening a terminal link in the external browser failed.",
759
+ "canvas.context-unavailable": "A resize canvas had no 2D context; the original is kept.",
760
+ ...THROTTLE_LOG_EVENTS
761
+ }
762
+ },
763
+ "terminal.setup": {
764
+ description: "The renderer attaching a backend-managed environment setup terminal.",
765
+ events: {
766
+ "session.bind-from-environment": "The environment hook bound a setup session to a tab.",
767
+ "setup.started-received": "An environment-setup-started event arrived.",
768
+ "setup.complete-received": "An environment-setup-complete event arrived.",
769
+ "attach.state-changed": "A setup tab's attach inputs changed; runs per effect pass.",
770
+ "terminal.preserve-failed": "Keeping a setup terminal's buffer before conversion failed.",
771
+ "tab.marker-retired": "A setup tab with no live PTY stopped being a setup tab.",
772
+ "tab.added": "The backend-managed setup tab was added to a new layout.",
773
+ "session.bind-skipped": "A setup session lookup was already running for this tab.",
774
+ "session.requested": "A tab asked the backend for its setup session.",
775
+ "session.unavailable": "The backend had no setup session to give a tab.",
776
+ "session.bind-started": "A backend setup session was found and is being bound to a tab.",
777
+ "session.awaited": "The layout is waiting for a setup session before adding the tab.",
778
+ "reconcile.started": "The reconcile effect found setup tabs that still need a session.",
779
+ "reconnect-listener.install-failed": "Listening for event stream reconnects failed.",
780
+ "layout.initial-decided": "An empty layout was evaluated for its setup tab; runs per effect."
781
+ }
782
+ }
783
+ });
784
+
785
+ // ../protocol/src/log-vocabulary/tmux.ts
786
+ var TMUX_LOG_AREAS = defineLogAreas({
787
+ tmux: {
788
+ description: "Claude tmux tabs: launch, the poll loop, cleanup and the tmux prompt queue.",
789
+ events: {
790
+ "poll.discovery-failed": "Finding the session's transcript failed; a later tick retries.",
791
+ "poll.snapshot-failed": "Reading the hook and transcript state failed; the next tick retries.",
792
+ "poll.drain-pending-failed": "Delivering pending hook events failed; the next tick retries.",
793
+ "poll.drain-timeouts-failed": "Delivering hook timeouts failed; the next tick retries.",
794
+ "poll.tail-failed": "Reading new transcript lines failed; the next tick retries.",
795
+ "cleanup.session-stop-failed": "A tmux session could not be stopped while cleaning up an environment.",
796
+ "cleanup.skipped": "Environment tmux cleanup was skipped because tmux could not be reached and nothing required it.",
797
+ "cleanup.environments-load-failed": "Environments could not be loaded during tmux cleanup, so it stays incomplete.",
798
+ "cleanup.kill-failed": "An environment's tmux sessions could not be killed.",
799
+ "hooks.uninstall-failed": "Workspace hooks could not be uninstalled.",
800
+ "hooks.git-exclude-failed": "The git exclude for Claude's local settings could not be set.",
801
+ "naming.prepare-failed": "First-prompt naming could not be prepared; the prompt still goes ahead.",
802
+ "orphans.skipped": "Orphan reconciliation was skipped because pane layouts are unreadable.",
803
+ "orphan.reaped": "A tmux session no tab references was killed.",
804
+ "orphan.kill-skipped": "An orphan tmux kill was skipped because the tmux server could not be reached.",
805
+ "cli.thinking-display-probe-failed": "Probing the CLI for --thinking-display failed, so it launches without it.",
806
+ "cli.fast-mode-unsupported": "The claude CLI lacks --settings, so it launches without fast mode.",
807
+ "cli.effort-unsupported": "The claude CLI lacks --effort, so it launches without it.",
808
+ "interactive.snapshot-failed": "An interactive snapshot failed; expected while a pane is closing.",
809
+ "signal.arm-failed": "The Claude state signal could not be armed.",
810
+ "signal.degraded": "The Claude state signal missed a change or rang too often, so polling stays at one second until it is re-armed.",
811
+ "pr-refresh.schedule-failed": "A pull request refresh after a turn could not be scheduled.",
812
+ "pr-probe.failed": "Probing for a pull request an agent created failed.",
813
+ "activity.persist-failed": "Tmux tab activity could not be saved.",
814
+ "fast-mode.persist-failed": "The launch fast mode could not be saved.",
815
+ "fast-mode.repair-failed": "Fast mode metadata could not be repaired on a reattached session.",
816
+ "pane.observe-failed": "A pane observation failed. Error class only: pane contents are sensitive.",
817
+ "turn.failure-record-failed": "A failed turn could not be recorded.",
818
+ "slash-command.settle-timeout": "Timed out waiting for a Claude slash command to settle.",
819
+ "queue.failing": "A tmux prompt queue keeps failing to dispatch.",
820
+ "queue.rename-failed": "An environment could not be named from its first prompt; the prompt still goes ahead.",
821
+ ...THROTTLE_LOG_EVENTS
822
+ }
823
+ }
824
+ });
825
+
826
+ // ../protocol/src/log-vocabulary/updater.ts
827
+ var UPDATER_LOG_AREAS = defineLogAreas({
828
+ updater: {
829
+ description: "Desktop self-update: electron-updater and updates a remote client requested.",
830
+ events: {
831
+ "channel.following": "Update checks now follow a different release channel.",
832
+ "check-report.failed": "A check's result could not be reported.",
833
+ "check.failed": "An update check failed; the next periodic check retries.",
834
+ "download.failed": "Downloading or staging an update failed.",
835
+ downloaded: "An update finished downloading.",
836
+ "library.message": "One line from electron-updater at its own level. Its debug output, which includes the differential download plan, is off by default.",
837
+ "remote.check-failed": "A check a remote client requested failed.",
838
+ "remote.installing": "Installing an update for a remote client.",
839
+ "remote.read-failed": "Update requests could not be read from the Local backend.",
840
+ "remote.relaunch-prepare-failed": "Preparing the relaunch after a remote update failed.",
841
+ "remote.relaunched": "The app relaunched to finish a remote client's update.",
842
+ "remote.report-failed": "An update report could not reach the Local backend.",
843
+ "remote.restart-not-recorded": "The backend did not record a restart, so it was not installed.",
844
+ "remote.unavailable": "Updates requested by remote clients are unavailable in this session.",
845
+ "restart-prompt.failed": "The restart prompt for a downloaded update failed.",
846
+ unavailable: "Auto-update could not be set up in this session.",
847
+ "update.failed": "electron-updater reported an update error.",
848
+ "standalone.restarting": "A standalone backend is restarting into a new version."
849
+ }
850
+ }
851
+ });
852
+
853
+ // ../protocol/src/log-vocabulary/web-annotations.ts
854
+ var WEB_ANNOTATIONS_LOG_AREAS = defineLogAreas({
855
+ "web-annotations": {
856
+ description: "Web annotation requests and their background reconciler.",
857
+ events: {
858
+ "reconcile.failed": "A background reconcile pass failed; the next one retries.",
859
+ "legacy.degraded": "Legacy annotation storage is damaged, so the previous committed copy is served read-only.",
860
+ "legacy.draft-index-problem": "The legacy draft index could not be used; `status` says why.",
861
+ "legacy.unreadable-records": "The legacy import found unreadable records; they stay unread.",
862
+ "legacy.unavailable": "Legacy annotation storage could not be read.",
863
+ "legacy.unreadable": "An environment's legacy annotation storage is unreadable.",
864
+ "legacy.archive-failed": "Imported legacy annotation files could not be archived.",
865
+ "legacy.files-archived": "Legacy files beside an imported environment were archived, not imported.",
866
+ "migration.draft-failed": "Migrating one draft failed.",
867
+ "draft-reconcile.deferred": "Draft reconciliation was deferred; a later pass retries.",
868
+ "request.handoff-deferred": "A request's handoff was deferred; a later pass retries.",
869
+ "evidence.materialize-failed": "Materializing a request's evidence failed; it backs off and retries.",
870
+ "queue.publish-deferred": "Publishing a request to the queue was deferred; it retries under the same id.",
871
+ "request.reconcile-failed": "Reconciling a request failed; the next pass retries.",
872
+ "turn-end.reconcile-failed": "Reconciling a request at the end of a turn failed; the next pass retries.",
873
+ "gc.failed": "Annotation garbage collection failed; the next pass retries.",
874
+ "record.unavailable": "An annotation record is unavailable; written once per record.",
875
+ "storage.unavailable": "An environment's annotation store is unreadable.",
876
+ "change-hint.listener-failed": "A change hint listener threw.",
877
+ "orphan.remove-failed": "An orphaned environment's annotation storage could not be removed.",
878
+ "storage.load-failed": "An environment's annotation storage could not be loaded.",
879
+ ...THROTTLE_LOG_EVENTS
880
+ }
881
+ }
882
+ });
883
+
884
+ // ../protocol/src/log-vocabulary/storage.ts
885
+ var STORAGE_LOG_AREAS = defineLogAreas({
886
+ storage: {
887
+ description: "The SQLite-backed stores, their snapshots and imports from older formats.",
888
+ events: {
889
+ "usage.environment-label-failed": "Usage labels could not be retained for a removed environment; deletion continues.",
890
+ "snapshot.integrity-failed": "An hourly database snapshot failed its integrity check and was discarded.",
891
+ "snapshot.skipped-low-disk": "The hourly database snapshot was skipped because the disk lacks room; `retryAt` says when it tries again.",
892
+ "snapshot.failed": "The hourly database snapshot failed; `retryAt` says when it tries again, if known.",
893
+ "listener.attention-failed": "An environment attention listener threw; the committed mutation stands.",
894
+ "listener.change-failed": "A resource change listener threw; the committed mutation stands.",
895
+ "kanban.image-cleanup-failed": "An orphaned Kanban image could not be removed after its retries; it is safe to remove later.",
896
+ "nodes.entries-dropped": "Unreadable node registry entries were ignored.",
897
+ "preview-identity.reminted": "The data directory moved or was copied, so previews get a new backend identity.",
898
+ "machine-profile.invalid": "The stored machine profile was invalid and the default was restored.",
899
+ "permission-rules.cleanup-failed": "A deleted project's permission rules could not be removed.",
900
+ "retired.turn-cleanup-pending": "Cleanup of a retired Looped Review turn did not finish and stays pending.",
901
+ "handoffs.prune-failed": "Pruning agent handoffs that nothing references failed; a later prune retries.",
902
+ "desktop-connections.malformed": "Stored desktop connection settings were malformed, so the local connection is used.",
903
+ "legacy-json.moved": "JSON store files written after the SQLite migration were archived, not imported.",
904
+ "legacy-json.archive-failed": "Imported JSON store files could not be archived."
905
+ }
906
+ }
907
+ });
908
+
909
+ // ../protocol/src/log-vocabulary/build-pipeline.ts
910
+ var BUILD_PIPELINE_LOG_AREAS = defineLogAreas({
911
+ "build-pipeline": {
912
+ description: "Build pipelines: their supervision, stages, transcripts and sidebar state.",
913
+ events: {
914
+ "sidebar.reconcile-failed": "Sidebar activity for pipelines could not be reconciled.",
915
+ "sidebar.update-failed": "The sidebar could not be updated for one pipeline.",
916
+ "result.consume-deferred": "Consuming a stage's workflow result failed; it stays staged and is retried.",
917
+ "consolidation.consume-deferred": "Consuming a review consolidation result failed; it stays pending and is retried.",
918
+ "dispatch.prepare-failed": "Attaching the agent before dispatch failed; the prompt request does the same work and answers authoritatively.",
919
+ "interaction.resolved": "A human interaction on a pipeline stage resolved. Metadata only.",
920
+ "transcripts.migrated": "A transcript migration pass moved stage transcripts; counts only.",
921
+ "transcripts.maintenance-failed": "Migrating or sweeping stage transcripts failed; the next start retries.",
922
+ "restore.skipped": "A pipeline could not be restored at startup and was skipped.",
923
+ "criteria.record-failed": "Acceptance criteria results could not be recorded on the ticket.",
924
+ "workspace.waiting": "A pipeline is waiting for its workspace; written once per reason.",
925
+ "rewind.pending": "A pipeline's code rewind has not finished; written once per reason.",
926
+ "kanban.status-failed": "A restarted pipeline's Kanban status could not be set; it retries shortly.",
927
+ "usage.read-failed": "Reading a stage session's token usage failed.",
928
+ "checkpoint.deferred": "A stage transcript checkpoint could not be written yet; the provider's history stands.",
929
+ "checkpoint.not-committed": "A stage transcript checkpoint was reverted in the commit that should have kept it.",
930
+ "legacy-transcript.deferred": "Moving a legacy inline transcript failed; the inline body stays readable."
931
+ }
932
+ }
933
+ });
934
+
935
+ // ../protocol/src/log-vocabulary/agent-branch.ts
936
+ var AGENT_BRANCH_LOG_AREAS = defineLogAreas({
937
+ "agent-branch": {
938
+ description: "Agent branches shared by review fan-outs, graph agents and goal verifiers; `owner` names which.",
939
+ events: {
940
+ "observation.checkpoint-failed": "Checkpointing reviewer observations failed; the next pass retries.",
941
+ "transcript.mirror-failed": "Mirroring a reviewer transcript failed.",
942
+ "usage.read-failed": "Reading a reviewer's token usage failed.",
943
+ "result.nudge-failed": "An agent with an uncommitted result could not be nudged.",
944
+ "dispatch.prepare-failed": "Attaching the agent before dispatch failed; the prompt request answers authoritatively.",
945
+ "result.consume-deferred": "Consuming a branch's workflow result failed; it stays staged and is retried."
946
+ }
947
+ }
948
+ });
949
+
950
+ // ../protocol/src/log-vocabulary/change-tracking.ts
951
+ var CHANGE_TRACKING_LOG_AREAS = defineLogAreas({
952
+ "change-tracking": {
953
+ description: "Change tracking: turn capture, evidence pulls and measurements.",
954
+ events: {
955
+ "journal-import.failed": "Importing surviving OpenCode command journals as legacy summaries failed.",
956
+ "projection.failed": "Projecting a change event onto its environment failed.",
957
+ "startup.reconcile-failed": "Reconciling change tracking at startup failed.",
958
+ "turn-start.capture-failed": "Capturing a turn's start failed, so the turn is untracked.",
959
+ "dispatch.record-failed": "Recording a turn's dispatch outcome failed.",
960
+ "turn.finalize-failed": "Finalizing a turn failed.",
961
+ "turn.settle-failed": "Settling a late interrupted turn failed.",
962
+ "evidence.pull-failed": "Pulling change evidence from a bridge failed; a later pull retries.",
963
+ "measurement.failed": "Recomputing a tool's measurement failed."
964
+ }
965
+ },
966
+ "diff-stats": {
967
+ description: "Environment diff stats and the worktree signals that drive them.",
968
+ events: {
969
+ "baseline.update-failed": "An environment's diff baseline could not be updated.",
970
+ "scan.watcher-failed": "An environment's diff watcher failed; its scans fall back to polling.",
971
+ "scan.failed": "A diff scan failed; the last results stay, marked stale, and the scan is retried.",
972
+ "scan.freshness-read-failed": "Reading whether an environment's remote is fresh failed.",
973
+ "scan.listener-failed": "A change-tracking scan listener threw; the scan itself stands.",
974
+ "emit.diff-stats-failed": "A diff stats change could not be emitted to its sink.",
975
+ "emit.worktree-snapshot-failed": "A worktree snapshot could not be emitted to its sink.",
976
+ "signal.demoted": "A worktree signal stopped being trusted, so scans fall back to timers until it is re-armed."
977
+ }
978
+ }
979
+ });
980
+
981
+ // ../protocol/src/log-vocabulary/coordinator.ts
982
+ var COORDINATOR_LOG_AREAS = defineLogAreas({
983
+ coordinator: {
984
+ description: "Coordinators: delegations, status wakes and their store.",
985
+ events: {
986
+ "delegation.open-failed": "A delegation could not be opened; `source` says for what.",
987
+ "deliver-now.drain-failed": "The mail delivery pass after deliverNow failed; the next sweep delivers.",
988
+ "mail.move-failed": "Mail could not move to the new main coordinator.",
989
+ "work.move-failed": "Work could not move to the main coordinator.",
990
+ "wake.observe-remote-workflow-failed": "A remote workflow could not be observed for status wakes.",
991
+ "wake.observe-pull-request-failed": "A pull request could not be observed for status wakes.",
992
+ "wake.observe-workflow-failed": "A workflow could not be observed for status wakes.",
993
+ "wake.deliver-failed": "A workflow status wake could not be delivered; the next pass retries.",
994
+ "wake.waiting-check-failed": "A waiting worker could not be checked; the next pass retries.",
995
+ "wake.resolve-report-failed": "A finished Resolve tab could not be reported.",
996
+ "wake.waiting-report-failed": "A waiting worker could not be reported.",
997
+ "wake.worker-outcomes-failed": "Coordinator-owned workers' merges and deletions could not be checked; the next sweep retries.",
998
+ "store.malformed": "The coordinator store was malformed and is treated as empty.",
999
+ "store.unsupported-version": "The coordinator store has an unsupported version and is treated as empty.",
1000
+ "store.invalid-workspace": "An invalid coordinator workspace record was ignored.",
1001
+ "store.workflows-cleared": "The workflow store was full, so a batch of its oldest finished records was removed.",
1002
+ "store.workflows-in-use": "The workflow store was full and every record was still in use, so new work was refused.",
1003
+ "remote-worker.settle-failed": "A remote worker could not be settled."
1004
+ }
1005
+ }
1006
+ });
1007
+
1008
+ // ../protocol/src/log-vocabulary/review.ts
1009
+ var REVIEW_LOG_AREAS = defineLogAreas({
1010
+ review: {
1011
+ description: "Multi Review workflows: scheduling, graph runs and interactive fix sessions.",
1012
+ events: {
1013
+ "fix-tab.publish-failed": "A fix request was delivered but its tab could not be opened; the user is told.",
1014
+ "graph-run.not-started": "A workflow's graph run did not start.",
1015
+ "reconcile.scan-failed": "A reconciliation scan failed; the next scan retries.",
1016
+ "graph-engine.unavailable": "The graph engine is selected but unavailable, so the bespoke engine runs.",
1017
+ "graph-run.cancel-failed": "Cancelling a graph run failed; the next pass projects how it ended.",
1018
+ "delete.cleanup-failed": "A cleanup step after deleting a workflow failed; stale tabs reconcile away on hydration.",
1019
+ "fix-session.read-failed": "Reading an interactive fix session's state failed.",
1020
+ "fix-outcome.read-failed": "Reading an interactive fix's outcome failed; it stays pending.",
1021
+ "fix-usage.read-failed": "Reading a fix session's token usage failed.",
1022
+ "result.consume-deferred": "Consuming a workflow result failed; it stays staged and is retried.",
1023
+ "failure-triage.failed": "Classifying a review package's failing tests failed; the package is sealed without the triage and says so."
1024
+ }
1025
+ },
1026
+ "pull-request": {
1027
+ description: "Pull request monitoring, auto-merge and the `gh` reads behind them.",
1028
+ events: {
1029
+ "merged-state.persist-failed": "A merged pull request's state could not be saved; GitHub stays authoritative and cleanup goes on.",
1030
+ "refresh.failed": "A pull request could not be refreshed; the armed flag stands.",
1031
+ "arm.track-failed": "An armed environment could not be tracked; the monitor's next sync retries.",
1032
+ "gh.pr-list-unparseable": "`gh pr list` returned nothing that parses. Sizes only, never the output.",
1033
+ "monitor.start-failed": "Monitoring could not start for a newly opened pull request.",
1034
+ "cleanup-scheduler.missing": "A merged pull request was seen, but this runtime has no merge cleanup scheduler.",
1035
+ "auto-merge.evaluation-failed": "Evaluating an environment for auto-merge failed.",
1036
+ "auto-merge.merge-failed": "Auto-merge could not merge a pull request; the attempt is held and retried.",
1037
+ "auto-merge.resolve-failed": "Auto-merge could not launch Resolve for a pull request; the attempt is held and retried.",
1038
+ "monitor.detection-failed": "Checking an environment for its pull request failed.",
1039
+ "monitor.detection-admission-failed": "A pull request check could not be admitted to the work pool.",
1040
+ "monitor.terminal-repair-failed": "Repairing a merged or closed pull request's side effects failed.",
1041
+ "monitor.terminal-resume-failed": "Resuming a merged or closed pull request's side effects failed.",
1042
+ "monitor.stale-reading-ignored": "A non-merged reading (`state`) for a pull request already merged was ignored as stale.",
1043
+ "monitor.state-persist-failed": "A pull request's observed state could not be saved.",
1044
+ "monitor.state-clear-failed": "A pull request's saved state could not be cleared.",
1045
+ "monitor.task-reconcile-failed": "Updating the Kanban task of a merged or closed (`state`) pull request failed.",
1046
+ "monitor.task-store-failed": "A pull request could not be recorded on its Kanban task.",
1047
+ "monitor.emit-failed": "A pull request monitor event could not be emitted to its sink."
1048
+ }
1049
+ }
1050
+ });
1051
+
1052
+ // ../protocol/src/log-vocabulary/public-api.ts
1053
+ var PUBLIC_API_LOG_AREAS = defineLogAreas({
1054
+ "public-api": {
1055
+ description: "The public CLI's operations: their outcomes, reconciliation and exec workers.",
1056
+ events: {
1057
+ "outcome.record-failed": "A background operation's outcome could not be recorded; reconciliation settles it.",
1058
+ "goal-checks.stop-failed": "Goal checks could not be stopped.",
1059
+ "exec.list-failed": "Exec workers could not be listed.",
1060
+ "exec.cancel-failed": "An exec could not be cancelled.",
1061
+ "goal-workers.list-failed": "Goal check workers could not be listed.",
1062
+ "operation.reconcile-failed": "Reconciling one operation failed; the next pass retries.",
1063
+ "reconcile.pass-failed": "A reconciliation pass failed; the next one retries."
1064
+ }
1065
+ }
1066
+ });
1067
+
1068
+ // ../protocol/src/log-vocabulary/agent-accounts.ts
1069
+ var AGENT_ACCOUNTS_LOG_AREAS = defineLogAreas({
1070
+ "agent-accounts": {
1071
+ description: "Agent accounts: automatic switching, staged logins and plan usage.",
1072
+ events: {
1073
+ "switch-notice.failed": "A notice about an automatic account switch failed; the switch stands. `audience` says whose.",
1074
+ "auto-switch.check-failed": "An automatic account check failed; the next nudge retries.",
1075
+ "container-sync.failed": "Handing a login or account to a container failed; `step` says which part.",
1076
+ "last-usage.save-failed": "The last plan usage reading could not be saved; the next save retries.",
1077
+ "login-cleanup.failed": "A temporary login could not be cleaned up.",
1078
+ "login-refresh.deferred": "Containers were not told to refresh their login now; they reconcile from its durable generation."
1079
+ }
1080
+ }
1081
+ });
1082
+
1083
+ // ../protocol/src/log-vocabulary/docker.ts
1084
+ var DOCKER_LOG_AREAS = defineLogAreas({
1085
+ docker: {
1086
+ description: "Docker containers: lifecycle, starts, staged inputs and the login files they hold.",
1087
+ events: {
1088
+ "portable-inputs.relay-missing": "Docker is rootless and the image predates the staged-input relay, so the container cannot read them until rebuilt.",
1089
+ "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.",
1090
+ "opencode.warm-incomplete": "OpenCode did not finish loading /workspace in a container.",
1091
+ "login-keeper.pass-failed": "A Claude login keeper pass failed; the next interval retries.",
1092
+ "login-keeper.refresh-failed": "Refreshing the host Claude login failed. Fixed text: CLI output can hold credentials.",
1093
+ "login-keeper.refresh-not-extended": "Refreshing the host Claude login did not extend its expiry.",
1094
+ "login-keeper.refresh-check-failed": "Checking the host Claude login after a refresh failed.",
1095
+ "login-watcher.pass-failed": "A container login file watcher pass failed; the next one retries.",
1096
+ "lifecycle.record-failure-failed": "A failed container operation could not be recorded.",
1097
+ "lifecycle.reconcile-failed": "Reconciling one environment's container operation failed; the next pass retries.",
1098
+ "replacement.clear-terminals-failed": "Terminal sessions could not be cleared after a container replacement.",
1099
+ "recovery.clear-terminals-failed": "Terminal sessions could not be cleared after a recovery restore.",
1100
+ "github-ranges.seed-not-copied": "The GitHub ranges seed could not be copied into a container, so its firewall fetches them.",
1101
+ "availability.probe-failed": "Docker is not available; written when the diagnostic changes. Fixed-shape metadata only: messages can hold daemon endpoints.",
1102
+ "start.port-collision-retrying": "An automatic host port collided on start, so it is retried once with fresh ports."
1103
+ }
1104
+ },
1105
+ "docker.reachability": {
1106
+ description: "Whether agents in containers can reach the backend's agent tools server.",
1107
+ events: {
1108
+ "check.crashed": "A reachability check crashed.",
1109
+ "check.started": "A reachability check started.",
1110
+ "check.finished": "A reachability check finished.",
1111
+ "check.probe": "One probe of a finished check.",
1112
+ "check.summary": "Content-free status and reason for a check that did not find the host reachable.",
1113
+ "check.remediation": "One command the user can run to unblock containers.",
1114
+ "shutdown.awaiting-network": "Shutdown is waiting for probe network preparation.",
1115
+ "shutdown.cleanup-deferred": "Probe network cleanup waits until its preparation settles.",
1116
+ "shutdown.removing-resources": "Shutdown is removing probe resources.",
1117
+ "shutdown.container-remove-failed": "A probe container could not be removed at shutdown.",
1118
+ "shutdown.network-remove-failed": "The probe network could not be removed at shutdown.",
1119
+ "probe.skipped": "A container probe was skipped because the agent tools server is not listening.",
1120
+ "preflight.refused": "A stage was refused because its container cannot reach the host.",
1121
+ "probe.prepare-failed": "A container could not be prepared for a probe.",
1122
+ "probe.result": "The outcome of probing one container.",
1123
+ "probe.contradicts-host": "A container probe disagrees with the host status, so the host is rechecked.",
1124
+ "topology.detected": "The Docker topology was read.",
1125
+ "firewall.detected": "The host firewall was read.",
1126
+ "probe-network.remove-failed": "The probe network could not be removed.",
1127
+ "probe-network.create-failed": "The probe network could not be created, so only the default bridge is checked.",
1128
+ "event.emit-failed": "A reachability event could not be emitted.",
1129
+ "host-addresses.list-failed": "Host addresses could not be listed.",
1130
+ "probe-image.present": "The probe image is already present.",
1131
+ "probe-image.pulling": "The probe image is being pulled.",
1132
+ "probe-image.pulled": "The probe image was pulled.",
1133
+ "probe-image.pull-failed": "The probe image could not be pulled.",
1134
+ "probe-image.fallback": "The environment image is used as the probe image.",
1135
+ "probe-image.missing": "No probe image is available.",
1136
+ "network.list-failed": "Docker networks could not be listed.",
1137
+ "network.inspect-failed": "A Docker network could not be inspected.",
1138
+ "stale-containers.removing": "Stale probe containers are being removed.",
1139
+ "stale-networks.removing": "Stale probe networks are being removed."
1140
+ }
1141
+ }
1142
+ });
1143
+
1144
+ // ../protocol/src/log-vocabulary/mcp.ts
1145
+ var MCP_LOG_AREAS = defineLogAreas({
1146
+ "control-mcp": {
1147
+ description: "The Control MCP server other agents and devices reach Orkestrator through.",
1148
+ events: {
1149
+ "listener.port-free": "The Control MCP's fixed port is free again, so it is listening.",
1150
+ "state-listener.failed": "A Control MCP state listener threw; the others still run.",
1151
+ "delegation.remote-open-failed": "A delegation could not be opened on another node.",
1152
+ "delegation.open-failed": "A coordinator delegation could not be opened."
1153
+ }
1154
+ },
1155
+ "mcp-management": {
1156
+ description: "Managed MCP configuration: its commands, overlays and apply loop.",
1157
+ events: {
1158
+ "command.failed": "An MCP management command failed; `ref` is the correlation id shown to the user.",
1159
+ "overlay.materialise-failed": "An MCP overlay could not be written.",
1160
+ "apply.tick-failed": "An MCP apply tick failed; the next one retries."
1161
+ }
1162
+ }
1163
+ });
1164
+
1165
+ // ../protocol/src/log-vocabulary/design.ts
1166
+ var DESIGN_LOG_AREAS = defineLogAreas({
1167
+ design: {
1168
+ description: "The design canvas: its library, renderer and session links.",
1169
+ events: {
1170
+ "change-signal.failed": "A design change signal failed.",
1171
+ "library.index-write-failed": "The design library index could not be written.",
1172
+ "library.refresh-failed": "The design library could not be refreshed.",
1173
+ "renderer.problem": "The renderer hit a limit or lost a browser; `problem` is a fixed name.",
1174
+ "task.failed": "A design background task failed.",
1175
+ "canvas.needs-recovery": "A design canvas is unreadable and marked for recovery.",
1176
+ "startup.step-failed": "One part of design startup failed; `step` says which.",
1177
+ "legacy.retire-failed": "A migrated legacy design could not be retired.",
1178
+ "profiles.swept": "Design startup removed stale browser profiles.",
1179
+ "session-link.record-failed": "A closing conversation could not be recorded on a design link."
1180
+ }
1181
+ }
1182
+ });
1183
+
1184
+ // ../protocol/src/log-vocabulary/graph.ts
1185
+ var GRAPH_LOG_AREAS = defineLogAreas({
1186
+ graph: {
1187
+ description: "Graph runs: launches, passes, rewinds, system actions and templates.",
1188
+ events: {
1189
+ "describe.pass-failed": "A graph describe pass failed. Content-free: never the description or draft.",
1190
+ "system.stop-failed": "A system action's work could not be stopped.",
1191
+ "system.action-failed": "A system action failed; `cause` is its fixed failure cause.",
1192
+ "attention.update-failed": "The sidebar could not be updated for a run.",
1193
+ "launch.ticket-link-failed": "A launched run's ticket could not be linked.",
1194
+ "launch.started": "A graph run was launched.",
1195
+ "launch.swept": "Runs that ended without an environment were removed.",
1196
+ "rewind.pending": "A run's code rewind has not finished.",
1197
+ "rewind.applied": "A run was restarted or rewound.",
1198
+ "rewind.waiting": "A run waits for its code rewind to finish.",
1199
+ "history.pruned": "Finished runs beyond an environment's history were removed.",
1200
+ "history.prune-failed": "Pruning an environment's run history failed.",
1201
+ "worktree.cleanup-failed": "A run's branch worktree cleanup failed.",
1202
+ "run.unreadable": "A run is unreadable, so it is not scheduled.",
1203
+ "run.pass-failed": "A pass over a run failed.",
1204
+ "transcript.capture-failed": "A run's transcript capture failed.",
1205
+ "ticket.link-failed": "A run's ticket could not be linked to its environment.",
1206
+ "template.skipped": "A built-in template was skipped as invalid or a duplicate."
1207
+ }
1208
+ }
1209
+ });
1210
+
1211
+ // ../protocol/src/log-vocabulary/nodes.ts
1212
+ var NODES_LOG_AREAS = defineLogAreas({
1213
+ nodes: {
1214
+ description: "Command nodes: links, handovers, leaf mail and project copies.",
1215
+ events: {
1216
+ "actions.resume-failed": "Approved actions could not be resumed; a later pass retries.",
1217
+ "project-copy.notify-failed": "The coordinator could not be told a project copy finished.",
1218
+ "mail.delivery-deferred": "Leaf mail could not reach a coordinator yet.",
1219
+ "command.post-step-failed": "A step after a routed command failed.",
1220
+ "seed-files.incomplete": "Seed files for a leaf environment were not all copied.",
1221
+ "contact.record-failed": "The latest controller contact could not be recorded.",
1222
+ "settings.send-failed": "Settings could not be sent to a node.",
1223
+ "verification.record-failed": "A node verification could not be recorded.",
1224
+ "profile.record-failed": "A node profile could not be recorded.",
1225
+ "detach.unconfirmed": "A forgotten node has not confirmed the detach yet.",
1226
+ "handover.recovery-pending": "Command handover recovery is still pending."
1227
+ }
1228
+ }
1229
+ });
1230
+
1231
+ // ../protocol/src/log-vocabulary/linear.ts
1232
+ var LINEAR_LOG_AREAS = defineLogAreas({
1233
+ linear: {
1234
+ description: "Linear issues read for build actions.",
1235
+ events: {
1236
+ "comments.load-failed": "An issue's comments could not be loaded; the issue still renders without them."
1237
+ }
1238
+ }
1239
+ });
1240
+
1241
+ // ../protocol/src/log-vocabulary/usage-history.ts
1242
+ var USAGE_HISTORY_LOG_AREAS = defineLogAreas({
1243
+ "usage-history": {
1244
+ description: "Recorded agent token usage.",
1245
+ events: {
1246
+ "record.failed": "Agent usage could not be recorded; a later read counts it.",
1247
+ "prune.failed": "Pruning recorded usage failed; the next prune retries."
1248
+ }
1249
+ }
1250
+ });
1251
+
1252
+ // ../protocol/src/log-vocabulary/feature.ts
1253
+ var FEATURE_LOG_AREAS = defineLogAreas({
1254
+ feature: {
1255
+ description: "Pipeline environments started from a feature, and feature planning.",
1256
+ events: {
1257
+ "naming.fallback": "Automatic naming failed, so a local fallback name is used. Error kind only: the description stays out.",
1258
+ "planning.legacy-adopt-failed": "Legacy planning conversations could not be adopted.",
1259
+ "planning.tick-retrying": "A planning tick failed on a transient error; the next tick retries."
1260
+ }
1261
+ }
1262
+ });
1263
+
1264
+ // ../protocol/src/log-vocabulary/host.ts
1265
+ var HOST_LOG_AREAS = defineLogAreas({
1266
+ host: {
1267
+ description: "The host machine: its executables, load, suspends and maintenance.",
1268
+ events: {
1269
+ "path.discovered": "Executable discovery finished. Counts and booleans only: PATH entries can hold private directory names.",
1270
+ "tool.available": "A host tool's availability was read.",
1271
+ "tool.missing": "A host tool was not found.",
1272
+ "maintenance.listener-failed": "A host maintenance listener threw; the others still run.",
1273
+ "suspend.reconcile-failed": "Reconciling due work after a host suspension failed.",
1274
+ "load.sample-failed": "Sampling machine load failed; the next sample retries."
1275
+ }
1276
+ }
1277
+ });
1278
+
1279
+ // ../protocol/src/log-vocabulary/transcript-artifacts.ts
1280
+ var TRANSCRIPT_ARTIFACTS_LOG_AREAS = defineLogAreas({
1281
+ "transcript-artifacts": {
1282
+ description: "Transcript artifacts: previews, printing, grants and their ledger. Ids, kinds, sizes and reason codes only.",
1283
+ events: {
1284
+ "announce-failed": "An artifact change could not be announced.",
1285
+ "cleanup-failed": "An artifact cleanup failed.",
1286
+ "grant-revocation-failed": "A grant could not be revoked.",
1287
+ "ledger-listener-failed": "A ledger listener threw.",
1288
+ "ledger-read-failed": "The ledger could not be read.",
1289
+ "operation-executor-failed": "A preview operation's executor failed.",
1290
+ "operation-failed": "A preview operation failed.",
1291
+ "pdf-preview": "A PDF preview was served.",
1292
+ "pdf-preview-failed": "A PDF preview failed.",
1293
+ "pdf-print-failed": "Printing an artifact to PDF failed.",
1294
+ "pdf-printed": "An artifact was printed to PDF.",
1295
+ "runtime-unavailable": "The artifact runtime could not be created."
1296
+ }
1297
+ }
1298
+ });
1299
+
1300
+ // ../protocol/src/log-vocabulary/scheduler.ts
1301
+ var SCHEDULER_LOG_AREAS = defineLogAreas({
1302
+ scheduler: {
1303
+ description: "Scheduled jobs and the backend-owned timing that fires them.",
1304
+ events: {
1305
+ "tick.failed": "A scheduler tick failed; the next tick retries.",
1306
+ "job.claim-failed": "A due job could not be claimed.",
1307
+ "fire.heartbeat-failed": "A running fire's heartbeat could not be recorded.",
1308
+ "fire.outcome-record-failed": "A finished fire's outcome could not be recorded."
1309
+ }
1310
+ }
1311
+ });
1312
+
1313
+ // ../protocol/src/log-vocabulary/web-app.ts
1314
+ var WEB_APP_LOG_AREAS = defineLogAreas({
1315
+ "web.app": {
1316
+ description: "The application root: startup checks and restoring state.",
1317
+ events: {
1318
+ "config.load-failed": "The application config could not be loaded.",
1319
+ "docker.check-failed": "A Docker availability probe failed; the result stays unknown.",
1320
+ "docker.checked": "A Docker availability check finished.",
1321
+ "docker.orphans-cleared": "Reconciling with Docker cleared orphaned container references.",
1322
+ "docker.sync-failed": "Reconciling environments with Docker failed; non-fatal.",
1323
+ "prompt-queues.restore-failed": "An environment's prompt queues could not be restored.",
1324
+ "multi-reviews.restore-failed": "An environment's multi reviews could not be restored.",
1325
+ "build-pipelines.migrate-failed": "Migrating legacy build pipelines failed; the next launch retries.",
1326
+ "build-pipelines.restore-failed": "A project's build pipelines could not be restored.",
1327
+ "macos-permissions.check-failed": "Reading macOS file permission status failed.",
1328
+ "cli-check.failed": "One startup CLI check failed; its result stays unknown.",
1329
+ "cli-check.completed": "A startup CLI check finished; one line per tool.",
1330
+ "cli-check.retried": "A user-requested CLI recheck finished.",
1331
+ "cli-check.retry-failed": "A user-requested CLI recheck failed.",
1332
+ "exit.failed": "Exiting through the plugin failed; the window closes instead.",
1333
+ "zoom.native-failed": "Applying native zoom failed; the CSS fallback is used.",
1334
+ "github-cli.status-failed": "Reading the GitHub CLI setup status failed.",
1335
+ "attachments.restore-failed": "Saved prompt attachments could not be restored before startup.",
1336
+ "startup-launch.persist-failed": "Saving the startup agent launch failed; nothing started.",
1337
+ "environment.start-failed": "Starting an environment from the terminal overlay failed.",
1338
+ "project.delete-failed": "Deleting a project from its dialog failed."
1339
+ }
1340
+ },
1341
+ "web.session": {
1342
+ description: "The renderer's terminal and agent session store.",
1343
+ events: {
1344
+ "status.update-failed": "A session status change could not be saved.",
1345
+ "activity.update-failed": "A best-effort session activity update failed.",
1346
+ "environment-sessions.disconnect-failed": "Disconnecting an environment's sessions failed.",
1347
+ "container-sessions.sync-failed": "Syncing sessions with container state failed.",
1348
+ "reorder.failed": "Reordering sessions failed; the list reloads from the backend.",
1349
+ "refresh.manual-failed": "A manual refresh of an agent tab failed."
1350
+ }
1351
+ },
1352
+ "web.action-bar": {
1353
+ description: "The environment action bar.",
1354
+ events: {
1355
+ "editor.open-failed": "The external editor could not be opened.",
1356
+ "run-commands.read-failed": "Reading the project's run commands file failed.",
1357
+ "environment.delete-failed": "Deleting an environment from the action bar failed.",
1358
+ "merge.started": "A user-requested PR merge started.",
1359
+ "merge.completed": "A user-requested PR merge command returned.",
1360
+ "merge.failed": "A user-requested PR merge failed."
1361
+ }
1362
+ }
1363
+ });
1364
+
1365
+ // ../protocol/src/log-vocabulary/web-build-pipeline.ts
1366
+ var WEB_BUILD_PIPELINE_LOG_AREAS = defineLogAreas({
1367
+ "web.build-pipeline": {
1368
+ description: "Build pipelines as the renderer starts, hydrates and shows them.",
1369
+ events: {
1370
+ "build.start-failed": "A build could not be started.",
1371
+ "pipeline.hydrate-failed": "A pipeline read failed; source says who asked for it.",
1372
+ "pipeline.project-mismatch": "A pending tab activation was dropped: wrong project.",
1373
+ "environment.not-found": "A build's environment read returned nothing after creation.",
1374
+ "environment.project-mismatch": "A build's environment was not added: wrong project.",
1375
+ "environment.hydrate-failed": "A build's environment read failed; live sync can recover.",
1376
+ "transcript.load-failed": "A stage transcript read failed and will retry with backoff.",
1377
+ "legacy.state-too-large": "Legacy pipeline state was over the limit and skipped.",
1378
+ "opencode-catalog.load-failed": "The cached OpenCode model list could not be loaded.",
1379
+ "opencode-preferences.load-failed": "OpenCode model preferences could not be loaded."
1380
+ }
1381
+ }
1382
+ });
1383
+
1384
+ // ../protocol/src/log-vocabulary/web-chat.ts
1385
+ var WEB_CHAT_LOG_AREAS = defineLogAreas({
1386
+ "web.chat": {
1387
+ description: "Rendering the agent transcript: messages, rich blocks and question cards.",
1388
+ events: {
1389
+ "message.copy-failed": "A message could not be copied to the clipboard.",
1390
+ "message.long-press-failed": "A user message's long-press action failed.",
1391
+ "message.link-open-failed": "A link in a message could not be opened.",
1392
+ "message.render-failed": "One transcript row failed to render; fields are the bounded diagnostic.",
1393
+ "image-preview.load-failed": "An image in a message could not be loaded for preview.",
1394
+ "session-list.load-failed": "The resume dialog could not fetch the resumable sessions.",
1395
+ "question.submit-failed": "An answer to an agent's question could not be submitted.",
1396
+ "question.dismiss-failed": "An agent's question could not be dismissed.",
1397
+ "rich-block.render-failed": "A rich block's renderer failed and its source is shown instead.",
1398
+ "rich-block.copy-failed": "A rich block's copy action could not write to the clipboard.",
1399
+ "scroll-viewport.not-found": "The scroll viewport was still missing when polling for it ended."
1400
+ }
1401
+ },
1402
+ "web.native-agent": {
1403
+ description: "The native agent tab and its composer.",
1404
+ events: {
1405
+ "model-catalogue.load-failed": "The native model catalogue could not be loaded.",
1406
+ "provider-lock.persist-failed": "The locked agent choice could not be saved.",
1407
+ "compose-draft.persist-failed": "A compose draft could not be saved.",
1408
+ "compose-draft.restore-failed": "A saved compose draft could not be restored.",
1409
+ "compose-draft.discard-failed": "A saved compose draft could not be discarded.",
1410
+ "paste.failed": "Pasting an image into a composer failed unexpectedly.",
1411
+ "agent-state.listen-failed": "Subscribing to a tab's agent state events failed.",
1412
+ "model-favorites.persist-failed": "The favorite model list could not be saved."
1413
+ }
1414
+ }
1415
+ });
1416
+
1417
+ // ../protocol/src/log-vocabulary/web-claude-tmux.ts
1418
+ var WEB_CLAUDE_TMUX_LOG_AREAS = defineLogAreas({
1419
+ "web.claude-tmux": {
1420
+ description: "The renderer's Claude tmux chat tab and interactive terminal.",
1421
+ events: {
1422
+ "sessions.list-failed": "The resume dialog could not list tmux sessions.",
1423
+ "tab.hydrate-failed": "Reading a tab's tmux session from the backend failed.",
1424
+ "models.catalog-unavailable": "The model catalogue failed; the bundled fallback stays.",
1425
+ "queue.promote-failed": "After an interrupt, the next queued prompt did not become the draft.",
1426
+ "files.load-failed": "The file list for @mentions could not be loaded.",
1427
+ "clipboard.image-failed": "An image pasted into the interactive terminal could not be saved.",
1428
+ "terminal.resize-failed": "Resizing the interactive terminal's session failed.",
1429
+ "terminal.recover-failed": "The interactive terminal could not reattach to its session."
1430
+ }
1431
+ }
1432
+ });
1433
+
1434
+ // ../protocol/src/log-vocabulary/web-design.ts
1435
+ var WEB_DESIGN_LOG_AREAS = defineLogAreas({
1436
+ "web.design": {
1437
+ description: "Opening design canvas tabs.",
1438
+ events: {
1439
+ "tab.duplicate-refused": "A design tab was not opened because its id is already in use."
1440
+ }
1441
+ }
1442
+ });
1443
+
1444
+ // ../protocol/src/log-vocabulary/web-environment.ts
1445
+ var WEB_ENVIRONMENT_LOG_AREAS = defineLogAreas({
1446
+ "web.environment": {
1447
+ description: "Environment lifecycle and dialogs as the renderer drives them.",
1448
+ events: {
1449
+ "start.called": "The renderer was asked to start an environment.",
1450
+ "start.unknown-environment": "A start was requested for an id the store does not hold.",
1451
+ "start.snapshot-read": "An environment's state as its start began.",
1452
+ "start.status-set": "The environment was marked as creating before the backend call.",
1453
+ "start.background-requested": "A start is being handed to the backend to run in background.",
1454
+ "start.backend-requested": "A foreground start call to the backend is being made.",
1455
+ "start.backend-completed": "The backend finished a foreground start.",
1456
+ "start.environment-refreshed": "An environment was read back after a foreground start.",
1457
+ "start.worktree-missing": "A local environment started with no worktree path.",
1458
+ "start.failed": "Starting an environment from the renderer failed.",
1459
+ "stop.called": "The renderer was asked to stop an environment.",
1460
+ "stop.status-set": "The environment's status was set while stopping it.",
1461
+ "stop.backend-requested": "A stop call to the backend is being made.",
1462
+ "stop.backend-completed": "The backend finished a stop.",
1463
+ "stop.sessions-disconnecting": "A stopped environment's sessions are being disconnected.",
1464
+ "stop.sessions-disconnected": "A stopped environment's sessions were disconnected.",
1465
+ "stop.failed": "Stopping an environment from the renderer failed.",
1466
+ "restart.failed": "Restarting an environment from the renderer failed.",
1467
+ "status-sync.failed": "An environment's status could not be synced from the backend.",
1468
+ "list.refresh-failed": "A background refresh of a project's environments failed.",
1469
+ "setup-snapshot.reconcile-failed": "An environment's setup state could not be reconciled.",
1470
+ "rename.received": "An environment-renamed event arrived.",
1471
+ "rename.pr-state-cleared": "A rename changed the branch, so stale PR state was cleared.",
1472
+ "unread.clear-failed": "An environment's unread work could not be cleared on the backend.",
1473
+ "create.failed": "Creating an environment from the dialog failed.",
1474
+ "create.port-mappings-invalid": "Creation was refused: a port is not between 1 and 65535.",
1475
+ "create.attachment-read-failed": "A file dropped on the create dialog could not be read.",
1476
+ "auto-start.failed": "A background start after creating an environment was rejected.",
1477
+ "models.pi-seed-failed": "The create dialog could not seed the Pi model catalogue.",
1478
+ "models.opencode-cache-load-failed": "The create dialog could not read cached OpenCode models.",
1479
+ "github-credential.check-failed": "The GitHub credential check before creating failed.",
1480
+ "feature-build.start-failed": "Starting a pipeline environment from the dialog failed.",
1481
+ "settings.extensions-load-failed": "The settings dialog could not load extensions.",
1482
+ "settings.container-reset-failed": "The settings dialog could not reset the container.",
1483
+ "settings.save-failed": "The settings dialog could not save.",
1484
+ "domains.test-failed": "Testing whether network whitelist domains resolve failed.",
1485
+ "network-whitelist.save-failed": "The network whitelist dialog could not save."
1486
+ }
1487
+ },
1488
+ "web.sidebar": {
1489
+ description: "The project and environment sidebar.",
1490
+ events: {
1491
+ "reorder.persist-failed": "A sidebar reorder could not be saved.",
1492
+ "fork.failed": "Forking an environment from the sidebar failed.",
1493
+ "auto-start.started": "Selecting an unstarted local environment is starting it.",
1494
+ "auto-start.failed": "Starting a local environment on selection failed.",
1495
+ "environment.stop-failed": "Stopping a selected environment failed.",
1496
+ "environment.restart-failed": "Restarting a selected environment failed.",
1497
+ "environment.delete-failed": "Deleting an environment from the sidebar failed.",
1498
+ "environments.load-failed": "A project's environments could not be loaded for the sidebar.",
1499
+ "project.add-failed": "Adding a project from the sidebar failed.",
1500
+ "project.create-failed": "Creating a project from scratch failed.",
1501
+ "project.delete-failed": "Deleting a project from the sidebar failed.",
1502
+ "folder.project-remove-failed": "A project could not be removed from its folder.",
1503
+ "folder.rename-failed": "A project folder could not be renamed.",
1504
+ "folder.ungroup-failed": "A project folder could not be removed.",
1505
+ "folder.sort-failed": "A project folder could not be sorted."
1506
+ }
1507
+ },
1508
+ "web.docker": {
1509
+ description: "The Docker settings view.",
1510
+ events: {
1511
+ "data.load-failed": "Container or image data could not be loaded.",
1512
+ "container.stop-failed": "Stopping a container from Docker settings failed.",
1513
+ "container.delete-failed": "Deleting a container from Docker settings failed.",
1514
+ "container.reattach-failed": "Reattaching a container to a project failed."
1515
+ }
1516
+ },
1517
+ "web.project": {
1518
+ description: "Adding a project from the renderer.",
1519
+ events: {
1520
+ "directory-picker.failed": "The directory picker could not be opened.",
1521
+ "git-remote.read-failed": "A chosen directory's git remote could not be read."
1522
+ }
1523
+ }
1524
+ });
1525
+
1526
+ // ../protocol/src/log-vocabulary/web-files.ts
1527
+ var WEB_FILES_LOG_AREAS = defineLogAreas({
1528
+ "web.files": {
1529
+ description: "The files panel, file viewer and file search.",
1530
+ events: {
1531
+ "file.save-failed": "A file could not be saved.",
1532
+ "git-changes.load-failed": "The files panel could not load the git changes.",
1533
+ "file-tree.load-failed": "The file tree could not be loaded.",
1534
+ "changes.refresh-failed": "Refreshing the files panel's changes failed.",
1535
+ "folder.load-failed": "An expanded folder's contents could not be loaded.",
1536
+ "path.copy-failed": "A file's path could not be copied to the clipboard.",
1537
+ "draft.persist-failed": "A file viewer tab's draft could not be saved.",
1538
+ "draft.restore-failed": "A file viewer tab's saved draft could not be restored.",
1539
+ "draft.discard-failed": "A file's saved draft could not be discarded before a reload."
1540
+ }
1541
+ }
1542
+ });
1543
+
1544
+ // ../protocol/src/log-vocabulary/web-github.ts
1545
+ var WEB_GITHUB_LOG_AREAS = defineLogAreas({
1546
+ "web.github": {
1547
+ description: "Pull request and GitHub issue views.",
1548
+ events: {
1549
+ "pull-request.url-failed": "A pull request's URL could not be read.",
1550
+ "pull-request.mode-request-failed": "The pull request monitor refused a watch mode request.",
1551
+ "pull-request.copy-failed": "A pull request value could not be copied to the clipboard.",
1552
+ "comment-edit-draft.clear-failed": "An edited comment's saved draft could not be cleared.",
1553
+ "issue-draft.clear-failed": "An edited issue's saved drafts could not be cleared.",
1554
+ "comment-draft.clear-failed": "A posted comment's draft could not be cleared."
1555
+ }
1556
+ },
1557
+ "web.linear": {
1558
+ description: "The Linear tickets view.",
1559
+ events: {
1560
+ "comment-draft.clear-failed": "A posted comment's draft could not be cleared."
1561
+ }
1562
+ }
1563
+ });
1564
+
1565
+ // ../protocol/src/log-vocabulary/web-kanban.ts
1566
+ var WEB_KANBAN_LOG_AREAS = defineLogAreas({
1567
+ "web.kanban": {
1568
+ description: "The Kanban board, its task dialog and project notes.",
1569
+ events: {
1570
+ "tasks.load-failed": "A project's tasks could not be loaded.",
1571
+ "task.add-failed": "A new task could not be added.",
1572
+ "task.update-failed": "A task's fields could not be updated.",
1573
+ "task.content-update-failed": "A task's content edit could not be saved.",
1574
+ "task.build-status-clear-failed": "A task's build status could not be cleared.",
1575
+ "task.delete-failed": "A task could not be deleted.",
1576
+ "task.move-failed": "A task move failed and its status was rolled back.",
1577
+ "comment.add-failed": "A comment could not be added to a task.",
1578
+ "comment.delete-failed": "A comment could not be deleted from a task.",
1579
+ "image.add-failed": "An image could not be added to a task.",
1580
+ "image.delete-failed": "An image could not be deleted from a task.",
1581
+ "notes.load-failed": "Project notes could not be loaded; the editor stays disabled.",
1582
+ "notes.save-failed": "Project notes could not be saved.",
1583
+ "notes.draft-retained": "A notes save failed; the edit stays in its durable draft.",
1584
+ "draft.restore-failed": "A saved create-task draft could not be restored.",
1585
+ "draft.persist-failed": "A create-task draft could not be saved; phase says when.",
1586
+ "draft.discard-failed": "A create-task draft could not be removed; phase says when.",
1587
+ "build.start-failed": "The task dialog could not start a build for a task.",
1588
+ "build.create-and-start-failed": "The task dialog could not create a task and build it."
1589
+ }
1590
+ },
1591
+ "web.feature-plan": {
1592
+ description: "Feature planning in the renderer.",
1593
+ events: {
1594
+ "features.load-failed": "A project's features could not be loaded.",
1595
+ "feature.create-failed": "A new feature could not be created.",
1596
+ "feature.update-failed": "A feature could not be updated.",
1597
+ "build.claim-failed": "A feature's build could not be claimed for a task.",
1598
+ "build.start-failed": "Starting a build from a feature failed.",
1599
+ "message.append-failed": "A message could not be added to a feature's chat.",
1600
+ "story-message.append-failed": "A message could not be added to a story's chat.",
1601
+ "planning.start-failed": "Feature planning could not be started.",
1602
+ "planning.retry-failed": "Feature planning could not be retried.",
1603
+ "planning.cancel-failed": "Feature planning could not be cancelled.",
1604
+ "drafts.persist-failed": "A project's feature chat drafts could not be saved.",
1605
+ "drafts.restore-failed": "A project's feature chat drafts could not be restored."
1606
+ }
1607
+ }
1608
+ });
1609
+
1610
+ // ../protocol/src/log-vocabulary/web-pane-layout.ts
1611
+ var WEB_PANE_LAYOUT_LOG_AREAS = defineLogAreas({
1612
+ "web.pane-layout": {
1613
+ description: "Panes and tabs in the renderer: moves, splits, teardown and saved layouts.",
1614
+ events: {
1615
+ "persist.failed": "A pane layout could not be written to the backend.",
1616
+ "persist.install-skipped": "A saved layout was not installed: its dependencies did not load.",
1617
+ "persist.settled-handler-failed": "A write-settled handler threw; later handlers still ran.",
1618
+ "environment.activated": "The active environment changed.",
1619
+ "environment.initialized": "An environment's pane state was initialized.",
1620
+ "environment.initialize-skipped": "Initialize was called with no active environment.",
1621
+ "environment.terminals-cleared": "A reset cleared the environment's terminal instances.",
1622
+ "terminal-session.cleanup-started": "A closed tab's terminal session is being cleaned up.",
1623
+ "teardown.pending": "A tab teardown was rejected; the backend keeps it pending and retries.",
1624
+ "browser-preview.destroy-failed": "Destroying a closed browser tab's preview failed.",
1625
+ "handoffs.prune-failed": "Pruning unreferenced agent handoffs failed.",
1626
+ "tab.reactivated": "A tab added twice was activated in its existing pane instead.",
1627
+ "tab.move-started": "A tab move passed its checks and is being applied.",
1628
+ "tab.move-failed": "A tab move was refused; `reason` says which lookup failed.",
1629
+ "tab.initial-prompt-cleared": "A tab's initial prompt was cleared.",
1630
+ "tab.initial-agent-options-cleared": "A tab's initial agent options were cleared.",
1631
+ "pane.split-depth-reached": "A split was refused at the maximum split depth.",
1632
+ "pane.edge-split-started": "An edge split passed its checks and is being applied.",
1633
+ "pane.edge-split-failed": "An edge split was refused; `reason` says which lookup failed.",
1634
+ "pane.close-refused": "Closing the only pane in a layout was refused.",
1635
+ "draft.discard-failed": "A closing tab's draft could not be discarded; the tab stayed open.",
1636
+ "draft.file-conflict-resolve-failed": "Discarding a newer saved file draft failed.",
1637
+ "draft.compose-conflict-resolve-failed": "Discarding a newer saved compose draft failed."
1638
+ }
1639
+ }
1640
+ });
1641
+
1642
+ // ../protocol/src/log-vocabulary/web-settings.ts
1643
+ var WEB_SETTINGS_LOG_AREAS = defineLogAreas({
1644
+ "web.settings": {
1645
+ description: "The settings screens.",
1646
+ events: {
1647
+ "config.save-failed": "Global settings could not be saved.",
1648
+ "config.load-failed": "The settings page could not load the config.",
1649
+ "config.reload-failed": "Re-reading the workspace config after a save failed.",
1650
+ "domains.test-failed": "The domain resolution test could not run.",
1651
+ "github-credentials.propagate-failed": "Propagating GitHub credentials to environments failed.",
1652
+ "credential.save-failed": "A credential could not be saved.",
1653
+ "credential.clear-failed": "A credential could not be cleared.",
1654
+ "gateway-token.save-failed": "The gateway token could not be saved.",
1655
+ "gateway-token.copy-failed": "Copying the gateway token to the clipboard failed.",
1656
+ "web-client-url.copy-failed": "Copying the web client address to the clipboard failed.",
1657
+ "backend-version.read-failed": "The debug tab could not read the backend version.",
1658
+ "messaging.flush-failed": "Saving pending messaging settings on unmount failed.",
1659
+ "directory-picker.failed": "The repository directory picker could not open.",
1660
+ "file-picker.failed": "The repository file picker could not open.",
1661
+ "repository.save-failed": "Repository settings could not be saved.",
1662
+ "model-catalogues.read-failed": "Reading the model catalogues for settings failed."
1663
+ }
1664
+ }
1665
+ });
1666
+
1667
+ // ../protocol/src/log-vocabulary/web-shell.ts
1668
+ var WEB_SHELL_LOG_AREAS = defineLogAreas({
1669
+ "web.startup": {
1670
+ description: "Loading the renderer, after the desktop connection check.",
1671
+ events: {
1672
+ "renderer.load-failed": "Importing or mounting the application failed.",
1673
+ "model-catalogue.restore-failed": "The cached model catalogue could not be restored; bundled fallbacks stay in use."
1674
+ }
1675
+ },
1676
+ "web.window": {
1677
+ description: "Errors nothing in the renderer caught. Bug reports classify these two lines.",
1678
+ events: {
1679
+ "error.unhandled": "A window error event reached the bootstrap handler.",
1680
+ "rejection.unhandled": "A promise rejected with no handler."
1681
+ }
1682
+ },
1683
+ "web.react": {
1684
+ description: "React's root error callbacks and the lazy view boundary.",
1685
+ events: {
1686
+ "root.caught-error": "An error boundary caught a render error.",
1687
+ "root.uncaught-error": "A render error reached the root with no boundary.",
1688
+ "root.recoverable-error": "React recovered from a render error by retrying.",
1689
+ "lazy-view.failed": "A lazily loaded view failed; fields are the bounded diagnostic."
1690
+ }
1691
+ }
1692
+ });
1693
+
1694
+ // ../protocol/src/log-vocabulary/web-sync.ts
1695
+ var WEB_SYNC_LOG_AREAS = defineLogAreas({
1696
+ "web.resource-sync": {
1697
+ description: "Keeping renderer stores current with backend resources.",
1698
+ events: {
1699
+ "handler.threw": "A resource change handler threw; other handlers still ran.",
1700
+ "resync-handler.threw": "A resync handler threw; the resync counts as failed.",
1701
+ "view-safety-check.threw": "A view safety check handler threw; the others still ran.",
1702
+ "snapshots.batch-failed": "A scoped snapshot batch failed; individual reads take over.",
1703
+ "manifest.scoped-check-failed": "The scoped manifest read failed; a full resync runs.",
1704
+ "manifest.check-failed": "The manifest read failed; a full resync runs.",
1705
+ "subscribe.failed": "Subscribing to a resource transport event failed.",
1706
+ "change.malformed": "A resource-changed payload had the wrong shape and was dropped.",
1707
+ "config.refresh-failed": "Refreshing the config store after a change failed.",
1708
+ "pane-layout.refresh-failed": "Refreshing an environment's pane layout failed.",
1709
+ "setup-completion.observe-failed": "Subscribing to setup completion events failed.",
1710
+ "resync.project-failed": "The authoritative project read failed during a store resync.",
1711
+ "resync.environment-failed": "The authoritative environment read failed during a resync.",
1712
+ "resync.read-failed": "One of a store resync's per-environment reads failed.",
1713
+ "resync.pane-failed": "A pane layout read failed during a store resync.",
1714
+ "agent-mail.summary-refresh-failed": "Refreshing the agent mail summary failed.",
1715
+ "agent-mail.mailbox-refresh-failed": "Refreshing one agent mailbox failed.",
1716
+ "prompt-queues.refresh-failed": "Refreshing an environment's prompt queues failed.",
1717
+ "build-pipeline.refresh-failed": "Refreshing one build pipeline failed.",
1718
+ "multi-review.refresh-failed": "Refreshing one multi review workflow failed.",
1719
+ "authoritative.resync-failed": "Re-reading a snapshot after a stream reconnect failed.",
1720
+ "observation.listener-threw": "A native observation invalidation listener threw.",
1721
+ "observation.subscribe-failed": "Subscribing to native observation events failed.",
1722
+ "hydration.status-listener-failed": "A bounded hydration status listener threw.",
1723
+ "hydration.notification-failed": "A bounded hydration change notification threw."
1724
+ }
1725
+ },
1726
+ "web.read-coordinator": {
1727
+ description: "The renderer's coalesced, bounded backend reads.",
1728
+ events: {
1729
+ "listener.threw": "A read state listener threw.",
1730
+ "read.settle-failed": "Applying a finished read's result threw."
1731
+ }
1732
+ },
1733
+ "web.gateway": {
1734
+ description: "The renderer's connection to the gateway: requests and event streams.",
1735
+ events: {
1736
+ "events.disconnected": "The main event stream dropped; it reconnects and replays.",
1737
+ "terminal-stream.disconnected": "A terminal event stream dropped; it reconnects.",
1738
+ "connection-listener.failed": "A main stream connection state listener threw.",
1739
+ "event-listener.failed": "A listener for a gateway event threw.",
1740
+ "stream-listener.failed": "A listener for the stream-connected notice threw."
1741
+ }
1742
+ },
1743
+ "web.federation": {
1744
+ description: "Events from federated nodes as the renderer receives them.",
1745
+ events: {
1746
+ "resync-handler.failed": "A node resync handler failed.",
1747
+ "event-handler.failed": "A handler for an event relayed from a node failed.",
1748
+ "environment.start-failed": "Starting an environment opened in a workspace window failed."
1749
+ }
1750
+ }
1751
+ });
1752
+
1753
+ // ../protocol/src/log-vocabulary/index.ts
1754
+ var LOG_VOCABULARY = {
1755
+ ...AGENT_MAIL_LOG_AREAS,
1756
+ ...BACKEND_LOG_AREAS,
1757
+ ...BRIDGE_LOG_AREAS,
1758
+ ...DESKTOP_LOG_AREAS,
1759
+ ...ENVIRONMENT_LOG_AREAS,
1760
+ ...GATEWAY_LOG_AREAS,
1761
+ ...LOCAL_SERVER_LOG_AREAS,
1762
+ ...GIT_LOG_AREAS,
1763
+ ...LOGGING_LOG_AREAS,
1764
+ ...MODEL_LOG_AREAS,
1765
+ ...NATIVE_AGENT_LOG_AREAS,
1766
+ ...PREVIEW_LOG_AREAS,
1767
+ ...RUNTIME_LOG_AREAS,
1768
+ ...TERMINAL_LOG_AREAS,
1769
+ ...TMUX_LOG_AREAS,
1770
+ ...UPDATER_LOG_AREAS,
1771
+ ...WEB_ANNOTATIONS_LOG_AREAS,
1772
+ ...STORAGE_LOG_AREAS,
1773
+ ...BUILD_PIPELINE_LOG_AREAS,
1774
+ ...AGENT_BRANCH_LOG_AREAS,
1775
+ ...CHANGE_TRACKING_LOG_AREAS,
1776
+ ...COORDINATOR_LOG_AREAS,
1777
+ ...REVIEW_LOG_AREAS,
1778
+ ...PUBLIC_API_LOG_AREAS,
1779
+ ...AGENT_ACCOUNTS_LOG_AREAS,
1780
+ ...DOCKER_LOG_AREAS,
1781
+ ...MCP_LOG_AREAS,
1782
+ ...DESIGN_LOG_AREAS,
1783
+ ...GRAPH_LOG_AREAS,
1784
+ ...NODES_LOG_AREAS,
1785
+ ...LINEAR_LOG_AREAS,
1786
+ ...USAGE_HISTORY_LOG_AREAS,
1787
+ ...FEATURE_LOG_AREAS,
1788
+ ...HOST_LOG_AREAS,
1789
+ ...TRANSCRIPT_ARTIFACTS_LOG_AREAS,
1790
+ ...SCHEDULER_LOG_AREAS,
1791
+ ...WEB_APP_LOG_AREAS,
1792
+ ...WEB_BUILD_PIPELINE_LOG_AREAS,
1793
+ ...WEB_CHAT_LOG_AREAS,
1794
+ ...WEB_CLAUDE_TMUX_LOG_AREAS,
1795
+ ...WEB_DESIGN_LOG_AREAS,
1796
+ ...WEB_ENVIRONMENT_LOG_AREAS,
1797
+ ...WEB_FILES_LOG_AREAS,
1798
+ ...WEB_GITHUB_LOG_AREAS,
1799
+ ...WEB_KANBAN_LOG_AREAS,
1800
+ ...WEB_PANE_LAYOUT_LOG_AREAS,
1801
+ ...WEB_SETTINGS_LOG_AREAS,
1802
+ ...WEB_SHELL_LOG_AREAS,
1803
+ ...WEB_SYNC_LOG_AREAS
1804
+ };
1805
+
1806
+ // ../protocol/src/secret-redaction.ts
1807
+ var TEXT_RULES = [
1808
+ {
1809
+ pattern: /([a-z][a-z0-9+.-]*:\/\/)[^/\s:@]+(?::[^/\s@]*)?@/gi,
1810
+ replacement: "$1[redacted]@"
1811
+ },
1812
+ {
1813
+ pattern: /([?&](?:access[_-]?token|refresh[_-]?token|id[_-]?token|api[_-]?key|apikey|auth|authorization|token|secret|password|passwd|signature|sig|key|state|code)=)[^&\s"'`]+/gi,
1814
+ replacement: "$1[redacted]"
1815
+ },
1816
+ { pattern: /\bBearer\s+[A-Za-z0-9._~+/=-]{8,}/gi, replacement: "Bearer [redacted]" },
1817
+ { pattern: /\bBasic\s+[A-Za-z0-9+/=]{8,}/gi, replacement: "Basic [redacted]" },
1818
+ {
1819
+ pattern: /\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}/g,
1820
+ replacement: "[redacted]"
1821
+ },
1822
+ { pattern: /\bgh[pousr]_[A-Za-z0-9]{16,}/g, replacement: "[redacted]" },
1823
+ { pattern: /\bgithub_pat_[A-Za-z0-9_]{20,}/g, replacement: "[redacted]" },
1824
+ { pattern: /\b(?:sk|rk|pk)-[A-Za-z0-9_-]{12,}/g, replacement: "[redacted]" },
1825
+ { pattern: /\bxox[baprse]-[A-Za-z0-9-]{8,}/g, replacement: "[redacted]" },
1826
+ { pattern: /\bAKIA[0-9A-Z]{12,}/g, replacement: "[redacted]" },
1827
+ { pattern: /\bAIza[0-9A-Za-z_-]{20,}/g, replacement: "[redacted]" },
1828
+ {
1829
+ 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,
1830
+ replacement: "$1$2[redacted]"
1831
+ }
1832
+ ];
1833
+ function redactSecrets(value) {
1834
+ let result = value;
1835
+ for (const rule of TEXT_RULES) {
1836
+ result = result.replace(new RegExp(rule.pattern.source, rule.pattern.flags), rule.replacement);
1837
+ }
1838
+ return result;
1839
+ }
1840
+
1841
+ // ../protocol/src/log-error.ts
1842
+ var MAX_MESSAGE_CHARS = 1024;
1843
+ var MAX_STACK_FRAMES = 8;
1844
+ var MAX_FRAME_CHARS = 240;
1845
+ var MAX_RAW_FRAME_CHARS = 1024;
1846
+ var MAX_CAUSE_DEPTH = 2;
1847
+ var TRUNCATED_MARKER = "...[truncated]";
1848
+ var NAME_PATTERN = /^[A-Za-z_$][\w$.-]{0,63}$/;
1849
+ var CODE_PATTERN = /^[\w.:-]{1,64}$/;
1850
+ var SYSCALL_PATTERN = /^[\w./ -]{1,128}$/;
1851
+ var COMMAND_OUTPUT_FIELDS = ["stdout", "stderr", "cmd", "spawnargs"];
1852
+ var safeErrors = new WeakSet;
1853
+ function isSafeLogError(value) {
1854
+ return typeof value === "object" && value !== null && safeErrors.has(value);
1855
+ }
1856
+ function brand(details) {
1857
+ const safe = Object.freeze(details);
1858
+ safeErrors.add(safe);
1859
+ return safe;
1860
+ }
1861
+ function boundedText(value, maxChars) {
1862
+ const cut = value.length > maxChars ? `${value.slice(0, maxChars - TRUNCATED_MARKER.length)}${TRUNCATED_MARKER}` : value;
1863
+ return redactSecrets(cut).replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]+/g, " ").trim();
1864
+ }
1865
+ var FRAME_LOCATION = /(^|[\s(])((?:[a-z][a-z0-9+.-]*:\/\/[^/\s)]*)?(?:\/|[a-z]:[\\/]|\\\\).*?)(?=:\d+(?::\d+)?\)?(?:,|$)|\)(?:,|$)|,\s|$)/gi;
1866
+ var LOCATION_SCHEME = /^([a-z][a-z0-9+.-]*):\/\/[^/\s)]*/i;
1867
+ var APP_PATH = /(?:^|\/)((?:apps\/(?:backend|desktop|web|web-public)|packages\/(?:protocol|cli|toolchain)|bridges\/[\w-]+|[\w-]+-bridge)\/.*)$/;
1868
+ var PACKAGED_PATH = /\/((?:app\.asar(?:\.unpacked)?|resources)\/.*)$/i;
1869
+ function appRelativeLocation(location) {
1870
+ const scheme = LOCATION_SCHEME.exec(location)?.[1]?.toLowerCase();
1871
+ const isWebUrl = scheme !== undefined && scheme !== "file";
1872
+ const withoutOrigin = location.replace(LOCATION_SCHEME, "");
1873
+ const path = (isWebUrl ? withoutOrigin.split(/[?#]/, 1)[0] : withoutOrigin).replace(/\\/g, "/");
1874
+ const modules = path.lastIndexOf("/node_modules/");
1875
+ if (modules >= 0)
1876
+ return path.slice(modules + 1);
1877
+ const app = APP_PATH.exec(path)?.[1] ?? PACKAGED_PATH.exec(path)?.[1];
1878
+ if (app)
1879
+ return app;
1880
+ if (isWebUrl)
1881
+ return path.replace(/^\/+/, "");
1882
+ return `.../${path.slice(path.lastIndexOf("/") + 1)}`;
1883
+ }
1884
+ function relativeFrame(frame) {
1885
+ return frame.slice(0, MAX_RAW_FRAME_CHARS).replace(FRAME_LOCATION, (_match, lead, location) => `${lead}${appRelativeLocation(location)}`);
1886
+ }
1887
+ function read(target, key) {
1888
+ try {
1889
+ return target[key];
1890
+ } catch {
1891
+ return;
1892
+ }
1893
+ }
1894
+ function matching(value, pattern) {
1895
+ return typeof value === "string" && pattern.test(value) ? value : undefined;
1896
+ }
1897
+ function finite(value) {
1898
+ return typeof value === "number" && Number.isFinite(value) ? value : undefined;
1899
+ }
1900
+ function isCommandFailure(target, name, message) {
1901
+ return name === "CommandFailedError" || Boolean(message?.startsWith("Command failed")) || COMMAND_OUTPUT_FIELDS.some((field) => read(target, field) !== undefined);
1902
+ }
1903
+ function stackFrames(target, message) {
1904
+ const stack = read(target, "stack");
1905
+ if (typeof stack !== "string")
1906
+ return;
1907
+ const index = message ? stack.indexOf(message) : -1;
1908
+ const body = index >= 0 ? stack.slice(index + message.length) : stack;
1909
+ const frames = body.split(`
1910
+ `).filter((line) => /^\s*at\s/.test(line)).slice(0, MAX_STACK_FRAMES).map((line) => boundedText(relativeFrame(line), MAX_FRAME_CHARS));
1911
+ return frames.length > 0 ? frames : undefined;
1912
+ }
1913
+ function describe(error, includeStack, includeMessage, depth) {
1914
+ if (typeof error !== "object" || error === null) {
1915
+ if (!includeMessage)
1916
+ return { name: "NonError" };
1917
+ return {
1918
+ name: "NonError",
1919
+ message: typeof error === "string" ? boundedText(error, MAX_MESSAGE_CHARS) : `[${typeof error}]`
1920
+ };
1921
+ }
1922
+ const rawMessage = read(error, "message");
1923
+ if (!(error instanceof Error) && typeof rawMessage !== "string") {
1924
+ return { name: "NonError", message: "[object]" };
1925
+ }
1926
+ const name = matching(read(error, "name"), NAME_PATTERN) ?? "Error";
1927
+ const message = typeof rawMessage === "string" ? rawMessage : undefined;
1928
+ const commandFailure = isCommandFailure(error, name, message);
1929
+ const stackHoldsMessage = message !== undefined && String(read(error, "stack") ?? "").includes(message);
1930
+ const details = { name };
1931
+ if (commandFailure)
1932
+ details.outputOmitted = true;
1933
+ else if (message && includeMessage)
1934
+ details.message = boundedText(message, MAX_MESSAGE_CHARS);
1935
+ const code = read(error, "code");
1936
+ const safeCode = finite(code) ?? matching(code, CODE_PATTERN);
1937
+ if (safeCode !== undefined)
1938
+ details.code = safeCode;
1939
+ const errno = finite(read(error, "errno"));
1940
+ if (errno !== undefined)
1941
+ details.errno = errno;
1942
+ const syscall = matching(read(error, "syscall"), SYSCALL_PATTERN);
1943
+ if (syscall)
1944
+ details.syscall = syscall;
1945
+ const exitCode = finite(read(error, "exitCode"));
1946
+ if (exitCode !== undefined)
1947
+ details.exitCode = exitCode;
1948
+ const signal = matching(read(error, "signal"), CODE_PATTERN);
1949
+ if (signal)
1950
+ details.signal = signal;
1951
+ if (includeStack && (!commandFailure || stackHoldsMessage || !message)) {
1952
+ const frames = stackFrames(error, message);
1953
+ if (frames)
1954
+ details.stack = frames;
1955
+ }
1956
+ const members = read(error, "errors");
1957
+ if (Array.isArray(members))
1958
+ details.errorCount = members.length;
1959
+ const cause = read(error, "cause") ?? (Array.isArray(members) ? members[0] : undefined);
1960
+ if (cause !== undefined && cause !== null && depth < MAX_CAUSE_DEPTH) {
1961
+ details.cause = describe(cause, false, includeMessage, depth + 1);
1962
+ }
1963
+ return details;
1964
+ }
1965
+ function formatLogError(error, options = {}) {
1966
+ try {
1967
+ return brand(describe(error, options.stack !== false, options.message !== false, 0));
1968
+ } catch {
1969
+ return brand({ name: "Error", message: "[unreadable]" });
1970
+ }
1971
+ }
1972
+ function logErrorKind(error) {
1973
+ if (typeof error !== "object" || error === null)
1974
+ return "NonError";
1975
+ if (!(error instanceof Error) && typeof read(error, "message") !== "string")
1976
+ return "NonError";
1977
+ const code = read(error, "code");
1978
+ const safeCode = finite(code) ?? matching(code, CODE_PATTERN);
1979
+ if (safeCode !== undefined)
1980
+ return String(safeCode);
1981
+ return matching(read(error, "name"), NAME_PATTERN) ?? "Error";
1982
+ }
1983
+
1984
+ // ../protocol/src/logger.ts
1985
+ var LOG_LEVELS = ["error", "warn", "info", "debug", "trace"];
1986
+ var MAX_FIELD_CHARS = 2048;
1987
+ var TRUNCATION_MARKER_RESERVE = 32;
1988
+ var MAX_FIELDS = 32;
1989
+ var FIELD_NAME_PATTERN = /^[A-Za-z][\w.-]{0,63}$/;
1990
+ var BARE_TEXT_VALUE = /^[\w./:@+,~-]+$/;
1991
+ var THROTTLE_KIND_PATTERN = /^[\w.:-]{1,64}$/;
1992
+ var MAX_THROTTLE_SCOPE_CHARS = 128;
1993
+ var FORBIDDEN_FIELD_NAMES = new Set([
1994
+ "stdout",
1995
+ "stderr",
1996
+ "cmd",
1997
+ "spawnargs",
1998
+ "prompt",
1999
+ "token",
2000
+ "password",
2001
+ "secret",
2002
+ "authorization",
2003
+ "apikey",
2004
+ "cookie",
2005
+ "credentials"
2006
+ ]);
2007
+ var LEVEL_RANK = {
2008
+ error: 0,
2009
+ warn: 1,
2010
+ info: 2,
2011
+ debug: 3,
2012
+ trace: 4
2013
+ };
2014
+ var OUTPUT_METHOD = {
2015
+ error: "error",
2016
+ warn: "warn",
2017
+ info: "info",
2018
+ debug: "debug",
2019
+ trace: "debug"
2020
+ };
2021
+ var consoleSink = ({ method, line }) => {
2022
+ console[method](line);
2023
+ };
2024
+ var DEFAULT_CONFIG = {
2025
+ level: "info",
2026
+ areaLevels: {},
2027
+ format: "text",
2028
+ sink: consoleSink
2029
+ };
2030
+ var config = DEFAULT_CONFIG;
2031
+ var generation = 0;
2032
+ function configureLogger(change) {
2033
+ config = { ...config, ...change };
2034
+ generation += 1;
2035
+ }
2036
+ function isLogLevel(value) {
2037
+ return typeof value === "string" && LOG_LEVELS.includes(value);
2038
+ }
2039
+ function areaSpec(area) {
2040
+ return Object.hasOwn(LOG_VOCABULARY, area) ? LOG_VOCABULARY[area] : undefined;
2041
+ }
2042
+ function thresholdRank(area) {
2043
+ for (let scope = area;; scope = scope.slice(0, scope.lastIndexOf("."))) {
2044
+ const level = Object.hasOwn(config.areaLevels, scope) ? config.areaLevels[scope] : undefined;
2045
+ if (level)
2046
+ return LEVEL_RANK[level];
2047
+ if (!scope.includes("."))
2048
+ return LEVEL_RANK[config.level];
2049
+ }
2050
+ }
2051
+ function boundedString(value, maxChars) {
2052
+ if (value.length <= maxChars)
2053
+ return value;
2054
+ const kept = maxChars - TRUNCATION_MARKER_RESERVE;
2055
+ return `${value.slice(0, kept)}...[truncated ${value.length - kept} chars]`;
2056
+ }
2057
+ function sanitizeValue(name, value, maxChars) {
2058
+ if (FORBIDDEN_FIELD_NAMES.has(name.toLowerCase().replace(/[-_.]/g, "")))
2059
+ return "[forbidden]";
2060
+ switch (typeof value) {
2061
+ case "string":
2062
+ return boundedString(value, maxChars);
2063
+ case "number":
2064
+ return Number.isFinite(value) ? value : String(value);
2065
+ case "boolean":
2066
+ return value;
2067
+ case "undefined":
2068
+ return;
2069
+ case "bigint":
2070
+ return value.toString();
2071
+ case "object":
2072
+ if (value === null)
2073
+ return null;
2074
+ if (isSafeLogError(value))
2075
+ return value;
2076
+ if (value instanceof Error)
2077
+ return formatLogError(value);
2078
+ return "[rejected:object]";
2079
+ default:
2080
+ return `[rejected:${typeof value}]`;
2081
+ }
2082
+ }
2083
+ function sanitizeFields(fields, maxChars) {
2084
+ const clean = {};
2085
+ let count = 0;
2086
+ let dropped = 0;
2087
+ for (const name of Object.keys(fields)) {
2088
+ const value = sanitizeValue(name, fields[name], maxChars);
2089
+ if (value === undefined)
2090
+ continue;
2091
+ if (count >= MAX_FIELDS || !FIELD_NAME_PATTERN.test(name)) {
2092
+ dropped += 1;
2093
+ continue;
2094
+ }
2095
+ clean[name] = value;
2096
+ count += 1;
2097
+ }
2098
+ if (dropped > 0)
2099
+ clean.droppedFields = dropped;
2100
+ return count > 0 || dropped > 0 ? clean : undefined;
2101
+ }
2102
+ function textValue(value) {
2103
+ if (typeof value !== "string")
2104
+ return String(value);
2105
+ return BARE_TEXT_VALUE.test(value) ? value : JSON.stringify(value);
2106
+ }
2107
+ function appendTextField(parts, name, value) {
2108
+ if (typeof value !== "object" || value === null) {
2109
+ parts.push(`${name}=${textValue(value)}`);
2110
+ return;
2111
+ }
2112
+ for (const key of Object.keys(value)) {
2113
+ const entry = value[key];
2114
+ if (entry === undefined)
2115
+ continue;
2116
+ if (key === "cause")
2117
+ appendTextField(parts, `${name}.cause`, entry);
2118
+ else if (key === "stack")
2119
+ parts.push(`${name}.stack=${textValue(entry.join(" | "))}`);
2120
+ else
2121
+ parts.push(`${name}.${key}=${textValue(entry)}`);
2122
+ }
2123
+ }
2124
+ function escapeLogLine(line) {
2125
+ return line.replace(/[\u007f-\u009f\u2028\u2029]/g, (character) => `\\u${character.charCodeAt(0).toString(16).padStart(4, "0")}`);
2126
+ }
2127
+ function renderText(record) {
2128
+ const tag = areaSpec(record.area)?.tag ?? record.area;
2129
+ const parts = [`[${tag}]`, record.event];
2130
+ if (record.fields) {
2131
+ for (const name of Object.keys(record.fields))
2132
+ appendTextField(parts, name, record.fields[name]);
2133
+ }
2134
+ return escapeLogLine(parts.join(" "));
2135
+ }
2136
+ function renderJson(record) {
2137
+ return escapeLogLine(JSON.stringify(record));
2138
+ }
2139
+ function deliver(record) {
2140
+ try {
2141
+ config.sink({
2142
+ method: OUTPUT_METHOD[record.level],
2143
+ line: config.format === "json" ? renderJson(record) : renderText(record),
2144
+ record
2145
+ });
2146
+ return true;
2147
+ } catch {
2148
+ return false;
2149
+ }
2150
+ }
2151
+ function buildRecord(level, area, event, fields) {
2152
+ const clean = fields ? sanitizeFields(fields, areaSpec(area)?.maxStringChars ?? MAX_FIELD_CHARS) : undefined;
2153
+ return {
2154
+ orklog: 1,
2155
+ ts: new Date().toISOString(),
2156
+ level,
2157
+ area,
2158
+ event,
2159
+ ...clean ? { fields: clean } : {}
2160
+ };
2161
+ }
2162
+ var LOG_THROTTLE_WINDOW_MS = 60000;
2163
+ var LOG_THROTTLE_MAX_KEYS = 512;
2164
+ var LOG_THROTTLE_IDLE_MS = 5 * LOG_THROTTLE_WINDOW_MS;
2165
+ var throttledSites = new Map;
2166
+ var throttledKeyCount = 0;
2167
+ var throttleRecency = 0;
2168
+ var throttleGeneration = generation;
2169
+ var nextThrottleFlushAt = 0;
2170
+ function writeThrottleLine(site, event, fields) {
2171
+ const spec = areaSpec(site.area);
2172
+ if (!spec)
2173
+ return;
2174
+ const listed = Object.hasOwn(spec.events, event);
2175
+ const line = { site: site.event, ...site.scope === undefined ? {} : { scope: site.scope } };
2176
+ deliver(buildRecord(site.level, site.area, listed ? event : "invalid-event", listed ? { ...line, ...fields } : undefined));
2177
+ }
2178
+ function syncThrottleLevels() {
2179
+ if (throttleGeneration === generation)
2180
+ return;
2181
+ throttleGeneration = generation;
2182
+ for (const [siteKey, site] of Array.from(throttledSites)) {
2183
+ if (LEVEL_RANK[site.level] <= thresholdRank(site.area))
2184
+ continue;
2185
+ throttledSites.delete(siteKey);
2186
+ throttledKeyCount -= site.keys.size;
2187
+ }
2188
+ }
2189
+ function rollThrottleWindow(site, kind, key, now) {
2190
+ const elapsed = now - key.windowStart;
2191
+ if (elapsed >= 0 && elapsed < LOG_THROTTLE_WINDOW_MS)
2192
+ return;
2193
+ if (key.pending > 0) {
2194
+ writeThrottleLine(site, "throttle.suppressed", {
2195
+ kind,
2196
+ suppressed: key.pending,
2197
+ windowSeconds: Math.max(0, Math.round(elapsed / 1000))
2198
+ });
2199
+ }
2200
+ key.pending = 0;
2201
+ key.windowStart = now;
2202
+ }
2203
+ function flushDueThrottleWindows(now) {
2204
+ if (now < nextThrottleFlushAt && nextThrottleFlushAt - now <= LOG_THROTTLE_WINDOW_MS)
2205
+ return;
2206
+ nextThrottleFlushAt = now + LOG_THROTTLE_WINDOW_MS;
2207
+ for (const site of throttledSites.values()) {
2208
+ for (const [kind, key] of site.keys)
2209
+ rollThrottleWindow(site, kind, key, now);
2210
+ }
2211
+ }
2212
+ function evictOldestThrottleKey() {
2213
+ let oldest;
2214
+ for (const [siteKey, site] of throttledSites) {
2215
+ for (const [kind, key] of site.keys) {
2216
+ if (!oldest || key.recency < oldest.key.recency)
2217
+ oldest = { siteKey, site, kind, key };
2218
+ }
2219
+ }
2220
+ if (!oldest)
2221
+ return;
2222
+ const { siteKey, site, kind, key } = oldest;
2223
+ writeThrottleLine(site, "throttle.evicted", { kind, suppressed: key.pending });
2224
+ site.keys.delete(kind);
2225
+ throttledKeyCount -= 1;
2226
+ if (site.keys.size === 0)
2227
+ throttledSites.delete(siteKey);
2228
+ }
2229
+ function throttleSiteKey(area, event, scope) {
2230
+ return `${area}\x00${event}\x00${scope ?? ""}`;
2231
+ }
2232
+ function noteThrottledFailure(area, level, event, scope, kind) {
2233
+ const now = Date.now();
2234
+ flushDueThrottleWindows(now);
2235
+ const siteKey = throttleSiteKey(area, event, scope);
2236
+ let site = throttledSites.get(siteKey);
2237
+ let known = site?.keys.get(kind);
2238
+ if (known && now - known.lastFailureAt >= LOG_THROTTLE_IDLE_MS) {
2239
+ site.keys.delete(kind);
2240
+ throttledKeyCount -= 1;
2241
+ if (site.keys.size === 0) {
2242
+ throttledSites.delete(siteKey);
2243
+ site = undefined;
2244
+ }
2245
+ known = undefined;
2246
+ }
2247
+ if (!known && throttledKeyCount >= LOG_THROTTLE_MAX_KEYS) {
2248
+ evictOldestThrottleKey();
2249
+ site = throttledSites.get(siteKey);
2250
+ }
2251
+ site ??= { area, event, scope, level, since: now, failures: 0, keys: new Map };
2252
+ site.level = level;
2253
+ site.failures += 1;
2254
+ throttledSites.delete(siteKey);
2255
+ throttledSites.set(siteKey, site);
2256
+ if (known) {
2257
+ rollThrottleWindow(site, kind, known, now);
2258
+ known.pending += 1;
2259
+ known.lastFailureAt = now;
2260
+ known.recency = ++throttleRecency;
2261
+ site.keys.delete(kind);
2262
+ site.keys.set(kind, known);
2263
+ return false;
2264
+ }
2265
+ site.keys.set(kind, {
2266
+ pending: 0,
2267
+ windowStart: now,
2268
+ lastFailureAt: now,
2269
+ recency: ++throttleRecency
2270
+ });
2271
+ throttledKeyCount += 1;
2272
+ return true;
2273
+ }
2274
+ function noteThrottledSuccess(area, event, scope) {
2275
+ const now = Date.now();
2276
+ flushDueThrottleWindows(now);
2277
+ const siteKey = throttleSiteKey(area, event, scope);
2278
+ const site = throttledSites.get(siteKey);
2279
+ if (!site)
2280
+ return;
2281
+ throttledSites.delete(siteKey);
2282
+ throttledKeyCount -= site.keys.size;
2283
+ let suppressed = 0;
2284
+ for (const key of site.keys.values())
2285
+ suppressed += key.pending;
2286
+ writeThrottleLine(site, "throttle.recovered", {
2287
+ failures: site.failures,
2288
+ kinds: site.keys.size,
2289
+ suppressed,
2290
+ faultSeconds: Math.max(0, Math.round((now - site.since) / 1000))
2291
+ });
2292
+ }
2293
+ function throttleKind(options) {
2294
+ if (options.kind === undefined)
2295
+ return logErrorKind(options.error);
2296
+ return THROTTLE_KIND_PATTERN.test(options.kind) ? options.kind : "invalid-kind";
2297
+ }
2298
+ function resolveFields(fields) {
2299
+ try {
2300
+ return typeof fields === "function" ? fields() : fields;
2301
+ } catch {
2302
+ return { fieldsFailed: true };
2303
+ }
2304
+ }
2305
+ function deliverEvent(level, area, event, fields) {
2306
+ const spec = areaSpec(area);
2307
+ if (!spec)
2308
+ return deliver(buildRecord(level, "logging", "unknown-area", undefined));
2309
+ if (!Object.hasOwn(spec.events, event))
2310
+ return deliver(buildRecord(level, area, "invalid-event", undefined));
2311
+ return deliver(buildRecord(level, area, event, fields));
2312
+ }
2313
+ function tryWriteLog(level, area, event, fields) {
2314
+ if (LEVEL_RANK[level] > thresholdRank(area))
2315
+ return false;
2316
+ return deliverEvent(level, area, event, resolveFields(fields));
2317
+ }
2318
+ function createLogger(area) {
2319
+ const spec = areaSpec(area);
2320
+ let seenGeneration = -1;
2321
+ let rank = 0;
2322
+ const enabled = (level) => {
2323
+ if (seenGeneration !== generation) {
2324
+ seenGeneration = generation;
2325
+ rank = thresholdRank(area);
2326
+ }
2327
+ return LEVEL_RANK[level] <= rank;
2328
+ };
2329
+ const writeResolved = (level, event, resolved) => {
2330
+ deliverEvent(level, area, event, resolved);
2331
+ };
2332
+ const write = (level, event, fields) => {
2333
+ if (!enabled(level))
2334
+ return;
2335
+ writeResolved(level, event, resolveFields(fields));
2336
+ };
2337
+ return {
2338
+ error: (event, fields) => write("error", event, fields),
2339
+ warn: (event, fields) => write("warn", event, fields),
2340
+ info: (event, fields) => write("info", event, fields),
2341
+ debug: (event, fields) => write("debug", event, fields),
2342
+ trace: (event, fields) => write("trace", event, fields),
2343
+ throttled: (level, event, options) => {
2344
+ syncThrottleLevels();
2345
+ if (!enabled(level))
2346
+ return;
2347
+ if (!spec || !Object.hasOwn(spec.events, event) || event.startsWith("throttle.") || !Object.hasOwn(spec.events, "throttle.recovered")) {
2348
+ deliver(buildRecord(level, spec ? area : "logging", spec ? "invalid-event" : "unknown-area", undefined));
2349
+ return;
2350
+ }
2351
+ const kind = throttleKind(options);
2352
+ const scope = options.scope?.slice(0, MAX_THROTTLE_SCOPE_CHARS);
2353
+ if (!noteThrottledFailure(area, level, event, scope, kind))
2354
+ return;
2355
+ writeResolved(level, event, {
2356
+ ...scope === undefined ? {} : { scope },
2357
+ kind,
2358
+ ...resolveFields(options.fields)
2359
+ });
2360
+ },
2361
+ recovered: (event, scope) => {
2362
+ syncThrottleLevels();
2363
+ if (throttledKeyCount === 0)
2364
+ return;
2365
+ noteThrottledSuccess(area, event, scope?.slice(0, MAX_THROTTLE_SCOPE_CHARS));
2366
+ },
2367
+ isEnabled: enabled
2368
+ };
2369
+ }
2370
+
2371
+ // ../protocol/src/log-policy.ts
2372
+ var BRIDGE_DIAGNOSTICS_LOG_AREA = "bridge.diagnostics";
2373
+ var MAX_LOG_DETAIL_AREAS = 256;
2374
+ var MAX_LOG_AREA_NAME_CHARS = 64;
2375
+ var LOG_AREA_NAME = /^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*)*$/;
2376
+ function parseLogDetail(value) {
2377
+ if (typeof value !== "object" || value === null || Array.isArray(value))
2378
+ return null;
2379
+ const { level, areaLevels } = value;
2380
+ if (!isLogLevel(level))
2381
+ return null;
2382
+ if (areaLevels === undefined)
2383
+ return { level, areaLevels: {} };
2384
+ if (typeof areaLevels !== "object" || areaLevels === null || Array.isArray(areaLevels)) {
2385
+ return null;
2386
+ }
2387
+ const names = Object.keys(areaLevels).sort();
2388
+ if (names.length > MAX_LOG_DETAIL_AREAS)
2389
+ return null;
2390
+ const clean = {};
2391
+ for (const name of names) {
2392
+ const areaLevel = areaLevels[name];
2393
+ if (name.length > MAX_LOG_AREA_NAME_CHARS || !LOG_AREA_NAME.test(name))
2394
+ return null;
2395
+ if (!isLogLevel(areaLevel))
2396
+ return null;
2397
+ clean[name] = areaLevel;
2398
+ }
2399
+ return { level, areaLevels: clean };
2400
+ }
2401
+ var LEVEL_DETAIL = {
2402
+ error: 0,
2403
+ warn: 1,
2404
+ info: 2,
2405
+ debug: 3,
2406
+ trace: 4
2407
+ };
2408
+ function effectiveLogLevel(detail, area) {
2409
+ for (let scope = area;; scope = scope.slice(0, scope.lastIndexOf("."))) {
2410
+ const level = Object.hasOwn(detail.areaLevels, scope) ? detail.areaLevels[scope] : undefined;
2411
+ if (level)
2412
+ return level;
2413
+ if (!scope.includes("."))
2414
+ return detail.level;
2415
+ }
2416
+ }
2417
+ function logDetailEnablesBridgeDiagnostics(detail) {
2418
+ return LEVEL_DETAIL[effectiveLogLevel(detail, BRIDGE_DIAGNOSTICS_LOG_AREA)] >= LEVEL_DETAIL.debug;
2419
+ }
2420
+ var BRIDGE_LOG_POLICY_ROUTE = "/debug/log-policy";
2421
+ function parseBridgeLogPolicy(value) {
2422
+ const detail = parseLogDetail(value);
2423
+ if (!detail)
2424
+ return null;
2425
+ const { seq } = value;
2426
+ return Number.isSafeInteger(seq) && seq >= 0 ? { ...detail, seq } : null;
2427
+ }
2428
+
2429
+ // ../protocol/src/node/logger-environment.ts
2430
+ var LOG_LEVEL_ENV = "ORKESTRATOR_LOG_LEVEL";
2431
+ var LOG_FORMAT_ENV = "ORKESTRATOR_LOG_FORMAT";
2432
+ var BRIDGE_LOG_RELAY_ENV = "ORKESTRATOR_BRIDGE_LOG_RELAY";
2433
+ var bridgeLogLevelOverrides = new WeakMap;
2434
+ function logLevelEnvironmentValue(env) {
2435
+ return env[LOG_LEVEL_ENV] ?? bridgeLogLevelOverrides.get(env);
2436
+ }
2437
+ function parseLogLevels(value) {
2438
+ const parsed = { areaLevels: {}, invalid: [] };
2439
+ for (const entry of (value ?? "").split(",")) {
2440
+ const trimmed = entry.trim();
2441
+ if (!trimmed)
2442
+ continue;
2443
+ const separator = trimmed.indexOf("=");
2444
+ if (separator < 0) {
2445
+ if (isLogLevel(trimmed))
2446
+ parsed.level = trimmed;
2447
+ else
2448
+ parsed.invalid.push(trimmed);
2449
+ continue;
2450
+ }
2451
+ const area = trimmed.slice(0, separator);
2452
+ const level = trimmed.slice(separator + 1);
2453
+ if (isLogLevel(level) && isKnownScope(area))
2454
+ parsed.areaLevels[area] = level;
2455
+ else
2456
+ parsed.invalid.push(trimmed);
2457
+ }
2458
+ return parsed;
2459
+ }
2460
+ function isKnownScope(scope) {
2461
+ return Object.keys(LOG_VOCABULARY).some((area) => area === scope || area.startsWith(`${scope}.`));
2462
+ }
2463
+ function configureLoggerFromEnvironment(env, options = {}) {
2464
+ const levels = parseLogLevels(env[LOG_LEVEL_ENV]);
2465
+ const requestedFormat = env[LOG_FORMAT_ENV];
2466
+ const format = options.relayToSupervisor || requestedFormat === "json" ? "json" : "text";
2467
+ configureLogger({
2468
+ ...levels.level ? { level: levels.level } : {},
2469
+ areaLevels: levels.areaLevels,
2470
+ format
2471
+ });
2472
+ const log = createLogger("logging");
2473
+ if (levels.invalid.length > 0) {
2474
+ log.warn("config.invalid", { variable: LOG_LEVEL_ENV, entries: levels.invalid.length });
2475
+ }
2476
+ if (requestedFormat && requestedFormat !== "json" && requestedFormat !== "text") {
2477
+ log.warn("config.invalid", { variable: LOG_FORMAT_ENV, entries: 1 });
2478
+ }
2479
+ }
2480
+ function configureBridgeLogger(env = process.env) {
2481
+ const relayToSupervisor = env[BRIDGE_LOG_RELAY_ENV] === "1";
2482
+ bridgeLogLevelOverrides.set(env, env[LOG_LEVEL_ENV]);
2483
+ delete env[BRIDGE_LOG_RELAY_ENV];
2484
+ configureLoggerFromEnvironment(env, { relayToSupervisor });
2485
+ delete env[LOG_FORMAT_ENV];
2486
+ delete env[LOG_LEVEL_ENV];
2487
+ }
2488
+
2489
+ // ../protocol/src/node/log-policy.ts
2490
+ function effectiveLogDetail(detail, env = process.env) {
2491
+ const overrides = parseLogLevels(logLevelEnvironmentValue(env));
2492
+ return {
2493
+ level: overrides.level ?? detail.level,
2494
+ areaLevels: { ...detail.areaLevels, ...overrides.areaLevels }
2495
+ };
2496
+ }
2497
+ function applyLogDetail(detail, env = process.env) {
2498
+ const effective = effectiveLogDetail(detail, env);
2499
+ configureLogger(effective);
2500
+ return effective;
2501
+ }
2502
+
1
2503
  // ../protocol/src/node/bridge-diagnostics.ts
2
2504
  import { createHash } from "node:crypto";
3
- var INTERVAL_MS = 60000;
2505
+
2506
+ // ../protocol/src/event-loop-stall-monitor.ts
2507
+ var log = createLogger("event-loop");
2508
+ var EVENT_LOOP_STALL_ALWAYS_LOG_MS = 1e4;
2509
+
2510
+ // ../protocol/src/node/bridge-diagnostics.ts
2511
+ var log2 = createLogger("bridge.diagnostics");
2512
+ var BRIDGE_DIAGNOSTICS_INTERVAL_MS = 60000;
2513
+ var INTERVAL_MS = BRIDGE_DIAGNOSTICS_INTERVAL_MS;
2514
+ var STALL_NO_DELTA_MS = 2 * INTERVAL_MS;
2515
+ var STALL_TOOL_PENDING_MS = 10 * 60000;
2516
+ var STALL_TICK_DELAY_MS = EVENT_LOOP_STALL_ALWAYS_LOG_MS;
2517
+ var BRIDGE_DIAGNOSTICS_KEEPALIVE_MS = 10 * 60000;
4
2518
  var MAX_PENDING_TOOLS = 128;
5
2519
  var MAX_REPORTED_TOOLS = 8;
6
2520
  var MAX_ID_LENGTH = 1024;
@@ -61,6 +2575,28 @@ var UPDATE_KINDS = new Set([
61
2575
  "step-started",
62
2576
  "step-completed"
63
2577
  ]);
2578
+ var COUNTER_CHANGE_THRESHOLDS = {
2579
+ stderrBytes: 4096,
2580
+ requestsSent: 1,
2581
+ responsesReceived: 1,
2582
+ timeouts: 1,
2583
+ notificationsReceived: Number.POSITIVE_INFINITY,
2584
+ protocolErrors: 1
2585
+ };
2586
+ var WAITING_PHASES = new Set([
2587
+ "sending",
2588
+ "following",
2589
+ "draining",
2590
+ "cancelling"
2591
+ ]);
2592
+ function sameSet(a, b) {
2593
+ if (a.size !== b.size)
2594
+ return false;
2595
+ for (const value of a)
2596
+ if (!b.has(value))
2597
+ return false;
2598
+ return true;
2599
+ }
64
2600
  function identity(value) {
65
2601
  if (typeof value !== "string" || !value || value.length > MAX_ID_LENGTH)
66
2602
  return;
@@ -69,7 +2605,16 @@ function identity(value) {
69
2605
  function readBridgeDebugFlag(value) {
70
2606
  return value?.trim() === "1";
71
2607
  }
2608
+ var liveDiagnostics;
2609
+ var liveScopes = new Set;
2610
+ function setLiveBridgeDiagnostics(enabled) {
2611
+ liveDiagnostics = enabled;
2612
+ for (const scope of Array.from(liveScopes))
2613
+ scope.syncActive();
2614
+ }
72
2615
  function bridgeDebugEnabled(bridge, env = process.env) {
2616
+ if (liveDiagnostics !== undefined && env === process.env)
2617
+ return liveDiagnostics;
73
2618
  const value = env.ORKESTRATOR_BRIDGE_DEBUG ?? env[`${bridge.toUpperCase()}_BRIDGE_DEBUG`];
74
2619
  return readBridgeDebugFlag(value);
75
2620
  }
@@ -127,18 +2672,35 @@ function safeDiagnosticMetrics(value) {
127
2672
  result.state = value.state;
128
2673
  return result;
129
2674
  }
130
- var MAX_ENTRY_BYTES = 8192;
131
- function writeDiagnostic(bridge, payload, write) {
2675
+ function bridgeDiagnosticsChangesEnabled() {
2676
+ return log2.isEnabled("trace");
2677
+ }
2678
+ function writeBridgeDiagnostic({ bridge, event, payload }) {
2679
+ return tryWriteLog("info", "bridge.diagnostics", event, { bridge, payload });
2680
+ }
2681
+ function bridgeDiagnosticsActive() {
2682
+ return log2.isEnabled("info");
2683
+ }
2684
+ function bridgeDiagnosticsStreamEnabled(bridge) {
2685
+ return bridgeDebugEnabled(bridge) || log2.isEnabled("debug");
2686
+ }
2687
+ function writeDiagnostic(bridge, event, payload, write) {
132
2688
  try {
133
- let json = JSON.stringify({ bridge, ...payload });
134
- if (Buffer.byteLength(json) > MAX_ENTRY_BYTES)
135
- json = JSON.stringify({
136
- bridge,
137
- event: "snapshot-overflow",
138
- omittedBytes: Buffer.byteLength(json)
139
- });
140
- write(`[bridge-diagnostics] ${json}`);
141
- } catch {}
2689
+ const json = JSON.stringify({ bridge, event, ...payload });
2690
+ const bytes = Buffer.byteLength(json);
2691
+ if (bytes <= MAX_BRIDGE_DIAGNOSTIC_BYTES) {
2692
+ const accepted = write({ bridge, event, payload: json });
2693
+ return accepted !== false;
2694
+ }
2695
+ const accepted = write({
2696
+ bridge,
2697
+ event: "snapshot-overflow",
2698
+ payload: JSON.stringify({ bridge, event: "snapshot-overflow", omittedBytes: bytes })
2699
+ });
2700
+ return accepted !== false;
2701
+ } catch {
2702
+ return false;
2703
+ }
142
2704
  }
143
2705
 
144
2706
  class BridgeRunDiagnostics {
@@ -148,6 +2710,7 @@ class BridgeRunDiagnostics {
148
2710
  write;
149
2711
  intervalMs;
150
2712
  metrics;
2713
+ active;
151
2714
  counters = {
152
2715
  stderrBytes: 0,
153
2716
  requestsSent: 0,
@@ -169,25 +2732,38 @@ class BridgeRunDiagnostics {
169
2732
  completedTools = 0;
170
2733
  pending = new Map;
171
2734
  phase = "sending";
2735
+ processScope = false;
172
2736
  terminal = "pending";
173
2737
  stream = "pending";
174
2738
  cancellation = "none";
175
2739
  cancelReason;
176
2740
  run;
177
2741
  closed = false;
2742
+ wasActive;
2743
+ baseline;
2744
+ changeQueued = false;
178
2745
  timer;
179
- constructor(bridge, state, now = Date.now, write = (line) => console.info(line), intervalMs = INTERVAL_MS, metrics = () => ({})) {
2746
+ constructor(bridge, state, now = Date.now, write = writeBridgeDiagnostic, intervalMs = INTERVAL_MS, metrics = () => ({}), active = () => true) {
180
2747
  this.bridge = bridge;
181
2748
  this.state = state;
182
2749
  this.now = now;
183
2750
  this.write = write;
184
2751
  this.intervalMs = intervalMs;
185
2752
  this.metrics = metrics;
2753
+ this.active = active;
186
2754
  this.startedAt = this.lastTick = now();
2755
+ this.wasActive = active();
187
2756
  this.timer = setInterval(() => this.report("heartbeat"), intervalMs);
188
2757
  this.timer.unref();
2758
+ liveScopes.add(this);
189
2759
  this.report("send-started");
190
2760
  }
2761
+ syncActive() {
2762
+ const active = this.active();
2763
+ if (active && !this.wasActive)
2764
+ this.report("heartbeat");
2765
+ this.wasActive = active;
2766
+ }
191
2767
  sent(runId) {
192
2768
  this.run = identity(runId);
193
2769
  this.phase = "following";
@@ -211,7 +2787,8 @@ class BridgeRunDiagnostics {
211
2787
  return;
212
2788
  }
213
2789
  if (stage === "completed") {
214
- this.pending.delete(key);
2790
+ if (this.pending.delete(key))
2791
+ this.changed();
215
2792
  this.completedTools++;
216
2793
  return;
217
2794
  }
@@ -226,13 +2803,23 @@ class BridgeRunDiagnostics {
226
2803
  stage: stage === "started" || existing?.stage === "started" ? "started" : "partial",
227
2804
  nested
228
2805
  });
2806
+ if (!existing)
2807
+ this.changed();
229
2808
  }
230
2809
  checkpoint(phase) {
2810
+ if (phase === "attached")
2811
+ this.processScope = true;
2812
+ if (phase === this.phase)
2813
+ return;
231
2814
  this.phase = phase;
2815
+ this.changed();
232
2816
  }
233
2817
  count(key, amount = 1) {
234
- if (!this.closed && Number.isSafeInteger(amount) && amount >= 0)
235
- this.counters[key] += amount;
2818
+ if (this.closed || !Number.isSafeInteger(amount) || amount < 0)
2819
+ return;
2820
+ this.counters[key] += amount;
2821
+ if (amount > 0 && Number.isFinite(COUNTER_CHANGE_THRESHOLDS[key]))
2822
+ this.changed();
236
2823
  }
237
2824
  translationFailed() {
238
2825
  this.translationFailures++;
@@ -248,8 +2835,10 @@ class BridgeRunDiagnostics {
248
2835
  }
249
2836
  terminalSettled(outcome) {
250
2837
  this.terminal = outcome;
251
- if (outcome === "resolved")
2838
+ if (outcome === "resolved" && this.phase !== "draining") {
252
2839
  this.phase = "draining";
2840
+ this.changed();
2841
+ }
253
2842
  }
254
2843
  requestCancellation(reason = "user") {
255
2844
  this.cancellation = "pending";
@@ -271,10 +2860,38 @@ class BridgeRunDiagnostics {
271
2860
  if (this.closed)
272
2861
  return;
273
2862
  const now = this.now();
274
- const age = (time) => time === undefined ? null : Math.max(0, now - time);
275
2863
  const tickDelayMs = event === "heartbeat" ? Math.max(0, now - this.lastTick - this.intervalMs) : 0;
276
2864
  if (event === "heartbeat")
277
2865
  this.lastTick = now;
2866
+ if (!bridgeDiagnosticsActive())
2867
+ return;
2868
+ const stall = this.stallState(now, tickDelayMs);
2869
+ if (event === "heartbeat" && !this.active() && !this.periodicDue(now, stall))
2870
+ return;
2871
+ this.writeSnapshot(event, now, tickDelayMs, stall);
2872
+ }
2873
+ changed() {
2874
+ if (this.closed || this.changeQueued || !bridgeDiagnosticsChangesEnabled())
2875
+ return;
2876
+ this.changeQueued = true;
2877
+ queueMicrotask(() => {
2878
+ this.changeQueued = false;
2879
+ this.reportChange();
2880
+ });
2881
+ }
2882
+ reportChange() {
2883
+ if (this.closed || !bridgeDiagnosticsChangesEnabled() || !bridgeDiagnosticsActive())
2884
+ return;
2885
+ const last = this.baseline;
2886
+ if (last && !this.changedSince(last))
2887
+ return;
2888
+ const now = this.now();
2889
+ try {
2890
+ this.writeSnapshot("change", now, 0, this.stallState(now, 0));
2891
+ } catch {}
2892
+ }
2893
+ writeSnapshot(event, now, tickDelayMs, stall) {
2894
+ const age = (time) => time === undefined ? null : Math.max(0, now - time);
278
2895
  const pendingTools = Array.from(this.pending.entries()).slice(0, MAX_REPORTED_TOOLS).map(([id, tool]) => ({
279
2896
  id,
280
2897
  kind: tool.kind,
@@ -283,8 +2900,7 @@ class BridgeRunDiagnostics {
283
2900
  ageMs: age(tool.since)
284
2901
  }));
285
2902
  try {
286
- writeDiagnostic(this.bridge, {
287
- event,
2903
+ const written = writeDiagnostic(this.bridge, event, {
288
2904
  session: identity(this.state.id),
289
2905
  run: this.run,
290
2906
  phase: this.phase,
@@ -311,20 +2927,120 @@ class BridgeRunDiagnostics {
311
2927
  completedTools: this.completedTools,
312
2928
  tickDelayMs
313
2929
  }, this.write);
2930
+ if (!written)
2931
+ return;
2932
+ this.baseline = {
2933
+ at: now,
2934
+ phase: this.phase,
2935
+ pending: new Set(this.pending.keys()),
2936
+ counters: { ...this.counters },
2937
+ stall
2938
+ };
314
2939
  } catch {}
315
2940
  }
2941
+ periodicDue(now, stall) {
2942
+ if (stall.signals.has("tick-delay"))
2943
+ return true;
2944
+ const last = this.baseline;
2945
+ if (!last)
2946
+ return true;
2947
+ if (!sameSet(stall.signals, last.stall.signals) || !sameSet(stall.tools, last.stall.tools))
2948
+ return true;
2949
+ if (stall.signals.has("no-delta") && this.changedSince(last))
2950
+ return true;
2951
+ return now - last.at >= BRIDGE_DIAGNOSTICS_KEEPALIVE_MS;
2952
+ }
2953
+ changedSince(last) {
2954
+ if (this.phase !== last.phase)
2955
+ return true;
2956
+ if (this.pending.size !== last.pending.size)
2957
+ return true;
2958
+ for (const key of this.pending.keys())
2959
+ if (!last.pending.has(key))
2960
+ return true;
2961
+ for (const key of Object.keys(this.counters))
2962
+ if (this.counters[key] - last.counters[key] >= COUNTER_CHANGE_THRESHOLDS[key])
2963
+ return true;
2964
+ return false;
2965
+ }
2966
+ stallState(now, tickDelayMs) {
2967
+ const signals = new Set;
2968
+ const tools = new Set;
2969
+ let oldestPending;
2970
+ for (const [key, tool] of this.pending) {
2971
+ if (oldestPending === undefined || tool.since < oldestPending)
2972
+ oldestPending = tool.since;
2973
+ if (now - tool.since >= STALL_TOOL_PENDING_MS)
2974
+ tools.add(key);
2975
+ }
2976
+ const waitingSince = this.processScope ? oldestPending : WAITING_PHASES.has(this.phase) ? this.startedAt : undefined;
2977
+ if (waitingSince !== undefined) {
2978
+ const quietSince = Math.max(this.lastDelta ?? waitingSince, waitingSince);
2979
+ if (now - quietSince >= STALL_NO_DELTA_MS)
2980
+ signals.add("no-delta");
2981
+ }
2982
+ if (tools.size > 0)
2983
+ signals.add("tool-pending");
2984
+ if (tickDelayMs >= STALL_TICK_DELAY_MS)
2985
+ signals.add("tick-delay");
2986
+ return { signals, tools };
2987
+ }
316
2988
  close(phase = "finished") {
317
2989
  if (this.closed)
318
2990
  return;
319
2991
  this.phase = phase;
320
2992
  this.report("closed");
321
2993
  this.closed = true;
2994
+ liveScopes.delete(this);
322
2995
  clearInterval(this.timer);
323
2996
  this.pending.clear();
324
2997
  }
325
2998
  }
326
2999
  function createBridgeDiagnostics(bridge, state, metrics) {
327
- return bridgeDebugEnabled(bridge) ? new BridgeRunDiagnostics(bridge, state, undefined, undefined, undefined, metrics) : undefined;
3000
+ return new BridgeRunDiagnostics(bridge, state, undefined, undefined, undefined, metrics, () => bridgeDiagnosticsStreamEnabled(bridge));
3001
+ }
3002
+ var bufferedFlushes = new Set;
3003
+
3004
+ // ../protocol/src/node/bridge-log-policy.ts
3005
+ var MAX_BRIDGE_LOG_POLICY_BYTES = 64 * 1024;
3006
+ var appliedSeq = -1;
3007
+ function applyBridgeLogPolicy(value, env = process.env) {
3008
+ const policy = parseBridgeLogPolicy(value);
3009
+ if (!policy)
3010
+ return { status: 400, body: { error: "Invalid log policy" } };
3011
+ if (policy.seq < appliedSeq) {
3012
+ return { status: 200, body: { applied: false, stale: true, seq: appliedSeq } };
3013
+ }
3014
+ appliedSeq = policy.seq;
3015
+ const effective = applyLogDetail(policy, env);
3016
+ const diagnostics = logDetailEnablesBridgeDiagnostics(effective);
3017
+ setLiveBridgeDiagnostics(diagnostics);
3018
+ return { status: 200, body: { applied: true, seq: policy.seq, diagnostics } };
3019
+ }
3020
+ async function readBridgeLogPolicyBody(request) {
3021
+ if (!request.body)
3022
+ return null;
3023
+ const chunks = [];
3024
+ let bytes = 0;
3025
+ const reader = request.body.getReader();
3026
+ try {
3027
+ for (;; ) {
3028
+ const { done, value } = await reader.read();
3029
+ if (done)
3030
+ break;
3031
+ bytes += value.byteLength;
3032
+ if (bytes > MAX_BRIDGE_LOG_POLICY_BYTES)
3033
+ return null;
3034
+ chunks.push(value);
3035
+ }
3036
+ return JSON.parse(Buffer.concat(chunks).toString("utf8"));
3037
+ } catch {
3038
+ return null;
3039
+ } finally {
3040
+ await reader.cancel().catch(() => {
3041
+ return;
3042
+ });
3043
+ }
328
3044
  }
329
3045
 
330
3046
  // ../../bridges/codex-bridge/src/index.ts
@@ -4014,6 +6730,7 @@ var AGENT_INTERACTION_LIMITS = Object.freeze({
4014
6730
  maxSerializedPayloadBytes: 256 * 1024,
4015
6731
  maxIdLength: 512,
4016
6732
  maxProviderValueLength: 4096,
6733
+ maxSourceNameLength: 256,
4017
6734
  maxJournalEntries: 512,
4018
6735
  maxWorkflowSummaries: 64
4019
6736
  });
@@ -4081,6 +6798,19 @@ var LIMITED_HOLD_REASONS = new Set([
4081
6798
  "provider-limit",
4082
6799
  "upstream-may-expire"
4083
6800
  ]);
6801
+ var AGENT_INTERACTION_SOURCE_KINDS = ["mcp-server"];
6802
+ var SOURCE_SCOPE_LABELS = Object.freeze({
6803
+ user: "user settings",
6804
+ project: "project settings",
6805
+ local: "local settings",
6806
+ dynamic: "session settings",
6807
+ plugin: "a plugin",
6808
+ managed: "managed settings",
6809
+ enterprise: "enterprise settings",
6810
+ claudeai: "a claude.ai connector",
6811
+ agent: "an agent definition",
6812
+ sdk: "the agent host"
6813
+ });
4084
6814
  var UNATTENDED_POLICY_INSTRUCTION = "This is a non-interactive build session: no user can answer a provider input request. " + "If input is unavailable or declined, choose the safest likely assumption yourself, " + "state that assumption, and continue. Never treat the absence of a person as authorization.";
4085
6815
  var INTERACTIVE_AGENT_INTERACTION_POLICY = Object.freeze({
4086
6816
  version: AGENT_INTERACTION_POLICY_VERSION,
@@ -4156,8 +6886,11 @@ var REQUEST_KEYS = new Set([
4156
6886
  "createdAt",
4157
6887
  "updatedAt",
4158
6888
  "expiresAt",
4159
- "hold"
6889
+ "hold",
6890
+ "source"
4160
6891
  ]);
6892
+ var SOURCE_KEYS = new Set(["kind", "name", "scope"]);
6893
+ var SOURCE_KINDS = new Set(AGENT_INTERACTION_SOURCE_KINDS);
4161
6894
  var HOLD_KEYS = new Set(["available", "heldAt", "reason"]);
4162
6895
  var HOLD_REASONS = new Set(AGENT_INTERACTION_HOLD_REASONS);
4163
6896
  var PRESENTATION_KEYS = new Set([
@@ -8954,6 +11687,7 @@ function toBridgeModel(model) {
8954
11687
  }
8955
11688
  // ../protocol/src/human-prompts.ts
8956
11689
  var HUMAN_PROMPT_SCAN_BYTES = 16 * 1024;
11690
+ var HUMAN_PROMPT_OBSERVATION_ROWS = 64;
8957
11691
  function humanPromptObservation(messages, tasks) {
8958
11692
  const object = (value) => !!value && typeof value === "object" && !Array.isArray(value);
8959
11693
  const parts = [];
@@ -8987,7 +11721,7 @@ function humanPromptObservation(messages, tasks) {
8987
11721
  }
8988
11722
  };
8989
11723
  if (Array.isArray(messages)) {
8990
- for (let i = messages.length - 1;i >= Math.max(0, messages.length - 64); i--) {
11724
+ for (let i = messages.length - 1;i >= Math.max(0, messages.length - HUMAN_PROMPT_OBSERVATION_ROWS); i--) {
8991
11725
  const message = messages[i];
8992
11726
  if (object(message))
8993
11727
  walk(message.parts);
@@ -13153,6 +15887,7 @@ var COORDINATOR_CONTROL_TOOL_NAMES = Object.freeze([
13153
15887
  "update_schedule",
13154
15888
  "update_ticket"
13155
15889
  ]);
15890
+ var COORDINATOR_PROJECT_HOME_MESSAGE_WINDOW_MS = 3 * 60 * 60000;
13156
15891
  var COORDINATOR_CONTEXT_OPEN_TAG = "<orkestrator-coordinator-context>";
13157
15892
  var COORDINATOR_CONTEXT_CLOSE_TAG = "</orkestrator-coordinator-context>";
13158
15893
  function stripCoordinatorContext(text) {
@@ -13237,6 +15972,7 @@ function parseCapacityRetryContinuation(text) {
13237
15972
  }
13238
15973
 
13239
15974
  // ../../bridges/codex-bridge/src/history/rollout.ts
15975
+ var log3 = createLogger("bridge.codex");
13240
15976
  function getCodexHomeDir() {
13241
15977
  return process.env.CODEX_HOME || join11(homedir(), ".codex");
13242
15978
  }
@@ -13838,7 +16574,7 @@ async function hydrateMessagesFromPersistedSession(threadId, options = {}) {
13838
16574
  };
13839
16575
  }
13840
16576
  }
13841
- console.warn(`[codex-bridge] Rollout for thread ${threadId} could not be read for hydration`);
16577
+ log3.warn("rollout.hydrate-failed", { threadId });
13842
16578
  return {
13843
16579
  messages: [],
13844
16580
  title: meta.title,
@@ -14327,6 +17063,7 @@ async function replayPersistedRollout(threadId, snapshot, meta, structuredTurns)
14327
17063
  }
14328
17064
 
14329
17065
  // ../../bridges/codex-bridge/src/messages/render-turn.ts
17066
+ var log4 = createLogger("bridge.codex");
14330
17067
  var TRUNCATION_NOTICE = `
14331
17068
  … output truncated`;
14332
17069
  var SUBAGENT_TRANSCRIPT_PROBE_INTERVAL_MS = 2000;
@@ -14743,7 +17480,7 @@ async function renderTurn(turn, options) {
14743
17480
  loadSnapshot = latestSnapshot;
14744
17481
  }
14745
17482
  } catch (error) {
14746
- console.error("[codex-bridge] Failed to load sub-agent activity:", error);
17483
+ log4.warn("subagent.activity-load-failed", { error: formatLogError(error) });
14747
17484
  }
14748
17485
  }
14749
17486
  const { items, itemsByKey, accumulatorsByKey, itemKeys } = collectTurnItems(turn, options.segment);
@@ -15521,6 +18258,7 @@ function extractThreadId(params) {
15521
18258
  }
15522
18259
 
15523
18260
  // ../../bridges/codex-bridge/src/app-server/jsonl-rpc-client.ts
18261
+ var log5 = createLogger("bridge.codex");
15524
18262
  var DEFAULT_MAX_INBOUND_LINE_BYTES = 64 * 1024 * 1024;
15525
18263
  var DEFAULT_MAX_OUTBOUND_LINE_BYTES = 32 * 1024 * 1024;
15526
18264
  var DEFAULT_REQUEST_TIMEOUT_MS = 60000;
@@ -15632,7 +18370,7 @@ class JsonlRpcClient {
15632
18370
  try {
15633
18371
  this.options.recordInboundLine(line);
15634
18372
  } catch (error) {
15635
- console.error("[codex-bridge] notification recorder threw:", error);
18373
+ log5.error("recorder.threw", { error: formatLogError(error) });
15636
18374
  }
15637
18375
  }
15638
18376
  const message = parseInboundLine(line);
@@ -15664,7 +18402,7 @@ class JsonlRpcClient {
15664
18402
  try {
15665
18403
  this.options.onServerRequest(message);
15666
18404
  } catch (error) {
15667
- console.error("[codex-bridge] server-request handoff threw:", error);
18405
+ log5.error("server-request.handoff-failed", { error: formatLogError(error) });
15668
18406
  }
15669
18407
  return;
15670
18408
  }
@@ -15673,7 +18411,7 @@ class JsonlRpcClient {
15673
18411
  try {
15674
18412
  this.options.onNotification(message, extractThreadId(message.params));
15675
18413
  } catch (error) {
15676
- console.error("[codex-bridge] notification enqueue threw:", error);
18414
+ log5.error("notification.enqueue-failed", { error: formatLogError(error) });
15677
18415
  }
15678
18416
  return;
15679
18417
  }
@@ -15845,7 +18583,7 @@ class SerialQueue {
15845
18583
  this.maxObservedDepth = Math.max(this.maxObservedDepth, this.depth);
15846
18584
  const previous = this.chains.get(key) ?? Promise.resolve();
15847
18585
  const next = previous.then(() => task()).catch((error) => {
15848
- console.error(`[codex-bridge] queued task for ${key} failed:`, error);
18586
+ log5.error("queue.task-failed", { key, error: formatLogError(error) });
15849
18587
  }).finally(() => {
15850
18588
  this.depth -= 1;
15851
18589
  if (this.chains.get(key) === next)
@@ -15868,6 +18606,10 @@ class SerialQueue {
15868
18606
  // ../../bridges/codex-bridge/src/app-server/notification-recorder.ts
15869
18607
  import { appendFile as appendFile4, mkdir as mkdir5 } from "node:fs/promises";
15870
18608
  import { join as join13 } from "node:path";
18609
+ var log6 = createLogger("bridge.codex");
18610
+ function recorderNotice(message) {
18611
+ log6.warn("recorder.notice", { detail: message });
18612
+ }
15871
18613
  var DEFAULT_MAX_RECORDING_BYTES = 64 * 1024 * 1024;
15872
18614
  var DEFAULT_FLUSH_INTERVAL_MS = 250;
15873
18615
  var DEFAULT_WARN_INTERVAL_MS = 60000;
@@ -15901,7 +18643,7 @@ class NotificationRecorder {
15901
18643
  this.ensureDirImpl = options.ensureDirImpl ?? ((path) => mkdir5(path, { recursive: true }).then(() => {
15902
18644
  return;
15903
18645
  }));
15904
- this.warnImpl = options.warnImpl ?? ((message) => console.error(message));
18646
+ this.warnImpl = options.warnImpl ?? recorderNotice;
15905
18647
  this.now = options.now ?? Date.now;
15906
18648
  this.stats = {
15907
18649
  fileName: options.fileName,
@@ -15957,7 +18699,7 @@ class NotificationRecorder {
15957
18699
  if (this.lastWarnedAt !== null && now - this.lastWarnedAt < this.warnIntervalMs)
15958
18700
  return;
15959
18701
  this.lastWarnedAt = now;
15960
- this.warnImpl(`[codex-bridge] RECORDING app-server notifications to ${this.path} ` + `(${this.stats.linesRecorded} lines). Prompts, file contents and absolute paths ` + "are written verbatim. Unset CODEX_BRIDGE_RECORD_NOTIFICATIONS to stop.");
18702
+ this.warnImpl(`RECORDING app-server notifications to ${this.path} ` + `(${this.stats.linesRecorded} lines). Prompts, file contents and absolute paths ` + "are written verbatim. Unset CODEX_BRIDGE_RECORD_NOTIFICATIONS to stop.");
15961
18703
  }
15962
18704
  async flushOnce() {
15963
18705
  if (this.buffer.length === 0)
@@ -15979,7 +18721,7 @@ class NotificationRecorder {
15979
18721
  } catch (error) {
15980
18722
  this.stats.writeErrors += 1;
15981
18723
  this.stats.linesDropped += pending.length;
15982
- console.error(`[codex-bridge] Failed to write notification recording: ${String(error)}`);
18724
+ log6.error("recorder.write-failed", { error: formatLogError(error, { stack: false }) });
15983
18725
  }
15984
18726
  }
15985
18727
  async close() {
@@ -15993,12 +18735,12 @@ class NotificationRecorder {
15993
18735
  }
15994
18736
  function createRecorderFromEnv(options) {
15995
18737
  const env = options.env ?? process.env;
15996
- const warn = options.warn ?? ((message) => console.error(message));
18738
+ const warn = options.warn ?? recorderNotice;
15997
18739
  const directory = env.CODEX_BRIDGE_RECORD_NOTIFICATIONS?.trim();
15998
18740
  if (!directory)
15999
18741
  return null;
16000
18742
  if (env[RECORD_CONFIRM_ENV]?.trim() !== "1") {
16001
- warn(`[codex-bridge] Ignoring CODEX_BRIDGE_RECORD_NOTIFICATIONS=${directory}: recordings ` + "capture every prompt, file content and absolute path verbatim, so they also " + `require ${RECORD_CONFIRM_ENV}=1. Not recording.`);
18743
+ warn(`Ignoring CODEX_BRIDGE_RECORD_NOTIFICATIONS=${directory}: recordings ` + "capture every prompt, file content and absolute path verbatim, so they also " + `require ${RECORD_CONFIRM_ENV}=1. Not recording.`);
16002
18744
  return null;
16003
18745
  }
16004
18746
  const stamp = new Date(options.now?.() ?? Date.now()).toISOString().replace(/[:.]/g, "-");
@@ -16014,6 +18756,7 @@ function createRecorderFromEnv(options) {
16014
18756
  import { execFile as execFileCallback } from "node:child_process";
16015
18757
  import { createHash as createHash8 } from "node:crypto";
16016
18758
  import { promisify } from "node:util";
18759
+ var log7 = createLogger("bridge.codex");
16017
18760
  var execFile2 = promisify(execFileCallback);
16018
18761
  var RUNTIME_ENV_SCRIPT_ENV = "ORKESTRATOR_RUNTIME_ENV_SCRIPT";
16019
18762
  var DEFAULT_RUNTIME_ENV_SCRIPT = "/usr/local/bin/orkestrator-runtime-env.sh";
@@ -16091,10 +18834,10 @@ async function refreshRuntimeEnvironment(run = execFile2) {
16091
18834
  });
16092
18835
  const updated = applyRuntimeEnvironmentOutput(stdout);
16093
18836
  if (updated.length > 0) {
16094
- console.error("[codex-bridge] Refreshed runtime environment:", updated.join(", "));
18837
+ log7.info("runtime-env.refreshed", { names: updated.join(", ") });
16095
18838
  }
16096
18839
  } catch (error) {
16097
- console.error("[codex-bridge] Failed to refresh runtime environment:", error);
18840
+ log7.warn("runtime-env.refresh-failed", { error: formatLogError(error) });
16098
18841
  }
16099
18842
  }
16100
18843
  function fingerprintRuntimeEnvironment(env = process.env) {
@@ -16114,6 +18857,8 @@ function runtimeEnvironmentSnapshot(env = process.env) {
16114
18857
  }
16115
18858
 
16116
18859
  // ../../bridges/codex-bridge/src/app-server/process-supervisor.ts
18860
+ var log8 = createLogger("bridge.codex");
18861
+
16117
18862
  class AppServerOwnershipUnavailableError extends AppServerUnavailableError {
16118
18863
  ownershipContention = true;
16119
18864
  constructor(detail) {
@@ -16393,7 +19138,10 @@ class AppServerSupervisor {
16393
19138
  if (describedLines >= STDERR_METADATA_LINE_BUDGET)
16394
19139
  return;
16395
19140
  describedLines += 1;
16396
- console.error(`[codex-bridge][app-server:${generationId}] stderr ${describeChildStderrLine(line)}`);
19141
+ log8.info("app-server.stderr", () => ({
19142
+ generation: generationId,
19143
+ detail: describeChildStderrLine(line)
19144
+ }));
16397
19145
  };
16398
19146
  child.stderr?.setEncoding?.("utf8");
16399
19147
  child.stderr?.on("data", (chunk) => {
@@ -16414,13 +19162,20 @@ class AppServerSupervisor {
16414
19162
  stderrTail = "";
16415
19163
  if (suppressedLines === 0)
16416
19164
  return;
16417
- console.error(`[codex-bridge][app-server:${generationId}] suppressed ${suppressedLines} stderr line(s) (${suppressedBytes} bytes of payload)`);
19165
+ log8.info("app-server.stderr-suppressed", {
19166
+ generation: generationId,
19167
+ lines: suppressedLines,
19168
+ payloadBytes: suppressedBytes
19169
+ });
16418
19170
  suppressedLines = 0;
16419
19171
  suppressedBytes = 0;
16420
19172
  };
16421
19173
  const recorder = (this.options.createRecorder ?? ((generation) => createRecorderFromEnv({ generation })))(generationId);
16422
19174
  if (recorder) {
16423
- console.error(`[codex-bridge][app-server:${generationId}] recording notifications to ${recorder.getStats().fileName}`);
19175
+ log8.warn("app-server.recording", {
19176
+ generation: generationId,
19177
+ fileName: recorder.getStats().fileName
19178
+ });
16424
19179
  }
16425
19180
  const client = new JsonlRpcClient({
16426
19181
  generation: generationId,
@@ -16430,7 +19185,7 @@ class AppServerSupervisor {
16430
19185
  onServerRequest: (request) => this.options.onServerRequest(request, generationId),
16431
19186
  onProtocolViolation: (detail) => {
16432
19187
  this.unknownNotifications += 1;
16433
- console.error(`[codex-bridge][app-server:${generationId}] protocol: ${detail}`);
19188
+ log8.warn("app-server.protocol-violation", { generation: generationId, detail });
16434
19189
  },
16435
19190
  ...recorder ? { recordInboundLine: (line) => recorder.record(line) } : {}
16436
19191
  });
@@ -16508,7 +19263,13 @@ class AppServerSupervisor {
16508
19263
  return;
16509
19264
  const exited = this.current;
16510
19265
  this.current = null;
16511
- console.error(`[codex-bridge][app-server:${generationId}] exited unexpectedly (code=${code ?? "null"}, signal=${signal ?? "null"}, pid=${exited.child.pid ?? "unknown"}, uptimeMs=${Math.max(0, this.now() - exited.startedAt)})`);
19266
+ log8.warn("app-server.exited", {
19267
+ generation: generationId,
19268
+ code,
19269
+ signal,
19270
+ pid: exited.child.pid,
19271
+ uptimeMs: Math.max(0, this.now() - exited.startedAt)
19272
+ });
16512
19273
  this.options.onGenerationExit?.(generationId);
16513
19274
  if (this.stopping) {
16514
19275
  this.setState("stopped");
@@ -16766,7 +19527,7 @@ class AppServerSupervisor {
16766
19527
  if (outcome === "contended")
16767
19528
  return true;
16768
19529
  if (matches && pid !== null) {
16769
- console.error(`[codex-bridge] Reaping stale app-server pid ${pid}`);
19530
+ log8.info("app-server.stale-reaped", { pid });
16770
19531
  (this.options.signalPidFileProcess ?? signalStaleProcessTree)(pid);
16771
19532
  }
16772
19533
  return true;
@@ -17443,6 +20204,7 @@ function buildInteractionResponse(request, answer) {
17443
20204
  }
17444
20205
 
17445
20206
  // ../../bridges/codex-bridge/src/app-server/server-request-router.ts
20207
+ var log9 = createLogger("bridge.codex");
17446
20208
  var DEFAULT_RESPONSE_TIMEOUT_MS = 1e4;
17447
20209
  var DEFAULT_APPROVAL_TIMEOUT_MS = AGENT_INTERACTION_DEFAULT_TIMEOUT_MS;
17448
20210
 
@@ -17602,7 +20364,10 @@ class ServerRequestRouter {
17602
20364
  record.timedOut = true;
17603
20365
  this.counts.timedOut += 1;
17604
20366
  if (this.sendStarted.has(key)) {
17605
- console.error(`[codex-bridge] Response to ${record.method} has not flushed within ${this.responseTimeoutMs}ms`);
20367
+ log9.error("server-request.flush-timeout", {
20368
+ method: record.method,
20369
+ timeoutMs: this.responseTimeoutMs
20370
+ });
17606
20371
  return;
17607
20372
  }
17608
20373
  this.finish(key, record, "protocol-error", () => this.options.respondWithError(generation, request.id, JSON_RPC_METHOD_NOT_FOUND, "Orkestrator did not produce a response in time"));
@@ -17703,7 +20468,7 @@ class ServerRequestRouter {
17703
20468
  accepted = this.options.presentApproval?.(approval) === true;
17704
20469
  } catch (error) {
17705
20470
  deadline.settle();
17706
- console.error("[codex-bridge] presentApproval threw; falling back to auto-decline:", error);
20471
+ log9.error("approval.present-failed", { error: formatLogError(error) });
17707
20472
  return false;
17708
20473
  }
17709
20474
  if (!accepted) {
@@ -17740,7 +20505,7 @@ class ServerRequestRouter {
17740
20505
  try {
17741
20506
  this.options.onApprovalResolved?.(parked.request, decision, resolution);
17742
20507
  } catch (error) {
17743
- console.error("[codex-bridge] onApprovalResolved threw:", error);
20508
+ log9.error("approval.resolved-callback-failed", { error: formatLogError(error) });
17744
20509
  }
17745
20510
  if (options.skipSend) {
17746
20511
  this.pending.delete(parked.key);
@@ -17761,7 +20526,7 @@ class ServerRequestRouter {
17761
20526
  try {
17762
20527
  this.options.onApprovalResolved?.(parked.request, "withdrawn", "withdrawn");
17763
20528
  } catch (error) {
17764
- console.error("[codex-bridge] onApprovalResolved threw:", error);
20529
+ log9.error("approval.resolved-callback-failed", { error: formatLogError(error) });
17765
20530
  }
17766
20531
  this.pending.delete(parked.key);
17767
20532
  this.sendStarted.delete(parked.key);
@@ -17803,7 +20568,7 @@ class ServerRequestRouter {
17803
20568
  accepted = this.options.presentInteraction?.(interaction) === true;
17804
20569
  } catch (error) {
17805
20570
  deadline?.settle();
17806
- console.error("[codex-bridge] presentInteraction threw; cancelling:", error);
20571
+ log9.error("interaction.present-failed", { error: formatLogError(error) });
17807
20572
  return false;
17808
20573
  }
17809
20574
  if (!accepted) {
@@ -17839,7 +20604,7 @@ class ServerRequestRouter {
17839
20604
  try {
17840
20605
  this.options.onInteractionResolved?.(parked.request, answer, resolution);
17841
20606
  } catch (error) {
17842
- console.error("[codex-bridge] onInteractionResolved threw:", error);
20607
+ log9.error("interaction.resolved-callback-failed", { error: formatLogError(error) });
17843
20608
  }
17844
20609
  if (options.skipSend) {
17845
20610
  this.pending.delete(parked.key);
@@ -17872,7 +20637,10 @@ class ServerRequestRouter {
17872
20637
  try {
17873
20638
  await send();
17874
20639
  } catch (error) {
17875
- console.error(`[codex-bridge] Failed to answer server request ${record.method}:`, error instanceof Error ? error.message : error);
20640
+ log9.error("server-request.answer-failed", {
20641
+ method: record.method,
20642
+ error: formatLogError(error, { stack: false })
20643
+ });
17876
20644
  } finally {
17877
20645
  this.pending.delete(key);
17878
20646
  this.sendStarted.delete(key);
@@ -17886,7 +20654,7 @@ class ServerRequestRouter {
17886
20654
  }
17887
20655
  violation(method, detail) {
17888
20656
  this.options.onInvariantViolation?.(method, detail);
17889
- console.error(`[codex-bridge] app-server invariant violation (${method}): ${detail}`);
20657
+ log9.error("app-server.invariant-violation", { method, detail });
17890
20658
  }
17891
20659
  explain(record, message) {
17892
20660
  this.options.reportToTranscript?.({
@@ -18471,41 +21239,6 @@ function reduceHistoricalTurns(turns, generation, threadId, handle) {
18471
21239
  return { events, unsupportedItemTypes };
18472
21240
  }
18473
21241
 
18474
- // ../protocol/src/secret-redaction.ts
18475
- var TEXT_RULES = [
18476
- {
18477
- pattern: /([a-z][a-z0-9+.-]*:\/\/)[^/\s:@]+(?::[^/\s@]*)?@/gi,
18478
- replacement: "$1[redacted]@"
18479
- },
18480
- {
18481
- pattern: /([?&](?:access[_-]?token|refresh[_-]?token|id[_-]?token|api[_-]?key|apikey|auth|authorization|token|secret|password|passwd|signature|sig|key|state|code)=)[^&\s"'`]+/gi,
18482
- replacement: "$1[redacted]"
18483
- },
18484
- { pattern: /\bBearer\s+[A-Za-z0-9._~+/=-]{8,}/gi, replacement: "Bearer [redacted]" },
18485
- { pattern: /\bBasic\s+[A-Za-z0-9+/=]{8,}/gi, replacement: "Basic [redacted]" },
18486
- {
18487
- pattern: /\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}/g,
18488
- replacement: "[redacted]"
18489
- },
18490
- { pattern: /\bgh[pousr]_[A-Za-z0-9]{16,}/g, replacement: "[redacted]" },
18491
- { pattern: /\bgithub_pat_[A-Za-z0-9_]{20,}/g, replacement: "[redacted]" },
18492
- { pattern: /\b(?:sk|rk|pk)-[A-Za-z0-9_-]{12,}/g, replacement: "[redacted]" },
18493
- { pattern: /\bxox[baprse]-[A-Za-z0-9-]{8,}/g, replacement: "[redacted]" },
18494
- { pattern: /\bAKIA[0-9A-Z]{12,}/g, replacement: "[redacted]" },
18495
- { pattern: /\bAIza[0-9A-Za-z_-]{20,}/g, replacement: "[redacted]" },
18496
- {
18497
- 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,
18498
- replacement: "$1$2[redacted]"
18499
- }
18500
- ];
18501
- function redactSecrets(value) {
18502
- let result = value;
18503
- for (const rule of TEXT_RULES) {
18504
- result = result.replace(new RegExp(rule.pattern.source, rule.pattern.flags), rule.replacement);
18505
- }
18506
- return result;
18507
- }
18508
-
18509
21242
  // ../../bridges/codex-bridge/src/sessions/dispatch-journal.ts
18510
21243
  import { createHash as createHash10 } from "node:crypto";
18511
21244
  import { mkdir as mkdir8, open as open6, rename as rename6, rm as rm7, writeFile as writeFile5 } from "node:fs/promises";
@@ -18525,6 +21258,7 @@ import {
18525
21258
  writeFile as writeFile4
18526
21259
  } from "node:fs/promises";
18527
21260
  import { join as join15 } from "node:path";
21261
+ var log10 = createLogger("bridge.codex");
18528
21262
  var BRIDGE_SESSION_REGISTRY_VERSION = 2;
18529
21263
  var SESSION_TITLE_SOURCES = new Set([
18530
21264
  "codex",
@@ -18824,7 +21558,7 @@ class BridgeSessionStore {
18824
21558
  await chmod(path, PRIVATE_FILE_MODE);
18825
21559
  }
18826
21560
  warnPersistenceFailure(error) {
18827
- console.warn("[codex-bridge] Failed to persist bridge session registry:", error instanceof Error ? error.message : error);
21561
+ log10.warn("registry.persist-failed", { error: formatLogError(error, { stack: false }) });
18828
21562
  }
18829
21563
  toRecord(options) {
18830
21564
  const { agentMcp: _agentMcp, ...persistedConfig } = options.config;
@@ -18848,6 +21582,7 @@ class BridgeSessionStore {
18848
21582
  }
18849
21583
 
18850
21584
  // ../../bridges/codex-bridge/src/sessions/dispatch-journal.ts
21585
+ var log11 = createLogger("bridge.codex");
18851
21586
  var DISPATCH_JOURNAL_VERSION = 1;
18852
21587
  var DISPATCH_COMPLETENESS_VERSION = 1;
18853
21588
  var MAX_FRESH_SESSION_MARKERS = 256;
@@ -19386,7 +22121,7 @@ class DispatchJournal {
19386
22121
  throw error;
19387
22122
  });
19388
22123
  } catch (error) {
19389
- console.warn("[codex-bridge] Failed to persist dispatch journal:", error instanceof Error ? error.message : error);
22124
+ log11.warn("journal.persist-failed", { error: formatLogError(error, { stack: false }) });
19390
22125
  if (options.failClosed)
19391
22126
  throw error;
19392
22127
  }
@@ -20051,6 +22786,7 @@ var APP_SERVER_CAPABILITIES = {
20051
22786
  };
20052
22787
 
20053
22788
  // ../../bridges/codex-bridge/src/engine/app-server-engine.ts
22789
+ var log12 = createLogger("bridge.codex");
20054
22790
  var AGENT_MAIL_TOOL_APPROVALS = Object.fromEntries([
20055
22791
  ...AGENT_MAIL_TOOL_NAMES,
20056
22792
  ...ARTIFACT_TOOL_NAMES,
@@ -20634,7 +23370,7 @@ class AppServerEngine {
20634
23370
  try {
20635
23371
  listener(event);
20636
23372
  } catch (error) {
20637
- console.error("[codex-bridge] app-server engine listener failed:", error);
23373
+ log12.error("engine.listener-failed", { error: formatLogError(error) });
20638
23374
  }
20639
23375
  }
20640
23376
  }
@@ -20759,7 +23495,9 @@ class AppServerEngine {
20759
23495
  const sequence = ++this.accountCheckSequence;
20760
23496
  const generation = this.supervisor.getGeneration();
20761
23497
  this.supervisor.request("account/read", { refreshToken }).catch(signedOutAccountRead).then((response) => this.applyAccountRead(response, sequence, generation, accountReplaced)).catch((error) => {
20762
- console.warn("[codex-bridge] Account sign-in check failed:", redactSecrets(error instanceof Error ? error.message : String(error)));
23498
+ log12.warn("account.sign-in-check-failed", {
23499
+ error: formatLogError(error, { stack: false })
23500
+ });
20763
23501
  });
20764
23502
  }
20765
23503
  async applyAccountRead(response, sequence, generation, accountChanged) {
@@ -21344,7 +24082,9 @@ class AppServerEngine {
21344
24082
  const generation = this.supervisor.getGeneration();
21345
24083
  const response = await this.supervisor.request("account/read", { refreshToken: false }).catch(signedOutAccountRead);
21346
24084
  this.applyAccountRead(response, sequence, generation, false).catch((error) => {
21347
- console.warn("[codex-bridge] Account connector recovery failed:", redactSecrets(error instanceof Error ? error.message : String(error)));
24085
+ log12.warn("account.connector-recovery-failed", {
24086
+ error: formatLogError(error, { stack: false })
24087
+ });
21348
24088
  });
21349
24089
  const pendingSignIn = normalizePendingSignIn(this.pendingSignIn?.display);
21350
24090
  if (!pendingSignIn && this.pendingSignIn) {
@@ -21555,7 +24295,7 @@ class AppServerEngine {
21555
24295
  await this.supervisor.request("thread/name/set", { threadId, name });
21556
24296
  return true;
21557
24297
  } catch (error) {
21558
- console.warn("[codex-bridge] thread/name/set failed:", error instanceof Error ? error.message : error);
24298
+ log12.warn("thread.rename-failed", { error: formatLogError(error, { stack: false }) });
21559
24299
  return false;
21560
24300
  }
21561
24301
  }
@@ -21575,7 +24315,7 @@ class AppServerEngine {
21575
24315
  } catch (error) {
21576
24316
  if (requireConfirmation)
21577
24317
  throw error;
21578
- console.warn("[codex-bridge] thread/unsubscribe failed:", error instanceof Error ? error.message : error);
24318
+ log12.warn("thread.unsubscribe-failed", { error: formatLogError(error, { stack: false }) });
21579
24319
  }
21580
24320
  this.accountProofTurns.delete(threadId);
21581
24321
  this.rolloutPaths.delete(threadId);
@@ -22117,6 +24857,7 @@ function externalRevertCut(messages, survivingTurnIds, running) {
22117
24857
  }
22118
24858
 
22119
24859
  // ../../bridges/codex-bridge/src/app-server-runtime-sessions.ts
24860
+ var log13 = createLogger("bridge.codex");
22120
24861
  var SESSION_CLOSING_ERROR = "Session is closing";
22121
24862
  var ACTIVITY_PROCESS = randomUUID8();
22122
24863
 
@@ -22243,7 +24984,10 @@ class CodexRuntimeSessions {
22243
24984
  try {
22244
24985
  fork = await this.ctx.options.engine.forkThread(parent.threadId, parent.config, lastTurnId);
22245
24986
  } catch (error) {
22246
- console.warn(`[codex-bridge] thread/fork failed for ${parent.threadId}:`, error instanceof Error ? error.message : error);
24987
+ log13.warn("thread.fork-failed", {
24988
+ threadId: parent.threadId,
24989
+ error: formatLogError(error, { stack: false })
24990
+ });
22247
24991
  return { outcome: "unavailable" };
22248
24992
  }
22249
24993
  if (!fork.id)
@@ -22292,7 +25036,10 @@ class CodexRuntimeSessions {
22292
25036
  await this.ctx.callbacks.deleteSession(child.id).catch(() => {
22293
25037
  return;
22294
25038
  });
22295
- console.warn(`[codex-bridge] Fork of ${parent.threadId} could not be hydrated:`, error instanceof Error ? error.message : error);
25039
+ log13.warn("thread.fork-hydrate-failed", {
25040
+ threadId: parent.threadId,
25041
+ error: formatLogError(error, { stack: false })
25042
+ });
22296
25043
  return { outcome: "unavailable" };
22297
25044
  }
22298
25045
  }
@@ -22304,7 +25051,10 @@ class CodexRuntimeSessions {
22304
25051
  });
22305
25052
  turns = thread?.turns;
22306
25053
  } catch (error) {
22307
- console.warn(`[codex-bridge] Could not read turns for thread ${context.threadId}:`, error instanceof Error ? error.message : error);
25054
+ log13.warn("thread.turns-read-failed", {
25055
+ threadId: context.threadId,
25056
+ error: formatLogError(error, { stack: false })
25057
+ });
22308
25058
  return;
22309
25059
  }
22310
25060
  if (!turns?.length)
@@ -22792,7 +25542,10 @@ class CodexRuntimeSessions {
22792
25542
  try {
22793
25543
  turns = (await this.ctx.options.engine.readThread(context.threadId, { includeTurns: true }))?.turns;
22794
25544
  } catch (error) {
22795
- console.warn(`[codex-bridge] Could not read turns after a revert of thread ${context.threadId}:`, error instanceof Error ? error.message : error);
25545
+ log13.warn("thread.turns-read-after-revert-failed", {
25546
+ threadId: context.threadId,
25547
+ error: formatLogError(error, { stack: false })
25548
+ });
22796
25549
  return;
22797
25550
  }
22798
25551
  if (!turns || this.ctx.registry.getThread(context.threadId) !== context)
@@ -22880,7 +25633,10 @@ class CodexRuntimeSessions {
22880
25633
  if (attached && requestedModelChanged) {
22881
25634
  attached.modelId = previousConfirmedModel;
22882
25635
  }
22883
- console.warn(`[codex-bridge] Could not apply configuration for session ${sessionId}:`, error instanceof Error ? error.message : error);
25636
+ log13.warn("session.config-apply-failed", {
25637
+ sessionId,
25638
+ error: formatLogError(error, { stack: false })
25639
+ });
22884
25640
  return "unavailable";
22885
25641
  }
22886
25642
  if (session.config.policy?.projectResources !== nextConfig.policy?.projectResources) {
@@ -22900,7 +25656,10 @@ class CodexRuntimeSessions {
22900
25656
  try {
22901
25657
  context = await this.ctx.callbacks.ensureAttached(sessionId);
22902
25658
  } catch (error) {
22903
- console.warn(`[codex-bridge] Serving the last known transcript for session ${sessionId}:`, error instanceof Error ? error.message : error);
25659
+ log13.warn("transcript.serving-last-known", {
25660
+ sessionId,
25661
+ error: formatLogError(error, { stack: false })
25662
+ });
22904
25663
  const known = this.ctx.registry.getThreadForSession(sessionId);
22905
25664
  return known ? this.ctx.callbacks.messagesForSession(session, known) : [...session.localMessages];
22906
25665
  }
@@ -23099,7 +25858,7 @@ class CodexRuntimeSessions {
23099
25858
  }
23100
25859
  return "unpublished";
23101
25860
  }
23102
- console.warn("[codex-bridge] Failed to persist bridge session registry:", error instanceof Error ? error.message : error);
25861
+ log13.warn("registry.persist-failed", { error: formatLogError(error, { stack: false }) });
23103
25862
  }
23104
25863
  if (this.ctx.registry.getSession(sessionId) !== session)
23105
25864
  return "released";
@@ -23193,6 +25952,8 @@ class CodexRuntimeSessions {
23193
25952
  }
23194
25953
  }
23195
25954
  // ../../bridges/codex-bridge/src/app-server-runtime-approvals.ts
25955
+ var log14 = createLogger("bridge.codex");
25956
+
23196
25957
  class CodexRuntimeApprovals {
23197
25958
  ctx;
23198
25959
  lifecycle;
@@ -23282,7 +26043,7 @@ class CodexRuntimeApprovals {
23282
26043
  if (this.ctx.options.engine.resolveApproval(approvalId, decision)) {
23283
26044
  if (decision === "cancel") {
23284
26045
  this.ctx.callbacks.abort(sessionId).catch((error) => {
23285
- console.error("[codex-bridge] Failed to cancel turn after approval response:", error);
26046
+ log14.error("approval.cancel-failed", { error: formatLogError(error) });
23286
26047
  });
23287
26048
  }
23288
26049
  return "applied";
@@ -23473,7 +26234,7 @@ async function readBounded2(absolutePath, maxBytes) {
23473
26234
  await handle.close();
23474
26235
  }
23475
26236
  }
23476
- function describe(bytes, candidate) {
26237
+ function describe2(bytes, candidate) {
23477
26238
  const content = new TextDecoder("utf-8").decode(bytes);
23478
26239
  const parsed = extractFrontmatter(content);
23479
26240
  const base = candidate.relativePath.replace(/\.md$/i, "").split("/").at(-1) ?? "template";
@@ -23601,7 +26362,7 @@ async function scanPromptTemplates(roots, limits = TEMPLATE_LIMITS) {
23601
26362
  const metadata = {
23602
26363
  statKey: candidate.statKey,
23603
26364
  fingerprint: fingerprintOf(bytes),
23604
- ...describe(bytes, candidate)
26365
+ ...describe2(bytes, candidate)
23605
26366
  };
23606
26367
  if (metadataCache.size >= METADATA_CACHE_MAX)
23607
26368
  metadataCache.clear();
@@ -24685,6 +27446,8 @@ class UpdateCoalescer {
24685
27446
 
24686
27447
  // ../../bridges/codex-bridge/src/app-server-runtime-capacity-retry.ts
24687
27448
  import { stat as stat8 } from "node:fs/promises";
27449
+ var log15 = createLogger("bridge.codex");
27450
+
24688
27451
  class CodexCapacityRetry {
24689
27452
  ctx;
24690
27453
  lifecycle;
@@ -24797,7 +27560,10 @@ class CodexCapacityRetry {
24797
27560
  }
24798
27561
  entry.stage = "starting";
24799
27562
  const work = this.startContinuation(context, turn, entry).catch((error) => {
24800
- console.error(`[codex-bridge] Capacity retry of turn ${turn.turnId} failed:`, error instanceof Error ? error.message : error);
27563
+ log15.error("turn.capacity-retry-failed", {
27564
+ turnId: turn.turnId,
27565
+ error: formatLogError(error, { stack: false })
27566
+ });
24801
27567
  if (this.pending.get(turn) === entry && context.activeTurn === turn && !turn.isTerminal()) {
24802
27568
  this.end(context, turn, "failed", entry.error, CAPACITY_RETRY_START_FAILED_TEXT);
24803
27569
  }
@@ -24866,7 +27632,10 @@ class CodexCapacityRetry {
24866
27632
  });
24867
27633
  return;
24868
27634
  }
24869
- await this.ctx.journal.markAccepted(requestId, { threadId: context.threadId, turnId: started.turnId }).catch((error) => console.warn(`[codex-bridge] Could not journal capacity retry of ${requestId}:`, error instanceof Error ? error.message : error));
27635
+ await this.ctx.journal.markAccepted(requestId, { threadId: context.threadId, turnId: started.turnId }).catch((error) => log15.warn("turn.capacity-retry-journal-failed", {
27636
+ requestId,
27637
+ error: formatLogError(error, { stack: false })
27638
+ }));
24870
27639
  if (plan.outputSchema) {
24871
27640
  const ledger = this.ctx.registry.recordStructuredOutputTurn(context.threadId, started.turnId, false);
24872
27641
  await Promise.all(ledger.map((session) => this.ctx.callbacks.persistSession(session)));
@@ -24934,6 +27703,7 @@ class CodexCapacityRetry {
24934
27703
  }
24935
27704
 
24936
27705
  // ../../bridges/codex-bridge/src/app-server-runtime-lifecycle.ts
27706
+ var log16 = createLogger("bridge.codex");
24937
27707
  function artifactConnectionToken(value) {
24938
27708
  if (!value || typeof value !== "object" || Array.isArray(value))
24939
27709
  return;
@@ -25117,7 +27887,10 @@ class CodexRuntimeLifecycle {
25117
27887
  this.ctx.registry.setPhase(existing, "recovering");
25118
27888
  this.emitStatus(existing);
25119
27889
  this.ctx.callbacks.scheduleRecoveryBackstop(existing);
25120
- console.warn(`[codex-bridge] Could not restore dispatch ${record.requestId}:`, error instanceof Error ? error.message : error);
27890
+ log16.warn("dispatch.restore-failed", {
27891
+ requestId: record.requestId,
27892
+ error: formatLogError(error, { stack: false })
27893
+ });
25121
27894
  return;
25122
27895
  }
25123
27896
  if (!context) {
@@ -25293,7 +28066,11 @@ class CodexRuntimeLifecycle {
25293
28066
  });
25294
28067
  }));
25295
28068
  }
25296
- console.warn(`[codex-bridge] Could not re-attach thread ${threadId}${isMissingRolloutError(error) ? " (no rollout on disk)" : ""}:`, error instanceof Error ? error.message : error);
28069
+ log16.warn("thread.reattach-failed", {
28070
+ threadId,
28071
+ rolloutMissing: isMissingRolloutError(error),
28072
+ error: formatLogError(error, { stack: false })
28073
+ });
25297
28074
  if (!isMissingRolloutError(error))
25298
28075
  throw error;
25299
28076
  return;
@@ -25370,7 +28147,7 @@ class CodexRuntimeLifecycle {
25370
28147
  coalescer: new UpdateCoalescer({
25371
28148
  intervalMs: this.ctx.options.coalesceIntervalMs ?? (() => messageSnapshotIntervalMs(this.ctx.threadState.get(threadId)?.lastPublishedSnapshotChars ?? 0)),
25372
28149
  publish: () => this.ctx.callbacks.publishAssistantMessage(threadId),
25373
- onError: (error) => console.error("[codex-bridge] Failed to publish message update:", error)
28150
+ onError: (error) => log16.error("message.publish-failed", { error: formatLogError(error) })
25374
28151
  })
25375
28152
  };
25376
28153
  this.ctx.threadState.set(threadId, state);
@@ -25406,7 +28183,7 @@ class CodexRuntimeLifecycle {
25406
28183
  this.ctx.commandCatalogue.withdrawGeneration(event.generation);
25407
28184
  const recovery = this.ctx.generationRecovery.then(() => this.ctx.callbacks.recoverAfterGenerationChange(event.generation));
25408
28185
  this.ctx.generationRecovery = recovery.catch((error) => {
25409
- console.error("[codex-bridge] Generation recovery failed:", error);
28186
+ log16.error("generation.recovery-failed", { error: formatLogError(error) });
25410
28187
  });
25411
28188
  return;
25412
28189
  }
@@ -25426,7 +28203,7 @@ class CodexRuntimeLifecycle {
25426
28203
  }
25427
28204
  if (event.kind === "account.reload.requested") {
25428
28205
  this.ctx.callbacks.reloadStoredAccountLogin().catch((error) => {
25429
- console.warn("[codex-bridge] Reloading the stored account login failed:", error instanceof Error ? error.message : error);
28206
+ log16.warn("account.login-reload-failed", { error: formatLogError(error, { stack: false }) });
25430
28207
  });
25431
28208
  return;
25432
28209
  }
@@ -25729,7 +28506,10 @@ class CodexRuntimeLifecycle {
25729
28506
  }
25730
28507
  this.ctx.options.changeEvidence?.turn(this.evidenceSource(context, turn), event.status);
25731
28508
  const finalize = () => this.runFinalization(context, turn).catch((error) => {
25732
- console.error(`[codex-bridge] Failed to finalize turn ${turn.turnId}:`, error instanceof Error ? error.message : error);
28509
+ log16.error("turn.finalize-failed", {
28510
+ turnId: turn.turnId,
28511
+ error: formatLogError(error, { stack: false })
28512
+ });
25733
28513
  });
25734
28514
  const tail = this.takeRefusedCellTail(threadId, turn);
25735
28515
  if (!tail) {
@@ -25944,7 +28724,7 @@ class CodexRuntimeLifecycle {
25944
28724
  }
25945
28725
  trackCommandChangeWork(work) {
25946
28726
  const tracked = work.catch((error) => {
25947
- console.error("[codex-bridge] Failed to record a command's line changes:", error instanceof Error ? error.message : error);
28727
+ log16.warn("command-changes.record-failed", { error: formatLogError(error, { stack: false }) });
25948
28728
  });
25949
28729
  this.ctx.pendingCommandChanges.add(tracked);
25950
28730
  tracked.finally(() => this.ctx.pendingCommandChanges.delete(tracked));
@@ -26387,7 +29167,7 @@ class CodexRuntimeLifecycle {
26387
29167
  try {
26388
29168
  await state.coalescer.flushNow();
26389
29169
  } catch (error) {
26390
- console.error("[codex-bridge] Failed to flush before ordered-event reconciliation:", error);
29170
+ log16.error("ordered-events.flush-failed", { error: formatLogError(error) });
26391
29171
  }
26392
29172
  state.orderedReconcilePending = false;
26393
29173
  for (const sessionId of this.ctx.sessionIdsForThread(threadId)) {
@@ -26406,7 +29186,7 @@ class CodexRuntimeLifecycle {
26406
29186
  await state.coalescer.flushNow();
26407
29187
  event.publish();
26408
29188
  } catch (error) {
26409
- console.error("[codex-bridge] Failed to publish ordered event:", error);
29189
+ log16.error("ordered-events.publish-failed", { error: formatLogError(error) });
26410
29190
  state.orderedEvents.length = 0;
26411
29191
  state.orderedEventBytes = 0;
26412
29192
  state.orderedReconcilePending = true;
@@ -26415,7 +29195,7 @@ class CodexRuntimeLifecycle {
26415
29195
  }
26416
29196
  }
26417
29197
  } catch (error) {
26418
- console.error("[codex-bridge] Failed to reconcile ordered events:", error);
29198
+ log16.error("ordered-events.reconcile-failed", { error: formatLogError(error) });
26419
29199
  } finally {
26420
29200
  state.orderedEventDraining = false;
26421
29201
  if ((state.orderedReconcilePending || state.orderedEvents.length > 0) && this.ctx.threadState.get(threadId) === state) {
@@ -26531,6 +29311,7 @@ function isTabInitialPromptRequestId(requestId) {
26531
29311
  }
26532
29312
 
26533
29313
  // ../../bridges/codex-bridge/src/app-server-runtime-prompt.ts
29314
+ var log17 = createLogger("bridge.codex");
26534
29315
  function commandRefusal(message) {
26535
29316
  return { ok: false, status: 422, error: message, kind: "command-unavailable" };
26536
29317
  }
@@ -27191,7 +29972,11 @@ class CodexRuntimePrompt {
27191
29972
  try {
27192
29973
  outcome = await this.ctx.options.engine.reconcileRequest(context.threadId, accumulator.providerRequestId);
27193
29974
  } catch (error) {
27194
- console.warn(`[codex-bridge] Could not reconcile ${requestId} on thread ${context.threadId}:`, error instanceof Error ? error.message : error);
29975
+ log17.warn("dispatch.reconcile-failed", {
29976
+ requestId,
29977
+ threadId: context.threadId,
29978
+ error: formatLogError(error, { stack: false })
29979
+ });
27195
29980
  return "recovering";
27196
29981
  }
27197
29982
  if (outcome.result === "attach") {
@@ -27462,7 +30247,7 @@ class CodexRuntimePrompt {
27462
30247
  if (this.ctx.stopping || this.shouldAbandonDrain(expectedGeneration))
27463
30248
  return;
27464
30249
  if (Date.now() >= deadline) {
27465
- console.warn("[codex-bridge] Restarting app-server with turns still in flight: the drain deadline expired.");
30250
+ log17.warn("app-server.drain-expired");
27466
30251
  return;
27467
30252
  }
27468
30253
  await this.waitForThreadActivity();
@@ -27496,6 +30281,8 @@ class CodexRuntimePrompt {
27496
30281
 
27497
30282
  // ../../bridges/codex-bridge/src/app-server-runtime-tail.ts
27498
30283
  import { join as join21, relative as relative4, isAbsolute as isAbsolute11 } from "node:path";
30284
+ var log18 = createLogger("bridge.codex");
30285
+
27499
30286
  class CodexRuntimeTail {
27500
30287
  ctx;
27501
30288
  lifecycle;
@@ -27643,7 +30430,7 @@ class CodexRuntimeTail {
27643
30430
  };
27644
30431
  }
27645
30432
  } catch (error) {
27646
- console.warn("[codex-bridge] model/list failed; falling back to cache:", error instanceof Error ? error.message : error);
30433
+ log18.warn("models.list-failed", { error: formatLogError(error, { stack: false }) });
27647
30434
  }
27648
30435
  return this.ctx.options.loadCachedModels();
27649
30436
  }
@@ -27669,7 +30456,7 @@ class CodexRuntimeTail {
27669
30456
  });
27670
30457
  }
27671
30458
  } catch (error) {
27672
- console.warn("[codex-bridge] thread/list failed; using rollout parser:", error instanceof Error ? error.message : error);
30459
+ log18.warn("threads.list-failed", { error: formatLogError(error, { stack: false }) });
27673
30460
  }
27674
30461
  const archived = new Set;
27675
30462
  try {
@@ -27754,7 +30541,10 @@ class CodexRuntimeTail {
27754
30541
  else
27755
30542
  await this.ctx.options.engine.unarchiveThread(threadId);
27756
30543
  } catch (error) {
27757
- console.warn(`[codex-bridge] thread/${archived ? "archive" : "unarchive"} failed:`, error instanceof Error ? error.message : error);
30544
+ log18.warn("thread.archive-failed", {
30545
+ archived,
30546
+ error: formatLogError(error, { stack: false })
30547
+ });
27758
30548
  return "failed";
27759
30549
  } finally {
27760
30550
  invalidateTranscriptCatalogCache();
@@ -28386,6 +31176,7 @@ var CODEX_FALLBACK_MODEL_CATALOG = [
28386
31176
  ];
28387
31177
 
28388
31178
  // ../../bridges/codex-bridge/src/models-cache.ts
31179
+ var log19 = createLogger("bridge.codex");
28389
31180
  var MODEL_REASONING_EFFORTS = new Set([
28390
31181
  "minimal",
28391
31182
  "low",
@@ -28532,12 +31323,14 @@ class ModelCatalogCache {
28532
31323
  await this.opts.writePersistedCache(models);
28533
31324
  }
28534
31325
  } catch (error) {
28535
- console.warn("[codex-bridge] Background model refresh failed:", error instanceof Error ? error.message : error);
31326
+ log19.warn("models.refresh-failed", { error: formatLogError(error, { stack: false }) });
28536
31327
  }
28537
31328
  }
28538
31329
  }
28539
31330
 
28540
31331
  // ../../bridges/codex-bridge/src/index.ts
31332
+ var log20 = createLogger("bridge.codex");
31333
+ configureBridgeLogger();
28541
31334
  var WORKFLOW_RESULT_TOOL_NAMES2 = new Set(WORKFLOW_RESULT_KINDS.map(workflowResultToolName));
28542
31335
  function isWorkflowResultTool(value) {
28543
31336
  return typeof value === "string" && (WORKFLOW_RESULT_TOOL_NAMES2.has(value) || workflowResultTurnToolPort(value) !== null);
@@ -28569,7 +31362,11 @@ app.onError((error, c) => {
28569
31362
  const response = error.getResponse();
28570
31363
  return c.newResponse(response.body, response);
28571
31364
  }
28572
- console.error(`[codex-bridge] ${c.req.method} ${c.req.path} failed: ${redactSecrets(error.stack ?? `${error.name}: ${error.message}`)}`);
31365
+ log20.error("http.request-failed", {
31366
+ method: c.req.method,
31367
+ path: c.req.path,
31368
+ error: formatLogError(error)
31369
+ });
28573
31370
  return c.text("Internal Server Error", 500);
28574
31371
  });
28575
31372
  var MAX_CODEX_TRANSCRIPT_RESPONSE_BYTES = 16 * 1024 * 1024;
@@ -28593,10 +31390,10 @@ function notifyObservers(event, revision) {
28593
31390
  for (const observer of observers) {
28594
31391
  try {
28595
31392
  Promise.resolve(observer(event, revision, "{}")).catch((error) => {
28596
- console.error("[codex-bridge] Failed to notify SSE observer:", error);
31393
+ log20.warn("sse.observer-failed", { error: formatLogError(error) });
28597
31394
  });
28598
31395
  } catch (error) {
28599
- console.error("[codex-bridge] Failed to notify SSE observer:", error);
31396
+ log20.warn("sse.observer-failed", { error: formatLogError(error) });
28600
31397
  }
28601
31398
  }
28602
31399
  }
@@ -28729,7 +31526,7 @@ async function writeCodexRawLog(sessionId, entry, logDir = codexRawLogDir) {
28729
31526
  })}
28730
31527
  `, "utf8");
28731
31528
  } catch (error) {
28732
- console.error("[codex-bridge] Failed to write raw Codex log:", error);
31529
+ log20.warn("raw-log.write-failed", { error: formatLogError(error) });
28733
31530
  }
28734
31531
  }
28735
31532
  function createShutdownHandler(timer, clearTimer = clearInterval, exit = (code) => process.exit(code), stopEngine = () => stopSelectedEngine()) {
@@ -28740,12 +31537,12 @@ function createShutdownHandler(timer, clearTimer = clearInterval, exit = (code)
28740
31537
  shuttingDown = true;
28741
31538
  clearTimer(timer);
28742
31539
  stopEngine().catch((error) => {
28743
- console.warn("[codex-bridge] Failed to stop the Codex engine:", error);
31540
+ log20.warn("engine.stop-failed", { error: formatLogError(error) });
28744
31541
  }).finally(() => exit(0));
28745
31542
  };
28746
31543
  }
28747
31544
  function createParentExitHandler(interrupt, shutdown, report = (turns, ms) => {
28748
- console.error(`[codex-bridge] Stopped ${turns} running turn(s) in ${ms} ms`);
31545
+ log20.info("turns.stopped", { turns, elapsedMs: ms });
28749
31546
  }) {
28750
31547
  return async () => {
28751
31548
  const detectedAt = performance.now();
@@ -28776,7 +31573,7 @@ function serializeSseEventData(event) {
28776
31573
  ...event.data
28777
31574
  });
28778
31575
  } catch {
28779
- console.error("[codex-bridge] Failed to serialize an SSE payload");
31576
+ log20.error("sse.payload-serialize-failed");
28780
31577
  return JSON.stringify({
28781
31578
  sessionId: event.sessionId,
28782
31579
  error: "payload could not be serialized"
@@ -28841,7 +31638,7 @@ function emit(event) {
28841
31638
  messageId = retainedMessageId(event.type, payload);
28842
31639
  bytes = eager === null ? estimateSsePayloadBytes(payload) : Buffer.byteLength(eager, "utf8");
28843
31640
  } catch {
28844
- console.error("[codex-bridge] Failed to snapshot an SSE payload");
31641
+ log20.error("sse.payload-snapshot-failed");
28845
31642
  payload = { error: "payload could not be serialized" };
28846
31643
  eager = subscribers.size > 0 ? serializeSseEventData({ sessionId, data: payload }) : null;
28847
31644
  messageId = undefined;
@@ -28858,10 +31655,10 @@ function emit(event) {
28858
31655
  for (const subscriber of subscribers) {
28859
31656
  try {
28860
31657
  Promise.resolve(subscriber(event, revision, eager ?? "{}")).catch((error) => {
28861
- console.error("[codex-bridge] Failed to notify SSE subscriber:", error);
31658
+ log20.warn("sse.subscriber-failed", { error: formatLogError(error) });
28862
31659
  });
28863
31660
  } catch (error) {
28864
- console.error("[codex-bridge] Failed to notify SSE subscriber:", error);
31661
+ log20.warn("sse.subscriber-failed", { error: formatLogError(error) });
28865
31662
  }
28866
31663
  }
28867
31664
  }
@@ -28888,7 +31685,7 @@ async function writePersistedBridgeCache(models) {
28888
31685
  await mkdir9(bridgeCacheDir(), { recursive: true });
28889
31686
  await writeFile6(bridgeCachePath(), JSON.stringify({ version: BRIDGE_MODEL_CACHE_VERSION, at: Date.now(), models }, null, 2));
28890
31687
  } catch (error) {
28891
- console.warn("[codex-bridge] Failed to persist model cache:", error instanceof Error ? error.message : error);
31688
+ log20.warn("models.cache-persist-failed", { error: formatLogError(error, { stack: false }) });
28892
31689
  }
28893
31690
  }
28894
31691
  async function readCodexCliModelCache() {
@@ -28910,7 +31707,7 @@ async function fetchLiveModelsFromCli(run = execFile4, env = process.env) {
28910
31707
  const models = parseModelCatalog(stdout);
28911
31708
  return models.length > 0 ? models : null;
28912
31709
  } catch (error) {
28913
- console.warn("[codex-bridge] `codex debug models` failed:", error instanceof Error ? error.message : error);
31710
+ log20.warn("models.debug-read-failed", { error: formatLogError(error, { stack: false }) });
28914
31711
  return null;
28915
31712
  }
28916
31713
  }
@@ -28955,7 +31752,7 @@ async function sweepIdleThreads(runtime = appServerRuntime) {
28955
31752
  try {
28956
31753
  await runtime.sweepIdle();
28957
31754
  } catch (error) {
28958
- console.warn("[codex-bridge] Idle sweep failed:", error);
31755
+ log20.warn("idle-sweep.failed", { error: formatLogError(error) });
28959
31756
  }
28960
31757
  }
28961
31758
  function createCodexProcessDiagnostics(runtime = appServerRuntime) {
@@ -28991,9 +31788,9 @@ async function startSelectedEngine(env = process.env, runtime = appServerRuntime
28991
31788
  }
28992
31789
  try {
28993
31790
  await runtime.start();
28994
- console.error(`[codex-bridge] app-server engine ready (codex ${runtime.getHealth().codexVersion ?? "unknown"})`);
31791
+ log20.info("engine.ready", { codexVersion: runtime.getHealth().codexVersion ?? "unknown" });
28995
31792
  } catch (error) {
28996
- console.error("[codex-bridge] Failed to start the app-server engine:", error instanceof Error ? error.message : error);
31793
+ log20.error("engine.start-failed", { error: formatLogError(error, { stack: false }) });
28997
31794
  }
28998
31795
  }
28999
31796
  var __testing = {
@@ -29079,7 +31876,7 @@ function startSseKeepalive(writeSSE, intervalMs = 5000, shouldSendAtActiveCadenc
29079
31876
  id: String(eventRing.latestRevision),
29080
31877
  data: "{}"
29081
31878
  }).catch((error) => {
29082
- console.error("[codex-bridge] Failed to write SSE keepalive:", error);
31879
+ log20.warn("sse.keepalive-failed", { error: formatLogError(error, { stack: false }) });
29083
31880
  });
29084
31881
  }, intervalMs);
29085
31882
  }
@@ -29158,6 +31955,10 @@ app.use("/session/:id/transcript", async (c, next) => {
29158
31955
  c.res.headers.append("Vary", "Accept-Encoding");
29159
31956
  });
29160
31957
  app.use("/session/:id/transcript", compress({ encoding: "gzip" }));
31958
+ app.post(BRIDGE_LOG_POLICY_ROUTE, async (c) => {
31959
+ const answer = applyBridgeLogPolicy(await readBridgeLogPolicyBody(c.req.raw));
31960
+ return c.json(answer.body, answer.status);
31961
+ });
29161
31962
  app.get("/global/health", (c) => {
29162
31963
  const health = appServerRuntime.getHealth();
29163
31964
  const terminal = health.state === "failed" || health.circuitOpen;
@@ -29329,7 +32130,7 @@ app.get("/session/:id/usage", async (c) => {
29329
32130
  return c.json({ error: "Session not found" }, 404);
29330
32131
  return c.json({ contextUsage });
29331
32132
  } catch (error) {
29332
- console.warn("[codex-bridge] Account usage read failed:", error instanceof Error ? error.message : error);
32133
+ log20.warn("account.usage-read-failed", { error: formatLogError(error, { stack: false }) });
29333
32134
  return c.json({ error: "Account usage is temporarily unavailable" }, 503);
29334
32135
  }
29335
32136
  });
@@ -29739,7 +32540,7 @@ app.get("/event/subscribe", (c) => {
29739
32540
  if (!open)
29740
32541
  return;
29741
32542
  open = false;
29742
- console.error(`[codex-bridge] Closing SSE subscriber (${reason}); the client will reconnect and replay from its cursor`);
32543
+ log20.info("sse.closed", { reason });
29743
32544
  resolveConnectionClosed();
29744
32545
  };
29745
32546
  const writeWhileOpen = createSerializedSseWriter(createOpenSseWriter(() => open, (event) => stream.writeSSE(event)), { onOverflow: () => failSlowSubscriber("write backlog exceeded its cap") });
@@ -29887,7 +32688,7 @@ if (parentPid !== null) {
29887
32688
  startParentWatchdog({
29888
32689
  parentPid,
29889
32690
  onParentExit: () => {
29890
- console.error(`[codex-bridge] Backend process ${parentPid} is gone; shutting down`);
32691
+ log20.warn("parent.gone", { parentPid });
29891
32692
  createParentExitHandler((budgetMs) => appServerRuntime.interruptForParentExit(budgetMs), shutdownHandler)();
29892
32693
  }
29893
32694
  });