refactor: tighten canonical tool-call typing and display mapping

This commit is contained in:
Mohamed Boudra
2026-02-09 08:53:27 +07:00
parent 0176614467
commit 6d4992b2f5
25 changed files with 2833 additions and 1764 deletions
@@ -13,17 +13,10 @@ function loadFixture(name: string): unknown {
}
describe("shared messages stream parsing", () => {
it("parses legacy inProgress tool_call snapshots and normalizes status", () => {
it("rejects legacy inProgress tool_call snapshots", () => {
const fixture = loadFixture("legacy-agent-stream-snapshot-inProgress.json");
const parsed = AgentStreamSnapshotMessageSchema.parse(fixture);
const first = parsed.payload.events[0]?.event;
expect(first?.type).toBe("timeline");
if (first?.type === "timeline" && first.item.type === "tool_call") {
expect(first.item.status).toBe("running");
expect(first.item.error).toBeNull();
expect(first.item.output).toBeNull();
}
const parsed = AgentStreamSnapshotMessageSchema.safeParse(fixture);
expect(parsed.success).toBe(false);
});
it("parses representative agent_stream tool_call event", () => {
@@ -61,24 +54,16 @@ describe("shared messages stream parsing", () => {
}
});
it("parses websocket envelope for agent_stream_snapshot with legacy status", () => {
it("rejects websocket envelope for agent_stream_snapshot with legacy status", () => {
const fixture = loadFixture("legacy-agent-stream-snapshot-inProgress.json") as {
type: "agent_stream_snapshot";
payload: unknown;
};
const wrapped = WSOutboundMessageSchema.parse({
const wrapped = WSOutboundMessageSchema.safeParse({
type: "session",
message: fixture,
});
if (wrapped.type === "session" && wrapped.message.type === "agent_stream_snapshot") {
const first = wrapped.message.payload.events[0]?.event;
expect(first?.type).toBe("timeline");
if (first?.type === "timeline" && first.item.type === "tool_call") {
expect(first.item.status).toBe("running");
expect(first.item.error).toBeNull();
}
}
expect(wrapped.success).toBe(false);
});
});