UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

76 lines (75 loc) • 3.59 kB
import { r as normalizeProviderId } from "./provider-id-b5XGSf9C.mjs"; import { i as modelMatchesProviderModelRoute } from "./provider-model-route-hB9HZIqE.mjs"; import { i as resolveConfiguredCyberAccessProgram } from "./model-extra-params-D2Glrj-b.mjs"; //#region src/agents/model-catalog-access-programs.ts /** Missing metadata is unknown. Neither model presence nor auth type grants a program. */ function resolveModelCatalogAccessPrograms(e) { const { snapshot: t, entry: n, evaluation: r, runtimeId: i } = e; if (!e.isCurrent() || r.availability !== true || t.refreshFailed || t.pendingProviders?.some((e) => normalizeProviderId(e) === normalizeProviderId(n.provider))) return; const a = r.runtimeAuth?.id === i && r.runtimeAuth.source === "native"; const o = r.selectedCredential; const s = r.selectedRoute; if (!a && (!o || o.source === "harness" || !s || s.requestTransportOverrides === "present")) return; const c = (a ? t.nativeProviderOutcomes?.[i] : t.providerOutcomes)?.find((e) => normalizeProviderId(e.provider) === normalizeProviderId(n.provider) && (a || (o?.source === "profile" ? e.profileId === o.profileId : o?.source === "direct" && e.profileId === void 0))); if (c?.status !== "ready") return; const l = c.modelAccessPrograms?.find((e) => e.modelId === n.id && e.runtimeId === i && (a || s && e.api !== void 0 && e.baseUrl !== void 0 && modelMatchesProviderModelRoute({ provider: n.provider, api: e.api, baseUrl: e.baseUrl, route: s }))); return l ? [...l.cyber] : void 0; } /** One default selection for catalog presentation and physical runtime requests. */ function resolveModelCyberAccessProgramDefault(e) { const { provider: t, modelId: n, runtimeId: r, route: i } = e; return normalizeProviderId(t) === "openai" && (r === "codex" || r === "openclaw" && i !== void 0 && (i.api === "openai-responses" || i.api === "openai-chatgpt-responses") && modelMatchesProviderModelRoute({ provider: t, api: i.api, baseUrl: i.baseUrl, route: { ...i, baseUrl: i.api === "openai-responses" ? "https://api.openai.com/v1" : "https://chatgpt.com/backend-api/codex" } })) ? resolveConfiguredCyberAccessProgram({ config: e.config, agentId: e.agentId, provider: t, modelId: n }, "standard") : void 0; } const OPENAI_ACCESS_PROGRAM_PROVIDERS = /* @__PURE__ */ new Set([ "openai", "openai-codex", "codex", "codex-cli" ]); /** * Daybreak is an OpenAI program. A saved session choice survives model changes so it * applies again on an OpenAI model, but any other provider runs that turn as Standard. * OpenAI routes keep their explicit entitlement and runtime errors. */ function resolveCyberAccessProgramForProvider(e, t) { return e === void 0 || e === "standard" || OPENAI_ACCESS_PROGRAM_PROVIDERS.has(normalizeProviderId(t)) ? { program: e } : { program: "standard", notApplied: e }; } /** The application baseline and configured inheritance do not grant Daybreak entitlement. */ function projectModelCatalogAccessPrograms(e) { const t = resolveModelCatalogAccessPrograms(e); const n = resolveModelCyberAccessProgramDefault({ config: e.config, agentId: e.agentId, provider: e.entry.provider, modelId: e.entry.id, runtimeId: e.runtimeId, route: e.evaluation.selectedRoute }); return { ...t === void 0 ? {} : { availableAccessPrograms: { cyber: t } }, ...n === void 0 ? {} : { cyberAccessProgramDefault: n } }; } //#endregion export { resolveModelCyberAccessProgramDefault as i, resolveCyberAccessProgramForProvider as n, resolveModelCatalogAccessPrograms as r, projectModelCatalogAccessPrograms as t };