@ai-sdk/harness-claude-code 1.0.66 → 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
@@ -138,6 +138,7 @@ var startMessageSchema = harnessV1BridgeStartBaseSchema.extend({
138
138
  maxTurns: z.number().optional(),
139
139
  env: z.record(z.string(), z.string()).optional(),
140
140
  skills: z.array(z.string()).optional(),
141
+ mcpServers: z.record(z.string(), z.unknown()).optional(),
141
142
  // Resume signal. When true, the bridge passes `{ continue: true }` to the
142
143
  // Claude SDK so the in-workdir thread state is rehydrated. The host sets this
143
144
  // on the first prompt after a cross-process resume.
@@ -149,10 +150,35 @@ var inboundMessageSchema = z.discriminatedUnion("type", [
149
150
  ]);
150
151
 
151
152
  // src/version.ts
152
- var VERSION = true ? "1.0.66" : "0.0.0-test";
153
+ var VERSION = true ? "1.0.67" : "0.0.0-test";
153
154
 
154
155
  // src/claude-code-harness.ts
155
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
+ ]);
156
182
  var CLAUDE_CODE_BUILTIN_TOOLS = {
157
183
  read: commonTool("read", {
158
184
  nativeName: "Read",
@@ -337,23 +363,64 @@ var CLAUDE_CODE_BUILTIN_TOOLS = {
337
363
  timeout: z2.number()
338
364
  })
339
365
  }),
340
- Monitor: tool({
341
- description: "Run and monitor a shell command",
342
- inputSchema: z2.object({
343
- command: z2.string(),
344
- description: z2.string().optional(),
345
- timeout_ms: z2.number().optional(),
346
- persistent: z2.boolean().optional()
347
- })
348
- }),
349
- ListMcpResources: tool({
350
- description: "List resources available from MCP servers",
351
- inputSchema: z2.object({ server: z2.string().optional() })
352
- }),
353
- ReadMcpResource: tool({
354
- description: "Read a specific MCP resource by URI",
355
- inputSchema: z2.object({ server: z2.string(), uri: z2.string() })
356
- }),
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
+ },
357
424
  ExitPlanMode: tool({
358
425
  description: "Exit plan mode with optional permission approvals",
359
426
  inputSchema: z2.looseObject({
@@ -365,6 +432,13 @@ var CLAUDE_CODE_BUILTIN_TOOLS = {
365
432
  ).optional()
366
433
  })
367
434
  }),
435
+ EnterPlanMode: {
436
+ ...tool({
437
+ description: "Enter plan mode",
438
+ inputSchema: z2.object({})
439
+ }),
440
+ toolUseKind: "readonly"
441
+ },
368
442
  EnterWorktree: tool({
369
443
  description: "Create or enter an isolated git worktree",
370
444
  inputSchema: z2.object({
@@ -423,7 +497,255 @@ var CLAUDE_CODE_BUILTIN_TOOLS = {
423
497
  query: z2.string(),
424
498
  max_results: z2.number().optional()
425
499
  })
426
- })
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
+ }
427
749
  };
428
750
  var BOOTSTRAP_DIR = ".harness-bootstrap/claude-code";
429
751
  var claudeCodeBridgeCoordsSchema = z2.object({
@@ -436,6 +758,11 @@ var claudeCodeResumeStateSchema = z2.looseObject({
436
758
  bridge: claudeCodeBridgeCoordsSchema.optional()
437
759
  });
438
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
+ }
439
766
  let cachedBootstrap;
440
767
  const thinking = settings.thinking ?? {
441
768
  type: "adaptive",
@@ -538,7 +865,8 @@ function createClaudeCode(settings = {}) {
538
865
  debug: startOpts.observability?.debug,
539
866
  permissionMode: startOpts.permissionMode,
540
867
  builtinToolFiltering: startOpts.builtinToolFiltering,
541
- skills: startOpts.skills ?? []
868
+ skills: startOpts.skills ?? [],
869
+ mcpServers: settings.mcpServers
542
870
  });
543
871
  } catch {
544
872
  }
@@ -560,7 +888,7 @@ function createClaudeCode(settings = {}) {
560
888
  abortSignal: startOpts.abortSignal
561
889
  }) : void 0;
562
890
  const port = resolveBridgePort(sandboxSession, settings.port);
563
- const token = randomBytes(32).toString("hex");
891
+ const token = settings.mintBridgeToken == null ? randomBytes(32).toString("hex") : settings.mintBridgeToken(sandboxId);
564
892
  const authEnv = resolveClaudeCodeEnv(settings.auth);
565
893
  const env = {
566
894
  ...authEnv,
@@ -669,7 +997,8 @@ function createClaudeCode(settings = {}) {
669
997
  debug: startOpts.observability?.debug,
670
998
  permissionMode: startOpts.permissionMode,
671
999
  builtinToolFiltering: startOpts.builtinToolFiltering,
672
- skills: startOpts.skills ?? []
1000
+ skills: startOpts.skills ?? [],
1001
+ mcpServers: settings.mcpServers
673
1002
  });
674
1003
  }
675
1004
  };
@@ -857,7 +1186,8 @@ function createSession({
857
1186
  debug,
858
1187
  permissionMode,
859
1188
  builtinToolFiltering,
860
- skills
1189
+ skills,
1190
+ mcpServers
861
1191
  }) {
862
1192
  let stopped = false;
863
1193
  let stopPromise;
@@ -1003,6 +1333,7 @@ function createSession({
1003
1333
  ...env !== void 0 ? { env } : {},
1004
1334
  thinking,
1005
1335
  ...skills.length > 0 ? { skills: skills.map((skill) => skill.name) } : {},
1336
+ ...mcpServers == null ? {} : { mcpServers },
1006
1337
  ...permissionMode ? { permissionMode } : {},
1007
1338
  ...builtinToolFiltering ? { builtinToolFiltering } : {},
1008
1339
  ...debug ? { debug } : {},
@@ -1039,6 +1370,7 @@ function createSession({
1039
1370
  ...env !== void 0 ? { env } : {},
1040
1371
  thinking,
1041
1372
  ...skills.length > 0 ? { skills: skills.map((skill) => skill.name) } : {},
1373
+ ...mcpServers == null ? {} : { mcpServers },
1042
1374
  ...permissionMode ? { permissionMode } : {},
1043
1375
  ...builtinToolFiltering ? { builtinToolFiltering } : {},
1044
1376
  ...debug ? { debug } : {},