@deepstrike/sdk 0.2.26 → 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.
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepstrike/sdk",
3
- "version": "0.2.26",
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.26",
23
+ "@deepstrike/core": "0.2.27",
24
24
  "@google/generative-ai": "^0.24.1",
25
25
  "openai": "^5.23.2"
26
26
  },