orkestrator 2.37.4-beta → 2.37.6-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/artifact-runtime/preview-worker.js +70 -0
- package/dist/artifact-runtime/worker-context/Dockerfile +1 -1
- package/dist/artifact-runtime/worker-context/package-lock.json +4 -4
- package/dist/artifact-runtime/worker-context/package.json +1 -1
- package/dist/artifact-runtime/worker-context/preview-worker.mjs +70 -0
- package/dist/client.js +65 -15
- package/dist/main.js +5031 -3769
- package/package.json +4 -4
- package/resources/acp-bridge/dist/index.js +43 -54
- package/resources/claude-bridge/dist/index.js +1562 -1605
- package/resources/codex-bridge/dist/index.js +46 -143
- package/resources/cursor-bridge/dist/index.js +49 -30
- package/resources/cursor-bridge/runtime/install.json +1 -1
- package/resources/pi-bridge/dist/index.js +51 -38
- package/resources/pi-bridge/runtime/install.json +1 -1
- package/resources/release-runtime/bun.lock +2 -2
- package/resources/release-runtime/package.json +1 -1
|
@@ -1315,16 +1315,20 @@ var BRIDGE_LOG_AREAS = defineLogAreas({
|
|
|
1315
1315
|
"prompt.accepted": "The route accepted a prompt and answered 202.",
|
|
1316
1316
|
"prompt.failed": "A prompt turn failed; the session reports the error.",
|
|
1317
1317
|
"prompt.processing-failed": "A prompt accepted by the route failed while processing.",
|
|
1318
|
+
"prompt.processing-usage-limited": "A prompt accepted by the route ended on a usage limit; the turn already logged prompt.usage-limited.",
|
|
1318
1319
|
"prompt.received": "A prompt reached the bridge; only its length is logged.",
|
|
1319
1320
|
"prompt.send-failed": "A prompt request failed; the route answered with an error.",
|
|
1321
|
+
"prompt.usage-limited": "A prompt turn ended because the account's plan allowance is used up; the session reports the limit.",
|
|
1320
1322
|
"query.close-failed": "Stopping the Claude query failed while closing a tab; the close stays pending.",
|
|
1321
1323
|
"query.failed": "A Claude query ended with an error result.",
|
|
1324
|
+
"query.usage-limited": "Claude refused a query because the account's plan allowance is used up; the turn reports the limit.",
|
|
1322
1325
|
"question.answer-failed": "The answer-question route failed.",
|
|
1323
1326
|
"question.answering": "Answering a parked question.",
|
|
1324
1327
|
"question.answers-prepared": "The route prepared a question answer for the session.",
|
|
1325
1328
|
"question.answers-received": "A parked question received its answers.",
|
|
1326
1329
|
"question.stale": "An answer arrived for a question no longer pending; the route answered stale.",
|
|
1327
1330
|
"question.wait-failed": "A parked question ended without an answer: cancelled, timed out or closed.",
|
|
1331
|
+
"read-only-connection.bedrock-withheld": "A read-only turn did not take the user settings' Bedrock connection: it names no bearer token or static key pair, so the CLI would resolve AWS profiles, whose credential_process runs outside the read-only boundary.",
|
|
1328
1332
|
"runtime.ended-under-resumed-turn": "The Claude runtime ended while a resumed root turn was still open.",
|
|
1329
1333
|
"server.listening": "The HTTP server is listening.",
|
|
1330
1334
|
"server.starting": "The HTTP server is about to bind.",
|
|
@@ -1517,10 +1521,10 @@ var DESKTOP_LOG_AREAS = defineLogAreas({
|
|
|
1517
1521
|
"dev-mode.ignored-packaged": "A packaged app was launched with ELECTRON_DEV=1 and ignored it; it loads its bundled renderer.",
|
|
1518
1522
|
"instance.already-running": "Another instance holds this data directory; this one will quit.",
|
|
1519
1523
|
"main-thread.stalled": {
|
|
1520
|
-
description: "A timer fired late, so windows, IPC and the stdout reader waited.",
|
|
1524
|
+
description: "A timer fired late, so windows, IPC and the stdout reader waited. `cpuMs` is the CPU time the process used in the window: near `lagMs` the main thread was busy, far below it the thread waited.",
|
|
1521
1525
|
essential: true,
|
|
1522
1526
|
minLevel: "error",
|
|
1523
|
-
fields: { lagMs: "number", intervalMs: "number" }
|
|
1527
|
+
fields: { lagMs: "number", intervalMs: "number", cpuMs: "number" }
|
|
1524
1528
|
},
|
|
1525
1529
|
"process-memory": "Development only: working set per Electron process type, sampled on an interval.",
|
|
1526
1530
|
"process-memory.failed": "Development only: one process memory sample could not be read.",
|
|
@@ -1954,6 +1958,7 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
|
|
|
1954
1958
|
description: "The OpenCode 2.x provider: its event monitor, steering, routing, host and container servers.",
|
|
1955
1959
|
events: {
|
|
1956
1960
|
"events.dropped": "The 2.x event stream ended or failed, so reads go to the server until it reconnects. Error class only.",
|
|
1961
|
+
"monitor.silent": "The 2.x event stream sent a heartbeat and then went quiet, so it is replaced. `silenceMs` only.",
|
|
1957
1962
|
"steer.unconfirmed": "A 2.x steer got no definite answer, so its delivery is reconciled from history. Error class only.",
|
|
1958
1963
|
"provider.dispose-failed": "Disposing the 2.x provider of a replaced server failed. Error class only.",
|
|
1959
1964
|
"transcript.unknown-row": "A 2.x history row of a kind the transcript does not know was dropped (a newer server). Its kind name only, once per kind.",
|
|
@@ -2019,20 +2024,26 @@ var RUNTIME_LOG_AREAS = defineLogAreas({
|
|
|
2019
2024
|
description: "This process's event loop. A stall of 10 seconds or more is written at error, so no level hides it.",
|
|
2020
2025
|
events: {
|
|
2021
2026
|
stalled: {
|
|
2022
|
-
description: "A timer fired late, so every request in that window waited. In the backend the line also names what ran: `storageMs` and the `storage*` fields describe the slow SQLite calls in the window (`operation.slow` in `storage`), `commandsInFlight` and `commands` the commands running,
|
|
2027
|
+
description: "A timer fired late, so every request in that window waited. In the backend the line also names what ran: `storageMs` and the `storage*` fields describe the slow SQLite calls in the window (`operation.slow` in `storage`), `storageCalls` and `storageCallMs` every SQLite call that ended in it, slow or not (`storageMainCallMs` and `storageLedgerCallMs` per database), `commandsInFlight` and `commands` the commands running, `blockingCommand` one whose synchronous part overlapped it, and `jobsInWindow` and `jobs` the recurring jobs that ran around it. `cpuMs` is the CPU time the process used in the window: near `lagMs` its own thread was busy, far below it the thread waited.",
|
|
2023
2028
|
essential: true,
|
|
2024
2029
|
minLevel: "error",
|
|
2025
2030
|
fields: {
|
|
2026
2031
|
lagMs: "number",
|
|
2027
2032
|
intervalMs: "number",
|
|
2033
|
+
cpuMs: "number",
|
|
2028
2034
|
storageMs: "number",
|
|
2029
2035
|
storageDatabase: "label",
|
|
2030
2036
|
storageOp: "label",
|
|
2031
2037
|
storageTable: "label",
|
|
2032
2038
|
storageLongestMs: "number",
|
|
2033
2039
|
storageBusy: "boolean",
|
|
2040
|
+
storageCalls: "number",
|
|
2041
|
+
storageCallMs: "number",
|
|
2042
|
+
storageMainCallMs: "number",
|
|
2043
|
+
storageLedgerCallMs: "number",
|
|
2034
2044
|
commandsInFlight: "number",
|
|
2035
|
-
blockingCommandMs: "number"
|
|
2045
|
+
blockingCommandMs: "number",
|
|
2046
|
+
jobsInWindow: "number"
|
|
2036
2047
|
}
|
|
2037
2048
|
}
|
|
2038
2049
|
}
|
|
@@ -2072,6 +2083,8 @@ var TERMINAL_LOG_AREAS = defineLogAreas({
|
|
|
2072
2083
|
"pty.exit-notify-failed": "Notifying a terminal's exit failed.",
|
|
2073
2084
|
"pty.late-exit-listener-failed": "A listener added after a terminal exited threw.",
|
|
2074
2085
|
"setup.pty-reused": "A setup terminal reused its existing PTY.",
|
|
2086
|
+
"setup.pty-retired": "A setup retry ended the terminal the previous run left open, so the new run gets its own.",
|
|
2087
|
+
"setup.pty-retire-failed": "A setup retry could not end the previous run's process tree, so it kept that terminal and started nothing.",
|
|
2075
2088
|
"setup.pty-spawning": "A setup terminal is spawning its PTY. The argument count only, never the arguments.",
|
|
2076
2089
|
"setup.pty-spawned": "A setup terminal's PTY started.",
|
|
2077
2090
|
"setup.pty-exited": "A setup terminal's PTY exited.",
|
|
@@ -2332,7 +2345,6 @@ var STORAGE_LOG_AREAS = defineLogAreas({
|
|
|
2332
2345
|
"native-session-owners.backfill-failed": "Native-session rows could not be given their environment as owner at open; an environment delete then parses those rows instead, and the next open retries.",
|
|
2333
2346
|
"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.",
|
|
2334
2347
|
"lease.heartbeat-failed": "A held lease's heartbeat failed, which shortens the lease; the next one retries.",
|
|
2335
|
-
"scrub.vacuum-failed": "Deleted-content page reclamation failed; the checkpoint is attempted independently.",
|
|
2336
2348
|
"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.",
|
|
2337
2349
|
"upkeep.vacuum-failed": "Periodic page reclamation failed; the next upkeep pass retries.",
|
|
2338
2350
|
"upkeep.finished": "One periodic upkeep pass ended: `optimizeMs` is how long refreshing planner statistics held the event loop, `released` and `left` the free pages returned and still free, `releaseMs` the release child's run and `stop` why it ended (`done`, `budget`, `busy`, `no-progress`, `slow-step`, `not-incremental`, `no-free-pages`, `failed`).",
|
|
@@ -2383,6 +2395,8 @@ var BUILD_PIPELINE_LOG_AREAS = defineLogAreas({
|
|
|
2383
2395
|
"workspace.waiting": "A pipeline is waiting for its workspace; written once per reason.",
|
|
2384
2396
|
"rewind.pending": "A pipeline's code rewind has not finished; written once per reason.",
|
|
2385
2397
|
"kanban.status-failed": "A restarted pipeline's Kanban status could not be set; it retries shortly.",
|
|
2398
|
+
"kanban.environment-deleted-read-failed": "The pipelines of an environment being deleted could not be read, so their tickets keep their columns.",
|
|
2399
|
+
"kanban.environment-deleted-update-failed": "The ticket of a pipeline whose environment was deleted could not be moved; the deletion goes on.",
|
|
2386
2400
|
"usage.read-failed": "Reading a stage session's token usage failed.",
|
|
2387
2401
|
"checkpoint.deferred": "A stage transcript checkpoint could not be written yet; the provider's history stands.",
|
|
2388
2402
|
"checkpoint.not-committed": "A stage transcript checkpoint was reverted in the commit that should have kept it.",
|
|
@@ -2433,6 +2447,7 @@ var CHANGE_TRACKING_LOG_AREAS = defineLogAreas({
|
|
|
2433
2447
|
"baseline.update-failed": "An environment's diff baseline could not be updated.",
|
|
2434
2448
|
"scan.watcher-failed": "An environment's diff watcher failed; its scans fall back to polling.",
|
|
2435
2449
|
"scan.failed": "A diff scan failed; the last results stay, marked stale, and the scan is retried.",
|
|
2450
|
+
"scan.target-missing": "A local environment's worktree folder is missing (deleted, moved or on an unmounted drive); no scan runs, the last results stay, marked stale, and the folder is checked again on the failure backoff.",
|
|
2436
2451
|
"scan.freshness-read-failed": "Reading whether an environment's remote is fresh failed.",
|
|
2437
2452
|
"scan.listener-failed": "A change-tracking scan listener threw; the scan itself stands.",
|
|
2438
2453
|
"emit.diff-stats-failed": "A diff stats change could not be emitted to its sink.",
|
|
@@ -2517,7 +2532,17 @@ var REVIEW_LOG_AREAS = defineLogAreas({
|
|
|
2517
2532
|
"fix-outcome.read-failed": "Reading an interactive fix's outcome failed; it stays pending.",
|
|
2518
2533
|
"fix-usage.read-failed": "Reading an Address Findings session's token usage failed.",
|
|
2519
2534
|
"result.consume-deferred": "Consuming a workflow result failed; it stays staged and is retried.",
|
|
2520
|
-
"failure-triage.failed": "Classifying a review package's failing tests failed; the package is sealed without the triage and says so."
|
|
2535
|
+
"failure-triage.failed": "Classifying a review package's failing tests failed; the package is sealed without the triage and says so.",
|
|
2536
|
+
"consolidation.budget-exceeded": {
|
|
2537
|
+
description: "A panel's reports did not fit one consolidation turn even after optional prose was removed, so consolidation failed before dispatch. Counts only.",
|
|
2538
|
+
essential: true,
|
|
2539
|
+
fields: {
|
|
2540
|
+
reviewers: "number",
|
|
2541
|
+
sourceFindings: "number",
|
|
2542
|
+
compactBytes: "number",
|
|
2543
|
+
maxBytes: "number"
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2521
2546
|
}
|
|
2522
2547
|
},
|
|
2523
2548
|
"pull-request": {
|
|
@@ -2610,9 +2635,10 @@ var DOCKER_LOG_AREAS = defineLogAreas({
|
|
|
2610
2635
|
"git-mirror.clone-fallback": "A new environment could not clone from its project's Git mirror and cloned from the remote.",
|
|
2611
2636
|
"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.",
|
|
2612
2637
|
"opencode.warm-incomplete": "OpenCode did not finish loading /workspace in a container.",
|
|
2613
|
-
"opencode.listener-replaced": "The process on a container's OpenCode port (`provider`: `opencode` or `opencode2`) is not the server the backend launched and recorded, so its password was withheld and the next start replaces it. `stage` is `request` when the re-check after a refused connection or an unexpected answer found it
|
|
2638
|
+
"opencode.listener-replaced": "The process on a container's OpenCode port (`provider`: `opencode` or `opencode2`) is not the server the backend launched and recorded, so its password was withheld and the next start replaces it. `stage` is `request` when the re-check after a refused connection or an unexpected answer found it; that connection then sends nothing more.",
|
|
2614
2639
|
"opencode.project-config-too-large": "A checkout's opencode.json or opencode.jsonc was larger than the limit, so a launched OpenCode server does not read it. File name only.",
|
|
2615
|
-
"opencode.project-config-filtered": "Values were left out of a checkout's OpenCode configuration before a launched server reads it
|
|
2640
|
+
"opencode.project-config-filtered": "Values were left out of a checkout's OpenCode configuration before a launched server reads it: counts of plugin keys, `{env:}` and `{file:}` references and dropped instructions (including separate instructionGlob and instructionUrl counts), and the names of files that were not a JSONC object. Never values.",
|
|
2641
|
+
"daemon.rootless-live-restore": "The Docker daemon is rootless and has live-restore on, which a rootless restart cannot honour: the new daemon reports every container exited while the old containers' processes keep running with no network, so turn live-restore off in its daemon.json. Written once per backend.",
|
|
2616
2642
|
"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.",
|
|
2617
2643
|
"lifecycle-event.reconcile-failed": "Reconciling an environment after a container start or stop event failed; the next status read retries.",
|
|
2618
2644
|
"login-keeper.pass-failed": "A Claude login keeper pass failed; the next interval retries.",
|
|
@@ -2626,7 +2652,8 @@ var DOCKER_LOG_AREAS = defineLogAreas({
|
|
|
2626
2652
|
"recovery.clear-terminals-failed": "Terminal sessions could not be cleared after a recovery restore.",
|
|
2627
2653
|
"github-ranges.seed-not-copied": "The GitHub ranges seed could not be copied into a container, so its firewall fetches them.",
|
|
2628
2654
|
"availability.probe-failed": "Docker is not available; written when the diagnostic changes. Fixed-shape metadata only: messages can hold daemon endpoints.",
|
|
2629
|
-
"start.port-collision-retrying": "An automatic host port collided on start, so it is retried
|
|
2655
|
+
"start.port-collision-retrying": "An automatic host port collided on start, so it is retried (up to three times): with fresh ports, or, when `backendChosen`, on the same backend-chosen port after a pause.",
|
|
2656
|
+
"host-ports.owned-list-failed": "Docker could not list the host ports the backend chose for this owner's other containers, so a new rootless container's ports were chosen avoiding only this process's recent choices.",
|
|
2630
2657
|
"writer-lease.lost": {
|
|
2631
2658
|
description: "This backend lost the registry writer lease, for the fixed `reason` given. Schedules stop and container changes are refused until it restarts.",
|
|
2632
2659
|
essential: true,
|
|
@@ -2649,7 +2676,7 @@ var DOCKER_LOG_AREAS = defineLogAreas({
|
|
|
2649
2676
|
fields: { provider: "label", containerPort: "number" }
|
|
2650
2677
|
},
|
|
2651
2678
|
"bridge.listener-refused": {
|
|
2652
|
-
description: "The socket listening on a container bridge's port is not the one the bridge the backend started opened
|
|
2679
|
+
description: "The socket listening on a container bridge's port is not the one the bridge the backend started opened, so its token is not handed out and the next start replaces it. `reason` is a fixed label: `different-socket`, `several-sockets`, `pending` (a start has not recorded its bridge yet, or failed before it did) or `scan-incomplete`.",
|
|
2653
2680
|
essential: true,
|
|
2654
2681
|
fields: { provider: "label", reason: "label" }
|
|
2655
2682
|
},
|
|
@@ -3171,6 +3198,7 @@ var WEB_KANBAN_LOG_AREAS = defineLogAreas({
|
|
|
3171
3198
|
"task.move-failed": "A task move failed and its status was rolled back.",
|
|
3172
3199
|
"comment.add-failed": "A comment could not be added to a task.",
|
|
3173
3200
|
"comment.delete-failed": "A comment could not be deleted from a task.",
|
|
3201
|
+
"pr.merge-failed": "Merging a ticket's pull request from its Notes tab failed; the error was shown to the user.",
|
|
3174
3202
|
"image.add-failed": "An image could not be added to a task.",
|
|
3175
3203
|
"image.delete-failed": "An image could not be deleted from a task.",
|
|
3176
3204
|
"notes.load-failed": "Project notes could not be loaded; the editor stays disabled.",
|
|
@@ -4720,11 +4748,10 @@ function setLiveBridgeDiagnostics(enabled) {
|
|
|
4720
4748
|
for (const scope of Array.from(liveScopes))
|
|
4721
4749
|
scope.syncActive();
|
|
4722
4750
|
}
|
|
4723
|
-
function bridgeDebugEnabled(
|
|
4751
|
+
function bridgeDebugEnabled(_bridge, env = process.env) {
|
|
4724
4752
|
if (liveDiagnostics !== undefined && env === process.env)
|
|
4725
4753
|
return liveDiagnostics;
|
|
4726
|
-
|
|
4727
|
-
return readBridgeDebugFlag(value);
|
|
4754
|
+
return readBridgeDebugFlag(env.ORKESTRATOR_BRIDGE_DEBUG);
|
|
4728
4755
|
}
|
|
4729
4756
|
function safeDiagnosticMetrics(value) {
|
|
4730
4757
|
const result = {};
|
|
@@ -24041,7 +24068,6 @@ import {
|
|
|
24041
24068
|
} from "node:fs/promises";
|
|
24042
24069
|
import { join as join15 } from "node:path";
|
|
24043
24070
|
var log12 = createLogger("bridge.codex");
|
|
24044
|
-
var BRIDGE_SESSION_REGISTRY_VERSION = 2;
|
|
24045
24071
|
var SESSION_TITLE_SOURCES = new Set([
|
|
24046
24072
|
"codex",
|
|
24047
24073
|
"explicit",
|
|
@@ -24145,9 +24171,6 @@ class BridgeSessionStore {
|
|
|
24145
24171
|
dir() {
|
|
24146
24172
|
return codexBridgeStateDir(this.codexHome);
|
|
24147
24173
|
}
|
|
24148
|
-
path() {
|
|
24149
|
-
return join15(this.dir(), `bridge-sessions-${this.cwdHash}.json`);
|
|
24150
|
-
}
|
|
24151
24174
|
recordsDir() {
|
|
24152
24175
|
return join15(this.dir(), `bridge-sessions-${this.cwdHash}`);
|
|
24153
24176
|
}
|
|
@@ -24172,19 +24195,13 @@ class BridgeSessionStore {
|
|
|
24172
24195
|
}
|
|
24173
24196
|
async load() {
|
|
24174
24197
|
const cutoff = this.now() - this.retentionMs;
|
|
24175
|
-
const legacy = await this.loadLegacy(cutoff);
|
|
24176
|
-
let migrationFailed = false;
|
|
24177
|
-
await this.migrateLegacy(legacy).catch((error) => {
|
|
24178
|
-
migrationFailed = true;
|
|
24179
|
-
this.warnPersistenceFailure(error);
|
|
24180
|
-
});
|
|
24181
24198
|
await this.adoptLoginRecords().catch((error) => this.warnPersistenceFailure(error));
|
|
24182
24199
|
let names;
|
|
24183
24200
|
try {
|
|
24184
24201
|
await this.ensurePrivateStorage();
|
|
24185
24202
|
names = await readdir2(this.recordsDir());
|
|
24186
24203
|
} catch {
|
|
24187
|
-
return
|
|
24204
|
+
return [];
|
|
24188
24205
|
}
|
|
24189
24206
|
const records = await Promise.all(names.map(async (name) => {
|
|
24190
24207
|
const path = join15(this.recordsDir(), name);
|
|
@@ -24213,8 +24230,7 @@ class BridgeSessionStore {
|
|
|
24213
24230
|
return null;
|
|
24214
24231
|
}
|
|
24215
24232
|
}));
|
|
24216
|
-
|
|
24217
|
-
return migrationFailed && loaded.length === 0 ? legacy : loaded;
|
|
24233
|
+
return records.filter((record) => record !== null);
|
|
24218
24234
|
}
|
|
24219
24235
|
async loadRecord(bridgeSessionId) {
|
|
24220
24236
|
const cutoff = this.now() - this.retentionMs;
|
|
@@ -24222,9 +24238,6 @@ class BridgeSessionStore {
|
|
|
24222
24238
|
const record = await this.readRecordFile(join15(this.recordsDir(), key), bridgeSessionId, cutoff);
|
|
24223
24239
|
if (record !== RECORD_FILE_MISSING)
|
|
24224
24240
|
return record;
|
|
24225
|
-
const legacy = (await this.readLegacy(cutoff)).find((session) => session.bridgeSessionId === bridgeSessionId);
|
|
24226
|
-
if (legacy)
|
|
24227
|
-
return legacy;
|
|
24228
24241
|
const loginRecords = this.loginRecordsDir();
|
|
24229
24242
|
if (!loginRecords)
|
|
24230
24243
|
return null;
|
|
@@ -24281,53 +24294,6 @@ class BridgeSessionStore {
|
|
|
24281
24294
|
});
|
|
24282
24295
|
await attempt;
|
|
24283
24296
|
}
|
|
24284
|
-
async loadLegacy(cutoff) {
|
|
24285
|
-
try {
|
|
24286
|
-
await chmod(this.dir(), PRIVATE_DIRECTORY_MODE);
|
|
24287
|
-
await chmod(this.path(), PRIVATE_FILE_MODE);
|
|
24288
|
-
} catch {
|
|
24289
|
-
return [];
|
|
24290
|
-
}
|
|
24291
|
-
return this.readLegacy(cutoff);
|
|
24292
|
-
}
|
|
24293
|
-
async readLegacy(cutoff) {
|
|
24294
|
-
try {
|
|
24295
|
-
const parsed = JSON.parse(await readFile6(this.path(), "utf8"));
|
|
24296
|
-
if (parsed.version !== BRIDGE_SESSION_REGISTRY_VERSION)
|
|
24297
|
-
return [];
|
|
24298
|
-
if (!Array.isArray(parsed.sessions))
|
|
24299
|
-
return [];
|
|
24300
|
-
return parsed.sessions.filter((session) => isPersistedBridgeSession(session, this.cwdHash, cutoff));
|
|
24301
|
-
} catch {
|
|
24302
|
-
return [];
|
|
24303
|
-
}
|
|
24304
|
-
}
|
|
24305
|
-
async migrateLegacy(sessions) {
|
|
24306
|
-
if (sessions.length === 0)
|
|
24307
|
-
return;
|
|
24308
|
-
await this.ensurePrivateStorage();
|
|
24309
|
-
await Promise.all(sessions.map(async (session) => {
|
|
24310
|
-
const target = this.recordPath(session.bridgeSessionId);
|
|
24311
|
-
const temporary = `${target}.${process.pid}.${randomUUID8()}.tmp`;
|
|
24312
|
-
await writeFile4(temporary, `${JSON.stringify(session, null, 2)}
|
|
24313
|
-
`, {
|
|
24314
|
-
encoding: "utf8",
|
|
24315
|
-
mode: PRIVATE_FILE_MODE
|
|
24316
|
-
});
|
|
24317
|
-
await chmod(temporary, PRIVATE_FILE_MODE);
|
|
24318
|
-
await link2(temporary, target).catch((error) => {
|
|
24319
|
-
if (error.code !== "EEXIST")
|
|
24320
|
-
throw error;
|
|
24321
|
-
});
|
|
24322
|
-
await chmod(target, PRIVATE_FILE_MODE);
|
|
24323
|
-
await rm6(temporary, { force: true }).catch(() => {
|
|
24324
|
-
return;
|
|
24325
|
-
});
|
|
24326
|
-
}));
|
|
24327
|
-
await rm6(this.path(), { force: true }).catch(() => {
|
|
24328
|
-
return;
|
|
24329
|
-
});
|
|
24330
|
-
}
|
|
24331
24297
|
async adoptLoginRecords() {
|
|
24332
24298
|
const source = this.loginRecordsDir();
|
|
24333
24299
|
if (!source)
|
|
@@ -25920,34 +25886,6 @@ function allowlistRateLimits(value) {
|
|
|
25920
25886
|
...Object.keys(rateLimitsByLimitId).length > 0 ? { rateLimitsByLimitId } : {}
|
|
25921
25887
|
};
|
|
25922
25888
|
}
|
|
25923
|
-
var MAX_DATE_MS2 = 8640000000000000;
|
|
25924
|
-
function rateLimitWindowsFromRead(value) {
|
|
25925
|
-
const response = objectRecord(value);
|
|
25926
|
-
const snapshot = allowlistRateLimitSnapshot(response.rateLimits);
|
|
25927
|
-
const planLabel = optionalPublicString(snapshot.limitName);
|
|
25928
|
-
const normalModelSlug = optionalPublicString(snapshot.normalModelSlug);
|
|
25929
|
-
const windows = [];
|
|
25930
|
-
for (const slot of ["primary", "secondary"]) {
|
|
25931
|
-
if (!Object.hasOwn(snapshot, slot))
|
|
25932
|
-
continue;
|
|
25933
|
-
const window = objectRecord(snapshot[slot]);
|
|
25934
|
-
if (!window)
|
|
25935
|
-
continue;
|
|
25936
|
-
const usedPercent = typeof window.usedPercent === "number" ? window.usedPercent : undefined;
|
|
25937
|
-
const windowMinutes = typeof window.windowDurationMins === "number" ? window.windowDurationMins : undefined;
|
|
25938
|
-
const resetsAtSeconds = typeof window.resetsAt === "number" ? window.resetsAt : undefined;
|
|
25939
|
-
const resetsAtMs = resetsAtSeconds !== undefined && Math.abs(resetsAtSeconds * 1000) <= MAX_DATE_MS2 ? resetsAtSeconds * 1000 : undefined;
|
|
25940
|
-
const resetsAt = resetsAtMs !== undefined ? new Date(resetsAtMs).toISOString() : undefined;
|
|
25941
|
-
windows.push({
|
|
25942
|
-
slot,
|
|
25943
|
-
label: slot === "primary" ? planLabel ?? normalModelSlug ?? "Primary" : "Secondary",
|
|
25944
|
-
...usedPercent !== undefined ? { usedPercent } : {},
|
|
25945
|
-
...resetsAt !== undefined ? { resetsAt } : {},
|
|
25946
|
-
...windowMinutes !== undefined ? { windowMinutes } : {}
|
|
25947
|
-
});
|
|
25948
|
-
}
|
|
25949
|
-
return windows;
|
|
25950
|
-
}
|
|
25951
25889
|
function safeUsageCount(value) {
|
|
25952
25890
|
let parsed;
|
|
25953
25891
|
if (typeof value === "bigint")
|
|
@@ -27074,10 +27012,6 @@ class AppServerEngine {
|
|
|
27074
27012
|
const response = await this.supervisor.request("account/usage/read", undefined);
|
|
27075
27013
|
return accountUsageWindows(response);
|
|
27076
27014
|
}
|
|
27077
|
-
async readRateLimitWindows() {
|
|
27078
|
-
const response = await this.supervisor.request("account/rateLimits/read", undefined);
|
|
27079
|
-
return rateLimitWindowsFromRead(response);
|
|
27080
|
-
}
|
|
27081
27015
|
async beginAccountLogin(method = "browser") {
|
|
27082
27016
|
const sequence = ++this.loginSequence;
|
|
27083
27017
|
this.forgetSignIn();
|
|
@@ -28477,7 +28411,9 @@ class CodexRuntimeSessions {
|
|
|
28477
28411
|
const session = this.ctx.registry.getSession(sessionId);
|
|
28478
28412
|
if (!session)
|
|
28479
28413
|
return null;
|
|
28480
|
-
|
|
28414
|
+
const threadId = this.loadedThreadId(sessionId);
|
|
28415
|
+
const health = await this.ctx.options.engine.getRuntimeHealth(threadId);
|
|
28416
|
+
return { ...health, session: { state: threadId ? "attached" : "detached" } };
|
|
28481
28417
|
}
|
|
28482
28418
|
async listMcpServers(sessionId) {
|
|
28483
28419
|
const session = this.ctx.registry.getSession(sessionId);
|
|
@@ -33515,11 +33451,6 @@ class CodexRuntimeTail {
|
|
|
33515
33451
|
}
|
|
33516
33452
|
return this.ctx.options.loadCachedModels();
|
|
33517
33453
|
}
|
|
33518
|
-
async readPlanUsage() {
|
|
33519
|
-
const limits = await this.ctx.options.engine.readRateLimitWindows();
|
|
33520
|
-
const windows = accountUsageFromLimits(limits);
|
|
33521
|
-
return windows.length > 0 ? windows : undefined;
|
|
33522
|
-
}
|
|
33523
33454
|
async listSessions(options = {}) {
|
|
33524
33455
|
const cwd = getWorkingDirectory(this.ctx.options.cwd);
|
|
33525
33456
|
const merged = new Map;
|
|
@@ -33875,9 +33806,6 @@ class AppServerRuntime {
|
|
|
33875
33806
|
listModels(...args) {
|
|
33876
33807
|
return this.tail.listModels(...args);
|
|
33877
33808
|
}
|
|
33878
|
-
readPlanUsage(...args) {
|
|
33879
|
-
return this.tail.readPlanUsage(...args);
|
|
33880
|
-
}
|
|
33881
33809
|
listSessions(...args) {
|
|
33882
33810
|
return this.tail.listSessions(...args);
|
|
33883
33811
|
}
|
|
@@ -34501,7 +34429,6 @@ function boundCodexTranscriptResponse(messages, tailMessages) {
|
|
|
34501
34429
|
return { messages: bounded, messageWindow };
|
|
34502
34430
|
}
|
|
34503
34431
|
var BRIDGE_TOKEN_ENV = "CODEX_BRIDGE_TOKEN";
|
|
34504
|
-
var BRIDGE_ALLOWED_ORIGINS_ENV = "CODEX_BRIDGE_ALLOWED_ORIGINS";
|
|
34505
34432
|
var bridgeCredential = loadBridgeCredential(BRIDGE_TOKEN_ENV);
|
|
34506
34433
|
var bridgeAuthEnabledOverrideForTesting = null;
|
|
34507
34434
|
var sseRouteTestHooks = null;
|
|
@@ -34604,11 +34531,6 @@ function bearerToken(header) {
|
|
|
34604
34531
|
function isTrustedBridgeOrigin(origin) {
|
|
34605
34532
|
if (!origin)
|
|
34606
34533
|
return true;
|
|
34607
|
-
if (origin === "null" || origin === "file://")
|
|
34608
|
-
return true;
|
|
34609
|
-
const configured = (process.env[BRIDGE_ALLOWED_ORIGINS_ENV] ?? "").split(",").map((entry) => entry.trim().replace(/\/$/, "")).filter(Boolean);
|
|
34610
|
-
if (configured.includes(origin.replace(/\/$/, "")))
|
|
34611
|
-
return true;
|
|
34612
34534
|
try {
|
|
34613
34535
|
const parsed = new URL(origin);
|
|
34614
34536
|
return (parsed.protocol === "http:" || parsed.protocol === "https:") && (parsed.hostname === "127.0.0.1" || parsed.hostname === "localhost" || parsed.hostname === "::1" || parsed.hostname === "[::1]");
|
|
@@ -35013,21 +34935,10 @@ app.use("*", async (c, next) => {
|
|
|
35013
34935
|
if (!isTrustedBridgeOrigin(origin)) {
|
|
35014
34936
|
return c.json({ error: "Origin is not allowed" }, 403);
|
|
35015
34937
|
}
|
|
35016
|
-
if (origin) {
|
|
35017
|
-
c.header("Access-Control-Allow-Origin", origin);
|
|
35018
|
-
c.header("Vary", "Origin");
|
|
35019
|
-
}
|
|
35020
|
-
if (c.req.method === "OPTIONS") {
|
|
35021
|
-
c.header("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
|
|
35022
|
-
c.header("Access-Control-Allow-Headers", "Content-Type, Authorization, X-Orkestrator-Codex-Token");
|
|
35023
|
-
c.header("Access-Control-Allow-Private-Network", "true");
|
|
35024
|
-
return c.body(null, 204);
|
|
35025
|
-
}
|
|
35026
34938
|
if (isBridgeAuthEnabled() && !isPublicHealthRequest(c.req.method, c.req.path)) {
|
|
35027
34939
|
const dedicatedHeaderToken = c.req.raw.headers.get("x-orkestrator-codex-token")?.trim();
|
|
35028
34940
|
const headerToken = bearerToken(c.req.raw.headers.get("authorization") ?? undefined);
|
|
35029
|
-
|
|
35030
|
-
if (!tokenMatches(dedicatedHeaderToken) && !tokenMatches(headerToken) && !tokenMatches(eventToken)) {
|
|
34941
|
+
if (!tokenMatches(dedicatedHeaderToken) && !tokenMatches(headerToken)) {
|
|
35031
34942
|
return c.json({ error: "Unauthorized" }, 401);
|
|
35032
34943
|
}
|
|
35033
34944
|
const admission = await admitFetchBridgeRequest(bridgeCredential.authority, c.req.raw);
|
|
@@ -35136,10 +35047,6 @@ app.post("/global/auth/logout", async (c) => {
|
|
|
35136
35047
|
app.get("/global/models", async (c) => {
|
|
35137
35048
|
return c.json(await appServerRuntime.listModels());
|
|
35138
35049
|
});
|
|
35139
|
-
app.get("/global/usage", async (c) => {
|
|
35140
|
-
const account = await appServerRuntime.readPlanUsage();
|
|
35141
|
-
return c.json({ account: account ?? null });
|
|
35142
|
-
});
|
|
35143
35050
|
app.get("/session/:id/commands", async (c) => {
|
|
35144
35051
|
return c.json(await appServerRuntime.getCommandCatalogue(c.req.param("id")));
|
|
35145
35052
|
});
|
|
@@ -35628,10 +35535,6 @@ app.post("/session/:id/abort", async (c) => {
|
|
|
35628
35535
|
return c.json({ error: "Session not found" }, 404);
|
|
35629
35536
|
return c.json({ status: outcome.status, phase: outcome.phase }, 202);
|
|
35630
35537
|
});
|
|
35631
|
-
app.delete("/session/:id", async (c) => {
|
|
35632
|
-
const deleted = await appServerRuntime.deleteSession(c.req.param("id"));
|
|
35633
|
-
return deleted ? c.json({ status: "deleted" }) : c.json({ error: "Session not found" }, 404);
|
|
35634
|
-
});
|
|
35635
35538
|
app.get("/event/subscribe", (c) => {
|
|
35636
35539
|
const cursor = parseEventCursor(c.req.query("since")) ?? parseEventCursor(c.req.header("last-event-id"));
|
|
35637
35540
|
const sessionFilter = c.req.query("sessionId")?.trim() || null;
|