orkestrator 2.36.2-beta → 2.36.4-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.
@@ -17,6 +17,7 @@ var TEXT_RULES = [
17
17
  pattern: /\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}/g,
18
18
  replacement: "[redacted]"
19
19
  },
20
+ { pattern: /\bok[ab]_[A-Za-z0-9_-]{16,}/g, replacement: "[redacted]" },
20
21
  { pattern: /\bgh[pousr]_[A-Za-z0-9]{16,}/g, replacement: "[redacted]" },
21
22
  { pattern: /\bgithub_pat_[A-Za-z0-9_]{20,}/g, replacement: "[redacted]" },
22
23
  { pattern: /\b(?:sk|rk|pk)-[A-Za-z0-9_-]{12,}/g, replacement: "[redacted]" },
@@ -257,6 +258,12 @@ var BACKEND_LOG_AREAS = defineLogAreas({
257
258
  "startup.looped-review-pending": "Cleanup of the retired Looped Review stays pending.",
258
259
  "notice.failed": "A background notice after a turn or prompt failed; `step` says which.",
259
260
  "artifacts.live-unavailable": "Live interactive artifacts are unavailable.",
261
+ "previous-run": {
262
+ description: "This start read how the previous run ended: `outcome` is `clean` when it reached the end of shutdown and `crashed` when it did not, `ranForMs` its length and `lastSeenAgoMs` the time since its last health row.",
263
+ essential: true,
264
+ fields: { outcome: "label", ranForMs: "number", lastSeenAgoMs: "number" }
265
+ },
266
+ "health.write-failed": "A health summary row could not be written or read; the next sample retries.",
260
267
  "shutdown.step-failed": "One part of shutdown failed and the rest went on; `step` says which.",
261
268
  "shutdown.signal-received": {
262
269
  description: "A signal started shutdown, which tells a clean quit from the backend being killed.",
@@ -300,7 +307,8 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
300
307
  description: "What every long-lived bridge does the same way: its sweep and its shutdown.",
301
308
  events: {
302
309
  "idle-sweep.failed": "An idle sweep threw; the next tick retries.",
303
- "shutdown.failed": "Releasing the bridge failed during shutdown; it still exits."
310
+ "shutdown.failed": "Releasing the bridge failed during shutdown; it still exits.",
311
+ "credential.not-hardened": "The bridge could not mark itself non-dumpable, so a same-uid process can read its memory; `reason` says why."
304
312
  }
305
313
  },
306
314
  "bridge.acp": {
@@ -434,7 +442,6 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
434
442
  "parent.gone": "The backend that launched this bridge has gone; stopping turns and shutting down.",
435
443
  "queue.overflow": "The notification queue passed a bound and dropped its backlog.",
436
444
  "queue.task-failed": "A task on a per-thread queue failed.",
437
- "raw-log.write-failed": "Appending to the raw Codex log failed.",
438
445
  "recorder.notice": "The notification recorder needs attention: it is on, or was asked for without its confirmation.",
439
446
  "recorder.threw": "The notification recorder threw.",
440
447
  "recorder.write-failed": "Writing a notification recording failed; its lines were dropped.",
@@ -640,6 +647,7 @@ var ENVIRONMENT_LOG_AREAS = defineLogAreas({
640
647
  environment: {
641
648
  description: "Environment naming, setup, status, moves, deletion and cleanup afterwards.",
642
649
  events: {
650
+ "cleanup.sessions-failed": "Session metadata cleanup failed during environment deletion; deletion continues.",
643
651
  "cleanup.branch-kept": "A deleted environment's local branch was kept, as it may hold unmerged work.",
644
652
  "rename.failed": "Naming an environment from its pending prompt failed for the first time.",
645
653
  "rename.still-failing": "That rename is still failing; written at the 2nd, 4th, 8th... failure.",
@@ -668,6 +676,7 @@ var ENVIRONMENT_LOG_AREAS = defineLogAreas({
668
676
  "status.docker-error": "A transient Docker error stopped a status read, so the stored status is kept.",
669
677
  "setup.clear-launch-failed": "A pending agent launch could not be cleared after setup failed.",
670
678
  "setup.record-failure-failed": "A setup failure before its first attempt could not be recorded.",
679
+ "setup.tab-publish-failed": "The setup terminal's tab could not be published.",
671
680
  "lifecycle.failed": "Starting, rebuilding or recreating an environment failed; `operation` says which.",
672
681
  "tab-teardown.pending": "A tab's teardown failed and stays pending; the reconcile sweep retries.",
673
682
  "tab-reconcile.skipped": "Orphaned tab reconciliation was skipped because pane layouts are unreadable.",
@@ -712,6 +721,7 @@ var GATEWAY_LOG_AREAS = defineLogAreas({
712
721
  "websocket.upgrade-failed": "A WebSocket upgrade failed.",
713
722
  "events.client-dropped": "An event-stream client buffered too much and was dropped; it reconnects and refetches.",
714
723
  "proxy.client-disconnected": "A proxy client went away, so its upstream request was aborted.",
724
+ "traffic.burst": "Connections or requests spiked. Counts by source address, route class, client family, listener and registered invoke command; never request content.",
715
725
  "throttle.suppressed": "Repeats of the throttled `site` were counted over a window, not written.",
716
726
  "throttle.recovered": "The throttled `site` succeeded again, so its fault has cleared.",
717
727
  "throttle.evicted": "The tracked-key limit dropped the `site`, so no recovered line follows unless it fails again."
@@ -845,6 +855,7 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
845
855
  "native-agent": {
846
856
  description: "Native agent sessions and what the backend reads from their bridges.",
847
857
  events: {
858
+ "session.bridge-replaced-for-policy": "An idle bridge was stopped so a resume could apply the user's wider execution policy.",
848
859
  "catalogue.outdated-bridge": "A bridge predates the command catalogue, so its commands stay unavailable.",
849
860
  "compact.instructions-ignored": "A bridge compacted without confirming the instructions sent with /compact: it predates them.",
850
861
  "handoff.summary-read-failed": "Change summaries could not be read for a handoff, so the carrier says they are unmeasured.",
@@ -875,6 +886,7 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
875
886
  "turn-recovery.failed": "Recovering an incomplete turn failed.",
876
887
  "turn-recovery.exhausted": "A turn failed again after automatic recovery and is left for the user.",
877
888
  "turn-recovery.retrying": "An incomplete or provider-failed turn is being retried automatically.",
889
+ "usage-limit.notice-failed": "A usage-limit stop's outcome could not be read for its notice.",
878
890
  "usage-limit.resend-failed": "Resending after a usage limit failed. An unknown send stays in the journal.",
879
891
  "title.strategy-failed": "A session title strategy failed, so the next is tried. Content-free: the error can quote the prompt.",
880
892
  ...THROTTLE_LOG_EVENTS
@@ -891,6 +903,15 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
891
903
  "recover.failed": "Goals could not be recovered at startup."
892
904
  }
893
905
  },
906
+ "native-agent.subork": {
907
+ description: "Suborks: the ask_agents calls a native agent makes. Content-free.",
908
+ events: {
909
+ "pass.failed": "A pass over a call failed, so a later pass retries. Counts only.",
910
+ "delivery.failed": "A call's answers could not be placed in the caller's mailbox yet. Error class only.",
911
+ "retention.failed": "An old call could not be removed.",
912
+ "sweep.failed": "A running call's caller could not be checked; the next sweep looks again."
913
+ }
914
+ },
894
915
  "native-agent.opencode": {
895
916
  description: "The OpenCode provider: its request monitor, retries and agent tools.",
896
917
  events: {
@@ -900,7 +921,8 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
900
921
  "coordinator-servers.unavailable": "OpenCode coordinator research servers are unavailable.",
901
922
  "monitor.reconnecting": "The request monitor lost its stream and is reconnecting. Error class only.",
902
923
  "worker-limit.reached": "The bounded request workers are full, so the stream restarts and a snapshot reconciles.",
903
- "request.failed": "Handling a request event failed, so the stream restarts. Error class only."
924
+ "request.failed": "Handling a request event failed, so the stream restarts. Error class only.",
925
+ "credential-plugin.skipped": "A host OpenCode server started without the credential plugin, so its tools inherit its password; `reason` says why."
904
926
  }
905
927
  }
906
928
  });
@@ -928,6 +950,7 @@ var PREVIEW_LOG_AREAS = defineLogAreas({
928
950
  "publication.start-failed": "Private preview publication did not start.",
929
951
  "publication.reconfigure-failed": "Preview publication could not be reconfigured.",
930
952
  "publication.listening": "Private preview origins are listening.",
953
+ "publication.same-site": "The preview domain is the same site as the application; publication runs with a warning.",
931
954
  "certificate.reloaded": "The preview certificate was reloaded.",
932
955
  "access.revoked-close-failed": "A revoked preview resource could not be closed. Error class only.",
933
956
  "registry.invalid-definition": "An invalid stored preview service definition was ignored.",
@@ -1236,10 +1259,19 @@ var STORAGE_LOG_AREAS = defineLogAreas({
1236
1259
  "retired.turn-cleanup-pending": "Cleanup of a retired Looped Review turn did not finish and stays pending.",
1237
1260
  "handoffs.prune-failed": "Pruning agent handoffs that nothing references failed; a later prune retries.",
1238
1261
  "desktop-connections.malformed": "Stored desktop connection settings were malformed, so the local connection is used.",
1262
+ "config.restrict-mode-failed": "A config file holding provider secrets could not be set to owner-only; the backend carries on.",
1239
1263
  "legacy-json.moved": "JSON store files written after the SQLite migration were archived, not imported.",
1240
1264
  "legacy-json.archive-failed": "Imported JSON store files could not be archived.",
1265
+ "lease.timed-out": "A waiter gave up on a lease; `lease` and `family` name it, `holderAgeMs` is the time since its holder's last heartbeat (null when the holder had just gone), `waitedMs` how long the waiter waited.",
1241
1266
  "lease.heartbeat-failed": "A held lease's heartbeat failed, which shortens the lease; the next one retries.",
1242
- "scrub.checkpoint-failed": "Deleted content could not be scrubbed from the WAL because the truncating checkpoint failed or was blocked; the next checkpoint retries.",
1267
+ "scrub.vacuum-failed": "Deleted-content page reclamation failed; the checkpoint is attempted independently.",
1268
+ "scrub.checkpoint-failed": "Deleted content could not be scrubbed from the WAL yet because the truncating checkpoint failed or a reader held an older snapshot; it is retried without waiting until it succeeds.",
1269
+ "upkeep.vacuum-failed": "Periodic page reclamation failed; the next upkeep pass retries.",
1270
+ "optimize.failed": "Refreshing the query planner's statistics failed; queries still run and the next check retries.",
1271
+ "ledger.moved": "The change-tracking ledger was moved out of the main database into its own file; `rows` and `durationMs` say how much and how long.",
1272
+ "snapshot.top-tables-failed": "The sampled table sizes from a finished snapshot could not be saved; the snapshot stands and the next one retries.",
1273
+ "snapshot.ledger-skipped": "The daily change-tracking ledger snapshot was skipped because the disk or the snapshot budget lacks room; `retryAt` says when it tries again.",
1274
+ "snapshot.ledger-failed": "The daily change-tracking ledger snapshot failed; `retryAt` says when it tries again, if known.",
1243
1275
  ...THROTTLE_LOG_EVENTS
1244
1276
  }
1245
1277
  }
@@ -1256,6 +1288,7 @@ var BUILD_PIPELINE_LOG_AREAS = defineLogAreas({
1256
1288
  "consolidation.consume-deferred": "Consuming a review consolidation result failed; it stays pending and is retried.",
1257
1289
  "dispatch.prepare-failed": "Attaching the agent before dispatch failed; the prompt request does the same work and answers authoritatively.",
1258
1290
  "interaction.resolved": "A human interaction on a pipeline stage resolved. Metadata only.",
1291
+ "user-message.background-send-refused": "The bridge refused a queued user message during a background wait; it stays queued and is retried.",
1259
1292
  "transcripts.migrated": "A transcript migration pass moved stage transcripts; counts only.",
1260
1293
  "transcripts.maintenance-failed": "Migrating or sweeping stage transcripts failed; the next start retries.",
1261
1294
  "restore.skipped": "A pipeline could not be restored at startup and was skipped.",
@@ -1293,6 +1326,8 @@ var CHANGE_TRACKING_LOG_AREAS = defineLogAreas({
1293
1326
  description: "Change tracking: turn capture, evidence pulls and measurements.",
1294
1327
  events: {
1295
1328
  "journal-import.failed": "Importing surviving OpenCode command journals as legacy summaries failed.",
1329
+ "measurement-drain.failed": "Draining an owner's superseded measurements failed; the retention pass retries.",
1330
+ "retention.failed": "A retention pass failed partway; what it deleted stands and the next pass goes on.",
1296
1331
  "projection.failed": "Projecting a change event onto its environment failed.",
1297
1332
  "startup.reconcile-failed": "Reconciling change tracking at startup failed.",
1298
1333
  "turn-start.capture-failed": "Capturing a turn's start failed, so the turn is untracked.",
@@ -1323,7 +1358,16 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
1323
1358
  coordinator: {
1324
1359
  description: "Coordinators: delegations, status wakes and their store.",
1325
1360
  events: {
1361
+ ...THROTTLE_LOG_EVENTS,
1326
1362
  "delegation.open-failed": "A delegation could not be opened; `source` says for what.",
1363
+ "delegation.reconcile-failed": "One delegation could not be settled; the rest of the pass still ran and the next one retries.",
1364
+ "delegation.wake-failed": "One delegation's wake could not be delivered; the rest of the pass still ran and the next one retries.",
1365
+ "delegation.wake-held": "A wake is waiting on a state the user can change (messaging off, conversation limit), and is not counted as a failure.",
1366
+ "delegation.wake-pass-failed": "A delegation wake pass could not run; the next sweep retries.",
1367
+ "delegation.wake-retire-failed": "A wake that keeps failing could not be given up on; the next pass retries.",
1368
+ "delegation.wake-retire-notice-failed": "The one notice for a wake being retired could not be sent; the wake stays owed and the next pass retries.",
1369
+ "delegation.wake-retired": "A wake kept failing and was given up on; `kind` is the last failure.",
1370
+ "mail.reconcile-failed": "One coordinator's mail could not be reconciled; the sweep carried on with the others.",
1327
1371
  "deliver-now.drain-failed": "The mail delivery pass after deliverNow failed; the next sweep delivers.",
1328
1372
  "mail.move-failed": "Mail could not move to the new main coordinator.",
1329
1373
  "work.move-failed": "Work could not move to the main coordinator.",
@@ -1331,6 +1375,11 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
1331
1375
  "wake.observe-pull-request-failed": "A pull request could not be observed for status wakes.",
1332
1376
  "wake.observe-feature-plan-failed": "A feature plan could not be observed for status wakes.",
1333
1377
  "wake.observe-workflow-failed": "A workflow could not be observed for status wakes.",
1378
+ "notice.outbox-refused": "A leaf's outbox refused a coordinator notice, so its own coordinator takes it.",
1379
+ "notice.start-main-failed": "A coordinator notice could not start a main coordinator; it waits for one to open.",
1380
+ "notice.take-back-unread": "A notice handed back from a command node found no open coordinator here.",
1381
+ "limit-stop.own": "A coordinator's own usage-limit stop attempted to move it off the account.",
1382
+ "limit-stop.notice-failed": "A usage-limit notice could not be sent; it stays in the ledger for the next attempt.",
1334
1383
  "wake.deliver-failed": "A workflow status wake could not be delivered; the next pass retries.",
1335
1384
  "wake.waiting-check-failed": "A waiting worker could not be checked; the next pass retries.",
1336
1385
  "wake.resolve-report-failed": "A finished Resolve tab could not be reported.",
@@ -1361,15 +1410,15 @@ var REVIEW_LOG_AREAS = defineLogAreas({
1361
1410
  review: {
1362
1411
  description: "Multi Review workflows: scheduling, graph runs and interactive fix sessions.",
1363
1412
  events: {
1364
- "fix-tab.publish-failed": "A fix request was delivered but its tab could not be opened; the user is told.",
1413
+ "fix-tab.publish-failed": "A Address Findings request was delivered but its tab could not be opened; the user is told.",
1365
1414
  "graph-run.not-started": "A workflow's graph run did not start.",
1366
1415
  "reconcile.scan-failed": "A reconciliation scan failed; the next scan retries.",
1367
1416
  "graph-engine.unavailable": "The graph engine is selected but unavailable, so the bespoke engine runs.",
1368
1417
  "graph-run.cancel-failed": "Cancelling a graph run failed; the next pass projects how it ended.",
1369
1418
  "delete.cleanup-failed": "A cleanup step after deleting a workflow failed; stale tabs reconcile away on hydration.",
1370
- "fix-session.read-failed": "Reading an interactive fix session's state failed.",
1419
+ "fix-session.read-failed": "Reading an interactive Address Findings session's state failed.",
1371
1420
  "fix-outcome.read-failed": "Reading an interactive fix's outcome failed; it stays pending.",
1372
- "fix-usage.read-failed": "Reading a fix session's token usage failed.",
1421
+ "fix-usage.read-failed": "Reading an Address Findings session's token usage failed.",
1373
1422
  "result.consume-deferred": "Consuming a workflow result failed; it stays staged and is retried.",
1374
1423
  "failure-triage.failed": "Classifying a review package's failing tests failed; the package is sealed without the triage and says so."
1375
1424
  }
@@ -1422,6 +1471,7 @@ var AGENT_ACCOUNTS_LOG_AREAS = defineLogAreas({
1422
1471
  "agent-accounts": {
1423
1472
  description: "Agent accounts: automatic switching, staged logins and plan usage.",
1424
1473
  events: {
1474
+ "limit-stop-notice.failed": "A session's usage-limit stop could not be reported.",
1425
1475
  "switch-notice.failed": "A notice about an automatic account switch failed; the switch stands. `audience` says whose.",
1426
1476
  "auto-switch.check-failed": "An automatic account check failed; the next nudge retries.",
1427
1477
  "container-sync.failed": "Handing a login or account to a container failed; `step` says which part.",
@@ -1440,8 +1490,22 @@ var DOCKER_LOG_AREAS = defineLogAreas({
1440
1490
  description: "Docker containers: lifecycle, starts, staged inputs and the login files they hold.",
1441
1491
  events: {
1442
1492
  "portable-inputs.relay-missing": "Docker is rootless and the image predates the staged-input relay, so the container cannot read them until rebuilt.",
1493
+ "git-mirror.mount-unavailable": "A new container gets no project Git mirror, so its clone goes to the remote.",
1494
+ "git-mirror.refreshed": "A project's Git mirror was built or updated.",
1495
+ "git-mirror.seeded": "A project's Git mirror was built from its host checkout and only what the remote added to it.",
1496
+ "git-mirror.seed-skipped": "A project's host checkout could not seed its Git mirror, so the build downloads everything.",
1497
+ "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.",
1498
+ "git-mirror.low-disk": "A project's Git mirror was not updated: the disk is nearly full.",
1499
+ "git-mirror.oversized": "A project's repository is too large for a Git mirror, so its environments keep the blobless clone.",
1500
+ "git-mirror.compact-failed": "A project's Git mirror could not be compacted.",
1501
+ "git-mirror.state-write-failed": "A project's Git mirror could not be marked for checking.",
1502
+ "git-mirror.remove-failed": "A project's Git mirror could not be removed; a sweep retries.",
1503
+ "git-mirror.orphans-removed": "Git mirrors of removed projects were removed.",
1504
+ "git-mirror.clone-used": "A new environment cloned from its project's Git mirror.",
1505
+ "git-mirror.clone-fallback": "A new environment could not clone from its project's Git mirror and cloned from the remote.",
1443
1506
  "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.",
1444
1507
  "opencode.warm-incomplete": "OpenCode did not finish loading /workspace in a container.",
1508
+ "log-driver.unbounded": "The Docker daemon offers neither the local nor the json-file log driver, so new containers keep its default driver, whose log may be uncapped. Written once per backend.",
1445
1509
  "lifecycle-event.reconcile-failed": "Reconciling an environment after a container start or stop event failed; the next status read retries.",
1446
1510
  "login-keeper.pass-failed": "A Claude login keeper pass failed; the next interval retries.",
1447
1511
  "login-keeper.refresh-failed": "Refreshing the host Claude login failed. Fixed text: CLI output can hold credentials.",
@@ -1465,6 +1529,7 @@ var DOCKER_LOG_AREAS = defineLogAreas({
1465
1529
  essential: true,
1466
1530
  fields: { staleForMs: "number" }
1467
1531
  },
1532
+ "writer-lease.listener-failed": "The callback told about a lost registry writer lease threw, so the schedules settings learn of the loss only at their next read.",
1468
1533
  "writer-lease.not-acquired": {
1469
1534
  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.",
1470
1535
  essential: true,
@@ -1588,8 +1653,12 @@ var NODES_LOG_AREAS = defineLogAreas({
1588
1653
  nodes: {
1589
1654
  description: "Command nodes: links, handovers, leaf mail, ticket sync and project copies.",
1590
1655
  events: {
1656
+ ...THROTTLE_LOG_EVENTS,
1591
1657
  "actions.resume-failed": "Approved actions could not be resumed; a later pass retries.",
1592
1658
  "project-copy.notify-failed": "The coordinator could not be told a project copy finished.",
1659
+ "mail.return-deferred": "The leaf refused returned mail; it remains queued for retry.",
1660
+ "notices.take-back-failed": "A notice for this node's coordinator stayed in the outbox.",
1661
+ "notice.collected-retired": "A detached controller owned a notice with ambiguous delivery; retired without redelivery.",
1593
1662
  "mail.delivery-deferred": "Leaf mail could not reach a coordinator yet.",
1594
1663
  "command.post-step-failed": "A step after a routed command failed.",
1595
1664
  "seed-files.incomplete": "Seed files for a leaf environment were not all copied.",
@@ -2105,6 +2174,7 @@ var WEB_SYNC_LOG_AREAS = defineLogAreas({
2105
2174
  "web.read-coordinator": {
2106
2175
  description: "The renderer's coalesced, bounded backend reads.",
2107
2176
  events: {
2177
+ "poll.read-failed": "A coordinated poll's read failed; it stays on its interval.",
2108
2178
  "listener.threw": "A read state listener threw.",
2109
2179
  "read.settle-failed": "Applying a finished read's result threw."
2110
2180
  }
@@ -2114,6 +2184,7 @@ var WEB_SYNC_LOG_AREAS = defineLogAreas({
2114
2184
  events: {
2115
2185
  "events.disconnected": "The main event stream dropped; it reconnects and replays.",
2116
2186
  "terminal-stream.disconnected": "A terminal event stream dropped; it reconnects.",
2187
+ "relayed-stream.disconnected": "The relayed node event stream dropped; it reconnects.",
2117
2188
  "connection-listener.failed": "A main stream connection state listener threw.",
2118
2189
  "event-listener.failed": "A listener for a gateway event threw.",
2119
2190
  "stream-listener.failed": "A listener for the stream-connected notice threw."
@@ -3244,9 +3315,76 @@ function createBridgeDiagnostics(bridge, state, metrics) {
3244
3315
  }
3245
3316
  var bufferedFlushes = new Set;
3246
3317
 
3318
+ // ../protocol/src/node/bridge-credential.ts
3319
+ import { createHash as createHash2, randomBytes, timingSafeEqual } from "node:crypto";
3320
+ import { createRequire } from "node:module";
3321
+ var BRIDGE_TOKEN_PREFIX = "okb_";
3322
+ var PR_SET_DUMPABLE = 4;
3323
+ var VERIFIER_PATTERN = /^[0-9a-f]{64}$/;
3324
+ var log3 = createLogger("bridge.lifecycle");
3325
+ function mintBridgeToken() {
3326
+ return `${BRIDGE_TOKEN_PREFIX}${randomBytes(32).toString("base64url")}`;
3327
+ }
3328
+ function bridgeTokenVerifier(token) {
3329
+ return createHash2("sha256").update(token).digest("hex");
3330
+ }
3331
+ function bridgeTokenVerifierEnv(tokenEnv) {
3332
+ return `${tokenEnv}_SHA256`;
3333
+ }
3334
+ function credentialFromVerifier(verifier, plainToken) {
3335
+ const expected = Buffer.from(verifier, "hex");
3336
+ return {
3337
+ plainToken,
3338
+ matches(candidate) {
3339
+ if (!candidate)
3340
+ return false;
3341
+ return timingSafeEqual(expected, createHash2("sha256").update(candidate).digest());
3342
+ }
3343
+ };
3344
+ }
3345
+ function bridgeCredentialFromToken(token) {
3346
+ return credentialFromVerifier(bridgeTokenVerifier(token), token);
3347
+ }
3348
+ function markProcessNonDumpable(loadFfi = () => createRequire(import.meta.url)("bun:ffi")) {
3349
+ if (process.platform !== "linux" || !process.versions.bun)
3350
+ return false;
3351
+ try {
3352
+ const { dlopen, FFIType } = loadFfi();
3353
+ const libc = dlopen("libc.so.6", {
3354
+ prctl: {
3355
+ args: [FFIType.i32, FFIType.u64, FFIType.u64, FFIType.u64, FFIType.u64],
3356
+ returns: FFIType.i32
3357
+ }
3358
+ });
3359
+ try {
3360
+ if (libc.symbols.prctl(PR_SET_DUMPABLE, 0n, 0n, 0n, 0n) === 0)
3361
+ return true;
3362
+ } finally {
3363
+ libc.close();
3364
+ }
3365
+ log3.warn("credential.not-hardened", { reason: "prctl-refused" });
3366
+ } catch {
3367
+ log3.warn("credential.not-hardened", { reason: "ffi-unavailable" });
3368
+ }
3369
+ return false;
3370
+ }
3371
+ function loadBridgeCredential(tokenEnv, options = {}) {
3372
+ const env = options.env ?? process.env;
3373
+ const verifierEnv = bridgeTokenVerifierEnv(tokenEnv);
3374
+ const verifier = env[verifierEnv]?.trim();
3375
+ const token = env[tokenEnv]?.trim();
3376
+ delete env[verifierEnv];
3377
+ delete env[tokenEnv];
3378
+ if (verifier) {
3379
+ (options.harden ?? markProcessNonDumpable)();
3380
+ return VERIFIER_PATTERN.test(verifier) ? credentialFromVerifier(verifier, undefined) : bridgeCredentialFromToken(mintBridgeToken());
3381
+ }
3382
+ return bridgeCredentialFromToken(token || mintBridgeToken());
3383
+ }
3384
+
3247
3385
  // ../../bridges/acp-bridge/src/acp-context.ts
3248
3386
  import { spawn as spawn2 } from "node:child_process";
3249
- import { createHmac, randomBytes as randomBytes2, timingSafeEqual } from "node:crypto";
3387
+ import { createHmac, randomBytes as randomBytes3, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
3250
3388
  import { resolve as resolve3 } from "node:path";
3251
3389
 
3252
3390
  // ../protocol/src/capacity-retry.ts
@@ -11661,6 +11799,7 @@ var PROJECTION_FIELD_SET = new Set([
11661
11799
  "asyncQuestionResponses",
11662
11800
  "contextUsage",
11663
11801
  "goal",
11802
+ "suborks",
11664
11803
  "rateLimits",
11665
11804
  "runtime",
11666
11805
  "runtimeHealthAuthoritative",
@@ -11686,6 +11825,7 @@ var OPTIONAL_PROJECTION_FIELD_SET = new Set([
11686
11825
  "asyncQuestionResponses",
11687
11826
  "contextUsage",
11688
11827
  "goal",
11828
+ "suborks",
11689
11829
  "rateLimits",
11690
11830
  "runtime",
11691
11831
  "runtimeHealthAuthoritative",
@@ -12069,7 +12209,7 @@ import { spawn } from "node:child_process";
12069
12209
  import { constants } from "node:fs";
12070
12210
  import { lstat, open as open2, realpath } from "node:fs/promises";
12071
12211
  import { dirname, isAbsolute, join as join2, relative, resolve, sep } from "node:path";
12072
- import { randomBytes } from "node:crypto";
12212
+ import { randomBytes as randomBytes2 } from "node:crypto";
12073
12213
 
12074
12214
  // ../protocol/src/coordinator-web-research.ts
12075
12215
  var DEFAULT_COORDINATOR_RESEARCH_MCP_SERVERS = Object.freeze([{ name: "context7", url: "https://mcp.context7.com/mcp" }]);
@@ -12485,7 +12625,7 @@ class AcpClientMethods {
12485
12625
  }
12486
12626
  const cwd = await secureTerminalCwd(request.cwd, this.workspaceRoot);
12487
12627
  const outputLimit = Math.min(MAX_TERMINAL_OUTPUT_BYTES, Number.isSafeInteger(request.outputByteLimit) && (request.outputByteLimit ?? 0) > 0 ? request.outputByteLimit : DEFAULT_TERMINAL_OUTPUT_BYTES);
12488
- const terminalId = randomBytes(16).toString("hex");
12628
+ const terminalId = randomBytes2(16).toString("hex");
12489
12629
  const child = this.spawnTerminalImpl(request.command, request.args ?? [], {
12490
12630
  cwd,
12491
12631
  env: withoutBridgeControlEnvironment({
@@ -12883,7 +13023,7 @@ function grokQuestionTimeoutFromEnv(env) {
12883
13023
  }
12884
13024
 
12885
13025
  // ../../bridges/acp-bridge/src/acp-mcp-inventory.ts
12886
- import { createHash as createHash2 } from "node:crypto";
13026
+ import { createHash as createHash3 } from "node:crypto";
12887
13027
  import { readFile, stat } from "node:fs/promises";
12888
13028
  import { homedir as homedir2 } from "node:os";
12889
13029
  import { join as join4, resolve as resolve2 } from "node:path";
@@ -12974,7 +13114,7 @@ function grokMcpConfigFiles(options = { cwd: process.cwd() }) {
12974
13114
  }
12975
13115
  async function fileDigest(file) {
12976
13116
  try {
12977
- return `sha256:${createHash2("sha256").update(await readFile(file)).digest("base64url")}`;
13117
+ return `sha256:${createHash3("sha256").update(await readFile(file)).digest("base64url")}`;
12978
13118
  } catch {
12979
13119
  return "absent";
12980
13120
  }
@@ -12982,7 +13122,7 @@ async function fileDigest(file) {
12982
13122
  async function grokMcpConfigFingerprint(files) {
12983
13123
  const [user, project] = await Promise.all([fileDigest(files.user), fileDigest(files.project)]);
12984
13124
  return {
12985
- fingerprint: createHash2("sha256").update(`user=${user}\x00project=${project}`).digest("base64url"),
13125
+ fingerprint: createHash3("sha256").update(`user=${user}\x00project=${project}`).digest("base64url"),
12986
13126
  sources: { user, project }
12987
13127
  };
12988
13128
  }
@@ -13041,26 +13181,20 @@ function grokMcpConfigStatus(loaded, current) {
13041
13181
  }
13042
13182
 
13043
13183
  // ../../bridges/acp-bridge/src/acp-context.ts
13044
- var log3 = createLogger("bridge.acp");
13184
+ var log4 = createLogger("bridge.acp");
13045
13185
  var CURSOR_TODO_STATUSES = ["pending", "in_progress", "completed", "cancelled"];
13046
13186
  var providerConfig = loadAcpProviderConfig();
13047
13187
  var provider = providerConfig.id;
13048
13188
  var port = parsePort(process.env.PORT);
13049
13189
  var hostname = process.env.HOSTNAME?.trim() || "127.0.0.1";
13050
13190
  var workingDirectory = resolve3(process.env.CWD?.trim() || process.cwd());
13051
- var authToken = process.env.ACP_BRIDGE_TOKEN?.trim() || randomBytes2(32).toString("base64url");
13052
- delete process.env.ACP_BRIDGE_TOKEN;
13191
+ var bridgeCredential = loadBridgeCredential("ACP_BRIDGE_TOKEN");
13192
+ var authToken = bridgeCredential.plainToken ?? "";
13193
+ var externalSessionKey = randomBytes3(32);
13053
13194
  var executable = providerConfig.executable;
13054
13195
  var stateDirectory = process.env.ACP_STATE_DIR?.trim();
13055
13196
  var stateFile = stateDirectory ? resolve3(stateDirectory, "state.json") : null;
13056
13197
  var sessions = new Map;
13057
- var cursorDiscoveryRevision = 0;
13058
- function currentCursorDiscoveryRevision() {
13059
- return cursorDiscoveryRevision;
13060
- }
13061
- function bumpCursorDiscoveryRevision() {
13062
- cursorDiscoveryRevision = cursorDiscoveryRevision >= Number.MAX_SAFE_INTEGER ? 0 : cursorDiscoveryRevision + 1;
13063
- }
13064
13198
  var acpToolSourceStates = new WeakMap;
13065
13199
  var saturatedText = new WeakSet;
13066
13200
  var trimmedToolCalls = new WeakMap;
@@ -13174,18 +13308,6 @@ var CLOSE_ATTACH_WAIT_MS = parseDuration(process.env.ACP_CLOSE_ATTACH_WAIT_MS, 5
13174
13308
  var CLOSE_CANCEL_WAIT_MS = parseDuration(process.env.ACP_CLOSE_CANCEL_WAIT_MS, 2000);
13175
13309
  var CLOSE_SESSION_WAIT_MS = parseDuration(process.env.ACP_CLOSE_SESSION_WAIT_MS, 2000);
13176
13310
  var SESSION_CLOSING_ERROR = "Session is closing";
13177
- var CURSOR_BACKGROUND_WAIT_MS = parseDuration(process.env.ACP_CURSOR_BACKGROUND_WAIT_MS, 30 * 60000);
13178
- var MAX_CURSOR_BACKGROUND_CONTINUATIONS = 4;
13179
- var MAX_CURSOR_CHILD_RESULT_BYTES = 64 * 1024;
13180
- var MAX_CURSOR_CHILD_PARTS = 64;
13181
- var MAX_CURSOR_TRANSCRIPT_HYDRATE_CHILDREN = 8;
13182
- var MAX_CURSOR_SETTLED_CLAIMS = 64;
13183
- var CURSOR_JSONL_SOURCE_PREFIX = "cursor-jsonl:";
13184
- var MAX_CURSOR_DISCOVERY_ENTRIES = 4096;
13185
- var CURSOR_CHILD_DISCOVERY_SKEW_MS = 5000;
13186
- var MAX_CURSOR_CHILD_PROMPT_BYTES = 4 * 1024;
13187
- var MAX_CURSOR_CHILD_PROMPT_RECORDS = 8;
13188
- var CURSOR_BACKGROUND_CONTINUATION_PREFIX = "Background subagent finished.";
13189
13311
  var POLICY_DENIAL_MAX_CONTINUATIONS = 8;
13190
13312
  var RETRIABLE_PROVIDER_RETRY_POLICY = {
13191
13313
  ...DEFAULT_CAPACITY_RETRY_POLICY,
@@ -13280,7 +13402,7 @@ class AcpProcess {
13280
13402
  }
13281
13403
  this.child.once("error", (error) => this.#close(error));
13282
13404
  this.child.once("exit", (code, signal) => {
13283
- log3.warn("agent.exited", {
13405
+ log4.warn("agent.exited", {
13284
13406
  provider,
13285
13407
  pid: this.child.pid ?? null,
13286
13408
  code,
@@ -13527,7 +13649,7 @@ function activeSessionReservations() {
13527
13649
  var EXTERNAL_SESSION_PREFIX = "acp-session:";
13528
13650
  function externalSessionToken(acpSessionId) {
13529
13651
  const encoded = Buffer.from(acpSessionId).toString("base64url");
13530
- const signature = createHmac("sha256", authToken).update(encoded).digest("base64url");
13652
+ const signature = createHmac("sha256", externalSessionKey).update(encoded).digest("base64url");
13531
13653
  return `${EXTERNAL_SESSION_PREFIX}${encoded}.${signature}`;
13532
13654
  }
13533
13655
  function parseExternalSessionToken(value) {
@@ -13541,14 +13663,14 @@ function parseExternalSessionToken(value) {
13541
13663
  const signature = token.slice(separator + 1);
13542
13664
  if (!encoded || encoded.length > 1024 || !signature)
13543
13665
  return null;
13544
- const expected = createHmac("sha256", authToken).update(encoded).digest();
13666
+ const expected = createHmac("sha256", externalSessionKey).update(encoded).digest();
13545
13667
  let supplied;
13546
13668
  try {
13547
13669
  supplied = Buffer.from(signature, "base64url");
13548
13670
  } catch {
13549
13671
  return null;
13550
13672
  }
13551
- if (supplied.length !== expected.length || !timingSafeEqual(supplied, expected))
13673
+ if (supplied.length !== expected.length || !timingSafeEqual2(supplied, expected))
13552
13674
  return null;
13553
13675
  let decoded;
13554
13676
  try {
@@ -13828,6 +13950,24 @@ function assertExecutionPolicyNotWidened(current, next) {
13828
13950
  throw new PolicyWideningRefusedError(widened);
13829
13951
  }
13830
13952
 
13953
+ // ../protocol/src/suborks.ts
13954
+ var SUBORK_TOOL_NAME = "ask_agents";
13955
+ var AGENT_SUBORK_TOOL_NAMES = Object.freeze([SUBORK_TOOL_NAME]);
13956
+ var SUBORK_LIMITS = Object.freeze({
13957
+ targetsPerCall: 4,
13958
+ activePerSession: 8,
13959
+ totalPerSession: 64,
13960
+ retainedBatchesPerSession: 16,
13961
+ promptMaxBytes: 64 * 1024,
13962
+ nameMaxChars: 80,
13963
+ targetTextMaxChars: 200,
13964
+ storedAnswerMaxBytes: 64 * 1024,
13965
+ deliveredAnswersMaxBytes: AGENT_MAIL_MAX_BODY_BYTES - 2 * 1024,
13966
+ lineMaxChars: 240,
13967
+ errorMaxChars: 1024,
13968
+ deadlineMs: 45 * 60000
13969
+ });
13970
+
13831
13971
  // ../protocol/src/web-annotations-errors.ts
13832
13972
  var WEB_ANNOTATION_ERROR_CODES = Object.freeze([
13833
13973
  "conflict",
@@ -14367,7 +14507,7 @@ function encodedStringBytes(value, previous) {
14367
14507
  // ../../bridges/acp-bridge/src/acp-persist-writer.ts
14368
14508
  import { promises as fs2 } from "node:fs";
14369
14509
  import { dirname as dirname2 } from "node:path";
14370
- import { randomBytes as randomBytes3 } from "node:crypto";
14510
+ import { randomBytes as randomBytes4 } from "node:crypto";
14371
14511
 
14372
14512
  // ../protocol/src/node/transcript-window.ts
14373
14513
  import { Buffer as Buffer4 } from "node:buffer";
@@ -14457,7 +14597,7 @@ function boundTranscriptResponse(messages, maximumBytes, options = {}) {
14457
14597
  }
14458
14598
 
14459
14599
  // ../../bridges/acp-bridge/src/acp-persist-writer.ts
14460
- var log4 = createLogger("bridge.acp");
14600
+ var log5 = createLogger("bridge.acp");
14461
14601
  function boundPersistedSnapshot(snapshot) {
14462
14602
  const bounded = {
14463
14603
  ...snapshot,
@@ -14612,10 +14752,7 @@ function persistedSnapshot() {
14612
14752
  ...state.commandsRevision === undefined ? {} : { commandsRevision: state.commandsRevision },
14613
14753
  ...state.commandsTruncated ? { commandsTruncated: true } : {},
14614
14754
  ...state.title ? { title: state.title } : {},
14615
- ...state.subagentLimitExceeded ? { subagentLimitExceeded: true } : {},
14616
- ...state.settledCursorAgentIds.size > 0 ? {
14617
- settledCursorAgentIds: Array.from(state.settledCursorAgentIds).slice(-MAX_CURSOR_SETTLED_CLAIMS)
14618
- } : {}
14755
+ ...state.subagentLimitExceeded ? { subagentLimitExceeded: true } : {}
14619
14756
  }))
14620
14757
  };
14621
14758
  return boundPersistedSnapshot(snapshot);
@@ -14654,7 +14791,7 @@ function schedulePersist() {
14654
14791
  await writePersistedState();
14655
14792
  });
14656
14793
  setPersistenceTail(operation.catch((error) => {
14657
- log4.warn("state.persist-failed", { error: formatLogError(error, { stack: false }) });
14794
+ log5.warn("state.persist-failed", { error: formatLogError(error, { stack: false }) });
14658
14795
  }));
14659
14796
  }
14660
14797
  function persistState() {
@@ -14674,16 +14811,16 @@ async function writePersistedState() {
14674
14811
  throw new Error("ACP persisted state exceeds its byte limit");
14675
14812
  }
14676
14813
  await fs2.mkdir(dirname2(file), { recursive: true, mode: 448 });
14677
- const temporary = `${file}.${process.pid}.${randomBytes3(6).toString("hex")}.tmp`;
14814
+ const temporary = `${file}.${process.pid}.${randomBytes4(6).toString("hex")}.tmp`;
14678
14815
  await fs2.writeFile(temporary, payload, { mode: 384 });
14679
14816
  await fs2.rename(temporary, file);
14680
14817
  }
14681
14818
 
14682
14819
  // ../../bridges/acp-bridge/src/acp-rows.ts
14683
- import { randomBytes as randomBytes4 } from "node:crypto";
14820
+ import { randomBytes as randomBytes5 } from "node:crypto";
14684
14821
 
14685
14822
  // ../protocol/src/node/revised-rows.ts
14686
- import { createHash as createHash3 } from "node:crypto";
14823
+ import { createHash as createHash4 } from "node:crypto";
14687
14824
  var RECENTLY_REVISED_ROWS_MAX = 128;
14688
14825
 
14689
14826
  class RecentlyRevisedRows {
@@ -14721,7 +14858,7 @@ class RecentlyRevisedRows {
14721
14858
  function revisedRowsReconciliationToken(overflowVersion, omitted) {
14722
14859
  if (overflowVersion === 0 && omitted.length === 0)
14723
14860
  return;
14724
- const digest = createHash3("sha256").update(String(overflowVersion));
14861
+ const digest = createHash4("sha256").update(String(overflowVersion));
14725
14862
  for (const row of omitted)
14726
14863
  digest.update(JSON.stringify(row) ?? "null");
14727
14864
  return digest.digest("hex");
@@ -14770,7 +14907,7 @@ function currentAssistantMessage(state) {
14770
14907
  if (!message || message.role !== "assistant" || rowIsFull(message) || state.status !== "running" && state.historyReplay !== "hydrate") {
14771
14908
  const modelId = boundedModelId(state.sessionConfig.composer.selectedModelId);
14772
14909
  message = {
14773
- id: randomBytes4(12).toString("hex"),
14910
+ id: randomBytes5(12).toString("hex"),
14774
14911
  role: "assistant",
14775
14912
  content: "",
14776
14913
  parts: [],
@@ -15706,44 +15843,12 @@ function ensureAcpToolSource(part) {
15706
15843
  acpToolSourceStates.set(part, source);
15707
15844
  return source;
15708
15845
  }
15709
- function recordCursorTaskPrompt(part, prompt) {
15710
- const bounded = truncateUtf8(prompt.trim(), MAX_CURSOR_CHILD_PROMPT_BYTES);
15711
- if (!bounded)
15712
- return false;
15713
- const source = ensureAcpToolSource(part);
15714
- if (source.cursorTask?.prompt)
15715
- return false;
15716
- source.cursorTask = { ...source.cursorTask, prompt: bounded };
15717
- renderAcpToolSource(part, source);
15718
- return true;
15719
- }
15720
- function toolPartAgentId(part) {
15721
- if (typeof part.toolArgs?.agentId === "string") {
15722
- return truncateUtf8(part.toolArgs.agentId.trim(), MAX_TOOL_ID_BYTES);
15723
- }
15724
- if (typeof part.toolArgs?.agent_id === "string") {
15725
- return truncateUtf8(part.toolArgs.agent_id.trim(), MAX_TOOL_ID_BYTES);
15726
- }
15727
- const lifecycle = toolCallLifecycle(part.toolOutput);
15728
- if (typeof lifecycle?.agentId === "string") {
15729
- return truncateUtf8(lifecycle.agentId.trim(), MAX_TOOL_ID_BYTES);
15730
- }
15731
- if (typeof lifecycle?.agent_id === "string") {
15732
- return truncateUtf8(lifecycle.agent_id.trim(), MAX_TOOL_ID_BYTES);
15733
- }
15734
- return;
15735
- }
15736
15846
  function syncActiveSubagentTool(state, part) {
15737
15847
  if (part.agentState === "active") {
15738
- const agentId = toolPartAgentId(part);
15739
- const reportedPrompt = part.cursorTaskPromptReported === true && typeof part.toolArgs?.prompt === "string" ? truncateUtf8(part.toolArgs.prompt.trim(), MAX_CURSOR_CHILD_PROMPT_BYTES) : undefined;
15740
15848
  const activated = activateSubagent(state, part.toolUseId, {
15741
15849
  ...typeof part.toolArgs?.description === "string" ? { description: truncateUtf8(part.toolArgs.description.trim(), MAX_TOOL_TITLE_BYTES) } : {},
15742
15850
  ...typeof part.toolArgs?.subagent_type === "string" ? { subagentType: truncateUtf8(part.toolArgs.subagent_type.trim(), MAX_TOOL_NAME_BYTES) } : {},
15743
- ...part.toolState ? { toolState: part.toolState } : {},
15744
- ...reportedPrompt ? { reportedPrompt } : {},
15745
- ...agentId ? { agentId, agentIdDiscovered: false } : {},
15746
- ...agentId ? { agentIdSettlementSafe: false } : {}
15851
+ ...part.toolState ? { toolState: part.toolState } : {}
15747
15852
  });
15748
15853
  if (!activated) {
15749
15854
  part.agentState = "failed";
@@ -15780,32 +15885,25 @@ function activateSubagent(state, toolUseId, descriptor) {
15780
15885
  state.child?.notify("session/cancel", { sessionId: state.acpSessionId });
15781
15886
  return false;
15782
15887
  }
15783
- const wasActive = state.activeSubagentToolIds.has(toolUseId);
15784
15888
  const previous = state.activeSubagentDescriptors.get(toolUseId);
15785
15889
  const next = {
15786
15890
  ...previous,
15787
15891
  ...descriptor,
15788
- agentId: descriptor.agentId ?? previous?.agentId,
15789
15892
  description: descriptor.description ?? previous?.description,
15790
15893
  subagentType: descriptor.subagentType ?? previous?.subagentType,
15791
15894
  toolState: descriptor.toolState ?? previous?.toolState
15792
15895
  };
15793
15896
  state.activeSubagentToolIds.add(toolUseId);
15794
15897
  state.activeSubagentDescriptors.set(toolUseId, next);
15795
- if (!wasActive || previous?.agentId !== next.agentId || previous?.agentIdDiscovered !== next.agentIdDiscovered || previous?.agentIdSettlementSafe !== next.agentIdSettlementSafe || previous?.reportedPrompt !== next.reportedPrompt) {
15796
- bumpCursorDiscoveryRevision();
15797
- }
15798
15898
  return true;
15799
15899
  }
15800
15900
  function settleActiveSubagent(state, toolUseId) {
15801
- const activeDeleted = state.activeSubagentToolIds.delete(toolUseId);
15802
- const descriptorDeleted = state.activeSubagentDescriptors.delete(toolUseId);
15901
+ state.activeSubagentToolIds.delete(toolUseId);
15902
+ state.activeSubagentDescriptors.delete(toolUseId);
15803
15903
  for (const [subagentId, mappedToolUseId] of state.subagentToolIds) {
15804
15904
  if (mappedToolUseId === toolUseId)
15805
15905
  state.subagentToolIds.delete(subagentId);
15806
15906
  }
15807
- if (activeDeleted || descriptorDeleted)
15808
- bumpCursorDiscoveryRevision();
15809
15907
  }
15810
15908
  var MAX_CURSOR_TASK_PROMPT_BYTES = 64 * 1024;
15811
15909
  var TASK_LAUNCH_ARG_KEYS = [
@@ -16287,8 +16385,6 @@ function applyCursorTask(state, params) {
16287
16385
  }
16288
16386
  }
16289
16387
  renderAcpToolSource(part, source);
16290
- if (prompt)
16291
- part.cursorTaskPromptReported = true;
16292
16388
  if (part.agentState === "finished" || part.agentState === "failed") {
16293
16389
  stampSubagentRuntimeDuration(part);
16294
16390
  }
@@ -16296,7 +16392,6 @@ function applyCursorTask(state, params) {
16296
16392
  commitToolPartMutation(state, part, source);
16297
16393
  }
16298
16394
  function failAllActiveSubagents(state) {
16299
- const hadActiveSubagents = state.activeSubagentToolIds.size > 0 || state.activeSubagentDescriptors.size > 0;
16300
16395
  for (const message of state.messages) {
16301
16396
  for (const part of message.parts) {
16302
16397
  if (part.type !== "tool-invocation" || !state.activeSubagentToolIds.has(part.toolUseId))
@@ -16312,8 +16407,6 @@ function failAllActiveSubagents(state) {
16312
16407
  state.activeSubagentToolIds.clear();
16313
16408
  state.activeSubagentDescriptors.clear();
16314
16409
  state.subagentToolIds.clear();
16315
- if (hadActiveSubagents)
16316
- bumpCursorDiscoveryRevision();
16317
16410
  }
16318
16411
  function settleEvictedSubagentFromToolUpdate(state, toolUseId, update) {
16319
16412
  const toolState = mapAcpToolState(update.status);
@@ -16457,6 +16550,7 @@ var WORKFLOW_RESULT_KINDS = [
16457
16550
  "fix-result",
16458
16551
  "verification-result",
16459
16552
  "pr-result",
16553
+ "subork-answer",
16460
16554
  "graph-output",
16461
16555
  "graph-template"
16462
16556
  ];
@@ -16472,7 +16566,8 @@ var WORKFLOW_RESULT_TOOL_NAMES = {
16472
16566
  "verification-result": "submit_verification_result",
16473
16567
  "pr-result": "submit_pr_result",
16474
16568
  "graph-output": "submit_graph_output",
16475
- "graph-template": "submit_graph_template"
16569
+ "graph-template": "submit_graph_template",
16570
+ "subork-answer": "submit_subork_answer"
16476
16571
  };
16477
16572
  var WORKFLOW_RESULT_VALIDATION_TOOL_NAME = "validate_workflow_result";
16478
16573
  var REPORT_FINDING_TOOL_NAME = "report_finding";
@@ -16647,7 +16742,7 @@ var DEFAULT_WORKFLOW_RESULT_TOOLS_SETTINGS = {
16647
16742
  };
16648
16743
 
16649
16744
  // ../../bridges/acp-bridge/src/acp-session.ts
16650
- import { randomBytes as randomBytes7 } from "node:crypto";
16745
+ import { randomBytes as randomBytes8 } from "node:crypto";
16651
16746
  import { resolve as resolve7 } from "node:path";
16652
16747
 
16653
16748
  // ../../bridges/acp-bridge/src/session-config.ts
@@ -17875,18 +17970,18 @@ async function readJournal(path, maxEntries) {
17875
17970
  }
17876
17971
 
17877
17972
  // ../../bridges/acp-bridge/src/grok-interjection.ts
17878
- import { createHash as createHash4, randomBytes as randomBytes5 } from "node:crypto";
17973
+ import { createHash as createHash5, randomBytes as randomBytes6 } from "node:crypto";
17879
17974
  var GROK_INTERJECT_METHOD = "_x.ai/interject";
17880
17975
  var GROK_INTERJECTION_NOTIFICATION = "_x.ai/session/interjection";
17881
17976
  var MAX_GROK_INTERJECTION_JOURNAL = 256;
17882
17977
  var MAX_GROK_INTERJECTION_ID_BYTES = 512;
17883
17978
  var MAX_GROK_INTERJECTION_TEXT_BYTES = 64 * 1024;
17884
- var grokBridgeGeneration = randomBytes5(12).toString("base64url");
17979
+ var grokBridgeGeneration = randomBytes6(12).toString("base64url");
17885
17980
  function grokRunId(promptSequence) {
17886
17981
  return `grok:${grokBridgeGeneration}:${promptSequence}`;
17887
17982
  }
17888
17983
  function grokInterjectionDigest(text) {
17889
- return createHash4("sha256").update(text).digest("hex");
17984
+ return createHash5("sha256").update(text).digest("hex");
17890
17985
  }
17891
17986
  function parseGrokInterjectResult(value) {
17892
17987
  if (!isObject6(value) || value.status !== "queued")
@@ -17978,7 +18073,7 @@ function applyGrokInterjectionBroadcast(journal, acpSessionId, method, params, n
17978
18073
  return broadcast;
17979
18074
  }
17980
18075
  async function probeGrokInterjectionExtension(requester) {
17981
- const probeId = `orkestrator-qualification-${randomBytes5(12).toString("base64url")}`;
18076
+ const probeId = `orkestrator-qualification-${randomBytes6(12).toString("base64url")}`;
17982
18077
  try {
17983
18078
  await requestGrokInterjection(requester, {
17984
18079
  sessionId: probeId,
@@ -18014,7 +18109,7 @@ function isObject6(value) {
18014
18109
  }
18015
18110
 
18016
18111
  // ../../bridges/acp-bridge/src/acp-commands.ts
18017
- import { randomBytes as randomBytes6 } from "node:crypto";
18112
+ import { randomBytes as randomBytes7 } from "node:crypto";
18018
18113
 
18019
18114
  // ../protocol/src/agent-command-catalogue.ts
18020
18115
  var NATIVE_AGENT_COMMAND_CATALOGUE_VERSION = 1;
@@ -18145,7 +18240,7 @@ function commandUnavailableResponse(message) {
18145
18240
  }
18146
18241
 
18147
18242
  // ../../bridges/acp-bridge/src/acp-commands.ts
18148
- var COMMAND_CATALOGUE_GENERATION = `${provider}:${randomBytes6(8).toString("hex")}`;
18243
+ var COMMAND_CATALOGUE_GENERATION = `${provider}:${randomBytes7(8).toString("hex")}`;
18149
18244
  var COMMAND_ROWS_BYTE_BUDGET = COMMAND_CATALOGUE_LIMITS.maxWireBytes - 16 * 1024;
18150
18245
  var PROVIDER_LABEL = `${provider.charAt(0).toUpperCase()}${provider.slice(1)}`;
18151
18246
  function commandId(name) {
@@ -18317,7 +18412,7 @@ function compactCommandSelection(state) {
18317
18412
  }
18318
18413
 
18319
18414
  // ../../bridges/acp-bridge/src/acp-persistence.ts
18320
- var log5 = createLogger("bridge.acp");
18415
+ var log6 = createLogger("bridge.acp");
18321
18416
  async function listNormalizedModels(signal) {
18322
18417
  const live = mergeComposerCatalog(provider, [
18323
18418
  ...catalogCache ? [catalogCache] : [],
@@ -18365,14 +18460,14 @@ function restoreSessionConfig(candidate) {
18365
18460
  const restored = parsePersistedAcpSessionConfig(provider, candidate.sessionConfig);
18366
18461
  if (restored)
18367
18462
  return restored;
18368
- log5.warn("state.session-config-reset");
18463
+ log6.warn("state.session-config-reset");
18369
18464
  return emptySessionConfig();
18370
18465
  }
18371
18466
  if (candidate.composer !== undefined) {
18372
18467
  const composer = parsePersistedComposerState(provider, candidate.composer);
18373
18468
  if (composer)
18374
18469
  return { ...emptySessionConfig(), composer };
18375
- log5.warn("state.composer-reset");
18470
+ log6.warn("state.composer-reset");
18376
18471
  }
18377
18472
  return emptySessionConfig();
18378
18473
  }
@@ -18453,9 +18548,8 @@ async function restorePersistedState() {
18453
18548
  await loadPersistedState();
18454
18549
  } catch (error) {
18455
18550
  sessions.clear();
18456
- bumpCursorDiscoveryRevision();
18457
18551
  clientSessionKeys.clear();
18458
- log5.warn("state.discarded", { error: formatLogError(error, { stack: false }) });
18552
+ log6.warn("state.discarded", { error: formatLogError(error, { stack: false }) });
18459
18553
  const file = stateFile;
18460
18554
  if (!file)
18461
18555
  return;
@@ -18507,7 +18601,6 @@ async function loadPersistedState() {
18507
18601
  messages,
18508
18602
  activeSubagentToolIds: new Set,
18509
18603
  activeSubagentDescriptors: new Map,
18510
- settledCursorAgentIds: new Set,
18511
18604
  subagentLimitExceeded: candidate.subagentLimitExceeded === true,
18512
18605
  subagentToolIds: new Map,
18513
18606
  cursorTodos: restoreCursorTodosFromMessages(messages),
@@ -18694,7 +18787,6 @@ function normalizeBridgePart(value, index, messageId) {
18694
18787
  ...isObject3(value.toolArgs) ? { toolArgs: boundedToolArguments(value.toolArgs) } : {},
18695
18788
  ...toolState ? { toolState } : {},
18696
18789
  ...agentState ? { agentState } : {},
18697
- ...value.cursorTaskPromptReported === true ? { cursorTaskPromptReported: true } : {},
18698
18790
  ...toolTitle ? { toolTitle } : {},
18699
18791
  ...toolOutput !== undefined ? { toolOutput } : {},
18700
18792
  ...toolError !== undefined ? { toolError } : {},
@@ -18731,10 +18823,178 @@ function isStringTuple(value) {
18731
18823
  return Array.isArray(value) && value.length === 2 && typeof value[0] === "string";
18732
18824
  }
18733
18825
 
18826
+ // ../protocol/src/rich-content-policy.ts
18827
+ var KIB = 1024;
18828
+ var MIB = 1024 * KIB;
18829
+ var CODE_BLOCK_POLICY = {
18830
+ maxHighlightBytes: 32 * KIB,
18831
+ maxHighlightLines: 2000,
18832
+ initialVisualLines: 24
18833
+ };
18834
+ var MERMAID_POLICY = {
18835
+ maxSourceBytes: 32 * KIB,
18836
+ maxEdges: 250,
18837
+ maxSvgBytes: 1 * MIB,
18838
+ maxSvgElements: 5000,
18839
+ renderTimeoutMs: 5000
18840
+ };
18841
+ var CHART_POLICY = {
18842
+ maxPayloadBytes: 256 * KIB,
18843
+ maxSeries: 6,
18844
+ maxBarCategories: 100,
18845
+ maxCartesianPoints: 2000,
18846
+ maxDonutSlices: 24,
18847
+ maxTitleCharacters: 200,
18848
+ maxLabelCharacters: 200,
18849
+ maxDescriptionCharacters: 2000,
18850
+ maxSourceNotes: 8,
18851
+ maxSourceNoteCharacters: 500,
18852
+ maxIdCharacters: 64,
18853
+ maxUnitCharacters: 32,
18854
+ maxAbsoluteValue: 1000000000000000,
18855
+ maxJsonDepth: 16
18856
+ };
18857
+ var WORKFLOW_SNAPSHOT_POLICY = {
18858
+ maxNormalizedBytes: 256 * KIB,
18859
+ maxNodes: 200,
18860
+ maxEdges: 400,
18861
+ maxIdCharacters: 128,
18862
+ maxLabelCharacters: 200,
18863
+ maxDescriptionCharacters: 2000,
18864
+ maxRawStatusCharacters: 100,
18865
+ maxLinksPerNode: 8
18866
+ };
18867
+ var STATIC_HTML_POLICY = {
18868
+ maxSourceBytes: 256 * KIB,
18869
+ maxPreparedBytes: 16 * MIB,
18870
+ maxElements: 5000
18871
+ };
18872
+ var STATIC_PRESENTATION_POLICY = {
18873
+ maxDocumentBytes: STATIC_HTML_POLICY.maxSourceBytes,
18874
+ maxElements: STATIC_HTML_POLICY.maxElements,
18875
+ maxFramesPerWindow: 4,
18876
+ renderTimeoutMs: 15000,
18877
+ maxSizeChangesPerWindow: 16,
18878
+ sizeChangeWindowMs: 5000,
18879
+ maxRefusedMessages: 100,
18880
+ maxSearchTextCharacters: 64 * KIB,
18881
+ searchTextChunkCharacters: 2 * KIB
18882
+ };
18883
+ var INTERACTIVE_HTML_POLICY = {
18884
+ maxAuthoredBytes: 512 * KIB,
18885
+ maxAssets: 32,
18886
+ maxAssetBytesTotal: 10 * MIB,
18887
+ maxDependencies: 4,
18888
+ maxPreparedBytes: 16 * MIB,
18889
+ maxRuntimeElements: 1e4,
18890
+ maxProbeSteps: 20,
18891
+ maxProbeStepMs: 2000,
18892
+ defaultWaitVisibleMs: 1000,
18893
+ maxProbeTextCharacters: 1024,
18894
+ probeTargetPattern: /^[A-Za-z][A-Za-z0-9_-]{0,63}$/
18895
+ };
18896
+ var PREVIEW_CAPTURE_POLICY = {
18897
+ maxPngBytes: 8 * MIB,
18898
+ maxPixels: 12000000,
18899
+ maxDimension: 4096,
18900
+ minDimension: 240,
18901
+ maxCapturesPerReceipt: 3,
18902
+ defaultViewport: { width: 960, height: 640, deviceScaleFactor: 1 }
18903
+ };
18904
+ var PREVIEW_ADMISSION_POLICY = {
18905
+ runningPerEnvironment: 1,
18906
+ runningGlobal: 2,
18907
+ queuedPerEnvironment: 8,
18908
+ queuedGlobal: 16,
18909
+ nonterminalPerConversation: 2,
18910
+ queuedMetadataBytesGlobal: 8 * MIB,
18911
+ queueWaitMs: 15000,
18912
+ workerWallMs: 30000,
18913
+ readinessMs: 5000,
18914
+ operationDeadlineMs: 45000,
18915
+ cleanupGraceMs: 2000,
18916
+ workerMemoryBytes: 1024 * MIB,
18917
+ workerCpus: 2,
18918
+ workerPids: 128
18919
+ };
18920
+ var FRONTEND_RENDER_POLICY = {
18921
+ highlightConcurrency: 2,
18922
+ diagramConcurrency: 1,
18923
+ maxQueuedJobs: 32,
18924
+ maxQueuedSourceBytes: 2 * MIB,
18925
+ maxSettledCacheEntries: 128,
18926
+ maxSettledCacheBytes: 16 * MIB,
18927
+ maxInactiveViewStateEntries: 500,
18928
+ maxActiveViewStateEntries: 200,
18929
+ maxPinnedViewStateEntries: 50,
18930
+ liveExecutableHostsPerWindow: 1,
18931
+ imageDecodeMaxPixels: 40000000,
18932
+ pdfPreviewMaxPages: 100,
18933
+ pdfPreviewMaxBytes: 20 * MIB
18934
+ };
18935
+ var PDF_POLICY = {
18936
+ maxPages: 100,
18937
+ maxBytes: 20 * MIB,
18938
+ thumbnailMaxDimension: 1024,
18939
+ thumbnailMaxPngBytes: 4 * MIB,
18940
+ imageDecodeMaxPixels: 40000000,
18941
+ printMarginMm: 10,
18942
+ previewCacheEntries: 32,
18943
+ previewCacheBytes: 16 * MIB
18944
+ };
18945
+ var DIAGNOSTIC_POLICY = {
18946
+ maxPersistedEntries: 50,
18947
+ maxEntryBytes: 2 * KIB,
18948
+ maxPersistedBytes: 32 * KIB,
18949
+ maxToolFieldErrors: 20,
18950
+ maxToolDiagnosticBytes: 8 * KIB
18951
+ };
18952
+ var ARTIFACT_TOOL_POLICY = {
18953
+ maxResultBytes: 16 * KIB,
18954
+ maxSourceSliceBytes: 8 * KIB,
18955
+ maxTitleCharacters: 120,
18956
+ maxSummaryCharacters: 400,
18957
+ maxRequestKeyCharacters: 128,
18958
+ maxRepairRevisions: 2,
18959
+ maxTransientRetries: 2,
18960
+ maxUnpublishedArtifactsPerConversation: 100,
18961
+ maxRevisionsPerArtifact: 100,
18962
+ assetStoreBytesPerEnvironment: 1024 * MIB,
18963
+ scopeCapabilityTtlMs: 24 * 60 * 60 * 1000
18964
+ };
18965
+ var ARTIFACT_RETENTION_POLICY = {
18966
+ cleanupIntervalMs: 60 * 60 * 1000,
18967
+ abandonedStagingMs: 60 * 60 * 1000,
18968
+ unpublishedDraftMs: 7 * 24 * 60 * 60 * 1000,
18969
+ unreferencedPreviewAssetMs: 24 * 60 * 60 * 1000
18970
+ };
18971
+ var FRAME_CHANNEL_POLICY = {
18972
+ maxMessageBytes: 8 * KIB,
18973
+ messagesPerSecond: 20,
18974
+ burst: 40,
18975
+ sizeUpdatesPerSecond: 4,
18976
+ minInlineHeight: 120,
18977
+ maxInlineHeight: 1600,
18978
+ maxLinkCharacters: 2048,
18979
+ maxLinkLabelCharacters: 200
18980
+ };
18981
+
18734
18982
  // ../protocol/src/agent-system-instructions.ts
18735
- 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.";
18983
+ var AGENT_IMAGE_PREVIEW_INSTRUCTION = "Orkestrator renders Markdown images inline in the transcript. When you show the user an image in your reply (a photograph, screenshot, rendered preview, or a requested image file) 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.";
18736
18984
  var AGENT_DOCUMENT_INSTRUCTION = "When the user asks for a document (a report, design doc, plan, analysis, guide, or other writing to keep), prefer writing it as a Markdown file in a `docs/` folder at the root of the working directory, and tell the user the file's path. Project instructions (such as AGENTS.md or CLAUDE.md), local skills, and the user's own request take priority over this default when they say where or how to write documents.";
18985
+ var AGENT_CHART_SPEC_SHAPES = "bar adds xAxis:{kind:'category',label}, yAxis:{label,unit?}, categories:[{id,label}], series:[{id,label,points:[{categoryId,value|null}]}] (one point per category); " + "line/area/scatter add xAxis:{kind:'number'|'utc-time',label,unit?}, yAxis:{label,unit?}, series:[{id,label,points:[{x,y|null}]}]; " + "donut adds valueLabel, unit?, slices:[{id,label,value}]";
18986
+ var AGENT_CHART_FENCE_EXAMPLE = '{"schemaVersion":1,"kind":"bar","title":"Passing tests","description":"Passing tests per suite.","xAxis":{"kind":"category","label":"Suite"},"yAxis":{"label":"Tests"},"categories":[{"id":"unit","label":"Unit"},{"id":"browser","label":"Browser"}],"series":[{"id":"passed","label":"Passed","points":[{"categoryId":"unit","value":40},{"categoryId":"browser","value":8}]}]}';
18987
+ var AGENT_VISUAL_OUTPUT_INSTRUCTION = [
18988
+ "Orkestrator displays rich visuals directly in the conversation; choose one when it helps answer the question.",
18989
+ `Flows, architecture, sequences and relationships: a \`mermaid\` code fence. Standard bar, line, area, scatter and donut charts: a \`chart\` code fence holding one ChartSpecV1 JSON object with schemaVersion 1, kind, title and description; ${AGENT_CHART_SPEC_SHAPES}. For example: ${AGENT_CHART_FENCE_EXAMPLE}.`,
18990
+ "When this session has the Orkestrator artifact tools, use them for durable visuals: create_artifact, preview_artifact, get_artifact_operation to inspect the diagnostics and capture, then publish_artifact, and respect their repair limits.",
18991
+ `A custom report, timeline or layout combining text and graphics is an html-static artifact: self-contained HTML, CSS and inline SVG, with no scripts or network resources. Its verified document is displayed in the transcript as real, selectable content, so keep it within ${STATIC_PRESENTATION_POLICY.maxDocumentBytes / 1024} KiB and ${STATIC_PRESENTATION_POLICY.maxElements} elements, use fluid widths, let content set the height (no 100vh on the root), and colour it with the --ork-foreground, --ork-muted-foreground, --ork-background, --ork-border, --ork-primary and --ork-chart-1 to --ork-chart-8 CSS variables, which follow the application theme. Always give them a fallback, such as var(--ork-foreground, #18181b), because the preview defines none of them.`,
18992
+ "Behaviour that needs authored JavaScript, such as a calculator or a filterable dashboard, is an html-interactive artifact; it runs when the reader activates it.",
18993
+ "Use ordinary images only for photographs, screenshots and requested image files.",
18994
+ "HTML, SVG and JavaScript code fences are shown as source and a file path alone publishes nothing: a visual is in the conversation only once publish_artifact succeeds. If verification is unavailable, say so and use a supported form such as a Mermaid or chart fence."
18995
+ ].join(" ");
18737
18996
  var GENERAL_AGENT_INSTRUCTIONS = [
18997
+ AGENT_VISUAL_OUTPUT_INSTRUCTION,
18738
18998
  AGENT_IMAGE_PREVIEW_INSTRUCTION,
18739
18999
  AGENT_DOCUMENT_INSTRUCTION
18740
19000
  ];
@@ -18983,7 +19243,7 @@ class InteractionDeadline {
18983
19243
  }
18984
19244
 
18985
19245
  // ../../bridges/acp-bridge/src/acp-command-changes.ts
18986
- import { createHash as createHash6 } from "node:crypto";
19246
+ import { createHash as createHash7 } from "node:crypto";
18987
19247
  import { resolve as resolve6 } from "node:path";
18988
19248
 
18989
19249
  // ../protocol/src/node/workspace-change-probe.ts
@@ -19985,7 +20245,7 @@ function workspaceObservationReportIssues(value) {
19985
20245
  }
19986
20246
 
19987
20247
  // ../protocol/src/node/change-tracking/evidence-spool.ts
19988
- import { createHash as createHash5, randomUUID as randomUUID2 } from "node:crypto";
20248
+ import { createHash as createHash6, randomUUID as randomUUID2 } from "node:crypto";
19989
20249
  import { readdirSync, readFileSync as readFileSync2 } from "node:fs";
19990
20250
  import { appendFile as appendFile2, mkdir as mkdir2, rename as rename2, rm as rm3, writeFile as writeFile2 } from "node:fs/promises";
19991
20251
  import { join as join7 } from "node:path";
@@ -20001,10 +20261,10 @@ var DEFAULT_EVIDENCE_SPOOL_LIMITS = {
20001
20261
  var ENTRIES_FILE = "entries.jsonl";
20002
20262
  var BODY_DIRECTORY = "bodies";
20003
20263
  function evidenceBodyId(bytes) {
20004
- return `sha256:${createHash5("sha256").update(bytes).digest("hex")}`;
20264
+ return `sha256:${createHash6("sha256").update(bytes).digest("hex")}`;
20005
20265
  }
20006
20266
  function stableEvidenceId(...parts) {
20007
- const hash = createHash5("sha256");
20267
+ const hash = createHash6("sha256");
20008
20268
  for (const part of parts)
20009
20269
  hash.update(`${part ?? ""}\x00`);
20010
20270
  return hash.digest("hex").slice(0, 40);
@@ -20647,7 +20907,7 @@ function canonicalEvidence(evidence) {
20647
20907
  }
20648
20908
 
20649
20909
  // ../../bridges/acp-bridge/src/change-evidence.ts
20650
- var log6 = createLogger("bridge.acp");
20910
+ var log7 = createLogger("bridge.acp");
20651
20911
  var MAX_DIFF_BLOCKS_PER_CALL = 100;
20652
20912
  var MAX_HELD_DIFF_BYTES = 32 * 1024 * 1024;
20653
20913
  var MAX_SEEN_CALL_IDS = 8192;
@@ -20946,7 +21206,7 @@ function recordAcpToolEvidence(state, part, update) {
20946
21206
  if (isTerminal(phase))
20947
21207
  settleRecord(state, part, record);
20948
21208
  } catch (error) {
20949
- log6.warn("evidence.record-failed", {
21209
+ log7.warn("evidence.record-failed", {
20950
21210
  errorClass: error instanceof Error ? error.name : "unknown"
20951
21211
  });
20952
21212
  }
@@ -20990,7 +21250,7 @@ function recordAcpShellObservation(state, toolUseId, observation) {
20990
21250
  ...observation.unavailableReason ? { unavailableReason: observation.unavailableReason } : {}
20991
21251
  });
20992
21252
  } catch (error) {
20993
- log6.warn("evidence.shell-record-failed", {
21253
+ log7.warn("evidence.shell-record-failed", {
20994
21254
  errorClass: error instanceof Error ? error.name : "unknown"
20995
21255
  });
20996
21256
  }
@@ -21022,14 +21282,14 @@ function endAcpTurnEvidence(state, outcome) {
21022
21282
  const writers = state.activeSubagentToolIds.size > 0 || turn.backgroundLaunched ? "may-write" : "quiescent";
21023
21283
  changeEvidenceRecorder().turn({ conversationId: state.id, turnId: turn.turnId }, outcome, writers);
21024
21284
  } catch (error) {
21025
- log6.warn("evidence.turn-record-failed", {
21285
+ log7.warn("evidence.turn-record-failed", {
21026
21286
  errorClass: error instanceof Error ? error.name : "unknown"
21027
21287
  });
21028
21288
  }
21029
21289
  }
21030
21290
 
21031
21291
  // ../../bridges/acp-bridge/src/acp-command-changes.ts
21032
- var log7 = createLogger("bridge.acp");
21292
+ var log8 = createLogger("bridge.acp");
21033
21293
  var MAX_WINDOWS_PER_SESSION = 256;
21034
21294
  var MAX_CACHED_JOURNALS = MAX_RESUMABLE_SESSIONS;
21035
21295
  var probe;
@@ -21143,7 +21403,7 @@ function closeWindow(active, state, toolUseId, role) {
21143
21403
  recordAcpShellObservation(state, toolUseId, observation);
21144
21404
  recordCommandChange(state, toolUseId, legacyCommandChange(observation));
21145
21405
  }).catch((error) => {
21146
- log7.warn("command-change.record-failed", {
21406
+ log8.warn("command-change.record-failed", {
21147
21407
  errorClass: error instanceof Error ? error.name : "unknown"
21148
21408
  });
21149
21409
  });
@@ -21202,7 +21462,7 @@ async function applyJournaledCommandChanges(state) {
21202
21462
  function journalFor(acpSessionId) {
21203
21463
  if (!journalDirectory || !acpSessionId)
21204
21464
  return;
21205
- const name = createHash6("sha256").update(acpSessionId).digest("hex").slice(0, 40);
21465
+ const name = createHash7("sha256").update(acpSessionId).digest("hex").slice(0, 40);
21206
21466
  const path = resolve6(journalDirectory, `${name}.jsonl`);
21207
21467
  let journal = journals.get(path);
21208
21468
  if (journal) {
@@ -21360,13 +21620,12 @@ async function resumeSessionReserved(acpSessionId, signal, patch, policy, agentM
21360
21620
  throw new HttpError(410, `${provider} cannot reload persisted ACP sessions`);
21361
21621
  }
21362
21622
  state = {
21363
- id: randomBytes7(16).toString("hex"),
21623
+ id: randomBytes8(16).toString("hex"),
21364
21624
  acpSessionId,
21365
21625
  status: "idle",
21366
21626
  messages: [],
21367
21627
  activeSubagentToolIds: new Set,
21368
21628
  activeSubagentDescriptors: new Map,
21369
- settledCursorAgentIds: new Set,
21370
21629
  subagentLimitExceeded: false,
21371
21630
  subagentToolIds: new Map,
21372
21631
  cursorTodos: [],
@@ -21425,10 +21684,8 @@ async function resumeSessionReserved(acpSessionId, signal, patch, policy, agentM
21425
21684
  await persistState();
21426
21685
  return state;
21427
21686
  } catch (error) {
21428
- if (state && sessions.get(state.id) === state) {
21687
+ if (state && sessions.get(state.id) === state)
21429
21688
  sessions.delete(state.id);
21430
- bumpCursorDiscoveryRevision();
21431
- }
21432
21689
  if (state)
21433
21690
  clearApprovals(state);
21434
21691
  await child.close();
@@ -21520,7 +21777,7 @@ async function createSessionReserved(clientSessionKey, signal, spawnOptions = {}
21520
21777
  if (!isObject3(created) || typeof created.sessionId !== "string") {
21521
21778
  throw new Error(`${provider} returned an invalid ACP session`);
21522
21779
  }
21523
- const id = randomBytes7(16).toString("hex");
21780
+ const id = randomBytes8(16).toString("hex");
21524
21781
  const sessionConfig = normalizeAcpSessionConfig(provider, created);
21525
21782
  rememberCatalog(sessionConfig.composer);
21526
21783
  const state = newSessionState(id, clientSessionKey, created.sessionId, child, sessionConfig, spawnOptions);
@@ -21537,10 +21794,8 @@ async function createSessionReserved(clientSessionKey, signal, spawnOptions = {}
21537
21794
  return state;
21538
21795
  } catch (error) {
21539
21796
  state.dispatching = false;
21540
- if (sessions.get(id) === state) {
21797
+ if (sessions.get(id) === state)
21541
21798
  sessions.delete(id);
21542
- bumpCursorDiscoveryRevision();
21543
- }
21544
21799
  if (clientSessionKey && clientSessionKeys.get(clientSessionKey) === id) {
21545
21800
  clientSessionKeys.delete(clientSessionKey);
21546
21801
  }
@@ -21561,7 +21816,6 @@ function newSessionState(id, clientSessionKey, acpSessionId, child, sessionConfi
21561
21816
  messages: [],
21562
21817
  activeSubagentToolIds: new Set,
21563
21818
  activeSubagentDescriptors: new Map,
21564
- settledCursorAgentIds: new Set,
21565
21819
  subagentLimitExceeded: false,
21566
21820
  subagentToolIds: new Map,
21567
21821
  cursorTodos: [],
@@ -21592,7 +21846,7 @@ function newSessionState(id, clientSessionKey, acpSessionId, child, sessionConfi
21592
21846
  };
21593
21847
  }
21594
21848
  async function createDeferredSession(clientSessionKey, spawnOptions) {
21595
- const id = randomBytes7(16).toString("hex");
21849
+ const id = randomBytes8(16).toString("hex");
21596
21850
  const empty = normalizeAcpSessionConfig(provider, {});
21597
21851
  const sessionConfig = withRequestedSelection({ ...empty, composer: { ...empty.composer, models: catalogCache?.models ?? [] } }, composerPatchFromSpawn(spawnOptions));
21598
21852
  const state = newSessionState(id, clientSessionKey, "", null, sessionConfig, spawnOptions);
@@ -21671,6 +21925,7 @@ async function startDeferredSession(state) {
21671
21925
  var ORKESTRATOR_AUTO_ALLOWED_TOOL_NAMES = [
21672
21926
  ...AGENT_MAIL_TOOL_NAMES,
21673
21927
  ...AGENT_GOAL_TOOL_NAMES,
21928
+ ...AGENT_SUBORK_TOOL_NAMES,
21674
21929
  ...WEB_ANNOTATION_TOOL_NAMES,
21675
21930
  ...ARTIFACT_TOOL_NAMES
21676
21931
  ];
@@ -22303,7 +22558,7 @@ function parkPermission(state, child, requestId, params) {
22303
22558
  }
22304
22559
  ];
22305
22560
  }).slice(0, 20) : [];
22306
- const id = randomBytes7(12).toString("hex");
22561
+ const id = randomBytes8(12).toString("hex");
22307
22562
  const requestedAt = Date.now();
22308
22563
  const promptSequence = state.promptSequence;
22309
22564
  const toolCallId = isObject3(params.toolCall) ? params.toolCall.toolCallId : undefined;
@@ -22360,7 +22615,7 @@ function permissionTitle(params) {
22360
22615
  return title.slice(0, 500);
22361
22616
  }
22362
22617
  function appendNonTextContent(state, update, role) {
22363
- const messageId = randomBytes7(12).toString("hex");
22618
+ const messageId = randomBytes8(12).toString("hex");
22364
22619
  const parts = contentBlockParts(update.content, messageId, 0);
22365
22620
  if (parts.length === 0)
22366
22621
  return;
@@ -22500,7 +22755,7 @@ function applySessionUpdate(state, params) {
22500
22755
  if (!message) {
22501
22756
  const modelId = role === "assistant" ? boundedModelId(state.sessionConfig.composer.selectedModelId) : undefined;
22502
22757
  message = {
22503
- id: randomBytes7(12).toString("hex"),
22758
+ id: randomBytes8(12).toString("hex"),
22504
22759
  role,
22505
22760
  content: "",
22506
22761
  parts: [],
@@ -22927,7 +23182,7 @@ function setPromptJournal(state, entry) {
22927
23182
  state.promptJournal.set(entry.requestId, entry);
22928
23183
  }
22929
23184
  // ../../bridges/acp-bridge/src/acp-prompt.ts
22930
- import { randomBytes as randomBytes8 } from "node:crypto";
23185
+ import { randomBytes as randomBytes9 } from "node:crypto";
22931
23186
 
22932
23187
  // ../../bridges/acp-bridge/src/structured-prompt-marker.ts
22933
23188
  var STRUCTURED_PROMPT_INSTRUCTION_PREFIX = "End your turn with exactly one JSON value";
@@ -23004,7 +23259,7 @@ function openRetryCard(state, text) {
23004
23259
  type: "retry",
23005
23260
  content: text,
23006
23261
  toolState: "pending",
23007
- sourcePartId: randomBytes8(12).toString("hex"),
23262
+ sourcePartId: randomBytes9(12).toString("hex"),
23008
23263
  sourceMessageId: message.id,
23009
23264
  createdAt: new Date().toISOString()
23010
23265
  };
@@ -23406,6 +23661,18 @@ async function forkAcpSession(state, upToMessageId, signal) {
23406
23661
 
23407
23662
  // ../protocol/src/human-prompts.ts
23408
23663
  var HUMAN_PROMPT_SCAN_BYTES = 16 * 1024;
23664
+ var HUMAN_PROMPT_KINDS = new Set([
23665
+ "sign-in",
23666
+ "device-code",
23667
+ "press-enter",
23668
+ "secret",
23669
+ "host-key"
23670
+ ]);
23671
+ var HUMAN_PROMPT_SOURCES = new Set([
23672
+ "user-command",
23673
+ "agent-tool",
23674
+ "agent-background-task"
23675
+ ]);
23409
23676
  var HUMAN_PROMPT_OBSERVATION_ROWS = 64;
23410
23677
  function humanPromptObservation(messages, tasks) {
23411
23678
  const object = (value) => !!value && typeof value === "object" && !Array.isArray(value);
@@ -23458,7 +23725,7 @@ function humanPromptObservation(messages, tasks) {
23458
23725
  }
23459
23726
 
23460
23727
  // ../../bridges/acp-bridge/src/acp-http.ts
23461
- import { randomBytes as randomBytes9, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
23728
+ import { randomBytes as randomBytes10 } from "node:crypto";
23462
23729
  import { pathToFileURL } from "node:url";
23463
23730
  import { gzip } from "node:zlib";
23464
23731
 
@@ -23897,7 +24164,7 @@ var DEFAULT_MCP_MANAGEMENT_ROLLOUT = Object.freeze({
23897
24164
 
23898
24165
  // ../protocol/src/node/bridge-transcript-summary.ts
23899
24166
  import { Buffer as Buffer5 } from "node:buffer";
23900
- import { createHash as createHash7 } from "node:crypto";
24167
+ import { createHash as createHash8 } from "node:crypto";
23901
24168
 
23902
24169
  // ../protocol/src/node/progressive-transcript.ts
23903
24170
  var BRIDGE_TRANSCRIPT_MAX_MESSAGES = 100;
@@ -24063,7 +24330,7 @@ function digestPayload(payload) {
24063
24330
  const serialized = JSON.stringify(payload);
24064
24331
  return {
24065
24332
  bytes: Buffer5.byteLength(serialized),
24066
- digest: createHash7("sha256").update(serialized).digest("base64url").slice(0, 32)
24333
+ digest: createHash8("sha256").update(serialized).digest("base64url").slice(0, 32)
24067
24334
  };
24068
24335
  }
24069
24336
  function topLevelKey(part, index) {
@@ -24499,10 +24766,8 @@ async function runClose(state) {
24499
24766
  schedulePersist();
24500
24767
  return "pending";
24501
24768
  }
24502
- if (sessions.get(state.id) === state) {
24769
+ if (sessions.get(state.id) === state)
24503
24770
  sessions.delete(state.id);
24504
- bumpCursorDiscoveryRevision();
24505
- }
24506
24771
  const clientKey = state.clientSessionKey;
24507
24772
  if (clientKey !== undefined && clientSessionKeys.get(clientKey) === state.id) {
24508
24773
  clientSessionKeys.delete(clientKey);
@@ -24778,7 +25043,8 @@ function holdParkedRequest(state, family, id, held) {
24778
25043
  }
24779
25044
 
24780
25045
  // ../../bridges/acp-bridge/src/acp-http.ts
24781
- var TRANSCRIPT_GENERATION = randomBytes9(16).toString("hex");
25046
+ var TRANSCRIPT_GENERATION = randomBytes10(16).toString("hex");
25047
+ var log9 = createLogger("bridge.acp");
24782
25048
 
24783
25049
  class CommandUnavailableError extends Error {
24784
25050
  }
@@ -24827,7 +25093,17 @@ async function route(request, response, clientSignal) {
24827
25093
  return json(response, 200, { models });
24828
25094
  }
24829
25095
  if (url.pathname === "/session/list" && request.method === "GET") {
24830
- return json(response, 200, { sessions: await listResumableSessions() });
25096
+ try {
25097
+ return json(response, 200, { sessions: await listResumableSessions() });
25098
+ } catch (error) {
25099
+ if (error instanceof HttpError || error instanceof CredentialError)
25100
+ throw error;
25101
+ log9.warn("http.route-failed", {
25102
+ method: request.method,
25103
+ error: formatLogError(error, { message: false })
25104
+ });
25105
+ return json(response, 500, { error: "Failed to read session history" });
25106
+ }
24831
25107
  }
24832
25108
  if (url.pathname === "/session/resume" && request.method === "POST") {
24833
25109
  const body = await readJson(request);
@@ -25215,7 +25491,7 @@ async function route(request, response, clientSignal) {
25215
25491
  }
25216
25492
  throw error;
25217
25493
  }
25218
- const userMessageId = randomBytes9(12).toString("hex");
25494
+ const userMessageId = randomBytes10(12).toString("hex");
25219
25495
  const userVisiblePrompt = selectedCommand ? displayPrompt || prompt : prompt;
25220
25496
  state.messages.push({
25221
25497
  id: userMessageId,
@@ -25438,11 +25714,7 @@ function authenticated(request) {
25438
25714
  Array.isArray(dedicated) ? dedicated[0] : dedicated,
25439
25715
  request.headers.authorization?.replace(/^Bearer\s+/i, "")
25440
25716
  ];
25441
- const right = Buffer.from(authToken);
25442
- return candidates.some((candidate) => {
25443
- const left = Buffer.from(candidate?.trim() || "");
25444
- return left.length === right.length && timingSafeEqual2(left, right);
25445
- });
25717
+ return candidates.some((candidate) => bridgeCredential.matches(candidate?.trim()));
25446
25718
  }
25447
25719
  function isTrustedBridgeOrigin(origin) {
25448
25720
  if (!origin)
@@ -25588,6 +25860,7 @@ function installFatalRejectionGuard(options) {
25588
25860
  const APP_PATH = /(?:^|\/)((?:apps\/(?:backend|desktop|web|web-public)|packages\/(?:protocol|cli|toolchain)|bridges\/[\w-]+|[\w-]+-bridge)\/.*)$/;
25589
25861
  const PACKAGED_PATH = /\/((?:app\.asar(?:\.unpacked)?|resources)\/.*)$/i;
25590
25862
  const CREDENTIALS = [
25863
+ { pattern: /\bok[ab]_[A-Za-z0-9_-]{16,}/g, replacement: "[redacted]" },
25591
25864
  {
25592
25865
  pattern: /([a-z][a-z0-9+.-]*:\/\/)[^/\s:@]+(?::[^/\s@]*)?@/gi,
25593
25866
  replacement: "$1[redacted]@"
@@ -25715,9 +25988,9 @@ function installFatalRejectionGuard(options) {
25715
25988
  }
25716
25989
 
25717
25990
  // ../protocol/src/node/process-failure-log.ts
25718
- var log8 = createLogger("process");
25991
+ var log10 = createLogger("process");
25719
25992
  function logUnhandledRejection(reason) {
25720
- log8.throttled("error", "rejection.unhandled", {
25993
+ log10.throttled("error", "rejection.unhandled", {
25721
25994
  error: reason,
25722
25995
  fields: () => ({ error: formatLogError(reason, { message: false }) })
25723
25996
  });
@@ -25750,7 +26023,7 @@ function watchClientDisconnect(request, response, onDisconnect) {
25750
26023
  }
25751
26024
 
25752
26025
  // ../../bridges/acp-bridge/src/acp-server.ts
25753
- var log9 = createLogger("bridge.acp");
26026
+ var log11 = createLogger("bridge.acp");
25754
26027
  configureBridgeLogger();
25755
26028
  await restorePersistedState();
25756
26029
  var server = createServer((request, response) => {
@@ -25765,13 +26038,13 @@ var server = createServer((request, response) => {
25765
26038
  return;
25766
26039
  }
25767
26040
  if (error instanceof PolicyWideningRefusedError) {
25768
- log9.warn("session.policy-widening-refused", { widened: error.widened.join(",") });
26041
+ log11.warn("session.policy-widening-refused", { widened: error.widened.join(",") });
25769
26042
  json(response, 403, error.refusal());
25770
26043
  return;
25771
26044
  }
25772
26045
  const status = error instanceof HttpError ? error.status : 500;
25773
26046
  if (status === 500 && !controller.signal.aborted) {
25774
- log9.warn("http.route-failed", {
26047
+ log11.warn("http.route-failed", {
25775
26048
  method: request.method,
25776
26049
  error: formatLogError(error, { message: false })
25777
26050
  });
@@ -25779,7 +26052,7 @@ var server = createServer((request, response) => {
25779
26052
  json(response, status, { error: error instanceof Error ? error.message : String(error) });
25780
26053
  }).finally(stopWatchingClient);
25781
26054
  });
25782
- server.listen(port, hostname, () => log9.info("server.listening", { provider, hostname, port }));
26055
+ server.listen(port, hostname, () => log11.info("server.listening", { provider, hostname, port }));
25783
26056
  var shutdownPromise = null;
25784
26057
  function shutdown() {
25785
26058
  if (shutdownPromise)
@@ -25821,10 +26094,6 @@ export {
25821
26094
  CLOSE_ATTACH_WAIT_MS,
25822
26095
  CLOSE_CANCEL_WAIT_MS,
25823
26096
  CLOSE_SESSION_WAIT_MS,
25824
- CURSOR_BACKGROUND_CONTINUATION_PREFIX,
25825
- CURSOR_BACKGROUND_WAIT_MS,
25826
- CURSOR_CHILD_DISCOVERY_SKEW_MS,
25827
- CURSOR_JSONL_SOURCE_PREFIX,
25828
26097
  CURSOR_TODO_STATUSES,
25829
26098
  DIFF_CONTEXT_LINES,
25830
26099
  EXTERNAL_SESSION_PREFIX,
@@ -25838,17 +26107,9 @@ export {
25838
26107
  MAX_APPROVALS_PER_SESSION,
25839
26108
  MAX_BODY_BYTES,
25840
26109
  MAX_CHILD_PARTS_PER_CALL,
25841
- MAX_CURSOR_BACKGROUND_CONTINUATIONS,
25842
- MAX_CURSOR_CHILD_PARTS,
25843
- MAX_CURSOR_CHILD_PROMPT_BYTES,
25844
- MAX_CURSOR_CHILD_PROMPT_RECORDS,
25845
- MAX_CURSOR_CHILD_RESULT_BYTES,
25846
- MAX_CURSOR_DISCOVERY_ENTRIES,
25847
- MAX_CURSOR_SETTLED_CLAIMS,
25848
26110
  MAX_CURSOR_TASK_PROMPT_BYTES,
25849
26111
  MAX_CURSOR_TODOS,
25850
26112
  MAX_CURSOR_TODO_CANDIDATES,
25851
- MAX_CURSOR_TRANSCRIPT_HYDRATE_CHILDREN,
25852
26113
  MAX_DIFF_EDIT_DISTANCE,
25853
26114
  MAX_EVICTED_TOOL_CALL_IDS,
25854
26115
  MAX_GROK_INTERJECTION_ID_BYTES,
@@ -25940,7 +26201,7 @@ export {
25940
26201
  boundedNullableString,
25941
26202
  boundedString2 as boundedString,
25942
26203
  boundedToolArguments,
25943
- bumpCursorDiscoveryRevision,
26204
+ bridgeCredential,
25944
26205
  catalogCache,
25945
26206
  catalogProbe,
25946
26207
  clearApprovals,
@@ -25956,7 +26217,6 @@ export {
25956
26217
  createDisplayDiff,
25957
26218
  createSession,
25958
26219
  createSessionReserved,
25959
- currentCursorDiscoveryRevision,
25960
26220
  cursorSubagentTypeLabel,
25961
26221
  cursorTaskNamedState,
25962
26222
  diffFileLines,
@@ -26057,7 +26317,6 @@ export {
26057
26317
  raceAbort,
26058
26318
  readJson,
26059
26319
  reconcileStaleToolParts,
26060
- recordCursorTaskPrompt,
26061
26320
  recordTurnUsage,
26062
26321
  rememberCatalog,
26063
26322
  rememberHistoryMessage,
@@ -26122,7 +26381,6 @@ export {
26122
26381
  toolCallContentText,
26123
26382
  toolCallLifecycle,
26124
26383
  toolCallLocationPath,
26125
- toolPartAgentId,
26126
26384
  trimNoticePartId,
26127
26385
  trimPartsTo,
26128
26386
  trimmedToolCalls,