mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-03 01:29:56 +00:00
* fix: show skipped tools separately from blocked activity * fix(sdk): preserve non-success events for skipped tools * fix(ci): preboot simulators before SimSlim reconfiguration * fix(android): fold late skipped results into completed work
44 lines
1.6 KiB
TypeScript
44 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { normalizeGatewayEvent } from "./normalize.js";
|
|
|
|
// Terminal tool/item events are emitted with phase:"end" plus the real status
|
|
// (running|completed|failed|blocked), so failed/blocked must not collapse to completed.
|
|
function agentItemEvent(data: Record<string, unknown>) {
|
|
return { event: "agent", payload: { runId: "r1", stream: "item", data } };
|
|
}
|
|
|
|
describe("normalizeGatewayEvent IDs", () => {
|
|
it.each([
|
|
{ field: "sequence", seq: 0, ts: 123, expectedId: "0:agent:r1:main:123" },
|
|
{ field: "timestamp", seq: 1, ts: 0, expectedId: "1:agent:r1:main:0" },
|
|
])("preserves zero $field values", ({ seq, ts, expectedId }) => {
|
|
const event = normalizeGatewayEvent({
|
|
event: "agent",
|
|
seq,
|
|
payload: {
|
|
runId: "r1",
|
|
sessionKey: "main",
|
|
ts,
|
|
stream: "lifecycle",
|
|
data: { phase: "start" },
|
|
},
|
|
});
|
|
|
|
expect(event.id).toBe(expectedId);
|
|
expect(event.ts).toBe(ts);
|
|
});
|
|
});
|
|
|
|
describe("normalizeGatewayEvent terminal tool item status", () => {
|
|
it.each([
|
|
[{ phase: "end", status: "failed" }, "tool.call.failed"],
|
|
[{ phase: "end", status: "blocked" }, "tool.call.failed"],
|
|
[{ phase: "end", status: "completed" }, "tool.call.completed"],
|
|
[{ phase: "end", status: "skipped" }, "tool.call.failed"],
|
|
[{ phase: "end" }, "tool.call.completed"],
|
|
])("classifies %j as %s", (data, expectedType) => {
|
|
const event = normalizeGatewayEvent(agentItemEvent(data));
|
|
expect(event.type).toBe(expectedType);
|
|
expect(event.data).toEqual(data);
|
|
});
|
|
});
|