orkestrator 2.36.1 → 2.36.3-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24570,6 +24570,7 @@ var PROJECTION_FIELD_SET = new Set([
24570
24570
  "asyncQuestionResponses",
24571
24571
  "contextUsage",
24572
24572
  "goal",
24573
+ "suborks",
24573
24574
  "rateLimits",
24574
24575
  "runtime",
24575
24576
  "runtimeHealthAuthoritative",
@@ -24595,6 +24596,7 @@ var OPTIONAL_PROJECTION_FIELD_SET = new Set([
24595
24596
  "asyncQuestionResponses",
24596
24597
  "contextUsage",
24597
24598
  "goal",
24599
+ "suborks",
24598
24600
  "rateLimits",
24599
24601
  "runtime",
24600
24602
  "runtimeHealthAuthoritative",
@@ -25634,6 +25636,8 @@ function transcriptBoundSummary(state) {
25634
25636
  var AGENT_MAIL_MAX_BODY_BYTES = 32 * 1024;
25635
25637
  var AGENT_MAIL_MAX_STORE_BYTES = 32 * 1024 * 1024;
25636
25638
  var AGENT_MAIL_DEFAULT_RETENTION_DAYS = 14;
25639
+ var AGENT_MAIL_MAX_ATTACHMENT_BYTES = 8 * 1024 * 1024;
25640
+ var AGENT_MAIL_MAX_TOTAL_ATTACHMENT_BYTES = 32 * 1024 * 1024;
25637
25641
  var AGENT_MAIL_DEFAULT_AUTONOMOUS_WAKE_BUDGET = 16;
25638
25642
  var AGENT_MAIL_DEFAULT_HOURLY_WAKE_LIMIT = 40;
25639
25643
  var AGENT_MAIL_TOOL_NAMES = Object.freeze([
@@ -25707,6 +25711,7 @@ var WORKFLOW_RESULT_KINDS = [
25707
25711
  "fix-result",
25708
25712
  "verification-result",
25709
25713
  "pr-result",
25714
+ "subork-answer",
25710
25715
  "graph-output",
25711
25716
  "graph-template"
25712
25717
  ];
@@ -25722,7 +25727,8 @@ var WORKFLOW_RESULT_TOOL_NAMES = {
25722
25727
  "verification-result": "submit_verification_result",
25723
25728
  "pr-result": "submit_pr_result",
25724
25729
  "graph-output": "submit_graph_output",
25725
- "graph-template": "submit_graph_template"
25730
+ "graph-template": "submit_graph_template",
25731
+ "subork-answer": "submit_subork_answer"
25726
25732
  };
25727
25733
  var WORKFLOW_RESULT_VALIDATION_TOOL_NAME = "validate_workflow_result";
25728
25734
  var REPORT_FINDING_TOOL_NAME = "report_finding";
@@ -27707,6 +27713,97 @@ function chargeAppended(state, before, after) {
27707
27713
  function readText(value) {
27708
27714
  return typeof value === "string" ? value : "";
27709
27715
  }
27716
+ // ../protocol/src/execution-policy-narrowing.ts
27717
+ var APPROVALS_STRICTNESS = {
27718
+ "auto-approve": 0,
27719
+ ask: 1,
27720
+ deny: 2
27721
+ };
27722
+ var SANDBOX_STRICTNESS = {
27723
+ none: 0,
27724
+ container: 1,
27725
+ provider: 2
27726
+ };
27727
+ function networkStrictness(value) {
27728
+ return value === "restricted" ? 1 : 0;
27729
+ }
27730
+ function isSubset(candidate, of) {
27731
+ const allowed = new Set(of);
27732
+ return candidate.every((item) => allowed.has(item));
27733
+ }
27734
+ function rawCapabilityDenials(policy) {
27735
+ return [
27736
+ ...policy.capabilityPolicy?.deny ?? [],
27737
+ ...policy.capabilityPolicy?.extendedDeny ?? []
27738
+ ];
27739
+ }
27740
+ function executionPolicyWidenings(current, next) {
27741
+ if (!current)
27742
+ return [];
27743
+ const widened = [];
27744
+ if (next.id !== current.id)
27745
+ widened.push("id");
27746
+ if (APPROVALS_STRICTNESS[next.approvals] < APPROVALS_STRICTNESS[current.approvals]) {
27747
+ widened.push("approvals");
27748
+ }
27749
+ if (SANDBOX_STRICTNESS[next.sandbox] < SANDBOX_STRICTNESS[current.sandbox]) {
27750
+ widened.push("sandbox");
27751
+ }
27752
+ if (next.projectResources && !current.projectResources)
27753
+ widened.push("projectResources");
27754
+ if (networkStrictness(next.networkAccess) < networkStrictness(current.networkAccess)) {
27755
+ widened.push("networkAccess");
27756
+ }
27757
+ if (networkStrictness(next.containerNetworkAccess) < networkStrictness(current.containerNetworkAccess)) {
27758
+ widened.push("containerNetworkAccess");
27759
+ }
27760
+ const currentAllow = current.toolPolicy?.allow;
27761
+ const nextAllow = next.toolPolicy?.allow;
27762
+ const allowNarrows = currentAllow === undefined ? nextAllow === undefined || nextAllow.length === 0 : nextAllow !== undefined && isSubset(nextAllow, currentAllow);
27763
+ if (!allowNarrows)
27764
+ widened.push("toolPolicy.allow");
27765
+ if (!isSubset(current.toolPolicy?.deny ?? [], next.toolPolicy?.deny ?? [])) {
27766
+ widened.push("toolPolicy.deny");
27767
+ }
27768
+ if (!isSubset(rawCapabilityDenials(current), rawCapabilityDenials(next))) {
27769
+ widened.push("capabilityPolicy.deny");
27770
+ }
27771
+ if (!isSubset(next.capabilityPolicy?.allow ?? [], current.capabilityPolicy?.allow ?? [])) {
27772
+ widened.push("capabilityPolicy.allow");
27773
+ }
27774
+ const currentServers = nativeAgentUserMcpGrant(current);
27775
+ const nextServers = nativeAgentUserMcpGrant(next);
27776
+ if (currentServers !== undefined && (nextServers === undefined || !isSubset(nextServers, currentServers))) {
27777
+ widened.push("capabilityPolicy.userMcpServers");
27778
+ }
27779
+ return widened;
27780
+ }
27781
+ var POLICY_WIDENING_REFUSED_CODE = "policy-widening-refused";
27782
+ function policyWideningRefusal(widened) {
27783
+ return {
27784
+ error: "Execution policy can only be narrowed on a live session; a wider policy applies after the agent bridge restarts.",
27785
+ code: POLICY_WIDENING_REFUSED_CODE,
27786
+ widened
27787
+ };
27788
+ }
27789
+
27790
+ class PolicyWideningRefusedError extends Error {
27791
+ widened;
27792
+ constructor(widened) {
27793
+ super(policyWideningRefusal(widened).error);
27794
+ this.widened = widened;
27795
+ this.name = "PolicyWideningRefusedError";
27796
+ }
27797
+ refusal() {
27798
+ return policyWideningRefusal(this.widened);
27799
+ }
27800
+ }
27801
+ function assertExecutionPolicyNotWidened(current, next) {
27802
+ const widened = executionPolicyWidenings(current, next);
27803
+ if (widened.length > 0)
27804
+ throw new PolicyWideningRefusedError(widened);
27805
+ }
27806
+
27710
27807
  // ../../bridges/cursor-bridge/src/execution-policy.ts
27711
27808
  function resolveCursorExecutionPolicy(policy) {
27712
27809
  const resolved = policy ?? {
@@ -27747,6 +27844,9 @@ function resolveCursorExecutionPolicy(policy) {
27747
27844
  ...notes.length > 0 ? { note: notes.join(" ") } : {}
27748
27845
  };
27749
27846
  }
27847
+ function liveExecutionPolicy(state) {
27848
+ return state.policyPending ? undefined : state.policy;
27849
+ }
27750
27850
  function cursorAppliedPolicy(state) {
27751
27851
  const sessionPolicy = state.policy;
27752
27852
  return resolveCursorExecutionPolicy(state.readOnly ? {
@@ -28470,6 +28570,16 @@ function logErrorKind(error) {
28470
28570
  }
28471
28571
 
28472
28572
  // ../protocol/src/log-vocabulary/define.ts
28573
+ var ESSENTIAL_ERROR_FIELDS = {
28574
+ "error.name": "label",
28575
+ "error.code": "label",
28576
+ "error.errno": "number",
28577
+ "error.syscall": "label",
28578
+ "error.exitCode": "number",
28579
+ "error.signal": "label",
28580
+ "error.outputOmitted": "boolean",
28581
+ "error.errorCount": "number"
28582
+ };
28473
28583
  var THROTTLE_LOG_EVENTS = {
28474
28584
  "throttle.suppressed": "Repeats of the throttled `site` were counted over a window, not written.",
28475
28585
  "throttle.recovered": "The throttled `site` succeeded again, so its fault has cleared.",
@@ -28519,7 +28629,11 @@ var BACKEND_LOG_AREAS = defineLogAreas({
28519
28629
  backend: {
28520
28630
  description: "The backend process: startup, background notices and shutdown.",
28521
28631
  events: {
28522
- starting: "The backend process is starting.",
28632
+ starting: {
28633
+ description: "The backend process is starting.",
28634
+ essential: true,
28635
+ fields: { version: "label" }
28636
+ },
28523
28637
  "ssh-socket.resolved": "An SSH agent socket was found.",
28524
28638
  "ssh-socket.missing": "No usable SSH agent socket was found.",
28525
28639
  "standalone-updater.mismatch": "--standalone-updater does not match --data-dir, so self-update is off.",
@@ -28534,8 +28648,16 @@ var BACKEND_LOG_AREAS = defineLogAreas({
28534
28648
  "notice.failed": "A background notice after a turn or prompt failed; `step` says which.",
28535
28649
  "artifacts.live-unavailable": "Live interactive artifacts are unavailable.",
28536
28650
  "shutdown.step-failed": "One part of shutdown failed and the rest went on; `step` says which.",
28537
- "shutdown.signal-received": "A signal started shutdown, which tells a clean quit from the backend being killed.",
28538
- "shutdown.finished": "Shutdown finished, and the process exits with `code`.",
28651
+ "shutdown.signal-received": {
28652
+ description: "A signal started shutdown, which tells a clean quit from the backend being killed.",
28653
+ essential: true,
28654
+ fields: { signal: "label" }
28655
+ },
28656
+ "shutdown.finished": {
28657
+ description: "Shutdown finished, and the process exits with `code`.",
28658
+ essential: true,
28659
+ fields: { code: "number" }
28660
+ },
28539
28661
  "port-policy.second-backend": "Another backend serves the default data directory, so this one avoids its ports.",
28540
28662
  "port-policy.serve-on-free-port": "--tailscale-serve is on a free gateway port; pass --port with --strict-gateway-port to keep one."
28541
28663
  }
@@ -28578,7 +28700,10 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
28578
28700
  "evidence.record-failed": "Change evidence could not be recorded; the read loop carries on.",
28579
28701
  "evidence.shell-record-failed": "A shell observation could not be recorded.",
28580
28702
  "evidence.turn-record-failed": "Turn change evidence could not be recorded.",
28703
+ "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.",
28704
+ "http.route-failed": "An HTTP route answered 500; its error message is not logged because it can hold content.",
28581
28705
  "server.listening": "The HTTP server is listening.",
28706
+ "session.policy-widening-refused": "A request tried to widen a live session's execution policy and was refused; widened names the axes.",
28582
28707
  "state.composer-reset": "A saved composer state was malformed and was reset.",
28583
28708
  "state.discarded": "Saved bridge state could not be used and was discarded.",
28584
28709
  "state.persist-failed": "Saving bridge state failed; a later write retries.",
@@ -28632,7 +28757,7 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
28632
28757
  "session.created": "A session was created or recovered.",
28633
28758
  "session.delete-failed": "Deleting a session failed.",
28634
28759
  "session.fork-failed": "Forking a session failed.",
28635
- "session.policy-widening-refused": "A config request tried to widen a live session's execution policy and was refused; widened names the axes.",
28760
+ "session.policy-widening-refused": "A request tried to widen a live session's execution policy and was refused; widened names the axes.",
28636
28761
  "session.rename-failed": "Renaming a session failed.",
28637
28762
  "session.resolve-failed": "A session could not be found or loaded for a request; action names the request.",
28638
28763
  "session.rewind-failed": "Rewinding session files failed.",
@@ -28666,6 +28791,7 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
28666
28791
  "app-server.exited": "app-server exited unexpectedly; the code and signal say how.",
28667
28792
  "app-server.invariant-violation": "app-server asked for something its configuration forbids.",
28668
28793
  "app-server.protocol-violation": "app-server wrote a line that is not valid protocol; it was ignored.",
28794
+ "app-server.overflow-restart-failed": "Replacing the child after a notification queue overflow failed; the next request tries again.",
28669
28795
  "app-server.recording": "Notification recording is on; recordings hold content.",
28670
28796
  "app-server.stale-reaped": "A stale app-server left by an earlier bridge was stopped.",
28671
28797
  "app-server.stderr": "Metadata of an app-server stderr line, never its content.",
@@ -28696,6 +28822,7 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
28696
28822
  "ordered-events.publish-failed": "Publishing an ordered event failed; clients are told to rehydrate.",
28697
28823
  "ordered-events.reconcile-failed": "Reconciling ordered events failed.",
28698
28824
  "parent.gone": "The backend that launched this bridge has gone; stopping turns and shutting down.",
28825
+ "queue.overflow": "The notification queue passed a bound and dropped its backlog.",
28699
28826
  "queue.task-failed": "A task on a per-thread queue failed.",
28700
28827
  "raw-log.write-failed": "Appending to the raw Codex log failed.",
28701
28828
  "recorder.notice": "The notification recorder needs attention: it is on, or was asked for without its confirmation.",
@@ -28709,6 +28836,7 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
28709
28836
  "server-request.flush-timeout": "An answer to a server request did not flush in time.",
28710
28837
  "server-request.handoff-failed": "Handing a server request to the router threw.",
28711
28838
  "session.config-apply-failed": "Applying session configuration failed; the route answers unavailable.",
28839
+ "session.policy-widening-refused": "A request tried to widen a live session's execution policy and was refused; widened names the axes.",
28712
28840
  "sse.closed": "An event stream was closed by the bridge; the client reconnects and replays.",
28713
28841
  "sse.keepalive-failed": "An event stream keepalive failed.",
28714
28842
  "sse.observer-failed": "An event stream observer failed; it reconnects.",
@@ -28737,19 +28865,39 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
28737
28865
  events: {
28738
28866
  "agent.archive-failed": "Archiving or unarchiving an agent failed.",
28739
28867
  "http.route-failed": "An HTTP route failed unexpectedly; its error is not logged because it can hold content.",
28868
+ "session.policy-widening-refused": "A request tried to widen a live session's execution policy and was refused; widened names the axes.",
28740
28869
  "startup.closes-failed": "Finishing closes a previous process left behind failed at startup.",
28741
28870
  "startup.closes-incomplete": "Some closes a previous process left behind did not finish at startup; a retried close finishes them.",
28742
28871
  "state.publication-failing": "Saving bridge state is failing; new prompts and steers are refused until it recovers.",
28743
28872
  "state.publication-recovered": "Saving bridge state recovered.",
28744
- "state.transcripts-shortened": "The state file reached its limit, so some sessions were saved with a shortened transcript copy."
28873
+ "state.transcripts-shortened": "The state file reached its limit, so some sessions were saved with a shortened transcript copy.",
28874
+ "session.resume-fell-back": {
28875
+ description: "A saved conversation could not be resumed, so a new one started; its error message is not logged because it can hold content.",
28876
+ essential: true,
28877
+ fields: ESSENTIAL_ERROR_FIELDS
28878
+ },
28879
+ "turn.failed": "A turn failed; its error message is not logged because it can hold content. A cancelled turn is not a failure.",
28880
+ "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.",
28881
+ "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.",
28882
+ "turn.timed-out": "A turn outlived its time budget, so its run was asked to cancel; `turn.failed` follows if it never stops."
28745
28883
  }
28746
28884
  },
28747
28885
  "bridge.pi": {
28748
28886
  description: "The Pi bridge: its routes, sessions and saved state.",
28749
28887
  events: {
28750
28888
  "http.route-failed": "An HTTP route failed unexpectedly; its error is not logged because it can hold content.",
28889
+ "session.policy-widening-refused": "A request tried to widen a live session's execution policy and was refused; widened names the axes.",
28890
+ "session-list.failed": "Reading the resumable sessions failed, so none were offered; its error message is not logged because it can hold content.",
28751
28891
  "state.over-budget": "The state file stayed over budget after shedding transcripts, so the write was skipped.",
28752
- "state.transcripts-shed": "The state file was over budget, so some sessions were saved without their transcript."
28892
+ "state.transcripts-shed": "The state file was over budget, so some sessions were saved without their transcript.",
28893
+ "session.resume-fell-back": {
28894
+ description: "A saved conversation could not be reopened, so a new one started; its error message is not logged because it can hold content.",
28895
+ essential: true,
28896
+ fields: ESSENTIAL_ERROR_FIELDS
28897
+ },
28898
+ "turn.failed": "A turn failed; its error message is not logged because it can hold content. A cancelled turn is not a failure.",
28899
+ "turn.refused": "Pi refused a prompt before starting a run, so nothing ran; its error message is not logged because it can hold content.",
28900
+ "turn.startup-timed-out": "Pi did not start a turn within its startup deadline, so the prompt was abandoned."
28753
28901
  }
28754
28902
  }
28755
28903
  });
@@ -28760,14 +28908,31 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
28760
28908
  description: "The Electron main process: startup, windows, quit and the Local backend's life.",
28761
28909
  events: {
28762
28910
  "backend.docker-context-seed-failed": "An agent-test profile fell back to the default Docker context.",
28763
- "backend.exited": "The Local backend exited unexpectedly; Local work is unavailable.",
28764
- "backend.exited-recovering": "The Local backend exited just after a remote update; relaunching unattended.",
28911
+ "backend.exited": {
28912
+ description: "The Local backend exited unexpectedly; Local work is unavailable. `error.exitCode` and `error.signal` say how.",
28913
+ essential: true,
28914
+ fields: ESSENTIAL_ERROR_FIELDS
28915
+ },
28916
+ "backend.exited-recovering": {
28917
+ description: "The Local backend exited just after a remote update; relaunching unattended. `error.exitCode` and `error.signal` say how.",
28918
+ essential: true,
28919
+ fields: ESSENTIAL_ERROR_FIELDS
28920
+ },
28765
28921
  "backend.keychain-link-remove-failed": "An agent-test profile kept a legacy link to the host keychain.",
28766
- "backend.start-failed": "The Local backend did not start; continuing with remote machines.",
28922
+ "backend.start-failed": {
28923
+ description: "The Local backend did not start; continuing with remote machines.",
28924
+ essential: true,
28925
+ fields: ESSENTIAL_ERROR_FIELDS
28926
+ },
28767
28927
  "clipboard.write-failed": "Writing text to the system clipboard failed.",
28768
28928
  "dev-mode.ignored-packaged": "A packaged app was launched with ELECTRON_DEV=1 and ignored it; it loads its bundled renderer.",
28769
28929
  "instance.already-running": "Another instance holds this data directory; this one will quit.",
28770
- "main-thread.stalled": "A timer fired late, so windows, IPC and the stdout reader waited.",
28930
+ "main-thread.stalled": {
28931
+ description: "A timer fired late, so windows, IPC and the stdout reader waited.",
28932
+ essential: true,
28933
+ minLevel: "error",
28934
+ fields: { lagMs: "number", intervalMs: "number" }
28935
+ },
28771
28936
  "quit.stopping-backend": "The app is quitting and has asked the Local backend to stop.",
28772
28937
  "relaunch.schedule-failed": "The AppImage relaunch waiter failed; using Electron's relauncher.",
28773
28938
  "relaunch.service-register-failed": "The AppImage relaunch service was refused; using a detached waiter.",
@@ -28778,7 +28943,11 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
28778
28943
  "saved-machines.attach-failed": "Saved machines were not imported into the command node yet.",
28779
28944
  "saved-machines.attached": "Saved machines were imported into the local command node.",
28780
28945
  "startup.failed": "The application failed to start.",
28781
- "uncaught-exception": "The main process hit an uncaught exception.",
28946
+ "uncaught-exception": {
28947
+ description: "The main process hit an uncaught exception.",
28948
+ essential: true,
28949
+ fields: ESSENTIAL_ERROR_FIELDS
28950
+ },
28782
28951
  "uncaught-exception.dialog-failed": "The uncaught exception sheet could not be shown.",
28783
28952
  "window.create-failed": "A menu-driven new window could not be created.",
28784
28953
  "window.recreate-failed": "The main window could not be recreated on activation.",
@@ -28801,6 +28970,12 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
28801
28970
  "unhandled-rejection": "An unhandled rejection occurred while the renderer was starting."
28802
28971
  }
28803
28972
  },
28973
+ "desktop.permissions": {
28974
+ description: "Permission requests refused on the renderer and workspace realm sessions.",
28975
+ events: {
28976
+ denied: "A renderer asked for a permission the policy does not grant."
28977
+ }
28978
+ },
28804
28979
  "desktop.dialog": {
28805
28980
  description: "Native dialogs, whose modal loops hold the main thread while they are open.",
28806
28981
  events: {
@@ -28883,6 +29058,7 @@ var ENVIRONMENT_LOG_AREAS = defineLogAreas({
28883
29058
  "status.docker-error": "A transient Docker error stopped a status read, so the stored status is kept.",
28884
29059
  "setup.clear-launch-failed": "A pending agent launch could not be cleared after setup failed.",
28885
29060
  "setup.record-failure-failed": "A setup failure before its first attempt could not be recorded.",
29061
+ "setup.tab-publish-failed": "The setup terminal's tab could not be published.",
28886
29062
  "lifecycle.failed": "Starting, rebuilding or recreating an environment failed; `operation` says which.",
28887
29063
  "tab-teardown.pending": "A tab's teardown failed and stays pending; the reconcile sweep retries.",
28888
29064
  "tab-reconcile.skipped": "Orphaned tab reconciliation was skipped because pane layouts are unreadable.",
@@ -28919,6 +29095,8 @@ var GATEWAY_LOG_AREAS = defineLogAreas({
28919
29095
  "loopback.unavailable": "The loopback client listener could not start.",
28920
29096
  "auth-token.stored": "The gateway token's file was written. The path only, never the token.",
28921
29097
  "auth-token.persist-failed": "The gateway token could not be saved.",
29098
+ "auth-guess.throttled": "A listener saw enough different wrong tokens that it now pauses new ones. Never the values.",
29099
+ "host.refused": "A request named a host this gateway does not answer to. Logged once per name, up to a limit.",
28922
29100
  "port.fallback": "The preferred port was taken, so a nearby one is used.",
28923
29101
  "port.fallback-distant": "The preferred port and those nearby were taken, so another is used.",
28924
29102
  "request.failed": "A gateway request failed. Throttled: repeats are counted, not written.",
@@ -28962,6 +29140,22 @@ var LOCAL_SERVER_LOG_AREAS = defineLogAreas({
28962
29140
  "bridge-runtime.installed": "A bridge runtime finished installing.",
28963
29141
  "opencode.database-lost-retrying": "OpenCode lost its shared database at startup, so it is retried.",
28964
29142
  "server.stopping": "A local server is being stopped, for the fixed `reason` given.",
29143
+ "bridge.started": {
29144
+ description: "A local bridge process was spawned; `key` names its kind and environment.",
29145
+ essential: true,
29146
+ fields: { key: "label", pid: "number" }
29147
+ },
29148
+ "bridge.exited": {
29149
+ 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.",
29150
+ essential: true,
29151
+ fields: {
29152
+ key: "label",
29153
+ pid: "number",
29154
+ code: "number",
29155
+ signal: "label",
29156
+ requested: "boolean"
29157
+ }
29158
+ },
28965
29159
  "reaper.tmux-list-failed": "Orphaned claude-tmux sessions could not be listed.",
28966
29160
  "reaper.tmux-kill-failed": "An orphaned tmux session could not be killed.",
28967
29161
  "reaper.tmux-reaped": "Orphaned claude-tmux sessions of a deleted environment were killed.",
@@ -28995,13 +29189,29 @@ var LOGGING_LOG_AREAS = defineLogAreas({
28995
29189
  "capture.started": "Saving logs to disk began for this process.",
28996
29190
  "capture.stopped": "Saving logs to disk stopped for this process.",
28997
29191
  "config.invalid": "A logging environment variable held a value that was ignored.",
28998
- "entries.dropped": "The log queue was full, so entries were dropped and counted.",
29192
+ "entries.dropped": {
29193
+ 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.",
29194
+ essential: true,
29195
+ fields: { entries: "number", bytes: "number", reason: "label" }
29196
+ },
29197
+ "essential.started": {
29198
+ description: "This process began writing the essential log. One with no `essential.stopped` before it means the last writer died.",
29199
+ essential: true,
29200
+ fields: { owner: "label" }
29201
+ },
29202
+ "essential.stopped": {
29203
+ description: "This process stopped writing the essential log, in an orderly exit.",
29204
+ essential: true,
29205
+ fields: { owner: "label" }
29206
+ },
29207
+ "essential.write-failed": "Writing the essential log failed. Its entries are counted, and a marker reports them at the next write that works.",
28999
29208
  "policy.changed": "The logging settings changed: saving, retention and levels, with no content.",
29000
29209
  "policy.bridge-predates-route": "A running bridge has no logging settings route; it applies them at its next start.",
29001
29210
  "policy.push-failed": "A running bridge did not take the logging settings after retries; its next start resends them.",
29002
29211
  "prune.failed": "Removing expired log files failed; the next sweep retries.",
29003
29212
  "write.failed": "Appending to the log file failed.",
29004
- "unknown-area": "Code outside the type checker asked for an area that is not listed."
29213
+ "unknown-area": "Code outside the type checker asked for an area that is not listed.",
29214
+ ...THROTTLE_LOG_EVENTS
29005
29215
  }
29006
29216
  }
29007
29217
  });
@@ -29056,6 +29266,7 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
29056
29266
  "turn-recovery.failed": "Recovering an incomplete turn failed.",
29057
29267
  "turn-recovery.exhausted": "A turn failed again after automatic recovery and is left for the user.",
29058
29268
  "turn-recovery.retrying": "An incomplete or provider-failed turn is being retried automatically.",
29269
+ "usage-limit.notice-failed": "A usage-limit stop's outcome could not be read for its notice.",
29059
29270
  "usage-limit.resend-failed": "Resending after a usage limit failed. An unknown send stays in the journal.",
29060
29271
  "title.strategy-failed": "A session title strategy failed, so the next is tried. Content-free: the error can quote the prompt.",
29061
29272
  ...THROTTLE_LOG_EVENTS
@@ -29072,6 +29283,15 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
29072
29283
  "recover.failed": "Goals could not be recovered at startup."
29073
29284
  }
29074
29285
  },
29286
+ "native-agent.subork": {
29287
+ description: "Suborks: the ask_agents calls a native agent makes. Content-free.",
29288
+ events: {
29289
+ "pass.failed": "A pass over a call failed, so a later pass retries. Counts only.",
29290
+ "delivery.failed": "A call's answers could not be placed in the caller's mailbox yet. Error class only.",
29291
+ "retention.failed": "An old call could not be removed.",
29292
+ "sweep.failed": "A running call's caller could not be checked; the next sweep looks again."
29293
+ }
29294
+ },
29075
29295
  "native-agent.opencode": {
29076
29296
  description: "The OpenCode provider: its request monitor, retries and agent tools.",
29077
29297
  events: {
@@ -29126,7 +29346,28 @@ var RUNTIME_LOG_AREAS = defineLogAreas({
29126
29346
  "event-loop": {
29127
29347
  description: "This process's event loop. A stall of 10 seconds or more is written at error, so no level hides it.",
29128
29348
  events: {
29129
- stalled: "A timer fired late, so every request in that window waited."
29349
+ stalled: {
29350
+ description: "A timer fired late, so every request in that window waited.",
29351
+ essential: true,
29352
+ minLevel: "error",
29353
+ fields: { lagMs: "number", intervalMs: "number" }
29354
+ }
29355
+ }
29356
+ },
29357
+ process: {
29358
+ description: "Failures of a whole process that nothing in it handled.",
29359
+ events: {
29360
+ "rejection.unhandled": {
29361
+ description: "A promise rejection reached the fatal rejection guard, which keeps the process running.",
29362
+ essential: true,
29363
+ fields: { kind: "label", ...ESSENTIAL_ERROR_FIELDS }
29364
+ },
29365
+ "uncaught-exception": {
29366
+ 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.",
29367
+ essential: true,
29368
+ fields: { origin: "label", ...ESSENTIAL_ERROR_FIELDS }
29369
+ },
29370
+ ...THROTTLE_LOG_EVENTS
29130
29371
  }
29131
29372
  }
29132
29373
  });
@@ -29364,21 +29605,43 @@ var STORAGE_LOG_AREAS = defineLogAreas({
29364
29605
  description: "The SQLite-backed stores, their snapshots and imports from older formats.",
29365
29606
  events: {
29366
29607
  "usage.environment-label-failed": "Usage labels could not be retained for a removed environment; deletion continues.",
29367
- "snapshot.integrity-failed": "An hourly database snapshot failed its integrity check and was discarded.",
29608
+ "migration.failed": {
29609
+ 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.",
29610
+ essential: true,
29611
+ fields: {
29612
+ fromVersion: "number",
29613
+ toVersion: "number",
29614
+ step: "label",
29615
+ ...ESSENTIAL_ERROR_FIELDS
29616
+ }
29617
+ },
29618
+ "snapshot.integrity-failed": {
29619
+ description: "A database snapshot failed its integrity check and was discarded.",
29620
+ essential: true,
29621
+ fields: {}
29622
+ },
29368
29623
  "snapshot.skipped-low-disk": "The hourly database snapshot was skipped because the disk lacks room; `retryAt` says when it tries again.",
29369
- "snapshot.failed": "The hourly database snapshot failed; `retryAt` says when it tries again, if known.",
29624
+ "snapshot.failed": {
29625
+ description: "The hourly database snapshot failed; `retryAt` says when it tries again, if known.",
29626
+ essential: true,
29627
+ fields: { retryAt: "label", ...ESSENTIAL_ERROR_FIELDS }
29628
+ },
29370
29629
  "listener.attention-failed": "An environment attention listener threw; the committed mutation stands.",
29371
29630
  "listener.change-failed": "A resource change listener threw; the committed mutation stands.",
29372
29631
  "kanban.image-cleanup-failed": "An orphaned Kanban image could not be removed after its retries; it is safe to remove later.",
29373
29632
  "nodes.entries-dropped": "Unreadable node registry entries were ignored.",
29374
29633
  "preview-identity.reminted": "The data directory moved or was copied, so previews get a new backend identity.",
29634
+ "preview-settings.invalid": "Invalid preview settings disabled transport and relay.",
29375
29635
  "machine-profile.invalid": "The stored machine profile was invalid and the default was restored.",
29376
29636
  "permission-rules.cleanup-failed": "A deleted project's permission rules could not be removed.",
29377
29637
  "retired.turn-cleanup-pending": "Cleanup of a retired Looped Review turn did not finish and stays pending.",
29378
29638
  "handoffs.prune-failed": "Pruning agent handoffs that nothing references failed; a later prune retries.",
29379
29639
  "desktop-connections.malformed": "Stored desktop connection settings were malformed, so the local connection is used.",
29380
29640
  "legacy-json.moved": "JSON store files written after the SQLite migration were archived, not imported.",
29381
- "legacy-json.archive-failed": "Imported JSON store files could not be archived."
29641
+ "legacy-json.archive-failed": "Imported JSON store files could not be archived.",
29642
+ "lease.heartbeat-failed": "A held lease's heartbeat failed, which shortens the lease; the next one retries.",
29643
+ "scrub.checkpoint-failed": "Deleted content could not be scrubbed from the WAL because the truncating checkpoint failed or was blocked; the next checkpoint retries.",
29644
+ ...THROTTLE_LOG_EVENTS
29382
29645
  }
29383
29646
  }
29384
29647
  });
@@ -29469,6 +29732,11 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
29469
29732
  "wake.observe-pull-request-failed": "A pull request could not be observed for status wakes.",
29470
29733
  "wake.observe-feature-plan-failed": "A feature plan could not be observed for status wakes.",
29471
29734
  "wake.observe-workflow-failed": "A workflow could not be observed for status wakes.",
29735
+ "notice.outbox-refused": "A leaf's outbox refused a coordinator notice, so its own coordinator takes it.",
29736
+ "notice.start-main-failed": "A coordinator notice could not start a main coordinator; it waits for one to open.",
29737
+ "notice.take-back-unread": "A notice handed back from a command node found no open coordinator here.",
29738
+ "limit-stop.own": "A coordinator's own usage-limit stop attempted to move it off the account.",
29739
+ "limit-stop.notice-failed": "A usage-limit notice could not be sent; it stays in the ledger for the next attempt.",
29472
29740
  "wake.deliver-failed": "A workflow status wake could not be delivered; the next pass retries.",
29473
29741
  "wake.waiting-check-failed": "A waiting worker could not be checked; the next pass retries.",
29474
29742
  "wake.resolve-report-failed": "A finished Resolve tab could not be reported.",
@@ -29486,8 +29754,10 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
29486
29754
  "remote-worker.settle-failed": "A remote worker could not be settled.",
29487
29755
  "checkout.merge-followed": "After an environment's PR merged, the project checkout was fast-forwarded, or `outcome` says why not.",
29488
29756
  "checkout.merge-follow-failed": "Fast-forwarding the project checkout failed, after an environment's PR merged or before mail woke the main coordinator.",
29489
- "checkout.mail-follow": "Before mail woke the main coordinator, the project checkout was fast-forwarded, or `outcome` says why not (`timed-out`, `failed`).",
29490
- "checkout.mail-follow-failed": "Before mail woke the main coordinator, checking whether to fast-forward the project checkout failed; the mail was delivered anyway."
29757
+ "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`).",
29758
+ "checkout.mail-follow-failed": "Before mail woke the main coordinator, checking whether to fast-forward the project checkout failed; the mail was delivered anyway.",
29759
+ "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`.",
29760
+ "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."
29491
29761
  }
29492
29762
  }
29493
29763
  });
@@ -29497,15 +29767,15 @@ var REVIEW_LOG_AREAS = defineLogAreas({
29497
29767
  review: {
29498
29768
  description: "Multi Review workflows: scheduling, graph runs and interactive fix sessions.",
29499
29769
  events: {
29500
- "fix-tab.publish-failed": "A fix request was delivered but its tab could not be opened; the user is told.",
29770
+ "fix-tab.publish-failed": "A Address Findings request was delivered but its tab could not be opened; the user is told.",
29501
29771
  "graph-run.not-started": "A workflow's graph run did not start.",
29502
29772
  "reconcile.scan-failed": "A reconciliation scan failed; the next scan retries.",
29503
29773
  "graph-engine.unavailable": "The graph engine is selected but unavailable, so the bespoke engine runs.",
29504
29774
  "graph-run.cancel-failed": "Cancelling a graph run failed; the next pass projects how it ended.",
29505
29775
  "delete.cleanup-failed": "A cleanup step after deleting a workflow failed; stale tabs reconcile away on hydration.",
29506
- "fix-session.read-failed": "Reading an interactive fix session's state failed.",
29776
+ "fix-session.read-failed": "Reading an interactive Address Findings session's state failed.",
29507
29777
  "fix-outcome.read-failed": "Reading an interactive fix's outcome failed; it stays pending.",
29508
- "fix-usage.read-failed": "Reading a fix session's token usage failed.",
29778
+ "fix-usage.read-failed": "Reading an Address Findings session's token usage failed.",
29509
29779
  "result.consume-deferred": "Consuming a workflow result failed; it stays staged and is retried.",
29510
29780
  "failure-triage.failed": "Classifying a review package's failing tests failed; the package is sealed without the triage and says so."
29511
29781
  }
@@ -29558,6 +29828,7 @@ var AGENT_ACCOUNTS_LOG_AREAS = defineLogAreas({
29558
29828
  "agent-accounts": {
29559
29829
  description: "Agent accounts: automatic switching, staged logins and plan usage.",
29560
29830
  events: {
29831
+ "limit-stop-notice.failed": "A session's usage-limit stop could not be reported.",
29561
29832
  "switch-notice.failed": "A notice about an automatic account switch failed; the switch stands. `audience` says whose.",
29562
29833
  "auto-switch.check-failed": "An automatic account check failed; the next nudge retries.",
29563
29834
  "container-sync.failed": "Handing a login or account to a container failed; `step` says which part.",
@@ -29576,6 +29847,17 @@ var DOCKER_LOG_AREAS = defineLogAreas({
29576
29847
  description: "Docker containers: lifecycle, starts, staged inputs and the login files they hold.",
29577
29848
  events: {
29578
29849
  "portable-inputs.relay-missing": "Docker is rootless and the image predates the staged-input relay, so the container cannot read them until rebuilt.",
29850
+ "git-mirror.mount-unavailable": "A new container gets no project Git mirror, so its clone goes to the remote.",
29851
+ "git-mirror.refreshed": "A project's Git mirror was built or updated.",
29852
+ "git-mirror.refresh-failed": "A project's Git mirror could not be updated. New clones still work, from the mirror as it was or from the remote.",
29853
+ "git-mirror.low-disk": "A project's Git mirror was not updated: the disk is nearly full.",
29854
+ "git-mirror.oversized": "A project's repository is too large for a Git mirror, so its environments keep the blobless clone.",
29855
+ "git-mirror.compact-failed": "A project's Git mirror could not be compacted.",
29856
+ "git-mirror.state-write-failed": "A project's Git mirror could not be marked for checking.",
29857
+ "git-mirror.remove-failed": "A project's Git mirror could not be removed; a sweep retries.",
29858
+ "git-mirror.orphans-removed": "Git mirrors of removed projects were removed.",
29859
+ "git-mirror.clone-used": "A new environment cloned from its project's Git mirror.",
29860
+ "git-mirror.clone-fallback": "A new environment could not clone from its project's Git mirror and cloned from the remote.",
29579
29861
  "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.",
29580
29862
  "opencode.warm-incomplete": "OpenCode did not finish loading /workspace in a container.",
29581
29863
  "lifecycle-event.reconcile-failed": "Reconciling an environment after a container start or stop event failed; the next status read retries.",
@@ -29590,7 +29872,27 @@ var DOCKER_LOG_AREAS = defineLogAreas({
29590
29872
  "recovery.clear-terminals-failed": "Terminal sessions could not be cleared after a recovery restore.",
29591
29873
  "github-ranges.seed-not-copied": "The GitHub ranges seed could not be copied into a container, so its firewall fetches them.",
29592
29874
  "availability.probe-failed": "Docker is not available; written when the diagnostic changes. Fixed-shape metadata only: messages can hold daemon endpoints.",
29593
- "start.port-collision-retrying": "An automatic host port collided on start, so it is retried once with fresh ports."
29875
+ "start.port-collision-retrying": "An automatic host port collided on start, so it is retried once with fresh ports.",
29876
+ "writer-lease.lost": {
29877
+ description: "This backend lost the registry writer lease, for the fixed `reason` given. Schedules stop and container changes are refused until it restarts.",
29878
+ essential: true,
29879
+ fields: { reason: "label" }
29880
+ },
29881
+ "writer-lease.regained": {
29882
+ 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.",
29883
+ essential: true,
29884
+ fields: { staleForMs: "number" }
29885
+ },
29886
+ "writer-lease.not-acquired": {
29887
+ 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.",
29888
+ essential: true,
29889
+ fields: { reason: "label" }
29890
+ },
29891
+ "bridge.launched": {
29892
+ 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.",
29893
+ essential: true,
29894
+ fields: { provider: "label", containerPort: "number" }
29895
+ }
29594
29896
  }
29595
29897
  },
29596
29898
  "docker.reachability": {
@@ -29704,8 +30006,12 @@ var NODES_LOG_AREAS = defineLogAreas({
29704
30006
  nodes: {
29705
30007
  description: "Command nodes: links, handovers, leaf mail, ticket sync and project copies.",
29706
30008
  events: {
30009
+ ...THROTTLE_LOG_EVENTS,
29707
30010
  "actions.resume-failed": "Approved actions could not be resumed; a later pass retries.",
29708
30011
  "project-copy.notify-failed": "The coordinator could not be told a project copy finished.",
30012
+ "mail.return-deferred": "The leaf refused returned mail; it remains queued for retry.",
30013
+ "notices.take-back-failed": "A notice for this node's coordinator stayed in the outbox.",
30014
+ "notice.collected-retired": "A detached controller owned a notice with ambiguous delivery; retired without redelivery.",
29709
30015
  "mail.delivery-deferred": "Leaf mail could not reach a coordinator yet.",
29710
30016
  "command.post-step-failed": "A step after a routed command failed.",
29711
30017
  "seed-files.incomplete": "Seed files for a leaf environment were not all copied.",
@@ -30221,6 +30527,7 @@ var WEB_SYNC_LOG_AREAS = defineLogAreas({
30221
30527
  "web.read-coordinator": {
30222
30528
  description: "The renderer's coalesced, bounded backend reads.",
30223
30529
  events: {
30530
+ "poll.read-failed": "A coordinated poll's read failed; it stays on its interval.",
30224
30531
  "listener.threw": "A read state listener threw.",
30225
30532
  "read.settle-failed": "Applying a finished read's result threw."
30226
30533
  }
@@ -30298,6 +30605,146 @@ var LOG_VOCABULARY = {
30298
30605
  ...WEB_SYNC_LOG_AREAS
30299
30606
  };
30300
30607
 
30608
+ // ../protocol/src/log-essential-labels.ts
30609
+ var ERROR_NAMES = new Set([
30610
+ "Error",
30611
+ "TypeError",
30612
+ "RangeError",
30613
+ "ReferenceError",
30614
+ "SyntaxError",
30615
+ "URIError",
30616
+ "EvalError",
30617
+ "AggregateError",
30618
+ "AbortError",
30619
+ "TimeoutError",
30620
+ "SystemError"
30621
+ ]);
30622
+ var ERROR_CODES = new Set([
30623
+ "EACCES",
30624
+ "EADDRINUSE",
30625
+ "EADDRNOTAVAIL",
30626
+ "EAGAIN",
30627
+ "EBADF",
30628
+ "EBUSY",
30629
+ "ECANCELED",
30630
+ "ECONNABORTED",
30631
+ "ECONNREFUSED",
30632
+ "ECONNRESET",
30633
+ "EEXIST",
30634
+ "EHOSTUNREACH",
30635
+ "EINTR",
30636
+ "EINVAL",
30637
+ "EIO",
30638
+ "EISDIR",
30639
+ "EMFILE",
30640
+ "ENETUNREACH",
30641
+ "ENFILE",
30642
+ "ENOENT",
30643
+ "ENOMEM",
30644
+ "ENOSPC",
30645
+ "ENOSYS",
30646
+ "ENOTDIR",
30647
+ "ENOTEMPTY",
30648
+ "ENOTFOUND",
30649
+ "EPERM",
30650
+ "EPIPE",
30651
+ "EROFS",
30652
+ "ETIMEDOUT",
30653
+ "EXDEV",
30654
+ "SQLITE_BUSY",
30655
+ "SQLITE_CORRUPT",
30656
+ "SQLITE_FULL",
30657
+ "SQLITE_IOERR",
30658
+ "SQLITE_NOTADB",
30659
+ "SQLITE_READONLY",
30660
+ "ERR_CANCELED",
30661
+ "ERR_STREAM_DESTROYED"
30662
+ ]);
30663
+ var SYSCALLS = new Set([
30664
+ "open",
30665
+ "read",
30666
+ "write",
30667
+ "stat",
30668
+ "lstat",
30669
+ "mkdir",
30670
+ "rmdir",
30671
+ "readdir",
30672
+ "rename",
30673
+ "unlink",
30674
+ "fsync",
30675
+ "fdatasync",
30676
+ "close",
30677
+ "access",
30678
+ "chmod",
30679
+ "copyfile",
30680
+ "connect",
30681
+ "listen",
30682
+ "bind",
30683
+ "spawn",
30684
+ "kill",
30685
+ "getaddrinfo"
30686
+ ]);
30687
+ var SIGNALS = new Set([
30688
+ "SIGABRT",
30689
+ "SIGALRM",
30690
+ "SIGBUS",
30691
+ "SIGCHLD",
30692
+ "SIGCONT",
30693
+ "SIGFPE",
30694
+ "SIGHUP",
30695
+ "SIGILL",
30696
+ "SIGINT",
30697
+ "SIGKILL",
30698
+ "SIGPIPE",
30699
+ "SIGQUIT",
30700
+ "SIGSEGV",
30701
+ "SIGSTOP",
30702
+ "SIGTERM",
30703
+ "SIGTRAP",
30704
+ "SIGTSTP",
30705
+ "SIGTTIN",
30706
+ "SIGTTOU",
30707
+ "SIGUSR1",
30708
+ "SIGUSR2",
30709
+ "SIGWINCH",
30710
+ "SIGXCPU",
30711
+ "SIGXFSZ"
30712
+ ]);
30713
+ var PROVIDERS3 = new Set(["claude", "codex", "opencode", "cursor", "grok", "acp", "pi"]);
30714
+ var UUID = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}";
30715
+ var SOURCE = new RegExp(`^(?:claude|codex|opencode|cursor|grok|acp|pi):${UUID}$`, "i");
30716
+
30717
+ // ../protocol/src/log-essential.ts
30718
+ var vocabulary = LOG_VOCABULARY;
30719
+ var UNDECLARED_ERROR_LABELS = new Set([
30720
+ "site",
30721
+ "kind",
30722
+ "step",
30723
+ "reason",
30724
+ "signal",
30725
+ "code"
30726
+ ]);
30727
+ function eventSpec(area, event) {
30728
+ const spec = Object.hasOwn(vocabulary, area) ? vocabulary[area] : undefined;
30729
+ if (!spec || !Object.hasOwn(spec.events, event))
30730
+ return null;
30731
+ const definition = spec.events[event];
30732
+ return typeof definition === "object" && definition.essential ? definition : null;
30733
+ }
30734
+ function declaredEssential(area, event, level) {
30735
+ const spec = eventSpec(area, event);
30736
+ return spec && (spec.minLevel !== "error" || level === "error") ? spec : null;
30737
+ }
30738
+ function hasEssentialEvents(area) {
30739
+ const spec = Object.hasOwn(vocabulary, area) ? vocabulary[area] : undefined;
30740
+ return spec !== undefined && Object.values(spec.events).some((event) => typeof event === "object" && event.essential);
30741
+ }
30742
+ function isEssentialEntry(area, event, level) {
30743
+ if (area === "logging" && event === "essential.write-failed")
30744
+ return false;
30745
+ return level === "error" || declaredEssential(area, event, level) !== null;
30746
+ }
30747
+
30301
30748
  // ../protocol/src/logger.ts
30302
30749
  var LOG_LEVELS = ["error", "warn", "info", "debug", "trace"];
30303
30750
  var MAX_FIELD_CHARS = 2048;
@@ -30342,7 +30789,9 @@ var DEFAULT_CONFIG = {
30342
30789
  level: "info",
30343
30790
  areaLevels: {},
30344
30791
  format: "text",
30345
- sink: consoleSink
30792
+ sink: consoleSink,
30793
+ essentialSink: null,
30794
+ relayEssential: false
30346
30795
  };
30347
30796
  var config2 = DEFAULT_CONFIG;
30348
30797
  var generation = 0;
@@ -30453,17 +30902,38 @@ function renderText(record) {
30453
30902
  function renderJson(record) {
30454
30903
  return escapeLogLine(JSON.stringify(record));
30455
30904
  }
30905
+ function offerEssential(record) {
30906
+ if (!config2.essentialSink || !isEssentialEntry(record.area, record.event, record.level))
30907
+ return;
30908
+ try {
30909
+ config2.essentialSink(record);
30910
+ } catch {}
30911
+ }
30456
30912
  function deliver(record) {
30913
+ let delivered = true;
30457
30914
  try {
30458
30915
  config2.sink({
30459
30916
  method: OUTPUT_METHOD[record.level],
30460
30917
  line: config2.format === "json" ? renderJson(record) : renderText(record),
30461
30918
  record
30462
30919
  });
30463
- return true;
30464
30920
  } catch {
30465
- return false;
30921
+ delivered = false;
30466
30922
  }
30923
+ offerEssential(record);
30924
+ return delivered;
30925
+ }
30926
+ function deliverEssentialOnly(record) {
30927
+ if (config2.essentialSink) {
30928
+ offerEssential(record);
30929
+ return;
30930
+ }
30931
+ if (!config2.relayEssential)
30932
+ return;
30933
+ const marked = { ...record, essentialOnly: true };
30934
+ try {
30935
+ config2.sink({ method: OUTPUT_METHOD[record.level], line: renderJson(marked), record: marked });
30936
+ } catch {}
30467
30937
  }
30468
30938
  function buildRecord(level, area, event, fields) {
30469
30939
  const clean = fields ? sanitizeFields(fields, areaSpec(area)?.maxStringChars ?? MAX_FIELD_CHARS) : undefined;
@@ -30628,12 +31098,17 @@ function deliverEvent(level, area, event, fields) {
30628
31098
  return deliver(buildRecord(level, area, event, fields));
30629
31099
  }
30630
31100
  function tryWriteLog(level, area, event, fields) {
30631
- if (LEVEL_RANK[level] > thresholdRank(area))
31101
+ if (LEVEL_RANK[level] > thresholdRank(area)) {
31102
+ if (isEssentialEntry(area, event, level)) {
31103
+ deliverEssentialOnly(buildRecord(level, area, event, resolveFields(fields)));
31104
+ }
30632
31105
  return false;
31106
+ }
30633
31107
  return deliverEvent(level, area, event, resolveFields(fields));
30634
31108
  }
30635
31109
  function createLogger(area) {
30636
31110
  const spec = areaSpec(area);
31111
+ const mayHoldEssential = hasEssentialEvents(area);
30637
31112
  let seenGeneration = -1;
30638
31113
  let rank = 0;
30639
31114
  const enabled = (level) => {
@@ -30646,9 +31121,16 @@ function createLogger(area) {
30646
31121
  const writeResolved = (level, event, resolved) => {
30647
31122
  deliverEvent(level, area, event, resolved);
30648
31123
  };
31124
+ const writeFiltered = (level, event, fields) => {
31125
+ if (!mayHoldEssential || !isEssentialEntry(area, event, level))
31126
+ return;
31127
+ deliverEssentialOnly(buildRecord(level, area, event, resolveFields(fields)));
31128
+ };
30649
31129
  const write = (level, event, fields) => {
30650
- if (!enabled(level))
31130
+ if (!enabled(level)) {
31131
+ writeFiltered(level, event, fields);
30651
31132
  return;
31133
+ }
30652
31134
  writeResolved(level, event, resolveFields(fields));
30653
31135
  };
30654
31136
  return {
@@ -30659,8 +31141,10 @@ function createLogger(area) {
30659
31141
  trace: (event, fields) => write("trace", event, fields),
30660
31142
  throttled: (level, event, options) => {
30661
31143
  syncThrottleLevels();
30662
- if (!enabled(level))
31144
+ if (!enabled(level)) {
31145
+ writeFiltered(level, event, options.fields);
30663
31146
  return;
31147
+ }
30664
31148
  if (!spec || !Object.hasOwn(spec.events, event) || event.startsWith("throttle.") || !Object.hasOwn(spec.events, "throttle.recovered")) {
30665
31149
  deliver(buildRecord(level, spec ? area : "logging", spec ? "invalid-event" : "unknown-area", undefined));
30666
31150
  return;
@@ -31054,6 +31538,7 @@ function restoreSession(entry, fileBytes) {
31054
31538
  state.id = entry.id;
31055
31539
  if (isNativeAgentExecutionPolicy(entry.policy))
31056
31540
  state.policy = entry.policy;
31541
+ state.policyPending = true;
31057
31542
  if (typeof entry.readOnly === "boolean")
31058
31543
  state.readOnly = entry.readOnly;
31059
31544
  if (nonBlank(entry.agentId))
@@ -34403,15 +34888,18 @@ async function createSession(clientSessionKey, patch, policy, readOnly) {
34403
34888
  throw new SessionConflictError("This Cursor session is closing; retry once the close completes");
34404
34889
  }
34405
34890
  if (policy)
34406
- existing.policy = resolveCursorExecutionPolicy(policy);
34891
+ await applyRequestedPolicy(existing, resolveCursorExecutionPolicy(policy));
34407
34892
  return existing;
34408
34893
  }
34409
34894
  const inFlight = sessionCreations.get(clientSessionKey);
34410
- if (inFlight)
34411
- return inFlight;
34895
+ if (inFlight) {
34896
+ await inFlight;
34897
+ return createSession(clientSessionKey, patch, policy, readOnly);
34898
+ }
34412
34899
  }
34413
34900
  const work = (async () => {
34414
34901
  const state = newSessionState(clientSessionKey, resolveCursorExecutionPolicy(policy));
34902
+ state.policyPending = !policy;
34415
34903
  state.promptJournalComplete = true;
34416
34904
  if (typeof readOnly === "boolean")
34417
34905
  state.readOnly = readOnly;
@@ -34432,6 +34920,8 @@ async function createSession(clientSessionKey, patch, policy, readOnly) {
34432
34920
  }
34433
34921
  }
34434
34922
  async function ensureAgent(state, options = {}) {
34923
+ if (policyChanges.has(state))
34924
+ throw new SessionConflictError("Session policy is changing");
34435
34925
  assertSessionOpen(state);
34436
34926
  if (state.agent && (state.attachedMcpKey ?? "") !== mcpConnectionKey(state.agentMcp)) {
34437
34927
  const agent = state.agent;
@@ -34460,6 +34950,8 @@ async function ensureAgent(state, options = {}) {
34460
34950
  await detachAgent(state);
34461
34951
  }
34462
34952
  assertSessionOpen(state);
34953
+ if (policyChanges.has(state))
34954
+ throw new SessionConflictError("Session policy is changing");
34463
34955
  if (state.agent)
34464
34956
  return state.agent;
34465
34957
  state.attaching ??= attach(state).finally(() => {
@@ -34684,6 +35176,10 @@ async function attach(state) {
34684
35176
  if (state.configResumePending) {
34685
35177
  throw new Error("Cursor could not reopen this conversation with the updated configuration. The conversation was kept; retry with the current settings.", { cause: error });
34686
35178
  }
35179
+ log5.warn("session.resume-fell-back", {
35180
+ sessionId: state.id,
35181
+ error: formatLogError(error, { message: false })
35182
+ });
34687
35183
  state.agentId = undefined;
34688
35184
  }
34689
35185
  }
@@ -34950,6 +35446,32 @@ function resumePolicyKey(policy) {
34950
35446
  toolPolicy: resolved.toolPolicy ?? null
34951
35447
  });
34952
35448
  }
35449
+ var policyChanges = new WeakSet;
35450
+ async function applyRequestedPolicy(state, policy) {
35451
+ if (policyChanges.has(state))
35452
+ throw new SessionConflictError("Session policy is changing");
35453
+ assertExecutionPolicyNotWidened(liveExecutionPolicy(state), policy);
35454
+ if (JSON.stringify(state.policy) !== JSON.stringify(policy)) {
35455
+ if (state.status === "running" || state.dispatching || state.rewinding) {
35456
+ throw new SessionConflictError("Session is already running");
35457
+ }
35458
+ policyChanges.add(state);
35459
+ state.dispatching = true;
35460
+ try {
35461
+ await state.attaching?.catch(() => {
35462
+ return;
35463
+ });
35464
+ await detachAgent(state);
35465
+ assertSessionOpen(state);
35466
+ assertExecutionPolicyNotWidened(liveExecutionPolicy(state), policy);
35467
+ state.policy = policy;
35468
+ } finally {
35469
+ state.dispatching = false;
35470
+ policyChanges.delete(state);
35471
+ }
35472
+ }
35473
+ state.policyPending = false;
35474
+ }
34953
35475
  function resumeComposerConflicts(state, patch) {
34954
35476
  if (!patch)
34955
35477
  return false;
@@ -34975,9 +35497,11 @@ async function resumeSession(agentId, patch, policy, agentMcp) {
34975
35497
  throw new SessionConflictError("This Cursor session is closing; retry once the close completes");
34976
35498
  }
34977
35499
  if (existing) {
34978
- if (resumePolicyKey(existing.policy) !== requestedPolicyKey || resumeComposerConflicts(existing, patch)) {
34979
- throw new SessionConflictError("Cursor session is already adopted under a different execution policy");
35500
+ if (resumeComposerConflicts(existing, patch)) {
35501
+ throw new SessionConflictError("Cursor session is already adopted with different composer controls");
34980
35502
  }
35503
+ if (policy)
35504
+ await applyRequestedPolicy(existing, resolveCursorExecutionPolicy(policy));
34981
35505
  if (agentMcp)
34982
35506
  existing.agentMcp = agentMcp;
34983
35507
  return existing;
@@ -34993,6 +35517,7 @@ async function resumeSession(agentId, patch, policy, agentMcp) {
34993
35517
  if (hasTombstoneForAgent(agentId))
34994
35518
  await finishTombstonesForAgent(agentId);
34995
35519
  const state = newSessionState(undefined, resolveCursorExecutionPolicy(policy));
35520
+ state.policyPending = !policy;
34996
35521
  state.agentId = agentId;
34997
35522
  state.agentMcp = agentMcp;
34998
35523
  applyComposerPatch(state, patch);
@@ -35053,7 +35578,11 @@ async function recoverActiveRun(state) {
35053
35578
  state.status = "running";
35054
35579
  state.turnStartedAt = active.createdAt;
35055
35580
  beginAssistantTurn(state);
35056
- state.cancelTurn = () => active.cancel();
35581
+ state.turnCancelRequested = undefined;
35582
+ state.cancelTurn = () => {
35583
+ state.turnCancelRequested = true;
35584
+ return active.cancel();
35585
+ };
35057
35586
  state.revision += 1;
35058
35587
  const unsubscribe = active.onDidChangeStatus(() => {
35059
35588
  state.revision += 1;
@@ -35076,7 +35605,16 @@ async function recoverActiveRun(state) {
35076
35605
  await hydrateHistory(state);
35077
35606
  state.status = active.status === "error" ? "error" : "idle";
35078
35607
  state.error = active.error?.message;
35608
+ if (active.status === "error" && state.turnCancelRequested !== true) {
35609
+ log5.warn("turn.recovery-failed", { sessionId: state.id });
35610
+ }
35079
35611
  } catch (error) {
35612
+ if (state.turnCancelRequested !== true) {
35613
+ log5.warn("turn.recovery-failed", {
35614
+ sessionId: state.id,
35615
+ error: formatLogError(error, { message: false })
35616
+ });
35617
+ }
35080
35618
  state.status = "error";
35081
35619
  state.error = error instanceof Error ? error.message : "Cursor run recovery failed";
35082
35620
  } finally {
@@ -36134,6 +36672,7 @@ function classify(toolCall) {
36134
36672
  return;
36135
36673
  }
36136
36674
  // ../../bridges/cursor-bridge/src/prompt.ts
36675
+ var log6 = createLogger("bridge.cursor");
36137
36676
  var STRUCTURED_PROMPT_INSTRUCTION_PREFIX = "End your turn with exactly one JSON value";
36138
36677
  function structuredPromptInstruction(schema) {
36139
36678
  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.
@@ -36248,7 +36787,9 @@ async function followStartedRun(state, run, promptSequence, input, diagnostics,
36248
36787
  state.revision += 1;
36249
36788
  });
36250
36789
  let cancelling;
36790
+ state.turnCancelRequested = undefined;
36251
36791
  state.cancelTurn = () => {
36792
+ state.turnCancelRequested = true;
36252
36793
  if (!cancelling) {
36253
36794
  const attempt = (async () => {
36254
36795
  await (diagnostics ? diagnostics.cancel(run, "user") : run.cancel().catch(() => {
@@ -36333,6 +36874,7 @@ async function followRun(state, run, promptSequence, input, timeoutMs = PROMPT_T
36333
36874
  }) : undefined;
36334
36875
  if (!turnStillOwned(state, promptSequence))
36335
36876
  return await closedTurnStopped();
36877
+ log6.warn("turn.timed-out", { sessionId: state.id });
36336
36878
  state.error = error.message;
36337
36879
  state.revision += 1;
36338
36880
  schedulePersist();
@@ -36400,6 +36942,12 @@ function finishTurn(state, result, input, streamed) {
36400
36942
  schedulePersist();
36401
36943
  }
36402
36944
  function failTurn(state, error, input, result, streamed = {}) {
36945
+ if (state.turnCancelRequested !== true) {
36946
+ log6.warn("turn.failed", {
36947
+ sessionId: state.id,
36948
+ error: formatLogError(error, { message: false })
36949
+ });
36950
+ }
36403
36951
  settleBackgroundChildren(state);
36404
36952
  settleAbandonedToolParts(state);
36405
36953
  endTurnEvidence(state, turnEvidence.get(state), {
@@ -37270,7 +37818,8 @@ function configureLoggerFromEnvironment(env, options = {}) {
37270
37818
  configureLogger({
37271
37819
  ...levels.level ? { level: levels.level } : {},
37272
37820
  areaLevels: levels.areaLevels,
37273
- format
37821
+ format,
37822
+ relayEssential: options.relayToSupervisor === true
37274
37823
  });
37275
37824
  const log = createLogger("logging");
37276
37825
  if (levels.invalid.length > 0) {
@@ -38103,7 +38652,7 @@ var SOURCES = new Set([
38103
38652
  var EXECUTION_KINDS = new Set(NATIVE_AGENT_COMMAND_EXECUTION_KINDS);
38104
38653
  var ORIGINS2 = new Set(NATIVE_AGENT_COMMAND_ORIGINS);
38105
38654
  var UNAVAILABLE_REASONS = new Set(NATIVE_AGENT_COMMAND_UNAVAILABLE_REASONS);
38106
- var ERROR_CODES = new Set(NATIVE_AGENT_COMMAND_CATALOGUE_ERROR_CODES);
38655
+ var ERROR_CODES2 = new Set(NATIVE_AGENT_COMMAND_CATALOGUE_ERROR_CODES);
38107
38656
  var encoder2 = new TextEncoder;
38108
38657
  function utf8ByteLength(value) {
38109
38658
  if (/^[\x00-\x7f]*$/.test(value))
@@ -38391,7 +38940,7 @@ async function answerSessionActivityBatch(body, read, options = {}) {
38391
38940
  }
38392
38941
 
38393
38942
  // ../../bridges/cursor-bridge/src/http.ts
38394
- var log6 = createLogger("bridge.cursor");
38943
+ var log7 = createLogger("bridge.cursor");
38395
38944
 
38396
38945
  class HttpError extends Error {
38397
38946
  status;
@@ -38434,6 +38983,10 @@ async function route(request, response, clientSignal) {
38434
38983
  } catch (error) {
38435
38984
  if (error instanceof HttpError)
38436
38985
  return json(response, error.status, { error: error.message });
38986
+ if (error instanceof PolicyWideningRefusedError) {
38987
+ log7.warn("session.policy-widening-refused", { widened: error.widened.join(",") });
38988
+ return json(response, 403, error.refusal());
38989
+ }
38437
38990
  if (error instanceof CredentialError) {
38438
38991
  return json(response, 401, {
38439
38992
  error: error.message,
@@ -38456,7 +39009,7 @@ async function route(request, response, clientSignal) {
38456
39009
  if (error instanceof PromptAttachmentError) {
38457
39010
  return json(response, 400, { error: error.message });
38458
39011
  }
38459
- log6.error("http.route-failed");
39012
+ log7.error("http.route-failed");
38460
39013
  return json(response, 500, { error: "Internal bridge error" });
38461
39014
  }
38462
39015
  }
@@ -38973,6 +39526,9 @@ function unsupportedCommandRefresh() {
38973
39526
  }
38974
39527
  async function handlePrompt(request, response, state, clientSignal) {
38975
39528
  const body = await readJson(request);
39529
+ if (isNativeAgentExecutionPolicy(body.policy)) {
39530
+ assertExecutionPolicyNotWidened(liveExecutionPolicy(state), resolveCursorExecutionPolicy(body.policy));
39531
+ }
38976
39532
  const prompt = typeof body.prompt === "string" ? body.prompt.trim() : "";
38977
39533
  const requestId = readBoundedString(body.requestId, MAX_PROMPT_REQUEST_ID_BYTES, "requestId");
38978
39534
  const schema = isObject(body.outputSchema) ? body.outputSchema : undefined;
@@ -39018,6 +39574,7 @@ async function handlePrompt(request, response, state, clientSignal) {
39018
39574
  kind: "prompt-journal-saturated"
39019
39575
  });
39020
39576
  }
39577
+ state.policyPending = false;
39021
39578
  const idleSteer = commandFields.allowProviderCommands ? idleSteerPromptReply(prompt, "Cursor") : null;
39022
39579
  if (idleSteer) {
39023
39580
  assertSessionOpen(state);
@@ -39154,6 +39711,10 @@ async function dispatchClaimedPrompt(response, state, input) {
39154
39711
  userMessageId
39155
39712
  });
39156
39713
  } catch (error) {
39714
+ log7.warn("turn.send-failed", {
39715
+ sessionId: state.id,
39716
+ error: formatLogError(error, { message: false })
39717
+ });
39157
39718
  state.status = "error";
39158
39719
  state.error = errorText(error);
39159
39720
  state.dispatching = false;
@@ -39444,7 +40005,7 @@ function startParentWatchdog(options) {
39444
40005
  }
39445
40006
 
39446
40007
  // ../protocol/src/bridge-lifecycle.ts
39447
- var log7 = createLogger("bridge.lifecycle");
40008
+ var log8 = createLogger("bridge.lifecycle");
39448
40009
  var TERMINATION_SIGNALS = ["SIGTERM", "SIGINT"];
39449
40010
  function errorKind(error) {
39450
40011
  if (error instanceof Error)
@@ -39498,7 +40059,7 @@ class BridgeLifecycle {
39498
40059
  }
39499
40060
  requestExit() {
39500
40061
  this.#exit ??= this.shutdown().then(() => this.#options.exit(0), (error) => {
39501
- log7.error("shutdown.failed", {
40062
+ log8.error("shutdown.failed", {
39502
40063
  bridge: this.#options.label,
39503
40064
  errorClass: errorKind(error)
39504
40065
  });
@@ -39515,7 +40076,7 @@ class BridgeLifecycle {
39515
40076
  try {
39516
40077
  idleSweep.run();
39517
40078
  } catch (error) {
39518
- log7.warn("idle-sweep.failed", {
40079
+ log8.warn("idle-sweep.failed", {
39519
40080
  bridge: this.#options.label,
39520
40081
  errorClass: errorKind(error)
39521
40082
  });
@@ -39587,7 +40148,7 @@ async function settleIdleDetaches() {
39587
40148
  }
39588
40149
 
39589
40150
  // ../../bridges/cursor-bridge/src/server.ts
39590
- var log8 = createLogger("bridge.cursor");
40151
+ var log9 = createLogger("bridge.cursor");
39591
40152
  var IDLE_SWEEP_MS = 60 * 1000;
39592
40153
  var lifecycle;
39593
40154
  var server = createServer((request, response) => {
@@ -39622,7 +40183,7 @@ function lifecycleFor(listenPort, options) {
39622
40183
  applyWorkingDirectory();
39623
40184
  await loadPersistedState();
39624
40185
  finishRestoredTombstones().catch(() => {
39625
- log8.warn("startup.closes-failed");
40186
+ log9.warn("startup.closes-failed");
39626
40187
  });
39627
40188
  await new Promise((resolve) => server.listen(listenPort, hostname, resolve));
39628
40189
  },
@@ -39776,6 +40337,9 @@ function installFatalRejectionGuard(options) {
39776
40337
  try {
39777
40338
  warn(`${options.label} Unhandled promise rejection (continuing): ${describe(reason)}`);
39778
40339
  } catch {}
40340
+ try {
40341
+ options.onRejection?.(reason);
40342
+ } catch {}
39779
40343
  };
39780
40344
  target.on("unhandledRejection", handler);
39781
40345
  return () => {
@@ -39783,6 +40347,15 @@ function installFatalRejectionGuard(options) {
39783
40347
  };
39784
40348
  }
39785
40349
 
40350
+ // ../protocol/src/node/process-failure-log.ts
40351
+ var log10 = createLogger("process");
40352
+ function logUnhandledRejection(reason) {
40353
+ log10.throttled("error", "rejection.unhandled", {
40354
+ error: reason,
40355
+ fields: () => ({ error: formatLogError(reason, { message: false }) })
40356
+ });
40357
+ }
40358
+
39786
40359
  // ../../bridges/cursor-bridge/src/login-cli.ts
39787
40360
  async function runLogin(emit) {
39788
40361
  const handle = beginLogin({ openBrowser: true });
@@ -39814,7 +40387,7 @@ async function runLogin(emit) {
39814
40387
 
39815
40388
  // ../../bridges/cursor-bridge/src/index.ts
39816
40389
  configureBridgeLogger();
39817
- installFatalRejectionGuard({ label: "[cursor-bridge]" });
40390
+ installFatalRejectionGuard({ label: "[cursor-bridge]", onRejection: logUnhandledRejection });
39818
40391
  if (process.argv.includes("--login")) {
39819
40392
  process.exit(await runLogin((line) => process.stdout.write(`${line}
39820
40393
  `)));
@@ -39945,6 +40518,7 @@ export {
39945
40518
  json,
39946
40519
  listModels,
39947
40520
  listResumableSessions,
40521
+ liveExecutionPolicy,
39948
40522
  loadPersistedState,
39949
40523
  logout,
39950
40524
  messageWindow,