@ai-sdk/harness-claude-code 1.0.102 → 1.0.104
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 +17 -0
- package/dist/bridge/index.mjs +28 -5
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/bridge/create-emit-stream-event.ts +50 -22
- package/src/claude-code-harness.ts +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @ai-sdk/harness-claude-code
|
|
2
2
|
|
|
3
|
+
## 1.0.104
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f21945b: fix(harness-claude-code): keep non-text tool result content and scalar MCP tool results intact instead of flattening them to a stringified or re-parsed value
|
|
8
|
+
- 0c37bf0: fix(harness): avoid warning about lack of credential brokering support when `credentialForwarding` callback is used to replace all credentials with ephemeral fake secrets
|
|
9
|
+
- Updated dependencies [0c37bf0]
|
|
10
|
+
- @ai-sdk/harness@1.0.100
|
|
11
|
+
|
|
12
|
+
## 1.0.103
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [6bcc0f8]
|
|
17
|
+
- @ai-sdk/provider-utils@5.0.36
|
|
18
|
+
- @ai-sdk/harness@1.0.99
|
|
19
|
+
|
|
3
20
|
## 1.0.102
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/bridge/index.mjs
CHANGED
|
@@ -810,9 +810,12 @@ function createEmitStreamEvent({
|
|
|
810
810
|
const toolName = toCommonName2(nativeName);
|
|
811
811
|
const dynamic = state.externalMcpToolUseIds.delete(block.tool_use_id);
|
|
812
812
|
const isError = !!block.is_error;
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
|
|
813
|
+
const result = toolUseResult !== void 0 ? toolUseResult : resolveToolResult({
|
|
814
|
+
toolName,
|
|
815
|
+
dynamic,
|
|
816
|
+
isError,
|
|
817
|
+
rawContent: block.content
|
|
818
|
+
});
|
|
816
819
|
emit({
|
|
817
820
|
type: "tool-result",
|
|
818
821
|
toolCallId: block.tool_use_id,
|
|
@@ -947,18 +950,38 @@ function handleStreamEvent({
|
|
|
947
950
|
}
|
|
948
951
|
}
|
|
949
952
|
}
|
|
953
|
+
function isTextEntry(entry) {
|
|
954
|
+
return entry != null && typeof entry === "object" && "text" in entry;
|
|
955
|
+
}
|
|
950
956
|
function stringifyContent(content) {
|
|
951
957
|
if (typeof content === "string") return content;
|
|
952
958
|
if (Array.isArray(content)) {
|
|
953
959
|
return content.map(
|
|
954
|
-
(entry) => entry
|
|
960
|
+
(entry) => isTextEntry(entry) ? String(entry.text ?? "") : JSON.stringify(entry)
|
|
955
961
|
).join("");
|
|
956
962
|
}
|
|
957
963
|
return JSON.stringify(content);
|
|
958
964
|
}
|
|
965
|
+
function hasNonTextContent(content) {
|
|
966
|
+
return Array.isArray(content) && content.some((entry) => !isTextEntry(entry));
|
|
967
|
+
}
|
|
968
|
+
function resolveToolResult({
|
|
969
|
+
toolName,
|
|
970
|
+
dynamic,
|
|
971
|
+
isError,
|
|
972
|
+
rawContent
|
|
973
|
+
}) {
|
|
974
|
+
if (toolName === "bash") {
|
|
975
|
+
return { exitCode: isError ? 1 : 0, stdout: stringifyContent(rawContent) };
|
|
976
|
+
}
|
|
977
|
+
if (hasNonTextContent(rawContent)) return rawContent;
|
|
978
|
+
const content = stringifyContent(rawContent);
|
|
979
|
+
return dynamic ? parseMcpToolResult(content) : content;
|
|
980
|
+
}
|
|
959
981
|
function parseMcpToolResult(content) {
|
|
960
982
|
try {
|
|
961
|
-
|
|
983
|
+
const parsed = JSON.parse(content);
|
|
984
|
+
return parsed !== null && typeof parsed === "object" ? parsed : content;
|
|
962
985
|
} catch {
|
|
963
986
|
return content;
|
|
964
987
|
}
|