@rcrsr/rill-ext-claude-code 0.8.6 → 0.11.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rcrsr/rill-ext-claude-code",
3
- "version": "0.8.6",
3
+ "version": "0.11.0",
4
4
  "description": "rill extension for Claude Code CLI integration",
5
5
  "license": "MIT",
6
6
  "author": "Andre Bremer",
@@ -17,33 +17,38 @@
17
17
  "scripting"
18
18
  ],
19
19
  "peerDependencies": {
20
- "node-pty": "^1.0.0",
21
- "@rcrsr/rill": "^0.8.6"
20
+ "@rcrsr/rill": "^0.11.0",
21
+ "node-pty": "^1.0.0"
22
22
  },
23
23
  "devDependencies": {
24
+ "@rcrsr/rill": "^0.11.0",
25
+ "@types/node": "^25.3.0",
24
26
  "@types/which": "^3.0.4",
25
- "@rcrsr/rill": "^0.8.6"
27
+ "dts-bundle-generator": "^9.5.1",
28
+ "tsup": "^8.5.1",
29
+ "undici-types": "^7.22.0"
26
30
  },
27
31
  "files": [
28
32
  "dist"
29
33
  ],
30
34
  "repository": {
31
35
  "type": "git",
32
- "url": "git+https://github.com/rcrsr/rill.git",
36
+ "url": "git+https://github.com/rcrsr/rill-ext.git",
33
37
  "directory": "packages/ext/claude-code"
34
38
  },
35
- "homepage": "https://rill.run/docs/extensions/claude-code/",
39
+ "homepage": "https://github.com/rcrsr/rill-ext/tree/main/packages/ext/claude-code#readme",
36
40
  "bugs": {
37
- "url": "https://github.com/rcrsr/rill/issues"
41
+ "url": "https://github.com/rcrsr/rill-ext/issues"
38
42
  },
39
43
  "publishConfig": {
40
44
  "access": "public"
41
45
  },
42
46
  "dependencies": {
43
- "which": "^6.0.0"
47
+ "which": "^6.0.1",
48
+ "@rcrsr/rill-ext-param-shared": "0.0.1"
44
49
  },
45
50
  "scripts": {
46
- "build": "tsc --build",
51
+ "build": "tsup && dts-bundle-generator --config dts-bundle-generator.config.cjs",
47
52
  "test": "vitest run",
48
53
  "typecheck": "tsc --noEmit",
49
54
  "lint": "eslint --config ../../../eslint.config.js src/",
package/dist/factory.d.ts DELETED
@@ -1,26 +0,0 @@
1
- /**
2
- * Extension factory for Claude Code integration.
3
- * Creates extension instance with config validation and process lifecycle management.
4
- */
5
- import { type ExtensionResult } from '@rcrsr/rill';
6
- import type { ClaudeCodeConfig } from './types.js';
7
- /**
8
- * Create Claude Code extension instance.
9
- * Validates configuration and returns host functions with cleanup.
10
- *
11
- * @param config - Extension configuration
12
- * @returns ExtensionResult with prompt, skill, command functions and dispose
13
- * @throws Error for invalid configuration (EC-1, EC-2)
14
- *
15
- * @example
16
- * ```typescript
17
- * const ext = createClaudeCodeExtension({
18
- * binaryPath: '/usr/local/bin/claude',
19
- * defaultTimeout: 60000
20
- * });
21
- * // Use with rill runtime...
22
- * await ext.dispose();
23
- * ```
24
- */
25
- export declare function createClaudeCodeExtension(config?: ClaudeCodeConfig): ExtensionResult;
26
- //# sourceMappingURL=factory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAGL,KAAK,eAAe,EAGrB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,gBAAgB,EAAiB,MAAM,YAAY,CAAC;AAwGlE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,GAAE,gBAAqB,GAC5B,eAAe,CA2TjB"}
package/dist/factory.js DELETED
@@ -1,376 +0,0 @@
1
- /**
2
- * Extension factory for Claude Code integration.
3
- * Creates extension instance with config validation and process lifecycle management.
4
- */
5
- import which from 'which';
6
- import { RuntimeError, emitExtensionEvent, } from '@rcrsr/rill';
7
- import { spawnClaudeCli } from './process.js';
8
- import { createStreamParser } from './stream-parser.js';
9
- import { extractResult } from './result.js';
10
- // ============================================================
11
- // CONSTANTS
12
- // ============================================================
13
- const DEFAULT_BINARY_PATH = 'claude';
14
- const DEFAULT_TIMEOUT = 1800000;
15
- const MAX_TIMEOUT = 3600000;
16
- // ============================================================
17
- // HELPER FUNCTIONS
18
- // ============================================================
19
- /**
20
- * Serialize dict args to CLI flags for skill/command.
21
- * Boolean true values become flags without value, nested dicts use dot-notation.
22
- *
23
- * @param args - Dict of arguments to serialize
24
- * @returns Array of CLI flag strings
25
- */
26
- function serializeArgsToFlags(args) {
27
- const flags = [];
28
- for (const [key, value] of Object.entries(args)) {
29
- if (value === true) {
30
- // Boolean true: flag without value
31
- flags.push(`--${key}`);
32
- }
33
- else if (typeof value === 'object' &&
34
- value !== null &&
35
- !Array.isArray(value)) {
36
- // Nested dict: dot-notation
37
- const nested = value;
38
- for (const [nestedKey, nestedValue] of Object.entries(nested)) {
39
- flags.push(`--${key}.${nestedKey}`, String(nestedValue));
40
- }
41
- }
42
- else {
43
- // Other values: key-value pair
44
- flags.push(`--${key}`, String(value));
45
- }
46
- }
47
- return flags;
48
- }
49
- /**
50
- * Truncate text to max length for event logging.
51
- *
52
- * @param text - Text to truncate
53
- * @param maxLength - Maximum length (default: 100)
54
- * @returns Truncated text with ellipsis if needed
55
- */
56
- function truncateText(text, maxLength = 100) {
57
- if (text.length <= maxLength) {
58
- return text;
59
- }
60
- return text.slice(0, maxLength) + '...';
61
- }
62
- // ============================================================
63
- // VALIDATION
64
- // ============================================================
65
- /**
66
- * Validate timeout is positive integer within bounds.
67
- *
68
- * @param timeout - Timeout in milliseconds
69
- * @throws Error if timeout invalid
70
- */
71
- function validateTimeout(timeout) {
72
- if (!Number.isInteger(timeout)) {
73
- throw new Error('Invalid timeout: must be positive integer, max 3600000');
74
- }
75
- if (timeout <= 0) {
76
- throw new Error('Invalid timeout: must be positive integer, max 3600000');
77
- }
78
- if (timeout > MAX_TIMEOUT) {
79
- throw new Error('Invalid timeout: must be positive integer, max 3600000');
80
- }
81
- }
82
- // ============================================================
83
- // FACTORY
84
- // ============================================================
85
- /**
86
- * Create Claude Code extension instance.
87
- * Validates configuration and returns host functions with cleanup.
88
- *
89
- * @param config - Extension configuration
90
- * @returns ExtensionResult with prompt, skill, command functions and dispose
91
- * @throws Error for invalid configuration (EC-1, EC-2)
92
- *
93
- * @example
94
- * ```typescript
95
- * const ext = createClaudeCodeExtension({
96
- * binaryPath: '/usr/local/bin/claude',
97
- * defaultTimeout: 60000
98
- * });
99
- * // Use with rill runtime...
100
- * await ext.dispose();
101
- * ```
102
- */
103
- export function createClaudeCodeExtension(config = {}) {
104
- // Extract config with defaults
105
- const binaryPath = config.binaryPath ?? DEFAULT_BINARY_PATH;
106
- const defaultTimeout = config.defaultTimeout ?? DEFAULT_TIMEOUT;
107
- const dangerouslySkipPermissions = config.dangerouslySkipPermissions ?? true;
108
- const settingSources = config.settingSources ?? '';
109
- // Validate timeout immediately
110
- validateTimeout(defaultTimeout);
111
- // Validate binary path eagerly (sync throw if not in PATH)
112
- try {
113
- which.sync(binaryPath);
114
- }
115
- catch {
116
- throw new Error(`Binary not found: ${binaryPath}`);
117
- }
118
- // Track active processes for cleanup
119
- const tracker = {
120
- disposers: new Set(),
121
- };
122
- // Dispose function for cleanup
123
- const dispose = () => {
124
- // EC-16: Cleanup failure logs warning, doesn't throw
125
- for (const disposer of tracker.disposers) {
126
- try {
127
- disposer();
128
- }
129
- catch (error) {
130
- const message = error instanceof Error ? error.message : 'Unknown error';
131
- console.warn(`Failed to cleanup process: ${message}`);
132
- }
133
- }
134
- tracker.disposers.clear();
135
- };
136
- // Return extension result with implementations
137
- const result = {
138
- // IR-2: claude-code::prompt
139
- prompt: {
140
- params: [
141
- { name: 'text', type: 'string' },
142
- { name: 'options', type: 'dict', defaultValue: {} },
143
- ],
144
- fn: async (args, ctx) => {
145
- const startTime = Date.now();
146
- try {
147
- // Extract arguments
148
- const text = args[0];
149
- const options = (args[1] ?? {});
150
- // EC-3: Validate text is non-empty
151
- if (text.trim().length === 0) {
152
- throw new RuntimeError('RILL-R004', 'prompt text cannot be empty');
153
- }
154
- // Extract timeout option
155
- const timeout = typeof options['timeout'] === 'number'
156
- ? options['timeout']
157
- : defaultTimeout;
158
- // Spawn process and collect messages
159
- const spawn = spawnClaudeCli(text, {
160
- binaryPath,
161
- timeoutMs: timeout,
162
- dangerouslySkipPermissions,
163
- settingSources,
164
- });
165
- // Register cleanup
166
- tracker.disposers.add(spawn.dispose);
167
- // Parse stream output
168
- const parser = createStreamParser();
169
- const messages = [];
170
- spawn.ptyProcess.onData((chunk) => {
171
- parser.processChunk(chunk, (msg) => messages.push(msg));
172
- });
173
- // Wait for process completion
174
- try {
175
- await spawn.exitCode;
176
- parser.flush((msg) => messages.push(msg));
177
- }
178
- finally {
179
- tracker.disposers.delete(spawn.dispose);
180
- spawn.dispose();
181
- }
182
- // Extract result
183
- const result = extractResult(messages);
184
- // AC-17: Emit claude-code:prompt event
185
- const duration = Date.now() - startTime;
186
- emitExtensionEvent(ctx, {
187
- event: 'claude-code:prompt',
188
- subsystem: 'extension:claude-code',
189
- prompt: truncateText(text),
190
- duration,
191
- });
192
- // Convert to plain object literal for RillValue compatibility
193
- return {
194
- ...result,
195
- tokens: { ...result.tokens },
196
- };
197
- }
198
- catch (error) {
199
- // AC-20: Emit claude-code:error event
200
- const duration = Date.now() - startTime;
201
- emitExtensionEvent(ctx, {
202
- event: 'claude-code:error',
203
- subsystem: 'extension:claude-code',
204
- error: error instanceof Error ? error.message : 'Unknown error',
205
- duration,
206
- });
207
- throw error;
208
- }
209
- },
210
- description: 'Execute Claude Code prompt and return result text and token usage',
211
- returnType: 'dict',
212
- },
213
- // IR-3: claude-code::skill
214
- skill: {
215
- params: [
216
- { name: 'name', type: 'string' },
217
- { name: 'args', type: 'dict', defaultValue: {} },
218
- ],
219
- fn: async (fnArgs, ctx) => {
220
- const startTime = Date.now();
221
- try {
222
- // Extract arguments
223
- const name = fnArgs[0];
224
- const args = (fnArgs[1] ?? {});
225
- // EC-10: Validate name is non-empty
226
- if (name.trim().length === 0) {
227
- throw new RuntimeError('RILL-R004', 'skill name cannot be empty');
228
- }
229
- // Format input as /{name} {serialized args}
230
- const flags = serializeArgsToFlags(args);
231
- const flagsText = flags.length > 0 ? ' ' + flags.join(' ') : '';
232
- const prompt = `/${name}${flagsText}`;
233
- // Extract timeout option
234
- const timeout = typeof args['timeout'] === 'number'
235
- ? args['timeout']
236
- : defaultTimeout;
237
- // Spawn process
238
- const spawn = spawnClaudeCli(prompt, {
239
- binaryPath,
240
- timeoutMs: timeout,
241
- dangerouslySkipPermissions,
242
- settingSources,
243
- });
244
- tracker.disposers.add(spawn.dispose);
245
- // Parse stream output
246
- const parser = createStreamParser();
247
- const messages = [];
248
- spawn.ptyProcess.onData((chunk) => {
249
- parser.processChunk(chunk, (msg) => messages.push(msg));
250
- });
251
- // Wait for process completion
252
- try {
253
- await spawn.exitCode;
254
- parser.flush((msg) => messages.push(msg));
255
- }
256
- finally {
257
- tracker.disposers.delete(spawn.dispose);
258
- spawn.dispose();
259
- }
260
- // Extract result
261
- const result = extractResult(messages);
262
- // AC-18: Emit claude-code:skill event
263
- const duration = Date.now() - startTime;
264
- emitExtensionEvent(ctx, {
265
- event: 'claude-code:skill',
266
- subsystem: 'extension:claude-code',
267
- name,
268
- args,
269
- duration,
270
- });
271
- // Convert to plain object literal for RillValue compatibility
272
- return {
273
- ...result,
274
- tokens: { ...result.tokens },
275
- };
276
- }
277
- catch (error) {
278
- // AC-20: Emit claude-code:error event
279
- const duration = Date.now() - startTime;
280
- emitExtensionEvent(ctx, {
281
- event: 'claude-code:error',
282
- subsystem: 'extension:claude-code',
283
- error: error instanceof Error ? error.message : 'Unknown error',
284
- duration,
285
- });
286
- throw error;
287
- }
288
- },
289
- description: 'Execute Claude Code skill with instruction and return structured result',
290
- returnType: 'dict',
291
- },
292
- // IR-4: claude-code::command
293
- command: {
294
- params: [
295
- { name: 'name', type: 'string' },
296
- { name: 'args', type: 'dict', defaultValue: {} },
297
- ],
298
- fn: async (fnArgs, ctx) => {
299
- const startTime = Date.now();
300
- try {
301
- // Extract arguments
302
- const name = fnArgs[0];
303
- const args = (fnArgs[1] ?? {});
304
- // EC-13: Validate name is non-empty
305
- if (name.trim().length === 0) {
306
- throw new RuntimeError('RILL-R004', 'command name cannot be empty');
307
- }
308
- // Format input similar to skill
309
- const flags = serializeArgsToFlags(args);
310
- const flagsText = flags.length > 0 ? ' ' + flags.join(' ') : '';
311
- const prompt = `/${name}${flagsText}`;
312
- // Extract timeout option
313
- const timeout = typeof args['timeout'] === 'number'
314
- ? args['timeout']
315
- : defaultTimeout;
316
- // Spawn process
317
- const spawn = spawnClaudeCli(prompt, {
318
- binaryPath,
319
- timeoutMs: timeout,
320
- dangerouslySkipPermissions,
321
- settingSources,
322
- });
323
- tracker.disposers.add(spawn.dispose);
324
- // Parse stream output
325
- const parser = createStreamParser();
326
- const messages = [];
327
- spawn.ptyProcess.onData((chunk) => {
328
- parser.processChunk(chunk, (msg) => messages.push(msg));
329
- });
330
- // Wait for process completion
331
- try {
332
- await spawn.exitCode;
333
- parser.flush((msg) => messages.push(msg));
334
- }
335
- finally {
336
- tracker.disposers.delete(spawn.dispose);
337
- spawn.dispose();
338
- }
339
- // Extract result
340
- const result = extractResult(messages);
341
- // AC-19: Emit claude-code:command event
342
- const duration = Date.now() - startTime;
343
- emitExtensionEvent(ctx, {
344
- event: 'claude-code:command',
345
- subsystem: 'extension:claude-code',
346
- name,
347
- args,
348
- duration,
349
- });
350
- // Convert to plain object literal for RillValue compatibility
351
- return {
352
- ...result,
353
- tokens: { ...result.tokens },
354
- };
355
- }
356
- catch (error) {
357
- // AC-20: Emit claude-code:error event
358
- const duration = Date.now() - startTime;
359
- emitExtensionEvent(ctx, {
360
- event: 'claude-code:error',
361
- subsystem: 'extension:claude-code',
362
- error: error instanceof Error ? error.message : 'Unknown error',
363
- duration,
364
- });
365
- throw error;
366
- }
367
- },
368
- description: 'Execute Claude Code command with task description and return execution summary',
369
- returnType: 'dict',
370
- },
371
- };
372
- // IR-5: Dispose function for process cleanup
373
- result.dispose = dispose;
374
- return result;
375
- }
376
- //# sourceMappingURL=factory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,kBAAkB,GAInB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAc5C,+DAA+D;AAC/D,YAAY;AACZ,+DAA+D;AAE/D,MAAM,mBAAmB,GAAG,QAAQ,CAAC;AACrC,MAAM,eAAe,GAAG,OAAO,CAAC;AAChC,MAAM,WAAW,GAAG,OAAO,CAAC;AAE5B,+DAA+D;AAC/D,mBAAmB;AACnB,+DAA+D;AAE/D;;;;;;GAMG;AACH,SAAS,oBAAoB,CAAC,IAA6B;IACzD,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,mCAAmC;YACnC,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;QACzB,CAAC;aAAM,IACL,OAAO,KAAK,KAAK,QAAQ;YACzB,KAAK,KAAK,IAAI;YACd,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EACrB,CAAC;YACD,4BAA4B;YAC5B,MAAM,MAAM,GAAG,KAAgC,CAAC;YAChD,KAAK,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC9D,KAAK,CAAC,IAAI,CAAC,KA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AC;AAM5C,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAM9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,+DAA+D;AAC/D,UAAU;AACV,+DAA+D;AAE/D,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AA4B/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,+DAA+D;AAC/D,oBAAoB;AACpB,+DAA+D;AAE/D,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAO5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,+DAA+D;AAC/D,oBAAoB;AACpB,+DAA+D;AAE/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC"}
package/dist/process.d.ts DELETED
@@ -1,44 +0,0 @@
1
- /**
2
- * Process manager for Claude CLI spawning and lifecycle.
3
- * Handles PTY spawn, timeout enforcement, and cleanup.
4
- */
5
- import * as pty from 'node-pty';
6
- /**
7
- * Process spawn result.
8
- * Includes PTY instance and cleanup function.
9
- */
10
- export interface SpawnResult {
11
- /** PTY process instance */
12
- readonly ptyProcess: pty.IPty;
13
- /** Exit code promise (resolves when process exits) */
14
- readonly exitCode: Promise<number>;
15
- /** Cleanup function (kills process if running) */
16
- readonly dispose: () => void;
17
- }
18
- /**
19
- * Options for spawning Claude CLI process.
20
- */
21
- export interface SpawnOptions {
22
- /** Path to Claude CLI binary (default: 'claude') */
23
- readonly binaryPath?: string | undefined;
24
- /** Timeout in milliseconds (kills process after duration) */
25
- readonly timeoutMs?: number | undefined;
26
- /** Working directory for process (default: inherit) */
27
- readonly cwd?: string | undefined;
28
- /** Environment variables (default: inherit) */
29
- readonly env?: Record<string, string | undefined> | undefined;
30
- /** Skip permission checks (default: true) */
31
- readonly dangerouslySkipPermissions?: boolean | undefined;
32
- /** Setting sources to load: 'user', 'project', 'local' (default: '') */
33
- readonly settingSources?: string | undefined;
34
- }
35
- /**
36
- * Spawn Claude CLI process with timeout enforcement.
37
- *
38
- * @param prompt - User prompt to send to Claude
39
- * @param options - Spawn options
40
- * @returns Process handle with exit code and cleanup
41
- * @throws RuntimeError RILL-R004 for spawn failures
42
- */
43
- export declare function spawnClaudeCli(prompt: string, options?: SpawnOptions): SpawnResult;
44
- //# sourceMappingURL=process.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAOhC;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,2BAA2B;IAC3B,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,IAAI,CAAC;IAC9B,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACnC,kDAAkD;IAClD,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,6DAA6D;IAC7D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,uDAAuD;IACvD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,+CAA+C;IAC/C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;IAC9D,6CAA6C;IAC7C,QAAQ,CAAC,0BAA0B,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1D,wEAAwE;IACxE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9C;AAMD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,YAAiB,GACzB,WAAW,CAkKb"}
package/dist/process.js DELETED
@@ -1,125 +0,0 @@
1
- /**
2
- * Process manager for Claude CLI spawning and lifecycle.
3
- * Handles PTY spawn, timeout enforcement, and cleanup.
4
- */
5
- import * as pty from 'node-pty';
6
- import { RuntimeError } from '@rcrsr/rill';
7
- // ============================================================
8
- // SPAWN FUNCTION
9
- // ============================================================
10
- /**
11
- * Spawn Claude CLI process with timeout enforcement.
12
- *
13
- * @param prompt - User prompt to send to Claude
14
- * @param options - Spawn options
15
- * @returns Process handle with exit code and cleanup
16
- * @throws RuntimeError RILL-R004 for spawn failures
17
- */
18
- export function spawnClaudeCli(prompt, options = {}) {
19
- const { binaryPath = 'claude', timeoutMs, cwd = process.cwd(), env = process.env, dangerouslySkipPermissions = true, settingSources = '', } = options;
20
- // Build CLI args
21
- const args = [
22
- '-p',
23
- prompt,
24
- '--output-format',
25
- 'stream-json',
26
- '--verbose',
27
- '--no-session-persistence',
28
- '--setting-sources',
29
- settingSources,
30
- ];
31
- if (dangerouslySkipPermissions) {
32
- args.push('--dangerously-skip-permissions');
33
- }
34
- // Track timeout and process state
35
- let timeoutId;
36
- let disposed = false;
37
- // Create promise for exit code
38
- let resolveExit;
39
- let rejectExit;
40
- const exitCode = new Promise((resolve, reject) => {
41
- resolveExit = resolve;
42
- rejectExit = reject;
43
- });
44
- // Spawn process
45
- let ptyProcess;
46
- try {
47
- ptyProcess = pty.spawn(binaryPath, args, {
48
- name: 'xterm-256color',
49
- cols: 80,
50
- rows: 30,
51
- cwd,
52
- env,
53
- });
54
- }
55
- catch (error) {
56
- // Handle spawn errors
57
- if (error instanceof Error) {
58
- const code = error.code;
59
- // EC-4: Binary not found
60
- if (code === 'ENOENT') {
61
- throw new RuntimeError('RILL-R004', 'claude binary not found', undefined, { binaryPath });
62
- }
63
- // EC-5: Permission denied
64
- if (code === 'EACCES') {
65
- throw new RuntimeError('RILL-R004', 'Permission denied: claude', undefined, { binaryPath });
66
- }
67
- // EC-6: Generic spawn failure
68
- throw new RuntimeError('RILL-R004', `Failed to spawn claude binary: ${error.message}`, undefined, { binaryPath, originalError: error.message });
69
- }
70
- // Unknown error type
71
- throw new RuntimeError('RILL-R004', `Failed to spawn claude binary: Unknown error`, undefined, { binaryPath });
72
- }
73
- // Set up timeout enforcement
74
- if (timeoutMs !== undefined && timeoutMs > 0) {
75
- timeoutId = setTimeout(() => {
76
- if (!disposed) {
77
- disposed = true;
78
- ptyProcess.kill();
79
- rejectExit(new RuntimeError('RILL-R004', `Claude CLI timeout after ${timeoutMs}ms`, undefined, { timeoutMs }));
80
- }
81
- }, timeoutMs);
82
- }
83
- // Handle process exit
84
- ptyProcess.onExit((event) => {
85
- if (timeoutId) {
86
- clearTimeout(timeoutId);
87
- }
88
- if (!disposed) {
89
- disposed = true;
90
- const { exitCode: code } = event;
91
- // EC-9: Non-zero exit code
92
- if (code !== 0) {
93
- rejectExit(new RuntimeError('RILL-R004', `Claude CLI exited with code ${code}`, undefined, { exitCode: code }));
94
- }
95
- else {
96
- resolveExit(code);
97
- }
98
- }
99
- });
100
- // Cleanup function
101
- const dispose = () => {
102
- if (disposed) {
103
- return;
104
- }
105
- disposed = true;
106
- if (timeoutId) {
107
- clearTimeout(timeoutId);
108
- }
109
- // EC-16: Cleanup failure warning
110
- try {
111
- ptyProcess.kill();
112
- }
113
- catch (error) {
114
- // Log warning but don't throw
115
- const message = error instanceof Error ? error.message : 'Unknown error';
116
- console.warn(`Failed to kill claude process during cleanup: ${message}`);
117
- }
118
- };
119
- return {
120
- ptyProcess,
121
- exitCode,
122
- dispose,
123
- };
124
- }
125
- //# sourceMappingURL=process.js.map