@kaitranntt/ccs 7.52.2-dev.1 → 7.52.2-dev.3
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/commands/copilot-command.d.ts.map +1 -1
- package/dist/commands/copilot-command.js +38 -0
- package/dist/commands/copilot-command.js.map +1 -1
- package/dist/copilot/copilot-models.d.ts.map +1 -1
- package/dist/copilot/copilot-models.js +55 -13
- package/dist/copilot/copilot-models.js.map +1 -1
- package/dist/copilot/types.d.ts +10 -0
- package/dist/copilot/types.d.ts.map +1 -1
- package/dist/ui/assets/{accounts-szAllF_0.js → accounts-IsT_BiCd.js} +1 -1
- package/dist/ui/assets/{alert-dialog-DPdKlUG9.js → alert-dialog-QYUhRzXK.js} +1 -1
- package/dist/ui/assets/{api-Bq7TnM0v.js → api-BYUVLPig.js} +1 -1
- package/dist/ui/assets/{auth-section-DYPWbNRj.js → auth-section-CqMQGbDM.js} +1 -1
- package/dist/ui/assets/{backups-section-gIWfCGmR.js → backups-section-htDdMLh5.js} +1 -1
- package/dist/ui/assets/{checkbox-CcX8-GfD.js → checkbox-DGiQ22i1.js} +1 -1
- package/dist/ui/assets/{cliproxy-SS8eRAX0.js → cliproxy-BpQHL05v.js} +1 -1
- package/dist/ui/assets/{cliproxy-control-panel-Bu0TtDft.js → cliproxy-control-panel-CCdMLyj2.js} +1 -1
- package/dist/ui/assets/{confirm-dialog-BZj0PYFs.js → confirm-dialog-DDdeYI2H.js} +1 -1
- package/dist/ui/assets/copilot-DFaXcekY.js +3 -0
- package/dist/ui/assets/{cursor-rS1S0i_y.js → cursor-DepYQY1w.js} +1 -1
- package/dist/ui/assets/{droid-Dfc2QwbE.js → droid-CTtRivEr.js} +1 -1
- package/dist/ui/assets/{globalenv-section-BrHb5lRq.js → globalenv-section-CljFwX-s.js} +1 -1
- package/dist/ui/assets/{health-B0WQPDXb.js → health-D6oasd62.js} +1 -1
- package/dist/ui/assets/{index-BFTIN2qO.js → index-CGPdFYiT.js} +1 -1
- package/dist/ui/assets/{index-BVBXszJi.js → index-CK9IG4x4.js} +1 -1
- package/dist/ui/assets/{index-DxKsP0Ke.js → index-CeXOFv5d.js} +1 -1
- package/dist/ui/assets/{index-DCQkhmoo.js → index-CmZS09IA.js} +2 -2
- package/dist/ui/assets/{index-LHbr_5SB.js → index-Diuv26bz.js} +1 -1
- package/dist/ui/assets/{proxy-status-widget-DPXgRGkB.js → proxy-status-widget-exblPwy_.js} +1 -1
- package/dist/ui/assets/{separator-DtcqgZIS.js → separator-CSt5QZvu.js} +1 -1
- package/dist/ui/assets/{shared-DPJ_z23p.js → shared-CbdTTMNS.js} +1 -1
- package/dist/ui/assets/{switch-BL5xZtnr.js → switch-CTrO47Q-.js} +1 -1
- package/dist/ui/assets/{updates-B3HKUp7y.js → updates-BBghSoYr.js} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/utils/error-codes.d.ts +1 -1
- package/dist/utils/error-codes.d.ts.map +1 -1
- package/dist/utils/error-codes.js +11 -6
- package/dist/utils/error-codes.js.map +1 -1
- package/lib/error-codes.ps1 +14 -4
- package/lib/error-codes.sh +10 -6
- package/package.json +1 -1
- package/dist/ui/assets/copilot-DnJj3frU.js +0 -3
package/lib/error-codes.sh
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# CCS Error Codes
|
|
3
|
-
# Documentation:
|
|
3
|
+
# Documentation: https://docs.ccs.kaitran.ca/reference/error-codes
|
|
4
|
+
|
|
5
|
+
readonly ERROR_CODE_DOCS_BASE_URL="https://docs.ccs.kaitran.ca/reference/error-codes"
|
|
4
6
|
|
|
5
7
|
# Configuration Errors (E100-E199)
|
|
6
8
|
readonly E_CONFIG_MISSING="E101"
|
|
7
9
|
readonly E_CONFIG_INVALID_JSON="E102"
|
|
8
10
|
readonly E_CONFIG_INVALID_PROFILE="E103"
|
|
9
11
|
|
|
10
|
-
# Profile Management Errors (
|
|
12
|
+
# Profile Management Errors (E104-E107)
|
|
11
13
|
readonly E_PROFILE_NOT_FOUND="E104"
|
|
12
14
|
readonly E_PROFILE_ALREADY_EXISTS="E105"
|
|
13
15
|
readonly E_PROFILE_CANNOT_DELETE_DEFAULT="E106"
|
|
@@ -37,7 +39,9 @@ readonly E_INVALID_STATE="E901"
|
|
|
37
39
|
# Get error documentation URL
|
|
38
40
|
get_error_doc_url() {
|
|
39
41
|
local error_code="$1"
|
|
40
|
-
|
|
42
|
+
local lowercase_code
|
|
43
|
+
lowercase_code="$(printf '%s' "$error_code" | tr '[:upper:]' '[:lower:]')"
|
|
44
|
+
echo "${ERROR_CODE_DOCS_BASE_URL}#${lowercase_code}"
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
# Get error category from code
|
|
@@ -45,10 +49,10 @@ get_error_category() {
|
|
|
45
49
|
local error_code="$1"
|
|
46
50
|
local code="${error_code#E}"
|
|
47
51
|
|
|
48
|
-
if [[ $
|
|
49
|
-
echo "Configuration"
|
|
50
|
-
elif [[ $code -ge 200 && $code -lt 300 ]]; then
|
|
52
|
+
if [[ "$error_code" == "$E_PROFILE_NOT_FOUND" || "$error_code" == "$E_PROFILE_ALREADY_EXISTS" || "$error_code" == "$E_PROFILE_CANNOT_DELETE_DEFAULT" || "$error_code" == "$E_PROFILE_INVALID_NAME" ]]; then
|
|
51
53
|
echo "Profile Management"
|
|
54
|
+
elif [[ $code -ge 100 && $code -lt 200 ]]; then
|
|
55
|
+
echo "Configuration"
|
|
52
56
|
elif [[ $code -ge 300 && $code -lt 400 ]]; then
|
|
53
57
|
echo "Claude CLI Detection"
|
|
54
58
|
elif [[ $code -ge 400 && $code -lt 500 ]]; then
|
package/package.json
CHANGED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{j as e}from"./radix-ui-BR1vy4kf.js";import{aY as j,aZ as ye,B as b,d as v,a as X,r as ce,s as re,t as de,v as ue,ao as be,ap as Se,w as J,V as W,n as K,L as S,I as ae,x as me,a_ as Ce,S as y,Q as Pe,R as ke,U as V,a$ as Fe,c as Y}from"./index-DCQkhmoo.js";import{r as N}from"./react-vendor-CNOkPC89.js";import{a as Me,u as M,b as C}from"./tanstack-e99Cjjy2.js";import{C as Te}from"./confirm-dialog-BZj0PYFs.js";import{R as xe,L as pe,ai as Le,k as Re,a2 as Ae,Z as ne,J as Ee,al as Oe,b as _e,T as qe,a5 as De,ar as Ie,ay as ie,K as Ue,I as Qe,az as Je,u as he,v as ge}from"./icons-BYZM_9Gm.js";import{S as Z}from"./separator-DtcqgZIS.js";import{S as $}from"./switch-BL5xZtnr.js";import{t as T}from"./notifications-B2HqRBj7.js";import"./utils-CzKF5WmX.js";import"./form-utils-Cn_Uld6y.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-DPdKlUG9.js";async function Ke(){const t=await fetch(j("/copilot/status"));if(!t.ok)throw new Error("Failed to fetch copilot status");return t.json()}async function ze(){const t=await fetch(j("/copilot/config"));if(!t.ok)throw new Error("Failed to fetch copilot config");return t.json()}async function Be(){const t=await fetch(j("/copilot/models"));if(!t.ok)throw new Error("Failed to fetch copilot models");return t.json()}async function Ge(){const t=await fetch(j("/copilot/settings/raw"));if(!t.ok)throw new Error("Failed to fetch copilot raw settings");return t.json()}async function Ve(t){const s=await fetch(j("/copilot/config"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!s.ok)throw new Error("Failed to update copilot config");return s.json()}async function $e(t){const s=await fetch(j("/copilot/settings/raw"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.status===409)throw new ye("Copilot raw settings changed externally");if(!s.ok)throw new Error("Failed to save copilot raw settings");return s.json()}async function He(){const t=await fetch(j("/copilot/auth/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start auth");return t.json()}async function Ye(){const t=await fetch(j("/copilot/daemon/start"),{method:"POST"});if(!t.ok)throw new Error("Failed to start daemon");return t.json()}async function Ze(){const t=await fetch(j("/copilot/daemon/stop"),{method:"POST"});if(!t.ok)throw new Error("Failed to stop daemon");return t.json()}async function Xe(){const t=await fetch(j("/copilot/info"));if(!t.ok)throw new Error("Failed to fetch copilot info");return t.json()}async function We(t){const s=await fetch(j("/copilot/install"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{version:t}:{})});if(!s.ok)throw new Error("Failed to install copilot-api");return s.json()}function fe(){const t=Me(),s=M({queryKey:["copilot-status"],queryFn:Ke,refetchInterval:5e3}),o=M({queryKey:["copilot-config"],queryFn:ze}),d=M({queryKey:["copilot-models"],queryFn:Be}),a=M({queryKey:["copilot-raw-settings"],queryFn:Ge}),c=M({queryKey:["copilot-info"],queryFn:Xe}),l=C({mutationFn:Ve,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),u=C({mutationFn:$e,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-config"]}),t.invalidateQueries({queryKey:["copilot-raw-settings"]})}}),i=C({mutationFn:He,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),h=C({mutationFn:Ye,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),g=C({mutationFn:Ze,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]})}}),n=C({mutationFn:We,onSuccess:()=>{t.invalidateQueries({queryKey:["copilot-status"]}),t.invalidateQueries({queryKey:["copilot-info"]})}});return N.useMemo(()=>({status:s.data,statusLoading:s.isLoading,statusError:s.error,refetchStatus:s.refetch,config:o.data,configLoading:o.isLoading,models:d.data?.models??[],currentModel:d.data?.current,modelsLoading:d.isLoading,rawSettings:a.data,rawSettingsLoading:a.isLoading,refetchRawSettings:a.refetch,updateConfig:l.mutate,updateConfigAsync:l.mutateAsync,isUpdating:l.isPending,saveRawSettings:u.mutate,saveRawSettingsAsync:u.mutateAsync,isSavingRawSettings:u.isPending,startAuth:i.mutate,startAuthAsync:i.mutateAsync,isAuthenticating:i.isPending,authResult:i.data,startDaemon:h.mutate,isStartingDaemon:h.isPending,stopDaemon:g.mutate,isStoppingDaemon:g.isPending,info:c.data,infoLoading:c.isLoading,refetchInfo:c.refetch,install:n.mutate,installAsync:n.mutateAsync,isInstalling:n.isPending}),[s.data,s.isLoading,s.error,s.refetch,o.data,o.isLoading,d.data,d.isLoading,a.data,a.isLoading,a.refetch,l.mutate,l.mutateAsync,l.isPending,u.mutate,u.mutateAsync,u.isPending,i.mutate,i.mutateAsync,i.isPending,i.data,h.mutate,h.isPending,g.mutate,g.isPending,c.data,c.isLoading,c.refetch,n.mutate,n.mutateAsync,n.isPending])}function et({rawSettings:t,rawSettingsLoading:s,isUpdating:o,isSavingRawSettings:d,hasChanges:a,isRawJsonValid:c,onRefresh:l,onSave:u}){return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Copilot Configuration"}),t&&e.jsx(b,{variant:"outline",className:"text-xs",children:"copilot.settings.json"})]}),t&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified:"," ",t.exists?new Date(t.mtime).toLocaleString():"Never saved"]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{variant:"ghost",size:"sm",onClick:l,disabled:s,children:e.jsx(xe,{className:`w-4 h-4 ${s?"animate-spin":""}`})}),e.jsx(v,{size:"sm",onClick:u,disabled:o||d||!a||!c,children:o||d?e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Le,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}const tt=[{name:"GPT-4.1 (Free)",description:"Free tier - no premium usage",default:"gpt-4.1",opus:"gpt-4.1",sonnet:"gpt-4.1",haiku:"gpt-4.1"},{name:"GPT-5 Mini (Free)",description:"Free tier - lightweight model",default:"gpt-5-mini",opus:"gpt-5-mini",sonnet:"gpt-5-mini",haiku:"gpt-5-mini"},{name:"Raptor Mini (Free)",description:"Free tier - fine-tuned for coding",default:"raptor-mini",opus:"raptor-mini",sonnet:"raptor-mini",haiku:"raptor-mini"}],st=[{name:"Claude Opus 4.5",description:"Pro+ (3x) - Most capable reasoning",default:"claude-opus-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"Claude Sonnet 4.5",description:"Pro+ (1x) - Balanced performance",default:"claude-sonnet-4.5",opus:"claude-opus-4.5",sonnet:"claude-sonnet-4.5",haiku:"claude-haiku-4.5"},{name:"GPT-5.2",description:"Pro+ (1x) - Latest OpenAI (Preview)",default:"gpt-5.2",opus:"gpt-5.2",sonnet:"gpt-5.1",haiku:"gpt-5-mini"},{name:"GPT-5.1 Codex Max",description:"Pro+ (1x) - Best for coding",default:"gpt-5.1-codex-max",opus:"gpt-5.1-codex-max",sonnet:"gpt-5.1-codex",haiku:"gpt-5.1-codex-mini"},{name:"Gemini 2.5 Pro",description:"Pro+ (1x) - Google latest",default:"gemini-2.5-pro",opus:"gemini-2.5-pro",sonnet:"gemini-2.5-pro",haiku:"gemini-3-flash"}];function oe(t){switch(t){case"free":return"bg-green-100 text-green-700 border-green-200";case"pro":return"bg-blue-100 text-blue-700 border-blue-200";case"pro+":return"bg-purple-100 text-purple-700 border-purple-200";case"business":return"bg-orange-100 text-orange-700 border-orange-200";case"enterprise":return"bg-red-100 text-red-700 border-red-200";default:return"bg-muted text-muted-foreground"}}function at(t){return t==null?null:t===0?"Free":t<1?`${t}x`:t===1?"1x":`${t}x`}function I({label:t,description:s,value:o,onChange:d,models:a,disabled:c}){const{t:l}=X(),u=a.find(i=>i.id===o);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",children:t}),s&&e.jsx("p",{className:"text-[10px] text-muted-foreground",children:s})]}),e.jsxs(ce,{value:o||"",onValueChange:d,disabled:c,children:[e.jsx(re,{className:"h-9",children:e.jsx(de,{placeholder:l("componentModelSelector.selectModel"),children:o&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:o}),u?.minPlan&&e.jsx(b,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${oe(u.minPlan)}`,children:u.minPlan})]})})}),e.jsx(ue,{className:"max-h-[300px]",children:e.jsxs(be,{children:[e.jsx(Se,{className:"text-xs text-muted-foreground",children:l("componentModelSelector.availableModelsCount",{count:a.length})}),a.map(i=>e.jsx(J,{value:i.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:i.name||i.id}),i.minPlan&&e.jsx(b,{variant:"outline",className:`text-[9px] px-1 py-0 h-4 ${oe(i.minPlan)}`,children:i.minPlan}),i.multiplier!==void 0&&e.jsx("span",{className:"text-[9px] text-muted-foreground",children:at(i.multiplier)}),i.preview&&e.jsx(b,{variant:"secondary",className:"text-[9px] px-1 py-0 h-4",children:l("componentModelSelector.preview")}),o===i.id&&e.jsx(Re,{className:"w-3 h-3 text-primary ml-auto"})]})},i.id))]})})]})]})}function nt({currentModel:t,opusModel:s,sonnetModel:o,haikuModel:d,models:a,modelsLoading:c,onApplyPreset:l,onUpdateModel:u,onUpdateOpusModel:i,onUpdateSonnetModel:h,onUpdateHaikuModel:g}){return e.jsx(W,{value:"config",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(K,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[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:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b,{variant:"outline",className:"text-[10px] bg-green-100 text-green-700 border-green-200",children:"Free Tier"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"No premium usage count"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:tt.map(n=>e.jsxs(v,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>l(n),title:n.description,children:[e.jsx(ne,{className:"w-3 h-3 text-green-600"}),n.name]},n.name))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(b,{variant:"outline",className:"text-[10px] bg-blue-100 text-blue-700 border-blue-200",children:"Pro+ Required"}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Uses premium request quota"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:st.map(n=>e.jsxs(v,{variant:"outline",size:"sm",className:"text-xs h-7 gap-1",onClick:()=>l(n),title:n.description,children:[e.jsx(ne,{className:"w-3 h-3"}),n.name]},n.name))})]})]}),e.jsx(Z,{}),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(I,{label:"Default Model",description:"Used when no specific tier is requested",value:t,onChange:u,models:a,disabled:c}),e.jsx(I,{label:"Opus (Most capable)",description:"For complex reasoning tasks",value:s||t,onChange:i,models:a,disabled:c}),e.jsx(I,{label:"Sonnet (Balanced)",description:"Balance of speed and capability",value:o||t,onChange:h,models:a,disabled:c}),e.jsx(I,{label:"Haiku (Fast)",description:"Quick responses for simple tasks",value:d||t,onChange:g,models:a,disabled:c})]})]})]})})})}function it({enabled:t,autoStart:s,port:o,accountType:d,rateLimit:a,waitOnLimit:c,onUpdateEnabled:l,onUpdateAutoStart:u,onUpdatePort:i,onUpdateAccountType:h,onUpdateRateLimit:g,onUpdateWaitOnLimit:n}){const{t:m}=X();return e.jsx(W,{value:"settings",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden",children:e.jsx(K,{className:"flex-1",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{htmlFor:"enabled",className:"text-sm font-medium",children:m("copilotSettings.enableCopilot")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:m("copilotSettings.enableCopilotDesc")})]}),e.jsx($,{id:"enabled",checked:t,onCheckedChange:l})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:m("copilotSettings.basicSettings")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"port",className:"text-xs",children:m("copilotPage.port")}),e.jsx(ae,{id:"port",type:"number",value:o,onChange:p=>i(parseInt(p.target.value,10)),min:1024,max:65535,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"account-type",className:"text-xs",children:m("copilotSettings.accountType")}),e.jsxs(ce,{value:d,onValueChange:h,children:[e.jsx(re,{id:"account-type",className:"max-w-[150px] h-8",children:e.jsx(de,{})}),e.jsxs(ue,{children:[e.jsx(J,{value:"individual",children:m("copilotSettings.accountTypeIndividual")}),e.jsx(J,{value:"business",children:m("copilotSettings.accountTypeBusiness")}),e.jsx(J,{value:"enterprise",children:m("copilotSettings.accountTypeEnterprise")})]})]})]})]}),e.jsx(Z,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:m("copilotSettings.rateLimiting")}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{htmlFor:"rate-limit",className:"text-xs",children:m("copilotSettings.rateLimitSeconds")}),e.jsx(ae,{id:"rate-limit",type:"number",value:a,onChange:p=>g(p.target.value),placeholder:m("copilotSettings.noLimit"),min:0,className:"max-w-[150px] h-8"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{htmlFor:"wait-on-limit",className:"text-xs",children:m("copilotSettings.waitOnRateLimit")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:m("copilotSettings.waitOnRateLimitDesc")})]}),e.jsx($,{id:"wait-on-limit",checked:c,onCheckedChange:n})]})]}),e.jsx(Z,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium",children:m("copilotSettings.daemonSettings")}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(S,{htmlFor:"auto-start",className:"text-xs",children:m("copilotSettings.autoStartDaemon")}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:m("copilotSettings.autoStartDaemonDesc")})]}),e.jsx($,{id:"auto-start",checked:s,onCheckedChange:u})]})]})]})})})}function U({label:t,command:s}){return e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:t}),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:s}),e.jsx(me,{value:s,size:"icon",className:"h-6 w-6"})]})]})}function ot({rawSettings:t}){return e.jsx(W,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(K,{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(Ee,{className:"w-4 h-4"}),"Configuration Info"]}),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:"GitHub Copilot"})]}),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(me,{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:"Status"}),e.jsx(b,{variant:"outline",className:t.exists?"w-fit text-green-600 border-green-200 bg-green-50":"w-fit text-muted-foreground",children:t.exists?"File exists":"Using defaults"})]})]})]})]}),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(U,{label:"Run with Copilot",command:"ccs copilot"}),e.jsx(U,{label:"Authenticate",command:"ccs copilot auth"}),e.jsx(U,{label:"Start daemon",command:"ccs copilot --start"}),e.jsx(U,{label:"Stop daemon",command:"ccs copilot --stop"})]})]})]})})})}const lt=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"];function le(t){const s=t?.env||{};return lt.filter(o=>!s[o]?.trim())}function ct(){const{config:t,configLoading:s,models:o,modelsLoading:d,rawSettings:a,rawSettingsLoading:c,updateConfigAsync:l,isUpdating:u,saveRawSettingsAsync:i,isSavingRawSettings:h,refetchRawSettings:g}=fe(),[n,m]=N.useState({}),[p,P]=N.useState(null),[z,L]=N.useState(!1),R=n.enabled??t?.enabled??!1,A=n.autoStart??t?.auto_start??!1,k=n.port??t?.port??4141,E=n.accountType??t?.account_type??"individual",O=n.model??t?.model??"claude-sonnet-4-5-20250929",f=n.rateLimit??t?.rate_limit?.toString()??"",_=n.waitOnLimit??t?.wait_on_limit??!0,q=n.opusModel??t?.opus_model??"",D=n.sonnetModel??t?.sonnet_model??"",F=n.haikuModel??t?.haiku_model??"",B=(x,w)=>{m(we=>({...we,[x]:w}))},G=x=>{m(w=>({...w,model:x.default,opusModel:x.opus,sonnetModel:x.sonnet,haikuModel:x.haiku})),T.success(`Applied "${x.name}" preset`)},r=N.useMemo(()=>p!==null?p:a?.settings?JSON.stringify(a.settings,null,2):`{
|
|
2
|
-
"env": {}
|
|
3
|
-
}`,[p,a]),je=N.useCallback(x=>{P(x)},[]),ee=N.useMemo(()=>{try{return JSON.parse(r),!0}catch{return!1}},[r]),Ne=N.useMemo(()=>{const x=Object.keys(n).length>0,w=p!==null&&p!==JSON.stringify(a?.settings,null,2);return x||w},[n,p,a]),te=N.useMemo(()=>{if(p!==null)try{return JSON.parse(p)}catch{return a?.settings}return a?.settings},[p,a?.settings]),ve=N.useMemo(()=>le(te),[te]),se=async()=>{try{if(Object.keys(n).length>0&&await l({enabled:R,auto_start:A,port:k,account_type:E,model:O,rate_limit:f?parseInt(f,10):null,wait_on_limit:_,opus_model:q||void 0,sonnet_model:D||void 0,haiku_model:F||void 0}),p!==null&&ee){const x=JSON.parse(r),w=le(x);await i({settings:x,expectedMtime:a?.mtime}),w.length>0?T.success("Copilot configuration saved",{description:`Missing fields will use defaults: ${w.join(", ")}`}):T.success("Copilot configuration saved")}else T.success("Copilot configuration saved");m({}),P(null)}catch(x){Ce(x)?L(!0):T.error("Failed to save settings")}};return{configLoading:s,rawSettingsLoading:c,modelsLoading:d,isUpdating:u,isSavingRawSettings:h,models:o,rawSettings:a,rawJsonContent:r,rawJsonEdits:p,enabled:R,autoStart:A,port:k,accountType:E,currentModel:O,rateLimit:f,waitOnLimit:_,opusModel:q,sonnetModel:D,haikuModel:F,isRawJsonValid:ee,hasChanges:Ne,conflictDialog:z,updateField:B,applyPreset:G,handleRawJsonChange:je,handleSave:se,handleConflictResolve:async x=>{L(!1),x?(await g(),se()):P(null)},refetchRawSettings:g,missingRequiredFields:ve}}function rt(){const{configLoading:t,rawSettingsLoading:s,modelsLoading:o,isUpdating:d,isSavingRawSettings:a,models:c,rawSettings:l,rawJsonContent:u,rawJsonEdits:i,enabled:h,autoStart:g,port:n,accountType:m,currentModel:p,rateLimit:P,waitOnLimit:z,opusModel:L,sonnetModel:R,haikuModel:A,isRawJsonValid:k,hasChanges:E,conflictDialog:O,updateField:f,applyPreset:_,handleRawJsonChange:q,handleSave:D,handleConflictResolve:F,refetchRawSettings:B,missingRequiredFields:G}=ct();return t||s?e.jsxs("div",{className:"space-y-6",children:[e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"}),e.jsx(y,{className:"h-10 w-full"})]}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(et,{rawSettings:l,rawSettingsLoading:s,isUpdating:d,isSavingRawSettings:a,hasChanges:E,isRawJsonValid:k,onRefresh:()=>B(),onSave:D}),e.jsxs("div",{className:"flex-1 flex divide-x overflow-hidden",children:[e.jsx("div",{className:"w-[540px] shrink-0 flex flex-col overflow-hidden bg-muted/5",children:e.jsx("div",{className:"h-full flex flex-col",children:e.jsxs(Pe,{defaultValue:"config",className:"h-full flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(ke,{className:"w-full",children:[e.jsx(V,{value:"config",className:"flex-1",children:"Model Config"}),e.jsx(V,{value:"settings",className:"flex-1",children:"Settings"}),e.jsx(V,{value:"info",className:"flex-1",children:"Info"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[e.jsx(nt,{currentModel:p,opusModel:L,sonnetModel:R,haikuModel:A,models:c,modelsLoading:o,onApplyPreset:_,onUpdateModel:r=>f("model",r),onUpdateOpusModel:r=>f("opusModel",r),onUpdateSonnetModel:r=>f("sonnetModel",r),onUpdateHaikuModel:r=>f("haikuModel",r)}),e.jsx(it,{enabled:h,autoStart:g,port:n,accountType:m,rateLimit:P,waitOnLimit:z,onUpdateEnabled:r=>f("enabled",r),onUpdateAutoStart:r=>f("autoStart",r),onUpdatePort:r=>f("port",r),onUpdateAccountType:r=>f("accountType",r),onUpdateRateLimit:r=>f("rateLimit",r),onUpdateWaitOnLimit:r=>f("waitOnLimit",r)}),e.jsx(ot,{rawSettings:l})]})]})})}),e.jsxs("div",{className:"flex-1 min-w-0 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(Oe,{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(Fe,{rawJsonContent:u,isRawJsonValid:k,rawJsonEdits:i,rawSettingsEnv:l?.settings?.env,onChange:q,missingRequiredFields:G})]})]}),e.jsx(Te,{open:O,title:"File Modified Externally",description:"This settings file was modified by another process. Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>F(!0),onCancel:()=>F(!1)})]})}function H({title:t,children:s}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide px-3",children:t}),e.jsx("div",{className:"space-y-1",children:s})]})}function Q({icon:t,label:s,status:o,statusText:d,variant:a="default"}){return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg bg-muted/50",children:[e.jsx(t,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("span",{className:"text-sm",children:s})}),e.jsx("div",{className:"flex items-center gap-1.5",children:o?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:Y("w-4 h-4",a==="warning"?"text-yellow-500":"text-green-500")}),e.jsx("span",{className:Y("text-xs",a==="warning"?"text-yellow-500":"text-green-500"),children:d||"Yes"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:d||"No"})]})})]})}function dt(){return e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsx(y,{className:"h-8 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"}),e.jsx(y,{className:"h-12 w-full"})]})}function Ct(){const{t}=X(),{status:s,statusLoading:o,refetchStatus:d,startAuth:a,isAuthenticating:c,startDaemon:l,isStartingDaemon:u,stopDaemon:i,isStoppingDaemon:h,install:g,isInstalling:n}=fe();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 shrink-0",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(_e,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:t("copilotPage.title")})]}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>d(),disabled:o,children:e.jsx(xe,{className:Y("w-4 h-4",o&&"animate-spin")})})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("copilotPage.subtitle")})]}),e.jsx(K,{className:"flex-1",children:o?e.jsx(dt,{}):e.jsxs("div",{className:"p-3 space-y-4",children:[e.jsxs("div",{className:"rounded-md border border-yellow-500/50 bg-yellow-500/15 p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qe,{className:"h-4 w-4 text-yellow-600 dark:text-yellow-400 shrink-0"}),e.jsx("span",{className:"text-xs font-semibold text-yellow-800 dark:text-yellow-200",children:t("copilotPage.unofficialTitle")})]}),e.jsxs("ul",{className:"text-[11px] text-yellow-700 dark:text-yellow-300 space-y-0.5 pl-6 list-disc",children:[e.jsx("li",{children:t("copilotPage.unofficialItem1")}),e.jsx("li",{children:t("copilotPage.unofficialItem2")}),e.jsx("li",{children:t("copilotPage.unofficialItem3")})]})]}),e.jsxs(H,{title:t("copilotPage.setup"),children:[e.jsx(Q,{icon:De,label:"copilot-api",status:s?.installed??!1,statusText:s?.installed?s.version?`v${s.version}`:t("copilotPage.installed"):t("copilotPage.missing")}),!s?.installed&&e.jsx(v,{size:"sm",className:"w-full mt-2",onClick:()=>g(void 0),disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(pe,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),t("copilotPage.installing")]}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{className:"w-3.5 h-3.5 mr-1.5"}),t("copilotPage.installCopilotApi")]})}),s?.installed&&e.jsx(Q,{icon:ie,label:t("copilotPage.integration"),status:s?.enabled??!1,statusText:s?.enabled?t("copilotPage.enabled"):t("copilotPage.disabled")})]}),s?.installed&&e.jsxs(H,{title:t("copilotPage.auth"),children:[e.jsx(Q,{icon:Ue,label:t("copilotPage.github"),status:s?.authenticated??!1,statusText:s?.authenticated?t("copilotPage.connected"):t("copilotPage.notConnected")}),!s?.authenticated&&e.jsx(v,{size:"sm",className:"w-full mt-2",onClick:()=>a(),disabled:c,children:t(c?"copilotPage.authenticating":"copilotPage.authenticate")})]}),s?.authenticated&&e.jsxs(H,{title:t("copilotPage.daemon"),children:[e.jsx(Q,{icon:Qe,label:t("copilotPage.status"),status:s?.daemon_running??!1,statusText:s?.daemon_running?t("copilotPage.running"):t("copilotPage.stopped")}),e.jsxs("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:[t("copilotPage.port"),": ",s?.port??4141]}),e.jsx("div",{className:"px-1",children:s?.daemon_running?e.jsxs(v,{size:"sm",variant:"outline",className:"w-full",onClick:()=>i(),disabled:h,children:[e.jsx(Je,{className:"w-3.5 h-3.5 mr-1.5"}),t(h?"copilotPage.stopping":"copilotPage.stop")]}):e.jsxs(v,{size:"sm",variant:"outline",className:"w-full",onClick:()=>l(),disabled:u,children:[e.jsx(ie,{className:"w-3.5 h-3.5 mr-1.5"}),t(u?"copilotPage.starting":"copilotPage.start")]})})]})]})}),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.jsx("span",{children:t("copilotPage.proxy")}),s?.daemon_running?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(he,{className:"w-3 h-3 text-green-500"}),t("copilotPage.active")]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ge,{className:"w-3 h-3 text-muted-foreground"}),t("copilotPage.inactive")]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-background overflow-hidden",children:e.jsx(rt,{})})]})}export{Ct as CopilotPage};
|