UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

37 lines (36 loc) • 1.9 kB
import { i as classifyOpenAIBaseUrl } from "./base-url-C__ME3gK.mjs"; import { n as TOKEN_SHARING_AUTH_FLOW, s as TOKEN_SHARING_RESOURCE, t as IDENTITY_AUTH_FLOW } from "./token-sharing-B3gRpTpZ.mjs"; //#region extensions/openai/model-auth-policy.ts /** Credential storage mode and the endpoint it authorizes are independent. */ function resolveModelAuthPolicy(e) { if (e.provider.trim().toLowerCase() !== "openai") return; const t = e.api?.trim().toLowerCase(); if (e.mode === "oauth" && e.authFlow === "chatgpt-identity") return { authRequirement: null, compatible: false, incompatibilityReason: "requires token-sharing consent. Sign in again and enable sharing, or explicitly choose another inference credential" }; if (e.mode === "oauth" && e.authFlow === "chatgpt-token-sharing") { if (e.capability) return { authRequirement: "api-key", compatible: false, incompatibilityReason: "does not support this operation with Sign in with ChatGPT. Configure a credential that supports it" }; return { authRequirement: "api-key", compatible: (!t || t === "openai-responses") && (!e.baseUrl || e.baseUrl.replace(/\/$/, "") === "https://api.openai.com/v1"), incompatibilityReason: "requires the public OpenAI Responses endpoint for ChatGPT token sharing" }; } const n = e.mode === "oauth" || e.mode === "token"; const r = e.mode === "api-key" || e.mode === "api_key"; const i = t === "openai-chatgpt-responses"; const a = e.capability === "embedding" && e.mode !== "oauth" && classifyOpenAIBaseUrl(e.baseUrl) !== "custom"; return { authRequirement: n ? "subscription" : r || e.mode === "aws-sdk" ? "api-key" : null, compatible: (!a || r) && (t === void 0 || (i ? n : r)), incompatibilityReason: i && !a ? "requires a ChatGPT subscription (OAuth or token) profile" : "requires an OpenAI API key profile" }; } //#endregion export { resolveModelAuthPolicy as t };