@sentropic/llm-mesh 0.34.0 → 0.35.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/README.md +36 -0
- package/dist/enrollment/contracts.d.ts +1 -1
- package/dist/enrollment/contracts.d.ts.map +1 -1
- package/dist/node/claude-code-cli-runner.d.ts +56 -0
- package/dist/node/claude-code-cli-runner.d.ts.map +1 -0
- package/dist/node/claude-code-cli-runner.js +590 -0
- package/dist/node/claude-code-cli-runner.js.map +1 -0
- package/dist/node/claude-code-cli-wire.d.ts +55 -0
- package/dist/node/claude-code-cli-wire.d.ts.map +1 -0
- package/dist/node/claude-code-cli-wire.js +144 -0
- package/dist/node/claude-code-cli-wire.js.map +1 -0
- package/dist/node/cli/bin.d.ts +3 -0
- package/dist/node/cli/bin.d.ts.map +1 -0
- package/dist/node/cli/bin.js +15 -0
- package/dist/node/cli/bin.js.map +1 -0
- package/dist/node/cli/enroll-args.d.ts +41 -0
- package/dist/node/cli/enroll-args.d.ts.map +1 -0
- package/dist/node/cli/enroll-args.js +118 -0
- package/dist/node/cli/enroll-args.js.map +1 -0
- package/dist/node/cli/enroll-cli.d.ts +4 -0
- package/dist/node/cli/enroll-cli.d.ts.map +1 -0
- package/dist/node/cli/enroll-cli.js +124 -0
- package/dist/node/cli/enroll-cli.js.map +1 -0
- package/dist/node/cli/enroll-command.d.ts +3 -0
- package/dist/node/cli/enroll-command.d.ts.map +1 -0
- package/dist/node/cli/enroll-command.js +87 -0
- package/dist/node/cli/enroll-command.js.map +1 -0
- package/dist/node/index.d.ts +6 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +4 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/keyring/encrypted-file-keyring.d.ts +7 -1
- package/dist/node/keyring/encrypted-file-keyring.d.ts.map +1 -1
- package/dist/node/keyring/encrypted-file-keyring.js +46 -1
- package/dist/node/keyring/encrypted-file-keyring.js.map +1 -1
- package/dist/service/local-account-transport-service.js +1 -1
- package/dist/service/local-account-transport-service.js.map +1 -1
- package/dist/transport/claude-code-runtime-client.d.ts +24 -0
- package/dist/transport/claude-code-runtime-client.d.ts.map +1 -1
- package/dist/transport/claude-code-runtime-client.js +66 -3
- package/dist/transport/claude-code-runtime-client.js.map +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
// @sentropic/llm-mesh/node/claude-code-cli-runner.ts
|
|
2
|
+
//
|
|
3
|
+
// Concrete Node host for the Claude Code runtime client. Spawns the `claude`
|
|
4
|
+
// CLI headless (`-p --verbose --output-format stream-json --model --effort`,
|
|
5
|
+
// optional `--system-prompt-file`, plus confinement flags), feeds the
|
|
6
|
+
// projected prompt over stdin, and normalizes stream-json output to
|
|
7
|
+
// ClaudeCodeCliEvent.
|
|
8
|
+
//
|
|
9
|
+
// Secret boundary: the seat OAuth access projection travels as
|
|
10
|
+
// CLAUDE_CODE_OAUTH_TOKEN in the CHILD env only. It never appears on argv,
|
|
11
|
+
// in logs, or in thrown messages. The child env is an allowlist (PATH and a
|
|
12
|
+
// few locale/timezone knobs copied from the parent); every known
|
|
13
|
+
// authentication, endpoint, and cloud carrier is purged before the seat token
|
|
14
|
+
// is injected, so the CLI cannot prefer ambient key auth over the seat grant
|
|
15
|
+
// and ambient secrets never reach the CLI or its hook/MCP descendants.
|
|
16
|
+
// Confinement: the CLI runs with `--tools ""`, `--strict-mcp-config` (no
|
|
17
|
+
// MCP config, so no MCP servers), and `--no-session-persistence`, inside a
|
|
18
|
+
// fresh sandbox directory used as cwd, HOME, and CLAUDE_CONFIG_DIR; ambient
|
|
19
|
+
// hooks, skills, plugins, and settings never load from the sandbox. A
|
|
20
|
+
// non-empty tool/MCP inventory in the CLI `init` line fails the run closed
|
|
21
|
+
// immediately, before any further event is emitted, and a successful run
|
|
22
|
+
// always observed an `init` line. Requests carrying tool definitions are
|
|
23
|
+
// refused before spawning: the CLI host never silently drops them.
|
|
24
|
+
// Quota signals (5-hour session limit, rate limits, overload) surface as
|
|
25
|
+
// ClaudeCliQuotaError; every other host failure is a fixed-message runner
|
|
26
|
+
// error with no CLI output attached.
|
|
27
|
+
import { spawn } from 'node:child_process';
|
|
28
|
+
import { mkdtemp, rm } from 'node:fs/promises';
|
|
29
|
+
import { tmpdir } from 'node:os';
|
|
30
|
+
import { join } from 'node:path';
|
|
31
|
+
import { StringDecoder } from 'node:string_decoder';
|
|
32
|
+
import { ClaudeCliQuotaError, ClaudeCodeRuntimeClient, } from '../transport/claude-code-runtime-client.js';
|
|
33
|
+
import { appendCappedTail, diagnoseClaudeCodeQuota, extractQuotaText, parseClaudeCodeLine, renderClaudeCodeCliPrompt } from './claude-code-cli-wire.js';
|
|
34
|
+
export const CLAUDE_CODE_OAUTH_ENV_VAR = 'CLAUDE_CODE_OAUTH_TOKEN';
|
|
35
|
+
export const CLAUDE_CODE_STREAM_PROTOCOL = 'claude-code-stream-json-v1';
|
|
36
|
+
export const DEFAULT_CLAUDE_CODE_CLI_PATH = 'claude';
|
|
37
|
+
export const DEFAULT_CLAUDE_CODE_EFFORT = 'medium';
|
|
38
|
+
export const DEFAULT_CLAUDE_CODE_TIMEOUT_MS = 300_000;
|
|
39
|
+
export const CLAUDE_CODE_RESULT_TIMEOUT_MS = 15_000;
|
|
40
|
+
/** SIGTERM grace before the group SIGKILL escalation. */
|
|
41
|
+
const KILL_GRACE_MS = 2_000;
|
|
42
|
+
/** One NDJSON line past this fails the run instead of growing the buffer. */
|
|
43
|
+
const MAX_STDOUT_LINE_CHARS = 1_048_576;
|
|
44
|
+
/** Whole-run stdout past this fails the run instead of growing memory. */
|
|
45
|
+
const MAX_STDOUT_TOTAL_BYTES = 33_554_432;
|
|
46
|
+
/** Probe output past this fails the probe instead of growing memory. */
|
|
47
|
+
const MAX_PROBE_OUTPUT_BYTES = 65_536;
|
|
48
|
+
/** Oldest qualified CLI line: every confinement flag below was verified on 2.1.x. */
|
|
49
|
+
const MIN_CLAUDE_CODE_MAJOR = 2;
|
|
50
|
+
const MIN_CLAUDE_CODE_MINOR = 1;
|
|
51
|
+
const REQUIRED_CLAUDE_CODE_FLAGS = [
|
|
52
|
+
'--verbose',
|
|
53
|
+
'--output-format',
|
|
54
|
+
'--model',
|
|
55
|
+
'--effort',
|
|
56
|
+
'--system-prompt-file',
|
|
57
|
+
'--tools',
|
|
58
|
+
'--strict-mcp-config',
|
|
59
|
+
'--no-session-persistence',
|
|
60
|
+
];
|
|
61
|
+
const STDERR_TAIL_BYTES = 8_192;
|
|
62
|
+
const nonEmpty = (value) => typeof value === 'string' && value.length > 0 && value.length <= 4096
|
|
63
|
+
&& !/[\0-\x1f\x7f]/.test(value);
|
|
64
|
+
const validEffort = (value) => /^[A-Za-z0-9-]{1,16}$/.test(value);
|
|
65
|
+
const validModelId = (value) => /^[a-zA-Z0-9][a-zA-Z0-9._:-]*$/.test(value) && value.length <= 256;
|
|
66
|
+
/**
|
|
67
|
+
* Parent env names copied into the CLI child. Everything else — ambient
|
|
68
|
+
* secrets, auth carriers, endpoints, cloud credentials — never crosses.
|
|
69
|
+
*/
|
|
70
|
+
const CHILD_ENV_COPY = ['PATH', 'LANG', 'LC_ALL', 'TZ', 'NO_COLOR'];
|
|
71
|
+
/**
|
|
72
|
+
* Auth/endpoint/cloud carriers purged from the child env before the seat
|
|
73
|
+
* token is injected. The allowlist above already excludes them; this is
|
|
74
|
+
* belt-and-suspenders in case the allowlist ever grows.
|
|
75
|
+
*/
|
|
76
|
+
const PURGED_ENV_PREFIXES = [
|
|
77
|
+
'ANTHROPIC_',
|
|
78
|
+
'CLAUDE_CODE_',
|
|
79
|
+
'AWS_',
|
|
80
|
+
'GOOGLE_',
|
|
81
|
+
'GEMINI_',
|
|
82
|
+
'AZURE_',
|
|
83
|
+
'VERTEX_',
|
|
84
|
+
'BEDROCK_',
|
|
85
|
+
];
|
|
86
|
+
/**
|
|
87
|
+
* Minimal child env: allowlist copy, purge, then the sandbox dirs and — when
|
|
88
|
+
* a seat projection is supplied — the seat token. The probe passes no token
|
|
89
|
+
* and never runs a workload.
|
|
90
|
+
*/
|
|
91
|
+
const buildChildEnv = (sandboxDir, accessToken) => {
|
|
92
|
+
const env = {};
|
|
93
|
+
for (const name of CHILD_ENV_COPY) {
|
|
94
|
+
const value = process.env[name];
|
|
95
|
+
if (value !== undefined)
|
|
96
|
+
env[name] = value;
|
|
97
|
+
}
|
|
98
|
+
if (process.platform === 'win32') {
|
|
99
|
+
const systemRoot = process.env['SystemRoot'];
|
|
100
|
+
if (systemRoot !== undefined)
|
|
101
|
+
env['SystemRoot'] = systemRoot;
|
|
102
|
+
}
|
|
103
|
+
for (const name of Object.keys(env)) {
|
|
104
|
+
if (PURGED_ENV_PREFIXES.some((prefix) => name.startsWith(prefix)))
|
|
105
|
+
delete env[name];
|
|
106
|
+
}
|
|
107
|
+
if (accessToken !== undefined)
|
|
108
|
+
env[CLAUDE_CODE_OAUTH_ENV_VAR] = accessToken;
|
|
109
|
+
env['CLAUDE_CONFIG_DIR'] = sandboxDir;
|
|
110
|
+
env['HOME'] = sandboxDir;
|
|
111
|
+
env['TMPDIR'] = sandboxDir;
|
|
112
|
+
env['TMP'] = sandboxDir;
|
|
113
|
+
env['TEMP'] = sandboxDir;
|
|
114
|
+
env['XDG_CONFIG_HOME'] = sandboxDir;
|
|
115
|
+
env['XDG_CACHE_HOME'] = sandboxDir;
|
|
116
|
+
env['XDG_DATA_HOME'] = sandboxDir;
|
|
117
|
+
env['XDG_STATE_HOME'] = sandboxDir;
|
|
118
|
+
return env;
|
|
119
|
+
};
|
|
120
|
+
const abortedError = () => {
|
|
121
|
+
const error = new Error('claude CLI runner aborted');
|
|
122
|
+
error.name = 'AbortError';
|
|
123
|
+
return error;
|
|
124
|
+
};
|
|
125
|
+
const runnerError = (message) => {
|
|
126
|
+
const error = new Error(message);
|
|
127
|
+
error.name = 'ClaudeCliRunnerError';
|
|
128
|
+
return error;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Signal the whole process group on POSIX (the child is spawned detached, so
|
|
132
|
+
* its pid is the group id) and the direct child on win32. Skipped only when
|
|
133
|
+
* our own stdio pipes are already closed — while they are open the group is
|
|
134
|
+
* necessarily alive, so there is no pid-reuse race.
|
|
135
|
+
*/
|
|
136
|
+
const killTree = (child, closed, signal) => {
|
|
137
|
+
if (!child || closed())
|
|
138
|
+
return;
|
|
139
|
+
// POSIX: signal the detached process group first (the child is spawned
|
|
140
|
+
// detached, so its pid is the group id). When the group is already gone
|
|
141
|
+
// (ESRCH) fall back to the direct child so a non-group-leader child is
|
|
142
|
+
// still reaped; win32 has no process groups.
|
|
143
|
+
if (child.pid !== undefined && process.platform !== 'win32') {
|
|
144
|
+
try {
|
|
145
|
+
process.kill(-child.pid, signal);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
catch { /* group gone: fall through to the direct child */ }
|
|
149
|
+
}
|
|
150
|
+
try {
|
|
151
|
+
if (child.exitCode === null)
|
|
152
|
+
child.kill(signal);
|
|
153
|
+
}
|
|
154
|
+
catch { /* already gone */ }
|
|
155
|
+
};
|
|
156
|
+
const destroyPipes = (child) => {
|
|
157
|
+
try {
|
|
158
|
+
child?.stdin?.destroy();
|
|
159
|
+
}
|
|
160
|
+
catch { /* already gone */ }
|
|
161
|
+
try {
|
|
162
|
+
child?.stdout?.destroy();
|
|
163
|
+
}
|
|
164
|
+
catch { /* already gone */ }
|
|
165
|
+
try {
|
|
166
|
+
child?.stderr?.destroy();
|
|
167
|
+
}
|
|
168
|
+
catch { /* already gone */ }
|
|
169
|
+
};
|
|
170
|
+
const waitForClose = async (child, closed, timeoutMs) => {
|
|
171
|
+
if (closed())
|
|
172
|
+
return true;
|
|
173
|
+
return new Promise((resolve) => {
|
|
174
|
+
const timer = setTimeout(() => resolve(false), timeoutMs);
|
|
175
|
+
timer.unref?.();
|
|
176
|
+
child.once('close', () => { clearTimeout(timer); resolve(true); });
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Hard teardown: SIGTERM the group, escalate to a group SIGKILL past the
|
|
181
|
+
* grace, destroy our pipe ends so a surviving grandchild holding stdout can
|
|
182
|
+
* neither block nor orphan the run, then await the close.
|
|
183
|
+
*/
|
|
184
|
+
const shutdown = async (child, closed) => {
|
|
185
|
+
if (!child)
|
|
186
|
+
return;
|
|
187
|
+
killTree(child, closed, 'SIGTERM');
|
|
188
|
+
if (await waitForClose(child, closed, KILL_GRACE_MS))
|
|
189
|
+
return;
|
|
190
|
+
killTree(child, closed, 'SIGKILL');
|
|
191
|
+
destroyPipes(child);
|
|
192
|
+
await waitForClose(child, closed, CLAUDE_CODE_RESULT_TIMEOUT_MS);
|
|
193
|
+
};
|
|
194
|
+
export class NodeClaudeCodeCliRunner {
|
|
195
|
+
cliPath;
|
|
196
|
+
effort;
|
|
197
|
+
systemPromptFile;
|
|
198
|
+
timeoutMs;
|
|
199
|
+
stderrTailBytes;
|
|
200
|
+
constructor(options = {}) {
|
|
201
|
+
if (options.cliPath !== undefined && !nonEmpty(options.cliPath)) {
|
|
202
|
+
throw new Error('claude CLI path must be a non-empty string');
|
|
203
|
+
}
|
|
204
|
+
if (options.effort !== undefined && !validEffort(options.effort)) {
|
|
205
|
+
throw new Error('claude CLI effort must match [A-Za-z0-9-]{1,16}');
|
|
206
|
+
}
|
|
207
|
+
if (options.systemPromptFile !== undefined && !nonEmpty(options.systemPromptFile)) {
|
|
208
|
+
throw new Error('claude CLI system prompt file must be a non-empty string');
|
|
209
|
+
}
|
|
210
|
+
if (options.timeoutMs !== undefined
|
|
211
|
+
&& (!Number.isFinite(options.timeoutMs) || options.timeoutMs <= 0)) {
|
|
212
|
+
throw new Error('claude CLI timeout must be a positive number of milliseconds');
|
|
213
|
+
}
|
|
214
|
+
if (options.collectStderrBytes !== undefined
|
|
215
|
+
&& (!Number.isSafeInteger(options.collectStderrBytes) || options.collectStderrBytes < 0)) {
|
|
216
|
+
throw new Error('claude CLI stderr cap must be a non-negative safe integer');
|
|
217
|
+
}
|
|
218
|
+
this.cliPath = options.cliPath ?? DEFAULT_CLAUDE_CODE_CLI_PATH;
|
|
219
|
+
this.effort = options.effort ?? DEFAULT_CLAUDE_CODE_EFFORT;
|
|
220
|
+
this.systemPromptFile = options.systemPromptFile;
|
|
221
|
+
this.timeoutMs = options.timeoutMs ?? DEFAULT_CLAUDE_CODE_TIMEOUT_MS;
|
|
222
|
+
this.stderrTailBytes = options.collectStderrBytes ?? STDERR_TAIL_BYTES;
|
|
223
|
+
}
|
|
224
|
+
run(input) {
|
|
225
|
+
return {
|
|
226
|
+
[Symbol.asyncIterator]: () => this.execute(input.access, input.request, input.signal),
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
async *execute(access, request, signal) {
|
|
230
|
+
if (!nonEmpty(access.accessToken) || /[\r\n]/.test(access.accessToken)) {
|
|
231
|
+
throw runnerError('claude CLI runner refused an invalid access projection');
|
|
232
|
+
}
|
|
233
|
+
if (!validModelId(request.modelId))
|
|
234
|
+
throw runnerError('claude CLI runner refused an invalid model id');
|
|
235
|
+
// Tool definitions are never forwarded: the CLI runs with `--tools ""`,
|
|
236
|
+
// so accepting them would silently drop caller intent. Refuse instead.
|
|
237
|
+
if (request.tools !== undefined && request.tools.length > 0) {
|
|
238
|
+
throw runnerError('claude CLI runner refused a request with tool definitions');
|
|
239
|
+
}
|
|
240
|
+
// No token-bearing process exists before this point: abort and prompt
|
|
241
|
+
// rendering both precede the spawn.
|
|
242
|
+
if (signal.aborted)
|
|
243
|
+
throw abortedError();
|
|
244
|
+
const prompt = renderClaudeCodeCliPrompt(request);
|
|
245
|
+
if (signal.aborted)
|
|
246
|
+
throw abortedError();
|
|
247
|
+
const sandboxDir = await mkdtemp(join(tmpdir(), 'claude-seat-')).catch(() => {
|
|
248
|
+
throw runnerError('claude CLI runner failed to isolate the CLI workspace');
|
|
249
|
+
});
|
|
250
|
+
let child;
|
|
251
|
+
let closed = false;
|
|
252
|
+
const isClosed = () => closed;
|
|
253
|
+
try {
|
|
254
|
+
// --verbose is required with -p --output-format stream-json on the 2.1
|
|
255
|
+
// line; --tools "" disables every built-in (local) tool; with
|
|
256
|
+
// --strict-mcp-config and no --mcp-config no MCP server can load;
|
|
257
|
+
// --no-session-persistence keeps the seat run off disk.
|
|
258
|
+
const args = ['-p', '--verbose', '--output-format', 'stream-json',
|
|
259
|
+
'--model', request.modelId, '--effort', this.effort,
|
|
260
|
+
'--tools', '', '--strict-mcp-config', '--no-session-persistence',
|
|
261
|
+
...(this.systemPromptFile ? ['--system-prompt-file', this.systemPromptFile] : [])];
|
|
262
|
+
const env = buildChildEnv(sandboxDir, access.accessToken);
|
|
263
|
+
try {
|
|
264
|
+
child = spawn(this.cliPath, args, { env: env, stdio: ['pipe', 'pipe', 'pipe'],
|
|
265
|
+
cwd: sandboxDir, detached: process.platform !== 'win32' });
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
throw runnerError('claude CLI runner failed to spawn the CLI');
|
|
269
|
+
}
|
|
270
|
+
child.once('close', () => { closed = true; });
|
|
271
|
+
// The internal stop fires on external abort and on timeout; consume
|
|
272
|
+
// observes it so a SIGTERM-ignoring CLI cannot hold the run open.
|
|
273
|
+
const stop = new AbortController();
|
|
274
|
+
const onAbort = () => { stop.abort(); void shutdown(child, isClosed); };
|
|
275
|
+
if (signal.aborted) {
|
|
276
|
+
onAbort();
|
|
277
|
+
throw abortedError();
|
|
278
|
+
}
|
|
279
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
280
|
+
let timer;
|
|
281
|
+
let timedOut = false;
|
|
282
|
+
try {
|
|
283
|
+
timer = setTimeout(() => {
|
|
284
|
+
timedOut = true;
|
|
285
|
+
stop.abort();
|
|
286
|
+
void shutdown(child, isClosed);
|
|
287
|
+
}, this.timeoutMs);
|
|
288
|
+
timer.unref?.();
|
|
289
|
+
yield* this.consume(child, prompt, stop.signal);
|
|
290
|
+
if (stop.signal.aborted) {
|
|
291
|
+
if (signal.aborted)
|
|
292
|
+
throw abortedError();
|
|
293
|
+
if (timedOut)
|
|
294
|
+
throw runnerError('claude CLI runner timed out waiting for the CLI result');
|
|
295
|
+
throw runnerError('claude CLI runner stopped before the CLI result');
|
|
296
|
+
}
|
|
297
|
+
if (timedOut)
|
|
298
|
+
throw runnerError('claude CLI runner timed out waiting for the CLI result');
|
|
299
|
+
}
|
|
300
|
+
catch (error) {
|
|
301
|
+
if (signal.aborted)
|
|
302
|
+
throw abortedError();
|
|
303
|
+
if (timedOut)
|
|
304
|
+
throw runnerError('claude CLI runner timed out waiting for the CLI result');
|
|
305
|
+
if (error instanceof ClaudeCliQuotaError)
|
|
306
|
+
throw error;
|
|
307
|
+
if (error instanceof Error && error.name === 'ClaudeCliRunnerError')
|
|
308
|
+
throw error;
|
|
309
|
+
throw runnerError('claude CLI runner failed while reading CLI output');
|
|
310
|
+
}
|
|
311
|
+
finally {
|
|
312
|
+
clearTimeout(timer);
|
|
313
|
+
signal.removeEventListener('abort', onAbort);
|
|
314
|
+
await shutdown(child, isClosed);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
finally {
|
|
318
|
+
await rm(sandboxDir, { recursive: true, force: true }).catch(() => undefined);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
async *consume(child, prompt, stop) {
|
|
322
|
+
const stdout = child.stdout;
|
|
323
|
+
const stderr = child.stderr;
|
|
324
|
+
if (!stdout || !stderr)
|
|
325
|
+
throw runnerError('claude CLI runner lost the CLI pipes');
|
|
326
|
+
// Byte-capped tail: the pipe is always drained, but at most
|
|
327
|
+
// collectStderrBytes are retained (0 keeps nothing).
|
|
328
|
+
let stderrTail = Buffer.from('');
|
|
329
|
+
stderr.on('data', (chunk) => {
|
|
330
|
+
stderrTail = appendCappedTail(stderrTail, chunk, this.stderrTailBytes);
|
|
331
|
+
});
|
|
332
|
+
const failures = [];
|
|
333
|
+
child.once('error', (error) => { failures.push(error); });
|
|
334
|
+
const stdinError = new Promise((resolve) => {
|
|
335
|
+
child.stdin?.once('error', () => resolve());
|
|
336
|
+
child.stdin?.once('close', () => resolve());
|
|
337
|
+
});
|
|
338
|
+
const writePrompt = (async () => {
|
|
339
|
+
try {
|
|
340
|
+
if (!child.stdin)
|
|
341
|
+
return;
|
|
342
|
+
await new Promise((resolve, reject) => {
|
|
343
|
+
child.stdin.write(prompt, (error) => { if (error)
|
|
344
|
+
reject(error);
|
|
345
|
+
else
|
|
346
|
+
resolve(); });
|
|
347
|
+
child.stdin.end();
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
catch { /* the exit path below reports the failure */ }
|
|
351
|
+
})();
|
|
352
|
+
void stdinError;
|
|
353
|
+
const decoder = new StringDecoder('utf8');
|
|
354
|
+
let buffer = '';
|
|
355
|
+
let totalBytes = 0;
|
|
356
|
+
let toolCalls = 0;
|
|
357
|
+
let textEmitted = false;
|
|
358
|
+
let lastStopReason;
|
|
359
|
+
let sawInit = false;
|
|
360
|
+
let toolsInventory;
|
|
361
|
+
let mcpInventory;
|
|
362
|
+
let result;
|
|
363
|
+
let errorPayload;
|
|
364
|
+
const applyOutcome = (outcome) => {
|
|
365
|
+
if (outcome.type === 'system_init') {
|
|
366
|
+
sawInit = true;
|
|
367
|
+
toolsInventory = outcome.init.tools;
|
|
368
|
+
mcpInventory = outcome.init.mcpServers;
|
|
369
|
+
// Fail fast at the init line: a build ignoring `--tools ""` must be
|
|
370
|
+
// rejected before any further event is consumed or emitted.
|
|
371
|
+
if ((Array.isArray(toolsInventory) && toolsInventory.length > 0)
|
|
372
|
+
|| (Array.isArray(mcpInventory) && mcpInventory.length > 0)) {
|
|
373
|
+
throw runnerError('claude CLI runner refused a non-empty CLI tool inventory');
|
|
374
|
+
}
|
|
375
|
+
return [];
|
|
376
|
+
}
|
|
377
|
+
if (outcome.type === 'text') {
|
|
378
|
+
textEmitted = true;
|
|
379
|
+
return [{ type: 'text_delta', text: outcome.text }];
|
|
380
|
+
}
|
|
381
|
+
// Local tools are disabled at the CLI, so a tool_use block can only
|
|
382
|
+
// describe a server-side execution. It is republished verbatim; the
|
|
383
|
+
// non-empty init inventory above is the fail-closed enforcement point.
|
|
384
|
+
if (outcome.type === 'tool_use') {
|
|
385
|
+
toolCalls += 1;
|
|
386
|
+
return [outcome.event];
|
|
387
|
+
}
|
|
388
|
+
if (outcome.type === 'stop_reason') {
|
|
389
|
+
lastStopReason = outcome.reason;
|
|
390
|
+
return [];
|
|
391
|
+
}
|
|
392
|
+
if (outcome.type === 'result') {
|
|
393
|
+
result = outcome.result;
|
|
394
|
+
return [];
|
|
395
|
+
}
|
|
396
|
+
errorPayload = outcome.payload;
|
|
397
|
+
return [];
|
|
398
|
+
};
|
|
399
|
+
const exitCode = new Promise((resolve) => {
|
|
400
|
+
child.once('exit', (code) => resolve(code));
|
|
401
|
+
child.once('error', () => resolve(null));
|
|
402
|
+
});
|
|
403
|
+
try {
|
|
404
|
+
for await (const chunk of stdout) {
|
|
405
|
+
if (stop.aborted)
|
|
406
|
+
return;
|
|
407
|
+
totalBytes += chunk.length;
|
|
408
|
+
if (totalBytes > MAX_STDOUT_TOTAL_BYTES) {
|
|
409
|
+
throw runnerError('claude CLI runner refused an oversized CLI output');
|
|
410
|
+
}
|
|
411
|
+
buffer += decoder.write(chunk);
|
|
412
|
+
if (buffer.length > MAX_STDOUT_LINE_CHARS) {
|
|
413
|
+
throw runnerError('claude CLI runner refused an oversized CLI output line');
|
|
414
|
+
}
|
|
415
|
+
let boundary = buffer.indexOf('\n');
|
|
416
|
+
while (boundary >= 0) {
|
|
417
|
+
const line = buffer.slice(0, boundary).trim();
|
|
418
|
+
buffer = buffer.slice(boundary + 1);
|
|
419
|
+
boundary = buffer.indexOf('\n');
|
|
420
|
+
if (!line)
|
|
421
|
+
continue;
|
|
422
|
+
for (const outcome of parseClaudeCodeLine(line)) {
|
|
423
|
+
const events = applyOutcome(outcome);
|
|
424
|
+
for (const event of events)
|
|
425
|
+
yield event;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
// A final line without a trailing newline is still a line.
|
|
430
|
+
buffer += decoder.end();
|
|
431
|
+
if (buffer.trim().length > 0) {
|
|
432
|
+
for (const outcome of parseClaudeCodeLine(buffer.trim())) {
|
|
433
|
+
const events = applyOutcome(outcome);
|
|
434
|
+
for (const event of events)
|
|
435
|
+
yield event;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
catch (error) {
|
|
440
|
+
if (error instanceof Error && error.name === 'ClaudeCliRunnerError')
|
|
441
|
+
throw error;
|
|
442
|
+
throw runnerError('claude CLI runner failed while reading CLI output');
|
|
443
|
+
}
|
|
444
|
+
await writePrompt;
|
|
445
|
+
const code = await exitCode;
|
|
446
|
+
if (errorPayload !== undefined || result === undefined) {
|
|
447
|
+
const structuredText = errorPayload === undefined ? undefined : extractQuotaText(errorPayload);
|
|
448
|
+
const structured = structuredText === undefined
|
|
449
|
+
? { quota: false }
|
|
450
|
+
: diagnoseClaudeCodeQuota(structuredText);
|
|
451
|
+
const diagnosis = structured.quota
|
|
452
|
+
? structured
|
|
453
|
+
: diagnoseClaudeCodeQuota(stderrTail.toString('utf8'));
|
|
454
|
+
if (diagnosis.quota)
|
|
455
|
+
throw new ClaudeCliQuotaError(diagnosis.retryAfterMs);
|
|
456
|
+
if (code !== 0) {
|
|
457
|
+
const spawnFailure = failures.length > 0;
|
|
458
|
+
throw runnerError(spawnFailure
|
|
459
|
+
? 'claude CLI runner failed to run the CLI executable'
|
|
460
|
+
: `claude CLI runner exited with code ${String(code)}`);
|
|
461
|
+
}
|
|
462
|
+
throw runnerError('claude CLI runner ended without a CLI result');
|
|
463
|
+
}
|
|
464
|
+
// A successful run always observed the `init` line: without it the tool
|
|
465
|
+
// inventory gate above never ran, so the result is untrusted.
|
|
466
|
+
if (!sawInit)
|
|
467
|
+
throw runnerError('claude CLI runner ended without a CLI init line');
|
|
468
|
+
const finishReason = toolCalls > 0 ? 'tool_calls'
|
|
469
|
+
: lastStopReason === 'max_tokens' ? 'length' : result.finishReason;
|
|
470
|
+
if (result.resultText !== undefined && !textEmitted && result.resultText.trim().length > 0) {
|
|
471
|
+
yield { type: 'text_delta', text: result.resultText };
|
|
472
|
+
}
|
|
473
|
+
yield result.usage !== undefined
|
|
474
|
+
? { type: 'result', finishReason, usage: result.usage }
|
|
475
|
+
: { type: 'result', finishReason };
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Run one probe command with a token-free allowlist env inside the sandbox;
|
|
480
|
+
* never runs a workload. Output is byte-capped; stderr is drained.
|
|
481
|
+
*/
|
|
482
|
+
const runProbeCommand = (cliPath, args, env, sandboxDir, timeoutMs) => new Promise((resolve, reject) => {
|
|
483
|
+
let child;
|
|
484
|
+
try {
|
|
485
|
+
// Detached like the workload spawn so the timeout below can signal the
|
|
486
|
+
// whole group (killTree falls back to the direct child on win32).
|
|
487
|
+
child = spawn(cliPath, args, { env: env, stdio: ['ignore', 'pipe', 'pipe'],
|
|
488
|
+
cwd: sandboxDir, detached: process.platform !== 'win32' });
|
|
489
|
+
}
|
|
490
|
+
catch {
|
|
491
|
+
reject(runnerError('claude CLI probe failed to spawn the CLI'));
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
let closed = false;
|
|
495
|
+
child.once('close', () => { closed = true; });
|
|
496
|
+
const isClosed = () => closed;
|
|
497
|
+
let received = 0;
|
|
498
|
+
let output = Buffer.from('');
|
|
499
|
+
child.stdout?.on('data', (chunk) => {
|
|
500
|
+
received += chunk.length;
|
|
501
|
+
if (received <= MAX_PROBE_OUTPUT_BYTES)
|
|
502
|
+
output = Buffer.concat([output, chunk]);
|
|
503
|
+
});
|
|
504
|
+
child.stderr?.on('data', () => { });
|
|
505
|
+
const timer = setTimeout(() => {
|
|
506
|
+
killTree(child, isClosed, 'SIGKILL');
|
|
507
|
+
destroyPipes(child);
|
|
508
|
+
reject(runnerError('claude CLI probe timed out'));
|
|
509
|
+
}, timeoutMs);
|
|
510
|
+
timer.unref?.();
|
|
511
|
+
child.once('error', () => {
|
|
512
|
+
clearTimeout(timer);
|
|
513
|
+
reject(runnerError('claude CLI probe failed to run the CLI'));
|
|
514
|
+
});
|
|
515
|
+
// Resolve on `close`, not `exit`, so all stdio is drained: `exit` can fire
|
|
516
|
+
// while the last output bytes are still in flight. Buffer.concat keeps
|
|
517
|
+
// multi-byte characters split across chunks intact.
|
|
518
|
+
child.once('close', (code) => {
|
|
519
|
+
clearTimeout(timer);
|
|
520
|
+
if (code !== 0) {
|
|
521
|
+
reject(runnerError('claude CLI probe could not read the CLI'));
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
if (received > MAX_PROBE_OUTPUT_BYTES) {
|
|
525
|
+
reject(runnerError('claude CLI probe refused an oversized CLI output'));
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
resolve(output.toString('utf8'));
|
|
529
|
+
});
|
|
530
|
+
});
|
|
531
|
+
/** Probe `claude --version` and `claude --help` with a token-free env; never runs a workload. */
|
|
532
|
+
export const probeClaudeCodeCliCapabilities = (options) => {
|
|
533
|
+
if (!nonEmpty(options.source))
|
|
534
|
+
throw new Error('claude CLI probe needs a trusted source label');
|
|
535
|
+
if (!nonEmpty(options.qualificationRef))
|
|
536
|
+
throw new Error('claude CLI probe needs a qualification reference');
|
|
537
|
+
const cliPath = options.cliPath ?? DEFAULT_CLAUDE_CODE_CLI_PATH;
|
|
538
|
+
const timeoutMs = options.timeoutMs ?? CLAUDE_CODE_RESULT_TIMEOUT_MS;
|
|
539
|
+
return (async () => {
|
|
540
|
+
const sandboxDir = await mkdtemp(join(tmpdir(), 'claude-seat-probe-')).catch(() => {
|
|
541
|
+
throw runnerError('claude CLI probe failed to isolate the CLI workspace');
|
|
542
|
+
});
|
|
543
|
+
try {
|
|
544
|
+
const env = buildChildEnv(sandboxDir);
|
|
545
|
+
const version = await runProbeCommand(cliPath, ['--version'], env, sandboxDir, timeoutMs);
|
|
546
|
+
const match = /(\d+)\.(\d+)\.(\d+)/.exec(version);
|
|
547
|
+
const major = match === null ? NaN : Number(match[1]);
|
|
548
|
+
const minor = match === null ? NaN : Number(match[2]);
|
|
549
|
+
if (!Number.isSafeInteger(major) || !Number.isSafeInteger(minor)
|
|
550
|
+
|| major < MIN_CLAUDE_CODE_MAJOR || (major === MIN_CLAUDE_CODE_MAJOR && minor < MIN_CLAUDE_CODE_MINOR)) {
|
|
551
|
+
throw runnerError('claude CLI probe requires claude 2.1 or newer');
|
|
552
|
+
}
|
|
553
|
+
const help = await runProbeCommand(cliPath, ['--help'], env, sandboxDir, timeoutMs);
|
|
554
|
+
const missing = REQUIRED_CLAUDE_CODE_FLAGS.filter((flag) => !help.includes(flag));
|
|
555
|
+
if (missing.length > 0)
|
|
556
|
+
throw runnerError('claude CLI probe found a CLI missing confinement flags');
|
|
557
|
+
// Flags alone are not enough: the probe pins the stream-json value and
|
|
558
|
+
// the `-p` headless switch the runner relies on.
|
|
559
|
+
if (!help.includes('stream-json'))
|
|
560
|
+
throw runnerError('claude CLI probe found a CLI without stream-json output');
|
|
561
|
+
if (!/(^|\s)-p(\s|,|$)/m.test(help))
|
|
562
|
+
throw runnerError('claude CLI probe found a CLI without headless print mode');
|
|
563
|
+
return { protocol: CLAUDE_CODE_STREAM_PROTOCOL, cliVersion: `${major}.${minor}.${Number(match[3])}`,
|
|
564
|
+
source: options.source, qualificationRef: options.qualificationRef };
|
|
565
|
+
}
|
|
566
|
+
finally {
|
|
567
|
+
await rm(sandboxDir, { recursive: true, force: true }).catch(() => undefined);
|
|
568
|
+
}
|
|
569
|
+
})();
|
|
570
|
+
};
|
|
571
|
+
/**
|
|
572
|
+
* Factory for the consumer: builds the `clients.anthropic` runtime client
|
|
573
|
+
* over a dedicated Claude seat. Wire with
|
|
574
|
+
* `createDefaultProviderAdapters({ anthropic })`.
|
|
575
|
+
*/
|
|
576
|
+
export const createClaudeSeatAnthropicClient = (options) => {
|
|
577
|
+
const runner = new NodeClaudeCodeCliRunner({
|
|
578
|
+
...(options.cliPath !== undefined ? { cliPath: options.cliPath } : {}),
|
|
579
|
+
...(options.effort !== undefined ? { effort: options.effort } : {}),
|
|
580
|
+
...(options.systemPromptFile !== undefined ? { systemPromptFile: options.systemPromptFile } : {}),
|
|
581
|
+
...(options.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : {}),
|
|
582
|
+
});
|
|
583
|
+
return new ClaudeCodeRuntimeClient({
|
|
584
|
+
runner,
|
|
585
|
+
capabilities: { ...options.capabilities },
|
|
586
|
+
...(options.fallback !== undefined ? { fallback: options.fallback } : {}),
|
|
587
|
+
...(options.now !== undefined ? { now: options.now } : {}),
|
|
588
|
+
});
|
|
589
|
+
};
|
|
590
|
+
//# sourceMappingURL=claude-code-cli-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude-code-cli-runner.js","sourceRoot":"","sources":["../../src/node/claude-code-cli-runner.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,sEAAsE;AACtE,oEAAoE;AACpE,sBAAsB;AACtB,EAAE;AACF,+DAA+D;AAC/D,2EAA2E;AAC3E,4EAA4E;AAC5E,iEAAiE;AACjE,8EAA8E;AAC9E,6EAA6E;AAC7E,uEAAuE;AACvE,yEAAyE;AACzE,2EAA2E;AAC3E,4EAA4E;AAC5E,sEAAsE;AACtE,2EAA2E;AAC3E,yEAAyE;AACzE,yEAAyE;AACzE,mEAAmE;AACnE,yEAAyE;AACzE,0EAA0E;AAC1E,qCAAqC;AAErC,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,E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