sync local pi changes

This commit is contained in:
alex wiesner
2026-04-09 23:14:57 +01:00
parent 18245c778e
commit ec378ebd28
128 changed files with 22510 additions and 3436 deletions

View File

@@ -0,0 +1,38 @@
import test from "node:test";
import assert from "node:assert/strict";
import { normalizePiEvent } from "./normalize.mjs";
test("normalizePiEvent converts tool start events into protocol tool-call records", () => {
const normalized = normalizePiEvent({
type: "tool_execution_start",
toolName: "read",
args: { path: "src/app.ts", offset: 1, limit: 20 },
});
assert.deepEqual(normalized, {
type: "tool_call",
toolName: "read",
args: { path: "src/app.ts", offset: 1, limit: 20 },
});
});
test("normalizePiEvent converts assistant message_end into a final-text record", () => {
const normalized = normalizePiEvent({
type: "message_end",
message: {
role: "assistant",
model: "anthropic/claude-sonnet-4-5",
stopReason: "end_turn",
content: [{ type: "text", text: "Final answer" }],
usage: { input: 10, output: 5, totalTokens: 15, cost: { total: 0.001 } },
},
});
assert.deepEqual(normalized, {
type: "assistant_text",
text: "Final answer",
model: "anthropic/claude-sonnet-4-5",
stopReason: "end_turn",
usage: { input: 10, output: 5, totalTokens: 15, cost: { total: 0.001 } },
});
});