@llm-dev-ops/agentics-cli 1.4.7 → 1.4.8
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/cli/index.js +109 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/contracts/adr-006-claude-code-synthesis-runner.d.ts +196 -0
- package/dist/contracts/adr-006-claude-code-synthesis-runner.d.ts.map +1 -0
- package/dist/contracts/adr-006-claude-code-synthesis-runner.js +177 -0
- package/dist/contracts/adr-006-claude-code-synthesis-runner.js.map +1 -0
- package/dist/contracts/adr-007-subcommand-synthesis-router.d.ts +273 -0
- package/dist/contracts/adr-007-subcommand-synthesis-router.d.ts.map +1 -0
- package/dist/contracts/adr-007-subcommand-synthesis-router.js +226 -0
- package/dist/contracts/adr-007-subcommand-synthesis-router.js.map +1 -0
- package/dist/contracts/adr-008-synthesis-artifact-persistence.d.ts +323 -0
- package/dist/contracts/adr-008-synthesis-artifact-persistence.d.ts.map +1 -0
- package/dist/contracts/adr-008-synthesis-artifact-persistence.js +184 -0
- package/dist/contracts/adr-008-synthesis-artifact-persistence.js.map +1 -0
- package/dist/mcp/mcp-server.d.ts +35 -0
- package/dist/mcp/mcp-server.d.ts.map +1 -0
- package/dist/mcp/mcp-server.js +692 -0
- package/dist/mcp/mcp-server.js.map +1 -0
- package/dist/runtime/claude-code-runner.d.ts +93 -0
- package/dist/runtime/claude-code-runner.d.ts.map +1 -0
- package/dist/runtime/claude-code-runner.js +588 -0
- package/dist/runtime/claude-code-runner.js.map +1 -0
- package/dist/runtime/index.d.ts +5 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +5 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/synthesis/artifact-writer.d.ts +62 -0
- package/dist/synthesis/artifact-writer.d.ts.map +1 -0
- package/dist/synthesis/artifact-writer.js +603 -0
- package/dist/synthesis/artifact-writer.js.map +1 -0
- package/dist/synthesis/index.d.ts +7 -0
- package/dist/synthesis/index.d.ts.map +1 -0
- package/dist/synthesis/index.js +7 -0
- package/dist/synthesis/index.js.map +1 -0
- package/dist/synthesis/prompts/index.d.ts +50 -0
- package/dist/synthesis/prompts/index.d.ts.map +1 -0
- package/dist/synthesis/prompts/index.js +502 -0
- package/dist/synthesis/prompts/index.js.map +1 -0
- package/dist/synthesis/router.d.ts +70 -0
- package/dist/synthesis/router.d.ts.map +1 -0
- package/dist/synthesis/router.js +346 -0
- package/dist/synthesis/router.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code Runner — ADR-006 Implementation
|
|
3
|
+
*
|
|
4
|
+
* Enterprise-grade subprocess invocation of the Claude Code CLI binary.
|
|
5
|
+
* Single synchronous invocation per decision-grade command.
|
|
6
|
+
* Contract-validated output against agentics-contracts response schemas.
|
|
7
|
+
*
|
|
8
|
+
* INVARIANTS:
|
|
9
|
+
* - Exactly one subprocess invocation per call to invoke()
|
|
10
|
+
* - Output is ALWAYS validated against the contract schema before return
|
|
11
|
+
* - SYNTHESIS_FORBIDDEN commands NEVER reach this module
|
|
12
|
+
* - Binary resolution is cached for the lifetime of the singleton
|
|
13
|
+
* - All errors are structured CLIError instances with correlation IDs
|
|
14
|
+
* - No user input reaches the subprocess without sanitization
|
|
15
|
+
*
|
|
16
|
+
* FORBIDDEN:
|
|
17
|
+
* - Async/streaming invocation (one call, one result)
|
|
18
|
+
* - Bypassing contract validation
|
|
19
|
+
* - Invoking for SYNTHESIS_FORBIDDEN commands
|
|
20
|
+
* - Swallowing stderr diagnostics
|
|
21
|
+
*/
|
|
22
|
+
import { execFileSync } from 'node:child_process';
|
|
23
|
+
import { existsSync } from 'node:fs';
|
|
24
|
+
import { CLIError } from '../errors/index.js';
|
|
25
|
+
import { safeValidateResponse } from '../contracts/validator.js';
|
|
26
|
+
import { SYNTHESIS_SCHEMA_MAP } from '../contracts/adr-006-claude-code-synthesis-runner.js';
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// Constants
|
|
29
|
+
// ============================================================================
|
|
30
|
+
/** Default model when neither options nor env var specifies one */
|
|
31
|
+
const DEFAULT_MODEL = 'claude-sonnet-4-20250514';
|
|
32
|
+
/** Default subprocess timeout: 2 minutes */
|
|
33
|
+
const DEFAULT_TIMEOUT_MS = 120_000;
|
|
34
|
+
/** Maximum stdout capture: 10 MiB (prevents OOM on runaway output) */
|
|
35
|
+
const MAX_BUFFER_BYTES = 10 * 1024 * 1024;
|
|
36
|
+
/** Maximum raw output stored in result (truncated beyond this) */
|
|
37
|
+
const MAX_RAW_OUTPUT_STORED = 1_024_000; // ~1 MiB
|
|
38
|
+
/** Binary candidates in resolution priority order */
|
|
39
|
+
const BINARY_CANDIDATES = ['claude', 'claude-code'];
|
|
40
|
+
/** Minimum timeout to accept (prevents accidental zero-timeout) */
|
|
41
|
+
const MIN_TIMEOUT_MS = 5_000;
|
|
42
|
+
/** Maximum timeout to accept (prevents unbounded hangs) */
|
|
43
|
+
const MAX_TIMEOUT_MS = 600_000; // 10 minutes
|
|
44
|
+
// ============================================================================
|
|
45
|
+
// Synthesis Error Class
|
|
46
|
+
// ============================================================================
|
|
47
|
+
/**
|
|
48
|
+
* Structured error for synthesis-specific failures.
|
|
49
|
+
* Carries the run-id, model, duration, and raw output preview
|
|
50
|
+
* for comprehensive diagnostics without leaking full prompt content.
|
|
51
|
+
*/
|
|
52
|
+
export class SynthesisError extends CLIError {
|
|
53
|
+
synthesisRunId;
|
|
54
|
+
synthesisModel;
|
|
55
|
+
synthesisDurationMs;
|
|
56
|
+
constructor(options) {
|
|
57
|
+
super({
|
|
58
|
+
code: options.code,
|
|
59
|
+
category: options.category,
|
|
60
|
+
message: options.message,
|
|
61
|
+
details: {
|
|
62
|
+
...options.details,
|
|
63
|
+
synthesis_run_id: options.runId,
|
|
64
|
+
synthesis_model: options.model,
|
|
65
|
+
synthesis_duration_ms: options.durationMs,
|
|
66
|
+
},
|
|
67
|
+
module: 'claude-code-runner',
|
|
68
|
+
correlationId: options.correlationId,
|
|
69
|
+
recoverable: options.recoverable,
|
|
70
|
+
exitCode: options.exitCode,
|
|
71
|
+
cause: options.cause,
|
|
72
|
+
});
|
|
73
|
+
this.name = 'SynthesisError';
|
|
74
|
+
this.synthesisRunId = options.runId;
|
|
75
|
+
this.synthesisModel = options.model;
|
|
76
|
+
this.synthesisDurationMs = options.durationMs;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// ============================================================================
|
|
80
|
+
// Binary Resolution
|
|
81
|
+
// ============================================================================
|
|
82
|
+
/**
|
|
83
|
+
* Resolve a binary on PATH using the platform-appropriate lookup command.
|
|
84
|
+
* Uses `which` on POSIX, `where` on Windows.
|
|
85
|
+
*
|
|
86
|
+
* @returns The absolute path to the binary, or null if not found.
|
|
87
|
+
*/
|
|
88
|
+
function resolveBinaryOnPath(name) {
|
|
89
|
+
const lookupCommand = process.platform === 'win32' ? 'where' : 'which';
|
|
90
|
+
try {
|
|
91
|
+
const result = execFileSync(lookupCommand, [name], {
|
|
92
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
93
|
+
timeout: 5_000,
|
|
94
|
+
encoding: 'utf-8',
|
|
95
|
+
});
|
|
96
|
+
// `which` and `where` both output the path on stdout; take first line
|
|
97
|
+
const resolved = result.trim().split(/\r?\n/)[0]?.trim();
|
|
98
|
+
return resolved && resolved.length > 0 ? resolved : null;
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Validate that a resolved binary can actually execute by running --version.
|
|
106
|
+
* This catches cases where the binary exists but is corrupted or wrong arch.
|
|
107
|
+
*
|
|
108
|
+
* @returns true if the binary responds to --version within 5s, false otherwise.
|
|
109
|
+
*/
|
|
110
|
+
function binaryIsExecutable(binaryPath) {
|
|
111
|
+
try {
|
|
112
|
+
execFileSync(binaryPath, ['--version'], {
|
|
113
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
114
|
+
timeout: 5_000,
|
|
115
|
+
encoding: 'utf-8',
|
|
116
|
+
});
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// --version may not be supported; try --help as fallback
|
|
121
|
+
try {
|
|
122
|
+
execFileSync(binaryPath, ['--help'], {
|
|
123
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
124
|
+
timeout: 5_000,
|
|
125
|
+
encoding: 'utf-8',
|
|
126
|
+
});
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// ============================================================================
|
|
135
|
+
// Output Processing
|
|
136
|
+
// ============================================================================
|
|
137
|
+
/**
|
|
138
|
+
* Strip markdown code fences from Claude Code output.
|
|
139
|
+
*
|
|
140
|
+
* Handles:
|
|
141
|
+
* - ```json\n...\n```
|
|
142
|
+
* - ```\n...\n```
|
|
143
|
+
* - Leading/trailing whitespace and \r\n line endings
|
|
144
|
+
* - Multiple code fence blocks (takes the first one)
|
|
145
|
+
* - Nested or indented fences (outer only)
|
|
146
|
+
*/
|
|
147
|
+
function stripCodeFences(raw) {
|
|
148
|
+
// Normalize line endings
|
|
149
|
+
const normalized = raw.replace(/\r\n/g, '\n').trim();
|
|
150
|
+
// Attempt 1: Full string is a single fenced block
|
|
151
|
+
const fullFencePattern = /^```(?:json|JSON)?\s*\n([\s\S]*?)\n\s*```\s*$/;
|
|
152
|
+
const fullMatch = fullFencePattern.exec(normalized);
|
|
153
|
+
if (fullMatch?.[1]) {
|
|
154
|
+
return fullMatch[1].trim();
|
|
155
|
+
}
|
|
156
|
+
// Attempt 2: Fenced block embedded in surrounding text (take first)
|
|
157
|
+
const embeddedFencePattern = /```(?:json|JSON)?\s*\n([\s\S]*?)\n\s*```/;
|
|
158
|
+
const embeddedMatch = embeddedFencePattern.exec(normalized);
|
|
159
|
+
if (embeddedMatch?.[1]) {
|
|
160
|
+
return embeddedMatch[1].trim();
|
|
161
|
+
}
|
|
162
|
+
return normalized;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Sanitize a prompt string for safe subprocess invocation.
|
|
166
|
+
*
|
|
167
|
+
* Removes or escapes characters that could cause shell injection
|
|
168
|
+
* when passed as a CLI argument to execFileSync (which does NOT
|
|
169
|
+
* use a shell, but we sanitize defensively).
|
|
170
|
+
*
|
|
171
|
+
* Strips:
|
|
172
|
+
* - Null bytes (could truncate strings in C-backed binaries)
|
|
173
|
+
* - Control characters except \n and \t (which are valid in prompts)
|
|
174
|
+
*/
|
|
175
|
+
function sanitizePrompt(prompt) {
|
|
176
|
+
// Remove null bytes
|
|
177
|
+
let sanitized = prompt.replace(/\0/g, '');
|
|
178
|
+
// Remove control characters except newline (\n=0x0A) and tab (\t=0x09)
|
|
179
|
+
// eslint-disable-next-line no-control-regex
|
|
180
|
+
sanitized = sanitized.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, '');
|
|
181
|
+
return sanitized;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Clamp a timeout value to the safe range [MIN_TIMEOUT_MS, MAX_TIMEOUT_MS].
|
|
185
|
+
*/
|
|
186
|
+
function clampTimeout(timeoutMs) {
|
|
187
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs < MIN_TIMEOUT_MS) {
|
|
188
|
+
return MIN_TIMEOUT_MS;
|
|
189
|
+
}
|
|
190
|
+
if (timeoutMs > MAX_TIMEOUT_MS) {
|
|
191
|
+
return MAX_TIMEOUT_MS;
|
|
192
|
+
}
|
|
193
|
+
return Math.floor(timeoutMs);
|
|
194
|
+
}
|
|
195
|
+
// ============================================================================
|
|
196
|
+
// Implementation
|
|
197
|
+
// ============================================================================
|
|
198
|
+
export class ClaudeCodeRunner {
|
|
199
|
+
/** Cached binary path after first successful resolution */
|
|
200
|
+
resolvedBinary = null;
|
|
201
|
+
/**
|
|
202
|
+
* Resolve the Claude Code binary path.
|
|
203
|
+
*
|
|
204
|
+
* Resolution order:
|
|
205
|
+
* 1. AGENTICS_CLAUDE_BIN env var (explicit override)
|
|
206
|
+
* 2. `claude` on PATH
|
|
207
|
+
* 3. `claude-code` on PATH
|
|
208
|
+
*
|
|
209
|
+
* Caches the result for the lifetime of this instance.
|
|
210
|
+
*
|
|
211
|
+
* @throws CLIError (ECLI-SYNTH-001) if no usable binary is found.
|
|
212
|
+
*/
|
|
213
|
+
resolve() {
|
|
214
|
+
if (this.resolvedBinary !== null) {
|
|
215
|
+
return this.resolvedBinary;
|
|
216
|
+
}
|
|
217
|
+
// Priority 1: Explicit environment variable override
|
|
218
|
+
const envBin = process.env['AGENTICS_CLAUDE_BIN'];
|
|
219
|
+
if (envBin !== undefined && envBin.length > 0) {
|
|
220
|
+
// Check as absolute path first, then as PATH lookup
|
|
221
|
+
const isAbsolute = existsSync(envBin);
|
|
222
|
+
const onPath = !isAbsolute ? resolveBinaryOnPath(envBin) : null;
|
|
223
|
+
const candidate = isAbsolute ? envBin : onPath;
|
|
224
|
+
if (candidate !== null) {
|
|
225
|
+
if (binaryIsExecutable(candidate)) {
|
|
226
|
+
this.resolvedBinary = candidate;
|
|
227
|
+
return candidate;
|
|
228
|
+
}
|
|
229
|
+
throw new CLIError({
|
|
230
|
+
code: 'ECLI-SYNTH-001',
|
|
231
|
+
category: 'CONFIG_ERROR',
|
|
232
|
+
message: `AGENTICS_CLAUDE_BIN="${envBin}" was found but is not executable`,
|
|
233
|
+
details: {
|
|
234
|
+
configured_path: envBin,
|
|
235
|
+
resolved_path: candidate,
|
|
236
|
+
hint: 'Verify the binary is not corrupted and has execute permissions',
|
|
237
|
+
},
|
|
238
|
+
module: 'claude-code-runner',
|
|
239
|
+
recoverable: false,
|
|
240
|
+
exitCode: 78,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
throw new CLIError({
|
|
244
|
+
code: 'ECLI-SYNTH-001',
|
|
245
|
+
category: 'CONFIG_ERROR',
|
|
246
|
+
message: `AGENTICS_CLAUDE_BIN="${envBin}" was not found on disk or PATH`,
|
|
247
|
+
details: {
|
|
248
|
+
configured_path: envBin,
|
|
249
|
+
hint: 'Set AGENTICS_CLAUDE_BIN to the full path of the Claude Code binary',
|
|
250
|
+
},
|
|
251
|
+
module: 'claude-code-runner',
|
|
252
|
+
recoverable: false,
|
|
253
|
+
exitCode: 78,
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
// Priority 2-3: Standard binary names on PATH
|
|
257
|
+
for (const candidateName of BINARY_CANDIDATES) {
|
|
258
|
+
const resolvedPath = resolveBinaryOnPath(candidateName);
|
|
259
|
+
if (resolvedPath !== null && binaryIsExecutable(resolvedPath)) {
|
|
260
|
+
this.resolvedBinary = resolvedPath;
|
|
261
|
+
return resolvedPath;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
throw new CLIError({
|
|
265
|
+
code: 'ECLI-SYNTH-001',
|
|
266
|
+
category: 'CONFIG_ERROR',
|
|
267
|
+
message: 'Claude Code CLI binary not found. Install it or set AGENTICS_CLAUDE_BIN.',
|
|
268
|
+
details: {
|
|
269
|
+
searched_names: [...BINARY_CANDIDATES],
|
|
270
|
+
platform: process.platform,
|
|
271
|
+
path_dirs: (process.env['PATH'] ?? '').split(process.platform === 'win32' ? ';' : ':').length,
|
|
272
|
+
hint: 'Install Claude Code: npm install -g @anthropic-ai/claude-code',
|
|
273
|
+
},
|
|
274
|
+
module: 'claude-code-runner',
|
|
275
|
+
recoverable: false,
|
|
276
|
+
exitCode: 78,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Invoke Claude Code with a prompt and return contract-validated output.
|
|
281
|
+
*
|
|
282
|
+
* Flow:
|
|
283
|
+
* 1. Resolve binary (cached)
|
|
284
|
+
* 2. Resolve model and timeout from options → env → defaults
|
|
285
|
+
* 3. Sanitize prompt
|
|
286
|
+
* 4. Spawn subprocess: `<binary> --print --output-format json --model <model> <prompt>`
|
|
287
|
+
* 5. Capture stdout + stderr
|
|
288
|
+
* 6. Strip code fences from stdout
|
|
289
|
+
* 7. Parse as JSON (throw ECLI-SYNTH-003 on failure)
|
|
290
|
+
* 8. Validate against contract response schema (throw ECLI-SYNTH-004 on failure)
|
|
291
|
+
* 9. Return validated result
|
|
292
|
+
*
|
|
293
|
+
* @throws SynthesisError on any failure (see ADR-006 error code table)
|
|
294
|
+
*/
|
|
295
|
+
invoke(prompt, options) {
|
|
296
|
+
// Resolve binary (cached after first call)
|
|
297
|
+
const binary = this.resolve();
|
|
298
|
+
// Resolve configuration: options → env → defaults
|
|
299
|
+
const model = resolveModel(options.model);
|
|
300
|
+
const timeoutMs = resolveTimeout(options.timeoutMs);
|
|
301
|
+
const verbose = options.verbose ?? (process.env['AGENTICS_DEV'] === '1' || process.env['AGENTICS_DEV'] === 'true');
|
|
302
|
+
const correlationId = options.correlationId;
|
|
303
|
+
// Sanitize prompt
|
|
304
|
+
const sanitizedPrompt = sanitizePrompt(prompt);
|
|
305
|
+
if (sanitizedPrompt.length === 0) {
|
|
306
|
+
throw new SynthesisError({
|
|
307
|
+
code: 'ECLI-SYNTH-006',
|
|
308
|
+
message: 'Prompt is empty after sanitization',
|
|
309
|
+
runId: options.runId,
|
|
310
|
+
model,
|
|
311
|
+
durationMs: 0,
|
|
312
|
+
category: 'INTERNAL_ERROR',
|
|
313
|
+
exitCode: 70,
|
|
314
|
+
recoverable: false,
|
|
315
|
+
correlationId,
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
if (verbose) {
|
|
319
|
+
process.stderr.write(`[claude-code-runner] resolve=${binary} model=${model} timeout=${timeoutMs}ms ` +
|
|
320
|
+
`runId=${options.runId} promptLen=${sanitizedPrompt.length}\n`);
|
|
321
|
+
}
|
|
322
|
+
// Build subprocess arguments
|
|
323
|
+
const subprocessArgs = [
|
|
324
|
+
'--print',
|
|
325
|
+
'--output-format', 'json',
|
|
326
|
+
'--model', model,
|
|
327
|
+
sanitizedPrompt,
|
|
328
|
+
];
|
|
329
|
+
// Execute subprocess
|
|
330
|
+
const startTime = Date.now();
|
|
331
|
+
let rawStdout;
|
|
332
|
+
let rawStderr = '';
|
|
333
|
+
try {
|
|
334
|
+
rawStdout = execFileSync(binary, subprocessArgs, {
|
|
335
|
+
encoding: 'utf-8',
|
|
336
|
+
timeout: timeoutMs,
|
|
337
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
338
|
+
env: {
|
|
339
|
+
...process.env,
|
|
340
|
+
// Suppress interactive prompts in Claude Code
|
|
341
|
+
CI: '1',
|
|
342
|
+
// Do not inherit AGENTICS_DEV into the child to avoid recursive debug spam
|
|
343
|
+
AGENTICS_DEV: undefined,
|
|
344
|
+
},
|
|
345
|
+
maxBuffer: MAX_BUFFER_BYTES,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
catch (error) {
|
|
349
|
+
const durationMs = Date.now() - startTime;
|
|
350
|
+
handleSubprocessError(error, options.runId, model, timeoutMs, durationMs, correlationId);
|
|
351
|
+
// handleSubprocessError always throws; this is unreachable but satisfies TS
|
|
352
|
+
throw error;
|
|
353
|
+
}
|
|
354
|
+
const durationMs = Date.now() - startTime;
|
|
355
|
+
if (verbose) {
|
|
356
|
+
process.stderr.write(`[claude-code-runner] completed in ${durationMs}ms stdout=${rawStdout.length}B\n`);
|
|
357
|
+
}
|
|
358
|
+
// Process output: strip fences → parse JSON → validate contract
|
|
359
|
+
const cleanedOutput = stripCodeFences(rawStdout);
|
|
360
|
+
// Parse JSON
|
|
361
|
+
let parsed;
|
|
362
|
+
try {
|
|
363
|
+
parsed = JSON.parse(cleanedOutput);
|
|
364
|
+
}
|
|
365
|
+
catch (parseError) {
|
|
366
|
+
throw new SynthesisError({
|
|
367
|
+
code: 'ECLI-SYNTH-003',
|
|
368
|
+
message: 'Claude Code output is not valid JSON after code-fence stripping',
|
|
369
|
+
runId: options.runId,
|
|
370
|
+
model,
|
|
371
|
+
durationMs,
|
|
372
|
+
category: 'DOWNSTREAM_ERROR',
|
|
373
|
+
exitCode: 140,
|
|
374
|
+
recoverable: false,
|
|
375
|
+
correlationId,
|
|
376
|
+
details: {
|
|
377
|
+
raw_output_length: rawStdout.length,
|
|
378
|
+
cleaned_output_preview: cleanedOutput.slice(0, 300),
|
|
379
|
+
stderr_preview: rawStderr.slice(0, 300),
|
|
380
|
+
parse_error: parseError instanceof Error ? parseError.message : String(parseError),
|
|
381
|
+
},
|
|
382
|
+
cause: parseError instanceof Error ? parseError : undefined,
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
// Validate parsed output is an object (not array, string, null, etc.)
|
|
386
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
387
|
+
throw new SynthesisError({
|
|
388
|
+
code: 'ECLI-SYNTH-003',
|
|
389
|
+
message: `Claude Code output parsed as ${parsed === null ? 'null' : Array.isArray(parsed) ? 'array' : typeof parsed}, expected object`,
|
|
390
|
+
runId: options.runId,
|
|
391
|
+
model,
|
|
392
|
+
durationMs,
|
|
393
|
+
category: 'DOWNSTREAM_ERROR',
|
|
394
|
+
exitCode: 140,
|
|
395
|
+
recoverable: false,
|
|
396
|
+
correlationId,
|
|
397
|
+
details: {
|
|
398
|
+
parsed_type: parsed === null ? 'null' : Array.isArray(parsed) ? 'array' : typeof parsed,
|
|
399
|
+
},
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
// Contract validation against the response schema for this subcommand
|
|
403
|
+
if (options.schemaKey) {
|
|
404
|
+
const schemaName = SYNTHESIS_SCHEMA_MAP[options.schemaKey];
|
|
405
|
+
if (schemaName) {
|
|
406
|
+
const validationResult = safeValidateResponse(schemaName, parsed, correlationId);
|
|
407
|
+
if (!validationResult.valid) {
|
|
408
|
+
throw new SynthesisError({
|
|
409
|
+
code: 'ECLI-SYNTH-004',
|
|
410
|
+
message: `Claude Code output failed contract validation against schema "${schemaName}"`,
|
|
411
|
+
runId: options.runId,
|
|
412
|
+
model,
|
|
413
|
+
durationMs,
|
|
414
|
+
category: 'DOWNSTREAM_ERROR',
|
|
415
|
+
exitCode: 140,
|
|
416
|
+
recoverable: false,
|
|
417
|
+
correlationId,
|
|
418
|
+
details: {
|
|
419
|
+
schema_name: schemaName,
|
|
420
|
+
schema_key: options.schemaKey,
|
|
421
|
+
validation_errors: validationResult.error.validationErrors.slice(0, 5),
|
|
422
|
+
},
|
|
423
|
+
cause: validationResult.error,
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
// Truncate rawOutput for storage safety
|
|
429
|
+
const truncatedRawOutput = rawStdout.length > MAX_RAW_OUTPUT_STORED
|
|
430
|
+
? rawStdout.slice(0, MAX_RAW_OUTPUT_STORED) + `\n...[truncated from ${rawStdout.length} bytes]`
|
|
431
|
+
: rawStdout;
|
|
432
|
+
return {
|
|
433
|
+
data: parsed,
|
|
434
|
+
runId: options.runId,
|
|
435
|
+
model,
|
|
436
|
+
durationMs,
|
|
437
|
+
rawOutput: truncatedRawOutput,
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
// ============================================================================
|
|
442
|
+
// Configuration Resolution Helpers
|
|
443
|
+
// ============================================================================
|
|
444
|
+
/**
|
|
445
|
+
* Resolve the model to use: explicit option → env var → default.
|
|
446
|
+
* Validates the model string is non-empty.
|
|
447
|
+
*/
|
|
448
|
+
function resolveModel(optionModel) {
|
|
449
|
+
const envModel = process.env['AGENTICS_CLAUDE_MODEL'];
|
|
450
|
+
const model = optionModel ?? (envModel && envModel.length > 0 ? envModel : undefined) ?? DEFAULT_MODEL;
|
|
451
|
+
// Defensive: model must be a non-empty alphanumeric-ish string
|
|
452
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(model)) {
|
|
453
|
+
throw new CLIError({
|
|
454
|
+
code: 'ECLI-SYNTH-006',
|
|
455
|
+
category: 'CONFIG_ERROR',
|
|
456
|
+
message: `Invalid model name: "${model}". Must be alphanumeric with dots, hyphens, or underscores.`,
|
|
457
|
+
details: { model },
|
|
458
|
+
module: 'claude-code-runner',
|
|
459
|
+
recoverable: false,
|
|
460
|
+
exitCode: 78,
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
return model;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Resolve and clamp the timeout: explicit option → env var → default.
|
|
467
|
+
*/
|
|
468
|
+
function resolveTimeout(optionTimeout) {
|
|
469
|
+
if (optionTimeout !== undefined) {
|
|
470
|
+
return clampTimeout(optionTimeout);
|
|
471
|
+
}
|
|
472
|
+
const envTimeout = process.env['AGENTICS_CLAUDE_TIMEOUT_MS'];
|
|
473
|
+
if (envTimeout !== undefined && envTimeout.length > 0) {
|
|
474
|
+
const parsed = parseInt(envTimeout, 10);
|
|
475
|
+
if (Number.isFinite(parsed)) {
|
|
476
|
+
return clampTimeout(parsed);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
return DEFAULT_TIMEOUT_MS;
|
|
480
|
+
}
|
|
481
|
+
// ============================================================================
|
|
482
|
+
// Subprocess Error Handler
|
|
483
|
+
// ============================================================================
|
|
484
|
+
/**
|
|
485
|
+
* Handle execFileSync errors and convert to structured SynthesisError.
|
|
486
|
+
*
|
|
487
|
+
* Node.js child_process errors have these relevant fields:
|
|
488
|
+
* - killed: boolean (true if process was killed by timeout signal)
|
|
489
|
+
* - status: number | null (exit code, null if killed)
|
|
490
|
+
* - stderr: Buffer | string (captured stderr output)
|
|
491
|
+
* - message: string (Node.js error message)
|
|
492
|
+
*
|
|
493
|
+
* @throws SynthesisError always
|
|
494
|
+
*/
|
|
495
|
+
function handleSubprocessError(error, runId, model, timeoutMs, durationMs, correlationId) {
|
|
496
|
+
// Type-narrow the child_process error
|
|
497
|
+
const cpError = error;
|
|
498
|
+
// Extract stderr for diagnostics (may be Buffer or string)
|
|
499
|
+
let stderrStr = '';
|
|
500
|
+
if (typeof cpError.stderr === 'string') {
|
|
501
|
+
stderrStr = cpError.stderr;
|
|
502
|
+
}
|
|
503
|
+
else if (Buffer.isBuffer(cpError.stderr)) {
|
|
504
|
+
stderrStr = cpError.stderr.toString('utf-8');
|
|
505
|
+
}
|
|
506
|
+
const stderrPreview = stderrStr.slice(0, 1_000);
|
|
507
|
+
// Case 1: Killed by timeout
|
|
508
|
+
if (cpError.killed === true) {
|
|
509
|
+
throw new SynthesisError({
|
|
510
|
+
code: 'ECLI-SYNTH-005',
|
|
511
|
+
message: `Claude Code subprocess timed out after ${timeoutMs}ms (wall-clock: ${durationMs}ms)`,
|
|
512
|
+
runId,
|
|
513
|
+
model,
|
|
514
|
+
durationMs,
|
|
515
|
+
category: 'NETWORK_ERROR',
|
|
516
|
+
exitCode: 120,
|
|
517
|
+
recoverable: true,
|
|
518
|
+
correlationId,
|
|
519
|
+
details: {
|
|
520
|
+
timeout_ms: timeoutMs,
|
|
521
|
+
signal: cpError.signal,
|
|
522
|
+
stderr_preview: stderrPreview,
|
|
523
|
+
hint: 'Increase AGENTICS_CLAUDE_TIMEOUT_MS or simplify the prompt',
|
|
524
|
+
},
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
// Case 2: ENOENT — binary vanished between resolve() and invoke()
|
|
528
|
+
if (cpError.code === 'ENOENT') {
|
|
529
|
+
throw new SynthesisError({
|
|
530
|
+
code: 'ECLI-SYNTH-001',
|
|
531
|
+
message: 'Claude Code binary not found at execution time (may have been uninstalled)',
|
|
532
|
+
runId,
|
|
533
|
+
model,
|
|
534
|
+
durationMs,
|
|
535
|
+
category: 'CONFIG_ERROR',
|
|
536
|
+
exitCode: 78,
|
|
537
|
+
recoverable: false,
|
|
538
|
+
correlationId,
|
|
539
|
+
details: {
|
|
540
|
+
error_code: cpError.code,
|
|
541
|
+
},
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
// Case 3: Non-zero exit code
|
|
545
|
+
throw new SynthesisError({
|
|
546
|
+
code: 'ECLI-SYNTH-002',
|
|
547
|
+
message: `Claude Code exited with code ${cpError.status ?? 'unknown'}: ${stderrPreview.split('\n')[0] || cpError.message || 'no details'}`,
|
|
548
|
+
runId,
|
|
549
|
+
model,
|
|
550
|
+
durationMs,
|
|
551
|
+
category: 'DOWNSTREAM_ERROR',
|
|
552
|
+
exitCode: 140,
|
|
553
|
+
recoverable: false,
|
|
554
|
+
correlationId,
|
|
555
|
+
details: {
|
|
556
|
+
exit_code: cpError.status,
|
|
557
|
+
signal: cpError.signal,
|
|
558
|
+
stderr_preview: stderrPreview,
|
|
559
|
+
node_error_code: cpError.code,
|
|
560
|
+
},
|
|
561
|
+
cause: error instanceof Error ? error : undefined,
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
// ============================================================================
|
|
565
|
+
// Singleton & Factory
|
|
566
|
+
// ============================================================================
|
|
567
|
+
/** Module-level singleton. Binary resolution is cached here. */
|
|
568
|
+
let singletonRunner = null;
|
|
569
|
+
/**
|
|
570
|
+
* Get or create the singleton ClaudeCodeRunner.
|
|
571
|
+
*
|
|
572
|
+
* Uses a singleton so binary resolution (which spawns `which`/`where`)
|
|
573
|
+
* only happens once per process lifetime.
|
|
574
|
+
*/
|
|
575
|
+
export function createClaudeCodeRunner() {
|
|
576
|
+
if (singletonRunner === null) {
|
|
577
|
+
singletonRunner = new ClaudeCodeRunner();
|
|
578
|
+
}
|
|
579
|
+
return singletonRunner;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Reset the singleton (for testing only).
|
|
583
|
+
* Clears cached binary resolution so the next call re-resolves.
|
|
584
|
+
*/
|
|
585
|
+
export function resetClaudeCodeRunnerForTesting() {
|
|
586
|
+
singletonRunner = null;
|
|
587
|
+
}
|
|
588
|
+
//# sourceMappingURL=claude-code-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code-runner.js","sourceRoot":"","sources":["../../src/runtime/claude-code-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;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,OAAO,EAAE;YACP,SAAS,EAAE,OAAO,CAAC,MAAM;YACzB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,cAAc,EAAE,aAAa;YAC7B,eAAe,EAAE,OAAO,CAAC,IAAI;SAC9B;QACD,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;KAClD,CAAC,CAAC;AACL,CAAC;AAED,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E,gEAAgE;AAChE,IAAI,eAAe,GAA4B,IAAI,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB;IACpC,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;QAC7B,eAAe,GAAG,IAAI,gBAAgB,EAAE,CAAC;IAC3C,CAAC;IACD,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,+BAA+B;IAC7C,eAAe,GAAG,IAAI,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,cAAc,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,cAAc,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAC"}
|