@ai-sdk/harness-claude-code 1.0.121 → 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 +12 -0
- package/dist/bridge/index.mjs +22 -13
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +34 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/bridge/create-emit-stream-event.ts +8 -7
- package/src/bridge/index.ts +6 -5
- package/src/bridge/json-schema-to-zod.ts +16 -3
- package/src/claude-code-harness.ts +48 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
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
|
+
|
|
3
15
|
## 1.0.121
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/bridge/index.mjs
CHANGED
|
@@ -779,11 +779,12 @@ function createEmitStreamEvent({
|
|
|
779
779
|
});
|
|
780
780
|
return;
|
|
781
781
|
}
|
|
782
|
-
|
|
783
|
-
|
|
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
|
|
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" &&
|
|
833
|
-
const toolResultBlocks =
|
|
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
|
|
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
|
|
1091
|
+
function jsonSchemaToZodObject(input) {
|
|
1091
1092
|
const schema = isJsonSchemaObject(input) ? input : {};
|
|
1092
|
-
return
|
|
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
|
|
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
|
-
|
|
1493
|
-
server.tool(
|
|
1500
|
+
server.registerTool(
|
|
1494
1501
|
tool.name,
|
|
1495
|
-
|
|
1496
|
-
|
|
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"];
|