openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
63 lines (62 loc) • 2.32 kB
JavaScript
import { o as hasConfiguredSecretInput } from "./types.secrets-BmNLLnHp.mjs";
import { n as normalizeAccountId } from "./account-id-BqKT3GuY.mjs";
import { n as resolveAccountKey } from "./account-lookup-FhQZVFfo.mjs";
import { t as mergeAccountConfig } from "./channel-account-config-BvENCH3O.mjs";
import { t as createAccountListHelpers } from "./account-helpers-2ZndtV_R.mjs";
import "./secret-input-CpgOwFAi.mjs";
import "./account-helpers-DlavPc2B.mjs";
import "./account-resolution-BlF3HfnR.mjs";
//#region extensions/x/src/cost-limits.ts
function resolveXCostLimits(e) {
return {
dailyUsd: e?.dailyUsd ?? 100,
monthlyUsd: e?.monthlyUsd ?? 1e3,
cycleStartDay: e?.cycleStartDay ?? 1
};
}
//#endregion
//#region extensions/x/src/accounts.ts
const accounts = createAccountListHelpers("x", {
omitKeys: ["defaultAccount"],
nestedObjectKeys: [
"guests",
"costLimits",
"verifiedFromGitHub"
],
implicitDefaultAccount: { channelKeys: [
"userId",
"clientId",
"refreshToken"
] }
});
const listXAccountIds = accounts.listAccountIds;
const listXRuntimeAccountIds = (e) => [...new Set(listXAccountIds(e).map(normalizeAccountId))];
const resolveDefaultXAccountId = accounts.resolveDefaultAccountId;
/** Config keys keep their authored case; this finds the key `resolveXAccount` reads. */
function resolveXAccountKey(e, t) {
const n = normalizeAccountId(t);
return resolveAccountKey(e.channels?.x?.accounts, n, void 0, void 0, { channelId: "x" });
}
function resolveXAccount(e, t) {
const n = normalizeAccountId(t ?? resolveDefaultXAccountId(e));
const r = accounts.resolveAccountConfig(e, n);
if (r.guests) r.guests = mergeAccountConfig({
channelConfig: e.channels?.x?.guests,
accountConfig: r.guests,
nestedObjectKeys: ["tools"]
});
const i = e.channels?.x?.enabled !== false && r.enabled !== false;
const a = Boolean(r.userId && r.username && r.clientId && hasConfiguredSecretInput(r.clientSecret) && hasConfiguredSecretInput(r.refreshToken));
return {
accountId: n,
config: r,
costLimits: resolveXCostLimits(r.costLimits),
enabled: i,
configured: a,
userId: r.userId ?? "",
username: r.username ?? "",
name: r.name
};
}
//#endregion
export { resolveXAccountKey as a, resolveXAccount as i, listXRuntimeAccountIds as n, resolveDefaultXAccountId as r, listXAccountIds as t };