import type { MessageBlock } from "@rakazo/contracts"; import { describe, expect, it } from "vitest"; import { isToolActivityBlock } from "./tool-activity.js"; describe("tool activity", () => { it.each([ { kind: "steps", steps: [{ label: "Browser", count: 1 }] }, { kind: "progress", text: "Using browser", activity: true }, { kind: "progress", text: "Using brex: list_expenses", activity: true }, ])("recognizes $kind activity", (block) => { expect(isToolActivityBlock(block)).toBe(true); }); it("keeps assistant narration separate from tool activity", () => { expect(isToolActivityBlock({ kind: "progress", text: "I’m checking that now." })).toBe(false); expect(isToolActivityBlock({ kind: "progress", text: "Using browser" })).toBe(false); expect( isToolActivityBlock({ kind: "progress", text: "Let me check", pendingToolNames: ["browser"], }), ).toBe(false); expect( isToolActivityBlock({ kind: "progress", text: "Using the search results, I found it." }), ).toBe(false); expect( isToolActivityBlock({ kind: "progress", text: "Using the search results, I found…", }), ).toBe(false); expect( isToolActivityBlock({ kind: "progress", text: "Using these notes, here is a summary.", }), ).toBe(false); expect(isToolActivityBlock({ kind: "text", text: "Done." })).toBe(false); }); });