@kaitranntt/ccs 7.28.2-dev.1 → 7.28.2-dev.2
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/dist/cliproxy/auth/provider-refreshers/index.d.ts.map +1 -1
- package/dist/cliproxy/auth/provider-refreshers/index.js +1 -0
- package/dist/cliproxy/auth/provider-refreshers/index.js.map +1 -1
- package/dist/ui/assets/{accounts-Dx1GSmE5.js → accounts-Cje5sOzx.js} +1 -1
- package/dist/ui/assets/{alert-dialog-Bn6K2nsn.js → alert-dialog-Dq1Pn8h9.js} +1 -1
- package/dist/ui/assets/{api-Cp9G3vp7.js → api-Byy7A2jW.js} +1 -1
- package/dist/ui/assets/{auth-section-DD7GA40Q.js → auth-section-CuKAt0BI.js} +1 -1
- package/dist/ui/assets/{backups-section-BhQu2E4b.js → backups-section-Ws7lEoW8.js} +1 -1
- package/dist/ui/assets/cliproxy-DZi4XuZf.js +3 -0
- package/dist/ui/assets/{cliproxy-control-panel-CzEcwQpU.js → cliproxy-control-panel-BZra72Ny.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-DXOlh68I.js → confirm-dialog-DxQPPkSd.js} +1 -1
- package/dist/ui/assets/{copilot-B40z4Wb2.js → copilot-CmwCzzD4.js} +3 -3
- package/dist/ui/assets/{globalenv-section-DM5NsLUS.js → globalenv-section-DV4fwOAk.js} +1 -1
- package/dist/ui/assets/{health-BV9rZ_Ya.js → health-BKZFx-kN.js} +1 -1
- package/dist/ui/assets/{index-DANNDDO3.js → index-4s6OG891.js} +1 -1
- package/dist/ui/assets/{index-BKqrprbn.js → index-BV2Az_iT.js} +1 -1
- package/dist/ui/assets/index-DqGEeXwx.js +1 -0
- package/dist/ui/assets/{index-D7Pl56Ob.js → index-Z-6Jxa1d.js} +10 -10
- package/dist/ui/assets/{index-BtaYToht.js → index-bta-rhbN.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-P-1knrgv.js → proxy-status-widget-Cc5eGBNW.js} +1 -1
- package/dist/ui/assets/{shared-DG32MUkN.js → shared-C6jB88nc.js} +1 -1
- package/dist/ui/assets/{switch-D0G-SCdh.js → switch-Cjeoav0D.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/web-server/routes/account-routes.d.ts.map +1 -1
- package/dist/web-server/routes/account-routes.js +3 -10
- package/dist/web-server/routes/account-routes.js.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.js +5 -10
- package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
- package/dist/web-server/routes/cliproxy-stats-routes.d.ts.map +1 -1
- package/dist/web-server/routes/cliproxy-stats-routes.js +3 -10
- package/dist/web-server/routes/cliproxy-stats-routes.js.map +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/cliproxy-DYjT8MVB.js +0 -3
- package/dist/ui/assets/index-DRPh4nzV.js +0 -1
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{j as e,$ as vs,a0 as Ns}from"./radix-ui-qEZD5MMp.js";import{r as m}from"./react-vendor-CNOkPC89.js";import{a as Ke,u as ze,b as ws}from"./tanstack-De4wvi8X.js";import{b as w,C as Be,a as $e,c as _,P as ie,L as re,I as ge,X as qe,Y as Ve,Z as Qe,_ as Je,$ as me,a0 as We,a1 as bs,a2 as Ye,a3 as Xe,u as Ze,a4 as fe,a5 as je,a6 as ve,a7 as Ne,a8 as es,a9 as ys,aa as _e,ab as Ee,B as K,ac as Cs,q as ss,m as we,l as ks,ad as Ss,ae as As,af as Ps,ag as X,T as Z,o as ee,p as se,ah as Ms,ai as Os,aj as Ts,ak as Re,al as Ds,am as Is,an as _s,ao as Es,ap as ce,aq as Rs,ar as Ls,as as Fs,at as Hs,H as Us,J as Gs,K as Le,M as Fe,au as Ks,av as zs,aw as Bs,ax as $s,ay as qs,az as Vs,aA as Qs,aB as Js,aC as Ws,aD as Ys,aE as Xs,S as Zs}from"./index-D7Pl56Ob.js";import{t as B}from"./notifications-B2HqRBj7.js";import{b as ts,L as $,m as be,x as et,j as q,l as st,an as ye,a6 as Ce,n as W,$ as ae,ao as tt,ap as oe,Z as le,I as at,f as nt,a1 as as,aq as it,ah as rt,X as ke,_ as ns,s as is,t as xe,ar as ot,T as lt,u as de,as as ct,ag as rs,p as dt,at as ut,a0 as mt,ak as xt,au as os}from"./icons-C6UNjkCT.js";import{S as Se,C as pt}from"./confirm-dialog-DXOlh68I.js";import{S as ht}from"./switch-D0G-SCdh.js";import{P as gt}from"./proxy-status-widget-P-1knrgv.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-Bn6K2nsn.js";const te={agy:{provider:"agy",displayName:"Antigravity",defaultModel:"gemini-claude-opus-4-5-thinking",models:[{id:"gemini-claude-opus-4-5-thinking",name:"Claude Opus 4.5 Thinking",description:"Most capable, extended thinking",presetMapping:{default:"gemini-claude-opus-4-5-thinking",opus:"gemini-claude-opus-4-5-thinking",sonnet:"gemini-claude-sonnet-4-5-thinking",haiku:"gemini-claude-sonnet-4-5"}},{id:"gemini-claude-sonnet-4-5-thinking",name:"Claude Sonnet 4.5 Thinking",description:"Balanced with extended thinking",presetMapping:{default:"gemini-claude-sonnet-4-5-thinking",opus:"gemini-claude-opus-4-5-thinking",sonnet:"gemini-claude-sonnet-4-5-thinking",haiku:"gemini-claude-sonnet-4-5"}},{id:"gemini-claude-sonnet-4-5",name:"Claude Sonnet 4.5",description:"Fast and capable",presetMapping:{default:"gemini-claude-sonnet-4-5",opus:"gemini-claude-opus-4-5-thinking",sonnet:"gemini-claude-sonnet-4-5",haiku:"gemini-claude-sonnet-4-5"}},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",description:"Google latest model via Antigravity",presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",description:"Fast Gemini model via Antigravity",presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}}]},gemini:{provider:"gemini",displayName:"Gemini",defaultModel:"gemini-2.5-pro",models:[{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",tier:"paid",description:"Latest model, requires paid Google account",presetMapping:{default:"gemini-3-pro-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash",tier:"paid",description:"Fast Gemini 3 model, requires paid Google account",presetMapping:{default:"gemini-3-flash-preview",opus:"gemini-3-pro-preview",sonnet:"gemini-3-pro-preview",haiku:"gemini-3-flash-preview"}},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account",presetMapping:{default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-2.5-flash"}}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5.2-codex",models:[{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Full reasoning support (xhigh)",presetMapping:{default:"gpt-5.2-codex",opus:"gpt-5.2-codex",sonnet:"gpt-5.2-codex",haiku:"gpt-5-mini"}},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"Fast, capped at high reasoning (no xhigh)",presetMapping:{default:"gpt-5-mini",opus:"gpt-5.2-codex",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"}},{id:"gpt-5.1-codex-max",name:"Codex Max (5.1)",description:"Legacy most capable Codex model",presetMapping:{default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max-high",sonnet:"gpt-5.1-codex-max",haiku:"gpt-5.1-codex-mini-high"}},{id:"gpt-5.2",name:"GPT 5.2",description:"Latest GPT model",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.2",haiku:"gpt-5.2"}},{id:"gpt-5.1-codex-mini",name:"Codex Mini",description:"Fast and efficient Codex model"}]},qwen:{provider:"qwen",displayName:"Qwen",defaultModel:"qwen-coder-plus",models:[{id:"qwen-coder-plus",name:"Qwen Coder Plus",description:"Alibaba code-focused model"},{id:"qwen-max",name:"Qwen Max",description:"Most capable Qwen model"}]},iflow:{provider:"iflow",displayName:"iFlow",defaultModel:"iflow-default",models:[{id:"iflow-default",name:"iFlow Default",description:"Default iFlow model"}]},kiro:{provider:"kiro",displayName:"Kiro (AWS)",defaultModel:"kiro-claude-sonnet-4-5",models:[{id:"kiro-claude-opus-4-5",name:"Kiro Claude Opus 4.5",description:"Claude Opus 4.5 via Kiro (2.2x credit)",presetMapping:{default:"kiro-claude-opus-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4-5",name:"Kiro Claude Sonnet 4.5",description:"Claude Sonnet 4.5 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4-5",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4-5",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-sonnet-4",name:"Kiro Claude Sonnet 4",description:"Claude Sonnet 4 via Kiro (1.3x credit)",presetMapping:{default:"kiro-claude-sonnet-4",opus:"kiro-claude-opus-4-5",sonnet:"kiro-claude-sonnet-4",haiku:"kiro-claude-haiku-4-5"}},{id:"kiro-claude-haiku-4-5",name:"Kiro Claude Haiku 4.5",description:"Claude Haiku 4.5 via Kiro (0.4x credit)"}]},ghcp:{provider:"ghcp",displayName:"GitHub Copilot (OAuth)",defaultModel:"claude-sonnet-4.5",models:[{id:"claude-opus-4.5",name:"Claude Opus 4.5",description:"Anthropic Claude Opus 4.5 via GitHub Copilot",presetMapping:{default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4.5",name:"Claude Sonnet 4.5",description:"Anthropic Claude Sonnet 4.5 via GitHub Copilot",presetMapping:{default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"}},{id:"claude-sonnet-4",name:"Claude Sonnet 4",description:"Anthropic Claude Sonnet 4 via GitHub Copilot"},{id:"claude-haiku-4.5",name:"Claude Haiku 4.5",description:"Anthropic Claude Haiku 4.5 via GitHub Copilot"},{id:"gpt-5.2",name:"GPT-5.2",description:"OpenAI GPT-5.2 via GitHub Copilot",presetMapping:{default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"}},{id:"gpt-5.1",name:"GPT-5.1",description:"OpenAI GPT-5.1 via GitHub Copilot"},{id:"gpt-5",name:"GPT-5",description:"OpenAI GPT-5 via GitHub Copilot"},{id:"gpt-5-mini",name:"GPT-5 Mini",description:"OpenAI GPT-5 Mini via GitHub Copilot"},{id:"gemini-3-pro",name:"Gemini 3 Pro",description:"Google Gemini 3 Pro via GitHub Copilot"}]},claude:{provider:"claude",displayName:"Claude (Anthropic)",defaultModel:"claude-sonnet-4-5-20250514",models:[{id:"claude-opus-4-5-20250220",name:"Claude Opus 4.5",description:"Most capable Claude model",presetMapping:{default:"claude-opus-4-5-20250220",opus:"claude-opus-4-5-20250220",sonnet:"claude-sonnet-4-5-20250514",haiku:"claude-haiku-4-5-20250514"}},{id:"claude-sonnet-4-5-20250514",name:"Claude Sonnet 4.5",description:"Balanced performance and speed",presetMapping:{default:"claude-sonnet-4-5-20250514",opus:"claude-opus-4-5-20250220",sonnet:"claude-sonnet-4-5-20250514",haiku:"claude-haiku-4-5-20250514"}},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",description:"Previous generation Sonnet",presetMapping:{default:"claude-sonnet-4-20250514",opus:"claude-opus-4-5-20250220",sonnet:"claude-sonnet-4-20250514",haiku:"claude-haiku-4-5-20250514"}},{id:"claude-haiku-4-5-20250514",name:"Claude Haiku 4.5",description:"Fast and efficient"}]}},pe=8317,ue="ccs-internal-managed";async function ft(){try{const s=await fetch("/api/settings/auth/tokens/raw");return s.ok?(await s.json())?.apiKey?.value??ue:ue}catch{return ue}}async function he(s,a){const t=te[s];if(!t)return{success:!1};const r=t.models[0],i=r?.presetMapping||{default:t.defaultModel,opus:t.defaultModel,sonnet:t.defaultModel,haiku:t.defaultModel},c=await ft(),u={env:{ANTHROPIC_BASE_URL:`http://127.0.0.1:${pe}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:c,ANTHROPIC_MODEL:i.default,ANTHROPIC_DEFAULT_OPUS_MODEL:i.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:i.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:i.haiku}};try{return{success:(await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:u})})).ok,presetName:r?.name||t.defaultModel}}catch{return{success:!1}}}const He=[{id:"agy",name:"Antigravity",description:"Antigravity AI models"},{id:"claude",name:"Claude (Anthropic)",description:"Claude Opus/Sonnet models"},{id:"gemini",name:"Google Gemini",description:"Gemini Pro/Flash models"},{id:"codex",name:"OpenAI Codex",description:"GPT-4 and codex models"},{id:"qwen",name:"Alibaba Qwen",description:"Qwen Code models"},{id:"iflow",name:"iFlow",description:"iFlow AI models"},{id:"kiro",name:"Kiro (AWS)",description:"AWS CodeWhisperer models"},{id:"ghcp",name:"GitHub Copilot (OAuth)",description:"GitHub Copilot via OAuth"}],ls=["provider","auth","variant","success"];function jt(s){return s==="account"?1:ls.indexOf(s)}function vt({currentProgress:s,allSteps:a}){return e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:a.map((t,r)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${s>=r?"bg-primary":"bg-muted"}`},t))})}function Nt({providers:s,onSelect:a}){return e.jsx("div",{className:"grid gap-2",children:s.map(t=>e.jsxs("button",{onClick:()=>a(t.id),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:t.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:t.description})]}),e.jsx(ts,{className:"w-4 h-4 text-muted-foreground"})]},t.id))})}function wt({selectedProvider:s,providers:a,authCommand:t,isRefreshing:r,isPending:i,onBack:c,onStartAuth:l,onRefresh:u}){const[o,x]=m.useState(!1),g=async h=>{await navigator.clipboard.writeText(h),x(!0),setTimeout(()=>x(!1),2e3)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Authenticate with ",a.find(h=>h.id===s)?.name," to add an account"]}),e.jsx(w,{onClick:l,disabled:i,className:"w-full gap-2",size:"lg",children:i?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(be,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),i&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or use terminal"})})]}),e.jsx(Be,{children:e.jsxs($e,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(et,{className:"w-4 h-4"}),"Run this command in your terminal:"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"flex-1 px-3 py-2 bg-muted rounded-md font-mono text-sm",children:t}),e.jsx(w,{variant:"outline",size:"icon",onClick:()=>g(t),children:o?e.jsx(q,{className:"w-4 h-4 text-green-500"}):e.jsx(st,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(w,{variant:"ghost",onClick:c,disabled:i,children:[e.jsx(ye,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(w,{variant:"outline",onClick:u,disabled:r||i,children:[e.jsx(Ce,{className:`w-4 h-4 mr-2 ${r?"animate-spin":""}`}),r?"Checking...":"Refresh Status"]})]})]})}function bt({accounts:s,privacyMode:a,onSelect:t,onAddNew:r,onBack:i}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:["Select an account (",s.length,")"]}),e.jsx("div",{className:"grid gap-2",children:s.map(c=>e.jsxs("button",{type:"button",onClick:()=>t(c),className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-muted flex items-center justify-center",children:e.jsx(W,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:_("font-medium",a&&ie),children:c.email||c.id}),c.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(ts,{className:"w-4 h-4 text-muted-foreground"})]},c.id))}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-2 text-muted-foreground",children:"Or"})})]}),e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 p-3 border-2 border-dashed border-primary/50 rounded-lg hover:border-primary hover:bg-primary/5 transition-colors text-left",onClick:r,children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(be,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-primary",children:"Add new account"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Authenticate with a different account"})]})]}),e.jsx("div",{className:"flex items-center justify-between pt-2",children:e.jsxs(w,{variant:"ghost",onClick:i,children:[e.jsx(ye,{className:"w-4 h-4 mr-2"}),"Back"]})})]})}function yt({selectedProvider:s,selectedAccount:a,variantName:t,modelName:r,isPending:i,privacyMode:c,onVariantNameChange:l,onModelChange:u,onBack:o,onSkip:x,onCreate:g}){return e.jsxs("div",{className:"space-y-4",children:[a&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(W,{className:"w-4 h-4"}),e.jsxs("span",{children:["Using:"," ",e.jsx("span",{className:_(c&&ie),children:a.email||a.id})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{htmlFor:"variant-name",children:"Variant Name *"}),e.jsx(ge,{id:"variant-name",value:t,onChange:h=>l(h.target.value),placeholder:"e.g., my-gemini, g3, flash"}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Use this name to invoke: ccs ",t||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{children:"Model"}),e.jsxs(qe,{value:r,onValueChange:u,children:[e.jsx(Ve,{children:e.jsx(Qe,{placeholder:"Select a model"})}),e.jsx(Je,{children:te[s]?.models.map(h=>e.jsx(me,{value:h.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:h.name}),h.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",h.description]})]})},h.id))})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Default: ",te[s]?.defaultModel||"provider default"]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(w,{variant:"ghost",onClick:o,children:[e.jsx(ye,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"ghost",onClick:x,children:"Skip"}),e.jsx(w,{onClick:g,disabled:!t||i,children:i?"Creating...":"Create Variant"})]})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Skip if you just wanted to add an account without creating a variant"})]})}function Ct({variantName:s,onClose:a}){return e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("div",{className:"w-16 h-16 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center",children:e.jsx(q,{className:"w-8 h-8 text-green-600 dark:text-green-400"})})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-lg",children:"Variant Created!"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Your custom variant is ready to use"})]}),e.jsx(Be,{children:e.jsxs($e,{className:"p-4 space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Usage:"}),e.jsxs("code",{className:"block px-3 py-2 bg-muted rounded-md font-mono text-sm",children:["ccs ",s,' "your prompt here"']})]})}),e.jsx(w,{onClick:a,className:"w-full",children:"Done"})]})}function kt({open:s,onClose:a}){const[t,r]=m.useState("provider"),[i,c]=m.useState(""),[l,u]=m.useState(null),[o,x]=m.useState(""),[g,h]=m.useState(""),[p,d]=m.useState(!1),[C,E]=m.useState(!1),{data:j,refetch:D}=We(),L=bs(),T=Ye(),M=Xe(),{privacyMode:O}=Ze(),f=j?.authStatus.find(y=>y.provider===i),P=m.useMemo(()=>f?.accounts||[],[f?.accounts]);m.useEffect(()=>{if(!s){const y=setTimeout(()=>{r("provider"),c(""),u(null),x(""),h(""),E(!1)},0);return()=>clearTimeout(y)}},[s]),m.useEffect(()=>{if(t==="auth"&&P.length>0&&!C){const y=setTimeout(()=>{r("account")},0);return()=>clearTimeout(y)}},[t,P,C]);const v=async()=>{d(!0),await D(),d(!1)},k=()=>{const y=(f?.accounts?.length||0)===0;T.mutate({provider:i},{onSuccess:async N=>{if(y){const I=await he(i);I.success&&I.presetName?B.success(`Applied "${I.presetName}" preset`):I.success||B.warning("Account added, but failed to apply default preset")}N.account&&(u(N.account),r("variant")),D()}})},R=y=>{c(y),(j?.authStatus.find(G=>G.provider===y)?.accounts||[]).length===0?r("auth"):r("account")},S=y=>{u(y),r("variant")},b=async()=>{if(!(!o||!i))try{await L.mutateAsync({name:o,provider:i,model:g||void 0,account:l?.id}),r("success")}catch(y){console.error("Failed to create variant:",y)}},F=`ccs ${i} --auth --add`,U=jt(t),z=y=>{if(!y&&(T.isPending&&i&&M.mutate(i),t==="success"||t==="provider")){a();return}};return e.jsx(fe,{open:s,onOpenChange:z,children:e.jsxs(je,{className:"sm:max-w-lg",onPointerDownOutside:y=>{t!=="success"&&t!=="provider"&&y.preventDefault()},onEscapeKeyDown:y=>{(T.isPending||L.isPending)&&y.preventDefault()},children:[e.jsxs(ve,{children:[e.jsxs(Ne,{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(es,{children:[t==="provider"&&"Select a provider to get started",t==="auth"&&"Authenticate with your provider",t==="account"&&"Select which account to use",t==="variant"&&"Create your custom variant",t==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[t==="provider"&&e.jsx(Nt,{providers:He,onSelect:R}),t==="auth"&&e.jsx(wt,{selectedProvider:i,providers:He,authCommand:F,isRefreshing:p,isPending:T.isPending,onBack:()=>r("provider"),onStartAuth:k,onRefresh:v}),t==="account"&&e.jsx(bt,{accounts:P,privacyMode:O,onSelect:S,onAddNew:()=>{E(!0),r("auth")},onBack:()=>r("provider")}),t==="variant"&&e.jsx(yt,{selectedProvider:i,selectedAccount:l,variantName:o,modelName:g,isPending:L.isPending,privacyMode:O,onVariantNameChange:x,onModelChange:h,onBack:()=>P.length>0?r("account"):r("provider"),onSkip:a,onCreate:b}),t==="success"&&e.jsx(Ct,{variantName:o,onClose:a})]}),e.jsx(vt,{currentProgress:U,allSteps:ls})]})})}function St({open:s,onClose:a,provider:t,displayName:r,isFirstAccount:i=!1}){const[c,l]=m.useState(""),u=Ye(),o=ys(),x=Xe(),g=t==="kiro",h=u.isPending||o.isPending,p=()=>{h&&x.mutate(t),l(""),a()},d=()=>{u.mutate({provider:t,nickname:c.trim()||void 0},{onSuccess:async()=>{const j=await he(t);j.success&&j.presetName?i&&B.success(`Applied "${j.presetName}" preset`):j.success||B.warning("Account added, but failed to apply default preset. You may need to configure settings manually."),l(""),a()}})},C=()=>{o.mutate(void 0,{onSuccess:async()=>{const j=await he("kiro");j.success&&j.presetName&&i&&B.success(`Applied "${j.presetName}" preset`),l(""),a()}})},E=j=>{j||p()};return e.jsx(fe,{open:s,onOpenChange:E,children:e.jsxs(je,{className:"sm:max-w-md",children:[e.jsxs(ve,{children:[e.jsxs(Ne,{children:["Add ",r," Account"]}),e.jsx(es,{children:g?"Authenticate via browser or import an existing token from Kiro IDE.":"Click the button below to authenticate a new account. A browser window will open for OAuth."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{htmlFor:"nickname",children:"Nickname (optional)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ge,{id:"nickname",value:c,onChange:j=>l(j.target.value),placeholder:"e.g., work, personal",disabled:h,className:"flex-1"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"A friendly name to identify this account. Auto-generated from email if left empty."})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(w,{variant:"ghost",onClick:p,children:"Cancel"}),g&&e.jsx(w,{variant:"outline",onClick:C,disabled:h,children:o.isPending?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-4 h-4 mr-2 animate-spin"}),"Importing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(tt,{className:"w-4 h-4 mr-2"}),"Import from IDE"]})}),e.jsx(w,{onClick:d,disabled:h,children:u.isPending?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-4 h-4 mr-2 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(be,{className:"w-4 h-4 mr-2"}),"Authenticate"]})})]}),u.isPending&&e.jsx("p",{className:"text-sm text-center text-muted-foreground",children:"Complete the OAuth flow in your browser..."}),o.isPending&&e.jsx("p",{className:"text-sm text-center text-muted-foreground",children:"Importing token from Kiro IDE..."})]})]})})}const At=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function Pt(s){const a=s?.env||{};return At.filter(t=>!a[t]?.trim())}function Mt(s){const[a,t]=m.useState(null),[r,i]=m.useState(!1),c=Ke(),{data:l,isLoading:u,refetch:o}=ze({queryKey:["settings",s],queryFn:async()=>{const v=await fetch(`/api/settings/${s}/raw`);return v.ok?v.json():{profile:s,settings:{env:{}},mtime:Date.now(),path:`~/.ccs/profiles/${s}/settings.json`}}}),x=l?.settings,g=m.useMemo(()=>a!==null?a:x?JSON.stringify(x,null,2):`{
|
|
2
|
-
"env": {}
|
|
3
|
-
}`,[a,x]),h=m.useCallback(v=>{t(v)},[]),p=m.useMemo(()=>{try{return JSON.parse(g)}catch{return x||{env:{}}}},[g,x]),d=p?.env?.ANTHROPIC_MODEL,C=p?.env?.ANTHROPIC_DEFAULT_OPUS_MODEL,E=p?.env?.ANTHROPIC_DEFAULT_SONNET_MODEL,j=p?.env?.ANTHROPIC_DEFAULT_HAIKU_MODEL,D=m.useCallback((v,k)=>{const R={...p?.env||{},[v]:k},S={...p,env:R};t(JSON.stringify(S,null,2))},[p]),L=m.useCallback(v=>{const k={...p?.env||{},...v},R={...p,env:k};t(JSON.stringify(R,null,2))},[p]),T=m.useMemo(()=>{try{return JSON.parse(g),!0}catch{return!1}},[g]),M=m.useMemo(()=>a===null?!1:a!==JSON.stringify(x,null,2),[a,x]),O=m.useMemo(()=>Pt(p),[p]),f=ws({mutationFn:async()=>{const v=JSON.parse(g),k=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:v,expectedMtime:l?.mtime})});if(k.status===409)throw new Error("CONFLICT");if(!k.ok)throw new Error("Failed to save");return k.json()},onSuccess:v=>{c.invalidateQueries({queryKey:["settings",s]}),t(null),v?.warning?B.success("Settings saved",{description:v.warning}):B.success("Settings saved")},onError:v=>{v.message==="CONFLICT"?i(!0):B.error(v.message)}}),P=async v=>{i(!1),v?(await o(),f.mutate()):t(null)};return{data:l,isLoading:u,refetch:o,rawJsonContent:g,rawJsonEdits:a,isRawJsonValid:T,hasChanges:M,currentSettings:p,currentModel:d,opusModel:C,sonnetModel:E,haikuModel:j,handleRawJsonChange:h,updateEnvValue:D,updateEnvValues:L,saveMutation:{mutate:()=>f.mutate(),isPending:f.isPending},conflictDialog:r,setConflictDialog:i,handleConflictResolve:P,missingRequiredFields:O}}function Q({label:s,description:a,value:t,onChange:r,catalog:i,allModels:c,disabled:l}){const u=new Set(i?.models.map(o=>o.id)||[]);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:s}),a&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:a})]}),e.jsxs(qe,{value:t||"",onValueChange:r,disabled:l,children:[e.jsx(Ve,{className:"h-9",children:e.jsx(Qe,{placeholder:"Select model",children:t&&e.jsx("span",{className:"truncate font-mono text-xs",children:t})})}),e.jsxs(Je,{className:"max-h-[300px]",children:[i&&i.models.length>0&&e.jsxs(_e,{children:[e.jsx(Ee,{className:"text-xs text-primary",children:"Recommended"}),i.models.map(o=>e.jsx(me,{value:o.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:o.id}),o.tier==="paid"&&e.jsx(K,{variant:"outline",className:"text-[9px] h-4 px-1",children:"PAID"}),t===o.id&&e.jsx(q,{className:"w-3 h-3 text-primary ml-auto"})]})},o.id))]}),c.length>0&&e.jsxs(_e,{children:[e.jsxs(Ee,{className:"text-xs text-muted-foreground",children:["All Models (",c.length,")"]}),c.filter(o=>!u.has(o.id)).map(o=>e.jsx(me,{value:o.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:o.id}),t===o.id&&e.jsx(q,{className:"w-3 h-3 text-primary ml-auto"})]})},o.id))]}),(!i||i.models.length===0)&&c.length===0&&e.jsx("div",{className:"py-2 px-3 text-xs text-muted-foreground",children:"No models available"})]})]})]})}function Ot({open:s,onClose:a,currentValues:t,onApply:r,onSave:i,isSaving:c,catalog:l,allModels:u}){const[o,x]=m.useState(t),[g,h]=m.useState(""),p=d=>{d?(x(t),h("")):a()};return e.jsx(fe,{open:s,onOpenChange:p,children:e.jsxs(je,{className:"sm:max-w-md",children:[e.jsx(ve,{children:e.jsxs(Ne,{className:"flex items-center gap-2",children:[e.jsx(ae,{className:"w-4 h-4"}),"Custom Preset"]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(re,{htmlFor:"preset-name",children:"Preset Name (optional)"}),e.jsx(ge,{id:"preset-name",value:g,onChange:d=>h(d.target.value),placeholder:"e.g., My Custom Config",className:"text-sm"})]}),e.jsx(Se,{}),e.jsx(Q,{label:"Default Model",description:"Used when no specific tier is requested",value:o.default,onChange:d=>x({...o,default:d}),catalog:l,allModels:u}),e.jsx(Q,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:o.opus,onChange:d=>x({...o,opus:d}),catalog:l,allModels:u}),e.jsx(Q,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:o.sonnet,onChange:d=>x({...o,sonnet:d}),catalog:l,allModels:u}),e.jsx(Q,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:o.haiku,onChange:d=>x({...o,haiku:d}),catalog:l,allModels:u})]}),e.jsxs(Cs,{className:"gap-2 sm:gap-0",children:[e.jsx(w,{variant:"outline",onClick:a,children:"Cancel"}),i&&e.jsxs(w,{variant:"secondary",onClick:()=>i(o,g||void 0),disabled:c||!g.trim(),children:[c?e.jsx($,{className:"w-4 h-4 mr-1 animate-spin"}):e.jsx(oe,{className:"w-4 h-4 mr-1"}),"Save Preset"]}),e.jsxs(w,{onClick:()=>r(o,g||void 0),children:[e.jsx(le,{className:"w-4 h-4 mr-1"}),"Apply Preset"]})]})]})})}function ne({label:s,command:a}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:s}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:a}),e.jsx(ss,{value:a,size:"icon",className:"h-6 w-6"})]})]})}function Tt({provider:s,displayName:a,data:t,authStatus:r}){return e.jsx(we,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(at,{className:"w-4 h-4"}),"Provider Information"]}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Provider"}),e.jsx("span",{className:"font-mono",children:a})]}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"File Path"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:t.path}),e.jsx(ss,{value:t.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Last Modified"}),e.jsx("span",{className:"text-xs",children:new Date(t.mtime).toLocaleString()})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Status"}),r.authenticated?e.jsxs(K,{variant:"outline",className:"w-fit text-green-600 border-green-200 bg-green-50",children:[e.jsx(nt,{className:"w-3 h-3 mr-1"}),"Authenticated"]}):e.jsx(K,{variant:"outline",className:"w-fit text-muted-foreground",children:"Not connected"})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:"Quick Usage"}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsx(ne,{label:"Run with prompt",command:`ccs ${s} "your prompt"`}),e.jsx(ne,{label:"Change model",command:`ccs ${s} --config`}),e.jsx(ne,{label:"Add account",command:`ccs ${s} --add`}),e.jsx(ne,{label:"List accounts",command:`ccs ${s} --accounts`})]})]})]})})}const Dt={gemini:"/assets/providers/gemini-color.svg",codex:"/assets/providers/openai.svg",agy:"/assets/providers/agy.png",qwen:"/assets/providers/qwen-color.svg",iflow:"/assets/providers/iflow.png",kiro:"/assets/providers/kiro.png",ghcp:"/assets/providers/copilot.svg",claude:"/assets/providers/claude.svg"},It={gemini:{text:"text-blue-600",letter:"G"},claude:{text:"text-orange-600",letter:"C"},codex:{text:"text-emerald-600",letter:"X"},agy:{text:"text-violet-600",letter:"A"},qwen:{text:"text-cyan-600",letter:"Q"},iflow:{text:"text-indigo-600",letter:"i"},kiro:{text:"text-teal-600",letter:"K"},ghcp:{text:"text-green-600",letter:"C"}},_t={sm:{container:"w-6 h-6",icon:"w-4 h-4",text:"text-xs"},md:{container:"w-8 h-8",icon:"w-5 h-5",text:"text-sm"},lg:{container:"w-12 h-12",icon:"w-8 h-8",text:"text-lg"}};function Ae({provider:s,className:a,size:t="md"}){const r=s.toLowerCase(),i=It[r]||{text:"text-gray-600",letter:s[0]?.toUpperCase()||"?"},c=_t[t],l=Dt[r];return e.jsx("div",{className:_("flex items-center justify-center rounded-md",l&&"bg-white p-1",c.container,a),children:l?e.jsx("img",{src:l,alt:`${s} logo`,className:_(c.icon,"object-contain")}):e.jsx("span",{className:_("font-semibold",i.text,c.text),children:i.letter})})}function Et({displayName:s,logoProvider:a,provider:t,data:r,isLoading:i,hasChanges:c,isRawJsonValid:l,isSaving:u,isRemoteMode:o,port:x,onRefetch:g,onSave:h}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ae,{provider:a||t,size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),o&&e.jsxs(K,{variant:"secondary",className:"text-xs gap-1 bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:[e.jsx(as,{className:"w-3 h-3"}),"Remote"]}),x&&e.jsxs(K,{variant:"outline",className:"text-xs gap-1 font-mono",children:[e.jsx(it,{className:"w-3 h-3"}),":",x]}),!o&&r?.path&&e.jsx(K,{variant:"outline",className:"text-xs",children:r.path.replace(/^.*[\\/]/,"")})]}),o?e.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-400 mt-0.5",children:"Traffic auto-routed to remote server"}):r&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(r.mtime).toLocaleString()]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"ghost",size:"sm",onClick:g,disabled:i,children:e.jsx(Ce,{className:`w-4 h-4 ${i?"animate-spin":""}`})}),e.jsx(w,{size:"sm",onClick:h,disabled:u||!c||!l,children:u?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(rt,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function Rt({catalog:s,savedPresets:a,currentModel:t,opusModel:r,sonnetModel:i,haikuModel:c,providerModels:l,onApplyPreset:u,onUpdateEnvValue:o,onOpenCustomPreset:x,onDeletePreset:g,isDeletePending:h}){const p=s&&s.models.length>0||a.length>0;return e.jsxs(e.Fragment,{children:[p&&e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[e.jsx(ae,{className:"w-4 h-4"}),"Presets"]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"Apply pre-configured model mappings"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[s?.models.slice(0,4).map(d=>e.jsxs(w,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>{const C=d.presetMapping||{default:d.id,opus:d.id,sonnet:d.id,haiku:d.id};u({ANTHROPIC_MODEL:C.default,ANTHROPIC_DEFAULT_OPUS_MODEL:C.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:C.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:C.haiku})},children:[e.jsx(le,{className:"w-3 h-3"}),d.name]},d.id)),a.map(d=>e.jsxs("div",{className:"group relative",children:[e.jsxs(w,{variant:"secondary",size:"sm",className:"text-xs h-7 gap-1 pr-6",onClick:()=>{u({ANTHROPIC_MODEL:d.default,ANTHROPIC_DEFAULT_OPUS_MODEL:d.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:d.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:d.haiku})},children:[e.jsx(oe,{className:"w-3 h-3 fill-current"}),d.name]}),e.jsx(w,{variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-7 w-5 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:C=>{C.stopPropagation(),g(d.name)},disabled:h,children:e.jsx(ke,{className:"w-3 h-3"})})]},d.name)),e.jsxs(w,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1 border-primary/50 text-primary hover:bg-primary/10 hover:border-primary",onClick:x,children:[e.jsx(ns,{className:"w-3 h-3"}),"Custom"]})]})]}),e.jsx(Se,{}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-2",children:"Model Mapping"}),e.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Configure which models to use for each tier"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(Q,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:d=>o("ANTHROPIC_MODEL",d),catalog:s,allModels:l}),e.jsx(Q,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:r,onChange:d=>o("ANTHROPIC_DEFAULT_OPUS_MODEL",d),catalog:s,allModels:l}),e.jsx(Q,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:i,onChange:d=>o("ANTHROPIC_DEFAULT_SONNET_MODEL",d),catalog:s,allModels:l}),e.jsx(Q,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:c,onChange:d=>o("ANTHROPIC_DEFAULT_HAIKU_MODEL",d),catalog:s,allModels:l})]})]})]})}function Lt({className:s,...a}){return e.jsx(vs,{"data-slot":"checkbox",className:_("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",s),...a,children:e.jsx(Ns,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:e.jsx(q,{className:"size-3.5"})})})}function Ft(s){const a=Math.max(0,Math.min(100,s));return a<=20?"bg-destructive":a<=50?"bg-yellow-500":"bg-green-500"}function Ue(s){if(!s)return"";try{const a=new Date(s),r=new Date().getTime()-a.getTime();if(r<0)return"just now";const i=Math.floor(r/(1e3*60)),c=Math.floor(r/(1e3*60*60)),l=Math.floor(r/(1e3*60*60*24));return l>0?`${l}d ago`:c>0?`${c}h ago`:i>0?`${i}m ago`:"just now"}catch{return""}}function Ht(s){if(!s)return!1;try{const a=new Date(s);return new Date().getTime()-a.getTime()<3600*1e3}catch{return!1}}function Ut({account:s,onSetDefault:a,onRemove:t,onPauseToggle:r,isRemoving:i,isPausingAccount:c,privacyMode:l,showQuota:u,selectable:o,selected:x,onSelectChange:g}){const{data:h}=ks(u),{data:p,isLoading:d}=Ss(s.provider,s.id,u),C=h?.accountStats?.[s.email||s.id]?.lastUsedAt,E=Ht(C),j=p?.success?As(p.models):null,D=p?.success&&p.models.length>0?Ps(p.models):null;return e.jsxs("div",{className:_("flex flex-col gap-2 p-3 rounded-lg border transition-colors",s.isDefault?"border-primary/30 bg-primary/5":"border-border hover:bg-muted/30",s.paused&&"opacity-75",x&&"ring-2 ring-primary/50 bg-primary/5"),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[o&&e.jsx("button",{type:"button",onClick:()=>g?.(!x),className:_("flex items-center justify-center w-5 h-5 rounded border-2 transition-colors shrink-0",x?"bg-primary border-primary text-primary-foreground":"border-muted-foreground/30 hover:border-primary/50"),"aria-label":x?"Deselect account":"Select account",children:x&&e.jsx(q,{className:"w-3 h-3"})}),r&&e.jsx(X,{children:e.jsxs(Z,{children:[e.jsx(ee,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:()=>r(!s.paused),disabled:c,children:c?e.jsx($,{className:"w-4 h-4 animate-spin"}):s.paused?e.jsx(is,{className:"w-4 h-4 text-emerald-500"}):e.jsx(xe,{className:"w-4 h-4 text-muted-foreground hover:text-foreground"})})}),e.jsx(se,{side:"top",children:s.paused?"Resume account":"Pause account"})]})}),e.jsx("div",{className:_("flex items-center justify-center w-8 h-8 rounded-full",s.isDefault?"bg-primary/10":"bg-muted"),children:e.jsx(W,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:_("font-medium text-sm",l&&ie),children:s.email||s.id}),s.isDefault&&e.jsxs(K,{variant:"secondary",className:"text-[10px] h-4 px-1.5 gap-0.5",children:[e.jsx(oe,{className:"w-2.5 h-2.5 fill-current"}),"Default"]}),s.tier&&s.tier!=="unknown"&&e.jsx(K,{variant:"outline",className:_("text-[10px] h-4 px-1.5 uppercase",s.tier==="paid"&&"border-blue-500 text-blue-600",s.tier==="free"&&"border-gray-400 text-gray-500"),children:s.tier}),s.paused&&e.jsxs(K,{variant:"outline",className:"text-[10px] h-4 px-1.5 border-yellow-500 text-yellow-600",children:[e.jsx(xe,{className:"w-2 h-2 mr-0.5"}),"Paused"]})]}),s.provider==="agy"&&e.jsx("div",{className:"flex items-center gap-1.5 mt-1",children:s.projectId?e.jsx(X,{children:e.jsxs(Z,{children:[e.jsx(ee,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(ot,{className:"w-3 h-3","aria-hidden":"true"}),e.jsx("span",{className:_("font-mono max-w-[180px] truncate",l&&ie),title:s.projectId,children:s.projectId})]})}),e.jsx(se,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:"GCP Project ID (read-only)"})})]})}):e.jsx(X,{children:e.jsxs(Z,{children:[e.jsx(ee,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600 dark:text-amber-500",children:[e.jsx(lt,{className:"w-3 h-3","aria-label":"Warning"}),e.jsx("span",{children:"Project ID: N/A"})]})}),e.jsx(se,{side:"bottom",className:"max-w-[250px]",children:e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsx("p",{className:"font-medium text-amber-600",children:"Missing Project ID"}),e.jsx("p",{children:"This may cause errors. Remove the account and re-add it to fetch the project ID."})]})})]})})}),s.lastUsedAt&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground mt-0.5",children:[e.jsx(de,{className:"w-3 h-3"}),"Last used: ",new Date(s.lastUsedAt).toLocaleDateString()]})]})]}),e.jsxs(Ms,{children:[e.jsx(Os,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon",className:"h-7 w-7",children:e.jsx(ct,{className:"w-4 h-4"})})}),e.jsxs(Ts,{align:"end",children:[!s.isDefault&&e.jsxs(Re,{onClick:a,children:[e.jsx(oe,{className:"w-4 h-4 mr-2"}),"Set as default"]}),e.jsxs(Re,{className:"text-destructive focus:text-destructive",onClick:t,disabled:i,children:[e.jsx(rs,{className:"w-4 h-4 mr-2"}),i?"Removing...":"Remove account"]})]})]})]}),u&&e.jsx("div",{className:"pl-11",children:d?e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx($,{className:"w-3 h-3 animate-spin"}),e.jsx("span",{children:"Loading quota..."})]}):j!==null?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"flex items-center gap-1.5 text-xs",children:E?e.jsxs(e.Fragment,{children:[e.jsx(dt,{className:"w-3 h-3 text-emerald-500"}),e.jsxs("span",{className:"text-emerald-600 dark:text-emerald-400",children:["Active · ",Ue(C)]})]}):C?e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"w-3 h-3 text-muted-foreground"}),e.jsxs("span",{className:"text-muted-foreground",children:["Last used ",Ue(C)]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ut,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Not used yet"})]})}),e.jsx(X,{children:e.jsxs(Z,{children:[e.jsx(ee,{asChild:!0,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ds,{value:Math.max(0,Math.min(100,j)),className:"h-2 flex-1",indicatorClassName:Ft(j)}),e.jsxs("span",{className:"text-xs font-medium w-10 text-right",children:[j,"%"]})]})}),e.jsx(se,{side:"bottom",className:"max-w-xs",children:e.jsxs("div",{className:"text-xs space-y-1",children:[e.jsx("p",{className:"font-medium",children:"Model Quotas:"}),(()=>{const L=Is(p?.models||[]),T=_s(L),M=["primary","gemini-3","gemini-2","other"];return M.map((O,f)=>{const P=T.get(O);if(!P||P.length===0)return null;const v=M.slice(0,f).every(k=>!T.get(k)?.length);return e.jsxs("div",{children:[!v&&e.jsx("div",{className:"border-t border-border/40 my-1"}),P.map(k=>e.jsxs("div",{className:"flex justify-between gap-4",children:[e.jsx("span",{className:_("truncate",k.exhausted&&"text-red-500"),children:k.displayName}),e.jsxs("span",{className:_("font-mono",k.exhausted&&"text-red-500"),children:[k.percentage,"%"]})]},k.name))]},O)})})(),D&&e.jsxs("div",{className:"flex items-center gap-1.5 pt-1 border-t border-border/50",children:[e.jsx(de,{className:"w-3 h-3 text-blue-400"}),e.jsxs("span",{className:"text-blue-400 font-medium",children:["Resets ",Es(D)]})]})]})})]})})]}):p?.error||p&&!p.success?e.jsx(X,{children:e.jsxs(Z,{children:[e.jsx(ee,{asChild:!0,children:e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsxs(K,{variant:"outline",className:"text-[10px] h-5 px-2 gap-1 border-muted-foreground/50 text-muted-foreground",children:[e.jsx(mt,{className:"w-3 h-3"}),"N/A"]})})}),e.jsx(se,{side:"bottom",children:e.jsx("p",{className:"text-xs",children:p?.error||"Quota information unavailable"})})]})}):null})]})}function Gt({selectedCount:s,onPauseSelected:a,onResumeSelected:t,onClearSelection:r,isPausing:i,isResuming:c}){if(s<1)return null;const l=i||c;return e.jsxs("div",{className:"flex items-center gap-3 p-2 bg-muted/50 rounded-lg border mt-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[s," selected"]}),e.jsx(w,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:r,disabled:l,children:"Clear"}),e.jsxs("div",{className:"flex gap-2 ml-auto",children:[e.jsxs(w,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:a,disabled:l,children:[i?e.jsx($,{className:"w-3 h-3 animate-spin"}):e.jsx(xe,{className:"w-3 h-3"}),"Pause Selected"]}),e.jsxs(w,{size:"sm",variant:"outline",className:"h-7 text-xs gap-1",onClick:t,disabled:l,children:[c?e.jsx($,{className:"w-3 h-3 animate-spin"}):e.jsx(is,{className:"w-3 h-3"}),"Resume Selected"]})]})]})}function Kt({accounts:s,onAddAccount:a,onSetDefault:t,onRemoveAccount:r,onPauseToggle:i,onSoloMode:c,onBulkPause:l,onBulkResume:u,isRemovingAccount:o,isPausingAccount:x,isSoloingAccount:g,isBulkPausing:h,isBulkResuming:p,privacyMode:d,showQuota:C,isKiro:E,kiroNoIncognito:j,onKiroNoIncognitoChange:D,kiroSettingsLoading:L}){const[T,M]=m.useState(new Set),O=m.useMemo(()=>new Set(s.map(N=>N.id)),[s]),f=m.useMemo(()=>new Set([...T].filter(N=>O.has(N))),[T,O]),P=!!(l&&u),v=f.size,k=s.length>0&&f.size===s.length,R=f.size>0&&f.size<s.length,S=m.useCallback(N=>{M(I=>{const G=new Set(I);return G.has(N)?G.delete(N):G.add(N),G})},[]),b=m.useCallback(()=>{M(new Set(s.map(N=>N.id)))},[s]),F=m.useCallback(()=>{M(new Set)},[]),U=m.useCallback(()=>{k?F():b()},[k,b,F]),z=m.useCallback(()=>{l&&f.size>0&&(l(Array.from(f)),M(new Set))},[l,f]),y=m.useCallback(()=>{u&&f.size>0&&(u(Array.from(f)),M(new Set))},[u,f]);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2",children:[P&&s.length>0&&e.jsx(Lt,{checked:k,onCheckedChange:U,"aria-label":"Select all accounts",className:R?"data-[state=checked]:bg-primary/50":"",...R?{"data-state":"indeterminate"}:{}}),e.jsx(W,{className:"w-4 h-4"}),"Accounts",s.length>0&&e.jsx(K,{variant:"secondary",className:"text-xs",children:s.length})]}),e.jsxs(w,{variant:"default",size:"sm",className:"h-7 text-xs gap-1",onClick:a,children:[e.jsx(ns,{className:"w-3 h-3"}),"Add"]})]}),P&&v>0&&e.jsx(Gt,{selectedCount:v,onPauseSelected:z,onResumeSelected:y,onClearSelection:F,isPausing:!!h,isResuming:!!p}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(N=>e.jsx(Ut,{account:N,onSetDefault:()=>t(N.id),onRemove:()=>r(N.id),onPauseToggle:i?I=>i(N.id,I):void 0,onSoloMode:c?()=>c(N.id):void 0,isRemoving:o,isPausingAccount:x,isSoloingAccount:g,privacyMode:d,showQuota:C,selectable:P,selected:f.has(N.id),onSelectChange:()=>S(N.id)},N.id))}):e.jsxs("div",{className:"py-6 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed",children:[e.jsx(W,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:"No accounts connected"}),e.jsx("p",{className:"text-xs opacity-70",children:"Add an account to get started"})]}),E&&D&&e.jsx("div",{className:"mt-3 pt-3 border-t border-dashed",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(as,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Use incognito"})]}),e.jsx(ht,{checked:!j,onCheckedChange:N=>D(!N),disabled:L,className:"scale-90"})]})})]})}function zt({provider:s,catalog:a,savedPresets:t,currentModel:r,opusModel:i,sonnetModel:c,haikuModel:l,providerModels:u,onApplyPreset:o,onUpdateEnvValue:x,onOpenCustomPreset:g,onDeletePreset:h,isDeletePending:p,accounts:d,onAddAccount:C,onSetDefault:E,onRemoveAccount:j,onPauseToggle:D,onSoloMode:L,onBulkPause:T,onBulkResume:M,isRemovingAccount:O,isPausingAccount:f,isSoloingAccount:P,isBulkPausing:v,isBulkResuming:k,privacyMode:R,isRemoteMode:S}){const b=s==="kiro",[F,U]=m.useState(!0),[z,y]=m.useState(!0),[N,I]=m.useState(!1),G=m.useCallback(async()=>{if(b)try{y(!0);const A=(await ce.config.get()).cliproxy;U(A?.kiro_no_incognito??!0)}catch{U(!0)}finally{y(!1)}},[b]),Y=m.useCallback(async n=>{U(n),I(!0);try{const A=await ce.config.get(),J=A.cliproxy??{};await ce.config.update({...A,cliproxy:{...J,kiro_no_incognito:n}})}catch{U(!n)}finally{I(!1)}},[]);return m.useEffect(()=>{G()},[G]),e.jsx(we,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsx(Rt,{catalog:a,savedPresets:t,currentModel:r,opusModel:i,sonnetModel:c,haikuModel:l,providerModels:u,onApplyPreset:o,onUpdateEnvValue:x,onOpenCustomPreset:g,onDeletePreset:h,isDeletePending:p}),e.jsx(Se,{}),e.jsx(Kt,{accounts:d,onAddAccount:C,onSetDefault:E,onRemoveAccount:j,onPauseToggle:D,onSoloMode:L,onBulkPause:T,onBulkResume:M,isRemovingAccount:O,isPausingAccount:f,isSoloingAccount:P,isBulkPausing:v,isBulkResuming:k,privacyMode:R,showQuota:s==="agy"&&!S,isKiro:b,kiroNoIncognito:F,onKiroNoIncognitoChange:Y,kiroSettingsLoading:z||N})]})})}function Ge({provider:s,displayName:a,authStatus:t,catalog:r,logoProvider:i,baseProvider:c,isRemoteMode:l,port:u,onAddAccount:o,onSetDefault:x,onRemoveAccount:g,onPauseToggle:h,onSoloMode:p,onBulkPause:d,onBulkResume:C,isRemovingAccount:E,isPausingAccount:j,isSoloingAccount:D,isBulkPausing:L,isBulkResuming:T}){const[M,O]=m.useState(!1),{privacyMode:f}=Ze(),{data:P}=Rs(),{data:v}=Ls(s),k=Fs(),R=Hs(),S=v?.presets||[],b=c||s,F=m.useMemo(()=>{if(!P?.models)return[];const V={gemini:["google"],agy:["antigravity"],codex:["openai"],qwen:["alibaba","qwen"],iflow:["iflow"],kiro:["kiro","aws"],ghcp:["github","copilot"]}[b.toLowerCase()]||[b.toLowerCase()];return P.models.filter(Ie=>V.some(js=>Ie.owned_by.toLowerCase().includes(js)))},[P,b]),{data:U,isLoading:z,refetch:y,rawJsonContent:N,rawJsonEdits:I,isRawJsonValid:G,hasChanges:Y,currentModel:n,opusModel:A,sonnetModel:J,haikuModel:Pe,handleRawJsonChange:cs,updateEnvValue:ds,updateEnvValues:Me,saveMutation:Oe,conflictDialog:us,handleConflictResolve:Te,missingRequiredFields:ms}=Mt(s),xs=t.accounts||[],{data:ps}=ze({queryKey:["auth-tokens-raw"],queryFn:async()=>{const H=await fetch("/api/settings/auth/tokens/raw");return H.ok?H.json():{apiKey:{value:"ccs-internal-managed"}}},staleTime:6e4}),De=ps?.apiKey?.value??"ccs-internal-managed",hs=H=>{Me({ANTHROPIC_BASE_URL:`http://127.0.0.1:${u??pe}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:De,...H}),B.success(`Applied "${H.ANTHROPIC_MODEL?.split("/").pop()||"preset"}" preset`)},gs=(H,V)=>{Me({ANTHROPIC_BASE_URL:`http://127.0.0.1:${u??pe}/api/provider/${s}`,ANTHROPIC_AUTH_TOKEN:De,ANTHROPIC_MODEL:H.default,ANTHROPIC_DEFAULT_OPUS_MODEL:H.opus,ANTHROPIC_DEFAULT_SONNET_MODEL:H.sonnet,ANTHROPIC_DEFAULT_HAIKU_MODEL:H.haiku}),B.success(`Applied ${V?`"${V}"`:"custom"} preset`),O(!1)},fs=(H,V)=>{if(!V){B.error("Please enter a preset name to save");return}k.mutate({profile:s,data:{name:V,...H}}),O(!1)};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Et,{provider:s,displayName:a,logoProvider:i,data:U,isLoading:z,hasChanges:Y,isRawJsonValid:G,isSaving:Oe.isPending,isRemoteMode:l,port:u,onRefetch:y,onSave:()=>Oe.mutate()}),z?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx($,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):e.jsxs("div",{className:"flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex flex-col overflow-hidden bg-muted/5",children:e.jsxs(Us,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(Gs,{className:"w-full",children:[e.jsx(Le,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(Le,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(Fe,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(zt,{provider:s,catalog:r,savedPresets:S,currentModel:n,opusModel:A,sonnetModel:J,haikuModel:Pe,providerModels:F,onApplyPreset:hs,onUpdateEnvValue:ds,onOpenCustomPreset:()=>O(!0),onDeletePreset:H=>R.mutate({profile:s,name:H}),isDeletePending:R.isPending,accounts:xs,onAddAccount:o,onSetDefault:x,onRemoveAccount:g,onPauseToggle:h,onSoloMode:p,onBulkPause:d,onBulkResume:C,isRemovingAccount:E,isPausingAccount:j,isSoloingAccount:D,isBulkPausing:L,isBulkResuming:T,privacyMode:f,isRemoteMode:l})}),e.jsx(Fe,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Tt,{provider:s,displayName:a,data:U,authStatus:t})})]})]})}),e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(xt,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(Ks,{rawJsonContent:N,isRawJsonValid:G,rawJsonEdits:I,onRawJsonChange:cs,profileEnv:U?.settings?.env,missingRequiredFields:ms})]})]}),e.jsx(pt,{open:us,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>Te(!0),onCancel:()=>Te(!1)}),e.jsx(Ot,{open:M,onClose:()=>O(!1),currentValues:{default:n||"",opus:A||"",sonnet:J||"",haiku:Pe||""},onApply:gs,onSave:fs,isSaving:k.isPending,catalog:r,allModels:F})]})}function Bt({status:s,isSelected:a,onSelect:t}){const r=s.accounts?.length||0;return e.jsxs("button",{className:_("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:t,children:[e.jsx(Ae,{provider:s.provider,size:"md"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.displayName}),r>0&&e.jsx(K,{variant:"secondary",className:"text-[10px] h-4 px-1",children:r})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:s.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-3 h-3 text-green-600"}),e.jsx("span",{className:"text-xs text-green-600",children:"Connected"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ke,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not connected"})]})})]})]})}function $t({variant:s,parentAuth:a,isSelected:t,onSelect:r,onDelete:i,isDeleting:c}){return e.jsxs("button",{className:_("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",t?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:r,children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ae,{provider:s.provider,size:"sm"}),e.jsx(os,{className:"w-2.5 h-2.5 absolute -bottom-0.5 -right-0.5 text-muted-foreground"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:s.name}),e.jsx(K,{variant:"outline",className:"text-[9px] h-4 px-1",children:"variant"})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:a?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"w-3 h-3 text-green-600"}),e.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["via ",s.provider]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ke,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Parent not connected"})]})})]}),e.jsx(w,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:l=>{l.stopPropagation(),i()},disabled:c,children:e.jsx(rs,{className:"w-3 h-3"})})]})}function qt({onSetup:s}){return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20",children:e.jsxs("div",{className:"text-center max-w-md px-8",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mx-auto mb-6",children:e.jsx(le,{className:"w-8 h-8 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"CCS Profile Manager"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Manage OAuth authentication, account preferences, and model selection for CLIProxy providers. Configure how CCS routes requests to different AI backends."}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-6",children:["For live usage stats and real-time monitoring, visit the"," ",e.jsx("a",{href:"/cliproxy/control-panel",className:"text-primary hover:underline",children:"Control Panel"}),"."]}),e.jsxs(w,{onClick:s,className:"gap-2",children:[e.jsx(ae,{className:"w-4 h-4"}),"Quick Setup"]})]})})}function ra(){const s=Ke(),{data:a,isLoading:t}=We(),{data:r,isFetching:i}=zs(),{data:c}=Bs(),l=$s(),u=qs(),o=Vs(),x=Qs(),g=Js(),h=Ws(),p=Ys(),d=Xs(),[C,E]=m.useState(()=>typeof window<"u"?localStorage.getItem("cliproxy-selected-provider"):null),[j,D]=m.useState(null),[L,T]=m.useState(!1),[M,O]=m.useState(null),f=m.useMemo(()=>a?.authStatus||[],[a?.authStatus]),P=a?.source==="remote",v=m.useMemo(()=>r?.variants||[],[r?.variants]),k=n=>{E(n),n&&localStorage.setItem("cliproxy-selected-provider",n)},R=m.useMemo(()=>j?null:C&&f.some(n=>n.provider===C)?C:f.length>0&&(f.find(A=>(A.accounts?.length||0)>0)?.provider||f[0]?.provider)||null,[C,j,f]),S=f.find(n=>n.provider===R),b=v.find(n=>n.name===j),F=b?f.find(n=>n.provider===b.provider):void 0,U=()=>{s.invalidateQueries({queryKey:["cliproxy"]}),s.invalidateQueries({queryKey:["cliproxy-auth"]})},z=(n,A,J)=>{o.isPending||x.isPending||(J?o.mutate({provider:n,accountId:A}):x.mutate({provider:n,accountId:A}))},y=(n,A)=>{g.isPending||g.mutate({provider:n,accountId:A})},N=(n,A)=>{h.isPending||h.mutate({provider:n,accountIds:A})},I=(n,A)=>{p.isPending||p.mutate({provider:n,accountIds:A})},G=n=>{k(n),D(null)},Y=n=>{D(n),k(null)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:c?.backendLabel??"CLIProxy"})]}),e.jsx(w,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:U,disabled:i,children:e.jsx(Ce,{className:_("w-4 h-4",i&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"CCS-level account management"}),e.jsxs(w,{variant:"default",size:"sm",className:"w-full gap-2",onClick:()=>T(!0),children:[e.jsx(ae,{className:"w-4 h-4"}),"Quick Setup"]})]}),e.jsx(we,{className:"flex-1",children:e.jsxs("div",{className:"p-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2",children:"Providers"}),t?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(n=>e.jsx(Zs,{className:"h-14 w-full rounded-lg"},n))}):e.jsx("div",{className:"space-y-1",children:f.map(n=>e.jsx(Bt,{status:n,isSelected:R===n.provider,onSelect:()=>G(n.provider)},n.provider))}),v.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3 py-2 mt-4 flex items-center gap-1.5",children:[e.jsx(os,{className:"w-3 h-3"}),"Variants"]}),e.jsx("div",{className:"space-y-1",children:v.map(n=>e.jsx($t,{variant:n,parentAuth:f.find(A=>A.provider===n.provider),isSelected:j===n.name,onSelect:()=>Y(n.name),onDelete:()=>d.mutate(n.name),isDeleting:d.isPending},n.name))})]})]})}),e.jsx("div",{className:"p-3 border-t",children:e.jsx(gt,{})}),e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{children:[f.length," provider",f.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(q,{className:"w-3 h-3 text-green-600"}),f.filter(n=>n.authenticated).length," connected"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:b&&F?e.jsx(Ge,{provider:b.name,displayName:`${b.name} (${b.provider} variant)`,authStatus:F,catalog:te[b.provider],logoProvider:b.provider,baseProvider:b.provider,isRemoteMode:P,port:b.port,onAddAccount:()=>O({provider:b.provider,displayName:F.displayName,isFirstAccount:(F.accounts?.length||0)===0}),onSetDefault:n=>l.mutate({provider:b.provider,accountId:n}),onRemoveAccount:n=>u.mutate({provider:b.provider,accountId:n}),onPauseToggle:(n,A)=>z(b.provider,n,A),onSoloMode:n=>y(b.provider,n),onBulkPause:n=>N(b.provider,n),onBulkResume:n=>I(b.provider,n),isRemovingAccount:u.isPending,isPausingAccount:o.isPending||x.isPending,isSoloingAccount:g.isPending,isBulkPausing:h.isPending,isBulkResuming:p.isPending}):S?e.jsx(Ge,{provider:S.provider,displayName:S.displayName,authStatus:S,catalog:te[S.provider],isRemoteMode:P,onAddAccount:()=>O({provider:S.provider,displayName:S.displayName,isFirstAccount:(S.accounts?.length||0)===0}),onSetDefault:n=>l.mutate({provider:S.provider,accountId:n}),onRemoveAccount:n=>u.mutate({provider:S.provider,accountId:n}),onPauseToggle:(n,A)=>z(S.provider,n,A),onSoloMode:n=>y(S.provider,n),onBulkPause:n=>N(S.provider,n),onBulkResume:n=>I(S.provider,n),isRemovingAccount:u.isPending,isPausingAccount:o.isPending||x.isPending,isSoloingAccount:g.isPending,isBulkPausing:h.isPending,isBulkResuming:p.isPending}):e.jsx(qt,{onSetup:()=>T(!0)})}),e.jsx(kt,{open:L,onClose:()=>T(!1)}),e.jsx(St,{open:M!==null,onClose:()=>O(null),provider:M?.provider||"",displayName:M?.displayName||"",isFirstAccount:M?.isFirstAccount||!1})]})}export{ra as CliproxyPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-qEZD5MMp.js";import{r as i}from"./react-vendor-CNOkPC89.js";import{aM as $,aN as P,I as F,aO as U,aJ as _,aL as B,m as K,b as A}from"./index-D7Pl56Ob.js";import{S as z}from"./switch-D0G-SCdh.js";import{x as q,j as D,Q as J,V,m as Y,a6 as L,a0 as Q,p as X}from"./icons-C6UNjkCT.js";import"./tanstack-De4wvi8X.js";import"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-C-pVd1--.js";import"./code-highlight-BRUf_pqB.js";function Z(){const{state:s}=$(),a=P(),[d,l]=i.useState(""),[o,m]=i.useState(""),[f,h]=i.useState(!1),[j,u]=i.useState(!1),S=i.useCallback(async()=>{try{a.setWebSearchLoading(!0),a.setWebSearchError(null);const t=await fetch("/api/websearch");if(!t.ok)throw new Error("Failed to load WebSearch config");const r=await t.json();a.setWebSearchConfig(r)}catch(t){a.setWebSearchError(t.message)}finally{a.setWebSearchLoading(!1)}},[a]),v=i.useCallback(async()=>{try{a.setWebSearchStatusLoading(!0);const t=await fetch("/api/websearch/status");if(!t.ok)throw new Error("Failed to load status");const r=await t.json();a.setWebSearchStatus(r)}catch{}finally{a.setWebSearchStatusLoading(!1)}},[a]),p=i.useCallback(async t=>{const r=s.webSearchConfig;if(!r)return;const w={...r,...t};a.setWebSearchConfig(w);try{a.setWebSearchSaving(!0),a.setWebSearchError(null);const n=await fetch("/api/websearch",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(!n.ok){const k=await n.json();throw new Error(k.error||"Failed to save")}const C=await n.json();a.setWebSearchConfig(C.websearch),a.setWebSearchSuccess(!0),setTimeout(()=>a.setWebSearchSuccess(!1),1500)}catch(n){a.setWebSearchConfig(r),a.setWebSearchError(n.message)}finally{a.setWebSearchSaving(!1)}},[s.webSearchConfig,a]);i.useEffect(()=>{s.webSearchConfig&&(l(s.webSearchConfig.providers?.gemini?.model??"gemini-2.5-flash"),m(s.webSearchConfig.providers?.opencode?.model??"opencode/grok-code"))},[s.webSearchConfig]);const x=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.gemini?.model??"gemini-2.5-flash";if(d!==t){const r=s.webSearchConfig?.providers||{};await p({providers:{...r,gemini:{...r.gemini,model:d}}}),h(!0),setTimeout(()=>h(!1),2e3)}},[d,s.webSearchConfig,p]),g=i.useCallback(async()=>{const t=s.webSearchConfig?.providers?.opencode?.model??"opencode/grok-code";if(o!==t){const r=s.webSearchConfig?.providers||{};await p({providers:{...r,opencode:{...r.opencode,model:o}}}),u(!0),setTimeout(()=>u(!1),2e3)}},[o,s.webSearchConfig,p]);return{config:s.webSearchConfig,status:s.webSearchStatus,loading:s.webSearchLoading,statusLoading:s.webSearchStatusLoading,saving:s.webSearchSaving,error:s.webSearchError,success:s.webSearchSuccess,geminiModelInput:d,setGeminiModelInput:l,opencodeModelInput:o,setOpencodeModelInput:m,geminiModelSaved:f,opencodeModelSaved:j,fetchConfig:S,fetchStatus:v,saveConfig:p,saveGeminiModel:x,saveOpencodeModel:g}}function O({name:s,label:a,badge:d,badgeColor:l,enabled:o,installed:m,statusLoading:f,saving:h,onToggle:j,modelInput:u,setModelInput:S,onModelBlur:v,modelSaved:p,modelPlaceholder:x,showHint:g,setShowHint:t,installCmd:r,docsUrl:w,hintColor:n}){const C=l==="green"?"bg-green-500/10 text-green-600":l==="blue"?"bg-blue-500/10 text-blue-600":"bg-purple-500/10 text-purple-600",k=n==="amber"?"bg-amber-50 dark:bg-amber-900/20 text-amber-700 dark:text-amber-300":n==="blue"?"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"bg-purple-50 dark:bg-purple-900/20 text-purple-700 dark:text-purple-300",y=n==="amber"?"bg-amber-100 dark:bg-amber-900/40":n==="blue"?"bg-blue-100 dark:bg-blue-900/40":"bg-purple-100 dark:bg-purple-900/40",E=n==="amber"?"text-amber-600 dark:text-amber-400":n==="blue"?"text-blue-600 dark:text-blue-400":"text-purple-600 dark:text-purple-400",M=s==="opencode"?"OpenCode":s.charAt(0).toUpperCase()+s.slice(1);return e.jsxs("div",{className:`rounded-lg border transition-colors ${o?"border-primary border-l-4":"border-border"}`,children:[e.jsxs("div",{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(q,{className:`w-5 h-5 ${o?"text-primary":"text-muted-foreground"}`}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"font-mono font-medium",children:s}),e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${C}`,children:d}),m?e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-500/10 text-green-600 font-medium",children:"installed"}):e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-600 font-medium",children:"not installed"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a})]})]}),e.jsx(z,{checked:o,onCheckedChange:j,disabled:h||!m})]}),o&&u!==void 0&&S&&v&&e.jsx("div",{className:"px-4 pb-4 pt-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Model:"}),e.jsx(F,{value:u,onChange:I=>S(I.target.value),onBlur:v,placeholder:x,className:"h-8 text-sm font-mono",disabled:h}),p&&e.jsxs("span",{className:"flex items-center gap-1 text-green-600 dark:text-green-400 text-xs animate-in fade-in duration-200",children:[e.jsx(D,{className:"w-3.5 h-3.5"}),"Saved"]})]})}),!m&&!f&&e.jsxs("div",{className:"px-4 pb-4 pt-0 border-t border-border/50",children:[e.jsxs("button",{onClick:()=>t(!g),className:`flex items-center gap-2 text-sm hover:underline w-full py-2 ${E}`,children:[g?e.jsx(J,{className:"w-4 h-4"}):e.jsx(V,{className:"w-4 h-4"}),"How to install ",M," CLI"]}),g&&e.jsxs("div",{className:`mt-2 p-3 rounded-md text-sm ${k}`,children:[e.jsxs("p",{className:"mb-2",children:["Install globally"," ",d==="GROK_API_KEY"?"(requires xAI API key)":"(FREE tier available)",":"]}),e.jsx("code",{className:`text-sm px-2 py-1 rounded font-mono block mb-2 ${y}`,children:r}),e.jsxs("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"hover:underline inline-flex items-center gap-1",children:[e.jsx(Y,{className:"w-3 h-3"}),"View documentation"]})]})]})]})}function ce(){const{config:s,status:a,loading:d,statusLoading:l,saving:o,error:m,success:f,geminiModelInput:h,setGeminiModelInput:j,opencodeModelInput:u,setOpencodeModelInput:S,geminiModelSaved:v,opencodeModelSaved:p,fetchConfig:x,fetchStatus:g,saveConfig:t,saveGeminiModel:r,saveOpencodeModel:w}=Z(),{fetchRawConfig:n}=U(),[C,k]=i.useState(!1),[y,E]=i.useState(!1),[M,I]=i.useState(!1);i.useEffect(()=>{x(),g(),n()},[x,g,n]);const N=s?.providers?.gemini?.enabled??!1,W=s?.providers?.grok?.enabled??!1,G=s?.providers?.opencode?.enabled??!1,H=()=>{const c=s?.providers||{},b=c.gemini?.enabled??!1;t({enabled:!b||W||G,providers:{...c,gemini:{...c.gemini,enabled:!b}}})},R=()=>{const c=s?.providers||{},b=c.grok?.enabled??!1;t({enabled:N||!b||G,providers:{...c,grok:{...c.grok,enabled:!b}}})},T=()=>{const c=s?.providers||{},b=c.opencode?.enabled??!1;t({enabled:N||W||!b,providers:{...c,opencode:{...c.opencode,enabled:!b}}})};return d?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[e.jsx(L,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Loading..."})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`absolute left-5 right-5 top-20 z-10 transition-all duration-200 ease-out ${m||f?"opacity-100 translate-y-0":"opacity-0 -translate-y-2 pointer-events-none"}`,children:[m&&e.jsxs(_,{variant:"destructive",className:"py-2 shadow-lg",children:[e.jsx(Q,{className:"h-4 w-4"}),e.jsx(B,{children:m})]}),f&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md border border-green-200 bg-green-50 text-green-700 shadow-lg dark:border-green-900/50 dark:bg-green-900/90 dark:text-green-300",children:[e.jsx(X,{className:"h-4 w-4 shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:"Saved"})]})]}),e.jsx(K,{className:"flex-1",children:e.jsxs("div",{className:"p-5 space-y-6",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"CLI-based web search for third-party profiles (gemini, codex, agy, etc.)"}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-muted/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:N?"WebSearch enabled":"WebSearch disabled"}),l?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Checking status..."}):a?.readiness?e.jsx("p",{className:"text-sm text-muted-foreground",children:a.readiness.message}):null]}),e.jsx(A,{variant:"ghost",size:"sm",onClick:g,disabled:l,children:e.jsx(L,{className:`w-4 h-4 ${l?"animate-spin":""}`})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-base font-medium",children:"Providers"}),e.jsx(O,{name:"gemini",label:"Google Gemini CLI (1000 req/day free)",badge:"FREE",badgeColor:"green",enabled:N,installed:a?.geminiCli?.installed??!1,statusLoading:l,saving:o,onToggle:H,modelInput:h,setModelInput:j,onModelBlur:r,modelSaved:v,modelPlaceholder:"gemini-2.5-flash",showHint:C,setShowHint:k,installCmd:"npm install -g @google/gemini-cli",docsUrl:"https://github.com/google-gemini/gemini-cli",hintColor:"amber"}),e.jsx(O,{name:"opencode",label:"OpenCode (web search via Zen)",badge:"FREE",badgeColor:"green",enabled:G,installed:a?.opencodeCli?.installed??!1,statusLoading:l,saving:o,onToggle:T,modelInput:u,setModelInput:S,onModelBlur:w,modelSaved:p,modelPlaceholder:"opencode/grok-code",showHint:y,setShowHint:E,installCmd:"curl -fsSL https://opencode.ai/install | bash",docsUrl:"https://github.com/sst/opencode",hintColor:"purple"}),e.jsx(O,{name:"grok",label:"xAI Grok CLI (web + X search)",badge:"GROK_API_KEY",badgeColor:"blue",enabled:W,installed:a?.grokCli?.installed??!1,statusLoading:l,saving:o,onToggle:R,showHint:M,setShowHint:I,installCmd:"npm install -g @vibe-kit/grok-cli",docsUrl:"https://github.com/superagent-ai/grok-cli",hintColor:"blue"})]})]})}),e.jsx("div",{className:"p-4 border-t bg-background",children:e.jsxs(A,{variant:"outline",size:"sm",onClick:()=>{x(),n()},disabled:d||o,className:"w-full",children:[e.jsx(L,{className:`w-4 h-4 mr-2 ${d?"animate-spin":""}`}),"Refresh"]})})]})}export{ce as default};
|