




















@@ -103,6 +103,24 @@ const mocks = vi.hoisted(() => ({
103103),
104104}));
105105106+type RunMessageActionInput = {
107+agentId?: string;
108+cfg?: unknown;
109+params?: Record<string, unknown>;
110+requesterSenderId?: string;
111+sandboxRoot?: string;
112+senderIsOwner?: boolean;
113+sessionKey?: string;
114+toolContext?: {
115+currentThreadTs?: string;
116+replyToMode?: string;
117+};
118+};
119+120+function firstRunMessageActionInput(): RunMessageActionInput | undefined {
121+return mocks.runMessageAction.mock.calls.at(0)?.[0] as RunMessageActionInput | undefined;
122+}
123+106124const openClawToolsFactoryMocks = vi.hoisted(() => {
107125const tool = (name: string) => ({
108126 name,
@@ -330,14 +348,7 @@ async function executeSend(params: {
330348action: "send",
331349 ...params.action,
332350});
333-return mocks.runMessageAction.mock.calls[0]?.[0] as
334-| {
335-params?: Record<string, unknown>;
336-sandboxRoot?: string;
337-requesterSenderId?: string;
338-senderIsOwner?: boolean;
339-}
340-| undefined;
351+return firstRunMessageActionInput();
341352}
342353343354describe("message tool secret scoping", () => {
@@ -474,7 +485,7 @@ describe("message tool secret scoping", () => {
474485expect(secretResolveCall.allowedPaths).toEqual(
475486new Set(["channels.discord.token", "channels.discord.accounts.ops.token"]),
476487);
477-expect(mocks.runMessageAction.mock.calls[0]?.[0]?.cfg).toBe(resolvedConfig);
488+expect(firstRunMessageActionInput()?.cfg).toBe(resolvedConfig);
478489});
479490});
480491@@ -494,7 +505,7 @@ describe("message tool agent routing", () => {
494505message: "hi",
495506});
496507497-const call = mocks.runMessageAction.mock.calls[0]?.[0];
508+const call = firstRunMessageActionInput();
498509expect(call?.agentId).toBe("alpha");
499510expect(call?.sessionKey).toBe("agent:alpha:main");
500511});
@@ -517,7 +528,7 @@ describe("message tool agent routing", () => {
517528message: "stay in thread",
518529});
519530520-const call = mocks.runMessageAction.mock.calls[0]?.[0];
531+const call = firstRunMessageActionInput();
521532expect(call?.toolContext?.currentThreadTs).toBe("111.222");
522533expect(call?.toolContext?.replyToMode).toBe("all");
523534});
@@ -541,7 +552,7 @@ describe("message tool agent routing", () => {
541552message: "send at channel level",
542553});
543554544-const call = mocks.runMessageAction.mock.calls[0]?.[0];
555+const call = firstRunMessageActionInput();
545556expect(call?.toolContext?.currentThreadTs).toBe("111.222");
546557expect(call?.toolContext?.replyToMode).toBe("off");
547558});
@@ -567,7 +578,7 @@ describe("message tool agent routing", () => {
567578message: "stay in thread",
568579});
569580570-const call = mocks.runMessageAction.mock.calls[0]?.[0];
581+const call = firstRunMessageActionInput();
571582expect(call?.toolContext?.currentThreadTs).toBe("111.222");
572583expect(call?.toolContext?.replyToMode).toBe("all");
573584});
@@ -615,7 +626,7 @@ describe("message tool explicit target guard", () => {
615626filePath: "/tmp/report.png",
616627});
617628618-const call = mocks.runMessageAction.mock.calls[0]?.[0];
629+const call = firstRunMessageActionInput();
619630expect(call?.params?.target).toBe("channel:C999");
620631});
621632});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。