openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
79 lines (78 loc) • 2.74 kB
JavaScript
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs";
import { a as asOptionalRecord } from "./record-coerce-CVPuDqcc.mjs";
import "./string-coerce-runtime-BwAZZDf5.mjs";
import { n as OPENAI_CODEX_RESPONSES_BASE_URL } from "./base-url-C__ME3gK.mjs";
//#region extensions/openai/model-service-tiers.ts
/** Only authenticated remote rows may supply this private observation, never fallback seeds. */
function readOpenAICodexServiceTiers(e) {
return e.flatMap((e) => {
const t = asOptionalRecord(e);
const n = normalizeOptionalString(t?.slug) ?? normalizeOptionalString(t?.id);
const r = t?.service_tiers;
if (!n || !Array.isArray(r)) return [];
const i = [];
for (const e of r) {
const t = normalizeOptionalString(asOptionalRecord(e)?.id);
if (!t) return [];
i.push(t);
}
return [{
modelId: n,
runtimeId: "codex",
api: "openai-chatgpt-responses",
baseUrl: OPENAI_CODEX_RESPONSES_BASE_URL,
serviceTiers: [...new Set(i)]
}];
});
}
/** Only explicit caller-specific metadata grants a program, never a model name or plan. */
function readOpenAIModelAccessPrograms(e, t) {
return e.flatMap((e) => {
const n = asOptionalRecord(e);
const r = normalizeOptionalString(n?.slug) ?? normalizeOptionalString(n?.id);
const i = asOptionalRecord(n?.available_access_programs)?.cyber;
if (!r || !Array.isArray(i) || !i.every((e) => typeof e === "string")) return [];
const a = i.filter((e) => e === "standard" || e === "daybreak_blue" || e === "daybreak_red");
return t.runtimeIds.map((e) => ({
modelId: r,
runtimeId: e,
api: t.api,
baseUrl: t.baseUrl,
cyber: a
}));
});
}
/**
* A successful account-scoped listing is authoritative even when every row is hidden; static
* hints must not invent subscription access. Hidden rows stay listed: the account is entitled.
*/
function buildOpenAICodexReadyOutcome(e) {
const t = readOpenAICodexServiceTiers(e);
const n = readOpenAIModelAccessPrograms(e, {
api: "openai-chatgpt-responses",
baseUrl: OPENAI_CODEX_RESPONSES_BASE_URL,
runtimeIds: ["openclaw", "codex"]
});
return {
provider: "openai",
status: "ready",
...t.length ? { modelServiceTiers: t } : {},
...n.length ? { modelAccessPrograms: n } : {},
listedModelIds: e.flatMap((e) => {
const t = asOptionalRecord(e);
return normalizeOptionalString(t?.slug) ?? normalizeOptionalString(t?.id) ?? [];
})
};
}
function projectOpenAICatalog(e, t) {
const n = t?.trim();
return {
providers: { openai: e.provider },
...e.outcome ? { outcomes: [n ? {
...e.outcome,
profileId: n
} : e.outcome] } : {}
};
}
//#endregion
export { projectOpenAICatalog as n, readOpenAIModelAccessPrograms as r, buildOpenAICodexReadyOutcome as t };