






























@@ -1441,12 +1441,10 @@ describe("dispatchReplyFromConfig", () => {
1441144114421442await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });
144314431444-expect(replyMediaPathMocks.createReplyMediaPathNormalizer).toHaveBeenCalledWith(
1445-expect.objectContaining({
1446- cfg,
1447-messageProvider: "webchat",
1448-}),
1449-);
1444+const normalizerOptions = replyMediaPathMocks.createReplyMediaPathNormalizer.mock
1445+.calls[0]?.[0] as { cfg?: unknown; messageProvider?: unknown } | undefined;
1446+expect(normalizerOptions?.cfg).toBe(cfg);
1447+expect(normalizerOptions?.messageProvider).toBe("webchat");
14501448expect(dispatcher.sendToolResult).not.toHaveBeenCalled();
14511449expect(dispatcher.sendFinalReply).toHaveBeenCalledWith({ text: "done" });
14521450});
@@ -1472,9 +1470,7 @@ describe("dispatchReplyFromConfig", () => {
14721470};
1473147114741472await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });
1475-expect(dispatcher.sendToolResult).toHaveBeenCalledWith(
1476-expect.objectContaining({ text: "🔧 exec: ls" }),
1477-);
1473+expect(firstToolResultPayload(dispatcher)?.text).toBe("🔧 exec: ls");
14781474expect(dispatcher.sendToolResult).toHaveBeenCalledTimes(1);
14791475expect(dispatcher.sendFinalReply).toHaveBeenCalledTimes(1);
14801476});
@@ -1509,18 +1505,17 @@ describe("dispatchReplyFromConfig", () => {
15091505await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });
1510150615111507expect(dispatcher.sendToolResult).toHaveBeenCalledTimes(1);
1512-expect(firstToolResultPayload(dispatcher)).toEqual(
1513-expect.objectContaining({
1514-text: "Approval required.\n\n```txt\n/approve 117ba06d allow-once\n```",
1515-channelData: {
1516-execApproval: {
1517-approvalId: "117ba06d-1111-2222-3333-444444444444",
1518-approvalSlug: "117ba06d",
1519-allowedDecisions: ["allow-once", "allow-always", "deny"],
1520-},
1521-},
1522-}),
1508+const toolPayload = firstToolResultPayload(dispatcher);
1509+expect(toolPayload?.text).toBe(
1510+"Approval required.\n\n```txt\n/approve 117ba06d allow-once\n```",
15231511);
1512+expect(toolPayload?.channelData).toStrictEqual({
1513+execApproval: {
1514+approvalId: "117ba06d-1111-2222-3333-444444444444",
1515+approvalSlug: "117ba06d",
1516+allowedDecisions: ["allow-once", "allow-always", "deny"],
1517+},
1518+});
15241519expect(dispatcher.sendFinalReply).toHaveBeenCalledWith({ text: "NO_REPLY" });
15251520});
15261521@@ -1544,9 +1539,7 @@ describe("dispatchReplyFromConfig", () => {
15441539};
1545154015461541await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });
1547-expect(dispatcher.sendToolResult).toHaveBeenCalledWith(
1548-expect.objectContaining({ text: "🔧 exec: ls" }),
1549-);
1542+expect(firstToolResultPayload(dispatcher)?.text).toBe("🔧 exec: ls");
15501543expect(dispatcher.sendFinalReply).toHaveBeenCalledTimes(1);
15511544});
15521545@@ -1576,10 +1569,7 @@ describe("dispatchReplyFromConfig", () => {
15761569await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });
1577157015781571expect(dispatcher.sendToolResult).toHaveBeenCalledTimes(2);
1579-expect(dispatcher.sendToolResult).toHaveBeenNthCalledWith(
1580-1,
1581-expect.objectContaining({ text: "🔧 tools/sessions_send" }),
1582-);
1572+expect(firstToolResultPayload(dispatcher)?.text).toBe("🔧 tools/sessions_send");
15831573const sent = (dispatcher.sendToolResult as Mock).mock.calls[1]?.[0] as ReplyPayload | undefined;
15841574expect(sent?.mediaUrl).toBe("https://example.com/tts-native.opus");
15851575expect(sent?.text).toBeUndefined();
@@ -1622,16 +1612,13 @@ describe("dispatchReplyFromConfig", () => {
1622161216231613await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });
162416141625-expect(dispatcher.sendToolResult).toHaveBeenNthCalledWith(
1626-1,
1627-expect.objectContaining({
1628-text: "Inspect code, patch it, run tests.\n\n1. Inspect code\n2. Patch code\n3. Run tests",
1629-}),
1630-);
1631-expect(dispatcher.sendToolResult).toHaveBeenNthCalledWith(
1632-2,
1633-expect.objectContaining({ text: "Working: awaiting approval: pnpm test" }),
1615+expect(firstToolResultPayload(dispatcher)?.text).toBe(
1616+"Inspect code, patch it, run tests.\n\n1. Inspect code\n2. Patch code\n3. Run tests",
16341617);
1618+const secondToolPayload = (dispatcher.sendToolResult as Mock).mock.calls[1]?.[0] as
1619+| ReplyPayload
1620+| undefined;
1621+expect(secondToolPayload?.text).toBe("Working: awaiting approval: pnpm test");
16351622expect(dispatcher.sendToolResult).toHaveBeenCalledTimes(2);
16361623expect(dispatcher.sendFinalReply).toHaveBeenCalledWith({ text: "done" });
16371624});
@@ -1667,10 +1654,7 @@ describe("dispatchReplyFromConfig", () => {
1667165416681655await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });
166916561670-expect(dispatcher.sendToolResult).toHaveBeenNthCalledWith(
1671-1,
1672-expect.objectContaining({ text: "Working: 1 added, 2 modified" }),
1673-);
1657+expect(firstToolResultPayload(dispatcher)?.text).toBe("Working: 1 added, 2 modified");
16741658expect(dispatcher.sendToolResult).toHaveBeenCalledTimes(1);
16751659expect(dispatcher.sendFinalReply).toHaveBeenCalledWith({ text: "done" });
16761660});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。