fix: sync delivery routing context

Co-authored-by: adam91holt <adam91holt@users.noreply.github.com>
This commit is contained in:
Peter Steinberger
2026-01-17 06:01:30 +00:00
parent e59d8c5436
commit 285ed8bac3
10 changed files with 208 additions and 51 deletions

View File

@@ -76,6 +76,7 @@ describe("deliverAgentCommandResult", () => {
} as unknown as RuntimeEnv;
const sessionEntry = {
lastAccountId: "legacy",
lastChannel: "whatsapp",
} as SessionEntry;
const result = {
payloads: [{ text: "hi" }],
@@ -141,4 +142,40 @@ describe("deliverAgentCommandResult", () => {
expect.objectContaining({ accountId: undefined }),
);
});
it("skips session accountId when channel differs", async () => {
const cfg = {} as ClawdbotConfig;
const deps = {} as CliDeps;
const runtime = {
log: vi.fn(),
error: vi.fn(),
} as unknown as RuntimeEnv;
const sessionEntry = {
lastAccountId: "legacy",
lastChannel: "telegram",
} as SessionEntry;
const result = {
payloads: [{ text: "hi" }],
meta: {},
};
const { deliverAgentCommandResult } = await import("./agent/delivery.js");
await deliverAgentCommandResult({
cfg,
deps,
runtime,
opts: {
message: "hello",
deliver: true,
channel: "whatsapp",
},
sessionEntry,
result,
payloads: result.payloads,
});
expect(mocks.resolveOutboundTarget).toHaveBeenCalledWith(
expect.objectContaining({ accountId: undefined, channel: "whatsapp" }),
);
});
});