@yina-npm/openrouterx 0.4.24 → 0.4.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/.next/BUILD_ID +1 -1
- package/app/.next/app-path-routes-manifest.json +1 -1
- package/app/.next/build-manifest.json +2 -2
- package/app/.next/server/app/(dashboard)/dashboard/admin/keys/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/admin/users/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/proxy-pools/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/(dashboard)/dashboard/user/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_global-error.html +1 -1
- package/app/.next/server/app/_global-error.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_not-found.html +1 -1
- package/app/.next/server/app/_not-found.rsc +4 -4
- package/app/.next/server/app/_not-found.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/_not-found.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/api/models/route.js +1 -1
- package/app/.next/server/app/api/oauth/[provider]/[action]/route.js +2 -2
- package/app/.next/server/app/api/oauth/[provider]/[action]/route.js.nft.json +1 -1
- package/app/.next/server/app/api/providers/route.js +1 -1
- package/app/.next/server/app/api/translator/console-logs/route.js +1 -1
- package/app/.next/server/app/api/translator/console-logs/stream/route.js +1 -1
- package/app/.next/server/app/api/version/route.js +1 -1
- package/app/.next/server/app/api/version/update/route.js +1 -1
- package/app/.next/server/app/callback/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/callback.html +1 -1
- package/app/.next/server/app/callback.rsc +4 -4
- package/app/.next/server/app/callback.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/callback.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/callback.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/callback.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/callback.segments/callback/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/callback.segments/callback.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.html +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.rsc +4 -4
- package/app/.next/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/dashboard/settings/pricing.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard/settings.segment.rsc +1 -1
- package/app/.next/server/app/dashboard/settings/pricing.segments/dashboard.segment.rsc +1 -1
- package/app/.next/server/app/index.html +1 -1
- package/app/.next/server/app/index.rsc +4 -4
- package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/index.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/index.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/landing.html +1 -1
- package/app/.next/server/app/landing.rsc +4 -4
- package/app/.next/server/app/landing.segments/_full.segment.rsc +4 -4
- package/app/.next/server/app/landing.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/landing.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/landing.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/landing.segments/landing/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/landing.segments/landing.segment.rsc +1 -1
- package/app/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/login.html +1 -1
- package/app/.next/server/app/login.rsc +5 -5
- package/app/.next/server/app/login.segments/_full.segment.rsc +5 -5
- package/app/.next/server/app/login.segments/_head.segment.rsc +1 -1
- package/app/.next/server/app/login.segments/_index.segment.rsc +4 -4
- package/app/.next/server/app/login.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/login.segments/login/__PAGE__.segment.rsc +2 -2
- package/app/.next/server/app/login.segments/login.segment.rsc +1 -1
- package/app/.next/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app-paths-manifest.json +1 -1
- package/app/.next/server/chunks/2549.js +1 -1
- package/app/.next/server/chunks/3110.js +1 -1
- package/app/.next/server/chunks/4122.js +1 -1
- package/app/.next/server/chunks/4664.js +1 -1
- package/app/.next/server/chunks/7595.js +1 -1
- package/app/.next/server/chunks/7828.js +1 -1
- package/app/.next/server/chunks/8590.js +1 -1
- package/app/.next/server/middleware-build-manifest.js +1 -1
- package/app/.next/server/pages/404.html +1 -1
- package/app/.next/server/pages/500.html +1 -1
- package/app/.next/static/chunks/{1321-e48fd14f5bef6d7a.js → 1321-d98e54ebc0972392.js} +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-39ab11dad9bb6b89.js +1 -0
- package/app/.next/static/css/dcb19ed9cc4c0c31.css +1 -0
- package/app/package.json +1 -1
- package/package.json +1 -1
- package/app/.next/static/chunks/app/(dashboard)/dashboard/providers/[id]/page-0dc79ccb25aab919.js +0 -1
- package/app/.next/static/css/d726e4e5a2cfbfd1.css +0 -1
- /package/app/.next/static/{SQn85l_D0P4BshNJQkGiZ → 8lL2B4zuUt2JCMuDcfoON}/_buildManifest.js +0 -0
- /package/app/.next/static/{SQn85l_D0P4BshNJQkGiZ → 8lL2B4zuUt2JCMuDcfoON}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.id=2549,exports.ids=[2549],exports.modules={12557:(a,b,c)=>{c.d(b,{Bl:()=>j,Qo:()=>f,S5:()=>l,hk:()=>e,kJ:()=>k});var d=c(3662);function e(a,b,c=0){let f=b?("string"==typeof b?b:JSON.stringify(b)).toLowerCase():"";for(let b of d.t2)if(b.text&&f&&f.includes(b.text)||b.status&&b.status===a){if(b.backoff){let a=Math.min(c+1,d.EQ.maxLevel);return{shouldFallback:!0,cooldownMs:function(a=0){let b=Math.max(0,a-1);return Math.min(d.EQ.base*Math.pow(2,b),d.EQ.max)}(a),newBackoffLevel:a}}return{shouldFallback:!0,cooldownMs:b.cooldownMs}}return{shouldFallback:!0,cooldownMs:d.wf}}function f(a){if(!a)return"";let b=new Date(a).getTime()-Date.now();if(b<=0)return"reset after 0s";let c=Math.ceil(b/1e3),d=Math.floor(c/3600),e=Math.floor(c%3600/60),f=c%60,g=[];return d>0&&g.push(`${d}h`),e>0&&g.push(`${e}m`),(f>0||0===g.length)&&g.push(`${f}s`),`reset after ${g.join(" ")}`}let g="modelLock_",h=`${g}__all`;function i(a){return a?`${g}${a}`:h}function j(a,b){let c=a[i(b)]||a[h];return!!c&&new Date(c).getTime()>Date.now()}function k(a){if(!a)return null;let b=null,c=Date.now();for(let[d,e]of Object.entries(a)){if(!d.startsWith(g)||!e)continue;let a=new Date(e).getTime();a<=c||(!b||a<b)&&(b=a)}return b?new Date(b).toISOString():null}function l(a,b){return{[i(a)]:new Date(Date.now()+b).toISOString()}}},13808:(a,b,c)=>{c.d(b,{lz:()=>f});var d=c(55511),e=c.n(d);function f(){let a=e().randomBytes(32).toString("base64url"),b=e().createHash("sha256").update(a).digest("base64url");return{codeVerifier:a,codeChallenge:b,state:e().randomBytes(32).toString("base64url")}}},43659:(a,b,c)=>{c.d(b,{A1:()=>g,lR:()=>i,wO:()=>h,yj:()=>e,zL:()=>f});var d=c(3662);function e(a,b){let c;return new Response(JSON.stringify((c=d.LY[a]||(a>=500?{type:"server_error",code:"internal_server_error"}:{type:"invalid_request_error",code:""}),{error:{message:b||d.O[a]||"An error occurred",type:c.type,code:c.code}})),{status:a,headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}})}async function f(a,b=null){let c="";try{c=await a.text()}catch{c=""}if(b&&"function"==typeof b.parseError)try{let e=b.parseError(a,c);if(e&&"object"==typeof e){let b=e.message||d.O[a.status]||`Upstream error: ${a.status}`;return{statusCode:e.status||a.status,message:b,resetsAtMs:e.resetsAtMs}}}catch{}let e="";try{let a=JSON.parse(c);e=a.error?.message||a.message||a.error||c}catch{e=c}let g=("string"==typeof e?e:JSON.stringify(e))||d.O[a.status]||`Upstream error: ${a.status}`;return{statusCode:a.status,message:g}}function g(a,b,c){return{success:!1,status:a,error:b,resetsAtMs:c,response:e(a,b)}}function h(a,b,c,d){let e=Math.max(Math.ceil((new Date(c).getTime()-Date.now())/1e3),1);return new Response(JSON.stringify({error:{message:`${b} (${d})`}}),{status:a,headers:{"Content-Type":"application/json","Retry-After":String(e)}})}function i(a,b,c,d){let e=d||a.code||"FETCH_FAILED",f=a.message||"Unknown error",g=a.cause?.code,h=a.cause?.message,i=g||h?` (cause: ${[g,h].filter(Boolean).join(": ")})`:"";return`[${e}]: ${f}${i}`}},74177:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{PY:()=>p,Re:()=>n,Su:()=>o,exchangeTokens:()=>m,kP:()=>l,sO:()=>k});var e=c(48895),f=c(13808),g=c(92990),h=a([e]);function i(a){try{if(!a||"string"!=typeof a)return null;let b=a.split(".");if(3!==b.length)return null;let c=b[1].replace(/-/g,"+").replace(/_/g,"/"),d=(4-c.length%4)%4,e=c+"=".repeat(d);return JSON.parse(Buffer.from(e,"base64").toString("utf8"))}catch{return null}}function j(a){let b=i(a);if(!b)return{};let c=b["https://api.openai.com/auth"]||{};return{email:b.email,chatgptAccountId:c.chatgpt_account_id,chatgptPlanType:c.chatgpt_plan_type}}e=(h.then?(await h)():h)[0];let q={claude:{config:g.OV,flowType:"authorization_code_pkce",buildAuthUrl:(a,b,c,d)=>{let e=new URLSearchParams({code:"true",client_id:a.clientId,response_type:"code",redirect_uri:b,scope:a.scopes.join(" "),code_challenge:d,code_challenge_method:a.codeChallengeMethod,state:c});return`${a.authorizeUrl}?${e.toString()}`},exchangeToken:async(a,b,c,d,e)=>{let f=b,g="";if(f.includes("#")){let a=f.split("#");f=a[0],g=a[1]||""}let h=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({code:f,state:g||e,grant_type:"authorization_code",client_id:a.clientId,redirect_uri:c,code_verifier:d})});if(!h.ok){let a=await h.text();throw Error(`Token exchange failed: ${a}`)}return await h.json()},mapTokens:a=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,scope:a.scope})},codex:{config:g.DI,flowType:"authorization_code_pkce",fixedPort:1455,callbackPath:"/auth/callback",buildAuthUrl:(a,b,c,d)=>{let e={response_type:"code",client_id:a.clientId,redirect_uri:b,scope:a.scope,code_challenge:d,code_challenge_method:a.codeChallengeMethod,...a.extraParams,state:c},f=Object.entries(e).map(([a,b])=>`${a}=${encodeURIComponent(b)}`).join("&");return`${a.authorizeUrl}?${f}`},exchangeToken:async(a,b,c,d)=>{let e=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({grant_type:"authorization_code",client_id:a.clientId,code:b,redirect_uri:c,code_verifier:d})});if(!e.ok){let a=await e.text();throw Error(`Token exchange failed: ${a}`)}return await e.json()},mapTokens:a=>{let b=j(a.id_token),c={accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in};return b.email&&(c.email=b.email),(b.chatgptAccountId||b.chatgptPlanType)&&(c.providerSpecificData={chatgptAccountId:b.chatgptAccountId,chatgptPlanType:b.chatgptPlanType}),c}},"gemini-cli":{config:g.LT,flowType:"authorization_code",buildAuthUrl:(a,b,c)=>{let d=new URLSearchParams({client_id:a.clientId,response_type:"code",redirect_uri:b,scope:a.scopes.join(" "),state:c,access_type:"offline",prompt:"consent"});return`${a.authorizeUrl}?${d.toString()}`},exchangeToken:async(a,b,c)=>{let d=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({grant_type:"authorization_code",client_id:a.clientId,client_secret:a.clientSecret,code:b,redirect_uri:c})});if(!d.ok){let a=await d.text();throw Error(`Token exchange failed: ${a}`)}return await d.json()},postExchange:async a=>{let b=await fetch(`${g.LT.userInfoUrl}?alt=json`,{headers:{Authorization:`Bearer ${a.access_token}`}}),c=b.ok?await b.json():{},d="";try{let b=await fetch("https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist",{method:"POST",headers:{Authorization:`Bearer ${a.access_token}`,"Content-Type":"application/json"},body:JSON.stringify({metadata:getOAuthClientMetadata(),mode:1})});if(b.ok){let a=await b.json();d=a.cloudaicompanionProject?.id||a.cloudaicompanionProject||""}}catch(a){console.log("Failed to fetch project ID:",a)}return{userInfo:c,projectId:d}},mapTokens:(a,b)=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,scope:a.scope,email:b?.userInfo?.email,projectId:b?.projectId})},antigravity:{config:g.YT,flowType:"authorization_code",buildAuthUrl:(a,b,c)=>{let d=new URLSearchParams({client_id:a.clientId,response_type:"code",redirect_uri:b,scope:a.scopes.join(" "),state:c,access_type:"offline",prompt:"consent"});return`${a.authorizeUrl}?${d.toString()}`},exchangeToken:async(a,b,c)=>{let d=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({grant_type:"authorization_code",client_id:a.clientId,client_secret:a.clientSecret,code:b,redirect_uri:c})});if(!d.ok){let a=await d.text();throw Error(`Token exchange failed: ${a}`)}return await d.json()},postExchange:async a=>{let b={Authorization:`Bearer ${a.access_token}`,"Content-Type":"application/json","User-Agent":g.YT.loadCodeAssistUserAgent,"X-Goog-Api-Client":g.YT.loadCodeAssistApiClient,"Client-Metadata":g.YT.loadCodeAssistClientMetadata,"x-request-source":"local"},c={ideType:"IDE_UNSPECIFIED",platform:"PLATFORM_UNSPECIFIED",pluginType:"GEMINI"},d=await fetch(`${g.YT.userInfoUrl}?alt=json`,{headers:{Authorization:`Bearer ${a.access_token}`,"x-request-source":"local"}}),e=d.ok?await d.json():{},f="",h="legacy-tier";try{let a=await fetch(g.YT.loadCodeAssistEndpoint,{method:"POST",headers:b,body:JSON.stringify({metadata:c})});if(a.ok){let b=await a.json();if(f=b.cloudaicompanionProject?.id||b.cloudaicompanionProject||"",Array.isArray(b.allowedTiers)){for(let a of b.allowedTiers)if(a.isDefault&&a.id){h=a.id.trim();break}}}}catch(a){console.log("Failed to load code assist:",a)}return f&&(async()=>{for(let a=0;a<10;a++){try{let a=await fetch(g.YT.onboardUserEndpoint,{method:"POST",headers:b,body:JSON.stringify({tierId:h,metadata:c})});if(a.ok){let b=await a.json();if(!0===b.done)break}}catch(a){break}await new Promise(a=>setTimeout(a,5e3))}})().catch(()=>{}),{userInfo:e,projectId:f}},mapTokens:(a,b)=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,scope:a.scope,email:b?.userInfo?.email,projectId:b?.projectId})},iflow:{config:g.ZL,flowType:"authorization_code",buildAuthUrl:(a,b,c)=>{let d=new URLSearchParams({loginMethod:a.extraParams.loginMethod,type:a.extraParams.type,redirect:b,state:c,client_id:a.clientId});return`${a.authorizeUrl}?${d.toString()}`},exchangeToken:async(a,b,c)=>{let d=Buffer.from(`${a.clientId}:${a.clientSecret}`).toString("base64"),e=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json",Authorization:`Basic ${d}`},body:new URLSearchParams({grant_type:"authorization_code",code:b,redirect_uri:c,client_id:a.clientId,client_secret:a.clientSecret})});if(!e.ok){let a=await e.text();throw Error(`Token exchange failed: ${a}`)}return await e.json()},postExchange:async a=>{let b=await fetch(`${g.ZL.userInfoUrl}?accessToken=${encodeURIComponent(a.access_token)}`,{headers:{Accept:"application/json"}});if(!b.ok){let a=await b.text();throw Error(`Failed to fetch user info: ${a}`)}let c=await b.json();if(!c.success)throw Error(`User info request failed: ${c.message||"Unknown error"}`);let d=c.data||{};if(!d.apiKey||""===d.apiKey.trim())throw Error("Empty API key returned from iFlow");if(!(d.email?.trim()||d.phone?.trim()))throw Error("Missing account email/phone in user info");return{userInfo:d}},mapTokens:(a,b)=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,apiKey:b?.userInfo?.apiKey,email:b?.userInfo?.email||b?.userInfo?.phone,displayName:b?.userInfo?.nickname||b?.userInfo?.name})},qoder:{config:g.hF,flowType:"authorization_code",buildAuthUrl:(a,b,c)=>{let d=new URLSearchParams({client_id:a.clientId,response_type:"code",redirect_uri:b,state:c});return`${a.authorizeUrl}?${d.toString()}`},exchangeToken:async(a,b,c)=>{let d=Buffer.from(`${a.clientId}:${a.clientSecret}`).toString("base64"),e=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json",Authorization:`Basic ${d}`},body:new URLSearchParams({grant_type:"authorization_code",code:b,redirect_uri:c,client_id:a.clientId,client_secret:a.clientSecret})});if(!e.ok){let a=await e.text();throw Error(`Token exchange failed: ${a}`)}return await e.json()},postExchange:async a=>{let b=await fetch(`${g.hF.userInfoUrl}?accessToken=${encodeURIComponent(a.access_token)}`,{headers:{Accept:"application/json"}});if(!b.ok){let a=await b.text();throw Error(`Failed to fetch user info: ${a}`)}let c=await b.json();if(!c.success)throw Error(`User info request failed: ${c.message||"Unknown error"}`);let d=c.data||{};if(!d.apiKey||""===d.apiKey.trim())throw Error("Empty API key returned from Qoder");if(!(d.email?.trim()||d.phone?.trim()))throw Error("Missing account email/phone in user info");return{userInfo:d}},mapTokens:(a,b)=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,apiKey:b?.userInfo?.apiKey,email:b?.userInfo?.email||b?.userInfo?.phone,displayName:b?.userInfo?.nickname||b?.userInfo?.name})},qwen:{config:g.Hp,flowType:"device_code",requestDeviceCode:async(a,b)=>{let c=await fetch(a.deviceCodeUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({client_id:a.clientId,scope:a.scope,code_challenge:b,code_challenge_method:a.codeChallengeMethod})});if(!c.ok){let a=await c.text();throw Error(`Device code request failed: ${a}`)}return await c.json()},pollToken:async(a,b,c)=>{let d=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",client_id:a.clientId,device_code:b,code_verifier:c})});return{ok:d.ok,data:await d.json()}},mapTokens:a=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,providerSpecificData:{resourceUrl:a.resource_url}})},github:{config:g.Nu,flowType:"device_code",requestDeviceCode:async a=>{let b=await fetch(a.deviceCodeUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({client_id:a.clientId,scope:a.scopes})});if(!b.ok){let a=await b.text();throw Error(`Device code request failed: ${a}`)}return await b.json()},pollToken:async(a,b)=>{let c,d=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({client_id:a.clientId,device_code:b,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})});try{c=await d.json()}catch(b){let a=await d.text();c={error:"invalid_response",error_description:a}}return{ok:d.ok,data:c}},postExchange:async a=>{let b=await fetch(g.Nu.copilotTokenUrl,{headers:{Authorization:`Bearer ${a.access_token}`,Accept:"application/json","X-GitHub-Api-Version":g.Nu.apiVersion,"User-Agent":g.Nu.userAgent}}),c=b.ok?await b.json():{},d=await fetch(g.Nu.userInfoUrl,{headers:{Authorization:`Bearer ${a.access_token}`,Accept:"application/json","X-GitHub-Api-Version":g.Nu.apiVersion,"User-Agent":g.Nu.userAgent}}),e=d.ok?await d.json():{};return{copilotToken:c,userInfo:e}},mapTokens:(a,b)=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,providerSpecificData:{copilotToken:b?.copilotToken?.token,copilotTokenExpiresAt:b?.copilotToken?.expires_at,githubUserId:b?.userInfo?.id,githubLogin:b?.userInfo?.login,githubName:b?.userInfo?.name,githubEmail:b?.userInfo?.email}})},kiro:{config:g.Tx,flowType:"device_code",requestDeviceCode:async(a,b,c={})=>{let d=("string"==typeof c.region?c.region.trim():"")||"us-east-1",e=("string"==typeof c.startUrl?c.startUrl.trim():"")||a.startUrl,f="idc"===c.authMethod?"idc":"builder-id",g=`https://oidc.${d}.amazonaws.com/client/register`,h=`https://oidc.${d}.amazonaws.com/device_authorization`,i=await fetch(g,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({clientName:a.clientName,clientType:a.clientType,scopes:a.scopes,grantTypes:a.grantTypes,issuerUrl:a.issuerUrl})});if(!i.ok){let a=await i.text();throw Error(`Client registration failed: ${a}`)}let j=await i.json(),k=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({clientId:j.clientId,clientSecret:j.clientSecret,startUrl:e})});if(!k.ok){let a=await k.text();throw Error(`Device authorization failed: ${a}`)}let l=await k.json();return{device_code:l.deviceCode,user_code:l.userCode,verification_uri:l.verificationUri,verification_uri_complete:l.verificationUriComplete,expires_in:l.expiresIn,interval:l.interval||5,_clientId:j.clientId,_clientSecret:j.clientSecret,_region:d,_authMethod:f,_startUrl:e}},pollToken:async(a,b,c,d)=>{let e,f=d?._region||"us-east-1",g=`https://oidc.${f}.amazonaws.com/token`,h=await fetch(g,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({clientId:d?._clientId,clientSecret:d?._clientSecret,deviceCode:b,grantType:"urn:ietf:params:oauth:grant-type:device_code"})});try{e=await h.json()}catch(b){let a=await h.text();e={error:"invalid_response",error_description:a}}return e.accessToken?{ok:!0,data:{access_token:e.accessToken,refresh_token:e.refreshToken,expires_in:e.expiresIn,profile_arn:e?.profileArn||null,_clientId:d?._clientId,_clientSecret:d?._clientSecret,_region:d?._region,_authMethod:d?._authMethod,_startUrl:d?._startUrl}}:{ok:!1,data:{error:e.error||"authorization_pending",error_description:e.error_description||e.message}}},mapTokens:a=>{let b=function(a){let b=i(a);if(b)return b.email||b.preferred_username||b.sub||void 0}(a.access_token);return{accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,email:b,providerSpecificData:{profileArn:a?.profile_arn||null,clientId:a._clientId,clientSecret:a._clientSecret,region:a._region||"us-east-1",authMethod:a._authMethod||"builder-id",startUrl:a._startUrl||g.Tx.startUrl}}}},cursor:{config:g.WN,flowType:"import_token",mapTokens:a=>({accessToken:a.accessToken,refreshToken:null,expiresIn:a.expiresIn||86400,providerSpecificData:{machineId:a.machineId,authMethod:"imported"}})},"kimi-coding":{config:g.t,flowType:"device_code",requestDeviceCode:async a=>{let b=await fetch(a.deviceCodeUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({client_id:a.clientId})});if(!b.ok){let a=await b.text();throw Error(`Device code request failed: ${a}`)}let c=await b.json();return{device_code:c.device_code,user_code:c.user_code,verification_uri:c.verification_uri||"https://www.kimi.com/code/authorize_device",verification_uri_complete:c.verification_uri_complete||`https://www.kimi.com/code/authorize_device?user_code=${c.user_code}`,expires_in:c.expires_in,interval:c.interval||5}},pollToken:async(a,b)=>{let c,d=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",client_id:a.clientId,device_code:b})});try{c=await d.json()}catch(b){let a=await d.text();c={error:"invalid_response",error_description:a}}return{ok:d.ok,data:c}},mapTokens:a=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in})},kilocode:{config:g.MZ,flowType:"device_code",requestDeviceCode:async a=>{let b=await fetch(a.initiateUrl,{method:"POST",headers:{"Content-Type":"application/json"}});if(!b.ok){if(429===b.status)throw Error("Too many pending authorization requests. Please try again later.");let a=await b.text();throw Error(`Device auth initiation failed: ${a}`)}let c=await b.json();return{device_code:c.code,user_code:c.code,verification_uri:c.verificationUrl,verification_uri_complete:c.verificationUrl,expires_in:c.expiresIn||300,interval:3}},pollToken:async(a,b)=>{let c=await fetch(`${a.pollUrlBase}/${b}`);if(202===c.status)return{ok:!1,data:{error:"authorization_pending"}};if(403===c.status)return{ok:!1,data:{error:"access_denied",error_description:"Authorization denied by user"}};if(410===c.status)return{ok:!1,data:{error:"expired_token",error_description:"Authorization code expired"}};if(!c.ok)return{ok:!1,data:{error:"poll_failed",error_description:`Poll failed: ${c.status}`}};let d=await c.json();if("approved"===d.status&&d.token){let b=null;try{let c=await fetch(`${a.apiBaseUrl}/api/profile`,{headers:{Authorization:`Bearer ${d.token}`}});if(c.ok){let a=await c.json();b=a.organizations?.[0]?.id||null}}catch{}return{ok:!0,data:{access_token:d.token,_userEmail:d.userEmail,_orgId:b}}}return{ok:!1,data:{error:"authorization_pending"}}},mapTokens:a=>({accessToken:a.access_token,refreshToken:null,expiresIn:null,email:a._userEmail,...a._orgId?{providerSpecificData:{orgId:a._orgId}}:{}})},cline:{config:g.lB,flowType:"authorization_code",buildAuthUrl:(a,b)=>{let c=new URLSearchParams({client_type:"extension",callback_url:b,redirect_uri:b});return`${a.authorizeUrl}?${c.toString()}`},exchangeToken:async(a,b,c)=>{try{let a=b,c=4-a.length%4;4!==c&&(a+="=".repeat(c));let d=Buffer.from(a,"base64").toString("utf-8"),e=d.lastIndexOf("}");if(-1===e)throw Error("No JSON found in decoded code");let f=JSON.parse(d.substring(0,e+1));return{access_token:f.accessToken,refresh_token:f.refreshToken,email:f.email,firstName:f.firstName,lastName:f.lastName,expires_at:f.expiresAt}}catch(f){let d=await fetch(a.tokenExchangeUrl,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:b,client_type:"extension",redirect_uri:c})});if(!d.ok){let a=await d.text();throw Error(`Cline token exchange failed: ${a}`)}let e=await d.json();return{access_token:e.data?.accessToken||e.accessToken,refresh_token:e.data?.refreshToken||e.refreshToken,email:e.data?.userInfo?.email||"",expires_at:e.data?.expiresAt||e.expiresAt}}},mapTokens:a=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_at?Math.floor((new Date(a.expires_at).getTime()-Date.now())/1e3):3600,email:a.email,providerSpecificData:{firstName:a.firstName,lastName:a.lastName}})},gitlab:{config:g.f7,flowType:"authorization_code_pkce",buildAuthUrl:(a,b,c,d,e={})=>{let f=e.baseUrl||a.defaultBaseUrl,g=e.clientId||"",h=new URLSearchParams({client_id:g,redirect_uri:b,response_type:"code",state:c,scope:a.scope,code_challenge:d,code_challenge_method:a.codeChallengeMethod});return`${f}${a.authorizeUrlPath}?${h.toString()}`},exchangeToken:async(a,b,c,d,e,f={})=>{let g=f.baseUrl||a.defaultBaseUrl,h=f.clientId||"",i=f.clientSecret||"",j=new URLSearchParams({client_id:h,grant_type:"authorization_code",code:b,redirect_uri:c,code_verifier:d});i&&j.set("client_secret",i);let k=await fetch(`${g}${a.tokenUrlPath}`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:j.toString()});if(!k.ok)throw Error(`GitLab token exchange failed: ${await k.text()}`);let l=await k.json(),m=await fetch(`${g}${a.userInfoUrlPath}`,{headers:{Authorization:`Bearer ${l.access_token}`}}),n=m.ok?await m.json():{};return{...l,_user:n,_baseUrl:g,_clientId:h}},mapTokens:a=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,scope:a.scope,providerSpecificData:{username:a._user?.username||"",email:a._user?.email||a._user?.public_email||"",name:a._user?.name||"",baseUrl:a._baseUrl,clientId:a._clientId,authKind:"oauth"}})},codebuddy:{config:g.Nl,flowType:"device_code",requestDeviceCode:async a=>{let b=await fetch(`${a.stateUrl}?platform=${a.platform}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","User-Agent":a.userAgent,"X-Requested-With":"XMLHttpRequest","X-Domain":"copilot.tencent.com","X-No-Authorization":"true","X-No-User-Id":"true","X-Product":"SaaS"},body:"{}"});if(!b.ok)throw Error(`CodeBuddy state request failed: ${await b.text()}`);let c=await b.json();if(0!==c.code||!c.data?.state||!c.data?.authUrl)throw Error(`CodeBuddy state error: ${c.msg||"missing state/authUrl"}`);return{device_code:c.data.state,verification_uri:c.data.authUrl,user_code:"",interval:a.pollInterval/1e3,_isCodeBuddy:!0}},pollToken:async(a,b)=>{let c=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","User-Agent":a.userAgent,"X-Requested-With":"XMLHttpRequest","X-Domain":"copilot.tencent.com","X-No-Authorization":"true","X-No-User-Id":"true","X-Product":"SaaS"},body:JSON.stringify({state:b})});if(!c.ok)return{ok:!1,data:{error:"request_failed"}};let d=await c.json();return 0===d.code&&d.data?.accessToken?{ok:!0,data:{access_token:d.data.accessToken,refresh_token:d.data.refreshToken||"",token_type:d.data.tokenType||"Bearer"}}:11217===d.code?{ok:!0,data:{error:"authorization_pending"}}:{ok:!1,data:{error:d.msg||"unknown_error"}}},mapTokens:a=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:86400,providerSpecificData:{}})}};function k(a){let b=q[a];if(!b)throw Error(`Unknown provider: ${a}`);return b}function l(a,b,c){let d=k(a),{codeVerifier:e,codeChallenge:g,state:h}=(0,f.lz)();return{authUrl:"device_code"===d.flowType?null:"authorization_code_pkce"===d.flowType?d.buildAuthUrl(d.config,b,h,g,c||{}):d.buildAuthUrl(d.config,b,h,void 0,c||{}),state:h,codeVerifier:e,codeChallenge:g,redirectUri:b,flowType:d.flowType,fixedPort:d.fixedPort,callbackPath:d.callbackPath||"/callback"}}async function m(a,b,c,d,e,f){let g=k(a),h=await g.exchangeToken(g.config,b,c,d,e,f||{}),i=null;return g.postExchange&&(i=await g.postExchange(h)),g.mapTokens(h,i)}async function n(a,b,c){let d=k(a);if("device_code"!==d.flowType)throw Error(`Provider ${a} does not support device code flow`);return await d.requestDeviceCode(d.config,b,c||{})}async function o(a,b,c,d){let e=k(a);if("device_code"!==e.flowType)throw Error(`Provider ${a} does not support device code flow`);let f=await e.pollToken(e.config,b,c,d);if(f.ok)if(f.data.access_token){let a=null;return e.postExchange&&(a=await e.postExchange(f.data)),{success:!0,tokens:e.mapTokens(f.data,a)}}else if("authorization_pending"===f.data.error||"slow_down"===f.data.error)return{success:!1,error:f.data.error,errorDescription:f.data.error_description||f.data.message,pending:"authorization_pending"===f.data.error};else return{success:!1,error:f.data.error||"no_access_token",errorDescription:f.data.error_description||f.data.message||"No access token received"};return{success:!1,error:f.data.error,errorDescription:f.data.error_description}}let r=!1;async function p(){if(!r){r=!0;try{let{getProviderConnections:a,updateProviderConnection:b}=await Promise.resolve().then(c.bind(c,89718));for(let c of(await a()).filter(a=>{if("codex"!==a.provider||"oauth"!==a.authType||!a.idToken)return!1;let b=!!a.email,c=!!a.providerSpecificData?.chatgptAccountId;return!b||!c})){let a=j(c.idToken);if(!a.email&&!a.chatgptAccountId)continue;let d={};!c.email&&a.email&&(d.email=a.email),(a.chatgptAccountId||a.chatgptPlanType)&&(d.providerSpecificData={...c.providerSpecificData||{},chatgptAccountId:a.chatgptAccountId,chatgptPlanType:a.chatgptPlanType}),Object.keys(d).length&&await b(c.id,d)}}catch(a){r=!1,console.log("backfillCodexEmails failed:",a?.message||a)}}}d()}catch(a){d(a)}})},92990:(a,b,c)=>{c.d(b,{DI:()=>e,Hp:()=>g,LT:()=>f,MZ:()=>o,Nl:()=>r,Nu:()=>k,OV:()=>d,Tx:()=>l,WN:()=>m,YT:()=>j,ZL:()=>i,f7:()=>q,hF:()=>h,lB:()=>p,t:()=>n}),c(21820);let d={clientId:"9d1c250a-e61b-44d9-88ed-5944d1962f5e",authorizeUrl:"https://claude.ai/oauth/authorize",tokenUrl:"https://api.anthropic.com/v1/oauth/token",scopes:["org:create_api_key","user:profile","user:inference"],codeChallengeMethod:"S256"},e={clientId:"app_EMoamEEZ73f0CkXaXp7hrann",authorizeUrl:"https://auth.openai.com/oauth/authorize",tokenUrl:"https://auth.openai.com/oauth/token",scope:"openid profile email offline_access",codeChallengeMethod:"S256",extraParams:{id_token_add_organizations:"true",codex_cli_simplified_flow:"true",originator:"codex_cli_rs"}},f={clientId:"681255809395-oo8ft2oprdrnp9e3aqf6av3hmdib135j.apps.googleusercontent.com",clientSecret:"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",authorizeUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",userInfoUrl:"https://www.googleapis.com/oauth2/v1/userinfo",scopes:["https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/userinfo.email","https://www.googleapis.com/auth/userinfo.profile"]},g={clientId:"f0304373b74a44d2b584a3fb70ca9e56",deviceCodeUrl:"https://chat.qwen.ai/api/v1/oauth2/device/code",tokenUrl:"https://chat.qwen.ai/api/v1/oauth2/token",scope:"openid profile email model.completion",codeChallengeMethod:"S256"},h={apiBaseUrl:"https://api2.qoder.sh",deviceTokenUrl:"https://api2.qoder.sh/api/v1/deviceToken/poll",deviceRefreshUrl:"https://api2.qoder.sh/api/v1/deviceToken/refresh",refreshUrl:"https://api2.qoder.sh/api/v3/user/refresh_token",userInfoUrl:"https://api2.qoder.sh/api/v1/userinfo",statusUrl:"https://api2.qoder.sh/api/v3/user/status",loginUrl:"https://qoder.com/login"},i={clientId:"10009311001",clientSecret:"4Z3YjXycVsQvyGF1etiNlIBB4RsqSDtW",authorizeUrl:"https://iflow.cn/oauth",tokenUrl:"https://iflow.cn/oauth/token",userInfoUrl:"https://iflow.cn/api/oauth/getUserInfo",extraParams:{loginMethod:"phone",type:"phone"}},j={clientId:"1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com",clientSecret:"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",authorizeUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",userInfoUrl:"https://www.googleapis.com/oauth2/v1/userinfo",scopes:["https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/userinfo.email","https://www.googleapis.com/auth/userinfo.profile","https://www.googleapis.com/auth/cclog","https://www.googleapis.com/auth/experimentsandconfigs"],apiEndpoint:"https://cloudcode-pa.googleapis.com",apiVersion:"v1internal",loadCodeAssistEndpoint:"https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist",onboardUserEndpoint:"https://cloudcode-pa.googleapis.com/v1internal:onboardUser",loadCodeAssistUserAgent:"google-api-nodejs-client/9.15.1",loadCodeAssistApiClient:"google-cloud-sdk vscode_cloudshelleditor/0.1",loadCodeAssistClientMetadata:JSON.stringify({ideType:"IDE_UNSPECIFIED",platform:"PLATFORM_UNSPECIFIED",pluginType:"GEMINI"})},k={clientId:"Iv1.b507a08c87ecfe98",deviceCodeUrl:"https://github.com/login/device/code",tokenUrl:"https://github.com/login/oauth/access_token",userInfoUrl:"https://api.github.com/user",scopes:"read:user",apiVersion:"2022-11-28",copilotTokenUrl:"https://api.github.com/copilot_internal/v2/token",userAgent:"GitHubCopilotChat/0.26.7",editorVersion:"vscode/1.85.0",editorPluginVersion:"copilot-chat/0.26.7"},l={ssoOidcEndpoint:"https://oidc.us-east-1.amazonaws.com",registerClientUrl:"https://oidc.us-east-1.amazonaws.com/client/register",deviceAuthUrl:"https://oidc.us-east-1.amazonaws.com/device_authorization",tokenUrl:"https://oidc.us-east-1.amazonaws.com/token",startUrl:"https://view.awsapps.com/start",clientName:"kiro-oauth-client",clientType:"public",scopes:["codewhisperer:completions","codewhisperer:analysis","codewhisperer:conversations"],grantTypes:["urn:ietf:params:oauth:grant-type:device_code","refresh_token"],issuerUrl:"https://identitycenter.amazonaws.com/ssoins-722374e8c3c8e6c6",socialAuthEndpoint:"https://prod.us-east-1.auth.desktop.kiro.dev",socialLoginUrl:"https://prod.us-east-1.auth.desktop.kiro.dev/login",socialTokenUrl:"https://prod.us-east-1.auth.desktop.kiro.dev/oauth/token",socialRefreshUrl:"https://prod.us-east-1.auth.desktop.kiro.dev/refreshToken",authMethods:["builder-id","idc","google","github","import"]},m={apiEndpoint:"https://api2.cursor.sh",chatEndpoint:"/aiserver.v1.ChatService/StreamUnifiedChatWithTools",modelsEndpoint:"/aiserver.v1.AiService/GetDefaultModelNudgeData",api3Endpoint:"https://api3.cursor.sh",agentEndpoint:"https://agent.api5.cursor.sh",agentNonPrivacyEndpoint:"https://agentn.api5.cursor.sh",clientVersion:"3.1.0",clientType:"ide",tokenStoragePaths:{linux:"~/.config/Cursor/User/globalStorage/state.vscdb",macos:"/Users/<user>/Library/Application Support/Cursor/User/globalStorage/state.vscdb",windows:"%APPDATA%\\Cursor\\User\\globalStorage\\state.vscdb"},dbKeys:{accessToken:"cursorAuth/accessToken",machineId:"storage.serviceMachineId"}},n={clientId:process.env.KIMI_CODING_OAUTH_CLIENT_ID||"17e5f671-d194-4dfb-9706-5516cb48c098",deviceCodeUrl:"https://auth.kimi.com/api/oauth/device_authorization",tokenUrl:"https://auth.kimi.com/api/oauth/token"},o={apiBaseUrl:"https://api.kilo.ai",initiateUrl:"https://api.kilo.ai/api/device-auth/codes",pollUrlBase:"https://api.kilo.ai/api/device-auth/codes"},p={appBaseUrl:"https://app.cline.bot",apiBaseUrl:"https://api.cline.bot",authorizeUrl:"https://api.cline.bot/api/v1/auth/authorize",tokenExchangeUrl:"https://api.cline.bot/api/v1/auth/token",refreshUrl:"https://api.cline.bot/api/v1/auth/refresh"},q={defaultBaseUrl:"https://gitlab.com",authorizeUrlPath:"/oauth/authorize",tokenUrlPath:"/oauth/token",userInfoUrlPath:"/api/v4/user",scope:"api read_user",codeChallengeMethod:"S256"},r={baseUrl:"https://copilot.tencent.com",stateUrl:"https://copilot.tencent.com/v2/plugin/auth/state",tokenUrl:"https://copilot.tencent.com/v2/plugin/auth/token",refreshUrl:"https://copilot.tencent.com/v2/plugin/auth/token/refresh",userAgent:"CLI/2.63.2 CodeBuddy/2.63.2",platform:"CLI",pollInterval:5e3}}};
|
|
1
|
+
"use strict";exports.id=2549,exports.ids=[2549],exports.modules={12557:(a,b,c)=>{c.d(b,{Bl:()=>j,Qo:()=>f,S5:()=>l,hk:()=>e,kJ:()=>k});var d=c(3662);function e(a,b,c=0){let f=b?("string"==typeof b?b:JSON.stringify(b)).toLowerCase():"";for(let b of d.t2)if(b.text&&f&&f.includes(b.text)||b.status&&b.status===a){if(b.backoff){let a=Math.min(c+1,d.EQ.maxLevel);return{shouldFallback:!0,cooldownMs:function(a=0){let b=Math.max(0,a-1);return Math.min(d.EQ.base*Math.pow(2,b),d.EQ.max)}(a),newBackoffLevel:a}}return{shouldFallback:!0,cooldownMs:b.cooldownMs}}return{shouldFallback:!0,cooldownMs:d.wf}}function f(a){if(!a)return"";let b=new Date(a).getTime()-Date.now();if(b<=0)return"reset after 0s";let c=Math.ceil(b/1e3),d=Math.floor(c/3600),e=Math.floor(c%3600/60),f=c%60,g=[];return d>0&&g.push(`${d}h`),e>0&&g.push(`${e}m`),(f>0||0===g.length)&&g.push(`${f}s`),`reset after ${g.join(" ")}`}let g="modelLock_",h=`${g}__all`;function i(a){return a?`${g}${a}`:h}function j(a,b){let c=a[i(b)]||a[h];return!!c&&new Date(c).getTime()>Date.now()}function k(a){if(!a)return null;let b=null,c=Date.now();for(let[d,e]of Object.entries(a)){if(!d.startsWith(g)||!e)continue;let a=new Date(e).getTime();a<=c||(!b||a<b)&&(b=a)}return b?new Date(b).toISOString():null}function l(a,b){return{[i(a)]:new Date(Date.now()+b).toISOString()}}},13808:(a,b,c)=>{c.d(b,{lz:()=>f});var d=c(55511),e=c.n(d);function f(){let a=e().randomBytes(32).toString("base64url"),b=e().createHash("sha256").update(a).digest("base64url");return{codeVerifier:a,codeChallenge:b,state:e().randomBytes(32).toString("base64url")}}},43659:(a,b,c)=>{c.d(b,{A1:()=>g,lR:()=>i,wO:()=>h,yj:()=>e,zL:()=>f});var d=c(3662);function e(a,b){let c;return new Response(JSON.stringify((c=d.LY[a]||(a>=500?{type:"server_error",code:"internal_server_error"}:{type:"invalid_request_error",code:""}),{error:{message:b||d.O[a]||"An error occurred",type:c.type,code:c.code}})),{status:a,headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}})}async function f(a,b=null){let c="";try{c=await a.text()}catch{c=""}if(b&&"function"==typeof b.parseError)try{let e=b.parseError(a,c);if(e&&"object"==typeof e){let b=e.message||d.O[a.status]||`Upstream error: ${a.status}`;return{statusCode:e.status||a.status,message:b,resetsAtMs:e.resetsAtMs}}}catch{}let e="";try{let a=JSON.parse(c);e=a.error?.message||a.message||a.error||c}catch{e=c}let g=("string"==typeof e?e:JSON.stringify(e))||d.O[a.status]||`Upstream error: ${a.status}`;return{statusCode:a.status,message:g}}function g(a,b,c){return{success:!1,status:a,error:b,resetsAtMs:c,response:e(a,b)}}function h(a,b,c,d){let e=Math.max(Math.ceil((new Date(c).getTime()-Date.now())/1e3),1);return new Response(JSON.stringify({error:{message:`${b} (${d})`}}),{status:a,headers:{"Content-Type":"application/json","Retry-After":String(e)}})}function i(a,b,c,d){let e=d||a.code||"FETCH_FAILED",f=a.message||"Unknown error",g=a.cause?.code,h=a.cause?.message,i=g||h?` (cause: ${[g,h].filter(Boolean).join(": ")})`:"";return`[${e}]: ${f}${i}`}},74177:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{PY:()=>p,Re:()=>n,Su:()=>o,YR:()=>j,exchangeTokens:()=>m,kP:()=>l,sO:()=>k});var e=c(48895),f=c(13808),g=c(92990),h=a([e]);function i(a){try{if(!a||"string"!=typeof a)return null;let b=a.split(".");if(3!==b.length)return null;let c=b[1].replace(/-/g,"+").replace(/_/g,"/"),d=(4-c.length%4)%4,e=c+"=".repeat(d);return JSON.parse(Buffer.from(e,"base64").toString("utf8"))}catch{return null}}function j(a){let b=i(a);if(!b)return{};let c=b["https://api.openai.com/auth"]||{};return{email:b.email,chatgptAccountId:c.chatgpt_account_id,chatgptPlanType:c.chatgpt_plan_type}}e=(h.then?(await h)():h)[0];let q={claude:{config:g.OV,flowType:"authorization_code_pkce",buildAuthUrl:(a,b,c,d)=>{let e=new URLSearchParams({code:"true",client_id:a.clientId,response_type:"code",redirect_uri:b,scope:a.scopes.join(" "),code_challenge:d,code_challenge_method:a.codeChallengeMethod,state:c});return`${a.authorizeUrl}?${e.toString()}`},exchangeToken:async(a,b,c,d,e)=>{let f=b,g="";if(f.includes("#")){let a=f.split("#");f=a[0],g=a[1]||""}let h=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({code:f,state:g||e,grant_type:"authorization_code",client_id:a.clientId,redirect_uri:c,code_verifier:d})});if(!h.ok){let a=await h.text();throw Error(`Token exchange failed: ${a}`)}return await h.json()},mapTokens:a=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,scope:a.scope})},codex:{config:g.DI,flowType:"authorization_code_pkce",fixedPort:1455,callbackPath:"/auth/callback",buildAuthUrl:(a,b,c,d)=>{let e={response_type:"code",client_id:a.clientId,redirect_uri:b,scope:a.scope,code_challenge:d,code_challenge_method:a.codeChallengeMethod,...a.extraParams,state:c},f=Object.entries(e).map(([a,b])=>`${a}=${encodeURIComponent(b)}`).join("&");return`${a.authorizeUrl}?${f}`},exchangeToken:async(a,b,c,d)=>{let e=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({grant_type:"authorization_code",client_id:a.clientId,code:b,redirect_uri:c,code_verifier:d})});if(!e.ok){let a=await e.text();throw Error(`Token exchange failed: ${a}`)}return await e.json()},mapTokens:a=>{let b=j(a.id_token),c={accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in};return b.email&&(c.email=b.email),(b.chatgptAccountId||b.chatgptPlanType)&&(c.providerSpecificData={chatgptAccountId:b.chatgptAccountId,chatgptPlanType:b.chatgptPlanType}),c}},"gemini-cli":{config:g.LT,flowType:"authorization_code",buildAuthUrl:(a,b,c)=>{let d=new URLSearchParams({client_id:a.clientId,response_type:"code",redirect_uri:b,scope:a.scopes.join(" "),state:c,access_type:"offline",prompt:"consent"});return`${a.authorizeUrl}?${d.toString()}`},exchangeToken:async(a,b,c)=>{let d=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({grant_type:"authorization_code",client_id:a.clientId,client_secret:a.clientSecret,code:b,redirect_uri:c})});if(!d.ok){let a=await d.text();throw Error(`Token exchange failed: ${a}`)}return await d.json()},postExchange:async a=>{let b=await fetch(`${g.LT.userInfoUrl}?alt=json`,{headers:{Authorization:`Bearer ${a.access_token}`}}),c=b.ok?await b.json():{},d="";try{let b=await fetch("https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist",{method:"POST",headers:{Authorization:`Bearer ${a.access_token}`,"Content-Type":"application/json"},body:JSON.stringify({metadata:getOAuthClientMetadata(),mode:1})});if(b.ok){let a=await b.json();d=a.cloudaicompanionProject?.id||a.cloudaicompanionProject||""}}catch(a){console.log("Failed to fetch project ID:",a)}return{userInfo:c,projectId:d}},mapTokens:(a,b)=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,scope:a.scope,email:b?.userInfo?.email,projectId:b?.projectId})},antigravity:{config:g.YT,flowType:"authorization_code",buildAuthUrl:(a,b,c)=>{let d=new URLSearchParams({client_id:a.clientId,response_type:"code",redirect_uri:b,scope:a.scopes.join(" "),state:c,access_type:"offline",prompt:"consent"});return`${a.authorizeUrl}?${d.toString()}`},exchangeToken:async(a,b,c)=>{let d=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({grant_type:"authorization_code",client_id:a.clientId,client_secret:a.clientSecret,code:b,redirect_uri:c})});if(!d.ok){let a=await d.text();throw Error(`Token exchange failed: ${a}`)}return await d.json()},postExchange:async a=>{let b={Authorization:`Bearer ${a.access_token}`,"Content-Type":"application/json","User-Agent":g.YT.loadCodeAssistUserAgent,"X-Goog-Api-Client":g.YT.loadCodeAssistApiClient,"Client-Metadata":g.YT.loadCodeAssistClientMetadata,"x-request-source":"local"},c={ideType:"IDE_UNSPECIFIED",platform:"PLATFORM_UNSPECIFIED",pluginType:"GEMINI"},d=await fetch(`${g.YT.userInfoUrl}?alt=json`,{headers:{Authorization:`Bearer ${a.access_token}`,"x-request-source":"local"}}),e=d.ok?await d.json():{},f="",h="legacy-tier";try{let a=await fetch(g.YT.loadCodeAssistEndpoint,{method:"POST",headers:b,body:JSON.stringify({metadata:c})});if(a.ok){let b=await a.json();if(f=b.cloudaicompanionProject?.id||b.cloudaicompanionProject||"",Array.isArray(b.allowedTiers)){for(let a of b.allowedTiers)if(a.isDefault&&a.id){h=a.id.trim();break}}}}catch(a){console.log("Failed to load code assist:",a)}return f&&(async()=>{for(let a=0;a<10;a++){try{let a=await fetch(g.YT.onboardUserEndpoint,{method:"POST",headers:b,body:JSON.stringify({tierId:h,metadata:c})});if(a.ok){let b=await a.json();if(!0===b.done)break}}catch(a){break}await new Promise(a=>setTimeout(a,5e3))}})().catch(()=>{}),{userInfo:e,projectId:f}},mapTokens:(a,b)=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,scope:a.scope,email:b?.userInfo?.email,projectId:b?.projectId})},iflow:{config:g.ZL,flowType:"authorization_code",buildAuthUrl:(a,b,c)=>{let d=new URLSearchParams({loginMethod:a.extraParams.loginMethod,type:a.extraParams.type,redirect:b,state:c,client_id:a.clientId});return`${a.authorizeUrl}?${d.toString()}`},exchangeToken:async(a,b,c)=>{let d=Buffer.from(`${a.clientId}:${a.clientSecret}`).toString("base64"),e=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json",Authorization:`Basic ${d}`},body:new URLSearchParams({grant_type:"authorization_code",code:b,redirect_uri:c,client_id:a.clientId,client_secret:a.clientSecret})});if(!e.ok){let a=await e.text();throw Error(`Token exchange failed: ${a}`)}return await e.json()},postExchange:async a=>{let b=await fetch(`${g.ZL.userInfoUrl}?accessToken=${encodeURIComponent(a.access_token)}`,{headers:{Accept:"application/json"}});if(!b.ok){let a=await b.text();throw Error(`Failed to fetch user info: ${a}`)}let c=await b.json();if(!c.success)throw Error(`User info request failed: ${c.message||"Unknown error"}`);let d=c.data||{};if(!d.apiKey||""===d.apiKey.trim())throw Error("Empty API key returned from iFlow");if(!(d.email?.trim()||d.phone?.trim()))throw Error("Missing account email/phone in user info");return{userInfo:d}},mapTokens:(a,b)=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,apiKey:b?.userInfo?.apiKey,email:b?.userInfo?.email||b?.userInfo?.phone,displayName:b?.userInfo?.nickname||b?.userInfo?.name})},qoder:{config:g.hF,flowType:"authorization_code",buildAuthUrl:(a,b,c)=>{let d=new URLSearchParams({client_id:a.clientId,response_type:"code",redirect_uri:b,state:c});return`${a.authorizeUrl}?${d.toString()}`},exchangeToken:async(a,b,c)=>{let d=Buffer.from(`${a.clientId}:${a.clientSecret}`).toString("base64"),e=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json",Authorization:`Basic ${d}`},body:new URLSearchParams({grant_type:"authorization_code",code:b,redirect_uri:c,client_id:a.clientId,client_secret:a.clientSecret})});if(!e.ok){let a=await e.text();throw Error(`Token exchange failed: ${a}`)}return await e.json()},postExchange:async a=>{let b=await fetch(`${g.hF.userInfoUrl}?accessToken=${encodeURIComponent(a.access_token)}`,{headers:{Accept:"application/json"}});if(!b.ok){let a=await b.text();throw Error(`Failed to fetch user info: ${a}`)}let c=await b.json();if(!c.success)throw Error(`User info request failed: ${c.message||"Unknown error"}`);let d=c.data||{};if(!d.apiKey||""===d.apiKey.trim())throw Error("Empty API key returned from Qoder");if(!(d.email?.trim()||d.phone?.trim()))throw Error("Missing account email/phone in user info");return{userInfo:d}},mapTokens:(a,b)=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,apiKey:b?.userInfo?.apiKey,email:b?.userInfo?.email||b?.userInfo?.phone,displayName:b?.userInfo?.nickname||b?.userInfo?.name})},qwen:{config:g.Hp,flowType:"device_code",requestDeviceCode:async(a,b)=>{let c=await fetch(a.deviceCodeUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({client_id:a.clientId,scope:a.scope,code_challenge:b,code_challenge_method:a.codeChallengeMethod})});if(!c.ok){let a=await c.text();throw Error(`Device code request failed: ${a}`)}return await c.json()},pollToken:async(a,b,c)=>{let d=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",client_id:a.clientId,device_code:b,code_verifier:c})});return{ok:d.ok,data:await d.json()}},mapTokens:a=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,providerSpecificData:{resourceUrl:a.resource_url}})},github:{config:g.Nu,flowType:"device_code",requestDeviceCode:async a=>{let b=await fetch(a.deviceCodeUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({client_id:a.clientId,scope:a.scopes})});if(!b.ok){let a=await b.text();throw Error(`Device code request failed: ${a}`)}return await b.json()},pollToken:async(a,b)=>{let c,d=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({client_id:a.clientId,device_code:b,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})});try{c=await d.json()}catch(b){let a=await d.text();c={error:"invalid_response",error_description:a}}return{ok:d.ok,data:c}},postExchange:async a=>{let b=await fetch(g.Nu.copilotTokenUrl,{headers:{Authorization:`Bearer ${a.access_token}`,Accept:"application/json","X-GitHub-Api-Version":g.Nu.apiVersion,"User-Agent":g.Nu.userAgent}}),c=b.ok?await b.json():{},d=await fetch(g.Nu.userInfoUrl,{headers:{Authorization:`Bearer ${a.access_token}`,Accept:"application/json","X-GitHub-Api-Version":g.Nu.apiVersion,"User-Agent":g.Nu.userAgent}}),e=d.ok?await d.json():{};return{copilotToken:c,userInfo:e}},mapTokens:(a,b)=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,providerSpecificData:{copilotToken:b?.copilotToken?.token,copilotTokenExpiresAt:b?.copilotToken?.expires_at,githubUserId:b?.userInfo?.id,githubLogin:b?.userInfo?.login,githubName:b?.userInfo?.name,githubEmail:b?.userInfo?.email}})},kiro:{config:g.Tx,flowType:"device_code",requestDeviceCode:async(a,b,c={})=>{let d=("string"==typeof c.region?c.region.trim():"")||"us-east-1",e=("string"==typeof c.startUrl?c.startUrl.trim():"")||a.startUrl,f="idc"===c.authMethod?"idc":"builder-id",g=`https://oidc.${d}.amazonaws.com/client/register`,h=`https://oidc.${d}.amazonaws.com/device_authorization`,i=await fetch(g,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({clientName:a.clientName,clientType:a.clientType,scopes:a.scopes,grantTypes:a.grantTypes,issuerUrl:a.issuerUrl})});if(!i.ok){let a=await i.text();throw Error(`Client registration failed: ${a}`)}let j=await i.json(),k=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({clientId:j.clientId,clientSecret:j.clientSecret,startUrl:e})});if(!k.ok){let a=await k.text();throw Error(`Device authorization failed: ${a}`)}let l=await k.json();return{device_code:l.deviceCode,user_code:l.userCode,verification_uri:l.verificationUri,verification_uri_complete:l.verificationUriComplete,expires_in:l.expiresIn,interval:l.interval||5,_clientId:j.clientId,_clientSecret:j.clientSecret,_region:d,_authMethod:f,_startUrl:e}},pollToken:async(a,b,c,d)=>{let e,f=d?._region||"us-east-1",g=`https://oidc.${f}.amazonaws.com/token`,h=await fetch(g,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({clientId:d?._clientId,clientSecret:d?._clientSecret,deviceCode:b,grantType:"urn:ietf:params:oauth:grant-type:device_code"})});try{e=await h.json()}catch(b){let a=await h.text();e={error:"invalid_response",error_description:a}}return e.accessToken?{ok:!0,data:{access_token:e.accessToken,refresh_token:e.refreshToken,expires_in:e.expiresIn,profile_arn:e?.profileArn||null,_clientId:d?._clientId,_clientSecret:d?._clientSecret,_region:d?._region,_authMethod:d?._authMethod,_startUrl:d?._startUrl}}:{ok:!1,data:{error:e.error||"authorization_pending",error_description:e.error_description||e.message}}},mapTokens:a=>{let b=function(a){let b=i(a);if(b)return b.email||b.preferred_username||b.sub||void 0}(a.access_token);return{accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,email:b,providerSpecificData:{profileArn:a?.profile_arn||null,clientId:a._clientId,clientSecret:a._clientSecret,region:a._region||"us-east-1",authMethod:a._authMethod||"builder-id",startUrl:a._startUrl||g.Tx.startUrl}}}},cursor:{config:g.WN,flowType:"import_token",mapTokens:a=>({accessToken:a.accessToken,refreshToken:null,expiresIn:a.expiresIn||86400,providerSpecificData:{machineId:a.machineId,authMethod:"imported"}})},"kimi-coding":{config:g.t,flowType:"device_code",requestDeviceCode:async a=>{let b=await fetch(a.deviceCodeUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({client_id:a.clientId})});if(!b.ok){let a=await b.text();throw Error(`Device code request failed: ${a}`)}let c=await b.json();return{device_code:c.device_code,user_code:c.user_code,verification_uri:c.verification_uri||"https://www.kimi.com/code/authorize_device",verification_uri_complete:c.verification_uri_complete||`https://www.kimi.com/code/authorize_device?user_code=${c.user_code}`,expires_in:c.expires_in,interval:c.interval||5}},pollToken:async(a,b)=>{let c,d=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({grant_type:"urn:ietf:params:oauth:grant-type:device_code",client_id:a.clientId,device_code:b})});try{c=await d.json()}catch(b){let a=await d.text();c={error:"invalid_response",error_description:a}}return{ok:d.ok,data:c}},mapTokens:a=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in})},kilocode:{config:g.MZ,flowType:"device_code",requestDeviceCode:async a=>{let b=await fetch(a.initiateUrl,{method:"POST",headers:{"Content-Type":"application/json"}});if(!b.ok){if(429===b.status)throw Error("Too many pending authorization requests. Please try again later.");let a=await b.text();throw Error(`Device auth initiation failed: ${a}`)}let c=await b.json();return{device_code:c.code,user_code:c.code,verification_uri:c.verificationUrl,verification_uri_complete:c.verificationUrl,expires_in:c.expiresIn||300,interval:3}},pollToken:async(a,b)=>{let c=await fetch(`${a.pollUrlBase}/${b}`);if(202===c.status)return{ok:!1,data:{error:"authorization_pending"}};if(403===c.status)return{ok:!1,data:{error:"access_denied",error_description:"Authorization denied by user"}};if(410===c.status)return{ok:!1,data:{error:"expired_token",error_description:"Authorization code expired"}};if(!c.ok)return{ok:!1,data:{error:"poll_failed",error_description:`Poll failed: ${c.status}`}};let d=await c.json();if("approved"===d.status&&d.token){let b=null;try{let c=await fetch(`${a.apiBaseUrl}/api/profile`,{headers:{Authorization:`Bearer ${d.token}`}});if(c.ok){let a=await c.json();b=a.organizations?.[0]?.id||null}}catch{}return{ok:!0,data:{access_token:d.token,_userEmail:d.userEmail,_orgId:b}}}return{ok:!1,data:{error:"authorization_pending"}}},mapTokens:a=>({accessToken:a.access_token,refreshToken:null,expiresIn:null,email:a._userEmail,...a._orgId?{providerSpecificData:{orgId:a._orgId}}:{}})},cline:{config:g.lB,flowType:"authorization_code",buildAuthUrl:(a,b)=>{let c=new URLSearchParams({client_type:"extension",callback_url:b,redirect_uri:b});return`${a.authorizeUrl}?${c.toString()}`},exchangeToken:async(a,b,c)=>{try{let a=b,c=4-a.length%4;4!==c&&(a+="=".repeat(c));let d=Buffer.from(a,"base64").toString("utf-8"),e=d.lastIndexOf("}");if(-1===e)throw Error("No JSON found in decoded code");let f=JSON.parse(d.substring(0,e+1));return{access_token:f.accessToken,refresh_token:f.refreshToken,email:f.email,firstName:f.firstName,lastName:f.lastName,expires_at:f.expiresAt}}catch(f){let d=await fetch(a.tokenExchangeUrl,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:b,client_type:"extension",redirect_uri:c})});if(!d.ok){let a=await d.text();throw Error(`Cline token exchange failed: ${a}`)}let e=await d.json();return{access_token:e.data?.accessToken||e.accessToken,refresh_token:e.data?.refreshToken||e.refreshToken,email:e.data?.userInfo?.email||"",expires_at:e.data?.expiresAt||e.expiresAt}}},mapTokens:a=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_at?Math.floor((new Date(a.expires_at).getTime()-Date.now())/1e3):3600,email:a.email,providerSpecificData:{firstName:a.firstName,lastName:a.lastName}})},gitlab:{config:g.f7,flowType:"authorization_code_pkce",buildAuthUrl:(a,b,c,d,e={})=>{let f=e.baseUrl||a.defaultBaseUrl,g=e.clientId||"",h=new URLSearchParams({client_id:g,redirect_uri:b,response_type:"code",state:c,scope:a.scope,code_challenge:d,code_challenge_method:a.codeChallengeMethod});return`${f}${a.authorizeUrlPath}?${h.toString()}`},exchangeToken:async(a,b,c,d,e,f={})=>{let g=f.baseUrl||a.defaultBaseUrl,h=f.clientId||"",i=f.clientSecret||"",j=new URLSearchParams({client_id:h,grant_type:"authorization_code",code:b,redirect_uri:c,code_verifier:d});i&&j.set("client_secret",i);let k=await fetch(`${g}${a.tokenUrlPath}`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:j.toString()});if(!k.ok)throw Error(`GitLab token exchange failed: ${await k.text()}`);let l=await k.json(),m=await fetch(`${g}${a.userInfoUrlPath}`,{headers:{Authorization:`Bearer ${l.access_token}`}}),n=m.ok?await m.json():{};return{...l,_user:n,_baseUrl:g,_clientId:h}},mapTokens:a=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:a.expires_in,scope:a.scope,providerSpecificData:{username:a._user?.username||"",email:a._user?.email||a._user?.public_email||"",name:a._user?.name||"",baseUrl:a._baseUrl,clientId:a._clientId,authKind:"oauth"}})},codebuddy:{config:g.Nl,flowType:"device_code",requestDeviceCode:async a=>{let b=await fetch(`${a.stateUrl}?platform=${a.platform}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","User-Agent":a.userAgent,"X-Requested-With":"XMLHttpRequest","X-Domain":"copilot.tencent.com","X-No-Authorization":"true","X-No-User-Id":"true","X-Product":"SaaS"},body:"{}"});if(!b.ok)throw Error(`CodeBuddy state request failed: ${await b.text()}`);let c=await b.json();if(0!==c.code||!c.data?.state||!c.data?.authUrl)throw Error(`CodeBuddy state error: ${c.msg||"missing state/authUrl"}`);return{device_code:c.data.state,verification_uri:c.data.authUrl,user_code:"",interval:a.pollInterval/1e3,_isCodeBuddy:!0}},pollToken:async(a,b)=>{let c=await fetch(a.tokenUrl,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","User-Agent":a.userAgent,"X-Requested-With":"XMLHttpRequest","X-Domain":"copilot.tencent.com","X-No-Authorization":"true","X-No-User-Id":"true","X-Product":"SaaS"},body:JSON.stringify({state:b})});if(!c.ok)return{ok:!1,data:{error:"request_failed"}};let d=await c.json();return 0===d.code&&d.data?.accessToken?{ok:!0,data:{access_token:d.data.accessToken,refresh_token:d.data.refreshToken||"",token_type:d.data.tokenType||"Bearer"}}:11217===d.code?{ok:!0,data:{error:"authorization_pending"}}:{ok:!1,data:{error:d.msg||"unknown_error"}}},mapTokens:a=>({accessToken:a.access_token,refreshToken:a.refresh_token,expiresIn:86400,providerSpecificData:{}})}};function k(a){let b=q[a];if(!b)throw Error(`Unknown provider: ${a}`);return b}function l(a,b,c){let d=k(a),{codeVerifier:e,codeChallenge:g,state:h}=(0,f.lz)();return{authUrl:"device_code"===d.flowType?null:"authorization_code_pkce"===d.flowType?d.buildAuthUrl(d.config,b,h,g,c||{}):d.buildAuthUrl(d.config,b,h,void 0,c||{}),state:h,codeVerifier:e,codeChallenge:g,redirectUri:b,flowType:d.flowType,fixedPort:d.fixedPort,callbackPath:d.callbackPath||"/callback"}}async function m(a,b,c,d,e,f){let g=k(a),h=await g.exchangeToken(g.config,b,c,d,e,f||{}),i=null;return g.postExchange&&(i=await g.postExchange(h)),g.mapTokens(h,i)}async function n(a,b,c){let d=k(a);if("device_code"!==d.flowType)throw Error(`Provider ${a} does not support device code flow`);return await d.requestDeviceCode(d.config,b,c||{})}async function o(a,b,c,d){let e=k(a);if("device_code"!==e.flowType)throw Error(`Provider ${a} does not support device code flow`);let f=await e.pollToken(e.config,b,c,d);if(f.ok)if(f.data.access_token){let a=null;return e.postExchange&&(a=await e.postExchange(f.data)),{success:!0,tokens:e.mapTokens(f.data,a)}}else if("authorization_pending"===f.data.error||"slow_down"===f.data.error)return{success:!1,error:f.data.error,errorDescription:f.data.error_description||f.data.message,pending:"authorization_pending"===f.data.error};else return{success:!1,error:f.data.error||"no_access_token",errorDescription:f.data.error_description||f.data.message||"No access token received"};return{success:!1,error:f.data.error,errorDescription:f.data.error_description}}let r=!1;async function p(){if(!r){r=!0;try{let{getProviderConnections:a,updateProviderConnection:b}=await Promise.resolve().then(c.bind(c,89718));for(let c of(await a()).filter(a=>{if("codex"!==a.provider||"oauth"!==a.authType||!a.idToken)return!1;let b=!!a.email,c=!!a.providerSpecificData?.chatgptAccountId;return!b||!c})){let a=j(c.idToken);if(!a.email&&!a.chatgptAccountId)continue;let d={};!c.email&&a.email&&(d.email=a.email),(a.chatgptAccountId||a.chatgptPlanType)&&(d.providerSpecificData={...c.providerSpecificData||{},chatgptAccountId:a.chatgptAccountId,chatgptPlanType:a.chatgptPlanType}),Object.keys(d).length&&await b(c.id,d)}}catch(a){r=!1,console.log("backfillCodexEmails failed:",a?.message||a)}}}d()}catch(a){d(a)}})},92990:(a,b,c)=>{c.d(b,{DI:()=>e,Hp:()=>g,LT:()=>f,MZ:()=>o,Nl:()=>r,Nu:()=>k,OV:()=>d,Tx:()=>l,WN:()=>m,YT:()=>j,ZL:()=>i,f7:()=>q,hF:()=>h,lB:()=>p,t:()=>n}),c(21820);let d={clientId:"9d1c250a-e61b-44d9-88ed-5944d1962f5e",authorizeUrl:"https://claude.ai/oauth/authorize",tokenUrl:"https://api.anthropic.com/v1/oauth/token",scopes:["org:create_api_key","user:profile","user:inference"],codeChallengeMethod:"S256"},e={clientId:"app_EMoamEEZ73f0CkXaXp7hrann",authorizeUrl:"https://auth.openai.com/oauth/authorize",tokenUrl:"https://auth.openai.com/oauth/token",scope:"openid profile email offline_access",codeChallengeMethod:"S256",extraParams:{id_token_add_organizations:"true",codex_cli_simplified_flow:"true",originator:"codex_cli_rs"}},f={clientId:"681255809395-oo8ft2oprdrnp9e3aqf6av3hmdib135j.apps.googleusercontent.com",clientSecret:"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",authorizeUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",userInfoUrl:"https://www.googleapis.com/oauth2/v1/userinfo",scopes:["https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/userinfo.email","https://www.googleapis.com/auth/userinfo.profile"]},g={clientId:"f0304373b74a44d2b584a3fb70ca9e56",deviceCodeUrl:"https://chat.qwen.ai/api/v1/oauth2/device/code",tokenUrl:"https://chat.qwen.ai/api/v1/oauth2/token",scope:"openid profile email model.completion",codeChallengeMethod:"S256"},h={apiBaseUrl:"https://api2.qoder.sh",deviceTokenUrl:"https://api2.qoder.sh/api/v1/deviceToken/poll",deviceRefreshUrl:"https://api2.qoder.sh/api/v1/deviceToken/refresh",refreshUrl:"https://api2.qoder.sh/api/v3/user/refresh_token",userInfoUrl:"https://api2.qoder.sh/api/v1/userinfo",statusUrl:"https://api2.qoder.sh/api/v3/user/status",loginUrl:"https://qoder.com/login"},i={clientId:"10009311001",clientSecret:"4Z3YjXycVsQvyGF1etiNlIBB4RsqSDtW",authorizeUrl:"https://iflow.cn/oauth",tokenUrl:"https://iflow.cn/oauth/token",userInfoUrl:"https://iflow.cn/api/oauth/getUserInfo",extraParams:{loginMethod:"phone",type:"phone"}},j={clientId:"1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com",clientSecret:"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",authorizeUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",userInfoUrl:"https://www.googleapis.com/oauth2/v1/userinfo",scopes:["https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/userinfo.email","https://www.googleapis.com/auth/userinfo.profile","https://www.googleapis.com/auth/cclog","https://www.googleapis.com/auth/experimentsandconfigs"],apiEndpoint:"https://cloudcode-pa.googleapis.com",apiVersion:"v1internal",loadCodeAssistEndpoint:"https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist",onboardUserEndpoint:"https://cloudcode-pa.googleapis.com/v1internal:onboardUser",loadCodeAssistUserAgent:"google-api-nodejs-client/9.15.1",loadCodeAssistApiClient:"google-cloud-sdk vscode_cloudshelleditor/0.1",loadCodeAssistClientMetadata:JSON.stringify({ideType:"IDE_UNSPECIFIED",platform:"PLATFORM_UNSPECIFIED",pluginType:"GEMINI"})},k={clientId:"Iv1.b507a08c87ecfe98",deviceCodeUrl:"https://github.com/login/device/code",tokenUrl:"https://github.com/login/oauth/access_token",userInfoUrl:"https://api.github.com/user",scopes:"read:user",apiVersion:"2022-11-28",copilotTokenUrl:"https://api.github.com/copilot_internal/v2/token",userAgent:"GitHubCopilotChat/0.26.7",editorVersion:"vscode/1.85.0",editorPluginVersion:"copilot-chat/0.26.7"},l={ssoOidcEndpoint:"https://oidc.us-east-1.amazonaws.com",registerClientUrl:"https://oidc.us-east-1.amazonaws.com/client/register",deviceAuthUrl:"https://oidc.us-east-1.amazonaws.com/device_authorization",tokenUrl:"https://oidc.us-east-1.amazonaws.com/token",startUrl:"https://view.awsapps.com/start",clientName:"kiro-oauth-client",clientType:"public",scopes:["codewhisperer:completions","codewhisperer:analysis","codewhisperer:conversations"],grantTypes:["urn:ietf:params:oauth:grant-type:device_code","refresh_token"],issuerUrl:"https://identitycenter.amazonaws.com/ssoins-722374e8c3c8e6c6",socialAuthEndpoint:"https://prod.us-east-1.auth.desktop.kiro.dev",socialLoginUrl:"https://prod.us-east-1.auth.desktop.kiro.dev/login",socialTokenUrl:"https://prod.us-east-1.auth.desktop.kiro.dev/oauth/token",socialRefreshUrl:"https://prod.us-east-1.auth.desktop.kiro.dev/refreshToken",authMethods:["builder-id","idc","google","github","import"]},m={apiEndpoint:"https://api2.cursor.sh",chatEndpoint:"/aiserver.v1.ChatService/StreamUnifiedChatWithTools",modelsEndpoint:"/aiserver.v1.AiService/GetDefaultModelNudgeData",api3Endpoint:"https://api3.cursor.sh",agentEndpoint:"https://agent.api5.cursor.sh",agentNonPrivacyEndpoint:"https://agentn.api5.cursor.sh",clientVersion:"3.1.0",clientType:"ide",tokenStoragePaths:{linux:"~/.config/Cursor/User/globalStorage/state.vscdb",macos:"/Users/<user>/Library/Application Support/Cursor/User/globalStorage/state.vscdb",windows:"%APPDATA%\\Cursor\\User\\globalStorage\\state.vscdb"},dbKeys:{accessToken:"cursorAuth/accessToken",machineId:"storage.serviceMachineId"}},n={clientId:process.env.KIMI_CODING_OAUTH_CLIENT_ID||"17e5f671-d194-4dfb-9706-5516cb48c098",deviceCodeUrl:"https://auth.kimi.com/api/oauth/device_authorization",tokenUrl:"https://auth.kimi.com/api/oauth/token"},o={apiBaseUrl:"https://api.kilo.ai",initiateUrl:"https://api.kilo.ai/api/device-auth/codes",pollUrlBase:"https://api.kilo.ai/api/device-auth/codes"},p={appBaseUrl:"https://app.cline.bot",apiBaseUrl:"https://api.cline.bot",authorizeUrl:"https://api.cline.bot/api/v1/auth/authorize",tokenExchangeUrl:"https://api.cline.bot/api/v1/auth/token",refreshUrl:"https://api.cline.bot/api/v1/auth/refresh"},q={defaultBaseUrl:"https://gitlab.com",authorizeUrlPath:"/oauth/authorize",tokenUrlPath:"/oauth/token",userInfoUrlPath:"/api/v4/user",scope:"api read_user",codeChallengeMethod:"S256"},r={baseUrl:"https://copilot.tencent.com",stateUrl:"https://copilot.tencent.com/v2/plugin/auth/state",tokenUrl:"https://copilot.tencent.com/v2/plugin/auth/token",refreshUrl:"https://copilot.tencent.com/v2/plugin/auth/token/refresh",userAgent:"CLI/2.63.2 CodeBuddy/2.63.2",platform:"CLI",pollInterval:5e3}}};
|
|
@@ -7,7 +7,7 @@ ${f(e.content)}`});continue}if("tool"===e.role){let a=f(e.content),d=e.tool_call
|
|
|
7
7
|
\`\`\`json
|
|
8
8
|
${b}
|
|
9
9
|
\`\`\`
|
|
10
|
-
Respond ONLY with the JSON object, no other text.`)}else"json_object"===a.type&&j.push("You must respond with valid JSON. Respond ONLY with a JSON object, no other text.")}let k={type:"text",text:f.Co};if(j.length>0?h.system=[k,{type:"text",text:j.join("\n"),cache_control:{type:"ephemeral",ttl:"1h"}}]:h.system=[k],b.tools&&Array.isArray(b.tools)){for(let a of(h.tools=[],b.tools)){let b=a.type;if(b&&"function"!==b){h.tools.push(a);continue}let c="function"===b&&a.function?a.function:a,d=c.name,f=""+d;e.set(f,d),h.tools.push({name:f,description:c.description||"",input_schema:c.parameters||c.input_schema||{type:"object",properties:{},required:[]}})}h.tools.length>0&&(h.tools[h.tools.length-1].cache_control={type:"ephemeral",ttl:"1h"})}if(b.tool_choice&&(h.tool_choice=(d=b.tool_choice)?"object"==typeof d&&d.type?d:"auto"===d||"none"===d?{type:"auto"}:"required"===d?{type:"any"}:"object"==typeof d&&d.function?{type:"tool",name:d.function.name}:{type:"auto"}:{type:"auto"}),b.thinking&&(h.thinking={type:b.thinking.type||"enabled",...b.thinking.budget_tokens&&{budget_tokens:b.thinking.budget_tokens},...b.thinking.max_tokens&&{max_tokens:b.thinking.max_tokens}}),b.reasoning_effort&&!h.thinking){let a={none:0,low:4096,medium:8192,high:16384,xhigh:32768}[b.reasoning_effort.toLowerCase()];0===a||a&&(h.thinking={type:"enabled",budget_tokens:a})}return e.size>0&&(h._toolNameMap=e),h}function i(a){return"string"==typeof a?a:Array.isArray(a)?a.filter(a=>"text"===a.type).map(a=>a.text).join("\n"):""}function j(a,b,c){let d=h(a,b,c);return d.system&&Array.isArray(d.system)&&(d.system=d.system.filter(a=>!a.text||!a.text.includes("You are Claude Code")),0===d.system.length&&delete d.system),d.tools&&Array.isArray(d.tools)&&(d.tools=d.tools.map(a=>a.name&&a.name.startsWith("")?{...a,name:a.name.slice(0)}:a)),d.messages&&Array.isArray(d.messages)&&(d.messages=d.messages.map(a=>{if(!a.content||!Array.isArray(a.content))return a;let b=a.content.map(a=>"tool_use"===a.type&&a.name&&a.name.startsWith("")?{...a,name:a.name.slice(0)}:a);return{...a,content:b}})),d}(0,d.kz)(e.h.OPENAI,e.h.CLAUDE,h,null)},29675:(a,b,c)=>{c.r(b),c.d(b,{claudeToOpenAIResponse:()=>g});var d=c(33110),e=c(14170);function f(a,b,c=null){return{id:`chatcmpl-${a.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:a.model,choices:[{index:0,delta:b,finish_reason:c}]}}function g(a,b){if(!a)return null;let c=[];switch(a.type){case"message_start":b.messageId=a.message?.id||`msg_${Date.now()}`,b.model=a.message?.model,b.toolCallIndex=0,c.push(f(b,{role:"assistant"}));break;case"content_block_start":{let d=a.content_block;if(d?.type==="server_tool_use"){b.serverToolBlockIndex=a.index;break}if(d?.type==="text")b.textBlockStarted=!0;else if(d?.type==="thinking")b.inThinkingBlock=!0,b.currentBlockIndex=a.index,c.push(f(b,{content:"<think>"}));else if(d?.type==="tool_use"){let e=b.toolCallIndex++,g=b.toolNameMap?.get(d.name)||d.name,h={index:e,id:d.id,type:"function",function:{name:g,arguments:""}};b.toolCalls.set(a.index,h),c.push(f(b,{tool_calls:[h]}))}break}case"content_block_delta":{if(a.index===b.serverToolBlockIndex)break;let d=a.delta;if(d?.type==="text_delta"&&d.text)c.push(f(b,{content:d.text}));else if(d?.type==="thinking_delta"&&d.thinking)c.push(f(b,{reasoning_content:d.thinking}));else if(d?.type==="input_json_delta"&&d.partial_json){let e=b.toolCalls.get(a.index);e&&(e.function.arguments+=d.partial_json,c.push(f(b,{tool_calls:[{index:e.index,id:e.id,function:{arguments:d.partial_json}}]})))}break}case"content_block_stop":if(a.index===b.serverToolBlockIndex){b.serverToolBlockIndex=-1;break}b.inThinkingBlock&&a.index===b.currentBlockIndex&&(c.push(f(b,{content:"</think>"})),b.inThinkingBlock=!1),b.textBlockStarted=!1,b.thinkingBlockStarted=!1;break;case"message_delta":if(a.usage&&"object"==typeof a.usage){let c="number"==typeof a.usage.input_tokens?a.usage.input_tokens:0,d="number"==typeof a.usage.output_tokens?a.usage.output_tokens:0,e="number"==typeof a.usage.cache_read_input_tokens?a.usage.cache_read_input_tokens:0,f="number"==typeof a.usage.cache_creation_input_tokens?a.usage.cache_creation_input_tokens:0,g=c+e+f;b.usage={prompt_tokens:g,completion_tokens:d,total_tokens:g+d,input_tokens:c,output_tokens:d},e>0&&(b.usage.cache_read_input_tokens=e),f>0&&(b.usage.cache_creation_input_tokens=f)}if(a.delta?.stop_reason){b.finishReason=function(a){switch(a){case"end_turn":case"stop_sequence":default:return"stop";case"max_tokens":return"length";case"tool_use":return"tool_calls"}}(a.delta.stop_reason);let d={id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:{},finish_reason:b.finishReason}]};if(b.usage){d.usage={prompt_tokens:b.usage.prompt_tokens,completion_tokens:b.usage.completion_tokens,total_tokens:b.usage.total_tokens};let a=b.usage.cache_read_input_tokens,c=b.usage.cache_creation_input_tokens;(a>0||c>0)&&(d.usage.prompt_tokens_details={},a>0&&(d.usage.prompt_tokens_details.cached_tokens=a),c>0&&(d.usage.prompt_tokens_details.cache_creation_tokens=c))}c.push(d),b.finishReasonSent=!0}break;case"message_stop":if(!b.finishReasonSent){let a=b.finishReason||(b.toolCalls?.size>0?"tool_calls":"stop"),d=b.usage&&"object"==typeof b.usage?{usage:{prompt_tokens:b.usage.input_tokens||0,completion_tokens:b.usage.output_tokens||0,total_tokens:(b.usage.input_tokens||0)+(b.usage.output_tokens||0)}}:{};c.push({id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:{},finish_reason:a}],...d}),b.finishReasonSent=!0}}return c.length>0?c:null}(0,d.kz)(e.h.CLAUDE,e.h.OPENAI,null,g)},32546:(a,b,c)=>{c.r(b),c.d(b,{geminiToOpenAIResponse:()=>f});var d=c(33110),e=c(14170);function f(a,b){if(!a)return null;let c=a.response||a;if(!c||!c.candidates?.[0])return null;let d=[],e=c.candidates[0],f=e.content;if(b.messageId||(b.messageId=c.responseId||`msg_${Date.now()}`,b.model=c.modelVersion||"gemini",b.functionIndex=0,d.push({id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:{role:"assistant"},finish_reason:null}]})),f?.parts)for(let a of f.parts){let c=a.thoughtSignature||a.thought_signature,e=!0===a.thought;if(c){let c=void 0!==a.text&&""!==a.text,f=!!a.functionCall;if(c&&d.push({id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:e?{reasoning_content:a.text}:{content:a.text},finish_reason:null}]}),f){let c=a.functionCall.name,e=b.toolNameMap?.get(c)||c,f=a.functionCall.args||{},g=b.functionIndex++,h={id:`${e}-${Date.now()}-${g}`,index:g,type:"function",function:{name:e,arguments:JSON.stringify(f)}};b.toolCalls.set(g,h),d.push({id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:{tool_calls:[h]},finish_reason:null}]})}continue}if(void 0!==a.text&&""!==a.text&&d.push({id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:{content:a.text},finish_reason:null}]}),a.functionCall){let c=a.functionCall.name,e=b.toolNameMap?.get(c)||c,f=a.functionCall.args||{},g=b.functionIndex++,h={id:`${e}-${Date.now()}-${g}`,index:g,type:"function",function:{name:e,arguments:JSON.stringify(f)}};b.toolCalls.set(g,h),d.push({id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:{tool_calls:[h]},finish_reason:null}]})}let f=a.inlineData||a.inline_data;if(f?.data){let a=f.mimeType||f.mime_type||"image/png";d.push({id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:{images:[{type:"image_url",image_url:{url:`data:${a};base64,${f.data}`}}]},finish_reason:null}]})}}let g=c.usageMetadata||a.usageMetadata;if(g&&"object"==typeof g){let a="number"==typeof g.cachedContentTokenCount?g.cachedContentTokenCount:0,c="number"==typeof g.promptTokenCount?g.promptTokenCount:0,d="number"==typeof g.thoughtsTokenCount?g.thoughtsTokenCount:0,e="number"==typeof g.candidatesTokenCount?g.candidatesTokenCount:0,f="number"==typeof g.totalTokenCount?g.totalTokenCount:0;0===e&&f>0&&(e=f-c-d)<0&&(e=0),b.usage={prompt_tokens:c,completion_tokens:e+d,total_tokens:f},a>0&&(b.usage.prompt_tokens_details={cached_tokens:a}),d>0&&(b.usage.completion_tokens_details={reasoning_tokens:d})}if(e.finishReason){let a=e.finishReason.toLowerCase();"stop"===a&&b.toolCalls.size>0&&(a="tool_calls");let c={id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:{},finish_reason:a}]};b.usage&&(c.usage=b.usage),d.push(c),b.finishReason=a}return d.length>0?d:null}(0,d.kz)(e.h.GEMINI,e.h.OPENAI,null,f),(0,d.kz)(e.h.GEMINI_CLI,e.h.OPENAI,null,f),(0,d.kz)(e.h.ANTIGRAVITY,e.h.OPENAI,null,f),(0,d.kz)(e.h.VERTEX,e.h.OPENAI,null,f)},33110:(a,b,c)=>{c.d(b,{Ws:()=>v,Ai:()=>w,nZ:()=>u,kz:()=>q,GH:()=>s,Y8:()=>t});var d=c(14170);let e=/^[a-zA-Z0-9_-]+$/;function f(a=0,b=0,c=""){let d=c?`_${c.replace(/[^a-zA-Z0-9_-]/g,"")}`:"";return`call_msg${a}_tc${b}${d}`}function g(a){if(!a||"string"!=typeof a)return null;let b=a.replace(/[^a-zA-Z0-9_-]/g,"");return b.length>0?b:null}var h=c(96281);c(3156);var i=c(55399),j=c(80662);let k=new Set(["minimax","minimax-cn"]),l=["text","image_url","image","input_audio","audio_url"];var m=c(57647);c(39536);let n=new Map,o=new Map,p=!1;function q(a,b,c,d){let e=`${a}:${b}`;c&&n.set(e,c),d&&o.set(e,d)}function r(){p||(p=!0,c(60983),c(19979),c(52638),c(97102),c(59611),c(54817),c(65377),c(80198),c(13595),c(74447),c(97821),c(29675),c(66159),c(32546),c(89475),c(4845),c(52830),c(65651),c(39551),c(47723))}function s(a,b,c,o,p=!0,q=null,t=null,u=null,v=[],w=null,x=null){r();let y=o;if(!function(a,b=[]){if(!b.length||!a.messages||!Array.isArray(a.messages))return;let c=new Set(["image_url","image"]),d=new Set(["audio_url","input_audio"]),e=a=>c.has(a)?b.includes("image"):!!d.has(a)&&b.includes("audio");for(let b of a.messages)Array.isArray(b.content)&&(b.content=b.content.filter(a=>!e(a.type)),0===b.content.length&&(b.content=""))}(y,v),(0,m.SZ)(y),!function(a){if(a.messages&&Array.isArray(a.messages))for(let b=0;b<a.messages.length;b++){let c=a.messages[b];if("assistant"===c.role&&c.tool_calls&&Array.isArray(c.tool_calls))for(let a=0;a<c.tool_calls.length;a++){let d=c.tool_calls[a];if(!d.id||!e.test(d.id)){let c=g(d.id);d.id=c||f(b,a,d.function?.name)}d.type||(d.type="function"),d.function?.arguments&&"string"!=typeof d.function.arguments&&(d.function.arguments=JSON.stringify(d.function.arguments))}if("tool"===c.role&&c.tool_call_id&&!e.test(c.tool_call_id)){let a=g(c.tool_call_id);c.tool_call_id=a||f(b,0)}if(Array.isArray(c.content))for(let a=0;a<c.content.length;a++){let d=c.content[a];if("tool_use"===d.type&&d.id&&!e.test(d.id)){let c=g(d.id);d.id=c||f(b,a,d.name)}if("tool_result"===d.type&&d.tool_use_id&&!e.test(d.tool_use_id)){let c=g(d.tool_use_id);d.tool_use_id=c||f(b,a)}}}}(y),!function(a){if(!a.messages||!Array.isArray(a.messages))return;let b=[];for(let c=0;c<a.messages.length;c++){let d=a.messages[c],e=a.messages[c+1];b.push(d);let f=function(a){if("assistant"!==a.role)return[];let b=[];if(a.tool_calls&&Array.isArray(a.tool_calls))for(let c of a.tool_calls)c.id&&b.push(c.id);if(Array.isArray(a.content))for(let c of a.content)"tool_use"===c.type&&c.id&&b.push(c.id);return b}(d);if(0!==f.length&&e&&!function(a,b){if(!a||!b.length)return!1;if("tool"===a.role&&a.tool_call_id)return b.includes(a.tool_call_id);if("user"===a.role&&Array.isArray(a.content)){for(let c of a.content)if("tool_result"===c.type&&b.includes(c.tool_use_id))return!0}return!1}(e,f))for(let a of f)b.push({role:"tool",tool_call_id:a,content:""})}a.messages=b}(y),a!==b){if(a!==d.h.OPENAI){let b=n.get(`${a}:${d.h.OPENAI}`);b&&(y=b(c,y,p,q),u?.logOpenAIRequest?.(y))}if(b!==d.h.OPENAI){let a=n.get(`${d.h.OPENAI}:${b}`);a&&(y=a(c,y,p,q))}}if(b===d.h.OPENAI&&(y=function(a){if(!a.messages||!Array.isArray(a.messages))return a;if(a.messages=a.messages.map(a=>{if("tool"===a.role||"assistant"===a.role&&a.tool_calls||"string"==typeof a.content)return a;if(Array.isArray(a.content)){let b=[];for(let c of a.content)if("thinking"!==c.type&&"redacted_thinking"!==c.type){if(l.includes(c.type)){let{signature:a,cache_control:d,...e}=c;b.push(e)}else if("tool_use"===c.type)continue;else if("tool_result"===c.type){let{signature:a,cache_control:d,...e}=c;b.push(e)}}return 0===b.length&&b.push({type:"text",text:""}),{...a,content:b}}return a}),a.messages=a.messages.filter(a=>"tool"===a.role||"assistant"===a.role&&!!a.tool_calls||("string"==typeof a.content?""!==a.content.trim():!Array.isArray(a.content)||a.content.some(a=>"text"===a.type&&a.text?.trim()||"text"!==a.type))),a.tools&&Array.isArray(a.tools)&&0===a.tools.length&&delete a.tools,a.tools&&Array.isArray(a.tools)&&a.tools.length>0&&(a.tools=a.tools.map(a=>"function"===a.type&&a.function?a:a.name&&(a.input_schema||a.description)?{type:"function",function:{name:a.name,description:String(a.description||""),parameters:a.input_schema||{type:"object",properties:{}}}}:a.functionDeclarations&&Array.isArray(a.functionDeclarations)?a.functionDeclarations.map(a=>({type:"function",function:{name:a.name,description:String(a.description||""),parameters:a.parameters||{type:"object",properties:{}}}})):a).flat()),a.tool_choice&&"object"==typeof a.tool_choice){let b=a.tool_choice;"auto"===b.type?a.tool_choice="auto":"any"===b.type?a.tool_choice="required":"tool"===b.type&&b.name&&(a.tool_choice={type:"function",function:{name:b.name}})}return a}(y)),b===d.h.CLAUDE&&(y=function(a,b=null,c=null,d=null){if(k.has(b)&&delete a.output_config,a.system&&Array.isArray(a.system)&&(a.system=a.system.map((b,c)=>{let{cache_control:d,...e}=b;return c===a.system.length-1?{...e,cache_control:{type:"ephemeral",ttl:"1h"}}:e})),a.messages&&Array.isArray(a.messages)){let c=a.messages.length,d=[];for(let b=0;b<c;b++){let e=a.messages[b];if(Array.isArray(e.content))for(let a of e.content)delete a.cache_control;(b===c-1&&"assistant"===e.role||"string"==typeof e.content&&e.content.trim()||Array.isArray(e.content)&&e.content.some(a=>"text"===a.type&&a.text?.trim()||"tool_use"===a.type||"tool_result"===a.type))&&d.push(e)}d=function(a){if(a.length<=1)return a;for(let b of a)if("assistant"===b.role&&Array.isArray(b.content)&&b.content.some(a=>"tool_use"===a.type)){let a=[],c=!1;for(let d of b.content)"tool_use"===d.type?(c=!0,a.push(d)):"thinking"===d.type||"redacted_thinking"===d.type?a.push(d):c||a.push(d);b.content=a}let b=[];for(let c of a){let a=b[b.length-1];if(a&&a.role===c.role){let b=Array.isArray(a.content)?a.content:[{type:"text",text:a.content}],d=Array.isArray(c.content)?c.content:[{type:"text",text:c.content}];a.content=[...b.filter(a=>"tool_result"===a.type),...d.filter(a=>"tool_result"===a.type),...b.filter(a=>"tool_result"!==a.type),...d.filter(a=>"tool_result"!==a.type)]}else{let a=Array.isArray(c.content)?c.content:[{type:"text",text:c.content}];b.push({role:c.role,content:[...a]})}}return b}(d),a.messages=d;let e=d[d.length-1],f=e?.role==="user",g=a.thinking?.type==="enabled"&&f,i=!1;for(let a=d.length-1;a>=0;a--){let c=d[a];if("assistant"===c.role&&Array.isArray(c.content)){if(!i&&c.content.length>0){for(let a=c.content.length-1;a>=0;a--){let b=c.content[a];if("thinking"!==b.type&&"redacted_thinking"!==b.type){b.cache_control={type:"ephemeral"};break}}i=!0}if("claude"===b||b?.startsWith("anthropic-compatible")){let a=!1,b=!1;for(let d of c.content)("thinking"===d.type||"redacted_thinking"===d.type)&&(d.signature=h.xr,b=!0),"tool_use"===d.type&&(a=!0);g&&!b&&a&&c.content.unshift({type:"thinking",thinking:".",signature:h.xr})}}}}if(a.tools&&Array.isArray(a.tools)&&("claude"!==b&&(a.tools=a.tools.filter(a=>!a.type||"function"===a.type)),a.tools=a.tools.map((b,c)=>{let{cache_control:d,...e}=b;return c===a.tools.length-1?{...e,cache_control:{type:"ephemeral",ttl:"1h"}}:e}),0===a.tools.length&&(delete a.tools,delete a.tool_choice)),("claude"===b||b?.startsWith("anthropic-compatible"))&&c){let b=d?(0,j.RF)(d):null;a=(0,i.fO)(a,c,b)}return a}(y,t,q?.accessToken||q?.apiKey||null,w)),"claude"===t){let a=q?.accessToken||q?.apiKey||null;if(a?.includes("sk-ant-oat")){let{body:a,toolNameMap:b}=(0,i.Az)(y);y=a,b?.size>0&&(y._toolNameMap=b)}}return y}function t(a,b,c,e){if(r(),b===a)return[c];let f=[c],g=null;if(a!==d.h.OPENAI){let b=o.get(`${a}:${d.h.OPENAI}`);if(b){f=[];let a=b(c,e);a&&(g=f=Array.isArray(a)?a:[a])}}if(b!==d.h.OPENAI){let a=o.get(`${d.h.OPENAI}:${b}`);if(a){let b=[];for(let c of f){let d=a(c,e);d&&b.push(...Array.isArray(d)?d:[d])}f=b}}return g&&b!==d.h.OPENAI&&a!==d.h.OPENAI&&(f._openaiIntermediate=g),f}function u(a,b){return a!==b}function v(a){let b={messageId:null,model:null,textBlockStarted:!1,thinkingBlockStarted:!1,inThinkingBlock:!1,currentBlockIndex:null,toolCalls:new Map,finishReason:null,finishReasonSent:!1,usage:null,contentBlockIndex:-1};return a===d.h.OPENAI_RESPONSES?{...b,seq:0,responseId:`resp_${Date.now()}`,created:Math.floor(Date.now()/1e3),started:!1,msgTextBuf:{},msgItemAdded:{},msgContentAdded:{},msgItemDone:{},reasoningId:"",reasoningIndex:-1,reasoningBuf:"",reasoningPartAdded:!1,reasoningDone:!1,inThinking:!1,funcArgsBuf:{},funcNames:{},funcCallIds:{},funcArgsDone:{},funcItemDone:{},completedSent:!1}:b}function w(){r()}},39006:a=>{a.exports={rE:"0.4.24"}},39536:(a,b,c)=>{c.d(b,{c:()=>m});var d=c(55511),e=c.n(d),f=c(74957),g=c(35024),h=c(75924),i=c(41004),j=c(80662),k=c(39609),l=c(47593);class m extends f.H{constructor(){super("antigravity",g.xq.antigravity)}buildUrl(a,b,c=0){let d=this.getBaseUrls(),e=d[c]||d[0];return`${e}/v1internal:${b?"streamGenerateContent?alt=sse":"generateContent"}`}buildHeaders(a,b=!0,c=null){return{"Content-Type":"application/json",Authorization:`Bearer ${a.accessToken}`,"User-Agent":this.config.headers?.["User-Agent"]||h.K["User-Agent"],[h.Ox.name]:h.Ox.value,...c&&{"X-Machine-Session-Id":c},Accept:b?"text/event-stream":"application/json"}}transformRequest(a,b,c,d){let f=d?.projectId||this.generateProjectId(),g=b.request?.contents?.map(a=>{let b=a.role;a.parts?.some(a=>a.functionResponse)&&(b="user");let c=a.parts?.filter(a=>(!a.thought||!!a.functionCall)&&(!a.thoughtSignature||!!a.functionCall||!!a.text));return b!==a.role||c?.length!==a.parts?.length?{...a,role:b,parts:c}:a}),h=b.request?.tools;if(h&&h.length>0){let a=h.flatMap(a=>(a.functionDeclarations||[]).map(a=>({...a,name:function(a){if(!a)return"_unknown";let b=a.replace(/[^a-zA-Z0-9_.:\-]/g,"_");return/^[a-zA-Z_]/.test(b)||(b="_"+b),b.substring(0,64)}(a.name),parameters:a.parameters?(0,l.Yr)(structuredClone(a.parameters)):{type:"object",properties:{reason:{type:"string",description:"Brief explanation"}},required:["reason"]}})));h=a.length>0?[{functionDeclarations:a}]:[]}let{tools:i,toolConfig:k,...m}=b.request||{},n={...m.generationConfig||{}};n.maxOutputTokens>16384&&(n.maxOutputTokens=16384);let o={...m,generationConfig:n,...g&&{contents:g},...h&&{tools:h},sessionId:b.request?.sessionId||(0,j.RF)(d?.email||d?.connectionId),safetySettings:void 0,...h?.length>0&&{toolConfig:{functionCallingConfig:{mode:"VALIDATED"}}}};return{...b,project:f,model:a,userAgent:"antigravity",requestType:"agent",requestId:`agent-${e().randomUUID()}`,request:o}}async refreshCredentials(a,b,c=null){if(!a.refreshToken)return null;try{let d=await (0,k.proxyAwareFetch)(h.NA.google.token,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:a.refreshToken,client_id:this.config.clientId,client_secret:this.config.clientSecret})},c);if(!d.ok)return null;let e=await d.json();return b?.info?.("TOKEN","Antigravity refreshed"),{accessToken:e.access_token,refreshToken:e.refresh_token||a.refreshToken,expiresIn:e.expires_in,projectId:a.projectId}}catch(a){return b?.error?.("TOKEN",`Antigravity refresh error: ${a.message}`),null}}generateProjectId(){let a=["useful","bright","swift","calm","bold"][Math.floor(5*Math.random())],b=["fuze","wave","spark","flow","core"][Math.floor(5*Math.random())];return`${a}-${b}-${e().randomUUID().slice(0,5)}`}generateSessionId(){return e().randomUUID()+Date.now().toString()}parseRetryHeaders(a){if(!a?.get)return null;let b=a.get("retry-after");if(b){let a=parseInt(b,10);if(!isNaN(a)&&a>0)return 1e3*a;let c=new Date(b);if(!isNaN(c.getTime())){let a=c.getTime()-Date.now();return a>0?a:null}}let c=a.get("x-ratelimit-reset-after");if(c){let a=parseInt(c,10);if(!isNaN(a)&&a>0)return 1e3*a}let d=a.get("x-ratelimit-reset");if(d){let a=1e3*parseInt(d,10)-Date.now();return a>0?a:null}return null}parseRetryFromErrorMessage(a){if(!a||"string"!=typeof a)return null;let b=a.match(/reset after (\d+h)?(\d+m)?(\d+s)?/i);if(!b)return null;let c=0;return b[1]&&(c+=3600*parseInt(b[1])*1e3),b[2]&&(c+=60*parseInt(b[2])*1e3),b[3]&&(c+=1e3*parseInt(b[3])),c>0?c:null}async execute({model:a,body:b,stream:c,credentials:d,signal:e,log:f,proxyOptions:g=null}){let h=this.getFallbackCount(),j=null,l=0,m={},n={};for(let o=0;o<h;o++){let p=this.buildUrl(a,c,o),q=this.transformRequest(a,b,c,d),r=q.request?.sessionId,s=this.buildHeaders(d,c,r);m[o]||(m[o]=0),n[o]||(n[o]=0);try{let a=await (0,k.proxyAwareFetch)(p,{method:"POST",headers:s,body:JSON.stringify(q),signal:e},g);if(a.status===i.gx.RATE_LIMITED||a.status===i.gx.SERVICE_UNAVAILABLE){let b=this.parseRetryHeaders(a.headers);if(!b)try{let c=await a.clone().text(),d=JSON.parse(c),e=d?.error?.message||d?.message||"";b=this.parseRetryFromErrorMessage(e)}catch(a){}if(b&&b<=1e4&&n[o]<3){n[o]++,f?.debug?.("RETRY",`${a.status} with Retry-After: ${Math.ceil(b/1e3)}s, waiting... (${n[o]}/3)`),await new Promise(a=>setTimeout(a,b)),o--;continue}if(a.status===i.gx.RATE_LIMITED&&(!b||0===b)&&m[o]<3){m[o]++;let a=Math.min(1e3*2**m[o],1e4);f?.debug?.("RETRY",`429 auto retry ${m[o]}/3 after ${a/1e3}s`),await new Promise(b=>setTimeout(b,a)),o--;continue}if(f?.debug?.("RETRY",`${a.status}, Retry-After ${b?`too long (${Math.ceil(b/1e3)}s)`:"missing"}, trying fallback`),l=a.status,o+1<h)continue}if(this.shouldRetry(a.status,o)){f?.debug?.("RETRY",`${a.status} on ${p}, trying fallback ${o+1}`),l=a.status;continue}return{response:a,url:p,headers:s,transformedBody:q}}catch(a){if(j=a,o+1<h){f?.debug?.("RETRY",`Error on ${p}, trying fallback ${o+1}`);continue}throw a}}throw j||Error(`All ${h} URLs failed with status ${l}`)}static cloakTools(a,b=null){let c=a.request?.tools;if(!c||0===c.length)return{cloakedBody:a,toolNameMap:null};let d="github-copilot"===b,e=new Map,f=[],g=new Set(n.map(a=>a.name));for(let a of c)if(a.functionDeclarations)for(let b of a.functionDeclarations){if(d&&h.J5.has(b.name)||d&&g.has(b.name))continue;if(h.J5.has(b.name)){f.push(b);continue}let a=`${b.name}${h.QH}`;e.set(a,b.name),f.push({...b,name:a})}let i=[],j=new Set;for(let a of[...f,...n])!a?.name||j.has(a.name)||(j.add(a.name),i.push(a));let k=a.request?.contents?.map(a=>{if(!a.parts)return a;let b=a.parts.map(a=>a.functionCall&&!h.J5.has(a.functionCall.name)?{...a,functionCall:{...a.functionCall,name:`${a.functionCall.name}${h.QH}`}}:a.functionResponse&&!h.J5.has(a.functionResponse.name)?{...a,functionResponse:{...a.functionResponse,name:`${a.functionResponse.name}${h.QH}`}}:a);return{...a,parts:b}});return{cloakedBody:{...a,request:{...a.request,tools:[{functionDeclarations:i}],contents:k||a.request.contents}},toolNameMap:e}}}let n=[{name:"browser_subagent",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"command_status",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"find_by_name",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"generate_image",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"grep_search",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"list_dir",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"list_resources",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"mcp_sequential-thinking_sequentialthinking",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"multi_replace_file_content",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"notify_user",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"read_resource",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"read_terminal",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"read_url_content",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"replace_file_content",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"run_command",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"search_web",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"send_command_input",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"task_boundary",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"view_content_chunk",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"view_file",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"write_to_file",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}}]},39551:(a,b,c)=>{c.r(b),c.d(b,{ollamaBodyToOpenAI:()=>i,ollamaToOpenAI:()=>f});var d=c(33110),e=c(14170);function f(a,b){if(!a||"object"!=typeof a)return null;b.ollama||(b.ollama={id:`chatcmpl-${Date.now()}`,created:Math.floor(Date.now()/1e3),model:a.model||b.model});let{id:c,created:d,model:e}=b.ollama;if(a.done){let f=g(a),h="stop";return("tool_calls"===a.done_reason||b.hadToolCalls)&&(h="tool_calls"),{id:c,object:"chat.completion.chunk",created:d,model:e,choices:[{index:0,delta:{},finish_reason:h}],usage:f}}let f=a.message;if(!f)return null;let i="string"==typeof f.content?f.content:"",j="string"==typeof f.thinking?f.thinking:"",k=Array.isArray(f.tool_calls)?f.tool_calls:null;if(!i&&!j&&!k)return null;i&&(b.accumulatedContent=(b.accumulatedContent||"")+i),j&&(b.accumulatedThinking=(b.accumulatedThinking||"")+j);let l={};return i&&(l.content=i),j&&(l.reasoning_content=j),k&&(b.hadToolCalls=!0,l.tool_calls=h(k)),{id:c,object:"chat.completion.chunk",created:d,model:e,choices:[{index:0,delta:l,finish_reason:null}]}}function g(a){return{prompt_tokens:a.prompt_eval_count||0,completion_tokens:a.eval_count||0,total_tokens:(a.prompt_eval_count||0)+(a.eval_count||0)}}function h(a){return a.map((a,b)=>({index:a.function?.index??b,id:a.id||`call_${b}_${Date.now()}`,type:"function",function:{name:a.function?.name||"",arguments:"string"==typeof a.function?.arguments?a.function.arguments:JSON.stringify(a.function?.arguments||{})}}))}function i(a){let b=a.message||{},c=b.content||"",d=b.thinking||"",e=Array.isArray(b.tool_calls)?b.tool_calls:[],f={role:"assistant"};c&&(f.content=c),d&&(f.reasoning_content=d),e.length>0&&(f.tool_calls=h(e)),f.content||f.tool_calls||(f.content="");let i=a.done_reason||"stop";return e.length>0&&(i="tool_calls"),{id:`chatcmpl-${Date.now()}`,object:"chat.completion",created:Math.floor(Date.now()/1e3),model:a.model||"ollama",choices:[{index:0,message:f,finish_reason:i}],usage:g(a)}}(0,d.kz)(e.h.OLLAMA,e.h.OPENAI,null,f)},42654:(a,b,c)=>{c.d(b,{m:()=>d});function d(a){return"string"==typeof a?[{type:"message",role:"user",content:[{type:"input_text",text:""===a.trim()?"...":a}]}]:Array.isArray(a)?0===a.length?[{type:"message",role:"user",content:[{type:"input_text",text:"..."}]}]:a:null}},47593:(a,b,c)=>{c.d(b,{KZ:()=>i,S6:()=>f,Yr:()=>m,f6:()=>j,fc:()=>e,kU:()=>g,pT:()=>h,w_:()=>k});let d=["minLength","maxLength","exclusiveMinimum","exclusiveMaximum","pattern","minItems","maxItems","format","default","examples","$schema","$defs","definitions","const","$ref","$comment","additionalProperties","propertyNames","patternProperties","enumDescriptions","anyOf","oneOf","allOf","not","dependencies","dependentSchemas","dependentRequired","title","if","then","else","contentMediaType","contentEncoding","cornerRadius","fillColor","fontFamily","fontSize","fontWeight","gap","padding","strokeColor","strokeThickness","textColor"],e=[{category:"HARM_CATEGORY_HATE_SPEECH",threshold:"OFF"},{category:"HARM_CATEGORY_DANGEROUS_CONTENT",threshold:"OFF"},{category:"HARM_CATEGORY_SEXUALLY_EXPLICIT",threshold:"OFF"},{category:"HARM_CATEGORY_HARASSMENT",threshold:"OFF"},{category:"HARM_CATEGORY_CIVIC_INTEGRITY",threshold:"OFF"}];function f(a){let b=[];if("string"==typeof a)b.push({text:a});else if(Array.isArray(a)){for(let c of a)if("text"===c.type)b.push({text:c.text});else if("image_url"===c.type&&c.image_url?.url?.startsWith("data:")){let a=c.image_url.url,d=a.indexOf(",");if(-1!==d){let c=a.substring(5,d),e=a.substring(d+1),f=c.split(";")[0];b.push({inlineData:{mime_type:f,data:e}})}}else if("image_url"===c.type&&c.image_url?.url&&(c.image_url.url.startsWith("http://")||c.image_url.url.startsWith("https://")))b.push({fileData:{fileUri:c.image_url.url,mimeType:"image/*"}});else if("input_audio"===c.type&&c.input_audio?.data){let a=c.input_audio.format||"wav",d="mp3"===a?"audio/mpeg":`audio/${a}`;b.push({inlineData:{mime_type:d,data:c.input_audio.data}})}else if("audio_url"===c.type&&c.audio_url?.url?.startsWith("data:")){let a=c.audio_url.url,d=a.indexOf(",");if(-1!==d){let c=a.substring(5,d),e=a.substring(d+1),f=c.split(";")[0];b.push({inlineData:{mime_type:f,data:e}})}}}return b}function g(a){return"string"==typeof a?a:Array.isArray(a)?a.filter(a=>"text"===a.type).map(a=>a.text).join(""):""}function h(a){if("string"!=typeof a)return a;try{return JSON.parse(a)}catch{return null}}function i(){return`agent-${crypto.randomUUID()}`}function j(){return crypto.randomUUID()+Date.now().toString()}function k(){let a=["useful","bright","swift","calm","bold"],b=["fuze","wave","spark","flow","core"],c=a[Math.floor(Math.random()*a.length)],d=b[Math.floor(Math.random()*b.length)];return`${c}-${d}-${crypto.randomUUID().slice(0,5)}`}function l(a){let b=0,c=-1;for(let d=0;d<a.length;d++){let e=a[d],f=0,g=e.type;"object"===g||e.properties?f=3:"array"===g||e.items?f=2:g&&"null"!==g&&(f=1),f>c&&(c=f,b=d)}return b}function m(a){return a&&"object"==typeof a&&(!function a(b){if(b&&"object"==typeof b)for(let c of(void 0===b.const||b.enum||(b.enum=[b.const],delete b.const),Object.values(b)))c&&"object"==typeof c&&a(c)}(a),!function a(b){if(b&&"object"==typeof b)for(let c of(b.enum&&Array.isArray(b.enum)&&(b.enum=b.enum.map(a=>String(a)),b.type||(b.type="string")),Object.values(b)))c&&"object"==typeof c&&a(c)}(a),!function a(b){if(b&&"object"==typeof b){if(b.allOf&&Array.isArray(b.allOf)){let a={};for(let c of b.allOf)if(c.properties&&(a.properties||(a.properties={}),Object.assign(a.properties,c.properties)),c.required&&Array.isArray(c.required))for(let b of(a.required||(a.required=[]),c.required))a.required.includes(b)||a.required.push(b);delete b.allOf,a.properties&&(b.properties={...b.properties,...a.properties}),a.required&&(b.required=[...b.required||[],...a.required])}for(let c of Object.values(b))c&&"object"==typeof c&&a(c)}}(a),!function a(b){if(b&&"object"==typeof b){if(b.anyOf&&Array.isArray(b.anyOf)&&b.anyOf.length>0){let a=b.anyOf.filter(a=>a&&"null"!==a.type);if(a.length>0){let c=l(a),d=a[c];delete b.anyOf,Object.assign(b,d)}}if(b.oneOf&&Array.isArray(b.oneOf)&&b.oneOf.length>0){let a=b.oneOf.filter(a=>a&&"null"!==a.type);if(a.length>0){let c=l(a),d=a[c];delete b.oneOf,Object.assign(b,d)}}for(let c of Object.values(b))c&&"object"==typeof c&&a(c)}}(a),!function a(b){if(b&&"object"==typeof b){if(b.type&&Array.isArray(b.type)){let a=b.type.filter(a=>"null"!==a);b.type=a.length>0?a[0]:"string"}for(let c of Object.values(b))c&&"object"==typeof c&&a(c)}}(a),!function a(b){if(b&&"object"==typeof b)for(let c of(b.properties&&!b.type&&(b.type="object"),Object.values(b)))c&&"object"==typeof c&&a(c)}(a),!function a(b,c){if(b&&"object"==typeof b){if(Array.isArray(b)){for(let d of b)a(d,c);return}for(let d of Object.keys(b)){if(c.includes(d)||d.startsWith("x-")){delete b[d];continue}let e=b[d];e&&"object"==typeof e&&a(e,c)}}}(a,d),!function a(b){if(b&&"object"==typeof b){if(b.required&&Array.isArray(b.required)&&b.properties){let a=b.required.filter(a=>Object.prototype.hasOwnProperty.call(b.properties,a));0===a.length?delete b.required:b.required=a}for(let c of Object.values(b))c&&"object"==typeof c&&a(c)}}(a),!function a(b){if(b&&"object"==typeof b)for(let c of("object"!==b.type||b.properties&&0!==Object.keys(b.properties).length||(b.properties={reason:{type:"string",description:"Brief explanation of why you are calling this tool"}},b.required=["reason"]),Object.values(b)))c&&"object"==typeof c&&a(c)}(a)),a}},47723:(a,b,c)=>{c.r(b),c.d(b,{convertCommandCodeToOpenAI:()=>h});var d=c(33110),e=c(14170);function f(a,b,c=null){return{id:a.responseId,object:"chat.completion.chunk",created:a.created,model:a.model,choices:[{index:0,delta:b,finish_reason:c}]}}function g(a){switch(a){case"stop":case"error":return"stop";case"length":return"length";case"tool-calls":case"tool_use":return"tool_calls";case"content-filter":return"content_filter";default:return a||"stop"}}function h(a,b){var c;if(!a)return null;if(a&&"object"==typeof a&&"chat.completion.chunk"===a.object)return a;let d=a;if("string"==typeof a){let b=a.trim();if(!b)return null;let c=b.startsWith("data:")?b.slice(5).trim():b;if(!c||"[DONE]"===c)return null;try{d=JSON.parse(c)}catch{return null}}if(!d||"object"!=typeof d||!d.type)return null;c=d.model,b.responseId||(b.responseId=`chatcmpl-${Date.now()}`,b.created=Math.floor(Date.now()/1e3),b.model=b.model||c||"commandcode",b.chunkIndex=0,b.toolIndex=0,b.toolIndexById=new Map,b.openTools=new Set,b.openText=!1,b.finishReason=null,b.usage=null);let e=[];switch(d.type){case"text-delta":{let a=d.text||d.delta||"";if(!a)break;let c=0===b.chunkIndex?{role:"assistant",content:a}:{content:a};b.chunkIndex++,b.openText=!0,e.push(f(b,c));break}case"reasoning-delta":{let a=d.text||"";if(!a)break;let c=0===b.chunkIndex?{role:"assistant",reasoning_content:a}:{reasoning_content:a};b.chunkIndex++,e.push(f(b,c));break}case"tool-input-start":{let a=d.id||d.toolCallId||`call_${Date.now()}_${b.toolIndex}`,c=b.toolIndexById.get(a);null==c&&(c=b.toolIndex++,b.toolIndexById.set(a,c)),b.openTools.add(a);let g={...0===b.chunkIndex?{role:"assistant"}:{},tool_calls:[{index:c,id:a,type:"function",function:{name:d.toolName||"",arguments:""}}]};b.chunkIndex++,e.push(f(b,g));break}case"tool-input-delta":{let a=d.id||d.toolCallId,c=b.toolIndexById.get(a);if(null==c)break;let g={tool_calls:[{index:c,function:{arguments:d.delta||d.inputTextDelta||""}}]};e.push(f(b,g));break}case"tool-call":{let a=d.toolCallId;if(b.toolIndexById.has(a))break;let c=b.toolIndex++;b.toolIndexById.set(a,c);let g="string"==typeof d.input?d.input:JSON.stringify(d.input??{}),h={...0===b.chunkIndex?{role:"assistant"}:{},tool_calls:[{index:c,id:a,type:"function",function:{name:d.toolName||"",arguments:g}}]};b.chunkIndex++,e.push(f(b,h));break}case"finish-step":b.finishReason=g(d.finishReason),d.usage&&(b.usage=d.usage);break;case"finish":{let a=b.finishReason||g(d.finishReason||"stop"),c=f(b,{},a),h=d.totalUsage||b.usage;h&&(c.usage={prompt_tokens:h.inputTokens??0,completion_tokens:h.outputTokens??0,total_tokens:h.totalTokens??(h.inputTokens??0)+(h.outputTokens??0)}),e.push(c);break}case"error":{b.finishReason="stop";let a=d.error??d.message??"unknown",c="string"==typeof a?a:JSON.stringify(a);e.push(f(b,{content:`
|
|
10
|
+
Respond ONLY with the JSON object, no other text.`)}else"json_object"===a.type&&j.push("You must respond with valid JSON. Respond ONLY with a JSON object, no other text.")}let k={type:"text",text:f.Co};if(j.length>0?h.system=[k,{type:"text",text:j.join("\n"),cache_control:{type:"ephemeral",ttl:"1h"}}]:h.system=[k],b.tools&&Array.isArray(b.tools)){for(let a of(h.tools=[],b.tools)){let b=a.type;if(b&&"function"!==b){h.tools.push(a);continue}let c="function"===b&&a.function?a.function:a,d=c.name,f=""+d;e.set(f,d),h.tools.push({name:f,description:c.description||"",input_schema:c.parameters||c.input_schema||{type:"object",properties:{},required:[]}})}h.tools.length>0&&(h.tools[h.tools.length-1].cache_control={type:"ephemeral",ttl:"1h"})}if(b.tool_choice&&(h.tool_choice=(d=b.tool_choice)?"object"==typeof d&&d.type?d:"auto"===d||"none"===d?{type:"auto"}:"required"===d?{type:"any"}:"object"==typeof d&&d.function?{type:"tool",name:d.function.name}:{type:"auto"}:{type:"auto"}),b.thinking&&(h.thinking={type:b.thinking.type||"enabled",...b.thinking.budget_tokens&&{budget_tokens:b.thinking.budget_tokens},...b.thinking.max_tokens&&{max_tokens:b.thinking.max_tokens}}),b.reasoning_effort&&!h.thinking){let a={none:0,low:4096,medium:8192,high:16384,xhigh:32768}[b.reasoning_effort.toLowerCase()];0===a||a&&(h.thinking={type:"enabled",budget_tokens:a})}return e.size>0&&(h._toolNameMap=e),h}function i(a){return"string"==typeof a?a:Array.isArray(a)?a.filter(a=>"text"===a.type).map(a=>a.text).join("\n"):""}function j(a,b,c){let d=h(a,b,c);return d.system&&Array.isArray(d.system)&&(d.system=d.system.filter(a=>!a.text||!a.text.includes("You are Claude Code")),0===d.system.length&&delete d.system),d.tools&&Array.isArray(d.tools)&&(d.tools=d.tools.map(a=>a.name&&a.name.startsWith("")?{...a,name:a.name.slice(0)}:a)),d.messages&&Array.isArray(d.messages)&&(d.messages=d.messages.map(a=>{if(!a.content||!Array.isArray(a.content))return a;let b=a.content.map(a=>"tool_use"===a.type&&a.name&&a.name.startsWith("")?{...a,name:a.name.slice(0)}:a);return{...a,content:b}})),d}(0,d.kz)(e.h.OPENAI,e.h.CLAUDE,h,null)},29675:(a,b,c)=>{c.r(b),c.d(b,{claudeToOpenAIResponse:()=>g});var d=c(33110),e=c(14170);function f(a,b,c=null){return{id:`chatcmpl-${a.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:a.model,choices:[{index:0,delta:b,finish_reason:c}]}}function g(a,b){if(!a)return null;let c=[];switch(a.type){case"message_start":b.messageId=a.message?.id||`msg_${Date.now()}`,b.model=a.message?.model,b.toolCallIndex=0,c.push(f(b,{role:"assistant"}));break;case"content_block_start":{let d=a.content_block;if(d?.type==="server_tool_use"){b.serverToolBlockIndex=a.index;break}if(d?.type==="text")b.textBlockStarted=!0;else if(d?.type==="thinking")b.inThinkingBlock=!0,b.currentBlockIndex=a.index,c.push(f(b,{content:"<think>"}));else if(d?.type==="tool_use"){let e=b.toolCallIndex++,g=b.toolNameMap?.get(d.name)||d.name,h={index:e,id:d.id,type:"function",function:{name:g,arguments:""}};b.toolCalls.set(a.index,h),c.push(f(b,{tool_calls:[h]}))}break}case"content_block_delta":{if(a.index===b.serverToolBlockIndex)break;let d=a.delta;if(d?.type==="text_delta"&&d.text)c.push(f(b,{content:d.text}));else if(d?.type==="thinking_delta"&&d.thinking)c.push(f(b,{reasoning_content:d.thinking}));else if(d?.type==="input_json_delta"&&d.partial_json){let e=b.toolCalls.get(a.index);e&&(e.function.arguments+=d.partial_json,c.push(f(b,{tool_calls:[{index:e.index,id:e.id,function:{arguments:d.partial_json}}]})))}break}case"content_block_stop":if(a.index===b.serverToolBlockIndex){b.serverToolBlockIndex=-1;break}b.inThinkingBlock&&a.index===b.currentBlockIndex&&(c.push(f(b,{content:"</think>"})),b.inThinkingBlock=!1),b.textBlockStarted=!1,b.thinkingBlockStarted=!1;break;case"message_delta":if(a.usage&&"object"==typeof a.usage){let c="number"==typeof a.usage.input_tokens?a.usage.input_tokens:0,d="number"==typeof a.usage.output_tokens?a.usage.output_tokens:0,e="number"==typeof a.usage.cache_read_input_tokens?a.usage.cache_read_input_tokens:0,f="number"==typeof a.usage.cache_creation_input_tokens?a.usage.cache_creation_input_tokens:0,g=c+e+f;b.usage={prompt_tokens:g,completion_tokens:d,total_tokens:g+d,input_tokens:c,output_tokens:d},e>0&&(b.usage.cache_read_input_tokens=e),f>0&&(b.usage.cache_creation_input_tokens=f)}if(a.delta?.stop_reason){b.finishReason=function(a){switch(a){case"end_turn":case"stop_sequence":default:return"stop";case"max_tokens":return"length";case"tool_use":return"tool_calls"}}(a.delta.stop_reason);let d={id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:{},finish_reason:b.finishReason}]};if(b.usage){d.usage={prompt_tokens:b.usage.prompt_tokens,completion_tokens:b.usage.completion_tokens,total_tokens:b.usage.total_tokens};let a=b.usage.cache_read_input_tokens,c=b.usage.cache_creation_input_tokens;(a>0||c>0)&&(d.usage.prompt_tokens_details={},a>0&&(d.usage.prompt_tokens_details.cached_tokens=a),c>0&&(d.usage.prompt_tokens_details.cache_creation_tokens=c))}c.push(d),b.finishReasonSent=!0}break;case"message_stop":if(!b.finishReasonSent){let a=b.finishReason||(b.toolCalls?.size>0?"tool_calls":"stop"),d=b.usage&&"object"==typeof b.usage?{usage:{prompt_tokens:b.usage.input_tokens||0,completion_tokens:b.usage.output_tokens||0,total_tokens:(b.usage.input_tokens||0)+(b.usage.output_tokens||0)}}:{};c.push({id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:{},finish_reason:a}],...d}),b.finishReasonSent=!0}}return c.length>0?c:null}(0,d.kz)(e.h.CLAUDE,e.h.OPENAI,null,g)},32546:(a,b,c)=>{c.r(b),c.d(b,{geminiToOpenAIResponse:()=>f});var d=c(33110),e=c(14170);function f(a,b){if(!a)return null;let c=a.response||a;if(!c||!c.candidates?.[0])return null;let d=[],e=c.candidates[0],f=e.content;if(b.messageId||(b.messageId=c.responseId||`msg_${Date.now()}`,b.model=c.modelVersion||"gemini",b.functionIndex=0,d.push({id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:{role:"assistant"},finish_reason:null}]})),f?.parts)for(let a of f.parts){let c=a.thoughtSignature||a.thought_signature,e=!0===a.thought;if(c){let c=void 0!==a.text&&""!==a.text,f=!!a.functionCall;if(c&&d.push({id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:e?{reasoning_content:a.text}:{content:a.text},finish_reason:null}]}),f){let c=a.functionCall.name,e=b.toolNameMap?.get(c)||c,f=a.functionCall.args||{},g=b.functionIndex++,h={id:`${e}-${Date.now()}-${g}`,index:g,type:"function",function:{name:e,arguments:JSON.stringify(f)}};b.toolCalls.set(g,h),d.push({id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:{tool_calls:[h]},finish_reason:null}]})}continue}if(void 0!==a.text&&""!==a.text&&d.push({id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:{content:a.text},finish_reason:null}]}),a.functionCall){let c=a.functionCall.name,e=b.toolNameMap?.get(c)||c,f=a.functionCall.args||{},g=b.functionIndex++,h={id:`${e}-${Date.now()}-${g}`,index:g,type:"function",function:{name:e,arguments:JSON.stringify(f)}};b.toolCalls.set(g,h),d.push({id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:{tool_calls:[h]},finish_reason:null}]})}let f=a.inlineData||a.inline_data;if(f?.data){let a=f.mimeType||f.mime_type||"image/png";d.push({id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:{images:[{type:"image_url",image_url:{url:`data:${a};base64,${f.data}`}}]},finish_reason:null}]})}}let g=c.usageMetadata||a.usageMetadata;if(g&&"object"==typeof g){let a="number"==typeof g.cachedContentTokenCount?g.cachedContentTokenCount:0,c="number"==typeof g.promptTokenCount?g.promptTokenCount:0,d="number"==typeof g.thoughtsTokenCount?g.thoughtsTokenCount:0,e="number"==typeof g.candidatesTokenCount?g.candidatesTokenCount:0,f="number"==typeof g.totalTokenCount?g.totalTokenCount:0;0===e&&f>0&&(e=f-c-d)<0&&(e=0),b.usage={prompt_tokens:c,completion_tokens:e+d,total_tokens:f},a>0&&(b.usage.prompt_tokens_details={cached_tokens:a}),d>0&&(b.usage.completion_tokens_details={reasoning_tokens:d})}if(e.finishReason){let a=e.finishReason.toLowerCase();"stop"===a&&b.toolCalls.size>0&&(a="tool_calls");let c={id:`chatcmpl-${b.messageId}`,object:"chat.completion.chunk",created:Math.floor(Date.now()/1e3),model:b.model,choices:[{index:0,delta:{},finish_reason:a}]};b.usage&&(c.usage=b.usage),d.push(c),b.finishReason=a}return d.length>0?d:null}(0,d.kz)(e.h.GEMINI,e.h.OPENAI,null,f),(0,d.kz)(e.h.GEMINI_CLI,e.h.OPENAI,null,f),(0,d.kz)(e.h.ANTIGRAVITY,e.h.OPENAI,null,f),(0,d.kz)(e.h.VERTEX,e.h.OPENAI,null,f)},33110:(a,b,c)=>{c.d(b,{Ws:()=>v,Ai:()=>w,nZ:()=>u,kz:()=>q,GH:()=>s,Y8:()=>t});var d=c(14170);let e=/^[a-zA-Z0-9_-]+$/;function f(a=0,b=0,c=""){let d=c?`_${c.replace(/[^a-zA-Z0-9_-]/g,"")}`:"";return`call_msg${a}_tc${b}${d}`}function g(a){if(!a||"string"!=typeof a)return null;let b=a.replace(/[^a-zA-Z0-9_-]/g,"");return b.length>0?b:null}var h=c(96281);c(3156);var i=c(55399),j=c(80662);let k=new Set(["minimax","minimax-cn"]),l=["text","image_url","image","input_audio","audio_url"];var m=c(57647);c(39536);let n=new Map,o=new Map,p=!1;function q(a,b,c,d){let e=`${a}:${b}`;c&&n.set(e,c),d&&o.set(e,d)}function r(){p||(p=!0,c(60983),c(19979),c(52638),c(97102),c(59611),c(54817),c(65377),c(80198),c(13595),c(74447),c(97821),c(29675),c(66159),c(32546),c(89475),c(4845),c(52830),c(65651),c(39551),c(47723))}function s(a,b,c,o,p=!0,q=null,t=null,u=null,v=[],w=null,x=null){r();let y=o;if(!function(a,b=[]){if(!b.length||!a.messages||!Array.isArray(a.messages))return;let c=new Set(["image_url","image"]),d=new Set(["audio_url","input_audio"]),e=a=>c.has(a)?b.includes("image"):!!d.has(a)&&b.includes("audio");for(let b of a.messages)Array.isArray(b.content)&&(b.content=b.content.filter(a=>!e(a.type)),0===b.content.length&&(b.content=""))}(y,v),(0,m.SZ)(y),!function(a){if(a.messages&&Array.isArray(a.messages))for(let b=0;b<a.messages.length;b++){let c=a.messages[b];if("assistant"===c.role&&c.tool_calls&&Array.isArray(c.tool_calls))for(let a=0;a<c.tool_calls.length;a++){let d=c.tool_calls[a];if(!d.id||!e.test(d.id)){let c=g(d.id);d.id=c||f(b,a,d.function?.name)}d.type||(d.type="function"),d.function?.arguments&&"string"!=typeof d.function.arguments&&(d.function.arguments=JSON.stringify(d.function.arguments))}if("tool"===c.role&&c.tool_call_id&&!e.test(c.tool_call_id)){let a=g(c.tool_call_id);c.tool_call_id=a||f(b,0)}if(Array.isArray(c.content))for(let a=0;a<c.content.length;a++){let d=c.content[a];if("tool_use"===d.type&&d.id&&!e.test(d.id)){let c=g(d.id);d.id=c||f(b,a,d.name)}if("tool_result"===d.type&&d.tool_use_id&&!e.test(d.tool_use_id)){let c=g(d.tool_use_id);d.tool_use_id=c||f(b,a)}}}}(y),!function(a){if(!a.messages||!Array.isArray(a.messages))return;let b=[];for(let c=0;c<a.messages.length;c++){let d=a.messages[c],e=a.messages[c+1];b.push(d);let f=function(a){if("assistant"!==a.role)return[];let b=[];if(a.tool_calls&&Array.isArray(a.tool_calls))for(let c of a.tool_calls)c.id&&b.push(c.id);if(Array.isArray(a.content))for(let c of a.content)"tool_use"===c.type&&c.id&&b.push(c.id);return b}(d);if(0!==f.length&&e&&!function(a,b){if(!a||!b.length)return!1;if("tool"===a.role&&a.tool_call_id)return b.includes(a.tool_call_id);if("user"===a.role&&Array.isArray(a.content)){for(let c of a.content)if("tool_result"===c.type&&b.includes(c.tool_use_id))return!0}return!1}(e,f))for(let a of f)b.push({role:"tool",tool_call_id:a,content:""})}a.messages=b}(y),a!==b){if(a!==d.h.OPENAI){let b=n.get(`${a}:${d.h.OPENAI}`);b&&(y=b(c,y,p,q),u?.logOpenAIRequest?.(y))}if(b!==d.h.OPENAI){let a=n.get(`${d.h.OPENAI}:${b}`);a&&(y=a(c,y,p,q))}}if(b===d.h.OPENAI&&(y=function(a){if(!a.messages||!Array.isArray(a.messages))return a;if(a.messages=a.messages.map(a=>{if("tool"===a.role||"assistant"===a.role&&a.tool_calls||"string"==typeof a.content)return a;if(Array.isArray(a.content)){let b=[];for(let c of a.content)if("thinking"!==c.type&&"redacted_thinking"!==c.type){if(l.includes(c.type)){let{signature:a,cache_control:d,...e}=c;b.push(e)}else if("tool_use"===c.type)continue;else if("tool_result"===c.type){let{signature:a,cache_control:d,...e}=c;b.push(e)}}return 0===b.length&&b.push({type:"text",text:""}),{...a,content:b}}return a}),a.messages=a.messages.filter(a=>"tool"===a.role||"assistant"===a.role&&!!a.tool_calls||("string"==typeof a.content?""!==a.content.trim():!Array.isArray(a.content)||a.content.some(a=>"text"===a.type&&a.text?.trim()||"text"!==a.type))),a.tools&&Array.isArray(a.tools)&&0===a.tools.length&&delete a.tools,a.tools&&Array.isArray(a.tools)&&a.tools.length>0&&(a.tools=a.tools.map(a=>"function"===a.type&&a.function?a:a.name&&(a.input_schema||a.description)?{type:"function",function:{name:a.name,description:String(a.description||""),parameters:a.input_schema||{type:"object",properties:{}}}}:a.functionDeclarations&&Array.isArray(a.functionDeclarations)?a.functionDeclarations.map(a=>({type:"function",function:{name:a.name,description:String(a.description||""),parameters:a.parameters||{type:"object",properties:{}}}})):a).flat()),a.tool_choice&&"object"==typeof a.tool_choice){let b=a.tool_choice;"auto"===b.type?a.tool_choice="auto":"any"===b.type?a.tool_choice="required":"tool"===b.type&&b.name&&(a.tool_choice={type:"function",function:{name:b.name}})}return a}(y)),b===d.h.CLAUDE&&(y=function(a,b=null,c=null,d=null){if(k.has(b)&&delete a.output_config,a.system&&Array.isArray(a.system)&&(a.system=a.system.map((b,c)=>{let{cache_control:d,...e}=b;return c===a.system.length-1?{...e,cache_control:{type:"ephemeral",ttl:"1h"}}:e})),a.messages&&Array.isArray(a.messages)){let c=a.messages.length,d=[];for(let b=0;b<c;b++){let e=a.messages[b];if(Array.isArray(e.content))for(let a of e.content)delete a.cache_control;(b===c-1&&"assistant"===e.role||"string"==typeof e.content&&e.content.trim()||Array.isArray(e.content)&&e.content.some(a=>"text"===a.type&&a.text?.trim()||"tool_use"===a.type||"tool_result"===a.type))&&d.push(e)}d=function(a){if(a.length<=1)return a;for(let b of a)if("assistant"===b.role&&Array.isArray(b.content)&&b.content.some(a=>"tool_use"===a.type)){let a=[],c=!1;for(let d of b.content)"tool_use"===d.type?(c=!0,a.push(d)):"thinking"===d.type||"redacted_thinking"===d.type?a.push(d):c||a.push(d);b.content=a}let b=[];for(let c of a){let a=b[b.length-1];if(a&&a.role===c.role){let b=Array.isArray(a.content)?a.content:[{type:"text",text:a.content}],d=Array.isArray(c.content)?c.content:[{type:"text",text:c.content}];a.content=[...b.filter(a=>"tool_result"===a.type),...d.filter(a=>"tool_result"===a.type),...b.filter(a=>"tool_result"!==a.type),...d.filter(a=>"tool_result"!==a.type)]}else{let a=Array.isArray(c.content)?c.content:[{type:"text",text:c.content}];b.push({role:c.role,content:[...a]})}}return b}(d),a.messages=d;let e=d[d.length-1],f=e?.role==="user",g=a.thinking?.type==="enabled"&&f,i=!1;for(let a=d.length-1;a>=0;a--){let c=d[a];if("assistant"===c.role&&Array.isArray(c.content)){if(!i&&c.content.length>0){for(let a=c.content.length-1;a>=0;a--){let b=c.content[a];if("thinking"!==b.type&&"redacted_thinking"!==b.type){b.cache_control={type:"ephemeral"};break}}i=!0}if("claude"===b||b?.startsWith("anthropic-compatible")){let a=!1,b=!1;for(let d of c.content)("thinking"===d.type||"redacted_thinking"===d.type)&&(d.signature=h.xr,b=!0),"tool_use"===d.type&&(a=!0);g&&!b&&a&&c.content.unshift({type:"thinking",thinking:".",signature:h.xr})}}}}if(a.tools&&Array.isArray(a.tools)&&("claude"!==b&&(a.tools=a.tools.filter(a=>!a.type||"function"===a.type)),a.tools=a.tools.map((b,c)=>{let{cache_control:d,...e}=b;return c===a.tools.length-1?{...e,cache_control:{type:"ephemeral",ttl:"1h"}}:e}),0===a.tools.length&&(delete a.tools,delete a.tool_choice)),("claude"===b||b?.startsWith("anthropic-compatible"))&&c){let b=d?(0,j.RF)(d):null;a=(0,i.fO)(a,c,b)}return a}(y,t,q?.accessToken||q?.apiKey||null,w)),"claude"===t){let a=q?.accessToken||q?.apiKey||null;if(a?.includes("sk-ant-oat")){let{body:a,toolNameMap:b}=(0,i.Az)(y);y=a,b?.size>0&&(y._toolNameMap=b)}}return y}function t(a,b,c,e){if(r(),b===a)return[c];let f=[c],g=null;if(a!==d.h.OPENAI){let b=o.get(`${a}:${d.h.OPENAI}`);if(b){f=[];let a=b(c,e);a&&(g=f=Array.isArray(a)?a:[a])}}if(b!==d.h.OPENAI){let a=o.get(`${d.h.OPENAI}:${b}`);if(a){let b=[];for(let c of f){let d=a(c,e);d&&b.push(...Array.isArray(d)?d:[d])}f=b}}return g&&b!==d.h.OPENAI&&a!==d.h.OPENAI&&(f._openaiIntermediate=g),f}function u(a,b){return a!==b}function v(a){let b={messageId:null,model:null,textBlockStarted:!1,thinkingBlockStarted:!1,inThinkingBlock:!1,currentBlockIndex:null,toolCalls:new Map,finishReason:null,finishReasonSent:!1,usage:null,contentBlockIndex:-1};return a===d.h.OPENAI_RESPONSES?{...b,seq:0,responseId:`resp_${Date.now()}`,created:Math.floor(Date.now()/1e3),started:!1,msgTextBuf:{},msgItemAdded:{},msgContentAdded:{},msgItemDone:{},reasoningId:"",reasoningIndex:-1,reasoningBuf:"",reasoningPartAdded:!1,reasoningDone:!1,inThinking:!1,funcArgsBuf:{},funcNames:{},funcCallIds:{},funcArgsDone:{},funcItemDone:{},completedSent:!1}:b}function w(){r()}},39006:a=>{a.exports={rE:"0.4.25"}},39536:(a,b,c)=>{c.d(b,{c:()=>m});var d=c(55511),e=c.n(d),f=c(74957),g=c(35024),h=c(75924),i=c(41004),j=c(80662),k=c(39609),l=c(47593);class m extends f.H{constructor(){super("antigravity",g.xq.antigravity)}buildUrl(a,b,c=0){let d=this.getBaseUrls(),e=d[c]||d[0];return`${e}/v1internal:${b?"streamGenerateContent?alt=sse":"generateContent"}`}buildHeaders(a,b=!0,c=null){return{"Content-Type":"application/json",Authorization:`Bearer ${a.accessToken}`,"User-Agent":this.config.headers?.["User-Agent"]||h.K["User-Agent"],[h.Ox.name]:h.Ox.value,...c&&{"X-Machine-Session-Id":c},Accept:b?"text/event-stream":"application/json"}}transformRequest(a,b,c,d){let f=d?.projectId||this.generateProjectId(),g=b.request?.contents?.map(a=>{let b=a.role;a.parts?.some(a=>a.functionResponse)&&(b="user");let c=a.parts?.filter(a=>(!a.thought||!!a.functionCall)&&(!a.thoughtSignature||!!a.functionCall||!!a.text));return b!==a.role||c?.length!==a.parts?.length?{...a,role:b,parts:c}:a}),h=b.request?.tools;if(h&&h.length>0){let a=h.flatMap(a=>(a.functionDeclarations||[]).map(a=>({...a,name:function(a){if(!a)return"_unknown";let b=a.replace(/[^a-zA-Z0-9_.:\-]/g,"_");return/^[a-zA-Z_]/.test(b)||(b="_"+b),b.substring(0,64)}(a.name),parameters:a.parameters?(0,l.Yr)(structuredClone(a.parameters)):{type:"object",properties:{reason:{type:"string",description:"Brief explanation"}},required:["reason"]}})));h=a.length>0?[{functionDeclarations:a}]:[]}let{tools:i,toolConfig:k,...m}=b.request||{},n={...m.generationConfig||{}};n.maxOutputTokens>16384&&(n.maxOutputTokens=16384);let o={...m,generationConfig:n,...g&&{contents:g},...h&&{tools:h},sessionId:b.request?.sessionId||(0,j.RF)(d?.email||d?.connectionId),safetySettings:void 0,...h?.length>0&&{toolConfig:{functionCallingConfig:{mode:"VALIDATED"}}}};return{...b,project:f,model:a,userAgent:"antigravity",requestType:"agent",requestId:`agent-${e().randomUUID()}`,request:o}}async refreshCredentials(a,b,c=null){if(!a.refreshToken)return null;try{let d=await (0,k.proxyAwareFetch)(h.NA.google.token,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:new URLSearchParams({grant_type:"refresh_token",refresh_token:a.refreshToken,client_id:this.config.clientId,client_secret:this.config.clientSecret})},c);if(!d.ok)return null;let e=await d.json();return b?.info?.("TOKEN","Antigravity refreshed"),{accessToken:e.access_token,refreshToken:e.refresh_token||a.refreshToken,expiresIn:e.expires_in,projectId:a.projectId}}catch(a){return b?.error?.("TOKEN",`Antigravity refresh error: ${a.message}`),null}}generateProjectId(){let a=["useful","bright","swift","calm","bold"][Math.floor(5*Math.random())],b=["fuze","wave","spark","flow","core"][Math.floor(5*Math.random())];return`${a}-${b}-${e().randomUUID().slice(0,5)}`}generateSessionId(){return e().randomUUID()+Date.now().toString()}parseRetryHeaders(a){if(!a?.get)return null;let b=a.get("retry-after");if(b){let a=parseInt(b,10);if(!isNaN(a)&&a>0)return 1e3*a;let c=new Date(b);if(!isNaN(c.getTime())){let a=c.getTime()-Date.now();return a>0?a:null}}let c=a.get("x-ratelimit-reset-after");if(c){let a=parseInt(c,10);if(!isNaN(a)&&a>0)return 1e3*a}let d=a.get("x-ratelimit-reset");if(d){let a=1e3*parseInt(d,10)-Date.now();return a>0?a:null}return null}parseRetryFromErrorMessage(a){if(!a||"string"!=typeof a)return null;let b=a.match(/reset after (\d+h)?(\d+m)?(\d+s)?/i);if(!b)return null;let c=0;return b[1]&&(c+=3600*parseInt(b[1])*1e3),b[2]&&(c+=60*parseInt(b[2])*1e3),b[3]&&(c+=1e3*parseInt(b[3])),c>0?c:null}async execute({model:a,body:b,stream:c,credentials:d,signal:e,log:f,proxyOptions:g=null}){let h=this.getFallbackCount(),j=null,l=0,m={},n={};for(let o=0;o<h;o++){let p=this.buildUrl(a,c,o),q=this.transformRequest(a,b,c,d),r=q.request?.sessionId,s=this.buildHeaders(d,c,r);m[o]||(m[o]=0),n[o]||(n[o]=0);try{let a=await (0,k.proxyAwareFetch)(p,{method:"POST",headers:s,body:JSON.stringify(q),signal:e},g);if(a.status===i.gx.RATE_LIMITED||a.status===i.gx.SERVICE_UNAVAILABLE){let b=this.parseRetryHeaders(a.headers);if(!b)try{let c=await a.clone().text(),d=JSON.parse(c),e=d?.error?.message||d?.message||"";b=this.parseRetryFromErrorMessage(e)}catch(a){}if(b&&b<=1e4&&n[o]<3){n[o]++,f?.debug?.("RETRY",`${a.status} with Retry-After: ${Math.ceil(b/1e3)}s, waiting... (${n[o]}/3)`),await new Promise(a=>setTimeout(a,b)),o--;continue}if(a.status===i.gx.RATE_LIMITED&&(!b||0===b)&&m[o]<3){m[o]++;let a=Math.min(1e3*2**m[o],1e4);f?.debug?.("RETRY",`429 auto retry ${m[o]}/3 after ${a/1e3}s`),await new Promise(b=>setTimeout(b,a)),o--;continue}if(f?.debug?.("RETRY",`${a.status}, Retry-After ${b?`too long (${Math.ceil(b/1e3)}s)`:"missing"}, trying fallback`),l=a.status,o+1<h)continue}if(this.shouldRetry(a.status,o)){f?.debug?.("RETRY",`${a.status} on ${p}, trying fallback ${o+1}`),l=a.status;continue}return{response:a,url:p,headers:s,transformedBody:q}}catch(a){if(j=a,o+1<h){f?.debug?.("RETRY",`Error on ${p}, trying fallback ${o+1}`);continue}throw a}}throw j||Error(`All ${h} URLs failed with status ${l}`)}static cloakTools(a,b=null){let c=a.request?.tools;if(!c||0===c.length)return{cloakedBody:a,toolNameMap:null};let d="github-copilot"===b,e=new Map,f=[],g=new Set(n.map(a=>a.name));for(let a of c)if(a.functionDeclarations)for(let b of a.functionDeclarations){if(d&&h.J5.has(b.name)||d&&g.has(b.name))continue;if(h.J5.has(b.name)){f.push(b);continue}let a=`${b.name}${h.QH}`;e.set(a,b.name),f.push({...b,name:a})}let i=[],j=new Set;for(let a of[...f,...n])!a?.name||j.has(a.name)||(j.add(a.name),i.push(a));let k=a.request?.contents?.map(a=>{if(!a.parts)return a;let b=a.parts.map(a=>a.functionCall&&!h.J5.has(a.functionCall.name)?{...a,functionCall:{...a.functionCall,name:`${a.functionCall.name}${h.QH}`}}:a.functionResponse&&!h.J5.has(a.functionResponse.name)?{...a,functionResponse:{...a.functionResponse,name:`${a.functionResponse.name}${h.QH}`}}:a);return{...a,parts:b}});return{cloakedBody:{...a,request:{...a.request,tools:[{functionDeclarations:i}],contents:k||a.request.contents}},toolNameMap:e}}}let n=[{name:"browser_subagent",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"command_status",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"find_by_name",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"generate_image",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"grep_search",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"list_dir",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"list_resources",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"mcp_sequential-thinking_sequentialthinking",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"multi_replace_file_content",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"notify_user",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"read_resource",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"read_terminal",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"read_url_content",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"replace_file_content",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"run_command",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"search_web",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"send_command_input",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"task_boundary",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"view_content_chunk",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"view_file",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}},{name:"write_to_file",description:"This tool is currently unavailable.",parameters:{type:"OBJECT",properties:{},required:[]}}]},39551:(a,b,c)=>{c.r(b),c.d(b,{ollamaBodyToOpenAI:()=>i,ollamaToOpenAI:()=>f});var d=c(33110),e=c(14170);function f(a,b){if(!a||"object"!=typeof a)return null;b.ollama||(b.ollama={id:`chatcmpl-${Date.now()}`,created:Math.floor(Date.now()/1e3),model:a.model||b.model});let{id:c,created:d,model:e}=b.ollama;if(a.done){let f=g(a),h="stop";return("tool_calls"===a.done_reason||b.hadToolCalls)&&(h="tool_calls"),{id:c,object:"chat.completion.chunk",created:d,model:e,choices:[{index:0,delta:{},finish_reason:h}],usage:f}}let f=a.message;if(!f)return null;let i="string"==typeof f.content?f.content:"",j="string"==typeof f.thinking?f.thinking:"",k=Array.isArray(f.tool_calls)?f.tool_calls:null;if(!i&&!j&&!k)return null;i&&(b.accumulatedContent=(b.accumulatedContent||"")+i),j&&(b.accumulatedThinking=(b.accumulatedThinking||"")+j);let l={};return i&&(l.content=i),j&&(l.reasoning_content=j),k&&(b.hadToolCalls=!0,l.tool_calls=h(k)),{id:c,object:"chat.completion.chunk",created:d,model:e,choices:[{index:0,delta:l,finish_reason:null}]}}function g(a){return{prompt_tokens:a.prompt_eval_count||0,completion_tokens:a.eval_count||0,total_tokens:(a.prompt_eval_count||0)+(a.eval_count||0)}}function h(a){return a.map((a,b)=>({index:a.function?.index??b,id:a.id||`call_${b}_${Date.now()}`,type:"function",function:{name:a.function?.name||"",arguments:"string"==typeof a.function?.arguments?a.function.arguments:JSON.stringify(a.function?.arguments||{})}}))}function i(a){let b=a.message||{},c=b.content||"",d=b.thinking||"",e=Array.isArray(b.tool_calls)?b.tool_calls:[],f={role:"assistant"};c&&(f.content=c),d&&(f.reasoning_content=d),e.length>0&&(f.tool_calls=h(e)),f.content||f.tool_calls||(f.content="");let i=a.done_reason||"stop";return e.length>0&&(i="tool_calls"),{id:`chatcmpl-${Date.now()}`,object:"chat.completion",created:Math.floor(Date.now()/1e3),model:a.model||"ollama",choices:[{index:0,message:f,finish_reason:i}],usage:g(a)}}(0,d.kz)(e.h.OLLAMA,e.h.OPENAI,null,f)},42654:(a,b,c)=>{c.d(b,{m:()=>d});function d(a){return"string"==typeof a?[{type:"message",role:"user",content:[{type:"input_text",text:""===a.trim()?"...":a}]}]:Array.isArray(a)?0===a.length?[{type:"message",role:"user",content:[{type:"input_text",text:"..."}]}]:a:null}},47593:(a,b,c)=>{c.d(b,{KZ:()=>i,S6:()=>f,Yr:()=>m,f6:()=>j,fc:()=>e,kU:()=>g,pT:()=>h,w_:()=>k});let d=["minLength","maxLength","exclusiveMinimum","exclusiveMaximum","pattern","minItems","maxItems","format","default","examples","$schema","$defs","definitions","const","$ref","$comment","additionalProperties","propertyNames","patternProperties","enumDescriptions","anyOf","oneOf","allOf","not","dependencies","dependentSchemas","dependentRequired","title","if","then","else","contentMediaType","contentEncoding","cornerRadius","fillColor","fontFamily","fontSize","fontWeight","gap","padding","strokeColor","strokeThickness","textColor"],e=[{category:"HARM_CATEGORY_HATE_SPEECH",threshold:"OFF"},{category:"HARM_CATEGORY_DANGEROUS_CONTENT",threshold:"OFF"},{category:"HARM_CATEGORY_SEXUALLY_EXPLICIT",threshold:"OFF"},{category:"HARM_CATEGORY_HARASSMENT",threshold:"OFF"},{category:"HARM_CATEGORY_CIVIC_INTEGRITY",threshold:"OFF"}];function f(a){let b=[];if("string"==typeof a)b.push({text:a});else if(Array.isArray(a)){for(let c of a)if("text"===c.type)b.push({text:c.text});else if("image_url"===c.type&&c.image_url?.url?.startsWith("data:")){let a=c.image_url.url,d=a.indexOf(",");if(-1!==d){let c=a.substring(5,d),e=a.substring(d+1),f=c.split(";")[0];b.push({inlineData:{mime_type:f,data:e}})}}else if("image_url"===c.type&&c.image_url?.url&&(c.image_url.url.startsWith("http://")||c.image_url.url.startsWith("https://")))b.push({fileData:{fileUri:c.image_url.url,mimeType:"image/*"}});else if("input_audio"===c.type&&c.input_audio?.data){let a=c.input_audio.format||"wav",d="mp3"===a?"audio/mpeg":`audio/${a}`;b.push({inlineData:{mime_type:d,data:c.input_audio.data}})}else if("audio_url"===c.type&&c.audio_url?.url?.startsWith("data:")){let a=c.audio_url.url,d=a.indexOf(",");if(-1!==d){let c=a.substring(5,d),e=a.substring(d+1),f=c.split(";")[0];b.push({inlineData:{mime_type:f,data:e}})}}}return b}function g(a){return"string"==typeof a?a:Array.isArray(a)?a.filter(a=>"text"===a.type).map(a=>a.text).join(""):""}function h(a){if("string"!=typeof a)return a;try{return JSON.parse(a)}catch{return null}}function i(){return`agent-${crypto.randomUUID()}`}function j(){return crypto.randomUUID()+Date.now().toString()}function k(){let a=["useful","bright","swift","calm","bold"],b=["fuze","wave","spark","flow","core"],c=a[Math.floor(Math.random()*a.length)],d=b[Math.floor(Math.random()*b.length)];return`${c}-${d}-${crypto.randomUUID().slice(0,5)}`}function l(a){let b=0,c=-1;for(let d=0;d<a.length;d++){let e=a[d],f=0,g=e.type;"object"===g||e.properties?f=3:"array"===g||e.items?f=2:g&&"null"!==g&&(f=1),f>c&&(c=f,b=d)}return b}function m(a){return a&&"object"==typeof a&&(!function a(b){if(b&&"object"==typeof b)for(let c of(void 0===b.const||b.enum||(b.enum=[b.const],delete b.const),Object.values(b)))c&&"object"==typeof c&&a(c)}(a),!function a(b){if(b&&"object"==typeof b)for(let c of(b.enum&&Array.isArray(b.enum)&&(b.enum=b.enum.map(a=>String(a)),b.type||(b.type="string")),Object.values(b)))c&&"object"==typeof c&&a(c)}(a),!function a(b){if(b&&"object"==typeof b){if(b.allOf&&Array.isArray(b.allOf)){let a={};for(let c of b.allOf)if(c.properties&&(a.properties||(a.properties={}),Object.assign(a.properties,c.properties)),c.required&&Array.isArray(c.required))for(let b of(a.required||(a.required=[]),c.required))a.required.includes(b)||a.required.push(b);delete b.allOf,a.properties&&(b.properties={...b.properties,...a.properties}),a.required&&(b.required=[...b.required||[],...a.required])}for(let c of Object.values(b))c&&"object"==typeof c&&a(c)}}(a),!function a(b){if(b&&"object"==typeof b){if(b.anyOf&&Array.isArray(b.anyOf)&&b.anyOf.length>0){let a=b.anyOf.filter(a=>a&&"null"!==a.type);if(a.length>0){let c=l(a),d=a[c];delete b.anyOf,Object.assign(b,d)}}if(b.oneOf&&Array.isArray(b.oneOf)&&b.oneOf.length>0){let a=b.oneOf.filter(a=>a&&"null"!==a.type);if(a.length>0){let c=l(a),d=a[c];delete b.oneOf,Object.assign(b,d)}}for(let c of Object.values(b))c&&"object"==typeof c&&a(c)}}(a),!function a(b){if(b&&"object"==typeof b){if(b.type&&Array.isArray(b.type)){let a=b.type.filter(a=>"null"!==a);b.type=a.length>0?a[0]:"string"}for(let c of Object.values(b))c&&"object"==typeof c&&a(c)}}(a),!function a(b){if(b&&"object"==typeof b)for(let c of(b.properties&&!b.type&&(b.type="object"),Object.values(b)))c&&"object"==typeof c&&a(c)}(a),!function a(b,c){if(b&&"object"==typeof b){if(Array.isArray(b)){for(let d of b)a(d,c);return}for(let d of Object.keys(b)){if(c.includes(d)||d.startsWith("x-")){delete b[d];continue}let e=b[d];e&&"object"==typeof e&&a(e,c)}}}(a,d),!function a(b){if(b&&"object"==typeof b){if(b.required&&Array.isArray(b.required)&&b.properties){let a=b.required.filter(a=>Object.prototype.hasOwnProperty.call(b.properties,a));0===a.length?delete b.required:b.required=a}for(let c of Object.values(b))c&&"object"==typeof c&&a(c)}}(a),!function a(b){if(b&&"object"==typeof b)for(let c of("object"!==b.type||b.properties&&0!==Object.keys(b.properties).length||(b.properties={reason:{type:"string",description:"Brief explanation of why you are calling this tool"}},b.required=["reason"]),Object.values(b)))c&&"object"==typeof c&&a(c)}(a)),a}},47723:(a,b,c)=>{c.r(b),c.d(b,{convertCommandCodeToOpenAI:()=>h});var d=c(33110),e=c(14170);function f(a,b,c=null){return{id:a.responseId,object:"chat.completion.chunk",created:a.created,model:a.model,choices:[{index:0,delta:b,finish_reason:c}]}}function g(a){switch(a){case"stop":case"error":return"stop";case"length":return"length";case"tool-calls":case"tool_use":return"tool_calls";case"content-filter":return"content_filter";default:return a||"stop"}}function h(a,b){var c;if(!a)return null;if(a&&"object"==typeof a&&"chat.completion.chunk"===a.object)return a;let d=a;if("string"==typeof a){let b=a.trim();if(!b)return null;let c=b.startsWith("data:")?b.slice(5).trim():b;if(!c||"[DONE]"===c)return null;try{d=JSON.parse(c)}catch{return null}}if(!d||"object"!=typeof d||!d.type)return null;c=d.model,b.responseId||(b.responseId=`chatcmpl-${Date.now()}`,b.created=Math.floor(Date.now()/1e3),b.model=b.model||c||"commandcode",b.chunkIndex=0,b.toolIndex=0,b.toolIndexById=new Map,b.openTools=new Set,b.openText=!1,b.finishReason=null,b.usage=null);let e=[];switch(d.type){case"text-delta":{let a=d.text||d.delta||"";if(!a)break;let c=0===b.chunkIndex?{role:"assistant",content:a}:{content:a};b.chunkIndex++,b.openText=!0,e.push(f(b,c));break}case"reasoning-delta":{let a=d.text||"";if(!a)break;let c=0===b.chunkIndex?{role:"assistant",reasoning_content:a}:{reasoning_content:a};b.chunkIndex++,e.push(f(b,c));break}case"tool-input-start":{let a=d.id||d.toolCallId||`call_${Date.now()}_${b.toolIndex}`,c=b.toolIndexById.get(a);null==c&&(c=b.toolIndex++,b.toolIndexById.set(a,c)),b.openTools.add(a);let g={...0===b.chunkIndex?{role:"assistant"}:{},tool_calls:[{index:c,id:a,type:"function",function:{name:d.toolName||"",arguments:""}}]};b.chunkIndex++,e.push(f(b,g));break}case"tool-input-delta":{let a=d.id||d.toolCallId,c=b.toolIndexById.get(a);if(null==c)break;let g={tool_calls:[{index:c,function:{arguments:d.delta||d.inputTextDelta||""}}]};e.push(f(b,g));break}case"tool-call":{let a=d.toolCallId;if(b.toolIndexById.has(a))break;let c=b.toolIndex++;b.toolIndexById.set(a,c);let g="string"==typeof d.input?d.input:JSON.stringify(d.input??{}),h={...0===b.chunkIndex?{role:"assistant"}:{},tool_calls:[{index:c,id:a,type:"function",function:{name:d.toolName||"",arguments:g}}]};b.chunkIndex++,e.push(f(b,h));break}case"finish-step":b.finishReason=g(d.finishReason),d.usage&&(b.usage=d.usage);break;case"finish":{let a=b.finishReason||g(d.finishReason||"stop"),c=f(b,{},a),h=d.totalUsage||b.usage;h&&(c.usage={prompt_tokens:h.inputTokens??0,completion_tokens:h.outputTokens??0,total_tokens:h.totalTokens??(h.inputTokens??0)+(h.outputTokens??0)}),e.push(c);break}case"error":{b.finishReason="stop";let a=d.error??d.message??"unknown",c="string"==typeof a?a:JSON.stringify(a);e.push(f(b,{content:`
|
|
11
11
|
|
|
12
12
|
[CommandCode error: ${c}]`})),e.push(f(b,{},"stop"))}}return e.length?e:null}(0,d.kz)(e.h.COMMANDCODE,e.h.OPENAI,null,h)},52638:(a,b,c)=>{c.r(b),c.d(b,{geminiToOpenAIRequest:()=>g});var d=c(33110),e=c(14170),f=c(3156);function g(a,b,c){let d={model:a,messages:[],stream:c};if(b.generationConfig){let a=b.generationConfig;if(a.maxOutputTokens){let c={max_tokens:a.maxOutputTokens,tools:b.tools};d.max_tokens=(0,f.M)(c)}void 0!==a.temperature&&(d.temperature=a.temperature),void 0!==a.topP&&(d.top_p=a.topP)}if(b.systemInstruction){var e;let a="string"==typeof(e=b.systemInstruction)?e:e.parts&&Array.isArray(e.parts)?e.parts.map(a=>a.text||"").join(""):"";a&&d.messages.push({role:"system",content:a})}if(b.contents&&Array.isArray(b.contents))for(let a of b.contents){let b=function(a){let b="user"===a.role?"user":"assistant";if(!a.parts||!Array.isArray(a.parts))return null;let c=[],d=[];for(let b of a.parts)if(void 0!==b.text&&c.push({type:"text",text:b.text}),b.inlineData&&c.push({type:"image_url",image_url:{url:`data:${b.inlineData.mimeType};base64,${b.inlineData.data}`}}),b.functionCall&&d.push({id:`call_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,type:"function",function:{name:b.functionCall.name,arguments:JSON.stringify(b.functionCall.args||{})}}),b.functionResponse)return{role:"tool",tool_call_id:b.functionResponse.id||b.functionResponse.name,content:JSON.stringify(b.functionResponse.response?.result||b.functionResponse.response||{})};if(d.length>0){let a={role:"assistant"};return c.length>0&&(a.content=1===c.length?c[0].text:c),a.tool_calls=d,a}return c.length>0?{role:b,content:1===c.length&&"text"===c[0].type?c[0].text:c}:null}(a);b&&d.messages.push(b)}if(b.tools&&Array.isArray(b.tools)){for(let a of(d.tools=[],b.tools))if(a.functionDeclarations)for(let b of a.functionDeclarations)d.tools.push({type:"function",function:{name:b.name,description:b.description||"",parameters:b.parameters||{type:"object",properties:{}}}})}return d}(0,d.kz)(e.h.GEMINI,e.h.OPENAI,g,null),(0,d.kz)(e.h.GEMINI_CLI,e.h.OPENAI,g,null)},52830:(a,b,c)=>{c.r(b),c.d(b,{convertKiroToOpenAI:()=>f});var d=c(33110),e=c(14170);function f(a,b){if(!a)return null;if("chat.completion.chunk"===a.object&&a.choices)return a;let c=a;if("string"==typeof a){let b=a.split("\n"),d="",e="";for(let a of b)a.startsWith("event:")?d=a.slice(6).trim():a.startsWith(":event-type:")?d=a.slice(12).trim():a.startsWith("data:")?e=a.slice(5).trim():a.startsWith(":content-type:")||a.trim()&&!a.startsWith(":")&&(e=a.trim());if(!e)return null;try{(c=JSON.parse(e))._eventType=d}catch{c={text:e,_eventType:d}}}b.responseId||(b.responseId=`chatcmpl-${Date.now()}`,b.created=Math.floor(Date.now()/1e3),b.chunkIndex=0);let d=c._eventType||c.event||"";if("assistantResponseEvent"===d||c.assistantResponseEvent){let a=c.assistantResponseEvent?.content||c.content||"";if(!a)return null;let d={id:b.responseId,object:"chat.completion.chunk",created:b.created,model:b.model||"kiro",choices:[{index:0,delta:{...0===b.chunkIndex?{role:"assistant"}:{},content:a},finish_reason:null}]};return b.chunkIndex++,d}if("reasoningContentEvent"===d||c.reasoningContentEvent){let a=c.reasoningContentEvent?.content||c.content||"";if(!a)return null;let d={id:b.responseId,object:"chat.completion.chunk",created:b.created,model:b.model||"kiro",choices:[{index:0,delta:{...0===b.chunkIndex?{role:"assistant"}:{},content:`<thinking>${a}</thinking>`},finish_reason:null}]};return b.chunkIndex++,d}if("toolUseEvent"===d||c.toolUseEvent){let a=c.toolUseEvent||c,d=a.toolUseId||`call_${Date.now()}`,e=a.name||"",f=a.input||{},g={id:b.responseId,object:"chat.completion.chunk",created:b.created,model:b.model||"kiro",choices:[{index:0,delta:{...0===b.chunkIndex?{role:"assistant"}:{},tool_calls:[{index:0,id:d,type:"function",function:{name:e,arguments:JSON.stringify(f)}}]},finish_reason:null}]};return b.chunkIndex++,g}if("messageStopEvent"===d||"done"===d||c.messageStopEvent){b.finishReason="stop";let a={id:b.responseId,object:"chat.completion.chunk",created:b.created,model:b.model||"kiro",choices:[{index:0,delta:{},finish_reason:"stop"}]};return b.usage&&"object"==typeof b.usage&&(a.usage=b.usage),a}if("usageEvent"===d||c.usageEvent){let a=c.usageEvent||c;a&&"object"==typeof a&&(b.usage={prompt_tokens:a.inputTokens||0,completion_tokens:a.outputTokens||0,total_tokens:(a.inputTokens||0)+(a.outputTokens||0)})}return null}(0,d.kz)(e.h.KIRO,e.h.OPENAI,null,f)},54817:(a,b,c)=>{c.r(b),c.d(b,{antigravityToOpenAIRequest:()=>g});var d=c(33110),e=c(14170),f=c(3156);function g(a,b,c){let d=b.request||b,e={model:a,messages:[],stream:c};if(d.generationConfig){let a=d.generationConfig;if(a.maxOutputTokens){let b={max_tokens:a.maxOutputTokens,tools:d.tools};e.max_tokens=(0,f.M)(b)}if(void 0!==a.temperature&&(e.temperature=a.temperature),void 0!==a.topP&&(e.top_p=a.topP),void 0!==a.topK&&(e.top_k=a.topK),a.thinkingConfig){let b=a.thinkingConfig.thinkingBudget||0;b>0&&(b<=2048?e.reasoning_effort="low":b<=16384?e.reasoning_effort="medium":e.reasoning_effort="high")}}if(d.systemInstruction){var g;let a="string"==typeof(g=d.systemInstruction)?g:g.parts&&Array.isArray(g.parts)?g.parts.map(a=>a.text||"").join(""):"";a&&e.messages.push({role:"system",content:a})}if(d.contents&&Array.isArray(d.contents))for(let a of d.contents){let b=function(a){let b="model"===a.role?"assistant":"user"===a.role?"user":a.role;if(!a.parts||!Array.isArray(a.parts))return null;let c=[],d=[],e=[],f="";for(let b of a.parts){if(!0===b.thought&&b.text){f+=b.text;continue}if(b.thoughtSignature&&void 0!==b.text){c.push({type:"text",text:b.text});continue}void 0!==b.text&&c.push({type:"text",text:b.text}),b.inlineData&&c.push({type:"image_url",image_url:{url:`data:${b.inlineData.mimeType};base64,${b.inlineData.data}`}}),b.functionCall&&d.push({id:b.functionCall.id||`call_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,type:"function",function:{name:b.functionCall.name,arguments:JSON.stringify(b.functionCall.args||{})}}),b.functionResponse&&e.push({role:"tool",tool_call_id:b.functionResponse.id||b.functionResponse.name,content:JSON.stringify(b.functionResponse.response?.result||b.functionResponse.response||{})})}if(e.length>0)return e;if(d.length>0){let a={role:"assistant"};return c.length>0&&(a.content=1===c.length&&"text"===c[0].type?c[0].text:c),f&&(a.reasoning_content=f),a.tool_calls=d,a}if(c.length>0||f){let a={role:b};return c.length>0&&(a.content=1===c.length&&"text"===c[0].type?c[0].text:c),f&&(a.reasoning_content=f),a}return null}(a);b&&(Array.isArray(b)?e.messages.push(...b):e.messages.push(b))}if(d.tools&&Array.isArray(d.tools)){for(let a of(e.tools=[],d.tools))if(a.functionDeclarations)for(let b of a.functionDeclarations)e.tools.push({type:"function",function:{name:b.name,description:b.description||"",parameters:function a(b){if(!b||"object"!=typeof b)return b;let c=Array.isArray(b)?[...b]:{...b};if("string"==typeof c.type&&(c.type=c.type.toLowerCase()),delete c.enumDescriptions,c.properties){let b={};for(let[d,e]of Object.entries(c.properties))b[d]=a(e);c.properties=b}return c.items&&(c.items=a(c.items)),c}(b.parameters)||{type:"object",properties:{}}}})}return e}(0,d.kz)(e.h.ANTIGRAVITY,e.h.OPENAI,g,null)},55399:(a,b,c)=>{c.d(b,{Az:()=>f,fO:()=>i,kR:()=>g});var d=c(55511),e=c(75924);function f(a){let b=a.tools;if(!b||0===b.length)return{body:a,toolNameMap:null};let c=new Map,d=[];for(let a of b){let b=`${a.name}${e.uR}`;c.set(b,a.name),d.push({...a,name:b})}let f=[...d,...h],g=a.messages?.map(a=>{if(!Array.isArray(a.content))return a;let b=a.content.map(a=>"tool_use"===a.type?{...a,name:`${a.name}${e.uR}`}:a);return{...a,content:b}});return{body:{...a,tools:f,messages:g||a.messages},toolNameMap:c.size>0?c:null}}function g(a,b){if(!b?.size||!Array.isArray(a?.content))return a;let c=a.content.map(a=>a?.type==="tool_use"&&b.has(a.name)?{...a,name:b.get(a.name)}:a);return{...a,content:c}}let h=[{name:"Task",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"TaskOutput",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"TaskStop",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"TaskCreate",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"TaskGet",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"TaskUpdate",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"TaskList",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"Bash",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"Glob",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"Grep",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"Read",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"Edit",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"Write",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"NotebookEdit",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"WebFetch",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"WebSearch",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"AskUserQuestion",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"Skill",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"EnterPlanMode",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}},{name:"ExitPlanMode",description:"This tool is currently unavailable.",input_schema:{type:"object",properties:{}}}];function i(a,b,c){let e,f,g,h,i,j;if(!b||!b.includes("sk-ant-oat"))return a;let k={...a},l={type:"text",text:(e=JSON.stringify(a),f=(0,d.createHash)("sha256").update(e).digest("hex").slice(0,5),g=(0,d.randomBytes)(2).toString("hex").slice(0,3),`x-anthropic-billing-header: cc_version=2.1.92.${g}; cc_entrypoint=sdk-cli; cch=${f};`)};return Array.isArray(k.system)?k.system[0]?.text?.startsWith("x-anthropic-billing-header:")||(k.system=[l,...k.system]):"string"==typeof k.system?k.system=[l,{type:"text",text:k.system}]:k.system=[l],k.metadata?.user_id||(k.metadata={...k.metadata,user_id:(h=(0,d.randomBytes)(32).toString("hex"),i=(0,d.randomUUID)(),j=c||(0,d.randomUUID)(),`{"device_id":"${h}","account_uuid":"${i}","session_id":"${j}"}`)}),k}},57647:(a,b,c)=>{c.d(b,{SZ:()=>j,Tz:()=>h,jJ:()=>i});var d=c(35024);c(15626);function e(a){return"string"==typeof a&&a.startsWith("openai-compatible-")}function f(a){return"string"==typeof a&&a.startsWith("anthropic-compatible-")}function g(a){return e(a)&&a.includes("responses")?"responses":"chat"}function h(a){if(a.input&&(Array.isArray(a.input)||"string"==typeof a.input)&&!a.messages)return"openai-responses";if(a.request?.contents&&"antigravity"===a.userAgent)return"antigravity";if(a.contents&&Array.isArray(a.contents))return"gemini";if(a.stream_options||a.response_format||void 0!==a.logprobs||void 0!==a.top_logprobs||void 0!==a.n||void 0!==a.presence_penalty||void 0!==a.frequency_penalty||a.logit_bias||a.user)return"openai";if(a.messages&&Array.isArray(a.messages)){let b=a.messages[0];if(b?.content&&Array.isArray(b.content)){let c=b.content[0];if(c?.type==="text"&&!a.model?.includes("/")){if(a.system||a.anthropic_version)return"claude";let c=b.content.some(a=>"image"===a.type&&a.source?.type==="base64"),d=b.content.some(a=>"image_url"===a.type&&a.image_url?.url);if(c)return"claude";if(d)return"openai";if(b.content.some(a=>"tool_use"===a.type||"tool_result"===a.type))return"claude"}}if(void 0!==a.system||a.anthropic_version)return"claude"}return"openai"}function i(a){return e(a)?"responses"===g(a)?"openai-responses":"openai":f(a)?"claude":function(a){if(e(a)){let b=g(a);return{...d.xq.openai,format:"responses"===b?"openai-responses":"openai",baseUrl:"https://api.openai.com/v1"}}return f(a)?{...d.xq.anthropic,format:"claude",baseUrl:"https://api.anthropic.com/v1"}:d.xq[a]||d.xq.openai}(a).format||"openai"}function j(a){return!function(a){let b=a.messages||a.contents;if(!b?.length)return!0;let c=b[b.length-1];return c?.role==="user"}(a)&&(delete a.reasoning_effort,delete a.thinking),a}},59611:(a,b,c)=>{c.r(b),c.d(b,{openaiToVertexRequest:()=>h});var d=c(33110),e=c(14170),f=c(97102),g=c(96281);function h(a,b,c,d){var e=(0,f.openaiToGeminiRequest)(a,b,c,d);if(!e?.contents)return e;for(let a of e.contents)if(Array.isArray(a.parts))for(let b of a.parts)void 0!==b.thoughtSignature&&(b.thoughtSignature=g.n6),b.functionCall&&"id"in b.functionCall&&delete b.functionCall.id,b.functionResponse&&"id"in b.functionResponse&&delete b.functionResponse.id;return e}(0,d.kz)(e.h.OPENAI,e.h.VERTEX,h,null)},60983:(a,b,c)=>{c.r(b),c.d(b,{claudeToOpenAIRequest:()=>g});var d=c(33110),e=c(14170),f=c(3156);function g(a,b,c){let d={model:a,messages:[],stream:c};if(b.max_tokens&&(d.max_tokens=(0,f.M)(b)),void 0!==b.temperature&&(d.temperature=b.temperature),b.system){let a=Array.isArray(b.system)?b.system.map(a=>a.text||"").join("\n"):b.system;a&&d.messages.push({role:"system",content:a})}if(b.messages&&Array.isArray(b.messages))for(let a=0;a<b.messages.length;a++){let c=function(a){let b="user"===a.role||"tool"===a.role?"user":"assistant";if("string"==typeof a.content)return{role:b,content:a.content};if(Array.isArray(a.content)){let c=[],d=[],e=[];for(let b of a.content)switch(b.type){case"text":c.push({type:"text",text:b.text});break;case"image":b.source?.type==="base64"&&c.push({type:"image_url",image_url:{url:`data:${b.source.media_type};base64,${b.source.data}`}});break;case"tool_use":d.push({id:b.id,type:"function",function:{name:b.name,arguments:JSON.stringify(b.input||{})}});break;case"tool_result":let a="";"string"==typeof b.content?a=b.content:Array.isArray(b.content)?a=b.content.filter(a=>"text"===a.type).map(a=>a.text).join("\n")||JSON.stringify(b.content):b.content&&(a=JSON.stringify(b.content)),e.push({role:"tool",tool_call_id:b.tool_use_id,content:a})}if(e.length>0)return c.length>0?[...e,{role:"user",content:1===c.length&&"text"===c[0].type?c[0].text:c}]:e;if(d.length>0){let a={role:"assistant"};return c.length>0&&(a.content=1===c.length&&"text"===c[0].type?c[0].text:c),a.tool_calls=d,a}if(c.length>0)return{role:b,content:1===c.length&&"text"===c[0].type?c[0].text:c};if(0===a.content.length)return{role:b,content:""}}return null}(b.messages[a]);c&&(Array.isArray(c)?d.messages.push(...c):d.messages.push(c))}return function(a){for(let b=0;b<a.length;b++){let c=a[b];if("assistant"===c.role&&c.tool_calls&&c.tool_calls.length>0){let d=c.tool_calls.map(a=>a.id),e=new Set,f=b+1;for(let c=b+1;c<a.length;c++){let b=a[c];if("tool"===b.role&&b.tool_call_id)e.add(b.tool_call_id),f=c+1;else break}let g=d.filter(a=>!e.has(a));if(g.length>0){let c=g.map(a=>({role:"tool",tool_call_id:a,content:"[No response received]"}));a.splice(f,0,...c),b=f+c.length-1}}}}(d.messages),b.tools&&Array.isArray(b.tools)&&(d.tools=b.tools.map(a=>({type:"function",function:{name:a.name,description:String(a.description||""),parameters:a.input_schema||{type:"object",properties:{}}}}))),b.tool_choice&&(d.tool_choice=function(a){if(!a)return"auto";if("string"==typeof a)return a;switch(a.type){case"auto":default:return"auto";case"any":return"required";case"tool":return{type:"function",function:{name:a.name}}}}(b.tool_choice)),d}(0,d.kz)(e.h.CLAUDE,e.h.OPENAI,g,null)},65377:(a,b,c)=>{c.r(b),c.d(b,{openaiResponsesToOpenAIRequest:()=>h,openaiToOpenAIResponsesRequest:()=>j});var d=c(33110),e=c(14170),f=c(42654);let g=a=>"string"==typeof a&&a.length>64?a.substring(0,64):a;function h(a,b,c,d){if(!b.input)return b;let e={...b};e.messages=[],b.instructions&&e.messages.push({role:"system",content:b.instructions});let g=null,h=[],j=(0,f.m)(b.input);if(!j)return b;for(let a of j){let b=a.type||(a.role?"message":null);if("message"===b){if(g&&(e.messages.push(g),g=null),h.length>0){for(let a of h)e.messages.push(a);h=[]}let b=Array.isArray(a.content)?a.content.map(a=>"input_text"===a.type||"output_text"===a.type?{type:"text",text:a.text}:"input_image"===a.type?{type:"image_url",image_url:{url:a.image_url||a.file_id||"",detail:a.detail||"auto"}}:a):a.content;e.messages.push({role:a.role,content:b})}else if("function_call"===b){if(g||(g={role:"assistant",content:null,tool_calls:[]}),!a.name||"string"!=typeof a.name||""===a.name.trim())continue;g.tool_calls.push({id:a.call_id,type:"function",function:{name:a.name,arguments:a.arguments}})}else if("function_call_output"===b){if(g&&(e.messages.push(g),g=null),h.length>0){for(let a of h)e.messages.push(a);h=[]}e.messages.push({role:"tool",tool_call_id:a.call_id,content:"string"==typeof a.output?a.output:JSON.stringify(a.output)})}else if("reasoning"===b)continue}if(g&&e.messages.push(g),h.length>0)for(let a of h)e.messages.push(a);return b.tools&&Array.isArray(b.tools)&&(e.tools=b.tools.map(a=>{if(a.function)return a;let b=a.name;return b&&"string"==typeof b&&""!==b.trim()?{type:"function",function:{name:b,description:String(a.description||""),parameters:i(a.parameters),strict:a.strict}}:null}).filter(Boolean)),delete e.input,delete e.instructions,delete e.include,delete e.prompt_cache_key,delete e.store,delete e.reasoning,e}function i(a){return a?"object"!==a.type||a.properties?a:{...a,properties:{}}:{type:"object",properties:{}}}function j(a,b,c,d){if(b.input)return{...b,model:a,stream:!0};let e={model:a,input:[],stream:!0,store:!1},f=!1;for(let a of b.messages||[]){if("system"===a.role){f||(e.instructions="string"==typeof a.content?a.content:"",f=!0);continue}if("user"===a.role||"assistant"===a.role){let b="user"===a.role?"input_text":"output_text",c="string"==typeof a.content?[{type:b,text:a.content}]:Array.isArray(a.content)?a.content.map(a=>{if("text"===a.type)return{type:b,text:a.text};if("image_url"===a.type)return{type:"input_image",image_url:"string"==typeof a.image_url?a.image_url:a.image_url?.url,detail:a.image_url?.detail||"auto"};if("input_image"===a.type)return a;let c=a.text||a.content||JSON.stringify(a);return{type:b,text:"string"==typeof c?c:JSON.stringify(c)}}):[];c.length>0&&e.input.push({type:"message",role:a.role,content:c})}if("assistant"===a.role&&a.tool_calls)for(let b of a.tool_calls)e.input.push({type:"function_call",call_id:g(b.id),name:b.function?.name||"_unknown",arguments:b.function?.arguments||"{}"});if("tool"===a.role){let b="string"==typeof a.content?a.content:Array.isArray(a.content)?a.content.map(a=>a.text||JSON.stringify(a)).join(""):JSON.stringify(a.content);e.input.push({type:"function_call_output",call_id:g(a.tool_call_id),output:b})}}return f||(e.instructions=""),b.tools&&Array.isArray(b.tools)&&(e.tools=b.tools.map(a=>"function"===a.type?{type:"function",name:a.function.name,description:String(a.function.description||""),parameters:i(a.function.parameters),strict:a.function.strict}:a)),void 0!==b.temperature&&(e.temperature=b.temperature),void 0!==b.max_tokens&&(e.max_tokens=b.max_tokens),void 0!==b.top_p&&(e.top_p=b.top_p),e}(0,d.kz)(e.h.OPENAI_RESPONSES,e.h.OPENAI,h,null),(0,d.kz)(e.h.OPENAI,e.h.OPENAI_RESPONSES,j,null)},65651:(a,b,c)=>{c.r(b),c.d(b,{convertCursorToOpenAI:()=>f});var d=c(33110),e=c(14170);function f(a,b){return a?("chat.completion.chunk"===a.object&&a.choices||"chat.completion"===a.object&&a.choices,a):null}(0,d.kz)(e.h.CURSOR,e.h.OPENAI,null,f)},66159:(a,b,c)=>{c.r(b),c.d(b,{openaiToClaudeResponse:()=>i});var d=c(33110),e=c(14170);let f="proxy_";function g(a,b){a.thinkingBlockStarted&&(b.push({type:"content_block_stop",index:a.thinkingBlockIndex}),a.thinkingBlockStarted=!1)}function h(a,b){a.textBlockStarted&&!a.textBlockClosed&&(a.textBlockClosed=!0,b.push({type:"content_block_stop",index:a.textBlockIndex}),a.textBlockStarted=!1)}function i(a,b){if(!a||!a.choices?.[0])return null;let c=[],d=a.choices[0],e=d.delta;if(a.usage&&"object"==typeof a.usage){let c="number"==typeof a.usage.prompt_tokens?a.usage.prompt_tokens:0,d="number"==typeof a.usage.completion_tokens?a.usage.completion_tokens:0,e=a.usage.prompt_tokens_details?.cached_tokens,f=a.usage.prompt_tokens_details?.cache_creation_tokens,g="number"==typeof e?e:0,h="number"==typeof f?f:0;b.usage={input_tokens:c-g-h,output_tokens:d},g>0&&(b.usage.cache_read_input_tokens=g),h>0&&(b.usage.cache_creation_input_tokens=h)}b.messageStartSent||(b.messageStartSent=!0,b.messageId=a.id?.replace("chatcmpl-","")||`msg_${Date.now()}`,(!b.messageId||"chat"===b.messageId||b.messageId.length<8)&&(b.messageId=a.extend_fields?.requestId||a.extend_fields?.traceId||`msg_${Date.now()}`),b.model=a.model||"unknown",b.nextBlockIndex=0,c.push({type:"message_start",message:{id:b.messageId,type:"message",role:"assistant",model:b.model,content:[],stop_reason:null,stop_sequence:null,usage:{input_tokens:0,output_tokens:0}}}));let i=e?.reasoning_content||e?.reasoning;if(i&&(h(b,c),b.thinkingBlockStarted||(b.thinkingBlockIndex=b.nextBlockIndex++,b.thinkingBlockStarted=!0,c.push({type:"content_block_start",index:b.thinkingBlockIndex,content_block:{type:"thinking",thinking:""}})),c.push({type:"content_block_delta",index:b.thinkingBlockIndex,delta:{type:"thinking_delta",thinking:i}})),e?.content&&(g(b,c),b.textBlockStarted||(b.textBlockIndex=b.nextBlockIndex++,b.textBlockStarted=!0,b.textBlockClosed=!1,c.push({type:"content_block_start",index:b.textBlockIndex,content_block:{type:"text",text:""}})),c.push({type:"content_block_delta",index:b.textBlockIndex,delta:{type:"text_delta",text:e.content}})),e?.tool_calls)for(let a of e.tool_calls){let d=a.index??0;if(a.id){g(b,c),h(b,c);let e=b.nextBlockIndex++;b.toolCalls.set(d,{id:a.id,name:a.function?.name||"",blockIndex:e});let i=a.function?.name||"";i.startsWith(f)&&(i=i.slice(f.length)),c.push({type:"content_block_start",index:e,content_block:{type:"tool_use",id:a.id,name:i,input:{}}})}if(a.function?.arguments){let e=b.toolCalls.get(d);e&&c.push({type:"content_block_delta",index:e.blockIndex,delta:{type:"input_json_delta",partial_json:a.function.arguments}})}}if(d.finish_reason){for(let[,a]of(g(b,c),h(b,c),b.toolCalls))c.push({type:"content_block_stop",index:a.blockIndex});b.finishReason=d.finish_reason;let a=b.usage||{input_tokens:0,output_tokens:0};c.push({type:"message_delta",delta:{stop_reason:function(a){switch(a){case"stop":default:return"end_turn";case"length":return"max_tokens";case"tool_calls":return"tool_use"}}(d.finish_reason)},usage:a}),c.push({type:"message_stop"})}return c.length>0?c:null}(0,d.kz)(e.h.OPENAI,e.h.CLAUDE,null,i)},74447:(a,b,c)=>{c.r(b),c.d(b,{openaiToOllamaRequest:()=>f});var d=c(33110),e=c(14170);function f(a,b,c){let d={model:a,messages:function(a){if(!Array.isArray(a))return a;let b=[],c=new Map;for(let b of a)if("assistant"===b.role&&b.tool_calls)for(let a of b.tool_calls)a.id&&a.function?.name&&c.set(a.id,a.function.name);for(let d of a){if("tool"===d.role){let a=g(d.content);if(!a)continue;let e=c.get(d.tool_call_id)||d.name||"unknown_tool";b.push({role:"tool",tool_name:e,content:a});continue}if("assistant"===d.role&&d.tool_calls){let a=g(d.content)||"",c=d.tool_calls.map(a=>({type:"function",function:{index:a.index||0,name:a.function?.name||"",arguments:"string"==typeof a.function?.arguments?JSON.parse(a.function.arguments||"{}"):a.function?.arguments||{}}}));b.push({role:"assistant",content:a,tool_calls:c});continue}let a=d.role,e=g(d.content),f=function(a){if(!Array.isArray(a))return[];let b=[];for(let c of a){if(!c||"image_url"!==c.type)continue;let a="string"==typeof c.image_url?c.image_url:c.image_url?.url;if("string"!=typeof a||!a)continue;let d=a.match(/^data:[^;]+;base64,([\s\S]+)$/);d&&b.push(d[1])}return b}(d.content);if(!e&&"assistant"!==a)continue;let h={role:a,content:e};f.length>0&&(h.images=f),b.push(h)}return b}(b.messages),stream:c};return void 0!==b.temperature&&(d.options=d.options||{},d.options.temperature=b.temperature),void 0!==b.max_tokens&&(d.options=d.options||{},d.options.num_predict=b.max_tokens),void 0!==b.top_p&&(d.options=d.options||{},d.options.top_p=b.top_p),b.tools&&Array.isArray(b.tools)&&(d.tools=b.tools),b.tool_choice&&(d.tool_choice=b.tool_choice),d}function g(a){return"string"==typeof a?a:Array.isArray(a)&&a.filter(a=>a&&"text"===a.type&&a.text).map(a=>a.text).join("\n")||""}(0,d.kz)(e.h.OPENAI,e.h.OLLAMA,f,null)},74957:(a,b,c)=>{c.d(b,{H:()=>h});var d=c(41004),e=c(35024),f=c(93800),g=c(39609);class h{constructor(a,b){this.provider=a,this.config=b,this.noAuth=b?.noAuth||!1}getProvider(){return this.provider}getBaseUrls(){return this.config.baseUrls||(this.config.baseUrl?[this.config.baseUrl]:[])}getFallbackCount(){return this.getBaseUrls().length||1}buildUrl(a,b,c=0,d=null){if(this.provider?.startsWith?.("openai-compatible-")){let a=d?.providerSpecificData?.baseUrl||"https://api.openai.com/v1",b=(0,f.wl)(a,"openai-compatible"),c=(a.replace(/\/+$/,"")!==b?(0,f.Hl)({url:a}):null)||d?.providerSpecificData?.apiType||(this.provider.includes("responses")?"responses":"chat");return`${b}${"responses"===c?"/responses":"/chat/completions"}`}if(this.provider?.startsWith?.("anthropic-compatible-")){let a=d?.providerSpecificData?.baseUrl||"https://api.anthropic.com/v1",b=(0,f.wl)(a,"anthropic-compatible");return`${b}/messages`}if("ollama-local"===this.provider)return`${(0,e.Ak)(d)}/api/chat`;let g=this.getBaseUrls();return g[c]||g[0]||this.config.baseUrl}buildHeaders(a,b=!0){let c={"Content-Type":"application/json",...this.config.headers};return this.provider?.startsWith?.("anthropic-compatible-")?(a.apiKey?c["x-api-key"]=a.apiKey:a.accessToken&&(c.Authorization=`Bearer ${a.accessToken}`),c["anthropic-version"]||(c["anthropic-version"]="2023-06-01")):a.accessToken?c.Authorization=`Bearer ${a.accessToken}`:a.apiKey&&(c.Authorization=`Bearer ${a.apiKey}`),b&&(c.Accept="text/event-stream"),c}transformRequest(a,b,c,d){return b}shouldRetry(a,b){return a===d.gx.RATE_LIMITED&&b+1<this.getFallbackCount()}async refreshCredentials(a,b,c=null){return null}needsRefresh(a){return!!a.expiresAt&&new Date(a.expiresAt).getTime()-Date.now()<3e5}parseError(a,b){return{status:a.status,message:b||`HTTP ${a.status}`}}async execute({model:a,body:b,stream:c,credentials:e,signal:f,log:h,proxyOptions:i=null}){let j=this.getFallbackCount(),k=null,l=0,m={},n={...d.cI,...this.config.retry},o=async(a,b,c)=>{let{attempts:e,delayMs:f}=(0,d.DR)(n[b]);return!(e<=0)&&!(m[a]>=e)&&(m[a]++,h?.debug?.("RETRY",`${c} retry ${m[a]}/${e} after ${f/1e3}s`),await new Promise(a=>setTimeout(a,f)),!0)};for(let n=0;n<j;n++){let p=this.buildUrl(a,c,n,e),q=this.transformRequest(a,b,c,e),r=this.buildHeaders(e,c);m[n]||(m[n]=0);try{let a=await (0,g.proxyAwareFetch)(p,{method:"POST",headers:r,body:JSON.stringify(q),signal:f},i);if(await o(n,a.status,`status ${a.status}`)){n--;continue}if(this.shouldRetry(a.status,n)){h?.debug?.("RETRY",`${a.status} on ${p}, trying fallback ${n+1}`),l=a.status;continue}return{response:a,url:p,headers:r,transformedBody:q}}catch(a){if(k=a,"AbortError"===a.name)throw a;if(await o(n,d.gx.BAD_GATEWAY,`network "${a.message}"`)){n--;continue}if(n+1<j){h?.debug?.("RETRY",`Error on ${p}, trying fallback ${n+1}`);continue}throw a}}throw k||Error(`All ${j} URLs failed with status ${l}`)}}},80198:(a,b,c)=>{c.r(b),c.d(b,{buildKiroPayload:()=>g});var d=c(33110),e=c(14170),f=c(94755);function g(a,b,c,d){let e=b.messages||[],g=b.tools||[],h=b.temperature,i=b.top_p,{history:j,currentMessage:k}=function(a,b,c){let d=[],e=null,g=[],h=[],i=[],j=[],k=null,l=()=>{if("user"===k){let a={userInputMessage:{content:g.join("\n\n").trim()||"continue",modelId:""}};j.length>0&&(a.userInputMessage.images=j),i.length>0&&(a.userInputMessage.userInputMessageContext={toolResults:i}),b&&b.length>0&&0===d.length&&(a.userInputMessage.userInputMessageContext||(a.userInputMessage.userInputMessageContext={}),a.userInputMessage.userInputMessageContext.tools=b.map(a=>{let b=a.function?.name||a.name,c=a.function?.description||a.description||"";c.trim()||(c=`Tool: ${b}`);let d=a.function?.parameters||a.parameters||a.input_schema||{};return{toolSpecification:{name:b,description:c,inputSchema:{json:0===Object.keys(d).length?{type:"object",properties:{},required:[]}:{...d,required:d.required??[]}}}}})),d.push(a),e=a,g=[],i=[],j=[]}else if("assistant"===k){let a=h.join("\n\n").trim()||"...";d.push({assistantResponseMessage:{content:a}}),h=[]}};for(let b=0;b<a.length;b++){let c=a[b],e=c.role;if(("system"===e||"tool"===e)&&(e="user"),e!==k&&null!==k&&l(),k=e,"user"===e){let a="";if("string"==typeof c.content)a=c.content;else if(Array.isArray(c.content)){let b=[];for(let a of c.content)if("text"===a.type||a.text)b.push(a.text||"");else if("image_url"!==a.type){if("image"===a.type&&a.source?.type==="base64"&&a.source?.data){let b=a.source.media_type||"image/png",c=b.split("/")[1]||b;j.push({format:c,source:{bytes:a.source.data}})}}else{let c=a.image_url?.url||"",d=c.match(/^data:([^;]+);base64,(.+)$/);if(d){let a=d[1],b=a.split("/")[1]||a;j.push({format:b,source:{bytes:d[2]}})}else(c.startsWith("http://")||c.startsWith("https://"))&&b.push(`[Image: ${c}]`)}a=b.join("\n");let d=c.content.filter(a=>"tool_result"===a.type);d.length>0&&d.forEach(a=>{let b=Array.isArray(a.content)?a.content.map(a=>a.text||"").join("\n"):"string"==typeof a.content?a.content:"";i.push({toolUseId:a.tool_use_id,status:"success",content:[{text:b}]})})}if("tool"===c.role){let a="string"==typeof c.content?c.content:"";i.push({toolUseId:c.tool_call_id,status:"success",content:[{text:a}]})}else a&&g.push(a)}else if("assistant"===e){let a="",b=[];if(Array.isArray(c.content)?(a=c.content.filter(a=>"text"===a.type).map(a=>a.text).join("\n").trim(),b=c.content.filter(a=>"tool_use"===a.type)):"string"==typeof c.content&&(a=c.content.trim()),c.tool_calls&&c.tool_calls.length>0&&(b=c.tool_calls),a&&h.push(a),b.length>0){h.length,l();let a=d[d.length-1];a?.assistantResponseMessage&&(a.assistantResponseMessage.toolUses=b.map(a=>a.function?{toolUseId:a.id||(0,f.A)(),name:a.function.name,input:"string"==typeof a.function.arguments?JSON.parse(a.function.arguments):a.function.arguments||{}}:{toolUseId:a.id||(0,f.A)(),name:a.name,input:a.input||{}})),k=null}}}null!==k&&l();for(let a=d.length-1;a>=0;a--)if(d[a].userInputMessage){e=d.splice(a,1)[0];break}let m=d[0]?.userInputMessage?.userInputMessageContext?.tools;d.forEach(a=>{a.userInputMessage?.userInputMessageContext?.tools&&delete a.userInputMessage.userInputMessageContext.tools,a.userInputMessage?.userInputMessageContext&&0===Object.keys(a.userInputMessage.userInputMessageContext).length&&delete a.userInputMessage.userInputMessageContext,a.userInputMessage&&!a.userInputMessage.modelId&&(a.userInputMessage.modelId=c)});let n=[];for(let a=0;a<d.length;a++){let b=d[a];if(b.userInputMessage&&n.length>0&&n[n.length-1].userInputMessage){let a=n[n.length-1];a.userInputMessage.content+="\n\n"+b.userInputMessage.content}else n.push(b)}return m&&e?.userInputMessage&&!e.userInputMessage.userInputMessageContext?.tools&&(e.userInputMessage.userInputMessageContext||(e.userInputMessage.userInputMessageContext={}),e.userInputMessage.userInputMessageContext.tools=m),{history:n,currentMessage:e}}(e,g,a),l=d?.providerSpecificData?.profileArn||"",m=k?.userInputMessage?.content||"",n=new Date().toISOString();m=`[Context: Current time is ${n}]
|
|
13
13
|
|