2026-02-15 00:42:42 +00:00
|
|
|
import type { OpenClawConfig } from "../config/config.js";
|
|
|
|
|
|
2026-03-16 01:05:18 -07:00
|
|
|
/** Resolve the config path prefix for a channel account, falling back to the root channel section. */
|
2026-02-15 00:42:42 +00:00
|
|
|
export function resolveChannelAccountConfigBasePath(params: {
|
|
|
|
|
cfg: OpenClawConfig;
|
|
|
|
|
channelKey: string;
|
|
|
|
|
accountId: string;
|
|
|
|
|
}): string {
|
|
|
|
|
const channels = params.cfg.channels as unknown as Record<string, unknown> | undefined;
|
|
|
|
|
const channelSection = channels?.[params.channelKey] as Record<string, unknown> | undefined;
|
|
|
|
|
const accounts = channelSection?.accounts as Record<string, unknown> | undefined;
|
|
|
|
|
const useAccountPath = Boolean(accounts?.[params.accountId]);
|
|
|
|
|
return useAccountPath
|
|
|
|
|
? `channels.${params.channelKey}.accounts.${params.accountId}.`
|
|
|
|
|
: `channels.${params.channelKey}.`;
|
|
|
|
|
}
|