@ai-sdk/harness-claude-code 1.0.120 → 1.0.122

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,27 @@
1
1
  # @ai-sdk/harness-claude-code
2
2
 
3
+ ## 1.0.122
4
+
5
+ ### Patch Changes
6
+
7
+ - d975097: feat(harness): add `AbortSignal` to `SandboxChannel.connect`, plus a `sleep()` helper function
8
+ - 44f860b: fix(harness-claude-code): preserve open-object tool parameters
9
+ - e3ff272: fix(harness-claude-code): ignore non-array user messages when converting tool results
10
+ - c0e5d1d: feat(harness): allow consumers of bridge backed harnesses to configure `reconnect` timeout
11
+ - Updated dependencies [d975097]
12
+ - Updated dependencies [b2baeba]
13
+ - @ai-sdk/harness@1.0.118
14
+
15
+ ## 1.0.121
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [2973485]
20
+ - Updated dependencies [a4db5ea]
21
+ - Updated dependencies [2937ea2]
22
+ - @ai-sdk/provider-utils@5.0.45
23
+ - @ai-sdk/harness@1.0.117
24
+
3
25
  ## 1.0.120
4
26
 
5
27
  ### Patch Changes
@@ -779,11 +779,12 @@ function createEmitStreamEvent({
779
779
  });
780
780
  return;
781
781
  }
782
- if (type === "assistant" && msg.message?.content) {
783
- const usage = toUsageRecord(msg.message.usage);
782
+ const messageContent = msg.message?.content;
783
+ if (type === "assistant" && Array.isArray(messageContent)) {
784
+ const usage = toUsageRecord(msg.message?.usage);
784
785
  const toolUseIds = [];
785
786
  let opensStep = false;
786
- for (const block of msg.message.content) {
787
+ for (const block of messageContent) {
787
788
  if (block.type === "tool_use" && typeof block.id === "string" && typeof block.name === "string") {
788
789
  toolUseIds.push(block.id);
789
790
  if (block.name === "StructuredOutput") {
@@ -829,12 +830,12 @@ function createEmitStreamEvent({
829
830
  }
830
831
  return;
831
832
  }
832
- if (type === "user" && msg.message?.content) {
833
- const toolResultBlocks = msg.message.content.filter(
833
+ if (type === "user" && Array.isArray(messageContent)) {
834
+ const toolResultBlocks = messageContent.filter(
834
835
  (block) => block.type === "tool_result"
835
836
  );
836
837
  const toolUseResult = toolResultBlocks.length === 1 ? msg.tool_use_result : void 0;
837
- for (const block of msg.message.content) {
838
+ for (const block of messageContent) {
838
839
  if (block.type === "tool_result" && typeof block.tool_use_id === "string") {
839
840
  if (state.structuredOutputToolUseIds.delete(block.tool_use_id)) {
840
841
  continue;
@@ -1087,9 +1088,16 @@ function defaultUsage() {
1087
1088
 
1088
1089
  // src/bridge/json-schema-to-zod.ts
1089
1090
  import { z } from "zod/v4";
1090
- function jsonSchemaToZodShape(input) {
1091
+ function jsonSchemaToZodObject(input) {
1091
1092
  const schema = isJsonSchemaObject(input) ? input : {};
1092
- return toZodShape(schema);
1093
+ return toZodObject(schema);
1094
+ }
1095
+ function toZodObject(schema) {
1096
+ const object = z.object(toZodShape(schema));
1097
+ if (schema.additionalProperties === false) return object.strict();
1098
+ return object.catchall(
1099
+ isJsonSchemaObject(schema.additionalProperties) ? toZodType(schema.additionalProperties) : z.unknown()
1100
+ );
1093
1101
  }
1094
1102
  function toZodShape(schema) {
1095
1103
  if (!schema?.properties) return {};
@@ -1131,7 +1139,7 @@ function zodForType(schema) {
1131
1139
  Array.isArray(schema.items) ? z.any() : toZodType(schema.items)
1132
1140
  );
1133
1141
  case "object":
1134
- return z.object(toZodShape(schema));
1142
+ return toZodObject(schema);
1135
1143
  case "null":
1136
1144
  return z.null();
1137
1145
  default:
@@ -1489,11 +1497,12 @@ async function runTurn(start, turn) {
1489
1497
  version: "1.0.0"
1490
1498
  });
1491
1499
  for (const tool of start.tools) {
1492
- const shape = jsonSchemaToZodShape(tool.inputSchema);
1493
- server.tool(
1500
+ server.registerTool(
1494
1501
  tool.name,
1495
- tool.description ?? "",
1496
- shape,
1502
+ {
1503
+ description: tool.description ?? "",
1504
+ inputSchema: jsonSchemaToZodObject(tool.inputSchema)
1505
+ },
1497
1506
  async (...handlerArgs) => {
1498
1507
  const [input, extra] = handlerArgs;
1499
1508
  const metadataToolCallId = extra._meta?.["claudecode/toolUseId"];