UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

74 lines (73 loc) • 2.37 kB
import { r as asNullableRecord } from "./record-coerce-CVPuDqcc.mjs"; import { r as resolveChannelAccount } from "./account-resolution-D7u1J1M0.mjs"; import { i as hasResolvedCredentialValue, r as hasConfiguredUnavailableCredentialStatus } from "./account-snapshot-fields-B0Zypjh2.mjs"; import { a as resolveUnavailableChannelAccountSnapshot } from "./account-state-CG07Qq4V.mjs"; import { i as buildChannelAccountSummary, n as buildChannelAccountSnapshotFromInspection, o as resolveChannelAccountConfigured, s as resolveChannelAccountEnabled } from "./account-summary-RVgW5Dlx.mjs"; import { t as inspectReadOnlyChannelAccount } from "./read-only-account-inspect-CcH_u7aK.mjs"; //#region src/channels/account-inspection.ts async function inspectChannelAccount(e) { return e.plugin.config.inspectAccount?.(e.cfg, e.accountId) ?? await inspectReadOnlyChannelAccount({ channelId: e.plugin.id, cfg: e.cfg, accountId: e.accountId }); } async function resolveInspectedChannelAccount(e) { const t = resolveUnavailableChannelAccountSnapshot(e.cfg, { channelId: e.plugin.id, accountId: e.accountId }); if (t) return { kind: "unavailable", account: t, enabled: t.enabled !== false, configured: t.configured === true, snapshot: t }; const n = await inspectChannelAccount({ ...e, cfg: e.sourceConfig }); const r = await inspectChannelAccount(e); const i = asNullableRecord(r); const a = asNullableRecord(n); const o = Boolean(n && hasConfiguredUnavailableCredentialStatus(n) && (!hasResolvedCredentialValue(r) || a?.configured === true && i?.configured === false)) ? n : r; if (o != null) { const t = buildChannelAccountSnapshotFromInspection({ account: o, accountId: e.accountId }); return { kind: "inspected", account: o, enabled: t.enabled !== false, configured: t.configured, snapshot: t }; } const s = await resolveChannelAccount(e); const c = resolveChannelAccountEnabled({ plugin: e.plugin, account: s, cfg: e.cfg }); const l = await resolveChannelAccountConfigured({ plugin: e.plugin, account: s, cfg: e.cfg }); return { kind: "resolved", account: s, enabled: c, configured: l, snapshot: await buildChannelAccountSummary({ ...e, account: s, enabled: c, configured: l }) }; } //#endregion export { resolveInspectedChannelAccount as n, inspectChannelAccount as t };