@ai-sdk/harness-claude-code 1.0.99 → 1.0.101

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @ai-sdk/harness-claude-code
2
2
 
3
+ ## 1.0.101
4
+
5
+ ### Patch Changes
6
+
7
+ - @ai-sdk/harness@1.0.97
8
+
9
+ ## 1.0.100
10
+
11
+ ### Patch Changes
12
+
13
+ - c0c7fac: feat(harness): add reusable `createReadBridgeAsset()` helper function
14
+ - ce6df5b: fix(harness-claude-code): use structured `tool_result` blocks when present for tool results instead of agent-facing response
15
+ - 7388399: fix(harness-claude-code): mark approval-gated external MCP tool calls as dynamic
16
+ - Updated dependencies [c0c7fac]
17
+ - @ai-sdk/harness@1.0.96
18
+
3
19
  ## 1.0.99
4
20
 
5
21
  ### Patch Changes
@@ -680,6 +680,10 @@ function createClaudeStreamEventState() {
680
680
  };
681
681
  }
682
682
  var UNRECOVERABLE_API_RETRY_STATUSES = /* @__PURE__ */ new Set([401, 403, 404]);
683
+ var HOST_TOOL_PREFIX = "mcp__harness-tools__";
684
+ function isExternalMcpTool(nativeName) {
685
+ return nativeName.startsWith("mcp__") && !nativeName.startsWith(HOST_TOOL_PREFIX);
686
+ }
683
687
  function createEmitStreamEvent({
684
688
  state,
685
689
  emit,
@@ -754,15 +758,14 @@ function createEmitStreamEvent({
754
758
  state.structuredOutputToolUseIds.add(block.id);
755
759
  continue;
756
760
  }
757
- const mcpPrefix = "mcp__harness-tools__";
758
- if (block.name.startsWith(mcpPrefix)) {
761
+ if (block.name.startsWith(HOST_TOOL_PREFIX)) {
759
762
  state.pendingStepToolUseIds.add(block.id);
760
763
  state.mcpToolUseIds.add(block.id);
761
764
  opensStep = true;
762
765
  continue;
763
766
  }
764
767
  state.nativeToolCallNames.set(block.id, block.name);
765
- const dynamic = block.name.startsWith("mcp__");
768
+ const dynamic = isExternalMcpTool(block.name);
766
769
  if (dynamic) state.externalMcpToolUseIds.add(block.id);
767
770
  if (state.approvalRequestedToolUseIds.has(block.id)) {
768
771
  continue;
@@ -787,6 +790,10 @@ function createEmitStreamEvent({
787
790
  return;
788
791
  }
789
792
  if (type === "user" && msg.message?.content) {
793
+ const toolResultBlocks = msg.message.content.filter(
794
+ (block) => block.type === "tool_result"
795
+ );
796
+ const toolUseResult = toolResultBlocks.length === 1 ? msg.tool_use_result : void 0;
790
797
  for (const block of msg.message.content) {
791
798
  if (block.type === "tool_result" && typeof block.tool_use_id === "string") {
792
799
  if (state.structuredOutputToolUseIds.delete(block.tool_use_id)) {
@@ -804,7 +811,8 @@ function createEmitStreamEvent({
804
811
  const dynamic = state.externalMcpToolUseIds.delete(block.tool_use_id);
805
812
  const isError = !!block.is_error;
806
813
  const content = stringifyContent(block.content);
807
- const result = toolName === "bash" ? { exitCode: isError ? 1 : 0, stdout: content } : dynamic ? parseMcpToolResult(content) : content;
814
+ const contentResult = toolName === "bash" ? { exitCode: isError ? 1 : 0, stdout: content } : dynamic ? parseMcpToolResult(content) : content;
815
+ const result = toolUseResult !== void 0 ? toolUseResult : contentResult;
808
816
  emit({
809
817
  type: "tool-result",
810
818
  toolCallId: block.tool_use_id,
@@ -868,7 +876,6 @@ function formatApiRetryWarning(msg) {
868
876
  if (msg.error) details.push(msg.error);
869
877
  return details.length > 0 ? `Claude Code API retry: ${details.join("; ")}` : "Claude Code API retry";
870
878
  }
871
- var HOST_TOOL_PREFIX = "mcp__harness-tools__";
872
879
  function handleStreamEvent({
873
880
  event,
874
881
  state,
@@ -895,7 +902,7 @@ function handleStreamEvent({
895
902
  return;
896
903
  }
897
904
  const hostToolName = nativeName.startsWith(HOST_TOOL_PREFIX) ? nativeName.slice(HOST_TOOL_PREFIX.length) : void 0;
898
- const dynamic = hostToolName === void 0 && nativeName.startsWith("mcp__");
905
+ const dynamic = isExternalMcpTool(nativeName);
899
906
  partialBlocks.set(index, { id, kind: "tool-input" });
900
907
  send({
901
908
  type: "tool-input-start",
@@ -1208,7 +1215,8 @@ function createPermissionOptions(input) {
1208
1215
  toolName: toCommonName(toolName),
1209
1216
  nativeName: toolName,
1210
1217
  input: JSON.stringify(toolInput ?? {}),
1211
- providerExecuted: true
1218
+ providerExecuted: true,
1219
+ ...isExternalMcpTool(toolName) ? { dynamic: true } : {}
1212
1220
  });
1213
1221
  input.emit({
1214
1222
  type: "tool-approval-request",