@skill-harness/adapters 0.8.0 → 0.10.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/closed-schema.d.ts +50 -0
- package/dist/closed-schema.js +353 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/pi-daddy-ledger-v2.d.ts +460 -0
- package/dist/pi-daddy-ledger-v2.js +649 -0
- package/dist/pi-json.d.ts +21 -0
- package/dist/pi-json.js +1 -1
- package/dist/pi.js +30 -2
- package/dist/trajectory.d.ts +56 -0
- package/dist/trajectory.js +1104 -0
- package/package.json +2 -2
package/dist/pi.js
CHANGED
|
@@ -2,7 +2,8 @@ import { existsSync, mkdtempSync, readFileSync, statSync } from "node:fs";
|
|
|
2
2
|
import { tmpdir, homedir } from "node:os";
|
|
3
3
|
import { join, resolve } from "node:path";
|
|
4
4
|
import { runPiJson } from "./pi-json.js";
|
|
5
|
-
import {
|
|
5
|
+
import { collectTrajectorySources, normalizePiTraces, resequence } from "./trajectory.js";
|
|
6
|
+
import { exec, onPath, envNum, traceSha256 } from "@skill-harness/core";
|
|
6
7
|
const PI_TIMEOUT_MS = envNum("PI_TIMEOUT_MS", 300_000);
|
|
7
8
|
/**
|
|
8
9
|
* Refuse to hand pi a skill dir it will silently ignore.
|
|
@@ -205,13 +206,40 @@ export const piAdapter = {
|
|
|
205
206
|
` (exit ${r.code}${r.malformedLines ? `, ${r.malformedLines} malformed line(s)` : ""})` +
|
|
206
207
|
(r.stderr.trim() ? `: ${r.stderr.trim()}` : ""));
|
|
207
208
|
}
|
|
209
|
+
if (r.malformedLines > 0) {
|
|
210
|
+
r.trace.capture_errors = [`pi JSONL contained ${r.malformedLines} malformed line(s); absence-based trace assertions are unsafe`];
|
|
211
|
+
r.trace.trace_sha256 = traceSha256(r.trace);
|
|
212
|
+
}
|
|
208
213
|
traces.push(r.trace);
|
|
209
214
|
parts.push(header(i + 1, total, req.turns[i]));
|
|
210
215
|
parts.push(`<<< ASSISTANT:\n${r.trace.final_text.trim()}\n`);
|
|
211
216
|
if (r.code !== 0)
|
|
212
217
|
parts.push(`[pi exited ${r.code} on turn ${i + 1}]\n${r.stderr.trim()}\n`);
|
|
213
218
|
}
|
|
214
|
-
|
|
219
|
+
const native = req.eventSources?.length
|
|
220
|
+
? collectTrajectorySources(req.cwd, req.eventSources)
|
|
221
|
+
: { events: [], errors: [] };
|
|
222
|
+
const piEvents = normalizePiTraces(traces);
|
|
223
|
+
const combined = [...piEvents, ...native.events];
|
|
224
|
+
const chronologyErrors = [];
|
|
225
|
+
if (piEvents.length && native.events.length) {
|
|
226
|
+
if (combined.some((event) => !event.at || !Number.isFinite(Date.parse(event.at)))) {
|
|
227
|
+
chronologyErrors.push("pi/native events cannot be globally ordered because at least one event has no valid `at` timestamp");
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
const piTimes = new Set(piEvents.map((event) => Date.parse(event.at)));
|
|
231
|
+
if (native.events.some((event) => piTimes.has(Date.parse(event.at)))) {
|
|
232
|
+
chronologyErrors.push("pi/native events contain equal timestamps, so strict cross-source order is ambiguous");
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
const eventErrors = [...native.errors, ...chronologyErrors];
|
|
237
|
+
return {
|
|
238
|
+
transcript: parts.join("\n"),
|
|
239
|
+
traces,
|
|
240
|
+
events: resequence(combined),
|
|
241
|
+
...(eventErrors.length ? { eventErrors } : {}),
|
|
242
|
+
};
|
|
215
243
|
},
|
|
216
244
|
/**
|
|
217
245
|
* Run the judge: no skills, no context files, no session, single prompt.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ExecutionTraceV1, TrajectoryEventSource, TrajectoryEventV1 } from "@skill-harness/core";
|
|
2
|
+
export interface CollectedTrajectorySources {
|
|
3
|
+
events: TrajectoryEventV1[];
|
|
4
|
+
errors: string[];
|
|
5
|
+
}
|
|
6
|
+
/** Read and normalize declared workspace-local native ledger files. */
|
|
7
|
+
export declare function collectTrajectorySources(cwd: string, sources: TrajectoryEventSource[]): CollectedTrajectorySources;
|
|
8
|
+
/** Combine independently sequenced sources by recorded time while retaining each native sequence. */
|
|
9
|
+
export declare function resequence(events: TrajectoryEventV1[]): TrajectoryEventV1[];
|
|
10
|
+
/** Normalize pi's structured calls into adapter-neutral start/completion events. */
|
|
11
|
+
export declare function normalizePiTraces(traces: ExecutionTraceV1[]): TrajectoryEventV1[];
|
|
12
|
+
/** Normalize principal-pi-skills' immutable assurance event schema v1.0. */
|
|
13
|
+
export declare function normalizePrincipalAssuranceLedger(text: string): TrajectoryEventV1[];
|
|
14
|
+
/**
|
|
15
|
+
* Normalize pi-daddy's public ledgers: unversioned 0.17 GrantRecord lines and
|
|
16
|
+
* ledgerVersion 2 runtime events emitted by 0.18.0. Version detection precedes
|
|
17
|
+
* the legacy fallback so a new event can never be misdiagnosed as an old grant.
|
|
18
|
+
*/
|
|
19
|
+
export declare function normalizePiDaddyLedger(text: string): TrajectoryEventV1[];
|
|
20
|
+
/**
|
|
21
|
+
* pi-daddy's canonical refusal vocabulary, in the pinned contract's own order.
|
|
22
|
+
*
|
|
23
|
+
* This is a copy of `#/$defs/refusalCode` from the pinned schema and is exported
|
|
24
|
+
* so `pi-daddy-contract.test.ts` can assert set equality against the producer
|
|
25
|
+
* artifact — a hand-maintained second vocabulary without that drift assertion is
|
|
26
|
+
* exactly how `GRANT_ID_MALFORMED` came to be rejected as "unsupported".
|
|
27
|
+
*/
|
|
28
|
+
export declare const V2_REFUSAL_CODES: Set<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Every vocabulary the adapter restates from the pinned contract, paired with the
|
|
31
|
+
* place in the schema it must equal.
|
|
32
|
+
*
|
|
33
|
+
* The closed schema gates first, so a semantic check that has drifted *narrower*
|
|
34
|
+
* than the contract no longer opens a hole — it produces the opposite failure:
|
|
35
|
+
* a contract-valid record admitted by the schema and then thrown out by a stale
|
|
36
|
+
* harness set, which is precisely what `GRANT_ID_MALFORMED` did. One manifest, one
|
|
37
|
+
* test over all of it, so re-pinning cannot quietly leave a set behind.
|
|
38
|
+
*/
|
|
39
|
+
export declare const V2_RESTATED_VOCABULARIES: ReadonlyArray<{
|
|
40
|
+
name: string;
|
|
41
|
+
kind: "enum" | "propertyNames" | "discriminators" | "typeNames" | "numericPropertyNames";
|
|
42
|
+
pointer: string;
|
|
43
|
+
values: ReadonlySet<string>;
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* Harness-side subsets of a contract vocabulary, not restatements of one. They encode
|
|
47
|
+
* the harness's own semantics — which lease outcomes a receipt may be appended after,
|
|
48
|
+
* and which may precede that release — so the assertion on them is containment, not
|
|
49
|
+
* equality. Anything the test *equality*-asserts belongs in the manifest above
|
|
50
|
+
* instead; membership here is a claim that the harness deliberately holds a subset.
|
|
51
|
+
*/
|
|
52
|
+
export declare const V2_VOCABULARY_SUBSETS: ReadonlyArray<{
|
|
53
|
+
name: string;
|
|
54
|
+
pointer: string;
|
|
55
|
+
values: ReadonlySet<string>;
|
|
56
|
+
}>;
|