mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 23:20:22 +00:00
fix: use session origin provider in chat delivery routing
This commit is contained in:
@@ -854,6 +854,46 @@ describe("chat directive tag stripping for non-streaming final payloads", () =>
|
||||
);
|
||||
});
|
||||
|
||||
it("chat.send falls back to origin provider metadata for configured main CLI delivery inheritance", async () => {
|
||||
createTranscriptFixture("openclaw-chat-send-config-main-origin-provider-routes-");
|
||||
mockState.mainSessionKey = "work";
|
||||
mockState.finalText = "ok";
|
||||
mockState.sessionEntry = {
|
||||
origin: {
|
||||
provider: "whatsapp",
|
||||
accountId: "default",
|
||||
},
|
||||
lastTo: "whatsapp:+8613800138000",
|
||||
};
|
||||
const respond = vi.fn();
|
||||
const context = createChatContext();
|
||||
|
||||
await runNonStreamingChatSend({
|
||||
context,
|
||||
respond,
|
||||
idempotencyKey: "idem-config-main-origin-provider-routes",
|
||||
client: {
|
||||
connect: {
|
||||
client: {
|
||||
mode: GATEWAY_CLIENT_MODES.CLI,
|
||||
id: "cli",
|
||||
},
|
||||
},
|
||||
} as unknown,
|
||||
sessionKey: "agent:main:work",
|
||||
deliver: true,
|
||||
expectBroadcast: false,
|
||||
});
|
||||
|
||||
expect(mockState.lastDispatchCtx).toEqual(
|
||||
expect.objectContaining({
|
||||
OriginatingChannel: "whatsapp",
|
||||
OriginatingTo: "whatsapp:+8613800138000",
|
||||
AccountId: "default",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("chat.send keeps configured main delivery inheritance when connect metadata omits client details", async () => {
|
||||
createTranscriptFixture("openclaw-chat-send-config-main-connect-no-client-");
|
||||
mockState.mainSessionKey = "work";
|
||||
|
||||
@@ -121,6 +121,10 @@ type ChatSendDeliveryEntry = {
|
||||
accountId?: string;
|
||||
threadId?: string | number;
|
||||
};
|
||||
origin?: {
|
||||
provider?: string;
|
||||
accountId?: string;
|
||||
};
|
||||
lastChannel?: string;
|
||||
lastTo?: string;
|
||||
lastAccountId?: string;
|
||||
@@ -162,11 +166,16 @@ function resolveChatSendOriginatingRoute(params: {
|
||||
}
|
||||
|
||||
const routeChannelCandidate = normalizeMessageChannel(
|
||||
params.entry?.deliveryContext?.channel ?? params.entry?.lastChannel,
|
||||
params.entry?.deliveryContext?.channel ??
|
||||
params.entry?.lastChannel ??
|
||||
params.entry?.origin?.provider,
|
||||
);
|
||||
const routeToCandidate = params.entry?.deliveryContext?.to ?? params.entry?.lastTo;
|
||||
const routeAccountIdCandidate =
|
||||
params.entry?.deliveryContext?.accountId ?? params.entry?.lastAccountId ?? undefined;
|
||||
params.entry?.deliveryContext?.accountId ??
|
||||
params.entry?.lastAccountId ??
|
||||
params.entry?.origin?.accountId ??
|
||||
undefined;
|
||||
const routeThreadIdCandidate =
|
||||
params.entry?.deliveryContext?.threadId ?? params.entry?.lastThreadId;
|
||||
if (params.sessionKey.length > CHAT_SEND_SESSION_KEY_MAX_LENGTH) {
|
||||
|
||||
Reference in New Issue
Block a user