@scottwalker/claude-connector 0.2.0 → 0.4.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 +249 -21
- package/dist/builder/args-builder.d.ts +2 -1
- package/dist/builder/args-builder.d.ts.map +1 -1
- package/dist/builder/args-builder.js +38 -31
- package/dist/builder/args-builder.js.map +1 -1
- package/dist/client/chat-handle.d.ts +115 -0
- package/dist/client/chat-handle.d.ts.map +1 -0
- package/dist/client/chat-handle.js +246 -0
- package/dist/client/chat-handle.js.map +1 -0
- package/dist/client/claude.d.ts +96 -55
- package/dist/client/claude.d.ts.map +1 -1
- package/dist/client/claude.js +192 -46
- package/dist/client/claude.js.map +1 -1
- package/dist/client/session.d.ts +4 -2
- package/dist/client/session.d.ts.map +1 -1
- package/dist/client/session.js +19 -12
- package/dist/client/session.js.map +1 -1
- package/dist/client/stream-handle.d.ts +99 -0
- package/dist/client/stream-handle.d.ts.map +1 -0
- package/dist/client/stream-handle.js +173 -0
- package/dist/client/stream-handle.js.map +1 -0
- package/dist/constants.d.ts +119 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +164 -0
- package/dist/constants.js.map +1 -0
- package/dist/errors/errors.d.ts.map +1 -1
- package/dist/errors/errors.js +7 -6
- package/dist/errors/errors.js.map +1 -1
- package/dist/executor/cli-executor.d.ts.map +1 -1
- package/dist/executor/cli-executor.js +34 -11
- package/dist/executor/cli-executor.js.map +1 -1
- package/dist/executor/interface.d.ts +5 -0
- package/dist/executor/interface.d.ts.map +1 -1
- package/dist/executor/sdk-executor.d.ts +143 -26
- package/dist/executor/sdk-executor.d.ts.map +1 -1
- package/dist/executor/sdk-executor.js +417 -88
- package/dist/executor/sdk-executor.js.map +1 -1
- package/dist/index.d.ts +74 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +82 -4
- package/dist/index.js.map +1 -1
- package/dist/parser/json-parser.d.ts.map +1 -1
- package/dist/parser/json-parser.js +20 -19
- package/dist/parser/json-parser.js.map +1 -1
- package/dist/parser/stream-parser.d.ts.map +1 -1
- package/dist/parser/stream-parser.js +26 -25
- package/dist/parser/stream-parser.js.map +1 -1
- package/dist/scheduler/scheduler.js +6 -11
- package/dist/scheduler/scheduler.js.map +1 -1
- package/dist/types/client.d.ts +343 -3
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/result.d.ts +116 -1
- package/dist/types/result.d.ts.map +1 -1
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +5 -6
- package/dist/utils/validation.js.map +1 -1
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="etc/
|
|
2
|
+
<img src="etc/origin.png" alt="Claude Connector" width="350" style="border-radius: 16px" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<h1 align="center">Claude Connector</h1>
|
|
@@ -22,6 +22,7 @@ Claude Code is a powerful AI coding agent, but it only runs in a terminal. **cla
|
|
|
22
22
|
- **Two execution modes** — persistent SDK session (fast, default) or CLI process spawning (simple)
|
|
23
23
|
- **Executor abstraction** — swap CLI for SDK or HTTP backend without changing your code
|
|
24
24
|
- **Full CLI parity** — exposes all 45+ Claude Code flags through typed options
|
|
25
|
+
- **Typed handles** — `StreamHandle` (fluent `.on().done()` + `for-await`) and `ChatHandle` (multi-turn conversations)
|
|
25
26
|
|
|
26
27
|
## Requirements
|
|
27
28
|
|
|
@@ -37,9 +38,9 @@ npm install @scottwalker/claude-connector
|
|
|
37
38
|
## Quick Start
|
|
38
39
|
|
|
39
40
|
```typescript
|
|
40
|
-
import { Claude } from '@scottwalker/claude-connector'
|
|
41
|
+
import { Claude, PERMISSION_ACCEPT_EDITS } from '@scottwalker/claude-connector'
|
|
41
42
|
|
|
42
|
-
const claude = new Claude()
|
|
43
|
+
const claude = new Claude({ permissionMode: PERMISSION_ACCEPT_EDITS })
|
|
43
44
|
|
|
44
45
|
// Simple query
|
|
45
46
|
const result = await claude.query('Find and fix bugs in auth.ts')
|
|
@@ -55,6 +56,8 @@ console.log(result.usage) // { inputTokens, outputTokens }
|
|
|
55
56
|
Point to a specific Claude Code installation when multiple versions coexist:
|
|
56
57
|
|
|
57
58
|
```typescript
|
|
59
|
+
import { Claude } from '@scottwalker/claude-connector'
|
|
60
|
+
|
|
58
61
|
const claude = new Claude({
|
|
59
62
|
executable: '/opt/claude-code/v2/bin/claude',
|
|
60
63
|
cwd: '/path/to/project',
|
|
@@ -63,21 +66,41 @@ const claude = new Claude({
|
|
|
63
66
|
|
|
64
67
|
### Streaming
|
|
65
68
|
|
|
66
|
-
Real-time output as Claude works
|
|
69
|
+
Real-time output as Claude works. `stream()` returns a `StreamHandle` — use the fluent `.on().done()` API or classic `for-await`:
|
|
67
70
|
|
|
68
71
|
```typescript
|
|
69
|
-
|
|
72
|
+
import {
|
|
73
|
+
Claude,
|
|
74
|
+
EVENT_TEXT, EVENT_TOOL_USE, EVENT_RESULT, EVENT_ERROR,
|
|
75
|
+
} from '@scottwalker/claude-connector'
|
|
76
|
+
|
|
77
|
+
const claude = new Claude()
|
|
78
|
+
|
|
79
|
+
// Fluent API (.on / .done)
|
|
80
|
+
const result = await claude
|
|
81
|
+
.stream('Rewrite the auth module')
|
|
82
|
+
.on(EVENT_TEXT, (e) => process.stdout.write(e.text))
|
|
83
|
+
.on(EVENT_TOOL_USE, (e) => console.log(`[Tool] ${e.toolName}`))
|
|
84
|
+
.on(EVENT_ERROR, (e) => console.error(e.message))
|
|
85
|
+
.done()
|
|
86
|
+
|
|
87
|
+
console.log(`Done in ${result.durationMs}ms`)
|
|
88
|
+
|
|
89
|
+
// Classic for-await
|
|
90
|
+
const handle = claude.stream('Rewrite the auth module')
|
|
91
|
+
|
|
92
|
+
for await (const event of handle) {
|
|
70
93
|
switch (event.type) {
|
|
71
|
-
case
|
|
94
|
+
case EVENT_TEXT:
|
|
72
95
|
process.stdout.write(event.text)
|
|
73
96
|
break
|
|
74
|
-
case
|
|
97
|
+
case EVENT_TOOL_USE:
|
|
75
98
|
console.log(`[Tool] ${event.toolName}`)
|
|
76
99
|
break
|
|
77
|
-
case
|
|
100
|
+
case EVENT_RESULT:
|
|
78
101
|
console.log(`\nDone in ${event.durationMs}ms`)
|
|
79
102
|
break
|
|
80
|
-
case
|
|
103
|
+
case EVENT_ERROR:
|
|
81
104
|
console.error(event.message)
|
|
82
105
|
break
|
|
83
106
|
}
|
|
@@ -89,6 +112,9 @@ for await (const event of claude.stream('Rewrite the auth module')) {
|
|
|
89
112
|
Maintain conversation context across queries:
|
|
90
113
|
|
|
91
114
|
```typescript
|
|
115
|
+
import { Claude } from '@scottwalker/claude-connector'
|
|
116
|
+
|
|
117
|
+
const claude = new Claude()
|
|
92
118
|
const session = claude.session()
|
|
93
119
|
await session.query('Analyze the architecture of this project')
|
|
94
120
|
await session.query('Now refactor the auth module based on your analysis')
|
|
@@ -107,6 +133,9 @@ const s3 = claude.session({ resume: session.sessionId!, fork: true })
|
|
|
107
133
|
Get typed JSON responses via JSON Schema:
|
|
108
134
|
|
|
109
135
|
```typescript
|
|
136
|
+
import { Claude } from '@scottwalker/claude-connector'
|
|
137
|
+
|
|
138
|
+
const claude = new Claude()
|
|
110
139
|
const result = await claude.query('Extract all API endpoints from the codebase', {
|
|
111
140
|
schema: {
|
|
112
141
|
type: 'object',
|
|
@@ -134,10 +163,14 @@ console.log(result.structured)
|
|
|
134
163
|
Run independent queries concurrently (each spawns a separate CLI process):
|
|
135
164
|
|
|
136
165
|
```typescript
|
|
166
|
+
import { Claude, PERMISSION_PLAN } from '@scottwalker/claude-connector'
|
|
167
|
+
|
|
168
|
+
const claude = new Claude()
|
|
169
|
+
|
|
137
170
|
const [bugs, tests, docs] = await claude.parallel([
|
|
138
171
|
{ prompt: 'Find bugs in src/', options: { cwd: './src' } },
|
|
139
172
|
{ prompt: 'Run the test suite', options: { allowedTools: ['Bash'] } },
|
|
140
|
-
{ prompt: 'Review documentation', options: { permissionMode:
|
|
173
|
+
{ prompt: 'Review documentation', options: { permissionMode: PERMISSION_PLAN } },
|
|
141
174
|
])
|
|
142
175
|
```
|
|
143
176
|
|
|
@@ -146,13 +179,16 @@ const [bugs, tests, docs] = await claude.parallel([
|
|
|
146
179
|
Node.js-level equivalent of the `/loop` CLI command:
|
|
147
180
|
|
|
148
181
|
```typescript
|
|
182
|
+
import { Claude, SCHED_RESULT, SCHED_ERROR } from '@scottwalker/claude-connector'
|
|
183
|
+
|
|
184
|
+
const claude = new Claude()
|
|
149
185
|
const job = claude.loop('5m', 'Check CI pipeline status and report failures')
|
|
150
186
|
|
|
151
|
-
job.on(
|
|
187
|
+
job.on(SCHED_RESULT, (result) => {
|
|
152
188
|
console.log(`[${new Date().toISOString()}] ${result.text}`)
|
|
153
189
|
})
|
|
154
190
|
|
|
155
|
-
job.on(
|
|
191
|
+
job.on(SCHED_ERROR, (err) => {
|
|
156
192
|
console.error('Check failed:', err.message)
|
|
157
193
|
})
|
|
158
194
|
|
|
@@ -167,6 +203,8 @@ Supported intervals: `'30s'`, `'5m'`, `'2h'`, `'1d'`, or raw milliseconds.
|
|
|
167
203
|
Connect Model Context Protocol servers:
|
|
168
204
|
|
|
169
205
|
```typescript
|
|
206
|
+
import { Claude } from '@scottwalker/claude-connector'
|
|
207
|
+
|
|
170
208
|
const claude = new Claude({
|
|
171
209
|
// From config file
|
|
172
210
|
mcpConfig: './mcp.json',
|
|
@@ -190,6 +228,8 @@ const claude = new Claude({
|
|
|
190
228
|
Define specialized agents:
|
|
191
229
|
|
|
192
230
|
```typescript
|
|
231
|
+
import { Claude, PERMISSION_ACCEPT_EDITS } from '@scottwalker/claude-connector'
|
|
232
|
+
|
|
193
233
|
const claude = new Claude({
|
|
194
234
|
agents: {
|
|
195
235
|
reviewer: {
|
|
@@ -201,7 +241,7 @@ const claude = new Claude({
|
|
|
201
241
|
deployer: {
|
|
202
242
|
description: 'Deployment automation agent',
|
|
203
243
|
tools: ['Bash', 'Read'],
|
|
204
|
-
permissionMode:
|
|
244
|
+
permissionMode: PERMISSION_ACCEPT_EDITS,
|
|
205
245
|
},
|
|
206
246
|
},
|
|
207
247
|
})
|
|
@@ -212,6 +252,9 @@ const claude = new Claude({
|
|
|
212
252
|
Run operations in an isolated copy of the repository:
|
|
213
253
|
|
|
214
254
|
```typescript
|
|
255
|
+
import { Claude } from '@scottwalker/claude-connector'
|
|
256
|
+
|
|
257
|
+
const claude = new Claude()
|
|
215
258
|
const result = await claude.query('Refactor the entire auth module', {
|
|
216
259
|
worktree: 'refactor-auth', // or `true` for auto-generated name
|
|
217
260
|
})
|
|
@@ -223,7 +266,9 @@ Pass data alongside the prompt (like `echo data | claude -p "prompt"`):
|
|
|
223
266
|
|
|
224
267
|
```typescript
|
|
225
268
|
import { readFileSync } from 'node:fs'
|
|
269
|
+
import { Claude } from '@scottwalker/claude-connector'
|
|
226
270
|
|
|
271
|
+
const claude = new Claude()
|
|
227
272
|
const result = await claude.query('Analyze this error log and suggest fixes', {
|
|
228
273
|
input: readFileSync('./error.log', 'utf-8'),
|
|
229
274
|
})
|
|
@@ -234,6 +279,8 @@ const result = await claude.query('Analyze this error log and suggest fixes', {
|
|
|
234
279
|
Attach hooks to tool execution:
|
|
235
280
|
|
|
236
281
|
```typescript
|
|
282
|
+
import { Claude } from '@scottwalker/claude-connector'
|
|
283
|
+
|
|
237
284
|
const claude = new Claude({
|
|
238
285
|
hooks: {
|
|
239
286
|
PostToolUse: [
|
|
@@ -252,11 +299,187 @@ const claude = new Claude({
|
|
|
252
299
|
})
|
|
253
300
|
```
|
|
254
301
|
|
|
302
|
+
### Programmatic Permissions
|
|
303
|
+
|
|
304
|
+
Control tool approval with a callback instead of static permission modes:
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
import { Claude } from '@scottwalker/claude-connector'
|
|
308
|
+
|
|
309
|
+
const claude = new Claude({
|
|
310
|
+
canUseTool: (tool, args) => {
|
|
311
|
+
if (tool === 'Bash' && args.command?.includes('rm ')) return false
|
|
312
|
+
if (tool === 'Edit') return true
|
|
313
|
+
return 'ask' // fall back to default behavior
|
|
314
|
+
},
|
|
315
|
+
})
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### In-Process MCP Tools
|
|
319
|
+
|
|
320
|
+
Define custom tools that run in-process — no external MCP server required:
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
import { Claude, createSdkMcpServer, sdkTool } from '@scottwalker/claude-connector'
|
|
324
|
+
|
|
325
|
+
const server = createSdkMcpServer({
|
|
326
|
+
tools: {
|
|
327
|
+
getUser: sdkTool({ id: { type: 'string' } }, async ({ id }) => {
|
|
328
|
+
return { name: 'Alice', role: 'admin' }
|
|
329
|
+
}),
|
|
330
|
+
},
|
|
331
|
+
})
|
|
332
|
+
const claude = new Claude({ mcpServers: { myTools: server } })
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### JS Hook Callbacks
|
|
336
|
+
|
|
337
|
+
Subscribe to all 21 hook events with native JS callbacks (no shell commands):
|
|
338
|
+
|
|
339
|
+
```typescript
|
|
340
|
+
import { Claude } from '@scottwalker/claude-connector'
|
|
341
|
+
|
|
342
|
+
const claude = new Claude({
|
|
343
|
+
hookCallbacks: {
|
|
344
|
+
PreToolUse: ({ toolName, args }) => {
|
|
345
|
+
if (toolName === 'Bash' && args.command?.includes('sudo')) return 'deny'
|
|
346
|
+
},
|
|
347
|
+
PostToolUse: ({ toolName, result }) => console.log(`${toolName} done`),
|
|
348
|
+
Notification: ({ message }) => sendSlack(message),
|
|
349
|
+
},
|
|
350
|
+
})
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### Thinking Config
|
|
354
|
+
|
|
355
|
+
Control Claude's reasoning behavior:
|
|
356
|
+
|
|
357
|
+
```typescript
|
|
358
|
+
import { Claude } from '@scottwalker/claude-connector'
|
|
359
|
+
|
|
360
|
+
const claude = new Claude({ thinking: { type: 'enabled' } })
|
|
361
|
+
// 'adaptive' — Claude decides | 'enabled' — always think | 'disabled' — no thinking
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Runtime Control
|
|
365
|
+
|
|
366
|
+
Change model or permission mode during a session:
|
|
367
|
+
|
|
368
|
+
```typescript
|
|
369
|
+
import { Claude, PERMISSION_PLAN } from '@scottwalker/claude-connector'
|
|
370
|
+
|
|
371
|
+
const claude = new Claude({ model: 'sonnet' })
|
|
372
|
+
claude.setModel('opus') // switch to a more capable model
|
|
373
|
+
claude.setPermissionMode(PERMISSION_PLAN) // tighten permissions mid-session
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### Dynamic MCP
|
|
377
|
+
|
|
378
|
+
Add, reconnect, or toggle MCP servers at runtime:
|
|
379
|
+
|
|
380
|
+
```typescript
|
|
381
|
+
const claude = new Claude()
|
|
382
|
+
claude.setMcpServers({ db: { command: 'npx', args: ['@db/mcp'] } })
|
|
383
|
+
await claude.reconnectMcpServer('db') // restart after config change
|
|
384
|
+
claude.toggleMcpServer('db', false) // temporarily disable
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### File Checkpointing
|
|
388
|
+
|
|
389
|
+
Snapshot and restore files modified by Claude:
|
|
390
|
+
|
|
391
|
+
```typescript
|
|
392
|
+
const claude = new Claude({ enableFileCheckpointing: true })
|
|
393
|
+
const result = await claude.query('Refactor the auth module')
|
|
394
|
+
// Something went wrong? Roll back all file changes:
|
|
395
|
+
await claude.rewindFiles(result.sessionId!)
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### Account & Model Info
|
|
399
|
+
|
|
400
|
+
Query your subscription info and available models:
|
|
401
|
+
|
|
402
|
+
```typescript
|
|
403
|
+
const claude = new Claude()
|
|
404
|
+
const account = await claude.accountInfo() // { plan, usage, limits }
|
|
405
|
+
const models = await claude.supportedModels() // ['opus', 'sonnet', ...]
|
|
406
|
+
const agents = await claude.supportedAgents() // available agent types
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### Per-Query Abort
|
|
410
|
+
|
|
411
|
+
Cancel individual queries with standard `AbortSignal`:
|
|
412
|
+
|
|
413
|
+
```typescript
|
|
414
|
+
const controller = new AbortController()
|
|
415
|
+
setTimeout(() => controller.abort(), 30_000) // 30s timeout
|
|
416
|
+
|
|
417
|
+
const result = await claude.query('Long analysis task', {
|
|
418
|
+
signal: controller.signal,
|
|
419
|
+
})
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### Subagent Control
|
|
423
|
+
|
|
424
|
+
Monitor and stop spawned subagent tasks:
|
|
425
|
+
|
|
426
|
+
```typescript
|
|
427
|
+
const handle = claude.stream('Run a full analysis')
|
|
428
|
+
.on('task_started', (e) => console.log(`Subagent: ${e.taskId}`))
|
|
429
|
+
.on('task_progress', (e) => console.log(`Progress: ${e.status}`))
|
|
430
|
+
.on('task_notification', (e) => console.log(e.message))
|
|
431
|
+
|
|
432
|
+
// Stop a specific subagent
|
|
433
|
+
await claude.stopTask(taskId)
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
### Settings & Plugins
|
|
437
|
+
|
|
438
|
+
Provide CLAUDE.md instructions, settings overrides, and plugins programmatically:
|
|
439
|
+
|
|
440
|
+
```typescript
|
|
441
|
+
const claude = new Claude({
|
|
442
|
+
settingSources: ['./project/CLAUDE.md', './team/CLAUDE.md'],
|
|
443
|
+
settings: { preferredLanguage: 'TypeScript', maxFileSize: 10_000 },
|
|
444
|
+
plugins: ['@claude/eslint-plugin', '@claude/prettier-plugin'],
|
|
445
|
+
})
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Custom Process Spawn
|
|
449
|
+
|
|
450
|
+
Override how Claude Code processes are created — useful for VMs, containers, or remote execution:
|
|
451
|
+
|
|
452
|
+
```typescript
|
|
453
|
+
import { Claude } from '@scottwalker/claude-connector'
|
|
454
|
+
|
|
455
|
+
const claude = new Claude({
|
|
456
|
+
spawnClaudeCodeProcess: (args, env) => {
|
|
457
|
+
// Run inside a Docker container instead of locally
|
|
458
|
+
return spawn('docker', ['exec', 'my-sandbox', 'claude', ...args], { env })
|
|
459
|
+
},
|
|
460
|
+
})
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
### Session Utilities
|
|
464
|
+
|
|
465
|
+
List and inspect past sessions:
|
|
466
|
+
|
|
467
|
+
```typescript
|
|
468
|
+
const claude = new Claude()
|
|
469
|
+
const sessions = await claude.listSessions() // all session IDs + metadata
|
|
470
|
+
const messages = await claude.getSessionMessages(id) // full message history
|
|
471
|
+
```
|
|
472
|
+
|
|
255
473
|
### Full Configuration
|
|
256
474
|
|
|
257
475
|
All Claude Code CLI capabilities in one place:
|
|
258
476
|
|
|
259
477
|
```typescript
|
|
478
|
+
import {
|
|
479
|
+
Claude,
|
|
480
|
+
EFFORT_HIGH, PERMISSION_ACCEPT_EDITS, PERMISSION_PLAN,
|
|
481
|
+
} from '@scottwalker/claude-connector'
|
|
482
|
+
|
|
260
483
|
const claude = new Claude({
|
|
261
484
|
// CLI binary
|
|
262
485
|
executable: '/usr/local/bin/claude',
|
|
@@ -264,11 +487,11 @@ const claude = new Claude({
|
|
|
264
487
|
|
|
265
488
|
// Model
|
|
266
489
|
model: 'opus', // 'opus' | 'sonnet' | 'haiku' | full model ID
|
|
267
|
-
effortLevel:
|
|
490
|
+
effortLevel: EFFORT_HIGH, // EFFORT_LOW | EFFORT_MEDIUM | EFFORT_HIGH | EFFORT_MAX
|
|
268
491
|
fallbackModel: 'sonnet', // auto-fallback on failure
|
|
269
492
|
|
|
270
493
|
// Permissions
|
|
271
|
-
permissionMode:
|
|
494
|
+
permissionMode: PERMISSION_ACCEPT_EDITS, // PERMISSION_DEFAULT | PERMISSION_ACCEPT_EDITS | PERMISSION_PLAN | PERMISSION_AUTO | PERMISSION_DONT_ASK | PERMISSION_BYPASS
|
|
272
495
|
allowedTools: ['Read', 'Edit', 'Bash(npm run *)'],
|
|
273
496
|
disallowedTools: ['WebFetch'],
|
|
274
497
|
|
|
@@ -306,7 +529,7 @@ const claude = new Claude({
|
|
|
306
529
|
// Override any option per query
|
|
307
530
|
const result = await claude.query('Analyze this module', {
|
|
308
531
|
model: 'haiku', // cheaper model for this query
|
|
309
|
-
permissionMode:
|
|
532
|
+
permissionMode: PERMISSION_PLAN, // read-only
|
|
310
533
|
maxTurns: 3,
|
|
311
534
|
})
|
|
312
535
|
```
|
|
@@ -326,6 +549,8 @@ import {
|
|
|
326
549
|
ValidationError,
|
|
327
550
|
} from '@scottwalker/claude-connector'
|
|
328
551
|
|
|
552
|
+
const claude = new Claude()
|
|
553
|
+
|
|
329
554
|
try {
|
|
330
555
|
const result = await claude.query('Fix the bug')
|
|
331
556
|
} catch (err) {
|
|
@@ -350,10 +575,13 @@ try {
|
|
|
350
575
|
|
|
351
576
|
## Custom Executor
|
|
352
577
|
|
|
353
|
-
The `IExecutor` abstraction lets you swap the CLI backend for testing, mocking, or
|
|
578
|
+
The `IExecutor` abstraction lets you swap the CLI backend for testing, mocking, or alternative transports:
|
|
354
579
|
|
|
355
580
|
```typescript
|
|
356
|
-
import {
|
|
581
|
+
import {
|
|
582
|
+
Claude, EVENT_TEXT, EVENT_RESULT,
|
|
583
|
+
type IExecutor, type ExecuteOptions, type QueryResult, type StreamEvent,
|
|
584
|
+
} from '@scottwalker/claude-connector'
|
|
357
585
|
|
|
358
586
|
class MockExecutor implements IExecutor {
|
|
359
587
|
async execute(args: readonly string[], options: ExecuteOptions): Promise<QueryResult> {
|
|
@@ -370,9 +598,9 @@ class MockExecutor implements IExecutor {
|
|
|
370
598
|
}
|
|
371
599
|
|
|
372
600
|
async *stream(args: readonly string[], options: ExecuteOptions): AsyncIterable<StreamEvent> {
|
|
373
|
-
yield { type:
|
|
601
|
+
yield { type: EVENT_TEXT, text: 'Mocked stream' }
|
|
374
602
|
yield {
|
|
375
|
-
type:
|
|
603
|
+
type: EVENT_RESULT,
|
|
376
604
|
text: 'Mocked stream',
|
|
377
605
|
sessionId: 'mock-session',
|
|
378
606
|
usage: { inputTokens: 0, outputTokens: 0 },
|
|
@@ -438,7 +666,7 @@ cd claude-connector
|
|
|
438
666
|
npm install
|
|
439
667
|
|
|
440
668
|
npm run build # compile TypeScript
|
|
441
|
-
npm test # run
|
|
669
|
+
npm test # run 122 unit tests
|
|
442
670
|
npm run test:integration # build + run integration test
|
|
443
671
|
npm run typecheck # type-check without emitting
|
|
444
672
|
```
|
|
@@ -16,8 +16,9 @@ import type { ClientOptions, QueryOptions } from '../types/index.js';
|
|
|
16
16
|
*/
|
|
17
17
|
/** Merged options ready for argument building. */
|
|
18
18
|
export interface ResolvedOptions {
|
|
19
|
-
readonly prompt
|
|
19
|
+
readonly prompt?: string;
|
|
20
20
|
readonly outputFormat: 'json' | 'stream-json';
|
|
21
|
+
readonly inputFormat?: 'stream-json';
|
|
21
22
|
readonly cwd: string;
|
|
22
23
|
readonly model?: string;
|
|
23
24
|
readonly effortLevel?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args-builder.d.ts","sourceRoot":"","sources":["../../src/builder/args-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"args-builder.d.ts","sourceRoot":"","sources":["../../src/builder/args-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAarE;;;;;;;;;;;;;;GAcG;AAEH,kDAAkD;AAClD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,aAAa,CAAC;IAC9C,QAAQ,CAAC,WAAW,CAAC,EAAE,aAAa,CAAC;IACrC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,CAA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LAG_NO_SESSION_PERSISTENCE, FLAG_NAME, FLAG_SETTINGS, FORMAT_STREAM_JSON, } from '../constants.js';
|
|
1
2
|
/**
|
|
2
3
|
* Merge client-level defaults with per-query overrides.
|
|
3
4
|
*/
|
|
@@ -39,115 +40,121 @@ export function mergeOptions(client, query, extra) {
|
|
|
39
40
|
* @returns Array of strings to pass to `spawn('claude', args)`.
|
|
40
41
|
*/
|
|
41
42
|
export function buildArgs(options) {
|
|
42
|
-
const args = [
|
|
43
|
+
const args = [FLAG_PRINT, FLAG_OUTPUT_FORMAT, options.outputFormat];
|
|
43
44
|
// BUG-1 fix: stream-json requires --verbose
|
|
44
|
-
if (options.outputFormat ===
|
|
45
|
-
args.push(
|
|
45
|
+
if (options.outputFormat === FORMAT_STREAM_JSON) {
|
|
46
|
+
args.push(FLAG_VERBOSE);
|
|
47
|
+
}
|
|
48
|
+
// ── Input format (bidirectional streaming) ─────────────────────
|
|
49
|
+
if (options.inputFormat) {
|
|
50
|
+
args.push(FLAG_INPUT_FORMAT, options.inputFormat);
|
|
46
51
|
}
|
|
47
52
|
// ── Prompt ──────────────────────────────────────────────────────
|
|
48
|
-
|
|
53
|
+
if (options.prompt) {
|
|
54
|
+
args.push(options.prompt);
|
|
55
|
+
}
|
|
49
56
|
// ── Session ─────────────────────────────────────────────────────
|
|
50
57
|
if (options.continueSession) {
|
|
51
|
-
args.push(
|
|
58
|
+
args.push(FLAG_CONTINUE);
|
|
52
59
|
}
|
|
53
60
|
if (options.sessionId) {
|
|
54
|
-
args.push(
|
|
61
|
+
args.push(FLAG_RESUME, options.sessionId);
|
|
55
62
|
}
|
|
56
63
|
if (options.forkSession) {
|
|
57
|
-
args.push(
|
|
64
|
+
args.push(FLAG_FORK_SESSION);
|
|
58
65
|
}
|
|
59
66
|
// ── Model ───────────────────────────────────────────────────────
|
|
60
67
|
if (options.model) {
|
|
61
|
-
args.push(
|
|
68
|
+
args.push(FLAG_MODEL, options.model);
|
|
62
69
|
}
|
|
63
70
|
if (options.fallbackModel) {
|
|
64
|
-
args.push(
|
|
71
|
+
args.push(FLAG_FALLBACK_MODEL, options.fallbackModel);
|
|
65
72
|
}
|
|
66
73
|
if (options.effortLevel) {
|
|
67
|
-
args.push(
|
|
74
|
+
args.push(FLAG_EFFORT, options.effortLevel);
|
|
68
75
|
}
|
|
69
76
|
// ── Permissions ─────────────────────────────────────────────────
|
|
70
77
|
if (options.permissionMode) {
|
|
71
|
-
args.push(
|
|
78
|
+
args.push(FLAG_PERMISSION_MODE, options.permissionMode);
|
|
72
79
|
}
|
|
73
80
|
if (options.allowedTools?.length) {
|
|
74
|
-
args.push(
|
|
81
|
+
args.push(FLAG_ALLOWED_TOOLS, ...options.allowedTools);
|
|
75
82
|
}
|
|
76
83
|
if (options.disallowedTools?.length) {
|
|
77
|
-
args.push(
|
|
84
|
+
args.push(FLAG_DISALLOWED_TOOLS, ...options.disallowedTools);
|
|
78
85
|
}
|
|
79
86
|
// ── Tools (built-in set restriction) ────────────────────────────
|
|
80
87
|
if (options.tools) {
|
|
81
88
|
if (options.tools.length === 0) {
|
|
82
|
-
args.push(
|
|
89
|
+
args.push(FLAG_TOOLS, '');
|
|
83
90
|
}
|
|
84
91
|
else {
|
|
85
|
-
args.push(
|
|
92
|
+
args.push(FLAG_TOOLS, ...options.tools);
|
|
86
93
|
}
|
|
87
94
|
}
|
|
88
95
|
// ── System prompt ───────────────────────────────────────────────
|
|
89
96
|
if (options.systemPrompt) {
|
|
90
|
-
args.push(
|
|
97
|
+
args.push(FLAG_SYSTEM_PROMPT, options.systemPrompt);
|
|
91
98
|
}
|
|
92
99
|
if (options.appendSystemPrompt) {
|
|
93
|
-
args.push(
|
|
100
|
+
args.push(FLAG_APPEND_SYSTEM_PROMPT, options.appendSystemPrompt);
|
|
94
101
|
}
|
|
95
102
|
// ── Limits ──────────────────────────────────────────────────────
|
|
96
103
|
if (options.maxTurns !== undefined) {
|
|
97
|
-
args.push(
|
|
104
|
+
args.push(FLAG_MAX_TURNS, String(options.maxTurns));
|
|
98
105
|
}
|
|
99
106
|
if (options.maxBudget !== undefined) {
|
|
100
|
-
args.push(
|
|
107
|
+
args.push(FLAG_MAX_BUDGET, String(options.maxBudget));
|
|
101
108
|
}
|
|
102
109
|
// ── Directories ─────────────────────────────────────────────────
|
|
103
110
|
if (options.additionalDirs?.length) {
|
|
104
111
|
for (const dir of options.additionalDirs) {
|
|
105
|
-
args.push(
|
|
112
|
+
args.push(FLAG_ADD_DIR, dir);
|
|
106
113
|
}
|
|
107
114
|
}
|
|
108
115
|
// ── MCP ─────────────────────────────────────────────────────────
|
|
109
116
|
if (options.mcpConfig) {
|
|
110
117
|
const configs = Array.isArray(options.mcpConfig) ? options.mcpConfig : [options.mcpConfig];
|
|
111
118
|
for (const cfg of configs) {
|
|
112
|
-
args.push(
|
|
119
|
+
args.push(FLAG_MCP_CONFIG, cfg);
|
|
113
120
|
}
|
|
114
121
|
}
|
|
115
122
|
if (options.mcpServers && Object.keys(options.mcpServers).length > 0) {
|
|
116
|
-
args.push(
|
|
123
|
+
args.push(FLAG_MCP_CONFIG, JSON.stringify({ mcpServers: options.mcpServers }));
|
|
117
124
|
}
|
|
118
125
|
if (options.strictMcpConfig) {
|
|
119
|
-
args.push(
|
|
126
|
+
args.push(FLAG_STRICT_MCP_CONFIG);
|
|
120
127
|
}
|
|
121
128
|
// ── Agents ──────────────────────────────────────────────────────
|
|
122
129
|
if (options.agents && Object.keys(options.agents).length > 0) {
|
|
123
|
-
args.push(
|
|
130
|
+
args.push(FLAG_AGENTS, JSON.stringify(options.agents));
|
|
124
131
|
}
|
|
125
132
|
if (options.agent) {
|
|
126
|
-
args.push(
|
|
133
|
+
args.push(FLAG_AGENT, options.agent);
|
|
127
134
|
}
|
|
128
135
|
// ── Structured output ───────────────────────────────────────────
|
|
129
136
|
if (options.schema) {
|
|
130
|
-
args.push(
|
|
137
|
+
args.push(FLAG_JSON_SCHEMA, JSON.stringify(options.schema));
|
|
131
138
|
}
|
|
132
139
|
// ── Worktree ────────────────────────────────────────────────────
|
|
133
140
|
if (options.worktree) {
|
|
134
141
|
if (typeof options.worktree === 'string') {
|
|
135
|
-
args.push(
|
|
142
|
+
args.push(FLAG_WORKTREE, options.worktree);
|
|
136
143
|
}
|
|
137
144
|
else {
|
|
138
|
-
args.push(
|
|
145
|
+
args.push(FLAG_WORKTREE);
|
|
139
146
|
}
|
|
140
147
|
}
|
|
141
148
|
// ── Misc ────────────────────────────────────────────────────────
|
|
142
149
|
if (options.noSessionPersistence) {
|
|
143
|
-
args.push(
|
|
150
|
+
args.push(FLAG_NO_SESSION_PERSISTENCE);
|
|
144
151
|
}
|
|
145
152
|
if (options.name) {
|
|
146
|
-
args.push(
|
|
153
|
+
args.push(FLAG_NAME, options.name);
|
|
147
154
|
}
|
|
148
155
|
// ── Hooks (via --settings) ──────────────────────────────────────
|
|
149
156
|
if (options.hooks && Object.keys(options.hooks).length > 0) {
|
|
150
|
-
args.push(
|
|
157
|
+
args.push(FLAG_SETTINGS, JSON.stringify({ hooks: options.hooks }));
|
|
151
158
|
}
|
|
152
159
|
return args;
|
|
153
160
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args-builder.js","sourceRoot":"","sources":["../../src/builder/args-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"args-builder.js","sourceRoot":"","sources":["../../src/builder/args-builder.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EAAE,kBAAkB,EAAE,YAAY,EAAE,iBAAiB,EAC/D,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,EACzD,mBAAmB,EAAE,WAAW,EAAE,oBAAoB,EACtD,kBAAkB,EAAE,qBAAqB,EAAE,UAAU,EACrD,kBAAkB,EAAE,yBAAyB,EAAE,cAAc,EAC7D,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,sBAAsB,EACtE,WAAW,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EACxD,2BAA2B,EAAE,SA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