UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 2.56 kB
import{l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{a as asOptionalRecord,p as readStringField}from"./record-coerce-BTbqdJ3-.mjs";import{p as sanitizeConfiguredModelProviderRequest}from"./provider-request-config-BQ-HhEKu.mjs";import{n as assertOkOrThrowHttpError}from"./provider-http-errors-CWZQ78Qm.mjs";import"./string-coerce-runtime-BYDH9Quw.mjs";import{t as executeProviderOperationWithRetry}from"./operation-retry-BWpsksDm.mjs";import{c as fetchWithTimeoutGuarded}from"./shared-BGvdIfYO.mjs";import{t as resolveProviderApiKeyHttpRequestConfig}from"./provider-http-D0sVd8r_.mjs"; //!extensions/minimax/media-provider-runtime.ts const DEFAULT_MINIMAX_MEDIA_BASE_URL=`https://api.minimax.io`;function resolveMinimaxMediaBaseUrl(e,t){const n=normalizeOptionalString(e?.models?.providers?.[t]?.baseUrl);return new URL(n??DEFAULT_MINIMAX_MEDIA_BASE_URL).origin}async function resolveMinimaxMediaRequestConfig(e){return resolveProviderApiKeyHttpRequestConfig({req:e,missingApiKeyMessage:`MiniMax API key missing`,jsonContentType:e.capability!==`audio`,baseUrl:e.baseUrl??resolveMinimaxMediaBaseUrl(e.cfg,e.providerId),defaultBaseUrl:DEFAULT_MINIMAX_MEDIA_BASE_URL,provider:e.providerId,capability:e.capability,request:sanitizeConfiguredModelProviderRequest(e.cfg?.models?.providers?.[e.providerId]?.request)})}function assertMinimaxBaseResp(e,t){const n=asOptionalRecord(e);if(n&&typeof n.status_code===`number`&&n.status_code!==0)throw new Error(`${t} (${n.status_code}): ${readStringField(n,`status_msg`)??`unknown error`}`)}function normalizeMinimaxHexAudio(e,t){const n=e.trim();if(!/^[0-9a-f]+$/iu.test(n)||n.length%2!==0)throw new Error(`${t} returned malformed hex audio`);return n}function resolveMinimaxGuardedRequestOptions(e){return e.allowPrivateNetwork||e.dispatcherPolicy?{...e.allowPrivateNetwork?{ssrfPolicy:{allowPrivateNetwork:true}}:{},...e.dispatcherPolicy?{dispatcherPolicy:e.dispatcherPolicy}:{}}:void 0}async function fetchMinimaxResponse(e){return await executeProviderOperationWithRetry({provider:`minimax`,stage:e.stage,operation:async()=>{const t=typeof e.timeoutMs===`function`?e.timeoutMs():e.timeoutMs;const n=await fetchWithTimeoutGuarded(e.url,e.init??{},typeof t===`number`&&Number.isFinite(t)&&t>0?t:void 0,fetch,resolveMinimaxGuardedRequestOptions(e.policy));try{await assertOkOrThrowHttpError(n.response,e.requestFailedMessage)}catch(e){await n.release();throw e}return n}})}export{resolveMinimaxMediaRequestConfig as i,fetchMinimaxResponse as n,normalizeMinimaxHexAudio as r,assertMinimaxBaseResp as t};