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
|
@@ -1322,6 +1322,8 @@ var LOGGING_LOG_AREAS = defineLogAreas({
|
|
|
1322
1322
|
},
|
|
1323
1323
|
"essential.write-failed": "Writing the essential log failed. Its entries are counted, and a marker reports them at the next write that works.",
|
|
1324
1324
|
"policy.changed": "The logging settings changed: saving, retention and levels, with no content.",
|
|
1325
|
+
"policy.detail-expired": "Raised log detail reached its expiry, so the backend set its raised levels back to info. Saving is unchanged.",
|
|
1326
|
+
"policy.expiry-failed": "Checking or applying the log detail expiry failed; the next check, a minute later, tries again.",
|
|
1325
1327
|
"policy.bridge-predates-route": "A running bridge has no logging settings route; it applies them at its next start.",
|
|
1326
1328
|
"policy.push-failed": "A running bridge did not take the logging settings after retries; its next start resends them.",
|
|
1327
1329
|
"prune.failed": "Removing expired log files failed; the next sweep retries.",
|
|
@@ -1329,6 +1331,23 @@ var LOGGING_LOG_AREAS = defineLogAreas({
|
|
|
1329
1331
|
"unknown-area": "Code outside the type checker asked for an area that is not listed.",
|
|
1330
1332
|
...THROTTLE_LOG_EVENTS
|
|
1331
1333
|
}
|
|
1334
|
+
},
|
|
1335
|
+
"renderer-errors": {
|
|
1336
|
+
description: "Renderer failures a desktop window reported from its error ring: class, boundary, surface, count and fingerprint, never a message or stack.",
|
|
1337
|
+
events: {
|
|
1338
|
+
"error.recorded": {
|
|
1339
|
+
description: "A renderer reported `count` new occurrences of one failure since its last report.",
|
|
1340
|
+
essential: true,
|
|
1341
|
+
fields: {
|
|
1342
|
+
errorClass: "label",
|
|
1343
|
+
boundary: "label",
|
|
1344
|
+
route: "label",
|
|
1345
|
+
fingerprint: "label",
|
|
1346
|
+
count: "number"
|
|
1347
|
+
}
|
|
1348
|
+
},
|
|
1349
|
+
"report.rate-limited": "Renderer error entries arrived faster than the backend records them, so `dropped` were counted and not written."
|
|
1350
|
+
}
|
|
1332
1351
|
}
|
|
1333
1352
|
});
|
|
1334
1353
|
|
|
@@ -1386,6 +1405,8 @@ var NATIVE_AGENT_LOG_AREAS = defineLogAreas({
|
|
|
1386
1405
|
"usage-limit.notice-failed": "A usage-limit stop's outcome could not be read for its notice.",
|
|
1387
1406
|
"usage-limit.resend-failed": "Resending after a usage limit failed. An unknown send stays in the journal.",
|
|
1388
1407
|
"title.strategy-failed": "A session title strategy failed, so the next is tried. Content-free: the error can quote the prompt.",
|
|
1408
|
+
"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.",
|
|
1409
|
+
"steer.capability-cleared": "A projection cleared `actions.steer` because its bridge did not qualify. Identifiers and turn status only.",
|
|
1389
1410
|
...THROTTLE_LOG_EVENTS
|
|
1390
1411
|
}
|
|
1391
1412
|
},
|
|
@@ -1486,6 +1507,9 @@ var RUNTIME_LOG_AREAS = defineLogAreas({
|
|
|
1486
1507
|
essential: true,
|
|
1487
1508
|
fields: { origin: "label", ...ESSENTIAL_ERROR_FIELDS }
|
|
1488
1509
|
},
|
|
1510
|
+
"child.reaped": "A macOS child whose exit Bun lost was reaped after its command settled, so it no longer waits as a zombie.",
|
|
1511
|
+
"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.",
|
|
1512
|
+
"child.reap-unavailable": "waitpid could not be loaded, so children whose exit Bun lost stay zombies until this process exits.",
|
|
1489
1513
|
...THROTTLE_LOG_EVENTS
|
|
1490
1514
|
}
|
|
1491
1515
|
}
|
|
@@ -1892,6 +1916,13 @@ var COORDINATOR_LOG_AREAS = defineLogAreas({
|
|
|
1892
1916
|
"store.workflows-cleared": "The workflow store was full, so a batch of its oldest finished records was removed.",
|
|
1893
1917
|
"store.workflows-in-use": "The workflow store was full and every record was still in use, so new work was refused.",
|
|
1894
1918
|
"remote-worker.settle-failed": "A remote worker could not be settled.",
|
|
1919
|
+
"node-release.failed": "Work on a node that was forgotten or handed over could not be closed; the sweep's registry check retries.",
|
|
1920
|
+
"node-release.reconcile-failed": "The sweep could not check records against the node registry; the next sweep retries.",
|
|
1921
|
+
"node-release.unregistered": "Records named a node the registry no longer holds, so their work was closed here.",
|
|
1922
|
+
"node-release.notice-failed": "The notice for work closed on a released node could not be sent; it stays owed and the sweep retries.",
|
|
1923
|
+
"node-release.no-coordinator": "Work closed on a released node belonged to a coordinator that no longer exists, so nobody was told.",
|
|
1924
|
+
"node-offline.notice-failed": "The notice that a node has been unreachable for a day could not be sent; the next failed read retries.",
|
|
1925
|
+
"node-offline.check-failed": "Whether a long-unreachable node's coordinators were told could not be checked; the next read retries.",
|
|
1895
1926
|
"checkout.merge-followed": "After an environment's PR merged, the project checkout was fast-forwarded, or `outcome` says why not.",
|
|
1896
1927
|
"checkout.merge-follow-failed": "Fast-forwarding the project checkout failed, after an environment's PR merged or before mail woke the main coordinator.",
|
|
1897
1928
|
"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`).",
|
|
@@ -1988,6 +2019,7 @@ var DOCKER_LOG_AREAS = defineLogAreas({
|
|
|
1988
2019
|
events: {
|
|
1989
2020
|
"portable-inputs.relay-missing": "Docker is rootless and the image predates the staged-input relay, so the container cannot read them until rebuilt.",
|
|
1990
2021
|
"git-mirror.mount-unavailable": "A new container gets no project Git mirror, so its clone goes to the remote.",
|
|
2022
|
+
"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.",
|
|
1991
2023
|
"git-mirror.refreshed": "A project's Git mirror was built or updated.",
|
|
1992
2024
|
"git-mirror.seeded": "A project's Git mirror was built from its host checkout and only what the remote added to it.",
|
|
1993
2025
|
"git-mirror.seed-skipped": "A project's host checkout could not seed its Git mirror, so the build downloads everything.",
|
|
@@ -2164,6 +2196,7 @@ var NODES_LOG_AREAS = defineLogAreas({
|
|
|
2164
2196
|
"verification.record-failed": "A node verification could not be recorded.",
|
|
2165
2197
|
"profile.record-failed": "A node profile could not be recorded.",
|
|
2166
2198
|
"detach.unconfirmed": "A forgotten node has not confirmed the detach yet.",
|
|
2199
|
+
"grant.revocation-listener-failed": "A connection could not be told its client grant was removed; the grant is still gone.",
|
|
2167
2200
|
"handover.recovery-pending": "Command handover recovery is still pending.",
|
|
2168
2201
|
"ticket-sync.work-record-failed": "A remote build started but its ticket work location could not be saved.",
|
|
2169
2202
|
"ticket-sync.failed": "A Kanban sync with a node failed; it is retried.",
|
|
@@ -2216,7 +2249,9 @@ var HOST_LOG_AREAS = defineLogAreas({
|
|
|
2216
2249
|
"tool.missing": "A host tool was not found.",
|
|
2217
2250
|
"maintenance.listener-failed": "A host maintenance listener threw; the others still run.",
|
|
2218
2251
|
"suspend.reconcile-failed": "Reconciling due work after a host suspension failed.",
|
|
2219
|
-
"load.sample-failed": "Sampling machine load failed; the next sample retries."
|
|
2252
|
+
"load.sample-failed": "Sampling machine load failed; the next sample retries.",
|
|
2253
|
+
"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.",
|
|
2254
|
+
...THROTTLE_LOG_EVENTS
|
|
2220
2255
|
}
|
|
2221
2256
|
}
|
|
2222
2257
|
});
|
|
@@ -6926,6 +6961,8 @@ class InteractionDeadline {
|
|
|
6926
6961
|
}
|
|
6927
6962
|
|
|
6928
6963
|
// ../protocol/src/coordinator.ts
|
|
6964
|
+
var COORDINATOR_OTHER_ENVIRONMENTS_SETTING_LABEL = "Let the coordinator use environments it did not create";
|
|
6965
|
+
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.`;
|
|
6929
6966
|
var COORDINATOR_CONTROL_TOOL_NAMES = Object.freeze([
|
|
6930
6967
|
"ack_message",
|
|
6931
6968
|
"add_ticket_comment",
|
|
@@ -32584,12 +32621,823 @@ function isFileEditToolName(toolName) {
|
|
|
32584
32621
|
}
|
|
32585
32622
|
|
|
32586
32623
|
// ../protocol/src/node/workspace-change-probe.ts
|
|
32587
|
-
import {
|
|
32588
|
-
import { randomUUID } from "node:crypto";
|
|
32624
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
32589
32625
|
import { rmSync } from "node:fs";
|
|
32590
32626
|
import { copyFile, lstat, mkdtemp as mkdtemp2, rm as rm2 } from "node:fs/promises";
|
|
32591
32627
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
32592
32628
|
import { delimiter, isAbsolute, join as join4, resolve as resolve2 } from "node:path";
|
|
32629
|
+
|
|
32630
|
+
// ../protocol/src/node/command-capture.ts
|
|
32631
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
32632
|
+
import { randomUUID } from "node:crypto";
|
|
32633
|
+
import { constants as fsConstants } from "node:fs";
|
|
32634
|
+
import * as captureFs from "node:fs";
|
|
32635
|
+
import os from "node:os";
|
|
32636
|
+
import path from "node:path";
|
|
32637
|
+
import { inspect } from "node:util";
|
|
32638
|
+
|
|
32639
|
+
// ../protocol/src/node/command-failure-reason.ts
|
|
32640
|
+
var MAX_MATCHED_CHARS = 16 * 1024;
|
|
32641
|
+
var SIGNAL_PATTERN = /^SIG[A-Z0-9]{1,16}$/;
|
|
32642
|
+
var TOOL_RULES = {
|
|
32643
|
+
git: [
|
|
32644
|
+
["branch-exists", /a branch named .* already exists/i],
|
|
32645
|
+
["ref-conflict", /exists; cannot create|cannot lock ref .* is at .* but expected/i],
|
|
32646
|
+
["lock-held", /could not lock config file [^\n]*: File exists/i],
|
|
32647
|
+
["lock-held", /(?:unable to create '[^\n]*\.lock'|cannot lock ref)[^\n]*: File exists/i],
|
|
32648
|
+
["lock-held", /another git process/i],
|
|
32649
|
+
["worktree-conflict", /already (?:checked out|used by worktree)|used by worktree at/i],
|
|
32650
|
+
["invalid-ref", /not a valid (?:branch name|object name)|bad (?:revision|object)/i],
|
|
32651
|
+
["invalid-ref", /unknown revision|ambiguous argument|invalid reference/i],
|
|
32652
|
+
["branch-not-found", /no branch named|refname .* not found|branch '.*' not found/i],
|
|
32653
|
+
["branch-not-found", /did not match any file\(s\) known to git/i],
|
|
32654
|
+
["dubious-ownership", /detected dubious ownership/i],
|
|
32655
|
+
["no-remote", /does not appear to be a git repository|no such remote/i],
|
|
32656
|
+
["no-remote", /repository (?:.* )?not found/i],
|
|
32657
|
+
["not-a-repository", /not a git repository/i],
|
|
32658
|
+
["remote-ref-missing", /could(?:n't| not) find remote ref|not our ref/i],
|
|
32659
|
+
["merge-conflict", /\bCONFLICT \(|merge conflict|could not apply|unmerged files/i],
|
|
32660
|
+
["dirty-worktree", /local changes .* would be overwritten|commit your changes or stash/i],
|
|
32661
|
+
["nothing-to-commit", /nothing to commit|no changes added to commit/i],
|
|
32662
|
+
["push-rejected", /\[(?:remote )?rejected\]|non-fast-forward/i],
|
|
32663
|
+
["identity-unknown", /please tell me who you are|unable to auto-detect email/i],
|
|
32664
|
+
[
|
|
32665
|
+
"worktree-has-changes",
|
|
32666
|
+
/^fatal: [^\n]*['"] contains modified or untracked files(?:, use --force to delete it)?\.?\s*$/im
|
|
32667
|
+
],
|
|
32668
|
+
["not-a-worktree", /^fatal: [^\n]*['"] is not a working tree\.?\s*$/im],
|
|
32669
|
+
["branch-not-merged", /^(?:error|fatal): [^\n]*['"] is not fully merged\.?\s*$/im]
|
|
32670
|
+
],
|
|
32671
|
+
gh: [
|
|
32672
|
+
["pull-request-exists", /a pull request for branch .* already exists/i],
|
|
32673
|
+
["no-pull-request", /no (?:pull requests? (?:found|match)|open pull requests?\b)/i],
|
|
32674
|
+
["rate-limited", /rate limit|http 429/i],
|
|
32675
|
+
["forbidden", /http 403|resource not accessible/i],
|
|
32676
|
+
["resource-not-found", /http 404|could not resolve to a/i],
|
|
32677
|
+
["server-error", /http 5\d\d/i]
|
|
32678
|
+
],
|
|
32679
|
+
docker: [
|
|
32680
|
+
["daemon-unavailable", /cannot connect to the docker daemon|error during connect/i],
|
|
32681
|
+
[
|
|
32682
|
+
"daemon-unavailable",
|
|
32683
|
+
/is the docker daemon running|docker desktop is (?:not running|unable)/i
|
|
32684
|
+
],
|
|
32685
|
+
["container-not-found", /no such container/i],
|
|
32686
|
+
["container-not-running", /container .* is (?:not running|paused|restarting)/i],
|
|
32687
|
+
["container-name-conflict", /name .* is already in use/i],
|
|
32688
|
+
["image-not-found", /no such image|pull access denied|manifest .* not found/i],
|
|
32689
|
+
["image-not-found", /manifest unknown|repository does not exist/i],
|
|
32690
|
+
["removal-in-progress", /removal of container .* is already in progress/i],
|
|
32691
|
+
[
|
|
32692
|
+
"image-in-use",
|
|
32693
|
+
/image is (?:being used|referenced)|unable to (?:remove|delete) .*must be forced/i
|
|
32694
|
+
],
|
|
32695
|
+
["volume-in-use", /volume is in use/i],
|
|
32696
|
+
["volume-not-found", /no such volume/i],
|
|
32697
|
+
["network-in-use", /has active endpoints/i],
|
|
32698
|
+
["network-not-found", /network .* not found/i]
|
|
32699
|
+
],
|
|
32700
|
+
tmux: [
|
|
32701
|
+
["session-exists", /duplicate session/i],
|
|
32702
|
+
[
|
|
32703
|
+
"server-not-running",
|
|
32704
|
+
/no server running|failed to connect to server|no sessions|server exited|lost server/i
|
|
32705
|
+
],
|
|
32706
|
+
[
|
|
32707
|
+
"server-not-running",
|
|
32708
|
+
/error connecting to \/[^\n]* \((?:No such file or directory|Connection refused)\)/i
|
|
32709
|
+
],
|
|
32710
|
+
["session-not-found", /can't find (?:session|window|pane)|session not found/i]
|
|
32711
|
+
]
|
|
32712
|
+
};
|
|
32713
|
+
var ALL_TOOLS = Object.keys(TOOL_RULES);
|
|
32714
|
+
var SHARED_RULES = [
|
|
32715
|
+
["disk-full", /no space left|enospc|disk quota exceeded/i],
|
|
32716
|
+
["auth-failed", /authentication (?:failed|required)|could not read (?:username|password)/i],
|
|
32717
|
+
["auth-failed", /terminal prompts disabled|invalid username or password|bad credentials/i],
|
|
32718
|
+
["auth-failed", /permission denied \(|permission to \S+ denied|host key verification failed/i],
|
|
32719
|
+
["auth-failed", /gh auth login|not logged in|unauthorized|http 401|returned error: 40[13]/i],
|
|
32720
|
+
["network-failed", /could not resolve host|connection (?:timed out|refused|reset)/i],
|
|
32721
|
+
["network-failed", /network is unreachable|no route to host|temporary failure in name/i],
|
|
32722
|
+
["network-failed", /early eof|failed to connect|remote end hung up/i],
|
|
32723
|
+
["network-failed", /unable to access ['"]?https?:\/\//i],
|
|
32724
|
+
["network-failed", /tls handshake|i\/o timeout/i],
|
|
32725
|
+
[
|
|
32726
|
+
"network-failed",
|
|
32727
|
+
/error connecting to (?:https?:\/\/)?[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?(?::\d+)?(?:[\s/:]|$)/i
|
|
32728
|
+
],
|
|
32729
|
+
["port-in-use", /port is already allocated|address already in use/i],
|
|
32730
|
+
["permission-denied", /permission denied|operation not permitted|read-only file system/i],
|
|
32731
|
+
["command-not-found", /command not found/i],
|
|
32732
|
+
["path-not-found", /no such file or directory/i],
|
|
32733
|
+
["invalid-usage", /^usage: |unknown (?:option|flag|command|shorthand flag)|invalid option/im]
|
|
32734
|
+
];
|
|
32735
|
+
var TOOL_EXIT_CODES = {
|
|
32736
|
+
git: { 129: "invalid-usage" },
|
|
32737
|
+
gh: { 2: "aborted", 4: "auth-failed" },
|
|
32738
|
+
docker: { 125: "daemon-error" },
|
|
32739
|
+
tmux: {}
|
|
32740
|
+
};
|
|
32741
|
+
var SHARED_EXIT_CODES = {
|
|
32742
|
+
124: "timed-out",
|
|
32743
|
+
126: "not-executable",
|
|
32744
|
+
127: "command-not-found",
|
|
32745
|
+
137: "killed",
|
|
32746
|
+
143: "killed"
|
|
32747
|
+
};
|
|
32748
|
+
function read2(target, key) {
|
|
32749
|
+
return target[key];
|
|
32750
|
+
}
|
|
32751
|
+
function boundedForMatching(text) {
|
|
32752
|
+
if (text.length <= MAX_MATCHED_CHARS)
|
|
32753
|
+
return text;
|
|
32754
|
+
const half = MAX_MATCHED_CHARS / 2;
|
|
32755
|
+
return `${text.slice(0, half)}
|
|
32756
|
+
${text.slice(-half)}`;
|
|
32757
|
+
}
|
|
32758
|
+
function failureText(error) {
|
|
32759
|
+
const stderr = read2(error, "stderr");
|
|
32760
|
+
if (Buffer.isBuffer(stderr) && stderr.length > 0) {
|
|
32761
|
+
return boundedForMatching(stderr.subarray(-MAX_MATCHED_CHARS).toString());
|
|
32762
|
+
}
|
|
32763
|
+
if (typeof stderr === "string" && stderr.length > 0)
|
|
32764
|
+
return boundedForMatching(stderr);
|
|
32765
|
+
const message = read2(error, "message");
|
|
32766
|
+
if (typeof message !== "string")
|
|
32767
|
+
return "";
|
|
32768
|
+
return message.startsWith("Command failed") ? "" : boundedForMatching(message);
|
|
32769
|
+
}
|
|
32770
|
+
function isRawSpawnEnoent(error) {
|
|
32771
|
+
const syscall = read2(error, "syscall");
|
|
32772
|
+
return read2(error, "code") === "ENOENT" && typeof syscall === "string" && /^(?:spawn(?:Sync)?(?:\s|$)|posix_spawnp?$)/.test(syscall);
|
|
32773
|
+
}
|
|
32774
|
+
function classifiedReason(error, exitCode, signal, options) {
|
|
32775
|
+
if (read2(error, "aborted") === true)
|
|
32776
|
+
return "aborted";
|
|
32777
|
+
if (read2(error, "outputLimitExceeded") === true)
|
|
32778
|
+
return "output-too-large";
|
|
32779
|
+
if (read2(error, "timedOut") === true)
|
|
32780
|
+
return "timed-out";
|
|
32781
|
+
if (read2(error, "executableMissing") === true || isRawSpawnEnoent(error)) {
|
|
32782
|
+
return "executable-missing";
|
|
32783
|
+
}
|
|
32784
|
+
const named = exitCode === null ? undefined : options.exitCodes?.[exitCode];
|
|
32785
|
+
if (named)
|
|
32786
|
+
return named;
|
|
32787
|
+
if (signal)
|
|
32788
|
+
return "killed";
|
|
32789
|
+
const text = failureText(error);
|
|
32790
|
+
for (const tool of options.tools ?? ALL_TOOLS) {
|
|
32791
|
+
for (const [reason, pattern] of TOOL_RULES[tool]) {
|
|
32792
|
+
if (pattern.test(text))
|
|
32793
|
+
return reason;
|
|
32794
|
+
}
|
|
32795
|
+
}
|
|
32796
|
+
for (const [reason, pattern] of SHARED_RULES) {
|
|
32797
|
+
if (pattern.test(text))
|
|
32798
|
+
return reason;
|
|
32799
|
+
}
|
|
32800
|
+
if (exitCode !== null) {
|
|
32801
|
+
for (const tool of options.tools ?? []) {
|
|
32802
|
+
const reason = TOOL_EXIT_CODES[tool][exitCode];
|
|
32803
|
+
if (reason)
|
|
32804
|
+
return reason;
|
|
32805
|
+
}
|
|
32806
|
+
const reason = SHARED_EXIT_CODES[exitCode];
|
|
32807
|
+
if (reason)
|
|
32808
|
+
return reason;
|
|
32809
|
+
}
|
|
32810
|
+
return "unclassified";
|
|
32811
|
+
}
|
|
32812
|
+
function numericExitCode(error) {
|
|
32813
|
+
for (const key of ["exitCode", "code"]) {
|
|
32814
|
+
const value = read2(error, key);
|
|
32815
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
32816
|
+
return value;
|
|
32817
|
+
}
|
|
32818
|
+
return null;
|
|
32819
|
+
}
|
|
32820
|
+
function classifyCommandFailure(error, options = {}) {
|
|
32821
|
+
if (typeof error !== "object" || error === null) {
|
|
32822
|
+
return { reason: "unclassified", exitCode: null, signal: null };
|
|
32823
|
+
}
|
|
32824
|
+
try {
|
|
32825
|
+
const exitCode = numericExitCode(error);
|
|
32826
|
+
const rawSignal = read2(error, "signal");
|
|
32827
|
+
const signal = typeof rawSignal === "string" && SIGNAL_PATTERN.test(rawSignal) ? rawSignal : null;
|
|
32828
|
+
return { reason: classifiedReason(error, exitCode, signal, options), exitCode, signal };
|
|
32829
|
+
} catch {
|
|
32830
|
+
return { reason: "unclassified", exitCode: null, signal: null };
|
|
32831
|
+
}
|
|
32832
|
+
}
|
|
32833
|
+
|
|
32834
|
+
// ../protocol/src/node/lost-exit-reaper.ts
|
|
32835
|
+
import { createRequire as createRequire3 } from "node:module";
|
|
32836
|
+
|
|
32837
|
+
// ../protocol/src/node/shell-process-state.ts
|
|
32838
|
+
import { readdirSync, readFileSync } from "node:fs";
|
|
32839
|
+
import { constants as osConstants } from "node:os";
|
|
32840
|
+
var PROCESS_INSPECTION_OPTIONS = {
|
|
32841
|
+
timeout: 100,
|
|
32842
|
+
killSignal: "SIGKILL",
|
|
32843
|
+
maxBuffer: 1024 * 1024
|
|
32844
|
+
};
|
|
32845
|
+
function bunRuntime() {
|
|
32846
|
+
return globalThis.Bun;
|
|
32847
|
+
}
|
|
32848
|
+
function decodeWaitStatus(status) {
|
|
32849
|
+
const signalNumber = status & 127;
|
|
32850
|
+
if (signalNumber === 0)
|
|
32851
|
+
return { code: status >> 8 & 255, signal: null };
|
|
32852
|
+
const name = Object.entries(osConstants.signals).find(([, value]) => value === signalNumber)?.[0];
|
|
32853
|
+
return { code: null, signal: name ?? "SIGKILL" };
|
|
32854
|
+
}
|
|
32855
|
+
function readZombieExit(pid) {
|
|
32856
|
+
try {
|
|
32857
|
+
const result = bunRuntime()?.spawnSync(["/bin/ps", "-o", "stat=,xstat=", "-p", String(pid)], PROCESS_INSPECTION_OPTIONS);
|
|
32858
|
+
if (!result?.success)
|
|
32859
|
+
return;
|
|
32860
|
+
const { stdout } = result;
|
|
32861
|
+
const match = /^Z\S*\s+([0-9a-f]+)\s*$/i.exec(stdout.toString().trim());
|
|
32862
|
+
return match ? decodeWaitStatus(Number.parseInt(match[1], 16)) : undefined;
|
|
32863
|
+
} catch {
|
|
32864
|
+
return;
|
|
32865
|
+
}
|
|
32866
|
+
}
|
|
32867
|
+
var EXIT_WATCH_MS = 1000;
|
|
32868
|
+
var EXIT_WATCH_MAX_MS = 16000;
|
|
32869
|
+
function watchForLostExit(pid, onExit) {
|
|
32870
|
+
if (process.platform !== "darwin" || pid === undefined || !bunRuntime())
|
|
32871
|
+
return () => {
|
|
32872
|
+
return;
|
|
32873
|
+
};
|
|
32874
|
+
let timer;
|
|
32875
|
+
const watch = (delayMs) => {
|
|
32876
|
+
timer = setTimeout(() => {
|
|
32877
|
+
const exit = readZombieExit(pid);
|
|
32878
|
+
if (exit)
|
|
32879
|
+
onExit(exit);
|
|
32880
|
+
else
|
|
32881
|
+
watch(Math.min(delayMs * 2, EXIT_WATCH_MAX_MS));
|
|
32882
|
+
}, delayMs);
|
|
32883
|
+
};
|
|
32884
|
+
watch(EXIT_WATCH_MS);
|
|
32885
|
+
return () => clearTimeout(timer);
|
|
32886
|
+
}
|
|
32887
|
+
function isLiveMember(state, groupId, pgid) {
|
|
32888
|
+
return Number(groupId) === pgid && state !== undefined && !/^[ZX]/.test(state);
|
|
32889
|
+
}
|
|
32890
|
+
function linuxGroupHasLiveMember(pgid) {
|
|
32891
|
+
for (const entry of readdirSync("/proc")) {
|
|
32892
|
+
if (!/^\d+$/.test(entry))
|
|
32893
|
+
continue;
|
|
32894
|
+
let stat;
|
|
32895
|
+
try {
|
|
32896
|
+
stat = readFileSync(`/proc/${entry}/stat`, "latin1");
|
|
32897
|
+
} catch {
|
|
32898
|
+
continue;
|
|
32899
|
+
}
|
|
32900
|
+
const [state, , groupId] = stat.slice(stat.lastIndexOf(")") + 2).split(" ");
|
|
32901
|
+
if (isLiveMember(state, groupId, pgid))
|
|
32902
|
+
return true;
|
|
32903
|
+
}
|
|
32904
|
+
return false;
|
|
32905
|
+
}
|
|
32906
|
+
function psGroupHasLiveMember(pgid) {
|
|
32907
|
+
const result = bunRuntime()?.spawnSync(["/bin/ps", "-A", "-o", "pgid=,stat="], PROCESS_INSPECTION_OPTIONS);
|
|
32908
|
+
if (!result?.success)
|
|
32909
|
+
return true;
|
|
32910
|
+
return result.stdout.toString().split(`
|
|
32911
|
+
`).some((line) => {
|
|
32912
|
+
const [groupId, state] = line.trim().split(/\s+/);
|
|
32913
|
+
return isLiveMember(state, groupId, pgid);
|
|
32914
|
+
});
|
|
32915
|
+
}
|
|
32916
|
+
function groupHasLiveMember(pgid) {
|
|
32917
|
+
try {
|
|
32918
|
+
return process.platform === "linux" ? linuxGroupHasLiveMember(pgid) : psGroupHasLiveMember(pgid);
|
|
32919
|
+
} catch {
|
|
32920
|
+
return true;
|
|
32921
|
+
}
|
|
32922
|
+
}
|
|
32923
|
+
|
|
32924
|
+
// ../protocol/src/node/lost-exit-reaper.ts
|
|
32925
|
+
var log3 = createLogger("process");
|
|
32926
|
+
var REAP_GRACE_MS = 2000;
|
|
32927
|
+
var REAP_MAX_CHECK_MS = 30000;
|
|
32928
|
+
var REAP_MAX_CHECKS = 12;
|
|
32929
|
+
var REAP_MAX_PENDING = 256;
|
|
32930
|
+
function createLostExitReaper(options) {
|
|
32931
|
+
const { system } = options;
|
|
32932
|
+
const graceMs = options.graceMs ?? REAP_GRACE_MS;
|
|
32933
|
+
const maxCheckMs = options.maxCheckMs ?? REAP_MAX_CHECK_MS;
|
|
32934
|
+
const maxChecks = options.maxChecks ?? REAP_MAX_CHECKS;
|
|
32935
|
+
const maxPending = options.maxPending ?? REAP_MAX_PENDING;
|
|
32936
|
+
const pending = new Map;
|
|
32937
|
+
let reaped = 0;
|
|
32938
|
+
let abandoned = 0;
|
|
32939
|
+
const abandon = (pid, reason) => {
|
|
32940
|
+
abandoned += 1;
|
|
32941
|
+
log3.warn("child.reap-abandoned", { pid, reason });
|
|
32942
|
+
};
|
|
32943
|
+
const check = (pid, reported, startedAt) => {
|
|
32944
|
+
if (reported())
|
|
32945
|
+
return false;
|
|
32946
|
+
const found = system.inspect(pid);
|
|
32947
|
+
if (found === undefined)
|
|
32948
|
+
return true;
|
|
32949
|
+
if (found === "gone" || found.ppid !== system.selfPid)
|
|
32950
|
+
return false;
|
|
32951
|
+
if (!found.state.startsWith("Z"))
|
|
32952
|
+
return true;
|
|
32953
|
+
const result = system.waitNoHang(pid);
|
|
32954
|
+
if (result === pid) {
|
|
32955
|
+
reaped += 1;
|
|
32956
|
+
log3.info("child.reaped", { pid, waitedMs: Date.now() - startedAt });
|
|
32957
|
+
return false;
|
|
32958
|
+
}
|
|
32959
|
+
if (result === 0)
|
|
32960
|
+
return true;
|
|
32961
|
+
abandon(pid, "waitpid-failed");
|
|
32962
|
+
return false;
|
|
32963
|
+
};
|
|
32964
|
+
const schedule = (pid, reported, startedAt, delayMs, checks) => {
|
|
32965
|
+
const timer = setTimeout(() => {
|
|
32966
|
+
pending.delete(pid);
|
|
32967
|
+
let again;
|
|
32968
|
+
try {
|
|
32969
|
+
again = check(pid, reported, startedAt);
|
|
32970
|
+
} catch {
|
|
32971
|
+
again = true;
|
|
32972
|
+
}
|
|
32973
|
+
if (!again)
|
|
32974
|
+
return;
|
|
32975
|
+
if (checks + 1 >= maxChecks) {
|
|
32976
|
+
abandon(pid, "not-a-zombie");
|
|
32977
|
+
return;
|
|
32978
|
+
}
|
|
32979
|
+
schedule(pid, reported, startedAt, Math.min(delayMs * 2, maxCheckMs), checks + 1);
|
|
32980
|
+
}, delayMs);
|
|
32981
|
+
timer.unref?.();
|
|
32982
|
+
pending.set(pid, timer);
|
|
32983
|
+
};
|
|
32984
|
+
return {
|
|
32985
|
+
reap(pid, reported) {
|
|
32986
|
+
if (!Number.isSafeInteger(pid) || pid <= 1 || pid === system.selfPid)
|
|
32987
|
+
return;
|
|
32988
|
+
if (pending.has(pid) || reported())
|
|
32989
|
+
return;
|
|
32990
|
+
if (pending.size >= maxPending) {
|
|
32991
|
+
abandon(pid, "capacity");
|
|
32992
|
+
return;
|
|
32993
|
+
}
|
|
32994
|
+
schedule(pid, reported, Date.now(), graceMs, 0);
|
|
32995
|
+
},
|
|
32996
|
+
stats: () => ({ pending: pending.size, reaped, abandoned }),
|
|
32997
|
+
stop() {
|
|
32998
|
+
for (const timer of pending.values())
|
|
32999
|
+
clearTimeout(timer);
|
|
33000
|
+
pending.clear();
|
|
33001
|
+
}
|
|
33002
|
+
};
|
|
33003
|
+
}
|
|
33004
|
+
var WNOHANG = 1;
|
|
33005
|
+
function loadDarwinWaitpid(loadFfi = () => createRequire3(import.meta.url)("bun:ffi")) {
|
|
33006
|
+
try {
|
|
33007
|
+
const { dlopen, FFIType } = loadFfi();
|
|
33008
|
+
const libSystem = dlopen("/usr/lib/libSystem.B.dylib", {
|
|
33009
|
+
waitpid: { args: [FFIType.i32, FFIType.ptr, FFIType.i32], returns: FFIType.i32 }
|
|
33010
|
+
});
|
|
33011
|
+
const status = new Int32Array(1);
|
|
33012
|
+
return (pid) => libSystem.symbols.waitpid(pid, status, WNOHANG);
|
|
33013
|
+
} catch {
|
|
33014
|
+
return;
|
|
33015
|
+
}
|
|
33016
|
+
}
|
|
33017
|
+
function darwinReaperSystem(loadFfi) {
|
|
33018
|
+
const waitNoHang = loadDarwinWaitpid(loadFfi);
|
|
33019
|
+
if (!waitNoHang)
|
|
33020
|
+
return;
|
|
33021
|
+
return {
|
|
33022
|
+
selfPid: process.pid,
|
|
33023
|
+
inspect(pid) {
|
|
33024
|
+
const result = bunRuntime()?.spawnSync(["/bin/ps", "-o", "ppid=,stat=", "-p", String(pid)], PROCESS_INSPECTION_OPTIONS);
|
|
33025
|
+
if (!result)
|
|
33026
|
+
return;
|
|
33027
|
+
const output = result.stdout.toString().trim();
|
|
33028
|
+
if (!result.success)
|
|
33029
|
+
return result.exitCode === 1 && output === "" ? "gone" : undefined;
|
|
33030
|
+
const match = /^(\d+)\s+(\S+)$/.exec(output);
|
|
33031
|
+
return match ? { ppid: Number(match[1]), state: match[2] } : undefined;
|
|
33032
|
+
},
|
|
33033
|
+
waitNoHang
|
|
33034
|
+
};
|
|
33035
|
+
}
|
|
33036
|
+
var defaultReaper;
|
|
33037
|
+
function createDarwinLostExitReaper(loadFfi) {
|
|
33038
|
+
const system = darwinReaperSystem(loadFfi);
|
|
33039
|
+
if (!system)
|
|
33040
|
+
log3.warn("child.reap-unavailable");
|
|
33041
|
+
return system ? createLostExitReaper({ system }) : null;
|
|
33042
|
+
}
|
|
33043
|
+
function sharedReaper() {
|
|
33044
|
+
if (defaultReaper === undefined) {
|
|
33045
|
+
defaultReaper = createDarwinLostExitReaper();
|
|
33046
|
+
}
|
|
33047
|
+
return defaultReaper ?? undefined;
|
|
33048
|
+
}
|
|
33049
|
+
function reapAfterLostExit(pid, reported) {
|
|
33050
|
+
if (process.platform !== "darwin" || pid === undefined || !bunRuntime())
|
|
33051
|
+
return;
|
|
33052
|
+
sharedReaper()?.reap(pid, reported);
|
|
33053
|
+
}
|
|
33054
|
+
|
|
33055
|
+
// ../protocol/src/node/command-capture.ts
|
|
33056
|
+
class CommandFailedError extends Error {
|
|
33057
|
+
stdout;
|
|
33058
|
+
stdoutBytes;
|
|
33059
|
+
stderr;
|
|
33060
|
+
timedOut;
|
|
33061
|
+
outputCloseTimedOut;
|
|
33062
|
+
executableMissing;
|
|
33063
|
+
aborted;
|
|
33064
|
+
outputLimitExceeded;
|
|
33065
|
+
exitCode;
|
|
33066
|
+
signal;
|
|
33067
|
+
constructor(message, details = {}) {
|
|
33068
|
+
super(message);
|
|
33069
|
+
this.name = "CommandFailedError";
|
|
33070
|
+
this.stdout = details.stdout ?? "";
|
|
33071
|
+
this.stdoutBytes = details.stdoutBytes ?? Buffer.alloc(0);
|
|
33072
|
+
this.stderr = details.stderr ?? "";
|
|
33073
|
+
this.timedOut = details.timedOut ?? false;
|
|
33074
|
+
this.outputCloseTimedOut = details.outputCloseTimedOut ?? false;
|
|
33075
|
+
this.executableMissing = details.executableMissing ?? false;
|
|
33076
|
+
this.aborted = details.aborted ?? false;
|
|
33077
|
+
this.outputLimitExceeded = details.outputLimitExceeded ?? false;
|
|
33078
|
+
this.exitCode = details.exitCode ?? null;
|
|
33079
|
+
this.signal = details.signal ?? null;
|
|
33080
|
+
}
|
|
33081
|
+
toJSON() {
|
|
33082
|
+
return { ...formatLogError(this), ...classifyCommandFailure(this) };
|
|
33083
|
+
}
|
|
33084
|
+
[inspect.custom]() {
|
|
33085
|
+
const { name, reason, exitCode, signal, stack } = this.toJSON();
|
|
33086
|
+
const frames = stack?.length ? ` | ${stack.join(" | ")}` : "";
|
|
33087
|
+
return `${name} reason=${reason} exitCode=${exitCode} signal=${signal} outputOmitted=true${frames}`;
|
|
33088
|
+
}
|
|
33089
|
+
}
|
|
33090
|
+
function redactCommandValues(value, redactValues) {
|
|
33091
|
+
const secrets = Array.from(new Set((redactValues ?? []).filter((secret) => typeof secret === "string" && secret.length > 0))).sort((left, right) => right.length - left.length);
|
|
33092
|
+
return secrets.reduce((redacted, secret) => redacted.split(secret).join("[REDACTED]"), value);
|
|
33093
|
+
}
|
|
33094
|
+
var COMMAND_ABORTED_MESSAGE = "Command aborted";
|
|
33095
|
+
var OUTPUT_LIMIT_MESSAGE = "maxBuffer length exceeded";
|
|
33096
|
+
function commandFailureOutcome(error) {
|
|
33097
|
+
const details = error ?? {};
|
|
33098
|
+
const message = typeof details.message === "string" ? details.message : "";
|
|
33099
|
+
return {
|
|
33100
|
+
timedOut: details.killed === true,
|
|
33101
|
+
executableMissing: details.code === "ENOENT",
|
|
33102
|
+
aborted: message === COMMAND_ABORTED_MESSAGE,
|
|
33103
|
+
outputLimitExceeded: details.outputLimitExceeded === true,
|
|
33104
|
+
exitCode: typeof details.code === "number" ? details.code : null,
|
|
33105
|
+
signal: details.signal ?? null
|
|
33106
|
+
};
|
|
33107
|
+
}
|
|
33108
|
+
var commandInvocations = new Map;
|
|
33109
|
+
var commandCaptureMetrics;
|
|
33110
|
+
var commandObservers = new Map;
|
|
33111
|
+
function nonInteractiveGitEnv(env) {
|
|
33112
|
+
const merged = { ...env ?? process.env };
|
|
33113
|
+
merged.GIT_TERMINAL_PROMPT ??= "0";
|
|
33114
|
+
if (process.platform !== "win32") {
|
|
33115
|
+
merged.SSH_ASKPASS ??= "/usr/bin/false";
|
|
33116
|
+
merged.SSH_ASKPASS_REQUIRE ??= "force";
|
|
33117
|
+
}
|
|
33118
|
+
return merged;
|
|
33119
|
+
}
|
|
33120
|
+
var MAX_COMMAND_OUTPUT_BYTES2 = 50 * 1024 * 1024;
|
|
33121
|
+
var COMMAND_KILL_GRACE_MS = 100;
|
|
33122
|
+
var COMMAND_OUTPUT_CHECK_MS = 100;
|
|
33123
|
+
var COMMAND_GROUP_POLL_MS = 5;
|
|
33124
|
+
var COMMAND_GROUP_POLL_MAX_MS = 200;
|
|
33125
|
+
function openCaptureFile() {
|
|
33126
|
+
const filePath = path.join(os.tmpdir(), `orkestrator-capture-${randomUUID()}`);
|
|
33127
|
+
const fd = captureFs.openSync(filePath, fsConstants.O_CREAT | fsConstants.O_EXCL | fsConstants.O_RDWR | fsConstants.O_APPEND, 384);
|
|
33128
|
+
try {
|
|
33129
|
+
captureFs.unlinkSync(filePath);
|
|
33130
|
+
return fd;
|
|
33131
|
+
} catch (error) {
|
|
33132
|
+
captureFs.closeSync(fd);
|
|
33133
|
+
throw error;
|
|
33134
|
+
}
|
|
33135
|
+
}
|
|
33136
|
+
function readCaptureFile(fd, limit) {
|
|
33137
|
+
const size = Math.min(captureFs.fstatSync(fd).size, limit);
|
|
33138
|
+
const buffer = Buffer.allocUnsafe(size);
|
|
33139
|
+
let offset = 0;
|
|
33140
|
+
while (offset < size) {
|
|
33141
|
+
const bytesRead = captureFs.readSync(fd, buffer, offset, size - offset, offset);
|
|
33142
|
+
if (bytesRead === 0)
|
|
33143
|
+
break;
|
|
33144
|
+
offset += bytesRead;
|
|
33145
|
+
}
|
|
33146
|
+
return buffer.subarray(0, offset);
|
|
33147
|
+
}
|
|
33148
|
+
function spawnCaptured(command, args, options, stdoutFd, stderrFd) {
|
|
33149
|
+
const payload = options.stdin?.length ? Buffer.from(options.stdin) : undefined;
|
|
33150
|
+
const env = command === "git" ? nonInteractiveGitEnv(options.env) : options.env ?? process.env;
|
|
33151
|
+
const detached = process.platform !== "win32";
|
|
33152
|
+
const bun = bunRuntime();
|
|
33153
|
+
if (bun) {
|
|
33154
|
+
const child = bun.spawn([command, ...args], {
|
|
33155
|
+
cwd: options.cwd,
|
|
33156
|
+
env,
|
|
33157
|
+
detached,
|
|
33158
|
+
windowsHide: true,
|
|
33159
|
+
stdin: payload ?? "pipe",
|
|
33160
|
+
stdout: stdoutFd,
|
|
33161
|
+
stderr: stderrFd
|
|
33162
|
+
});
|
|
33163
|
+
if (!payload)
|
|
33164
|
+
closeStdin(child.stdin);
|
|
33165
|
+
const current = () => ({ code: child.exitCode, signal: child.signalCode });
|
|
33166
|
+
return {
|
|
33167
|
+
pid: child.pid,
|
|
33168
|
+
exited: child.exited.then(current),
|
|
33169
|
+
current,
|
|
33170
|
+
kill: (signal) => child.kill(signal)
|
|
33171
|
+
};
|
|
33172
|
+
}
|
|
33173
|
+
const child = spawn2(command, args, {
|
|
33174
|
+
cwd: options.cwd,
|
|
33175
|
+
env,
|
|
33176
|
+
detached,
|
|
33177
|
+
windowsHide: true,
|
|
33178
|
+
stdio: [payload ? "pipe" : "ignore", stdoutFd, stderrFd]
|
|
33179
|
+
});
|
|
33180
|
+
if (payload) {
|
|
33181
|
+
child.stdin?.on("error", () => {
|
|
33182
|
+
return;
|
|
33183
|
+
});
|
|
33184
|
+
child.stdin?.end(payload);
|
|
33185
|
+
}
|
|
33186
|
+
return {
|
|
33187
|
+
pid: child.pid,
|
|
33188
|
+
exited: new Promise((resolve, reject) => {
|
|
33189
|
+
child.once("exit", (code, signal) => resolve({ code, signal }));
|
|
33190
|
+
child.once("error", reject);
|
|
33191
|
+
}),
|
|
33192
|
+
current: () => ({ code: child.exitCode, signal: child.signalCode }),
|
|
33193
|
+
kill: (signal) => {
|
|
33194
|
+
child.kill(signal);
|
|
33195
|
+
}
|
|
33196
|
+
};
|
|
33197
|
+
}
|
|
33198
|
+
function closeStdin(stdin) {
|
|
33199
|
+
try {
|
|
33200
|
+
Promise.resolve(stdin.end()).catch(() => {
|
|
33201
|
+
return;
|
|
33202
|
+
});
|
|
33203
|
+
} catch {}
|
|
33204
|
+
}
|
|
33205
|
+
function exitReported(child) {
|
|
33206
|
+
const { code, signal } = child.current();
|
|
33207
|
+
return code !== null || signal !== null;
|
|
33208
|
+
}
|
|
33209
|
+
function signalCommand(child, signal) {
|
|
33210
|
+
if (child.pid === undefined)
|
|
33211
|
+
return;
|
|
33212
|
+
try {
|
|
33213
|
+
if (process.platform !== "win32") {
|
|
33214
|
+
process.kill(-child.pid, signal);
|
|
33215
|
+
} else {
|
|
33216
|
+
child.kill(signal);
|
|
33217
|
+
}
|
|
33218
|
+
} catch {}
|
|
33219
|
+
}
|
|
33220
|
+
function commandGroupAlive(child) {
|
|
33221
|
+
if (process.platform === "win32" || child.pid === undefined)
|
|
33222
|
+
return false;
|
|
33223
|
+
try {
|
|
33224
|
+
process.kill(-child.pid, 0);
|
|
33225
|
+
} catch (error) {
|
|
33226
|
+
if (error.code === "ESRCH")
|
|
33227
|
+
return false;
|
|
33228
|
+
}
|
|
33229
|
+
return groupHasLiveMember(child.pid);
|
|
33230
|
+
}
|
|
33231
|
+
function executeCommandBytes(command, args, options, timeoutMs, outputLimit, stderrLimit) {
|
|
33232
|
+
return new Promise((resolve, reject) => {
|
|
33233
|
+
if (options.signal?.aborted) {
|
|
33234
|
+
reject(Object.assign(new Error(COMMAND_ABORTED_MESSAGE), { killed: true }));
|
|
33235
|
+
return;
|
|
33236
|
+
}
|
|
33237
|
+
const captureFds = [];
|
|
33238
|
+
const releaseCaptureFds = () => {
|
|
33239
|
+
for (const fd of captureFds.splice(0)) {
|
|
33240
|
+
try {
|
|
33241
|
+
captureFs.closeSync(fd);
|
|
33242
|
+
} catch {}
|
|
33243
|
+
}
|
|
33244
|
+
};
|
|
33245
|
+
try {
|
|
33246
|
+
captureFds.push(openCaptureFile());
|
|
33247
|
+
captureFds.push(openCaptureFile());
|
|
33248
|
+
} catch (error) {
|
|
33249
|
+
releaseCaptureFds();
|
|
33250
|
+
const code = error.code ?? "unknown";
|
|
33251
|
+
reject(new Error(`Could not open a command output file in the temporary directory: ${code}`));
|
|
33252
|
+
return;
|
|
33253
|
+
}
|
|
33254
|
+
const [stdoutFd, stderrFd] = captureFds;
|
|
33255
|
+
let child;
|
|
33256
|
+
try {
|
|
33257
|
+
child = spawnCaptured(command, args, options, stdoutFd, stderrFd);
|
|
33258
|
+
} catch (error) {
|
|
33259
|
+
releaseCaptureFds();
|
|
33260
|
+
reject(error);
|
|
33261
|
+
return;
|
|
33262
|
+
}
|
|
33263
|
+
let settled = false;
|
|
33264
|
+
let timedOut = false;
|
|
33265
|
+
let timeoutTimer;
|
|
33266
|
+
let groupTimer;
|
|
33267
|
+
let limitTimer;
|
|
33268
|
+
let stopExitWatch = () => {};
|
|
33269
|
+
let commandExit;
|
|
33270
|
+
const finishCapture = () => {
|
|
33271
|
+
settled = true;
|
|
33272
|
+
clearTimeout(timeoutTimer);
|
|
33273
|
+
clearTimeout(groupTimer);
|
|
33274
|
+
clearInterval(limitTimer);
|
|
33275
|
+
stopExitWatch();
|
|
33276
|
+
options.signal?.removeEventListener("abort", abort);
|
|
33277
|
+
if (!exitReported(child))
|
|
33278
|
+
reapAfterLostExit(child.pid, () => exitReported(child));
|
|
33279
|
+
try {
|
|
33280
|
+
return {
|
|
33281
|
+
stdout: readCaptureFile(stdoutFd, outputLimit),
|
|
33282
|
+
stderr: readCaptureFile(stderrFd, stderrLimit)
|
|
33283
|
+
};
|
|
33284
|
+
} catch (error) {
|
|
33285
|
+
reject(error);
|
|
33286
|
+
return;
|
|
33287
|
+
} finally {
|
|
33288
|
+
releaseCaptureFds();
|
|
33289
|
+
}
|
|
33290
|
+
};
|
|
33291
|
+
const fail = (error) => {
|
|
33292
|
+
if (settled)
|
|
33293
|
+
return;
|
|
33294
|
+
const output = finishCapture();
|
|
33295
|
+
if (output)
|
|
33296
|
+
reject(Object.assign(error, { ...output, killed: timedOut }));
|
|
33297
|
+
};
|
|
33298
|
+
const abort = () => {
|
|
33299
|
+
timedOut = true;
|
|
33300
|
+
signalCommand(child, "SIGKILL");
|
|
33301
|
+
fail(new Error(COMMAND_ABORTED_MESSAGE));
|
|
33302
|
+
};
|
|
33303
|
+
options.signal?.addEventListener("abort", abort, { once: true });
|
|
33304
|
+
const checkOutputLimit = () => {
|
|
33305
|
+
const stream = captureFs.fstatSync(stdoutFd).size > outputLimit ? "stdout" : captureFs.fstatSync(stderrFd).size > stderrLimit ? "stderr" : undefined;
|
|
33306
|
+
if (stream === undefined)
|
|
33307
|
+
return false;
|
|
33308
|
+
signalCommand(child, "SIGKILL");
|
|
33309
|
+
fail(Object.assign(new Error(`${stream} ${OUTPUT_LIMIT_MESSAGE}`), {
|
|
33310
|
+
outputLimitExceeded: true
|
|
33311
|
+
}));
|
|
33312
|
+
return true;
|
|
33313
|
+
};
|
|
33314
|
+
const failIfOverLimit = () => {
|
|
33315
|
+
try {
|
|
33316
|
+
return checkOutputLimit();
|
|
33317
|
+
} catch (error) {
|
|
33318
|
+
signalCommand(child, "SIGKILL");
|
|
33319
|
+
fail(error instanceof Error ? error : new Error(String(error)));
|
|
33320
|
+
return true;
|
|
33321
|
+
}
|
|
33322
|
+
};
|
|
33323
|
+
limitTimer = setInterval(() => {
|
|
33324
|
+
if (!settled && !timedOut)
|
|
33325
|
+
failIfOverLimit();
|
|
33326
|
+
}, COMMAND_OUTPUT_CHECK_MS);
|
|
33327
|
+
const settleOnExit = () => {
|
|
33328
|
+
if (settled || timedOut || failIfOverLimit())
|
|
33329
|
+
return;
|
|
33330
|
+
if (commandExit?.code !== 0 || commandExit.signal !== null) {
|
|
33331
|
+
fail(Object.assign(new Error(`Command failed: ${[command, ...args].join(" ")}`), {
|
|
33332
|
+
code: commandExit?.code,
|
|
33333
|
+
signal: commandExit?.signal
|
|
33334
|
+
}));
|
|
33335
|
+
return;
|
|
33336
|
+
}
|
|
33337
|
+
const output = finishCapture();
|
|
33338
|
+
if (output)
|
|
33339
|
+
resolve(output);
|
|
33340
|
+
};
|
|
33341
|
+
const awaitGroupExit = (delayMs) => {
|
|
33342
|
+
if (settled || timedOut)
|
|
33343
|
+
return;
|
|
33344
|
+
if (commandGroupAlive(child)) {
|
|
33345
|
+
groupTimer = setTimeout(awaitGroupExit, delayMs, Math.min(delayMs * 2, COMMAND_GROUP_POLL_MAX_MS));
|
|
33346
|
+
return;
|
|
33347
|
+
}
|
|
33348
|
+
settleOnExit();
|
|
33349
|
+
};
|
|
33350
|
+
const onCommandExit = (exit) => {
|
|
33351
|
+
if (commandExit)
|
|
33352
|
+
return;
|
|
33353
|
+
commandExit = exit;
|
|
33354
|
+
stopExitWatch();
|
|
33355
|
+
if (options.waitForDescendants)
|
|
33356
|
+
awaitGroupExit(COMMAND_GROUP_POLL_MS);
|
|
33357
|
+
else
|
|
33358
|
+
settleOnExit();
|
|
33359
|
+
};
|
|
33360
|
+
child.exited.then(onCommandExit, (error) => fail(error instanceof Error ? error : new Error(String(error))));
|
|
33361
|
+
stopExitWatch = watchForLostExit(child.pid, (exit) => {
|
|
33362
|
+
if (!settled && !timedOut)
|
|
33363
|
+
onCommandExit(exit);
|
|
33364
|
+
});
|
|
33365
|
+
if (timeoutMs > 0) {
|
|
33366
|
+
timeoutTimer = setTimeout(() => {
|
|
33367
|
+
timedOut = true;
|
|
33368
|
+
signalCommand(child, "SIGTERM");
|
|
33369
|
+
timeoutTimer = setTimeout(() => {
|
|
33370
|
+
signalCommand(child, "SIGKILL");
|
|
33371
|
+
fail(Object.assign(new Error(`Command timed out after ${timeoutMs} ms`), {
|
|
33372
|
+
code: child.current().code,
|
|
33373
|
+
signal: child.current().signal
|
|
33374
|
+
}));
|
|
33375
|
+
}, COMMAND_KILL_GRACE_MS);
|
|
33376
|
+
}, timeoutMs);
|
|
33377
|
+
}
|
|
33378
|
+
});
|
|
33379
|
+
}
|
|
33380
|
+
async function runCommandBytes(command, args = [], options = {}) {
|
|
33381
|
+
const timeoutMs = options.timeoutMs ?? 60000;
|
|
33382
|
+
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 0 || timeoutMs > 2147483647) {
|
|
33383
|
+
throw new RangeError("timeoutMs must be an integer between 0 and 2147483647");
|
|
33384
|
+
}
|
|
33385
|
+
const outputLimit = options.maxOutputBytes ?? MAX_COMMAND_OUTPUT_BYTES2;
|
|
33386
|
+
if (!Number.isSafeInteger(outputLimit) || outputLimit <= 0) {
|
|
33387
|
+
throw new RangeError("maxOutputBytes must be a positive integer");
|
|
33388
|
+
}
|
|
33389
|
+
const stderrLimit = options.maxStderrBytes ?? outputLimit;
|
|
33390
|
+
if (!Number.isSafeInteger(stderrLimit) || stderrLimit <= 0) {
|
|
33391
|
+
throw new RangeError("maxStderrBytes must be a positive integer");
|
|
33392
|
+
}
|
|
33393
|
+
if (commandInvocations.size < 64 || commandInvocations.has(command)) {
|
|
33394
|
+
commandInvocations.set(command, (commandInvocations.get(command) ?? 0) + 1);
|
|
33395
|
+
}
|
|
33396
|
+
for (const observer of commandObservers.get(command) ?? [])
|
|
33397
|
+
observer(args);
|
|
33398
|
+
commandCaptureMetrics?.started(command, args);
|
|
33399
|
+
try {
|
|
33400
|
+
const { stdout, stderr } = await executeCommandBytes(command, args, options, timeoutMs, outputLimit, stderrLimit);
|
|
33401
|
+
commandCaptureMetrics?.capturedBytes(stdout.length);
|
|
33402
|
+
return {
|
|
33403
|
+
stdout: Buffer.isBuffer(stdout) ? stdout : Buffer.from(stdout),
|
|
33404
|
+
stderr: Buffer.isBuffer(stderr) ? stderr : Buffer.from(stderr)
|
|
33405
|
+
};
|
|
33406
|
+
} catch (error) {
|
|
33407
|
+
const outcome = commandFailureOutcome(error);
|
|
33408
|
+
const redacting = options.redactValues?.some((value) => typeof value === "string" && value.length > 0);
|
|
33409
|
+
if (error && typeof error === "object" && "stdout" in error && "stderr" in error) {
|
|
33410
|
+
const withOutput = error;
|
|
33411
|
+
const stderr = withOutput.stderr?.toString() ?? "";
|
|
33412
|
+
const stdout = withOutput.stdout?.toString() ?? "";
|
|
33413
|
+
const message = (stderr || stdout || withOutput.message || "Command failed").trim();
|
|
33414
|
+
throw new CommandFailedError(redactCommandValues(message, options.redactValues), {
|
|
33415
|
+
...outcome,
|
|
33416
|
+
stdout: redactCommandValues(stdout, options.redactValues),
|
|
33417
|
+
stderr: redactCommandValues(stderr, options.redactValues),
|
|
33418
|
+
...!redacting && Buffer.isBuffer(withOutput.stdout) ? { stdoutBytes: withOutput.stdout } : {}
|
|
33419
|
+
});
|
|
33420
|
+
}
|
|
33421
|
+
if (redacting) {
|
|
33422
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
33423
|
+
throw new CommandFailedError(redactCommandValues(message || "Command failed", options.redactValues), outcome);
|
|
33424
|
+
}
|
|
33425
|
+
if (outcome.timedOut || outcome.executableMissing) {
|
|
33426
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
33427
|
+
throw new CommandFailedError(message || "Command failed", outcome);
|
|
33428
|
+
}
|
|
33429
|
+
throw error;
|
|
33430
|
+
}
|
|
33431
|
+
}
|
|
33432
|
+
async function runCommand(command, args = [], options = {}) {
|
|
33433
|
+
const { stdout, stderr } = await runCommandBytes(command, args, options);
|
|
33434
|
+
return {
|
|
33435
|
+
stdout: redactCommandValues(stdout.toString(), options.redactValues),
|
|
33436
|
+
stderr: redactCommandValues(stderr.toString(), options.redactValues)
|
|
33437
|
+
};
|
|
33438
|
+
}
|
|
33439
|
+
|
|
33440
|
+
// ../protocol/src/node/workspace-change-probe.ts
|
|
32593
33441
|
var DEFAULT_MAX_UNTRACKED_FILE_BYTES = 2 * 1024 * 1024;
|
|
32594
33442
|
var DEFAULT_MAX_UNTRACKED_FILES = 5000;
|
|
32595
33443
|
var DEFAULT_SLOW_SNAPSHOT_MS = 500;
|
|
@@ -32607,27 +33455,16 @@ process.once("exit", () => {
|
|
|
32607
33455
|
} catch {}
|
|
32608
33456
|
}
|
|
32609
33457
|
});
|
|
32610
|
-
var runGit = (args, options) =>
|
|
32611
|
-
const
|
|
32612
|
-
|
|
32613
|
-
|
|
32614
|
-
|
|
32615
|
-
|
|
32616
|
-
|
|
32617
|
-
let stdout = "";
|
|
32618
|
-
let stdoutBytes = 0;
|
|
32619
|
-
child.stdout.setEncoding("utf8");
|
|
32620
|
-
child.stdout.on("data", (chunk) => {
|
|
32621
|
-
stdoutBytes += chunk.length;
|
|
32622
|
-
if (stdoutBytes <= GIT_MAX_BUFFER)
|
|
32623
|
-
stdout += chunk;
|
|
33458
|
+
var runGit = async (args, options) => {
|
|
33459
|
+
const { stdout } = await runCommand("git", args, {
|
|
33460
|
+
cwd: options.cwd,
|
|
33461
|
+
env: { ...process.env, ...options.env, GIT_OPTIONAL_LOCKS: "0" },
|
|
33462
|
+
timeoutMs: GIT_TIMEOUT_MS,
|
|
33463
|
+
maxOutputBytes: GIT_MAX_BUFFER,
|
|
33464
|
+
...options.stdin === undefined ? {} : { stdin: options.stdin }
|
|
32624
33465
|
});
|
|
32625
|
-
|
|
32626
|
-
|
|
32627
|
-
child.on("close", (code) => code === 0 ? resolvePromise({ stdout }) : reject(new Error(`git exited with ${code}`)));
|
|
32628
|
-
child.stdin.on("error", () => {});
|
|
32629
|
-
child.stdin.end(options.stdin);
|
|
32630
|
-
});
|
|
33466
|
+
return { stdout };
|
|
33467
|
+
};
|
|
32631
33468
|
|
|
32632
33469
|
class WorkspaceChangeProbe {
|
|
32633
33470
|
git;
|
|
@@ -32915,7 +33752,7 @@ class WorkspaceChangeProbe {
|
|
|
32915
33752
|
return;
|
|
32916
33753
|
const { root, indexPath } = repo.location;
|
|
32917
33754
|
const started = this.now();
|
|
32918
|
-
const tempIndex = join4(this.tempDir, `orkestrator-probe-${
|
|
33755
|
+
const tempIndex = join4(this.tempDir, `orkestrator-probe-${randomUUID2()}.index`);
|
|
32919
33756
|
const objectDirectory = await mkdtemp2(join4(this.tempDir, "orkestrator-probe-objects-"));
|
|
32920
33757
|
temporaryObjectDirectories.add(objectDirectory);
|
|
32921
33758
|
let retained = false;
|
|
@@ -33483,8 +34320,8 @@ function workspaceObservationReportIssues(value) {
|
|
|
33483
34320
|
}
|
|
33484
34321
|
|
|
33485
34322
|
// ../protocol/src/node/change-tracking/evidence-spool.ts
|
|
33486
|
-
import { createHash as createHash4, randomUUID as
|
|
33487
|
-
import { readdirSync, readFileSync } from "node:fs";
|
|
34323
|
+
import { createHash as createHash4, randomUUID as randomUUID3 } from "node:crypto";
|
|
34324
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
33488
34325
|
import { appendFile as appendFile2, mkdir as mkdir3, rename as rename3, rm as rm3, writeFile as writeFile3 } from "node:fs/promises";
|
|
33489
34326
|
import { join as join5 } from "node:path";
|
|
33490
34327
|
var DEFAULT_EVIDENCE_SPOOL_LIMITS = {
|
|
@@ -33529,7 +34366,7 @@ class ChangeEvidenceSpool {
|
|
|
33529
34366
|
restoring = false;
|
|
33530
34367
|
constructor(options = {}) {
|
|
33531
34368
|
this.limits = { ...DEFAULT_EVIDENCE_SPOOL_LIMITS, ...options.limits };
|
|
33532
|
-
this.runtimeEpoch = options.runtimeEpoch ??
|
|
34369
|
+
this.runtimeEpoch = options.runtimeEpoch ?? randomUUID3();
|
|
33533
34370
|
this.directory = options.directory;
|
|
33534
34371
|
if (this.directory) {
|
|
33535
34372
|
this.restoring = true;
|
|
@@ -33632,7 +34469,7 @@ class ChangeEvidenceSpool {
|
|
|
33632
34469
|
return;
|
|
33633
34470
|
if (this.entries.length >= this.limits.maxEntries - 1)
|
|
33634
34471
|
return;
|
|
33635
|
-
const gapId =
|
|
34472
|
+
const gapId = randomUUID3();
|
|
33636
34473
|
const coverage = this.droppedUnknown ? {
|
|
33637
34474
|
kind: "unknown-range",
|
|
33638
34475
|
bindingId: this.gapBindingId || "unknown",
|
|
@@ -33794,8 +34631,8 @@ class ChangeEvidenceSpool {
|
|
|
33794
34631
|
restore(directory) {
|
|
33795
34632
|
const bodyDirectory = join5(directory, BODY_DIRECTORY);
|
|
33796
34633
|
try {
|
|
33797
|
-
for (const name of
|
|
33798
|
-
const bytes = new Uint8Array(
|
|
34634
|
+
for (const name of readdirSync2(bodyDirectory)) {
|
|
34635
|
+
const bytes = new Uint8Array(readFileSync2(join5(bodyDirectory, name)));
|
|
33799
34636
|
const id = evidenceBodyId(bytes);
|
|
33800
34637
|
if (bodyFileName(id) !== name)
|
|
33801
34638
|
continue;
|
|
@@ -33807,7 +34644,7 @@ class ChangeEvidenceSpool {
|
|
|
33807
34644
|
} catch {}
|
|
33808
34645
|
let text = "";
|
|
33809
34646
|
try {
|
|
33810
|
-
text =
|
|
34647
|
+
text = readFileSync2(join5(directory, ENTRIES_FILE), "utf8");
|
|
33811
34648
|
} catch {
|
|
33812
34649
|
return;
|
|
33813
34650
|
}
|
|
@@ -34532,7 +35369,7 @@ function rememberSessionList(directory, stamp, entries) {
|
|
|
34532
35369
|
}
|
|
34533
35370
|
|
|
34534
35371
|
// ../../bridges/pi-bridge/src/agent-session.ts
|
|
34535
|
-
var
|
|
35372
|
+
var log4 = createLogger("bridge.pi");
|
|
34536
35373
|
var closingSessions = new WeakSet;
|
|
34537
35374
|
|
|
34538
35375
|
class SessionClosingError extends Error {
|
|
@@ -35066,12 +35903,12 @@ function sessionManagerFor(state) {
|
|
|
35066
35903
|
state.resumeFallbackFile = undefined;
|
|
35067
35904
|
if (!hasHistory && state.resumeFallbackFile !== state.sessionFile && (state.messages.length > 0 || state.promptSequence > 0)) {
|
|
35068
35905
|
state.resumeFallbackFile = state.sessionFile;
|
|
35069
|
-
|
|
35906
|
+
log4.warn("session.resume-fell-back", { sessionId: state.id });
|
|
35070
35907
|
appendResumeFallbackNotice(state);
|
|
35071
35908
|
}
|
|
35072
35909
|
return manager;
|
|
35073
35910
|
} catch (error) {
|
|
35074
|
-
|
|
35911
|
+
log4.warn("session.resume-fell-back", {
|
|
35075
35912
|
sessionId: state.id,
|
|
35076
35913
|
error: formatLogError(error, { message: false })
|
|
35077
35914
|
});
|
|
@@ -35201,7 +36038,7 @@ async function listResumableSessions() {
|
|
|
35201
36038
|
read.abort();
|
|
35202
36039
|
if (error instanceof TimeoutError)
|
|
35203
36040
|
throw error;
|
|
35204
|
-
|
|
36041
|
+
log4.warn("session-list.failed", { error: formatLogError(error, { message: false }) });
|
|
35205
36042
|
return [];
|
|
35206
36043
|
}
|
|
35207
36044
|
}
|
|
@@ -35587,11 +36424,11 @@ function pushMessage(state, role, content, parts, createdAt, messageId = randomB
|
|
|
35587
36424
|
import { createHash as createHash6 } from "node:crypto";
|
|
35588
36425
|
|
|
35589
36426
|
// ../protocol/src/event-loop-stall-monitor.ts
|
|
35590
|
-
var
|
|
36427
|
+
var log5 = createLogger("event-loop");
|
|
35591
36428
|
var EVENT_LOOP_STALL_ALWAYS_LOG_MS = 1e4;
|
|
35592
36429
|
|
|
35593
36430
|
// ../protocol/src/node/bridge-diagnostics.ts
|
|
35594
|
-
var
|
|
36431
|
+
var log6 = createLogger("bridge.diagnostics");
|
|
35595
36432
|
var BRIDGE_DIAGNOSTICS_INTERVAL_MS = 60000;
|
|
35596
36433
|
var INTERVAL_MS = BRIDGE_DIAGNOSTICS_INTERVAL_MS;
|
|
35597
36434
|
var STALL_NO_DELTA_MS = 2 * INTERVAL_MS;
|
|
@@ -35756,16 +36593,16 @@ function safeDiagnosticMetrics(value) {
|
|
|
35756
36593
|
return result;
|
|
35757
36594
|
}
|
|
35758
36595
|
function bridgeDiagnosticsChangesEnabled() {
|
|
35759
|
-
return
|
|
36596
|
+
return log6.isEnabled("trace");
|
|
35760
36597
|
}
|
|
35761
36598
|
function writeBridgeDiagnostic({ bridge, event, payload }) {
|
|
35762
36599
|
return tryWriteLog("info", "bridge.diagnostics", event, { bridge, payload });
|
|
35763
36600
|
}
|
|
35764
36601
|
function bridgeDiagnosticsActive() {
|
|
35765
|
-
return
|
|
36602
|
+
return log6.isEnabled("info");
|
|
35766
36603
|
}
|
|
35767
36604
|
function bridgeDiagnosticsStreamEnabled(bridge) {
|
|
35768
|
-
return bridgeDebugEnabled(bridge) ||
|
|
36605
|
+
return bridgeDebugEnabled(bridge) || log6.isEnabled("debug");
|
|
35769
36606
|
}
|
|
35770
36607
|
function writeDiagnostic(bridge, event, payload, write) {
|
|
35771
36608
|
try {
|
|
@@ -36261,7 +37098,7 @@ var STRUCTURED_OUTPUT_FAILURE_CODES = new Set([
|
|
|
36261
37098
|
]);
|
|
36262
37099
|
|
|
36263
37100
|
// ../../bridges/pi-bridge/src/prompt.ts
|
|
36264
|
-
var
|
|
37101
|
+
var log7 = createLogger("bridge.pi");
|
|
36265
37102
|
var STRUCTURED_PROMPT_INSTRUCTION_PREFIX = "End your turn with exactly one JSON value";
|
|
36266
37103
|
function structuredPromptInstruction(schema) {
|
|
36267
37104
|
return `${STRUCTURED_PROMPT_INSTRUCTION_PREFIX} matching this JSON Schema. That final message must be the JSON value alone, with no Markdown fence and no commentary around it.
|
|
@@ -36472,7 +37309,7 @@ async function withinStartupDeadline(accepted, deadlineMs) {
|
|
|
36472
37309
|
}
|
|
36473
37310
|
}
|
|
36474
37311
|
function abandonStartup(state, session, claim, accepted, settled, input, diagnostics, error, evidenceTurnId) {
|
|
36475
|
-
|
|
37312
|
+
log7.warn("turn.startup-timed-out", { sessionId: state.id });
|
|
36476
37313
|
state.status = "error";
|
|
36477
37314
|
state.error = error.message;
|
|
36478
37315
|
state.revision += 1;
|
|
@@ -36629,7 +37466,7 @@ function recordInterruptedOutput(state, input, message) {
|
|
|
36629
37466
|
}
|
|
36630
37467
|
function failTurn(state, session, error, input, abortedBeforeCleanup = state.turnAborted === true) {
|
|
36631
37468
|
if (!abortedBeforeCleanup && state.turnCancelRequested !== true) {
|
|
36632
|
-
|
|
37469
|
+
log7.warn("turn.failed", {
|
|
36633
37470
|
sessionId: state.id,
|
|
36634
37471
|
error: formatLogError(error, { message: false })
|
|
36635
37472
|
});
|
|
@@ -37373,6 +38210,7 @@ function effectiveLogLevel(detail, area) {
|
|
|
37373
38210
|
return detail.level;
|
|
37374
38211
|
}
|
|
37375
38212
|
}
|
|
38213
|
+
var LOG_DETAIL_EXPIRY_MS = 24 * 60 * 60 * 1000;
|
|
37376
38214
|
function logDetailEnablesBridgeDiagnostics(detail) {
|
|
37377
38215
|
return LEVEL_DETAIL[effectiveLogLevel(detail, BRIDGE_DIAGNOSTICS_LOG_AREA)] >= LEVEL_DETAIL.debug;
|
|
37378
38216
|
}
|
|
@@ -38487,7 +39325,7 @@ async function answerSessionActivityBatch(body, read, options = {}) {
|
|
|
38487
39325
|
}
|
|
38488
39326
|
|
|
38489
39327
|
// ../../bridges/pi-bridge/src/http.ts
|
|
38490
|
-
var
|
|
39328
|
+
var log8 = createLogger("bridge.pi");
|
|
38491
39329
|
|
|
38492
39330
|
class HttpError extends Error {
|
|
38493
39331
|
status;
|
|
@@ -38560,7 +39398,7 @@ async function route(request, response, clientSignal) {
|
|
|
38560
39398
|
if (error instanceof HttpError)
|
|
38561
39399
|
return json(response, error.status, { error: error.message });
|
|
38562
39400
|
if (error instanceof PolicyWideningRefusedError) {
|
|
38563
|
-
|
|
39401
|
+
log8.warn("session.policy-widening-refused", { widened: error.widened.join(",") });
|
|
38564
39402
|
return json(response, 403, error.refusal());
|
|
38565
39403
|
}
|
|
38566
39404
|
if (error instanceof SessionBusyError)
|
|
@@ -38577,7 +39415,7 @@ async function route(request, response, clientSignal) {
|
|
|
38577
39415
|
if (error instanceof PromptAttachmentError) {
|
|
38578
39416
|
return json(response, 400, { error: error.message });
|
|
38579
39417
|
}
|
|
38580
|
-
|
|
39418
|
+
log8.error("http.route-failed");
|
|
38581
39419
|
return json(response, 500, { error: "Internal bridge error" });
|
|
38582
39420
|
}
|
|
38583
39421
|
}
|
|
@@ -39344,7 +40182,7 @@ async function handleAdmittedPrompt(request, response, state, clientSignal, admi
|
|
|
39344
40182
|
});
|
|
39345
40183
|
}
|
|
39346
40184
|
if (error instanceof PromptRefusedError && !cancelRequestedFor(state, claim)) {
|
|
39347
|
-
|
|
40185
|
+
log8.warn("turn.refused", {
|
|
39348
40186
|
sessionId: state.id,
|
|
39349
40187
|
error: formatLogError(error, { message: false })
|
|
39350
40188
|
});
|
|
@@ -39604,7 +40442,7 @@ function startParentWatchdog(options) {
|
|
|
39604
40442
|
}
|
|
39605
40443
|
|
|
39606
40444
|
// ../protocol/src/bridge-lifecycle.ts
|
|
39607
|
-
var
|
|
40445
|
+
var log9 = createLogger("bridge.lifecycle");
|
|
39608
40446
|
var TERMINATION_SIGNALS = ["SIGTERM", "SIGINT"];
|
|
39609
40447
|
function errorKind(error) {
|
|
39610
40448
|
if (error instanceof Error)
|
|
@@ -39658,7 +40496,7 @@ class BridgeLifecycle {
|
|
|
39658
40496
|
}
|
|
39659
40497
|
requestExit() {
|
|
39660
40498
|
this.#exit ??= this.shutdown().then(() => this.#options.exit(0), (error) => {
|
|
39661
|
-
|
|
40499
|
+
log9.error("shutdown.failed", {
|
|
39662
40500
|
bridge: this.#options.label,
|
|
39663
40501
|
errorClass: errorKind(error)
|
|
39664
40502
|
});
|
|
@@ -39675,7 +40513,7 @@ class BridgeLifecycle {
|
|
|
39675
40513
|
try {
|
|
39676
40514
|
idleSweep.run();
|
|
39677
40515
|
} catch (error) {
|
|
39678
|
-
|
|
40516
|
+
log9.warn("idle-sweep.failed", {
|
|
39679
40517
|
bridge: this.#options.label,
|
|
39680
40518
|
errorClass: errorKind(error)
|
|
39681
40519
|
});
|
|
@@ -39946,9 +40784,9 @@ function installFatalRejectionGuard(options) {
|
|
|
39946
40784
|
}
|
|
39947
40785
|
|
|
39948
40786
|
// ../protocol/src/node/process-failure-log.ts
|
|
39949
|
-
var
|
|
40787
|
+
var log10 = createLogger("process");
|
|
39950
40788
|
function logUnhandledRejection(reason) {
|
|
39951
|
-
|
|
40789
|
+
log10.throttled("error", "rejection.unhandled", {
|
|
39952
40790
|
error: reason,
|
|
39953
40791
|
fields: () => ({ error: formatLogError(reason, { message: false }) })
|
|
39954
40792
|
});
|