orkestrator 2.36.4-beta → 2.36.5-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +11962 -10260
- package/dist/main.js +5058 -2903
- package/package.json +3 -3
- package/resources/acp-bridge/dist/index.js +884 -48
- package/resources/claude-bridge/dist/index.js +1177 -183
- package/resources/codex-bridge/dist/index.js +999 -161
- package/resources/cursor-bridge/dist/index.js +876 -40
- package/resources/cursor-bridge/runtime/install.json +1 -1
- package/resources/pi-bridge/dist/index.js +890 -52
- package/resources/pi-bridge/runtime/install.json +1 -1
|
@@ -1621,6 +1621,8 @@ var LOGGING_LOG_AREAS = defineLogAreas({
|
|
|
1621
1621
|
},
|
|
1622
1622
|
"essential.write-failed": "Writing the essential log failed. Its entries are counted, and a marker reports them at the next write that works.",
|
|
1623
1623
|
"policy.changed": "The logging settings changed: saving, retention and levels, with no content.",
|
|
1624
|
+
"policy.detail-expired": "Raised log detail reached its expiry, so the backend set its raised levels back to info. Saving is unchanged.",
|
|
1625
|
+
"policy.expiry-failed": "Checking or applying the log detail expiry failed; the next check, a minute later, tries again.",
|
|
1624
1626
|
"policy.bridge-predates-route": "A running bridge has no logging settings route; it applies them at its next start.",
|
|
1625
1627
|
"policy.push-failed": "A running bridge did not take the logging settings after retries; its next start resends them.",
|
|
1626
1628
|
"prune.failed": "Removing expired log files failed; the next sweep retries.",
|
|
@@ -1628,6 +1630,23 @@ var LOGGING_LOG_AREAS = defineLogAreas({
|
|
|
1628
1630
|
"unknown-area": "Code outside the type checker asked for an area that is not listed.",
|
|
1629
1631
|
...THROTTLE_LOG_EVENTS
|
|
1630
1632
|
}
|
|
1633
|
+
},
|
|
1634
|
+
"renderer-errors": {
|
|
1635
|
+
description: "Renderer failures a desktop window reported from its error ring: class, boundary, surface, count and fingerprint, never a message or stack.",
|
|
1636
|
+
events: {
|
|
1637
|
+
"error.recorded": {
|
|
1638
|
+
description: "A renderer reported `count` new occurrences of one failure since its last report.",
|
|
1639
|
+
essential: true,
|
|
1640
|
+
fields: {
|
|
1641
|
+
errorClass: "label",
|
|
1642
|
+
boundary: "label",
|
|
1643
|
+
route: "label",
|
|
1644
|
+
fingerprint: "label",
|
|
1645
|
+
count: "number"
|
|
1646
|
+
}
|
|
1647
|
+
},
|
|
1648
|
+
"report.rate-limited": "Renderer error entries arrived faster than the backend records them, so `dropped` were counted and not written."
|
|
1649
|
+
}
|
|
1631
1650
|
}
|
|
1632
1651
|
});
|
|
1633
1652
|
|
|
@@ -1685,6 +1704,8 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
|
|
|
1685
1704
|
"usage-limit.notice-failed": "A usage-limit stop's outcome could not be read for its notice.",
|
|
1686
1705
|
"usage-limit.resend-failed": "Resending after a usage limit failed. An unknown send stays in the journal.",
|
|
1687
1706
|
"title.strategy-failed": "A session title strategy failed, so the next is tried. Content-free: the error can quote the prompt.",
|
|
1707
|
+
"steer.qualification-failed": "A bridge's steer qualification failed or answered non-OK, so steering is not offered. Agent and status code or error class only.",
|
|
1708
|
+
"steer.capability-cleared": "A projection cleared `actions.steer` because its bridge did not qualify. Identifiers and turn status only.",
|
|
1688
1709
|
...THROTTLE_LOG_EVENTS
|
|
1689
1710
|
}
|
|
1690
1711
|
},
|
|
@@ -1785,6 +1806,9 @@ var RUNTIME_LOG_AREAS = defineLogAreas({
|
|
|
1785
1806
|
essential: true,
|
|
1786
1807
|
fields: { origin: "label", ...ESSENTIAL_ERROR_FIELDS }
|
|
1787
1808
|
},
|
|
1809
|
+
"child.reaped": "A macOS child whose exit Bun lost was reaped after its command settled, so it no longer waits as a zombie.",
|
|
1810
|
+
"child.reap-abandoned": "A child whose exit Bun lost was left unreaped: `reason` says whether it was never seen as a zombie (`not-a-zombie`), too many were pending (`capacity`), or `waitpid` failed.",
|
|
1811
|
+
"child.reap-unavailable": "waitpid could not be loaded, so children whose exit Bun lost stay zombies until this process exits.",
|
|
1788
1812
|
...THROTTLE_LOG_EVENTS
|
|
1789
1813
|
}
|
|
1790
1814
|
}
|
|
@@ -2191,6 +2215,13 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
|
|
|
2191
2215
|
"store.workflows-cleared": "The workflow store was full, so a batch of its oldest finished records was removed.",
|
|
2192
2216
|
"store.workflows-in-use": "The workflow store was full and every record was still in use, so new work was refused.",
|
|
2193
2217
|
"remote-worker.settle-failed": "A remote worker could not be settled.",
|
|
2218
|
+
"node-release.failed": "Work on a node that was forgotten or handed over could not be closed; the sweep's registry check retries.",
|
|
2219
|
+
"node-release.reconcile-failed": "The sweep could not check records against the node registry; the next sweep retries.",
|
|
2220
|
+
"node-release.unregistered": "Records named a node the registry no longer holds, so their work was closed here.",
|
|
2221
|
+
"node-release.notice-failed": "The notice for work closed on a released node could not be sent; it stays owed and the sweep retries.",
|
|
2222
|
+
"node-release.no-coordinator": "Work closed on a released node belonged to a coordinator that no longer exists, so nobody was told.",
|
|
2223
|
+
"node-offline.notice-failed": "The notice that a node has been unreachable for a day could not be sent; the next failed read retries.",
|
|
2224
|
+
"node-offline.check-failed": "Whether a long-unreachable node's coordinators were told could not be checked; the next read retries.",
|
|
2194
2225
|
"checkout.merge-followed": "After an environment's PR merged, the project checkout was fast-forwarded, or `outcome` says why not.",
|
|
2195
2226
|
"checkout.merge-follow-failed": "Fast-forwarding the project checkout failed, after an environment's PR merged or before mail woke the main coordinator.",
|
|
2196
2227
|
"checkout.mail-follow": "Before mail woke the main coordinator, the project checkout was fast-forwarded (`fast-forwarded-fetched` when the fetch was slow or failed and the upstream commit already fetched was merged), or `outcome` says why not (`timed-out`, `failed`).",
|
|
@@ -2287,6 +2318,7 @@ var DOCKER_LOG_AREAS = defineLogAreas({
|
|
|
2287
2318
|
events: {
|
|
2288
2319
|
"portable-inputs.relay-missing": "Docker is rootless and the image predates the staged-input relay, so the container cannot read them until rebuilt.",
|
|
2289
2320
|
"git-mirror.mount-unavailable": "A new container gets no project Git mirror, so its clone goes to the remote.",
|
|
2321
|
+
"git-mirror.mount-withheld": "A new restricted container gets no project Git mirror because its firewall would not let it reach the project's remote, so it cannot read what the remote serves through the mirror either.",
|
|
2290
2322
|
"git-mirror.refreshed": "A project's Git mirror was built or updated.",
|
|
2291
2323
|
"git-mirror.seeded": "A project's Git mirror was built from its host checkout and only what the remote added to it.",
|
|
2292
2324
|
"git-mirror.seed-skipped": "A project's host checkout could not seed its Git mirror, so the build downloads everything.",
|
|
@@ -2463,6 +2495,7 @@ var NODES_LOG_AREAS = defineLogAreas({
|
|
|
2463
2495
|
"verification.record-failed": "A node verification could not be recorded.",
|
|
2464
2496
|
"profile.record-failed": "A node profile could not be recorded.",
|
|
2465
2497
|
"detach.unconfirmed": "A forgotten node has not confirmed the detach yet.",
|
|
2498
|
+
"grant.revocation-listener-failed": "A connection could not be told its client grant was removed; the grant is still gone.",
|
|
2466
2499
|
"handover.recovery-pending": "Command handover recovery is still pending.",
|
|
2467
2500
|
"ticket-sync.work-record-failed": "A remote build started but its ticket work location could not be saved.",
|
|
2468
2501
|
"ticket-sync.failed": "A Kanban sync with a node failed; it is retried.",
|
|
@@ -2515,7 +2548,9 @@ var HOST_LOG_AREAS = defineLogAreas({
|
|
|
2515
2548
|
"tool.missing": "A host tool was not found.",
|
|
2516
2549
|
"maintenance.listener-failed": "A host maintenance listener threw; the others still run.",
|
|
2517
2550
|
"suspend.reconcile-failed": "Reconciling due work after a host suspension failed.",
|
|
2518
|
-
"load.sample-failed": "Sampling machine load failed; the next sample retries."
|
|
2551
|
+
"load.sample-failed": "Sampling machine load failed; the next sample retries.",
|
|
2552
|
+
"usage.source-stalled": "A usage source (scope: disk or gpu-sysfs) did not answer in time; its figure is missing from the sample until it does.",
|
|
2553
|
+
...THROTTLE_LOG_EVENTS
|
|
2519
2554
|
}
|
|
2520
2555
|
}
|
|
2521
2556
|
});
|
|
@@ -3838,6 +3873,7 @@ function effectiveLogLevel(detail, area) {
|
|
|
3838
3873
|
return detail.level;
|
|
3839
3874
|
}
|
|
3840
3875
|
}
|
|
3876
|
+
var LOG_DETAIL_EXPIRY_MS = 24 * 60 * 60 * 1000;
|
|
3841
3877
|
function logDetailEnablesBridgeDiagnostics(detail) {
|
|
3842
3878
|
return LEVEL_DETAIL[effectiveLogLevel(detail, BRIDGE_DIAGNOSTICS_LOG_AREA)] >= LEVEL_DETAIL.debug;
|
|
3843
3879
|
}
|
|
@@ -7960,12 +7996,823 @@ function structuredOutputFailure(provider, code, message, options = {}) {
|
|
|
7960
7996
|
}
|
|
7961
7997
|
|
|
7962
7998
|
// ../protocol/src/node/workspace-change-probe.ts
|
|
7963
|
-
import {
|
|
7964
|
-
import { randomUUID } from "node:crypto";
|
|
7999
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
7965
8000
|
import { rmSync } from "node:fs";
|
|
7966
8001
|
import { copyFile, lstat, mkdtemp, rm } from "node:fs/promises";
|
|
7967
8002
|
import { tmpdir } from "node:os";
|
|
7968
8003
|
import { delimiter, isAbsolute, join, resolve } from "node:path";
|
|
8004
|
+
|
|
8005
|
+
// ../protocol/src/node/command-capture.ts
|
|
8006
|
+
import { spawn } from "node:child_process";
|
|
8007
|
+
import { randomUUID } from "node:crypto";
|
|
8008
|
+
import { constants as fsConstants } from "node:fs";
|
|
8009
|
+
import * as captureFs from "node:fs";
|
|
8010
|
+
import os from "node:os";
|
|
8011
|
+
import path from "node:path";
|
|
8012
|
+
import { inspect } from "node:util";
|
|
8013
|
+
|
|
8014
|
+
// ../protocol/src/node/command-failure-reason.ts
|
|
8015
|
+
var MAX_MATCHED_CHARS = 16 * 1024;
|
|
8016
|
+
var SIGNAL_PATTERN = /^SIG[A-Z0-9]{1,16}$/;
|
|
8017
|
+
var TOOL_RULES = {
|
|
8018
|
+
git: [
|
|
8019
|
+
["branch-exists", /a branch named .* already exists/i],
|
|
8020
|
+
["ref-conflict", /exists; cannot create|cannot lock ref .* is at .* but expected/i],
|
|
8021
|
+
["lock-held", /could not lock config file [^\n]*: File exists/i],
|
|
8022
|
+
["lock-held", /(?:unable to create '[^\n]*\.lock'|cannot lock ref)[^\n]*: File exists/i],
|
|
8023
|
+
["lock-held", /another git process/i],
|
|
8024
|
+
["worktree-conflict", /already (?:checked out|used by worktree)|used by worktree at/i],
|
|
8025
|
+
["invalid-ref", /not a valid (?:branch name|object name)|bad (?:revision|object)/i],
|
|
8026
|
+
["invalid-ref", /unknown revision|ambiguous argument|invalid reference/i],
|
|
8027
|
+
["branch-not-found", /no branch named|refname .* not found|branch '.*' not found/i],
|
|
8028
|
+
["branch-not-found", /did not match any file\(s\) known to git/i],
|
|
8029
|
+
["dubious-ownership", /detected dubious ownership/i],
|
|
8030
|
+
["no-remote", /does not appear to be a git repository|no such remote/i],
|
|
8031
|
+
["no-remote", /repository (?:.* )?not found/i],
|
|
8032
|
+
["not-a-repository", /not a git repository/i],
|
|
8033
|
+
["remote-ref-missing", /could(?:n't| not) find remote ref|not our ref/i],
|
|
8034
|
+
["merge-conflict", /\bCONFLICT \(|merge conflict|could not apply|unmerged files/i],
|
|
8035
|
+
["dirty-worktree", /local changes .* would be overwritten|commit your changes or stash/i],
|
|
8036
|
+
["nothing-to-commit", /nothing to commit|no changes added to commit/i],
|
|
8037
|
+
["push-rejected", /\[(?:remote )?rejected\]|non-fast-forward/i],
|
|
8038
|
+
["identity-unknown", /please tell me who you are|unable to auto-detect email/i],
|
|
8039
|
+
[
|
|
8040
|
+
"worktree-has-changes",
|
|
8041
|
+
/^fatal: [^\n]*['"] contains modified or untracked files(?:, use --force to delete it)?\.?\s*$/im
|
|
8042
|
+
],
|
|
8043
|
+
["not-a-worktree", /^fatal: [^\n]*['"] is not a working tree\.?\s*$/im],
|
|
8044
|
+
["branch-not-merged", /^(?:error|fatal): [^\n]*['"] is not fully merged\.?\s*$/im]
|
|
8045
|
+
],
|
|
8046
|
+
gh: [
|
|
8047
|
+
["pull-request-exists", /a pull request for branch .* already exists/i],
|
|
8048
|
+
["no-pull-request", /no (?:pull requests? (?:found|match)|open pull requests?\b)/i],
|
|
8049
|
+
["rate-limited", /rate limit|http 429/i],
|
|
8050
|
+
["forbidden", /http 403|resource not accessible/i],
|
|
8051
|
+
["resource-not-found", /http 404|could not resolve to a/i],
|
|
8052
|
+
["server-error", /http 5\d\d/i]
|
|
8053
|
+
],
|
|
8054
|
+
docker: [
|
|
8055
|
+
["daemon-unavailable", /cannot connect to the docker daemon|error during connect/i],
|
|
8056
|
+
[
|
|
8057
|
+
"daemon-unavailable",
|
|
8058
|
+
/is the docker daemon running|docker desktop is (?:not running|unable)/i
|
|
8059
|
+
],
|
|
8060
|
+
["container-not-found", /no such container/i],
|
|
8061
|
+
["container-not-running", /container .* is (?:not running|paused|restarting)/i],
|
|
8062
|
+
["container-name-conflict", /name .* is already in use/i],
|
|
8063
|
+
["image-not-found", /no such image|pull access denied|manifest .* not found/i],
|
|
8064
|
+
["image-not-found", /manifest unknown|repository does not exist/i],
|
|
8065
|
+
["removal-in-progress", /removal of container .* is already in progress/i],
|
|
8066
|
+
[
|
|
8067
|
+
"image-in-use",
|
|
8068
|
+
/image is (?:being used|referenced)|unable to (?:remove|delete) .*must be forced/i
|
|
8069
|
+
],
|
|
8070
|
+
["volume-in-use", /volume is in use/i],
|
|
8071
|
+
["volume-not-found", /no such volume/i],
|
|
8072
|
+
["network-in-use", /has active endpoints/i],
|
|
8073
|
+
["network-not-found", /network .* not found/i]
|
|
8074
|
+
],
|
|
8075
|
+
tmux: [
|
|
8076
|
+
["session-exists", /duplicate session/i],
|
|
8077
|
+
[
|
|
8078
|
+
"server-not-running",
|
|
8079
|
+
/no server running|failed to connect to server|no sessions|server exited|lost server/i
|
|
8080
|
+
],
|
|
8081
|
+
[
|
|
8082
|
+
"server-not-running",
|
|
8083
|
+
/error connecting to \/[^\n]* \((?:No such file or directory|Connection refused)\)/i
|
|
8084
|
+
],
|
|
8085
|
+
["session-not-found", /can't find (?:session|window|pane)|session not found/i]
|
|
8086
|
+
]
|
|
8087
|
+
};
|
|
8088
|
+
var ALL_TOOLS = Object.keys(TOOL_RULES);
|
|
8089
|
+
var SHARED_RULES = [
|
|
8090
|
+
["disk-full", /no space left|enospc|disk quota exceeded/i],
|
|
8091
|
+
["auth-failed", /authentication (?:failed|required)|could not read (?:username|password)/i],
|
|
8092
|
+
["auth-failed", /terminal prompts disabled|invalid username or password|bad credentials/i],
|
|
8093
|
+
["auth-failed", /permission denied \(|permission to \S+ denied|host key verification failed/i],
|
|
8094
|
+
["auth-failed", /gh auth login|not logged in|unauthorized|http 401|returned error: 40[13]/i],
|
|
8095
|
+
["network-failed", /could not resolve host|connection (?:timed out|refused|reset)/i],
|
|
8096
|
+
["network-failed", /network is unreachable|no route to host|temporary failure in name/i],
|
|
8097
|
+
["network-failed", /early eof|failed to connect|remote end hung up/i],
|
|
8098
|
+
["network-failed", /unable to access ['"]?https?:\/\//i],
|
|
8099
|
+
["network-failed", /tls handshake|i\/o timeout/i],
|
|
8100
|
+
[
|
|
8101
|
+
"network-failed",
|
|
8102
|
+
/error connecting to (?:https?:\/\/)?[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?(?::\d+)?(?:[\s/:]|$)/i
|
|
8103
|
+
],
|
|
8104
|
+
["port-in-use", /port is already allocated|address already in use/i],
|
|
8105
|
+
["permission-denied", /permission denied|operation not permitted|read-only file system/i],
|
|
8106
|
+
["command-not-found", /command not found/i],
|
|
8107
|
+
["path-not-found", /no such file or directory/i],
|
|
8108
|
+
["invalid-usage", /^usage: |unknown (?:option|flag|command|shorthand flag)|invalid option/im]
|
|
8109
|
+
];
|
|
8110
|
+
var TOOL_EXIT_CODES = {
|
|
8111
|
+
git: { 129: "invalid-usage" },
|
|
8112
|
+
gh: { 2: "aborted", 4: "auth-failed" },
|
|
8113
|
+
docker: { 125: "daemon-error" },
|
|
8114
|
+
tmux: {}
|
|
8115
|
+
};
|
|
8116
|
+
var SHARED_EXIT_CODES = {
|
|
8117
|
+
124: "timed-out",
|
|
8118
|
+
126: "not-executable",
|
|
8119
|
+
127: "command-not-found",
|
|
8120
|
+
137: "killed",
|
|
8121
|
+
143: "killed"
|
|
8122
|
+
};
|
|
8123
|
+
function read2(target, key) {
|
|
8124
|
+
return target[key];
|
|
8125
|
+
}
|
|
8126
|
+
function boundedForMatching(text) {
|
|
8127
|
+
if (text.length <= MAX_MATCHED_CHARS)
|
|
8128
|
+
return text;
|
|
8129
|
+
const half = MAX_MATCHED_CHARS / 2;
|
|
8130
|
+
return `${text.slice(0, half)}
|
|
8131
|
+
${text.slice(-half)}`;
|
|
8132
|
+
}
|
|
8133
|
+
function failureText(error) {
|
|
8134
|
+
const stderr = read2(error, "stderr");
|
|
8135
|
+
if (Buffer.isBuffer(stderr) && stderr.length > 0) {
|
|
8136
|
+
return boundedForMatching(stderr.subarray(-MAX_MATCHED_CHARS).toString());
|
|
8137
|
+
}
|
|
8138
|
+
if (typeof stderr === "string" && stderr.length > 0)
|
|
8139
|
+
return boundedForMatching(stderr);
|
|
8140
|
+
const message = read2(error, "message");
|
|
8141
|
+
if (typeof message !== "string")
|
|
8142
|
+
return "";
|
|
8143
|
+
return message.startsWith("Command failed") ? "" : boundedForMatching(message);
|
|
8144
|
+
}
|
|
8145
|
+
function isRawSpawnEnoent(error) {
|
|
8146
|
+
const syscall = read2(error, "syscall");
|
|
8147
|
+
return read2(error, "code") === "ENOENT" && typeof syscall === "string" && /^(?:spawn(?:Sync)?(?:\s|$)|posix_spawnp?$)/.test(syscall);
|
|
8148
|
+
}
|
|
8149
|
+
function classifiedReason(error, exitCode, signal, options) {
|
|
8150
|
+
if (read2(error, "aborted") === true)
|
|
8151
|
+
return "aborted";
|
|
8152
|
+
if (read2(error, "outputLimitExceeded") === true)
|
|
8153
|
+
return "output-too-large";
|
|
8154
|
+
if (read2(error, "timedOut") === true)
|
|
8155
|
+
return "timed-out";
|
|
8156
|
+
if (read2(error, "executableMissing") === true || isRawSpawnEnoent(error)) {
|
|
8157
|
+
return "executable-missing";
|
|
8158
|
+
}
|
|
8159
|
+
const named = exitCode === null ? undefined : options.exitCodes?.[exitCode];
|
|
8160
|
+
if (named)
|
|
8161
|
+
return named;
|
|
8162
|
+
if (signal)
|
|
8163
|
+
return "killed";
|
|
8164
|
+
const text = failureText(error);
|
|
8165
|
+
for (const tool of options.tools ?? ALL_TOOLS) {
|
|
8166
|
+
for (const [reason, pattern] of TOOL_RULES[tool]) {
|
|
8167
|
+
if (pattern.test(text))
|
|
8168
|
+
return reason;
|
|
8169
|
+
}
|
|
8170
|
+
}
|
|
8171
|
+
for (const [reason, pattern] of SHARED_RULES) {
|
|
8172
|
+
if (pattern.test(text))
|
|
8173
|
+
return reason;
|
|
8174
|
+
}
|
|
8175
|
+
if (exitCode !== null) {
|
|
8176
|
+
for (const tool of options.tools ?? []) {
|
|
8177
|
+
const reason = TOOL_EXIT_CODES[tool][exitCode];
|
|
8178
|
+
if (reason)
|
|
8179
|
+
return reason;
|
|
8180
|
+
}
|
|
8181
|
+
const reason = SHARED_EXIT_CODES[exitCode];
|
|
8182
|
+
if (reason)
|
|
8183
|
+
return reason;
|
|
8184
|
+
}
|
|
8185
|
+
return "unclassified";
|
|
8186
|
+
}
|
|
8187
|
+
function numericExitCode(error) {
|
|
8188
|
+
for (const key of ["exitCode", "code"]) {
|
|
8189
|
+
const value = read2(error, key);
|
|
8190
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
8191
|
+
return value;
|
|
8192
|
+
}
|
|
8193
|
+
return null;
|
|
8194
|
+
}
|
|
8195
|
+
function classifyCommandFailure(error, options = {}) {
|
|
8196
|
+
if (typeof error !== "object" || error === null) {
|
|
8197
|
+
return { reason: "unclassified", exitCode: null, signal: null };
|
|
8198
|
+
}
|
|
8199
|
+
try {
|
|
8200
|
+
const exitCode = numericExitCode(error);
|
|
8201
|
+
const rawSignal = read2(error, "signal");
|
|
8202
|
+
const signal = typeof rawSignal === "string" && SIGNAL_PATTERN.test(rawSignal) ? rawSignal : null;
|
|
8203
|
+
return { reason: classifiedReason(error, exitCode, signal, options), exitCode, signal };
|
|
8204
|
+
} catch {
|
|
8205
|
+
return { reason: "unclassified", exitCode: null, signal: null };
|
|
8206
|
+
}
|
|
8207
|
+
}
|
|
8208
|
+
|
|
8209
|
+
// ../protocol/src/node/lost-exit-reaper.ts
|
|
8210
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
8211
|
+
|
|
8212
|
+
// ../protocol/src/node/shell-process-state.ts
|
|
8213
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
8214
|
+
import { constants as osConstants } from "node:os";
|
|
8215
|
+
var PROCESS_INSPECTION_OPTIONS = {
|
|
8216
|
+
timeout: 100,
|
|
8217
|
+
killSignal: "SIGKILL",
|
|
8218
|
+
maxBuffer: 1024 * 1024
|
|
8219
|
+
};
|
|
8220
|
+
function bunRuntime() {
|
|
8221
|
+
return globalThis.Bun;
|
|
8222
|
+
}
|
|
8223
|
+
function decodeWaitStatus(status) {
|
|
8224
|
+
const signalNumber = status & 127;
|
|
8225
|
+
if (signalNumber === 0)
|
|
8226
|
+
return { code: status >> 8 & 255, signal: null };
|
|
8227
|
+
const name = Object.entries(osConstants.signals).find(([, value]) => value === signalNumber)?.[0];
|
|
8228
|
+
return { code: null, signal: name ?? "SIGKILL" };
|
|
8229
|
+
}
|
|
8230
|
+
function readZombieExit(pid) {
|
|
8231
|
+
try {
|
|
8232
|
+
const result = bunRuntime()?.spawnSync(["/bin/ps", "-o", "stat=,xstat=", "-p", String(pid)], PROCESS_INSPECTION_OPTIONS);
|
|
8233
|
+
if (!result?.success)
|
|
8234
|
+
return;
|
|
8235
|
+
const { stdout } = result;
|
|
8236
|
+
const match = /^Z\S*\s+([0-9a-f]+)\s*$/i.exec(stdout.toString().trim());
|
|
8237
|
+
return match ? decodeWaitStatus(Number.parseInt(match[1], 16)) : undefined;
|
|
8238
|
+
} catch {
|
|
8239
|
+
return;
|
|
8240
|
+
}
|
|
8241
|
+
}
|
|
8242
|
+
var EXIT_WATCH_MS = 1000;
|
|
8243
|
+
var EXIT_WATCH_MAX_MS = 16000;
|
|
8244
|
+
function watchForLostExit(pid, onExit) {
|
|
8245
|
+
if (process.platform !== "darwin" || pid === undefined || !bunRuntime())
|
|
8246
|
+
return () => {
|
|
8247
|
+
return;
|
|
8248
|
+
};
|
|
8249
|
+
let timer;
|
|
8250
|
+
const watch = (delayMs) => {
|
|
8251
|
+
timer = setTimeout(() => {
|
|
8252
|
+
const exit = readZombieExit(pid);
|
|
8253
|
+
if (exit)
|
|
8254
|
+
onExit(exit);
|
|
8255
|
+
else
|
|
8256
|
+
watch(Math.min(delayMs * 2, EXIT_WATCH_MAX_MS));
|
|
8257
|
+
}, delayMs);
|
|
8258
|
+
};
|
|
8259
|
+
watch(EXIT_WATCH_MS);
|
|
8260
|
+
return () => clearTimeout(timer);
|
|
8261
|
+
}
|
|
8262
|
+
function isLiveMember(state, groupId, pgid) {
|
|
8263
|
+
return Number(groupId) === pgid && state !== undefined && !/^[ZX]/.test(state);
|
|
8264
|
+
}
|
|
8265
|
+
function linuxGroupHasLiveMember(pgid) {
|
|
8266
|
+
for (const entry of readdirSync("/proc")) {
|
|
8267
|
+
if (!/^\d+$/.test(entry))
|
|
8268
|
+
continue;
|
|
8269
|
+
let stat;
|
|
8270
|
+
try {
|
|
8271
|
+
stat = readFileSync(`/proc/${entry}/stat`, "latin1");
|
|
8272
|
+
} catch {
|
|
8273
|
+
continue;
|
|
8274
|
+
}
|
|
8275
|
+
const [state, , groupId] = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
|
|
8276
|
+
if (isLiveMember(state, groupId, pgid))
|
|
8277
|
+
return true;
|
|
8278
|
+
}
|
|
8279
|
+
return false;
|
|
8280
|
+
}
|
|
8281
|
+
function psGroupHasLiveMember(pgid) {
|
|
8282
|
+
const result = bunRuntime()?.spawnSync(["/bin/ps", "-A", "-o", "pgid=,stat="], PROCESS_INSPECTION_OPTIONS);
|
|
8283
|
+
if (!result?.success)
|
|
8284
|
+
return true;
|
|
8285
|
+
return result.stdout.toString().split(`
|
|
8286
|
+
`).some((line) => {
|
|
8287
|
+
const [groupId, state] = line.trim().split(/\s+/);
|
|
8288
|
+
return isLiveMember(state, groupId, pgid);
|
|
8289
|
+
});
|
|
8290
|
+
}
|
|
8291
|
+
function groupHasLiveMember(pgid) {
|
|
8292
|
+
try {
|
|
8293
|
+
return process.platform === "linux" ? linuxGroupHasLiveMember(pgid) : psGroupHasLiveMember(pgid);
|
|
8294
|
+
} catch {
|
|
8295
|
+
return true;
|
|
8296
|
+
}
|
|
8297
|
+
}
|
|
8298
|
+
|
|
8299
|
+
// ../protocol/src/node/lost-exit-reaper.ts
|
|
8300
|
+
var log4 = createLogger("process");
|
|
8301
|
+
var REAP_GRACE_MS = 2000;
|
|
8302
|
+
var REAP_MAX_CHECK_MS = 30000;
|
|
8303
|
+
var REAP_MAX_CHECKS = 12;
|
|
8304
|
+
var REAP_MAX_PENDING = 256;
|
|
8305
|
+
function createLostExitReaper(options) {
|
|
8306
|
+
const { system } = options;
|
|
8307
|
+
const graceMs = options.graceMs ?? REAP_GRACE_MS;
|
|
8308
|
+
const maxCheckMs = options.maxCheckMs ?? REAP_MAX_CHECK_MS;
|
|
8309
|
+
const maxChecks = options.maxChecks ?? REAP_MAX_CHECKS;
|
|
8310
|
+
const maxPending = options.maxPending ?? REAP_MAX_PENDING;
|
|
8311
|
+
const pending = new Map;
|
|
8312
|
+
let reaped = 0;
|
|
8313
|
+
let abandoned = 0;
|
|
8314
|
+
const abandon = (pid, reason) => {
|
|
8315
|
+
abandoned += 1;
|
|
8316
|
+
log4.warn("child.reap-abandoned", { pid, reason });
|
|
8317
|
+
};
|
|
8318
|
+
const check = (pid, reported, startedAt) => {
|
|
8319
|
+
if (reported())
|
|
8320
|
+
return false;
|
|
8321
|
+
const found = system.inspect(pid);
|
|
8322
|
+
if (found === undefined)
|
|
8323
|
+
return true;
|
|
8324
|
+
if (found === "gone" || found.ppid !== system.selfPid)
|
|
8325
|
+
return false;
|
|
8326
|
+
if (!found.state.startsWith("Z"))
|
|
8327
|
+
return true;
|
|
8328
|
+
const result = system.waitNoHang(pid);
|
|
8329
|
+
if (result === pid) {
|
|
8330
|
+
reaped += 1;
|
|
8331
|
+
log4.info("child.reaped", { pid, waitedMs: Date.now() - startedAt });
|
|
8332
|
+
return false;
|
|
8333
|
+
}
|
|
8334
|
+
if (result === 0)
|
|
8335
|
+
return true;
|
|
8336
|
+
abandon(pid, "waitpid-failed");
|
|
8337
|
+
return false;
|
|
8338
|
+
};
|
|
8339
|
+
const schedule = (pid, reported, startedAt, delayMs, checks) => {
|
|
8340
|
+
const timer = setTimeout(() => {
|
|
8341
|
+
pending.delete(pid);
|
|
8342
|
+
let again;
|
|
8343
|
+
try {
|
|
8344
|
+
again = check(pid, reported, startedAt);
|
|
8345
|
+
} catch {
|
|
8346
|
+
again = true;
|
|
8347
|
+
}
|
|
8348
|
+
if (!again)
|
|
8349
|
+
return;
|
|
8350
|
+
if (checks + 1 >= maxChecks) {
|
|
8351
|
+
abandon(pid, "not-a-zombie");
|
|
8352
|
+
return;
|
|
8353
|
+
}
|
|
8354
|
+
schedule(pid, reported, startedAt, Math.min(delayMs * 2, maxCheckMs), checks + 1);
|
|
8355
|
+
}, delayMs);
|
|
8356
|
+
timer.unref?.();
|
|
8357
|
+
pending.set(pid, timer);
|
|
8358
|
+
};
|
|
8359
|
+
return {
|
|
8360
|
+
reap(pid, reported) {
|
|
8361
|
+
if (!Number.isSafeInteger(pid) || pid <= 1 || pid === system.selfPid)
|
|
8362
|
+
return;
|
|
8363
|
+
if (pending.has(pid) || reported())
|
|
8364
|
+
return;
|
|
8365
|
+
if (pending.size >= maxPending) {
|
|
8366
|
+
abandon(pid, "capacity");
|
|
8367
|
+
return;
|
|
8368
|
+
}
|
|
8369
|
+
schedule(pid, reported, Date.now(), graceMs, 0);
|
|
8370
|
+
},
|
|
8371
|
+
stats: () => ({ pending: pending.size, reaped, abandoned }),
|
|
8372
|
+
stop() {
|
|
8373
|
+
for (const timer of pending.values())
|
|
8374
|
+
clearTimeout(timer);
|
|
8375
|
+
pending.clear();
|
|
8376
|
+
}
|
|
8377
|
+
};
|
|
8378
|
+
}
|
|
8379
|
+
var WNOHANG = 1;
|
|
8380
|
+
function loadDarwinWaitpid(loadFfi = () => createRequire2(import.meta.url)("bun:ffi")) {
|
|
8381
|
+
try {
|
|
8382
|
+
const { dlopen, FFIType } = loadFfi();
|
|
8383
|
+
const libSystem = dlopen("/usr/lib/libSystem.B.dylib", {
|
|
8384
|
+
waitpid: { args: [FFIType.i32, FFIType.ptr, FFIType.i32], returns: FFIType.i32 }
|
|
8385
|
+
});
|
|
8386
|
+
const status = new Int32Array(1);
|
|
8387
|
+
return (pid) => libSystem.symbols.waitpid(pid, status, WNOHANG);
|
|
8388
|
+
} catch {
|
|
8389
|
+
return;
|
|
8390
|
+
}
|
|
8391
|
+
}
|
|
8392
|
+
function darwinReaperSystem(loadFfi) {
|
|
8393
|
+
const waitNoHang = loadDarwinWaitpid(loadFfi);
|
|
8394
|
+
if (!waitNoHang)
|
|
8395
|
+
return;
|
|
8396
|
+
return {
|
|
8397
|
+
selfPid: process.pid,
|
|
8398
|
+
inspect(pid) {
|
|
8399
|
+
const result = bunRuntime()?.spawnSync(["/bin/ps", "-o", "ppid=,stat=", "-p", String(pid)], PROCESS_INSPECTION_OPTIONS);
|
|
8400
|
+
if (!result)
|
|
8401
|
+
return;
|
|
8402
|
+
const output = result.stdout.toString().trim();
|
|
8403
|
+
if (!result.success)
|
|
8404
|
+
return result.exitCode === 1 && output === "" ? "gone" : undefined;
|
|
8405
|
+
const match = /^(\d+)\s+(\S+)$/.exec(output);
|
|
8406
|
+
return match ? { ppid: Number(match[1]), state: match[2] } : undefined;
|
|
8407
|
+
},
|
|
8408
|
+
waitNoHang
|
|
8409
|
+
};
|
|
8410
|
+
}
|
|
8411
|
+
var defaultReaper;
|
|
8412
|
+
function createDarwinLostExitReaper(loadFfi) {
|
|
8413
|
+
const system = darwinReaperSystem(loadFfi);
|
|
8414
|
+
if (!system)
|
|
8415
|
+
log4.warn("child.reap-unavailable");
|
|
8416
|
+
return system ? createLostExitReaper({ system }) : null;
|
|
8417
|
+
}
|
|
8418
|
+
function sharedReaper() {
|
|
8419
|
+
if (defaultReaper === undefined) {
|
|
8420
|
+
defaultReaper = createDarwinLostExitReaper();
|
|
8421
|
+
}
|
|
8422
|
+
return defaultReaper ?? undefined;
|
|
8423
|
+
}
|
|
8424
|
+
function reapAfterLostExit(pid, reported) {
|
|
8425
|
+
if (process.platform !== "darwin" || pid === undefined || !bunRuntime())
|
|
8426
|
+
return;
|
|
8427
|
+
sharedReaper()?.reap(pid, reported);
|
|
8428
|
+
}
|
|
8429
|
+
|
|
8430
|
+
// ../protocol/src/node/command-capture.ts
|
|
8431
|
+
class CommandFailedError extends Error {
|
|
8432
|
+
stdout;
|
|
8433
|
+
stdoutBytes;
|
|
8434
|
+
stderr;
|
|
8435
|
+
timedOut;
|
|
8436
|
+
outputCloseTimedOut;
|
|
8437
|
+
executableMissing;
|
|
8438
|
+
aborted;
|
|
8439
|
+
outputLimitExceeded;
|
|
8440
|
+
exitCode;
|
|
8441
|
+
signal;
|
|
8442
|
+
constructor(message, details = {}) {
|
|
8443
|
+
super(message);
|
|
8444
|
+
this.name = "CommandFailedError";
|
|
8445
|
+
this.stdout = details.stdout ?? "";
|
|
8446
|
+
this.stdoutBytes = details.stdoutBytes ?? Buffer.alloc(0);
|
|
8447
|
+
this.stderr = details.stderr ?? "";
|
|
8448
|
+
this.timedOut = details.timedOut ?? false;
|
|
8449
|
+
this.outputCloseTimedOut = details.outputCloseTimedOut ?? false;
|
|
8450
|
+
this.executableMissing = details.executableMissing ?? false;
|
|
8451
|
+
this.aborted = details.aborted ?? false;
|
|
8452
|
+
this.outputLimitExceeded = details.outputLimitExceeded ?? false;
|
|
8453
|
+
this.exitCode = details.exitCode ?? null;
|
|
8454
|
+
this.signal = details.signal ?? null;
|
|
8455
|
+
}
|
|
8456
|
+
toJSON() {
|
|
8457
|
+
return { ...formatLogError(this), ...classifyCommandFailure(this) };
|
|
8458
|
+
}
|
|
8459
|
+
[inspect.custom]() {
|
|
8460
|
+
const { name, reason, exitCode, signal, stack } = this.toJSON();
|
|
8461
|
+
const frames = stack?.length ? ` | ${stack.join(" | ")}` : "";
|
|
8462
|
+
return `${name} reason=${reason} exitCode=${exitCode} signal=${signal} outputOmitted=true${frames}`;
|
|
8463
|
+
}
|
|
8464
|
+
}
|
|
8465
|
+
function redactCommandValues(value, redactValues) {
|
|
8466
|
+
const secrets = Array.from(new Set((redactValues ?? []).filter((secret) => typeof secret === "string" && secret.length > 0))).sort((left, right) => right.length - left.length);
|
|
8467
|
+
return secrets.reduce((redacted, secret) => redacted.split(secret).join("[REDACTED]"), value);
|
|
8468
|
+
}
|
|
8469
|
+
var COMMAND_ABORTED_MESSAGE = "Command aborted";
|
|
8470
|
+
var OUTPUT_LIMIT_MESSAGE = "maxBuffer length exceeded";
|
|
8471
|
+
function commandFailureOutcome(error) {
|
|
8472
|
+
const details = error ?? {};
|
|
8473
|
+
const message = typeof details.message === "string" ? details.message : "";
|
|
8474
|
+
return {
|
|
8475
|
+
timedOut: details.killed === true,
|
|
8476
|
+
executableMissing: details.code === "ENOENT",
|
|
8477
|
+
aborted: message === COMMAND_ABORTED_MESSAGE,
|
|
8478
|
+
outputLimitExceeded: details.outputLimitExceeded === true,
|
|
8479
|
+
exitCode: typeof details.code === "number" ? details.code : null,
|
|
8480
|
+
signal: details.signal ?? null
|
|
8481
|
+
};
|
|
8482
|
+
}
|
|
8483
|
+
var commandInvocations = new Map;
|
|
8484
|
+
var commandCaptureMetrics;
|
|
8485
|
+
var commandObservers = new Map;
|
|
8486
|
+
function nonInteractiveGitEnv(env) {
|
|
8487
|
+
const merged = { ...env ?? process.env };
|
|
8488
|
+
merged.GIT_TERMINAL_PROMPT ??= "0";
|
|
8489
|
+
if (process.platform !== "win32") {
|
|
8490
|
+
merged.SSH_ASKPASS ??= "/usr/bin/false";
|
|
8491
|
+
merged.SSH_ASKPASS_REQUIRE ??= "force";
|
|
8492
|
+
}
|
|
8493
|
+
return merged;
|
|
8494
|
+
}
|
|
8495
|
+
var MAX_COMMAND_OUTPUT_BYTES = 50 * 1024 * 1024;
|
|
8496
|
+
var COMMAND_KILL_GRACE_MS = 100;
|
|
8497
|
+
var COMMAND_OUTPUT_CHECK_MS = 100;
|
|
8498
|
+
var COMMAND_GROUP_POLL_MS = 5;
|
|
8499
|
+
var COMMAND_GROUP_POLL_MAX_MS = 200;
|
|
8500
|
+
function openCaptureFile() {
|
|
8501
|
+
const filePath = path.join(os.tmpdir(), `orkestrator-capture-${randomUUID()}`);
|
|
8502
|
+
const fd = captureFs.openSync(filePath, fsConstants.O_CREAT | fsConstants.O_EXCL | fsConstants.O_RDWR | fsConstants.O_APPEND, 384);
|
|
8503
|
+
try {
|
|
8504
|
+
captureFs.unlinkSync(filePath);
|
|
8505
|
+
return fd;
|
|
8506
|
+
} catch (error) {
|
|
8507
|
+
captureFs.closeSync(fd);
|
|
8508
|
+
throw error;
|
|
8509
|
+
}
|
|
8510
|
+
}
|
|
8511
|
+
function readCaptureFile(fd, limit) {
|
|
8512
|
+
const size = Math.min(captureFs.fstatSync(fd).size, limit);
|
|
8513
|
+
const buffer = Buffer.allocUnsafe(size);
|
|
8514
|
+
let offset = 0;
|
|
8515
|
+
while (offset < size) {
|
|
8516
|
+
const bytesRead = captureFs.readSync(fd, buffer, offset, size - offset, offset);
|
|
8517
|
+
if (bytesRead === 0)
|
|
8518
|
+
break;
|
|
8519
|
+
offset += bytesRead;
|
|
8520
|
+
}
|
|
8521
|
+
return buffer.subarray(0, offset);
|
|
8522
|
+
}
|
|
8523
|
+
function spawnCaptured(command, args, options, stdoutFd, stderrFd) {
|
|
8524
|
+
const payload = options.stdin?.length ? Buffer.from(options.stdin) : undefined;
|
|
8525
|
+
const env = command === "git" ? nonInteractiveGitEnv(options.env) : options.env ?? process.env;
|
|
8526
|
+
const detached = process.platform !== "win32";
|
|
8527
|
+
const bun = bunRuntime();
|
|
8528
|
+
if (bun) {
|
|
8529
|
+
const child = bun.spawn([command, ...args], {
|
|
8530
|
+
cwd: options.cwd,
|
|
8531
|
+
env,
|
|
8532
|
+
detached,
|
|
8533
|
+
windowsHide: true,
|
|
8534
|
+
stdin: payload ?? "pipe",
|
|
8535
|
+
stdout: stdoutFd,
|
|
8536
|
+
stderr: stderrFd
|
|
8537
|
+
});
|
|
8538
|
+
if (!payload)
|
|
8539
|
+
closeStdin(child.stdin);
|
|
8540
|
+
const current = () => ({ code: child.exitCode, signal: child.signalCode });
|
|
8541
|
+
return {
|
|
8542
|
+
pid: child.pid,
|
|
8543
|
+
exited: child.exited.then(current),
|
|
8544
|
+
current,
|
|
8545
|
+
kill: (signal) => child.kill(signal)
|
|
8546
|
+
};
|
|
8547
|
+
}
|
|
8548
|
+
const child = spawn(command, args, {
|
|
8549
|
+
cwd: options.cwd,
|
|
8550
|
+
env,
|
|
8551
|
+
detached,
|
|
8552
|
+
windowsHide: true,
|
|
8553
|
+
stdio: [payload ? "pipe" : "ignore", stdoutFd, stderrFd]
|
|
8554
|
+
});
|
|
8555
|
+
if (payload) {
|
|
8556
|
+
child.stdin?.on("error", () => {
|
|
8557
|
+
return;
|
|
8558
|
+
});
|
|
8559
|
+
child.stdin?.end(payload);
|
|
8560
|
+
}
|
|
8561
|
+
return {
|
|
8562
|
+
pid: child.pid,
|
|
8563
|
+
exited: new Promise((resolve, reject) => {
|
|
8564
|
+
child.once("exit", (code, signal) => resolve({ code, signal }));
|
|
8565
|
+
child.once("error", reject);
|
|
8566
|
+
}),
|
|
8567
|
+
current: () => ({ code: child.exitCode, signal: child.signalCode }),
|
|
8568
|
+
kill: (signal) => {
|
|
8569
|
+
child.kill(signal);
|
|
8570
|
+
}
|
|
8571
|
+
};
|
|
8572
|
+
}
|
|
8573
|
+
function closeStdin(stdin) {
|
|
8574
|
+
try {
|
|
8575
|
+
Promise.resolve(stdin.end()).catch(() => {
|
|
8576
|
+
return;
|
|
8577
|
+
});
|
|
8578
|
+
} catch {}
|
|
8579
|
+
}
|
|
8580
|
+
function exitReported(child) {
|
|
8581
|
+
const { code, signal } = child.current();
|
|
8582
|
+
return code !== null || signal !== null;
|
|
8583
|
+
}
|
|
8584
|
+
function signalCommand(child, signal) {
|
|
8585
|
+
if (child.pid === undefined)
|
|
8586
|
+
return;
|
|
8587
|
+
try {
|
|
8588
|
+
if (process.platform !== "win32") {
|
|
8589
|
+
process.kill(-child.pid, signal);
|
|
8590
|
+
} else {
|
|
8591
|
+
child.kill(signal);
|
|
8592
|
+
}
|
|
8593
|
+
} catch {}
|
|
8594
|
+
}
|
|
8595
|
+
function commandGroupAlive(child) {
|
|
8596
|
+
if (process.platform === "win32" || child.pid === undefined)
|
|
8597
|
+
return false;
|
|
8598
|
+
try {
|
|
8599
|
+
process.kill(-child.pid, 0);
|
|
8600
|
+
} catch (error) {
|
|
8601
|
+
if (error.code === "ESRCH")
|
|
8602
|
+
return false;
|
|
8603
|
+
}
|
|
8604
|
+
return groupHasLiveMember(child.pid);
|
|
8605
|
+
}
|
|
8606
|
+
function executeCommandBytes(command, args, options, timeoutMs, outputLimit, stderrLimit) {
|
|
8607
|
+
return new Promise((resolve, reject) => {
|
|
8608
|
+
if (options.signal?.aborted) {
|
|
8609
|
+
reject(Object.assign(new Error(COMMAND_ABORTED_MESSAGE), { killed: true }));
|
|
8610
|
+
return;
|
|
8611
|
+
}
|
|
8612
|
+
const captureFds = [];
|
|
8613
|
+
const releaseCaptureFds = () => {
|
|
8614
|
+
for (const fd of captureFds.splice(0)) {
|
|
8615
|
+
try {
|
|
8616
|
+
captureFs.closeSync(fd);
|
|
8617
|
+
} catch {}
|
|
8618
|
+
}
|
|
8619
|
+
};
|
|
8620
|
+
try {
|
|
8621
|
+
captureFds.push(openCaptureFile());
|
|
8622
|
+
captureFds.push(openCaptureFile());
|
|
8623
|
+
} catch (error) {
|
|
8624
|
+
releaseCaptureFds();
|
|
8625
|
+
const code = error.code ?? "unknown";
|
|
8626
|
+
reject(new Error(`Could not open a command output file in the temporary directory: ${code}`));
|
|
8627
|
+
return;
|
|
8628
|
+
}
|
|
8629
|
+
const [stdoutFd, stderrFd] = captureFds;
|
|
8630
|
+
let child;
|
|
8631
|
+
try {
|
|
8632
|
+
child = spawnCaptured(command, args, options, stdoutFd, stderrFd);
|
|
8633
|
+
} catch (error) {
|
|
8634
|
+
releaseCaptureFds();
|
|
8635
|
+
reject(error);
|
|
8636
|
+
return;
|
|
8637
|
+
}
|
|
8638
|
+
let settled = false;
|
|
8639
|
+
let timedOut = false;
|
|
8640
|
+
let timeoutTimer;
|
|
8641
|
+
let groupTimer;
|
|
8642
|
+
let limitTimer;
|
|
8643
|
+
let stopExitWatch = () => {};
|
|
8644
|
+
let commandExit;
|
|
8645
|
+
const finishCapture = () => {
|
|
8646
|
+
settled = true;
|
|
8647
|
+
clearTimeout(timeoutTimer);
|
|
8648
|
+
clearTimeout(groupTimer);
|
|
8649
|
+
clearInterval(limitTimer);
|
|
8650
|
+
stopExitWatch();
|
|
8651
|
+
options.signal?.removeEventListener("abort", abort);
|
|
8652
|
+
if (!exitReported(child))
|
|
8653
|
+
reapAfterLostExit(child.pid, () => exitReported(child));
|
|
8654
|
+
try {
|
|
8655
|
+
return {
|
|
8656
|
+
stdout: readCaptureFile(stdoutFd, outputLimit),
|
|
8657
|
+
stderr: readCaptureFile(stderrFd, stderrLimit)
|
|
8658
|
+
};
|
|
8659
|
+
} catch (error) {
|
|
8660
|
+
reject(error);
|
|
8661
|
+
return;
|
|
8662
|
+
} finally {
|
|
8663
|
+
releaseCaptureFds();
|
|
8664
|
+
}
|
|
8665
|
+
};
|
|
8666
|
+
const fail = (error) => {
|
|
8667
|
+
if (settled)
|
|
8668
|
+
return;
|
|
8669
|
+
const output = finishCapture();
|
|
8670
|
+
if (output)
|
|
8671
|
+
reject(Object.assign(error, { ...output, killed: timedOut }));
|
|
8672
|
+
};
|
|
8673
|
+
const abort = () => {
|
|
8674
|
+
timedOut = true;
|
|
8675
|
+
signalCommand(child, "SIGKILL");
|
|
8676
|
+
fail(new Error(COMMAND_ABORTED_MESSAGE));
|
|
8677
|
+
};
|
|
8678
|
+
options.signal?.addEventListener("abort", abort, { once: true });
|
|
8679
|
+
const checkOutputLimit = () => {
|
|
8680
|
+
const stream = captureFs.fstatSync(stdoutFd).size > outputLimit ? "stdout" : captureFs.fstatSync(stderrFd).size > stderrLimit ? "stderr" : undefined;
|
|
8681
|
+
if (stream === undefined)
|
|
8682
|
+
return false;
|
|
8683
|
+
signalCommand(child, "SIGKILL");
|
|
8684
|
+
fail(Object.assign(new Error(`${stream} ${OUTPUT_LIMIT_MESSAGE}`), {
|
|
8685
|
+
outputLimitExceeded: true
|
|
8686
|
+
}));
|
|
8687
|
+
return true;
|
|
8688
|
+
};
|
|
8689
|
+
const failIfOverLimit = () => {
|
|
8690
|
+
try {
|
|
8691
|
+
return checkOutputLimit();
|
|
8692
|
+
} catch (error) {
|
|
8693
|
+
signalCommand(child, "SIGKILL");
|
|
8694
|
+
fail(error instanceof Error ? error : new Error(String(error)));
|
|
8695
|
+
return true;
|
|
8696
|
+
}
|
|
8697
|
+
};
|
|
8698
|
+
limitTimer = setInterval(() => {
|
|
8699
|
+
if (!settled && !timedOut)
|
|
8700
|
+
failIfOverLimit();
|
|
8701
|
+
}, COMMAND_OUTPUT_CHECK_MS);
|
|
8702
|
+
const settleOnExit = () => {
|
|
8703
|
+
if (settled || timedOut || failIfOverLimit())
|
|
8704
|
+
return;
|
|
8705
|
+
if (commandExit?.code !== 0 || commandExit.signal !== null) {
|
|
8706
|
+
fail(Object.assign(new Error(`Command failed: ${[command, ...args].join(" ")}`), {
|
|
8707
|
+
code: commandExit?.code,
|
|
8708
|
+
signal: commandExit?.signal
|
|
8709
|
+
}));
|
|
8710
|
+
return;
|
|
8711
|
+
}
|
|
8712
|
+
const output = finishCapture();
|
|
8713
|
+
if (output)
|
|
8714
|
+
resolve(output);
|
|
8715
|
+
};
|
|
8716
|
+
const awaitGroupExit = (delayMs) => {
|
|
8717
|
+
if (settled || timedOut)
|
|
8718
|
+
return;
|
|
8719
|
+
if (commandGroupAlive(child)) {
|
|
8720
|
+
groupTimer = setTimeout(awaitGroupExit, delayMs, Math.min(delayMs * 2, COMMAND_GROUP_POLL_MAX_MS));
|
|
8721
|
+
return;
|
|
8722
|
+
}
|
|
8723
|
+
settleOnExit();
|
|
8724
|
+
};
|
|
8725
|
+
const onCommandExit = (exit) => {
|
|
8726
|
+
if (commandExit)
|
|
8727
|
+
return;
|
|
8728
|
+
commandExit = exit;
|
|
8729
|
+
stopExitWatch();
|
|
8730
|
+
if (options.waitForDescendants)
|
|
8731
|
+
awaitGroupExit(COMMAND_GROUP_POLL_MS);
|
|
8732
|
+
else
|
|
8733
|
+
settleOnExit();
|
|
8734
|
+
};
|
|
8735
|
+
child.exited.then(onCommandExit, (error) => fail(error instanceof Error ? error : new Error(String(error))));
|
|
8736
|
+
stopExitWatch = watchForLostExit(child.pid, (exit) => {
|
|
8737
|
+
if (!settled && !timedOut)
|
|
8738
|
+
onCommandExit(exit);
|
|
8739
|
+
});
|
|
8740
|
+
if (timeoutMs > 0) {
|
|
8741
|
+
timeoutTimer = setTimeout(() => {
|
|
8742
|
+
timedOut = true;
|
|
8743
|
+
signalCommand(child, "SIGTERM");
|
|
8744
|
+
timeoutTimer = setTimeout(() => {
|
|
8745
|
+
signalCommand(child, "SIGKILL");
|
|
8746
|
+
fail(Object.assign(new Error(`Command timed out after ${timeoutMs} ms`), {
|
|
8747
|
+
code: child.current().code,
|
|
8748
|
+
signal: child.current().signal
|
|
8749
|
+
}));
|
|
8750
|
+
}, COMMAND_KILL_GRACE_MS);
|
|
8751
|
+
}, timeoutMs);
|
|
8752
|
+
}
|
|
8753
|
+
});
|
|
8754
|
+
}
|
|
8755
|
+
async function runCommandBytes(command, args = [], options = {}) {
|
|
8756
|
+
const timeoutMs = options.timeoutMs ?? 60000;
|
|
8757
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 0 || timeoutMs > 2147483647) {
|
|
8758
|
+
throw new RangeError("timeoutMs must be an integer between 0 and 2147483647");
|
|
8759
|
+
}
|
|
8760
|
+
const outputLimit = options.maxOutputBytes ?? MAX_COMMAND_OUTPUT_BYTES;
|
|
8761
|
+
if (!Number.isSafeInteger(outputLimit) || outputLimit <= 0) {
|
|
8762
|
+
throw new RangeError("maxOutputBytes must be a positive integer");
|
|
8763
|
+
}
|
|
8764
|
+
const stderrLimit = options.maxStderrBytes ?? outputLimit;
|
|
8765
|
+
if (!Number.isSafeInteger(stderrLimit) || stderrLimit <= 0) {
|
|
8766
|
+
throw new RangeError("maxStderrBytes must be a positive integer");
|
|
8767
|
+
}
|
|
8768
|
+
if (commandInvocations.size < 64 || commandInvocations.has(command)) {
|
|
8769
|
+
commandInvocations.set(command, (commandInvocations.get(command) ?? 0) + 1);
|
|
8770
|
+
}
|
|
8771
|
+
for (const observer of commandObservers.get(command) ?? [])
|
|
8772
|
+
observer(args);
|
|
8773
|
+
commandCaptureMetrics?.started(command, args);
|
|
8774
|
+
try {
|
|
8775
|
+
const { stdout, stderr } = await executeCommandBytes(command, args, options, timeoutMs, outputLimit, stderrLimit);
|
|
8776
|
+
commandCaptureMetrics?.capturedBytes(stdout.length);
|
|
8777
|
+
return {
|
|
8778
|
+
stdout: Buffer.isBuffer(stdout) ? stdout : Buffer.from(stdout),
|
|
8779
|
+
stderr: Buffer.isBuffer(stderr) ? stderr : Buffer.from(stderr)
|
|
8780
|
+
};
|
|
8781
|
+
} catch (error) {
|
|
8782
|
+
const outcome = commandFailureOutcome(error);
|
|
8783
|
+
const redacting = options.redactValues?.some((value) => typeof value === "string" && value.length > 0);
|
|
8784
|
+
if (error && typeof error === "object" && "stdout" in error && "stderr" in error) {
|
|
8785
|
+
const withOutput = error;
|
|
8786
|
+
const stderr = withOutput.stderr?.toString() ?? "";
|
|
8787
|
+
const stdout = withOutput.stdout?.toString() ?? "";
|
|
8788
|
+
const message = (stderr || stdout || withOutput.message || "Command failed").trim();
|
|
8789
|
+
throw new CommandFailedError(redactCommandValues(message, options.redactValues), {
|
|
8790
|
+
...outcome,
|
|
8791
|
+
stdout: redactCommandValues(stdout, options.redactValues),
|
|
8792
|
+
stderr: redactCommandValues(stderr, options.redactValues),
|
|
8793
|
+
...!redacting && Buffer.isBuffer(withOutput.stdout) ? { stdoutBytes: withOutput.stdout } : {}
|
|
8794
|
+
});
|
|
8795
|
+
}
|
|
8796
|
+
if (redacting) {
|
|
8797
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
8798
|
+
throw new CommandFailedError(redactCommandValues(message || "Command failed", options.redactValues), outcome);
|
|
8799
|
+
}
|
|
8800
|
+
if (outcome.timedOut || outcome.executableMissing) {
|
|
8801
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
8802
|
+
throw new CommandFailedError(message || "Command failed", outcome);
|
|
8803
|
+
}
|
|
8804
|
+
throw error;
|
|
8805
|
+
}
|
|
8806
|
+
}
|
|
8807
|
+
async function runCommand(command, args = [], options = {}) {
|
|
8808
|
+
const { stdout, stderr } = await runCommandBytes(command, args, options);
|
|
8809
|
+
return {
|
|
8810
|
+
stdout: redactCommandValues(stdout.toString(), options.redactValues),
|
|
8811
|
+
stderr: redactCommandValues(stderr.toString(), options.redactValues)
|
|
8812
|
+
};
|
|
8813
|
+
}
|
|
8814
|
+
|
|
8815
|
+
// ../protocol/src/node/workspace-change-probe.ts
|
|
7969
8816
|
var DEFAULT_MAX_UNTRACKED_FILE_BYTES = 2 * 1024 * 1024;
|
|
7970
8817
|
var DEFAULT_MAX_UNTRACKED_FILES = 5000;
|
|
7971
8818
|
var DEFAULT_SLOW_SNAPSHOT_MS = 500;
|
|
@@ -7983,27 +8830,16 @@ process.once("exit", () => {
|
|
|
7983
8830
|
} catch {}
|
|
7984
8831
|
}
|
|
7985
8832
|
});
|
|
7986
|
-
var runGit = (args, options) =>
|
|
7987
|
-
const
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
let stdout = "";
|
|
7994
|
-
let stdoutBytes = 0;
|
|
7995
|
-
child.stdout.setEncoding("utf8");
|
|
7996
|
-
child.stdout.on("data", (chunk) => {
|
|
7997
|
-
stdoutBytes += chunk.length;
|
|
7998
|
-
if (stdoutBytes <= GIT_MAX_BUFFER)
|
|
7999
|
-
stdout += chunk;
|
|
8833
|
+
var runGit = async (args, options) => {
|
|
8834
|
+
const { stdout } = await runCommand("git", args, {
|
|
8835
|
+
cwd: options.cwd,
|
|
8836
|
+
env: { ...process.env, ...options.env, GIT_OPTIONAL_LOCKS: "0" },
|
|
8837
|
+
timeoutMs: GIT_TIMEOUT_MS,
|
|
8838
|
+
maxOutputBytes: GIT_MAX_BUFFER,
|
|
8839
|
+
...options.stdin === undefined ? {} : { stdin: options.stdin }
|
|
8000
8840
|
});
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
child.on("close", (code) => code === 0 ? resolvePromise({ stdout }) : reject(new Error(`git exited with ${code}`)));
|
|
8004
|
-
child.stdin.on("error", () => {});
|
|
8005
|
-
child.stdin.end(options.stdin);
|
|
8006
|
-
});
|
|
8841
|
+
return { stdout };
|
|
8842
|
+
};
|
|
8007
8843
|
|
|
8008
8844
|
class WorkspaceChangeProbe {
|
|
8009
8845
|
git;
|
|
@@ -8291,7 +9127,7 @@ class WorkspaceChangeProbe {
|
|
|
8291
9127
|
return;
|
|
8292
9128
|
const { root, indexPath } = repo.location;
|
|
8293
9129
|
const started = this.now();
|
|
8294
|
-
const tempIndex = join(this.tempDir, `orkestrator-probe-${
|
|
9130
|
+
const tempIndex = join(this.tempDir, `orkestrator-probe-${randomUUID2()}.index`);
|
|
8295
9131
|
const objectDirectory = await mkdtemp(join(this.tempDir, "orkestrator-probe-objects-"));
|
|
8296
9132
|
temporaryObjectDirectories.add(objectDirectory);
|
|
8297
9133
|
let retained = false;
|
|
@@ -9062,7 +9898,7 @@ function registerSessionActivityBatchRoute(app, runtime) {
|
|
|
9062
9898
|
}
|
|
9063
9899
|
|
|
9064
9900
|
// ../../bridges/codex-bridge/src/transcript-routes.ts
|
|
9065
|
-
import { randomUUID as
|
|
9901
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
9066
9902
|
|
|
9067
9903
|
// ../protocol/src/node/revised-rows.ts
|
|
9068
9904
|
import { createHash as createHash3 } from "node:crypto";
|
|
@@ -9671,7 +10507,7 @@ function changeEvidenceAckRouteBody(spool, body) {
|
|
|
9671
10507
|
}
|
|
9672
10508
|
|
|
9673
10509
|
// ../../bridges/codex-bridge/src/transcript-routes.ts
|
|
9674
|
-
var TRANSCRIPT_PROCESS =
|
|
10510
|
+
var TRANSCRIPT_PROCESS = randomUUID3();
|
|
9675
10511
|
function codexTranscriptSource(runtime, sessionId) {
|
|
9676
10512
|
const status = runtime.getStatus(sessionId, false);
|
|
9677
10513
|
const cached = runtime.getCachedMessages(sessionId);
|
|
@@ -10129,8 +10965,8 @@ function workspaceObservationReportIssues(value) {
|
|
|
10129
10965
|
}
|
|
10130
10966
|
|
|
10131
10967
|
// ../protocol/src/node/change-tracking/evidence-spool.ts
|
|
10132
|
-
import { createHash as createHash5, randomUUID as
|
|
10133
|
-
import { readdirSync, readFileSync } from "node:fs";
|
|
10968
|
+
import { createHash as createHash5, randomUUID as randomUUID4 } from "node:crypto";
|
|
10969
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
10134
10970
|
import { appendFile, mkdir, rename, rm as rm2, writeFile } from "node:fs/promises";
|
|
10135
10971
|
import { join as join3 } from "node:path";
|
|
10136
10972
|
var DEFAULT_EVIDENCE_SPOOL_LIMITS = {
|
|
@@ -10175,7 +11011,7 @@ class ChangeEvidenceSpool {
|
|
|
10175
11011
|
restoring = false;
|
|
10176
11012
|
constructor(options = {}) {
|
|
10177
11013
|
this.limits = { ...DEFAULT_EVIDENCE_SPOOL_LIMITS, ...options.limits };
|
|
10178
|
-
this.runtimeEpoch = options.runtimeEpoch ??
|
|
11014
|
+
this.runtimeEpoch = options.runtimeEpoch ?? randomUUID4();
|
|
10179
11015
|
this.directory = options.directory;
|
|
10180
11016
|
if (this.directory) {
|
|
10181
11017
|
this.restoring = true;
|
|
@@ -10278,7 +11114,7 @@ class ChangeEvidenceSpool {
|
|
|
10278
11114
|
return;
|
|
10279
11115
|
if (this.entries.length >= this.limits.maxEntries - 1)
|
|
10280
11116
|
return;
|
|
10281
|
-
const gapId =
|
|
11117
|
+
const gapId = randomUUID4();
|
|
10282
11118
|
const coverage = this.droppedUnknown ? {
|
|
10283
11119
|
kind: "unknown-range",
|
|
10284
11120
|
bindingId: this.gapBindingId || "unknown",
|
|
@@ -10440,8 +11276,8 @@ class ChangeEvidenceSpool {
|
|
|
10440
11276
|
restore(directory) {
|
|
10441
11277
|
const bodyDirectory = join3(directory, BODY_DIRECTORY);
|
|
10442
11278
|
try {
|
|
10443
|
-
for (const name of
|
|
10444
|
-
const bytes = new Uint8Array(
|
|
11279
|
+
for (const name of readdirSync2(bodyDirectory)) {
|
|
11280
|
+
const bytes = new Uint8Array(readFileSync2(join3(bodyDirectory, name)));
|
|
10445
11281
|
const id = evidenceBodyId(bytes);
|
|
10446
11282
|
if (bodyFileName(id) !== name)
|
|
10447
11283
|
continue;
|
|
@@ -10453,7 +11289,7 @@ class ChangeEvidenceSpool {
|
|
|
10453
11289
|
} catch {}
|
|
10454
11290
|
let text = "";
|
|
10455
11291
|
try {
|
|
10456
|
-
text =
|
|
11292
|
+
text = readFileSync2(join3(directory, ENTRIES_FILE), "utf8");
|
|
10457
11293
|
} catch {
|
|
10458
11294
|
return;
|
|
10459
11295
|
}
|
|
@@ -11355,12 +12191,12 @@ async function inheritCommandChanges(codexHome, parentThreadId, forkThreadId, me
|
|
|
11355
12191
|
}
|
|
11356
12192
|
|
|
11357
12193
|
// ../../bridges/codex-bridge/src/change-evidence-migration.ts
|
|
11358
|
-
import { randomUUID as
|
|
12194
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
11359
12195
|
import {
|
|
11360
12196
|
existsSync,
|
|
11361
12197
|
mkdirSync,
|
|
11362
|
-
readFileSync as
|
|
11363
|
-
readdirSync as
|
|
12198
|
+
readFileSync as readFileSync3,
|
|
12199
|
+
readdirSync as readdirSync3,
|
|
11364
12200
|
renameSync,
|
|
11365
12201
|
rmSync as rmSync2,
|
|
11366
12202
|
statSync,
|
|
@@ -11371,13 +12207,13 @@ import { isDeepStrictEqual } from "node:util";
|
|
|
11371
12207
|
function readBounded(path, limit) {
|
|
11372
12208
|
if (statSync(path).size > limit)
|
|
11373
12209
|
throw new Error("Evidence migration exceeds storage capacity");
|
|
11374
|
-
const bytes =
|
|
12210
|
+
const bytes = readFileSync3(path);
|
|
11375
12211
|
if (bytes.length > limit)
|
|
11376
12212
|
throw new Error("Evidence migration exceeds storage capacity");
|
|
11377
12213
|
return bytes;
|
|
11378
12214
|
}
|
|
11379
12215
|
function publishFile(path, contents) {
|
|
11380
|
-
const temporary = `${path}.${
|
|
12216
|
+
const temporary = `${path}.${randomUUID5()}.tmp`;
|
|
11381
12217
|
try {
|
|
11382
12218
|
writeFileSync(temporary, contents, { mode: 384 });
|
|
11383
12219
|
renameSync(temporary, path);
|
|
@@ -11448,7 +12284,7 @@ function migrateCodexChangeEvidence(legacy, shared) {
|
|
|
11448
12284
|
publishFile(target, bytes);
|
|
11449
12285
|
}
|
|
11450
12286
|
const retainedNames = new Set([...bodyIds].map((id) => id.replace(/[^A-Za-z0-9]/g, "_")));
|
|
11451
|
-
for (const name of
|
|
12287
|
+
for (const name of readdirSync3(join7(shared, "bodies"))) {
|
|
11452
12288
|
if (/^sha256_[a-f0-9]{64}$/.test(name) && !retainedNames.has(name)) {
|
|
11453
12289
|
rmSync2(join7(shared, "bodies", name));
|
|
11454
12290
|
}
|
|
@@ -12362,7 +13198,7 @@ function humanPromptObservation(messages, tasks) {
|
|
|
12362
13198
|
var USAGE_LIMIT_ERROR_CODE = "usage-limit";
|
|
12363
13199
|
|
|
12364
13200
|
// ../../bridges/codex-bridge/src/sessions/typed-prompts.ts
|
|
12365
|
-
import { createHash as createHash7, randomUUID as
|
|
13201
|
+
import { createHash as createHash7, randomUUID as randomUUID6 } from "node:crypto";
|
|
12366
13202
|
import { mkdir as mkdir4, open, opendir, rename as rename3, rm as rm4, writeFile as writeFile3 } from "node:fs/promises";
|
|
12367
13203
|
import { dirname as dirname2, join as join10 } from "node:path";
|
|
12368
13204
|
var MAX_TYPED_PROMPT_CHARS = 32000;
|
|
@@ -12406,7 +13242,7 @@ var writes = new Map;
|
|
|
12406
13242
|
async function writeRecord(path, record) {
|
|
12407
13243
|
const pending = (writes.get(path) ?? Promise.resolve()).then(async () => {
|
|
12408
13244
|
await mkdir4(dirname2(path), { recursive: true, mode: 448 });
|
|
12409
|
-
const temp = `${path}.${
|
|
13245
|
+
const temp = `${path}.${randomUUID6()}.tmp`;
|
|
12410
13246
|
try {
|
|
12411
13247
|
await writeFile3(temp, JSON.stringify(record), { mode: 384, flag: "wx" });
|
|
12412
13248
|
await rename3(temp, path);
|
|
@@ -16421,6 +17257,8 @@ function codeModeMcpCallPart(call, toolUseId) {
|
|
|
16421
17257
|
|
|
16422
17258
|
// ../protocol/src/coordinator.ts
|
|
16423
17259
|
var COORDINATOR_CODEX_USER_SKILLS_DIR_ENV = "ORKESTRATOR_COORDINATOR_CODEX_USER_SKILLS_DIR";
|
|
17260
|
+
var COORDINATOR_OTHER_ENVIRONMENTS_SETTING_LABEL = "Let the coordinator use environments it did not create";
|
|
17261
|
+
var COORDINATOR_ENVIRONMENT_ORIGIN_REFUSAL = `Not done: this coordinator did not create that environment, so it may not send it work. Do not retry. Use an environment this coordinator launched, or start a new one. If the user wants this coordinator to work in environments it did not create, tell them to turn on "${COORDINATOR_OTHER_ENVIRONMENTS_SETTING_LABEL}" in this project's settings, under Coordinator.`;
|
|
16424
17262
|
var COORDINATOR_CONTROL_TOOL_NAMES = Object.freeze([
|
|
16425
17263
|
"ack_message",
|
|
16426
17264
|
"add_ticket_comment",
|
|
@@ -16890,7 +17728,7 @@ async function readSessionIndex(path) {
|
|
|
16890
17728
|
}
|
|
16891
17729
|
|
|
16892
17730
|
// ../../bridges/codex-bridge/src/history/rollout.ts
|
|
16893
|
-
var
|
|
17731
|
+
var log5 = createLogger("bridge.codex");
|
|
16894
17732
|
function getCodexHomeDir() {
|
|
16895
17733
|
return process.env.CODEX_HOME || join11(homedir(), ".codex");
|
|
16896
17734
|
}
|
|
@@ -17459,7 +18297,7 @@ async function hydrateMessagesFromPersistedSession(threadId, options = {}) {
|
|
|
17459
18297
|
};
|
|
17460
18298
|
}
|
|
17461
18299
|
}
|
|
17462
|
-
|
|
18300
|
+
log5.warn("rollout.hydrate-failed", { threadId });
|
|
17463
18301
|
return {
|
|
17464
18302
|
messages: [],
|
|
17465
18303
|
title: meta.title,
|
|
@@ -17948,7 +18786,7 @@ async function replayPersistedRollout(threadId, snapshot, meta, structuredTurns)
|
|
|
17948
18786
|
}
|
|
17949
18787
|
|
|
17950
18788
|
// ../../bridges/codex-bridge/src/messages/render-turn.ts
|
|
17951
|
-
var
|
|
18789
|
+
var log6 = createLogger("bridge.codex");
|
|
17952
18790
|
var TRUNCATION_NOTICE = `
|
|
17953
18791
|
… output truncated`;
|
|
17954
18792
|
var SUBAGENT_TRANSCRIPT_PROBE_INTERVAL_MS = 2000;
|
|
@@ -18369,7 +19207,7 @@ async function renderTurn(turn, options) {
|
|
|
18369
19207
|
loadSnapshot = latestSnapshot;
|
|
18370
19208
|
}
|
|
18371
19209
|
} catch (error) {
|
|
18372
|
-
|
|
19210
|
+
log6.warn("subagent.activity-load-failed", { error: formatLogError(error) });
|
|
18373
19211
|
}
|
|
18374
19212
|
}
|
|
18375
19213
|
const { items, itemsByKey, accumulatorsByKey, versionsByKey, itemKeys } = collectTurnItems(turn, options.segment);
|
|
@@ -18760,7 +19598,7 @@ async function publishAssistantRows(context, state, turn, options) {
|
|
|
18760
19598
|
}
|
|
18761
19599
|
|
|
18762
19600
|
// ../../bridges/codex-bridge/src/app-server-runtime-sessions.ts
|
|
18763
|
-
import { createHash as createHash13, randomUUID as
|
|
19601
|
+
import { createHash as createHash13, randomUUID as randomUUID9 } from "node:crypto";
|
|
18764
19602
|
|
|
18765
19603
|
// ../protocol/src/agent-mail.ts
|
|
18766
19604
|
var AGENT_MAIL_MAX_BODY_BYTES = 32 * 1024;
|
|
@@ -19100,8 +19938,8 @@ import { createHash as createHash12 } from "node:crypto";
|
|
|
19100
19938
|
import { isAbsolute as isAbsolute9, join as join20 } from "node:path";
|
|
19101
19939
|
|
|
19102
19940
|
// ../../bridges/codex-bridge/src/app-server/process-supervisor.ts
|
|
19103
|
-
import { execFile as
|
|
19104
|
-
import { randomUUID as
|
|
19941
|
+
import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
|
|
19942
|
+
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
19105
19943
|
import {
|
|
19106
19944
|
link,
|
|
19107
19945
|
mkdir as mkdir6,
|
|
@@ -19366,7 +20204,7 @@ function extractThreadId(params) {
|
|
|
19366
20204
|
}
|
|
19367
20205
|
|
|
19368
20206
|
// ../../bridges/codex-bridge/src/app-server/jsonl-rpc-client.ts
|
|
19369
|
-
var
|
|
20207
|
+
var log7 = createLogger("bridge.codex");
|
|
19370
20208
|
var DEFAULT_MAX_INBOUND_LINE_BYTES = 64 * 1024 * 1024;
|
|
19371
20209
|
var DEFAULT_MAX_OUTBOUND_LINE_BYTES = 32 * 1024 * 1024;
|
|
19372
20210
|
var DEFAULT_REQUEST_TIMEOUT_MS = 60000;
|
|
@@ -19478,7 +20316,7 @@ class JsonlRpcClient {
|
|
|
19478
20316
|
try {
|
|
19479
20317
|
this.options.recordInboundLine(line);
|
|
19480
20318
|
} catch (error) {
|
|
19481
|
-
|
|
20319
|
+
log7.error("recorder.threw", { error: formatLogError(error) });
|
|
19482
20320
|
}
|
|
19483
20321
|
}
|
|
19484
20322
|
const message = parseInboundLine(line);
|
|
@@ -19510,7 +20348,7 @@ class JsonlRpcClient {
|
|
|
19510
20348
|
try {
|
|
19511
20349
|
this.options.onServerRequest(message);
|
|
19512
20350
|
} catch (error) {
|
|
19513
|
-
|
|
20351
|
+
log7.error("server-request.handoff-failed", { error: formatLogError(error) });
|
|
19514
20352
|
}
|
|
19515
20353
|
return;
|
|
19516
20354
|
}
|
|
@@ -19519,7 +20357,7 @@ class JsonlRpcClient {
|
|
|
19519
20357
|
try {
|
|
19520
20358
|
this.options.onNotification(message, extractThreadId(message.params), Buffer.byteLength(line, "utf8"));
|
|
19521
20359
|
} catch (error) {
|
|
19522
|
-
|
|
20360
|
+
log7.error("notification.enqueue-failed", { error: formatLogError(error) });
|
|
19523
20361
|
}
|
|
19524
20362
|
return;
|
|
19525
20363
|
}
|
|
@@ -19701,7 +20539,7 @@ class SerialQueue {
|
|
|
19701
20539
|
run(key, task, bytes = 0) {
|
|
19702
20540
|
if (this.depth >= this.maxDepth || this.bytes + bytes > this.maxBytes) {
|
|
19703
20541
|
const overflow = { depth: this.depth, bytes: this.bytes };
|
|
19704
|
-
|
|
20542
|
+
log7.error("queue.overflow", overflow);
|
|
19705
20543
|
this.clear();
|
|
19706
20544
|
this.onOverflow?.(overflow);
|
|
19707
20545
|
return;
|
|
@@ -19781,16 +20619,16 @@ class SerialQueue {
|
|
|
19781
20619
|
queue.waiters.splice(0, resolved);
|
|
19782
20620
|
}
|
|
19783
20621
|
reportTaskFailure(key, error) {
|
|
19784
|
-
|
|
20622
|
+
log7.error("queue.task-failed", { key, error: formatLogError(error) });
|
|
19785
20623
|
}
|
|
19786
20624
|
}
|
|
19787
20625
|
|
|
19788
20626
|
// ../../bridges/codex-bridge/src/app-server/notification-recorder.ts
|
|
19789
20627
|
import { appendFile as appendFile4, mkdir as mkdir5 } from "node:fs/promises";
|
|
19790
20628
|
import { join as join13 } from "node:path";
|
|
19791
|
-
var
|
|
20629
|
+
var log8 = createLogger("bridge.codex");
|
|
19792
20630
|
function recorderNotice(message) {
|
|
19793
|
-
|
|
20631
|
+
log8.warn("recorder.notice", { detail: message });
|
|
19794
20632
|
}
|
|
19795
20633
|
var DEFAULT_MAX_RECORDING_BYTES = 64 * 1024 * 1024;
|
|
19796
20634
|
var DEFAULT_FLUSH_INTERVAL_MS = 250;
|
|
@@ -19903,7 +20741,7 @@ class NotificationRecorder {
|
|
|
19903
20741
|
} catch (error) {
|
|
19904
20742
|
this.stats.writeErrors += 1;
|
|
19905
20743
|
this.stats.linesDropped += pending.length;
|
|
19906
|
-
|
|
20744
|
+
log8.error("recorder.write-failed", { error: formatLogError(error, { stack: false }) });
|
|
19907
20745
|
}
|
|
19908
20746
|
}
|
|
19909
20747
|
async close() {
|
|
@@ -19938,8 +20776,8 @@ function createRecorderFromEnv(options) {
|
|
|
19938
20776
|
import { execFile as execFileCallback } from "node:child_process";
|
|
19939
20777
|
import { createHash as createHash9 } from "node:crypto";
|
|
19940
20778
|
import { promisify } from "node:util";
|
|
19941
|
-
var
|
|
19942
|
-
var
|
|
20779
|
+
var log9 = createLogger("bridge.codex");
|
|
20780
|
+
var execFile = promisify(execFileCallback);
|
|
19943
20781
|
var RUNTIME_ENV_SCRIPT_ENV = "ORKESTRATOR_RUNTIME_ENV_SCRIPT";
|
|
19944
20782
|
var DEFAULT_RUNTIME_ENV_SCRIPT = "/usr/local/bin/orkestrator-runtime-env.sh";
|
|
19945
20783
|
var RUNTIME_ENV_CREDENTIAL_VARIABLES = new Set([
|
|
@@ -20001,7 +20839,7 @@ function applyRuntimeEnvironmentOutput(output) {
|
|
|
20001
20839
|
}
|
|
20002
20840
|
return updated;
|
|
20003
20841
|
}
|
|
20004
|
-
async function refreshRuntimeEnvironment(run =
|
|
20842
|
+
async function refreshRuntimeEnvironment(run = execFile) {
|
|
20005
20843
|
try {
|
|
20006
20844
|
const runtimeEnvScript = getRuntimeEnvironmentScriptPath();
|
|
20007
20845
|
const { stdout } = await run("/bin/sh", [
|
|
@@ -20016,10 +20854,10 @@ async function refreshRuntimeEnvironment(run = execFile2) {
|
|
|
20016
20854
|
});
|
|
20017
20855
|
const updated = applyRuntimeEnvironmentOutput(stdout);
|
|
20018
20856
|
if (updated.length > 0) {
|
|
20019
|
-
|
|
20857
|
+
log9.info("runtime-env.refreshed", { names: updated.join(", ") });
|
|
20020
20858
|
}
|
|
20021
20859
|
} catch (error) {
|
|
20022
|
-
|
|
20860
|
+
log9.warn("runtime-env.refresh-failed", { error: formatLogError(error) });
|
|
20023
20861
|
}
|
|
20024
20862
|
}
|
|
20025
20863
|
function fingerprintRuntimeEnvironment(env = process.env) {
|
|
@@ -20039,7 +20877,7 @@ function runtimeEnvironmentSnapshot(env = process.env) {
|
|
|
20039
20877
|
}
|
|
20040
20878
|
|
|
20041
20879
|
// ../../bridges/codex-bridge/src/app-server/process-supervisor.ts
|
|
20042
|
-
var
|
|
20880
|
+
var log10 = createLogger("bridge.codex");
|
|
20043
20881
|
|
|
20044
20882
|
class AppServerOwnershipUnavailableError extends AppServerUnavailableError {
|
|
20045
20883
|
ownershipContention = true;
|
|
@@ -20094,7 +20932,7 @@ class AppServerSupervisor {
|
|
|
20094
20932
|
unknownNotifications = 0;
|
|
20095
20933
|
unknownServerRequests = 0;
|
|
20096
20934
|
drainPromise = null;
|
|
20097
|
-
pidOwnerToken =
|
|
20935
|
+
pidOwnerToken = randomUUID7();
|
|
20098
20936
|
pidOwnershipHeld = false;
|
|
20099
20937
|
constructor(options) {
|
|
20100
20938
|
this.options = options;
|
|
@@ -20258,7 +21096,7 @@ class AppServerSupervisor {
|
|
|
20258
21096
|
if (this.stopping)
|
|
20259
21097
|
throw new AppServerUnavailableError("stopped");
|
|
20260
21098
|
const environmentFingerprint = this.fingerprintEnvironment();
|
|
20261
|
-
const instanceId =
|
|
21099
|
+
const instanceId = randomUUID7();
|
|
20262
21100
|
const instanceStartedAt = this.now();
|
|
20263
21101
|
if (this.options.pidFileEnabled !== false && !this.pidOwnershipHeld) {
|
|
20264
21102
|
const available = await this.acquirePidFileOwnership(instanceId);
|
|
@@ -20325,7 +21163,7 @@ class AppServerSupervisor {
|
|
|
20325
21163
|
if (describedLines >= STDERR_METADATA_LINE_BUDGET)
|
|
20326
21164
|
return;
|
|
20327
21165
|
describedLines += 1;
|
|
20328
|
-
|
|
21166
|
+
log10.info("app-server.stderr", () => ({
|
|
20329
21167
|
generation: generationId,
|
|
20330
21168
|
detail: describeChildStderrLine(line)
|
|
20331
21169
|
}));
|
|
@@ -20349,7 +21187,7 @@ class AppServerSupervisor {
|
|
|
20349
21187
|
stderrTail = "";
|
|
20350
21188
|
if (suppressedLines === 0)
|
|
20351
21189
|
return;
|
|
20352
|
-
|
|
21190
|
+
log10.info("app-server.stderr-suppressed", {
|
|
20353
21191
|
generation: generationId,
|
|
20354
21192
|
lines: suppressedLines,
|
|
20355
21193
|
payloadBytes: suppressedBytes
|
|
@@ -20359,7 +21197,7 @@ class AppServerSupervisor {
|
|
|
20359
21197
|
};
|
|
20360
21198
|
const recorder = (this.options.createRecorder ?? ((generation) => createRecorderFromEnv({ generation })))(generationId);
|
|
20361
21199
|
if (recorder) {
|
|
20362
|
-
|
|
21200
|
+
log10.warn("app-server.recording", {
|
|
20363
21201
|
generation: generationId,
|
|
20364
21202
|
fileName: recorder.getStats().fileName
|
|
20365
21203
|
});
|
|
@@ -20372,7 +21210,7 @@ class AppServerSupervisor {
|
|
|
20372
21210
|
onServerRequest: (request) => this.options.onServerRequest(request, generationId),
|
|
20373
21211
|
onProtocolViolation: (detail) => {
|
|
20374
21212
|
this.unknownNotifications += 1;
|
|
20375
|
-
|
|
21213
|
+
log10.warn("app-server.protocol-violation", { generation: generationId, detail });
|
|
20376
21214
|
},
|
|
20377
21215
|
...recorder ? { recordInboundLine: (line) => recorder.record(line) } : {}
|
|
20378
21216
|
});
|
|
@@ -20450,7 +21288,7 @@ class AppServerSupervisor {
|
|
|
20450
21288
|
return;
|
|
20451
21289
|
const exited = this.current;
|
|
20452
21290
|
this.current = null;
|
|
20453
|
-
|
|
21291
|
+
log10.warn("app-server.exited", {
|
|
20454
21292
|
generation: generationId,
|
|
20455
21293
|
code,
|
|
20456
21294
|
signal,
|
|
@@ -20470,7 +21308,7 @@ class AppServerSupervisor {
|
|
|
20470
21308
|
const reason = "notification queue overflowed";
|
|
20471
21309
|
this.lastError = reason;
|
|
20472
21310
|
this.restartNow(reason).catch((error) => {
|
|
20473
|
-
|
|
21311
|
+
log10.error("app-server.overflow-restart-failed", { error: formatLogError(error) });
|
|
20474
21312
|
});
|
|
20475
21313
|
}
|
|
20476
21314
|
async ensureEnvironmentIsCurrent(options) {
|
|
@@ -20723,7 +21561,7 @@ class AppServerSupervisor {
|
|
|
20723
21561
|
if (outcome === "contended")
|
|
20724
21562
|
return true;
|
|
20725
21563
|
if (matches && pid !== null) {
|
|
20726
|
-
|
|
21564
|
+
log10.info("app-server.stale-reaped", { pid });
|
|
20727
21565
|
(this.options.signalPidFileProcess ?? signalStaleProcessTree)(pid);
|
|
20728
21566
|
}
|
|
20729
21567
|
return true;
|
|
@@ -20836,7 +21674,7 @@ class AppServerSupervisor {
|
|
|
20836
21674
|
}
|
|
20837
21675
|
function runPs(args) {
|
|
20838
21676
|
return new Promise((resolve, reject) => {
|
|
20839
|
-
|
|
21677
|
+
execFile2("/bin/ps", args, {
|
|
20840
21678
|
maxBuffer: 1024 * 1024,
|
|
20841
21679
|
env: { ...runtimeEnvironmentSnapshot(), LC_ALL: "C", LANG: "C", TZ: process.env.TZ }
|
|
20842
21680
|
}, (error, stdout) => {
|
|
@@ -21400,7 +22238,7 @@ function buildInteractionResponse(request, answer) {
|
|
|
21400
22238
|
}
|
|
21401
22239
|
|
|
21402
22240
|
// ../../bridges/codex-bridge/src/app-server/server-request-router.ts
|
|
21403
|
-
var
|
|
22241
|
+
var log11 = createLogger("bridge.codex");
|
|
21404
22242
|
var DEFAULT_RESPONSE_TIMEOUT_MS = 1e4;
|
|
21405
22243
|
var DEFAULT_APPROVAL_TIMEOUT_MS = AGENT_INTERACTION_DEFAULT_TIMEOUT_MS;
|
|
21406
22244
|
|
|
@@ -21560,7 +22398,7 @@ class ServerRequestRouter {
|
|
|
21560
22398
|
record.timedOut = true;
|
|
21561
22399
|
this.counts.timedOut += 1;
|
|
21562
22400
|
if (this.sendStarted.has(key)) {
|
|
21563
|
-
|
|
22401
|
+
log11.error("server-request.flush-timeout", {
|
|
21564
22402
|
method: record.method,
|
|
21565
22403
|
timeoutMs: this.responseTimeoutMs
|
|
21566
22404
|
});
|
|
@@ -21664,7 +22502,7 @@ class ServerRequestRouter {
|
|
|
21664
22502
|
accepted = this.options.presentApproval?.(approval) === true;
|
|
21665
22503
|
} catch (error) {
|
|
21666
22504
|
deadline.settle();
|
|
21667
|
-
|
|
22505
|
+
log11.error("approval.present-failed", { error: formatLogError(error) });
|
|
21668
22506
|
return false;
|
|
21669
22507
|
}
|
|
21670
22508
|
if (!accepted) {
|
|
@@ -21701,7 +22539,7 @@ class ServerRequestRouter {
|
|
|
21701
22539
|
try {
|
|
21702
22540
|
this.options.onApprovalResolved?.(parked.request, decision, resolution);
|
|
21703
22541
|
} catch (error) {
|
|
21704
|
-
|
|
22542
|
+
log11.error("approval.resolved-callback-failed", { error: formatLogError(error) });
|
|
21705
22543
|
}
|
|
21706
22544
|
if (options.skipSend) {
|
|
21707
22545
|
this.pending.delete(parked.key);
|
|
@@ -21722,7 +22560,7 @@ class ServerRequestRouter {
|
|
|
21722
22560
|
try {
|
|
21723
22561
|
this.options.onApprovalResolved?.(parked.request, "withdrawn", "withdrawn");
|
|
21724
22562
|
} catch (error) {
|
|
21725
|
-
|
|
22563
|
+
log11.error("approval.resolved-callback-failed", { error: formatLogError(error) });
|
|
21726
22564
|
}
|
|
21727
22565
|
this.pending.delete(parked.key);
|
|
21728
22566
|
this.sendStarted.delete(parked.key);
|
|
@@ -21764,7 +22602,7 @@ class ServerRequestRouter {
|
|
|
21764
22602
|
accepted = this.options.presentInteraction?.(interaction) === true;
|
|
21765
22603
|
} catch (error) {
|
|
21766
22604
|
deadline?.settle();
|
|
21767
|
-
|
|
22605
|
+
log11.error("interaction.present-failed", { error: formatLogError(error) });
|
|
21768
22606
|
return false;
|
|
21769
22607
|
}
|
|
21770
22608
|
if (!accepted) {
|
|
@@ -21800,7 +22638,7 @@ class ServerRequestRouter {
|
|
|
21800
22638
|
try {
|
|
21801
22639
|
this.options.onInteractionResolved?.(parked.request, answer, resolution);
|
|
21802
22640
|
} catch (error) {
|
|
21803
|
-
|
|
22641
|
+
log11.error("interaction.resolved-callback-failed", { error: formatLogError(error) });
|
|
21804
22642
|
}
|
|
21805
22643
|
if (options.skipSend) {
|
|
21806
22644
|
this.pending.delete(parked.key);
|
|
@@ -21833,7 +22671,7 @@ class ServerRequestRouter {
|
|
|
21833
22671
|
try {
|
|
21834
22672
|
await send();
|
|
21835
22673
|
} catch (error) {
|
|
21836
|
-
|
|
22674
|
+
log11.error("server-request.answer-failed", {
|
|
21837
22675
|
method: record.method,
|
|
21838
22676
|
error: formatLogError(error, { stack: false })
|
|
21839
22677
|
});
|
|
@@ -21850,7 +22688,7 @@ class ServerRequestRouter {
|
|
|
21850
22688
|
}
|
|
21851
22689
|
violation(method, detail) {
|
|
21852
22690
|
this.options.onInvariantViolation?.(method, detail);
|
|
21853
|
-
|
|
22691
|
+
log11.error("app-server.invariant-violation", { method, detail });
|
|
21854
22692
|
}
|
|
21855
22693
|
explain(record, message) {
|
|
21856
22694
|
this.options.reportToTranscript?.({
|
|
@@ -22441,7 +23279,7 @@ import { mkdir as mkdir8, open as open7, rename as rename6, rm as rm7, writeFile
|
|
|
22441
23279
|
import { join as join16 } from "node:path";
|
|
22442
23280
|
|
|
22443
23281
|
// ../../bridges/codex-bridge/src/sessions/persistence.ts
|
|
22444
|
-
import { createHash as createHash10, randomUUID as
|
|
23282
|
+
import { createHash as createHash10, randomUUID as randomUUID8 } from "node:crypto";
|
|
22445
23283
|
import {
|
|
22446
23284
|
chmod,
|
|
22447
23285
|
link as link2,
|
|
@@ -22454,7 +23292,7 @@ import {
|
|
|
22454
23292
|
writeFile as writeFile4
|
|
22455
23293
|
} from "node:fs/promises";
|
|
22456
23294
|
import { join as join15 } from "node:path";
|
|
22457
|
-
var
|
|
23295
|
+
var log12 = createLogger("bridge.codex");
|
|
22458
23296
|
var BRIDGE_SESSION_REGISTRY_VERSION = 2;
|
|
22459
23297
|
var SESSION_TITLE_SOURCES = new Set([
|
|
22460
23298
|
"codex",
|
|
@@ -22722,7 +23560,7 @@ class BridgeSessionStore {
|
|
|
22722
23560
|
await this.ensurePrivateStorage();
|
|
22723
23561
|
await Promise.all(sessions.map(async (session) => {
|
|
22724
23562
|
const target = this.recordPath(session.bridgeSessionId);
|
|
22725
|
-
const temporary = `${target}.${process.pid}.${
|
|
23563
|
+
const temporary = `${target}.${process.pid}.${randomUUID8()}.tmp`;
|
|
22726
23564
|
await writeFile4(temporary, `${JSON.stringify(session, null, 2)}
|
|
22727
23565
|
`, {
|
|
22728
23566
|
encoding: "utf8",
|
|
@@ -22753,7 +23591,7 @@ class BridgeSessionStore {
|
|
|
22753
23591
|
await Promise.all(names.map(async (name) => {
|
|
22754
23592
|
const from = join15(source, name);
|
|
22755
23593
|
const target = join15(this.recordsDir(), name);
|
|
22756
|
-
const temporary = `${target}.${process.pid}.${
|
|
23594
|
+
const temporary = `${target}.${process.pid}.${randomUUID8()}.tmp`;
|
|
22757
23595
|
await writeFile4(temporary, await readFile6(from), { mode: PRIVATE_FILE_MODE });
|
|
22758
23596
|
await chmod(temporary, PRIVATE_FILE_MODE);
|
|
22759
23597
|
try {
|
|
@@ -22778,7 +23616,7 @@ class BridgeSessionStore {
|
|
|
22778
23616
|
`);
|
|
22779
23617
|
}
|
|
22780
23618
|
async writeAtomicPath(path, payload) {
|
|
22781
|
-
const temporary = `${path}.${process.pid}.${
|
|
23619
|
+
const temporary = `${path}.${process.pid}.${randomUUID8()}.tmp`;
|
|
22782
23620
|
await writeFile4(temporary, payload, {
|
|
22783
23621
|
encoding: "utf8",
|
|
22784
23622
|
mode: PRIVATE_FILE_MODE
|
|
@@ -22793,7 +23631,7 @@ class BridgeSessionStore {
|
|
|
22793
23631
|
await chmod(path, PRIVATE_FILE_MODE);
|
|
22794
23632
|
}
|
|
22795
23633
|
warnPersistenceFailure(error) {
|
|
22796
|
-
|
|
23634
|
+
log12.warn("registry.persist-failed", { error: formatLogError(error, { stack: false }) });
|
|
22797
23635
|
}
|
|
22798
23636
|
toRecord(options) {
|
|
22799
23637
|
const { agentMcp: _agentMcp, ...persistedConfig } = options.config;
|
|
@@ -22817,7 +23655,7 @@ class BridgeSessionStore {
|
|
|
22817
23655
|
}
|
|
22818
23656
|
|
|
22819
23657
|
// ../../bridges/codex-bridge/src/sessions/dispatch-journal.ts
|
|
22820
|
-
var
|
|
23658
|
+
var log13 = createLogger("bridge.codex");
|
|
22821
23659
|
var DISPATCH_JOURNAL_VERSION = 1;
|
|
22822
23660
|
var DISPATCH_COMPLETENESS_VERSION = 1;
|
|
22823
23661
|
var MAX_FRESH_SESSION_MARKERS = 256;
|
|
@@ -23356,7 +24194,7 @@ class DispatchJournal {
|
|
|
23356
24194
|
throw error;
|
|
23357
24195
|
});
|
|
23358
24196
|
} catch (error) {
|
|
23359
|
-
|
|
24197
|
+
log13.warn("journal.persist-failed", { error: formatLogError(error, { stack: false }) });
|
|
23360
24198
|
if (options.failClosed)
|
|
23361
24199
|
throw error;
|
|
23362
24200
|
}
|
|
@@ -23472,12 +24310,12 @@ function coordinatorCapabilityPolicy(mode) {
|
|
|
23472
24310
|
}
|
|
23473
24311
|
|
|
23474
24312
|
// ../../bridges/codex-bridge/src/codex-config.ts
|
|
23475
|
-
import { existsSync as existsSync3, readdirSync as
|
|
24313
|
+
import { existsSync as existsSync3, readdirSync as readdirSync4, realpathSync, statSync as statSync2 } from "node:fs";
|
|
23476
24314
|
import { homedir as homedir3 } from "node:os";
|
|
23477
24315
|
import { isAbsolute as isAbsolute8, join as join18, relative as relative3, sep } from "node:path";
|
|
23478
24316
|
|
|
23479
24317
|
// ../../bridges/codex-bridge/src/shell-exclusions.ts
|
|
23480
|
-
import { closeSync, openSync, readSync, fstatSync } from "node:fs";
|
|
24318
|
+
import { closeSync as closeSync2, openSync as openSync2, readSync as readSync2, fstatSync as fstatSync2 } from "node:fs";
|
|
23481
24319
|
import { homedir as homedir2 } from "node:os";
|
|
23482
24320
|
import { dirname as dirname3, join as join17, resolve as resolve3 } from "node:path";
|
|
23483
24321
|
function configuredShellExclusions(env) {
|
|
@@ -23499,21 +24337,21 @@ function configuredShellExclusions(env) {
|
|
|
23499
24337
|
for (const path of paths) {
|
|
23500
24338
|
let fd;
|
|
23501
24339
|
try {
|
|
23502
|
-
fd =
|
|
24340
|
+
fd = openSync2(path, "r");
|
|
23503
24341
|
} catch (error) {
|
|
23504
24342
|
if (error.code === "ENOENT")
|
|
23505
24343
|
continue;
|
|
23506
24344
|
throw new Error("Cannot read Codex shell exclusions");
|
|
23507
24345
|
}
|
|
23508
24346
|
try {
|
|
23509
|
-
const stat =
|
|
24347
|
+
const stat = fstatSync2(fd);
|
|
23510
24348
|
if (!stat.isFile() || stat.size > 1024 * 1024) {
|
|
23511
24349
|
throw new Error("Invalid Codex configuration file");
|
|
23512
24350
|
}
|
|
23513
24351
|
const buffer = Buffer.alloc(1024 * 1024 + 1);
|
|
23514
24352
|
let length = 0;
|
|
23515
24353
|
while (length < buffer.length) {
|
|
23516
|
-
const count =
|
|
24354
|
+
const count = readSync2(fd, buffer, length, buffer.length - length, null);
|
|
23517
24355
|
if (count === 0)
|
|
23518
24356
|
break;
|
|
23519
24357
|
length += count;
|
|
@@ -23525,7 +24363,7 @@ function configuredShellExclusions(env) {
|
|
|
23525
24363
|
} catch {
|
|
23526
24364
|
throw new Error("Cannot load Codex shell exclusions");
|
|
23527
24365
|
} finally {
|
|
23528
|
-
|
|
24366
|
+
closeSync2(fd);
|
|
23529
24367
|
}
|
|
23530
24368
|
}
|
|
23531
24369
|
return [...exclusions];
|
|
@@ -23695,7 +24533,7 @@ function codexCoordinatorSkillReadRoots(env = process.env, home = env.HOME?.trim
|
|
|
23695
24533
|
grants.add(real);
|
|
23696
24534
|
let entries;
|
|
23697
24535
|
try {
|
|
23698
|
-
entries =
|
|
24536
|
+
entries = readdirSync4(real).filter((name) => !name.startsWith("."));
|
|
23699
24537
|
} catch {
|
|
23700
24538
|
continue;
|
|
23701
24539
|
}
|
|
@@ -24108,7 +24946,7 @@ var APP_SERVER_CAPABILITIES = {
|
|
|
24108
24946
|
};
|
|
24109
24947
|
|
|
24110
24948
|
// ../../bridges/codex-bridge/src/engine/app-server-engine.ts
|
|
24111
|
-
var
|
|
24949
|
+
var log14 = createLogger("bridge.codex");
|
|
24112
24950
|
var AGENT_MAIL_TOOL_APPROVALS = Object.fromEntries([
|
|
24113
24951
|
...AGENT_MAIL_TOOL_NAMES,
|
|
24114
24952
|
...ARTIFACT_TOOL_NAMES,
|
|
@@ -24693,7 +25531,7 @@ class AppServerEngine {
|
|
|
24693
25531
|
try {
|
|
24694
25532
|
listener(event);
|
|
24695
25533
|
} catch (error) {
|
|
24696
|
-
|
|
25534
|
+
log14.error("engine.listener-failed", { error: formatLogError(error) });
|
|
24697
25535
|
}
|
|
24698
25536
|
}
|
|
24699
25537
|
}
|
|
@@ -24818,7 +25656,7 @@ class AppServerEngine {
|
|
|
24818
25656
|
const sequence = ++this.accountCheckSequence;
|
|
24819
25657
|
const generation = this.supervisor.getGeneration();
|
|
24820
25658
|
this.supervisor.request("account/read", { refreshToken }).catch(signedOutAccountRead).then((response) => this.applyAccountRead(response, sequence, generation, accountReplaced)).catch((error) => {
|
|
24821
|
-
|
|
25659
|
+
log14.warn("account.sign-in-check-failed", {
|
|
24822
25660
|
error: formatLogError(error, { stack: false })
|
|
24823
25661
|
});
|
|
24824
25662
|
});
|
|
@@ -25405,7 +26243,7 @@ class AppServerEngine {
|
|
|
25405
26243
|
const generation = this.supervisor.getGeneration();
|
|
25406
26244
|
const response = await this.supervisor.request("account/read", { refreshToken: false }).catch(signedOutAccountRead);
|
|
25407
26245
|
this.applyAccountRead(response, sequence, generation, false).catch((error) => {
|
|
25408
|
-
|
|
26246
|
+
log14.warn("account.connector-recovery-failed", {
|
|
25409
26247
|
error: formatLogError(error, { stack: false })
|
|
25410
26248
|
});
|
|
25411
26249
|
});
|
|
@@ -25618,7 +26456,7 @@ class AppServerEngine {
|
|
|
25618
26456
|
await this.supervisor.request("thread/name/set", { threadId, name });
|
|
25619
26457
|
return true;
|
|
25620
26458
|
} catch (error) {
|
|
25621
|
-
|
|
26459
|
+
log14.warn("thread.rename-failed", { error: formatLogError(error, { stack: false }) });
|
|
25622
26460
|
return false;
|
|
25623
26461
|
}
|
|
25624
26462
|
}
|
|
@@ -25638,7 +26476,7 @@ class AppServerEngine {
|
|
|
25638
26476
|
} catch (error) {
|
|
25639
26477
|
if (requireConfirmation)
|
|
25640
26478
|
throw error;
|
|
25641
|
-
|
|
26479
|
+
log14.warn("thread.unsubscribe-failed", { error: formatLogError(error, { stack: false }) });
|
|
25642
26480
|
}
|
|
25643
26481
|
this.accountProofTurns.delete(threadId);
|
|
25644
26482
|
this.rolloutPaths.delete(threadId);
|
|
@@ -26184,9 +27022,9 @@ function externalRevertCut(messages, survivingTurnIds, running) {
|
|
|
26184
27022
|
}
|
|
26185
27023
|
|
|
26186
27024
|
// ../../bridges/codex-bridge/src/app-server-runtime-sessions.ts
|
|
26187
|
-
var
|
|
27025
|
+
var log15 = createLogger("bridge.codex");
|
|
26188
27026
|
var SESSION_CLOSING_ERROR = "Session is closing";
|
|
26189
|
-
var ACTIVITY_PROCESS =
|
|
27027
|
+
var ACTIVITY_PROCESS = randomUUID9();
|
|
26190
27028
|
|
|
26191
27029
|
class CodexRuntimeSessions {
|
|
26192
27030
|
ctx;
|
|
@@ -26339,7 +27177,7 @@ class CodexRuntimeSessions {
|
|
|
26339
27177
|
try {
|
|
26340
27178
|
fork = await this.ctx.options.engine.forkThread(parent.threadId, parent.config, lastTurnId);
|
|
26341
27179
|
} catch (error) {
|
|
26342
|
-
|
|
27180
|
+
log15.warn("thread.fork-failed", {
|
|
26343
27181
|
threadId: parent.threadId,
|
|
26344
27182
|
error: formatLogError(error, { stack: false })
|
|
26345
27183
|
});
|
|
@@ -26391,7 +27229,7 @@ class CodexRuntimeSessions {
|
|
|
26391
27229
|
await this.ctx.callbacks.deleteSession(child.id).catch(() => {
|
|
26392
27230
|
return;
|
|
26393
27231
|
});
|
|
26394
|
-
|
|
27232
|
+
log15.warn("thread.fork-hydrate-failed", {
|
|
26395
27233
|
threadId: parent.threadId,
|
|
26396
27234
|
error: formatLogError(error, { stack: false })
|
|
26397
27235
|
});
|
|
@@ -26406,7 +27244,7 @@ class CodexRuntimeSessions {
|
|
|
26406
27244
|
});
|
|
26407
27245
|
turns = thread?.turns;
|
|
26408
27246
|
} catch (error) {
|
|
26409
|
-
|
|
27247
|
+
log15.warn("thread.turns-read-failed", {
|
|
26410
27248
|
threadId: context.threadId,
|
|
26411
27249
|
error: formatLogError(error, { stack: false })
|
|
26412
27250
|
});
|
|
@@ -26898,7 +27736,7 @@ class CodexRuntimeSessions {
|
|
|
26898
27736
|
try {
|
|
26899
27737
|
turns = (await this.ctx.options.engine.readThread(context.threadId, { includeTurns: true }))?.turns;
|
|
26900
27738
|
} catch (error) {
|
|
26901
|
-
|
|
27739
|
+
log15.warn("thread.turns-read-after-revert-failed", {
|
|
26902
27740
|
threadId: context.threadId,
|
|
26903
27741
|
error: formatLogError(error, { stack: false })
|
|
26904
27742
|
});
|
|
@@ -26999,7 +27837,7 @@ class CodexRuntimeSessions {
|
|
|
26999
27837
|
}
|
|
27000
27838
|
} catch (error) {
|
|
27001
27839
|
await restoreEngineConfig();
|
|
27002
|
-
|
|
27840
|
+
log15.warn("session.config-apply-failed", {
|
|
27003
27841
|
sessionId,
|
|
27004
27842
|
error: formatLogError(error, { stack: false })
|
|
27005
27843
|
});
|
|
@@ -27042,7 +27880,7 @@ class CodexRuntimeSessions {
|
|
|
27042
27880
|
try {
|
|
27043
27881
|
context = await this.ctx.callbacks.ensureAttached(sessionId);
|
|
27044
27882
|
} catch (error) {
|
|
27045
|
-
|
|
27883
|
+
log15.warn("transcript.serving-last-known", {
|
|
27046
27884
|
sessionId,
|
|
27047
27885
|
error: formatLogError(error, { stack: false })
|
|
27048
27886
|
});
|
|
@@ -27245,7 +28083,7 @@ class CodexRuntimeSessions {
|
|
|
27245
28083
|
}
|
|
27246
28084
|
return "unpublished";
|
|
27247
28085
|
}
|
|
27248
|
-
|
|
28086
|
+
log15.warn("registry.persist-failed", { error: formatLogError(error, { stack: false }) });
|
|
27249
28087
|
}
|
|
27250
28088
|
if (this.ctx.registry.getSession(sessionId) !== session)
|
|
27251
28089
|
return "released";
|
|
@@ -27339,7 +28177,7 @@ class CodexRuntimeSessions {
|
|
|
27339
28177
|
}
|
|
27340
28178
|
}
|
|
27341
28179
|
// ../../bridges/codex-bridge/src/app-server-runtime-approvals.ts
|
|
27342
|
-
var
|
|
28180
|
+
var log16 = createLogger("bridge.codex");
|
|
27343
28181
|
|
|
27344
28182
|
class CodexRuntimeApprovals {
|
|
27345
28183
|
ctx;
|
|
@@ -27430,7 +28268,7 @@ class CodexRuntimeApprovals {
|
|
|
27430
28268
|
if (this.ctx.options.engine.resolveApproval(approvalId, decision)) {
|
|
27431
28269
|
if (decision === "cancel") {
|
|
27432
28270
|
this.ctx.callbacks.abort(sessionId).catch((error) => {
|
|
27433
|
-
|
|
28271
|
+
log16.error("approval.cancel-failed", { error: formatLogError(error) });
|
|
27434
28272
|
});
|
|
27435
28273
|
}
|
|
27436
28274
|
return "applied";
|
|
@@ -28837,7 +29675,7 @@ class UpdateCoalescer {
|
|
|
28837
29675
|
|
|
28838
29676
|
// ../../bridges/codex-bridge/src/app-server-runtime-capacity-retry.ts
|
|
28839
29677
|
import { stat as stat9 } from "node:fs/promises";
|
|
28840
|
-
var
|
|
29678
|
+
var log17 = createLogger("bridge.codex");
|
|
28841
29679
|
|
|
28842
29680
|
class CodexCapacityRetry {
|
|
28843
29681
|
ctx;
|
|
@@ -28951,7 +29789,7 @@ class CodexCapacityRetry {
|
|
|
28951
29789
|
}
|
|
28952
29790
|
entry.stage = "starting";
|
|
28953
29791
|
const work = this.startContinuation(context, turn, entry).catch((error) => {
|
|
28954
|
-
|
|
29792
|
+
log17.error("turn.capacity-retry-failed", {
|
|
28955
29793
|
turnId: turn.turnId,
|
|
28956
29794
|
error: formatLogError(error, { stack: false })
|
|
28957
29795
|
});
|
|
@@ -29023,7 +29861,7 @@ class CodexCapacityRetry {
|
|
|
29023
29861
|
});
|
|
29024
29862
|
return;
|
|
29025
29863
|
}
|
|
29026
|
-
await this.ctx.journal.markAccepted(requestId, { threadId: context.threadId, turnId: started.turnId }).catch((error) =>
|
|
29864
|
+
await this.ctx.journal.markAccepted(requestId, { threadId: context.threadId, turnId: started.turnId }).catch((error) => log17.warn("turn.capacity-retry-journal-failed", {
|
|
29027
29865
|
requestId,
|
|
29028
29866
|
error: formatLogError(error, { stack: false })
|
|
29029
29867
|
}));
|
|
@@ -29094,7 +29932,7 @@ class CodexCapacityRetry {
|
|
|
29094
29932
|
}
|
|
29095
29933
|
|
|
29096
29934
|
// ../../bridges/codex-bridge/src/app-server-runtime-lifecycle.ts
|
|
29097
|
-
var
|
|
29935
|
+
var log18 = createLogger("bridge.codex");
|
|
29098
29936
|
function artifactConnectionToken(value) {
|
|
29099
29937
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
29100
29938
|
return;
|
|
@@ -29279,7 +30117,7 @@ class CodexRuntimeLifecycle {
|
|
|
29279
30117
|
this.ctx.registry.setPhase(existing, "recovering");
|
|
29280
30118
|
this.emitStatus(existing);
|
|
29281
30119
|
this.ctx.callbacks.scheduleRecoveryBackstop(existing);
|
|
29282
|
-
|
|
30120
|
+
log18.warn("dispatch.restore-failed", {
|
|
29283
30121
|
requestId: record.requestId,
|
|
29284
30122
|
error: formatLogError(error, { stack: false })
|
|
29285
30123
|
});
|
|
@@ -29458,7 +30296,7 @@ class CodexRuntimeLifecycle {
|
|
|
29458
30296
|
});
|
|
29459
30297
|
}));
|
|
29460
30298
|
}
|
|
29461
|
-
|
|
30299
|
+
log18.warn("thread.reattach-failed", {
|
|
29462
30300
|
threadId,
|
|
29463
30301
|
rolloutMissing: isMissingRolloutError(error),
|
|
29464
30302
|
error: formatLogError(error, { stack: false })
|
|
@@ -29539,7 +30377,7 @@ class CodexRuntimeLifecycle {
|
|
|
29539
30377
|
coalescer: new UpdateCoalescer({
|
|
29540
30378
|
intervalMs: this.ctx.options.coalesceIntervalMs ?? (() => messageSnapshotIntervalMs(this.ctx.threadState.get(threadId)?.lastPublishedSnapshotChars ?? 0)),
|
|
29541
30379
|
publish: () => this.ctx.callbacks.publishAssistantMessage(threadId),
|
|
29542
|
-
onError: (error) =>
|
|
30380
|
+
onError: (error) => log18.error("message.publish-failed", { error: formatLogError(error) })
|
|
29543
30381
|
})
|
|
29544
30382
|
};
|
|
29545
30383
|
this.ctx.threadState.set(threadId, state);
|
|
@@ -29575,7 +30413,7 @@ class CodexRuntimeLifecycle {
|
|
|
29575
30413
|
this.ctx.commandCatalogue.withdrawGeneration(event.generation);
|
|
29576
30414
|
const recovery = this.ctx.generationRecovery.then(() => this.ctx.callbacks.recoverAfterGenerationChange(event.generation));
|
|
29577
30415
|
this.ctx.generationRecovery = recovery.catch((error) => {
|
|
29578
|
-
|
|
30416
|
+
log18.error("generation.recovery-failed", { error: formatLogError(error) });
|
|
29579
30417
|
});
|
|
29580
30418
|
return;
|
|
29581
30419
|
}
|
|
@@ -29595,7 +30433,7 @@ class CodexRuntimeLifecycle {
|
|
|
29595
30433
|
}
|
|
29596
30434
|
if (event.kind === "account.reload.requested") {
|
|
29597
30435
|
this.ctx.callbacks.reloadStoredAccountLogin().catch((error) => {
|
|
29598
|
-
|
|
30436
|
+
log18.warn("account.login-reload-failed", { error: formatLogError(error, { stack: false }) });
|
|
29599
30437
|
});
|
|
29600
30438
|
return;
|
|
29601
30439
|
}
|
|
@@ -29898,7 +30736,7 @@ class CodexRuntimeLifecycle {
|
|
|
29898
30736
|
}
|
|
29899
30737
|
this.ctx.options.changeEvidence?.turn(this.evidenceSource(context, turn), event.status);
|
|
29900
30738
|
const finalize = () => this.runFinalization(context, turn).catch((error) => {
|
|
29901
|
-
|
|
30739
|
+
log18.error("turn.finalize-failed", {
|
|
29902
30740
|
turnId: turn.turnId,
|
|
29903
30741
|
error: formatLogError(error, { stack: false })
|
|
29904
30742
|
});
|
|
@@ -30116,7 +30954,7 @@ class CodexRuntimeLifecycle {
|
|
|
30116
30954
|
}
|
|
30117
30955
|
trackCommandChangeWork(work) {
|
|
30118
30956
|
const tracked = work.catch((error) => {
|
|
30119
|
-
|
|
30957
|
+
log18.warn("command-changes.record-failed", { error: formatLogError(error, { stack: false }) });
|
|
30120
30958
|
});
|
|
30121
30959
|
this.ctx.pendingCommandChanges.add(tracked);
|
|
30122
30960
|
tracked.finally(() => this.ctx.pendingCommandChanges.delete(tracked));
|
|
@@ -30560,7 +31398,7 @@ class CodexRuntimeLifecycle {
|
|
|
30560
31398
|
try {
|
|
30561
31399
|
await state.coalescer.flushNow();
|
|
30562
31400
|
} catch (error) {
|
|
30563
|
-
|
|
31401
|
+
log18.error("ordered-events.flush-failed", { error: formatLogError(error) });
|
|
30564
31402
|
}
|
|
30565
31403
|
state.orderedReconcilePending = false;
|
|
30566
31404
|
for (const sessionId of this.ctx.sessionIdsForThread(threadId)) {
|
|
@@ -30579,7 +31417,7 @@ class CodexRuntimeLifecycle {
|
|
|
30579
31417
|
await state.coalescer.flushNow();
|
|
30580
31418
|
event.publish();
|
|
30581
31419
|
} catch (error) {
|
|
30582
|
-
|
|
31420
|
+
log18.error("ordered-events.publish-failed", { error: formatLogError(error) });
|
|
30583
31421
|
state.orderedEvents.length = 0;
|
|
30584
31422
|
state.orderedEventBytes = 0;
|
|
30585
31423
|
state.orderedReconcilePending = true;
|
|
@@ -30588,7 +31426,7 @@ class CodexRuntimeLifecycle {
|
|
|
30588
31426
|
}
|
|
30589
31427
|
}
|
|
30590
31428
|
} catch (error) {
|
|
30591
|
-
|
|
31429
|
+
log18.error("ordered-events.reconcile-failed", { error: formatLogError(error) });
|
|
30592
31430
|
} finally {
|
|
30593
31431
|
state.orderedEventDraining = false;
|
|
30594
31432
|
if ((state.orderedReconcilePending || state.orderedEvents.length > 0) && this.ctx.threadState.get(threadId) === state) {
|
|
@@ -30704,7 +31542,7 @@ function isTabInitialPromptRequestId(requestId) {
|
|
|
30704
31542
|
}
|
|
30705
31543
|
|
|
30706
31544
|
// ../../bridges/codex-bridge/src/app-server-runtime-prompt.ts
|
|
30707
|
-
var
|
|
31545
|
+
var log19 = createLogger("bridge.codex");
|
|
30708
31546
|
function commandRefusal(message) {
|
|
30709
31547
|
return { ok: false, status: 422, error: message, kind: "command-unavailable" };
|
|
30710
31548
|
}
|
|
@@ -31366,7 +32204,7 @@ class CodexRuntimePrompt {
|
|
|
31366
32204
|
try {
|
|
31367
32205
|
outcome = await this.ctx.options.engine.reconcileRequest(context.threadId, accumulator.providerRequestId);
|
|
31368
32206
|
} catch (error) {
|
|
31369
|
-
|
|
32207
|
+
log19.warn("dispatch.reconcile-failed", {
|
|
31370
32208
|
requestId,
|
|
31371
32209
|
threadId: context.threadId,
|
|
31372
32210
|
error: formatLogError(error, { stack: false })
|
|
@@ -31641,7 +32479,7 @@ class CodexRuntimePrompt {
|
|
|
31641
32479
|
if (this.ctx.stopping || this.shouldAbandonDrain(expectedGeneration))
|
|
31642
32480
|
return;
|
|
31643
32481
|
if (Date.now() >= deadline) {
|
|
31644
|
-
|
|
32482
|
+
log19.warn("app-server.drain-expired");
|
|
31645
32483
|
return;
|
|
31646
32484
|
}
|
|
31647
32485
|
await this.waitForThreadActivity();
|
|
@@ -31675,7 +32513,7 @@ class CodexRuntimePrompt {
|
|
|
31675
32513
|
|
|
31676
32514
|
// ../../bridges/codex-bridge/src/app-server-runtime-tail.ts
|
|
31677
32515
|
import { join as join22, relative as relative4, isAbsolute as isAbsolute11 } from "node:path";
|
|
31678
|
-
var
|
|
32516
|
+
var log20 = createLogger("bridge.codex");
|
|
31679
32517
|
|
|
31680
32518
|
class CodexRuntimeTail {
|
|
31681
32519
|
ctx;
|
|
@@ -31824,7 +32662,7 @@ class CodexRuntimeTail {
|
|
|
31824
32662
|
};
|
|
31825
32663
|
}
|
|
31826
32664
|
} catch (error) {
|
|
31827
|
-
|
|
32665
|
+
log20.warn("models.list-failed", { error: formatLogError(error, { stack: false }) });
|
|
31828
32666
|
}
|
|
31829
32667
|
return this.ctx.options.loadCachedModels();
|
|
31830
32668
|
}
|
|
@@ -31850,7 +32688,7 @@ class CodexRuntimeTail {
|
|
|
31850
32688
|
});
|
|
31851
32689
|
}
|
|
31852
32690
|
} catch (error) {
|
|
31853
|
-
|
|
32691
|
+
log20.warn("threads.list-failed", { error: formatLogError(error, { stack: false }) });
|
|
31854
32692
|
}
|
|
31855
32693
|
const archived = new Set;
|
|
31856
32694
|
try {
|
|
@@ -31935,7 +32773,7 @@ class CodexRuntimeTail {
|
|
|
31935
32773
|
else
|
|
31936
32774
|
await this.ctx.options.engine.unarchiveThread(threadId);
|
|
31937
32775
|
} catch (error) {
|
|
31938
|
-
|
|
32776
|
+
log20.warn("thread.archive-failed", {
|
|
31939
32777
|
archived,
|
|
31940
32778
|
error: formatLogError(error, { stack: false })
|
|
31941
32779
|
});
|
|
@@ -32581,9 +33419,9 @@ function installFatalRejectionGuard(options) {
|
|
|
32581
33419
|
}
|
|
32582
33420
|
|
|
32583
33421
|
// ../protocol/src/node/process-failure-log.ts
|
|
32584
|
-
var
|
|
33422
|
+
var log21 = createLogger("process");
|
|
32585
33423
|
function logUnhandledRejection(reason) {
|
|
32586
|
-
|
|
33424
|
+
log21.throttled("error", "rejection.unhandled", {
|
|
32587
33425
|
error: reason,
|
|
32588
33426
|
fields: () => ({ error: formatLogError(reason, { message: false }) })
|
|
32589
33427
|
});
|
|
@@ -32608,7 +33446,7 @@ var CODEX_FALLBACK_MODEL_CATALOG = [
|
|
|
32608
33446
|
];
|
|
32609
33447
|
|
|
32610
33448
|
// ../../bridges/codex-bridge/src/models-cache.ts
|
|
32611
|
-
var
|
|
33449
|
+
var log22 = createLogger("bridge.codex");
|
|
32612
33450
|
var MODEL_REASONING_EFFORTS = new Set([
|
|
32613
33451
|
"minimal",
|
|
32614
33452
|
"low",
|
|
@@ -32755,13 +33593,13 @@ class ModelCatalogCache {
|
|
|
32755
33593
|
await this.opts.writePersistedCache(models);
|
|
32756
33594
|
}
|
|
32757
33595
|
} catch (error) {
|
|
32758
|
-
|
|
33596
|
+
log22.warn("models.refresh-failed", { error: formatLogError(error, { stack: false }) });
|
|
32759
33597
|
}
|
|
32760
33598
|
}
|
|
32761
33599
|
}
|
|
32762
33600
|
|
|
32763
33601
|
// ../../bridges/codex-bridge/src/index.ts
|
|
32764
|
-
var
|
|
33602
|
+
var log23 = createLogger("bridge.codex");
|
|
32765
33603
|
configureBridgeLogger();
|
|
32766
33604
|
var WORKFLOW_RESULT_TOOL_NAMES2 = new Set(WORKFLOW_RESULT_KINDS.map(workflowResultToolName));
|
|
32767
33605
|
function isWorkflowResultTool(value) {
|
|
@@ -32791,14 +33629,14 @@ function isScopedAgentMcp(value) {
|
|
|
32791
33629
|
var app = new Hono2;
|
|
32792
33630
|
app.onError((error, c) => {
|
|
32793
33631
|
if (error instanceof PolicyWideningRefusedError) {
|
|
32794
|
-
|
|
33632
|
+
log23.warn("session.policy-widening-refused", { widened: error.widened.join(",") });
|
|
32795
33633
|
return c.json(error.refusal(), 403);
|
|
32796
33634
|
}
|
|
32797
33635
|
if ("getResponse" in error) {
|
|
32798
33636
|
const response = error.getResponse();
|
|
32799
33637
|
return c.newResponse(response.body, response);
|
|
32800
33638
|
}
|
|
32801
|
-
|
|
33639
|
+
log23.error("http.request-failed", {
|
|
32802
33640
|
method: c.req.method,
|
|
32803
33641
|
path: c.req.path,
|
|
32804
33642
|
error: formatLogError(error)
|
|
@@ -32816,7 +33654,7 @@ var bridgeCredential = loadBridgeCredential(BRIDGE_TOKEN_ENV);
|
|
|
32816
33654
|
var bridgeAuthEnabledOverrideForTesting = null;
|
|
32817
33655
|
var sseRouteTestHooks = null;
|
|
32818
33656
|
var BRIDGE_VERSION = "1.0.0";
|
|
32819
|
-
var
|
|
33657
|
+
var execFile3 = promisify2(execFileCallback2);
|
|
32820
33658
|
var subscribers = new Set;
|
|
32821
33659
|
var observers = new Set;
|
|
32822
33660
|
function observationFrameData(sessionId) {
|
|
@@ -32826,10 +33664,10 @@ function notifyObservers(event, revision) {
|
|
|
32826
33664
|
for (const observer of observers) {
|
|
32827
33665
|
try {
|
|
32828
33666
|
Promise.resolve(observer(event, revision, "{}")).catch((error) => {
|
|
32829
|
-
|
|
33667
|
+
log23.warn("sse.observer-failed", { error: formatLogError(error) });
|
|
32830
33668
|
});
|
|
32831
33669
|
} catch (error) {
|
|
32832
|
-
|
|
33670
|
+
log23.warn("sse.observer-failed", { error: formatLogError(error) });
|
|
32833
33671
|
}
|
|
32834
33672
|
}
|
|
32835
33673
|
}
|
|
@@ -32937,12 +33775,12 @@ function createShutdownHandler(timer, clearTimer = clearInterval, exit = (code)
|
|
|
32937
33775
|
shuttingDown = true;
|
|
32938
33776
|
clearTimer(timer);
|
|
32939
33777
|
stopEngine().catch((error) => {
|
|
32940
|
-
|
|
33778
|
+
log23.warn("engine.stop-failed", { error: formatLogError(error) });
|
|
32941
33779
|
}).finally(() => exit(0));
|
|
32942
33780
|
};
|
|
32943
33781
|
}
|
|
32944
33782
|
function createParentExitHandler(interrupt, shutdown, report = (turns, ms) => {
|
|
32945
|
-
|
|
33783
|
+
log23.info("turns.stopped", { turns, elapsedMs: ms });
|
|
32946
33784
|
}) {
|
|
32947
33785
|
return async () => {
|
|
32948
33786
|
const detectedAt = performance.now();
|
|
@@ -32973,7 +33811,7 @@ function serializeSseEventData(event) {
|
|
|
32973
33811
|
...event.data
|
|
32974
33812
|
});
|
|
32975
33813
|
} catch {
|
|
32976
|
-
|
|
33814
|
+
log23.error("sse.payload-serialize-failed");
|
|
32977
33815
|
return JSON.stringify({
|
|
32978
33816
|
sessionId: event.sessionId,
|
|
32979
33817
|
error: "payload could not be serialized"
|
|
@@ -33038,7 +33876,7 @@ function emit(event) {
|
|
|
33038
33876
|
messageId = retainedMessageId(event.type, payload);
|
|
33039
33877
|
bytes = eager === null ? estimateSsePayloadBytes(payload) : Buffer.byteLength(eager, "utf8");
|
|
33040
33878
|
} catch {
|
|
33041
|
-
|
|
33879
|
+
log23.error("sse.payload-snapshot-failed");
|
|
33042
33880
|
payload = { error: "payload could not be serialized" };
|
|
33043
33881
|
eager = subscribers.size > 0 ? serializeSseEventData({ sessionId, data: payload }) : null;
|
|
33044
33882
|
messageId = undefined;
|
|
@@ -33055,10 +33893,10 @@ function emit(event) {
|
|
|
33055
33893
|
for (const subscriber of subscribers) {
|
|
33056
33894
|
try {
|
|
33057
33895
|
Promise.resolve(subscriber(event, revision, eager ?? "{}")).catch((error) => {
|
|
33058
|
-
|
|
33896
|
+
log23.warn("sse.subscriber-failed", { error: formatLogError(error) });
|
|
33059
33897
|
});
|
|
33060
33898
|
} catch (error) {
|
|
33061
|
-
|
|
33899
|
+
log23.warn("sse.subscriber-failed", { error: formatLogError(error) });
|
|
33062
33900
|
}
|
|
33063
33901
|
}
|
|
33064
33902
|
}
|
|
@@ -33085,7 +33923,7 @@ async function writePersistedBridgeCache(models) {
|
|
|
33085
33923
|
await mkdir9(bridgeCacheDir(), { recursive: true });
|
|
33086
33924
|
await writeFile6(bridgeCachePath(), JSON.stringify({ version: BRIDGE_MODEL_CACHE_VERSION, at: Date.now(), models }, null, 2));
|
|
33087
33925
|
} catch (error) {
|
|
33088
|
-
|
|
33926
|
+
log23.warn("models.cache-persist-failed", { error: formatLogError(error, { stack: false }) });
|
|
33089
33927
|
}
|
|
33090
33928
|
}
|
|
33091
33929
|
async function readCodexCliModelCache() {
|
|
@@ -33097,7 +33935,7 @@ async function readCodexCliModelCache() {
|
|
|
33097
33935
|
return null;
|
|
33098
33936
|
}
|
|
33099
33937
|
}
|
|
33100
|
-
async function fetchLiveModelsFromCli(run =
|
|
33938
|
+
async function fetchLiveModelsFromCli(run = execFile3, env = process.env) {
|
|
33101
33939
|
const codexPath = env.CODEX_PATH || "codex";
|
|
33102
33940
|
try {
|
|
33103
33941
|
const { stdout } = await run(codexPath, ["debug", "models"], {
|
|
@@ -33107,7 +33945,7 @@ async function fetchLiveModelsFromCli(run = execFile4, env = process.env) {
|
|
|
33107
33945
|
const models = parseModelCatalog(stdout);
|
|
33108
33946
|
return models.length > 0 ? models : null;
|
|
33109
33947
|
} catch (error) {
|
|
33110
|
-
|
|
33948
|
+
log23.warn("models.debug-read-failed", { error: formatLogError(error, { stack: false }) });
|
|
33111
33949
|
return null;
|
|
33112
33950
|
}
|
|
33113
33951
|
}
|
|
@@ -33152,7 +33990,7 @@ async function sweepIdleThreads(runtime = appServerRuntime) {
|
|
|
33152
33990
|
try {
|
|
33153
33991
|
await runtime.sweepIdle();
|
|
33154
33992
|
} catch (error) {
|
|
33155
|
-
|
|
33993
|
+
log23.warn("idle-sweep.failed", { error: formatLogError(error) });
|
|
33156
33994
|
}
|
|
33157
33995
|
}
|
|
33158
33996
|
function createCodexProcessDiagnostics(runtime = appServerRuntime) {
|
|
@@ -33188,9 +34026,9 @@ async function startSelectedEngine(env = process.env, runtime = appServerRuntime
|
|
|
33188
34026
|
}
|
|
33189
34027
|
try {
|
|
33190
34028
|
await runtime.start();
|
|
33191
|
-
|
|
34029
|
+
log23.info("engine.ready", { codexVersion: runtime.getHealth().codexVersion ?? "unknown" });
|
|
33192
34030
|
} catch (error) {
|
|
33193
|
-
|
|
34031
|
+
log23.error("engine.start-failed", { error: formatLogError(error, { stack: false }) });
|
|
33194
34032
|
}
|
|
33195
34033
|
}
|
|
33196
34034
|
var __testing = {
|
|
@@ -33273,7 +34111,7 @@ function startSseKeepalive(writeSSE, intervalMs = 5000, shouldSendAtActiveCadenc
|
|
|
33273
34111
|
id: String(eventRing.latestRevision),
|
|
33274
34112
|
data: "{}"
|
|
33275
34113
|
}).catch((error) => {
|
|
33276
|
-
|
|
34114
|
+
log23.warn("sse.keepalive-failed", { error: formatLogError(error, { stack: false }) });
|
|
33277
34115
|
});
|
|
33278
34116
|
}, intervalMs);
|
|
33279
34117
|
}
|
|
@@ -33529,7 +34367,7 @@ app.get("/session/:id/usage", async (c) => {
|
|
|
33529
34367
|
return c.json({ error: "Session not found" }, 404);
|
|
33530
34368
|
return c.json({ contextUsage });
|
|
33531
34369
|
} catch (error) {
|
|
33532
|
-
|
|
34370
|
+
log23.warn("account.usage-read-failed", { error: formatLogError(error, { stack: false }) });
|
|
33533
34371
|
return c.json({ error: "Account usage is temporarily unavailable" }, 503);
|
|
33534
34372
|
}
|
|
33535
34373
|
});
|
|
@@ -33940,7 +34778,7 @@ app.get("/event/subscribe", (c) => {
|
|
|
33940
34778
|
if (!open)
|
|
33941
34779
|
return;
|
|
33942
34780
|
open = false;
|
|
33943
|
-
|
|
34781
|
+
log23.info("sse.closed", { reason });
|
|
33944
34782
|
resolveConnectionClosed();
|
|
33945
34783
|
};
|
|
33946
34784
|
const writeWhileOpen = createSerializedSseWriter(createOpenSseWriter(() => open, (event) => stream.writeSSE(event)), { onOverflow: () => failSlowSubscriber("write backlog exceeded its cap") });
|
|
@@ -34088,7 +34926,7 @@ if (parentPid !== null) {
|
|
|
34088
34926
|
startParentWatchdog({
|
|
34089
34927
|
parentPid,
|
|
34090
34928
|
onParentExit: () => {
|
|
34091
|
-
|
|
34929
|
+
log23.warn("parent.gone", { parentPid });
|
|
34092
34930
|
createParentExitHandler((budgetMs) => appServerRuntime.interruptForParentExit(budgetMs), shutdownHandler)();
|
|
34093
34931
|
}
|
|
34094
34932
|
});
|