@shumai-one/shumai-agent 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13369,7 +13369,7 @@ References are relative to ${jYF(B.filePath)}.
13369
13369
  ${B.content}
13370
13370
  </skill>`;return Q?`${F}
13371
13371
 
13372
- ${Q}`:F}function jYF(B){let Q=B.replace(/\/+$/,""),F=Q.lastIndexOf("/");return F<=0?"/":Q.slice(0,F)}function Di(B,Q){let F=[{type:"text",text:B}];if(Q)F.push(...Q);return{role:"user",content:F,timestamp:Date.now()}}function nYF(B,Q,F){return{role:"assistant",content:[{type:"text",text:""}],api:B.api,provider:B.provider,model:B.id,stopReason:F?"aborted":"error",errorMessage:Q instanceof Error?Q.message:String(Q),timestamp:Date.now(),usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}}function mz(B){return{...B,headers:B?.headers?{...B.headers}:void 0,metadata:B?.metadata?{...B.metadata}:void 0}}function iYF(...B){let Q={},F=!1;for(let U of B){if(!U)continue;Object.assign(Q,U),F=!0}return F?Q:void 0}function pYF(B){let Q=new Set,F=new Set;for(let U of B){if(Q.has(U))F.add(U);Q.add(U)}return[...F]}function aYF(B,Q){let F=mz(B);if(!Q)return F;if(Object.hasOwn(Q,"transport"))F.transport=Q.transport;if(Object.hasOwn(Q,"timeoutMs"))F.timeoutMs=Q.timeoutMs;if(Object.hasOwn(Q,"maxRetries"))F.maxRetries=Q.maxRetries;if(Object.hasOwn(Q,"maxRetryDelayMs"))F.maxRetryDelayMs=Q.maxRetryDelayMs;if(Object.hasOwn(Q,"cacheRetention"))F.cacheRetention=Q.cacheRetention;if(Object.hasOwn(Q,"headers"))if(Q.headers===void 0)F.headers=void 0;else{let U={...F.headers??{}};for(let[I,G]of Object.entries(Q.headers))if(G===void 0)delete U[I];else U[I]=G;F.headers=Object.keys(U).length>0?U:void 0}if(Object.hasOwn(Q,"metadata"))if(Q.metadata===void 0)F.metadata=void 0;else{let U={...F.metadata??{}};for(let[I,G]of Object.entries(Q.metadata))if(G===void 0)delete U[I];else U[I]=G;F.metadata=Object.keys(U).length>0?U:void 0}return F}var zi="*";function TN(B,Q){if(B instanceof nI)return B;let F=cV(B);if(F instanceof kR)return new nI("session",F.message,F);if(F instanceof oY)return new nI("compaction",F.message,F);if(F instanceof FT)return new nI("branch_summary",F.message,F);return new nI(Q,F.message,F)}function Tz(B){return TN(B,"hook")}class GRB{env;session;phase="idle";runAbortController;runPromise;pendingSessionWrites=[];model;thinkingLevel;systemPrompt;streamOptions;getApiKeyAndHeaders;resources;tools=new Map;activeToolNames;steerQueue=[];steeringQueueMode;followUpQueue=[];followUpQueueMode;nextTurnQueue=[];handlers=new Map;constructor(B){this.env=B.env,this.session=B.session,this.resources=B.resources??{},this.streamOptions=mz(B.streamOptions),this.systemPrompt=B.systemPrompt,this.getApiKeyAndHeaders=B.getApiKeyAndHeaders,this.validateUniqueNames((B.tools??[]).map((Q)=>Q.name),"Duplicate tool name(s)");for(let Q of B.tools??[])this.tools.set(Q.name,Q);this.model=B.model,this.thinkingLevel=B.thinkingLevel??"off",this.activeToolNames=B.activeToolNames?[...B.activeToolNames]:(B.tools??[]).map((Q)=>Q.name),this.validateUniqueNames(this.activeToolNames,"Duplicate active tool name(s)"),this.validateToolNames(this.activeToolNames),this.steeringQueueMode=B.steeringMode??"one-at-a-time",this.followUpQueueMode=B.followUpMode??"one-at-a-time"}getHandlers(B){return this.handlers.get(B)}async emitOwn(B,Q){for(let F of this.getHandlers(zi)??[])try{await F(B,Q)}catch(U){throw Tz(U)}}async emitAny(B,Q){for(let F of this.getHandlers(zi)??[])try{await F(B,Q)}catch(U){throw Tz(U)}}async emitHook(B){let Q=this.getHandlers(B.type);if(!Q||Q.size===0)return;let F;for(let U of Q)try{let I=await U(B);if(I!==void 0)F=I}catch(I){throw Tz(I)}return F}async emitBeforeProviderRequest(B,Q,F){let U=this.getHandlers("before_provider_request"),I=mz(F);if(!U||U.size===0)return I;for(let G of U)try{let Z=await G({type:"before_provider_request",model:B,sessionId:Q,streamOptions:mz(I)});if(Z?.streamOptions)I=aYF(I,Z.streamOptions)}catch(Z){throw Tz(Z)}return I}async emitBeforeProviderPayload(B,Q){let F=this.getHandlers("before_provider_payload"),U=Q;if(!F||F.size===0)return U;for(let I of F)try{let G=await I({type:"before_provider_payload",model:B,payload:U});if(G!==void 0)U=G.payload}catch(G){throw Tz(G)}return U}async emitQueueUpdate(){await this.emitOwn({type:"queue_update",steer:[...this.steerQueue],followUp:[...this.followUpQueue],nextTurn:[...this.nextTurnQueue]})}startRunPromise(){let B=()=>{};return this.runPromise=new Promise((Q)=>{B=Q}),()=>{this.runPromise=void 0,B()}}async createTurnState(){let B=await this.session.buildContext(),Q=this.getResources(),F=await this.session.getMetadata(),U=[...this.tools.values()],I=this.activeToolNames.map((Z)=>this.tools.get(Z)).filter((Z)=>Z!==void 0),G="You are a helpful assistant.";if(typeof this.systemPrompt==="string")G=this.systemPrompt;else if(this.systemPrompt)G=await this.systemPrompt({env:this.env,session:this.session,model:this.model,thinkingLevel:this.thinkingLevel,activeTools:I,resources:Q});return{messages:B.messages,resources:Q,streamOptions:mz(this.streamOptions),sessionId:F.id,systemPrompt:G,model:this.model,thinkingLevel:this.thinkingLevel,tools:U,activeTools:I}}createContext(B,Q){return{systemPrompt:Q??B.systemPrompt,messages:B.messages.slice(),tools:B.activeTools.slice()}}createStreamFn(B){return async(Q,F,U)=>{let I=B(),G=await this.getApiKeyAndHeaders?.(Q),Z={...I.streamOptions,headers:iYF(I.streamOptions.headers,G?.headers)},W=await this.emitBeforeProviderRequest(Q,I.sessionId,Z);return iM(Q,F,{cacheRetention:W.cacheRetention,headers:W.headers,maxRetries:W.maxRetries,maxRetryDelayMs:W.maxRetryDelayMs,metadata:W.metadata,onPayload:async(g)=>await this.emitBeforeProviderPayload(Q,g),onResponse:async(g)=>{let V={...g.headers};await this.emitOwn({type:"after_provider_response",status:g.status,headers:V},U?.signal)},reasoning:U?.reasoning,signal:U?.signal,sessionId:I.sessionId,timeoutMs:W.timeoutMs,transport:W.transport,apiKey:G?.apiKey})}}async drainQueuedMessages(B,Q){let F=Q==="all"?B.splice(0):B.splice(0,1);if(F.length===0)return F;try{return await this.emitQueueUpdate(),F}catch(U){throw B.unshift(...F),Tz(U)}}createLoopConfig(B,Q){let F=B();return{model:F.model,reasoning:F.thinkingLevel==="off"?void 0:F.thinkingLevel,convertToLlm:Jz,transformContext:async(U)=>{return(await this.emitHook({type:"context",messages:[...U]}))?.messages??U},beforeToolCall:async({toolCall:U,args:I})=>{let G=await this.emitHook({type:"tool_call",toolCallId:U.id,toolName:U.name,input:I});return G?{block:G.block,reason:G.reason}:void 0},afterToolCall:async({toolCall:U,args:I,result:G,isError:Z})=>{let W=await this.emitHook({type:"tool_result",toolCallId:U.id,toolName:U.name,input:I,content:G.content,details:G.details,isError:Z});return W?{content:W.content,details:W.details,isError:W.isError,terminate:W.terminate}:void 0},prepareNextTurn:async()=>{await this.flushPendingSessionWrites();let U=await this.createTurnState();return Q(U),{context:this.createContext(U),model:U.model,thinkingLevel:U.thinkingLevel}},getSteeringMessages:async()=>this.drainQueuedMessages(this.steerQueue,this.steeringQueueMode),getFollowUpMessages:async()=>this.drainQueuedMessages(this.followUpQueue,this.followUpQueueMode)}}validateUniqueNames(B,Q){let F=pYF(B);if(F.length>0)throw new nI("invalid_argument",`${Q}: ${F.join(", ")}`)}validateToolNames(B,Q=this.tools){this.validateUniqueNames(B,"Duplicate active tool name(s)");let F=B.filter((U)=>!Q.has(U));if(F.length>0)throw new nI("invalid_argument",`Unknown tool(s): ${F.join(", ")}`)}async flushPendingSessionWrites(){while(this.pendingSessionWrites.length>0){let B=this.pendingSessionWrites[0];if(B.type==="message")await this.session.appendMessage(B.message);else if(B.type==="model_change")await this.session.appendModelChange(B.provider,B.modelId);else if(B.type==="thinking_level_change")await this.session.appendThinkingLevelChange(B.thinkingLevel);else if(B.type==="active_tools_change")await this.session.appendActiveToolsChange(B.activeToolNames);else if(B.type==="custom")await this.session.appendCustomEntry(B.customType,B.data);else if(B.type==="custom_message")await this.session.appendCustomMessageEntry(B.customType,B.content,B.display,B.details);else if(B.type==="label")await this.session.appendLabel(B.targetId,B.label);else if(B.type==="session_info")await this.session.appendSessionName(B.name??"");else if(B.type==="leaf")await this.session.getStorage().setLeafId(B.targetId);this.pendingSessionWrites.shift()}}async handleAgentEvent(B,Q){if(B.type==="message_end"){await this.session.appendMessage(B.message),await this.emitAny(B,Q);return}if(B.type==="turn_end"){let F;try{await this.emitAny(B,Q)}catch(I){F=I}let U=this.pendingSessionWrites.length>0;if(await this.flushPendingSessionWrites(),F)throw F;await this.emitOwn({type:"save_point",hadPendingMutations:U});return}if(B.type==="agent_end"){await this.flushPendingSessionWrites(),this.phase="idle",await this.emitAny(B,Q),await this.emitOwn({type:"settled",nextTurnCount:this.nextTurnQueue.length},Q);return}await this.emitAny(B,Q)}async emitRunFailure(B,Q,F,U){let I=nYF(B,Q,F);return await this.handleAgentEvent({type:"message_start",message:I},U),await this.handleAgentEvent({type:"message_end",message:I},U),await this.handleAgentEvent({type:"turn_end",message:I,toolResults:[]},U),await this.handleAgentEvent({type:"agent_end",messages:[I]},U),[I]}async executeTurn(B,Q,F){let U=B,I=[Di(Q,F?.images)];if(this.nextTurnQueue.length>0){let b=this.nextTurnQueue.splice(0);try{await this.emitQueueUpdate()}catch(X){throw this.nextTurnQueue.unshift(...b),Tz(X)}I=[...b,I[0]]}let G=await this.emitHook({type:"before_agent_start",prompt:Q,images:F?.images,systemPrompt:B.systemPrompt,resources:B.resources});if(G?.messages)I=[...I,...G.messages];let Z=new AbortController,W=()=>U,g=(b)=>{U=b};this.runAbortController=Z;let V=(async()=>{try{return await _XB(I,this.createContext(B,G?.systemPrompt),this.createLoopConfig(W,g),(b)=>this.handleAgentEvent(b,Z.signal),Z.signal,this.createStreamFn(W))}catch(b){try{return await this.emitRunFailure(U.model,b,Z.signal.aborted,Z.signal)}catch(X){let C=AggregateError([cV(b),cV(X)],"Agent run failed and failure reporting failed");throw new nI("unknown",C.message,C)}}})();try{let b=await V;for(let X=b.length-1;X>=0;X--){let C=b[X];if(C.role==="assistant")return C}throw new nI("invalid_state","AgentHarness prompt completed without an assistant message")}finally{try{await this.flushPendingSessionWrites()}finally{this.runAbortController=void 0}}}async prompt(B,Q){if(this.phase!=="idle")throw new nI("busy","AgentHarness is busy");this.phase="turn";let F=this.startRunPromise();try{let U=await this.createTurnState();return await this.executeTurn(U,B,Q)}catch(U){throw this.phase="idle",TN(U,"unknown")}finally{F()}}async skill(B,Q){if(this.phase!=="idle")throw new nI("busy","AgentHarness is busy");this.phase="turn";let F=this.startRunPromise();try{let U=await this.createTurnState(),I=(U.resources.skills??[]).find((G)=>G.name===B);if(!I)throw new nI("invalid_argument",`Unknown skill: ${B}`);return await this.executeTurn(U,$gQ(I,Q))}catch(U){throw this.phase="idle",TN(U,"unknown")}finally{F()}}async promptFromTemplate(B,Q=[]){if(this.phase!=="idle")throw new nI("busy","AgentHarness is busy");this.phase="turn";let F=this.startRunPromise();try{let U=await this.createTurnState(),I=(U.resources.promptTemplates??[]).find((G)=>G.name===B);if(!I)throw new nI("invalid_argument",`Unknown prompt template: ${B}`);return await this.executeTurn(U,zgQ(I,Q))}catch(U){throw this.phase="idle",TN(U,"unknown")}finally{F()}}async steer(B,Q){if(this.phase==="idle")throw new nI("invalid_state","Cannot steer while idle");this.steerQueue.push(Di(B,Q?.images)),await this.emitQueueUpdate()}async followUp(B,Q){if(this.phase==="idle")throw new nI("invalid_state","Cannot follow up while idle");this.followUpQueue.push(Di(B,Q?.images)),await this.emitQueueUpdate()}async nextTurn(B,Q){this.nextTurnQueue.push(Di(B,Q?.images)),await this.emitQueueUpdate()}async appendMessage(B){try{if(this.phase==="idle")await this.session.appendMessage(B);else this.pendingSessionWrites.push({type:"message",message:B})}catch(Q){throw TN(Q,"session")}}async compact(B){if(this.phase!=="idle")throw new nI("busy","compact() requires idle harness");this.phase="compaction";try{let Q=this.model;if(!Q)throw new nI("invalid_state","No model set for compaction");let F=await this.getApiKeyAndHeaders?.(Q);if(!F)throw new nI("auth","No auth available for compaction");let U=await this.session.getBranch(),I=lXB(U,fXB);if(!I.ok)throw I.error;let G=I.value;if(!G)throw new nI("compaction","Nothing to compact");let Z=await this.emitHook({type:"session_before_compact",preparation:G,branchEntries:U,customInstructions:B,signal:new AbortController().signal});if(Z?.cancel)throw new nI("compaction","Compaction cancelled");let W=Z?.compaction,g=W?{ok:!0,value:W}:await uXB(G,Q,F.apiKey,F.headers,B,void 0,this.thinkingLevel);if(!g.ok)throw g.error;let V=g.value,b=await this.session.appendCompaction(V.summary,V.firstKeptEntryId,V.tokensBefore,V.details,W!==void 0),X=await this.session.getEntry(b);if(X?.type==="compaction")await this.emitOwn({type:"session_compact",compactionEntry:X,fromHook:W!==void 0});return V}catch(Q){throw TN(Q,"compaction")}finally{this.phase="idle"}}async navigateTree(B,Q){if(this.phase!=="idle")throw new nI("busy","navigateTree() requires idle harness");this.phase="branch_summary";try{let F=await this.session.getLeafId();if(F===B)return{cancelled:!1};let U=await this.session.getEntry(B);if(!U)throw new nI("invalid_argument",`Entry ${B} not found`);let{entries:I,commonAncestorId:G}=await qXB(this.session,F,B),Z={targetId:B,oldLeafId:F,commonAncestorId:G,entriesToSummarize:I,userWantsSummary:Q?.summarize??!1,customInstructions:Q?.customInstructions,replaceInstructions:Q?.replaceInstructions,label:Q?.label},W=new AbortController().signal,g=await this.emitHook({type:"session_before_tree",preparation:Z,signal:W});if(g?.cancel)return{cancelled:!0};let V,b=g?.summary?.summary,X=g?.summary?.details;if(!b&&Q?.summarize&&I.length>0){let A=this.model;if(!A)throw new nI("invalid_state","No model set for branch summary");let Y=await this.getApiKeyAndHeaders?.(A);if(!Y)throw new nI("auth","No auth available for branch summary");let L=await jXB(I,{model:A,apiKey:Y.apiKey,headers:Y.headers,signal:new AbortController().signal,customInstructions:g?.customInstructions??Q?.customInstructions,replaceInstructions:g?.replaceInstructions??Q?.replaceInstructions});if(!L.ok){if(L.error.code==="aborted")return{cancelled:!0};throw new nI("branch_summary",L.error.message,L.error)}b=L.value.summary,X={readFiles:L.value.readFiles,modifiedFiles:L.value.modifiedFiles}}let C,N;if(U.type==="message"&&U.message.role==="user"){N=U.parentId;let A=U.message.content;C=typeof A==="string"?A:A.filter((Y)=>Y.type==="text").map((Y)=>Y.text).join("")}else if(U.type==="custom_message")N=U.parentId,C=typeof U.content==="string"?U.content:U.content.filter((A)=>A.type==="text").map((A)=>A.text).join("");else N=B;let R=await this.session.moveTo(N,b?{summary:b,details:X,fromHook:g?.summary!==void 0}:void 0);if(R){let A=await this.session.getEntry(R);if(A?.type==="branch_summary")V=A}return await this.emitOwn({type:"session_tree",newLeafId:await this.session.getLeafId(),oldLeafId:F,summaryEntry:V,fromHook:g?.summary!==void 0}),{cancelled:!1,editorText:C,summaryEntry:V}}catch(F){throw TN(F,"branch_summary")}finally{this.phase="idle"}}getModel(){return this.model}async setModel(B){try{let Q=this.model;if(this.phase==="idle")await this.session.appendModelChange(B.provider,B.id);else this.pendingSessionWrites.push({type:"model_change",provider:B.provider,modelId:B.id});this.model=B,await this.emitOwn({type:"model_update",model:B,previousModel:Q,source:"set"})}catch(Q){throw TN(Q,"session")}}getThinkingLevel(){return this.thinkingLevel}async setThinkingLevel(B){try{let Q=this.thinkingLevel;if(this.phase==="idle")await this.session.appendThinkingLevelChange(B);else this.pendingSessionWrites.push({type:"thinking_level_change",thinkingLevel:B});this.thinkingLevel=B,await this.emitOwn({type:"thinking_level_update",level:B,previousLevel:Q})}catch(Q){throw TN(Q,"session")}}getTools(){return[...this.tools.values()]}async setTools(B,Q){try{this.validateUniqueNames(B.map((Z)=>Z.name),"Duplicate tool name(s)");let F=new Map(B.map((Z)=>[Z.name,Z])),U=Q?[...Q]:this.activeToolNames;this.validateToolNames(U,F);let I=[...this.tools.keys()],G=[...this.activeToolNames];if(this.phase==="idle")await this.session.appendActiveToolsChange(U);else this.pendingSessionWrites.push({type:"active_tools_change",activeToolNames:[...U]});this.tools=F,this.activeToolNames=[...U],await this.emitOwn({type:"tools_update",toolNames:[...this.tools.keys()],previousToolNames:I,activeToolNames:[...this.activeToolNames],previousActiveToolNames:G,source:"set"})}catch(F){throw TN(F,"invalid_argument")}}getActiveTools(){return this.activeToolNames.map((B)=>this.tools.get(B))}async setActiveTools(B){try{this.validateToolNames(B);let Q=[...this.tools.keys()],F=[...this.activeToolNames];if(this.phase==="idle")await this.session.appendActiveToolsChange(B);else this.pendingSessionWrites.push({type:"active_tools_change",activeToolNames:[...B]});this.activeToolNames=[...B],await this.emitOwn({type:"tools_update",toolNames:[...this.tools.keys()],previousToolNames:Q,activeToolNames:[...this.activeToolNames],previousActiveToolNames:F,source:"set"})}catch(Q){throw TN(Q,"invalid_argument")}}getSteeringMode(){return this.steeringQueueMode}async setSteeringMode(B){this.steeringQueueMode=B}getFollowUpMode(){return this.followUpQueueMode}async setFollowUpMode(B){this.followUpQueueMode=B}getResources(){return{skills:this.resources.skills?.slice(),promptTemplates:this.resources.promptTemplates?.slice()}}async setResources(B){let Q=this.getResources();this.resources={skills:B.skills?.slice(),promptTemplates:B.promptTemplates?.slice()},await this.emitOwn({type:"resources_update",resources:this.getResources(),previousResources:Q})}getStreamOptions(){return mz(this.streamOptions)}async setStreamOptions(B){this.streamOptions=mz(B)}async abort(){let B=[...this.steerQueue],Q=[...this.followUpQueue];this.steerQueue=[],this.followUpQueue=[],this.runAbortController?.abort();let F=[];try{await this.emitQueueUpdate()}catch(U){F.push(cV(U))}try{await this.waitForIdle()}catch(U){F.push(cV(U))}try{await this.emitOwn({type:"abort",clearedSteer:B,clearedFollowUp:Q})}catch(U){F.push(cV(U))}if(F.length>0){let U=F.length===1?F[0]:AggregateError(F,"Abort completed with errors");throw TN(U,"hook")}return{clearedSteer:B,clearedFollowUp:Q}}async waitForIdle(){await this.runPromise}subscribe(B){let Q=this.handlers.get(zi);if(!Q)Q=new Set,this.handlers.set(zi,Q);return Q.add(B),()=>Q.delete(B)}on(B,Q){let F=this.handlers.get(B);if(!F)F=new Set,this.handlers.set(B,F);return F.add(Q),()=>F.delete(Q)}}var m1I=globalThis.Buffer;import{spawn as bRB}from"child_process";import{randomUUID as BLF}from"crypto";import{constants as QLF,createReadStream as FLF}from"fs";import{access as ULF,appendFile as ILF,lstat as _gQ,mkdir as WRB,mkdtemp as GLF,readdir as ZLF,readFile as vgQ,realpath as WLF,rm as gLF,writeFile as PgQ}from"fs/promises";import{tmpdir as VLF}from"os";import{isAbsolute as bLF,join as gRB,resolve as wi}from"path";import{createInterface as XLF}from"readline";function mN(B,Q){return bLF(Q)?Q:wi(B,Q)}function CLF(B){if(B.isFile())return"file";if(B.isDirectory())return"directory";if(B.isSymbolicLink())return"symlink";return}function fgQ(B,Q){let F=CLF(Q);if(!F)return pU(new wN("invalid","Unsupported file type",B));return H0({name:B.replace(/\/+$/,"").split("/").pop()??B,path:B,kind:F,size:Q.size,mtimeMs:Q.mtimeMs})}function RLF(B){return B instanceof Error&&"code"in B}function dR(B,Q){if(B instanceof wN)return B;let F=cV(B);if(RLF(B)){let U=B.message;switch(B.code){case"ABORT_ERR":return new wN("aborted",U,Q,F);case"ENOENT":return new wN("not_found",U,Q,F);case"EACCES":case"EPERM":return new wN("permission_denied",U,Q,F);case"ENOTDIR":return new wN("not_directory",U,Q,F);case"EISDIR":return new wN("is_directory",U,Q,F);case"EINVAL":return new wN("invalid",U,Q,F)}}return new wN("unknown",F.message,Q,F)}function VJ(B,Q){return B?.aborted?pU(new wN("aborted","aborted",Q)):void 0}async function Si(B){try{return await ULF(B,QLF.F_OK),!0}catch{return!1}}async function lgQ(B,Q,F){return await new Promise((U)=>{let I="",G;try{G=bRB(B,Q,{stdio:["ignore","pipe","ignore"],windowsHide:!0})}catch{U({stdout:"",status:null});return}let Z=setTimeout(()=>{if(G.pid)VRB(G.pid)},F);G.stdout?.setEncoding("utf8"),G.stdout?.on("data",(W)=>{I+=W}),G.on("error",()=>{clearTimeout(Z),U({stdout:"",status:null})}),G.on("close",(W)=>{clearTimeout(Z),U({stdout:I,status:W})})})}async function ugQ(){let B=process.platform==="win32"?await lgQ("where",["bash.exe"],5000):await lgQ("which",["bash"],5000);if(B.status!==0||!B.stdout)return null;let Q=B.stdout.trim().split(/\r?\n/)[0];return Q&&await Si(Q)?Q:null}async function NLF(B){if(B){if(await Si(B))return H0({shell:B,args:["-c"]});return pU(new SN("shell_unavailable",`Custom shell path not found: ${B}`))}if(process.platform==="win32"){let F=[],U=process.env.ProgramFiles;if(U)F.push(`${U}\\Git\\bin\\bash.exe`);let I=process.env["ProgramFiles(x86)"];if(I)F.push(`${I}\\Git\\bin\\bash.exe`);for(let Z of F)if(await Si(Z))return H0({shell:Z,args:["-c"]});let G=await ugQ();if(G)return H0({shell:G,args:["-c"]});return pU(new SN("shell_unavailable","No bash shell found"))}if(await Si("/bin/bash"))return H0({shell:"/bin/bash",args:["-c"]});let Q=await ugQ();if(Q)return H0({shell:Q,args:["-c"]});return H0({shell:"sh",args:["-c"]})}function ALF(B,Q){return{...process.env,...B,...Q}}function VRB(B){if(process.platform==="win32"){try{bRB("taskkill",["/F","/T","/PID",String(B)],{stdio:"ignore",detached:!0,windowsHide:!0})}catch{}return}try{process.kill(-B,"SIGKILL")}catch{try{process.kill(B,"SIGKILL")}catch{}}}class yi{cwd;shellPath;shellEnv;constructor(B){this.cwd=B.cwd,this.shellPath=B.shellPath,this.shellEnv=B.shellEnv}async absolutePath(B){return H0(mN(this.cwd,B))}async joinPath(B){return H0(gRB(...B))}async exec(B,Q){if(Q?.abortSignal?.aborted)return pU(new SN("aborted","aborted"));let F=Q?.cwd?mN(this.cwd,Q.cwd):this.cwd,U=await NLF(this.shellPath);if(!U.ok)return U;return await new Promise((I)=>{let G="",Z="",W=!1,g=!1,V,b,X,C=()=>{if(b?.pid)VRB(b.pid)},N=(R)=>{if(X)clearTimeout(X);if(Q?.abortSignal)Q.abortSignal.removeEventListener("abort",C);if(W)return;W=!0,I(R)};try{b=bRB(U.value.shell,[...U.value.args,B],{cwd:F,detached:process.platform!=="win32",env:ALF(this.shellEnv,Q?.env),stdio:["ignore","pipe","pipe"],windowsHide:!0})}catch(R){let A=cV(R);N(pU(new SN("spawn_error",A.message,A)));return}if(X=typeof Q?.timeout==="number"?setTimeout(()=>{if(g=!0,b?.pid)VRB(b.pid)},Q.timeout*1000):void 0,Q?.abortSignal)if(Q.abortSignal.aborted)C();else Q.abortSignal.addEventListener("abort",C,{once:!0});b.stdout?.setEncoding("utf8"),b.stderr?.setEncoding("utf8"),b.stdout?.on("data",(R)=>{G+=R;try{Q?.onStdout?.(R)}catch(A){let Y=cV(A);V=new SN("callback_error",Y.message,Y),C()}}),b.stderr?.on("data",(R)=>{Z+=R;try{Q?.onStderr?.(R)}catch(A){let Y=cV(A);V=new SN("callback_error",Y.message,Y),C()}}),b.on("error",(R)=>{N(pU(new SN("spawn_error",R.message,R)))}),b.on("close",(R)=>{if(V){N(pU(V));return}if(g){N(pU(new SN("timeout",`timeout:${Q?.timeout}`)));return}if(Q?.abortSignal?.aborted){N(pU(new SN("aborted","aborted")));return}N(H0({stdout:G,stderr:Z,exitCode:R??0}))})})}async readTextFile(B,Q){let F=mN(this.cwd,B),U=VJ(Q,F);if(U)return U;try{return H0(await vgQ(F,{encoding:"utf8",signal:Q}))}catch(I){return pU(dR(I,F))}}async readTextLines(B,Q){let F=mN(this.cwd,B),U=VJ(Q?.abortSignal,F);if(U)return U;if(Q?.maxLines!==void 0&&Q.maxLines<=0)return H0([]);let I,G;try{I=FLF(F,{encoding:"utf8",signal:Q?.abortSignal}),G=XLF({input:I,crlfDelay:1/0});let Z=[];for await(let g of G){let V=VJ(Q?.abortSignal,F);if(V)return V;if(Z.push(g),Q?.maxLines!==void 0&&Z.length>=Q.maxLines)break}let W=VJ(Q?.abortSignal,F);if(W)return W;return H0(Z)}catch(Z){return pU(dR(Z,F))}finally{G?.close(),I?.destroy()}}async readBinaryFile(B,Q){let F=mN(this.cwd,B),U=VJ(Q,F);if(U)return U;try{return H0(await vgQ(F,{signal:Q}))}catch(I){return pU(dR(I,F))}}async writeFile(B,Q,F){let U=mN(this.cwd,B),I=VJ(F,U);if(I)return I;try{await WRB(wi(U,".."),{recursive:!0});let G=VJ(F,U);if(G)return G;return await PgQ(U,Q,{signal:F}),H0(void 0)}catch(G){return pU(dR(G,U))}}async appendFile(B,Q){let F=mN(this.cwd,B);try{return await WRB(wi(F,".."),{recursive:!0}),await ILF(F,Q),H0(void 0)}catch(U){return pU(dR(U,F))}}async fileInfo(B){let Q=mN(this.cwd,B);try{return fgQ(Q,await _gQ(Q))}catch(F){return pU(dR(F,Q))}}async listDir(B,Q){let F=mN(this.cwd,B),U=VJ(Q,F);if(U)return U;try{let I=await ZLF(F,{withFileTypes:!0}),G=[];for(let Z of I){let W=VJ(Q,F);if(W)return W;let g=wi(F,Z.name);try{let V=fgQ(g,await _gQ(g));if(V.ok)G.push(V.value)}catch(V){return pU(dR(V,g))}}return H0(G)}catch(I){return pU(dR(I,F))}}async canonicalPath(B){let Q=mN(this.cwd,B);try{return H0(await WLF(Q))}catch(F){return pU(dR(F,Q))}}async exists(B){let Q=await this.fileInfo(B);if(Q.ok)return H0(!0);if(Q.error.code==="not_found")return H0(!1);return pU(Q.error)}async createDir(B,Q){let F=mN(this.cwd,B);try{return await WRB(F,{recursive:Q?.recursive??!0}),H0(void 0)}catch(U){return pU(dR(U,F))}}async remove(B,Q){let F=mN(this.cwd,B);try{return await gLF(F,{recursive:Q?.recursive??!1,force:Q?.force??!1}),H0(void 0)}catch(U){return pU(dR(U,F))}}async createTempDir(B="tmp-"){try{return H0(await GLF(gRB(VLF(),B)))}catch(Q){return pU(dR(Q))}}async createTempFile(B){let Q=await this.createTempDir("tmp-");if(!Q.ok)return Q;let F=gRB(Q.value,`${B?.prefix??""}${BLF()}${B?.suffix??""}`);try{return await PgQ(F,""),H0(F)}catch(U){return pU(dR(U,F))}}async cleanup(){}}var YLF=new Map;function LLF(B,Q){return(F,U,I)=>{if(F.api!==B)throw Error(`Mismatched api: ${F.api} expected ${B}`);return Q(F,U,I)}}function HLF(B,Q){return(F,U,I)=>{if(F.api!==B)throw Error(`Mismatched api: ${F.api} expected ${B}`);return Q(F,U,I)}}function GA(B,Q){YLF.set(B.api,{provider:{api:B.api,stream:LLF(B.api,B.stream),streamSimple:HLF(B.api,B.streamSimple)},sourceId:Q})}ZA();var qgQ={openrouter:{"black-forest-labs/flux.2-flex":{id:"black-forest-labs/flux.2-flex",name:"Black Forest Labs: FLUX.2 Flex",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"black-forest-labs/flux.2-klein-4b":{id:"black-forest-labs/flux.2-klein-4b",name:"Black Forest Labs: FLUX.2 Klein 4B",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"black-forest-labs/flux.2-max":{id:"black-forest-labs/flux.2-max",name:"Black Forest Labs: FLUX.2 Max",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"black-forest-labs/flux.2-pro":{id:"black-forest-labs/flux.2-pro",name:"Black Forest Labs: FLUX.2 Pro",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"bytedance-seed/seedream-4.5":{id:"bytedance-seed/seedream-4.5",name:"ByteDance Seed: Seedream 4.5",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"google/gemini-2.5-flash-image":{id:"google/gemini-2.5-flash-image",name:"Google: Nano Banana (Gemini 2.5 Flash Image)",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:0.3,output:2.5,cacheRead:0.03,cacheWrite:0.08333333333333334}},"google/gemini-3-pro-image-preview":{id:"google/gemini-3-pro-image-preview",name:"Google: Nano Banana Pro (Gemini 3 Pro Image Preview)",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:2,output:12,cacheRead:0.19999999999999998,cacheWrite:0.375}},"google/gemini-3.1-flash-image-preview":{id:"google/gemini-3.1-flash-image-preview",name:"Google: Nano Banana 2 (Gemini 3.1 Flash Image Preview)",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:0.5,output:3,cacheRead:0,cacheWrite:0}},"openai/gpt-5-image":{id:"openai/gpt-5-image",name:"OpenAI: GPT-5 Image",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:10,output:10,cacheRead:1.25,cacheWrite:0}},"openai/gpt-5-image-mini":{id:"openai/gpt-5-image-mini",name:"OpenAI: GPT-5 Image Mini",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:2.5,output:2,cacheRead:0.25,cacheWrite:0}},"openai/gpt-5.4-image-2":{id:"openai/gpt-5.4-image-2",name:"OpenAI: GPT-5.4 Image 2",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:8,output:15,cacheRead:2,cacheWrite:0}},"openrouter/auto":{id:"openrouter/auto",name:"Auto Router",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["text","image"],cost:{input:-1e6,output:-1e6,cacheRead:0,cacheWrite:0}},"recraft/recraft-v3":{id:"recraft/recraft-v3",name:"Recraft: Recraft V3",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4":{id:"recraft/recraft-v4",name:"Recraft: Recraft V4",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4-pro":{id:"recraft/recraft-v4-pro",name:"Recraft: Recraft V4 Pro",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4-pro-vector":{id:"recraft/recraft-v4-pro-vector",name:"Recraft: Recraft V4 Pro Vector",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4-vector":{id:"recraft/recraft-v4-vector",name:"Recraft: Recraft V4 Vector",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1":{id:"recraft/recraft-v4.1",name:"Recraft: Recraft V4.1",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1-pro":{id:"recraft/recraft-v4.1-pro",name:"Recraft: Recraft V4.1 Pro",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1-pro-vector":{id:"recraft/recraft-v4.1-pro-vector",name:"Recraft: Recraft V4.1 Pro Vector",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1-utility":{id:"recraft/recraft-v4.1-utility",name:"Recraft: Recraft V4.1 Utility",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1-utility-pro":{id:"recraft/recraft-v4.1-utility-pro",name:"Recraft: Recraft V4.1 Utility Pro",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1-vector":{id:"recraft/recraft-v4.1-vector",name:"Recraft: Recraft V4.1 Vector",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"sourceful/riverflow-v2-fast":{id:"sourceful/riverflow-v2-fast",name:"Sourceful: Riverflow V2 Fast",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"sourceful/riverflow-v2-fast-preview":{id:"sourceful/riverflow-v2-fast-preview",name:"Sourceful: Riverflow V2 Fast Preview",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"sourceful/riverflow-v2-max-preview":{id:"sourceful/riverflow-v2-max-preview",name:"Sourceful: Riverflow V2 Max Preview",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"sourceful/riverflow-v2-pro":{id:"sourceful/riverflow-v2-pro",name:"Sourceful: Riverflow V2 Pro",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"sourceful/riverflow-v2-standard-preview":{id:"sourceful/riverflow-v2-standard-preview",name:"Sourceful: Riverflow V2 Standard Preview",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"x-ai/grok-imagine-image-quality":{id:"x-ai/grok-imagine-image-quality",name:"xAI: Grok Imagine Image Quality",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}}};var yLF=new Map;for(let[B,Q]of Object.entries(qgQ)){let F=new Map;for(let[U,I]of Object.entries(Q))F.set(U,I);yLF.set(B,F)}var MLF=new Map;function TLF(B,Q){return(F,U,I)=>{if(F.api!==B)throw Error(`Mismatched api: ${F.api} expected ${B}`);return Q(F,U,I)}}function jgQ(B,Q){MLF.set(B.api,{provider:{api:B.api,generateImages:TLF(B.api,B.generateImages)},sourceId:Q})}var pgQ;function hLF(B,Q){return{api:B.api,provider:B.provider,model:B.id,output:[],stopReason:"error",errorMessage:Q instanceof Error?Q.message:String(Q),timestamp:Date.now()}}function kLF(){return pgQ||=Promise.resolve().then(() => (igQ(),ngQ)).then((B)=>B),pgQ}var dLF=async(B,Q,F)=>{try{return await(await kLF()).generateImagesOpenRouter(B,Q,F)}catch(U){return hLF(B,U)}};function $LF(){jgQ({api:"openrouter-images",generateImages:dLF})}$LF();WA();ON();ON();var w5F=function(B,Q){if(typeof B==="string"&&/^\.\.?\//.test(B))return B.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(F,U,I,G,Z){return U?Q?".jsx":".js":I&&(!G||!Z)?F:I+G+"."+Z.toLowerCase()+"js"});return B},S5F=(B)=>{let Q=import.meta.url.endsWith(".js")?B.replace(/\.ts$/,".js"):B;return import(w5F(Q))},gbQ,VbQ,bbQ,XbQ,CbQ,RbQ,NbQ,AbQ,YbQ,LbQ;function HbQ(B,Q){(async()=>{for await(let F of Q)B.push(F);B.end()})()}function JbQ(B,Q){return{role:"assistant",content:[],api:B.api,provider:B.provider,model:B.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"error",errorMessage:Q instanceof Error?Q.message:String(Q),timestamp:Date.now()}}function bJ(B){return(Q,F,U)=>{let I=new nW;return B().then((G)=>{let Z=G.stream(Q,F,U);HbQ(I,Z)}).catch((G)=>{let Z=JbQ(Q,G);I.push({type:"error",reason:"error",error:Z}),I.end(Z)}),I}}function XJ(B){return(Q,F,U)=>{let I=new nW;return B().then((G)=>{let Z=G.streamSimple(Q,F,U);HbQ(I,Z)}).catch((G)=>{let Z=JbQ(Q,G);I.push({type:"error",reason:"error",error:Z}),I.end(Z)}),I}}function xbQ(){return gbQ||=Promise.resolve().then(() => (ZVQ(),GVQ)).then((B)=>{let Q=B;return{stream:Q.streamAnthropic,streamSimple:Q.streamSimpleAnthropic}}),gbQ}function EbQ(){return VbQ||=Promise.resolve().then(() => (VVQ(),gVQ)).then((B)=>{let Q=B;return{stream:Q.streamAzureOpenAIResponses,streamSimple:Q.streamSimpleAzureOpenAIResponses}}),VbQ}function DbQ(){return bbQ||=Promise.resolve().then(() => (RVQ(),CVQ)).then((B)=>{let Q=B;return{stream:Q.streamGoogle,streamSimple:Q.streamSimpleGoogle}}),bbQ}function zbQ(){return XbQ||=Promise.resolve().then(() => (HVQ(),LVQ)).then((B)=>{let Q=B;return{stream:Q.streamGoogleVertex,streamSimple:Q.streamSimpleGoogleVertex}}),XbQ}function wbQ(){return CbQ||=Promise.resolve().then(() => (wVQ(),zVQ)).then((B)=>{let Q=B;return{stream:Q.streamMistral,streamSimple:Q.streamSimpleMistral}}),CbQ}function SbQ(){return RbQ||=Promise.resolve().then(() => (aVQ(),pVQ)).then((B)=>{let Q=B;return{stream:Q.streamOpenAICodexResponses,streamSimple:Q.streamSimpleOpenAICodexResponses}}),RbQ}function ybQ(){return NbQ||=Promise.resolve().then(() => (FbQ(),QbQ)).then((B)=>{let Q=B;return{stream:Q.streamOpenAICompletions,streamSimple:Q.streamSimpleOpenAICompletions}}),NbQ}function MbQ(){return AbQ||=Promise.resolve().then(() => (WbQ(),ZbQ)).then((B)=>{let Q=B;return{stream:Q.streamOpenAIResponses,streamSimple:Q.streamSimpleOpenAIResponses}}),AbQ}function TbQ(){if(YbQ)return Promise.resolve(YbQ);return LbQ||=S5F("./amazon-bedrock.ts").then((B)=>{let Q=B;return{stream:Q.streamBedrock,streamSimple:Q.streamSimpleBedrock}}),LbQ}var y5F=bJ(xbQ),M5F=XJ(xbQ),T5F=bJ(EbQ),m5F=XJ(EbQ),O5F=bJ(DbQ),c5F=XJ(DbQ),K5F=bJ(zbQ),h5F=XJ(zbQ),k5F=bJ(wbQ),d5F=XJ(wbQ),$5F=bJ(SbQ),_5F=XJ(SbQ),v5F=bJ(ybQ),P5F=XJ(ybQ),f5F=bJ(MbQ),l5F=XJ(MbQ),u5F=bJ(TbQ),q5F=XJ(TbQ);function j5F(){GA({api:"anthropic-messages",stream:y5F,streamSimple:M5F}),GA({api:"openai-completions",stream:v5F,streamSimple:P5F}),GA({api:"mistral-conversations",stream:k5F,streamSimple:d5F}),GA({api:"openai-responses",stream:f5F,streamSimple:l5F}),GA({api:"azure-openai-responses",stream:T5F,streamSimple:m5F}),GA({api:"openai-codex-responses",stream:$5F,streamSimple:_5F}),GA({api:"google-generative-ai",stream:O5F,streamSimple:c5F}),GA({api:"google-vertex",stream:K5F,streamSimple:h5F}),GA({api:"bedrock-converse-stream",stream:u5F,streamSimple:q5F})}j5F();yRB();ZA();ON();LT();var wb={};WU(wb,{IsUndefined:()=>xW,IsUint8Array:()=>RJ,IsSymbol:()=>dRB,IsString:()=>IG,IsRegExp:()=>rh,IsObject:()=>mI,IsNumber:()=>PR,IsNull:()=>kRB,IsIterator:()=>hRB,IsFunction:()=>KRB,IsDate:()=>Kz,IsBoolean:()=>CJ,IsBigInt:()=>oh,IsAsyncIterator:()=>cRB,IsArray:()=>JW,HasPropertyKey:()=>pi});function pi(B,Q){return Q in B}function cRB(B){return mI(B)&&!JW(B)&&!RJ(B)&&Symbol.asyncIterator in B}function JW(B){return Array.isArray(B)}function oh(B){return typeof B==="bigint"}function CJ(B){return typeof B==="boolean"}function Kz(B){return B instanceof globalThis.Date}function KRB(B){return typeof B==="function"}function hRB(B){return mI(B)&&!JW(B)&&!RJ(B)&&Symbol.iterator in B}function kRB(B){return B===null}function PR(B){return typeof B==="number"}function mI(B){return typeof B==="object"&&B!==null}function rh(B){return B instanceof globalThis.RegExp}function IG(B){return typeof B==="string"}function dRB(B){return typeof B==="symbol"}function RJ(B){return B instanceof globalThis.Uint8Array}function xW(B){return B===void 0}function n5F(B){return B.map((Q)=>ai(Q))}function i5F(B){return new Date(B.getTime())}function p5F(B){return new Uint8Array(B)}function a5F(B){return new RegExp(B.source,B.flags)}function o5F(B){let Q={};for(let F of Object.getOwnPropertyNames(B))Q[F]=ai(B[F]);for(let F of Object.getOwnPropertySymbols(B))Q[F]=ai(B[F]);return Q}function ai(B){return JW(B)?n5F(B):Kz(B)?i5F(B):RJ(B)?p5F(B):rh(B)?a5F(B):mI(B)?o5F(B):B}function nG(B){return ai(B)}function zT(B,Q){return Q===void 0?nG(B):nG({...Q,...B})}function mbQ(B){return B!==null&&typeof B==="object"}function ObQ(B){return globalThis.Array.isArray(B)&&!globalThis.ArrayBuffer.isView(B)}function cbQ(B){return B===void 0}function KbQ(B){return typeof B==="number"}var oi;(function(B){B.InstanceMode="default",B.ExactOptionalPropertyTypes=!1,B.AllowArrayObject=!1,B.AllowNaN=!1,B.AllowNullVoid=!1;function Q(Z,W){return B.ExactOptionalPropertyTypes?W in Z:Z[W]!==void 0}B.IsExactOptionalProperty=Q;function F(Z){let W=mbQ(Z);return B.AllowArrayObject?W:W&&!ObQ(Z)}B.IsObjectLike=F;function U(Z){return F(Z)&&!(Z instanceof Date)&&!(Z instanceof Uint8Array)}B.IsRecordLike=U;function I(Z){return B.AllowNaN?KbQ(Z):Number.isFinite(Z)}B.IsNumberLike=I;function G(Z){let W=cbQ(Z);return B.AllowNullVoid?W||Z===null:W}B.IsVoidLike=G})(oi||(oi={}));function r5F(B){return globalThis.Object.freeze(B).map((Q)=>sh(Q))}function s5F(B){return B}function t5F(B){return B}function e5F(B){return B}function BxF(B){let Q={};for(let F of Object.getOwnPropertyNames(B))Q[F]=sh(B[F]);for(let F of Object.getOwnPropertySymbols(B))Q[F]=sh(B[F]);return globalThis.Object.freeze(Q)}function sh(B){return JW(B)?r5F(B):Kz(B)?s5F(B):RJ(B)?t5F(B):rh(B)?e5F(B):mI(B)?BxF(B):B}function UQ(B,Q){let F=Q!==void 0?{...Q,...B}:B;switch(oi.InstanceMode){case"freeze":return sh(F);case"clone":return nG(F);default:return F}}class KV extends Error{constructor(B){super(B)}}var iW=Symbol.for("TypeBox.Transform"),VA=Symbol.for("TypeBox.Readonly"),hV=Symbol.for("TypeBox.Optional"),cN=Symbol.for("TypeBox.Hint"),zQ=Symbol.for("TypeBox.Kind");function wT(B){return mI(B)&&B[VA]==="Readonly"}function SC(B){return mI(B)&&B[hV]==="Optional"}function $RB(B){return J0(B,"Any")}function _RB(B){return J0(B,"Argument")}function bA(B){return J0(B,"Array")}function hz(B){return J0(B,"AsyncIterator")}function kz(B){return J0(B,"BigInt")}function NJ(B){return J0(B,"Boolean")}function XA(B){return J0(B,"Computed")}function CA(B){return J0(B,"Constructor")}function QxF(B){return J0(B,"Date")}function RA(B){return J0(B,"Function")}function NA(B){return J0(B,"Integer")}function wZ(B){return J0(B,"Intersect")}function dz(B){return J0(B,"Iterator")}function J0(B,Q){return mI(B)&&zQ in B&&B[zQ]===Q}function ri(B){return CJ(B)||PR(B)||IG(B)}function fR(B){return J0(B,"Literal")}function lR(B){return J0(B,"MappedKey")}function iG(B){return J0(B,"MappedResult")}function r9(B){return J0(B,"Never")}function FxF(B){return J0(B,"Not")}function th(B){return J0(B,"Null")}function AA(B){return J0(B,"Number")}function EW(B){return J0(B,"Object")}function $z(B){return J0(B,"Promise")}function _z(B){return J0(B,"Record")}function UW(B){return J0(B,"Ref")}function vRB(B){return J0(B,"RegExp")}function AJ(B){return J0(B,"String")}function eh(B){return J0(B,"Symbol")}function uR(B){return J0(B,"TemplateLiteral")}function UxF(B){return J0(B,"This")}function s9(B){return mI(B)&&iW in B}function qR(B){return J0(B,"Tuple")}function Bk(B){return J0(B,"Undefined")}function y0(B){return J0(B,"Union")}function IxF(B){return J0(B,"Uint8Array")}function GxF(B){return J0(B,"Unknown")}function ZxF(B){return J0(B,"Unsafe")}function WxF(B){return J0(B,"Void")}function gxF(B){return mI(B)&&zQ in B&&IG(B[zQ])}function jR(B){return $RB(B)||_RB(B)||bA(B)||NJ(B)||kz(B)||hz(B)||XA(B)||CA(B)||QxF(B)||RA(B)||NA(B)||wZ(B)||dz(B)||fR(B)||lR(B)||iG(B)||r9(B)||FxF(B)||th(B)||AA(B)||EW(B)||$z(B)||_z(B)||UW(B)||vRB(B)||AJ(B)||eh(B)||uR(B)||UxF(B)||qR(B)||Bk(B)||y0(B)||IxF(B)||GxF(B)||ZxF(B)||WxF(B)||gxF(B)}var SB={};WU(SB,{TypeGuardUnknownTypeError:()=>hbQ,IsVoid:()=>xXQ,IsUnsafe:()=>JXQ,IsUnknown:()=>HXQ,IsUnionLiteral:()=>LxF,IsUnion:()=>lRB,IsUndefined:()=>YXQ,IsUint8Array:()=>LXQ,IsTuple:()=>AXQ,IsTransform:()=>NXQ,IsThis:()=>RXQ,IsTemplateLiteral:()=>CXQ,IsSymbol:()=>XXQ,IsString:()=>bXQ,IsSchema:()=>tg,IsRegExp:()=>VXQ,IsRef:()=>gXQ,IsRecursive:()=>YxF,IsRecord:()=>WXQ,IsReadonly:()=>CxF,IsProperties:()=>si,IsPromise:()=>ZXQ,IsOptional:()=>RxF,IsObject:()=>GXQ,IsNumber:()=>IXQ,IsNull:()=>UXQ,IsNot:()=>FXQ,IsNever:()=>QXQ,IsMappedResult:()=>BXQ,IsMappedKey:()=>ebQ,IsLiteralValue:()=>tbQ,IsLiteralString:()=>rbQ,IsLiteralNumber:()=>sbQ,IsLiteralBoolean:()=>AxF,IsLiteral:()=>Fk,IsKindOf:()=>B0,IsKind:()=>EXQ,IsIterator:()=>obQ,IsIntersect:()=>abQ,IsInteger:()=>pbQ,IsImport:()=>NxF,IsFunction:()=>ibQ,IsDate:()=>nbQ,IsConstructor:()=>jbQ,IsComputed:()=>qbQ,IsBoolean:()=>ubQ,IsBigInt:()=>lbQ,IsAsyncIterator:()=>fbQ,IsArray:()=>PbQ,IsArgument:()=>vbQ,IsAny:()=>_bQ});class hbQ extends KV{}var VxF=["Argument","Any","Array","AsyncIterator","BigInt","Boolean","Computed","Constructor","Date","Enum","Function","Integer","Intersect","Iterator","Literal","MappedKey","MappedResult","Not","Null","Number","Object","Promise","Record","Ref","RegExp","String","Symbol","TemplateLiteral","This","Tuple","Undefined","Union","Uint8Array","Unknown","Void"];function kbQ(B){try{return new RegExp(B),!0}catch{return!1}}function PRB(B){if(!IG(B))return!1;for(let Q=0;Q<B.length;Q++){let F=B.charCodeAt(Q);if(F>=7&&F<=13||F===27||F===127)return!1}return!0}function dbQ(B){return fRB(B)||tg(B)}function Qk(B){return xW(B)||oh(B)}function GG(B){return xW(B)||PR(B)}function fRB(B){return xW(B)||CJ(B)}function OI(B){return xW(B)||IG(B)}function bxF(B){return xW(B)||IG(B)&&PRB(B)&&kbQ(B)}function XxF(B){return xW(B)||IG(B)&&PRB(B)}function $bQ(B){return xW(B)||tg(B)}function CxF(B){return mI(B)&&B[VA]==="Readonly"}function RxF(B){return mI(B)&&B[hV]==="Optional"}function _bQ(B){return B0(B,"Any")&&OI(B.$id)}function vbQ(B){return B0(B,"Argument")&&PR(B.index)}function PbQ(B){return B0(B,"Array")&&B.type==="array"&&OI(B.$id)&&tg(B.items)&&GG(B.minItems)&&GG(B.maxItems)&&fRB(B.uniqueItems)&&$bQ(B.contains)&&GG(B.minContains)&&GG(B.maxContains)}function fbQ(B){return B0(B,"AsyncIterator")&&B.type==="AsyncIterator"&&OI(B.$id)&&tg(B.items)}function lbQ(B){return B0(B,"BigInt")&&B.type==="bigint"&&OI(B.$id)&&Qk(B.exclusiveMaximum)&&Qk(B.exclusiveMinimum)&&Qk(B.maximum)&&Qk(B.minimum)&&Qk(B.multipleOf)}function ubQ(B){return B0(B,"Boolean")&&B.type==="boolean"&&OI(B.$id)}function qbQ(B){return B0(B,"Computed")&&IG(B.target)&&JW(B.parameters)&&B.parameters.every((Q)=>tg(Q))}function jbQ(B){return B0(B,"Constructor")&&B.type==="Constructor"&&OI(B.$id)&&JW(B.parameters)&&B.parameters.every((Q)=>tg(Q))&&tg(B.returns)}function nbQ(B){return B0(B,"Date")&&B.type==="Date"&&OI(B.$id)&&GG(B.exclusiveMaximumTimestamp)&&GG(B.exclusiveMinimumTimestamp)&&GG(B.maximumTimestamp)&&GG(B.minimumTimestamp)&&GG(B.multipleOfTimestamp)}function ibQ(B){return B0(B,"Function")&&B.type==="Function"&&OI(B.$id)&&JW(B.parameters)&&B.parameters.every((Q)=>tg(Q))&&tg(B.returns)}function NxF(B){return B0(B,"Import")&&pi(B,"$defs")&&mI(B.$defs)&&si(B.$defs)&&pi(B,"$ref")&&IG(B.$ref)&&B.$ref in B.$defs}function pbQ(B){return B0(B,"Integer")&&B.type==="integer"&&OI(B.$id)&&GG(B.exclusiveMaximum)&&GG(B.exclusiveMinimum)&&GG(B.maximum)&&GG(B.minimum)&&GG(B.multipleOf)}function si(B){return mI(B)&&Object.entries(B).every(([Q,F])=>PRB(Q)&&tg(F))}function abQ(B){return B0(B,"Intersect")&&(IG(B.type)&&B.type!=="object"?!1:!0)&&JW(B.allOf)&&B.allOf.every((Q)=>tg(Q)&&!NXQ(Q))&&OI(B.type)&&(fRB(B.unevaluatedProperties)||$bQ(B.unevaluatedProperties))&&OI(B.$id)}function obQ(B){return B0(B,"Iterator")&&B.type==="Iterator"&&OI(B.$id)&&tg(B.items)}function B0(B,Q){return mI(B)&&zQ in B&&B[zQ]===Q}function rbQ(B){return Fk(B)&&IG(B.const)}function sbQ(B){return Fk(B)&&PR(B.const)}function AxF(B){return Fk(B)&&CJ(B.const)}function Fk(B){return B0(B,"Literal")&&OI(B.$id)&&tbQ(B.const)}function tbQ(B){return CJ(B)||PR(B)||IG(B)}function ebQ(B){return B0(B,"MappedKey")&&JW(B.keys)&&B.keys.every((Q)=>PR(Q)||IG(Q))}function BXQ(B){return B0(B,"MappedResult")&&si(B.properties)}function QXQ(B){return B0(B,"Never")&&mI(B.not)&&Object.getOwnPropertyNames(B.not).length===0}function FXQ(B){return B0(B,"Not")&&tg(B.not)}function UXQ(B){return B0(B,"Null")&&B.type==="null"&&OI(B.$id)}function IXQ(B){return B0(B,"Number")&&B.type==="number"&&OI(B.$id)&&GG(B.exclusiveMaximum)&&GG(B.exclusiveMinimum)&&GG(B.maximum)&&GG(B.minimum)&&GG(B.multipleOf)}function GXQ(B){return B0(B,"Object")&&B.type==="object"&&OI(B.$id)&&si(B.properties)&&dbQ(B.additionalProperties)&&GG(B.minProperties)&&GG(B.maxProperties)}function ZXQ(B){return B0(B,"Promise")&&B.type==="Promise"&&OI(B.$id)&&tg(B.item)}function WXQ(B){return B0(B,"Record")&&B.type==="object"&&OI(B.$id)&&dbQ(B.additionalProperties)&&mI(B.patternProperties)&&((Q)=>{let F=Object.getOwnPropertyNames(Q.patternProperties);return F.length===1&&kbQ(F[0])&&mI(Q.patternProperties)&&tg(Q.patternProperties[F[0]])})(B)}function YxF(B){return mI(B)&&cN in B&&B[cN]==="Recursive"}function gXQ(B){return B0(B,"Ref")&&OI(B.$id)&&IG(B.$ref)}function VXQ(B){return B0(B,"RegExp")&&OI(B.$id)&&IG(B.source)&&IG(B.flags)&&GG(B.maxLength)&&GG(B.minLength)}function bXQ(B){return B0(B,"String")&&B.type==="string"&&OI(B.$id)&&GG(B.minLength)&&GG(B.maxLength)&&bxF(B.pattern)&&XxF(B.format)}function XXQ(B){return B0(B,"Symbol")&&B.type==="symbol"&&OI(B.$id)}function CXQ(B){return B0(B,"TemplateLiteral")&&B.type==="string"&&IG(B.pattern)&&B.pattern[0]==="^"&&B.pattern[B.pattern.length-1]==="$"}function RXQ(B){return B0(B,"This")&&OI(B.$id)&&IG(B.$ref)}function NXQ(B){return mI(B)&&iW in B}function AXQ(B){return B0(B,"Tuple")&&B.type==="array"&&OI(B.$id)&&PR(B.minItems)&&PR(B.maxItems)&&B.minItems===B.maxItems&&(xW(B.items)&&xW(B.additionalItems)&&B.minItems===0||JW(B.items)&&B.items.every((Q)=>tg(Q)))}function YXQ(B){return B0(B,"Undefined")&&B.type==="undefined"&&OI(B.$id)}function LxF(B){return lRB(B)&&B.anyOf.every((Q)=>rbQ(Q)||sbQ(Q))}function lRB(B){return B0(B,"Union")&&OI(B.$id)&&mI(B)&&JW(B.anyOf)&&B.anyOf.every((Q)=>tg(Q))}function LXQ(B){return B0(B,"Uint8Array")&&B.type==="Uint8Array"&&OI(B.$id)&&GG(B.minByteLength)&&GG(B.maxByteLength)}function HXQ(B){return B0(B,"Unknown")&&OI(B.$id)}function JXQ(B){return B0(B,"Unsafe")}function xXQ(B){return B0(B,"Void")&&B.type==="void"&&OI(B.$id)}function EXQ(B){return mI(B)&&zQ in B&&IG(B[zQ])&&!VxF.includes(B[zQ])}function tg(B){return mI(B)&&(_bQ(B)||vbQ(B)||PbQ(B)||ubQ(B)||lbQ(B)||fbQ(B)||qbQ(B)||jbQ(B)||nbQ(B)||ibQ(B)||pbQ(B)||abQ(B)||obQ(B)||Fk(B)||ebQ(B)||BXQ(B)||QXQ(B)||FXQ(B)||UXQ(B)||IXQ(B)||GXQ(B)||ZXQ(B)||WXQ(B)||gXQ(B)||VXQ(B)||bXQ(B)||XXQ(B)||CXQ(B)||RXQ(B)||AXQ(B)||YXQ(B)||lRB(B)||LXQ(B)||HXQ(B)||JXQ(B)||xXQ(B)||EXQ(B))}var DXQ="(true|false)",ti="(0|[1-9][0-9]*)",zXQ="(.*)";var t9="^(0|[1-9][0-9]*)$",e9="^(.*)$",wXQ="^(?!.*)$";function SXQ(B,Q){return B.includes(Q)}function yXQ(B){return[...new Set(B)]}function HxF(B,Q){return B.filter((F)=>Q.includes(F))}function JxF(B,Q){return B.reduce((F,U)=>{return HxF(F,U)},Q)}function MXQ(B){return B.length===1?B[0]:B.length>1?JxF(B.slice(1),B[0]):[]}function TXQ(B){let Q=[];for(let F of B)Q.push(...F);return Q}function BE(B){return UQ({[zQ]:"Any"},B)}function ST(B,Q){return UQ({[zQ]:"Array",type:"array",items:B},Q)}function mXQ(B){return UQ({[zQ]:"Argument",index:B})}function yT(B,Q){return UQ({[zQ]:"AsyncIterator",type:"AsyncIterator",items:B},Q)}function mG(B,Q,F){return UQ({[zQ]:"Computed",target:B,parameters:Q},F)}function xxF(B,Q){let{[Q]:F,...U}=B;return U}function SZ(B,Q){return Q.reduce((F,U)=>xxF(F,U),B)}function M0(B){return UQ({[zQ]:"Never",not:{}},B)}function f0(B){return UQ({[zQ]:"MappedResult",properties:B})}function MT(B,Q,F){return UQ({[zQ]:"Constructor",type:"Constructor",parameters:B,returns:Q},F)}function eY(B,Q,F){return UQ({[zQ]:"Function",type:"Function",parameters:B,returns:Q},F)}function Uk(B,Q){return UQ({[zQ]:"Union",anyOf:B},Q)}function ExF(B){return B.some((Q)=>SC(Q))}function OXQ(B){return B.map((Q)=>SC(Q)?DxF(Q):Q)}function DxF(B){return SZ(B,[hV])}function zxF(B,Q){return ExF(B)?Sb(Uk(OXQ(B),Q)):Uk(OXQ(B),Q)}function BL(B,Q){return B.length===1?UQ(B[0],Q):B.length===0?M0(Q):zxF(B,Q)}function AI(B,Q){return B.length===0?M0(Q):B.length===1?UQ(B[0],Q):Uk(B,Q)}class uRB extends KV{}function wxF(B){return B.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function qRB(B,Q,F){return B[Q]===F&&B.charCodeAt(Q-1)!==92}function LJ(B,Q){return qRB(B,Q,"(")}function Ik(B,Q){return qRB(B,Q,")")}function cXQ(B,Q){return qRB(B,Q,"|")}function SxF(B){if(!(LJ(B,0)&&Ik(B,B.length-1)))return!1;let Q=0;for(let F=0;F<B.length;F++){if(LJ(B,F))Q+=1;if(Ik(B,F))Q-=1;if(Q===0&&F!==B.length-1)return!1}return!0}function yxF(B){return B.slice(1,B.length-1)}function MxF(B){let Q=0;for(let F=0;F<B.length;F++){if(LJ(B,F))Q+=1;if(Ik(B,F))Q-=1;if(cXQ(B,F)&&Q===0)return!0}return!1}function TxF(B){for(let Q=0;Q<B.length;Q++)if(LJ(B,Q))return!0;return!1}function mxF(B){let[Q,F]=[0,0],U=[];for(let G=0;G<B.length;G++){if(LJ(B,G))Q+=1;if(Ik(B,G))Q-=1;if(cXQ(B,G)&&Q===0){let Z=B.slice(F,G);if(Z.length>0)U.push(TT(Z));F=G+1}}let I=B.slice(F);if(I.length>0)U.push(TT(I));if(U.length===0)return{type:"const",const:""};if(U.length===1)return U[0];return{type:"or",expr:U}}function OxF(B){function Q(I,G){if(!LJ(I,G))throw new uRB("TemplateLiteralParser: Index must point to open parens");let Z=0;for(let W=G;W<I.length;W++){if(LJ(I,W))Z+=1;if(Ik(I,W))Z-=1;if(Z===0)return[G,W]}throw new uRB("TemplateLiteralParser: Unclosed group parens in expression")}function F(I,G){for(let Z=G;Z<I.length;Z++)if(LJ(I,Z))return[G,Z];return[G,I.length]}let U=[];for(let I=0;I<B.length;I++)if(LJ(B,I)){let[G,Z]=Q(B,I),W=B.slice(G,Z+1);U.push(TT(W)),I=Z}else{let[G,Z]=F(B,I),W=B.slice(G,Z);if(W.length>0)U.push(TT(W));I=Z-1}return U.length===0?{type:"const",const:""}:U.length===1?U[0]:{type:"and",expr:U}}function TT(B){return SxF(B)?TT(yxF(B)):MxF(B)?mxF(B):TxF(B)?OxF(B):{type:"const",const:wxF(B)}}function mT(B){return TT(B.slice(1,B.length-1))}class KXQ extends KV{}function cxF(B){return B.type==="or"&&B.expr.length===2&&B.expr[0].type==="const"&&B.expr[0].const==="0"&&B.expr[1].type==="const"&&B.expr[1].const==="[1-9][0-9]*"}function KxF(B){return B.type==="or"&&B.expr.length===2&&B.expr[0].type==="const"&&B.expr[0].const==="true"&&B.expr[1].type==="const"&&B.expr[1].const==="false"}function hxF(B){return B.type==="const"&&B.const===".*"}function vz(B){return cxF(B)||hxF(B)?!1:KxF(B)?!0:B.type==="and"?B.expr.every((Q)=>vz(Q)):B.type==="or"?B.expr.every((Q)=>vz(Q)):B.type==="const"?!0:(()=>{throw new KXQ("Unknown expression type")})()}function hXQ(B){let Q=mT(B.pattern);return vz(Q)}class kXQ extends KV{}function*dXQ(B){if(B.length===1)return yield*B[0];for(let Q of B[0])for(let F of dXQ(B.slice(1)))yield`${Q}${F}`}function*kxF(B){return yield*dXQ(B.expr.map((Q)=>[...Gk(Q)]))}function*dxF(B){for(let Q of B.expr)yield*Gk(Q)}function*$xF(B){return yield B.const}function*Gk(B){return B.type==="and"?yield*kxF(B):B.type==="or"?yield*dxF(B):B.type==="const"?yield*$xF(B):(()=>{throw new kXQ("Unknown expression")})()}function ei(B){let Q=mT(B.pattern);return vz(Q)?[...Gk(Q)]:[]}function GI(B,Q){return UQ({[zQ]:"Literal",const:B,type:typeof B},Q)}function Bp(B){return UQ({[zQ]:"Boolean",type:"boolean"},B)}function OT(B){return UQ({[zQ]:"BigInt",type:"bigint"},B)}function KN(B){return UQ({[zQ]:"Number",type:"number"},B)}function YA(B){return UQ({[zQ]:"String",type:"string"},B)}function*_xF(B){let Q=B.trim().replace(/"|'/g,"");return Q==="boolean"?yield Bp():Q==="number"?yield KN():Q==="bigint"?yield OT():Q==="string"?yield YA():yield(()=>{let F=Q.split("|").map((U)=>GI(U.trim()));return F.length===0?M0():F.length===1?F[0]:BL(F)})()}function*vxF(B){if(B[1]!=="{"){let Q=GI("$"),F=jRB(B.slice(1));return yield*[Q,...F]}for(let Q=2;Q<B.length;Q++)if(B[Q]==="}"){let F=_xF(B.slice(2,Q)),U=jRB(B.slice(Q+1));return yield*[...F,...U]}yield GI(B)}function*jRB(B){for(let Q=0;Q<B.length;Q++)if(B[Q]==="$"){let F=GI(B.slice(0,Q)),U=vxF(B.slice(Q));return yield*[F,...U]}yield GI(B)}function $XQ(B){return[...jRB(B)]}class _XQ extends KV{}function PxF(B){return B.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vXQ(B,Q){return uR(B)?B.pattern.slice(1,B.pattern.length-1):y0(B)?`(${B.anyOf.map((F)=>vXQ(F,Q)).join("|")})`:AA(B)?`${Q}${ti}`:NA(B)?`${Q}${ti}`:kz(B)?`${Q}${ti}`:AJ(B)?`${Q}${zXQ}`:fR(B)?`${Q}${PxF(B.const.toString())}`:NJ(B)?`${Q}${DXQ}`:(()=>{throw new _XQ(`Unexpected Kind '${B[zQ]}'`)})()}function nRB(B){return`^${B.map((Q)=>vXQ(Q,"")).join("")}$`}function Pz(B){let F=ei(B).map((U)=>GI(U));return BL(F)}function Qp(B,Q){let F=IG(B)?nRB($XQ(B)):nRB(B);return UQ({[zQ]:"TemplateLiteral",type:"string",pattern:F},Q)}function fxF(B){return ei(B).map((F)=>F.toString())}function lxF(B){let Q=[];for(let F of B)Q.push(...yC(F));return Q}function uxF(B){return[B.toString()]}function yC(B){return[...new Set(uR(B)?fxF(B):y0(B)?lxF(B.anyOf):fR(B)?uxF(B.const):AA(B)?["[number]"]:NA(B)?["[number]"]:[])]}function qxF(B,Q,F){let U={};for(let I of Object.getOwnPropertyNames(Q))U[I]=QE(B,yC(Q[I]),F);return U}function jxF(B,Q,F){return qxF(B,Q.properties,F)}function PXQ(B,Q,F){let U=jxF(B,Q,F);return f0(U)}function lXQ(B,Q){return B.map((F)=>uXQ(F,Q))}function nxF(B){return B.filter((Q)=>!r9(Q))}function ixF(B,Q){return Fp(nxF(lXQ(B,Q)))}function pxF(B){return B.some((Q)=>r9(Q))?[]:B}function axF(B,Q){return BL(pxF(lXQ(B,Q)))}function oxF(B,Q){return Q in B?B[Q]:Q==="[number]"?BL(B):M0()}function rxF(B,Q){return Q==="[number]"?B:M0()}function sxF(B,Q){return Q in B?B[Q]:M0()}function uXQ(B,Q){return wZ(B)?ixF(B.allOf,Q):y0(B)?axF(B.anyOf,Q):qR(B)?oxF(B.items??[],Q):bA(B)?rxF(B.items,Q):EW(B)?sxF(B.properties,Q):M0()}function iRB(B,Q){return Q.map((F)=>uXQ(B,F))}function fXQ(B,Q){return BL(iRB(B,Q))}function QE(B,Q,F){if(UW(B)||UW(Q)){if(!jR(B)||!jR(Q))throw new KV("Index types using Ref parameters require both Type and Key to be of TSchema");return mG("Index",[B,Q])}if(iG(Q))return PXQ(B,Q,F);if(lR(Q))return qXQ(B,Q,F);return UQ(jR(Q)?fXQ(B,yC(Q)):fXQ(B,Q),F)}function txF(B,Q,F){return{[Q]:QE(B,[Q],nG(F))}}function exF(B,Q,F){return Q.reduce((U,I)=>{return{...U,...txF(B,I,F)}},{})}function B9F(B,Q,F){return exF(B,Q.keys,F)}function qXQ(B,Q,F){let U=B9F(B,Q,F);return f0(U)}function cT(B,Q){return UQ({[zQ]:"Iterator",type:"Iterator",items:B},Q)}function Q9F(B){return globalThis.Object.keys(B).filter((Q)=>!SC(B[Q]))}function F9F(B,Q){let F=Q9F(B),U=F.length>0?{[zQ]:"Object",type:"object",required:F,properties:B}:{[zQ]:"Object",type:"object",properties:B};return UQ(U,Q)}var cI=F9F;function Up(B,Q){return UQ({[zQ]:"Promise",type:"Promise",item:B},Q)}function U9F(B){return UQ(SZ(B,[VA]))}function I9F(B){return UQ({...B,[VA]:"Readonly"})}function G9F(B,Q){return Q===!1?U9F(B):I9F(B)}function MC(B,Q){let F=Q??!0;return iG(B)?jXQ(B,F):G9F(B,F)}function Z9F(B,Q){let F={};for(let U of globalThis.Object.getOwnPropertyNames(B))F[U]=MC(B[U],Q);return F}function W9F(B,Q){return Z9F(B.properties,Q)}function jXQ(B,Q){let F=W9F(B,Q);return f0(F)}function hN(B,Q){return UQ(B.length>0?{[zQ]:"Tuple",type:"array",items:B,additionalItems:!1,minItems:B.length,maxItems:B.length}:{[zQ]:"Tuple",type:"array",minItems:B.length,maxItems:B.length},Q)}function nXQ(B,Q){return B in Q?kN(B,Q[B]):f0(Q)}function g9F(B){return{[B]:GI(B)}}function V9F(B){let Q={};for(let F of B)Q[F]=GI(F);return Q}function b9F(B,Q){return SXQ(Q,B)?g9F(B):V9F(Q)}function X9F(B,Q){let F=b9F(B,Q);return nXQ(B,F)}function Zk(B,Q){return Q.map((F)=>kN(B,F))}function C9F(B,Q){let F={};for(let U of globalThis.Object.getOwnPropertyNames(Q))F[U]=kN(B,Q[U]);return F}function kN(B,Q){let F={...Q};return SC(Q)?Sb(kN(B,SZ(Q,[hV]))):wT(Q)?MC(kN(B,SZ(Q,[VA]))):iG(Q)?nXQ(B,Q.properties):lR(Q)?X9F(B,Q.keys):CA(Q)?MT(Zk(B,Q.parameters),kN(B,Q.returns),F):RA(Q)?eY(Zk(B,Q.parameters),kN(B,Q.returns),F):hz(Q)?yT(kN(B,Q.items),F):dz(Q)?cT(kN(B,Q.items),F):wZ(Q)?yb(Zk(B,Q.allOf),F):y0(Q)?AI(Zk(B,Q.anyOf),F):qR(Q)?hN(Zk(B,Q.items??[]),F):EW(Q)?cI(C9F(B,Q.properties),F):bA(Q)?ST(kN(B,Q.items),F):$z(Q)?Up(kN(B,Q.item),F):Q}function R9F(B,Q){let F={};for(let U of B)F[U]=kN(U,Q);return F}function iXQ(B,Q,F){let U=jR(B)?yC(B):B,I=Q({[zQ]:"MappedKey",keys:U}),G=R9F(U,I);return cI(G,F)}function N9F(B){return UQ(SZ(B,[hV]))}function A9F(B){return UQ({...B,[hV]:"Optional"})}function Y9F(B,Q){return Q===!1?N9F(B):A9F(B)}function Sb(B,Q){let F=Q??!0;return iG(B)?pXQ(B,F):Y9F(B,F)}function L9F(B,Q){let F={};for(let U of globalThis.Object.getOwnPropertyNames(B))F[U]=Sb(B[U],Q);return F}function H9F(B,Q){return L9F(B.properties,Q)}function pXQ(B,Q){let F=H9F(B,Q);return f0(F)}function Wk(B,Q={}){let F=B.every((I)=>EW(I)),U=jR(Q.unevaluatedProperties)?{unevaluatedProperties:Q.unevaluatedProperties}:{};return UQ(Q.unevaluatedProperties===!1||jR(Q.unevaluatedProperties)||F?{...U,[zQ]:"Intersect",type:"object",allOf:B}:{...U,[zQ]:"Intersect",allOf:B},Q)}function J9F(B){return B.every((Q)=>SC(Q))}function x9F(B){return SZ(B,[hV])}function aXQ(B){return B.map((Q)=>SC(Q)?x9F(Q):Q)}function E9F(B,Q){return J9F(B)?Sb(Wk(aXQ(B),Q)):Wk(aXQ(B),Q)}function Fp(B,Q={}){if(B.length===1)return UQ(B[0],Q);if(B.length===0)return M0(Q);if(B.some((F)=>s9(F)))throw Error("Cannot intersect transform types");return E9F(B,Q)}function yb(B,Q){if(B.length===1)return UQ(B[0],Q);if(B.length===0)return M0(Q);if(B.some((F)=>s9(F)))throw Error("Cannot intersect transform types");return Wk(B,Q)}function QL(...B){let[Q,F]=typeof B[0]==="string"?[B[0],B[1]]:[B[0].$id,B[1]];if(typeof Q!=="string")throw new KV("Ref: $ref must be a string");return UQ({[zQ]:"Ref",$ref:Q},F)}function D9F(B,Q){return mG("Awaited",[mG(B,Q)])}function z9F(B){return mG("Awaited",[QL(B)])}function w9F(B){return yb(oXQ(B))}function S9F(B){return AI(oXQ(B))}function y9F(B){return KT(B)}function oXQ(B){return B.map((Q)=>KT(Q))}function KT(B,Q){return UQ(XA(B)?D9F(B.target,B.parameters):wZ(B)?w9F(B.allOf):y0(B)?S9F(B.anyOf):$z(B)?y9F(B.item):UW(B)?z9F(B.$ref):B,Q)}function rXQ(B){let Q=[];for(let F of B)Q.push(gk(F));return Q}function M9F(B){let Q=rXQ(B);return TXQ(Q)}function T9F(B){let Q=rXQ(B);return MXQ(Q)}function m9F(B){return B.map((Q,F)=>F.toString())}function O9F(B){return["[number]"]}function c9F(B){return globalThis.Object.getOwnPropertyNames(B)}function K9F(B){if(!h9F)return[];return globalThis.Object.getOwnPropertyNames(B).map((F)=>{return F[0]==="^"&&F[F.length-1]==="$"?F.slice(1,F.length-1):F})}function gk(B){return wZ(B)?M9F(B.allOf):y0(B)?T9F(B.anyOf):qR(B)?m9F(B.items??[]):bA(B)?O9F(B.items):EW(B)?c9F(B.properties):_z(B)?K9F(B.patternProperties):[]}var h9F=!1;function k9F(B,Q){return mG("KeyOf",[mG(B,Q)])}function d9F(B){return mG("KeyOf",[QL(B)])}function $9F(B,Q){let F=gk(B),U=_9F(F),I=BL(U);return UQ(I,Q)}function _9F(B){return B.map((Q)=>Q==="[number]"?KN():GI(Q))}function hT(B,Q){return XA(B)?k9F(B.target,B.parameters):UW(B)?d9F(B.$ref):iG(B)?sXQ(B,Q):$9F(B,Q)}function v9F(B,Q){let F={};for(let U of globalThis.Object.getOwnPropertyNames(B))F[U]=hT(B[U],nG(Q));return F}function P9F(B,Q){return v9F(B.properties,Q)}function sXQ(B,Q){let F=P9F(B,Q);return f0(F)}function f9F(B){let Q=[];for(let F of B)Q.push(...gk(F));return yXQ(Q)}function l9F(B){return B.filter((Q)=>!r9(Q))}function u9F(B,Q){let F=[];for(let U of B)F.push(...iRB(U,[Q]));return l9F(F)}function q9F(B,Q){let F={};for(let U of Q)F[U]=Fp(u9F(B,U));return F}function tXQ(B,Q){let F=f9F(B),U=q9F(B,F);return cI(U,Q)}function Ip(B){return UQ({[zQ]:"Date",type:"Date"},B)}function Gp(B){return UQ({[zQ]:"Null",type:"null"},B)}function Zp(B){return UQ({[zQ]:"Symbol",type:"symbol"},B)}function Wp(B){return UQ({[zQ]:"Undefined",type:"undefined"},B)}function gp(B){return UQ({[zQ]:"Uint8Array",type:"Uint8Array"},B)}function FE(B){return UQ({[zQ]:"Unknown"},B)}function j9F(B){return B.map((Q)=>pRB(Q,!1))}function n9F(B){let Q={};for(let F of globalThis.Object.getOwnPropertyNames(B))Q[F]=MC(pRB(B[F],!1));return Q}function Vp(B,Q){return Q===!0?B:MC(B)}function pRB(B,Q){return cRB(B)?Vp(BE(),Q):hRB(B)?Vp(BE(),Q):JW(B)?MC(hN(j9F(B))):RJ(B)?gp():Kz(B)?Ip():mI(B)?Vp(cI(n9F(B)),Q):KRB(B)?Vp(eY([],FE()),Q):xW(B)?Wp():kRB(B)?Gp():dRB(B)?Zp():oh(B)?OT():PR(B)?GI(B):CJ(B)?GI(B):IG(B)?GI(B):cI({})}function eXQ(B,Q){return UQ(pRB(B,!0),Q)}function BCQ(B,Q){return CA(B)?hN(B.parameters,Q):M0(Q)}function QCQ(B,Q){if(xW(B))throw Error("Enum undefined or empty");let F=globalThis.Object.getOwnPropertyNames(B).filter((G)=>isNaN(G)).map((G)=>B[G]),I=[...new Set(F)].map((G)=>GI(G));return AI(I,{...Q,[cN]:"Enum"})}class ZCQ extends KV{}var IQ;(function(B){B[B.Union=0]="Union",B[B.True=1]="True",B[B.False=2]="False"})(IQ||(IQ={}));function dN(B){return B===IQ.False?B:IQ.True}function kT(B){throw new ZCQ(B)}function pW(B){return SB.IsNever(B)||SB.IsIntersect(B)||SB.IsUnion(B)||SB.IsUnknown(B)||SB.IsAny(B)}function aW(B,Q){return SB.IsNever(Q)?VCQ(B,Q):SB.IsIntersect(Q)?bp(B,Q):SB.IsUnion(Q)?tRB(B,Q):SB.IsUnknown(Q)?RCQ(B,Q):SB.IsAny(Q)?sRB(B,Q):kT("StructuralRight")}function sRB(B,Q){return IQ.True}function i9F(B,Q){return SB.IsIntersect(Q)?bp(B,Q):SB.IsUnion(Q)&&Q.anyOf.some((F)=>SB.IsAny(F)||SB.IsUnknown(F))?IQ.True:SB.IsUnion(Q)?IQ.Union:SB.IsUnknown(Q)?IQ.True:SB.IsAny(Q)?IQ.True:IQ.Union}function p9F(B,Q){return SB.IsUnknown(B)?IQ.False:SB.IsAny(B)?IQ.Union:SB.IsNever(B)?IQ.True:IQ.False}function a9F(B,Q){return SB.IsObject(Q)&&Xp(Q)?IQ.True:pW(Q)?aW(B,Q):!SB.IsArray(Q)?IQ.False:dN(KI(B.items,Q.items))}function o9F(B,Q){return pW(Q)?aW(B,Q):!SB.IsAsyncIterator(Q)?IQ.False:dN(KI(B.items,Q.items))}function r9F(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsBigInt(Q)?IQ.True:IQ.False}function WCQ(B,Q){return SB.IsLiteralBoolean(B)?IQ.True:SB.IsBoolean(B)?IQ.True:IQ.False}function s9F(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsBoolean(Q)?IQ.True:IQ.False}function t9F(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):!SB.IsConstructor(Q)?IQ.False:B.parameters.length>Q.parameters.length?IQ.False:!B.parameters.every((F,U)=>dN(KI(Q.parameters[U],F))===IQ.True)?IQ.False:dN(KI(B.returns,Q.returns))}function e9F(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsDate(Q)?IQ.True:IQ.False}function BEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):!SB.IsFunction(Q)?IQ.False:B.parameters.length>Q.parameters.length?IQ.False:!B.parameters.every((F,U)=>dN(KI(Q.parameters[U],F))===IQ.True)?IQ.False:dN(KI(B.returns,Q.returns))}function gCQ(B,Q){return SB.IsLiteral(B)&&wb.IsNumber(B.const)?IQ.True:SB.IsNumber(B)||SB.IsInteger(B)?IQ.True:IQ.False}function QEF(B,Q){return SB.IsInteger(Q)||SB.IsNumber(Q)?IQ.True:pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):IQ.False}function bp(B,Q){return Q.allOf.every((F)=>KI(B,F)===IQ.True)?IQ.True:IQ.False}function FEF(B,Q){return B.allOf.some((F)=>KI(F,Q)===IQ.True)?IQ.True:IQ.False}function UEF(B,Q){return pW(Q)?aW(B,Q):!SB.IsIterator(Q)?IQ.False:dN(KI(B.items,Q.items))}function IEF(B,Q){return SB.IsLiteral(Q)&&Q.const===B.const?IQ.True:pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsString(Q)?CCQ(B,Q):SB.IsNumber(Q)?bCQ(B,Q):SB.IsInteger(Q)?gCQ(B,Q):SB.IsBoolean(Q)?WCQ(B,Q):IQ.False}function VCQ(B,Q){return IQ.False}function GEF(B,Q){return IQ.True}function FCQ(B){let[Q,F]=[B,0];while(!0){if(!SB.IsNot(Q))break;Q=Q.not,F+=1}return F%2===0?Q:FE()}function ZEF(B,Q){return SB.IsNot(B)?KI(FCQ(B),Q):SB.IsNot(Q)?KI(B,FCQ(Q)):kT("Invalid fallthrough for Not")}function WEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsNull(Q)?IQ.True:IQ.False}function bCQ(B,Q){return SB.IsLiteralNumber(B)?IQ.True:SB.IsNumber(B)||SB.IsInteger(B)?IQ.True:IQ.False}function gEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsInteger(Q)||SB.IsNumber(Q)?IQ.True:IQ.False}function TC(B,Q){return Object.getOwnPropertyNames(B.properties).length===Q}function UCQ(B){return Xp(B)}function ICQ(B){return TC(B,0)||TC(B,1)&&"description"in B.properties&&SB.IsUnion(B.properties.description)&&B.properties.description.anyOf.length===2&&(SB.IsString(B.properties.description.anyOf[0])&&SB.IsUndefined(B.properties.description.anyOf[1])||SB.IsString(B.properties.description.anyOf[1])&&SB.IsUndefined(B.properties.description.anyOf[0]))}function aRB(B){return TC(B,0)}function GCQ(B){return TC(B,0)}function VEF(B){return TC(B,0)}function bEF(B){return TC(B,0)}function XEF(B){return Xp(B)}function CEF(B){let Q=KN();return TC(B,0)||TC(B,1)&&"length"in B.properties&&dN(KI(B.properties.length,Q))===IQ.True}function REF(B){return TC(B,0)}function Xp(B){let Q=KN();return TC(B,0)||TC(B,1)&&"length"in B.properties&&dN(KI(B.properties.length,Q))===IQ.True}function NEF(B){let Q=eY([BE()],BE());return TC(B,0)||TC(B,1)&&"then"in B.properties&&dN(KI(B.properties.then,Q))===IQ.True}function XCQ(B,Q){return KI(B,Q)===IQ.False?IQ.False:SB.IsOptional(B)&&!SB.IsOptional(Q)?IQ.False:IQ.True}function Mb(B,Q){return SB.IsUnknown(B)?IQ.False:SB.IsAny(B)?IQ.Union:SB.IsNever(B)||SB.IsLiteralString(B)&&UCQ(Q)||SB.IsLiteralNumber(B)&&aRB(Q)||SB.IsLiteralBoolean(B)&&GCQ(Q)||SB.IsSymbol(B)&&ICQ(Q)||SB.IsBigInt(B)&&VEF(Q)||SB.IsString(B)&&UCQ(Q)||SB.IsSymbol(B)&&ICQ(Q)||SB.IsNumber(B)&&aRB(Q)||SB.IsInteger(B)&&aRB(Q)||SB.IsBoolean(B)&&GCQ(Q)||SB.IsUint8Array(B)&&XEF(Q)||SB.IsDate(B)&&bEF(Q)||SB.IsConstructor(B)&&REF(Q)||SB.IsFunction(B)&&CEF(Q)?IQ.True:SB.IsRecord(B)&&SB.IsString(oRB(B))?(()=>{return Q[cN]==="Record"?IQ.True:IQ.False})():SB.IsRecord(B)&&SB.IsNumber(oRB(B))?(()=>{return TC(Q,0)?IQ.True:IQ.False})():IQ.False}function AEF(B,Q){return pW(Q)?aW(B,Q):SB.IsRecord(Q)?$N(B,Q):!SB.IsObject(Q)?IQ.False:(()=>{for(let F of Object.getOwnPropertyNames(Q.properties)){if(!(F in B.properties)&&!SB.IsOptional(Q.properties[F]))return IQ.False;if(SB.IsOptional(Q.properties[F]))return IQ.True;if(XCQ(B.properties[F],Q.properties[F])===IQ.False)return IQ.False}return IQ.True})()}function YEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)&&NEF(Q)?IQ.True:!SB.IsPromise(Q)?IQ.False:dN(KI(B.item,Q.item))}function oRB(B){return t9 in B.patternProperties?KN():(e9 in B.patternProperties)?YA():kT("Unknown record key pattern")}function rRB(B){return t9 in B.patternProperties?B.patternProperties[t9]:(e9 in B.patternProperties)?B.patternProperties[e9]:kT("Unable to get record value schema")}function $N(B,Q){let[F,U]=[oRB(Q),rRB(Q)];return SB.IsLiteralString(B)&&SB.IsNumber(F)&&dN(KI(B,U))===IQ.True?IQ.True:SB.IsUint8Array(B)&&SB.IsNumber(F)?KI(B,U):SB.IsString(B)&&SB.IsNumber(F)?KI(B,U):SB.IsArray(B)&&SB.IsNumber(F)?KI(B,U):SB.IsObject(B)?(()=>{for(let I of Object.getOwnPropertyNames(B.properties))if(XCQ(U,B.properties[I])===IQ.False)return IQ.False;return IQ.True})():IQ.False}function LEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):!SB.IsRecord(Q)?IQ.False:KI(rRB(B),rRB(Q))}function HEF(B,Q){let F=SB.IsRegExp(B)?YA():B,U=SB.IsRegExp(Q)?YA():Q;return KI(F,U)}function CCQ(B,Q){return SB.IsLiteral(B)&&wb.IsString(B.const)?IQ.True:SB.IsString(B)?IQ.True:IQ.False}function JEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsString(Q)?IQ.True:IQ.False}function xEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsSymbol(Q)?IQ.True:IQ.False}function EEF(B,Q){return SB.IsTemplateLiteral(B)?KI(Pz(B),Q):SB.IsTemplateLiteral(Q)?KI(B,Pz(Q)):kT("Invalid fallthrough for TemplateLiteral")}function DEF(B,Q){return SB.IsArray(Q)&&B.items!==void 0&&B.items.every((F)=>KI(F,Q.items)===IQ.True)}function zEF(B,Q){return SB.IsNever(B)?IQ.True:SB.IsUnknown(B)?IQ.False:SB.IsAny(B)?IQ.Union:IQ.False}function wEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)&&Xp(Q)?IQ.True:SB.IsArray(Q)&&DEF(B,Q)?IQ.True:!SB.IsTuple(Q)?IQ.False:wb.IsUndefined(B.items)&&!wb.IsUndefined(Q.items)||!wb.IsUndefined(B.items)&&wb.IsUndefined(Q.items)?IQ.False:wb.IsUndefined(B.items)&&!wb.IsUndefined(Q.items)?IQ.True:B.items.every((F,U)=>KI(F,Q.items[U])===IQ.True)?IQ.True:IQ.False}function SEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsUint8Array(Q)?IQ.True:IQ.False}function yEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsVoid(Q)?mEF(B,Q):SB.IsUndefined(Q)?IQ.True:IQ.False}function tRB(B,Q){return Q.anyOf.some((F)=>KI(B,F)===IQ.True)?IQ.True:IQ.False}function MEF(B,Q){return B.anyOf.every((F)=>KI(F,Q)===IQ.True)?IQ.True:IQ.False}function RCQ(B,Q){return IQ.True}function TEF(B,Q){return SB.IsNever(Q)?VCQ(B,Q):SB.IsIntersect(Q)?bp(B,Q):SB.IsUnion(Q)?tRB(B,Q):SB.IsAny(Q)?sRB(B,Q):SB.IsString(Q)?CCQ(B,Q):SB.IsNumber(Q)?bCQ(B,Q):SB.IsInteger(Q)?gCQ(B,Q):SB.IsBoolean(Q)?WCQ(B,Q):SB.IsArray(Q)?p9F(B,Q):SB.IsTuple(Q)?zEF(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsUnknown(Q)?IQ.True:IQ.False}function mEF(B,Q){return SB.IsUndefined(B)?IQ.True:SB.IsUndefined(B)?IQ.True:IQ.False}function OEF(B,Q){return SB.IsIntersect(Q)?bp(B,Q):SB.IsUnion(Q)?tRB(B,Q):SB.IsUnknown(Q)?RCQ(B,Q):SB.IsAny(Q)?sRB(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsVoid(Q)?IQ.True:IQ.False}function KI(B,Q){return SB.IsTemplateLiteral(B)||SB.IsTemplateLiteral(Q)?EEF(B,Q):SB.IsRegExp(B)||SB.IsRegExp(Q)?HEF(B,Q):SB.IsNot(B)||SB.IsNot(Q)?ZEF(B,Q):SB.IsAny(B)?i9F(B,Q):SB.IsArray(B)?a9F(B,Q):SB.IsBigInt(B)?r9F(B,Q):SB.IsBoolean(B)?s9F(B,Q):SB.IsAsyncIterator(B)?o9F(B,Q):SB.IsConstructor(B)?t9F(B,Q):SB.IsDate(B)?e9F(B,Q):SB.IsFunction(B)?BEF(B,Q):SB.IsInteger(B)?QEF(B,Q):SB.IsIntersect(B)?FEF(B,Q):SB.IsIterator(B)?UEF(B,Q):SB.IsLiteral(B)?IEF(B,Q):SB.IsNever(B)?GEF(B,Q):SB.IsNull(B)?WEF(B,Q):SB.IsNumber(B)?gEF(B,Q):SB.IsObject(B)?AEF(B,Q):SB.IsRecord(B)?LEF(B,Q):SB.IsString(B)?JEF(B,Q):SB.IsSymbol(B)?xEF(B,Q):SB.IsTuple(B)?wEF(B,Q):SB.IsPromise(B)?YEF(B,Q):SB.IsUint8Array(B)?SEF(B,Q):SB.IsUndefined(B)?yEF(B,Q):SB.IsUnion(B)?MEF(B,Q):SB.IsUnknown(B)?TEF(B,Q):SB.IsVoid(B)?OEF(B,Q):kT(`Unknown left type operand '${B[zQ]}'`)}function UE(B,Q){return KI(B,Q)}function cEF(B,Q,F,U,I){let G={};for(let Z of globalThis.Object.getOwnPropertyNames(B))G[Z]=dT(B[Z],Q,F,U,nG(I));return G}function KEF(B,Q,F,U,I){return cEF(B.properties,Q,F,U,I)}function NCQ(B,Q,F,U,I){let G=KEF(B,Q,F,U,I);return f0(G)}function hEF(B,Q,F,U){let I=UE(B,Q);return I===IQ.Union?AI([F,U]):I===IQ.True?F:U}function dT(B,Q,F,U,I){return iG(B)?NCQ(B,Q,F,U,I):lR(B)?UQ(ACQ(B,Q,F,U,I)):UQ(hEF(B,Q,F,U),I)}function kEF(B,Q,F,U,I){return{[B]:dT(GI(B),Q,F,U,nG(I))}}function dEF(B,Q,F,U,I){return B.reduce((G,Z)=>{return{...G,...kEF(Z,Q,F,U,I)}},{})}function $EF(B,Q,F,U,I){return dEF(B.keys,Q,F,U,I)}function ACQ(B,Q,F,U,I){let G=$EF(B,Q,F,U,I);return f0(G)}function YCQ(B,Q){return $T(Pz(B),Q)}function _EF(B,Q){let F=B.filter((U)=>UE(U,Q)===IQ.False);return F.length===1?F[0]:AI(F)}function $T(B,Q,F={}){if(uR(B))return UQ(YCQ(B,Q),F);if(iG(B))return UQ(LCQ(B,Q),F);return UQ(y0(B)?_EF(B.anyOf,Q):UE(B,Q)!==IQ.False?M0():B,F)}function vEF(B,Q){let F={};for(let U of globalThis.Object.getOwnPropertyNames(B))F[U]=$T(B[U],Q);return F}function PEF(B,Q){return vEF(B.properties,Q)}function LCQ(B,Q){let F=PEF(B,Q);return f0(F)}function HCQ(B,Q){return _T(Pz(B),Q)}function fEF(B,Q){let F=B.filter((U)=>UE(U,Q)!==IQ.False);return F.length===1?F[0]:AI(F)}function _T(B,Q,F){if(uR(B))return UQ(HCQ(B,Q),F);if(iG(B))return UQ(JCQ(B,Q),F);return UQ(y0(B)?fEF(B.anyOf,Q):UE(B,Q)!==IQ.False?B:M0(),F)}function lEF(B,Q){let F={};for(let U of globalThis.Object.getOwnPropertyNames(B))F[U]=_T(B[U],Q);return F}function uEF(B,Q){return lEF(B.properties,Q)}function JCQ(B,Q){let F=uEF(B,Q);return f0(F)}function xCQ(B,Q){return CA(B)?UQ(B.returns,Q):M0(Q)}function Cp(B){return MC(Sb(B))}function fz(B,Q,F){return UQ({[zQ]:"Record",type:"object",patternProperties:{[B]:Q}},F)}function eRB(B,Q,F){let U={};for(let I of B)U[I]=Q;return cI(U,{...F,[cN]:"Record"})}function qEF(B,Q,F){return hXQ(B)?eRB(yC(B),Q,F):fz(B.pattern,Q,F)}function jEF(B,Q,F){return eRB(yC(AI(B)),Q,F)}function nEF(B,Q,F){return eRB([B.toString()],Q,F)}function iEF(B,Q,F){return fz(B.source,Q,F)}function pEF(B,Q,F){let U=xW(B.pattern)?e9:B.pattern;return fz(U,Q,F)}function aEF(B,Q,F){return fz(e9,Q,F)}function oEF(B,Q,F){return fz(wXQ,Q,F)}function rEF(B,Q,F){return cI({true:Q,false:Q},F)}function sEF(B,Q,F){return fz(t9,Q,F)}function tEF(B,Q,F){return fz(t9,Q,F)}function Rp(B,Q,F={}){return y0(B)?jEF(B.anyOf,Q,F):uR(B)?qEF(B,Q,F):fR(B)?nEF(B.const,Q,F):NJ(B)?rEF(B,Q,F):NA(B)?sEF(B,Q,F):AA(B)?tEF(B,Q,F):vRB(B)?iEF(B,Q,F):AJ(B)?pEF(B,Q,F):$RB(B)?aEF(B,Q,F):r9(B)?oEF(B,Q,F):M0(F)}function Np(B){return globalThis.Object.getOwnPropertyNames(B.patternProperties)[0]}function ECQ(B){let Q=Np(B);return Q===e9?YA():Q===t9?KN():YA({pattern:Q})}function Ap(B){return B.patternProperties[Np(B)]}function eEF(B,Q){return Q.parameters=Vk(B,Q.parameters),Q.returns=LA(B,Q.returns),Q}function BDF(B,Q){return Q.parameters=Vk(B,Q.parameters),Q.returns=LA(B,Q.returns),Q}function QDF(B,Q){return Q.allOf=Vk(B,Q.allOf),Q}function FDF(B,Q){return Q.anyOf=Vk(B,Q.anyOf),Q}function UDF(B,Q){if(xW(Q.items))return Q;return Q.items=Vk(B,Q.items),Q}function IDF(B,Q){return Q.items=LA(B,Q.items),Q}function GDF(B,Q){return Q.items=LA(B,Q.items),Q}function ZDF(B,Q){return Q.items=LA(B,Q.items),Q}function WDF(B,Q){return Q.item=LA(B,Q.item),Q}function gDF(B,Q){let F=CDF(B,Q.properties);return{...Q,...cI(F)}}function VDF(B,Q){let F=LA(B,ECQ(Q)),U=LA(B,Ap(Q)),I=Rp(F,U);return{...Q,...I}}function bDF(B,Q){return Q.index in B?B[Q.index]:FE()}function XDF(B,Q){let F=wT(Q),U=SC(Q),I=LA(B,Q);return F&&U?Cp(I):F&&!U?MC(I):!F&&U?Sb(I):I}function CDF(B,Q){return globalThis.Object.getOwnPropertyNames(Q).reduce((F,U)=>{return{...F,[U]:XDF(B,Q[U])}},{})}function Vk(B,Q){return Q.map((F)=>LA(B,F))}function LA(B,Q){return CA(Q)?eEF(B,Q):RA(Q)?BDF(B,Q):wZ(Q)?QDF(B,Q):y0(Q)?FDF(B,Q):qR(Q)?UDF(B,Q):bA(Q)?IDF(B,Q):hz(Q)?GDF(B,Q):dz(Q)?ZDF(B,Q):$z(Q)?WDF(B,Q):EW(Q)?gDF(B,Q):_z(Q)?VDF(B,Q):_RB(Q)?bDF(B,Q):Q}function DCQ(B,Q){return LA(Q,zT(B))}function zCQ(B){return UQ({[zQ]:"Integer",type:"integer"},B)}function RDF(B,Q,F){return{[B]:HA(GI(B),Q,nG(F))}}function NDF(B,Q,F){return B.reduce((I,G)=>{return{...I,...RDF(G,Q,F)}},{})}function ADF(B,Q,F){return NDF(B.keys,Q,F)}function wCQ(B,Q,F){let U=ADF(B,Q,F);return f0(U)}function YDF(B){let[Q,F]=[B.slice(0,1),B.slice(1)];return[Q.toLowerCase(),F].join("")}function LDF(B){let[Q,F]=[B.slice(0,1),B.slice(1)];return[Q.toUpperCase(),F].join("")}function HDF(B){return B.toUpperCase()}function JDF(B){return B.toLowerCase()}function xDF(B,Q,F){let U=mT(B.pattern);if(!vz(U))return{...B,pattern:SCQ(B.pattern,Q)};let Z=[...Gk(U)].map((V)=>GI(V)),W=yCQ(Z,Q),g=AI(W);return Qp([g],F)}function SCQ(B,Q){return typeof B==="string"?Q==="Uncapitalize"?YDF(B):Q==="Capitalize"?LDF(B):Q==="Uppercase"?HDF(B):Q==="Lowercase"?JDF(B):B:B.toString()}function yCQ(B,Q){return B.map((F)=>HA(F,Q))}function HA(B,Q,F={}){return lR(B)?wCQ(B,Q,F):uR(B)?xDF(B,Q,F):y0(B)?AI(yCQ(B.anyOf,Q),F):fR(B)?GI(SCQ(B.const,Q),F):UQ(B,F)}function MCQ(B,Q={}){return HA(B,"Capitalize",Q)}function TCQ(B,Q={}){return HA(B,"Lowercase",Q)}function mCQ(B,Q={}){return HA(B,"Uncapitalize",Q)}function OCQ(B,Q={}){return HA(B,"Uppercase",Q)}function EDF(B,Q,F){let U={};for(let I of globalThis.Object.getOwnPropertyNames(B))U[I]=IE(B[I],Q,nG(F));return U}function DDF(B,Q,F){return EDF(B.properties,Q,F)}function cCQ(B,Q,F){let U=DDF(B,Q,F);return f0(U)}function zDF(B,Q){return B.map((F)=>B2B(F,Q))}function wDF(B,Q){return B.map((F)=>B2B(F,Q))}function SDF(B,Q){let{[Q]:F,...U}=B;return U}function yDF(B,Q){return Q.reduce((F,U)=>SDF(F,U),B)}function MDF(B,Q,F){let U=SZ(B,[iW,"$id","required","properties"]),I=yDF(F,Q);return cI(I,U)}function TDF(B){let Q=B.reduce((F,U)=>ri(U)?[...F,GI(U)]:F,[]);return AI(Q)}function B2B(B,Q){return wZ(B)?yb(zDF(B.allOf,Q)):y0(B)?AI(wDF(B.anyOf,Q)):EW(B)?MDF(B,Q,B.properties):cI({})}function IE(B,Q,F){let U=JW(Q)?TDF(Q):Q,I=jR(Q)?yC(Q):Q,G=UW(B),Z=UW(Q);return iG(B)?cCQ(B,I,F):lR(Q)?KCQ(B,Q,F):G&&Z?mG("Omit",[B,U],F):!G&&Z?mG("Omit",[B,U],F):G&&!Z?mG("Omit",[B,U],F):UQ({...B2B(B,I),...F})}function mDF(B,Q,F){return{[Q]:IE(B,[Q],nG(F))}}function ODF(B,Q,F){return Q.reduce((U,I)=>{return{...U,...mDF(B,I,F)}},{})}function cDF(B,Q,F){return ODF(B,Q.keys,F)}function KCQ(B,Q,F){let U=cDF(B,Q,F);return f0(U)}function KDF(B,Q,F){let U={};for(let I of globalThis.Object.getOwnPropertyNames(B))U[I]=GE(B[I],Q,nG(F));return U}function hDF(B,Q,F){return KDF(B.properties,Q,F)}function hCQ(B,Q,F){let U=hDF(B,Q,F);return f0(U)}function kDF(B,Q){return B.map((F)=>Q2B(F,Q))}function dDF(B,Q){return B.map((F)=>Q2B(F,Q))}function $DF(B,Q){let F={};for(let U of Q)if(U in B)F[U]=B[U];return F}function _DF(B,Q,F){let U=SZ(B,[iW,"$id","required","properties"]),I=$DF(F,Q);return cI(I,U)}function vDF(B){let Q=B.reduce((F,U)=>ri(U)?[...F,GI(U)]:F,[]);return AI(Q)}function Q2B(B,Q){return wZ(B)?yb(kDF(B.allOf,Q)):y0(B)?AI(dDF(B.anyOf,Q)):EW(B)?_DF(B,Q,B.properties):cI({})}function GE(B,Q,F){let U=JW(Q)?vDF(Q):Q,I=jR(Q)?yC(Q):Q,G=UW(B),Z=UW(Q);return iG(B)?hCQ(B,I,F):lR(Q)?kCQ(B,Q,F):G&&Z?mG("Pick",[B,U],F):!G&&Z?mG("Pick",[B,U],F):G&&!Z?mG("Pick",[B,U],F):UQ({...Q2B(B,I),...F})}function PDF(B,Q,F){return{[Q]:GE(B,[Q],nG(F))}}function fDF(B,Q,F){return Q.reduce((U,I)=>{return{...U,...PDF(B,I,F)}},{})}function lDF(B,Q,F){return fDF(B,Q.keys,F)}function kCQ(B,Q,F){let U=lDF(B,Q,F);return f0(U)}function uDF(B,Q){return mG("Partial",[mG(B,Q)])}function qDF(B){return mG("Partial",[QL(B)])}function jDF(B){let Q={};for(let F of globalThis.Object.getOwnPropertyNames(B))Q[F]=Sb(B[F]);return Q}function nDF(B,Q){let F=SZ(B,[iW,"$id","required","properties"]),U=jDF(Q);return cI(U,F)}function dCQ(B){return B.map((Q)=>$CQ(Q))}function $CQ(B){return XA(B)?uDF(B.target,B.parameters):UW(B)?qDF(B.$ref):wZ(B)?yb(dCQ(B.allOf)):y0(B)?AI(dCQ(B.anyOf)):EW(B)?nDF(B,B.properties):kz(B)?B:NJ(B)?B:NA(B)?B:fR(B)?B:th(B)?B:AA(B)?B:AJ(B)?B:eh(B)?B:Bk(B)?B:cI({})}function vT(B,Q){if(iG(B))return _CQ(B,Q);else return UQ({...$CQ(B),...Q})}function iDF(B,Q){let F={};for(let U of globalThis.Object.getOwnPropertyNames(B))F[U]=vT(B[U],nG(Q));return F}function pDF(B,Q){return iDF(B.properties,Q)}function _CQ(B,Q){let F=pDF(B,Q);return f0(F)}function aDF(B,Q){return mG("Required",[mG(B,Q)])}function oDF(B){return mG("Required",[QL(B)])}function rDF(B){let Q={};for(let F of globalThis.Object.getOwnPropertyNames(B))Q[F]=SZ(B[F],[hV]);return Q}function sDF(B,Q){let F=SZ(B,[iW,"$id","required","properties"]),U=rDF(Q);return cI(U,F)}function vCQ(B){return B.map((Q)=>PCQ(Q))}function PCQ(B){return XA(B)?aDF(B.target,B.parameters):UW(B)?oDF(B.$ref):wZ(B)?yb(vCQ(B.allOf)):y0(B)?AI(vCQ(B.anyOf)):EW(B)?sDF(B,B.properties):kz(B)?B:NJ(B)?B:NA(B)?B:fR(B)?B:th(B)?B:AA(B)?B:AJ(B)?B:eh(B)?B:Bk(B)?B:cI({})}function PT(B,Q){if(iG(B))return fCQ(B,Q);else return UQ({...PCQ(B),...Q})}function tDF(B,Q){let F={};for(let U of globalThis.Object.getOwnPropertyNames(B))F[U]=PT(B[U],Q);return F}function eDF(B,Q){return tDF(B.properties,Q)}function fCQ(B,Q){let F=eDF(B,Q);return f0(F)}function B3F(B,Q){return Q.map((F)=>{return UW(F)?F2B(B,F.$ref):nR(B,F)})}function F2B(B,Q){return Q in B?UW(B[Q])?F2B(B,B[Q].$ref):nR(B,B[Q]):M0()}function Q3F(B){return KT(B[0])}function F3F(B){return QE(B[0],B[1])}function U3F(B){return hT(B[0])}function I3F(B){return vT(B[0])}function G3F(B){return IE(B[0],B[1])}function Z3F(B){return GE(B[0],B[1])}function W3F(B){return PT(B[0])}function g3F(B,Q,F){let U=B3F(B,F);return Q==="Awaited"?Q3F(U):Q==="Index"?F3F(U):Q==="KeyOf"?U3F(U):Q==="Partial"?I3F(U):Q==="Omit"?G3F(U):Q==="Pick"?Z3F(U):Q==="Required"?W3F(U):M0()}function V3F(B,Q){return ST(nR(B,Q))}function b3F(B,Q){return yT(nR(B,Q))}function X3F(B,Q,F){return MT(bk(B,Q),nR(B,F))}function C3F(B,Q,F){return eY(bk(B,Q),nR(B,F))}function R3F(B,Q){return yb(bk(B,Q))}function N3F(B,Q){return cT(nR(B,Q))}function A3F(B,Q){return cI(globalThis.Object.keys(Q).reduce((F,U)=>{return{...F,[U]:nR(B,Q[U])}},{}))}function Y3F(B,Q){let[F,U]=[nR(B,Ap(Q)),Np(Q)],I=zT(Q);return I.patternProperties[U]=F,I}function L3F(B,Q){return UW(Q)?{...F2B(B,Q.$ref),[iW]:Q[iW]}:Q}function H3F(B,Q){return hN(bk(B,Q))}function J3F(B,Q){return AI(bk(B,Q))}function bk(B,Q){return Q.map((F)=>nR(B,F))}function nR(B,Q){return SC(Q)?UQ(nR(B,SZ(Q,[hV])),Q):wT(Q)?UQ(nR(B,SZ(Q,[VA])),Q):s9(Q)?UQ(L3F(B,Q),Q):bA(Q)?UQ(V3F(B,Q.items),Q):hz(Q)?UQ(b3F(B,Q.items),Q):XA(Q)?UQ(g3F(B,Q.target,Q.parameters)):CA(Q)?UQ(X3F(B,Q.parameters,Q.returns),Q):RA(Q)?UQ(C3F(B,Q.parameters,Q.returns),Q):wZ(Q)?UQ(R3F(B,Q.allOf),Q):dz(Q)?UQ(N3F(B,Q.items),Q):EW(Q)?UQ(A3F(B,Q.properties),Q):_z(Q)?UQ(Y3F(B,Q)):qR(Q)?UQ(H3F(B,Q.items||[]),Q):y0(Q)?UQ(J3F(B,Q.anyOf),Q):Q}function x3F(B,Q){return Q in B?nR(B,B[Q]):M0()}function lCQ(B){return globalThis.Object.getOwnPropertyNames(B).reduce((Q,F)=>{return{...Q,[F]:x3F(B,F)}},{})}class uCQ{constructor(B){let Q=lCQ(B),F=this.WithIdentifiers(Q);this.$defs=F}Import(B,Q){let F={...this.$defs,[B]:UQ(this.$defs[B],Q)};return UQ({[zQ]:"Import",$defs:F,$ref:B})}WithIdentifiers(B){return globalThis.Object.getOwnPropertyNames(B).reduce((Q,F)=>{return{...Q,[F]:{...B[F],$id:F}}},{})}}function qCQ(B){return new uCQ(B)}function jCQ(B,Q){return UQ({[zQ]:"Not",not:B},Q)}function nCQ(B,Q){return RA(B)?hN(B.parameters,Q):M0()}var E3F=0;function iCQ(B,Q={}){if(xW(Q.$id))Q.$id=`T${E3F++}`;let F=zT(B({[zQ]:"This",$ref:`${Q.$id}`}));return F.$id=Q.$id,UQ({[cN]:"Recursive",...F},Q)}function pCQ(B,Q){let F=IG(B)?new globalThis.RegExp(B):B;return UQ({[zQ]:"RegExp",type:"RegExp",source:F.source,flags:F.flags},Q)}function D3F(B){return wZ(B)?B.allOf:y0(B)?B.anyOf:qR(B)?B.items??[]:[]}function aCQ(B){return D3F(B)}function oCQ(B,Q){return RA(B)?UQ(B.returns,Q):M0(Q)}class rCQ{constructor(B){this.schema=B}Decode(B){return new sCQ(this.schema,B)}}class sCQ{constructor(B,Q){this.schema=B,this.decode=Q}EncodeTransform(B,Q){let I={Encode:(G)=>Q[iW].Encode(B(G)),Decode:(G)=>this.decode(Q[iW].Decode(G))};return{...Q,[iW]:I}}EncodeSchema(B,Q){let F={Decode:this.decode,Encode:B};return{...Q,[iW]:F}}Encode(B){return s9(this.schema)?this.EncodeTransform(B,this.schema):this.EncodeSchema(B,this.schema)}}function tCQ(B){return new rCQ(B)}function eCQ(B={}){return UQ({[zQ]:B[zQ]??"Unsafe"},B)}function BRQ(B){return UQ({[zQ]:"Void",type:"void"},B)}var U2B={};WU(U2B,{Void:()=>BRQ,Uppercase:()=>OCQ,Unsafe:()=>eCQ,Unknown:()=>FE,Union:()=>AI,Undefined:()=>Wp,Uncapitalize:()=>mCQ,Uint8Array:()=>gp,Tuple:()=>hN,Transform:()=>tCQ,TemplateLiteral:()=>Qp,Symbol:()=>Zp,String:()=>YA,ReturnType:()=>oCQ,Rest:()=>aCQ,Required:()=>PT,RegExp:()=>pCQ,Ref:()=>QL,Recursive:()=>iCQ,Record:()=>Rp,ReadonlyOptional:()=>Cp,Readonly:()=>MC,Promise:()=>Up,Pick:()=>GE,Partial:()=>vT,Parameters:()=>nCQ,Optional:()=>Sb,Omit:()=>IE,Object:()=>cI,Number:()=>KN,Null:()=>Gp,Not:()=>jCQ,Never:()=>M0,Module:()=>qCQ,Mapped:()=>iXQ,Lowercase:()=>TCQ,Literal:()=>GI,KeyOf:()=>hT,Iterator:()=>cT,Intersect:()=>yb,Integer:()=>zCQ,Instantiate:()=>DCQ,InstanceType:()=>xCQ,Index:()=>QE,Function:()=>eY,Extract:()=>_T,Extends:()=>dT,Exclude:()=>$T,Enum:()=>QCQ,Date:()=>Ip,ConstructorParameters:()=>BCQ,Constructor:()=>MT,Const:()=>eXQ,Composite:()=>tXQ,Capitalize:()=>MCQ,Boolean:()=>Bp,BigInt:()=>OT,Awaited:()=>KT,AsyncIterator:()=>yT,Array:()=>ST,Argument:()=>mXQ,Any:()=>BE});var DU=U2B;import*as Rm from"fs";import*as Xr from"path";var{S3Client:z3F}=globalThis.Bun;import*as Xk from"crypto";import*as yZ from"fs";import*as kV from"path";class I2B{cache=new Map;maxCapacity;iterator=null;sampleSize;constructor(B=50000,Q=50){this.maxCapacity=Math.max(0,B),this.sampleSize=Math.max(1,Q)}get(B){this.evictSample();let Q=this.cache.get(B);if(!Q)return;if(this.now()>Q.expiresAt){this.cache.delete(B);return}return this.cache.delete(B),this.cache.set(B,Q),Q.value}set(B,Q,F){if(this.maxCapacity<=0||F<=0||isNaN(F)){this.cache.delete(B);return}if(this.cache.has(B))this.cache.delete(B);else if(this.cache.size>=this.maxCapacity){let U=this.cache.keys().next().value;if(U!==void 0)this.cache.delete(U)}this.cache.set(B,{value:Q,expiresAt:this.now()+F})}delete(B){return this.cache.delete(B)}evictSample(){if(this.cache.size===0)return;if(!this.iterator)this.iterator=this.cache.keys();let B=this.now();for(let Q=0;Q<this.sampleSize;Q++){let F=this.iterator.next();if(F.done){this.iterator=this.cache.keys();break}let U=F.value,I=this.cache.get(U);if(I&&B>I.expiresAt)this.cache.delete(U)}}now(){return performance.now()}get size(){return this.cache.size}clear(){this.cache.clear(),this.iterator=null}}function w3F(B,Q){let F=process.env.BETTER_AUTH_SECRET||"shumai-local-storage-secret",U=Xk.createHmac("sha256",F);U.update(`${B}/${Q}`);let I=U.digest("hex");return`/api/upload/local?bucket=${encodeURIComponent(B)}&key=${encodeURIComponent(Q)}&Signature=${I}`}class FRQ{client;bucket;presignCache=new I2B(50000);constructor(B,Q,F,U,I,G="auto"){let Z=B;if(!Z.startsWith("http://")&&!Z.startsWith("https://"))Z=`${I?"https":"http"}://${B}`;this.client=new z3F({region:G,endpoint:Z,accessKeyId:Q,secretAccessKey:F,bucket:U}),this.bucket=U}async getObjectSize(B,Q){return await this.client.size(Q,{bucket:B})}async putObject(B,Q,F,U,I){await this.client.write(Q,F,{bucket:B,type:I})}async getObject(B,Q){let F=this.client.file(Q,{bucket:B}),U=await F.arrayBuffer();return{buffer:Buffer.from(U),contentType:F.type||"application/octet-stream"}}async copyObject(B,Q,F,U){let I=this.client.file(Q,{bucket:B});await this.client.write(U,I,{bucket:F})}async downloadToFile(B,Q,F){let U=this.client.file(Q,{bucket:B});await Bun.write(F,U)}async deleteObject(B,Q){try{if(!await this.client.exists(Q,{bucket:B}))return 0;return await this.client.delete(Q,{bucket:B}),1}catch{return 0}}async deletePrefix(B,Q){let F=await this.listObjects(B,Q);if(F.length>0)await Promise.all(F.map((U)=>this.deleteObject(B,U)));return F.length}async headObject(B,Q){let F=this.client.file(Q,{bucket:B});if(!await F.exists())throw Error("NoSuchKey: The specified key does not exist.");return{key:Q,size:await F.size,lastModified:new Date,contentType:F.type||"application/octet-stream",eTag:""}}async listObjects(B,Q){let F=[],U=!0,I=void 0;while(U){let G=await this.client.list({prefix:Q,continuationToken:I});if(G.contents){for(let Z of G.contents)if(Z.key)F.push(Z.key)}U=G.isTruncated||!1,I=G.nextContinuationToken}return F}async uploadFile(B,Q){let F=NG()+kV.extname(B);return await this.uploadFileToKey(B,F,Q),F}async uploadFileToKey(B,Q,F){await this.client.write(Q,Bun.file(B),{bucket:this.bucket,type:F})}async presign(B,Q,F,U){let I=parseInt(process.env.PRESIGNED_URL_EXPIRES_IN||"5",10),G=I*3600,W=Math.round(I*60*2/3)*60*1000,g=`${B}:${Q}:${U||""}`;if(F==="GET"){let X=this.presignCache.get(g);if(X)return X}let V={bucket:B,expiresIn:G,method:F};if(U)V.contentDisposition=`attachment; filename="${U}"`;let b=this.client.presign(Q,V);if(F==="GET")this.presignCache.set(g,b,W);return b}}class URQ{basePath;endpoint;constructor(B,Q="data"){if(this.endpoint=B.replace(/\/$/,""),this.basePath=kV.resolve(Q),!yZ.existsSync(this.basePath))yZ.mkdirSync(this.basePath,{recursive:!0})}getFilePath(B,Q){let F=kV.join(this.basePath,B,Q);if(!F.startsWith(this.basePath))throw Error("Invalid path: potential path traversal detected");return F}async getObjectSize(B,Q){let F=this.getFilePath(B,Q);try{return(await yZ.promises.stat(F)).size}catch(U){if(U instanceof Error&&U.code==="ENOENT")throw Error("NoSuchKey: The specified key does not exist.",{cause:U});throw U}}async putObject(B,Q,F,U,I){let G=this.getFilePath(B,Q),Z=kV.dirname(G);if(!yZ.existsSync(Z))yZ.mkdirSync(Z,{recursive:!0});await yZ.promises.writeFile(G,F)}async getObject(B,Q){let F=this.getFilePath(B,Q);try{return{buffer:await yZ.promises.readFile(F),contentType:Bun.file(F).type||"application/octet-stream"}}catch(U){if(U instanceof Error&&U.code==="ENOENT")throw Error("NoSuchKey: The specified key does not exist.",{cause:U});throw U}}async copyObject(B,Q,F,U){let I=this.getFilePath(B,Q),G=this.getFilePath(F,U),Z=kV.dirname(G);if(!yZ.existsSync(Z))yZ.mkdirSync(Z,{recursive:!0});await yZ.promises.copyFile(I,G)}async downloadToFile(B,Q,F){let U=this.getFilePath(B,Q);await yZ.promises.copyFile(U,F)}async deleteObject(B,Q){let F=this.getFilePath(B,Q);try{return await yZ.promises.unlink(F),1}catch(U){if(U instanceof Error&&U.code==="ENOENT")return 0;throw U}}async deletePrefix(B,Q){let F=await this.listObjects(B,Q);if(F.length===0)return 0;let U=this.getFilePath(B,Q);try{return await yZ.promises.rm(U,{recursive:!0,force:!0}),F.length}catch(I){if(I instanceof Error&&I.code==="ENOENT")return 0;throw I}}async headObject(B,Q){let F=this.getFilePath(B,Q);try{let U=await yZ.promises.stat(F),I=Xk.createHash("md5").update(F+U.mtimeMs).digest("hex");return{key:Q,size:U.size,lastModified:U.mtime,contentType:Bun.file(Q).type||"application/octet-stream",eTag:`"${I}"`}}catch(U){if(U instanceof Error&&U.code==="ENOENT")throw Error("NoSuchKey: The specified key does not exist.",{cause:U});throw U}}async listObjects(B,Q){let F=kV.join(this.basePath,B),U=[];if(!yZ.existsSync(F))return U;let I=async(G)=>{let Z=await yZ.promises.readdir(G);for(let W of Z){let g=kV.join(G,W);if((await yZ.promises.stat(g)).isDirectory())await I(g);else{let X=kV.relative(F,g).split(kV.sep).join("/");if(X.startsWith(Q))U.push(X)}}};return await I(F),U}async uploadFile(B,Q){let F=NG()+kV.extname(B);return await this.uploadFileToKey(B,F,Q),F}async uploadFileToKey(B,Q,F){let U=process.env.S3_BUCKET||"shumai",I=this.getFilePath(U,Q),G=kV.dirname(I);if(!yZ.existsSync(G))yZ.mkdirSync(G,{recursive:!0});await yZ.promises.copyFile(B,I)}async presign(B,Q,F,U){if(F!=="GET"&&F!=="PUT")throw Error(`Invalid method: ${F}`);if(F==="PUT")return`${this.endpoint}${w3F(B,Q)}`;let I=`${this.endpoint}/files/${B}/${Q}`;if(U)I+=`?filename=${encodeURIComponent(U)}`;return I}}var S3F=process.env.STORAGE_BACKEND||"local",y3F=process.env.SHUMAI_SERVER_PORT||"3000",QRQ=process.env.AWS_ENDPOINT_URL_S3||"http://localhost",yF=S3F==="s3"?new FRQ(QRQ,process.env.S3_ACCESS_KEY_ID||"minioadmin",process.env.S3_SECRET_ACCESS_KEY||"minioadmin",process.env.S3_BUCKET||"shumai",process.env.S3_USE_SSL==="true",process.env.S3_REGION||"auto"):new URQ(`${QRQ}:${y3F}`);var _RQ=Pb(V2B(),1);import*as mC from"fs";import*as Rk from"path";function $RQ(B){if(!B)return B;let Q=B.match(/files\/[A-Z0-9]{26}/);return Q?Q[0]:B}class vRQ{prismaClient;constructor(B=VB){this.prismaClient=B}async getSkillContent(B){let Q=await this.prismaClient.skill.findUnique({where:{id:B}});if(!Q)throw Error(`Skill with ID ${B} not found.`);let F=Rk.join(process.cwd(),".pi","skills",Q.id),U=Rk.join(F,".hash"),I=!0;if(mC.existsSync(U)){if(mC.readFileSync(U,"utf8")===Q.hash)I=!1}if(I){if(mC.existsSync(F))mC.rmSync(F,{recursive:!0,force:!0});mC.mkdirSync(F,{recursive:!0});let Z=await this.prismaClient.asset.findUnique({where:{id:Q.assetId},include:{storageKey:!0}});if(!Z||!Z.storageKey?.key)throw Error("Skill asset not found or has no key");let{buffer:W}=await yF.getObject(process.env.S3_BUCKET||"shumai",Z.storageKey.key);new _RQ.default(W).extractAllTo(F,!0),mC.writeFileSync(U,Q.hash)}let G=Rk.join(F,"SKILL.md");if(!mC.existsSync(G))G=Rk.join(F,"skill.md");if(!mC.existsSync(G))throw Error(`Skill downloaded but SKILL.md not found in ${F}`);return mC.readFileSync(G,"utf8")}async getSkillEnvs(B){let Q=await this.prismaClient.skill.findUnique({where:{id:B}});if(!Q)return{};let F=Q.config,U={};if(F?.environmentVariables&&Array.isArray(F.environmentVariables))for(let I of F.environmentVariables){let G=I.default!==void 0&&I.default!==null&&I.default!==""?I.default:process.env[I.name];if(G!==void 0)U[I.name]=G}return U}async createAgent(B){let{teamId:Q,name:F,type:U,enabled:I,avatar:G,providerId:Z,modelId:W,thinkingLevel:g,systemPrompt:V,soul:b,skills:X}=B;if(U==="embedding"||U==="autofill"){if(await this.prismaClient.agent.findFirst({where:{type:U,teamId:Q}}))throw Error(`Agent of type ${U} already exists for this team`)}if(U==="chat"||U==="autofill"){if(!Z||!W)throw Error("providerId and modelId are required for chat/autofill agents");let C=await this.prismaClient.model.findUnique({where:{id:W}});if(!C)throw Error("model not found");if(C.providerId!==Z)throw Error("model does not belong to provider")}return this.prismaClient.$transaction(async(C)=>{if(!await C.team.findUnique({where:{id:Q}}))throw Error("team not found");let R={provider:Z||"",model:W||"",thinkingLevel:g,systemPrompt:V},A=await C.user.create({data:{name:F,email:`agent-${Date.now()}-${Math.random().toString(36).substring(7)}@shumai.ai`,type:"agent",image:$RQ(G)}}),Y=await C.agent.create({data:{id:A.id,teamId:Q,type:U,enabled:I??!0,providerId:Z||null,modelId:W||null,soul:b,config:R,skills:{create:X?.map((L)=>({skillId:L}))||[]}}});return await C.teamMember.create({data:{teamId:Q,userId:A.id,role:"reviewer"}}),C.agent.findUnique({where:{id:Y.id},include:{user:!0,skills:{include:{skill:!0}}}})})}async updateAgent(B){let{agentId:Q,name:F,type:U,enabled:I,avatar:G,providerId:Z,modelId:W,thinkingLevel:g,systemPrompt:V,soul:b,skills:X}=B,C=await this.prismaClient.agent.findUnique({where:{id:Q},include:{user:{include:{teamMembers:!0}}}});if(!C)throw Error("agent not found");if(U==="embedding"||U==="autofill"){if(await this.prismaClient.agent.findFirst({where:{type:U,id:{not:Q},teamId:C.teamId}}))throw Error(`Agent of type ${U} already exists for this team`)}if(U==="chat"||U==="autofill"){if(!Z||!W)throw Error("providerId and modelId are required for chat/autofill agents");let R=await this.prismaClient.model.findUnique({where:{id:W}});if(!R)throw Error("model not found");if(R.providerId!==Z)throw Error("model does not belong to provider")}let N={provider:Z||"",model:W||"",thinkingLevel:g,systemPrompt:V};return this.prismaClient.$transaction(async(R)=>{return await R.user.update({where:{id:Q},data:{name:F,image:$RQ(G)}}),await R.agentSkill.deleteMany({where:{agentId:Q}}),R.agent.update({where:{id:Q},data:{type:U,enabled:I??!0,providerId:Z||null,modelId:W||null,soul:b,config:N,skills:{create:X?.map((A)=>({skillId:A}))||[]}},include:{user:!0,skills:{include:{skill:!0}}}})})}async deleteAgent(B){let{agentId:Q}=B;if(!await this.prismaClient.agent.findUnique({where:{id:Q}}))throw Error("agent not found");await this.prismaClient.user.delete({where:{id:Q}})}async listAgents(B){return this.prismaClient.agent.findMany({where:{teamId:B.teamId},orderBy:{id:"desc"},include:{user:!0,provider:!0,modelRef:!0,skills:{include:{skill:!0}}}})}async getSessionEntries(B){return this.prismaClient.agentSessionEntry.findMany({where:{sessionId:B.sessionId},orderBy:{id:"asc"}})}}var uz=new vRQ;class qz{sessionId;constructor(B){this.sessionId=B}async getMetadata(){let B=await VB.agentSession.findUnique({where:{id:this.sessionId}});if(!B)throw Error(`Session ${this.sessionId} not found`);return{id:B.id,createdAt:B.createdAt.toISOString(),agentId:B.agentId,userId:B.userId||void 0,cwd:B.cwd,assetId:B.assetId||void 0,userCommentId:B.userCommentId||void 0}}async getLeafId(){return(await VB.agentSession.findUnique({where:{id:this.sessionId},select:{leafId:!0}}))?.leafId||null}async setLeafId(B){await VB.agentSession.update({where:{id:this.sessionId},data:{leafId:B}})}async createEntryId(){return NG()}async appendEntry(B){let Q=structuredClone(B);if(Q.type==="message"){let F=Q.message;if(F.role==="toolResult"){let U=F.details;if(Array.isArray(F.content)&&U?.sourceKeys){let I=U.sourceKeys,G=0;F.content.forEach((Z)=>{if(Z.type==="image"&&I[G])Z.data="__S3_DATA__",G++})}if(F.toolName==="read_skill"&&!F.isError){if(U?.skillId&&Array.isArray(F.content))F.content.forEach((I)=>{if(I.type==="text"&&I.text&&!I.text.startsWith("Skill with ID")&&!I.text.startsWith("Skill downloaded but")&&!I.text.startsWith("Error reading skill"))I.text="__SKILL_CONTENT__"})}}}await VB.agentSessionEntry.create({data:{id:B.id,sessionId:this.sessionId,entry:Q}}),await this.setLeafId(B.id)}async getEntry(B){let Q=await VB.agentSessionEntry.findUnique({where:{id:B}});if(!Q)return;let F=Q.entry;return await this.reinjectImageDataAsync(F),await this.reinjectSkillContentAsync(F),F}async findEntries(B){let F=(await VB.agentSessionEntry.findMany({where:{sessionId:this.sessionId,entry:{path:["type"],equals:B}},orderBy:{id:"asc"}})).map((U)=>U.entry);for(let U of F)await this.reinjectImageDataAsync(U),await this.reinjectSkillContentAsync(U);return F}async getLabel(B){return(await VB.agentSessionEntry.findFirst({where:{sessionId:this.sessionId,entry:{path:["id"],equals:B}}}))?.entry?.label}async getPathToRoot(B){if(!B)return[];let Q=await VB.agentSessionEntry.findMany({where:{sessionId:this.sessionId}}),F=new Map;for(let G of Q)F.set(G.id,G.entry);let U=[],I=B;while(I){let G=F.get(I);if(!G)break;U.unshift(G),I=G.parentId}for(let G of U)await this.reinjectImageDataAsync(G),await this.reinjectSkillContentAsync(G);return U}async getEntries(){let Q=(await VB.agentSessionEntry.findMany({where:{sessionId:this.sessionId},orderBy:{id:"asc"}})).map((F)=>F.entry);for(let F of Q)await this.reinjectImageDataAsync(F),await this.reinjectSkillContentAsync(F);return Q}async reinjectImageDataAsync(B){if(B.type==="message"){let Q=B.message;if(Q.role==="toolResult"){let F=Q.details;if(Array.isArray(Q.content)&&F?.sourceKeys){let U=F.sourceKeys,I=0;for(let G of Q.content)if(G.type==="image"&&G.data==="__S3_DATA__"&&U[I]){let Z=U[I];try{let{buffer:W}=await yF.getObject(process.env.S3_BUCKET||"shumai",Z);G.data=W.toString("base64")}catch(W){console.error(`Failed to re-inject image data for key ${Z}:`,W)}I++}}}}}async reinjectSkillContentAsync(B){if(B.type==="message"){let Q=B.message;if(Q.role==="toolResult"&&Q.toolName==="read_skill"){let F=Q.details;if(F?.skillId&&Array.isArray(Q.content)){for(let U of Q.content)if(U.type==="text"&&U.text==="__SKILL_CONTENT__")try{let I=await uz.getSkillContent(F.skillId);U.text=I}catch(I){console.error(`Failed to re-inject skill content for skill ${F.skillId}:`,I)}}}}}static async create(B){if(B.sessionId)return new qz(B.sessionId);else{let Q=await VB.agentSession.create({data:{agentId:B.agentId,userId:B.userId,cwd:B.cwd||process.cwd(),assetId:B.assetId||null,userCommentId:B.userCommentId||null}});return new qz(Q.id)}}}var e3F=DU.Object({});function PRQ(B,Q){return{name:"analyze_image",label:"Analyze Image",description:"Retrieves and views the image content. Call this tool if you need to analyze the image.",parameters:e3F,execute:async()=>{try{let F=await VB.asset.findUnique({where:{id:B},include:{storageKey:!0}});if(!F)return{content:[{type:"text",text:`Asset with ID ${B} not found.`}],details:{}};let U=F.storageKey?.key;if(F.media){let b=F.media;if(b.imageTranscodes&&b.imageTranscodes.length>0)U=b.imageTranscodes[0].key||U}if(!U)return{content:[{type:"text",text:"No media content found for this asset."}],details:{}};let I=null;if(Q){let b=await VB.assetComment.findUnique({where:{id:Q}});if(b?.annotation){let X=b.annotation;if(Array.isArray(X)&&X.length>0)I=X}}let G=U;if(I){let b=await VB.workflowTask.create({data:{assetId:B,projectId:F.projectId||"none",type:e0.transcode,status:$I.pending,payload:{projectId:F.projectId||"none",imageAnnotation:{annotations:I}}}}),C=(await oN.executeWait(b)).output;if(C?.key)G=C.key;else throw Error("Image annotation transcode workflow failed to output S3 key.")}let Z=process.env.S3_BUCKET||"shumai",{buffer:W,contentType:g}=await yF.getObject(Z,G);return{content:[{type:"image",data:W.toString("base64"),mimeType:g||"image/webp"}],details:{sourceKeys:[G]}}}catch(F){return{content:[{type:"text",text:`Error analyzing image: ${F instanceof Error?F.message:String(F)}`}],details:{}}}}}}var BzF=DU.Object({start:DU.Number({description:"Start time in seconds"}),end:DU.Number({description:"End time in seconds"}),count:DU.Number({description:"Number of screenshots to take"})});function fRQ(B,Q){return{name:"screenshot",label:"Take Video Screenshots",description:"Takes screenshots for a video at specified interval. It returns the images to the agent context.",parameters:BzF,execute:async(F,U)=>{try{let I=await VB.asset.findUnique({where:{id:B}});if(!I)return{content:[{type:"text",text:`Asset with ID ${B} not found.`}],details:{}};let G=null,Z=null;if(Q){let R=await VB.assetComment.findUnique({where:{id:Q}});if(R){if(G=R.second!==null?R.second:null,R.annotation){let A=R.annotation;if(Array.isArray(A)&&A.length>0)Z=A}}}let W=await VB.workflowTask.create({data:{assetId:B,projectId:I.projectId||"none",type:e0.transcode,status:$I.pending,payload:{projectId:I.projectId||"none",screenshot:{start:U.start,end:U.end,count:U.count,commentTimestamp:G,annotations:Z}}}}),b=(await oN.executeWait(W)).output?.screenshots;if(!b||b.length===0)return{content:[{type:"text",text:"No screenshots were generated."}],details:{}};let X=[],C=[],N=process.env.S3_BUCKET||"shumai";for(let R of b){let{buffer:A,contentType:Y}=await yF.getObject(N,R.key);X.push({type:"image",data:A.toString("base64"),mimeType:Y||"image/webp"}),C.push(R.key)}return{content:X,details:{sourceKeys:C}}}catch(I){return{content:[{type:"text",text:`Error taking screenshots: ${I instanceof Error?I.message:String(I)}`}],details:{}}}}}}async function WE(B){let Q=await VB.workflowTask.create({data:{type:e0.agent_tool_call,status:$I.pending,assetId:B.assetId,payload:{projectId:"none",agentToolCall:{toolName:B.toolName,args:B.args,userId:B.userId}}}}),F=await oN.executeWait(Q);if(F.status===$I.failed){let I=F.output?.error||"Workflow task failed";throw Error(I)}return F.output}import*as FL from"fs";import*as qT from"path";var b2B=[137,80,78,71,13,10,26,10];function Jp(B){if(lRQ(B,[255,216,255]))return B[3]===247?null:"image/jpeg";if(lRQ(B,b2B))return QzF(B)&&!FzF(B)?"image/png":null;if(jz(B,0,"GIF"))return"image/gif";if(jz(B,0,"RIFF")&&jz(B,8,"WEBP"))return"image/webp";if(jz(B,4,"ftyp"))return"video/mp4";return null}function QzF(B){return B.length>=16&&uRQ(B,b2B.length)===13&&jz(B,12,"IHDR")}function FzF(B){let Q=b2B.length;while(Q+8<=B.length){let F=uRQ(B,Q),U=Q+4;if(jz(B,U,"acTL"))return!0;if(jz(B,U,"IDAT"))return!1;let I=Q+8+F+4;if(I<=Q||I>B.length)return!1;Q=I}return!1}function uRQ(B,Q){return(B[Q]??0)*16777216+((B[Q+1]??0)<<16)+((B[Q+2]??0)<<8)+(B[Q+3]??0)}function lRQ(B,Q){if(B.length<Q.length)return!1;return Q.every((F,U)=>B[U]===F)}function jz(B,Q,F){if(B.length<Q+F.length)return!1;for(let U=0;U<F.length;U++)if(B[Q+U]!==F.charCodeAt(U))return!1;return!0}function UzF(B){try{let U=FL.openSync(B,"r");try{let I=Buffer.alloc(4100),G=FL.readSync(U,I,0,4100,0),Z=Jp(new Uint8Array(I.subarray(0,G)));if(Z)return Z}finally{FL.closeSync(U)}}catch{}let Q=qT.extname(B).toLowerCase();return{".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".mp4":"video/mp4",".mov":"video/quicktime",".pdf":"application/pdf"}[Q]||"application/octet-stream"}var IzF=DU.Object({parent:DU.String({description:"The parent folder ID under which to create the file. This parameter is required."}),path:DU.String({description:"The absolute or relative local path to the file on disk. This parameter is required."})});function qRQ(B){return{name:"create_file",label:"Create File",description:"Create a new file in a specified parent folder from a local file path.",parameters:IzF,execute:async(Q,F)=>{try{let U=qT.resolve(process.cwd(),F.path);if(!FL.existsSync(U))throw Error(`Local file not found at path: ${F.path}`);let I=FL.statSync(U).size,G=UzF(U),Z=`files/${NG()}/raw`;await yF.uploadFileToKey(U,Z,G);let W=await WE({toolName:"create_file",args:{parent:F.parent,s3Key:Z,name:qT.basename(U),size:I,contentType:G},userId:B,assetId:F.parent});return{content:[{type:"text",text:JSON.stringify(W,null,2)}],details:W}}catch(U){return{content:[{type:"text",text:`Error creating file: ${U instanceof Error?U.message:String(U)}`}],details:{}}}}}}var GzF=DU.Object({parent:DU.String({description:"The parent folder ID under which to create the new folder. This parameter is required."}),name:DU.String({description:"The name of the new folder to create. This parameter is required."})});function jRQ(B){return{name:"create_folder",label:"Create Folder",description:"Create a new folder in a specified parent folder.",parameters:GzF,execute:async(Q,F)=>{try{let U=await WE({toolName:"create_folder",args:F,userId:B,assetId:F.parent});return{content:[{type:"text",text:JSON.stringify(U,null,2)}],details:U}}catch(U){return{content:[{type:"text",text:`Error creating folder: ${U instanceof Error?U.message:String(U)}`}],details:{}}}}}}import*as UL from"fs";import*as jT from"path";function ZzF(B){try{let U=UL.openSync(B,"r");try{let I=Buffer.alloc(4100),G=UL.readSync(U,I,0,4100,0),Z=Jp(new Uint8Array(I.subarray(0,G)));if(Z)return Z}finally{UL.closeSync(U)}}catch{}let Q=jT.extname(B).toLowerCase();return{".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".mp4":"video/mp4",".mov":"video/quicktime",".pdf":"application/pdf"}[Q]||"application/octet-stream"}var WzF=DU.Object({parent:DU.String({description:"The parent file ID for which to create a new version. This parameter is required."}),path:DU.String({description:"The absolute or relative local path to the file on disk. This parameter is required."})});function nRQ(B){return{name:"create_version",label:"Create Version",description:"Create a new version of an existing file from a local file path.",parameters:WzF,execute:async(Q,F)=>{try{let U=jT.resolve(process.cwd(),F.path);if(!UL.existsSync(U))throw Error(`Local file not found at path: ${F.path}`);let I=UL.statSync(U).size,G=ZzF(U),Z=`files/${NG()}/raw`;await yF.uploadFileToKey(U,Z,G);let W=await WE({toolName:"create_version",args:{parent:F.parent,s3Key:Z,name:jT.basename(U),size:I,contentType:G},userId:B,assetId:F.parent});return{content:[{type:"text",text:JSON.stringify(W,null,2)}],details:W}}catch(U){return{content:[{type:"text",text:`Error creating file version: ${U instanceof Error?U.message:String(U)}`}],details:{}}}}}}var gzF=DU.Object({parent:DU.String({description:"The parent folder ID to list assets from. This parameter is required."}),page:DU.Optional(DU.Number({description:"The page number to retrieve, default is 1.",default:1})),pageSize:DU.Optional(DU.Number({description:"The number of assets per page, default is 20.",default:20})),type:DU.Optional(DU.String({description:"Filter assets by type: 'file', 'folder', or 'all'. Default is 'all'.",enum:["file","folder","all"],default:"all"}))});function iRQ(B){return{name:"list_assets",label:"List Assets",description:"List the assets (files and folders) inside a parent folder with pagination.",parameters:gzF,execute:async(Q,F)=>{try{let U=await WE({toolName:"list_assets",args:F,userId:B,assetId:F.parent});return{content:[{type:"text",text:JSON.stringify(U,null,2)}],details:U}}catch(U){return{content:[{type:"text",text:`Error listing assets: ${U instanceof Error?U.message:String(U)}`}],details:{}}}}}}var VzF=DU.Object({skillId:DU.String({description:"The ID of the skill to read"})}),pRQ=(B)=>({name:"read_skill",label:"Read Agent Skill",description:"Downloads and reads an agent skill to understand how to use it.",parameters:VzF,execute:async(Q,F)=>{try{if(!await VB.skill.findUnique({where:{id:F.skillId}}))return{content:[{type:"text",text:`Skill with ID ${F.skillId} not found.`}],details:{skillId:F.skillId}};let I=await uz.getSkillEnvs(F.skillId);return B(I),{content:[{type:"text",text:await uz.getSkillContent(F.skillId)}],details:{skillId:F.skillId}}}catch(U){return{content:[{type:"text",text:`Error reading skill ${F.skillId}: ${U instanceof Error?U.message:String(U)}`}],details:{skillId:F.skillId}}}}});import{spawn as bzF}from"child_process";var XzF=DU.Object({command:DU.String({description:"The bash command to execute."}),timeout:DU.Optional(DU.Number({description:"Maximum execution time in seconds."}))}),aRQ=(B,Q={},F)=>{return{name:"bash",description:"Execute a bash command in a sandboxed environment.",label:"Executing bash command",parameters:XzF,execute:async(U,{command:I,timeout:G},Z)=>{F?.clearBlockedHost?.();let W=await B4.wrapWithSandbox(I);return new Promise((g,V)=>{let b=bzF("bash",["-c",W],{cwd:B,detached:!0,stdio:["ignore","pipe","pipe"],env:{PATH:process.env.PATH||"",HOME:process.env.HOME||"",...Q}}),X="",C="",N=!1,R;if(G!==void 0&&G>0)R=setTimeout(()=>{if(N=!0,b.pid)try{process.kill(-b.pid,"SIGKILL")}catch{b.kill("SIGKILL")}},G*1000);b.stdout?.on("data",(Y)=>{X+=Y.toString()}),b.stderr?.on("data",(Y)=>{C+=Y.toString()});let A=()=>{if(b.pid)try{process.kill(-b.pid,"SIGKILL")}catch{b.kill("SIGKILL")}};Z?.addEventListener("abort",A,{once:!0}),b.on("error",(Y)=>{if(R)clearTimeout(R);Z?.removeEventListener("abort",A),qX.error({err:Y,command:I,stdout:X,stderr:C},"Sandboxed bash command encountered process error"),V(Y)}),b.on("close",(Y)=>{if(R)clearTimeout(R);Z?.removeEventListener("abort",A);let L=F?.getBlockedHost?.();if(Z?.aborted)qX.error({command:I,stdout:X,stderr:C},"Sandboxed bash command aborted"),V(Error("aborted"));else if(N)qX.error({timeout:G,command:I,stdout:X,stderr:C},"Sandboxed bash command timed out"),V(Error(`bash command timed out after ${G} seconds`));else if(L)V(Error(`Network request to ${L} is blocked, please ask admin to allow it in sandbox settings.`));else if(Y!==0&&Y!==null)qX.error({exitCode:Y,command:I,stdout:X,stderr:C},"Sandboxed bash command exited with failure code"),V(Error(`bash command exited with code ${Y}`));else{let H=X+C;g({content:[{type:"text",text:H||(Y===0?"Success":`Failed with exit code ${Y}`)}],details:{exitCode:Y,stdout:X,stderr:C}})}})})}}};import{ApplicationFailure as X2B}from"@temporalio/workflow";async function oRQ(B){let{updateTaskStatusActivity:Q,getEmbeddingContextActivity:F,generateImageEmbeddingActivity:U,generateVideoChunkEmbeddingActivity:I,saveAssetEmbeddingsActivity:G,updateTaskUsageActivity:Z,createCommentActivity:W,updateCommentActivity:g,getAgentWorkerQueueActivity:V,getTranscodeWorkerQueueActivity:b,downloadMediaToTmpActivity:X,cleanupTmpDirActivity:C,transcodeVideoChunkActivity:N,deleteS3ObjectActivity:R}=aN(),A,Y="",L="",H;try{Y=await QF(Fg,V),L=await QF(kL,b),await QF(Y,Q,{taskId:B.id,status:"processing"});let J=B.payload;if(A=(await QF(Y,W,{assetId:B.assetId,message:"__EMBEDDING__",sessionId:J?.agent?.sessionId||B.id,agentId:J?.agent?.agentId||"default"})).id,!B.teamId)throw X2B.create({message:"Task has no teamId",nonRetryable:!0});let M=await QF(Y,F,{teamId:B.teamId,assetId:B.assetId}),{asset:y,chunkDuration:m,chunkOverlap:c}=M,k=y.mediaType?.startsWith("image/"),d=y.mediaType?.startsWith("video/");if(!k&&!d)throw X2B.create({message:`unsupported media type for embeddings: ${y.mediaType}`,nonRetryable:!0});let $=y.storageKey?.key,FB=y.mediaType;if(y.media){let IB=y.media;if(d){if(IB.videoTranscodes&&IB.videoTranscodes.length>0){let t=IB.videoTranscodes.find((ZB)=>!ZB.isRaw)||IB.videoTranscodes[0];if(t?.key)$=t.key}}else if(k){if(IB.imageTranscodes&&IB.imageTranscodes.length>0){let t=IB.imageTranscodes.find((ZB)=>!ZB.isRaw)||IB.imageTranscodes[0];if(t?.key){if($=t.key,t.format)FB=`image/${t.format}`}}}}if(!$)throw X2B.create({message:"asset has no key",nonRetryable:!0});let bB=[],CB={model:"gemini-embedding-2",inputTokens:0,outputTokens:0};if(k){let IB=await QF(Y,U,{teamId:B.teamId,assetKey:$,mediaType:FB});if(bB.push({embedding:IB.embedding}),IB.usage)CB.inputTokens+=IB.usage.inputTokens||0,CB.outputTokens+=IB.usage.outputTokens||0}else if(d){let IB=await QF(L,X,{assetKey:$}),{filePath:t}=IB;H=IB.tmpDir;let ZB=y.media?.duration||0,LB=m||60,HQ=Math.max(1,LB-(c??5));for(let wQ=0;wQ<ZB;wQ+=HQ){let hQ=wQ+LB;if(hQ>=ZB)hQ=ZB;let jB=await QF(L,N,{assetId:y.id,filePath:t,startTime:wQ,endTime:hQ}),{chunkKey:lQ}=jB;try{let oF=await QF(Y,I,{teamId:B.teamId,chunkKey:lQ});if(bB.push({embedding:oF.embedding,startTime:wQ,endTime:hQ}),oF.usage)CB.inputTokens+=oF.usage.inputTokens||0,CB.outputTokens+=oF.usage.outputTokens||0}finally{await QF(L,R,{key:lQ})}if(hQ>=ZB)break}}if(bB.length>0)await QF(Y,G,{assetId:B.assetId,embeddings:bB});if(await QF(Y,Z,{taskId:B.id,inputTokens:CB.inputTokens,outputTokens:CB.outputTokens,model:CB.model}),A)await QF(Y,g,{commentId:A,message:"Embedding completed successfully."});await QF(Y,Q,{taskId:B.id,status:"completed"})}catch(J){if(console.error(`AgentEmbeddingMedia failed for task ${B.id}:`,J),A&&Y)try{await QF(Y,g,{commentId:A,message:`Embedding failed: ${J instanceof Error?J.message:String(J)}`})}catch(w){console.error("Failed to update error comment:",w)}if(Y)await QF(Y,Q,{taskId:B.id,status:"failed",output:{error:J instanceof Error?J.message:String(J)}});throw J}finally{if(H&&L)try{await QF(L,C,{tmpDir:H})}catch(J){console.error("Failed to cleanup transcode worker tmp dir:",J)}}}async function rRQ(B){let{generateTextEmbeddingActivity:Q,updateWorkflowTaskActivity:F,getAgentWorkerQueueActivity:U}=aN(),I="",Z=B.payload?.queryEmbeddingForSearch?.text;if(!Z)throw Error("Missing text in query_embedding_for_search task payload");try{I=await QF(Fg,U),await QF(I,F,{taskId:B.id,status:"processing",heartbeat:!0});let W=await QF(I,Q,{text:Z,teamId:B.teamId});await QF(I,F,{taskId:B.id,status:"completed",output:{embedding:W.embedding},inputTokens:W.usage.inputTokens,outputTokens:W.usage.outputTokens,model:W.usage.model})}catch(W){if(console.error(`queryEmbeddingForSearch failed for task ${B.id}:`,W),I)await QF(I,F,{taskId:B.id,status:"failed",output:{error:W instanceof Error?W.message:String(W)}});throw W}}import{ApplicationFailure as CzF}from"@temporalio/workflow";async function sRQ(B){let{updateTaskStatusActivity:Q,getAssetActivity:F,extractAiMetadataActivity:U,getProjectAutofillFieldsActivity:I,getAgentAutofillContextActivity:G,autofillAiActivity:Z,updateTaskUsageActivity:W,updateAssetMetadataActivity:g,createCommentActivity:V,updateCommentActivity:b,getTranscodeWorkerQueueActivity:X,getAgentWorkerQueueActivity:C,downloadMediaToTmpActivity:N,cleanupTmpDirActivity:R}=aN(),A,Y,L="",H="";try{H=await QF(Fg,C),L=await QF(kL,X),await QF(H,Q,{taskId:B.id,status:"processing"});let J=B.payload;A=(await QF(H,V,{assetId:B.assetId,message:"__AUTOFILL__",sessionId:J?.agent?.sessionId||B.id,agentId:J?.agent?.agentId||"default"})).id;let M=await QF(H,F,B.assetId),y=M?.storageKey?.key;if(!M||!M.project||!y)throw CzF.create({message:"Asset or project not found",nonRetryable:!0});let m=M.project.teamId,c=M.project.id,k=M.mediaType?.startsWith("image/")||!1,d=await QF(L,N,{assetKey:y}),{filePath:$}=d;Y=d.tmpDir;let FB=await QF(L,U,{assetKey:y,filePath:$,type:"autofill",isImage:k});if(FB.length===0){if(A)await QF(H,b,{commentId:A,message:"Autofill completed: No images could be extracted for analysis."});await QF(H,Q,{taskId:B.id,status:"completed"});return}let bB=await QF(H,I,c);if(bB.length===0){if(A)await QF(H,b,{commentId:A,message:"Autofill completed: No autofill fields defined in project."});await QF(H,Q,{taskId:B.id,status:"completed"});return}let CB=await QF(H,G,{teamId:m}),IB=await QF(H,Z,{teamId:m,images:FB,fields:bB.map((LB)=>({id:LB.key,config:LB.config,description:LB.description})),context:CB});if(IB.usage)await QF(H,W,{taskId:B.id,inputTokens:IB.usage.inputTokens,outputTokens:IB.usage.outputTokens,model:IB.usage.model});let t=JSON.parse(IB.text),ZB=Object.entries(t).map(([LB,NQ])=>({key:LB,value:NQ}));if(ZB.length>0)await QF(H,g,{assetId:M.id,metadata:ZB});if(A)await QF(H,b,{commentId:A,message:"Autofill completed successfully.",sessionId:IB.sessionId});await QF(H,Q,{taskId:B.id,status:"completed"})}catch(J){if(console.error(`AgentAutofillMedia failed for task ${B.id}:`,J),A&&H)try{await QF(H,b,{commentId:A,message:`Autofill failed: ${J instanceof Error?J.message:String(J)}`})}catch(w){console.error("Failed to update error comment:",w)}if(H)await QF(H,Q,{taskId:B.id,status:"failed",output:{error:J instanceof Error?J.message:String(J)}});throw J}finally{if(Y&&L)try{await QF(L,R,{tmpDir:Y})}catch(J){console.error("Failed to cleanup tmp dir:",J)}}}import{ApplicationFailure as Nk}from"@temporalio/workflow";function tRQ(B){if(!B)return"other";let Q=B.toLowerCase();if(Q.startsWith("image/")||Q==="application/x-photoshop"||Q==="image/vnd.adobe.photoshop")return"image";if(Q.startsWith("video/"))return"video";return"other"}class C2B{assetId;assetName;mediaType;videoDuration;commentTimestamp;pathContext;explicitMention=!1;constructor(B){this.assetId=B}withPathContext(B){return this.pathContext=B,this}withAssetDetails(B,Q,F){return this.assetName=B,this.mediaType=Q||void 0,this.videoDuration=F,this}withCommentTimestamp(B){if(B!==void 0&&B!==null)this.commentTimestamp=B;return this}withExplicitMention(B){return this.explicitMention=!!B,this}build(){let B=`The user is discussing an asset with ID: ${this.assetId}.`;if(this.assetName)B+=`
13372
+ ${Q}`:F}function jYF(B){let Q=B.replace(/\/+$/,""),F=Q.lastIndexOf("/");return F<=0?"/":Q.slice(0,F)}function Di(B,Q){let F=[{type:"text",text:B}];if(Q)F.push(...Q);return{role:"user",content:F,timestamp:Date.now()}}function nYF(B,Q,F){return{role:"assistant",content:[{type:"text",text:""}],api:B.api,provider:B.provider,model:B.id,stopReason:F?"aborted":"error",errorMessage:Q instanceof Error?Q.message:String(Q),timestamp:Date.now(),usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}}function mz(B){return{...B,headers:B?.headers?{...B.headers}:void 0,metadata:B?.metadata?{...B.metadata}:void 0}}function iYF(...B){let Q={},F=!1;for(let U of B){if(!U)continue;Object.assign(Q,U),F=!0}return F?Q:void 0}function pYF(B){let Q=new Set,F=new Set;for(let U of B){if(Q.has(U))F.add(U);Q.add(U)}return[...F]}function aYF(B,Q){let F=mz(B);if(!Q)return F;if(Object.hasOwn(Q,"transport"))F.transport=Q.transport;if(Object.hasOwn(Q,"timeoutMs"))F.timeoutMs=Q.timeoutMs;if(Object.hasOwn(Q,"maxRetries"))F.maxRetries=Q.maxRetries;if(Object.hasOwn(Q,"maxRetryDelayMs"))F.maxRetryDelayMs=Q.maxRetryDelayMs;if(Object.hasOwn(Q,"cacheRetention"))F.cacheRetention=Q.cacheRetention;if(Object.hasOwn(Q,"headers"))if(Q.headers===void 0)F.headers=void 0;else{let U={...F.headers??{}};for(let[I,G]of Object.entries(Q.headers))if(G===void 0)delete U[I];else U[I]=G;F.headers=Object.keys(U).length>0?U:void 0}if(Object.hasOwn(Q,"metadata"))if(Q.metadata===void 0)F.metadata=void 0;else{let U={...F.metadata??{}};for(let[I,G]of Object.entries(Q.metadata))if(G===void 0)delete U[I];else U[I]=G;F.metadata=Object.keys(U).length>0?U:void 0}return F}var zi="*";function TN(B,Q){if(B instanceof nI)return B;let F=cV(B);if(F instanceof kR)return new nI("session",F.message,F);if(F instanceof oY)return new nI("compaction",F.message,F);if(F instanceof FT)return new nI("branch_summary",F.message,F);return new nI(Q,F.message,F)}function Tz(B){return TN(B,"hook")}class GRB{env;session;phase="idle";runAbortController;runPromise;pendingSessionWrites=[];model;thinkingLevel;systemPrompt;streamOptions;getApiKeyAndHeaders;resources;tools=new Map;activeToolNames;steerQueue=[];steeringQueueMode;followUpQueue=[];followUpQueueMode;nextTurnQueue=[];handlers=new Map;constructor(B){this.env=B.env,this.session=B.session,this.resources=B.resources??{},this.streamOptions=mz(B.streamOptions),this.systemPrompt=B.systemPrompt,this.getApiKeyAndHeaders=B.getApiKeyAndHeaders,this.validateUniqueNames((B.tools??[]).map((Q)=>Q.name),"Duplicate tool name(s)");for(let Q of B.tools??[])this.tools.set(Q.name,Q);this.model=B.model,this.thinkingLevel=B.thinkingLevel??"off",this.activeToolNames=B.activeToolNames?[...B.activeToolNames]:(B.tools??[]).map((Q)=>Q.name),this.validateUniqueNames(this.activeToolNames,"Duplicate active tool name(s)"),this.validateToolNames(this.activeToolNames),this.steeringQueueMode=B.steeringMode??"one-at-a-time",this.followUpQueueMode=B.followUpMode??"one-at-a-time"}getHandlers(B){return this.handlers.get(B)}async emitOwn(B,Q){for(let F of this.getHandlers(zi)??[])try{await F(B,Q)}catch(U){throw Tz(U)}}async emitAny(B,Q){for(let F of this.getHandlers(zi)??[])try{await F(B,Q)}catch(U){throw Tz(U)}}async emitHook(B){let Q=this.getHandlers(B.type);if(!Q||Q.size===0)return;let F;for(let U of Q)try{let I=await U(B);if(I!==void 0)F=I}catch(I){throw Tz(I)}return F}async emitBeforeProviderRequest(B,Q,F){let U=this.getHandlers("before_provider_request"),I=mz(F);if(!U||U.size===0)return I;for(let G of U)try{let Z=await G({type:"before_provider_request",model:B,sessionId:Q,streamOptions:mz(I)});if(Z?.streamOptions)I=aYF(I,Z.streamOptions)}catch(Z){throw Tz(Z)}return I}async emitBeforeProviderPayload(B,Q){let F=this.getHandlers("before_provider_payload"),U=Q;if(!F||F.size===0)return U;for(let I of F)try{let G=await I({type:"before_provider_payload",model:B,payload:U});if(G!==void 0)U=G.payload}catch(G){throw Tz(G)}return U}async emitQueueUpdate(){await this.emitOwn({type:"queue_update",steer:[...this.steerQueue],followUp:[...this.followUpQueue],nextTurn:[...this.nextTurnQueue]})}startRunPromise(){let B=()=>{};return this.runPromise=new Promise((Q)=>{B=Q}),()=>{this.runPromise=void 0,B()}}async createTurnState(){let B=await this.session.buildContext(),Q=this.getResources(),F=await this.session.getMetadata(),U=[...this.tools.values()],I=this.activeToolNames.map((Z)=>this.tools.get(Z)).filter((Z)=>Z!==void 0),G="You are a helpful assistant.";if(typeof this.systemPrompt==="string")G=this.systemPrompt;else if(this.systemPrompt)G=await this.systemPrompt({env:this.env,session:this.session,model:this.model,thinkingLevel:this.thinkingLevel,activeTools:I,resources:Q});return{messages:B.messages,resources:Q,streamOptions:mz(this.streamOptions),sessionId:F.id,systemPrompt:G,model:this.model,thinkingLevel:this.thinkingLevel,tools:U,activeTools:I}}createContext(B,Q){return{systemPrompt:Q??B.systemPrompt,messages:B.messages.slice(),tools:B.activeTools.slice()}}createStreamFn(B){return async(Q,F,U)=>{let I=B(),G=await this.getApiKeyAndHeaders?.(Q),Z={...I.streamOptions,headers:iYF(I.streamOptions.headers,G?.headers)},W=await this.emitBeforeProviderRequest(Q,I.sessionId,Z);return iM(Q,F,{cacheRetention:W.cacheRetention,headers:W.headers,maxRetries:W.maxRetries,maxRetryDelayMs:W.maxRetryDelayMs,metadata:W.metadata,onPayload:async(g)=>await this.emitBeforeProviderPayload(Q,g),onResponse:async(g)=>{let V={...g.headers};await this.emitOwn({type:"after_provider_response",status:g.status,headers:V},U?.signal)},reasoning:U?.reasoning,signal:U?.signal,sessionId:I.sessionId,timeoutMs:W.timeoutMs,transport:W.transport,apiKey:G?.apiKey})}}async drainQueuedMessages(B,Q){let F=Q==="all"?B.splice(0):B.splice(0,1);if(F.length===0)return F;try{return await this.emitQueueUpdate(),F}catch(U){throw B.unshift(...F),Tz(U)}}createLoopConfig(B,Q){let F=B();return{model:F.model,reasoning:F.thinkingLevel==="off"?void 0:F.thinkingLevel,convertToLlm:Jz,transformContext:async(U)=>{return(await this.emitHook({type:"context",messages:[...U]}))?.messages??U},beforeToolCall:async({toolCall:U,args:I})=>{let G=await this.emitHook({type:"tool_call",toolCallId:U.id,toolName:U.name,input:I});return G?{block:G.block,reason:G.reason}:void 0},afterToolCall:async({toolCall:U,args:I,result:G,isError:Z})=>{let W=await this.emitHook({type:"tool_result",toolCallId:U.id,toolName:U.name,input:I,content:G.content,details:G.details,isError:Z});return W?{content:W.content,details:W.details,isError:W.isError,terminate:W.terminate}:void 0},prepareNextTurn:async()=>{await this.flushPendingSessionWrites();let U=await this.createTurnState();return Q(U),{context:this.createContext(U),model:U.model,thinkingLevel:U.thinkingLevel}},getSteeringMessages:async()=>this.drainQueuedMessages(this.steerQueue,this.steeringQueueMode),getFollowUpMessages:async()=>this.drainQueuedMessages(this.followUpQueue,this.followUpQueueMode)}}validateUniqueNames(B,Q){let F=pYF(B);if(F.length>0)throw new nI("invalid_argument",`${Q}: ${F.join(", ")}`)}validateToolNames(B,Q=this.tools){this.validateUniqueNames(B,"Duplicate active tool name(s)");let F=B.filter((U)=>!Q.has(U));if(F.length>0)throw new nI("invalid_argument",`Unknown tool(s): ${F.join(", ")}`)}async flushPendingSessionWrites(){while(this.pendingSessionWrites.length>0){let B=this.pendingSessionWrites[0];if(B.type==="message")await this.session.appendMessage(B.message);else if(B.type==="model_change")await this.session.appendModelChange(B.provider,B.modelId);else if(B.type==="thinking_level_change")await this.session.appendThinkingLevelChange(B.thinkingLevel);else if(B.type==="active_tools_change")await this.session.appendActiveToolsChange(B.activeToolNames);else if(B.type==="custom")await this.session.appendCustomEntry(B.customType,B.data);else if(B.type==="custom_message")await this.session.appendCustomMessageEntry(B.customType,B.content,B.display,B.details);else if(B.type==="label")await this.session.appendLabel(B.targetId,B.label);else if(B.type==="session_info")await this.session.appendSessionName(B.name??"");else if(B.type==="leaf")await this.session.getStorage().setLeafId(B.targetId);this.pendingSessionWrites.shift()}}async handleAgentEvent(B,Q){if(B.type==="message_end"){await this.session.appendMessage(B.message),await this.emitAny(B,Q);return}if(B.type==="turn_end"){let F;try{await this.emitAny(B,Q)}catch(I){F=I}let U=this.pendingSessionWrites.length>0;if(await this.flushPendingSessionWrites(),F)throw F;await this.emitOwn({type:"save_point",hadPendingMutations:U});return}if(B.type==="agent_end"){await this.flushPendingSessionWrites(),this.phase="idle",await this.emitAny(B,Q),await this.emitOwn({type:"settled",nextTurnCount:this.nextTurnQueue.length},Q);return}await this.emitAny(B,Q)}async emitRunFailure(B,Q,F,U){let I=nYF(B,Q,F);return await this.handleAgentEvent({type:"message_start",message:I},U),await this.handleAgentEvent({type:"message_end",message:I},U),await this.handleAgentEvent({type:"turn_end",message:I,toolResults:[]},U),await this.handleAgentEvent({type:"agent_end",messages:[I]},U),[I]}async executeTurn(B,Q,F){let U=B,I=[Di(Q,F?.images)];if(this.nextTurnQueue.length>0){let b=this.nextTurnQueue.splice(0);try{await this.emitQueueUpdate()}catch(X){throw this.nextTurnQueue.unshift(...b),Tz(X)}I=[...b,I[0]]}let G=await this.emitHook({type:"before_agent_start",prompt:Q,images:F?.images,systemPrompt:B.systemPrompt,resources:B.resources});if(G?.messages)I=[...I,...G.messages];let Z=new AbortController,W=()=>U,g=(b)=>{U=b};this.runAbortController=Z;let V=(async()=>{try{return await _XB(I,this.createContext(B,G?.systemPrompt),this.createLoopConfig(W,g),(b)=>this.handleAgentEvent(b,Z.signal),Z.signal,this.createStreamFn(W))}catch(b){try{return await this.emitRunFailure(U.model,b,Z.signal.aborted,Z.signal)}catch(X){let C=AggregateError([cV(b),cV(X)],"Agent run failed and failure reporting failed");throw new nI("unknown",C.message,C)}}})();try{let b=await V;for(let X=b.length-1;X>=0;X--){let C=b[X];if(C.role==="assistant")return C}throw new nI("invalid_state","AgentHarness prompt completed without an assistant message")}finally{try{await this.flushPendingSessionWrites()}finally{this.runAbortController=void 0}}}async prompt(B,Q){if(this.phase!=="idle")throw new nI("busy","AgentHarness is busy");this.phase="turn";let F=this.startRunPromise();try{let U=await this.createTurnState();return await this.executeTurn(U,B,Q)}catch(U){throw this.phase="idle",TN(U,"unknown")}finally{F()}}async skill(B,Q){if(this.phase!=="idle")throw new nI("busy","AgentHarness is busy");this.phase="turn";let F=this.startRunPromise();try{let U=await this.createTurnState(),I=(U.resources.skills??[]).find((G)=>G.name===B);if(!I)throw new nI("invalid_argument",`Unknown skill: ${B}`);return await this.executeTurn(U,$gQ(I,Q))}catch(U){throw this.phase="idle",TN(U,"unknown")}finally{F()}}async promptFromTemplate(B,Q=[]){if(this.phase!=="idle")throw new nI("busy","AgentHarness is busy");this.phase="turn";let F=this.startRunPromise();try{let U=await this.createTurnState(),I=(U.resources.promptTemplates??[]).find((G)=>G.name===B);if(!I)throw new nI("invalid_argument",`Unknown prompt template: ${B}`);return await this.executeTurn(U,zgQ(I,Q))}catch(U){throw this.phase="idle",TN(U,"unknown")}finally{F()}}async steer(B,Q){if(this.phase==="idle")throw new nI("invalid_state","Cannot steer while idle");this.steerQueue.push(Di(B,Q?.images)),await this.emitQueueUpdate()}async followUp(B,Q){if(this.phase==="idle")throw new nI("invalid_state","Cannot follow up while idle");this.followUpQueue.push(Di(B,Q?.images)),await this.emitQueueUpdate()}async nextTurn(B,Q){this.nextTurnQueue.push(Di(B,Q?.images)),await this.emitQueueUpdate()}async appendMessage(B){try{if(this.phase==="idle")await this.session.appendMessage(B);else this.pendingSessionWrites.push({type:"message",message:B})}catch(Q){throw TN(Q,"session")}}async compact(B){if(this.phase!=="idle")throw new nI("busy","compact() requires idle harness");this.phase="compaction";try{let Q=this.model;if(!Q)throw new nI("invalid_state","No model set for compaction");let F=await this.getApiKeyAndHeaders?.(Q);if(!F)throw new nI("auth","No auth available for compaction");let U=await this.session.getBranch(),I=lXB(U,fXB);if(!I.ok)throw I.error;let G=I.value;if(!G)throw new nI("compaction","Nothing to compact");let Z=await this.emitHook({type:"session_before_compact",preparation:G,branchEntries:U,customInstructions:B,signal:new AbortController().signal});if(Z?.cancel)throw new nI("compaction","Compaction cancelled");let W=Z?.compaction,g=W?{ok:!0,value:W}:await uXB(G,Q,F.apiKey,F.headers,B,void 0,this.thinkingLevel);if(!g.ok)throw g.error;let V=g.value,b=await this.session.appendCompaction(V.summary,V.firstKeptEntryId,V.tokensBefore,V.details,W!==void 0),X=await this.session.getEntry(b);if(X?.type==="compaction")await this.emitOwn({type:"session_compact",compactionEntry:X,fromHook:W!==void 0});return V}catch(Q){throw TN(Q,"compaction")}finally{this.phase="idle"}}async navigateTree(B,Q){if(this.phase!=="idle")throw new nI("busy","navigateTree() requires idle harness");this.phase="branch_summary";try{let F=await this.session.getLeafId();if(F===B)return{cancelled:!1};let U=await this.session.getEntry(B);if(!U)throw new nI("invalid_argument",`Entry ${B} not found`);let{entries:I,commonAncestorId:G}=await qXB(this.session,F,B),Z={targetId:B,oldLeafId:F,commonAncestorId:G,entriesToSummarize:I,userWantsSummary:Q?.summarize??!1,customInstructions:Q?.customInstructions,replaceInstructions:Q?.replaceInstructions,label:Q?.label},W=new AbortController().signal,g=await this.emitHook({type:"session_before_tree",preparation:Z,signal:W});if(g?.cancel)return{cancelled:!0};let V,b=g?.summary?.summary,X=g?.summary?.details;if(!b&&Q?.summarize&&I.length>0){let A=this.model;if(!A)throw new nI("invalid_state","No model set for branch summary");let Y=await this.getApiKeyAndHeaders?.(A);if(!Y)throw new nI("auth","No auth available for branch summary");let L=await jXB(I,{model:A,apiKey:Y.apiKey,headers:Y.headers,signal:new AbortController().signal,customInstructions:g?.customInstructions??Q?.customInstructions,replaceInstructions:g?.replaceInstructions??Q?.replaceInstructions});if(!L.ok){if(L.error.code==="aborted")return{cancelled:!0};throw new nI("branch_summary",L.error.message,L.error)}b=L.value.summary,X={readFiles:L.value.readFiles,modifiedFiles:L.value.modifiedFiles}}let C,N;if(U.type==="message"&&U.message.role==="user"){N=U.parentId;let A=U.message.content;C=typeof A==="string"?A:A.filter((Y)=>Y.type==="text").map((Y)=>Y.text).join("")}else if(U.type==="custom_message")N=U.parentId,C=typeof U.content==="string"?U.content:U.content.filter((A)=>A.type==="text").map((A)=>A.text).join("");else N=B;let R=await this.session.moveTo(N,b?{summary:b,details:X,fromHook:g?.summary!==void 0}:void 0);if(R){let A=await this.session.getEntry(R);if(A?.type==="branch_summary")V=A}return await this.emitOwn({type:"session_tree",newLeafId:await this.session.getLeafId(),oldLeafId:F,summaryEntry:V,fromHook:g?.summary!==void 0}),{cancelled:!1,editorText:C,summaryEntry:V}}catch(F){throw TN(F,"branch_summary")}finally{this.phase="idle"}}getModel(){return this.model}async setModel(B){try{let Q=this.model;if(this.phase==="idle")await this.session.appendModelChange(B.provider,B.id);else this.pendingSessionWrites.push({type:"model_change",provider:B.provider,modelId:B.id});this.model=B,await this.emitOwn({type:"model_update",model:B,previousModel:Q,source:"set"})}catch(Q){throw TN(Q,"session")}}getThinkingLevel(){return this.thinkingLevel}async setThinkingLevel(B){try{let Q=this.thinkingLevel;if(this.phase==="idle")await this.session.appendThinkingLevelChange(B);else this.pendingSessionWrites.push({type:"thinking_level_change",thinkingLevel:B});this.thinkingLevel=B,await this.emitOwn({type:"thinking_level_update",level:B,previousLevel:Q})}catch(Q){throw TN(Q,"session")}}getTools(){return[...this.tools.values()]}async setTools(B,Q){try{this.validateUniqueNames(B.map((Z)=>Z.name),"Duplicate tool name(s)");let F=new Map(B.map((Z)=>[Z.name,Z])),U=Q?[...Q]:this.activeToolNames;this.validateToolNames(U,F);let I=[...this.tools.keys()],G=[...this.activeToolNames];if(this.phase==="idle")await this.session.appendActiveToolsChange(U);else this.pendingSessionWrites.push({type:"active_tools_change",activeToolNames:[...U]});this.tools=F,this.activeToolNames=[...U],await this.emitOwn({type:"tools_update",toolNames:[...this.tools.keys()],previousToolNames:I,activeToolNames:[...this.activeToolNames],previousActiveToolNames:G,source:"set"})}catch(F){throw TN(F,"invalid_argument")}}getActiveTools(){return this.activeToolNames.map((B)=>this.tools.get(B))}async setActiveTools(B){try{this.validateToolNames(B);let Q=[...this.tools.keys()],F=[...this.activeToolNames];if(this.phase==="idle")await this.session.appendActiveToolsChange(B);else this.pendingSessionWrites.push({type:"active_tools_change",activeToolNames:[...B]});this.activeToolNames=[...B],await this.emitOwn({type:"tools_update",toolNames:[...this.tools.keys()],previousToolNames:Q,activeToolNames:[...this.activeToolNames],previousActiveToolNames:F,source:"set"})}catch(Q){throw TN(Q,"invalid_argument")}}getSteeringMode(){return this.steeringQueueMode}async setSteeringMode(B){this.steeringQueueMode=B}getFollowUpMode(){return this.followUpQueueMode}async setFollowUpMode(B){this.followUpQueueMode=B}getResources(){return{skills:this.resources.skills?.slice(),promptTemplates:this.resources.promptTemplates?.slice()}}async setResources(B){let Q=this.getResources();this.resources={skills:B.skills?.slice(),promptTemplates:B.promptTemplates?.slice()},await this.emitOwn({type:"resources_update",resources:this.getResources(),previousResources:Q})}getStreamOptions(){return mz(this.streamOptions)}async setStreamOptions(B){this.streamOptions=mz(B)}async abort(){let B=[...this.steerQueue],Q=[...this.followUpQueue];this.steerQueue=[],this.followUpQueue=[],this.runAbortController?.abort();let F=[];try{await this.emitQueueUpdate()}catch(U){F.push(cV(U))}try{await this.waitForIdle()}catch(U){F.push(cV(U))}try{await this.emitOwn({type:"abort",clearedSteer:B,clearedFollowUp:Q})}catch(U){F.push(cV(U))}if(F.length>0){let U=F.length===1?F[0]:AggregateError(F,"Abort completed with errors");throw TN(U,"hook")}return{clearedSteer:B,clearedFollowUp:Q}}async waitForIdle(){await this.runPromise}subscribe(B){let Q=this.handlers.get(zi);if(!Q)Q=new Set,this.handlers.set(zi,Q);return Q.add(B),()=>Q.delete(B)}on(B,Q){let F=this.handlers.get(B);if(!F)F=new Set,this.handlers.set(B,F);return F.add(Q),()=>F.delete(Q)}}var m1I=globalThis.Buffer;import{spawn as bRB}from"child_process";import{randomUUID as BLF}from"crypto";import{constants as QLF,createReadStream as FLF}from"fs";import{access as ULF,appendFile as ILF,lstat as _gQ,mkdir as WRB,mkdtemp as GLF,readdir as ZLF,readFile as vgQ,realpath as WLF,rm as gLF,writeFile as PgQ}from"fs/promises";import{tmpdir as VLF}from"os";import{isAbsolute as bLF,join as gRB,resolve as wi}from"path";import{createInterface as XLF}from"readline";function mN(B,Q){return bLF(Q)?Q:wi(B,Q)}function CLF(B){if(B.isFile())return"file";if(B.isDirectory())return"directory";if(B.isSymbolicLink())return"symlink";return}function fgQ(B,Q){let F=CLF(Q);if(!F)return pU(new wN("invalid","Unsupported file type",B));return H0({name:B.replace(/\/+$/,"").split("/").pop()??B,path:B,kind:F,size:Q.size,mtimeMs:Q.mtimeMs})}function RLF(B){return B instanceof Error&&"code"in B}function dR(B,Q){if(B instanceof wN)return B;let F=cV(B);if(RLF(B)){let U=B.message;switch(B.code){case"ABORT_ERR":return new wN("aborted",U,Q,F);case"ENOENT":return new wN("not_found",U,Q,F);case"EACCES":case"EPERM":return new wN("permission_denied",U,Q,F);case"ENOTDIR":return new wN("not_directory",U,Q,F);case"EISDIR":return new wN("is_directory",U,Q,F);case"EINVAL":return new wN("invalid",U,Q,F)}}return new wN("unknown",F.message,Q,F)}function VJ(B,Q){return B?.aborted?pU(new wN("aborted","aborted",Q)):void 0}async function Si(B){try{return await ULF(B,QLF.F_OK),!0}catch{return!1}}async function lgQ(B,Q,F){return await new Promise((U)=>{let I="",G;try{G=bRB(B,Q,{stdio:["ignore","pipe","ignore"],windowsHide:!0})}catch{U({stdout:"",status:null});return}let Z=setTimeout(()=>{if(G.pid)VRB(G.pid)},F);G.stdout?.setEncoding("utf8"),G.stdout?.on("data",(W)=>{I+=W}),G.on("error",()=>{clearTimeout(Z),U({stdout:"",status:null})}),G.on("close",(W)=>{clearTimeout(Z),U({stdout:I,status:W})})})}async function ugQ(){let B=process.platform==="win32"?await lgQ("where",["bash.exe"],5000):await lgQ("which",["bash"],5000);if(B.status!==0||!B.stdout)return null;let Q=B.stdout.trim().split(/\r?\n/)[0];return Q&&await Si(Q)?Q:null}async function NLF(B){if(B){if(await Si(B))return H0({shell:B,args:["-c"]});return pU(new SN("shell_unavailable",`Custom shell path not found: ${B}`))}if(process.platform==="win32"){let F=[],U=process.env.ProgramFiles;if(U)F.push(`${U}\\Git\\bin\\bash.exe`);let I=process.env["ProgramFiles(x86)"];if(I)F.push(`${I}\\Git\\bin\\bash.exe`);for(let Z of F)if(await Si(Z))return H0({shell:Z,args:["-c"]});let G=await ugQ();if(G)return H0({shell:G,args:["-c"]});return pU(new SN("shell_unavailable","No bash shell found"))}if(await Si("/bin/bash"))return H0({shell:"/bin/bash",args:["-c"]});let Q=await ugQ();if(Q)return H0({shell:Q,args:["-c"]});return H0({shell:"sh",args:["-c"]})}function ALF(B,Q){return{...process.env,...B,...Q}}function VRB(B){if(process.platform==="win32"){try{bRB("taskkill",["/F","/T","/PID",String(B)],{stdio:"ignore",detached:!0,windowsHide:!0})}catch{}return}try{process.kill(-B,"SIGKILL")}catch{try{process.kill(B,"SIGKILL")}catch{}}}class yi{cwd;shellPath;shellEnv;constructor(B){this.cwd=B.cwd,this.shellPath=B.shellPath,this.shellEnv=B.shellEnv}async absolutePath(B){return H0(mN(this.cwd,B))}async joinPath(B){return H0(gRB(...B))}async exec(B,Q){if(Q?.abortSignal?.aborted)return pU(new SN("aborted","aborted"));let F=Q?.cwd?mN(this.cwd,Q.cwd):this.cwd,U=await NLF(this.shellPath);if(!U.ok)return U;return await new Promise((I)=>{let G="",Z="",W=!1,g=!1,V,b,X,C=()=>{if(b?.pid)VRB(b.pid)},N=(R)=>{if(X)clearTimeout(X);if(Q?.abortSignal)Q.abortSignal.removeEventListener("abort",C);if(W)return;W=!0,I(R)};try{b=bRB(U.value.shell,[...U.value.args,B],{cwd:F,detached:process.platform!=="win32",env:ALF(this.shellEnv,Q?.env),stdio:["ignore","pipe","pipe"],windowsHide:!0})}catch(R){let A=cV(R);N(pU(new SN("spawn_error",A.message,A)));return}if(X=typeof Q?.timeout==="number"?setTimeout(()=>{if(g=!0,b?.pid)VRB(b.pid)},Q.timeout*1000):void 0,Q?.abortSignal)if(Q.abortSignal.aborted)C();else Q.abortSignal.addEventListener("abort",C,{once:!0});b.stdout?.setEncoding("utf8"),b.stderr?.setEncoding("utf8"),b.stdout?.on("data",(R)=>{G+=R;try{Q?.onStdout?.(R)}catch(A){let Y=cV(A);V=new SN("callback_error",Y.message,Y),C()}}),b.stderr?.on("data",(R)=>{Z+=R;try{Q?.onStderr?.(R)}catch(A){let Y=cV(A);V=new SN("callback_error",Y.message,Y),C()}}),b.on("error",(R)=>{N(pU(new SN("spawn_error",R.message,R)))}),b.on("close",(R)=>{if(V){N(pU(V));return}if(g){N(pU(new SN("timeout",`timeout:${Q?.timeout}`)));return}if(Q?.abortSignal?.aborted){N(pU(new SN("aborted","aborted")));return}N(H0({stdout:G,stderr:Z,exitCode:R??0}))})})}async readTextFile(B,Q){let F=mN(this.cwd,B),U=VJ(Q,F);if(U)return U;try{return H0(await vgQ(F,{encoding:"utf8",signal:Q}))}catch(I){return pU(dR(I,F))}}async readTextLines(B,Q){let F=mN(this.cwd,B),U=VJ(Q?.abortSignal,F);if(U)return U;if(Q?.maxLines!==void 0&&Q.maxLines<=0)return H0([]);let I,G;try{I=FLF(F,{encoding:"utf8",signal:Q?.abortSignal}),G=XLF({input:I,crlfDelay:1/0});let Z=[];for await(let g of G){let V=VJ(Q?.abortSignal,F);if(V)return V;if(Z.push(g),Q?.maxLines!==void 0&&Z.length>=Q.maxLines)break}let W=VJ(Q?.abortSignal,F);if(W)return W;return H0(Z)}catch(Z){return pU(dR(Z,F))}finally{G?.close(),I?.destroy()}}async readBinaryFile(B,Q){let F=mN(this.cwd,B),U=VJ(Q,F);if(U)return U;try{return H0(await vgQ(F,{signal:Q}))}catch(I){return pU(dR(I,F))}}async writeFile(B,Q,F){let U=mN(this.cwd,B),I=VJ(F,U);if(I)return I;try{await WRB(wi(U,".."),{recursive:!0});let G=VJ(F,U);if(G)return G;return await PgQ(U,Q,{signal:F}),H0(void 0)}catch(G){return pU(dR(G,U))}}async appendFile(B,Q){let F=mN(this.cwd,B);try{return await WRB(wi(F,".."),{recursive:!0}),await ILF(F,Q),H0(void 0)}catch(U){return pU(dR(U,F))}}async fileInfo(B){let Q=mN(this.cwd,B);try{return fgQ(Q,await _gQ(Q))}catch(F){return pU(dR(F,Q))}}async listDir(B,Q){let F=mN(this.cwd,B),U=VJ(Q,F);if(U)return U;try{let I=await ZLF(F,{withFileTypes:!0}),G=[];for(let Z of I){let W=VJ(Q,F);if(W)return W;let g=wi(F,Z.name);try{let V=fgQ(g,await _gQ(g));if(V.ok)G.push(V.value)}catch(V){return pU(dR(V,g))}}return H0(G)}catch(I){return pU(dR(I,F))}}async canonicalPath(B){let Q=mN(this.cwd,B);try{return H0(await WLF(Q))}catch(F){return pU(dR(F,Q))}}async exists(B){let Q=await this.fileInfo(B);if(Q.ok)return H0(!0);if(Q.error.code==="not_found")return H0(!1);return pU(Q.error)}async createDir(B,Q){let F=mN(this.cwd,B);try{return await WRB(F,{recursive:Q?.recursive??!0}),H0(void 0)}catch(U){return pU(dR(U,F))}}async remove(B,Q){let F=mN(this.cwd,B);try{return await gLF(F,{recursive:Q?.recursive??!1,force:Q?.force??!1}),H0(void 0)}catch(U){return pU(dR(U,F))}}async createTempDir(B="tmp-"){try{return H0(await GLF(gRB(VLF(),B)))}catch(Q){return pU(dR(Q))}}async createTempFile(B){let Q=await this.createTempDir("tmp-");if(!Q.ok)return Q;let F=gRB(Q.value,`${B?.prefix??""}${BLF()}${B?.suffix??""}`);try{return await PgQ(F,""),H0(F)}catch(U){return pU(dR(U,F))}}async cleanup(){}}var YLF=new Map;function LLF(B,Q){return(F,U,I)=>{if(F.api!==B)throw Error(`Mismatched api: ${F.api} expected ${B}`);return Q(F,U,I)}}function HLF(B,Q){return(F,U,I)=>{if(F.api!==B)throw Error(`Mismatched api: ${F.api} expected ${B}`);return Q(F,U,I)}}function GA(B,Q){YLF.set(B.api,{provider:{api:B.api,stream:LLF(B.api,B.stream),streamSimple:HLF(B.api,B.streamSimple)},sourceId:Q})}ZA();var qgQ={openrouter:{"black-forest-labs/flux.2-flex":{id:"black-forest-labs/flux.2-flex",name:"Black Forest Labs: FLUX.2 Flex",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"black-forest-labs/flux.2-klein-4b":{id:"black-forest-labs/flux.2-klein-4b",name:"Black Forest Labs: FLUX.2 Klein 4B",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"black-forest-labs/flux.2-max":{id:"black-forest-labs/flux.2-max",name:"Black Forest Labs: FLUX.2 Max",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"black-forest-labs/flux.2-pro":{id:"black-forest-labs/flux.2-pro",name:"Black Forest Labs: FLUX.2 Pro",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"bytedance-seed/seedream-4.5":{id:"bytedance-seed/seedream-4.5",name:"ByteDance Seed: Seedream 4.5",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"google/gemini-2.5-flash-image":{id:"google/gemini-2.5-flash-image",name:"Google: Nano Banana (Gemini 2.5 Flash Image)",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:0.3,output:2.5,cacheRead:0.03,cacheWrite:0.08333333333333334}},"google/gemini-3-pro-image-preview":{id:"google/gemini-3-pro-image-preview",name:"Google: Nano Banana Pro (Gemini 3 Pro Image Preview)",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:2,output:12,cacheRead:0.19999999999999998,cacheWrite:0.375}},"google/gemini-3.1-flash-image-preview":{id:"google/gemini-3.1-flash-image-preview",name:"Google: Nano Banana 2 (Gemini 3.1 Flash Image Preview)",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:0.5,output:3,cacheRead:0,cacheWrite:0}},"openai/gpt-5-image":{id:"openai/gpt-5-image",name:"OpenAI: GPT-5 Image",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:10,output:10,cacheRead:1.25,cacheWrite:0}},"openai/gpt-5-image-mini":{id:"openai/gpt-5-image-mini",name:"OpenAI: GPT-5 Image Mini",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:2.5,output:2,cacheRead:0.25,cacheWrite:0}},"openai/gpt-5.4-image-2":{id:"openai/gpt-5.4-image-2",name:"OpenAI: GPT-5.4 Image 2",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:8,output:15,cacheRead:2,cacheWrite:0}},"openrouter/auto":{id:"openrouter/auto",name:"Auto Router",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["text","image"],cost:{input:-1e6,output:-1e6,cacheRead:0,cacheWrite:0}},"recraft/recraft-v3":{id:"recraft/recraft-v3",name:"Recraft: Recraft V3",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4":{id:"recraft/recraft-v4",name:"Recraft: Recraft V4",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4-pro":{id:"recraft/recraft-v4-pro",name:"Recraft: Recraft V4 Pro",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4-pro-vector":{id:"recraft/recraft-v4-pro-vector",name:"Recraft: Recraft V4 Pro Vector",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4-vector":{id:"recraft/recraft-v4-vector",name:"Recraft: Recraft V4 Vector",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1":{id:"recraft/recraft-v4.1",name:"Recraft: Recraft V4.1",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1-pro":{id:"recraft/recraft-v4.1-pro",name:"Recraft: Recraft V4.1 Pro",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1-pro-vector":{id:"recraft/recraft-v4.1-pro-vector",name:"Recraft: Recraft V4.1 Pro Vector",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1-utility":{id:"recraft/recraft-v4.1-utility",name:"Recraft: Recraft V4.1 Utility",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1-utility-pro":{id:"recraft/recraft-v4.1-utility-pro",name:"Recraft: Recraft V4.1 Utility Pro",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1-vector":{id:"recraft/recraft-v4.1-vector",name:"Recraft: Recraft V4.1 Vector",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"sourceful/riverflow-v2-fast":{id:"sourceful/riverflow-v2-fast",name:"Sourceful: Riverflow V2 Fast",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"sourceful/riverflow-v2-fast-preview":{id:"sourceful/riverflow-v2-fast-preview",name:"Sourceful: Riverflow V2 Fast Preview",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"sourceful/riverflow-v2-max-preview":{id:"sourceful/riverflow-v2-max-preview",name:"Sourceful: Riverflow V2 Max Preview",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"sourceful/riverflow-v2-pro":{id:"sourceful/riverflow-v2-pro",name:"Sourceful: Riverflow V2 Pro",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"sourceful/riverflow-v2-standard-preview":{id:"sourceful/riverflow-v2-standard-preview",name:"Sourceful: Riverflow V2 Standard Preview",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"x-ai/grok-imagine-image-quality":{id:"x-ai/grok-imagine-image-quality",name:"xAI: Grok Imagine Image Quality",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}}};var yLF=new Map;for(let[B,Q]of Object.entries(qgQ)){let F=new Map;for(let[U,I]of Object.entries(Q))F.set(U,I);yLF.set(B,F)}var MLF=new Map;function TLF(B,Q){return(F,U,I)=>{if(F.api!==B)throw Error(`Mismatched api: ${F.api} expected ${B}`);return Q(F,U,I)}}function jgQ(B,Q){MLF.set(B.api,{provider:{api:B.api,generateImages:TLF(B.api,B.generateImages)},sourceId:Q})}var pgQ;function hLF(B,Q){return{api:B.api,provider:B.provider,model:B.id,output:[],stopReason:"error",errorMessage:Q instanceof Error?Q.message:String(Q),timestamp:Date.now()}}function kLF(){return pgQ||=Promise.resolve().then(() => (igQ(),ngQ)).then((B)=>B),pgQ}var dLF=async(B,Q,F)=>{try{return await(await kLF()).generateImagesOpenRouter(B,Q,F)}catch(U){return hLF(B,U)}};function $LF(){jgQ({api:"openrouter-images",generateImages:dLF})}$LF();WA();ON();ON();var w5F=function(B,Q){if(typeof B==="string"&&/^\.\.?\//.test(B))return B.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(F,U,I,G,Z){return U?Q?".jsx":".js":I&&(!G||!Z)?F:I+G+"."+Z.toLowerCase()+"js"});return B},S5F=(B)=>{let Q=import.meta.url.endsWith(".js")?B.replace(/\.ts$/,".js"):B;return import(w5F(Q))},gbQ,VbQ,bbQ,XbQ,CbQ,RbQ,NbQ,AbQ,YbQ,LbQ;function HbQ(B,Q){(async()=>{for await(let F of Q)B.push(F);B.end()})()}function JbQ(B,Q){return{role:"assistant",content:[],api:B.api,provider:B.provider,model:B.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"error",errorMessage:Q instanceof Error?Q.message:String(Q),timestamp:Date.now()}}function bJ(B){return(Q,F,U)=>{let I=new nW;return B().then((G)=>{let Z=G.stream(Q,F,U);HbQ(I,Z)}).catch((G)=>{let Z=JbQ(Q,G);I.push({type:"error",reason:"error",error:Z}),I.end(Z)}),I}}function XJ(B){return(Q,F,U)=>{let I=new nW;return B().then((G)=>{let Z=G.streamSimple(Q,F,U);HbQ(I,Z)}).catch((G)=>{let Z=JbQ(Q,G);I.push({type:"error",reason:"error",error:Z}),I.end(Z)}),I}}function xbQ(){return gbQ||=Promise.resolve().then(() => (ZVQ(),GVQ)).then((B)=>{let Q=B;return{stream:Q.streamAnthropic,streamSimple:Q.streamSimpleAnthropic}}),gbQ}function EbQ(){return VbQ||=Promise.resolve().then(() => (VVQ(),gVQ)).then((B)=>{let Q=B;return{stream:Q.streamAzureOpenAIResponses,streamSimple:Q.streamSimpleAzureOpenAIResponses}}),VbQ}function DbQ(){return bbQ||=Promise.resolve().then(() => (RVQ(),CVQ)).then((B)=>{let Q=B;return{stream:Q.streamGoogle,streamSimple:Q.streamSimpleGoogle}}),bbQ}function zbQ(){return XbQ||=Promise.resolve().then(() => (HVQ(),LVQ)).then((B)=>{let Q=B;return{stream:Q.streamGoogleVertex,streamSimple:Q.streamSimpleGoogleVertex}}),XbQ}function wbQ(){return CbQ||=Promise.resolve().then(() => (wVQ(),zVQ)).then((B)=>{let Q=B;return{stream:Q.streamMistral,streamSimple:Q.streamSimpleMistral}}),CbQ}function SbQ(){return RbQ||=Promise.resolve().then(() => (aVQ(),pVQ)).then((B)=>{let Q=B;return{stream:Q.streamOpenAICodexResponses,streamSimple:Q.streamSimpleOpenAICodexResponses}}),RbQ}function ybQ(){return NbQ||=Promise.resolve().then(() => (FbQ(),QbQ)).then((B)=>{let Q=B;return{stream:Q.streamOpenAICompletions,streamSimple:Q.streamSimpleOpenAICompletions}}),NbQ}function MbQ(){return AbQ||=Promise.resolve().then(() => (WbQ(),ZbQ)).then((B)=>{let Q=B;return{stream:Q.streamOpenAIResponses,streamSimple:Q.streamSimpleOpenAIResponses}}),AbQ}function TbQ(){if(YbQ)return Promise.resolve(YbQ);return LbQ||=S5F("./amazon-bedrock.ts").then((B)=>{let Q=B;return{stream:Q.streamBedrock,streamSimple:Q.streamSimpleBedrock}}),LbQ}var y5F=bJ(xbQ),M5F=XJ(xbQ),T5F=bJ(EbQ),m5F=XJ(EbQ),O5F=bJ(DbQ),c5F=XJ(DbQ),K5F=bJ(zbQ),h5F=XJ(zbQ),k5F=bJ(wbQ),d5F=XJ(wbQ),$5F=bJ(SbQ),_5F=XJ(SbQ),v5F=bJ(ybQ),P5F=XJ(ybQ),f5F=bJ(MbQ),l5F=XJ(MbQ),u5F=bJ(TbQ),q5F=XJ(TbQ);function j5F(){GA({api:"anthropic-messages",stream:y5F,streamSimple:M5F}),GA({api:"openai-completions",stream:v5F,streamSimple:P5F}),GA({api:"mistral-conversations",stream:k5F,streamSimple:d5F}),GA({api:"openai-responses",stream:f5F,streamSimple:l5F}),GA({api:"azure-openai-responses",stream:T5F,streamSimple:m5F}),GA({api:"openai-codex-responses",stream:$5F,streamSimple:_5F}),GA({api:"google-generative-ai",stream:O5F,streamSimple:c5F}),GA({api:"google-vertex",stream:K5F,streamSimple:h5F}),GA({api:"bedrock-converse-stream",stream:u5F,streamSimple:q5F})}j5F();yRB();ZA();ON();LT();var wb={};WU(wb,{IsUndefined:()=>xW,IsUint8Array:()=>RJ,IsSymbol:()=>dRB,IsString:()=>IG,IsRegExp:()=>rh,IsObject:()=>mI,IsNumber:()=>PR,IsNull:()=>kRB,IsIterator:()=>hRB,IsFunction:()=>KRB,IsDate:()=>Kz,IsBoolean:()=>CJ,IsBigInt:()=>oh,IsAsyncIterator:()=>cRB,IsArray:()=>JW,HasPropertyKey:()=>pi});function pi(B,Q){return Q in B}function cRB(B){return mI(B)&&!JW(B)&&!RJ(B)&&Symbol.asyncIterator in B}function JW(B){return Array.isArray(B)}function oh(B){return typeof B==="bigint"}function CJ(B){return typeof B==="boolean"}function Kz(B){return B instanceof globalThis.Date}function KRB(B){return typeof B==="function"}function hRB(B){return mI(B)&&!JW(B)&&!RJ(B)&&Symbol.iterator in B}function kRB(B){return B===null}function PR(B){return typeof B==="number"}function mI(B){return typeof B==="object"&&B!==null}function rh(B){return B instanceof globalThis.RegExp}function IG(B){return typeof B==="string"}function dRB(B){return typeof B==="symbol"}function RJ(B){return B instanceof globalThis.Uint8Array}function xW(B){return B===void 0}function n5F(B){return B.map((Q)=>ai(Q))}function i5F(B){return new Date(B.getTime())}function p5F(B){return new Uint8Array(B)}function a5F(B){return new RegExp(B.source,B.flags)}function o5F(B){let Q={};for(let F of Object.getOwnPropertyNames(B))Q[F]=ai(B[F]);for(let F of Object.getOwnPropertySymbols(B))Q[F]=ai(B[F]);return Q}function ai(B){return JW(B)?n5F(B):Kz(B)?i5F(B):RJ(B)?p5F(B):rh(B)?a5F(B):mI(B)?o5F(B):B}function nG(B){return ai(B)}function zT(B,Q){return Q===void 0?nG(B):nG({...Q,...B})}function mbQ(B){return B!==null&&typeof B==="object"}function ObQ(B){return globalThis.Array.isArray(B)&&!globalThis.ArrayBuffer.isView(B)}function cbQ(B){return B===void 0}function KbQ(B){return typeof B==="number"}var oi;(function(B){B.InstanceMode="default",B.ExactOptionalPropertyTypes=!1,B.AllowArrayObject=!1,B.AllowNaN=!1,B.AllowNullVoid=!1;function Q(Z,W){return B.ExactOptionalPropertyTypes?W in Z:Z[W]!==void 0}B.IsExactOptionalProperty=Q;function F(Z){let W=mbQ(Z);return B.AllowArrayObject?W:W&&!ObQ(Z)}B.IsObjectLike=F;function U(Z){return F(Z)&&!(Z instanceof Date)&&!(Z instanceof Uint8Array)}B.IsRecordLike=U;function I(Z){return B.AllowNaN?KbQ(Z):Number.isFinite(Z)}B.IsNumberLike=I;function G(Z){let W=cbQ(Z);return B.AllowNullVoid?W||Z===null:W}B.IsVoidLike=G})(oi||(oi={}));function r5F(B){return globalThis.Object.freeze(B).map((Q)=>sh(Q))}function s5F(B){return B}function t5F(B){return B}function e5F(B){return B}function BxF(B){let Q={};for(let F of Object.getOwnPropertyNames(B))Q[F]=sh(B[F]);for(let F of Object.getOwnPropertySymbols(B))Q[F]=sh(B[F]);return globalThis.Object.freeze(Q)}function sh(B){return JW(B)?r5F(B):Kz(B)?s5F(B):RJ(B)?t5F(B):rh(B)?e5F(B):mI(B)?BxF(B):B}function UQ(B,Q){let F=Q!==void 0?{...Q,...B}:B;switch(oi.InstanceMode){case"freeze":return sh(F);case"clone":return nG(F);default:return F}}class KV extends Error{constructor(B){super(B)}}var iW=Symbol.for("TypeBox.Transform"),VA=Symbol.for("TypeBox.Readonly"),hV=Symbol.for("TypeBox.Optional"),cN=Symbol.for("TypeBox.Hint"),zQ=Symbol.for("TypeBox.Kind");function wT(B){return mI(B)&&B[VA]==="Readonly"}function SC(B){return mI(B)&&B[hV]==="Optional"}function $RB(B){return J0(B,"Any")}function _RB(B){return J0(B,"Argument")}function bA(B){return J0(B,"Array")}function hz(B){return J0(B,"AsyncIterator")}function kz(B){return J0(B,"BigInt")}function NJ(B){return J0(B,"Boolean")}function XA(B){return J0(B,"Computed")}function CA(B){return J0(B,"Constructor")}function QxF(B){return J0(B,"Date")}function RA(B){return J0(B,"Function")}function NA(B){return J0(B,"Integer")}function wZ(B){return J0(B,"Intersect")}function dz(B){return J0(B,"Iterator")}function J0(B,Q){return mI(B)&&zQ in B&&B[zQ]===Q}function ri(B){return CJ(B)||PR(B)||IG(B)}function fR(B){return J0(B,"Literal")}function lR(B){return J0(B,"MappedKey")}function iG(B){return J0(B,"MappedResult")}function r9(B){return J0(B,"Never")}function FxF(B){return J0(B,"Not")}function th(B){return J0(B,"Null")}function AA(B){return J0(B,"Number")}function EW(B){return J0(B,"Object")}function $z(B){return J0(B,"Promise")}function _z(B){return J0(B,"Record")}function UW(B){return J0(B,"Ref")}function vRB(B){return J0(B,"RegExp")}function AJ(B){return J0(B,"String")}function eh(B){return J0(B,"Symbol")}function uR(B){return J0(B,"TemplateLiteral")}function UxF(B){return J0(B,"This")}function s9(B){return mI(B)&&iW in B}function qR(B){return J0(B,"Tuple")}function Bk(B){return J0(B,"Undefined")}function y0(B){return J0(B,"Union")}function IxF(B){return J0(B,"Uint8Array")}function GxF(B){return J0(B,"Unknown")}function ZxF(B){return J0(B,"Unsafe")}function WxF(B){return J0(B,"Void")}function gxF(B){return mI(B)&&zQ in B&&IG(B[zQ])}function jR(B){return $RB(B)||_RB(B)||bA(B)||NJ(B)||kz(B)||hz(B)||XA(B)||CA(B)||QxF(B)||RA(B)||NA(B)||wZ(B)||dz(B)||fR(B)||lR(B)||iG(B)||r9(B)||FxF(B)||th(B)||AA(B)||EW(B)||$z(B)||_z(B)||UW(B)||vRB(B)||AJ(B)||eh(B)||uR(B)||UxF(B)||qR(B)||Bk(B)||y0(B)||IxF(B)||GxF(B)||ZxF(B)||WxF(B)||gxF(B)}var SB={};WU(SB,{TypeGuardUnknownTypeError:()=>hbQ,IsVoid:()=>xXQ,IsUnsafe:()=>JXQ,IsUnknown:()=>HXQ,IsUnionLiteral:()=>LxF,IsUnion:()=>lRB,IsUndefined:()=>YXQ,IsUint8Array:()=>LXQ,IsTuple:()=>AXQ,IsTransform:()=>NXQ,IsThis:()=>RXQ,IsTemplateLiteral:()=>CXQ,IsSymbol:()=>XXQ,IsString:()=>bXQ,IsSchema:()=>tg,IsRegExp:()=>VXQ,IsRef:()=>gXQ,IsRecursive:()=>YxF,IsRecord:()=>WXQ,IsReadonly:()=>CxF,IsProperties:()=>si,IsPromise:()=>ZXQ,IsOptional:()=>RxF,IsObject:()=>GXQ,IsNumber:()=>IXQ,IsNull:()=>UXQ,IsNot:()=>FXQ,IsNever:()=>QXQ,IsMappedResult:()=>BXQ,IsMappedKey:()=>ebQ,IsLiteralValue:()=>tbQ,IsLiteralString:()=>rbQ,IsLiteralNumber:()=>sbQ,IsLiteralBoolean:()=>AxF,IsLiteral:()=>Fk,IsKindOf:()=>B0,IsKind:()=>EXQ,IsIterator:()=>obQ,IsIntersect:()=>abQ,IsInteger:()=>pbQ,IsImport:()=>NxF,IsFunction:()=>ibQ,IsDate:()=>nbQ,IsConstructor:()=>jbQ,IsComputed:()=>qbQ,IsBoolean:()=>ubQ,IsBigInt:()=>lbQ,IsAsyncIterator:()=>fbQ,IsArray:()=>PbQ,IsArgument:()=>vbQ,IsAny:()=>_bQ});class hbQ extends KV{}var VxF=["Argument","Any","Array","AsyncIterator","BigInt","Boolean","Computed","Constructor","Date","Enum","Function","Integer","Intersect","Iterator","Literal","MappedKey","MappedResult","Not","Null","Number","Object","Promise","Record","Ref","RegExp","String","Symbol","TemplateLiteral","This","Tuple","Undefined","Union","Uint8Array","Unknown","Void"];function kbQ(B){try{return new RegExp(B),!0}catch{return!1}}function PRB(B){if(!IG(B))return!1;for(let Q=0;Q<B.length;Q++){let F=B.charCodeAt(Q);if(F>=7&&F<=13||F===27||F===127)return!1}return!0}function dbQ(B){return fRB(B)||tg(B)}function Qk(B){return xW(B)||oh(B)}function GG(B){return xW(B)||PR(B)}function fRB(B){return xW(B)||CJ(B)}function OI(B){return xW(B)||IG(B)}function bxF(B){return xW(B)||IG(B)&&PRB(B)&&kbQ(B)}function XxF(B){return xW(B)||IG(B)&&PRB(B)}function $bQ(B){return xW(B)||tg(B)}function CxF(B){return mI(B)&&B[VA]==="Readonly"}function RxF(B){return mI(B)&&B[hV]==="Optional"}function _bQ(B){return B0(B,"Any")&&OI(B.$id)}function vbQ(B){return B0(B,"Argument")&&PR(B.index)}function PbQ(B){return B0(B,"Array")&&B.type==="array"&&OI(B.$id)&&tg(B.items)&&GG(B.minItems)&&GG(B.maxItems)&&fRB(B.uniqueItems)&&$bQ(B.contains)&&GG(B.minContains)&&GG(B.maxContains)}function fbQ(B){return B0(B,"AsyncIterator")&&B.type==="AsyncIterator"&&OI(B.$id)&&tg(B.items)}function lbQ(B){return B0(B,"BigInt")&&B.type==="bigint"&&OI(B.$id)&&Qk(B.exclusiveMaximum)&&Qk(B.exclusiveMinimum)&&Qk(B.maximum)&&Qk(B.minimum)&&Qk(B.multipleOf)}function ubQ(B){return B0(B,"Boolean")&&B.type==="boolean"&&OI(B.$id)}function qbQ(B){return B0(B,"Computed")&&IG(B.target)&&JW(B.parameters)&&B.parameters.every((Q)=>tg(Q))}function jbQ(B){return B0(B,"Constructor")&&B.type==="Constructor"&&OI(B.$id)&&JW(B.parameters)&&B.parameters.every((Q)=>tg(Q))&&tg(B.returns)}function nbQ(B){return B0(B,"Date")&&B.type==="Date"&&OI(B.$id)&&GG(B.exclusiveMaximumTimestamp)&&GG(B.exclusiveMinimumTimestamp)&&GG(B.maximumTimestamp)&&GG(B.minimumTimestamp)&&GG(B.multipleOfTimestamp)}function ibQ(B){return B0(B,"Function")&&B.type==="Function"&&OI(B.$id)&&JW(B.parameters)&&B.parameters.every((Q)=>tg(Q))&&tg(B.returns)}function NxF(B){return B0(B,"Import")&&pi(B,"$defs")&&mI(B.$defs)&&si(B.$defs)&&pi(B,"$ref")&&IG(B.$ref)&&B.$ref in B.$defs}function pbQ(B){return B0(B,"Integer")&&B.type==="integer"&&OI(B.$id)&&GG(B.exclusiveMaximum)&&GG(B.exclusiveMinimum)&&GG(B.maximum)&&GG(B.minimum)&&GG(B.multipleOf)}function si(B){return mI(B)&&Object.entries(B).every(([Q,F])=>PRB(Q)&&tg(F))}function abQ(B){return B0(B,"Intersect")&&(IG(B.type)&&B.type!=="object"?!1:!0)&&JW(B.allOf)&&B.allOf.every((Q)=>tg(Q)&&!NXQ(Q))&&OI(B.type)&&(fRB(B.unevaluatedProperties)||$bQ(B.unevaluatedProperties))&&OI(B.$id)}function obQ(B){return B0(B,"Iterator")&&B.type==="Iterator"&&OI(B.$id)&&tg(B.items)}function B0(B,Q){return mI(B)&&zQ in B&&B[zQ]===Q}function rbQ(B){return Fk(B)&&IG(B.const)}function sbQ(B){return Fk(B)&&PR(B.const)}function AxF(B){return Fk(B)&&CJ(B.const)}function Fk(B){return B0(B,"Literal")&&OI(B.$id)&&tbQ(B.const)}function tbQ(B){return CJ(B)||PR(B)||IG(B)}function ebQ(B){return B0(B,"MappedKey")&&JW(B.keys)&&B.keys.every((Q)=>PR(Q)||IG(Q))}function BXQ(B){return B0(B,"MappedResult")&&si(B.properties)}function QXQ(B){return B0(B,"Never")&&mI(B.not)&&Object.getOwnPropertyNames(B.not).length===0}function FXQ(B){return B0(B,"Not")&&tg(B.not)}function UXQ(B){return B0(B,"Null")&&B.type==="null"&&OI(B.$id)}function IXQ(B){return B0(B,"Number")&&B.type==="number"&&OI(B.$id)&&GG(B.exclusiveMaximum)&&GG(B.exclusiveMinimum)&&GG(B.maximum)&&GG(B.minimum)&&GG(B.multipleOf)}function GXQ(B){return B0(B,"Object")&&B.type==="object"&&OI(B.$id)&&si(B.properties)&&dbQ(B.additionalProperties)&&GG(B.minProperties)&&GG(B.maxProperties)}function ZXQ(B){return B0(B,"Promise")&&B.type==="Promise"&&OI(B.$id)&&tg(B.item)}function WXQ(B){return B0(B,"Record")&&B.type==="object"&&OI(B.$id)&&dbQ(B.additionalProperties)&&mI(B.patternProperties)&&((Q)=>{let F=Object.getOwnPropertyNames(Q.patternProperties);return F.length===1&&kbQ(F[0])&&mI(Q.patternProperties)&&tg(Q.patternProperties[F[0]])})(B)}function YxF(B){return mI(B)&&cN in B&&B[cN]==="Recursive"}function gXQ(B){return B0(B,"Ref")&&OI(B.$id)&&IG(B.$ref)}function VXQ(B){return B0(B,"RegExp")&&OI(B.$id)&&IG(B.source)&&IG(B.flags)&&GG(B.maxLength)&&GG(B.minLength)}function bXQ(B){return B0(B,"String")&&B.type==="string"&&OI(B.$id)&&GG(B.minLength)&&GG(B.maxLength)&&bxF(B.pattern)&&XxF(B.format)}function XXQ(B){return B0(B,"Symbol")&&B.type==="symbol"&&OI(B.$id)}function CXQ(B){return B0(B,"TemplateLiteral")&&B.type==="string"&&IG(B.pattern)&&B.pattern[0]==="^"&&B.pattern[B.pattern.length-1]==="$"}function RXQ(B){return B0(B,"This")&&OI(B.$id)&&IG(B.$ref)}function NXQ(B){return mI(B)&&iW in B}function AXQ(B){return B0(B,"Tuple")&&B.type==="array"&&OI(B.$id)&&PR(B.minItems)&&PR(B.maxItems)&&B.minItems===B.maxItems&&(xW(B.items)&&xW(B.additionalItems)&&B.minItems===0||JW(B.items)&&B.items.every((Q)=>tg(Q)))}function YXQ(B){return B0(B,"Undefined")&&B.type==="undefined"&&OI(B.$id)}function LxF(B){return lRB(B)&&B.anyOf.every((Q)=>rbQ(Q)||sbQ(Q))}function lRB(B){return B0(B,"Union")&&OI(B.$id)&&mI(B)&&JW(B.anyOf)&&B.anyOf.every((Q)=>tg(Q))}function LXQ(B){return B0(B,"Uint8Array")&&B.type==="Uint8Array"&&OI(B.$id)&&GG(B.minByteLength)&&GG(B.maxByteLength)}function HXQ(B){return B0(B,"Unknown")&&OI(B.$id)}function JXQ(B){return B0(B,"Unsafe")}function xXQ(B){return B0(B,"Void")&&B.type==="void"&&OI(B.$id)}function EXQ(B){return mI(B)&&zQ in B&&IG(B[zQ])&&!VxF.includes(B[zQ])}function tg(B){return mI(B)&&(_bQ(B)||vbQ(B)||PbQ(B)||ubQ(B)||lbQ(B)||fbQ(B)||qbQ(B)||jbQ(B)||nbQ(B)||ibQ(B)||pbQ(B)||abQ(B)||obQ(B)||Fk(B)||ebQ(B)||BXQ(B)||QXQ(B)||FXQ(B)||UXQ(B)||IXQ(B)||GXQ(B)||ZXQ(B)||WXQ(B)||gXQ(B)||VXQ(B)||bXQ(B)||XXQ(B)||CXQ(B)||RXQ(B)||AXQ(B)||YXQ(B)||lRB(B)||LXQ(B)||HXQ(B)||JXQ(B)||xXQ(B)||EXQ(B))}var DXQ="(true|false)",ti="(0|[1-9][0-9]*)",zXQ="(.*)";var t9="^(0|[1-9][0-9]*)$",e9="^(.*)$",wXQ="^(?!.*)$";function SXQ(B,Q){return B.includes(Q)}function yXQ(B){return[...new Set(B)]}function HxF(B,Q){return B.filter((F)=>Q.includes(F))}function JxF(B,Q){return B.reduce((F,U)=>{return HxF(F,U)},Q)}function MXQ(B){return B.length===1?B[0]:B.length>1?JxF(B.slice(1),B[0]):[]}function TXQ(B){let Q=[];for(let F of B)Q.push(...F);return Q}function BE(B){return UQ({[zQ]:"Any"},B)}function ST(B,Q){return UQ({[zQ]:"Array",type:"array",items:B},Q)}function mXQ(B){return UQ({[zQ]:"Argument",index:B})}function yT(B,Q){return UQ({[zQ]:"AsyncIterator",type:"AsyncIterator",items:B},Q)}function mG(B,Q,F){return UQ({[zQ]:"Computed",target:B,parameters:Q},F)}function xxF(B,Q){let{[Q]:F,...U}=B;return U}function SZ(B,Q){return Q.reduce((F,U)=>xxF(F,U),B)}function M0(B){return UQ({[zQ]:"Never",not:{}},B)}function f0(B){return UQ({[zQ]:"MappedResult",properties:B})}function MT(B,Q,F){return UQ({[zQ]:"Constructor",type:"Constructor",parameters:B,returns:Q},F)}function eY(B,Q,F){return UQ({[zQ]:"Function",type:"Function",parameters:B,returns:Q},F)}function Uk(B,Q){return UQ({[zQ]:"Union",anyOf:B},Q)}function ExF(B){return B.some((Q)=>SC(Q))}function OXQ(B){return B.map((Q)=>SC(Q)?DxF(Q):Q)}function DxF(B){return SZ(B,[hV])}function zxF(B,Q){return ExF(B)?Sb(Uk(OXQ(B),Q)):Uk(OXQ(B),Q)}function BL(B,Q){return B.length===1?UQ(B[0],Q):B.length===0?M0(Q):zxF(B,Q)}function AI(B,Q){return B.length===0?M0(Q):B.length===1?UQ(B[0],Q):Uk(B,Q)}class uRB extends KV{}function wxF(B){return B.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function qRB(B,Q,F){return B[Q]===F&&B.charCodeAt(Q-1)!==92}function LJ(B,Q){return qRB(B,Q,"(")}function Ik(B,Q){return qRB(B,Q,")")}function cXQ(B,Q){return qRB(B,Q,"|")}function SxF(B){if(!(LJ(B,0)&&Ik(B,B.length-1)))return!1;let Q=0;for(let F=0;F<B.length;F++){if(LJ(B,F))Q+=1;if(Ik(B,F))Q-=1;if(Q===0&&F!==B.length-1)return!1}return!0}function yxF(B){return B.slice(1,B.length-1)}function MxF(B){let Q=0;for(let F=0;F<B.length;F++){if(LJ(B,F))Q+=1;if(Ik(B,F))Q-=1;if(cXQ(B,F)&&Q===0)return!0}return!1}function TxF(B){for(let Q=0;Q<B.length;Q++)if(LJ(B,Q))return!0;return!1}function mxF(B){let[Q,F]=[0,0],U=[];for(let G=0;G<B.length;G++){if(LJ(B,G))Q+=1;if(Ik(B,G))Q-=1;if(cXQ(B,G)&&Q===0){let Z=B.slice(F,G);if(Z.length>0)U.push(TT(Z));F=G+1}}let I=B.slice(F);if(I.length>0)U.push(TT(I));if(U.length===0)return{type:"const",const:""};if(U.length===1)return U[0];return{type:"or",expr:U}}function OxF(B){function Q(I,G){if(!LJ(I,G))throw new uRB("TemplateLiteralParser: Index must point to open parens");let Z=0;for(let W=G;W<I.length;W++){if(LJ(I,W))Z+=1;if(Ik(I,W))Z-=1;if(Z===0)return[G,W]}throw new uRB("TemplateLiteralParser: Unclosed group parens in expression")}function F(I,G){for(let Z=G;Z<I.length;Z++)if(LJ(I,Z))return[G,Z];return[G,I.length]}let U=[];for(let I=0;I<B.length;I++)if(LJ(B,I)){let[G,Z]=Q(B,I),W=B.slice(G,Z+1);U.push(TT(W)),I=Z}else{let[G,Z]=F(B,I),W=B.slice(G,Z);if(W.length>0)U.push(TT(W));I=Z-1}return U.length===0?{type:"const",const:""}:U.length===1?U[0]:{type:"and",expr:U}}function TT(B){return SxF(B)?TT(yxF(B)):MxF(B)?mxF(B):TxF(B)?OxF(B):{type:"const",const:wxF(B)}}function mT(B){return TT(B.slice(1,B.length-1))}class KXQ extends KV{}function cxF(B){return B.type==="or"&&B.expr.length===2&&B.expr[0].type==="const"&&B.expr[0].const==="0"&&B.expr[1].type==="const"&&B.expr[1].const==="[1-9][0-9]*"}function KxF(B){return B.type==="or"&&B.expr.length===2&&B.expr[0].type==="const"&&B.expr[0].const==="true"&&B.expr[1].type==="const"&&B.expr[1].const==="false"}function hxF(B){return B.type==="const"&&B.const===".*"}function vz(B){return cxF(B)||hxF(B)?!1:KxF(B)?!0:B.type==="and"?B.expr.every((Q)=>vz(Q)):B.type==="or"?B.expr.every((Q)=>vz(Q)):B.type==="const"?!0:(()=>{throw new KXQ("Unknown expression type")})()}function hXQ(B){let Q=mT(B.pattern);return vz(Q)}class kXQ extends KV{}function*dXQ(B){if(B.length===1)return yield*B[0];for(let Q of B[0])for(let F of dXQ(B.slice(1)))yield`${Q}${F}`}function*kxF(B){return yield*dXQ(B.expr.map((Q)=>[...Gk(Q)]))}function*dxF(B){for(let Q of B.expr)yield*Gk(Q)}function*$xF(B){return yield B.const}function*Gk(B){return B.type==="and"?yield*kxF(B):B.type==="or"?yield*dxF(B):B.type==="const"?yield*$xF(B):(()=>{throw new kXQ("Unknown expression")})()}function ei(B){let Q=mT(B.pattern);return vz(Q)?[...Gk(Q)]:[]}function GI(B,Q){return UQ({[zQ]:"Literal",const:B,type:typeof B},Q)}function Bp(B){return UQ({[zQ]:"Boolean",type:"boolean"},B)}function OT(B){return UQ({[zQ]:"BigInt",type:"bigint"},B)}function KN(B){return UQ({[zQ]:"Number",type:"number"},B)}function YA(B){return UQ({[zQ]:"String",type:"string"},B)}function*_xF(B){let Q=B.trim().replace(/"|'/g,"");return Q==="boolean"?yield Bp():Q==="number"?yield KN():Q==="bigint"?yield OT():Q==="string"?yield YA():yield(()=>{let F=Q.split("|").map((U)=>GI(U.trim()));return F.length===0?M0():F.length===1?F[0]:BL(F)})()}function*vxF(B){if(B[1]!=="{"){let Q=GI("$"),F=jRB(B.slice(1));return yield*[Q,...F]}for(let Q=2;Q<B.length;Q++)if(B[Q]==="}"){let F=_xF(B.slice(2,Q)),U=jRB(B.slice(Q+1));return yield*[...F,...U]}yield GI(B)}function*jRB(B){for(let Q=0;Q<B.length;Q++)if(B[Q]==="$"){let F=GI(B.slice(0,Q)),U=vxF(B.slice(Q));return yield*[F,...U]}yield GI(B)}function $XQ(B){return[...jRB(B)]}class _XQ extends KV{}function PxF(B){return B.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function vXQ(B,Q){return uR(B)?B.pattern.slice(1,B.pattern.length-1):y0(B)?`(${B.anyOf.map((F)=>vXQ(F,Q)).join("|")})`:AA(B)?`${Q}${ti}`:NA(B)?`${Q}${ti}`:kz(B)?`${Q}${ti}`:AJ(B)?`${Q}${zXQ}`:fR(B)?`${Q}${PxF(B.const.toString())}`:NJ(B)?`${Q}${DXQ}`:(()=>{throw new _XQ(`Unexpected Kind '${B[zQ]}'`)})()}function nRB(B){return`^${B.map((Q)=>vXQ(Q,"")).join("")}$`}function Pz(B){let F=ei(B).map((U)=>GI(U));return BL(F)}function Qp(B,Q){let F=IG(B)?nRB($XQ(B)):nRB(B);return UQ({[zQ]:"TemplateLiteral",type:"string",pattern:F},Q)}function fxF(B){return ei(B).map((F)=>F.toString())}function lxF(B){let Q=[];for(let F of B)Q.push(...yC(F));return Q}function uxF(B){return[B.toString()]}function yC(B){return[...new Set(uR(B)?fxF(B):y0(B)?lxF(B.anyOf):fR(B)?uxF(B.const):AA(B)?["[number]"]:NA(B)?["[number]"]:[])]}function qxF(B,Q,F){let U={};for(let I of Object.getOwnPropertyNames(Q))U[I]=QE(B,yC(Q[I]),F);return U}function jxF(B,Q,F){return qxF(B,Q.properties,F)}function PXQ(B,Q,F){let U=jxF(B,Q,F);return f0(U)}function lXQ(B,Q){return B.map((F)=>uXQ(F,Q))}function nxF(B){return B.filter((Q)=>!r9(Q))}function ixF(B,Q){return Fp(nxF(lXQ(B,Q)))}function pxF(B){return B.some((Q)=>r9(Q))?[]:B}function axF(B,Q){return BL(pxF(lXQ(B,Q)))}function oxF(B,Q){return Q in B?B[Q]:Q==="[number]"?BL(B):M0()}function rxF(B,Q){return Q==="[number]"?B:M0()}function sxF(B,Q){return Q in B?B[Q]:M0()}function uXQ(B,Q){return wZ(B)?ixF(B.allOf,Q):y0(B)?axF(B.anyOf,Q):qR(B)?oxF(B.items??[],Q):bA(B)?rxF(B.items,Q):EW(B)?sxF(B.properties,Q):M0()}function iRB(B,Q){return Q.map((F)=>uXQ(B,F))}function fXQ(B,Q){return BL(iRB(B,Q))}function QE(B,Q,F){if(UW(B)||UW(Q)){if(!jR(B)||!jR(Q))throw new KV("Index types using Ref parameters require both Type and Key to be of TSchema");return mG("Index",[B,Q])}if(iG(Q))return PXQ(B,Q,F);if(lR(Q))return qXQ(B,Q,F);return UQ(jR(Q)?fXQ(B,yC(Q)):fXQ(B,Q),F)}function txF(B,Q,F){return{[Q]:QE(B,[Q],nG(F))}}function exF(B,Q,F){return Q.reduce((U,I)=>{return{...U,...txF(B,I,F)}},{})}function B9F(B,Q,F){return exF(B,Q.keys,F)}function qXQ(B,Q,F){let U=B9F(B,Q,F);return f0(U)}function cT(B,Q){return UQ({[zQ]:"Iterator",type:"Iterator",items:B},Q)}function Q9F(B){return globalThis.Object.keys(B).filter((Q)=>!SC(B[Q]))}function F9F(B,Q){let F=Q9F(B),U=F.length>0?{[zQ]:"Object",type:"object",required:F,properties:B}:{[zQ]:"Object",type:"object",properties:B};return UQ(U,Q)}var cI=F9F;function Up(B,Q){return UQ({[zQ]:"Promise",type:"Promise",item:B},Q)}function U9F(B){return UQ(SZ(B,[VA]))}function I9F(B){return UQ({...B,[VA]:"Readonly"})}function G9F(B,Q){return Q===!1?U9F(B):I9F(B)}function MC(B,Q){let F=Q??!0;return iG(B)?jXQ(B,F):G9F(B,F)}function Z9F(B,Q){let F={};for(let U of globalThis.Object.getOwnPropertyNames(B))F[U]=MC(B[U],Q);return F}function W9F(B,Q){return Z9F(B.properties,Q)}function jXQ(B,Q){let F=W9F(B,Q);return f0(F)}function hN(B,Q){return UQ(B.length>0?{[zQ]:"Tuple",type:"array",items:B,additionalItems:!1,minItems:B.length,maxItems:B.length}:{[zQ]:"Tuple",type:"array",minItems:B.length,maxItems:B.length},Q)}function nXQ(B,Q){return B in Q?kN(B,Q[B]):f0(Q)}function g9F(B){return{[B]:GI(B)}}function V9F(B){let Q={};for(let F of B)Q[F]=GI(F);return Q}function b9F(B,Q){return SXQ(Q,B)?g9F(B):V9F(Q)}function X9F(B,Q){let F=b9F(B,Q);return nXQ(B,F)}function Zk(B,Q){return Q.map((F)=>kN(B,F))}function C9F(B,Q){let F={};for(let U of globalThis.Object.getOwnPropertyNames(Q))F[U]=kN(B,Q[U]);return F}function kN(B,Q){let F={...Q};return SC(Q)?Sb(kN(B,SZ(Q,[hV]))):wT(Q)?MC(kN(B,SZ(Q,[VA]))):iG(Q)?nXQ(B,Q.properties):lR(Q)?X9F(B,Q.keys):CA(Q)?MT(Zk(B,Q.parameters),kN(B,Q.returns),F):RA(Q)?eY(Zk(B,Q.parameters),kN(B,Q.returns),F):hz(Q)?yT(kN(B,Q.items),F):dz(Q)?cT(kN(B,Q.items),F):wZ(Q)?yb(Zk(B,Q.allOf),F):y0(Q)?AI(Zk(B,Q.anyOf),F):qR(Q)?hN(Zk(B,Q.items??[]),F):EW(Q)?cI(C9F(B,Q.properties),F):bA(Q)?ST(kN(B,Q.items),F):$z(Q)?Up(kN(B,Q.item),F):Q}function R9F(B,Q){let F={};for(let U of B)F[U]=kN(U,Q);return F}function iXQ(B,Q,F){let U=jR(B)?yC(B):B,I=Q({[zQ]:"MappedKey",keys:U}),G=R9F(U,I);return cI(G,F)}function N9F(B){return UQ(SZ(B,[hV]))}function A9F(B){return UQ({...B,[hV]:"Optional"})}function Y9F(B,Q){return Q===!1?N9F(B):A9F(B)}function Sb(B,Q){let F=Q??!0;return iG(B)?pXQ(B,F):Y9F(B,F)}function L9F(B,Q){let F={};for(let U of globalThis.Object.getOwnPropertyNames(B))F[U]=Sb(B[U],Q);return F}function H9F(B,Q){return L9F(B.properties,Q)}function pXQ(B,Q){let F=H9F(B,Q);return f0(F)}function Wk(B,Q={}){let F=B.every((I)=>EW(I)),U=jR(Q.unevaluatedProperties)?{unevaluatedProperties:Q.unevaluatedProperties}:{};return UQ(Q.unevaluatedProperties===!1||jR(Q.unevaluatedProperties)||F?{...U,[zQ]:"Intersect",type:"object",allOf:B}:{...U,[zQ]:"Intersect",allOf:B},Q)}function J9F(B){return B.every((Q)=>SC(Q))}function x9F(B){return SZ(B,[hV])}function aXQ(B){return B.map((Q)=>SC(Q)?x9F(Q):Q)}function E9F(B,Q){return J9F(B)?Sb(Wk(aXQ(B),Q)):Wk(aXQ(B),Q)}function Fp(B,Q={}){if(B.length===1)return UQ(B[0],Q);if(B.length===0)return M0(Q);if(B.some((F)=>s9(F)))throw Error("Cannot intersect transform types");return E9F(B,Q)}function yb(B,Q){if(B.length===1)return UQ(B[0],Q);if(B.length===0)return M0(Q);if(B.some((F)=>s9(F)))throw Error("Cannot intersect transform types");return Wk(B,Q)}function QL(...B){let[Q,F]=typeof B[0]==="string"?[B[0],B[1]]:[B[0].$id,B[1]];if(typeof Q!=="string")throw new KV("Ref: $ref must be a string");return UQ({[zQ]:"Ref",$ref:Q},F)}function D9F(B,Q){return mG("Awaited",[mG(B,Q)])}function z9F(B){return mG("Awaited",[QL(B)])}function w9F(B){return yb(oXQ(B))}function S9F(B){return AI(oXQ(B))}function y9F(B){return KT(B)}function oXQ(B){return B.map((Q)=>KT(Q))}function KT(B,Q){return UQ(XA(B)?D9F(B.target,B.parameters):wZ(B)?w9F(B.allOf):y0(B)?S9F(B.anyOf):$z(B)?y9F(B.item):UW(B)?z9F(B.$ref):B,Q)}function rXQ(B){let Q=[];for(let F of B)Q.push(gk(F));return Q}function M9F(B){let Q=rXQ(B);return TXQ(Q)}function T9F(B){let Q=rXQ(B);return MXQ(Q)}function m9F(B){return B.map((Q,F)=>F.toString())}function O9F(B){return["[number]"]}function c9F(B){return globalThis.Object.getOwnPropertyNames(B)}function K9F(B){if(!h9F)return[];return globalThis.Object.getOwnPropertyNames(B).map((F)=>{return F[0]==="^"&&F[F.length-1]==="$"?F.slice(1,F.length-1):F})}function gk(B){return wZ(B)?M9F(B.allOf):y0(B)?T9F(B.anyOf):qR(B)?m9F(B.items??[]):bA(B)?O9F(B.items):EW(B)?c9F(B.properties):_z(B)?K9F(B.patternProperties):[]}var h9F=!1;function k9F(B,Q){return mG("KeyOf",[mG(B,Q)])}function d9F(B){return mG("KeyOf",[QL(B)])}function $9F(B,Q){let F=gk(B),U=_9F(F),I=BL(U);return UQ(I,Q)}function _9F(B){return B.map((Q)=>Q==="[number]"?KN():GI(Q))}function hT(B,Q){return XA(B)?k9F(B.target,B.parameters):UW(B)?d9F(B.$ref):iG(B)?sXQ(B,Q):$9F(B,Q)}function v9F(B,Q){let F={};for(let U of globalThis.Object.getOwnPropertyNames(B))F[U]=hT(B[U],nG(Q));return F}function P9F(B,Q){return v9F(B.properties,Q)}function sXQ(B,Q){let F=P9F(B,Q);return f0(F)}function f9F(B){let Q=[];for(let F of B)Q.push(...gk(F));return yXQ(Q)}function l9F(B){return B.filter((Q)=>!r9(Q))}function u9F(B,Q){let F=[];for(let U of B)F.push(...iRB(U,[Q]));return l9F(F)}function q9F(B,Q){let F={};for(let U of Q)F[U]=Fp(u9F(B,U));return F}function tXQ(B,Q){let F=f9F(B),U=q9F(B,F);return cI(U,Q)}function Ip(B){return UQ({[zQ]:"Date",type:"Date"},B)}function Gp(B){return UQ({[zQ]:"Null",type:"null"},B)}function Zp(B){return UQ({[zQ]:"Symbol",type:"symbol"},B)}function Wp(B){return UQ({[zQ]:"Undefined",type:"undefined"},B)}function gp(B){return UQ({[zQ]:"Uint8Array",type:"Uint8Array"},B)}function FE(B){return UQ({[zQ]:"Unknown"},B)}function j9F(B){return B.map((Q)=>pRB(Q,!1))}function n9F(B){let Q={};for(let F of globalThis.Object.getOwnPropertyNames(B))Q[F]=MC(pRB(B[F],!1));return Q}function Vp(B,Q){return Q===!0?B:MC(B)}function pRB(B,Q){return cRB(B)?Vp(BE(),Q):hRB(B)?Vp(BE(),Q):JW(B)?MC(hN(j9F(B))):RJ(B)?gp():Kz(B)?Ip():mI(B)?Vp(cI(n9F(B)),Q):KRB(B)?Vp(eY([],FE()),Q):xW(B)?Wp():kRB(B)?Gp():dRB(B)?Zp():oh(B)?OT():PR(B)?GI(B):CJ(B)?GI(B):IG(B)?GI(B):cI({})}function eXQ(B,Q){return UQ(pRB(B,!0),Q)}function BCQ(B,Q){return CA(B)?hN(B.parameters,Q):M0(Q)}function QCQ(B,Q){if(xW(B))throw Error("Enum undefined or empty");let F=globalThis.Object.getOwnPropertyNames(B).filter((G)=>isNaN(G)).map((G)=>B[G]),I=[...new Set(F)].map((G)=>GI(G));return AI(I,{...Q,[cN]:"Enum"})}class ZCQ extends KV{}var IQ;(function(B){B[B.Union=0]="Union",B[B.True=1]="True",B[B.False=2]="False"})(IQ||(IQ={}));function dN(B){return B===IQ.False?B:IQ.True}function kT(B){throw new ZCQ(B)}function pW(B){return SB.IsNever(B)||SB.IsIntersect(B)||SB.IsUnion(B)||SB.IsUnknown(B)||SB.IsAny(B)}function aW(B,Q){return SB.IsNever(Q)?VCQ(B,Q):SB.IsIntersect(Q)?bp(B,Q):SB.IsUnion(Q)?tRB(B,Q):SB.IsUnknown(Q)?RCQ(B,Q):SB.IsAny(Q)?sRB(B,Q):kT("StructuralRight")}function sRB(B,Q){return IQ.True}function i9F(B,Q){return SB.IsIntersect(Q)?bp(B,Q):SB.IsUnion(Q)&&Q.anyOf.some((F)=>SB.IsAny(F)||SB.IsUnknown(F))?IQ.True:SB.IsUnion(Q)?IQ.Union:SB.IsUnknown(Q)?IQ.True:SB.IsAny(Q)?IQ.True:IQ.Union}function p9F(B,Q){return SB.IsUnknown(B)?IQ.False:SB.IsAny(B)?IQ.Union:SB.IsNever(B)?IQ.True:IQ.False}function a9F(B,Q){return SB.IsObject(Q)&&Xp(Q)?IQ.True:pW(Q)?aW(B,Q):!SB.IsArray(Q)?IQ.False:dN(KI(B.items,Q.items))}function o9F(B,Q){return pW(Q)?aW(B,Q):!SB.IsAsyncIterator(Q)?IQ.False:dN(KI(B.items,Q.items))}function r9F(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsBigInt(Q)?IQ.True:IQ.False}function WCQ(B,Q){return SB.IsLiteralBoolean(B)?IQ.True:SB.IsBoolean(B)?IQ.True:IQ.False}function s9F(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsBoolean(Q)?IQ.True:IQ.False}function t9F(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):!SB.IsConstructor(Q)?IQ.False:B.parameters.length>Q.parameters.length?IQ.False:!B.parameters.every((F,U)=>dN(KI(Q.parameters[U],F))===IQ.True)?IQ.False:dN(KI(B.returns,Q.returns))}function e9F(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsDate(Q)?IQ.True:IQ.False}function BEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):!SB.IsFunction(Q)?IQ.False:B.parameters.length>Q.parameters.length?IQ.False:!B.parameters.every((F,U)=>dN(KI(Q.parameters[U],F))===IQ.True)?IQ.False:dN(KI(B.returns,Q.returns))}function gCQ(B,Q){return SB.IsLiteral(B)&&wb.IsNumber(B.const)?IQ.True:SB.IsNumber(B)||SB.IsInteger(B)?IQ.True:IQ.False}function QEF(B,Q){return SB.IsInteger(Q)||SB.IsNumber(Q)?IQ.True:pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):IQ.False}function bp(B,Q){return Q.allOf.every((F)=>KI(B,F)===IQ.True)?IQ.True:IQ.False}function FEF(B,Q){return B.allOf.some((F)=>KI(F,Q)===IQ.True)?IQ.True:IQ.False}function UEF(B,Q){return pW(Q)?aW(B,Q):!SB.IsIterator(Q)?IQ.False:dN(KI(B.items,Q.items))}function IEF(B,Q){return SB.IsLiteral(Q)&&Q.const===B.const?IQ.True:pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsString(Q)?CCQ(B,Q):SB.IsNumber(Q)?bCQ(B,Q):SB.IsInteger(Q)?gCQ(B,Q):SB.IsBoolean(Q)?WCQ(B,Q):IQ.False}function VCQ(B,Q){return IQ.False}function GEF(B,Q){return IQ.True}function FCQ(B){let[Q,F]=[B,0];while(!0){if(!SB.IsNot(Q))break;Q=Q.not,F+=1}return F%2===0?Q:FE()}function ZEF(B,Q){return SB.IsNot(B)?KI(FCQ(B),Q):SB.IsNot(Q)?KI(B,FCQ(Q)):kT("Invalid fallthrough for Not")}function WEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsNull(Q)?IQ.True:IQ.False}function bCQ(B,Q){return SB.IsLiteralNumber(B)?IQ.True:SB.IsNumber(B)||SB.IsInteger(B)?IQ.True:IQ.False}function gEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsInteger(Q)||SB.IsNumber(Q)?IQ.True:IQ.False}function TC(B,Q){return Object.getOwnPropertyNames(B.properties).length===Q}function UCQ(B){return Xp(B)}function ICQ(B){return TC(B,0)||TC(B,1)&&"description"in B.properties&&SB.IsUnion(B.properties.description)&&B.properties.description.anyOf.length===2&&(SB.IsString(B.properties.description.anyOf[0])&&SB.IsUndefined(B.properties.description.anyOf[1])||SB.IsString(B.properties.description.anyOf[1])&&SB.IsUndefined(B.properties.description.anyOf[0]))}function aRB(B){return TC(B,0)}function GCQ(B){return TC(B,0)}function VEF(B){return TC(B,0)}function bEF(B){return TC(B,0)}function XEF(B){return Xp(B)}function CEF(B){let Q=KN();return TC(B,0)||TC(B,1)&&"length"in B.properties&&dN(KI(B.properties.length,Q))===IQ.True}function REF(B){return TC(B,0)}function Xp(B){let Q=KN();return TC(B,0)||TC(B,1)&&"length"in B.properties&&dN(KI(B.properties.length,Q))===IQ.True}function NEF(B){let Q=eY([BE()],BE());return TC(B,0)||TC(B,1)&&"then"in B.properties&&dN(KI(B.properties.then,Q))===IQ.True}function XCQ(B,Q){return KI(B,Q)===IQ.False?IQ.False:SB.IsOptional(B)&&!SB.IsOptional(Q)?IQ.False:IQ.True}function Mb(B,Q){return SB.IsUnknown(B)?IQ.False:SB.IsAny(B)?IQ.Union:SB.IsNever(B)||SB.IsLiteralString(B)&&UCQ(Q)||SB.IsLiteralNumber(B)&&aRB(Q)||SB.IsLiteralBoolean(B)&&GCQ(Q)||SB.IsSymbol(B)&&ICQ(Q)||SB.IsBigInt(B)&&VEF(Q)||SB.IsString(B)&&UCQ(Q)||SB.IsSymbol(B)&&ICQ(Q)||SB.IsNumber(B)&&aRB(Q)||SB.IsInteger(B)&&aRB(Q)||SB.IsBoolean(B)&&GCQ(Q)||SB.IsUint8Array(B)&&XEF(Q)||SB.IsDate(B)&&bEF(Q)||SB.IsConstructor(B)&&REF(Q)||SB.IsFunction(B)&&CEF(Q)?IQ.True:SB.IsRecord(B)&&SB.IsString(oRB(B))?(()=>{return Q[cN]==="Record"?IQ.True:IQ.False})():SB.IsRecord(B)&&SB.IsNumber(oRB(B))?(()=>{return TC(Q,0)?IQ.True:IQ.False})():IQ.False}function AEF(B,Q){return pW(Q)?aW(B,Q):SB.IsRecord(Q)?$N(B,Q):!SB.IsObject(Q)?IQ.False:(()=>{for(let F of Object.getOwnPropertyNames(Q.properties)){if(!(F in B.properties)&&!SB.IsOptional(Q.properties[F]))return IQ.False;if(SB.IsOptional(Q.properties[F]))return IQ.True;if(XCQ(B.properties[F],Q.properties[F])===IQ.False)return IQ.False}return IQ.True})()}function YEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)&&NEF(Q)?IQ.True:!SB.IsPromise(Q)?IQ.False:dN(KI(B.item,Q.item))}function oRB(B){return t9 in B.patternProperties?KN():(e9 in B.patternProperties)?YA():kT("Unknown record key pattern")}function rRB(B){return t9 in B.patternProperties?B.patternProperties[t9]:(e9 in B.patternProperties)?B.patternProperties[e9]:kT("Unable to get record value schema")}function $N(B,Q){let[F,U]=[oRB(Q),rRB(Q)];return SB.IsLiteralString(B)&&SB.IsNumber(F)&&dN(KI(B,U))===IQ.True?IQ.True:SB.IsUint8Array(B)&&SB.IsNumber(F)?KI(B,U):SB.IsString(B)&&SB.IsNumber(F)?KI(B,U):SB.IsArray(B)&&SB.IsNumber(F)?KI(B,U):SB.IsObject(B)?(()=>{for(let I of Object.getOwnPropertyNames(B.properties))if(XCQ(U,B.properties[I])===IQ.False)return IQ.False;return IQ.True})():IQ.False}function LEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):!SB.IsRecord(Q)?IQ.False:KI(rRB(B),rRB(Q))}function HEF(B,Q){let F=SB.IsRegExp(B)?YA():B,U=SB.IsRegExp(Q)?YA():Q;return KI(F,U)}function CCQ(B,Q){return SB.IsLiteral(B)&&wb.IsString(B.const)?IQ.True:SB.IsString(B)?IQ.True:IQ.False}function JEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsString(Q)?IQ.True:IQ.False}function xEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsSymbol(Q)?IQ.True:IQ.False}function EEF(B,Q){return SB.IsTemplateLiteral(B)?KI(Pz(B),Q):SB.IsTemplateLiteral(Q)?KI(B,Pz(Q)):kT("Invalid fallthrough for TemplateLiteral")}function DEF(B,Q){return SB.IsArray(Q)&&B.items!==void 0&&B.items.every((F)=>KI(F,Q.items)===IQ.True)}function zEF(B,Q){return SB.IsNever(B)?IQ.True:SB.IsUnknown(B)?IQ.False:SB.IsAny(B)?IQ.Union:IQ.False}function wEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)&&Xp(Q)?IQ.True:SB.IsArray(Q)&&DEF(B,Q)?IQ.True:!SB.IsTuple(Q)?IQ.False:wb.IsUndefined(B.items)&&!wb.IsUndefined(Q.items)||!wb.IsUndefined(B.items)&&wb.IsUndefined(Q.items)?IQ.False:wb.IsUndefined(B.items)&&!wb.IsUndefined(Q.items)?IQ.True:B.items.every((F,U)=>KI(F,Q.items[U])===IQ.True)?IQ.True:IQ.False}function SEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsUint8Array(Q)?IQ.True:IQ.False}function yEF(B,Q){return pW(Q)?aW(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsRecord(Q)?$N(B,Q):SB.IsVoid(Q)?mEF(B,Q):SB.IsUndefined(Q)?IQ.True:IQ.False}function tRB(B,Q){return Q.anyOf.some((F)=>KI(B,F)===IQ.True)?IQ.True:IQ.False}function MEF(B,Q){return B.anyOf.every((F)=>KI(F,Q)===IQ.True)?IQ.True:IQ.False}function RCQ(B,Q){return IQ.True}function TEF(B,Q){return SB.IsNever(Q)?VCQ(B,Q):SB.IsIntersect(Q)?bp(B,Q):SB.IsUnion(Q)?tRB(B,Q):SB.IsAny(Q)?sRB(B,Q):SB.IsString(Q)?CCQ(B,Q):SB.IsNumber(Q)?bCQ(B,Q):SB.IsInteger(Q)?gCQ(B,Q):SB.IsBoolean(Q)?WCQ(B,Q):SB.IsArray(Q)?p9F(B,Q):SB.IsTuple(Q)?zEF(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsUnknown(Q)?IQ.True:IQ.False}function mEF(B,Q){return SB.IsUndefined(B)?IQ.True:SB.IsUndefined(B)?IQ.True:IQ.False}function OEF(B,Q){return SB.IsIntersect(Q)?bp(B,Q):SB.IsUnion(Q)?tRB(B,Q):SB.IsUnknown(Q)?RCQ(B,Q):SB.IsAny(Q)?sRB(B,Q):SB.IsObject(Q)?Mb(B,Q):SB.IsVoid(Q)?IQ.True:IQ.False}function KI(B,Q){return SB.IsTemplateLiteral(B)||SB.IsTemplateLiteral(Q)?EEF(B,Q):SB.IsRegExp(B)||SB.IsRegExp(Q)?HEF(B,Q):SB.IsNot(B)||SB.IsNot(Q)?ZEF(B,Q):SB.IsAny(B)?i9F(B,Q):SB.IsArray(B)?a9F(B,Q):SB.IsBigInt(B)?r9F(B,Q):SB.IsBoolean(B)?s9F(B,Q):SB.IsAsyncIterator(B)?o9F(B,Q):SB.IsConstructor(B)?t9F(B,Q):SB.IsDate(B)?e9F(B,Q):SB.IsFunction(B)?BEF(B,Q):SB.IsInteger(B)?QEF(B,Q):SB.IsIntersect(B)?FEF(B,Q):SB.IsIterator(B)?UEF(B,Q):SB.IsLiteral(B)?IEF(B,Q):SB.IsNever(B)?GEF(B,Q):SB.IsNull(B)?WEF(B,Q):SB.IsNumber(B)?gEF(B,Q):SB.IsObject(B)?AEF(B,Q):SB.IsRecord(B)?LEF(B,Q):SB.IsString(B)?JEF(B,Q):SB.IsSymbol(B)?xEF(B,Q):SB.IsTuple(B)?wEF(B,Q):SB.IsPromise(B)?YEF(B,Q):SB.IsUint8Array(B)?SEF(B,Q):SB.IsUndefined(B)?yEF(B,Q):SB.IsUnion(B)?MEF(B,Q):SB.IsUnknown(B)?TEF(B,Q):SB.IsVoid(B)?OEF(B,Q):kT(`Unknown left type operand '${B[zQ]}'`)}function UE(B,Q){return KI(B,Q)}function cEF(B,Q,F,U,I){let G={};for(let Z of globalThis.Object.getOwnPropertyNames(B))G[Z]=dT(B[Z],Q,F,U,nG(I));return G}function KEF(B,Q,F,U,I){return cEF(B.properties,Q,F,U,I)}function NCQ(B,Q,F,U,I){let G=KEF(B,Q,F,U,I);return f0(G)}function hEF(B,Q,F,U){let I=UE(B,Q);return I===IQ.Union?AI([F,U]):I===IQ.True?F:U}function dT(B,Q,F,U,I){return iG(B)?NCQ(B,Q,F,U,I):lR(B)?UQ(ACQ(B,Q,F,U,I)):UQ(hEF(B,Q,F,U),I)}function kEF(B,Q,F,U,I){return{[B]:dT(GI(B),Q,F,U,nG(I))}}function dEF(B,Q,F,U,I){return B.reduce((G,Z)=>{return{...G,...kEF(Z,Q,F,U,I)}},{})}function $EF(B,Q,F,U,I){return dEF(B.keys,Q,F,U,I)}function ACQ(B,Q,F,U,I){let G=$EF(B,Q,F,U,I);return f0(G)}function YCQ(B,Q){return $T(Pz(B),Q)}function _EF(B,Q){let F=B.filter((U)=>UE(U,Q)===IQ.False);return F.length===1?F[0]:AI(F)}function $T(B,Q,F={}){if(uR(B))return UQ(YCQ(B,Q),F);if(iG(B))return UQ(LCQ(B,Q),F);return UQ(y0(B)?_EF(B.anyOf,Q):UE(B,Q)!==IQ.False?M0():B,F)}function vEF(B,Q){let F={};for(let U of globalThis.Object.getOwnPropertyNames(B))F[U]=$T(B[U],Q);return F}function PEF(B,Q){return vEF(B.properties,Q)}function LCQ(B,Q){let F=PEF(B,Q);return f0(F)}function HCQ(B,Q){return _T(Pz(B),Q)}function fEF(B,Q){let F=B.filter((U)=>UE(U,Q)!==IQ.False);return F.length===1?F[0]:AI(F)}function _T(B,Q,F){if(uR(B))return UQ(HCQ(B,Q),F);if(iG(B))return UQ(JCQ(B,Q),F);return UQ(y0(B)?fEF(B.anyOf,Q):UE(B,Q)!==IQ.False?B:M0(),F)}function lEF(B,Q){let F={};for(let U of globalThis.Object.getOwnPropertyNames(B))F[U]=_T(B[U],Q);return F}function uEF(B,Q){return lEF(B.properties,Q)}function JCQ(B,Q){let F=uEF(B,Q);return f0(F)}function xCQ(B,Q){return CA(B)?UQ(B.returns,Q):M0(Q)}function Cp(B){return MC(Sb(B))}function fz(B,Q,F){return UQ({[zQ]:"Record",type:"object",patternProperties:{[B]:Q}},F)}function eRB(B,Q,F){let U={};for(let I of B)U[I]=Q;return cI(U,{...F,[cN]:"Record"})}function qEF(B,Q,F){return hXQ(B)?eRB(yC(B),Q,F):fz(B.pattern,Q,F)}function jEF(B,Q,F){return eRB(yC(AI(B)),Q,F)}function nEF(B,Q,F){return eRB([B.toString()],Q,F)}function iEF(B,Q,F){return fz(B.source,Q,F)}function pEF(B,Q,F){let U=xW(B.pattern)?e9:B.pattern;return fz(U,Q,F)}function aEF(B,Q,F){return fz(e9,Q,F)}function oEF(B,Q,F){return fz(wXQ,Q,F)}function rEF(B,Q,F){return cI({true:Q,false:Q},F)}function sEF(B,Q,F){return fz(t9,Q,F)}function tEF(B,Q,F){return fz(t9,Q,F)}function Rp(B,Q,F={}){return y0(B)?jEF(B.anyOf,Q,F):uR(B)?qEF(B,Q,F):fR(B)?nEF(B.const,Q,F):NJ(B)?rEF(B,Q,F):NA(B)?sEF(B,Q,F):AA(B)?tEF(B,Q,F):vRB(B)?iEF(B,Q,F):AJ(B)?pEF(B,Q,F):$RB(B)?aEF(B,Q,F):r9(B)?oEF(B,Q,F):M0(F)}function Np(B){return globalThis.Object.getOwnPropertyNames(B.patternProperties)[0]}function ECQ(B){let Q=Np(B);return Q===e9?YA():Q===t9?KN():YA({pattern:Q})}function Ap(B){return B.patternProperties[Np(B)]}function eEF(B,Q){return Q.parameters=Vk(B,Q.parameters),Q.returns=LA(B,Q.returns),Q}function BDF(B,Q){return Q.parameters=Vk(B,Q.parameters),Q.returns=LA(B,Q.returns),Q}function QDF(B,Q){return Q.allOf=Vk(B,Q.allOf),Q}function FDF(B,Q){return Q.anyOf=Vk(B,Q.anyOf),Q}function UDF(B,Q){if(xW(Q.items))return Q;return Q.items=Vk(B,Q.items),Q}function IDF(B,Q){return Q.items=LA(B,Q.items),Q}function GDF(B,Q){return Q.items=LA(B,Q.items),Q}function ZDF(B,Q){return Q.items=LA(B,Q.items),Q}function WDF(B,Q){return Q.item=LA(B,Q.item),Q}function gDF(B,Q){let F=CDF(B,Q.properties);return{...Q,...cI(F)}}function VDF(B,Q){let F=LA(B,ECQ(Q)),U=LA(B,Ap(Q)),I=Rp(F,U);return{...Q,...I}}function bDF(B,Q){return Q.index in B?B[Q.index]:FE()}function XDF(B,Q){let F=wT(Q),U=SC(Q),I=LA(B,Q);return F&&U?Cp(I):F&&!U?MC(I):!F&&U?Sb(I):I}function CDF(B,Q){return globalThis.Object.getOwnPropertyNames(Q).reduce((F,U)=>{return{...F,[U]:XDF(B,Q[U])}},{})}function Vk(B,Q){return Q.map((F)=>LA(B,F))}function LA(B,Q){return CA(Q)?eEF(B,Q):RA(Q)?BDF(B,Q):wZ(Q)?QDF(B,Q):y0(Q)?FDF(B,Q):qR(Q)?UDF(B,Q):bA(Q)?IDF(B,Q):hz(Q)?GDF(B,Q):dz(Q)?ZDF(B,Q):$z(Q)?WDF(B,Q):EW(Q)?gDF(B,Q):_z(Q)?VDF(B,Q):_RB(Q)?bDF(B,Q):Q}function DCQ(B,Q){return LA(Q,zT(B))}function zCQ(B){return UQ({[zQ]:"Integer",type:"integer"},B)}function RDF(B,Q,F){return{[B]:HA(GI(B),Q,nG(F))}}function NDF(B,Q,F){return B.reduce((I,G)=>{return{...I,...RDF(G,Q,F)}},{})}function ADF(B,Q,F){return NDF(B.keys,Q,F)}function wCQ(B,Q,F){let U=ADF(B,Q,F);return f0(U)}function YDF(B){let[Q,F]=[B.slice(0,1),B.slice(1)];return[Q.toLowerCase(),F].join("")}function LDF(B){let[Q,F]=[B.slice(0,1),B.slice(1)];return[Q.toUpperCase(),F].join("")}function HDF(B){return B.toUpperCase()}function JDF(B){return B.toLowerCase()}function xDF(B,Q,F){let U=mT(B.pattern);if(!vz(U))return{...B,pattern:SCQ(B.pattern,Q)};let Z=[...Gk(U)].map((V)=>GI(V)),W=yCQ(Z,Q),g=AI(W);return Qp([g],F)}function SCQ(B,Q){return typeof B==="string"?Q==="Uncapitalize"?YDF(B):Q==="Capitalize"?LDF(B):Q==="Uppercase"?HDF(B):Q==="Lowercase"?JDF(B):B:B.toString()}function yCQ(B,Q){return B.map((F)=>HA(F,Q))}function HA(B,Q,F={}){return lR(B)?wCQ(B,Q,F):uR(B)?xDF(B,Q,F):y0(B)?AI(yCQ(B.anyOf,Q),F):fR(B)?GI(SCQ(B.const,Q),F):UQ(B,F)}function MCQ(B,Q={}){return HA(B,"Capitalize",Q)}function TCQ(B,Q={}){return HA(B,"Lowercase",Q)}function mCQ(B,Q={}){return HA(B,"Uncapitalize",Q)}function OCQ(B,Q={}){return HA(B,"Uppercase",Q)}function EDF(B,Q,F){let U={};for(let I of globalThis.Object.getOwnPropertyNames(B))U[I]=IE(B[I],Q,nG(F));return U}function DDF(B,Q,F){return EDF(B.properties,Q,F)}function cCQ(B,Q,F){let U=DDF(B,Q,F);return f0(U)}function zDF(B,Q){return B.map((F)=>B2B(F,Q))}function wDF(B,Q){return B.map((F)=>B2B(F,Q))}function SDF(B,Q){let{[Q]:F,...U}=B;return U}function yDF(B,Q){return Q.reduce((F,U)=>SDF(F,U),B)}function MDF(B,Q,F){let U=SZ(B,[iW,"$id","required","properties"]),I=yDF(F,Q);return cI(I,U)}function TDF(B){let Q=B.reduce((F,U)=>ri(U)?[...F,GI(U)]:F,[]);return AI(Q)}function B2B(B,Q){return wZ(B)?yb(zDF(B.allOf,Q)):y0(B)?AI(wDF(B.anyOf,Q)):EW(B)?MDF(B,Q,B.properties):cI({})}function IE(B,Q,F){let U=JW(Q)?TDF(Q):Q,I=jR(Q)?yC(Q):Q,G=UW(B),Z=UW(Q);return iG(B)?cCQ(B,I,F):lR(Q)?KCQ(B,Q,F):G&&Z?mG("Omit",[B,U],F):!G&&Z?mG("Omit",[B,U],F):G&&!Z?mG("Omit",[B,U],F):UQ({...B2B(B,I),...F})}function mDF(B,Q,F){return{[Q]:IE(B,[Q],nG(F))}}function ODF(B,Q,F){return Q.reduce((U,I)=>{return{...U,...mDF(B,I,F)}},{})}function cDF(B,Q,F){return ODF(B,Q.keys,F)}function KCQ(B,Q,F){let U=cDF(B,Q,F);return f0(U)}function KDF(B,Q,F){let U={};for(let I of globalThis.Object.getOwnPropertyNames(B))U[I]=GE(B[I],Q,nG(F));return U}function hDF(B,Q,F){return KDF(B.properties,Q,F)}function hCQ(B,Q,F){let U=hDF(B,Q,F);return f0(U)}function kDF(B,Q){return B.map((F)=>Q2B(F,Q))}function dDF(B,Q){return B.map((F)=>Q2B(F,Q))}function $DF(B,Q){let F={};for(let U of Q)if(U in B)F[U]=B[U];return F}function _DF(B,Q,F){let U=SZ(B,[iW,"$id","required","properties"]),I=$DF(F,Q);return cI(I,U)}function vDF(B){let Q=B.reduce((F,U)=>ri(U)?[...F,GI(U)]:F,[]);return AI(Q)}function Q2B(B,Q){return wZ(B)?yb(kDF(B.allOf,Q)):y0(B)?AI(dDF(B.anyOf,Q)):EW(B)?_DF(B,Q,B.properties):cI({})}function GE(B,Q,F){let U=JW(Q)?vDF(Q):Q,I=jR(Q)?yC(Q):Q,G=UW(B),Z=UW(Q);return iG(B)?hCQ(B,I,F):lR(Q)?kCQ(B,Q,F):G&&Z?mG("Pick",[B,U],F):!G&&Z?mG("Pick",[B,U],F):G&&!Z?mG("Pick",[B,U],F):UQ({...Q2B(B,I),...F})}function PDF(B,Q,F){return{[Q]:GE(B,[Q],nG(F))}}function fDF(B,Q,F){return Q.reduce((U,I)=>{return{...U,...PDF(B,I,F)}},{})}function lDF(B,Q,F){return fDF(B,Q.keys,F)}function kCQ(B,Q,F){let U=lDF(B,Q,F);return f0(U)}function uDF(B,Q){return mG("Partial",[mG(B,Q)])}function qDF(B){return mG("Partial",[QL(B)])}function jDF(B){let Q={};for(let F of globalThis.Object.getOwnPropertyNames(B))Q[F]=Sb(B[F]);return Q}function nDF(B,Q){let F=SZ(B,[iW,"$id","required","properties"]),U=jDF(Q);return cI(U,F)}function dCQ(B){return B.map((Q)=>$CQ(Q))}function $CQ(B){return XA(B)?uDF(B.target,B.parameters):UW(B)?qDF(B.$ref):wZ(B)?yb(dCQ(B.allOf)):y0(B)?AI(dCQ(B.anyOf)):EW(B)?nDF(B,B.properties):kz(B)?B:NJ(B)?B:NA(B)?B:fR(B)?B:th(B)?B:AA(B)?B:AJ(B)?B:eh(B)?B:Bk(B)?B:cI({})}function vT(B,Q){if(iG(B))return _CQ(B,Q);else return UQ({...$CQ(B),...Q})}function iDF(B,Q){let F={};for(let U of globalThis.Object.getOwnPropertyNames(B))F[U]=vT(B[U],nG(Q));return F}function pDF(B,Q){return iDF(B.properties,Q)}function _CQ(B,Q){let F=pDF(B,Q);return f0(F)}function aDF(B,Q){return mG("Required",[mG(B,Q)])}function oDF(B){return mG("Required",[QL(B)])}function rDF(B){let Q={};for(let F of globalThis.Object.getOwnPropertyNames(B))Q[F]=SZ(B[F],[hV]);return Q}function sDF(B,Q){let F=SZ(B,[iW,"$id","required","properties"]),U=rDF(Q);return cI(U,F)}function vCQ(B){return B.map((Q)=>PCQ(Q))}function PCQ(B){return XA(B)?aDF(B.target,B.parameters):UW(B)?oDF(B.$ref):wZ(B)?yb(vCQ(B.allOf)):y0(B)?AI(vCQ(B.anyOf)):EW(B)?sDF(B,B.properties):kz(B)?B:NJ(B)?B:NA(B)?B:fR(B)?B:th(B)?B:AA(B)?B:AJ(B)?B:eh(B)?B:Bk(B)?B:cI({})}function PT(B,Q){if(iG(B))return fCQ(B,Q);else return UQ({...PCQ(B),...Q})}function tDF(B,Q){let F={};for(let U of globalThis.Object.getOwnPropertyNames(B))F[U]=PT(B[U],Q);return F}function eDF(B,Q){return tDF(B.properties,Q)}function fCQ(B,Q){let F=eDF(B,Q);return f0(F)}function B3F(B,Q){return Q.map((F)=>{return UW(F)?F2B(B,F.$ref):nR(B,F)})}function F2B(B,Q){return Q in B?UW(B[Q])?F2B(B,B[Q].$ref):nR(B,B[Q]):M0()}function Q3F(B){return KT(B[0])}function F3F(B){return QE(B[0],B[1])}function U3F(B){return hT(B[0])}function I3F(B){return vT(B[0])}function G3F(B){return IE(B[0],B[1])}function Z3F(B){return GE(B[0],B[1])}function W3F(B){return PT(B[0])}function g3F(B,Q,F){let U=B3F(B,F);return Q==="Awaited"?Q3F(U):Q==="Index"?F3F(U):Q==="KeyOf"?U3F(U):Q==="Partial"?I3F(U):Q==="Omit"?G3F(U):Q==="Pick"?Z3F(U):Q==="Required"?W3F(U):M0()}function V3F(B,Q){return ST(nR(B,Q))}function b3F(B,Q){return yT(nR(B,Q))}function X3F(B,Q,F){return MT(bk(B,Q),nR(B,F))}function C3F(B,Q,F){return eY(bk(B,Q),nR(B,F))}function R3F(B,Q){return yb(bk(B,Q))}function N3F(B,Q){return cT(nR(B,Q))}function A3F(B,Q){return cI(globalThis.Object.keys(Q).reduce((F,U)=>{return{...F,[U]:nR(B,Q[U])}},{}))}function Y3F(B,Q){let[F,U]=[nR(B,Ap(Q)),Np(Q)],I=zT(Q);return I.patternProperties[U]=F,I}function L3F(B,Q){return UW(Q)?{...F2B(B,Q.$ref),[iW]:Q[iW]}:Q}function H3F(B,Q){return hN(bk(B,Q))}function J3F(B,Q){return AI(bk(B,Q))}function bk(B,Q){return Q.map((F)=>nR(B,F))}function nR(B,Q){return SC(Q)?UQ(nR(B,SZ(Q,[hV])),Q):wT(Q)?UQ(nR(B,SZ(Q,[VA])),Q):s9(Q)?UQ(L3F(B,Q),Q):bA(Q)?UQ(V3F(B,Q.items),Q):hz(Q)?UQ(b3F(B,Q.items),Q):XA(Q)?UQ(g3F(B,Q.target,Q.parameters)):CA(Q)?UQ(X3F(B,Q.parameters,Q.returns),Q):RA(Q)?UQ(C3F(B,Q.parameters,Q.returns),Q):wZ(Q)?UQ(R3F(B,Q.allOf),Q):dz(Q)?UQ(N3F(B,Q.items),Q):EW(Q)?UQ(A3F(B,Q.properties),Q):_z(Q)?UQ(Y3F(B,Q)):qR(Q)?UQ(H3F(B,Q.items||[]),Q):y0(Q)?UQ(J3F(B,Q.anyOf),Q):Q}function x3F(B,Q){return Q in B?nR(B,B[Q]):M0()}function lCQ(B){return globalThis.Object.getOwnPropertyNames(B).reduce((Q,F)=>{return{...Q,[F]:x3F(B,F)}},{})}class uCQ{constructor(B){let Q=lCQ(B),F=this.WithIdentifiers(Q);this.$defs=F}Import(B,Q){let F={...this.$defs,[B]:UQ(this.$defs[B],Q)};return UQ({[zQ]:"Import",$defs:F,$ref:B})}WithIdentifiers(B){return globalThis.Object.getOwnPropertyNames(B).reduce((Q,F)=>{return{...Q,[F]:{...B[F],$id:F}}},{})}}function qCQ(B){return new uCQ(B)}function jCQ(B,Q){return UQ({[zQ]:"Not",not:B},Q)}function nCQ(B,Q){return RA(B)?hN(B.parameters,Q):M0()}var E3F=0;function iCQ(B,Q={}){if(xW(Q.$id))Q.$id=`T${E3F++}`;let F=zT(B({[zQ]:"This",$ref:`${Q.$id}`}));return F.$id=Q.$id,UQ({[cN]:"Recursive",...F},Q)}function pCQ(B,Q){let F=IG(B)?new globalThis.RegExp(B):B;return UQ({[zQ]:"RegExp",type:"RegExp",source:F.source,flags:F.flags},Q)}function D3F(B){return wZ(B)?B.allOf:y0(B)?B.anyOf:qR(B)?B.items??[]:[]}function aCQ(B){return D3F(B)}function oCQ(B,Q){return RA(B)?UQ(B.returns,Q):M0(Q)}class rCQ{constructor(B){this.schema=B}Decode(B){return new sCQ(this.schema,B)}}class sCQ{constructor(B,Q){this.schema=B,this.decode=Q}EncodeTransform(B,Q){let I={Encode:(G)=>Q[iW].Encode(B(G)),Decode:(G)=>this.decode(Q[iW].Decode(G))};return{...Q,[iW]:I}}EncodeSchema(B,Q){let F={Decode:this.decode,Encode:B};return{...Q,[iW]:F}}Encode(B){return s9(this.schema)?this.EncodeTransform(B,this.schema):this.EncodeSchema(B,this.schema)}}function tCQ(B){return new rCQ(B)}function eCQ(B={}){return UQ({[zQ]:B[zQ]??"Unsafe"},B)}function BRQ(B){return UQ({[zQ]:"Void",type:"void"},B)}var U2B={};WU(U2B,{Void:()=>BRQ,Uppercase:()=>OCQ,Unsafe:()=>eCQ,Unknown:()=>FE,Union:()=>AI,Undefined:()=>Wp,Uncapitalize:()=>mCQ,Uint8Array:()=>gp,Tuple:()=>hN,Transform:()=>tCQ,TemplateLiteral:()=>Qp,Symbol:()=>Zp,String:()=>YA,ReturnType:()=>oCQ,Rest:()=>aCQ,Required:()=>PT,RegExp:()=>pCQ,Ref:()=>QL,Recursive:()=>iCQ,Record:()=>Rp,ReadonlyOptional:()=>Cp,Readonly:()=>MC,Promise:()=>Up,Pick:()=>GE,Partial:()=>vT,Parameters:()=>nCQ,Optional:()=>Sb,Omit:()=>IE,Object:()=>cI,Number:()=>KN,Null:()=>Gp,Not:()=>jCQ,Never:()=>M0,Module:()=>qCQ,Mapped:()=>iXQ,Lowercase:()=>TCQ,Literal:()=>GI,KeyOf:()=>hT,Iterator:()=>cT,Intersect:()=>yb,Integer:()=>zCQ,Instantiate:()=>DCQ,InstanceType:()=>xCQ,Index:()=>QE,Function:()=>eY,Extract:()=>_T,Extends:()=>dT,Exclude:()=>$T,Enum:()=>QCQ,Date:()=>Ip,ConstructorParameters:()=>BCQ,Constructor:()=>MT,Const:()=>eXQ,Composite:()=>tXQ,Capitalize:()=>MCQ,Boolean:()=>Bp,BigInt:()=>OT,Awaited:()=>KT,AsyncIterator:()=>yT,Array:()=>ST,Argument:()=>mXQ,Any:()=>BE});var DU=U2B;import*as Rm from"fs";import*as Xr from"path";var{S3Client:z3F}=globalThis.Bun;import*as Xk from"crypto";import*as yZ from"fs";import*as kV from"path";class I2B{cache=new Map;maxCapacity;iterator=null;sampleSize;constructor(B=50000,Q=50){this.maxCapacity=Math.max(0,B),this.sampleSize=Math.max(1,Q)}get(B){this.evictSample();let Q=this.cache.get(B);if(!Q)return;if(this.now()>Q.expiresAt){this.cache.delete(B);return}return this.cache.delete(B),this.cache.set(B,Q),Q.value}set(B,Q,F){if(this.maxCapacity<=0||F<=0||isNaN(F)){this.cache.delete(B);return}if(this.cache.has(B))this.cache.delete(B);else if(this.cache.size>=this.maxCapacity){let U=this.cache.keys().next().value;if(U!==void 0)this.cache.delete(U)}this.cache.set(B,{value:Q,expiresAt:this.now()+F})}delete(B){return this.cache.delete(B)}evictSample(){if(this.cache.size===0)return;if(!this.iterator)this.iterator=this.cache.keys();let B=this.now();for(let Q=0;Q<this.sampleSize;Q++){let F=this.iterator.next();if(F.done){this.iterator=this.cache.keys();break}let U=F.value,I=this.cache.get(U);if(I&&B>I.expiresAt)this.cache.delete(U)}}now(){return performance.now()}get size(){return this.cache.size}clear(){this.cache.clear(),this.iterator=null}}function w3F(B,Q){let F=process.env.BETTER_AUTH_SECRET||"shumai-local-storage-secret",U=Xk.createHmac("sha256",F);U.update(`${B}/${Q}`);let I=U.digest("hex");return`/api/upload/local?bucket=${encodeURIComponent(B)}&key=${encodeURIComponent(Q)}&Signature=${I}`}class FRQ{client;bucket;presignCache=new I2B(50000);constructor(B,Q,F,U,I,G="auto"){let Z=B;if(!Z.startsWith("http://")&&!Z.startsWith("https://"))Z=`${I?"https":"http"}://${B}`;this.client=new z3F({region:G,endpoint:Z,accessKeyId:Q,secretAccessKey:F,bucket:U}),this.bucket=U}async getObjectSize(B,Q){return await this.client.size(Q,{bucket:B})}async putObject(B,Q,F,U,I){await this.client.write(Q,F,{bucket:B,type:I})}async getObject(B,Q){let F=this.client.file(Q,{bucket:B}),U=await F.arrayBuffer();return{buffer:Buffer.from(U),contentType:F.type||"application/octet-stream"}}async copyObject(B,Q,F,U){let I=this.client.file(Q,{bucket:B});await this.client.write(U,I,{bucket:F})}async downloadToFile(B,Q,F){let U=this.client.file(Q,{bucket:B});await Bun.write(F,U)}async deleteObject(B,Q){try{if(!await this.client.exists(Q,{bucket:B}))return 0;return await this.client.delete(Q,{bucket:B}),1}catch{return 0}}async deletePrefix(B,Q){let F=await this.listObjects(B,Q);if(F.length>0)await Promise.all(F.map((U)=>this.deleteObject(B,U)));return F.length}async headObject(B,Q){let F=this.client.file(Q,{bucket:B});if(!await F.exists())throw Error("NoSuchKey: The specified key does not exist.");return{key:Q,size:await F.size,lastModified:new Date,contentType:F.type||"application/octet-stream",eTag:""}}async listObjects(B,Q){let F=[],U=!0,I=void 0;while(U){let G=await this.client.list({prefix:Q,continuationToken:I});if(G.contents){for(let Z of G.contents)if(Z.key)F.push(Z.key)}U=G.isTruncated||!1,I=G.nextContinuationToken}return F}async uploadFile(B,Q){let F=NG()+kV.extname(B);return await this.uploadFileToKey(B,F,Q),F}async uploadFileToKey(B,Q,F){await this.client.write(Q,Bun.file(B),{bucket:this.bucket,type:F})}async presign(B,Q,F,U){let I=parseInt(process.env.PRESIGNED_URL_EXPIRES_IN||"5",10),G=I*3600,W=Math.round(I*60*2/3)*60*1000,g=`${B}:${Q}:${U||""}`;if(F==="GET"){let X=this.presignCache.get(g);if(X)return X}let V={bucket:B,expiresIn:G,method:F};if(U)V.contentDisposition=`attachment; filename="${U}"`;let b=this.client.presign(Q,V);if(F==="GET")this.presignCache.set(g,b,W);return b}}class URQ{basePath;endpoint;constructor(B,Q="data"){if(this.endpoint=B.replace(/\/$/,""),this.basePath=kV.resolve(Q),!yZ.existsSync(this.basePath))yZ.mkdirSync(this.basePath,{recursive:!0})}getFilePath(B,Q){let F=kV.join(this.basePath,B,Q);if(!F.startsWith(this.basePath))throw Error("Invalid path: potential path traversal detected");return F}async getObjectSize(B,Q){let F=this.getFilePath(B,Q);try{return(await yZ.promises.stat(F)).size}catch(U){if(U instanceof Error&&U.code==="ENOENT")throw Error("NoSuchKey: The specified key does not exist.",{cause:U});throw U}}async putObject(B,Q,F,U,I){let G=this.getFilePath(B,Q),Z=kV.dirname(G);if(!yZ.existsSync(Z))yZ.mkdirSync(Z,{recursive:!0});await yZ.promises.writeFile(G,F)}async getObject(B,Q){let F=this.getFilePath(B,Q);try{return{buffer:await yZ.promises.readFile(F),contentType:Bun.file(F).type||"application/octet-stream"}}catch(U){if(U instanceof Error&&U.code==="ENOENT")throw Error("NoSuchKey: The specified key does not exist.",{cause:U});throw U}}async copyObject(B,Q,F,U){let I=this.getFilePath(B,Q),G=this.getFilePath(F,U),Z=kV.dirname(G);if(!yZ.existsSync(Z))yZ.mkdirSync(Z,{recursive:!0});await yZ.promises.copyFile(I,G)}async downloadToFile(B,Q,F){let U=this.getFilePath(B,Q);await yZ.promises.copyFile(U,F)}async deleteObject(B,Q){let F=this.getFilePath(B,Q);try{return await yZ.promises.unlink(F),1}catch(U){if(U instanceof Error&&U.code==="ENOENT")return 0;throw U}}async deletePrefix(B,Q){let F=await this.listObjects(B,Q);if(F.length===0)return 0;let U=this.getFilePath(B,Q);try{return await yZ.promises.rm(U,{recursive:!0,force:!0}),F.length}catch(I){if(I instanceof Error&&I.code==="ENOENT")return 0;throw I}}async headObject(B,Q){let F=this.getFilePath(B,Q);try{let U=await yZ.promises.stat(F),I=Xk.createHash("md5").update(F+U.mtimeMs).digest("hex");return{key:Q,size:U.size,lastModified:U.mtime,contentType:Bun.file(Q).type||"application/octet-stream",eTag:`"${I}"`}}catch(U){if(U instanceof Error&&U.code==="ENOENT")throw Error("NoSuchKey: The specified key does not exist.",{cause:U});throw U}}async listObjects(B,Q){let F=kV.join(this.basePath,B),U=[];if(!yZ.existsSync(F))return U;let I=async(G)=>{let Z=await yZ.promises.readdir(G);for(let W of Z){let g=kV.join(G,W);if((await yZ.promises.stat(g)).isDirectory())await I(g);else{let X=kV.relative(F,g).split(kV.sep).join("/");if(X.startsWith(Q))U.push(X)}}};return await I(F),U}async uploadFile(B,Q){let F=NG()+kV.extname(B);return await this.uploadFileToKey(B,F,Q),F}async uploadFileToKey(B,Q,F){let U=process.env.S3_BUCKET||"shumai",I=this.getFilePath(U,Q),G=kV.dirname(I);if(!yZ.existsSync(G))yZ.mkdirSync(G,{recursive:!0});await yZ.promises.copyFile(B,I)}async presign(B,Q,F,U){if(F!=="GET"&&F!=="PUT")throw Error(`Invalid method: ${F}`);if(F==="PUT")return`${this.endpoint}${w3F(B,Q)}`;let I=`${this.endpoint}/files/${B}/${Q}`;if(U)I+=`?filename=${encodeURIComponent(U)}`;return I}}var S3F=process.env.STORAGE_BACKEND||"local",y3F=process.env.SHUMAI_SERVER_PORT||"3000",QRQ=process.env.AWS_ENDPOINT_URL_S3||`http://localhost:${y3F}`,yF=S3F==="s3"?new FRQ(QRQ,process.env.S3_ACCESS_KEY_ID||"minioadmin",process.env.S3_SECRET_ACCESS_KEY||"minioadmin",process.env.S3_BUCKET||"shumai",process.env.S3_USE_SSL==="true",process.env.S3_REGION||"auto"):new URQ(QRQ);var _RQ=Pb(V2B(),1);import*as mC from"fs";import*as Rk from"path";function $RQ(B){if(!B)return B;let Q=B.match(/files\/[A-Z0-9]{26}/);return Q?Q[0]:B}class vRQ{prismaClient;constructor(B=VB){this.prismaClient=B}async getSkillContent(B){let Q=await this.prismaClient.skill.findUnique({where:{id:B}});if(!Q)throw Error(`Skill with ID ${B} not found.`);let F=Rk.join(process.cwd(),".pi","skills",Q.id),U=Rk.join(F,".hash"),I=!0;if(mC.existsSync(U)){if(mC.readFileSync(U,"utf8")===Q.hash)I=!1}if(I){if(mC.existsSync(F))mC.rmSync(F,{recursive:!0,force:!0});mC.mkdirSync(F,{recursive:!0});let Z=await this.prismaClient.asset.findUnique({where:{id:Q.assetId},include:{storageKey:!0}});if(!Z||!Z.storageKey?.key)throw Error("Skill asset not found or has no key");let{buffer:W}=await yF.getObject(process.env.S3_BUCKET||"shumai",Z.storageKey.key);new _RQ.default(W).extractAllTo(F,!0),mC.writeFileSync(U,Q.hash)}let G=Rk.join(F,"SKILL.md");if(!mC.existsSync(G))G=Rk.join(F,"skill.md");if(!mC.existsSync(G))throw Error(`Skill downloaded but SKILL.md not found in ${F}`);return mC.readFileSync(G,"utf8")}async getSkillEnvs(B){let Q=await this.prismaClient.skill.findUnique({where:{id:B}});if(!Q)return{};let F=Q.config,U={};if(F?.environmentVariables&&Array.isArray(F.environmentVariables))for(let I of F.environmentVariables){let G=I.default!==void 0&&I.default!==null&&I.default!==""?I.default:process.env[I.name];if(G!==void 0)U[I.name]=G}return U}async createAgent(B){let{teamId:Q,name:F,type:U,enabled:I,avatar:G,providerId:Z,modelId:W,thinkingLevel:g,systemPrompt:V,soul:b,skills:X}=B;if(U==="embedding"||U==="autofill"){if(await this.prismaClient.agent.findFirst({where:{type:U,teamId:Q}}))throw Error(`Agent of type ${U} already exists for this team`)}if(U==="chat"||U==="autofill"){if(!Z||!W)throw Error("providerId and modelId are required for chat/autofill agents");let C=await this.prismaClient.model.findUnique({where:{id:W}});if(!C)throw Error("model not found");if(C.providerId!==Z)throw Error("model does not belong to provider")}return this.prismaClient.$transaction(async(C)=>{if(!await C.team.findUnique({where:{id:Q}}))throw Error("team not found");let R={provider:Z||"",model:W||"",thinkingLevel:g,systemPrompt:V},A=await C.user.create({data:{name:F,email:`agent-${Date.now()}-${Math.random().toString(36).substring(7)}@shumai.ai`,type:"agent",image:$RQ(G)}}),Y=await C.agent.create({data:{id:A.id,teamId:Q,type:U,enabled:I??!0,providerId:Z||null,modelId:W||null,soul:b,config:R,skills:{create:X?.map((L)=>({skillId:L}))||[]}}});return await C.teamMember.create({data:{teamId:Q,userId:A.id,role:"reviewer"}}),C.agent.findUnique({where:{id:Y.id},include:{user:!0,skills:{include:{skill:!0}}}})})}async updateAgent(B){let{agentId:Q,name:F,type:U,enabled:I,avatar:G,providerId:Z,modelId:W,thinkingLevel:g,systemPrompt:V,soul:b,skills:X}=B,C=await this.prismaClient.agent.findUnique({where:{id:Q},include:{user:{include:{teamMembers:!0}}}});if(!C)throw Error("agent not found");if(U==="embedding"||U==="autofill"){if(await this.prismaClient.agent.findFirst({where:{type:U,id:{not:Q},teamId:C.teamId}}))throw Error(`Agent of type ${U} already exists for this team`)}if(U==="chat"||U==="autofill"){if(!Z||!W)throw Error("providerId and modelId are required for chat/autofill agents");let R=await this.prismaClient.model.findUnique({where:{id:W}});if(!R)throw Error("model not found");if(R.providerId!==Z)throw Error("model does not belong to provider")}let N={provider:Z||"",model:W||"",thinkingLevel:g,systemPrompt:V};return this.prismaClient.$transaction(async(R)=>{return await R.user.update({where:{id:Q},data:{name:F,image:$RQ(G)}}),await R.agentSkill.deleteMany({where:{agentId:Q}}),R.agent.update({where:{id:Q},data:{type:U,enabled:I??!0,providerId:Z||null,modelId:W||null,soul:b,config:N,skills:{create:X?.map((A)=>({skillId:A}))||[]}},include:{user:!0,skills:{include:{skill:!0}}}})})}async deleteAgent(B){let{agentId:Q}=B;if(!await this.prismaClient.agent.findUnique({where:{id:Q}}))throw Error("agent not found");await this.prismaClient.user.delete({where:{id:Q}})}async listAgents(B){return this.prismaClient.agent.findMany({where:{teamId:B.teamId},orderBy:{id:"desc"},include:{user:!0,provider:!0,modelRef:!0,skills:{include:{skill:!0}}}})}async getSessionEntries(B){return this.prismaClient.agentSessionEntry.findMany({where:{sessionId:B.sessionId},orderBy:{id:"asc"}})}}var uz=new vRQ;class qz{sessionId;constructor(B){this.sessionId=B}async getMetadata(){let B=await VB.agentSession.findUnique({where:{id:this.sessionId}});if(!B)throw Error(`Session ${this.sessionId} not found`);return{id:B.id,createdAt:B.createdAt.toISOString(),agentId:B.agentId,userId:B.userId||void 0,cwd:B.cwd,assetId:B.assetId||void 0,userCommentId:B.userCommentId||void 0}}async getLeafId(){return(await VB.agentSession.findUnique({where:{id:this.sessionId},select:{leafId:!0}}))?.leafId||null}async setLeafId(B){await VB.agentSession.update({where:{id:this.sessionId},data:{leafId:B}})}async createEntryId(){return NG()}async appendEntry(B){let Q=structuredClone(B);if(Q.type==="message"){let F=Q.message;if(F.role==="toolResult"){let U=F.details;if(Array.isArray(F.content)&&U?.sourceKeys){let I=U.sourceKeys,G=0;F.content.forEach((Z)=>{if(Z.type==="image"&&I[G])Z.data="__S3_DATA__",G++})}if(F.toolName==="read_skill"&&!F.isError){if(U?.skillId&&Array.isArray(F.content))F.content.forEach((I)=>{if(I.type==="text"&&I.text&&!I.text.startsWith("Skill with ID")&&!I.text.startsWith("Skill downloaded but")&&!I.text.startsWith("Error reading skill"))I.text="__SKILL_CONTENT__"})}}}await VB.agentSessionEntry.create({data:{id:B.id,sessionId:this.sessionId,entry:Q}}),await this.setLeafId(B.id)}async getEntry(B){let Q=await VB.agentSessionEntry.findUnique({where:{id:B}});if(!Q)return;let F=Q.entry;return await this.reinjectImageDataAsync(F),await this.reinjectSkillContentAsync(F),F}async findEntries(B){let F=(await VB.agentSessionEntry.findMany({where:{sessionId:this.sessionId,entry:{path:["type"],equals:B}},orderBy:{id:"asc"}})).map((U)=>U.entry);for(let U of F)await this.reinjectImageDataAsync(U),await this.reinjectSkillContentAsync(U);return F}async getLabel(B){return(await VB.agentSessionEntry.findFirst({where:{sessionId:this.sessionId,entry:{path:["id"],equals:B}}}))?.entry?.label}async getPathToRoot(B){if(!B)return[];let Q=await VB.agentSessionEntry.findMany({where:{sessionId:this.sessionId}}),F=new Map;for(let G of Q)F.set(G.id,G.entry);let U=[],I=B;while(I){let G=F.get(I);if(!G)break;U.unshift(G),I=G.parentId}for(let G of U)await this.reinjectImageDataAsync(G),await this.reinjectSkillContentAsync(G);return U}async getEntries(){let Q=(await VB.agentSessionEntry.findMany({where:{sessionId:this.sessionId},orderBy:{id:"asc"}})).map((F)=>F.entry);for(let F of Q)await this.reinjectImageDataAsync(F),await this.reinjectSkillContentAsync(F);return Q}async reinjectImageDataAsync(B){if(B.type==="message"){let Q=B.message;if(Q.role==="toolResult"){let F=Q.details;if(Array.isArray(Q.content)&&F?.sourceKeys){let U=F.sourceKeys,I=0;for(let G of Q.content)if(G.type==="image"&&G.data==="__S3_DATA__"&&U[I]){let Z=U[I];try{let{buffer:W}=await yF.getObject(process.env.S3_BUCKET||"shumai",Z);G.data=W.toString("base64")}catch(W){console.error(`Failed to re-inject image data for key ${Z}:`,W)}I++}}}}}async reinjectSkillContentAsync(B){if(B.type==="message"){let Q=B.message;if(Q.role==="toolResult"&&Q.toolName==="read_skill"){let F=Q.details;if(F?.skillId&&Array.isArray(Q.content)){for(let U of Q.content)if(U.type==="text"&&U.text==="__SKILL_CONTENT__")try{let I=await uz.getSkillContent(F.skillId);U.text=I}catch(I){console.error(`Failed to re-inject skill content for skill ${F.skillId}:`,I)}}}}}static async create(B){if(B.sessionId)return new qz(B.sessionId);else{let Q=await VB.agentSession.create({data:{agentId:B.agentId,userId:B.userId,cwd:B.cwd||process.cwd(),assetId:B.assetId||null,userCommentId:B.userCommentId||null}});return new qz(Q.id)}}}var e3F=DU.Object({});function PRQ(B,Q){return{name:"analyze_image",label:"Analyze Image",description:"Retrieves and views the image content. Call this tool if you need to analyze the image.",parameters:e3F,execute:async()=>{try{let F=await VB.asset.findUnique({where:{id:B},include:{storageKey:!0}});if(!F)return{content:[{type:"text",text:`Asset with ID ${B} not found.`}],details:{}};let U=F.storageKey?.key;if(F.media){let b=F.media;if(b.imageTranscodes&&b.imageTranscodes.length>0)U=b.imageTranscodes[0].key||U}if(!U)return{content:[{type:"text",text:"No media content found for this asset."}],details:{}};let I=null;if(Q){let b=await VB.assetComment.findUnique({where:{id:Q}});if(b?.annotation){let X=b.annotation;if(Array.isArray(X)&&X.length>0)I=X}}let G=U;if(I){let b=await VB.workflowTask.create({data:{assetId:B,projectId:F.projectId||"none",type:e0.transcode,status:$I.pending,payload:{projectId:F.projectId||"none",imageAnnotation:{annotations:I}}}}),C=(await oN.executeWait(b)).output;if(C?.key)G=C.key;else throw Error("Image annotation transcode workflow failed to output S3 key.")}let Z=process.env.S3_BUCKET||"shumai",{buffer:W,contentType:g}=await yF.getObject(Z,G);return{content:[{type:"image",data:W.toString("base64"),mimeType:g||"image/webp"}],details:{sourceKeys:[G]}}}catch(F){return{content:[{type:"text",text:`Error analyzing image: ${F instanceof Error?F.message:String(F)}`}],details:{}}}}}}var BzF=DU.Object({start:DU.Number({description:"Start time in seconds"}),end:DU.Number({description:"End time in seconds"}),count:DU.Number({description:"Number of screenshots to take"})});function fRQ(B,Q){return{name:"screenshot",label:"Take Video Screenshots",description:"Takes screenshots for a video at specified interval. It returns the images to the agent context.",parameters:BzF,execute:async(F,U)=>{try{let I=await VB.asset.findUnique({where:{id:B}});if(!I)return{content:[{type:"text",text:`Asset with ID ${B} not found.`}],details:{}};let G=null,Z=null;if(Q){let R=await VB.assetComment.findUnique({where:{id:Q}});if(R){if(G=R.second!==null?R.second:null,R.annotation){let A=R.annotation;if(Array.isArray(A)&&A.length>0)Z=A}}}let W=await VB.workflowTask.create({data:{assetId:B,projectId:I.projectId||"none",type:e0.transcode,status:$I.pending,payload:{projectId:I.projectId||"none",screenshot:{start:U.start,end:U.end,count:U.count,commentTimestamp:G,annotations:Z}}}}),b=(await oN.executeWait(W)).output?.screenshots;if(!b||b.length===0)return{content:[{type:"text",text:"No screenshots were generated."}],details:{}};let X=[],C=[],N=process.env.S3_BUCKET||"shumai";for(let R of b){let{buffer:A,contentType:Y}=await yF.getObject(N,R.key);X.push({type:"image",data:A.toString("base64"),mimeType:Y||"image/webp"}),C.push(R.key)}return{content:X,details:{sourceKeys:C}}}catch(I){return{content:[{type:"text",text:`Error taking screenshots: ${I instanceof Error?I.message:String(I)}`}],details:{}}}}}}async function WE(B){let Q=await VB.workflowTask.create({data:{type:e0.agent_tool_call,status:$I.pending,assetId:B.assetId,payload:{projectId:"none",agentToolCall:{toolName:B.toolName,args:B.args,userId:B.userId}}}}),F=await oN.executeWait(Q);if(F.status===$I.failed){let I=F.output?.error||"Workflow task failed";throw Error(I)}return F.output}import*as FL from"fs";import*as qT from"path";var b2B=[137,80,78,71,13,10,26,10];function Jp(B){if(lRQ(B,[255,216,255]))return B[3]===247?null:"image/jpeg";if(lRQ(B,b2B))return QzF(B)&&!FzF(B)?"image/png":null;if(jz(B,0,"GIF"))return"image/gif";if(jz(B,0,"RIFF")&&jz(B,8,"WEBP"))return"image/webp";if(jz(B,4,"ftyp"))return"video/mp4";return null}function QzF(B){return B.length>=16&&uRQ(B,b2B.length)===13&&jz(B,12,"IHDR")}function FzF(B){let Q=b2B.length;while(Q+8<=B.length){let F=uRQ(B,Q),U=Q+4;if(jz(B,U,"acTL"))return!0;if(jz(B,U,"IDAT"))return!1;let I=Q+8+F+4;if(I<=Q||I>B.length)return!1;Q=I}return!1}function uRQ(B,Q){return(B[Q]??0)*16777216+((B[Q+1]??0)<<16)+((B[Q+2]??0)<<8)+(B[Q+3]??0)}function lRQ(B,Q){if(B.length<Q.length)return!1;return Q.every((F,U)=>B[U]===F)}function jz(B,Q,F){if(B.length<Q+F.length)return!1;for(let U=0;U<F.length;U++)if(B[Q+U]!==F.charCodeAt(U))return!1;return!0}function UzF(B){try{let U=FL.openSync(B,"r");try{let I=Buffer.alloc(4100),G=FL.readSync(U,I,0,4100,0),Z=Jp(new Uint8Array(I.subarray(0,G)));if(Z)return Z}finally{FL.closeSync(U)}}catch{}let Q=qT.extname(B).toLowerCase();return{".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".mp4":"video/mp4",".mov":"video/quicktime",".pdf":"application/pdf"}[Q]||"application/octet-stream"}var IzF=DU.Object({parent:DU.String({description:"The parent folder ID under which to create the file. This parameter is required."}),path:DU.String({description:"The absolute or relative local path to the file on disk. This parameter is required."})});function qRQ(B){return{name:"create_file",label:"Create File",description:"Create a new file in a specified parent folder from a local file path.",parameters:IzF,execute:async(Q,F)=>{try{let U=qT.resolve(process.cwd(),F.path);if(!FL.existsSync(U))throw Error(`Local file not found at path: ${F.path}`);let I=FL.statSync(U).size,G=UzF(U),Z=`files/${NG()}/raw`;await yF.uploadFileToKey(U,Z,G);let W=await WE({toolName:"create_file",args:{parent:F.parent,s3Key:Z,name:qT.basename(U),size:I,contentType:G},userId:B,assetId:F.parent});return{content:[{type:"text",text:JSON.stringify(W,null,2)}],details:W}}catch(U){return{content:[{type:"text",text:`Error creating file: ${U instanceof Error?U.message:String(U)}`}],details:{}}}}}}var GzF=DU.Object({parent:DU.String({description:"The parent folder ID under which to create the new folder. This parameter is required."}),name:DU.String({description:"The name of the new folder to create. This parameter is required."})});function jRQ(B){return{name:"create_folder",label:"Create Folder",description:"Create a new folder in a specified parent folder.",parameters:GzF,execute:async(Q,F)=>{try{let U=await WE({toolName:"create_folder",args:F,userId:B,assetId:F.parent});return{content:[{type:"text",text:JSON.stringify(U,null,2)}],details:U}}catch(U){return{content:[{type:"text",text:`Error creating folder: ${U instanceof Error?U.message:String(U)}`}],details:{}}}}}}import*as UL from"fs";import*as jT from"path";function ZzF(B){try{let U=UL.openSync(B,"r");try{let I=Buffer.alloc(4100),G=UL.readSync(U,I,0,4100,0),Z=Jp(new Uint8Array(I.subarray(0,G)));if(Z)return Z}finally{UL.closeSync(U)}}catch{}let Q=jT.extname(B).toLowerCase();return{".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".svg":"image/svg+xml",".mp4":"video/mp4",".mov":"video/quicktime",".pdf":"application/pdf"}[Q]||"application/octet-stream"}var WzF=DU.Object({parent:DU.String({description:"The parent file ID for which to create a new version. This parameter is required."}),path:DU.String({description:"The absolute or relative local path to the file on disk. This parameter is required."})});function nRQ(B){return{name:"create_version",label:"Create Version",description:"Create a new version of an existing file from a local file path.",parameters:WzF,execute:async(Q,F)=>{try{let U=jT.resolve(process.cwd(),F.path);if(!UL.existsSync(U))throw Error(`Local file not found at path: ${F.path}`);let I=UL.statSync(U).size,G=ZzF(U),Z=`files/${NG()}/raw`;await yF.uploadFileToKey(U,Z,G);let W=await WE({toolName:"create_version",args:{parent:F.parent,s3Key:Z,name:jT.basename(U),size:I,contentType:G},userId:B,assetId:F.parent});return{content:[{type:"text",text:JSON.stringify(W,null,2)}],details:W}}catch(U){return{content:[{type:"text",text:`Error creating file version: ${U instanceof Error?U.message:String(U)}`}],details:{}}}}}}var gzF=DU.Object({parent:DU.String({description:"The parent folder ID to list assets from. This parameter is required."}),page:DU.Optional(DU.Number({description:"The page number to retrieve, default is 1.",default:1})),pageSize:DU.Optional(DU.Number({description:"The number of assets per page, default is 20.",default:20})),type:DU.Optional(DU.String({description:"Filter assets by type: 'file', 'folder', or 'all'. Default is 'all'.",enum:["file","folder","all"],default:"all"}))});function iRQ(B){return{name:"list_assets",label:"List Assets",description:"List the assets (files and folders) inside a parent folder with pagination.",parameters:gzF,execute:async(Q,F)=>{try{let U=await WE({toolName:"list_assets",args:F,userId:B,assetId:F.parent});return{content:[{type:"text",text:JSON.stringify(U,null,2)}],details:U}}catch(U){return{content:[{type:"text",text:`Error listing assets: ${U instanceof Error?U.message:String(U)}`}],details:{}}}}}}var VzF=DU.Object({skillId:DU.String({description:"The ID of the skill to read"})}),pRQ=(B)=>({name:"read_skill",label:"Read Agent Skill",description:"Downloads and reads an agent skill to understand how to use it.",parameters:VzF,execute:async(Q,F)=>{try{if(!await VB.skill.findUnique({where:{id:F.skillId}}))return{content:[{type:"text",text:`Skill with ID ${F.skillId} not found.`}],details:{skillId:F.skillId}};let I=await uz.getSkillEnvs(F.skillId);return B(I),{content:[{type:"text",text:await uz.getSkillContent(F.skillId)}],details:{skillId:F.skillId}}}catch(U){return{content:[{type:"text",text:`Error reading skill ${F.skillId}: ${U instanceof Error?U.message:String(U)}`}],details:{skillId:F.skillId}}}}});import{spawn as bzF}from"child_process";var XzF=DU.Object({command:DU.String({description:"The bash command to execute."}),timeout:DU.Optional(DU.Number({description:"Maximum execution time in seconds."}))}),aRQ=(B,Q={},F)=>{return{name:"bash",description:"Execute a bash command in a sandboxed environment.",label:"Executing bash command",parameters:XzF,execute:async(U,{command:I,timeout:G},Z)=>{F?.clearBlockedHost?.();let W=await B4.wrapWithSandbox(I);return new Promise((g,V)=>{let b=bzF("bash",["-c",W],{cwd:B,detached:!0,stdio:["ignore","pipe","pipe"],env:{PATH:process.env.PATH||"",HOME:process.env.HOME||"",...Q}}),X="",C="",N=!1,R;if(G!==void 0&&G>0)R=setTimeout(()=>{if(N=!0,b.pid)try{process.kill(-b.pid,"SIGKILL")}catch{b.kill("SIGKILL")}},G*1000);b.stdout?.on("data",(Y)=>{X+=Y.toString()}),b.stderr?.on("data",(Y)=>{C+=Y.toString()});let A=()=>{if(b.pid)try{process.kill(-b.pid,"SIGKILL")}catch{b.kill("SIGKILL")}};Z?.addEventListener("abort",A,{once:!0}),b.on("error",(Y)=>{if(R)clearTimeout(R);Z?.removeEventListener("abort",A),qX.error({err:Y,command:I,stdout:X,stderr:C},"Sandboxed bash command encountered process error"),V(Y)}),b.on("close",(Y)=>{if(R)clearTimeout(R);Z?.removeEventListener("abort",A);let L=F?.getBlockedHost?.();if(Z?.aborted)qX.error({command:I,stdout:X,stderr:C},"Sandboxed bash command aborted"),V(Error("aborted"));else if(N)qX.error({timeout:G,command:I,stdout:X,stderr:C},"Sandboxed bash command timed out"),V(Error(`bash command timed out after ${G} seconds`));else if(L)V(Error(`Network request to ${L} is blocked, please ask admin to allow it in sandbox settings.`));else if(Y!==0&&Y!==null)qX.error({exitCode:Y,command:I,stdout:X,stderr:C},"Sandboxed bash command exited with failure code"),V(Error(`bash command exited with code ${Y}`));else{let H=X+C;g({content:[{type:"text",text:H||(Y===0?"Success":`Failed with exit code ${Y}`)}],details:{exitCode:Y,stdout:X,stderr:C}})}})})}}};import{ApplicationFailure as X2B}from"@temporalio/workflow";async function oRQ(B){let{updateTaskStatusActivity:Q,getEmbeddingContextActivity:F,generateImageEmbeddingActivity:U,generateVideoChunkEmbeddingActivity:I,saveAssetEmbeddingsActivity:G,updateTaskUsageActivity:Z,createCommentActivity:W,updateCommentActivity:g,getAgentWorkerQueueActivity:V,getTranscodeWorkerQueueActivity:b,downloadMediaToTmpActivity:X,cleanupTmpDirActivity:C,transcodeVideoChunkActivity:N,deleteS3ObjectActivity:R}=aN(),A,Y="",L="",H;try{Y=await QF(Fg,V),L=await QF(kL,b),await QF(Y,Q,{taskId:B.id,status:"processing"});let J=B.payload;if(A=(await QF(Y,W,{assetId:B.assetId,message:"__EMBEDDING__",sessionId:J?.agent?.sessionId||B.id,agentId:J?.agent?.agentId||"default"})).id,!B.teamId)throw X2B.create({message:"Task has no teamId",nonRetryable:!0});let M=await QF(Y,F,{teamId:B.teamId,assetId:B.assetId}),{asset:y,chunkDuration:m,chunkOverlap:c}=M,k=y.mediaType?.startsWith("image/"),d=y.mediaType?.startsWith("video/");if(!k&&!d)throw X2B.create({message:`unsupported media type for embeddings: ${y.mediaType}`,nonRetryable:!0});let $=y.storageKey?.key,FB=y.mediaType;if(y.media){let IB=y.media;if(d){if(IB.videoTranscodes&&IB.videoTranscodes.length>0){let t=IB.videoTranscodes.find((ZB)=>!ZB.isRaw)||IB.videoTranscodes[0];if(t?.key)$=t.key}}else if(k){if(IB.imageTranscodes&&IB.imageTranscodes.length>0){let t=IB.imageTranscodes.find((ZB)=>!ZB.isRaw)||IB.imageTranscodes[0];if(t?.key){if($=t.key,t.format)FB=`image/${t.format}`}}}}if(!$)throw X2B.create({message:"asset has no key",nonRetryable:!0});let bB=[],CB={model:"gemini-embedding-2",inputTokens:0,outputTokens:0};if(k){let IB=await QF(Y,U,{teamId:B.teamId,assetKey:$,mediaType:FB});if(bB.push({embedding:IB.embedding}),IB.usage)CB.inputTokens+=IB.usage.inputTokens||0,CB.outputTokens+=IB.usage.outputTokens||0}else if(d){let IB=await QF(L,X,{assetKey:$}),{filePath:t}=IB;H=IB.tmpDir;let ZB=y.media?.duration||0,LB=m||60,HQ=Math.max(1,LB-(c??5));for(let wQ=0;wQ<ZB;wQ+=HQ){let hQ=wQ+LB;if(hQ>=ZB)hQ=ZB;let jB=await QF(L,N,{assetId:y.id,filePath:t,startTime:wQ,endTime:hQ}),{chunkKey:lQ}=jB;try{let oF=await QF(Y,I,{teamId:B.teamId,chunkKey:lQ});if(bB.push({embedding:oF.embedding,startTime:wQ,endTime:hQ}),oF.usage)CB.inputTokens+=oF.usage.inputTokens||0,CB.outputTokens+=oF.usage.outputTokens||0}finally{await QF(L,R,{key:lQ})}if(hQ>=ZB)break}}if(bB.length>0)await QF(Y,G,{assetId:B.assetId,embeddings:bB});if(await QF(Y,Z,{taskId:B.id,inputTokens:CB.inputTokens,outputTokens:CB.outputTokens,model:CB.model}),A)await QF(Y,g,{commentId:A,message:"Embedding completed successfully."});await QF(Y,Q,{taskId:B.id,status:"completed"})}catch(J){if(console.error(`AgentEmbeddingMedia failed for task ${B.id}:`,J),A&&Y)try{await QF(Y,g,{commentId:A,message:`Embedding failed: ${J instanceof Error?J.message:String(J)}`})}catch(w){console.error("Failed to update error comment:",w)}if(Y)await QF(Y,Q,{taskId:B.id,status:"failed",output:{error:J instanceof Error?J.message:String(J)}});throw J}finally{if(H&&L)try{await QF(L,C,{tmpDir:H})}catch(J){console.error("Failed to cleanup transcode worker tmp dir:",J)}}}async function rRQ(B){let{generateTextEmbeddingActivity:Q,updateWorkflowTaskActivity:F,getAgentWorkerQueueActivity:U}=aN(),I="",Z=B.payload?.queryEmbeddingForSearch?.text;if(!Z)throw Error("Missing text in query_embedding_for_search task payload");try{I=await QF(Fg,U),await QF(I,F,{taskId:B.id,status:"processing",heartbeat:!0});let W=await QF(I,Q,{text:Z,teamId:B.teamId});await QF(I,F,{taskId:B.id,status:"completed",output:{embedding:W.embedding},inputTokens:W.usage.inputTokens,outputTokens:W.usage.outputTokens,model:W.usage.model})}catch(W){if(console.error(`queryEmbeddingForSearch failed for task ${B.id}:`,W),I)await QF(I,F,{taskId:B.id,status:"failed",output:{error:W instanceof Error?W.message:String(W)}});throw W}}import{ApplicationFailure as CzF}from"@temporalio/workflow";async function sRQ(B){let{updateTaskStatusActivity:Q,getAssetActivity:F,extractAiMetadataActivity:U,getProjectAutofillFieldsActivity:I,getAgentAutofillContextActivity:G,autofillAiActivity:Z,updateTaskUsageActivity:W,updateAssetMetadataActivity:g,createCommentActivity:V,updateCommentActivity:b,getTranscodeWorkerQueueActivity:X,getAgentWorkerQueueActivity:C,downloadMediaToTmpActivity:N,cleanupTmpDirActivity:R}=aN(),A,Y,L="",H="";try{H=await QF(Fg,C),L=await QF(kL,X),await QF(H,Q,{taskId:B.id,status:"processing"});let J=B.payload;A=(await QF(H,V,{assetId:B.assetId,message:"__AUTOFILL__",sessionId:J?.agent?.sessionId||B.id,agentId:J?.agent?.agentId||"default"})).id;let M=await QF(H,F,B.assetId),y=M?.storageKey?.key;if(!M||!M.project||!y)throw CzF.create({message:"Asset or project not found",nonRetryable:!0});let m=M.project.teamId,c=M.project.id,k=M.mediaType?.startsWith("image/")||!1,d=await QF(L,N,{assetKey:y}),{filePath:$}=d;Y=d.tmpDir;let FB=await QF(L,U,{assetKey:y,filePath:$,type:"autofill",isImage:k});if(FB.length===0){if(A)await QF(H,b,{commentId:A,message:"Autofill completed: No images could be extracted for analysis."});await QF(H,Q,{taskId:B.id,status:"completed"});return}let bB=await QF(H,I,c);if(bB.length===0){if(A)await QF(H,b,{commentId:A,message:"Autofill completed: No autofill fields defined in project."});await QF(H,Q,{taskId:B.id,status:"completed"});return}let CB=await QF(H,G,{teamId:m}),IB=await QF(H,Z,{teamId:m,images:FB,fields:bB.map((LB)=>({id:LB.key,config:LB.config,description:LB.description})),context:CB});if(IB.usage)await QF(H,W,{taskId:B.id,inputTokens:IB.usage.inputTokens,outputTokens:IB.usage.outputTokens,model:IB.usage.model});let t=JSON.parse(IB.text),ZB=Object.entries(t).map(([LB,NQ])=>({key:LB,value:NQ}));if(ZB.length>0)await QF(H,g,{assetId:M.id,metadata:ZB});if(A)await QF(H,b,{commentId:A,message:"Autofill completed successfully.",sessionId:IB.sessionId});await QF(H,Q,{taskId:B.id,status:"completed"})}catch(J){if(console.error(`AgentAutofillMedia failed for task ${B.id}:`,J),A&&H)try{await QF(H,b,{commentId:A,message:`Autofill failed: ${J instanceof Error?J.message:String(J)}`})}catch(w){console.error("Failed to update error comment:",w)}if(H)await QF(H,Q,{taskId:B.id,status:"failed",output:{error:J instanceof Error?J.message:String(J)}});throw J}finally{if(Y&&L)try{await QF(L,R,{tmpDir:Y})}catch(J){console.error("Failed to cleanup tmp dir:",J)}}}import{ApplicationFailure as Nk}from"@temporalio/workflow";function tRQ(B){if(!B)return"other";let Q=B.toLowerCase();if(Q.startsWith("image/")||Q==="application/x-photoshop"||Q==="image/vnd.adobe.photoshop")return"image";if(Q.startsWith("video/"))return"video";return"other"}class C2B{assetId;assetName;mediaType;videoDuration;commentTimestamp;pathContext;explicitMention=!1;constructor(B){this.assetId=B}withPathContext(B){return this.pathContext=B,this}withAssetDetails(B,Q,F){return this.assetName=B,this.mediaType=Q||void 0,this.videoDuration=F,this}withCommentTimestamp(B){if(B!==void 0&&B!==null)this.commentTimestamp=B;return this}withExplicitMention(B){return this.explicitMention=!!B,this}build(){let B=`The user is discussing an asset with ID: ${this.assetId}.`;if(this.assetName)B+=`
13373
13373
  File Name: ${this.assetName}`;if(this.mediaType){let Q=tRQ(this.mediaType);if(B+=`
13374
13374
  File Type: ${Q}`,Q==="video"&&this.videoDuration!==void 0)B+=`
13375
13375
  Video Length: ${this.videoDuration.toFixed(2)} seconds`}if(this.commentTimestamp!==void 0)B+=`
@@ -13866,7 +13866,7 @@ To resolve this, you can:
13866
13866
  `)}}function BLB(B,Q){let F=Q.plugins?.reduce((I,G)=>{return{...I,...G.endpoints}},{})??{},U=Q.plugins?.map((I)=>I.middlewares?.map((G)=>{let Z=async(W)=>{let g=await B;return x0(`middleware ${G.path} ${I.id}`,{[zW]:"middleware",[HF.ATTR_HTTP_ROUTE]:G.path,[wW]:`plugin:${I.id}`},()=>G.middleware({...W,context:{...g,...W.context}}))};return Z.options=G.middleware.options,{path:G.path,middleware:Z}})).filter((I)=>I!==void 0).flat()||[];return{api:xwQ({signInSocial:VwQ(),callbackOAuth:BwQ,getSession:PYB(),signOut:XwQ,signUpEmail:CwQ(),signInEmail:bwQ(),resetPassword:WwQ,verifyPassword:gwQ,verifyEmail:ezQ,sendVerificationEmail:tzQ,changeEmail:HwQ,changePassword:AwQ,setPassword:YwQ,updateSession:RwQ(),updateUser:NwQ(),deleteUser:LwQ,requestPasswordReset:GwQ,requestPasswordResetCallback:ZwQ,listSessions:S3Q(),revokeSession:y3Q,revokeSessions:M3Q,revokeOtherSessions:T3Q,linkSocialAccount:azQ,listUserAccounts:pzQ,deleteUserCallback:eYB,unlinkAccount:ozQ,refreshToken:rzQ,getAccessToken:sYB,accountInfo:szQ,...F,ok:UwQ,error:FwQ},B),middlewares:U}}var DwQ=(B,Q)=>{let{api:F,middlewares:U}=BLB(B,Q),I=new URL(B.baseURL).pathname;return KYB(F,{routerContext:B,openapi:{disabled:!0},basePath:I,routerMiddleware:[{path:"/**",middleware:J3Q},...U],allowedMediaTypes:["application/json"],skipTrailingSlashes:Q.advanced?.skipTrailingSlashes??!1,async onRequest(G){let Z=B.options.disabledPaths||[],W=Qm(G.url,I);if(Z.includes(W))return new Response("Not Found",{status:404});let g=G;for(let b of B.options.plugins||[])if(b.onRequest){let X=await x0(`onRequest ${b.id}`,{[zW]:"onRequest",[wW]:`plugin:${b.id}`},()=>b.onRequest(g,B));if(X&&"response"in X)return X.response;if(X&&"request"in X)g=X.request}let V=await z3Q(g,B);if(V)return V;return g},async onResponse(G,Z){await w3Q(Z,B);for(let W of B.options.plugins||[])if(W.onResponse){let g=await x0(`onResponse ${W.id}`,{[zW]:"onResponse",[wW]:`plugin:${W.id}`,[HF.ATTR_HTTP_RESPONSE_STATUS_CODE]:G.status},()=>W.onResponse(G,B));if(g)return g.response}return G},onError(G){if(WV(G)&&G.status==="FOUND")return;if(Q.onAPIError?.throw)throw G;if(Q.onAPIError?.onError){Q.onAPIError.onError(G,B);return}let Z=Q.logger?.level,W=Z==="error"||Z==="warn"||Z==="debug"?ZF:void 0;if(Q.logger?.disabled!==!0){if(G&&typeof G==="object"&&"message"in G&&typeof G.message==="string"){if(G.message.includes("no column")||G.message.includes("column")||G.message.includes("relation")||G.message.includes("table")||G.message.includes("does not exist")){B.logger?.error(G.message);return}}if(WV(G)){if(G.status==="INTERNAL_SERVER_ERROR")B.logger.error(G.status,G);W?.error(G.message)}else B.logger?.error(G&&typeof G==="object"&&"name"in G?G.name:"",G)}}})};var zwQ="better-auth-secret-12345678901234567890";PU();function z6F(B){let Q=new Set(B).size;if(Q===0)return 0;return Math.log2(Math.pow(Q,B.length))}function wwQ(B){if(!B)return null;return B.split(",").map((Q)=>{Q=Q.trim();let F=Q.indexOf(":");if(F===-1)throw new OQ(`Invalid BETTER_AUTH_SECRETS entry: "${Q}". Expected format: "<version>:<secret>"`);let U=parseInt(Q.slice(0,F),10);if(!Number.isInteger(U)||U<0)throw new OQ(`Invalid version in BETTER_AUTH_SECRETS: "${Q.slice(0,F)}". Version must be a non-negative integer.`);let I=Q.slice(F+1).trim();if(!I)throw new OQ(`Empty secret value for version ${U} in BETTER_AUTH_SECRETS.`);return{version:U,value:I}})}function SwQ(B,Q){if(B.length===0)throw new OQ("`secrets` array must contain at least one entry.");let F=new Set;for(let I of B){let G=parseInt(String(I.version),10);if(!Number.isInteger(G)||G<0||String(G)!==String(I.version).trim())throw new OQ(`Invalid version ${I.version} in \`secrets\`. Version must be a non-negative integer.`);if(!I.value)throw new OQ(`Empty secret value for version ${G} in \`secrets\`.`);if(F.has(G))throw new OQ(`Duplicate version ${G} in \`secrets\`. Each version must be unique.`);F.add(G)}let U=B[0];if(U.value.length<32)Q.warn(`[better-auth] Warning: the current secret (version ${U.version}) should be at least 32 characters long for adequate security.`);if(z6F(U.value)<120)Q.warn("[better-auth] Warning: the current secret appears low-entropy. Use a randomly generated secret for production.")}function ywQ(B,Q){let F=new Map;for(let U of B)F.set(parseInt(String(U.version),10),U.value);return{keys:F,currentVersion:parseInt(String(B[0].version),10),legacySecret:Q&&Q!=="better-auth-secret-12345678901234567890"?Q:void 0}}Tb();PU();pz();Tb();import Br from"fs";import cwQ from"fs/promises";import Vm from"os";import KwQ from"path";Op();async function w6F(B,Q){return{database:Q?.database,adapter:Q?.adapter,emailVerification:{sendVerificationEmail:!!B.emailVerification?.sendVerificationEmail,sendOnSignUp:!!B.emailVerification?.sendOnSignUp,sendOnSignIn:!!B.emailVerification?.sendOnSignIn,autoSignInAfterVerification:!!B.emailVerification?.autoSignInAfterVerification,expiresIn:B.emailVerification?.expiresIn,beforeEmailVerification:!!B.emailVerification?.beforeEmailVerification,afterEmailVerification:!!B.emailVerification?.afterEmailVerification},emailAndPassword:{enabled:!!B.emailAndPassword?.enabled,disableSignUp:!!B.emailAndPassword?.disableSignUp,requireEmailVerification:!!B.emailAndPassword?.requireEmailVerification,maxPasswordLength:B.emailAndPassword?.maxPasswordLength,minPasswordLength:B.emailAndPassword?.minPasswordLength,sendResetPassword:!!B.emailAndPassword?.sendResetPassword,resetPasswordTokenExpiresIn:B.emailAndPassword?.resetPasswordTokenExpiresIn,onPasswordReset:!!B.emailAndPassword?.onPasswordReset,password:{hash:!!B.emailAndPassword?.password?.hash,verify:!!B.emailAndPassword?.password?.verify},autoSignIn:!!B.emailAndPassword?.autoSignIn,revokeSessionsOnPasswordReset:!!B.emailAndPassword?.revokeSessionsOnPasswordReset},socialProviders:await Promise.all(Object.keys(B.socialProviders||{}).map(async(F)=>{let U=B.socialProviders?.[F];if(!U)return{};let I=typeof U==="function"?await U():U;return{id:F,mapProfileToUser:!!I.mapProfileToUser,disableDefaultScope:!!I.disableDefaultScope,disableIdTokenSignIn:!!I.disableIdTokenSignIn,disableImplicitSignUp:I.disableImplicitSignUp,disableSignUp:I.disableSignUp,getUserInfo:!!I.getUserInfo,overrideUserInfoOnSignIn:!!I.overrideUserInfoOnSignIn,prompt:I.prompt,verifyIdToken:!!I.verifyIdToken,scope:I.scope,refreshAccessToken:!!I.refreshAccessToken}})),plugins:B.plugins?.map((F)=>F.id.toString()),user:{modelName:B.user?.modelName,fields:B.user?.fields,additionalFields:B.user?.additionalFields,changeEmail:{enabled:B.user?.changeEmail?.enabled,sendChangeEmailConfirmation:!!B.user?.changeEmail?.sendChangeEmailConfirmation}},verification:{modelName:B.verification?.modelName,disableCleanup:B.verification?.disableCleanup,fields:B.verification?.fields},session:{modelName:B.session?.modelName,additionalFields:B.session?.additionalFields,cookieCache:{enabled:B.session?.cookieCache?.enabled,maxAge:B.session?.cookieCache?.maxAge,strategy:B.session?.cookieCache?.strategy},disableSessionRefresh:B.session?.disableSessionRefresh,expiresIn:B.session?.expiresIn,fields:B.session?.fields,freshAge:B.session?.freshAge,preserveSessionInDatabase:B.session?.preserveSessionInDatabase,storeSessionInDatabase:B.session?.storeSessionInDatabase,updateAge:B.session?.updateAge},account:{modelName:B.account?.modelName,fields:B.account?.fields,encryptOAuthTokens:B.account?.encryptOAuthTokens,updateAccountOnSignIn:B.account?.updateAccountOnSignIn,accountLinking:{enabled:B.account?.accountLinking?.enabled,trustedProviders:B.account?.accountLinking?.trustedProviders,updateUserInfoOnLink:B.account?.accountLinking?.updateUserInfoOnLink,allowUnlinkingAll:B.account?.accountLinking?.allowUnlinkingAll}},hooks:{after:!!B.hooks?.after,before:!!B.hooks?.before},secondaryStorage:!!B.secondaryStorage,advanced:{cookiePrefix:!!B.advanced?.cookiePrefix,cookies:!!B.advanced?.cookies,crossSubDomainCookies:{domain:!!B.advanced?.crossSubDomainCookies?.domain,enabled:B.advanced?.crossSubDomainCookies?.enabled,additionalCookies:B.advanced?.crossSubDomainCookies?.additionalCookies},database:{generateId:B.advanced?.database?.generateId,defaultFindManyLimit:B.advanced?.database?.defaultFindManyLimit},useSecureCookies:B.advanced?.useSecureCookies,ipAddress:{disableIpTracking:B.advanced?.ipAddress?.disableIpTracking,ipAddressHeaders:B.advanced?.ipAddress?.ipAddressHeaders},disableCSRFCheck:B.advanced?.disableCSRFCheck,cookieAttributes:{expires:B.advanced?.defaultCookieAttributes?.expires,secure:B.advanced?.defaultCookieAttributes?.secure,sameSite:B.advanced?.defaultCookieAttributes?.sameSite,domain:!!B.advanced?.defaultCookieAttributes?.domain,path:B.advanced?.defaultCookieAttributes?.path,httpOnly:B.advanced?.defaultCookieAttributes?.httpOnly}},trustedOrigins:B.trustedOrigins?.length,rateLimit:{storage:B.rateLimit?.storage,modelName:B.rateLimit?.modelName,window:B.rateLimit?.window,customStorage:!!B.rateLimit?.customStorage,enabled:B.rateLimit?.enabled,max:B.rateLimit?.max},onAPIError:{errorURL:B.onAPIError?.errorURL,onError:!!B.onAPIError?.onError,throw:B.onAPIError?.throw},logger:{disabled:B.logger?.disabled,level:B.logger?.level,log:!!B.logger?.log},databaseHooks:{user:{create:{after:!!B.databaseHooks?.user?.create?.after,before:!!B.databaseHooks?.user?.create?.before},update:{after:!!B.databaseHooks?.user?.update?.after,before:!!B.databaseHooks?.user?.update?.before}},session:{create:{after:!!B.databaseHooks?.session?.create?.after,before:!!B.databaseHooks?.session?.create?.before},update:{after:!!B.databaseHooks?.session?.update?.after,before:!!B.databaseHooks?.session?.update?.before}},account:{create:{after:!!B.databaseHooks?.account?.create?.after,before:!!B.databaseHooks?.account?.create?.before},update:{after:!!B.databaseHooks?.account?.update?.after,before:!!B.databaseHooks?.account?.update?.before}},verification:{create:{after:!!B.databaseHooks?.verification?.create?.after,before:!!B.databaseHooks?.verification?.create?.before},update:{after:!!B.databaseHooks?.verification?.update?.after,before:!!B.databaseHooks?.verification?.update?.before}}}}}function S6F(){let B=T0.npm_config_user_agent;if(!B)return;let Q=B.split(" ")[0],F=Q.lastIndexOf("/"),U=Q.substring(0,F);return{name:U==="npminstall"?"cnpm":U,version:Q.substring(F+1)}}function y6F(){return T0.CI!=="false"&&(("BUILD_ID"in T0)||("BUILD_NUMBER"in T0)||("CI"in T0)||("CI_APP_ID"in T0)||("CI_BUILD_ID"in T0)||("CI_BUILD_NUMBER"in T0)||("CI_NAME"in T0)||("CONTINUOUS_INTEGRATION"in T0)||("RUN_ID"in T0))}function M6F(){if(typeof Deno<"u")return{name:"deno",version:Deno?.version?.deno??null};if(typeof Bun<"u")return{name:"bun",version:Bun?.version??null};if(typeof process<"u"&&process?.versions?.node)return{name:"node",version:process.versions.node??null};return{name:"edge",version:null}}function T6F(){return ZI("NODE_ENV")==="production"?"production":y6F()?"ci":HJ()?"test":"development"}async function MwQ(B){let Q=await Sw("SHA-256").digest(B);return ZV.encode(Q)}var m6F=(B)=>{return oT("a-z","A-Z","0-9")(B||32)},sE;async function hwQ(){if(sE)return sE;try{let B=process.cwd();if(!B)return;let Q=await cwQ.readFile(KwQ.join(B,"package.json"),"utf-8");return sE=JSON.parse(Q),sE}catch{}}async function kwQ(B){if(sE)return sE.dependencies?.[B]||sE.devDependencies?.[B]||sE.peerDependencies?.[B];try{let Q=process.cwd();if(!Q)throw Error("no-cwd");let F=KwQ.join(Q,"node_modules",B,"package.json"),U=await cwQ.readFile(F,"utf-8");return JSON.parse(U).version||await TwQ(B)||void 0}catch{}return TwQ(B)}async function TwQ(B){let Q=await hwQ();if(!Q)return;return{...Q.dependencies,...Q.devDependencies,...Q.peerDependencies}[B]}async function O6F(){return(await hwQ())?.name}async function c6F(){try{let B=Vm.cpus();return{deploymentVendor:K6F(),systemPlatform:Vm.platform(),systemRelease:Vm.release(),systemArchitecture:Vm.arch(),cpuCount:B.length,cpuModel:B.length?B[0].model:null,cpuSpeed:B.length?B[0].speed:null,memory:Vm.totalmem(),isWSL:await $6F(),isDocker:await dwQ(),isTTY:process.stdout?process.stdout.isTTY:null}}catch{return{systemPlatform:null,systemRelease:null,systemArchitecture:null,cpuCount:null,cpuModel:null,cpuSpeed:null,memory:null,isWSL:null,isDocker:null,isTTY:null}}}function K6F(){let B=process.env,Q=(...F)=>F.some((U)=>Boolean(B[U]));if(Q("CF_PAGES","CF_PAGES_URL","CF_ACCOUNT_ID")||typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers")return"cloudflare";if(Q("VERCEL","VERCEL_URL","VERCEL_ENV"))return"vercel";if(Q("NETLIFY","NETLIFY_URL"))return"netlify";if(Q("RENDER","RENDER_URL","RENDER_INTERNAL_HOSTNAME","RENDER_SERVICE_ID"))return"render";if(Q("AWS_LAMBDA_FUNCTION_NAME","AWS_EXECUTION_ENV","LAMBDA_TASK_ROOT"))return"aws";if(Q("GOOGLE_CLOUD_FUNCTION_NAME","GOOGLE_CLOUD_PROJECT","GCP_PROJECT","K_SERVICE"))return"gcp";if(Q("AZURE_FUNCTION_NAME","FUNCTIONS_WORKER_RUNTIME","WEBSITE_INSTANCE_ID","WEBSITE_SITE_NAME"))return"azure";if(Q("DENO_DEPLOYMENT_ID","DENO_REGION"))return"deno-deploy";if(Q("FLY_APP_NAME","FLY_REGION","FLY_ALLOC_ID"))return"fly-io";if(Q("RAILWAY_STATIC_URL","RAILWAY_ENVIRONMENT_NAME"))return"railway";if(Q("DYNO","HEROKU_APP_NAME"))return"heroku";if(Q("DO_DEPLOYMENT_ID","DO_APP_NAME","DIGITALOCEAN"))return"digitalocean";if(Q("KOYEB","KOYEB_DEPLOYMENT_ID","KOYEB_APP_NAME"))return"koyeb";return null}var QLB;async function h6F(){try{return Br.statSync("/.dockerenv"),!0}catch{return!1}}async function k6F(){try{return Br.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}async function dwQ(){if(QLB===void 0)QLB=await h6F()||await k6F();return QLB}var FLB,d6F=async()=>{try{return Br.statSync("/run/.containerenv"),!0}catch{return!1}};async function mwQ(){if(FLB===void 0)FLB=await d6F()||await dwQ();return FLB}async function $6F(){try{if(process.platform!=="linux")return!1;if(Vm.release().toLowerCase().includes("microsoft")){if(await mwQ())return!1;return!0}return Br.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!await mwQ():!1}catch{return!1}}var rE=null;async function OwQ(B){if(rE)return rE;let Q=await O6F();if(Q)return rE=await MwQ(B?B+Q:Q),rE;if(B)return rE=await MwQ(B),rE;return rE=m6F(32),rE}async function _6F(){for(let[B,Q]of Object.entries({pg:"postgresql",mysql:"mysql",mariadb:"mariadb",sqlite3:"sqlite","better-sqlite3":"sqlite","@prisma/client":"prisma",mongoose:"mongodb",mongodb:"mongodb","drizzle-orm":"drizzle"})){let F=await kwQ(B);if(F)return{name:Q,version:F}}}async function v6F(){for(let[B,Q]of Object.entries({next:"next",nuxt:"nuxt","react-router":"react-router",astro:"astro","@sveltejs/kit":"sveltekit","solid-start":"solid-start","tanstack-start":"tanstack-start",hono:"hono",express:"express",elysia:"elysia",expo:"expo"})){let F=await kwQ(B);if(F)return{name:Q,version:F}}}var P6F=async function(){};async function $wQ(B,Q){let F=B.telemetry?.debug||Sp("BETTER_AUTH_TELEMETRY_DEBUG",!1),U=Y2B.BETTER_AUTH_TELEMETRY_ENDPOINT;if(!U&&!Q?.customTrack)return{publish:P6F};let I=async(g)=>{if(Q?.customTrack)await Q.customTrack(g).catch(ZF.error);else if(U)if(F)ZF.info("telemetry event",JSON.stringify(g,null,2));else await kQ(U,{method:"POST",body:g}).catch(ZF.error)},Z=await(async()=>{let g=B.telemetry?.enabled!==void 0?B.telemetry.enabled:!1;return(Sp("BETTER_AUTH_TELEMETRY",!1)||g)&&(Q?.skipTestCheck||!HJ())})(),W;if(Z)W=await OwQ(typeof B.baseURL==="string"?B.baseURL:void 0),I({type:"init",payload:{config:await w6F(B,Q),runtime:M6F(),database:await _6F(),framework:await v6F(),environment:T6F(),systemInfo:await c6F(),packageManager:S6F()},anonymousId:W});return{publish:async(g)=>{if(!Z)return;if(!W)W=await OwQ(typeof B.baseURL==="string"?B.baseURL:void 0);await I({type:g.type,payload:g.payload,anonymousId:W})}}}function f6F(B){let Q=new Set(B).size;if(Q===0)return 0;return Math.log2(Math.pow(Q,B.length))}function l6F(B,Q){let F=B===zwQ;if(HJ())return;if(F&&VE)throw new OQ("You are using the default secret. Please set `BETTER_AUTH_SECRET` in your environment variables or pass `secret` in your auth config.");if(!B)throw new OQ("BETTER_AUTH_SECRET is missing. Set it in your environment or pass `secret` to betterAuth({ secret }).");if(B.length<32)Q.warn("[better-auth] Warning: your BETTER_AUTH_SECRET should be at least 32 characters long for adequate security. Generate one with `npx auth secret` or `openssl rand -base64 32`.");if(f6F(B)<120)Q.warn("[better-auth] Warning: your BETTER_AUTH_SECRET appears low-entropy. Use a randomly generated secret for production.")}async function _wQ(B,Q,F){if(!Q.database)Q=$o(Q,{session:{cookieCache:{enabled:!0,strategy:"jwe",refreshCache:!0,maxAge:Q.session?.expiresIn||604800}},account:{storeStateStrategy:"cookie",storeAccountCookie:!0}});let U=Q.plugins||[],I=tDQ(Q),G=JJ(Q.logger),Z=Q2(Q.baseURL);if(Q2(Q.baseURL)){let{allowedHosts:c}=Q.baseURL;if(!c||c.length===0)throw new OQ('baseURL.allowedHosts cannot be empty. Provide at least one allowed host pattern (e.g., ["myapp.com", "*.vercel.app"]).')}let W=Z?void 0:_J(typeof Q.baseURL==="string"?Q.baseURL:void 0,Q.basePath);if(!W&&!Z)G.warn("[better-auth] Base URL could not be determined. Please set a valid base URL using the baseURL config option or the BETTER_AUTH_URL environment variable. Without this, callbacks and redirects may not work correctly.");if(B.id==="memory"&&Q.advanced?.database?.generateId===!1)G.error(`[better-auth] Misconfiguration detected.
13867
13867
  You are using the memory DB with generateId: false.
13868
13868
  This will cause no id to be generated for any model.
13869
- Most of the features of Better Auth will not work correctly.`);let g=Q.secrets??wwQ(T0.BETTER_AUTH_SECRETS),V=Q.secret||T0.BETTER_AUTH_SECRET||T0.AUTH_SECRET||"",b,X;if(g)SwQ(g,G),b=g[0].value,X=ywQ(g,V);else b=V||"better-auth-secret-12345678901234567890",l6F(b,G),X=b;Q={...Q,secret:b,baseURL:Z?Q.baseURL:W?new URL(W).origin:"",basePath:Q.basePath||"/api/auth",plugins:U.concat(I)},EwQ(Q,G);let C=mo(Q),N=mX(Q),R=(await Promise.all(Object.entries(Q.socialProviders||{}).map(async([c,k])=>{let d=typeof k==="function"?await k():k;if(d==null)return null;if(d.enabled===!1)return null;if(!d.clientId)G.warn(`Social provider ${c} is missing clientId or clientSecret`);let $=rYB[c](d);return $.disableImplicitSignUp=d.disableImplicitSignUp,$}))).filter((c)=>c!==null),A=({model:c,size:k})=>{if(typeof Q.advanced?.generateId==="function")return Q.advanced.generateId({model:c,size:k});let d=Q?.advanced?.database?.generateId;if(typeof d==="function")return d({model:c,size:k});if(d==="uuid")return crypto.randomUUID();if(d==="serial"||d===!1)return!1;return vN(k)},{publish:Y}=await $wQ(Q,{adapter:B.id,database:typeof Q.database==="function"?"adapter":F(Q.database)}),L=new Set(Q.plugins.map((c)=>c.id)),H=(c)=>Q.plugins.find((k)=>k.id===c)??null,J=(c)=>L.has(c),w=await jd(Q),M=await nd(Q),y={appName:Q.appName||"Better Auth",baseURL:W||"",version:gYB(),socialProviders:R,options:Q,oauthConfig:{storeStateStrategy:Q.account?.storeStateStrategy||(Q.database?"database":"cookie"),skipStateCookieCheck:!!Q.account?.skipStateCookieCheck},tables:N,trustedOrigins:w,trustedProviders:M,isTrustedOrigin(c,k){return this.trustedOrigins.some((d)=>ea(c,d,k))},sessionConfig:{updateAge:Q.session?.updateAge!==void 0?Q.session.updateAge:86400,expiresIn:Q.session?.expiresIn||604800,freshAge:Q.session?.freshAge===void 0?86400:Q.session.freshAge,cookieRefreshCache:(()=>{let c=Q.session?.cookieCache?.refreshCache,k=Q.session?.cookieCache?.maxAge||300;if((!!Q.database||!!Q.secondaryStorage)&&c)return G.warn("[better-auth] `session.cookieCache.refreshCache` is enabled while `database` or `secondaryStorage` is configured. `refreshCache` is meant for stateless (DB-less) setups. Disabling `refreshCache` \u2014 remove it from your config to silence this warning."),!1;if(c===!1||c===void 0)return!1;if(c===!0)return{enabled:!0,updateAge:Math.floor(k*0.2)};return{enabled:!0,updateAge:c.updateAge!==void 0?c.updateAge:Math.floor(k*0.2)}})()},secret:b,secretConfig:X,rateLimit:{...Q.rateLimit,enabled:Q.rateLimit?.enabled??VE,window:Q.rateLimit?.window||10,max:Q.rateLimit?.max||100,storage:Q.rateLimit?.storage||(Q.secondaryStorage?"secondary-storage":"memory")},authCookies:C,logger:G,generateId:A,session:null,secondaryStorage:Q.secondaryStorage,password:{hash:Q.emailAndPassword?.password?.hash||YEQ,verify:Q.emailAndPassword?.password?.verify||LEQ,config:{minPasswordLength:Q.emailAndPassword?.minPasswordLength||8,maxPasswordLength:Q.emailAndPassword?.maxPasswordLength||128},checkPassword:Q3Q},setNewSession(c){this.newSession=c},newSession:null,adapter:B,internalAdapter:ko(B,{options:Q,logger:G,hooks:Q.databaseHooks?[{source:"user",hooks:Q.databaseHooks}]:[],generateId:A}),createAuthCookie:_d(Q),async runMigrations(){throw new OQ("runMigrations will be set by the specific init implementation")},publishTelemetry:Y,skipCSRFCheck:!!Q.advanced?.disableCSRFCheck,skipOriginCheck:Q.advanced?.disableOriginCheck!==void 0?Q.advanced.disableOriginCheck:HJ()?!0:!1,runInBackground:Q.advanced?.backgroundTasks?.handler??((c)=>{c.catch(()=>{})}),async runInBackgroundOrAwait(c){try{if(Q.advanced?.backgroundTasks?.handler){if(c instanceof Promise)Q.advanced.backgroundTasks.handler(c.catch((k)=>{G.error("Failed to run background task:",k)}))}else await c}catch(k){G.error("Failed to run background task:",k)}},getPlugin:H,hasPlugin:J},m=sDQ(y);if(_7(m))await m;return y}PU();ta();var vwQ=async(B)=>{let Q=await GEQ(B),U=await _wQ(Q,B,(I)=>Ld(I)||"unknown");return U.runMigrations=async function(){if(!B.database||"updateMany"in B.database)throw new OQ("Database is not provided or it's an adapter. Migrations are only supported with a database instance.");let{runMigrations:I}=await WEQ(B);await I()},U};PU();var PwQ=(B,Q)=>{let F=Q(B),{api:U}=BLB(F,B);return{handler:async(I)=>{let G=await F,Z=G.options.basePath||"/api/auth",W;if(Q2(B.baseURL))W=await vo(G,I,_o(G.options));else{if(W=G,!G.options.baseURL){let V=_J(void 0,Z,I,void 0,G.options.advanced?.trustedProxyHeaders);if(V)G.baseURL=V,G.options.baseURL=OE(G.baseURL)||void 0;else throw new OQ("Could not get base URL from request. Please provide a valid base URL.")}W.trustedOrigins=await jd(G.options,I),W.trustedProviders=await nd(G.options,I)}let{handler:g}=DwQ(W,B);return RYB(W.adapter,()=>g(I))},api:U,options:B,$context:F,$ERROR_CODES:{...B.plugins?.reduce((I,G)=>{if(G.$ERROR_CODES)return{...I,...G.$ERROR_CODES};return I},{}),...LQ}}};var ULB=(B)=>{return PwQ(B,vwQ)};Tb();PU();J2B();pz();XE();wk();PU();function ILB(B){return B?.code==="P2025"||B?.meta?.cause==="Record to delete does not exist."}var fwQ=(B,Q)=>{let F=null,U=(Z,W=!1)=>({getFieldName:g,getModelName:V,getFieldAttributes:b,getDefaultModelName:X,schema:C})=>{let N=Z,R=(J,w,M)=>{if(!J&&!M)return;let y={};if(J)for(let m of J)y[g({model:w,field:m})]=!0;if(M){if(!J){let m=C[X(w)]?.fields||{};m.id={type:"string"};for(let c of Object.keys(m))y[g({model:w,field:c})]=!0}for(let[m,c]of Object.entries(M)){let k=A(w,V(m),C);if(c.relation==="one-to-one")y[k]=!0;else y[k]={take:c.limit}}}return y},A=(J,w,M)=>{try{let y=X(J),m=X(w),c=V(w).toLowerCase(),k=Object.entries(M[m]?.fields||{}).filter(([d,$])=>$.references&&X($.references.model)===y);if(k.length>0){let[d,$]=k[0];return $?.unique===!0||Q.usePlural===!0?c:`${c}s`}if(k=Object.entries(M[y]?.fields||{}).filter(([d,$])=>$.references&&X($.references.model)===m),k.length>0)return c}catch{}return`${V(w).toLowerCase()}s`};function Y(J){switch(J){case"starts_with":return"startsWith";case"ends_with":return"endsWith";case"ne":return"not";case"not_in":return"notIn";default:return J}}let L=(J,w)=>{if(!w?.length)return!1;return w.some((M)=>{if(M.connector==="OR")return!1;if(M.operator&&M.operator!=="eq")return!1;if(M.mode==="insensitive"){let y=Q.provider==="postgresql"||Q.provider==="mongodb",m=typeof M.value==="string"||Array.isArray(M.value)&&M.value.every((c)=>typeof c==="string");if(y&&m)return!1}if(M.field==="id")return!0;return b({model:J,field:M.field})?.unique===!0})},H=({action:J,model:w,where:M})=>{if(!M||!M.length)return{};let y=($)=>{let FB=g({model:w,field:$.field}),bB=($.mode??"sensitive")==="insensitive"&&(typeof $.value==="string"||Array.isArray($.value)&&$.value.every((LB)=>typeof LB==="string")),CB=Q.provider==="postgresql"||Q.provider==="mongodb",IB=bB&&CB?"insensitive":void 0,t=IB?{mode:IB}:{};if($.operator==="ne"&&$.value===null)return b({model:w,field:$.field})?.required!==!0?{[FB]:{not:null}}:{};if(($.operator==="in"||$.operator==="not_in")&&Array.isArray($.value)){let LB=$.value.filter((HQ)=>HQ!=null);if(LB.length===0)if($.operator==="in")return{AND:[{[FB]:{equals:"__never__"}},{[FB]:{not:"__never__"}}]};else return{};let NQ=Y($.operator);return{[FB]:{[NQ]:LB,...t}}}if($.operator==="eq"||!$.operator)return{[FB]:{equals:$.value,...t}};if($.operator==="ne")return{[FB]:{not:{equals:$.value},...t}};let ZB=Y($.operator);return{[FB]:{[ZB]:$.value,...t}}};if(J==="update"){let $=M.filter((ZB)=>ZB.connector==="AND"||!ZB.connector),FB=M.filter((ZB)=>ZB.connector==="OR"),bB=$.filter((ZB)=>ZB.operator==="eq"||!ZB.operator),CB=$.filter((ZB)=>ZB.operator!=="eq"&&ZB.operator!==void 0).map((ZB)=>y(ZB)),IB=FB.map((ZB)=>y(ZB)),t={};for(let ZB of bB){let LB=g({model:w,field:ZB.field});t[LB]=ZB.value}if(CB.length>0)t.AND=CB;if(IB.length>0)t.OR=IB;return t}if(J==="delete"){let $=M.find((FB)=>FB.field==="id");if($){let FB=g({model:w,field:"id"}),bB=M.filter((NQ)=>NQ.field!=="id");if(bB.length===0)return{[FB]:$.value};let CB=bB.filter((NQ)=>NQ.connector==="AND"||!NQ.connector),IB=bB.filter((NQ)=>NQ.connector==="OR"),t=CB.map((NQ)=>y(NQ)),ZB=IB.map((NQ)=>y(NQ)),LB={[FB]:$.value};if(t.length>0)LB.AND=t;if(ZB.length>0)LB.OR=ZB;return LB}}if(M.length===1){let $=M[0];if(!$)return;return y($)}let m=M.filter(($)=>$.connector==="AND"||!$.connector),c=M.filter(($)=>$.connector==="OR"),k=m.map(($)=>y($)),d=c.map(($)=>y($));return{...k.length?{AND:k}:{},...d.length?{OR:d}:{}}};return{async create({model:J,data:w,select:M}){if(!N[J])throw new OQ(`Model ${J} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);return await N[J].create({data:w,select:R(M,J)})},async findOne({model:J,where:w,select:M,join:y}){let m=H({model:J,where:w,action:"findOne"});if(!N[J])throw new OQ(`Model ${J} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);let c=new Map;for(let $ of Object.keys(y??{})){let FB=A(J,$,C);c.set(FB,V($))}let k=R(M,J,y),d=await N[J].findFirst({where:m,select:k});if(y&&d)for(let[$,FB]of c.entries()){if($===FB)continue;if($ in d)d[FB]=d[$],delete d[$]}return d},async findMany({model:J,where:w,limit:M,select:y,offset:m,sortBy:c,join:k}){let d=H({model:J,where:w,action:"findMany"});if(!N[J])throw new OQ(`Model ${J} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);let $=new Map;if(k)for(let[CB,IB]of Object.entries(k)){let t=A(J,CB,C);$.set(t,V(CB))}let FB=R(y,J,k),bB=await N[J].findMany({where:d,take:M||100,skip:m||0,...c?.field?{orderBy:{[g({model:J,field:c.field})]:c.direction==="desc"?"desc":"asc"}}:{},select:FB});if(k&&Array.isArray(bB))for(let CB of bB)for(let[IB,t]of $.entries()){if(IB===t)continue;if(IB in CB)CB[t]=CB[IB],delete CB[IB]}return bB},async count({model:J,where:w}){let M=H({model:J,where:w,action:"count"});if(!N[J])throw new OQ(`Model ${J} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);return await N[J].count({where:M})},async update({model:J,where:w,update:M}){if(!N[J])throw new OQ(`Model ${J} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);if(!L(J,w)){let m=H({model:J,where:w,action:"updateMany"});if(!(await N[J].updateMany({where:m,data:M}))?.count)return null;return await N[J].findFirst({where:m})}let y=H({model:J,where:w,action:"update"});return await N[J].update({where:y,data:M})},async updateMany({model:J,where:w,update:M}){if(!N[J])throw new OQ(`Model ${J} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);let y=H({model:J,where:w,action:"updateMany"}),m=await N[J].updateMany({where:y,data:M});return m?m.count:0},async delete({model:J,where:w}){if(!N[J])throw new OQ(`Model ${J} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);if(!w?.some((y)=>y.field==="id")){let y=H({model:J,where:w,action:"deleteMany"});await N[J].deleteMany({where:y});return}let M=H({model:J,where:w,action:"delete"});try{await N[J].delete({where:M})}catch(y){if(ILB(y))return;console.log(y)}},async deleteMany({model:J,where:w}){let M=H({model:J,where:w,action:"deleteMany"}),y=await N[J].deleteMany({where:M});return y?y.count:0},async consumeOne({model:J,where:w}){if(!N[J])throw new OQ(`Model ${J} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);if(w?.some((m)=>m.field==="id")){let m=H({model:J,where:w,action:"delete"});try{return await N[J].delete({where:m})??null}catch(c){if(ILB(c))return null;throw c}}let M=H({model:J,where:w,action:"findOne"}),y=async(m)=>{let c=await m[J].findFirst({where:M});if(!c)return null;try{return(await m[J].deleteMany({where:H({model:J,where:[...w??[],{field:"id",value:c.id,operator:"eq",connector:"AND",mode:"sensitive"}],action:"deleteMany"})}))?.count>0?c:null}catch(k){if(ILB(k))return null;throw k}};return W||typeof N.$transaction!=="function"?y(N):N.$transaction(y)},options:Q}},I=null;I={config:{adapterId:"prisma",adapterName:"Prisma Adapter",usePlural:Q.usePlural??!1,debugLogs:Q.debugLogs??!1,supportsUUIDs:Q.provider==="postgresql"?!0:!1,supportsArrays:Q.provider==="postgresql"||Q.provider==="mongodb"?!0:!1,transaction:Q.transaction??!1?(Z)=>B.$transaction((W)=>{return Z(EJ({config:{...I.config,transaction:!1},adapter:U(W,!0)})(F))}):!1},adapter:U(B)};let G=EJ(I);return(Z)=>{return F=Z,G(Z)}};var lwQ={openai:{name:"openai",config:{api:"openai-responses",baseUrl:"https://api.openai.com/v1",apiKey:"OPENAI_API_KEY"},models:[{modelId:"gpt-4",name:"GPT-4",config:{api:"openai-responses",reasoning:!1,input:["text"],contextWindow:8192,maxTokens:8192,cost:{input:30,output:60,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-4-turbo",name:"GPT-4 Turbo",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:10,output:30,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-4.1",name:"GPT-4.1",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"gpt-4.1-mini",name:"GPT-4.1 mini",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:0.4,output:1.6,cacheRead:0.1,cacheWrite:0}}},{modelId:"gpt-4.1-nano",name:"GPT-4.1 nano",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:0.1,output:0.4,cacheRead:0.025,cacheWrite:0}}},{modelId:"gpt-4o",name:"GPT-4o",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"gpt-4o-2024-05-13",name:"GPT-4o (2024-05-13)",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:5,output:15,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-4o-2024-08-06",name:"GPT-4o (2024-08-06)",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"gpt-4o-2024-11-20",name:"GPT-4o (2024-11-20)",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"gpt-4o-mini",name:"GPT-4o mini",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0.075,cacheWrite:0}}},{modelId:"gpt-5",name:"GPT-5",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5-chat-latest",name:"GPT-5 Chat Latest",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5-codex",name:"GPT-5-Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5-mini",name:"GPT-5 Mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"gpt-5-nano",name:"GPT-5 Nano",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.05,output:0.4,cacheRead:0.005,cacheWrite:0}}},{modelId:"gpt-5-pro",name:"GPT-5 Pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:15,output:120,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-5.1",name:"GPT-5.1",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-chat-latest",name:"GPT-5.1 Chat",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-codex",name:"GPT-5.1 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"gpt-5.2",name:"GPT-5.2",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-chat-latest",name:"GPT-5.2 Chat",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-codex",name:"GPT-5.2 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-pro",name:"GPT-5.2 Pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:21,output:168,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-5.3-chat-latest",name:"GPT-5.3 Chat (latest)",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.3-codex",name:"GPT-5.3 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:32000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.4",name:"GPT-5.4",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:272000,maxTokens:128000,cost:{input:2.5,output:15,cacheRead:0.25,cacheWrite:0}}},{modelId:"gpt-5.4-mini",name:"GPT-5.4 mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.75,output:4.5,cacheRead:0.075,cacheWrite:0}}},{modelId:"gpt-5.4-nano",name:"GPT-5.4 nano",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.2,output:1.25,cacheRead:0.02,cacheWrite:0}}},{modelId:"gpt-5.4-pro",name:"GPT-5.4 Pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-5.5",name:"GPT-5.5",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:272000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"gpt-5.5-pro",name:"GPT-5.5 Pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:0,cacheWrite:0}}},{modelId:"o1",name:"o1",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0}}},{modelId:"o1-pro",name:"o1-pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:150,output:600,cacheRead:0,cacheWrite:0}}},{modelId:"o3",name:"o3",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"o3-deep-research",name:"o3-deep-research",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0}}},{modelId:"o3-mini",name:"o3-mini",config:{api:"openai-responses",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.55,cacheWrite:0}}},{modelId:"o3-pro",name:"o3-pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:20,output:80,cacheRead:0,cacheWrite:0}}},{modelId:"o4-mini",name:"o4-mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.275,cacheWrite:0}}},{modelId:"o4-mini-deep-research",name:"o4-mini-deep-research",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}}]},anthropic:{name:"anthropic",config:{api:"anthropic-messages",baseUrl:"https://api.anthropic.com",apiKey:"ANTHROPIC_API_KEY"},models:[{modelId:"claude-3-5-haiku-20241022",name:"Claude Haiku 3.5",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:0.8,output:4,cacheRead:0.08,cacheWrite:1}}},{modelId:"claude-3-5-haiku-latest",name:"Claude Haiku 3.5 (latest)",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:0.8,output:4,cacheRead:0.08,cacheWrite:1}}},{modelId:"claude-3-5-sonnet-20240620",name:"Claude Sonnet 3.5",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-3-5-sonnet-20241022",name:"Claude Sonnet 3.5 v2",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-3-7-sonnet-20250219",name:"Claude Sonnet 3.7",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-3-haiku-20240307",name:"Claude Haiku 3",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:0.25,output:1.25,cacheRead:0.03,cacheWrite:0.3}}},{modelId:"claude-3-opus-20240229",name:"Claude Opus 3",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-3-sonnet-20240229",name:"Claude Sonnet 3",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:0.3}}},{modelId:"claude-fable-5",name:"Claude Fable 5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5}}},{modelId:"claude-haiku-4-5",name:"Claude Haiku 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"claude-opus-4-0",name:"Claude Opus 4 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-opus-4-1",name:"Claude Opus 4.1 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-opus-4-1-20250805",name:"Claude Opus 4.1",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-opus-4-20250514",name:"Claude Opus 4",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-opus-4-5",name:"Claude Opus 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-6",name:"Claude Opus 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-7",name:"Claude Opus 4.7",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-8",name:"Claude Opus 4.8",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-sonnet-4-0",name:"Claude Sonnet 4 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4-5",name:"Claude Sonnet 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}}]},google:{name:"google",config:{api:"google-generative-ai",baseUrl:"https://generativelanguage.googleapis.com/v1beta",apiKey:"GEMINI_API_KEY"},models:[{modelId:"gemini-2.0-flash",name:"Gemini 2.0 Flash",config:{api:"google-generative-ai",reasoning:!1,input:["text","image"],contextWindow:1048576,maxTokens:8192,cost:{input:0.1,output:0.4,cacheRead:0.025,cacheWrite:0}}},{modelId:"gemini-2.0-flash-lite",name:"Gemini 2.0 Flash-Lite",config:{api:"google-generative-ai",reasoning:!1,input:["text","image"],contextWindow:1048576,maxTokens:8192,cost:{input:0.075,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"gemini-2.5-flash",name:"Gemini 2.5 Flash",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.3,output:2.5,cacheRead:0.03,cacheWrite:0}}},{modelId:"gemini-2.5-flash-lite",name:"Gemini 2.5 Flash-Lite",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.1,output:0.4,cacheRead:0.01,cacheWrite:0}}},{modelId:"gemini-2.5-pro",name:"Gemini 2.5 Pro",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.5,output:3,cacheRead:0.05,cacheWrite:0}}},{modelId:"gemini-3-pro-preview",name:"Gemini 3 Pro Preview",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"gemini-3.1-flash-lite",name:"Gemini 3.1 Flash Lite",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.25,output:1.5,cacheRead:0.025,cacheWrite:0}}},{modelId:"gemini-3.1-flash-lite-preview",name:"Gemini 3.1 Flash Lite Preview",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.25,output:1.5,cacheRead:0.025,cacheWrite:0}}},{modelId:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"gemini-3.1-pro-preview-customtools",name:"Gemini 3.1 Pro Preview Custom Tools",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"gemini-3.5-flash",name:"Gemini 3.5 Flash",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.5,output:9,cacheRead:0.15,cacheWrite:0}}},{modelId:"gemini-flash-latest",name:"Gemini Flash Latest",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.3,output:2.5,cacheRead:0.075,cacheWrite:0}}},{modelId:"gemini-flash-lite-latest",name:"Gemini Flash-Lite Latest",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.1,output:0.4,cacheRead:0.025,cacheWrite:0}}},{modelId:"gemma-4-26b-a4b-it",name:"Gemma 4 26B A4B IT",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"gemma-4-31b-it",name:"Gemma 4 31B IT",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"gemma-4-E2B-it",name:"Gemma 4 E2B IT",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:131072,maxTokens:8192,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"gemma-4-E4B-it",name:"Gemma 4 E4B IT",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:131072,maxTokens:8192,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}}]},deepseek:{name:"deepseek",config:{api:"openai-completions",baseUrl:"https://api.deepseek.com",apiKey:"DEEPSEEK_API_KEY"},models:[{modelId:"deepseek-v4-flash",name:"DeepSeek V4 Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:0.14,output:0.28,cacheRead:0.0028,cacheWrite:0}}},{modelId:"deepseek-v4-pro",name:"DeepSeek V4 Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:0.435,output:0.87,cacheRead:0.003625,cacheWrite:0}}}]},groq:{name:"groq",config:{api:"openai-completions",baseUrl:"https://api.groq.com/openai/v1",apiKey:"GROQ_API_KEY"},models:[{modelId:"llama-3.1-8b-instant",name:"Llama 3.1 8B",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.05,output:0.08,cacheRead:0,cacheWrite:0}}},{modelId:"llama-3.3-70b-versatile",name:"Llama 3.3 70B",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:32768,cost:{input:0.59,output:0.79,cacheRead:0,cacheWrite:0}}},{modelId:"meta-llama/llama-4-scout-17b-16e-instruct",name:"Llama 4 Scout 17B 16E",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:131072,maxTokens:8192,cost:{input:0.11,output:0.34,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-120b",name:"GPT OSS 120B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:65536,cost:{input:0.15,output:0.6,cacheRead:0.075,cacheWrite:0}}},{modelId:"openai/gpt-oss-20b",name:"GPT OSS 20B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:65536,cost:{input:0.075,output:0.3,cacheRead:0.0375,cacheWrite:0}}},{modelId:"openai/gpt-oss-safeguard-20b",name:"Safety GPT OSS 20B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:65536,cost:{input:0.075,output:0.3,cacheRead:0.037,cacheWrite:0}}},{modelId:"qwen/qwen3-32b",name:"Qwen3-32B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:40960,cost:{input:0.29,output:0.59,cacheRead:0,cacheWrite:0}}}]},openrouter:{name:"openrouter",config:{api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",apiKey:"OPENROUTER_API_KEY"},models:[{modelId:"ai21/jamba-large-1.7",name:"AI21: Jamba Large 1.7",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:4096,cost:{input:2,output:8,cacheRead:0,cacheWrite:0}}},{modelId:"amazon/nova-2-lite-v1",name:"Amazon: Nova 2 Lite",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65535,cost:{input:0.3,output:2.5,cacheRead:0,cacheWrite:0}}},{modelId:"amazon/nova-lite-v1",name:"Amazon: Nova Lite 1.0",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:300000,maxTokens:5120,cost:{input:0.06,output:0.24,cacheRead:0,cacheWrite:0}}},{modelId:"amazon/nova-micro-v1",name:"Amazon: Nova Micro 1.0",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:5120,cost:{input:0.035,output:0.14,cacheRead:0,cacheWrite:0}}},{modelId:"amazon/nova-premier-v1",name:"Amazon: Nova Premier 1.0",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:1e6,maxTokens:32000,cost:{input:2.5,output:12.5,cacheRead:0.625,cacheWrite:0}}},{modelId:"amazon/nova-pro-v1",name:"Amazon: Nova Pro 1.0",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:300000,maxTokens:5120,cost:{input:0.8,output:3.2,cacheRead:0,cacheWrite:0}}},{modelId:"anthropic/claude-3-haiku",name:"Anthropic: Claude 3 Haiku",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:0.25,output:1.25,cacheRead:0.03,cacheWrite:0.3}}},{modelId:"anthropic/claude-3.5-haiku",name:"Anthropic: Claude 3.5 Haiku",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:0.8,output:4,cacheRead:0.08,cacheWrite:1}}},{modelId:"anthropic/claude-fable-5",name:"Anthropic: Claude Fable 5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5}}},{modelId:"anthropic/claude-haiku-4.5",name:"Anthropic: Claude Haiku 4.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"anthropic/claude-opus-4",name:"Anthropic: Claude Opus 4",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"anthropic/claude-opus-4.1",name:"Anthropic: Claude Opus 4.1",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"anthropic/claude-opus-4.5",name:"Anthropic: Claude Opus 4.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic/claude-opus-4.6",name:"Anthropic: Claude Opus 4.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic/claude-opus-4.6-fast",name:"Anthropic: Claude Opus 4.6 (Fast)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:30,output:150,cacheRead:3,cacheWrite:37.5}}},{modelId:"anthropic/claude-opus-4.7",name:"Anthropic: Claude Opus 4.7",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic/claude-opus-4.7-fast",name:"Anthropic: Claude Opus 4.7 (Fast)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:30,output:150,cacheRead:3,cacheWrite:37.5}}},{modelId:"anthropic/claude-opus-4.8",name:"Anthropic: Claude Opus 4.8",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic/claude-opus-4.8-fast",name:"Anthropic: Claude Opus 4.8 (Fast)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5}}},{modelId:"anthropic/claude-sonnet-4",name:"Anthropic: Claude Sonnet 4",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"anthropic/claude-sonnet-4.5",name:"Anthropic: Claude Sonnet 4.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"anthropic/claude-sonnet-4.6",name:"Anthropic: Claude Sonnet 4.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"arcee-ai/trinity-large-thinking",name:"Arcee AI: Trinity Large Thinking",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.22,output:0.85,cacheRead:0.06,cacheWrite:0}}},{modelId:"arcee-ai/trinity-mini",name:"Arcee AI: Trinity Mini",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.045,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"arcee-ai/virtuoso-large",name:"Arcee AI: Virtuoso Large",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:64000,cost:{input:0.75,output:1.2,cacheRead:0,cacheWrite:0}}},{modelId:"auto",name:"Auto",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:2000000,maxTokens:30000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"bytedance-seed/seed-1.6",name:"ByteDance Seed: Seed 1.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0.25,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"bytedance-seed/seed-1.6-flash",name:"ByteDance Seed: Seed 1.6 Flash",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0.075,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"bytedance-seed/seed-2.0-lite",name:"ByteDance Seed: Seed-2.0-Lite",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.25,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"bytedance-seed/seed-2.0-mini",name:"ByteDance Seed: Seed-2.0-Mini",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.1,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"cohere/command-r-08-2024",name:"Cohere: Command R (08-2024)",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4000,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"cohere/command-r-plus-08-2024",name:"Cohere: Command R+ (08-2024)",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4000,cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek/deepseek-chat",name:"DeepSeek: DeepSeek V3",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16000,cost:{input:0.2002,output:0.8001,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek/deepseek-chat-v3-0324",name:"DeepSeek: DeepSeek V3 0324",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:163840,maxTokens:16384,cost:{input:0.2,output:0.77,cacheRead:0.135,cacheWrite:0}}},{modelId:"deepseek/deepseek-chat-v3.1",name:"DeepSeek: DeepSeek V3.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:32768,cost:{input:0.21,output:0.79,cacheRead:0.13,cacheWrite:0}}},{modelId:"deepseek/deepseek-r1",name:"DeepSeek: R1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:16000,cost:{input:0.7,output:2.5,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek/deepseek-r1-0528",name:"DeepSeek: R1 0528",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:32768,cost:{input:0.5,output:2.15,cacheRead:0.35,cacheWrite:0}}},{modelId:"deepseek/deepseek-v3.1-terminus",name:"DeepSeek: DeepSeek V3.1 Terminus",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:32768,cost:{input:0.27,output:0.95,cacheRead:0.13,cacheWrite:0}}},{modelId:"deepseek/deepseek-v3.2",name:"DeepSeek: DeepSeek V3.2",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:64000,cost:{input:0.2288,output:0.3432,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek/deepseek-v3.2-exp",name:"DeepSeek: DeepSeek V3.2 Exp",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:65536,cost:{input:0.27,output:0.41,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek/deepseek-v4-flash",name:"DeepSeek: DeepSeek V4 Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:65536,cost:{input:0.09,output:0.18,cacheRead:0.02,cacheWrite:0}}},{modelId:"deepseek/deepseek-v4-pro",name:"DeepSeek: DeepSeek V4 Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:384000,cost:{input:0.435,output:0.87,cacheRead:0.003625,cacheWrite:0}}},{modelId:"essentialai/rnj-1-instruct",name:"EssentialAI: Rnj 1 Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:32768,maxTokens:4096,cost:{input:0.15,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"google/gemini-2.5-flash",name:"Google: Gemini 2.5 Flash",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65535,cost:{input:0.3,output:2.5,cacheRead:0.03,cacheWrite:0.083333}}},{modelId:"google/gemini-2.5-flash-lite",name:"Google: Gemini 2.5 Flash Lite",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65535,cost:{input:0.1,output:0.4,cacheRead:0.01,cacheWrite:0.083333}}},{modelId:"google/gemini-2.5-flash-lite-preview-09-2025",name:"Google: Gemini 2.5 Flash Lite Preview 09-2025",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65535,cost:{input:0.1,output:0.4,cacheRead:0.01,cacheWrite:0.083333}}},{modelId:"google/gemini-2.5-pro",name:"Google: Gemini 2.5 Pro",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0.375}}},{modelId:"google/gemini-2.5-pro-preview",name:"Google: Gemini 2.5 Pro Preview 06-05",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0.375}}},{modelId:"google/gemini-2.5-pro-preview-05-06",name:"Google: Gemini 2.5 Pro Preview 05-06",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65535,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0.375}}},{modelId:"google/gemini-3-flash-preview",name:"Google: Gemini 3 Flash Preview",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.5,output:3,cacheRead:0.05,cacheWrite:0.083333}}},{modelId:"google/gemini-3.1-flash-lite",name:"Google: Gemini 3.1 Flash Lite",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.25,output:1.5,cacheRead:0.025,cacheWrite:0.083333}}},{modelId:"google/gemini-3.1-flash-lite-preview",name:"Google: Gemini 3.1 Flash Lite Preview",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.25,output:1.5,cacheRead:0.025,cacheWrite:0.083333}}},{modelId:"google/gemini-3.1-pro-preview",name:"Google: Gemini 3.1 Pro Preview",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0.375}}},{modelId:"google/gemini-3.1-pro-preview-customtools",name:"Google: Gemini 3.1 Pro Preview Custom Tools",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048756,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0.375}}},{modelId:"google/gemini-3.5-flash",name:"Google: Gemini 3.5 Flash",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.5,output:9,cacheRead:0.15,cacheWrite:0.083333}}},{modelId:"google/gemma-3-12b-it",name:"Google: Gemma 3 12B",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:131072,maxTokens:16384,cost:{input:0.05,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"google/gemma-3-27b-it",name:"Google: Gemma 3 27B",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:131072,maxTokens:16384,cost:{input:0.08,output:0.16,cacheRead:0,cacheWrite:0}}},{modelId:"google/gemma-4-26b-a4b-it",name:"Google: Gemma 4 26B A4B ",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:4096,cost:{input:0.06,output:0.33,cacheRead:0,cacheWrite:0}}},{modelId:"google/gemma-4-26b-a4b-it:free",name:"Google: Gemma 4 26B A4B (free)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"google/gemma-4-31b-it",name:"Google: Gemma 4 31B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.12,output:0.35,cacheRead:0.09,cacheWrite:0}}},{modelId:"google/gemma-4-31b-it:free",name:"Google: Gemma 4 31B (free)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"ibm-granite/granite-4.1-8b",name:"IBM: Granite 4.1 8B",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.05,output:0.1,cacheRead:0.05,cacheWrite:0}}},{modelId:"inception/mercury-2",name:"Inception: Mercury 2",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:50000,cost:{input:0.25,output:0.75,cacheRead:0.025,cacheWrite:0}}},{modelId:"inclusionai/ling-2.6-1t",name:"inclusionAI: Ling-2.6-1T",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:0.075,output:0.625,cacheRead:0.015,cacheWrite:0}}},{modelId:"inclusionai/ling-2.6-flash",name:"inclusionAI: Ling-2.6-flash",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:0.01,output:0.03,cacheRead:0.002,cacheWrite:0}}},{modelId:"inclusionai/ring-2.6-1t",name:"inclusionAI: Ring-2.6-1T",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:0.075,output:0.625,cacheRead:0.015,cacheWrite:0}}},{modelId:"kwaipilot/kat-coder-pro-v2",name:"Kwaipilot: KAT-Coder-Pro V2",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:80000,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"meta-llama/llama-3.1-70b-instruct",name:"Meta: Llama 3.1 70B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.4,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"meta-llama/llama-3.1-8b-instruct",name:"Meta: Llama 3.1 8B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.02,output:0.03,cacheRead:0,cacheWrite:0}}},{modelId:"meta-llama/llama-3.3-70b-instruct",name:"Meta: Llama 3.3 70B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.1,output:0.32,cacheRead:0,cacheWrite:0}}},{modelId:"meta-llama/llama-3.3-70b-instruct:free",name:"Meta: Llama 3.3 70B Instruct (free)",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"meta-llama/llama-4-maverick",name:"Meta: Llama 4 Maverick",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:1048576,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"meta-llama/llama-4-scout",name:"Meta: Llama 4 Scout",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:1e7,maxTokens:16384,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"minimax/minimax-m1",name:"MiniMax: MiniMax M1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:40000,cost:{input:0.4,output:2.2,cacheRead:0,cacheWrite:0}}},{modelId:"minimax/minimax-m2",name:"MiniMax: MiniMax M2",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:196608,cost:{input:0.255,output:1,cacheRead:0.03,cacheWrite:0}}},{modelId:"minimax/minimax-m2.1",name:"MiniMax: MiniMax M2.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:196608,cost:{input:0.29,output:0.95,cacheRead:0.03,cacheWrite:0}}},{modelId:"minimax/minimax-m2.5",name:"MiniMax: MiniMax M2.5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:196608,cost:{input:0.15,output:0.9,cacheRead:0.05,cacheWrite:0}}},{modelId:"minimax/minimax-m2.7",name:"MiniMax: MiniMax M2.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.25,output:1,cacheRead:0.05,cacheWrite:0}}},{modelId:"minimax/minimax-m3",name:"MiniMax: MiniMax M3",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:512000,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"mistralai/codestral-2508",name:"Mistral: Codestral 2508",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:4096,cost:{input:0.3,output:0.9,cacheRead:0.03,cacheWrite:0}}},{modelId:"mistralai/devstral-2512",name:"Mistral: Devstral 2 2512",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:4096,cost:{input:0.4,output:2,cacheRead:0.04,cacheWrite:0}}},{modelId:"mistralai/ministral-14b-2512",name:"Mistral: Ministral 3 14B 2512",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:4096,cost:{input:0.2,output:0.2,cacheRead:0.02,cacheWrite:0}}},{modelId:"mistralai/ministral-3b-2512",name:"Mistral: Ministral 3 3B 2512",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:131072,maxTokens:4096,cost:{input:0.1,output:0.1,cacheRead:0.01,cacheWrite:0}}},{modelId:"mistralai/ministral-8b-2512",name:"Mistral: Ministral 3 8B 2512",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:4096,cost:{input:0.15,output:0.15,cacheRead:0.015,cacheWrite:0}}},{modelId:"mistralai/mistral-large",name:"Mistral Large",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:2,output:6,cacheRead:0.2,cacheWrite:0}}},{modelId:"mistralai/mistral-large-2407",name:"Mistral Large 2407",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:4096,cost:{input:2,output:6,cacheRead:0.2,cacheWrite:0}}},{modelId:"mistralai/mistral-large-2512",name:"Mistral: Mistral Large 3 2512",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:4096,cost:{input:0.5,output:1.5,cacheRead:0.05,cacheWrite:0}}},{modelId:"mistralai/mistral-medium-3",name:"Mistral: Mistral Medium 3",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:131072,maxTokens:4096,cost:{input:0.4,output:2,cacheRead:0.04,cacheWrite:0}}},{modelId:"mistralai/mistral-medium-3-5",name:"Mistral: Mistral Medium 3.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:4096,cost:{input:1.5,output:7.5,cacheRead:0,cacheWrite:0}}},{modelId:"mistralai/mistral-medium-3.1",name:"Mistral: Mistral Medium 3.1",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:131072,maxTokens:4096,cost:{input:0.4,output:2,cacheRead:0.04,cacheWrite:0}}},{modelId:"mistralai/mistral-nemo",name:"Mistral: Mistral Nemo",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:4096,cost:{input:0.02,output:0.03,cacheRead:0,cacheWrite:0}}},{modelId:"mistralai/mistral-saba",name:"Mistral: Saba",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:32768,maxTokens:4096,cost:{input:0.2,output:0.6,cacheRead:0.02,cacheWrite:0}}},{modelId:"mistralai/mistral-small-2603",name:"Mistral: Mistral Small 4",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:4096,cost:{input:0.15,output:0.6,cacheRead:0.015,cacheWrite:0}}},{modelId:"mistralai/mistral-small-3.2-24b-instruct",name:"Mistral: Mistral Small 3.2 24B",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:0.075,output:0.2,cacheRead:0,cacheWrite:0}}},{modelId:"mistralai/mixtral-8x22b-instruct",name:"Mistral: Mixtral 8x22B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:65536,maxTokens:4096,cost:{input:2,output:6,cacheRead:0.2,cacheWrite:0}}},{modelId:"mistralai/voxtral-small-24b-2507",name:"Mistral: Voxtral Small 24B 2507",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:32000,maxTokens:4096,cost:{input:0.1,output:0.3,cacheRead:0.01,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2",name:"MoonshotAI: Kimi K2 0711",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:32768,cost:{input:0.57,output:2.3,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2-0905",name:"MoonshotAI: Kimi K2 0905",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:2.5,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2-thinking",name:"MoonshotAI: Kimi K2 Thinking",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:2.5,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2.5",name:"MoonshotAI: Kimi K2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:4096,cost:{input:0.41,output:2.06,cacheRead:0.07,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2.6",name:"MoonshotAI: Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262142,cost:{input:0.68,output:3.41,cacheRead:0.34,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2.7-code",name:"MoonshotAI: Kimi K2.7 Code",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.75,output:3.5,cacheRead:0.16,cacheWrite:0}}},{modelId:"nex-agi/nex-n2-pro:free",name:"Nex AGI: Nex-N2-Pro (free)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/llama-3.3-nemotron-super-49b-v1.5",name:"NVIDIA: Llama 3.3 Nemotron Super 49B V1.5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.4,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-nano-30b-a3b",name:"NVIDIA: Nemotron 3 Nano 30B A3B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:228000,cost:{input:0.05,output:0.2,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-nano-30b-a3b:free",name:"NVIDIA: Nemotron 3 Nano 30B A3B (free)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning:free",name:"NVIDIA: Nemotron 3 Nano Omni (free)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:65536,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-super-120b-a12b",name:"NVIDIA: Nemotron 3 Super",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:4096,cost:{input:0.09,output:0.45,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-super-120b-a12b:free",name:"NVIDIA: Nemotron 3 Super (free)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:262144,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-ultra-550b-a55b",name:"NVIDIA: Nemotron 3 Ultra",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:16384,cost:{input:0.5,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-ultra-550b-a55b:free",name:"NVIDIA: Nemotron 3 Ultra (free)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:65536,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-nano-12b-v2-vl:free",name:"NVIDIA: Nemotron Nano 12B 2 VL (free)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:128000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-nano-9b-v2:free",name:"NVIDIA: Nemotron Nano 9B V2 (free)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-3.5-turbo",name:"OpenAI: GPT-3.5 Turbo",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:16385,maxTokens:4096,cost:{input:0.5,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-3.5-turbo-0613",name:"OpenAI: GPT-3.5 Turbo (older v0613)",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:4095,maxTokens:4096,cost:{input:1,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-3.5-turbo-16k",name:"OpenAI: GPT-3.5 Turbo 16k",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:16385,maxTokens:4096,cost:{input:3,output:4,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-4",name:"OpenAI: GPT-4",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:8191,maxTokens:4096,cost:{input:30,output:60,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-4-turbo",name:"OpenAI: GPT-4 Turbo",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:10,output:30,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-4-turbo-preview",name:"OpenAI: GPT-4 Turbo Preview",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:10,output:30,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-4.1",name:"OpenAI: GPT-4.1",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:4096,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"openai/gpt-4.1-mini",name:"OpenAI: GPT-4.1 Mini",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:0.4,output:1.6,cacheRead:0.1,cacheWrite:0}}},{modelId:"openai/gpt-4.1-nano",name:"OpenAI: GPT-4.1 Nano",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:0.1,output:0.4,cacheRead:0.025,cacheWrite:0}}},{modelId:"openai/gpt-4o",name:"OpenAI: GPT-4o",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-4o-2024-05-13",name:"OpenAI: GPT-4o (2024-05-13)",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:5,output:15,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-4o-2024-08-06",name:"OpenAI: GPT-4o (2024-08-06)",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"openai/gpt-4o-2024-11-20",name:"OpenAI: GPT-4o (2024-11-20)",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"openai/gpt-4o-mini",name:"OpenAI: GPT-4o-mini",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0.075,cacheWrite:0}}},{modelId:"openai/gpt-4o-mini-2024-07-18",name:"OpenAI: GPT-4o-mini (2024-07-18)",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0.075,cacheWrite:0}}},{modelId:"openai/gpt-5",name:"OpenAI: GPT-5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5-codex",name:"OpenAI: GPT-5 Codex",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5-mini",name:"OpenAI: GPT-5 Mini",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"openai/gpt-5-nano",name:"OpenAI: GPT-5 Nano",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:4096,cost:{input:0.05,output:0.4,cacheRead:0.01,cacheWrite:0}}},{modelId:"openai/gpt-5-pro",name:"OpenAI: GPT-5 Pro",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:15,output:120,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-5.1",name:"OpenAI: GPT-5.1",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.13,cacheWrite:0}}},{modelId:"openai/gpt-5.1-chat",name:"OpenAI: GPT-5.1 Chat",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:32000,cost:{input:1.25,output:10,cacheRead:0.13,cacheWrite:0}}},{modelId:"openai/gpt-5.1-codex",name:"OpenAI: GPT-5.1-Codex",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.13,cacheWrite:0}}},{modelId:"openai/gpt-5.1-codex-max",name:"OpenAI: GPT-5.1-Codex-Max",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5.1-codex-mini",name:"OpenAI: GPT-5.1-Codex-Mini",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:1e5,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"openai/gpt-5.2",name:"OpenAI: GPT-5.2",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.2-chat",name:"OpenAI: GPT-5.2 Chat",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.2-codex",name:"OpenAI: GPT-5.2-Codex",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.2-pro",name:"OpenAI: GPT-5.2 Pro",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:21,output:168,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-5.3-chat",name:"OpenAI: GPT-5.3 Chat",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.3-codex",name:"OpenAI: GPT-5.3-Codex",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.4",name:"OpenAI: GPT-5.4",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:2.5,output:15,cacheRead:0.25,cacheWrite:0}}},{modelId:"openai/gpt-5.4-mini",name:"OpenAI: GPT-5.4 Mini",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.75,output:4.5,cacheRead:0.075,cacheWrite:0}}},{modelId:"openai/gpt-5.4-nano",name:"OpenAI: GPT-5.4 Nano",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.2,output:1.25,cacheRead:0.02,cacheWrite:0}}},{modelId:"openai/gpt-5.4-pro",name:"OpenAI: GPT-5.4 Pro",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-5.5",name:"OpenAI: GPT-5.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"openai/gpt-5.5-pro",name:"OpenAI: GPT-5.5 Pro",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-audio",name:"OpenAI: GPT Audio",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-audio-mini",name:"OpenAI: GPT Audio Mini",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.6,output:2.4,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-chat-latest",name:"OpenAI: GPT Chat Latest",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"openai/gpt-oss-120b",name:"OpenAI: gpt-oss-120b",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:4096,cost:{input:0.039,output:0.18,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-120b:free",name:"OpenAI: gpt-oss-120b (free)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-20b",name:"OpenAI: gpt-oss-20b",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:4096,cost:{input:0.029,output:0.14,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-20b:free",name:"OpenAI: gpt-oss-20b (free)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:8192,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-safeguard-20b",name:"OpenAI: gpt-oss-safeguard-20b",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:65536,cost:{input:0.075,output:0.3,cacheRead:0.037,cacheWrite:0}}},{modelId:"openai/o1",name:"OpenAI: o1",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0}}},{modelId:"openai/o3",name:"OpenAI: o3",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"openai/o3-deep-research",name:"OpenAI: o3 Deep Research",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0}}},{modelId:"openai/o3-mini",name:"OpenAI: o3 Mini",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.55,cacheWrite:0}}},{modelId:"openai/o3-mini-high",name:"OpenAI: o3 Mini High",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.55,cacheWrite:0}}},{modelId:"openai/o3-pro",name:"OpenAI: o3 Pro",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:20,output:80,cacheRead:0,cacheWrite:0}}},{modelId:"openai/o4-mini",name:"OpenAI: o4 Mini",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.275,cacheWrite:0}}},{modelId:"openai/o4-mini-deep-research",name:"OpenAI: o4 Mini Deep Research",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"openai/o4-mini-high",name:"OpenAI: o4 Mini High",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.275,cacheWrite:0}}},{modelId:"openrouter/auto",name:"Auto Router",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:2000000,maxTokens:4096,cost:{input:-1e6,output:-1e6,cacheRead:0,cacheWrite:0}}},{modelId:"openrouter/free",name:"Free Models Router",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"openrouter/owl-alpha",name:"Owl Alpha",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:1048756,maxTokens:262144,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"poolside/laguna-m.1:free",name:"Poolside: Laguna M.1 (free)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"poolside/laguna-xs.2:free",name:"Poolside: Laguna XS.2 (free)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"prime-intellect/intellect-3",name:"Prime Intellect: INTELLECT-3",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.2,output:1.1,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen-2.5-72b-instruct",name:"Qwen2.5 72B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.36,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen-plus",name:"Qwen: Qwen-Plus",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:1e6,maxTokens:32768,cost:{input:0.26,output:0.78,cacheRead:0.052,cacheWrite:0.325}}},{modelId:"qwen/qwen-plus-2025-07-28",name:"Qwen: Qwen Plus 0728",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:1e6,maxTokens:32768,cost:{input:0.26,output:0.78,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen-plus-2025-07-28:thinking",name:"Qwen: Qwen Plus 0728 (thinking)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:32768,cost:{input:0.26,output:0.78,cacheRead:0,cacheWrite:0.325}}},{modelId:"qwen/qwen3-14b",name:"Qwen: Qwen3 14B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131702,maxTokens:40960,cost:{input:0.1,output:0.24,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-235b-a22b",name:"Qwen: Qwen3 235B A22B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:8192,cost:{input:0.455,output:1.82,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-235b-a22b-2507",name:"Qwen: Qwen3 235B A22B Instruct 2507",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:16384,cost:{input:0.09,output:0.1,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-235b-a22b-thinking-2507",name:"Qwen: Qwen3 235B A22B Thinking 2507",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.1,output:0.1,cacheRead:0.1,cacheWrite:0}}},{modelId:"qwen/qwen3-30b-a3b",name:"Qwen: Qwen3 30B A3B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.12,output:0.5,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-30b-a3b-instruct-2507",name:"Qwen: Qwen3 30B A3B Instruct 2507",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:32000,cost:{input:0.04815,output:0.19305,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-30b-a3b-thinking-2507",name:"Qwen: Qwen3 30B A3B Thinking 2507",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.08,output:0.4,cacheRead:0.08,cacheWrite:0}}},{modelId:"qwen/qwen3-32b",name:"Qwen: Qwen3 32B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.08,output:0.28,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-8b",name:"Qwen: Qwen3 8B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:8192,cost:{input:0.05,output:0.4,cacheRead:0.05,cacheWrite:0}}},{modelId:"qwen/qwen3-coder",name:"Qwen: Qwen3 Coder 480B A35B",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:1048576,maxTokens:65536,cost:{input:0.22,output:1.8,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-coder-30b-a3b-instruct",name:"Qwen: Qwen3 Coder 30B A3B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:160000,maxTokens:32768,cost:{input:0.07,output:0.27,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-coder-flash",name:"Qwen: Qwen3 Coder Flash",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:1e6,maxTokens:65536,cost:{input:0.195,output:0.975,cacheRead:0.039,cacheWrite:0.24375}}},{modelId:"qwen/qwen3-coder-next",name:"Qwen: Qwen3 Coder Next",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.11,output:0.8,cacheRead:0.07,cacheWrite:0}}},{modelId:"qwen/qwen3-coder-plus",name:"Qwen: Qwen3 Coder Plus",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:1e6,maxTokens:65536,cost:{input:0.65,output:3.25,cacheRead:0.13,cacheWrite:0.8125}}},{modelId:"qwen/qwen3-coder:free",name:"Qwen: Qwen3 Coder 480B A35B (free)",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:1048576,maxTokens:262000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-max",name:"Qwen: Qwen3 Max",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:0.78,output:3.9,cacheRead:0.156,cacheWrite:0.975}}},{modelId:"qwen/qwen3-max-thinking",name:"Qwen: Qwen3 Max Thinking",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:0.78,output:3.9,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-next-80b-a3b-instruct",name:"Qwen: Qwen3 Next 80B A3B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:16384,cost:{input:0.09,output:1.1,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-next-80b-a3b-instruct:free",name:"Qwen: Qwen3 Next 80B A3B Instruct (free)",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-next-80b-a3b-thinking",name:"Qwen: Qwen3 Next 80B A3B Thinking",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:0.0975,output:0.78,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-vl-235b-a22b-instruct",name:"Qwen: Qwen3 VL 235B A22B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:16384,cost:{input:0.2,output:0.88,cacheRead:0.11,cacheWrite:0}}},{modelId:"qwen/qwen3-vl-235b-a22b-thinking",name:"Qwen: Qwen3 VL 235B A22B Thinking",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:131072,maxTokens:32768,cost:{input:0.26,output:2.6,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-vl-30b-a3b-instruct",name:"Qwen: Qwen3 VL 30B A3B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0.13,output:0.52,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-vl-30b-a3b-thinking",name:"Qwen: Qwen3 VL 30B A3B Thinking",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:131072,maxTokens:32768,cost:{input:0.13,output:1.56,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-vl-32b-instruct",name:"Qwen: Qwen3 VL 32B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0.104,output:0.416,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-vl-8b-instruct",name:"Qwen: Qwen3 VL 8B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:256000,maxTokens:32768,cost:{input:0.08,output:0.5,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-vl-8b-thinking",name:"Qwen: Qwen3 VL 8B Thinking",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:32768,cost:{input:0.117,output:1.365,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.5-122b-a10b",name:"Qwen: Qwen3.5-122B-A10B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.26,output:2.08,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.5-27b",name:"Qwen: Qwen3.5-27B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.195,output:1.56,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.5-35b-a3b",name:"Qwen: Qwen3.5-35B-A3B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.14,output:1,cacheRead:0.05,cacheWrite:0}}},{modelId:"qwen/qwen3.5-397b-a17b",name:"Qwen: Qwen3.5 397B A17B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.39,output:2.34,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.5-9b",name:"Qwen: Qwen3.5-9B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.1,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.5-flash-02-23",name:"Qwen: Qwen3.5-Flash",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.065,output:0.26,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.5-plus-02-15",name:"Qwen: Qwen3.5 Plus 2026-02-15",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.26,output:1.56,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.5-plus-20260420",name:"Qwen: Qwen3.5 Plus 2026-04-20",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.3,output:1.8,cacheRead:0,cacheWrite:0.375}}},{modelId:"qwen/qwen3.6-27b",name:"Qwen: Qwen3.6 27B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262140,cost:{input:0.2885,output:3.17,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.6-35b-a3b",name:"Qwen: Qwen3.6 35B A3B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.15,output:1,cacheRead:0.05,cacheWrite:0}}},{modelId:"qwen/qwen3.6-flash",name:"Qwen: Qwen3.6 Flash",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.1875,output:1.125,cacheRead:0,cacheWrite:0.234375}}},{modelId:"qwen/qwen3.6-max-preview",name:"Qwen: Qwen3.6 Max Preview",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:1.04,output:6.24,cacheRead:0,cacheWrite:1.3}}},{modelId:"qwen/qwen3.6-plus",name:"Qwen: Qwen3.6 Plus",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.325,output:1.95,cacheRead:0,cacheWrite:0.40625}}},{modelId:"qwen/qwen3.7-max",name:"Qwen: Qwen3.7 Max",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:65536,cost:{input:1.25,output:3.75,cacheRead:0.25,cacheWrite:1.5625}}},{modelId:"qwen/qwen3.7-plus",name:"Qwen: Qwen3.7 Plus",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.32,output:1.28,cacheRead:0.064,cacheWrite:0.4}}},{modelId:"rekaai/reka-edge",name:"Reka Edge",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:16384,maxTokens:16384,cost:{input:0.1,output:0.1,cacheRead:0,cacheWrite:0}}},{modelId:"relace/relace-search",name:"Relace: Relace Search",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:128000,cost:{input:1,output:3,cacheRead:0,cacheWrite:0}}},{modelId:"sao10k/l3.1-euryale-70b",name:"Sao10K: Llama 3.1 Euryale 70B v2.2",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.85,output:0.85,cacheRead:0,cacheWrite:0}}},{modelId:"stepfun/step-3.5-flash",name:"StepFun: Step 3.5 Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:16384,cost:{input:0.09,output:0.3,cacheRead:0.02,cacheWrite:0}}},{modelId:"stepfun/step-3.7-flash",name:"StepFun: Step 3.7 Flash",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:0.2,output:1.15,cacheRead:0.04,cacheWrite:0}}},{modelId:"tencent/hy3-preview",name:"Tencent: Hy3 preview",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:4096,cost:{input:0.063,output:0.21,cacheRead:0.021,cacheWrite:0}}},{modelId:"thedrummer/rocinante-12b",name:"TheDrummer: Rocinante 12B",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:32768,maxTokens:32768,cost:{input:0.17,output:0.43,cacheRead:0,cacheWrite:0}}},{modelId:"thedrummer/unslopnemo-12b",name:"TheDrummer: UnslopNemo 12B",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:32768,maxTokens:32768,cost:{input:0.4,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"upstage/solar-pro-3",name:"Upstage: Solar Pro 3",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.15,output:0.6,cacheRead:0.015,cacheWrite:0}}},{modelId:"x-ai/grok-4.20",name:"xAI: Grok 4.20",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:2000000,maxTokens:4096,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"x-ai/grok-4.3",name:"xAI: Grok 4.3",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:4096,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"x-ai/grok-build-0.1",name:"xAI: Grok Build 0.1",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:4096,cost:{input:1,output:2,cacheRead:0.2,cacheWrite:0}}},{modelId:"xiaomi/mimo-v2-flash",name:"Xiaomi: MiMo-V2-Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:0.1,output:0.3,cacheRead:0.01,cacheWrite:0}}},{modelId:"xiaomi/mimo-v2.5",name:"Xiaomi: MiMo-V2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:131072,cost:{input:0.14,output:0.28,cacheRead:0.0028,cacheWrite:0}}},{modelId:"xiaomi/mimo-v2.5-pro",name:"Xiaomi: MiMo-V2.5-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:0.435,output:0.87,cacheRead:0.0036,cacheWrite:0}}},{modelId:"z-ai/glm-4.5",name:"Z.ai: GLM 4.5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:98304,cost:{input:0.6,output:2.2,cacheRead:0.11,cacheWrite:0}}},{modelId:"z-ai/glm-4.5-air",name:"Z.ai: GLM 4.5 Air",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131070,cost:{input:0.125,output:0.85,cacheRead:0.06,cacheWrite:0}}},{modelId:"z-ai/glm-4.5v",name:"Z.ai: GLM 4.5V",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:65536,maxTokens:16384,cost:{input:0.6,output:1.8,cacheRead:0.11,cacheWrite:0}}},{modelId:"z-ai/glm-4.6",name:"Z.ai: GLM 4.6",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:131072,cost:{input:0.43,output:1.74,cacheRead:0.08,cacheWrite:0}}},{modelId:"z-ai/glm-4.6v",name:"Z.ai: GLM 4.6V",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:131072,maxTokens:32768,cost:{input:0.3,output:0.9,cacheRead:0.055,cacheWrite:0}}},{modelId:"z-ai/glm-4.7",name:"Z.ai: GLM 4.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:131072,cost:{input:0.4,output:1.75,cacheRead:0.08,cacheWrite:0}}},{modelId:"z-ai/glm-4.7-flash",name:"Z.ai: GLM 4.7 Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:16384,cost:{input:0.06,output:0.4,cacheRead:0.01,cacheWrite:0}}},{modelId:"z-ai/glm-5",name:"Z.ai: GLM 5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:4096,cost:{input:0.6,output:1.9,cacheRead:0.119,cacheWrite:0}}},{modelId:"z-ai/glm-5-turbo",name:"Z.ai: GLM 5 Turbo",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:131072,cost:{input:1.2,output:4,cacheRead:0.24,cacheWrite:0}}},{modelId:"z-ai/glm-5.1",name:"Z.ai: GLM 5.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:4096,cost:{input:0.98,output:3.08,cacheRead:0.182,cacheWrite:0}}},{modelId:"~anthropic/claude-fable-latest",name:"Anthropic: Claude Fable Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5}}},{modelId:"~anthropic/claude-haiku-latest",name:"Anthropic Claude Haiku Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"~anthropic/claude-opus-latest",name:"Anthropic: Claude Opus Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"~anthropic/claude-sonnet-latest",name:"Anthropic Claude Sonnet Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"~google/gemini-flash-latest",name:"Google Gemini Flash Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.5,output:9,cacheRead:0.15,cacheWrite:0.083333}}},{modelId:"~google/gemini-pro-latest",name:"Google Gemini Pro Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0.375}}},{modelId:"~moonshotai/kimi-latest",name:"MoonshotAI Kimi Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262142,cost:{input:0.68,output:3.41,cacheRead:0.34,cacheWrite:0}}},{modelId:"~openai/gpt-latest",name:"OpenAI GPT Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"~openai/gpt-mini-latest",name:"OpenAI GPT Mini Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.75,output:4.5,cacheRead:0.075,cacheWrite:0}}}]},mistral:{name:"mistral",config:{api:"mistral-conversations",baseUrl:"https://api.mistral.ai",apiKey:"MISTRAL_API_KEY"},models:[{modelId:"codestral-latest",name:"Codestral (latest)",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:4096,cost:{input:0.3,output:0.9,cacheRead:0,cacheWrite:0}}},{modelId:"devstral-2512",name:"Devstral 2",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"devstral-latest",name:"Devstral 2",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"devstral-medium-2507",name:"Devstral Medium",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"devstral-medium-latest",name:"Devstral 2 (latest)",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"devstral-small-2505",name:"Devstral Small 2505",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"devstral-small-2507",name:"Devstral Small",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"labs-devstral-small-2512",name:"Devstral Small 2",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"magistral-medium-latest",name:"Magistral Medium (latest)",config:{api:"mistral-conversations",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:2,output:5,cacheRead:0,cacheWrite:0}}},{modelId:"magistral-small",name:"Magistral Small",config:{api:"mistral-conversations",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.5,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"ministral-3b-latest",name:"Ministral 3B (latest)",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.04,output:0.04,cacheRead:0,cacheWrite:0}}},{modelId:"ministral-8b-latest",name:"Ministral 8B (latest)",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.1,output:0.1,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-large-2411",name:"Mistral Large 2.1",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:2,output:6,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-large-2512",name:"Mistral Large 3",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.5,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-large-latest",name:"Mistral Large (latest)",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.5,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-medium-2505",name:"Mistral Medium 3",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:131072,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-medium-2508",name:"Mistral Medium 3.1",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-medium-2604",name:"Mistral Medium 3.5",config:{api:"mistral-conversations",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:1.5,output:7.5,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-medium-3.5",name:"Mistral Medium 3.5",config:{api:"mistral-conversations",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:1.5,output:7.5,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-medium-latest",name:"Mistral Medium (latest)",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-nemo",name:"Mistral Nemo",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.15,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-small-2506",name:"Mistral Small 3.2",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-small-2603",name:"Mistral Small 4",config:{api:"mistral-conversations",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-small-latest",name:"Mistral Small (latest)",config:{api:"mistral-conversations",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"open-mistral-7b",name:"Mistral 7B",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:8000,maxTokens:8000,cost:{input:0.25,output:0.25,cacheRead:0,cacheWrite:0}}},{modelId:"open-mistral-nemo",name:"Open Mistral Nemo",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.15,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"open-mixtral-8x22b",name:"Mixtral 8x22B",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:64000,maxTokens:64000,cost:{input:2,output:6,cacheRead:0,cacheWrite:0}}},{modelId:"open-mixtral-8x7b",name:"Mixtral 8x7B",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:32000,maxTokens:32000,cost:{input:0.7,output:0.7,cacheRead:0,cacheWrite:0}}},{modelId:"pixtral-12b",name:"Pixtral 12B",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:128000,cost:{input:0.15,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"pixtral-large-latest",name:"Pixtral Large (latest)",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:128000,cost:{input:2,output:6,cacheRead:0,cacheWrite:0}}}]},"amazon-bedrock":{name:"amazon-bedrock",config:{api:"bedrock-converse-stream",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",apiKey:""},models:[{modelId:"amazon.nova-2-lite-v1:0",name:"Nova 2 Lite",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:0.33,output:2.75,cacheRead:0,cacheWrite:0}}},{modelId:"amazon.nova-lite-v1:0",name:"Nova Lite",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:300000,maxTokens:8192,cost:{input:0.06,output:0.24,cacheRead:0.015,cacheWrite:0}}},{modelId:"amazon.nova-micro-v1:0",name:"Nova Micro",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:8192,cost:{input:0.035,output:0.14,cacheRead:0.00875,cacheWrite:0}}},{modelId:"amazon.nova-pro-v1:0",name:"Nova Pro",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:300000,maxTokens:8192,cost:{input:0.8,output:3.2,cacheRead:0.2,cacheWrite:0}}},{modelId:"anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"anthropic.claude-opus-4-1-20250805-v1:0",name:"Claude Opus 4.1",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic.claude-opus-4-7",name:"Claude Opus 4.7",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic.claude-opus-4-8",name:"Claude Opus 4.8",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"au.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (AU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"au.anthropic.claude-opus-4-6-v1",name:"AU Anthropic Claude Opus 4.6",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:16.5,output:82.5,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"au.anthropic.claude-opus-4-8",name:"Claude Opus 4.8 (AU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"au.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (AU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"au.anthropic.claude-sonnet-4-6",name:"AU Anthropic Claude Sonnet 4.6",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:3.3,output:16.5,cacheRead:0.33,cacheWrite:4.125}}},{modelId:"deepseek.r1-v1:0",name:"DeepSeek-R1",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:32768,cost:{input:1.35,output:5.4,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek.v3-v1:0",name:"DeepSeek-V3.1",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:81920,cost:{input:0.58,output:1.68,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek.v3.2",name:"DeepSeek-V3.2",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:81920,cost:{input:0.62,output:1.85,cacheRead:0,cacheWrite:0}}},{modelId:"eu.anthropic.claude-fable-5",name:"Claude Fable 5 (EU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:11,output:55,cacheRead:1.1,cacheWrite:13.75}}},{modelId:"eu.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (EU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"eu.anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5 (EU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"eu.anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6 (EU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5.5,output:27.5,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"eu.anthropic.claude-opus-4-7",name:"Claude Opus 4.7 (EU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5.5,output:27.5,cacheRead:0.55,cacheWrite:6.875}}},{modelId:"eu.anthropic.claude-opus-4-8",name:"Claude Opus 4.8 (EU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5.5,output:27.5,cacheRead:0.55,cacheWrite:6.875}}},{modelId:"eu.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (EU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3.3,output:16.5,cacheRead:0.33,cacheWrite:4.125}}},{modelId:"eu.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (EU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3.3,output:16.5,cacheRead:0.33,cacheWrite:4.125}}},{modelId:"global.anthropic.claude-fable-5",name:"Claude Fable 5 (Global)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5}}},{modelId:"global.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (Global)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"global.anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5 (Global)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"global.anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6 (Global)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"global.anthropic.claude-opus-4-7",name:"Claude Opus 4.7 (Global)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"global.anthropic.claude-opus-4-8",name:"Claude Opus 4.8 (Global)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"global.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (Global)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"global.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (Global)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"google.gemma-3-27b-it",name:"Google Gemma 3 27B Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:202752,maxTokens:8192,cost:{input:0.12,output:0.2,cacheRead:0,cacheWrite:0}}},{modelId:"google.gemma-3-4b-it",name:"Gemma 3 4B IT",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:0.04,output:0.08,cacheRead:0,cacheWrite:0}}},{modelId:"jp.anthropic.claude-opus-4-7",name:"Claude Opus 4.7 (JP)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"jp.anthropic.claude-opus-4-8",name:"Claude Opus 4.8 (JP)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"jp.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (JP)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"jp.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (JP)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"meta.llama3-1-70b-instruct-v1:0",name:"Llama 3.1 70B Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.72,output:0.72,cacheRead:0,cacheWrite:0}}},{modelId:"meta.llama3-1-8b-instruct-v1:0",name:"Llama 3.1 8B Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.22,output:0.22,cacheRead:0,cacheWrite:0}}},{modelId:"meta.llama3-3-70b-instruct-v1:0",name:"Llama 3.3 70B Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.72,output:0.72,cacheRead:0,cacheWrite:0}}},{modelId:"meta.llama4-maverick-17b-instruct-v1:0",name:"Llama 4 Maverick 17B Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:1e6,maxTokens:16384,cost:{input:0.24,output:0.97,cacheRead:0,cacheWrite:0}}},{modelId:"meta.llama4-scout-17b-instruct-v1:0",name:"Llama 4 Scout 17B Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:3500000,maxTokens:16384,cost:{input:0.17,output:0.66,cacheRead:0,cacheWrite:0}}},{modelId:"minimax.minimax-m2",name:"MiniMax M2",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:204608,maxTokens:128000,cost:{input:0.3,output:1.2,cacheRead:0,cacheWrite:0}}},{modelId:"minimax.minimax-m2.1",name:"MiniMax M2.1",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0,cacheWrite:0}}},{modelId:"minimax.minimax-m2.5",name:"MiniMax M2.5",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:196608,maxTokens:98304,cost:{input:0.3,output:1.2,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.devstral-2-123b",name:"Devstral 2 123B",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:8192,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.magistral-small-2509",name:"Magistral Small 1.2",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:40000,cost:{input:0.5,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.ministral-3-14b-instruct",name:"Ministral 14B 3.0",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.2,output:0.2,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.ministral-3-3b-instruct",name:"Ministral 3 3B",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:256000,maxTokens:8192,cost:{input:0.1,output:0.1,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.ministral-3-8b-instruct",name:"Ministral 3 8B",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.15,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.mistral-large-3-675b-instruct",name:"Mistral Large 3",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:256000,maxTokens:8192,cost:{input:0.5,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.pixtral-large-2502-v1:0",name:"Pixtral Large (25.02)",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:8192,cost:{input:2,output:6,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.voxtral-mini-3b-2507",name:"Voxtral Mini 3B 2507",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.04,output:0.04,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.voxtral-small-24b-2507",name:"Voxtral Small 24B 2507",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:32000,maxTokens:8192,cost:{input:0.15,output:0.35,cacheRead:0,cacheWrite:0}}},{modelId:"moonshot.kimi-k2-thinking",name:"Kimi K2 Thinking",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:262143,maxTokens:16000,cost:{input:0.6,output:2.5,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai.kimi-k2.5",name:"Kimi K2.5",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:262143,maxTokens:16000,cost:{input:0.6,output:3,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia.nemotron-nano-12b-v2",name:"NVIDIA Nemotron Nano 12B v2 VL BF16",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:0.2,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia.nemotron-nano-3-30b",name:"NVIDIA Nemotron Nano 3 30B",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.06,output:0.24,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia.nemotron-nano-9b-v2",name:"NVIDIA Nemotron Nano 9B v2",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.06,output:0.23,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia.nemotron-super-3-120b",name:"NVIDIA Nemotron 3 Super 120B A12B",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:131072,cost:{input:0.15,output:0.65,cacheRead:0,cacheWrite:0}}},{modelId:"openai.gpt-5.4",name:"GPT-5.4",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:272000,maxTokens:128000,cost:{input:2.75,output:16.5,cacheRead:0.275,cacheWrite:0}}},{modelId:"openai.gpt-5.5",name:"GPT-5.5",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:272000,maxTokens:128000,cost:{input:5.5,output:33,cacheRead:0.55,cacheWrite:0}}},{modelId:"openai.gpt-oss-120b",name:"gpt-oss-120b",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"openai.gpt-oss-120b-1:0",name:"gpt-oss-120b",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"openai.gpt-oss-20b",name:"gpt-oss-20b",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.07,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"openai.gpt-oss-20b-1:0",name:"gpt-oss-20b",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.07,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"openai.gpt-oss-safeguard-120b",name:"GPT OSS Safeguard 120B",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"openai.gpt-oss-safeguard-20b",name:"GPT OSS Safeguard 20B",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.07,output:0.2,cacheRead:0,cacheWrite:0}}},{modelId:"qwen.qwen3-235b-a22b-2507-v1:0",name:"Qwen3 235B A22B 2507",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:131072,cost:{input:0.22,output:0.88,cacheRead:0,cacheWrite:0}}},{modelId:"qwen.qwen3-32b-v1:0",name:"Qwen3 32B (dense)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:16384,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"qwen.qwen3-coder-30b-a3b-v1:0",name:"Qwen3 Coder 30B A3B Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:131072,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"qwen.qwen3-coder-480b-a35b-v1:0",name:"Qwen3 Coder 480B A35B Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:65536,cost:{input:0.22,output:1.8,cacheRead:0,cacheWrite:0}}},{modelId:"qwen.qwen3-coder-next",name:"Qwen3 Coder Next",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:65536,cost:{input:0.22,output:1.8,cacheRead:0,cacheWrite:0}}},{modelId:"qwen.qwen3-next-80b-a3b",name:"Qwen/Qwen3-Next-80B-A3B-Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:262000,maxTokens:262000,cost:{input:0.14,output:1.4,cacheRead:0,cacheWrite:0}}},{modelId:"qwen.qwen3-vl-235b-a22b",name:"Qwen/Qwen3-VL-235B-A22B-Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:262000,maxTokens:262000,cost:{input:0.3,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"us.anthropic.claude-fable-5",name:"Claude Fable 5 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5}}},{modelId:"us.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"us.anthropic.claude-opus-4-1-20250805-v1:0",name:"Claude Opus 4.1 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"us.anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"us.anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"us.anthropic.claude-opus-4-7",name:"Claude Opus 4.7 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"us.anthropic.claude-opus-4-8",name:"Claude Opus 4.8 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"us.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"us.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"us.deepseek.r1-v1:0",name:"DeepSeek-R1 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:32768,cost:{input:1.35,output:5.4,cacheRead:0,cacheWrite:0}}},{modelId:"us.meta.llama4-maverick-17b-instruct-v1:0",name:"Llama 4 Maverick 17B Instruct (US)",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:1e6,maxTokens:16384,cost:{input:0.24,output:0.97,cacheRead:0,cacheWrite:0}}},{modelId:"us.meta.llama4-scout-17b-instruct-v1:0",name:"Llama 4 Scout 17B Instruct (US)",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:3500000,maxTokens:16384,cost:{input:0.17,output:0.66,cacheRead:0,cacheWrite:0}}},{modelId:"writer.palmyra-x4-v1:0",name:"Palmyra X4",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:122880,maxTokens:8192,cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0}}},{modelId:"writer.palmyra-x5-v1:0",name:"Palmyra X5",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:1040000,maxTokens:8192,cost:{input:0.6,output:6,cacheRead:0,cacheWrite:0}}},{modelId:"zai.glm-4.7",name:"GLM-4.7",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.6,output:2.2,cacheRead:0,cacheWrite:0}}},{modelId:"zai.glm-4.7-flash",name:"GLM-4.7-Flash",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:131072,cost:{input:0.07,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"zai.glm-5",name:"GLM-5",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:101376,cost:{input:1,output:3.2,cacheRead:0,cacheWrite:0}}}]},"ant-ling":{name:"ant-ling",config:{api:"openai-completions",baseUrl:"https://api.ant-ling.com/v1",apiKey:""},models:[{modelId:"Ling-2.6-1T",name:"Ling 2.6 1T",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:0.06,output:0.25,cacheRead:0,cacheWrite:0}}},{modelId:"Ling-2.6-flash",name:"Ling 2.6 Flash",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:0.01,output:0.02,cacheRead:0,cacheWrite:0}}},{modelId:"Ring-2.6-1T",name:"Ring 2.6 1T",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:0.06,output:0.25,cacheRead:0,cacheWrite:0}}}]},"azure-openai-responses":{name:"azure-openai-responses",config:{api:"azure-openai-responses",baseUrl:"",apiKey:"AZURE_OPENAI_API_KEY"},models:[{modelId:"gpt-4",name:"GPT-4",config:{api:"azure-openai-responses",reasoning:!1,input:["text"],contextWindow:8192,maxTokens:8192,cost:{input:30,output:60,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-4-turbo",name:"GPT-4 Turbo",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:10,output:30,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-4.1",name:"GPT-4.1",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"gpt-4.1-mini",name:"GPT-4.1 mini",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:0.4,output:1.6,cacheRead:0.1,cacheWrite:0}}},{modelId:"gpt-4.1-nano",name:"GPT-4.1 nano",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:0.1,output:0.4,cacheRead:0.025,cacheWrite:0}}},{modelId:"gpt-4o",name:"GPT-4o",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"gpt-4o-2024-05-13",name:"GPT-4o (2024-05-13)",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:5,output:15,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-4o-2024-08-06",name:"GPT-4o (2024-08-06)",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"gpt-4o-2024-11-20",name:"GPT-4o (2024-11-20)",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"gpt-4o-mini",name:"GPT-4o mini",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0.075,cacheWrite:0}}},{modelId:"gpt-5",name:"GPT-5",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5-chat-latest",name:"GPT-5 Chat Latest",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5-codex",name:"GPT-5-Codex",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5-mini",name:"GPT-5 Mini",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"gpt-5-nano",name:"GPT-5 Nano",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.05,output:0.4,cacheRead:0.005,cacheWrite:0}}},{modelId:"gpt-5-pro",name:"GPT-5 Pro",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:15,output:120,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-5.1",name:"GPT-5.1",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-chat-latest",name:"GPT-5.1 Chat",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-codex",name:"GPT-5.1 Codex",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex mini",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"gpt-5.2",name:"GPT-5.2",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-chat-latest",name:"GPT-5.2 Chat",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-codex",name:"GPT-5.2 Codex",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-pro",name:"GPT-5.2 Pro",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:21,output:168,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-5.3-chat-latest",name:"GPT-5.3 Chat (latest)",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.3-codex",name:"GPT-5.3 Codex",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:32000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.4",name:"GPT-5.4",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:2.5,output:15,cacheRead:0.25,cacheWrite:0}}},{modelId:"gpt-5.4-mini",name:"GPT-5.4 mini",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.75,output:4.5,cacheRead:0.075,cacheWrite:0}}},{modelId:"gpt-5.4-nano",name:"GPT-5.4 nano",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.2,output:1.25,cacheRead:0.02,cacheWrite:0}}},{modelId:"gpt-5.4-pro",name:"GPT-5.4 Pro",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-5.5",name:"GPT-5.5",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"gpt-5.5-pro",name:"GPT-5.5 Pro",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:0,cacheWrite:0}}},{modelId:"o1",name:"o1",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0}}},{modelId:"o1-pro",name:"o1-pro",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:150,output:600,cacheRead:0,cacheWrite:0}}},{modelId:"o3",name:"o3",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"o3-deep-research",name:"o3-deep-research",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0}}},{modelId:"o3-mini",name:"o3-mini",config:{api:"azure-openai-responses",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.55,cacheWrite:0}}},{modelId:"o3-pro",name:"o3-pro",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:20,output:80,cacheRead:0,cacheWrite:0}}},{modelId:"o4-mini",name:"o4-mini",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.275,cacheWrite:0}}},{modelId:"o4-mini-deep-research",name:"o4-mini-deep-research",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}}]},cerebras:{name:"cerebras",config:{api:"openai-completions",baseUrl:"https://api.cerebras.ai/v1",apiKey:"CEREBRAS_API_KEY"},models:[{modelId:"gpt-oss-120b",name:"GPT OSS 120B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:40960,cost:{input:0.35,output:0.75,cacheRead:0,cacheWrite:0}}},{modelId:"zai-glm-4.7",name:"Z.AI GLM-4.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:40960,cost:{input:2.25,output:2.75,cacheRead:0,cacheWrite:0}}}]},"cloudflare-ai-gateway":{name:"cloudflare-ai-gateway",config:{api:"anthropic-messages",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",apiKey:"CLOUDFLARE_API_KEY"},models:[{modelId:"claude-3-5-haiku",name:"Claude Haiku 3.5 (latest)",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:0.8,output:4,cacheRead:0.08,cacheWrite:1}}},{modelId:"claude-3-haiku",name:"Claude Haiku 3",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:0.25,output:1.25,cacheRead:0.03,cacheWrite:0.3}}},{modelId:"claude-3-opus",name:"Claude Opus 3",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-3-sonnet",name:"Claude Sonnet 3",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:0.3}}},{modelId:"claude-3.5-haiku",name:"Claude Haiku 3.5 (latest)",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:0.8,output:4,cacheRead:0.08,cacheWrite:1}}},{modelId:"claude-3.5-sonnet",name:"Claude Sonnet 3.5 v2",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-fable-5",name:"Claude Fable 5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5}}},{modelId:"claude-haiku-4-5",name:"Claude Haiku 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"claude-opus-4",name:"Claude Opus 4 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-opus-4-1",name:"Claude Opus 4.1 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-opus-4-5",name:"Claude Opus 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-6",name:"Claude Opus 4.6 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-7",name:"Claude Opus 4.7",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-8",name:"Claude Opus 4.8",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-sonnet-4",name:"Claude Sonnet 4 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4-5",name:"Claude Sonnet 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"gpt-4",name:"GPT-4",config:{api:"openai-responses",reasoning:!1,input:["text"],contextWindow:8192,maxTokens:8192,cost:{input:30,output:60,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-4-turbo",name:"GPT-4 Turbo",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:10,output:30,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-4o",name:"GPT-4o",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"gpt-4o-mini",name:"GPT-4o mini",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0.08,cacheWrite:0}}},{modelId:"gpt-5.1",name:"GPT-5.1",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.13,cacheWrite:0}}},{modelId:"gpt-5.1-codex",name:"GPT-5.1 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.2",name:"GPT-5.2",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-codex",name:"GPT-5.2 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.3-codex",name:"GPT-5.3 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.4",name:"GPT-5.4",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:2.5,output:15,cacheRead:0.25,cacheWrite:0}}},{modelId:"gpt-5.5",name:"GPT-5.5",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"o1",name:"o1",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0}}},{modelId:"o3",name:"o3",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"o3-mini",name:"o3-mini",config:{api:"openai-responses",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.55,cacheWrite:0}}},{modelId:"o3-pro",name:"o3-pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:20,output:80,cacheRead:0,cacheWrite:0}}},{modelId:"o4-mini",name:"o4-mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.28,cacheWrite:0}}},{modelId:"workers-ai/@cf/moonshotai/kimi-k2.5",name:"Kimi K2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:0.6,output:3,cacheRead:0.1,cacheWrite:0}}},{modelId:"workers-ai/@cf/moonshotai/kimi-k2.6",name:"Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}},{modelId:"workers-ai/@cf/nvidia/nemotron-3-120b-a12b",name:"Nemotron 3 Super 120B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:256000,cost:{input:0.5,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"workers-ai/@cf/zai-org/glm-4.7-flash",name:"GLM-4.7-Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.06,output:0.4,cacheRead:0,cacheWrite:0}}}]},"cloudflare-workers-ai":{name:"cloudflare-workers-ai",config:{api:"openai-completions",baseUrl:"https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1",apiKey:"CLOUDFLARE_API_KEY"},models:[{modelId:"@cf/google/gemma-4-26b-a4b-it",name:"Gemma 4 26B A4B IT",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:16384,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/ibm-granite/granite-4.0-h-micro",name:"Granite 4.0 H Micro",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131000,maxTokens:131000,cost:{input:0.017,output:0.112,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/meta/llama-3.3-70b-instruct-fp8-fast",name:"Llama 3.3 70B Instruct fp8 Fast",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:24000,maxTokens:24000,cost:{input:0.293,output:2.253,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/meta/llama-4-scout-17b-16e-instruct",name:"Llama 4 Scout 17B 16E Instruct",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:131000,maxTokens:16384,cost:{input:0.27,output:0.85,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/mistralai/mistral-small-3.1-24b-instruct",name:"Mistral Small 3.1 24B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.351,output:0.555,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/moonshotai/kimi-k2.6",name:"Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:256000,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}},{modelId:"@cf/moonshotai/kimi-k2.7-code",name:"Kimi K2.7 Code",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.95,output:4,cacheRead:0.19,cacheWrite:0}}},{modelId:"@cf/nvidia/nemotron-3-120b-a12b",name:"Nemotron 3 Super 120B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:256000,cost:{input:0.5,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/openai/gpt-oss-120b",name:"GPT OSS 120B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.35,output:0.75,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/openai/gpt-oss-20b",name:"GPT OSS 20B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.2,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/qwen/qwen3-30b-a3b-fp8",name:"Qwen3 30B A3b fp8",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:32768,maxTokens:32768,cost:{input:0.0509,output:0.335,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/zai-org/glm-4.7-flash",name:"GLM-4.7-Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.0605,output:0.4,cacheRead:0,cacheWrite:0}}}]},fireworks:{name:"fireworks",config:{api:"anthropic-messages",baseUrl:"https://api.fireworks.ai/inference",apiKey:"FIREWORKS_API_KEY"},models:[{modelId:"accounts/fireworks/models/deepseek-v4-flash",name:"DeepSeek V4 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:0.14,output:0.28,cacheRead:0.03,cacheWrite:0}}},{modelId:"accounts/fireworks/models/deepseek-v4-pro",name:"DeepSeek V4 Pro",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:1.74,output:3.48,cacheRead:0.145,cacheWrite:0}}},{modelId:"accounts/fireworks/models/glm-5p1",name:"GLM 5.1",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:202800,maxTokens:131072,cost:{input:1.4,output:4.4,cacheRead:0.26,cacheWrite:0}}},{modelId:"accounts/fireworks/models/gpt-oss-120b",name:"GPT OSS 120B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:32768,cost:{input:0.15,output:0.6,cacheRead:0.015,cacheWrite:0}}},{modelId:"accounts/fireworks/models/gpt-oss-20b",name:"GPT OSS 20B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:32768,cost:{input:0.07,output:0.3,cacheRead:0.035,cacheWrite:0}}},{modelId:"accounts/fireworks/models/kimi-k2p6",name:"Kimi K2.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262000,maxTokens:262000,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}},{modelId:"accounts/fireworks/models/kimi-k2p7-code",name:"Kimi K2.7 Code",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262000,maxTokens:262000,cost:{input:0.95,output:4,cacheRead:0.19,cacheWrite:0}}},{modelId:"accounts/fireworks/models/minimax-m2p7",name:"MiniMax-M2.7",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:196608,maxTokens:196608,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"accounts/fireworks/models/minimax-m3",name:"MiniMax-M3",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:512000,maxTokens:512000,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"accounts/fireworks/models/qwen3p7-plus",name:"Qwen 3.7 Plus",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.4,output:1.6,cacheRead:0.08,cacheWrite:0}}},{modelId:"accounts/fireworks/routers/glm-5p1-fast",name:"GLM 5.1 Fast",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:202800,maxTokens:131072,cost:{input:2.8,output:8.8,cacheRead:0.52,cacheWrite:0}}},{modelId:"accounts/fireworks/routers/kimi-k2p6-fast",name:"Kimi K2.6 Fast",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262000,maxTokens:262000,cost:{input:2,output:8,cacheRead:0.3,cacheWrite:0}}},{modelId:"accounts/fireworks/routers/kimi-k2p6-turbo",name:"Kimi K2.6 Turbo",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262000,maxTokens:262000,cost:{input:2,output:8,cacheRead:0.3,cacheWrite:0}}},{modelId:"accounts/fireworks/routers/kimi-k2p7-code-fast",name:"Kimi K2.7 Code Fast",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262000,maxTokens:262000,cost:{input:2,output:8,cacheRead:0.38,cacheWrite:0}}}]},"github-copilot":{name:"github-copilot",config:{api:"openai-completions",baseUrl:"https://api.individual.githubcopilot.com",apiKey:"COPILOT_GITHUB_TOKEN"},models:[{modelId:"claude-fable-5",name:"Claude Fable 5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5}}},{modelId:"claude-haiku-4.5",name:"Claude Haiku 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"claude-opus-4.5",name:"Claude Opus 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4.6",name:"Claude Opus 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:32000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4.7",name:"Claude Opus 4.7",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4.8",name:"Claude Opus 4.8",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-sonnet-4",name:"Claude Sonnet 4 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:216000,maxTokens:16000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4.5",name:"Claude Sonnet 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4.6",name:"Claude Sonnet 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:32000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"gemini-2.5-pro",name:"Gemini 2.5 Pro",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:64000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:64000,cost:{input:0.5,output:3,cacheRead:0.05,cacheWrite:0}}},{modelId:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"gemini-3.5-flash",name:"Gemini 3.5 Flash",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1.5,output:9,cacheRead:0.15,cacheWrite:0}}},{modelId:"gpt-4.1",name:"GPT-4.1",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"gpt-5-mini",name:"GPT-5 Mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:264000,maxTokens:64000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"gpt-5.2",name:"GPT-5.2",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-codex",name:"GPT-5.2 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.3-codex",name:"GPT-5.3 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.4",name:"GPT-5.4",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:2.5,output:15,cacheRead:0.25,cacheWrite:0}}},{modelId:"gpt-5.4-mini",name:"GPT-5.4 mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.75,output:4.5,cacheRead:0.075,cacheWrite:0}}},{modelId:"gpt-5.4-nano",name:"GPT-5.4 nano",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.2,output:1.25,cacheRead:0.02,cacheWrite:0}}},{modelId:"gpt-5.5",name:"GPT-5.5",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"raptor-mini",name:"Raptor mini",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}}]},"google-vertex":{name:"google-vertex",config:{api:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",apiKey:"GOOGLE_CLOUD_API_KEY"},models:[{modelId:"gemini-1.5-flash",name:"Gemini 1.5 Flash (Vertex)",config:{api:"google-vertex",reasoning:!1,input:["text","image"],contextWindow:1e6,maxTokens:8192,cost:{input:0.075,output:0.3,cacheRead:0.01875,cacheWrite:0}}},{modelId:"gemini-1.5-flash-8b",name:"Gemini 1.5 Flash-8B (Vertex)",config:{api:"google-vertex",reasoning:!1,input:["text","image"],contextWindow:1e6,maxTokens:8192,cost:{input:0.0375,output:0.15,cacheRead:0.01,cacheWrite:0}}},{modelId:"gemini-1.5-pro",name:"Gemini 1.5 Pro (Vertex)",config:{api:"google-vertex",reasoning:!1,input:["text","image"],contextWindow:1e6,maxTokens:8192,cost:{input:1.25,output:5,cacheRead:0.3125,cacheWrite:0}}},{modelId:"gemini-2.0-flash",name:"Gemini 2.0 Flash (Vertex)",config:{api:"google-vertex",reasoning:!1,input:["text","image"],contextWindow:1048576,maxTokens:8192,cost:{input:0.15,output:0.6,cacheRead:0.0375,cacheWrite:0}}},{modelId:"gemini-2.0-flash-lite",name:"Gemini 2.0 Flash Lite (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.075,output:0.3,cacheRead:0.01875,cacheWrite:0}}},{modelId:"gemini-2.5-flash",name:"Gemini 2.5 Flash (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.3,output:2.5,cacheRead:0.03,cacheWrite:0}}},{modelId:"gemini-2.5-flash-lite",name:"Gemini 2.5 Flash Lite (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.1,output:0.4,cacheRead:0.01,cacheWrite:0}}},{modelId:"gemini-2.5-flash-lite-preview-09-2025",name:"Gemini 2.5 Flash Lite Preview 09-25 (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.1,output:0.4,cacheRead:0.01,cacheWrite:0}}},{modelId:"gemini-2.5-pro",name:"Gemini 2.5 Pro (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.5,output:3,cacheRead:0.05,cacheWrite:0}}},{modelId:"gemini-3-pro-preview",name:"Gemini 3 Pro Preview (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"gemini-3.1-pro-preview-customtools",name:"Gemini 3.1 Pro Preview Custom Tools (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}}]},huggingface:{name:"huggingface",config:{api:"openai-completions",baseUrl:"https://router.huggingface.co/v1",apiKey:"HF_TOKEN"},models:[{modelId:"MiniMaxAI/MiniMax-M2.1",name:"MiniMax-M2.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0,cacheWrite:0}}},{modelId:"MiniMaxAI/MiniMax-M2.5",name:"MiniMax-M2.5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.03,cacheWrite:0}}},{modelId:"MiniMaxAI/MiniMax-M2.7",name:"MiniMax-M2.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"Qwen/Qwen3-235B-A22B-Thinking-2507",name:"Qwen3-235B-A22B-Thinking-2507",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:131072,cost:{input:0.3,output:3,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3-Coder-480B-A35B-Instruct",name:"Qwen3-Coder-480B-A35B-Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:66536,cost:{input:2,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3-Coder-Next",name:"Qwen3-Coder-Next",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:0.2,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3-Next-80B-A3B-Instruct",name:"Qwen3-Next-80B-A3B-Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:66536,cost:{input:0.25,output:1,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3-Next-80B-A3B-Thinking",name:"Qwen3-Next-80B-A3B-Thinking",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:131072,cost:{input:0.3,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3.5-397B-A17B",name:"Qwen3.5-397B-A17B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0.6,output:3.6,cacheRead:0,cacheWrite:0}}},{modelId:"XiaomiMiMo/MiMo-V2-Flash",name:"MiMo-V2-Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:4096,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek-ai/DeepSeek-R1-0528",name:"DeepSeek-R1-0528",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:163840,cost:{input:3,output:5,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek-ai/DeepSeek-V3.2",name:"DeepSeek-V3.2",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:65536,cost:{input:0.28,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek-ai/DeepSeek-V4-Pro",name:"DeepSeek V4 Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:393216,cost:{input:0.435,output:0.87,cacheRead:0.003625,cacheWrite:0}}},{modelId:"moonshotai/Kimi-K2-Instruct",name:"Kimi-K2-Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:1,output:3,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/Kimi-K2-Instruct-0905",name:"Kimi-K2-Instruct-0905",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:16384,cost:{input:1,output:3,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/Kimi-K2-Thinking",name:"Kimi-K2-Thinking",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"moonshotai/Kimi-K2.5",name:"Kimi-K2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:3,cacheRead:0.1,cacheWrite:0}}},{modelId:"moonshotai/Kimi-K2.6",name:"Kimi-K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}},{modelId:"zai-org/GLM-4.7",name:"GLM-4.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.6,output:2.2,cacheRead:0.11,cacheWrite:0}}},{modelId:"zai-org/GLM-4.7-Flash",name:"GLM-4.7-Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:128000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"zai-org/GLM-5",name:"GLM-5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:131072,cost:{input:1,output:3.2,cacheRead:0.2,cacheWrite:0}}},{modelId:"zai-org/GLM-5.1",name:"GLM-5.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:131072,cost:{input:1,output:3.2,cacheRead:0.2,cacheWrite:0}}}]},"kimi-coding":{name:"kimi-coding",config:{api:"anthropic-messages",baseUrl:"https://api.kimi.com/coding",apiKey:"KIMI_API_KEY"},models:[{modelId:"k2p7",name:"Kimi K2.7 Code",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"kimi-for-coding",name:"Kimi For Coding",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"kimi-k2-thinking",name:"Kimi K2 Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}}]},minimax:{name:"minimax",config:{api:"anthropic-messages",baseUrl:"https://api.minimax.io/anthropic",apiKey:"MINIMAX_API_KEY"},models:[{modelId:"MiniMax-M2.7",name:"MiniMax-M2.7",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0.375}}},{modelId:"MiniMax-M2.7-highspeed",name:"MiniMax-M2.7-highspeed",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.6,output:2.4,cacheRead:0.06,cacheWrite:0.375}}},{modelId:"MiniMax-M3",name:"MiniMax-M3",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:512000,maxTokens:128000,cost:{input:0.6,output:2.4,cacheRead:0.12,cacheWrite:0}}}]},"minimax-cn":{name:"minimax-cn",config:{api:"anthropic-messages",baseUrl:"https://api.minimaxi.com/anthropic",apiKey:"MINIMAX_CN_API_KEY"},models:[{modelId:"MiniMax-M2.7",name:"MiniMax-M2.7",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0.375}}},{modelId:"MiniMax-M2.7-highspeed",name:"MiniMax-M2.7-highspeed",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.6,output:2.4,cacheRead:0.06,cacheWrite:0.375}}},{modelId:"MiniMax-M3",name:"MiniMax-M3",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:512000,maxTokens:128000,cost:{input:0.6,output:2.4,cacheRead:0.12,cacheWrite:0}}}]},moonshotai:{name:"moonshotai",config:{api:"openai-completions",baseUrl:"https://api.moonshot.ai/v1",apiKey:"MOONSHOT_API_KEY"},models:[{modelId:"kimi-k2-0711-preview",name:"Kimi K2 0711",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.6,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"kimi-k2-0905-preview",name:"Kimi K2 0905",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"kimi-k2-thinking",name:"Kimi K2 Thinking",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"kimi-k2-thinking-turbo",name:"Kimi K2 Thinking Turbo",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:1.15,output:8,cacheRead:0.15,cacheWrite:0}}},{modelId:"kimi-k2-turbo-preview",name:"Kimi K2 Turbo",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:2.4,output:10,cacheRead:0.6,cacheWrite:0}}},{modelId:"kimi-k2.5",name:"Kimi K2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:3,cacheRead:0.1,cacheWrite:0}}},{modelId:"kimi-k2.6",name:"Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}},{modelId:"kimi-k2.7-code",name:"Kimi K2.7 Code",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.95,output:4,cacheRead:0.19,cacheWrite:0}}}]},"moonshotai-cn":{name:"moonshotai-cn",config:{api:"openai-completions",baseUrl:"https://api.moonshot.cn/v1",apiKey:"MOONSHOT_API_KEY"},models:[{modelId:"kimi-k2-0711-preview",name:"Kimi K2 0711",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.6,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"kimi-k2-0905-preview",name:"Kimi K2 0905",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"kimi-k2-thinking",name:"Kimi K2 Thinking",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"kimi-k2-thinking-turbo",name:"Kimi K2 Thinking Turbo",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:1.15,output:8,cacheRead:0.15,cacheWrite:0}}},{modelId:"kimi-k2-turbo-preview",name:"Kimi K2 Turbo",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:2.4,output:10,cacheRead:0.6,cacheWrite:0}}},{modelId:"kimi-k2.5",name:"Kimi K2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:3,cacheRead:0.1,cacheWrite:0}}},{modelId:"kimi-k2.6",name:"Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}}]},nvidia:{name:"nvidia",config:{api:"openai-completions",baseUrl:"https://integrate.api.nvidia.com/v1",apiKey:""},models:[{modelId:"meta/llama-3.1-70b-instruct",name:"Llama 3.1 70b Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.1-8b-instruct",name:"Llama 3.1 8B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:16000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.2-11b-vision-instruct",name:"Llama 3.2 11b Vision Instruct",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.2-90b-vision-instruct",name:"Llama-3.2-90B-Vision-Instruct",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:8192,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.3-70b-instruct",name:"Llama 3.3 70b Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"mistralai/mistral-large-3-675b-instruct-2512",name:"Mistral Large 3 675B Instruct 2512",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"mistralai/mistral-small-4-119b-2603",name:"mistral-small-4-119b-2603",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:8192,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2.6",name:"Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-nano-30b-a3b",name:"nemotron-3-nano-30b-a3b",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning",name:"Nemotron 3 Nano Omni",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:65536,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-super-120b-a12b",name:"Nemotron 3 Super",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.2,output:0.8,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-ultra-550b-a55b",name:"Nemotron 3 Ultra 550B A55B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:65536,cost:{input:0.5,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"nvidia/nvidia-nemotron-nano-9b-v2",name:"nvidia-nemotron-nano-9b-v2",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-120b",name:"GPT-OSS-120B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:8192,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-20b",name:"GPT OSS 20B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.5-122b-a10b",name:"Qwen3.5 122B-A10B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"stepfun-ai/step-3.5-flash",name:"Step 3.5 Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:16384,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"stepfun-ai/step-3.7-flash",name:"Step 3.7 Flash",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:16384,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"z-ai/glm-5.1",name:"GLM-5.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}}]},"openai-codex":{name:"openai-codex",config:{api:"openai-codex-responses",baseUrl:"https://chatgpt.com/backend-api",apiKey:""},models:[{modelId:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",config:{api:"openai-codex-responses",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.4",name:"GPT-5.4",config:{api:"openai-codex-responses",reasoning:!0,input:["text","image"],contextWindow:272000,maxTokens:128000,cost:{input:2.5,output:15,cacheRead:0.25,cacheWrite:0}}},{modelId:"gpt-5.4-mini",name:"GPT-5.4 mini",config:{api:"openai-codex-responses",reasoning:!0,input:["text","image"],contextWindow:272000,maxTokens:128000,cost:{input:0.75,output:4.5,cacheRead:0.075,cacheWrite:0}}},{modelId:"gpt-5.5",name:"GPT-5.5",config:{api:"openai-codex-responses",reasoning:!0,input:["text","image"],contextWindow:272000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}}]},opencode:{name:"opencode",config:{api:"openai-completions",baseUrl:"https://opencode.ai/zen/v1",apiKey:"OPENCODE_API_KEY"},models:[{modelId:"big-pickle",name:"Big Pickle",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:32000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"claude-haiku-4-5",name:"Claude Haiku 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"claude-opus-4-1",name:"Claude Opus 4.1",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-opus-4-5",name:"Claude Opus 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-6",name:"Claude Opus 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-7",name:"Claude Opus 4.7",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-8",name:"Claude Opus 4.8",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-sonnet-4",name:"Claude Sonnet 4",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4-5",name:"Claude Sonnet 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"deepseek-v4-flash",name:"DeepSeek V4 Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:0.14,output:0.28,cacheRead:0.028,cacheWrite:0}}},{modelId:"deepseek-v4-flash-free",name:"DeepSeek V4 Flash Free",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:128000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek-v4-pro",name:"DeepSeek V4 Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:1.74,output:3.84,cacheRead:0.145,cacheWrite:0}}},{modelId:"gemini-3-flash",name:"Gemini 3 Flash",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.5,output:3,cacheRead:0.05,cacheWrite:0}}},{modelId:"gemini-3.1-pro",name:"Gemini 3.1 Pro Preview",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"gemini-3.5-flash",name:"Gemini 3.5 Flash",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.5,output:9,cacheRead:0.15,cacheWrite:0}}},{modelId:"glm-5",name:"GLM-5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:1,output:3.2,cacheRead:0.2,cacheWrite:0}}},{modelId:"glm-5.1",name:"GLM-5.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:1.4,output:4.4,cacheRead:0.26,cacheWrite:0}}},{modelId:"gpt-5",name:"GPT-5",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.07,output:8.5,cacheRead:0.107,cacheWrite:0}}},{modelId:"gpt-5-codex",name:"GPT-5 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.07,output:8.5,cacheRead:0.107,cacheWrite:0}}},{modelId:"gpt-5-nano",name:"GPT-5 Nano",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.05,output:0.4,cacheRead:0.005,cacheWrite:0}}},{modelId:"gpt-5.1",name:"GPT-5.1",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.07,output:8.5,cacheRead:0.107,cacheWrite:0}}},{modelId:"gpt-5.1-codex",name:"GPT-5.1 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.07,output:8.5,cacheRead:0.107,cacheWrite:0}}},{modelId:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex Mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"gpt-5.2",name:"GPT-5.2",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-codex",name:"GPT-5.2 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.3-codex",name:"GPT-5.3 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.4",name:"GPT-5.4",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:272000,maxTokens:128000,cost:{input:2.5,output:15,cacheRead:0.25,cacheWrite:0}}},{modelId:"gpt-5.4-mini",name:"GPT-5.4 Mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.75,output:4.5,cacheRead:0.075,cacheWrite:0}}},{modelId:"gpt-5.4-nano",name:"GPT-5.4 Nano",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.2,output:1.25,cacheRead:0.02,cacheWrite:0}}},{modelId:"gpt-5.4-pro",name:"GPT-5.4 Pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:30,cacheWrite:0}}},{modelId:"gpt-5.5",name:"GPT-5.5",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"gpt-5.5-pro",name:"GPT-5.5 Pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:30,cacheWrite:0}}},{modelId:"grok-build-0.1",name:"Grok Build 0.1",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:1,output:2,cacheRead:0.2,cacheWrite:0}}},{modelId:"kimi-k2.5",name:"Kimi K2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.6,output:3,cacheRead:0.08,cacheWrite:0}}},{modelId:"kimi-k2.6",name:"Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}},{modelId:"mimo-v2.5-free",name:"MiMo V2.5 Free",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"minimax-m2.5",name:"MiniMax M2.5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"minimax-m2.7",name:"MiniMax M2.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"nemotron-3-ultra-free",name:"Nemotron 3 Ultra Free",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:128000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"north-mini-code-free",name:"North Mini Code Free",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:64000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"qwen3.5-plus",name:"Qwen3.5 Plus",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.2,output:1.2,cacheRead:0.02,cacheWrite:0.25}}},{modelId:"qwen3.6-plus",name:"Qwen3.6 Plus",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.5,output:3,cacheRead:0.05,cacheWrite:0.625}}}]},"opencode-go":{name:"opencode-go",config:{api:"openai-completions",baseUrl:"https://opencode.ai/zen/go/v1",apiKey:"OPENCODE_API_KEY"},models:[{modelId:"deepseek-v4-flash",name:"DeepSeek V4 Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:0.14,output:0.28,cacheRead:0.0028,cacheWrite:0}}},{modelId:"deepseek-v4-pro",name:"DeepSeek V4 Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:1.74,output:3.48,cacheRead:0.0145,cacheWrite:0}}},{modelId:"glm-5",name:"GLM-5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:32768,cost:{input:1,output:3.2,cacheRead:0.2,cacheWrite:0}}},{modelId:"glm-5.1",name:"GLM-5.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:32768,cost:{input:1.4,output:4.4,cacheRead:0.26,cacheWrite:0}}},{modelId:"kimi-k2.6",name:"Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}},{modelId:"kimi-k2.7-code",name:"Kimi K2.7 Code",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.95,output:4,cacheRead:0.19,cacheWrite:0}}},{modelId:"mimo-v2.5",name:"MiMo V2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:0.14,output:0.28,cacheRead:0.0028,cacheWrite:0}}},{modelId:"mimo-v2.5-pro",name:"MiMo V2.5 Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:128000,cost:{input:1.74,output:3.48,cacheRead:0.0145,cacheWrite:0}}},{modelId:"minimax-m2.7",name:"MiniMax M2.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"minimax-m3",name:"MiniMax M3 (3x usage)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:512000,maxTokens:131072,cost:{input:0.1,output:0.4,cacheRead:0.02,cacheWrite:0}}},{modelId:"qwen3.6-plus",name:"Qwen3.6 Plus",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.5,output:3,cacheRead:0.05,cacheWrite:0.625}}},{modelId:"qwen3.7-max",name:"Qwen3.7 Max",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:65536,cost:{input:2.5,output:7.5,cacheRead:0.5,cacheWrite:3.125}}},{modelId:"qwen3.7-plus",name:"Qwen3.7 Plus",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.4,output:1.6,cacheRead:0.04,cacheWrite:0.5}}}]},together:{name:"together",config:{api:"openai-completions",baseUrl:"https://api.together.ai/v1",apiKey:"TOGETHER_API_KEY"},models:[{modelId:"MiniMaxAI/MiniMax-M2.7",name:"MiniMax-M2.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"MiniMaxAI/MiniMax-M3",name:"MiniMax-M3",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:524288,maxTokens:250000,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"Qwen/Qwen2.5-7B-Instruct-Turbo",name:"Qwen 2.5 7B Instruct Turbo",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:32768,maxTokens:32768,cost:{input:0.3,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3-235B-A22B-Instruct-2507-tput",name:"Qwen3 235B A22B Instruct 2507 FP8",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.2,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3.5-397B-A17B",name:"Qwen3.5 397B A17B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:130000,cost:{input:0.6,output:3.6,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3.5-9B",name:"Qwen3.5 9B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.17,output:0.25,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3.6-Plus",name:"Qwen3.6 Plus",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:500000,cost:{input:0.5,output:3,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3.7-Max",name:"Qwen3.7 Max",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:1e6,maxTokens:500000,cost:{input:2.5,output:7.5,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek-ai/DeepSeek-V4-Pro",name:"DeepSeek V4 Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:512000,maxTokens:384000,cost:{input:1.74,output:3.48,cacheRead:0.2,cacheWrite:0}}},{modelId:"essentialai/Rnj-1-Instruct",name:"Rnj-1 Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:32768,maxTokens:32768,cost:{input:0.15,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"google/gemma-4-31B-it",name:"Gemma 4 31B Instruct",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.39,output:0.97,cacheRead:0,cacheWrite:0}}},{modelId:"meta-llama/Llama-3.3-70B-Instruct-Turbo",name:"Llama 3.3 70B",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.88,output:0.88,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/Kimi-K2.6",name:"Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131000,cost:{input:1.2,output:4.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"moonshotai/Kimi-K2.7-Code",name:"Kimi K2.7 Code",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:131072,cost:{input:0.95,output:4,cacheRead:0.19,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-ultra-550b-a55b",name:"Nemotron 3 Ultra 550B A55B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:512300,maxTokens:512300,cost:{input:0.6,output:3.6,cacheRead:0.2,cacheWrite:0}}},{modelId:"openai/gpt-oss-120b",name:"GPT OSS 120B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-20b",name:"GPT OSS 20B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.05,output:0.2,cacheRead:0,cacheWrite:0}}},{modelId:"zai-org/GLM-5",name:"GLM-5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:131072,cost:{input:1,output:3.2,cacheRead:0,cacheWrite:0}}},{modelId:"zai-org/GLM-5.1",name:"GLM-5.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:131072,cost:{input:1.4,output:4.4,cacheRead:0,cacheWrite:0}}}]},"vercel-ai-gateway":{name:"vercel-ai-gateway",config:{api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",apiKey:"AI_GATEWAY_API_KEY"},models:[{modelId:"alibaba/qwen-3-14b",name:"Qwen3-14B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:40960,maxTokens:16384,cost:{input:0.12,output:0.24,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen-3-235b",name:"Qwen3 235B A22B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:16384,cost:{input:0.22,output:0.88,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen-3-30b",name:"Qwen3-30B-A3B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:40960,maxTokens:16384,cost:{input:0.12,output:0.5,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen-3-32b",name:"Qwen 3 32B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:8192,cost:{input:0.16,output:0.64,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen-3.6-max-preview",name:"Qwen 3.6 Max Preview",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:240000,maxTokens:64000,cost:{input:1.3,output:7.8,cacheRead:0.26,cacheWrite:1.625}}},{modelId:"alibaba/qwen3-235b-a22b-thinking",name:"Qwen3 VL 235B A22B Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:131072,maxTokens:32768,cost:{input:0.4,output:4,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen3-coder",name:"Qwen3 Coder 480B A35B Instruct",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:1.5,output:7.5,cacheRead:0.3,cacheWrite:0}}},{modelId:"alibaba/qwen3-coder-30b-a3b",name:"Qwen 3 Coder 30B A3B Instruct",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:8192,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen3-coder-next",name:"Qwen3 Coder Next",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:256000,cost:{input:0.5,output:1.2,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen3-coder-plus",name:"Qwen3 Coder Plus",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:1e6,maxTokens:65536,cost:{input:1,output:5,cacheRead:0.2,cacheWrite:0}}},{modelId:"alibaba/qwen3-max",name:"Qwen3 Max",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:1.2,output:6,cacheRead:0.24,cacheWrite:0}}},{modelId:"alibaba/qwen3-max-preview",name:"Qwen3 Max Preview",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:1.2,output:6,cacheRead:0.24,cacheWrite:0}}},{modelId:"alibaba/qwen3-max-thinking",name:"Qwen 3 Max Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:65536,cost:{input:1.2,output:6,cacheRead:0.24,cacheWrite:0}}},{modelId:"alibaba/qwen3-next-80b-a3b-instruct",name:"Qwen3 Next 80B A3B Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:32768,cost:{input:0.15,output:1.2,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen3-next-80b-a3b-thinking",name:"Qwen3 Next 80B A3B Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:32768,cost:{input:0.15,output:1.2,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen3-vl-thinking",name:"Qwen3 VL 235B A22B Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:131072,maxTokens:32768,cost:{input:0.4,output:4,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen3.5-flash",name:"Qwen 3.5 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:0.1,output:0.4,cacheRead:0.001,cacheWrite:0.125}}},{modelId:"alibaba/qwen3.5-plus",name:"Qwen 3.5 Plus",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:0.4,output:2.4,cacheRead:0.04,cacheWrite:0.5}}},{modelId:"alibaba/qwen3.6-27b",name:"Qwen 3.6 27B",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:0.6,output:3.6,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen3.6-plus",name:"Qwen 3.6 Plus",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:0.5,output:3,cacheRead:0.1,cacheWrite:0.625}}},{modelId:"alibaba/qwen3.7-max",name:"Qwen 3.7 Max",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:991000,maxTokens:64000,cost:{input:1.25,output:3.75,cacheRead:0.25,cacheWrite:1.5625}}},{modelId:"alibaba/qwen3.7-plus",name:"Qwen 3.7 Plus",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:0.4,output:1.6,cacheRead:0.08,cacheWrite:0.5}}},{modelId:"anthropic/claude-3-haiku",name:"Claude 3 Haiku",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:0.25,output:1.25,cacheRead:0.03,cacheWrite:0.3}}},{modelId:"anthropic/claude-3.5-haiku",name:"Claude 3.5 Haiku",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:0.8,output:4,cacheRead:0.08,cacheWrite:1}}},{modelId:"anthropic/claude-haiku-4.5",name:"Claude Haiku 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"anthropic/claude-opus-4",name:"Claude Opus 4",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"anthropic/claude-opus-4.1",name:"Claude Opus 4.1",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"anthropic/claude-opus-4.5",name:"Claude Opus 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic/claude-opus-4.6",name:"Claude Opus 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic/claude-opus-4.7",name:"Claude Opus 4.7",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic/claude-opus-4.8",name:"Claude Opus 4.8",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic/claude-sonnet-4",name:"Claude Sonnet 4",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"anthropic/claude-sonnet-4.5",name:"Claude Sonnet 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"anthropic/claude-sonnet-4.6",name:"Claude Sonnet 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"arcee-ai/trinity-large-preview",name:"Trinity Large Preview",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:131000,maxTokens:131000,cost:{input:0.25,output:1,cacheRead:0,cacheWrite:0}}},{modelId:"arcee-ai/trinity-large-thinking",name:"Trinity Large Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:262100,maxTokens:80000,cost:{input:0.25,output:0.9,cacheRead:0,cacheWrite:0}}},{modelId:"bytedance/seed-1.6",name:"Seed 1.6",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:32000,cost:{input:0.25,output:2,cacheRead:0.05,cacheWrite:0}}},{modelId:"cohere/command-a",name:"Command A",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:8000,cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek/deepseek-r1",name:"DeepSeek-R1",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:8192,cost:{input:1.35,output:5.4,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek/deepseek-v3",name:"DeepSeek V3 0324",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:163840,maxTokens:163840,cost:{input:0.27,output:1.12,cacheRead:0.135,cacheWrite:0}}},{modelId:"deepseek/deepseek-v3.1",name:"DeepSeek V3.1",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:8192,cost:{input:0.56,output:1.68,cacheRead:0.28,cacheWrite:0}}},{modelId:"deepseek/deepseek-v3.1-terminus",name:"DeepSeek V3.1 Terminus",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:65536,cost:{input:0.27,output:1,cacheRead:0.135,cacheWrite:0}}},{modelId:"deepseek/deepseek-v3.2",name:"DeepSeek V3.2",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:8000,cost:{input:0.28,output:0.42,cacheRead:0.028,cacheWrite:0}}},{modelId:"deepseek/deepseek-v3.2-thinking",name:"DeepSeek V3.2 Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:8000,cost:{input:0.62,output:1.85,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek/deepseek-v4-flash",name:"DeepSeek V4 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:384000,cost:{input:0.14,output:0.28,cacheRead:0.0028,cacheWrite:0}}},{modelId:"deepseek/deepseek-v4-pro",name:"DeepSeek V4 Pro",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:0.435,output:0.87,cacheRead:0.0036,cacheWrite:0}}},{modelId:"google/gemini-2.5-flash",name:"Gemini 2.5 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.3,output:2.5,cacheRead:0.03,cacheWrite:0}}},{modelId:"google/gemini-2.5-flash-lite",name:"Gemini 2.5 Flash Lite",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.1,output:0.4,cacheRead:0.01,cacheWrite:0}}},{modelId:"google/gemini-2.5-pro",name:"Gemini 2.5 Pro",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"google/gemini-3-flash",name:"Gemini 3 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65000,cost:{input:0.5,output:3,cacheRead:0.05,cacheWrite:0}}},{modelId:"google/gemini-3-pro-preview",name:"Gemini 3 Pro Preview",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"google/gemini-3.1-flash-lite",name:"Gemini 3.1 Flash Lite",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65000,cost:{input:0.25,output:1.5,cacheRead:0.03,cacheWrite:0}}},{modelId:"google/gemini-3.1-flash-lite-preview",name:"Gemini 3.1 Flash Lite Preview",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65000,cost:{input:0.25,output:1.5,cacheRead:0.03,cacheWrite:0}}},{modelId:"google/gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"google/gemini-3.5-flash",name:"Gemini 3.5 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:1.5,output:9,cacheRead:0.15,cacheWrite:0}}},{modelId:"google/gemma-4-26b-a4b-it",name:"Gemma 4 26B A4B IT",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.15,output:0.6,cacheRead:0.015,cacheWrite:0}}},{modelId:"google/gemma-4-31b-it",name:"Gemma 4 31B IT",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.14,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"inception/mercury-2",name:"Mercury 2",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.25,output:0.75,cacheRead:0.025,cacheWrite:0}}},{modelId:"inception/mercury-coder-small",name:"Mercury Coder Small Beta",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:32000,maxTokens:16384,cost:{input:0.25,output:1,cacheRead:0,cacheWrite:0}}},{modelId:"kwaipilot/kat-coder-pro-v2",name:"Kat Coder Pro V2",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:256000,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"meituan/longcat-flash-chat",name:"LongCat Flash Chat",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:1e5,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.1-70b",name:"Llama 3.1 70B Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:8192,cost:{input:0.72,output:0.72,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.1-8b",name:"Llama 3.1 8B Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:8192,cost:{input:0.22,output:0.22,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.2-11b",name:"Llama 3.2 11B Vision Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:8192,cost:{input:0.16,output:0.16,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.2-90b",name:"Llama 3.2 90B Vision Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:8192,cost:{input:0.72,output:0.72,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.3-70b",name:"Llama 3.3 70B Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:8192,cost:{input:0.72,output:0.72,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-4-maverick",name:"Llama 4 Maverick 17B Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:8192,cost:{input:0.24,output:0.97,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-4-scout",name:"Llama 4 Scout 17B Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:8192,cost:{input:0.17,output:0.66,cacheRead:0,cacheWrite:0}}},{modelId:"minimax/minimax-m2",name:"MiniMax M2",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:205000,maxTokens:205000,cost:{input:0.3,output:1.2,cacheRead:0.03,cacheWrite:0.375}}},{modelId:"minimax/minimax-m2.1",name:"MiniMax M2.1",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.03,cacheWrite:0.375}}},{modelId:"minimax/minimax-m2.1-lightning",name:"MiniMax M2.1 Lightning",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:2.4,cacheRead:0.03,cacheWrite:0.375}}},{modelId:"minimax/minimax-m2.5",name:"MiniMax M2.5",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131000,cost:{input:0.3,output:1.2,cacheRead:0.03,cacheWrite:0.375}}},{modelId:"minimax/minimax-m2.5-highspeed",name:"MiniMax M2.5 High Speed",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131000,cost:{input:0.6,output:2.4,cacheRead:0.03,cacheWrite:0.375}}},{modelId:"minimax/minimax-m2.7",name:"MiniMax M2.7",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131000,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0.375}}},{modelId:"minimax/minimax-m2.7-highspeed",name:"MiniMax M2.7 High Speed",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131100,cost:{input:0.6,output:2.4,cacheRead:0.06,cacheWrite:0.375}}},{modelId:"minimax/minimax-m3",name:"MiniMax M3",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:1e6,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"mistral/codestral",name:"Mistral Codestral",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4000,cost:{input:0.3,output:0.9,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/devstral-2",name:"Devstral 2",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:256000,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/devstral-small",name:"Devstral Small 1.1",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:64000,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/devstral-small-2",name:"Devstral Small 2",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:256000,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/ministral-3b",name:"Ministral 3B",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4000,cost:{input:0.1,output:0.1,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/ministral-8b",name:"Ministral 8B",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4000,cost:{input:0.15,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/mistral-medium",name:"Mistral Medium 3.1",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:64000,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/mistral-medium-3.5",name:"Mistral Medium Latest",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:256000,cost:{input:1.5,output:7.5,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/mistral-nemo",name:"Mistral Nemo 12B",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.02,output:0.04,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/mistral-small",name:"Mistral Small",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:32000,maxTokens:4000,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/pixtral-12b",name:"Pixtral 12B 2409",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4000,cost:{input:0.15,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/pixtral-large",name:"Pixtral Large",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4000,cost:{input:2,output:6,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2",name:"Kimi K2 Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.57,output:2.3,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2-thinking",name:"Kimi K2 Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:262114,maxTokens:262114,cost:{input:0.6,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2.5",name:"Kimi K2.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262114,maxTokens:262114,cost:{input:0.6,output:3,cacheRead:0.1,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2.6",name:"Kimi K2.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262000,maxTokens:262000,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2.7-code",name:"Kimi K2.7 Code",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:32768,cost:{input:0.95,output:4,cacheRead:0.19,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-super-120b-a12b",name:"NVIDIA Nemotron 3 Super 120B A12B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:32000,cost:{input:0.15,output:0.65,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-ultra-550b-a55b",name:"Nemotron 3 Ultra",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:65000,cost:{input:0.6,output:2.4,cacheRead:0.12,cacheWrite:0}}},{modelId:"nvidia/nemotron-nano-12b-v2-vl",name:"Nvidia Nemotron Nano 12B V2 VL",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:131072,maxTokens:131072,cost:{input:0.2,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-nano-9b-v2",name:"Nvidia Nemotron Nano 9B V2",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.06,output:0.23,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-4-turbo",name:"GPT-4 Turbo",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:10,output:30,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-4.1",name:"GPT-4.1",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"openai/gpt-4.1-mini",name:"GPT-4.1 mini",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:0.4,output:1.6,cacheRead:0.1,cacheWrite:0}}},{modelId:"openai/gpt-4.1-nano",name:"GPT-4.1 nano",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:0.1,output:0.4,cacheRead:0.025,cacheWrite:0}}},{modelId:"openai/gpt-4o",name:"GPT-4o",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"openai/gpt-4o-mini",name:"GPT-4o mini",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0.075,cacheWrite:0}}},{modelId:"openai/gpt-5",name:"GPT-5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5-chat",name:"GPT 5 Chat",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5-codex",name:"GPT-5-Codex",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5-mini",name:"GPT-5 mini",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"openai/gpt-5-nano",name:"GPT-5 nano",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.05,output:0.4,cacheRead:0.005,cacheWrite:0}}},{modelId:"openai/gpt-5-pro",name:"GPT-5 pro",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:272000,cost:{input:15,output:120,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-5.1-codex",name:"GPT-5.1-Codex",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5.1-codex-max",name:"GPT 5.1 Codex Max",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5.1-codex-mini",name:"GPT 5.1 Codex Mini",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"openai/gpt-5.1-instant",name:"GPT-5.1 Instant",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5.1-thinking",name:"GPT 5.1 Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5.2",name:"GPT 5.2",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.2-chat",name:"GPT 5.2 Chat",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.2-codex",name:"GPT 5.2 Codex",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.2-pro",name:"GPT 5.2 ",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:21,output:168,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-5.3-chat",name:"GPT-5.3 Chat",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.3-codex",name:"GPT 5.3 Codex",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.4",name:"GPT 5.4",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:2.5,output:15,cacheRead:0.25,cacheWrite:0}}},{modelId:"openai/gpt-5.4-mini",name:"GPT 5.4 Mini",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.75,output:4.5,cacheRead:0.075,cacheWrite:0}}},{modelId:"openai/gpt-5.4-nano",name:"GPT 5.4 Nano",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.2,output:1.25,cacheRead:0.02,cacheWrite:0}}},{modelId:"openai/gpt-5.4-pro",name:"GPT 5.4 Pro",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-5.5",name:"GPT 5.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"openai/gpt-5.5-pro",name:"GPT 5.5 Pro",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:30,output:180,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-120b",name:"GPT OSS 120B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131000,cost:{input:0.35,output:0.75,cacheRead:0.25,cacheWrite:0}}},{modelId:"openai/gpt-oss-20b",name:"GPT OSS 20B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:8192,cost:{input:0.05,output:0.2,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-safeguard-20b",name:"GPT OSS Safeguard 20B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:65536,cost:{input:0.075,output:0.3,cacheRead:0.037,cacheWrite:0}}},{modelId:"openai/o1",name:"o1",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0}}},{modelId:"openai/o3",name:"o3",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"openai/o3-deep-research",name:"o3-deep-research",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0}}},{modelId:"openai/o3-mini",name:"o3-mini",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.55,cacheWrite:0}}},{modelId:"openai/o3-pro",name:"o3 Pro",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:20,output:80,cacheRead:0,cacheWrite:0}}},{modelId:"openai/o4-mini",name:"o4-mini",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.275,cacheWrite:0}}},{modelId:"perplexity/sonar",name:"Sonar",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:127000,maxTokens:8000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"perplexity/sonar-pro",name:"Sonar Pro",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"stepfun/step-3.5-flash",name:"StepFun 3.5 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:262114,maxTokens:262114,cost:{input:0.09,output:0.3,cacheRead:0,cacheWrite:0.02}}},{modelId:"stepfun/step-3.7-flash",name:"Step 3.7 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:0.2,output:1.15,cacheRead:0.04,cacheWrite:0}}},{modelId:"xai/grok-4.1-fast-non-reasoning",name:"Grok 4.1 Fast Non-Reasoning",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:1e6,maxTokens:1e6,cost:{input:0.2,output:0.5,cacheRead:0.05,cacheWrite:0}}},{modelId:"xai/grok-4.1-fast-reasoning",name:"Grok 4.1 Fast Reasoning",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:1e6,cost:{input:0.2,output:0.5,cacheRead:0.05,cacheWrite:0}}},{modelId:"xai/grok-4.20-multi-agent",name:"Grok 4.20 Multi-Agent",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:2000000,maxTokens:2000000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"xai/grok-4.20-multi-agent-beta",name:"Grok 4.20 Multi Agent Beta",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:2000000,maxTokens:2000000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"xai/grok-4.20-non-reasoning",name:"Grok 4.20 Non-Reasoning",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:2000000,maxTokens:2000000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"xai/grok-4.20-non-reasoning-beta",name:"Grok 4.20 Beta Non-Reasoning",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:2000000,maxTokens:2000000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"xai/grok-4.20-reasoning",name:"Grok 4.20 Reasoning",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:2000000,maxTokens:2000000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"xai/grok-4.20-reasoning-beta",name:"Grok 4.20 Beta Reasoning",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:2000000,maxTokens:2000000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"xai/grok-4.3",name:"Grok 4.3",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:1e6,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"xai/grok-build-0.1",name:"Grok Build 0.1",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:1,output:2,cacheRead:0.2,cacheWrite:0}}},{modelId:"xiaomi/mimo-v2-flash",name:"MiMo V2 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:32000,cost:{input:0.1,output:0.3,cacheRead:0.01,cacheWrite:0}}},{modelId:"xiaomi/mimo-v2-pro",name:"MiMo V2 Pro",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:128000,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"xiaomi/mimo-v2.5",name:"MiMo M2.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:131100,cost:{input:0.14,output:0.28,cacheRead:0.0028,cacheWrite:0}}},{modelId:"xiaomi/mimo-v2.5-pro",name:"MiMo V2.5 Pro",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:131000,cost:{input:0.435,output:0.87,cacheRead:0.0036,cacheWrite:0}}},{modelId:"zai/glm-4.5",name:"GLM-4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:96000,cost:{input:0.6,output:2.2,cacheRead:0.11,cacheWrite:0}}},{modelId:"zai/glm-4.5-air",name:"GLM 4.5 Air",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:96000,cost:{input:0.2,output:1.1,cacheRead:0.03,cacheWrite:0}}},{modelId:"zai/glm-4.5v",name:"GLM 4.5V",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:66000,maxTokens:16000,cost:{input:0.6,output:1.8,cacheRead:0.11,cacheWrite:0}}},{modelId:"zai/glm-4.6",name:"GLM 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:96000,cost:{input:0.6,output:2.2,cacheRead:0.11,cacheWrite:0}}},{modelId:"zai/glm-4.6v",name:"GLM-4.6V",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:24000,cost:{input:0.3,output:0.9,cacheRead:0.05,cacheWrite:0}}},{modelId:"zai/glm-4.6v-flash",name:"GLM-4.6V-Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:24000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"zai/glm-4.7",name:"GLM 4.7",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131000,maxTokens:40000,cost:{input:2.25,output:2.75,cacheRead:2.25,cacheWrite:0}}},{modelId:"zai/glm-4.7-flash",name:"GLM 4.7 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:131000,cost:{input:0.07,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"zai/glm-4.7-flashx",name:"GLM 4.7 FlashX",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:128000,cost:{input:0.06,output:0.4,cacheRead:0.01,cacheWrite:0}}},{modelId:"zai/glm-5",name:"GLM 5",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:202800,maxTokens:131100,cost:{input:1,output:3.2,cacheRead:0.2,cacheWrite:0}}},{modelId:"zai/glm-5-turbo",name:"GLM 5 Turbo",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:202800,maxTokens:131100,cost:{input:1.2,output:4,cacheRead:0.24,cacheWrite:0}}},{modelId:"zai/glm-5.1",name:"GLM 5.1",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:202800,maxTokens:64000,cost:{input:1.4,output:4.4,cacheRead:0.26,cacheWrite:0}}},{modelId:"zai/glm-5v-turbo",name:"GLM 5V Turbo",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:128000,cost:{input:1.2,output:4,cacheRead:0.24,cacheWrite:0}}}]},xai:{name:"xai",config:{api:"openai-completions",baseUrl:"https://api.x.ai/v1",apiKey:"XAI_API_KEY"},models:[{modelId:"grok-3",name:"Grok 3",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:8192,cost:{input:3,output:15,cacheRead:0.75,cacheWrite:0}}},{modelId:"grok-3-fast",name:"Grok 3 Fast",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:8192,cost:{input:5,output:25,cacheRead:1.25,cacheWrite:0}}},{modelId:"grok-4.20-0309-non-reasoning",name:"Grok 4.20 (Non-Reasoning)",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:1e6,maxTokens:30000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"grok-4.20-0309-reasoning",name:"Grok 4.20 (Reasoning)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:30000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"grok-4.3",name:"Grok 4.3",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:30000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"grok-build-0.1",name:"Grok Build 0.1",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:1,output:2,cacheRead:0.2,cacheWrite:0}}},{modelId:"grok-code-fast-1",name:"Grok Code Fast 1",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:32768,maxTokens:8192,cost:{input:0.2,output:1.5,cacheRead:0.02,cacheWrite:0}}}]},xiaomi:{name:"xiaomi",config:{api:"openai-completions",baseUrl:"https://api.xiaomimimo.com/v1",apiKey:"XIAOMI_API_KEY"},models:[{modelId:"mimo-v2-flash",name:"MiMo-V2-Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:0.1,output:0.3,cacheRead:0.01,cacheWrite:0}}},{modelId:"mimo-v2-omni",name:"MiMo-V2-Omni",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0.08,cacheWrite:0}}},{modelId:"mimo-v2-pro",name:"MiMo-V2-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"mimo-v2.5",name:"MiMo-V2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0.08,cacheWrite:0}}},{modelId:"mimo-v2.5-pro",name:"MiMo-V2.5-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"mimo-v2.5-pro-ultraspeed",name:"MiMo-V2.5-Pro-UltraSpeed",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1.305,output:2.61,cacheRead:0.0108,cacheWrite:0}}}]},"xiaomi-token-plan-ams":{name:"xiaomi-token-plan-ams",config:{api:"openai-completions",baseUrl:"https://token-plan-ams.xiaomimimo.com/v1",apiKey:"XIAOMI_TOKEN_PLAN_AMS_API_KEY"},models:[{modelId:"mimo-v2-omni",name:"MiMo-V2-Omni",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0.08,cacheWrite:0}}},{modelId:"mimo-v2-pro",name:"MiMo-V2-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"mimo-v2.5",name:"MiMo-V2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0.08,cacheWrite:0}}},{modelId:"mimo-v2.5-pro",name:"MiMo-V2.5-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"mimo-v2.5-pro-ultraspeed",name:"MiMo-V2.5-Pro-UltraSpeed",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1.305,output:2.61,cacheRead:0.0108,cacheWrite:0}}}]},"xiaomi-token-plan-cn":{name:"xiaomi-token-plan-cn",config:{api:"openai-completions",baseUrl:"https://token-plan-cn.xiaomimimo.com/v1",apiKey:"XIAOMI_TOKEN_PLAN_CN_API_KEY"},models:[{modelId:"mimo-v2-omni",name:"MiMo-V2-Omni",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0.08,cacheWrite:0}}},{modelId:"mimo-v2-pro",name:"MiMo-V2-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"mimo-v2.5",name:"MiMo-V2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0.08,cacheWrite:0}}},{modelId:"mimo-v2.5-pro",name:"MiMo-V2.5-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"mimo-v2.5-pro-ultraspeed",name:"MiMo-V2.5-Pro-UltraSpeed",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1.305,output:2.61,cacheRead:0.0108,cacheWrite:0}}}]},"xiaomi-token-plan-sgp":{name:"xiaomi-token-plan-sgp",config:{api:"openai-completions",baseUrl:"https://token-plan-sgp.xiaomimimo.com/v1",apiKey:"XIAOMI_TOKEN_PLAN_SGP_API_KEY"},models:[{modelId:"mimo-v2-omni",name:"MiMo-V2-Omni",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0.08,cacheWrite:0}}},{modelId:"mimo-v2-pro",name:"MiMo-V2-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"mimo-v2.5",name:"MiMo-V2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0.08,cacheWrite:0}}},{modelId:"mimo-v2.5-pro",name:"MiMo-V2.5-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"mimo-v2.5-pro-ultraspeed",name:"MiMo-V2.5-Pro-UltraSpeed",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1.305,output:2.61,cacheRead:0.0108,cacheWrite:0}}}]},zai:{name:"zai",config:{api:"openai-completions",baseUrl:"https://api.z.ai/api/coding/paas/v4",apiKey:"ZAI_API_KEY"},models:[{modelId:"glm-4.5-air",name:"GLM-4.5-Air",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:98304,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-4.7",name:"GLM-4.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-5-turbo",name:"GLM-5-Turbo",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-5.1",name:"GLM-5.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-5.2",name:"GLM-5.2",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-5v-turbo",name:"GLM-5V-Turbo",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}}]},"zai-coding-cn":{name:"zai-coding-cn",config:{api:"openai-completions",baseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiKey:""},models:[{modelId:"glm-4.5-air",name:"GLM-4.5-Air",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:98304,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-4.7",name:"GLM-4.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-5-turbo",name:"GLM-5-Turbo",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-5.1",name:"GLM-5.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-5.2",name:"GLM-5.2",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-5v-turbo",name:"GLM-5V-Turbo",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}}]}};class Qr{prismaClient;constructor(B=VB){this.prismaClient=B}async initBuiltinProviders(B){let Q=await this.prismaClient.team.findUnique({where:{id:B},include:{_count:{select:{providers:!0}}}});if(Q&&Q._count.providers===0){let F=Object.entries(lwQ).reverse();for(let[U,I]of F){let G=I;await this.prismaClient.provider.create({data:{teamId:Q.id,name:U,config:G.config,isBuiltin:!0,models:{create:G.models.map((Z)=>({modelId:Z.modelId,name:Z.name,config:Z.config}))}}})}}}async listByTeam(B){return(await this.prismaClient.provider.findMany({where:{teamId:B},include:{_count:{select:{models:!0}}},orderBy:{id:"desc"}})).map((F)=>({...F,modelsCount:F._count.models,_count:void 0}))}async getById(B){return this.prismaClient.provider.findUnique({where:{id:B}})}async listModelsByProvider(B,Q){return this.prismaClient.model.findMany({where:{providerId:Q,provider:{teamId:B}},orderBy:{id:"asc"}})}async create(B,Q,F,U){return this.prismaClient.provider.create({data:{teamId:B,name:Q,config:F,models:{create:U.map((I)=>({modelId:I.modelId,name:I.name,config:I.config}))}},include:{models:!0}})}async update(B,Q,F,U){return this.prismaClient.$transaction(async(I)=>{return await I.model.deleteMany({where:{providerId:Q}}),I.provider.update({where:{id:Q,teamId:B},data:{config:F,models:{create:U.map((G)=>({modelId:G.modelId,name:G.name,config:G.config}))}},include:{models:!0}})})}async delete(B,Q){if(!await this.prismaClient.provider.findUnique({where:{id:Q,teamId:B}}))throw Error("Provider not found");return this.prismaClient.provider.delete({where:{id:Q,teamId:B}})}}var uwQ=new Qr;class qwQ{async upsertMetadata(B,Q,F,U){return await VB.userMetadata.upsert({where:{userIdTeamIdKey:{userId:B,teamId:Q,key:F}},update:{value:U},create:{userId:B,teamId:Q,key:F,value:U}})}async listMetadata(B,Q){return(await VB.userMetadata.findMany({where:{userId:B,teamId:Q},orderBy:{key:"asc"}})).map((U)=>({key:U.key,value:U.value}))}async getMetadata(B,Q,F){let U=await VB.userMetadata.findUnique({where:{userIdTeamIdKey:{userId:B,teamId:Q,key:F}}});if(!U)return null;return{key:U.key,value:U.value}}}var jwQ=new qwQ;var u6F=/<@([^>]+)>/g;class nwQ{async create(B){this.createAsync(B).catch((Q)=>{console.error("Failed to create notification asynchronously:",Q)})}async createAsync(B){let Q=B.projectId;if(!Q&&B.assetId){let U=await VB.asset.findUnique({where:{id:B.assetId},include:{project:!0}});if(U?.projectId)Q=U.projectId}if(Q){let U=await VB.project.findUnique({where:{id:Q}});if(U&&!U.enableNotification)return}let F=async(U,I)=>{try{await VB.notification.create({data:{type:U,teamId:B.teamId,projectId:Q,creatorId:B.creatorId,assetId:B.assetId,taskId:B.taskId,userId:I}})}catch(G){console.error("Failed to save notification",{type:U,err:G})}};if(await F(B.type,B.userId),(B.type===eV.comment_created||B.type===eV.reply_created)&&B.commentMessage){let U=[...B.commentMessage.matchAll(u6F)],I=new Set;for(let G of U)if(G.length>1){let Z=G[1];if(I.has(Z))continue;if(I.add(Z),B.creatorId===Z)continue;await F(eV.mention,Z)}}}async getListWhere(B,Q,F,U){let I=[];if(F.scope==="project")I=(await VB.projectMember.findMany({where:{teamMemberId:F.id},include:{project:!0}})).filter((b)=>b.project).map((b)=>b.projectId);let G=await jwQ.getMetadata(Q,B,"notification_settings"),Z=G?G.value:{comments:!0,replies:!0,mentions:!0,yourUploads:!1,otherUploads:!0,statusUpdates:!0},W=[];if(Z.comments)W.push({type:eV.comment_created,userId:null});if(Z.replies)W.push({type:eV.reply_created,userId:Q}),W.push({type:eV.reply_created,userId:null});if(Z.mentions)W.push({type:eV.mention,userId:Q});if(Z.yourUploads&&Z.otherUploads)W.push({type:eV.successful_file_uploaded});else if(Z.yourUploads)W.push({type:eV.successful_file_uploaded,creatorId:Q});else if(Z.otherUploads)W.push({type:eV.successful_file_uploaded,creatorId:{not:Q}});if(Z.statusUpdates)W.push({type:eV.metadata_field_updated_status});W.push({type:eV.new_user_join_team}),W.push({type:eV.new_user_join_project});let g={teamId:B,OR:W,AND:[{OR:[...Z.yourUploads?[{type:eV.successful_file_uploaded,creatorId:Q}]:[],{creatorId:null},{creatorId:{not:Q}}]}]};if(F.scope==="project"){let V=Array.isArray(g.AND)?g.AND:g.AND?[g.AND]:[];g.AND=[...V,{OR:[{type:eV.mention},{projectId:{in:I}}]}]}if(U&&F.lastReadNotification){let V=Array.isArray(g.AND)?g.AND:g.AND?[g.AND]:[];g.AND=[...V,{id:{gt:F.lastReadNotification.id}}]}return g}async getUnreadCount(B,Q){let F=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B,userId:Q}},include:{lastReadNotification:!0}});if(!F)return 0;let U=await this.getListWhere(B,Q,F,!0);return VB.notification.count({where:U})}async list(B,Q,F){let U=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B,userId:Q}},include:{lastReadNotification:!0}});if(!U)throw Error("failed to get team member");let I=await this.getListWhere(B,Q,U,!!F.unreadOnly);return $V(async(G,Z)=>{let W=await VB.notification.findMany({where:I,orderBy:{id:"desc"},skip:G,take:Z,include:{creator:!0,team:!0,project:!0,asset:!0,user:!0}});return Promise.all(W.map(async(g)=>{return this.toNotificationInfo(g,U.lastReadNotification)}))},null,{after:F.after,first:F.pageSize})}async markRead(B,Q,F){let U=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B,userId:Q}},include:{lastReadNotification:!0}});if(!U)throw Error("failed to get team member");if(!await VB.notification.findUnique({where:{id:F}}))throw Error("notification not found");let G=!0;if(U.lastReadNotification){if(F<=U.lastReadNotification.id)G=!1}if(G)await VB.teamMember.update({where:{id:U.id},data:{lastReadNotificationId:F}})}async toNotificationInfo(B,Q){let F={id:B.id,type:B.type||void 0,createdAt:B.createdAt.toISOString(),isRead:Q!==null&&B.id<=Q.id};if(B.creator)F.creator={id:B.creator.id,name:B.creator.name};if(B.team)F.team={id:B.team.id,name:B.team.name};if(B.project)F.project={id:B.project.id,name:B.project.name};if(B.user)F.user={id:B.user.id,name:B.user.name};if(B.asset){let U=B.asset,I="",G="",Z=0,W=0,g=U.media;if(g){let V=process.env.S3_BUCKET||"shumai";try{if(g.sprite){if(I=await yF.presign(V,g.sprite.key,"GET"),g.poster)G=await yF.presign(V,g.poster.key||"","GET");if(g.metadata)Z=g.metadata.originalWidth,W=g.metadata.originalHeight}else if(g.thumbnail)I=await yF.presign(V,g.thumbnail.key||"","GET"),G=I}catch(b){console.error("Failed to generate presigned url for notification asset preview:",b)}}F.asset={id:U.id,name:U.name,mediaType:U.mediaType||void 0,preview:I||void 0,thumbnailUrl:G||void 0,originalWidth:Z||void 0,originalHeight:W||void 0}}return F}}var iwQ=new nwQ;var YI=class extends Error{res;status;constructor(B=500,Q){super(Q?.message,{cause:Q?.cause});this.res=Q?.res,this.status=B}getResponse(){if(this.res)return new Response(this.res.body,{status:this.status,headers:this.res.headers});return new Response(this.message,{status:this.status})}};class pwQ{async ensureDefaultTeam(){let B=await VB.team.findFirst({where:{name:"Default Team"}});if(!B)B=await VB.team.create({data:{name:"Default Team",settings:{transcode:{videoStrategy:"best_match"}},sandbox:{create:{}}}}),await uwQ.initBuiltinProviders(B.id);return B}async createTeam(B,Q){return await VB.$transaction(async(F)=>{let U=await F.team.create({data:{name:Q.name,settings:{},sandbox:{create:{}}}}),I=await F.asset.create({data:{name:"root",type:"root",status:"processed"}}),G=await F.team.update({where:{id:U.id},data:{rootFolderId:I.id},include:{rootFolder:!0}});return await F.teamMember.create({data:{teamId:U.id,userId:B.id,role:"owner",scope:"team"}}),await new Qr(F).initBuiltinProviders(U.id),this.toTeamInfo(G)})}async getUserTeams(B){let Q={members:{some:{userId:B.userId}}};return await $V(async(F,U)=>{return(await VB.team.findMany({where:Q,skip:F,take:U,orderBy:{id:"desc"},include:{rootFolder:!0}})).map(this.toTeamInfo)},null,B.pagination)}async joinTeam(B){if(!await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B.teamId,userId:B.userId}}}))await VB.teamMember.create({data:{teamId:B.teamId,userId:B.userId,role:"reviewer",scope:"team"}})}async getMe(B){let Q=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B.teamId,userId:B.user.id}},include:{user:!0}});if(!Q)throw new YI(403,{message:"user is not a team member"});let F=await iwQ.getUnreadCount(B.teamId,B.user.id);return{id:Q.user.id,name:Q.user.name,email:Q.user.email||void 0,role:Q.role,image:await MX(Q.user.image),unreadNotificationCount:F}}async updateMe(B,Q){let F={};if(Q.name!==void 0)F.name=Q.name;if(Q.imageKey!==void 0)F.image=Q.imageKey;await VB.user.update({where:{id:B},data:F})}async getTeamMembers(B){let Q=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B.teamId,userId:B.userId}}});if(!Q)throw new YI(403,{message:"Requester is not a team member"});let F=await VB.teamMember.findMany({where:{teamId:B.teamId,...B.includeAgents?{user:{OR:[{type:"human"},{type:"agent",agent:{type:"chat",enabled:!0}}]}}:{user:{type:{not:"agent"}}}},include:{user:!0,projectMembers:!0}}),U=F;if(Q.scope==="project"){let I=await VB.projectMember.findMany({where:{teamMemberId:Q.id},select:{projectId:!0}}).then((G)=>G.map((Z)=>Z.projectId));U=F.filter((G)=>{if(G.scope==="team")return!0;return G.projectMembers.some((Z)=>I.includes(Z.projectId))})}return Promise.all(U.map(async(I)=>({id:I.user.id,name:I.user.name,email:void 0,role:I.role,type:I.user.type||void 0,image:await MX(I.user.image),scope:I.scope})))}async updateMemberRole(B){let Q=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B.teamId,userId:B.userId}}});if(!Q)throw new YI(404,{message:"Member not found"});if(Q.role==="owner")throw new YI(403,{message:"Cannot change the role of an owner"});await VB.teamMember.update({where:{id:Q.id},data:{role:B.role}})}async removeMember(B,Q){let F=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B,userId:Q}}});if(!F)throw new YI(404,{message:"Member not found"});if(F.role==="owner")throw new YI(403,{message:"Cannot remove an owner"});await VB.teamMember.delete({where:{id:F.id}})}async getSettings(B){let Q=await VB.team.findUnique({where:{id:B}});if(!Q)throw new YI(404,{message:"team not found"});let F=Q.settings||{},U=await VB.agent.findFirst({where:{teamId:B,type:"embedding",enabled:!0}});return F.semanticSearchEnabled=!!U,F}async updateSettings(B,Q,F){let U=await VB.team.findUnique({where:{id:B}});if(!U)throw new YI(404,{message:"team not found"});let I=U.settings||{};return I[Q]=F,(await VB.team.update({where:{id:B},data:{settings:I}})).settings||{}}async getSandboxSettings(B){let Q=await VB.sandbox.findUnique({where:{teamId:B}});return{allowedDomains:Q?.allowedDomains||[],pendingDomains:Q?.pendingDomains||[]}}async updateSandboxSettings(B,Q){let F=await VB.sandbox.upsert({where:{teamId:B},create:{teamId:B,allowedDomains:Q.allowedDomains,pendingDomains:Q.pendingDomains},update:{allowedDomains:Q.allowedDomains,pendingDomains:Q.pendingDomains}});return{allowedDomains:F.allowedDomains,pendingDomains:F.pendingDomains}}async getSignupInfo(){let B=await VB.user.count();return{initialized:B>0,userCount:B,demoMode:process.env.SHUMAI_DEMO_MODE==="1"}}toTeamInfo(B){return{id:B.id,name:B.name,rootFolder:B.rootFolder?.id||B.rootFolderId||void 0,updatedAt:B.updatedAt}}}var Fr=new pwQ;class awQ{async createTeamInvite(B){let Q=NG(),F=await VB.invite.create({data:{code:Q,teamId:B.teamId,inviterId:B.inviterId,role:B.role}});return this.getInvite(F.code)}async createProjectInvite(B){let Q=await VB.project.findUniqueOrThrow({where:{id:B.projectId},include:{team:!0}}),F=NG(),U=await VB.invite.create({data:{code:F,teamId:Q.teamId,projectId:Q.id,inviterId:B.inviterId,role:B.role}});return this.getInvite(U.code)}async getInvite(B){return await VB.invite.findUniqueOrThrow({where:{code:B},include:{team:!0,project:!0,inviter:!0}})}async validateInvite(B){let Q=await VB.invite.findUnique({where:{code:B}});if(!Q)return!1;if(Q.used)return!1;return!0}async consumeInvite(B,Q){await VB.$transaction(async(F)=>{let U=await F.invite.findUniqueOrThrow({where:{code:B},include:{team:!0,project:!0}});if(U.used)throw Error("invite code already used");let I=await F.user.findUniqueOrThrow({where:{id:Q}}),G=await F.teamMember.findUnique({where:{teamIdUserId:{teamId:U.teamId,userId:I.id}}});if(!U.projectId)if(G){if(G.scope==="project")await F.teamMember.update({where:{id:G.id},data:{scope:"team",role:U.role}})}else await F.teamMember.create({data:{teamId:U.teamId,userId:I.id,role:U.role,scope:"team"}});else{if(!G)G=await F.teamMember.create({data:{teamId:U.teamId,userId:I.id,role:"reviewer",scope:"project"}});if(!await F.projectMember.findUnique({where:{projectIdTeamMemberId:{projectId:U.projectId,teamMemberId:G.id}}}))await F.projectMember.create({data:{projectId:U.projectId,teamMemberId:G.id,role:U.role}})}await F.invite.update({where:{id:U.id},data:{used:!0}})})}}var Ur=new awQ;var FXG=ULB({database:fwQ(VB,{provider:"postgresql"}),emailAndPassword:{enabled:!0,minPasswordLength:3},secret:process.env.BETTER_AUTH_SECRET,baseURL:process.env.BETTER_AUTH_URL||`http://localhost:${process.env.SHUMAI_SERVER_PORT||"3000"}`,basePath:"/api/auth",trustedOrigins:[`http://localhost:${process.env.SHUMAI_SERVER_PORT||"3000"}`,`http://127.0.0.1:${process.env.SHUMAI_SERVER_PORT||"3000"}`],advanced:{disableCSRFCheck:!0},hooks:{before:I2(async(B)=>{if(B.path==="/sign-up/email"){let F=B.body?.inviteCode;if((await Fr.getSignupInfo()).initialized){if(!F)return console.log("[Better Auth Hook] Public signup is disabled"),B.json({error:"Public signup is disabled"},{status:403});if(!await Ur.validateInvite(F))return B.json({error:"Invalid or expired invite code"},{status:400})}}}),after:I2(async(B)=>{if(B.path==="/sign-up/email"){let Q=B.context.returned;if(Q&&Q.user&&Q.user.id){let F=Q.user,I=B.body?.inviteCode;try{let G=await Fr.getSignupInfo(),Z=await Fr.ensureDefaultTeam();if(G.userCount===1)await VB.teamMember.create({data:{teamId:Z.id,userId:F.id,role:"owner",scope:"team"}});else if(!I)await VB.teamMember.create({data:{teamId:Z.id,userId:F.id,role:"editor",scope:"team"}});if(I)await Ur.consumeInvite(I,F.id)}catch(G){console.error(`[Better Auth Hook] Error in after hook: ${G}`)}}}})}});class owQ{async hasPermission(B){if(!B.user)throw new YI(401,{message:"User is required"});let{teamId:Q,projectId:F}=await this.resolveContext(B.type,B.id),U=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:Q,userId:B.user.id}}});if(!U)throw new YI(403,{message:"User is not a member of the team"});if(F){let I=await VB.projectMember.findUnique({where:{projectIdTeamMemberId:{projectId:F,teamMemberId:U.id}}});if(I)return this.checkRole(I.role,B.permission)}if(U.scope==="team")return this.checkRole(U.role,B.permission);if(!F){if(B.permission==="Read")return}throw new YI(403,{message:"User has only project scope"})}async resolveContext(B,Q){switch(B){case"team":return{teamId:Q};case"project":{let F=await VB.project.findUnique({where:{id:Q},select:{teamId:!0}});if(!F)throw new YI(404,{message:"Project not found"});return{teamId:F.teamId,projectId:Q}}case"asset":{let F=await VB.asset.findUnique({where:{id:Q},select:{parentId:!0,teamRootFolder:{select:{id:!0}},project:{select:{id:!0,teamId:!0}}}});if(!F)throw new YI(404,{message:"Asset not found"});if(F.project)return{teamId:F.project.teamId,projectId:F.project.id};if(F.teamRootFolder)return{teamId:F.teamRootFolder.id};if(F.parentId)return this.resolveContext("asset",F.parentId);throw new YI(403,{message:"Could not resolve context for asset"})}case"collection":{let F=await VB.collection.findUnique({where:{id:Q},include:{project:!0}});if(!F)throw new YI(404,{message:"Collection not found"});return{teamId:F.project.teamId,projectId:F.projectId}}case"agent":{let F=await VB.agent.findUnique({where:{id:Q},select:{teamId:!0}});if(!F)throw new YI(404,{message:"Agent not found"});return{teamId:F.teamId}}case"agentSession":{let F=await VB.agentSession.findUnique({where:{id:Q},include:{agent:!0}});if(!F)throw new YI(404,{message:"Agent session not found"});return{teamId:F.agent.teamId}}case"share":{let F=await VB.shareLink.findUnique({where:{id:Q},include:{project:!0}});if(!F)throw new YI(404,{message:"Share not found"});return{teamId:F.project.teamId,projectId:F.projectId}}case"metadataField":{let F=await VB.metadataField.findUnique({where:{key:Q},select:{teamId:!0,projectId:!0}});if(!F)throw new YI(404,{message:"Metadata field not found"});if(F.projectId)return{teamId:(await VB.project.findUnique({where:{id:F.projectId},select:{teamId:!0}})).teamId,projectId:F.projectId};if(!F.teamId)throw new YI(403,{message:"Metadata field has no context"});return{teamId:F.teamId}}case"skill":{let F=await VB.skill.findUnique({where:{id:Q},select:{teamId:!0}});if(!F)throw new YI(404,{message:"Skill not found"});return{teamId:F.teamId}}case"provider":{let F=await VB.provider.findUnique({where:{id:Q},select:{teamId:!0}});if(!F)throw new YI(404,{message:"Provider not found"});return{teamId:F.teamId}}case"invite":{let F=await VB.invite.findUnique({where:{id:Q},select:{teamId:!0,projectId:!0}});if(!F)throw new YI(404,{message:"Invite not found"});return{teamId:F.teamId,projectId:F.projectId??void 0}}case"comment":{let F=await VB.assetComment.findUnique({where:{id:Q},include:{asset:{include:{project:!0}}}});if(!F)throw new YI(404,{message:"Comment not found"});if(!F.asset.project)throw new YI(403,{message:"Comment asset has no project"});return{teamId:F.asset.project.teamId,projectId:F.asset.projectId}}default:throw new YI(403,{message:`Unsupported resource type: ${B}`})}}checkRole(B,Q){switch(Q){case"Read":return;case"Edit":if(B==="owner"||B==="editor")return;break;case"Admin":if(B==="owner")return;break}throw new YI(403,{message:"Permission denied"})}}var rd=new owQ;class rwQ{async createCollection(B,Q,F){return await VB.collection.create({data:{name:Q.name,filter:Q.filter,projectId:B,creatorId:F},include:{creator:!0}})}async updateCollection(B,Q){return await VB.collection.update({where:{id:B},data:{...Q.name&&{name:Q.name},...Q.filter&&{filter:Q.filter}},include:{creator:!0}})}async deleteCollection(B){return await VB.collection.delete({where:{id:B}})}async getCollection(B){return await VB.collection.findUnique({where:{id:B},include:{creator:!0}})}async listCollections(B,Q){return await $V((F,U)=>VB.collection.findMany({where:{projectId:B},include:{creator:!0},orderBy:{id:"desc"},skip:F,take:U}),()=>VB.collection.count({where:{projectId:B}}),Q)}}var VXG=new rwQ;var swQ=[{key:"file_size",scope:"SYSTEM",readOnly:!0,config:{name:"File Size",type:"number",number:{scale:0}}},{key:"resolution_width",scope:"SYSTEM",readOnly:!0,config:{name:"Resolution Width",type:"number",number:{scale:0}}},{key:"resolution_height",scope:"SYSTEM",readOnly:!0,config:{name:"Resolution Height",type:"number",number:{scale:0}}},{key:"name",scope:"SYSTEM",readOnly:!0,config:{name:"Name",type:"text",text:{}}},{key:"rating",scope:"SYSTEM",readOnly:!1,config:{name:"Rating",type:"rating",rating:{maxValue:5}}},{key:"duration",scope:"SYSTEM",readOnly:!0,config:{name:"Duration",type:"number",number:{scale:0}}},{key:"bitRate",scope:"SYSTEM",readOnly:!0,config:{name:"Bit Rate",type:"number",number:{scale:1}}},{key:"frame_rate",scope:"SYSTEM",readOnly:!0,config:{name:"Frame Rate",type:"number",number:{scale:3}}},{key:"keywords",scope:"SYSTEM",readOnly:!1,config:{name:"Keywords",type:"selectMulti",selectMulti:{options:[]}}},{key:"file_type",scope:"SYSTEM",readOnly:!0,config:{name:"File Type",type:"select",select:{options:[{id:"video",displayName:"Video",color:"system"},{id:"audio",displayName:"Audio",color:"system"},{id:"image",displayName:"Image",color:"system"},{id:"document",displayName:"Document",color:"system"},{id:"file",displayName:"File",color:"system"}]}}},{key:"audio_bit_depth",scope:"SYSTEM",readOnly:!0,config:{name:"Audio Bit Depth",type:"number",number:{scale:0}}},{key:"audio_channels",scope:"SYSTEM",readOnly:!0,config:{name:"Audio Channels",type:"number",number:{scale:0}}},{key:"audio_codec",scope:"SYSTEM",readOnly:!0,config:{name:"Audio Codec",type:"text",text:{}}},{key:"audio_sample_rate",scope:"SYSTEM",readOnly:!0,config:{name:"Audio Sample Rate",type:"number",number:{scale:0}}},{key:"video_codec",scope:"SYSTEM",readOnly:!0,config:{name:"Video Codec",type:"text",text:{}}},{key:"format",scope:"SYSTEM",readOnly:!0,config:{name:"Format",type:"text",text:{}}},{key:"status",scope:"SYSTEM",readOnly:!1,config:{name:"Status",type:"select",select:{options:[{id:"needs_review",displayName:"Needs Review",color:"red"},{id:"in_progress",displayName:"In Progress",color:"yellow"},{id:"approved",displayName:"Approved",color:"green"}]}}}];class twQ{client;constructor(B=VB){this.client=B}async syncSystemFields(){await this.client.$transaction(async(B)=>{for(let Q of swQ)await B.metadataField.upsert({where:{key:Q.key},update:{scope:Q.scope,readOnly:Q.readOnly,config:Q.config},create:{key:Q.key,scope:Q.scope,readOnly:Q.readOnly??!1,config:Q.config}})})}async createTeamField(B,Q){return await this.client.metadataField.create({data:{key:NG(),scope:"TEAM",teamId:B,config:Q.config,aiAutofill:Q.aiAutofill,description:Q.description}})}async listTeamFields(B){return await this.client.metadataField.findMany({where:{OR:[{scope:"SYSTEM"},{AND:[{scope:"TEAM"},{teamId:B}]}]}})}async getFieldByKey(B){return this.client.metadataField.findUnique({where:{key:B}})}async updateTeamField(B,Q,F){let U=await this.client.metadataField.findUnique({where:{key:Q}});if(!U)throw Error("Field not found");if(U.teamId!==B)throw Error("Field does not belong to this team");return await this.client.metadataField.update({where:{id:U.id},data:{config:F.config,aiAutofill:F.aiAutofill??U.aiAutofill,description:F.description??U.description}})}async deleteTeamField(B,Q){let F=await this.client.metadataField.findUnique({where:{key:Q}});if(!F)throw Error("Field not found");if(F.teamId!==B)throw Error("Field does not belong to this team");await this.client.metadataField.delete({where:{key:Q}})}async createProjectField(B,Q){let F=await this.client.project.findUnique({where:{id:B},select:{teamId:!0}});if(!F)throw Error("Project not found");return await this.client.metadataField.create({data:{key:NG(),scope:"PROJECT",projectId:B,teamId:F.teamId,config:Q.config,aiAutofill:Q.aiAutofill,description:Q.description}})}async listProjectFields(B,Q){let F=await this.client.project.findUnique({where:{id:Q},select:{teamId:!0}});if(!F)throw Error("Project not found");let U=await this.client.metadataField.findMany({where:{OR:[{scope:"SYSTEM"},{AND:[{scope:"TEAM"},{teamId:F.teamId}]},{AND:[{scope:"PROJECT"},{projectId:Q}]}]}}),I=B?await this.getProjectFieldsOrder(B,Q):[],G=new Map;I.forEach((g,V)=>{G.set(g.fieldId,V)});let Z=new Map;I.forEach((g)=>{Z.set(g.fieldId,g.visible)});let W=U.map((g)=>({field:g,visible:Z.has(g.key)?Z.get(g.key):B===null}));return W.sort((g,V)=>{let b=G.get(g.field.key),X=G.get(V.field.key);if(b!==void 0&&X!==void 0)return b-X;if(b!==void 0)return-1;if(X!==void 0)return 1;let C=g.field.config?.name||"",N=V.field.config?.name||"";return C.localeCompare(N)}),W}async getProjectFieldsOrder(B,Q){let F=this.getProjectFieldOrderKey(B,Q),U=await this.client.systemSettings.findUnique({where:{key:F}});if(!U||!U.value)return[];return U.value}async updateProjectFieldsOrder(B,Q,F){let U=this.getProjectFieldOrderKey(B,Q);await this.client.systemSettings.upsert({where:{key:U},create:{key:U,value:F},update:{value:F}})}getProjectFieldOrderKey(B,Q){return`project_field_order:${B}:${Q}`}async updateProjectField(B,Q,F){let U=await this.client.metadataField.findUnique({where:{key:Q}});if(!U)throw Error("Field not found");if(U.projectId!==B)throw Error("Field does not belong to this project");return await this.client.metadataField.update({where:{id:U.id},data:{config:F.config,aiAutofill:F.aiAutofill??U.aiAutofill,description:F.description??U.description}})}async deleteProjectField(B,Q){let F=await this.client.metadataField.findUnique({where:{key:Q}});if(!F)throw Error("Field not found");if(F.projectId!==B)throw Error("Field does not belong to this project");await this.client.metadataField.delete({where:{key:Q}})}async updateAssetMetadata(B,Q,F=!1){let U=await TX.resolveLatestVersionId(B);await this.client.$transaction(async(I)=>{for(let G of Q){let Z=await I.metadataField.findUnique({where:{key:G.key}});if(Z?.readOnly&&!F)throw Error(`Field ${Z.key} is read-only`);let W=G.value,g=null,V=null,b=null,X=null,C=null;if(typeof W==="string"){let N=new Date(W);if(!isNaN(N.getTime())&&W.includes("T")&&W.includes("-"))C=N;else g=W}else if(typeof W==="number")V=W;else if(typeof W==="boolean")b=W;else if(W instanceof Date)C=W;else if(Array.isArray(W))X=W;else if(W===null);else if(typeof W==="object")X=W;else g=String(W);await I.assetMetadataValue.upsert({where:{assetId_fieldKey:{assetId:U,fieldKey:G.key}},create:{assetId:U,fieldKey:G.key,stringValue:g,numberValue:V,booleanValue:b,jsonValue:X,dateValue:C},update:{stringValue:g,numberValue:V,booleanValue:b,jsonValue:X,dateValue:C}})}await I.asset.update({where:{id:U},data:{updatedAt:new Date}})})}}var Ir=new twQ;class ewQ{async createProject(B,Q){if(!await VB.team.findUnique({where:{id:Q.teamId}}))throw Error("Team not found");let U=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:Q.teamId,userId:B.id}}});if(!U)throw Error("creator is not a team member");let I=await VB.$transaction(async(G)=>{let Z=await G.project.create({data:{name:Q.name,teamId:Q.teamId,enableNotification:Q.enableNotification??!0,coverImageKey:Q.coverImageKey}}),W=await G.asset.create({data:{name:"root",type:"root",status:"processed",projectId:Z.id}}),g=await G.asset.create({data:{name:"share_root",type:"share_root",status:"processed",projectId:Z.id}}),V=await G.project.update({where:{id:Z.id},data:{rootFolderId:W.id,shareRootId:g.id},include:{rootFolder:!0}});return await G.projectMember.create({data:{projectId:Z.id,teamMemberId:U.id,role:"owner"}}),V});return this.toProjectInfo(I)}async getProject(B){let Q=await VB.project.findUnique({where:{id:B},include:{rootFolder:!0}});if(!Q)throw Error("Project not found");return this.toProjectInfo(Q)}async updateProject(B){let Q=await VB.project.findUnique({where:{id:B.projectId},include:{team:!0}});if(!Q)throw Error("Project not found");if(!Q.team)throw Error("Project has no team");let F=await VB.project.update({where:{id:B.projectId},data:{name:B.name,coverImageKey:B.coverImageKey,enableNotification:B.enableNotification},include:{rootFolder:!0}});return this.toProjectInfo(F)}async listProjects(B){let Q=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B.teamId,userId:B.userId}}});if(!Q)throw Error("failed to get team member");let F={teamId:B.teamId};if(Q.scope==="project")F.members={some:{teamMemberId:Q.id}};let U={},I=B.sortDirection==="desc"?"desc":"asc";if(B.sortBy)if(B.sortBy==="created_at")U.createdAt=I;else if(B.sortBy==="updated_at")U.updatedAt=I;else U.name=I;else U.name="asc";return await $V(async(Z,W)=>{let g=await VB.project.findMany({where:F,orderBy:U,skip:Z,take:W,include:{rootFolder:!0}});return await Promise.all(g.map((b)=>this.toProjectInfo(b)))},null,B.pagination)}async addProjectMember(B){if(!await VB.user.findUnique({where:{id:B.userId}}))throw Error("User not found");let F=await VB.project.findUnique({where:{id:B.projectId},include:{team:!0}});if(!F)throw Error("Project not found");let U=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:F.teamId,userId:B.userId}}});if(!U)throw Error("user is not a team member");await VB.projectMember.create({data:{projectId:B.projectId,teamMemberId:U.id,role:B.role}})}async listProjectMembers(B){let Q=await VB.projectMember.findMany({where:{projectId:B.projectId,...B.includeAgents?{teamMember:{user:{OR:[{type:"human"},{type:"agent",agent:{type:"chat",enabled:!0}}]}}}:{teamMember:{user:{type:{not:"agent"}}}}},include:{teamMember:{include:{user:!0}}}});return Promise.all(Q.filter((F)=>F.teamMember&&F.teamMember.user).map(async(F)=>({id:F.teamMember.user.id,name:F.teamMember.user.name,role:F.role,image:await MX(F.teamMember.user.image),scope:F.teamMember.scope})))}async deleteProject(B){let Q=await VB.project.findUnique({where:{id:B}});if(!Q)throw Error("Project not found");let F=new Date(0);if(await VB.$transaction(async(U)=>{await U.asset.updateMany({where:{projectId:B},data:{isDeleted:!0,projectId:null}});let I=[Q.rootFolderId,Q.shareRootId].filter((G)=>G!==null);if(I.length>0)await U.asset.updateMany({where:{id:{in:I}},data:{status:"trashed",deletedAt:F}});await U.project.update({where:{id:B},data:{rootFolderId:null,shareRootId:null}}),await U.project.delete({where:{id:B}})}),Q.coverImageKey){let U=process.env.S3_BUCKET||"shumai";try{await yF.deleteObject(U,Q.coverImageKey)}catch(I){console.error(`Failed to delete project cover image ${Q.coverImageKey}:`,I)}}}async getProjectRootFolder(B){let Q=await VB.project.findUnique({where:{id:B},include:{rootFolder:!0}});if(!Q)throw Error("Project not found");if(!Q.rootFolderId)return"";return Q.rootFolderId}async getProjectTeam(B){let Q=await VB.project.findUnique({where:{id:B}});if(!Q)throw Error("Project not found");return Q.teamId}async updateMemberRole(B){let Q=await VB.projectMember.findFirst({where:{projectId:B.projectId,teamMember:{userId:B.userId}}});if(!Q)throw Error("Member not found");if(Q.role==="owner")throw Error("Cannot change the role of an owner");await VB.projectMember.update({where:{id:Q.id},data:{role:B.role}})}async removeMember(B,Q){let F=await VB.projectMember.findFirst({where:{projectId:B,teamMember:{userId:Q}}});if(!F)throw Error("Member not found");if(F.role==="owner")throw Error("Cannot remove an owner");await VB.projectMember.delete({where:{id:F.id}})}async getProjectMe(B,Q){let F=await VB.user.findUnique({where:{id:Q}});if(!F)throw Error("User not found");let U=await VB.project.findUnique({where:{id:B}});if(!U)throw Error("Project not found");let I=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:U.teamId,userId:Q}}});if(!I)throw Error("User is not a team member");let G=await VB.projectMember.findFirst({where:{projectId:B,teamMemberId:I.id}}),Z=G?G.role:I.role;return{id:F.id,name:F.name,role:Z,image:await MX(F.image)}}async toProjectInfo(B){let Q={id:B.id,name:B.name,teamId:B.teamId,enableNotification:B.enableNotification??!0,coverImageKey:B.coverImageKey||void 0,updatedAt:B.updatedAt};if(B.rootFolderId)Q.rootFolder=B.rootFolderId;else if(B.rootFolder)Q.rootFolder=B.rootFolder.id;if(B.coverImageKey)try{let F=process.env.S3_BUCKET||"shumai",U=await yF.presign(F,B.coverImageKey,"GET");Q.coverImage=U}catch(F){let U=F}return Q}}var zXG=new ewQ;function Gr(B){if(!B)return[];let Q=B.toLowerCase(),F=new Set,U=Array.from(Q),I=U.length;if(I>=3)for(let G=0;G<=I-3;G++)F.add(U[G]+U[G+1]+U[G+2]);else if(I===2)F.add(U[0]+U[1]);else if(I===1)F.add(U[0]);return Array.from(F)}class tE{selectSql=gQ.sql`*`;fromSql=null;wheres=[];orderSql=null;limitCount=null;offsetCount=null;select(B){return this.selectSql=B,this}from(B){return this.fromSql=B,this}addWhere(B){return this.wheres.push(B),this}orderBy(B){return this.orderSql=B,this}limit(B){return this.limitCount=B,this}offset(B){return this.offsetCount=B,this}addSearchConditions(B,Q,F){if(!Q||Q.length===0)return this;let U=[];for(let I of Q){if(F?.skipNameContains&&I.field==="name"&&I.operator==="contains")continue;let G=this.buildSqlCondition(I.field,I.operator,I.value);if(G)U.push(G)}if(U.length>0){let I=B==="OR"?" OR ":" AND ";this.addWhere(gQ.sql`(${gQ.join(U,I)})`)}return this}build(){if(!this.fromSql)throw Error("FROM clause is required in SqlQueryBuilder");let B=[gQ.sql`SELECT`,this.selectSql,gQ.sql`FROM`,this.fromSql];if(this.wheres.length>0)B.push(gQ.sql`WHERE`),B.push(gQ.join(this.wheres," AND "));if(this.orderSql)B.push(gQ.sql`ORDER BY`),B.push(this.orderSql);if(this.limitCount!==null)B.push(gQ.sql`LIMIT ${this.limitCount}`);if(this.offsetCount!==null)B.push(gQ.sql`OFFSET ${this.offsetCount}`);return gQ.join(B," ")}isDate(B){if(B instanceof Date)return!0;if(typeof B!=="string")return!1;let Q=B.toLowerCase();if(["today","yesterday","tomorrow","one week ago","one week from now","one month ago","one month from now"].includes(Q)||Q.match(/\d+\s+days?\s+(ago|from\s+now)/))return!0;let U=new Date(B);return!isNaN(U.getTime())&&B.includes("-")}toDate(B){return this.toDateBound(B,"start")}toDateBound(B,Q){let F=this.parseRelativeDate(B);if(F instanceof Date)return F;if(F&&"gte"in F&&"lte"in F)return Q==="start"?F.gte:F.lte;return new Date(B)}parseDateRange(B){let Q=this.parseRelativeDate(B);if(Q&&"gte"in Q&&"lte"in Q)return{start:Q.gte,end:Q.lte};let F=Q instanceof Date?Q:new Date(B),U=new Date(F);U.setHours(0,0,0,0);let I=new Date(F);return I.setHours(23,59,59,999),{start:U,end:I}}parseRelativeDate(B){if(B instanceof Date)return B;let Q=String(B).toLowerCase(),F=new Date,U=(g)=>{let V=new Date(g);return V.setHours(0,0,0,0),V},I=(g)=>{let V=new Date(g);return V.setHours(23,59,59,999),V};if(Q==="today")return{gte:U(F),lte:I(F)};if(Q==="yesterday"){let g=new Date(F);return g.setDate(g.getDate()-1),{gte:U(g),lte:I(g)}}if(Q==="tomorrow"){let g=new Date(F);return g.setDate(g.getDate()+1),{gte:U(g),lte:I(g)}}if(Q==="one week ago"){let g=new Date(F);return g.setDate(g.getDate()-7),g}if(Q==="one week from now"){let g=new Date(F);return g.setDate(g.getDate()+7),g}if(Q==="one month ago"){let g=new Date(F);return g.setMonth(g.getMonth()-1),g}if(Q==="one month from now"){let g=new Date(F);return g.setMonth(g.getMonth()+1),g}let G=Q.match(/(\d+)\s+days?\s+ago/);if(G){let g=new Date(F);return g.setDate(g.getDate()-parseInt(G[1])),g}let Z=Q.match(/(\d+)\s+days?\s+from\s+now/);if(Z){let g=new Date(F);return g.setDate(g.getDate()+parseInt(Z[1])),g}let W=new Date(B);return isNaN(W.getTime())?null:W}buildEavValueMatch(B){if(typeof B==="string"){let Q=String(B);if(this.isDate(Q)){let F=this.parseRelativeDate(Q);if(F instanceof Date)return gQ.sql`date_value = ${F}`;else if(F&&"gte"in F)return gQ.sql`date_value >= ${F.gte} AND date_value <= ${F.lte}`}return gQ.sql`string_value = ${Q}`}if(typeof B==="number")return gQ.sql`number_value = ${Number(B)}`;if(typeof B==="boolean")return gQ.sql`boolean_value = ${Boolean(B)}`;if(B instanceof Date)return gQ.sql`date_value = ${B}`;if(Array.isArray(B)||typeof B==="object"&&B!==null)return gQ.sql`json_value = ${JSON.stringify(B)}::jsonb`;return gQ.sql`string_value = ${String(B)}`}buildSqlCondition(B,Q,F){let U=B==="sizeByte"||B==="size_byte"?"size_byte":B==="createdAt"||B==="created_at"?"created_at":B==="updatedAt"||B==="updated_at"?"updated_at":B,I=gQ.raw(`a."${U}"`);if(B==="name"){let G=String(F);switch(Q){case"eq":return gQ.sql`${I} = ${G}`;case"neq":return gQ.sql`${I} != ${G}`;case"contains":return gQ.sql`${I} ILIKE ${"%"+G+"%"}`;case"notContains":return gQ.sql`${I} NOT ILIKE ${"%"+G+"%"}`;case"isEmpty":return gQ.sql`${I} = ''`;case"isNotEmpty":return gQ.sql`${I} != ''`;default:throw Error(`Unsupported operator for name field: ${Q}`)}}if(B==="sizeByte"||B==="size_byte"){let G=Number(F);switch(Q){case"eq":return gQ.sql`${I} = ${G}`;case"neq":return gQ.sql`${I} != ${G}`;case"gt":return gQ.sql`${I} > ${G}`;case"gte":return gQ.sql`${I} >= ${G}`;case"lt":return gQ.sql`${I} < ${G}`;case"lte":return gQ.sql`${I} <= ${G}`;default:throw Error(`Unsupported operator for sizeByte field: ${Q}`)}}if(B==="createdAt"||B==="updatedAt"||B==="created_at"||B==="updated_at"){let G=this.toDate(F);switch(Q){case"eq":return gQ.sql`${I} = ${G}`;case"neq":return gQ.sql`${I} != ${G}`;case"gt":return gQ.sql`${I} > ${this.toDateBound(F,"end")}`;case"gte":return gQ.sql`${I} >= ${this.toDateBound(F,"start")}`;case"lt":return gQ.sql`${I} < ${this.toDateBound(F,"start")}`;case"lte":return gQ.sql`${I} <= ${this.toDateBound(F,"end")}`;case"isWithin":{let Z=this.parseDateRange(F);return gQ.sql`${I} >= ${Z.start} AND ${I} <= ${Z.end}`}default:throw Error(`Unsupported operator for date field: ${Q}`)}}switch(Q){case"isEmpty":return gQ.sql`a.id NOT IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B})`;case"isNotEmpty":return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B})`;case"eq":{let G=this.buildEavValueMatch(F);return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND ${G})`}case"neq":{let G=this.buildEavValueMatch(F);return gQ.sql`a.id NOT IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B}) OR a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND NOT (${G}))`}case"gt":return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND (number_value > ${Number(F)} OR date_value > ${this.toDateBound(F,"end")}))`;case"gte":return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND (number_value >= ${Number(F)} OR date_value >= ${this.toDateBound(F,"start")}))`;case"lt":return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND (number_value < ${Number(F)} OR date_value < ${this.toDateBound(F,"start")}))`;case"lte":return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND (number_value <= ${Number(F)} OR date_value <= ${this.toDateBound(F,"end")}))`;case"contains":return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND string_value ILIKE ${"%"+String(F)+"%"})`;case"notContains":return gQ.sql`a.id NOT IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND string_value ILIKE ${"%"+String(F)+"%"})`;case"in":{let G=Array.isArray(F)?F:[F],Z=G.map((W)=>Number(W)).filter((W)=>!isNaN(W));return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND (string_value = ANY(${G}) OR number_value = ANY(${Z}::double precision[])))`}case"notIn":{let G=Array.isArray(F)?F:[F],Z=G.map((W)=>Number(W)).filter((W)=>!isNaN(W));return gQ.sql`a.id NOT IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND (string_value = ANY(${G}) OR number_value = ANY(${Z}::double precision[])))`}case"hasAll":return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND json_value @> ${JSON.stringify(F)}::jsonb)`;case"hasAny":{let G=(Array.isArray(F)?F:[F]).map(String);return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND jsonb_exists_any(json_value, ${G}::text[]))`}case"hasNone":{let G=(Array.isArray(F)?F:[F]).map(String);return gQ.sql`a.id NOT IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND jsonb_exists_any(json_value, ${G}::text[]))`}case"isWithin":{let G=this.parseDateRange(F);return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND date_value >= ${G.start} AND date_value <= ${G.end})`}default:throw Error(`Unsupported operator for metadata field: ${Q}`)}}}class B4Q{prismaClient;assetSvc;constructor(B=VB,Q=TX){this.prismaClient=B;this.assetSvc=Q}async search(B,Q){let F=Q.recursively===!1?[B]:await this.assetSvc.getDescendantFolderIds(B),U=Q.assetType==="folder"?[AF.folder]:[AF.file,AF.version_stack];if(Q.query&&Q.isSemantic){let c=(await this.prismaClient.asset.findUnique({where:{id:B},select:{project:{select:{teamId:!0}}}}))?.project?.teamId;if(!c)throw Error("Team ID not found for folder");if(!await this.prismaClient.agent.findFirst({where:{teamId:c,type:"embedding",enabled:!0}}))throw new YI(422,{message:"Embedding agent not configured or disabled for this team."});let d=await this.prismaClient.workflowTask.create({data:{type:e0.query_embedding_for_search,teamId:c,assetId:B,payload:{projectId:"",queryEmbeddingForSearch:{text:Q.query}},status:"pending"}}),bB=(await oN.executeWait(d)).output?.embedding;if(!bB)throw Error("Failed to generate query embedding");let CB=JSON.stringify(bB),IB=new tE().select(gQ.sql`a.id as "assetId", ae.start_time as "startTime", ae.end_time as "endTime", (ae.embedding <=> ${CB}::vector) as "distance"`).from(gQ.sql`assets a JOIN asset_embeddings ae ON a.id = ae.asset_id`).addWhere(gQ.sql`a.is_deleted = false`);if(F.length>0)IB.addWhere(gQ.sql`a.parent_id = ANY(${F})`);if(Q.showSymlink)IB.addWhere(gQ.sql`
13869
+ Most of the features of Better Auth will not work correctly.`);let g=Q.secrets??wwQ(T0.BETTER_AUTH_SECRETS),V=Q.secret||T0.BETTER_AUTH_SECRET||T0.AUTH_SECRET||"",b,X;if(g)SwQ(g,G),b=g[0].value,X=ywQ(g,V);else b=V||"better-auth-secret-12345678901234567890",l6F(b,G),X=b;Q={...Q,secret:b,baseURL:Z?Q.baseURL:W?new URL(W).origin:"",basePath:Q.basePath||"/api/auth",plugins:U.concat(I)},EwQ(Q,G);let C=mo(Q),N=mX(Q),R=(await Promise.all(Object.entries(Q.socialProviders||{}).map(async([c,k])=>{let d=typeof k==="function"?await k():k;if(d==null)return null;if(d.enabled===!1)return null;if(!d.clientId)G.warn(`Social provider ${c} is missing clientId or clientSecret`);let $=rYB[c](d);return $.disableImplicitSignUp=d.disableImplicitSignUp,$}))).filter((c)=>c!==null),A=({model:c,size:k})=>{if(typeof Q.advanced?.generateId==="function")return Q.advanced.generateId({model:c,size:k});let d=Q?.advanced?.database?.generateId;if(typeof d==="function")return d({model:c,size:k});if(d==="uuid")return crypto.randomUUID();if(d==="serial"||d===!1)return!1;return vN(k)},{publish:Y}=await $wQ(Q,{adapter:B.id,database:typeof Q.database==="function"?"adapter":F(Q.database)}),L=new Set(Q.plugins.map((c)=>c.id)),H=(c)=>Q.plugins.find((k)=>k.id===c)??null,J=(c)=>L.has(c),w=await jd(Q),M=await nd(Q),y={appName:Q.appName||"Better Auth",baseURL:W||"",version:gYB(),socialProviders:R,options:Q,oauthConfig:{storeStateStrategy:Q.account?.storeStateStrategy||(Q.database?"database":"cookie"),skipStateCookieCheck:!!Q.account?.skipStateCookieCheck},tables:N,trustedOrigins:w,trustedProviders:M,isTrustedOrigin(c,k){return this.trustedOrigins.some((d)=>ea(c,d,k))},sessionConfig:{updateAge:Q.session?.updateAge!==void 0?Q.session.updateAge:86400,expiresIn:Q.session?.expiresIn||604800,freshAge:Q.session?.freshAge===void 0?86400:Q.session.freshAge,cookieRefreshCache:(()=>{let c=Q.session?.cookieCache?.refreshCache,k=Q.session?.cookieCache?.maxAge||300;if((!!Q.database||!!Q.secondaryStorage)&&c)return G.warn("[better-auth] `session.cookieCache.refreshCache` is enabled while `database` or `secondaryStorage` is configured. `refreshCache` is meant for stateless (DB-less) setups. Disabling `refreshCache` \u2014 remove it from your config to silence this warning."),!1;if(c===!1||c===void 0)return!1;if(c===!0)return{enabled:!0,updateAge:Math.floor(k*0.2)};return{enabled:!0,updateAge:c.updateAge!==void 0?c.updateAge:Math.floor(k*0.2)}})()},secret:b,secretConfig:X,rateLimit:{...Q.rateLimit,enabled:Q.rateLimit?.enabled??VE,window:Q.rateLimit?.window||10,max:Q.rateLimit?.max||100,storage:Q.rateLimit?.storage||(Q.secondaryStorage?"secondary-storage":"memory")},authCookies:C,logger:G,generateId:A,session:null,secondaryStorage:Q.secondaryStorage,password:{hash:Q.emailAndPassword?.password?.hash||YEQ,verify:Q.emailAndPassword?.password?.verify||LEQ,config:{minPasswordLength:Q.emailAndPassword?.minPasswordLength||8,maxPasswordLength:Q.emailAndPassword?.maxPasswordLength||128},checkPassword:Q3Q},setNewSession(c){this.newSession=c},newSession:null,adapter:B,internalAdapter:ko(B,{options:Q,logger:G,hooks:Q.databaseHooks?[{source:"user",hooks:Q.databaseHooks}]:[],generateId:A}),createAuthCookie:_d(Q),async runMigrations(){throw new OQ("runMigrations will be set by the specific init implementation")},publishTelemetry:Y,skipCSRFCheck:!!Q.advanced?.disableCSRFCheck,skipOriginCheck:Q.advanced?.disableOriginCheck!==void 0?Q.advanced.disableOriginCheck:HJ()?!0:!1,runInBackground:Q.advanced?.backgroundTasks?.handler??((c)=>{c.catch(()=>{})}),async runInBackgroundOrAwait(c){try{if(Q.advanced?.backgroundTasks?.handler){if(c instanceof Promise)Q.advanced.backgroundTasks.handler(c.catch((k)=>{G.error("Failed to run background task:",k)}))}else await c}catch(k){G.error("Failed to run background task:",k)}},getPlugin:H,hasPlugin:J},m=sDQ(y);if(_7(m))await m;return y}PU();ta();var vwQ=async(B)=>{let Q=await GEQ(B),U=await _wQ(Q,B,(I)=>Ld(I)||"unknown");return U.runMigrations=async function(){if(!B.database||"updateMany"in B.database)throw new OQ("Database is not provided or it's an adapter. Migrations are only supported with a database instance.");let{runMigrations:I}=await WEQ(B);await I()},U};PU();var PwQ=(B,Q)=>{let F=Q(B),{api:U}=BLB(F,B);return{handler:async(I)=>{let G=await F,Z=G.options.basePath||"/api/auth",W;if(Q2(B.baseURL))W=await vo(G,I,_o(G.options));else{if(W=G,!G.options.baseURL){let V=_J(void 0,Z,I,void 0,G.options.advanced?.trustedProxyHeaders);if(V)G.baseURL=V,G.options.baseURL=OE(G.baseURL)||void 0;else throw new OQ("Could not get base URL from request. Please provide a valid base URL.")}W.trustedOrigins=await jd(G.options,I),W.trustedProviders=await nd(G.options,I)}let{handler:g}=DwQ(W,B);return RYB(W.adapter,()=>g(I))},api:U,options:B,$context:F,$ERROR_CODES:{...B.plugins?.reduce((I,G)=>{if(G.$ERROR_CODES)return{...I,...G.$ERROR_CODES};return I},{}),...LQ}}};var ULB=(B)=>{return PwQ(B,vwQ)};Tb();PU();J2B();pz();XE();wk();PU();function ILB(B){return B?.code==="P2025"||B?.meta?.cause==="Record to delete does not exist."}var fwQ=(B,Q)=>{let F=null,U=(Z,W=!1)=>({getFieldName:g,getModelName:V,getFieldAttributes:b,getDefaultModelName:X,schema:C})=>{let N=Z,R=(J,w,M)=>{if(!J&&!M)return;let y={};if(J)for(let m of J)y[g({model:w,field:m})]=!0;if(M){if(!J){let m=C[X(w)]?.fields||{};m.id={type:"string"};for(let c of Object.keys(m))y[g({model:w,field:c})]=!0}for(let[m,c]of Object.entries(M)){let k=A(w,V(m),C);if(c.relation==="one-to-one")y[k]=!0;else y[k]={take:c.limit}}}return y},A=(J,w,M)=>{try{let y=X(J),m=X(w),c=V(w).toLowerCase(),k=Object.entries(M[m]?.fields||{}).filter(([d,$])=>$.references&&X($.references.model)===y);if(k.length>0){let[d,$]=k[0];return $?.unique===!0||Q.usePlural===!0?c:`${c}s`}if(k=Object.entries(M[y]?.fields||{}).filter(([d,$])=>$.references&&X($.references.model)===m),k.length>0)return c}catch{}return`${V(w).toLowerCase()}s`};function Y(J){switch(J){case"starts_with":return"startsWith";case"ends_with":return"endsWith";case"ne":return"not";case"not_in":return"notIn";default:return J}}let L=(J,w)=>{if(!w?.length)return!1;return w.some((M)=>{if(M.connector==="OR")return!1;if(M.operator&&M.operator!=="eq")return!1;if(M.mode==="insensitive"){let y=Q.provider==="postgresql"||Q.provider==="mongodb",m=typeof M.value==="string"||Array.isArray(M.value)&&M.value.every((c)=>typeof c==="string");if(y&&m)return!1}if(M.field==="id")return!0;return b({model:J,field:M.field})?.unique===!0})},H=({action:J,model:w,where:M})=>{if(!M||!M.length)return{};let y=($)=>{let FB=g({model:w,field:$.field}),bB=($.mode??"sensitive")==="insensitive"&&(typeof $.value==="string"||Array.isArray($.value)&&$.value.every((LB)=>typeof LB==="string")),CB=Q.provider==="postgresql"||Q.provider==="mongodb",IB=bB&&CB?"insensitive":void 0,t=IB?{mode:IB}:{};if($.operator==="ne"&&$.value===null)return b({model:w,field:$.field})?.required!==!0?{[FB]:{not:null}}:{};if(($.operator==="in"||$.operator==="not_in")&&Array.isArray($.value)){let LB=$.value.filter((HQ)=>HQ!=null);if(LB.length===0)if($.operator==="in")return{AND:[{[FB]:{equals:"__never__"}},{[FB]:{not:"__never__"}}]};else return{};let NQ=Y($.operator);return{[FB]:{[NQ]:LB,...t}}}if($.operator==="eq"||!$.operator)return{[FB]:{equals:$.value,...t}};if($.operator==="ne")return{[FB]:{not:{equals:$.value},...t}};let ZB=Y($.operator);return{[FB]:{[ZB]:$.value,...t}}};if(J==="update"){let $=M.filter((ZB)=>ZB.connector==="AND"||!ZB.connector),FB=M.filter((ZB)=>ZB.connector==="OR"),bB=$.filter((ZB)=>ZB.operator==="eq"||!ZB.operator),CB=$.filter((ZB)=>ZB.operator!=="eq"&&ZB.operator!==void 0).map((ZB)=>y(ZB)),IB=FB.map((ZB)=>y(ZB)),t={};for(let ZB of bB){let LB=g({model:w,field:ZB.field});t[LB]=ZB.value}if(CB.length>0)t.AND=CB;if(IB.length>0)t.OR=IB;return t}if(J==="delete"){let $=M.find((FB)=>FB.field==="id");if($){let FB=g({model:w,field:"id"}),bB=M.filter((NQ)=>NQ.field!=="id");if(bB.length===0)return{[FB]:$.value};let CB=bB.filter((NQ)=>NQ.connector==="AND"||!NQ.connector),IB=bB.filter((NQ)=>NQ.connector==="OR"),t=CB.map((NQ)=>y(NQ)),ZB=IB.map((NQ)=>y(NQ)),LB={[FB]:$.value};if(t.length>0)LB.AND=t;if(ZB.length>0)LB.OR=ZB;return LB}}if(M.length===1){let $=M[0];if(!$)return;return y($)}let m=M.filter(($)=>$.connector==="AND"||!$.connector),c=M.filter(($)=>$.connector==="OR"),k=m.map(($)=>y($)),d=c.map(($)=>y($));return{...k.length?{AND:k}:{},...d.length?{OR:d}:{}}};return{async create({model:J,data:w,select:M}){if(!N[J])throw new OQ(`Model ${J} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);return await N[J].create({data:w,select:R(M,J)})},async findOne({model:J,where:w,select:M,join:y}){let m=H({model:J,where:w,action:"findOne"});if(!N[J])throw new OQ(`Model ${J} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);let c=new Map;for(let $ of Object.keys(y??{})){let FB=A(J,$,C);c.set(FB,V($))}let k=R(M,J,y),d=await N[J].findFirst({where:m,select:k});if(y&&d)for(let[$,FB]of c.entries()){if($===FB)continue;if($ in d)d[FB]=d[$],delete d[$]}return d},async findMany({model:J,where:w,limit:M,select:y,offset:m,sortBy:c,join:k}){let d=H({model:J,where:w,action:"findMany"});if(!N[J])throw new OQ(`Model ${J} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);let $=new Map;if(k)for(let[CB,IB]of Object.entries(k)){let t=A(J,CB,C);$.set(t,V(CB))}let FB=R(y,J,k),bB=await N[J].findMany({where:d,take:M||100,skip:m||0,...c?.field?{orderBy:{[g({model:J,field:c.field})]:c.direction==="desc"?"desc":"asc"}}:{},select:FB});if(k&&Array.isArray(bB))for(let CB of bB)for(let[IB,t]of $.entries()){if(IB===t)continue;if(IB in CB)CB[t]=CB[IB],delete CB[IB]}return bB},async count({model:J,where:w}){let M=H({model:J,where:w,action:"count"});if(!N[J])throw new OQ(`Model ${J} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);return await N[J].count({where:M})},async update({model:J,where:w,update:M}){if(!N[J])throw new OQ(`Model ${J} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);if(!L(J,w)){let m=H({model:J,where:w,action:"updateMany"});if(!(await N[J].updateMany({where:m,data:M}))?.count)return null;return await N[J].findFirst({where:m})}let y=H({model:J,where:w,action:"update"});return await N[J].update({where:y,data:M})},async updateMany({model:J,where:w,update:M}){if(!N[J])throw new OQ(`Model ${J} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);let y=H({model:J,where:w,action:"updateMany"}),m=await N[J].updateMany({where:y,data:M});return m?m.count:0},async delete({model:J,where:w}){if(!N[J])throw new OQ(`Model ${J} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);if(!w?.some((y)=>y.field==="id")){let y=H({model:J,where:w,action:"deleteMany"});await N[J].deleteMany({where:y});return}let M=H({model:J,where:w,action:"delete"});try{await N[J].delete({where:M})}catch(y){if(ILB(y))return;console.log(y)}},async deleteMany({model:J,where:w}){let M=H({model:J,where:w,action:"deleteMany"}),y=await N[J].deleteMany({where:M});return y?y.count:0},async consumeOne({model:J,where:w}){if(!N[J])throw new OQ(`Model ${J} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`);if(w?.some((m)=>m.field==="id")){let m=H({model:J,where:w,action:"delete"});try{return await N[J].delete({where:m})??null}catch(c){if(ILB(c))return null;throw c}}let M=H({model:J,where:w,action:"findOne"}),y=async(m)=>{let c=await m[J].findFirst({where:M});if(!c)return null;try{return(await m[J].deleteMany({where:H({model:J,where:[...w??[],{field:"id",value:c.id,operator:"eq",connector:"AND",mode:"sensitive"}],action:"deleteMany"})}))?.count>0?c:null}catch(k){if(ILB(k))return null;throw k}};return W||typeof N.$transaction!=="function"?y(N):N.$transaction(y)},options:Q}},I=null;I={config:{adapterId:"prisma",adapterName:"Prisma Adapter",usePlural:Q.usePlural??!1,debugLogs:Q.debugLogs??!1,supportsUUIDs:Q.provider==="postgresql"?!0:!1,supportsArrays:Q.provider==="postgresql"||Q.provider==="mongodb"?!0:!1,transaction:Q.transaction??!1?(Z)=>B.$transaction((W)=>{return Z(EJ({config:{...I.config,transaction:!1},adapter:U(W,!0)})(F))}):!1},adapter:U(B)};let G=EJ(I);return(Z)=>{return F=Z,G(Z)}};var lwQ={openai:{name:"openai",config:{api:"openai-responses",baseUrl:"https://api.openai.com/v1",apiKey:"OPENAI_API_KEY"},models:[{modelId:"gpt-4",name:"GPT-4",config:{api:"openai-responses",reasoning:!1,input:["text"],contextWindow:8192,maxTokens:8192,cost:{input:30,output:60,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-4-turbo",name:"GPT-4 Turbo",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:10,output:30,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-4.1",name:"GPT-4.1",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"gpt-4.1-mini",name:"GPT-4.1 mini",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:0.4,output:1.6,cacheRead:0.1,cacheWrite:0}}},{modelId:"gpt-4.1-nano",name:"GPT-4.1 nano",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:0.1,output:0.4,cacheRead:0.025,cacheWrite:0}}},{modelId:"gpt-4o",name:"GPT-4o",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"gpt-4o-2024-05-13",name:"GPT-4o (2024-05-13)",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:5,output:15,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-4o-2024-08-06",name:"GPT-4o (2024-08-06)",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"gpt-4o-2024-11-20",name:"GPT-4o (2024-11-20)",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"gpt-4o-mini",name:"GPT-4o mini",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0.075,cacheWrite:0}}},{modelId:"gpt-5",name:"GPT-5",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5-chat-latest",name:"GPT-5 Chat Latest",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5-codex",name:"GPT-5-Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5-mini",name:"GPT-5 Mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"gpt-5-nano",name:"GPT-5 Nano",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.05,output:0.4,cacheRead:0.005,cacheWrite:0}}},{modelId:"gpt-5-pro",name:"GPT-5 Pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:15,output:120,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-5.1",name:"GPT-5.1",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-chat-latest",name:"GPT-5.1 Chat",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-codex",name:"GPT-5.1 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"gpt-5.2",name:"GPT-5.2",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-chat-latest",name:"GPT-5.2 Chat",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-codex",name:"GPT-5.2 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-pro",name:"GPT-5.2 Pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:21,output:168,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-5.3-chat-latest",name:"GPT-5.3 Chat (latest)",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.3-codex",name:"GPT-5.3 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:32000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.4",name:"GPT-5.4",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:272000,maxTokens:128000,cost:{input:2.5,output:15,cacheRead:0.25,cacheWrite:0}}},{modelId:"gpt-5.4-mini",name:"GPT-5.4 mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.75,output:4.5,cacheRead:0.075,cacheWrite:0}}},{modelId:"gpt-5.4-nano",name:"GPT-5.4 nano",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.2,output:1.25,cacheRead:0.02,cacheWrite:0}}},{modelId:"gpt-5.4-pro",name:"GPT-5.4 Pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-5.5",name:"GPT-5.5",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:272000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"gpt-5.5-pro",name:"GPT-5.5 Pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:0,cacheWrite:0}}},{modelId:"o1",name:"o1",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0}}},{modelId:"o1-pro",name:"o1-pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:150,output:600,cacheRead:0,cacheWrite:0}}},{modelId:"o3",name:"o3",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"o3-deep-research",name:"o3-deep-research",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0}}},{modelId:"o3-mini",name:"o3-mini",config:{api:"openai-responses",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.55,cacheWrite:0}}},{modelId:"o3-pro",name:"o3-pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:20,output:80,cacheRead:0,cacheWrite:0}}},{modelId:"o4-mini",name:"o4-mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.275,cacheWrite:0}}},{modelId:"o4-mini-deep-research",name:"o4-mini-deep-research",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}}]},anthropic:{name:"anthropic",config:{api:"anthropic-messages",baseUrl:"https://api.anthropic.com",apiKey:"ANTHROPIC_API_KEY"},models:[{modelId:"claude-3-5-haiku-20241022",name:"Claude Haiku 3.5",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:0.8,output:4,cacheRead:0.08,cacheWrite:1}}},{modelId:"claude-3-5-haiku-latest",name:"Claude Haiku 3.5 (latest)",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:0.8,output:4,cacheRead:0.08,cacheWrite:1}}},{modelId:"claude-3-5-sonnet-20240620",name:"Claude Sonnet 3.5",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-3-5-sonnet-20241022",name:"Claude Sonnet 3.5 v2",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-3-7-sonnet-20250219",name:"Claude Sonnet 3.7",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-3-haiku-20240307",name:"Claude Haiku 3",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:0.25,output:1.25,cacheRead:0.03,cacheWrite:0.3}}},{modelId:"claude-3-opus-20240229",name:"Claude Opus 3",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-3-sonnet-20240229",name:"Claude Sonnet 3",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:0.3}}},{modelId:"claude-fable-5",name:"Claude Fable 5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5}}},{modelId:"claude-haiku-4-5",name:"Claude Haiku 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"claude-opus-4-0",name:"Claude Opus 4 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-opus-4-1",name:"Claude Opus 4.1 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-opus-4-1-20250805",name:"Claude Opus 4.1",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-opus-4-20250514",name:"Claude Opus 4",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-opus-4-5",name:"Claude Opus 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-6",name:"Claude Opus 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-7",name:"Claude Opus 4.7",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-8",name:"Claude Opus 4.8",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-sonnet-4-0",name:"Claude Sonnet 4 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4-5",name:"Claude Sonnet 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}}]},google:{name:"google",config:{api:"google-generative-ai",baseUrl:"https://generativelanguage.googleapis.com/v1beta",apiKey:"GEMINI_API_KEY"},models:[{modelId:"gemini-2.0-flash",name:"Gemini 2.0 Flash",config:{api:"google-generative-ai",reasoning:!1,input:["text","image"],contextWindow:1048576,maxTokens:8192,cost:{input:0.1,output:0.4,cacheRead:0.025,cacheWrite:0}}},{modelId:"gemini-2.0-flash-lite",name:"Gemini 2.0 Flash-Lite",config:{api:"google-generative-ai",reasoning:!1,input:["text","image"],contextWindow:1048576,maxTokens:8192,cost:{input:0.075,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"gemini-2.5-flash",name:"Gemini 2.5 Flash",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.3,output:2.5,cacheRead:0.03,cacheWrite:0}}},{modelId:"gemini-2.5-flash-lite",name:"Gemini 2.5 Flash-Lite",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.1,output:0.4,cacheRead:0.01,cacheWrite:0}}},{modelId:"gemini-2.5-pro",name:"Gemini 2.5 Pro",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.5,output:3,cacheRead:0.05,cacheWrite:0}}},{modelId:"gemini-3-pro-preview",name:"Gemini 3 Pro Preview",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"gemini-3.1-flash-lite",name:"Gemini 3.1 Flash Lite",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.25,output:1.5,cacheRead:0.025,cacheWrite:0}}},{modelId:"gemini-3.1-flash-lite-preview",name:"Gemini 3.1 Flash Lite Preview",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.25,output:1.5,cacheRead:0.025,cacheWrite:0}}},{modelId:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"gemini-3.1-pro-preview-customtools",name:"Gemini 3.1 Pro Preview Custom Tools",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"gemini-3.5-flash",name:"Gemini 3.5 Flash",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.5,output:9,cacheRead:0.15,cacheWrite:0}}},{modelId:"gemini-flash-latest",name:"Gemini Flash Latest",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.3,output:2.5,cacheRead:0.075,cacheWrite:0}}},{modelId:"gemini-flash-lite-latest",name:"Gemini Flash-Lite Latest",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.1,output:0.4,cacheRead:0.025,cacheWrite:0}}},{modelId:"gemma-4-26b-a4b-it",name:"Gemma 4 26B A4B IT",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"gemma-4-31b-it",name:"Gemma 4 31B IT",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"gemma-4-E2B-it",name:"Gemma 4 E2B IT",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:131072,maxTokens:8192,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"gemma-4-E4B-it",name:"Gemma 4 E4B IT",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:131072,maxTokens:8192,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}}]},deepseek:{name:"deepseek",config:{api:"openai-completions",baseUrl:"https://api.deepseek.com",apiKey:"DEEPSEEK_API_KEY"},models:[{modelId:"deepseek-v4-flash",name:"DeepSeek V4 Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:0.14,output:0.28,cacheRead:0.0028,cacheWrite:0}}},{modelId:"deepseek-v4-pro",name:"DeepSeek V4 Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:0.435,output:0.87,cacheRead:0.003625,cacheWrite:0}}}]},groq:{name:"groq",config:{api:"openai-completions",baseUrl:"https://api.groq.com/openai/v1",apiKey:"GROQ_API_KEY"},models:[{modelId:"llama-3.1-8b-instant",name:"Llama 3.1 8B",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.05,output:0.08,cacheRead:0,cacheWrite:0}}},{modelId:"llama-3.3-70b-versatile",name:"Llama 3.3 70B",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:32768,cost:{input:0.59,output:0.79,cacheRead:0,cacheWrite:0}}},{modelId:"meta-llama/llama-4-scout-17b-16e-instruct",name:"Llama 4 Scout 17B 16E",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:131072,maxTokens:8192,cost:{input:0.11,output:0.34,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-120b",name:"GPT OSS 120B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:65536,cost:{input:0.15,output:0.6,cacheRead:0.075,cacheWrite:0}}},{modelId:"openai/gpt-oss-20b",name:"GPT OSS 20B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:65536,cost:{input:0.075,output:0.3,cacheRead:0.0375,cacheWrite:0}}},{modelId:"openai/gpt-oss-safeguard-20b",name:"Safety GPT OSS 20B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:65536,cost:{input:0.075,output:0.3,cacheRead:0.037,cacheWrite:0}}},{modelId:"qwen/qwen3-32b",name:"Qwen3-32B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:40960,cost:{input:0.29,output:0.59,cacheRead:0,cacheWrite:0}}}]},openrouter:{name:"openrouter",config:{api:"openai-completions",baseUrl:"https://openrouter.ai/api/v1",apiKey:"OPENROUTER_API_KEY"},models:[{modelId:"ai21/jamba-large-1.7",name:"AI21: Jamba Large 1.7",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:4096,cost:{input:2,output:8,cacheRead:0,cacheWrite:0}}},{modelId:"amazon/nova-2-lite-v1",name:"Amazon: Nova 2 Lite",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65535,cost:{input:0.3,output:2.5,cacheRead:0,cacheWrite:0}}},{modelId:"amazon/nova-lite-v1",name:"Amazon: Nova Lite 1.0",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:300000,maxTokens:5120,cost:{input:0.06,output:0.24,cacheRead:0,cacheWrite:0}}},{modelId:"amazon/nova-micro-v1",name:"Amazon: Nova Micro 1.0",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:5120,cost:{input:0.035,output:0.14,cacheRead:0,cacheWrite:0}}},{modelId:"amazon/nova-premier-v1",name:"Amazon: Nova Premier 1.0",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:1e6,maxTokens:32000,cost:{input:2.5,output:12.5,cacheRead:0.625,cacheWrite:0}}},{modelId:"amazon/nova-pro-v1",name:"Amazon: Nova Pro 1.0",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:300000,maxTokens:5120,cost:{input:0.8,output:3.2,cacheRead:0,cacheWrite:0}}},{modelId:"anthropic/claude-3-haiku",name:"Anthropic: Claude 3 Haiku",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:0.25,output:1.25,cacheRead:0.03,cacheWrite:0.3}}},{modelId:"anthropic/claude-3.5-haiku",name:"Anthropic: Claude 3.5 Haiku",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:0.8,output:4,cacheRead:0.08,cacheWrite:1}}},{modelId:"anthropic/claude-fable-5",name:"Anthropic: Claude Fable 5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5}}},{modelId:"anthropic/claude-haiku-4.5",name:"Anthropic: Claude Haiku 4.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"anthropic/claude-opus-4",name:"Anthropic: Claude Opus 4",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"anthropic/claude-opus-4.1",name:"Anthropic: Claude Opus 4.1",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"anthropic/claude-opus-4.5",name:"Anthropic: Claude Opus 4.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic/claude-opus-4.6",name:"Anthropic: Claude Opus 4.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic/claude-opus-4.6-fast",name:"Anthropic: Claude Opus 4.6 (Fast)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:30,output:150,cacheRead:3,cacheWrite:37.5}}},{modelId:"anthropic/claude-opus-4.7",name:"Anthropic: Claude Opus 4.7",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic/claude-opus-4.7-fast",name:"Anthropic: Claude Opus 4.7 (Fast)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:30,output:150,cacheRead:3,cacheWrite:37.5}}},{modelId:"anthropic/claude-opus-4.8",name:"Anthropic: Claude Opus 4.8",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic/claude-opus-4.8-fast",name:"Anthropic: Claude Opus 4.8 (Fast)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5}}},{modelId:"anthropic/claude-sonnet-4",name:"Anthropic: Claude Sonnet 4",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"anthropic/claude-sonnet-4.5",name:"Anthropic: Claude Sonnet 4.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"anthropic/claude-sonnet-4.6",name:"Anthropic: Claude Sonnet 4.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"arcee-ai/trinity-large-thinking",name:"Arcee AI: Trinity Large Thinking",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.22,output:0.85,cacheRead:0.06,cacheWrite:0}}},{modelId:"arcee-ai/trinity-mini",name:"Arcee AI: Trinity Mini",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.045,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"arcee-ai/virtuoso-large",name:"Arcee AI: Virtuoso Large",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:64000,cost:{input:0.75,output:1.2,cacheRead:0,cacheWrite:0}}},{modelId:"auto",name:"Auto",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:2000000,maxTokens:30000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"bytedance-seed/seed-1.6",name:"ByteDance Seed: Seed 1.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0.25,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"bytedance-seed/seed-1.6-flash",name:"ByteDance Seed: Seed 1.6 Flash",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0.075,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"bytedance-seed/seed-2.0-lite",name:"ByteDance Seed: Seed-2.0-Lite",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.25,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"bytedance-seed/seed-2.0-mini",name:"ByteDance Seed: Seed-2.0-Mini",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.1,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"cohere/command-r-08-2024",name:"Cohere: Command R (08-2024)",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4000,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"cohere/command-r-plus-08-2024",name:"Cohere: Command R+ (08-2024)",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4000,cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek/deepseek-chat",name:"DeepSeek: DeepSeek V3",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16000,cost:{input:0.2002,output:0.8001,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek/deepseek-chat-v3-0324",name:"DeepSeek: DeepSeek V3 0324",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:163840,maxTokens:16384,cost:{input:0.2,output:0.77,cacheRead:0.135,cacheWrite:0}}},{modelId:"deepseek/deepseek-chat-v3.1",name:"DeepSeek: DeepSeek V3.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:32768,cost:{input:0.21,output:0.79,cacheRead:0.13,cacheWrite:0}}},{modelId:"deepseek/deepseek-r1",name:"DeepSeek: R1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:16000,cost:{input:0.7,output:2.5,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek/deepseek-r1-0528",name:"DeepSeek: R1 0528",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:32768,cost:{input:0.5,output:2.15,cacheRead:0.35,cacheWrite:0}}},{modelId:"deepseek/deepseek-v3.1-terminus",name:"DeepSeek: DeepSeek V3.1 Terminus",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:32768,cost:{input:0.27,output:0.95,cacheRead:0.13,cacheWrite:0}}},{modelId:"deepseek/deepseek-v3.2",name:"DeepSeek: DeepSeek V3.2",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:64000,cost:{input:0.2288,output:0.3432,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek/deepseek-v3.2-exp",name:"DeepSeek: DeepSeek V3.2 Exp",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:65536,cost:{input:0.27,output:0.41,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek/deepseek-v4-flash",name:"DeepSeek: DeepSeek V4 Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:65536,cost:{input:0.09,output:0.18,cacheRead:0.02,cacheWrite:0}}},{modelId:"deepseek/deepseek-v4-pro",name:"DeepSeek: DeepSeek V4 Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:384000,cost:{input:0.435,output:0.87,cacheRead:0.003625,cacheWrite:0}}},{modelId:"essentialai/rnj-1-instruct",name:"EssentialAI: Rnj 1 Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:32768,maxTokens:4096,cost:{input:0.15,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"google/gemini-2.5-flash",name:"Google: Gemini 2.5 Flash",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65535,cost:{input:0.3,output:2.5,cacheRead:0.03,cacheWrite:0.083333}}},{modelId:"google/gemini-2.5-flash-lite",name:"Google: Gemini 2.5 Flash Lite",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65535,cost:{input:0.1,output:0.4,cacheRead:0.01,cacheWrite:0.083333}}},{modelId:"google/gemini-2.5-flash-lite-preview-09-2025",name:"Google: Gemini 2.5 Flash Lite Preview 09-2025",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65535,cost:{input:0.1,output:0.4,cacheRead:0.01,cacheWrite:0.083333}}},{modelId:"google/gemini-2.5-pro",name:"Google: Gemini 2.5 Pro",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0.375}}},{modelId:"google/gemini-2.5-pro-preview",name:"Google: Gemini 2.5 Pro Preview 06-05",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0.375}}},{modelId:"google/gemini-2.5-pro-preview-05-06",name:"Google: Gemini 2.5 Pro Preview 05-06",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65535,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0.375}}},{modelId:"google/gemini-3-flash-preview",name:"Google: Gemini 3 Flash Preview",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.5,output:3,cacheRead:0.05,cacheWrite:0.083333}}},{modelId:"google/gemini-3.1-flash-lite",name:"Google: Gemini 3.1 Flash Lite",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.25,output:1.5,cacheRead:0.025,cacheWrite:0.083333}}},{modelId:"google/gemini-3.1-flash-lite-preview",name:"Google: Gemini 3.1 Flash Lite Preview",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.25,output:1.5,cacheRead:0.025,cacheWrite:0.083333}}},{modelId:"google/gemini-3.1-pro-preview",name:"Google: Gemini 3.1 Pro Preview",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0.375}}},{modelId:"google/gemini-3.1-pro-preview-customtools",name:"Google: Gemini 3.1 Pro Preview Custom Tools",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048756,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0.375}}},{modelId:"google/gemini-3.5-flash",name:"Google: Gemini 3.5 Flash",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.5,output:9,cacheRead:0.15,cacheWrite:0.083333}}},{modelId:"google/gemma-3-12b-it",name:"Google: Gemma 3 12B",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:131072,maxTokens:16384,cost:{input:0.05,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"google/gemma-3-27b-it",name:"Google: Gemma 3 27B",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:131072,maxTokens:16384,cost:{input:0.08,output:0.16,cacheRead:0,cacheWrite:0}}},{modelId:"google/gemma-4-26b-a4b-it",name:"Google: Gemma 4 26B A4B ",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:4096,cost:{input:0.06,output:0.33,cacheRead:0,cacheWrite:0}}},{modelId:"google/gemma-4-26b-a4b-it:free",name:"Google: Gemma 4 26B A4B (free)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"google/gemma-4-31b-it",name:"Google: Gemma 4 31B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.12,output:0.35,cacheRead:0.09,cacheWrite:0}}},{modelId:"google/gemma-4-31b-it:free",name:"Google: Gemma 4 31B (free)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"ibm-granite/granite-4.1-8b",name:"IBM: Granite 4.1 8B",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.05,output:0.1,cacheRead:0.05,cacheWrite:0}}},{modelId:"inception/mercury-2",name:"Inception: Mercury 2",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:50000,cost:{input:0.25,output:0.75,cacheRead:0.025,cacheWrite:0}}},{modelId:"inclusionai/ling-2.6-1t",name:"inclusionAI: Ling-2.6-1T",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:0.075,output:0.625,cacheRead:0.015,cacheWrite:0}}},{modelId:"inclusionai/ling-2.6-flash",name:"inclusionAI: Ling-2.6-flash",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:0.01,output:0.03,cacheRead:0.002,cacheWrite:0}}},{modelId:"inclusionai/ring-2.6-1t",name:"inclusionAI: Ring-2.6-1T",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:0.075,output:0.625,cacheRead:0.015,cacheWrite:0}}},{modelId:"kwaipilot/kat-coder-pro-v2",name:"Kwaipilot: KAT-Coder-Pro V2",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:80000,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"meta-llama/llama-3.1-70b-instruct",name:"Meta: Llama 3.1 70B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.4,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"meta-llama/llama-3.1-8b-instruct",name:"Meta: Llama 3.1 8B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.02,output:0.03,cacheRead:0,cacheWrite:0}}},{modelId:"meta-llama/llama-3.3-70b-instruct",name:"Meta: Llama 3.3 70B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.1,output:0.32,cacheRead:0,cacheWrite:0}}},{modelId:"meta-llama/llama-3.3-70b-instruct:free",name:"Meta: Llama 3.3 70B Instruct (free)",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"meta-llama/llama-4-maverick",name:"Meta: Llama 4 Maverick",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:1048576,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"meta-llama/llama-4-scout",name:"Meta: Llama 4 Scout",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:1e7,maxTokens:16384,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"minimax/minimax-m1",name:"MiniMax: MiniMax M1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:40000,cost:{input:0.4,output:2.2,cacheRead:0,cacheWrite:0}}},{modelId:"minimax/minimax-m2",name:"MiniMax: MiniMax M2",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:196608,cost:{input:0.255,output:1,cacheRead:0.03,cacheWrite:0}}},{modelId:"minimax/minimax-m2.1",name:"MiniMax: MiniMax M2.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:196608,cost:{input:0.29,output:0.95,cacheRead:0.03,cacheWrite:0}}},{modelId:"minimax/minimax-m2.5",name:"MiniMax: MiniMax M2.5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:196608,cost:{input:0.15,output:0.9,cacheRead:0.05,cacheWrite:0}}},{modelId:"minimax/minimax-m2.7",name:"MiniMax: MiniMax M2.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.25,output:1,cacheRead:0.05,cacheWrite:0}}},{modelId:"minimax/minimax-m3",name:"MiniMax: MiniMax M3",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:512000,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"mistralai/codestral-2508",name:"Mistral: Codestral 2508",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:4096,cost:{input:0.3,output:0.9,cacheRead:0.03,cacheWrite:0}}},{modelId:"mistralai/devstral-2512",name:"Mistral: Devstral 2 2512",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:4096,cost:{input:0.4,output:2,cacheRead:0.04,cacheWrite:0}}},{modelId:"mistralai/ministral-14b-2512",name:"Mistral: Ministral 3 14B 2512",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:4096,cost:{input:0.2,output:0.2,cacheRead:0.02,cacheWrite:0}}},{modelId:"mistralai/ministral-3b-2512",name:"Mistral: Ministral 3 3B 2512",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:131072,maxTokens:4096,cost:{input:0.1,output:0.1,cacheRead:0.01,cacheWrite:0}}},{modelId:"mistralai/ministral-8b-2512",name:"Mistral: Ministral 3 8B 2512",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:4096,cost:{input:0.15,output:0.15,cacheRead:0.015,cacheWrite:0}}},{modelId:"mistralai/mistral-large",name:"Mistral Large",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:2,output:6,cacheRead:0.2,cacheWrite:0}}},{modelId:"mistralai/mistral-large-2407",name:"Mistral Large 2407",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:4096,cost:{input:2,output:6,cacheRead:0.2,cacheWrite:0}}},{modelId:"mistralai/mistral-large-2512",name:"Mistral: Mistral Large 3 2512",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:4096,cost:{input:0.5,output:1.5,cacheRead:0.05,cacheWrite:0}}},{modelId:"mistralai/mistral-medium-3",name:"Mistral: Mistral Medium 3",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:131072,maxTokens:4096,cost:{input:0.4,output:2,cacheRead:0.04,cacheWrite:0}}},{modelId:"mistralai/mistral-medium-3-5",name:"Mistral: Mistral Medium 3.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:4096,cost:{input:1.5,output:7.5,cacheRead:0,cacheWrite:0}}},{modelId:"mistralai/mistral-medium-3.1",name:"Mistral: Mistral Medium 3.1",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:131072,maxTokens:4096,cost:{input:0.4,output:2,cacheRead:0.04,cacheWrite:0}}},{modelId:"mistralai/mistral-nemo",name:"Mistral: Mistral Nemo",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:4096,cost:{input:0.02,output:0.03,cacheRead:0,cacheWrite:0}}},{modelId:"mistralai/mistral-saba",name:"Mistral: Saba",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:32768,maxTokens:4096,cost:{input:0.2,output:0.6,cacheRead:0.02,cacheWrite:0}}},{modelId:"mistralai/mistral-small-2603",name:"Mistral: Mistral Small 4",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:4096,cost:{input:0.15,output:0.6,cacheRead:0.015,cacheWrite:0}}},{modelId:"mistralai/mistral-small-3.2-24b-instruct",name:"Mistral: Mistral Small 3.2 24B",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:0.075,output:0.2,cacheRead:0,cacheWrite:0}}},{modelId:"mistralai/mixtral-8x22b-instruct",name:"Mistral: Mixtral 8x22B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:65536,maxTokens:4096,cost:{input:2,output:6,cacheRead:0.2,cacheWrite:0}}},{modelId:"mistralai/voxtral-small-24b-2507",name:"Mistral: Voxtral Small 24B 2507",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:32000,maxTokens:4096,cost:{input:0.1,output:0.3,cacheRead:0.01,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2",name:"MoonshotAI: Kimi K2 0711",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:32768,cost:{input:0.57,output:2.3,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2-0905",name:"MoonshotAI: Kimi K2 0905",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:2.5,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2-thinking",name:"MoonshotAI: Kimi K2 Thinking",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:2.5,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2.5",name:"MoonshotAI: Kimi K2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:4096,cost:{input:0.41,output:2.06,cacheRead:0.07,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2.6",name:"MoonshotAI: Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262142,cost:{input:0.68,output:3.41,cacheRead:0.34,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2.7-code",name:"MoonshotAI: Kimi K2.7 Code",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.75,output:3.5,cacheRead:0.16,cacheWrite:0}}},{modelId:"nex-agi/nex-n2-pro:free",name:"Nex AGI: Nex-N2-Pro (free)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/llama-3.3-nemotron-super-49b-v1.5",name:"NVIDIA: Llama 3.3 Nemotron Super 49B V1.5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.4,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-nano-30b-a3b",name:"NVIDIA: Nemotron 3 Nano 30B A3B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:228000,cost:{input:0.05,output:0.2,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-nano-30b-a3b:free",name:"NVIDIA: Nemotron 3 Nano 30B A3B (free)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning:free",name:"NVIDIA: Nemotron 3 Nano Omni (free)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:65536,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-super-120b-a12b",name:"NVIDIA: Nemotron 3 Super",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:4096,cost:{input:0.09,output:0.45,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-super-120b-a12b:free",name:"NVIDIA: Nemotron 3 Super (free)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:262144,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-ultra-550b-a55b",name:"NVIDIA: Nemotron 3 Ultra",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:16384,cost:{input:0.5,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-ultra-550b-a55b:free",name:"NVIDIA: Nemotron 3 Ultra (free)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:65536,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-nano-12b-v2-vl:free",name:"NVIDIA: Nemotron Nano 12B 2 VL (free)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:128000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-nano-9b-v2:free",name:"NVIDIA: Nemotron Nano 9B V2 (free)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-3.5-turbo",name:"OpenAI: GPT-3.5 Turbo",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:16385,maxTokens:4096,cost:{input:0.5,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-3.5-turbo-0613",name:"OpenAI: GPT-3.5 Turbo (older v0613)",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:4095,maxTokens:4096,cost:{input:1,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-3.5-turbo-16k",name:"OpenAI: GPT-3.5 Turbo 16k",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:16385,maxTokens:4096,cost:{input:3,output:4,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-4",name:"OpenAI: GPT-4",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:8191,maxTokens:4096,cost:{input:30,output:60,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-4-turbo",name:"OpenAI: GPT-4 Turbo",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:10,output:30,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-4-turbo-preview",name:"OpenAI: GPT-4 Turbo Preview",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:10,output:30,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-4.1",name:"OpenAI: GPT-4.1",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:4096,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"openai/gpt-4.1-mini",name:"OpenAI: GPT-4.1 Mini",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:0.4,output:1.6,cacheRead:0.1,cacheWrite:0}}},{modelId:"openai/gpt-4.1-nano",name:"OpenAI: GPT-4.1 Nano",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:0.1,output:0.4,cacheRead:0.025,cacheWrite:0}}},{modelId:"openai/gpt-4o",name:"OpenAI: GPT-4o",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-4o-2024-05-13",name:"OpenAI: GPT-4o (2024-05-13)",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:5,output:15,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-4o-2024-08-06",name:"OpenAI: GPT-4o (2024-08-06)",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"openai/gpt-4o-2024-11-20",name:"OpenAI: GPT-4o (2024-11-20)",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"openai/gpt-4o-mini",name:"OpenAI: GPT-4o-mini",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0.075,cacheWrite:0}}},{modelId:"openai/gpt-4o-mini-2024-07-18",name:"OpenAI: GPT-4o-mini (2024-07-18)",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0.075,cacheWrite:0}}},{modelId:"openai/gpt-5",name:"OpenAI: GPT-5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5-codex",name:"OpenAI: GPT-5 Codex",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5-mini",name:"OpenAI: GPT-5 Mini",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"openai/gpt-5-nano",name:"OpenAI: GPT-5 Nano",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:4096,cost:{input:0.05,output:0.4,cacheRead:0.01,cacheWrite:0}}},{modelId:"openai/gpt-5-pro",name:"OpenAI: GPT-5 Pro",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:15,output:120,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-5.1",name:"OpenAI: GPT-5.1",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.13,cacheWrite:0}}},{modelId:"openai/gpt-5.1-chat",name:"OpenAI: GPT-5.1 Chat",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:32000,cost:{input:1.25,output:10,cacheRead:0.13,cacheWrite:0}}},{modelId:"openai/gpt-5.1-codex",name:"OpenAI: GPT-5.1-Codex",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.13,cacheWrite:0}}},{modelId:"openai/gpt-5.1-codex-max",name:"OpenAI: GPT-5.1-Codex-Max",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5.1-codex-mini",name:"OpenAI: GPT-5.1-Codex-Mini",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:1e5,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"openai/gpt-5.2",name:"OpenAI: GPT-5.2",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.2-chat",name:"OpenAI: GPT-5.2 Chat",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.2-codex",name:"OpenAI: GPT-5.2-Codex",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.2-pro",name:"OpenAI: GPT-5.2 Pro",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:21,output:168,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-5.3-chat",name:"OpenAI: GPT-5.3 Chat",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.3-codex",name:"OpenAI: GPT-5.3-Codex",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.4",name:"OpenAI: GPT-5.4",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:2.5,output:15,cacheRead:0.25,cacheWrite:0}}},{modelId:"openai/gpt-5.4-mini",name:"OpenAI: GPT-5.4 Mini",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.75,output:4.5,cacheRead:0.075,cacheWrite:0}}},{modelId:"openai/gpt-5.4-nano",name:"OpenAI: GPT-5.4 Nano",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.2,output:1.25,cacheRead:0.02,cacheWrite:0}}},{modelId:"openai/gpt-5.4-pro",name:"OpenAI: GPT-5.4 Pro",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-5.5",name:"OpenAI: GPT-5.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"openai/gpt-5.5-pro",name:"OpenAI: GPT-5.5 Pro",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-audio",name:"OpenAI: GPT Audio",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-audio-mini",name:"OpenAI: GPT Audio Mini",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.6,output:2.4,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-chat-latest",name:"OpenAI: GPT Chat Latest",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"openai/gpt-oss-120b",name:"OpenAI: gpt-oss-120b",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:4096,cost:{input:0.039,output:0.18,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-120b:free",name:"OpenAI: gpt-oss-120b (free)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-20b",name:"OpenAI: gpt-oss-20b",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:4096,cost:{input:0.029,output:0.14,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-20b:free",name:"OpenAI: gpt-oss-20b (free)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:8192,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-safeguard-20b",name:"OpenAI: gpt-oss-safeguard-20b",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:65536,cost:{input:0.075,output:0.3,cacheRead:0.037,cacheWrite:0}}},{modelId:"openai/o1",name:"OpenAI: o1",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0}}},{modelId:"openai/o3",name:"OpenAI: o3",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"openai/o3-deep-research",name:"OpenAI: o3 Deep Research",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0}}},{modelId:"openai/o3-mini",name:"OpenAI: o3 Mini",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.55,cacheWrite:0}}},{modelId:"openai/o3-mini-high",name:"OpenAI: o3 Mini High",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.55,cacheWrite:0}}},{modelId:"openai/o3-pro",name:"OpenAI: o3 Pro",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:20,output:80,cacheRead:0,cacheWrite:0}}},{modelId:"openai/o4-mini",name:"OpenAI: o4 Mini",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.275,cacheWrite:0}}},{modelId:"openai/o4-mini-deep-research",name:"OpenAI: o4 Mini Deep Research",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"openai/o4-mini-high",name:"OpenAI: o4 Mini High",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.275,cacheWrite:0}}},{modelId:"openrouter/auto",name:"Auto Router",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:2000000,maxTokens:4096,cost:{input:-1e6,output:-1e6,cacheRead:0,cacheWrite:0}}},{modelId:"openrouter/free",name:"Free Models Router",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"openrouter/owl-alpha",name:"Owl Alpha",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:1048756,maxTokens:262144,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"poolside/laguna-m.1:free",name:"Poolside: Laguna M.1 (free)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"poolside/laguna-xs.2:free",name:"Poolside: Laguna XS.2 (free)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"prime-intellect/intellect-3",name:"Prime Intellect: INTELLECT-3",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.2,output:1.1,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen-2.5-72b-instruct",name:"Qwen2.5 72B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.36,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen-plus",name:"Qwen: Qwen-Plus",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:1e6,maxTokens:32768,cost:{input:0.26,output:0.78,cacheRead:0.052,cacheWrite:0.325}}},{modelId:"qwen/qwen-plus-2025-07-28",name:"Qwen: Qwen Plus 0728",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:1e6,maxTokens:32768,cost:{input:0.26,output:0.78,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen-plus-2025-07-28:thinking",name:"Qwen: Qwen Plus 0728 (thinking)",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:32768,cost:{input:0.26,output:0.78,cacheRead:0,cacheWrite:0.325}}},{modelId:"qwen/qwen3-14b",name:"Qwen: Qwen3 14B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131702,maxTokens:40960,cost:{input:0.1,output:0.24,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-235b-a22b",name:"Qwen: Qwen3 235B A22B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:8192,cost:{input:0.455,output:1.82,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-235b-a22b-2507",name:"Qwen: Qwen3 235B A22B Instruct 2507",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:16384,cost:{input:0.09,output:0.1,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-235b-a22b-thinking-2507",name:"Qwen: Qwen3 235B A22B Thinking 2507",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.1,output:0.1,cacheRead:0.1,cacheWrite:0}}},{modelId:"qwen/qwen3-30b-a3b",name:"Qwen: Qwen3 30B A3B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.12,output:0.5,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-30b-a3b-instruct-2507",name:"Qwen: Qwen3 30B A3B Instruct 2507",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:32000,cost:{input:0.04815,output:0.19305,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-30b-a3b-thinking-2507",name:"Qwen: Qwen3 30B A3B Thinking 2507",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.08,output:0.4,cacheRead:0.08,cacheWrite:0}}},{modelId:"qwen/qwen3-32b",name:"Qwen: Qwen3 32B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.08,output:0.28,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-8b",name:"Qwen: Qwen3 8B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:8192,cost:{input:0.05,output:0.4,cacheRead:0.05,cacheWrite:0}}},{modelId:"qwen/qwen3-coder",name:"Qwen: Qwen3 Coder 480B A35B",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:1048576,maxTokens:65536,cost:{input:0.22,output:1.8,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-coder-30b-a3b-instruct",name:"Qwen: Qwen3 Coder 30B A3B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:160000,maxTokens:32768,cost:{input:0.07,output:0.27,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-coder-flash",name:"Qwen: Qwen3 Coder Flash",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:1e6,maxTokens:65536,cost:{input:0.195,output:0.975,cacheRead:0.039,cacheWrite:0.24375}}},{modelId:"qwen/qwen3-coder-next",name:"Qwen: Qwen3 Coder Next",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.11,output:0.8,cacheRead:0.07,cacheWrite:0}}},{modelId:"qwen/qwen3-coder-plus",name:"Qwen: Qwen3 Coder Plus",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:1e6,maxTokens:65536,cost:{input:0.65,output:3.25,cacheRead:0.13,cacheWrite:0.8125}}},{modelId:"qwen/qwen3-coder:free",name:"Qwen: Qwen3 Coder 480B A35B (free)",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:1048576,maxTokens:262000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-max",name:"Qwen: Qwen3 Max",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:0.78,output:3.9,cacheRead:0.156,cacheWrite:0.975}}},{modelId:"qwen/qwen3-max-thinking",name:"Qwen: Qwen3 Max Thinking",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:0.78,output:3.9,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-next-80b-a3b-instruct",name:"Qwen: Qwen3 Next 80B A3B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:16384,cost:{input:0.09,output:1.1,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-next-80b-a3b-instruct:free",name:"Qwen: Qwen3 Next 80B A3B Instruct (free)",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-next-80b-a3b-thinking",name:"Qwen: Qwen3 Next 80B A3B Thinking",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:0.0975,output:0.78,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-vl-235b-a22b-instruct",name:"Qwen: Qwen3 VL 235B A22B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:16384,cost:{input:0.2,output:0.88,cacheRead:0.11,cacheWrite:0}}},{modelId:"qwen/qwen3-vl-235b-a22b-thinking",name:"Qwen: Qwen3 VL 235B A22B Thinking",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:131072,maxTokens:32768,cost:{input:0.26,output:2.6,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-vl-30b-a3b-instruct",name:"Qwen: Qwen3 VL 30B A3B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0.13,output:0.52,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-vl-30b-a3b-thinking",name:"Qwen: Qwen3 VL 30B A3B Thinking",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:131072,maxTokens:32768,cost:{input:0.13,output:1.56,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-vl-32b-instruct",name:"Qwen: Qwen3 VL 32B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0.104,output:0.416,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-vl-8b-instruct",name:"Qwen: Qwen3 VL 8B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:256000,maxTokens:32768,cost:{input:0.08,output:0.5,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3-vl-8b-thinking",name:"Qwen: Qwen3 VL 8B Thinking",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:32768,cost:{input:0.117,output:1.365,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.5-122b-a10b",name:"Qwen: Qwen3.5-122B-A10B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.26,output:2.08,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.5-27b",name:"Qwen: Qwen3.5-27B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.195,output:1.56,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.5-35b-a3b",name:"Qwen: Qwen3.5-35B-A3B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.14,output:1,cacheRead:0.05,cacheWrite:0}}},{modelId:"qwen/qwen3.5-397b-a17b",name:"Qwen: Qwen3.5 397B A17B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.39,output:2.34,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.5-9b",name:"Qwen: Qwen3.5-9B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.1,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.5-flash-02-23",name:"Qwen: Qwen3.5-Flash",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.065,output:0.26,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.5-plus-02-15",name:"Qwen: Qwen3.5 Plus 2026-02-15",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.26,output:1.56,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.5-plus-20260420",name:"Qwen: Qwen3.5 Plus 2026-04-20",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.3,output:1.8,cacheRead:0,cacheWrite:0.375}}},{modelId:"qwen/qwen3.6-27b",name:"Qwen: Qwen3.6 27B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262140,cost:{input:0.2885,output:3.17,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.6-35b-a3b",name:"Qwen: Qwen3.6 35B A3B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.15,output:1,cacheRead:0.05,cacheWrite:0}}},{modelId:"qwen/qwen3.6-flash",name:"Qwen: Qwen3.6 Flash",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.1875,output:1.125,cacheRead:0,cacheWrite:0.234375}}},{modelId:"qwen/qwen3.6-max-preview",name:"Qwen: Qwen3.6 Max Preview",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:1.04,output:6.24,cacheRead:0,cacheWrite:1.3}}},{modelId:"qwen/qwen3.6-plus",name:"Qwen: Qwen3.6 Plus",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.325,output:1.95,cacheRead:0,cacheWrite:0.40625}}},{modelId:"qwen/qwen3.7-max",name:"Qwen: Qwen3.7 Max",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:65536,cost:{input:1.25,output:3.75,cacheRead:0.25,cacheWrite:1.5625}}},{modelId:"qwen/qwen3.7-plus",name:"Qwen: Qwen3.7 Plus",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.32,output:1.28,cacheRead:0.064,cacheWrite:0.4}}},{modelId:"rekaai/reka-edge",name:"Reka Edge",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:16384,maxTokens:16384,cost:{input:0.1,output:0.1,cacheRead:0,cacheWrite:0}}},{modelId:"relace/relace-search",name:"Relace: Relace Search",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:128000,cost:{input:1,output:3,cacheRead:0,cacheWrite:0}}},{modelId:"sao10k/l3.1-euryale-70b",name:"Sao10K: Llama 3.1 Euryale 70B v2.2",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.85,output:0.85,cacheRead:0,cacheWrite:0}}},{modelId:"stepfun/step-3.5-flash",name:"StepFun: Step 3.5 Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:16384,cost:{input:0.09,output:0.3,cacheRead:0.02,cacheWrite:0}}},{modelId:"stepfun/step-3.7-flash",name:"StepFun: Step 3.7 Flash",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:0.2,output:1.15,cacheRead:0.04,cacheWrite:0}}},{modelId:"tencent/hy3-preview",name:"Tencent: Hy3 preview",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:4096,cost:{input:0.063,output:0.21,cacheRead:0.021,cacheWrite:0}}},{modelId:"thedrummer/rocinante-12b",name:"TheDrummer: Rocinante 12B",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:32768,maxTokens:32768,cost:{input:0.17,output:0.43,cacheRead:0,cacheWrite:0}}},{modelId:"thedrummer/unslopnemo-12b",name:"TheDrummer: UnslopNemo 12B",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:32768,maxTokens:32768,cost:{input:0.4,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"upstage/solar-pro-3",name:"Upstage: Solar Pro 3",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.15,output:0.6,cacheRead:0.015,cacheWrite:0}}},{modelId:"x-ai/grok-4.20",name:"xAI: Grok 4.20",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:2000000,maxTokens:4096,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"x-ai/grok-4.3",name:"xAI: Grok 4.3",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:4096,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"x-ai/grok-build-0.1",name:"xAI: Grok Build 0.1",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:4096,cost:{input:1,output:2,cacheRead:0.2,cacheWrite:0}}},{modelId:"xiaomi/mimo-v2-flash",name:"Xiaomi: MiMo-V2-Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:0.1,output:0.3,cacheRead:0.01,cacheWrite:0}}},{modelId:"xiaomi/mimo-v2.5",name:"Xiaomi: MiMo-V2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:131072,cost:{input:0.14,output:0.28,cacheRead:0.0028,cacheWrite:0}}},{modelId:"xiaomi/mimo-v2.5-pro",name:"Xiaomi: MiMo-V2.5-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:0.435,output:0.87,cacheRead:0.0036,cacheWrite:0}}},{modelId:"z-ai/glm-4.5",name:"Z.ai: GLM 4.5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:98304,cost:{input:0.6,output:2.2,cacheRead:0.11,cacheWrite:0}}},{modelId:"z-ai/glm-4.5-air",name:"Z.ai: GLM 4.5 Air",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131070,cost:{input:0.125,output:0.85,cacheRead:0.06,cacheWrite:0}}},{modelId:"z-ai/glm-4.5v",name:"Z.ai: GLM 4.5V",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:65536,maxTokens:16384,cost:{input:0.6,output:1.8,cacheRead:0.11,cacheWrite:0}}},{modelId:"z-ai/glm-4.6",name:"Z.ai: GLM 4.6",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:131072,cost:{input:0.43,output:1.74,cacheRead:0.08,cacheWrite:0}}},{modelId:"z-ai/glm-4.6v",name:"Z.ai: GLM 4.6V",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:131072,maxTokens:32768,cost:{input:0.3,output:0.9,cacheRead:0.055,cacheWrite:0}}},{modelId:"z-ai/glm-4.7",name:"Z.ai: GLM 4.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:131072,cost:{input:0.4,output:1.75,cacheRead:0.08,cacheWrite:0}}},{modelId:"z-ai/glm-4.7-flash",name:"Z.ai: GLM 4.7 Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:16384,cost:{input:0.06,output:0.4,cacheRead:0.01,cacheWrite:0}}},{modelId:"z-ai/glm-5",name:"Z.ai: GLM 5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:4096,cost:{input:0.6,output:1.9,cacheRead:0.119,cacheWrite:0}}},{modelId:"z-ai/glm-5-turbo",name:"Z.ai: GLM 5 Turbo",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:131072,cost:{input:1.2,output:4,cacheRead:0.24,cacheWrite:0}}},{modelId:"z-ai/glm-5.1",name:"Z.ai: GLM 5.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:4096,cost:{input:0.98,output:3.08,cacheRead:0.182,cacheWrite:0}}},{modelId:"~anthropic/claude-fable-latest",name:"Anthropic: Claude Fable Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5}}},{modelId:"~anthropic/claude-haiku-latest",name:"Anthropic Claude Haiku Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"~anthropic/claude-opus-latest",name:"Anthropic: Claude Opus Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"~anthropic/claude-sonnet-latest",name:"Anthropic Claude Sonnet Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"~google/gemini-flash-latest",name:"Google Gemini Flash Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.5,output:9,cacheRead:0.15,cacheWrite:0.083333}}},{modelId:"~google/gemini-pro-latest",name:"Google Gemini Pro Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0.375}}},{modelId:"~moonshotai/kimi-latest",name:"MoonshotAI Kimi Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262142,cost:{input:0.68,output:3.41,cacheRead:0.34,cacheWrite:0}}},{modelId:"~openai/gpt-latest",name:"OpenAI GPT Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"~openai/gpt-mini-latest",name:"OpenAI GPT Mini Latest",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.75,output:4.5,cacheRead:0.075,cacheWrite:0}}}]},mistral:{name:"mistral",config:{api:"mistral-conversations",baseUrl:"https://api.mistral.ai",apiKey:"MISTRAL_API_KEY"},models:[{modelId:"codestral-latest",name:"Codestral (latest)",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:4096,cost:{input:0.3,output:0.9,cacheRead:0,cacheWrite:0}}},{modelId:"devstral-2512",name:"Devstral 2",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"devstral-latest",name:"Devstral 2",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"devstral-medium-2507",name:"Devstral Medium",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"devstral-medium-latest",name:"Devstral 2 (latest)",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"devstral-small-2505",name:"Devstral Small 2505",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"devstral-small-2507",name:"Devstral Small",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"labs-devstral-small-2512",name:"Devstral Small 2",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"magistral-medium-latest",name:"Magistral Medium (latest)",config:{api:"mistral-conversations",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:2,output:5,cacheRead:0,cacheWrite:0}}},{modelId:"magistral-small",name:"Magistral Small",config:{api:"mistral-conversations",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.5,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"ministral-3b-latest",name:"Ministral 3B (latest)",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.04,output:0.04,cacheRead:0,cacheWrite:0}}},{modelId:"ministral-8b-latest",name:"Ministral 8B (latest)",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.1,output:0.1,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-large-2411",name:"Mistral Large 2.1",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:2,output:6,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-large-2512",name:"Mistral Large 3",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.5,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-large-latest",name:"Mistral Large (latest)",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.5,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-medium-2505",name:"Mistral Medium 3",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:131072,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-medium-2508",name:"Mistral Medium 3.1",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-medium-2604",name:"Mistral Medium 3.5",config:{api:"mistral-conversations",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:1.5,output:7.5,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-medium-3.5",name:"Mistral Medium 3.5",config:{api:"mistral-conversations",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:1.5,output:7.5,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-medium-latest",name:"Mistral Medium (latest)",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-nemo",name:"Mistral Nemo",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.15,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-small-2506",name:"Mistral Small 3.2",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-small-2603",name:"Mistral Small 4",config:{api:"mistral-conversations",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"mistral-small-latest",name:"Mistral Small (latest)",config:{api:"mistral-conversations",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"open-mistral-7b",name:"Mistral 7B",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:8000,maxTokens:8000,cost:{input:0.25,output:0.25,cacheRead:0,cacheWrite:0}}},{modelId:"open-mistral-nemo",name:"Open Mistral Nemo",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.15,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"open-mixtral-8x22b",name:"Mixtral 8x22B",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:64000,maxTokens:64000,cost:{input:2,output:6,cacheRead:0,cacheWrite:0}}},{modelId:"open-mixtral-8x7b",name:"Mixtral 8x7B",config:{api:"mistral-conversations",reasoning:!1,input:["text"],contextWindow:32000,maxTokens:32000,cost:{input:0.7,output:0.7,cacheRead:0,cacheWrite:0}}},{modelId:"pixtral-12b",name:"Pixtral 12B",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:128000,cost:{input:0.15,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"pixtral-large-latest",name:"Pixtral Large (latest)",config:{api:"mistral-conversations",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:128000,cost:{input:2,output:6,cacheRead:0,cacheWrite:0}}}]},"amazon-bedrock":{name:"amazon-bedrock",config:{api:"bedrock-converse-stream",baseUrl:"https://bedrock-runtime.us-east-1.amazonaws.com",apiKey:""},models:[{modelId:"amazon.nova-2-lite-v1:0",name:"Nova 2 Lite",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:0.33,output:2.75,cacheRead:0,cacheWrite:0}}},{modelId:"amazon.nova-lite-v1:0",name:"Nova Lite",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:300000,maxTokens:8192,cost:{input:0.06,output:0.24,cacheRead:0.015,cacheWrite:0}}},{modelId:"amazon.nova-micro-v1:0",name:"Nova Micro",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:8192,cost:{input:0.035,output:0.14,cacheRead:0.00875,cacheWrite:0}}},{modelId:"amazon.nova-pro-v1:0",name:"Nova Pro",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:300000,maxTokens:8192,cost:{input:0.8,output:3.2,cacheRead:0.2,cacheWrite:0}}},{modelId:"anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"anthropic.claude-opus-4-1-20250805-v1:0",name:"Claude Opus 4.1",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic.claude-opus-4-7",name:"Claude Opus 4.7",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic.claude-opus-4-8",name:"Claude Opus 4.8",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"au.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (AU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"au.anthropic.claude-opus-4-6-v1",name:"AU Anthropic Claude Opus 4.6",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:16.5,output:82.5,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"au.anthropic.claude-opus-4-8",name:"Claude Opus 4.8 (AU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"au.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (AU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"au.anthropic.claude-sonnet-4-6",name:"AU Anthropic Claude Sonnet 4.6",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:3.3,output:16.5,cacheRead:0.33,cacheWrite:4.125}}},{modelId:"deepseek.r1-v1:0",name:"DeepSeek-R1",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:32768,cost:{input:1.35,output:5.4,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek.v3-v1:0",name:"DeepSeek-V3.1",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:81920,cost:{input:0.58,output:1.68,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek.v3.2",name:"DeepSeek-V3.2",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:81920,cost:{input:0.62,output:1.85,cacheRead:0,cacheWrite:0}}},{modelId:"eu.anthropic.claude-fable-5",name:"Claude Fable 5 (EU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:11,output:55,cacheRead:1.1,cacheWrite:13.75}}},{modelId:"eu.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (EU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"eu.anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5 (EU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"eu.anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6 (EU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5.5,output:27.5,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"eu.anthropic.claude-opus-4-7",name:"Claude Opus 4.7 (EU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5.5,output:27.5,cacheRead:0.55,cacheWrite:6.875}}},{modelId:"eu.anthropic.claude-opus-4-8",name:"Claude Opus 4.8 (EU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5.5,output:27.5,cacheRead:0.55,cacheWrite:6.875}}},{modelId:"eu.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (EU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3.3,output:16.5,cacheRead:0.33,cacheWrite:4.125}}},{modelId:"eu.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (EU)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3.3,output:16.5,cacheRead:0.33,cacheWrite:4.125}}},{modelId:"global.anthropic.claude-fable-5",name:"Claude Fable 5 (Global)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5}}},{modelId:"global.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (Global)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"global.anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5 (Global)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"global.anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6 (Global)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"global.anthropic.claude-opus-4-7",name:"Claude Opus 4.7 (Global)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"global.anthropic.claude-opus-4-8",name:"Claude Opus 4.8 (Global)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"global.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (Global)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"global.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (Global)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"google.gemma-3-27b-it",name:"Google Gemma 3 27B Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:202752,maxTokens:8192,cost:{input:0.12,output:0.2,cacheRead:0,cacheWrite:0}}},{modelId:"google.gemma-3-4b-it",name:"Gemma 3 4B IT",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:0.04,output:0.08,cacheRead:0,cacheWrite:0}}},{modelId:"jp.anthropic.claude-opus-4-7",name:"Claude Opus 4.7 (JP)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"jp.anthropic.claude-opus-4-8",name:"Claude Opus 4.8 (JP)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"jp.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (JP)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"jp.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (JP)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"meta.llama3-1-70b-instruct-v1:0",name:"Llama 3.1 70B Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.72,output:0.72,cacheRead:0,cacheWrite:0}}},{modelId:"meta.llama3-1-8b-instruct-v1:0",name:"Llama 3.1 8B Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.22,output:0.22,cacheRead:0,cacheWrite:0}}},{modelId:"meta.llama3-3-70b-instruct-v1:0",name:"Llama 3.3 70B Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.72,output:0.72,cacheRead:0,cacheWrite:0}}},{modelId:"meta.llama4-maverick-17b-instruct-v1:0",name:"Llama 4 Maverick 17B Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:1e6,maxTokens:16384,cost:{input:0.24,output:0.97,cacheRead:0,cacheWrite:0}}},{modelId:"meta.llama4-scout-17b-instruct-v1:0",name:"Llama 4 Scout 17B Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:3500000,maxTokens:16384,cost:{input:0.17,output:0.66,cacheRead:0,cacheWrite:0}}},{modelId:"minimax.minimax-m2",name:"MiniMax M2",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:204608,maxTokens:128000,cost:{input:0.3,output:1.2,cacheRead:0,cacheWrite:0}}},{modelId:"minimax.minimax-m2.1",name:"MiniMax M2.1",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0,cacheWrite:0}}},{modelId:"minimax.minimax-m2.5",name:"MiniMax M2.5",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:196608,maxTokens:98304,cost:{input:0.3,output:1.2,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.devstral-2-123b",name:"Devstral 2 123B",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:8192,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.magistral-small-2509",name:"Magistral Small 1.2",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:40000,cost:{input:0.5,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.ministral-3-14b-instruct",name:"Ministral 14B 3.0",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.2,output:0.2,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.ministral-3-3b-instruct",name:"Ministral 3 3B",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:256000,maxTokens:8192,cost:{input:0.1,output:0.1,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.ministral-3-8b-instruct",name:"Ministral 3 8B",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.15,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.mistral-large-3-675b-instruct",name:"Mistral Large 3",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:256000,maxTokens:8192,cost:{input:0.5,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.pixtral-large-2502-v1:0",name:"Pixtral Large (25.02)",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:8192,cost:{input:2,output:6,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.voxtral-mini-3b-2507",name:"Voxtral Mini 3B 2507",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.04,output:0.04,cacheRead:0,cacheWrite:0}}},{modelId:"mistral.voxtral-small-24b-2507",name:"Voxtral Small 24B 2507",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:32000,maxTokens:8192,cost:{input:0.15,output:0.35,cacheRead:0,cacheWrite:0}}},{modelId:"moonshot.kimi-k2-thinking",name:"Kimi K2 Thinking",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:262143,maxTokens:16000,cost:{input:0.6,output:2.5,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai.kimi-k2.5",name:"Kimi K2.5",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:262143,maxTokens:16000,cost:{input:0.6,output:3,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia.nemotron-nano-12b-v2",name:"NVIDIA Nemotron Nano 12B v2 VL BF16",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:0.2,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia.nemotron-nano-3-30b",name:"NVIDIA Nemotron Nano 3 30B",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.06,output:0.24,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia.nemotron-nano-9b-v2",name:"NVIDIA Nemotron Nano 9B v2",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0.06,output:0.23,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia.nemotron-super-3-120b",name:"NVIDIA Nemotron 3 Super 120B A12B",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:131072,cost:{input:0.15,output:0.65,cacheRead:0,cacheWrite:0}}},{modelId:"openai.gpt-5.4",name:"GPT-5.4",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:272000,maxTokens:128000,cost:{input:2.75,output:16.5,cacheRead:0.275,cacheWrite:0}}},{modelId:"openai.gpt-5.5",name:"GPT-5.5",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:272000,maxTokens:128000,cost:{input:5.5,output:33,cacheRead:0.55,cacheWrite:0}}},{modelId:"openai.gpt-oss-120b",name:"gpt-oss-120b",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"openai.gpt-oss-120b-1:0",name:"gpt-oss-120b",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"openai.gpt-oss-20b",name:"gpt-oss-20b",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.07,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"openai.gpt-oss-20b-1:0",name:"gpt-oss-20b",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.07,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"openai.gpt-oss-safeguard-120b",name:"GPT OSS Safeguard 120B",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"openai.gpt-oss-safeguard-20b",name:"GPT OSS Safeguard 20B",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.07,output:0.2,cacheRead:0,cacheWrite:0}}},{modelId:"qwen.qwen3-235b-a22b-2507-v1:0",name:"Qwen3 235B A22B 2507",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:131072,cost:{input:0.22,output:0.88,cacheRead:0,cacheWrite:0}}},{modelId:"qwen.qwen3-32b-v1:0",name:"Qwen3 32B (dense)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:16384,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"qwen.qwen3-coder-30b-a3b-v1:0",name:"Qwen3 Coder 30B A3B Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:131072,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"qwen.qwen3-coder-480b-a35b-v1:0",name:"Qwen3 Coder 480B A35B Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:65536,cost:{input:0.22,output:1.8,cacheRead:0,cacheWrite:0}}},{modelId:"qwen.qwen3-coder-next",name:"Qwen3 Coder Next",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:65536,cost:{input:0.22,output:1.8,cacheRead:0,cacheWrite:0}}},{modelId:"qwen.qwen3-next-80b-a3b",name:"Qwen/Qwen3-Next-80B-A3B-Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text"],contextWindow:262000,maxTokens:262000,cost:{input:0.14,output:1.4,cacheRead:0,cacheWrite:0}}},{modelId:"qwen.qwen3-vl-235b-a22b",name:"Qwen/Qwen3-VL-235B-A22B-Instruct",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:262000,maxTokens:262000,cost:{input:0.3,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"us.anthropic.claude-fable-5",name:"Claude Fable 5 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5}}},{modelId:"us.anthropic.claude-haiku-4-5-20251001-v1:0",name:"Claude Haiku 4.5 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"us.anthropic.claude-opus-4-1-20250805-v1:0",name:"Claude Opus 4.1 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"us.anthropic.claude-opus-4-5-20251101-v1:0",name:"Claude Opus 4.5 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"us.anthropic.claude-opus-4-6-v1",name:"Claude Opus 4.6 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"us.anthropic.claude-opus-4-7",name:"Claude Opus 4.7 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"us.anthropic.claude-opus-4-8",name:"Claude Opus 4.8 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"us.anthropic.claude-sonnet-4-5-20250929-v1:0",name:"Claude Sonnet 4.5 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"us.anthropic.claude-sonnet-4-6",name:"Claude Sonnet 4.6 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"us.deepseek.r1-v1:0",name:"DeepSeek-R1 (US)",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:32768,cost:{input:1.35,output:5.4,cacheRead:0,cacheWrite:0}}},{modelId:"us.meta.llama4-maverick-17b-instruct-v1:0",name:"Llama 4 Maverick 17B Instruct (US)",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:1e6,maxTokens:16384,cost:{input:0.24,output:0.97,cacheRead:0,cacheWrite:0}}},{modelId:"us.meta.llama4-scout-17b-instruct-v1:0",name:"Llama 4 Scout 17B Instruct (US)",config:{api:"bedrock-converse-stream",reasoning:!1,input:["text","image"],contextWindow:3500000,maxTokens:16384,cost:{input:0.17,output:0.66,cacheRead:0,cacheWrite:0}}},{modelId:"writer.palmyra-x4-v1:0",name:"Palmyra X4",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:122880,maxTokens:8192,cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0}}},{modelId:"writer.palmyra-x5-v1:0",name:"Palmyra X5",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:1040000,maxTokens:8192,cost:{input:0.6,output:6,cacheRead:0,cacheWrite:0}}},{modelId:"zai.glm-4.7",name:"GLM-4.7",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.6,output:2.2,cacheRead:0,cacheWrite:0}}},{modelId:"zai.glm-4.7-flash",name:"GLM-4.7-Flash",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:131072,cost:{input:0.07,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"zai.glm-5",name:"GLM-5",config:{api:"bedrock-converse-stream",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:101376,cost:{input:1,output:3.2,cacheRead:0,cacheWrite:0}}}]},"ant-ling":{name:"ant-ling",config:{api:"openai-completions",baseUrl:"https://api.ant-ling.com/v1",apiKey:""},models:[{modelId:"Ling-2.6-1T",name:"Ling 2.6 1T",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:0.06,output:0.25,cacheRead:0,cacheWrite:0}}},{modelId:"Ling-2.6-flash",name:"Ling 2.6 Flash",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:0.01,output:0.02,cacheRead:0,cacheWrite:0}}},{modelId:"Ring-2.6-1T",name:"Ring 2.6 1T",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:0.06,output:0.25,cacheRead:0,cacheWrite:0}}}]},"azure-openai-responses":{name:"azure-openai-responses",config:{api:"azure-openai-responses",baseUrl:"",apiKey:"AZURE_OPENAI_API_KEY"},models:[{modelId:"gpt-4",name:"GPT-4",config:{api:"azure-openai-responses",reasoning:!1,input:["text"],contextWindow:8192,maxTokens:8192,cost:{input:30,output:60,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-4-turbo",name:"GPT-4 Turbo",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:10,output:30,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-4.1",name:"GPT-4.1",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"gpt-4.1-mini",name:"GPT-4.1 mini",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:0.4,output:1.6,cacheRead:0.1,cacheWrite:0}}},{modelId:"gpt-4.1-nano",name:"GPT-4.1 nano",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:0.1,output:0.4,cacheRead:0.025,cacheWrite:0}}},{modelId:"gpt-4o",name:"GPT-4o",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"gpt-4o-2024-05-13",name:"GPT-4o (2024-05-13)",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:5,output:15,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-4o-2024-08-06",name:"GPT-4o (2024-08-06)",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"gpt-4o-2024-11-20",name:"GPT-4o (2024-11-20)",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"gpt-4o-mini",name:"GPT-4o mini",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0.075,cacheWrite:0}}},{modelId:"gpt-5",name:"GPT-5",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5-chat-latest",name:"GPT-5 Chat Latest",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5-codex",name:"GPT-5-Codex",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5-mini",name:"GPT-5 Mini",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"gpt-5-nano",name:"GPT-5 Nano",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.05,output:0.4,cacheRead:0.005,cacheWrite:0}}},{modelId:"gpt-5-pro",name:"GPT-5 Pro",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:15,output:120,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-5.1",name:"GPT-5.1",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-chat-latest",name:"GPT-5.1 Chat",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-codex",name:"GPT-5.1 Codex",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex mini",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"gpt-5.2",name:"GPT-5.2",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-chat-latest",name:"GPT-5.2 Chat",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-codex",name:"GPT-5.2 Codex",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-pro",name:"GPT-5.2 Pro",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:21,output:168,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-5.3-chat-latest",name:"GPT-5.3 Chat (latest)",config:{api:"azure-openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.3-codex",name:"GPT-5.3 Codex",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:32000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.4",name:"GPT-5.4",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:2.5,output:15,cacheRead:0.25,cacheWrite:0}}},{modelId:"gpt-5.4-mini",name:"GPT-5.4 mini",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.75,output:4.5,cacheRead:0.075,cacheWrite:0}}},{modelId:"gpt-5.4-nano",name:"GPT-5.4 nano",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.2,output:1.25,cacheRead:0.02,cacheWrite:0}}},{modelId:"gpt-5.4-pro",name:"GPT-5.4 Pro",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-5.5",name:"GPT-5.5",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"gpt-5.5-pro",name:"GPT-5.5 Pro",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:0,cacheWrite:0}}},{modelId:"o1",name:"o1",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0}}},{modelId:"o1-pro",name:"o1-pro",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:150,output:600,cacheRead:0,cacheWrite:0}}},{modelId:"o3",name:"o3",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"o3-deep-research",name:"o3-deep-research",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0}}},{modelId:"o3-mini",name:"o3-mini",config:{api:"azure-openai-responses",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.55,cacheWrite:0}}},{modelId:"o3-pro",name:"o3-pro",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:20,output:80,cacheRead:0,cacheWrite:0}}},{modelId:"o4-mini",name:"o4-mini",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.275,cacheWrite:0}}},{modelId:"o4-mini-deep-research",name:"o4-mini-deep-research",config:{api:"azure-openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}}]},cerebras:{name:"cerebras",config:{api:"openai-completions",baseUrl:"https://api.cerebras.ai/v1",apiKey:"CEREBRAS_API_KEY"},models:[{modelId:"gpt-oss-120b",name:"GPT OSS 120B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:40960,cost:{input:0.35,output:0.75,cacheRead:0,cacheWrite:0}}},{modelId:"zai-glm-4.7",name:"Z.AI GLM-4.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:40960,cost:{input:2.25,output:2.75,cacheRead:0,cacheWrite:0}}}]},"cloudflare-ai-gateway":{name:"cloudflare-ai-gateway",config:{api:"anthropic-messages",baseUrl:"https://gateway.ai.cloudflare.com/v1/{CLOUDFLARE_ACCOUNT_ID}/{CLOUDFLARE_GATEWAY_ID}/anthropic",apiKey:"CLOUDFLARE_API_KEY"},models:[{modelId:"claude-3-5-haiku",name:"Claude Haiku 3.5 (latest)",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:0.8,output:4,cacheRead:0.08,cacheWrite:1}}},{modelId:"claude-3-haiku",name:"Claude Haiku 3",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:0.25,output:1.25,cacheRead:0.03,cacheWrite:0.3}}},{modelId:"claude-3-opus",name:"Claude Opus 3",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-3-sonnet",name:"Claude Sonnet 3",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:0.3}}},{modelId:"claude-3.5-haiku",name:"Claude Haiku 3.5 (latest)",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:0.8,output:4,cacheRead:0.08,cacheWrite:1}}},{modelId:"claude-3.5-sonnet",name:"Claude Sonnet 3.5 v2",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-fable-5",name:"Claude Fable 5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5}}},{modelId:"claude-haiku-4-5",name:"Claude Haiku 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"claude-opus-4",name:"Claude Opus 4 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-opus-4-1",name:"Claude Opus 4.1 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-opus-4-5",name:"Claude Opus 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-6",name:"Claude Opus 4.6 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-7",name:"Claude Opus 4.7",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-8",name:"Claude Opus 4.8",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-sonnet-4",name:"Claude Sonnet 4 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4-5",name:"Claude Sonnet 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"gpt-4",name:"GPT-4",config:{api:"openai-responses",reasoning:!1,input:["text"],contextWindow:8192,maxTokens:8192,cost:{input:30,output:60,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-4-turbo",name:"GPT-4 Turbo",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:10,output:30,cacheRead:0,cacheWrite:0}}},{modelId:"gpt-4o",name:"GPT-4o",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"gpt-4o-mini",name:"GPT-4o mini",config:{api:"openai-responses",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0.08,cacheWrite:0}}},{modelId:"gpt-5.1",name:"GPT-5.1",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.13,cacheWrite:0}}},{modelId:"gpt-5.1-codex",name:"GPT-5.1 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.2",name:"GPT-5.2",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-codex",name:"GPT-5.2 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.3-codex",name:"GPT-5.3 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.4",name:"GPT-5.4",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:2.5,output:15,cacheRead:0.25,cacheWrite:0}}},{modelId:"gpt-5.5",name:"GPT-5.5",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"o1",name:"o1",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0}}},{modelId:"o3",name:"o3",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"o3-mini",name:"o3-mini",config:{api:"openai-responses",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.55,cacheWrite:0}}},{modelId:"o3-pro",name:"o3-pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:20,output:80,cacheRead:0,cacheWrite:0}}},{modelId:"o4-mini",name:"o4-mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.28,cacheWrite:0}}},{modelId:"workers-ai/@cf/moonshotai/kimi-k2.5",name:"Kimi K2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:0.6,output:3,cacheRead:0.1,cacheWrite:0}}},{modelId:"workers-ai/@cf/moonshotai/kimi-k2.6",name:"Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}},{modelId:"workers-ai/@cf/nvidia/nemotron-3-120b-a12b",name:"Nemotron 3 Super 120B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:256000,cost:{input:0.5,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"workers-ai/@cf/zai-org/glm-4.7-flash",name:"GLM-4.7-Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.06,output:0.4,cacheRead:0,cacheWrite:0}}}]},"cloudflare-workers-ai":{name:"cloudflare-workers-ai",config:{api:"openai-completions",baseUrl:"https://api.cloudflare.com/client/v4/accounts/{CLOUDFLARE_ACCOUNT_ID}/ai/v1",apiKey:"CLOUDFLARE_API_KEY"},models:[{modelId:"@cf/google/gemma-4-26b-a4b-it",name:"Gemma 4 26B A4B IT",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:16384,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/ibm-granite/granite-4.0-h-micro",name:"Granite 4.0 H Micro",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131000,maxTokens:131000,cost:{input:0.017,output:0.112,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/meta/llama-3.3-70b-instruct-fp8-fast",name:"Llama 3.3 70B Instruct fp8 Fast",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:24000,maxTokens:24000,cost:{input:0.293,output:2.253,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/meta/llama-4-scout-17b-16e-instruct",name:"Llama 4 Scout 17B 16E Instruct",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:131000,maxTokens:16384,cost:{input:0.27,output:0.85,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/mistralai/mistral-small-3.1-24b-instruct",name:"Mistral Small 3.1 24B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.351,output:0.555,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/moonshotai/kimi-k2.6",name:"Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:256000,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}},{modelId:"@cf/moonshotai/kimi-k2.7-code",name:"Kimi K2.7 Code",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.95,output:4,cacheRead:0.19,cacheWrite:0}}},{modelId:"@cf/nvidia/nemotron-3-120b-a12b",name:"Nemotron 3 Super 120B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:256000,cost:{input:0.5,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/openai/gpt-oss-120b",name:"GPT OSS 120B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.35,output:0.75,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/openai/gpt-oss-20b",name:"GPT OSS 20B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:16384,cost:{input:0.2,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/qwen/qwen3-30b-a3b-fp8",name:"Qwen3 30B A3b fp8",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:32768,maxTokens:32768,cost:{input:0.0509,output:0.335,cacheRead:0,cacheWrite:0}}},{modelId:"@cf/zai-org/glm-4.7-flash",name:"GLM-4.7-Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.0605,output:0.4,cacheRead:0,cacheWrite:0}}}]},fireworks:{name:"fireworks",config:{api:"anthropic-messages",baseUrl:"https://api.fireworks.ai/inference",apiKey:"FIREWORKS_API_KEY"},models:[{modelId:"accounts/fireworks/models/deepseek-v4-flash",name:"DeepSeek V4 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:0.14,output:0.28,cacheRead:0.03,cacheWrite:0}}},{modelId:"accounts/fireworks/models/deepseek-v4-pro",name:"DeepSeek V4 Pro",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:1.74,output:3.48,cacheRead:0.145,cacheWrite:0}}},{modelId:"accounts/fireworks/models/glm-5p1",name:"GLM 5.1",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:202800,maxTokens:131072,cost:{input:1.4,output:4.4,cacheRead:0.26,cacheWrite:0}}},{modelId:"accounts/fireworks/models/gpt-oss-120b",name:"GPT OSS 120B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:32768,cost:{input:0.15,output:0.6,cacheRead:0.015,cacheWrite:0}}},{modelId:"accounts/fireworks/models/gpt-oss-20b",name:"GPT OSS 20B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:32768,cost:{input:0.07,output:0.3,cacheRead:0.035,cacheWrite:0}}},{modelId:"accounts/fireworks/models/kimi-k2p6",name:"Kimi K2.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262000,maxTokens:262000,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}},{modelId:"accounts/fireworks/models/kimi-k2p7-code",name:"Kimi K2.7 Code",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262000,maxTokens:262000,cost:{input:0.95,output:4,cacheRead:0.19,cacheWrite:0}}},{modelId:"accounts/fireworks/models/minimax-m2p7",name:"MiniMax-M2.7",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:196608,maxTokens:196608,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"accounts/fireworks/models/minimax-m3",name:"MiniMax-M3",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:512000,maxTokens:512000,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"accounts/fireworks/models/qwen3p7-plus",name:"Qwen 3.7 Plus",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.4,output:1.6,cacheRead:0.08,cacheWrite:0}}},{modelId:"accounts/fireworks/routers/glm-5p1-fast",name:"GLM 5.1 Fast",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:202800,maxTokens:131072,cost:{input:2.8,output:8.8,cacheRead:0.52,cacheWrite:0}}},{modelId:"accounts/fireworks/routers/kimi-k2p6-fast",name:"Kimi K2.6 Fast",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262000,maxTokens:262000,cost:{input:2,output:8,cacheRead:0.3,cacheWrite:0}}},{modelId:"accounts/fireworks/routers/kimi-k2p6-turbo",name:"Kimi K2.6 Turbo",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262000,maxTokens:262000,cost:{input:2,output:8,cacheRead:0.3,cacheWrite:0}}},{modelId:"accounts/fireworks/routers/kimi-k2p7-code-fast",name:"Kimi K2.7 Code Fast",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262000,maxTokens:262000,cost:{input:2,output:8,cacheRead:0.38,cacheWrite:0}}}]},"github-copilot":{name:"github-copilot",config:{api:"openai-completions",baseUrl:"https://api.individual.githubcopilot.com",apiKey:"COPILOT_GITHUB_TOKEN"},models:[{modelId:"claude-fable-5",name:"Claude Fable 5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:10,output:50,cacheRead:1,cacheWrite:12.5}}},{modelId:"claude-haiku-4.5",name:"Claude Haiku 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"claude-opus-4.5",name:"Claude Opus 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4.6",name:"Claude Opus 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:32000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4.7",name:"Claude Opus 4.7",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4.8",name:"Claude Opus 4.8",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-sonnet-4",name:"Claude Sonnet 4 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:216000,maxTokens:16000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4.5",name:"Claude Sonnet 4.5 (latest)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4.6",name:"Claude Sonnet 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:32000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"gemini-2.5-pro",name:"Gemini 2.5 Pro",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:64000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:64000,cost:{input:0.5,output:3,cacheRead:0.05,cacheWrite:0}}},{modelId:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"gemini-3.5-flash",name:"Gemini 3.5 Flash",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1.5,output:9,cacheRead:0.15,cacheWrite:0}}},{modelId:"gpt-4.1",name:"GPT-4.1",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"gpt-5-mini",name:"GPT-5 Mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:264000,maxTokens:64000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"gpt-5.2",name:"GPT-5.2",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-codex",name:"GPT-5.2 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.3-codex",name:"GPT-5.3 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.4",name:"GPT-5.4",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:2.5,output:15,cacheRead:0.25,cacheWrite:0}}},{modelId:"gpt-5.4-mini",name:"GPT-5.4 mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.75,output:4.5,cacheRead:0.075,cacheWrite:0}}},{modelId:"gpt-5.4-nano",name:"GPT-5.4 nano",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.2,output:1.25,cacheRead:0.02,cacheWrite:0}}},{modelId:"gpt-5.5",name:"GPT-5.5",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"raptor-mini",name:"Raptor mini",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}}]},"google-vertex":{name:"google-vertex",config:{api:"google-vertex",baseUrl:"https://{location}-aiplatform.googleapis.com",apiKey:"GOOGLE_CLOUD_API_KEY"},models:[{modelId:"gemini-1.5-flash",name:"Gemini 1.5 Flash (Vertex)",config:{api:"google-vertex",reasoning:!1,input:["text","image"],contextWindow:1e6,maxTokens:8192,cost:{input:0.075,output:0.3,cacheRead:0.01875,cacheWrite:0}}},{modelId:"gemini-1.5-flash-8b",name:"Gemini 1.5 Flash-8B (Vertex)",config:{api:"google-vertex",reasoning:!1,input:["text","image"],contextWindow:1e6,maxTokens:8192,cost:{input:0.0375,output:0.15,cacheRead:0.01,cacheWrite:0}}},{modelId:"gemini-1.5-pro",name:"Gemini 1.5 Pro (Vertex)",config:{api:"google-vertex",reasoning:!1,input:["text","image"],contextWindow:1e6,maxTokens:8192,cost:{input:1.25,output:5,cacheRead:0.3125,cacheWrite:0}}},{modelId:"gemini-2.0-flash",name:"Gemini 2.0 Flash (Vertex)",config:{api:"google-vertex",reasoning:!1,input:["text","image"],contextWindow:1048576,maxTokens:8192,cost:{input:0.15,output:0.6,cacheRead:0.0375,cacheWrite:0}}},{modelId:"gemini-2.0-flash-lite",name:"Gemini 2.0 Flash Lite (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.075,output:0.3,cacheRead:0.01875,cacheWrite:0}}},{modelId:"gemini-2.5-flash",name:"Gemini 2.5 Flash (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.3,output:2.5,cacheRead:0.03,cacheWrite:0}}},{modelId:"gemini-2.5-flash-lite",name:"Gemini 2.5 Flash Lite (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.1,output:0.4,cacheRead:0.01,cacheWrite:0}}},{modelId:"gemini-2.5-flash-lite-preview-09-2025",name:"Gemini 2.5 Flash Lite Preview 09-25 (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.1,output:0.4,cacheRead:0.01,cacheWrite:0}}},{modelId:"gemini-2.5-pro",name:"Gemini 2.5 Pro (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.5,output:3,cacheRead:0.05,cacheWrite:0}}},{modelId:"gemini-3-pro-preview",name:"Gemini 3 Pro Preview (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"gemini-3.1-pro-preview-customtools",name:"Gemini 3.1 Pro Preview Custom Tools (Vertex)",config:{api:"google-vertex",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}}]},huggingface:{name:"huggingface",config:{api:"openai-completions",baseUrl:"https://router.huggingface.co/v1",apiKey:"HF_TOKEN"},models:[{modelId:"MiniMaxAI/MiniMax-M2.1",name:"MiniMax-M2.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0,cacheWrite:0}}},{modelId:"MiniMaxAI/MiniMax-M2.5",name:"MiniMax-M2.5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.03,cacheWrite:0}}},{modelId:"MiniMaxAI/MiniMax-M2.7",name:"MiniMax-M2.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"Qwen/Qwen3-235B-A22B-Thinking-2507",name:"Qwen3-235B-A22B-Thinking-2507",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:131072,cost:{input:0.3,output:3,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3-Coder-480B-A35B-Instruct",name:"Qwen3-Coder-480B-A35B-Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:66536,cost:{input:2,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3-Coder-Next",name:"Qwen3-Coder-Next",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:0.2,output:1.5,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3-Next-80B-A3B-Instruct",name:"Qwen3-Next-80B-A3B-Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:66536,cost:{input:0.25,output:1,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3-Next-80B-A3B-Thinking",name:"Qwen3-Next-80B-A3B-Thinking",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:131072,cost:{input:0.3,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3.5-397B-A17B",name:"Qwen3.5-397B-A17B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0.6,output:3.6,cacheRead:0,cacheWrite:0}}},{modelId:"XiaomiMiMo/MiMo-V2-Flash",name:"MiMo-V2-Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:4096,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek-ai/DeepSeek-R1-0528",name:"DeepSeek-R1-0528",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:163840,cost:{input:3,output:5,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek-ai/DeepSeek-V3.2",name:"DeepSeek-V3.2",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:65536,cost:{input:0.28,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek-ai/DeepSeek-V4-Pro",name:"DeepSeek V4 Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:393216,cost:{input:0.435,output:0.87,cacheRead:0.003625,cacheWrite:0}}},{modelId:"moonshotai/Kimi-K2-Instruct",name:"Kimi-K2-Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:1,output:3,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/Kimi-K2-Instruct-0905",name:"Kimi-K2-Instruct-0905",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:16384,cost:{input:1,output:3,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/Kimi-K2-Thinking",name:"Kimi-K2-Thinking",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"moonshotai/Kimi-K2.5",name:"Kimi-K2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:3,cacheRead:0.1,cacheWrite:0}}},{modelId:"moonshotai/Kimi-K2.6",name:"Kimi-K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}},{modelId:"zai-org/GLM-4.7",name:"GLM-4.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.6,output:2.2,cacheRead:0.11,cacheWrite:0}}},{modelId:"zai-org/GLM-4.7-Flash",name:"GLM-4.7-Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:128000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"zai-org/GLM-5",name:"GLM-5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:131072,cost:{input:1,output:3.2,cacheRead:0.2,cacheWrite:0}}},{modelId:"zai-org/GLM-5.1",name:"GLM-5.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:131072,cost:{input:1,output:3.2,cacheRead:0.2,cacheWrite:0}}}]},"kimi-coding":{name:"kimi-coding",config:{api:"anthropic-messages",baseUrl:"https://api.kimi.com/coding",apiKey:"KIMI_API_KEY"},models:[{modelId:"k2p7",name:"Kimi K2.7 Code",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"kimi-for-coding",name:"Kimi For Coding",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"kimi-k2-thinking",name:"Kimi K2 Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}}]},minimax:{name:"minimax",config:{api:"anthropic-messages",baseUrl:"https://api.minimax.io/anthropic",apiKey:"MINIMAX_API_KEY"},models:[{modelId:"MiniMax-M2.7",name:"MiniMax-M2.7",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0.375}}},{modelId:"MiniMax-M2.7-highspeed",name:"MiniMax-M2.7-highspeed",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.6,output:2.4,cacheRead:0.06,cacheWrite:0.375}}},{modelId:"MiniMax-M3",name:"MiniMax-M3",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:512000,maxTokens:128000,cost:{input:0.6,output:2.4,cacheRead:0.12,cacheWrite:0}}}]},"minimax-cn":{name:"minimax-cn",config:{api:"anthropic-messages",baseUrl:"https://api.minimaxi.com/anthropic",apiKey:"MINIMAX_CN_API_KEY"},models:[{modelId:"MiniMax-M2.7",name:"MiniMax-M2.7",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0.375}}},{modelId:"MiniMax-M2.7-highspeed",name:"MiniMax-M2.7-highspeed",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.6,output:2.4,cacheRead:0.06,cacheWrite:0.375}}},{modelId:"MiniMax-M3",name:"MiniMax-M3",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:512000,maxTokens:128000,cost:{input:0.6,output:2.4,cacheRead:0.12,cacheWrite:0}}}]},moonshotai:{name:"moonshotai",config:{api:"openai-completions",baseUrl:"https://api.moonshot.ai/v1",apiKey:"MOONSHOT_API_KEY"},models:[{modelId:"kimi-k2-0711-preview",name:"Kimi K2 0711",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.6,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"kimi-k2-0905-preview",name:"Kimi K2 0905",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"kimi-k2-thinking",name:"Kimi K2 Thinking",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"kimi-k2-thinking-turbo",name:"Kimi K2 Thinking Turbo",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:1.15,output:8,cacheRead:0.15,cacheWrite:0}}},{modelId:"kimi-k2-turbo-preview",name:"Kimi K2 Turbo",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:2.4,output:10,cacheRead:0.6,cacheWrite:0}}},{modelId:"kimi-k2.5",name:"Kimi K2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:3,cacheRead:0.1,cacheWrite:0}}},{modelId:"kimi-k2.6",name:"Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}},{modelId:"kimi-k2.7-code",name:"Kimi K2.7 Code",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.95,output:4,cacheRead:0.19,cacheWrite:0}}}]},"moonshotai-cn":{name:"moonshotai-cn",config:{api:"openai-completions",baseUrl:"https://api.moonshot.cn/v1",apiKey:"MOONSHOT_API_KEY"},models:[{modelId:"kimi-k2-0711-preview",name:"Kimi K2 0711",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:16384,cost:{input:0.6,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"kimi-k2-0905-preview",name:"Kimi K2 0905",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"kimi-k2-thinking",name:"Kimi K2 Thinking",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"kimi-k2-thinking-turbo",name:"Kimi K2 Thinking Turbo",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:1.15,output:8,cacheRead:0.15,cacheWrite:0}}},{modelId:"kimi-k2-turbo-preview",name:"Kimi K2 Turbo",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:2.4,output:10,cacheRead:0.6,cacheWrite:0}}},{modelId:"kimi-k2.5",name:"Kimi K2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.6,output:3,cacheRead:0.1,cacheWrite:0}}},{modelId:"kimi-k2.6",name:"Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}}]},nvidia:{name:"nvidia",config:{api:"openai-completions",baseUrl:"https://integrate.api.nvidia.com/v1",apiKey:""},models:[{modelId:"meta/llama-3.1-70b-instruct",name:"Llama 3.1 70b Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.1-8b-instruct",name:"Llama 3.1 8B Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:16000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.2-11b-vision-instruct",name:"Llama 3.2 11b Vision Instruct",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.2-90b-vision-instruct",name:"Llama-3.2-90B-Vision-Instruct",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:8192,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.3-70b-instruct",name:"Llama 3.3 70b Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4096,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"mistralai/mistral-large-3-675b-instruct-2512",name:"Mistral Large 3 675B Instruct 2512",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"mistralai/mistral-small-4-119b-2603",name:"mistral-small-4-119b-2603",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:8192,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2.6",name:"Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-nano-30b-a3b",name:"nemotron-3-nano-30b-a3b",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning",name:"Nemotron 3 Nano Omni",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:65536,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-super-120b-a12b",name:"Nemotron 3 Super",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.2,output:0.8,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-ultra-550b-a55b",name:"Nemotron 3 Ultra 550B A55B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:65536,cost:{input:0.5,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"nvidia/nvidia-nemotron-nano-9b-v2",name:"nvidia-nemotron-nano-9b-v2",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-120b",name:"GPT-OSS-120B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:8192,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-20b",name:"GPT OSS 20B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:32768,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"qwen/qwen3.5-122b-a10b",name:"Qwen3.5 122B-A10B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"stepfun-ai/step-3.5-flash",name:"Step 3.5 Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:16384,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"stepfun-ai/step-3.7-flash",name:"Step 3.7 Flash",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:16384,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"z-ai/glm-5.1",name:"GLM-5.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}}]},"openai-codex":{name:"openai-codex",config:{api:"openai-codex-responses",baseUrl:"https://chatgpt.com/backend-api",apiKey:""},models:[{modelId:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",config:{api:"openai-codex-responses",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.4",name:"GPT-5.4",config:{api:"openai-codex-responses",reasoning:!0,input:["text","image"],contextWindow:272000,maxTokens:128000,cost:{input:2.5,output:15,cacheRead:0.25,cacheWrite:0}}},{modelId:"gpt-5.4-mini",name:"GPT-5.4 mini",config:{api:"openai-codex-responses",reasoning:!0,input:["text","image"],contextWindow:272000,maxTokens:128000,cost:{input:0.75,output:4.5,cacheRead:0.075,cacheWrite:0}}},{modelId:"gpt-5.5",name:"GPT-5.5",config:{api:"openai-codex-responses",reasoning:!0,input:["text","image"],contextWindow:272000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}}]},opencode:{name:"opencode",config:{api:"openai-completions",baseUrl:"https://opencode.ai/zen/v1",apiKey:"OPENCODE_API_KEY"},models:[{modelId:"big-pickle",name:"Big Pickle",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:32000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"claude-haiku-4-5",name:"Claude Haiku 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"claude-opus-4-1",name:"Claude Opus 4.1",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"claude-opus-4-5",name:"Claude Opus 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-6",name:"Claude Opus 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-7",name:"Claude Opus 4.7",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-opus-4-8",name:"Claude Opus 4.8",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"claude-sonnet-4",name:"Claude Sonnet 4",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4-5",name:"Claude Sonnet 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"deepseek-v4-flash",name:"DeepSeek V4 Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:0.14,output:0.28,cacheRead:0.028,cacheWrite:0}}},{modelId:"deepseek-v4-flash-free",name:"DeepSeek V4 Flash Free",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:128000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek-v4-pro",name:"DeepSeek V4 Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:1.74,output:3.84,cacheRead:0.145,cacheWrite:0}}},{modelId:"gemini-3-flash",name:"Gemini 3 Flash",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.5,output:3,cacheRead:0.05,cacheWrite:0}}},{modelId:"gemini-3.1-pro",name:"Gemini 3.1 Pro Preview",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"gemini-3.5-flash",name:"Gemini 3.5 Flash",config:{api:"google-generative-ai",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.5,output:9,cacheRead:0.15,cacheWrite:0}}},{modelId:"glm-5",name:"GLM-5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:1,output:3.2,cacheRead:0.2,cacheWrite:0}}},{modelId:"glm-5.1",name:"GLM-5.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:1.4,output:4.4,cacheRead:0.26,cacheWrite:0}}},{modelId:"gpt-5",name:"GPT-5",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.07,output:8.5,cacheRead:0.107,cacheWrite:0}}},{modelId:"gpt-5-codex",name:"GPT-5 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.07,output:8.5,cacheRead:0.107,cacheWrite:0}}},{modelId:"gpt-5-nano",name:"GPT-5 Nano",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.05,output:0.4,cacheRead:0.005,cacheWrite:0}}},{modelId:"gpt-5.1",name:"GPT-5.1",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.07,output:8.5,cacheRead:0.107,cacheWrite:0}}},{modelId:"gpt-5.1-codex",name:"GPT-5.1 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.07,output:8.5,cacheRead:0.107,cacheWrite:0}}},{modelId:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex Mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"gpt-5.2",name:"GPT-5.2",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.2-codex",name:"GPT-5.2 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.3-codex",name:"GPT-5.3 Codex",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"gpt-5.4",name:"GPT-5.4",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:272000,maxTokens:128000,cost:{input:2.5,output:15,cacheRead:0.25,cacheWrite:0}}},{modelId:"gpt-5.4-mini",name:"GPT-5.4 Mini",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.75,output:4.5,cacheRead:0.075,cacheWrite:0}}},{modelId:"gpt-5.4-nano",name:"GPT-5.4 Nano",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.2,output:1.25,cacheRead:0.02,cacheWrite:0}}},{modelId:"gpt-5.4-pro",name:"GPT-5.4 Pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:30,cacheWrite:0}}},{modelId:"gpt-5.5",name:"GPT-5.5",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"gpt-5.5-pro",name:"GPT-5.5 Pro",config:{api:"openai-responses",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:30,cacheWrite:0}}},{modelId:"grok-build-0.1",name:"Grok Build 0.1",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:1,output:2,cacheRead:0.2,cacheWrite:0}}},{modelId:"kimi-k2.5",name:"Kimi K2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.6,output:3,cacheRead:0.08,cacheWrite:0}}},{modelId:"kimi-k2.6",name:"Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}},{modelId:"mimo-v2.5-free",name:"MiMo V2.5 Free",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"minimax-m2.5",name:"MiniMax M2.5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"minimax-m2.7",name:"MiniMax M2.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"nemotron-3-ultra-free",name:"Nemotron 3 Ultra Free",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:128000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"north-mini-code-free",name:"North Mini Code Free",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:64000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"qwen3.5-plus",name:"Qwen3.5 Plus",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.2,output:1.2,cacheRead:0.02,cacheWrite:0.25}}},{modelId:"qwen3.6-plus",name:"Qwen3.6 Plus",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.5,output:3,cacheRead:0.05,cacheWrite:0.625}}}]},"opencode-go":{name:"opencode-go",config:{api:"openai-completions",baseUrl:"https://opencode.ai/zen/go/v1",apiKey:"OPENCODE_API_KEY"},models:[{modelId:"deepseek-v4-flash",name:"DeepSeek V4 Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:0.14,output:0.28,cacheRead:0.0028,cacheWrite:0}}},{modelId:"deepseek-v4-pro",name:"DeepSeek V4 Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:1.74,output:3.48,cacheRead:0.0145,cacheWrite:0}}},{modelId:"glm-5",name:"GLM-5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:32768,cost:{input:1,output:3.2,cacheRead:0.2,cacheWrite:0}}},{modelId:"glm-5.1",name:"GLM-5.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:32768,cost:{input:1.4,output:4.4,cacheRead:0.26,cacheWrite:0}}},{modelId:"kimi-k2.6",name:"Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}},{modelId:"kimi-k2.7-code",name:"Kimi K2.7 Code",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:262144,cost:{input:0.95,output:4,cacheRead:0.19,cacheWrite:0}}},{modelId:"mimo-v2.5",name:"MiMo V2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:0.14,output:0.28,cacheRead:0.0028,cacheWrite:0}}},{modelId:"mimo-v2.5-pro",name:"MiMo V2.5 Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:128000,cost:{input:1.74,output:3.48,cacheRead:0.0145,cacheWrite:0}}},{modelId:"minimax-m2.7",name:"MiniMax M2.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"minimax-m3",name:"MiniMax M3 (3x usage)",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:512000,maxTokens:131072,cost:{input:0.1,output:0.4,cacheRead:0.02,cacheWrite:0}}},{modelId:"qwen3.6-plus",name:"Qwen3.6 Plus",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.5,output:3,cacheRead:0.05,cacheWrite:0.625}}},{modelId:"qwen3.7-max",name:"Qwen3.7 Max",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:65536,cost:{input:2.5,output:7.5,cacheRead:0.5,cacheWrite:3.125}}},{modelId:"qwen3.7-plus",name:"Qwen3.7 Plus",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.4,output:1.6,cacheRead:0.04,cacheWrite:0.5}}}]},together:{name:"together",config:{api:"openai-completions",baseUrl:"https://api.together.ai/v1",apiKey:"TOGETHER_API_KEY"},models:[{modelId:"MiniMaxAI/MiniMax-M2.7",name:"MiniMax-M2.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"MiniMaxAI/MiniMax-M3",name:"MiniMax-M3",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:524288,maxTokens:250000,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"Qwen/Qwen2.5-7B-Instruct-Turbo",name:"Qwen 2.5 7B Instruct Turbo",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:32768,maxTokens:32768,cost:{input:0.3,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3-235B-A22B-Instruct-2507-tput",name:"Qwen3 235B A22B Instruct 2507 FP8",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:262144,cost:{input:0.2,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3.5-397B-A17B",name:"Qwen3.5 397B A17B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:130000,cost:{input:0.6,output:3.6,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3.5-9B",name:"Qwen3.5 9B",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:65536,cost:{input:0.17,output:0.25,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3.6-Plus",name:"Qwen3.6 Plus",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:500000,cost:{input:0.5,output:3,cacheRead:0,cacheWrite:0}}},{modelId:"Qwen/Qwen3.7-Max",name:"Qwen3.7 Max",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:1e6,maxTokens:500000,cost:{input:2.5,output:7.5,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek-ai/DeepSeek-V4-Pro",name:"DeepSeek V4 Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:512000,maxTokens:384000,cost:{input:1.74,output:3.48,cacheRead:0.2,cacheWrite:0}}},{modelId:"essentialai/Rnj-1-Instruct",name:"Rnj-1 Instruct",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:32768,maxTokens:32768,cost:{input:0.15,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"google/gemma-4-31B-it",name:"Gemma 4 31B Instruct",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.39,output:0.97,cacheRead:0,cacheWrite:0}}},{modelId:"meta-llama/Llama-3.3-70B-Instruct-Turbo",name:"Llama 3.3 70B",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.88,output:0.88,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/Kimi-K2.6",name:"Kimi K2.6",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131000,cost:{input:1.2,output:4.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"moonshotai/Kimi-K2.7-Code",name:"Kimi K2.7 Code",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:131072,cost:{input:0.95,output:4,cacheRead:0.19,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-ultra-550b-a55b",name:"Nemotron 3 Ultra 550B A55B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:512300,maxTokens:512300,cost:{input:0.6,output:3.6,cacheRead:0.2,cacheWrite:0}}},{modelId:"openai/gpt-oss-120b",name:"GPT OSS 120B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-20b",name:"GPT OSS 20B",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.05,output:0.2,cacheRead:0,cacheWrite:0}}},{modelId:"zai-org/GLM-5",name:"GLM-5",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:131072,cost:{input:1,output:3.2,cacheRead:0,cacheWrite:0}}},{modelId:"zai-org/GLM-5.1",name:"GLM-5.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:202752,maxTokens:131072,cost:{input:1.4,output:4.4,cacheRead:0,cacheWrite:0}}}]},"vercel-ai-gateway":{name:"vercel-ai-gateway",config:{api:"anthropic-messages",baseUrl:"https://ai-gateway.vercel.sh",apiKey:"AI_GATEWAY_API_KEY"},models:[{modelId:"alibaba/qwen-3-14b",name:"Qwen3-14B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:40960,maxTokens:16384,cost:{input:0.12,output:0.24,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen-3-235b",name:"Qwen3 235B A22B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:16384,cost:{input:0.22,output:0.88,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen-3-30b",name:"Qwen3-30B-A3B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:40960,maxTokens:16384,cost:{input:0.12,output:0.5,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen-3-32b",name:"Qwen 3 32B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:8192,cost:{input:0.16,output:0.64,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen-3.6-max-preview",name:"Qwen 3.6 Max Preview",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:240000,maxTokens:64000,cost:{input:1.3,output:7.8,cacheRead:0.26,cacheWrite:1.625}}},{modelId:"alibaba/qwen3-235b-a22b-thinking",name:"Qwen3 VL 235B A22B Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:131072,maxTokens:32768,cost:{input:0.4,output:4,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen3-coder",name:"Qwen3 Coder 480B A35B Instruct",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:1.5,output:7.5,cacheRead:0.3,cacheWrite:0}}},{modelId:"alibaba/qwen3-coder-30b-a3b",name:"Qwen 3 Coder 30B A3B Instruct",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:8192,cost:{input:0.15,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen3-coder-next",name:"Qwen3 Coder Next",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:256000,cost:{input:0.5,output:1.2,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen3-coder-plus",name:"Qwen3 Coder Plus",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:1e6,maxTokens:65536,cost:{input:1,output:5,cacheRead:0.2,cacheWrite:0}}},{modelId:"alibaba/qwen3-max",name:"Qwen3 Max",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:1.2,output:6,cacheRead:0.24,cacheWrite:0}}},{modelId:"alibaba/qwen3-max-preview",name:"Qwen3 Max Preview",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:262144,maxTokens:32768,cost:{input:1.2,output:6,cacheRead:0.24,cacheWrite:0}}},{modelId:"alibaba/qwen3-max-thinking",name:"Qwen 3 Max Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:65536,cost:{input:1.2,output:6,cacheRead:0.24,cacheWrite:0}}},{modelId:"alibaba/qwen3-next-80b-a3b-instruct",name:"Qwen3 Next 80B A3B Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:32768,cost:{input:0.15,output:1.2,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen3-next-80b-a3b-thinking",name:"Qwen3 Next 80B A3B Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:32768,cost:{input:0.15,output:1.2,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen3-vl-thinking",name:"Qwen3 VL 235B A22B Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:131072,maxTokens:32768,cost:{input:0.4,output:4,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen3.5-flash",name:"Qwen 3.5 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:0.1,output:0.4,cacheRead:0.001,cacheWrite:0.125}}},{modelId:"alibaba/qwen3.5-plus",name:"Qwen 3.5 Plus",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:0.4,output:2.4,cacheRead:0.04,cacheWrite:0.5}}},{modelId:"alibaba/qwen3.6-27b",name:"Qwen 3.6 27B",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:0.6,output:3.6,cacheRead:0,cacheWrite:0}}},{modelId:"alibaba/qwen3.6-plus",name:"Qwen 3.6 Plus",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:0.5,output:3,cacheRead:0.1,cacheWrite:0.625}}},{modelId:"alibaba/qwen3.7-max",name:"Qwen 3.7 Max",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:991000,maxTokens:64000,cost:{input:1.25,output:3.75,cacheRead:0.25,cacheWrite:1.5625}}},{modelId:"alibaba/qwen3.7-plus",name:"Qwen 3.7 Plus",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:0.4,output:1.6,cacheRead:0.08,cacheWrite:0.5}}},{modelId:"anthropic/claude-3-haiku",name:"Claude 3 Haiku",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:4096,cost:{input:0.25,output:1.25,cacheRead:0.03,cacheWrite:0.3}}},{modelId:"anthropic/claude-3.5-haiku",name:"Claude 3.5 Haiku",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8192,cost:{input:0.8,output:4,cacheRead:0.08,cacheWrite:1}}},{modelId:"anthropic/claude-haiku-4.5",name:"Claude Haiku 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:1,output:5,cacheRead:0.1,cacheWrite:1.25}}},{modelId:"anthropic/claude-opus-4",name:"Claude Opus 4",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"anthropic/claude-opus-4.1",name:"Claude Opus 4.1",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:32000,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75}}},{modelId:"anthropic/claude-opus-4.5",name:"Claude Opus 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:64000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic/claude-opus-4.6",name:"Claude Opus 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic/claude-opus-4.7",name:"Claude Opus 4.7",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic/claude-opus-4.8",name:"Claude Opus 4.8",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:25,cacheRead:0.5,cacheWrite:6.25}}},{modelId:"anthropic/claude-sonnet-4",name:"Claude Sonnet 4",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"anthropic/claude-sonnet-4.5",name:"Claude Sonnet 4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"anthropic/claude-sonnet-4.6",name:"Claude Sonnet 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:3,output:15,cacheRead:0.3,cacheWrite:3.75}}},{modelId:"arcee-ai/trinity-large-preview",name:"Trinity Large Preview",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:131000,maxTokens:131000,cost:{input:0.25,output:1,cacheRead:0,cacheWrite:0}}},{modelId:"arcee-ai/trinity-large-thinking",name:"Trinity Large Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:262100,maxTokens:80000,cost:{input:0.25,output:0.9,cacheRead:0,cacheWrite:0}}},{modelId:"bytedance/seed-1.6",name:"Seed 1.6",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:32000,cost:{input:0.25,output:2,cacheRead:0.05,cacheWrite:0}}},{modelId:"cohere/command-a",name:"Command A",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:8000,cost:{input:2.5,output:10,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek/deepseek-r1",name:"DeepSeek-R1",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:8192,cost:{input:1.35,output:5.4,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek/deepseek-v3",name:"DeepSeek V3 0324",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:163840,maxTokens:163840,cost:{input:0.27,output:1.12,cacheRead:0.135,cacheWrite:0}}},{modelId:"deepseek/deepseek-v3.1",name:"DeepSeek V3.1",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:163840,maxTokens:8192,cost:{input:0.56,output:1.68,cacheRead:0.28,cacheWrite:0}}},{modelId:"deepseek/deepseek-v3.1-terminus",name:"DeepSeek V3.1 Terminus",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:65536,cost:{input:0.27,output:1,cacheRead:0.135,cacheWrite:0}}},{modelId:"deepseek/deepseek-v3.2",name:"DeepSeek V3.2",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:8000,cost:{input:0.28,output:0.42,cacheRead:0.028,cacheWrite:0}}},{modelId:"deepseek/deepseek-v3.2-thinking",name:"DeepSeek V3.2 Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:8000,cost:{input:0.62,output:1.85,cacheRead:0,cacheWrite:0}}},{modelId:"deepseek/deepseek-v4-flash",name:"DeepSeek V4 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:384000,cost:{input:0.14,output:0.28,cacheRead:0.0028,cacheWrite:0}}},{modelId:"deepseek/deepseek-v4-pro",name:"DeepSeek V4 Pro",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:384000,cost:{input:0.435,output:0.87,cacheRead:0.0036,cacheWrite:0}}},{modelId:"google/gemini-2.5-flash",name:"Gemini 2.5 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65536,cost:{input:0.3,output:2.5,cacheRead:0.03,cacheWrite:0}}},{modelId:"google/gemini-2.5-flash-lite",name:"Gemini 2.5 Flash Lite",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:0.1,output:0.4,cacheRead:0.01,cacheWrite:0}}},{modelId:"google/gemini-2.5-pro",name:"Gemini 2.5 Pro",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:65536,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"google/gemini-3-flash",name:"Gemini 3 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65000,cost:{input:0.5,output:3,cacheRead:0.05,cacheWrite:0}}},{modelId:"google/gemini-3-pro-preview",name:"Gemini 3 Pro Preview",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"google/gemini-3.1-flash-lite",name:"Gemini 3.1 Flash Lite",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65000,cost:{input:0.25,output:1.5,cacheRead:0.03,cacheWrite:0}}},{modelId:"google/gemini-3.1-flash-lite-preview",name:"Gemini 3.1 Flash Lite Preview",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:65000,cost:{input:0.25,output:1.5,cacheRead:0.03,cacheWrite:0}}},{modelId:"google/gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:2,output:12,cacheRead:0.2,cacheWrite:0}}},{modelId:"google/gemini-3.5-flash",name:"Gemini 3.5 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:64000,cost:{input:1.5,output:9,cacheRead:0.15,cacheWrite:0}}},{modelId:"google/gemma-4-26b-a4b-it",name:"Gemma 4 26B A4B IT",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.15,output:0.6,cacheRead:0.015,cacheWrite:0}}},{modelId:"google/gemma-4-31b-it",name:"Gemma 4 31B IT",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.14,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"inception/mercury-2",name:"Mercury 2",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:128000,cost:{input:0.25,output:0.75,cacheRead:0.025,cacheWrite:0}}},{modelId:"inception/mercury-coder-small",name:"Mercury Coder Small Beta",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:32000,maxTokens:16384,cost:{input:0.25,output:1,cacheRead:0,cacheWrite:0}}},{modelId:"kwaipilot/kat-coder-pro-v2",name:"Kat Coder Pro V2",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:256000,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"meituan/longcat-flash-chat",name:"LongCat Flash Chat",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:1e5,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.1-70b",name:"Llama 3.1 70B Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:8192,cost:{input:0.72,output:0.72,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.1-8b",name:"Llama 3.1 8B Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:8192,cost:{input:0.22,output:0.22,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.2-11b",name:"Llama 3.2 11B Vision Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:8192,cost:{input:0.16,output:0.16,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.2-90b",name:"Llama 3.2 90B Vision Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:8192,cost:{input:0.72,output:0.72,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-3.3-70b",name:"Llama 3.3 70B Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:8192,cost:{input:0.72,output:0.72,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-4-maverick",name:"Llama 4 Maverick 17B Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:8192,cost:{input:0.24,output:0.97,cacheRead:0,cacheWrite:0}}},{modelId:"meta/llama-4-scout",name:"Llama 4 Scout 17B Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:8192,cost:{input:0.17,output:0.66,cacheRead:0,cacheWrite:0}}},{modelId:"minimax/minimax-m2",name:"MiniMax M2",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:205000,maxTokens:205000,cost:{input:0.3,output:1.2,cacheRead:0.03,cacheWrite:0.375}}},{modelId:"minimax/minimax-m2.1",name:"MiniMax M2.1",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:1.2,cacheRead:0.03,cacheWrite:0.375}}},{modelId:"minimax/minimax-m2.1-lightning",name:"MiniMax M2.1 Lightning",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0.3,output:2.4,cacheRead:0.03,cacheWrite:0.375}}},{modelId:"minimax/minimax-m2.5",name:"MiniMax M2.5",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131000,cost:{input:0.3,output:1.2,cacheRead:0.03,cacheWrite:0.375}}},{modelId:"minimax/minimax-m2.5-highspeed",name:"MiniMax M2.5 High Speed",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131000,cost:{input:0.6,output:2.4,cacheRead:0.03,cacheWrite:0.375}}},{modelId:"minimax/minimax-m2.7",name:"MiniMax M2.7",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131000,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0.375}}},{modelId:"minimax/minimax-m2.7-highspeed",name:"MiniMax M2.7 High Speed",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131100,cost:{input:0.6,output:2.4,cacheRead:0.06,cacheWrite:0.375}}},{modelId:"minimax/minimax-m3",name:"MiniMax M3",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:1e6,cost:{input:0.3,output:1.2,cacheRead:0.06,cacheWrite:0}}},{modelId:"mistral/codestral",name:"Mistral Codestral",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4000,cost:{input:0.3,output:0.9,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/devstral-2",name:"Devstral 2",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:256000,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/devstral-small",name:"Devstral Small 1.1",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:64000,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/devstral-small-2",name:"Devstral Small 2",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:256000,maxTokens:256000,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/ministral-3b",name:"Ministral 3B",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4000,cost:{input:0.1,output:0.1,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/ministral-8b",name:"Ministral 8B",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:128000,maxTokens:4000,cost:{input:0.15,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/mistral-medium",name:"Mistral Medium 3.1",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:64000,cost:{input:0.4,output:2,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/mistral-medium-3.5",name:"Mistral Medium Latest",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:256000,cost:{input:1.5,output:7.5,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/mistral-nemo",name:"Mistral Nemo 12B",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.02,output:0.04,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/mistral-small",name:"Mistral Small",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:32000,maxTokens:4000,cost:{input:0.1,output:0.3,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/pixtral-12b",name:"Pixtral 12B 2409",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4000,cost:{input:0.15,output:0.15,cacheRead:0,cacheWrite:0}}},{modelId:"mistral/pixtral-large",name:"Pixtral Large",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4000,cost:{input:2,output:6,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2",name:"Kimi K2 Instruct",config:{api:"anthropic-messages",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.57,output:2.3,cacheRead:0,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2-thinking",name:"Kimi K2 Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:262114,maxTokens:262114,cost:{input:0.6,output:2.5,cacheRead:0.15,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2.5",name:"Kimi K2.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262114,maxTokens:262114,cost:{input:0.6,output:3,cacheRead:0.1,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2.6",name:"Kimi K2.6",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:262000,maxTokens:262000,cost:{input:0.95,output:4,cacheRead:0.16,cacheWrite:0}}},{modelId:"moonshotai/kimi-k2.7-code",name:"Kimi K2.7 Code",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:32768,cost:{input:0.95,output:4,cacheRead:0.19,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-super-120b-a12b",name:"NVIDIA Nemotron 3 Super 120B A12B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:256000,maxTokens:32000,cost:{input:0.15,output:0.65,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-3-ultra-550b-a55b",name:"Nemotron 3 Ultra",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:65000,cost:{input:0.6,output:2.4,cacheRead:0.12,cacheWrite:0}}},{modelId:"nvidia/nemotron-nano-12b-v2-vl",name:"Nvidia Nemotron Nano 12B V2 VL",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:131072,maxTokens:131072,cost:{input:0.2,output:0.6,cacheRead:0,cacheWrite:0}}},{modelId:"nvidia/nemotron-nano-9b-v2",name:"Nvidia Nemotron Nano 9B V2",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131072,cost:{input:0.06,output:0.23,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-4-turbo",name:"GPT-4 Turbo",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:4096,cost:{input:10,output:30,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-4.1",name:"GPT-4.1",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"openai/gpt-4.1-mini",name:"GPT-4.1 mini",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:0.4,output:1.6,cacheRead:0.1,cacheWrite:0}}},{modelId:"openai/gpt-4.1-nano",name:"GPT-4.1 nano",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:1047576,maxTokens:32768,cost:{input:0.1,output:0.4,cacheRead:0.025,cacheWrite:0}}},{modelId:"openai/gpt-4o",name:"GPT-4o",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:2.5,output:10,cacheRead:1.25,cacheWrite:0}}},{modelId:"openai/gpt-4o-mini",name:"GPT-4o mini",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:0.15,output:0.6,cacheRead:0.075,cacheWrite:0}}},{modelId:"openai/gpt-5",name:"GPT-5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5-chat",name:"GPT 5 Chat",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5-codex",name:"GPT-5-Codex",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5-mini",name:"GPT-5 mini",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"openai/gpt-5-nano",name:"GPT-5 nano",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.05,output:0.4,cacheRead:0.005,cacheWrite:0}}},{modelId:"openai/gpt-5-pro",name:"GPT-5 pro",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:272000,cost:{input:15,output:120,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-5.1-codex",name:"GPT-5.1-Codex",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5.1-codex-max",name:"GPT 5.1 Codex Max",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5.1-codex-mini",name:"GPT 5.1 Codex Mini",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.25,output:2,cacheRead:0.025,cacheWrite:0}}},{modelId:"openai/gpt-5.1-instant",name:"GPT-5.1 Instant",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5.1-thinking",name:"GPT 5.1 Thinking",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.25,output:10,cacheRead:0.125,cacheWrite:0}}},{modelId:"openai/gpt-5.2",name:"GPT 5.2",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.2-chat",name:"GPT 5.2 Chat",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.2-codex",name:"GPT 5.2 Codex",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.2-pro",name:"GPT 5.2 ",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:21,output:168,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-5.3-chat",name:"GPT-5.3 Chat",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:16384,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.3-codex",name:"GPT 5.3 Codex",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:1.75,output:14,cacheRead:0.175,cacheWrite:0}}},{modelId:"openai/gpt-5.4",name:"GPT 5.4",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:2.5,output:15,cacheRead:0.25,cacheWrite:0}}},{modelId:"openai/gpt-5.4-mini",name:"GPT 5.4 Mini",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.75,output:4.5,cacheRead:0.075,cacheWrite:0}}},{modelId:"openai/gpt-5.4-nano",name:"GPT 5.4 Nano",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:400000,maxTokens:128000,cost:{input:0.2,output:1.25,cacheRead:0.02,cacheWrite:0}}},{modelId:"openai/gpt-5.4-pro",name:"GPT 5.4 Pro",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:128000,cost:{input:30,output:180,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-5.5",name:"GPT 5.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:5,output:30,cacheRead:0.5,cacheWrite:0}}},{modelId:"openai/gpt-5.5-pro",name:"GPT 5.5 Pro",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:128000,cost:{input:30,output:180,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-120b",name:"GPT OSS 120B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:131000,cost:{input:0.35,output:0.75,cacheRead:0.25,cacheWrite:0}}},{modelId:"openai/gpt-oss-20b",name:"GPT OSS 20B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:8192,cost:{input:0.05,output:0.2,cacheRead:0,cacheWrite:0}}},{modelId:"openai/gpt-oss-safeguard-20b",name:"GPT OSS Safeguard 20B",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:65536,cost:{input:0.075,output:0.3,cacheRead:0.037,cacheWrite:0}}},{modelId:"openai/o1",name:"o1",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:15,output:60,cacheRead:7.5,cacheWrite:0}}},{modelId:"openai/o3",name:"o3",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:2,output:8,cacheRead:0.5,cacheWrite:0}}},{modelId:"openai/o3-deep-research",name:"o3-deep-research",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:10,output:40,cacheRead:2.5,cacheWrite:0}}},{modelId:"openai/o3-mini",name:"o3-mini",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.55,cacheWrite:0}}},{modelId:"openai/o3-pro",name:"o3 Pro",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:20,output:80,cacheRead:0,cacheWrite:0}}},{modelId:"openai/o4-mini",name:"o4-mini",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:1e5,cost:{input:1.1,output:4.4,cacheRead:0.275,cacheWrite:0}}},{modelId:"perplexity/sonar",name:"Sonar",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:127000,maxTokens:8000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"perplexity/sonar-pro",name:"Sonar Pro",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:200000,maxTokens:8000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"stepfun/step-3.5-flash",name:"StepFun 3.5 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:262114,maxTokens:262114,cost:{input:0.09,output:0.3,cacheRead:0,cacheWrite:0.02}}},{modelId:"stepfun/step-3.7-flash",name:"Step 3.7 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:0.2,output:1.15,cacheRead:0.04,cacheWrite:0}}},{modelId:"xai/grok-4.1-fast-non-reasoning",name:"Grok 4.1 Fast Non-Reasoning",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:1e6,maxTokens:1e6,cost:{input:0.2,output:0.5,cacheRead:0.05,cacheWrite:0}}},{modelId:"xai/grok-4.1-fast-reasoning",name:"Grok 4.1 Fast Reasoning",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:1e6,cost:{input:0.2,output:0.5,cacheRead:0.05,cacheWrite:0}}},{modelId:"xai/grok-4.20-multi-agent",name:"Grok 4.20 Multi-Agent",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:2000000,maxTokens:2000000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"xai/grok-4.20-multi-agent-beta",name:"Grok 4.20 Multi Agent Beta",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:2000000,maxTokens:2000000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"xai/grok-4.20-non-reasoning",name:"Grok 4.20 Non-Reasoning",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:2000000,maxTokens:2000000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"xai/grok-4.20-non-reasoning-beta",name:"Grok 4.20 Beta Non-Reasoning",config:{api:"anthropic-messages",reasoning:!1,input:["text","image"],contextWindow:2000000,maxTokens:2000000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"xai/grok-4.20-reasoning",name:"Grok 4.20 Reasoning",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:2000000,maxTokens:2000000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"xai/grok-4.20-reasoning-beta",name:"Grok 4.20 Beta Reasoning",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:2000000,maxTokens:2000000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"xai/grok-4.3",name:"Grok 4.3",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:1e6,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"xai/grok-build-0.1",name:"Grok Build 0.1",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:1,output:2,cacheRead:0.2,cacheWrite:0}}},{modelId:"xiaomi/mimo-v2-flash",name:"MiMo V2 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:32000,cost:{input:0.1,output:0.3,cacheRead:0.01,cacheWrite:0}}},{modelId:"xiaomi/mimo-v2-pro",name:"MiMo V2 Pro",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:128000,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"xiaomi/mimo-v2.5",name:"MiMo M2.5",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:131100,cost:{input:0.14,output:0.28,cacheRead:0.0028,cacheWrite:0}}},{modelId:"xiaomi/mimo-v2.5-pro",name:"MiMo V2.5 Pro",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:1050000,maxTokens:131000,cost:{input:0.435,output:0.87,cacheRead:0.0036,cacheWrite:0}}},{modelId:"zai/glm-4.5",name:"GLM-4.5",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:96000,cost:{input:0.6,output:2.2,cacheRead:0.11,cacheWrite:0}}},{modelId:"zai/glm-4.5-air",name:"GLM 4.5 Air",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:128000,maxTokens:96000,cost:{input:0.2,output:1.1,cacheRead:0.03,cacheWrite:0}}},{modelId:"zai/glm-4.5v",name:"GLM 4.5V",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:66000,maxTokens:16000,cost:{input:0.6,output:1.8,cacheRead:0.11,cacheWrite:0}}},{modelId:"zai/glm-4.6",name:"GLM 4.6",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:96000,cost:{input:0.6,output:2.2,cacheRead:0.11,cacheWrite:0}}},{modelId:"zai/glm-4.6v",name:"GLM-4.6V",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:24000,cost:{input:0.3,output:0.9,cacheRead:0.05,cacheWrite:0}}},{modelId:"zai/glm-4.6v-flash",name:"GLM-4.6V-Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:128000,maxTokens:24000,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"zai/glm-4.7",name:"GLM 4.7",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:131000,maxTokens:40000,cost:{input:2.25,output:2.75,cacheRead:2.25,cacheWrite:0}}},{modelId:"zai/glm-4.7-flash",name:"GLM 4.7 Flash",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:131000,cost:{input:0.07,output:0.4,cacheRead:0,cacheWrite:0}}},{modelId:"zai/glm-4.7-flashx",name:"GLM 4.7 FlashX",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:128000,cost:{input:0.06,output:0.4,cacheRead:0.01,cacheWrite:0}}},{modelId:"zai/glm-5",name:"GLM 5",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:202800,maxTokens:131100,cost:{input:1,output:3.2,cacheRead:0.2,cacheWrite:0}}},{modelId:"zai/glm-5-turbo",name:"GLM 5 Turbo",config:{api:"anthropic-messages",reasoning:!0,input:["text"],contextWindow:202800,maxTokens:131100,cost:{input:1.2,output:4,cacheRead:0.24,cacheWrite:0}}},{modelId:"zai/glm-5.1",name:"GLM 5.1",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:202800,maxTokens:64000,cost:{input:1.4,output:4.4,cacheRead:0.26,cacheWrite:0}}},{modelId:"zai/glm-5v-turbo",name:"GLM 5V Turbo",config:{api:"anthropic-messages",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:128000,cost:{input:1.2,output:4,cacheRead:0.24,cacheWrite:0}}}]},xai:{name:"xai",config:{api:"openai-completions",baseUrl:"https://api.x.ai/v1",apiKey:"XAI_API_KEY"},models:[{modelId:"grok-3",name:"Grok 3",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:8192,cost:{input:3,output:15,cacheRead:0.75,cacheWrite:0}}},{modelId:"grok-3-fast",name:"Grok 3 Fast",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:131072,maxTokens:8192,cost:{input:5,output:25,cacheRead:1.25,cacheWrite:0}}},{modelId:"grok-4.20-0309-non-reasoning",name:"Grok 4.20 (Non-Reasoning)",config:{api:"openai-completions",reasoning:!1,input:["text","image"],contextWindow:1e6,maxTokens:30000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"grok-4.20-0309-reasoning",name:"Grok 4.20 (Reasoning)",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:30000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"grok-4.3",name:"Grok 4.3",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1e6,maxTokens:30000,cost:{input:1.25,output:2.5,cacheRead:0.2,cacheWrite:0}}},{modelId:"grok-build-0.1",name:"Grok Build 0.1",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:256000,maxTokens:256000,cost:{input:1,output:2,cacheRead:0.2,cacheWrite:0}}},{modelId:"grok-code-fast-1",name:"Grok Code Fast 1",config:{api:"openai-completions",reasoning:!1,input:["text"],contextWindow:32768,maxTokens:8192,cost:{input:0.2,output:1.5,cacheRead:0.02,cacheWrite:0}}}]},xiaomi:{name:"xiaomi",config:{api:"openai-completions",baseUrl:"https://api.xiaomimimo.com/v1",apiKey:"XIAOMI_API_KEY"},models:[{modelId:"mimo-v2-flash",name:"MiMo-V2-Flash",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:262144,maxTokens:65536,cost:{input:0.1,output:0.3,cacheRead:0.01,cacheWrite:0}}},{modelId:"mimo-v2-omni",name:"MiMo-V2-Omni",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0.08,cacheWrite:0}}},{modelId:"mimo-v2-pro",name:"MiMo-V2-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"mimo-v2.5",name:"MiMo-V2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0.08,cacheWrite:0}}},{modelId:"mimo-v2.5-pro",name:"MiMo-V2.5-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"mimo-v2.5-pro-ultraspeed",name:"MiMo-V2.5-Pro-UltraSpeed",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1.305,output:2.61,cacheRead:0.0108,cacheWrite:0}}}]},"xiaomi-token-plan-ams":{name:"xiaomi-token-plan-ams",config:{api:"openai-completions",baseUrl:"https://token-plan-ams.xiaomimimo.com/v1",apiKey:"XIAOMI_TOKEN_PLAN_AMS_API_KEY"},models:[{modelId:"mimo-v2-omni",name:"MiMo-V2-Omni",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0.08,cacheWrite:0}}},{modelId:"mimo-v2-pro",name:"MiMo-V2-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"mimo-v2.5",name:"MiMo-V2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0.08,cacheWrite:0}}},{modelId:"mimo-v2.5-pro",name:"MiMo-V2.5-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"mimo-v2.5-pro-ultraspeed",name:"MiMo-V2.5-Pro-UltraSpeed",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1.305,output:2.61,cacheRead:0.0108,cacheWrite:0}}}]},"xiaomi-token-plan-cn":{name:"xiaomi-token-plan-cn",config:{api:"openai-completions",baseUrl:"https://token-plan-cn.xiaomimimo.com/v1",apiKey:"XIAOMI_TOKEN_PLAN_CN_API_KEY"},models:[{modelId:"mimo-v2-omni",name:"MiMo-V2-Omni",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0.08,cacheWrite:0}}},{modelId:"mimo-v2-pro",name:"MiMo-V2-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"mimo-v2.5",name:"MiMo-V2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0.08,cacheWrite:0}}},{modelId:"mimo-v2.5-pro",name:"MiMo-V2.5-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"mimo-v2.5-pro-ultraspeed",name:"MiMo-V2.5-Pro-UltraSpeed",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1.305,output:2.61,cacheRead:0.0108,cacheWrite:0}}}]},"xiaomi-token-plan-sgp":{name:"xiaomi-token-plan-sgp",config:{api:"openai-completions",baseUrl:"https://token-plan-sgp.xiaomimimo.com/v1",apiKey:"XIAOMI_TOKEN_PLAN_SGP_API_KEY"},models:[{modelId:"mimo-v2-omni",name:"MiMo-V2-Omni",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:262144,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0.08,cacheWrite:0}}},{modelId:"mimo-v2-pro",name:"MiMo-V2-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"mimo-v2.5",name:"MiMo-V2.5",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:1048576,maxTokens:131072,cost:{input:0.4,output:2,cacheRead:0.08,cacheWrite:0}}},{modelId:"mimo-v2.5-pro",name:"MiMo-V2.5-Pro",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1,output:3,cacheRead:0.2,cacheWrite:0}}},{modelId:"mimo-v2.5-pro-ultraspeed",name:"MiMo-V2.5-Pro-UltraSpeed",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1048576,maxTokens:131072,cost:{input:1.305,output:2.61,cacheRead:0.0108,cacheWrite:0}}}]},zai:{name:"zai",config:{api:"openai-completions",baseUrl:"https://api.z.ai/api/coding/paas/v4",apiKey:"ZAI_API_KEY"},models:[{modelId:"glm-4.5-air",name:"GLM-4.5-Air",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:98304,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-4.7",name:"GLM-4.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-5-turbo",name:"GLM-5-Turbo",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-5.1",name:"GLM-5.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-5.2",name:"GLM-5.2",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-5v-turbo",name:"GLM-5V-Turbo",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}}]},"zai-coding-cn":{name:"zai-coding-cn",config:{api:"openai-completions",baseUrl:"https://open.bigmodel.cn/api/coding/paas/v4",apiKey:""},models:[{modelId:"glm-4.5-air",name:"GLM-4.5-Air",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:131072,maxTokens:98304,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-4.7",name:"GLM-4.7",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:204800,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-5-turbo",name:"GLM-5-Turbo",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-5.1",name:"GLM-5.1",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:200000,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-5.2",name:"GLM-5.2",config:{api:"openai-completions",reasoning:!0,input:["text"],contextWindow:1e6,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}},{modelId:"glm-5v-turbo",name:"GLM-5V-Turbo",config:{api:"openai-completions",reasoning:!0,input:["text","image"],contextWindow:200000,maxTokens:131072,cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}}]}};class Qr{prismaClient;constructor(B=VB){this.prismaClient=B}async initBuiltinProviders(B){let Q=await this.prismaClient.team.findUnique({where:{id:B},include:{_count:{select:{providers:!0}}}});if(Q&&Q._count.providers===0){let F=Object.entries(lwQ).reverse();for(let[U,I]of F){let G=I;await this.prismaClient.provider.create({data:{teamId:Q.id,name:U,config:G.config,isBuiltin:!0,models:{create:G.models.map((Z)=>({modelId:Z.modelId,name:Z.name,config:Z.config}))}}})}}}async listByTeam(B){return(await this.prismaClient.provider.findMany({where:{teamId:B},include:{_count:{select:{models:!0}}},orderBy:{id:"desc"}})).map((F)=>({...F,modelsCount:F._count.models,_count:void 0}))}async getById(B){return this.prismaClient.provider.findUnique({where:{id:B}})}async listModelsByProvider(B,Q){return this.prismaClient.model.findMany({where:{providerId:Q,provider:{teamId:B}},orderBy:{id:"asc"}})}async create(B,Q,F,U){return this.prismaClient.provider.create({data:{teamId:B,name:Q,config:F,models:{create:U.map((I)=>({modelId:I.modelId,name:I.name,config:I.config}))}},include:{models:!0}})}async update(B,Q,F,U){return this.prismaClient.$transaction(async(I)=>{return await I.model.deleteMany({where:{providerId:Q}}),I.provider.update({where:{id:Q,teamId:B},data:{config:F,models:{create:U.map((G)=>({modelId:G.modelId,name:G.name,config:G.config}))}},include:{models:!0}})})}async delete(B,Q){if(!await this.prismaClient.provider.findUnique({where:{id:Q,teamId:B}}))throw Error("Provider not found");return this.prismaClient.provider.delete({where:{id:Q,teamId:B}})}}var uwQ=new Qr;class qwQ{async upsertMetadata(B,Q,F,U){return await VB.userMetadata.upsert({where:{userIdTeamIdKey:{userId:B,teamId:Q,key:F}},update:{value:U},create:{userId:B,teamId:Q,key:F,value:U}})}async listMetadata(B,Q){return(await VB.userMetadata.findMany({where:{userId:B,teamId:Q},orderBy:{key:"asc"}})).map((U)=>({key:U.key,value:U.value}))}async getMetadata(B,Q,F){let U=await VB.userMetadata.findUnique({where:{userIdTeamIdKey:{userId:B,teamId:Q,key:F}}});if(!U)return null;return{key:U.key,value:U.value}}}var jwQ=new qwQ;var u6F=/<@([^>]+)>/g;class nwQ{async create(B){this.createAsync(B).catch((Q)=>{console.error("Failed to create notification asynchronously:",Q)})}async createAsync(B){let Q=B.projectId;if(!Q&&B.assetId){let U=await VB.asset.findUnique({where:{id:B.assetId},include:{project:!0}});if(U?.projectId)Q=U.projectId}if(Q){let U=await VB.project.findUnique({where:{id:Q}});if(U&&!U.enableNotification)return}let F=async(U,I)=>{try{await VB.notification.create({data:{type:U,teamId:B.teamId,projectId:Q,creatorId:B.creatorId,assetId:B.assetId,taskId:B.taskId,userId:I}})}catch(G){console.error("Failed to save notification",{type:U,err:G})}};if(await F(B.type,B.userId),(B.type===eV.comment_created||B.type===eV.reply_created)&&B.commentMessage){let U=[...B.commentMessage.matchAll(u6F)],I=new Set;for(let G of U)if(G.length>1){let Z=G[1];if(I.has(Z))continue;if(I.add(Z),B.creatorId===Z)continue;await F(eV.mention,Z)}}}async getListWhere(B,Q,F,U){let I=[];if(F.scope==="project")I=(await VB.projectMember.findMany({where:{teamMemberId:F.id},include:{project:!0}})).filter((b)=>b.project).map((b)=>b.projectId);let G=await jwQ.getMetadata(Q,B,"notification_settings"),Z=G?G.value:{comments:!0,replies:!0,mentions:!0,yourUploads:!1,otherUploads:!0,statusUpdates:!0},W=[];if(Z.comments)W.push({type:eV.comment_created,userId:null});if(Z.replies)W.push({type:eV.reply_created,userId:Q}),W.push({type:eV.reply_created,userId:null});if(Z.mentions)W.push({type:eV.mention,userId:Q});if(Z.yourUploads&&Z.otherUploads)W.push({type:eV.successful_file_uploaded});else if(Z.yourUploads)W.push({type:eV.successful_file_uploaded,creatorId:Q});else if(Z.otherUploads)W.push({type:eV.successful_file_uploaded,creatorId:{not:Q}});if(Z.statusUpdates)W.push({type:eV.metadata_field_updated_status});W.push({type:eV.new_user_join_team}),W.push({type:eV.new_user_join_project});let g={teamId:B,OR:W,AND:[{OR:[...Z.yourUploads?[{type:eV.successful_file_uploaded,creatorId:Q}]:[],{creatorId:null},{creatorId:{not:Q}}]}]};if(F.scope==="project"){let V=Array.isArray(g.AND)?g.AND:g.AND?[g.AND]:[];g.AND=[...V,{OR:[{type:eV.mention},{projectId:{in:I}}]}]}if(U&&F.lastReadNotification){let V=Array.isArray(g.AND)?g.AND:g.AND?[g.AND]:[];g.AND=[...V,{id:{gt:F.lastReadNotification.id}}]}return g}async getUnreadCount(B,Q){let F=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B,userId:Q}},include:{lastReadNotification:!0}});if(!F)return 0;let U=await this.getListWhere(B,Q,F,!0);return VB.notification.count({where:U})}async list(B,Q,F){let U=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B,userId:Q}},include:{lastReadNotification:!0}});if(!U)throw Error("failed to get team member");let I=await this.getListWhere(B,Q,U,!!F.unreadOnly);return $V(async(G,Z)=>{let W=await VB.notification.findMany({where:I,orderBy:{id:"desc"},skip:G,take:Z,include:{creator:!0,team:!0,project:!0,asset:!0,user:!0}});return Promise.all(W.map(async(g)=>{return this.toNotificationInfo(g,U.lastReadNotification)}))},null,{after:F.after,first:F.pageSize})}async markRead(B,Q,F){let U=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B,userId:Q}},include:{lastReadNotification:!0}});if(!U)throw Error("failed to get team member");if(!await VB.notification.findUnique({where:{id:F}}))throw Error("notification not found");let G=!0;if(U.lastReadNotification){if(F<=U.lastReadNotification.id)G=!1}if(G)await VB.teamMember.update({where:{id:U.id},data:{lastReadNotificationId:F}})}async toNotificationInfo(B,Q){let F={id:B.id,type:B.type||void 0,createdAt:B.createdAt.toISOString(),isRead:Q!==null&&B.id<=Q.id};if(B.creator)F.creator={id:B.creator.id,name:B.creator.name};if(B.team)F.team={id:B.team.id,name:B.team.name};if(B.project)F.project={id:B.project.id,name:B.project.name};if(B.user)F.user={id:B.user.id,name:B.user.name};if(B.asset){let U=B.asset,I="",G="",Z=0,W=0,g=U.media;if(g){let V=process.env.S3_BUCKET||"shumai";try{if(g.sprite){if(I=await yF.presign(V,g.sprite.key,"GET"),g.poster)G=await yF.presign(V,g.poster.key||"","GET");if(g.metadata)Z=g.metadata.originalWidth,W=g.metadata.originalHeight}else if(g.thumbnail)I=await yF.presign(V,g.thumbnail.key||"","GET"),G=I}catch(b){console.error("Failed to generate presigned url for notification asset preview:",b)}}F.asset={id:U.id,name:U.name,mediaType:U.mediaType||void 0,preview:I||void 0,thumbnailUrl:G||void 0,originalWidth:Z||void 0,originalHeight:W||void 0}}return F}}var iwQ=new nwQ;var YI=class extends Error{res;status;constructor(B=500,Q){super(Q?.message,{cause:Q?.cause});this.res=Q?.res,this.status=B}getResponse(){if(this.res)return new Response(this.res.body,{status:this.status,headers:this.res.headers});return new Response(this.message,{status:this.status})}};class pwQ{async ensureDefaultTeam(){let B=await VB.team.findFirst({where:{name:"Default Team"}});if(!B)B=await VB.team.create({data:{name:"Default Team",settings:{transcode:{videoStrategy:"best_match"}},sandbox:{create:{}}}}),await uwQ.initBuiltinProviders(B.id);return B}async createTeam(B,Q){return await VB.$transaction(async(F)=>{let U=await F.team.create({data:{name:Q.name,settings:{},sandbox:{create:{}}}}),I=await F.asset.create({data:{name:"root",type:"root",status:"processed"}}),G=await F.team.update({where:{id:U.id},data:{rootFolderId:I.id},include:{rootFolder:!0}});return await F.teamMember.create({data:{teamId:U.id,userId:B.id,role:"owner",scope:"team"}}),await new Qr(F).initBuiltinProviders(U.id),this.toTeamInfo(G)})}async getUserTeams(B){let Q={members:{some:{userId:B.userId}}};return await $V(async(F,U)=>{return(await VB.team.findMany({where:Q,skip:F,take:U,orderBy:{id:"desc"},include:{rootFolder:!0}})).map(this.toTeamInfo)},null,B.pagination)}async joinTeam(B){if(!await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B.teamId,userId:B.userId}}}))await VB.teamMember.create({data:{teamId:B.teamId,userId:B.userId,role:"reviewer",scope:"team"}})}async getMe(B){let Q=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B.teamId,userId:B.user.id}},include:{user:!0}});if(!Q)throw new YI(403,{message:"user is not a team member"});let F=await iwQ.getUnreadCount(B.teamId,B.user.id);return{id:Q.user.id,name:Q.user.name,email:Q.user.email||void 0,role:Q.role,image:await MX(Q.user.image),unreadNotificationCount:F}}async updateMe(B,Q){let F={};if(Q.name!==void 0)F.name=Q.name;if(Q.imageKey!==void 0)F.image=Q.imageKey;await VB.user.update({where:{id:B},data:F})}async getTeamMembers(B){let Q=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B.teamId,userId:B.userId}}});if(!Q)throw new YI(403,{message:"Requester is not a team member"});let F=await VB.teamMember.findMany({where:{teamId:B.teamId,...B.includeAgents?{user:{OR:[{type:"human"},{type:"agent",agent:{type:"chat",enabled:!0}}]}}:{user:{type:{not:"agent"}}}},include:{user:!0,projectMembers:!0}}),U=F;if(Q.scope==="project"){let I=await VB.projectMember.findMany({where:{teamMemberId:Q.id},select:{projectId:!0}}).then((G)=>G.map((Z)=>Z.projectId));U=F.filter((G)=>{if(G.scope==="team")return!0;return G.projectMembers.some((Z)=>I.includes(Z.projectId))})}return Promise.all(U.map(async(I)=>({id:I.user.id,name:I.user.name,email:void 0,role:I.role,type:I.user.type||void 0,image:await MX(I.user.image),scope:I.scope})))}async updateMemberRole(B){let Q=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B.teamId,userId:B.userId}}});if(!Q)throw new YI(404,{message:"Member not found"});if(Q.role==="owner")throw new YI(403,{message:"Cannot change the role of an owner"});await VB.teamMember.update({where:{id:Q.id},data:{role:B.role}})}async removeMember(B,Q){let F=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B,userId:Q}}});if(!F)throw new YI(404,{message:"Member not found"});if(F.role==="owner")throw new YI(403,{message:"Cannot remove an owner"});await VB.teamMember.delete({where:{id:F.id}})}async getSettings(B){let Q=await VB.team.findUnique({where:{id:B}});if(!Q)throw new YI(404,{message:"team not found"});let F=Q.settings||{},U=await VB.agent.findFirst({where:{teamId:B,type:"embedding",enabled:!0}});return F.semanticSearchEnabled=!!U,F}async updateSettings(B,Q,F){let U=await VB.team.findUnique({where:{id:B}});if(!U)throw new YI(404,{message:"team not found"});let I=U.settings||{};if(Q==="transcode.videoStrategy"){if(!I.transcode)I.transcode={};I.transcode.videoStrategy=F,delete I["transcode.videoStrategy"]}else I[Q]=F;return(await VB.team.update({where:{id:B},data:{settings:I}})).settings||{}}async getSandboxSettings(B){let Q=await VB.sandbox.findUnique({where:{teamId:B}});return{allowedDomains:Q?.allowedDomains||[],pendingDomains:Q?.pendingDomains||[]}}async updateSandboxSettings(B,Q){let F=await VB.sandbox.upsert({where:{teamId:B},create:{teamId:B,allowedDomains:Q.allowedDomains,pendingDomains:Q.pendingDomains},update:{allowedDomains:Q.allowedDomains,pendingDomains:Q.pendingDomains}});return{allowedDomains:F.allowedDomains,pendingDomains:F.pendingDomains}}async getSignupInfo(){let B=await VB.user.count();return{initialized:B>0,userCount:B,demoMode:process.env.SHUMAI_DEMO_MODE==="1"}}toTeamInfo(B){return{id:B.id,name:B.name,rootFolder:B.rootFolder?.id||B.rootFolderId||void 0,updatedAt:B.updatedAt}}}var Fr=new pwQ;class awQ{async createTeamInvite(B){let Q=NG(),F=await VB.invite.create({data:{code:Q,teamId:B.teamId,inviterId:B.inviterId,role:B.role}});return this.getInvite(F.code)}async createProjectInvite(B){let Q=await VB.project.findUniqueOrThrow({where:{id:B.projectId},include:{team:!0}}),F=NG(),U=await VB.invite.create({data:{code:F,teamId:Q.teamId,projectId:Q.id,inviterId:B.inviterId,role:B.role}});return this.getInvite(U.code)}async getInvite(B){return await VB.invite.findUniqueOrThrow({where:{code:B},include:{team:!0,project:!0,inviter:!0}})}async validateInvite(B){let Q=await VB.invite.findUnique({where:{code:B}});if(!Q)return!1;if(Q.used)return!1;return!0}async consumeInvite(B,Q){await VB.$transaction(async(F)=>{let U=await F.invite.findUniqueOrThrow({where:{code:B},include:{team:!0,project:!0}});if(U.used)throw Error("invite code already used");let I=await F.user.findUniqueOrThrow({where:{id:Q}}),G=await F.teamMember.findUnique({where:{teamIdUserId:{teamId:U.teamId,userId:I.id}}});if(!U.projectId)if(G){if(G.scope==="project")await F.teamMember.update({where:{id:G.id},data:{scope:"team",role:U.role}})}else await F.teamMember.create({data:{teamId:U.teamId,userId:I.id,role:U.role,scope:"team"}});else{if(!G)G=await F.teamMember.create({data:{teamId:U.teamId,userId:I.id,role:"reviewer",scope:"project"}});if(!await F.projectMember.findUnique({where:{projectIdTeamMemberId:{projectId:U.projectId,teamMemberId:G.id}}}))await F.projectMember.create({data:{projectId:U.projectId,teamMemberId:G.id,role:U.role}})}await F.invite.update({where:{id:U.id},data:{used:!0}})})}}var Ur=new awQ;var FXG=ULB({database:fwQ(VB,{provider:"postgresql"}),emailAndPassword:{enabled:!0,minPasswordLength:3},secret:process.env.BETTER_AUTH_SECRET,baseURL:process.env.BETTER_AUTH_URL||`http://localhost:${process.env.SHUMAI_SERVER_PORT||"3000"}`,basePath:"/api/auth",trustedOrigins:[`http://localhost:${process.env.SHUMAI_SERVER_PORT||"3000"}`,`http://127.0.0.1:${process.env.SHUMAI_SERVER_PORT||"3000"}`],advanced:{disableCSRFCheck:!0},hooks:{before:I2(async(B)=>{if(B.path==="/sign-up/email"){let F=B.body?.inviteCode;if((await Fr.getSignupInfo()).initialized){if(!F)return console.log("[Better Auth Hook] Public signup is disabled"),B.json({error:"Public signup is disabled"},{status:403});if(!await Ur.validateInvite(F))return B.json({error:"Invalid or expired invite code"},{status:400})}}}),after:I2(async(B)=>{if(B.path==="/sign-up/email"){let Q=B.context.returned;if(Q&&Q.user&&Q.user.id){let F=Q.user,I=B.body?.inviteCode;try{let G=await Fr.getSignupInfo(),Z=await Fr.ensureDefaultTeam();if(G.userCount===1)await VB.teamMember.create({data:{teamId:Z.id,userId:F.id,role:"owner",scope:"team"}});else if(!I)await VB.teamMember.create({data:{teamId:Z.id,userId:F.id,role:"editor",scope:"team"}});if(I)await Ur.consumeInvite(I,F.id)}catch(G){console.error(`[Better Auth Hook] Error in after hook: ${G}`)}}}})}});class owQ{async hasPermission(B){if(!B.user)throw new YI(401,{message:"User is required"});let{teamId:Q,projectId:F}=await this.resolveContext(B.type,B.id),U=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:Q,userId:B.user.id}}});if(!U)throw new YI(403,{message:"User is not a member of the team"});if(F){let I=await VB.projectMember.findUnique({where:{projectIdTeamMemberId:{projectId:F,teamMemberId:U.id}}});if(I)return this.checkRole(I.role,B.permission)}if(U.scope==="team")return this.checkRole(U.role,B.permission);if(!F){if(B.permission==="Read")return}throw new YI(403,{message:"User has only project scope"})}async resolveContext(B,Q){switch(B){case"team":return{teamId:Q};case"project":{let F=await VB.project.findUnique({where:{id:Q},select:{teamId:!0}});if(!F)throw new YI(404,{message:"Project not found"});return{teamId:F.teamId,projectId:Q}}case"asset":{let F=await VB.asset.findUnique({where:{id:Q},select:{parentId:!0,teamRootFolder:{select:{id:!0}},project:{select:{id:!0,teamId:!0}}}});if(!F)throw new YI(404,{message:"Asset not found"});if(F.project)return{teamId:F.project.teamId,projectId:F.project.id};if(F.teamRootFolder)return{teamId:F.teamRootFolder.id};if(F.parentId)return this.resolveContext("asset",F.parentId);throw new YI(403,{message:"Could not resolve context for asset"})}case"collection":{let F=await VB.collection.findUnique({where:{id:Q},include:{project:!0}});if(!F)throw new YI(404,{message:"Collection not found"});return{teamId:F.project.teamId,projectId:F.projectId}}case"agent":{let F=await VB.agent.findUnique({where:{id:Q},select:{teamId:!0}});if(!F)throw new YI(404,{message:"Agent not found"});return{teamId:F.teamId}}case"agentSession":{let F=await VB.agentSession.findUnique({where:{id:Q},include:{agent:!0}});if(!F)throw new YI(404,{message:"Agent session not found"});return{teamId:F.agent.teamId}}case"share":{let F=await VB.shareLink.findUnique({where:{id:Q},include:{project:!0}});if(!F)throw new YI(404,{message:"Share not found"});return{teamId:F.project.teamId,projectId:F.projectId}}case"metadataField":{let F=await VB.metadataField.findUnique({where:{key:Q},select:{teamId:!0,projectId:!0}});if(!F)throw new YI(404,{message:"Metadata field not found"});if(F.projectId)return{teamId:(await VB.project.findUnique({where:{id:F.projectId},select:{teamId:!0}})).teamId,projectId:F.projectId};if(!F.teamId)throw new YI(403,{message:"Metadata field has no context"});return{teamId:F.teamId}}case"skill":{let F=await VB.skill.findUnique({where:{id:Q},select:{teamId:!0}});if(!F)throw new YI(404,{message:"Skill not found"});return{teamId:F.teamId}}case"provider":{let F=await VB.provider.findUnique({where:{id:Q},select:{teamId:!0}});if(!F)throw new YI(404,{message:"Provider not found"});return{teamId:F.teamId}}case"invite":{let F=await VB.invite.findUnique({where:{id:Q},select:{teamId:!0,projectId:!0}});if(!F)throw new YI(404,{message:"Invite not found"});return{teamId:F.teamId,projectId:F.projectId??void 0}}case"comment":{let F=await VB.assetComment.findUnique({where:{id:Q},include:{asset:{include:{project:!0}}}});if(!F)throw new YI(404,{message:"Comment not found"});if(!F.asset.project)throw new YI(403,{message:"Comment asset has no project"});return{teamId:F.asset.project.teamId,projectId:F.asset.projectId}}default:throw new YI(403,{message:`Unsupported resource type: ${B}`})}}checkRole(B,Q){switch(Q){case"Read":return;case"Edit":if(B==="owner"||B==="editor")return;break;case"Admin":if(B==="owner")return;break}throw new YI(403,{message:"Permission denied"})}}var rd=new owQ;class rwQ{async createCollection(B,Q,F){return await VB.collection.create({data:{name:Q.name,filter:Q.filter,projectId:B,creatorId:F},include:{creator:!0}})}async updateCollection(B,Q){return await VB.collection.update({where:{id:B},data:{...Q.name&&{name:Q.name},...Q.filter&&{filter:Q.filter}},include:{creator:!0}})}async deleteCollection(B){return await VB.collection.delete({where:{id:B}})}async getCollection(B){return await VB.collection.findUnique({where:{id:B},include:{creator:!0}})}async listCollections(B,Q){return await $V((F,U)=>VB.collection.findMany({where:{projectId:B},include:{creator:!0},orderBy:{id:"desc"},skip:F,take:U}),()=>VB.collection.count({where:{projectId:B}}),Q)}}var VXG=new rwQ;var swQ=[{key:"file_size",scope:"SYSTEM",readOnly:!0,config:{name:"File Size",type:"number",number:{scale:0}}},{key:"resolution_width",scope:"SYSTEM",readOnly:!0,config:{name:"Resolution Width",type:"number",number:{scale:0}}},{key:"resolution_height",scope:"SYSTEM",readOnly:!0,config:{name:"Resolution Height",type:"number",number:{scale:0}}},{key:"name",scope:"SYSTEM",readOnly:!0,config:{name:"Name",type:"text",text:{}}},{key:"rating",scope:"SYSTEM",readOnly:!1,config:{name:"Rating",type:"rating",rating:{maxValue:5}}},{key:"duration",scope:"SYSTEM",readOnly:!0,config:{name:"Duration",type:"number",number:{scale:0}}},{key:"bitRate",scope:"SYSTEM",readOnly:!0,config:{name:"Bit Rate",type:"number",number:{scale:1}}},{key:"frame_rate",scope:"SYSTEM",readOnly:!0,config:{name:"Frame Rate",type:"number",number:{scale:3}}},{key:"keywords",scope:"SYSTEM",readOnly:!1,config:{name:"Keywords",type:"selectMulti",selectMulti:{options:[]}}},{key:"file_type",scope:"SYSTEM",readOnly:!0,config:{name:"File Type",type:"select",select:{options:[{id:"video",displayName:"Video",color:"system"},{id:"audio",displayName:"Audio",color:"system"},{id:"image",displayName:"Image",color:"system"},{id:"document",displayName:"Document",color:"system"},{id:"file",displayName:"File",color:"system"}]}}},{key:"audio_bit_depth",scope:"SYSTEM",readOnly:!0,config:{name:"Audio Bit Depth",type:"number",number:{scale:0}}},{key:"audio_channels",scope:"SYSTEM",readOnly:!0,config:{name:"Audio Channels",type:"number",number:{scale:0}}},{key:"audio_codec",scope:"SYSTEM",readOnly:!0,config:{name:"Audio Codec",type:"text",text:{}}},{key:"audio_sample_rate",scope:"SYSTEM",readOnly:!0,config:{name:"Audio Sample Rate",type:"number",number:{scale:0}}},{key:"video_codec",scope:"SYSTEM",readOnly:!0,config:{name:"Video Codec",type:"text",text:{}}},{key:"format",scope:"SYSTEM",readOnly:!0,config:{name:"Format",type:"text",text:{}}},{key:"status",scope:"SYSTEM",readOnly:!1,config:{name:"Status",type:"select",select:{options:[{id:"needs_review",displayName:"Needs Review",color:"red"},{id:"in_progress",displayName:"In Progress",color:"yellow"},{id:"approved",displayName:"Approved",color:"green"}]}}}];class twQ{client;constructor(B=VB){this.client=B}async syncSystemFields(){await this.client.$transaction(async(B)=>{for(let Q of swQ)await B.metadataField.upsert({where:{key:Q.key},update:{scope:Q.scope,readOnly:Q.readOnly,config:Q.config},create:{key:Q.key,scope:Q.scope,readOnly:Q.readOnly??!1,config:Q.config}})})}async createTeamField(B,Q){return await this.client.metadataField.create({data:{key:NG(),scope:"TEAM",teamId:B,config:Q.config,aiAutofill:Q.aiAutofill,description:Q.description}})}async listTeamFields(B){return await this.client.metadataField.findMany({where:{OR:[{scope:"SYSTEM"},{AND:[{scope:"TEAM"},{teamId:B}]}]}})}async getFieldByKey(B){return this.client.metadataField.findUnique({where:{key:B}})}async updateTeamField(B,Q,F){let U=await this.client.metadataField.findUnique({where:{key:Q}});if(!U)throw Error("Field not found");if(U.teamId!==B)throw Error("Field does not belong to this team");return await this.client.metadataField.update({where:{id:U.id},data:{config:F.config,aiAutofill:F.aiAutofill??U.aiAutofill,description:F.description??U.description}})}async deleteTeamField(B,Q){let F=await this.client.metadataField.findUnique({where:{key:Q}});if(!F)throw Error("Field not found");if(F.teamId!==B)throw Error("Field does not belong to this team");await this.client.metadataField.delete({where:{key:Q}})}async createProjectField(B,Q){let F=await this.client.project.findUnique({where:{id:B},select:{teamId:!0}});if(!F)throw Error("Project not found");return await this.client.metadataField.create({data:{key:NG(),scope:"PROJECT",projectId:B,teamId:F.teamId,config:Q.config,aiAutofill:Q.aiAutofill,description:Q.description}})}async listProjectFields(B,Q){let F=await this.client.project.findUnique({where:{id:Q},select:{teamId:!0}});if(!F)throw Error("Project not found");let U=await this.client.metadataField.findMany({where:{OR:[{scope:"SYSTEM"},{AND:[{scope:"TEAM"},{teamId:F.teamId}]},{AND:[{scope:"PROJECT"},{projectId:Q}]}]}}),I=B?await this.getProjectFieldsOrder(B,Q):[],G=new Map;I.forEach((g,V)=>{G.set(g.fieldId,V)});let Z=new Map;I.forEach((g)=>{Z.set(g.fieldId,g.visible)});let W=U.map((g)=>({field:g,visible:Z.has(g.key)?Z.get(g.key):B===null}));return W.sort((g,V)=>{let b=G.get(g.field.key),X=G.get(V.field.key);if(b!==void 0&&X!==void 0)return b-X;if(b!==void 0)return-1;if(X!==void 0)return 1;let C=g.field.config?.name||"",N=V.field.config?.name||"";return C.localeCompare(N)}),W}async getProjectFieldsOrder(B,Q){let F=this.getProjectFieldOrderKey(B,Q),U=await this.client.systemSettings.findUnique({where:{key:F}});if(!U||!U.value)return[];return U.value}async updateProjectFieldsOrder(B,Q,F){let U=this.getProjectFieldOrderKey(B,Q);await this.client.systemSettings.upsert({where:{key:U},create:{key:U,value:F},update:{value:F}})}getProjectFieldOrderKey(B,Q){return`project_field_order:${B}:${Q}`}async updateProjectField(B,Q,F){let U=await this.client.metadataField.findUnique({where:{key:Q}});if(!U)throw Error("Field not found");if(U.projectId!==B)throw Error("Field does not belong to this project");return await this.client.metadataField.update({where:{id:U.id},data:{config:F.config,aiAutofill:F.aiAutofill??U.aiAutofill,description:F.description??U.description}})}async deleteProjectField(B,Q){let F=await this.client.metadataField.findUnique({where:{key:Q}});if(!F)throw Error("Field not found");if(F.projectId!==B)throw Error("Field does not belong to this project");await this.client.metadataField.delete({where:{key:Q}})}async updateAssetMetadata(B,Q,F=!1){let U=await TX.resolveLatestVersionId(B);await this.client.$transaction(async(I)=>{for(let G of Q){let Z=await I.metadataField.findUnique({where:{key:G.key}});if(Z?.readOnly&&!F)throw Error(`Field ${Z.key} is read-only`);let W=G.value,g=null,V=null,b=null,X=null,C=null;if(typeof W==="string"){let N=new Date(W);if(!isNaN(N.getTime())&&W.includes("T")&&W.includes("-"))C=N;else g=W}else if(typeof W==="number")V=W;else if(typeof W==="boolean")b=W;else if(W instanceof Date)C=W;else if(Array.isArray(W))X=W;else if(W===null);else if(typeof W==="object")X=W;else g=String(W);await I.assetMetadataValue.upsert({where:{assetId_fieldKey:{assetId:U,fieldKey:G.key}},create:{assetId:U,fieldKey:G.key,stringValue:g,numberValue:V,booleanValue:b,jsonValue:X,dateValue:C},update:{stringValue:g,numberValue:V,booleanValue:b,jsonValue:X,dateValue:C}})}await I.asset.update({where:{id:U},data:{updatedAt:new Date}})})}}var Ir=new twQ;class ewQ{async createProject(B,Q){if(!await VB.team.findUnique({where:{id:Q.teamId}}))throw Error("Team not found");let U=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:Q.teamId,userId:B.id}}});if(!U)throw Error("creator is not a team member");let I=await VB.$transaction(async(G)=>{let Z=await G.project.create({data:{name:Q.name,teamId:Q.teamId,enableNotification:Q.enableNotification??!0,coverImageKey:Q.coverImageKey}}),W=await G.asset.create({data:{name:"root",type:"root",status:"processed",projectId:Z.id}}),g=await G.asset.create({data:{name:"share_root",type:"share_root",status:"processed",projectId:Z.id}}),V=await G.project.update({where:{id:Z.id},data:{rootFolderId:W.id,shareRootId:g.id},include:{rootFolder:!0}});return await G.projectMember.create({data:{projectId:Z.id,teamMemberId:U.id,role:"owner"}}),V});return this.toProjectInfo(I)}async getProject(B){let Q=await VB.project.findUnique({where:{id:B},include:{rootFolder:!0}});if(!Q)throw Error("Project not found");return this.toProjectInfo(Q)}async updateProject(B){let Q=await VB.project.findUnique({where:{id:B.projectId},include:{team:!0}});if(!Q)throw Error("Project not found");if(!Q.team)throw Error("Project has no team");let F=await VB.project.update({where:{id:B.projectId},data:{name:B.name,coverImageKey:B.coverImageKey,enableNotification:B.enableNotification},include:{rootFolder:!0}});return this.toProjectInfo(F)}async listProjects(B){let Q=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:B.teamId,userId:B.userId}}});if(!Q)throw Error("failed to get team member");let F={teamId:B.teamId};if(Q.scope==="project")F.members={some:{teamMemberId:Q.id}};let U={},I=B.sortDirection==="desc"?"desc":"asc";if(B.sortBy)if(B.sortBy==="created_at")U.createdAt=I;else if(B.sortBy==="updated_at")U.updatedAt=I;else U.name=I;else U.name="asc";return await $V(async(Z,W)=>{let g=await VB.project.findMany({where:F,orderBy:U,skip:Z,take:W,include:{rootFolder:!0}});return await Promise.all(g.map((b)=>this.toProjectInfo(b)))},null,B.pagination)}async addProjectMember(B){if(!await VB.user.findUnique({where:{id:B.userId}}))throw Error("User not found");let F=await VB.project.findUnique({where:{id:B.projectId},include:{team:!0}});if(!F)throw Error("Project not found");let U=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:F.teamId,userId:B.userId}}});if(!U)throw Error("user is not a team member");await VB.projectMember.create({data:{projectId:B.projectId,teamMemberId:U.id,role:B.role}})}async listProjectMembers(B){let Q=await VB.projectMember.findMany({where:{projectId:B.projectId,...B.includeAgents?{teamMember:{user:{OR:[{type:"human"},{type:"agent",agent:{type:"chat",enabled:!0}}]}}}:{teamMember:{user:{type:{not:"agent"}}}}},include:{teamMember:{include:{user:!0}}}});return Promise.all(Q.filter((F)=>F.teamMember&&F.teamMember.user).map(async(F)=>({id:F.teamMember.user.id,name:F.teamMember.user.name,role:F.role,image:await MX(F.teamMember.user.image),scope:F.teamMember.scope})))}async deleteProject(B){let Q=await VB.project.findUnique({where:{id:B}});if(!Q)throw Error("Project not found");let F=new Date(0);if(await VB.$transaction(async(U)=>{await U.asset.updateMany({where:{projectId:B},data:{isDeleted:!0,projectId:null}});let I=[Q.rootFolderId,Q.shareRootId].filter((G)=>G!==null);if(I.length>0)await U.asset.updateMany({where:{id:{in:I}},data:{status:"trashed",deletedAt:F}});await U.project.update({where:{id:B},data:{rootFolderId:null,shareRootId:null}}),await U.project.delete({where:{id:B}})}),Q.coverImageKey){let U=process.env.S3_BUCKET||"shumai";try{await yF.deleteObject(U,Q.coverImageKey)}catch(I){console.error(`Failed to delete project cover image ${Q.coverImageKey}:`,I)}}}async getProjectRootFolder(B){let Q=await VB.project.findUnique({where:{id:B},include:{rootFolder:!0}});if(!Q)throw Error("Project not found");if(!Q.rootFolderId)return"";return Q.rootFolderId}async getProjectTeam(B){let Q=await VB.project.findUnique({where:{id:B}});if(!Q)throw Error("Project not found");return Q.teamId}async updateMemberRole(B){let Q=await VB.projectMember.findFirst({where:{projectId:B.projectId,teamMember:{userId:B.userId}}});if(!Q)throw Error("Member not found");if(Q.role==="owner")throw Error("Cannot change the role of an owner");await VB.projectMember.update({where:{id:Q.id},data:{role:B.role}})}async removeMember(B,Q){let F=await VB.projectMember.findFirst({where:{projectId:B,teamMember:{userId:Q}}});if(!F)throw Error("Member not found");if(F.role==="owner")throw Error("Cannot remove an owner");await VB.projectMember.delete({where:{id:F.id}})}async getProjectMe(B,Q){let F=await VB.user.findUnique({where:{id:Q}});if(!F)throw Error("User not found");let U=await VB.project.findUnique({where:{id:B}});if(!U)throw Error("Project not found");let I=await VB.teamMember.findUnique({where:{teamIdUserId:{teamId:U.teamId,userId:Q}}});if(!I)throw Error("User is not a team member");let G=await VB.projectMember.findFirst({where:{projectId:B,teamMemberId:I.id}}),Z=G?G.role:I.role;return{id:F.id,name:F.name,role:Z,image:await MX(F.image)}}async toProjectInfo(B){let Q={id:B.id,name:B.name,teamId:B.teamId,enableNotification:B.enableNotification??!0,coverImageKey:B.coverImageKey||void 0,updatedAt:B.updatedAt};if(B.rootFolderId)Q.rootFolder=B.rootFolderId;else if(B.rootFolder)Q.rootFolder=B.rootFolder.id;if(B.coverImageKey)try{let F=process.env.S3_BUCKET||"shumai",U=await yF.presign(F,B.coverImageKey,"GET");Q.coverImage=U}catch(F){let U=F}return Q}}var zXG=new ewQ;function Gr(B){if(!B)return[];let Q=B.toLowerCase(),F=new Set,U=Array.from(Q),I=U.length;if(I>=3)for(let G=0;G<=I-3;G++)F.add(U[G]+U[G+1]+U[G+2]);else if(I===2)F.add(U[0]+U[1]);else if(I===1)F.add(U[0]);return Array.from(F)}class tE{selectSql=gQ.sql`*`;fromSql=null;wheres=[];orderSql=null;limitCount=null;offsetCount=null;select(B){return this.selectSql=B,this}from(B){return this.fromSql=B,this}addWhere(B){return this.wheres.push(B),this}orderBy(B){return this.orderSql=B,this}limit(B){return this.limitCount=B,this}offset(B){return this.offsetCount=B,this}addSearchConditions(B,Q,F){if(!Q||Q.length===0)return this;let U=[];for(let I of Q){if(F?.skipNameContains&&I.field==="name"&&I.operator==="contains")continue;let G=this.buildSqlCondition(I.field,I.operator,I.value);if(G)U.push(G)}if(U.length>0){let I=B==="OR"?" OR ":" AND ";this.addWhere(gQ.sql`(${gQ.join(U,I)})`)}return this}build(){if(!this.fromSql)throw Error("FROM clause is required in SqlQueryBuilder");let B=[gQ.sql`SELECT`,this.selectSql,gQ.sql`FROM`,this.fromSql];if(this.wheres.length>0)B.push(gQ.sql`WHERE`),B.push(gQ.join(this.wheres," AND "));if(this.orderSql)B.push(gQ.sql`ORDER BY`),B.push(this.orderSql);if(this.limitCount!==null)B.push(gQ.sql`LIMIT ${this.limitCount}`);if(this.offsetCount!==null)B.push(gQ.sql`OFFSET ${this.offsetCount}`);return gQ.join(B," ")}isDate(B){if(B instanceof Date)return!0;if(typeof B!=="string")return!1;let Q=B.toLowerCase();if(["today","yesterday","tomorrow","one week ago","one week from now","one month ago","one month from now"].includes(Q)||Q.match(/\d+\s+days?\s+(ago|from\s+now)/))return!0;let U=new Date(B);return!isNaN(U.getTime())&&B.includes("-")}toDate(B){return this.toDateBound(B,"start")}toDateBound(B,Q){let F=this.parseRelativeDate(B);if(F instanceof Date)return F;if(F&&"gte"in F&&"lte"in F)return Q==="start"?F.gte:F.lte;return new Date(B)}parseDateRange(B){let Q=this.parseRelativeDate(B);if(Q&&"gte"in Q&&"lte"in Q)return{start:Q.gte,end:Q.lte};let F=Q instanceof Date?Q:new Date(B),U=new Date(F);U.setHours(0,0,0,0);let I=new Date(F);return I.setHours(23,59,59,999),{start:U,end:I}}parseRelativeDate(B){if(B instanceof Date)return B;let Q=String(B).toLowerCase(),F=new Date,U=(g)=>{let V=new Date(g);return V.setHours(0,0,0,0),V},I=(g)=>{let V=new Date(g);return V.setHours(23,59,59,999),V};if(Q==="today")return{gte:U(F),lte:I(F)};if(Q==="yesterday"){let g=new Date(F);return g.setDate(g.getDate()-1),{gte:U(g),lte:I(g)}}if(Q==="tomorrow"){let g=new Date(F);return g.setDate(g.getDate()+1),{gte:U(g),lte:I(g)}}if(Q==="one week ago"){let g=new Date(F);return g.setDate(g.getDate()-7),g}if(Q==="one week from now"){let g=new Date(F);return g.setDate(g.getDate()+7),g}if(Q==="one month ago"){let g=new Date(F);return g.setMonth(g.getMonth()-1),g}if(Q==="one month from now"){let g=new Date(F);return g.setMonth(g.getMonth()+1),g}let G=Q.match(/(\d+)\s+days?\s+ago/);if(G){let g=new Date(F);return g.setDate(g.getDate()-parseInt(G[1])),g}let Z=Q.match(/(\d+)\s+days?\s+from\s+now/);if(Z){let g=new Date(F);return g.setDate(g.getDate()+parseInt(Z[1])),g}let W=new Date(B);return isNaN(W.getTime())?null:W}buildEavValueMatch(B){if(typeof B==="string"){let Q=String(B);if(this.isDate(Q)){let F=this.parseRelativeDate(Q);if(F instanceof Date)return gQ.sql`date_value = ${F}`;else if(F&&"gte"in F)return gQ.sql`date_value >= ${F.gte} AND date_value <= ${F.lte}`}return gQ.sql`string_value = ${Q}`}if(typeof B==="number")return gQ.sql`number_value = ${Number(B)}`;if(typeof B==="boolean")return gQ.sql`boolean_value = ${Boolean(B)}`;if(B instanceof Date)return gQ.sql`date_value = ${B}`;if(Array.isArray(B)||typeof B==="object"&&B!==null)return gQ.sql`json_value = ${JSON.stringify(B)}::jsonb`;return gQ.sql`string_value = ${String(B)}`}buildSqlCondition(B,Q,F){let U=B==="sizeByte"||B==="size_byte"?"size_byte":B==="createdAt"||B==="created_at"?"created_at":B==="updatedAt"||B==="updated_at"?"updated_at":B,I=gQ.raw(`a."${U}"`);if(B==="name"){let G=String(F);switch(Q){case"eq":return gQ.sql`${I} = ${G}`;case"neq":return gQ.sql`${I} != ${G}`;case"contains":return gQ.sql`${I} ILIKE ${"%"+G+"%"}`;case"notContains":return gQ.sql`${I} NOT ILIKE ${"%"+G+"%"}`;case"isEmpty":return gQ.sql`${I} = ''`;case"isNotEmpty":return gQ.sql`${I} != ''`;default:throw Error(`Unsupported operator for name field: ${Q}`)}}if(B==="sizeByte"||B==="size_byte"){let G=Number(F);switch(Q){case"eq":return gQ.sql`${I} = ${G}`;case"neq":return gQ.sql`${I} != ${G}`;case"gt":return gQ.sql`${I} > ${G}`;case"gte":return gQ.sql`${I} >= ${G}`;case"lt":return gQ.sql`${I} < ${G}`;case"lte":return gQ.sql`${I} <= ${G}`;default:throw Error(`Unsupported operator for sizeByte field: ${Q}`)}}if(B==="createdAt"||B==="updatedAt"||B==="created_at"||B==="updated_at"){let G=this.toDate(F);switch(Q){case"eq":return gQ.sql`${I} = ${G}`;case"neq":return gQ.sql`${I} != ${G}`;case"gt":return gQ.sql`${I} > ${this.toDateBound(F,"end")}`;case"gte":return gQ.sql`${I} >= ${this.toDateBound(F,"start")}`;case"lt":return gQ.sql`${I} < ${this.toDateBound(F,"start")}`;case"lte":return gQ.sql`${I} <= ${this.toDateBound(F,"end")}`;case"isWithin":{let Z=this.parseDateRange(F);return gQ.sql`${I} >= ${Z.start} AND ${I} <= ${Z.end}`}default:throw Error(`Unsupported operator for date field: ${Q}`)}}switch(Q){case"isEmpty":return gQ.sql`a.id NOT IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B})`;case"isNotEmpty":return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B})`;case"eq":{let G=this.buildEavValueMatch(F);return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND ${G})`}case"neq":{let G=this.buildEavValueMatch(F);return gQ.sql`a.id NOT IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B}) OR a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND NOT (${G}))`}case"gt":return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND (number_value > ${Number(F)} OR date_value > ${this.toDateBound(F,"end")}))`;case"gte":return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND (number_value >= ${Number(F)} OR date_value >= ${this.toDateBound(F,"start")}))`;case"lt":return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND (number_value < ${Number(F)} OR date_value < ${this.toDateBound(F,"start")}))`;case"lte":return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND (number_value <= ${Number(F)} OR date_value <= ${this.toDateBound(F,"end")}))`;case"contains":return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND string_value ILIKE ${"%"+String(F)+"%"})`;case"notContains":return gQ.sql`a.id NOT IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND string_value ILIKE ${"%"+String(F)+"%"})`;case"in":{let G=Array.isArray(F)?F:[F],Z=G.map((W)=>Number(W)).filter((W)=>!isNaN(W));return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND (string_value = ANY(${G}) OR number_value = ANY(${Z}::double precision[])))`}case"notIn":{let G=Array.isArray(F)?F:[F],Z=G.map((W)=>Number(W)).filter((W)=>!isNaN(W));return gQ.sql`a.id NOT IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND (string_value = ANY(${G}) OR number_value = ANY(${Z}::double precision[])))`}case"hasAll":return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND json_value @> ${JSON.stringify(F)}::jsonb)`;case"hasAny":{let G=(Array.isArray(F)?F:[F]).map(String);return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND jsonb_exists_any(json_value, ${G}::text[]))`}case"hasNone":{let G=(Array.isArray(F)?F:[F]).map(String);return gQ.sql`a.id NOT IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND jsonb_exists_any(json_value, ${G}::text[]))`}case"isWithin":{let G=this.parseDateRange(F);return gQ.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${B} AND date_value >= ${G.start} AND date_value <= ${G.end})`}default:throw Error(`Unsupported operator for metadata field: ${Q}`)}}}class B4Q{prismaClient;assetSvc;constructor(B=VB,Q=TX){this.prismaClient=B;this.assetSvc=Q}async search(B,Q){let F=Q.recursively===!1?[B]:await this.assetSvc.getDescendantFolderIds(B),U=Q.assetType==="folder"?[AF.folder]:[AF.file,AF.version_stack];if(Q.query&&Q.isSemantic){let c=(await this.prismaClient.asset.findUnique({where:{id:B},select:{project:{select:{teamId:!0}}}}))?.project?.teamId;if(!c)throw Error("Team ID not found for folder");if(!await this.prismaClient.agent.findFirst({where:{teamId:c,type:"embedding",enabled:!0}}))throw new YI(422,{message:"Embedding agent not configured or disabled for this team."});let d=await this.prismaClient.workflowTask.create({data:{type:e0.query_embedding_for_search,teamId:c,assetId:B,payload:{projectId:"",queryEmbeddingForSearch:{text:Q.query}},status:"pending"}}),bB=(await oN.executeWait(d)).output?.embedding;if(!bB)throw Error("Failed to generate query embedding");let CB=JSON.stringify(bB),IB=new tE().select(gQ.sql`a.id as "assetId", ae.start_time as "startTime", ae.end_time as "endTime", (ae.embedding <=> ${CB}::vector) as "distance"`).from(gQ.sql`assets a JOIN asset_embeddings ae ON a.id = ae.asset_id`).addWhere(gQ.sql`a.is_deleted = false`);if(F.length>0)IB.addWhere(gQ.sql`a.parent_id = ANY(${F})`);if(Q.showSymlink)IB.addWhere(gQ.sql`
13870
13870
  (a.type = ANY(${U}::"AssetType"[]) OR (a.type = 'symlink' AND a.target_id IN (SELECT id FROM assets WHERE type = ANY(${U}::"AssetType"[]))))
13871
13871
  `);else IB.addWhere(gQ.sql`a.type = ANY(${U}::"AssetType"[])`);if(Q.conditions&&Q.conditions.length>0)IB.addSearchConditions(Q.operator,Q.conditions,{skipNameContains:!0});let t=Q.conditions?.find((gB)=>gB.field==="name"&&gB.operator==="contains");if(t){let gB=String(t.value),OB=Gr(gB);if(OB.length>0)IB.addWhere(gQ.sql`a.name_ngram @> ${OB}::text[]`),IB.addWhere(gQ.sql`a.name ILIKE ${"%"+gB+"%"}`);else IB.addWhere(gQ.sql`a.name ILIKE ${"%"+gB+"%"}`)}IB.orderBy(gQ.sql`distance ASC`);let ZB=Q.first||20;if(ZB<=0||ZB>200)ZB=20;let LB=0;if(Q.after)LB=Dp(Q.after);IB.limit(ZB+1).offset(LB);let NQ=IB.build(),HQ=await this.prismaClient.$queryRaw(NQ),wQ=HQ.length>ZB,hQ=wQ?HQ.slice(0,ZB):HQ,jB=Array.from(new Set(hQ.map((gB)=>gB.assetId))),lQ=await this.assetSvc.listAssetsByIds(jB),oF=new Map;for(let gB of lQ)oF.set(gB.id,gB);let E0=[];for(let gB of hQ){let OB=oF.get(gB.assetId);if(OB)E0.push({...OB,startTime:gB.startTime,endTime:gB.endTime})}let gU={},jF=new tE().select(gQ.sql`COUNT(*)`).from(gQ.sql`assets a JOIN asset_embeddings ae ON a.id = ae.asset_id`).addWhere(gQ.sql`a.is_deleted = false`);if(F.length>0)jF.addWhere(gQ.sql`a.parent_id = ANY(${F})`);if(Q.showSymlink)jF.addWhere(gQ.sql`
13872
13872
  (a.type = ANY(${U}::"AssetType"[]) OR (a.type = 'symlink' AND a.target_id IN (SELECT id FROM assets WHERE type = ANY(${U}::"AssetType"[]))))
@@ -13910,7 +13910,7 @@ Most of the features of Better Auth will not work correctly.`);let g=Q.secrets??
13910
13910
  `;if(F.length===0)throw new bm("Asset is not shared");let U=F[0].shareRootId,I=await VB.shareLink.findUnique({where:{rootFolderId:U}});if(!I)throw new bm("Share link not found for this asset");if(I.isDisabled)throw new Zr("Share link is disabled");if(I.expireAt&&I.expireAt<new Date)throw new Wr("Share link has expired");if(I.password&&I.password!==Q)throw new gr("Invalid password for share link");return I}async toShareLinkInfo(B){let Q=B.expireAt?new Date(B.expireAt)<new Date:!1,F=B.creator?await MX(B.creator.image):void 0;return{id:B.id,name:B.name,expireAt:B.expireAt?.toISOString(),isDisabled:B.isDisabled,hasPassword:!!B.password,password:B.password,defaultSortOrder:B.defaultSortOrder,viewMode:B.viewMode,fieldVisibility:B.fieldVisibility,rootFolderId:B.rootFolderId,projectId:B.projectId,isExpired:Q,createdAt:B.createdAt.toISOString(),updatedAt:B.updatedAt.toISOString(),creator:B.creator?{id:B.creator.id,name:B.creator.name,image:F}:null}}}var oXG=new Q4Q;var GLB=Pb(V2B(),1);import*as U4Q from"crypto";var q6F=(B)=>B.replace(/\r\n/g,`
13911
13911
  `).replace(/\r/g,`
13912
13912
  `),j6F=(B)=>{let Q=q6F(B);if(!Q.startsWith("---"))return{yamlString:null,body:Q};let F=Q.indexOf(`
13913
- ---`,3);if(F===-1)return{yamlString:null,body:Q};return{yamlString:Q.slice(4,F),body:Q.slice(F+4).trim()}},F4Q=(B)=>{let{yamlString:Q,body:F}=j6F(B);if(!Q)return{frontmatter:{},body:F};return{frontmatter:lh(Q)??{},body:F}};class I4Q{prismaClient;constructor(B=VB){this.prismaClient=B}async upsertSkill(B,Q){let F,U;if(Q.githubUrl){let{downloadUrl:C,path:N}=this.parseGithubUrl(Q.githubUrl);U=N,F=await this.downloadGithubZip(C)}else if(Q.assetId){let C=await this.prismaClient.asset.findUnique({where:{id:Q.assetId},include:{storageKey:!0}}),N=C?.storageKey?.key;if(!C||!N)throw Error("Asset not found or has no key");let{buffer:R}=await yF.getObject(process.env.S3_BUCKET||"shumai",N);F=R}else throw Error("Either assetId or githubUrl must be provided");let{name:I,description:G,repackedZip:Z}=await this.processSkillZip(F,U);if(await this.prismaClient.skill.findUnique({where:{teamId_name:{teamId:B,name:I}}})&&!Q.override){let C=Error(`Skill with name "${I}" already exists.`);throw C.name="ConflictError",C}let g=U4Q.createHash("sha256").update(Z).digest("hex"),V=`skills/${NG()}.zip`;await yF.putObject(process.env.S3_BUCKET||"shumai",V,Z,Z.length,"application/zip");let b=await this.prismaClient.asset.create({data:{name:`${I}.zip`,storageKey:{create:{key:V}},type:"file",mediaType:"application/zip",sizeByte:Z.length,status:"uploaded"}}),X=await this.prismaClient.skill.upsert({where:{teamId_name:{teamId:B,name:I}},update:{description:G,assetId:b.id,hash:g},create:{name:I,description:G,assetId:b.id,hash:g,teamId:B}});return this.toSkillInfo(X)}async deleteSkill(B){if(!await this.prismaClient.skill.findUnique({where:{id:B}}))return;await this.prismaClient.skill.delete({where:{id:B}})}async updateSkillConfig(B,Q){let F=await this.prismaClient.skill.update({where:{id:B},data:{config:Q}});return this.toSkillInfo(F)}async listSkills(B){return(await this.prismaClient.skill.findMany({where:{teamId:B},orderBy:{id:"desc"}})).map((F)=>this.toSkillInfo(F))}parseGithubUrl(B){let F=new URL(B).pathname.split("/").filter(Boolean);if(F.length<2)throw Error("Invalid GitHub URL: missing owner or repo");let U=F[0],I=F[1],G="main",Z;if(F.length>2)if(F[2]==="tree"||F[2]==="blob"){if(F.length<4)throw Error("Invalid GitHub URL: missing ref or path");G=F[3],Z=F.slice(4).join("/")}else Z=F.slice(2).join("/");return{downloadUrl:`https://codeload.github.com/${U}/${I}/zip/refs/heads/${G}`,path:Z}}async downloadGithubZip(B){let Q=await fetch(B);if(!Q.ok){if(B.endsWith("/refs/heads/main")){let F=B.replace("/refs/heads/main","/refs/heads/master"),U=await fetch(F);if(U.ok)return Buffer.from(await U.arrayBuffer())}throw Error(`Failed to download GitHub ZIP from ${B}`)}return Buffer.from(await Q.arrayBuffer())}async processSkillZip(B,Q){let U=new GLB.default(B).getEntries();if(U.length===0)throw Error("The provided ZIP file is empty");let G=U[0].entryName.split("/")[0],Z=U.every((A)=>A.entryName.startsWith(`${G}/`)),W=Q||"";if(W.toLowerCase().endsWith("skill.md"))W=W.substring(0,W.toLowerCase().lastIndexOf("skill.md"));let g="";if(Z)g=W?`${G}/${W.replace(/\/$/,"")}/`:`${G}/`;else g=W?`${W.replace(/\/$/,"")}/`:"";let V=U.find((A)=>{let Y=A.entryName.toLowerCase(),L=g.toLowerCase();return Y.startsWith(L)&&Y.endsWith("skill.md")});if(!V)throw Error(`SKILL.md not found in ${Q||"root"}`);let b=V.getData().toString("utf8"),{name:X,description:C}=this.parseSkillMd(b),N=new GLB.default,R=V.entryName.substring(0,V.entryName.toLowerCase().lastIndexOf("skill.md"));for(let A of U){if(A.isDirectory)continue;if(A.entryName.startsWith(R)){let Y=A.entryName.substring(R.length);N.addFile(Y,A.getData())}}return{name:X,description:C,repackedZip:N.toBuffer()}}parseSkillMd(B){let{frontmatter:Q}=F4Q(B),F=Q.name||"Unnamed Skill",U=Q.description||"";return{name:F,description:U}}toSkillInfo(B){return{id:B.id,name:B.name,description:B.description,config:B.config,assetId:B.assetId,hash:B.hash,createdAt:B.createdAt.toISOString(),updatedAt:B.updatedAt.toISOString()}}}var UCG=new I4Q;import{execFile as n6F}from"child_process";import*as qA from"fs";import*as Z4Q from"os";import*as uX from"path";import Xm from"sharp";import{promisify as i6F}from"util";var ZLB={apch:"Apple ProRes 422 High Quality",apcn:"Apple ProRes 422 Standard Definition",apcs:"Apple ProRes 422 LT",apco:"Apple ProRes 422 Proxy",ap4h:"Apple ProRes 4444",jpeg:"JPEG Image","3gvo":"3GPP Video Orientation",a3d1:"Multiview Video Coding",a3d2:"Multiview Video Coding",a3d3:"Multiview Video Coding",a3d4:"Multiview Video Coding",a3ds:"Auro-Cx 3D audio","ac-3":"AC-3 audio","ac-4":"AC-4 audio",alac:"Apple lossless audio codec",alaw:"a-Law",av01:"AV1 video",avc1:"Advanced Video Coding",avc2:"Advanced Video Coding",avc3:"Advanced Video Coding",avc4:"Advanced Video Coding",avcp:"Advanced Video Coding Parameters",dra1:"DRA Audio",drac:"Dirac Video Coder","dts-":"Dependent base layer for DTS layered audio","dts+":"Enhancement layer for DTS layered audio",dtsc:"DTS Coherent Acoustics audio",dtse:"DTS Express low bit rate audio, also known as DTS LBR",dtsh:"DTS-HD High Resolution Audio",dtsl:"DTS-HD Master Audio",dtsx:"DTS:X",dvav:"AVC-based \u201CDolby Vision\u201D",dvhe:"HEVC-based \u201CDolby Vision\u201D","ec-3":"Enhanced AC-3 audio",enca:"Encrypted/Protected audio",encf:"Encrypted/Protected font",encm:"Encrypted/Protected metadata stream",encs:"Encrypted Systems stream",enct:"Encrypted Text",encv:"Encrypted/protected video",fdp:"File delivery hints",fLaC:"Fres Lossless Audio Codec",g719:"ITU-T Recommendation G.719 (2008)",g726:"ITU-T Recommendation G.726 (1990)",hev1:"High Efficiency Video Coding",hvc1:"High Efficiency Video Coding",hvt1:"High Efficiency Video Coding",ixse:"DVB Track Level Index Track",lhe1:"Layered High Efficiency Video Coding",lht1:"Layered High Efficiency Video Coding",lhv1:"Layered High Efficiency Video Coding",m2ts:"MPEG-2 transport stream for DMB",m4ae:"MPEG-4 Audio Enhancement MP4v1/2",mett:"Text timed metadata that is not XML",metx:"XML timed metadata",mha1:"MPEG-H Audio (single stream, uncapsulated)",mha2:"MPEG-H Audio (multi-stream, unencapsulated)",mhm1:"MPEG-H Audio (single stream, MHAS encapsulated)",mhm2:"MPEG-H Audio (multi-stream, MHAS encapsulated)",mjp2:"Motion JPEG 2000",mlix:"DVB Movie level index track",mlpa:"MLP Audio",mp4a:"MPEG-4 Audio",mp4s:"MPEG-4 Systems",mp4v:"MPEG-4 Visual",mvc1:"Multiview coding",mvc2:"Multiview coding",mvc3:"Multiview coding",mvc4:"Multiview coding",mvd1:"Multiview coding",mvd2:"Multiview coding",mvd3:"Multiview coding",mvd4:"Multiview coding",oksd:"OMA Keys",Opus:"Opus audio coding",pm2t:"Protected MPEG-2 Transport",prtp:"Protected RTP Reception",raw:"Uncompressed audio",resv:"Restricted Video",rm2t:"MPEG-2 Transport Reception",rrtp:"RTP reception",rsrp:"SRTP Reception",rtmd:"Real Time Metadata Sample Entry(XAVC Format)",rtp:"RTP Hints",s263:"ITU H.263 video (3GPP format)",samr:"Narrowband AMR voice",sawb:"Wideband AMR voice",sawp:"Extended AMR-WB (AMR-WB+)",sevc:"EVRC Voice",sm2t:"MPEG-2 Transport Server",sqcp:"13K Voice",srtp:"SRTP Hints",ssmv:"SMV Voice",STGS:"Subtitle Sample Entry (HMMP)",stpp:"Subtitles (Timed Text)",svc1:"Scalable Video Coding",svc2:"Scalable Video Coding",svcM:"SVC Metadata",tc64:"64 bit timecode samples",tmcd:"32 bit timecode samples",twos:"Uncompressed 16-bit audio",tx3g:"Timed Text stream",ulaw:"Samples have been compressed using uLaw 2:1.",unid:"Dynamic Range Control (DRC) data",urim:"Binary timed metadata identified by URI","vc-1":"SMPTE VC-1",vp08:"VP8 video",vp09:"VP9 video",wvtt:"WebVTT"};var Cm=i6F(n6F);class W4Q{prismaClient;constructor(B=VB){this.prismaClient=B}resolveCodecName(B){let Q=B.mime_codec_string||B.tags?.mime_codec_string;if(Q&&typeof Q==="string"){let F=Q.split(".")[0];if(ZLB[F])return ZLB[F]}return B.codec_name}safeParseInt(B){if(B===void 0||B===null)return;let Q=typeof B==="string"?parseInt(B,10):B;return Number.isFinite(Q)?Q:void 0}async getVideoInfo(B){let{stdout:Q}=await Cm("ffprobe",["-v","quiet","-print_format","json","-show_format","-show_streams",B]),F=JSON.parse(Q),U=F.streams.find((W)=>W.codec_type==="video"),I=F.streams.find((W)=>W.codec_type==="audio");if(!U)throw Error("No video stream found");let G=U.r_frame_rate.split("/"),Z=parseFloat(G[0])/parseFloat(G[1]);return{originalWidth:U.width,originalHeight:U.height,duration:parseFloat(F.format.duration),bitRate:parseFloat(F.format.bit_rate),frameRate:Z,hasAudio:!!I,videoCodec:this.resolveCodecName(U),audioCodec:I?this.resolveCodecName(I):void 0,audioChannels:I?.channels,audioSampleRate:this.safeParseInt(I?.sample_rate),audioBitDepth:this.safeParseInt(I?.bits_per_raw_sample)??this.safeParseInt(I?.bits_per_sample),mimeType:""}}async getImageInfo(B){let Q=B;if(B.startsWith("http")){let U=await fetch(B);if(!U.ok)throw Error(`Failed to fetch image from ${B}: ${U.statusText}`);Q=Buffer.from(await U.arrayBuffer())}let F=await Xm(Q,{limitInputPixels:!1}).metadata();return{originalWidth:F.width||0,originalHeight:F.height||0,duration:0,bitRate:0,frameRate:0,hasAudio:!1,mimeType:F.format||""}}async transcodeVideo(B){let Q=`[0:v]scale=w=${B.width}:h=${B.height}:force_original_aspect_ratio=decrease,scale=w='trunc(iw/2)*2':h='trunc(ih/2)*2'`;if(B.frameRate)Q+=`,fps=${B.frameRate}`;Q+="[vout]";let F=["-i",B.inputFile,"-filter_complex",Q,"-map","[vout]"];if(!B.disableAudio)F.push("-map","0:a?");if(F.push("-c:v","libx264","-preset","fast","-crf","23"),!B.disableAudio)F.push("-c:a","aac","-b:a","128k");F.push("-movflags","+faststart","-max_muxing_queue_size","1024",B.outputFile),await Cm("ffmpeg",["-y","-loglevel","warning",...F])}async transcodeImage(B,Q,F,U,I=null){let G=B;if(typeof B==="string"&&B.startsWith("http")){let b=await fetch(B);if(!b.ok)throw Error(`Failed to fetch image from ${B}: ${b.statusText}`);G=Buffer.from(await b.arrayBuffer())}let Z=Xm(G,{limitInputPixels:!1}),W=7680,g=F>0?Math.min(F,W):W,V=I&&I>0?Math.min(I,W):W;Z.resize(g,V,{withoutEnlargement:!0,fit:"inside"}),await Z.webp({quality:U}).toFile(Q)}async generateSprite(B,Q,F,U){let G=`[0:v]fps=${100/U},scale=w=480:h=-2,tile=10x10[sprite_out];[0:v]scale=-2:720:force_original_aspect_ratio=decrease,select='eq(n\\,0)'[thumb_out]`;await Cm("ffmpeg",["-y","-loglevel","warning",...["-i",B,"-filter_complex",G,"-map","[sprite_out]","-frames:v","1","-c:v","libwebp","-q:v","75",Q,"-map","[thumb_out]","-c:v","libwebp","-q:v","75","-frames:v","1","-max_muxing_queue_size","1024",F]])}async extractAudio(B,Q,F){await Cm("ffmpeg",["-y","-loglevel","warning",...["-i",B,"-vn","-acodec","libmp3lame","-b:a",F,Q]])}async extractVideoFrames(B){if(B.isImage){let Z=uX.join(B.outputDir,"1.webp");return await this.transcodeImage(B.inputFile,Z,-1,80,B.frameHeight),[Z]}let Q=await this.getVideoInfo(B.inputFile),F=B.numFrames/Q.duration,U=uX.join(B.outputDir,"%d.webp"),I=["-i",B.inputFile,"-vf",`fps=${F},scale=-2:${B.frameHeight}`,"-c:v","libwebp","-q:v","80",U];return await Cm("ffmpeg",["-y","-loglevel","warning",...I]),qA.readdirSync(B.outputDir).filter((Z)=>Z.endsWith(".webp")).sort((Z,W)=>{let g=parseInt(uX.basename(Z,".webp")),V=parseInt(uX.basename(W,".webp"));return g-V}).map((Z)=>uX.join(B.outputDir,Z))}createTempDir(B){return qA.mkdtempSync(uX.join(Z4Q.tmpdir(),B))}removeDir(B){qA.rmSync(B,{recursive:!0,force:!0})}async createVideoTranscodeTask(B,Q,F){return this.prismaClient.workflowTask.create({data:{assetId:B,projectId:Q,type:e0.transcode,status:$I.pending,payload:{projectId:Q,transcode:F}}})}async createImageTranscodeTask(B,Q,F){return this.prismaClient.workflowTask.create({data:{assetId:B,projectId:Q,type:e0.transcode,status:$I.pending,payload:{projectId:Q,transcode:F}}})}async takeScreenshots(B){let Q=process.env.S3_BUCKET||"shumai",F=this.createTempDir("screenshot-"),U=uX.join(F,uX.basename(B.assetKey));try{await yF.downloadToFile(Q,B.assetKey,U);let I=[];if(B.count<=1)I=[B.start];else{let W=(B.end-B.start)/B.count;I=Array.from({length:B.count},(g,V)=>B.start+V*W)}let G=B.commentTimestamp;if(G!==void 0&&G!==null){if(G>=B.start&&G<=B.end){let W=0,g=Math.abs(I[0]-G);for(let V=1;V<I.length;V++){let b=Math.abs(I[V]-G);if(b<g)g=b,W=V}I[W]=G}}let Z=[];for(let W of I){let g=`shot-${W.toFixed(3)}-${NG()}.webp`,V=uX.join(F,g),b=["-ss",W.toFixed(3),"-i",U,"-vframes","1","-vf","scale=-2:720","-c:v","libwebp","-q:v","80",V];if(await Cm("ffmpeg",["-y","-loglevel","warning",...b]),G!==void 0&&G!==null&&W===G&&B.annotations&&B.annotations.length>0){let N=await Xm(V,{limitInputPixels:!1}).metadata(),R=N.width||1280,A=N.height||720,Y=G4Q(R,A,B.annotations),L=uX.join(F,`composite-${g}`);await Xm(V,{limitInputPixels:!1}).composite([{input:Buffer.from(Y),top:0,left:0}]).toFile(L),qA.renameSync(L,V)}let X=`files/${B.assetId}/screenshots/${g}`,C=qA.readFileSync(V);await yF.putObject(Q,X,C,C.length,"image/webp"),Z.push({key:X,timestamp:W})}return Z}finally{this.removeDir(F)}}async overlayAnnotations(B){let Q=process.env.S3_BUCKET||"shumai",F=this.createTempDir("annotation-"),U=uX.join(F,uX.basename(B.assetKey));try{await yF.downloadToFile(Q,B.assetKey,U);let I=await Xm(U,{limitInputPixels:!1}).metadata(),G=I.width||1920,Z=I.height||1080,W=G4Q(G,Z,B.annotations),g=`annotation-${NG()}.webp`,V=uX.join(F,g);await Xm(U,{limitInputPixels:!1}).composite([{input:Buffer.from(W),top:0,left:0}]).resize(16383,16383,{fit:"inside",withoutEnlargement:!0}).webp({quality:90}).toFile(V);let b=`files/${B.assetId}/annotations/${g}`,X=qA.readFileSync(V);return await yF.putObject(Q,b,X,X.length,"image/webp"),b}finally{this.removeDir(F)}}}function G4Q(B,Q,F){let U=Math.max(2,Math.round(Math.max(B,Q)*0.004)),I=[];for(let G of F){let Z=G.color||"#ff0000";switch(G.type){case"box":{if(G.points.length<2)continue;let[g,V]=G.points,b=Math.min(g[0],V[0])*B,X=Math.min(g[1],V[1])*Q,C=Math.abs(V[0]-g[0])*B,N=Math.abs(V[1]-g[1])*Q;I.push(`<rect x="${b}" y="${X}" width="${C}" height="${N}" stroke="${Z}" stroke-width="${U}" fill="none" />`);break}case"line":case"freehand":{if(G.points.length<2)continue;let g=G.points.map(([V,b])=>`${V*B},${b*Q}`).join(" ");I.push(`<polyline points="${g}" stroke="${Z}" stroke-width="${U}" stroke-linecap="round" stroke-linejoin="round" fill="none" />`);break}case"arrow":{if(G.points.length<2)continue;let g=G.points.map(([w,M])=>[w*B,M*Q]),V=g.map(([w,M])=>`${w},${M}`).join(" ");I.push(`<polyline points="${V}" stroke="${Z}" stroke-width="${U}" stroke-linecap="round" stroke-linejoin="round" fill="none" />`);let b=g[g.length-1],X=g[g.length-2],C=b[0]-X[0],N=b[1]-X[1],R=Math.atan2(N,C),A=Math.max(12,Math.max(B,Q)*0.015),Y=b[0]-A*Math.cos(R-Math.PI/6),L=b[1]-A*Math.sin(R-Math.PI/6),H=b[0]-A*Math.cos(R+Math.PI/6),J=b[1]-A*Math.sin(R+Math.PI/6);I.push(`<polygon points="${b[0]},${b[1]} ${Y},${L} ${H},${J}" fill="${Z}" />`);break}}}return`<svg width="${B}" height="${Q}" viewBox="0 0 ${B} ${Q}" xmlns="http://www.w3.org/2000/svg">${I.join(`
13913
+ ---`,3);if(F===-1)return{yamlString:null,body:Q};return{yamlString:Q.slice(4,F),body:Q.slice(F+4).trim()}},F4Q=(B)=>{let{yamlString:Q,body:F}=j6F(B);if(!Q)return{frontmatter:{},body:F};return{frontmatter:lh(Q)??{},body:F}};class I4Q{prismaClient;constructor(B=VB){this.prismaClient=B}async upsertSkill(B,Q){let F,U;if(Q.githubUrl){let{downloadUrl:C,path:N}=this.parseGithubUrl(Q.githubUrl);U=N,F=await this.downloadGithubZip(C)}else if(Q.assetId){let C=await this.prismaClient.asset.findUnique({where:{id:Q.assetId},include:{storageKey:!0}}),N=C?.storageKey?.key;if(!C||!N)throw Error("Asset not found or has no key");let{buffer:R}=await yF.getObject(process.env.S3_BUCKET||"shumai",N);F=R}else throw Error("Either assetId or githubUrl must be provided");let{name:I,description:G,repackedZip:Z}=await this.processSkillZip(F,U);if(await this.prismaClient.skill.findUnique({where:{teamId_name:{teamId:B,name:I}}})&&!Q.override){let C=Error(`Skill with name "${I}" already exists.`);throw C.name="ConflictError",C}let g=U4Q.createHash("sha256").update(Z).digest("hex"),V=`skills/${NG()}.zip`;await yF.putObject(process.env.S3_BUCKET||"shumai",V,Z,Z.length,"application/zip");let b=await this.prismaClient.asset.create({data:{name:`${I}.zip`,storageKey:{create:{key:V}},type:"file",mediaType:"application/zip",sizeByte:Z.length,status:"uploaded"}}),X=await this.prismaClient.skill.upsert({where:{teamId_name:{teamId:B,name:I}},update:{description:G,assetId:b.id,hash:g},create:{name:I,description:G,assetId:b.id,hash:g,teamId:B}});return this.toSkillInfo(X)}async deleteSkill(B){if(!await this.prismaClient.skill.findUnique({where:{id:B}}))return;await this.prismaClient.skill.delete({where:{id:B}})}async updateSkillConfig(B,Q){let F=await this.prismaClient.skill.update({where:{id:B},data:{config:Q}});return this.toSkillInfo(F)}async listSkills(B){return(await this.prismaClient.skill.findMany({where:{teamId:B},orderBy:{id:"desc"}})).map((F)=>this.toSkillInfo(F))}parseGithubUrl(B){let F=new URL(B).pathname.split("/").filter(Boolean);if(F.length<2)throw Error("Invalid GitHub URL: missing owner or repo");let U=F[0],I=F[1],G="main",Z;if(F.length>2)if(F[2]==="tree"||F[2]==="blob"){if(F.length<4)throw Error("Invalid GitHub URL: missing ref or path");G=F[3],Z=F.slice(4).join("/")}else Z=F.slice(2).join("/");return{downloadUrl:`https://codeload.github.com/${U}/${I}/zip/refs/heads/${G}`,path:Z}}async downloadGithubZip(B){let Q=await fetch(B);if(!Q.ok){if(B.endsWith("/refs/heads/main")){let F=B.replace("/refs/heads/main","/refs/heads/master"),U=await fetch(F);if(U.ok)return Buffer.from(await U.arrayBuffer())}throw Error(`Failed to download GitHub ZIP from ${B}`)}return Buffer.from(await Q.arrayBuffer())}async processSkillZip(B,Q){let U=new GLB.default(B).getEntries();if(U.length===0)throw Error("The provided ZIP file is empty");let G=U[0].entryName.split("/")[0],Z=U.every((A)=>A.entryName.startsWith(`${G}/`)),W=Q||"";if(W.toLowerCase().endsWith("skill.md"))W=W.substring(0,W.toLowerCase().lastIndexOf("skill.md"));let g="";if(Z)g=W?`${G}/${W.replace(/\/$/,"")}/`:`${G}/`;else g=W?`${W.replace(/\/$/,"")}/`:"";let V=U.find((A)=>{let Y=A.entryName.toLowerCase(),L=g.toLowerCase();return Y.startsWith(L)&&Y.endsWith("skill.md")});if(!V)throw Error(`SKILL.md not found in ${Q||"root"}`);let b=V.getData().toString("utf8"),{name:X,description:C}=this.parseSkillMd(b),N=new GLB.default,R=V.entryName.substring(0,V.entryName.toLowerCase().lastIndexOf("skill.md"));for(let A of U){if(A.isDirectory)continue;if(A.entryName.startsWith(R)){let Y=A.entryName.substring(R.length);N.addFile(Y,A.getData())}}return{name:X,description:C,repackedZip:N.toBuffer()}}parseSkillMd(B){let{frontmatter:Q}=F4Q(B),F=Q.name||"Unnamed Skill",U=Q.description||"";return{name:F,description:U}}toSkillInfo(B){return{id:B.id,name:B.name,description:B.description,config:B.config,assetId:B.assetId,hash:B.hash,createdAt:B.createdAt.toISOString(),updatedAt:B.updatedAt.toISOString()}}}var UCG=new I4Q;import{execFile as n6F}from"child_process";import*as qA from"fs";import*as Z4Q from"os";import*as uX from"path";import Xm from"sharp";import{promisify as i6F}from"util";var ZLB={apch:"Apple ProRes 422 High Quality",apcn:"Apple ProRes 422 Standard Definition",apcs:"Apple ProRes 422 LT",apco:"Apple ProRes 422 Proxy",ap4h:"Apple ProRes 4444",jpeg:"JPEG Image","3gvo":"3GPP Video Orientation",a3d1:"Multiview Video Coding",a3d2:"Multiview Video Coding",a3d3:"Multiview Video Coding",a3d4:"Multiview Video Coding",a3ds:"Auro-Cx 3D audio","ac-3":"AC-3 audio","ac-4":"AC-4 audio",alac:"Apple lossless audio codec",alaw:"a-Law",av01:"AV1 video",avc1:"Advanced Video Coding",avc2:"Advanced Video Coding",avc3:"Advanced Video Coding",avc4:"Advanced Video Coding",avcp:"Advanced Video Coding Parameters",dra1:"DRA Audio",drac:"Dirac Video Coder","dts-":"Dependent base layer for DTS layered audio","dts+":"Enhancement layer for DTS layered audio",dtsc:"DTS Coherent Acoustics audio",dtse:"DTS Express low bit rate audio, also known as DTS LBR",dtsh:"DTS-HD High Resolution Audio",dtsl:"DTS-HD Master Audio",dtsx:"DTS:X",dvav:"AVC-based \u201CDolby Vision\u201D",dvhe:"HEVC-based \u201CDolby Vision\u201D","ec-3":"Enhanced AC-3 audio",enca:"Encrypted/Protected audio",encf:"Encrypted/Protected font",encm:"Encrypted/Protected metadata stream",encs:"Encrypted Systems stream",enct:"Encrypted Text",encv:"Encrypted/protected video",fdp:"File delivery hints",fLaC:"Fres Lossless Audio Codec",g719:"ITU-T Recommendation G.719 (2008)",g726:"ITU-T Recommendation G.726 (1990)",hev1:"High Efficiency Video Coding",hvc1:"High Efficiency Video Coding",hvt1:"High Efficiency Video Coding",ixse:"DVB Track Level Index Track",lhe1:"Layered High Efficiency Video Coding",lht1:"Layered High Efficiency Video Coding",lhv1:"Layered High Efficiency Video Coding",m2ts:"MPEG-2 transport stream for DMB",m4ae:"MPEG-4 Audio Enhancement MP4v1/2",mett:"Text timed metadata that is not XML",metx:"XML timed metadata",mha1:"MPEG-H Audio (single stream, uncapsulated)",mha2:"MPEG-H Audio (multi-stream, unencapsulated)",mhm1:"MPEG-H Audio (single stream, MHAS encapsulated)",mhm2:"MPEG-H Audio (multi-stream, MHAS encapsulated)",mjp2:"Motion JPEG 2000",mlix:"DVB Movie level index track",mlpa:"MLP Audio",mp4a:"MPEG-4 Audio",mp4s:"MPEG-4 Systems",mp4v:"MPEG-4 Visual",mvc1:"Multiview coding",mvc2:"Multiview coding",mvc3:"Multiview coding",mvc4:"Multiview coding",mvd1:"Multiview coding",mvd2:"Multiview coding",mvd3:"Multiview coding",mvd4:"Multiview coding",oksd:"OMA Keys",Opus:"Opus audio coding",pm2t:"Protected MPEG-2 Transport",prtp:"Protected RTP Reception",raw:"Uncompressed audio",resv:"Restricted Video",rm2t:"MPEG-2 Transport Reception",rrtp:"RTP reception",rsrp:"SRTP Reception",rtmd:"Real Time Metadata Sample Entry(XAVC Format)",rtp:"RTP Hints",s263:"ITU H.263 video (3GPP format)",samr:"Narrowband AMR voice",sawb:"Wideband AMR voice",sawp:"Extended AMR-WB (AMR-WB+)",sevc:"EVRC Voice",sm2t:"MPEG-2 Transport Server",sqcp:"13K Voice",srtp:"SRTP Hints",ssmv:"SMV Voice",STGS:"Subtitle Sample Entry (HMMP)",stpp:"Subtitles (Timed Text)",svc1:"Scalable Video Coding",svc2:"Scalable Video Coding",svcM:"SVC Metadata",tc64:"64 bit timecode samples",tmcd:"32 bit timecode samples",twos:"Uncompressed 16-bit audio",tx3g:"Timed Text stream",ulaw:"Samples have been compressed using uLaw 2:1.",unid:"Dynamic Range Control (DRC) data",urim:"Binary timed metadata identified by URI","vc-1":"SMPTE VC-1",vp08:"VP8 video",vp09:"VP9 video",wvtt:"WebVTT"};var Cm=i6F(n6F);class W4Q{prismaClient;constructor(B=VB){this.prismaClient=B}resolveCodecName(B){let Q=B.mime_codec_string||B.tags?.mime_codec_string;if(Q&&typeof Q==="string"){let F=Q.split(".")[0];if(ZLB[F])return ZLB[F]}return B.codec_name}safeParseInt(B){if(B===void 0||B===null)return;let Q=typeof B==="string"?parseInt(B,10):B;return Number.isFinite(Q)?Q:void 0}async getVideoInfo(B){let{stdout:Q}=await Cm("ffprobe",["-v","quiet","-print_format","json","-show_format","-show_streams",B]),F=JSON.parse(Q),U=F.streams.find((V)=>V.codec_type==="video"),I=F.streams.find((V)=>V.codec_type==="audio");if(!U)throw Error("No video stream found");let G=0;if(U.avg_frame_rate){let V=U.avg_frame_rate.split("/");if(V.length===2){let b=parseFloat(V[0]),X=parseFloat(V[1]);if(X>0)G=b/X}}if(G===0&&U.r_frame_rate){let V=U.r_frame_rate.split("/");if(V.length===2){let b=parseFloat(V[0]),X=parseFloat(V[1]);if(X>0)G=b/X}}let Z=parseFloat(F.format.duration),W=0;if(U.nb_frames)W=parseInt(U.nb_frames,10);if(!W&&G>0&&!isNaN(Z))W=Math.round(Z*G);let g=U.tags?.timecode||F.format?.tags?.timecode;return{originalWidth:U.width,originalHeight:U.height,duration:Z,bitRate:parseFloat(F.format.bit_rate),frameRate:G||30,totalFrames:W||0,startTimecode:g,hasAudio:!!I,videoCodec:this.resolveCodecName(U),audioCodec:I?this.resolveCodecName(I):void 0,audioChannels:I?.channels,audioSampleRate:this.safeParseInt(I?.sample_rate),audioBitDepth:this.safeParseInt(I?.bits_per_raw_sample)??this.safeParseInt(I?.bits_per_sample),mimeType:""}}async getImageInfo(B){let Q=B;if(B.startsWith("http")){let U=await fetch(B);if(!U.ok)throw Error(`Failed to fetch image from ${B}: ${U.statusText}`);Q=Buffer.from(await U.arrayBuffer())}let F=await Xm(Q,{limitInputPixels:!1}).metadata();return{originalWidth:F.width||0,originalHeight:F.height||0,duration:0,bitRate:0,frameRate:0,totalFrames:0,startTimecode:void 0,hasAudio:!1,mimeType:F.format||""}}async transcodeVideo(B){let Q=`[0:v]scale=w=${B.width}:h=${B.height}:force_original_aspect_ratio=decrease,scale=w='trunc(iw/2)*2':h='trunc(ih/2)*2'`;if(B.frameRate)Q+=`,fps=${B.frameRate}`;Q+="[vout]";let F=["-i",B.inputFile,"-filter_complex",Q,"-map","[vout]"];if(B.frameRate){let U;if(typeof B.frameRate==="number")U=B.frameRate;else{let I=B.frameRate.split("/");if(I.length===2)U=parseFloat(I[0])/parseFloat(I[1]);else U=parseFloat(B.frameRate)}if(Number.isFinite(U)&&U>0){let I=Math.max(1,Math.round(U));F.push("-r",U.toString(),"-g",I.toString(),"-force_key_frames","expr:gte(t,n_forced*1)")}}if(!B.disableAudio)F.push("-map","0:a?");if(F.push("-c:v","libx264","-preset","fast","-crf","26"),!B.disableAudio)F.push("-c:a","aac","-b:a","128k");F.push("-movflags","+faststart","-max_muxing_queue_size","1024",B.outputFile),await Cm("ffmpeg",["-y","-loglevel","warning",...F])}async transcodeImage(B,Q,F,U,I=null){let G=B;if(typeof B==="string"&&B.startsWith("http")){let b=await fetch(B);if(!b.ok)throw Error(`Failed to fetch image from ${B}: ${b.statusText}`);G=Buffer.from(await b.arrayBuffer())}let Z=Xm(G,{limitInputPixels:!1}),W=7680,g=F>0?Math.min(F,W):W,V=I&&I>0?Math.min(I,W):W;Z.resize(g,V,{withoutEnlargement:!0,fit:"inside"}),await Z.webp({quality:U}).toFile(Q)}async generateSprite(B,Q,F,U){let G=`[0:v]fps=${100/U},scale=w=480:h=-2,tile=10x10[sprite_out];[0:v]scale=-2:720:force_original_aspect_ratio=decrease,select='eq(n\\,0)'[thumb_out]`;await Cm("ffmpeg",["-y","-loglevel","warning",...["-i",B,"-filter_complex",G,"-map","[sprite_out]","-frames:v","1","-c:v","libwebp","-q:v","75",Q,"-map","[thumb_out]","-c:v","libwebp","-q:v","75","-frames:v","1","-max_muxing_queue_size","1024",F]])}async extractAudio(B,Q,F){await Cm("ffmpeg",["-y","-loglevel","warning",...["-i",B,"-vn","-acodec","libmp3lame","-b:a",F,Q]])}async extractVideoFrames(B){if(B.isImage){let Z=uX.join(B.outputDir,"1.webp");return await this.transcodeImage(B.inputFile,Z,-1,80,B.frameHeight),[Z]}let Q=await this.getVideoInfo(B.inputFile),F=B.numFrames/Q.duration,U=uX.join(B.outputDir,"%d.webp"),I=["-i",B.inputFile,"-vf",`fps=${F},scale=-2:${B.frameHeight}`,"-c:v","libwebp","-q:v","80",U];return await Cm("ffmpeg",["-y","-loglevel","warning",...I]),qA.readdirSync(B.outputDir).filter((Z)=>Z.endsWith(".webp")).sort((Z,W)=>{let g=parseInt(uX.basename(Z,".webp")),V=parseInt(uX.basename(W,".webp"));return g-V}).map((Z)=>uX.join(B.outputDir,Z))}createTempDir(B){return qA.mkdtempSync(uX.join(Z4Q.tmpdir(),B))}removeDir(B){qA.rmSync(B,{recursive:!0,force:!0})}async createVideoTranscodeTask(B,Q,F){return this.prismaClient.workflowTask.create({data:{assetId:B,projectId:Q,type:e0.transcode,status:$I.pending,payload:{projectId:Q,transcode:F}}})}async createImageTranscodeTask(B,Q,F){return this.prismaClient.workflowTask.create({data:{assetId:B,projectId:Q,type:e0.transcode,status:$I.pending,payload:{projectId:Q,transcode:F}}})}async takeScreenshots(B){let Q=process.env.S3_BUCKET||"shumai",F=this.createTempDir("screenshot-"),U=uX.join(F,uX.basename(B.assetKey));try{await yF.downloadToFile(Q,B.assetKey,U);let I=[];if(B.count<=1)I=[B.start];else{let W=(B.end-B.start)/B.count;I=Array.from({length:B.count},(g,V)=>B.start+V*W)}let G=B.commentTimestamp;if(G!==void 0&&G!==null){if(G>=B.start&&G<=B.end){let W=0,g=Math.abs(I[0]-G);for(let V=1;V<I.length;V++){let b=Math.abs(I[V]-G);if(b<g)g=b,W=V}I[W]=G}}let Z=[];for(let W of I){let g=`shot-${W.toFixed(3)}-${NG()}.webp`,V=uX.join(F,g),b=["-ss",W.toFixed(3),"-i",U,"-vframes","1","-vf","scale=-2:720","-c:v","libwebp","-q:v","80",V];if(await Cm("ffmpeg",["-y","-loglevel","warning",...b]),G!==void 0&&G!==null&&W===G&&B.annotations&&B.annotations.length>0){let N=await Xm(V,{limitInputPixels:!1}).metadata(),R=N.width||1280,A=N.height||720,Y=G4Q(R,A,B.annotations),L=uX.join(F,`composite-${g}`);await Xm(V,{limitInputPixels:!1}).composite([{input:Buffer.from(Y),top:0,left:0}]).toFile(L),qA.renameSync(L,V)}let X=`files/${B.assetId}/screenshots/${g}`,C=qA.readFileSync(V);await yF.putObject(Q,X,C,C.length,"image/webp"),Z.push({key:X,timestamp:W})}return Z}finally{this.removeDir(F)}}async overlayAnnotations(B){let Q=process.env.S3_BUCKET||"shumai",F=this.createTempDir("annotation-"),U=uX.join(F,uX.basename(B.assetKey));try{await yF.downloadToFile(Q,B.assetKey,U);let I=await Xm(U,{limitInputPixels:!1}).metadata(),G=I.width||1920,Z=I.height||1080,W=G4Q(G,Z,B.annotations),g=`annotation-${NG()}.webp`,V=uX.join(F,g);await Xm(U,{limitInputPixels:!1}).composite([{input:Buffer.from(W),top:0,left:0}]).resize(16383,16383,{fit:"inside",withoutEnlargement:!0}).webp({quality:90}).toFile(V);let b=`files/${B.assetId}/annotations/${g}`,X=qA.readFileSync(V);return await yF.putObject(Q,b,X,X.length,"image/webp"),b}finally{this.removeDir(F)}}}function G4Q(B,Q,F){let U=Math.max(2,Math.round(Math.max(B,Q)*0.004)),I=[];for(let G of F){let Z=G.color||"#ff0000";switch(G.type){case"box":{if(G.points.length<2)continue;let[g,V]=G.points,b=Math.min(g[0],V[0])*B,X=Math.min(g[1],V[1])*Q,C=Math.abs(V[0]-g[0])*B,N=Math.abs(V[1]-g[1])*Q;I.push(`<rect x="${b}" y="${X}" width="${C}" height="${N}" stroke="${Z}" stroke-width="${U}" fill="none" />`);break}case"line":case"freehand":{if(G.points.length<2)continue;let g=G.points.map(([V,b])=>`${V*B},${b*Q}`).join(" ");I.push(`<polyline points="${g}" stroke="${Z}" stroke-width="${U}" stroke-linecap="round" stroke-linejoin="round" fill="none" />`);break}case"arrow":{if(G.points.length<2)continue;let g=G.points.map(([w,M])=>[w*B,M*Q]),V=g.map(([w,M])=>`${w},${M}`).join(" ");I.push(`<polyline points="${V}" stroke="${Z}" stroke-width="${U}" stroke-linecap="round" stroke-linejoin="round" fill="none" />`);let b=g[g.length-1],X=g[g.length-2],C=b[0]-X[0],N=b[1]-X[1],R=Math.atan2(N,C),A=Math.max(12,Math.max(B,Q)*0.015),Y=b[0]-A*Math.cos(R-Math.PI/6),L=b[1]-A*Math.sin(R-Math.PI/6),H=b[0]-A*Math.cos(R+Math.PI/6),J=b[1]-A*Math.sin(R+Math.PI/6);I.push(`<polygon points="${b[0]},${b[1]} ${Y},${L} ${H},${J}" fill="${Z}" />`);break}}}return`<svg width="${B}" height="${Q}" viewBox="0 0 ${B} ${Q}" xmlns="http://www.w3.org/2000/svg">${I.join(`
13914
13914
  `)}</svg>`}var WLB=new W4Q;import{ApplicationFailure as qCG}from"@temporalio/activity";import{execFile as p6F}from"child_process";import{promisify as a6F}from"util";var iCG=a6F(p6F);import{ApplicationFailure as oCG}from"@temporalio/workflow";class gLB{db;assetId;teamId;projectId;spec={};constructor(B,Q,F,U){this.db=B;this.assetId=Q;this.teamId=F;this.projectId=U}setStrategy(B){return this.spec.videoStrategy=B,this}withSprite(){return this.spec.sprite=!0,this}withPoster(){return this.spec.poster=!0,this}async submit(){return(await this.db.workflowTask.create({data:{assetId:this.assetId,teamId:this.teamId,projectId:this.projectId,type:e0.transcode,status:$I.pending,payload:{projectId:this.projectId,transcode:this.spec}}})).id}}class VLB{db;assetId;teamId;projectId;spec={};constructor(B,Q,F,U){this.db=B;this.assetId=Q;this.teamId=F;this.projectId=U}withThumbnail(){return this.spec.thumbnail=!0,this}async submit(){return(await this.db.workflowTask.create({data:{assetId:this.assetId,teamId:this.teamId,projectId:this.projectId,type:e0.transcode,status:$I.pending,payload:{projectId:this.projectId,transcode:this.spec}}})).id}}class g4Q{prismaClient;constructor(B=VB){this.prismaClient=B}async createUploadTask(B,Q){let F=Q.files.filter((C)=>!C.name.startsWith(".")),U=F.length===1?F[0].name:`${F.length} Items`,I=0,G=(C)=>{for(let N of C){if(N.name.startsWith("."))continue;if(N.type==="file")I++;else G(N.children)}};G(Q.files);let Z=await this.prismaClient.task.create({data:{creatorId:B,type:"upload",name:U,total:I,status:I6.pending}}),W=await this.prismaClient.asset.findUnique({where:{id:Q.parentId},include:{project:!0}});if(!W)throw Error("Parent asset not found");if(!W.projectId)throw Error("Parent asset has no project");let g=[],V=W.type===AF.file,b=V?W.parentId:W.id,X=[];return await this.prismaClient.$transaction(async(C)=>{let N=await this.createAssetsRecursively(C,B,Z.id,W.projectId,b,Q.files,g,X);if(V&&N.length>0)for(let R of N)await TX.reparentAssets({assetIds:[R],newParentId:W.id,creatorId:B},C);return N}),{taskId:Z.id,presignedUrls:g,createdAssets:X}}async createAssetsRecursively(B,Q,F,U,I,G,Z,W){let V=(await B.asset.findFirst({where:{parentId:I},orderBy:{sortIndex:"asc"}}))?.sortIndex||void 0,b=[];for(let X of G){if(X.name.startsWith("."))continue;let C=yX(null,V||null);V=C;let N=X.type==="folder"?AF.folder:AF.file,R=null;if(N===AF.file)R=`files/${NG()}/raw`;let A=await B.asset.create({data:{name:X.name,type:N,storageKey:R?{create:{key:R}}:void 0,sortIndex:C,mediaType:X.mediaType,status:N===AF.folder?UD.uploaded:UD.uploading,sizeByte:X.size,creator:Q?{connect:{id:Q}}:void 0,parent:I?{connect:{id:I}}:void 0,project:{connect:{id:U}},task:{connect:{id:F}}}});if(b.push(A.id),W.push({tempId:X.id,assetId:A.id}),N===AF.folder&&I)await B.asset.update({where:{id:I},data:{fileCount:{increment:1}}});if(X.children&&X.children.length>0)await this.createAssetsRecursively(B,Q,F,U,A.id,X.children,Z,W);else if(N===AF.file&&R){let Y=await yF.presign(process.env.S3_BUCKET||"shumai",R,"PUT");Z.push({id:X.id,fileId:A.id,url:Y})}}return b}async confirmFileUpload(B,Q,F){let U=await this.prismaClient.asset.findUnique({where:{id:F.fileId},include:{storageKey:!0,project:{include:{team:!0}}}});if(!U)throw Error("Asset not found");if(!U.project)throw Error("Project not found for asset");let I=U.storageKey?.key;if(!I)throw Error("Asset has no key");if(F.errorMessage){if(await this.prismaClient.asset.delete({where:{id:U.id}}),await this.prismaClient.task.findUnique({where:{id:Q}})){let g=await this.prismaClient.task.update({where:{id:Q},data:{uploaded:{increment:1}}});if(g.uploaded===g.total)await this.prismaClient.task.update({where:{id:Q},data:{status:I6.completed}})}return}let G=await yF.getObjectSize(process.env.S3_BUCKET||"shumai",I),Z=U.project;await this.prismaClient.$transaction(async(W)=>{let g=await W.asset.update({where:{id:U.id},data:{status:UD.uploaded,sizeByte:G}});if(U.parentId)await W.asset.update({where:{id:U.parentId},data:{fileCount:{increment:1}}}),await TX.updateAncestorsSize(W,U.parentId,g.sizeByte);let V=await W.task.update({where:{id:Q},data:{uploaded:{increment:1}}});if(V.uploaded===(V.total||0))await W.task.update({where:{id:Q},data:{status:I6.completed}});let b=Z.team;if(!b)return;if(!U.projectId)throw Error("Asset project ID is missing");await this.triggerPostUploadWorkflows(W,U.id,b.id,U.projectId)})}async triggerPostUploadWorkflows(B,Q,F,U){let I=await B.asset.findUnique({where:{id:Q}});if(!I)throw Error("Asset not found");let G=await B.team.findUnique({where:{id:F}});if(!G)throw Error("Team not found");let Z=await B.agent.findFirst({where:{type:"autofill",enabled:!0,user:{teamMembers:{some:{teamId:G.id}}}}});if(Z)await B.workflowTask.create({data:{assetId:I.id,type:e0.ai_metadata_autofill,status:$I.pending,teamId:G.id,projectId:U,payload:{projectId:U,agent:{agentId:Z.id}}}});let W=I.mediaType?.startsWith("video/"),g=I.mediaType?.startsWith("image/");if(!W&&!g)await B.asset.update({where:{id:I.id},data:{status:UD.processed}});else{let V=G.settings;if(W){let b=V?.transcode?.videoStrategy||"best_match";await new gLB(B,I.id,G.id,U).setStrategy(b).withSprite().withPoster().submit()}else if(g)await new VLB(B,I.id,G.id,U).withThumbnail().submit()}}async listUploadTasks(B,Q){let F={creatorId:B,type:"upload"},{data:U,pageInfo:I}=await $V(async(Z,W)=>{return this.prismaClient.task.findMany({where:F,orderBy:{id:"desc"},skip:Z,take:W})},async()=>this.prismaClient.task.count({where:F}),Q);return{data:U.map((Z)=>({id:Z.id,name:Z.name||"",total:Z.total||0,uploaded:Z.uploaded,createdAt:Z.createdAt.toISOString()})),pageInfo:I}}}var Vr=new g4Q;async function V4Q(B){let{agent:Q,dbProviders:F,teamSkills:U,allowedDomains:I}=B.context;if(!Q.provider)throw YZ.create({message:"agent has no provider configured",nonRetryable:!0});if(!Q.modelRef)throw YZ.create({message:"agent has no model configured",nonRetryable:!0});let G=Q.provider.name,Z=Q.modelRef.modelId,W=`You are the AI assistant for shumai.
13915
13915
  shumai is a professional creative collaboration platform similar to frame.io, where users can upload creative files, manage projects, assign tasks, get precise feedback, and share their work. As the agent, your role is to help users use and manage this platform.
13916
13916