@ai-sdk/harness-claude-code 1.0.65 → 1.0.67

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 CHANGED
@@ -136,7 +136,9 @@ var thinkingSchema = z.discriminatedUnion("type", [
136
136
  var startMessageSchema = harnessV1BridgeStartBaseSchema.extend({
137
137
  thinking: thinkingSchema,
138
138
  maxTurns: z.number().optional(),
139
+ env: z.record(z.string(), z.string()).optional(),
139
140
  skills: z.array(z.string()).optional(),
141
+ mcpServers: z.record(z.string(), z.unknown()).optional(),
140
142
  // Resume signal. When true, the bridge passes `{ continue: true }` to the
141
143
  // Claude SDK so the in-workdir thread state is rehydrated. The host sets this
142
144
  // on the first prompt after a cross-process resume.
@@ -148,10 +150,35 @@ var inboundMessageSchema = z.discriminatedUnion("type", [
148
150
  ]);
149
151
 
150
152
  // src/version.ts
151
- var VERSION = true ? "1.0.65" : "0.0.0-test";
153
+ var VERSION = true ? "1.0.67" : "0.0.0-test";
152
154
 
153
155
  // src/claude-code-harness.ts
154
156
  var CLAUDE_CODE_CLIENT_APP = `ai-sdk/harness-claude-code/${VERSION}`;
157
+ var listMcpResourcesInputSchema = z2.object({
158
+ server: z2.string().optional()
159
+ });
160
+ var readMcpResourceInputSchema = z2.object({
161
+ server: z2.string(),
162
+ uri: z2.string()
163
+ });
164
+ var structuredTeamMessageSchema = z2.discriminatedUnion("type", [
165
+ z2.object({
166
+ type: z2.literal("shutdown_request"),
167
+ reason: z2.string().optional()
168
+ }),
169
+ z2.object({
170
+ type: z2.literal("shutdown_response"),
171
+ request_id: z2.string(),
172
+ approve: z2.boolean(),
173
+ reason: z2.string().optional()
174
+ }),
175
+ z2.object({
176
+ type: z2.literal("plan_approval_response"),
177
+ request_id: z2.string(),
178
+ approve: z2.boolean(),
179
+ feedback: z2.string().optional()
180
+ })
181
+ ]);
155
182
  var CLAUDE_CODE_BUILTIN_TOOLS = {
156
183
  read: commonTool("read", {
157
184
  nativeName: "Read",
@@ -336,23 +363,64 @@ var CLAUDE_CODE_BUILTIN_TOOLS = {
336
363
  timeout: z2.number()
337
364
  })
338
365
  }),
339
- Monitor: tool({
340
- description: "Run and monitor a shell command",
341
- inputSchema: z2.object({
342
- command: z2.string(),
343
- description: z2.string().optional(),
344
- timeout_ms: z2.number().optional(),
345
- persistent: z2.boolean().optional()
346
- })
347
- }),
348
- ListMcpResources: tool({
349
- description: "List resources available from MCP servers",
350
- inputSchema: z2.object({ server: z2.string().optional() })
351
- }),
352
- ReadMcpResource: tool({
353
- description: "Read a specific MCP resource by URI",
354
- inputSchema: z2.object({ server: z2.string(), uri: z2.string() })
355
- }),
366
+ Monitor: {
367
+ ...tool({
368
+ description: "Run and monitor a shell command or WebSocket",
369
+ inputSchema: z2.object({
370
+ description: z2.string().optional(),
371
+ timeout_ms: z2.number().optional(),
372
+ persistent: z2.boolean().optional(),
373
+ command: z2.string().optional(),
374
+ ws: z2.object({
375
+ url: z2.string(),
376
+ protocols: z2.array(z2.string()).optional()
377
+ }).optional()
378
+ })
379
+ }),
380
+ toolUseKind: "bash"
381
+ },
382
+ ListMcpResources: {
383
+ ...tool({
384
+ description: "List resources available from MCP servers",
385
+ inputSchema: listMcpResourcesInputSchema
386
+ }),
387
+ toolUseKind: "readonly"
388
+ },
389
+ ListMcpResourcesTool: {
390
+ ...tool({
391
+ description: "List resources available from MCP servers",
392
+ inputSchema: listMcpResourcesInputSchema
393
+ }),
394
+ toolUseKind: "readonly"
395
+ },
396
+ ReadMcpResource: {
397
+ ...tool({
398
+ description: "Read a specific MCP resource by URI",
399
+ inputSchema: readMcpResourceInputSchema
400
+ }),
401
+ toolUseKind: "readonly"
402
+ },
403
+ ReadMcpResourceTool: {
404
+ ...tool({
405
+ description: "Read a specific MCP resource by URI",
406
+ inputSchema: readMcpResourceInputSchema
407
+ }),
408
+ toolUseKind: "readonly"
409
+ },
410
+ ReadMcpResourceDirTool: {
411
+ ...tool({
412
+ description: "List direct children of an MCP directory resource",
413
+ inputSchema: readMcpResourceInputSchema
414
+ }),
415
+ toolUseKind: "readonly"
416
+ },
417
+ RefreshMcpTools: {
418
+ ...tool({
419
+ description: "Refresh tools from one or all connected MCP servers",
420
+ inputSchema: z2.object({ server: z2.string().optional() })
421
+ }),
422
+ toolUseKind: "readonly"
423
+ },
356
424
  ExitPlanMode: tool({
357
425
  description: "Exit plan mode with optional permission approvals",
358
426
  inputSchema: z2.looseObject({
@@ -364,6 +432,13 @@ var CLAUDE_CODE_BUILTIN_TOOLS = {
364
432
  ).optional()
365
433
  })
366
434
  }),
435
+ EnterPlanMode: {
436
+ ...tool({
437
+ description: "Enter plan mode",
438
+ inputSchema: z2.object({})
439
+ }),
440
+ toolUseKind: "readonly"
441
+ },
367
442
  EnterWorktree: tool({
368
443
  description: "Create or enter an isolated git worktree",
369
444
  inputSchema: z2.object({
@@ -422,7 +497,255 @@ var CLAUDE_CODE_BUILTIN_TOOLS = {
422
497
  query: z2.string(),
423
498
  max_results: z2.number().optional()
424
499
  })
425
- })
500
+ }),
501
+ Artifact: {
502
+ ...tool({
503
+ description: "Publish or list claude.ai artifacts",
504
+ inputSchema: z2.object({
505
+ action: z2.enum(["publish", "list"]).optional(),
506
+ file_path: z2.string().optional(),
507
+ favicon: z2.string().optional(),
508
+ limit: z2.number().optional(),
509
+ scope: z2.enum(["mine", "shared", "all"]).optional(),
510
+ title: z2.string().optional(),
511
+ description: z2.string().optional(),
512
+ label: z2.string().optional(),
513
+ url: z2.string().optional(),
514
+ force: z2.boolean().optional()
515
+ })
516
+ }),
517
+ toolUseKind: "edit"
518
+ },
519
+ CronCreate: {
520
+ ...tool({
521
+ description: "Schedule a recurring or one-shot prompt",
522
+ inputSchema: z2.object({
523
+ cron: z2.string(),
524
+ prompt: z2.string(),
525
+ recurring: z2.boolean().optional(),
526
+ durable: z2.boolean().optional()
527
+ })
528
+ }),
529
+ toolUseKind: "edit"
530
+ },
531
+ CronDelete: {
532
+ ...tool({
533
+ description: "Delete a scheduled prompt by id",
534
+ inputSchema: z2.object({ id: z2.string() })
535
+ }),
536
+ toolUseKind: "edit"
537
+ },
538
+ CronList: {
539
+ ...tool({
540
+ description: "List scheduled prompts for the current session",
541
+ inputSchema: z2.object({})
542
+ }),
543
+ toolUseKind: "readonly"
544
+ },
545
+ DesignSync: {
546
+ ...tool({
547
+ description: "Read or update claude.ai Design projects",
548
+ inputSchema: z2.object({
549
+ method: z2.enum([
550
+ "list_projects",
551
+ "get_project",
552
+ "list_files",
553
+ "get_file",
554
+ "finalize_plan",
555
+ "write_files",
556
+ "delete_files",
557
+ "register_assets",
558
+ "unregister_assets",
559
+ "create_project",
560
+ "report_validate"
561
+ ]),
562
+ projectId: z2.string().optional(),
563
+ path: z2.string().optional(),
564
+ writes: z2.array(z2.string()).max(256).optional(),
565
+ deletes: z2.array(z2.string()).max(256).optional(),
566
+ planId: z2.string().optional(),
567
+ files: z2.array(
568
+ z2.object({
569
+ path: z2.string(),
570
+ localPath: z2.string().optional(),
571
+ data: z2.string().optional(),
572
+ encoding: z2.literal("base64").optional(),
573
+ mimeType: z2.string().optional()
574
+ })
575
+ ).max(256).optional(),
576
+ paths: z2.array(z2.string()).max(256).optional(),
577
+ name: z2.string().optional(),
578
+ assets: z2.array(
579
+ z2.object({
580
+ name: z2.string(),
581
+ path: z2.string(),
582
+ subtitle: z2.string().optional(),
583
+ viewport: z2.object({
584
+ width: z2.number(),
585
+ height: z2.number().optional()
586
+ }).optional(),
587
+ group: z2.string().optional()
588
+ })
589
+ ).max(256).optional(),
590
+ localDir: z2.string().optional(),
591
+ counts: z2.object({
592
+ total: z2.number(),
593
+ bad: z2.number(),
594
+ thin: z2.number(),
595
+ variantsIdentical: z2.number(),
596
+ iterations: z2.number()
597
+ }).optional()
598
+ })
599
+ }),
600
+ toolUseKind: "edit"
601
+ },
602
+ LSP: {
603
+ ...tool({
604
+ description: "Query a language server for code intelligence",
605
+ inputSchema: z2.object({
606
+ operation: z2.enum([
607
+ "goToDefinition",
608
+ "findReferences",
609
+ "hover",
610
+ "documentSymbol",
611
+ "workspaceSymbol",
612
+ "goToImplementation",
613
+ "prepareCallHierarchy",
614
+ "incomingCalls",
615
+ "outgoingCalls"
616
+ ]),
617
+ filePath: z2.string(),
618
+ line: z2.number().int().positive(),
619
+ character: z2.number().int().positive(),
620
+ query: z2.string().optional()
621
+ })
622
+ }),
623
+ toolUseKind: "readonly"
624
+ },
625
+ PowerShell: {
626
+ ...tool({
627
+ description: "Execute a PowerShell command, optionally in background",
628
+ inputSchema: z2.object({
629
+ command: z2.string(),
630
+ timeout: z2.number().optional(),
631
+ description: z2.string().optional(),
632
+ run_in_background: z2.boolean().optional(),
633
+ dangerouslyDisableSandbox: z2.boolean().optional()
634
+ })
635
+ }),
636
+ toolUseKind: "bash"
637
+ },
638
+ PushNotification: {
639
+ ...tool({
640
+ description: "Send a notification for proactive or scheduled work",
641
+ inputSchema: z2.object({
642
+ message: z2.string(),
643
+ status: z2.literal("proactive")
644
+ })
645
+ }),
646
+ toolUseKind: "edit"
647
+ },
648
+ RemoteTrigger: {
649
+ ...tool({
650
+ description: "List, manage, or run a claude.ai Routine trigger",
651
+ inputSchema: z2.object({
652
+ action: z2.enum(["list", "get", "create", "update", "run"]),
653
+ trigger_id: z2.string().optional(),
654
+ body: z2.record(z2.string(), z2.unknown()).optional()
655
+ })
656
+ }),
657
+ toolUseKind: "edit"
658
+ },
659
+ ReportFindings: {
660
+ ...tool({
661
+ description: "Return verified code-review findings",
662
+ inputSchema: z2.object({
663
+ level: z2.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
664
+ findings: z2.array(
665
+ z2.object({
666
+ file: z2.string(),
667
+ line: z2.number().optional(),
668
+ summary: z2.string(),
669
+ short_summary: z2.string().optional(),
670
+ failure_scenario: z2.string(),
671
+ category: z2.string().optional(),
672
+ verdict: z2.enum(["CONFIRMED", "PLAUSIBLE"]).optional(),
673
+ outcome: z2.enum(["fixed", "skipped", "no_change_needed"]).optional()
674
+ })
675
+ ).max(32)
676
+ })
677
+ }),
678
+ toolUseKind: "readonly"
679
+ },
680
+ ScheduleWakeup: {
681
+ ...tool({
682
+ description: "Schedule or stop the next iteration of a dynamic loop",
683
+ inputSchema: z2.object({
684
+ delaySeconds: z2.number().optional(),
685
+ reason: z2.string().optional(),
686
+ prompt: z2.string().optional(),
687
+ stop: z2.boolean().optional()
688
+ })
689
+ }),
690
+ toolUseKind: "edit"
691
+ },
692
+ SendMessage: {
693
+ ...tool({
694
+ description: "Send a plain-text or protocol message to another agent",
695
+ inputSchema: z2.object({
696
+ to: z2.string(),
697
+ summary: z2.string().max(200).optional(),
698
+ message: z2.union([z2.string(), structuredTeamMessageSchema])
699
+ })
700
+ }),
701
+ toolUseKind: "edit"
702
+ },
703
+ SendUserFile: {
704
+ ...tool({
705
+ description: "Send one or more files to the user",
706
+ inputSchema: z2.object({
707
+ files: z2.union([z2.string(), z2.array(z2.string()).min(1)]),
708
+ caption: z2.string().optional(),
709
+ status: z2.enum(["normal", "proactive"]),
710
+ display: z2.enum(["render", "attach"]).optional()
711
+ })
712
+ }),
713
+ toolUseKind: "readonly"
714
+ },
715
+ ShareOnboardingGuide: {
716
+ ...tool({
717
+ description: "Create, update, inspect, or delete an onboarding guide",
718
+ inputSchema: z2.object({
719
+ mode: z2.enum(["check", "update", "create", "delete"]).optional(),
720
+ short_code: z2.string().regex(/^[A-Za-z0-9_-]{1,64}$/).optional()
721
+ })
722
+ }),
723
+ toolUseKind: "edit"
724
+ },
725
+ WaitForMcpServers: {
726
+ ...tool({
727
+ description: "Wait for MCP servers that are still connecting",
728
+ inputSchema: z2.object({
729
+ servers: z2.array(z2.string()).optional()
730
+ })
731
+ }),
732
+ toolUseKind: "readonly"
733
+ },
734
+ Workflow: {
735
+ ...tool({
736
+ description: "Run or resume a dynamic multi-agent workflow",
737
+ inputSchema: z2.object({
738
+ script: z2.string().optional(),
739
+ name: z2.string().optional(),
740
+ description: z2.string().optional(),
741
+ title: z2.string().optional(),
742
+ args: z2.record(z2.string(), z2.unknown()).optional(),
743
+ scriptPath: z2.string().optional(),
744
+ resumeFromRunId: z2.string().optional()
745
+ })
746
+ }),
747
+ toolUseKind: "edit"
748
+ }
426
749
  };
427
750
  var BOOTSTRAP_DIR = ".harness-bootstrap/claude-code";
428
751
  var claudeCodeBridgeCoordsSchema = z2.object({
@@ -435,6 +758,11 @@ var claudeCodeResumeStateSchema = z2.looseObject({
435
758
  bridge: claudeCodeBridgeCoordsSchema.optional()
436
759
  });
437
760
  function createClaudeCode(settings = {}) {
761
+ if (settings.mcpServers != null && Object.prototype.hasOwnProperty.call(settings.mcpServers, "harness-tools")) {
762
+ throw new Error(
763
+ 'Claude Code MCP server name "harness-tools" is reserved for HarnessAgent tools.'
764
+ );
765
+ }
438
766
  let cachedBootstrap;
439
767
  const thinking = settings.thinking ?? {
440
768
  type: "adaptive",
@@ -526,6 +854,7 @@ function createClaudeCode(settings = {}) {
526
854
  proc: void 0,
527
855
  model: settings.model,
528
856
  maxTurns: settings.maxTurns,
857
+ env: settings.env,
529
858
  thinking,
530
859
  isResume: true,
531
860
  continueOnFirstPrompt: false,
@@ -536,7 +865,8 @@ function createClaudeCode(settings = {}) {
536
865
  debug: startOpts.observability?.debug,
537
866
  permissionMode: startOpts.permissionMode,
538
867
  builtinToolFiltering: startOpts.builtinToolFiltering,
539
- skills: startOpts.skills ?? []
868
+ skills: startOpts.skills ?? [],
869
+ mcpServers: settings.mcpServers
540
870
  });
541
871
  } catch {
542
872
  }
@@ -558,7 +888,7 @@ function createClaudeCode(settings = {}) {
558
888
  abortSignal: startOpts.abortSignal
559
889
  }) : void 0;
560
890
  const port = resolveBridgePort(sandboxSession, settings.port);
561
- const token = randomBytes(32).toString("hex");
891
+ const token = settings.mintBridgeToken == null ? randomBytes(32).toString("hex") : settings.mintBridgeToken(sandboxId);
562
892
  const authEnv = resolveClaudeCodeEnv(settings.auth);
563
893
  const env = {
564
894
  ...authEnv,
@@ -656,6 +986,7 @@ function createClaudeCode(settings = {}) {
656
986
  proc,
657
987
  model: settings.model,
658
988
  maxTurns: settings.maxTurns,
989
+ env: settings.env,
659
990
  thinking,
660
991
  isResume: respawnStrategy !== void 0,
661
992
  continueOnFirstPrompt: respawnStrategy !== void 0,
@@ -666,7 +997,8 @@ function createClaudeCode(settings = {}) {
666
997
  debug: startOpts.observability?.debug,
667
998
  permissionMode: startOpts.permissionMode,
668
999
  builtinToolFiltering: startOpts.builtinToolFiltering,
669
- skills: startOpts.skills ?? []
1000
+ skills: startOpts.skills ?? [],
1001
+ mcpServers: settings.mcpServers
670
1002
  });
671
1003
  }
672
1004
  };
@@ -843,6 +1175,7 @@ function createSession({
843
1175
  proc,
844
1176
  model,
845
1177
  maxTurns,
1178
+ env,
846
1179
  thinking,
847
1180
  isResume,
848
1181
  continueOnFirstPrompt,
@@ -853,7 +1186,8 @@ function createSession({
853
1186
  debug,
854
1187
  permissionMode,
855
1188
  builtinToolFiltering,
856
- skills
1189
+ skills,
1190
+ mcpServers
857
1191
  }) {
858
1192
  let stopped = false;
859
1193
  let stopPromise;
@@ -996,8 +1330,10 @@ function createSession({
996
1330
  })),
997
1331
  model,
998
1332
  maxTurns,
1333
+ ...env !== void 0 ? { env } : {},
999
1334
  thinking,
1000
1335
  ...skills.length > 0 ? { skills: skills.map((skill) => skill.name) } : {},
1336
+ ...mcpServers == null ? {} : { mcpServers },
1001
1337
  ...permissionMode ? { permissionMode } : {},
1002
1338
  ...builtinToolFiltering ? { builtinToolFiltering } : {},
1003
1339
  ...debug ? { debug } : {},
@@ -1031,8 +1367,10 @@ function createSession({
1031
1367
  })),
1032
1368
  model,
1033
1369
  maxTurns,
1370
+ ...env !== void 0 ? { env } : {},
1034
1371
  thinking,
1035
1372
  ...skills.length > 0 ? { skills: skills.map((skill) => skill.name) } : {},
1373
+ ...mcpServers == null ? {} : { mcpServers },
1036
1374
  ...permissionMode ? { permissionMode } : {},
1037
1375
  ...builtinToolFiltering ? { builtinToolFiltering } : {},
1038
1376
  ...debug ? { debug } : {},