orkestrator 2.36.0 → 2.36.2-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.
- package/dist/client.js +339 -23
- package/dist/main.js +10532 -4435
- package/package.json +3 -3
- package/resources/acp-bridge/dist/index.js +634 -429
- package/resources/claude-bridge/dist/index.js +548 -147
- package/resources/codex-bridge/dist/index.js +1919 -1260
- package/resources/cursor-bridge/dist/index.js +587 -42
- package/resources/cursor-bridge/runtime/install.json +1 -1
- package/resources/pi-bridge/dist/index.js +738 -103
- package/resources/pi-bridge/runtime/install.json +1 -1
|
@@ -4082,6 +4082,7 @@ var COORDINATOR_CONTROL_TOOL_NAMES = Object.freeze([
|
|
|
4082
4082
|
"request_project_on_node",
|
|
4083
4083
|
"request_root_changes",
|
|
4084
4084
|
"resolve_conflicts",
|
|
4085
|
+
"restart_build_pipeline_step",
|
|
4085
4086
|
"resume_build_pipeline",
|
|
4086
4087
|
"resume_schedule",
|
|
4087
4088
|
"run_worker_command",
|
|
@@ -4109,6 +4110,8 @@ var COORDINATOR_PROJECT_HOME_MESSAGE_WINDOW_MS = 3 * 60 * 60000;
|
|
|
4109
4110
|
var AGENT_MAIL_MAX_BODY_BYTES = 32 * 1024;
|
|
4110
4111
|
var AGENT_MAIL_MAX_STORE_BYTES = 32 * 1024 * 1024;
|
|
4111
4112
|
var AGENT_MAIL_DEFAULT_RETENTION_DAYS = 14;
|
|
4113
|
+
var AGENT_MAIL_MAX_ATTACHMENT_BYTES = 8 * 1024 * 1024;
|
|
4114
|
+
var AGENT_MAIL_MAX_TOTAL_ATTACHMENT_BYTES = 32 * 1024 * 1024;
|
|
4112
4115
|
var AGENT_MAIL_DEFAULT_AUTONOMOUS_WAKE_BUDGET = 16;
|
|
4113
4116
|
var AGENT_MAIL_DEFAULT_HOURLY_WAKE_LIMIT = 40;
|
|
4114
4117
|
var AGENT_MAIL_TOOL_NAMES = Object.freeze([
|
|
@@ -4142,6 +4145,9 @@ function agentMailCapabilities(tabType, agent, locked = true) {
|
|
|
4142
4145
|
}
|
|
4143
4146
|
if (tabType === "claude-tmux")
|
|
4144
4147
|
return { canPull: true, canSend: true, canInject: true };
|
|
4148
|
+
if (tabType === "pipeline-worker") {
|
|
4149
|
+
return agent ? { canPull: true, canSend: true, canInject: true } : { canPull: false, canSend: false, canInject: false };
|
|
4150
|
+
}
|
|
4145
4151
|
if (["claude", "codex", "opencode"].includes(tabType)) {
|
|
4146
4152
|
return { canPull: true, canSend: true, canInject: false };
|
|
4147
4153
|
}
|
|
@@ -28904,6 +28910,16 @@ function logErrorKind(error) {
|
|
|
28904
28910
|
}
|
|
28905
28911
|
|
|
28906
28912
|
// ../protocol/src/log-vocabulary/define.ts
|
|
28913
|
+
var ESSENTIAL_ERROR_FIELDS = {
|
|
28914
|
+
"error.name": "label",
|
|
28915
|
+
"error.code": "label",
|
|
28916
|
+
"error.errno": "number",
|
|
28917
|
+
"error.syscall": "label",
|
|
28918
|
+
"error.exitCode": "number",
|
|
28919
|
+
"error.signal": "label",
|
|
28920
|
+
"error.outputOmitted": "boolean",
|
|
28921
|
+
"error.errorCount": "number"
|
|
28922
|
+
};
|
|
28907
28923
|
var THROTTLE_LOG_EVENTS = {
|
|
28908
28924
|
"throttle.suppressed": "Repeats of the throttled `site` were counted over a window, not written.",
|
|
28909
28925
|
"throttle.recovered": "The throttled `site` succeeded again, so its fault has cleared.",
|
|
@@ -28953,7 +28969,11 @@ var BACKEND_LOG_AREAS = defineLogAreas({
|
|
|
28953
28969
|
backend: {
|
|
28954
28970
|
description: "The backend process: startup, background notices and shutdown.",
|
|
28955
28971
|
events: {
|
|
28956
|
-
starting:
|
|
28972
|
+
starting: {
|
|
28973
|
+
description: "The backend process is starting.",
|
|
28974
|
+
essential: true,
|
|
28975
|
+
fields: { version: "label" }
|
|
28976
|
+
},
|
|
28957
28977
|
"ssh-socket.resolved": "An SSH agent socket was found.",
|
|
28958
28978
|
"ssh-socket.missing": "No usable SSH agent socket was found.",
|
|
28959
28979
|
"standalone-updater.mismatch": "--standalone-updater does not match --data-dir, so self-update is off.",
|
|
@@ -28968,8 +28988,16 @@ var BACKEND_LOG_AREAS = defineLogAreas({
|
|
|
28968
28988
|
"notice.failed": "A background notice after a turn or prompt failed; `step` says which.",
|
|
28969
28989
|
"artifacts.live-unavailable": "Live interactive artifacts are unavailable.",
|
|
28970
28990
|
"shutdown.step-failed": "One part of shutdown failed and the rest went on; `step` says which.",
|
|
28971
|
-
"shutdown.signal-received":
|
|
28972
|
-
|
|
28991
|
+
"shutdown.signal-received": {
|
|
28992
|
+
description: "A signal started shutdown, which tells a clean quit from the backend being killed.",
|
|
28993
|
+
essential: true,
|
|
28994
|
+
fields: { signal: "label" }
|
|
28995
|
+
},
|
|
28996
|
+
"shutdown.finished": {
|
|
28997
|
+
description: "Shutdown finished, and the process exits with `code`.",
|
|
28998
|
+
essential: true,
|
|
28999
|
+
fields: { code: "number" }
|
|
29000
|
+
},
|
|
28973
29001
|
"port-policy.second-backend": "Another backend serves the default data directory, so this one avoids its ports.",
|
|
28974
29002
|
"port-policy.serve-on-free-port": "--tailscale-serve is on a free gateway port; pass --port with --strict-gateway-port to keep one."
|
|
28975
29003
|
}
|
|
@@ -29012,7 +29040,10 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
|
|
|
29012
29040
|
"evidence.record-failed": "Change evidence could not be recorded; the read loop carries on.",
|
|
29013
29041
|
"evidence.shell-record-failed": "A shell observation could not be recorded.",
|
|
29014
29042
|
"evidence.turn-record-failed": "Turn change evidence could not be recorded.",
|
|
29043
|
+
"agent.exited": "An ACP agent process exited, with its `code` and `signal`, always at `warn`. `requested` is true when the bridge closed it normally, false for an unrequested or fault-driven exit.",
|
|
29044
|
+
"http.route-failed": "An HTTP route answered 500; its error message is not logged because it can hold content.",
|
|
29015
29045
|
"server.listening": "The HTTP server is listening.",
|
|
29046
|
+
"session.policy-widening-refused": "A request tried to widen a live session's execution policy and was refused; widened names the axes.",
|
|
29016
29047
|
"state.composer-reset": "A saved composer state was malformed and was reset.",
|
|
29017
29048
|
"state.discarded": "Saved bridge state could not be used and was discarded.",
|
|
29018
29049
|
"state.persist-failed": "Saving bridge state failed; a later write retries.",
|
|
@@ -29066,7 +29097,7 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
|
|
|
29066
29097
|
"session.created": "A session was created or recovered.",
|
|
29067
29098
|
"session.delete-failed": "Deleting a session failed.",
|
|
29068
29099
|
"session.fork-failed": "Forking a session failed.",
|
|
29069
|
-
"session.policy-widening-refused": "A
|
|
29100
|
+
"session.policy-widening-refused": "A request tried to widen a live session's execution policy and was refused; widened names the axes.",
|
|
29070
29101
|
"session.rename-failed": "Renaming a session failed.",
|
|
29071
29102
|
"session.resolve-failed": "A session could not be found or loaded for a request; action names the request.",
|
|
29072
29103
|
"session.rewind-failed": "Rewinding session files failed.",
|
|
@@ -29100,6 +29131,7 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
|
|
|
29100
29131
|
"app-server.exited": "app-server exited unexpectedly; the code and signal say how.",
|
|
29101
29132
|
"app-server.invariant-violation": "app-server asked for something its configuration forbids.",
|
|
29102
29133
|
"app-server.protocol-violation": "app-server wrote a line that is not valid protocol; it was ignored.",
|
|
29134
|
+
"app-server.overflow-restart-failed": "Replacing the child after a notification queue overflow failed; the next request tries again.",
|
|
29103
29135
|
"app-server.recording": "Notification recording is on; recordings hold content.",
|
|
29104
29136
|
"app-server.stale-reaped": "A stale app-server left by an earlier bridge was stopped.",
|
|
29105
29137
|
"app-server.stderr": "Metadata of an app-server stderr line, never its content.",
|
|
@@ -29130,6 +29162,7 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
|
|
|
29130
29162
|
"ordered-events.publish-failed": "Publishing an ordered event failed; clients are told to rehydrate.",
|
|
29131
29163
|
"ordered-events.reconcile-failed": "Reconciling ordered events failed.",
|
|
29132
29164
|
"parent.gone": "The backend that launched this bridge has gone; stopping turns and shutting down.",
|
|
29165
|
+
"queue.overflow": "The notification queue passed a bound and dropped its backlog.",
|
|
29133
29166
|
"queue.task-failed": "A task on a per-thread queue failed.",
|
|
29134
29167
|
"raw-log.write-failed": "Appending to the raw Codex log failed.",
|
|
29135
29168
|
"recorder.notice": "The notification recorder needs attention: it is on, or was asked for without its confirmation.",
|
|
@@ -29143,6 +29176,7 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
|
|
|
29143
29176
|
"server-request.flush-timeout": "An answer to a server request did not flush in time.",
|
|
29144
29177
|
"server-request.handoff-failed": "Handing a server request to the router threw.",
|
|
29145
29178
|
"session.config-apply-failed": "Applying session configuration failed; the route answers unavailable.",
|
|
29179
|
+
"session.policy-widening-refused": "A request tried to widen a live session's execution policy and was refused; widened names the axes.",
|
|
29146
29180
|
"sse.closed": "An event stream was closed by the bridge; the client reconnects and replays.",
|
|
29147
29181
|
"sse.keepalive-failed": "An event stream keepalive failed.",
|
|
29148
29182
|
"sse.observer-failed": "An event stream observer failed; it reconnects.",
|
|
@@ -29171,19 +29205,39 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
|
|
|
29171
29205
|
events: {
|
|
29172
29206
|
"agent.archive-failed": "Archiving or unarchiving an agent failed.",
|
|
29173
29207
|
"http.route-failed": "An HTTP route failed unexpectedly; its error is not logged because it can hold content.",
|
|
29208
|
+
"session.policy-widening-refused": "A request tried to widen a live session's execution policy and was refused; widened names the axes.",
|
|
29174
29209
|
"startup.closes-failed": "Finishing closes a previous process left behind failed at startup.",
|
|
29175
29210
|
"startup.closes-incomplete": "Some closes a previous process left behind did not finish at startup; a retried close finishes them.",
|
|
29176
29211
|
"state.publication-failing": "Saving bridge state is failing; new prompts and steers are refused until it recovers.",
|
|
29177
29212
|
"state.publication-recovered": "Saving bridge state recovered.",
|
|
29178
|
-
"state.transcripts-shortened": "The state file reached its limit, so some sessions were saved with a shortened transcript copy."
|
|
29213
|
+
"state.transcripts-shortened": "The state file reached its limit, so some sessions were saved with a shortened transcript copy.",
|
|
29214
|
+
"session.resume-fell-back": {
|
|
29215
|
+
description: "A saved conversation could not be resumed, so a new one started; its error message is not logged because it can hold content.",
|
|
29216
|
+
essential: true,
|
|
29217
|
+
fields: ESSENTIAL_ERROR_FIELDS
|
|
29218
|
+
},
|
|
29219
|
+
"turn.failed": "A turn failed; its error message is not logged because it can hold content. A cancelled turn is not a failure.",
|
|
29220
|
+
"turn.recovery-failed": "A run recovered after a bridge restart ended in failure, or could not be followed. A cancelled run is not a failure.",
|
|
29221
|
+
"turn.send-failed": "Sending a prompt to Cursor failed, so whether its run started is unknown; its error message is not logged because it can hold content.",
|
|
29222
|
+
"turn.timed-out": "A turn outlived its time budget, so its run was asked to cancel; `turn.failed` follows if it never stops."
|
|
29179
29223
|
}
|
|
29180
29224
|
},
|
|
29181
29225
|
"bridge.pi": {
|
|
29182
29226
|
description: "The Pi bridge: its routes, sessions and saved state.",
|
|
29183
29227
|
events: {
|
|
29184
29228
|
"http.route-failed": "An HTTP route failed unexpectedly; its error is not logged because it can hold content.",
|
|
29229
|
+
"session.policy-widening-refused": "A request tried to widen a live session's execution policy and was refused; widened names the axes.",
|
|
29230
|
+
"session-list.failed": "Reading the resumable sessions failed, so none were offered; its error message is not logged because it can hold content.",
|
|
29185
29231
|
"state.over-budget": "The state file stayed over budget after shedding transcripts, so the write was skipped.",
|
|
29186
|
-
"state.transcripts-shed": "The state file was over budget, so some sessions were saved without their transcript."
|
|
29232
|
+
"state.transcripts-shed": "The state file was over budget, so some sessions were saved without their transcript.",
|
|
29233
|
+
"session.resume-fell-back": {
|
|
29234
|
+
description: "A saved conversation could not be reopened, so a new one started; its error message is not logged because it can hold content.",
|
|
29235
|
+
essential: true,
|
|
29236
|
+
fields: ESSENTIAL_ERROR_FIELDS
|
|
29237
|
+
},
|
|
29238
|
+
"turn.failed": "A turn failed; its error message is not logged because it can hold content. A cancelled turn is not a failure.",
|
|
29239
|
+
"turn.refused": "Pi refused a prompt before starting a run, so nothing ran; its error message is not logged because it can hold content.",
|
|
29240
|
+
"turn.startup-timed-out": "Pi did not start a turn within its startup deadline, so the prompt was abandoned."
|
|
29187
29241
|
}
|
|
29188
29242
|
}
|
|
29189
29243
|
});
|
|
@@ -29194,14 +29248,31 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
|
|
|
29194
29248
|
description: "The Electron main process: startup, windows, quit and the Local backend's life.",
|
|
29195
29249
|
events: {
|
|
29196
29250
|
"backend.docker-context-seed-failed": "An agent-test profile fell back to the default Docker context.",
|
|
29197
|
-
"backend.exited":
|
|
29198
|
-
|
|
29251
|
+
"backend.exited": {
|
|
29252
|
+
description: "The Local backend exited unexpectedly; Local work is unavailable. `error.exitCode` and `error.signal` say how.",
|
|
29253
|
+
essential: true,
|
|
29254
|
+
fields: ESSENTIAL_ERROR_FIELDS
|
|
29255
|
+
},
|
|
29256
|
+
"backend.exited-recovering": {
|
|
29257
|
+
description: "The Local backend exited just after a remote update; relaunching unattended. `error.exitCode` and `error.signal` say how.",
|
|
29258
|
+
essential: true,
|
|
29259
|
+
fields: ESSENTIAL_ERROR_FIELDS
|
|
29260
|
+
},
|
|
29199
29261
|
"backend.keychain-link-remove-failed": "An agent-test profile kept a legacy link to the host keychain.",
|
|
29200
|
-
"backend.start-failed":
|
|
29262
|
+
"backend.start-failed": {
|
|
29263
|
+
description: "The Local backend did not start; continuing with remote machines.",
|
|
29264
|
+
essential: true,
|
|
29265
|
+
fields: ESSENTIAL_ERROR_FIELDS
|
|
29266
|
+
},
|
|
29201
29267
|
"clipboard.write-failed": "Writing text to the system clipboard failed.",
|
|
29202
29268
|
"dev-mode.ignored-packaged": "A packaged app was launched with ELECTRON_DEV=1 and ignored it; it loads its bundled renderer.",
|
|
29203
29269
|
"instance.already-running": "Another instance holds this data directory; this one will quit.",
|
|
29204
|
-
"main-thread.stalled":
|
|
29270
|
+
"main-thread.stalled": {
|
|
29271
|
+
description: "A timer fired late, so windows, IPC and the stdout reader waited.",
|
|
29272
|
+
essential: true,
|
|
29273
|
+
minLevel: "error",
|
|
29274
|
+
fields: { lagMs: "number", intervalMs: "number" }
|
|
29275
|
+
},
|
|
29205
29276
|
"quit.stopping-backend": "The app is quitting and has asked the Local backend to stop.",
|
|
29206
29277
|
"relaunch.schedule-failed": "The AppImage relaunch waiter failed; using Electron's relauncher.",
|
|
29207
29278
|
"relaunch.service-register-failed": "The AppImage relaunch service was refused; using a detached waiter.",
|
|
@@ -29212,7 +29283,11 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
|
|
|
29212
29283
|
"saved-machines.attach-failed": "Saved machines were not imported into the command node yet.",
|
|
29213
29284
|
"saved-machines.attached": "Saved machines were imported into the local command node.",
|
|
29214
29285
|
"startup.failed": "The application failed to start.",
|
|
29215
|
-
"uncaught-exception":
|
|
29286
|
+
"uncaught-exception": {
|
|
29287
|
+
description: "The main process hit an uncaught exception.",
|
|
29288
|
+
essential: true,
|
|
29289
|
+
fields: ESSENTIAL_ERROR_FIELDS
|
|
29290
|
+
},
|
|
29216
29291
|
"uncaught-exception.dialog-failed": "The uncaught exception sheet could not be shown.",
|
|
29217
29292
|
"window.create-failed": "A menu-driven new window could not be created.",
|
|
29218
29293
|
"window.recreate-failed": "The main window could not be recreated on activation.",
|
|
@@ -29235,6 +29310,12 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
|
|
|
29235
29310
|
"unhandled-rejection": "An unhandled rejection occurred while the renderer was starting."
|
|
29236
29311
|
}
|
|
29237
29312
|
},
|
|
29313
|
+
"desktop.permissions": {
|
|
29314
|
+
description: "Permission requests refused on the renderer and workspace realm sessions.",
|
|
29315
|
+
events: {
|
|
29316
|
+
denied: "A renderer asked for a permission the policy does not grant."
|
|
29317
|
+
}
|
|
29318
|
+
},
|
|
29238
29319
|
"desktop.dialog": {
|
|
29239
29320
|
description: "Native dialogs, whose modal loops hold the main thread while they are open.",
|
|
29240
29321
|
events: {
|
|
@@ -29353,6 +29434,8 @@ var GATEWAY_LOG_AREAS = defineLogAreas({
|
|
|
29353
29434
|
"loopback.unavailable": "The loopback client listener could not start.",
|
|
29354
29435
|
"auth-token.stored": "The gateway token's file was written. The path only, never the token.",
|
|
29355
29436
|
"auth-token.persist-failed": "The gateway token could not be saved.",
|
|
29437
|
+
"auth-guess.throttled": "A listener saw enough different wrong tokens that it now pauses new ones. Never the values.",
|
|
29438
|
+
"host.refused": "A request named a host this gateway does not answer to. Logged once per name, up to a limit.",
|
|
29356
29439
|
"port.fallback": "The preferred port was taken, so a nearby one is used.",
|
|
29357
29440
|
"port.fallback-distant": "The preferred port and those nearby were taken, so another is used.",
|
|
29358
29441
|
"request.failed": "A gateway request failed. Throttled: repeats are counted, not written.",
|
|
@@ -29396,6 +29479,22 @@ var LOCAL_SERVER_LOG_AREAS = defineLogAreas({
|
|
|
29396
29479
|
"bridge-runtime.installed": "A bridge runtime finished installing.",
|
|
29397
29480
|
"opencode.database-lost-retrying": "OpenCode lost its shared database at startup, so it is retried.",
|
|
29398
29481
|
"server.stopping": "A local server is being stopped, for the fixed `reason` given.",
|
|
29482
|
+
"bridge.started": {
|
|
29483
|
+
description: "A local bridge process was spawned; `key` names its kind and environment.",
|
|
29484
|
+
essential: true,
|
|
29485
|
+
fields: { key: "label", pid: "number" }
|
|
29486
|
+
},
|
|
29487
|
+
"bridge.exited": {
|
|
29488
|
+
description: "A local bridge process exited, with its `code` and `signal`. `warn` when nothing asked it to, whatever the code; `info` when the backend stopped it, which `server.stopping` explains.",
|
|
29489
|
+
essential: true,
|
|
29490
|
+
fields: {
|
|
29491
|
+
key: "label",
|
|
29492
|
+
pid: "number",
|
|
29493
|
+
code: "number",
|
|
29494
|
+
signal: "label",
|
|
29495
|
+
requested: "boolean"
|
|
29496
|
+
}
|
|
29497
|
+
},
|
|
29399
29498
|
"reaper.tmux-list-failed": "Orphaned claude-tmux sessions could not be listed.",
|
|
29400
29499
|
"reaper.tmux-kill-failed": "An orphaned tmux session could not be killed.",
|
|
29401
29500
|
"reaper.tmux-reaped": "Orphaned claude-tmux sessions of a deleted environment were killed.",
|
|
@@ -29429,13 +29528,29 @@ var LOGGING_LOG_AREAS = defineLogAreas({
|
|
|
29429
29528
|
"capture.started": "Saving logs to disk began for this process.",
|
|
29430
29529
|
"capture.stopped": "Saving logs to disk stopped for this process.",
|
|
29431
29530
|
"config.invalid": "A logging environment variable held a value that was ignored.",
|
|
29432
|
-
"entries.dropped":
|
|
29531
|
+
"entries.dropped": {
|
|
29532
|
+
description: "Entries were dropped and counted, for the fixed `reason` given: the queue was full, a write failed or, in the essential log, one event was repeating too fast.",
|
|
29533
|
+
essential: true,
|
|
29534
|
+
fields: { entries: "number", bytes: "number", reason: "label" }
|
|
29535
|
+
},
|
|
29536
|
+
"essential.started": {
|
|
29537
|
+
description: "This process began writing the essential log. One with no `essential.stopped` before it means the last writer died.",
|
|
29538
|
+
essential: true,
|
|
29539
|
+
fields: { owner: "label" }
|
|
29540
|
+
},
|
|
29541
|
+
"essential.stopped": {
|
|
29542
|
+
description: "This process stopped writing the essential log, in an orderly exit.",
|
|
29543
|
+
essential: true,
|
|
29544
|
+
fields: { owner: "label" }
|
|
29545
|
+
},
|
|
29546
|
+
"essential.write-failed": "Writing the essential log failed. Its entries are counted, and a marker reports them at the next write that works.",
|
|
29433
29547
|
"policy.changed": "The logging settings changed: saving, retention and levels, with no content.",
|
|
29434
29548
|
"policy.bridge-predates-route": "A running bridge has no logging settings route; it applies them at its next start.",
|
|
29435
29549
|
"policy.push-failed": "A running bridge did not take the logging settings after retries; its next start resends them.",
|
|
29436
29550
|
"prune.failed": "Removing expired log files failed; the next sweep retries.",
|
|
29437
29551
|
"write.failed": "Appending to the log file failed.",
|
|
29438
|
-
"unknown-area": "Code outside the type checker asked for an area that is not listed."
|
|
29552
|
+
"unknown-area": "Code outside the type checker asked for an area that is not listed.",
|
|
29553
|
+
...THROTTLE_LOG_EVENTS
|
|
29439
29554
|
}
|
|
29440
29555
|
}
|
|
29441
29556
|
});
|
|
@@ -29560,7 +29675,28 @@ var RUNTIME_LOG_AREAS = defineLogAreas({
|
|
|
29560
29675
|
"event-loop": {
|
|
29561
29676
|
description: "This process's event loop. A stall of 10 seconds or more is written at error, so no level hides it.",
|
|
29562
29677
|
events: {
|
|
29563
|
-
stalled:
|
|
29678
|
+
stalled: {
|
|
29679
|
+
description: "A timer fired late, so every request in that window waited.",
|
|
29680
|
+
essential: true,
|
|
29681
|
+
minLevel: "error",
|
|
29682
|
+
fields: { lagMs: "number", intervalMs: "number" }
|
|
29683
|
+
}
|
|
29684
|
+
}
|
|
29685
|
+
},
|
|
29686
|
+
process: {
|
|
29687
|
+
description: "Failures of a whole process that nothing in it handled.",
|
|
29688
|
+
events: {
|
|
29689
|
+
"rejection.unhandled": {
|
|
29690
|
+
description: "A promise rejection reached the fatal rejection guard, which keeps the process running.",
|
|
29691
|
+
essential: true,
|
|
29692
|
+
fields: { kind: "label", ...ESSENTIAL_ERROR_FIELDS }
|
|
29693
|
+
},
|
|
29694
|
+
"uncaught-exception": {
|
|
29695
|
+
description: "An exception reached the top of the backend, which is about to die with it. `origin` says whether it was thrown or a rejected top-level await.",
|
|
29696
|
+
essential: true,
|
|
29697
|
+
fields: { origin: "label", ...ESSENTIAL_ERROR_FIELDS }
|
|
29698
|
+
},
|
|
29699
|
+
...THROTTLE_LOG_EVENTS
|
|
29564
29700
|
}
|
|
29565
29701
|
}
|
|
29566
29702
|
});
|
|
@@ -29798,21 +29934,43 @@ var STORAGE_LOG_AREAS = defineLogAreas({
|
|
|
29798
29934
|
description: "The SQLite-backed stores, their snapshots and imports from older formats.",
|
|
29799
29935
|
events: {
|
|
29800
29936
|
"usage.environment-label-failed": "Usage labels could not be retained for a removed environment; deletion continues.",
|
|
29801
|
-
"
|
|
29937
|
+
"migration.failed": {
|
|
29938
|
+
description: "The database could not be brought to this build's schema, so it did not open; `step` says whether the safety copy or the migration itself failed.",
|
|
29939
|
+
essential: true,
|
|
29940
|
+
fields: {
|
|
29941
|
+
fromVersion: "number",
|
|
29942
|
+
toVersion: "number",
|
|
29943
|
+
step: "label",
|
|
29944
|
+
...ESSENTIAL_ERROR_FIELDS
|
|
29945
|
+
}
|
|
29946
|
+
},
|
|
29947
|
+
"snapshot.integrity-failed": {
|
|
29948
|
+
description: "A database snapshot failed its integrity check and was discarded.",
|
|
29949
|
+
essential: true,
|
|
29950
|
+
fields: {}
|
|
29951
|
+
},
|
|
29802
29952
|
"snapshot.skipped-low-disk": "The hourly database snapshot was skipped because the disk lacks room; `retryAt` says when it tries again.",
|
|
29803
|
-
"snapshot.failed":
|
|
29953
|
+
"snapshot.failed": {
|
|
29954
|
+
description: "The hourly database snapshot failed; `retryAt` says when it tries again, if known.",
|
|
29955
|
+
essential: true,
|
|
29956
|
+
fields: { retryAt: "label", ...ESSENTIAL_ERROR_FIELDS }
|
|
29957
|
+
},
|
|
29804
29958
|
"listener.attention-failed": "An environment attention listener threw; the committed mutation stands.",
|
|
29805
29959
|
"listener.change-failed": "A resource change listener threw; the committed mutation stands.",
|
|
29806
29960
|
"kanban.image-cleanup-failed": "An orphaned Kanban image could not be removed after its retries; it is safe to remove later.",
|
|
29807
29961
|
"nodes.entries-dropped": "Unreadable node registry entries were ignored.",
|
|
29808
29962
|
"preview-identity.reminted": "The data directory moved or was copied, so previews get a new backend identity.",
|
|
29963
|
+
"preview-settings.invalid": "Invalid preview settings disabled transport and relay.",
|
|
29809
29964
|
"machine-profile.invalid": "The stored machine profile was invalid and the default was restored.",
|
|
29810
29965
|
"permission-rules.cleanup-failed": "A deleted project's permission rules could not be removed.",
|
|
29811
29966
|
"retired.turn-cleanup-pending": "Cleanup of a retired Looped Review turn did not finish and stays pending.",
|
|
29812
29967
|
"handoffs.prune-failed": "Pruning agent handoffs that nothing references failed; a later prune retries.",
|
|
29813
29968
|
"desktop-connections.malformed": "Stored desktop connection settings were malformed, so the local connection is used.",
|
|
29814
29969
|
"legacy-json.moved": "JSON store files written after the SQLite migration were archived, not imported.",
|
|
29815
|
-
"legacy-json.archive-failed": "Imported JSON store files could not be archived."
|
|
29970
|
+
"legacy-json.archive-failed": "Imported JSON store files could not be archived.",
|
|
29971
|
+
"lease.heartbeat-failed": "A held lease's heartbeat failed, which shortens the lease; the next one retries.",
|
|
29972
|
+
"scrub.checkpoint-failed": "Deleted content could not be scrubbed from the WAL because the truncating checkpoint failed or was blocked; the next checkpoint retries.",
|
|
29973
|
+
...THROTTLE_LOG_EVENTS
|
|
29816
29974
|
}
|
|
29817
29975
|
}
|
|
29818
29976
|
});
|
|
@@ -29838,6 +29996,7 @@ var BUILD_PIPELINE_LOG_AREAS = defineLogAreas({
|
|
|
29838
29996
|
"usage.read-failed": "Reading a stage session's token usage failed.",
|
|
29839
29997
|
"checkpoint.deferred": "A stage transcript checkpoint could not be written yet; the provider's history stands.",
|
|
29840
29998
|
"checkpoint.not-committed": "A stage transcript checkpoint was reverted in the commit that should have kept it.",
|
|
29999
|
+
"worker-mail.claim-failed": "Mail queued for a worker could not be claimed at its turn end; it stays queued.",
|
|
29841
30000
|
"legacy-transcript.deferred": "Moving a legacy inline transcript failed; the inline body stays readable."
|
|
29842
30001
|
}
|
|
29843
30002
|
}
|
|
@@ -29907,6 +30066,10 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
|
|
|
29907
30066
|
"wake.resolve-report-failed": "A finished Resolve tab could not be reported.",
|
|
29908
30067
|
"wake.waiting-report-failed": "A waiting worker could not be reported.",
|
|
29909
30068
|
"wake.worker-outcomes-failed": "Coordinator-owned workers' merges and deletions could not be checked; the next sweep retries.",
|
|
30069
|
+
"pr-watch.added": "A pull request a coordinator conversation showed joined the project's watch; `source` says how.",
|
|
30070
|
+
"pr-watch.observe-failed": "A watched pull request could not be observed; the next sweep retries.",
|
|
30071
|
+
"pr-watch.read-failed": "GitHub could not be read for a watched pull request; `code` is the error category.",
|
|
30072
|
+
"pr-watch.removed": "A watched pull request stopped being watched without a reading; `reason` is `deleted` (GitHub confirmed it is gone) or `unreadable` (not found for the give-up period).",
|
|
29910
30073
|
"store.malformed": "The coordinator store was malformed and is treated as empty.",
|
|
29911
30074
|
"store.unsupported-version": "The coordinator store has an unsupported version and is treated as empty.",
|
|
29912
30075
|
"store.invalid-workspace": "An invalid coordinator workspace record was ignored.",
|
|
@@ -29915,8 +30078,10 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
|
|
|
29915
30078
|
"remote-worker.settle-failed": "A remote worker could not be settled.",
|
|
29916
30079
|
"checkout.merge-followed": "After an environment's PR merged, the project checkout was fast-forwarded, or `outcome` says why not.",
|
|
29917
30080
|
"checkout.merge-follow-failed": "Fast-forwarding the project checkout failed, after an environment's PR merged or before mail woke the main coordinator.",
|
|
29918
|
-
"checkout.mail-follow": "Before mail woke the main coordinator, the project checkout was fast-forwarded, or `outcome` says why not (`timed-out`, `failed`).",
|
|
29919
|
-
"checkout.mail-follow-failed": "Before mail woke the main coordinator, checking whether to fast-forward the project checkout failed; the mail was delivered anyway."
|
|
30081
|
+
"checkout.mail-follow": "Before mail woke the main coordinator, the project checkout was fast-forwarded (`fast-forwarded-fetched` when the fetch was slow or failed and the upstream commit already fetched was merged), or `outcome` says why not (`timed-out`, `failed`).",
|
|
30082
|
+
"checkout.mail-follow-failed": "Before mail woke the main coordinator, checking whether to fast-forward the project checkout failed; the mail was delivered anyway.",
|
|
30083
|
+
"checkout.message-check": "Before a typed message to the main coordinator, the backend answered whether to fast-forward the project checkout: `outcome` (`offer`, `fast-forwarded`, `turn-running`, `not-behind`, `blocked`, `no-status`), `fetch` (`fetched`, `failed`, `timed-out`, `skipped`) and `durationMs`.",
|
|
30084
|
+
"checkout.message-check-failed": "Before a typed message to the main coordinator, fast-forwarding to the upstream commit already fetched failed after a slow or failed fetch; the message was sent anyway."
|
|
29920
30085
|
}
|
|
29921
30086
|
}
|
|
29922
30087
|
});
|
|
@@ -30019,7 +30184,27 @@ var DOCKER_LOG_AREAS = defineLogAreas({
|
|
|
30019
30184
|
"recovery.clear-terminals-failed": "Terminal sessions could not be cleared after a recovery restore.",
|
|
30020
30185
|
"github-ranges.seed-not-copied": "The GitHub ranges seed could not be copied into a container, so its firewall fetches them.",
|
|
30021
30186
|
"availability.probe-failed": "Docker is not available; written when the diagnostic changes. Fixed-shape metadata only: messages can hold daemon endpoints.",
|
|
30022
|
-
"start.port-collision-retrying": "An automatic host port collided on start, so it is retried once with fresh ports."
|
|
30187
|
+
"start.port-collision-retrying": "An automatic host port collided on start, so it is retried once with fresh ports.",
|
|
30188
|
+
"writer-lease.lost": {
|
|
30189
|
+
description: "This backend lost the registry writer lease, for the fixed `reason` given. Schedules stop and container changes are refused until it restarts.",
|
|
30190
|
+
essential: true,
|
|
30191
|
+
fields: { reason: "label" }
|
|
30192
|
+
},
|
|
30193
|
+
"writer-lease.regained": {
|
|
30194
|
+
description: "This backend took the registry writer lease over from a holder that stopped refreshing it (it crashed, was killed or stalled), `staleForMs` after its last refresh. The counterpart of that holder's `writer-lease.lost` with reason `reclaimed`; a lease left by a clean shutdown is acquired silently.",
|
|
30195
|
+
essential: true,
|
|
30196
|
+
fields: { staleForMs: "number" }
|
|
30197
|
+
},
|
|
30198
|
+
"writer-lease.not-acquired": {
|
|
30199
|
+
description: "This backend started without the registry writer lease, for the fixed `reason` given. A second backend on one data directory is normal: it serves reads, runs no schedules and refuses container changes.",
|
|
30200
|
+
essential: true,
|
|
30201
|
+
fields: { reason: "label" }
|
|
30202
|
+
},
|
|
30203
|
+
"bridge.launched": {
|
|
30204
|
+
description: "A bridge process was launched in a container, for the first time there or as a relaunch; `provider` names it. A relaunch keeps the run before it in the previous log.",
|
|
30205
|
+
essential: true,
|
|
30206
|
+
fields: { provider: "label", containerPort: "number" }
|
|
30207
|
+
}
|
|
30023
30208
|
}
|
|
30024
30209
|
},
|
|
30025
30210
|
"docker.reachability": {
|
|
@@ -30727,6 +30912,146 @@ var LOG_VOCABULARY = {
|
|
|
30727
30912
|
...WEB_SYNC_LOG_AREAS
|
|
30728
30913
|
};
|
|
30729
30914
|
|
|
30915
|
+
// ../protocol/src/log-essential-labels.ts
|
|
30916
|
+
var ERROR_NAMES = new Set([
|
|
30917
|
+
"Error",
|
|
30918
|
+
"TypeError",
|
|
30919
|
+
"RangeError",
|
|
30920
|
+
"ReferenceError",
|
|
30921
|
+
"SyntaxError",
|
|
30922
|
+
"URIError",
|
|
30923
|
+
"EvalError",
|
|
30924
|
+
"AggregateError",
|
|
30925
|
+
"AbortError",
|
|
30926
|
+
"TimeoutError",
|
|
30927
|
+
"SystemError"
|
|
30928
|
+
]);
|
|
30929
|
+
var ERROR_CODES2 = new Set([
|
|
30930
|
+
"EACCES",
|
|
30931
|
+
"EADDRINUSE",
|
|
30932
|
+
"EADDRNOTAVAIL",
|
|
30933
|
+
"EAGAIN",
|
|
30934
|
+
"EBADF",
|
|
30935
|
+
"EBUSY",
|
|
30936
|
+
"ECANCELED",
|
|
30937
|
+
"ECONNABORTED",
|
|
30938
|
+
"ECONNREFUSED",
|
|
30939
|
+
"ECONNRESET",
|
|
30940
|
+
"EEXIST",
|
|
30941
|
+
"EHOSTUNREACH",
|
|
30942
|
+
"EINTR",
|
|
30943
|
+
"EINVAL",
|
|
30944
|
+
"EIO",
|
|
30945
|
+
"EISDIR",
|
|
30946
|
+
"EMFILE",
|
|
30947
|
+
"ENETUNREACH",
|
|
30948
|
+
"ENFILE",
|
|
30949
|
+
"ENOENT",
|
|
30950
|
+
"ENOMEM",
|
|
30951
|
+
"ENOSPC",
|
|
30952
|
+
"ENOSYS",
|
|
30953
|
+
"ENOTDIR",
|
|
30954
|
+
"ENOTEMPTY",
|
|
30955
|
+
"ENOTFOUND",
|
|
30956
|
+
"EPERM",
|
|
30957
|
+
"EPIPE",
|
|
30958
|
+
"EROFS",
|
|
30959
|
+
"ETIMEDOUT",
|
|
30960
|
+
"EXDEV",
|
|
30961
|
+
"SQLITE_BUSY",
|
|
30962
|
+
"SQLITE_CORRUPT",
|
|
30963
|
+
"SQLITE_FULL",
|
|
30964
|
+
"SQLITE_IOERR",
|
|
30965
|
+
"SQLITE_NOTADB",
|
|
30966
|
+
"SQLITE_READONLY",
|
|
30967
|
+
"ERR_CANCELED",
|
|
30968
|
+
"ERR_STREAM_DESTROYED"
|
|
30969
|
+
]);
|
|
30970
|
+
var SYSCALLS = new Set([
|
|
30971
|
+
"open",
|
|
30972
|
+
"read",
|
|
30973
|
+
"write",
|
|
30974
|
+
"stat",
|
|
30975
|
+
"lstat",
|
|
30976
|
+
"mkdir",
|
|
30977
|
+
"rmdir",
|
|
30978
|
+
"readdir",
|
|
30979
|
+
"rename",
|
|
30980
|
+
"unlink",
|
|
30981
|
+
"fsync",
|
|
30982
|
+
"fdatasync",
|
|
30983
|
+
"close",
|
|
30984
|
+
"access",
|
|
30985
|
+
"chmod",
|
|
30986
|
+
"copyfile",
|
|
30987
|
+
"connect",
|
|
30988
|
+
"listen",
|
|
30989
|
+
"bind",
|
|
30990
|
+
"spawn",
|
|
30991
|
+
"kill",
|
|
30992
|
+
"getaddrinfo"
|
|
30993
|
+
]);
|
|
30994
|
+
var SIGNALS = new Set([
|
|
30995
|
+
"SIGABRT",
|
|
30996
|
+
"SIGALRM",
|
|
30997
|
+
"SIGBUS",
|
|
30998
|
+
"SIGCHLD",
|
|
30999
|
+
"SIGCONT",
|
|
31000
|
+
"SIGFPE",
|
|
31001
|
+
"SIGHUP",
|
|
31002
|
+
"SIGILL",
|
|
31003
|
+
"SIGINT",
|
|
31004
|
+
"SIGKILL",
|
|
31005
|
+
"SIGPIPE",
|
|
31006
|
+
"SIGQUIT",
|
|
31007
|
+
"SIGSEGV",
|
|
31008
|
+
"SIGSTOP",
|
|
31009
|
+
"SIGTERM",
|
|
31010
|
+
"SIGTRAP",
|
|
31011
|
+
"SIGTSTP",
|
|
31012
|
+
"SIGTTIN",
|
|
31013
|
+
"SIGTTOU",
|
|
31014
|
+
"SIGUSR1",
|
|
31015
|
+
"SIGUSR2",
|
|
31016
|
+
"SIGWINCH",
|
|
31017
|
+
"SIGXCPU",
|
|
31018
|
+
"SIGXFSZ"
|
|
31019
|
+
]);
|
|
31020
|
+
var PROVIDERS3 = new Set(["claude", "codex", "opencode", "cursor", "grok", "acp", "pi"]);
|
|
31021
|
+
var UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
|
|
31022
|
+
var SOURCE = new RegExp(`^(?:claude|codex|opencode|cursor|grok|acp|pi):${UUID}$`, "i");
|
|
31023
|
+
|
|
31024
|
+
// ../protocol/src/log-essential.ts
|
|
31025
|
+
var vocabulary = LOG_VOCABULARY;
|
|
31026
|
+
var UNDECLARED_ERROR_LABELS = new Set([
|
|
31027
|
+
"site",
|
|
31028
|
+
"kind",
|
|
31029
|
+
"step",
|
|
31030
|
+
"reason",
|
|
31031
|
+
"signal",
|
|
31032
|
+
"code"
|
|
31033
|
+
]);
|
|
31034
|
+
function eventSpec(area, event) {
|
|
31035
|
+
const spec = Object.hasOwn(vocabulary, area) ? vocabulary[area] : undefined;
|
|
31036
|
+
if (!spec || !Object.hasOwn(spec.events, event))
|
|
31037
|
+
return null;
|
|
31038
|
+
const definition = spec.events[event];
|
|
31039
|
+
return typeof definition === "object" && definition.essential ? definition : null;
|
|
31040
|
+
}
|
|
31041
|
+
function declaredEssential(area, event, level) {
|
|
31042
|
+
const spec = eventSpec(area, event);
|
|
31043
|
+
return spec && (spec.minLevel !== "error" || level === "error") ? spec : null;
|
|
31044
|
+
}
|
|
31045
|
+
function hasEssentialEvents(area) {
|
|
31046
|
+
const spec = Object.hasOwn(vocabulary, area) ? vocabulary[area] : undefined;
|
|
31047
|
+
return spec !== undefined && Object.values(spec.events).some((event) => typeof event === "object" && event.essential);
|
|
31048
|
+
}
|
|
31049
|
+
function isEssentialEntry(area, event, level) {
|
|
31050
|
+
if (area === "logging" && event === "essential.write-failed")
|
|
31051
|
+
return false;
|
|
31052
|
+
return level === "error" || declaredEssential(area, event, level) !== null;
|
|
31053
|
+
}
|
|
31054
|
+
|
|
30730
31055
|
// ../protocol/src/logger.ts
|
|
30731
31056
|
var LOG_LEVELS = ["error", "warn", "info", "debug", "trace"];
|
|
30732
31057
|
var MAX_FIELD_CHARS = 2048;
|
|
@@ -30771,7 +31096,9 @@ var DEFAULT_CONFIG = {
|
|
|
30771
31096
|
level: "info",
|
|
30772
31097
|
areaLevels: {},
|
|
30773
31098
|
format: "text",
|
|
30774
|
-
sink: consoleSink
|
|
31099
|
+
sink: consoleSink,
|
|
31100
|
+
essentialSink: null,
|
|
31101
|
+
relayEssential: false
|
|
30775
31102
|
};
|
|
30776
31103
|
var config2 = DEFAULT_CONFIG;
|
|
30777
31104
|
var generation = 0;
|
|
@@ -30882,17 +31209,38 @@ function renderText(record) {
|
|
|
30882
31209
|
function renderJson(record) {
|
|
30883
31210
|
return escapeLogLine(JSON.stringify(record));
|
|
30884
31211
|
}
|
|
31212
|
+
function offerEssential(record) {
|
|
31213
|
+
if (!config2.essentialSink || !isEssentialEntry(record.area, record.event, record.level))
|
|
31214
|
+
return;
|
|
31215
|
+
try {
|
|
31216
|
+
config2.essentialSink(record);
|
|
31217
|
+
} catch {}
|
|
31218
|
+
}
|
|
30885
31219
|
function deliver(record) {
|
|
31220
|
+
let delivered = true;
|
|
30886
31221
|
try {
|
|
30887
31222
|
config2.sink({
|
|
30888
31223
|
method: OUTPUT_METHOD[record.level],
|
|
30889
31224
|
line: config2.format === "json" ? renderJson(record) : renderText(record),
|
|
30890
31225
|
record
|
|
30891
31226
|
});
|
|
30892
|
-
return true;
|
|
30893
31227
|
} catch {
|
|
30894
|
-
|
|
31228
|
+
delivered = false;
|
|
30895
31229
|
}
|
|
31230
|
+
offerEssential(record);
|
|
31231
|
+
return delivered;
|
|
31232
|
+
}
|
|
31233
|
+
function deliverEssentialOnly(record) {
|
|
31234
|
+
if (config2.essentialSink) {
|
|
31235
|
+
offerEssential(record);
|
|
31236
|
+
return;
|
|
31237
|
+
}
|
|
31238
|
+
if (!config2.relayEssential)
|
|
31239
|
+
return;
|
|
31240
|
+
const marked = { ...record, essentialOnly: true };
|
|
31241
|
+
try {
|
|
31242
|
+
config2.sink({ method: OUTPUT_METHOD[record.level], line: renderJson(marked), record: marked });
|
|
31243
|
+
} catch {}
|
|
30896
31244
|
}
|
|
30897
31245
|
function buildRecord(level, area, event, fields) {
|
|
30898
31246
|
const clean = fields ? sanitizeFields(fields, areaSpec(area)?.maxStringChars ?? MAX_FIELD_CHARS) : undefined;
|
|
@@ -31057,12 +31405,17 @@ function deliverEvent(level, area, event, fields) {
|
|
|
31057
31405
|
return deliver(buildRecord(level, area, event, fields));
|
|
31058
31406
|
}
|
|
31059
31407
|
function tryWriteLog(level, area, event, fields) {
|
|
31060
|
-
if (LEVEL_RANK[level] > thresholdRank(area))
|
|
31408
|
+
if (LEVEL_RANK[level] > thresholdRank(area)) {
|
|
31409
|
+
if (isEssentialEntry(area, event, level)) {
|
|
31410
|
+
deliverEssentialOnly(buildRecord(level, area, event, resolveFields(fields)));
|
|
31411
|
+
}
|
|
31061
31412
|
return false;
|
|
31413
|
+
}
|
|
31062
31414
|
return deliverEvent(level, area, event, resolveFields(fields));
|
|
31063
31415
|
}
|
|
31064
31416
|
function createLogger(area) {
|
|
31065
31417
|
const spec = areaSpec(area);
|
|
31418
|
+
const mayHoldEssential = hasEssentialEvents(area);
|
|
31066
31419
|
let seenGeneration = -1;
|
|
31067
31420
|
let rank = 0;
|
|
31068
31421
|
const enabled = (level) => {
|
|
@@ -31075,9 +31428,16 @@ function createLogger(area) {
|
|
|
31075
31428
|
const writeResolved = (level, event, resolved) => {
|
|
31076
31429
|
deliverEvent(level, area, event, resolved);
|
|
31077
31430
|
};
|
|
31431
|
+
const writeFiltered = (level, event, fields) => {
|
|
31432
|
+
if (!mayHoldEssential || !isEssentialEntry(area, event, level))
|
|
31433
|
+
return;
|
|
31434
|
+
deliverEssentialOnly(buildRecord(level, area, event, resolveFields(fields)));
|
|
31435
|
+
};
|
|
31078
31436
|
const write = (level, event, fields) => {
|
|
31079
|
-
if (!enabled(level))
|
|
31437
|
+
if (!enabled(level)) {
|
|
31438
|
+
writeFiltered(level, event, fields);
|
|
31080
31439
|
return;
|
|
31440
|
+
}
|
|
31081
31441
|
writeResolved(level, event, resolveFields(fields));
|
|
31082
31442
|
};
|
|
31083
31443
|
return {
|
|
@@ -31088,8 +31448,10 @@ function createLogger(area) {
|
|
|
31088
31448
|
trace: (event, fields) => write("trace", event, fields),
|
|
31089
31449
|
throttled: (level, event, options) => {
|
|
31090
31450
|
syncThrottleLevels();
|
|
31091
|
-
if (!enabled(level))
|
|
31451
|
+
if (!enabled(level)) {
|
|
31452
|
+
writeFiltered(level, event, options.fields);
|
|
31092
31453
|
return;
|
|
31454
|
+
}
|
|
31093
31455
|
if (!spec || !Object.hasOwn(spec.events, event) || event.startsWith("throttle.") || !Object.hasOwn(spec.events, "throttle.recovered")) {
|
|
31094
31456
|
deliver(buildRecord(level, spec ? area : "logging", spec ? "invalid-event" : "unknown-area", undefined));
|
|
31095
31457
|
return;
|
|
@@ -31163,41 +31525,46 @@ async function drainPersistence() {
|
|
|
31163
31525
|
return;
|
|
31164
31526
|
});
|
|
31165
31527
|
}
|
|
31166
|
-
function
|
|
31167
|
-
const
|
|
31168
|
-
|
|
31169
|
-
|
|
31170
|
-
|
|
31171
|
-
|
|
31172
|
-
|
|
31173
|
-
|
|
31174
|
-
|
|
31175
|
-
|
|
31176
|
-
|
|
31177
|
-
|
|
31178
|
-
|
|
31528
|
+
function encodeStateWithinBudget(payload, lastAccessedById, budget) {
|
|
31529
|
+
const envelope = JSON.stringify({ ...payload, sessions: [] });
|
|
31530
|
+
const head = envelope.slice(0, -2);
|
|
31531
|
+
const records = payload.sessions.map((session) => JSON.stringify(session));
|
|
31532
|
+
const separators = Math.max(0, records.length - 1);
|
|
31533
|
+
let total = Buffer.byteLength(envelope) + separators;
|
|
31534
|
+
for (const record of records)
|
|
31535
|
+
total += Buffer.byteLength(record);
|
|
31536
|
+
if (total > budget) {
|
|
31537
|
+
const oldestFirst = payload.sessions.map((session, index) => ({ session, index })).sort((left, right) => (lastAccessedById.get(left.session.id) ?? 0) - (lastAccessedById.get(right.session.id) ?? 0));
|
|
31538
|
+
let shed = 0;
|
|
31539
|
+
for (const { session, index } of oldestFirst) {
|
|
31540
|
+
if (total <= budget)
|
|
31541
|
+
break;
|
|
31542
|
+
if (session.messages.length === 0)
|
|
31543
|
+
continue;
|
|
31544
|
+
session.droppedMessages = (session.droppedMessages ?? 0) + session.messages.length;
|
|
31545
|
+
session.messages = [];
|
|
31546
|
+
session.transcriptTruncated = true;
|
|
31547
|
+
shed += 1;
|
|
31548
|
+
const trimmed = JSON.stringify(session);
|
|
31549
|
+
total += Buffer.byteLength(trimmed) - Buffer.byteLength(records[index]);
|
|
31550
|
+
records[index] = trimmed;
|
|
31551
|
+
}
|
|
31552
|
+
if (total > budget) {
|
|
31553
|
+
log.warn("state.over-budget", { sessions: shed });
|
|
31554
|
+
return;
|
|
31179
31555
|
}
|
|
31556
|
+
log.warn("state.transcripts-shed", { sessions: shed });
|
|
31180
31557
|
}
|
|
31181
|
-
|
|
31182
|
-
return false;
|
|
31558
|
+
return `${head}${records.join(",")}]}`;
|
|
31183
31559
|
}
|
|
31184
31560
|
async function persistNow(write = { barrier: false }) {
|
|
31185
31561
|
const stateFile = stateFilePath();
|
|
31186
31562
|
if (!stateFile)
|
|
31187
31563
|
return;
|
|
31188
31564
|
const live = Array.from(sessions.values()).filter((state) => !isPendingRemoval(state));
|
|
31189
|
-
const
|
|
31190
|
-
|
|
31191
|
-
|
|
31192
|
-
sessions: live.map(toPersisted)
|
|
31193
|
-
};
|
|
31194
|
-
let serialized = JSON.stringify(payload);
|
|
31195
|
-
if (Buffer.byteLength(serialized) > MAX_STATE_FILE_BYTES) {
|
|
31196
|
-
const order = new Map(live.map((state) => [state.id, state.lastAccessed]));
|
|
31197
|
-
if (!shedToFit(payload, order)) {
|
|
31198
|
-
throw new Error("Pi bridge state exceeds its persistence budget");
|
|
31199
|
-
}
|
|
31200
|
-
serialized = JSON.stringify(payload);
|
|
31565
|
+
const serialized = encodeStateWithinBudget({ version: 1, provider: "pi", sessions: live.map(toPersisted) }, new Map(live.map((state) => [state.id, state.lastAccessed])), MAX_STATE_FILE_BYTES);
|
|
31566
|
+
if (serialized === undefined) {
|
|
31567
|
+
throw new Error("Pi bridge state exceeds its persistence budget");
|
|
31201
31568
|
}
|
|
31202
31569
|
await mkdir(dirname(stateFile), { recursive: true, mode: 448 });
|
|
31203
31570
|
if (writeGateForTests)
|
|
@@ -31273,6 +31640,7 @@ function restoreSession(entry) {
|
|
|
31273
31640
|
state.id = entry.id;
|
|
31274
31641
|
if (isNativeAgentExecutionPolicy(entry.policy))
|
|
31275
31642
|
state.policy = entry.policy;
|
|
31643
|
+
state.policyPending = true;
|
|
31276
31644
|
if (nonBlank(entry.sessionFile))
|
|
31277
31645
|
state.sessionFile = entry.sessionFile;
|
|
31278
31646
|
if (nonBlank(entry.piSessionId))
|
|
@@ -31586,7 +31954,7 @@ function readString2(value) {
|
|
|
31586
31954
|
}
|
|
31587
31955
|
// ../../bridges/pi-bridge/src/agent-session.ts
|
|
31588
31956
|
import { randomBytes as randomBytes6 } from "node:crypto";
|
|
31589
|
-
import { existsSync as existsSync2 } from "node:fs";
|
|
31957
|
+
import { existsSync as existsSync2, statSync } from "node:fs";
|
|
31590
31958
|
|
|
31591
31959
|
// ../protocol/src/agent-system-instructions.ts
|
|
31592
31960
|
var AGENT_IMAGE_PREVIEW_INSTRUCTION = "Orkestrator renders Markdown images inline in the transcript. When you show the user an image in your reply (a screenshot, rendered preview, or chart) using Markdown image syntax, reference it by its absolute path. In a managed worktree or container environment, save the file inside the working directory, preferably in a git-ignored folder so preview files stay out of the change set. Local image previews are limited to Orkestrator-managed workspace storage or the container's /workspace. Project-home checkouts are excluded from host preview reads, even when they are the working directory, so images saved there cannot be previewed from a local Markdown path. Paths outside previewable storage, such as /tmp, also show a placeholder.";
|
|
@@ -31601,9 +31969,100 @@ function agentSystemInstructions(providerSpecific = []) {
|
|
|
31601
31969
|
`);
|
|
31602
31970
|
}
|
|
31603
31971
|
|
|
31972
|
+
// ../protocol/src/execution-policy-narrowing.ts
|
|
31973
|
+
var APPROVALS_STRICTNESS = {
|
|
31974
|
+
"auto-approve": 0,
|
|
31975
|
+
ask: 1,
|
|
31976
|
+
deny: 2
|
|
31977
|
+
};
|
|
31978
|
+
var SANDBOX_STRICTNESS = {
|
|
31979
|
+
none: 0,
|
|
31980
|
+
container: 1,
|
|
31981
|
+
provider: 2
|
|
31982
|
+
};
|
|
31983
|
+
function networkStrictness(value) {
|
|
31984
|
+
return value === "restricted" ? 1 : 0;
|
|
31985
|
+
}
|
|
31986
|
+
function isSubset(candidate, of) {
|
|
31987
|
+
const allowed = new Set(of);
|
|
31988
|
+
return candidate.every((item) => allowed.has(item));
|
|
31989
|
+
}
|
|
31990
|
+
function rawCapabilityDenials(policy) {
|
|
31991
|
+
return [
|
|
31992
|
+
...policy.capabilityPolicy?.deny ?? [],
|
|
31993
|
+
...policy.capabilityPolicy?.extendedDeny ?? []
|
|
31994
|
+
];
|
|
31995
|
+
}
|
|
31996
|
+
function executionPolicyWidenings(current, next) {
|
|
31997
|
+
if (!current)
|
|
31998
|
+
return [];
|
|
31999
|
+
const widened = [];
|
|
32000
|
+
if (next.id !== current.id)
|
|
32001
|
+
widened.push("id");
|
|
32002
|
+
if (APPROVALS_STRICTNESS[next.approvals] < APPROVALS_STRICTNESS[current.approvals]) {
|
|
32003
|
+
widened.push("approvals");
|
|
32004
|
+
}
|
|
32005
|
+
if (SANDBOX_STRICTNESS[next.sandbox] < SANDBOX_STRICTNESS[current.sandbox]) {
|
|
32006
|
+
widened.push("sandbox");
|
|
32007
|
+
}
|
|
32008
|
+
if (next.projectResources && !current.projectResources)
|
|
32009
|
+
widened.push("projectResources");
|
|
32010
|
+
if (networkStrictness(next.networkAccess) < networkStrictness(current.networkAccess)) {
|
|
32011
|
+
widened.push("networkAccess");
|
|
32012
|
+
}
|
|
32013
|
+
if (networkStrictness(next.containerNetworkAccess) < networkStrictness(current.containerNetworkAccess)) {
|
|
32014
|
+
widened.push("containerNetworkAccess");
|
|
32015
|
+
}
|
|
32016
|
+
const currentAllow = current.toolPolicy?.allow;
|
|
32017
|
+
const nextAllow = next.toolPolicy?.allow;
|
|
32018
|
+
const allowNarrows = currentAllow === undefined ? nextAllow === undefined || nextAllow.length === 0 : nextAllow !== undefined && isSubset(nextAllow, currentAllow);
|
|
32019
|
+
if (!allowNarrows)
|
|
32020
|
+
widened.push("toolPolicy.allow");
|
|
32021
|
+
if (!isSubset(current.toolPolicy?.deny ?? [], next.toolPolicy?.deny ?? [])) {
|
|
32022
|
+
widened.push("toolPolicy.deny");
|
|
32023
|
+
}
|
|
32024
|
+
if (!isSubset(rawCapabilityDenials(current), rawCapabilityDenials(next))) {
|
|
32025
|
+
widened.push("capabilityPolicy.deny");
|
|
32026
|
+
}
|
|
32027
|
+
if (!isSubset(next.capabilityPolicy?.allow ?? [], current.capabilityPolicy?.allow ?? [])) {
|
|
32028
|
+
widened.push("capabilityPolicy.allow");
|
|
32029
|
+
}
|
|
32030
|
+
const currentServers = nativeAgentUserMcpGrant(current);
|
|
32031
|
+
const nextServers = nativeAgentUserMcpGrant(next);
|
|
32032
|
+
if (currentServers !== undefined && (nextServers === undefined || !isSubset(nextServers, currentServers))) {
|
|
32033
|
+
widened.push("capabilityPolicy.userMcpServers");
|
|
32034
|
+
}
|
|
32035
|
+
return widened;
|
|
32036
|
+
}
|
|
32037
|
+
var POLICY_WIDENING_REFUSED_CODE = "policy-widening-refused";
|
|
32038
|
+
function policyWideningRefusal(widened) {
|
|
32039
|
+
return {
|
|
32040
|
+
error: "Execution policy can only be narrowed on a live session; a wider policy applies after the agent bridge restarts.",
|
|
32041
|
+
code: POLICY_WIDENING_REFUSED_CODE,
|
|
32042
|
+
widened
|
|
32043
|
+
};
|
|
32044
|
+
}
|
|
32045
|
+
|
|
32046
|
+
class PolicyWideningRefusedError extends Error {
|
|
32047
|
+
widened;
|
|
32048
|
+
constructor(widened) {
|
|
32049
|
+
super(policyWideningRefusal(widened).error);
|
|
32050
|
+
this.widened = widened;
|
|
32051
|
+
this.name = "PolicyWideningRefusedError";
|
|
32052
|
+
}
|
|
32053
|
+
refusal() {
|
|
32054
|
+
return policyWideningRefusal(this.widened);
|
|
32055
|
+
}
|
|
32056
|
+
}
|
|
32057
|
+
function assertExecutionPolicyNotWidened(current, next) {
|
|
32058
|
+
const widened = executionPolicyWidenings(current, next);
|
|
32059
|
+
if (widened.length > 0)
|
|
32060
|
+
throw new PolicyWideningRefusedError(widened);
|
|
32061
|
+
}
|
|
32062
|
+
|
|
31604
32063
|
// ../../bridges/pi-bridge/src/agent-session.ts
|
|
31605
|
-
import { realpath, stat as
|
|
31606
|
-
import { join as
|
|
32064
|
+
import { realpath, stat as stat3 } from "node:fs/promises";
|
|
32065
|
+
import { join as join7, resolve as resolve3, sep } from "node:path";
|
|
31607
32066
|
|
|
31608
32067
|
// ../protocol/src/node/command-change-journal.ts
|
|
31609
32068
|
import { appendFile, mkdir as mkdir2, readFile as readFile3, rename as rename2, rm, stat, writeFile as writeFile2 } from "node:fs/promises";
|
|
@@ -33684,7 +34143,44 @@ async function overlayCommandChanges(state, options = {}) {
|
|
|
33684
34143
|
} catch {}
|
|
33685
34144
|
}
|
|
33686
34145
|
|
|
34146
|
+
// ../../bridges/pi-bridge/src/session-list-cache.ts
|
|
34147
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
34148
|
+
import { readdir, stat as stat2 } from "node:fs/promises";
|
|
34149
|
+
import { join as join6 } from "node:path";
|
|
34150
|
+
var SESSION_LIST_CACHE_TTL_MS = 30000;
|
|
34151
|
+
var MAX_CACHED_SESSION_LIST_BYTES = 2 * 1024 * 1024;
|
|
34152
|
+
var cached2;
|
|
34153
|
+
async function sessionFilesStamp(directory) {
|
|
34154
|
+
let names;
|
|
34155
|
+
try {
|
|
34156
|
+
names = (await readdir(directory)).filter((name) => name.endsWith(".jsonl")).sort();
|
|
34157
|
+
} catch {
|
|
34158
|
+
return;
|
|
34159
|
+
}
|
|
34160
|
+
const stats = await Promise.all(names.map((name) => stat2(join6(directory, name)).catch(() => {
|
|
34161
|
+
return;
|
|
34162
|
+
})));
|
|
34163
|
+
const hash = createHash4("sha256");
|
|
34164
|
+
for (const [index, name] of names.entries()) {
|
|
34165
|
+
const file = stats[index];
|
|
34166
|
+
hash.update(file ? `${name}\x00${file.size}\x00${file.mtimeMs}\x00${file.ctimeMs}\x00${file.ino}
|
|
34167
|
+
` : `${name}\x00gone
|
|
34168
|
+
`);
|
|
34169
|
+
}
|
|
34170
|
+
return hash.digest("hex");
|
|
34171
|
+
}
|
|
34172
|
+
function cachedSessionList(directory, stamp) {
|
|
34173
|
+
if (stamp === undefined || cached2?.directory !== directory || cached2.stamp !== stamp || performance.now() >= cached2.expiresAt) {
|
|
34174
|
+
return;
|
|
34175
|
+
}
|
|
34176
|
+
return cached2.entries;
|
|
34177
|
+
}
|
|
34178
|
+
function rememberSessionList(directory, stamp, entries) {
|
|
34179
|
+
cached2 = stamp !== undefined && encodedJsonBytes(entries) <= MAX_CACHED_SESSION_LIST_BYTES ? { directory, stamp, entries, expiresAt: performance.now() + SESSION_LIST_CACHE_TTL_MS } : undefined;
|
|
34180
|
+
}
|
|
34181
|
+
|
|
33687
34182
|
// ../../bridges/pi-bridge/src/agent-session.ts
|
|
34183
|
+
var log2 = createLogger("bridge.pi");
|
|
33688
34184
|
var closingSessions = new WeakSet;
|
|
33689
34185
|
|
|
33690
34186
|
class SessionClosingError extends Error {
|
|
@@ -33693,6 +34189,13 @@ class SessionClosingError extends Error {
|
|
|
33693
34189
|
super("This Pi session is closing; retry once the close completes");
|
|
33694
34190
|
}
|
|
33695
34191
|
}
|
|
34192
|
+
|
|
34193
|
+
class SessionBusyError extends Error {
|
|
34194
|
+
name = "SessionBusyError";
|
|
34195
|
+
constructor() {
|
|
34196
|
+
super("The Pi session is already running");
|
|
34197
|
+
}
|
|
34198
|
+
}
|
|
33696
34199
|
function isSessionClosed(state) {
|
|
33697
34200
|
return closingSessions.has(state);
|
|
33698
34201
|
}
|
|
@@ -33794,8 +34297,9 @@ async function createSession(clientSessionKey, patch, policy) {
|
|
|
33794
34297
|
throw new SessionClosingError;
|
|
33795
34298
|
if (existing) {
|
|
33796
34299
|
const resolved = resolvePiExecutionPolicy(policy);
|
|
33797
|
-
if (policy || resolved.id === "coordinator-read-only")
|
|
33798
|
-
existing
|
|
34300
|
+
if (policy || resolved.id === "coordinator-read-only") {
|
|
34301
|
+
await applyRequestedPolicy(existing, resolved);
|
|
34302
|
+
}
|
|
33799
34303
|
if (resolved.id === "coordinator-read-only" && existing.readOnly !== true) {
|
|
33800
34304
|
await setSessionReadOnly(existing, true);
|
|
33801
34305
|
}
|
|
@@ -33803,12 +34307,24 @@ async function createSession(clientSessionKey, patch, policy) {
|
|
|
33803
34307
|
return existing;
|
|
33804
34308
|
}
|
|
33805
34309
|
const inFlight = sessionCreations.get(clientSessionKey);
|
|
33806
|
-
if (inFlight)
|
|
33807
|
-
|
|
34310
|
+
if (inFlight) {
|
|
34311
|
+
const existing = await inFlight;
|
|
34312
|
+
if (isSessionClosed(existing))
|
|
34313
|
+
throw new SessionClosingError;
|
|
34314
|
+
const resolved = resolvePiExecutionPolicy(policy);
|
|
34315
|
+
if (policy || resolved.id === "coordinator-read-only") {
|
|
34316
|
+
await applyRequestedPolicy(existing, resolved);
|
|
34317
|
+
}
|
|
34318
|
+
if (resolved.id === "coordinator-read-only" && existing.readOnly !== true) {
|
|
34319
|
+
await setSessionReadOnly(existing, true);
|
|
34320
|
+
}
|
|
34321
|
+
return existing;
|
|
34322
|
+
}
|
|
33808
34323
|
}
|
|
33809
34324
|
const work = (async () => {
|
|
33810
34325
|
const resolved = resolvePiExecutionPolicy(policy);
|
|
33811
34326
|
const state = newSessionState(clientSessionKey, resolved);
|
|
34327
|
+
state.policyPending = !policy;
|
|
33812
34328
|
state.promptJournalComplete = true;
|
|
33813
34329
|
if (resolved.id === "coordinator-read-only")
|
|
33814
34330
|
state.readOnly = true;
|
|
@@ -33829,6 +34345,8 @@ async function createSession(clientSessionKey, patch, policy) {
|
|
|
33829
34345
|
}
|
|
33830
34346
|
}
|
|
33831
34347
|
async function ensureSession(state) {
|
|
34348
|
+
if (policyChanges.has(state))
|
|
34349
|
+
throw new SessionBusyError;
|
|
33832
34350
|
if (closingSessions.has(state))
|
|
33833
34351
|
throw new SessionClosingError;
|
|
33834
34352
|
if (state.session)
|
|
@@ -34097,9 +34615,9 @@ function projectResourceDiscoveryOptions(enabled = false, readOnly = false) {
|
|
|
34097
34615
|
}
|
|
34098
34616
|
function coordinatorProjectSkillPaths(cwd = workingDirectory) {
|
|
34099
34617
|
return [
|
|
34100
|
-
|
|
34101
|
-
|
|
34102
|
-
|
|
34618
|
+
join7(cwd, ".pi", "skills"),
|
|
34619
|
+
join7(cwd, ".agents", "skills"),
|
|
34620
|
+
join7(cwd, ".claude", "skills")
|
|
34103
34621
|
].filter((path) => existsSync2(path));
|
|
34104
34622
|
}
|
|
34105
34623
|
function piResourceLoaderPolicy(state, cwd = workingDirectory) {
|
|
@@ -34129,6 +34647,35 @@ function coordinatorProcessPolicy() {
|
|
|
34129
34647
|
networkAccess: "restricted"
|
|
34130
34648
|
};
|
|
34131
34649
|
}
|
|
34650
|
+
function liveExecutionPolicy(state) {
|
|
34651
|
+
return state.policyPending ? undefined : state.policy;
|
|
34652
|
+
}
|
|
34653
|
+
var policyChanges = new WeakSet;
|
|
34654
|
+
async function applyRequestedPolicy(state, policy) {
|
|
34655
|
+
if (policyChanges.has(state))
|
|
34656
|
+
throw new SessionBusyError;
|
|
34657
|
+
assertExecutionPolicyNotWidened(liveExecutionPolicy(state), policy);
|
|
34658
|
+
if (JSON.stringify(state.policy) !== JSON.stringify(policy)) {
|
|
34659
|
+
if (state.status === "running" || state.dispatching)
|
|
34660
|
+
throw new SessionBusyError;
|
|
34661
|
+
policyChanges.add(state);
|
|
34662
|
+
state.dispatching = true;
|
|
34663
|
+
try {
|
|
34664
|
+
await state.attaching?.catch(() => {
|
|
34665
|
+
return;
|
|
34666
|
+
});
|
|
34667
|
+
await detachSession(state);
|
|
34668
|
+
if (isSessionClosed(state))
|
|
34669
|
+
throw new SessionClosingError;
|
|
34670
|
+
assertExecutionPolicyNotWidened(liveExecutionPolicy(state), policy);
|
|
34671
|
+
state.policy = policy;
|
|
34672
|
+
} finally {
|
|
34673
|
+
state.dispatching = false;
|
|
34674
|
+
policyChanges.delete(state);
|
|
34675
|
+
}
|
|
34676
|
+
}
|
|
34677
|
+
state.policyPending = false;
|
|
34678
|
+
}
|
|
34132
34679
|
function resolvePiExecutionPolicy(policy) {
|
|
34133
34680
|
if (process.env[BRIDGE_EXECUTION_POLICY_ENV2] === "coordinator-read-only") {
|
|
34134
34681
|
return coordinatorProcessPolicy();
|
|
@@ -34161,8 +34708,17 @@ function sessionManagerFor(state) {
|
|
|
34161
34708
|
const directory = sessionDirectory();
|
|
34162
34709
|
if (state.sessionFile) {
|
|
34163
34710
|
try {
|
|
34164
|
-
|
|
34165
|
-
|
|
34711
|
+
const hasHistory = (statSync(state.sessionFile, { throwIfNoEntry: false })?.size ?? 0) > 0;
|
|
34712
|
+
const manager = SessionManager.open(state.sessionFile, directory, workingDirectory);
|
|
34713
|
+
if (!hasHistory && (state.messages.length > 0 || state.promptSequence > 0)) {
|
|
34714
|
+
log2.warn("session.resume-fell-back", { sessionId: state.id });
|
|
34715
|
+
}
|
|
34716
|
+
return manager;
|
|
34717
|
+
} catch (error) {
|
|
34718
|
+
log2.warn("session.resume-fell-back", {
|
|
34719
|
+
sessionId: state.id,
|
|
34720
|
+
error: formatLogError(error, { message: false })
|
|
34721
|
+
});
|
|
34166
34722
|
state.sessionFile = undefined;
|
|
34167
34723
|
}
|
|
34168
34724
|
}
|
|
@@ -34267,9 +34823,31 @@ async function applyComposerToSession(state) {
|
|
|
34267
34823
|
state.revision += 1;
|
|
34268
34824
|
}
|
|
34269
34825
|
}
|
|
34826
|
+
var SESSION_LIST_TIMEOUT_MESSAGE = "Pi took too long to read its session history";
|
|
34827
|
+
var sessionListTimeoutMs = CATALOG_TIMEOUT_MS;
|
|
34828
|
+
function setSessionListTimeoutForTests(timeoutMs) {
|
|
34829
|
+
sessionListTimeoutMs = timeoutMs ?? CATALOG_TIMEOUT_MS;
|
|
34830
|
+
}
|
|
34270
34831
|
async function listResumableSessions() {
|
|
34271
|
-
const
|
|
34272
|
-
|
|
34832
|
+
const read = new AbortController;
|
|
34833
|
+
try {
|
|
34834
|
+
return await withTimeout(readResumableSessions(read.signal), sessionListTimeoutMs, SESSION_LIST_TIMEOUT_MESSAGE);
|
|
34835
|
+
} catch (error) {
|
|
34836
|
+
read.abort();
|
|
34837
|
+
if (error instanceof TimeoutError)
|
|
34838
|
+
throw error;
|
|
34839
|
+
log2.warn("session-list.failed", { error: formatLogError(error, { message: false }) });
|
|
34840
|
+
return [];
|
|
34841
|
+
}
|
|
34842
|
+
}
|
|
34843
|
+
async function readResumableSessions(signal) {
|
|
34844
|
+
const directory = SessionManager.create(workingDirectory, sessionDirectory()).getSessionDir();
|
|
34845
|
+
const stamp = await sessionFilesStamp(directory);
|
|
34846
|
+
const cached = cachedSessionList(directory, stamp);
|
|
34847
|
+
if (cached)
|
|
34848
|
+
return cached;
|
|
34849
|
+
const listed = await SessionManager.list(workingDirectory, sessionDirectory(), undefined, signal);
|
|
34850
|
+
const entries = listed.slice(0, MAX_RESUME_ENTRIES).map((info) => ({
|
|
34273
34851
|
sessionId: info.path,
|
|
34274
34852
|
...info.name?.trim() ? { title: info.name.trim() } : {},
|
|
34275
34853
|
...info.created ? { createdAt: new Date(info.created).toISOString() } : {},
|
|
@@ -34279,9 +34857,11 @@ async function listResumableSessions() {
|
|
|
34279
34857
|
...info.parentSessionPath ? { parentId: info.parentSessionPath } : {},
|
|
34280
34858
|
...info.parentSessionPath ? { branchLabel: info.name?.trim() || info.firstMessage.trim().slice(0, 80) || "Fork" } : {}
|
|
34281
34859
|
}));
|
|
34860
|
+
rememberSessionList(directory, stamp, entries);
|
|
34861
|
+
return entries;
|
|
34282
34862
|
}
|
|
34283
34863
|
function resumableSessionRoot() {
|
|
34284
|
-
return sessionDirectory() ??
|
|
34864
|
+
return sessionDirectory() ?? join7(agentDirectory() ?? getAgentDir(), "sessions");
|
|
34285
34865
|
}
|
|
34286
34866
|
async function assertResumableSessionFile(sessionFile) {
|
|
34287
34867
|
const root = resumableSessionRoot();
|
|
@@ -34297,7 +34877,7 @@ async function assertResumableSessionFile(sessionFile) {
|
|
|
34297
34877
|
if (real !== rootReal && !real.startsWith(rootReal.endsWith(sep) ? rootReal : rootReal + sep)) {
|
|
34298
34878
|
throw new Error("That Pi session file is outside this environment's session directory");
|
|
34299
34879
|
}
|
|
34300
|
-
const info = await
|
|
34880
|
+
const info = await stat3(real).catch(() => {
|
|
34301
34881
|
return;
|
|
34302
34882
|
});
|
|
34303
34883
|
if (!info?.isFile())
|
|
@@ -34316,15 +34896,8 @@ async function resumeSession(sessionFile, patch, policy) {
|
|
|
34316
34896
|
if (sameFile) {
|
|
34317
34897
|
if (isSessionClosed(existing))
|
|
34318
34898
|
throw new SessionClosingError;
|
|
34319
|
-
if (policy
|
|
34320
|
-
|
|
34321
|
-
throw new Error("The Pi session is already running");
|
|
34322
|
-
}
|
|
34323
|
-
await detachSession(existing);
|
|
34324
|
-
if (isSessionClosed(existing))
|
|
34325
|
-
throw new SessionClosingError;
|
|
34326
|
-
existing.policy = resolvePiExecutionPolicy(policy);
|
|
34327
|
-
}
|
|
34899
|
+
if (policy)
|
|
34900
|
+
await applyRequestedPolicy(existing, resolvePiExecutionPolicy(policy));
|
|
34328
34901
|
applyComposerPatch(existing, patch);
|
|
34329
34902
|
existing.lastAccessed = Date.now();
|
|
34330
34903
|
return existing;
|
|
@@ -34335,12 +34908,15 @@ async function resumeSession(sessionFile, patch, policy) {
|
|
|
34335
34908
|
const existing = await inFlight;
|
|
34336
34909
|
if (isSessionClosed(existing))
|
|
34337
34910
|
throw new SessionClosingError;
|
|
34911
|
+
if (policy)
|
|
34912
|
+
await applyRequestedPolicy(existing, resolvePiExecutionPolicy(policy));
|
|
34338
34913
|
applyComposerPatch(existing, patch);
|
|
34339
34914
|
existing.lastAccessed = Date.now();
|
|
34340
34915
|
return existing;
|
|
34341
34916
|
}
|
|
34342
34917
|
const work = (async () => {
|
|
34343
34918
|
const state = newSessionState(undefined, resolvePiExecutionPolicy(policy));
|
|
34919
|
+
state.policyPending = !policy;
|
|
34344
34920
|
state.sessionFile = resolved;
|
|
34345
34921
|
applyComposerPatch(state, patch);
|
|
34346
34922
|
state.composer = await hydrateComposerForSession(state.composer, undefined, defaultModelIds(state));
|
|
@@ -34641,14 +35217,14 @@ function pushMessage(state, role, content, parts, createdAt, messageId = randomB
|
|
|
34641
35217
|
chargeTranscript(state, Buffer.byteLength(JSON.stringify(message)));
|
|
34642
35218
|
}
|
|
34643
35219
|
// ../protocol/src/node/bridge-diagnostics.ts
|
|
34644
|
-
import { createHash as
|
|
35220
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
34645
35221
|
|
|
34646
35222
|
// ../protocol/src/event-loop-stall-monitor.ts
|
|
34647
|
-
var
|
|
35223
|
+
var log3 = createLogger("event-loop");
|
|
34648
35224
|
var EVENT_LOOP_STALL_ALWAYS_LOG_MS = 1e4;
|
|
34649
35225
|
|
|
34650
35226
|
// ../protocol/src/node/bridge-diagnostics.ts
|
|
34651
|
-
var
|
|
35227
|
+
var log4 = createLogger("bridge.diagnostics");
|
|
34652
35228
|
var BRIDGE_DIAGNOSTICS_INTERVAL_MS = 60000;
|
|
34653
35229
|
var INTERVAL_MS = BRIDGE_DIAGNOSTICS_INTERVAL_MS;
|
|
34654
35230
|
var STALL_NO_DELTA_MS = 2 * INTERVAL_MS;
|
|
@@ -34740,7 +35316,7 @@ function sameSet(a, b) {
|
|
|
34740
35316
|
function identity(value) {
|
|
34741
35317
|
if (typeof value !== "string" || !value || value.length > MAX_ID_LENGTH)
|
|
34742
35318
|
return;
|
|
34743
|
-
return
|
|
35319
|
+
return createHash5("sha256").update(value).digest("hex").slice(0, 16);
|
|
34744
35320
|
}
|
|
34745
35321
|
function readBridgeDebugFlag(value) {
|
|
34746
35322
|
return value?.trim() === "1";
|
|
@@ -34813,16 +35389,16 @@ function safeDiagnosticMetrics(value) {
|
|
|
34813
35389
|
return result;
|
|
34814
35390
|
}
|
|
34815
35391
|
function bridgeDiagnosticsChangesEnabled() {
|
|
34816
|
-
return
|
|
35392
|
+
return log4.isEnabled("trace");
|
|
34817
35393
|
}
|
|
34818
35394
|
function writeBridgeDiagnostic({ bridge, event, payload }) {
|
|
34819
35395
|
return tryWriteLog("info", "bridge.diagnostics", event, { bridge, payload });
|
|
34820
35396
|
}
|
|
34821
35397
|
function bridgeDiagnosticsActive() {
|
|
34822
|
-
return
|
|
35398
|
+
return log4.isEnabled("info");
|
|
34823
35399
|
}
|
|
34824
35400
|
function bridgeDiagnosticsStreamEnabled(bridge) {
|
|
34825
|
-
return bridgeDebugEnabled(bridge) ||
|
|
35401
|
+
return bridgeDebugEnabled(bridge) || log4.isEnabled("debug");
|
|
34826
35402
|
}
|
|
34827
35403
|
function writeDiagnostic(bridge, event, payload, write) {
|
|
34828
35404
|
try {
|
|
@@ -35318,6 +35894,7 @@ var STRUCTURED_OUTPUT_FAILURE_CODES = new Set([
|
|
|
35318
35894
|
]);
|
|
35319
35895
|
|
|
35320
35896
|
// ../../bridges/pi-bridge/src/prompt.ts
|
|
35897
|
+
var log5 = createLogger("bridge.pi");
|
|
35321
35898
|
var STRUCTURED_PROMPT_INSTRUCTION_PREFIX = "End your turn with exactly one JSON value";
|
|
35322
35899
|
function structuredPromptInstruction(schema) {
|
|
35323
35900
|
return `${STRUCTURED_PROMPT_INSTRUCTION_PREFIX} matching this JSON Schema. That final message must be the JSON value alone, with no Markdown fence and no commentary around it.
|
|
@@ -35397,6 +35974,7 @@ ${structuredPromptInstruction(input.schema)}` : input.prompt;
|
|
|
35397
35974
|
});
|
|
35398
35975
|
const commandRun = input.extensionCommand ? beginCommandRun(state, input.extensionCommand) : undefined;
|
|
35399
35976
|
state.turnAborted = undefined;
|
|
35977
|
+
state.turnCancelRequested = undefined;
|
|
35400
35978
|
state.turnError = undefined;
|
|
35401
35979
|
state.currentTurnApiDurationMs = undefined;
|
|
35402
35980
|
let run;
|
|
@@ -35463,6 +36041,8 @@ ${structuredPromptInstruction(input.schema)}` : input.prompt;
|
|
|
35463
36041
|
const cancelTurn = (reason = "user") => {
|
|
35464
36042
|
if (cancelling)
|
|
35465
36043
|
return cancelling;
|
|
36044
|
+
if (reason === "user")
|
|
36045
|
+
state.turnCancelRequested = true;
|
|
35466
36046
|
const operation = (async () => {
|
|
35467
36047
|
if (commandRun) {
|
|
35468
36048
|
commandRun.cancelled = true;
|
|
@@ -35485,8 +36065,12 @@ ${structuredPromptInstruction(input.schema)}` : input.prompt;
|
|
|
35485
36065
|
})();
|
|
35486
36066
|
cancelling = operation;
|
|
35487
36067
|
operation.catch(() => {
|
|
35488
|
-
if (cancelling === operation)
|
|
36068
|
+
if (cancelling === operation) {
|
|
35489
36069
|
cancelling = undefined;
|
|
36070
|
+
if (reason === "user" && state.cancelTurn === cancelTurn) {
|
|
36071
|
+
state.turnCancelRequested = undefined;
|
|
36072
|
+
}
|
|
36073
|
+
}
|
|
35490
36074
|
});
|
|
35491
36075
|
return operation;
|
|
35492
36076
|
};
|
|
@@ -35521,6 +36105,7 @@ async function withinStartupDeadline(accepted, deadlineMs) {
|
|
|
35521
36105
|
}
|
|
35522
36106
|
}
|
|
35523
36107
|
function abandonStartup(state, session, claim, accepted, settled, input, diagnostics, error, evidenceTurnId) {
|
|
36108
|
+
log5.warn("turn.startup-timed-out", { sessionId: state.id });
|
|
35524
36109
|
state.status = "error";
|
|
35525
36110
|
state.error = error.message;
|
|
35526
36111
|
state.revision += 1;
|
|
@@ -35597,6 +36182,7 @@ async function followRun(state, session, run, promptSequence, input, promptTimeo
|
|
|
35597
36182
|
}
|
|
35598
36183
|
finishTurn(state, session, input);
|
|
35599
36184
|
} catch (error) {
|
|
36185
|
+
const abortedBeforeCleanup = state.turnAborted === true;
|
|
35600
36186
|
state.diagnostics?.terminalSettled("rejected");
|
|
35601
36187
|
state.diagnostics?.streamSettled("rejected");
|
|
35602
36188
|
state.diagnostics?.checkpoint("cancelling");
|
|
@@ -35610,7 +36196,7 @@ async function followRun(state, session, run, promptSequence, input, promptTimeo
|
|
|
35610
36196
|
commandRun.error ??= errorText(error);
|
|
35611
36197
|
settleCommandRun(state, commandRun, input.requestId);
|
|
35612
36198
|
}
|
|
35613
|
-
failTurn(state, session, error, input);
|
|
36199
|
+
failTurn(state, session, error, input, abortedBeforeCleanup);
|
|
35614
36200
|
} finally {
|
|
35615
36201
|
if (commandRun && state.commandRun === commandRun)
|
|
35616
36202
|
state.commandRun = undefined;
|
|
@@ -35674,7 +36260,13 @@ function recordInterruptedOutput(state, input, message) {
|
|
|
35674
36260
|
error: { code: "interrupted", message, provider: PROVIDER, retryable: true }
|
|
35675
36261
|
});
|
|
35676
36262
|
}
|
|
35677
|
-
function failTurn(state, session, error, input) {
|
|
36263
|
+
function failTurn(state, session, error, input, abortedBeforeCleanup = state.turnAborted === true) {
|
|
36264
|
+
if (!abortedBeforeCleanup && state.turnCancelRequested !== true) {
|
|
36265
|
+
log5.warn("turn.failed", {
|
|
36266
|
+
sessionId: state.id,
|
|
36267
|
+
error: formatLogError(error, { message: false })
|
|
36268
|
+
});
|
|
36269
|
+
}
|
|
35678
36270
|
settleTurn(state, session);
|
|
35679
36271
|
recordTurnEnded(state, piRunId(state), "failed");
|
|
35680
36272
|
state.status = "error";
|
|
@@ -35884,7 +36476,7 @@ function toImageContent(image) {
|
|
|
35884
36476
|
// ../../bridges/pi-bridge/src/prompt-attachments.ts
|
|
35885
36477
|
import { constants } from "node:fs";
|
|
35886
36478
|
import { lstat as lstat2, open as open2, realpath as realpath2 } from "node:fs/promises";
|
|
35887
|
-
import { isAbsolute as isAbsolute3, join as
|
|
36479
|
+
import { isAbsolute as isAbsolute3, join as join8, relative as relative2, resolve as resolve4, sep as sep2 } from "node:path";
|
|
35888
36480
|
class PromptAttachmentError extends Error {
|
|
35889
36481
|
code;
|
|
35890
36482
|
name = "PromptAttachmentError";
|
|
@@ -35987,7 +36579,7 @@ function isPathWithin(root, candidate) {
|
|
|
35987
36579
|
async function assertNoSymlinkComponents(root, targetPath) {
|
|
35988
36580
|
let currentPath = root;
|
|
35989
36581
|
for (const segment of relative2(root, targetPath).split(sep2).filter(Boolean)) {
|
|
35990
|
-
currentPath =
|
|
36582
|
+
currentPath = join8(currentPath, segment);
|
|
35991
36583
|
const stats = await lstat2(currentPath).catch((error) => {
|
|
35992
36584
|
throw attachmentErrorForFsFailure(error);
|
|
35993
36585
|
});
|
|
@@ -36467,7 +37059,8 @@ function configureLoggerFromEnvironment(env, options = {}) {
|
|
|
36467
37059
|
configureLogger({
|
|
36468
37060
|
...levels.level ? { level: levels.level } : {},
|
|
36469
37061
|
areaLevels: levels.areaLevels,
|
|
36470
|
-
format
|
|
37062
|
+
format,
|
|
37063
|
+
relayEssential: options.relayToSupervisor === true
|
|
36471
37064
|
});
|
|
36472
37065
|
const log = createLogger("logging");
|
|
36473
37066
|
if (levels.invalid.length > 0) {
|
|
@@ -36571,7 +37164,7 @@ function humanPromptObservation(messages, tasks) {
|
|
|
36571
37164
|
}
|
|
36572
37165
|
|
|
36573
37166
|
// ../../bridges/pi-bridge/src/http.ts
|
|
36574
|
-
import { createHash as
|
|
37167
|
+
import { createHash as createHash7, randomBytes as randomBytes7 } from "node:crypto";
|
|
36575
37168
|
import { pathToFileURL } from "node:url";
|
|
36576
37169
|
import { gzip } from "node:zlib";
|
|
36577
37170
|
|
|
@@ -36628,7 +37221,7 @@ var DEFAULT_MCP_MANAGEMENT_ROLLOUT = Object.freeze({
|
|
|
36628
37221
|
|
|
36629
37222
|
// ../protocol/src/node/bridge-transcript-summary.ts
|
|
36630
37223
|
import { Buffer as Buffer5 } from "node:buffer";
|
|
36631
|
-
import { createHash as
|
|
37224
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
36632
37225
|
|
|
36633
37226
|
// ../protocol/src/node/progressive-transcript.ts
|
|
36634
37227
|
var BRIDGE_TRANSCRIPT_MAX_MESSAGES = 100;
|
|
@@ -36794,7 +37387,7 @@ function digestPayload(payload) {
|
|
|
36794
37387
|
const serialized = JSON.stringify(payload);
|
|
36795
37388
|
return {
|
|
36796
37389
|
bytes: Buffer5.byteLength(serialized),
|
|
36797
|
-
digest:
|
|
37390
|
+
digest: createHash6("sha256").update(serialized).digest("base64url").slice(0, 32)
|
|
36798
37391
|
};
|
|
36799
37392
|
}
|
|
36800
37393
|
function topLevelKey(part, index) {
|
|
@@ -37515,7 +38108,7 @@ async function answerSessionActivityBatch(body, read, options = {}) {
|
|
|
37515
38108
|
}
|
|
37516
38109
|
|
|
37517
38110
|
// ../../bridges/pi-bridge/src/http.ts
|
|
37518
|
-
var
|
|
38111
|
+
var log6 = createLogger("bridge.pi");
|
|
37519
38112
|
|
|
37520
38113
|
class HttpError extends Error {
|
|
37521
38114
|
status;
|
|
@@ -37587,6 +38180,12 @@ async function route(request, response, clientSignal) {
|
|
|
37587
38180
|
} catch (error) {
|
|
37588
38181
|
if (error instanceof HttpError)
|
|
37589
38182
|
return json(response, error.status, { error: error.message });
|
|
38183
|
+
if (error instanceof PolicyWideningRefusedError) {
|
|
38184
|
+
log6.warn("session.policy-widening-refused", { widened: error.widened.join(",") });
|
|
38185
|
+
return json(response, 403, error.refusal());
|
|
38186
|
+
}
|
|
38187
|
+
if (error instanceof SessionBusyError)
|
|
38188
|
+
return json(response, 409, { error: error.message });
|
|
37590
38189
|
if (error instanceof CredentialError) {
|
|
37591
38190
|
return json(response, 401, { error: error.message, kind: "authentication-required" });
|
|
37592
38191
|
}
|
|
@@ -37599,7 +38198,7 @@ async function route(request, response, clientSignal) {
|
|
|
37599
38198
|
if (error instanceof PromptAttachmentError) {
|
|
37600
38199
|
return json(response, 400, { error: error.message });
|
|
37601
38200
|
}
|
|
37602
|
-
|
|
38201
|
+
log6.error("http.route-failed");
|
|
37603
38202
|
return json(response, 500, { error: "Internal bridge error" });
|
|
37604
38203
|
}
|
|
37605
38204
|
}
|
|
@@ -37649,7 +38248,15 @@ async function routeGlobal(request, response, url) {
|
|
|
37649
38248
|
return true;
|
|
37650
38249
|
}
|
|
37651
38250
|
if (url.pathname === "/session/list" && request.method === "GET") {
|
|
37652
|
-
|
|
38251
|
+
let listed;
|
|
38252
|
+
try {
|
|
38253
|
+
listed = await listResumableSessions();
|
|
38254
|
+
} catch (error) {
|
|
38255
|
+
if (!(error instanceof TimeoutError))
|
|
38256
|
+
throw error;
|
|
38257
|
+
json(response, 504, { error: error.message });
|
|
38258
|
+
return true;
|
|
38259
|
+
}
|
|
37653
38260
|
json(response, 200, {
|
|
37654
38261
|
sessions: listed.map((entry) => ({
|
|
37655
38262
|
id: entry.sessionId,
|
|
@@ -37693,8 +38300,9 @@ async function routeGlobal(request, response, url) {
|
|
|
37693
38300
|
if (!sessionFile)
|
|
37694
38301
|
throw new HttpError(400, "sessionId is required");
|
|
37695
38302
|
const state = await resumeSession(sessionFile, parseComposerPatch(body), isNativeAgentExecutionPolicy(body.policy) ? body.policy : undefined).catch((error) => {
|
|
37696
|
-
if (error instanceof SessionClosingError)
|
|
38303
|
+
if (error instanceof SessionClosingError || error instanceof SessionBusyError || error instanceof PolicyWideningRefusedError) {
|
|
37697
38304
|
throw error;
|
|
38305
|
+
}
|
|
37698
38306
|
throw new HttpError(400, errorText(error));
|
|
37699
38307
|
});
|
|
37700
38308
|
storeAgentMcp(state, body.agentMcp);
|
|
@@ -37991,7 +38599,7 @@ async function handleSteer(request, response, state) {
|
|
|
37991
38599
|
throw new HttpError(400, "requestId is required");
|
|
37992
38600
|
if (!expectedRunId)
|
|
37993
38601
|
throw new HttpError(400, "expectedRunId is required");
|
|
37994
|
-
const inputDigest =
|
|
38602
|
+
const inputDigest = createHash7("sha256").update(text).digest("hex");
|
|
37995
38603
|
const previous = state.steerJournal.get(requestId);
|
|
37996
38604
|
if (previous) {
|
|
37997
38605
|
if (previous.inputDigest !== inputDigest || previous.expectedRunId !== expectedRunId) {
|
|
@@ -38125,6 +38733,9 @@ async function handlePrompt(request, response, state, clientSignal) {
|
|
|
38125
38733
|
}
|
|
38126
38734
|
async function handleAdmittedPrompt(request, response, state, clientSignal, admission) {
|
|
38127
38735
|
const body = await readJson(request);
|
|
38736
|
+
if (isNativeAgentExecutionPolicy(body.policy)) {
|
|
38737
|
+
assertExecutionPolicyNotWidened(liveExecutionPolicy(state), resolvePiExecutionPolicy(body.policy));
|
|
38738
|
+
}
|
|
38128
38739
|
const commandFields = readBridgePromptCommandFields(body);
|
|
38129
38740
|
if (!commandFields.ok)
|
|
38130
38741
|
throw new HttpError(400, commandFields.error);
|
|
@@ -38163,6 +38774,7 @@ async function handleAdmittedPrompt(request, response, state, clientSignal, admi
|
|
|
38163
38774
|
}
|
|
38164
38775
|
return json(response, 202, { accepted: true, duplicate: true });
|
|
38165
38776
|
}
|
|
38777
|
+
state.policyPending = false;
|
|
38166
38778
|
let selection;
|
|
38167
38779
|
if (command) {
|
|
38168
38780
|
const resolved = resolveCommandSelection(state, command);
|
|
@@ -38352,6 +38964,12 @@ async function handleAdmittedPrompt(request, response, state, clientSignal, admi
|
|
|
38352
38964
|
...requestId ? { requestId } : {}
|
|
38353
38965
|
});
|
|
38354
38966
|
}
|
|
38967
|
+
if (error instanceof PromptRefusedError && !cancelRequestedFor(state, claim)) {
|
|
38968
|
+
log6.warn("turn.refused", {
|
|
38969
|
+
sessionId: state.id,
|
|
38970
|
+
error: formatLogError(error, { message: false })
|
|
38971
|
+
});
|
|
38972
|
+
}
|
|
38355
38973
|
state.messages.splice(messageStart);
|
|
38356
38974
|
state.uncheckedTranscriptBytes = uncheckedBeforePrompt;
|
|
38357
38975
|
state.status = "error";
|
|
@@ -38607,7 +39225,7 @@ function startParentWatchdog(options) {
|
|
|
38607
39225
|
}
|
|
38608
39226
|
|
|
38609
39227
|
// ../protocol/src/bridge-lifecycle.ts
|
|
38610
|
-
var
|
|
39228
|
+
var log7 = createLogger("bridge.lifecycle");
|
|
38611
39229
|
var TERMINATION_SIGNALS = ["SIGTERM", "SIGINT"];
|
|
38612
39230
|
function errorKind(error) {
|
|
38613
39231
|
if (error instanceof Error)
|
|
@@ -38661,7 +39279,7 @@ class BridgeLifecycle {
|
|
|
38661
39279
|
}
|
|
38662
39280
|
requestExit() {
|
|
38663
39281
|
this.#exit ??= this.shutdown().then(() => this.#options.exit(0), (error) => {
|
|
38664
|
-
|
|
39282
|
+
log7.error("shutdown.failed", {
|
|
38665
39283
|
bridge: this.#options.label,
|
|
38666
39284
|
errorClass: errorKind(error)
|
|
38667
39285
|
});
|
|
@@ -38678,7 +39296,7 @@ class BridgeLifecycle {
|
|
|
38678
39296
|
try {
|
|
38679
39297
|
idleSweep.run();
|
|
38680
39298
|
} catch (error) {
|
|
38681
|
-
|
|
39299
|
+
log7.warn("idle-sweep.failed", {
|
|
38682
39300
|
bridge: this.#options.label,
|
|
38683
39301
|
errorClass: errorKind(error)
|
|
38684
39302
|
});
|
|
@@ -38937,6 +39555,9 @@ function installFatalRejectionGuard(options) {
|
|
|
38937
39555
|
try {
|
|
38938
39556
|
warn(`${options.label} Unhandled promise rejection (continuing): ${describe(reason)}`);
|
|
38939
39557
|
} catch {}
|
|
39558
|
+
try {
|
|
39559
|
+
options.onRejection?.(reason);
|
|
39560
|
+
} catch {}
|
|
38940
39561
|
};
|
|
38941
39562
|
target.on("unhandledRejection", handler);
|
|
38942
39563
|
return () => {
|
|
@@ -38944,9 +39565,18 @@ function installFatalRejectionGuard(options) {
|
|
|
38944
39565
|
};
|
|
38945
39566
|
}
|
|
38946
39567
|
|
|
39568
|
+
// ../protocol/src/node/process-failure-log.ts
|
|
39569
|
+
var log8 = createLogger("process");
|
|
39570
|
+
function logUnhandledRejection(reason) {
|
|
39571
|
+
log8.throttled("error", "rejection.unhandled", {
|
|
39572
|
+
error: reason,
|
|
39573
|
+
fields: () => ({ error: formatLogError(reason, { message: false }) })
|
|
39574
|
+
});
|
|
39575
|
+
}
|
|
39576
|
+
|
|
38947
39577
|
// ../../bridges/pi-bridge/src/index.ts
|
|
38948
39578
|
configureBridgeLogger();
|
|
38949
|
-
installFatalRejectionGuard({ label: "[pi-bridge]" });
|
|
39579
|
+
installFatalRejectionGuard({ label: "[pi-bridge]", onRejection: logUnhandledRejection });
|
|
38950
39580
|
if (process.env.PI_BRIDGE_LIBRARY_ONLY !== "1") {
|
|
38951
39581
|
await start();
|
|
38952
39582
|
}
|
|
@@ -38988,9 +39618,11 @@ export {
|
|
|
38988
39618
|
PromptAttachmentError,
|
|
38989
39619
|
PromptRefusedError,
|
|
38990
39620
|
PromptStartupTimeoutError,
|
|
39621
|
+
SESSION_LIST_TIMEOUT_MESSAGE,
|
|
38991
39622
|
STARTUP_TIMEOUT_MS,
|
|
38992
39623
|
STREAM_BOUND_INTERVAL_BYTES,
|
|
38993
39624
|
STRUCTURED_PROMPT_INSTRUCTION_PREFIX,
|
|
39625
|
+
SessionBusyError,
|
|
38994
39626
|
SessionClosingError,
|
|
38995
39627
|
TODO_STATUSES,
|
|
38996
39628
|
TimeoutError,
|
|
@@ -39039,6 +39671,7 @@ export {
|
|
|
39039
39671
|
dispatchPrompt,
|
|
39040
39672
|
drainPersistence,
|
|
39041
39673
|
emptyComposer,
|
|
39674
|
+
encodeStateWithinBudget,
|
|
39042
39675
|
ensureSession,
|
|
39043
39676
|
errorText,
|
|
39044
39677
|
expireComposerHydrationRetryForTests,
|
|
@@ -39057,6 +39690,7 @@ export {
|
|
|
39057
39690
|
json,
|
|
39058
39691
|
listModels,
|
|
39059
39692
|
listResumableSessions,
|
|
39693
|
+
liveExecutionPolicy,
|
|
39060
39694
|
loadPersistedState,
|
|
39061
39695
|
markSessionClosed,
|
|
39062
39696
|
markSessionDefault,
|
|
@@ -39142,6 +39776,7 @@ export {
|
|
|
39142
39776
|
setPendingRemoval,
|
|
39143
39777
|
setPersistWriteGateForTests,
|
|
39144
39778
|
setPromptJournal,
|
|
39779
|
+
setSessionListTimeoutForTests,
|
|
39145
39780
|
setSessionReadOnly,
|
|
39146
39781
|
setSessionTitle,
|
|
39147
39782
|
setStartupTimeoutForTests,
|