@gobing-ai/ts-runtime 0.4.18 → 0.4.20
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.
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import type { ProcessExecutionSource, ProcessRegistry } from './process-registry';
|
|
2
2
|
import type { RuntimePaths } from './runtime-paths';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Controls how stdout/stderr is captured: buffered in memory, streamed to the
|
|
5
|
+
* caller's terminal, or piped without TTY inherit.
|
|
6
|
+
*
|
|
7
|
+
* - `{ mode: 'buffered' }` — end-buffered capture (`all: true`). `onOutput`
|
|
8
|
+
* may observe, but the model is a completed result.
|
|
9
|
+
* - `{ mode: 'stream', isTTY? }` — inherit the terminal AND pipe, so chunks
|
|
10
|
+
* render live. Requires a TTY (defaults to the parent's stdout TTY status).
|
|
11
|
+
* - `{ mode: 'pipe' }` — pipe stdout/stderr to the caller with **no TTY
|
|
12
|
+
* inherit** and stdin ignored. `onOutput` fires as chunks arrive (mid-run),
|
|
13
|
+
* distinct from both TTY stream-inherit and end-buffered `all: true`.
|
|
14
|
+
* This is the non-interactive live-output policy for pipeline agent runs
|
|
15
|
+
* (ADR-047): no interactive prompt, no terminal capture, live data events.
|
|
16
|
+
*/
|
|
4
17
|
export type OutputPolicy = {
|
|
5
18
|
mode: 'buffered';
|
|
6
19
|
} | {
|
|
7
20
|
mode: 'stream';
|
|
8
21
|
isTTY?: boolean;
|
|
22
|
+
} | {
|
|
23
|
+
mode: 'pipe';
|
|
9
24
|
};
|
|
10
25
|
/** Shared configuration for a process executor (default timeout, output buffering, output policy). */
|
|
11
26
|
export interface ProcessExecutorConfig {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-executor.d.ts","sourceRoot":"","sources":["../src/process-executor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC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qBAAqB;IAC9B,KAAK,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW;CAWlD"}
|
package/dist/process-executor.js
CHANGED
|
@@ -357,14 +357,18 @@ export class BunPipeProcessSpawner {
|
|
|
357
357
|
}
|
|
358
358
|
// ── Helpers ───────────────────────────────────────────────────────────────
|
|
359
359
|
function buildExecaOptions(opts) {
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
(opts.outputPolicy.isTTY ?? process.stdout.isTTY ?? isatty(1));
|
|
360
|
+
const mode = opts.forceBuffered ? 'buffered' : (opts.outputPolicy?.mode ?? 'buffered');
|
|
361
|
+
const streamToTerminal = mode === 'stream' &&
|
|
362
|
+
(opts.outputPolicy?.mode === 'stream' ? (opts.outputPolicy.isTTY ?? process.stdout.isTTY ?? isatty(1)) : false);
|
|
363
363
|
return {
|
|
364
364
|
reject: opts.rejectOnError,
|
|
365
365
|
stdin: 'ignore',
|
|
366
366
|
stripFinalNewline: true,
|
|
367
|
-
...(
|
|
367
|
+
...(mode === 'pipe'
|
|
368
|
+
? { stdout: 'pipe', stderr: 'pipe' }
|
|
369
|
+
: streamToTerminal
|
|
370
|
+
? { stdout: ['inherit', 'pipe'], stderr: ['inherit', 'pipe'] }
|
|
371
|
+
: { all: true }),
|
|
368
372
|
...(opts.cwd !== undefined ? { cwd: opts.cwd } : {}),
|
|
369
373
|
...(opts.env !== undefined ? { env: opts.env } : {}),
|
|
370
374
|
...(opts.timeout !== undefined ? { timeout: opts.timeout } : {}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gobing-ai/ts-runtime",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.20",
|
|
4
4
|
"description": "@gobing-ai/ts-runtime — Runtime abstractions for Bun, Node, and Cloudflare Workers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -58,17 +58,17 @@
|
|
|
58
58
|
"release": "echo 'Manual publish is disabled. Releases go through GitHub Actions via Trusted Publishing — push a tag: git tag @gobing-ai/ts-runtime-v<version> && git push --tags' && exit 1"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@gobing-ai/ts-utils": "^0.4.
|
|
61
|
+
"@gobing-ai/ts-utils": "^0.4.20",
|
|
62
62
|
"execa": "^9.5.0",
|
|
63
63
|
"yaml": "^2.7.0",
|
|
64
64
|
"zod": "^4.1.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@gobing-ai/ts-db": "^0.4.
|
|
67
|
+
"@gobing-ai/ts-db": "^0.4.20",
|
|
68
68
|
"@types/bun": "1.3.14"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@gobing-ai/ts-db": "^0.4.
|
|
71
|
+
"@gobing-ai/ts-db": "^0.4.20"
|
|
72
72
|
},
|
|
73
73
|
"peerDependenciesMeta": {
|
|
74
74
|
"@gobing-ai/ts-db": {
|
package/src/process-executor.ts
CHANGED
|
@@ -5,8 +5,21 @@ import type { RuntimePaths } from './runtime-paths';
|
|
|
5
5
|
|
|
6
6
|
// ── Types ────────────────────────────────────────────────────────────────
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Controls how stdout/stderr is captured: buffered in memory, streamed to the
|
|
10
|
+
* caller's terminal, or piped without TTY inherit.
|
|
11
|
+
*
|
|
12
|
+
* - `{ mode: 'buffered' }` — end-buffered capture (`all: true`). `onOutput`
|
|
13
|
+
* may observe, but the model is a completed result.
|
|
14
|
+
* - `{ mode: 'stream', isTTY? }` — inherit the terminal AND pipe, so chunks
|
|
15
|
+
* render live. Requires a TTY (defaults to the parent's stdout TTY status).
|
|
16
|
+
* - `{ mode: 'pipe' }` — pipe stdout/stderr to the caller with **no TTY
|
|
17
|
+
* inherit** and stdin ignored. `onOutput` fires as chunks arrive (mid-run),
|
|
18
|
+
* distinct from both TTY stream-inherit and end-buffered `all: true`.
|
|
19
|
+
* This is the non-interactive live-output policy for pipeline agent runs
|
|
20
|
+
* (ADR-047): no interactive prompt, no terminal capture, live data events.
|
|
21
|
+
*/
|
|
22
|
+
export type OutputPolicy = { mode: 'buffered' } | { mode: 'stream'; isTTY?: boolean } | { mode: 'pipe' };
|
|
10
23
|
|
|
11
24
|
/** Shared configuration for a process executor (default timeout, output buffering, output policy). */
|
|
12
25
|
export interface ProcessExecutorConfig {
|
|
@@ -621,16 +634,20 @@ function buildExecaOptions(opts: {
|
|
|
621
634
|
forceBuffered: boolean;
|
|
622
635
|
signal?: AbortSignal;
|
|
623
636
|
}): ExecaOptions {
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
(opts.outputPolicy.isTTY ?? process.stdout.isTTY ?? isatty(1));
|
|
637
|
+
const mode = opts.forceBuffered ? 'buffered' : (opts.outputPolicy?.mode ?? 'buffered');
|
|
638
|
+
const streamToTerminal =
|
|
639
|
+
mode === 'stream' &&
|
|
640
|
+
(opts.outputPolicy?.mode === 'stream' ? (opts.outputPolicy.isTTY ?? process.stdout.isTTY ?? isatty(1)) : false);
|
|
628
641
|
|
|
629
642
|
return {
|
|
630
643
|
reject: opts.rejectOnError,
|
|
631
644
|
stdin: 'ignore',
|
|
632
645
|
stripFinalNewline: true,
|
|
633
|
-
...(
|
|
646
|
+
...(mode === 'pipe'
|
|
647
|
+
? { stdout: 'pipe', stderr: 'pipe' }
|
|
648
|
+
: streamToTerminal
|
|
649
|
+
? { stdout: ['inherit', 'pipe'] as const, stderr: ['inherit', 'pipe'] as const }
|
|
650
|
+
: { all: true }),
|
|
634
651
|
...(opts.cwd !== undefined ? { cwd: opts.cwd } : {}),
|
|
635
652
|
...(opts.env !== undefined ? { env: opts.env } : {}),
|
|
636
653
|
...(opts.timeout !== undefined ? { timeout: opts.timeout } : {}),
|