@code-yeongyu/senpi 2026.9.23-3 → 2026.9.23-5
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.
- package/CHANGELOG.md +38 -0
- package/dist/bundle/chunks/{app-server-command-U5Y46LHO.js → app-server-command-BGT65PGC.js} +1 -1
- package/dist/bundle/chunks/{chunk-UCTYTLP3.js → chunk-3RN6BFG2.js} +2 -2
- package/dist/bundle/chunks/{chunk-XTXBPXZZ.js → chunk-EN6KDFY2.js} +1 -1
- package/dist/bundle/chunks/{chunk-2NFHX2FJ.js → chunk-J3QXPP4T.js} +1 -1
- package/dist/bundle/chunks/chunk-LTIMMSDM.js +8 -0
- package/dist/bundle/chunks/{chunk-67Z5WNA4.js → chunk-PSMTQDII.js} +1 -1
- package/dist/bundle/chunks/{chunk-TH4PERSI.js → chunk-RRSND33J.js} +50 -64
- package/dist/bundle/chunks/{chunk-Y4AJLTFT.js → chunk-WUYBEF7C.js} +1 -1
- package/dist/bundle/chunks/{chunk-IDSOMHWS.js → chunk-WXIRFRXY.js} +1 -1
- package/dist/bundle/chunks/{chunk-R6F525XB.js → chunk-XDSQYM4F.js} +1 -1
- package/dist/bundle/chunks/{chunk-TUVSARCZ.js → chunk-ZEFQYQOU.js} +1 -1
- package/dist/bundle/chunks/{cli-main-65WMMIRT.js → cli-main-W55CWPEI.js} +1 -1
- package/dist/bundle/chunks/cursor-agent.js +1 -1
- package/dist/bundle/chunks/{help-fast-path-VXAZDQ3Z.js → help-fast-path-QXVCHTP3.js} +1 -1
- package/dist/bundle/chunks/{host-command-5PEFD4N6.js → host-command-3PUZYQOK.js} +1 -1
- package/dist/bundle/chunks/{host-lifecycle-BXW5C4JT.js → host-lifecycle-OHPSU5VU.js} +1 -1
- package/dist/bundle/chunks/{interactive-host-runtime-DUNYT24Q.js → interactive-host-runtime-57LEAJPU.js} +1 -1
- package/dist/bundle/chunks/{interactive-mode-SCG5PQZ6.js → interactive-mode-EDJZ4CSY.js} +1 -1
- package/dist/bundle/chunks/{multi-session-host-QC6BZZNH.js → multi-session-host-GFSDQQUJ.js} +1 -1
- package/dist/bundle/chunks/{package-manager-cli-23GULCVL.js → package-manager-cli-J7244EJE.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-B6RSUQKL.js → pi-messages-CAS467IY.js} +1 -1
- package/dist/bundle/chunks/{rotation-stream-ZIYWOB2N.js → rotation-stream-CZT4TRPD.js} +1 -1
- package/dist/bundle/chunks/{rpc-mode-ZQ4E6FFA.js → rpc-mode-75CRTY24.js} +1 -1
- package/dist/bundle/chunks/{session-picker-CO2ZK3EC.js → session-picker-ZIBANFBQ.js} +1 -1
- package/dist/bundle/chunks/session-worker.js +56 -70
- package/dist/bundle/cli.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/core/agent-session.d.ts +9 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +14 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/models.d.ts.map +1 -1
- package/dist/core/extensions/builtin/cursor-cli-oauth/models.js +43 -26
- package/dist/core/extensions/builtin/cursor-cli-oauth/models.js.map +1 -1
- package/dist/core/extensions/builtin/nested-agents-md/index.js +1 -1
- package/dist/core/extensions/builtin/nested-agents-md/index.js.map +1 -1
- package/dist/core/extensions/builtin/rule-activation/types.d.ts +2 -0
- package/dist/core/extensions/builtin/rule-activation/types.d.ts.map +1 -1
- package/dist/core/extensions/builtin/rule-activation/types.js +7 -1
- package/dist/core/extensions/builtin/rule-activation/types.js.map +1 -1
- package/dist/core/extensions/builtin/rules/index.d.ts.map +1 -1
- package/dist/core/extensions/builtin/rules/index.js +2 -1
- package/dist/core/extensions/builtin/rules/index.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/output-format.d.ts +15 -0
- package/dist/core/extensions/builtin/terminal/output-format.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/output-format.js +43 -2
- package/dist/core/extensions/builtin/terminal/output-format.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash-output.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash-output.js +4 -3
- package/dist/core/extensions/builtin/terminal/tools/bash-output.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/bash.js +3 -3
- package/dist/core/extensions/builtin/terminal/tools/bash.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/context.d.ts +7 -4
- package/dist/core/extensions/builtin/terminal/tools/context.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/context.js +5 -0
- package/dist/core/extensions/builtin/terminal/tools/context.js.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/render.d.ts.map +1 -1
- package/dist/core/extensions/builtin/terminal/tools/render.js +5 -2
- package/dist/core/extensions/builtin/terminal/tools/render.js.map +1 -1
- package/dist/core/extensions/builtin/webfetch/webfetch/tool.d.ts +3 -1
- package/dist/core/extensions/builtin/webfetch/webfetch/tool.d.ts.map +1 -1
- package/dist/core/extensions/builtin/webfetch/webfetch/tool.js +9 -3
- package/dist/core/extensions/builtin/webfetch/webfetch/tool.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +87 -14
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/tool-call-display-name.d.ts +15 -0
- package/dist/core/tool-call-display-name.d.ts.map +1 -0
- package/dist/core/tool-call-display-name.js +14 -0
- package/dist/core/tool-call-display-name.js.map +1 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +12 -7
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +9 -6
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep/format.d.ts +3 -2
- package/dist/core/tools/grep/format.d.ts.map +1 -1
- package/dist/core/tools/grep/format.js +5 -3
- package/dist/core/tools/grep/format.js.map +1 -1
- package/dist/core/tools/grep/index.js +2 -2
- package/dist/core/tools/grep/index.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +5 -3
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/model-only-text.d.ts +4 -0
- package/dist/core/tools/model-only-text.d.ts.map +1 -0
- package/dist/core/tools/model-only-text.js +12 -0
- package/dist/core/tools/model-only-text.js.map +1 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +15 -5
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +2 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/bash.d.ts.map +1 -1
- package/dist/core/tools/renderers/bash.js +1 -25
- package/dist/core/tools/renderers/bash.js.map +1 -1
- package/dist/core/tools/renderers/grep.d.ts.map +1 -1
- package/dist/core/tools/renderers/grep.js +0 -25
- package/dist/core/tools/renderers/grep.js.map +1 -1
- package/dist/core/tools/renderers/read.d.ts +8 -0
- package/dist/core/tools/renderers/read.d.ts.map +1 -1
- package/dist/core/tools/renderers/read.js +2 -14
- package/dist/core/tools/renderers/read.js.map +1 -1
- package/dist/modes/interactive/components/exploration-call.d.ts +4 -1
- package/dist/modes/interactive/components/exploration-call.d.ts.map +1 -1
- package/dist/modes/interactive/components/exploration-call.js +17 -2
- package/dist/modes/interactive/components/exploration-call.js.map +1 -1
- package/dist/modes/interactive/components/exploration-group.d.ts +3 -1
- package/dist/modes/interactive/components/exploration-group.d.ts.map +1 -1
- package/dist/modes/interactive/components/exploration-group.js +7 -1
- package/dist/modes/interactive/components/exploration-group.js.map +1 -1
- package/dist/modes/interactive/components/exploration-rules.d.ts +5 -0
- package/dist/modes/interactive/components/exploration-rules.d.ts.map +1 -0
- package/dist/modes/interactive/components/exploration-rules.js +15 -0
- package/dist/modes/interactive/components/exploration-rules.js.map +1 -0
- package/dist/modes/interactive/components/exploration-transcript-container.d.ts.map +1 -1
- package/dist/modes/interactive/components/exploration-transcript-container.js +10 -1
- package/dist/modes/interactive/components/exploration-transcript-container.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +4 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +3 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/json-event.d.ts +1 -0
- package/dist/modes/json-event.d.ts.map +1 -1
- package/dist/modes/json-event.js +1 -0
- package/dist/modes/json-event.js.map +1 -1
- package/docs/json.md +4 -1
- package/docs/rpc.md +7 -1
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +26 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@code-yeongyu/senpi-codemode/src/tool/render.ts +4 -19
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js +8 -23
- package/node_modules/@earendil-works/pi-agent-core/dist/agent-loop.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/tool-name-alias.d.ts +8 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/tool-name-alias.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/dist/tool-name-alias.js +27 -0
- package/node_modules/@earendil-works/pi-agent-core/dist/tool-name-alias.js.map +1 -1
- package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js +17 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/cursor/catalog-grouping.d.ts +18 -1
- package/node_modules/@earendil-works/pi-ai/dist/cursor/catalog-grouping.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/cursor/catalog-grouping.js +103 -3
- package/node_modules/@earendil-works/pi-ai/dist/cursor/catalog-grouping.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/cursor/selection-descriptor.d.ts +3 -1
- package/node_modules/@earendil-works/pi-ai/dist/cursor/selection-descriptor.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/cursor/selection-descriptor.js +15 -3
- package/node_modules/@earendil-works/pi-ai/dist/cursor/selection-descriptor.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/cursor/store-migration.d.ts +7 -2
- package/node_modules/@earendil-works/pi-ai/dist/cursor/store-migration.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/cursor/store-migration.js +92 -20
- package/node_modules/@earendil-works/pi-ai/dist/cursor/store-migration.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/model.d.ts +9 -1
- package/node_modules/@earendil-works/pi-ai/dist/model.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/model.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cursor.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/cursor.js +1 -0
- package/node_modules/@earendil-works/pi-ai/dist/providers/cursor.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts +5 -0
- package/node_modules/@earendil-works/pi-ai/dist/types.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/types.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +7 -7
- package/dist/bundle/chunks/chunk-XPDV6SIX.js +0 -8
|
@@ -146,7 +146,7 @@ ${text}`})}});stepBlobIds.push(storeCursorBlob(blobStore,toBinary(ConversationSt
|
|
|
146
146
|
`)}function toolResultToText2(message){return[message.toolName,...message.content.map(block=>contentToText([block]))].join(`
|
|
147
147
|
`)}function messageToText(message){return message.role==="user"?contentToText(message.content):message.role==="assistant"?assistantContentToText(message.content):message.role==="configurationUpdate"?"":toolResultToText2(message)}function serializeContext(context){let parts=[];context.systemPrompt&&parts.push(`system:${context.systemPrompt}`);for(let message of context.messages)parts.push(`${message.role}:${messageToText(message)}`);return context.tools?.length&&parts.push(`tools:${JSON.stringify(context.tools)}`),parts.join(`
|
|
148
148
|
|
|
149
|
-
`)}function commonPrefixLength(a,b){let length=Math.min(a.length,b.length),index=0;for(;index<length&&a[index]===b[index];)index++;return index}function withUsageEstimate(message,context,options,promptCache){let promptText=serializeContext(context),promptTokens=estimateTokens(promptText),outputTokens=estimateTokens(assistantContentToText(message.content)),input=promptTokens,cacheRead=0,cacheWrite=0,sessionId=options?.sessionId;if(sessionId&&options?.cacheRetention!=="none"){let previousPrompt=promptCache.get(sessionId);if(previousPrompt){let cachedChars=commonPrefixLength(previousPrompt,promptText);cacheRead=estimateTokens(previousPrompt.slice(0,cachedChars)),cacheWrite=estimateTokens(promptText.slice(cachedChars)),input=Math.max(0,promptTokens-cacheRead)}else cacheWrite=promptTokens;promptCache.set(sessionId,promptText)}return{...message,usage:{input,output:outputTokens,cacheRead,cacheWrite,totalTokens:input+outputTokens+cacheRead+cacheWrite,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}}function splitStringByTokenSize(text,minTokenSize,maxTokenSize){let chunks=[],index=0;for(;index<text.length;){let tokenSize=minTokenSize+Math.floor(Math.random()*(maxTokenSize-minTokenSize+1)),charSize=Math.max(1,tokenSize*4);chunks.push(text.slice(index,index+charSize)),index+=charSize}return chunks.length>0?chunks:[""]}function cloneMessage(message,api,provider,modelId){let cloned=structuredClone(message);return{...cloned,api,provider,model:modelId,timestamp:cloned.timestamp??Date.now(),usage:cloned.usage??DEFAULT_USAGE}}function createDeferredMessage(model,handle){return{role:"assistant",content:[],api:model.api,provider:model.provider,model:model.id,usage:DEFAULT_USAGE,stopReason:"deferred",deferred:handle,timestamp:Date.now()}}function createErrorMessage(error,api,provider,modelId){return{role:"assistant",content:[],api,provider,model:modelId,usage:DEFAULT_USAGE,stopReason:"error",errorMessage:error instanceof Error?error.message:String(error),timestamp:Date.now()}}function createAbortedMessage(partial){return{...partial,stopReason:"aborted",errorMessage:"Request was aborted",timestamp:Date.now()}}function scheduleChunk(chunk,tokensPerSecond,schedulerHook){if(schedulerHook)return Promise.resolve(schedulerHook());if(!tokensPerSecond||tokensPerSecond<=0)return new Promise(resolve=>queueMicrotask(resolve));let delayMs=estimateTokens(chunk)/tokensPerSecond*1e3;return new Promise(resolve=>setTimeout(resolve,delayMs))}async function streamWithDeltas(stream,message,minTokenSize,maxTokenSize,tokensPerSecond,schedulerHook,signal){let partial={...message,content:[],stopReason:"pending"};if(signal?.aborted){let aborted=createAbortedMessage(partial);stream.push({type:"error",reason:"aborted",error:aborted}),stream.end(aborted);return}stream.push({type:"start",partial:{...partial}});for(let index=0;index<message.content.length;index++){if(signal?.aborted){let aborted=createAbortedMessage(partial);stream.push({type:"error",reason:"aborted",error:aborted}),stream.end(aborted);return}let block=message.content[index];if(block.type==="thinking"){partial.content=[...partial.content,{type:"thinking",thinking:""}],stream.push({type:"thinking_start",contentIndex:index,partial:{...partial}});for(let chunk of splitStringByTokenSize(block.thinking,minTokenSize,maxTokenSize)){if(await scheduleChunk(chunk,tokensPerSecond,schedulerHook),signal?.aborted){let aborted=createAbortedMessage(partial);stream.push({type:"error",reason:"aborted",error:aborted}),stream.end(aborted);return}partial.content[index].thinking+=chunk,stream.push({type:"thinking_delta",contentIndex:index,delta:chunk,partial:{...partial}})}stream.push({type:"thinking_end",contentIndex:index,content:block.thinking,partial:{...partial}});continue}if(block.type==="text"){partial.content=[...partial.content,{type:"text",text:""}],stream.push({type:"text_start",contentIndex:index,partial:{...partial}});for(let chunk of splitStringByTokenSize(block.text,minTokenSize,maxTokenSize)){if(await scheduleChunk(chunk,tokensPerSecond,schedulerHook),signal?.aborted){let aborted=createAbortedMessage(partial);stream.push({type:"error",reason:"aborted",error:aborted}),stream.end(aborted);return}partial.content[index].text+=chunk,stream.push({type:"text_delta",contentIndex:index,delta:chunk,partial:{...partial}})}stream.push({type:"text_end",contentIndex:index,content:block.text,partial:{...partial}});continue}if(block.type!=="providerNative"){partial.content=[...partial.content,{type:"toolCall",id:block.id,name:block.name,arguments:{}}],stream.push({type:"toolcall_start",contentIndex:index,partial:{...partial}});for(let chunk of splitStringByTokenSize(JSON.stringify(block.arguments),minTokenSize,maxTokenSize)){if(await scheduleChunk(chunk,tokensPerSecond,schedulerHook),signal?.aborted){let aborted=createAbortedMessage(partial);stream.push({type:"error",reason:"aborted",error:aborted}),stream.end(aborted);return}stream.push({type:"toolcall_delta",contentIndex:index,delta:chunk,partial:{...partial}})}partial.content[index].arguments=block.arguments,stream.push({type:"toolcall_end",contentIndex:index,toolCall:block,partial:{...partial}})}}if(message.stopReason==="pending")throw new Error("Faux response ended without a stop reason");if(message.stopReason==="error"||message.stopReason==="aborted"){stream.push({type:"error",reason:message.stopReason,error:message}),stream.end(message);return}stream.push({type:"done",reason:message.stopReason,message}),stream.end(message)}function createFauxCore(options){let api=options.api??randomId(DEFAULT_API),provider=options.provider??DEFAULT_PROVIDER,minTokenSize=Math.max(1,Math.min(options.tokenSize?.min??DEFAULT_MIN_TOKEN_SIZE,options.tokenSize?.max??DEFAULT_MAX_TOKEN_SIZE)),maxTokenSize=Math.max(minTokenSize,options.tokenSize?.max??DEFAULT_MAX_TOKEN_SIZE),pendingResponses=[],tokensPerSecond=options.tokensPerSecond,schedulerHook=options.schedulerHook,state={callCount:0,deferredFetchCount:0,cancelledDeferred:[]},promptCache=new Map,callLog=[],deferredResponses=new Map,models=(options.models?.length?options.models:[{id:DEFAULT_MODEL_ID,name:DEFAULT_MODEL_NAME,reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384}]).map(definition=>({id:definition.id,name:definition.name??definition.id,api,provider,baseUrl:DEFAULT_BASE_URL,reasoning:definition.reasoning??!1,input:definition.input??["text","image"],cost:definition.cost??{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:definition.contextWindow??128e3,maxTokens:definition.maxTokens??16384})),resolveResponse=async(step,context,streamOptions,requestModel)=>{let resolved=typeof step=="function"?await step(context,streamOptions,state,requestModel):step;return withUsageEstimate(cloneMessage(resolved,api,provider,requestModel.id),context,streamOptions,promptCache)},stream=(requestModel,context,streamOptions)=>{let outer=createAssistantMessageEventStream(),step=pendingResponses.shift();return state.callCount++,callLog.push({context:cloneContextForLog(context),options:cloneStreamOptionsForLog(streamOptions),timestamp:Date.now(),modelId:requestModel.id}),queueMicrotask(async()=>{try{if(await streamOptions?.onResponse?.({status:200,headers:{}},requestModel),!step){let message2=createErrorMessage(new Error("No more faux responses queued"),api,provider,requestModel.id);message2=withUsageEstimate(message2,context,streamOptions,promptCache),outer.push({type:"error",reason:"error",error:message2}),outer.end(message2);return}if(streamOptions?.deferred){let handle={provider:requestModel.provider,modelId:requestModel.id,api:requestModel.api,id:randomId("deferred"),...options.deferred?.pollAfterMs!==void 0?{pollAfterMs:options.deferred.pollAfterMs}:{}};deferredResponses.set(handle.id,{handle,step,context,options:streamOptions,model:requestModel,pendingFetches:Math.max(0,Math.floor(options.deferred?.pendingFetches??0)),cancelled:!1}),await streamWithDeltas(outer,createDeferredMessage(requestModel,handle),minTokenSize,maxTokenSize,tokensPerSecond,schedulerHook,streamOptions.signal);return}let message=await resolveResponse(step,context,streamOptions,requestModel);await streamWithDeltas(outer,message,minTokenSize,maxTokenSize,tokensPerSecond,schedulerHook,streamOptions?.signal)}catch(error){let message=createErrorMessage(error,api,provider,requestModel.id);outer.push({type:"error",reason:"error",error:message}),outer.end(message)}}),outer},streamSimple=(streamModel,context,streamOptions)=>stream(streamModel,context,streamOptions),fetchDeferred=(requestModel,handle,fetchOptions)=>{let outer=createAssistantMessageEventStream();return state.deferredFetchCount++,queueMicrotask(async()=>{try{await fetchOptions?.onResponse?.({status:200,headers:{}},requestModel);let entry=deferredResponses.get(handle.id);if(!entry||entry.handle.provider!==handle.provider||entry.handle.modelId!==handle.modelId||entry.handle.api!==handle.api)throw new Error(`Unknown faux deferred response: ${handle.id}`);if(entry.cancelled)throw new Error(`Faux deferred response was cancelled: ${handle.id}`);if(entry.pendingFetches>0){entry.pendingFetches--,await streamWithDeltas(outer,createDeferredMessage(requestModel,entry.handle),minTokenSize,maxTokenSize,tokensPerSecond,schedulerHook,fetchOptions?.signal);return}if(!entry.final){let{deferred:_deferred,signal:_submissionSignal,onResponse:_submissionOnResponse,...submissionOptions}=entry.options??{};try{entry.final=await resolveResponse(entry.step,entry.context,submissionOptions,entry.model)}catch(error){entry.final=createErrorMessage(error,api,provider,entry.model.id)}}await streamWithDeltas(outer,entry.final,minTokenSize,maxTokenSize,tokensPerSecond,schedulerHook,fetchOptions?.signal)}catch(error){let message=createErrorMessage(error,api,provider,requestModel.id);outer.push({type:"error",reason:"error",error:message}),outer.end(message)}}),outer},cancelDeferred=async(requestModel,handle,cancelOptions)=>{state.cancelledDeferred.push(structuredClone(handle));let entry=deferredResponses.get(handle.id);entry&&(entry.cancelled=!0),await cancelOptions?.onResponse?.({status:200,headers:{}},requestModel)};function getModel(requestedModelId){return requestedModelId?models.find(candidate=>candidate.id===requestedModelId):models[0]}return{api,provider,models,stream,streamSimple,fetchDeferred,cancelDeferred,getModel,state,setResponses(responses){pendingResponses=[...responses]},appendResponses(responses){pendingResponses.push(...responses)},getPendingResponseCount(){return pendingResponses.length},getCallLog(){return callLog.map(entry=>({context:cloneContextForLog(entry.context),options:cloneStreamOptionsForLog(entry.options),timestamp:entry.timestamp,modelId:entry.modelId}))}}}var registeredFauxProviders=new Map;function getRegisteredFauxProvider(api){return registeredFauxProviders.get(api)}function fauxOverflowError(provider,message){return fauxAssistantMessage([],{stopReason:"error",errorMessage:`${provider}: ${message}`})}function fauxProvider(options={}){let core=createFauxCore(options);return{provider:createProvider({id:core.provider,auth:{apiKey:{name:"Faux",resolve:async()=>({auth:{}})}},models:core.models,api:{stream:core.stream,streamSimple:core.streamSimple,fetchDeferred:core.fetchDeferred,cancelDeferred:core.cancelDeferred}}),api:core.api,models:core.models,getModel:core.getModel,state:core.state,setResponses:core.setResponses,appendResponses:core.appendResponses,getPendingResponseCount:core.getPendingResponseCount,getCallLog:core.getCallLog}}var apiProviderRegistry=new Map,builtinApiProviderRegistry=new Map,getProviderScope=()=>{},providerScopeStrictMode=!1;function installProviderScopeAccessor(accessor){getProviderScope=accessor}function getActiveProviderScope(){let scope=getProviderScope();if(scope?.state==="closed")throw new Error("Provider scope is closed");if(!scope&&providerScopeStrictMode)throw new Error("Provider scope is required in strict mode");return scope}function wrapStream(api,stream){return(model,context,options)=>{if(model.api!==api)throw new Error(`Mismatched api: ${model.api} expected ${api}`);return stream(model,context,options)}}function wrapStreamSimple(api,streamSimple){return(model,context,options)=>{if(model.api!==api)throw new Error(`Mismatched api: ${model.api} expected ${api}`);return streamSimple(model,context,options)}}function createRegisteredProvider(provider,sourceId){return{provider:{api:provider.api,stream:wrapStream(provider.api,provider.stream),streamSimple:wrapStreamSimple(provider.api,provider.streamSimple)},sourceId}}function registerApiProvider(provider,sourceId){let scope=getActiveProviderScope();(scope?scope.overlay:apiProviderRegistry).set(provider.api,createRegisteredProvider(provider,sourceId))}function registerBuiltinApiProvider(provider){let registered=builtinApiProviderRegistry.get(provider.api)??createRegisteredProvider(provider);builtinApiProviderRegistry.set(provider.api,registered),apiProviderRegistry.has(provider.api)||apiProviderRegistry.set(provider.api,registered)}function getApiProvider(api){let scope=getActiveProviderScope();if(scope)return scope.overlay.get(api)?.provider??builtinApiProviderRegistry.get(api)?.provider;let faux=getRegisteredFauxProvider(api);return faux?{api:faux.api,stream:wrapStream(faux.api,faux.stream),streamSimple:wrapStreamSimple(faux.api,faux.streamSimple)}:apiProviderRegistry.get(api)?.provider}function getApiProviders(){let scope=getActiveProviderScope();if(scope){let providers=new Map(builtinApiProviderRegistry);for(let[api,entry]of scope.overlay)providers.set(api,entry);return Array.from(providers.values(),entry=>entry.provider)}return Array.from(apiProviderRegistry.values(),entry=>entry.provider)}function unregisterApiProviders(sourceId){let scope=getActiveProviderScope(),registry=scope?scope.overlay:apiProviderRegistry;for(let[api,entry]of registry.entries())entry.sourceId===sourceId&®istry.delete(api)}function clearApiProviders(){let scope=getActiveProviderScope();(scope?scope.overlay:apiProviderRegistry).clear()}function envApiKeyAuth(name,envVars){return{name,login:async interaction=>{interaction.signal.throwIfAborted();let key=await interaction.prompt({type:"secret",message:`Enter ${name}`});return interaction.signal.throwIfAborted(),{type:"api_key",key}},resolve:async({ctx,credential,signal})=>{if(signal.throwIfAborted(),credential?.key)return{auth:{apiKey:credential.key},env:credential.env,source:"stored credential"};for(let envVar of envVars){let value=await ctx.env(envVar);if(signal.throwIfAborted(),value)return{auth:{apiKey:value},source:envVar}}}}}function lazyOAuth(input){let promise,loaded=()=>(promise??=input.load(),promise);return{name:input.name,isSubscription:input.isSubscription,loginLabel:input.loginLabel,login:async interaction=>(await loaded()).login(interaction),refresh:async(credential,signal)=>(await loaded()).refresh(credential,signal),toAuth:async credential=>(await loaded()).toAuth(credential)}}var cursor_variant_aliases_default={$schema:"cursor-variant-aliases/v1",source:"union of GetUsableModels live capture (204 ids) and cursor-agent CLI listing capture (203 ids), 2026-08-18",aliases:{"claude-4-sonnet":{targetId:"claude-4-sonnet",legacyVariantId:"claude-4-sonnet",encoding:"legacy-variant"},"claude-4-sonnet-thinking":{targetId:"claude-4-sonnet-thinking",legacyVariantId:"claude-4-sonnet-thinking",encoding:"legacy-variant"},"claude-4.5-opus-high":{targetId:"claude-4.5-opus",level:"high",legacyVariantId:"claude-4.5-opus-high",encoding:"legacy-variant"},"claude-4.5-opus-high-thinking":{targetId:"claude-4.5-opus-thinking",level:"high",legacyVariantId:"claude-4.5-opus-high-thinking",encoding:"legacy-variant"},"claude-4.5-sonnet":{targetId:"claude-4.5-sonnet",legacyVariantId:"claude-4.5-sonnet",encoding:"legacy-variant"},"claude-4.5-sonnet-thinking":{targetId:"claude-4.5-sonnet-thinking",legacyVariantId:"claude-4.5-sonnet-thinking",encoding:"legacy-variant"},"claude-4.6-opus-high":{targetId:"claude-4.6-opus",level:"high",legacyVariantId:"claude-4.6-opus-high",encoding:"legacy-variant"},"claude-4.6-opus-max":{targetId:"claude-4.6-opus",level:"max",legacyVariantId:"claude-4.6-opus-max",encoding:"legacy-variant"},"claude-4.6-opus-high-thinking":{targetId:"claude-4.6-opus-thinking",level:"high",legacyVariantId:"claude-4.6-opus-high-thinking",encoding:"legacy-variant"},"claude-4.6-opus-max-thinking":{targetId:"claude-4.6-opus-thinking",level:"max",legacyVariantId:"claude-4.6-opus-max-thinking",encoding:"legacy-variant"},"claude-4.6-sonnet-medium":{targetId:"claude-4.6-sonnet",level:"medium",legacyVariantId:"claude-4.6-sonnet-medium",encoding:"legacy-variant"},"claude-4.6-sonnet-medium-thinking":{targetId:"claude-4.6-sonnet-thinking",level:"medium",legacyVariantId:"claude-4.6-sonnet-medium-thinking",encoding:"legacy-variant"},"claude-fable-5-high":{targetId:"claude-fable-5",level:"high",legacyVariantId:"claude-fable-5-high",encoding:"legacy-variant"},"claude-fable-5-low":{targetId:"claude-fable-5",level:"low",legacyVariantId:"claude-fable-5-low",encoding:"legacy-variant"},"claude-fable-5-max":{targetId:"claude-fable-5",level:"max",legacyVariantId:"claude-fable-5-max",encoding:"legacy-variant"},"claude-fable-5-medium":{targetId:"claude-fable-5",level:"medium",legacyVariantId:"claude-fable-5-medium",encoding:"legacy-variant"},"claude-fable-5-xhigh":{targetId:"claude-fable-5",level:"xhigh",legacyVariantId:"claude-fable-5-xhigh",encoding:"legacy-variant"},"claude-fable-5-thinking-high":{targetId:"claude-fable-5-thinking",level:"high",legacyVariantId:"claude-fable-5-thinking-high",encoding:"legacy-variant"},"claude-fable-5-thinking-low":{targetId:"claude-fable-5-thinking",level:"low",legacyVariantId:"claude-fable-5-thinking-low",encoding:"legacy-variant"},"claude-fable-5-thinking-max":{targetId:"claude-fable-5-thinking",level:"max",legacyVariantId:"claude-fable-5-thinking-max",encoding:"legacy-variant"},"claude-fable-5-thinking-medium":{targetId:"claude-fable-5-thinking",level:"medium",legacyVariantId:"claude-fable-5-thinking-medium",encoding:"legacy-variant"},"claude-fable-5-thinking-xhigh":{targetId:"claude-fable-5-thinking",level:"xhigh",legacyVariantId:"claude-fable-5-thinking-xhigh",encoding:"legacy-variant"},"claude-opus-4-7-high":{targetId:"claude-opus-4-7",level:"high",legacyVariantId:"claude-opus-4-7-high",encoding:"legacy-variant"},"claude-opus-4-7-low":{targetId:"claude-opus-4-7",level:"low",legacyVariantId:"claude-opus-4-7-low",encoding:"legacy-variant"},"claude-opus-4-7-max":{targetId:"claude-opus-4-7",level:"max",legacyVariantId:"claude-opus-4-7-max",encoding:"legacy-variant"},"claude-opus-4-7-medium":{targetId:"claude-opus-4-7",level:"medium",legacyVariantId:"claude-opus-4-7-medium",encoding:"legacy-variant"},"claude-opus-4-7-xhigh":{targetId:"claude-opus-4-7",level:"xhigh",legacyVariantId:"claude-opus-4-7-xhigh",encoding:"legacy-variant"},"claude-opus-4-7-high-fast":{targetId:"claude-opus-4-7-high-fast",legacyVariantId:"claude-opus-4-7-high-fast",encoding:"legacy-variant"},"claude-opus-4-7-low-fast":{targetId:"claude-opus-4-7-low-fast",legacyVariantId:"claude-opus-4-7-low-fast",encoding:"legacy-variant"},"claude-opus-4-7-max-fast":{targetId:"claude-opus-4-7-max-fast",legacyVariantId:"claude-opus-4-7-max-fast",encoding:"legacy-variant"},"claude-opus-4-7-medium-fast":{targetId:"claude-opus-4-7-medium-fast",legacyVariantId:"claude-opus-4-7-medium-fast",encoding:"legacy-variant"},"claude-opus-4-7-xhigh-fast":{targetId:"claude-opus-4-7-xhigh-fast",legacyVariantId:"claude-opus-4-7-xhigh-fast",encoding:"legacy-variant"},"claude-opus-4-7-thinking-high":{targetId:"claude-opus-4-7-thinking",level:"high",legacyVariantId:"claude-opus-4-7-thinking-high",encoding:"legacy-variant"},"claude-opus-4-7-thinking-low":{targetId:"claude-opus-4-7-thinking",level:"low",legacyVariantId:"claude-opus-4-7-thinking-low",encoding:"legacy-variant"},"claude-opus-4-7-thinking-max":{targetId:"claude-opus-4-7-thinking",level:"max",legacyVariantId:"claude-opus-4-7-thinking-max",encoding:"legacy-variant"},"claude-opus-4-7-thinking-medium":{targetId:"claude-opus-4-7-thinking",level:"medium",legacyVariantId:"claude-opus-4-7-thinking-medium",encoding:"legacy-variant"},"claude-opus-4-7-thinking-xhigh":{targetId:"claude-opus-4-7-thinking",level:"xhigh",legacyVariantId:"claude-opus-4-7-thinking-xhigh",encoding:"legacy-variant"},"claude-opus-4-7-thinking-high-fast":{targetId:"claude-opus-4-7-thinking-high-fast",legacyVariantId:"claude-opus-4-7-thinking-high-fast",encoding:"legacy-variant"},"claude-opus-4-7-thinking-low-fast":{targetId:"claude-opus-4-7-thinking-low-fast",legacyVariantId:"claude-opus-4-7-thinking-low-fast",encoding:"legacy-variant"},"claude-opus-4-7-thinking-max-fast":{targetId:"claude-opus-4-7-thinking-max-fast",legacyVariantId:"claude-opus-4-7-thinking-max-fast",encoding:"legacy-variant"},"claude-opus-4-7-thinking-medium-fast":{targetId:"claude-opus-4-7-thinking-medium-fast",legacyVariantId:"claude-opus-4-7-thinking-medium-fast",encoding:"legacy-variant"},"claude-opus-4-7-thinking-xhigh-fast":{targetId:"claude-opus-4-7-thinking-xhigh-fast",legacyVariantId:"claude-opus-4-7-thinking-xhigh-fast",encoding:"legacy-variant"},"claude-opus-4-8-high":{targetId:"claude-opus-4-8",level:"high",legacyVariantId:"claude-opus-4-8-high",encoding:"legacy-variant"},"claude-opus-4-8-low":{targetId:"claude-opus-4-8",level:"low",legacyVariantId:"claude-opus-4-8-low",encoding:"legacy-variant"},"claude-opus-4-8-max":{targetId:"claude-opus-4-8",level:"max",legacyVariantId:"claude-opus-4-8-max",encoding:"legacy-variant"},"claude-opus-4-8-medium":{targetId:"claude-opus-4-8",level:"medium",legacyVariantId:"claude-opus-4-8-medium",encoding:"legacy-variant"},"claude-opus-4-8-xhigh":{targetId:"claude-opus-4-8",level:"xhigh",legacyVariantId:"claude-opus-4-8-xhigh",encoding:"legacy-variant"},"claude-opus-4-8-high-fast":{targetId:"claude-opus-4-8-high-fast",legacyVariantId:"claude-opus-4-8-high-fast",encoding:"legacy-variant"},"claude-opus-4-8-low-fast":{targetId:"claude-opus-4-8-low-fast",legacyVariantId:"claude-opus-4-8-low-fast",encoding:"legacy-variant"},"claude-opus-4-8-max-fast":{targetId:"claude-opus-4-8-max-fast",legacyVariantId:"claude-opus-4-8-max-fast",encoding:"legacy-variant"},"claude-opus-4-8-medium-fast":{targetId:"claude-opus-4-8-medium-fast",legacyVariantId:"claude-opus-4-8-medium-fast",encoding:"legacy-variant"},"claude-opus-4-8-xhigh-fast":{targetId:"claude-opus-4-8-xhigh-fast",legacyVariantId:"claude-opus-4-8-xhigh-fast",encoding:"legacy-variant"},"claude-opus-4-8-thinking-high":{targetId:"claude-opus-4-8-thinking",level:"high",legacyVariantId:"claude-opus-4-8-thinking-high",encoding:"legacy-variant"},"claude-opus-4-8-thinking-low":{targetId:"claude-opus-4-8-thinking",level:"low",legacyVariantId:"claude-opus-4-8-thinking-low",encoding:"legacy-variant"},"claude-opus-4-8-thinking-max":{targetId:"claude-opus-4-8-thinking",level:"max",legacyVariantId:"claude-opus-4-8-thinking-max",encoding:"legacy-variant"},"claude-opus-4-8-thinking-medium":{targetId:"claude-opus-4-8-thinking",level:"medium",legacyVariantId:"claude-opus-4-8-thinking-medium",encoding:"legacy-variant"},"claude-opus-4-8-thinking-xhigh":{targetId:"claude-opus-4-8-thinking",level:"xhigh",legacyVariantId:"claude-opus-4-8-thinking-xhigh",encoding:"legacy-variant"},"claude-opus-4-8-thinking-high-fast":{targetId:"claude-opus-4-8-thinking-high-fast",legacyVariantId:"claude-opus-4-8-thinking-high-fast",encoding:"legacy-variant"},"claude-opus-4-8-thinking-low-fast":{targetId:"claude-opus-4-8-thinking-low-fast",legacyVariantId:"claude-opus-4-8-thinking-low-fast",encoding:"legacy-variant"},"claude-opus-4-8-thinking-max-fast":{targetId:"claude-opus-4-8-thinking-max-fast",legacyVariantId:"claude-opus-4-8-thinking-max-fast",encoding:"legacy-variant"},"claude-opus-4-8-thinking-medium-fast":{targetId:"claude-opus-4-8-thinking-medium-fast",legacyVariantId:"claude-opus-4-8-thinking-medium-fast",encoding:"legacy-variant"},"claude-opus-4-8-thinking-xhigh-fast":{targetId:"claude-opus-4-8-thinking-xhigh-fast",legacyVariantId:"claude-opus-4-8-thinking-xhigh-fast",encoding:"legacy-variant"},"claude-opus-5-high":{targetId:"claude-opus-5",level:"high",legacyVariantId:"claude-opus-5-high",encoding:"legacy-variant"},"claude-opus-5-low":{targetId:"claude-opus-5",level:"low",legacyVariantId:"claude-opus-5-low",encoding:"legacy-variant"},"claude-opus-5-medium":{targetId:"claude-opus-5",level:"medium",legacyVariantId:"claude-opus-5-medium",encoding:"legacy-variant"},"claude-opus-5-max":{targetId:"claude-opus-5",level:"max",legacyVariantId:"claude-opus-5-max",encoding:"legacy-variant"},"claude-opus-5-high-fast":{targetId:"claude-opus-5-high-fast",legacyVariantId:"claude-opus-5-high-fast",encoding:"legacy-variant"},"claude-opus-5-low-fast":{targetId:"claude-opus-5-low-fast",legacyVariantId:"claude-opus-5-low-fast",encoding:"legacy-variant"},"claude-opus-5-medium-fast":{targetId:"claude-opus-5-medium-fast",legacyVariantId:"claude-opus-5-medium-fast",encoding:"legacy-variant"},"claude-opus-5-max-fast":{targetId:"claude-opus-5-max-fast",legacyVariantId:"claude-opus-5-max-fast",encoding:"legacy-variant"},"claude-opus-5-thinking-high":{targetId:"claude-opus-5-thinking",level:"high",legacyVariantId:"claude-opus-5-thinking-high",encoding:"legacy-variant"},"claude-opus-5-thinking-low":{targetId:"claude-opus-5-thinking",level:"low",legacyVariantId:"claude-opus-5-thinking-low",encoding:"legacy-variant"},"claude-opus-5-thinking-max":{targetId:"claude-opus-5-thinking",level:"max",legacyVariantId:"claude-opus-5-thinking-max",encoding:"legacy-variant"},"claude-opus-5-thinking-medium":{targetId:"claude-opus-5-thinking",level:"medium",legacyVariantId:"claude-opus-5-thinking-medium",encoding:"legacy-variant"},"claude-opus-5-thinking-xhigh":{targetId:"claude-opus-5-thinking",level:"xhigh",legacyVariantId:"claude-opus-5-thinking-xhigh",encoding:"legacy-variant"},"claude-opus-5-thinking-high-fast":{targetId:"claude-opus-5-thinking-high-fast",legacyVariantId:"claude-opus-5-thinking-high-fast",encoding:"legacy-variant"},"claude-opus-5-thinking-low-fast":{targetId:"claude-opus-5-thinking-low-fast",legacyVariantId:"claude-opus-5-thinking-low-fast",encoding:"legacy-variant"},"claude-opus-5-thinking-max-fast":{targetId:"claude-opus-5-thinking-max-fast",legacyVariantId:"claude-opus-5-thinking-max-fast",encoding:"legacy-variant"},"claude-opus-5-thinking-medium-fast":{targetId:"claude-opus-5-thinking-medium-fast",legacyVariantId:"claude-opus-5-thinking-medium-fast",encoding:"legacy-variant"},"claude-opus-5-thinking-xhigh-fast":{targetId:"claude-opus-5-thinking-xhigh-fast",legacyVariantId:"claude-opus-5-thinking-xhigh-fast",encoding:"legacy-variant"},"claude-sonnet-5-high":{targetId:"claude-sonnet-5",level:"high",legacyVariantId:"claude-sonnet-5-high",encoding:"legacy-variant"},"claude-sonnet-5-low":{targetId:"claude-sonnet-5",level:"low",legacyVariantId:"claude-sonnet-5-low",encoding:"legacy-variant"},"claude-sonnet-5-max":{targetId:"claude-sonnet-5",level:"max",legacyVariantId:"claude-sonnet-5-max",encoding:"legacy-variant"},"claude-sonnet-5-medium":{targetId:"claude-sonnet-5",level:"medium",legacyVariantId:"claude-sonnet-5-medium",encoding:"legacy-variant"},"claude-sonnet-5-xhigh":{targetId:"claude-sonnet-5",level:"xhigh",legacyVariantId:"claude-sonnet-5-xhigh",encoding:"legacy-variant"},"claude-sonnet-5-thinking-high":{targetId:"claude-sonnet-5-thinking",level:"high",legacyVariantId:"claude-sonnet-5-thinking-high",encoding:"legacy-variant"},"claude-sonnet-5-thinking-low":{targetId:"claude-sonnet-5-thinking",level:"low",legacyVariantId:"claude-sonnet-5-thinking-low",encoding:"legacy-variant"},"claude-sonnet-5-thinking-max":{targetId:"claude-sonnet-5-thinking",level:"max",legacyVariantId:"claude-sonnet-5-thinking-max",encoding:"legacy-variant"},"claude-sonnet-5-thinking-medium":{targetId:"claude-sonnet-5-thinking",level:"medium",legacyVariantId:"claude-sonnet-5-thinking-medium",encoding:"legacy-variant"},"claude-sonnet-5-thinking-xhigh":{targetId:"claude-sonnet-5-thinking",level:"xhigh",legacyVariantId:"claude-sonnet-5-thinking-xhigh",encoding:"legacy-variant"},"composer-2.5":{targetId:"composer-2.5",legacyVariantId:"composer-2.5",encoding:"legacy-variant"},"composer-2.5-fast":{targetId:"composer-2.5-fast",legacyVariantId:"composer-2.5-fast",encoding:"legacy-variant"},"cursor-grok-4.5-high":{targetId:"cursor-grok-4.5",level:"high",legacyVariantId:"cursor-grok-4.5-high",encoding:"legacy-variant"},"cursor-grok-4.5-low":{targetId:"cursor-grok-4.5",level:"low",legacyVariantId:"cursor-grok-4.5-low",encoding:"legacy-variant"},"cursor-grok-4.5-medium":{targetId:"cursor-grok-4.5",level:"medium",legacyVariantId:"cursor-grok-4.5-medium",encoding:"legacy-variant"},"cursor-grok-4.5-max":{targetId:"cursor-grok-4.5",level:"max",legacyVariantId:"cursor-grok-4.5-max",encoding:"legacy-variant"},"cursor-grok-4.5-thinking-low":{targetId:"cursor-grok-4.5",level:"low",legacyVariantId:"cursor-grok-4.5-thinking-low",encoding:"legacy-variant"},"cursor-grok-4.5-thinking-medium":{targetId:"cursor-grok-4.5",level:"medium",legacyVariantId:"cursor-grok-4.5-thinking-medium",encoding:"legacy-variant"},"cursor-grok-4.5-thinking-max":{targetId:"cursor-grok-4.5",level:"max",legacyVariantId:"cursor-grok-4.5-thinking-max",encoding:"legacy-variant"},"cursor-grok-4.5-high-fast":{targetId:"cursor-grok-4.5-high-fast",legacyVariantId:"cursor-grok-4.5-high-fast",encoding:"legacy-variant"},"cursor-grok-4.5-low-fast":{targetId:"cursor-grok-4.5-low-fast",legacyVariantId:"cursor-grok-4.5-low-fast",encoding:"legacy-variant"},"cursor-grok-4.5-medium-fast":{targetId:"cursor-grok-4.5-medium-fast",legacyVariantId:"cursor-grok-4.5-medium-fast",encoding:"legacy-variant"},"cursor-grok-4.5-max-fast":{targetId:"cursor-grok-4.5-max-fast",legacyVariantId:"cursor-grok-4.5-max-fast",encoding:"legacy-variant"},"cursor-grok-4.6-high":{targetId:"cursor-grok-4.6",level:"high",legacyVariantId:"cursor-grok-4.6-high",encoding:"legacy-variant"},"cursor-grok-4.6-low":{targetId:"cursor-grok-4.6",level:"low",legacyVariantId:"cursor-grok-4.6-low",encoding:"legacy-variant"},"cursor-grok-4.6-medium":{targetId:"cursor-grok-4.6",level:"medium",legacyVariantId:"cursor-grok-4.6-medium",encoding:"legacy-variant"},"cursor-grok-4.6-xhigh":{targetId:"cursor-grok-4.6",level:"xhigh",legacyVariantId:"cursor-grok-4.6-xhigh",encoding:"legacy-variant"},"cursor-grok-4.6-max":{targetId:"cursor-grok-4.6",level:"max",legacyVariantId:"cursor-grok-4.6-max",encoding:"legacy-variant"},"cursor-grok-4.6-thinking-low":{targetId:"cursor-grok-4.6",level:"low",legacyVariantId:"cursor-grok-4.6-thinking-low",encoding:"legacy-variant"},"cursor-grok-4.6-thinking-medium":{targetId:"cursor-grok-4.6",level:"medium",legacyVariantId:"cursor-grok-4.6-thinking-medium",encoding:"legacy-variant"},"cursor-grok-4.6-thinking-max":{targetId:"cursor-grok-4.6",level:"max",legacyVariantId:"cursor-grok-4.6-thinking-max",encoding:"legacy-variant"},"cursor-grok-4.6-high-fast":{targetId:"cursor-grok-4.6-high-fast",legacyVariantId:"cursor-grok-4.6-high-fast",encoding:"legacy-variant"},"cursor-grok-4.6-low-fast":{targetId:"cursor-grok-4.6-low-fast",legacyVariantId:"cursor-grok-4.6-low-fast",encoding:"legacy-variant"},"cursor-grok-4.6-medium-fast":{targetId:"cursor-grok-4.6-medium-fast",legacyVariantId:"cursor-grok-4.6-medium-fast",encoding:"legacy-variant"},"cursor-grok-4.6-xhigh-fast":{targetId:"cursor-grok-4.6-xhigh-fast",legacyVariantId:"cursor-grok-4.6-xhigh-fast",encoding:"legacy-variant"},"cursor-grok-4.6-max-fast":{targetId:"cursor-grok-4.6-max-fast",legacyVariantId:"cursor-grok-4.6-max-fast",encoding:"legacy-variant"},default:{targetId:"default",legacyVariantId:"default",encoding:"legacy-variant"},"gemini-3-flash":{targetId:"gemini-3-flash",legacyVariantId:"gemini-3-flash",encoding:"legacy-variant"},"gemini-3.1-pro":{targetId:"gemini-3.1-pro",legacyVariantId:"gemini-3.1-pro",encoding:"legacy-variant"},"gemini-3.5-flash":{targetId:"gemini-3.5-flash",legacyVariantId:"gemini-3.5-flash",encoding:"legacy-variant"},"gemini-3.6-flash-high":{targetId:"gemini-3.6-flash",level:"high",legacyVariantId:"gemini-3.6-flash-high",encoding:"legacy-variant"},"gemini-3.6-flash-low":{targetId:"gemini-3.6-flash",level:"low",legacyVariantId:"gemini-3.6-flash-low",encoding:"legacy-variant"},"gemini-3.6-flash-medium":{targetId:"gemini-3.6-flash",level:"medium",legacyVariantId:"gemini-3.6-flash-medium",encoding:"legacy-variant"},"gemini-3.6-flash-minimal":{targetId:"gemini-3.6-flash",level:"minimal",legacyVariantId:"gemini-3.6-flash-minimal",encoding:"legacy-variant"},"gemini-3.7-flash-high":{targetId:"gemini-3.7-flash",level:"high",legacyVariantId:"gemini-3.7-flash-high",encoding:"legacy-variant"},"gemini-3.7-flash-low":{targetId:"gemini-3.7-flash",level:"low",legacyVariantId:"gemini-3.7-flash-low",encoding:"legacy-variant"},"gemini-3.7-flash-medium":{targetId:"gemini-3.7-flash",level:"medium",legacyVariantId:"gemini-3.7-flash-medium",encoding:"legacy-variant"},"gemini-3.7-flash-max":{targetId:"gemini-3.7-flash",level:"max",legacyVariantId:"gemini-3.7-flash-max",encoding:"legacy-variant"},"gemini-3.7-flash-thinking-low":{targetId:"gemini-3.7-flash",level:"low",legacyVariantId:"gemini-3.7-flash-thinking-low",encoding:"legacy-variant"},"gemini-3.7-flash-thinking-medium":{targetId:"gemini-3.7-flash",level:"medium",legacyVariantId:"gemini-3.7-flash-thinking-medium",encoding:"legacy-variant"},"gemini-3.7-flash-thinking-max":{targetId:"gemini-3.7-flash",level:"max",legacyVariantId:"gemini-3.7-flash-thinking-max",encoding:"legacy-variant"},"glm-5.2-high":{targetId:"glm-5.2",level:"high",legacyVariantId:"glm-5.2-high",encoding:"legacy-variant"},"glm-5.2-max":{targetId:"glm-5.2",level:"max",legacyVariantId:"glm-5.2-max",encoding:"legacy-variant"},"gpt-5-mini":{targetId:"gpt-5-mini",legacyVariantId:"gpt-5-mini",encoding:"legacy-variant"},"gpt-5.1":{targetId:"gpt-5.1",legacyVariantId:"gpt-5.1",encoding:"legacy-variant"},"gpt-5.1-high":{targetId:"gpt-5.1",level:"high",legacyVariantId:"gpt-5.1-high",encoding:"legacy-variant"},"gpt-5.1-low":{targetId:"gpt-5.1",level:"low",legacyVariantId:"gpt-5.1-low",encoding:"legacy-variant"},"gpt-5.2":{targetId:"gpt-5.2",legacyVariantId:"gpt-5.2",encoding:"legacy-variant"},"gpt-5.2-high":{targetId:"gpt-5.2",level:"high",legacyVariantId:"gpt-5.2-high",encoding:"legacy-variant"},"gpt-5.2-low":{targetId:"gpt-5.2",level:"low",legacyVariantId:"gpt-5.2-low",encoding:"legacy-variant"},"gpt-5.2-xhigh":{targetId:"gpt-5.2",level:"xhigh",legacyVariantId:"gpt-5.2-xhigh",encoding:"legacy-variant"},"gpt-5.2-medium":{targetId:"gpt-5.2",level:"medium",legacyVariantId:"gpt-5.2-medium",encoding:"legacy-variant"},"gpt-5.2-max":{targetId:"gpt-5.2",level:"max",legacyVariantId:"gpt-5.2-max",encoding:"legacy-variant"},"gpt-5.2-thinking-low":{targetId:"gpt-5.2",level:"low",legacyVariantId:"gpt-5.2-thinking-low",encoding:"legacy-variant"},"gpt-5.2-thinking-medium":{targetId:"gpt-5.2",level:"medium",legacyVariantId:"gpt-5.2-thinking-medium",encoding:"legacy-variant"},"gpt-5.2-thinking-max":{targetId:"gpt-5.2",level:"max",legacyVariantId:"gpt-5.2-thinking-max",encoding:"legacy-variant"},"gpt-5.2-fast":{targetId:"gpt-5.2-fast",legacyVariantId:"gpt-5.2-fast",encoding:"legacy-variant"},"gpt-5.2-high-fast":{targetId:"gpt-5.2-high-fast",legacyVariantId:"gpt-5.2-high-fast",encoding:"legacy-variant"},"gpt-5.2-low-fast":{targetId:"gpt-5.2-low-fast",legacyVariantId:"gpt-5.2-low-fast",encoding:"legacy-variant"},"gpt-5.2-xhigh-fast":{targetId:"gpt-5.2-xhigh-fast",legacyVariantId:"gpt-5.2-xhigh-fast",encoding:"legacy-variant"},"gpt-5.2-medium-fast":{targetId:"gpt-5.2-medium-fast",legacyVariantId:"gpt-5.2-medium-fast",encoding:"legacy-variant"},"gpt-5.2-max-fast":{targetId:"gpt-5.2-max-fast",legacyVariantId:"gpt-5.2-max-fast",encoding:"legacy-variant"},"gpt-5.3-codex":{targetId:"gpt-5.3-codex",legacyVariantId:"gpt-5.3-codex",encoding:"legacy-variant"},"gpt-5.3-codex-high":{targetId:"gpt-5.3-codex",level:"high",legacyVariantId:"gpt-5.3-codex-high",encoding:"legacy-variant"},"gpt-5.3-codex-low":{targetId:"gpt-5.3-codex",level:"low",legacyVariantId:"gpt-5.3-codex-low",encoding:"legacy-variant"},"gpt-5.3-codex-xhigh":{targetId:"gpt-5.3-codex",level:"xhigh",legacyVariantId:"gpt-5.3-codex-xhigh",encoding:"legacy-variant"},"gpt-5.3-codex-medium":{targetId:"gpt-5.3-codex",level:"medium",legacyVariantId:"gpt-5.3-codex-medium",encoding:"legacy-variant"},"gpt-5.3-codex-max":{targetId:"gpt-5.3-codex",level:"max",legacyVariantId:"gpt-5.3-codex-max",encoding:"legacy-variant"},"gpt-5.3-codex-thinking-low":{targetId:"gpt-5.3-codex",level:"low",legacyVariantId:"gpt-5.3-codex-thinking-low",encoding:"legacy-variant"},"gpt-5.3-codex-thinking-medium":{targetId:"gpt-5.3-codex",level:"medium",legacyVariantId:"gpt-5.3-codex-thinking-medium",encoding:"legacy-variant"},"gpt-5.3-codex-thinking-max":{targetId:"gpt-5.3-codex",level:"max",legacyVariantId:"gpt-5.3-codex-thinking-max",encoding:"legacy-variant"},"gpt-5.3-codex-fast":{targetId:"gpt-5.3-codex-fast",legacyVariantId:"gpt-5.3-codex-fast",encoding:"legacy-variant"},"gpt-5.3-codex-high-fast":{targetId:"gpt-5.3-codex-high-fast",legacyVariantId:"gpt-5.3-codex-high-fast",encoding:"legacy-variant"},"gpt-5.3-codex-low-fast":{targetId:"gpt-5.3-codex-low-fast",legacyVariantId:"gpt-5.3-codex-low-fast",encoding:"legacy-variant"},"gpt-5.3-codex-xhigh-fast":{targetId:"gpt-5.3-codex-xhigh-fast",legacyVariantId:"gpt-5.3-codex-xhigh-fast",encoding:"legacy-variant"},"gpt-5.3-codex-medium-fast":{targetId:"gpt-5.3-codex-medium-fast",legacyVariantId:"gpt-5.3-codex-medium-fast",encoding:"legacy-variant"},"gpt-5.3-codex-max-fast":{targetId:"gpt-5.3-codex-max-fast",legacyVariantId:"gpt-5.3-codex-max-fast",encoding:"legacy-variant"},"gpt-5.4-high":{targetId:"gpt-5.4",level:"high",legacyVariantId:"gpt-5.4-high",encoding:"legacy-variant"},"gpt-5.4-low":{targetId:"gpt-5.4",level:"low",legacyVariantId:"gpt-5.4-low",encoding:"legacy-variant"},"gpt-5.4-medium":{targetId:"gpt-5.4",level:"medium",legacyVariantId:"gpt-5.4-medium",encoding:"legacy-variant"},"gpt-5.4-xhigh":{targetId:"gpt-5.4",level:"xhigh",legacyVariantId:"gpt-5.4-xhigh",encoding:"legacy-variant"},"gpt-5.4-high-fast":{targetId:"gpt-5.4-high-fast",legacyVariantId:"gpt-5.4-high-fast",encoding:"legacy-variant"},"gpt-5.4-medium-fast":{targetId:"gpt-5.4-medium-fast",legacyVariantId:"gpt-5.4-medium-fast",encoding:"legacy-variant"},"gpt-5.4-xhigh-fast":{targetId:"gpt-5.4-xhigh-fast",legacyVariantId:"gpt-5.4-xhigh-fast",encoding:"legacy-variant"},"gpt-5.4-mini-high":{targetId:"gpt-5.4-mini",level:"high",legacyVariantId:"gpt-5.4-mini-high",encoding:"legacy-variant"},"gpt-5.4-mini-low":{targetId:"gpt-5.4-mini",level:"low",legacyVariantId:"gpt-5.4-mini-low",encoding:"legacy-variant"},"gpt-5.4-mini-medium":{targetId:"gpt-5.4-mini",level:"medium",legacyVariantId:"gpt-5.4-mini-medium",encoding:"legacy-variant"},"gpt-5.4-mini-none":{targetId:"gpt-5.4-mini",level:"off",legacyVariantId:"gpt-5.4-mini-none",encoding:"legacy-variant"},"gpt-5.4-mini-xhigh":{targetId:"gpt-5.4-mini",level:"xhigh",legacyVariantId:"gpt-5.4-mini-xhigh",encoding:"legacy-variant"},"gpt-5.4-nano-high":{targetId:"gpt-5.4-nano",level:"high",legacyVariantId:"gpt-5.4-nano-high",encoding:"legacy-variant"},"gpt-5.4-nano-low":{targetId:"gpt-5.4-nano",level:"low",legacyVariantId:"gpt-5.4-nano-low",encoding:"legacy-variant"},"gpt-5.4-nano-medium":{targetId:"gpt-5.4-nano",level:"medium",legacyVariantId:"gpt-5.4-nano-medium",encoding:"legacy-variant"},"gpt-5.4-nano-none":{targetId:"gpt-5.4-nano",level:"off",legacyVariantId:"gpt-5.4-nano-none",encoding:"legacy-variant"},"gpt-5.4-nano-xhigh":{targetId:"gpt-5.4-nano",level:"xhigh",legacyVariantId:"gpt-5.4-nano-xhigh",encoding:"legacy-variant"},"gpt-5.5-extra-high":{targetId:"gpt-5.5",level:"extra-high",legacyVariantId:"gpt-5.5-extra-high",encoding:"legacy-variant"},"gpt-5.5-high":{targetId:"gpt-5.5",level:"high",legacyVariantId:"gpt-5.5-high",encoding:"legacy-variant"},"gpt-5.5-low":{targetId:"gpt-5.5",level:"low",legacyVariantId:"gpt-5.5-low",encoding:"legacy-variant"},"gpt-5.5-medium":{targetId:"gpt-5.5",level:"medium",legacyVariantId:"gpt-5.5-medium",encoding:"legacy-variant"},"gpt-5.5-none":{targetId:"gpt-5.5",level:"off",legacyVariantId:"gpt-5.5-none",encoding:"legacy-variant"},"gpt-5.5-max":{targetId:"gpt-5.5",level:"max",legacyVariantId:"gpt-5.5-max",encoding:"legacy-variant"},"gpt-5.5-thinking-low":{targetId:"gpt-5.5",level:"low",legacyVariantId:"gpt-5.5-thinking-low",encoding:"legacy-variant"},"gpt-5.5-thinking-medium":{targetId:"gpt-5.5",level:"medium",legacyVariantId:"gpt-5.5-thinking-medium",encoding:"legacy-variant"},"gpt-5.5-thinking-max":{targetId:"gpt-5.5",level:"max",legacyVariantId:"gpt-5.5-thinking-max",encoding:"legacy-variant"},"gpt-5.5-extra-high-fast":{targetId:"gpt-5.5-extra-high-fast",legacyVariantId:"gpt-5.5-extra-high-fast",encoding:"legacy-variant"},"gpt-5.5-high-fast":{targetId:"gpt-5.5-high-fast",legacyVariantId:"gpt-5.5-high-fast",encoding:"legacy-variant"},"gpt-5.5-low-fast":{targetId:"gpt-5.5-low-fast",legacyVariantId:"gpt-5.5-low-fast",encoding:"legacy-variant"},"gpt-5.5-medium-fast":{targetId:"gpt-5.5-medium-fast",legacyVariantId:"gpt-5.5-medium-fast",encoding:"legacy-variant"},"gpt-5.5-none-fast":{targetId:"gpt-5.5-none-fast",legacyVariantId:"gpt-5.5-none-fast",encoding:"legacy-variant"},"gpt-5.5-max-fast":{targetId:"gpt-5.5-max-fast",legacyVariantId:"gpt-5.5-max-fast",encoding:"legacy-variant"},"gpt-5.6-luna-high":{targetId:"gpt-5.6-luna",level:"high",legacyVariantId:"gpt-5.6-luna-high",encoding:"legacy-variant"},"gpt-5.6-luna-low":{targetId:"gpt-5.6-luna",level:"low",legacyVariantId:"gpt-5.6-luna-low",encoding:"legacy-variant"},"gpt-5.6-luna-max":{targetId:"gpt-5.6-luna",level:"max",legacyVariantId:"gpt-5.6-luna-max",encoding:"legacy-variant"},"gpt-5.6-luna-medium":{targetId:"gpt-5.6-luna",level:"medium",legacyVariantId:"gpt-5.6-luna-medium",encoding:"legacy-variant"},"gpt-5.6-luna-none":{targetId:"gpt-5.6-luna",level:"off",legacyVariantId:"gpt-5.6-luna-none",encoding:"legacy-variant"},"gpt-5.6-luna-xhigh":{targetId:"gpt-5.6-luna",level:"xhigh",legacyVariantId:"gpt-5.6-luna-xhigh",encoding:"legacy-variant"},"gpt-5.6-luna-thinking-low":{targetId:"gpt-5.6-luna",level:"low",legacyVariantId:"gpt-5.6-luna-thinking-low",encoding:"legacy-variant"},"gpt-5.6-luna-thinking-medium":{targetId:"gpt-5.6-luna",level:"medium",legacyVariantId:"gpt-5.6-luna-thinking-medium",encoding:"legacy-variant"},"gpt-5.6-luna-thinking-max":{targetId:"gpt-5.6-luna",level:"max",legacyVariantId:"gpt-5.6-luna-thinking-max",encoding:"legacy-variant"},"gpt-5.6-luna-high-fast":{targetId:"gpt-5.6-luna-high-fast",legacyVariantId:"gpt-5.6-luna-high-fast",encoding:"legacy-variant"},"gpt-5.6-luna-low-fast":{targetId:"gpt-5.6-luna-low-fast",legacyVariantId:"gpt-5.6-luna-low-fast",encoding:"legacy-variant"},"gpt-5.6-luna-max-fast":{targetId:"gpt-5.6-luna-max-fast",legacyVariantId:"gpt-5.6-luna-max-fast",encoding:"legacy-variant"},"gpt-5.6-luna-medium-fast":{targetId:"gpt-5.6-luna-medium-fast",legacyVariantId:"gpt-5.6-luna-medium-fast",encoding:"legacy-variant"},"gpt-5.6-luna-none-fast":{targetId:"gpt-5.6-luna-none-fast",legacyVariantId:"gpt-5.6-luna-none-fast",encoding:"legacy-variant"},"gpt-5.6-luna-xhigh-fast":{targetId:"gpt-5.6-luna-xhigh-fast",legacyVariantId:"gpt-5.6-luna-xhigh-fast",encoding:"legacy-variant"},"gpt-5.6-sol-high":{targetId:"gpt-5.6-sol",level:"high",legacyVariantId:"gpt-5.6-sol-high",encoding:"legacy-variant"},"gpt-5.6-sol-low":{targetId:"gpt-5.6-sol",level:"low",legacyVariantId:"gpt-5.6-sol-low",encoding:"legacy-variant"},"gpt-5.6-sol-max":{targetId:"gpt-5.6-sol",level:"max",legacyVariantId:"gpt-5.6-sol-max",encoding:"legacy-variant"},"gpt-5.6-sol-medium":{targetId:"gpt-5.6-sol",level:"medium",legacyVariantId:"gpt-5.6-sol-medium",encoding:"legacy-variant"},"gpt-5.6-sol-none":{targetId:"gpt-5.6-sol",level:"off",legacyVariantId:"gpt-5.6-sol-none",encoding:"legacy-variant"},"gpt-5.6-sol-xhigh":{targetId:"gpt-5.6-sol",level:"xhigh",legacyVariantId:"gpt-5.6-sol-xhigh",encoding:"legacy-variant"},"gpt-5.6-sol-thinking-low":{targetId:"gpt-5.6-sol",level:"low",legacyVariantId:"gpt-5.6-sol-thinking-low",encoding:"legacy-variant"},"gpt-5.6-sol-thinking-medium":{targetId:"gpt-5.6-sol",level:"medium",legacyVariantId:"gpt-5.6-sol-thinking-medium",encoding:"legacy-variant"},"gpt-5.6-sol-thinking-max":{targetId:"gpt-5.6-sol",level:"max",legacyVariantId:"gpt-5.6-sol-thinking-max",encoding:"legacy-variant"},"gpt-5.6-sol-high-fast":{targetId:"gpt-5.6-sol-high-fast",legacyVariantId:"gpt-5.6-sol-high-fast",encoding:"legacy-variant"},"gpt-5.6-sol-low-fast":{targetId:"gpt-5.6-sol-low-fast",legacyVariantId:"gpt-5.6-sol-low-fast",encoding:"legacy-variant"},"gpt-5.6-sol-max-fast":{targetId:"gpt-5.6-sol-max-fast",legacyVariantId:"gpt-5.6-sol-max-fast",encoding:"legacy-variant"},"gpt-5.6-sol-medium-fast":{targetId:"gpt-5.6-sol-medium-fast",legacyVariantId:"gpt-5.6-sol-medium-fast",encoding:"legacy-variant"},"gpt-5.6-sol-none-fast":{targetId:"gpt-5.6-sol-none-fast",legacyVariantId:"gpt-5.6-sol-none-fast",encoding:"legacy-variant"},"gpt-5.6-sol-xhigh-fast":{targetId:"gpt-5.6-sol-xhigh-fast",legacyVariantId:"gpt-5.6-sol-xhigh-fast",encoding:"legacy-variant"},"gpt-5.6-terra-high":{targetId:"gpt-5.6-terra",level:"high",legacyVariantId:"gpt-5.6-terra-high",encoding:"legacy-variant"},"gpt-5.6-terra-low":{targetId:"gpt-5.6-terra",level:"low",legacyVariantId:"gpt-5.6-terra-low",encoding:"legacy-variant"},"gpt-5.6-terra-max":{targetId:"gpt-5.6-terra",level:"max",legacyVariantId:"gpt-5.6-terra-max",encoding:"legacy-variant"},"gpt-5.6-terra-medium":{targetId:"gpt-5.6-terra",level:"medium",legacyVariantId:"gpt-5.6-terra-medium",encoding:"legacy-variant"},"gpt-5.6-terra-none":{targetId:"gpt-5.6-terra",level:"off",legacyVariantId:"gpt-5.6-terra-none",encoding:"legacy-variant"},"gpt-5.6-terra-xhigh":{targetId:"gpt-5.6-terra",level:"xhigh",legacyVariantId:"gpt-5.6-terra-xhigh",encoding:"legacy-variant"},"gpt-5.6-terra-high-fast":{targetId:"gpt-5.6-terra-high-fast",legacyVariantId:"gpt-5.6-terra-high-fast",encoding:"legacy-variant"},"gpt-5.6-terra-low-fast":{targetId:"gpt-5.6-terra-low-fast",legacyVariantId:"gpt-5.6-terra-low-fast",encoding:"legacy-variant"},"gpt-5.6-terra-max-fast":{targetId:"gpt-5.6-terra-max-fast",legacyVariantId:"gpt-5.6-terra-max-fast",encoding:"legacy-variant"},"gpt-5.6-terra-medium-fast":{targetId:"gpt-5.6-terra-medium-fast",legacyVariantId:"gpt-5.6-terra-medium-fast",encoding:"legacy-variant"},"gpt-5.6-terra-none-fast":{targetId:"gpt-5.6-terra-none-fast",legacyVariantId:"gpt-5.6-terra-none-fast",encoding:"legacy-variant"},"gpt-5.6-terra-xhigh-fast":{targetId:"gpt-5.6-terra-xhigh-fast",legacyVariantId:"gpt-5.6-terra-xhigh-fast",encoding:"legacy-variant"},"kimi-k2.7-code":{targetId:"kimi-k2.7-code",legacyVariantId:"kimi-k2.7-code",encoding:"legacy-variant"},"kimi-k3-high":{targetId:"kimi-k3",level:"high",legacyVariantId:"kimi-k3-high",encoding:"legacy-variant"},"kimi-k3-low":{targetId:"kimi-k3",level:"low",legacyVariantId:"kimi-k3-low",encoding:"legacy-variant"},"kimi-k3-max":{targetId:"kimi-k3",level:"max",legacyVariantId:"kimi-k3-max",encoding:"legacy-variant"},auto:{targetId:"auto",legacyVariantId:"auto",encoding:"legacy-variant"},"claude-fable-5-low-fast":{targetId:"claude-fable-5-low-fast",legacyVariantId:"claude-fable-5-low-fast",encoding:"legacy-variant"},"claude-fable-5-medium-fast":{targetId:"claude-fable-5-medium-fast",legacyVariantId:"claude-fable-5-medium-fast",encoding:"legacy-variant"},"claude-fable-5-max-fast":{targetId:"claude-fable-5-max-fast",legacyVariantId:"claude-fable-5-max-fast",encoding:"legacy-variant"},"claude-sonnet-5-low-fast":{targetId:"claude-sonnet-5-low-fast",legacyVariantId:"claude-sonnet-5-low-fast",encoding:"legacy-variant"},"claude-sonnet-5-medium-fast":{targetId:"claude-sonnet-5-medium-fast",legacyVariantId:"claude-sonnet-5-medium-fast",encoding:"legacy-variant"},"claude-sonnet-5-max-fast":{targetId:"claude-sonnet-5-max-fast",legacyVariantId:"claude-sonnet-5-max-fast",encoding:"legacy-variant"},"claude-sonnet-4-7-low":{targetId:"claude-sonnet-4-7",level:"low",legacyVariantId:"claude-sonnet-4-7-low",encoding:"legacy-variant"},"claude-sonnet-4-7-medium":{targetId:"claude-sonnet-4-7",level:"medium",legacyVariantId:"claude-sonnet-4-7-medium",encoding:"legacy-variant"},"claude-sonnet-4-7-max":{targetId:"claude-sonnet-4-7",level:"max",legacyVariantId:"claude-sonnet-4-7-max",encoding:"legacy-variant"},"claude-sonnet-4-7-low-fast":{targetId:"claude-sonnet-4-7-low-fast",legacyVariantId:"claude-sonnet-4-7-low-fast",encoding:"legacy-variant"},"claude-sonnet-4-7-medium-fast":{targetId:"claude-sonnet-4-7-medium-fast",legacyVariantId:"claude-sonnet-4-7-medium-fast",encoding:"legacy-variant"},"claude-sonnet-4-7-max-fast":{targetId:"claude-sonnet-4-7-max-fast",legacyVariantId:"claude-sonnet-4-7-max-fast",encoding:"legacy-variant"},"claude-sonnet-4-7-thinking-low":{targetId:"claude-sonnet-4-7-thinking",level:"low",legacyVariantId:"claude-sonnet-4-7-thinking-low",encoding:"legacy-variant"},"claude-sonnet-4-7-thinking-medium":{targetId:"claude-sonnet-4-7-thinking",level:"medium",legacyVariantId:"claude-sonnet-4-7-thinking-medium",encoding:"legacy-variant"},"claude-sonnet-4-7-thinking-max":{targetId:"claude-sonnet-4-7-thinking",level:"max",legacyVariantId:"claude-sonnet-4-7-thinking-max",encoding:"legacy-variant"},"claude-mythos-5-low":{targetId:"claude-mythos-5",level:"low",legacyVariantId:"claude-mythos-5-low",encoding:"legacy-variant"},"claude-mythos-5-medium":{targetId:"claude-mythos-5",level:"medium",legacyVariantId:"claude-mythos-5-medium",encoding:"legacy-variant"},"claude-mythos-5-max":{targetId:"claude-mythos-5",level:"max",legacyVariantId:"claude-mythos-5-max",encoding:"legacy-variant"},"claude-mythos-5-low-fast":{targetId:"claude-mythos-5-low-fast",legacyVariantId:"claude-mythos-5-low-fast",encoding:"legacy-variant"},"claude-mythos-5-medium-fast":{targetId:"claude-mythos-5-medium-fast",legacyVariantId:"claude-mythos-5-medium-fast",encoding:"legacy-variant"},"claude-mythos-5-max-fast":{targetId:"claude-mythos-5-max-fast",legacyVariantId:"claude-mythos-5-max-fast",encoding:"legacy-variant"},"claude-mythos-5-thinking-low":{targetId:"claude-mythos-5-thinking",level:"low",legacyVariantId:"claude-mythos-5-thinking-low",encoding:"legacy-variant"},"claude-mythos-5-thinking-medium":{targetId:"claude-mythos-5-thinking",level:"medium",legacyVariantId:"claude-mythos-5-thinking-medium",encoding:"legacy-variant"},"claude-mythos-5-thinking-max":{targetId:"claude-mythos-5-thinking",level:"max",legacyVariantId:"claude-mythos-5-thinking-max",encoding:"legacy-variant"},"gpt-5.4-codex-low":{targetId:"gpt-5.4-codex",level:"low",legacyVariantId:"gpt-5.4-codex-low",encoding:"legacy-variant"},"gpt-5.4-codex-medium":{targetId:"gpt-5.4-codex",level:"medium",legacyVariantId:"gpt-5.4-codex-medium",encoding:"legacy-variant"},"gpt-5.4-codex-max":{targetId:"gpt-5.4-codex",level:"max",legacyVariantId:"gpt-5.4-codex-max",encoding:"legacy-variant"},"gpt-5.4-codex-thinking-low":{targetId:"gpt-5.4-codex",level:"low",legacyVariantId:"gpt-5.4-codex-thinking-low",encoding:"legacy-variant"},"gpt-5.4-codex-thinking-medium":{targetId:"gpt-5.4-codex",level:"medium",legacyVariantId:"gpt-5.4-codex-thinking-medium",encoding:"legacy-variant"},"gpt-5.4-codex-thinking-max":{targetId:"gpt-5.4-codex",level:"max",legacyVariantId:"gpt-5.4-codex-thinking-max",encoding:"legacy-variant"},"gpt-5.4-codex-low-fast":{targetId:"gpt-5.4-codex-low-fast",legacyVariantId:"gpt-5.4-codex-low-fast",encoding:"legacy-variant"},"gpt-5.4-codex-medium-fast":{targetId:"gpt-5.4-codex-medium-fast",legacyVariantId:"gpt-5.4-codex-medium-fast",encoding:"legacy-variant"},"gpt-5.4-codex-max-fast":{targetId:"gpt-5.4-codex-max-fast",legacyVariantId:"gpt-5.4-codex-max-fast",encoding:"legacy-variant"},"gemini-3.7-flash-low-fast":{targetId:"gemini-3.7-flash-low-fast",legacyVariantId:"gemini-3.7-flash-low-fast",encoding:"legacy-variant"},"gemini-3.7-flash-medium-fast":{targetId:"gemini-3.7-flash-medium-fast",legacyVariantId:"gemini-3.7-flash-medium-fast",encoding:"legacy-variant"},"gemini-3.7-flash-max-fast":{targetId:"gemini-3.7-flash-max-fast",legacyVariantId:"gemini-3.7-flash-max-fast",encoding:"legacy-variant"},"gemini-3.7-pro-low":{targetId:"gemini-3.7-pro",level:"low",legacyVariantId:"gemini-3.7-pro-low",encoding:"legacy-variant"},"gemini-3.7-pro-medium":{targetId:"gemini-3.7-pro",level:"medium",legacyVariantId:"gemini-3.7-pro-medium",encoding:"legacy-variant"},"gemini-3.7-pro-max":{targetId:"gemini-3.7-pro",level:"max",legacyVariantId:"gemini-3.7-pro-max",encoding:"legacy-variant"},"gemini-3.7-pro-thinking-low":{targetId:"gemini-3.7-pro",level:"low",legacyVariantId:"gemini-3.7-pro-thinking-low",encoding:"legacy-variant"},"gemini-3.7-pro-thinking-medium":{targetId:"gemini-3.7-pro",level:"medium",legacyVariantId:"gemini-3.7-pro-thinking-medium",encoding:"legacy-variant"},"gemini-3.7-pro-thinking-max":{targetId:"gemini-3.7-pro",level:"max",legacyVariantId:"gemini-3.7-pro-thinking-max",encoding:"legacy-variant"},"gemini-3.7-pro-low-fast":{targetId:"gemini-3.7-pro-low-fast",legacyVariantId:"gemini-3.7-pro-low-fast",encoding:"legacy-variant"},"gemini-3.7-pro-medium-fast":{targetId:"gemini-3.7-pro-medium-fast",legacyVariantId:"gemini-3.7-pro-medium-fast",encoding:"legacy-variant"},"gemini-3.7-pro-max-fast":{targetId:"gemini-3.7-pro-max-fast",legacyVariantId:"gemini-3.7-pro-max-fast",encoding:"legacy-variant"},"gemini-3.6-pro-low":{targetId:"gemini-3.6-pro",level:"low",legacyVariantId:"gemini-3.6-pro-low",encoding:"legacy-variant"},"gemini-3.6-pro-medium":{targetId:"gemini-3.6-pro",level:"medium",legacyVariantId:"gemini-3.6-pro-medium",encoding:"legacy-variant"},"gemini-3.6-pro-max":{targetId:"gemini-3.6-pro",level:"max",legacyVariantId:"gemini-3.6-pro-max",encoding:"legacy-variant"},"gemini-3.6-pro-thinking-low":{targetId:"gemini-3.6-pro",level:"low",legacyVariantId:"gemini-3.6-pro-thinking-low",encoding:"legacy-variant"},"gemini-3.6-pro-thinking-medium":{targetId:"gemini-3.6-pro",level:"medium",legacyVariantId:"gemini-3.6-pro-thinking-medium",encoding:"legacy-variant"},"gemini-3.6-pro-thinking-max":{targetId:"gemini-3.6-pro",level:"max",legacyVariantId:"gemini-3.6-pro-thinking-max",encoding:"legacy-variant"},"gemini-3.6-pro-low-fast":{targetId:"gemini-3.6-pro-low-fast",legacyVariantId:"gemini-3.6-pro-low-fast",encoding:"legacy-variant"},"gemini-3.6-pro-medium-fast":{targetId:"gemini-3.6-pro-medium-fast",legacyVariantId:"gemini-3.6-pro-medium-fast",encoding:"legacy-variant"},"gemini-3.6-pro-max-fast":{targetId:"gemini-3.6-pro-max-fast",legacyVariantId:"gemini-3.6-pro-max-fast",encoding:"legacy-variant"},"gemini-3.5-pro-low":{targetId:"gemini-3.5-pro",level:"low",legacyVariantId:"gemini-3.5-pro-low",encoding:"legacy-variant"},"gemini-3.5-pro-medium":{targetId:"gemini-3.5-pro",level:"medium",legacyVariantId:"gemini-3.5-pro-medium",encoding:"legacy-variant"},"gemini-3.5-pro-max":{targetId:"gemini-3.5-pro",level:"max",legacyVariantId:"gemini-3.5-pro-max",encoding:"legacy-variant"},"gemini-3.5-pro-thinking-low":{targetId:"gemini-3.5-pro",level:"low",legacyVariantId:"gemini-3.5-pro-thinking-low",encoding:"legacy-variant"},"gemini-3.5-pro-thinking-medium":{targetId:"gemini-3.5-pro",level:"medium",legacyVariantId:"gemini-3.5-pro-thinking-medium",encoding:"legacy-variant"},"gemini-3.5-pro-thinking-max":{targetId:"gemini-3.5-pro",level:"max",legacyVariantId:"gemini-3.5-pro-thinking-max",encoding:"legacy-variant"},"gemini-3.5-pro-low-fast":{targetId:"gemini-3.5-pro-low-fast",legacyVariantId:"gemini-3.5-pro-low-fast",encoding:"legacy-variant"},"gemini-3.5-pro-medium-fast":{targetId:"gemini-3.5-pro-medium-fast",legacyVariantId:"gemini-3.5-pro-medium-fast",encoding:"legacy-variant"},"gemini-3.5-pro-max-fast":{targetId:"gemini-3.5-pro-max-fast",legacyVariantId:"gemini-3.5-pro-max-fast",encoding:"legacy-variant"},"composer-2.6-low":{targetId:"composer-2.6",level:"low",legacyVariantId:"composer-2.6-low",encoding:"legacy-variant"},"composer-2.6-medium":{targetId:"composer-2.6",level:"medium",legacyVariantId:"composer-2.6-medium",encoding:"legacy-variant"},"composer-2.6-max":{targetId:"composer-2.6",level:"max",legacyVariantId:"composer-2.6-max",encoding:"legacy-variant"},"composer-2.6-thinking-low":{targetId:"composer-2.6",level:"low",legacyVariantId:"composer-2.6-thinking-low",encoding:"legacy-variant"},"composer-2.6-thinking-medium":{targetId:"composer-2.6",level:"medium",legacyVariantId:"composer-2.6-thinking-medium",encoding:"legacy-variant"},"composer-2.6-thinking-max":{targetId:"composer-2.6",level:"max",legacyVariantId:"composer-2.6-thinking-max",encoding:"legacy-variant"},"composer-2.6-low-fast":{targetId:"composer-2.6-low-fast",legacyVariantId:"composer-2.6-low-fast",encoding:"legacy-variant"},"composer-2.6-medium-fast":{targetId:"composer-2.6-medium-fast",legacyVariantId:"composer-2.6-medium-fast",encoding:"legacy-variant"},"composer-2.6-max-fast":{targetId:"composer-2.6-max-fast",legacyVariantId:"composer-2.6-max-fast",encoding:"legacy-variant"},"composer-2.6-lite-low":{targetId:"composer-2.6-lite",level:"low",legacyVariantId:"composer-2.6-lite-low",encoding:"legacy-variant"},"composer-2.6-lite-medium":{targetId:"composer-2.6-lite",level:"medium",legacyVariantId:"composer-2.6-lite-medium",encoding:"legacy-variant"},"composer-2.6-lite-max":{targetId:"composer-2.6-lite",level:"max",legacyVariantId:"composer-2.6-lite-max",encoding:"legacy-variant"},"composer-2.6-lite-thinking-low":{targetId:"composer-2.6-lite",level:"low",legacyVariantId:"composer-2.6-lite-thinking-low",encoding:"legacy-variant"},"composer-2.6-lite-thinking-medium":{targetId:"composer-2.6-lite",level:"medium",legacyVariantId:"composer-2.6-lite-thinking-medium",encoding:"legacy-variant"},"composer-2.6-lite-thinking-max":{targetId:"composer-2.6-lite",level:"max",legacyVariantId:"composer-2.6-lite-thinking-max",encoding:"legacy-variant"},"composer-2.6-lite-low-fast":{targetId:"composer-2.6-lite-low-fast",legacyVariantId:"composer-2.6-lite-low-fast",encoding:"legacy-variant"},"composer-2.6-lite-medium-fast":{targetId:"composer-2.6-lite-medium-fast",legacyVariantId:"composer-2.6-lite-medium-fast",encoding:"legacy-variant"},"composer-2.6-lite-max-fast":{targetId:"composer-2.6-lite-max-fast",legacyVariantId:"composer-2.6-lite-max-fast",encoding:"legacy-variant"},"deepseek-v4-low":{targetId:"deepseek-v4",level:"low",legacyVariantId:"deepseek-v4-low",encoding:"legacy-variant"},"deepseek-v4-medium":{targetId:"deepseek-v4",level:"medium",legacyVariantId:"deepseek-v4-medium",encoding:"legacy-variant"},"deepseek-v4-max":{targetId:"deepseek-v4",level:"max",legacyVariantId:"deepseek-v4-max",encoding:"legacy-variant"},"deepseek-v4-thinking-low":{targetId:"deepseek-v4",level:"low",legacyVariantId:"deepseek-v4-thinking-low",encoding:"legacy-variant"},"deepseek-v4-thinking-medium":{targetId:"deepseek-v4",level:"medium",legacyVariantId:"deepseek-v4-thinking-medium",encoding:"legacy-variant"},"deepseek-v4-thinking-max":{targetId:"deepseek-v4",level:"max",legacyVariantId:"deepseek-v4-thinking-max",encoding:"legacy-variant"},"deepseek-v4-low-fast":{targetId:"deepseek-v4-low-fast",legacyVariantId:"deepseek-v4-low-fast",encoding:"legacy-variant"},"deepseek-v4-medium-fast":{targetId:"deepseek-v4-medium-fast",legacyVariantId:"deepseek-v4-medium-fast",encoding:"legacy-variant"},"deepseek-v4-max-fast":{targetId:"deepseek-v4-max-fast",legacyVariantId:"deepseek-v4-max-fast",encoding:"legacy-variant"}}};var P="parameters",V="variant-id";function ladder(values,encoding=P){let out={};for(let value of values)out[value==="none"?"off":value]={value,encoding};return out}var CLAUDE_ORDER=["thinking","context","effort"],GPT_ORDER=["context","reasoning","fast"];function claude(window,maxWindow,levels,defaultContext){return{evidence:"available-models",window,maxWindow,parameterOrder:CLAUDE_ORDER,defaultContext,requestContext:window>=1e6?"1m":defaultContext,levels:ladder(levels)}}function gpt(levels,order=GPT_ORDER,window=4e5,maxWindow=4e5){return{evidence:"available-models",window,maxWindow,parameterOrder:order,defaultContext:"272k",requestContext:order.includes("context")&&window>=1e6?"1m":void 0,levels:ladder(levels)}}var CURSOR_MODEL_CAPABILITIES={"claude-fable-5":claude(1e6,1e6,["low","medium","high","xhigh","max"],"300k"),"claude-sonnet-5":claude(1e6,1e6,["low","medium","high","xhigh","max"],"300k"),"claude-opus-4-7":claude(1e6,1e6,["low","medium","high","xhigh","max"],"300k"),"claude-opus-4-8":claude(1e6,1e6,["low","medium","high","xhigh","max"],"300k"),"claude-opus-5":claude(1e6,1e6,["low","medium","high","xhigh","max"],"300k"),"claude-4.6-opus":claude(1e6,1e6,["high","max"],"200k"),"claude-4.6-sonnet":claude(1e6,1e6,["medium"],"200k"),"claude-4.5-opus":{evidence:"available-models",window:2e5,parameterOrder:["thinking"],levels:{high:{value:"high",encoding:V}}},"gpt-5.6-sol":gpt(["none","low","medium","high","xhigh","max"],GPT_ORDER,1e6,1e6),"gpt-5.6-luna":gpt(["none","low","medium","high","xhigh","max"],GPT_ORDER,1e6,1e6),"gpt-5.6-terra":gpt(["none","low","medium","high","xhigh","max"],GPT_ORDER,272e3,272e3),"gpt-5.5":{...gpt(["none","low","medium","high"],GPT_ORDER,1e6,1e6),levels:{...ladder(["none","low","medium","high"]),xhigh:{value:"extra-high",encoding:P}}},"gpt-5.3-codex":{...gpt([],["reasoning","fast"]),maxWindow:void 0,defaultContext:void 0,levels:{...ladder(["low","medium","high"]),xhigh:{value:"extra-high",encoding:P}}},"gpt-5.1":{...gpt([],["reasoning"]),maxWindow:void 0,defaultContext:void 0,levels:ladder(["low","high"])},"gpt-5.2":{...gpt([],["reasoning"]),maxWindow:void 0,defaultContext:void 0,levels:{...ladder(["low","high"]),xhigh:{value:"xhigh",encoding:V}}},"gpt-5.4":{...gpt([],["reasoning"]),maxWindow:void 0,defaultContext:void 0,levels:{...ladder(["low","medium","high"]),xhigh:{value:"xhigh",encoding:V}}},"gpt-5.4-mini":{evidence:"available-models",window:4e5,parameterOrder:[],levels:ladder(["none","low","medium","high","xhigh"],V)},"gpt-5.4-nano":{...gpt([],["reasoning"]),maxWindow:void 0,defaultContext:void 0,levels:ladder(["none","low","medium","high","xhigh"])},"gemini-3.7-flash":{evidence:"cli-live",window:1048576,parameterOrder:["effort"],levels:ladder(["low","medium","high"])},"gemini-3.6-flash":{evidence:"suffix-only",window:1048576,parameterOrder:[],levels:ladder(["minimal","low","medium","high"],V)},"cursor-grok-4.6":{evidence:"available-models",window:5e5,parameterOrder:["effort","fast"],levels:ladder(["low","medium","high","xhigh"])},"cursor-grok-4.5":{evidence:"suffix-only",window:5e5,parameterOrder:[],levels:ladder(["low","medium","high"],V)},"glm-5.2":{evidence:"available-models",window:1e6,parameterOrder:["reasoning"],levels:ladder(["high","max"])},"kimi-k3":{evidence:"available-models",window:1048576,parameterOrder:["reasoning"],levels:ladder(["low","high","max"])},"composer-2.5":{evidence:"available-models",window:2e5,parameterOrder:["fast"],levels:{}},"claude-haiku-4-5":{evidence:"available-models",window:2e5,parameterOrder:["thinking"],levels:{}},"claude-4-sonnet":{evidence:"available-models",window:2e5,parameterOrder:["thinking","context"],defaultContext:"200k",levels:{}},"claude-4.5-sonnet":{evidence:"available-models",window:2e5,parameterOrder:["thinking","context"],defaultContext:"200k",levels:{}},"kimi-k2.7-code":{evidence:"available-models",window:262144,parameterOrder:[],levels:{}},"gemini-3-flash":{evidence:"available-models",window:1e6,parameterOrder:[],levels:{}},"gemini-3.1-pro":{evidence:"available-models",window:1e6,parameterOrder:[],levels:{}},"gemini-3.5-flash":{evidence:"available-models",window:1048576,parameterOrder:[],levels:{}},"gpt-5-mini":{evidence:"available-models",window:4e5,parameterOrder:[],levels:{}}},ALIASES=cursor_variant_aliases_default.aliases,LEVEL_TOKENS=["minimal","low","medium","high","extra-high","xhigh","max","none"];function parseCursorVariantId(originalId){let rest=originalId,fast=!1;rest.endsWith("-fast")&&(fast=!0,rest=rest.slice(0,-5));let level,thinking,alternation=LEVEL_TOKENS.join("|"),patterns=[[new RegExp(`-thinking-(${alternation})$`),!0],[new RegExp(`-(${alternation})-thinking$`),!0]];for(let[pattern,flag]of patterns){let match=rest.match(pattern);if(match)return level=match[1],thinking=flag,rest=rest.slice(0,match.index),{baseId:rest,level,thinking,fast,originalId}}if(rest.endsWith("-thinking"))return{baseId:rest.slice(0,-9),level,thinking:!0,fast,originalId};let levelMatch=rest.match(new RegExp(`-(${alternation})$`));return levelMatch&&(level=levelMatch[1],thinking=!1,rest=rest.slice(0,levelMatch.index)),{baseId:rest,level,thinking,fast,originalId}}function getCursorVariantAlias(originalId){return ALIASES[originalId]}function getCursorBaseIdForVariant(originalId){let alias=ALIASES[originalId];if(alias)return parseCursorVariantId(alias.targetId).baseId}function getCursorCapabilityForBase(baseId){return CURSOR_MODEL_CAPABILITIES[baseId]}var ALL_LEVELS=["off","minimal","low","medium","high","xhigh","max"],FALLBACK_WINDOW=2e5;function isClaude(baseId){return baseId.startsWith("claude-")}function cleanName(members,baseId,thinkingMode){let levelWords=/(Minimal|Low|Medium|High|Extra High|XHigh|Max|None)/g,name=(members.find(member=>member.level==="high")??members.find(member=>member.level==="medium")??members.find(member=>member.level==="low")??members[0]).raw.name;return name=name.replace(/\s*\(NO ZDR\)\s*/g," ").trim(),name=name.replace(new RegExp(`\\s+${levelWords.source}\\b`,"g"),""),name=name.replace(/\s+Fast\b/g,""),thinkingMode!==!0&&(name=name.replace(/\s+Thinking\b/g,"")),name=name.replace(/\u0001/g,"(NO ZDR)").replace(/\s+/g," ").trim(),name.length===0&&(name=baseId),name}function buildLevelMap(members,capability){let observed=new Set(members.map(member=>member.level).filter(level=>level!==void 0)),map={};for(let level of ALL_LEVELS){if(level==="off"){let offSpec=capability?.levels.off;map.off=offSpec!==void 0&&observed.has("none")?offSpec.value:null;continue}let spec=capability?.levels[level];map[level]=spec!==void 0&&(observed.has(level)||observed.has(spec.value))?spec.value:null}return map}function pickRepresentative(members){let withLevels=members.filter(member=>member.level!==void 0&&member.level!=="none"),pool=withLevels.length>0?withLevels:members,order=["medium","low","minimal","high","xhigh","extra-high","max","none"];return[...pool].sort((a,b)=>{let ai=order.indexOf(a.level??"none"),bi=order.indexOf(b.level??"none");return ai!==bi?ai-bi:a.alias.legacyVariantId.localeCompare(b.alias.legacyVariantId)})[0].alias.legacyVariantId}function normalizeCursorCatalog(rawEntries){let groups=new Map,order=[];for(let raw of rawEntries){let alias=getCursorVariantAlias(raw.id);if(!alias){let parsed2=parseCursorVariantId(raw.id),key2=`unknown${parsed2.baseId}${raw.id}`;groups.has(key2)||order.push(key2);let member={raw,alias:{targetId:raw.id,legacyVariantId:raw.id,encoding:"legacy-variant"},level:parsed2.level,thinking:parsed2.thinking,fast:parsed2.fast};groups.set(key2,[member]);continue}let parsed=parseCursorVariantId(raw.id),key=`${alias.targetId}${parsed.fast}`;groups.has(key)||(order.push(key),groups.set(key,[])),groups.get(key).push({raw,alias,level:parsed.level,thinking:parsed.thinking,fast:parsed.fast})}let out=[];for(let key of order){let members=groups.get(key),first=members[0],baseId=parseCursorVariantId(first.alias.targetId).baseId,capability=CURSOR_MODEL_CAPABILITIES[baseId],isGrouped=members.length>1||first.alias.targetId!==first.raw.id,efforts=members.filter(member=>member.level!==void 0&&member.level!=="none");if(isGrouped&&efforts.length>0&&!first.fast){let thinkingMode=isClaude(baseId)?first.thinking===!0:void 0;out.push({id:first.alias.targetId,name:cleanName(members,baseId,thinkingMode),reasoning:!0,thinkingLevelMap:buildLevelMap(members,capability),window:capability?.window??FALLBACK_WINDOW,...capability?.maxWindow!==void 0?{maxWindow:capability.maxWindow}:{},input:[...new Set(members.flatMap(member=>member.raw.input))],cursorMaxMode:members.some(member=>member.raw.cursorMaxMode),capabilityId:baseId,...thinkingMode!==void 0?{thinkingMode}:{},representativeVariantId:pickRepresentative(members),legacyAliases:members.map(member=>member.alias.legacyVariantId).sort()});continue}for(let member of members){let memberBase=parseCursorVariantId(member.raw.id).baseId,memberCapability=CURSOR_MODEL_CAPABILITIES[memberBase];out.push({id:member.raw.id,name:member.raw.name,reasoning:!1,window:memberCapability?.window??FALLBACK_WINDOW,...memberCapability?.maxWindow!==void 0?{maxWindow:memberCapability.maxWindow}:{},input:[...member.raw.input],cursorMaxMode:member.raw.cursorMaxMode,legacyAliases:[member.alias.legacyVariantId]})}}return out}function identityCompat(model){return model.compat?.cursorReasoning}function suffixAliasId(compat,level,spec){let suffixes=level==="off"?["none"]:spec.value===level?[spec.value]:[spec.value,level];for(let suffix of suffixes){let candidates=compat.thinkingMode===!0?[`${compat.capabilityId}-thinking-${suffix}`,`${compat.capabilityId}-${suffix}-thinking`]:[`${compat.capabilityId}-${suffix}`];for(let candidate of candidates){let alias=getCursorVariantAlias(candidate);if(alias)return alias.legacyVariantId}}}function buildParameters(capabilityId,value,thinkingMode){let capability=CURSOR_MODEL_CAPABILITIES[capabilityId];if(!capability)return[];let out=[];for(let id of capability.parameterOrder)switch(id){case"thinking":out.push({id,value:thinkingMode===!0?"true":"false"});break;case"context":{let context=capability.requestContext??capability.defaultContext;context!==void 0&&out.push({id,value:context});break}case"effort":case"reasoning":out.push({id,value});break;case"fast":out.push({id,value:"false"});break}return out}function resolveCursorSelectionDescriptor(model,selection){let compat=identityCompat(model),fallback={modelId:model.upstreamModelId??model.id,parameters:[]};if(!compat)return fallback;if(selection===void 0)return{modelId:compat.representativeVariantId,parameters:[]};if(selection.source==="legacy-variant")return selection.legacyVariantId===void 0||getCursorVariantAlias(selection.legacyVariantId)===void 0?{modelId:compat.representativeVariantId,parameters:[]}:{modelId:selection.legacyVariantId,parameters:[]};let capability=CURSOR_MODEL_CAPABILITIES[compat.capabilityId],spec=capability?.levels[selection.level];if(!capability||!spec)return{modelId:compat.representativeVariantId,parameters:[]};let suffixId=suffixAliasId(compat,selection.level,spec);return suffixId!==void 0?{modelId:suffixId,parameters:[]}:spec.encoding==="variant-id"?{modelId:compat.representativeVariantId,parameters:[]}:{modelId:compat.capabilityId,parameters:buildParameters(compat.capabilityId,spec.value,compat.thinkingMode)}}function renderCursorCliModelString(model,selection){let resolved=resolveCursorSelectionDescriptor(model,selection);if(resolved.parameters.length===0)return resolved.modelId;let args=resolved.parameters.map(parameter=>`${parameter.id}=${parameter.value}`).join(",");return`${resolved.modelId}[${args}]`}var __rewriteRelativeImportExtension=function(path,preserveJsx){return typeof path=="string"&&/^\.\.?\//.test(path)?path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(m,tsx,d,ext,cm){return tsx?preserveJsx?".jsx":".js":d&&(!ext||!cm)?m:d+ext+"."+cm.toLowerCase()+"js"}):path},_existsSync=null,_homedir=null,_join=null,dynamicImport=specifier=>import(__rewriteRelativeImportExtension(specifier)),NODE_FS_SPECIFIER="node:fs",NODE_OS_SPECIFIER="node:os",NODE_PATH_SPECIFIER="node:path";typeof process<"u"&&(process.versions?.node||process.versions?.bun)&&(dynamicImport(NODE_FS_SPECIFIER).then(m=>{_existsSync=m.existsSync}),dynamicImport(NODE_OS_SPECIFIER).then(m=>{_homedir=m.homedir}),dynamicImport(NODE_PATH_SPECIFIER).then(m=>{_join=m.join}));var ANTHROPIC_AUTH_TOKEN_ENV="ANTHROPIC_AUTH_TOKEN",ANTHROPIC_OAUTH_TOKEN_ENV="ANTHROPIC_OAUTH_TOKEN",ANTHROPIC_API_KEY_ENV="ANTHROPIC_API_KEY",cachedVertexAdcCredentialsExists=null;function hasVertexAdcCredentials(env){let explicitCredentialsPath=env?.GOOGLE_APPLICATION_CREDENTIALS;if(explicitCredentialsPath)return _existsSync?_existsSync(explicitCredentialsPath):!1;if(cachedVertexAdcCredentialsExists===null){if(!_existsSync||!_homedir||!_join)return typeof process<"u"&&(process.versions?.node||process.versions?.bun)||(cachedVertexAdcCredentialsExists=!1),!1;let gacPath=getProviderEnvValue("GOOGLE_APPLICATION_CREDENTIALS",env);gacPath?cachedVertexAdcCredentialsExists=_existsSync(gacPath):cachedVertexAdcCredentialsExists=_existsSync(_join(_homedir(),".config","gcloud","application_default_credentials.json"))}return cachedVertexAdcCredentialsExists}function getApiKeyEnvVars(provider){if(provider==="github-copilot")return["COPILOT_GITHUB_TOKEN"];if(provider==="anthropic")return[ANTHROPIC_AUTH_TOKEN_ENV,ANTHROPIC_OAUTH_TOKEN_ENV,ANTHROPIC_API_KEY_ENV];let envVar={"alibaba-token-plan":"ALIBABA_TOKEN_PLAN_API_KEY","ant-ling":"ANT_LING_API_KEY","qwen-token-plan":"QWEN_TOKEN_PLAN_API_KEY","qwen-token-plan-cn":"QWEN_TOKEN_PLAN_CN_API_KEY","qwen-token-plan-individual":"QWEN_TOKEN_PLAN_API_KEY",openai:"OPENAI_API_KEY",ollama:"OLLAMA_API_KEY","azure-openai-responses":"AZURE_OPENAI_API_KEY",nvidia:"NVIDIA_API_KEY",deepseek:"DEEPSEEK_API_KEY",google:"GEMINI_API_KEY","google-vertex":"GOOGLE_CLOUD_API_KEY",groq:"GROQ_API_KEY",cerebras:"CEREBRAS_API_KEY",venice:"VENICE_API_KEY",xai:"XAI_API_KEY",radius:"RADIUS_API_KEY",openrouter:"OPENROUTER_API_KEY","vercel-ai-gateway":"AI_GATEWAY_API_KEY",opengateway:"OPENGATEWAY_API_KEY",zai:"ZAI_API_KEY","zai-coding-cn":"ZAI_CODING_CN_API_KEY",mistral:"MISTRAL_API_KEY",minimax:"MINIMAX_API_KEY","minimax-cn":"MINIMAX_CN_API_KEY",moonshotai:"MOONSHOT_API_KEY","moonshotai-cn":"MOONSHOT_API_KEY",huggingface:"HF_TOKEN",fireworks:"FIREWORKS_API_KEY",together:"TOGETHER_API_KEY",baseten:"BASETEN_API_KEY",bai:"BAI_API_KEY",opencode:"OPENCODE_API_KEY","opencode-go":"OPENCODE_API_KEY","kimi-coding":"KIMI_API_KEY","cloudflare-workers-ai":"CLOUDFLARE_API_KEY","cloudflare-ai-gateway":"CLOUDFLARE_API_KEY",xiaomi:"XIAOMI_API_KEY","xiaomi-token-plan-cn":"XIAOMI_TOKEN_PLAN_CN_API_KEY","xiaomi-token-plan-ams":"XIAOMI_TOKEN_PLAN_AMS_API_KEY","xiaomi-token-plan-sgp":"XIAOMI_TOKEN_PLAN_SGP_API_KEY"}[provider];return envVar?[envVar]:void 0}function findEnvKeys(provider,env){let envVars=getApiKeyEnvVars(provider);if(!envVars)return;let found=envVars.filter(envVar=>!!getProviderEnvValue(envVar,env));return found.length>0?found:void 0}function getEnvApiKey(provider,env){let envKeys=findEnvKeys(provider,env);if(envKeys?.[0]){let apiKeyEnv=provider==="anthropic"?envKeys.find(key=>key!==ANTHROPIC_AUTH_TOKEN_ENV):envKeys[0];if(apiKeyEnv)return getProviderEnvValue(apiKeyEnv,env)}if(provider==="google-vertex"){let hasCredentials=hasVertexAdcCredentials(env),hasProject=!!(getProviderEnvValue("GOOGLE_CLOUD_PROJECT",env)||getProviderEnvValue("GCLOUD_PROJECT",env)),hasLocation=!!getProviderEnvValue("GOOGLE_CLOUD_LOCATION",env);if(hasCredentials&&hasProject&&hasLocation)return"<authenticated>"}if(provider==="amazon-bedrock"&&(getProviderEnvValue("AWS_PROFILE",env)||getProviderEnvValue("AWS_ACCESS_KEY_ID",env)&&getProviderEnvValue("AWS_SECRET_ACCESS_KEY",env)||getProviderEnvValue("AWS_BEARER_TOKEN_BEDROCK",env)||getProviderEnvValue("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI",env)||getProviderEnvValue("AWS_CONTAINER_CREDENTIALS_FULL_URI",env)||getProviderEnvValue("AWS_WEB_IDENTITY_TOKEN_FILE",env)))return"<authenticated>"}var ImagesModelsImpl=class{constructor(options){this.providers=new Map,this.credentials=options?.credentials??new InMemoryCredentialStore,this.authContext=options?.authContext??defaultProviderAuthContext()}setProvider(provider){this.providers.set(provider.id,provider)}deleteProvider(id){this.providers.delete(id)}clearProviders(){this.providers.clear()}getProviders(){return Array.from(this.providers.values())}getProvider(id){return this.providers.get(id)}getModels(provider){if(provider!==void 0){let entry=this.providers.get(provider);if(!entry)return[];try{return entry.getModels()}catch{return[]}}let models=[];for(let entry of this.providers.values())try{models.push(...entry.getModels())}catch{}return models}getModel(provider,id){return this.getModels(provider).find(model=>model.id===id)}async refresh(provider){if(provider!==void 0){let entry=this.providers.get(provider);if(!entry?.refreshModels)return;try{await entry.refreshModels()}catch(error){throw error instanceof ModelsError?error:new ModelsError("model_source",`Model refresh failed for ${provider}`,{cause:error})}return}await Promise.allSettled(Array.from(this.providers.values(),async entry=>entry.refreshModels?.()))}async getAuth(providerOrModel,overrides){let providerId=typeof providerOrModel=="string"?providerOrModel:providerOrModel.provider,provider=this.providers.get(providerId);if(provider)return resolveProviderAuth(provider,this.credentials,this.authContext,overrides)}async generateImages(model,context,options){try{let provider=this.providers.get(model.provider);if(!provider)throw new ModelsError("provider",`Unknown provider: ${model.provider}`);let resolution=await this.getAuth(model,{apiKey:options?.apiKey,env:options?.env,signal:options?.signal}),auth=resolution?.auth;if(!auth)return provider.generateImages(model,context,options);let requestModel=auth.baseUrl?{...model,baseUrl:auth.baseUrl}:model,apiKey=options?.apiKey??auth.apiKey,headers=auth.headers||options?.headers?{...auth.headers,...options?.headers}:void 0,env=resolution.env||options?.env?{...resolution.env??{},...options?.env??{}}:void 0;return await provider.generateImages(requestModel,context,{...options,apiKey,headers,env})}catch(error){return{api:model.api,provider:model.provider,model:model.id,output:[],stopReason:"error",errorMessage:error instanceof Error?error.message:String(error),timestamp:Date.now()}}}};function createImagesModels(options){return new ImagesModelsImpl(options)}function createImagesProvider(input){let models=input.models,inflightRefresh,refreshModels=input.refreshModels;return{id:input.id,name:input.name??input.id,auth:input.auth,getModels:()=>models,refreshModels:refreshModels?()=>(inflightRefresh??=(async()=>{try{models=await refreshModels()}finally{inflightRefresh=void 0}})(),inflightRefresh):void 0,generateImages:(model,context,options)=>input.api.generateImages(model,context,options)}}function emit(segments,text,scan,recoveryBoundary=!1){if(text.length===0)return;let previous=segments.at(-1);previous?.scan===scan&&!previous.recoveryBoundary&&!recoveryBoundary?segments[segments.length-1]={text:previous.text+text,scan}:segments.push(recoveryBoundary?{text,scan,recoveryBoundary:!0}:{text,scan})}function isLineBreak(character){return character==="\r"||character===`
|
|
149
|
+
`)}function commonPrefixLength(a,b){let length=Math.min(a.length,b.length),index=0;for(;index<length&&a[index]===b[index];)index++;return index}function withUsageEstimate(message,context,options,promptCache){let promptText=serializeContext(context),promptTokens=estimateTokens(promptText),outputTokens=estimateTokens(assistantContentToText(message.content)),input=promptTokens,cacheRead=0,cacheWrite=0,sessionId=options?.sessionId;if(sessionId&&options?.cacheRetention!=="none"){let previousPrompt=promptCache.get(sessionId);if(previousPrompt){let cachedChars=commonPrefixLength(previousPrompt,promptText);cacheRead=estimateTokens(previousPrompt.slice(0,cachedChars)),cacheWrite=estimateTokens(promptText.slice(cachedChars)),input=Math.max(0,promptTokens-cacheRead)}else cacheWrite=promptTokens;promptCache.set(sessionId,promptText)}return{...message,usage:{input,output:outputTokens,cacheRead,cacheWrite,totalTokens:input+outputTokens+cacheRead+cacheWrite,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}}}}function splitStringByTokenSize(text,minTokenSize,maxTokenSize){let chunks=[],index=0;for(;index<text.length;){let tokenSize=minTokenSize+Math.floor(Math.random()*(maxTokenSize-minTokenSize+1)),charSize=Math.max(1,tokenSize*4);chunks.push(text.slice(index,index+charSize)),index+=charSize}return chunks.length>0?chunks:[""]}function cloneMessage(message,api,provider,modelId){let cloned=structuredClone(message);return{...cloned,api,provider,model:modelId,timestamp:cloned.timestamp??Date.now(),usage:cloned.usage??DEFAULT_USAGE}}function createDeferredMessage(model,handle){return{role:"assistant",content:[],api:model.api,provider:model.provider,model:model.id,usage:DEFAULT_USAGE,stopReason:"deferred",deferred:handle,timestamp:Date.now()}}function createErrorMessage(error,api,provider,modelId){return{role:"assistant",content:[],api,provider,model:modelId,usage:DEFAULT_USAGE,stopReason:"error",errorMessage:error instanceof Error?error.message:String(error),timestamp:Date.now()}}function createAbortedMessage(partial){return{...partial,stopReason:"aborted",errorMessage:"Request was aborted",timestamp:Date.now()}}function scheduleChunk(chunk,tokensPerSecond,schedulerHook){if(schedulerHook)return Promise.resolve(schedulerHook());if(!tokensPerSecond||tokensPerSecond<=0)return new Promise(resolve=>queueMicrotask(resolve));let delayMs=estimateTokens(chunk)/tokensPerSecond*1e3;return new Promise(resolve=>setTimeout(resolve,delayMs))}async function streamWithDeltas(stream,message,minTokenSize,maxTokenSize,tokensPerSecond,schedulerHook,signal){let partial={...message,content:[],stopReason:"pending"};if(signal?.aborted){let aborted=createAbortedMessage(partial);stream.push({type:"error",reason:"aborted",error:aborted}),stream.end(aborted);return}stream.push({type:"start",partial:{...partial}});for(let index=0;index<message.content.length;index++){if(signal?.aborted){let aborted=createAbortedMessage(partial);stream.push({type:"error",reason:"aborted",error:aborted}),stream.end(aborted);return}let block=message.content[index];if(block.type==="thinking"){partial.content=[...partial.content,{type:"thinking",thinking:""}],stream.push({type:"thinking_start",contentIndex:index,partial:{...partial}});for(let chunk of splitStringByTokenSize(block.thinking,minTokenSize,maxTokenSize)){if(await scheduleChunk(chunk,tokensPerSecond,schedulerHook),signal?.aborted){let aborted=createAbortedMessage(partial);stream.push({type:"error",reason:"aborted",error:aborted}),stream.end(aborted);return}partial.content[index].thinking+=chunk,stream.push({type:"thinking_delta",contentIndex:index,delta:chunk,partial:{...partial}})}stream.push({type:"thinking_end",contentIndex:index,content:block.thinking,partial:{...partial}});continue}if(block.type==="text"){partial.content=[...partial.content,{type:"text",text:""}],stream.push({type:"text_start",contentIndex:index,partial:{...partial}});for(let chunk of splitStringByTokenSize(block.text,minTokenSize,maxTokenSize)){if(await scheduleChunk(chunk,tokensPerSecond,schedulerHook),signal?.aborted){let aborted=createAbortedMessage(partial);stream.push({type:"error",reason:"aborted",error:aborted}),stream.end(aborted);return}partial.content[index].text+=chunk,stream.push({type:"text_delta",contentIndex:index,delta:chunk,partial:{...partial}})}stream.push({type:"text_end",contentIndex:index,content:block.text,partial:{...partial}});continue}if(block.type!=="providerNative"){partial.content=[...partial.content,{type:"toolCall",id:block.id,name:block.name,arguments:{}}],stream.push({type:"toolcall_start",contentIndex:index,partial:{...partial}});for(let chunk of splitStringByTokenSize(JSON.stringify(block.arguments),minTokenSize,maxTokenSize)){if(await scheduleChunk(chunk,tokensPerSecond,schedulerHook),signal?.aborted){let aborted=createAbortedMessage(partial);stream.push({type:"error",reason:"aborted",error:aborted}),stream.end(aborted);return}stream.push({type:"toolcall_delta",contentIndex:index,delta:chunk,partial:{...partial}})}partial.content[index].arguments=block.arguments,stream.push({type:"toolcall_end",contentIndex:index,toolCall:block,partial:{...partial}})}}if(message.stopReason==="pending")throw new Error("Faux response ended without a stop reason");if(message.stopReason==="error"||message.stopReason==="aborted"){stream.push({type:"error",reason:message.stopReason,error:message}),stream.end(message);return}stream.push({type:"done",reason:message.stopReason,message}),stream.end(message)}function createFauxCore(options){let api=options.api??randomId(DEFAULT_API),provider=options.provider??DEFAULT_PROVIDER,minTokenSize=Math.max(1,Math.min(options.tokenSize?.min??DEFAULT_MIN_TOKEN_SIZE,options.tokenSize?.max??DEFAULT_MAX_TOKEN_SIZE)),maxTokenSize=Math.max(minTokenSize,options.tokenSize?.max??DEFAULT_MAX_TOKEN_SIZE),pendingResponses=[],tokensPerSecond=options.tokensPerSecond,schedulerHook=options.schedulerHook,state={callCount:0,deferredFetchCount:0,cancelledDeferred:[]},promptCache=new Map,callLog=[],deferredResponses=new Map,models=(options.models?.length?options.models:[{id:DEFAULT_MODEL_ID,name:DEFAULT_MODEL_NAME,reasoning:!1,input:["text","image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:128e3,maxTokens:16384}]).map(definition=>({id:definition.id,name:definition.name??definition.id,api,provider,baseUrl:DEFAULT_BASE_URL,reasoning:definition.reasoning??!1,input:definition.input??["text","image"],cost:definition.cost??{input:0,output:0,cacheRead:0,cacheWrite:0},contextWindow:definition.contextWindow??128e3,maxTokens:definition.maxTokens??16384})),resolveResponse=async(step,context,streamOptions,requestModel)=>{let resolved=typeof step=="function"?await step(context,streamOptions,state,requestModel):step;return withUsageEstimate(cloneMessage(resolved,api,provider,requestModel.id),context,streamOptions,promptCache)},stream=(requestModel,context,streamOptions)=>{let outer=createAssistantMessageEventStream(),step=pendingResponses.shift();return state.callCount++,callLog.push({context:cloneContextForLog(context),options:cloneStreamOptionsForLog(streamOptions),timestamp:Date.now(),modelId:requestModel.id}),queueMicrotask(async()=>{try{if(await streamOptions?.onResponse?.({status:200,headers:{}},requestModel),!step){let message2=createErrorMessage(new Error("No more faux responses queued"),api,provider,requestModel.id);message2=withUsageEstimate(message2,context,streamOptions,promptCache),outer.push({type:"error",reason:"error",error:message2}),outer.end(message2);return}if(streamOptions?.deferred){let handle={provider:requestModel.provider,modelId:requestModel.id,api:requestModel.api,id:randomId("deferred"),...options.deferred?.pollAfterMs!==void 0?{pollAfterMs:options.deferred.pollAfterMs}:{}};deferredResponses.set(handle.id,{handle,step,context,options:streamOptions,model:requestModel,pendingFetches:Math.max(0,Math.floor(options.deferred?.pendingFetches??0)),cancelled:!1}),await streamWithDeltas(outer,createDeferredMessage(requestModel,handle),minTokenSize,maxTokenSize,tokensPerSecond,schedulerHook,streamOptions.signal);return}let message=await resolveResponse(step,context,streamOptions,requestModel);await streamWithDeltas(outer,message,minTokenSize,maxTokenSize,tokensPerSecond,schedulerHook,streamOptions?.signal)}catch(error){let message=createErrorMessage(error,api,provider,requestModel.id);outer.push({type:"error",reason:"error",error:message}),outer.end(message)}}),outer},streamSimple=(streamModel,context,streamOptions)=>stream(streamModel,context,streamOptions),fetchDeferred=(requestModel,handle,fetchOptions)=>{let outer=createAssistantMessageEventStream();return state.deferredFetchCount++,queueMicrotask(async()=>{try{await fetchOptions?.onResponse?.({status:200,headers:{}},requestModel);let entry=deferredResponses.get(handle.id);if(!entry||entry.handle.provider!==handle.provider||entry.handle.modelId!==handle.modelId||entry.handle.api!==handle.api)throw new Error(`Unknown faux deferred response: ${handle.id}`);if(entry.cancelled)throw new Error(`Faux deferred response was cancelled: ${handle.id}`);if(entry.pendingFetches>0){entry.pendingFetches--,await streamWithDeltas(outer,createDeferredMessage(requestModel,entry.handle),minTokenSize,maxTokenSize,tokensPerSecond,schedulerHook,fetchOptions?.signal);return}if(!entry.final){let{deferred:_deferred,signal:_submissionSignal,onResponse:_submissionOnResponse,...submissionOptions}=entry.options??{};try{entry.final=await resolveResponse(entry.step,entry.context,submissionOptions,entry.model)}catch(error){entry.final=createErrorMessage(error,api,provider,entry.model.id)}}await streamWithDeltas(outer,entry.final,minTokenSize,maxTokenSize,tokensPerSecond,schedulerHook,fetchOptions?.signal)}catch(error){let message=createErrorMessage(error,api,provider,requestModel.id);outer.push({type:"error",reason:"error",error:message}),outer.end(message)}}),outer},cancelDeferred=async(requestModel,handle,cancelOptions)=>{state.cancelledDeferred.push(structuredClone(handle));let entry=deferredResponses.get(handle.id);entry&&(entry.cancelled=!0),await cancelOptions?.onResponse?.({status:200,headers:{}},requestModel)};function getModel(requestedModelId){return requestedModelId?models.find(candidate=>candidate.id===requestedModelId):models[0]}return{api,provider,models,stream,streamSimple,fetchDeferred,cancelDeferred,getModel,state,setResponses(responses){pendingResponses=[...responses]},appendResponses(responses){pendingResponses.push(...responses)},getPendingResponseCount(){return pendingResponses.length},getCallLog(){return callLog.map(entry=>({context:cloneContextForLog(entry.context),options:cloneStreamOptionsForLog(entry.options),timestamp:entry.timestamp,modelId:entry.modelId}))}}}var registeredFauxProviders=new Map;function getRegisteredFauxProvider(api){return registeredFauxProviders.get(api)}function fauxOverflowError(provider,message){return fauxAssistantMessage([],{stopReason:"error",errorMessage:`${provider}: ${message}`})}function fauxProvider(options={}){let core=createFauxCore(options);return{provider:createProvider({id:core.provider,auth:{apiKey:{name:"Faux",resolve:async()=>({auth:{}})}},models:core.models,api:{stream:core.stream,streamSimple:core.streamSimple,fetchDeferred:core.fetchDeferred,cancelDeferred:core.cancelDeferred}}),api:core.api,models:core.models,getModel:core.getModel,state:core.state,setResponses:core.setResponses,appendResponses:core.appendResponses,getPendingResponseCount:core.getPendingResponseCount,getCallLog:core.getCallLog}}var apiProviderRegistry=new Map,builtinApiProviderRegistry=new Map,getProviderScope=()=>{},providerScopeStrictMode=!1;function installProviderScopeAccessor(accessor){getProviderScope=accessor}function getActiveProviderScope(){let scope=getProviderScope();if(scope?.state==="closed")throw new Error("Provider scope is closed");if(!scope&&providerScopeStrictMode)throw new Error("Provider scope is required in strict mode");return scope}function wrapStream(api,stream){return(model,context,options)=>{if(model.api!==api)throw new Error(`Mismatched api: ${model.api} expected ${api}`);return stream(model,context,options)}}function wrapStreamSimple(api,streamSimple){return(model,context,options)=>{if(model.api!==api)throw new Error(`Mismatched api: ${model.api} expected ${api}`);return streamSimple(model,context,options)}}function createRegisteredProvider(provider,sourceId){return{provider:{api:provider.api,stream:wrapStream(provider.api,provider.stream),streamSimple:wrapStreamSimple(provider.api,provider.streamSimple)},sourceId}}function registerApiProvider(provider,sourceId){let scope=getActiveProviderScope();(scope?scope.overlay:apiProviderRegistry).set(provider.api,createRegisteredProvider(provider,sourceId))}function registerBuiltinApiProvider(provider){let registered=builtinApiProviderRegistry.get(provider.api)??createRegisteredProvider(provider);builtinApiProviderRegistry.set(provider.api,registered),apiProviderRegistry.has(provider.api)||apiProviderRegistry.set(provider.api,registered)}function getApiProvider(api){let scope=getActiveProviderScope();if(scope)return scope.overlay.get(api)?.provider??builtinApiProviderRegistry.get(api)?.provider;let faux=getRegisteredFauxProvider(api);return faux?{api:faux.api,stream:wrapStream(faux.api,faux.stream),streamSimple:wrapStreamSimple(faux.api,faux.streamSimple)}:apiProviderRegistry.get(api)?.provider}function getApiProviders(){let scope=getActiveProviderScope();if(scope){let providers=new Map(builtinApiProviderRegistry);for(let[api,entry]of scope.overlay)providers.set(api,entry);return Array.from(providers.values(),entry=>entry.provider)}return Array.from(apiProviderRegistry.values(),entry=>entry.provider)}function unregisterApiProviders(sourceId){let scope=getActiveProviderScope(),registry=scope?scope.overlay:apiProviderRegistry;for(let[api,entry]of registry.entries())entry.sourceId===sourceId&®istry.delete(api)}function clearApiProviders(){let scope=getActiveProviderScope();(scope?scope.overlay:apiProviderRegistry).clear()}function envApiKeyAuth(name,envVars){return{name,login:async interaction=>{interaction.signal.throwIfAborted();let key=await interaction.prompt({type:"secret",message:`Enter ${name}`});return interaction.signal.throwIfAborted(),{type:"api_key",key}},resolve:async({ctx,credential,signal})=>{if(signal.throwIfAborted(),credential?.key)return{auth:{apiKey:credential.key},env:credential.env,source:"stored credential"};for(let envVar of envVars){let value=await ctx.env(envVar);if(signal.throwIfAborted(),value)return{auth:{apiKey:value},source:envVar}}}}}function lazyOAuth(input){let promise,loaded=()=>(promise??=input.load(),promise);return{name:input.name,isSubscription:input.isSubscription,loginLabel:input.loginLabel,login:async interaction=>(await loaded()).login(interaction),refresh:async(credential,signal)=>(await loaded()).refresh(credential,signal),toAuth:async credential=>(await loaded()).toAuth(credential)}}var cursor_variant_aliases_default={$schema:"cursor-variant-aliases/v1",source:"union of GetUsableModels live capture (204 ids) and cursor-agent CLI listing capture (203 ids), 2026-08-18",aliases:{"claude-4-sonnet":{targetId:"claude-4-sonnet",legacyVariantId:"claude-4-sonnet",encoding:"legacy-variant"},"claude-4-sonnet-thinking":{targetId:"claude-4-sonnet-thinking",legacyVariantId:"claude-4-sonnet-thinking",encoding:"legacy-variant"},"claude-4.5-opus-high":{targetId:"claude-4.5-opus",level:"high",legacyVariantId:"claude-4.5-opus-high",encoding:"legacy-variant"},"claude-4.5-opus-high-thinking":{targetId:"claude-4.5-opus-thinking",level:"high",legacyVariantId:"claude-4.5-opus-high-thinking",encoding:"legacy-variant"},"claude-4.5-sonnet":{targetId:"claude-4.5-sonnet",legacyVariantId:"claude-4.5-sonnet",encoding:"legacy-variant"},"claude-4.5-sonnet-thinking":{targetId:"claude-4.5-sonnet-thinking",legacyVariantId:"claude-4.5-sonnet-thinking",encoding:"legacy-variant"},"claude-4.6-opus-high":{targetId:"claude-4.6-opus",level:"high",legacyVariantId:"claude-4.6-opus-high",encoding:"legacy-variant"},"claude-4.6-opus-max":{targetId:"claude-4.6-opus",level:"max",legacyVariantId:"claude-4.6-opus-max",encoding:"legacy-variant"},"claude-4.6-opus-high-thinking":{targetId:"claude-4.6-opus-thinking",level:"high",legacyVariantId:"claude-4.6-opus-high-thinking",encoding:"legacy-variant"},"claude-4.6-opus-max-thinking":{targetId:"claude-4.6-opus-thinking",level:"max",legacyVariantId:"claude-4.6-opus-max-thinking",encoding:"legacy-variant"},"claude-4.6-sonnet-medium":{targetId:"claude-4.6-sonnet",level:"medium",legacyVariantId:"claude-4.6-sonnet-medium",encoding:"legacy-variant"},"claude-4.6-sonnet-medium-thinking":{targetId:"claude-4.6-sonnet-thinking",level:"medium",legacyVariantId:"claude-4.6-sonnet-medium-thinking",encoding:"legacy-variant"},"claude-fable-5-high":{targetId:"claude-fable-5",level:"high",legacyVariantId:"claude-fable-5-high",encoding:"legacy-variant"},"claude-fable-5-low":{targetId:"claude-fable-5",level:"low",legacyVariantId:"claude-fable-5-low",encoding:"legacy-variant"},"claude-fable-5-max":{targetId:"claude-fable-5",level:"max",legacyVariantId:"claude-fable-5-max",encoding:"legacy-variant"},"claude-fable-5-medium":{targetId:"claude-fable-5",level:"medium",legacyVariantId:"claude-fable-5-medium",encoding:"legacy-variant"},"claude-fable-5-xhigh":{targetId:"claude-fable-5",level:"xhigh",legacyVariantId:"claude-fable-5-xhigh",encoding:"legacy-variant"},"claude-fable-5-thinking-high":{targetId:"claude-fable-5-thinking",level:"high",legacyVariantId:"claude-fable-5-thinking-high",encoding:"legacy-variant"},"claude-fable-5-thinking-low":{targetId:"claude-fable-5-thinking",level:"low",legacyVariantId:"claude-fable-5-thinking-low",encoding:"legacy-variant"},"claude-fable-5-thinking-max":{targetId:"claude-fable-5-thinking",level:"max",legacyVariantId:"claude-fable-5-thinking-max",encoding:"legacy-variant"},"claude-fable-5-thinking-medium":{targetId:"claude-fable-5-thinking",level:"medium",legacyVariantId:"claude-fable-5-thinking-medium",encoding:"legacy-variant"},"claude-fable-5-thinking-xhigh":{targetId:"claude-fable-5-thinking",level:"xhigh",legacyVariantId:"claude-fable-5-thinking-xhigh",encoding:"legacy-variant"},"claude-opus-4-7-high":{targetId:"claude-opus-4-7",level:"high",legacyVariantId:"claude-opus-4-7-high",encoding:"legacy-variant"},"claude-opus-4-7-low":{targetId:"claude-opus-4-7",level:"low",legacyVariantId:"claude-opus-4-7-low",encoding:"legacy-variant"},"claude-opus-4-7-max":{targetId:"claude-opus-4-7",level:"max",legacyVariantId:"claude-opus-4-7-max",encoding:"legacy-variant"},"claude-opus-4-7-medium":{targetId:"claude-opus-4-7",level:"medium",legacyVariantId:"claude-opus-4-7-medium",encoding:"legacy-variant"},"claude-opus-4-7-xhigh":{targetId:"claude-opus-4-7",level:"xhigh",legacyVariantId:"claude-opus-4-7-xhigh",encoding:"legacy-variant"},"claude-opus-4-7-high-fast":{targetId:"claude-opus-4-7-high-fast",legacyVariantId:"claude-opus-4-7-high-fast",encoding:"legacy-variant"},"claude-opus-4-7-low-fast":{targetId:"claude-opus-4-7-low-fast",legacyVariantId:"claude-opus-4-7-low-fast",encoding:"legacy-variant"},"claude-opus-4-7-max-fast":{targetId:"claude-opus-4-7-max-fast",legacyVariantId:"claude-opus-4-7-max-fast",encoding:"legacy-variant"},"claude-opus-4-7-medium-fast":{targetId:"claude-opus-4-7-medium-fast",legacyVariantId:"claude-opus-4-7-medium-fast",encoding:"legacy-variant"},"claude-opus-4-7-xhigh-fast":{targetId:"claude-opus-4-7-xhigh-fast",legacyVariantId:"claude-opus-4-7-xhigh-fast",encoding:"legacy-variant"},"claude-opus-4-7-thinking-high":{targetId:"claude-opus-4-7-thinking",level:"high",legacyVariantId:"claude-opus-4-7-thinking-high",encoding:"legacy-variant"},"claude-opus-4-7-thinking-low":{targetId:"claude-opus-4-7-thinking",level:"low",legacyVariantId:"claude-opus-4-7-thinking-low",encoding:"legacy-variant"},"claude-opus-4-7-thinking-max":{targetId:"claude-opus-4-7-thinking",level:"max",legacyVariantId:"claude-opus-4-7-thinking-max",encoding:"legacy-variant"},"claude-opus-4-7-thinking-medium":{targetId:"claude-opus-4-7-thinking",level:"medium",legacyVariantId:"claude-opus-4-7-thinking-medium",encoding:"legacy-variant"},"claude-opus-4-7-thinking-xhigh":{targetId:"claude-opus-4-7-thinking",level:"xhigh",legacyVariantId:"claude-opus-4-7-thinking-xhigh",encoding:"legacy-variant"},"claude-opus-4-7-thinking-high-fast":{targetId:"claude-opus-4-7-thinking-high-fast",legacyVariantId:"claude-opus-4-7-thinking-high-fast",encoding:"legacy-variant"},"claude-opus-4-7-thinking-low-fast":{targetId:"claude-opus-4-7-thinking-low-fast",legacyVariantId:"claude-opus-4-7-thinking-low-fast",encoding:"legacy-variant"},"claude-opus-4-7-thinking-max-fast":{targetId:"claude-opus-4-7-thinking-max-fast",legacyVariantId:"claude-opus-4-7-thinking-max-fast",encoding:"legacy-variant"},"claude-opus-4-7-thinking-medium-fast":{targetId:"claude-opus-4-7-thinking-medium-fast",legacyVariantId:"claude-opus-4-7-thinking-medium-fast",encoding:"legacy-variant"},"claude-opus-4-7-thinking-xhigh-fast":{targetId:"claude-opus-4-7-thinking-xhigh-fast",legacyVariantId:"claude-opus-4-7-thinking-xhigh-fast",encoding:"legacy-variant"},"claude-opus-4-8-high":{targetId:"claude-opus-4-8",level:"high",legacyVariantId:"claude-opus-4-8-high",encoding:"legacy-variant"},"claude-opus-4-8-low":{targetId:"claude-opus-4-8",level:"low",legacyVariantId:"claude-opus-4-8-low",encoding:"legacy-variant"},"claude-opus-4-8-max":{targetId:"claude-opus-4-8",level:"max",legacyVariantId:"claude-opus-4-8-max",encoding:"legacy-variant"},"claude-opus-4-8-medium":{targetId:"claude-opus-4-8",level:"medium",legacyVariantId:"claude-opus-4-8-medium",encoding:"legacy-variant"},"claude-opus-4-8-xhigh":{targetId:"claude-opus-4-8",level:"xhigh",legacyVariantId:"claude-opus-4-8-xhigh",encoding:"legacy-variant"},"claude-opus-4-8-high-fast":{targetId:"claude-opus-4-8-high-fast",legacyVariantId:"claude-opus-4-8-high-fast",encoding:"legacy-variant"},"claude-opus-4-8-low-fast":{targetId:"claude-opus-4-8-low-fast",legacyVariantId:"claude-opus-4-8-low-fast",encoding:"legacy-variant"},"claude-opus-4-8-max-fast":{targetId:"claude-opus-4-8-max-fast",legacyVariantId:"claude-opus-4-8-max-fast",encoding:"legacy-variant"},"claude-opus-4-8-medium-fast":{targetId:"claude-opus-4-8-medium-fast",legacyVariantId:"claude-opus-4-8-medium-fast",encoding:"legacy-variant"},"claude-opus-4-8-xhigh-fast":{targetId:"claude-opus-4-8-xhigh-fast",legacyVariantId:"claude-opus-4-8-xhigh-fast",encoding:"legacy-variant"},"claude-opus-4-8-thinking-high":{targetId:"claude-opus-4-8-thinking",level:"high",legacyVariantId:"claude-opus-4-8-thinking-high",encoding:"legacy-variant"},"claude-opus-4-8-thinking-low":{targetId:"claude-opus-4-8-thinking",level:"low",legacyVariantId:"claude-opus-4-8-thinking-low",encoding:"legacy-variant"},"claude-opus-4-8-thinking-max":{targetId:"claude-opus-4-8-thinking",level:"max",legacyVariantId:"claude-opus-4-8-thinking-max",encoding:"legacy-variant"},"claude-opus-4-8-thinking-medium":{targetId:"claude-opus-4-8-thinking",level:"medium",legacyVariantId:"claude-opus-4-8-thinking-medium",encoding:"legacy-variant"},"claude-opus-4-8-thinking-xhigh":{targetId:"claude-opus-4-8-thinking",level:"xhigh",legacyVariantId:"claude-opus-4-8-thinking-xhigh",encoding:"legacy-variant"},"claude-opus-4-8-thinking-high-fast":{targetId:"claude-opus-4-8-thinking-high-fast",legacyVariantId:"claude-opus-4-8-thinking-high-fast",encoding:"legacy-variant"},"claude-opus-4-8-thinking-low-fast":{targetId:"claude-opus-4-8-thinking-low-fast",legacyVariantId:"claude-opus-4-8-thinking-low-fast",encoding:"legacy-variant"},"claude-opus-4-8-thinking-max-fast":{targetId:"claude-opus-4-8-thinking-max-fast",legacyVariantId:"claude-opus-4-8-thinking-max-fast",encoding:"legacy-variant"},"claude-opus-4-8-thinking-medium-fast":{targetId:"claude-opus-4-8-thinking-medium-fast",legacyVariantId:"claude-opus-4-8-thinking-medium-fast",encoding:"legacy-variant"},"claude-opus-4-8-thinking-xhigh-fast":{targetId:"claude-opus-4-8-thinking-xhigh-fast",legacyVariantId:"claude-opus-4-8-thinking-xhigh-fast",encoding:"legacy-variant"},"claude-opus-5-high":{targetId:"claude-opus-5",level:"high",legacyVariantId:"claude-opus-5-high",encoding:"legacy-variant"},"claude-opus-5-low":{targetId:"claude-opus-5",level:"low",legacyVariantId:"claude-opus-5-low",encoding:"legacy-variant"},"claude-opus-5-medium":{targetId:"claude-opus-5",level:"medium",legacyVariantId:"claude-opus-5-medium",encoding:"legacy-variant"},"claude-opus-5-max":{targetId:"claude-opus-5",level:"max",legacyVariantId:"claude-opus-5-max",encoding:"legacy-variant"},"claude-opus-5-high-fast":{targetId:"claude-opus-5-high-fast",legacyVariantId:"claude-opus-5-high-fast",encoding:"legacy-variant"},"claude-opus-5-low-fast":{targetId:"claude-opus-5-low-fast",legacyVariantId:"claude-opus-5-low-fast",encoding:"legacy-variant"},"claude-opus-5-medium-fast":{targetId:"claude-opus-5-medium-fast",legacyVariantId:"claude-opus-5-medium-fast",encoding:"legacy-variant"},"claude-opus-5-max-fast":{targetId:"claude-opus-5-max-fast",legacyVariantId:"claude-opus-5-max-fast",encoding:"legacy-variant"},"claude-opus-5-thinking-high":{targetId:"claude-opus-5-thinking",level:"high",legacyVariantId:"claude-opus-5-thinking-high",encoding:"legacy-variant"},"claude-opus-5-thinking-low":{targetId:"claude-opus-5-thinking",level:"low",legacyVariantId:"claude-opus-5-thinking-low",encoding:"legacy-variant"},"claude-opus-5-thinking-max":{targetId:"claude-opus-5-thinking",level:"max",legacyVariantId:"claude-opus-5-thinking-max",encoding:"legacy-variant"},"claude-opus-5-thinking-medium":{targetId:"claude-opus-5-thinking",level:"medium",legacyVariantId:"claude-opus-5-thinking-medium",encoding:"legacy-variant"},"claude-opus-5-thinking-xhigh":{targetId:"claude-opus-5-thinking",level:"xhigh",legacyVariantId:"claude-opus-5-thinking-xhigh",encoding:"legacy-variant"},"claude-opus-5-thinking-high-fast":{targetId:"claude-opus-5-thinking-high-fast",legacyVariantId:"claude-opus-5-thinking-high-fast",encoding:"legacy-variant"},"claude-opus-5-thinking-low-fast":{targetId:"claude-opus-5-thinking-low-fast",legacyVariantId:"claude-opus-5-thinking-low-fast",encoding:"legacy-variant"},"claude-opus-5-thinking-max-fast":{targetId:"claude-opus-5-thinking-max-fast",legacyVariantId:"claude-opus-5-thinking-max-fast",encoding:"legacy-variant"},"claude-opus-5-thinking-medium-fast":{targetId:"claude-opus-5-thinking-medium-fast",legacyVariantId:"claude-opus-5-thinking-medium-fast",encoding:"legacy-variant"},"claude-opus-5-thinking-xhigh-fast":{targetId:"claude-opus-5-thinking-xhigh-fast",legacyVariantId:"claude-opus-5-thinking-xhigh-fast",encoding:"legacy-variant"},"claude-sonnet-5-high":{targetId:"claude-sonnet-5",level:"high",legacyVariantId:"claude-sonnet-5-high",encoding:"legacy-variant"},"claude-sonnet-5-low":{targetId:"claude-sonnet-5",level:"low",legacyVariantId:"claude-sonnet-5-low",encoding:"legacy-variant"},"claude-sonnet-5-max":{targetId:"claude-sonnet-5",level:"max",legacyVariantId:"claude-sonnet-5-max",encoding:"legacy-variant"},"claude-sonnet-5-medium":{targetId:"claude-sonnet-5",level:"medium",legacyVariantId:"claude-sonnet-5-medium",encoding:"legacy-variant"},"claude-sonnet-5-xhigh":{targetId:"claude-sonnet-5",level:"xhigh",legacyVariantId:"claude-sonnet-5-xhigh",encoding:"legacy-variant"},"claude-sonnet-5-thinking-high":{targetId:"claude-sonnet-5-thinking",level:"high",legacyVariantId:"claude-sonnet-5-thinking-high",encoding:"legacy-variant"},"claude-sonnet-5-thinking-low":{targetId:"claude-sonnet-5-thinking",level:"low",legacyVariantId:"claude-sonnet-5-thinking-low",encoding:"legacy-variant"},"claude-sonnet-5-thinking-max":{targetId:"claude-sonnet-5-thinking",level:"max",legacyVariantId:"claude-sonnet-5-thinking-max",encoding:"legacy-variant"},"claude-sonnet-5-thinking-medium":{targetId:"claude-sonnet-5-thinking",level:"medium",legacyVariantId:"claude-sonnet-5-thinking-medium",encoding:"legacy-variant"},"claude-sonnet-5-thinking-xhigh":{targetId:"claude-sonnet-5-thinking",level:"xhigh",legacyVariantId:"claude-sonnet-5-thinking-xhigh",encoding:"legacy-variant"},"composer-2.5":{targetId:"composer-2.5",legacyVariantId:"composer-2.5",encoding:"legacy-variant"},"composer-2.5-fast":{targetId:"composer-2.5-fast",legacyVariantId:"composer-2.5-fast",encoding:"legacy-variant"},"cursor-grok-4.5-high":{targetId:"cursor-grok-4.5",level:"high",legacyVariantId:"cursor-grok-4.5-high",encoding:"legacy-variant"},"cursor-grok-4.5-low":{targetId:"cursor-grok-4.5",level:"low",legacyVariantId:"cursor-grok-4.5-low",encoding:"legacy-variant"},"cursor-grok-4.5-medium":{targetId:"cursor-grok-4.5",level:"medium",legacyVariantId:"cursor-grok-4.5-medium",encoding:"legacy-variant"},"cursor-grok-4.5-max":{targetId:"cursor-grok-4.5",level:"max",legacyVariantId:"cursor-grok-4.5-max",encoding:"legacy-variant"},"cursor-grok-4.5-thinking-low":{targetId:"cursor-grok-4.5",level:"low",legacyVariantId:"cursor-grok-4.5-thinking-low",encoding:"legacy-variant"},"cursor-grok-4.5-thinking-medium":{targetId:"cursor-grok-4.5",level:"medium",legacyVariantId:"cursor-grok-4.5-thinking-medium",encoding:"legacy-variant"},"cursor-grok-4.5-thinking-max":{targetId:"cursor-grok-4.5",level:"max",legacyVariantId:"cursor-grok-4.5-thinking-max",encoding:"legacy-variant"},"cursor-grok-4.5-high-fast":{targetId:"cursor-grok-4.5-high-fast",legacyVariantId:"cursor-grok-4.5-high-fast",encoding:"legacy-variant"},"cursor-grok-4.5-low-fast":{targetId:"cursor-grok-4.5-low-fast",legacyVariantId:"cursor-grok-4.5-low-fast",encoding:"legacy-variant"},"cursor-grok-4.5-medium-fast":{targetId:"cursor-grok-4.5-medium-fast",legacyVariantId:"cursor-grok-4.5-medium-fast",encoding:"legacy-variant"},"cursor-grok-4.5-max-fast":{targetId:"cursor-grok-4.5-max-fast",legacyVariantId:"cursor-grok-4.5-max-fast",encoding:"legacy-variant"},"cursor-grok-4.6-high":{targetId:"cursor-grok-4.6",level:"high",legacyVariantId:"cursor-grok-4.6-high",encoding:"legacy-variant"},"cursor-grok-4.6-low":{targetId:"cursor-grok-4.6",level:"low",legacyVariantId:"cursor-grok-4.6-low",encoding:"legacy-variant"},"cursor-grok-4.6-medium":{targetId:"cursor-grok-4.6",level:"medium",legacyVariantId:"cursor-grok-4.6-medium",encoding:"legacy-variant"},"cursor-grok-4.6-xhigh":{targetId:"cursor-grok-4.6",level:"xhigh",legacyVariantId:"cursor-grok-4.6-xhigh",encoding:"legacy-variant"},"cursor-grok-4.6-max":{targetId:"cursor-grok-4.6",level:"max",legacyVariantId:"cursor-grok-4.6-max",encoding:"legacy-variant"},"cursor-grok-4.6-thinking-low":{targetId:"cursor-grok-4.6",level:"low",legacyVariantId:"cursor-grok-4.6-thinking-low",encoding:"legacy-variant"},"cursor-grok-4.6-thinking-medium":{targetId:"cursor-grok-4.6",level:"medium",legacyVariantId:"cursor-grok-4.6-thinking-medium",encoding:"legacy-variant"},"cursor-grok-4.6-thinking-max":{targetId:"cursor-grok-4.6",level:"max",legacyVariantId:"cursor-grok-4.6-thinking-max",encoding:"legacy-variant"},"cursor-grok-4.6-high-fast":{targetId:"cursor-grok-4.6-high-fast",legacyVariantId:"cursor-grok-4.6-high-fast",encoding:"legacy-variant"},"cursor-grok-4.6-low-fast":{targetId:"cursor-grok-4.6-low-fast",legacyVariantId:"cursor-grok-4.6-low-fast",encoding:"legacy-variant"},"cursor-grok-4.6-medium-fast":{targetId:"cursor-grok-4.6-medium-fast",legacyVariantId:"cursor-grok-4.6-medium-fast",encoding:"legacy-variant"},"cursor-grok-4.6-xhigh-fast":{targetId:"cursor-grok-4.6-xhigh-fast",legacyVariantId:"cursor-grok-4.6-xhigh-fast",encoding:"legacy-variant"},"cursor-grok-4.6-max-fast":{targetId:"cursor-grok-4.6-max-fast",legacyVariantId:"cursor-grok-4.6-max-fast",encoding:"legacy-variant"},default:{targetId:"default",legacyVariantId:"default",encoding:"legacy-variant"},"gemini-3-flash":{targetId:"gemini-3-flash",legacyVariantId:"gemini-3-flash",encoding:"legacy-variant"},"gemini-3.1-pro":{targetId:"gemini-3.1-pro",legacyVariantId:"gemini-3.1-pro",encoding:"legacy-variant"},"gemini-3.5-flash":{targetId:"gemini-3.5-flash",legacyVariantId:"gemini-3.5-flash",encoding:"legacy-variant"},"gemini-3.6-flash-high":{targetId:"gemini-3.6-flash",level:"high",legacyVariantId:"gemini-3.6-flash-high",encoding:"legacy-variant"},"gemini-3.6-flash-low":{targetId:"gemini-3.6-flash",level:"low",legacyVariantId:"gemini-3.6-flash-low",encoding:"legacy-variant"},"gemini-3.6-flash-medium":{targetId:"gemini-3.6-flash",level:"medium",legacyVariantId:"gemini-3.6-flash-medium",encoding:"legacy-variant"},"gemini-3.6-flash-minimal":{targetId:"gemini-3.6-flash",level:"minimal",legacyVariantId:"gemini-3.6-flash-minimal",encoding:"legacy-variant"},"gemini-3.7-flash-high":{targetId:"gemini-3.7-flash",level:"high",legacyVariantId:"gemini-3.7-flash-high",encoding:"legacy-variant"},"gemini-3.7-flash-low":{targetId:"gemini-3.7-flash",level:"low",legacyVariantId:"gemini-3.7-flash-low",encoding:"legacy-variant"},"gemini-3.7-flash-medium":{targetId:"gemini-3.7-flash",level:"medium",legacyVariantId:"gemini-3.7-flash-medium",encoding:"legacy-variant"},"gemini-3.7-flash-max":{targetId:"gemini-3.7-flash",level:"max",legacyVariantId:"gemini-3.7-flash-max",encoding:"legacy-variant"},"gemini-3.7-flash-thinking-low":{targetId:"gemini-3.7-flash",level:"low",legacyVariantId:"gemini-3.7-flash-thinking-low",encoding:"legacy-variant"},"gemini-3.7-flash-thinking-medium":{targetId:"gemini-3.7-flash",level:"medium",legacyVariantId:"gemini-3.7-flash-thinking-medium",encoding:"legacy-variant"},"gemini-3.7-flash-thinking-max":{targetId:"gemini-3.7-flash",level:"max",legacyVariantId:"gemini-3.7-flash-thinking-max",encoding:"legacy-variant"},"glm-5.2-high":{targetId:"glm-5.2",level:"high",legacyVariantId:"glm-5.2-high",encoding:"legacy-variant"},"glm-5.2-max":{targetId:"glm-5.2",level:"max",legacyVariantId:"glm-5.2-max",encoding:"legacy-variant"},"gpt-5-mini":{targetId:"gpt-5-mini",legacyVariantId:"gpt-5-mini",encoding:"legacy-variant"},"gpt-5.1":{targetId:"gpt-5.1",legacyVariantId:"gpt-5.1",encoding:"legacy-variant"},"gpt-5.1-high":{targetId:"gpt-5.1",level:"high",legacyVariantId:"gpt-5.1-high",encoding:"legacy-variant"},"gpt-5.1-low":{targetId:"gpt-5.1",level:"low",legacyVariantId:"gpt-5.1-low",encoding:"legacy-variant"},"gpt-5.2":{targetId:"gpt-5.2",legacyVariantId:"gpt-5.2",encoding:"legacy-variant"},"gpt-5.2-high":{targetId:"gpt-5.2",level:"high",legacyVariantId:"gpt-5.2-high",encoding:"legacy-variant"},"gpt-5.2-low":{targetId:"gpt-5.2",level:"low",legacyVariantId:"gpt-5.2-low",encoding:"legacy-variant"},"gpt-5.2-xhigh":{targetId:"gpt-5.2",level:"xhigh",legacyVariantId:"gpt-5.2-xhigh",encoding:"legacy-variant"},"gpt-5.2-medium":{targetId:"gpt-5.2",level:"medium",legacyVariantId:"gpt-5.2-medium",encoding:"legacy-variant"},"gpt-5.2-max":{targetId:"gpt-5.2",level:"max",legacyVariantId:"gpt-5.2-max",encoding:"legacy-variant"},"gpt-5.2-thinking-low":{targetId:"gpt-5.2",level:"low",legacyVariantId:"gpt-5.2-thinking-low",encoding:"legacy-variant"},"gpt-5.2-thinking-medium":{targetId:"gpt-5.2",level:"medium",legacyVariantId:"gpt-5.2-thinking-medium",encoding:"legacy-variant"},"gpt-5.2-thinking-max":{targetId:"gpt-5.2",level:"max",legacyVariantId:"gpt-5.2-thinking-max",encoding:"legacy-variant"},"gpt-5.2-fast":{targetId:"gpt-5.2-fast",legacyVariantId:"gpt-5.2-fast",encoding:"legacy-variant"},"gpt-5.2-high-fast":{targetId:"gpt-5.2-high-fast",legacyVariantId:"gpt-5.2-high-fast",encoding:"legacy-variant"},"gpt-5.2-low-fast":{targetId:"gpt-5.2-low-fast",legacyVariantId:"gpt-5.2-low-fast",encoding:"legacy-variant"},"gpt-5.2-xhigh-fast":{targetId:"gpt-5.2-xhigh-fast",legacyVariantId:"gpt-5.2-xhigh-fast",encoding:"legacy-variant"},"gpt-5.2-medium-fast":{targetId:"gpt-5.2-medium-fast",legacyVariantId:"gpt-5.2-medium-fast",encoding:"legacy-variant"},"gpt-5.2-max-fast":{targetId:"gpt-5.2-max-fast",legacyVariantId:"gpt-5.2-max-fast",encoding:"legacy-variant"},"gpt-5.3-codex":{targetId:"gpt-5.3-codex",legacyVariantId:"gpt-5.3-codex",encoding:"legacy-variant"},"gpt-5.3-codex-high":{targetId:"gpt-5.3-codex",level:"high",legacyVariantId:"gpt-5.3-codex-high",encoding:"legacy-variant"},"gpt-5.3-codex-low":{targetId:"gpt-5.3-codex",level:"low",legacyVariantId:"gpt-5.3-codex-low",encoding:"legacy-variant"},"gpt-5.3-codex-xhigh":{targetId:"gpt-5.3-codex",level:"xhigh",legacyVariantId:"gpt-5.3-codex-xhigh",encoding:"legacy-variant"},"gpt-5.3-codex-medium":{targetId:"gpt-5.3-codex",level:"medium",legacyVariantId:"gpt-5.3-codex-medium",encoding:"legacy-variant"},"gpt-5.3-codex-max":{targetId:"gpt-5.3-codex",level:"max",legacyVariantId:"gpt-5.3-codex-max",encoding:"legacy-variant"},"gpt-5.3-codex-thinking-low":{targetId:"gpt-5.3-codex",level:"low",legacyVariantId:"gpt-5.3-codex-thinking-low",encoding:"legacy-variant"},"gpt-5.3-codex-thinking-medium":{targetId:"gpt-5.3-codex",level:"medium",legacyVariantId:"gpt-5.3-codex-thinking-medium",encoding:"legacy-variant"},"gpt-5.3-codex-thinking-max":{targetId:"gpt-5.3-codex",level:"max",legacyVariantId:"gpt-5.3-codex-thinking-max",encoding:"legacy-variant"},"gpt-5.3-codex-fast":{targetId:"gpt-5.3-codex-fast",legacyVariantId:"gpt-5.3-codex-fast",encoding:"legacy-variant"},"gpt-5.3-codex-high-fast":{targetId:"gpt-5.3-codex-high-fast",legacyVariantId:"gpt-5.3-codex-high-fast",encoding:"legacy-variant"},"gpt-5.3-codex-low-fast":{targetId:"gpt-5.3-codex-low-fast",legacyVariantId:"gpt-5.3-codex-low-fast",encoding:"legacy-variant"},"gpt-5.3-codex-xhigh-fast":{targetId:"gpt-5.3-codex-xhigh-fast",legacyVariantId:"gpt-5.3-codex-xhigh-fast",encoding:"legacy-variant"},"gpt-5.3-codex-medium-fast":{targetId:"gpt-5.3-codex-medium-fast",legacyVariantId:"gpt-5.3-codex-medium-fast",encoding:"legacy-variant"},"gpt-5.3-codex-max-fast":{targetId:"gpt-5.3-codex-max-fast",legacyVariantId:"gpt-5.3-codex-max-fast",encoding:"legacy-variant"},"gpt-5.4-high":{targetId:"gpt-5.4",level:"high",legacyVariantId:"gpt-5.4-high",encoding:"legacy-variant"},"gpt-5.4-low":{targetId:"gpt-5.4",level:"low",legacyVariantId:"gpt-5.4-low",encoding:"legacy-variant"},"gpt-5.4-medium":{targetId:"gpt-5.4",level:"medium",legacyVariantId:"gpt-5.4-medium",encoding:"legacy-variant"},"gpt-5.4-xhigh":{targetId:"gpt-5.4",level:"xhigh",legacyVariantId:"gpt-5.4-xhigh",encoding:"legacy-variant"},"gpt-5.4-high-fast":{targetId:"gpt-5.4-high-fast",legacyVariantId:"gpt-5.4-high-fast",encoding:"legacy-variant"},"gpt-5.4-medium-fast":{targetId:"gpt-5.4-medium-fast",legacyVariantId:"gpt-5.4-medium-fast",encoding:"legacy-variant"},"gpt-5.4-xhigh-fast":{targetId:"gpt-5.4-xhigh-fast",legacyVariantId:"gpt-5.4-xhigh-fast",encoding:"legacy-variant"},"gpt-5.4-mini-high":{targetId:"gpt-5.4-mini",level:"high",legacyVariantId:"gpt-5.4-mini-high",encoding:"legacy-variant"},"gpt-5.4-mini-low":{targetId:"gpt-5.4-mini",level:"low",legacyVariantId:"gpt-5.4-mini-low",encoding:"legacy-variant"},"gpt-5.4-mini-medium":{targetId:"gpt-5.4-mini",level:"medium",legacyVariantId:"gpt-5.4-mini-medium",encoding:"legacy-variant"},"gpt-5.4-mini-none":{targetId:"gpt-5.4-mini",level:"off",legacyVariantId:"gpt-5.4-mini-none",encoding:"legacy-variant"},"gpt-5.4-mini-xhigh":{targetId:"gpt-5.4-mini",level:"xhigh",legacyVariantId:"gpt-5.4-mini-xhigh",encoding:"legacy-variant"},"gpt-5.4-nano-high":{targetId:"gpt-5.4-nano",level:"high",legacyVariantId:"gpt-5.4-nano-high",encoding:"legacy-variant"},"gpt-5.4-nano-low":{targetId:"gpt-5.4-nano",level:"low",legacyVariantId:"gpt-5.4-nano-low",encoding:"legacy-variant"},"gpt-5.4-nano-medium":{targetId:"gpt-5.4-nano",level:"medium",legacyVariantId:"gpt-5.4-nano-medium",encoding:"legacy-variant"},"gpt-5.4-nano-none":{targetId:"gpt-5.4-nano",level:"off",legacyVariantId:"gpt-5.4-nano-none",encoding:"legacy-variant"},"gpt-5.4-nano-xhigh":{targetId:"gpt-5.4-nano",level:"xhigh",legacyVariantId:"gpt-5.4-nano-xhigh",encoding:"legacy-variant"},"gpt-5.5-extra-high":{targetId:"gpt-5.5",level:"extra-high",legacyVariantId:"gpt-5.5-extra-high",encoding:"legacy-variant"},"gpt-5.5-high":{targetId:"gpt-5.5",level:"high",legacyVariantId:"gpt-5.5-high",encoding:"legacy-variant"},"gpt-5.5-low":{targetId:"gpt-5.5",level:"low",legacyVariantId:"gpt-5.5-low",encoding:"legacy-variant"},"gpt-5.5-medium":{targetId:"gpt-5.5",level:"medium",legacyVariantId:"gpt-5.5-medium",encoding:"legacy-variant"},"gpt-5.5-none":{targetId:"gpt-5.5",level:"off",legacyVariantId:"gpt-5.5-none",encoding:"legacy-variant"},"gpt-5.5-max":{targetId:"gpt-5.5",level:"max",legacyVariantId:"gpt-5.5-max",encoding:"legacy-variant"},"gpt-5.5-thinking-low":{targetId:"gpt-5.5",level:"low",legacyVariantId:"gpt-5.5-thinking-low",encoding:"legacy-variant"},"gpt-5.5-thinking-medium":{targetId:"gpt-5.5",level:"medium",legacyVariantId:"gpt-5.5-thinking-medium",encoding:"legacy-variant"},"gpt-5.5-thinking-max":{targetId:"gpt-5.5",level:"max",legacyVariantId:"gpt-5.5-thinking-max",encoding:"legacy-variant"},"gpt-5.5-extra-high-fast":{targetId:"gpt-5.5-extra-high-fast",legacyVariantId:"gpt-5.5-extra-high-fast",encoding:"legacy-variant"},"gpt-5.5-high-fast":{targetId:"gpt-5.5-high-fast",legacyVariantId:"gpt-5.5-high-fast",encoding:"legacy-variant"},"gpt-5.5-low-fast":{targetId:"gpt-5.5-low-fast",legacyVariantId:"gpt-5.5-low-fast",encoding:"legacy-variant"},"gpt-5.5-medium-fast":{targetId:"gpt-5.5-medium-fast",legacyVariantId:"gpt-5.5-medium-fast",encoding:"legacy-variant"},"gpt-5.5-none-fast":{targetId:"gpt-5.5-none-fast",legacyVariantId:"gpt-5.5-none-fast",encoding:"legacy-variant"},"gpt-5.5-max-fast":{targetId:"gpt-5.5-max-fast",legacyVariantId:"gpt-5.5-max-fast",encoding:"legacy-variant"},"gpt-5.6-luna-high":{targetId:"gpt-5.6-luna",level:"high",legacyVariantId:"gpt-5.6-luna-high",encoding:"legacy-variant"},"gpt-5.6-luna-low":{targetId:"gpt-5.6-luna",level:"low",legacyVariantId:"gpt-5.6-luna-low",encoding:"legacy-variant"},"gpt-5.6-luna-max":{targetId:"gpt-5.6-luna",level:"max",legacyVariantId:"gpt-5.6-luna-max",encoding:"legacy-variant"},"gpt-5.6-luna-medium":{targetId:"gpt-5.6-luna",level:"medium",legacyVariantId:"gpt-5.6-luna-medium",encoding:"legacy-variant"},"gpt-5.6-luna-none":{targetId:"gpt-5.6-luna",level:"off",legacyVariantId:"gpt-5.6-luna-none",encoding:"legacy-variant"},"gpt-5.6-luna-xhigh":{targetId:"gpt-5.6-luna",level:"xhigh",legacyVariantId:"gpt-5.6-luna-xhigh",encoding:"legacy-variant"},"gpt-5.6-luna-thinking-low":{targetId:"gpt-5.6-luna",level:"low",legacyVariantId:"gpt-5.6-luna-thinking-low",encoding:"legacy-variant"},"gpt-5.6-luna-thinking-medium":{targetId:"gpt-5.6-luna",level:"medium",legacyVariantId:"gpt-5.6-luna-thinking-medium",encoding:"legacy-variant"},"gpt-5.6-luna-thinking-max":{targetId:"gpt-5.6-luna",level:"max",legacyVariantId:"gpt-5.6-luna-thinking-max",encoding:"legacy-variant"},"gpt-5.6-luna-high-fast":{targetId:"gpt-5.6-luna-high-fast",legacyVariantId:"gpt-5.6-luna-high-fast",encoding:"legacy-variant"},"gpt-5.6-luna-low-fast":{targetId:"gpt-5.6-luna-low-fast",legacyVariantId:"gpt-5.6-luna-low-fast",encoding:"legacy-variant"},"gpt-5.6-luna-max-fast":{targetId:"gpt-5.6-luna-max-fast",legacyVariantId:"gpt-5.6-luna-max-fast",encoding:"legacy-variant"},"gpt-5.6-luna-medium-fast":{targetId:"gpt-5.6-luna-medium-fast",legacyVariantId:"gpt-5.6-luna-medium-fast",encoding:"legacy-variant"},"gpt-5.6-luna-none-fast":{targetId:"gpt-5.6-luna-none-fast",legacyVariantId:"gpt-5.6-luna-none-fast",encoding:"legacy-variant"},"gpt-5.6-luna-xhigh-fast":{targetId:"gpt-5.6-luna-xhigh-fast",legacyVariantId:"gpt-5.6-luna-xhigh-fast",encoding:"legacy-variant"},"gpt-5.6-sol-high":{targetId:"gpt-5.6-sol",level:"high",legacyVariantId:"gpt-5.6-sol-high",encoding:"legacy-variant"},"gpt-5.6-sol-low":{targetId:"gpt-5.6-sol",level:"low",legacyVariantId:"gpt-5.6-sol-low",encoding:"legacy-variant"},"gpt-5.6-sol-max":{targetId:"gpt-5.6-sol",level:"max",legacyVariantId:"gpt-5.6-sol-max",encoding:"legacy-variant"},"gpt-5.6-sol-medium":{targetId:"gpt-5.6-sol",level:"medium",legacyVariantId:"gpt-5.6-sol-medium",encoding:"legacy-variant"},"gpt-5.6-sol-none":{targetId:"gpt-5.6-sol",level:"off",legacyVariantId:"gpt-5.6-sol-none",encoding:"legacy-variant"},"gpt-5.6-sol-xhigh":{targetId:"gpt-5.6-sol",level:"xhigh",legacyVariantId:"gpt-5.6-sol-xhigh",encoding:"legacy-variant"},"gpt-5.6-sol-thinking-low":{targetId:"gpt-5.6-sol",level:"low",legacyVariantId:"gpt-5.6-sol-thinking-low",encoding:"legacy-variant"},"gpt-5.6-sol-thinking-medium":{targetId:"gpt-5.6-sol",level:"medium",legacyVariantId:"gpt-5.6-sol-thinking-medium",encoding:"legacy-variant"},"gpt-5.6-sol-thinking-max":{targetId:"gpt-5.6-sol",level:"max",legacyVariantId:"gpt-5.6-sol-thinking-max",encoding:"legacy-variant"},"gpt-5.6-sol-high-fast":{targetId:"gpt-5.6-sol-high-fast",legacyVariantId:"gpt-5.6-sol-high-fast",encoding:"legacy-variant"},"gpt-5.6-sol-low-fast":{targetId:"gpt-5.6-sol-low-fast",legacyVariantId:"gpt-5.6-sol-low-fast",encoding:"legacy-variant"},"gpt-5.6-sol-max-fast":{targetId:"gpt-5.6-sol-max-fast",legacyVariantId:"gpt-5.6-sol-max-fast",encoding:"legacy-variant"},"gpt-5.6-sol-medium-fast":{targetId:"gpt-5.6-sol-medium-fast",legacyVariantId:"gpt-5.6-sol-medium-fast",encoding:"legacy-variant"},"gpt-5.6-sol-none-fast":{targetId:"gpt-5.6-sol-none-fast",legacyVariantId:"gpt-5.6-sol-none-fast",encoding:"legacy-variant"},"gpt-5.6-sol-xhigh-fast":{targetId:"gpt-5.6-sol-xhigh-fast",legacyVariantId:"gpt-5.6-sol-xhigh-fast",encoding:"legacy-variant"},"gpt-5.6-terra-high":{targetId:"gpt-5.6-terra",level:"high",legacyVariantId:"gpt-5.6-terra-high",encoding:"legacy-variant"},"gpt-5.6-terra-low":{targetId:"gpt-5.6-terra",level:"low",legacyVariantId:"gpt-5.6-terra-low",encoding:"legacy-variant"},"gpt-5.6-terra-max":{targetId:"gpt-5.6-terra",level:"max",legacyVariantId:"gpt-5.6-terra-max",encoding:"legacy-variant"},"gpt-5.6-terra-medium":{targetId:"gpt-5.6-terra",level:"medium",legacyVariantId:"gpt-5.6-terra-medium",encoding:"legacy-variant"},"gpt-5.6-terra-none":{targetId:"gpt-5.6-terra",level:"off",legacyVariantId:"gpt-5.6-terra-none",encoding:"legacy-variant"},"gpt-5.6-terra-xhigh":{targetId:"gpt-5.6-terra",level:"xhigh",legacyVariantId:"gpt-5.6-terra-xhigh",encoding:"legacy-variant"},"gpt-5.6-terra-high-fast":{targetId:"gpt-5.6-terra-high-fast",legacyVariantId:"gpt-5.6-terra-high-fast",encoding:"legacy-variant"},"gpt-5.6-terra-low-fast":{targetId:"gpt-5.6-terra-low-fast",legacyVariantId:"gpt-5.6-terra-low-fast",encoding:"legacy-variant"},"gpt-5.6-terra-max-fast":{targetId:"gpt-5.6-terra-max-fast",legacyVariantId:"gpt-5.6-terra-max-fast",encoding:"legacy-variant"},"gpt-5.6-terra-medium-fast":{targetId:"gpt-5.6-terra-medium-fast",legacyVariantId:"gpt-5.6-terra-medium-fast",encoding:"legacy-variant"},"gpt-5.6-terra-none-fast":{targetId:"gpt-5.6-terra-none-fast",legacyVariantId:"gpt-5.6-terra-none-fast",encoding:"legacy-variant"},"gpt-5.6-terra-xhigh-fast":{targetId:"gpt-5.6-terra-xhigh-fast",legacyVariantId:"gpt-5.6-terra-xhigh-fast",encoding:"legacy-variant"},"kimi-k2.7-code":{targetId:"kimi-k2.7-code",legacyVariantId:"kimi-k2.7-code",encoding:"legacy-variant"},"kimi-k3-high":{targetId:"kimi-k3",level:"high",legacyVariantId:"kimi-k3-high",encoding:"legacy-variant"},"kimi-k3-low":{targetId:"kimi-k3",level:"low",legacyVariantId:"kimi-k3-low",encoding:"legacy-variant"},"kimi-k3-max":{targetId:"kimi-k3",level:"max",legacyVariantId:"kimi-k3-max",encoding:"legacy-variant"},auto:{targetId:"auto",legacyVariantId:"auto",encoding:"legacy-variant"},"claude-fable-5-low-fast":{targetId:"claude-fable-5-low-fast",legacyVariantId:"claude-fable-5-low-fast",encoding:"legacy-variant"},"claude-fable-5-medium-fast":{targetId:"claude-fable-5-medium-fast",legacyVariantId:"claude-fable-5-medium-fast",encoding:"legacy-variant"},"claude-fable-5-max-fast":{targetId:"claude-fable-5-max-fast",legacyVariantId:"claude-fable-5-max-fast",encoding:"legacy-variant"},"claude-sonnet-5-low-fast":{targetId:"claude-sonnet-5-low-fast",legacyVariantId:"claude-sonnet-5-low-fast",encoding:"legacy-variant"},"claude-sonnet-5-medium-fast":{targetId:"claude-sonnet-5-medium-fast",legacyVariantId:"claude-sonnet-5-medium-fast",encoding:"legacy-variant"},"claude-sonnet-5-max-fast":{targetId:"claude-sonnet-5-max-fast",legacyVariantId:"claude-sonnet-5-max-fast",encoding:"legacy-variant"},"claude-sonnet-4-7-low":{targetId:"claude-sonnet-4-7",level:"low",legacyVariantId:"claude-sonnet-4-7-low",encoding:"legacy-variant"},"claude-sonnet-4-7-medium":{targetId:"claude-sonnet-4-7",level:"medium",legacyVariantId:"claude-sonnet-4-7-medium",encoding:"legacy-variant"},"claude-sonnet-4-7-max":{targetId:"claude-sonnet-4-7",level:"max",legacyVariantId:"claude-sonnet-4-7-max",encoding:"legacy-variant"},"claude-sonnet-4-7-low-fast":{targetId:"claude-sonnet-4-7-low-fast",legacyVariantId:"claude-sonnet-4-7-low-fast",encoding:"legacy-variant"},"claude-sonnet-4-7-medium-fast":{targetId:"claude-sonnet-4-7-medium-fast",legacyVariantId:"claude-sonnet-4-7-medium-fast",encoding:"legacy-variant"},"claude-sonnet-4-7-max-fast":{targetId:"claude-sonnet-4-7-max-fast",legacyVariantId:"claude-sonnet-4-7-max-fast",encoding:"legacy-variant"},"claude-sonnet-4-7-thinking-low":{targetId:"claude-sonnet-4-7-thinking",level:"low",legacyVariantId:"claude-sonnet-4-7-thinking-low",encoding:"legacy-variant"},"claude-sonnet-4-7-thinking-medium":{targetId:"claude-sonnet-4-7-thinking",level:"medium",legacyVariantId:"claude-sonnet-4-7-thinking-medium",encoding:"legacy-variant"},"claude-sonnet-4-7-thinking-max":{targetId:"claude-sonnet-4-7-thinking",level:"max",legacyVariantId:"claude-sonnet-4-7-thinking-max",encoding:"legacy-variant"},"claude-mythos-5-low":{targetId:"claude-mythos-5",level:"low",legacyVariantId:"claude-mythos-5-low",encoding:"legacy-variant"},"claude-mythos-5-medium":{targetId:"claude-mythos-5",level:"medium",legacyVariantId:"claude-mythos-5-medium",encoding:"legacy-variant"},"claude-mythos-5-max":{targetId:"claude-mythos-5",level:"max",legacyVariantId:"claude-mythos-5-max",encoding:"legacy-variant"},"claude-mythos-5-low-fast":{targetId:"claude-mythos-5-low-fast",legacyVariantId:"claude-mythos-5-low-fast",encoding:"legacy-variant"},"claude-mythos-5-medium-fast":{targetId:"claude-mythos-5-medium-fast",legacyVariantId:"claude-mythos-5-medium-fast",encoding:"legacy-variant"},"claude-mythos-5-max-fast":{targetId:"claude-mythos-5-max-fast",legacyVariantId:"claude-mythos-5-max-fast",encoding:"legacy-variant"},"claude-mythos-5-thinking-low":{targetId:"claude-mythos-5-thinking",level:"low",legacyVariantId:"claude-mythos-5-thinking-low",encoding:"legacy-variant"},"claude-mythos-5-thinking-medium":{targetId:"claude-mythos-5-thinking",level:"medium",legacyVariantId:"claude-mythos-5-thinking-medium",encoding:"legacy-variant"},"claude-mythos-5-thinking-max":{targetId:"claude-mythos-5-thinking",level:"max",legacyVariantId:"claude-mythos-5-thinking-max",encoding:"legacy-variant"},"gpt-5.4-codex-low":{targetId:"gpt-5.4-codex",level:"low",legacyVariantId:"gpt-5.4-codex-low",encoding:"legacy-variant"},"gpt-5.4-codex-medium":{targetId:"gpt-5.4-codex",level:"medium",legacyVariantId:"gpt-5.4-codex-medium",encoding:"legacy-variant"},"gpt-5.4-codex-max":{targetId:"gpt-5.4-codex",level:"max",legacyVariantId:"gpt-5.4-codex-max",encoding:"legacy-variant"},"gpt-5.4-codex-thinking-low":{targetId:"gpt-5.4-codex",level:"low",legacyVariantId:"gpt-5.4-codex-thinking-low",encoding:"legacy-variant"},"gpt-5.4-codex-thinking-medium":{targetId:"gpt-5.4-codex",level:"medium",legacyVariantId:"gpt-5.4-codex-thinking-medium",encoding:"legacy-variant"},"gpt-5.4-codex-thinking-max":{targetId:"gpt-5.4-codex",level:"max",legacyVariantId:"gpt-5.4-codex-thinking-max",encoding:"legacy-variant"},"gpt-5.4-codex-low-fast":{targetId:"gpt-5.4-codex-low-fast",legacyVariantId:"gpt-5.4-codex-low-fast",encoding:"legacy-variant"},"gpt-5.4-codex-medium-fast":{targetId:"gpt-5.4-codex-medium-fast",legacyVariantId:"gpt-5.4-codex-medium-fast",encoding:"legacy-variant"},"gpt-5.4-codex-max-fast":{targetId:"gpt-5.4-codex-max-fast",legacyVariantId:"gpt-5.4-codex-max-fast",encoding:"legacy-variant"},"gemini-3.7-flash-low-fast":{targetId:"gemini-3.7-flash-low-fast",legacyVariantId:"gemini-3.7-flash-low-fast",encoding:"legacy-variant"},"gemini-3.7-flash-medium-fast":{targetId:"gemini-3.7-flash-medium-fast",legacyVariantId:"gemini-3.7-flash-medium-fast",encoding:"legacy-variant"},"gemini-3.7-flash-max-fast":{targetId:"gemini-3.7-flash-max-fast",legacyVariantId:"gemini-3.7-flash-max-fast",encoding:"legacy-variant"},"gemini-3.7-pro-low":{targetId:"gemini-3.7-pro",level:"low",legacyVariantId:"gemini-3.7-pro-low",encoding:"legacy-variant"},"gemini-3.7-pro-medium":{targetId:"gemini-3.7-pro",level:"medium",legacyVariantId:"gemini-3.7-pro-medium",encoding:"legacy-variant"},"gemini-3.7-pro-max":{targetId:"gemini-3.7-pro",level:"max",legacyVariantId:"gemini-3.7-pro-max",encoding:"legacy-variant"},"gemini-3.7-pro-thinking-low":{targetId:"gemini-3.7-pro",level:"low",legacyVariantId:"gemini-3.7-pro-thinking-low",encoding:"legacy-variant"},"gemini-3.7-pro-thinking-medium":{targetId:"gemini-3.7-pro",level:"medium",legacyVariantId:"gemini-3.7-pro-thinking-medium",encoding:"legacy-variant"},"gemini-3.7-pro-thinking-max":{targetId:"gemini-3.7-pro",level:"max",legacyVariantId:"gemini-3.7-pro-thinking-max",encoding:"legacy-variant"},"gemini-3.7-pro-low-fast":{targetId:"gemini-3.7-pro-low-fast",legacyVariantId:"gemini-3.7-pro-low-fast",encoding:"legacy-variant"},"gemini-3.7-pro-medium-fast":{targetId:"gemini-3.7-pro-medium-fast",legacyVariantId:"gemini-3.7-pro-medium-fast",encoding:"legacy-variant"},"gemini-3.7-pro-max-fast":{targetId:"gemini-3.7-pro-max-fast",legacyVariantId:"gemini-3.7-pro-max-fast",encoding:"legacy-variant"},"gemini-3.6-pro-low":{targetId:"gemini-3.6-pro",level:"low",legacyVariantId:"gemini-3.6-pro-low",encoding:"legacy-variant"},"gemini-3.6-pro-medium":{targetId:"gemini-3.6-pro",level:"medium",legacyVariantId:"gemini-3.6-pro-medium",encoding:"legacy-variant"},"gemini-3.6-pro-max":{targetId:"gemini-3.6-pro",level:"max",legacyVariantId:"gemini-3.6-pro-max",encoding:"legacy-variant"},"gemini-3.6-pro-thinking-low":{targetId:"gemini-3.6-pro",level:"low",legacyVariantId:"gemini-3.6-pro-thinking-low",encoding:"legacy-variant"},"gemini-3.6-pro-thinking-medium":{targetId:"gemini-3.6-pro",level:"medium",legacyVariantId:"gemini-3.6-pro-thinking-medium",encoding:"legacy-variant"},"gemini-3.6-pro-thinking-max":{targetId:"gemini-3.6-pro",level:"max",legacyVariantId:"gemini-3.6-pro-thinking-max",encoding:"legacy-variant"},"gemini-3.6-pro-low-fast":{targetId:"gemini-3.6-pro-low-fast",legacyVariantId:"gemini-3.6-pro-low-fast",encoding:"legacy-variant"},"gemini-3.6-pro-medium-fast":{targetId:"gemini-3.6-pro-medium-fast",legacyVariantId:"gemini-3.6-pro-medium-fast",encoding:"legacy-variant"},"gemini-3.6-pro-max-fast":{targetId:"gemini-3.6-pro-max-fast",legacyVariantId:"gemini-3.6-pro-max-fast",encoding:"legacy-variant"},"gemini-3.5-pro-low":{targetId:"gemini-3.5-pro",level:"low",legacyVariantId:"gemini-3.5-pro-low",encoding:"legacy-variant"},"gemini-3.5-pro-medium":{targetId:"gemini-3.5-pro",level:"medium",legacyVariantId:"gemini-3.5-pro-medium",encoding:"legacy-variant"},"gemini-3.5-pro-max":{targetId:"gemini-3.5-pro",level:"max",legacyVariantId:"gemini-3.5-pro-max",encoding:"legacy-variant"},"gemini-3.5-pro-thinking-low":{targetId:"gemini-3.5-pro",level:"low",legacyVariantId:"gemini-3.5-pro-thinking-low",encoding:"legacy-variant"},"gemini-3.5-pro-thinking-medium":{targetId:"gemini-3.5-pro",level:"medium",legacyVariantId:"gemini-3.5-pro-thinking-medium",encoding:"legacy-variant"},"gemini-3.5-pro-thinking-max":{targetId:"gemini-3.5-pro",level:"max",legacyVariantId:"gemini-3.5-pro-thinking-max",encoding:"legacy-variant"},"gemini-3.5-pro-low-fast":{targetId:"gemini-3.5-pro-low-fast",legacyVariantId:"gemini-3.5-pro-low-fast",encoding:"legacy-variant"},"gemini-3.5-pro-medium-fast":{targetId:"gemini-3.5-pro-medium-fast",legacyVariantId:"gemini-3.5-pro-medium-fast",encoding:"legacy-variant"},"gemini-3.5-pro-max-fast":{targetId:"gemini-3.5-pro-max-fast",legacyVariantId:"gemini-3.5-pro-max-fast",encoding:"legacy-variant"},"composer-2.6-low":{targetId:"composer-2.6",level:"low",legacyVariantId:"composer-2.6-low",encoding:"legacy-variant"},"composer-2.6-medium":{targetId:"composer-2.6",level:"medium",legacyVariantId:"composer-2.6-medium",encoding:"legacy-variant"},"composer-2.6-max":{targetId:"composer-2.6",level:"max",legacyVariantId:"composer-2.6-max",encoding:"legacy-variant"},"composer-2.6-thinking-low":{targetId:"composer-2.6",level:"low",legacyVariantId:"composer-2.6-thinking-low",encoding:"legacy-variant"},"composer-2.6-thinking-medium":{targetId:"composer-2.6",level:"medium",legacyVariantId:"composer-2.6-thinking-medium",encoding:"legacy-variant"},"composer-2.6-thinking-max":{targetId:"composer-2.6",level:"max",legacyVariantId:"composer-2.6-thinking-max",encoding:"legacy-variant"},"composer-2.6-low-fast":{targetId:"composer-2.6-low-fast",legacyVariantId:"composer-2.6-low-fast",encoding:"legacy-variant"},"composer-2.6-medium-fast":{targetId:"composer-2.6-medium-fast",legacyVariantId:"composer-2.6-medium-fast",encoding:"legacy-variant"},"composer-2.6-max-fast":{targetId:"composer-2.6-max-fast",legacyVariantId:"composer-2.6-max-fast",encoding:"legacy-variant"},"composer-2.6-lite-low":{targetId:"composer-2.6-lite",level:"low",legacyVariantId:"composer-2.6-lite-low",encoding:"legacy-variant"},"composer-2.6-lite-medium":{targetId:"composer-2.6-lite",level:"medium",legacyVariantId:"composer-2.6-lite-medium",encoding:"legacy-variant"},"composer-2.6-lite-max":{targetId:"composer-2.6-lite",level:"max",legacyVariantId:"composer-2.6-lite-max",encoding:"legacy-variant"},"composer-2.6-lite-thinking-low":{targetId:"composer-2.6-lite",level:"low",legacyVariantId:"composer-2.6-lite-thinking-low",encoding:"legacy-variant"},"composer-2.6-lite-thinking-medium":{targetId:"composer-2.6-lite",level:"medium",legacyVariantId:"composer-2.6-lite-thinking-medium",encoding:"legacy-variant"},"composer-2.6-lite-thinking-max":{targetId:"composer-2.6-lite",level:"max",legacyVariantId:"composer-2.6-lite-thinking-max",encoding:"legacy-variant"},"composer-2.6-lite-low-fast":{targetId:"composer-2.6-lite-low-fast",legacyVariantId:"composer-2.6-lite-low-fast",encoding:"legacy-variant"},"composer-2.6-lite-medium-fast":{targetId:"composer-2.6-lite-medium-fast",legacyVariantId:"composer-2.6-lite-medium-fast",encoding:"legacy-variant"},"composer-2.6-lite-max-fast":{targetId:"composer-2.6-lite-max-fast",legacyVariantId:"composer-2.6-lite-max-fast",encoding:"legacy-variant"},"deepseek-v4-low":{targetId:"deepseek-v4",level:"low",legacyVariantId:"deepseek-v4-low",encoding:"legacy-variant"},"deepseek-v4-medium":{targetId:"deepseek-v4",level:"medium",legacyVariantId:"deepseek-v4-medium",encoding:"legacy-variant"},"deepseek-v4-max":{targetId:"deepseek-v4",level:"max",legacyVariantId:"deepseek-v4-max",encoding:"legacy-variant"},"deepseek-v4-thinking-low":{targetId:"deepseek-v4",level:"low",legacyVariantId:"deepseek-v4-thinking-low",encoding:"legacy-variant"},"deepseek-v4-thinking-medium":{targetId:"deepseek-v4",level:"medium",legacyVariantId:"deepseek-v4-thinking-medium",encoding:"legacy-variant"},"deepseek-v4-thinking-max":{targetId:"deepseek-v4",level:"max",legacyVariantId:"deepseek-v4-thinking-max",encoding:"legacy-variant"},"deepseek-v4-low-fast":{targetId:"deepseek-v4-low-fast",legacyVariantId:"deepseek-v4-low-fast",encoding:"legacy-variant"},"deepseek-v4-medium-fast":{targetId:"deepseek-v4-medium-fast",legacyVariantId:"deepseek-v4-medium-fast",encoding:"legacy-variant"},"deepseek-v4-max-fast":{targetId:"deepseek-v4-max-fast",legacyVariantId:"deepseek-v4-max-fast",encoding:"legacy-variant"}}};var P="parameters",V="variant-id";function ladder(values,encoding=P){let out={};for(let value of values)out[value==="none"?"off":value]={value,encoding};return out}var CLAUDE_ORDER=["thinking","context","effort"],GPT_ORDER=["context","reasoning","fast"];function claude(window,maxWindow,levels,defaultContext){return{evidence:"available-models",window,maxWindow,parameterOrder:CLAUDE_ORDER,defaultContext,requestContext:window>=1e6?"1m":defaultContext,levels:ladder(levels)}}function gpt(levels,order=GPT_ORDER,window=4e5,maxWindow=4e5){return{evidence:"available-models",window,maxWindow,parameterOrder:order,defaultContext:"272k",requestContext:order.includes("context")&&window>=1e6?"1m":void 0,levels:ladder(levels)}}var CURSOR_MODEL_CAPABILITIES={"claude-fable-5":claude(1e6,1e6,["low","medium","high","xhigh","max"],"300k"),"claude-sonnet-5":claude(1e6,1e6,["low","medium","high","xhigh","max"],"300k"),"claude-opus-4-7":claude(1e6,1e6,["low","medium","high","xhigh","max"],"300k"),"claude-opus-4-8":claude(1e6,1e6,["low","medium","high","xhigh","max"],"300k"),"claude-opus-5":claude(1e6,1e6,["low","medium","high","xhigh","max"],"300k"),"claude-4.6-opus":claude(1e6,1e6,["high","max"],"200k"),"claude-4.6-sonnet":claude(1e6,1e6,["medium"],"200k"),"claude-4.5-opus":{evidence:"available-models",window:2e5,parameterOrder:["thinking"],levels:{high:{value:"high",encoding:V}}},"gpt-5.6-sol":gpt(["none","low","medium","high","xhigh","max"],GPT_ORDER,1e6,1e6),"gpt-5.6-luna":gpt(["none","low","medium","high","xhigh","max"],GPT_ORDER,1e6,1e6),"gpt-5.6-terra":gpt(["none","low","medium","high","xhigh","max"],GPT_ORDER,272e3,272e3),"gpt-5.5":{...gpt(["none","low","medium","high"],GPT_ORDER,1e6,1e6),levels:{...ladder(["none","low","medium","high"]),xhigh:{value:"extra-high",encoding:P}}},"gpt-5.3-codex":{...gpt([],["reasoning","fast"]),maxWindow:void 0,defaultContext:void 0,levels:{...ladder(["low","medium","high"]),xhigh:{value:"extra-high",encoding:P}}},"gpt-5.1":{...gpt([],["reasoning"]),maxWindow:void 0,defaultContext:void 0,levels:ladder(["low","high"])},"gpt-5.2":{...gpt([],["reasoning"]),maxWindow:void 0,defaultContext:void 0,levels:{...ladder(["low","high"]),xhigh:{value:"xhigh",encoding:V}}},"gpt-5.4":{...gpt([],["reasoning"]),maxWindow:void 0,defaultContext:void 0,levels:{...ladder(["low","medium","high"]),xhigh:{value:"xhigh",encoding:V}}},"gpt-5.4-mini":{evidence:"available-models",window:4e5,parameterOrder:[],levels:ladder(["none","low","medium","high","xhigh"],V)},"gpt-5.4-nano":{...gpt([],["reasoning"]),maxWindow:void 0,defaultContext:void 0,levels:ladder(["none","low","medium","high","xhigh"])},"gemini-3.7-flash":{evidence:"cli-live",window:1048576,parameterOrder:["effort"],levels:ladder(["low","medium","high"])},"gemini-3.6-flash":{evidence:"suffix-only",window:1048576,parameterOrder:[],levels:ladder(["minimal","low","medium","high"],V)},"cursor-grok-4.6":{evidence:"available-models",window:5e5,parameterOrder:["effort","fast"],levels:ladder(["low","medium","high","xhigh"])},"cursor-grok-4.5":{evidence:"suffix-only",window:5e5,parameterOrder:[],levels:ladder(["low","medium","high"],V)},"glm-5.2":{evidence:"available-models",window:1e6,parameterOrder:["reasoning"],levels:ladder(["high","max"])},"kimi-k3":{evidence:"available-models",window:1048576,parameterOrder:["reasoning"],levels:ladder(["low","high","max"])},"composer-2.5":{evidence:"available-models",window:2e5,parameterOrder:["fast"],levels:{}},"claude-haiku-4-5":{evidence:"available-models",window:2e5,parameterOrder:["thinking"],levels:{}},"claude-4-sonnet":{evidence:"available-models",window:2e5,parameterOrder:["thinking","context"],defaultContext:"200k",levels:{}},"claude-4.5-sonnet":{evidence:"available-models",window:2e5,parameterOrder:["thinking","context"],defaultContext:"200k",levels:{}},"kimi-k2.7-code":{evidence:"available-models",window:262144,parameterOrder:[],levels:{}},"gemini-3-flash":{evidence:"available-models",window:1e6,parameterOrder:[],levels:{}},"gemini-3.1-pro":{evidence:"available-models",window:1e6,parameterOrder:[],levels:{}},"gemini-3.5-flash":{evidence:"available-models",window:1048576,parameterOrder:[],levels:{}},"gpt-5-mini":{evidence:"available-models",window:4e5,parameterOrder:[],levels:{}}},ALIASES=cursor_variant_aliases_default.aliases,LEVEL_TOKENS=["minimal","low","medium","high","extra-high","xhigh","max","none"];function parseCursorVariantId(originalId){let rest=originalId,fast=!1;rest.endsWith("-fast")&&(fast=!0,rest=rest.slice(0,-5));let level,thinking,alternation=LEVEL_TOKENS.join("|"),patterns=[[new RegExp(`-thinking-(${alternation})$`),!0],[new RegExp(`-(${alternation})-thinking$`),!0]];for(let[pattern,flag]of patterns){let match=rest.match(pattern);if(match)return level=match[1],thinking=flag,rest=rest.slice(0,match.index),{baseId:rest,level,thinking,fast,originalId}}if(rest.endsWith("-thinking"))return{baseId:rest.slice(0,-9),level,thinking:!0,fast,originalId};let levelMatch=rest.match(new RegExp(`-(${alternation})$`));return levelMatch&&(level=levelMatch[1],thinking=!1,rest=rest.slice(0,levelMatch.index)),{baseId:rest,level,thinking,fast,originalId}}function getCursorVariantAlias(originalId){return ALIASES[originalId]}function getCursorBaseIdForVariant(originalId){let alias=ALIASES[originalId];if(alias)return parseCursorVariantId(alias.targetId).baseId}function getCursorCapabilityForBase(baseId){return CURSOR_MODEL_CAPABILITIES[baseId]}var ALL_LEVELS=["off","minimal","low","medium","high","xhigh","max"],FALLBACK_WINDOW=2e5,STATIC_TARGETS=new Set(Object.values(cursor_variant_aliases_default.aliases).map(alias=>alias.targetId));function isClaude(baseId){return baseId.startsWith("claude-")}function cleanName(members,baseId,thinkingMode){let levelWords=/(Minimal|Low|Medium|High|Extra High|XHigh|Max|None)/g,name=(members.find(member=>member.level==="high")??members.find(member=>member.level==="medium")??members.find(member=>member.level==="low")??members[0]).raw.name;return name=name.replace(/\s*\(NO ZDR\)\s*/g," ").trim(),name=name.replace(new RegExp(`\\s+${levelWords.source}\\b`,"g"),""),name=name.replace(/\s+Fast\b/g,""),thinkingMode!==!0&&(name=name.replace(/\s+Thinking\b/g,"")),name=name.replace(/\u0001/g,"(NO ZDR)").replace(/\s+/g," ").trim(),name.length===0&&(name=baseId),name}function buildLevelMap(members,capability){let observed=new Set(members.map(member=>member.level).filter(level=>level!==void 0)),map={};for(let level of ALL_LEVELS){if(level==="off"){let offSpec=capability?.levels.off;map.off=offSpec!==void 0&&observed.has("none")?offSpec.value:null;continue}let spec=capability?.levels[level];map[level]=spec!==void 0&&(observed.has(level)||observed.has(spec.value))?spec.value:null}return map}function pickRepresentative(members){let withLevels=members.filter(member=>member.level!==void 0&&member.level!=="none"),pool=withLevels.length>0?withLevels:members,order=["medium","low","minimal","high","xhigh","extra-high","max","none"];return[...pool].sort((a,b)=>{let ai=order.indexOf(a.level??"none"),bi=order.indexOf(b.level??"none");return ai!==bi?ai-bi:a.alias.legacyVariantId.localeCompare(b.alias.legacyVariantId)})[0].alias.legacyVariantId}function normalizeDerivedLevel(token){switch(token){case"none":return"off";case"extra-high":return"xhigh";case"minimal":case"low":case"medium":case"high":case"xhigh":case"max":return token;default:return}}function buildDerivedLevelMap(members){let map=Object.fromEntries(ALL_LEVELS.map(level=>[level,null]));for(let member of members){let level=member.alias.level;level!==void 0&&member.level!==void 0&&map[level]===null&&(map[level]=member.level)}return map}function buildDerivedVariantIds(members){let map={};for(let member of members){let level=member.alias.level;level!==void 0&&map[level]===void 0&&(map[level]=member.raw.id)}return map}function deriveCursorVariantAliases(ids){let families=new Map,rawIds=new Set(ids);for(let id of ids){if(getCursorVariantAlias(id)!==void 0)continue;let parsed=parseCursorVariantId(id);if(parsed.fast||parsed.level===void 0||parsed.baseId==="")continue;let level=normalizeDerivedLevel(parsed.level);if(level===void 0)continue;let targetId=parsed.thinking===!0?`${parsed.baseId}-thinking`:parsed.baseId,family=families.get(targetId)??{targetId,levels:new Set,members:[]};family.levels.add(level),family.members.push([id,level,parsed.level]),families.set(targetId,family)}let derived=new Map;for(let family of families.values()){if(family.levels.size<2||STATIC_TARGETS.has(family.targetId)||getCursorVariantAlias(family.targetId)!==void 0||rawIds.has(family.targetId))continue;let chosen=new Map;for(let[id,level,suffix]of family.members){let previous=chosen.get(level);if(previous===void 0){chosen.set(level,id);continue}let previousSuffix=parseCursorVariantId(previous).level;(suffix===level&&previousSuffix!==level||suffix===level==(previousSuffix===level)&&id<previous)&&chosen.set(level,id)}for(let[level,id]of chosen)derived.set(id,{targetId:family.targetId,legacyVariantId:id,encoding:"legacy-variant",level})}return derived}function normalizeCursorCatalog(rawEntries){let derived=deriveCursorVariantAliases(rawEntries.map(raw=>raw.id)),groups=new Map,order=[];for(let raw of rawEntries){let alias=getCursorVariantAlias(raw.id)??derived.get(raw.id);if(!alias){let parsed2=parseCursorVariantId(raw.id),key2=`unknown${parsed2.baseId}${raw.id}`;groups.has(key2)||order.push(key2);let member={raw,alias:{targetId:raw.id,legacyVariantId:raw.id,encoding:"legacy-variant"},level:parsed2.level,thinking:parsed2.thinking,fast:parsed2.fast};groups.set(key2,[member]);continue}let parsed=parseCursorVariantId(raw.id),key=`${alias.targetId}${parsed.fast}`;groups.has(key)||(order.push(key),groups.set(key,[])),groups.get(key).push({raw,alias,level:parsed.level,thinking:parsed.thinking,fast:parsed.fast})}let out=[];for(let key of order){let members=groups.get(key),first=members[0],baseParsed=parseCursorVariantId(first.alias.targetId),derivedGroup=members.every(member=>derived.has(member.raw.id)),baseId=derivedGroup?parseCursorVariantId(first.raw.id).baseId:baseParsed.baseId,capability=CURSOR_MODEL_CAPABILITIES[baseId],isGrouped=members.length>1||first.alias.targetId!==first.raw.id,efforts=members.filter(member=>member.level!==void 0&&member.level!=="none");if(isGrouped&&efforts.length>0&&!first.fast){let thinkingMode=isClaude(baseId)?first.thinking===!0:void 0;out.push({id:first.alias.targetId,name:cleanName(members,baseId,thinkingMode),reasoning:!0,thinkingLevelMap:derivedGroup?buildDerivedLevelMap(members):buildLevelMap(members,capability),window:capability?.window??FALLBACK_WINDOW,...capability?.maxWindow!==void 0?{maxWindow:capability.maxWindow}:{},input:[...new Set(members.flatMap(member=>member.raw.input))],cursorMaxMode:members.some(member=>member.raw.cursorMaxMode),capabilityId:baseId,...thinkingMode!==void 0?{thinkingMode}:{},representativeVariantId:pickRepresentative(members),legacyAliases:members.map(member=>member.alias.legacyVariantId).sort(),...derivedGroup?{variantIds:buildDerivedVariantIds(members)}:{}});continue}for(let member of members){let memberBase=parseCursorVariantId(member.raw.id).baseId,memberCapability=CURSOR_MODEL_CAPABILITIES[memberBase];out.push({id:member.raw.id,name:member.raw.name,reasoning:!1,window:memberCapability?.window??FALLBACK_WINDOW,...memberCapability?.maxWindow!==void 0?{maxWindow:memberCapability.maxWindow}:{},input:[...member.raw.input],cursorMaxMode:member.raw.cursorMaxMode,legacyAliases:[member.alias.legacyVariantId]})}}return out}function identityCompat(model){return model.compat?.cursorReasoning}function suffixAliasId(compat,level,spec){let suffixes=level==="off"?["none"]:spec.value===level?[spec.value]:[spec.value,level];for(let suffix of suffixes){let candidates=compat.thinkingMode===!0?[`${compat.capabilityId}-thinking-${suffix}`,`${compat.capabilityId}-${suffix}-thinking`]:[`${compat.capabilityId}-${suffix}`];for(let candidate of candidates){let alias=getCursorVariantAlias(candidate);if(alias)return alias.legacyVariantId}}}function buildParameters(capabilityId,value,thinkingMode){let capability=CURSOR_MODEL_CAPABILITIES[capabilityId];if(!capability)return[];let out=[];for(let id of capability.parameterOrder)switch(id){case"thinking":out.push({id,value:thinkingMode===!0?"true":"false"});break;case"context":{let context=capability.requestContext??capability.defaultContext;context!==void 0&&out.push({id,value:context});break}case"effort":case"reasoning":out.push({id,value});break;case"fast":out.push({id,value:"false"});break}return out}function resolveCursorSelectionDescriptor(model,selection){let compat=identityCompat(model),fallback={modelId:model.upstreamModelId??model.id,parameters:[]};if(!compat)return fallback;if(selection===void 0)return{modelId:compat.representativeVariantId,parameters:[]};if(selection.source==="legacy-variant"){let legacyId=selection.legacyVariantId;return legacyId!==void 0&&(getCursorVariantAlias(legacyId)!==void 0||Object.values(compat.variantIds??{}).includes(legacyId))?{modelId:legacyId,parameters:[]}:{modelId:compat.representativeVariantId,parameters:[]}}let derivedVariantId=compat.variantIds?.[selection.level];if(derivedVariantId!==void 0)return{modelId:derivedVariantId,parameters:[]};if(compat.variantIds!==void 0)return{modelId:compat.representativeVariantId,parameters:[]};let capability=CURSOR_MODEL_CAPABILITIES[compat.capabilityId],spec=capability?.levels[selection.level];if(!capability||!spec)return{modelId:compat.representativeVariantId,parameters:[]};let suffixId=suffixAliasId(compat,selection.level,spec);return suffixId!==void 0?{modelId:suffixId,parameters:[]}:spec.encoding==="variant-id"?{modelId:compat.representativeVariantId,parameters:[]}:{modelId:compat.capabilityId,parameters:buildParameters(compat.capabilityId,spec.value,compat.thinkingMode)}}function renderCursorCliModelString(model,selection){let resolved=resolveCursorSelectionDescriptor(model,selection);if(resolved.parameters.length===0)return resolved.modelId;let args=resolved.parameters.map(parameter=>`${parameter.id}=${parameter.value}`).join(",");return`${resolved.modelId}[${args}]`}var __rewriteRelativeImportExtension=function(path,preserveJsx){return typeof path=="string"&&/^\.\.?\//.test(path)?path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(m,tsx,d,ext,cm){return tsx?preserveJsx?".jsx":".js":d&&(!ext||!cm)?m:d+ext+"."+cm.toLowerCase()+"js"}):path},_existsSync=null,_homedir=null,_join=null,dynamicImport=specifier=>import(__rewriteRelativeImportExtension(specifier)),NODE_FS_SPECIFIER="node:fs",NODE_OS_SPECIFIER="node:os",NODE_PATH_SPECIFIER="node:path";typeof process<"u"&&(process.versions?.node||process.versions?.bun)&&(dynamicImport(NODE_FS_SPECIFIER).then(m=>{_existsSync=m.existsSync}),dynamicImport(NODE_OS_SPECIFIER).then(m=>{_homedir=m.homedir}),dynamicImport(NODE_PATH_SPECIFIER).then(m=>{_join=m.join}));var ANTHROPIC_AUTH_TOKEN_ENV="ANTHROPIC_AUTH_TOKEN",ANTHROPIC_OAUTH_TOKEN_ENV="ANTHROPIC_OAUTH_TOKEN",ANTHROPIC_API_KEY_ENV="ANTHROPIC_API_KEY",cachedVertexAdcCredentialsExists=null;function hasVertexAdcCredentials(env){let explicitCredentialsPath=env?.GOOGLE_APPLICATION_CREDENTIALS;if(explicitCredentialsPath)return _existsSync?_existsSync(explicitCredentialsPath):!1;if(cachedVertexAdcCredentialsExists===null){if(!_existsSync||!_homedir||!_join)return typeof process<"u"&&(process.versions?.node||process.versions?.bun)||(cachedVertexAdcCredentialsExists=!1),!1;let gacPath=getProviderEnvValue("GOOGLE_APPLICATION_CREDENTIALS",env);gacPath?cachedVertexAdcCredentialsExists=_existsSync(gacPath):cachedVertexAdcCredentialsExists=_existsSync(_join(_homedir(),".config","gcloud","application_default_credentials.json"))}return cachedVertexAdcCredentialsExists}function getApiKeyEnvVars(provider){if(provider==="github-copilot")return["COPILOT_GITHUB_TOKEN"];if(provider==="anthropic")return[ANTHROPIC_AUTH_TOKEN_ENV,ANTHROPIC_OAUTH_TOKEN_ENV,ANTHROPIC_API_KEY_ENV];let envVar={"alibaba-token-plan":"ALIBABA_TOKEN_PLAN_API_KEY","ant-ling":"ANT_LING_API_KEY","qwen-token-plan":"QWEN_TOKEN_PLAN_API_KEY","qwen-token-plan-cn":"QWEN_TOKEN_PLAN_CN_API_KEY","qwen-token-plan-individual":"QWEN_TOKEN_PLAN_API_KEY",openai:"OPENAI_API_KEY",ollama:"OLLAMA_API_KEY","azure-openai-responses":"AZURE_OPENAI_API_KEY",nvidia:"NVIDIA_API_KEY",deepseek:"DEEPSEEK_API_KEY",google:"GEMINI_API_KEY","google-vertex":"GOOGLE_CLOUD_API_KEY",groq:"GROQ_API_KEY",cerebras:"CEREBRAS_API_KEY",venice:"VENICE_API_KEY",xai:"XAI_API_KEY",radius:"RADIUS_API_KEY",openrouter:"OPENROUTER_API_KEY","vercel-ai-gateway":"AI_GATEWAY_API_KEY",opengateway:"OPENGATEWAY_API_KEY",zai:"ZAI_API_KEY","zai-coding-cn":"ZAI_CODING_CN_API_KEY",mistral:"MISTRAL_API_KEY",minimax:"MINIMAX_API_KEY","minimax-cn":"MINIMAX_CN_API_KEY",moonshotai:"MOONSHOT_API_KEY","moonshotai-cn":"MOONSHOT_API_KEY",huggingface:"HF_TOKEN",fireworks:"FIREWORKS_API_KEY",together:"TOGETHER_API_KEY",baseten:"BASETEN_API_KEY",bai:"BAI_API_KEY",opencode:"OPENCODE_API_KEY","opencode-go":"OPENCODE_API_KEY","kimi-coding":"KIMI_API_KEY","cloudflare-workers-ai":"CLOUDFLARE_API_KEY","cloudflare-ai-gateway":"CLOUDFLARE_API_KEY",xiaomi:"XIAOMI_API_KEY","xiaomi-token-plan-cn":"XIAOMI_TOKEN_PLAN_CN_API_KEY","xiaomi-token-plan-ams":"XIAOMI_TOKEN_PLAN_AMS_API_KEY","xiaomi-token-plan-sgp":"XIAOMI_TOKEN_PLAN_SGP_API_KEY"}[provider];return envVar?[envVar]:void 0}function findEnvKeys(provider,env){let envVars=getApiKeyEnvVars(provider);if(!envVars)return;let found=envVars.filter(envVar=>!!getProviderEnvValue(envVar,env));return found.length>0?found:void 0}function getEnvApiKey(provider,env){let envKeys=findEnvKeys(provider,env);if(envKeys?.[0]){let apiKeyEnv=provider==="anthropic"?envKeys.find(key=>key!==ANTHROPIC_AUTH_TOKEN_ENV):envKeys[0];if(apiKeyEnv)return getProviderEnvValue(apiKeyEnv,env)}if(provider==="google-vertex"){let hasCredentials=hasVertexAdcCredentials(env),hasProject=!!(getProviderEnvValue("GOOGLE_CLOUD_PROJECT",env)||getProviderEnvValue("GCLOUD_PROJECT",env)),hasLocation=!!getProviderEnvValue("GOOGLE_CLOUD_LOCATION",env);if(hasCredentials&&hasProject&&hasLocation)return"<authenticated>"}if(provider==="amazon-bedrock"&&(getProviderEnvValue("AWS_PROFILE",env)||getProviderEnvValue("AWS_ACCESS_KEY_ID",env)&&getProviderEnvValue("AWS_SECRET_ACCESS_KEY",env)||getProviderEnvValue("AWS_BEARER_TOKEN_BEDROCK",env)||getProviderEnvValue("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI",env)||getProviderEnvValue("AWS_CONTAINER_CREDENTIALS_FULL_URI",env)||getProviderEnvValue("AWS_WEB_IDENTITY_TOKEN_FILE",env)))return"<authenticated>"}var ImagesModelsImpl=class{constructor(options){this.providers=new Map,this.credentials=options?.credentials??new InMemoryCredentialStore,this.authContext=options?.authContext??defaultProviderAuthContext()}setProvider(provider){this.providers.set(provider.id,provider)}deleteProvider(id){this.providers.delete(id)}clearProviders(){this.providers.clear()}getProviders(){return Array.from(this.providers.values())}getProvider(id){return this.providers.get(id)}getModels(provider){if(provider!==void 0){let entry=this.providers.get(provider);if(!entry)return[];try{return entry.getModels()}catch{return[]}}let models=[];for(let entry of this.providers.values())try{models.push(...entry.getModels())}catch{}return models}getModel(provider,id){return this.getModels(provider).find(model=>model.id===id)}async refresh(provider){if(provider!==void 0){let entry=this.providers.get(provider);if(!entry?.refreshModels)return;try{await entry.refreshModels()}catch(error){throw error instanceof ModelsError?error:new ModelsError("model_source",`Model refresh failed for ${provider}`,{cause:error})}return}await Promise.allSettled(Array.from(this.providers.values(),async entry=>entry.refreshModels?.()))}async getAuth(providerOrModel,overrides){let providerId=typeof providerOrModel=="string"?providerOrModel:providerOrModel.provider,provider=this.providers.get(providerId);if(provider)return resolveProviderAuth(provider,this.credentials,this.authContext,overrides)}async generateImages(model,context,options){try{let provider=this.providers.get(model.provider);if(!provider)throw new ModelsError("provider",`Unknown provider: ${model.provider}`);let resolution=await this.getAuth(model,{apiKey:options?.apiKey,env:options?.env,signal:options?.signal}),auth=resolution?.auth;if(!auth)return provider.generateImages(model,context,options);let requestModel=auth.baseUrl?{...model,baseUrl:auth.baseUrl}:model,apiKey=options?.apiKey??auth.apiKey,headers=auth.headers||options?.headers?{...auth.headers,...options?.headers}:void 0,env=resolution.env||options?.env?{...resolution.env??{},...options?.env??{}}:void 0;return await provider.generateImages(requestModel,context,{...options,apiKey,headers,env})}catch(error){return{api:model.api,provider:model.provider,model:model.id,output:[],stopReason:"error",errorMessage:error instanceof Error?error.message:String(error),timestamp:Date.now()}}}};function createImagesModels(options){return new ImagesModelsImpl(options)}function createImagesProvider(input){let models=input.models,inflightRefresh,refreshModels=input.refreshModels;return{id:input.id,name:input.name??input.id,auth:input.auth,getModels:()=>models,refreshModels:refreshModels?()=>(inflightRefresh??=(async()=>{try{models=await refreshModels()}finally{inflightRefresh=void 0}})(),inflightRefresh):void 0,generateImages:(model,context,options)=>input.api.generateImages(model,context,options)}}function emit(segments,text,scan,recoveryBoundary=!1){if(text.length===0)return;let previous=segments.at(-1);previous?.scan===scan&&!previous.recoveryBoundary&&!recoveryBoundary?segments[segments.length-1]={text:previous.text+text,scan}:segments.push(recoveryBoundary?{text,scan,recoveryBoundary:!0}:{text,scan})}function isLineBreak(character){return character==="\r"||character===`
|
|
150
150
|
`}function createRecoveryCodeMask(){let state={kind:"plain"},atLineStart=!0,leadingSpaces=0,plainIndent="",pendingTickCount=0,pendingDeferredTicks=0,pendingAtLineStart=!1,finished=!1;function flushPlainIndent(segments,scan,recoveryBoundary=!1){emit(segments,plainIndent,scan,recoveryBoundary),plainIndent=""}function updateLinePosition(character){isLineBreak(character)?(atLineStart=!0,leadingSpaces=0):atLineStart=!1}function completePendingTicks(segments){if(pendingTickCount===0)return;let tickCount=pendingTickCount,startedAtLineStart=pendingAtLineStart;pendingTickCount=0,pendingAtLineStart=!1,state.kind==="plain"?startedAtLineStart&&tickCount>=3?(flushPlainIndent(segments,!1,!0),state={kind:"fenced",delimiterLength:tickCount,closingLine:!1}):(flushPlainIndent(segments,!0),pendingDeferredTicks>0&&emit(segments,"`".repeat(pendingDeferredTicks),!1,!0),state={kind:"inline",delimiterLength:tickCount}):state.kind==="inline"?tickCount===state.delimiterLength&&(state={kind:"plain"}):startedAtLineStart&&tickCount>=state.delimiterLength&&(state.closingLine=!0),pendingDeferredTicks=0,atLineStart=!1,leadingSpaces=0}function appendTicks(segments,ticks){pendingTickCount===0&&(pendingAtLineStart=atLineStart),pendingTickCount+=ticks.length;let offset=0;if(state.kind==="plain"&&pendingAtLineStart&&plainIndent.length>0&&pendingDeferredTicks<3){let deferred=Math.min(3-pendingDeferredTicks,ticks.length);pendingDeferredTicks+=deferred,offset=deferred,pendingDeferredTicks===3&&(flushPlainIndent(segments,!1,!0),emit(segments,"```",!1),pendingDeferredTicks=0)}offset<ticks.length&&emit(segments,ticks.slice(offset),!1,state.kind==="plain"&&pendingTickCount===ticks.length)}function processPlainCharacter(segments,character){if(atLineStart&&character===" "&&leadingSpaces<3){plainIndent+=character,leadingSpaces+=1;return}flushPlainIndent(segments,!0),emit(segments,character,!0),updateLinePosition(character)}function processInlineCharacter(segments,character){emit(segments,character,!1),isLineBreak(character)&&(state={kind:"plain"}),updateLinePosition(character)}function processFencedCharacter(segments,character){if(state.kind==="fenced"){if(atLineStart&&character===" "&&leadingSpaces<3){emit(segments,character,!1),leadingSpaces+=1;return}emit(segments,character,!1),state.closingLine&&isLineBreak(character)&&(state={kind:"plain"}),updateLinePosition(character)}}function processText(segments,text){for(let index=0;index<text.length;){if(text[index]==="`"){let end=index+1;for(;text[end]==="`";)end+=1;appendTicks(segments,text.slice(index,end)),index=end;continue}completePendingTicks(segments);let character=text.charAt(index);state.kind==="plain"?processPlainCharacter(segments,character):state.kind==="inline"?processInlineCharacter(segments,character):processFencedCharacter(segments,character),index+=1}}function trackActiveText(text){for(let index=0;index<text.length;index+=1)updateLinePosition(text.charAt(index))}return{feed(text,options){if(finished)throw new Error("Recovery code mask is finished");let segments=[];return options?.activeInvoke?(completePendingTicks(segments),flushPlainIndent(segments,!0),emit(segments,text,!0),trackActiveText(text)):processText(segments,text),segments},finish(){if(finished)return[];let segments=[];return completePendingTicks(segments),state.kind==="plain"&&flushPlainIndent(segments,!0),finished=!0,segments}}}var XTML_TOOLS_OPEN="<|open|>tools<|sep|>",XTML_TOOLS_CLOSE="<|close|>tools<|sep|>",XTML_CALL_OPEN="<|open|>call ",XTML_CALL_CLOSE="<|close|>call<|sep|>",XTML_ARGUMENT_OPEN="<|open|>argument ",XTML_ARGUMENT_CLOSE="<|close|>argument<|sep|>",XTML_SEP="<|sep|>",XTML_OPEN_PREFIX="<|open|>",XTML_CLOSE_PREFIX="<|close|>",CHANNEL_NAME="[a-zA-Z_][a-zA-Z0-9_]*",STRUCTURAL_CHANNEL_NAME="(?:call|argument)\\b",SEPLESS_CHANNEL_NAME=`(?!${STRUCTURAL_CHANNEL_NAME})${CHANNEL_NAME}`,XTML_CHANNEL_MARKER_PATTERN=new RegExp([`<\\|(?:open|close)\\|>(?:${CHANNEL_NAME})?<\\|sep\\|>`,`<\\|(?:open|close)\\|>(?:${SEPLESS_CHANNEL_NAME})?(?=$|[^a-zA-Z0-9_])`,"<\\|sep\\|>"].join("|"),"g"),ANCHORED_CHANNEL_MARKER_PATTERN=new RegExp(`^(?:${XTML_CHANNEL_MARKER_PATTERN.source})`);function matchXtmlChannelMarker(text){return ANCHORED_CHANNEL_MARKER_PATTERN.exec(text)?.[0]}var ATTRIBUTE_PATTERN=/([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s<]+))/g;function parseXtmlAttributes(header){let attributes={};for(let match of header.matchAll(ATTRIBUTE_PATTERN)){let key=match[1];key&&(attributes[key]=match[2]??match[3]??match[4]??"")}return attributes}function getPartialXtmlSuffix(text,tokens){for(let token of tokens)for(let length=token.length-1;length>0;length-=1){let prefix=token.slice(0,length);if(text.endsWith(prefix))return prefix}return""}function coerceXtmlArgumentValue(raw,type){switch(type){case void 0:case"string":return{ok:!0,value:raw};case"number":{let parsed=Number(raw);return Number.isNaN(parsed)?{ok:!1}:{ok:!0,value:parsed}}case"boolean":return raw==="true"?{ok:!0,value:!0}:raw==="false"?{ok:!0,value:!1}:{ok:!1};case"object":case"array":try{return{ok:!0,value:JSON.parse(raw)}}catch{return{ok:!1}}default:return{ok:!0,value:raw}}}function parseCallBody(body,tool,options){let args={},rest=body;for(;rest=rest.replace(/^\s+/,""),!!rest.startsWith(XTML_ARGUMENT_OPEN);){let headerEnd=rest.indexOf(XTML_SEP,XTML_ARGUMENT_OPEN.length);if(headerEnd===-1)break;let attributes=parseXtmlAttributes(rest.slice(XTML_ARGUMENT_OPEN.length,headerEnd)),key=attributes.key,valueStart=headerEnd+XTML_SEP.length,valueEnd=rest.indexOf(XTML_ARGUMENT_CLOSE,valueStart);if(valueEnd===-1||!key)break;let coerced=coerceXtmlArgumentValue(rest.slice(valueStart,valueEnd),attributes.type);if(!coerced.ok)return options?.onError?.(`kimi-xtml: invalid value for argument "${key}" on tool "${tool.name}".`,{toolCall:rest.slice(0,valueEnd+XTML_ARGUMENT_CLOSE.length)}),null;args[key]=coerced.value,rest=rest.slice(valueEnd+XTML_ARGUMENT_CLOSE.length)}return args}function parseKimiXtmlGeneratedText(text,tools,options){let parsed=[],cursor=0;for(;cursor<text.length;){let blockStart=text.indexOf(XTML_TOOLS_OPEN,cursor);if(blockStart===-1)break;let bodyStart=blockStart+XTML_TOOLS_OPEN.length,blockEnd=text.indexOf(XTML_TOOLS_CLOSE,bodyStart),block=blockEnd===-1?text.slice(bodyStart):text.slice(bodyStart,blockEnd);cursor=blockEnd===-1?text.length:blockEnd+XTML_TOOLS_CLOSE.length;let callCursor=0;for(;callCursor<block.length;){let callStart=block.indexOf(XTML_CALL_OPEN,callCursor);if(callStart===-1)break;let headerEnd=block.indexOf(XTML_SEP,callStart+XTML_CALL_OPEN.length);if(headerEnd===-1)break;let attributes=parseXtmlAttributes(block.slice(callStart+XTML_CALL_OPEN.length,headerEnd)),bodyEnd=block.indexOf(XTML_CALL_CLOSE,headerEnd+XTML_SEP.length),callBody=bodyEnd===-1?block.slice(headerEnd+XTML_SEP.length):block.slice(headerEnd+XTML_SEP.length,bodyEnd);callCursor=bodyEnd===-1?block.length:bodyEnd+XTML_CALL_CLOSE.length;let name=attributes.tool,tool=name?tools.find(candidate=>candidate.name===name):void 0;if(!tool){options?.onError?.(`kimi-xtml: call for unknown tool "${name??""}".`,{toolCall:callBody});continue}let args=parseCallBody(callBody,tool,options);args&&parsed.push({name:tool.name,arguments:args})}}return parsed}var MARKER_PREFIXES=[XTML_OPEN_PREFIX,XTML_CLOSE_PREFIX,XTML_SEP];function findMarkerStart(text){return MARKER_PREFIXES.map(prefix=>text.indexOf(prefix)).filter(index=>index!==-1).sort((a,b)=>a-b)[0]}function couldExtendMarker(buffer,marker){if(marker.endsWith(XTML_SEP))return!1;let rest=buffer.slice(marker.length);return rest.length===0||XTML_SEP.startsWith(rest)}var STRUCTURAL_MARKER_OPENS=[XTML_CALL_OPEN,XTML_ARGUMENT_OPEN];function startsCompleteStructuralMarker(buffer){return STRUCTURAL_MARKER_OPENS.some(open=>buffer.startsWith(open))}function startsPartialStructuralMarker(buffer){return STRUCTURAL_MARKER_OPENS.some(open=>buffer.length<open.length&&open.startsWith(buffer))}function createXtmlRecoveryStreamParser(tools,options){let mask=createRecoveryCodeMask(),buffer="",mode="text",callIndex=-1,callName="",callArgs={},callStarted=!1,callInvalidReason=null,argumentKey="",argumentType;function resetCall(){callName="",callArgs={},callStarted=!1,callInvalidReason=null,argumentKey="",argumentType=void 0}function endCall(events,incomplete){if(!callStarted){resetCall();return}let event={type:"toolcall_end",index:callIndex,name:callName,id:`recovered-xtml-${callIndex}`,arguments:callArgs};incomplete&&(event.incomplete=!0,callInvalidReason&&(event.errorMessage=callInvalidReason)),events.push(event),resetCall(),mode="tools"}function processText(events){let markerIndex=findMarkerStart(buffer);if(markerIndex===void 0){let partial=getPartialXtmlSuffix(buffer,MARKER_PREFIXES),flushable=partial?buffer.slice(0,-partial.length):buffer;return flushable&&events.push({type:"text",text:flushable}),buffer=partial,!1}if(markerIndex>0)return events.push({type:"text",text:buffer.slice(0,markerIndex)}),buffer=buffer.slice(markerIndex),!0;if(startsCompleteStructuralMarker(buffer))return mode="tools",!0;if(startsPartialStructuralMarker(buffer))return!1;let marker=matchXtmlChannelMarker(buffer);return marker?couldExtendMarker(buffer,marker)?!1:(buffer=buffer.slice(marker.length),marker===XTML_TOOLS_OPEN&&(mode="tools"),!0):(events.push({type:"text",text:buffer.slice(0,2)}),buffer=buffer.slice(2),!0)}function process2(events){for(;;){if(mode==="text"){if(!processText(events))return;continue}if(mode==="tools"){let callStart=buffer.indexOf(XTML_CALL_OPEN),toolsEnd=buffer.indexOf(XTML_TOOLS_CLOSE);if(toolsEnd!==-1&&(callStart===-1||toolsEnd<callStart)){buffer=buffer.slice(toolsEnd+XTML_TOOLS_CLOSE.length),mode="text";continue}if(callStart===-1)return;buffer=buffer.slice(callStart+XTML_CALL_OPEN.length),mode="call-header";continue}if(mode==="call-header"||mode==="argument-header"){let sepIndex=buffer.indexOf(XTML_SEP);if(sepIndex===-1)return;let attributes=parseXtmlAttributes(buffer.slice(0,sepIndex));if(buffer=buffer.slice(sepIndex+XTML_SEP.length),mode==="call-header"){let name=attributes.tool??"";if(!tools.some(candidate=>candidate.name===name)){options?.onError?.(`kimi-xtml recovery: call for unknown tool "${name}".`,{}),mode="discard-call";continue}callIndex+=1,callName=name,callStarted=!0,events.push({type:"toolcall_start",index:callIndex,name,id:`recovered-xtml-${callIndex}`}),mode="call-body";continue}argumentKey=attributes.key??"",argumentType=attributes.type,mode="argument-value";continue}if(mode==="call-body"){let argStart=buffer.indexOf(XTML_ARGUMENT_OPEN),callEnd2=buffer.indexOf(XTML_CALL_CLOSE);if(callEnd2!==-1&&(argStart===-1||callEnd2<argStart)){buffer=buffer.slice(callEnd2+XTML_CALL_CLOSE.length),endCall(events,callInvalidReason!==null);continue}if(argStart===-1)return;buffer=buffer.slice(argStart+XTML_ARGUMENT_OPEN.length),mode="argument-header";continue}if(mode==="argument-value"){let valueEnd=buffer.indexOf(XTML_ARGUMENT_CLOSE);if(valueEnd===-1)return;let coerced=coerceXtmlArgumentValue(buffer.slice(0,valueEnd),argumentType);buffer=buffer.slice(valueEnd+XTML_ARGUMENT_CLOSE.length),coerced.ok?argumentKey&&(callArgs[argumentKey]=coerced.value,events.push({type:"toolcall_delta",index:callIndex,argumentsDelta:JSON.stringify(callArgs)})):(callInvalidReason=`kimi-xtml recovery: invalid value for argument "${argumentKey}".`,options?.onError?.(callInvalidReason,{toolCall:callName})),mode="call-body";continue}let callEnd=buffer.indexOf(XTML_CALL_CLOSE);if(callEnd===-1)return;buffer=buffer.slice(callEnd+XTML_CALL_CLOSE.length),resetCall(),mode="tools"}}function consume(segments){let events=[];for(let segment of segments){if(segment.scan){buffer+=segment.text,process2(events);continue}mode==="text"&&buffer&&(events.push({type:"text",text:buffer}),buffer=""),mode==="text"?events.push({type:"text",text:segment.text}):buffer+=segment.text}return events}return{feed(textDelta){return consume(mask.feed(textDelta))},interrupt(){let events=[];return mode==="text"&&buffer&&(events.push({type:"text",text:buffer}),buffer=""),events},finish(){let events=consume(mask.finish());if(mode==="text"){let rest=buffer;for(;;){let marker=matchXtmlChannelMarker(rest);if(!marker)break;rest=rest.slice(marker.length)}XTML_SEP.startsWith(rest)&&rest.length>0&&(rest=""),rest&&events.push({type:"text",text:rest})}else callStarted&&endCall(events,!0);return buffer="",mode="text",events}}}var NAMED_MARKER_PATTERN=/^<\|(open|close)\|>([a-zA-Z_][a-zA-Z0-9_]*)?/;function recoverThinkingContent(input){let mask=createRecoveryCodeMask(),channel="thinking",thinking="",response="",changed=!1,recoveredResponse=!1,append=text=>{channel==="response"?response+=text:thinking+=text},scan=text=>{let offset=0;for(let match of text.matchAll(XTML_CHANNEL_MARKER_PATTERN)){let index=match.index;if(index===void 0)continue;append(text.slice(offset,index));let named=NAMED_MARKER_PATTERN.exec(match[0]),action=named?.[1],name=named?.[2];changed=!0,action==="open"&&name==="response"?(channel="response",recoveredResponse=!0):(action==="open"&&name==="think"||action==="close"&&name==="response")&&(channel="thinking"),offset=index+match[0].length}append(text.slice(offset))};for(let segment of[...mask.feed(input),...mask.finish()])segment.scan?scan(segment.text):append(segment.text);return{thinking,response,changed,recoveredResponse}}function recoveredThinkingBlock(block,thinking){return{...block,thinking}}function strippedVisibleText(input){let mask=createRecoveryCodeMask(),text="",changed=!1;for(let segment of[...mask.feed(input),...mask.finish()]){if(!segment.scan){text+=segment.text;continue}let stripped=segment.text.replace(XTML_CHANNEL_MARKER_PATTERN,"");stripped!==segment.text&&(changed=!0),text+=stripped}return{text,changed}}function recoverKimiXtmlThinking(message){let changed=!1,thinkingChanged=!1,recoveredResponse=!1,content=[];for(let block of message.content){if(block.type==="text"){let stripped=strippedVisibleText(block.text);changed=changed||stripped.changed,content.push(stripped.changed?{...block,text:stripped.text}:block);continue}if(block.type!=="thinking"){content.push(block);continue}let recovered=recoverThinkingContent(block.thinking);changed=changed||recovered.changed,thinkingChanged=thinkingChanged||recovered.changed,recoveredResponse=recoveredResponse||recovered.recoveredResponse,content.push(recoveredThinkingBlock(block,recovered.thinking)),recovered.response.length>0&&content.push({type:"text",text:recovered.response})}return changed?{...message,content,diagnostics:thinkingChanged?[...message.diagnostics??[],{type:"kimi_xtml_thinking_recovery",timestamp:Date.now(),details:{recoveredResponse}}]:message.diagnostics}:message}function wrapStreamWithKimiThinkingRecovery(innerStream){let outerStream=new AssistantMessageEventStream;return(async()=>{try{for await(let event of innerStream){if(event.type==="done"){let message=recoverKimiXtmlThinking(event.message);outerStream.push({type:"done",reason:event.reason,message}),outerStream.end();return}if(event.type==="error"){outerStream.push(event),outerStream.end();return}outerStream.push(event)}outerStream.end(recoverKimiXtmlThinking(await innerStream.result()))}catch(error){outerStream.fail(error)}})(),outerStream}function encodeXmlText(value){return value.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")}function encodeXmlLineBreaks(value){return value.replaceAll("\r"," ").replaceAll(`
|
|
151
151
|
`," ")}function encodeXmlParameterText(value){let encoded=encodeXmlText(value),contentStart=0;for(;encoded[contentStart]==="\r"||encoded[contentStart]===`
|
|
152
152
|
`;)contentStart+=1;let contentEnd=encoded.length;for(;contentEnd>contentStart&&(encoded[contentEnd-1]==="\r"||encoded[contentEnd-1]===`
|
|
@@ -323,4 +323,4 @@ ${yamlBody.length>0?yamlBody:"null"}
|
|
|
323
323
|
`).map(line=>` ${line}`),"</tool_response>"].join(`
|
|
324
324
|
`)}function parseYamlXmlGeneratedText(text,tools,options){if(tools.length===0||text.length===0)return[];let parsedToolCalls=[],toolNames=tools.map(tool=>tool.name),cursor=0;for(;cursor<text.length;){let openingTag=findEarliestXmlToolTag(text.slice(cursor),toolNames);if(!openingTag)break;let absoluteIndex=cursor+openingTag.index;if(openingTag.selfClosing){parsedToolCalls.push({name:openingTag.name,arguments:{}}),cursor=absoluteIndex+openingTag.tag.length;continue}let contentStart=absoluteIndex+openingTag.tag.length,closingTagEnd=findClosingTagEnd(text,contentStart,openingTag.name);if(closingTagEnd===-1)break;let closingTagText=text.slice(contentStart,closingTagEnd),closingTagIndex=new RegExp(`</\\s*${escapeRegExp4(openingTag.name)}\\s*>`).exec(closingTagText)?.index;if(closingTagIndex===void 0){cursor=closingTagEnd;continue}let yamlContent=closingTagText.slice(0,closingTagIndex),parsedArguments=parseYamlMapping(yamlContent);parsedArguments!==null?parsedToolCalls.push({name:openingTag.name,arguments:parsedArguments}):options?.onError?.("Could not process YAML XML tool call, keeping original text.",{toolCall:text.slice(absoluteIndex,closingTagEnd)}),cursor=closingTagEnd}return parsedToolCalls}function createYamlXmlStreamParser(tools,options){let toolNames=tools.map(tool=>tool.name),buffer="",currentToolState=null,nextToolCallIndex=0;function emitSnapshot(events,yamlContent){if(!currentToolState)return;let parsedArguments=parseYamlMapping(yamlContent);if(parsedArguments===null)return;let snapshot=JSON.stringify(parsedArguments);snapshot==="{}"||snapshot===currentToolState.lastArgumentsSnapshot||(currentToolState.lastArgumentsSnapshot===null&&events.push({type:"toolcall_start",index:currentToolState.index,name:currentToolState.name,id:currentToolState.id}),currentToolState.lastArgumentsSnapshot=snapshot,events.push({type:"toolcall_delta",index:currentToolState.index,argumentsDelta:snapshot}))}function processBuffer(){let events=[];for(;buffer.length>0;){if(currentToolState){let closingTagMatch=new RegExp(`</\\s*${escapeRegExp4(currentToolState.name)}\\s*>`).exec(buffer);if(!closingTagMatch||closingTagMatch.index===void 0){emitSnapshot(events,buffer);break}let yamlContent=buffer.slice(0,closingTagMatch.index),originalCallText=`<${currentToolState.name}>${yamlContent}${closingTagMatch[0]}`,parsedArguments=parseYamlMapping(yamlContent);if(buffer=buffer.slice(closingTagMatch.index+closingTagMatch[0].length),parsedArguments===null){options?.onError?.("Could not process YAML XML tool call, keeping original text.",{toolCall:originalCallText}),currentToolState.lastArgumentsSnapshot!==null&&events.push({type:"toolcall_end",index:currentToolState.index,name:currentToolState.name,id:currentToolState.id,arguments:{},incomplete:!0,errorMessage:"Tool call arguments could not be parsed"}),shouldEmitRawToolCallTextOnError4(options)&&events.push({type:"text",text:originalCallText}),currentToolState=null;continue}emitSnapshot(events,yamlContent),currentToolState.lastArgumentsSnapshot===null&&events.push({type:"toolcall_start",index:currentToolState.index,name:currentToolState.name,id:currentToolState.id}),events.push({type:"toolcall_end",index:currentToolState.index,name:currentToolState.name,id:currentToolState.id,arguments:parsedArguments}),currentToolState=null;continue}let openingTag=findEarliestXmlToolTag(buffer,toolNames);if(!openingTag){let textLength=getSafeXmlTextLength(buffer,toolNames);if(textLength===0)break;events.push({type:"text",text:buffer.slice(0,textLength)}),buffer=buffer.slice(textLength);continue}if(openingTag.index>0&&events.push({type:"text",text:buffer.slice(0,openingTag.index)}),buffer=buffer.slice(openingTag.index+openingTag.tag.length),openingTag.selfClosing){let id=`yaml-xml-tool-${nextToolCallIndex}`,index=nextToolCallIndex;nextToolCallIndex+=1,events.push({type:"toolcall_start",index,name:openingTag.name,id}),events.push({type:"toolcall_end",index,name:openingTag.name,id,arguments:{}});continue}currentToolState={id:`yaml-xml-tool-${nextToolCallIndex}`,index:nextToolCallIndex,name:openingTag.name,lastArgumentsSnapshot:null},nextToolCallIndex+=1}return events}return{feed(textDelta){return textDelta.length===0?[]:(buffer+=textDelta,processBuffer())},finish(){let events=processBuffer();if(!currentToolState&&buffer.length>0&&(events.push({type:"text",text:buffer}),buffer=""),currentToolState){let state=currentToolState,parsedArguments=parseYamlMapping(buffer),tool=tools.find(candidate=>candidate.name===state.name),validatedArguments=null;if(parsedArguments!==null&&tool)try{validatedArguments=validateToolArguments(tool,{type:"toolCall",id:state.id,name:state.name,arguments:parsedArguments})}catch{validatedArguments=null}validatedArguments!==null?(emitSnapshot(events,buffer),state.lastArgumentsSnapshot===null&&events.push({type:"toolcall_start",index:state.index,name:state.name,id:state.id}),events.push({type:"toolcall_end",index:state.index,name:state.name,id:state.id,arguments:validatedArguments})):(state.lastArgumentsSnapshot===null&&events.push({type:"toolcall_start",index:state.index,name:state.name,id:state.id}),events.push({type:"toolcall_end",index:state.index,name:state.name,id:state.id,arguments:parsedArguments??{},incomplete:!0,errorMessage:"Tool call was truncated mid-arguments"}),options?.onError?.("Could not complete streaming YAML XML tool call at finish.",{protocol:"yaml-xml",retainedLength:buffer.length})),buffer="",currentToolState=null}return events}}}var hermesProtocol={formatToolsSystemPrompt:hermesFormatToolsSystemPrompt,formatToolResponse:hermesFormatToolResponse,formatToolCall:hermesFormatToolCall,parseGeneratedText:hermesParseGeneratedText,createStreamParser:hermesCreateStreamParser},morphXmlProtocol={formatToolsSystemPrompt:morphXmlFormatToolsSystemPrompt,formatToolResponse:morphXmlFormatToolResponse,formatToolCall:morphXmlFormatToolCall,parseGeneratedText:parseMorphXmlGeneratedText,createStreamParser:createMorphXmlStreamParser},yamlXmlProtocol={formatToolsSystemPrompt:yamlXmlFormatToolsSystemPrompt,formatToolResponse:yamlXmlFormatToolResponse,formatToolCall:yamlXmlFormatToolCall,parseGeneratedText:parseYamlXmlGeneratedText,createStreamParser:createYamlXmlStreamParser},gemma4Protocol={formatToolsSystemPrompt:gemma4FormatToolsSystemPrompt,formatToolResponse:gemma4FormatToolResponse,formatToolCall:gemma4FormatToolCall,parseGeneratedText:gemma4ParseGeneratedText,createStreamParser:gemma4CreateStreamParser},antmlProtocol={formatToolsSystemPrompt:antmlFormatToolsSystemPrompt,formatToolResponse:antmlFormatToolResponse,formatToolCall:antmlFormatToolCall,parseGeneratedText:parseAntmlGeneratedText,createStreamParser:createAntmlStreamParser},kimiXtmlProtocol={formatToolsSystemPrompt:kimiXtmlFormatToolsSystemPrompt,formatToolResponse:kimiXtmlFormatToolResponse,formatToolCall:kimiXtmlFormatToolCall,parseGeneratedText:parseKimiXtmlGeneratedText,createStreamParser:createKimiXtmlStreamParser},anthropicXmlProtocol={formatToolsSystemPrompt:anthropicXmlFormatToolsSystemPrompt,formatToolResponse:anthropicXmlFormatToolResponse,formatToolCall:anthropicXmlFormatToolCall,parseGeneratedText:parseAnthropicXmlGeneratedText,createStreamParser:createAnthropicXmlStreamParser},protocolRegistry={"anthropic-xml":anthropicXmlProtocol,antml:antmlProtocol,hermes:hermesProtocol,xml:morphXmlProtocol,"morph-xml":morphXmlProtocol,"yaml-xml":yamlXmlProtocol,"gemma4-delimiter":gemma4Protocol,"kimi-xtml":kimiXtmlProtocol};function getProtocol(format){let protocol=protocolRegistry[format];if(!protocol)throw new Error(`Unsupported tool call format: ${format}`);return protocol}function transformContext(context,protocol){let transformed={systemPrompt:context.systemPrompt,messages:context.messages.map(msg=>transformMessage(msg,protocol)),tools:void 0};if(context.tools&&context.tools.length>0){let toolPrompt=protocol.formatToolsSystemPrompt(context.tools);toolPrompt&&(transformed.systemPrompt=context.systemPrompt?`${toolPrompt}
|
|
325
325
|
|
|
326
|
-
${context.systemPrompt}`:toolPrompt)}return transformed}function transformMessage(message,protocol){switch(message.role){case"assistant":return transformAssistantMessage(message,protocol);case"toolResult":return transformToolResultMessage(message,protocol);default:return message}}function transformAssistantMessage(message,protocol){if(!message.content.some(block=>block.type==="toolCall"))return message;let newContent=[];for(let block of message.content)switch(block.type){case"text":{newContent.push(block);break}case"thinking":{newContent.push(block);break}case"toolCall":{let toolCallText=protocol.formatToolCall(block.name,block.arguments);newContent.push({type:"text",text:toolCallText});break}}return{...message,content:newContent}}function transformToolResultMessage(message,protocol){return{role:"user",content:protocol.formatToolResponse(message.toolName,message.toolCallId,message.content),timestamp:message.timestamp}}function wrapStreamWithToolCallMiddleware(innerStream,protocol,tools){let outerStream=new AssistantMessageEventStream,parser=protocol.createStreamParser(tools);return(async()=>{let projection=null,sawToolCall=!1,parserHasPendingInput=!1,flushParser=()=>{if(!projection||!parserHasPendingInput)return;let result=projection.projectParserEvents(parser.finish());sawToolCall=sawToolCall||result.sawToolCall,projection.finishText(),parserHasPendingInput=!1};try{for await(let event of innerStream)switch(event.type){case"start":projection=new StreamMessageProjection(outerStream,event.partial),outerStream.push({type:"start",partial:projection.message});break;case"text_start":if(!projection)break;projection.sync(event.partial),projection.startText(event.contentIndex,event.partial.content[event.contentIndex]);break;case"text_delta":{if(!projection)break;projection.sync(event.partial),event.delta.length>0&&(parserHasPendingInput=!0);let result=projection.projectParserEvents(parser.feed(event.delta));sawToolCall=sawToolCall||result.sawToolCall;break}case"text_end":if(!projection)break;projection.sync(event.partial),flushParser();break;case"thinking_start":if(!projection)break;projection.sync(event.partial),projection.startThinking(event.contentIndex,event.partial);break;case"thinking_delta":if(!projection)break;projection.sync(event.partial),projection.projectThinkingDelta(event.contentIndex,event.delta,event.partial);break;case"thinking_end":if(!projection)break;projection.sync(event.partial),projection.finishThinking(event.contentIndex,event.content,event.partial);break;case"done":{projection??=new StreamMessageProjection(outerStream,event.message),flushParser(),projection.finalizeDanglingToolCalls();let message=projection.finalize(event.message,sawToolCall),reason=(sawToolCall||projection.hasFinalizedToolCallContent())&&(event.reason==="stop"||event.reason==="length")?"toolUse":event.reason;outerStream.push({type:"done",reason,message}),outerStream.end();return}case"error":{if(!projection){outerStream.push(event),outerStream.end(event.error);return}projection.sync(event.error),flushParser(),projection.finalizeDanglingToolCalls();let message=projection.finalize(event.error,sawToolCall);if(projection.hasFinalizedToolCallContent()){let recovered={...message,stopReason:"toolUse"};outerStream.push({type:"done",reason:"toolUse",message:recovered}),outerStream.end(recovered);return}outerStream.push({type:"error",reason:event.reason,error:message}),outerStream.end(message);return}case"toolcall_start":case"toolcall_delta":case"toolcall_end":break}let innerMessage=await innerStream.result();projection??=new StreamMessageProjection(outerStream,innerMessage),flushParser(),projection.finalizeDanglingToolCalls(),outerStream.end(projection.finalize(innerMessage,sawToolCall))}catch(error){flushParser(),projection??=new StreamMessageProjection(outerStream,await innerStream.result()),projection.finalizeDanglingToolCalls();let fallback=projection.message;fallback.stopReason="error",fallback.errorMessage=error instanceof Error?error.message:JSON.stringify(error),outerStream.push({type:"error",reason:"error",error:fallback}),outerStream.end()}})(),outerStream}function getToolCallFormat(model){if(model.api!=="openai-completions")return;let format=model.compat?.toolCallFormat;if(format&&(format==="hermes"||format==="xml"||format==="morph-xml"||format==="yaml-xml"||format==="gemma4-delimiter"||format==="anthropic-xml"||format==="antml"||format==="kimi-xtml"))return format}function shouldRecoverTextToolCalls(model){return getToolCallFormat(model)!==void 0?!1:model.recoverTextToolCalls!==void 0?typeof model.recoverTextToolCalls=="boolean"?model.recoverTextToolCalls:!1:model.api==="cursor-agent"?!1:CLAUDE_MODEL_ID_PATTERN.test(model.id)||KIMI_MODEL_ID_PATTERN.test(model.id)}var CLAUDE_MODEL_ID_PATTERN=/(^|[^a-z0-9])claude([^a-z0-9]|$)/i,KIMI_MODEL_ID_PATTERN=/(^|[^a-z0-9])kimi([^a-z0-9]|$)/i;function hasKimiTextToolCallRecovery(model){return KIMI_MODEL_ID_PATTERN.test(model.id)}function wrapStreamWithModelRecovery(innerStream,model,tools){let recoveredStream=hasKimiTextToolCallRecovery(model)?wrapStreamWithKimiThinkingRecovery(innerStream):innerStream;return!shouldRecoverTextToolCalls(model)||tools.length===0?recoveredStream:wrapStreamWithInvokeRecovery(recoveredStream,tools,hasKimiTextToolCallRecovery(model)?{createParser:createXtmlRecoveryStreamParser,protocol:"kimi-xtml"}:void 0)}function cloneTextContent(content){return{type:"text",text:content.text,...content.textSignature===void 0?{}:{textSignature:content.textSignature}}}function cloneThinkingContent(content){return{type:"thinking",thinking:content.thinking,...content.thinkingSignature===void 0?{}:{thinkingSignature:content.thinkingSignature},...content.redacted===void 0?{}:{redacted:content.redacted}}}function cloneToolCall2(toolCall){return{type:"toolCall",id:toolCall.id,name:toolCall.name,arguments:structuredClone(toolCall.arguments),...toolCall.thoughtSignature===void 0?{}:{thoughtSignature:toolCall.thoughtSignature},...toolCall.namespace===void 0?{}:{namespace:toolCall.namespace}}}function cloneStartMessage(message){return{role:"assistant",content:[],api:message.api,provider:message.provider,model:message.model,...message.responseModel===void 0?{}:{responseModel:message.responseModel},...message.responseId===void 0?{}:{responseId:message.responseId},...message.providerThinkingLevel===void 0?{}:{providerThinkingLevel:message.providerThinkingLevel},...message.diagnostics===void 0?{}:{diagnostics:structuredClone(message.diagnostics)},usage:structuredClone(message.usage),stopReason:"pending",timestamp:message.timestamp}}function assertContentIndex(contentIndex){if(!Number.isSafeInteger(contentIndex)||contentIndex<0)throw new Error(`Invalid assistant message frame contentIndex: ${contentIndex}`)}function eventBlock(event){assertContentIndex(event.contentIndex);let block=event.partial.content[event.contentIndex];if(!block)throw new Error(`${event.type} event has no content block at index ${event.contentIndex}`);return block}function serializedArguments(argumentsValue){let serialized=JSON.stringify(argumentsValue);if(serialized===void 0)throw new Error("Tool-call arguments are not JSON-serializable");return serialized}var EMPTY_PARSED_TOOL_ARGUMENTS=serializedArguments(parseStreamingJson(""));function isJsonPrefix(snapshot,current){if(typeof snapshot=="string")return typeof current=="string"&¤t.startsWith(snapshot);if(Array.isArray(snapshot))return Array.isArray(current)&&snapshot.length<=current.length&&snapshot.every((value,index)=>isJsonPrefix(value,current[index]));if(typeof snapshot!="object"||snapshot===null)return Object.is(snapshot,current);if(typeof current!="object"||current===null||Array.isArray(current))return!1;let currentRecord=current;return Object.entries(snapshot).every(([key,value])=>Object.hasOwn(currentRecord,key)&&isJsonPrefix(value,currentRecord[key]))}var AssistantMessageFrameEncoder=class{constructor(){this.started=!1,this.terminal=!1,this.blocks=new Map}encode(event){if(this.terminal)throw new Error(`Assistant message event ${event.type} follows a terminal event`);switch(event.type){case"start":if(this.started)throw new Error("Assistant message stream contains more than one start event");return this.started=!0,{type:"start",partial:cloneStartMessage(event.partial)};case"done":if(!this.started)throw new Error("Assistant message done event appears before start");this.terminal=!0;return;case"error":this.terminal=!0;return}if(!this.started)throw new Error(`Assistant message ${event.type} event appears before start`);switch(event.type){case"text_start":{let content=eventBlock(event);if(content.type!=="text")throw new Error(`text_start event points to ${content.type} block at index ${event.contentIndex}`);return this.startBlock(event.contentIndex,{kind:"text",coveredChars:content.text.length,deltaChars:0}),{type:"text_start",contentIndex:event.contentIndex,content:cloneTextContent(content)}}case"text_delta":return this.encodeTextDelta(event.contentIndex,event.delta,"text");case"text_end":{let content=eventBlock(event);if(content.type!=="text")throw new Error(`text_end event points to ${content.type} block at index ${event.contentIndex}`);return this.endBlock(event.contentIndex,"text"),{type:"text_end",contentIndex:event.contentIndex,content:event.content,...content.textSignature===void 0?{}:{textSignature:content.textSignature}}}case"thinking_start":{let content=eventBlock(event);if(content.type!=="thinking")throw new Error(`thinking_start event points to ${content.type} block at index ${event.contentIndex}`);return this.startBlock(event.contentIndex,{kind:"thinking",coveredChars:content.thinking.length,deltaChars:0}),{type:"thinking_start",contentIndex:event.contentIndex,content:cloneThinkingContent(content)}}case"thinking_delta":return this.encodeTextDelta(event.contentIndex,event.delta,"thinking");case"thinking_end":{let content=eventBlock(event);if(content.type!=="thinking")throw new Error(`thinking_end event points to ${content.type} block at index ${event.contentIndex}`);return this.endBlock(event.contentIndex,"thinking"),{type:"thinking_end",contentIndex:event.contentIndex,content:event.content,...content.thinkingSignature===void 0?{}:{thinkingSignature:content.thinkingSignature},...content.redacted===void 0?{}:{redacted:content.redacted}}}case"toolcall_start":{let content=eventBlock(event);if(content.type!=="toolCall")throw new Error(`toolcall_start event points to ${content.type} block at index ${event.contentIndex}`);let snapshotArguments=serializedArguments(content.arguments),caughtUp=snapshotArguments===EMPTY_PARSED_TOOL_ARGUMENTS;return this.startBlock(event.contentIndex,{kind:"toolCall",caughtUp,catchupJson:"",snapshotArguments:caughtUp?"":snapshotArguments}),{type:"toolcall_start",contentIndex:event.contentIndex,toolCall:cloneToolCall2(content)}}case"toolcall_delta":{let state=this.block(event.contentIndex,"toolCall");if(state.kind!=="toolCall")throw new Error("Unreachable tool-call encoder state");if(state.caughtUp)return event.delta.length===0?void 0:{type:"toolcall_delta",contentIndex:event.contentIndex,delta:event.delta};state.catchupJson+=event.delta;let argumentsValue=parseStreamingJson(state.catchupJson);if(serializedArguments(argumentsValue)!==state.snapshotArguments){let snapshotArguments=parseStreamingJson(state.snapshotArguments);if(!isJsonPrefix(snapshotArguments,argumentsValue))return}state.caughtUp=!0,state.snapshotArguments="";let json=state.catchupJson;return state.catchupJson="",json.length===0?void 0:{type:"toolcall_checkpoint",contentIndex:event.contentIndex,json}}case"toolcall_end":{let content=eventBlock(event);if(content.type!=="toolCall")throw new Error(`toolcall_end event points to ${content.type} block at index ${event.contentIndex}`);if(event.toolCall.type!=="toolCall")throw new Error(`toolcall_end event has invalid tool call at index ${event.contentIndex}`);return this.endBlock(event.contentIndex,"toolCall"),{type:"toolcall_end",contentIndex:event.contentIndex,id:event.toolCall.id,name:event.toolCall.name,arguments:structuredClone(event.toolCall.arguments),...event.toolCall.thoughtSignature===void 0?{}:{thoughtSignature:event.toolCall.thoughtSignature},...event.toolCall.namespace===void 0?{}:{namespace:event.toolCall.namespace}}}}}startBlock(contentIndex,state){if(assertContentIndex(contentIndex),this.blocks.has(contentIndex))throw new Error(`Assistant message block ${contentIndex} starts more than once`);this.blocks.set(contentIndex,state)}block(contentIndex,kind){assertContentIndex(contentIndex);let state=this.blocks.get(contentIndex);if(state===void 0)throw new Error(`Assistant message ${kind} block ${contentIndex} has not started`);if(state.kind!==kind)throw new Error(`Assistant message block ${contentIndex} is ${state.kind}, not ${kind}`);return state}endBlock(contentIndex,kind){this.block(contentIndex,kind),this.blocks.delete(contentIndex)}encodeTextDelta(contentIndex,delta,kind){let state=this.block(contentIndex,kind);if(state.kind==="toolCall")throw new Error("Unreachable text encoder state");let deltaStart=state.deltaChars;state.deltaChars+=delta.length;let covered=Math.max(0,state.coveredChars-deltaStart);if(covered>=delta.length)return;let uncovered=covered===0?delta:delta.slice(covered);return kind==="text"?{type:"text_delta",contentIndex,delta:uncovered}:{type:"thinking_delta",contentIndex,delta:uncovered}}};function appendBlock(message,states,contentIndex,block,state){if(assertContentIndex(contentIndex),contentIndex!==message.content.length){let reason=contentIndex<message.content.length?"already exists":"would leave a gap";throw new Error(`Cannot start assistant message block at index ${contentIndex}: ${reason}`)}message.content.push(structuredClone(block)),states.set(contentIndex,state)}function activeBlock(message,states,contentIndex,expectedKind,frameType){assertContentIndex(contentIndex);let state=states.get(contentIndex),block=message.content[contentIndex];if(!state||!block)throw new Error(`${frameType} frame has no started block at index ${contentIndex}`);if(state.kind!==expectedKind||block.type!==expectedKind)throw new Error(`${frameType} frame expected ${expectedKind} block at index ${contentIndex}, found ${block.type}`);if(state.ended)throw new Error(`${frameType} frame follows the end of block at index ${contentIndex}`);return{block,state}}function reduceAssistantMessageFrames(frames){let message,frameBeforeStart,states=new Map;for(let frame of frames){if(frame.type==="start"){if(message)throw new Error("Assistant message frame sequence contains more than one start frame");if(frameBeforeStart!==void 0)throw new Error(`${frameBeforeStart} frame appears before the start frame`);message=structuredClone(frame.partial);continue}if(!message){frameBeforeStart??=frame.type;continue}switch(frame.type){case"text_start":if(frame.content.type!=="text")throw new Error(`text_start frame contains ${frame.content.type} content`);appendBlock(message,states,frame.contentIndex,frame.content,{kind:"text",ended:!1});break;case"text_delta":{let{block}=activeBlock(message,states,frame.contentIndex,"text",frame.type);if(block.type!=="text")throw new Error("Unreachable text frame state");block.text+=frame.delta;break}case"text_end":{let{block,state}=activeBlock(message,states,frame.contentIndex,"text",frame.type);if(block.type!=="text")throw new Error("Unreachable text frame state");block.text=frame.content,delete block.textSignature,frame.textSignature!==void 0&&(block.textSignature=frame.textSignature),state.ended=!0;break}case"thinking_start":if(frame.content.type!=="thinking")throw new Error(`thinking_start frame contains ${frame.content.type} content`);appendBlock(message,states,frame.contentIndex,frame.content,{kind:"thinking",ended:!1});break;case"thinking_delta":{let{block}=activeBlock(message,states,frame.contentIndex,"thinking",frame.type);if(block.type!=="thinking")throw new Error("Unreachable thinking frame state");block.thinking+=frame.delta;break}case"thinking_end":{let{block,state}=activeBlock(message,states,frame.contentIndex,"thinking",frame.type);if(block.type!=="thinking")throw new Error("Unreachable thinking frame state");block.thinking=frame.content,delete block.thinkingSignature,delete block.redacted,frame.thinkingSignature!==void 0&&(block.thinkingSignature=frame.thinkingSignature),frame.redacted!==void 0&&(block.redacted=frame.redacted),state.ended=!0;break}case"toolcall_start":if(frame.toolCall.type!=="toolCall")throw new Error(`toolcall_start frame contains ${frame.toolCall.type} content`);appendBlock(message,states,frame.contentIndex,frame.toolCall,{kind:"toolCall",ended:!1,json:""});break;case"toolcall_checkpoint":{let{block,state}=activeBlock(message,states,frame.contentIndex,"toolCall",frame.type);if(block.type!=="toolCall"||state.kind!=="toolCall")throw new Error("Unreachable tool-call checkpoint state");state.json=frame.json,block.arguments=parseStreamingJson(frame.json);break}case"toolcall_delta":{let{block,state}=activeBlock(message,states,frame.contentIndex,"toolCall",frame.type);if(block.type!=="toolCall"||state.kind!=="toolCall")throw new Error("Unreachable tool-call frame state");state.json+=frame.delta;break}case"toolcall_end":{let{block,state}=activeBlock(message,states,frame.contentIndex,"toolCall",frame.type);if(block.type!=="toolCall")throw new Error("Unreachable tool-call frame state");block.id=frame.id,block.name=frame.name,block.arguments=structuredClone(frame.arguments),delete block.thoughtSignature,delete block.namespace,frame.thoughtSignature!==void 0&&(block.thoughtSignature=frame.thoughtSignature),frame.namespace!==void 0&&(block.namespace=frame.namespace),state.ended=!0;break}}}if(message){for(let[contentIndex,state]of states){if(state.kind!=="toolCall"||state.ended||state.json.length===0)continue;let block=message.content[contentIndex];if(block?.type!=="toolCall")throw new Error("Unreachable tool-call frame state");block.arguments=parseStreamingJson(state.json)}return message}}var kCursorExecResolved=Symbol("provider.block.cursorExecResolved");function isCursorExecResolved(block){return block?.[kCursorExecResolved]===!0}function copyCursorExecResolved(target,source){source[kCursorExecResolved]===!0&&(target[kCursorExecResolved]=!0)}function dropFailedAssistantTurns(messages){let callIdsByKeptAssistants=new Set,callIdsByFailedAssistants=new Set;for(let message of messages){let assistant=asAssistantTurn(message);if(!assistant)continue;let declared=isFailedStop(assistant.stopReason)?callIdsByFailedAssistants:callIdsByKeptAssistants;for(let block of assistant.content)block.type==="toolCall"&&typeof block.id=="string"&&declared.add(block.id)}for(let id of callIdsByKeptAssistants)callIdsByFailedAssistants.delete(id);return messages.filter(message=>{let assistant=asAssistantTurn(message);return assistant?!isFailedStop(assistant.stopReason):message.role==="toolResult"&&"toolCallId"in message&&typeof message.toolCallId=="string"?!callIdsByFailedAssistants.has(message.toolCallId):!0})}function asAssistantTurn(message){if(message.role==="assistant"&&!(!("content"in message)||!Array.isArray(message.content)))return{stopReason:"stopReason"in message?message.stopReason:void 0,content:message.content}}function isFailedStop(stopReason){return stopReason==="error"||stopReason==="aborted"}var EMPTY_RESPONSE_ERROR="Model returned an empty response twice",EMPTY_TOOL_USE_ERROR="Model returned tool_use without a tool call twice",FORWARDED_EMPTY_RESPONSE_ERROR="Model returned an empty response after streaming thinking",FORWARDED_EMPTY_TOOL_USE_ERROR="Model returned tool_use without a tool call after streaming thinking";var OVERFLOW_PATTERNS=[/^Context window exhausted: /,/prompt is too long/i,/request_too_large/i,/input is too long for requested model/i,/exceeds (?:(?:the|this) )?(?:model'?s )?context window/i,/exceeds (?:the )?(?:model'?s )?maximum context length(?: of [\d,]+ tokens?|\s*\([\d,]+\))/i,/input token count.*exceeds the maximum/i,/maximum prompt length is \d+/i,/reduce the length of the messages/i,/maximum context length is \d+ tokens/i,/exceeds (?:the )?maximum allowed input length of [\d,]+ tokens?/i,/input \(\d+ tokens\) is longer than the model'?s context length \(\d+ tokens\)/i,/exceeds the limit of \d+/i,/exceeds the available context size/i,/greater than the context length/i,/context window exceeds limit/i,/exceeded model token limit/i,/too large for model with \d+ maximum context length/i,/prompt has [\d,]+ tokens?, but the configured context size is [\d,]+ tokens?/i,/model_context_window_exceeded/i,/prompt too long; exceeded (?:max )?context length/i,/range of input length should be/i,/context[_ ]length[_ ]exceeded/i,/too many tokens/i,/token limit exceeded/i,/^4(?:00|13)\s*(?:status code)?\s*\(no body\)/i,/(?:request[ _])?(?:body|entity|payload)[_ ]too[_ ]large/i,/Request payload is \d+ (?:bytes, over the \d+ byte|tokens, over the \d+ token) limit Kiro accepts\./,/Model context limit reached\. Conversation size exceeds model capacity\./],NON_OVERFLOW_PATTERNS=[/^(Throttling error|Service unavailable):/i,/rate limit/i,/too many requests/i,/tokens per (?:min|minute|hour|day)/i,/\bTPM\b/i,/\bRPM\b/i,/quota exceeded/i,/retry (?:after|in) \d/i,/^429\b/,/status code 429/i,/overloaded/i],RESOURCE_EXHAUSTED_PATTERN=/resource.?exhausted/i;function isContextOverflow(message,contextWindow){if(message.stopReason==="error"&&message.errorMessage){let isNonOverflow=NON_OVERFLOW_PATTERNS.some(p=>p.test(message.errorMessage));if(!isNonOverflow&&OVERFLOW_PATTERNS.some(p=>p.test(message.errorMessage)))return!0;let usage=message.usage,hasTokenEvidence=(usage.totalTokens||usage.input+usage.output+usage.cacheRead+usage.cacheWrite)>0;if(!isNonOverflow&&hasTokenEvidence&&RESOURCE_EXHAUSTED_PATTERN.test(message.errorMessage)&&(contextWindow===void 0||contextWindow<=0||cursorZeroTokenCount(message)>=contextWindow*.5))return!0}return!!(contextWindow&&message.stopReason==="stop"&&message.usage.input+message.usage.cacheRead>contextWindow||contextWindow&&message.stopReason==="length"&&message.usage.output===0&&message.usage.input+message.usage.cacheRead>=contextWindow*.99)}function isRecoverableLength(message,desiredMaxOutput){return message.stopReason==="length"&&desiredMaxOutput>0&&message.usage.output<desiredMaxOutput}function getOverflowPatterns(){return[...OVERFLOW_PATTERNS]}function cursorZeroTokenCount(message){let usage=message.usage;return usage?usage.totalTokens||(usage.input??0)+(usage.output??0)+(usage.cacheRead??0)+(usage.cacheWrite??0):0}function isCursorPayloadResourceExhausted(message,_estimateTokens){return message.stopReason!=="error"||!/resource.?exhausted/i.test(message.errorMessage||"")?!1:!(cursorZeroTokenCount(message)>0)}function isCursorQuotaResourceExhausted(message,contextWindow){let tokens=cursorZeroTokenCount(message);return message.stopReason==="error"&&RESOURCE_EXHAUSTED_PATTERN.test(message.errorMessage||"")&&contextWindow>0&&tokens>0&&tokens<contextWindow*.5}function isCursorZeroTokenResourceExhausted(message){return message.stopReason!=="error"||!/resource.?exhausted/i.test(message.errorMessage||"")?!1:!(cursorZeroTokenCount(message)>0)}function shouldSkipProviderFallbackForCursorZeroRe(options){return options?.sameModelRemint===!0}function shouldRetryOverflowWithoutCompact(compacted,errorMessage){return compacted?!1:/Nothing to compact/i.test(errorMessage||"")}function cursorOverflowCompactionSettings(settings,provider,reason){return reason!=="overflow"||provider!=="cursor"&&provider!=="cursor-cli-oauth"?settings:{...settings,keepRecentTokens:0,restorationEnabled:!1}}function buildProviderErrorPattern(patterns){return new RegExp(patterns.join("|"),"i")}function escapeRegExp5(text){return text.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var USAGE_LIMIT_EXHAUSTION={codes:["usage_limit_reached","usage_not_included"],markers:["usage_limit_reached","usage_not_included","usage limit has been reached"]},NON_RETRYABLE_PROVIDER_ERROR_PATTERN=buildProviderErrorPattern(["GoUsageLimitError","FreeUsageLimitError","Monthly usage limit reached","available balance","insufficient_quota","out of budget","quota exceeded","billing","credits_required","credits are required",...USAGE_LIMIT_EXHAUSTION.markers,"invalid request: tools\\.","invalid request: functions\\.","tools\\.[^ ]*function\\.parameters","tools\\.\\d+\\.function\\.parameters","invalid tool schema"]),RETRYABLE_PROVIDER_ERROR_PATTERN=buildProviderErrorPattern(["Credential store is busy: lock","overloaded","rate.?limit","too many requests","429","500","502","503","504","522","524","service.?unavailable","server.?error","internal.?error","provider.?returned.?error","exceeded request buffer limit while retrying upstream","network.?error","connection.?error","connection.?refused","connection.?lost","other side closed","fetch failed","getaddrinfo","ENOTFOUND","EAI_AGAIN","upstream.?connect","upstream.?unavailable","reset before headers","socket hang up","socket connection was closed","timed? out","timeout","terminated","websocket.?closed","websocket.?error","ended without","stream ended before message_stop","stream ended before a terminal response event","http2 request did not get a response","retry delay","you can retry your request","try your request again","please retry your request","the model request was rejected\\.\\s*check the request and try again\\.?","was found without a corresponding `",escapeRegExp5(FORWARDED_EMPTY_RESPONSE_ERROR),escapeRegExp5(FORWARDED_EMPTY_TOOL_USE_ERROR),"ResourceExhausted","Lock file is already being held"]),DEFAULT_MAX_AGENT_RETRY_DELAY_MS=6e4;function retryDelayMs(policy,attempt){let scheduledDelayMs=policy.baseDelayMs*2**Math.max(0,attempt-1),sample=Math.min(1,Math.max(0,(policy.random??Math.random)())),jitteredDelayMs=Math.round(scheduledDelayMs*(.9+sample*.2)),safeDelay=Number.isSafeInteger(jitteredDelayMs)?jitteredDelayMs:Number.MAX_SAFE_INTEGER;return Math.min(safeDelay,policy.maxAgentDelayMs??DEFAULT_MAX_AGENT_RETRY_DELAY_MS)}var RetrySleepAbortError=class extends Error{constructor(){super("Aborted")}};function sleep(ms,signal){return new Promise((resolve,reject)=>{if(signal?.aborted){reject(new RetrySleepAbortError);return}let timeout=setTimeout(resolve,ms);signal?.addEventListener("abort",()=>{clearTimeout(timeout),reject(new RetrySleepAbortError)},{once:!0})})}async function retryTransientCall(produce,isRetryable,policy,signal,callbacks){let maxAttempts=policy?.enabled?policy.maxRetries:0,attempt=0,lastRetry;for(;;)try{let value=await produce();return lastRetry&&await callbacks?.onRetryFinished?.(!0,lastRetry.attempt),value}catch(error){if(error instanceof RetrySleepAbortError)throw error;if(attempt>=maxAttempts||!isRetryable(error))throw lastRetry&&await callbacks?.onRetryFinished?.(!1,lastRetry.attempt,errorMessageOf(error)),error;attempt++,lastRetry={attempt,errorMessage:errorMessageOf(error)};let delayMs=retryDelayMs(policy,attempt);await callbacks?.onRetryScheduled?.(attempt,maxAttempts,delayMs,lastRetry.errorMessage);try{await sleep(delayMs,signal)}catch(sleepError){throw await callbacks?.onRetryFinished?.(!1,attempt,lastRetry.errorMessage),sleepError instanceof RetrySleepAbortError?error:sleepError}await callbacks?.onRetryAttemptStart?.()}}function errorMessageOf(error){return error instanceof Error?error.message||"Unknown error":String(error)||"Unknown error"}async function retryAssistantCall(produce,policy,signal,callbacks){let maxAttempts=policy?.enabled?policy.maxRetries:0,attempt=0,lastRetry;for(;;){let response=await produce();if(response.stopReason==="aborted")return lastRetry&&await callbacks?.onRetryFinished?.(!1,lastRetry.attempt),response;if(response.stopReason!=="error")return lastRetry&&await callbacks?.onRetryFinished?.(!0,lastRetry.attempt),response;if(attempt>=maxAttempts||!isRetryableAssistantError(response))return lastRetry&&await callbacks?.onRetryFinished?.(!1,lastRetry.attempt,response.errorMessage),response;attempt++,lastRetry={attempt,errorMessage:response.errorMessage||"Unknown error"};let delayMs=retryDelayMs(policy,attempt);await callbacks?.onRetryScheduled?.(attempt,maxAttempts,delayMs,lastRetry.errorMessage);try{await sleep(delayMs,signal)}catch(error){if(await callbacks?.onRetryFinished?.(!1,attempt,lastRetry.errorMessage),error instanceof RetrySleepAbortError){let{errorMessage:_errorMessage,...rest}=response;return{...rest,stopReason:"aborted"}}throw error}await callbacks?.onRetryAttemptStart?.()}}function isRetryableAssistantError(message){return message.stopReason!=="error"||message.stopDetails?.type==="refusal"||message.stopDetails?.type==="sensitive"||!message.errorMessage?!1:isRetryableErrorMessage(message.errorMessage)}var PROVIDER_STREAM_STALL_ERROR_PATTERN=/^(?:Idle timeout waiting for provider stream after \d+ms|Provider stream start timed out after \d+ms(?: \([^)]*\))?|WebSocket liveness timeout after \d+ms \(\d+ pings unanswered\)|Provider stream stalled after the last output item: response\.completed timed out after \d+ms)$/i,PROVIDER_TRANSPORT_TIMEOUT_ERROR_PATTERN=/^Request timed out\.?$/i;function isProviderStreamStallError(message){return message.stopReason==="error"&&PROVIDER_STREAM_STALL_ERROR_PATTERN.test(message.errorMessage??"")}var PROVIDER_STALL_PHASES=[{pattern:/^Provider stream start timed out after (\d+)ms/i,symptom:"accepted the request but never started sending a response",setting:"retry.provider.streamStartTimeoutMs"},{pattern:/^Idle timeout waiting for provider stream after (\d+)ms/i,symptom:"started the response and then went silent",setting:"retry.provider.timeoutMs"},{pattern:/^WebSocket liveness timeout after (\d+)ms/i,symptom:"stopped answering connection health checks"},{pattern:/^Provider stream stalled after the last output item: response\.completed timed out after (\d+)ms/i,symptom:"finished its output but never sent the end-of-response event"}];function formatStallDuration(timeoutMs){return timeoutMs<1e3?`${timeoutMs}ms`:timeoutMs<12e4?`${Math.round(timeoutMs/100)/10}s`:`${Math.round(timeoutMs/6e3)/10}m`}function describeProviderStallForUser(errorMessage,options={}){if(errorMessage)for(let{pattern,symptom,setting}of PROVIDER_STALL_PHASES){let match=pattern.exec(errorMessage);if(!match)continue;let subject=options.model?`The provider for ${options.model}`:"The provider",duration=formatStallDuration(Number(match[1])),sentences=[`${subject} ${symptom} within ${duration}, so the request was cancelled.`],attempts=options.attempts??0;if(attempts>0&&sentences.push(`Retried ${attempts} time${attempts===1?"":"s"} on the same model with the same result.`),options.recovery){let raise=setting?`, or raise ${setting} in settings (0 disables the bound)`:"",lead=options.recovery==="no-fallback-configured"?"No fallback model is configured for it, so nothing could take the turn over: run /fallback to add one":"Every model in its fallback chain was tried as well: run /fallback to review the chain";sentences.push(`${lead}, send the message again${raise}.`)}return sentences.join(" ")}}function isProviderTimeoutError(message){return message.abortSource==="provider"||isProviderStreamStallError(message)?!0:message.stopReason!=="error"&&message.stopReason!=="aborted"?!1:PROVIDER_TRANSPORT_TIMEOUT_ERROR_PATTERN.test(message.errorMessage??"")}function isRetryableErrorMessage(errorMessage){return classifyErrorMessage(errorMessage)==="retryable"}function classifyErrorMessage(errorMessage){return errorMessage?NON_RETRYABLE_PROVIDER_ERROR_PATTERN.test(errorMessage)?"non-retryable":RETRYABLE_PROVIDER_ERROR_PATTERN.test(errorMessage)?"retryable":"unknown":"unknown"}var TURN_RETRY_SUPPRESSION_PREFIX="senpi:no-turn-retry:";function stripTurnRetrySuppressionPrefix(message){return message.replaceAll(TURN_RETRY_SUPPRESSION_PREFIX,"")}var WEBSOCKET_CLOSED_PATTERN=/^WebSocket closed\b/i,WEBSOCKET_ERROR_PATTERN=/^WebSocket error$/i,WEBSOCKET_CONNECT_TIMEOUT_PATTERN=/^WebSocket connect timeout after (\d+)ms/i,RECOVERY_SENTENCE={"no-fallback-configured":"No fallback model is configured for it, so nothing could take the turn over: run /fallback to add one, or send the message again to continue from the partial reply.","chain-exhausted":"Every model in its fallback chain was tried as well: run /fallback to review the chain, or send the message again to continue from the partial reply."};function transportSymptom(errorMessage,subject){if(WEBSOCKET_CLOSED_PATTERN.test(errorMessage))return`The connection to ${subject} dropped before the reply finished (${errorMessage}).`;if(WEBSOCKET_ERROR_PATTERN.test(errorMessage))return`The connection to ${subject} reported an error before the reply finished (${errorMessage}).`;let connectTimeout=WEBSOCKET_CONNECT_TIMEOUT_PATTERN.exec(errorMessage);if(connectTimeout)return`${subject.replace(/^the provider/,"The provider")} did not accept the connection within ${formatStallDuration(Number(connectTimeout[1]))}.`}function describeProviderFailureForUser(errorMessage,options={}){if(!errorMessage)return;let message=stripTurnRetrySuppressionPrefix(errorMessage).trim();if(!message)return;let stall=describeProviderStallForUser(message,options);if(stall!==void 0)return stall;let subject=options.model?`the provider for ${options.model}`:"the provider",symptom=transportSymptom(message,subject);if(symptom===void 0)return;let sentences=[symptom],attempts=options.attempts??0;return attempts>0&&sentences.push(`Retried ${attempts} time${attempts===1?"":"s"} on the same model with the same result.`),options.recovery&&sentences.push(RECOVERY_SENTENCE[options.recovery]),sentences.join(" ")}var ANTHROPIC_POLICY_REFUSAL_PATTERN=/This request triggered restrictions on [\s\S]+? and was blocked under Anthropic's Usage Policy\b/i;function isClassifierRefusal(message){return message.stopReason!=="error"&&message.stopReason!=="toolUse"?!1:message.stopDetails?.type==="refusal"||message.stopDetails?.type==="sensitive"?!0:message.errorMessage?ANTHROPIC_POLICY_REFUSAL_PATTERN.test(message.errorMessage):!1}var TOOL_RESULT_PLACEHOLDER="Tool output unavailable (context compacted)";function incompleteToolCallRetryText(name,errorMessage){return errorMessage!==void 0?`${errorMessage}${errorMessage.endsWith(".")?"":"."} Re-issue the tool call with complete arguments.`:`Tool call "${name}" was not executed: the response ended before the tool call was complete. Re-issue the tool call with complete arguments.`}function repairOrphanedToolResults(messages){let toolCallIds=new Set,toolResultIds=new Set;for(let message of messages){if(message.role==="assistant")for(let block of message.content)block.type==="toolCall"&&toolCallIds.add(block.id);message.role==="toolResult"&&toolResultIds.add(message.toolCallId)}let output=[],dangling=new Set([...toolCallIds].filter(id=>!toolResultIds.has(id)));for(let message of messages){if(message.role==="toolResult"){if(!toolCallIds.has(message.toolCallId)){output.push({...message,content:[{type:"text",text:TOOL_RESULT_PLACEHOLDER}]});continue}output.push(message);continue}if(output.push(message),message.role==="assistant"){if(message.stopReason==="error"||message.stopReason==="aborted")continue;for(let block of message.content){if(block.type!=="toolCall"||!dangling.has(block.id))continue;let incomplete=block.incomplete===!0,text=incomplete?incompleteToolCallRetryText(block.name,block.errorMessage):TOOL_RESULT_PLACEHOLDER;output.push({role:"toolResult",toolCallId:block.id,toolName:block.name,content:[{type:"text",text}],isError:incomplete,timestamp:message.timestamp?message.timestamp+1:Date.now()}),dangling.delete(block.id)}}}return output}function StringEnum(values,options){return typebox_exports.Unsafe({type:"string",enum:values,...options?.description&&{description:options.description},...options?.default&&{default:options.default}})}var INVISIBLE_FORMAT_CHARS=new RegExp("\\p{Cf}","gu");function hasVisibleText(text){return text.replace(INVISIBLE_FORMAT_CHARS,"").trim().length>0}function hasVisibleAssistantContent(message){return message.content.some(block=>block.type==="toolCall"||block.type==="text"&&hasVisibleText(block.text))}export{create,messageDesc,fromBinary,fileDesc,toBinary,measureCursorModelInputSerializedBytes,measureCursorHistorySerializedBytes,piReadArgs,piLsPath,piLimit,piTimeout,composeShellCommand,omitUndefinedArgs,warmPromptCache,fauxText,fauxThinking,fauxToolCall,fauxAssistantMessage,createFauxCore,getRegisteredFauxProvider,fauxOverflowError,fauxProvider,installProviderScopeAccessor,registerApiProvider,registerBuiltinApiProvider,getApiProvider,getApiProviders,unregisterApiProviders,clearApiProviders,envApiKeyAuth,lazyOAuth,CURSOR_MODEL_CAPABILITIES,parseCursorVariantId,getCursorVariantAlias,getCursorBaseIdForVariant,getCursorCapabilityForBase,normalizeCursorCatalog,resolveCursorSelectionDescriptor,renderCursorCliModelString,ANTHROPIC_AUTH_TOKEN_ENV,ANTHROPIC_OAUTH_TOKEN_ENV,ANTHROPIC_API_KEY_ENV,getApiKeyEnvVars,findEnvKeys,getEnvApiKey,createImagesModels,createImagesProvider,createXtmlRecoveryStreamParser,wrapStreamWithInvokeRecovery,Compile,compile_exports,validateToolCall,validateToolArguments,require_dist,getProtocol,transformContext,wrapStreamWithToolCallMiddleware,getToolCallFormat,shouldRecoverTextToolCalls,hasKimiTextToolCallRecovery,wrapStreamWithModelRecovery,AssistantMessageFrameEncoder,reduceAssistantMessageFrames,kCursorExecResolved,isCursorExecResolved,copyCursorExecResolved,dropFailedAssistantTurns,EMPTY_RESPONSE_ERROR,EMPTY_TOOL_USE_ERROR,FORWARDED_EMPTY_RESPONSE_ERROR,FORWARDED_EMPTY_TOOL_USE_ERROR,isContextOverflow,isRecoverableLength,getOverflowPatterns,isCursorPayloadResourceExhausted,isCursorQuotaResourceExhausted,isCursorZeroTokenResourceExhausted,shouldSkipProviderFallbackForCursorZeroRe,shouldRetryOverflowWithoutCompact,cursorOverflowCompactionSettings,USAGE_LIMIT_EXHAUSTION,DEFAULT_MAX_AGENT_RETRY_DELAY_MS,retryDelayMs,retryTransientCall,retryAssistantCall,isRetryableAssistantError,isProviderStreamStallError,formatStallDuration,describeProviderStallForUser,isProviderTimeoutError,isRetryableErrorMessage,classifyErrorMessage,TURN_RETRY_SUPPRESSION_PREFIX,stripTurnRetrySuppressionPrefix,describeProviderFailureForUser,isClassifierRefusal,contentText,TOOL_RESULT_PLACEHOLDER,repairOrphanedToolResults,StringEnum,hasVisibleText,hasVisibleAssistantContent};
|
|
326
|
+
${context.systemPrompt}`:toolPrompt)}return transformed}function transformMessage(message,protocol){switch(message.role){case"assistant":return transformAssistantMessage(message,protocol);case"toolResult":return transformToolResultMessage(message,protocol);default:return message}}function transformAssistantMessage(message,protocol){if(!message.content.some(block=>block.type==="toolCall"))return message;let newContent=[];for(let block of message.content)switch(block.type){case"text":{newContent.push(block);break}case"thinking":{newContent.push(block);break}case"toolCall":{let toolCallText=protocol.formatToolCall(block.name,block.arguments);newContent.push({type:"text",text:toolCallText});break}}return{...message,content:newContent}}function transformToolResultMessage(message,protocol){return{role:"user",content:protocol.formatToolResponse(message.toolName,message.toolCallId,message.content),timestamp:message.timestamp}}function wrapStreamWithToolCallMiddleware(innerStream,protocol,tools){let outerStream=new AssistantMessageEventStream,parser=protocol.createStreamParser(tools);return(async()=>{let projection=null,sawToolCall=!1,parserHasPendingInput=!1,flushParser=()=>{if(!projection||!parserHasPendingInput)return;let result=projection.projectParserEvents(parser.finish());sawToolCall=sawToolCall||result.sawToolCall,projection.finishText(),parserHasPendingInput=!1};try{for await(let event of innerStream)switch(event.type){case"start":projection=new StreamMessageProjection(outerStream,event.partial),outerStream.push({type:"start",partial:projection.message});break;case"text_start":if(!projection)break;projection.sync(event.partial),projection.startText(event.contentIndex,event.partial.content[event.contentIndex]);break;case"text_delta":{if(!projection)break;projection.sync(event.partial),event.delta.length>0&&(parserHasPendingInput=!0);let result=projection.projectParserEvents(parser.feed(event.delta));sawToolCall=sawToolCall||result.sawToolCall;break}case"text_end":if(!projection)break;projection.sync(event.partial),flushParser();break;case"thinking_start":if(!projection)break;projection.sync(event.partial),projection.startThinking(event.contentIndex,event.partial);break;case"thinking_delta":if(!projection)break;projection.sync(event.partial),projection.projectThinkingDelta(event.contentIndex,event.delta,event.partial);break;case"thinking_end":if(!projection)break;projection.sync(event.partial),projection.finishThinking(event.contentIndex,event.content,event.partial);break;case"done":{projection??=new StreamMessageProjection(outerStream,event.message),flushParser(),projection.finalizeDanglingToolCalls();let message=projection.finalize(event.message,sawToolCall),reason=(sawToolCall||projection.hasFinalizedToolCallContent())&&(event.reason==="stop"||event.reason==="length")?"toolUse":event.reason;outerStream.push({type:"done",reason,message}),outerStream.end();return}case"error":{if(!projection){outerStream.push(event),outerStream.end(event.error);return}projection.sync(event.error),flushParser(),projection.finalizeDanglingToolCalls();let message=projection.finalize(event.error,sawToolCall);if(projection.hasFinalizedToolCallContent()){let recovered={...message,stopReason:"toolUse"};outerStream.push({type:"done",reason:"toolUse",message:recovered}),outerStream.end(recovered);return}outerStream.push({type:"error",reason:event.reason,error:message}),outerStream.end(message);return}case"toolcall_start":case"toolcall_delta":case"toolcall_end":break}let innerMessage=await innerStream.result();projection??=new StreamMessageProjection(outerStream,innerMessage),flushParser(),projection.finalizeDanglingToolCalls(),outerStream.end(projection.finalize(innerMessage,sawToolCall))}catch(error){flushParser(),projection??=new StreamMessageProjection(outerStream,await innerStream.result()),projection.finalizeDanglingToolCalls();let fallback=projection.message;fallback.stopReason="error",fallback.errorMessage=error instanceof Error?error.message:JSON.stringify(error),outerStream.push({type:"error",reason:"error",error:fallback}),outerStream.end()}})(),outerStream}function getToolCallFormat(model){if(model.api!=="openai-completions")return;let format=model.compat?.toolCallFormat;if(format&&(format==="hermes"||format==="xml"||format==="morph-xml"||format==="yaml-xml"||format==="gemma4-delimiter"||format==="anthropic-xml"||format==="antml"||format==="kimi-xtml"))return format}function shouldRecoverTextToolCalls(model){return getToolCallFormat(model)!==void 0?!1:model.recoverTextToolCalls!==void 0?typeof model.recoverTextToolCalls=="boolean"?model.recoverTextToolCalls:!1:model.api==="cursor-agent"?!1:CLAUDE_MODEL_ID_PATTERN.test(model.id)||KIMI_MODEL_ID_PATTERN.test(model.id)}var CLAUDE_MODEL_ID_PATTERN=/(^|[^a-z0-9])claude([^a-z0-9]|$)/i,KIMI_MODEL_ID_PATTERN=/(^|[^a-z0-9])kimi([^a-z0-9]|$)/i;function hasKimiTextToolCallRecovery(model){return KIMI_MODEL_ID_PATTERN.test(model.id)}function wrapStreamWithModelRecovery(innerStream,model,tools){let recoveredStream=hasKimiTextToolCallRecovery(model)?wrapStreamWithKimiThinkingRecovery(innerStream):innerStream;return!shouldRecoverTextToolCalls(model)||tools.length===0?recoveredStream:wrapStreamWithInvokeRecovery(recoveredStream,tools,hasKimiTextToolCallRecovery(model)?{createParser:createXtmlRecoveryStreamParser,protocol:"kimi-xtml"}:void 0)}function cloneTextContent(content){return{type:"text",text:content.text,...content.textSignature===void 0?{}:{textSignature:content.textSignature}}}function cloneThinkingContent(content){return{type:"thinking",thinking:content.thinking,...content.thinkingSignature===void 0?{}:{thinkingSignature:content.thinkingSignature},...content.redacted===void 0?{}:{redacted:content.redacted}}}function cloneToolCall2(toolCall){return{type:"toolCall",id:toolCall.id,name:toolCall.name,arguments:structuredClone(toolCall.arguments),...toolCall.thoughtSignature===void 0?{}:{thoughtSignature:toolCall.thoughtSignature},...toolCall.namespace===void 0?{}:{namespace:toolCall.namespace}}}function cloneStartMessage(message){return{role:"assistant",content:[],api:message.api,provider:message.provider,model:message.model,...message.responseModel===void 0?{}:{responseModel:message.responseModel},...message.responseId===void 0?{}:{responseId:message.responseId},...message.providerThinkingLevel===void 0?{}:{providerThinkingLevel:message.providerThinkingLevel},...message.diagnostics===void 0?{}:{diagnostics:structuredClone(message.diagnostics)},usage:structuredClone(message.usage),stopReason:"pending",timestamp:message.timestamp}}function assertContentIndex(contentIndex){if(!Number.isSafeInteger(contentIndex)||contentIndex<0)throw new Error(`Invalid assistant message frame contentIndex: ${contentIndex}`)}function eventBlock(event){assertContentIndex(event.contentIndex);let block=event.partial.content[event.contentIndex];if(!block)throw new Error(`${event.type} event has no content block at index ${event.contentIndex}`);return block}function serializedArguments(argumentsValue){let serialized=JSON.stringify(argumentsValue);if(serialized===void 0)throw new Error("Tool-call arguments are not JSON-serializable");return serialized}var EMPTY_PARSED_TOOL_ARGUMENTS=serializedArguments(parseStreamingJson(""));function isJsonPrefix(snapshot,current){if(typeof snapshot=="string")return typeof current=="string"&¤t.startsWith(snapshot);if(Array.isArray(snapshot))return Array.isArray(current)&&snapshot.length<=current.length&&snapshot.every((value,index)=>isJsonPrefix(value,current[index]));if(typeof snapshot!="object"||snapshot===null)return Object.is(snapshot,current);if(typeof current!="object"||current===null||Array.isArray(current))return!1;let currentRecord=current;return Object.entries(snapshot).every(([key,value])=>Object.hasOwn(currentRecord,key)&&isJsonPrefix(value,currentRecord[key]))}var AssistantMessageFrameEncoder=class{constructor(){this.started=!1,this.terminal=!1,this.blocks=new Map}encode(event){if(this.terminal)throw new Error(`Assistant message event ${event.type} follows a terminal event`);switch(event.type){case"start":if(this.started)throw new Error("Assistant message stream contains more than one start event");return this.started=!0,{type:"start",partial:cloneStartMessage(event.partial)};case"done":if(!this.started)throw new Error("Assistant message done event appears before start");this.terminal=!0;return;case"error":this.terminal=!0;return}if(!this.started)throw new Error(`Assistant message ${event.type} event appears before start`);switch(event.type){case"text_start":{let content=eventBlock(event);if(content.type!=="text")throw new Error(`text_start event points to ${content.type} block at index ${event.contentIndex}`);return this.startBlock(event.contentIndex,{kind:"text",coveredChars:content.text.length,deltaChars:0}),{type:"text_start",contentIndex:event.contentIndex,content:cloneTextContent(content)}}case"text_delta":return this.encodeTextDelta(event.contentIndex,event.delta,"text");case"text_end":{let content=eventBlock(event);if(content.type!=="text")throw new Error(`text_end event points to ${content.type} block at index ${event.contentIndex}`);return this.endBlock(event.contentIndex,"text"),{type:"text_end",contentIndex:event.contentIndex,content:event.content,...content.textSignature===void 0?{}:{textSignature:content.textSignature}}}case"thinking_start":{let content=eventBlock(event);if(content.type!=="thinking")throw new Error(`thinking_start event points to ${content.type} block at index ${event.contentIndex}`);return this.startBlock(event.contentIndex,{kind:"thinking",coveredChars:content.thinking.length,deltaChars:0}),{type:"thinking_start",contentIndex:event.contentIndex,content:cloneThinkingContent(content)}}case"thinking_delta":return this.encodeTextDelta(event.contentIndex,event.delta,"thinking");case"thinking_end":{let content=eventBlock(event);if(content.type!=="thinking")throw new Error(`thinking_end event points to ${content.type} block at index ${event.contentIndex}`);return this.endBlock(event.contentIndex,"thinking"),{type:"thinking_end",contentIndex:event.contentIndex,content:event.content,...content.thinkingSignature===void 0?{}:{thinkingSignature:content.thinkingSignature},...content.redacted===void 0?{}:{redacted:content.redacted}}}case"toolcall_start":{let content=eventBlock(event);if(content.type!=="toolCall")throw new Error(`toolcall_start event points to ${content.type} block at index ${event.contentIndex}`);let snapshotArguments=serializedArguments(content.arguments),caughtUp=snapshotArguments===EMPTY_PARSED_TOOL_ARGUMENTS;return this.startBlock(event.contentIndex,{kind:"toolCall",caughtUp,catchupJson:"",snapshotArguments:caughtUp?"":snapshotArguments}),{type:"toolcall_start",contentIndex:event.contentIndex,toolCall:cloneToolCall2(content)}}case"toolcall_delta":{let state=this.block(event.contentIndex,"toolCall");if(state.kind!=="toolCall")throw new Error("Unreachable tool-call encoder state");if(state.caughtUp)return event.delta.length===0?void 0:{type:"toolcall_delta",contentIndex:event.contentIndex,delta:event.delta};state.catchupJson+=event.delta;let argumentsValue=parseStreamingJson(state.catchupJson);if(serializedArguments(argumentsValue)!==state.snapshotArguments){let snapshotArguments=parseStreamingJson(state.snapshotArguments);if(!isJsonPrefix(snapshotArguments,argumentsValue))return}state.caughtUp=!0,state.snapshotArguments="";let json=state.catchupJson;return state.catchupJson="",json.length===0?void 0:{type:"toolcall_checkpoint",contentIndex:event.contentIndex,json}}case"toolcall_end":{let content=eventBlock(event);if(content.type!=="toolCall")throw new Error(`toolcall_end event points to ${content.type} block at index ${event.contentIndex}`);if(event.toolCall.type!=="toolCall")throw new Error(`toolcall_end event has invalid tool call at index ${event.contentIndex}`);return this.endBlock(event.contentIndex,"toolCall"),{type:"toolcall_end",contentIndex:event.contentIndex,id:event.toolCall.id,name:event.toolCall.name,arguments:structuredClone(event.toolCall.arguments),...event.toolCall.thoughtSignature===void 0?{}:{thoughtSignature:event.toolCall.thoughtSignature},...event.toolCall.namespace===void 0?{}:{namespace:event.toolCall.namespace}}}}}startBlock(contentIndex,state){if(assertContentIndex(contentIndex),this.blocks.has(contentIndex))throw new Error(`Assistant message block ${contentIndex} starts more than once`);this.blocks.set(contentIndex,state)}block(contentIndex,kind){assertContentIndex(contentIndex);let state=this.blocks.get(contentIndex);if(state===void 0)throw new Error(`Assistant message ${kind} block ${contentIndex} has not started`);if(state.kind!==kind)throw new Error(`Assistant message block ${contentIndex} is ${state.kind}, not ${kind}`);return state}endBlock(contentIndex,kind){this.block(contentIndex,kind),this.blocks.delete(contentIndex)}encodeTextDelta(contentIndex,delta,kind){let state=this.block(contentIndex,kind);if(state.kind==="toolCall")throw new Error("Unreachable text encoder state");let deltaStart=state.deltaChars;state.deltaChars+=delta.length;let covered=Math.max(0,state.coveredChars-deltaStart);if(covered>=delta.length)return;let uncovered=covered===0?delta:delta.slice(covered);return kind==="text"?{type:"text_delta",contentIndex,delta:uncovered}:{type:"thinking_delta",contentIndex,delta:uncovered}}};function appendBlock(message,states,contentIndex,block,state){if(assertContentIndex(contentIndex),contentIndex!==message.content.length){let reason=contentIndex<message.content.length?"already exists":"would leave a gap";throw new Error(`Cannot start assistant message block at index ${contentIndex}: ${reason}`)}message.content.push(structuredClone(block)),states.set(contentIndex,state)}function activeBlock(message,states,contentIndex,expectedKind,frameType){assertContentIndex(contentIndex);let state=states.get(contentIndex),block=message.content[contentIndex];if(!state||!block)throw new Error(`${frameType} frame has no started block at index ${contentIndex}`);if(state.kind!==expectedKind||block.type!==expectedKind)throw new Error(`${frameType} frame expected ${expectedKind} block at index ${contentIndex}, found ${block.type}`);if(state.ended)throw new Error(`${frameType} frame follows the end of block at index ${contentIndex}`);return{block,state}}function reduceAssistantMessageFrames(frames){let message,frameBeforeStart,states=new Map;for(let frame of frames){if(frame.type==="start"){if(message)throw new Error("Assistant message frame sequence contains more than one start frame");if(frameBeforeStart!==void 0)throw new Error(`${frameBeforeStart} frame appears before the start frame`);message=structuredClone(frame.partial);continue}if(!message){frameBeforeStart??=frame.type;continue}switch(frame.type){case"text_start":if(frame.content.type!=="text")throw new Error(`text_start frame contains ${frame.content.type} content`);appendBlock(message,states,frame.contentIndex,frame.content,{kind:"text",ended:!1});break;case"text_delta":{let{block}=activeBlock(message,states,frame.contentIndex,"text",frame.type);if(block.type!=="text")throw new Error("Unreachable text frame state");block.text+=frame.delta;break}case"text_end":{let{block,state}=activeBlock(message,states,frame.contentIndex,"text",frame.type);if(block.type!=="text")throw new Error("Unreachable text frame state");block.text=frame.content,delete block.textSignature,frame.textSignature!==void 0&&(block.textSignature=frame.textSignature),state.ended=!0;break}case"thinking_start":if(frame.content.type!=="thinking")throw new Error(`thinking_start frame contains ${frame.content.type} content`);appendBlock(message,states,frame.contentIndex,frame.content,{kind:"thinking",ended:!1});break;case"thinking_delta":{let{block}=activeBlock(message,states,frame.contentIndex,"thinking",frame.type);if(block.type!=="thinking")throw new Error("Unreachable thinking frame state");block.thinking+=frame.delta;break}case"thinking_end":{let{block,state}=activeBlock(message,states,frame.contentIndex,"thinking",frame.type);if(block.type!=="thinking")throw new Error("Unreachable thinking frame state");block.thinking=frame.content,delete block.thinkingSignature,delete block.redacted,frame.thinkingSignature!==void 0&&(block.thinkingSignature=frame.thinkingSignature),frame.redacted!==void 0&&(block.redacted=frame.redacted),state.ended=!0;break}case"toolcall_start":if(frame.toolCall.type!=="toolCall")throw new Error(`toolcall_start frame contains ${frame.toolCall.type} content`);appendBlock(message,states,frame.contentIndex,frame.toolCall,{kind:"toolCall",ended:!1,json:""});break;case"toolcall_checkpoint":{let{block,state}=activeBlock(message,states,frame.contentIndex,"toolCall",frame.type);if(block.type!=="toolCall"||state.kind!=="toolCall")throw new Error("Unreachable tool-call checkpoint state");state.json=frame.json,block.arguments=parseStreamingJson(frame.json);break}case"toolcall_delta":{let{block,state}=activeBlock(message,states,frame.contentIndex,"toolCall",frame.type);if(block.type!=="toolCall"||state.kind!=="toolCall")throw new Error("Unreachable tool-call frame state");state.json+=frame.delta;break}case"toolcall_end":{let{block,state}=activeBlock(message,states,frame.contentIndex,"toolCall",frame.type);if(block.type!=="toolCall")throw new Error("Unreachable tool-call frame state");block.id=frame.id,block.name=frame.name,block.arguments=structuredClone(frame.arguments),delete block.thoughtSignature,delete block.namespace,frame.thoughtSignature!==void 0&&(block.thoughtSignature=frame.thoughtSignature),frame.namespace!==void 0&&(block.namespace=frame.namespace),state.ended=!0;break}}}if(message){for(let[contentIndex,state]of states){if(state.kind!=="toolCall"||state.ended||state.json.length===0)continue;let block=message.content[contentIndex];if(block?.type!=="toolCall")throw new Error("Unreachable tool-call frame state");block.arguments=parseStreamingJson(state.json)}return message}}var kCursorExecResolved=Symbol("provider.block.cursorExecResolved");function isCursorExecResolved(block){return block?.[kCursorExecResolved]===!0}function copyCursorExecResolved(target,source){source[kCursorExecResolved]===!0&&(target[kCursorExecResolved]=!0)}function dropFailedAssistantTurns(messages){let callIdsByKeptAssistants=new Set,callIdsByFailedAssistants=new Set;for(let message of messages){let assistant=asAssistantTurn(message);if(!assistant)continue;let declared=isFailedStop(assistant.stopReason)?callIdsByFailedAssistants:callIdsByKeptAssistants;for(let block of assistant.content)block.type==="toolCall"&&typeof block.id=="string"&&declared.add(block.id)}for(let id of callIdsByKeptAssistants)callIdsByFailedAssistants.delete(id);return messages.filter(message=>{let assistant=asAssistantTurn(message);return assistant?!isFailedStop(assistant.stopReason):message.role==="toolResult"&&"toolCallId"in message&&typeof message.toolCallId=="string"?!callIdsByFailedAssistants.has(message.toolCallId):!0})}function asAssistantTurn(message){if(message.role==="assistant"&&!(!("content"in message)||!Array.isArray(message.content)))return{stopReason:"stopReason"in message?message.stopReason:void 0,content:message.content}}function isFailedStop(stopReason){return stopReason==="error"||stopReason==="aborted"}var EMPTY_RESPONSE_ERROR="Model returned an empty response twice",EMPTY_TOOL_USE_ERROR="Model returned tool_use without a tool call twice",FORWARDED_EMPTY_RESPONSE_ERROR="Model returned an empty response after streaming thinking",FORWARDED_EMPTY_TOOL_USE_ERROR="Model returned tool_use without a tool call after streaming thinking";var OVERFLOW_PATTERNS=[/^Context window exhausted: /,/prompt is too long/i,/request_too_large/i,/input is too long for requested model/i,/exceeds (?:(?:the|this) )?(?:model'?s )?context window/i,/exceeds (?:the )?(?:model'?s )?maximum context length(?: of [\d,]+ tokens?|\s*\([\d,]+\))/i,/input token count.*exceeds the maximum/i,/maximum prompt length is \d+/i,/reduce the length of the messages/i,/maximum context length is \d+ tokens/i,/exceeds (?:the )?maximum allowed input length of [\d,]+ tokens?/i,/input \(\d+ tokens\) is longer than the model'?s context length \(\d+ tokens\)/i,/exceeds the limit of \d+/i,/exceeds the available context size/i,/greater than the context length/i,/context window exceeds limit/i,/exceeded model token limit/i,/too large for model with \d+ maximum context length/i,/prompt has [\d,]+ tokens?, but the configured context size is [\d,]+ tokens?/i,/model_context_window_exceeded/i,/prompt too long; exceeded (?:max )?context length/i,/range of input length should be/i,/context[_ ]length[_ ]exceeded/i,/too many tokens/i,/token limit exceeded/i,/^4(?:00|13)\s*(?:status code)?\s*\(no body\)/i,/(?:request[ _])?(?:body|entity|payload)[_ ]too[_ ]large/i,/Request payload is \d+ (?:bytes, over the \d+ byte|tokens, over the \d+ token) limit Kiro accepts\./,/Model context limit reached\. Conversation size exceeds model capacity\./],NON_OVERFLOW_PATTERNS=[/^(Throttling error|Service unavailable):/i,/rate limit/i,/too many requests/i,/tokens per (?:min|minute|hour|day)/i,/\bTPM\b/i,/\bRPM\b/i,/quota exceeded/i,/retry (?:after|in) \d/i,/^429\b/,/status code 429/i,/overloaded/i],RESOURCE_EXHAUSTED_PATTERN=/resource.?exhausted/i;function isContextOverflow(message,contextWindow){if(message.stopReason==="error"&&message.errorMessage){let isNonOverflow=NON_OVERFLOW_PATTERNS.some(p=>p.test(message.errorMessage));if(!isNonOverflow&&OVERFLOW_PATTERNS.some(p=>p.test(message.errorMessage)))return!0;let usage=message.usage,hasTokenEvidence=(usage.totalTokens||usage.input+usage.output+usage.cacheRead+usage.cacheWrite)>0;if(!isNonOverflow&&hasTokenEvidence&&RESOURCE_EXHAUSTED_PATTERN.test(message.errorMessage)&&(contextWindow===void 0||contextWindow<=0||cursorZeroTokenCount(message)>=contextWindow*.5))return!0}return!!(contextWindow&&message.stopReason==="stop"&&message.usage.input+message.usage.cacheRead>contextWindow||contextWindow&&message.stopReason==="length"&&message.usage.output===0&&message.usage.input+message.usage.cacheRead>=contextWindow*.99)}function isRecoverableLength(message,desiredMaxOutput){return message.stopReason==="length"&&desiredMaxOutput>0&&message.usage.output<desiredMaxOutput}function getOverflowPatterns(){return[...OVERFLOW_PATTERNS]}function cursorZeroTokenCount(message){let usage=message.usage;return usage?usage.totalTokens||(usage.input??0)+(usage.output??0)+(usage.cacheRead??0)+(usage.cacheWrite??0):0}function isCursorPayloadResourceExhausted(message,_estimateTokens){return message.stopReason!=="error"||!/resource.?exhausted/i.test(message.errorMessage||"")?!1:!(cursorZeroTokenCount(message)>0)}function isCursorQuotaResourceExhausted(message,contextWindow){let tokens=cursorZeroTokenCount(message);return message.stopReason==="error"&&RESOURCE_EXHAUSTED_PATTERN.test(message.errorMessage||"")&&contextWindow>0&&tokens>0&&tokens<contextWindow*.5}function isCursorZeroTokenResourceExhausted(message){return message.stopReason!=="error"||!/resource.?exhausted/i.test(message.errorMessage||"")?!1:!(cursorZeroTokenCount(message)>0)}function shouldSkipProviderFallbackForCursorZeroRe(options){return options?.sameModelRemint===!0}function shouldRetryOverflowWithoutCompact(compacted,errorMessage){return compacted?!1:/Nothing to compact/i.test(errorMessage||"")}function cursorOverflowCompactionSettings(settings,provider,reason){return reason!=="overflow"||provider!=="cursor"&&provider!=="cursor-cli-oauth"?settings:{...settings,keepRecentTokens:0,restorationEnabled:!1}}function buildProviderErrorPattern(patterns){return new RegExp(patterns.join("|"),"i")}function escapeRegExp5(text){return text.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var USAGE_LIMIT_EXHAUSTION={codes:["usage_limit_reached","usage_not_included"],markers:["usage_limit_reached","usage_not_included","usage limit has been reached"]},NON_RETRYABLE_PROVIDER_ERROR_PATTERN=buildProviderErrorPattern(["GoUsageLimitError","FreeUsageLimitError","Monthly usage limit reached","available balance","insufficient_quota","out of budget","quota exceeded","billing","credits_required","credits are required",...USAGE_LIMIT_EXHAUSTION.markers,"invalid request: tools\\.","invalid request: functions\\.","tools\\.[^ ]*function\\.parameters","tools\\.\\d+\\.function\\.parameters","invalid tool schema"]),RETRYABLE_PROVIDER_ERROR_PATTERN=buildProviderErrorPattern(["Credential store is busy: lock","overloaded","rate.?limit","too many requests","429","500","502","503","504","522","524","service.?unavailable","server.?error","internal.?error","provider.?returned.?error","exceeded request buffer limit while retrying upstream","network.?error","connection.?error","connection.?refused","connection.?lost","other side closed","fetch failed","getaddrinfo","ENOTFOUND","EAI_AGAIN","upstream.?connect","upstream.?unavailable","reset before headers","socket hang up","socket connection was closed","timed? out","timeout","terminated","websocket.?closed","websocket.?error","ended without","stream ended before message_stop","stream ended before a terminal response event","http2 request did not get a response","retry delay","you can retry your request","try your request again","please retry your request","the model request was rejected\\.\\s*check the request and try again\\.?","was found without a corresponding `",escapeRegExp5(FORWARDED_EMPTY_RESPONSE_ERROR),escapeRegExp5(FORWARDED_EMPTY_TOOL_USE_ERROR),"ResourceExhausted","Lock file is already being held"]),DEFAULT_MAX_AGENT_RETRY_DELAY_MS=6e4;function retryDelayMs(policy,attempt){let scheduledDelayMs=policy.baseDelayMs*2**Math.max(0,attempt-1),sample=Math.min(1,Math.max(0,(policy.random??Math.random)())),jitteredDelayMs=Math.round(scheduledDelayMs*(.9+sample*.2)),safeDelay=Number.isSafeInteger(jitteredDelayMs)?jitteredDelayMs:Number.MAX_SAFE_INTEGER;return Math.min(safeDelay,policy.maxAgentDelayMs??DEFAULT_MAX_AGENT_RETRY_DELAY_MS)}var RetrySleepAbortError=class extends Error{constructor(){super("Aborted")}};function sleep(ms,signal){return new Promise((resolve,reject)=>{if(signal?.aborted){reject(new RetrySleepAbortError);return}let timeout=setTimeout(resolve,ms);signal?.addEventListener("abort",()=>{clearTimeout(timeout),reject(new RetrySleepAbortError)},{once:!0})})}async function retryTransientCall(produce,isRetryable,policy,signal,callbacks){let maxAttempts=policy?.enabled?policy.maxRetries:0,attempt=0,lastRetry;for(;;)try{let value=await produce();return lastRetry&&await callbacks?.onRetryFinished?.(!0,lastRetry.attempt),value}catch(error){if(error instanceof RetrySleepAbortError)throw error;if(attempt>=maxAttempts||!isRetryable(error))throw lastRetry&&await callbacks?.onRetryFinished?.(!1,lastRetry.attempt,errorMessageOf(error)),error;attempt++,lastRetry={attempt,errorMessage:errorMessageOf(error)};let delayMs=retryDelayMs(policy,attempt);await callbacks?.onRetryScheduled?.(attempt,maxAttempts,delayMs,lastRetry.errorMessage);try{await sleep(delayMs,signal)}catch(sleepError){throw await callbacks?.onRetryFinished?.(!1,attempt,lastRetry.errorMessage),sleepError instanceof RetrySleepAbortError?error:sleepError}await callbacks?.onRetryAttemptStart?.()}}function errorMessageOf(error){return error instanceof Error?error.message||"Unknown error":String(error)||"Unknown error"}async function retryAssistantCall(produce,policy,signal,callbacks){let maxAttempts=policy?.enabled?policy.maxRetries:0,attempt=0,lastRetry;for(;;){let response=await produce();if(response.stopReason==="aborted")return lastRetry&&await callbacks?.onRetryFinished?.(!1,lastRetry.attempt),response;if(response.stopReason!=="error")return lastRetry&&await callbacks?.onRetryFinished?.(!0,lastRetry.attempt),response;if(attempt>=maxAttempts||!isRetryableAssistantError(response))return lastRetry&&await callbacks?.onRetryFinished?.(!1,lastRetry.attempt,response.errorMessage),response;attempt++,lastRetry={attempt,errorMessage:response.errorMessage||"Unknown error"};let delayMs=retryDelayMs(policy,attempt);await callbacks?.onRetryScheduled?.(attempt,maxAttempts,delayMs,lastRetry.errorMessage);try{await sleep(delayMs,signal)}catch(error){if(await callbacks?.onRetryFinished?.(!1,attempt,lastRetry.errorMessage),error instanceof RetrySleepAbortError){let{errorMessage:_errorMessage,...rest}=response;return{...rest,stopReason:"aborted"}}throw error}await callbacks?.onRetryAttemptStart?.()}}function isRetryableAssistantError(message){return message.stopReason!=="error"||message.stopDetails?.type==="refusal"||message.stopDetails?.type==="sensitive"||!message.errorMessage?!1:isRetryableErrorMessage(message.errorMessage)}var PROVIDER_STREAM_STALL_ERROR_PATTERN=/^(?:Idle timeout waiting for provider stream after \d+ms|Provider stream start timed out after \d+ms(?: \([^)]*\))?|WebSocket liveness timeout after \d+ms \(\d+ pings unanswered\)|Provider stream stalled after the last output item: response\.completed timed out after \d+ms)$/i,PROVIDER_TRANSPORT_TIMEOUT_ERROR_PATTERN=/^Request timed out\.?$/i;function isProviderStreamStallError(message){return message.stopReason==="error"&&PROVIDER_STREAM_STALL_ERROR_PATTERN.test(message.errorMessage??"")}var PROVIDER_STALL_PHASES=[{pattern:/^Provider stream start timed out after (\d+)ms/i,symptom:"accepted the request but never started sending a response",setting:"retry.provider.streamStartTimeoutMs"},{pattern:/^Idle timeout waiting for provider stream after (\d+)ms/i,symptom:"started the response and then went silent",setting:"retry.provider.timeoutMs"},{pattern:/^WebSocket liveness timeout after (\d+)ms/i,symptom:"stopped answering connection health checks"},{pattern:/^Provider stream stalled after the last output item: response\.completed timed out after (\d+)ms/i,symptom:"finished its output but never sent the end-of-response event"}];function formatStallDuration(timeoutMs){return timeoutMs<1e3?`${timeoutMs}ms`:timeoutMs<12e4?`${Math.round(timeoutMs/100)/10}s`:`${Math.round(timeoutMs/6e3)/10}m`}function describeProviderStallForUser(errorMessage,options={}){if(errorMessage)for(let{pattern,symptom,setting}of PROVIDER_STALL_PHASES){let match=pattern.exec(errorMessage);if(!match)continue;let subject=options.model?`The provider for ${options.model}`:"The provider",duration=formatStallDuration(Number(match[1])),sentences=[`${subject} ${symptom} within ${duration}, so the request was cancelled.`],attempts=options.attempts??0;if(attempts>0&&sentences.push(`Retried ${attempts} time${attempts===1?"":"s"} on the same model with the same result.`),options.recovery){let raise=setting?`, or raise ${setting} in settings (0 disables the bound)`:"",lead=options.recovery==="no-fallback-configured"?"No fallback model is configured for it, so nothing could take the turn over: run /fallback to add one":"Every model in its fallback chain was tried as well: run /fallback to review the chain";sentences.push(`${lead}, send the message again${raise}.`)}return sentences.join(" ")}}function isProviderTimeoutError(message){return message.abortSource==="provider"||isProviderStreamStallError(message)?!0:message.stopReason!=="error"&&message.stopReason!=="aborted"?!1:PROVIDER_TRANSPORT_TIMEOUT_ERROR_PATTERN.test(message.errorMessage??"")}function isRetryableErrorMessage(errorMessage){return classifyErrorMessage(errorMessage)==="retryable"}function classifyErrorMessage(errorMessage){return errorMessage?NON_RETRYABLE_PROVIDER_ERROR_PATTERN.test(errorMessage)?"non-retryable":RETRYABLE_PROVIDER_ERROR_PATTERN.test(errorMessage)?"retryable":"unknown":"unknown"}var TURN_RETRY_SUPPRESSION_PREFIX="senpi:no-turn-retry:";function stripTurnRetrySuppressionPrefix(message){return message.replaceAll(TURN_RETRY_SUPPRESSION_PREFIX,"")}var WEBSOCKET_CLOSED_PATTERN=/^WebSocket closed\b/i,WEBSOCKET_ERROR_PATTERN=/^WebSocket error$/i,WEBSOCKET_CONNECT_TIMEOUT_PATTERN=/^WebSocket connect timeout after (\d+)ms/i,RECOVERY_SENTENCE={"no-fallback-configured":"No fallback model is configured for it, so nothing could take the turn over: run /fallback to add one, or send the message again to continue from the partial reply.","chain-exhausted":"Every model in its fallback chain was tried as well: run /fallback to review the chain, or send the message again to continue from the partial reply."};function transportSymptom(errorMessage,subject){if(WEBSOCKET_CLOSED_PATTERN.test(errorMessage))return`The connection to ${subject} dropped before the reply finished (${errorMessage}).`;if(WEBSOCKET_ERROR_PATTERN.test(errorMessage))return`The connection to ${subject} reported an error before the reply finished (${errorMessage}).`;let connectTimeout=WEBSOCKET_CONNECT_TIMEOUT_PATTERN.exec(errorMessage);if(connectTimeout)return`${subject.replace(/^the provider/,"The provider")} did not accept the connection within ${formatStallDuration(Number(connectTimeout[1]))}.`}function describeProviderFailureForUser(errorMessage,options={}){if(!errorMessage)return;let message=stripTurnRetrySuppressionPrefix(errorMessage).trim();if(!message)return;let stall=describeProviderStallForUser(message,options);if(stall!==void 0)return stall;let subject=options.model?`the provider for ${options.model}`:"the provider",symptom=transportSymptom(message,subject);if(symptom===void 0)return;let sentences=[symptom],attempts=options.attempts??0;return attempts>0&&sentences.push(`Retried ${attempts} time${attempts===1?"":"s"} on the same model with the same result.`),options.recovery&&sentences.push(RECOVERY_SENTENCE[options.recovery]),sentences.join(" ")}var ANTHROPIC_POLICY_REFUSAL_PATTERN=/This request triggered restrictions on [\s\S]+? and was blocked under Anthropic's Usage Policy\b/i;function isClassifierRefusal(message){return message.stopReason!=="error"&&message.stopReason!=="toolUse"?!1:message.stopDetails?.type==="refusal"||message.stopDetails?.type==="sensitive"?!0:message.errorMessage?ANTHROPIC_POLICY_REFUSAL_PATTERN.test(message.errorMessage):!1}var TOOL_RESULT_PLACEHOLDER="Tool output unavailable (context compacted)";function incompleteToolCallRetryText(name,errorMessage){return errorMessage!==void 0?`${errorMessage}${errorMessage.endsWith(".")?"":"."} Re-issue the tool call with complete arguments.`:`Tool call "${name}" was not executed: the response ended before the tool call was complete. Re-issue the tool call with complete arguments.`}function repairOrphanedToolResults(messages){let toolCallIds=new Set,toolResultIds=new Set;for(let message of messages){if(message.role==="assistant")for(let block of message.content)block.type==="toolCall"&&toolCallIds.add(block.id);message.role==="toolResult"&&toolResultIds.add(message.toolCallId)}let output=[],dangling=new Set([...toolCallIds].filter(id=>!toolResultIds.has(id)));for(let message of messages){if(message.role==="toolResult"){if(!toolCallIds.has(message.toolCallId)){output.push({...message,content:[{type:"text",text:TOOL_RESULT_PLACEHOLDER}]});continue}output.push(message);continue}if(output.push(message),message.role==="assistant"){if(message.stopReason==="error"||message.stopReason==="aborted")continue;for(let block of message.content){if(block.type!=="toolCall"||!dangling.has(block.id))continue;let incomplete=block.incomplete===!0,text=incomplete?incompleteToolCallRetryText(block.name,block.errorMessage):TOOL_RESULT_PLACEHOLDER;output.push({role:"toolResult",toolCallId:block.id,toolName:block.name,content:[{type:"text",text}],isError:incomplete,timestamp:message.timestamp?message.timestamp+1:Date.now()}),dangling.delete(block.id)}}}return output}function StringEnum(values,options){return typebox_exports.Unsafe({type:"string",enum:values,...options?.description&&{description:options.description},...options?.default&&{default:options.default}})}var INVISIBLE_FORMAT_CHARS=new RegExp("\\p{Cf}","gu");function hasVisibleText(text){return text.replace(INVISIBLE_FORMAT_CHARS,"").trim().length>0}function hasVisibleAssistantContent(message){return message.content.some(block=>block.type==="toolCall"||block.type==="text"&&hasVisibleText(block.text))}export{create,messageDesc,fromBinary,fileDesc,toBinary,measureCursorModelInputSerializedBytes,measureCursorHistorySerializedBytes,piReadArgs,piLsPath,piLimit,piTimeout,composeShellCommand,omitUndefinedArgs,warmPromptCache,fauxText,fauxThinking,fauxToolCall,fauxAssistantMessage,createFauxCore,getRegisteredFauxProvider,fauxOverflowError,fauxProvider,installProviderScopeAccessor,registerApiProvider,registerBuiltinApiProvider,getApiProvider,getApiProviders,unregisterApiProviders,clearApiProviders,envApiKeyAuth,lazyOAuth,CURSOR_MODEL_CAPABILITIES,parseCursorVariantId,getCursorVariantAlias,getCursorBaseIdForVariant,getCursorCapabilityForBase,deriveCursorVariantAliases,normalizeCursorCatalog,resolveCursorSelectionDescriptor,renderCursorCliModelString,ANTHROPIC_AUTH_TOKEN_ENV,ANTHROPIC_OAUTH_TOKEN_ENV,ANTHROPIC_API_KEY_ENV,getApiKeyEnvVars,findEnvKeys,getEnvApiKey,createImagesModels,createImagesProvider,createXtmlRecoveryStreamParser,wrapStreamWithInvokeRecovery,Compile,compile_exports,validateToolCall,validateToolArguments,require_dist,getProtocol,transformContext,wrapStreamWithToolCallMiddleware,getToolCallFormat,shouldRecoverTextToolCalls,hasKimiTextToolCallRecovery,wrapStreamWithModelRecovery,AssistantMessageFrameEncoder,reduceAssistantMessageFrames,kCursorExecResolved,isCursorExecResolved,copyCursorExecResolved,dropFailedAssistantTurns,EMPTY_RESPONSE_ERROR,EMPTY_TOOL_USE_ERROR,FORWARDED_EMPTY_RESPONSE_ERROR,FORWARDED_EMPTY_TOOL_USE_ERROR,isContextOverflow,isRecoverableLength,getOverflowPatterns,isCursorPayloadResourceExhausted,isCursorQuotaResourceExhausted,isCursorZeroTokenResourceExhausted,shouldSkipProviderFallbackForCursorZeroRe,shouldRetryOverflowWithoutCompact,cursorOverflowCompactionSettings,USAGE_LIMIT_EXHAUSTION,DEFAULT_MAX_AGENT_RETRY_DELAY_MS,retryDelayMs,retryTransientCall,retryAssistantCall,isRetryableAssistantError,isProviderStreamStallError,formatStallDuration,describeProviderStallForUser,isProviderTimeoutError,isRetryableErrorMessage,classifyErrorMessage,TURN_RETRY_SUPPRESSION_PREFIX,stripTurnRetrySuppressionPrefix,describeProviderFailureForUser,isClassifierRefusal,contentText,TOOL_RESULT_PLACEHOLDER,repairOrphanedToolResults,StringEnum,hasVisibleText,hasVisibleAssistantContent};
|