e5e6de2fad
- Replace bun:test with vitest across all packages - Replace bun build with esbuild - Replace bun:sqlite with better-sqlite3 - Fix OCAS Store API: store.put/get → store.cas.put/get - Fix vitest vi.mock hoisting (vi.hoisted) - Add pnpm-workspace.yaml and pnpm-lock.yaml - Update all package.json test/build scripts WIP: 8 failures remain in agent-hermes (bun engines check + sqlite migration) Refs #26
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
import { HermesAcpClient } from "../src/acp-client.js";
|
|
|
|
describe("handleSessionUpdate — text extraction", () => {
|
|
let client: HermesAcpClient;
|
|
|
|
beforeEach(() => {
|
|
client = new HermesAcpClient();
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await client.close();
|
|
});
|
|
|
|
it("agent_message_chunk accumulates text in messageChunks", () => {
|
|
(
|
|
client as unknown as { handleSessionUpdate: (u: Record<string, unknown>) => void }
|
|
).handleSessionUpdate({
|
|
sessionUpdate: "agent_message_chunk",
|
|
content: { type: "text", text: "hello" },
|
|
});
|
|
(
|
|
client as unknown as { handleSessionUpdate: (u: Record<string, unknown>) => void }
|
|
).handleSessionUpdate({
|
|
sessionUpdate: "agent_message_chunk",
|
|
content: { type: "text", text: " world" },
|
|
});
|
|
expect((client as unknown as { messageChunks: string[] }).messageChunks).toEqual([
|
|
"hello",
|
|
" world",
|
|
]);
|
|
});
|
|
|
|
it("non-text chunks and other update types are ignored", () => {
|
|
(
|
|
client as unknown as { handleSessionUpdate: (u: Record<string, unknown>) => void }
|
|
).handleSessionUpdate({
|
|
sessionUpdate: "agent_message_chunk",
|
|
content: { type: "image", text: "ignored" },
|
|
});
|
|
(
|
|
client as unknown as { handleSessionUpdate: (u: Record<string, unknown>) => void }
|
|
).handleSessionUpdate({
|
|
sessionUpdate: "tool_call",
|
|
title: "Bash",
|
|
toolCallId: "tc-1",
|
|
});
|
|
(
|
|
client as unknown as { handleSessionUpdate: (u: Record<string, unknown>) => void }
|
|
).handleSessionUpdate({ sessionUpdate: "unknown_type", data: {} });
|
|
expect((client as unknown as { messageChunks: string[] }).messageChunks).toHaveLength(0);
|
|
});
|
|
});
|