test(auto-reply): fix heartbeat typing block reply assertions

This commit is contained in:
Peter Steinberger
2026-01-12 23:01:53 +00:00
parent a55c880191
commit cf92099d40
2 changed files with 27 additions and 12 deletions

View File

@@ -47,9 +47,18 @@ vi.mock("./queue.js", async () => {
import { runReplyAgent } from "./agent-runner.js"; import { runReplyAgent } from "./agent-runner.js";
type EmbeddedPiAgentParams = { type EmbeddedPiAgentParams = {
onPartialReply?: (payload: { text?: string; mediaUrls?: string[] }) => Promise<void> | void; onPartialReply?: (payload: {
onBlockReply?: (payload: { text?: string; mediaUrls?: string[] }) => Promise<void> | void; text?: string;
onToolResult?: (payload: { text?: string; mediaUrls?: string[] }) => Promise<void> | void; mediaUrls?: string[];
}) => Promise<void> | void;
onBlockReply?: (payload: {
text?: string;
mediaUrls?: string[];
}) => Promise<void> | void;
onToolResult?: (payload: {
text?: string;
mediaUrls?: string[];
}) => Promise<void> | void;
}; };
function createMinimalRun(params?: { function createMinimalRun(params?: {
@@ -277,7 +286,13 @@ describe("runReplyAgent typing (heartbeat)", () => {
await run(); await run();
expect(typing.startTypingOnText).toHaveBeenCalledWith("chunk"); expect(typing.startTypingOnText).toHaveBeenCalledWith("chunk");
expect(onBlockReply).toHaveBeenCalledWith({ text: "chunk", mediaUrls: [] }); expect(onBlockReply).toHaveBeenCalled();
const [blockPayload, blockOpts] = onBlockReply.mock.calls[0] ?? [];
expect(blockPayload).toMatchObject({ text: "chunk", audioAsVoice: false });
expect(blockOpts).toMatchObject({
abortSignal: expect.any(AbortSignal),
timeoutMs: expect.any(Number),
});
}); });
it("signals typing on tool results", async () => { it("signals typing on tool results", async () => {

View File

@@ -629,14 +629,14 @@ export async function applyInlineDirectivesFastLane(params: {
provider: string; provider: string;
model: string; model: string;
initialModelLabel: string; initialModelLabel: string;
formatModelSwitchEvent: (label: string, alias?: string) => string; formatModelSwitchEvent: (label: string, alias?: string) => string;
agentCfg?: NonNullable<ClawdbotConfig["agents"]>["defaults"]; agentCfg?: NonNullable<ClawdbotConfig["agents"]>["defaults"];
modelState: { modelState: {
resolveDefaultThinkingLevel: () => Promise<ThinkLevel | undefined>; resolveDefaultThinkingLevel: () => Promise<ThinkLevel | undefined>;
allowedModelKeys: Set<string>; allowedModelKeys: Set<string>;
allowedModelCatalog: Awaited< allowedModelCatalog: Awaited<
ReturnType< ReturnType<
typeof import("../../agents/model-catalog.js").loadModelCatalog typeof import("../../agents/model-catalog.js").loadModelCatalog
> >
>; >;
resetModelOverride: boolean; resetModelOverride: boolean;