switchboard-router 0.9.46 → 0.9.48
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-cli-build/static/chunks/1321-468635886f5017ab.js → .next/static/chunks/1321-73cba51ca6694ffa.js} +1 -1
- package/app/.next-cli-build/BUILD_ID +1 -1
- package/app/.next-cli-build/app-path-routes-manifest.json +14 -14
- package/app/.next-cli-build/build-manifest.json +2 -2
- package/app/.next-cli-build/prerender-manifest.json +3 -3
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/agent-library/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/basic-chat/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/[toolId]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/cli-tools/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/combos/routing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/console-log/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/endpoint/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/[kind]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/combo/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/media-providers/web/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/mitm/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/profile/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/new/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/providers/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/pxpipe/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/quota/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/skills/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/token-saver/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/translator/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/(dashboard)/dashboard/usage/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_global-error.html +1 -1
- package/app/.next-cli-build/server/app/_global-error.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/_not-found.html +1 -1
- package/app/.next-cli-build/server/app/_not-found.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/aider-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/all-statuses/route.js +5 -5
- package/app/.next-cli-build/server/app/api/cli-tools/antigravity-mitm/alias/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cline-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/codex-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-registry/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-mcp-tools/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/cowork-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/deepseek-tui-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/cli-tools/droid-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/gemini-cli-settings/route.js +3 -3
- package/app/.next-cli-build/server/app/api/cli-tools/grok-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/hermes-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/jcode-settings/route.js +3 -3
- package/app/.next-cli-build/server/app/api/cli-tools/kilo-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/openclaw-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/opencode-settings/route.js +2 -2
- package/app/.next-cli-build/server/app/api/cli-tools/pi-settings/route.js +1 -1
- package/app/.next-cli-build/server/app/api/version/route.js +1 -1
- package/app/.next-cli-build/server/app/callback/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/callback.html +1 -1
- package/app/.next-cli-build/server/app/callback.rsc +3 -3
- package/app/.next-cli-build/server/app/callback.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/callback.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/callback.segments/callback/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/settings/pricing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.html +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/dashboard/settings/pricing.segments/dashboard/settings/pricing/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/index.html +1 -1
- package/app/.next-cli-build/server/app/index.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/index.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/landing/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/landing.html +1 -1
- package/app/.next-cli-build/server/app/landing.rsc +3 -3
- package/app/.next-cli-build/server/app/landing.segments/_full.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/landing.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/landing.segments/landing/__PAGE__.segment.rsc +3 -3
- package/app/.next-cli-build/server/app/login/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app/login.html +1 -1
- package/app/.next-cli-build/server/app/login.rsc +4 -4
- package/app/.next-cli-build/server/app/login.segments/_full.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/login.segments/_tree.segment.rsc +1 -1
- package/app/.next-cli-build/server/app/login.segments/login/__PAGE__.segment.rsc +4 -4
- package/app/.next-cli-build/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/app-paths-manifest.json +14 -14
- package/app/.next-cli-build/server/chunks/1350.js +1 -1
- package/app/.next-cli-build/server/chunks/2847.js +1 -1
- package/app/.next-cli-build/server/chunks/369.js +3 -3
- package/app/.next-cli-build/server/chunks/5717.js +1 -1
- package/app/.next-cli-build/server/chunks/7201.js +1 -1
- package/app/.next-cli-build/server/chunks/869.js +1 -1
- package/app/.next-cli-build/server/chunks/8998.js +1 -1
- package/app/.next-cli-build/server/chunks/9264.js +2 -2
- package/app/.next-cli-build/server/middleware-build-manifest.js +1 -1
- package/app/.next-cli-build/server/middleware.js +1 -1
- package/app/.next-cli-build/server/pages/404.html +1 -1
- package/app/.next-cli-build/server/pages/500.html +1 -1
- package/app/.next-cli-build/server/server-reference-manifest.js +1 -1
- package/app/.next-cli-build/server/server-reference-manifest.json +1 -1
- package/app/{.next/static/chunks/1321-468635886f5017ab.js → .next-cli-build/static/chunks/1321-73cba51ca6694ffa.js} +1 -1
- package/app/open-sse/identity/tls/bin/darwin/arm64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/darwin/x64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/linux/arm64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/linux/x64/switchboard-claude-tls +0 -0
- package/app/open-sse/identity/tls/bin/win32/arm64/switchboard-claude-tls.exe +0 -0
- package/app/open-sse/identity/tls/bin/win32/x64/switchboard-claude-tls.exe +0 -0
- package/app/package.json +1 -1
- package/package.json +1 -1
- /package/app/.next/static/{WW6AmUFPUk6i1gC7bGp99 → MSigI0uI9w5TrE5x-BeGU}/_buildManifest.js +0 -0
- /package/app/.next/static/{WW6AmUFPUk6i1gC7bGp99 → MSigI0uI9w5TrE5x-BeGU}/_ssgManifest.js +0 -0
- /package/app/.next-cli-build/static/{WW6AmUFPUk6i1gC7bGp99 → MSigI0uI9w5TrE5x-BeGU}/_buildManifest.js +0 -0
- /package/app/.next-cli-build/static/{WW6AmUFPUk6i1gC7bGp99 → MSigI0uI9w5TrE5x-BeGU}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.id=869,exports.ids=[869],exports.modules={4489:(a,b,c)=>{c.d(b,{ki:()=>f}),c(29696);let d=new Set(["chat","text","language","model"]),e=new Map(["imageToText","webSearch","webFetch"].map(a=>[a.toLowerCase(),a]));function f(a){if("string"!=typeof a||!a)return a;let b=a.toLowerCase();return d.has(b)?"llm":e.get(b)||b}},27335:(a,b,c)=>{c.d(b,{Xg:()=>r,vq:()=>f.vq,fZ:()=>j,cY:()=>t,ez:()=>n,ux:()=>m,OA:()=>o,kt:()=>p,KC:()=>s,SM:()=>i});var d=c(4630),e=c(39698),f=c(45350),g=c(6595);let h="-review";function i(a){return f.vq[a]||[]}function j(a){let b=f.vq[a];return b?.[0]?.id||null}let k=new Set(["kr","kiro"]);function l(a,b,c){if(!a)return;let d=a.find(a=>a.id===b);if(d)return d;if(!k.has(c))return;let e=(0,g.Kq)(b);if(e!==b)return a.find(a=>a.id===e)}function m(a,b){let c=f.vq[a];return c?(0,g.gr)(l(c,b,a)):null}function n(a,b){let c=f.vq[a];return c?(0,g.ec)(l(c,b,a)):null}function o(a,b){let c=f.vq[a];if(!c)return null;let d=l(c,b,a);return d?.kind||d?.type||null}function p(a,b){let c="string"==typeof b?b.match(/\([^()]+\)\s*$/):null,d=c?c[0]:"",e=d?b.slice(0,c.index).trim():b,g=l(f.vq[a],e,a);return g?.upstreamModelId?g.upstreamModelId+d:g?.id?g.id+d:"cx"===a&&"string"==typeof e&&e.endsWith(h)?e.slice(0,-h.length)+d:e+d}let q=Object.fromEntries(e.A.filter(a=>a.alias&&a.alias!==a.id).map(a=>[a.id,a.alias])),r=Object.fromEntries(Object.keys(d.xq).map(a=>[a,q[a]||a]));function s(a){let b=r[a]||a;return f.vq[b]||[]}function t(a,b){return(0,g.g5)(l(f.vq[a],b,a))}},29696:(a,b,c)=>{function d(a){return!(!a||"object"!=typeof a||Array.isArray(a))&&"boolean"==typeof a.supported&&(null==a.effort||"flat"===a.effort||"nested"===a.effort)}c.d(b,{K5:()=>d,ml:()=>f});let e=[{suffix:"aliyuncs.com",format:"qwen"},{suffix:"opencode.ai",format:"flat"},{suffix:"api.surplusintelligence.ai",format:"flat"},{suffix:"inference-api.nousresearch.com",format:"none"}];function f(a){let b="";try{b=new URL(String(a||"")).hostname.toLowerCase()}catch{return null}if(!b)return null;for(let a of e)if(b===a.suffix||b.endsWith(`.${a.suffix}`))return a.format;return null}},30869:(a,b,c)=>{c.d(b,{UY:()=>h,eh:()=>f.eh,fg:()=>e.fg,h0:()=>g,oc:()=>i});var d=c(39006),e=c(40615),f=c(81329);d.rE;let g={npmPackageName:"switchboard-router",installCmd:"npm i -g switchboard-router",installCmdLatest:"npm i -g switchboard-router@latest --prefer-online",shutdownCountdownSec:3,exitDelayMs:2200,statusPort:20129,statusPollIntervalMs:1e3,statusLogTailLines:8,installRetries:3,installRetryDelayMs:5e3,lingerAfterDoneMs:3e4,waitForExitMinMs:5e3,waitForExitMaxMs:2e4,waitForExitCheckMs:500,statusStartupTimeoutMs:2e3,appPort:20128},h={maxLines:200,pollIntervalMs:1e3},i={tickIntervalMs:6e4,pingLeadMs:5e3,refreshAheadMs:3e5,failureCooldownMs:9e5,providers:{claude:{settingsKey:"claudeAutoPing",quotaKey:"session (5h)",pingModel:"claude-haiku-4-5-20251001",pingText:"hi",pingMaxTokens:1},codex:{settingsKey:"codexAutoPing",quotaKey:"session",pingWhenResetAtSlides:!0,resetAtDriftMs:3e4,minPingIntervalMs:6e5,skipWhenBlockingQuotaExhausted:!0,pingModel:"gpt-5.5",pingText:"hi",pingInstructions:"Reply with OK.",pingReasoningEffort:"none"}}}},39006:a=>{a.exports=JSON.parse('{"UU":"switchboard-app","rE":"0.9.
|
|
1
|
+
"use strict";exports.id=869,exports.ids=[869],exports.modules={4489:(a,b,c)=>{c.d(b,{ki:()=>f}),c(29696);let d=new Set(["chat","text","language","model"]),e=new Map(["imageToText","webSearch","webFetch"].map(a=>[a.toLowerCase(),a]));function f(a){if("string"!=typeof a||!a)return a;let b=a.toLowerCase();return d.has(b)?"llm":e.get(b)||b}},27335:(a,b,c)=>{c.d(b,{Xg:()=>r,vq:()=>f.vq,fZ:()=>j,cY:()=>t,ez:()=>n,ux:()=>m,OA:()=>o,kt:()=>p,KC:()=>s,SM:()=>i});var d=c(4630),e=c(39698),f=c(45350),g=c(6595);let h="-review";function i(a){return f.vq[a]||[]}function j(a){let b=f.vq[a];return b?.[0]?.id||null}let k=new Set(["kr","kiro"]);function l(a,b,c){if(!a)return;let d=a.find(a=>a.id===b);if(d)return d;if(!k.has(c))return;let e=(0,g.Kq)(b);if(e!==b)return a.find(a=>a.id===e)}function m(a,b){let c=f.vq[a];return c?(0,g.gr)(l(c,b,a)):null}function n(a,b){let c=f.vq[a];return c?(0,g.ec)(l(c,b,a)):null}function o(a,b){let c=f.vq[a];if(!c)return null;let d=l(c,b,a);return d?.kind||d?.type||null}function p(a,b){let c="string"==typeof b?b.match(/\([^()]+\)\s*$/):null,d=c?c[0]:"",e=d?b.slice(0,c.index).trim():b,g=l(f.vq[a],e,a);return g?.upstreamModelId?g.upstreamModelId+d:g?.id?g.id+d:"cx"===a&&"string"==typeof e&&e.endsWith(h)?e.slice(0,-h.length)+d:e+d}let q=Object.fromEntries(e.A.filter(a=>a.alias&&a.alias!==a.id).map(a=>[a.id,a.alias])),r=Object.fromEntries(Object.keys(d.xq).map(a=>[a,q[a]||a]));function s(a){let b=r[a]||a;return f.vq[b]||[]}function t(a,b){return(0,g.g5)(l(f.vq[a],b,a))}},29696:(a,b,c)=>{function d(a){return!(!a||"object"!=typeof a||Array.isArray(a))&&"boolean"==typeof a.supported&&(null==a.effort||"flat"===a.effort||"nested"===a.effort)}c.d(b,{K5:()=>d,ml:()=>f});let e=[{suffix:"aliyuncs.com",format:"qwen"},{suffix:"opencode.ai",format:"flat"},{suffix:"api.surplusintelligence.ai",format:"flat"},{suffix:"inference-api.nousresearch.com",format:"none"}];function f(a){let b="";try{b=new URL(String(a||"")).hostname.toLowerCase()}catch{return null}if(!b)return null;for(let a of e)if(b===a.suffix||b.endsWith(`.${a.suffix}`))return a.format;return null}},30869:(a,b,c)=>{c.d(b,{UY:()=>h,eh:()=>f.eh,fg:()=>e.fg,h0:()=>g,oc:()=>i});var d=c(39006),e=c(40615),f=c(81329);d.rE;let g={npmPackageName:"switchboard-router",installCmd:"npm i -g switchboard-router",installCmdLatest:"npm i -g switchboard-router@latest --prefer-online",shutdownCountdownSec:3,exitDelayMs:2200,statusPort:20129,statusPollIntervalMs:1e3,statusLogTailLines:8,installRetries:3,installRetryDelayMs:5e3,lingerAfterDoneMs:3e4,waitForExitMinMs:5e3,waitForExitMaxMs:2e4,waitForExitCheckMs:500,statusStartupTimeoutMs:2e3,appPort:20128},h={maxLines:200,pollIntervalMs:1e3},i={tickIntervalMs:6e4,pingLeadMs:5e3,refreshAheadMs:3e5,failureCooldownMs:9e5,providers:{claude:{settingsKey:"claudeAutoPing",quotaKey:"session (5h)",pingModel:"claude-haiku-4-5-20251001",pingText:"hi",pingMaxTokens:1},codex:{settingsKey:"codexAutoPing",quotaKey:"session",pingWhenResetAtSlides:!0,resetAtDriftMs:3e4,minPingIntervalMs:6e5,skipWhenBlockingQuotaExhausted:!0,pingModel:"gpt-5.5",pingText:"hi",pingInstructions:"Reply with OK.",pingReasoningEffort:"none"}}}},39006:a=>{a.exports=JSON.parse('{"UU":"switchboard-app","rE":"0.9.48"}')},40615:(a,b,c)=>{c.d(b,{Q2:()=>s,js:()=>w,DI:()=>n,fg:()=>k,Pd:()=>o,IS:()=>h,nJ:()=>i,zN:()=>j,JH:()=>m,jO:()=>y,wb:()=>x,br:()=>l,wG:()=>v,zt:()=>t,gb:()=>q,gC:()=>r,mq:()=>p,rs:()=>u});var d=c(39698);let e="⚠️ Risk Notice: This provider uses a subscription/OAuth session not officially licensed for proxy/router use. Account may be restricted or banned. Use at your own risk.";Object.fromEntries(d.A.filter(a=>a.display).map(a=>{let b;return[a.id,"RISK_NOTICE"===(b=a.display).deprecationNotice?{...b,deprecationNotice:e}:b]}));let f=["serviceKinds","ttsConfig","sttConfig","embeddingConfig","imageConfig","imageToTextConfig","videoConfig","musicConfig","searchViaChat","searchConfig","fetchConfig","modelsFetcher","mediaPriority","hiddenKinds"],g=a=>Object.fromEntries(d.A.filter(b=>b.category===a).map(a=>[a.id,function(a){let b={};for(let c of(a.media&&Object.assign(b,a.media),f))void 0!==a[c]&&(b[c]=a[c]);let c={...a.display||{}};return"RISK_NOTICE"===c.deprecationNotice&&(c.deprecationNotice=e),{...c,id:a.id,alias:a.uiAlias||a.alias,...a.aliases?.length?{aliases:a.aliases}:{},...a.hidden?{hidden:!0}:{},...b,...void 0!==a.priority?{priority:a.priority}:{},...a.hasFree?{hasFree:!0}:{},...a.thinkingConfig?{thinkingConfig:a.thinkingConfig}:{},...a.regions?{regions:a.regions,defaultRegion:a.defaultRegion}:{},...a.hasProviderSpecificData?{hasProviderSpecificData:!0}:{},...a.noAuth?{noAuth:!0}:{},...a.passthroughModels?{passthroughModels:!0}:{},...a.hasOAuth?{hasOAuth:!0}:{},...a.authModes?{authModes:a.authModes}:{},...a.authType?{authType:a.authType}:{},...a.authHint?{authHint:a.authHint}:{}}}(a)])),h=g("free"),i=g("freeTier"),j=g("oauth"),k=g("apikey"),l=g("webCookie"),m="openai-compatible-",n="anthropic-compatible-",o="custom-embedding-";function p(a){return"string"==typeof a&&a.startsWith(m)}function q(a){return"string"==typeof a&&a.startsWith(n)}function r(a){return"string"==typeof a&&a.startsWith(o)}let s={...h,...i,...j,...k,...l};function t(a){for(let b of Object.values(s))if(b.alias===a||b.id===a||b.aliases?.includes(a))return b;return null}function u(a){let b=t(a);return b?.id||a}function v(a){let b=s[a];return b?.alias||a}let w=Object.values(s).reduce((a,b)=>(a[b.alias]=b.id,a),{});Object.values(s).reduce((a,b)=>(a[b.id]=b.alias,a),{});let x=d.A.filter(a=>a.features?.usage).map(a=>a.id),y=d.A.filter(a=>a.features?.usageApikey).map(a=>a.id)},81329:(a,b,c)=>{c.d(b,{CP:()=>h,PROVIDER_MODELS:()=>d.vq,Xg:()=>d.Xg,eh:()=>g});var d=c(27335),e=c(40615),f=c(4489);Object.entries(e.Q2).filter(([,a])=>a.passthroughModels).map(([a])=>a);let g=Object.entries(d.vq).flatMap(([a,b])=>b.map(b=>({provider:a,model:b.id,name:b.name}))),h=(a,b=null)=>{let c=a?.kind||a?.type||b;return c?(0,f.ki)(c):c}}};
|
|
@@ -34,7 +34,7 @@ data: ${JSON.stringify(a)}
|
|
|
34
34
|
|
|
35
35
|
`:`data: ${JSON.stringify(a)}
|
|
36
36
|
|
|
37
|
-
`}},18184:(a,b,c)=>{"use strict";function d({id:a,created:b,model:c},e,f=null){return{id:a,object:"chat.completion.chunk",created:b,model:c,choices:[{index:0,delta:e,finish_reason:f}]}}c.d(b,{k:()=>d})},18205:(a,b,c)=>{"use strict";c.d(b,{D:()=>f});var d=c(46248),e=c(38421);class f extends d.L{constructor(){super("ollama-local")}buildUrl(a,b,c=0,d=null){return`${(0,e.Ak)(d)}/api/chat`}}},18586:(a,b,c)=>{"use strict";c.d(b,{au:()=>m});var d=c(52655);let e="<|tool▁calls▁begin|>",f="<|tool▁call▁begin|>",g="<|tool▁sep|>",h="<|tool▁call▁end|>",i="<|tool▁calls▁end|>",j="<|DSML|tool_calls>",k=/(<|tool▁calls▁begin|>|<|DSML|tool_calls>)/,l=[[/deepseek|composer/i,{name:"deepseek",detect:a=>k.test(a),parse(a){let b=function(a){let b=a.indexOf(e);if(b<0)return null;let c=a.slice(0,b).trim(),j=a.indexOf(i,b),k=j>=0?a.slice(b+e.length,j):a.slice(b+e.length),l=j>=0?a.slice(j+i.length).trim():"",m=[],n=k.split(f).filter(Boolean);for(let a=0;a<n.length;a++){let b=n[a],c=function(a,b){let c=a;c.startsWith(f)&&(c=c.slice(f.length)),c.endsWith(h)&&(c=c.slice(0,-h.length));let e=c.indexOf(g);if(e<0)return null;let i=c.slice(e+g.length),j=i.search(/[\n`]/),k=j>0?i.slice(0,j).trim():i.trim();if(!k)return null;let l="{}",m=i.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/);if(m)l=m[1].trim();else{let a=i.slice(j>=0?j:0).trim();(a.startsWith("{")||a.startsWith("["))&&(l=a)}try{JSON.parse(l)}catch{l=JSON.stringify({_raw:l})}return{id:(0,d.J4)(0,b,k),type:"function",function:{name:k,arguments:l}}}(b=f+b,a);c&&m.push(c)}return 0===m.length?null:{content:[c,l].filter(Boolean).join("\n").trim()||null,toolCalls:m}}(a);if(b)return b;let c=function(a){let b,c=a.indexOf(j);if(c<0)return null;let e=a.slice(0,c).trim(),f=a.slice(c+j.length);if(f.length>5e5)return null;let g=/<|DSML|invoke\s+name="([^"]+)">([\s\S]*?)(?:<\/|DSML|invoke>|$)/g,h=/<|DSML|parameter\s+name="([^"]+)"\s+string="(true|false)">([\s\S]*?)(?=<|DSML|parameter|<\/|DSML|invoke>|$)/g,i=[];for(;null!==(b=g.exec(f));){let a,c=b[1],e=b[2],f={};for(h.lastIndex=0;null!==(a=h.exec(e));){let b=a[1],c="true"===a[2],d=a[3].trim();if(c)f[b]=d;else try{f[b]=JSON.parse(d)}catch{f[b]=d}}i.push({id:(0,d.J4)(0,i.length,c),type:"function",function:{name:c,arguments:JSON.stringify(f)}})}return 0===i.length?null:{content:e||null,toolCalls:i}}(a);return c||null}}]];function m(a,b){if(!a||!b)return null;let c=function(a){if(!a)return null;for(let[b,c]of l)if(b.test(a))return c;return null}(b);return c&&c.detect(a)?c.parse(a):null}},18762:(a,b,c)=>{"use strict";c(87350),c(68531),c(17438),c(22268),c(18101),c(73081),c(1031),c(19016),c(39490),new TextEncoder},18922:(a,b,c)=>{"use strict";let d;c.d(b,{ox:()=>z,pS:()=>A});var e=c(24081),f=c(50743),g=c(68176),h=c(22268);let i=null,j=0;async function k(){if(i&&Date.now()-j<5e3)return i;try{let{getSettings:a}=await Promise.resolve().then(c.bind(c,45874)),b=await a(),d="false"!==process.env.OBSERVABILITY_ENABLED;i={enabled:"boolean"==typeof b.enableObservability?b.enableObservability:d,maxRecords:b.observabilityMaxRecords||parseInt(process.env.OBSERVABILITY_MAX_RECORDS||String(200),10),batchSize:b.observabilityBatchSize||parseInt(process.env.OBSERVABILITY_BATCH_SIZE||String(20),10),flushIntervalMs:b.observabilityFlushIntervalMs||parseInt(process.env.OBSERVABILITY_FLUSH_INTERVAL_MS||String(5e3),10),maxJsonSize:1024*(b.observabilityMaxJsonSize||parseInt(process.env.OBSERVABILITY_MAX_JSON_SIZE||"5",10)),maxBuffer:parseInt(process.env.OBSERVABILITY_MAX_BUFFER||String(5e3),10)||5e3}}catch{i={enabled:!1,maxRecords:200,batchSize:20,flushIntervalMs:5e3,maxJsonSize:5120,maxBuffer:5e3}}return j=Date.now(),i}let l=[],m=null,n=!1,o=0,p=0,q=new Set(["accesstoken","refreshtoken","idtoken","apikey","copilottoken","cookies","clientsecret","secretaccesskey","authorization","xapikey","xswitchboardkey","cookie","token","password","passwd","secret","bearer","setcookie","xauthtoken"]);function r(a,b=new WeakSet){if(!a||"object"!=typeof a||b.has(a))return a;b.add(a);let c=null;if(Array.isArray(a)){for(let d=0;d<a.length;d++){let e=r(a[d],b);e===a[d]||c||(c=a.slice()),c&&(c[d]=e)}return c||a}for(let[d,e]of Object.entries(a)){let f=q.has(String(d).toLowerCase().replace(/[-_]/g,""))?"[REDACTED]":r(e,b);f===e||c||(c={...a}),c&&(c[d]=f)}return c||a}let s=new WeakMap;function t(a,b,c){if(a&&("object"==typeof a||"function"==typeof a))try{s.set(a,{maxSize:b,result:c})}catch{}return c}function u(a,b){let c;if(null==a)return{};if("object"==typeof a||"function"==typeof a)try{let c=s.get(a);if(c&&c.maxSize===b)return c.result}catch{}try{c=JSON.stringify(a)}catch{let c=String(a).substring(0,200);return t(a,b,{_truncated:!0,_originalSize:c.length,_preview:c,_error:"stringify_failed"})}return((0,h.nx)(a,c.length),c.length>b)?t(a,b,{_truncated:!0,_originalSize:c.length,_preview:c.substring(0,200)}):t(a,b,a)}function v(a,b,c){a.transaction(()=>{for(let d of c){let c=function(a,b){var c;let d,e,f;return a.id||(c=a.model,d=new Date().toISOString(),e=Math.random().toString(36).substring(2,8),f=c?c.replace(/[^a-zA-Z0-9-]/g,"-"):"unknown",a.id=`${d}-${e}-${f}`),a.timestamp||(a.timestamp=new Date().toISOString()),{id:a.id,provider:a.provider||null,model:a.model||null,connectionId:a.connectionId||null,timestamp:a.timestamp,status:a.status||null,latency:a.latency||{},tokens:a.tokens||{},request:u(a.request,b.maxJsonSize),providerRequest:u(a.providerRequest,b.maxJsonSize),providerResponse:u(a.providerResponse,b.maxJsonSize),response:u(a.response,b.maxJsonSize),pxpipe:a.pxpipe||void 0,rtk:a.rtk?{...a.rtk,hits:a.rtk.hits?.slice(0,50)}:void 0}}(d,b);a.run("INSERT INTO requestDetails(id, timestamp, provider, model, connectionId, status, data) VALUES(?, ?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET timestamp = excluded.timestamp, provider = excluded.provider, model = excluded.model, connectionId = excluded.connectionId, status = excluded.status, data = excluded.data",[c.id,c.timestamp,c.provider,c.model,c.connectionId,c.status,(0,f.s)(c)])}let d=a.get("SELECT timestamp FROM requestDetails ORDER BY timestamp DESC LIMIT 1 OFFSET ?",[Math.max(0,b.maxRecords-1)]);d&&a.run("DELETE FROM requestDetails WHERE timestamp < ?",[d.timestamp])})}let w=null,x=null;async function y(){if(n||0===l.length)return;n=!0;let a=null;try{for(;l.length>0;){let b=l.splice(0,l.length);try{let a=await (0,e.c)(),c=await k();w=a,x=c,v(a,c,b)}catch(c){a=c,l.unshift(...b);break}}}finally{n=!1}a&&console.error("[requestDetailsRepo] Batch write failed:",a)}async function z(a){let b=await k();if(!b.enabled)return;x=b;try{(0,e.c)().then(a=>{w=a},()=>{})}catch{}let c=function(a,b){if(!a||"object"!=typeof a)return a;let c={...a};return c.request?.headers&&(c.request={...c.request,headers:function(a){if(!a||"object"!=typeof a)return{};let b=["authorization","x-api-key","x-switchboard-key","cookie","token","api-key"],c={...a};for(let a of Object.keys(c))b.some(b=>a.toLowerCase().includes(b))&&delete c[a];return c}(c.request.headers)}),c.request=u(r(c.request),b),c.providerRequest=u(r(c.providerRequest),b),c.providerResponse=u(r(c.providerResponse),b),c.response=u(r(c.response),b),c.body&&(c.body=u(r(c.body),b)),c.raw&&(c.raw=u(r(c.raw),b)),c}(a,b.maxJsonSize);if(l.length>=b.maxBuffer){l.shift(),p++;let a=Date.now();a-o>6e4&&(console.warn(`[requestDetailsRepo] observability buffer full (${b.maxBuffer}); dropped ${p} record(s). Raise OBSERVABILITY_MAX_BUFFER or lower OBSERVABILITY_FLUSH_INTERVAL_MS.`),o=a,p=0)}l.push(c),l.length>=b.batchSize?(m&&(clearTimeout(m),m=null),y().catch(a=>console.error("[requestDetailsRepo] flush err:",a))):m||(m=setTimeout(()=>{m=null,y().catch(()=>{})},b.flushIntervalMs))}let A=async()=>{m&&(clearTimeout(m),m=null),l.length>0&&await y()},B="__switchboardRequestDetailsBeforeExitHandler",C="__switchboardRequestDetailsSyncFlushUnregister";(d=globalThis[B])&&process.off("beforeExit",d),globalThis[B]=A,process.on("beforeExit",A);try{let a=globalThis[C];if("function"==typeof a)try{a()}catch{}globalThis[C]=(0,g.H)(function(){if(0===l.length)return 0;let a=w,b=x;if(!a||!b)return 0;try{m&&(clearTimeout(m),m=null);let c=l.splice(0,l.length);try{v(a,b,c)}catch{return l.unshift(...c),0}return c.length}catch{return 0}},{flush:!0})}catch{}},19016:(a,b,c)=>{"use strict";c.d(b,{$U:()=>d,pb:()=>e,uB:()=>f});let d="data: [DONE]\n\n",e={"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"},f={"Content-Type":"text/event-stream","Cache-Control":"no-cache","X-Accel-Buffering":"no"}},19071:(a,b,c)=>{"use strict";let{kConnected:d,kPending:e,kRunning:f,kSize:g,kFree:h,kQueued:i}=c(49176);class j{constructor(a){this.connected=a[d],this.pending=a[e],this.running=a[f],this.size=a[g]}}class k{constructor(a){this.connected=a[d],this.free=a[h],this.pending=a[e],this.queued=a[i],this.running=a[f],this.size=a[g]}}a.exports={ClientStats:j,PoolStats:k}},19396:(a,b,c)=>{var d=c(45654);c(33889),d.cipher=d.cipher||{};var e=a.exports=d.cipher.modes=d.cipher.modes||{};function f(a,b){if("string"==typeof a&&(a=d.util.createBuffer(a)),d.util.isArray(a)&&a.length>4){var c=a;a=d.util.createBuffer();for(var e=0;e<c.length;++e)a.putByte(c[e])}if(a.length()<b)throw Error("Invalid IV length; got "+a.length()+" bytes and expected "+b+" bytes.");if(!d.util.isArray(a)){for(var f=[],g=b/4,e=0;e<g;++e)f.push(a.getInt32());a=f}return a}function g(a){a[a.length-1]=a[a.length-1]+1|0}function h(a){return[a/0x100000000|0,0|a]}e.ecb=function(a){a=a||{},this.name="ECB",this.cipher=a.cipher,this.blockSize=a.blockSize||16,this._ints=this.blockSize/4,this._inBlock=Array(this._ints),this._outBlock=Array(this._ints)},e.ecb.prototype.start=function(a){},e.ecb.prototype.encrypt=function(a,b,c){if(a.length()<this.blockSize&&!(c&&a.length()>0))return!0;for(var d=0;d<this._ints;++d)this._inBlock[d]=a.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var d=0;d<this._ints;++d)b.putInt32(this._outBlock[d])},e.ecb.prototype.decrypt=function(a,b,c){if(a.length()<this.blockSize&&!(c&&a.length()>0))return!0;for(var d=0;d<this._ints;++d)this._inBlock[d]=a.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var d=0;d<this._ints;++d)b.putInt32(this._outBlock[d])},e.ecb.prototype.pad=function(a,b){var c=a.length()===this.blockSize?this.blockSize:this.blockSize-a.length();return a.fillWithByte(c,c),!0},e.ecb.prototype.unpad=function(a,b){if(b.overflow>0)return!1;var c=a.length(),d=a.at(c-1);return!(d>this.blockSize<<2)&&(a.truncate(d),!0)},e.cbc=function(a){a=a||{},this.name="CBC",this.cipher=a.cipher,this.blockSize=a.blockSize||16,this._ints=this.blockSize/4,this._inBlock=Array(this._ints),this._outBlock=Array(this._ints)},e.cbc.prototype.start=function(a){if(null===a.iv){if(!this._prev)throw Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in a)this._iv=f(a.iv,this.blockSize),this._prev=this._iv.slice(0);else throw Error("Invalid IV parameter.")},e.cbc.prototype.encrypt=function(a,b,c){if(a.length()<this.blockSize&&!(c&&a.length()>0))return!0;for(var d=0;d<this._ints;++d)this._inBlock[d]=this._prev[d]^a.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var d=0;d<this._ints;++d)b.putInt32(this._outBlock[d]);this._prev=this._outBlock},e.cbc.prototype.decrypt=function(a,b,c){if(a.length()<this.blockSize&&!(c&&a.length()>0))return!0;for(var d=0;d<this._ints;++d)this._inBlock[d]=a.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var d=0;d<this._ints;++d)b.putInt32(this._prev[d]^this._outBlock[d]);this._prev=this._inBlock.slice(0)},e.cbc.prototype.pad=function(a,b){var c=a.length()===this.blockSize?this.blockSize:this.blockSize-a.length();return a.fillWithByte(c,c),!0},e.cbc.prototype.unpad=function(a,b){if(b.overflow>0)return!1;var c=a.length(),d=a.at(c-1);return!(d>this.blockSize<<2)&&(a.truncate(d),!0)},e.cfb=function(a){a=a||{},this.name="CFB",this.cipher=a.cipher,this.blockSize=a.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialBlock=Array(this._ints),this._partialOutput=d.util.createBuffer(),this._partialBytes=0},e.cfb.prototype.start=function(a){if(!("iv"in a))throw Error("Invalid IV parameter.");this._iv=f(a.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.cfb.prototype.encrypt=function(a,b,c){var d=a.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize){for(var e=0;e<this._ints;++e)this._inBlock[e]=a.getInt32()^this._outBlock[e],b.putInt32(this._inBlock[e]);return}var f=(this.blockSize-d)%this.blockSize;f>0&&(f=this.blockSize-f),this._partialOutput.clear();for(var e=0;e<this._ints;++e)this._partialBlock[e]=a.getInt32()^this._outBlock[e],this._partialOutput.putInt32(this._partialBlock[e]);if(f>0)a.read-=this.blockSize;else for(var e=0;e<this._ints;++e)this._inBlock[e]=this._partialBlock[e];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),f>0&&!c)return b.putBytes(this._partialOutput.getBytes(f-this._partialBytes)),this._partialBytes=f,!0;b.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0},e.cfb.prototype.decrypt=function(a,b,c){var d=a.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize){for(var e=0;e<this._ints;++e)this._inBlock[e]=a.getInt32(),b.putInt32(this._inBlock[e]^this._outBlock[e]);return}var f=(this.blockSize-d)%this.blockSize;f>0&&(f=this.blockSize-f),this._partialOutput.clear();for(var e=0;e<this._ints;++e)this._partialBlock[e]=a.getInt32(),this._partialOutput.putInt32(this._partialBlock[e]^this._outBlock[e]);if(f>0)a.read-=this.blockSize;else for(var e=0;e<this._ints;++e)this._inBlock[e]=this._partialBlock[e];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),f>0&&!c)return b.putBytes(this._partialOutput.getBytes(f-this._partialBytes)),this._partialBytes=f,!0;b.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0},e.ofb=function(a){a=a||{},this.name="OFB",this.cipher=a.cipher,this.blockSize=a.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialOutput=d.util.createBuffer(),this._partialBytes=0},e.ofb.prototype.start=function(a){if(!("iv"in a))throw Error("Invalid IV parameter.");this._iv=f(a.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.ofb.prototype.encrypt=function(a,b,c){var d=a.length();if(0===a.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize){for(var e=0;e<this._ints;++e)b.putInt32(a.getInt32()^this._outBlock[e]),this._inBlock[e]=this._outBlock[e];return}var f=(this.blockSize-d)%this.blockSize;f>0&&(f=this.blockSize-f),this._partialOutput.clear();for(var e=0;e<this._ints;++e)this._partialOutput.putInt32(a.getInt32()^this._outBlock[e]);if(f>0)a.read-=this.blockSize;else for(var e=0;e<this._ints;++e)this._inBlock[e]=this._outBlock[e];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),f>0&&!c)return b.putBytes(this._partialOutput.getBytes(f-this._partialBytes)),this._partialBytes=f,!0;b.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0},e.ofb.prototype.decrypt=e.ofb.prototype.encrypt,e.ctr=function(a){a=a||{},this.name="CTR",this.cipher=a.cipher,this.blockSize=a.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialOutput=d.util.createBuffer(),this._partialBytes=0},e.ctr.prototype.start=function(a){if(!("iv"in a))throw Error("Invalid IV parameter.");this._iv=f(a.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.ctr.prototype.encrypt=function(a,b,c){var d=a.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var e=0;e<this._ints;++e)b.putInt32(a.getInt32()^this._outBlock[e]);else{var f=(this.blockSize-d)%this.blockSize;f>0&&(f=this.blockSize-f),this._partialOutput.clear();for(var e=0;e<this._ints;++e)this._partialOutput.putInt32(a.getInt32()^this._outBlock[e]);if(f>0&&(a.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),f>0&&!c)return b.putBytes(this._partialOutput.getBytes(f-this._partialBytes)),this._partialBytes=f,!0;b.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}g(this._inBlock)},e.ctr.prototype.decrypt=e.ctr.prototype.encrypt,e.gcm=function(a){a=a||{},this.name="GCM",this.cipher=a.cipher,this.blockSize=a.blockSize||16,this._ints=this.blockSize/4,this._inBlock=Array(this._ints),this._outBlock=Array(this._ints),this._partialOutput=d.util.createBuffer(),this._partialBytes=0,this._R=0xe1000000},e.gcm.prototype.start=function(a){if(!("iv"in a))throw Error("Invalid IV parameter.");var b,c=d.util.createBuffer(a.iv);if(this._cipherLength=0,b="additionalData"in a?d.util.createBuffer(a.additionalData):d.util.createBuffer(),"tagLength"in a?this._tagLength=a.tagLength:this._tagLength=128,this._tag=null,a.decrypt&&(this._tag=d.util.createBuffer(a.tag).getBytes(),this._tag.length!==this._tagLength/8))throw Error("Authentication tag does not match tag length.");this._hashBlock=Array(this._ints),this.tag=null,this._hashSubkey=Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var e=c.length();if(12===e)this._j0=[c.getInt32(),c.getInt32(),c.getInt32(),1];else{for(this._j0=[0,0,0,0];c.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[c.getInt32(),c.getInt32(),c.getInt32(),c.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(h(8*e)))}this._inBlock=this._j0.slice(0),g(this._inBlock),this._partialBytes=0,b=d.util.createBuffer(b),this._aDataLength=h(8*b.length());var f=b.length()%this.blockSize;for(f&&b.fillWithByte(0,this.blockSize-f),this._s=[0,0,0,0];b.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[b.getInt32(),b.getInt32(),b.getInt32(),b.getInt32()])},e.gcm.prototype.encrypt=function(a,b,c){var d=a.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize){for(var e=0;e<this._ints;++e)b.putInt32(this._outBlock[e]^=a.getInt32());this._cipherLength+=this.blockSize}else{var f=(this.blockSize-d)%this.blockSize;f>0&&(f=this.blockSize-f),this._partialOutput.clear();for(var e=0;e<this._ints;++e)this._partialOutput.putInt32(a.getInt32()^this._outBlock[e]);if(f<=0||c){if(c){var h=d%this.blockSize;this._cipherLength+=h,this._partialOutput.truncate(this.blockSize-h)}else this._cipherLength+=this.blockSize;for(var e=0;e<this._ints;++e)this._outBlock[e]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),f>0&&!c)return a.read-=this.blockSize,b.putBytes(this._partialOutput.getBytes(f-this._partialBytes)),this._partialBytes=f,!0;b.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),g(this._inBlock)},e.gcm.prototype.decrypt=function(a,b,c){var d=a.length();if(d<this.blockSize&&!(c&&d>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),g(this._inBlock),this._hashBlock[0]=a.getInt32(),this._hashBlock[1]=a.getInt32(),this._hashBlock[2]=a.getInt32(),this._hashBlock[3]=a.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var e=0;e<this._ints;++e)b.putInt32(this._outBlock[e]^this._hashBlock[e]);d<this.blockSize?this._cipherLength+=d%this.blockSize:this._cipherLength+=this.blockSize},e.gcm.prototype.afterFinish=function(a,b){var c=!0;b.decrypt&&b.overflow&&a.truncate(this.blockSize-b.overflow),this.tag=d.util.createBuffer();var e=this._aDataLength.concat(h(8*this._cipherLength));this._s=this.ghash(this._hashSubkey,this._s,e);var f=[];this.cipher.encrypt(this._j0,f);for(var g=0;g<this._ints;++g)this.tag.putInt32(this._s[g]^f[g]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),b.decrypt&&this.tag.bytes()!==this._tag&&(c=!1),c},e.gcm.prototype.multiply=function(a,b){for(var c=[0,0,0,0],d=b.slice(0),e=0;e<128;++e)a[e/32|0]&1<<31-e%32&&(c[0]^=d[0],c[1]^=d[1],c[2]^=d[2],c[3]^=d[3]),this.pow(d,d);return c},e.gcm.prototype.pow=function(a,b){for(var c=1&a[3],d=3;d>0;--d)b[d]=a[d]>>>1|(1&a[d-1])<<31;b[0]=a[0]>>>1,c&&(b[0]^=this._R)},e.gcm.prototype.tableMultiply=function(a){for(var b=[0,0,0,0],c=0;c<32;++c){var d=a[c/8|0]>>>(7-c%8)*4&15,e=this._m[c][d];b[0]^=e[0],b[1]^=e[1],b[2]^=e[2],b[3]^=e[3]}return b},e.gcm.prototype.ghash=function(a,b,c){return b[0]^=c[0],b[1]^=c[1],b[2]^=c[2],b[3]^=c[3],this.tableMultiply(b)},e.gcm.prototype.generateHashTable=function(a,b){for(var c=8/b,d=4*c,e=16*c,f=Array(e),g=0;g<e;++g){var h=[0,0,0,0],i=g/d|0,j=(d-1-g%d)*b;h[i]=1<<b-1<<j,f[g]=this.generateSubHashTable(this.multiply(h,a),b)}return f},e.gcm.prototype.generateSubHashTable=function(a,b){var c=1<<b,d=c>>>1,e=Array(c);e[d]=a.slice(0);for(var f=d>>>1;f>0;)this.pow(e[2*f],e[f]=[]),f>>=1;for(f=2;f<d;){for(var g=1;g<f;++g){var h=e[f],i=e[g];e[f+g]=[h[0]^i[0],h[1]^i[1],h[2]^i[2],h[3]^i[3]]}f*=2}for(e[0]=[0,0,0,0],f=d+1;f<c;++f){var j=e[f^d];e[f]=[a[0]^j[0],a[1]^j[1],a[2]^j[2],a[3]^j[3]]}return e}},19431:(a,b,c)=>{"use strict";let d=c(34589),{Readable:e}=c(57075),f=c(84285),g=c(89409),h=c(38650),i=c(56698),{assertCacheStore:j,assertCacheMethods:k,getInterceptorOrigin:l,makeCacheKey:m,normalizeHeaders:n,parseCacheControlHeader:o,isInvalidOrWildcardVaryHeader:p,parseVaryHeader:q}=c(79468),{AbortError:r}=c(61448),{parseHttpDate:s}=c(24214),t=()=>{};function u(a,b){for(let c=0;c<a.length;c++)if(a[c]===b)return!0;return!1}function v(a,b){return a.cacheControlDirectives?.["must-revalidate"]===!0||"shared"===b&&(a.cacheControlDirectives?.["proxy-revalidate"]===!0||a.cacheControlDirectives?.["s-maxage"]!==void 0)}function w(a,b){try{a.delete(b)?.catch?.(t)}catch{}}function x(a,b){let c={...a.headers,"if-modified-since":function(a){let b=a?.["last-modified"];if("string"==typeof b&&s(b))return b}(b.headers)??new Date(b.cachedAt).toUTCString()};if(b.etag&&(c["if-none-match"]=b.etag),b.vary)for(let a in b.vary)null!=b.vary[a]&&(c[a]=b.vary[a]);return c}function y(a,b,c,d,e,f){if(f?.["only-if-cached"]){let a=!1,b={paused:!1,rawHeaders:[],rawTrailers:[],pause(){this.paused=!0},resume(){this.paused=!1},abort:c=>{a=!0,d.onResponseError?.(b,c??new r)}};try{if(d.onRequestStart?.(b,null),a||(d.onResponseStart?.(b,504,{},"Gateway Timeout"),a))return;d.onResponseEnd?.(b,{})}catch(a){"function"==typeof d.onResponseError&&d.onResponseError(b,a)}return!0}return a(e,new g(b,c,d))}function z(a,b,c,g,h,i){let j=f.isStream(c.body)?c.body:e.from(c.body??[]);d(!j.destroyed,"stream should not be destroyed"),d(!j.readableDidRead,"stream should not be readableDidRead");let k=!1,l={rawHeaders:[],rawTrailers:[],resume(){j.resume()},pause(){j.pause()},get paused(){return j.isPaused()},get aborted(){return k},get reason(){return j.errored},abort(a){k=!0,j.destroy(a??new r)}};if(j.on("error",function(b){if(!this.readableEnded)if("function"==typeof a.onResponseError)a.onResponseError(l,b);else throw b}).on("close",function(){this.errored||a.onResponseEnd?.(l,{})}),a.onRequestStart?.(l,h),j.destroyed)return;let m={...c.headers,age:String(g)};i&&(m.warning='110 - "response is stale"'),l.rawHeaders=f.toRawHeaders(m),a.onResponseStart?.(l,c.statusCode,m,c.statusMessage),"HEAD"===b.method?j.destroy():j.on("data",function(b){a.onResponseData?.(l,b)})}function A(a,b,c,d,e,h,j){var k,l,m,n,r;let s;if(!j)return y(a,b,c,d,e,h);if("shared"===b.type&&Object.hasOwn(j.headers,"set-cookie"))return f.isStream(j.body)&&j.body.on("error",t).destroy(),w(b.store,c),y(a,b,c,d,e,h);let u=Date.now();if(u>j.deleteAt)return a(e,new g(b,c,d));let A=Math.round((u-j.cachedAt)/1e3),B=h?.["max-age"]!==void 0&&A>=h["max-age"],C=B||(k=j,l=h,m=b.type,(s=Date.now())>k.staleAt?!(!v(k,m)&&l?.["max-stale"])||s>k.staleAt+1e3*l["max-stale"]:!!l?.["min-fresh"]&&k.staleAt-s<=1e3*l["min-fresh"]),D=B||function(a,b,{headers:c={}}){return!!(b?.["no-cache"]||a.cacheControlDirectives?.["no-cache"]&&!Array.isArray(a.cacheControlDirectives["no-cache"]))||!!c["if-modified-since"]||!!c["if-none-match"]}(j,h,e);if(C||D){let k;if(f.isStream(e.body)&&0!==f.bodyLength(e.body))return a(e,new g(b,c,d));if(!D&&(n=j,r=b.type,!(!(k=n.cacheControlDirectives?.["stale-while-revalidate"])||v(n,r))&&Date.now()<=n.staleAt+1e3*k))return z(d,e,j,A,null,!0),queueMicrotask(()=>{let d=x(e,j);a({...e,headers:d},new g(b,c,{onRequestStart(){},onRequestUpgrade(){},onResponseStart(){},onResponseData(){},onResponseEnd(){},onResponseError(){}}))}),!0;let l=!1;if(!v(j,b.type)){let a=j.cacheControlDirectives["stale-if-error"]??h?.["stale-if-error"];a&&(l=u<j.staleAt+1e3*a)}let m=x(e,j);return a({...e,headers:m},new i((h,i,k,l)=>{if(h){if(304===k){if(function(a,b){if(b.vary&&p(b.vary)||"shared"===a&&Object.hasOwn(b,"set-cookie"))return!0;let c=b["cache-control"];if(!c)return!1;let d=o(c);return!0===d["no-store"]||"shared"===a&&!0===d.private}(b.type,l))return f.isStream(j.body)&&j.body.on("error",t).destroy(),w(b.store,c),a(e,new g(b,c,d));if(void 0!==l["cache-control"])w(b.store,c);else if(function(a,b){if(!b)return!1;for(let c in b)if(null==a.vary||!Object.hasOwn(a.vary,c))return!0;return!1}(j,l.vary?q(l.vary,e.headers):void 0))return f.isStream(j.body)&&j.body.on("error",t).destroy(),w(b.store,c),a(e,new g(b,c,d))}z(d,e,j,A,i,C)}else f.isStream(j.body)&&j.body.on("error",t).destroy()},new g(b,c,d),l))}f.isStream(e.body)&&e.body.on("error",t).destroy(),z(d,e,j,A,null,!1)}a.exports=(a={})=>{let{store:b=new h,methods:c=["GET"],cacheByDefault:d,type:e="shared",origins:i}=a;if("object"!=typeof a||null===a)throw TypeError(`expected type of opts to be an Object, got ${null===a?"null":typeof a}`);j(b,"opts.store"),k(c,"opts.methods");var p="opts.origins";if(void 0!==i){if(!Array.isArray(i))throw TypeError(`expected ${p} to be an array or undefined, got ${typeof i}`);for(let a=0;a<i.length;a++){let b=i[a];if("string"!=typeof b&&!(b instanceof RegExp))throw TypeError(`expected ${p}[${a}] to be a string or RegExp, got ${typeof b}`)}}if(void 0!==d&&"number"!=typeof d)throw TypeError(`expected opts.cacheByDefault to be number or undefined, got ${typeof d}`);if(void 0!==e&&"shared"!==e&&"private"!==e)throw TypeError(`expected opts.type to be shared, private, or undefined, got ${typeof e}`);let q={store:b,methods:c,cacheByDefault:d,type:e},r=[];for(let a=0;a<f.safeHTTPMethods.length;a++){let b=f.safeHTTPMethods[a];u(c,b)||r.push(b)}return(a,c)=>(d,e)=>{let h=l(d,c);if(!h||u(r,d.method))return a(d,e);if(void 0!==i){let b=h.toString().toLowerCase(),c=!1;for(let a=0;a<i.length;a++){let d=i[a];if("string"==typeof d){if(d.toLowerCase()===b){c=!0;break}}else if(d.test(b)){c=!0;break}}if(!c)return a(d,e)}d={...d,headers:n(d)};let j=d.headers?.["cache-control"]?o(d.headers["cache-control"]):!function(a){let b=a?.pragma;if(!b)return!1;let c=Array.isArray(b)?b:[b];for(let a=0;a<c.length;a++){let b=c[a];if("string"!=typeof b)continue;let d=b.split(",");for(let a=0;a<d.length;a++)if("no-cache"===d[a].replace(/^[\t ]+|[\t ]+$/g,"").toLowerCase())return!0}return!1}(d.headers)?void 0:{"no-cache":!0};if(j?.["no-store"])return a(d,e);let k=m(d,h);if(!u(f.safeHTTPMethods,d.method))return a(d,new g(q,k,e));let p=b.get(k);return p&&"function"==typeof p.then?p.then(b=>A(a,q,k,e,d,j,b)):A(a,q,k,e,d,j,p)}}},19608:a=>{"use strict";let b=["GET","HEAD","POST"],c=new Set(b),d=[301,302,303,307,308],e=new Set(d),f=["1","7","9","11","13","15","17","19","20","21","22","23","25","37","42","43","53","69","77","79","87","95","101","102","103","104","109","110","111","113","115","117","119","123","135","137","139","143","161","179","389","427","465","512","513","514","515","526","530","531","532","540","548","554","556","563","587","601","636","989","990","993","995","1719","1720","1723","2049","3659","4045","4190","5060","5061","6000","6566","6665","6666","6667","6668","6669","6679","6697","10080"],g=new Set(f),h=["no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"],i=["",...h],j=new Set(h),k=["GET","HEAD","OPTIONS","TRACE","QUERY"],l=new Set(k),m=["CONNECT","TRACE","TRACK"],n=new Set(m),o=["audio","audioworklet","font","image","manifest","paintworklet","script","style","track","video","xslt",""],p=new Set(o);a.exports={subresource:o,forbiddenMethods:m,requestBodyHeader:["content-encoding","content-language","content-location","content-type","content-length"],referrerPolicy:i,requestRedirect:["follow","manual","error"],requestMode:["navigate","same-origin","no-cors","cors"],requestCredentials:["omit","same-origin","include"],requestCache:["default","no-store","reload","no-cache","force-cache","only-if-cached"],redirectStatus:d,corsSafeListedMethods:b,nullBodyStatus:[101,204,205,304],safeMethods:k,badPorts:f,requestDuplex:["half"],subresourceSet:p,badPortsSet:g,redirectStatusSet:e,corsSafeListedMethodsSet:c,safeMethodsSet:l,forbiddenMethodsSet:n,referrerPolicyTokens:j}},19659:(a,b,c)=>{"use strict";a.exports=c.p+"static/media/catalog.fb7b1b70.json"},20012:(a,b,c)=>{"use strict";c.d(b,{Tl:()=>l});var d=c(63971),e=c(50969),f=c(38528);let g={usageUrl:(0,f.U)("codex").url,resetCreditsUrl:(0,f.U)("codex").resetCreditsUrl,resetCreditsConsumeUrl:(0,f.U)("codex").resetCreditsConsumeUrl};function h(a){return a?.workspaceId||a?.accountId||a?.chatgptAccountId||null}function i(a){return!a||"object"!=typeof a||Array.isArray(a)?null:a.rate_limit&&"object"==typeof a.rate_limit?a.rate_limit:a}function j(a){let b=(0,d.Gv)(a?.used_percent??a?.percent_used),c=null!==b&&b>=0?b:null,e=(0,d.Gv)(a?.limit_window_seconds);return{used:c,total:100,remaining:null===c?null:Math.max(0,100-c),...e>0?{windowSeconds:e,displayName:18e3===e?"Session (5h)":604800===e?"Weekly (7d)":`Window (${e/3600}h)`}:{},resetAt:(0,f.eZ)(a?.reset_at??a?.resets_at??a?.resetAt??null)||((0,d.Gv)(a?.reset_after_seconds)>0?new Date(Date.now()+1e3*(0,d.Gv)(a.reset_after_seconds)).toISOString():null),unlimited:!1}}function k(a,b,c){let d=i(c);if(!d)return!1;let e=d.primary_window||d.primary||c.primary_window||c.primary,f=d.secondary_window||d.secondary||c.secondary_window||c.secondary,g=!1;return e&&(a[b?`${b}_session`:"session"]=j(e),!0===d.limit_reached&&(a[b?`${b}_session`:"session"].blocked=!0),g=!0),f&&(a[b?`${b}_weekly`:"weekly"]=j(f),!0===d.limit_reached&&(a[b?`${b}_weekly`:"weekly"].blocked=!0),g=!0),g}async function l(a,b=null,c=null){try{let d=await (0,e.Fm)(g.usageUrl,{method:"GET",headers:{Authorization:`Bearer ${a}`,Accept:"application/json",...h(c)?{"ChatGPT-Account-ID":h(c)}:{}},identity:"codex-cli",provider:"codex",format:"codex"},b);if(!d.ok)return{message:`Codex connected. Usage API temporarily unavailable (${d.status}).`};let j=await d.json(),l=j.rate_limit||j.rate_limits||j.rate_limits_by_limit_id?.codex||{},m=function(a){if(a.code_review_rate_limit||a.review_rate_limit)return a.code_review_rate_limit||a.review_rate_limit;let b=a.rate_limits_by_limit_id;return b&&"object"==typeof b&&!Array.isArray(b)?b.code_review||b.codex_review||b.review||null:(Array.isArray(a.additional_rate_limits)?a.additional_rate_limits:[]).find(a=>{let b=String(a?.limit_name||a?.metered_feature||a?.id||"").toLowerCase();return"code_review"===b||"codex_review"===b||"review"===b||b.includes("review")})||null}(j),n=Math.max(0,(0,f.IQ)(j.rate_limit_reset_credits?.available_count,0)),o={};for(let a of(k(o,"",l),k(o,"review",m),Array.isArray(j.additional_rate_limits)?j.additional_rate_limits:[])){if(a===m)continue;let b=a.limit_name||a.metered_feature||a.id;"string"==typeof b&&b&&k(o,b,a)}for(let[a,b]of Object.entries(j.rate_limits_by_limit_id||{}))"codex"!==a&&b!==m&&k(o,a,b);for(let[a,b]of Object.entries(o))b.displayName&&"session"!==a&&"weekly"!==a&&(b.displayName=`${a.replace(/_(session|weekly)$/,"")} \xb7 ${b.displayName}`);return{plan:j.plan_type||j.summary?.plan||"unknown",limitReached:i(l)?.limit_reached||!1,reviewLimitReached:i(m)?.limit_reached||!1,resetCredits:{availableCount:n},quotas:o}}catch(a){throw Error(`Failed to fetch Codex usage: ${a.message}`)}}},20096:a=>{var b={};a.exports=b;var c={};b.encode=function(a,b,c){if("string"!=typeof b)throw TypeError('"alphabet" must be a string.');if(void 0!==c&&"number"!=typeof c)throw TypeError('"maxline" must be a number.');var d="";if(a instanceof Uint8Array){var e=0,f=b.length,g=b.charAt(0),h=[0];for(e=0;e<a.length;++e){for(var i=0,j=a[e];i<h.length;++i)j+=h[i]<<8,h[i]=j%f,j=j/f|0;for(;j>0;)h.push(j%f),j=j/f|0}for(e=0;0===a[e]&&e<a.length-1;++e)d+=g;for(e=h.length-1;e>=0;--e)d+=b[h[e]]}else d=function(a,b){var c=0,d=b.length,e=b.charAt(0),f=[0];for(c=0;c<a.length();++c){for(var g=0,h=a.at(c);g<f.length;++g)h+=f[g]<<8,f[g]=h%d,h=h/d|0;for(;h>0;)f.push(h%d),h=h/d|0}var i="";for(c=0;0===a.at(c)&&c<a.length()-1;++c)i+=e;for(c=f.length-1;c>=0;--c)i+=b[f[c]];return i}(a,b);if(c){var k=RegExp(".{1,"+c+"}","g");d=d.match(k).join("\r\n")}return d},b.decode=function(a,b){if("string"!=typeof a)throw TypeError('"input" must be a string.');if("string"!=typeof b)throw TypeError('"alphabet" must be a string.');var d=c[b];if(!d){d=c[b]=[];for(var e=0;e<b.length;++e)d[b.charCodeAt(e)]=e}a=a.replace(/\s/g,"");for(var f=b.length,g=b.charAt(0),h=[0],e=0;e<a.length;e++){var i=d[a.charCodeAt(e)];if(void 0===i)return;for(var j=0,k=i;j<h.length;++j)k+=h[j]*f,h[j]=255&k,k>>=8;for(;k>0;)h.push(255&k),k>>=8}for(var l=0;a[l]===g&&l<a.length-1;++l)h.push(0);return"u">typeof Buffer?Buffer.from(h.reverse()):new Uint8Array(h.reverse())}},20308:(a,b,c)=>{var d=c(45654);if(c(45518),c(63070),c(88819),c(1277),c(36105),c(70710),c(49345),c(29984),c(67382),c(10401),c(33889),void 0===e)var e=d.jsbn.BigInteger;var f=d.asn1,g=d.pki=d.pki||{};a.exports=g.pbe=d.pbe=d.pbe||{};var h=g.oids,i={name:"EncryptedPrivateKeyInfo",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:f.Class.UNIVERSAL,type:f.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:f.Class.UNIVERSAL,type:f.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},j={name:"PBES2Algorithms",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:f.Class.UNIVERSAL,type:f.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:f.Class.UNIVERSAL,type:f.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:f.Class.UNIVERSAL,type:f.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:f.Class.UNIVERSAL,type:f.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:f.Class.UNIVERSAL,type:f.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:f.Class.UNIVERSAL,type:f.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:f.Class.UNIVERSAL,type:f.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},k={name:"pkcs-12PbeParams",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:f.Class.UNIVERSAL,type:f.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:f.Class.UNIVERSAL,type:f.Type.INTEGER,constructed:!1,capture:"iterations"}]};function l(a,b){return a.start().update(b).digest().getBytes()}function m(a){var b;if(a){if(!(b=g.oids[f.derToOid(a)])){var c=Error("Unsupported PRF OID.");throw c.oid=a,c.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],c}}else b="hmacWithSHA1";return n(b)}function n(a){var b=d.md;switch(a){case"hmacWithSHA224":b=d.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":a=a.substr(8).toLowerCase();break;default:var c=Error("Unsupported PRF algorithm.");throw c.algorithm=a,c.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],c}if(!b||!(a in b))throw Error("Unknown hash algorithm: "+a);return b[a].create()}g.encryptPrivateKeyInfo=function(a,b,c){(c=c||{}).saltSize=c.saltSize||8,c.count=c.count||2048,c.algorithm=c.algorithm||"aes128",c.prfAlgorithm=c.prfAlgorithm||"sha1";var e=d.random.getBytesSync(c.saltSize),i=c.count,j=f.integerToDer(i);if(0===c.algorithm.indexOf("aes")||"des"===c.algorithm){switch(c.algorithm){case"aes128":q=16,t=16,u=h["aes128-CBC"],v=d.aes.createEncryptionCipher;break;case"aes192":q=24,t=16,u=h["aes192-CBC"],v=d.aes.createEncryptionCipher;break;case"aes256":q=32,t=16,u=h["aes256-CBC"],v=d.aes.createEncryptionCipher;break;case"des":q=8,t=8,u=h.desCBC,v=d.des.createEncryptionCipher;break;default:var k,l,m,o,p,q,r,s,t,u,v,w=Error("Cannot encrypt private key. Unknown encryption algorithm.");throw w.algorithm=c.algorithm,w}var x="hmacWith"+c.prfAlgorithm.toUpperCase(),y=n(x),z=d.pkcs5.pbkdf2(b,e,i,q,y),A=d.random.getBytesSync(t),B=v(z);B.start(A),B.update(f.toDer(a)),B.finish(),s=B.output.getBytes();var C=(k=e,l=j,m=q,o=x,p=f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.OCTETSTRING,!1,k),f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,l.getBytes())]),"hmacWithSHA1"!==o&&p.value.push(f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,d.util.hexToBytes(m.toString(16))),f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.OID,!1,f.oidToDer(g.oids[o]).getBytes()),f.create(f.Class.UNIVERSAL,f.Type.NULL,!1,"")])),p);r=f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.OID,!1,f.oidToDer(h.pkcs5PBES2).getBytes()),f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.OID,!1,f.oidToDer(h.pkcs5PBKDF2).getBytes()),C]),f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.OID,!1,f.oidToDer(u).getBytes()),f.create(f.Class.UNIVERSAL,f.Type.OCTETSTRING,!1,A)])])])}else if("3des"===c.algorithm){q=24;var D=new d.util.ByteBuffer(e),z=g.pbe.generatePkcs12Key(b,D,1,i,q),A=g.pbe.generatePkcs12Key(b,D,2,i,q),B=d.des.createEncryptionCipher(z);B.start(A),B.update(f.toDer(a)),B.finish(),s=B.output.getBytes(),r=f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.OID,!1,f.oidToDer(h["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.OCTETSTRING,!1,e),f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,j.getBytes())])])}else{var w=Error("Cannot encrypt private key. Unknown encryption algorithm.");throw w.algorithm=c.algorithm,w}return f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[r,f.create(f.Class.UNIVERSAL,f.Type.OCTETSTRING,!1,s)])},g.decryptPrivateKeyInfo=function(a,b){var c=null,e={},h=[];if(!f.validate(a,i,e,h)){var j=Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw j.errors=h,j}var k=f.derToOid(e.encryptionOid),l=g.pbe.getCipher(k,e.encryptionParams,b),m=d.util.createBuffer(e.encryptedData);return l.update(m),l.finish()&&(c=f.fromDer(l.output)),c},g.encryptedPrivateKeyToPem=function(a,b){var c={type:"ENCRYPTED PRIVATE KEY",body:f.toDer(a).getBytes()};return d.pem.encode(c,{maxline:b})},g.encryptedPrivateKeyFromPem=function(a){var b=d.pem.decode(a)[0];if("ENCRYPTED PRIVATE KEY"!==b.type){var c=Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw c.headerType=b.type,c}if(b.procType&&"ENCRYPTED"===b.procType.type)throw Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return f.fromDer(b.body)},g.encryptRsaPrivateKey=function(a,b,c){if(!(c=c||{}).legacy){var e,h,i,j,k=g.wrapRsaPrivateKey(g.privateKeyToAsn1(a));return k=g.encryptPrivateKeyInfo(k,b,c),g.encryptedPrivateKeyToPem(k)}switch(c.algorithm){case"aes128":e="AES-128-CBC",i=16,h=d.random.getBytesSync(16),j=d.aes.createEncryptionCipher;break;case"aes192":e="AES-192-CBC",i=24,h=d.random.getBytesSync(16),j=d.aes.createEncryptionCipher;break;case"aes256":e="AES-256-CBC",i=32,h=d.random.getBytesSync(16),j=d.aes.createEncryptionCipher;break;case"3des":e="DES-EDE3-CBC",i=24,h=d.random.getBytesSync(8),j=d.des.createEncryptionCipher;break;case"des":e="DES-CBC",i=8,h=d.random.getBytesSync(8),j=d.des.createEncryptionCipher;break;default:var l=Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+c.algorithm+'".');throw l.algorithm=c.algorithm,l}var m=j(d.pbe.opensslDeriveBytes(b,h.substr(0,8),i));m.start(h),m.update(f.toDer(g.privateKeyToAsn1(a))),m.finish();var n={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:e,parameters:d.util.bytesToHex(h).toUpperCase()},body:m.output.getBytes()};return d.pem.encode(n)},g.decryptRsaPrivateKey=function(a,b){var c=null,e=d.pem.decode(a)[0];if("ENCRYPTED PRIVATE KEY"!==e.type&&"PRIVATE KEY"!==e.type&&"RSA PRIVATE KEY"!==e.type){var h=Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw h.headerType=h,h}if(e.procType&&"ENCRYPTED"===e.procType.type){switch(e.dekInfo.algorithm){case"DES-CBC":i=8,j=d.des.createDecryptionCipher;break;case"DES-EDE3-CBC":i=24,j=d.des.createDecryptionCipher;break;case"AES-128-CBC":i=16,j=d.aes.createDecryptionCipher;break;case"AES-192-CBC":i=24,j=d.aes.createDecryptionCipher;break;case"AES-256-CBC":i=32,j=d.aes.createDecryptionCipher;break;case"RC2-40-CBC":i=5,j=function(a){return d.rc2.createDecryptionCipher(a,40)};break;case"RC2-64-CBC":i=8,j=function(a){return d.rc2.createDecryptionCipher(a,64)};break;case"RC2-128-CBC":i=16,j=function(a){return d.rc2.createDecryptionCipher(a,128)};break;default:var i,j,h=Error('Could not decrypt private key; unsupported encryption algorithm "'+e.dekInfo.algorithm+'".');throw h.algorithm=e.dekInfo.algorithm,h}var k=d.util.hexToBytes(e.dekInfo.parameters),l=j(d.pbe.opensslDeriveBytes(b,k.substr(0,8),i));if(l.start(k),l.update(d.util.createBuffer(e.body)),!l.finish())return c;c=l.output.getBytes()}else c=e.body;return null!==(c="ENCRYPTED PRIVATE KEY"===e.type?g.decryptPrivateKeyInfo(f.fromDer(c),b):f.fromDer(c))&&(c=g.privateKeyFromAsn1(c)),c},g.pbe.generatePkcs12Key=function(a,b,c,e,f,g){if(null==g){if(!("sha1"in d.md))throw Error('"sha1" hash algorithm unavailable.');g=d.md.sha1.create()}var h,i,j=g.digestLength,k=g.blockLength,l=new d.util.ByteBuffer,m=new d.util.ByteBuffer;if(null!=a){for(i=0;i<a.length;i++)m.putInt16(a.charCodeAt(i));m.putInt16(0)}var n=m.length(),o=b.length(),p=new d.util.ByteBuffer;p.fillWithByte(c,k);var q=k*Math.ceil(o/k),r=new d.util.ByteBuffer;for(i=0;i<q;i++)r.putByte(b.at(i%o));var s=k*Math.ceil(n/k),t=new d.util.ByteBuffer;for(i=0;i<s;i++)t.putByte(m.at(i%n));var u=r;u.putBuffer(t);for(var v=Math.ceil(f/j),w=1;w<=v;w++){var x=new d.util.ByteBuffer;x.putBytes(p.bytes()),x.putBytes(u.bytes());for(var y=0;y<e;y++)g.start(),g.update(x.getBytes()),x=g.digest();var z=new d.util.ByteBuffer;for(i=0;i<k;i++)z.putByte(x.at(i%j));var A=Math.ceil(o/k)+Math.ceil(n/k),B=new d.util.ByteBuffer;for(h=0;h<A;h++){var C=new d.util.ByteBuffer(u.getBytes(k)),D=511;for(i=z.length()-1;i>=0;i--)D>>=8,D+=z.at(i)+C.at(i),C.setAt(i,255&D);B.putBuffer(C)}u=B,l.putBuffer(x)}return l.truncate(l.length()-f),l},g.pbe.getCipher=function(a,b,c){switch(a){case g.oids.pkcs5PBES2:return g.pbe.getCipherForPBES2(a,b,c);case g.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case g.oids["pbewithSHAAnd40BitRC2-CBC"]:return g.pbe.getCipherForPKCS12PBE(a,b,c);default:var d=Error("Cannot read encrypted PBE data block. Unsupported OID.");throw d.oid=a,d.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],d}},g.pbe.getCipherForPBES2=function(a,b,c){var e,h,i={},k=[];if(!f.validate(b,j,i,k)){var l=Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw l.errors=k,l}if((a=f.derToOid(i.kdfOid))!==g.oids.pkcs5PBKDF2){var l=Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw l.oid=a,l.supportedOids=["pkcs5PBKDF2"],l}if((a=f.derToOid(i.encOid))!==g.oids["aes128-CBC"]&&a!==g.oids["aes192-CBC"]&&a!==g.oids["aes256-CBC"]&&a!==g.oids["des-EDE3-CBC"]&&a!==g.oids.desCBC){var l=Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw l.oid=a,l.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],l}var n=i.kdfSalt,o=d.util.createBuffer(i.kdfIterationCount);switch(o=o.getInt(o.length()<<3),g.oids[a]){case"aes128-CBC":e=16,h=d.aes.createDecryptionCipher;break;case"aes192-CBC":e=24,h=d.aes.createDecryptionCipher;break;case"aes256-CBC":e=32,h=d.aes.createDecryptionCipher;break;case"des-EDE3-CBC":e=24,h=d.des.createDecryptionCipher;break;case"desCBC":e=8,h=d.des.createDecryptionCipher}var p=m(i.prfOid),q=d.pkcs5.pbkdf2(c,n,o,e,p),r=i.encIv,s=h(q);return s.start(r),s},g.pbe.getCipherForPKCS12PBE=function(a,b,c){var e,h,i,j={},l=[];if(!f.validate(b,k,j,l)){var n=Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw n.errors=l,n}var o=d.util.createBuffer(j.salt),p=d.util.createBuffer(j.iterations);switch(p=p.getInt(p.length()<<3),a){case g.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:e=24,h=8,i=d.des.startDecrypting;break;case g.oids["pbewithSHAAnd40BitRC2-CBC"]:e=5,h=8,i=function(a,b){var c=d.rc2.createDecryptionCipher(a,40);return c.start(b,null),c};break;default:var n=Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw n.oid=a,n}var q=m(j.prfOid),r=g.pbe.generatePkcs12Key(c,o,1,p,e,q);return q.start(),i(r,g.pbe.generatePkcs12Key(c,o,2,p,h,q))},g.pbe.opensslDeriveBytes=function(a,b,c,e){if(null==e){if(!("md5"in d.md))throw Error('"md5" hash algorithm unavailable.');e=d.md.md5.create()}null===b&&(b="");for(var f=[l(e,a+b)],g=16,h=1;g<c;++h,g+=16)f.push(l(e,f[h-1]+a+b));return f.join("").substr(0,c)}},20437:(a,b,c)=>{"use strict";c.d(b,{AL:()=>j,HG:()=>i,Jh:()=>m,KQ:()=>k,Or:()=>l,ok:()=>h.ok});var d=c(76760),e=c.n(d),f=c(73024),g=c.n(f),h=c(53859);let i=e().join(h.nJ,"db"),j=e().join(i,"data.sqlite"),k=e().join(i,"backups"),l={main:e().join(h.nJ,"db.json"),usage:e().join(h.nJ,"usage.json"),disabled:e().join(h.nJ,"disabledModels.json"),details:e().join(h.nJ,"request-details.json")};function m(){for(let a of[h.nJ,i,k])g().existsSync(a)||g().mkdirSync(a,{recursive:!0})}},20579:(a,b,c)=>{"use strict";let d,{Writable:e}=c(57075),{assertCacheKey:f,assertCacheValue:g}=c(79468);a.exports=class{#g=2e9;#h=1/0;#i;#j;#k;#l;#m;#n;#o;#p;constructor(a){if(a){if("object"!=typeof a)throw TypeError("SqliteCacheStore options must be an object");if(void 0!==a.maxEntrySize){if("number"!=typeof a.maxEntrySize||!Number.isInteger(a.maxEntrySize)||a.maxEntrySize<0)throw TypeError("SqliteCacheStore options.maxEntrySize must be a non-negative integer");if(a.maxEntrySize>2e9)throw TypeError("SqliteCacheStore options.maxEntrySize must be less than 2gb");this.#g=a.maxEntrySize}if(void 0!==a.maxCount){if("number"!=typeof a.maxCount||!Number.isInteger(a.maxCount)||a.maxCount<0)throw TypeError("SqliteCacheStore options.maxCount must be a non-negative integer");this.#h=a.maxCount}}d||(d=c(79868).DatabaseSync),this.#i=new d(a?.location??":memory:"),this.#i.exec(`
|
|
37
|
+
`}},18184:(a,b,c)=>{"use strict";function d({id:a,created:b,model:c},e,f=null){return{id:a,object:"chat.completion.chunk",created:b,model:c,choices:[{index:0,delta:e,finish_reason:f}]}}c.d(b,{k:()=>d})},18205:(a,b,c)=>{"use strict";c.d(b,{D:()=>f});var d=c(46248),e=c(38421);class f extends d.L{constructor(){super("ollama-local")}buildUrl(a,b,c=0,d=null){return`${(0,e.Ak)(d)}/api/chat`}}},18586:(a,b,c)=>{"use strict";c.d(b,{au:()=>m});var d=c(52655);let e="<|tool▁calls▁begin|>",f="<|tool▁call▁begin|>",g="<|tool▁sep|>",h="<|tool▁call▁end|>",i="<|tool▁calls▁end|>",j="<|DSML|tool_calls>",k=/(<|tool▁calls▁begin|>|<|DSML|tool_calls>)/,l=[[/deepseek|composer/i,{name:"deepseek",detect:a=>k.test(a),parse(a){let b=function(a){let b=a.indexOf(e);if(b<0)return null;let c=a.slice(0,b).trim(),j=a.indexOf(i,b),k=j>=0?a.slice(b+e.length,j):a.slice(b+e.length),l=j>=0?a.slice(j+i.length).trim():"",m=[],n=k.split(f).filter(Boolean);for(let a=0;a<n.length;a++){let b=n[a],c=function(a,b){let c=a;c.startsWith(f)&&(c=c.slice(f.length)),c.endsWith(h)&&(c=c.slice(0,-h.length));let e=c.indexOf(g);if(e<0)return null;let i=c.slice(e+g.length),j=i.search(/[\n`]/),k=j>0?i.slice(0,j).trim():i.trim();if(!k)return null;let l="{}",m=i.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/);if(m)l=m[1].trim();else{let a=i.slice(j>=0?j:0).trim();(a.startsWith("{")||a.startsWith("["))&&(l=a)}try{JSON.parse(l)}catch{l=JSON.stringify({_raw:l})}return{id:(0,d.J4)(0,b,k),type:"function",function:{name:k,arguments:l}}}(b=f+b,a);c&&m.push(c)}return 0===m.length?null:{content:[c,l].filter(Boolean).join("\n").trim()||null,toolCalls:m}}(a);if(b)return b;let c=function(a){let b,c=a.indexOf(j);if(c<0)return null;let e=a.slice(0,c).trim(),f=a.slice(c+j.length);if(f.length>5e5)return null;let g=/<|DSML|invoke\s+name="([^"]+)">([\s\S]*?)(?:<\/|DSML|invoke>|$)/g,h=/<|DSML|parameter\s+name="([^"]+)"\s+string="(true|false)">([\s\S]*?)(?=<|DSML|parameter|<\/|DSML|invoke>|$)/g,i=[];for(;null!==(b=g.exec(f));){let a,c=b[1],e=b[2],f={};for(h.lastIndex=0;null!==(a=h.exec(e));){let b=a[1],c="true"===a[2],d=a[3].trim();if(c)f[b]=d;else try{f[b]=JSON.parse(d)}catch{f[b]=d}}i.push({id:(0,d.J4)(0,i.length,c),type:"function",function:{name:c,arguments:JSON.stringify(f)}})}return 0===i.length?null:{content:e||null,toolCalls:i}}(a);return c||null}}]];function m(a,b){if(!a||!b)return null;let c=function(a){if(!a)return null;for(let[b,c]of l)if(b.test(a))return c;return null}(b);return c&&c.detect(a)?c.parse(a):null}},18762:(a,b,c)=>{"use strict";c(87350),c(68531),c(17438),c(22268),c(18101),c(73081),c(1031),c(19016),c(39490),new TextEncoder},18922:(a,b,c)=>{"use strict";let d;c.d(b,{ox:()=>z,pS:()=>A});var e=c(24081),f=c(50743),g=c(68176),h=c(22268);let i=null,j=0;async function k(){if(i&&Date.now()-j<5e3)return i;try{let{getSettings:a}=await Promise.resolve().then(c.bind(c,45874)),b=await a(),d="false"!==process.env.OBSERVABILITY_ENABLED;i={enabled:"boolean"==typeof b.enableObservability?b.enableObservability:d,maxRecords:b.observabilityMaxRecords||parseInt(process.env.OBSERVABILITY_MAX_RECORDS||String(200),10),batchSize:b.observabilityBatchSize||parseInt(process.env.OBSERVABILITY_BATCH_SIZE||String(20),10),flushIntervalMs:b.observabilityFlushIntervalMs||parseInt(process.env.OBSERVABILITY_FLUSH_INTERVAL_MS||String(5e3),10),maxJsonSize:1024*(b.observabilityMaxJsonSize||parseInt(process.env.OBSERVABILITY_MAX_JSON_SIZE||"5",10)),maxBuffer:parseInt(process.env.OBSERVABILITY_MAX_BUFFER||String(5e3),10)||5e3}}catch{i={enabled:!1,maxRecords:200,batchSize:20,flushIntervalMs:5e3,maxJsonSize:5120,maxBuffer:5e3}}return j=Date.now(),i}let l=[],m=null,n=!1,o=0,p=0,q=new Set(["accesstoken","refreshtoken","idtoken","apikey","copilottoken","cookies","clientsecret","secretaccesskey","authorization","xapikey","xswitchboardkey","cookie","token","password","passwd","secret","bearer","setcookie","xauthtoken"]);function r(a,b=new WeakSet){if(!a||"object"!=typeof a||b.has(a))return a;b.add(a);let c=null;if(Array.isArray(a)){for(let d=0;d<a.length;d++){let e=r(a[d],b);e===a[d]||c||(c=a.slice()),c&&(c[d]=e)}return c||a}for(let[d,e]of Object.entries(a)){let f=q.has(String(d).toLowerCase().replace(/[-_]/g,""))?"[REDACTED]":r(e,b);f===e||c||(c={...a}),c&&(c[d]=f)}return c||a}let s=new WeakMap;function t(a,b,c){if(a&&("object"==typeof a||"function"==typeof a))try{s.set(a,{maxSize:b,result:c})}catch{}return c}function u(a,b){let c;if(null==a)return{};if("object"==typeof a||"function"==typeof a)try{let c=s.get(a);if(c&&c.maxSize===b)return c.result}catch{}try{c=JSON.stringify(a)}catch{let c=String(a).substring(0,200);return t(a,b,{_truncated:!0,_originalSize:c.length,_preview:c,_error:"stringify_failed"})}return((0,h.nx)(a,c.length),c.length>b)?t(a,b,{_truncated:!0,_originalSize:c.length,_preview:c.substring(0,200)}):t(a,b,a)}function v(a,b,c){a.transaction(()=>{for(let d of c){let c=function(a,b){var c;let d,e,f;return a.id||(c=a.model,d=new Date().toISOString(),e=Math.random().toString(36).substring(2,8),f=c?c.replace(/[^a-zA-Z0-9-]/g,"-"):"unknown",a.id=`${d}-${e}-${f}`),a.timestamp||(a.timestamp=new Date().toISOString()),{id:a.id,provider:a.provider||null,model:a.model||null,connectionId:a.connectionId||null,timestamp:a.timestamp,status:a.status||null,latency:a.latency||{},tokens:a.tokens||{},request:u(a.request,b.maxJsonSize),providerRequest:u(a.providerRequest,b.maxJsonSize),providerResponse:u(a.providerResponse,b.maxJsonSize),response:u(a.response,b.maxJsonSize),pxpipe:a.pxpipe||void 0,toolHistory:a.toolHistory||void 0,rtk:a.rtk?{...a.rtk,hits:a.rtk.hits?.slice(0,50)}:void 0}}(d,b);a.run("INSERT INTO requestDetails(id, timestamp, provider, model, connectionId, status, data) VALUES(?, ?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET timestamp = excluded.timestamp, provider = excluded.provider, model = excluded.model, connectionId = excluded.connectionId, status = excluded.status, data = excluded.data",[c.id,c.timestamp,c.provider,c.model,c.connectionId,c.status,(0,f.s)(c)])}let d=a.get("SELECT timestamp FROM requestDetails ORDER BY timestamp DESC LIMIT 1 OFFSET ?",[Math.max(0,b.maxRecords-1)]);d&&a.run("DELETE FROM requestDetails WHERE timestamp < ?",[d.timestamp])})}let w=null,x=null;async function y(){if(n||0===l.length)return;n=!0;let a=null;try{for(;l.length>0;){let b=l.splice(0,l.length);try{let a=await (0,e.c)(),c=await k();w=a,x=c,v(a,c,b)}catch(c){a=c,l.unshift(...b);break}}}finally{n=!1}a&&console.error("[requestDetailsRepo] Batch write failed:",a)}async function z(a){let b=await k();if(!b.enabled)return;x=b;try{(0,e.c)().then(a=>{w=a},()=>{})}catch{}let c=function(a,b){if(!a||"object"!=typeof a)return a;let c={...a};return c.request?.headers&&(c.request={...c.request,headers:function(a){if(!a||"object"!=typeof a)return{};let b=["authorization","x-api-key","x-switchboard-key","cookie","token","api-key"],c={...a};for(let a of Object.keys(c))b.some(b=>a.toLowerCase().includes(b))&&delete c[a];return c}(c.request.headers)}),c.request=u(r(c.request),b),c.providerRequest=u(r(c.providerRequest),b),c.providerResponse=u(r(c.providerResponse),b),c.response=u(r(c.response),b),c.body&&(c.body=u(r(c.body),b)),c.raw&&(c.raw=u(r(c.raw),b)),c}(a,b.maxJsonSize);if(l.length>=b.maxBuffer){l.shift(),p++;let a=Date.now();a-o>6e4&&(console.warn(`[requestDetailsRepo] observability buffer full (${b.maxBuffer}); dropped ${p} record(s). Raise OBSERVABILITY_MAX_BUFFER or lower OBSERVABILITY_FLUSH_INTERVAL_MS.`),o=a,p=0)}l.push(c),l.length>=b.batchSize?(m&&(clearTimeout(m),m=null),y().catch(a=>console.error("[requestDetailsRepo] flush err:",a))):m||(m=setTimeout(()=>{m=null,y().catch(()=>{})},b.flushIntervalMs))}let A=async()=>{m&&(clearTimeout(m),m=null),l.length>0&&await y()},B="__switchboardRequestDetailsBeforeExitHandler",C="__switchboardRequestDetailsSyncFlushUnregister";(d=globalThis[B])&&process.off("beforeExit",d),globalThis[B]=A,process.on("beforeExit",A);try{let a=globalThis[C];if("function"==typeof a)try{a()}catch{}globalThis[C]=(0,g.H)(function(){if(0===l.length)return 0;let a=w,b=x;if(!a||!b)return 0;try{m&&(clearTimeout(m),m=null);let c=l.splice(0,l.length);try{v(a,b,c)}catch{return l.unshift(...c),0}return c.length}catch{return 0}},{flush:!0})}catch{}},19016:(a,b,c)=>{"use strict";c.d(b,{$U:()=>d,pb:()=>e,uB:()=>f});let d="data: [DONE]\n\n",e={"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"},f={"Content-Type":"text/event-stream","Cache-Control":"no-cache","X-Accel-Buffering":"no"}},19071:(a,b,c)=>{"use strict";let{kConnected:d,kPending:e,kRunning:f,kSize:g,kFree:h,kQueued:i}=c(49176);class j{constructor(a){this.connected=a[d],this.pending=a[e],this.running=a[f],this.size=a[g]}}class k{constructor(a){this.connected=a[d],this.free=a[h],this.pending=a[e],this.queued=a[i],this.running=a[f],this.size=a[g]}}a.exports={ClientStats:j,PoolStats:k}},19396:(a,b,c)=>{var d=c(45654);c(33889),d.cipher=d.cipher||{};var e=a.exports=d.cipher.modes=d.cipher.modes||{};function f(a,b){if("string"==typeof a&&(a=d.util.createBuffer(a)),d.util.isArray(a)&&a.length>4){var c=a;a=d.util.createBuffer();for(var e=0;e<c.length;++e)a.putByte(c[e])}if(a.length()<b)throw Error("Invalid IV length; got "+a.length()+" bytes and expected "+b+" bytes.");if(!d.util.isArray(a)){for(var f=[],g=b/4,e=0;e<g;++e)f.push(a.getInt32());a=f}return a}function g(a){a[a.length-1]=a[a.length-1]+1|0}function h(a){return[a/0x100000000|0,0|a]}e.ecb=function(a){a=a||{},this.name="ECB",this.cipher=a.cipher,this.blockSize=a.blockSize||16,this._ints=this.blockSize/4,this._inBlock=Array(this._ints),this._outBlock=Array(this._ints)},e.ecb.prototype.start=function(a){},e.ecb.prototype.encrypt=function(a,b,c){if(a.length()<this.blockSize&&!(c&&a.length()>0))return!0;for(var d=0;d<this._ints;++d)this._inBlock[d]=a.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var d=0;d<this._ints;++d)b.putInt32(this._outBlock[d])},e.ecb.prototype.decrypt=function(a,b,c){if(a.length()<this.blockSize&&!(c&&a.length()>0))return!0;for(var d=0;d<this._ints;++d)this._inBlock[d]=a.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var d=0;d<this._ints;++d)b.putInt32(this._outBlock[d])},e.ecb.prototype.pad=function(a,b){var c=a.length()===this.blockSize?this.blockSize:this.blockSize-a.length();return a.fillWithByte(c,c),!0},e.ecb.prototype.unpad=function(a,b){if(b.overflow>0)return!1;var c=a.length(),d=a.at(c-1);return!(d>this.blockSize<<2)&&(a.truncate(d),!0)},e.cbc=function(a){a=a||{},this.name="CBC",this.cipher=a.cipher,this.blockSize=a.blockSize||16,this._ints=this.blockSize/4,this._inBlock=Array(this._ints),this._outBlock=Array(this._ints)},e.cbc.prototype.start=function(a){if(null===a.iv){if(!this._prev)throw Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in a)this._iv=f(a.iv,this.blockSize),this._prev=this._iv.slice(0);else throw Error("Invalid IV parameter.")},e.cbc.prototype.encrypt=function(a,b,c){if(a.length()<this.blockSize&&!(c&&a.length()>0))return!0;for(var d=0;d<this._ints;++d)this._inBlock[d]=this._prev[d]^a.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var d=0;d<this._ints;++d)b.putInt32(this._outBlock[d]);this._prev=this._outBlock},e.cbc.prototype.decrypt=function(a,b,c){if(a.length()<this.blockSize&&!(c&&a.length()>0))return!0;for(var d=0;d<this._ints;++d)this._inBlock[d]=a.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var d=0;d<this._ints;++d)b.putInt32(this._prev[d]^this._outBlock[d]);this._prev=this._inBlock.slice(0)},e.cbc.prototype.pad=function(a,b){var c=a.length()===this.blockSize?this.blockSize:this.blockSize-a.length();return a.fillWithByte(c,c),!0},e.cbc.prototype.unpad=function(a,b){if(b.overflow>0)return!1;var c=a.length(),d=a.at(c-1);return!(d>this.blockSize<<2)&&(a.truncate(d),!0)},e.cfb=function(a){a=a||{},this.name="CFB",this.cipher=a.cipher,this.blockSize=a.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialBlock=Array(this._ints),this._partialOutput=d.util.createBuffer(),this._partialBytes=0},e.cfb.prototype.start=function(a){if(!("iv"in a))throw Error("Invalid IV parameter.");this._iv=f(a.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.cfb.prototype.encrypt=function(a,b,c){var d=a.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize){for(var e=0;e<this._ints;++e)this._inBlock[e]=a.getInt32()^this._outBlock[e],b.putInt32(this._inBlock[e]);return}var f=(this.blockSize-d)%this.blockSize;f>0&&(f=this.blockSize-f),this._partialOutput.clear();for(var e=0;e<this._ints;++e)this._partialBlock[e]=a.getInt32()^this._outBlock[e],this._partialOutput.putInt32(this._partialBlock[e]);if(f>0)a.read-=this.blockSize;else for(var e=0;e<this._ints;++e)this._inBlock[e]=this._partialBlock[e];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),f>0&&!c)return b.putBytes(this._partialOutput.getBytes(f-this._partialBytes)),this._partialBytes=f,!0;b.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0},e.cfb.prototype.decrypt=function(a,b,c){var d=a.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize){for(var e=0;e<this._ints;++e)this._inBlock[e]=a.getInt32(),b.putInt32(this._inBlock[e]^this._outBlock[e]);return}var f=(this.blockSize-d)%this.blockSize;f>0&&(f=this.blockSize-f),this._partialOutput.clear();for(var e=0;e<this._ints;++e)this._partialBlock[e]=a.getInt32(),this._partialOutput.putInt32(this._partialBlock[e]^this._outBlock[e]);if(f>0)a.read-=this.blockSize;else for(var e=0;e<this._ints;++e)this._inBlock[e]=this._partialBlock[e];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),f>0&&!c)return b.putBytes(this._partialOutput.getBytes(f-this._partialBytes)),this._partialBytes=f,!0;b.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0},e.ofb=function(a){a=a||{},this.name="OFB",this.cipher=a.cipher,this.blockSize=a.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialOutput=d.util.createBuffer(),this._partialBytes=0},e.ofb.prototype.start=function(a){if(!("iv"in a))throw Error("Invalid IV parameter.");this._iv=f(a.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.ofb.prototype.encrypt=function(a,b,c){var d=a.length();if(0===a.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize){for(var e=0;e<this._ints;++e)b.putInt32(a.getInt32()^this._outBlock[e]),this._inBlock[e]=this._outBlock[e];return}var f=(this.blockSize-d)%this.blockSize;f>0&&(f=this.blockSize-f),this._partialOutput.clear();for(var e=0;e<this._ints;++e)this._partialOutput.putInt32(a.getInt32()^this._outBlock[e]);if(f>0)a.read-=this.blockSize;else for(var e=0;e<this._ints;++e)this._inBlock[e]=this._outBlock[e];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),f>0&&!c)return b.putBytes(this._partialOutput.getBytes(f-this._partialBytes)),this._partialBytes=f,!0;b.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0},e.ofb.prototype.decrypt=e.ofb.prototype.encrypt,e.ctr=function(a){a=a||{},this.name="CTR",this.cipher=a.cipher,this.blockSize=a.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=Array(this._ints),this._partialOutput=d.util.createBuffer(),this._partialBytes=0},e.ctr.prototype.start=function(a){if(!("iv"in a))throw Error("Invalid IV parameter.");this._iv=f(a.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},e.ctr.prototype.encrypt=function(a,b,c){var d=a.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var e=0;e<this._ints;++e)b.putInt32(a.getInt32()^this._outBlock[e]);else{var f=(this.blockSize-d)%this.blockSize;f>0&&(f=this.blockSize-f),this._partialOutput.clear();for(var e=0;e<this._ints;++e)this._partialOutput.putInt32(a.getInt32()^this._outBlock[e]);if(f>0&&(a.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),f>0&&!c)return b.putBytes(this._partialOutput.getBytes(f-this._partialBytes)),this._partialBytes=f,!0;b.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}g(this._inBlock)},e.ctr.prototype.decrypt=e.ctr.prototype.encrypt,e.gcm=function(a){a=a||{},this.name="GCM",this.cipher=a.cipher,this.blockSize=a.blockSize||16,this._ints=this.blockSize/4,this._inBlock=Array(this._ints),this._outBlock=Array(this._ints),this._partialOutput=d.util.createBuffer(),this._partialBytes=0,this._R=0xe1000000},e.gcm.prototype.start=function(a){if(!("iv"in a))throw Error("Invalid IV parameter.");var b,c=d.util.createBuffer(a.iv);if(this._cipherLength=0,b="additionalData"in a?d.util.createBuffer(a.additionalData):d.util.createBuffer(),"tagLength"in a?this._tagLength=a.tagLength:this._tagLength=128,this._tag=null,a.decrypt&&(this._tag=d.util.createBuffer(a.tag).getBytes(),this._tag.length!==this._tagLength/8))throw Error("Authentication tag does not match tag length.");this._hashBlock=Array(this._ints),this.tag=null,this._hashSubkey=Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var e=c.length();if(12===e)this._j0=[c.getInt32(),c.getInt32(),c.getInt32(),1];else{for(this._j0=[0,0,0,0];c.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[c.getInt32(),c.getInt32(),c.getInt32(),c.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(h(8*e)))}this._inBlock=this._j0.slice(0),g(this._inBlock),this._partialBytes=0,b=d.util.createBuffer(b),this._aDataLength=h(8*b.length());var f=b.length()%this.blockSize;for(f&&b.fillWithByte(0,this.blockSize-f),this._s=[0,0,0,0];b.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[b.getInt32(),b.getInt32(),b.getInt32(),b.getInt32()])},e.gcm.prototype.encrypt=function(a,b,c){var d=a.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize){for(var e=0;e<this._ints;++e)b.putInt32(this._outBlock[e]^=a.getInt32());this._cipherLength+=this.blockSize}else{var f=(this.blockSize-d)%this.blockSize;f>0&&(f=this.blockSize-f),this._partialOutput.clear();for(var e=0;e<this._ints;++e)this._partialOutput.putInt32(a.getInt32()^this._outBlock[e]);if(f<=0||c){if(c){var h=d%this.blockSize;this._cipherLength+=h,this._partialOutput.truncate(this.blockSize-h)}else this._cipherLength+=this.blockSize;for(var e=0;e<this._ints;++e)this._outBlock[e]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),f>0&&!c)return a.read-=this.blockSize,b.putBytes(this._partialOutput.getBytes(f-this._partialBytes)),this._partialBytes=f,!0;b.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),g(this._inBlock)},e.gcm.prototype.decrypt=function(a,b,c){var d=a.length();if(d<this.blockSize&&!(c&&d>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),g(this._inBlock),this._hashBlock[0]=a.getInt32(),this._hashBlock[1]=a.getInt32(),this._hashBlock[2]=a.getInt32(),this._hashBlock[3]=a.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var e=0;e<this._ints;++e)b.putInt32(this._outBlock[e]^this._hashBlock[e]);d<this.blockSize?this._cipherLength+=d%this.blockSize:this._cipherLength+=this.blockSize},e.gcm.prototype.afterFinish=function(a,b){var c=!0;b.decrypt&&b.overflow&&a.truncate(this.blockSize-b.overflow),this.tag=d.util.createBuffer();var e=this._aDataLength.concat(h(8*this._cipherLength));this._s=this.ghash(this._hashSubkey,this._s,e);var f=[];this.cipher.encrypt(this._j0,f);for(var g=0;g<this._ints;++g)this.tag.putInt32(this._s[g]^f[g]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),b.decrypt&&this.tag.bytes()!==this._tag&&(c=!1),c},e.gcm.prototype.multiply=function(a,b){for(var c=[0,0,0,0],d=b.slice(0),e=0;e<128;++e)a[e/32|0]&1<<31-e%32&&(c[0]^=d[0],c[1]^=d[1],c[2]^=d[2],c[3]^=d[3]),this.pow(d,d);return c},e.gcm.prototype.pow=function(a,b){for(var c=1&a[3],d=3;d>0;--d)b[d]=a[d]>>>1|(1&a[d-1])<<31;b[0]=a[0]>>>1,c&&(b[0]^=this._R)},e.gcm.prototype.tableMultiply=function(a){for(var b=[0,0,0,0],c=0;c<32;++c){var d=a[c/8|0]>>>(7-c%8)*4&15,e=this._m[c][d];b[0]^=e[0],b[1]^=e[1],b[2]^=e[2],b[3]^=e[3]}return b},e.gcm.prototype.ghash=function(a,b,c){return b[0]^=c[0],b[1]^=c[1],b[2]^=c[2],b[3]^=c[3],this.tableMultiply(b)},e.gcm.prototype.generateHashTable=function(a,b){for(var c=8/b,d=4*c,e=16*c,f=Array(e),g=0;g<e;++g){var h=[0,0,0,0],i=g/d|0,j=(d-1-g%d)*b;h[i]=1<<b-1<<j,f[g]=this.generateSubHashTable(this.multiply(h,a),b)}return f},e.gcm.prototype.generateSubHashTable=function(a,b){var c=1<<b,d=c>>>1,e=Array(c);e[d]=a.slice(0);for(var f=d>>>1;f>0;)this.pow(e[2*f],e[f]=[]),f>>=1;for(f=2;f<d;){for(var g=1;g<f;++g){var h=e[f],i=e[g];e[f+g]=[h[0]^i[0],h[1]^i[1],h[2]^i[2],h[3]^i[3]]}f*=2}for(e[0]=[0,0,0,0],f=d+1;f<c;++f){var j=e[f^d];e[f]=[a[0]^j[0],a[1]^j[1],a[2]^j[2],a[3]^j[3]]}return e}},19431:(a,b,c)=>{"use strict";let d=c(34589),{Readable:e}=c(57075),f=c(84285),g=c(89409),h=c(38650),i=c(56698),{assertCacheStore:j,assertCacheMethods:k,getInterceptorOrigin:l,makeCacheKey:m,normalizeHeaders:n,parseCacheControlHeader:o,isInvalidOrWildcardVaryHeader:p,parseVaryHeader:q}=c(79468),{AbortError:r}=c(61448),{parseHttpDate:s}=c(24214),t=()=>{};function u(a,b){for(let c=0;c<a.length;c++)if(a[c]===b)return!0;return!1}function v(a,b){return a.cacheControlDirectives?.["must-revalidate"]===!0||"shared"===b&&(a.cacheControlDirectives?.["proxy-revalidate"]===!0||a.cacheControlDirectives?.["s-maxage"]!==void 0)}function w(a,b){try{a.delete(b)?.catch?.(t)}catch{}}function x(a,b){let c={...a.headers,"if-modified-since":function(a){let b=a?.["last-modified"];if("string"==typeof b&&s(b))return b}(b.headers)??new Date(b.cachedAt).toUTCString()};if(b.etag&&(c["if-none-match"]=b.etag),b.vary)for(let a in b.vary)null!=b.vary[a]&&(c[a]=b.vary[a]);return c}function y(a,b,c,d,e,f){if(f?.["only-if-cached"]){let a=!1,b={paused:!1,rawHeaders:[],rawTrailers:[],pause(){this.paused=!0},resume(){this.paused=!1},abort:c=>{a=!0,d.onResponseError?.(b,c??new r)}};try{if(d.onRequestStart?.(b,null),a||(d.onResponseStart?.(b,504,{},"Gateway Timeout"),a))return;d.onResponseEnd?.(b,{})}catch(a){"function"==typeof d.onResponseError&&d.onResponseError(b,a)}return!0}return a(e,new g(b,c,d))}function z(a,b,c,g,h,i){let j=f.isStream(c.body)?c.body:e.from(c.body??[]);d(!j.destroyed,"stream should not be destroyed"),d(!j.readableDidRead,"stream should not be readableDidRead");let k=!1,l={rawHeaders:[],rawTrailers:[],resume(){j.resume()},pause(){j.pause()},get paused(){return j.isPaused()},get aborted(){return k},get reason(){return j.errored},abort(a){k=!0,j.destroy(a??new r)}};if(j.on("error",function(b){if(!this.readableEnded)if("function"==typeof a.onResponseError)a.onResponseError(l,b);else throw b}).on("close",function(){this.errored||a.onResponseEnd?.(l,{})}),a.onRequestStart?.(l,h),j.destroyed)return;let m={...c.headers,age:String(g)};i&&(m.warning='110 - "response is stale"'),l.rawHeaders=f.toRawHeaders(m),a.onResponseStart?.(l,c.statusCode,m,c.statusMessage),"HEAD"===b.method?j.destroy():j.on("data",function(b){a.onResponseData?.(l,b)})}function A(a,b,c,d,e,h,j){var k,l,m,n,r;let s;if(!j)return y(a,b,c,d,e,h);if("shared"===b.type&&Object.hasOwn(j.headers,"set-cookie"))return f.isStream(j.body)&&j.body.on("error",t).destroy(),w(b.store,c),y(a,b,c,d,e,h);let u=Date.now();if(u>j.deleteAt)return a(e,new g(b,c,d));let A=Math.round((u-j.cachedAt)/1e3),B=h?.["max-age"]!==void 0&&A>=h["max-age"],C=B||(k=j,l=h,m=b.type,(s=Date.now())>k.staleAt?!(!v(k,m)&&l?.["max-stale"])||s>k.staleAt+1e3*l["max-stale"]:!!l?.["min-fresh"]&&k.staleAt-s<=1e3*l["min-fresh"]),D=B||function(a,b,{headers:c={}}){return!!(b?.["no-cache"]||a.cacheControlDirectives?.["no-cache"]&&!Array.isArray(a.cacheControlDirectives["no-cache"]))||!!c["if-modified-since"]||!!c["if-none-match"]}(j,h,e);if(C||D){let k;if(f.isStream(e.body)&&0!==f.bodyLength(e.body))return a(e,new g(b,c,d));if(!D&&(n=j,r=b.type,!(!(k=n.cacheControlDirectives?.["stale-while-revalidate"])||v(n,r))&&Date.now()<=n.staleAt+1e3*k))return z(d,e,j,A,null,!0),queueMicrotask(()=>{let d=x(e,j);a({...e,headers:d},new g(b,c,{onRequestStart(){},onRequestUpgrade(){},onResponseStart(){},onResponseData(){},onResponseEnd(){},onResponseError(){}}))}),!0;let l=!1;if(!v(j,b.type)){let a=j.cacheControlDirectives["stale-if-error"]??h?.["stale-if-error"];a&&(l=u<j.staleAt+1e3*a)}let m=x(e,j);return a({...e,headers:m},new i((h,i,k,l)=>{if(h){if(304===k){if(function(a,b){if(b.vary&&p(b.vary)||"shared"===a&&Object.hasOwn(b,"set-cookie"))return!0;let c=b["cache-control"];if(!c)return!1;let d=o(c);return!0===d["no-store"]||"shared"===a&&!0===d.private}(b.type,l))return f.isStream(j.body)&&j.body.on("error",t).destroy(),w(b.store,c),a(e,new g(b,c,d));if(void 0!==l["cache-control"])w(b.store,c);else if(function(a,b){if(!b)return!1;for(let c in b)if(null==a.vary||!Object.hasOwn(a.vary,c))return!0;return!1}(j,l.vary?q(l.vary,e.headers):void 0))return f.isStream(j.body)&&j.body.on("error",t).destroy(),w(b.store,c),a(e,new g(b,c,d))}z(d,e,j,A,i,C)}else f.isStream(j.body)&&j.body.on("error",t).destroy()},new g(b,c,d),l))}f.isStream(e.body)&&e.body.on("error",t).destroy(),z(d,e,j,A,null,!1)}a.exports=(a={})=>{let{store:b=new h,methods:c=["GET"],cacheByDefault:d,type:e="shared",origins:i}=a;if("object"!=typeof a||null===a)throw TypeError(`expected type of opts to be an Object, got ${null===a?"null":typeof a}`);j(b,"opts.store"),k(c,"opts.methods");var p="opts.origins";if(void 0!==i){if(!Array.isArray(i))throw TypeError(`expected ${p} to be an array or undefined, got ${typeof i}`);for(let a=0;a<i.length;a++){let b=i[a];if("string"!=typeof b&&!(b instanceof RegExp))throw TypeError(`expected ${p}[${a}] to be a string or RegExp, got ${typeof b}`)}}if(void 0!==d&&"number"!=typeof d)throw TypeError(`expected opts.cacheByDefault to be number or undefined, got ${typeof d}`);if(void 0!==e&&"shared"!==e&&"private"!==e)throw TypeError(`expected opts.type to be shared, private, or undefined, got ${typeof e}`);let q={store:b,methods:c,cacheByDefault:d,type:e},r=[];for(let a=0;a<f.safeHTTPMethods.length;a++){let b=f.safeHTTPMethods[a];u(c,b)||r.push(b)}return(a,c)=>(d,e)=>{let h=l(d,c);if(!h||u(r,d.method))return a(d,e);if(void 0!==i){let b=h.toString().toLowerCase(),c=!1;for(let a=0;a<i.length;a++){let d=i[a];if("string"==typeof d){if(d.toLowerCase()===b){c=!0;break}}else if(d.test(b)){c=!0;break}}if(!c)return a(d,e)}d={...d,headers:n(d)};let j=d.headers?.["cache-control"]?o(d.headers["cache-control"]):!function(a){let b=a?.pragma;if(!b)return!1;let c=Array.isArray(b)?b:[b];for(let a=0;a<c.length;a++){let b=c[a];if("string"!=typeof b)continue;let d=b.split(",");for(let a=0;a<d.length;a++)if("no-cache"===d[a].replace(/^[\t ]+|[\t ]+$/g,"").toLowerCase())return!0}return!1}(d.headers)?void 0:{"no-cache":!0};if(j?.["no-store"])return a(d,e);let k=m(d,h);if(!u(f.safeHTTPMethods,d.method))return a(d,new g(q,k,e));let p=b.get(k);return p&&"function"==typeof p.then?p.then(b=>A(a,q,k,e,d,j,b)):A(a,q,k,e,d,j,p)}}},19608:a=>{"use strict";let b=["GET","HEAD","POST"],c=new Set(b),d=[301,302,303,307,308],e=new Set(d),f=["1","7","9","11","13","15","17","19","20","21","22","23","25","37","42","43","53","69","77","79","87","95","101","102","103","104","109","110","111","113","115","117","119","123","135","137","139","143","161","179","389","427","465","512","513","514","515","526","530","531","532","540","548","554","556","563","587","601","636","989","990","993","995","1719","1720","1723","2049","3659","4045","4190","5060","5061","6000","6566","6665","6666","6667","6668","6669","6679","6697","10080"],g=new Set(f),h=["no-referrer","no-referrer-when-downgrade","same-origin","origin","strict-origin","origin-when-cross-origin","strict-origin-when-cross-origin","unsafe-url"],i=["",...h],j=new Set(h),k=["GET","HEAD","OPTIONS","TRACE","QUERY"],l=new Set(k),m=["CONNECT","TRACE","TRACK"],n=new Set(m),o=["audio","audioworklet","font","image","manifest","paintworklet","script","style","track","video","xslt",""],p=new Set(o);a.exports={subresource:o,forbiddenMethods:m,requestBodyHeader:["content-encoding","content-language","content-location","content-type","content-length"],referrerPolicy:i,requestRedirect:["follow","manual","error"],requestMode:["navigate","same-origin","no-cors","cors"],requestCredentials:["omit","same-origin","include"],requestCache:["default","no-store","reload","no-cache","force-cache","only-if-cached"],redirectStatus:d,corsSafeListedMethods:b,nullBodyStatus:[101,204,205,304],safeMethods:k,badPorts:f,requestDuplex:["half"],subresourceSet:p,badPortsSet:g,redirectStatusSet:e,corsSafeListedMethodsSet:c,safeMethodsSet:l,forbiddenMethodsSet:n,referrerPolicyTokens:j}},19659:(a,b,c)=>{"use strict";a.exports=c.p+"static/media/catalog.fb7b1b70.json"},20012:(a,b,c)=>{"use strict";c.d(b,{Tl:()=>l});var d=c(63971),e=c(50969),f=c(38528);let g={usageUrl:(0,f.U)("codex").url,resetCreditsUrl:(0,f.U)("codex").resetCreditsUrl,resetCreditsConsumeUrl:(0,f.U)("codex").resetCreditsConsumeUrl};function h(a){return a?.workspaceId||a?.accountId||a?.chatgptAccountId||null}function i(a){return!a||"object"!=typeof a||Array.isArray(a)?null:a.rate_limit&&"object"==typeof a.rate_limit?a.rate_limit:a}function j(a){let b=(0,d.Gv)(a?.used_percent??a?.percent_used),c=null!==b&&b>=0?b:null,e=(0,d.Gv)(a?.limit_window_seconds);return{used:c,total:100,remaining:null===c?null:Math.max(0,100-c),...e>0?{windowSeconds:e,displayName:18e3===e?"Session (5h)":604800===e?"Weekly (7d)":`Window (${e/3600}h)`}:{},resetAt:(0,f.eZ)(a?.reset_at??a?.resets_at??a?.resetAt??null)||((0,d.Gv)(a?.reset_after_seconds)>0?new Date(Date.now()+1e3*(0,d.Gv)(a.reset_after_seconds)).toISOString():null),unlimited:!1}}function k(a,b,c){let d=i(c);if(!d)return!1;let e=d.primary_window||d.primary||c.primary_window||c.primary,f=d.secondary_window||d.secondary||c.secondary_window||c.secondary,g=!1;return e&&(a[b?`${b}_session`:"session"]=j(e),!0===d.limit_reached&&(a[b?`${b}_session`:"session"].blocked=!0),g=!0),f&&(a[b?`${b}_weekly`:"weekly"]=j(f),!0===d.limit_reached&&(a[b?`${b}_weekly`:"weekly"].blocked=!0),g=!0),g}async function l(a,b=null,c=null){try{let d=await (0,e.Fm)(g.usageUrl,{method:"GET",headers:{Authorization:`Bearer ${a}`,Accept:"application/json",...h(c)?{"ChatGPT-Account-ID":h(c)}:{}},identity:"codex-cli",provider:"codex",format:"codex"},b);if(!d.ok)return{message:`Codex connected. Usage API temporarily unavailable (${d.status}).`};let j=await d.json(),l=j.rate_limit||j.rate_limits||j.rate_limits_by_limit_id?.codex||{},m=function(a){if(a.code_review_rate_limit||a.review_rate_limit)return a.code_review_rate_limit||a.review_rate_limit;let b=a.rate_limits_by_limit_id;return b&&"object"==typeof b&&!Array.isArray(b)?b.code_review||b.codex_review||b.review||null:(Array.isArray(a.additional_rate_limits)?a.additional_rate_limits:[]).find(a=>{let b=String(a?.limit_name||a?.metered_feature||a?.id||"").toLowerCase();return"code_review"===b||"codex_review"===b||"review"===b||b.includes("review")})||null}(j),n=Math.max(0,(0,f.IQ)(j.rate_limit_reset_credits?.available_count,0)),o={};for(let a of(k(o,"",l),k(o,"review",m),Array.isArray(j.additional_rate_limits)?j.additional_rate_limits:[])){if(a===m)continue;let b=a.limit_name||a.metered_feature||a.id;"string"==typeof b&&b&&k(o,b,a)}for(let[a,b]of Object.entries(j.rate_limits_by_limit_id||{}))"codex"!==a&&b!==m&&k(o,a,b);for(let[a,b]of Object.entries(o))b.displayName&&"session"!==a&&"weekly"!==a&&(b.displayName=`${a.replace(/_(session|weekly)$/,"")} \xb7 ${b.displayName}`);return{plan:j.plan_type||j.summary?.plan||"unknown",limitReached:i(l)?.limit_reached||!1,reviewLimitReached:i(m)?.limit_reached||!1,resetCredits:{availableCount:n},quotas:o}}catch(a){throw Error(`Failed to fetch Codex usage: ${a.message}`)}}},20096:a=>{var b={};a.exports=b;var c={};b.encode=function(a,b,c){if("string"!=typeof b)throw TypeError('"alphabet" must be a string.');if(void 0!==c&&"number"!=typeof c)throw TypeError('"maxline" must be a number.');var d="";if(a instanceof Uint8Array){var e=0,f=b.length,g=b.charAt(0),h=[0];for(e=0;e<a.length;++e){for(var i=0,j=a[e];i<h.length;++i)j+=h[i]<<8,h[i]=j%f,j=j/f|0;for(;j>0;)h.push(j%f),j=j/f|0}for(e=0;0===a[e]&&e<a.length-1;++e)d+=g;for(e=h.length-1;e>=0;--e)d+=b[h[e]]}else d=function(a,b){var c=0,d=b.length,e=b.charAt(0),f=[0];for(c=0;c<a.length();++c){for(var g=0,h=a.at(c);g<f.length;++g)h+=f[g]<<8,f[g]=h%d,h=h/d|0;for(;h>0;)f.push(h%d),h=h/d|0}var i="";for(c=0;0===a.at(c)&&c<a.length()-1;++c)i+=e;for(c=f.length-1;c>=0;--c)i+=b[f[c]];return i}(a,b);if(c){var k=RegExp(".{1,"+c+"}","g");d=d.match(k).join("\r\n")}return d},b.decode=function(a,b){if("string"!=typeof a)throw TypeError('"input" must be a string.');if("string"!=typeof b)throw TypeError('"alphabet" must be a string.');var d=c[b];if(!d){d=c[b]=[];for(var e=0;e<b.length;++e)d[b.charCodeAt(e)]=e}a=a.replace(/\s/g,"");for(var f=b.length,g=b.charAt(0),h=[0],e=0;e<a.length;e++){var i=d[a.charCodeAt(e)];if(void 0===i)return;for(var j=0,k=i;j<h.length;++j)k+=h[j]*f,h[j]=255&k,k>>=8;for(;k>0;)h.push(255&k),k>>=8}for(var l=0;a[l]===g&&l<a.length-1;++l)h.push(0);return"u">typeof Buffer?Buffer.from(h.reverse()):new Uint8Array(h.reverse())}},20308:(a,b,c)=>{var d=c(45654);if(c(45518),c(63070),c(88819),c(1277),c(36105),c(70710),c(49345),c(29984),c(67382),c(10401),c(33889),void 0===e)var e=d.jsbn.BigInteger;var f=d.asn1,g=d.pki=d.pki||{};a.exports=g.pbe=d.pbe=d.pbe||{};var h=g.oids,i={name:"EncryptedPrivateKeyInfo",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:f.Class.UNIVERSAL,type:f.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:f.Class.UNIVERSAL,type:f.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},j={name:"PBES2Algorithms",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:f.Class.UNIVERSAL,type:f.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:f.Class.UNIVERSAL,type:f.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:f.Class.UNIVERSAL,type:f.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:f.Class.UNIVERSAL,type:f.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:f.Class.UNIVERSAL,type:f.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:f.Class.UNIVERSAL,type:f.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:f.Class.UNIVERSAL,type:f.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},k={name:"pkcs-12PbeParams",tagClass:f.Class.UNIVERSAL,type:f.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:f.Class.UNIVERSAL,type:f.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:f.Class.UNIVERSAL,type:f.Type.INTEGER,constructed:!1,capture:"iterations"}]};function l(a,b){return a.start().update(b).digest().getBytes()}function m(a){var b;if(a){if(!(b=g.oids[f.derToOid(a)])){var c=Error("Unsupported PRF OID.");throw c.oid=a,c.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],c}}else b="hmacWithSHA1";return n(b)}function n(a){var b=d.md;switch(a){case"hmacWithSHA224":b=d.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":a=a.substr(8).toLowerCase();break;default:var c=Error("Unsupported PRF algorithm.");throw c.algorithm=a,c.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],c}if(!b||!(a in b))throw Error("Unknown hash algorithm: "+a);return b[a].create()}g.encryptPrivateKeyInfo=function(a,b,c){(c=c||{}).saltSize=c.saltSize||8,c.count=c.count||2048,c.algorithm=c.algorithm||"aes128",c.prfAlgorithm=c.prfAlgorithm||"sha1";var e=d.random.getBytesSync(c.saltSize),i=c.count,j=f.integerToDer(i);if(0===c.algorithm.indexOf("aes")||"des"===c.algorithm){switch(c.algorithm){case"aes128":q=16,t=16,u=h["aes128-CBC"],v=d.aes.createEncryptionCipher;break;case"aes192":q=24,t=16,u=h["aes192-CBC"],v=d.aes.createEncryptionCipher;break;case"aes256":q=32,t=16,u=h["aes256-CBC"],v=d.aes.createEncryptionCipher;break;case"des":q=8,t=8,u=h.desCBC,v=d.des.createEncryptionCipher;break;default:var k,l,m,o,p,q,r,s,t,u,v,w=Error("Cannot encrypt private key. Unknown encryption algorithm.");throw w.algorithm=c.algorithm,w}var x="hmacWith"+c.prfAlgorithm.toUpperCase(),y=n(x),z=d.pkcs5.pbkdf2(b,e,i,q,y),A=d.random.getBytesSync(t),B=v(z);B.start(A),B.update(f.toDer(a)),B.finish(),s=B.output.getBytes();var C=(k=e,l=j,m=q,o=x,p=f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.OCTETSTRING,!1,k),f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,l.getBytes())]),"hmacWithSHA1"!==o&&p.value.push(f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,d.util.hexToBytes(m.toString(16))),f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.OID,!1,f.oidToDer(g.oids[o]).getBytes()),f.create(f.Class.UNIVERSAL,f.Type.NULL,!1,"")])),p);r=f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.OID,!1,f.oidToDer(h.pkcs5PBES2).getBytes()),f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.OID,!1,f.oidToDer(h.pkcs5PBKDF2).getBytes()),C]),f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.OID,!1,f.oidToDer(u).getBytes()),f.create(f.Class.UNIVERSAL,f.Type.OCTETSTRING,!1,A)])])])}else if("3des"===c.algorithm){q=24;var D=new d.util.ByteBuffer(e),z=g.pbe.generatePkcs12Key(b,D,1,i,q),A=g.pbe.generatePkcs12Key(b,D,2,i,q),B=d.des.createEncryptionCipher(z);B.start(A),B.update(f.toDer(a)),B.finish(),s=B.output.getBytes(),r=f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.OID,!1,f.oidToDer(h["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[f.create(f.Class.UNIVERSAL,f.Type.OCTETSTRING,!1,e),f.create(f.Class.UNIVERSAL,f.Type.INTEGER,!1,j.getBytes())])])}else{var w=Error("Cannot encrypt private key. Unknown encryption algorithm.");throw w.algorithm=c.algorithm,w}return f.create(f.Class.UNIVERSAL,f.Type.SEQUENCE,!0,[r,f.create(f.Class.UNIVERSAL,f.Type.OCTETSTRING,!1,s)])},g.decryptPrivateKeyInfo=function(a,b){var c=null,e={},h=[];if(!f.validate(a,i,e,h)){var j=Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw j.errors=h,j}var k=f.derToOid(e.encryptionOid),l=g.pbe.getCipher(k,e.encryptionParams,b),m=d.util.createBuffer(e.encryptedData);return l.update(m),l.finish()&&(c=f.fromDer(l.output)),c},g.encryptedPrivateKeyToPem=function(a,b){var c={type:"ENCRYPTED PRIVATE KEY",body:f.toDer(a).getBytes()};return d.pem.encode(c,{maxline:b})},g.encryptedPrivateKeyFromPem=function(a){var b=d.pem.decode(a)[0];if("ENCRYPTED PRIVATE KEY"!==b.type){var c=Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw c.headerType=b.type,c}if(b.procType&&"ENCRYPTED"===b.procType.type)throw Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return f.fromDer(b.body)},g.encryptRsaPrivateKey=function(a,b,c){if(!(c=c||{}).legacy){var e,h,i,j,k=g.wrapRsaPrivateKey(g.privateKeyToAsn1(a));return k=g.encryptPrivateKeyInfo(k,b,c),g.encryptedPrivateKeyToPem(k)}switch(c.algorithm){case"aes128":e="AES-128-CBC",i=16,h=d.random.getBytesSync(16),j=d.aes.createEncryptionCipher;break;case"aes192":e="AES-192-CBC",i=24,h=d.random.getBytesSync(16),j=d.aes.createEncryptionCipher;break;case"aes256":e="AES-256-CBC",i=32,h=d.random.getBytesSync(16),j=d.aes.createEncryptionCipher;break;case"3des":e="DES-EDE3-CBC",i=24,h=d.random.getBytesSync(8),j=d.des.createEncryptionCipher;break;case"des":e="DES-CBC",i=8,h=d.random.getBytesSync(8),j=d.des.createEncryptionCipher;break;default:var l=Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+c.algorithm+'".');throw l.algorithm=c.algorithm,l}var m=j(d.pbe.opensslDeriveBytes(b,h.substr(0,8),i));m.start(h),m.update(f.toDer(g.privateKeyToAsn1(a))),m.finish();var n={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:e,parameters:d.util.bytesToHex(h).toUpperCase()},body:m.output.getBytes()};return d.pem.encode(n)},g.decryptRsaPrivateKey=function(a,b){var c=null,e=d.pem.decode(a)[0];if("ENCRYPTED PRIVATE KEY"!==e.type&&"PRIVATE KEY"!==e.type&&"RSA PRIVATE KEY"!==e.type){var h=Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw h.headerType=h,h}if(e.procType&&"ENCRYPTED"===e.procType.type){switch(e.dekInfo.algorithm){case"DES-CBC":i=8,j=d.des.createDecryptionCipher;break;case"DES-EDE3-CBC":i=24,j=d.des.createDecryptionCipher;break;case"AES-128-CBC":i=16,j=d.aes.createDecryptionCipher;break;case"AES-192-CBC":i=24,j=d.aes.createDecryptionCipher;break;case"AES-256-CBC":i=32,j=d.aes.createDecryptionCipher;break;case"RC2-40-CBC":i=5,j=function(a){return d.rc2.createDecryptionCipher(a,40)};break;case"RC2-64-CBC":i=8,j=function(a){return d.rc2.createDecryptionCipher(a,64)};break;case"RC2-128-CBC":i=16,j=function(a){return d.rc2.createDecryptionCipher(a,128)};break;default:var i,j,h=Error('Could not decrypt private key; unsupported encryption algorithm "'+e.dekInfo.algorithm+'".');throw h.algorithm=e.dekInfo.algorithm,h}var k=d.util.hexToBytes(e.dekInfo.parameters),l=j(d.pbe.opensslDeriveBytes(b,k.substr(0,8),i));if(l.start(k),l.update(d.util.createBuffer(e.body)),!l.finish())return c;c=l.output.getBytes()}else c=e.body;return null!==(c="ENCRYPTED PRIVATE KEY"===e.type?g.decryptPrivateKeyInfo(f.fromDer(c),b):f.fromDer(c))&&(c=g.privateKeyFromAsn1(c)),c},g.pbe.generatePkcs12Key=function(a,b,c,e,f,g){if(null==g){if(!("sha1"in d.md))throw Error('"sha1" hash algorithm unavailable.');g=d.md.sha1.create()}var h,i,j=g.digestLength,k=g.blockLength,l=new d.util.ByteBuffer,m=new d.util.ByteBuffer;if(null!=a){for(i=0;i<a.length;i++)m.putInt16(a.charCodeAt(i));m.putInt16(0)}var n=m.length(),o=b.length(),p=new d.util.ByteBuffer;p.fillWithByte(c,k);var q=k*Math.ceil(o/k),r=new d.util.ByteBuffer;for(i=0;i<q;i++)r.putByte(b.at(i%o));var s=k*Math.ceil(n/k),t=new d.util.ByteBuffer;for(i=0;i<s;i++)t.putByte(m.at(i%n));var u=r;u.putBuffer(t);for(var v=Math.ceil(f/j),w=1;w<=v;w++){var x=new d.util.ByteBuffer;x.putBytes(p.bytes()),x.putBytes(u.bytes());for(var y=0;y<e;y++)g.start(),g.update(x.getBytes()),x=g.digest();var z=new d.util.ByteBuffer;for(i=0;i<k;i++)z.putByte(x.at(i%j));var A=Math.ceil(o/k)+Math.ceil(n/k),B=new d.util.ByteBuffer;for(h=0;h<A;h++){var C=new d.util.ByteBuffer(u.getBytes(k)),D=511;for(i=z.length()-1;i>=0;i--)D>>=8,D+=z.at(i)+C.at(i),C.setAt(i,255&D);B.putBuffer(C)}u=B,l.putBuffer(x)}return l.truncate(l.length()-f),l},g.pbe.getCipher=function(a,b,c){switch(a){case g.oids.pkcs5PBES2:return g.pbe.getCipherForPBES2(a,b,c);case g.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case g.oids["pbewithSHAAnd40BitRC2-CBC"]:return g.pbe.getCipherForPKCS12PBE(a,b,c);default:var d=Error("Cannot read encrypted PBE data block. Unsupported OID.");throw d.oid=a,d.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],d}},g.pbe.getCipherForPBES2=function(a,b,c){var e,h,i={},k=[];if(!f.validate(b,j,i,k)){var l=Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw l.errors=k,l}if((a=f.derToOid(i.kdfOid))!==g.oids.pkcs5PBKDF2){var l=Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw l.oid=a,l.supportedOids=["pkcs5PBKDF2"],l}if((a=f.derToOid(i.encOid))!==g.oids["aes128-CBC"]&&a!==g.oids["aes192-CBC"]&&a!==g.oids["aes256-CBC"]&&a!==g.oids["des-EDE3-CBC"]&&a!==g.oids.desCBC){var l=Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw l.oid=a,l.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],l}var n=i.kdfSalt,o=d.util.createBuffer(i.kdfIterationCount);switch(o=o.getInt(o.length()<<3),g.oids[a]){case"aes128-CBC":e=16,h=d.aes.createDecryptionCipher;break;case"aes192-CBC":e=24,h=d.aes.createDecryptionCipher;break;case"aes256-CBC":e=32,h=d.aes.createDecryptionCipher;break;case"des-EDE3-CBC":e=24,h=d.des.createDecryptionCipher;break;case"desCBC":e=8,h=d.des.createDecryptionCipher}var p=m(i.prfOid),q=d.pkcs5.pbkdf2(c,n,o,e,p),r=i.encIv,s=h(q);return s.start(r),s},g.pbe.getCipherForPKCS12PBE=function(a,b,c){var e,h,i,j={},l=[];if(!f.validate(b,k,j,l)){var n=Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw n.errors=l,n}var o=d.util.createBuffer(j.salt),p=d.util.createBuffer(j.iterations);switch(p=p.getInt(p.length()<<3),a){case g.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:e=24,h=8,i=d.des.startDecrypting;break;case g.oids["pbewithSHAAnd40BitRC2-CBC"]:e=5,h=8,i=function(a,b){var c=d.rc2.createDecryptionCipher(a,40);return c.start(b,null),c};break;default:var n=Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw n.oid=a,n}var q=m(j.prfOid),r=g.pbe.generatePkcs12Key(c,o,1,p,e,q);return q.start(),i(r,g.pbe.generatePkcs12Key(c,o,2,p,h,q))},g.pbe.opensslDeriveBytes=function(a,b,c,e){if(null==e){if(!("md5"in d.md))throw Error('"md5" hash algorithm unavailable.');e=d.md.md5.create()}null===b&&(b="");for(var f=[l(e,a+b)],g=16,h=1;g<c;++h,g+=16)f.push(l(e,f[h-1]+a+b));return f.join("").substr(0,c)}},20437:(a,b,c)=>{"use strict";c.d(b,{AL:()=>j,HG:()=>i,Jh:()=>m,KQ:()=>k,Or:()=>l,ok:()=>h.ok});var d=c(76760),e=c.n(d),f=c(73024),g=c.n(f),h=c(53859);let i=e().join(h.nJ,"db"),j=e().join(i,"data.sqlite"),k=e().join(i,"backups"),l={main:e().join(h.nJ,"db.json"),usage:e().join(h.nJ,"usage.json"),disabled:e().join(h.nJ,"disabledModels.json"),details:e().join(h.nJ,"request-details.json")};function m(){for(let a of[h.nJ,i,k])g().existsSync(a)||g().mkdirSync(a,{recursive:!0})}},20579:(a,b,c)=>{"use strict";let d,{Writable:e}=c(57075),{assertCacheKey:f,assertCacheValue:g}=c(79468);a.exports=class{#g=2e9;#h=1/0;#i;#j;#k;#l;#m;#n;#o;#p;constructor(a){if(a){if("object"!=typeof a)throw TypeError("SqliteCacheStore options must be an object");if(void 0!==a.maxEntrySize){if("number"!=typeof a.maxEntrySize||!Number.isInteger(a.maxEntrySize)||a.maxEntrySize<0)throw TypeError("SqliteCacheStore options.maxEntrySize must be a non-negative integer");if(a.maxEntrySize>2e9)throw TypeError("SqliteCacheStore options.maxEntrySize must be less than 2gb");this.#g=a.maxEntrySize}if(void 0!==a.maxCount){if("number"!=typeof a.maxCount||!Number.isInteger(a.maxCount)||a.maxCount<0)throw TypeError("SqliteCacheStore options.maxCount must be a non-negative integer");this.#h=a.maxCount}}d||(d=c(79868).DatabaseSync),this.#i=new d(a?.location??":memory:"),this.#i.exec(`
|
|
38
38
|
PRAGMA journal_mode = WAL;
|
|
39
39
|
PRAGMA synchronous = NORMAL;
|
|
40
40
|
PRAGMA temp_store = memory;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
`)),a.enqueue(f.encode(`data: ${JSON.stringify(g([{index:0,delta:{},finish_reason:"stop"}]))}
|
|
6
6
|
|
|
7
|
-
`)),a.enqueue(f.encode("data: [DONE]\n\n")),a.close()}});return new Response(h,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}})}(!!c.stream,e)}(0,z.lg)(g),(0,z.LH)(g,i)}b&&(c.messages=(0,z.Jl)(c.messages))}}catch(a){A.warn?.("FEEDBACK",`capture/strip failed (ignored): ${a?.message||a}`)}let k=(0,r.t8)(c);if(n){let f=(0,l.tg)({models:n,comboName:e,settings:m,log:A});if(f.response)return f.response;n=f.models;let g=m.comboStrategies||{},h=g[e]?.fallbackStrategy||m.comboStrategy||"fallback";if("fusion"===h)return A.info("CHAT",`Combo "${e}" with ${n.length} models (strategy: fusion)`),(0,r.vt)({body:c,models:n,handleSingleModel:(c,e,f)=>{let g=!0===f?{isPanel:!0}:f||{},h=b;if(g.isPanel&&b){let{tools:a,tool_choice:c,...d}=b.body||{};h={...b,body:d}}return R(c,e,h,a,d,{...g,signal:g.signal||null})},log:A,comboName:e,judgeModel:g[e]?.judgeModel,tuning:g[e]?.fusionTuning,abortSignal:a?.signal||null,childComboDepth:1});if("auto"===h){let h=g[e]||{},i=!0===h.feedbackAsk,k=null;if(i)try{let b=(0,x.t)(new URL(a.url).pathname,c),e=(0,z.Mc)(c.messages),f=(0,z.EN)(d||"local-no-key");k={apiKeyHash:f,conversationFp:(0,z.sO)(e.firstUserText,f),openAiWire:"openai"===b,gateOk:!(c.tools&&c.tools.length||c.functions&&c.functions.length)&&Number(e.userTurns)>=2,feedbackAsk:!0}}catch{k=null}let m=h.routerModel;if(m&&await (0,j.getComboModels)(m))return A.warn("CHAT",`Auto routerModel is a combo (${m}) — rejected`),(0,q.yj)(w.gx.BAD_REQUEST,`routerModel cannot be a combo ("${m}"). Use a single provider/model.`);let o=[];for(let a of n)a!==m&&o.push(a);if(!o.length&&f.skipped.length)return(0,l.tW)({comboName:e,skipped:f.skipped.filter(a=>a.model!==m),log:A});let p={};for(let a of o)try{p[a]=await (0,C.w)(a)}catch{p[a]={}}return A.info("CHAT",`Combo "${e}" with ${o.length} workers (strategy: auto)`),(0,t.EA)({body:c,models:[...o,...n.includes(m)?[m]:[]],handleSingleModel:(c,e,f)=>R(c,e,b,a,d,{...f||{},comboDepth:0}),log:A,comboName:e,strategy:h,loadLearning:K,loadStats:L,loadGlobalStats:a=>(0,I.PO)(`gstats:${a}`,()=>(0,H.cX)(a),15e3),loadClusterP50:(a,b,c)=>(0,I.PO)(`p50:${a}:${b}:${c}`,()=>(0,H._6)(a,b,c)),loadProviderLatency:M,loadProviderUsage:N,loadProviderQuota:O,recordEvent:(0,l.zw)(a=>(0,H.ex)(a),f.skipped),applyJudgeScore:(a,b)=>(0,H.Vp)(a,b),autoDepth:0,clientAbortSignal:a?.signal||null,feedbackCtx:k,workerCaps:p})}let i=(0,s.R8)(n,k,m),o=i.filter(a=>!n.includes(a)),p=m.comboStickyRoundRobinLimit,u=g[e]||{},v=!1!==u.capacityAutoSwitch,y=u.providerStrategy&&"off"!==u.providerStrategy?await P(u):null;return A.info("CHAT",`Combo "${e}" with ${i.length} models (strategy: ${h}, sticky: ${p}, capacitySwitch: ${v})`),(0,r.Pr)({body:c,models:i,handleSingleModel:(0,s.ar)((c,e,f)=>R(c,e,b,a,d,f),o),log:A,comboName:e,comboStrategy:h,comboStickyLimit:p,autoSwitch:v,...y||{},abortSignal:a?.signal||null,childComboDepth:1})}let p=(0,s.R8)([e],k,m);if(p.length>1){let f=p.filter(a=>a!==e);return A.info("CHAT",`Capacity adapter for [${[...k].join(",")}] on "${e}" → trying ${p.join(", ")}`),(0,r.Pr)({body:c,models:p,handleSingleModel:(0,s.ar)((c,e,f)=>R(c,e,b,a,d,{...f||{},signal:f?.signal||a?.signal||null,preferredConnectionId:g,strictPreferredConnection:h,allowNativeClaudeOAuth:!0}),f),log:A,comboName:e,comboStrategy:(0,s.vB)(k,m),abortSignal:a?.signal||null,childComboDepth:1})}let u=null;try{u=(0,x.t)(new URL(a.url).pathname,c)}catch{}if(!(m.tokenSaver?.vault&&Array.isArray(c.tools)&&c.tools.length>0&&("openai"===u||"claude"===u)))return R(c,e,b,a,d,{signal:a?.signal||null,preferredConnectionId:g,strictPreferredConnection:h,allowNativeClaudeOAuth:!0});try{let f=(0,z.Bk)(c.messages,(0,z.EN)(d||"local-no-key"));if(!f)return R(c,e,b,a,d,{signal:a?.signal||null,preferredConnectionId:g,strictPreferredConnection:h,allowNativeClaudeOAuth:!0});await (0,y.Xy)(c,{conversationId:f}),(0,y.Ag)(c,u);let i=Number(m.tokenSaver?.vaultSearchLimit??5);return await (0,y.SS)({dispatch:(c,i)=>R(c,e,b,a,d,{signal:a?.signal||null,preferredConnectionId:g,strictPreferredConnection:h,allowNativeClaudeOAuth:!0,vaultInternal:!!i?.vaultInternal,vaultStore:!0,vaultConversationId:f}),body:c,wire:u,conversationId:f,searchLimit:i,log:A})}catch{return R(c,e,b,a,d,{signal:a?.signal||null,preferredConnectionId:g,strictPreferredConnection:h,allowNativeClaudeOAuth:!0})}})}async function R(a,b,c=null,d=null,e=null,i=null){let u=[d?.signal,i?.signal].filter(Boolean),v=u.length>1?AbortSignal.any(u):u[0],y=()=>(0,q.yj)(499,"Request aborted");if(v?.aborted)return y();await (0,k.vA)();let B=await (0,j.getModelInfo)(b),F=i?.autoDepth||0,J=i?.comboDepth||0;if(!B.provider){let f=await (0,j.getComboModels)(b);if(f){let g=await (0,h.mt)(),k=(0,l.tg)({models:f,comboName:b,settings:g,log:A});if(k.response)return k.response;f=k.models;let m=(0,r.t8)(a),n=(0,s.R8)(f,m,g),o=n.filter(a=>!f.includes(a)),p=g.comboStrategies||{},u=p[b]?.fallbackStrategy||g.comboStrategy||"fallback";if("auto"!==u&&J>=w.wg)return A.warn("CHAT",`Combo nesting limit at "${b}" (depth ${J})`),(0,q.yj)(w.gx.BAD_REQUEST,`Combo nesting too deep (>${w.wg}) at "${b}"`);if("fusion"===u)return A.info("CHAT",`Combo "${b}" with ${f.length} models (strategy: fusion)`),(0,r.vt)({body:a,models:f,handleSingleModel:(a,b,f)=>{let g=!0===f?{isPanel:!0}:f||{},h=c;if(g.isPanel&&c){let{tools:a,tool_choice:b,...d}=c.body||{};h={...c,body:d}}return R(a,b,h,d,e,{...i||{},...g,signal:g.signal||i?.signal||null})},log:A,comboName:b,judgeModel:p[b]?.judgeModel,tuning:p[b]?.fusionTuning,abortSignal:v||null,childComboDepth:J+1,autoDepth:F});if("auto"===u){if(F>=2)return A.warn("CHAT",`Auto combo recursion limit at "${b}" (depth ${F})`),(0,q.yj)(w.gx.BAD_REQUEST,`Auto combo recursion limit — "${b}" cannot nest further`);let g=p[b]||{},h=!0===g.feedbackAsk,i=null;if(h)try{let b=(0,x.t)(new URL(d.url).pathname,a),c=(0,z.Mc)(a.messages),f=(0,z.EN)(e||"local-no-key");i={apiKeyHash:f,conversationFp:(0,z.sO)(c.firstUserText,f),openAiWire:"openai"===b,gateOk:!(a.tools&&a.tools.length||a.functions&&a.functions.length)&&Number(c.userTurns)>=2,feedbackAsk:!0}}catch{i=null}let m=g.routerModel;if(m&&await (0,j.getComboModels)(m))return(0,q.yj)(w.gx.BAD_REQUEST,`routerModel cannot be a combo ("${m}")`);let n=[];for(let a of f)a!==m&&n.push(a);if(!n.length&&k.skipped.length)return(0,l.tW)({comboName:b,skipped:k.skipped.filter(a=>a.model!==m),log:A});let o={};for(let a of n)try{o[a]=await (0,C.w)(a)}catch{o[a]={}}return A.info("CHAT",`Combo "${b}" with ${n.length} workers (strategy: auto, depth=${F})`),(0,t.EA)({body:a,models:[...n,...f.includes(m)?[m]:[]],handleSingleModel:(a,b,f)=>R(a,b,c,d,e,{...f||{},comboDepth:J}),log:A,comboName:b,strategy:g,loadLearning:K,loadStats:L,loadGlobalStats:a=>(0,I.PO)(`gstats:${a}`,()=>(0,H.cX)(a),15e3),loadClusterP50:(a,b,c)=>(0,I.PO)(`p50:${a}:${b}:${c}`,()=>(0,H._6)(a,b,c)),loadProviderLatency:M,loadProviderUsage:N,loadProviderQuota:O,recordEvent:(0,l.zw)(a=>(0,H.ex)(a),k.skipped),applyJudgeScore:(a,b)=>(0,H.Vp)(a,b),autoDepth:F,comboDepth:J,clientAbortSignal:d?.signal||null,feedbackCtx:i,workerCaps:o})}let y=g.comboStickyRoundRobinLimit,B=p[b]||{},D=!1!==B.capacityAutoSwitch,E=B.providerStrategy&&"off"!==B.providerStrategy?await P(B):null;return A.info("CHAT",`Combo "${b}" with ${n.length} models (strategy: ${u}, sticky: ${y}, capacitySwitch: ${D})`),(0,r.Pr)({body:a,models:n,handleSingleModel:(0,s.ar)((a,b,f)=>R(a,b,c,d,e,f),o),log:A,comboName:b,comboStrategy:u,comboStickyLimit:y,autoSwitch:D,...E||{},abortSignal:v||null,childComboDepth:J+1,autoDepth:F})}return A.warn("CHAT","Invalid model format",{model:b}),(0,q.yj)(w.gx.BAD_REQUEST,"Invalid model format")}let{provider:Q,model:S}=B;b!==`${Q}/${S}`?A.info("ROUTING",`${b} → ${Q}/${S}`):A.info("ROUTING",`Provider: ${Q}, Model: ${S}`);let T=d?.headers?.get("user-agent")||"",U=new Set,V=null,W=null,X=(0,G.M)({request:d,provider:Q,allowNativeOAuth:i?.allowNativeClaudeOAuth===!0}),Y=(0,g.mA)({headers:d?.headers,body:a,scope:Q,clientKeyId:e});for(;;){if(v?.aborted)return y();let b=X||await (0,f.getProviderCredentials)(Q,U,S,{preferredConnectionId:i?.preferredConnectionId||null,strictPreferredConnection:i?.strictPreferredConnection===!0,sessionKey:Y,clientKeyId:e});if(v?.aborted)return y();if(!b||b.allRateLimited){if(b?.allRateLimited){let a=V||b.lastError||"Unavailable",c=W||Number(b.lastErrorCode)||w.gx.SERVICE_UNAVAILABLE;return A.warn("CHAT",`[${Q}/${S}] ${a} (${b.retryAfterHuman})`),(0,q.wO)(c,`[${Q}/${S}] ${a}`,b.retryAfter,b.retryAfterHuman)}if(0===U.size)return A.warn("AUTH",`No active credentials for provider: ${Q}`),(0,q.yj)(w.gx.NOT_FOUND,`No active credentials for provider: ${Q}`);return A.warn("CHAT","No more accounts available",{provider:Q}),(0,q.yj)(W||w.gx.SERVICE_UNAVAILABLE,V||"All accounts unavailable")}A.info("AUTH",`\x1b[32mUsing ${Q} account: ${b.connectionName}\x1b[0m`);let g=b.ephemeral?b:await (0,D.eU)(Q,b);if(v?.aborted)return y();if(("antigravity"===Q||"gemini-cli"===Q)&&!g.projectId){let a=await (0,E.eG)(b.connectionId,g.accessToken,Q);a&&(g.projectId=a,(0,D.vN)(b.connectionId,{projectId:a}).catch(()=>{}))}let j=await (0,h.mt)();if(v?.aborted)return y();let k=(j.providerThinking||{})[Q]||null,l="function"==typeof structuredClone?structuredClone(a):JSON.parse(JSON.stringify(a)),r=i?.sourceFormatOverride||(d?.url?(0,x.t)(new URL(d.url).pathname,a):null),s=!!i?.bypassPromptFilters,t=await (0,m.w)({body:{...l,model:`${Q}/${S}`},modelInfo:{provider:Q,model:S},credentials:g,log:A,clientRawRequest:c,connectionId:b.connectionId,userAgent:T,clientKeyId:e,ccFilterNaming:!!j.ccFilterNaming,rtkEnabled:!s&&!!j.rtkEnabled,vaultEnabled:!s&&!!i?.vaultStore&&!!j.tokenSaver?.vault,vaultThresholdKB:j.tokenSaver?.vaultThresholdKB??8,vaultTtlHours:j.tokenSaver?.vaultTtlHours??24,vaultConversationId:i?.vaultConversationId??null,headroomEnabled:!s&&!!j.headroomEnabled,headroomUrl:j.headroomUrl||n.ag,headroomCompressUserMessages:!s&&!!j.headroomCompressUserMessages,cavemanEnabled:!s&&!!j.cavemanEnabled,cavemanLevel:j.cavemanLevel||"full",ponytailEnabled:!s&&!!j.ponytailEnabled,ponytailLevel:j.ponytailLevel||"full",pxpipeEnabled:!s&&!!j.pxpipeEnabled,pxpipeMinChars:j.pxpipeMinChars,pxpipeTimeoutMs:j.pxpipeTimeoutMs,pxpipeTransform:!s&&j.pxpipeEnabled?await (0,o.RG)():null,onPxpipeEvent:p.T0,providerThinking:k,sourceFormatOverride:r,bypassNativePassthrough:!!i?.bypassNativePassthrough,vaultInternal:!!i?.vaultInternal,abortSignal:v||null,onCredentialsRefreshed:async a=>{b.ephemeral||await (0,D.vN)(b.connectionId,{...a,existingProviderSpecificData:b.providerSpecificData,testStatus:"active"})},onRequestSuccess:async()=>{b.ephemeral||await (0,f.Pt)(b.connectionId,b,S)},onUpstreamEmptyExhausted:async(a,c)=>{b.ephemeral||v?.aborted||await (0,f.vk)(b.connectionId,502,"string"==typeof a?a:a?.message||"empty stream",Q,S,c)}});if(v?.aborted||499===t.status){try{await t.response?.body?.cancel?.()}catch{}return y()}if(t.success||b.ephemeral)return t.response;let{shouldFallback:u}=await (0,f.vk)(b.connectionId,t.status,t.error,Q,S,t.resetsAtMs);if(u){A.warn("AUTH",`Account ${b.connectionName} unavailable (${t.status}), trying fallback`),U.add(b.connectionId),V=t.error,W=t.status;continue}return t.response}}[e,m]=J.then?(await J)():J,(0,H.tu)(a=>{(0,u.aW)(a),a?((0,I.Y3)(`stats:${a}:`),(0,I.Y3)(`learning:${a}`),(0,t.a8)(a)):(0,I.Y3)()}),d()}catch(a){d(a)}})},85432:(a,b,c)=>{c.d(b,{Kt:()=>m,MH:()=>l,vA:()=>k});var d=c(15717),e=c(19978),f=c(94454),g=c(29696);let h="compatible-reasoning:snapshot";async function i(){let a="function"==typeof d.Fh?(0,d.Fh)({type:"openai-compatible"}):Promise.resolve([]),b="function"==typeof d.uv?(0,d.uv)():Promise.resolve([]),[c,e]=await Promise.all([Promise.resolve(a).catch(()=>[]),Promise.resolve(b).catch(()=>[])]),f=new Map,h=new Map;for(let a of c){if(!a?.id||!a?.prefix)continue;let b={id:a.id,apiType:"responses"===a.apiType?"responses":"chat",staticFormat:(0,g.ml)(a.baseUrl)};f.set(a.id,b),h.set(a.prefix,b)}let i=new Map;for(let a of e){if(!a?.providerAlias||!a?.id||"llm"!==(a.type||"llm"))continue;let b=h.get(a.providerAlias);b&&(0,g.K5)(a.reasoning)&&i.set(`${b.id}|${a.id}`,a.reasoning)}return{nodesById:f,prefixToNode:h,byModel:i}}let j={nodesById:new Map,prefixToNode:new Map,byModel:new Map};async function k(a=15e3){try{let b=await (0,e.PO)(h,i,a);b&&(j=b)}catch{}}function l(){(0,e.Y3)(h)}function m(a,b){let c=j.prefixToNode.get(a);if(!c)return null;let d=j.byModel.get(`${c.id}|${b}`);return d||("none"===c.staticFormat?{supported:!1,effort:null}:c.staticFormat?{supported:!0,effort:"qwen"===c.staticFormat?null:c.staticFormat}:null)}(0,f.xl)(function(a,b){var c,d,e,f;if(!a||!a.startsWith("openai-compatible-"))return null;let g=j.nodesById.get(a),h=j.byModel.get(`${a}|${b}`);return h?(c=h,d=g?.apiType||"chat",c.supported?"responses"===d?"openai-responses":"nested"===c.effort?"openai-nested":"openai":"none"):g?.staticFormat?(e=g.staticFormat,f=g.apiType,"none"===e?"none":"qwen"===e?"qwen":"responses"===f?"openai-responses":"nested"===e?"openai-nested":"openai"):null})},86187:(a,b,c)=>{c.d(b,{Ag:()=>l,SS:()=>x,Xy:()=>w});var d=c(12197),e=c(54070),f=c(12407),g=c(66573);let h=new TextEncoder,i=/unknown tool|no tool named|tool not found|not a (valid|recognized) tool|is not available|error/i;function j(){return{type:"object",properties:{vault_id:{type:"string",description:"The vault id from the placeholder, e.g. vlt_abc123."},query:{type:"string",description:"What to look for in the stored content."}},required:["query"]}}function k(){return"Search the Switchboard conversation vault for the full content of a tool result that was externalized to save context. Provide the vault_id shown in the placeholder and a query describing what you need."}function l(a,b){try{if(!Array.isArray(a?.tools))return!1;for(let b=0;b<a.tools.length;b+=1){var c;if(c=a.tools[b],(c?.function?.name||c?.name||"")===d.mS)return!1}if("openai"===b)a.tools.push({type:"function",function:{name:d.mS,description:k(),parameters:j()}});else{if("claude"!==b)return!1;a.tools.push({name:d.mS,description:k(),input_schema:j()})}return!0}catch{return!1}}function m(a,b=!1){let c=new Headers(a);return c.delete("content-length"),b&&c.delete("content-encoding"),c}function n(a){try{let b=JSON.parse(a||"{}");return b&&"object"==typeof b?b:{}}catch{return{}}}function o(a,b){return"string"==typeof a&&a?{callId:a,query:b?.query,vaultId:b?.vault_id}:null}function p(a,b){if(!Array.isArray(a)||0===a.length||!b||a.some(a=>!a))return null;let c=a[0];return{kind:"call",callId:c.callId,query:c.query,vaultId:c.vaultId,calls:a,assistantRaw:b}}function q(a){let b=[],c=a.split(/\r?\n/);for(let a=0;a<c.length;a+=1){if(!c[a].startsWith("data:"))continue;let d=c[a].slice(5).trim();if(d&&"[DONE]"!==d)try{b.push(JSON.parse(d))}catch{}}return b}async function r(a){let b=null;try{let c=new Promise((a,c)=>{b=setTimeout(()=>c(Error("vault stream idle")),2e4)});return await Promise.race([a.read(),c])}finally{b&&clearTimeout(b)}}async function s(a){let b=a.clone().body?.getReader();if(!b)throw Error("missing stream body");let c=new TextDecoder,d="";try{for(;;){let a=await r(b);if(a.done)break;d+=c.decode(a.value,{stream:!0})}return d+c.decode()}catch(a){try{await b.cancel()}catch{}throw a}}async function t(a,b){try{var c,e;let f;if(!(a?.headers?.get("content-type")||"").toLowerCase().includes("text/event-stream")){let e=await a.clone().json();return c=new Response(JSON.stringify(e),{status:a.status,statusText:a.statusText,headers:m(a.headers)}),"openai"===b?function(a,b){if(Array.isArray(a?.choices)&&a.choices.length>1)return{kind:"none",replay:b};let c=a?.choices?.[0]?.message,e=Array.isArray(c?.tool_calls)?c.tool_calls:[],f=[],g=!1;for(let a=0;a<e.length;a+=1)e[a]?.function?.name===d.mS?f.push(o(e[a].id,n(e[a].function?.arguments))):g=!0;return 0===f.length?{kind:"none",replay:b}:g||"string"==typeof c?.content&&c.content.trim()?{kind:"mixed",replay:b}:p(f,c)||{kind:"none",replay:b}}(e,c):"claude"===b?function(a,b){let c=Array.isArray(a?.content)?a.content:[],e=[],f=!1,g=!1;for(let a=0;a<c.length;a+=1){let b=c[a];b?.type==="tool_use"&&(b.name===d.mS?e.push(o(b.id,b.input||{})):g=!0),b?.type==="text"&&"string"==typeof b.text&&b.text.trim()&&(f=!0)}return 0===e.length?{kind:"none",replay:b}:g||f?{kind:"mixed",replay:b}:p(e,c)||{kind:"none",replay:b}}(e,c):{kind:"none",replay:c}}let g=await s(a);return f=h.encode(g),e=new Response(new ReadableStream({start(a){a.enqueue(f),a.close()}}),{status:a.status,statusText:a.statusText,headers:m(a.headers,!0)}),"openai"===b?function(a,b){let c=new Map,e=!1,f=!1,g=q(a);for(let a=0;a<g.length;a+=1){let b=Array.isArray(g[a]?.choices)?g[a].choices:[];b.length>1&&(f=!0);let d=b[0];Number.isInteger(d?.index)&&d.index>0&&(f=!0);let h=d?.delta;if(!h)continue;"string"==typeof h.content&&h.content.trim()&&(e=!0);let i=Array.isArray(h.tool_calls)?h.tool_calls:[];for(let a=0;a<i.length;a+=1){let b=i[a],d=Number.isInteger(b?.index)?b.index:a,e=c.get(d)||{id:"",name:"",arguments:""};"string"==typeof b?.id&&(e.id=b.id),"string"==typeof b?.function?.name&&(e.name=b.function.name),"string"==typeof b?.function?.arguments&&(e.arguments+=b.function.arguments),c.set(d,e)}}let h=[...c.entries()].sort((a,b)=>a[0]-b[0]).map(([,a])=>a),i=[],j=[],k=!1;for(let a of h)a.name===d.mS?(i.push(o(a.id,n(a.arguments))),j.push({id:a.id,type:"function",function:{name:d.mS,arguments:a.arguments}})):k=!0;return 0===i.length?{kind:"none",replay:b}:f||k||e?{kind:"mixed",replay:b}:p(i,{role:"assistant",content:null,tool_calls:j})||{kind:"none",replay:b}}(g,e):"claude"===b?function(a,b){let c=new Map,e=!1,f=q(a);for(let a=0;a<f.length;a+=1){let b=f[a],d=Number.isInteger(b?.index)?b.index:0,g=b?.content_block;if(b?.type==="content_block_start"&&g?.type==="tool_use"&&c.set(d,{id:g.id||"",name:g.name||"",input:""}),b?.type==="content_block_start"&&g?.type==="text"&&"string"==typeof g.text&&g.text.trim()&&(e=!0),b?.delta?.type==="text_delta"&&"string"==typeof b.delta.text&&b.delta.text.trim()&&(e=!0),b?.delta?.type==="input_json_delta"){let a=c.get(d);a&&"string"==typeof b.delta.partial_json&&(a.input+=b.delta.partial_json)}}let g=[...c.entries()].sort((a,b)=>a[0]-b[0]).map(([,a])=>a),h=[],i=[],j=!1;for(let a of g)if(a.name===d.mS){let b=n(a.input);h.push(o(a.id,b)),i.push({type:"tool_use",id:a.id,name:d.mS,input:b})}else j=!0;return 0===h.length?{kind:"none",replay:b}:j||e?{kind:"mixed",replay:b}:p(h,i)||{kind:"none",replay:b}}(g,e):{kind:"none",replay:e}}catch{return{kind:"none",replay:a}}}function u(a){return h.encode(a).length}function v(a){try{if(!Array.isArray(a)||0===a.length)return"No matching content found in the vault for that query.";let b=[];for(let c=0;c<a.length;c+=1){let d=a[c]||{},e=d.toolName?` from ${d.toolName}`:"";b.push(`[chunk ${c+1}${e}]
|
|
8
|
-
${"string"==typeof d.text?d.text:""}`)}let c=b.join("\n\n");if(
|
|
7
|
+
`)),a.enqueue(f.encode("data: [DONE]\n\n")),a.close()}});return new Response(h,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}})}(!!c.stream,e)}(0,z.lg)(g),(0,z.LH)(g,i)}b&&(c.messages=(0,z.Jl)(c.messages))}}catch(a){A.warn?.("FEEDBACK",`capture/strip failed (ignored): ${a?.message||a}`)}let k=(0,r.t8)(c);if(n){let f=(0,l.tg)({models:n,comboName:e,settings:m,log:A});if(f.response)return f.response;n=f.models;let g=m.comboStrategies||{},h=g[e]?.fallbackStrategy||m.comboStrategy||"fallback";if("fusion"===h)return A.info("CHAT",`Combo "${e}" with ${n.length} models (strategy: fusion)`),(0,r.vt)({body:c,models:n,handleSingleModel:(c,e,f)=>{let g=!0===f?{isPanel:!0}:f||{},h=b;if(g.isPanel&&b){let{tools:a,tool_choice:c,...d}=b.body||{};h={...b,body:d}}return R(c,e,h,a,d,{...g,signal:g.signal||null})},log:A,comboName:e,judgeModel:g[e]?.judgeModel,tuning:g[e]?.fusionTuning,abortSignal:a?.signal||null,childComboDepth:1});if("auto"===h){let h=g[e]||{},i=!0===h.feedbackAsk,k=null;if(i)try{let b=(0,x.t)(new URL(a.url).pathname,c),e=(0,z.Mc)(c.messages),f=(0,z.EN)(d||"local-no-key");k={apiKeyHash:f,conversationFp:(0,z.sO)(e.firstUserText,f),openAiWire:"openai"===b,gateOk:!(c.tools&&c.tools.length||c.functions&&c.functions.length)&&Number(e.userTurns)>=2,feedbackAsk:!0}}catch{k=null}let m=h.routerModel;if(m&&await (0,j.getComboModels)(m))return A.warn("CHAT",`Auto routerModel is a combo (${m}) — rejected`),(0,q.yj)(w.gx.BAD_REQUEST,`routerModel cannot be a combo ("${m}"). Use a single provider/model.`);let o=[];for(let a of n)a!==m&&o.push(a);if(!o.length&&f.skipped.length)return(0,l.tW)({comboName:e,skipped:f.skipped.filter(a=>a.model!==m),log:A});let p={};for(let a of o)try{p[a]=await (0,C.w)(a)}catch{p[a]={}}return A.info("CHAT",`Combo "${e}" with ${o.length} workers (strategy: auto)`),(0,t.EA)({body:c,models:[...o,...n.includes(m)?[m]:[]],handleSingleModel:(c,e,f)=>R(c,e,b,a,d,{...f||{},comboDepth:0}),log:A,comboName:e,strategy:h,loadLearning:K,loadStats:L,loadGlobalStats:a=>(0,I.PO)(`gstats:${a}`,()=>(0,H.cX)(a),15e3),loadClusterP50:(a,b,c)=>(0,I.PO)(`p50:${a}:${b}:${c}`,()=>(0,H._6)(a,b,c)),loadProviderLatency:M,loadProviderUsage:N,loadProviderQuota:O,recordEvent:(0,l.zw)(a=>(0,H.ex)(a),f.skipped),applyJudgeScore:(a,b)=>(0,H.Vp)(a,b),autoDepth:0,clientAbortSignal:a?.signal||null,feedbackCtx:k,workerCaps:p})}let i=(0,s.R8)(n,k,m),o=i.filter(a=>!n.includes(a)),p=m.comboStickyRoundRobinLimit,u=g[e]||{},v=!1!==u.capacityAutoSwitch,y=u.providerStrategy&&"off"!==u.providerStrategy?await P(u):null;return A.info("CHAT",`Combo "${e}" with ${i.length} models (strategy: ${h}, sticky: ${p}, capacitySwitch: ${v})`),(0,r.Pr)({body:c,models:i,handleSingleModel:(0,s.ar)((c,e,f)=>R(c,e,b,a,d,f),o),log:A,comboName:e,comboStrategy:h,comboStickyLimit:p,autoSwitch:v,...y||{},abortSignal:a?.signal||null,childComboDepth:1})}let p=(0,s.R8)([e],k,m);if(p.length>1){let f=p.filter(a=>a!==e);return A.info("CHAT",`Capacity adapter for [${[...k].join(",")}] on "${e}" → trying ${p.join(", ")}`),(0,r.Pr)({body:c,models:p,handleSingleModel:(0,s.ar)((c,e,f)=>R(c,e,b,a,d,{...f||{},signal:f?.signal||a?.signal||null,preferredConnectionId:g,strictPreferredConnection:h,allowNativeClaudeOAuth:!0}),f),log:A,comboName:e,comboStrategy:(0,s.vB)(k,m),abortSignal:a?.signal||null,childComboDepth:1})}let u=null;try{u=(0,x.t)(new URL(a.url).pathname,c)}catch{}if(!(m.tokenSaver?.vault&&Array.isArray(c.tools)&&c.tools.length>0&&("openai"===u||"claude"===u)))return R(c,e,b,a,d,{signal:a?.signal||null,preferredConnectionId:g,strictPreferredConnection:h,allowNativeClaudeOAuth:!0});try{let f=(0,z.Bk)(c.messages,(0,z.EN)(d||"local-no-key"));if(!f)return R(c,e,b,a,d,{signal:a?.signal||null,preferredConnectionId:g,strictPreferredConnection:h,allowNativeClaudeOAuth:!0});await (0,y.Xy)(c,{conversationId:f,signal:a?.signal}),(0,y.Ag)(c,u);let i=Number(m.tokenSaver?.vaultSearchLimit??5);return await (0,y.SS)({dispatch:(c,i)=>R(c,e,b,a,d,{signal:i?.signal||a?.signal||null,preferredConnectionId:g,strictPreferredConnection:h,allowNativeClaudeOAuth:!0,vaultInternal:!!i?.vaultInternal,vaultStore:!0,vaultConversationId:f}),body:c,wire:u,signal:a?.signal,conversationId:f,searchLimit:i,log:A})}catch{return R(c,e,b,a,d,{signal:a?.signal||null,preferredConnectionId:g,strictPreferredConnection:h,allowNativeClaudeOAuth:!0})}})}async function R(a,b,c=null,d=null,e=null,i=null){let u=[d?.signal,i?.signal].filter(Boolean),v=u.length>1?AbortSignal.any(u):u[0],y=()=>(0,q.yj)(499,"Request aborted");if(v?.aborted)return y();await (0,k.vA)();let B=await (0,j.getModelInfo)(b),F=i?.autoDepth||0,J=i?.comboDepth||0;if(!B.provider){let f=await (0,j.getComboModels)(b);if(f){let g=await (0,h.mt)(),k=(0,l.tg)({models:f,comboName:b,settings:g,log:A});if(k.response)return k.response;f=k.models;let m=(0,r.t8)(a),n=(0,s.R8)(f,m,g),o=n.filter(a=>!f.includes(a)),p=g.comboStrategies||{},u=p[b]?.fallbackStrategy||g.comboStrategy||"fallback";if("auto"!==u&&J>=w.wg)return A.warn("CHAT",`Combo nesting limit at "${b}" (depth ${J})`),(0,q.yj)(w.gx.BAD_REQUEST,`Combo nesting too deep (>${w.wg}) at "${b}"`);if("fusion"===u)return A.info("CHAT",`Combo "${b}" with ${f.length} models (strategy: fusion)`),(0,r.vt)({body:a,models:f,handleSingleModel:(a,b,f)=>{let g=!0===f?{isPanel:!0}:f||{},h=c;if(g.isPanel&&c){let{tools:a,tool_choice:b,...d}=c.body||{};h={...c,body:d}}return R(a,b,h,d,e,{...i||{},...g,signal:g.signal||i?.signal||null})},log:A,comboName:b,judgeModel:p[b]?.judgeModel,tuning:p[b]?.fusionTuning,abortSignal:v||null,childComboDepth:J+1,autoDepth:F});if("auto"===u){if(F>=2)return A.warn("CHAT",`Auto combo recursion limit at "${b}" (depth ${F})`),(0,q.yj)(w.gx.BAD_REQUEST,`Auto combo recursion limit — "${b}" cannot nest further`);let g=p[b]||{},h=!0===g.feedbackAsk,i=null;if(h)try{let b=(0,x.t)(new URL(d.url).pathname,a),c=(0,z.Mc)(a.messages),f=(0,z.EN)(e||"local-no-key");i={apiKeyHash:f,conversationFp:(0,z.sO)(c.firstUserText,f),openAiWire:"openai"===b,gateOk:!(a.tools&&a.tools.length||a.functions&&a.functions.length)&&Number(c.userTurns)>=2,feedbackAsk:!0}}catch{i=null}let m=g.routerModel;if(m&&await (0,j.getComboModels)(m))return(0,q.yj)(w.gx.BAD_REQUEST,`routerModel cannot be a combo ("${m}")`);let n=[];for(let a of f)a!==m&&n.push(a);if(!n.length&&k.skipped.length)return(0,l.tW)({comboName:b,skipped:k.skipped.filter(a=>a.model!==m),log:A});let o={};for(let a of n)try{o[a]=await (0,C.w)(a)}catch{o[a]={}}return A.info("CHAT",`Combo "${b}" with ${n.length} workers (strategy: auto, depth=${F})`),(0,t.EA)({body:a,models:[...n,...f.includes(m)?[m]:[]],handleSingleModel:(a,b,f)=>R(a,b,c,d,e,{...f||{},comboDepth:J}),log:A,comboName:b,strategy:g,loadLearning:K,loadStats:L,loadGlobalStats:a=>(0,I.PO)(`gstats:${a}`,()=>(0,H.cX)(a),15e3),loadClusterP50:(a,b,c)=>(0,I.PO)(`p50:${a}:${b}:${c}`,()=>(0,H._6)(a,b,c)),loadProviderLatency:M,loadProviderUsage:N,loadProviderQuota:O,recordEvent:(0,l.zw)(a=>(0,H.ex)(a),k.skipped),applyJudgeScore:(a,b)=>(0,H.Vp)(a,b),autoDepth:F,comboDepth:J,clientAbortSignal:d?.signal||null,feedbackCtx:i,workerCaps:o})}let y=g.comboStickyRoundRobinLimit,B=p[b]||{},D=!1!==B.capacityAutoSwitch,E=B.providerStrategy&&"off"!==B.providerStrategy?await P(B):null;return A.info("CHAT",`Combo "${b}" with ${n.length} models (strategy: ${u}, sticky: ${y}, capacitySwitch: ${D})`),(0,r.Pr)({body:a,models:n,handleSingleModel:(0,s.ar)((a,b,f)=>R(a,b,c,d,e,f),o),log:A,comboName:b,comboStrategy:u,comboStickyLimit:y,autoSwitch:D,...E||{},abortSignal:v||null,childComboDepth:J+1,autoDepth:F})}return A.warn("CHAT","Invalid model format",{model:b}),(0,q.yj)(w.gx.BAD_REQUEST,"Invalid model format")}let{provider:Q,model:S}=B;b!==`${Q}/${S}`?A.info("ROUTING",`${b} → ${Q}/${S}`):A.info("ROUTING",`Provider: ${Q}, Model: ${S}`);let T=d?.headers?.get("user-agent")||"",U=new Set,V=null,W=null,X=(0,G.M)({request:d,provider:Q,allowNativeOAuth:i?.allowNativeClaudeOAuth===!0}),Y=(0,g.mA)({headers:d?.headers,body:a,scope:Q,clientKeyId:e});for(;;){if(v?.aborted)return y();let b=X||await (0,f.getProviderCredentials)(Q,U,S,{preferredConnectionId:i?.preferredConnectionId||null,strictPreferredConnection:i?.strictPreferredConnection===!0,sessionKey:Y,clientKeyId:e});if(v?.aborted)return y();if(!b||b.allRateLimited){if(b?.allRateLimited){let a=V||b.lastError||"Unavailable",c=W||Number(b.lastErrorCode)||w.gx.SERVICE_UNAVAILABLE;return A.warn("CHAT",`[${Q}/${S}] ${a} (${b.retryAfterHuman})`),(0,q.wO)(c,`[${Q}/${S}] ${a}`,b.retryAfter,b.retryAfterHuman)}if(0===U.size)return A.warn("AUTH",`No active credentials for provider: ${Q}`),(0,q.yj)(w.gx.NOT_FOUND,`No active credentials for provider: ${Q}`);return A.warn("CHAT","No more accounts available",{provider:Q}),(0,q.yj)(W||w.gx.SERVICE_UNAVAILABLE,V||"All accounts unavailable")}A.info("AUTH",`\x1b[32mUsing ${Q} account: ${b.connectionName}\x1b[0m`);let g=b.ephemeral?b:await (0,D.eU)(Q,b);if(v?.aborted)return y();if(("antigravity"===Q||"gemini-cli"===Q)&&!g.projectId){let a=await (0,E.eG)(b.connectionId,g.accessToken,Q);a&&(g.projectId=a,(0,D.vN)(b.connectionId,{projectId:a}).catch(()=>{}))}let j=await (0,h.mt)();if(v?.aborted)return y();let k=(j.providerThinking||{})[Q]||null,l="function"==typeof structuredClone?structuredClone(a):JSON.parse(JSON.stringify(a)),r=i?.sourceFormatOverride||(d?.url?(0,x.t)(new URL(d.url).pathname,a):null),s=!!i?.bypassPromptFilters,t=await (0,m.w)({body:{...l,model:`${Q}/${S}`},modelInfo:{provider:Q,model:S},credentials:g,log:A,clientRawRequest:c,connectionId:b.connectionId,userAgent:T,clientKeyId:e,ccFilterNaming:!!j.ccFilterNaming,rtkEnabled:!s&&!!j.rtkEnabled,vaultEnabled:!s&&!!i?.vaultStore&&!!j.tokenSaver?.vault,vaultThresholdKB:j.tokenSaver?.vaultThresholdKB??8,vaultTtlHours:j.tokenSaver?.vaultTtlHours??24,vaultConversationId:i?.vaultConversationId??null,headroomEnabled:!s&&!!j.headroomEnabled,headroomUrl:j.headroomUrl||n.ag,headroomCompressUserMessages:!s&&!!j.headroomCompressUserMessages,cavemanEnabled:!s&&!!j.cavemanEnabled,cavemanLevel:j.cavemanLevel||"full",ponytailEnabled:!s&&!!j.ponytailEnabled,ponytailLevel:j.ponytailLevel||"full",pxpipeEnabled:!s&&!!j.pxpipeEnabled,pxpipeMinChars:j.pxpipeMinChars,pxpipeTimeoutMs:j.pxpipeTimeoutMs,pxpipeTransform:!s&&j.pxpipeEnabled?await (0,o.RG)():null,onPxpipeEvent:p.T0,providerThinking:k,sourceFormatOverride:r,bypassNativePassthrough:!!i?.bypassNativePassthrough,vaultInternal:!!i?.vaultInternal,abortSignal:v||null,onCredentialsRefreshed:async a=>{b.ephemeral||await (0,D.vN)(b.connectionId,{...a,existingProviderSpecificData:b.providerSpecificData,testStatus:"active"})},onRequestSuccess:async()=>{b.ephemeral||await (0,f.Pt)(b.connectionId,b,S)},onUpstreamEmptyExhausted:async(a,c)=>{b.ephemeral||v?.aborted||await (0,f.vk)(b.connectionId,502,"string"==typeof a?a:a?.message||"empty stream",Q,S,c)}});if(v?.aborted||499===t.status){try{await t.response?.body?.cancel?.()}catch{}return y()}if(t.success||b.ephemeral)return t.response;let{shouldFallback:u}=await (0,f.vk)(b.connectionId,t.status,t.error,Q,S,t.resetsAtMs);if(u){A.warn("AUTH",`Account ${b.connectionName} unavailable (${t.status}), trying fallback`),U.add(b.connectionId),V=t.error,W=t.status;continue}return t.response}}[e,m]=J.then?(await J)():J,(0,H.tu)(a=>{(0,u.aW)(a),a?((0,I.Y3)(`stats:${a}:`),(0,I.Y3)(`learning:${a}`),(0,t.a8)(a)):(0,I.Y3)()}),d()}catch(a){d(a)}})},85432:(a,b,c)=>{c.d(b,{Kt:()=>m,MH:()=>l,vA:()=>k});var d=c(15717),e=c(19978),f=c(94454),g=c(29696);let h="compatible-reasoning:snapshot";async function i(){let a="function"==typeof d.Fh?(0,d.Fh)({type:"openai-compatible"}):Promise.resolve([]),b="function"==typeof d.uv?(0,d.uv)():Promise.resolve([]),[c,e]=await Promise.all([Promise.resolve(a).catch(()=>[]),Promise.resolve(b).catch(()=>[])]),f=new Map,h=new Map;for(let a of c){if(!a?.id||!a?.prefix)continue;let b={id:a.id,apiType:"responses"===a.apiType?"responses":"chat",staticFormat:(0,g.ml)(a.baseUrl)};f.set(a.id,b),h.set(a.prefix,b)}let i=new Map;for(let a of e){if(!a?.providerAlias||!a?.id||"llm"!==(a.type||"llm"))continue;let b=h.get(a.providerAlias);b&&(0,g.K5)(a.reasoning)&&i.set(`${b.id}|${a.id}`,a.reasoning)}return{nodesById:f,prefixToNode:h,byModel:i}}let j={nodesById:new Map,prefixToNode:new Map,byModel:new Map};async function k(a=15e3){try{let b=await (0,e.PO)(h,i,a);b&&(j=b)}catch{}}function l(){(0,e.Y3)(h)}function m(a,b){let c=j.prefixToNode.get(a);if(!c)return null;let d=j.byModel.get(`${c.id}|${b}`);return d||("none"===c.staticFormat?{supported:!1,effort:null}:c.staticFormat?{supported:!0,effort:"qwen"===c.staticFormat?null:c.staticFormat}:null)}(0,f.xl)(function(a,b){var c,d,e,f;if(!a||!a.startsWith("openai-compatible-"))return null;let g=j.nodesById.get(a),h=j.byModel.get(`${a}|${b}`);return h?(c=h,d=g?.apiType||"chat",c.supported?"responses"===d?"openai-responses":"nested"===c.effort?"openai-nested":"openai":"none"):g?.staticFormat?(e=g.staticFormat,f=g.apiType,"none"===e?"none":"qwen"===e?"qwen":"responses"===f?"openai-responses":"nested"===e?"openai-nested":"openai"):null})},86187:(a,b,c)=>{c.d(b,{Ag:()=>l,SS:()=>z,Xy:()=>y});var d=c(12197),e=c(54070),f=c(12407),g=c(66573);let h=new TextEncoder,i=/^\s*(?:<tool_use_error>\s*)?(?:Error:\s*)?(?:unknown tool|no (?:such )?tool (?:named|available)|tool not found|not a (?:valid|recognized) tool)[^\n]{0,80}sb_vault_search/i;function j(){return{type:"object",properties:{vault_id:{type:"string",description:"The vault id from the placeholder, e.g. vlt_abc123."},query:{type:"string",description:"What to look for in the stored content."}},required:["query"]}}function k(){return"Search the Switchboard conversation vault for the full content of a tool result that was externalized to save context. Provide the vault_id shown in the placeholder and a query describing what you need."}function l(a,b){try{if(!Array.isArray(a?.tools))return!1;for(let b=0;b<a.tools.length;b+=1){var c;if(c=a.tools[b],(c?.function?.name||c?.name||"")===d.mS)return!1}if("openai"===b)a.tools.push({type:"function",function:{name:d.mS,description:k(),parameters:j()}});else{if("claude"!==b)return!1;a.tools.push({name:d.mS,description:k(),input_schema:j()})}return!0}catch{return!1}}function m(a,b=!1){let c=new Headers(a);return c.delete("content-length"),b&&c.delete("content-encoding"),c}function n(a,b){if([204,205,304].includes(a.status))return new Response(null,{status:a.status,statusText:a.statusText,headers:m(a.headers,!0)});let c="string"==typeof b?h.encode(b):b;return new Response(new ReadableStream({start(a){a.enqueue(c),a.close()}}),{status:a.status,statusText:a.statusText,headers:m(a.headers,!0)})}function o(a){try{let b=JSON.parse(a||"{}");return b&&"object"==typeof b&&!Array.isArray(b)?b:null}catch{return null}}function p(a,b){return"string"==typeof a&&a&&"string"==typeof b?.query&&(null==b.vault_id||"string"==typeof b.vault_id)?{callId:a,query:b?.query,vaultId:b?.vault_id}:null}function q(a,b){if(!Array.isArray(a)||0===a.length||!b||a.some(a=>!a)||new Set(a.map(a=>a.callId)).size!==a.length)return null;let c=a[0];return{kind:"call",callId:c.callId,query:c.query,vaultId:c.vaultId,calls:a,assistantRaw:b}}function r(a){let b=[];for(let c of(b.hasDone=!1,b.invalid=!1,a.split(/\r?\n\r?\n/))){let a=c.split(/\r?\n/).filter(a=>a.startsWith("data:")).map(a=>a.slice(5).trimStart()).join("\n").trim();if(a){if("[DONE]"===a){b.hasDone=!0;continue}try{b.push(JSON.parse(a))}catch{b.invalid=!0}}}return b}async function s(a,b,c){let d,e;try{if(b?.aborted)throw Error("vault operation aborted");let f=new Promise((a,f)=>{d=setTimeout(()=>f(Error("vault stream idle or deadline exceeded")),c),e=()=>f(Error("vault operation aborted")),b?.addEventListener("abort",e,{once:!0})});return await Promise.race([a.read(),f])}finally{clearTimeout(d),e&&b?.removeEventListener("abort",e)}}async function t(a,{signal:b}={}){let c=a.body?.getReader();if(!c)return{text:"",bytes:new Uint8Array};let d=[],e=0,f=Date.now()+6e5;try{for(;;){let a=f-Date.now();if(a<=0)throw Error("vault buffer deadline exceeded");let g=await s(c,b,Math.min(12e4,a));if(g.done)break;if((e+=g.value.byteLength)>8388608)throw Error("vault buffer size exceeded");d.push(g.value)}let a=new Uint8Array(e),g=0;for(let b of d)a.set(b,g),g+=b.byteLength;return{bytes:a}}catch(a){try{Promise.resolve(c.cancel(a)).catch(()=>{})}catch{}throw a}finally{try{c.releaseLock()}catch{}}}async function u(a,b,{signal:c}={}){let e;if(!a.ok)return{kind:"none",replay:a};let f=a?.headers?.get("content-type")||"";try{var g;e=await t(a,{signal:c});let h=n(a,e.bytes),i=new TextDecoder("utf-8",{fatal:!0}).decode(e.bytes);if(!f.toLowerCase().includes("text/event-stream"))return{...(g=JSON.parse(i),"openai"===b?function(a,b){if(Array.isArray(a?.choices)&&a.choices.length>1)return{kind:"none",replay:b};let c=a?.choices?.[0],e=c?.message,f=Array.isArray(e?.tool_calls)?e.tool_calls:[],g=[],h=!1;for(let a=0;a<f.length;a+=1)f[a]?.function?.name===d.mS?g.push(p(f[a].id,o(f[a].function?.arguments))):h=!0;return 0===g.length?{kind:"none",replay:b}:h||a?.error||c?.finish_reason!=null&&!["stop","tool_calls","function_call"].includes(c.finish_reason)||e&&Object.keys(e).some(a=>!(["role","content","tool_calls"].includes(a)||"refusal"===a&&null==e[a]||"annotations"===a&&Array.isArray(e[a])&&0===e[a].length))||"string"==typeof e?.content&&e.content.trim()?{kind:"mixed",replay:b}:q(g,e)||{kind:"none",replay:b}}(g,h):"claude"===b?function(a,b){let c=Array.isArray(a?.content)?a.content:[],e=[],f=!1,g=!1;for(let a=0;a<c.length;a+=1){let b=c[a];b?.type==="tool_use"?b.name===d.mS?e.push(p(b.id,b.input||{})):g=!0:b?.type!=="text"&&b?.type!=="thinking"&&b?.type!=="redacted_thinking"&&(g=!0),b?.type==="text"&&"string"==typeof b.text&&b.text.trim()&&(f=!0)}return 0===e.length?{kind:"none",replay:b}:g||f||a?.error||a?.stop_reason!=null&&"tool_use"!==a.stop_reason?{kind:"mixed",replay:b}:q(e,c.filter(a=>a?.type!=="text"))||{kind:"none",replay:b}}(g,h):{kind:"none",replay:h}),replay:h};return{..."openai"===b?function(a,b){let c=new Map,e=!1,f=!1,g=r(a),h=g.invalid,i=g.hasDone;for(let a=0;a<g.length;a+=1){g[a]?.error&&(h=!0);let b=Array.isArray(g[a]?.choices)?g[a].choices:[];b.length>1&&(f=!0);let d=b[0];Number.isInteger(d?.index)&&d.index>0&&(f=!0),d?.finish_reason!=null&&(i=!0,["stop","tool_calls","function_call"].includes(d.finish_reason)||(h=!0));let j=d?.delta;if(!j)continue;Object.keys(j).some(a=>!["role","content","tool_calls"].includes(a))&&(h=!0),"string"==typeof j.content&&j.content.trim()&&(e=!0);let k=Array.isArray(j.tool_calls)?j.tool_calls:[];for(let a=0;a<k.length;a+=1){let b=k[a],d=b?.index;if(!Number.isInteger(d)){if(!b?.id){h=!0;continue}if(void 0===(d=[...c.entries()].find(([,a])=>a.id===b.id)?.[0])){if(c.size>=100){h=!0;continue}d=c.size?Math.max(...c.keys())+1:0}}if(!c.has(d)&&c.size>=100){h=!0;continue}let e=c.get(d);e?.id&&b?.id&&e.id!==b.id&&(h=!0);let f=c.get(d)||{id:"",name:"",arguments:""};"string"==typeof b?.id&&(f.id=b.id),"string"==typeof b?.function?.name&&(f.name=b.function.name),"string"==typeof b?.function?.arguments&&(f.arguments+=b.function.arguments),c.set(d,f)}}let j=[...c.entries()].sort((a,b)=>a[0]-b[0]).map(([,a])=>a),k=[],l=[],m=!1;for(let a of j)a.name===d.mS?(k.push(p(a.id,o(a.arguments))),l.push({id:a.id,type:"function",function:{name:d.mS,arguments:a.arguments}})):m=!0;return 0===k.length?{kind:"none",replay:b}:h||!i||f||m||e?{kind:"mixed",replay:b}:q(k,{role:"assistant",content:null,tool_calls:l})||{kind:"none",replay:b}}(i,h):"claude"===b?function(a,b){let c=new Map,e=!1,f=r(a),g=f.invalid,h=f.hasDone;for(let a of f){a?.type==="message_stop"&&(h=!0),a?.type==="message_delta"&&a.delta?.stop_reason&&"tool_use"!==a.delta.stop_reason&&(g=!0),a?.type==="error"&&(g=!0);let b=Number.isInteger(a?.index)?a.index:0,d=a?.content_block;if(a?.type==="content_block_start"&&d){if(c.size>=120){g=!0;continue}["tool_use","thinking","redacted_thinking","text"].includes(d.type)||(g=!0),c.set(b,{...d,partialInput:""}),"text"===d.type&&d.text?.trim()&&(e=!0)}let f=c.get(b),i=a?.type==="content_block_delta"?a.delta:void 0;if(i?.type==="text_delta"&&i.text?.trim()&&(e=!0),!f){a?.type==="content_block_delta"&&(g=!0);continue}i?.type==="input_json_delta"&&"tool_use"===f.type?f.partialInput+=i.partial_json||"":i?.type==="thinking_delta"&&"thinking"===f.type?f.thinking=(f.thinking||"")+(i.thinking||""):i?.type==="signature_delta"&&"thinking"===f.type?f.signature=(f.signature||"")+(i.signature||""):i&&"text_delta"!==i.type&&(g=!0)}let i=[],j=[];for(let[,a]of[...c.entries()].sort((a,b)=>a[0]-b[0])){let{partialInput:b,...c}=a;if("text"!==a.type){if("tool_use"===a.type)if(a.name!==d.mS)g=!0;else{let d=b?o(b):a.input||{};i.push(p(a.id,d)),c.input=d}j.push(c)}}return 0===i.length?{kind:"none",replay:b}:g||!h||e?{kind:"mixed",replay:b}:q(i,j)||{kind:"none",replay:b}}(i,h):{kind:"none",replay:h},replay:h}}catch{if(e)return{kind:"none",replay:n(a,e.bytes)};let d={type:"api_error",message:"Vault upstream stream did not complete."};return{kind:"none",replay:Response.json("claude"===b?{type:"error",error:d}:{error:d},{status:c?.aborted?499:502})}}}async function v(a,{signal:b,timeoutMs:c=5e3}={}){let d,e;try{if(b?.aborted)throw Error("vault operation aborted");let g=new Promise((a,f)=>{d=setTimeout(()=>f(Error("vault search deadline exceeded")),c),e=()=>f(Error("vault operation aborted")),b?.addEventListener("abort",e,{once:!0})});return await Promise.race([(0,f.$s)(a),g])}finally{clearTimeout(d),e&&b?.removeEventListener("abort",e)}}function w(a){return h.encode(a).length}function x(a){try{if(!Array.isArray(a)||0===a.length)return"No matching content found in the vault for that query.";let b=[];for(let c=0;c<a.length;c+=1){let d=a[c]||{},e=d.toolName?` from ${d.toolName}`:"";b.push(`[chunk ${c+1}${e}]
|
|
8
|
+
${"string"==typeof d.text?d.text:""}`)}let c=b.join("\n\n");if(w(c)<=d.El)return c;let e="\n…[truncated]";return`${(0,g.ST)(c,d.El-w(e))}${e}`}catch{return"No matching content found in the vault for that query."}}async function y(a,{conversationId:b,limit:c=5,signal:e}={}){try{let h=Array.isArray(a?.messages)?a.messages:null;if(!h||!b)return 0;let j=[],k=0,l=Date.now()+5e3;for(let a=0;a<h.length&&a<1e3&&!(e?.aborted||k>=100||Date.now()>=l);a+=1){let m=h[a],n=[...function(a){let b=[],c=Array.isArray(a?.tool_calls)?a.tool_calls:[];for(let a=0;a<c.length&&b.length<100;a+=1){let e=c[a];e?.function?.name===d.mS&&"string"==typeof e.id&&b.push({id:e.id,args:o(e.function.arguments)})}return b}(m),...function(a){let b=[],c=Array.isArray(a?.content)?a.content:[];for(let a=0;a<c.length&&b.length<100;a+=1){let e=c[a];e?.type==="tool_use"&&e.name===d.mS&&"string"==typeof e.id&&b.push({id:e.id,args:e.input||{}})}return b}(m)];for(let d=0;d<n.length;d+=1){var f,g;let m=n[d];if(e?.aborted||k>=100||Date.now()>=l)break;if(!p(m.id,m.args))continue;let o=function(a,b,c){for(let d=b;d<a.length&&d<1e3;d+=1){let b=a[d];if(b?.role==="tool"&&b.tool_call_id===c)return{target:b,content:b.content}}return null}(h,a+1,m.id)||function(a,b,c){for(let d=b;d<a.length&&d<1e3;d+=1){let b=Array.isArray(a[d]?.content)?a[d].content:[];for(let a=0;a<b.length;a+=1){let d=b[a];if(d?.type==="tool_result"&&d.tool_use_id===c)return{target:d,content:d.content}}}return null}(h,a+1,m.id);if(!o||(f=o.target,g=o.content,!(f?.is_error!==!1&&f?.status!=="success"&&(f?.is_error===!0||f?.status==="error"||i.test(function(a){try{if("string"==typeof a)return a;return JSON.stringify(a)||""}catch{return""}}(g))))))continue;k++;let q=await v({conversationId:b,query:m.args.query,vaultId:m.args.vault_id,limit:c},{signal:e,timeoutMs:Math.max(1,l-Date.now())});j.push({target:o.target,content:x(q)})}}for(let a of j)a.target.content=a.content,delete a.target.is_error,delete a.target.status;return j.length}catch{return 0}}async function z({dispatch:a,body:b,wire:c,conversationId:d,searchLimit:f=5,log:g=null,signal:h}){let i=b,j=0,k=new AbortController,l=setTimeout(()=>k.abort(),6e5),m=Date.now()+6e5,n=!1,o=h?AbortSignal.any([h,k.signal]):k.signal,p=async(b,c)=>{let d,e=Promise.resolve().then(()=>{if(o.aborted)throw Error("vault operation aborted");return a(b,{...c,signal:o})});e.then(a=>{if(o.aborted)try{Promise.resolve(a?.body?.cancel?.()).catch(()=>{})}catch{}},()=>{});try{let a=new Promise((a,b)=>{d=()=>b(Error("vault operation aborted")),o.aborted?d():o.addEventListener("abort",d,{once:!0})});return await Promise.race([e,a])}finally{d&&o.removeEventListener("abort",d)}},q=(a,b=502)=>{let d={type:"api_error",message:a};return Response.json("claude"===c?{type:"error",error:d}:{error:d},{status:b})},r=()=>q(h?.aborted?"Request aborted":"Vault processing deadline exceeded.",h?.aborted?499:502);try{for(let a=0;a<5;a+=1){if(o.aborted)return r();let b=await p(i,{vaultInternal:a>0,signal:o}),h=await u(b,c,{signal:o});if(o.aborted)return r();if("call"!==h.kind)return j>0&&g?.info?.("VAULT",`served ${j} vault search(es)`),h.replay||b;n||(n=!0,clearTimeout(l),l=setTimeout(()=>k.abort(),Math.max(1,Math.min(12e4,m-Date.now()))));let s=Array.isArray(h.calls)?h.calls:[],t=[];for(let a=0;a<s.length;a+=1){if(o.aborted)return r();if(j>=100)return q("Vault search budget exceeded.");let b=await v({conversationId:d,query:s[a].query,vaultId:s[a].vaultId,limit:f},{signal:o});t.push(x(b)),j+=1,(0,e.VS)()}i=function(a,b,c,d){let e=Array.isArray(c?.calls)?c.calls:[];if(!a||!Array.isArray(a.messages)||0===e.length||!c.assistantRaw)throw Error("invalid vault turn");let f=Array.isArray(d)?d:[],g=[...a.messages];if("openai"===b){g.push(c.assistantRaw);for(let a=0;a<e.length;a+=1)g.push({role:"tool",tool_call_id:e[a].callId,content:f[a]??""})}else if("claude"===b){let a=e.map((a,b)=>({type:"tool_result",tool_use_id:a.callId,content:f[b]??""}));g.push({role:"assistant",content:c.assistantRaw},{role:"user",content:a})}else throw Error("unsupported vault wire");return{...a,messages:g}}(i,c,h,t)}if(o.aborted)return r();return await p(i,{vaultInternal:!1,signal:o})}catch{if(o.aborted)return r();return q("Vault processing failed.")}finally{clearTimeout(l)}}},87155:(a,b,c)=>{c.d(b,{CG:()=>q,ED:()=>u,S1:()=>s,XF:()=>j,_g:()=>t,no:()=>r,sW:()=>w});var d=c(29021),e=c.n(d),f=c(33873),g=c.n(f),h=c(79646),i=c(49120);let j=g().join(i.nJ,"pxpipe"),k="pxpipe-proxy",l=g().join(j,"install.log"),m="win32"===process.platform,n=[...m?[`${process.env.ProgramFiles||""}\\nodejs`,`${process.env.APPDATA||""}\\npm`]:["/usr/local/bin","/opt/homebrew/bin",`${process.env.HOME||""}/.local/bin`,"/usr/bin","/bin"],process.env.PATH||""].filter(Boolean).join(g().delimiter),o=null;function p(){return g().join(j,"node_modules",k)}function q(){return g().join(p(),"dist","core","library.js")}function r(){try{let a=(0,h.execSync)(`${m?"where":"which"} npm`,{stdio:["ignore","pipe","ignore"],windowsHide:!0,env:{...process.env,PATH:n}}).toString().trim();return a?a.split(/\r?\n/)[0].trim():null}catch{return null}}function s(){try{let a=g().join(p(),"package.json");if(!e().existsSync(a)||!e().existsSync(q()))return{installed:!1,version:null,path:null};let b=JSON.parse(e().readFileSync(a,"utf8"));return{installed:!0,version:b.version||null,path:p()}}catch{return{installed:!1,version:null,path:null}}}function t(){return null!==o}function u(){return o||(o=v().finally(()=>{o=null}))}async function v(){let a=r();if(!a){let a=Error("npm not found on PATH — Node.js/npm is required to install PXPIPE");throw a.code="NPM_NOT_FOUND",a}e().existsSync(j)||e().mkdirSync(j,{recursive:!0});let b=g().join(j,"package.json");e().existsSync(b)||e().writeFileSync(b,JSON.stringify({name:"switchboard-pxpipe-host",private:!0},null,2));let c=e().openSync(l,"a");e().writeSync(c,`
|
|
9
9
|
[${new Date().toISOString()}] npm install ${k}@latest
|
|
10
10
|
`),await new Promise((b,d)=>{let e=(0,h.spawn)(a,["install",`${k}@latest`,"--no-audit","--no-fund","--omit=dev"],{cwd:j,stdio:["ignore",c,c],windowsHide:!0,env:{...process.env,PATH:n}}),f=setTimeout(()=>{e.kill("SIGKILL"),d(Error("npm install timed out after 5 minutes — see install.log"))},3e5);e.once("error",a=>{clearTimeout(f),d(a)}),e.once("exit",a=>{clearTimeout(f),0===a?b():d(Error(`npm install exited with code ${a} — see install.log`))})}).finally(()=>e().closeSync(c));let d=s();if(!d.installed)throw Error("install finished but package is missing — see install.log");return d}function w(a=200){try{if(!e().existsSync(l))return"";return e().readFileSync(l,"utf8").split(/\r?\n/).filter(Boolean).slice(-a).join("\n")}catch{return""}}},91686:(a,b,c)=>{c.d(b,{M:()=>e});var d=c(68393);function e({request:a,provider:b,allowNativeOAuth:c=!1}){if(!c||"anthropic"!==b||!a?.headers||!(0,d.i6)(a.headers))return null;let f=a.headers.get("authorization")||"";if(!f.startsWith("Bearer "))return null;let g=f.slice(7).trim();return g?{id:"claude-native-oauth",connectionId:"claude-native-oauth",connectionName:"Claude Code subscription",accessToken:g,ephemeral:!0,providerSpecificData:{}}:null}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
globalThis.__BUILD_MANIFEST={polyfillFiles:["static/chunks/polyfills-42372ed130431b0a.js"],devFiles:[],lowPriorityFiles:["static/
|
|
1
|
+
globalThis.__BUILD_MANIFEST={polyfillFiles:["static/chunks/polyfills-42372ed130431b0a.js"],devFiles:[],lowPriorityFiles:["static/MSigI0uI9w5TrE5x-BeGU/_buildManifest.js","static/MSigI0uI9w5TrE5x-BeGU/_ssgManifest.js"],rootMainFiles:["static/chunks/webpack-0aaec50204921747.js","static/chunks/4bd1b696-8a4ab4fdf0ae305a.js","static/chunks/3794-83acfce05009cf38.js","static/chunks/main-app-83fef838b21a8d19.js"],rootMainFilesTree:{},pages:{"/_app":[]}};
|