orkestrator 2.36.3-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.
@@ -1054,6 +1054,12 @@ var BACKEND_LOG_AREAS = defineLogAreas({
1054
1054
  "startup.looped-review-pending": "Cleanup of the retired Looped Review stays pending.",
1055
1055
  "notice.failed": "A background notice after a turn or prompt failed; `step` says which.",
1056
1056
  "artifacts.live-unavailable": "Live interactive artifacts are unavailable.",
1057
+ "previous-run": {
1058
+ 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.",
1059
+ essential: true,
1060
+ fields: { outcome: "label", ranForMs: "number", lastSeenAgoMs: "number" }
1061
+ },
1062
+ "health.write-failed": "A health summary row could not be written or read; the next sample retries.",
1057
1063
  "shutdown.step-failed": "One part of shutdown failed and the rest went on; `step` says which.",
1058
1064
  "shutdown.signal-received": {
1059
1065
  description: "A signal started shutdown, which tells a clean quit from the backend being killed.",
@@ -1097,7 +1103,8 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
1097
1103
  description: "What every long-lived bridge does the same way: its sweep and its shutdown.",
1098
1104
  events: {
1099
1105
  "idle-sweep.failed": "An idle sweep threw; the next tick retries.",
1100
- "shutdown.failed": "Releasing the bridge failed during shutdown; it still exits."
1106
+ "shutdown.failed": "Releasing the bridge failed during shutdown; it still exits.",
1107
+ "credential.not-hardened": "The bridge could not mark itself non-dumpable, so a same-uid process can read its memory; `reason` says why."
1101
1108
  }
1102
1109
  },
1103
1110
  "bridge.acp": {
@@ -1231,7 +1238,6 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
1231
1238
  "parent.gone": "The backend that launched this bridge has gone; stopping turns and shutting down.",
1232
1239
  "queue.overflow": "The notification queue passed a bound and dropped its backlog.",
1233
1240
  "queue.task-failed": "A task on a per-thread queue failed.",
1234
- "raw-log.write-failed": "Appending to the raw Codex log failed.",
1235
1241
  "recorder.notice": "The notification recorder needs attention: it is on, or was asked for without its confirmation.",
1236
1242
  "recorder.threw": "The notification recorder threw.",
1237
1243
  "recorder.write-failed": "Writing a notification recording failed; its lines were dropped.",
@@ -1437,6 +1443,7 @@ var ENVIRONMENT_LOG_AREAS = defineLogAreas({
1437
1443
  environment: {
1438
1444
  description: "Environment naming, setup, status, moves, deletion and cleanup afterwards.",
1439
1445
  events: {
1446
+ "cleanup.sessions-failed": "Session metadata cleanup failed during environment deletion; deletion continues.",
1440
1447
  "cleanup.branch-kept": "A deleted environment's local branch was kept, as it may hold unmerged work.",
1441
1448
  "rename.failed": "Naming an environment from its pending prompt failed for the first time.",
1442
1449
  "rename.still-failing": "That rename is still failing; written at the 2nd, 4th, 8th... failure.",
@@ -1510,6 +1517,7 @@ var GATEWAY_LOG_AREAS = defineLogAreas({
1510
1517
  "websocket.upgrade-failed": "A WebSocket upgrade failed.",
1511
1518
  "events.client-dropped": "An event-stream client buffered too much and was dropped; it reconnects and refetches.",
1512
1519
  "proxy.client-disconnected": "A proxy client went away, so its upstream request was aborted.",
1520
+ "traffic.burst": "Connections or requests spiked. Counts by source address, route class, client family, listener and registered invoke command; never request content.",
1513
1521
  "throttle.suppressed": "Repeats of the throttled `site` were counted over a window, not written.",
1514
1522
  "throttle.recovered": "The throttled `site` succeeded again, so its fault has cleared.",
1515
1523
  "throttle.evicted": "The tracked-key limit dropped the `site`, so no recovered line follows unless it fails again."
@@ -1643,6 +1651,7 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
1643
1651
  "native-agent": {
1644
1652
  description: "Native agent sessions and what the backend reads from their bridges.",
1645
1653
  events: {
1654
+ "session.bridge-replaced-for-policy": "An idle bridge was stopped so a resume could apply the user's wider execution policy.",
1646
1655
  "catalogue.outdated-bridge": "A bridge predates the command catalogue, so its commands stay unavailable.",
1647
1656
  "compact.instructions-ignored": "A bridge compacted without confirming the instructions sent with /compact: it predates them.",
1648
1657
  "handoff.summary-read-failed": "Change summaries could not be read for a handoff, so the carrier says they are unmeasured.",
@@ -1708,7 +1717,8 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
1708
1717
  "coordinator-servers.unavailable": "OpenCode coordinator research servers are unavailable.",
1709
1718
  "monitor.reconnecting": "The request monitor lost its stream and is reconnecting. Error class only.",
1710
1719
  "worker-limit.reached": "The bounded request workers are full, so the stream restarts and a snapshot reconciles.",
1711
- "request.failed": "Handling a request event failed, so the stream restarts. Error class only."
1720
+ "request.failed": "Handling a request event failed, so the stream restarts. Error class only.",
1721
+ "credential-plugin.skipped": "A host OpenCode server started without the credential plugin, so its tools inherit its password; `reason` says why."
1712
1722
  }
1713
1723
  }
1714
1724
  });
@@ -1736,6 +1746,7 @@ var PREVIEW_LOG_AREAS = defineLogAreas({
1736
1746
  "publication.start-failed": "Private preview publication did not start.",
1737
1747
  "publication.reconfigure-failed": "Preview publication could not be reconfigured.",
1738
1748
  "publication.listening": "Private preview origins are listening.",
1749
+ "publication.same-site": "The preview domain is the same site as the application; publication runs with a warning.",
1739
1750
  "certificate.reloaded": "The preview certificate was reloaded.",
1740
1751
  "access.revoked-close-failed": "A revoked preview resource could not be closed. Error class only.",
1741
1752
  "registry.invalid-definition": "An invalid stored preview service definition was ignored.",
@@ -2044,10 +2055,19 @@ var STORAGE_LOG_AREAS = defineLogAreas({
2044
2055
  "retired.turn-cleanup-pending": "Cleanup of a retired Looped Review turn did not finish and stays pending.",
2045
2056
  "handoffs.prune-failed": "Pruning agent handoffs that nothing references failed; a later prune retries.",
2046
2057
  "desktop-connections.malformed": "Stored desktop connection settings were malformed, so the local connection is used.",
2058
+ "config.restrict-mode-failed": "A config file holding provider secrets could not be set to owner-only; the backend carries on.",
2047
2059
  "legacy-json.moved": "JSON store files written after the SQLite migration were archived, not imported.",
2048
2060
  "legacy-json.archive-failed": "Imported JSON store files could not be archived.",
2061
+ "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.",
2049
2062
  "lease.heartbeat-failed": "A held lease's heartbeat failed, which shortens the lease; the next one retries.",
2050
- "scrub.checkpoint-failed": "Deleted content could not be scrubbed from the WAL because the truncating checkpoint failed or was blocked; the next checkpoint retries.",
2063
+ "scrub.vacuum-failed": "Deleted-content page reclamation failed; the checkpoint is attempted independently.",
2064
+ "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.",
2065
+ "upkeep.vacuum-failed": "Periodic page reclamation failed; the next upkeep pass retries.",
2066
+ "optimize.failed": "Refreshing the query planner's statistics failed; queries still run and the next check retries.",
2067
+ "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.",
2068
+ "snapshot.top-tables-failed": "The sampled table sizes from a finished snapshot could not be saved; the snapshot stands and the next one retries.",
2069
+ "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.",
2070
+ "snapshot.ledger-failed": "The daily change-tracking ledger snapshot failed; `retryAt` says when it tries again, if known.",
2051
2071
  ...THROTTLE_LOG_EVENTS
2052
2072
  }
2053
2073
  }
@@ -2064,6 +2084,7 @@ var BUILD_PIPELINE_LOG_AREAS = defineLogAreas({
2064
2084
  "consolidation.consume-deferred": "Consuming a review consolidation result failed; it stays pending and is retried.",
2065
2085
  "dispatch.prepare-failed": "Attaching the agent before dispatch failed; the prompt request does the same work and answers authoritatively.",
2066
2086
  "interaction.resolved": "A human interaction on a pipeline stage resolved. Metadata only.",
2087
+ "user-message.background-send-refused": "The bridge refused a queued user message during a background wait; it stays queued and is retried.",
2067
2088
  "transcripts.migrated": "A transcript migration pass moved stage transcripts; counts only.",
2068
2089
  "transcripts.maintenance-failed": "Migrating or sweeping stage transcripts failed; the next start retries.",
2069
2090
  "restore.skipped": "A pipeline could not be restored at startup and was skipped.",
@@ -2101,6 +2122,8 @@ var CHANGE_TRACKING_LOG_AREAS = defineLogAreas({
2101
2122
  description: "Change tracking: turn capture, evidence pulls and measurements.",
2102
2123
  events: {
2103
2124
  "journal-import.failed": "Importing surviving OpenCode command journals as legacy summaries failed.",
2125
+ "measurement-drain.failed": "Draining an owner's superseded measurements failed; the retention pass retries.",
2126
+ "retention.failed": "A retention pass failed partway; what it deleted stands and the next pass goes on.",
2104
2127
  "projection.failed": "Projecting a change event onto its environment failed.",
2105
2128
  "startup.reconcile-failed": "Reconciling change tracking at startup failed.",
2106
2129
  "turn-start.capture-failed": "Capturing a turn's start failed, so the turn is untracked.",
@@ -2131,7 +2154,16 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
2131
2154
  coordinator: {
2132
2155
  description: "Coordinators: delegations, status wakes and their store.",
2133
2156
  events: {
2157
+ ...THROTTLE_LOG_EVENTS,
2134
2158
  "delegation.open-failed": "A delegation could not be opened; `source` says for what.",
2159
+ "delegation.reconcile-failed": "One delegation could not be settled; the rest of the pass still ran and the next one retries.",
2160
+ "delegation.wake-failed": "One delegation's wake could not be delivered; the rest of the pass still ran and the next one retries.",
2161
+ "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.",
2162
+ "delegation.wake-pass-failed": "A delegation wake pass could not run; the next sweep retries.",
2163
+ "delegation.wake-retire-failed": "A wake that keeps failing could not be given up on; the next pass retries.",
2164
+ "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.",
2165
+ "delegation.wake-retired": "A wake kept failing and was given up on; `kind` is the last failure.",
2166
+ "mail.reconcile-failed": "One coordinator's mail could not be reconciled; the sweep carried on with the others.",
2135
2167
  "deliver-now.drain-failed": "The mail delivery pass after deliverNow failed; the next sweep delivers.",
2136
2168
  "mail.move-failed": "Mail could not move to the new main coordinator.",
2137
2169
  "work.move-failed": "Work could not move to the main coordinator.",
@@ -2256,6 +2288,8 @@ var DOCKER_LOG_AREAS = defineLogAreas({
2256
2288
  "portable-inputs.relay-missing": "Docker is rootless and the image predates the staged-input relay, so the container cannot read them until rebuilt.",
2257
2289
  "git-mirror.mount-unavailable": "A new container gets no project Git mirror, so its clone goes to the remote.",
2258
2290
  "git-mirror.refreshed": "A project's Git mirror was built or updated.",
2291
+ "git-mirror.seeded": "A project's Git mirror was built from its host checkout and only what the remote added to it.",
2292
+ "git-mirror.seed-skipped": "A project's host checkout could not seed its Git mirror, so the build downloads everything.",
2259
2293
  "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.",
2260
2294
  "git-mirror.low-disk": "A project's Git mirror was not updated: the disk is nearly full.",
2261
2295
  "git-mirror.oversized": "A project's repository is too large for a Git mirror, so its environments keep the blobless clone.",
@@ -2267,6 +2301,7 @@ var DOCKER_LOG_AREAS = defineLogAreas({
2267
2301
  "git-mirror.clone-fallback": "A new environment could not clone from its project's Git mirror and cloned from the remote.",
2268
2302
  "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.",
2269
2303
  "opencode.warm-incomplete": "OpenCode did not finish loading /workspace in a container.",
2304
+ "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.",
2270
2305
  "lifecycle-event.reconcile-failed": "Reconciling an environment after a container start or stop event failed; the next status read retries.",
2271
2306
  "login-keeper.pass-failed": "A Claude login keeper pass failed; the next interval retries.",
2272
2307
  "login-keeper.refresh-failed": "Refreshing the host Claude login failed. Fixed text: CLI output can hold credentials.",
@@ -2290,6 +2325,7 @@ var DOCKER_LOG_AREAS = defineLogAreas({
2290
2325
  essential: true,
2291
2326
  fields: { staleForMs: "number" }
2292
2327
  },
2328
+ "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.",
2293
2329
  "writer-lease.not-acquired": {
2294
2330
  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.",
2295
2331
  essential: true,
@@ -2944,6 +2980,7 @@ var WEB_SYNC_LOG_AREAS = defineLogAreas({
2944
2980
  events: {
2945
2981
  "events.disconnected": "The main event stream dropped; it reconnects and replays.",
2946
2982
  "terminal-stream.disconnected": "A terminal event stream dropped; it reconnects.",
2983
+ "relayed-stream.disconnected": "The relayed node event stream dropped; it reconnects.",
2947
2984
  "connection-listener.failed": "A main stream connection state listener threw.",
2948
2985
  "event-listener.failed": "A listener for a gateway event threw.",
2949
2986
  "stream-listener.failed": "A listener for the stream-connected notice threw."
@@ -3028,6 +3065,7 @@ var TEXT_RULES = [
3028
3065
  pattern: /\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}/g,
3029
3066
  replacement: "[redacted]"
3030
3067
  },
3068
+ { pattern: /\bok[ab]_[A-Za-z0-9_-]{16,}/g, replacement: "[redacted]" },
3031
3069
  { pattern: /\bgh[pousr]_[A-Za-z0-9]{16,}/g, replacement: "[redacted]" },
3032
3070
  { pattern: /\bgithub_pat_[A-Za-z0-9_]{20,}/g, replacement: "[redacted]" },
3033
3071
  { pattern: /\b(?:sk|rk|pk)-[A-Za-z0-9_-]{12,}/g, replacement: "[redacted]" },
@@ -3812,6 +3850,73 @@ function parseBridgeLogPolicy(value) {
3812
3850
  return Number.isSafeInteger(seq) && seq >= 0 ? { ...detail, seq } : null;
3813
3851
  }
3814
3852
 
3853
+ // ../protocol/src/node/bridge-credential.ts
3854
+ import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
3855
+ import { createRequire } from "node:module";
3856
+ var BRIDGE_TOKEN_PREFIX = "okb_";
3857
+ var PR_SET_DUMPABLE = 4;
3858
+ var VERIFIER_PATTERN = /^[0-9a-f]{64}$/;
3859
+ var log = createLogger("bridge.lifecycle");
3860
+ function mintBridgeToken() {
3861
+ return `${BRIDGE_TOKEN_PREFIX}${randomBytes(32).toString("base64url")}`;
3862
+ }
3863
+ function bridgeTokenVerifier(token) {
3864
+ return createHash("sha256").update(token).digest("hex");
3865
+ }
3866
+ function bridgeTokenVerifierEnv(tokenEnv) {
3867
+ return `${tokenEnv}_SHA256`;
3868
+ }
3869
+ function credentialFromVerifier(verifier, plainToken) {
3870
+ const expected = Buffer.from(verifier, "hex");
3871
+ return {
3872
+ plainToken,
3873
+ matches(candidate) {
3874
+ if (!candidate)
3875
+ return false;
3876
+ return timingSafeEqual(expected, createHash("sha256").update(candidate).digest());
3877
+ }
3878
+ };
3879
+ }
3880
+ function bridgeCredentialFromToken(token) {
3881
+ return credentialFromVerifier(bridgeTokenVerifier(token), token);
3882
+ }
3883
+ function markProcessNonDumpable(loadFfi = () => createRequire(import.meta.url)("bun:ffi")) {
3884
+ if (process.platform !== "linux" || !process.versions.bun)
3885
+ return false;
3886
+ try {
3887
+ const { dlopen, FFIType } = loadFfi();
3888
+ const libc = dlopen("libc.so.6", {
3889
+ prctl: {
3890
+ args: [FFIType.i32, FFIType.u64, FFIType.u64, FFIType.u64, FFIType.u64],
3891
+ returns: FFIType.i32
3892
+ }
3893
+ });
3894
+ try {
3895
+ if (libc.symbols.prctl(PR_SET_DUMPABLE, 0n, 0n, 0n, 0n) === 0)
3896
+ return true;
3897
+ } finally {
3898
+ libc.close();
3899
+ }
3900
+ log.warn("credential.not-hardened", { reason: "prctl-refused" });
3901
+ } catch {
3902
+ log.warn("credential.not-hardened", { reason: "ffi-unavailable" });
3903
+ }
3904
+ return false;
3905
+ }
3906
+ function loadBridgeCredential(tokenEnv, options = {}) {
3907
+ const env = options.env ?? process.env;
3908
+ const verifierEnv = bridgeTokenVerifierEnv(tokenEnv);
3909
+ const verifier = env[verifierEnv]?.trim();
3910
+ const token = env[tokenEnv]?.trim();
3911
+ delete env[verifierEnv];
3912
+ delete env[tokenEnv];
3913
+ if (verifier) {
3914
+ (options.harden ?? markProcessNonDumpable)();
3915
+ return VERIFIER_PATTERN.test(verifier) ? credentialFromVerifier(verifier, undefined) : bridgeCredentialFromToken(mintBridgeToken());
3916
+ }
3917
+ return bridgeCredentialFromToken(token || mintBridgeToken());
3918
+ }
3919
+
3815
3920
  // ../protocol/src/node/logger-environment.ts
3816
3921
  var LOG_LEVEL_ENV = "ORKESTRATOR_LOG_LEVEL";
3817
3922
  var LOG_FORMAT_ENV = "ORKESTRATOR_LOG_FORMAT";
@@ -3888,14 +3993,14 @@ function applyLogDetail(detail, env = process.env) {
3888
3993
  }
3889
3994
 
3890
3995
  // ../protocol/src/node/bridge-diagnostics.ts
3891
- import { createHash } from "node:crypto";
3996
+ import { createHash as createHash2 } from "node:crypto";
3892
3997
 
3893
3998
  // ../protocol/src/event-loop-stall-monitor.ts
3894
- var log = createLogger("event-loop");
3999
+ var log2 = createLogger("event-loop");
3895
4000
  var EVENT_LOOP_STALL_ALWAYS_LOG_MS = 1e4;
3896
4001
 
3897
4002
  // ../protocol/src/node/bridge-diagnostics.ts
3898
- var log2 = createLogger("bridge.diagnostics");
4003
+ var log3 = createLogger("bridge.diagnostics");
3899
4004
  var BRIDGE_DIAGNOSTICS_INTERVAL_MS = 60000;
3900
4005
  var INTERVAL_MS = BRIDGE_DIAGNOSTICS_INTERVAL_MS;
3901
4006
  var STALL_NO_DELTA_MS = 2 * INTERVAL_MS;
@@ -3987,7 +4092,7 @@ function sameSet(a, b) {
3987
4092
  function identity(value) {
3988
4093
  if (typeof value !== "string" || !value || value.length > MAX_ID_LENGTH)
3989
4094
  return;
3990
- return createHash("sha256").update(value).digest("hex").slice(0, 16);
4095
+ return createHash2("sha256").update(value).digest("hex").slice(0, 16);
3991
4096
  }
3992
4097
  function readBridgeDebugFlag(value) {
3993
4098
  return value?.trim() === "1";
@@ -4060,16 +4165,16 @@ function safeDiagnosticMetrics(value) {
4060
4165
  return result;
4061
4166
  }
4062
4167
  function bridgeDiagnosticsChangesEnabled() {
4063
- return log2.isEnabled("trace");
4168
+ return log3.isEnabled("trace");
4064
4169
  }
4065
4170
  function writeBridgeDiagnostic({ bridge, event, payload }) {
4066
4171
  return tryWriteLog("info", "bridge.diagnostics", event, { bridge, payload });
4067
4172
  }
4068
4173
  function bridgeDiagnosticsActive() {
4069
- return log2.isEnabled("info");
4174
+ return log3.isEnabled("info");
4070
4175
  }
4071
4176
  function bridgeDiagnosticsStreamEnabled(bridge) {
4072
- return bridgeDebugEnabled(bridge) || log2.isEnabled("debug");
4177
+ return bridgeDebugEnabled(bridge) || log3.isEnabled("debug");
4073
4178
  }
4074
4179
  function writeDiagnostic(bridge, event, payload, write) {
4075
4180
  try {
@@ -4432,8 +4537,7 @@ async function readBridgeLogPolicyBody(request) {
4432
4537
 
4433
4538
  // ../../bridges/codex-bridge/src/index.ts
4434
4539
  import { execFile as execFileCallback2 } from "node:child_process";
4435
- import { randomBytes, timingSafeEqual } from "node:crypto";
4436
- import { appendFile as appendFile5, mkdir as mkdir9, readFile as readFile7, writeFile as writeFile6 } from "node:fs/promises";
4540
+ import { mkdir as mkdir9, readFile as readFile7, writeFile as writeFile6 } from "node:fs/promises";
4437
4541
  import { join as join23 } from "node:path";
4438
4542
  import { promisify as promisify2 } from "node:util";
4439
4543
 
@@ -8961,7 +9065,7 @@ function registerSessionActivityBatchRoute(app, runtime) {
8961
9065
  import { randomUUID as randomUUID2 } from "node:crypto";
8962
9066
 
8963
9067
  // ../protocol/src/node/revised-rows.ts
8964
- import { createHash as createHash2 } from "node:crypto";
9068
+ import { createHash as createHash3 } from "node:crypto";
8965
9069
  var RECENTLY_REVISED_ROWS_MAX = 128;
8966
9070
 
8967
9071
  class RecentlyRevisedRows {
@@ -8999,7 +9103,7 @@ class RecentlyRevisedRows {
8999
9103
  function revisedRowsReconciliationToken(overflowVersion, omitted) {
9000
9104
  if (overflowVersion === 0 && omitted.length === 0)
9001
9105
  return;
9002
- const digest = createHash2("sha256").update(String(overflowVersion));
9106
+ const digest = createHash3("sha256").update(String(overflowVersion));
9003
9107
  for (const row of omitted)
9004
9108
  digest.update(JSON.stringify(row) ?? "null");
9005
9109
  return digest.digest("hex");
@@ -9007,7 +9111,7 @@ function revisedRowsReconciliationToken(overflowVersion, omitted) {
9007
9111
 
9008
9112
  // ../protocol/src/node/bridge-transcript-summary.ts
9009
9113
  import { Buffer as Buffer3 } from "node:buffer";
9010
- import { createHash as createHash3 } from "node:crypto";
9114
+ import { createHash as createHash4 } from "node:crypto";
9011
9115
 
9012
9116
  // ../protocol/src/node/progressive-transcript.ts
9013
9117
  var BRIDGE_TRANSCRIPT_MAX_MESSAGES = 100;
@@ -9173,7 +9277,7 @@ function digestPayload(payload) {
9173
9277
  const serialized = JSON.stringify(payload);
9174
9278
  return {
9175
9279
  bytes: Buffer3.byteLength(serialized),
9176
- digest: createHash3("sha256").update(serialized).digest("base64url").slice(0, 32)
9280
+ digest: createHash4("sha256").update(serialized).digest("base64url").slice(0, 32)
9177
9281
  };
9178
9282
  }
9179
9283
  function topLevelKey(part, index) {
@@ -9618,7 +9722,7 @@ function registerCodexChangeEvidenceRoutes(app, spool) {
9618
9722
  }
9619
9723
 
9620
9724
  // ../../bridges/codex-bridge/src/change-evidence.ts
9621
- import { createHash as createHash5 } from "node:crypto";
9725
+ import { createHash as createHash6 } from "node:crypto";
9622
9726
  import { existsSync as existsSync2 } from "node:fs";
9623
9727
  import { basename, join as join8 } from "node:path";
9624
9728
 
@@ -10025,7 +10129,7 @@ function workspaceObservationReportIssues(value) {
10025
10129
  }
10026
10130
 
10027
10131
  // ../protocol/src/node/change-tracking/evidence-spool.ts
10028
- import { createHash as createHash4, randomUUID as randomUUID3 } from "node:crypto";
10132
+ import { createHash as createHash5, randomUUID as randomUUID3 } from "node:crypto";
10029
10133
  import { readdirSync, readFileSync } from "node:fs";
10030
10134
  import { appendFile, mkdir, rename, rm as rm2, writeFile } from "node:fs/promises";
10031
10135
  import { join as join3 } from "node:path";
@@ -10041,10 +10145,10 @@ var DEFAULT_EVIDENCE_SPOOL_LIMITS = {
10041
10145
  var ENTRIES_FILE = "entries.jsonl";
10042
10146
  var BODY_DIRECTORY = "bodies";
10043
10147
  function evidenceBodyId(bytes) {
10044
- return `sha256:${createHash4("sha256").update(bytes).digest("hex")}`;
10148
+ return `sha256:${createHash5("sha256").update(bytes).digest("hex")}`;
10045
10149
  }
10046
10150
  function stableEvidenceId(...parts) {
10047
- const hash = createHash4("sha256");
10151
+ const hash = createHash5("sha256");
10048
10152
  for (const part of parts)
10049
10153
  hash.update(`${part ?? ""}\x00`);
10050
10154
  return hash.digest("hex").slice(0, 40);
@@ -11589,7 +11693,7 @@ function suppliedMovePath(change) {
11589
11693
  return supplied?.kind === "update" ? supplied.movePath : change.move_path;
11590
11694
  }
11591
11695
  function codexChangeEvidenceDir(codexHome, cwd) {
11592
- const cwdHash = createHash5("sha256").update(cwd).digest("hex").slice(0, 16);
11696
+ const cwdHash = createHash6("sha256").update(cwd).digest("hex").slice(0, 16);
11593
11697
  return join8(codexBridgeStateDir(codexHome), "change-evidence", cwdHash);
11594
11698
  }
11595
11699
  function createCodexChangeEvidence(options) {
@@ -12191,6 +12295,18 @@ function toBridgeModel(model) {
12191
12295
  }
12192
12296
  // ../protocol/src/human-prompts.ts
12193
12297
  var HUMAN_PROMPT_SCAN_BYTES = 16 * 1024;
12298
+ var HUMAN_PROMPT_KINDS = new Set([
12299
+ "sign-in",
12300
+ "device-code",
12301
+ "press-enter",
12302
+ "secret",
12303
+ "host-key"
12304
+ ]);
12305
+ var HUMAN_PROMPT_SOURCES = new Set([
12306
+ "user-command",
12307
+ "agent-tool",
12308
+ "agent-background-task"
12309
+ ]);
12194
12310
  var HUMAN_PROMPT_OBSERVATION_ROWS = 64;
12195
12311
  function humanPromptObservation(messages, tasks) {
12196
12312
  const object = (value) => !!value && typeof value === "object" && !Array.isArray(value);
@@ -12242,14 +12358,17 @@ function humanPromptObservation(messages, tasks) {
12242
12358
  return { messages: [{ parts }], backgroundTasks };
12243
12359
  }
12244
12360
 
12361
+ // ../protocol/src/agent-usage-limits.ts
12362
+ var USAGE_LIMIT_ERROR_CODE = "usage-limit";
12363
+
12245
12364
  // ../../bridges/codex-bridge/src/sessions/typed-prompts.ts
12246
- import { createHash as createHash6, randomUUID as randomUUID5 } from "node:crypto";
12365
+ import { createHash as createHash7, randomUUID as randomUUID5 } from "node:crypto";
12247
12366
  import { mkdir as mkdir4, open, opendir, rename as rename3, rm as rm4, writeFile as writeFile3 } from "node:fs/promises";
12248
12367
  import { dirname as dirname2, join as join10 } from "node:path";
12249
12368
  var MAX_TYPED_PROMPT_CHARS = 32000;
12250
12369
  var MAX_RECORD_BYTES = 6 * MAX_TYPED_PROMPT_CHARS + 2048;
12251
12370
  function typedPromptDigest(sentText) {
12252
- return createHash6("sha256").update(sentText.trim()).digest("hex");
12371
+ return createHash7("sha256").update(sentText.trim()).digest("hex");
12253
12372
  }
12254
12373
  function typedPromptFor(record, sentText) {
12255
12374
  return record?.sent === typedPromptDigest(sentText) ? record.typed : undefined;
@@ -14469,7 +14588,7 @@ async function deriveTranscriptSubagentPartsForTurn({
14469
14588
  }
14470
14589
 
14471
14590
  // ../../bridges/codex-bridge/src/history/rollout.ts
14472
- import { createHash as createHash7 } from "node:crypto";
14591
+ import { createHash as createHash8 } from "node:crypto";
14473
14592
  import { readdir, stat as stat5 } from "node:fs/promises";
14474
14593
  import { homedir } from "node:os";
14475
14594
  import { basename as basename2, join as join11 } from "node:path";
@@ -16341,13 +16460,11 @@ var COORDINATOR_CONTROL_TOOL_NAMES = Object.freeze([
16341
16460
  "launch_graph",
16342
16461
  "launch_job",
16343
16462
  "launch_multi_review",
16344
- "launch_node_environment",
16345
16463
  "launch_terminal",
16346
16464
  "list_agents",
16347
16465
  "list_environments",
16348
16466
  "list_graph_templates",
16349
16467
  "list_mailboxes",
16350
- "list_node_environments",
16351
16468
  "list_nodes",
16352
16469
  "list_projects",
16353
16470
  "list_provider_accounts",
@@ -16376,16 +16493,11 @@ var COORDINATOR_CONTROL_TOOL_NAMES = Object.freeze([
16376
16493
  "resume_schedule",
16377
16494
  "run_worker_command",
16378
16495
  "send_message",
16379
- "send_node_message",
16380
- "send_prompt_to_node_tab",
16381
16496
  "send_prompt_to_tab",
16382
16497
  "set_worker_goal",
16383
16498
  "start_build_pipeline",
16384
16499
  "start_environment",
16385
- "start_multi_review",
16386
- "start_node_environment",
16387
16500
  "stop_environment",
16388
- "stop_node_environment",
16389
16501
  "stop_worker_turn",
16390
16502
  "switch_provider_account",
16391
16503
  "set_account_auto_switch",
@@ -16778,7 +16890,7 @@ async function readSessionIndex(path) {
16778
16890
  }
16779
16891
 
16780
16892
  // ../../bridges/codex-bridge/src/history/rollout.ts
16781
- var log3 = createLogger("bridge.codex");
16893
+ var log4 = createLogger("bridge.codex");
16782
16894
  function getCodexHomeDir() {
16783
16895
  return process.env.CODEX_HOME || join11(homedir(), ".codex");
16784
16896
  }
@@ -17347,7 +17459,7 @@ async function hydrateMessagesFromPersistedSession(threadId, options = {}) {
17347
17459
  };
17348
17460
  }
17349
17461
  }
17350
- log3.warn("rollout.hydrate-failed", { threadId });
17462
+ log4.warn("rollout.hydrate-failed", { threadId });
17351
17463
  return {
17352
17464
  messages: [],
17353
17465
  title: meta.title,
@@ -17371,7 +17483,7 @@ var NON_TOOL_TURN_ITEM_TYPES = new Set([
17371
17483
  ]);
17372
17484
  var MAX_OPEN_CODE_MODE_CELLS = 256;
17373
17485
  function replayedRowId(threadId, scope, kind, ordinal) {
17374
- const digest = createHash7("sha256").update(`${threadId}\x00${scope}\x00${kind}\x00${ordinal}`).digest("hex");
17486
+ const digest = createHash8("sha256").update(`${threadId}\x00${scope}\x00${kind}\x00${ordinal}`).digest("hex");
17375
17487
  return `msg-r-${digest.slice(0, 32)}`;
17376
17488
  }
17377
17489
  async function forEachHistoryBatch(snapshot, visit) {
@@ -17836,7 +17948,7 @@ async function replayPersistedRollout(threadId, snapshot, meta, structuredTurns)
17836
17948
  }
17837
17949
 
17838
17950
  // ../../bridges/codex-bridge/src/messages/render-turn.ts
17839
- var log4 = createLogger("bridge.codex");
17951
+ var log5 = createLogger("bridge.codex");
17840
17952
  var TRUNCATION_NOTICE = `
17841
17953
  … output truncated`;
17842
17954
  var SUBAGENT_TRANSCRIPT_PROBE_INTERVAL_MS = 2000;
@@ -18257,7 +18369,7 @@ async function renderTurn(turn, options) {
18257
18369
  loadSnapshot = latestSnapshot;
18258
18370
  }
18259
18371
  } catch (error) {
18260
- log4.warn("subagent.activity-load-failed", { error: formatLogError(error) });
18372
+ log5.warn("subagent.activity-load-failed", { error: formatLogError(error) });
18261
18373
  }
18262
18374
  }
18263
18375
  const { items, itemsByKey, accumulatorsByKey, versionsByKey, itemKeys } = collectTurnItems(turn, options.segment);
@@ -18648,7 +18760,7 @@ async function publishAssistantRows(context, state, turn, options) {
18648
18760
  }
18649
18761
 
18650
18762
  // ../../bridges/codex-bridge/src/app-server-runtime-sessions.ts
18651
- import { createHash as createHash12, randomUUID as randomUUID8 } from "node:crypto";
18763
+ import { createHash as createHash13, randomUUID as randomUUID8 } from "node:crypto";
18652
18764
 
18653
18765
  // ../protocol/src/agent-mail.ts
18654
18766
  var AGENT_MAIL_MAX_BODY_BYTES = 32 * 1024;
@@ -18702,10 +18814,178 @@ function agentMailCapabilities(tabType, agent, locked = true) {
18702
18814
  }
18703
18815
  var NATIVE_AGENT_MAIL_CAPABILITIES = Object.freeze(Object.fromEntries(AGENT_PLATFORMS.map((agent) => [agent, agentMailCapabilities("agent-native", agent)])));
18704
18816
 
18817
+ // ../protocol/src/rich-content-policy.ts
18818
+ var KIB = 1024;
18819
+ var MIB = 1024 * KIB;
18820
+ var CODE_BLOCK_POLICY = {
18821
+ maxHighlightBytes: 32 * KIB,
18822
+ maxHighlightLines: 2000,
18823
+ initialVisualLines: 24
18824
+ };
18825
+ var MERMAID_POLICY = {
18826
+ maxSourceBytes: 32 * KIB,
18827
+ maxEdges: 250,
18828
+ maxSvgBytes: 1 * MIB,
18829
+ maxSvgElements: 5000,
18830
+ renderTimeoutMs: 5000
18831
+ };
18832
+ var CHART_POLICY = {
18833
+ maxPayloadBytes: 256 * KIB,
18834
+ maxSeries: 6,
18835
+ maxBarCategories: 100,
18836
+ maxCartesianPoints: 2000,
18837
+ maxDonutSlices: 24,
18838
+ maxTitleCharacters: 200,
18839
+ maxLabelCharacters: 200,
18840
+ maxDescriptionCharacters: 2000,
18841
+ maxSourceNotes: 8,
18842
+ maxSourceNoteCharacters: 500,
18843
+ maxIdCharacters: 64,
18844
+ maxUnitCharacters: 32,
18845
+ maxAbsoluteValue: 1000000000000000,
18846
+ maxJsonDepth: 16
18847
+ };
18848
+ var WORKFLOW_SNAPSHOT_POLICY = {
18849
+ maxNormalizedBytes: 256 * KIB,
18850
+ maxNodes: 200,
18851
+ maxEdges: 400,
18852
+ maxIdCharacters: 128,
18853
+ maxLabelCharacters: 200,
18854
+ maxDescriptionCharacters: 2000,
18855
+ maxRawStatusCharacters: 100,
18856
+ maxLinksPerNode: 8
18857
+ };
18858
+ var STATIC_HTML_POLICY = {
18859
+ maxSourceBytes: 256 * KIB,
18860
+ maxPreparedBytes: 16 * MIB,
18861
+ maxElements: 5000
18862
+ };
18863
+ var STATIC_PRESENTATION_POLICY = {
18864
+ maxDocumentBytes: STATIC_HTML_POLICY.maxSourceBytes,
18865
+ maxElements: STATIC_HTML_POLICY.maxElements,
18866
+ maxFramesPerWindow: 4,
18867
+ renderTimeoutMs: 15000,
18868
+ maxSizeChangesPerWindow: 16,
18869
+ sizeChangeWindowMs: 5000,
18870
+ maxRefusedMessages: 100,
18871
+ maxSearchTextCharacters: 64 * KIB,
18872
+ searchTextChunkCharacters: 2 * KIB
18873
+ };
18874
+ var INTERACTIVE_HTML_POLICY = {
18875
+ maxAuthoredBytes: 512 * KIB,
18876
+ maxAssets: 32,
18877
+ maxAssetBytesTotal: 10 * MIB,
18878
+ maxDependencies: 4,
18879
+ maxPreparedBytes: 16 * MIB,
18880
+ maxRuntimeElements: 1e4,
18881
+ maxProbeSteps: 20,
18882
+ maxProbeStepMs: 2000,
18883
+ defaultWaitVisibleMs: 1000,
18884
+ maxProbeTextCharacters: 1024,
18885
+ probeTargetPattern: /^[A-Za-z][A-Za-z0-9_-]{0,63}$/
18886
+ };
18887
+ var PREVIEW_CAPTURE_POLICY = {
18888
+ maxPngBytes: 8 * MIB,
18889
+ maxPixels: 12000000,
18890
+ maxDimension: 4096,
18891
+ minDimension: 240,
18892
+ maxCapturesPerReceipt: 3,
18893
+ defaultViewport: { width: 960, height: 640, deviceScaleFactor: 1 }
18894
+ };
18895
+ var PREVIEW_ADMISSION_POLICY = {
18896
+ runningPerEnvironment: 1,
18897
+ runningGlobal: 2,
18898
+ queuedPerEnvironment: 8,
18899
+ queuedGlobal: 16,
18900
+ nonterminalPerConversation: 2,
18901
+ queuedMetadataBytesGlobal: 8 * MIB,
18902
+ queueWaitMs: 15000,
18903
+ workerWallMs: 30000,
18904
+ readinessMs: 5000,
18905
+ operationDeadlineMs: 45000,
18906
+ cleanupGraceMs: 2000,
18907
+ workerMemoryBytes: 1024 * MIB,
18908
+ workerCpus: 2,
18909
+ workerPids: 128
18910
+ };
18911
+ var FRONTEND_RENDER_POLICY = {
18912
+ highlightConcurrency: 2,
18913
+ diagramConcurrency: 1,
18914
+ maxQueuedJobs: 32,
18915
+ maxQueuedSourceBytes: 2 * MIB,
18916
+ maxSettledCacheEntries: 128,
18917
+ maxSettledCacheBytes: 16 * MIB,
18918
+ maxInactiveViewStateEntries: 500,
18919
+ maxActiveViewStateEntries: 200,
18920
+ maxPinnedViewStateEntries: 50,
18921
+ liveExecutableHostsPerWindow: 1,
18922
+ imageDecodeMaxPixels: 40000000,
18923
+ pdfPreviewMaxPages: 100,
18924
+ pdfPreviewMaxBytes: 20 * MIB
18925
+ };
18926
+ var PDF_POLICY = {
18927
+ maxPages: 100,
18928
+ maxBytes: 20 * MIB,
18929
+ thumbnailMaxDimension: 1024,
18930
+ thumbnailMaxPngBytes: 4 * MIB,
18931
+ imageDecodeMaxPixels: 40000000,
18932
+ printMarginMm: 10,
18933
+ previewCacheEntries: 32,
18934
+ previewCacheBytes: 16 * MIB
18935
+ };
18936
+ var DIAGNOSTIC_POLICY = {
18937
+ maxPersistedEntries: 50,
18938
+ maxEntryBytes: 2 * KIB,
18939
+ maxPersistedBytes: 32 * KIB,
18940
+ maxToolFieldErrors: 20,
18941
+ maxToolDiagnosticBytes: 8 * KIB
18942
+ };
18943
+ var ARTIFACT_TOOL_POLICY = {
18944
+ maxResultBytes: 16 * KIB,
18945
+ maxSourceSliceBytes: 8 * KIB,
18946
+ maxTitleCharacters: 120,
18947
+ maxSummaryCharacters: 400,
18948
+ maxRequestKeyCharacters: 128,
18949
+ maxRepairRevisions: 2,
18950
+ maxTransientRetries: 2,
18951
+ maxUnpublishedArtifactsPerConversation: 100,
18952
+ maxRevisionsPerArtifact: 100,
18953
+ assetStoreBytesPerEnvironment: 1024 * MIB,
18954
+ scopeCapabilityTtlMs: 24 * 60 * 60 * 1000
18955
+ };
18956
+ var ARTIFACT_RETENTION_POLICY = {
18957
+ cleanupIntervalMs: 60 * 60 * 1000,
18958
+ abandonedStagingMs: 60 * 60 * 1000,
18959
+ unpublishedDraftMs: 7 * 24 * 60 * 60 * 1000,
18960
+ unreferencedPreviewAssetMs: 24 * 60 * 60 * 1000
18961
+ };
18962
+ var FRAME_CHANNEL_POLICY = {
18963
+ maxMessageBytes: 8 * KIB,
18964
+ messagesPerSecond: 20,
18965
+ burst: 40,
18966
+ sizeUpdatesPerSecond: 4,
18967
+ minInlineHeight: 120,
18968
+ maxInlineHeight: 1600,
18969
+ maxLinkCharacters: 2048,
18970
+ maxLinkLabelCharacters: 200
18971
+ };
18972
+
18705
18973
  // ../protocol/src/agent-system-instructions.ts
18706
- 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.";
18974
+ 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.";
18707
18975
  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.";
18976
+ 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}]";
18977
+ 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}]}]}';
18978
+ var AGENT_VISUAL_OUTPUT_INSTRUCTION = [
18979
+ "Orkestrator displays rich visuals directly in the conversation; choose one when it helps answer the question.",
18980
+ `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}.`,
18981
+ "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.",
18982
+ `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.`,
18983
+ "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.",
18984
+ "Use ordinary images only for photographs, screenshots and requested image files.",
18985
+ "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."
18986
+ ].join(" ");
18708
18987
  var GENERAL_AGENT_INSTRUCTIONS = [
18988
+ AGENT_VISUAL_OUTPUT_INSTRUCTION,
18709
18989
  AGENT_IMAGE_PREVIEW_INSTRUCTION,
18710
18990
  AGENT_DOCUMENT_INSTRUCTION
18711
18991
  ];
@@ -18816,7 +19096,7 @@ var ORKESTRATOR_ARTIFACT_MCP_PATH = "/artifact-mcp";
18816
19096
 
18817
19097
  // ../../bridges/codex-bridge/src/engine/app-server-engine.ts
18818
19098
  import { open as open9 } from "node:fs/promises";
18819
- import { createHash as createHash11 } from "node:crypto";
19099
+ import { createHash as createHash12 } from "node:crypto";
18820
19100
  import { isAbsolute as isAbsolute9, join as join20 } from "node:path";
18821
19101
 
18822
19102
  // ../../bridges/codex-bridge/src/app-server/process-supervisor.ts
@@ -19086,7 +19366,7 @@ function extractThreadId(params) {
19086
19366
  }
19087
19367
 
19088
19368
  // ../../bridges/codex-bridge/src/app-server/jsonl-rpc-client.ts
19089
- var log5 = createLogger("bridge.codex");
19369
+ var log6 = createLogger("bridge.codex");
19090
19370
  var DEFAULT_MAX_INBOUND_LINE_BYTES = 64 * 1024 * 1024;
19091
19371
  var DEFAULT_MAX_OUTBOUND_LINE_BYTES = 32 * 1024 * 1024;
19092
19372
  var DEFAULT_REQUEST_TIMEOUT_MS = 60000;
@@ -19198,7 +19478,7 @@ class JsonlRpcClient {
19198
19478
  try {
19199
19479
  this.options.recordInboundLine(line);
19200
19480
  } catch (error) {
19201
- log5.error("recorder.threw", { error: formatLogError(error) });
19481
+ log6.error("recorder.threw", { error: formatLogError(error) });
19202
19482
  }
19203
19483
  }
19204
19484
  const message = parseInboundLine(line);
@@ -19230,7 +19510,7 @@ class JsonlRpcClient {
19230
19510
  try {
19231
19511
  this.options.onServerRequest(message);
19232
19512
  } catch (error) {
19233
- log5.error("server-request.handoff-failed", { error: formatLogError(error) });
19513
+ log6.error("server-request.handoff-failed", { error: formatLogError(error) });
19234
19514
  }
19235
19515
  return;
19236
19516
  }
@@ -19239,7 +19519,7 @@ class JsonlRpcClient {
19239
19519
  try {
19240
19520
  this.options.onNotification(message, extractThreadId(message.params), Buffer.byteLength(line, "utf8"));
19241
19521
  } catch (error) {
19242
- log5.error("notification.enqueue-failed", { error: formatLogError(error) });
19522
+ log6.error("notification.enqueue-failed", { error: formatLogError(error) });
19243
19523
  }
19244
19524
  return;
19245
19525
  }
@@ -19421,7 +19701,7 @@ class SerialQueue {
19421
19701
  run(key, task, bytes = 0) {
19422
19702
  if (this.depth >= this.maxDepth || this.bytes + bytes > this.maxBytes) {
19423
19703
  const overflow = { depth: this.depth, bytes: this.bytes };
19424
- log5.error("queue.overflow", overflow);
19704
+ log6.error("queue.overflow", overflow);
19425
19705
  this.clear();
19426
19706
  this.onOverflow?.(overflow);
19427
19707
  return;
@@ -19501,16 +19781,16 @@ class SerialQueue {
19501
19781
  queue.waiters.splice(0, resolved);
19502
19782
  }
19503
19783
  reportTaskFailure(key, error) {
19504
- log5.error("queue.task-failed", { key, error: formatLogError(error) });
19784
+ log6.error("queue.task-failed", { key, error: formatLogError(error) });
19505
19785
  }
19506
19786
  }
19507
19787
 
19508
19788
  // ../../bridges/codex-bridge/src/app-server/notification-recorder.ts
19509
19789
  import { appendFile as appendFile4, mkdir as mkdir5 } from "node:fs/promises";
19510
19790
  import { join as join13 } from "node:path";
19511
- var log6 = createLogger("bridge.codex");
19791
+ var log7 = createLogger("bridge.codex");
19512
19792
  function recorderNotice(message) {
19513
- log6.warn("recorder.notice", { detail: message });
19793
+ log7.warn("recorder.notice", { detail: message });
19514
19794
  }
19515
19795
  var DEFAULT_MAX_RECORDING_BYTES = 64 * 1024 * 1024;
19516
19796
  var DEFAULT_FLUSH_INTERVAL_MS = 250;
@@ -19623,7 +19903,7 @@ class NotificationRecorder {
19623
19903
  } catch (error) {
19624
19904
  this.stats.writeErrors += 1;
19625
19905
  this.stats.linesDropped += pending.length;
19626
- log6.error("recorder.write-failed", { error: formatLogError(error, { stack: false }) });
19906
+ log7.error("recorder.write-failed", { error: formatLogError(error, { stack: false }) });
19627
19907
  }
19628
19908
  }
19629
19909
  async close() {
@@ -19656,9 +19936,9 @@ function createRecorderFromEnv(options) {
19656
19936
 
19657
19937
  // ../../bridges/codex-bridge/src/runtime-env.ts
19658
19938
  import { execFile as execFileCallback } from "node:child_process";
19659
- import { createHash as createHash8 } from "node:crypto";
19939
+ import { createHash as createHash9 } from "node:crypto";
19660
19940
  import { promisify } from "node:util";
19661
- var log7 = createLogger("bridge.codex");
19941
+ var log8 = createLogger("bridge.codex");
19662
19942
  var execFile2 = promisify(execFileCallback);
19663
19943
  var RUNTIME_ENV_SCRIPT_ENV = "ORKESTRATOR_RUNTIME_ENV_SCRIPT";
19664
19944
  var DEFAULT_RUNTIME_ENV_SCRIPT = "/usr/local/bin/orkestrator-runtime-env.sh";
@@ -19736,14 +20016,14 @@ async function refreshRuntimeEnvironment(run = execFile2) {
19736
20016
  });
19737
20017
  const updated = applyRuntimeEnvironmentOutput(stdout);
19738
20018
  if (updated.length > 0) {
19739
- log7.info("runtime-env.refreshed", { names: updated.join(", ") });
20019
+ log8.info("runtime-env.refreshed", { names: updated.join(", ") });
19740
20020
  }
19741
20021
  } catch (error) {
19742
- log7.warn("runtime-env.refresh-failed", { error: formatLogError(error) });
20022
+ log8.warn("runtime-env.refresh-failed", { error: formatLogError(error) });
19743
20023
  }
19744
20024
  }
19745
20025
  function fingerprintRuntimeEnvironment(env = process.env) {
19746
- const hash = createHash8("sha256");
20026
+ const hash = createHash9("sha256");
19747
20027
  for (const name of [...RUNTIME_ENV_VARIABLES].sort()) {
19748
20028
  hash.update(name);
19749
20029
  hash.update("\x00");
@@ -19759,7 +20039,7 @@ function runtimeEnvironmentSnapshot(env = process.env) {
19759
20039
  }
19760
20040
 
19761
20041
  // ../../bridges/codex-bridge/src/app-server/process-supervisor.ts
19762
- var log8 = createLogger("bridge.codex");
20042
+ var log9 = createLogger("bridge.codex");
19763
20043
 
19764
20044
  class AppServerOwnershipUnavailableError extends AppServerUnavailableError {
19765
20045
  ownershipContention = true;
@@ -20045,7 +20325,7 @@ class AppServerSupervisor {
20045
20325
  if (describedLines >= STDERR_METADATA_LINE_BUDGET)
20046
20326
  return;
20047
20327
  describedLines += 1;
20048
- log8.info("app-server.stderr", () => ({
20328
+ log9.info("app-server.stderr", () => ({
20049
20329
  generation: generationId,
20050
20330
  detail: describeChildStderrLine(line)
20051
20331
  }));
@@ -20069,7 +20349,7 @@ class AppServerSupervisor {
20069
20349
  stderrTail = "";
20070
20350
  if (suppressedLines === 0)
20071
20351
  return;
20072
- log8.info("app-server.stderr-suppressed", {
20352
+ log9.info("app-server.stderr-suppressed", {
20073
20353
  generation: generationId,
20074
20354
  lines: suppressedLines,
20075
20355
  payloadBytes: suppressedBytes
@@ -20079,7 +20359,7 @@ class AppServerSupervisor {
20079
20359
  };
20080
20360
  const recorder = (this.options.createRecorder ?? ((generation) => createRecorderFromEnv({ generation })))(generationId);
20081
20361
  if (recorder) {
20082
- log8.warn("app-server.recording", {
20362
+ log9.warn("app-server.recording", {
20083
20363
  generation: generationId,
20084
20364
  fileName: recorder.getStats().fileName
20085
20365
  });
@@ -20092,7 +20372,7 @@ class AppServerSupervisor {
20092
20372
  onServerRequest: (request) => this.options.onServerRequest(request, generationId),
20093
20373
  onProtocolViolation: (detail) => {
20094
20374
  this.unknownNotifications += 1;
20095
- log8.warn("app-server.protocol-violation", { generation: generationId, detail });
20375
+ log9.warn("app-server.protocol-violation", { generation: generationId, detail });
20096
20376
  },
20097
20377
  ...recorder ? { recordInboundLine: (line) => recorder.record(line) } : {}
20098
20378
  });
@@ -20170,7 +20450,7 @@ class AppServerSupervisor {
20170
20450
  return;
20171
20451
  const exited = this.current;
20172
20452
  this.current = null;
20173
- log8.warn("app-server.exited", {
20453
+ log9.warn("app-server.exited", {
20174
20454
  generation: generationId,
20175
20455
  code,
20176
20456
  signal,
@@ -20190,7 +20470,7 @@ class AppServerSupervisor {
20190
20470
  const reason = "notification queue overflowed";
20191
20471
  this.lastError = reason;
20192
20472
  this.restartNow(reason).catch((error) => {
20193
- log8.error("app-server.overflow-restart-failed", { error: formatLogError(error) });
20473
+ log9.error("app-server.overflow-restart-failed", { error: formatLogError(error) });
20194
20474
  });
20195
20475
  }
20196
20476
  async ensureEnvironmentIsCurrent(options) {
@@ -20443,7 +20723,7 @@ class AppServerSupervisor {
20443
20723
  if (outcome === "contended")
20444
20724
  return true;
20445
20725
  if (matches && pid !== null) {
20446
- log8.info("app-server.stale-reaped", { pid });
20726
+ log9.info("app-server.stale-reaped", { pid });
20447
20727
  (this.options.signalPidFileProcess ?? signalStaleProcessTree)(pid);
20448
20728
  }
20449
20729
  return true;
@@ -21120,7 +21400,7 @@ function buildInteractionResponse(request, answer) {
21120
21400
  }
21121
21401
 
21122
21402
  // ../../bridges/codex-bridge/src/app-server/server-request-router.ts
21123
- var log9 = createLogger("bridge.codex");
21403
+ var log10 = createLogger("bridge.codex");
21124
21404
  var DEFAULT_RESPONSE_TIMEOUT_MS = 1e4;
21125
21405
  var DEFAULT_APPROVAL_TIMEOUT_MS = AGENT_INTERACTION_DEFAULT_TIMEOUT_MS;
21126
21406
 
@@ -21280,7 +21560,7 @@ class ServerRequestRouter {
21280
21560
  record.timedOut = true;
21281
21561
  this.counts.timedOut += 1;
21282
21562
  if (this.sendStarted.has(key)) {
21283
- log9.error("server-request.flush-timeout", {
21563
+ log10.error("server-request.flush-timeout", {
21284
21564
  method: record.method,
21285
21565
  timeoutMs: this.responseTimeoutMs
21286
21566
  });
@@ -21384,7 +21664,7 @@ class ServerRequestRouter {
21384
21664
  accepted = this.options.presentApproval?.(approval) === true;
21385
21665
  } catch (error) {
21386
21666
  deadline.settle();
21387
- log9.error("approval.present-failed", { error: formatLogError(error) });
21667
+ log10.error("approval.present-failed", { error: formatLogError(error) });
21388
21668
  return false;
21389
21669
  }
21390
21670
  if (!accepted) {
@@ -21421,7 +21701,7 @@ class ServerRequestRouter {
21421
21701
  try {
21422
21702
  this.options.onApprovalResolved?.(parked.request, decision, resolution);
21423
21703
  } catch (error) {
21424
- log9.error("approval.resolved-callback-failed", { error: formatLogError(error) });
21704
+ log10.error("approval.resolved-callback-failed", { error: formatLogError(error) });
21425
21705
  }
21426
21706
  if (options.skipSend) {
21427
21707
  this.pending.delete(parked.key);
@@ -21442,7 +21722,7 @@ class ServerRequestRouter {
21442
21722
  try {
21443
21723
  this.options.onApprovalResolved?.(parked.request, "withdrawn", "withdrawn");
21444
21724
  } catch (error) {
21445
- log9.error("approval.resolved-callback-failed", { error: formatLogError(error) });
21725
+ log10.error("approval.resolved-callback-failed", { error: formatLogError(error) });
21446
21726
  }
21447
21727
  this.pending.delete(parked.key);
21448
21728
  this.sendStarted.delete(parked.key);
@@ -21484,7 +21764,7 @@ class ServerRequestRouter {
21484
21764
  accepted = this.options.presentInteraction?.(interaction) === true;
21485
21765
  } catch (error) {
21486
21766
  deadline?.settle();
21487
- log9.error("interaction.present-failed", { error: formatLogError(error) });
21767
+ log10.error("interaction.present-failed", { error: formatLogError(error) });
21488
21768
  return false;
21489
21769
  }
21490
21770
  if (!accepted) {
@@ -21520,7 +21800,7 @@ class ServerRequestRouter {
21520
21800
  try {
21521
21801
  this.options.onInteractionResolved?.(parked.request, answer, resolution);
21522
21802
  } catch (error) {
21523
- log9.error("interaction.resolved-callback-failed", { error: formatLogError(error) });
21803
+ log10.error("interaction.resolved-callback-failed", { error: formatLogError(error) });
21524
21804
  }
21525
21805
  if (options.skipSend) {
21526
21806
  this.pending.delete(parked.key);
@@ -21553,7 +21833,7 @@ class ServerRequestRouter {
21553
21833
  try {
21554
21834
  await send();
21555
21835
  } catch (error) {
21556
- log9.error("server-request.answer-failed", {
21836
+ log10.error("server-request.answer-failed", {
21557
21837
  method: record.method,
21558
21838
  error: formatLogError(error, { stack: false })
21559
21839
  });
@@ -21570,7 +21850,7 @@ class ServerRequestRouter {
21570
21850
  }
21571
21851
  violation(method, detail) {
21572
21852
  this.options.onInvariantViolation?.(method, detail);
21573
- log9.error("app-server.invariant-violation", { method, detail });
21853
+ log10.error("app-server.invariant-violation", { method, detail });
21574
21854
  }
21575
21855
  explain(record, message) {
21576
21856
  this.options.reportToTranscript?.({
@@ -22156,12 +22436,12 @@ function reduceHistoricalTurns(turns, generation, threadId, handle) {
22156
22436
  }
22157
22437
 
22158
22438
  // ../../bridges/codex-bridge/src/sessions/dispatch-journal.ts
22159
- import { createHash as createHash10 } from "node:crypto";
22439
+ import { createHash as createHash11 } from "node:crypto";
22160
22440
  import { mkdir as mkdir8, open as open7, rename as rename6, rm as rm7, writeFile as writeFile5 } from "node:fs/promises";
22161
22441
  import { join as join16 } from "node:path";
22162
22442
 
22163
22443
  // ../../bridges/codex-bridge/src/sessions/persistence.ts
22164
- import { createHash as createHash9, randomUUID as randomUUID7 } from "node:crypto";
22444
+ import { createHash as createHash10, randomUUID as randomUUID7 } from "node:crypto";
22165
22445
  import {
22166
22446
  chmod,
22167
22447
  link as link2,
@@ -22174,7 +22454,7 @@ import {
22174
22454
  writeFile as writeFile4
22175
22455
  } from "node:fs/promises";
22176
22456
  import { join as join15 } from "node:path";
22177
- var log10 = createLogger("bridge.codex");
22457
+ var log11 = createLogger("bridge.codex");
22178
22458
  var BRIDGE_SESSION_REGISTRY_VERSION = 2;
22179
22459
  var SESSION_TITLE_SOURCES = new Set([
22180
22460
  "codex",
@@ -22256,7 +22536,7 @@ function isPersistedSessionTombstone(value) {
22256
22536
  return tombstone.deleted === true && typeof tombstone.bridgeSessionId === "string" && tombstone.bridgeSessionId.length > 0 && typeof tombstone.deletedAt === "string" && Number.isFinite(Date.parse(tombstone.deletedAt));
22257
22537
  }
22258
22538
  function hashCwd(cwd) {
22259
- return createHash9("sha256").update(cwd).digest("hex").slice(0, 16);
22539
+ return createHash10("sha256").update(cwd).digest("hex").slice(0, 16);
22260
22540
  }
22261
22541
  var DEFAULT_RETENTION_MS = 7 * 24 * 60 * 60 * 1000;
22262
22542
  var RECORD_FILE_MISSING = Symbol("record-file-missing");
@@ -22290,7 +22570,7 @@ class BridgeSessionStore {
22290
22570
  return directory === this.recordsDir() ? undefined : directory;
22291
22571
  }
22292
22572
  recordKey(bridgeSessionId) {
22293
- return createHash9("sha256").update(bridgeSessionId).digest("hex");
22573
+ return createHash10("sha256").update(bridgeSessionId).digest("hex");
22294
22574
  }
22295
22575
  recordPath(bridgeSessionId) {
22296
22576
  return join15(this.recordsDir(), `${this.recordKey(bridgeSessionId)}.json`);
@@ -22513,7 +22793,7 @@ class BridgeSessionStore {
22513
22793
  await chmod(path, PRIVATE_FILE_MODE);
22514
22794
  }
22515
22795
  warnPersistenceFailure(error) {
22516
- log10.warn("registry.persist-failed", { error: formatLogError(error, { stack: false }) });
22796
+ log11.warn("registry.persist-failed", { error: formatLogError(error, { stack: false }) });
22517
22797
  }
22518
22798
  toRecord(options) {
22519
22799
  const { agentMcp: _agentMcp, ...persistedConfig } = options.config;
@@ -22537,7 +22817,7 @@ class BridgeSessionStore {
22537
22817
  }
22538
22818
 
22539
22819
  // ../../bridges/codex-bridge/src/sessions/dispatch-journal.ts
22540
- var log11 = createLogger("bridge.codex");
22820
+ var log12 = createLogger("bridge.codex");
22541
22821
  var DISPATCH_JOURNAL_VERSION = 1;
22542
22822
  var DISPATCH_COMPLETENESS_VERSION = 1;
22543
22823
  var MAX_FRESH_SESSION_MARKERS = 256;
@@ -22953,7 +23233,7 @@ class DispatchJournal {
22953
23233
  this.filterAdd(requestId);
22954
23234
  }
22955
23235
  filterPositions(requestId) {
22956
- const digest = createHash10("sha256").update(requestId, "utf8").digest();
23236
+ const digest = createHash11("sha256").update(requestId, "utf8").digest();
22957
23237
  const positions = [];
22958
23238
  for (let index = 0;index < UNTRACKED_FILTER_HASHES; index += 1) {
22959
23239
  positions.push(digest.readUInt32BE(index * 4) % UNTRACKED_FILTER_BITS);
@@ -23076,7 +23356,7 @@ class DispatchJournal {
23076
23356
  throw error;
23077
23357
  });
23078
23358
  } catch (error) {
23079
- log11.warn("journal.persist-failed", { error: formatLogError(error, { stack: false }) });
23359
+ log12.warn("journal.persist-failed", { error: formatLogError(error, { stack: false }) });
23080
23360
  if (options.failClosed)
23081
23361
  throw error;
23082
23362
  }
@@ -23828,7 +24108,7 @@ var APP_SERVER_CAPABILITIES = {
23828
24108
  };
23829
24109
 
23830
24110
  // ../../bridges/codex-bridge/src/engine/app-server-engine.ts
23831
- var log12 = createLogger("bridge.codex");
24111
+ var log13 = createLogger("bridge.codex");
23832
24112
  var AGENT_MAIL_TOOL_APPROVALS = Object.fromEntries([
23833
24113
  ...AGENT_MAIL_TOOL_NAMES,
23834
24114
  ...ARTIFACT_TOOL_NAMES,
@@ -24203,7 +24483,7 @@ async function readStoredLoginFingerprint(codexHome) {
24203
24483
  const apiKey = typeof root.OPENAI_API_KEY === "string" ? root.OPENAI_API_KEY : "";
24204
24484
  if (!refreshToken && !apiKey)
24205
24485
  return;
24206
- return createHash11("sha256").update(JSON.stringify([refreshToken, apiKey])).digest("hex");
24486
+ return createHash12("sha256").update(JSON.stringify([refreshToken, apiKey])).digest("hex");
24207
24487
  } catch {
24208
24488
  return;
24209
24489
  }
@@ -24413,7 +24693,7 @@ class AppServerEngine {
24413
24693
  try {
24414
24694
  listener(event);
24415
24695
  } catch (error) {
24416
- log12.error("engine.listener-failed", { error: formatLogError(error) });
24696
+ log13.error("engine.listener-failed", { error: formatLogError(error) });
24417
24697
  }
24418
24698
  }
24419
24699
  }
@@ -24538,7 +24818,7 @@ class AppServerEngine {
24538
24818
  const sequence = ++this.accountCheckSequence;
24539
24819
  const generation = this.supervisor.getGeneration();
24540
24820
  this.supervisor.request("account/read", { refreshToken }).catch(signedOutAccountRead).then((response) => this.applyAccountRead(response, sequence, generation, accountReplaced)).catch((error) => {
24541
- log12.warn("account.sign-in-check-failed", {
24821
+ log13.warn("account.sign-in-check-failed", {
24542
24822
  error: formatLogError(error, { stack: false })
24543
24823
  });
24544
24824
  });
@@ -25125,7 +25405,7 @@ class AppServerEngine {
25125
25405
  const generation = this.supervisor.getGeneration();
25126
25406
  const response = await this.supervisor.request("account/read", { refreshToken: false }).catch(signedOutAccountRead);
25127
25407
  this.applyAccountRead(response, sequence, generation, false).catch((error) => {
25128
- log12.warn("account.connector-recovery-failed", {
25408
+ log13.warn("account.connector-recovery-failed", {
25129
25409
  error: formatLogError(error, { stack: false })
25130
25410
  });
25131
25411
  });
@@ -25338,7 +25618,7 @@ class AppServerEngine {
25338
25618
  await this.supervisor.request("thread/name/set", { threadId, name });
25339
25619
  return true;
25340
25620
  } catch (error) {
25341
- log12.warn("thread.rename-failed", { error: formatLogError(error, { stack: false }) });
25621
+ log13.warn("thread.rename-failed", { error: formatLogError(error, { stack: false }) });
25342
25622
  return false;
25343
25623
  }
25344
25624
  }
@@ -25358,7 +25638,7 @@ class AppServerEngine {
25358
25638
  } catch (error) {
25359
25639
  if (requireConfirmation)
25360
25640
  throw error;
25361
- log12.warn("thread.unsubscribe-failed", { error: formatLogError(error, { stack: false }) });
25641
+ log13.warn("thread.unsubscribe-failed", { error: formatLogError(error, { stack: false }) });
25362
25642
  }
25363
25643
  this.accountProofTurns.delete(threadId);
25364
25644
  this.rolloutPaths.delete(threadId);
@@ -25828,7 +26108,7 @@ class ThreadRegistry {
25828
26108
  if (busy)
25829
26109
  throw new OverlappingTurnError(context.threadId);
25830
26110
  }
25831
- setPhase(context, phase, error) {
26111
+ setPhase(context, phase, error, errorCode) {
25832
26112
  if (phase === "starting") {
25833
26113
  context.turnStartedAt = new Date(this.now()).toISOString();
25834
26114
  } else if ((phase === "running" || phase === "cancelling" || phase === "recovering") && context.turnStartedAt === undefined && context.activeTurn) {
@@ -25838,6 +26118,7 @@ class ThreadRegistry {
25838
26118
  }
25839
26119
  context.phase = phase;
25840
26120
  context.error = phase === "failed" ? error : undefined;
26121
+ context.errorCode = phase === "failed" ? errorCode : undefined;
25841
26122
  }
25842
26123
  sessionsForThread(threadId) {
25843
26124
  const context = this.threads.get(threadId);
@@ -25903,7 +26184,7 @@ function externalRevertCut(messages, survivingTurnIds, running) {
25903
26184
  }
25904
26185
 
25905
26186
  // ../../bridges/codex-bridge/src/app-server-runtime-sessions.ts
25906
- var log13 = createLogger("bridge.codex");
26187
+ var log14 = createLogger("bridge.codex");
25907
26188
  var SESSION_CLOSING_ERROR = "Session is closing";
25908
26189
  var ACTIVITY_PROCESS = randomUUID8();
25909
26190
 
@@ -25920,7 +26201,7 @@ class CodexRuntimeSessions {
25920
26201
  }
25921
26202
  createSession(body) {
25922
26203
  const clientSessionKey = typeof body.clientSessionKey === "string" && body.clientSessionKey.trim().length > 0 && body.clientSessionKey.length <= 512 ? body.clientSessionKey : undefined;
25923
- const sessionId = clientSessionKey ? `session-client-${createHash12("sha256").update(this.ctx.options.cwd).update("\x00").update(clientSessionKey).digest("hex").slice(0, 32)}` : createSessionId();
26204
+ const sessionId = clientSessionKey ? `session-client-${createHash13("sha256").update(this.ctx.options.cwd).update("\x00").update(clientSessionKey).digest("hex").slice(0, 32)}` : createSessionId();
25924
26205
  const existing = this.ctx.registry.getSession(sessionId);
25925
26206
  if (existing) {
25926
26207
  this.ctx.registry.touch(sessionId);
@@ -26058,7 +26339,7 @@ class CodexRuntimeSessions {
26058
26339
  try {
26059
26340
  fork = await this.ctx.options.engine.forkThread(parent.threadId, parent.config, lastTurnId);
26060
26341
  } catch (error) {
26061
- log13.warn("thread.fork-failed", {
26342
+ log14.warn("thread.fork-failed", {
26062
26343
  threadId: parent.threadId,
26063
26344
  error: formatLogError(error, { stack: false })
26064
26345
  });
@@ -26110,7 +26391,7 @@ class CodexRuntimeSessions {
26110
26391
  await this.ctx.callbacks.deleteSession(child.id).catch(() => {
26111
26392
  return;
26112
26393
  });
26113
- log13.warn("thread.fork-hydrate-failed", {
26394
+ log14.warn("thread.fork-hydrate-failed", {
26114
26395
  threadId: parent.threadId,
26115
26396
  error: formatLogError(error, { stack: false })
26116
26397
  });
@@ -26125,7 +26406,7 @@ class CodexRuntimeSessions {
26125
26406
  });
26126
26407
  turns = thread?.turns;
26127
26408
  } catch (error) {
26128
- log13.warn("thread.turns-read-failed", {
26409
+ log14.warn("thread.turns-read-failed", {
26129
26410
  threadId: context.threadId,
26130
26411
  error: formatLogError(error, { stack: false })
26131
26412
  });
@@ -26242,7 +26523,7 @@ class CodexRuntimeSessions {
26242
26523
  return "not-found";
26243
26524
  if (this.sessionAdmissionClosed(session))
26244
26525
  return "closing";
26245
- const inputDigest = createHash12("sha256").update(input).digest("hex");
26526
+ const inputDigest = createHash13("sha256").update(input).digest("hex");
26246
26527
  const previous = this.ctx.steerRequests.get(requestId);
26247
26528
  if (previous) {
26248
26529
  if (previous.threadId !== session.threadId || previous.turnId !== expectedTurnId || previous.inputDigest !== inputDigest) {
@@ -26460,6 +26741,7 @@ class CodexRuntimeSessions {
26460
26741
  }
26461
26742
  const phaseBeforeReview = context.phase;
26462
26743
  const errorBeforeReview = context.error;
26744
+ const errorCodeBeforeReview = context.errorCode;
26463
26745
  context.dispatchInFlight = true;
26464
26746
  this.ctx.registry.setPhase(context, "starting");
26465
26747
  await this.ctx.callbacks.primeCommandChanges(context);
@@ -26525,7 +26807,7 @@ class CodexRuntimeSessions {
26525
26807
  });
26526
26808
  }
26527
26809
  if (context.phase === "starting") {
26528
- this.ctx.registry.setPhase(context, phaseBeforeReview, errorBeforeReview);
26810
+ this.ctx.registry.setPhase(context, phaseBeforeReview, errorBeforeReview, errorCodeBeforeReview);
26529
26811
  }
26530
26812
  this.lifecycle.emitStatus(context);
26531
26813
  const message = error instanceof Error ? error.message : "Native review failed";
@@ -26616,7 +26898,7 @@ class CodexRuntimeSessions {
26616
26898
  try {
26617
26899
  turns = (await this.ctx.options.engine.readThread(context.threadId, { includeTurns: true }))?.turns;
26618
26900
  } catch (error) {
26619
- log13.warn("thread.turns-read-after-revert-failed", {
26901
+ log14.warn("thread.turns-read-after-revert-failed", {
26620
26902
  threadId: context.threadId,
26621
26903
  error: formatLogError(error, { stack: false })
26622
26904
  });
@@ -26717,7 +26999,7 @@ class CodexRuntimeSessions {
26717
26999
  }
26718
27000
  } catch (error) {
26719
27001
  await restoreEngineConfig();
26720
- log13.warn("session.config-apply-failed", {
27002
+ log14.warn("session.config-apply-failed", {
26721
27003
  sessionId,
26722
27004
  error: formatLogError(error, { stack: false })
26723
27005
  });
@@ -26760,7 +27042,7 @@ class CodexRuntimeSessions {
26760
27042
  try {
26761
27043
  context = await this.ctx.callbacks.ensureAttached(sessionId);
26762
27044
  } catch (error) {
26763
- log13.warn("transcript.serving-last-known", {
27045
+ log14.warn("transcript.serving-last-known", {
26764
27046
  sessionId,
26765
27047
  error: formatLogError(error, { stack: false })
26766
27048
  });
@@ -26844,6 +27126,7 @@ class CodexRuntimeSessions {
26844
27126
  phase,
26845
27127
  title: session.titleSource === "prompt" ? undefined : session.title,
26846
27128
  error,
27129
+ ...phase === "failed" && error !== undefined && context?.errorCode === "usageLimitExceeded" ? { errorCode: USAGE_LIMIT_ERROR_CODE } : {},
26847
27130
  ...phase === "failed" && session.restartFailure && error === CODEX_RESTARTED_MID_TURN_MESSAGE ? {
26848
27131
  interruption: "restart",
26849
27132
  ...interruptedRequestId ? { interruptedRequestId } : {}
@@ -26962,7 +27245,7 @@ class CodexRuntimeSessions {
26962
27245
  }
26963
27246
  return "unpublished";
26964
27247
  }
26965
- log13.warn("registry.persist-failed", { error: formatLogError(error, { stack: false }) });
27248
+ log14.warn("registry.persist-failed", { error: formatLogError(error, { stack: false }) });
26966
27249
  }
26967
27250
  if (this.ctx.registry.getSession(sessionId) !== session)
26968
27251
  return "released";
@@ -27056,7 +27339,7 @@ class CodexRuntimeSessions {
27056
27339
  }
27057
27340
  }
27058
27341
  // ../../bridges/codex-bridge/src/app-server-runtime-approvals.ts
27059
- var log14 = createLogger("bridge.codex");
27342
+ var log15 = createLogger("bridge.codex");
27060
27343
 
27061
27344
  class CodexRuntimeApprovals {
27062
27345
  ctx;
@@ -27147,7 +27430,7 @@ class CodexRuntimeApprovals {
27147
27430
  if (this.ctx.options.engine.resolveApproval(approvalId, decision)) {
27148
27431
  if (decision === "cancel") {
27149
27432
  this.ctx.callbacks.abort(sessionId).catch((error) => {
27150
- log14.error("approval.cancel-failed", { error: formatLogError(error) });
27433
+ log15.error("approval.cancel-failed", { error: formatLogError(error) });
27151
27434
  });
27152
27435
  }
27153
27436
  return "applied";
@@ -27268,7 +27551,7 @@ function parseCommandToken(text, sigils = ["/"]) {
27268
27551
  }
27269
27552
 
27270
27553
  // ../../bridges/codex-bridge/src/prompts/template-discovery.ts
27271
- import { createHash as createHash13 } from "node:crypto";
27554
+ import { createHash as createHash14 } from "node:crypto";
27272
27555
  import { open as open10, readdir as readdir3, stat as stat8 } from "node:fs/promises";
27273
27556
  import { join as join21 } from "node:path";
27274
27557
  var TEMPLATE_LIMITS = Object.freeze({
@@ -27301,7 +27584,7 @@ function templateBindingRevision(origin, relativePath) {
27301
27584
  return commandBindingRevision(["template", origin, relativePath]);
27302
27585
  }
27303
27586
  function fingerprintOf(bytes) {
27304
- return createHash13("sha256").update(bytes).digest("hex").slice(0, 32);
27587
+ return createHash14("sha256").update(bytes).digest("hex").slice(0, 32);
27305
27588
  }
27306
27589
  function nameFromRelativePath(relativePath) {
27307
27590
  return `/${relativePath.replace(/\.md$/i, "")}`;
@@ -28554,7 +28837,7 @@ class UpdateCoalescer {
28554
28837
 
28555
28838
  // ../../bridges/codex-bridge/src/app-server-runtime-capacity-retry.ts
28556
28839
  import { stat as stat9 } from "node:fs/promises";
28557
- var log15 = createLogger("bridge.codex");
28840
+ var log16 = createLogger("bridge.codex");
28558
28841
 
28559
28842
  class CodexCapacityRetry {
28560
28843
  ctx;
@@ -28668,7 +28951,7 @@ class CodexCapacityRetry {
28668
28951
  }
28669
28952
  entry.stage = "starting";
28670
28953
  const work = this.startContinuation(context, turn, entry).catch((error) => {
28671
- log15.error("turn.capacity-retry-failed", {
28954
+ log16.error("turn.capacity-retry-failed", {
28672
28955
  turnId: turn.turnId,
28673
28956
  error: formatLogError(error, { stack: false })
28674
28957
  });
@@ -28740,7 +29023,7 @@ class CodexCapacityRetry {
28740
29023
  });
28741
29024
  return;
28742
29025
  }
28743
- await this.ctx.journal.markAccepted(requestId, { threadId: context.threadId, turnId: started.turnId }).catch((error) => log15.warn("turn.capacity-retry-journal-failed", {
29026
+ await this.ctx.journal.markAccepted(requestId, { threadId: context.threadId, turnId: started.turnId }).catch((error) => log16.warn("turn.capacity-retry-journal-failed", {
28744
29027
  requestId,
28745
29028
  error: formatLogError(error, { stack: false })
28746
29029
  }));
@@ -28811,7 +29094,7 @@ class CodexCapacityRetry {
28811
29094
  }
28812
29095
 
28813
29096
  // ../../bridges/codex-bridge/src/app-server-runtime-lifecycle.ts
28814
- var log16 = createLogger("bridge.codex");
29097
+ var log17 = createLogger("bridge.codex");
28815
29098
  function artifactConnectionToken(value) {
28816
29099
  if (!value || typeof value !== "object" || Array.isArray(value))
28817
29100
  return;
@@ -28996,7 +29279,7 @@ class CodexRuntimeLifecycle {
28996
29279
  this.ctx.registry.setPhase(existing, "recovering");
28997
29280
  this.emitStatus(existing);
28998
29281
  this.ctx.callbacks.scheduleRecoveryBackstop(existing);
28999
- log16.warn("dispatch.restore-failed", {
29282
+ log17.warn("dispatch.restore-failed", {
29000
29283
  requestId: record.requestId,
29001
29284
  error: formatLogError(error, { stack: false })
29002
29285
  });
@@ -29175,7 +29458,7 @@ class CodexRuntimeLifecycle {
29175
29458
  });
29176
29459
  }));
29177
29460
  }
29178
- log16.warn("thread.reattach-failed", {
29461
+ log17.warn("thread.reattach-failed", {
29179
29462
  threadId,
29180
29463
  rolloutMissing: isMissingRolloutError(error),
29181
29464
  error: formatLogError(error, { stack: false })
@@ -29256,7 +29539,7 @@ class CodexRuntimeLifecycle {
29256
29539
  coalescer: new UpdateCoalescer({
29257
29540
  intervalMs: this.ctx.options.coalesceIntervalMs ?? (() => messageSnapshotIntervalMs(this.ctx.threadState.get(threadId)?.lastPublishedSnapshotChars ?? 0)),
29258
29541
  publish: () => this.ctx.callbacks.publishAssistantMessage(threadId),
29259
- onError: (error) => log16.error("message.publish-failed", { error: formatLogError(error) })
29542
+ onError: (error) => log17.error("message.publish-failed", { error: formatLogError(error) })
29260
29543
  })
29261
29544
  };
29262
29545
  this.ctx.threadState.set(threadId, state);
@@ -29292,7 +29575,7 @@ class CodexRuntimeLifecycle {
29292
29575
  this.ctx.commandCatalogue.withdrawGeneration(event.generation);
29293
29576
  const recovery = this.ctx.generationRecovery.then(() => this.ctx.callbacks.recoverAfterGenerationChange(event.generation));
29294
29577
  this.ctx.generationRecovery = recovery.catch((error) => {
29295
- log16.error("generation.recovery-failed", { error: formatLogError(error) });
29578
+ log17.error("generation.recovery-failed", { error: formatLogError(error) });
29296
29579
  });
29297
29580
  return;
29298
29581
  }
@@ -29312,7 +29595,7 @@ class CodexRuntimeLifecycle {
29312
29595
  }
29313
29596
  if (event.kind === "account.reload.requested") {
29314
29597
  this.ctx.callbacks.reloadStoredAccountLogin().catch((error) => {
29315
- log16.warn("account.login-reload-failed", { error: formatLogError(error, { stack: false }) });
29598
+ log17.warn("account.login-reload-failed", { error: formatLogError(error, { stack: false }) });
29316
29599
  });
29317
29600
  return;
29318
29601
  }
@@ -29615,7 +29898,7 @@ class CodexRuntimeLifecycle {
29615
29898
  }
29616
29899
  this.ctx.options.changeEvidence?.turn(this.evidenceSource(context, turn), event.status);
29617
29900
  const finalize = () => this.runFinalization(context, turn).catch((error) => {
29618
- log16.error("turn.finalize-failed", {
29901
+ log17.error("turn.finalize-failed", {
29619
29902
  turnId: turn.turnId,
29620
29903
  error: formatLogError(error, { stack: false })
29621
29904
  });
@@ -29833,7 +30116,7 @@ class CodexRuntimeLifecycle {
29833
30116
  }
29834
30117
  trackCommandChangeWork(work) {
29835
30118
  const tracked = work.catch((error) => {
29836
- log16.warn("command-changes.record-failed", { error: formatLogError(error, { stack: false }) });
30119
+ log17.warn("command-changes.record-failed", { error: formatLogError(error, { stack: false }) });
29837
30120
  });
29838
30121
  this.ctx.pendingCommandChanges.add(tracked);
29839
30122
  tracked.finally(() => this.ctx.pendingCommandChanges.delete(tracked));
@@ -30045,6 +30328,7 @@ class CodexRuntimeLifecycle {
30045
30328
  }
30046
30329
  const phaseBeforeRebind = context.phase;
30047
30330
  const errorBeforeRebind = context.error;
30331
+ const errorCodeBeforeRebind = context.errorCode;
30048
30332
  const turn = context.activeTurn;
30049
30333
  try {
30050
30334
  if (!context.materialized) {
@@ -30070,7 +30354,7 @@ class CodexRuntimeLifecycle {
30070
30354
  context.unsubscribed = false;
30071
30355
  context.engineGeneration = generation;
30072
30356
  if (!turn) {
30073
- this.ctx.registry.setPhase(context, phaseBeforeRebind === "failed" ? "failed" : "idle", phaseBeforeRebind === "failed" ? errorBeforeRebind : undefined);
30357
+ this.ctx.registry.setPhase(context, phaseBeforeRebind === "failed" ? "failed" : "idle", phaseBeforeRebind === "failed" ? errorBeforeRebind : undefined, phaseBeforeRebind === "failed" ? errorCodeBeforeRebind : undefined);
30074
30358
  this.emitStatus(context);
30075
30359
  continue;
30076
30360
  }
@@ -30195,7 +30479,7 @@ class CodexRuntimeLifecycle {
30195
30479
  await Promise.all(restartNoticeSessions.map((session) => this.ctx.callbacks.persistSession(session)));
30196
30480
  }
30197
30481
  context.activeTurn = null;
30198
- this.ctx.registry.setPhase(context, turn.phase === "failed" ? "failed" : "idle", turn.error?.message);
30482
+ this.ctx.registry.setPhase(context, turn.phase === "failed" ? "failed" : "idle", turn.error?.message, turn.error?.code);
30199
30483
  state.assistantMessageId = undefined;
30200
30484
  this.ctx.callbacks.notifyThreadActivity();
30201
30485
  for (const sessionId of context.bridgeSessionIds) {
@@ -30276,7 +30560,7 @@ class CodexRuntimeLifecycle {
30276
30560
  try {
30277
30561
  await state.coalescer.flushNow();
30278
30562
  } catch (error) {
30279
- log16.error("ordered-events.flush-failed", { error: formatLogError(error) });
30563
+ log17.error("ordered-events.flush-failed", { error: formatLogError(error) });
30280
30564
  }
30281
30565
  state.orderedReconcilePending = false;
30282
30566
  for (const sessionId of this.ctx.sessionIdsForThread(threadId)) {
@@ -30295,7 +30579,7 @@ class CodexRuntimeLifecycle {
30295
30579
  await state.coalescer.flushNow();
30296
30580
  event.publish();
30297
30581
  } catch (error) {
30298
- log16.error("ordered-events.publish-failed", { error: formatLogError(error) });
30582
+ log17.error("ordered-events.publish-failed", { error: formatLogError(error) });
30299
30583
  state.orderedEvents.length = 0;
30300
30584
  state.orderedEventBytes = 0;
30301
30585
  state.orderedReconcilePending = true;
@@ -30304,7 +30588,7 @@ class CodexRuntimeLifecycle {
30304
30588
  }
30305
30589
  }
30306
30590
  } catch (error) {
30307
- log16.error("ordered-events.reconcile-failed", { error: formatLogError(error) });
30591
+ log17.error("ordered-events.reconcile-failed", { error: formatLogError(error) });
30308
30592
  } finally {
30309
30593
  state.orderedEventDraining = false;
30310
30594
  if ((state.orderedReconcilePending || state.orderedEvents.length > 0) && this.ctx.threadState.get(threadId) === state) {
@@ -30420,7 +30704,7 @@ function isTabInitialPromptRequestId(requestId) {
30420
30704
  }
30421
30705
 
30422
30706
  // ../../bridges/codex-bridge/src/app-server-runtime-prompt.ts
30423
- var log17 = createLogger("bridge.codex");
30707
+ var log18 = createLogger("bridge.codex");
30424
30708
  function commandRefusal(message) {
30425
30709
  return { ok: false, status: 422, error: message, kind: "command-unavailable" };
30426
30710
  }
@@ -31082,7 +31366,7 @@ class CodexRuntimePrompt {
31082
31366
  try {
31083
31367
  outcome = await this.ctx.options.engine.reconcileRequest(context.threadId, accumulator.providerRequestId);
31084
31368
  } catch (error) {
31085
- log17.warn("dispatch.reconcile-failed", {
31369
+ log18.warn("dispatch.reconcile-failed", {
31086
31370
  requestId,
31087
31371
  threadId: context.threadId,
31088
31372
  error: formatLogError(error, { stack: false })
@@ -31357,7 +31641,7 @@ class CodexRuntimePrompt {
31357
31641
  if (this.ctx.stopping || this.shouldAbandonDrain(expectedGeneration))
31358
31642
  return;
31359
31643
  if (Date.now() >= deadline) {
31360
- log17.warn("app-server.drain-expired");
31644
+ log18.warn("app-server.drain-expired");
31361
31645
  return;
31362
31646
  }
31363
31647
  await this.waitForThreadActivity();
@@ -31391,7 +31675,7 @@ class CodexRuntimePrompt {
31391
31675
 
31392
31676
  // ../../bridges/codex-bridge/src/app-server-runtime-tail.ts
31393
31677
  import { join as join22, relative as relative4, isAbsolute as isAbsolute11 } from "node:path";
31394
- var log18 = createLogger("bridge.codex");
31678
+ var log19 = createLogger("bridge.codex");
31395
31679
 
31396
31680
  class CodexRuntimeTail {
31397
31681
  ctx;
@@ -31540,7 +31824,7 @@ class CodexRuntimeTail {
31540
31824
  };
31541
31825
  }
31542
31826
  } catch (error) {
31543
- log18.warn("models.list-failed", { error: formatLogError(error, { stack: false }) });
31827
+ log19.warn("models.list-failed", { error: formatLogError(error, { stack: false }) });
31544
31828
  }
31545
31829
  return this.ctx.options.loadCachedModels();
31546
31830
  }
@@ -31566,7 +31850,7 @@ class CodexRuntimeTail {
31566
31850
  });
31567
31851
  }
31568
31852
  } catch (error) {
31569
- log18.warn("threads.list-failed", { error: formatLogError(error, { stack: false }) });
31853
+ log19.warn("threads.list-failed", { error: formatLogError(error, { stack: false }) });
31570
31854
  }
31571
31855
  const archived = new Set;
31572
31856
  try {
@@ -31651,7 +31935,7 @@ class CodexRuntimeTail {
31651
31935
  else
31652
31936
  await this.ctx.options.engine.unarchiveThread(threadId);
31653
31937
  } catch (error) {
31654
- log18.warn("thread.archive-failed", {
31938
+ log19.warn("thread.archive-failed", {
31655
31939
  archived,
31656
31940
  error: formatLogError(error, { stack: false })
31657
31941
  });
@@ -31984,7 +32268,7 @@ class AppServerRuntime {
31984
32268
  }
31985
32269
  }
31986
32270
 
31987
- // ../../bridges/codex-bridge/src/event-ring.ts
32271
+ // ../protocol/src/node/event-ring.ts
31988
32272
  var DEFAULT_RING_CAPACITY = 512;
31989
32273
 
31990
32274
  class EventRing {
@@ -32023,6 +32307,32 @@ class EventRing {
32023
32307
  }
32024
32308
  append(event) {
32025
32309
  this.revision += 1;
32310
+ this.retain(event);
32311
+ return this.revision;
32312
+ }
32313
+ appendAt(revision, event) {
32314
+ this.skipTo(revision - 1);
32315
+ this.revision = revision;
32316
+ this.retain(event);
32317
+ }
32318
+ advance() {
32319
+ this.advanceTo(this.revision + 1);
32320
+ return this.revision;
32321
+ }
32322
+ advanceTo(revision) {
32323
+ this.skipTo(revision);
32324
+ this.revision = revision;
32325
+ }
32326
+ skipTo(revision) {
32327
+ if (!Number.isSafeInteger(revision) || revision < this.revision) {
32328
+ throw new RangeError("EventRing: revisions must not go backwards");
32329
+ }
32330
+ if (revision > this.revision && this.buffer.length > 0) {
32331
+ this.droppedEvents += this.buffer.length;
32332
+ this.clear();
32333
+ }
32334
+ }
32335
+ retain(event) {
32026
32336
  if (this.supersede)
32027
32337
  this.collapseSuperseded(event);
32028
32338
  this.retainedBytes += Math.max(0, this.measureBytes(event));
@@ -32034,11 +32344,6 @@ class EventRing {
32034
32344
  this.retainedBytes -= Math.max(0, this.measureBytes(removed.event));
32035
32345
  this.droppedEvents += 1;
32036
32346
  }
32037
- return this.revision;
32038
- }
32039
- advance() {
32040
- this.revision += 1;
32041
- return this.revision;
32042
32347
  }
32043
32348
  collapseSuperseded(incoming) {
32044
32349
  const supersede = this.supersede;
@@ -32049,10 +32354,11 @@ class EventRing {
32049
32354
  const replacement = supersede(incoming, entry.event);
32050
32355
  if (replacement === null)
32051
32356
  continue;
32357
+ if (replacement === entry.event)
32358
+ return;
32052
32359
  this.retainedBytes -= Math.max(0, this.measureBytes(entry.event));
32053
32360
  entry.event = replacement;
32054
32361
  this.retainedBytes += Math.max(0, this.measureBytes(replacement));
32055
- return;
32056
32362
  }
32057
32363
  }
32058
32364
  since(cursor) {
@@ -32147,6 +32453,7 @@ function installFatalRejectionGuard(options) {
32147
32453
  const APP_PATH = /(?:^|\/)((?:apps\/(?:backend|desktop|web|web-public)|packages\/(?:protocol|cli|toolchain)|bridges\/[\w-]+|[\w-]+-bridge)\/.*)$/;
32148
32454
  const PACKAGED_PATH = /\/((?:app\.asar(?:\.unpacked)?|resources)\/.*)$/i;
32149
32455
  const CREDENTIALS = [
32456
+ { pattern: /\bok[ab]_[A-Za-z0-9_-]{16,}/g, replacement: "[redacted]" },
32150
32457
  {
32151
32458
  pattern: /([a-z][a-z0-9+.-]*:\/\/)[^/\s:@]+(?::[^/\s@]*)?@/gi,
32152
32459
  replacement: "$1[redacted]@"
@@ -32274,9 +32581,9 @@ function installFatalRejectionGuard(options) {
32274
32581
  }
32275
32582
 
32276
32583
  // ../protocol/src/node/process-failure-log.ts
32277
- var log19 = createLogger("process");
32584
+ var log20 = createLogger("process");
32278
32585
  function logUnhandledRejection(reason) {
32279
- log19.throttled("error", "rejection.unhandled", {
32586
+ log20.throttled("error", "rejection.unhandled", {
32280
32587
  error: reason,
32281
32588
  fields: () => ({ error: formatLogError(reason, { message: false }) })
32282
32589
  });
@@ -32301,7 +32608,7 @@ var CODEX_FALLBACK_MODEL_CATALOG = [
32301
32608
  ];
32302
32609
 
32303
32610
  // ../../bridges/codex-bridge/src/models-cache.ts
32304
- var log20 = createLogger("bridge.codex");
32611
+ var log21 = createLogger("bridge.codex");
32305
32612
  var MODEL_REASONING_EFFORTS = new Set([
32306
32613
  "minimal",
32307
32614
  "low",
@@ -32448,13 +32755,13 @@ class ModelCatalogCache {
32448
32755
  await this.opts.writePersistedCache(models);
32449
32756
  }
32450
32757
  } catch (error) {
32451
- log20.warn("models.refresh-failed", { error: formatLogError(error, { stack: false }) });
32758
+ log21.warn("models.refresh-failed", { error: formatLogError(error, { stack: false }) });
32452
32759
  }
32453
32760
  }
32454
32761
  }
32455
32762
 
32456
32763
  // ../../bridges/codex-bridge/src/index.ts
32457
- var log21 = createLogger("bridge.codex");
32764
+ var log22 = createLogger("bridge.codex");
32458
32765
  configureBridgeLogger();
32459
32766
  var WORKFLOW_RESULT_TOOL_NAMES2 = new Set(WORKFLOW_RESULT_KINDS.map(workflowResultToolName));
32460
32767
  function isWorkflowResultTool(value) {
@@ -32484,14 +32791,14 @@ function isScopedAgentMcp(value) {
32484
32791
  var app = new Hono2;
32485
32792
  app.onError((error, c) => {
32486
32793
  if (error instanceof PolicyWideningRefusedError) {
32487
- log21.warn("session.policy-widening-refused", { widened: error.widened.join(",") });
32794
+ log22.warn("session.policy-widening-refused", { widened: error.widened.join(",") });
32488
32795
  return c.json(error.refusal(), 403);
32489
32796
  }
32490
32797
  if ("getResponse" in error) {
32491
32798
  const response = error.getResponse();
32492
32799
  return c.newResponse(response.body, response);
32493
32800
  }
32494
- log21.error("http.request-failed", {
32801
+ log22.error("http.request-failed", {
32495
32802
  method: c.req.method,
32496
32803
  path: c.req.path,
32497
32804
  error: formatLogError(error)
@@ -32505,8 +32812,7 @@ function boundCodexTranscriptResponse(messages, tailMessages) {
32505
32812
  }
32506
32813
  var BRIDGE_TOKEN_ENV = "CODEX_BRIDGE_TOKEN";
32507
32814
  var BRIDGE_ALLOWED_ORIGINS_ENV = "CODEX_BRIDGE_ALLOWED_ORIGINS";
32508
- var bridgeAuthToken = process.env[BRIDGE_TOKEN_ENV]?.trim() || randomBytes(32).toString("base64url");
32509
- delete process.env[BRIDGE_TOKEN_ENV];
32815
+ var bridgeCredential = loadBridgeCredential(BRIDGE_TOKEN_ENV);
32510
32816
  var bridgeAuthEnabledOverrideForTesting = null;
32511
32817
  var sseRouteTestHooks = null;
32512
32818
  var BRIDGE_VERSION = "1.0.0";
@@ -32520,10 +32826,10 @@ function notifyObservers(event, revision) {
32520
32826
  for (const observer of observers) {
32521
32827
  try {
32522
32828
  Promise.resolve(observer(event, revision, "{}")).catch((error) => {
32523
- log21.warn("sse.observer-failed", { error: formatLogError(error) });
32829
+ log22.warn("sse.observer-failed", { error: formatLogError(error) });
32524
32830
  });
32525
32831
  } catch (error) {
32526
- log21.warn("sse.observer-failed", { error: formatLogError(error) });
32832
+ log22.warn("sse.observer-failed", { error: formatLogError(error) });
32527
32833
  }
32528
32834
  }
32529
32835
  }
@@ -32590,11 +32896,6 @@ function acquireReplayRetention() {
32590
32896
  }
32591
32897
  scheduleReplayRetentionDrop();
32592
32898
  var CLEANUP_INTERVAL_MS = 5 * 60 * 1000;
32593
- var codexRawLogDir = normalizeOptionalEnvPath("ORKESTRATOR_CODEX_RAW_LOG_DIR");
32594
- function normalizeOptionalEnvPath(name) {
32595
- const value = process.env[name]?.trim();
32596
- return value ? value : null;
32597
- }
32598
32899
  function isBridgeAuthEnabled() {
32599
32900
  if (bridgeAuthEnabledOverrideForTesting !== null) {
32600
32901
  return bridgeAuthEnabledOverrideForTesting;
@@ -32602,11 +32903,7 @@ function isBridgeAuthEnabled() {
32602
32903
  return !(process.env.CODEX_BRIDGE_NO_SERVER === "1" && process.env.CODEX_BRIDGE_AUTH_DISABLED_FOR_TESTING === "1");
32603
32904
  }
32604
32905
  function tokenMatches(candidate) {
32605
- if (!candidate)
32606
- return false;
32607
- const expected = Buffer.from(bridgeAuthToken);
32608
- const actual = Buffer.from(candidate);
32609
- return expected.length === actual.length && timingSafeEqual(expected, actual);
32906
+ return bridgeCredential.matches(candidate);
32610
32907
  }
32611
32908
  function bearerToken(header) {
32612
32909
  if (!header)
@@ -32632,33 +32929,6 @@ function isTrustedBridgeOrigin(origin) {
32632
32929
  function isPublicHealthRequest(method, path) {
32633
32930
  return method === "GET" && path === "/global/health";
32634
32931
  }
32635
- function sanitizeLogFileComponent(value) {
32636
- return value.replace(/[^a-zA-Z0-9._-]/g, "_");
32637
- }
32638
- function normalizeLogPayload(value) {
32639
- try {
32640
- return JSON.parse(JSON.stringify(value));
32641
- } catch {
32642
- return stringifyUnknown(value);
32643
- }
32644
- }
32645
- async function writeCodexRawLog(sessionId, entry, logDir = codexRawLogDir) {
32646
- if (!logDir) {
32647
- return;
32648
- }
32649
- try {
32650
- await mkdir9(logDir, { recursive: true });
32651
- const filename = `${sanitizeLogFileComponent(sessionId)}.jsonl`;
32652
- await appendFile5(join23(logDir, filename), `${JSON.stringify({
32653
- timestamp: new Date().toISOString(),
32654
- sessionId,
32655
- ...entry
32656
- })}
32657
- `, "utf8");
32658
- } catch (error) {
32659
- log21.warn("raw-log.write-failed", { error: formatLogError(error) });
32660
- }
32661
- }
32662
32932
  function createShutdownHandler(timer, clearTimer = clearInterval, exit = (code) => process.exit(code), stopEngine = () => stopSelectedEngine()) {
32663
32933
  let shuttingDown = false;
32664
32934
  return () => {
@@ -32667,12 +32937,12 @@ function createShutdownHandler(timer, clearTimer = clearInterval, exit = (code)
32667
32937
  shuttingDown = true;
32668
32938
  clearTimer(timer);
32669
32939
  stopEngine().catch((error) => {
32670
- log21.warn("engine.stop-failed", { error: formatLogError(error) });
32940
+ log22.warn("engine.stop-failed", { error: formatLogError(error) });
32671
32941
  }).finally(() => exit(0));
32672
32942
  };
32673
32943
  }
32674
32944
  function createParentExitHandler(interrupt, shutdown, report = (turns, ms) => {
32675
- log21.info("turns.stopped", { turns, elapsedMs: ms });
32945
+ log22.info("turns.stopped", { turns, elapsedMs: ms });
32676
32946
  }) {
32677
32947
  return async () => {
32678
32948
  const detectedAt = performance.now();
@@ -32703,7 +32973,7 @@ function serializeSseEventData(event) {
32703
32973
  ...event.data
32704
32974
  });
32705
32975
  } catch {
32706
- log21.error("sse.payload-serialize-failed");
32976
+ log22.error("sse.payload-serialize-failed");
32707
32977
  return JSON.stringify({
32708
32978
  sessionId: event.sessionId,
32709
32979
  error: "payload could not be serialized"
@@ -32768,7 +33038,7 @@ function emit(event) {
32768
33038
  messageId = retainedMessageId(event.type, payload);
32769
33039
  bytes = eager === null ? estimateSsePayloadBytes(payload) : Buffer.byteLength(eager, "utf8");
32770
33040
  } catch {
32771
- log21.error("sse.payload-snapshot-failed");
33041
+ log22.error("sse.payload-snapshot-failed");
32772
33042
  payload = { error: "payload could not be serialized" };
32773
33043
  eager = subscribers.size > 0 ? serializeSseEventData({ sessionId, data: payload }) : null;
32774
33044
  messageId = undefined;
@@ -32785,10 +33055,10 @@ function emit(event) {
32785
33055
  for (const subscriber of subscribers) {
32786
33056
  try {
32787
33057
  Promise.resolve(subscriber(event, revision, eager ?? "{}")).catch((error) => {
32788
- log21.warn("sse.subscriber-failed", { error: formatLogError(error) });
33058
+ log22.warn("sse.subscriber-failed", { error: formatLogError(error) });
32789
33059
  });
32790
33060
  } catch (error) {
32791
- log21.warn("sse.subscriber-failed", { error: formatLogError(error) });
33061
+ log22.warn("sse.subscriber-failed", { error: formatLogError(error) });
32792
33062
  }
32793
33063
  }
32794
33064
  }
@@ -32815,7 +33085,7 @@ async function writePersistedBridgeCache(models) {
32815
33085
  await mkdir9(bridgeCacheDir(), { recursive: true });
32816
33086
  await writeFile6(bridgeCachePath(), JSON.stringify({ version: BRIDGE_MODEL_CACHE_VERSION, at: Date.now(), models }, null, 2));
32817
33087
  } catch (error) {
32818
- log21.warn("models.cache-persist-failed", { error: formatLogError(error, { stack: false }) });
33088
+ log22.warn("models.cache-persist-failed", { error: formatLogError(error, { stack: false }) });
32819
33089
  }
32820
33090
  }
32821
33091
  async function readCodexCliModelCache() {
@@ -32837,7 +33107,7 @@ async function fetchLiveModelsFromCli(run = execFile4, env = process.env) {
32837
33107
  const models = parseModelCatalog(stdout);
32838
33108
  return models.length > 0 ? models : null;
32839
33109
  } catch (error) {
32840
- log21.warn("models.debug-read-failed", { error: formatLogError(error, { stack: false }) });
33110
+ log22.warn("models.debug-read-failed", { error: formatLogError(error, { stack: false }) });
32841
33111
  return null;
32842
33112
  }
32843
33113
  }
@@ -32882,7 +33152,7 @@ async function sweepIdleThreads(runtime = appServerRuntime) {
32882
33152
  try {
32883
33153
  await runtime.sweepIdle();
32884
33154
  } catch (error) {
32885
- log21.warn("idle-sweep.failed", { error: formatLogError(error) });
33155
+ log22.warn("idle-sweep.failed", { error: formatLogError(error) });
32886
33156
  }
32887
33157
  }
32888
33158
  function createCodexProcessDiagnostics(runtime = appServerRuntime) {
@@ -32918,9 +33188,9 @@ async function startSelectedEngine(env = process.env, runtime = appServerRuntime
32918
33188
  }
32919
33189
  try {
32920
33190
  await runtime.start();
32921
- log21.info("engine.ready", { codexVersion: runtime.getHealth().codexVersion ?? "unknown" });
33191
+ log22.info("engine.ready", { codexVersion: runtime.getHealth().codexVersion ?? "unknown" });
32922
33192
  } catch (error) {
32923
- log21.error("engine.start-failed", { error: formatLogError(error, { stack: false }) });
33193
+ log22.error("engine.start-failed", { error: formatLogError(error, { stack: false }) });
32924
33194
  }
32925
33195
  }
32926
33196
  var __testing = {
@@ -32958,7 +33228,6 @@ var __testing = {
32958
33228
  hydrateMessagesFromPersistedSessionForTesting: hydrateMessagesFromPersistedSession,
32959
33229
  listPersistedSessionsForCwdForTesting: listPersistedSessionsForCwd,
32960
33230
  mergePersistedSessionMetaForTesting: mergePersistedSessionMeta,
32961
- normalizeLogPayloadForTesting: normalizeLogPayload,
32962
33231
  readPersistedBridgeCache,
32963
33232
  readCodexCliModelCache,
32964
33233
  readTextFileIfPresentForTesting: readTextFileIfPresent,
@@ -32969,11 +33238,10 @@ var __testing = {
32969
33238
  bridgeAuthEnabledOverrideForTesting = null;
32970
33239
  return;
32971
33240
  }
32972
- bridgeAuthToken = token;
33241
+ bridgeCredential = bridgeCredentialFromToken(token);
32973
33242
  bridgeAuthEnabledOverrideForTesting = true;
32974
33243
  },
32975
33244
  isTrustedBridgeOriginForTesting: isTrustedBridgeOrigin,
32976
- sanitizeLogFileComponentForTesting: sanitizeLogFileComponent,
32977
33245
  serializeSseEventDataForTesting: serializeSseEventData,
32978
33246
  setSseRouteTestHooksForTesting: (hooks) => {
32979
33247
  sseRouteTestHooks = hooks;
@@ -32991,7 +33259,6 @@ var __testing = {
32991
33259
  releaseReplayRetention();
32992
33260
  };
32993
33261
  },
32994
- writeCodexRawLogForTesting: writeCodexRawLog,
32995
33262
  writePersistedBridgeCache
32996
33263
  };
32997
33264
  function startSseKeepalive(writeSSE, intervalMs = 5000, shouldSendAtActiveCadence = () => true, idleIntervalMs = 30000) {
@@ -33006,7 +33273,7 @@ function startSseKeepalive(writeSSE, intervalMs = 5000, shouldSendAtActiveCadenc
33006
33273
  id: String(eventRing.latestRevision),
33007
33274
  data: "{}"
33008
33275
  }).catch((error) => {
33009
- log21.warn("sse.keepalive-failed", { error: formatLogError(error, { stack: false }) });
33276
+ log22.warn("sse.keepalive-failed", { error: formatLogError(error, { stack: false }) });
33010
33277
  });
33011
33278
  }, intervalMs);
33012
33279
  }
@@ -33262,7 +33529,7 @@ app.get("/session/:id/usage", async (c) => {
33262
33529
  return c.json({ error: "Session not found" }, 404);
33263
33530
  return c.json({ contextUsage });
33264
33531
  } catch (error) {
33265
- log21.warn("account.usage-read-failed", { error: formatLogError(error, { stack: false }) });
33532
+ log22.warn("account.usage-read-failed", { error: formatLogError(error, { stack: false }) });
33266
33533
  return c.json({ error: "Account usage is temporarily unavailable" }, 503);
33267
33534
  }
33268
33535
  });
@@ -33673,7 +33940,7 @@ app.get("/event/subscribe", (c) => {
33673
33940
  if (!open)
33674
33941
  return;
33675
33942
  open = false;
33676
- log21.info("sse.closed", { reason });
33943
+ log22.info("sse.closed", { reason });
33677
33944
  resolveConnectionClosed();
33678
33945
  };
33679
33946
  const writeWhileOpen = createSerializedSseWriter(createOpenSseWriter(() => open, (event) => stream.writeSSE(event)), { onOverflow: () => failSlowSubscriber("write backlog exceeded its cap") });
@@ -33821,7 +34088,7 @@ if (parentPid !== null) {
33821
34088
  startParentWatchdog({
33822
34089
  parentPid,
33823
34090
  onParentExit: () => {
33824
- log21.warn("parent.gone", { parentPid });
34091
+ log22.warn("parent.gone", { parentPid });
33825
34092
  createParentExitHandler((budgetMs) => appServerRuntime.interruptForParentExit(budgetMs), shutdownHandler)();
33826
34093
  }
33827
34094
  });