@claudexor/core 4.1.0 → 4.2.0
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/capture-buffer.d.ts +26 -0
- package/dist/capture-buffer.d.ts.map +1 -0
- package/dist/capture-buffer.js +51 -0
- package/dist/capture-buffer.js.map +1 -0
- package/dist/capture-raw.d.ts +20 -0
- package/dist/capture-raw.d.ts.map +1 -0
- package/dist/capture-raw.js +161 -0
- package/dist/capture-raw.js.map +1 -0
- package/dist/env-scope.d.ts +7 -2
- package/dist/env-scope.d.ts.map +1 -1
- package/dist/env-scope.js +12 -3
- package/dist/env-scope.js.map +1 -1
- package/dist/host-facts.d.ts +18 -0
- package/dist/host-facts.d.ts.map +1 -0
- package/dist/host-facts.js +90 -0
- package/dist/host-facts.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/native/claudexor-process-identity +0 -0
- package/dist/proc.d.ts +25 -24
- package/dist/proc.d.ts.map +1 -1
- package/dist/proc.js +33 -159
- package/dist/proc.js.map +1 -1
- package/dist/process-drain.d.ts +31 -0
- package/dist/process-drain.d.ts.map +1 -0
- package/dist/process-drain.js +55 -0
- package/dist/process-drain.js.map +1 -0
- package/dist/process-identity.d.ts +25 -0
- package/dist/process-identity.d.ts.map +1 -1
- package/dist/process-identity.js +91 -8
- package/dist/process-identity.js.map +1 -1
- package/dist/process-lines.d.ts +1 -0
- package/dist/process-lines.d.ts.map +1 -1
- package/dist/process-lines.js +69 -13
- package/dist/process-lines.js.map +1 -1
- package/dist/process-output.d.ts +16 -0
- package/dist/process-output.d.ts.map +1 -0
- package/dist/process-output.js +28 -0
- package/dist/process-output.js.map +1 -0
- package/dist/process-registry.d.ts +15 -3
- package/dist/process-registry.d.ts.map +1 -1
- package/dist/process-registry.js +35 -3
- package/dist/process-registry.js.map +1 -1
- package/dist/process-scope-census.d.ts +196 -0
- package/dist/process-scope-census.d.ts.map +1 -0
- package/dist/process-scope-census.js +444 -0
- package/dist/process-scope-census.js.map +1 -0
- package/dist/process-scope-readers.d.ts +104 -0
- package/dist/process-scope-readers.d.ts.map +1 -0
- package/dist/process-scope-readers.js +429 -0
- package/dist/process-scope-readers.js.map +1 -0
- package/dist/process-scope.d.ts +21 -0
- package/dist/process-scope.d.ts.map +1 -0
- package/dist/process-scope.js +59 -0
- package/dist/process-scope.js.map +1 -0
- package/dist/process-table.d.ts +32 -0
- package/dist/process-table.d.ts.map +1 -0
- package/dist/process-table.js +122 -0
- package/dist/process-table.js.map +1 -0
- package/dist/process-tree.d.ts.map +1 -1
- package/dist/process-tree.js +6 -0
- package/dist/process-tree.js.map +1 -1
- package/dist/runloop.d.ts.map +1 -1
- package/dist/runloop.js +9 -0
- package/dist/runloop.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const CAPTURE_BUFFER_BUDGET_BYTES: number;
|
|
2
|
+
type Stream = "stdout" | "stderr";
|
|
3
|
+
export declare class CaptureOutputExceeded extends Error {
|
|
4
|
+
readonly stream: Stream;
|
|
5
|
+
readonly bufferBudgetBytes: number;
|
|
6
|
+
readonly code = "capture_output_exceeded";
|
|
7
|
+
constructor(stream: Stream, bufferBudgetBytes?: number);
|
|
8
|
+
}
|
|
9
|
+
/** Owns all exact-capture buffers; an overflow releases both streams at once. */
|
|
10
|
+
export declare class CaptureBuffers {
|
|
11
|
+
private readonly budget;
|
|
12
|
+
private chunks;
|
|
13
|
+
private bytes;
|
|
14
|
+
constructor(budget?: number);
|
|
15
|
+
get bufferedBytes(): number;
|
|
16
|
+
append(stream: Stream, chunk: Buffer): void;
|
|
17
|
+
text(stream: Stream): string;
|
|
18
|
+
clear(): void;
|
|
19
|
+
}
|
|
20
|
+
/** Exact consumers must refuse a line capture whose lifecycle owner closed a pipe. */
|
|
21
|
+
export declare function assertCaptureComplete(result: {
|
|
22
|
+
code: number | null;
|
|
23
|
+
drain?: "truncated";
|
|
24
|
+
}): void;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=capture-buffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture-buffer.d.ts","sourceRoot":"","sources":["../src/capture-buffer.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,2BAA2B,QAAoB,CAAC;AAC7D,KAAK,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElC,qBAAa,qBAAsB,SAAQ,KAAK;IAG5C,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,iBAAiB;IAH5B,QAAQ,CAAC,IAAI,6BAA6B;IAC1C,YACW,MAAM,EAAE,MAAM,EACd,iBAAiB,SAA8B,EAIzD;CACF;AAED,iFAAiF;AACjF,qBAAa,cAAc;IAGb,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,OAAO,CAAC,MAAM,CAAwD;IACtE,OAAO,CAAC,KAAK,CAAK;IAClB,YAA6B,MAAM,SAA8B,EAAI;IACrE,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAO1C;IAED,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE3B;IAED,KAAK,IAAI,IAAI,CAGZ;CACF;AAED,sFAAsF;AACtF,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,WAAW,CAAA;CAAE,GAAG,IAAI,CAOhG"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Combined exact-output buffer policy: 256 MiB, below V8's ~512 MiB string
|
|
2
|
+
// limit. Conversion and child memory are additional; this is not an RSS bound.
|
|
3
|
+
export const CAPTURE_BUFFER_BUDGET_BYTES = 256 * 1024 * 1024;
|
|
4
|
+
export class CaptureOutputExceeded extends Error {
|
|
5
|
+
stream;
|
|
6
|
+
bufferBudgetBytes;
|
|
7
|
+
code = "capture_output_exceeded";
|
|
8
|
+
constructor(stream, bufferBudgetBytes = CAPTURE_BUFFER_BUDGET_BYTES) {
|
|
9
|
+
super(`${stream} exceeded the ${bufferBudgetBytes}-byte combined capture buffer budget`);
|
|
10
|
+
this.stream = stream;
|
|
11
|
+
this.bufferBudgetBytes = bufferBudgetBytes;
|
|
12
|
+
this.name = "CaptureOutputExceeded";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** Owns all exact-capture buffers; an overflow releases both streams at once. */
|
|
16
|
+
export class CaptureBuffers {
|
|
17
|
+
budget;
|
|
18
|
+
chunks = { stdout: [], stderr: [] };
|
|
19
|
+
bytes = 0;
|
|
20
|
+
constructor(budget = CAPTURE_BUFFER_BUDGET_BYTES) {
|
|
21
|
+
this.budget = budget;
|
|
22
|
+
}
|
|
23
|
+
get bufferedBytes() {
|
|
24
|
+
return this.bytes;
|
|
25
|
+
}
|
|
26
|
+
append(stream, chunk) {
|
|
27
|
+
if (chunk.length > this.budget - this.bytes) {
|
|
28
|
+
this.clear();
|
|
29
|
+
throw new CaptureOutputExceeded(stream, this.budget);
|
|
30
|
+
}
|
|
31
|
+
this.bytes += chunk.length;
|
|
32
|
+
this.chunks[stream].push(chunk);
|
|
33
|
+
}
|
|
34
|
+
text(stream) {
|
|
35
|
+
return Buffer.concat(this.chunks[stream]).toString("utf8");
|
|
36
|
+
}
|
|
37
|
+
clear() {
|
|
38
|
+
this.chunks.stdout.length = this.chunks.stderr.length = 0;
|
|
39
|
+
this.bytes = 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Exact consumers must refuse a line capture whose lifecycle owner closed a pipe. */
|
|
43
|
+
export function assertCaptureComplete(result) {
|
|
44
|
+
if (result.drain === "truncated") {
|
|
45
|
+
throw Object.assign(new Error("Process output was not completely drained"), {
|
|
46
|
+
code: "capture_output_incomplete",
|
|
47
|
+
drain: result.drain,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=capture-buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture-buffer.js","sourceRoot":"","sources":["../src/capture-buffer.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,+EAA+E;AAC/E,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC;AAG7D,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAGnC,MAAM;IACN,iBAAiB;IAHnB,IAAI,GAAG,yBAAyB,CAAC;IAC1C,YACW,MAAc,EACd,iBAAiB,GAAG,2BAA2B;QAExD,KAAK,CAAC,GAAG,MAAM,iBAAiB,iBAAiB,sCAAsC,CAAC,CAAC;sBAHhF,MAAM;iCACN,iBAAiB;QAG1B,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED,iFAAiF;AACjF,MAAM,OAAO,cAAc;IAGI,MAAM;IAF3B,MAAM,GAA6B,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAC9D,KAAK,GAAG,CAAC,CAAC;IAClB,YAA6B,MAAM,GAAG,2BAA2B;sBAApC,MAAM;IAAiC,CAAC;IACrE,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,MAAM,CAAC,MAAc,EAAE,KAAa;QAClC,IAAI,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;YAC5C,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACvD,CAAC;QACD,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,CAAC,MAAc;QACjB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC7D,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAC1D,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;CACF;AAED,sFAAsF;AACtF,MAAM,UAAU,qBAAqB,CAAC,MAAoD;IACxF,IAAI,MAAM,CAAC,KAAK,KAAK,WAAW,EAAE,CAAC;QACjC,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,2CAA2C,CAAC,EAAE;YAC1E,IAAI,EAAE,2BAA2B;YACjC,KAAK,EAAE,MAAM,CAAC,KAAK;SACpB,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CaptureResult, SpawnOptions } from "./proc.js";
|
|
2
|
+
/** A caller-owned bounded projection, used only for non-exact previews. */
|
|
3
|
+
export interface CaptureProjection {
|
|
4
|
+
write(chunk: Buffer): void;
|
|
5
|
+
end(): string;
|
|
6
|
+
}
|
|
7
|
+
interface RawCaptureOptions extends SpawnOptions {
|
|
8
|
+
stdoutProjection?: CaptureProjection;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* BYTE-FAITHFUL capture: `runCapture` rides readline, which splits
|
|
12
|
+
* on lone `\r` too and rejoins with `\n` — destroying CR bytes in CRLF file
|
|
13
|
+
* content and fabricating trailing newlines. Diff-carrying git output MUST
|
|
14
|
+
* come through here, or `final/patch.diff` is corrupted at the source and
|
|
15
|
+
* fails `git apply` downstream. Raw buffers, no line splitting, no
|
|
16
|
+
* fabrication; the same spawn machinery (process group, abort, timeout).
|
|
17
|
+
*/
|
|
18
|
+
export declare function runCaptureRaw(cmd: string, args: string[], opts?: RawCaptureOptions): Promise<CaptureResult>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=capture-raw.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture-raw.d.ts","sourceRoot":"","sources":["../src/capture-raw.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG7D,2EAA2E;AAC3E,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,GAAG,IAAI,MAAM,CAAC;CACf;AACD,UAAU,iBAAkB,SAAQ,YAAY;IAC9C,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;CACtC;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,GAAE,iBAAsB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAmIxB"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { registerChildProcess, unregisterChildProcess } from "./process-registry.js";
|
|
3
|
+
import { composeSpawnEnv } from "./env-scope.js";
|
|
4
|
+
import { prepareHarnessCommand } from "./runtime-env.js";
|
|
5
|
+
import { runScopeMarkerOf } from "./process-scope.js";
|
|
6
|
+
import { killWindowsProcessTree, resolveKillTreeStrategy } from "./process-tree.js";
|
|
7
|
+
import { defaultProcessGroupService } from "./process-group.js";
|
|
8
|
+
import { CaptureBuffers } from "./capture-buffer.js";
|
|
9
|
+
/**
|
|
10
|
+
* BYTE-FAITHFUL capture: `runCapture` rides readline, which splits
|
|
11
|
+
* on lone `\r` too and rejoins with `\n` — destroying CR bytes in CRLF file
|
|
12
|
+
* content and fabricating trailing newlines. Diff-carrying git output MUST
|
|
13
|
+
* come through here, or `final/patch.diff` is corrupted at the source and
|
|
14
|
+
* fails `git apply` downstream. Raw buffers, no line splitting, no
|
|
15
|
+
* fabrication; the same spawn machinery (process group, abort, timeout).
|
|
16
|
+
*/
|
|
17
|
+
export async function runCaptureRaw(cmd, args, opts = {}) {
|
|
18
|
+
const invocation = prepareHarnessCommand(cmd, args, composeSpawnEnv(opts.inheritEnv, opts.env));
|
|
19
|
+
const env = invocation.env;
|
|
20
|
+
const child = spawn(invocation.binary, invocation.args, {
|
|
21
|
+
cwd: opts.cwd,
|
|
22
|
+
env,
|
|
23
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
24
|
+
windowsHide: true,
|
|
25
|
+
detached: true,
|
|
26
|
+
});
|
|
27
|
+
if (typeof child.pid === "number")
|
|
28
|
+
registerChildProcess(child.pid, cmd, runScopeMarkerOf(env));
|
|
29
|
+
child.once("exit", (code, signal) => opts.onExit?.(code, signal));
|
|
30
|
+
let captureChildClosed = false;
|
|
31
|
+
child.once("close", () => {
|
|
32
|
+
captureChildClosed = true;
|
|
33
|
+
});
|
|
34
|
+
child.once("error", () => {
|
|
35
|
+
captureChildClosed = true;
|
|
36
|
+
});
|
|
37
|
+
// Identity-proven-only group signalling for capture children too (round-4 #1
|
|
38
|
+
// residue): a raw `process.kill(-pid)` after the short-lived capture child
|
|
39
|
+
// exited could hit an unrelated recycled group. Group signals go only through
|
|
40
|
+
// the identity-verified handle captured at spawn; without a proven handle we
|
|
41
|
+
// fall back to `child.kill` — the ChildProcess OBJECT is pinned to this exact
|
|
42
|
+
// process by Node, so a direct-child signal can never target a recycled PID.
|
|
43
|
+
// On win32 no handle ever captures; the viable tree kill is taskkill, gated
|
|
44
|
+
// on the child not yet having closed (Node holds the process handle until
|
|
45
|
+
// then, so the PID cannot have been recycled).
|
|
46
|
+
const captureGroupService = opts.processGroups ?? defaultProcessGroupService;
|
|
47
|
+
let captureGroupHandle;
|
|
48
|
+
if (typeof child.pid === "number") {
|
|
49
|
+
const capture = captureGroupService.captureLeader(child.pid);
|
|
50
|
+
if (capture.status === "known")
|
|
51
|
+
captureGroupHandle = capture.handle;
|
|
52
|
+
}
|
|
53
|
+
const killTree = (signal) => {
|
|
54
|
+
if (captureGroupHandle) {
|
|
55
|
+
captureGroupService.signal(captureGroupHandle, signal);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if ((opts.killTreeStrategy ?? resolveKillTreeStrategy()) === "windows_taskkill" &&
|
|
59
|
+
typeof child.pid === "number" &&
|
|
60
|
+
!captureChildClosed) {
|
|
61
|
+
// A FAILED taskkill (typed result) must not strand the capture awaiting
|
|
62
|
+
// `close` forever (wave finding): fall through to the pinned
|
|
63
|
+
// ChildProcess kill so the direct child still dies and close fires.
|
|
64
|
+
const killed = (opts.windowsKillTree ?? killWindowsProcessTree)(child.pid);
|
|
65
|
+
if (killed.status !== "failed")
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
child.kill(signal);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
/* already gone */
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
child.stdin.on("error", () => { });
|
|
76
|
+
if (opts.input !== undefined)
|
|
77
|
+
child.stdin.write(opts.input);
|
|
78
|
+
child.stdin.end();
|
|
79
|
+
const buffers = new CaptureBuffers();
|
|
80
|
+
let captureError;
|
|
81
|
+
let captureFailed = false;
|
|
82
|
+
const failCapture = (error) => {
|
|
83
|
+
if (captureFailed)
|
|
84
|
+
return;
|
|
85
|
+
captureFailed = true;
|
|
86
|
+
captureError = error;
|
|
87
|
+
buffers.clear();
|
|
88
|
+
child.stdout.destroy();
|
|
89
|
+
child.stderr.destroy();
|
|
90
|
+
child.stdin.destroy();
|
|
91
|
+
killTree("SIGKILL");
|
|
92
|
+
};
|
|
93
|
+
const collect = (stream, chunk) => {
|
|
94
|
+
if (captureFailed)
|
|
95
|
+
return;
|
|
96
|
+
try {
|
|
97
|
+
if (stream === "stdout" && opts.stdoutProjection)
|
|
98
|
+
opts.stdoutProjection.write(chunk);
|
|
99
|
+
else
|
|
100
|
+
buffers.append(stream, chunk);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
failCapture(error);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
child.stdout.on("error", failCapture);
|
|
107
|
+
child.stderr.on("error", failCapture);
|
|
108
|
+
child.stdout.on("data", (chunk) => collect("stdout", chunk));
|
|
109
|
+
child.stderr.on("data", (chunk) => collect("stderr", chunk));
|
|
110
|
+
let killTimer;
|
|
111
|
+
const requestCancel = () => {
|
|
112
|
+
killTree(opts.cancelSignal ?? "SIGINT");
|
|
113
|
+
const killDelay = opts.cancelKillDelayMs ?? 1_000;
|
|
114
|
+
if (killDelay >= 0 && !killTimer) {
|
|
115
|
+
killTimer = setTimeout(() => killTree("SIGKILL"), killDelay);
|
|
116
|
+
killTimer.unref?.();
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
let timer;
|
|
120
|
+
if (opts.timeoutMs && opts.timeoutMs > 0) {
|
|
121
|
+
timer = setTimeout(() => killTree("SIGKILL"), opts.timeoutMs);
|
|
122
|
+
}
|
|
123
|
+
const abortSignal = opts.abortSignal;
|
|
124
|
+
if (abortSignal) {
|
|
125
|
+
if (abortSignal.aborted)
|
|
126
|
+
requestCancel();
|
|
127
|
+
else
|
|
128
|
+
abortSignal.addEventListener("abort", requestCancel, { once: true });
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
const [code, signal] = await new Promise((resolve, reject) => {
|
|
132
|
+
child.on("error", (err) => {
|
|
133
|
+
if (typeof child.pid === "number")
|
|
134
|
+
unregisterChildProcess(child.pid);
|
|
135
|
+
reject(err);
|
|
136
|
+
});
|
|
137
|
+
child.on("close", (c, s) => {
|
|
138
|
+
if (typeof child.pid === "number")
|
|
139
|
+
unregisterChildProcess(child.pid);
|
|
140
|
+
resolve([c, s]);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
if (captureFailed)
|
|
144
|
+
throw captureError;
|
|
145
|
+
return {
|
|
146
|
+
code,
|
|
147
|
+
signal,
|
|
148
|
+
stdout: opts.stdoutProjection?.end() ?? buffers.text("stdout"),
|
|
149
|
+
stderr: buffers.text("stderr"),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
finally {
|
|
153
|
+
buffers.clear();
|
|
154
|
+
if (timer)
|
|
155
|
+
clearTimeout(timer);
|
|
156
|
+
if (killTimer)
|
|
157
|
+
clearTimeout(killTimer);
|
|
158
|
+
abortSignal?.removeEventListener("abort", requestCancel);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=capture-raw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capture-raw.js","sourceRoot":"","sources":["../src/capture-raw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,0BAA0B,EAA2B,MAAM,oBAAoB,CAAC;AAEzF,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAWrD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,GAAW,EACX,IAAc,EACd,IAAI,GAAsB,EAAE;IAE5B,MAAM,UAAU,GAAG,qBAAqB,CAAC,GAAG,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI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I,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ;oBAAE,sBAAsB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACrE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;QACL,CAAC,CACF,CAAC;QACF,IAAI,aAAa;YAAE,MAAM,YAAY,CAAC;QACtC,OAAO;YACL,IAAI;YACJ,MAAM;YACN,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE,GAAG,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;YAC9D,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;SAC/B,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,IAAI,KAAK;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAC/B,IAAI,SAAS;YAAE,YAAY,CAAC,SAAS,CAAC,CAAC;QACvC,WAAW,EAAE,mBAAmB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC"}
|
package/dist/env-scope.d.ts
CHANGED
|
@@ -49,8 +49,13 @@ export declare function pickAllowlistedEnv(source: NodeJS.ProcessEnv, keys: read
|
|
|
49
49
|
/**
|
|
50
50
|
* Build the base child env for a given inheritance mode. `mirror_native` copies
|
|
51
51
|
* the parent env (the native CLIs' default); `clean` copies only the minimal
|
|
52
|
-
* allowlist (agent isolation)
|
|
53
|
-
*
|
|
52
|
+
* allowlist (agent isolation) PLUS every inherited scope marker: custody is not
|
|
53
|
+
* a secret and not a preference — an enclosing custodian (the host that started
|
|
54
|
+
* this daemon) must be able to end what it owns however the child env is
|
|
55
|
+
* composed, so names matching the shared marker grammar (`process-scope.ts`)
|
|
56
|
+
* with value `1` are forwarded in both modes. The adapter's `spec.env`
|
|
57
|
+
* overrides + the providerScrubEnv patch are applied ON TOP of this by the
|
|
58
|
+
* spawn layer.
|
|
54
59
|
*/
|
|
55
60
|
export declare function composeBaseEnv(inheritance: "mirror_native" | "clean", source?: NodeJS.ProcessEnv, execPath?: string, platform?: NodeJS.Platform): NodeJS.ProcessEnv;
|
|
56
61
|
/** Apply the run patch once, after baseline PATH/OS identity preparation. */
|
package/dist/env-scope.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-scope.d.ts","sourceRoot":"","sources":["../src/env-scope.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"env-scope.d.ts","sourceRoot":"","sources":["../src/env-scope.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EA4DhD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,SAAS,MAAM,EAAO,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAOnF;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAE,SAAS,MAAM,EAoChD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAarD,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,CAAC,UAAU,EACzB,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,MAAM,CAAC,UAAU,CAWnB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,eAAe,GAAG,OAAO,EACtC,MAAM,GAAE,MAAM,CAAC,UAAwB,EACvC,QAAQ,GAAE,MAAyB,EACnC,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAC3C,MAAM,CAAC,UAAU,CAOnB;AAED,6EAA6E;AAC7E,wBAAgB,eAAe,CAC7B,WAAW,GAAE,eAAe,GAAG,OAAyB,EACxD,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAM,GACpD,MAAM,CAAC,UAAU,CAWnB"}
|
package/dist/env-scope.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { harnessRuntimeEnv } from "./runtime-env.js";
|
|
2
|
+
import { inheritedScopeMarkers } from "./process-scope.js";
|
|
2
3
|
/**
|
|
3
4
|
* Declarative env-scrub SSOT for harness children.
|
|
4
5
|
*
|
|
@@ -178,14 +179,22 @@ export function pickAllowlistedEnv(source, keys, platform = process.platform) {
|
|
|
178
179
|
/**
|
|
179
180
|
* Build the base child env for a given inheritance mode. `mirror_native` copies
|
|
180
181
|
* the parent env (the native CLIs' default); `clean` copies only the minimal
|
|
181
|
-
* allowlist (agent isolation)
|
|
182
|
-
*
|
|
182
|
+
* allowlist (agent isolation) PLUS every inherited scope marker: custody is not
|
|
183
|
+
* a secret and not a preference — an enclosing custodian (the host that started
|
|
184
|
+
* this daemon) must be able to end what it owns however the child env is
|
|
185
|
+
* composed, so names matching the shared marker grammar (`process-scope.ts`)
|
|
186
|
+
* with value `1` are forwarded in both modes. The adapter's `spec.env`
|
|
187
|
+
* overrides + the providerScrubEnv patch are applied ON TOP of this by the
|
|
188
|
+
* spawn layer.
|
|
183
189
|
*/
|
|
184
190
|
export function composeBaseEnv(inheritance, source = process.env, execPath = process.execPath, platform = process.platform) {
|
|
185
191
|
const normalizedSource = harnessRuntimeEnv(source, execPath, platform);
|
|
186
192
|
if (inheritance !== "clean")
|
|
187
193
|
return normalizedSource;
|
|
188
|
-
return
|
|
194
|
+
return {
|
|
195
|
+
...pickAllowlistedEnv(normalizedSource, CLEAN_ENV_ALLOWLIST, platform),
|
|
196
|
+
...inheritedScopeMarkers(normalizedSource),
|
|
197
|
+
};
|
|
189
198
|
}
|
|
190
199
|
/** Apply the run patch once, after baseline PATH/OS identity preparation. */
|
|
191
200
|
export function composeSpawnEnv(inheritance = "mirror_native", patch = {}) {
|
package/dist/env-scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-scope.js","sourceRoot":"","sources":["../src/env-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"env-scope.js","sourceRoot":"","sources":["../src/env-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAsB;IACpD,iBAAiB;IACjB,gBAAgB;IAChB,YAAY;IACZ,eAAe;IACf,gBAAgB;IAChB,mBAAmB;IACnB,iBAAiB;IACjB,eAAe;IACf,oBAAoB;IACpB,yBAAyB;IACzB,qBAAqB;IACrB,mBAAmB;IACnB,sBAAsB;IACtB,oBAAoB;IACpB,gBAAgB;IAChB,yBAAyB;IACzB,yBAAyB;IACzB,wBAAwB;IACxB,yBAAyB;IACzB,4BAA4B;IAC5B,6BAA6B;IAC7B,2BAA2B;IAC3B,8BAA8B;IAC9B,4BAA4B;IAC5B,4BAA4B;IAC5B,6BAA6B;IAC7B,2DAA2D;IAC3D,mBAAmB;IACnB,uBAAuB;IACvB,mBAAmB;IACnB,aAAa;IACb,gCAAgC;IAChC,mEAAmE;IACnE,iBAAiB;IACjB,qBAAqB;IACrB,iBAAiB;IACjB,uBAAuB;IACvB,4BAA4B;IAC5B,sBAAsB;IACtB,yBAAyB;IACzB,kBAAkB;IAClB,qDAAqD;IACrD,gBAAgB;IAChB,gBAAgB;IAChB,aAAa;IACb,oBAAoB;IACpB,qBAAqB;IACrB,gBAAgB;IAChB,0BAA0B;IAC1B,gBAAgB;IAChB,kBAAkB;IAClB,oCAAoC;IACpC,sBAAsB;IACtB,2BAA2B;IAC3B,uEAAuE;IACvE,cAAc;IACd,iBAAiB;IACjB,kB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K,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;YAC9B,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;gBACxC,IAAI,QAAQ,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,WAAW,EAAE;oBAAE,OAAO,GAAG,CAAC,QAAQ,CAAC,CAAC;YACzE,CAAC;QACH,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;;YACtD,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACxB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const HOME_SCOPED_ENV = "CLAUDEXOR_HOME_SCOPED";
|
|
2
|
+
export declare const OPERATOR_HOME_ENV = "CLAUDEXOR_OPERATOR_HOME";
|
|
3
|
+
export declare const PLAYWRIGHT_BROWSERS_PATH_ENV = "PLAYWRIGHT_BROWSERS_PATH";
|
|
4
|
+
export interface HostFactsOptions {
|
|
5
|
+
/** The unscoped operator env (the daemon's own); default `process.env`. */
|
|
6
|
+
source?: NodeJS.ProcessEnv;
|
|
7
|
+
platform?: NodeJS.Platform;
|
|
8
|
+
/** One stat per call; injectable for deterministic tests. */
|
|
9
|
+
directoryExists?: (path: string) => boolean;
|
|
10
|
+
}
|
|
11
|
+
/** The operator's Playwright browser cache location for this platform (one path, no walk). */
|
|
12
|
+
export declare function playwrightCacheDir(source: NodeJS.ProcessEnv, platform: NodeJS.Platform): string | null;
|
|
13
|
+
/**
|
|
14
|
+
* The env patch to ADD on top of a harness spec env. `specEnv` is the patch
|
|
15
|
+
* the run already decided (its scoped HOME, if any); it is never rewritten.
|
|
16
|
+
*/
|
|
17
|
+
export declare function harnessHostFactsEnv(specEnv: Record<string, string | null | undefined> | undefined, options?: HostFactsOptions): Record<string, string>;
|
|
18
|
+
//# sourceMappingURL=host-facts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-facts.d.ts","sourceRoot":"","sources":["../src/host-facts.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,eAAe,0BAA0B,CAAC;AACvD,eAAO,MAAM,iBAAiB,4BAA4B,CAAC;AAC3D,eAAO,MAAM,4BAA4B,6BAA6B,CAAC;AAEvE,MAAM,WAAW,gBAAgB;IAC/B,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC3B,6DAA6D;IAC7D,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CAC7C;AAeD,8FAA8F;AAC9F,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,CAAC,UAAU,EACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ,GACxB,MAAM,GAAG,IAAI,CAaf;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,SAAS,EAC9D,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2BxB"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host facts told to a harness that runs under a scoped native-state HOME.
|
|
3
|
+
*
|
|
4
|
+
* A scoped HOME selects native state and credentials; it also makes the
|
|
5
|
+
* operator's own caches look absent, which sent models searching the whole
|
|
6
|
+
* home directory for a Playwright browser (the #449 incidents). Two
|
|
7
|
+
* environment facts say what is true instead: the HOME is scoped, and where
|
|
8
|
+
* the operator's home is. The Playwright browser cache is pointed at directly
|
|
9
|
+
* when the operator already has one.
|
|
10
|
+
*
|
|
11
|
+
* Captured from the daemon's UNSCOPED env (`source`, default `process.env`)
|
|
12
|
+
* before HOME/XDG/APPDATA are rebased by the spec env: the operator home is
|
|
13
|
+
* the daemon's home, never the scoped one. Precedence for
|
|
14
|
+
* `PLAYWRIGHT_BROWSERS_PATH`: an explicit value in the operator env (including
|
|
15
|
+
* the special `0`) always wins and is carried so it survives `clean`
|
|
16
|
+
* inheritance; otherwise the operator's cache directory is exported only if
|
|
17
|
+
* ONE stat says it exists; otherwise nothing. A directory stat establishes a
|
|
18
|
+
* location, not an installed compatible browser.
|
|
19
|
+
*/
|
|
20
|
+
import { statSync } from "node:fs";
|
|
21
|
+
import { posix, win32 } from "node:path";
|
|
22
|
+
export const HOME_SCOPED_ENV = "CLAUDEXOR_HOME_SCOPED";
|
|
23
|
+
export const OPERATOR_HOME_ENV = "CLAUDEXOR_OPERATOR_HOME";
|
|
24
|
+
export const PLAYWRIGHT_BROWSERS_PATH_ENV = "PLAYWRIGHT_BROWSERS_PATH";
|
|
25
|
+
function directoryExistsSync(path) {
|
|
26
|
+
try {
|
|
27
|
+
return statSync(path).isDirectory();
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function operatorHome(source, platform) {
|
|
34
|
+
const home = platform === "win32" ? source["USERPROFILE"] || source["HOME"] : source["HOME"];
|
|
35
|
+
return home && home.trim() ? home : null;
|
|
36
|
+
}
|
|
37
|
+
/** The operator's Playwright browser cache location for this platform (one path, no walk). */
|
|
38
|
+
export function playwrightCacheDir(source, platform) {
|
|
39
|
+
const home = operatorHome(source, platform);
|
|
40
|
+
// Joined with the TARGET platform's separator: the location is handed to a
|
|
41
|
+
// child on that platform, and the facts are computed where the daemon runs.
|
|
42
|
+
const join = platform === "win32" ? win32.join : posix.join;
|
|
43
|
+
if (platform === "win32") {
|
|
44
|
+
const local = source["LOCALAPPDATA"];
|
|
45
|
+
return local && local.trim() ? join(local, "ms-playwright") : null;
|
|
46
|
+
}
|
|
47
|
+
if (platform === "darwin")
|
|
48
|
+
return home ? join(home, "Library", "Caches", "ms-playwright") : null;
|
|
49
|
+
const xdg = source["XDG_CACHE_HOME"];
|
|
50
|
+
if (xdg && xdg.trim())
|
|
51
|
+
return join(xdg, "ms-playwright");
|
|
52
|
+
return home ? join(home, ".cache", "ms-playwright") : null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The env patch to ADD on top of a harness spec env. `specEnv` is the patch
|
|
56
|
+
* the run already decided (its scoped HOME, if any); it is never rewritten.
|
|
57
|
+
*/
|
|
58
|
+
export function harnessHostFactsEnv(specEnv, options = {}) {
|
|
59
|
+
const source = options.source ?? process.env;
|
|
60
|
+
const platform = options.platform ?? process.platform;
|
|
61
|
+
const exists = options.directoryExists ?? directoryExistsSync;
|
|
62
|
+
const out = {};
|
|
63
|
+
const home = operatorHome(source, platform);
|
|
64
|
+
const scopedHome = specEnv?.["HOME"];
|
|
65
|
+
// These facts are only true for a session running under a scoped native-state
|
|
66
|
+
// HOME. An in-place run that inherits the operator's own HOME needs none of
|
|
67
|
+
// them (its caches are already in reach), so say nothing.
|
|
68
|
+
if (!scopedHome || !home || scopedHome === home)
|
|
69
|
+
return out;
|
|
70
|
+
out[HOME_SCOPED_ENV] = "1";
|
|
71
|
+
out[OPERATOR_HOME_ENV] = home;
|
|
72
|
+
// An explicit value already in the spec patch (an embedder or reviewer
|
|
73
|
+
// asking for per-package browsers with `0`, or its own cache) wins over
|
|
74
|
+
// everything: the key is left to the patch as it stands.
|
|
75
|
+
if (specEnv?.[PLAYWRIGHT_BROWSERS_PATH_ENV] !== undefined)
|
|
76
|
+
return out;
|
|
77
|
+
const explicit = source[PLAYWRIGHT_BROWSERS_PATH_ENV];
|
|
78
|
+
if (explicit !== undefined) {
|
|
79
|
+
// An explicit operator value (including `0` = per-package browsers) wins
|
|
80
|
+
// over the automatic cache and is carried so a `clean` child env keeps it.
|
|
81
|
+
out[PLAYWRIGHT_BROWSERS_PATH_ENV] = explicit;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const cache = playwrightCacheDir(source, platform);
|
|
85
|
+
if (cache && exists(cache))
|
|
86
|
+
out[PLAYWRIGHT_BROWSERS_PATH_ENV] = cache;
|
|
87
|
+
}
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=host-facts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-facts.js","sourceRoot":"","sources":["../src/host-facts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,CAAC,MAAM,eAAe,GAAG,uBAAuB,CAAC;AACvD,MAAM,CAAC,MAAM,iBAAiB,GAAG,yBAAyB,CAAC;AAC3D,MAAM,CAAC,MAAM,4BAA4B,GAAG,0BAA0B,CAAC;AAUvE,SAAS,mBAAmB,CAAC,IAAY;IACvC,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,MAAyB,EAAE,QAAyB;IACxE,MAAM,IAAI,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7F,OAAO,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3C,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,kBAAkB,CAChC,MAAyB,EACzB,QAAy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EAAE,CAAC;IACvC,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;IACrC,8EAA8E;IAC9E,4EAA4E;IAC5E,0DAA0D;IAC1D,IAAI,CAAC,UAAU,IAAI,CAAC,IAAI,IAAI,UAAU,KAAK,IAAI;QAAE,OAAO,GAAG,CAAC;IAC5D,GAAG,CAAC,eAAe,CAAC,GAAG,GAAG,CAAC;IAC3B,GAAG,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC;IAC9B,uEAAuE;IACvE,wEAAwE;IACxE,yDAAyD;IACzD,IAAI,OAAO,EAAE,CAAC,4BAA4B,CAAC,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC;IACtE,MAAM,QAAQ,GAAG,MAAM,CAAC,4BAA4B,CAAC,CAAC;IACtD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,yEAAyE;QACzE,2EAA2E;QAC3E,GAAG,CAAC,4BAA4B,CAAC,GAAG,QAAQ,CAAC;IAC/C,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,GAAG,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QACnD,IAAI,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC;YAAE,GAAG,CAAC,4BAA4B,CAAC,GAAG,KAAK,CAAC;IACxE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,11 @@ export * from "./answer-assembly.js";
|
|
|
18
18
|
export * from "./auth-readiness.js";
|
|
19
19
|
export * from "./auth-capability-verifier.js";
|
|
20
20
|
export * from "./env-scope.js";
|
|
21
|
+
export * from "./process-scope.js";
|
|
22
|
+
export * from "./process-scope-census.js";
|
|
23
|
+
export * from "./process-scope-readers.js";
|
|
24
|
+
export * from "./process-table.js";
|
|
25
|
+
export * from "./host-facts.js";
|
|
21
26
|
export * from "./runtime-env.js";
|
|
22
27
|
export * from "./npm-launch.js";
|
|
23
28
|
export * from "./executable-inspection.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,11 @@ export * from "./answer-assembly.js";
|
|
|
18
18
|
export * from "./auth-readiness.js";
|
|
19
19
|
export * from "./auth-capability-verifier.js";
|
|
20
20
|
export * from "./env-scope.js";
|
|
21
|
+
export * from "./process-scope.js";
|
|
22
|
+
export * from "./process-scope-census.js";
|
|
23
|
+
export * from "./process-scope-readers.js";
|
|
24
|
+
export * from "./process-table.js";
|
|
25
|
+
export * from "./host-facts.js";
|
|
21
26
|
export * from "./runtime-env.js";
|
|
22
27
|
export * from "./npm-launch.js";
|
|
23
28
|
export * from "./executable-inspection.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC"}
|
|
Binary file
|
package/dist/proc.d.ts
CHANGED
|
@@ -28,6 +28,18 @@ export interface SpawnOptions {
|
|
|
28
28
|
* Defaults to `cancelKillDelayMs + 4000`.
|
|
29
29
|
*/
|
|
30
30
|
cancelDeadlineMs?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Bounded post-exit output drain (ms, `process-drain.ts`): once no output has
|
|
33
|
+
* arrived for this long AFTER the direct child exited (a descendant kept the
|
|
34
|
+
* pipe open), the parent-side streams are force-closed so capture completes
|
|
35
|
+
* (exit event `drain: "truncated"`). 0 disables (wait for a real `close`). Default 2000.
|
|
36
|
+
*/
|
|
37
|
+
exitDrainMs?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Absolute bound (ms) on the post-exit drain that ongoing descendant writes
|
|
40
|
+
* cannot renew. Default `max(10 * exitDrainMs, 30000)`.
|
|
41
|
+
*/
|
|
42
|
+
exitDrainMaxMs?: number;
|
|
31
43
|
/**
|
|
32
44
|
* Fail-closed disclosure (QA-027) for a consumer that broke the stream EARLY
|
|
33
45
|
* (it is no longer iterating, so the typed `termination_unconfirmed` event
|
|
@@ -91,10 +103,17 @@ export type ProcEvent = {
|
|
|
91
103
|
} | {
|
|
92
104
|
type: "stderr";
|
|
93
105
|
line: string;
|
|
94
|
-
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* `drain: "truncated"`: the direct child exited but a descendant kept its
|
|
109
|
+
* stdout/stderr open, and the bounded post-exit drain force-closed them so the
|
|
110
|
+
* run reaches its terminal barrier. The output captured up to then is complete.
|
|
111
|
+
*/
|
|
112
|
+
| {
|
|
95
113
|
type: "exit";
|
|
96
114
|
code: number | null;
|
|
97
115
|
signal: NodeJS.Signals | null;
|
|
116
|
+
drain?: "truncated";
|
|
98
117
|
}
|
|
99
118
|
/**
|
|
100
119
|
* QA-027 fail-closed death-proof disclosure: the process was cancelled and the
|
|
@@ -123,31 +142,13 @@ export interface CaptureResult {
|
|
|
123
142
|
signal: NodeJS.Signals | null;
|
|
124
143
|
stdout: string;
|
|
125
144
|
stderr: string;
|
|
145
|
+
/** The exit event's forced post-exit drain (`runCapture` only): later output was not read. */
|
|
146
|
+
drain?: "truncated";
|
|
126
147
|
}
|
|
127
|
-
|
|
128
|
-
* Label which stream said what in a compact one-line detail (truncated probe
|
|
129
|
-
* errors must stay attributable to stderr vs stdout). Null when both are empty.
|
|
130
|
-
*
|
|
131
|
-
* `transform` (e.g. a secret redactor) runs on each FULL stream BEFORE
|
|
132
|
-
* truncation — truncating first could split a token and leave a partial
|
|
133
|
-
* secret the redactor no longer recognizes. Each present stream then gets an
|
|
134
|
-
* equal code-point budget (never splitting a surrogate pair), so one noisy
|
|
135
|
-
* stream cannot evict the other from the detail.
|
|
136
|
-
*/
|
|
137
|
-
export declare function labelStreams(stderr: string, stdout: string, opts?: {
|
|
138
|
-
maxLen?: number;
|
|
139
|
-
transform?: (s: string) => string;
|
|
140
|
-
}): string | null;
|
|
148
|
+
export { labelStreams } from "./process-output.js";
|
|
141
149
|
/** Run a process to completion, capturing stdout/stderr. Throws on spawn error. */
|
|
142
150
|
export declare function runCapture(cmd: string, args: string[], opts?: SpawnOptions): Promise<CaptureResult>;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
* on lone `\r` too and rejoins with `\n` — destroying CR bytes in CRLF file
|
|
146
|
-
* content and fabricating trailing newlines. Diff-carrying git output MUST
|
|
147
|
-
* come through here, or `final/patch.diff` is corrupted at the source and
|
|
148
|
-
* fails `git apply` downstream. Raw buffers, no line splitting, no
|
|
149
|
-
* fabrication; the same spawn machinery (process group, abort, timeout).
|
|
150
|
-
*/
|
|
151
|
-
export declare function runCaptureRaw(cmd: string, args: string[], opts?: SpawnOptions): Promise<CaptureResult>;
|
|
151
|
+
export { runCaptureRaw, type CaptureProjection } from "./capture-raw.js";
|
|
152
|
+
export { CaptureOutputExceeded, CAPTURE_BUFFER_BUDGET_BYTES, assertCaptureComplete, } from "./capture-buffer.js";
|
|
152
153
|
export { armOrphanExit } from "./process-lifeline.js";
|
|
153
154
|
//# sourceMappingURL=proc.d.ts.map
|
package/dist/proc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proc.d.ts","sourceRoot":"","sources":["../src/proc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"proc.d.ts","sourceRoot":"","sources":["../src/proc.ts"],"names":[],"mappings":"AAEA,OAAO,EAA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