@deepstrike/sdk 0.2.25 → 0.2.27
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/tools/index.js +19 -0
- package/dist/types/agent.js +14 -1
- package/package.json +2 -2
package/dist/tools/index.js
CHANGED
|
@@ -86,6 +86,25 @@ function validateValue(schema, parent, key, path, state) {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
+
else if (expectedType === "array") {
|
|
90
|
+
// coerceItemArray: LLMs commonly wrap array args in a single-key { item: X } / { items: X }
|
|
91
|
+
// envelope, or emit a lone object where a one-element array was expected. Coerce both to an
|
|
92
|
+
// array so per-element validation runs (yielding precise `$.path[i]…` errors) instead of a
|
|
93
|
+
// blunt "must be array". Aligned with the string→number/boolean casts above.
|
|
94
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
95
|
+
const obj = value;
|
|
96
|
+
const objKeys = Object.keys(obj);
|
|
97
|
+
if (objKeys.length === 1 && (objKeys[0] === "item" || objKeys[0] === "items")) {
|
|
98
|
+
const inner = obj[objKeys[0]];
|
|
99
|
+
parent[key] = Array.isArray(inner) ? inner : [inner];
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
parent[key] = [obj];
|
|
103
|
+
}
|
|
104
|
+
value = parent[key];
|
|
105
|
+
state.repaired = true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
89
108
|
}
|
|
90
109
|
// 2. 补默认值 (Default Injection)
|
|
91
110
|
if (expectedType === "object") {
|
package/dist/types/agent.js
CHANGED
|
@@ -66,6 +66,19 @@ export function milestoneCheckResultToKernel(result) {
|
|
|
66
66
|
...(result.reason ? { reason: result.reason } : {}),
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
|
+
/** Tool-call `arguments` reach us as a raw model-authored string (e.g. the OpenAIChat-family
|
|
70
|
+
* non-streaming path passes it through verbatim via `normalizeToolCalls`). A malformed JSON
|
|
71
|
+
* string must degrade to empty args here, never throw — otherwise one bad tool-call on a
|
|
72
|
+
* sub-agent's final turn bricks the parent's result serialization. Mirrors the `catch→{}`
|
|
73
|
+
* guard every provider/runtime parse site already uses. */
|
|
74
|
+
function safeParseToolArgs(raw) {
|
|
75
|
+
try {
|
|
76
|
+
return JSON.parse(raw || "{}");
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return {};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
69
82
|
export function subAgentResultToKernel(result) {
|
|
70
83
|
const finalMessage = result.result.finalMessage;
|
|
71
84
|
return {
|
|
@@ -79,7 +92,7 @@ export function subAgentResultToKernel(result) {
|
|
|
79
92
|
tool_calls: (finalMessage.toolCalls ?? []).map(tc => ({
|
|
80
93
|
id: tc.id,
|
|
81
94
|
name: tc.name,
|
|
82
|
-
arguments:
|
|
95
|
+
arguments: safeParseToolArgs(tc.arguments),
|
|
83
96
|
})),
|
|
84
97
|
...(finalMessage.tokenCount !== undefined ? { token_count: finalMessage.tokenCount } : {}),
|
|
85
98
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepstrike/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.27",
|
|
4
4
|
"description": "DeepStrike Node.js SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@anthropic-ai/sdk": "^0.99.0",
|
|
23
|
-
"@deepstrike/core": "0.2.
|
|
23
|
+
"@deepstrike/core": "0.2.27",
|
|
24
24
|
"@google/generative-ai": "^0.24.1",
|
|
25
25
|
"openai": "^5.23.2"
|
|
26
26
|
},
|