@kaitranntt/ccs 5.15.0 → 5.16.0
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/VERSION +1 -1
- package/dist/cliproxy/account-manager.d.ts.map +1 -1
- package/dist/cliproxy/account-manager.js +35 -0
- package/dist/cliproxy/account-manager.js.map +1 -1
- package/dist/cliproxy/config-generator.d.ts +21 -0
- package/dist/cliproxy/config-generator.d.ts.map +1 -1
- package/dist/cliproxy/config-generator.js +122 -16
- package/dist/cliproxy/config-generator.js.map +1 -1
- package/dist/cliproxy/index.d.ts +7 -1
- package/dist/cliproxy/index.d.ts.map +1 -1
- package/dist/cliproxy/index.js +20 -2
- package/dist/cliproxy/index.js.map +1 -1
- package/dist/cliproxy/openai-compat-manager.d.ts +46 -0
- package/dist/cliproxy/openai-compat-manager.d.ts.map +1 -0
- package/dist/cliproxy/openai-compat-manager.js +191 -0
- package/dist/cliproxy/openai-compat-manager.js.map +1 -0
- package/dist/cliproxy/service-manager.d.ts +43 -0
- package/dist/cliproxy/service-manager.d.ts.map +1 -0
- package/dist/cliproxy/service-manager.js +220 -0
- package/dist/cliproxy/service-manager.js.map +1 -0
- package/dist/cliproxy/stats-fetcher.d.ts +59 -0
- package/dist/cliproxy/stats-fetcher.d.ts.map +1 -0
- package/dist/cliproxy/stats-fetcher.js +134 -0
- package/dist/cliproxy/stats-fetcher.js.map +1 -0
- package/dist/commands/config-command.d.ts +1 -0
- package/dist/commands/config-command.d.ts.map +1 -1
- package/dist/commands/config-command.js +24 -1
- package/dist/commands/config-command.js.map +1 -1
- package/dist/management/doctor.d.ts.map +1 -1
- package/dist/management/doctor.js +21 -7
- package/dist/management/doctor.js.map +1 -1
- package/dist/types/config.d.ts +13 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js.map +1 -1
- package/dist/ui/assets/accounts-Bl9qfu_d.js +1 -0
- package/dist/ui/assets/analytics-BHnr8pTE.js +64 -0
- package/dist/ui/assets/{api-LYILKXgM.js → api-DoPJHgqb.js} +1 -1
- package/dist/ui/assets/cliproxy-DRxRpTJv.js +1 -0
- package/dist/ui/assets/cliproxy-control-panel-CNpMpeWs.js +1 -0
- package/dist/ui/assets/{code-editor-HkboCFlD.js → code-editor-ek-uxeLN.js} +11 -11
- package/dist/ui/assets/health-DBc3-gE9.js +1 -0
- package/dist/ui/assets/icons-CqXn5eV0.js +1 -0
- package/dist/ui/assets/index-D-zCRwmw.js +12 -0
- package/dist/ui/assets/index-DMEwxqAV.css +1 -0
- package/dist/ui/assets/providers/agy.png +0 -0
- package/dist/ui/assets/providers/gemini-color.svg +1 -0
- package/dist/ui/assets/providers/openai.svg +1 -0
- package/dist/ui/assets/providers/qwen-color.svg +1 -0
- package/dist/ui/assets/{radix-ui-CgfZoNEt.js → radix-ui-OFtPgiRV.js} +1 -1
- package/dist/ui/assets/{settings-DUCWbKbP.js → settings-Dh8DSszQ.js} +1 -1
- package/dist/ui/assets/{shared-Da5f_jsc.js → shared-n31ZWpeq.js} +1 -1
- package/dist/ui/assets/{tanstack-BgSYOn90.js → tanstack-DMWkeNzM.js} +1 -1
- package/dist/ui/index.html +5 -5
- package/dist/web-server/routes.d.ts.map +1 -1
- package/dist/web-server/routes.js +329 -4
- package/dist/web-server/routes.js.map +1 -1
- package/package.json +1 -1
- package/scripts/verify-bundle.js +11 -4
- package/dist/ui/assets/accounts-CTh48XsV.js +0 -1
- package/dist/ui/assets/analytics-CeU8ZE3O.js +0 -64
- package/dist/ui/assets/cliproxy-Cy2Bjv-c.js +0 -1
- package/dist/ui/assets/health-DyAiAnv0.js +0 -1
- package/dist/ui/assets/icons-CRbZgamU.js +0 -1
- package/dist/ui/assets/index-BIVAVDH5.js +0 -10
- package/dist/ui/assets/index-vojI8oaQ.css +0 -1
- package/dist/ui/assets/table-BCRYixSo.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e
|
|
1
|
+
import{j as e}from"./radix-ui-OFtPgiRV.js";import{r as n}from"./react-vendor-CjrBBxxX.js";import{u as w,k as P,B as d,I as k,h as S,l as A,m as I,n as D,c as L,o as M,p as B,d as f}from"./index-D-zCRwmw.js";import{Q as E,k as p,a0 as O,a1 as z,g as N,f as R,o as Q,a2 as T,a3 as F}from"./icons-CqXn5eV0.js";import"./tanstack-DMWkeNzM.js";import"./form-utils-DKkU3nz7.js";function J(){const{data:a,isLoading:x}=w(),u=P(),[r,l]=n.useState(null),[o,v]=n.useState(""),[y,i]=n.useState(!1),[c,m]=n.useState(null),t=n.useMemo(()=>a?.profiles||[],[a?.profiles]),j=n.useMemo(()=>t.filter(s=>s.name.toLowerCase().includes(o.toLowerCase())),[t,o]),g=n.useMemo(()=>r&&t.some(s=>s.name===r)?r:t.length>0?t[0].name:null,[r,t]),C=s=>{u.mutate(s,{onSuccess:()=>{r===s&&l(null),m(null)}})},b=s=>{i(!1),l(s)},h=t.find(s=>s.name===g);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-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"API Profiles"})]}),e.jsxs(d,{size:"sm",onClick:()=>{i(!0)},children:[e.jsx(p,{className:"w-4 h-4 mr-1"}),"New"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(O,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(k,{placeholder:"Search profiles...",className:"pl-8 h-9",value:o,onChange:s=>v(s.target.value)})]})]}),e.jsx(S,{className:"flex-1",children:x?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading profiles..."}):j.length===0?e.jsx("div",{className:"p-4 text-center",children:t.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(z,{className:"w-12 h-12 mx-auto text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"No API profiles yet"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Create your first profile to connect to custom API endpoints"})]}),e.jsxs(d,{size:"sm",variant:"outline",onClick:()=>{i(!0)},children:[e.jsx(p,{className:"w-4 h-4 mr-1"}),"Create Profile"]})]}):e.jsxs("p",{className:"text-sm text-muted-foreground py-4",children:['No profiles match "',o,'"']})}):e.jsx("div",{className:"p-2 space-y-1",children:j.map(s=>e.jsx(U,{profile:s,isSelected:g===s.name,onSelect:()=>{l(s.name)},onDelete:()=>m(s.name)},s.name))})}),t.length>0&&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:[t.length," profile",t.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(N,{className:"w-3 h-3 text-green-600"}),t.filter(s=>s.configured).length," configured"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:h?e.jsx(A,{profileName:h.name,onDelete:()=>m(h.name)}):e.jsx(H,{onCreateClick:()=>{i(!0)}})}),e.jsx(I,{open:y,onOpenChange:i,onSuccess:b}),e.jsx(D,{open:!!c,title:"Delete Profile",description:`Are you sure you want to delete "${c}"? This will remove the settings file and cannot be undone.`,confirmText:"Delete",variant:"destructive",onConfirm:()=>c&&C(c),onCancel:()=>m(null)})]})}function U({profile:a,isSelected:x,onSelect:u,onDelete:r}){return e.jsxs("div",{className:L("group flex items-center gap-2 px-3 py-2.5 rounded-md cursor-pointer transition-colors",x?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:u,children:[a.configured?e.jsx(N,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(R,{className:"w-4 h-4 text-yellow-600 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:a.name}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("div",{className:"text-xs text-muted-foreground truncate flex-1",children:a.settingsPath}),e.jsx(M,{value:a.settingsPath,size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity"})]})]}),e.jsx(d,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:l=>{l.stopPropagation(),r()},children:e.jsx(Q,{className:"w-3.5 h-3.5 text-destructive"})})]})}function H({onCreateClick:a}){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(T,{className:"w-16 h-16 mx-auto text-muted-foreground/30 mb-6"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"API Profile Manager"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Configure custom API endpoints for Claude CLI. Connect to proxy services like copilot-api, OpenRouter, or your own API backend."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs(d,{onClick:a,className:"w-full",children:[e.jsx(p,{className:"w-4 h-4 mr-2"}),"Create Your First Profile"]}),e.jsx(B,{className:"my-4"}),e.jsxs("div",{className:"text-left space-y-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"What you can configure:"}),e.jsxs("ul",{className:"text-sm text-muted-foreground space-y-1.5",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(f,{variant:"outline",className:"text-xs shrink-0 mt-0.5",children:"URL"}),e.jsx("span",{children:"Custom API base URL endpoint"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(f,{variant:"outline",className:"text-xs shrink-0 mt-0.5",children:"Auth"}),e.jsx("span",{children:"API key or authentication token"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(f,{variant:"outline",className:"text-xs shrink-0 mt-0.5",children:"Models"}),e.jsx("span",{children:"Model mapping for Opus/Sonnet/Haiku"})]})]})]}),e.jsx("div",{className:"pt-4",children:e.jsxs("a",{href:"https://github.com/kaitranntt/ccs#api-profiles",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-xs text-primary hover:underline",children:["Learn more about API profiles",e.jsx(F,{className:"w-3 h-3 ml-1"})]})})]})]})})}export{J as ApiPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-OFtPgiRV.js";import{r as l}from"./react-vendor-CjrBBxxX.js";import{u as pe}from"./tanstack-DMWkeNzM.js";import{q as W,r as he,s as H,D as Z,t as J,v as X,w as Y,x as _,B as o,C as E,a as B,L as T,I as ee,y as ge,z as fe,A as ve,E as je,F as Ne,G as we,H as ye,J as be,K as Ce,c as L,h as Se,S as Ae,M as $,N as se,d as te}from"./index-D-zCRwmw.js";import{t as R,a as K,L as ae,a3 as G,T as ke,h as k,i as Pe,a4 as O,R as ne,v as V,Z as ie,a5 as re,X as de,o as De}from"./icons-CqXn5eV0.js";import"./form-utils-DKkU3nz7.js";const P={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"},{id:"gemini-claude-sonnet-4-5-thinking",name:"Claude Sonnet 4.5 Thinking",description:"Balanced with extended thinking"},{id:"gemini-claude-sonnet-4-5",name:"Claude Sonnet 4.5",description:"Fast and capable"},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro",description:"Google latest model via Antigravity"}]},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"},{id:"gemini-2.5-pro",name:"Gemini 2.5 Pro",description:"Stable, works with free Google account"}]},codex:{provider:"codex",displayName:"Codex",defaultModel:"gpt-5.1-codex-max",models:[{id:"gpt-5.1-codex-max",name:"Codex Max (5.1)",description:"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"}]}},U=[{id:"gemini",name:"Google Gemini",description:"Gemini Pro/Flash models"},{id:"codex",name:"OpenAI Codex",description:"GPT-4 and codex models"},{id:"agy",name:"Antigravity",description:"Antigravity AI models"},{id:"qwen",name:"Alibaba Qwen",description:"Qwen Code models"},{id:"iflow",name:"iFlow",description:"iFlow AI models"}];function Me({open:i,onClose:u}){const[a,n]=l.useState("provider"),[d,h]=l.useState(""),[r,v]=l.useState(null),[x,f]=l.useState(""),[j,S]=l.useState(""),[D,N]=l.useState(!1),[w,b]=l.useState(!1),[m,C]=l.useState(!1),{data:A,refetch:p}=W(),c=he(),g=H(),y=A?.authStatus.find(s=>s.provider===d)?.accounts||[];l.useEffect(()=>{if(!i){const s=setTimeout(()=>{n("provider"),h(""),v(null),f(""),S(""),N(!1),C(!1)},0);return()=>clearTimeout(s)}},[i]),l.useEffect(()=>{if(a==="auth"&&y.length>0&&!m){const s=setTimeout(()=>{n("account")},0);return()=>clearTimeout(s)}},[a,y,m]);const M=async s=>{await navigator.clipboard.writeText(s),N(!0),setTimeout(()=>N(!1),2e3)},t=async()=>{b(!0),await p(),b(!1)},F=()=>{g.mutate({provider:d},{onSuccess:s=>{s.account&&(v(s.account),n("variant")),p()}})},ce=s=>{h(s),(A?.authStatus.find(xe=>xe.provider===s)?.accounts||[]).length===0?n("auth"):n("account")},le=s=>{v(s),n("variant")},oe=async()=>{if(!(!x||!d))try{await c.mutateAsync({name:x,provider:d,model:j||void 0,account:r?.id}),n("success")}catch(s){console.error("Failed to create variant:",s)}},q=`ccs ${d} --auth --add`,z=["provider","auth","variant","success"],me=(s=>s==="account"?1:z.indexOf(s))(a),ue=s=>{if(!s&&(a==="success"||a==="provider")){u();return}};return e.jsx(Z,{open:i,onOpenChange:ue,children:e.jsxs(J,{className:"sm:max-w-lg",onPointerDownOutside:s=>{a!=="success"&&a!=="provider"&&s.preventDefault()},onEscapeKeyDown:s=>{(g.isPending||c.isPending)&&s.preventDefault()},children:[e.jsxs(X,{children:[e.jsxs(Y,{className:"flex items-center gap-2",children:[e.jsx(R,{className:"w-5 h-5 text-primary"}),"Quick Setup Wizard"]}),e.jsxs(_,{children:[a==="provider"&&"Select a provider to get started",a==="auth"&&"Authenticate with your provider",a==="account"&&"Select which account to use",a==="variant"&&"Create your custom variant",a==="success"&&"Setup complete!"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[a==="provider"&&e.jsx("div",{className:"grid gap-2",children:U.map(s=>e.jsxs("button",{onClick:()=>ce(s.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:s.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.description})]}),e.jsx(K,{className:"w-4 h-4 text-muted-foreground"})]},s.id))}),a==="auth"&&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 ",U.find(s=>s.id===d)?.name," to add an account"]}),e.jsx(o,{onClick:F,disabled:g.isPending,className:"w-full gap-2",size:"lg",children:g.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-4 h-4 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-4 h-4"}),"Authenticate in Browser"]})}),g.isPending&&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(E,{children:e.jsxs(B,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ke,{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:q}),e.jsx(o,{variant:"outline",size:"icon",onClick:()=>M(q),children:D?e.jsx(k,{className:"w-4 h-4 text-green-500"}):e.jsx(Pe,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(o,{variant:"ghost",onClick:()=>n("provider"),disabled:g.isPending,children:[e.jsx(O,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs(o,{variant:"outline",onClick:t,disabled:w||g.isPending,children:[e.jsx(ne,{className:`w-4 h-4 mr-2 ${w?"animate-spin":""}`}),w?"Checking...":"Refresh Status"]})]})]}),a==="account"&&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 (",y.length,")"]}),e.jsx("div",{className:"grid gap-2",children:y.map(s=>e.jsxs("button",{type:"button",onClick:()=>le(s),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(V,{className:"w-4 h-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.email||s.id}),s.isDefault&&e.jsx("div",{className:"text-xs text-muted-foreground",children:"Default account"})]})]}),e.jsx(K,{className:"w-4 h-4 text-muted-foreground"})]},s.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:()=>{C(!0),n("auth")},children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(G,{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(o,{variant:"ghost",onClick:()=>n("provider"),children:[e.jsx(O,{className:"w-4 h-4 mr-2"}),"Back"]})})]}),a==="variant"&&e.jsxs("div",{className:"space-y-4",children:[r&&e.jsxs("div",{className:"flex items-center gap-2 p-2 bg-muted/50 rounded-md text-sm",children:[e.jsx(V,{className:"w-4 h-4"}),e.jsxs("span",{children:["Using: ",r.email||r.id]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{htmlFor:"variant-name",children:"Variant Name *"}),e.jsx(ee,{id:"variant-name",value:x,onChange:s=>f(s.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 ",x||"<name>",' "prompt"']})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T,{children:"Model"}),e.jsxs(ge,{value:j,onValueChange:S,children:[e.jsx(fe,{children:e.jsx(ve,{placeholder:"Select a model"})}),e.jsx(je,{children:P[d]?.models.map(s=>e.jsx(Ne,{value:s.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:s.name}),s.description&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["- ",s.description]})]})},s.id))})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Default: ",P[d]?.defaultModel||"provider default"]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs(o,{variant:"ghost",onClick:()=>y.length>0?n("account"):n("provider"),children:[e.jsx(O,{className:"w-4 h-4 mr-2"}),"Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o,{variant:"ghost",onClick:u,children:"Skip"}),e.jsx(o,{onClick:oe,disabled:!x||c.isPending,children:c.isPending?"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"})]}),a==="success"&&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(k,{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(E,{children:e.jsxs(B,{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 ",x,' "your prompt here"']})]})}),e.jsx(o,{onClick:u,className:"w-full",children:"Done"})]})]}),e.jsx("div",{className:"flex justify-center gap-1 pt-2",children:z.map((s,I)=>e.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${me>=I?"bg-primary":"bg-muted"}`},s))})]})})}function Fe({open:i,onClose:u,provider:a,displayName:n}){const[d,h]=l.useState(""),r=H(),v=()=>{r.mutate({provider:a,nickname:d.trim()||void 0},{onSuccess:()=>{h(""),u()}})},x=f=>{!f&&!r.isPending&&(h(""),u())};return e.jsx(Z,{open:i,onOpenChange:x,children:e.jsxs(J,{className:"sm:max-w-md",children:[e.jsxs(X,{children:[e.jsxs(Y,{children:["Add ",n," Account"]}),e.jsx(_,{children:"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(T,{htmlFor:"nickname",children:"Nickname (optional)"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{className:"w-4 h-4 text-muted-foreground"}),e.jsx(ee,{id:"nickname",value:d,onChange:f=>h(f.target.value),placeholder:"e.g., work, personal",disabled:r.isPending,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(o,{variant:"ghost",onClick:u,disabled:r.isPending,children:"Cancel"}),e.jsx(o,{onClick:v,disabled:r.isPending,children:r.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-4 h-4 mr-2 animate-spin"}),"Authenticating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-4 h-4 mr-2"}),"Authenticate"]})})]}),r.isPending&&e.jsx("p",{className:"text-sm text-center text-muted-foreground",children:"Complete the OAuth flow in your browser..."})]})]})})}function Oe({status:i,isSelected:u,onSelect:a}){const n=i.accounts?.length||0;return e.jsxs("button",{className:L("w-full flex items-center gap-3 px-3 py-2.5 rounded-lg transition-colors cursor-pointer text-left",u?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:a,children:[e.jsx(se,{provider:i.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:i.displayName}),n>0&&e.jsx(te,{variant:"secondary",className:"text-[10px] h-4 px-1",children:n})]}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:i.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(k,{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(de,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Not connected"})]})})]})]})}function Te({variant:i,parentAuth:u,isSelected:a,onSelect:n,onDelete:d,isDeleting:h}){return e.jsxs("button",{className:L("group w-full flex items-center gap-3 px-3 py-2 rounded-lg transition-colors cursor-pointer text-left pl-6",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:n,children:[e.jsxs("div",{className:"relative",children:[e.jsx(se,{provider:i.provider,size:"sm"}),e.jsx(re,{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:i.name}),e.jsx(te,{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:u?.authenticated?e.jsxs(e.Fragment,{children:[e.jsx(k,{className:"w-3 h-3 text-green-600"}),e.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["via ",i.provider]})]}):e.jsxs(e.Fragment,{children:[e.jsx(de,{className:"w-3 h-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Parent not connected"})]})})]}),e.jsx(o,{variant:"ghost",size:"icon",className:"h-6 w-6 opacity-0 group-hover:opacity-100 hover:text-destructive",onClick:r=>{r.stopPropagation(),d()},disabled:h,children:e.jsx(De,{className:"w-3 h-3"})})]})}function Ge({onSetup:i}){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(ie,{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(o,{onClick:i,className:"gap-2",children:[e.jsx(R,{className:"w-4 h-4"}),"Quick Setup"]})]})})}function Be(){const i=pe(),{data:u,isLoading:a}=W(),{data:n,isFetching:d}=we(),h=ye(),r=be(),v=Ce(),[x,f]=l.useState(null),[j,S]=l.useState(null),[D,N]=l.useState(!1),[w,b]=l.useState(null),m=u?.authStatus||[],C=n?.variants||[],A=l.useMemo(()=>j?null:x&&m.some(t=>t.provider===x)?x:m.length>0?m[0].provider:null,[x,j,m]),p=m.find(t=>t.provider===A),c=C.find(t=>t.name===j),g=c?m.find(t=>t.provider===c.provider):void 0,Q=()=>{i.invalidateQueries({queryKey:["cliproxy"]}),i.invalidateQueries({queryKey:["cliproxy-auth"]})},y=t=>{f(t),S(null)},M=t=>{S(t),f(null)};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex",children:[e.jsxs("div",{className:"w-64 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(ie,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:"CLIProxy"})]}),e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:Q,disabled:d,children:e.jsx(ne,{className:L("w-4 h-4",d&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"CCS-level account management"}),e.jsxs(o,{variant:"outline",size:"sm",className:"w-full gap-2",onClick:()=>N(!0),children:[e.jsx(R,{className:"w-4 h-4"}),"Quick Setup"]})]}),e.jsx(Se,{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"}),a?e.jsx("div",{className:"space-y-2 px-2",children:[1,2,3,4].map(t=>e.jsx(Ae,{className:"h-14 w-full rounded-lg"},t))}):e.jsx("div",{className:"space-y-1",children:m.map(t=>e.jsx(Oe,{status:t,isSelected:A===t.provider,onSelect:()=>y(t.provider)},t.provider))}),C.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(re,{className:"w-3 h-3"}),"Variants"]}),e.jsx("div",{className:"space-y-1",children:C.map(t=>e.jsx(Te,{variant:t,parentAuth:m.find(F=>F.provider===t.provider),isSelected:j===t.name,onSelect:()=>M(t.name),onDelete:()=>v.mutate(t.name),isDeleting:v.isPending},t.name))})]})]})}),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:[m.length," provider",m.length!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(k,{className:"w-3 h-3 text-green-600"}),m.filter(t=>t.authenticated).length," connected"]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background",children:c&&g?e.jsx($,{provider:c.name,displayName:`${c.name} (${c.provider} variant)`,authStatus:g,catalog:P[c.provider],logoProvider:c.provider,onAddAccount:()=>b({provider:c.provider,displayName:g.displayName}),onSetDefault:t=>h.mutate({provider:c.provider,accountId:t}),onRemoveAccount:t=>r.mutate({provider:c.provider,accountId:t}),isRemovingAccount:r.isPending}):p?e.jsx($,{provider:p.provider,displayName:p.displayName,authStatus:p,catalog:P[p.provider],onAddAccount:()=>b({provider:p.provider,displayName:p.displayName}),onSetDefault:t=>h.mutate({provider:p.provider,accountId:t}),onRemoveAccount:t=>r.mutate({provider:p.provider,accountId:t}),isRemovingAccount:r.isPending}):e.jsx(Ge,{onSetup:()=>N(!0)})}),e.jsx(Me,{open:D,onClose:()=>N(!1)}),e.jsx(Fe,{open:w!==null,onClose:()=>b(null),provider:w?.provider||"",displayName:w?.displayName||""})]})}export{Be as CliproxyPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./radix-ui-OFtPgiRV.js";import{r as s}from"./react-vendor-CjrBBxxX.js";import{G as b,R as d,f as g,K as j,X as p}from"./icons-CqXn5eV0.js";const N=8317,C="ccs";function y({port:t=N}){const n=s.useRef(null),[r,c]=s.useState(!0),[o,a]=s.useState(null),[x,l]=s.useState(!1),[m,u]=s.useState(!0),i=`http://localhost:${t}/management.html`;s.useEffect(()=>{(async()=>{try{(await fetch(`http://localhost:${t}/`,{signal:AbortSignal.timeout(2e3)})).ok?(l(!0),a(null)):(l(!1),a("CLIProxy returned an error"))}catch{l(!1),a("CLIProxy is not running")}})()},[t]);const h=s.useCallback(()=>{if(c(!1),n.current?.contentWindow)try{n.current.contentWindow.postMessage({type:"ccs-auto-login",apiBase:`http://localhost:${t}`,managementKey:C},`http://localhost:${t}`)}catch{console.debug("[ControlPanelEmbed] postMessage failed - cross-origin")}},[t]),f=()=>{c(!0),n.current&&(n.current.src=i)};return!x&&o?e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(b,{className:"w-5 h-5 text-primary"}),e.jsx("h2",{className:"font-semibold",children:"CLIProxy Control Panel"})]}),e.jsxs("button",{className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm border rounded-md hover:bg-muted",onClick:f,children:[e.jsx(d,{className:"w-4 h-4"}),"Retry"]})]}),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-destructive/10 flex items-center justify-center mx-auto mb-6",children:e.jsx(g,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"CLIProxy Not Available"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:o}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Start a CLIProxy session with"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs gemini"})," or run"," ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ccs config"})," which auto-starts it."]})]})})]}):e.jsxs("div",{className:"flex-1 flex flex-col relative",children:[m&&!r&&e.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-20",children:e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-blue-50 dark:bg-blue-950 border border-blue-200 dark:border-blue-800 rounded-md text-sm",children:[e.jsx(j,{className:"h-3.5 w-3.5 text-blue-600"}),e.jsxs("span",{children:["Key:"," ",e.jsx("code",{className:"bg-blue-100 dark:bg-blue-900 px-1 rounded font-mono font-semibold",children:"ccs"})]}),e.jsx("button",{className:"text-blue-600 hover:text-blue-800 dark:hover:text-blue-400",onClick:()=>u(!1),children:e.jsx(p,{className:"h-3.5 w-3.5"})})]})}),r&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/80 z-10",children:e.jsxs("div",{className:"text-center",children:[e.jsx(d,{className:"w-8 h-8 animate-spin text-primary mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading Control Panel..."})]})}),e.jsx("iframe",{ref:n,src:i,className:"flex-1 w-full border-0",title:"CLIProxy Management Panel",onLoad:h})]})}function R(){return e.jsx("div",{className:"h-[calc(100vh-100px)] flex flex-col",children:e.jsx(y,{})})}export{R as CliproxyControlPanelPage};
|