Menu
popagent
publicLatest change 7f6c1d0ed24ffc264e50e9966eaf45024245ba71 - feat: add per-task agent communication by AkurAI Build
import { describe, expect, test } from "bun:test";
import { TaskAgentCommunicationSession } from "../task-agent-communication";
import { createAgentCommunicationTool } from "./agent-communication";
describe("agent communication tool", () => {
test("binds one task session and sender identity across list, send, wait, and reply", async () => {
const session = new TaskAgentCommunicationSession({
taskId: "task-1",
workspaceId: "default",
resourceId: "popagent-user",
participants: ["researcher", "reviewer"],
});
const researcher = createAgentCommunicationTool("researcher", session);
const reviewer = createAgentCommunicationTool("reviewer", session);
expect(await researcher.execute!({ op: "list" }, {} as never)).toEqual({
peers: [{ id: "reviewer", state: "idle" }],
});
const waiting = reviewer.execute!({ op: "wait", from: "researcher", timeoutMs: 1_000 }, {} as never);
const sent = await researcher.execute!({ op: "send", to: "reviewer", message: "Ready?" }, {} as never) as {
receipts: Array<{ messageId?: string }>;
};
const received = await waiting as { message: { id: string } };
expect(sent.receipts[0]?.messageId).toBe(received.message.id);
expect(await reviewer.execute!({
op: "send",
to: "researcher",
message: "Ready.",
replyTo: received.message.id,
}, {} as never)).toMatchObject({ receipts: [{ outcome: "queued" }] });
});
});