node-or-bun 0.0.0-stage → 0.2.1
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/CHANGELOG.md +38 -0
- package/LICENSE +21 -0
- package/README.md +118 -2
- package/dist/adapters/bun.d.ts +12 -0
- package/dist/adapters/bun.d.ts.map +1 -0
- package/dist/adapters/bun.js +263 -0
- package/dist/adapters/bun.js.map +1 -0
- package/dist/adapters/node.d.ts +11 -0
- package/dist/adapters/node.d.ts.map +1 -0
- package/dist/adapters/node.js +233 -0
- package/dist/adapters/node.js.map +1 -0
- package/dist/contract.d.ts +39 -0
- package/dist/contract.d.ts.map +1 -0
- package/dist/contract.js +4 -0
- package/dist/contract.js.map +1 -0
- package/dist/errors.d.ts +34 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +35 -0
- package/dist/errors.js.map +1 -0
- package/dist/executor.d.ts +3 -0
- package/dist/executor.d.ts.map +1 -0
- package/dist/executor.js +285 -0
- package/dist/executor.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/capture.d.ts +9 -0
- package/dist/internal/capture.d.ts.map +1 -0
- package/dist/internal/capture.js +58 -0
- package/dist/internal/capture.js.map +1 -0
- package/dist/internal/classification.d.ts +32 -0
- package/dist/internal/classification.d.ts.map +1 -0
- package/dist/internal/classification.js +64 -0
- package/dist/internal/classification.js.map +1 -0
- package/dist/internal/input.d.ts +9 -0
- package/dist/internal/input.d.ts.map +1 -0
- package/dist/internal/input.js +62 -0
- package/dist/internal/input.js.map +1 -0
- package/dist/internal/settlement.d.ts +15 -0
- package/dist/internal/settlement.d.ts.map +1 -0
- package/dist/internal/settlement.js +39 -0
- package/dist/internal/settlement.js.map +1 -0
- package/dist/internal/termination.d.ts +8 -0
- package/dist/internal/termination.d.ts.map +1 -0
- package/dist/internal/termination.js +22 -0
- package/dist/internal/termination.js.map +1 -0
- package/dist/testing/conformance.d.ts +12 -0
- package/dist/testing/conformance.d.ts.map +1 -0
- package/dist/testing/conformance.js +462 -0
- package/dist/testing/conformance.js.map +1 -0
- package/package.json +63 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.1 - 2026-10-18
|
|
4
|
+
|
|
5
|
+
- Preserve bounded, successfully decoded stdout/stderr on
|
|
6
|
+
`ProcessRuntimeError.output` so consumers can classify late observed exits
|
|
7
|
+
without losing captured content. The nullable pair is copied, frozen and
|
|
8
|
+
non-enumerable; error messages and ordinary error JSON do not include it.
|
|
9
|
+
- Keep first-cause settlement and capture/decode failure facts unchanged.
|
|
10
|
+
- See the [0.2.1 migration note](https://github.com/agent-teams-ai/process-runtime/blob/main/docs/migration-0.2.0-to-0.2.1.md).
|
|
11
|
+
|
|
12
|
+
## 0.2.0 - 2026-10-18
|
|
13
|
+
|
|
14
|
+
- Breaking: after a timeout or cancellation, late exit codes and decode
|
|
15
|
+
failures no longer settle the result; they are reported in
|
|
16
|
+
`ProcessRuntimeError.facts`. See the [migration
|
|
17
|
+
guide](https://github.com/agent-teams-ai/process-runtime/blob/main/docs/migration-0.1-to-0.2.md).
|
|
18
|
+
- Rename the package to `node-or-bun` while preserving `.`, `/node`, `/bun`,
|
|
19
|
+
and `/testing`.
|
|
20
|
+
- Apply the fixed facts-outside lifecycle and cancellation semantics to the
|
|
21
|
+
native Node.js and Bun adapters.
|
|
22
|
+
- Preserve classifier facts and bounded-output guarantees without exposing a
|
|
23
|
+
recursive runtime-error array.
|
|
24
|
+
- Rewrite synthetic cancellation conformance and document observable cleanup
|
|
25
|
+
guarantees and explicit limitations.
|
|
26
|
+
- Add the 0.1-to-0.2 migration guide.
|
|
27
|
+
- Remove the empty `dependencies` key; there are zero production dependencies.
|
|
28
|
+
No dependency on Engineering Foundation is added (repository policy); the
|
|
29
|
+
section 3.4 consumer-profile gap stays recorded in `docs/plan-scope.md`.
|
|
30
|
+
|
|
31
|
+
## 0.1.0 - 2026-10-14
|
|
32
|
+
|
|
33
|
+
- Add the neutral process contract and `createProcessExecutor`.
|
|
34
|
+
- Add explicit Node.js and Bun native adapters.
|
|
35
|
+
- Add shared conformance coverage for capture, cancellation, timeout, cleanup,
|
|
36
|
+
invalid output, and bounded stream behavior.
|
|
37
|
+
- Add typed build, package qualification, and reviewed-main GitHub OIDC release
|
|
38
|
+
workflow preparation.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Agent Teams
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,119 @@
|
|
|
1
|
-
#
|
|
1
|
+
# node-or-bun
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Runtime-agnostic process execution.
|
|
4
|
+
|
|
5
|
+
## Quickstart
|
|
6
|
+
|
|
7
|
+
There is NO autodetect: choose the runtime adapter explicitly.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
// Node.js
|
|
11
|
+
import { createProcessExecutor } from "node-or-bun";
|
|
12
|
+
import { createNodeProcessAdapter } from "node-or-bun/node";
|
|
13
|
+
|
|
14
|
+
const run = createProcessExecutor(createNodeProcessAdapter());
|
|
15
|
+
const result = await run.run({
|
|
16
|
+
command: process.execPath,
|
|
17
|
+
args: ["-e", "process.stdout.write('hello')"],
|
|
18
|
+
cwd: process.cwd(),
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
// Bun
|
|
24
|
+
import { createProcessExecutor } from "node-or-bun";
|
|
25
|
+
import { createBunProcessAdapter } from "node-or-bun/bun";
|
|
26
|
+
|
|
27
|
+
const run = createProcessExecutor(createBunProcessAdapter());
|
|
28
|
+
const result = await run.run({
|
|
29
|
+
command: process.execPath,
|
|
30
|
+
args: ["-e", "process.stdout.write('hello')"],
|
|
31
|
+
cwd: process.cwd(),
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The package keeps its 0.1.0 subpaths and adds none:
|
|
36
|
+
|
|
37
|
+
- `node-or-bun` exposes the runtime-neutral contract and executor.
|
|
38
|
+
- `node-or-bun/node` uses `node:child_process.spawn`.
|
|
39
|
+
- `node-or-bun/bun` uses `Bun.spawn`.
|
|
40
|
+
- `node-or-bun/testing` exposes the shared conformance suite.
|
|
41
|
+
|
|
42
|
+
## Observable guarantees
|
|
43
|
+
|
|
44
|
+
- **Bounded memory:** stdout and stderr are independently retained up to 4 MiB.
|
|
45
|
+
Overflow returns `output-limit`; bytes after the bound are discarded.
|
|
46
|
+
- **Cleanup before settlement:** a resolved result or rejection is produced only
|
|
47
|
+
after direct-child cleanup and capture settlement have completed or produced
|
|
48
|
+
an honest `cleanup` failure.
|
|
49
|
+
- **Unfinished capture is an error:** capture is allowed 1,000 ms to reach
|
|
50
|
+
natural EOF, then native close is requested and allowed a further 1,000 ms.
|
|
51
|
+
Forced close after the EOF deadline is a `cleanup` error with incomplete
|
|
52
|
+
custody retained.
|
|
53
|
+
- **Partial setup is held:** after synchronous spawn/retain, observation or
|
|
54
|
+
capture setup failure runs owned cleanup and capture close before `launch`
|
|
55
|
+
rejects.
|
|
56
|
+
- **Direct-child cleanup only:** default cleanup sends TERM to the direct child,
|
|
57
|
+
waits 1,000 ms, sends KILL, and waits a further 1,000 ms. It does not promise
|
|
58
|
+
cleanup of a detached `setsid` child or an arbitrary descendant tree.
|
|
59
|
+
- **Fixed facts-outside arbitration:** cleanup failure outranks all other
|
|
60
|
+
outcomes. Otherwise the first initiating timeout, cancellation,
|
|
61
|
+
capture/overflow error, or observation error wins. Otherwise normal exit
|
|
62
|
+
returns its observed `Exit`; numeric nonzero remains a result fact, while
|
|
63
|
+
strict malformed UTF-8 returns `invalid-output`.
|
|
64
|
+
|
|
65
|
+
Errors expose neutral classifier facts without a recursive error array:
|
|
66
|
+
initiating cause, whether completion was requested before exit observation,
|
|
67
|
+
the observed `Exit`, late capture/decode failure codes, bounded-output status,
|
|
68
|
+
and incomplete-custody status. Error messages do not include argv, environment,
|
|
69
|
+
or captured output. The library never logs captured output automatically.
|
|
70
|
+
|
|
71
|
+
`ProcessRuntimeError.output` retains `{ stdout, stderr }` after both bounded
|
|
72
|
+
captures settle and decode successfully. It is `null` before capture, while a
|
|
73
|
+
capture remains unsettled, or if either strict UTF-8 decode fails. Capture
|
|
74
|
+
failures can leave bounded prefixes; inspect the error code and late failure
|
|
75
|
+
facts before treating output as complete. The pair is copied and frozen, and
|
|
76
|
+
the property is non-enumerable so ordinary error JSON/spread omits it. Explicit
|
|
77
|
+
access or serialization of `error.output` still exposes captured content.
|
|
78
|
+
|
|
79
|
+
## What is not there
|
|
80
|
+
|
|
81
|
+
- No runtime autodetect and no hidden adapter selection.
|
|
82
|
+
- No stdin, PTY, event stream, supervisor, retry, command DSL, service
|
|
83
|
+
registry, Electron API, or product policy.
|
|
84
|
+
- No promise of POSIX process groups, Windows Job Objects, wrapper protocols,
|
|
85
|
+
or tree cleanup. A Foundation Host owns those containment boundaries and may
|
|
86
|
+
pair them with the native Node/Bun hooks.
|
|
87
|
+
- No promise for detached children created with `setsid`.
|
|
88
|
+
- No Execa backend. The accepted N decision keeps production dependencies
|
|
89
|
+
empty and uses the existing native Node and Bun adapters.
|
|
90
|
+
- No automatic output logging or implicit diagnostic dump.
|
|
91
|
+
|
|
92
|
+
## Development and CI evidence
|
|
93
|
+
|
|
94
|
+
The pinned tools are Node.js 26.11.1, Bun 1.4.3, and TypeScript 7.0.2. The
|
|
95
|
+
runtime contract remains Node.js `^24.18.0 || ^26.0.0` and Bun `>=1.4.3`.
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
npm install
|
|
99
|
+
npm run typecheck
|
|
100
|
+
npm run test
|
|
101
|
+
npm run pack
|
|
102
|
+
npm run qualify
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
This change-set executed typecheck, Node/Bun conformance, Node-under-Bun, pack,
|
|
106
|
+
and installed-consumer qualification locally on Linux only. The library CI
|
|
107
|
+
workflow executed the same steps on macOS, Ubuntu, and Windows runners plus a
|
|
108
|
+
Node 24.18.0 conformance run; those runs completed green on merge commit
|
|
109
|
+
`e6fbf257f4` (workflow runs `39112568940` and `39113096124`). Native Windows
|
|
110
|
+
wrapper/Job behavior and the Foundation job matrix are Foundation-side pending
|
|
111
|
+
items and are not claimed here.
|
|
112
|
+
|
|
113
|
+
See [the process contract](https://github.com/agent-teams-ai/process-runtime/blob/main/docs/process-contract.md),
|
|
114
|
+
[the 0.1-to-0.2 migration
|
|
115
|
+
guide](https://github.com/agent-teams-ai/process-runtime/blob/main/docs/migration-0.1-to-0.2.md),
|
|
116
|
+
and [the bounded scope
|
|
117
|
+
record](https://github.com/agent-teams-ai/process-runtime/blob/main/docs/plan-scope.md).
|
|
118
|
+
The `docs/` directory is not part of the published package, so these links
|
|
119
|
+
point at the repository copy.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CompletionCause, Launch, ProcessAdapter } from "../contract.js";
|
|
2
|
+
type BunChild = Bun.Subprocess<"ignore", "pipe", "pipe">;
|
|
3
|
+
export type BunRetain = (child: BunChild) => void;
|
|
4
|
+
export type BunAcquireHook = (request: Launch, retain: BunRetain) => void;
|
|
5
|
+
export type BunCleanupHook = (child: BunChild, cause: CompletionCause) => Promise<void>;
|
|
6
|
+
export type BunProcessAdapterOptions = {
|
|
7
|
+
readonly acquire?: BunAcquireHook;
|
|
8
|
+
readonly cleanup?: BunCleanupHook;
|
|
9
|
+
};
|
|
10
|
+
export declare const createBunProcessAdapter: (options?: BunProcessAdapterOptions) => ProcessAdapter;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=bun.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bun.d.ts","sourceRoot":"","sources":["../../src/adapters/bun.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAQ,MAAM,EAAE,cAAc,EAAkB,MAAM,gBAAgB,CAAC;AAWpG,KAAK,QAAQ,GAAG,GAAG,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEzD,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;AAClD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,KAAK,IAAI,CAAC;AAC1E,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAExF,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;CACnC,CAAC;AAgMF,eAAO,MAAM,uBAAuB,aACzB,wBAAwB,KAChC,cA+EF,CAAC"}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { PROCESS_CLEANUP_STEP_MS } from "../contract.js";
|
|
2
|
+
import { ProcessRuntimeError, processError } from "../errors.js";
|
|
3
|
+
import { rejectedReasons, settleOperation, settleWithin, withCause, } from "../internal/settlement.js";
|
|
4
|
+
import { cleanupDirectChild } from "../internal/termination.js";
|
|
5
|
+
const signalName = (signal) => {
|
|
6
|
+
if (signal === null)
|
|
7
|
+
return null;
|
|
8
|
+
return typeof signal === "string" ? signal : String(signal);
|
|
9
|
+
};
|
|
10
|
+
const observeExit = (child) => {
|
|
11
|
+
let terminal = false;
|
|
12
|
+
let terminalResolve;
|
|
13
|
+
const terminalProof = new Promise((resolve) => {
|
|
14
|
+
terminalResolve = resolve;
|
|
15
|
+
});
|
|
16
|
+
let settle;
|
|
17
|
+
let reject;
|
|
18
|
+
const exited = new Promise((resolve, rejectPromise) => {
|
|
19
|
+
settle = resolve;
|
|
20
|
+
reject = rejectPromise;
|
|
21
|
+
});
|
|
22
|
+
void exited.catch(() => undefined);
|
|
23
|
+
void child.exited.then(() => {
|
|
24
|
+
if (terminal)
|
|
25
|
+
return;
|
|
26
|
+
terminal = true;
|
|
27
|
+
terminalResolve();
|
|
28
|
+
settle({
|
|
29
|
+
exitCode: child.exitCode,
|
|
30
|
+
signal: signalName(child.signalCode),
|
|
31
|
+
});
|
|
32
|
+
}, (error) => {
|
|
33
|
+
// Bun documents `exited` as resolving when the process exits; a rejection
|
|
34
|
+
// is an observation error and is not accepted as terminal proof.
|
|
35
|
+
reject(processError("launch", "child process observation failed", error));
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
exited,
|
|
39
|
+
isTerminal: () => terminal,
|
|
40
|
+
waitForTerminal: (timeoutMs) => {
|
|
41
|
+
let timer;
|
|
42
|
+
const timeout = new Promise((resolve) => {
|
|
43
|
+
timer = setTimeout(() => resolve(false), timeoutMs);
|
|
44
|
+
});
|
|
45
|
+
const settled = terminalProof.then(() => true);
|
|
46
|
+
return Promise.race([settled, timeout]).finally(() => {
|
|
47
|
+
if (timer !== undefined)
|
|
48
|
+
clearTimeout(timer);
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const defaultCleanup = (child, cause, observation) => cleanupDirectChild({
|
|
54
|
+
cause,
|
|
55
|
+
isTerminal: observation.isTerminal,
|
|
56
|
+
waitForTerminal: observation.waitForTerminal,
|
|
57
|
+
terminate: (signal) => {
|
|
58
|
+
child.kill(signal);
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
const captureStream = (native) => {
|
|
62
|
+
const reader = native.getReader();
|
|
63
|
+
let closed = false;
|
|
64
|
+
let released = false;
|
|
65
|
+
let iteratorUsed = false;
|
|
66
|
+
let closePromise;
|
|
67
|
+
const release = () => {
|
|
68
|
+
if (released)
|
|
69
|
+
return;
|
|
70
|
+
reader.releaseLock();
|
|
71
|
+
released = true;
|
|
72
|
+
};
|
|
73
|
+
const close = () => {
|
|
74
|
+
closePromise ??= (async () => {
|
|
75
|
+
if (closed && released)
|
|
76
|
+
return;
|
|
77
|
+
closed = true;
|
|
78
|
+
// Cancellation must run while this reader is still attached. Release is
|
|
79
|
+
// attempted immediately and again after cancellation settles.
|
|
80
|
+
const cancellation = settleOperation(() => reader.cancel());
|
|
81
|
+
const firstRelease = settleOperation(release);
|
|
82
|
+
const cancellationSettlement = await cancellation;
|
|
83
|
+
const releases = [await firstRelease, await settleOperation(release)];
|
|
84
|
+
const failures = rejectedReasons([
|
|
85
|
+
cancellationSettlement,
|
|
86
|
+
...releases,
|
|
87
|
+
]);
|
|
88
|
+
if (failures.length === 1)
|
|
89
|
+
throw failures[0];
|
|
90
|
+
if (failures.length > 1) {
|
|
91
|
+
throw new AggregateError(failures, "native reader closure failed");
|
|
92
|
+
}
|
|
93
|
+
})();
|
|
94
|
+
return closePromise;
|
|
95
|
+
};
|
|
96
|
+
return {
|
|
97
|
+
stream: {
|
|
98
|
+
[Symbol.asyncIterator]() {
|
|
99
|
+
if (iteratorUsed) {
|
|
100
|
+
throw processError("stream", "capture stream has one consumer");
|
|
101
|
+
}
|
|
102
|
+
iteratorUsed = true;
|
|
103
|
+
return {
|
|
104
|
+
async next() {
|
|
105
|
+
if (closed)
|
|
106
|
+
return { done: true, value: undefined };
|
|
107
|
+
try {
|
|
108
|
+
const result = await reader.read();
|
|
109
|
+
if (result.done) {
|
|
110
|
+
closed = true;
|
|
111
|
+
release();
|
|
112
|
+
return { done: true, value: undefined };
|
|
113
|
+
}
|
|
114
|
+
return { done: false, value: result.value };
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
if (closed)
|
|
118
|
+
return { done: true, value: undefined };
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
async return() {
|
|
123
|
+
// Do not replace an abnormal read cause with a later close error.
|
|
124
|
+
// The executor observes this same idempotent close after cleanup.
|
|
125
|
+
void close().catch(() => undefined);
|
|
126
|
+
return { done: true, value: undefined };
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
close,
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
const createRunning = (child, observation, cleanupHook, captureOwners) => {
|
|
135
|
+
if (!(child.stdout instanceof ReadableStream) || !(child.stderr instanceof ReadableStream)) {
|
|
136
|
+
throw processError("launch", "capture stream was unavailable");
|
|
137
|
+
}
|
|
138
|
+
const stdout = captureStream(child.stdout);
|
|
139
|
+
captureOwners.push(stdout);
|
|
140
|
+
const stderr = captureStream(child.stderr);
|
|
141
|
+
captureOwners.push(stderr);
|
|
142
|
+
let cleanupPromise;
|
|
143
|
+
let closePromise;
|
|
144
|
+
return {
|
|
145
|
+
stdout: stdout.stream,
|
|
146
|
+
stderr: stderr.stream,
|
|
147
|
+
exited: observation.exited,
|
|
148
|
+
cleanup: (cause) => {
|
|
149
|
+
cleanupPromise ??= (async () => {
|
|
150
|
+
await cleanupHook(child, cause);
|
|
151
|
+
})();
|
|
152
|
+
return cleanupPromise;
|
|
153
|
+
},
|
|
154
|
+
closeCapture: () => {
|
|
155
|
+
closePromise ??= Promise.all([stdout.close(), stderr.close()]).then(() => undefined);
|
|
156
|
+
return closePromise;
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
const defaultAcquire = (request, retain) => {
|
|
161
|
+
const environment = request.environment === undefined
|
|
162
|
+
? Object.fromEntries(Object.entries(process.env).filter((entry) => entry[1] !== undefined))
|
|
163
|
+
: { ...request.environment };
|
|
164
|
+
const child = Bun.spawn([request.command, ...request.args], {
|
|
165
|
+
cwd: request.cwd,
|
|
166
|
+
env: environment,
|
|
167
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
168
|
+
});
|
|
169
|
+
retain(child);
|
|
170
|
+
};
|
|
171
|
+
export const createBunProcessAdapter = (options = {}) => {
|
|
172
|
+
const hasAcquire = options.acquire !== undefined;
|
|
173
|
+
const hasCleanup = options.cleanup !== undefined;
|
|
174
|
+
if (hasAcquire !== hasCleanup) {
|
|
175
|
+
throw processError("invalid-input", "acquire and cleanup hooks must be provided together");
|
|
176
|
+
}
|
|
177
|
+
const acquire = options.acquire ?? defaultAcquire;
|
|
178
|
+
const customCleanup = options.cleanup;
|
|
179
|
+
return {
|
|
180
|
+
launch: async (request) => {
|
|
181
|
+
let retainedChild;
|
|
182
|
+
let retainCount = 0;
|
|
183
|
+
let observation;
|
|
184
|
+
const captureOwners = [];
|
|
185
|
+
const retain = (child) => {
|
|
186
|
+
retainCount += 1;
|
|
187
|
+
if (retainCount !== 1 || !(child instanceof Object)) {
|
|
188
|
+
throw processError("invalid-input", "retain must be called exactly once with one child");
|
|
189
|
+
}
|
|
190
|
+
retainedChild = child;
|
|
191
|
+
observation = observeExit(child);
|
|
192
|
+
};
|
|
193
|
+
const rollback = async (cause) => {
|
|
194
|
+
const child = retainedChild;
|
|
195
|
+
if (child === undefined) {
|
|
196
|
+
throw processError("launch", "process setup failed", cause);
|
|
197
|
+
}
|
|
198
|
+
const observed = observation ?? observeExit(child);
|
|
199
|
+
const cleanupSettlement = await settleOperation(() => (customCleanup ?? ((target, cause) => defaultCleanup(target, cause, observed)))(child, "failed"));
|
|
200
|
+
const closeSettlement = await settleOperation(() => closeBunCaptureWithin(child, captureOwners));
|
|
201
|
+
const failures = rejectedReasons([
|
|
202
|
+
cleanupSettlement,
|
|
203
|
+
closeSettlement,
|
|
204
|
+
]);
|
|
205
|
+
if (failures.length > 0) {
|
|
206
|
+
const cleanupCause = failures.length === 1
|
|
207
|
+
? failures[0]
|
|
208
|
+
: new AggregateError(failures, "cleanup and capture closure both failed");
|
|
209
|
+
throw withCause(new ProcessRuntimeError("cleanup", "process setup cleanup failed", {
|
|
210
|
+
cause: cleanupCause,
|
|
211
|
+
initiatingError: cause,
|
|
212
|
+
incompleteCustody: true,
|
|
213
|
+
}), cleanupCause);
|
|
214
|
+
}
|
|
215
|
+
throw processError("launch", "process setup failed", cause);
|
|
216
|
+
};
|
|
217
|
+
try {
|
|
218
|
+
acquire(request, retain);
|
|
219
|
+
}
|
|
220
|
+
catch (cause) {
|
|
221
|
+
return rollback(cause);
|
|
222
|
+
}
|
|
223
|
+
if (retainedChild === undefined || observation === undefined) {
|
|
224
|
+
return rollback(new Error("acquire did not retain one child"));
|
|
225
|
+
}
|
|
226
|
+
let running;
|
|
227
|
+
try {
|
|
228
|
+
const observed = observation ?? observeExit(retainedChild);
|
|
229
|
+
running = createRunning(retainedChild, observed, customCleanup ?? ((child, cause) => defaultCleanup(child, cause, observed)), captureOwners);
|
|
230
|
+
return running;
|
|
231
|
+
}
|
|
232
|
+
catch (cause) {
|
|
233
|
+
return rollback(cause);
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
const closeBunCapture = async (child, captureOwners = []) => {
|
|
239
|
+
const operations = captureOwners.map((capture) => () => capture.close());
|
|
240
|
+
for (const stream of [child.stdout, child.stderr]) {
|
|
241
|
+
if (!(stream instanceof ReadableStream) || stream.locked)
|
|
242
|
+
continue;
|
|
243
|
+
operations.push(async () => {
|
|
244
|
+
await stream.cancel();
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
const settled = await Promise.all(operations.map((operation) => settleWithin(operation, PROCESS_CLEANUP_STEP_MS)));
|
|
248
|
+
const failures = settled.flatMap((settlement) => {
|
|
249
|
+
if (settlement.status === "rejected")
|
|
250
|
+
return [settlement.reason];
|
|
251
|
+
if (settlement.status === "timeout") {
|
|
252
|
+
return [processError("cleanup", "native capture close or reader settlement timed out")];
|
|
253
|
+
}
|
|
254
|
+
return [];
|
|
255
|
+
});
|
|
256
|
+
if (failures.length > 0) {
|
|
257
|
+
throw failures.length === 1 ? failures[0] : new AggregateError(failures, "native capture closure failed");
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const closeBunCaptureWithin = async (child, captureOwners = []) => {
|
|
261
|
+
await closeBunCapture(child, captureOwners);
|
|
262
|
+
};
|
|
263
|
+
//# sourceMappingURL=bun.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bun.js","sourceRoot":"","sources":["../../src/adapters/bun.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EACL,eAAe,EACf,eAAe,EACf,YAAY,EACZ,SAAS,GACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;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,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,uBAAuB,CAAC,CAAC,CAChF,CAAC;IACF,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,UAAU,EAAa,EAAE;QACzD,IAAI,UAAU,CAAC,MAAM,KAAK,UAAU;YAAE,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACjE,IAAI,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACpC,OAAO,CAAC,YAAY,CAAC,SAAS,EAAE,qDAAqD,CAAC,CAAC,CAAC;QAC1F,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC,CAAC;IACH,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,cAAc,CAAC,QAAQ,EAAE,+BAA+B,CAAC,CAAC;IAC5G,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,KAAK,EACjC,KAAe,EACf,aAAa,GAA6B,EAAE,EAC7B,EAAE;IACjB,MAAM,eAAe,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;AAC9C,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ChildProcess } from "node:child_process";
|
|
2
|
+
import type { CompletionCause, Launch, ProcessAdapter } from "../contract.js";
|
|
3
|
+
export type NodeRetain = (child: ChildProcess) => void;
|
|
4
|
+
export type NodeAcquireHook = (request: Launch, retain: NodeRetain) => void;
|
|
5
|
+
export type NodeCleanupHook = (child: ChildProcess, cause: CompletionCause) => Promise<void>;
|
|
6
|
+
export type NodeProcessAdapterOptions = {
|
|
7
|
+
readonly acquire?: NodeAcquireHook;
|
|
8
|
+
readonly cleanup?: NodeCleanupHook;
|
|
9
|
+
};
|
|
10
|
+
export declare const createNodeProcessAdapter: (options?: NodeProcessAdapterOptions) => ProcessAdapter;
|
|
11
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/adapters/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,KAAK,EAAE,eAAe,EAAQ,MAAM,EAAE,cAAc,EAAkB,MAAM,gBAAgB,CAAC;AAUpG,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;AACvD,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;AAC5E,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE7F,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC;CACpC,CAAC;AA0KF,eAAO,MAAM,wBAAwB,aAC1B,yBAAyB,KACjC,cA4FF,CAAC"}
|