openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
46 lines (45 loc) • 1.49 kB
JavaScript
import { r as asNullableRecord } from "./record-coerce-CVPuDqcc.mjs";
import { n as listReadOnlyChannelPluginsForConfigAsync } from "./read-only-idsFCBWl.mjs";
import { i as resolveChannelDefaultAccountId } from "./helpers-ELZNDAnv.mjs";
import { n as resolveInspectedChannelAccount } from "./account-inspection-BR5sYFpp.mjs";
//#region src/status/link-channel.ts
/** Returns link status for the first configured read-only channel that exposes linked state. */
async function resolveLinkChannelContext(e, t = {}) {
const n = t.sourceConfig ?? e;
for (const t of await listReadOnlyChannelPluginsForConfigAsync(e, {
activationSourceConfig: n,
includeSetupFallbackPlugins: false
})) {
const r = resolveChannelDefaultAccountId({
plugin: t,
cfg: e
});
const i = await resolveInspectedChannelAccount({
plugin: t,
cfg: e,
sourceConfig: n,
accountId: r
});
if (i.kind === "unavailable") continue;
const { account: a, snapshot: o } = i;
const s = i.kind === "resolved" && t.status?.buildChannelSummary ? await t.status.buildChannelSummary({
account: a,
cfg: e,
defaultAccountId: r,
snapshot: o
}) : o;
const c = asNullableRecord(s);
const l = c && typeof c.linked === "boolean" ? c.linked : null;
if (l === null) continue;
return {
linked: l,
authAgeMs: c && typeof c.authAgeMs === "number" ? c.authAgeMs : null,
account: a,
accountId: r,
plugin: t
};
}
return null;
}
//#endregion
export { resolveLinkChannelContext };