fix(doctor): match route channel coverage to runtime

This commit is contained in:
Peter Steinberger
2026-05-11 12:52:53 +01:00
parent c9fadc597a
commit 63ba3cd63d
2 changed files with 44 additions and 1 deletions

View File

@@ -743,6 +743,45 @@ describe("doctor preview warnings", () => {
expect(warnings).toStrictEqual([]);
});
it("does not treat channel aliases as route coverage when runtime would not match them", () => {
const warnings = collectChannelBoundMessageToolPolicyWarnings({
channels: {
imessage: {},
},
agents: {
list: [
{
id: "main",
default: true,
tools: {
allow: ["read"],
},
},
{
id: "ios-agent",
tools: {
profile: "messaging",
},
},
],
},
bindings: [
{
agentId: "ios-agent",
match: {
channel: "imsg",
},
},
],
});
expect(warnings).toEqual([
expect.stringContaining('Agent "main" is routed from channel "imessage"'),
]);
expect(warnings.join("\n")).not.toContain("ios-agent");
expect(warnings.join("\n")).not.toContain("imsg");
});
it("warns for the default agent when configured account routes are incomplete", () => {
const warnings = collectChannelBoundMessageToolPolicyWarnings({
channels: {

View File

@@ -43,6 +43,10 @@ function normalizeChannelKey(raw?: string | null): string {
return normalizeChatChannelId(raw) ?? normalizeLowercaseStringOrEmpty(raw);
}
function normalizeRouteBindingChannelKey(raw?: string | null): string {
return normalizeLowercaseStringOrEmpty(raw);
}
function listConfiguredChannelIds(cfg: OpenClawConfig): string[] {
if (!hasRecord(cfg.channels)) {
return [];
@@ -295,7 +299,7 @@ function collectBoundChannelTargets(cfg: OpenClawConfig): Array<{
const fullyCoveredChannels = new Set<string>();
const coveredAccountsByChannel = new Map<string, Set<string>>();
for (const binding of routeBindings) {
const channel = normalizeChannelKey(binding.match.channel);
const channel = normalizeRouteBindingChannelKey(binding.match.channel);
add(binding.agentId, channel);
if (!channel) {
continue;