UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

51 lines (50 loc) • 2.12 kB
import { l as isRecord } from "../record-coerce-CVPuDqcc.mjs"; import { t as appendConfigPathSegment } from "../dot-path-BJ4tyWKJ.mjs"; import "../shared-DyBTHA2R.mjs"; import { t as collectTtsApiKeyAssignments } from "../runtime-config-collectors-tts-CHhrNcW0.mjs"; //#region src/secrets/channel-secret-tts-runtime.ts /** Collects nested provider SecretRefs from channel root and account blocks. */ function collectNestedChannelTtsAssignments(e) { const t = e.providerBlockKey ?? "tts"; const n = e.ownerId; const resolveOwnerId = (e) => typeof n === "function" ? (t) => n({ accountId: e, providerId: t }) : n ?? "tts"; const r = e.channel[e.nestedKey]; const i = isRecord(r) && isRecord(r[t]) ? r[t] : void 0; if (i) { const collectTopLevel = (n, r) => collectTtsApiKeyAssignments({ tts: i, pathPrefix: `channels.${e.channelKey}.${e.nestedKey}.${t}`, ownerId: resolveOwnerId(n), defaults: e.defaults, context: e.context, active: r, inactiveReason: e.topInactiveReason }); if (typeof e.ownerId !== "function") collectTopLevel("default", e.topLevelActive); else { const t = e.surface.hasExplicitAccounts ? e.surface.accounts.filter(({ account: t, enabled: n }) => e.topLevelActive && n && !Object.hasOwn(t, e.nestedKey)) : e.topLevelActive ? [{ accountId: "default" }] : []; if (t.length === 0) collectTopLevel("default", false); else for (const { accountId: e } of t) collectTopLevel(e, true); } } if (!e.surface.hasExplicitAccounts) return; for (const n of e.surface.accounts) { const r = n.account[e.nestedKey]; const i = isRecord(r) && isRecord(r[t]) ? r[t] : void 0; if (!i) continue; collectTtsApiKeyAssignments({ tts: i, pathPrefix: `${appendConfigPathSegment(`channels.${e.channelKey}.accounts`, n.accountId)}.${e.nestedKey}.${t}`, ownerId: resolveOwnerId(n.accountId), defaults: e.defaults, context: e.context, active: e.accountActive(n), inactiveReason: typeof e.accountInactiveReason === "function" ? e.accountInactiveReason(n) : e.accountInactiveReason }); } } //#endregion export { collectNestedChannelTtsAssignments };