@skill-harness/adapters 0.26.2 → 0.28.0
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/pi-json.js +21 -3
- package/package.json +2 -2
package/dist/pi-json.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
-
import {
|
|
2
|
+
import { StringDecoder } from "node:string_decoder";
|
|
3
3
|
import { parseTrace, providerFailureFromJsonLine } from "@skill-harness/core";
|
|
4
4
|
/**
|
|
5
5
|
* Run `pi --mode json` and build an execution trace, **streaming**.
|
|
@@ -44,8 +44,7 @@ export function runPiJson(opts) {
|
|
|
44
44
|
child.kill("SIGKILL");
|
|
45
45
|
reject(new Error(`pi --mode json timed out after ${opts.timeoutMs}ms`));
|
|
46
46
|
}, opts.timeoutMs);
|
|
47
|
-
const
|
|
48
|
-
rl.on("line", (line) => {
|
|
47
|
+
const acceptLine = (line) => {
|
|
49
48
|
// Prefilter before the full parse: the events skipped here are both the
|
|
50
49
|
// overwhelming majority of lines and by far the largest.
|
|
51
50
|
//
|
|
@@ -76,6 +75,25 @@ export function runPiJson(opts) {
|
|
|
76
75
|
kept.push(line);
|
|
77
76
|
if (providerFailure === null)
|
|
78
77
|
providerFailure = providerFailureFromJsonLine(line);
|
|
78
|
+
};
|
|
79
|
+
// JSONL is LF-framed. readline also splits legal Unicode string separators
|
|
80
|
+
// on newer Node runtimes, turning valid model text into malformed records.
|
|
81
|
+
const decoder = new StringDecoder("utf8");
|
|
82
|
+
let pending = "";
|
|
83
|
+
child.stdout.on("data", (chunk) => {
|
|
84
|
+
pending += decoder.write(chunk);
|
|
85
|
+
let start = 0, end;
|
|
86
|
+
while ((end = pending.indexOf("\n", start)) >= 0) {
|
|
87
|
+
acceptLine(pending.slice(start, end));
|
|
88
|
+
start = end + 1;
|
|
89
|
+
}
|
|
90
|
+
pending = pending.slice(start);
|
|
91
|
+
});
|
|
92
|
+
child.stdout.on("end", () => {
|
|
93
|
+
pending += decoder.end();
|
|
94
|
+
if (pending)
|
|
95
|
+
acceptLine(pending);
|
|
96
|
+
pending = "";
|
|
79
97
|
});
|
|
80
98
|
child.stderr.on("data", (chunk) => {
|
|
81
99
|
if (stderr.length < MAX_STDERR_CHARS)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skill-harness/adapters",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "skill-harness Pi runner and judge adapter (internal API)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,6 +42,6 @@
|
|
|
42
42
|
"prepack": "node ../../scripts/release-pack.mjs --guard"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@skill-harness/core": "0.
|
|
45
|
+
"@skill-harness/core": "0.28.0"
|
|
46
46
|
}
|
|
47
47
|
}
|