@hmharness/kernel 0.23.33 → 0.23.34
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/loop.js +15 -2
- package/package.json +28 -28
package/dist/loop.js
CHANGED
|
@@ -26,7 +26,14 @@ export function sanitizeToolCalls(calls) {
|
|
|
26
26
|
if (!c.function?.arguments)
|
|
27
27
|
return { ...c, function: { ...c.function, arguments: '{}' } };
|
|
28
28
|
try {
|
|
29
|
-
JSON
|
|
29
|
+
// Tool arguments must be a JSON OBJECT: "str" / null / [1,2] / 42 all
|
|
30
|
+
// parse fine but leave tools reading undefined fields (v0.23.34
|
|
31
|
+
// hardening - "空/截断/非对象 arguments"). Rewritten to '{}' like the
|
|
32
|
+
// rest: valid on the wire, harmless to execute.
|
|
33
|
+
const parsed = JSON.parse(c.function.arguments);
|
|
34
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
35
|
+
return { ...c, function: { ...c.function, arguments: '{}' } };
|
|
36
|
+
}
|
|
30
37
|
return c;
|
|
31
38
|
}
|
|
32
39
|
catch {
|
|
@@ -162,7 +169,13 @@ export async function runLoop(opts) {
|
|
|
162
169
|
let badArgs = false;
|
|
163
170
|
if (rawArgs) {
|
|
164
171
|
try {
|
|
165
|
-
|
|
172
|
+
const parsed = JSON.parse(rawArgs);
|
|
173
|
+
// valid JSON but NOT an object ("str"/null/[1,2]/42): tools would
|
|
174
|
+
// read undefined fields - treat like unparseable (skip + clear msg)
|
|
175
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed))
|
|
176
|
+
badArgs = true;
|
|
177
|
+
else
|
|
178
|
+
args = parsed;
|
|
166
179
|
}
|
|
167
180
|
catch {
|
|
168
181
|
badArgs = true;
|
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@hmharness/kernel",
|
|
3
|
-
"version": "0.23.
|
|
4
|
-
"description": "hmharness kernel: tool registry, provider adapters, the agent loop, session log, config. Zero runtime dependencies (Node >=22 native fetch).",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./dist/index.d.ts",
|
|
10
|
-
"default": "./dist/index.js"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"types": "dist/index.d.ts",
|
|
14
|
-
"files": [
|
|
15
|
-
"dist"
|
|
16
|
-
],
|
|
17
|
-
"engines": {
|
|
18
|
-
"node": ">=22"
|
|
19
|
-
},
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"repository": {
|
|
22
|
-
"type": "git",
|
|
23
|
-
"url": "git+https://github.com/swsgbl/hmharness.git"
|
|
24
|
-
},
|
|
25
|
-
"scripts": {
|
|
26
|
-
"build": "tsc -p tsconfig.build.json"
|
|
27
|
-
}
|
|
28
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@hmharness/kernel",
|
|
3
|
+
"version": "0.23.34",
|
|
4
|
+
"description": "hmharness kernel: tool registry, provider adapters, the agent loop, session log, config. Zero runtime dependencies (Node >=22 native fetch).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"types": "dist/index.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=22"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/swsgbl/hmharness.git"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc -p tsconfig.build.json"
|
|
27
|
+
}
|
|
28
|
+
}
|