@agentsmarket/pipeline-runtime 0.4.0 → 0.5.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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/model-resolver.d.ts +14 -0
- package/dist/shell-stage.d.ts +82 -0
- package/dist/shell-stage.js +169 -0
- package/dist/stages.d.ts +9 -0
- package/dist/stages.js +52 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export { isToolSkill, invokeToolSkill, type ToolSkillContext, type ToolSkillResu
|
|
|
41
41
|
export { validateOutputSpec, DEFAULT_OUTPUT_FORMAT, DEFAULT_OUTPUT_DELIVERY, DEFAULT_OUTPUT_EXPIRES_IN, MIN_OUTPUT_EXPIRES_IN, MAX_OUTPUT_EXPIRES_IN, type PipelineOutputSpec, type PipelineOutputDelivery, type PipelineOutputFormat, type PipelineOutputSpecError, } from './output-spec.js';
|
|
42
42
|
export { analyzeCapabilities, type PipelineCapabilities, type NetworkCapability, type PipelineSpecLikeForCaps, type PipelineStageLikeForCaps, } from './capabilities.js';
|
|
43
43
|
export { extractProducedFiles, globToRegex, MAX_FILE_BYTES, MAX_TOTAL_BYTES, MAX_FILES, type ProducedFile, type ExtractResult, } from './file-output.js';
|
|
44
|
+
export { normalizeShellStage, ThrowingShellExecutor, NodeShellExecutor, ShellStageUnsupportedError, ShellStageExecError, ShellStageTimeoutError, SHELL_DEFAULT_TIMEOUT_MS, SHELL_MAX_TIMEOUT_MS, SHELL_MAX_OUTPUT_BYTES, type ShellStageSpec, type ShellExecutor, type ShellExecOptions, type ShellExecResult, } from './shell-stage.js';
|
|
44
45
|
export interface PipelineStageSpec {
|
|
45
46
|
id: string;
|
|
46
47
|
model: string;
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,7 @@ export { isToolSkill, invokeToolSkill, } from './tools/tool-skills.js';
|
|
|
28
28
|
export { validateOutputSpec, DEFAULT_OUTPUT_FORMAT, DEFAULT_OUTPUT_DELIVERY, DEFAULT_OUTPUT_EXPIRES_IN, MIN_OUTPUT_EXPIRES_IN, MAX_OUTPUT_EXPIRES_IN, } from './output-spec.js';
|
|
29
29
|
export { analyzeCapabilities, } from './capabilities.js';
|
|
30
30
|
export { extractProducedFiles, globToRegex, MAX_FILE_BYTES, MAX_TOTAL_BYTES, MAX_FILES, } from './file-output.js';
|
|
31
|
+
export { normalizeShellStage, ThrowingShellExecutor, NodeShellExecutor, ShellStageUnsupportedError, ShellStageExecError, ShellStageTimeoutError, SHELL_DEFAULT_TIMEOUT_MS, SHELL_MAX_TIMEOUT_MS, SHELL_MAX_OUTPUT_BYTES, } from './shell-stage.js';
|
|
31
32
|
export async function runStage(stage, ctx) {
|
|
32
33
|
const vars = [];
|
|
33
34
|
for (const [key, val] of Object.entries(ctx.outputs)) {
|
package/dist/model-resolver.d.ts
CHANGED
|
@@ -59,6 +59,20 @@ export interface PipelineStageLike {
|
|
|
59
59
|
* file helpers in stage context.
|
|
60
60
|
*/
|
|
61
61
|
working_dir?: string;
|
|
62
|
+
/**
|
|
63
|
+
* P4 NEW — shell stage. Either a command string (`"npm test"`) or an
|
|
64
|
+
* object `{ cmd, args?, cwd?, timeout_ms? }`. Executed only when the
|
|
65
|
+
* pipeline runs through `pipeline call --local`; server-side invokes
|
|
66
|
+
* throw `ShellStageUnsupportedError` with HTTP 400 SHELL_UNSUPPORTED_ON_SERVER.
|
|
67
|
+
*
|
|
68
|
+
* Mutually exclusive with `uses` / `model`+`prompt`.
|
|
69
|
+
*/
|
|
70
|
+
shell?: string | {
|
|
71
|
+
cmd: string;
|
|
72
|
+
args?: string[];
|
|
73
|
+
cwd?: string;
|
|
74
|
+
timeout_ms?: number;
|
|
75
|
+
};
|
|
62
76
|
/**
|
|
63
77
|
* Provider name (e.g. "minimax", "openrouter"). v0.3 NEW (optional in
|
|
64
78
|
* v0.3 transition; required once pickProvider auto-dispatch is removed).
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P4 — Shell stages (CLI-only).
|
|
3
|
+
*
|
|
4
|
+
* A `shell` stage lets a pipeline run a local command as part of its DAG.
|
|
5
|
+
* Useful for: running tests, linting, formatting, refactoring tools that
|
|
6
|
+
* live on the local machine.
|
|
7
|
+
*
|
|
8
|
+
* **Server-side is REJECTED.** Cloudflare Workers cannot spawn child
|
|
9
|
+
* processes. A pipeline with shell stages works only via `pipeline call
|
|
10
|
+
* --local`. The server explicitly throws `ShellStageUnsupportedError` so
|
|
11
|
+
* the user gets a clear 400 instead of a confusing 500.
|
|
12
|
+
*
|
|
13
|
+
* **Execution model:**
|
|
14
|
+
* - `spawn(cmd, args, { shell: false })` — no shell interpretation, args
|
|
15
|
+
* are passed verbatim to the OS as argv. Prevents shell injection.
|
|
16
|
+
* - `timeout` option sends SIGTERM after `timeout_ms`; the executor
|
|
17
|
+
* maps that to `ShellStageTimeoutError`.
|
|
18
|
+
* - Non-zero exit code → `ShellStageExecError` with stderr in message.
|
|
19
|
+
*
|
|
20
|
+
* **Why dynamic import of `node:child_process`:** the runtime package is
|
|
21
|
+
* also loaded by Cloudflare Workers (which have no Node bindings). Importing
|
|
22
|
+
* `child_process` at module top-level would crash Workers startup. The
|
|
23
|
+
* `NodeShellExecutor` lazily imports it inside `.exec()` so Workers
|
|
24
|
+
* never touch the binding (the server uses a throwing stub).
|
|
25
|
+
*
|
|
26
|
+
* Stage schema (two forms):
|
|
27
|
+
* shell: "npm test" # shorthand: auto-split
|
|
28
|
+
* shell: # explicit form
|
|
29
|
+
* cmd: "npm"
|
|
30
|
+
* args: ["test"]
|
|
31
|
+
* cwd: "./my-project"
|
|
32
|
+
* timeout_ms: 60000
|
|
33
|
+
*/
|
|
34
|
+
export interface ShellStageSpec {
|
|
35
|
+
cmd: string;
|
|
36
|
+
args?: string[];
|
|
37
|
+
cwd?: string;
|
|
38
|
+
timeout_ms?: number;
|
|
39
|
+
}
|
|
40
|
+
export declare const SHELL_DEFAULT_TIMEOUT_MS = 30000;
|
|
41
|
+
export declare const SHELL_MAX_OUTPUT_BYTES: number;
|
|
42
|
+
export declare const SHELL_MAX_TIMEOUT_MS = 600000;
|
|
43
|
+
export declare function normalizeShellStage(raw: unknown): ShellStageSpec | null;
|
|
44
|
+
export interface ShellExecOptions {
|
|
45
|
+
cwd: string;
|
|
46
|
+
timeoutMs: number;
|
|
47
|
+
}
|
|
48
|
+
export interface ShellExecResult {
|
|
49
|
+
stdout: string;
|
|
50
|
+
stderr: string;
|
|
51
|
+
exitCode: number;
|
|
52
|
+
durationMs: number;
|
|
53
|
+
cmd: string;
|
|
54
|
+
args: string[];
|
|
55
|
+
}
|
|
56
|
+
export interface ShellExecutor {
|
|
57
|
+
exec(spec: ShellStageSpec, opts: ShellExecOptions): Promise<ShellExecResult>;
|
|
58
|
+
}
|
|
59
|
+
export declare class ShellStageUnsupportedError extends Error {
|
|
60
|
+
readonly stageId: string;
|
|
61
|
+
readonly reason: string;
|
|
62
|
+
constructor(stageId: string, reason: string);
|
|
63
|
+
}
|
|
64
|
+
export declare class ShellStageExecError extends Error {
|
|
65
|
+
readonly stageId: string;
|
|
66
|
+
readonly exitCode: number;
|
|
67
|
+
readonly stderrSnippet: string;
|
|
68
|
+
constructor(stageId: string, exitCode: number, stderrSnippet: string);
|
|
69
|
+
}
|
|
70
|
+
export declare class ShellStageTimeoutError extends Error {
|
|
71
|
+
readonly stageId: string;
|
|
72
|
+
readonly timeoutMs: number;
|
|
73
|
+
constructor(stageId: string, timeoutMs: number);
|
|
74
|
+
}
|
|
75
|
+
export declare class ThrowingShellExecutor implements ShellExecutor {
|
|
76
|
+
private readonly reason;
|
|
77
|
+
constructor(reason: string);
|
|
78
|
+
exec(): Promise<ShellExecResult>;
|
|
79
|
+
}
|
|
80
|
+
export declare class NodeShellExecutor implements ShellExecutor {
|
|
81
|
+
exec(spec: ShellStageSpec, opts: ShellExecOptions): Promise<ShellExecResult>;
|
|
82
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P4 — Shell stages (CLI-only).
|
|
3
|
+
*
|
|
4
|
+
* A `shell` stage lets a pipeline run a local command as part of its DAG.
|
|
5
|
+
* Useful for: running tests, linting, formatting, refactoring tools that
|
|
6
|
+
* live on the local machine.
|
|
7
|
+
*
|
|
8
|
+
* **Server-side is REJECTED.** Cloudflare Workers cannot spawn child
|
|
9
|
+
* processes. A pipeline with shell stages works only via `pipeline call
|
|
10
|
+
* --local`. The server explicitly throws `ShellStageUnsupportedError` so
|
|
11
|
+
* the user gets a clear 400 instead of a confusing 500.
|
|
12
|
+
*
|
|
13
|
+
* **Execution model:**
|
|
14
|
+
* - `spawn(cmd, args, { shell: false })` — no shell interpretation, args
|
|
15
|
+
* are passed verbatim to the OS as argv. Prevents shell injection.
|
|
16
|
+
* - `timeout` option sends SIGTERM after `timeout_ms`; the executor
|
|
17
|
+
* maps that to `ShellStageTimeoutError`.
|
|
18
|
+
* - Non-zero exit code → `ShellStageExecError` with stderr in message.
|
|
19
|
+
*
|
|
20
|
+
* **Why dynamic import of `node:child_process`:** the runtime package is
|
|
21
|
+
* also loaded by Cloudflare Workers (which have no Node bindings). Importing
|
|
22
|
+
* `child_process` at module top-level would crash Workers startup. The
|
|
23
|
+
* `NodeShellExecutor` lazily imports it inside `.exec()` so Workers
|
|
24
|
+
* never touch the binding (the server uses a throwing stub).
|
|
25
|
+
*
|
|
26
|
+
* Stage schema (two forms):
|
|
27
|
+
* shell: "npm test" # shorthand: auto-split
|
|
28
|
+
* shell: # explicit form
|
|
29
|
+
* cmd: "npm"
|
|
30
|
+
* args: ["test"]
|
|
31
|
+
* cwd: "./my-project"
|
|
32
|
+
* timeout_ms: 60000
|
|
33
|
+
*/
|
|
34
|
+
export const SHELL_DEFAULT_TIMEOUT_MS = 30_000;
|
|
35
|
+
export const SHELL_MAX_OUTPUT_BYTES = 1024 * 1024;
|
|
36
|
+
export const SHELL_MAX_TIMEOUT_MS = 600_000;
|
|
37
|
+
export function normalizeShellStage(raw) {
|
|
38
|
+
if (typeof raw === 'string') {
|
|
39
|
+
const trimmed = raw.trim();
|
|
40
|
+
if (trimmed.length === 0)
|
|
41
|
+
return null;
|
|
42
|
+
const parts = trimmed.split(/\s+/);
|
|
43
|
+
return { cmd: parts[0], args: parts.slice(1) };
|
|
44
|
+
}
|
|
45
|
+
if (!raw || typeof raw !== 'object')
|
|
46
|
+
return null;
|
|
47
|
+
const obj = raw;
|
|
48
|
+
if (typeof obj.cmd !== 'string' || obj.cmd.trim().length === 0)
|
|
49
|
+
return null;
|
|
50
|
+
const spec = { cmd: obj.cmd.trim() };
|
|
51
|
+
if (Array.isArray(obj.args)) {
|
|
52
|
+
const args = obj.args.filter((a) => typeof a === 'string');
|
|
53
|
+
if (args.length > 0)
|
|
54
|
+
spec.args = args;
|
|
55
|
+
}
|
|
56
|
+
if (typeof obj.cwd === 'string' && obj.cwd.length > 0)
|
|
57
|
+
spec.cwd = obj.cwd;
|
|
58
|
+
if (typeof obj.timeout_ms === 'number' && Number.isFinite(obj.timeout_ms) && obj.timeout_ms > 0) {
|
|
59
|
+
spec.timeout_ms = Math.min(obj.timeout_ms, SHELL_MAX_TIMEOUT_MS);
|
|
60
|
+
}
|
|
61
|
+
return spec;
|
|
62
|
+
}
|
|
63
|
+
export class ShellStageUnsupportedError extends Error {
|
|
64
|
+
stageId;
|
|
65
|
+
reason;
|
|
66
|
+
constructor(stageId, reason) {
|
|
67
|
+
super(`Stage '${stageId}' uses a shell command but ${reason}`);
|
|
68
|
+
this.stageId = stageId;
|
|
69
|
+
this.reason = reason;
|
|
70
|
+
this.name = 'SHELL_STAGE_UNSUPPORTED';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export class ShellStageExecError extends Error {
|
|
74
|
+
stageId;
|
|
75
|
+
exitCode;
|
|
76
|
+
stderrSnippet;
|
|
77
|
+
constructor(stageId, exitCode, stderrSnippet) {
|
|
78
|
+
super(`Shell stage '${stageId}' exited with code ${exitCode}: ${stderrSnippet.slice(0, 500)}`);
|
|
79
|
+
this.stageId = stageId;
|
|
80
|
+
this.exitCode = exitCode;
|
|
81
|
+
this.stderrSnippet = stderrSnippet;
|
|
82
|
+
this.name = 'SHELL_STAGE_EXEC_FAILED';
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export class ShellStageTimeoutError extends Error {
|
|
86
|
+
stageId;
|
|
87
|
+
timeoutMs;
|
|
88
|
+
constructor(stageId, timeoutMs) {
|
|
89
|
+
super(`Shell stage '${stageId}' exceeded timeout of ${timeoutMs}ms`);
|
|
90
|
+
this.stageId = stageId;
|
|
91
|
+
this.timeoutMs = timeoutMs;
|
|
92
|
+
this.name = 'SHELL_STAGE_TIMEOUT';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export class ThrowingShellExecutor {
|
|
96
|
+
reason;
|
|
97
|
+
constructor(reason) {
|
|
98
|
+
this.reason = reason;
|
|
99
|
+
}
|
|
100
|
+
async exec() {
|
|
101
|
+
throw new ShellStageUnsupportedError('<unknown>', this.reason);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export class NodeShellExecutor {
|
|
105
|
+
async exec(spec, opts) {
|
|
106
|
+
const { spawn } = await import('node:child_process');
|
|
107
|
+
const args = spec.args ?? [];
|
|
108
|
+
const t0 = Date.now();
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
const child = spawn(spec.cmd, args, {
|
|
111
|
+
cwd: opts.cwd,
|
|
112
|
+
timeout: opts.timeoutMs,
|
|
113
|
+
shell: false,
|
|
114
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
115
|
+
});
|
|
116
|
+
let stdout = '';
|
|
117
|
+
let stderr = '';
|
|
118
|
+
let stdoutTruncated = false;
|
|
119
|
+
let stderrTruncated = false;
|
|
120
|
+
const onChunk = (target) => (chunk) => {
|
|
121
|
+
const text = typeof chunk === 'string' ? chunk : chunk.toString('utf-8');
|
|
122
|
+
if (target === 'stdout') {
|
|
123
|
+
if (stdout.length + text.length > SHELL_MAX_OUTPUT_BYTES) {
|
|
124
|
+
if (!stdoutTruncated) {
|
|
125
|
+
stdout = stdout.slice(0, SHELL_MAX_OUTPUT_BYTES) + '\n[stdout truncated at 1MB]';
|
|
126
|
+
stdoutTruncated = true;
|
|
127
|
+
}
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
stdout += text;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
if (stderr.length + text.length > SHELL_MAX_OUTPUT_BYTES) {
|
|
134
|
+
if (!stderrTruncated) {
|
|
135
|
+
stderr = stderr.slice(0, SHELL_MAX_OUTPUT_BYTES) + '\n[stderr truncated at 1MB]';
|
|
136
|
+
stderrTruncated = true;
|
|
137
|
+
}
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
stderr += text;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
child.stdout.on('data', onChunk('stdout'));
|
|
144
|
+
child.stderr.on('data', onChunk('stderr'));
|
|
145
|
+
let settled = false;
|
|
146
|
+
const settle = (fn) => {
|
|
147
|
+
if (settled)
|
|
148
|
+
return;
|
|
149
|
+
settled = true;
|
|
150
|
+
fn();
|
|
151
|
+
};
|
|
152
|
+
child.on('error', (e) => {
|
|
153
|
+
settle(() => reject(e));
|
|
154
|
+
});
|
|
155
|
+
child.on('close', (code, signal) => {
|
|
156
|
+
const durationMs = Date.now() - t0;
|
|
157
|
+
if (signal === 'SIGTERM' || signal === 'SIGKILL') {
|
|
158
|
+
settle(() => reject(new ShellStageTimeoutError('<shell>', opts.timeoutMs)));
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (code === 0) {
|
|
162
|
+
settle(() => resolve({ stdout, stderr, exitCode: 0, durationMs, cmd: spec.cmd, args }));
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
settle(() => reject(new ShellStageExecError('<shell>', code ?? -1, stderr || stdout)));
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
package/dist/stages.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ import type { PricingResolver } from './pricing.js';
|
|
|
18
18
|
import { createModelResolver, type ModelResolver, type PipelineLike, type PipelineStageLike, type SkillLike } from './model-resolver.js';
|
|
19
19
|
import { type PipelineEventSink } from './streaming-events.js';
|
|
20
20
|
import { type RuntimeConstraints } from './runtime-constraints.js';
|
|
21
|
+
import { type ShellExecutor } from './shell-stage.js';
|
|
21
22
|
import { type PipelineFetcher, type CompositionConfig } from './composition.js';
|
|
22
23
|
export interface ResolvedUse {
|
|
23
24
|
id: string;
|
|
@@ -115,6 +116,14 @@ export interface StageExecutorDeps {
|
|
|
115
116
|
* from `RunPipelineOptions.eventSink` by `runPipelineV2`.
|
|
116
117
|
*/
|
|
117
118
|
eventSink?: PipelineEventSink;
|
|
119
|
+
/**
|
|
120
|
+
* P4 — shell stage executor. Server passes a `ThrowingShellExecutor`
|
|
121
|
+
* that rejects every call (server cannot spawn processes). CLI passes
|
|
122
|
+
* a `NodeShellExecutor` that uses `child_process.spawn`.
|
|
123
|
+
*
|
|
124
|
+
* When absent, stages declaring `shell:` throw `ShellStageUnsupportedError`.
|
|
125
|
+
*/
|
|
126
|
+
shellExecutor?: ShellExecutor;
|
|
118
127
|
}
|
|
119
128
|
export interface RetryContext {
|
|
120
129
|
stageId: string;
|
package/dist/stages.js
CHANGED
|
@@ -22,6 +22,7 @@ import { isRetryableStatus, computeBackoffMs, RetryExhaustedError, DEFAULT_RETRY
|
|
|
22
22
|
import { NoopEventSink, makeStartedEvent as makePipelineStartedEvent, makeCompletedEvent as makePipelineCompletedEvent, makeFailedEvent as makePipelineFailedEvent, makeStageStartedEvent, makeStageCompletedEvent, makeStageSkippedEvent, makeStageFailedEvent, makeStageRetriedEvent, } from './streaming-events.js';
|
|
23
23
|
import { validateRuntimeConstraints, collectRuntimeWarnings, defaultRuntimeConstraints, } from './runtime-constraints.js';
|
|
24
24
|
import { resolveStageOutputRefs } from './stage-output-refs.js';
|
|
25
|
+
import { normalizeShellStage, ShellStageUnsupportedError, ShellStageExecError, ShellStageTimeoutError, SHELL_DEFAULT_TIMEOUT_MS, } from './shell-stage.js';
|
|
25
26
|
import { expandComposition, } from './composition.js';
|
|
26
27
|
import { groupIndependentStages, } from './parallel.js';
|
|
27
28
|
import { randomUUID } from 'node:crypto';
|
|
@@ -315,8 +316,57 @@ export async function executeStage(stage, pipeline, ctx, deps) {
|
|
|
315
316
|
const hasModel = typeof stage.model === 'string' && stage.model.length > 0;
|
|
316
317
|
const hasPrompt = typeof stage.prompt === 'string' && stage.prompt.length > 0;
|
|
317
318
|
const hasSystem = typeof stage.system === 'string' && stage.system.length > 0;
|
|
318
|
-
|
|
319
|
-
|
|
319
|
+
const hasShell = stage.shell !== undefined && stage.shell !== null;
|
|
320
|
+
if (!hasShell && !hasUses && !hasModel && !hasPrompt) {
|
|
321
|
+
throw new StageBadConfigError(`Stage '${stage.id}' requires one of: 'shell' (shell stage, CLI --local only), 'uses' (skill stage), 'model'+'prompt' (LLM stage), or just 'prompt' with default model`);
|
|
322
|
+
}
|
|
323
|
+
if (hasShell) {
|
|
324
|
+
if (!deps.shellExecutor) {
|
|
325
|
+
throw new ShellStageUnsupportedError(stage.id, 'no shell executor is configured for this run');
|
|
326
|
+
}
|
|
327
|
+
if (!deps.isLocal) {
|
|
328
|
+
throw new ShellStageUnsupportedError(stage.id, 'shell stages require CLI invocation with --local; the server cannot spawn child processes');
|
|
329
|
+
}
|
|
330
|
+
const spec = normalizeShellStage(stage.shell);
|
|
331
|
+
if (!spec) {
|
|
332
|
+
throw new StageBadConfigError(`Stage '${stage.id}' has a malformed 'shell' spec (expected string or { cmd, args?, cwd?, timeout_ms? })`);
|
|
333
|
+
}
|
|
334
|
+
const shellT0 = Date.now();
|
|
335
|
+
try {
|
|
336
|
+
const result = await deps.shellExecutor.exec(spec, {
|
|
337
|
+
cwd: spec.cwd ?? process.cwd(),
|
|
338
|
+
timeoutMs: spec.timeout_ms ?? SHELL_DEFAULT_TIMEOUT_MS,
|
|
339
|
+
});
|
|
340
|
+
const output = JSON.stringify({
|
|
341
|
+
cmd: spec.cmd,
|
|
342
|
+
args: spec.args ?? [],
|
|
343
|
+
cwd: spec.cwd ?? null,
|
|
344
|
+
stdout: result.stdout,
|
|
345
|
+
stderr: result.stderr,
|
|
346
|
+
exit_code: result.exitCode,
|
|
347
|
+
duration_ms: result.durationMs,
|
|
348
|
+
});
|
|
349
|
+
return {
|
|
350
|
+
output,
|
|
351
|
+
costMicroUsdc: 0,
|
|
352
|
+
usage: { inputTokens: 0, outputTokens: 0 },
|
|
353
|
+
nestedCalls: [],
|
|
354
|
+
modelUsed: 'shell',
|
|
355
|
+
...(spec.cwd ? { working_dir: spec.cwd, working_dir_ignored_on_server: false } : {}),
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
catch (e) {
|
|
359
|
+
if (e instanceof ShellStageExecError) {
|
|
360
|
+
throw new StageBadConfigError(`Stage '${stage.id}' ${e.message}`);
|
|
361
|
+
}
|
|
362
|
+
if (e instanceof ShellStageTimeoutError) {
|
|
363
|
+
throw new StageBadConfigError(`Stage '${stage.id}' ${e.message}`);
|
|
364
|
+
}
|
|
365
|
+
throw e;
|
|
366
|
+
}
|
|
367
|
+
finally {
|
|
368
|
+
void shellT0;
|
|
369
|
+
}
|
|
320
370
|
}
|
|
321
371
|
if (hasUses) {
|
|
322
372
|
let chainedInput = stage.input ?? ctx.inputs;
|
package/package.json
CHANGED