openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
40 lines (39 loc) • 1.49 kB
JavaScript
import { n as listReadOnlyChannelPluginsForConfig } from "./read-only-7UA2_pQ4.js";
import { t as resolveDefaultChannelAccountContext } from "./channel-account-context-Bhs-k9uX.js";
//#region src/commands/status.link-channel.ts
/** Returns link status for the first configured read-only channel that exposes linked state. */
async function resolveLinkChannelContext(cfg, options = {}) {
const sourceConfig = options.sourceConfig ?? cfg;
for (const plugin of listReadOnlyChannelPluginsForConfig(cfg, {
activationSourceConfig: sourceConfig,
includeSetupFallbackPlugins: false
})) {
const { defaultAccountId, account, enabled, configured } = await resolveDefaultChannelAccountContext(plugin, cfg, {
mode: "read_only",
commandName: "status"
});
const snapshot = plugin.config.describeAccount ? plugin.config.describeAccount(account, cfg) : {
accountId: defaultAccountId,
enabled,
configured
};
const summaryRecord = plugin.status?.buildChannelSummary ? await plugin.status.buildChannelSummary({
account,
cfg,
defaultAccountId,
snapshot
}) : void 0;
const linked = summaryRecord && typeof summaryRecord.linked === "boolean" ? summaryRecord.linked : null;
if (linked === null) continue;
return {
linked,
authAgeMs: summaryRecord && typeof summaryRecord.authAgeMs === "number" ? summaryRecord.authAgeMs : null,
account,
accountId: defaultAccountId,
plugin
};
}
return null;
}
//#endregion
export { resolveLinkChannelContext };