omniroute 3.0.7 → 3.0.9

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.
Files changed (95) hide show
  1. package/app/.next/BUILD_ID +1 -1
  2. package/app/.next/build-manifest.json +2 -2
  3. package/app/.next/prerender-manifest.json +3 -3
  4. package/app/.next/server/app/(dashboard)/dashboard/a2a/page_client-reference-manifest.js +1 -1
  5. package/app/.next/server/app/(dashboard)/dashboard/agents/page_client-reference-manifest.js +1 -1
  6. package/app/.next/server/app/(dashboard)/dashboard/analytics/page_client-reference-manifest.js +1 -1
  7. package/app/.next/server/app/(dashboard)/dashboard/api-manager/page_client-reference-manifest.js +1 -1
  8. package/app/.next/server/app/(dashboard)/dashboard/audit-log/page_client-reference-manifest.js +1 -1
  9. package/app/.next/server/app/(dashboard)/dashboard/auto-combo/page_client-reference-manifest.js +1 -1
  10. package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
  11. package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
  12. package/app/.next/server/app/(dashboard)/dashboard/costs/page_client-reference-manifest.js +1 -1
  13. package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
  14. package/app/.next/server/app/(dashboard)/dashboard/health/page_client-reference-manifest.js +1 -1
  15. package/app/.next/server/app/(dashboard)/dashboard/limits/page_client-reference-manifest.js +1 -1
  16. package/app/.next/server/app/(dashboard)/dashboard/logs/page_client-reference-manifest.js +1 -1
  17. package/app/.next/server/app/(dashboard)/dashboard/mcp/page_client-reference-manifest.js +1 -1
  18. package/app/.next/server/app/(dashboard)/dashboard/media/page_client-reference-manifest.js +1 -1
  19. package/app/.next/server/app/(dashboard)/dashboard/onboarding/page_client-reference-manifest.js +1 -1
  20. package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
  21. package/app/.next/server/app/(dashboard)/dashboard/playground/page_client-reference-manifest.js +1 -1
  22. package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
  23. package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
  24. package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
  25. package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
  26. package/app/.next/server/app/(dashboard)/dashboard/search-tools/page_client-reference-manifest.js +1 -1
  27. package/app/.next/server/app/(dashboard)/dashboard/settings/page_client-reference-manifest.js +1 -1
  28. package/app/.next/server/app/(dashboard)/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
  29. package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
  30. package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
  31. package/app/.next/server/app/400/page_client-reference-manifest.js +1 -1
  32. package/app/.next/server/app/401/page_client-reference-manifest.js +1 -1
  33. package/app/.next/server/app/403/page_client-reference-manifest.js +1 -1
  34. package/app/.next/server/app/408/page_client-reference-manifest.js +1 -1
  35. package/app/.next/server/app/429/page_client-reference-manifest.js +1 -1
  36. package/app/.next/server/app/500/page_client-reference-manifest.js +1 -1
  37. package/app/.next/server/app/502/page_client-reference-manifest.js +1 -1
  38. package/app/.next/server/app/503/page_client-reference-manifest.js +1 -1
  39. package/app/.next/server/app/_global-error.html +2 -2
  40. package/app/.next/server/app/_global-error.rsc +1 -1
  41. package/app/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  42. package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  43. package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  44. package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  45. package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  46. package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  47. package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
  48. package/app/.next/server/app/docs/page_client-reference-manifest.js +1 -1
  49. package/app/.next/server/app/forbidden/page_client-reference-manifest.js +1 -1
  50. package/app/.next/server/app/forgot-password/page_client-reference-manifest.js +1 -1
  51. package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
  52. package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
  53. package/app/.next/server/app/maintenance/page_client-reference-manifest.js +1 -1
  54. package/app/.next/server/app/offline/page_client-reference-manifest.js +1 -1
  55. package/app/.next/server/app/page_client-reference-manifest.js +1 -1
  56. package/app/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
  57. package/app/.next/server/app/status/page_client-reference-manifest.js +1 -1
  58. package/app/.next/server/app/terms/page_client-reference-manifest.js +1 -1
  59. package/app/.next/server/chunks/[root-of-the-server]__051203a6._.js +2 -2
  60. package/app/.next/server/chunks/[root-of-the-server]__0891af92._.js +1 -1
  61. package/app/.next/server/chunks/[root-of-the-server]__1f2b0d89._.js +1 -1
  62. package/app/.next/server/chunks/[root-of-the-server]__46e00e59._.js +1 -1
  63. package/app/.next/server/chunks/[root-of-the-server]__6e52619e._.js +1 -1
  64. package/app/.next/server/chunks/[root-of-the-server]__70a3877b._.js +5 -5
  65. package/app/.next/server/chunks/[root-of-the-server]__7ace0fcd._.js +1 -1
  66. package/app/.next/server/chunks/[root-of-the-server]__7fa4d14e._.js +1 -1
  67. package/app/.next/server/chunks/[root-of-the-server]__b013abab._.js +6 -6
  68. package/app/.next/server/chunks/_05c48915._.js +1 -1
  69. package/app/.next/server/chunks/_06515a8a._.js +1 -1
  70. package/app/.next/server/chunks/_2115d8de._.js +1 -1
  71. package/app/.next/server/chunks/_3ac953eb._.js +1 -1
  72. package/app/.next/server/chunks/_4b8fd853._.js +1 -1
  73. package/app/.next/server/chunks/_68683848._.js +1 -1
  74. package/app/.next/server/chunks/_ee9b677b._.js +1 -1
  75. package/app/.next/server/chunks/_efd5ede2._.js +5 -5
  76. package/app/.next/server/chunks/open-sse_translator_index_ts_f5fd0821._.js +1 -1
  77. package/app/.next/server/chunks/ssr/[root-of-the-server]__9ef96d20._.js +1 -1
  78. package/app/.next/server/chunks/ssr/[root-of-the-server]__a6942102._.js +1 -1
  79. package/app/.next/server/pages/500.html +2 -2
  80. package/app/.next/server/server-reference-manifest.js +1 -1
  81. package/app/.next/server/server-reference-manifest.json +1 -1
  82. package/app/.next/static/chunks/{84065c05df1a3a1a.js → 99d7f85f909fb5e1.js} +1 -1
  83. package/app/CHANGELOG.md +33 -0
  84. package/app/docs/openapi.yaml +1 -1
  85. package/app/open-sse/handlers/responseSanitizer.ts +69 -0
  86. package/app/open-sse/translator/response/openai-to-claude.ts +12 -1
  87. package/app/open-sse/utils/usageTracking.ts +44 -5
  88. package/app/package-lock.json +23 -23
  89. package/app/package.json +1 -1
  90. package/app/src/lib/db/combos.ts +5 -5
  91. package/app/src/lib/db/models.ts +9 -9
  92. package/package.json +1 -1
  93. /package/app/.next/static/{kmbT_1tKg7aSbEcFkhAUg → nOx2-MqITU8BMdt9WgycY}/_buildManifest.js +0 -0
  94. /package/app/.next/static/{kmbT_1tKg7aSbEcFkhAUg → nOx2-MqITU8BMdt9WgycY}/_clientMiddlewareManifest.json +0 -0
  95. /package/app/.next/static/{kmbT_1tKg7aSbEcFkhAUg → nOx2-MqITU8BMdt9WgycY}/_ssgManifest.js +0 -0
@@ -9,7 +9,7 @@ Respond ONLY with the JSON object, no other text.`)}else"json_object"===e.type&&
9
9
  </tool_result>`}function L(e,t,n=null){return{id:`chatcmpl-${e.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:e.model,choices:[{index:0,delta:t,finish_reason:n}]}}function Y(e,t){e.thinkingBlockStarted&&(t.push({type:"content_block_stop",index:e.thinkingBlockIndex}),e.thinkingBlockStarted=!1)}function K(e,t){e.textBlockStarted&&!e.textBlockClosed&&(e.textBlockClosed=!0,t.push({type:"content_block_stop",index:e.textBlockIndex}),e.textBlockStarted=!1)}function G(e,t){if(!e)return null;let n=e.response||e;if(!n||!n.candidates?.[0])return null;let o=[],s=n.candidates[0],r=s.content;if(t.messageId||(t.messageId=n.responseId||`msg_${Date.now()}`,t.model=n.modelVersion||"gemini",t.functionIndex=0,o.push({id:`chatcmpl-${t.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:t.model,choices:[{index:0,delta:{role:"assistant"},finish_reason:null}]})),r?.parts)for(let e of r.parts){let n=e.thoughtSignature||e.thought_signature,s=!0===e.thought;if(n){let n=void 0!==e.text&&""!==e.text,r=!!e.functionCall;if(n&&o.push({id:`chatcmpl-${t.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:t.model,choices:[{index:0,delta:s?{reasoning_content:e.text}:{content:e.text},finish_reason:null}]}),r){let n=e.functionCall.name,s=e.functionCall.args||{},r=t.functionIndex++,i={id:`${n}-${Date.now()}-${r}`,index:r,type:"function",function:{name:n,arguments:JSON.stringify(s)}};t.toolCalls.set(r,i),o.push({id:`chatcmpl-${t.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:t.model,choices:[{index:0,delta:{tool_calls:[i]},finish_reason:null}]})}continue}if(void 0!==e.text&&""!==e.text&&o.push({id:`chatcmpl-${t.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:t.model,choices:[{index:0,delta:{content:e.text},finish_reason:null}]}),e.functionCall){let n=e.functionCall.name,s=e.functionCall.args||{},r=t.functionIndex++,i={id:`${n}-${Date.now()}-${r}`,index:r,type:"function",function:{name:n,arguments:JSON.stringify(s)}};t.toolCalls.set(r,i),o.push({id:`chatcmpl-${t.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:t.model,choices:[{index:0,delta:{tool_calls:[i]},finish_reason:null}]})}let r=e.inlineData||e.inline_data;if(r?.data){let e=r.mimeType||r.mime_type||"image/png";o.push({id:`chatcmpl-${t.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:t.model,choices:[{index:0,delta:{images:[{type:"image_url",image_url:{url:`data:${e};base64,${r.data}`}}]},finish_reason:null}]})}}let i=n.usageMetadata||e.usageMetadata;if(i&&"object"==typeof i){let e="number"==typeof i.cachedContentTokenCount?i.cachedContentTokenCount:0,n="number"==typeof i.promptTokenCount?i.promptTokenCount:0,o="number"==typeof i.thoughtsTokenCount?i.thoughtsTokenCount:0,s="number"==typeof i.candidatesTokenCount?i.candidatesTokenCount:0,r="number"==typeof i.totalTokenCount?i.totalTokenCount:0;0===s&&r>0&&(s=r-n-o)<0&&(s=0),t.usage={prompt_tokens:n,completion_tokens:s+o,total_tokens:r},e>0&&(t.usage.prompt_tokens_details={cached_tokens:e}),o>0&&(t.usage.completion_tokens_details={reasoning_tokens:o})}if(s.finishReason){let e=s.finishReason.toLowerCase();"stop"===e&&t.toolCalls.size>0&&(e="tool_calls");let n={id:`chatcmpl-${t.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:t.model,choices:[{index:0,delta:{},finish_reason:e}]};t.usage&&(n.usage=t.usage),o.push(n),t.finishReason=e}return o.length>0?o:null}function W(e,t){if(!e)return null;let n=e.response||e;if(!n||!n.candidates?.[0])return null;let o=[],s=n.candidates[0],r=s.content;if(t.messageId||(t.messageId=n.responseId||`msg_${Date.now()}`,t.model=n.modelVersion||"gemini",t.contentBlockIndex=0,t.openTextBlockIdx=null,o.push({type:"message_start",message:{id:t.messageId,type:"message",role:"assistant",model:t.model,content:[],stop_reason:null,stop_sequence:null,usage:{input_tokens:0,output_tokens:0}}})),r?.parts)for(let e of r.parts){let n=e.thoughtSignature||e.thought_signature,s=!0===e.thought;if(s&&e.text){null!==t.openTextBlockIdx&&(o.push({type:"content_block_stop",index:t.openTextBlockIdx}),t.openTextBlockIdx=null);let n=t.contentBlockIndex++;o.push({type:"content_block_start",index:n,content_block:{type:"thinking",thinking:""}}),o.push({type:"content_block_delta",index:n,delta:{type:"thinking_delta",thinking:e.text}}),o.push({type:"content_block_stop",index:n});continue}if(e.functionCall){null!==t.openTextBlockIdx&&(o.push({type:"content_block_stop",index:t.openTextBlockIdx}),t.openTextBlockIdx=null);let n=e.functionCall,s=t.contentBlockIndex++,r=n.id||`toolu_${Date.now()}_${s}`;o.push({type:"content_block_start",index:s,content_block:{type:"tool_use",id:r,name:n.name,input:{}}});let i=JSON.stringify(n.args||{});o.push({type:"content_block_delta",index:s,delta:{type:"input_json_delta",partial_json:i}}),o.push({type:"content_block_stop",index:s}),t.hasToolUse||(t.hasToolUse=!0);continue}let r=void 0!==e.text&&""!==e.text&&!n,i=n&&void 0!==e.text&&""!==e.text&&!s&&!e.functionCall;if(r||i){if(null===t.openTextBlockIdx){let e=t.contentBlockIndex++;t.openTextBlockIdx=e,o.push({type:"content_block_start",index:e,content_block:{type:"text",text:""}})}o.push({type:"content_block_delta",index:t.openTextBlockIdx,delta:{type:"text_delta",text:e.text}})}}let i=n.usageMetadata||e.usageMetadata;if(i&&"object"==typeof i){let e="number"==typeof i.promptTokenCount?i.promptTokenCount:0,n="number"==typeof i.candidatesTokenCount?i.candidatesTokenCount:0,o="number"==typeof i.thoughtsTokenCount?i.thoughtsTokenCount:0,s="number"==typeof i.cachedContentTokenCount?i.cachedContentTokenCount:0;t.usage={input_tokens:e,output_tokens:n+o},s>0&&(t.usage.cache_read_input_tokens=s)}if(s.finishReason){let e;null!==t.openTextBlockIdx&&(o.push({type:"content_block_stop",index:t.openTextBlockIdx}),t.openTextBlockIdx=null);let n=s.finishReason.toLowerCase();e=t.hasToolUse||"tool_calls"===n?"tool_use":"max_tokens"===n||"length"===n?"max_tokens":"end_turn",o.push({type:"message_delta",delta:{stop_reason:e,stop_sequence:null},usage:t.usage||{input_tokens:0,output_tokens:0}}),o.push({type:"message_stop"})}return o.length>0?o:null}function Z(e,t,n){e.reasoningId||(e.reasoningId=`rs_${e.responseId}_${n}`,e.reasoningIndex=n,t("response.output_item.added",{type:"response.output_item.added",output_index:n,item:{id:e.reasoningId,type:"reasoning",summary:[]}}),t("response.reasoning_summary_part.added",{type:"response.reasoning_summary_part.added",item_id:e.reasoningId,output_index:n,summary_index:0,part:{type:"summary_text",text:""}}),e.reasoningPartAdded=!0)}function V(e,t,n){n&&(e.reasoningBuf+=n,t("response.reasoning_summary_text.delta",{type:"response.reasoning_summary_text.delta",item_id:e.reasoningId,output_index:e.reasoningIndex,summary_index:0,delta:n}))}function H(e,t){e.reasoningId&&!e.reasoningDone&&(e.reasoningDone=!0,t("response.reasoning_summary_text.done",{type:"response.reasoning_summary_text.done",item_id:e.reasoningId,output_index:e.reasoningIndex,summary_index:0,text:e.reasoningBuf}),t("response.reasoning_summary_part.done",{type:"response.reasoning_summary_part.done",item_id:e.reasoningId,output_index:e.reasoningIndex,summary_index:0,part:{type:"summary_text",text:e.reasoningBuf}}),t("response.output_item.done",{type:"response.output_item.done",output_index:e.reasoningIndex,item:{id:e.reasoningId,type:"reasoning",summary:[{type:"summary_text",text:e.reasoningBuf}]}}))}function z(e,t,n){if(e.msgItemAdded[n]&&!e.msgItemDone[n]){e.msgItemDone[n]=!0;let o=e.msgTextBuf[n]||"",s=`msg_${e.responseId}_${n}`;t("response.output_text.done",{type:"response.output_text.done",item_id:s,output_index:parseInt(n),content_index:0,text:o,logprobs:[]}),t("response.content_part.done",{type:"response.content_part.done",item_id:s,output_index:parseInt(n),content_index:0,part:{type:"output_text",annotations:[],logprobs:[],text:o}}),t("response.output_item.done",{type:"response.output_item.done",output_index:parseInt(n),item:{id:s,type:"message",content:[{type:"output_text",annotations:[],logprobs:[],text:o}],role:"assistant"}})}}function Q(e,t,n){let o=e.funcCallIds[n];if(o&&!e.funcItemDone[n]){let s=e.funcArgsBuf[n]||"{}";t("response.function_call_arguments.done",{type:"response.function_call_arguments.done",item_id:`fc_${o}`,output_index:parseInt(n),arguments:s}),t("response.output_item.done",{type:"response.output_item.done",output_index:parseInt(n),item:{id:`fc_${o}`,type:"function_call",arguments:s,call_id:o,name:e.funcNames[n]||""}}),e.funcItemDone[n]=!0,e.funcArgsDone[n]=!0}}function X(e,t){e.completedSent||(e.completedSent=!0,t("response.completed",{type:"response.completed",response:{id:e.responseId,object:"response",created_at:e.created,status:"completed",background:!1,error:null}}))}function ee(){}f(t.FORMATS.OPENAI,t.FORMATS.KIRO,function(e,t,n,o){let s=t.messages||[],r=t.tools||[],i=t.temperature,l=t.top_p,{history:a,currentMessage:u}=function(e,t,n){let o=[],s=null,r=[],i=[],l=[],a=null,u=()=>{if("user"===a){let e={userInputMessage:{content:r.join("\n\n").trim()||"continue",modelId:""}};l.length>0&&(e.userInputMessage.userInputMessageContext={toolResults:l}),t&&t.length>0&&0===o.length&&(e.userInputMessage.userInputMessageContext||(e.userInputMessage.userInputMessageContext={}),e.userInputMessage.userInputMessageContext.tools=t.map(e=>{let t=e.function?.name||e.name,n=e.function?.description||e.description||"";return n.trim()||(n=`Tool: ${t}`),{toolSpecification:{name:t,description:n,inputSchema:{json:e.function?.parameters||e.parameters||e.input_schema||{}}}}})),o.push(e),s=e,r=[],l=[]}else if("assistant"===a){let e=i.join("\n\n").trim()||"...";o.push({assistantResponseMessage:{content:e}}),i=[]}};for(let t=0;t<e.length;t++){let n=e[t],s=n.role;if(("system"===s||"tool"===s)&&(s="user"),s!==a&&null!==a&&u(),a=s,"user"===s){let e="";if("string"==typeof n.content)e=n.content;else if(Array.isArray(n.content)){e=n.content.filter(e=>"text"===e.type||e.text).map(e=>e.text||"").join("\n");let t=n.content.filter(e=>"tool_result"===e.type);t.length>0&&t.forEach(e=>{let t=Array.isArray(e.content)?e.content.map(e=>e.text||"").join("\n"):"string"==typeof e.content?e.content:"";l.push({toolUseId:e.tool_use_id,status:"success",content:[{text:t}]})})}if("tool"===n.role){let e="string"==typeof n.content?n.content:"";l.push({toolUseId:n.tool_call_id,status:"success",content:[{text:e}]})}else e&&r.push(e)}else if("assistant"===s){let e="",t=[];if(Array.isArray(n.content)?(e=n.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n").trim(),t=n.content.filter(e=>"tool_use"===e.type)):"string"==typeof n.content&&(e=n.content.trim()),n.tool_calls&&n.tool_calls.length>0&&(t=n.tool_calls),e&&i.push(e),t.length>0){i.length,u();let e=o[o.length-1];e?.assistantResponseMessage&&(e.assistantResponseMessage.toolUses=t.map(e=>e.function?{toolUseId:e.id||(0,P.v4)(),name:e.function.name,input:"string"==typeof e.function.arguments?JSON.parse(e.function.arguments):e.function.arguments||{}}:{toolUseId:e.id||(0,P.v4)(),name:e.name,input:e.input||{}})),a=null}}}null!==a&&u(),o.length>0&&o[o.length-1].userInputMessage&&(s=o.pop());let c=o[0];return c?.userInputMessage?.userInputMessageContext?.tools&&!s?.userInputMessage?.userInputMessageContext?.tools&&(s.userInputMessage.userInputMessageContext||(s.userInputMessage.userInputMessageContext={}),s.userInputMessage.userInputMessageContext.tools=c.userInputMessage.userInputMessageContext.tools),o.forEach(e=>{e.userInputMessage?.userInputMessageContext?.tools&&delete e.userInputMessage.userInputMessageContext.tools,e.userInputMessage?.userInputMessageContext&&0===Object.keys(e.userInputMessage.userInputMessageContext).length&&delete e.userInputMessage.userInputMessageContext,e.userInputMessage&&!e.userInputMessage.modelId&&(e.userInputMessage.modelId=n)}),{history:o,currentMessage:s}}(s,r,e),c=o?.providerSpecificData?.profileArn||"",p=u?.userInputMessage?.content||"",f=new Date().toISOString();p=`[Context: Current time is ${f}]
10
10
 
11
11
  ${p}`;let d={conversationState:{chatTriggerType:"MANUAL",conversationId:(0,P.v4)(),currentMessage:{userInputMessage:{content:p,modelId:e,origin:"AI_EDITOR",...u?.userInputMessage?.userInputMessageContext&&{userInputMessageContext:u.userInputMessage.userInputMessageContext}}},history:a}};return c&&(d.profileArn=c),d.inferenceConfig={},d.inferenceConfig.maxTokens=32e3,void 0!==i&&(d.inferenceConfig.temperature=i),void 0!==l&&(d.inferenceConfig.topP=l),d},null),f(t.FORMATS.OPENAI,t.FORMATS.CURSOR,function(e,t,n,o){let s=function(e){let t=[],n=new Map,o=(e,t)=>{if(!e)return;let o=t||"tool";n.set(e,{name:o});let s=q(e);s&&s!==e&&n.set(s,{name:o})};for(let t of e){if("assistant"===t.role&&t.tool_calls)for(let e of t.tool_calls)o(e.id||"",e.function?.name||"tool");if("assistant"===t.role&&Array.isArray(t.content))for(let e of t.content)e?.type==="tool_use"&&o(e.id||"",e.name||"tool")}for(let o=0;o<e.length;o++){let s=e[o];if("system"===s.role){t.push({role:"user",content:`[System Instructions]
12
- ${$(s.content)}`});continue}if("tool"===s.role){let e=$(s.content),o=s.tool_call_id||"",r=n.get(o)||{},i=s.name||r.name||"tool";t.push({role:"user",content:J(i,o,e)});continue}if("user"===s.role||"assistant"===s.role){if("user"===s.role&&Array.isArray(s.content)){let e=[];for(let t of s.content)if(t&&"object"==typeof t){if("text"===t.type){"string"==typeof t.text&&e.push(t.text||"");continue}if("tool_result"===t.type){let o=t.tool_use_id||"",s=n.get(o)||n.get(q(o)),r=s?.name||"tool",i=$(t.content);e.push(J(r,o,i))}}let o=e.filter(Boolean).join("\n");o&&t.push({role:"user",content:o});continue}let e=$(s.content);if("assistant"===s.role&&s.tool_calls&&s.tool_calls.length>0){let n={role:"assistant",content:e||""};n.tool_calls=s.tool_calls.map(e=>{let{index:t,...n}=e||{};return n}),t.push(n)}else if("assistant"===s.role&&Array.isArray(s.content)){let n=s.content.filter(e=>e?.type==="tool_use").map(e=>({id:e.id||"",type:"function",function:{name:e.name||"tool",arguments:JSON.stringify(e.input||{})}})).filter(e=>e.id);n.length>0?t.push({role:"assistant",content:e||"",tool_calls:n}):e&&t.push({role:"assistant",content:e})}else e&&t.push({role:s.role,content:e})}}return t}(t.messages||[]);return{...t,messages:s}},null),f(t.FORMATS.CLAUDE,t.FORMATS.GEMINI,function(e,t,n){let o={model:e,contents:[],generationConfig:{},safetySettings:O};if(void 0!==t.temperature&&(o.generationConfig.temperature=t.temperature),void 0!==t.top_p&&(o.generationConfig.topP=t.top_p),void 0!==t.top_k&&(o.generationConfig.topK=t.top_k),void 0!==t.max_tokens&&(o.generationConfig.maxOutputTokens=t.max_tokens),t.system){let e;(e=Array.isArray(t.system)?t.system.map(e=>e.text||"").join("\n"):String(t.system))&&(o.systemInstruction={role:"user",parts:[{text:e}]})}let s={};if(t.messages&&Array.isArray(t.messages)){for(let e of t.messages)if("assistant"===e.role&&Array.isArray(e.content))for(let t of e.content)"tool_use"===t.type&&t.id&&t.name&&(s[t.id]=t.name)}if(t.messages&&Array.isArray(t.messages))for(let e of t.messages){let t=[];if(Array.isArray(e.content))for(let n of e.content)switch(n.type){case"text":n.text&&t.push({text:n.text});break;case"thinking":n.thinking&&(t.push({thought:!0,text:n.thinking}),t.push({thoughtSignature:l,text:""}));break;case"tool_use":t.push({thoughtSignature:l,functionCall:{id:n.id,name:n.name,args:n.input||{}}});break;case"tool_result":{let e=n.content;Array.isArray(e)&&(e=e.map(e=>"text"===e.type?e.text:JSON.stringify(e)).join("\n"));let o=b(e);null===o?o={result:e}:"object"!=typeof o&&(o={result:o}),t.push({functionResponse:{id:n.tool_use_id,name:s[n.tool_use_id]||"unknown",response:{result:o}}});break}case"image":n.source?.type==="base64"&&t.push({inlineData:{mimeType:n.source.media_type,data:n.source.data}})}else"string"==typeof e.content&&e.content&&t.push({text:e.content});if(t.length>0){let n="assistant"===e.role?"model":"user";o.contents.push({role:n,parts:t})}}if(t.tools&&Array.isArray(t.tools)&&t.tools.length>0){let e=[];for(let n of t.tools)n.name&&e.push({name:n.name,description:n.description||"",parameters:M(n.input_schema||{type:"object",properties:{}})});e.length>0&&(o.tools=[{functionDeclarations:e}])}return t.thinking?.type==="enabled"&&t.thinking.budget_tokens&&(o.generationConfig.thinkingConfig={thinkingBudget:t.thinking.budget_tokens,include_thoughts:!0}),o},null),f(t.FORMATS.CLAUDE,t.FORMATS.OPENAI,null,function(e,t){if(!e)return null;let n=[];switch(e.type){case"message_start":t.messageId=e.message?.id||`msg_${Date.now()}`,t.model=e.message?.model,t.toolCallIndex=0,n.push(L(t,{role:"assistant"}));break;case"content_block_start":{let o=e.content_block;if(o?.type==="text")t.textBlockStarted=!0;else if(o?.type==="thinking")t.inThinkingBlock=!0,t.currentBlockIndex=e.index,n.push(L(t,{reasoning_content:""}));else if(o?.type==="tool_use"){let s=t.toolCallIndex++,r=t.toolNameMap?.get(o.name)||o.name,i={index:s,id:o.id,type:"function",function:{name:r,arguments:""}};t.toolCalls.set(e.index,i),n.push(L(t,{tool_calls:[i]}))}break}case"content_block_delta":{let o=e.delta;if(o?.type==="text_delta"&&o.text)n.push(L(t,{content:o.text}));else if(o?.type==="thinking_delta"&&o.thinking)n.push(L(t,{reasoning_content:o.thinking}));else if(o?.type==="input_json_delta"&&o.partial_json){let s=t.toolCalls.get(e.index);s&&(s.function.arguments+=o.partial_json,n.push(L(t,{tool_calls:[{index:s.index,id:s.id,function:{arguments:o.partial_json}}]})))}break}case"content_block_stop":t.inThinkingBlock&&e.index===t.currentBlockIndex&&(t.inThinkingBlock=!1),t.textBlockStarted=!1,t.thinkingBlockStarted=!1;break;case"message_delta":if(e.usage&&"object"==typeof e.usage){let n="number"==typeof e.usage.input_tokens?e.usage.input_tokens:0,o="number"==typeof e.usage.output_tokens?e.usage.output_tokens:0,s="number"==typeof e.usage.cache_read_input_tokens?e.usage.cache_read_input_tokens:0,r="number"==typeof e.usage.cache_creation_input_tokens?e.usage.cache_creation_input_tokens:0;t.usage={prompt_tokens:n,completion_tokens:o,input_tokens:n,output_tokens:o},s>0&&(t.usage.cache_read_input_tokens=s),r>0&&(t.usage.cache_creation_input_tokens=r)}if(e.delta?.stop_reason){t.finishReason=function(e){switch(e){case"end_turn":case"stop_sequence":default:return"stop";case"max_tokens":return"length";case"tool_use":return"tool_calls"}}(e.delta.stop_reason);let o={id:`chatcmpl-${t.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:t.model,choices:[{index:0,delta:{},finish_reason:t.finishReason}]};if(t.usage&&"object"==typeof t.usage){let e=t.usage.input_tokens||0,n=t.usage.output_tokens||0,s=t.usage.cache_read_input_tokens||0,r=t.usage.cache_creation_input_tokens||0,i=e+s+r;o.usage={prompt_tokens:i,completion_tokens:n,total_tokens:i+n},(s>0||r>0)&&(o.usage.prompt_tokens_details={},s>0&&(o.usage.prompt_tokens_details.cached_tokens=s),r>0&&(o.usage.prompt_tokens_details.cache_creation_tokens=r))}n.push(o),t.finishReasonSent=!0}break;case"message_stop":if(!t.finishReasonSent){let e=t.finishReason||(t.toolCalls?.size>0?"tool_calls":"stop"),o=t.usage&&"object"==typeof t.usage?{usage:{prompt_tokens:t.usage.input_tokens||0,completion_tokens:t.usage.output_tokens||0,total_tokens:(t.usage.input_tokens||0)+(t.usage.output_tokens||0)}}:{};n.push({id:`chatcmpl-${t.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:t.model,choices:[{index:0,delta:{},finish_reason:e}],...o}),t.finishReasonSent=!0}}return n.length>0?n:null}),f(t.FORMATS.OPENAI,t.FORMATS.CLAUDE,null,function(e,t){if(!e||!e.choices?.[0])return null;let n=[],o=e.choices[0],s=o.delta;if(e.usage&&"object"==typeof e.usage){let n="number"==typeof e.usage.prompt_tokens?e.usage.prompt_tokens:0,o="number"==typeof e.usage.completion_tokens?e.usage.completion_tokens:0,s=e.usage.prompt_tokens_details?.cached_tokens,r=e.usage.prompt_tokens_details?.cache_creation_tokens,i="number"==typeof s?s:0,l="number"==typeof r?r:0;t.usage={input_tokens:n-i-l,output_tokens:o},i>0&&(t.usage.cache_read_input_tokens=i),l>0&&(t.usage.cache_creation_input_tokens=l)}t.messageStartSent||(t.messageStartSent=!0,t.messageId=e.id?.replace("chatcmpl-","")||`msg_${Date.now()}`,(!t.messageId||"chat"===t.messageId||t.messageId.length<8)&&(t.messageId=e.extend_fields?.requestId||e.extend_fields?.traceId||`msg_${Date.now()}`),t.model=e.model||"unknown",t.nextBlockIndex=0,n.push({type:"message_start",message:{id:t.messageId,type:"message",role:"assistant",model:t.model,content:[],stop_reason:null,stop_sequence:null,usage:{input_tokens:0,output_tokens:0}}}));let r=s?.reasoning_content||s?.reasoning;if(r&&(K(t,n),t.thinkingBlockStarted||(t.thinkingBlockIndex=t.nextBlockIndex++,t.thinkingBlockStarted=!0,n.push({type:"content_block_start",index:t.thinkingBlockIndex,content_block:{type:"thinking",thinking:""}})),n.push({type:"content_block_delta",index:t.thinkingBlockIndex,delta:{type:"thinking_delta",thinking:r}})),s?.content&&(Y(t,n),t.textBlockStarted||(t.textBlockIndex=t.nextBlockIndex++,t.textBlockStarted=!0,t.textBlockClosed=!1,n.push({type:"content_block_start",index:t.textBlockIndex,content_block:{type:"text",text:""}})),n.push({type:"content_block_delta",index:t.textBlockIndex,delta:{type:"text_delta",text:s.content}})),s?.tool_calls)for(let e of s.tool_calls){let o=e.index??0;if(e.id){Y(t,n),K(t,n);let s=t.nextBlockIndex++;t.toolCalls.set(o,{id:e.id,name:e.function?.name||"",blockIndex:s});let r=e.function?.name||"";r.startsWith(_)&&(r=r.slice(_.length)),n.push({type:"content_block_start",index:s,content_block:{type:"tool_use",id:e.id,name:r,input:{}}})}if(e.function?.arguments){let s=t.toolCalls.get(o);s&&n.push({type:"content_block_delta",index:s.blockIndex,delta:{type:"input_json_delta",partial_json:e.function.arguments}})}}if(o.finish_reason){for(let[,e]of(Y(t,n),K(t,n),t.toolCalls))n.push({type:"content_block_stop",index:e.blockIndex});t.finishReason=o.finish_reason;let e=t.usage||{input_tokens:0,output_tokens:0};n.push({type:"message_delta",delta:{stop_reason:function(e){switch(e){case"stop":default:return"end_turn";case"length":return"max_tokens";case"tool_calls":return"tool_use"}}(o.finish_reason)},usage:e}),n.push({type:"message_stop"})}return n.length>0?n:null}),f(t.FORMATS.GEMINI,t.FORMATS.OPENAI,null,G),f(t.FORMATS.GEMINI_CLI,t.FORMATS.OPENAI,null,G),f(t.FORMATS.ANTIGRAVITY,t.FORMATS.OPENAI,null,G),f(t.FORMATS.GEMINI,t.FORMATS.CLAUDE,null,W),f(t.FORMATS.GEMINI_CLI,t.FORMATS.CLAUDE,null,W),f(t.FORMATS.ANTIGRAVITY,t.FORMATS.CLAUDE,null,W),f(t.FORMATS.OPENAI,t.FORMATS.ANTIGRAVITY,null,function(e,t){if(!e)return null;let n=e.choices?.[0];if(!n)return e.usage&&(t._usage=e.usage),null;let o=n.delta||{},s=n.finish_reason;t._toolCallAccum||(t._toolCallAccum={}),t._responseId||(t._responseId=e.id||`resp_${Date.now()}`),t._modelVersion||(t._modelVersion=e.model||"");let r=[];if(o.reasoning_content&&r.push({thought:!0,text:o.reasoning_content}),o.content&&r.push({text:o.content}),o.tool_calls){for(let e of o.tool_calls){let n=e.index??0;t._toolCallAccum[n]||(t._toolCallAccum[n]={id:"",name:"",arguments:""});let o=t._toolCallAccum[n];e.id&&(o.id=e.id),e.function?.name&&(o.name+=e.function.name),e.function?.arguments&&(o.arguments+=e.function.arguments)}if(0===r.length&&!s)return null}if(s)for(let e of Object.keys(t._toolCallAccum)){let n=t._toolCallAccum[e],o={};try{o=JSON.parse(n.arguments)}catch{}r.push({functionCall:{name:n.name,args:o}})}if(0===r.length&&!s)return null;0===r.length&&s&&r.push({text:""});let i={content:{role:"model",parts:r}};s&&(i.finishReason=({stop:"STOP",length:"MAX_TOKENS",tool_calls:"STOP",content_filter:"SAFETY"})[s]||"STOP");let l={candidates:[i],modelVersion:t._modelVersion,responseId:t._responseId},a=e.usage||t._usage;return a&&(l.usageMetadata={promptTokenCount:a.prompt_tokens||0,candidatesTokenCount:a.completion_tokens||0,totalTokenCount:a.total_tokens||0},a.completion_tokens_details?.reasoning_tokens&&(l.usageMetadata.thoughtsTokenCount=a.completion_tokens_details.reasoning_tokens),a.prompt_tokens_details?.cached_tokens&&(l.usageMetadata.cachedContentTokenCount=a.prompt_tokens_details.cached_tokens)),{response:l}}),f(t.FORMATS.OPENAI,t.FORMATS.OPENAI_RESPONSES,null,function(e,t){if(!e){var n=t;if(n.completedSent)return[];let e=[],o=(t,o)=>{o.sequence_number=++n.seq,e.push({event:t,data:o})};for(let e in n.msgItemAdded)z(n,o,e);for(let e in H(n,o),n.funcCallIds)Q(n,o,e);return X(n,o),e}if(!e.choices?.length)return[];let o=[],s=(e,n)=>{n.sequence_number=++t.seq,o.push({event:e,data:n})},r=e.choices[0],i=r.index||0,l=r.delta||{};if(t.started||(t.started=!0,t.responseId=e.id?`resp_${e.id}`:t.responseId,s("response.created",{type:"response.created",response:{id:t.responseId,object:"response",created_at:t.created,status:"in_progress",background:!1,error:null,output:[]}}),s("response.in_progress",{type:"response.in_progress",response:{id:t.responseId,object:"response",created_at:t.created,status:"in_progress"}})),l.reasoning_content&&(Z(t,s,i),V(t,s,l.reasoning_content)),l.content){let e=l.content;if(e.includes("<think>")&&(t.inThinking=!0,e=e.replace("<think>",""),Z(t,s,i)),e.includes("</think>")){let n=e.split("</think>"),o=n[0],r=n.slice(1).join("</think>");o&&V(t,s,o),H(t,s),t.inThinking=!1,e=r}if(t.inThinking&&e)return V(t,s,e),o;e&&function(e,t,n,o){if(!e.msgItemAdded[n]){e.msgItemAdded[n]=!0;let o=`msg_${e.responseId}_${n}`;t("response.output_item.added",{type:"response.output_item.added",output_index:n,item:{id:o,type:"message",content:[],role:"assistant"}})}e.msgContentAdded[n]||(e.msgContentAdded[n]=!0,t("response.content_part.added",{type:"response.content_part.added",item_id:`msg_${e.responseId}_${n}`,output_index:n,content_index:0,part:{type:"output_text",annotations:[],logprobs:[],text:""}})),t("response.output_text.delta",{type:"response.output_text.delta",item_id:`msg_${e.responseId}_${n}`,output_index:n,content_index:0,delta:o,logprobs:[]}),e.msgTextBuf[n]||(e.msgTextBuf[n]=""),e.msgTextBuf[n]+=o}(t,s,i,e)}if(l.tool_calls)for(let e of(z(t,s,i),l.tool_calls))!function(e,t,n){let o=n.index??0,s=n.id,r=n.function?.name;if(e.funcCallIds[o]&&s&&e.funcCallIds[o]!==s&&(Q(e,t,o),delete e.funcCallIds[o],delete e.funcNames[o],delete e.funcArgsBuf[o],delete e.funcArgsDone[o],delete e.funcItemDone[o]),r&&(e.funcNames[o]=r),!e.funcCallIds[o]&&s&&(e.funcCallIds[o]=s,t("response.output_item.added",{type:"response.output_item.added",output_index:o,item:{id:`fc_${s}`,type:"function_call",arguments:"",call_id:s,name:e.funcNames[o]||""}})),e.funcArgsBuf[o]||(e.funcArgsBuf[o]=""),n.function?.arguments){let r=e.funcCallIds[o]||s;r&&t("response.function_call_arguments.delta",{type:"response.function_call_arguments.delta",item_id:`fc_${r}`,output_index:o,delta:n.function.arguments}),e.funcArgsBuf[o]+=n.function.arguments}}(t,s,e);if(r.finish_reason){for(let e in t.msgItemAdded)z(t,s,e);for(let e in H(t,s),t.funcCallIds)Q(t,s,e);X(t,s)}return o}),f(t.FORMATS.OPENAI_RESPONSES,t.FORMATS.OPENAI,null,function(e,t){if(!e){if(!t.finishReasonSent&&t.started){t.finishReasonSent=!0;let e=(t.toolCallIndex||0)>0;return{id:t.chatId||`chatcmpl-${Date.now()}`,object:"chat.completion.chunk",created:t.created||Math.floor(Date.now()/1e3),model:t.model||"gpt-4",choices:[{index:0,delta:{},finish_reason:e?"tool_calls":"stop"}]}}return null}let n=e.type||e.event,o=e.data||e;if(t.started||(t.started=!0,t.chatId=`chatcmpl-${Date.now()}`,t.created=Math.floor(Date.now()/1e3),t.toolCallIndex=0,t.currentToolCallId=null),"response.output_text.delta"===n){let e=o.delta||"";return e?{id:t.chatId,object:"chat.completion.chunk",created:t.created,model:t.model||"gpt-4",choices:[{index:0,delta:{content:e},finish_reason:null}]}:null}if("response.output_text.done"===n)return null;if("response.output_item.added"===n&&o.item?.type==="function_call"){let e=o.item;return t.currentToolCallId=e.call_id||`call_${Date.now()}`,{id:t.chatId,object:"chat.completion.chunk",created:t.created,model:t.model||"gpt-4",choices:[{index:0,delta:{tool_calls:[{index:t.toolCallIndex,id:t.currentToolCallId,type:"function",function:{name:e.name||"",arguments:""}}]},finish_reason:null}]}}if("response.function_call_arguments.delta"===n){let e=o.delta||"";return e?{id:t.chatId,object:"chat.completion.chunk",created:t.created,model:t.model||"gpt-4",choices:[{index:0,delta:{tool_calls:[{index:t.toolCallIndex,id:t.currentToolCallId,type:"function",function:{arguments:e}}]},finish_reason:null}]}:null}if("response.output_item.done"===n&&o.item?.type==="function_call")return t.toolCallIndex++,null;if("response.completed"===n){let e=o.response?.usage;if(e&&"object"==typeof e){let n=e.input_tokens||e.prompt_tokens||0,o=e.output_tokens||e.completion_tokens||0,s=e.cache_read_input_tokens||0,r=e.cache_creation_input_tokens||0,i=n+s+r;t.usage={prompt_tokens:i,completion_tokens:o,total_tokens:i+o},(s>0||r>0)&&(t.usage.prompt_tokens_details={},s>0&&(t.usage.prompt_tokens_details.cached_tokens=s),r>0&&(t.usage.prompt_tokens_details.cache_creation_tokens=r))}if(!t.finishReasonSent){t.finishReasonSent=!0;let e=(t.toolCallIndex||0)>0?"tool_calls":"stop";t.finishReason=e;let n={id:t.chatId,object:"chat.completion.chunk",created:t.created,model:t.model||"gpt-4",choices:[{index:0,delta:{},finish_reason:e}]};return t.usage&&"object"==typeof t.usage&&(n.usage=t.usage),n}}return null}),f(t.FORMATS.KIRO,t.FORMATS.OPENAI,null,function(e,t){if(!e)return null;if("chat.completion.chunk"===e.object&&e.choices)return e;let n=e;if("string"==typeof e){let t=e.split("\n"),o="",s="";for(let e of t)e.startsWith("event:")?o=e.slice(6).trim():e.startsWith(":event-type:")?o=e.slice(12).trim():e.startsWith("data:")?s=e.slice(5).trim():e.startsWith(":content-type:")||e.trim()&&!e.startsWith(":")&&(s=e.trim());if(!s)return null;try{(n=JSON.parse(s))._eventType=o}catch{n={text:s,_eventType:o}}}t.responseId||(t.responseId=`chatcmpl-${Date.now()}`,t.created=Math.floor(Date.now()/1e3),t.chunkIndex=0);let o=n._eventType||n.event||"";if("assistantResponseEvent"===o||n.assistantResponseEvent){let e=n.assistantResponseEvent?.content||n.content||"";if(!e)return null;let o={id:t.responseId,object:"chat.completion.chunk",created:t.created,model:t.model||"kiro",choices:[{index:0,delta:{...0===t.chunkIndex?{role:"assistant"}:{},content:e},finish_reason:null}]};return t.chunkIndex++,o}if("reasoningContentEvent"===o||n.reasoningContentEvent){let e=n.reasoningContentEvent?.content||n.content||"";if(!e)return null;let o={id:t.responseId,object:"chat.completion.chunk",created:t.created,model:t.model||"kiro",choices:[{index:0,delta:{...0===t.chunkIndex?{role:"assistant"}:{},content:`<thinking>${e}</thinking>`},finish_reason:null}]};return t.chunkIndex++,o}if("toolUseEvent"===o||n.toolUseEvent){let e=n.toolUseEvent||n,o=e.toolUseId||`call_${Date.now()}`,s=e.name||"",r=e.input||{},i={id:t.responseId,object:"chat.completion.chunk",created:t.created,model:t.model||"kiro",choices:[{index:0,delta:{...0===t.chunkIndex?{role:"assistant"}:{},tool_calls:[{index:0,id:o,type:"function",function:{name:s,arguments:JSON.stringify(r)}}]},finish_reason:null}]};return t.chunkIndex++,i}if("messageStopEvent"===o||"done"===o||n.messageStopEvent){t.finishReason="stop";let e={id:t.responseId,object:"chat.completion.chunk",created:t.created,model:t.model||"kiro",choices:[{index:0,delta:{},finish_reason:"stop"}]};return t.usage&&"object"==typeof t.usage&&(e.usage=t.usage),e}if("usageEvent"===o||n.usageEvent){let e=n.usageEvent||n;e&&"object"==typeof e&&(t.usage={prompt_tokens:e.inputTokens||0,completion_tokens:e.outputTokens||0,total_tokens:(e.inputTokens||0)+(e.outputTokens||0)})}return null}),f(t.FORMATS.CURSOR,t.FORMATS.OPENAI,null,function(e,t){return e?("chat.completion.chunk"===e.object&&e.choices||"chat.completion"===e.object&&e.choices,e):null});var et=e.i(85713),en=e.i(384094);let eo=new Set([]),es=["glm-","ernie-"];function er(e){return"string"==typeof e?e:Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e&&"type"in e&&"text"===e.type).map(e=>"string"==typeof e.text?e.text:"").join("\n"):""}function ei(e,t,n,o,s){if(!Array.isArray(e))return e;let r=Array.isArray(e)&&("openai"!==o||!1===s)?e.map(e=>e&&"object"==typeof e&&"developer"===("string"==typeof e.role?e.role:"").toLowerCase()?{...e,role:"system"}:e):e;return function(e,t,n){if(!Array.isArray(e)||0===e.length||function(e,t){if(eo.has(e))return!1;let n=(t||"").toLowerCase();for(let e of es)if(n.startsWith(e))return!1;return!0}(t,n))return e;let o=e.filter(e=>"system"===e.role||"developer"===e.role);if(0===o.length)return e;let s=o.map(e=>er(e.content)).filter(Boolean).join("\n\n");if(!s)return e.filter(e=>"system"!==e.role&&"developer"!==e.role);let r=e.filter(e=>"system"!==e.role&&"developer"!==e.role),i=r.findIndex(e=>"user"===e.role);if(i>=0){let e=r[i],t=er(e.content);r[i]={...e,content:`[System Instructions]
12
+ ${$(s.content)}`});continue}if("tool"===s.role){let e=$(s.content),o=s.tool_call_id||"",r=n.get(o)||{},i=s.name||r.name||"tool";t.push({role:"user",content:J(i,o,e)});continue}if("user"===s.role||"assistant"===s.role){if("user"===s.role&&Array.isArray(s.content)){let e=[];for(let t of s.content)if(t&&"object"==typeof t){if("text"===t.type){"string"==typeof t.text&&e.push(t.text||"");continue}if("tool_result"===t.type){let o=t.tool_use_id||"",s=n.get(o)||n.get(q(o)),r=s?.name||"tool",i=$(t.content);e.push(J(r,o,i))}}let o=e.filter(Boolean).join("\n");o&&t.push({role:"user",content:o});continue}let e=$(s.content);if("assistant"===s.role&&s.tool_calls&&s.tool_calls.length>0){let n={role:"assistant",content:e||""};n.tool_calls=s.tool_calls.map(e=>{let{index:t,...n}=e||{};return n}),t.push(n)}else if("assistant"===s.role&&Array.isArray(s.content)){let n=s.content.filter(e=>e?.type==="tool_use").map(e=>({id:e.id||"",type:"function",function:{name:e.name||"tool",arguments:JSON.stringify(e.input||{})}})).filter(e=>e.id);n.length>0?t.push({role:"assistant",content:e||"",tool_calls:n}):e&&t.push({role:"assistant",content:e})}else e&&t.push({role:s.role,content:e})}}return t}(t.messages||[]);return{...t,messages:s}},null),f(t.FORMATS.CLAUDE,t.FORMATS.GEMINI,function(e,t,n){let o={model:e,contents:[],generationConfig:{},safetySettings:O};if(void 0!==t.temperature&&(o.generationConfig.temperature=t.temperature),void 0!==t.top_p&&(o.generationConfig.topP=t.top_p),void 0!==t.top_k&&(o.generationConfig.topK=t.top_k),void 0!==t.max_tokens&&(o.generationConfig.maxOutputTokens=t.max_tokens),t.system){let e;(e=Array.isArray(t.system)?t.system.map(e=>e.text||"").join("\n"):String(t.system))&&(o.systemInstruction={role:"user",parts:[{text:e}]})}let s={};if(t.messages&&Array.isArray(t.messages)){for(let e of t.messages)if("assistant"===e.role&&Array.isArray(e.content))for(let t of e.content)"tool_use"===t.type&&t.id&&t.name&&(s[t.id]=t.name)}if(t.messages&&Array.isArray(t.messages))for(let e of t.messages){let t=[];if(Array.isArray(e.content))for(let n of e.content)switch(n.type){case"text":n.text&&t.push({text:n.text});break;case"thinking":n.thinking&&(t.push({thought:!0,text:n.thinking}),t.push({thoughtSignature:l,text:""}));break;case"tool_use":t.push({thoughtSignature:l,functionCall:{id:n.id,name:n.name,args:n.input||{}}});break;case"tool_result":{let e=n.content;Array.isArray(e)&&(e=e.map(e=>"text"===e.type?e.text:JSON.stringify(e)).join("\n"));let o=b(e);null===o?o={result:e}:"object"!=typeof o&&(o={result:o}),t.push({functionResponse:{id:n.tool_use_id,name:s[n.tool_use_id]||"unknown",response:{result:o}}});break}case"image":n.source?.type==="base64"&&t.push({inlineData:{mimeType:n.source.media_type,data:n.source.data}})}else"string"==typeof e.content&&e.content&&t.push({text:e.content});if(t.length>0){let n="assistant"===e.role?"model":"user";o.contents.push({role:n,parts:t})}}if(t.tools&&Array.isArray(t.tools)&&t.tools.length>0){let e=[];for(let n of t.tools)n.name&&e.push({name:n.name,description:n.description||"",parameters:M(n.input_schema||{type:"object",properties:{}})});e.length>0&&(o.tools=[{functionDeclarations:e}])}return t.thinking?.type==="enabled"&&t.thinking.budget_tokens&&(o.generationConfig.thinkingConfig={thinkingBudget:t.thinking.budget_tokens,include_thoughts:!0}),o},null),f(t.FORMATS.CLAUDE,t.FORMATS.OPENAI,null,function(e,t){if(!e)return null;let n=[];switch(e.type){case"message_start":t.messageId=e.message?.id||`msg_${Date.now()}`,t.model=e.message?.model,t.toolCallIndex=0,n.push(L(t,{role:"assistant"}));break;case"content_block_start":{let o=e.content_block;if(o?.type==="text")t.textBlockStarted=!0;else if(o?.type==="thinking")t.inThinkingBlock=!0,t.currentBlockIndex=e.index,n.push(L(t,{reasoning_content:""}));else if(o?.type==="tool_use"){let s=t.toolCallIndex++,r=t.toolNameMap?.get(o.name)||o.name,i={index:s,id:o.id,type:"function",function:{name:r,arguments:""}};t.toolCalls.set(e.index,i),n.push(L(t,{tool_calls:[i]}))}break}case"content_block_delta":{let o=e.delta;if(o?.type==="text_delta"&&o.text)n.push(L(t,{content:o.text}));else if(o?.type==="thinking_delta"&&o.thinking)n.push(L(t,{reasoning_content:o.thinking}));else if(o?.type==="input_json_delta"&&o.partial_json){let s=t.toolCalls.get(e.index);s&&(s.function.arguments+=o.partial_json,n.push(L(t,{tool_calls:[{index:s.index,id:s.id,function:{arguments:o.partial_json}}]})))}break}case"content_block_stop":t.inThinkingBlock&&e.index===t.currentBlockIndex&&(t.inThinkingBlock=!1),t.textBlockStarted=!1,t.thinkingBlockStarted=!1;break;case"message_delta":if(e.usage&&"object"==typeof e.usage){let n="number"==typeof e.usage.input_tokens?e.usage.input_tokens:0,o="number"==typeof e.usage.output_tokens?e.usage.output_tokens:0,s="number"==typeof e.usage.cache_read_input_tokens?e.usage.cache_read_input_tokens:0,r="number"==typeof e.usage.cache_creation_input_tokens?e.usage.cache_creation_input_tokens:0;t.usage={prompt_tokens:n,completion_tokens:o,input_tokens:n,output_tokens:o},s>0&&(t.usage.cache_read_input_tokens=s),r>0&&(t.usage.cache_creation_input_tokens=r)}if(e.delta?.stop_reason){t.finishReason=function(e){switch(e){case"end_turn":case"stop_sequence":default:return"stop";case"max_tokens":return"length";case"tool_use":return"tool_calls"}}(e.delta.stop_reason);let o={id:`chatcmpl-${t.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:t.model,choices:[{index:0,delta:{},finish_reason:t.finishReason}]};if(t.usage&&"object"==typeof t.usage){let e=t.usage.input_tokens||0,n=t.usage.output_tokens||0,s=t.usage.cache_read_input_tokens||0,r=t.usage.cache_creation_input_tokens||0,i=e+s+r;o.usage={prompt_tokens:i,completion_tokens:n,total_tokens:i+n},(s>0||r>0)&&(o.usage.prompt_tokens_details={},s>0&&(o.usage.prompt_tokens_details.cached_tokens=s),r>0&&(o.usage.prompt_tokens_details.cache_creation_tokens=r))}n.push(o),t.finishReasonSent=!0}break;case"message_stop":if(!t.finishReasonSent){let e=t.finishReason||(t.toolCalls?.size>0?"tool_calls":"stop"),o=t.usage&&"object"==typeof t.usage?{usage:{prompt_tokens:t.usage.input_tokens||0,completion_tokens:t.usage.output_tokens||0,total_tokens:(t.usage.input_tokens||0)+(t.usage.output_tokens||0)}}:{};n.push({id:`chatcmpl-${t.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:t.model,choices:[{index:0,delta:{},finish_reason:e}],...o}),t.finishReasonSent=!0}}return n.length>0?n:null}),f(t.FORMATS.OPENAI,t.FORMATS.CLAUDE,null,function(e,t){if(!e||!e.choices?.[0])return null;let n=[],o=e.choices[0],s=o.delta;if(e.usage&&"object"==typeof e.usage){let n="number"==typeof e.usage.prompt_tokens?e.usage.prompt_tokens:0,o="number"==typeof e.usage.completion_tokens?e.usage.completion_tokens:0,s=e.usage.prompt_tokens_details?.cached_tokens,r=e.usage.prompt_tokens_details?.cache_creation_tokens,i="number"==typeof s?s:0,l="number"==typeof r?r:0;t.usage={input_tokens:n-i-l,output_tokens:o},i>0&&(t.usage.cache_read_input_tokens=i),l>0&&(t.usage.cache_creation_input_tokens=l)}t.messageStartSent||(t.messageStartSent=!0,t.messageId=e.id?.replace("chatcmpl-","")||`msg_${Date.now()}`,(!t.messageId||"chat"===t.messageId||t.messageId.length<8)&&(t.messageId=e.extend_fields?.requestId||e.extend_fields?.traceId||`msg_${Date.now()}`),t.model=e.model||"unknown",t.nextBlockIndex=0,n.push({type:"message_start",message:{id:t.messageId,type:"message",role:"assistant",model:t.model,content:[],stop_reason:null,stop_sequence:null,usage:{input_tokens:0,output_tokens:0}}}));let r=s?.reasoning_content||s?.reasoning;if(!r&&Array.isArray(s?.reasoning_details)){let e=[];for(let t of s.reasoning_details)if(t&&"object"==typeof t){let n=t.text||t.content;"string"==typeof n&&n&&e.push(n)}e.length>0&&(r=e.join(""))}if(r&&(K(t,n),t.thinkingBlockStarted||(t.thinkingBlockIndex=t.nextBlockIndex++,t.thinkingBlockStarted=!0,n.push({type:"content_block_start",index:t.thinkingBlockIndex,content_block:{type:"thinking",thinking:""}})),n.push({type:"content_block_delta",index:t.thinkingBlockIndex,delta:{type:"thinking_delta",thinking:r}})),s?.content&&(Y(t,n),t.textBlockStarted||(t.textBlockIndex=t.nextBlockIndex++,t.textBlockStarted=!0,t.textBlockClosed=!1,n.push({type:"content_block_start",index:t.textBlockIndex,content_block:{type:"text",text:""}})),n.push({type:"content_block_delta",index:t.textBlockIndex,delta:{type:"text_delta",text:s.content}})),s?.tool_calls)for(let e of s.tool_calls){let o=e.index??0;if(e.id){Y(t,n),K(t,n);let s=t.nextBlockIndex++;t.toolCalls.set(o,{id:e.id,name:e.function?.name||"",blockIndex:s});let r=e.function?.name||"";r.startsWith(_)&&(r=r.slice(_.length)),n.push({type:"content_block_start",index:s,content_block:{type:"tool_use",id:e.id,name:r,input:{}}})}if(e.function?.arguments){let s=t.toolCalls.get(o);s&&n.push({type:"content_block_delta",index:s.blockIndex,delta:{type:"input_json_delta",partial_json:e.function.arguments}})}}if(o.finish_reason){for(let[,e]of(Y(t,n),K(t,n),t.toolCalls))n.push({type:"content_block_stop",index:e.blockIndex});t.finishReason=o.finish_reason;let e=t.usage||{input_tokens:0,output_tokens:0};n.push({type:"message_delta",delta:{stop_reason:function(e){switch(e){case"stop":default:return"end_turn";case"length":return"max_tokens";case"tool_calls":return"tool_use"}}(o.finish_reason)},usage:e}),n.push({type:"message_stop"})}return n.length>0?n:null}),f(t.FORMATS.GEMINI,t.FORMATS.OPENAI,null,G),f(t.FORMATS.GEMINI_CLI,t.FORMATS.OPENAI,null,G),f(t.FORMATS.ANTIGRAVITY,t.FORMATS.OPENAI,null,G),f(t.FORMATS.GEMINI,t.FORMATS.CLAUDE,null,W),f(t.FORMATS.GEMINI_CLI,t.FORMATS.CLAUDE,null,W),f(t.FORMATS.ANTIGRAVITY,t.FORMATS.CLAUDE,null,W),f(t.FORMATS.OPENAI,t.FORMATS.ANTIGRAVITY,null,function(e,t){if(!e)return null;let n=e.choices?.[0];if(!n)return e.usage&&(t._usage=e.usage),null;let o=n.delta||{},s=n.finish_reason;t._toolCallAccum||(t._toolCallAccum={}),t._responseId||(t._responseId=e.id||`resp_${Date.now()}`),t._modelVersion||(t._modelVersion=e.model||"");let r=[];if(o.reasoning_content&&r.push({thought:!0,text:o.reasoning_content}),o.content&&r.push({text:o.content}),o.tool_calls){for(let e of o.tool_calls){let n=e.index??0;t._toolCallAccum[n]||(t._toolCallAccum[n]={id:"",name:"",arguments:""});let o=t._toolCallAccum[n];e.id&&(o.id=e.id),e.function?.name&&(o.name+=e.function.name),e.function?.arguments&&(o.arguments+=e.function.arguments)}if(0===r.length&&!s)return null}if(s)for(let e of Object.keys(t._toolCallAccum)){let n=t._toolCallAccum[e],o={};try{o=JSON.parse(n.arguments)}catch{}r.push({functionCall:{name:n.name,args:o}})}if(0===r.length&&!s)return null;0===r.length&&s&&r.push({text:""});let i={content:{role:"model",parts:r}};s&&(i.finishReason=({stop:"STOP",length:"MAX_TOKENS",tool_calls:"STOP",content_filter:"SAFETY"})[s]||"STOP");let l={candidates:[i],modelVersion:t._modelVersion,responseId:t._responseId},a=e.usage||t._usage;return a&&(l.usageMetadata={promptTokenCount:a.prompt_tokens||0,candidatesTokenCount:a.completion_tokens||0,totalTokenCount:a.total_tokens||0},a.completion_tokens_details?.reasoning_tokens&&(l.usageMetadata.thoughtsTokenCount=a.completion_tokens_details.reasoning_tokens),a.prompt_tokens_details?.cached_tokens&&(l.usageMetadata.cachedContentTokenCount=a.prompt_tokens_details.cached_tokens)),{response:l}}),f(t.FORMATS.OPENAI,t.FORMATS.OPENAI_RESPONSES,null,function(e,t){if(!e){var n=t;if(n.completedSent)return[];let e=[],o=(t,o)=>{o.sequence_number=++n.seq,e.push({event:t,data:o})};for(let e in n.msgItemAdded)z(n,o,e);for(let e in H(n,o),n.funcCallIds)Q(n,o,e);return X(n,o),e}if(!e.choices?.length)return[];let o=[],s=(e,n)=>{n.sequence_number=++t.seq,o.push({event:e,data:n})},r=e.choices[0],i=r.index||0,l=r.delta||{};if(t.started||(t.started=!0,t.responseId=e.id?`resp_${e.id}`:t.responseId,s("response.created",{type:"response.created",response:{id:t.responseId,object:"response",created_at:t.created,status:"in_progress",background:!1,error:null,output:[]}}),s("response.in_progress",{type:"response.in_progress",response:{id:t.responseId,object:"response",created_at:t.created,status:"in_progress"}})),l.reasoning_content&&(Z(t,s,i),V(t,s,l.reasoning_content)),l.content){let e=l.content;if(e.includes("<think>")&&(t.inThinking=!0,e=e.replace("<think>",""),Z(t,s,i)),e.includes("</think>")){let n=e.split("</think>"),o=n[0],r=n.slice(1).join("</think>");o&&V(t,s,o),H(t,s),t.inThinking=!1,e=r}if(t.inThinking&&e)return V(t,s,e),o;e&&function(e,t,n,o){if(!e.msgItemAdded[n]){e.msgItemAdded[n]=!0;let o=`msg_${e.responseId}_${n}`;t("response.output_item.added",{type:"response.output_item.added",output_index:n,item:{id:o,type:"message",content:[],role:"assistant"}})}e.msgContentAdded[n]||(e.msgContentAdded[n]=!0,t("response.content_part.added",{type:"response.content_part.added",item_id:`msg_${e.responseId}_${n}`,output_index:n,content_index:0,part:{type:"output_text",annotations:[],logprobs:[],text:""}})),t("response.output_text.delta",{type:"response.output_text.delta",item_id:`msg_${e.responseId}_${n}`,output_index:n,content_index:0,delta:o,logprobs:[]}),e.msgTextBuf[n]||(e.msgTextBuf[n]=""),e.msgTextBuf[n]+=o}(t,s,i,e)}if(l.tool_calls)for(let e of(z(t,s,i),l.tool_calls))!function(e,t,n){let o=n.index??0,s=n.id,r=n.function?.name;if(e.funcCallIds[o]&&s&&e.funcCallIds[o]!==s&&(Q(e,t,o),delete e.funcCallIds[o],delete e.funcNames[o],delete e.funcArgsBuf[o],delete e.funcArgsDone[o],delete e.funcItemDone[o]),r&&(e.funcNames[o]=r),!e.funcCallIds[o]&&s&&(e.funcCallIds[o]=s,t("response.output_item.added",{type:"response.output_item.added",output_index:o,item:{id:`fc_${s}`,type:"function_call",arguments:"",call_id:s,name:e.funcNames[o]||""}})),e.funcArgsBuf[o]||(e.funcArgsBuf[o]=""),n.function?.arguments){let r=e.funcCallIds[o]||s;r&&t("response.function_call_arguments.delta",{type:"response.function_call_arguments.delta",item_id:`fc_${r}`,output_index:o,delta:n.function.arguments}),e.funcArgsBuf[o]+=n.function.arguments}}(t,s,e);if(r.finish_reason){for(let e in t.msgItemAdded)z(t,s,e);for(let e in H(t,s),t.funcCallIds)Q(t,s,e);X(t,s)}return o}),f(t.FORMATS.OPENAI_RESPONSES,t.FORMATS.OPENAI,null,function(e,t){if(!e){if(!t.finishReasonSent&&t.started){t.finishReasonSent=!0;let e=(t.toolCallIndex||0)>0;return{id:t.chatId||`chatcmpl-${Date.now()}`,object:"chat.completion.chunk",created:t.created||Math.floor(Date.now()/1e3),model:t.model||"gpt-4",choices:[{index:0,delta:{},finish_reason:e?"tool_calls":"stop"}]}}return null}let n=e.type||e.event,o=e.data||e;if(t.started||(t.started=!0,t.chatId=`chatcmpl-${Date.now()}`,t.created=Math.floor(Date.now()/1e3),t.toolCallIndex=0,t.currentToolCallId=null),"response.output_text.delta"===n){let e=o.delta||"";return e?{id:t.chatId,object:"chat.completion.chunk",created:t.created,model:t.model||"gpt-4",choices:[{index:0,delta:{content:e},finish_reason:null}]}:null}if("response.output_text.done"===n)return null;if("response.output_item.added"===n&&o.item?.type==="function_call"){let e=o.item;return t.currentToolCallId=e.call_id||`call_${Date.now()}`,{id:t.chatId,object:"chat.completion.chunk",created:t.created,model:t.model||"gpt-4",choices:[{index:0,delta:{tool_calls:[{index:t.toolCallIndex,id:t.currentToolCallId,type:"function",function:{name:e.name||"",arguments:""}}]},finish_reason:null}]}}if("response.function_call_arguments.delta"===n){let e=o.delta||"";return e?{id:t.chatId,object:"chat.completion.chunk",created:t.created,model:t.model||"gpt-4",choices:[{index:0,delta:{tool_calls:[{index:t.toolCallIndex,id:t.currentToolCallId,type:"function",function:{arguments:e}}]},finish_reason:null}]}:null}if("response.output_item.done"===n&&o.item?.type==="function_call")return t.toolCallIndex++,null;if("response.completed"===n){let e=o.response?.usage;if(e&&"object"==typeof e){let n=e.input_tokens||e.prompt_tokens||0,o=e.output_tokens||e.completion_tokens||0,s=e.cache_read_input_tokens||0,r=e.cache_creation_input_tokens||0,i=n+s+r;t.usage={prompt_tokens:i,completion_tokens:o,total_tokens:i+o},(s>0||r>0)&&(t.usage.prompt_tokens_details={},s>0&&(t.usage.prompt_tokens_details.cached_tokens=s),r>0&&(t.usage.prompt_tokens_details.cache_creation_tokens=r))}if(!t.finishReasonSent){t.finishReasonSent=!0;let e=(t.toolCallIndex||0)>0?"tool_calls":"stop";t.finishReason=e;let n={id:t.chatId,object:"chat.completion.chunk",created:t.created,model:t.model||"gpt-4",choices:[{index:0,delta:{},finish_reason:e}]};return t.usage&&"object"==typeof t.usage&&(n.usage=t.usage),n}}return null}),f(t.FORMATS.KIRO,t.FORMATS.OPENAI,null,function(e,t){if(!e)return null;if("chat.completion.chunk"===e.object&&e.choices)return e;let n=e;if("string"==typeof e){let t=e.split("\n"),o="",s="";for(let e of t)e.startsWith("event:")?o=e.slice(6).trim():e.startsWith(":event-type:")?o=e.slice(12).trim():e.startsWith("data:")?s=e.slice(5).trim():e.startsWith(":content-type:")||e.trim()&&!e.startsWith(":")&&(s=e.trim());if(!s)return null;try{(n=JSON.parse(s))._eventType=o}catch{n={text:s,_eventType:o}}}t.responseId||(t.responseId=`chatcmpl-${Date.now()}`,t.created=Math.floor(Date.now()/1e3),t.chunkIndex=0);let o=n._eventType||n.event||"";if("assistantResponseEvent"===o||n.assistantResponseEvent){let e=n.assistantResponseEvent?.content||n.content||"";if(!e)return null;let o={id:t.responseId,object:"chat.completion.chunk",created:t.created,model:t.model||"kiro",choices:[{index:0,delta:{...0===t.chunkIndex?{role:"assistant"}:{},content:e},finish_reason:null}]};return t.chunkIndex++,o}if("reasoningContentEvent"===o||n.reasoningContentEvent){let e=n.reasoningContentEvent?.content||n.content||"";if(!e)return null;let o={id:t.responseId,object:"chat.completion.chunk",created:t.created,model:t.model||"kiro",choices:[{index:0,delta:{...0===t.chunkIndex?{role:"assistant"}:{},content:`<thinking>${e}</thinking>`},finish_reason:null}]};return t.chunkIndex++,o}if("toolUseEvent"===o||n.toolUseEvent){let e=n.toolUseEvent||n,o=e.toolUseId||`call_${Date.now()}`,s=e.name||"",r=e.input||{},i={id:t.responseId,object:"chat.completion.chunk",created:t.created,model:t.model||"kiro",choices:[{index:0,delta:{...0===t.chunkIndex?{role:"assistant"}:{},tool_calls:[{index:0,id:o,type:"function",function:{name:s,arguments:JSON.stringify(r)}}]},finish_reason:null}]};return t.chunkIndex++,i}if("messageStopEvent"===o||"done"===o||n.messageStopEvent){t.finishReason="stop";let e={id:t.responseId,object:"chat.completion.chunk",created:t.created,model:t.model||"kiro",choices:[{index:0,delta:{},finish_reason:"stop"}]};return t.usage&&"object"==typeof t.usage&&(e.usage=t.usage),e}if("usageEvent"===o||n.usageEvent){let e=n.usageEvent||n;e&&"object"==typeof e&&(t.usage={prompt_tokens:e.inputTokens||0,completion_tokens:e.outputTokens||0,total_tokens:(e.inputTokens||0)+(e.outputTokens||0)})}return null}),f(t.FORMATS.CURSOR,t.FORMATS.OPENAI,null,function(e,t){return e?("chat.completion.chunk"===e.object&&e.choices||"chat.completion"===e.object&&e.choices,e):null});var et=e.i(85713),en=e.i(384094);let eo=new Set([]),es=["glm-","ernie-"];function er(e){return"string"==typeof e?e:Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e&&"type"in e&&"text"===e.type).map(e=>"string"==typeof e.text?e.text:"").join("\n"):""}function ei(e,t,n,o,s){if(!Array.isArray(e))return e;let r=Array.isArray(e)&&("openai"!==o||!1===s)?e.map(e=>e&&"object"==typeof e&&"developer"===("string"==typeof e.role?e.role:"").toLowerCase()?{...e,role:"system"}:e):e;return function(e,t,n){if(!Array.isArray(e)||0===e.length||function(e,t){if(eo.has(e))return!1;let n=(t||"").toLowerCase();for(let e of es)if(n.startsWith(e))return!1;return!0}(t,n))return e;let o=e.filter(e=>"system"===e.role||"developer"===e.role);if(0===o.length)return e;let s=o.map(e=>er(e.content)).filter(Boolean).join("\n\n");if(!s)return e.filter(e=>"system"!==e.role&&"developer"!==e.role);let r=e.filter(e=>"system"!==e.role&&"developer"!==e.role),i=r.findIndex(e=>"user"===e.role);if(i>=0){let e=r[i],t=er(e.content);r[i]={...e,content:`[System Instructions]
13
13
  ${s}
14
14
 
15
15
  [User Message]
@@ -1,3 +1,3 @@
1
- module.exports=[918622,(a,b,c)=>{b.exports=a.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},446786,(a,b,c)=>{b.exports=a.x("os",()=>require("os"))},677850,a=>a.a(async(b,c)=>{try{let b=await a.y("zod");a.n(b),c()}catch(a){c(a)}},!0),342602,(a,b,c)=>{"use strict";b.exports=a.r(918622)},187924,(a,b,c)=>{"use strict";b.exports=a.r(342602).vendored["react-ssr"].ReactJsxRuntime},572131,(a,b,c)=>{"use strict";b.exports=a.r(342602).vendored["react-ssr"].React},804730,a=>{a.v({name:"omniroute",version:"3.0.7",description:"Smart AI Router with auto fallback — route to FREE & cheap models, zero downtime. Works with Cursor, Cline, Claude Desktop, Codex, and any OpenAI-compatible tool.",type:"module",bin:{omniroute:"bin/omniroute.mjs","omniroute-reset-password":"bin/reset-password.mjs"},files:["bin/","app/","open-sse/mcp-server/","src/shared/contracts/","scripts/postinstall.mjs","scripts/native-binary-compat.mjs","README.md","LICENSE"],workspaces:["open-sse"],engines:{node:">=18.0.0 <24.0.0"},keywords:["ai","router","proxy","openai","claude","anthropic","gemini","fallback","cursor","cline","codex","llm","auto-fallback"],license:"MIT",author:"diegosouzapw",repository:{type:"git",url:"https://github.com/diegosouzapw/OmniRoute"},homepage:"https://omniroute.online",scripts:{dev:"node scripts/run-next.mjs dev",build:"node scripts/build-next-isolated.mjs","build:cli":"node scripts/prepublish.mjs",start:"node scripts/run-next.mjs start",lint:"eslint .","electron:dev":'concurrently "npm run dev" "wait-on http://localhost:20128 && cd electron && npm run dev"',"electron:build":"npm run build && cd electron && npm run build","electron:build:win":"npm run build && cd electron && npm run build:win","electron:build:mac":"npm run build && cd electron && npm run build:mac","electron:build:linux":"npm run build && cd electron && npm run build:linux",test:"node --import tsx/esm --test tests/unit/*.test.mjs","test:unit":"node --import tsx/esm --test tests/unit/*.test.mjs","test:plan3":"node --import tsx/esm --test tests/unit/plan3-p0.test.mjs","test:fixes":"node --import tsx/esm --test tests/unit/fixes-p1.test.mjs","test:security":"node --import tsx/esm --test tests/unit/security-fase01.test.mjs","check:cycles":"node scripts/check-cycles.mjs","check:route-validation:t06":"node scripts/check-route-validation.mjs","check:any-budget:t11":"node scripts/check-t11-any-budget.mjs","check:docs-sync":"node scripts/check-docs-sync.mjs","typecheck:core":"tsc --pretty false -p tsconfig.typecheck-core.json","typecheck:noimplicit:core":"tsc --pretty false -p tsconfig.typecheck-noimplicit-core.json","test:integration":"node --import tsx/esm --test tests/integration/*.test.mjs","test:e2e":"node scripts/run-playwright-tests.mjs test tests/e2e/*.spec.ts","test:protocols:e2e":"node scripts/run-protocol-clients-tests.mjs","test:vitest":"vitest run open-sse/mcp-server/__tests__/*.test.ts open-sse/services/autoCombo/__tests__/*.test.ts","test:ecosystem":"node scripts/run-ecosystem-tests.mjs","test:coverage":"npx c8 --exclude=open-sse --check-coverage --lines 50 --functions 50 --branches 50 node --import tsx/esm --test tests/unit/*.test.mjs","test:all":"npm run test:unit && npm run test:vitest && npm run test:ecosystem && npm run test:e2e",check:"npm run lint && npm run test",prepublishOnly:"npm run build:cli",postinstall:"node scripts/postinstall.mjs",prepare:"husky","system-info":"node scripts/system-info.mjs"},dependencies:{"@lobehub/icons":"^5.0.1","@modelcontextprotocol/sdk":"^1.27.1","@monaco-editor/react":"^4.7.0","@swc/helpers":"0.5.19",bcryptjs:"^3.0.3","better-sqlite3":"^12.6.2",bottleneck:"^2.19.5",dompurify:"^3.3.2",express:"^5.2.1","fetch-socks":"^1.3.2","http-proxy-middleware":"^3.0.5","https-proxy-agent":"^8.0.0",jose:"^6.1.3",keytar:"^7.9.0",lowdb:"^7.0.1","monaco-editor":"^0.55.1",next:"^16.0.10","next-intl":"^4.8.3","node-machine-id":"^1.1.12",open:"^11.0.0",ora:"^9.1.0",pino:"^10.3.1","pino-pretty":"^13.1.3",react:"19.2.4","react-dom":"19.2.4",recharts:"^3.7.0",selfsigned:"^5.5.0",tsx:"^4.21.0",undici:"^7.19.2",uuid:"^13.0.0","wreq-js":"^2.0.1",zod:"^4.3.6",zustand:"^5.0.10"},devDependencies:{"@playwright/test":"^1.58.2","@tailwindcss/postcss":"^4.1.18","@types/bcryptjs":"^3.0.0","@types/better-sqlite3":"^7.6.13","@types/keytar":"^4.4.0","@types/node":"^25.2.3","@types/react":"^19.2.14","@types/react-dom":"^19.2.3",concurrently:"^9.2.1","cross-env":"^10.1.0",eslint:"^9.39.2","eslint-config-next":"^16.0.10",husky:"^9.1.7","lint-staged":"^16.2.7",prettier:"^3.8.1",tailwindcss:"^4",typescript:"^5.9.3","typescript-eslint":"^8.56.0",vitest:"^4.0.18","wait-on":"^9.0.4"},"lint-staged":{"*.{js,jsx,ts,tsx,mjs}":["prettier --write","eslint --fix --no-error-on-unmatched-pattern"],"*.{json,md,yml,yaml,css}":["prettier --write"]},pnpm:{onlyBuiltDependencies:["@parcel/watcher","@swc/core","better-sqlite3","esbuild","omniroute","sharp"]},overrides:{dompurify:"^3.3.2"}})},588788,a=>{"use strict";var b=a.i(32886),c=a.i(187924);function d({locale:a,...d}){if(!a)throw Error(void 0);return(0,c.jsx)(b.IntlProvider,{locale:a,...d})}a.s(["default",()=>d])}];
1
+ module.exports=[918622,(a,b,c)=>{b.exports=a.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},446786,(a,b,c)=>{b.exports=a.x("os",()=>require("os"))},677850,a=>a.a(async(b,c)=>{try{let b=await a.y("zod");a.n(b),c()}catch(a){c(a)}},!0),342602,(a,b,c)=>{"use strict";b.exports=a.r(918622)},187924,(a,b,c)=>{"use strict";b.exports=a.r(342602).vendored["react-ssr"].ReactJsxRuntime},572131,(a,b,c)=>{"use strict";b.exports=a.r(342602).vendored["react-ssr"].React},804730,a=>{a.v({name:"omniroute",version:"3.0.9",description:"Smart AI Router with auto fallback — route to FREE & cheap models, zero downtime. Works with Cursor, Cline, Claude Desktop, Codex, and any OpenAI-compatible tool.",type:"module",bin:{omniroute:"bin/omniroute.mjs","omniroute-reset-password":"bin/reset-password.mjs"},files:["bin/","app/","open-sse/mcp-server/","src/shared/contracts/","scripts/postinstall.mjs","scripts/native-binary-compat.mjs","README.md","LICENSE"],workspaces:["open-sse"],engines:{node:">=18.0.0 <24.0.0"},keywords:["ai","router","proxy","openai","claude","anthropic","gemini","fallback","cursor","cline","codex","llm","auto-fallback"],license:"MIT",author:"diegosouzapw",repository:{type:"git",url:"https://github.com/diegosouzapw/OmniRoute"},homepage:"https://omniroute.online",scripts:{dev:"node scripts/run-next.mjs dev",build:"node scripts/build-next-isolated.mjs","build:cli":"node scripts/prepublish.mjs",start:"node scripts/run-next.mjs start",lint:"eslint .","electron:dev":'concurrently "npm run dev" "wait-on http://localhost:20128 && cd electron && npm run dev"',"electron:build":"npm run build && cd electron && npm run build","electron:build:win":"npm run build && cd electron && npm run build:win","electron:build:mac":"npm run build && cd electron && npm run build:mac","electron:build:linux":"npm run build && cd electron && npm run build:linux",test:"node --import tsx/esm --test tests/unit/*.test.mjs","test:unit":"node --import tsx/esm --test tests/unit/*.test.mjs","test:plan3":"node --import tsx/esm --test tests/unit/plan3-p0.test.mjs","test:fixes":"node --import tsx/esm --test tests/unit/fixes-p1.test.mjs","test:security":"node --import tsx/esm --test tests/unit/security-fase01.test.mjs","check:cycles":"node scripts/check-cycles.mjs","check:route-validation:t06":"node scripts/check-route-validation.mjs","check:any-budget:t11":"node scripts/check-t11-any-budget.mjs","check:docs-sync":"node scripts/check-docs-sync.mjs","typecheck:core":"tsc --pretty false -p tsconfig.typecheck-core.json","typecheck:noimplicit:core":"tsc --pretty false -p tsconfig.typecheck-noimplicit-core.json","test:integration":"node --import tsx/esm --test tests/integration/*.test.mjs","test:e2e":"node scripts/run-playwright-tests.mjs test tests/e2e/*.spec.ts","test:protocols:e2e":"node scripts/run-protocol-clients-tests.mjs","test:vitest":"vitest run open-sse/mcp-server/__tests__/*.test.ts open-sse/services/autoCombo/__tests__/*.test.ts","test:ecosystem":"node scripts/run-ecosystem-tests.mjs","test:coverage":"npx c8 --exclude=open-sse --check-coverage --lines 50 --functions 50 --branches 50 node --import tsx/esm --test tests/unit/*.test.mjs","test:all":"npm run test:unit && npm run test:vitest && npm run test:ecosystem && npm run test:e2e",check:"npm run lint && npm run test",prepublishOnly:"npm run build:cli",postinstall:"node scripts/postinstall.mjs",prepare:"husky","system-info":"node scripts/system-info.mjs"},dependencies:{"@lobehub/icons":"^5.0.1","@modelcontextprotocol/sdk":"^1.27.1","@monaco-editor/react":"^4.7.0","@swc/helpers":"0.5.19",bcryptjs:"^3.0.3","better-sqlite3":"^12.6.2",bottleneck:"^2.19.5",dompurify:"^3.3.2",express:"^5.2.1","fetch-socks":"^1.3.2","http-proxy-middleware":"^3.0.5","https-proxy-agent":"^8.0.0",jose:"^6.1.3",keytar:"^7.9.0",lowdb:"^7.0.1","monaco-editor":"^0.55.1",next:"^16.0.10","next-intl":"^4.8.3","node-machine-id":"^1.1.12",open:"^11.0.0",ora:"^9.1.0",pino:"^10.3.1","pino-pretty":"^13.1.3",react:"19.2.4","react-dom":"19.2.4",recharts:"^3.7.0",selfsigned:"^5.5.0",tsx:"^4.21.0",undici:"^7.19.2",uuid:"^13.0.0","wreq-js":"^2.0.1",zod:"^4.3.6",zustand:"^5.0.10"},devDependencies:{"@playwright/test":"^1.58.2","@tailwindcss/postcss":"^4.1.18","@types/bcryptjs":"^3.0.0","@types/better-sqlite3":"^7.6.13","@types/keytar":"^4.4.0","@types/node":"^25.2.3","@types/react":"^19.2.14","@types/react-dom":"^19.2.3",concurrently:"^9.2.1","cross-env":"^10.1.0",eslint:"^9.39.2","eslint-config-next":"^16.0.10",husky:"^9.1.7","lint-staged":"^16.2.7",prettier:"^3.8.1",tailwindcss:"^4",typescript:"^5.9.3","typescript-eslint":"^8.56.0",vitest:"^4.0.18","wait-on":"^9.0.4"},"lint-staged":{"*.{js,jsx,ts,tsx,mjs}":["prettier --write","eslint --fix --no-error-on-unmatched-pattern"],"*.{json,md,yml,yaml,css}":["prettier --write"]},pnpm:{onlyBuiltDependencies:["@parcel/watcher","@swc/core","better-sqlite3","esbuild","omniroute","sharp"]},overrides:{dompurify:"^3.3.2"}})},588788,a=>{"use strict";var b=a.i(32886),c=a.i(187924);function d({locale:a,...d}){if(!a)throw Error(void 0);return(0,c.jsx)(b.IntlProvider,{locale:a,...d})}a.s(["default",()=>d])}];
2
2
 
3
3
  //# sourceMappingURL=%5Broot-of-the-server%5D__9ef96d20._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[193695,(a,b,c)=>{b.exports=a.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},677850,a=>a.a(async(b,c)=>{try{let b=await a.y("zod");a.n(b),c()}catch(a){c(a)}},!0),804730,a=>{a.v({name:"omniroute",version:"3.0.7",description:"Smart AI Router with auto fallback — route to FREE & cheap models, zero downtime. Works with Cursor, Cline, Claude Desktop, Codex, and any OpenAI-compatible tool.",type:"module",bin:{omniroute:"bin/omniroute.mjs","omniroute-reset-password":"bin/reset-password.mjs"},files:["bin/","app/","open-sse/mcp-server/","src/shared/contracts/","scripts/postinstall.mjs","scripts/native-binary-compat.mjs","README.md","LICENSE"],workspaces:["open-sse"],engines:{node:">=18.0.0 <24.0.0"},keywords:["ai","router","proxy","openai","claude","anthropic","gemini","fallback","cursor","cline","codex","llm","auto-fallback"],license:"MIT",author:"diegosouzapw",repository:{type:"git",url:"https://github.com/diegosouzapw/OmniRoute"},homepage:"https://omniroute.online",scripts:{dev:"node scripts/run-next.mjs dev",build:"node scripts/build-next-isolated.mjs","build:cli":"node scripts/prepublish.mjs",start:"node scripts/run-next.mjs start",lint:"eslint .","electron:dev":'concurrently "npm run dev" "wait-on http://localhost:20128 && cd electron && npm run dev"',"electron:build":"npm run build && cd electron && npm run build","electron:build:win":"npm run build && cd electron && npm run build:win","electron:build:mac":"npm run build && cd electron && npm run build:mac","electron:build:linux":"npm run build && cd electron && npm run build:linux",test:"node --import tsx/esm --test tests/unit/*.test.mjs","test:unit":"node --import tsx/esm --test tests/unit/*.test.mjs","test:plan3":"node --import tsx/esm --test tests/unit/plan3-p0.test.mjs","test:fixes":"node --import tsx/esm --test tests/unit/fixes-p1.test.mjs","test:security":"node --import tsx/esm --test tests/unit/security-fase01.test.mjs","check:cycles":"node scripts/check-cycles.mjs","check:route-validation:t06":"node scripts/check-route-validation.mjs","check:any-budget:t11":"node scripts/check-t11-any-budget.mjs","check:docs-sync":"node scripts/check-docs-sync.mjs","typecheck:core":"tsc --pretty false -p tsconfig.typecheck-core.json","typecheck:noimplicit:core":"tsc --pretty false -p tsconfig.typecheck-noimplicit-core.json","test:integration":"node --import tsx/esm --test tests/integration/*.test.mjs","test:e2e":"node scripts/run-playwright-tests.mjs test tests/e2e/*.spec.ts","test:protocols:e2e":"node scripts/run-protocol-clients-tests.mjs","test:vitest":"vitest run open-sse/mcp-server/__tests__/*.test.ts open-sse/services/autoCombo/__tests__/*.test.ts","test:ecosystem":"node scripts/run-ecosystem-tests.mjs","test:coverage":"npx c8 --exclude=open-sse --check-coverage --lines 50 --functions 50 --branches 50 node --import tsx/esm --test tests/unit/*.test.mjs","test:all":"npm run test:unit && npm run test:vitest && npm run test:ecosystem && npm run test:e2e",check:"npm run lint && npm run test",prepublishOnly:"npm run build:cli",postinstall:"node scripts/postinstall.mjs",prepare:"husky","system-info":"node scripts/system-info.mjs"},dependencies:{"@lobehub/icons":"^5.0.1","@modelcontextprotocol/sdk":"^1.27.1","@monaco-editor/react":"^4.7.0","@swc/helpers":"0.5.19",bcryptjs:"^3.0.3","better-sqlite3":"^12.6.2",bottleneck:"^2.19.5",dompurify:"^3.3.2",express:"^5.2.1","fetch-socks":"^1.3.2","http-proxy-middleware":"^3.0.5","https-proxy-agent":"^8.0.0",jose:"^6.1.3",keytar:"^7.9.0",lowdb:"^7.0.1","monaco-editor":"^0.55.1",next:"^16.0.10","next-intl":"^4.8.3","node-machine-id":"^1.1.12",open:"^11.0.0",ora:"^9.1.0",pino:"^10.3.1","pino-pretty":"^13.1.3",react:"19.2.4","react-dom":"19.2.4",recharts:"^3.7.0",selfsigned:"^5.5.0",tsx:"^4.21.0",undici:"^7.19.2",uuid:"^13.0.0","wreq-js":"^2.0.1",zod:"^4.3.6",zustand:"^5.0.10"},devDependencies:{"@playwright/test":"^1.58.2","@tailwindcss/postcss":"^4.1.18","@types/bcryptjs":"^3.0.0","@types/better-sqlite3":"^7.6.13","@types/keytar":"^4.4.0","@types/node":"^25.2.3","@types/react":"^19.2.14","@types/react-dom":"^19.2.3",concurrently:"^9.2.1","cross-env":"^10.1.0",eslint:"^9.39.2","eslint-config-next":"^16.0.10",husky:"^9.1.7","lint-staged":"^16.2.7",prettier:"^3.8.1",tailwindcss:"^4",typescript:"^5.9.3","typescript-eslint":"^8.56.0",vitest:"^4.0.18","wait-on":"^9.0.4"},"lint-staged":{"*.{js,jsx,ts,tsx,mjs}":["prettier --write","eslint --fix --no-error-on-unmatched-pattern"],"*.{json,md,yml,yaml,css}":["prettier --write"]},pnpm:{onlyBuiltDependencies:["@parcel/watcher","@swc/core","better-sqlite3","esbuild","omniroute","sharp"]},overrides:{dompurify:"^3.3.2"}})},569264,a=>{a.n(a.i(354832))},650645,a=>{a.n(a.i(827572))},923576,a=>{a.n(a.i(104858))},825210,a=>{a.n(a.i(402747))},517537,a=>{a.n(a.i(903363))},13718,a=>{a.n(a.i(47967))},118198,a=>{a.n(a.i(545518))},296736,(a,b,c)=>{"use strict";function d(a){if("function"!=typeof WeakMap)return null;var b=new WeakMap,c=new WeakMap;return(d=function(a){return a?c:b})(a)}c._=function(a,b){if(!b&&a&&a.__esModule)return a;if(null===a||"object"!=typeof a&&"function"!=typeof a)return{default:a};var c=d(b);if(c&&c.has(a))return c.get(a);var e={__proto__:null},f=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var g in a)if("default"!==g&&Object.prototype.hasOwnProperty.call(a,g)){var h=f?Object.getOwnPropertyDescriptor(a,g):null;h&&(h.get||h.set)?Object.defineProperty(e,g,h):e[g]=a[g]}return e.default=a,c&&c.set(a,e),e}},500790,(a,b,c)=>{let{createClientModuleProxy:d}=a.r(211857);a.n(d("[project]/node_modules/next/dist/client/app-dir/link.js <module evaluation>"))},784707,(a,b,c)=>{let{createClientModuleProxy:d}=a.r(211857);a.n(d("[project]/node_modules/next/dist/client/app-dir/link.js"))},297647,a=>{"use strict";a.i(500790);var b=a.i(784707);a.n(b)},395936,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={default:function(){return i},useLinkStatus:function(){return h.useLinkStatus}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f=a.r(296736),g=a.r(907997),h=f._(a.r(297647));function i(a){let b=a.legacyBehavior,c="string"==typeof a.children||"number"==typeof a.children||"string"==typeof a.children?.type,d=a.children?.type?.$$typeof===Symbol.for("react.client.reference");return!b||c||d||(a.children?.type?.$$typeof===Symbol.for("react.lazy")?console.error("Using a Lazy Component as a direct child of `<Link legacyBehavior>` from a Server Component is not supported. If you need legacyBehavior, wrap your Lazy Component in a Client Component that renders the Link's `<a>` tag."):console.error("Using a Server Component as a direct child of `<Link legacyBehavior>` is not supported. If you need legacyBehavior, wrap your Server Component in a Client Component that renders the Link's `<a>` tag.")),(0,g.jsx)(h.default,{...a})}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},330878,a=>{"use strict";var b=a.i(800717),c=a.i(118845),d=a.i(40953),e=(0,b.cache)(function(a,b){return function({_cache:a=(0,c.b)(),_formatters:b=(0,c.c)(a),getMessageFallback:e=d.d,messages:f,namespace:g,onError:h=d.b,...i}){return function({messages:a,namespace:b,...c},e){return a=a["!"],b=(0,d.r)(b,"!"),(0,d.a)({...c,messages:a,namespace:b})}({...i,onError:h,cache:a,formatters:b,getMessageFallback:e,messages:{"!":f},namespace:g?`!.${g}`:"!"},0)}({...a,namespace:b})});a.s(["default",()=>e],330878)},442979,a=>{"use strict";var b=a.i(330878),c=a.i(767228),d=a.i(800717)["use".trim()];function e(...[a]){let f=function(a){var b=(0,c.default)();try{return d(b)}catch(b){throw b instanceof TypeError&&b.message.includes("Cannot read properties of null (reading 'use')")?Error(`\`${a}\` is not callable within an async component. Please refer to https://next-intl.dev/docs/environments/server-client-components#async-components`,{cause:b}):b}}("useTranslations");return(0,b.default)(f,a)}a.s(["useTranslations",()=>e],442979)}];
1
+ module.exports=[193695,(a,b,c)=>{b.exports=a.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},677850,a=>a.a(async(b,c)=>{try{let b=await a.y("zod");a.n(b),c()}catch(a){c(a)}},!0),804730,a=>{a.v({name:"omniroute",version:"3.0.9",description:"Smart AI Router with auto fallback — route to FREE & cheap models, zero downtime. Works with Cursor, Cline, Claude Desktop, Codex, and any OpenAI-compatible tool.",type:"module",bin:{omniroute:"bin/omniroute.mjs","omniroute-reset-password":"bin/reset-password.mjs"},files:["bin/","app/","open-sse/mcp-server/","src/shared/contracts/","scripts/postinstall.mjs","scripts/native-binary-compat.mjs","README.md","LICENSE"],workspaces:["open-sse"],engines:{node:">=18.0.0 <24.0.0"},keywords:["ai","router","proxy","openai","claude","anthropic","gemini","fallback","cursor","cline","codex","llm","auto-fallback"],license:"MIT",author:"diegosouzapw",repository:{type:"git",url:"https://github.com/diegosouzapw/OmniRoute"},homepage:"https://omniroute.online",scripts:{dev:"node scripts/run-next.mjs dev",build:"node scripts/build-next-isolated.mjs","build:cli":"node scripts/prepublish.mjs",start:"node scripts/run-next.mjs start",lint:"eslint .","electron:dev":'concurrently "npm run dev" "wait-on http://localhost:20128 && cd electron && npm run dev"',"electron:build":"npm run build && cd electron && npm run build","electron:build:win":"npm run build && cd electron && npm run build:win","electron:build:mac":"npm run build && cd electron && npm run build:mac","electron:build:linux":"npm run build && cd electron && npm run build:linux",test:"node --import tsx/esm --test tests/unit/*.test.mjs","test:unit":"node --import tsx/esm --test tests/unit/*.test.mjs","test:plan3":"node --import tsx/esm --test tests/unit/plan3-p0.test.mjs","test:fixes":"node --import tsx/esm --test tests/unit/fixes-p1.test.mjs","test:security":"node --import tsx/esm --test tests/unit/security-fase01.test.mjs","check:cycles":"node scripts/check-cycles.mjs","check:route-validation:t06":"node scripts/check-route-validation.mjs","check:any-budget:t11":"node scripts/check-t11-any-budget.mjs","check:docs-sync":"node scripts/check-docs-sync.mjs","typecheck:core":"tsc --pretty false -p tsconfig.typecheck-core.json","typecheck:noimplicit:core":"tsc --pretty false -p tsconfig.typecheck-noimplicit-core.json","test:integration":"node --import tsx/esm --test tests/integration/*.test.mjs","test:e2e":"node scripts/run-playwright-tests.mjs test tests/e2e/*.spec.ts","test:protocols:e2e":"node scripts/run-protocol-clients-tests.mjs","test:vitest":"vitest run open-sse/mcp-server/__tests__/*.test.ts open-sse/services/autoCombo/__tests__/*.test.ts","test:ecosystem":"node scripts/run-ecosystem-tests.mjs","test:coverage":"npx c8 --exclude=open-sse --check-coverage --lines 50 --functions 50 --branches 50 node --import tsx/esm --test tests/unit/*.test.mjs","test:all":"npm run test:unit && npm run test:vitest && npm run test:ecosystem && npm run test:e2e",check:"npm run lint && npm run test",prepublishOnly:"npm run build:cli",postinstall:"node scripts/postinstall.mjs",prepare:"husky","system-info":"node scripts/system-info.mjs"},dependencies:{"@lobehub/icons":"^5.0.1","@modelcontextprotocol/sdk":"^1.27.1","@monaco-editor/react":"^4.7.0","@swc/helpers":"0.5.19",bcryptjs:"^3.0.3","better-sqlite3":"^12.6.2",bottleneck:"^2.19.5",dompurify:"^3.3.2",express:"^5.2.1","fetch-socks":"^1.3.2","http-proxy-middleware":"^3.0.5","https-proxy-agent":"^8.0.0",jose:"^6.1.3",keytar:"^7.9.0",lowdb:"^7.0.1","monaco-editor":"^0.55.1",next:"^16.0.10","next-intl":"^4.8.3","node-machine-id":"^1.1.12",open:"^11.0.0",ora:"^9.1.0",pino:"^10.3.1","pino-pretty":"^13.1.3",react:"19.2.4","react-dom":"19.2.4",recharts:"^3.7.0",selfsigned:"^5.5.0",tsx:"^4.21.0",undici:"^7.19.2",uuid:"^13.0.0","wreq-js":"^2.0.1",zod:"^4.3.6",zustand:"^5.0.10"},devDependencies:{"@playwright/test":"^1.58.2","@tailwindcss/postcss":"^4.1.18","@types/bcryptjs":"^3.0.0","@types/better-sqlite3":"^7.6.13","@types/keytar":"^4.4.0","@types/node":"^25.2.3","@types/react":"^19.2.14","@types/react-dom":"^19.2.3",concurrently:"^9.2.1","cross-env":"^10.1.0",eslint:"^9.39.2","eslint-config-next":"^16.0.10",husky:"^9.1.7","lint-staged":"^16.2.7",prettier:"^3.8.1",tailwindcss:"^4",typescript:"^5.9.3","typescript-eslint":"^8.56.0",vitest:"^4.0.18","wait-on":"^9.0.4"},"lint-staged":{"*.{js,jsx,ts,tsx,mjs}":["prettier --write","eslint --fix --no-error-on-unmatched-pattern"],"*.{json,md,yml,yaml,css}":["prettier --write"]},pnpm:{onlyBuiltDependencies:["@parcel/watcher","@swc/core","better-sqlite3","esbuild","omniroute","sharp"]},overrides:{dompurify:"^3.3.2"}})},569264,a=>{a.n(a.i(354832))},650645,a=>{a.n(a.i(827572))},923576,a=>{a.n(a.i(104858))},825210,a=>{a.n(a.i(402747))},517537,a=>{a.n(a.i(903363))},13718,a=>{a.n(a.i(47967))},118198,a=>{a.n(a.i(545518))},296736,(a,b,c)=>{"use strict";function d(a){if("function"!=typeof WeakMap)return null;var b=new WeakMap,c=new WeakMap;return(d=function(a){return a?c:b})(a)}c._=function(a,b){if(!b&&a&&a.__esModule)return a;if(null===a||"object"!=typeof a&&"function"!=typeof a)return{default:a};var c=d(b);if(c&&c.has(a))return c.get(a);var e={__proto__:null},f=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var g in a)if("default"!==g&&Object.prototype.hasOwnProperty.call(a,g)){var h=f?Object.getOwnPropertyDescriptor(a,g):null;h&&(h.get||h.set)?Object.defineProperty(e,g,h):e[g]=a[g]}return e.default=a,c&&c.set(a,e),e}},500790,(a,b,c)=>{let{createClientModuleProxy:d}=a.r(211857);a.n(d("[project]/node_modules/next/dist/client/app-dir/link.js <module evaluation>"))},784707,(a,b,c)=>{let{createClientModuleProxy:d}=a.r(211857);a.n(d("[project]/node_modules/next/dist/client/app-dir/link.js"))},297647,a=>{"use strict";a.i(500790);var b=a.i(784707);a.n(b)},395936,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={default:function(){return i},useLinkStatus:function(){return h.useLinkStatus}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});let f=a.r(296736),g=a.r(907997),h=f._(a.r(297647));function i(a){let b=a.legacyBehavior,c="string"==typeof a.children||"number"==typeof a.children||"string"==typeof a.children?.type,d=a.children?.type?.$$typeof===Symbol.for("react.client.reference");return!b||c||d||(a.children?.type?.$$typeof===Symbol.for("react.lazy")?console.error("Using a Lazy Component as a direct child of `<Link legacyBehavior>` from a Server Component is not supported. If you need legacyBehavior, wrap your Lazy Component in a Client Component that renders the Link's `<a>` tag."):console.error("Using a Server Component as a direct child of `<Link legacyBehavior>` is not supported. If you need legacyBehavior, wrap your Server Component in a Client Component that renders the Link's `<a>` tag.")),(0,g.jsx)(h.default,{...a})}("function"==typeof c.default||"object"==typeof c.default&&null!==c.default)&&void 0===c.default.__esModule&&(Object.defineProperty(c.default,"__esModule",{value:!0}),Object.assign(c.default,c),b.exports=c.default)},330878,a=>{"use strict";var b=a.i(800717),c=a.i(118845),d=a.i(40953),e=(0,b.cache)(function(a,b){return function({_cache:a=(0,c.b)(),_formatters:b=(0,c.c)(a),getMessageFallback:e=d.d,messages:f,namespace:g,onError:h=d.b,...i}){return function({messages:a,namespace:b,...c},e){return a=a["!"],b=(0,d.r)(b,"!"),(0,d.a)({...c,messages:a,namespace:b})}({...i,onError:h,cache:a,formatters:b,getMessageFallback:e,messages:{"!":f},namespace:g?`!.${g}`:"!"},0)}({...a,namespace:b})});a.s(["default",()=>e],330878)},442979,a=>{"use strict";var b=a.i(330878),c=a.i(767228),d=a.i(800717)["use".trim()];function e(...[a]){let f=function(a){var b=(0,c.default)();try{return d(b)}catch(b){throw b instanceof TypeError&&b.message.includes("Cannot read properties of null (reading 'use')")?Error(`\`${a}\` is not callable within an async component. Please refer to https://next-intl.dev/docs/environments/server-client-components#async-components`,{cause:b}):b}}("useTranslations");return(0,b.default)(f,a)}a.s(["useTranslations",()=>e],442979)}];
2
2
 
3
3
  //# sourceMappingURL=%5Broot-of-the-server%5D__a6942102._.js.map
@@ -1,2 +1,2 @@
1
- <!DOCTYPE html><!--kmbT_1tKg7aSbEcFkhAUg--><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/ad127912b31cdc66.js"/><script src="/_next/static/chunks/3dd6d23a48e5d078.js" async=""></script><script src="/_next/static/chunks/4fa395d360c87cc3.js" async=""></script><script src="/_next/static/chunks/b133d1854532ff8c.js" async=""></script><script src="/_next/static/chunks/c88fcc5f8b21ff92.js" async=""></script><script src="/_next/static/chunks/turbopack-782b2fac4674487a.js" async=""></script><script src="/_next/static/chunks/d96012bcfc98706a.js" async=""></script><script src="/_next/static/chunks/16ea27c3b926bc31.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: Internal Server Error.</title><script src="/_next/static/chunks/a6dad97d9634a72d.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}
2
- @media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/ad127912b31cdc66.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[339756,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"default\"]\n3:I[837457,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"default\"]\n4:I[897367,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n7:I[897367,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"ViewportBoundary\"]\n9:I[897367,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"MetadataBoundary\"]\nb:I[168027,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"default\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"kmbT_1tKg7aSbEcFkhAUg\",\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"__PAGE__\",{}]}],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[\"$\",\"title\",null,{\"children\":\"500: Internal Server Error.\"}]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"lineHeight\":\"48px\"},\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}\\n@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"paddingRight\":23,\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\"},\"children\":\"500\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"28px\"},\"children\":\"Internal Server Error.\"}]}]]}]}]}]]}],[[\"$\",\"script\",\"script-0\",{\"src\":\"/_next/static/chunks/d96012bcfc98706a.js\",\"async\":true,\"nonce\":\"$undefined\"}],[\"$\",\"script\",\"script-1\",{\"src\":\"/_next/static/chunks/16ea27c3b926bc31.js\",\"async\":true,\"nonce\":\"$undefined\"}]],[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,false]},null,false,false],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L7\",null,{\"children\":\"$L8\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$L9\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$La\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$b\",\"$undefined\"],\"S\":true}\n"])</script><script>self.__next_f.push([1,"8:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"6:null\na:[]\n"])</script></body></html>
1
+ <!DOCTYPE html><!--nOx2_MqITU8BMdt9WgycY--><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/_next/static/chunks/ad127912b31cdc66.js"/><script src="/_next/static/chunks/3dd6d23a48e5d078.js" async=""></script><script src="/_next/static/chunks/4fa395d360c87cc3.js" async=""></script><script src="/_next/static/chunks/b133d1854532ff8c.js" async=""></script><script src="/_next/static/chunks/c88fcc5f8b21ff92.js" async=""></script><script src="/_next/static/chunks/turbopack-782b2fac4674487a.js" async=""></script><script src="/_next/static/chunks/d96012bcfc98706a.js" async=""></script><script src="/_next/static/chunks/16ea27c3b926bc31.js" async=""></script><meta name="next-size-adjust" content=""/><title>500: Internal Server Error.</title><script src="/_next/static/chunks/a6dad97d9634a72d.js" noModule=""></script></head><body><div hidden=""><!--$--><!--/$--></div><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}
2
+ @media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error.</h2></div></div></div><!--$--><!--/$--><script src="/_next/static/chunks/ad127912b31cdc66.js" id="_R_" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:\"$Sreact.fragment\"\n2:I[339756,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"default\"]\n3:I[837457,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"default\"]\n4:I[897367,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"OutletBoundary\"]\n5:\"$Sreact.suspense\"\n7:I[897367,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"ViewportBoundary\"]\n9:I[897367,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"MetadataBoundary\"]\nb:I[168027,[\"/_next/static/chunks/d96012bcfc98706a.js\",\"/_next/static/chunks/16ea27c3b926bc31.js\"],\"default\"]\n"])</script><script>self.__next_f.push([1,"0:{\"P\":null,\"b\":\"nOx2-MqITU8BMdt9WgycY\",\"c\":[\"\",\"_global-error\"],\"q\":\"\",\"i\":false,\"f\":[[[\"\",{\"children\":[\"__PAGE__\",{}]}],[[\"$\",\"$1\",\"c\",{\"children\":[null,[\"$\",\"$L2\",null,{\"parallelRouterKey\":\"children\",\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L3\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"forbidden\":\"$undefined\",\"unauthorized\":\"$undefined\"}]]}],{\"children\":[[\"$\",\"$1\",\"c\",{\"children\":[[\"$\",\"html\",null,{\"id\":\"__next_error__\",\"children\":[[\"$\",\"head\",null,{\"children\":[\"$\",\"title\",null,{\"children\":\"500: Internal Server Error.\"}]}],[\"$\",\"body\",null,{\"children\":[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"style\":{\"lineHeight\":\"48px\"},\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}\\n@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"paddingRight\":23,\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\"},\"children\":\"500\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"28px\"},\"children\":\"Internal Server Error.\"}]}]]}]}]}]]}],[[\"$\",\"script\",\"script-0\",{\"src\":\"/_next/static/chunks/d96012bcfc98706a.js\",\"async\":true,\"nonce\":\"$undefined\"}],[\"$\",\"script\",\"script-1\",{\"src\":\"/_next/static/chunks/16ea27c3b926bc31.js\",\"async\":true,\"nonce\":\"$undefined\"}]],[\"$\",\"$L4\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.MetadataOutlet\",\"children\":\"$@6\"}]}]]}],{},null,false,false]},null,false,false],[\"$\",\"$1\",\"h\",{\"children\":[null,[\"$\",\"$L7\",null,{\"children\":\"$L8\"}],[\"$\",\"div\",null,{\"hidden\":true,\"children\":[\"$\",\"$L9\",null,{\"children\":[\"$\",\"$5\",null,{\"name\":\"Next.Metadata\",\"children\":\"$La\"}]}]}],[\"$\",\"meta\",null,{\"name\":\"next-size-adjust\",\"content\":\"\"}]]}],false]],\"m\":\"$undefined\",\"G\":[\"$b\",\"$undefined\"],\"S\":true}\n"])</script><script>self.__next_f.push([1,"8:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])</script><script>self.__next_f.push([1,"6:null\na:[]\n"])</script></body></html>
@@ -1 +1 @@
1
- self.__RSC_SERVER_MANIFEST="{\n \"node\": {},\n \"edge\": {},\n \"encryptionKey\": \"GT2OGLcmUlhJAJa0YmX+L2I1G2XUUapLrPFxQursgOc=\"\n}"
1
+ self.__RSC_SERVER_MANIFEST="{\n \"node\": {},\n \"edge\": {},\n \"encryptionKey\": \"nQYpocaEXdp0rkBo6PV4SmQqSsc6mcevja7Li6UVu0Y=\"\n}"
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "node": {},
3
3
  "edge": {},
4
- "encryptionKey": "GT2OGLcmUlhJAJa0YmX+L2I1G2XUUapLrPFxQursgOc="
4
+ "encryptionKey": "nQYpocaEXdp0rkBo6PV4SmQqSsc6mcevja7Li6UVu0Y="
5
5
  }
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,804730,e=>{e.v({name:"omniroute",version:"3.0.7",description:"Smart AI Router with auto fallback — route to FREE & cheap models, zero downtime. Works with Cursor, Cline, Claude Desktop, Codex, and any OpenAI-compatible tool.",type:"module",bin:{omniroute:"bin/omniroute.mjs","omniroute-reset-password":"bin/reset-password.mjs"},files:["bin/","app/","open-sse/mcp-server/","src/shared/contracts/","scripts/postinstall.mjs","scripts/native-binary-compat.mjs","README.md","LICENSE"],workspaces:["open-sse"],engines:{node:">=18.0.0 <24.0.0"},keywords:["ai","router","proxy","openai","claude","anthropic","gemini","fallback","cursor","cline","codex","llm","auto-fallback"],license:"MIT",author:"diegosouzapw",repository:{type:"git",url:"https://github.com/diegosouzapw/OmniRoute"},homepage:"https://omniroute.online",scripts:{dev:"node scripts/run-next.mjs dev",build:"node scripts/build-next-isolated.mjs","build:cli":"node scripts/prepublish.mjs",start:"node scripts/run-next.mjs start",lint:"eslint .","electron:dev":'concurrently "npm run dev" "wait-on http://localhost:20128 && cd electron && npm run dev"',"electron:build":"npm run build && cd electron && npm run build","electron:build:win":"npm run build && cd electron && npm run build:win","electron:build:mac":"npm run build && cd electron && npm run build:mac","electron:build:linux":"npm run build && cd electron && npm run build:linux",test:"node --import tsx/esm --test tests/unit/*.test.mjs","test:unit":"node --import tsx/esm --test tests/unit/*.test.mjs","test:plan3":"node --import tsx/esm --test tests/unit/plan3-p0.test.mjs","test:fixes":"node --import tsx/esm --test tests/unit/fixes-p1.test.mjs","test:security":"node --import tsx/esm --test tests/unit/security-fase01.test.mjs","check:cycles":"node scripts/check-cycles.mjs","check:route-validation:t06":"node scripts/check-route-validation.mjs","check:any-budget:t11":"node scripts/check-t11-any-budget.mjs","check:docs-sync":"node scripts/check-docs-sync.mjs","typecheck:core":"tsc --pretty false -p tsconfig.typecheck-core.json","typecheck:noimplicit:core":"tsc --pretty false -p tsconfig.typecheck-noimplicit-core.json","test:integration":"node --import tsx/esm --test tests/integration/*.test.mjs","test:e2e":"node scripts/run-playwright-tests.mjs test tests/e2e/*.spec.ts","test:protocols:e2e":"node scripts/run-protocol-clients-tests.mjs","test:vitest":"vitest run open-sse/mcp-server/__tests__/*.test.ts open-sse/services/autoCombo/__tests__/*.test.ts","test:ecosystem":"node scripts/run-ecosystem-tests.mjs","test:coverage":"npx c8 --exclude=open-sse --check-coverage --lines 50 --functions 50 --branches 50 node --import tsx/esm --test tests/unit/*.test.mjs","test:all":"npm run test:unit && npm run test:vitest && npm run test:ecosystem && npm run test:e2e",check:"npm run lint && npm run test",prepublishOnly:"npm run build:cli",postinstall:"node scripts/postinstall.mjs",prepare:"husky","system-info":"node scripts/system-info.mjs"},dependencies:{"@lobehub/icons":"^5.0.1","@modelcontextprotocol/sdk":"^1.27.1","@monaco-editor/react":"^4.7.0","@swc/helpers":"0.5.19",bcryptjs:"^3.0.3","better-sqlite3":"^12.6.2",bottleneck:"^2.19.5",dompurify:"^3.3.2",express:"^5.2.1","fetch-socks":"^1.3.2","http-proxy-middleware":"^3.0.5","https-proxy-agent":"^8.0.0",jose:"^6.1.3",keytar:"^7.9.0",lowdb:"^7.0.1","monaco-editor":"^0.55.1",next:"^16.0.10","next-intl":"^4.8.3","node-machine-id":"^1.1.12",open:"^11.0.0",ora:"^9.1.0",pino:"^10.3.1","pino-pretty":"^13.1.3",react:"19.2.4","react-dom":"19.2.4",recharts:"^3.7.0",selfsigned:"^5.5.0",tsx:"^4.21.0",undici:"^7.19.2",uuid:"^13.0.0","wreq-js":"^2.0.1",zod:"^4.3.6",zustand:"^5.0.10"},devDependencies:{"@playwright/test":"^1.58.2","@tailwindcss/postcss":"^4.1.18","@types/bcryptjs":"^3.0.0","@types/better-sqlite3":"^7.6.13","@types/keytar":"^4.4.0","@types/node":"^25.2.3","@types/react":"^19.2.14","@types/react-dom":"^19.2.3",concurrently:"^9.2.1","cross-env":"^10.1.0",eslint:"^9.39.2","eslint-config-next":"^16.0.10",husky:"^9.1.7","lint-staged":"^16.2.7",prettier:"^3.8.1",tailwindcss:"^4",typescript:"^5.9.3","typescript-eslint":"^8.56.0",vitest:"^4.0.18","wait-on":"^9.0.4"},"lint-staged":{"*.{js,jsx,ts,tsx,mjs}":["prettier --write","eslint --fix --no-error-on-unmatched-pattern"],"*.{json,md,yml,yaml,css}":["prettier --write"]},pnpm:{onlyBuiltDependencies:["@parcel/watcher","@swc/core","better-sqlite3","esbuild","omniroute","sharp"]},overrides:{dompurify:"^3.3.2"}})},175696,e=>{"use strict";var t=e.i(861745),s=e.i(843476);function n({locale:e,...n}){if(!e)throw Error(void 0);return(0,s.jsx)(t.IntlProvider,{locale:e,...n})}e.s(["default",()=>n])}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,804730,e=>{e.v({name:"omniroute",version:"3.0.9",description:"Smart AI Router with auto fallback — route to FREE & cheap models, zero downtime. Works with Cursor, Cline, Claude Desktop, Codex, and any OpenAI-compatible tool.",type:"module",bin:{omniroute:"bin/omniroute.mjs","omniroute-reset-password":"bin/reset-password.mjs"},files:["bin/","app/","open-sse/mcp-server/","src/shared/contracts/","scripts/postinstall.mjs","scripts/native-binary-compat.mjs","README.md","LICENSE"],workspaces:["open-sse"],engines:{node:">=18.0.0 <24.0.0"},keywords:["ai","router","proxy","openai","claude","anthropic","gemini","fallback","cursor","cline","codex","llm","auto-fallback"],license:"MIT",author:"diegosouzapw",repository:{type:"git",url:"https://github.com/diegosouzapw/OmniRoute"},homepage:"https://omniroute.online",scripts:{dev:"node scripts/run-next.mjs dev",build:"node scripts/build-next-isolated.mjs","build:cli":"node scripts/prepublish.mjs",start:"node scripts/run-next.mjs start",lint:"eslint .","electron:dev":'concurrently "npm run dev" "wait-on http://localhost:20128 && cd electron && npm run dev"',"electron:build":"npm run build && cd electron && npm run build","electron:build:win":"npm run build && cd electron && npm run build:win","electron:build:mac":"npm run build && cd electron && npm run build:mac","electron:build:linux":"npm run build && cd electron && npm run build:linux",test:"node --import tsx/esm --test tests/unit/*.test.mjs","test:unit":"node --import tsx/esm --test tests/unit/*.test.mjs","test:plan3":"node --import tsx/esm --test tests/unit/plan3-p0.test.mjs","test:fixes":"node --import tsx/esm --test tests/unit/fixes-p1.test.mjs","test:security":"node --import tsx/esm --test tests/unit/security-fase01.test.mjs","check:cycles":"node scripts/check-cycles.mjs","check:route-validation:t06":"node scripts/check-route-validation.mjs","check:any-budget:t11":"node scripts/check-t11-any-budget.mjs","check:docs-sync":"node scripts/check-docs-sync.mjs","typecheck:core":"tsc --pretty false -p tsconfig.typecheck-core.json","typecheck:noimplicit:core":"tsc --pretty false -p tsconfig.typecheck-noimplicit-core.json","test:integration":"node --import tsx/esm --test tests/integration/*.test.mjs","test:e2e":"node scripts/run-playwright-tests.mjs test tests/e2e/*.spec.ts","test:protocols:e2e":"node scripts/run-protocol-clients-tests.mjs","test:vitest":"vitest run open-sse/mcp-server/__tests__/*.test.ts open-sse/services/autoCombo/__tests__/*.test.ts","test:ecosystem":"node scripts/run-ecosystem-tests.mjs","test:coverage":"npx c8 --exclude=open-sse --check-coverage --lines 50 --functions 50 --branches 50 node --import tsx/esm --test tests/unit/*.test.mjs","test:all":"npm run test:unit && npm run test:vitest && npm run test:ecosystem && npm run test:e2e",check:"npm run lint && npm run test",prepublishOnly:"npm run build:cli",postinstall:"node scripts/postinstall.mjs",prepare:"husky","system-info":"node scripts/system-info.mjs"},dependencies:{"@lobehub/icons":"^5.0.1","@modelcontextprotocol/sdk":"^1.27.1","@monaco-editor/react":"^4.7.0","@swc/helpers":"0.5.19",bcryptjs:"^3.0.3","better-sqlite3":"^12.6.2",bottleneck:"^2.19.5",dompurify:"^3.3.2",express:"^5.2.1","fetch-socks":"^1.3.2","http-proxy-middleware":"^3.0.5","https-proxy-agent":"^8.0.0",jose:"^6.1.3",keytar:"^7.9.0",lowdb:"^7.0.1","monaco-editor":"^0.55.1",next:"^16.0.10","next-intl":"^4.8.3","node-machine-id":"^1.1.12",open:"^11.0.0",ora:"^9.1.0",pino:"^10.3.1","pino-pretty":"^13.1.3",react:"19.2.4","react-dom":"19.2.4",recharts:"^3.7.0",selfsigned:"^5.5.0",tsx:"^4.21.0",undici:"^7.19.2",uuid:"^13.0.0","wreq-js":"^2.0.1",zod:"^4.3.6",zustand:"^5.0.10"},devDependencies:{"@playwright/test":"^1.58.2","@tailwindcss/postcss":"^4.1.18","@types/bcryptjs":"^3.0.0","@types/better-sqlite3":"^7.6.13","@types/keytar":"^4.4.0","@types/node":"^25.2.3","@types/react":"^19.2.14","@types/react-dom":"^19.2.3",concurrently:"^9.2.1","cross-env":"^10.1.0",eslint:"^9.39.2","eslint-config-next":"^16.0.10",husky:"^9.1.7","lint-staged":"^16.2.7",prettier:"^3.8.1",tailwindcss:"^4",typescript:"^5.9.3","typescript-eslint":"^8.56.0",vitest:"^4.0.18","wait-on":"^9.0.4"},"lint-staged":{"*.{js,jsx,ts,tsx,mjs}":["prettier --write","eslint --fix --no-error-on-unmatched-pattern"],"*.{json,md,yml,yaml,css}":["prettier --write"]},pnpm:{onlyBuiltDependencies:["@parcel/watcher","@swc/core","better-sqlite3","esbuild","omniroute","sharp"]},overrides:{dompurify:"^3.3.2"}})},175696,e=>{"use strict";var t=e.i(861745),s=e.i(843476);function n({locale:e,...n}){if(!e)throw Error(void 0);return(0,s.jsx)(t.IntlProvider,{locale:e,...n})}e.s(["default",()=>n])}]);
package/app/CHANGELOG.md CHANGED
@@ -4,6 +4,39 @@
4
4
 
5
5
  ---
6
6
 
7
+ ## [3.0.9] — 2026-03-26
8
+
9
+ ### 🐛 Bug Fixes
10
+
11
+ - **NaN tokens in Claude Code / client responses (#617):**
12
+ - `sanitizeUsage()` now cross-maps `input_tokens`→`prompt_tokens` and `output_tokens`→`completion_tokens` before the whitelist filter, fixing responses showing NaN/0 token counts when providers return Claude-style usage field names
13
+
14
+ ### 🔒 Security
15
+
16
+ - Updated `yaml` package to fix stack overflow vulnerability (GHSA-48c2-rrv3-qjmp)
17
+
18
+ ### 📋 Issue Triage
19
+
20
+ - Closed #613 (Codestral — resolved with Custom Provider workaround)
21
+ - Commented on #615 (OpenCode dual-endpoint — workaround provided, tracked as feature request)
22
+ - Commented on #618 (tool call visibility — requesting v3.0.9 test)
23
+ - Commented on #627 (effort level — already supported)
24
+
25
+ ---
26
+
27
+ ## [3.0.8] — 2026-03-25
28
+
29
+ ### 🐛 Bug Fixes
30
+
31
+ - **Translation Failures for OpenAI-format Providers in Claude CLI (#632):**
32
+ - Handle `reasoning_details[]` array format from StepFun/OpenRouter — converts to `reasoning_content`
33
+ - Handle `reasoning` field alias from some providers → normalized to `reasoning_content`
34
+ - Cross-map usage field names: `input_tokens`↔`prompt_tokens`, `output_tokens`↔`completion_tokens` in `filterUsageForFormat`
35
+ - Fix `extractUsage` to accept both `input_tokens`/`output_tokens` and `prompt_tokens`/`completion_tokens` as valid usage fields
36
+ - Applied to both streaming (`sanitizeStreamingChunk`, `openai-to-claude.ts` translator) and non-streaming (`sanitizeMessage`) paths
37
+
38
+ ---
39
+
7
40
  ## [3.0.7] — 2026-03-25
8
41
 
9
42
  ### 🐛 Bug Fixes
@@ -1,7 +1,7 @@
1
1
  openapi: 3.1.0
2
2
  info:
3
3
  title: OmniRoute API
4
- version: 3.0.7
4
+ version: 3.0.9
5
5
  description: |
6
6
  OmniRoute is a local-first AI API proxy router. It provides an OpenAI-compatible
7
7
  endpoint that routes requests to multiple AI providers with load balancing,
@@ -172,6 +172,44 @@ function sanitizeMessage(msg: unknown): unknown {
172
172
  sanitized.reasoning_content = msgRecord.reasoning_content;
173
173
  }
174
174
 
175
+ // Handle 'reasoning' field alias (some providers use this instead of reasoning_content)
176
+ if (
177
+ msgRecord.reasoning &&
178
+ typeof msgRecord.reasoning === "string" &&
179
+ !sanitized.reasoning_content
180
+ ) {
181
+ sanitized.reasoning_content = msgRecord.reasoning;
182
+ }
183
+
184
+ // Handle reasoning_details[] array (StepFun/OpenRouter format)
185
+ // Structure: [{ type: "reasoning.text", text: "...", format: "unknown", index: 0 }]
186
+ if (Array.isArray(msgRecord.reasoning_details) && !sanitized.reasoning_content) {
187
+ const reasoningParts: string[] = [];
188
+ for (const detail of msgRecord.reasoning_details) {
189
+ const detailObj = detail && typeof detail === "object" ? (detail as JsonRecord) : null;
190
+ if (!detailObj) continue;
191
+ const detailType = typeof detailObj.type === "string" ? detailObj.type : "";
192
+ const detailText =
193
+ typeof detailObj.text === "string"
194
+ ? detailObj.text
195
+ : typeof detailObj.content === "string"
196
+ ? detailObj.content
197
+ : "";
198
+ if (
199
+ detailText &&
200
+ (detailType === "reasoning" ||
201
+ detailType === "reasoning.text" ||
202
+ detailType === "thinking" ||
203
+ detailType === "")
204
+ ) {
205
+ reasoningParts.push(detailText);
206
+ }
207
+ }
208
+ if (reasoningParts.length > 0) {
209
+ sanitized.reasoning_content = reasoningParts.join("");
210
+ }
211
+ }
212
+
175
213
  // Preserve tool_calls
176
214
  if (msgRecord.tool_calls) {
177
215
  sanitized.tool_calls = msgRecord.tool_calls;
@@ -193,6 +231,17 @@ function sanitizeUsage(usage: unknown): unknown {
193
231
  if (!usageRecord) return usage;
194
232
 
195
233
  const sanitized: JsonRecord = {};
234
+
235
+ // Cross-map Claude-style → OpenAI-style field names.
236
+ // Some providers return input_tokens/output_tokens instead of prompt_tokens/completion_tokens.
237
+ // Without this mapping, the whitelist filter below strips them, resulting in NaN/0 tokens (#617).
238
+ if (usageRecord.input_tokens !== undefined && usageRecord.prompt_tokens === undefined) {
239
+ usageRecord.prompt_tokens = usageRecord.input_tokens;
240
+ }
241
+ if (usageRecord.output_tokens !== undefined && usageRecord.completion_tokens === undefined) {
242
+ usageRecord.completion_tokens = usageRecord.output_tokens;
243
+ }
244
+
196
245
  for (const key of ALLOWED_USAGE_FIELDS) {
197
246
  if (usageRecord[key] !== undefined) {
198
247
  sanitized[key] = usageRecord[key];
@@ -258,6 +307,26 @@ export function sanitizeStreamingChunk(parsed: unknown): unknown {
258
307
  if (deltaRecord.content !== undefined) delta.content = deltaRecord.content;
259
308
  if (deltaRecord.reasoning_content !== undefined) {
260
309
  delta.reasoning_content = deltaRecord.reasoning_content;
310
+ } else if (typeof deltaRecord.reasoning === "string" && deltaRecord.reasoning) {
311
+ // Alias: some providers use 'reasoning' instead of 'reasoning_content'
312
+ delta.reasoning_content = deltaRecord.reasoning;
313
+ } else if (Array.isArray(deltaRecord.reasoning_details)) {
314
+ // StepFun/OpenRouter: reasoning_details[{type:"reasoning.text", text:"..."}]
315
+ const parts: string[] = [];
316
+ for (const detail of deltaRecord.reasoning_details) {
317
+ const d = detail && typeof detail === "object" ? (detail as JsonRecord) : null;
318
+ if (!d) continue;
319
+ const text =
320
+ typeof d.text === "string"
321
+ ? d.text
322
+ : typeof d.content === "string"
323
+ ? d.content
324
+ : "";
325
+ if (text) parts.push(text);
326
+ }
327
+ if (parts.length > 0) {
328
+ delta.reasoning_content = parts.join("");
329
+ }
261
330
  }
262
331
  if (deltaRecord.tool_calls !== undefined) delta.tool_calls = deltaRecord.tool_calls;
263
332
  if (deltaRecord.function_call !== undefined)
@@ -93,7 +93,18 @@ export function openaiToClaudeResponse(chunk, state) {
93
93
  }
94
94
 
95
95
  // Handle reasoning_content (thinking) - GLM, DeepSeek, etc.
96
- const reasoningContent = delta?.reasoning_content || delta?.reasoning;
96
+ // Also supports 'reasoning' field alias and reasoning_details[] (StepFun/OpenRouter)
97
+ let reasoningContent = delta?.reasoning_content || delta?.reasoning;
98
+ if (!reasoningContent && Array.isArray(delta?.reasoning_details)) {
99
+ const parts: string[] = [];
100
+ for (const detail of delta.reasoning_details) {
101
+ if (detail && typeof detail === "object") {
102
+ const text = detail.text || detail.content;
103
+ if (typeof text === "string" && text) parts.push(text);
104
+ }
105
+ }
106
+ if (parts.length > 0) reasoningContent = parts.join("");
107
+ }
97
108
  if (reasoningContent) {
98
109
  stopTextBlock(state, results);
99
110
 
@@ -66,12 +66,47 @@ export function addBufferToUsage(usage) {
66
66
  export function filterUsageForFormat(usage, targetFormat) {
67
67
  if (!usage || typeof usage !== "object") return usage;
68
68
 
69
+ // Cross-map between Claude-style and OpenAI-style field names before filtering.
70
+ // Some providers return input_tokens/output_tokens even when using OpenAI format.
71
+ const convertedUsage = { ...usage };
72
+ if (targetFormat === FORMATS.CLAUDE || targetFormat === FORMATS.OPENAI_RESPONSES) {
73
+ // OpenAI → Claude: prompt_tokens → input_tokens
74
+ if (convertedUsage.prompt_tokens !== undefined && convertedUsage.input_tokens === undefined) {
75
+ convertedUsage.input_tokens = convertedUsage.prompt_tokens;
76
+ }
77
+ if (
78
+ convertedUsage.completion_tokens !== undefined &&
79
+ convertedUsage.output_tokens === undefined
80
+ ) {
81
+ convertedUsage.output_tokens = convertedUsage.completion_tokens;
82
+ }
83
+ } else {
84
+ // Claude → OpenAI: input_tokens → prompt_tokens
85
+ if (convertedUsage.input_tokens !== undefined && convertedUsage.prompt_tokens === undefined) {
86
+ convertedUsage.prompt_tokens = convertedUsage.input_tokens;
87
+ }
88
+ if (
89
+ convertedUsage.output_tokens !== undefined &&
90
+ convertedUsage.completion_tokens === undefined
91
+ ) {
92
+ convertedUsage.completion_tokens = convertedUsage.output_tokens;
93
+ }
94
+ // Ensure total_tokens is set
95
+ if (
96
+ convertedUsage.total_tokens === undefined &&
97
+ convertedUsage.prompt_tokens !== undefined &&
98
+ convertedUsage.completion_tokens !== undefined
99
+ ) {
100
+ convertedUsage.total_tokens = convertedUsage.prompt_tokens + convertedUsage.completion_tokens;
101
+ }
102
+ }
103
+
69
104
  // Helper to pick only defined fields from usage
70
105
  const pickFields = (fields) => {
71
106
  const filtered = {};
72
107
  for (const field of fields) {
73
- if (usage[field] !== undefined) {
74
- filtered[field] = usage[field];
108
+ if (convertedUsage[field] !== undefined) {
109
+ filtered[field] = convertedUsage[field];
75
110
  }
76
111
  }
77
112
  return filtered;
@@ -230,10 +265,14 @@ export function extractUsage(chunk) {
230
265
  }
231
266
 
232
267
  // OpenAI format
233
- if (chunk.usage && typeof chunk.usage === "object" && chunk.usage.prompt_tokens !== undefined) {
268
+ if (
269
+ chunk.usage &&
270
+ typeof chunk.usage === "object" &&
271
+ (chunk.usage.prompt_tokens !== undefined || chunk.usage.input_tokens !== undefined)
272
+ ) {
234
273
  return normalizeUsage({
235
- prompt_tokens: chunk.usage.prompt_tokens,
236
- completion_tokens: chunk.usage.completion_tokens || 0,
274
+ prompt_tokens: chunk.usage.prompt_tokens ?? chunk.usage.input_tokens ?? 0,
275
+ completion_tokens: chunk.usage.completion_tokens ?? chunk.usage.output_tokens ?? 0,
237
276
  cached_tokens: chunk.usage.prompt_tokens_details?.cached_tokens,
238
277
  reasoning_tokens: chunk.usage.completion_tokens_details?.reasoning_tokens,
239
278
  });