fix(routing): preserve explicit cron account and bound message defaults

Co-authored-by: lbo728 <72309817+lbo728@users.noreply.github.com>
Co-authored-by: stakeswky <64798754+stakeswky@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-02-26 02:43:22 +00:00
parent 92eb3dfc9d
commit 1e7ec8bfd2
10 changed files with 114 additions and 1 deletions

View File

@@ -1021,4 +1021,32 @@ describe("runMessageAction accountId defaults", () => {
expect(ctx.accountId).toBe("ops");
expect(ctx.params.accountId).toBe("ops");
});
it("falls back to the agent's bound account when accountId is omitted", async () => {
await runMessageAction({
cfg: {
bindings: [{ agentId: "agent-b", match: { channel: "discord", accountId: "account-b" } }],
} as OpenClawConfig,
action: "send",
params: {
channel: "discord",
target: "channel:123",
message: "hi",
},
agentId: "agent-b",
});
expect(handleAction).toHaveBeenCalled();
const ctx = (handleAction.mock.calls as unknown as Array<[unknown]>)[0]?.[0] as
| {
accountId?: string | null;
params: Record<string, unknown>;
}
| undefined;
if (!ctx) {
throw new Error("expected action context");
}
expect(ctx.accountId).toBe("account-b");
expect(ctx.params.accountId).toBe("account-b");
});
});