fix(doctor): include fallback channel warnings

This commit is contained in:
stainlu
2026-05-10 22:07:15 +08:00
committed by Peter Steinberger
parent 1831162ac1
commit 60acfd9dfe
2 changed files with 49 additions and 4 deletions

View File

@@ -573,4 +573,44 @@ describe("doctor preview warnings", () => {
expect(warnings.join("\n")).not.toContain("slack");
expect(warnings.join("\n")).not.toContain("defaults");
});
it("warns for default-routed configured channels when other routes exist", () => {
const warnings = collectChannelBoundMessageToolPolicyWarnings({
channels: {
discord: {},
telegram: {},
},
agents: {
list: [
{
id: "main",
default: true,
tools: {
allow: ["read"],
},
},
{
id: "commander",
tools: {
profile: "messaging",
},
},
],
},
bindings: [
{
agentId: "commander",
match: {
channel: "discord",
},
},
],
});
expect(warnings).toEqual([
expect.stringContaining('Agent "main" is routed from channel "telegram"'),
]);
expect(warnings.join("\n")).not.toContain("commander");
expect(warnings.join("\n")).not.toContain("discord");
});
});

View File

@@ -242,13 +242,18 @@ function collectBoundChannelTargets(cfg: OpenClawConfig): Array<{
};
const routeBindings: AgentRouteBinding[] = listRouteBindings(cfg);
const explicitlyBoundChannels = new Set<string>();
for (const binding of routeBindings) {
add(binding.agentId, binding.match.channel);
const channel = binding.match.channel.trim();
add(binding.agentId, channel);
if (channel) {
explicitlyBoundChannels.add(channel);
}
}
if (routeBindings.length === 0) {
const defaultAgentId = resolveDefaultAgentId(cfg);
for (const channel of listConfiguredChannelIds(cfg)) {
const defaultAgentId = resolveDefaultAgentId(cfg);
for (const channel of listConfiguredChannelIds(cfg)) {
if (!explicitlyBoundChannels.has(channel)) {
add(defaultAgentId, channel);
}
}