Files
openclaw/src/plugin-sdk/config-paths.ts
2026-06-04 19:14:41 -04:00

18 lines
879 B
TypeScript

// Config path helpers resolve plugin-visible state and config file locations from OpenClaw config.
import type { OpenClawConfig } from "../config/types.openclaw.js";
/** Resolve the config path prefix for a channel account, falling back to the root channel section. */
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}.`;
}