mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-11 01:01:13 +00:00
fix(acp): guard missing delivery channel config
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { createAcpDispatchDeliveryCoordinator } from "./dispatch-acp-delivery.js";
|
||||
import type { ReplyDispatcher } from "./reply-dispatcher.js";
|
||||
import { buildTestCtx } from "./test-ctx.js";
|
||||
@@ -273,4 +274,30 @@ describe("createAcpDispatchDeliveryCoordinator", () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("routes ACP replies when cfg.channels is missing", async () => {
|
||||
const coordinator = createAcpDispatchDeliveryCoordinator({
|
||||
cfg: {} as OpenClawConfig,
|
||||
ctx: buildTestCtx({
|
||||
Provider: "discord",
|
||||
Surface: "discord",
|
||||
SessionKey: "agent:codex-acp:session-1",
|
||||
}),
|
||||
dispatcher: createDispatcher(),
|
||||
inboundAudio: false,
|
||||
shouldRouteToOriginating: true,
|
||||
originatingChannel: "discord",
|
||||
originatingTo: "channel:thread-1",
|
||||
});
|
||||
|
||||
await coordinator.deliver("block", { text: "hello" }, { skipTts: true });
|
||||
|
||||
expect(deliveryMocks.routeReply).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
channel: "discord",
|
||||
to: "channel:thread-1",
|
||||
accountId: undefined,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -43,8 +43,8 @@ function resolveDeliveryAccountId(params: {
|
||||
return undefined;
|
||||
}
|
||||
const channelCfg = (
|
||||
params.cfg.channels as Record<string, { defaultAccount?: unknown } | undefined>
|
||||
)[channelId];
|
||||
params.cfg.channels as Record<string, { defaultAccount?: unknown } | undefined> | undefined
|
||||
)?.[channelId];
|
||||
const configuredDefault = channelCfg?.defaultAccount;
|
||||
return typeof configuredDefault === "string" && configuredDefault.trim()
|
||||
? configuredDefault.trim()
|
||||
|
||||
Reference in New Issue
Block a user