




















@@ -6,7 +6,11 @@ import { listRouteBindings } from "../../../config/bindings.js";
66import type { AgentRouteBinding } from "../../../config/types.agents.js";
77import type { OpenClawConfig } from "../../../config/types.openclaw.js";
88import type { AgentToolsConfig, ToolsConfig } from "../../../config/types.tools.js";
9-import { normalizeAgentId } from "../../../routing/session-key.js";
9+import {
10+DEFAULT_ACCOUNT_ID,
11+normalizeAccountId,
12+normalizeAgentId,
13+} from "../../../routing/session-key.js";
1014import { createLazyImportLoader } from "../../../shared/lazy-promise.js";
11151216type ChannelDoctorModule = typeof import("./channel-doctor.js");
@@ -48,6 +52,21 @@ function listConfiguredChannelIds(cfg: OpenClawConfig): string[] {
4852.toSorted();
4953}
505455+function listConfiguredChannelAccountIds(cfg: OpenClawConfig, channelId: string): string[] {
56+if (!hasRecord(cfg.channels)) {
57+return [];
58+}
59+const channel = cfg.channels[channelId];
60+if (!hasRecord(channel) || !hasRecord(channel.accounts)) {
61+return [];
62+}
63+return Object.entries(channel.accounts)
64+.filter(([, value]) => !(hasRecord(value) && value.enabled === false))
65+.map(([accountId]) => normalizeAccountId(accountId))
66+.filter(Boolean)
67+.toSorted();
68+}
69+5170function hasPlugins(cfg: OpenClawConfig): boolean {
5271return hasRecord(cfg.plugins);
5372}
@@ -222,11 +241,26 @@ function formatChannelList(channels: string[]): string {
222241 .join(", ")}, and ${channels.length - 2} more`;
223242}
224243225-function isUnscopedChannelRouteBinding(binding: AgentRouteBinding): boolean {
244+function isUnscopedRouteBinding(binding: AgentRouteBinding): boolean {
226245const match = binding.match;
227-const accountId = match.accountId?.trim();
228246const hasRoles = Array.isArray(match.roles) && match.roles.length > 0;
229-return accountId === "*" && !match.peer && !match.guildId && !match.teamId && !hasRoles;
247+return !match.peer && !match.guildId && !match.teamId && !hasRoles;
248+}
249+250+function isUnscopedChannelRouteBinding(binding: AgentRouteBinding): boolean {
251+const accountId = binding.match.accountId?.trim();
252+return accountId === "*" && isUnscopedRouteBinding(binding);
253+}
254+255+function resolveUnscopedBindingAccountId(binding: AgentRouteBinding): string | undefined {
256+if (!isUnscopedRouteBinding(binding)) {
257+return undefined;
258+}
259+const accountId = binding.match.accountId?.trim();
260+if (accountId === "*") {
261+return "*";
262+}
263+return normalizeAccountId(accountId || DEFAULT_ACCOUNT_ID);
230264}
231265232266function collectBoundChannelTargets(cfg: OpenClawConfig): Array<{
@@ -250,17 +284,40 @@ function collectBoundChannelTargets(cfg: OpenClawConfig): Array<{
250284251285const routeBindings: AgentRouteBinding[] = listRouteBindings(cfg);
252286const fullyCoveredChannels = new Set<string>();
287+const coveredAccountsByChannel = new Map<string, Set<string>>();
253288for (const binding of routeBindings) {
254289const channel = binding.match.channel.trim();
255290add(binding.agentId, channel);
256-if (channel && isUnscopedChannelRouteBinding(binding)) {
291+if (!channel) {
292+continue;
293+}
294+if (isUnscopedChannelRouteBinding(binding)) {
257295fullyCoveredChannels.add(channel);
296+continue;
297+}
298+const coveredAccountId = resolveUnscopedBindingAccountId(binding);
299+if (coveredAccountId && coveredAccountId !== "*") {
300+let coveredAccounts = coveredAccountsByChannel.get(channel);
301+if (!coveredAccounts) {
302+coveredAccounts = new Set<string>();
303+coveredAccountsByChannel.set(channel, coveredAccounts);
304+}
305+coveredAccounts.add(coveredAccountId);
258306}
259307}
260308261309const defaultAgentId = resolveDefaultAgentId(cfg);
262310for (const channel of listConfiguredChannelIds(cfg)) {
263-if (!fullyCoveredChannels.has(channel)) {
311+if (fullyCoveredChannels.has(channel)) {
312+continue;
313+}
314+const configuredAccountIds = listConfiguredChannelAccountIds(cfg, channel);
315+if (configuredAccountIds.length === 0) {
316+add(defaultAgentId, channel);
317+continue;
318+}
319+const coveredAccounts = coveredAccountsByChannel.get(channel);
320+if (configuredAccountIds.some((accountId) => !coveredAccounts?.has(accountId))) {
264321add(defaultAgentId, channel);
265322}
266323}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。