@ai-sdk/harness-claude-code 0.0.0-d3900c59-20260626174016

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1319 @@
1
+ // src/claude-code-harness.ts
2
+ import { randomBytes } from "crypto";
3
+ import { readFile } from "fs/promises";
4
+ import path from "path";
5
+ import { fileURLToPath } from "url";
6
+ import {
7
+ commonTool,
8
+ harnessV1DiagnosticFromBridgeFrame,
9
+ HarnessCapabilityUnsupportedError
10
+ } from "@ai-sdk/harness";
11
+ import {
12
+ classifyDiskLog,
13
+ markBridgeStarting,
14
+ SandboxChannel,
15
+ waitForBridgeReady
16
+ } from "@ai-sdk/harness/utils";
17
+ import {
18
+ tool
19
+ } from "@ai-sdk/provider-utils";
20
+ import { WebSocket } from "ws";
21
+ import { z as z2 } from "zod/v4";
22
+
23
+ // src/claude-code-auth.ts
24
+ import { execFileSync } from "child_process";
25
+ import { readFileSync } from "fs";
26
+ import { homedir } from "os";
27
+ import { join } from "path";
28
+ import { getAiGatewayAuthFromEnv } from "@ai-sdk/harness/utils";
29
+ function resolveClaudeCodeEnv(auth, processEnv = process.env, options = {}) {
30
+ const readApiKey = options.readApiKeyHelper ?? readApiKeyHelper;
31
+ if (auth?.anthropic) {
32
+ return pickAnthropic({ explicit: auth.anthropic, processEnv, readApiKey });
33
+ }
34
+ const gatewayAuthFromEnv = getAiGatewayAuthFromEnv({ env: processEnv });
35
+ if (auth?.gateway) {
36
+ return pickGateway({
37
+ explicit: auth.gateway,
38
+ gatewayAuthFromEnv
39
+ });
40
+ }
41
+ if (gatewayAuthFromEnv.apiKey) {
42
+ return pickGateway({
43
+ explicit: {},
44
+ gatewayAuthFromEnv
45
+ });
46
+ }
47
+ return pickAnthropic({ processEnv, readApiKey });
48
+ }
49
+ function pickAnthropic({
50
+ explicit,
51
+ processEnv,
52
+ readApiKey
53
+ }) {
54
+ const env = {};
55
+ const helperKey = explicit ? void 0 : readApiKey();
56
+ const apiKey = explicit?.apiKey ?? processEnv.ANTHROPIC_API_KEY ?? helperKey;
57
+ const authToken = explicit?.authToken ?? processEnv.ANTHROPIC_AUTH_TOKEN ?? helperKey;
58
+ if (apiKey) env.ANTHROPIC_API_KEY = apiKey;
59
+ if (authToken) env.ANTHROPIC_AUTH_TOKEN = authToken;
60
+ const baseUrl = explicit?.baseUrl ?? processEnv.ANTHROPIC_BASE_URL;
61
+ if (baseUrl) env.ANTHROPIC_BASE_URL = baseUrl;
62
+ return env;
63
+ }
64
+ function readApiKeyHelper() {
65
+ const home = homedir();
66
+ if (!home) return void 0;
67
+ let raw;
68
+ try {
69
+ raw = readFileSync(join(home, ".claude", "settings.json"), "utf8");
70
+ } catch {
71
+ return void 0;
72
+ }
73
+ let settings;
74
+ try {
75
+ settings = JSON.parse(raw);
76
+ } catch {
77
+ return void 0;
78
+ }
79
+ const command = settings.apiKeyHelper;
80
+ if (typeof command !== "string" || command.length === 0) return void 0;
81
+ try {
82
+ const output = execFileSync("sh", ["-c", command], {
83
+ encoding: "utf8",
84
+ stdio: ["ignore", "pipe", "ignore"]
85
+ });
86
+ const trimmed = output.trim();
87
+ return trimmed.length > 0 ? trimmed : void 0;
88
+ } catch {
89
+ return void 0;
90
+ }
91
+ }
92
+ function pickGateway({
93
+ explicit,
94
+ gatewayAuthFromEnv
95
+ }) {
96
+ const apiKey = explicit.apiKey ?? gatewayAuthFromEnv.apiKey;
97
+ const baseUrl = explicit.baseUrl ?? gatewayAuthFromEnv.baseUrl;
98
+ const env = {};
99
+ if (apiKey) {
100
+ env.AI_GATEWAY_API_KEY = apiKey;
101
+ env.ANTHROPIC_API_KEY = apiKey;
102
+ }
103
+ env.AI_GATEWAY_BASE_URL = baseUrl;
104
+ env.ANTHROPIC_BASE_URL = baseUrl;
105
+ return env;
106
+ }
107
+
108
+ // src/claude-code-bridge-protocol.ts
109
+ import {
110
+ harnessV1BridgeInboundCommandSchemas,
111
+ harnessV1BridgeOutboundMessageSchema,
112
+ harnessV1BridgeReadySchema,
113
+ harnessV1BridgeStartBaseSchema
114
+ } from "@ai-sdk/harness";
115
+ import { z } from "zod/v4";
116
+ var outboundMessageSchema = harnessV1BridgeOutboundMessageSchema;
117
+ var startMessageSchema = harnessV1BridgeStartBaseSchema.extend({
118
+ thinking: z.enum(["off", "on", "adaptive"]).optional(),
119
+ maxTurns: z.number().optional(),
120
+ skills: z.array(z.string()).optional(),
121
+ // Resume signal. When true, the bridge passes `{ continue: true }` to the
122
+ // Claude SDK so the in-workdir thread state is rehydrated. The host sets this
123
+ // on the first prompt after a cross-process resume.
124
+ continue: z.boolean().optional()
125
+ });
126
+ var inboundMessageSchema = z.discriminatedUnion("type", [
127
+ startMessageSchema,
128
+ ...harnessV1BridgeInboundCommandSchemas
129
+ ]);
130
+
131
+ // src/claude-code-harness.ts
132
+ var CLAUDE_CODE_BUILTIN_TOOLS = {
133
+ read: commonTool("read", {
134
+ nativeName: "Read",
135
+ toolUseKind: "readonly",
136
+ description: "Read file contents (text, image, PDF, notebook)",
137
+ inputSchema: z2.object({
138
+ file_path: z2.string(),
139
+ offset: z2.number().optional(),
140
+ limit: z2.number().optional(),
141
+ pages: z2.string().optional()
142
+ })
143
+ }),
144
+ write: commonTool("write", {
145
+ nativeName: "Write",
146
+ toolUseKind: "edit",
147
+ description: "Overwrite or create a file at an absolute path",
148
+ inputSchema: z2.object({
149
+ file_path: z2.string(),
150
+ content: z2.string()
151
+ })
152
+ }),
153
+ edit: commonTool("edit", {
154
+ nativeName: "Edit",
155
+ toolUseKind: "edit",
156
+ description: "Edit a file by exact string replacement",
157
+ inputSchema: z2.object({
158
+ file_path: z2.string(),
159
+ old_string: z2.string(),
160
+ new_string: z2.string(),
161
+ replace_all: z2.boolean().optional()
162
+ })
163
+ }),
164
+ bash: commonTool("bash", {
165
+ nativeName: "Bash",
166
+ toolUseKind: "bash",
167
+ description: "Execute a shell command, optionally in background",
168
+ inputSchema: z2.object({
169
+ command: z2.string(),
170
+ timeout: z2.number().optional(),
171
+ description: z2.string().optional(),
172
+ run_in_background: z2.boolean().optional(),
173
+ dangerouslyDisableSandbox: z2.boolean().optional()
174
+ })
175
+ }),
176
+ glob: commonTool("glob", {
177
+ nativeName: "Glob",
178
+ toolUseKind: "readonly",
179
+ description: "Fast file-pattern search using glob syntax",
180
+ inputSchema: z2.object({
181
+ pattern: z2.string(),
182
+ path: z2.string().optional()
183
+ })
184
+ }),
185
+ grep: commonTool("grep", {
186
+ nativeName: "Grep",
187
+ toolUseKind: "readonly",
188
+ description: "Regex search over file contents via ripgrep",
189
+ inputSchema: z2.object({
190
+ pattern: z2.string(),
191
+ path: z2.string().optional(),
192
+ glob: z2.string().optional(),
193
+ output_mode: z2.enum(["content", "files_with_matches", "count"]).optional(),
194
+ "-B": z2.number().optional(),
195
+ "-A": z2.number().optional(),
196
+ "-C": z2.number().optional(),
197
+ context: z2.number().optional(),
198
+ "-n": z2.boolean().optional(),
199
+ "-i": z2.boolean().optional(),
200
+ "-o": z2.boolean().optional(),
201
+ type: z2.string().optional(),
202
+ head_limit: z2.number().optional(),
203
+ offset: z2.number().optional(),
204
+ multiline: z2.boolean().optional()
205
+ })
206
+ }),
207
+ webSearch: commonTool("webSearch", {
208
+ nativeName: "WebSearch",
209
+ toolUseKind: "readonly",
210
+ description: "Issue web search queries with optional domain filters",
211
+ inputSchema: z2.object({
212
+ query: z2.string(),
213
+ allowed_domains: z2.array(z2.string()).optional(),
214
+ blocked_domains: z2.array(z2.string()).optional()
215
+ })
216
+ }),
217
+ WebFetch: tool({
218
+ description: "Fetch a URL and run a prompt against its content",
219
+ inputSchema: z2.object({
220
+ url: z2.string(),
221
+ prompt: z2.string()
222
+ })
223
+ }),
224
+ NotebookEdit: tool({
225
+ description: "Edit, insert, or delete a Jupyter notebook cell",
226
+ inputSchema: z2.object({
227
+ notebook_path: z2.string(),
228
+ new_source: z2.string(),
229
+ cell_id: z2.string().optional(),
230
+ cell_type: z2.enum(["code", "markdown"]).optional(),
231
+ edit_mode: z2.enum(["replace", "insert", "delete"]).optional()
232
+ })
233
+ }),
234
+ TodoWrite: tool({
235
+ description: "Replace the session todo list",
236
+ inputSchema: z2.object({
237
+ todos: z2.array(
238
+ z2.object({
239
+ content: z2.string(),
240
+ status: z2.enum(["pending", "in_progress", "completed"]),
241
+ activeForm: z2.string()
242
+ })
243
+ )
244
+ })
245
+ }),
246
+ Agent: tool({
247
+ description: "Spawn a subagent with a task",
248
+ inputSchema: z2.object({
249
+ description: z2.string(),
250
+ prompt: z2.string(),
251
+ subagent_type: z2.string().optional(),
252
+ model: z2.enum(["sonnet", "opus", "haiku"]).optional(),
253
+ run_in_background: z2.boolean().optional(),
254
+ name: z2.string().optional(),
255
+ team_name: z2.string().optional(),
256
+ mode: z2.enum([
257
+ "acceptEdits",
258
+ "auto",
259
+ "bypassPermissions",
260
+ "default",
261
+ "dontAsk",
262
+ "plan"
263
+ ]).optional(),
264
+ isolation: z2.literal("worktree").optional()
265
+ })
266
+ }),
267
+ TaskCreate: tool({
268
+ description: "Create a task in the session-local task list",
269
+ inputSchema: z2.object({
270
+ subject: z2.string(),
271
+ description: z2.string(),
272
+ activeForm: z2.string().optional(),
273
+ metadata: z2.record(z2.string(), z2.unknown()).optional()
274
+ })
275
+ }),
276
+ TaskGet: tool({
277
+ description: "Retrieve a task by id",
278
+ inputSchema: z2.object({ taskId: z2.string() })
279
+ }),
280
+ TaskUpdate: tool({
281
+ description: "Update fields of an existing task",
282
+ inputSchema: z2.object({
283
+ taskId: z2.string(),
284
+ subject: z2.string().optional(),
285
+ description: z2.string().optional(),
286
+ activeForm: z2.string().optional(),
287
+ status: z2.union([
288
+ z2.enum(["pending", "in_progress", "completed"]),
289
+ z2.literal("deleted")
290
+ ]).optional(),
291
+ addBlocks: z2.array(z2.string()).optional(),
292
+ addBlockedBy: z2.array(z2.string()).optional(),
293
+ owner: z2.string().optional(),
294
+ metadata: z2.record(z2.string(), z2.unknown()).optional()
295
+ })
296
+ }),
297
+ TaskList: tool({
298
+ description: "Return all tasks in the session-local task list",
299
+ inputSchema: z2.object({})
300
+ }),
301
+ TaskStop: tool({
302
+ description: "Stop a running background task by id",
303
+ inputSchema: z2.object({
304
+ task_id: z2.string().optional(),
305
+ shell_id: z2.string().optional()
306
+ })
307
+ }),
308
+ TaskOutput: tool({
309
+ description: "Poll for output from a background task",
310
+ inputSchema: z2.object({
311
+ task_id: z2.string(),
312
+ block: z2.boolean(),
313
+ timeout: z2.number()
314
+ })
315
+ }),
316
+ ListMcpResources: tool({
317
+ description: "List resources available from MCP servers",
318
+ inputSchema: z2.object({ server: z2.string().optional() })
319
+ }),
320
+ ReadMcpResource: tool({
321
+ description: "Read a specific MCP resource by URI",
322
+ inputSchema: z2.object({ server: z2.string(), uri: z2.string() })
323
+ }),
324
+ ExitPlanMode: tool({
325
+ description: "Exit plan mode with optional permission approvals",
326
+ inputSchema: z2.object({
327
+ allowedPrompts: z2.array(
328
+ z2.object({
329
+ tool: z2.literal("Bash"),
330
+ prompt: z2.string()
331
+ })
332
+ ).optional()
333
+ }).passthrough()
334
+ }),
335
+ EnterWorktree: tool({
336
+ description: "Create or enter an isolated git worktree",
337
+ inputSchema: z2.object({
338
+ name: z2.string().optional(),
339
+ path: z2.string().optional()
340
+ })
341
+ }),
342
+ ExitWorktree: tool({
343
+ description: "Exit the current worktree session",
344
+ inputSchema: z2.object({
345
+ action: z2.enum(["keep", "remove"]),
346
+ discard_changes: z2.boolean().optional()
347
+ })
348
+ }),
349
+ AskUserQuestion: tool({
350
+ description: "Ask the user multiple-choice questions via a structured UI",
351
+ inputSchema: z2.object({
352
+ questions: z2.array(
353
+ z2.object({
354
+ question: z2.string(),
355
+ header: z2.string(),
356
+ options: z2.array(
357
+ z2.object({
358
+ label: z2.string(),
359
+ description: z2.string(),
360
+ preview: z2.string().optional()
361
+ })
362
+ ),
363
+ multiSelect: z2.boolean()
364
+ })
365
+ ).min(1).max(4),
366
+ answers: z2.record(z2.string(), z2.string()).optional(),
367
+ annotations: z2.record(
368
+ z2.string(),
369
+ z2.object({
370
+ preview: z2.string().optional(),
371
+ notes: z2.string().optional()
372
+ })
373
+ ).optional(),
374
+ metadata: z2.object({ source: z2.string().optional() }).optional()
375
+ })
376
+ }),
377
+ Skill: tool({
378
+ description: "Activate a skill by name",
379
+ inputSchema: z2.object({
380
+ skill: z2.string(),
381
+ args: z2.string().optional()
382
+ })
383
+ })
384
+ };
385
+ var BOOTSTRAP_DIR = "/tmp/harness/claude-code";
386
+ var claudeCodeBridgeCoordsSchema = z2.object({
387
+ port: z2.number(),
388
+ token: z2.string(),
389
+ lastSeenEventId: z2.number(),
390
+ sandboxId: z2.string().optional()
391
+ });
392
+ var claudeCodeResumeStateSchema = z2.object({ bridge: claudeCodeBridgeCoordsSchema.optional() }).passthrough();
393
+ function createClaudeCode(settings = {}) {
394
+ let cachedBootstrap;
395
+ return {
396
+ specificationVersion: "harness-v1",
397
+ harnessId: "claude-code",
398
+ builtinTools: CLAUDE_CODE_BUILTIN_TOOLS,
399
+ supportsBuiltinToolApprovals: true,
400
+ lifecycleStateSchema: claudeCodeResumeStateSchema,
401
+ getBootstrap: async () => {
402
+ if (cachedBootstrap != null) return cachedBootstrap;
403
+ const [pkg, lock, bridge] = await Promise.all([
404
+ readBridgeAsset("package.json"),
405
+ readBridgeAsset("pnpm-lock.yaml"),
406
+ readBridgeAsset("index.mjs")
407
+ ]);
408
+ cachedBootstrap = {
409
+ harnessId: "claude-code",
410
+ bootstrapDir: BOOTSTRAP_DIR,
411
+ files: [
412
+ { path: `${BOOTSTRAP_DIR}/package.json`, content: pkg },
413
+ { path: `${BOOTSTRAP_DIR}/pnpm-lock.yaml`, content: lock },
414
+ { path: `${BOOTSTRAP_DIR}/bridge.mjs`, content: bridge }
415
+ ],
416
+ commands: [
417
+ { command: `mkdir -p ${BOOTSTRAP_DIR}` },
418
+ {
419
+ command: `pnpm --dir ${BOOTSTRAP_DIR} install --frozen-lockfile --store-dir ${BOOTSTRAP_DIR}/.pnpm-store`
420
+ },
421
+ {
422
+ command: `cd ${BOOTSTRAP_DIR} && if [ -f node_modules/@anthropic-ai/claude-code/install.cjs ]; then node node_modules/@anthropic-ai/claude-code/install.cjs; fi && ./node_modules/.bin/claude --version`
423
+ }
424
+ ]
425
+ };
426
+ return cachedBootstrap;
427
+ },
428
+ doStart: async (startOpts) => {
429
+ const sandboxSession = startOpts.sandboxSession;
430
+ const session = sandboxSession.restricted();
431
+ const sandboxId = sandboxSession.id;
432
+ const lifecycleState = startOpts.continueFrom ?? startOpts.resumeFrom;
433
+ const isResume = lifecycleState != null;
434
+ const isContinue = startOpts.continueFrom != null;
435
+ const coords = isResume ? lifecycleState?.data?.bridge : void 0;
436
+ const workDir = startOpts.sessionWorkDir;
437
+ const sessionDataDir = `${sandboxSession.defaultWorkingDirectory}/.agent-runs/${startOpts.sessionId}`;
438
+ const bridgeStateDir = `${sessionDataDir}/bridge`;
439
+ const timeoutMs = settings.startupTimeoutMs ?? 12e4;
440
+ const report = startOpts.observability?.report;
441
+ const onDiagnostic = report ? (frame) => report(
442
+ harnessV1DiagnosticFromBridgeFrame(frame, {
443
+ sessionId: startOpts.sessionId,
444
+ timestamp: Date.now()
445
+ })
446
+ ) : void 0;
447
+ const buildConnect = (wsUrl2) => async () => {
448
+ return openBridgeWebSocket({ wsUrl: wsUrl2, timeoutMs });
449
+ };
450
+ if (coords) {
451
+ try {
452
+ const attachUrl = await sandboxSession.getPortUrl({
453
+ port: coords.port,
454
+ protocol: "ws"
455
+ }) + `?agent_bridge_token=${encodeURIComponent(coords.token)}`;
456
+ const attachChannel = new SandboxChannel({
457
+ connect: buildConnect(attachUrl),
458
+ outboundSchema: outboundMessageSchema,
459
+ initialLastSeenEventId: coords.lastSeenEventId,
460
+ onDiagnostic
461
+ });
462
+ await attachChannel.open(isContinue ? { resume: true } : void 0);
463
+ return createSession({
464
+ sessionId: startOpts.sessionId,
465
+ channel: attachChannel,
466
+ // The live bridge was spawned by another process; this one owns no
467
+ // process handle. The session lifecycle method decides whether the
468
+ // sandbox is left running, stopped, or destroyed.
469
+ proc: void 0,
470
+ model: settings.model,
471
+ maxTurns: settings.maxTurns,
472
+ thinking: settings.thinking,
473
+ isResume: true,
474
+ continueOnFirstPrompt: false,
475
+ rerunContinue: false,
476
+ bridgePort: coords.port,
477
+ bridgeToken: coords.token,
478
+ sandboxId,
479
+ debug: startOpts.observability?.debug,
480
+ permissionMode: startOpts.permissionMode,
481
+ skills: startOpts.skills ?? []
482
+ });
483
+ } catch {
484
+ }
485
+ }
486
+ let respawnStrategy = isResume ? "rerun" : void 0;
487
+ if (coords && isContinue) {
488
+ const logRaw = await Promise.resolve(
489
+ session.readTextFile({
490
+ path: `${bridgeStateDir}/event-log.ndjson`,
491
+ abortSignal: startOpts.abortSignal
492
+ })
493
+ ).catch(() => null);
494
+ if (await classifyDiskLog(logRaw) === "replay") {
495
+ respawnStrategy = "replay";
496
+ }
497
+ }
498
+ const sandboxHomeDir = startOpts.skills && startOpts.skills.length > 0 ? await resolveSandboxHomeDir({
499
+ sandbox: session,
500
+ abortSignal: startOpts.abortSignal
501
+ }) : void 0;
502
+ const port = resolveBridgePort(sandboxSession, settings.port);
503
+ const token = randomBytes(32).toString("hex");
504
+ const env = {
505
+ ...resolveClaudeCodeEnv(settings.auth),
506
+ BRIDGE_CHANNEL_TOKEN: token,
507
+ BRIDGE_WS_PORT: String(port),
508
+ ...sandboxHomeDir ? { HOME: sandboxHomeDir } : {},
509
+ ...respawnStrategy === "replay" ? { BRIDGE_REPLAY_FROM_DISK: "1" } : {}
510
+ };
511
+ if (respawnStrategy === void 0) {
512
+ await session.run({
513
+ command: `mkdir -p ${workDir} ${bridgeStateDir}`,
514
+ abortSignal: startOpts.abortSignal
515
+ });
516
+ if (startOpts.skills && startOpts.skills.length > 0) {
517
+ if (!sandboxHomeDir) {
518
+ throw new Error("Unable to resolve sandbox HOME directory.");
519
+ }
520
+ await writeSkills({
521
+ sandbox: session,
522
+ homeDir: sandboxHomeDir,
523
+ skills: startOpts.skills,
524
+ abortSignal: startOpts.abortSignal
525
+ });
526
+ }
527
+ }
528
+ await markBridgeStarting({
529
+ sandbox: session,
530
+ bridgeStateDir,
531
+ bridgeType: "claude-code",
532
+ abortSignal: startOpts.abortSignal
533
+ });
534
+ const proc = await session.spawn({
535
+ command: `node ${BOOTSTRAP_DIR}/bridge.mjs --workdir ${workDir} --bridge-state-dir ${bridgeStateDir}`,
536
+ env,
537
+ abortSignal: startOpts.abortSignal
538
+ });
539
+ const bridgeStartupStderr = [];
540
+ const bridgeStartupStderrDone = forwardBridgeStderr({
541
+ stream: proc.stderr,
542
+ collectTail: bridgeStartupStderr
543
+ });
544
+ void bridgeStartupStderrDone;
545
+ const { port: boundPort } = await waitForBridgeReady({
546
+ proc,
547
+ sandbox: session,
548
+ bridgeStateDir,
549
+ bridgeType: "claude-code",
550
+ timeoutMs,
551
+ abortSignal: startOpts.abortSignal,
552
+ createTimeoutError: ({ proc: proc2, stdoutTail }) => createBridgeStartupError({
553
+ message: "claude-code bridge did not become ready in time.",
554
+ proc: proc2,
555
+ stdoutTail,
556
+ stderrTail: bridgeStartupStderr,
557
+ stderrDone: bridgeStartupStderrDone
558
+ }),
559
+ createExitError: ({ proc: proc2, stdoutTail }) => createBridgeStartupError({
560
+ message: "claude-code bridge exited before becoming ready.",
561
+ proc: proc2,
562
+ stdoutTail,
563
+ stderrTail: bridgeStartupStderr,
564
+ stderrDone: bridgeStartupStderrDone
565
+ })
566
+ });
567
+ void drainRest(proc.stdout);
568
+ const wsUrl = await sandboxSession.getPortUrl({
569
+ port: boundPort,
570
+ protocol: "ws"
571
+ }) + `?agent_bridge_token=${encodeURIComponent(token)}`;
572
+ const channel = new SandboxChannel({
573
+ connect: buildConnect(wsUrl),
574
+ outboundSchema: outboundMessageSchema,
575
+ onDiagnostic,
576
+ // In replay mode the respawned bridge reloaded the finished turn from
577
+ // disk; seed the cursor and resume so it streams the tail (incl.
578
+ // `finish`) rather than starting empty.
579
+ ...respawnStrategy === "replay" ? { initialLastSeenEventId: coords?.lastSeenEventId ?? 0 } : {}
580
+ });
581
+ await channel.open(
582
+ respawnStrategy === "replay" ? { resume: true } : void 0
583
+ );
584
+ return createSession({
585
+ sessionId: startOpts.sessionId,
586
+ channel,
587
+ proc,
588
+ model: settings.model,
589
+ maxTurns: settings.maxTurns,
590
+ thinking: settings.thinking,
591
+ isResume: respawnStrategy !== void 0,
592
+ continueOnFirstPrompt: respawnStrategy !== void 0,
593
+ rerunContinue: respawnStrategy === "rerun",
594
+ bridgePort: boundPort,
595
+ bridgeToken: token,
596
+ sandboxId,
597
+ debug: startOpts.observability?.debug,
598
+ permissionMode: startOpts.permissionMode,
599
+ skills: startOpts.skills ?? []
600
+ });
601
+ }
602
+ };
603
+ }
604
+ function resolveBridgePort(sandboxSession, override) {
605
+ if (override !== void 0) return override;
606
+ if (sandboxSession.ports.length > 0) return sandboxSession.ports[0];
607
+ throw new HarnessCapabilityUnsupportedError({
608
+ harnessId: "claude-code",
609
+ message: "The claude-code harness needs a TCP port exposed by the sandbox. Create the sandbox with `ports: [<port>]` or pass `createClaudeCode({ port })`."
610
+ });
611
+ }
612
+ async function writeSkills({
613
+ sandbox,
614
+ homeDir,
615
+ skills,
616
+ abortSignal
617
+ }) {
618
+ for (const skill of skills) {
619
+ safeClaudeSkillName(skill.name);
620
+ for (const file of skill.files ?? []) {
621
+ safeClaudeSkillFilePath({
622
+ skillName: skill.name,
623
+ filePath: file.path
624
+ });
625
+ }
626
+ }
627
+ await sandbox.run({
628
+ command: `mkdir -p ${shellQuote(homeDir)}/.claude/skills`,
629
+ abortSignal
630
+ });
631
+ for (const skill of skills) {
632
+ const name = safeClaudeSkillName(skill.name);
633
+ const skillDir = `${homeDir}/.claude/skills/${name}`;
634
+ const path2 = `${skillDir}/SKILL.md`;
635
+ const content = `---
636
+ name: ${skill.name}
637
+ description: ${skill.description}
638
+ ---
639
+
640
+ ${skill.content}
641
+ `;
642
+ await sandbox.writeTextFile({ path: path2, content, abortSignal });
643
+ for (const file of skill.files ?? []) {
644
+ const filePath = safeClaudeSkillFilePath({
645
+ skillName: skill.name,
646
+ filePath: file.path
647
+ });
648
+ await sandbox.writeTextFile({
649
+ path: `${skillDir}/${filePath}`,
650
+ content: file.content,
651
+ abortSignal
652
+ });
653
+ }
654
+ }
655
+ }
656
+ async function resolveSandboxHomeDir({
657
+ sandbox,
658
+ abortSignal
659
+ }) {
660
+ const result = await sandbox.run({
661
+ command: 'printf "%s" "$HOME"',
662
+ abortSignal
663
+ });
664
+ const homeDir = result.stdout.trim();
665
+ if (result.exitCode !== 0 || !homeDir || !path.posix.isAbsolute(homeDir)) {
666
+ throw new Error(
667
+ `Unable to resolve sandbox HOME directory: ${result.stderr || result.stdout}`
668
+ );
669
+ }
670
+ return homeDir;
671
+ }
672
+ function safeClaudeSkillName(name) {
673
+ if (!/^[A-Za-z0-9._-]+$/.test(name) || name === "." || name === "..") {
674
+ throw new Error(`Invalid Claude Code skill name: ${name}`);
675
+ }
676
+ return name;
677
+ }
678
+ function safeClaudeSkillFilePath({
679
+ skillName,
680
+ filePath
681
+ }) {
682
+ const normalized = path.posix.normalize(filePath);
683
+ if (normalized === "." || normalized.startsWith("../") || path.posix.isAbsolute(normalized)) {
684
+ throw new Error(
685
+ `Invalid Claude Code skill file path for ${skillName}: ${filePath}`
686
+ );
687
+ }
688
+ return normalized;
689
+ }
690
+ function shellQuote(value) {
691
+ return `'${value.replace(/'/g, `'\\''`)}'`;
692
+ }
693
+ async function readBridgeAsset(name) {
694
+ const candidates = [
695
+ new URL(`./bridge/${name}`, import.meta.url),
696
+ new URL(`../bridge/${name}`, import.meta.url)
697
+ ];
698
+ let lastErr;
699
+ for (const url of candidates) {
700
+ try {
701
+ return await readFile(fileURLToPath(url), "utf8");
702
+ } catch (err) {
703
+ const code = err.code;
704
+ if (code !== "ENOENT") throw err;
705
+ lastErr = err;
706
+ }
707
+ }
708
+ throw lastErr ?? new Error(`bridge asset not found: ${name}`);
709
+ }
710
+ async function createBridgeStartupError({
711
+ message,
712
+ proc,
713
+ stdoutTail,
714
+ stderrTail,
715
+ stderrDone
716
+ }) {
717
+ await Promise.race([
718
+ stderrDone,
719
+ new Promise((resolve) => setTimeout(resolve, 250))
720
+ ]).catch(() => {
721
+ });
722
+ let exitStatus = "";
723
+ try {
724
+ const result = await Promise.race([
725
+ proc.wait(),
726
+ new Promise((resolve) => setTimeout(resolve, 250))
727
+ ]);
728
+ if (result?.exitCode !== void 0) {
729
+ exitStatus = ` Exit code: ${result.exitCode}.`;
730
+ }
731
+ } catch {
732
+ }
733
+ const details = [];
734
+ if (stdoutTail.length > 0) {
735
+ details.push(`stdout:
736
+ ${stdoutTail.join("\n")}`);
737
+ }
738
+ if (stderrTail.length > 0) {
739
+ details.push(`stderr:
740
+ ${stderrTail.join("\n")}`);
741
+ }
742
+ return new Error(
743
+ `${message}${exitStatus}${details.length > 0 ? `
744
+
745
+ ${details.join("\n\n")}` : ""}`
746
+ );
747
+ }
748
+ function lineDecoder() {
749
+ let buffer = "";
750
+ return {
751
+ push(chunk) {
752
+ buffer += chunk;
753
+ const lines = [];
754
+ let nl;
755
+ while ((nl = buffer.indexOf("\n")) !== -1) {
756
+ const raw = buffer.slice(0, nl);
757
+ buffer = buffer.slice(nl + 1);
758
+ const line = raw.replace(/\r$/, "").trim();
759
+ if (line.length > 0) lines.push(line);
760
+ }
761
+ return lines;
762
+ },
763
+ flush() {
764
+ const line = buffer.replace(/\r$/, "").trim();
765
+ buffer = "";
766
+ return line.length > 0 ? [line] : [];
767
+ }
768
+ };
769
+ }
770
+ async function forwardBridgeStderr({
771
+ stream,
772
+ collectTail
773
+ }) {
774
+ try {
775
+ const reader = stream.pipeThrough(new TextDecoderStream()).getReader();
776
+ const decoder = lineDecoder();
777
+ while (true) {
778
+ const { value, done } = await reader.read();
779
+ if (done) {
780
+ for (const line of decoder.flush()) {
781
+ const trimmed = line.trim();
782
+ if (!trimmed) continue;
783
+ if (collectTail) {
784
+ collectTail.push(trimmed);
785
+ if (collectTail.length > 20) collectTail.shift();
786
+ }
787
+ console.log(`[bridge stderr] ${trimmed}`);
788
+ }
789
+ return;
790
+ }
791
+ if (value) {
792
+ for (const line of decoder.push(value)) {
793
+ const trimmed = line.trim();
794
+ if (!trimmed) continue;
795
+ if (collectTail) {
796
+ collectTail.push(trimmed);
797
+ if (collectTail.length > 20) collectTail.shift();
798
+ }
799
+ console.log(`[bridge stderr] ${trimmed}`);
800
+ }
801
+ }
802
+ }
803
+ } catch {
804
+ }
805
+ }
806
+ async function drainRest(stream) {
807
+ try {
808
+ const reader = stream.pipeThrough(new TextDecoderStream()).getReader();
809
+ while (true) {
810
+ const { done } = await reader.read();
811
+ if (done) return;
812
+ }
813
+ } catch {
814
+ }
815
+ }
816
+ async function waitForBridgeHello({
817
+ ws,
818
+ timeoutMs
819
+ }) {
820
+ await new Promise((resolve, reject) => {
821
+ let settled = false;
822
+ const cleanup = () => {
823
+ ws.off("message", onMessage);
824
+ ws.off("close", onClose);
825
+ ws.off("error", onError);
826
+ if (timer) clearTimeout(timer);
827
+ };
828
+ const settle = (err) => {
829
+ if (settled) return;
830
+ settled = true;
831
+ cleanup();
832
+ if (err) reject(err);
833
+ else resolve();
834
+ };
835
+ const onMessage = (raw) => {
836
+ try {
837
+ const text = typeof raw === "string" ? raw : raw.toString ? raw.toString("utf8") : String(raw);
838
+ const parsed = JSON.parse(text);
839
+ if (parsed?.type === "bridge-hello") settle();
840
+ } catch {
841
+ }
842
+ };
843
+ const onClose = () => {
844
+ settle(
845
+ new Error("claude-code bridge closed before sending bridge-hello")
846
+ );
847
+ };
848
+ const onError = (err) => settle(err);
849
+ const timer = setTimeout(
850
+ () => settle(
851
+ new Error(
852
+ `claude-code bridge did not send bridge-hello within ${timeoutMs}ms`
853
+ )
854
+ ),
855
+ timeoutMs
856
+ );
857
+ timer.unref?.();
858
+ ws.on("message", onMessage);
859
+ ws.on("close", onClose);
860
+ ws.on("error", onError);
861
+ });
862
+ }
863
+ async function openBridgeWebSocket({
864
+ wsUrl,
865
+ timeoutMs
866
+ }) {
867
+ const deadline = Date.now() + timeoutMs;
868
+ let attempt = 0;
869
+ let lastError;
870
+ while (Date.now() < deadline) {
871
+ attempt++;
872
+ let ws;
873
+ try {
874
+ const remaining = Math.max(1, deadline - Date.now());
875
+ ws = await openWebSocket({
876
+ url: wsUrl,
877
+ timeoutMs: Math.min(1e4, remaining)
878
+ });
879
+ await waitForBridgeHello({
880
+ ws,
881
+ timeoutMs: Math.min(5e3, Math.max(1, deadline - Date.now()))
882
+ });
883
+ return ws;
884
+ } catch (err) {
885
+ lastError = err;
886
+ try {
887
+ ws?.close();
888
+ } catch {
889
+ }
890
+ const remaining = deadline - Date.now();
891
+ if (remaining <= 0) break;
892
+ await sleep(Math.min(250 * attempt, 1e3, remaining));
893
+ }
894
+ }
895
+ throw new Error(
896
+ `claude-code bridge did not complete WebSocket handshake within ${timeoutMs}ms after ${attempt} attempt(s). Last error: ${formatUnknownError(lastError)}`
897
+ );
898
+ }
899
+ function openWebSocket({
900
+ url,
901
+ timeoutMs
902
+ }) {
903
+ return new Promise((resolve, reject) => {
904
+ const ws = new WebSocket(url);
905
+ const timer = setTimeout(() => {
906
+ cleanup();
907
+ try {
908
+ ws.terminate();
909
+ } catch {
910
+ }
911
+ reject(new Error(`WebSocket open timed out after ${timeoutMs}ms`));
912
+ }, timeoutMs);
913
+ timer.unref?.();
914
+ const cleanup = () => {
915
+ clearTimeout(timer);
916
+ ws.off("open", onOpen);
917
+ ws.off("error", onError);
918
+ };
919
+ const onOpen = () => {
920
+ cleanup();
921
+ resolve(ws);
922
+ };
923
+ const onError = (err) => {
924
+ cleanup();
925
+ reject(err);
926
+ };
927
+ ws.once("open", onOpen);
928
+ ws.once("error", onError);
929
+ });
930
+ }
931
+ function sleep(ms) {
932
+ return new Promise((resolve) => {
933
+ const timer = setTimeout(resolve, ms);
934
+ timer.unref?.();
935
+ });
936
+ }
937
+ function formatUnknownError(error) {
938
+ if (error instanceof Error) return error.message;
939
+ return String(error);
940
+ }
941
+ function createSession({
942
+ sessionId,
943
+ channel,
944
+ proc,
945
+ model,
946
+ maxTurns,
947
+ thinking,
948
+ isResume,
949
+ continueOnFirstPrompt,
950
+ rerunContinue,
951
+ bridgePort,
952
+ bridgeToken,
953
+ sandboxId,
954
+ debug,
955
+ permissionMode,
956
+ skills
957
+ }) {
958
+ let stopped = false;
959
+ let stopPromise;
960
+ let pendingResumeFlag = continueOnFirstPrompt;
961
+ let instructionsApplied = isResume;
962
+ const wireTurn = (turnOpts) => {
963
+ let pendingResolve;
964
+ let pendingReject;
965
+ const done = new Promise((resolve, reject) => {
966
+ pendingResolve = resolve;
967
+ pendingReject = reject;
968
+ });
969
+ const unsubs = [];
970
+ const forward = (event) => {
971
+ try {
972
+ turnOpts.emit(event);
973
+ } catch {
974
+ }
975
+ };
976
+ let isSettled = false;
977
+ const settleSuccess = () => {
978
+ if (isSettled) return;
979
+ isSettled = true;
980
+ for (const u of unsubs) u();
981
+ pendingResolve();
982
+ };
983
+ const settleError = (err) => {
984
+ if (isSettled) return;
985
+ isSettled = true;
986
+ for (const u of unsubs) u();
987
+ pendingReject(err);
988
+ };
989
+ const eventTypes = [
990
+ "stream-start",
991
+ "text-start",
992
+ "text-delta",
993
+ "text-end",
994
+ "reasoning-start",
995
+ "reasoning-delta",
996
+ "reasoning-end",
997
+ "tool-call",
998
+ "tool-approval-request",
999
+ "tool-result",
1000
+ "finish-step",
1001
+ "raw"
1002
+ ];
1003
+ for (const type of eventTypes) {
1004
+ unsubs.push(
1005
+ channel.on(type, (msg) => {
1006
+ forward(msg);
1007
+ })
1008
+ );
1009
+ }
1010
+ unsubs.push(
1011
+ channel.on("finish", (msg) => {
1012
+ forward(msg);
1013
+ settleSuccess();
1014
+ })
1015
+ );
1016
+ unsubs.push(
1017
+ channel.on("error", (msg) => {
1018
+ forward(msg);
1019
+ settleError(msg.error);
1020
+ })
1021
+ );
1022
+ const onClose = (_code, reason) => {
1023
+ if (isSettled) return;
1024
+ if (reason === "suspended") {
1025
+ settleSuccess();
1026
+ return;
1027
+ }
1028
+ settleError(
1029
+ new Error("claude-code bridge closed before the turn finished.")
1030
+ );
1031
+ };
1032
+ channel.onClose(onClose);
1033
+ const onAbort = () => {
1034
+ if (isSettled) return;
1035
+ try {
1036
+ channel.send({ type: "abort" });
1037
+ } catch {
1038
+ }
1039
+ settleError(
1040
+ turnOpts.abortSignal?.reason ?? new DOMException("Aborted", "AbortError")
1041
+ );
1042
+ };
1043
+ if (turnOpts.abortSignal) {
1044
+ if (turnOpts.abortSignal.aborted) {
1045
+ onAbort();
1046
+ } else {
1047
+ turnOpts.abortSignal.addEventListener("abort", onAbort, {
1048
+ once: true
1049
+ });
1050
+ }
1051
+ }
1052
+ return {
1053
+ submitToolResult: async (input) => {
1054
+ channel.send({
1055
+ type: "tool-result",
1056
+ toolCallId: input.toolCallId,
1057
+ output: input.output,
1058
+ isError: input.isError
1059
+ });
1060
+ },
1061
+ submitToolApproval: async (input) => {
1062
+ channel.send({
1063
+ type: "tool-approval-response",
1064
+ approvalId: input.approvalId,
1065
+ approved: input.approved,
1066
+ reason: input.reason
1067
+ });
1068
+ },
1069
+ submitUserMessage: async (text) => {
1070
+ channel.send({ type: "user-message", text });
1071
+ },
1072
+ done
1073
+ };
1074
+ };
1075
+ return {
1076
+ sessionId,
1077
+ isResume,
1078
+ modelId: model,
1079
+ doPromptTurn: async (promptOpts) => {
1080
+ const control = wireTurn({
1081
+ emit: promptOpts.emit,
1082
+ abortSignal: promptOpts.abortSignal
1083
+ });
1084
+ let promptText = extractUserText(promptOpts.prompt);
1085
+ if (!instructionsApplied && promptOpts.instructions) {
1086
+ promptText = frameInstructions(promptOpts.instructions, promptText);
1087
+ }
1088
+ instructionsApplied = true;
1089
+ const startMessage = {
1090
+ type: "start",
1091
+ prompt: promptText,
1092
+ tools: (promptOpts.tools ?? []).map((t) => ({
1093
+ name: t.name,
1094
+ description: t.description,
1095
+ inputSchema: t.inputSchema
1096
+ })),
1097
+ model,
1098
+ maxTurns,
1099
+ thinking,
1100
+ ...skills.length > 0 ? { skills: skills.map((skill) => skill.name) } : {},
1101
+ ...permissionMode ? { permissionMode } : {},
1102
+ ...debug ? { debug } : {},
1103
+ ...pendingResumeFlag ? { continue: true } : {}
1104
+ };
1105
+ pendingResumeFlag = false;
1106
+ channel.send(startMessage);
1107
+ return control;
1108
+ },
1109
+ doContinueTurn: async (continueOpts) => {
1110
+ const control = wireTurn({
1111
+ emit: continueOpts.emit,
1112
+ abortSignal: continueOpts.abortSignal
1113
+ });
1114
+ if (rerunContinue) {
1115
+ pendingResumeFlag = false;
1116
+ channel.send({
1117
+ type: "start",
1118
+ /*
1119
+ * A continuation nudge rather than an empty prompt: `continue: true`
1120
+ * rehydrates the prior thread, and this is the new user turn that
1121
+ * drives it forward. It must be non-empty — an empty text block is
1122
+ * rejected by the Anthropic API once the SDK stamps it with
1123
+ * `cache_control`.
1124
+ */
1125
+ prompt: "Continue.",
1126
+ tools: (continueOpts.tools ?? []).map((t) => ({
1127
+ name: t.name,
1128
+ description: t.description,
1129
+ inputSchema: t.inputSchema
1130
+ })),
1131
+ model,
1132
+ maxTurns,
1133
+ thinking,
1134
+ ...skills.length > 0 ? { skills: skills.map((skill) => skill.name) } : {},
1135
+ ...permissionMode ? { permissionMode } : {},
1136
+ ...debug ? { debug } : {},
1137
+ continue: true
1138
+ });
1139
+ }
1140
+ return control;
1141
+ },
1142
+ doCompact: async (customInstructions) => {
1143
+ const text = customInstructions && customInstructions.trim() ? `/compact ${customInstructions.trim()}` : "/compact";
1144
+ channel.send({ type: "user-message", text });
1145
+ },
1146
+ doDetach: async () => {
1147
+ if (stopped) {
1148
+ throw new Error(
1149
+ `claude-code session ${sessionId} is already stopped; cannot detach.`
1150
+ );
1151
+ }
1152
+ stopped = true;
1153
+ const lastSeenEventId = await channel.suspend();
1154
+ const payload = {
1155
+ type: "resume-session",
1156
+ harnessId: "claude-code",
1157
+ specificationVersion: "harness-v1",
1158
+ data: {
1159
+ bridge: {
1160
+ port: bridgePort,
1161
+ token: bridgeToken,
1162
+ lastSeenEventId,
1163
+ sandboxId
1164
+ }
1165
+ }
1166
+ };
1167
+ return payload;
1168
+ },
1169
+ doDestroy: async () => {
1170
+ if (stopped) return stopPromise;
1171
+ stopped = true;
1172
+ stopPromise = (async () => {
1173
+ channel.beginClose();
1174
+ try {
1175
+ if (!channel.isClosed()) {
1176
+ channel.send({ type: "shutdown" });
1177
+ }
1178
+ } catch {
1179
+ }
1180
+ let stopTimer;
1181
+ try {
1182
+ if (proc) {
1183
+ await Promise.race([
1184
+ proc.wait(),
1185
+ new Promise((resolve) => {
1186
+ stopTimer = setTimeout(resolve, 5e3);
1187
+ stopTimer.unref?.();
1188
+ })
1189
+ ]);
1190
+ }
1191
+ } finally {
1192
+ if (stopTimer) clearTimeout(stopTimer);
1193
+ try {
1194
+ await proc?.kill();
1195
+ } catch {
1196
+ }
1197
+ channel.close();
1198
+ }
1199
+ })();
1200
+ return stopPromise;
1201
+ },
1202
+ doStop: async () => {
1203
+ if (stopped) {
1204
+ throw new Error(
1205
+ `claude-code session ${sessionId} is already stopped; cannot stop.`
1206
+ );
1207
+ }
1208
+ stopped = true;
1209
+ channel.beginClose();
1210
+ const data = channel.isClosed() ? {} : await new Promise((resolve, reject) => {
1211
+ const timer = setTimeout(() => {
1212
+ unsub();
1213
+ reject(
1214
+ new Error(
1215
+ `claude-code session ${sessionId} did not reply to detach within 5s.`
1216
+ )
1217
+ );
1218
+ }, 5e3);
1219
+ timer.unref?.();
1220
+ const unsub = channel.on("bridge-detach", (msg) => {
1221
+ clearTimeout(timer);
1222
+ unsub();
1223
+ resolve(msg.data);
1224
+ });
1225
+ try {
1226
+ channel.send({ type: "detach" });
1227
+ } catch (err) {
1228
+ clearTimeout(timer);
1229
+ unsub();
1230
+ reject(err);
1231
+ }
1232
+ });
1233
+ let stopTimer;
1234
+ try {
1235
+ if (proc) {
1236
+ await Promise.race([
1237
+ proc.wait(),
1238
+ new Promise((resolve) => {
1239
+ stopTimer = setTimeout(resolve, 5e3);
1240
+ stopTimer.unref?.();
1241
+ })
1242
+ ]);
1243
+ }
1244
+ } finally {
1245
+ if (stopTimer) clearTimeout(stopTimer);
1246
+ try {
1247
+ await proc?.kill();
1248
+ } catch {
1249
+ }
1250
+ channel.close();
1251
+ }
1252
+ const payload = {
1253
+ type: "resume-session",
1254
+ harnessId: "claude-code",
1255
+ specificationVersion: "harness-v1",
1256
+ data: data ?? {}
1257
+ };
1258
+ return payload;
1259
+ },
1260
+ doSuspendTurn: async () => {
1261
+ if (stopped) {
1262
+ throw new Error(
1263
+ `claude-code session ${sessionId} is stopped; cannot suspend.`
1264
+ );
1265
+ }
1266
+ stopped = true;
1267
+ const lastSeenEventId = await channel.suspend();
1268
+ const payload = {
1269
+ type: "continue-turn",
1270
+ harnessId: "claude-code",
1271
+ specificationVersion: "harness-v1",
1272
+ data: {
1273
+ bridge: {
1274
+ port: bridgePort,
1275
+ token: bridgeToken,
1276
+ lastSeenEventId,
1277
+ sandboxId
1278
+ }
1279
+ }
1280
+ };
1281
+ return payload;
1282
+ }
1283
+ };
1284
+ }
1285
+ function frameInstructions(instructions, userText) {
1286
+ return `<session-instructions>
1287
+ The block below is operating guidance from the system, not a message from the user \u2014 follow it, but do not mention it or attribute it to the user.
1288
+
1289
+ ${instructions}
1290
+ </session-instructions>
1291
+
1292
+ <user-message>
1293
+ ${userText}
1294
+ </user-message>`;
1295
+ }
1296
+ function extractUserText(prompt) {
1297
+ if (typeof prompt === "string") return prompt;
1298
+ const { content } = prompt;
1299
+ if (typeof content === "string") return content;
1300
+ const parts = [];
1301
+ for (const part of content) {
1302
+ if (part.type !== "text") {
1303
+ throw new HarnessCapabilityUnsupportedError({
1304
+ harnessId: "claude-code",
1305
+ message: `The claude-code harness does not yet support user message parts of type '${part.type}'. Pass a string or a user message whose content contains only text parts.`
1306
+ });
1307
+ }
1308
+ parts.push(part.text);
1309
+ }
1310
+ return parts.join("\n\n");
1311
+ }
1312
+
1313
+ // src/index.ts
1314
+ var claudeCode = createClaudeCode();
1315
+ export {
1316
+ claudeCode,
1317
+ createClaudeCode
1318
+ };
1319
+ //# sourceMappingURL=index.js.map