@deepseekcode/cli 1.0.10 → 1.0.11
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/cli.js +505 -505
- package/package.json +2 -2
- package/web/dist/assets/{AgentFlowView-CRwXzsUU.js → AgentFlowView-CZQeHyLi.js} +1 -1
- package/web/dist/assets/{AgentsView-CDY8XrTg.js → AgentsView-CfQ-EXdY.js} +1 -1
- package/web/dist/assets/{AskQuestionModal-CKt1m8Jo.js → AskQuestionModal-DGd7VFFR.js} +1 -1
- package/web/dist/assets/{AuditView-DbfHUxzt.js → AuditView-BVyD7ivS.js} +1 -1
- package/web/dist/assets/{AutomationView-Cy1-vLAP.js → AutomationView-3dP2f6BZ.js} +1 -1
- package/web/dist/assets/{ChannelConfigView-CprbcO4h.js → ChannelConfigView-BXvSck5e.js} +1 -1
- package/web/dist/assets/{FileTreeView-CbGQmQay.js → FileTreeView-HfjwdQz9.js} +1 -1
- package/web/dist/assets/{HookApprovalModal-DU0Gen9V.js → HookApprovalModal-dGHgJ_pM.js} +1 -1
- package/web/dist/assets/{HookConfigView-bKFZ-DDV.js → HookConfigView-F6uvScie.js} +2 -2
- package/web/dist/assets/{InboxView-B5puastg.js → InboxView-DQ1i65AD.js} +1 -1
- package/web/dist/assets/{ModelsView-Df8fwn3X.js → ModelsView-CsOKSn0l.js} +1 -1
- package/web/dist/assets/{SessionGrid-BPcnOjbx.js → SessionGrid-DPDDTcff.js} +10 -10
- package/web/dist/assets/{SettingsPanel-CWlTCD1c.js → SettingsPanel-D96vsDCf.js} +1 -1
- package/web/dist/assets/{SkillsView-m_a2rauP.js → SkillsView-DsRZm-UY.js} +1 -1
- package/web/dist/assets/{TerminalView-UaCcIjqn.js → TerminalView-CMmJ55Zj.js} +1 -1
- package/web/dist/assets/{ToolsView-DH4XhAov.js → ToolsView-CHJ8k68t.js} +1 -1
- package/web/dist/assets/{hookRisk-BkOtQiAS.js → hookRisk-DsIEdNpD.js} +1 -1
- package/web/dist/assets/{index-Bpfxw0Lr.js → index-DGWtPRgs.js} +2 -2
- package/web/dist/assets/index-DuBeChMI.css +1 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-xDhqs-ld.css +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as e}from"./markdown-BUScHEtT.js";import{r,p as U,F as ee,o as te,ad as se,B as ae,y as _,aE as re,aF as G,aG as ne,aH as oe,aI as le,aA as ce,aJ as ie,aK as de,aL as ue,I as xe}from"./icons-uody4X-4.js";import{a as y,t as i,e as H,g as me,c as he,T as ge,D as pe,w as K,n as O}from"./index-
|
|
1
|
+
import{j as e}from"./markdown-BUScHEtT.js";import{r,p as U,F as ee,o as te,ad as se,B as ae,y as _,aE as re,aF as G,aG as ne,aH as oe,aI as le,aA as ce,aJ as ie,aK as de,aL as ue,I as xe}from"./icons-uody4X-4.js";import{a as y,t as i,e as H,g as me,c as he,T as ge,D as pe,w as K,n as O}from"./index-DGWtPRgs.js";import"./react-vendor-C5NlWs7r.js";import"./state-DKyBAq9j.js";const D=r.memo(function({title:d,subtitle:s,enabled:c,onChange:l}){return e.jsxs("div",{className:"flex items-center justify-between p-3 bg-dark-bg rounded-lg",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:d}),e.jsx("div",{className:"text-xs text-dark-muted",children:s})]}),e.jsx("button",{onClick:()=>l(!c),className:`relative w-12 h-6 rounded-full transition-colors ${c?"bg-accent-green":"bg-dark-border"}`,children:e.jsx("span",{className:`absolute top-1 w-4 h-4 bg-white rounded-full transition-transform ${c?"left-7":"left-1"}`})})]})});function be(o){return o<1024?`${o} B`:o<1024*1024?`${(o/1024).toFixed(1)} KB`:`${(o/(1024*1024)).toFixed(1)} MB`}function fe(o){return new Date(o).toLocaleString()}function ke(){const[o,d]=r.useState([]),[s,c]=r.useState(null),[l,p]=r.useState(""),[b,v]=r.useState(""),[m,n]=r.useState(!1),[g,T]=r.useState(!1),N=r.useCallback(async()=>{n(!0);try{const a=await y.config.files.list();a.success&&Array.isArray(a.data)&&d(a.data)}catch{i.error("Failed to load config files")}finally{n(!1)}},[]),I=r.useCallback(async a=>{try{const S=await y.config.files.read(a);if(S.success&&S.data){const f=S.data;c(f.name),p(f.content),v(f.content)}}catch{i.error(`Failed to read ${a}`)}},[]);r.useEffect(()=>{N()},[N]);const L=r.useCallback(async()=>{if(s){T(!0);try{const a=await y.config.files.write(s,l);a.success?(v(l),i.success(`${s} saved`),N()):i.error(a.error||"Failed to save")}catch{i.error("Failed to save file")}finally{T(!1)}}},[s,l,N]),C=l!==b,M=(s==null?void 0:s.endsWith(".yaml"))||(s==null?void 0:s.endsWith(".yml")),E=s==null?void 0:s.endsWith(".json"),z=a=>M?a.replace(/(#.*)$/,'<span class="text-dark-muted">$1</span>').replace(/^(\s*)([\w-]+)(:)/,'$1<span class="text-accent-blue">$2</span>$3').replace(/:\s+(true|false|null|~)(\s*)$/,': <span class="text-accent-purple">$1</span>$2').replace(/:\s+(\d+\.?\d*)(\s*)$/,': <span class="text-accent-green">$1</span>$2').replace(/:\s+"([^"]*)"(\s*)$/,': <span class="text-accent-yellow">"$1"</span>$2'):E?a.replace(/(\s*"[^"]*")(\s*:)/g,'<span class="text-accent-blue">$1</span>$2').replace(/:\s+(true|false|null)/g,': <span class="text-accent-purple">$1</span>').replace(/:\s+(\d+\.?\d*)/g,': <span class="text-accent-green">$1</span>').replace(/:\s+"([^"]*)"/g,': <span class="text-accent-yellow">"$1"</span>'):a;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-dark-text",children:"Config Files"}),e.jsx("button",{onClick:N,disabled:m,className:"p-1.5 rounded hover:bg-dark-hover transition-colors text-dark-muted",title:"Refresh file list",children:e.jsx(U,{size:14,className:m?"animate-spin":""})})]}),o.length===0&&!m&&e.jsx("p",{className:"text-xs text-dark-muted",children:"No config files found in ~/.agent/"}),o.length>0&&e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-48 shrink-0 space-y-0.5 max-h-[300px] overflow-y-auto custom-scrollbar",children:o.map(a=>e.jsxs("button",{onClick:()=>I(a.name),className:`w-full text-left px-2.5 py-1.5 rounded text-xs flex items-center gap-2 transition-colors ${s===a.name?"bg-accent-blue/10 text-accent-blue":"text-dark-text hover:bg-dark-hover"}`,children:[e.jsx(ee,{size:12,className:"shrink-0"}),e.jsx("span",{className:"truncate flex-1",children:a.name}),!a.editable&&e.jsx("span",{className:"text-[10px] text-dark-muted shrink-0",title:"Read-only",children:"read"})]},a.name))}),s?e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-dark-muted",children:[e.jsx("span",{className:"text-dark-text font-medium",children:s}),o.find(a=>a.name===s)&&e.jsxs("span",{children:[be(o.find(a=>a.name===s).size)," · ",fe(o.find(a=>a.name===s).modified)]}),C&&e.jsxs("span",{className:"text-accent-yellow flex items-center gap-1",children:[e.jsx(te,{size:10}),"unsaved changes"]})]}),e.jsxs("button",{onClick:L,disabled:!C||g,className:`flex items-center gap-1 px-2.5 py-1 rounded text-xs transition-all ${C?"bg-accent-blue text-white hover:opacity-90":"bg-dark-hover text-dark-muted cursor-not-allowed"}`,children:[e.jsx(se,{size:12}),g?"Saving...":"Save"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"w-full h-[260px] p-3 rounded-lg bg-dark-bg border border-dark-border font-mono text-xs leading-relaxed overflow-auto custom-scrollbar pointer-events-none",dangerouslySetInnerHTML:{__html:l.split(`
|
|
2
2
|
`).map(z).join(`
|
|
3
3
|
`)||" "}}),e.jsx("textarea",{value:l,onChange:a=>p(a.target.value),className:"absolute inset-0 w-full h-full p-3 rounded-lg bg-transparent border border-dark-border font-mono text-xs leading-relaxed resize-none overflow-auto custom-scrollbar text-transparent caret-dark-text focus:outline-none focus:border-accent-blue/50",style:{color:"transparent"},spellCheck:!1})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-dark-muted",children:"Select a file to edit"})]})]})}const ve=r.memo(function({nameKey:d,descriptionKey:s,colors:c,isSelected:l,onClick:p}){const{t:b}=H(),v=["bg","surface","border","text","muted","accentBlue","accentGreen","accentRed","accentYellow","accentPurple"];return e.jsxs("button",{onClick:p,className:`relative flex flex-col items-center rounded-xl p-2 transition-all focus:outline-none focus:ring-2 focus:ring-accent-blue/50 ${l?"ring-2 ring-accent-blue/60 bg-dark-bg border border-accent-blue/40 shadow-sm":"border border-dark-border hover:border-accent-blue/30 bg-dark-bg hover:shadow-sm"}`,title:b(s),"aria-pressed":l,"aria-label":b(d),children:[e.jsx("div",{className:"flex gap-[2px] rounded-md overflow-hidden w-full h-8 mb-1.5 border border-dark-border/40",children:v.map(m=>e.jsx("div",{className:"flex-1",style:{backgroundColor:c[m]},title:m},m))}),e.jsx("span",{className:`text-[11px] font-medium truncate w-full text-center ${l?"text-accent-blue":"text-dark-text"}`,children:b(d)}),l&&e.jsx("span",{className:"absolute top-1 right-1 w-4 h-4 bg-accent-blue rounded-full flex items-center justify-center shadow-sm",children:e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",children:e.jsx("path",{d:"M1.5 4L3.5 6L6.5 2",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}),W=[{key:"bg",labelKey:"settings.colorBg"},{key:"surface",labelKey:"settings.colorSurface"},{key:"border",labelKey:"settings.colorBorder"},{key:"text",labelKey:"settings.colorText"},{key:"muted",labelKey:"settings.colorMuted"},{key:"accentBlue",labelKey:"settings.colorAccentBlue"},{key:"accentGreen",labelKey:"settings.colorAccentGreen"},{key:"accentRed",labelKey:"settings.colorAccentRed"},{key:"accentYellow",labelKey:"settings.colorAccentYellow"},{key:"accentPurple",labelKey:"settings.colorAccentPurple"}],je={language:["language","lang","Chinese","中文","English","en","zh"],theme:["theme","dark","light","color","palette","custom"],advanced:["advanced","yolo","auto","swarm","workspace","guard","bypass"],provider:["provider","model","api","key","openai","anthropic","deepseek"],configFiles:["config","file","yaml","json","editor"],system:["system","server","uptime","restart","reboot"],about:["about","version","info"]},Te=r.memo(function({onNavigate:d}){const{t:s}=H(),{theme:c,setTheme:l,themePresetId:p,setThemePreset:b,language:v,setLanguage:m,yolo:n,setYoloEnabled:g,autoSwarm:T,setAutoSwarmEnabled:N,workspaceGuardBypass:I,setWorkspaceGuardBypass:L,customTheme:C,customThemeEnabled:M,setCustomTheme:E,setCustomThemeEnabled:z,resetCustomTheme:a}=me(),S=he(t=>t.activeSessionId),[f,Y]=r.useState(M),q=r.useMemo(()=>c==="dark"?"dark":c==="light"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[c]),J=r.useMemo(()=>Object.values(ge),[]),[P,Q]=r.useState(0),[j,F]=r.useState(!1),[A,R]=r.useState(!1),[$,B]=r.useState(""),k=r.useCallback(t=>{if(!$.trim())return!0;const x=$.toLowerCase().trim();return(je[t]??[]).some(h=>h.toLowerCase().includes(x))},[$]);r.useEffect(()=>{let t=!0;const x=async()=>{try{const h=await y.system.status();t&&h.success&&h.data&&Q(h.data.uptime)}catch{}};x();const u=setInterval(x,j?2e3:1e4);return()=>{t=!1,clearInterval(u)}},[j]);const Z=r.useCallback(async()=>{if(window.confirm("Restart the server? All active sessions will be disconnected.")){F(!0);try{const t=await y.system.restart();t.success?i.info("Server restarting..."):(i.error(t.error||"Restart failed"),F(!1))}catch{i.error("Failed to send restart request"),F(!1)}}},[]),V=r.useCallback(async()=>{if(window.confirm("Shut down the server? This will stop the entire backend process.")&&window.confirm("Are you sure? All active sessions and unsaved work will be lost.")){R(!0);try{const t=await y.system.shutdown();t.success?i.info("Server shutting down..."):(i.error(t.error||"Shutdown failed"),R(!1))}catch{i.error("Failed to send shutdown request"),R(!1)}}},[]);r.useEffect(()=>{j&&P<1e4&&(F(!1),i.success("Server restarted"))},[P,j]);const X=t=>{const x=Math.floor(t/1e3),u=Math.floor(x/60),h=Math.floor(u/60);return h>0?`${h}h ${u%60}m`:u>0?`${u}m ${x%60}s`:`${x}s`};return e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar p-4 bg-transparent",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 gap-4 rounded-xl border border-dark-border bg-dark-surface p-3",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2 shrink-0",children:[e.jsx(ae,{size:18,className:"text-accent-blue"}),s("settings.title")]}),e.jsxs("div",{className:"relative flex-1 max-w-xs",children:[e.jsx(_,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-dark-muted pointer-events-none"}),e.jsx("input",{type:"text",value:$,onChange:t=>B(t.target.value),placeholder:"Search settings...",className:"w-full bg-dark-bg border border-dark-border rounded-lg pl-9 pr-3 py-1.5 text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue/60 focus:ring-2 focus:ring-accent-blue/15 outline-none transition-all"}),$&&e.jsx("button",{onClick:()=>B(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-dark-muted hover:text-dark-text text-xs p-1 rounded",children:"×"})]})]}),e.jsxs("div",{className:"space-y-5 max-w-3xl",children:[k("language")&&e.jsx(w,{icon:re,iconColor:"text-accent-blue",title:s("settings.language"),children:e.jsx("div",{className:"flex gap-2",children:["zh-CN","en"].map(t=>e.jsx("button",{onClick:()=>m(t),className:`px-4 py-2 rounded-lg transition-all ${v===t?"bg-accent-blue text-white":"bg-dark-hover text-dark-text hover:bg-dark-border"}`,children:s(t==="zh-CN"?"settings.languageZh":"settings.languageEn")},t))})}),k("theme")&&e.jsxs(w,{icon:G,iconColor:"text-accent-purple",title:s("settings.theme"),children:[e.jsx("div",{className:"flex gap-2 mb-4",children:["dark","light","auto"].map(t=>e.jsx("button",{onClick:()=>l(t),className:`px-4 py-2 rounded-lg transition-all ${c===t?"bg-accent-blue text-white":"bg-dark-hover text-dark-text hover:bg-dark-border"}`,children:s(t==="dark"?"settings.themeDark":t==="light"?"settings.themeLight":"settings.themeAuto")},t))}),e.jsxs("div",{className:"mb-4",children:[e.jsx("h4",{className:"text-xs font-semibold text-dark-text mb-2",children:s("settings.themePresets")}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2",children:J.map(t=>{if(!t)return null;const x=(p||pe)===t.id,u=q==="dark"?t.dark:t.light;return e.jsx(ve,{id:t.id,nameKey:t.nameKey,descriptionKey:t.descriptionKey,colors:u,isSelected:x,onClick:()=>b(t.id)},t.id)})})]}),e.jsxs("div",{className:"pt-4 border-t border-dark-border",children:[e.jsxs("button",{onClick:()=>{const t=!f;Y(t),z(t)},className:"flex items-center gap-2 text-sm text-dark-muted hover:text-dark-text transition-colors",children:[e.jsx(G,{size:14}),e.jsx("span",{children:s("settings.customOverrides")}),e.jsx("span",{className:`w-8 h-4 rounded-full transition-colors ${f?"bg-accent-blue":"bg-dark-border"}`,children:e.jsx("span",{className:`block w-3 h-3 rounded-full bg-white transition-transform mt-0.5 ${f?"ml-4":"ml-0.5"}`})})]}),f&&e.jsx("p",{className:"text-[10px] text-dark-muted mt-1 mb-2",children:s("settings.customOverridesHint")}),f&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"flex gap-1 mb-3 rounded-lg overflow-hidden h-6",children:W.map(({key:t})=>e.jsx("div",{className:"flex-1",style:{backgroundColor:C[t]},title:t},t))}),e.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2",children:W.map(({key:t,labelKey:x})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:C[t],onChange:u=>E({[t]:u.target.value}),className:"w-8 h-8 rounded border border-dark-border cursor-pointer bg-transparent p-0.5 shrink-0"}),e.jsx("span",{className:"text-xs text-dark-muted flex-1 truncate",children:s(x)}),e.jsx("input",{type:"text",value:C[t],onChange:u=>{const h=u.target.value;/^#[0-9a-fA-F]{0,6}$/.test(h)&&E({[t]:h})},className:"w-16 bg-dark-bg border border-dark-border rounded px-1 py-0.5 text-xs text-dark-text font-mono text-center",maxLength:7})]},t))}),e.jsx("button",{onClick:a,className:"mt-2 text-xs text-dark-muted hover:text-accent-red transition-colors",children:s("settings.resetColors")})]})]})]}),k("provider")&&e.jsxs(w,{icon:ne,iconColor:"text-accent-yellow",title:"Provider & Models",children:[e.jsx("p",{className:"text-sm text-dark-muted mb-3",children:"Configure AI providers, API keys, and model settings. Add or remove providers like OpenAI, Anthropic, DeepSeek, and more."}),e.jsxs("button",{onClick:()=>d==null?void 0:d("models"),className:"flex items-center gap-2 px-4 py-2 bg-accent-blue text-white rounded-lg hover:opacity-90 transition-opacity text-sm w-fit",children:[e.jsx(oe,{size:14}),"Manage Providers & Models"]})]}),k("context")&&e.jsx(w,{icon:le,iconColor:"text-accent-blue",title:"Max Context",children:e.jsx(we,{})}),k("advanced")&&e.jsx(w,{icon:ce,iconColor:"text-accent-yellow",title:s("settings.advancedFeatures"),children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(D,{title:s("settings.yoloMode"),subtitle:s("settings.yoloDesc"),enabled:n.enabled,onChange:t=>{g(t),K.send({type:"toggle_yolo",sessionId:S||"",data:t?"true":"false"})}}),e.jsx(D,{title:s("settings.autoSwarm"),subtitle:s("settings.autoSwarmDesc"),enabled:T.enabled,onChange:t=>{N(t),K.send({type:"toggle_auto_swarm",sessionId:S||"",data:t?"true":"false"})}}),e.jsx(D,{title:s("settings.workspaceGuard"),subtitle:s("settings.workspaceGuardDesc"),enabled:I,onChange:t=>{L(t),K.send({type:"toggle_workspace_guard",sessionId:S||"",data:t?"true":"false"})}})]})}),k("configFiles")&&e.jsx(w,{icon:ie,iconColor:"text-accent-green",title:"Config Files (~/.agent/)",children:e.jsx(ke,{})}),k("system")&&e.jsx(w,{icon:de,iconColor:"text-dark-muted",title:"System",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-dark-muted",children:"Server Uptime"}),e.jsx("span",{className:"text-dark-text font-mono",children:X(P)})]}),e.jsxs("button",{onClick:Z,disabled:j,className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm transition-all ${j?"bg-dark-hover text-dark-muted cursor-wait":"bg-accent-red/10 text-accent-red hover:bg-accent-red/20 border border-accent-red/30"}`,children:[e.jsx(U,{size:14,className:j?"animate-spin":""}),j?"Restarting...":"Restart Server"]}),e.jsxs("button",{onClick:V,disabled:A,className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm transition-all ${A?"bg-dark-hover text-dark-muted cursor-wait":"bg-accent-red/10 text-accent-red hover:bg-accent-red/20 border border-accent-red/30"}`,children:[e.jsx(ue,{size:14,className:A?"animate-pulse":""}),A?"Shutting Down...":"Shutdown Server"]})]})}),k("about")&&e.jsx(w,{icon:xe,iconColor:"text-accent-blue",title:s("settings.about"),children:e.jsxs("div",{className:"text-sm text-dark-muted space-y-2",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-dark-text",children:"DeepSeekCode Web"})," v1.0.0"]}),e.jsx("p",{children:s("settings.aboutDesc")}),e.jsx("p",{className:"text-xs",children:"Powered by React + TypeScript + TailwindCSS"})]})}),$.trim()&&!["language","theme","provider","advanced","configFiles","system","about"].some(k)&&e.jsxs("div",{className:"text-center py-12 text-dark-muted",children:[e.jsx(_,{size:32,className:"mx-auto mb-2 opacity-40"}),e.jsxs("p",{className:"text-sm",children:["No settings match “",$,"”"]})]})]})]})});function we(){const o=O(n=>n.maxContextTokens),d=O(n=>n.setMaxContextTokens),[s,c]=r.useState(String(o)),[l,p]=r.useState(!1),b=[32e3,64e3,128e3,256e3,512e3,1e6,2e6],v=async()=>{const n=parseInt(s,10);if(!(isNaN(n)||n<1e3)){p(!0),d(n);try{await y.config.provider.save({contextWindow:n}),i.success("Context window saved")}catch(g){i.error("Failed to save context window: "+(g instanceof Error?g.message:"Unknown error"))}p(!1)}},m=n=>n>=1e6?(n/1e6).toFixed(0)+"M":(n/1e3).toFixed(0)+"K";return e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-dark-muted mb-3",children:"Set the maximum context window (in tokens) for your AI model. This controls how the progress bar and usage percentage are calculated."}),e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("input",{type:"number",value:s,onChange:n=>c(n.target.value),min:1e3,max:1e7,step:1e3,className:"w-32 bg-dark-bg border border-dark-border rounded-lg px-3 py-1.5 text-sm text-dark-text font-mono focus:border-accent-blue/60 focus:ring-2 focus:ring-accent-blue/15 outline-none transition-all"}),e.jsx("span",{className:"text-sm text-dark-muted",children:"tokens"}),e.jsx("button",{onClick:v,disabled:l,className:"px-3 py-1.5 rounded-lg text-sm bg-accent-blue text-white hover:opacity-90 transition-opacity disabled:opacity-50",children:l?"Saving...":"Apply"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:b.map(n=>e.jsx("button",{onClick:async()=>{c(String(n)),d(n);try{await y.config.provider.save({contextWindow:n}),i.success("Context window saved")}catch(g){i.error("Failed to save context window: "+(g instanceof Error?g.message:"Unknown error"))}},className:"px-3 py-1 rounded-lg text-xs transition-all",children:m(n)},n))}),e.jsxs("p",{className:"text-xs text-dark-muted mt-2",children:["Current: ",e.jsx("span",{className:"font-mono text-dark-text",children:parseInt(s,10).toLocaleString()})," tokens"]})]})}function w({icon:o,iconColor:d,title:s,children:c}){return e.jsxs("div",{className:"rounded-xl border border-dark-border bg-dark-surface p-4",children:[e.jsxs("h3",{className:"font-medium mb-3 flex items-center gap-2",children:[e.jsx(o,{size:16,className:d}),s]}),c]})}export{Te as SettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./markdown-BUScHEtT.js";import{r as l,p as A,o as X,ab as Z,P as ee,ac as se,a8 as O,a9 as $,ad as U,ae as te}from"./icons-uody4X-4.js";import"./Toast-CcbSW0V2.js";import{e as re,M as _,a as p}from"./index-Bpfxw0Lr.js";import"./react-vendor-C5NlWs7r.js";import"./state-DKyBAq9j.js";const T={id:"",name:"",description:"",category:"",trigger:"",systemPrompt:"",injection:"lazy",tags:"",requiredTools:""};function oe(){const{t}=re(),[d,b]=l.useState([]),[f,E]=l.useState(!0),[P,j]=l.useState(null),[k,D]=l.useState(""),[v,N]=l.useState(null),[H,x]=l.useState(!1),[y,w]=l.useState(null),[I,q]=l.useState(!1),[F,u]=l.useState(null),[a,c]=l.useState(T),[Q,C]=l.useState(!1),[V,L]=l.useState(!1),[M,S]=l.useState(null),h=l.useRef(null),g=async()=>{E(!0),j(null);const s=await p.skills.list();if(s.success){const r=Array.isArray(s.data)?s.data:[];b(r),N(n=>{var o;return n&&r.some(W=>W.id===n)?n:((o=r[0])==null?void 0:o.id)||null}),s.data!==null&&s.data!==void 0&&!Array.isArray(s.data)&&j("服务端返回的技能数据格式异常")}else j(s.error||t("skills.loadFailedFallback"));E(!1)};l.useEffect(()=>{g()},[]);const i=l.useMemo(()=>d.find(s=>s.id===v)||d[0]||null,[d,v]),z=l.useMemo(()=>{const s=k.trim().toLowerCase();return s?d.filter(r=>[r.id,r.name,r.description,r.category,...r.tags||[]].join(" ").toLowerCase().includes(s)):d},[d,k]),Y=()=>{w(null),c(T),u(null),x(!0)},G=s=>{w(s.id),c({id:s.id,name:s.name,description:s.description,category:s.category,trigger:s.trigger||"",systemPrompt:s.systemPrompt||"",injection:s.injection||"lazy",tags:(s.tags||[]).join(", "),requiredTools:(s.requiredTools||[]).join(", ")}),u(null),x(!0)},J=async()=>{const s=a.id.trim();if(!s){u(t("skills.fieldId")+" is required");return}q(!0),u(null);const r={id:s,name:a.name.trim(),description:a.description.trim(),category:a.category.trim(),trigger:a.trigger.trim(),systemPrompt:a.systemPrompt,injection:a.injection.trim(),tags:B(a.tags),requiredTools:B(a.requiredTools)},n=y?await p.skills.update(y,r):await p.skills.create(r);n.success?(x(!1),w(null),c(T),await g(),N(s)):u(n.error||t("skills.save")),q(!1)},R=async s=>{(await p.skills.toggle(s.id,!s.enabled)).success&&b(n=>n.map(o=>o.id===s.id?{...o,enabled:!o.enabled}:o))},K=async s=>{L(!0),S(null);try{const r=await s.text(),n=await p.skills.import({fileName:s.name,content:r});n.success?(C(!1),await g()):S(n.error||t("skills.import"))}catch(r){S(r instanceof Error?r.message:t("skills.import"))}finally{L(!1),h.current&&(h.current.value="")}};return f?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(A,{size:32,className:"animate-spin mx-auto mb-2 text-accent-blue"}),e.jsx("p",{className:"text-dark-muted",children:"Loading..."})]})}):P?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(X,{size:32,className:"mx-auto mb-2 text-accent-red"}),e.jsx("p",{className:"text-accent-red mb-4",children:P}),e.jsx("button",{onClick:g,className:"px-4 py-2 bg-accent-blue text-white rounded-lg",children:t("skills.retry")})]})}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4 gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(Z,{size:20}),t("skills.title"),e.jsxs("span",{className:"text-sm font-normal text-dark-muted",children:["(",d.length,")"]})]}),e.jsx("input",{value:k,onChange:s=>D(s.target.value),placeholder:"Search skills",className:"w-56 px-3 py-2 bg-dark-surface border border-dark-border rounded-lg text-sm outline-none focus:border-accent-blue"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:Y,className:"flex items-center gap-2 px-3 py-2 bg-accent-blue text-white rounded-lg",children:[e.jsx(ee,{size:14}),t("skills.new")]}),e.jsxs("button",{onClick:()=>C(!0),className:"flex items-center gap-2 px-3 py-2 bg-dark-surface border border-dark-border rounded-lg",children:[e.jsx(se,{size:14}),t("skills.import")]}),e.jsxs("button",{onClick:g,className:"flex items-center gap-2 px-3 py-2 bg-dark-surface border border-dark-border rounded-lg",children:[e.jsx(A,{size:14}),t("skills.refresh")]})]})]}),e.jsxs("div",{className:"grid grid-cols-[320px_minmax(0,1fr)] gap-4 flex-1 min-h-0",children:[e.jsxs("div",{className:"border border-dark-border rounded-lg overflow-hidden bg-dark-surface flex flex-col min-h-0",children:[e.jsxs("div",{className:"px-3 py-2 border-b border-dark-border text-sm text-dark-muted flex items-center justify-between",children:[e.jsx("span",{children:t("skills.list")}),e.jsx("span",{children:z.length})]}),e.jsxs("div",{className:"overflow-y-auto custom-scrollbar",children:[z.map(s=>e.jsx("button",{onClick:()=>N(s.id),className:`w-full text-left px-3 py-3 border-b border-dark-border/60 hover:bg-dark-hover ${v===s.id?"bg-dark-hover":""}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:s.icon||"⭐"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:s.name}),e.jsx("div",{className:"text-xs text-dark-muted truncate",children:s.id})]})]})}),e.jsxs("button",{onClick:r=>{r.stopPropagation(),R(s)},className:`flex items-center gap-1 px-2 py-1 rounded text-xs font-medium transition-colors ${s.enabled?"bg-accent-green/20 text-accent-green hover:bg-accent-green/30":"bg-accent-red/20 text-accent-red hover:bg-accent-red/30"}`,title:s.enabled?t("skills.disable"):t("skills.enable"),children:[s.enabled?e.jsx(O,{size:16}):e.jsx($,{size:16}),s.enabled?t("skills.enabled"):t("skills.disabled")]})]})},s.id)),z.length===0&&e.jsx("div",{className:"p-4 text-sm text-dark-muted",children:t("skills.noSkills")})]})]}),e.jsx("div",{className:"border border-dark-border rounded-lg bg-dark-surface min-h-0 overflow-hidden flex flex-col",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-4 py-3 border-b border-dark-border flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-2xl",children:i.icon||"⭐"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold truncate",children:i.name}),e.jsxs("div",{className:"text-xs text-dark-muted",children:[i.id," · ",i.category]})]})]}),e.jsx("p",{className:"mt-2 text-sm text-dark-muted whitespace-pre-wrap",children:i.description})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>R(i),className:`flex items-center gap-1 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${i.enabled?"bg-accent-green/20 text-accent-green hover:bg-accent-green/30":"bg-accent-red/20 text-accent-red hover:bg-accent-red/30"}`,children:[i.enabled?e.jsx(O,{size:14}):e.jsx($,{size:14}),i.enabled?t("skills.enabled"):t("skills.disabled")]}),e.jsxs("button",{onClick:()=>G(i),className:"px-3 py-2 bg-accent-blue text-white rounded-lg text-sm flex items-center gap-2",children:[e.jsx(U,{size:14}),t("skills.edit")]})]})]}),e.jsxs("div",{className:"p-4 overflow-y-auto custom-scrollbar text-sm space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-dark-muted mb-1",children:t("skills.tags")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:(i.tags||[]).length>0?i.tags.map(s=>e.jsx("span",{className:"px-2 py-1 rounded bg-dark-bg border border-dark-border",children:s},s)):e.jsx("span",{className:"text-dark-muted",children:t("skills.none")})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-dark-muted mb-1",children:t("skills.source")}),e.jsx("div",{className:"break-all",children:i.source||t("skills.localSkill")})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-dark-muted mb-1",children:t("skills.systemPrompt")}),e.jsx("pre",{className:"whitespace-pre-wrap text-xs p-3 rounded border border-dark-border bg-dark-bg overflow-auto custom-scrollbar",children:i.systemPrompt||t("skills.none")})]})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center text-dark-muted",children:t("skills.selectSkill")})})]}),e.jsx(_,{isOpen:H,onClose:()=>x(!1),title:t(y?"skills.edit":"skills.new"),size:"xl",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(m,{label:t("skills.fieldId"),value:a.id,onChange:s=>c(r=>({...r,id:s}))}),e.jsx(m,{label:t("skills.fieldName"),value:a.name,onChange:s=>c(r=>({...r,name:s}))}),e.jsx(m,{label:t("skills.fieldCategory"),value:a.category,onChange:s=>c(r=>({...r,category:s}))}),e.jsx(m,{label:t("skills.fieldTrigger"),value:a.trigger,onChange:s=>c(r=>({...r,trigger:s}))}),e.jsx(m,{label:t("skills.tags"),value:a.tags,onChange:s=>c(r=>({...r,tags:s}))}),e.jsx(m,{label:t("skills.fieldTools"),value:a.requiredTools,onChange:s=>c(r=>({...r,requiredTools:s}))}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm mb-1 text-dark-muted",children:t("skills.description")}),e.jsx("textarea",{value:a.description,onChange:s=>c(r=>({...r,description:s.target.value})),className:"w-full h-20 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border outline-none resize-none"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm mb-1 text-dark-muted",children:t("skills.systemPrompt")}),e.jsx("textarea",{value:a.systemPrompt,onChange:s=>c(r=>({...r,systemPrompt:s.target.value})),className:"w-full h-40 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border outline-none resize-none font-mono text-sm"})]}),F&&e.jsx("div",{className:"col-span-2 text-sm text-accent-red",children:F}),e.jsxs("div",{className:"col-span-2 flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>x(!1),className:"px-4 py-2 border border-dark-border rounded-lg",children:t("skills.cancel")}),e.jsxs("button",{disabled:I,onClick:J,className:"px-4 py-2 bg-accent-blue text-white rounded-lg flex items-center gap-2",children:[e.jsx(U,{size:14}),t(I?"skills.saving":"skills.save")]})]})]})}),e.jsx(_,{isOpen:Q,onClose:()=>C(!1),title:t("skills.importTitle"),size:"md",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{ref:h,type:"file",accept:".md,.skill.md,.txt",className:"hidden",onChange:s=>{var n;const r=(n=s.target.files)==null?void 0:n[0];r&&K(r)}}),e.jsxs("button",{onClick:()=>{var s;return(s=h.current)==null?void 0:s.click()},disabled:V,className:"w-full py-6 border border-dashed border-dark-border rounded-lg flex items-center justify-center gap-2",children:[e.jsx(te,{size:16}),t("skills.chooseFile")]}),M&&e.jsx("div",{className:"text-sm text-accent-red",children:M}),e.jsx("div",{className:"text-xs text-dark-muted",children:t("skills.importHint")})]})})]})}function B(t){return t.split(",").map(d=>d.trim()).filter(Boolean)}function m({label:t,value:d,onChange:b}){return e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm mb-1 text-dark-muted",children:t}),e.jsx("input",{value:d,onChange:f=>b(f.target.value),className:"w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border outline-none focus:border-accent-blue"})]})}export{oe as SkillsView};
|
|
1
|
+
import{j as e}from"./markdown-BUScHEtT.js";import{r as l,p as A,o as X,ab as Z,P as ee,ac as se,a8 as O,a9 as $,ad as U,ae as te}from"./icons-uody4X-4.js";import"./Toast-CcbSW0V2.js";import{e as re,M as _,a as p}from"./index-DGWtPRgs.js";import"./react-vendor-C5NlWs7r.js";import"./state-DKyBAq9j.js";const T={id:"",name:"",description:"",category:"",trigger:"",systemPrompt:"",injection:"lazy",tags:"",requiredTools:""};function oe(){const{t}=re(),[d,b]=l.useState([]),[f,E]=l.useState(!0),[P,j]=l.useState(null),[k,D]=l.useState(""),[v,N]=l.useState(null),[H,x]=l.useState(!1),[y,w]=l.useState(null),[I,q]=l.useState(!1),[F,u]=l.useState(null),[a,c]=l.useState(T),[Q,C]=l.useState(!1),[V,L]=l.useState(!1),[M,S]=l.useState(null),h=l.useRef(null),g=async()=>{E(!0),j(null);const s=await p.skills.list();if(s.success){const r=Array.isArray(s.data)?s.data:[];b(r),N(n=>{var o;return n&&r.some(W=>W.id===n)?n:((o=r[0])==null?void 0:o.id)||null}),s.data!==null&&s.data!==void 0&&!Array.isArray(s.data)&&j("服务端返回的技能数据格式异常")}else j(s.error||t("skills.loadFailedFallback"));E(!1)};l.useEffect(()=>{g()},[]);const i=l.useMemo(()=>d.find(s=>s.id===v)||d[0]||null,[d,v]),z=l.useMemo(()=>{const s=k.trim().toLowerCase();return s?d.filter(r=>[r.id,r.name,r.description,r.category,...r.tags||[]].join(" ").toLowerCase().includes(s)):d},[d,k]),Y=()=>{w(null),c(T),u(null),x(!0)},G=s=>{w(s.id),c({id:s.id,name:s.name,description:s.description,category:s.category,trigger:s.trigger||"",systemPrompt:s.systemPrompt||"",injection:s.injection||"lazy",tags:(s.tags||[]).join(", "),requiredTools:(s.requiredTools||[]).join(", ")}),u(null),x(!0)},J=async()=>{const s=a.id.trim();if(!s){u(t("skills.fieldId")+" is required");return}q(!0),u(null);const r={id:s,name:a.name.trim(),description:a.description.trim(),category:a.category.trim(),trigger:a.trigger.trim(),systemPrompt:a.systemPrompt,injection:a.injection.trim(),tags:B(a.tags),requiredTools:B(a.requiredTools)},n=y?await p.skills.update(y,r):await p.skills.create(r);n.success?(x(!1),w(null),c(T),await g(),N(s)):u(n.error||t("skills.save")),q(!1)},R=async s=>{(await p.skills.toggle(s.id,!s.enabled)).success&&b(n=>n.map(o=>o.id===s.id?{...o,enabled:!o.enabled}:o))},K=async s=>{L(!0),S(null);try{const r=await s.text(),n=await p.skills.import({fileName:s.name,content:r});n.success?(C(!1),await g()):S(n.error||t("skills.import"))}catch(r){S(r instanceof Error?r.message:t("skills.import"))}finally{L(!1),h.current&&(h.current.value="")}};return f?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(A,{size:32,className:"animate-spin mx-auto mb-2 text-accent-blue"}),e.jsx("p",{className:"text-dark-muted",children:"Loading..."})]})}):P?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(X,{size:32,className:"mx-auto mb-2 text-accent-red"}),e.jsx("p",{className:"text-accent-red mb-4",children:P}),e.jsx("button",{onClick:g,className:"px-4 py-2 bg-accent-blue text-white rounded-lg",children:t("skills.retry")})]})}):e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4 gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(Z,{size:20}),t("skills.title"),e.jsxs("span",{className:"text-sm font-normal text-dark-muted",children:["(",d.length,")"]})]}),e.jsx("input",{value:k,onChange:s=>D(s.target.value),placeholder:"Search skills",className:"w-56 px-3 py-2 bg-dark-surface border border-dark-border rounded-lg text-sm outline-none focus:border-accent-blue"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:Y,className:"flex items-center gap-2 px-3 py-2 bg-accent-blue text-white rounded-lg",children:[e.jsx(ee,{size:14}),t("skills.new")]}),e.jsxs("button",{onClick:()=>C(!0),className:"flex items-center gap-2 px-3 py-2 bg-dark-surface border border-dark-border rounded-lg",children:[e.jsx(se,{size:14}),t("skills.import")]}),e.jsxs("button",{onClick:g,className:"flex items-center gap-2 px-3 py-2 bg-dark-surface border border-dark-border rounded-lg",children:[e.jsx(A,{size:14}),t("skills.refresh")]})]})]}),e.jsxs("div",{className:"grid grid-cols-[320px_minmax(0,1fr)] gap-4 flex-1 min-h-0",children:[e.jsxs("div",{className:"border border-dark-border rounded-lg overflow-hidden bg-dark-surface flex flex-col min-h-0",children:[e.jsxs("div",{className:"px-3 py-2 border-b border-dark-border text-sm text-dark-muted flex items-center justify-between",children:[e.jsx("span",{children:t("skills.list")}),e.jsx("span",{children:z.length})]}),e.jsxs("div",{className:"overflow-y-auto custom-scrollbar",children:[z.map(s=>e.jsx("button",{onClick:()=>N(s.id),className:`w-full text-left px-3 py-3 border-b border-dark-border/60 hover:bg-dark-hover ${v===s.id?"bg-dark-hover":""}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("div",{className:"min-w-0",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:s.icon||"⭐"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:s.name}),e.jsx("div",{className:"text-xs text-dark-muted truncate",children:s.id})]})]})}),e.jsxs("button",{onClick:r=>{r.stopPropagation(),R(s)},className:`flex items-center gap-1 px-2 py-1 rounded text-xs font-medium transition-colors ${s.enabled?"bg-accent-green/20 text-accent-green hover:bg-accent-green/30":"bg-accent-red/20 text-accent-red hover:bg-accent-red/30"}`,title:s.enabled?t("skills.disable"):t("skills.enable"),children:[s.enabled?e.jsx(O,{size:16}):e.jsx($,{size:16}),s.enabled?t("skills.enabled"):t("skills.disabled")]})]})},s.id)),z.length===0&&e.jsx("div",{className:"p-4 text-sm text-dark-muted",children:t("skills.noSkills")})]})]}),e.jsx("div",{className:"border border-dark-border rounded-lg bg-dark-surface min-h-0 overflow-hidden flex flex-col",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-4 py-3 border-b border-dark-border flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-2xl",children:i.icon||"⭐"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold truncate",children:i.name}),e.jsxs("div",{className:"text-xs text-dark-muted",children:[i.id," · ",i.category]})]})]}),e.jsx("p",{className:"mt-2 text-sm text-dark-muted whitespace-pre-wrap",children:i.description})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>R(i),className:`flex items-center gap-1 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${i.enabled?"bg-accent-green/20 text-accent-green hover:bg-accent-green/30":"bg-accent-red/20 text-accent-red hover:bg-accent-red/30"}`,children:[i.enabled?e.jsx(O,{size:14}):e.jsx($,{size:14}),i.enabled?t("skills.enabled"):t("skills.disabled")]}),e.jsxs("button",{onClick:()=>G(i),className:"px-3 py-2 bg-accent-blue text-white rounded-lg text-sm flex items-center gap-2",children:[e.jsx(U,{size:14}),t("skills.edit")]})]})]}),e.jsxs("div",{className:"p-4 overflow-y-auto custom-scrollbar text-sm space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-dark-muted mb-1",children:t("skills.tags")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:(i.tags||[]).length>0?i.tags.map(s=>e.jsx("span",{className:"px-2 py-1 rounded bg-dark-bg border border-dark-border",children:s},s)):e.jsx("span",{className:"text-dark-muted",children:t("skills.none")})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-dark-muted mb-1",children:t("skills.source")}),e.jsx("div",{className:"break-all",children:i.source||t("skills.localSkill")})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-dark-muted mb-1",children:t("skills.systemPrompt")}),e.jsx("pre",{className:"whitespace-pre-wrap text-xs p-3 rounded border border-dark-border bg-dark-bg overflow-auto custom-scrollbar",children:i.systemPrompt||t("skills.none")})]})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center text-dark-muted",children:t("skills.selectSkill")})})]}),e.jsx(_,{isOpen:H,onClose:()=>x(!1),title:t(y?"skills.edit":"skills.new"),size:"xl",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(m,{label:t("skills.fieldId"),value:a.id,onChange:s=>c(r=>({...r,id:s}))}),e.jsx(m,{label:t("skills.fieldName"),value:a.name,onChange:s=>c(r=>({...r,name:s}))}),e.jsx(m,{label:t("skills.fieldCategory"),value:a.category,onChange:s=>c(r=>({...r,category:s}))}),e.jsx(m,{label:t("skills.fieldTrigger"),value:a.trigger,onChange:s=>c(r=>({...r,trigger:s}))}),e.jsx(m,{label:t("skills.tags"),value:a.tags,onChange:s=>c(r=>({...r,tags:s}))}),e.jsx(m,{label:t("skills.fieldTools"),value:a.requiredTools,onChange:s=>c(r=>({...r,requiredTools:s}))}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm mb-1 text-dark-muted",children:t("skills.description")}),e.jsx("textarea",{value:a.description,onChange:s=>c(r=>({...r,description:s.target.value})),className:"w-full h-20 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border outline-none resize-none"})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("label",{className:"block text-sm mb-1 text-dark-muted",children:t("skills.systemPrompt")}),e.jsx("textarea",{value:a.systemPrompt,onChange:s=>c(r=>({...r,systemPrompt:s.target.value})),className:"w-full h-40 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border outline-none resize-none font-mono text-sm"})]}),F&&e.jsx("div",{className:"col-span-2 text-sm text-accent-red",children:F}),e.jsxs("div",{className:"col-span-2 flex justify-end gap-2",children:[e.jsx("button",{onClick:()=>x(!1),className:"px-4 py-2 border border-dark-border rounded-lg",children:t("skills.cancel")}),e.jsxs("button",{disabled:I,onClick:J,className:"px-4 py-2 bg-accent-blue text-white rounded-lg flex items-center gap-2",children:[e.jsx(U,{size:14}),t(I?"skills.saving":"skills.save")]})]})]})}),e.jsx(_,{isOpen:Q,onClose:()=>C(!1),title:t("skills.importTitle"),size:"md",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{ref:h,type:"file",accept:".md,.skill.md,.txt",className:"hidden",onChange:s=>{var n;const r=(n=s.target.files)==null?void 0:n[0];r&&K(r)}}),e.jsxs("button",{onClick:()=>{var s;return(s=h.current)==null?void 0:s.click()},disabled:V,className:"w-full py-6 border border-dashed border-dark-border rounded-lg flex items-center justify-center gap-2",children:[e.jsx(te,{size:16}),t("skills.chooseFile")]}),M&&e.jsx("div",{className:"text-sm text-accent-red",children:M}),e.jsx("div",{className:"text-xs text-dark-muted",children:t("skills.importHint")})]})})]})}function B(t){return t.split(",").map(d=>d.trim()).filter(Boolean)}function m({label:t,value:d,onChange:b}){return e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm mb-1 text-dark-muted",children:t}),e.jsx("input",{value:d,onChange:f=>b(f.target.value),className:"w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border outline-none focus:border-accent-blue"})]})}export{oe as SkillsView};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as r}from"./markdown-BUScHEtT.js";import{r as s,ao as U,ap as J,p as V,aq as _,D as K,a0 as Q,ar as X,as as Z}from"./icons-uody4X-4.js";import{x as ee,a as te}from"./terminal-Ck_l6svU.js";import{f as $,g as re,h as C,t as se}from"./index-
|
|
1
|
+
import{j as r}from"./markdown-BUScHEtT.js";import{r as s,ao as U,ap as J,p as V,aq as _,D as K,a0 as Q,ar as X,as as Z}from"./icons-uody4X-4.js";import{x as ee,a as te}from"./terminal-Ck_l6svU.js";import{f as $,g as re,h as C,t as se}from"./index-DGWtPRgs.js";import"./react-vendor-C5NlWs7r.js";import"./state-DKyBAq9j.js";const ne={background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",cursorAccent:"#1e1e1e",black:"#1e1e1e",red:"#f44747",green:"#608b4e",yellow:"#dcdcaa",blue:"#569cd6",magenta:"#c586c0",cyan:"#4ec9b0",white:"#d4d4d4",brightBlack:"#808080",brightRed:"#f44747",brightGreen:"#608b4e",brightYellow:"#dcdcaa",brightBlue:"#569cd6",brightMagenta:"#c586c0",brightCyan:"#4ec9b0",brightWhite:"#ffffff"};function de(){const f=s.useRef(null),c=s.useRef(null),w=s.useRef(null),o=s.useRef(null),[j,M]=s.useState(!1),[g,v]=s.useState(null),[B,R]=s.useState(!0),d=s.useRef(!1),S=s.useRef({isAtBottom:!0}),I=s.useCallback(t=>{const e=c.current;if(!e)return;const n=e.buffer.active;S.current.isAtBottom=n.baseY+e.rows>=n.length,e.write(t,()=>{S.current.isAtBottom&&!d.current&&e.scrollToBottom();const l=e.buffer.active;l.baseY+e.rows>=l.length&&(d.current=!1)})},[]),[k,y]=s.useState(""),p=s.useCallback(()=>{const t=c.current,e=o.current;!t||!e||e.readyState!==WebSocket.OPEN||e.send(JSON.stringify({type:"resize",cols:t.cols,rows:t.rows}))},[]),{status:T,errorMessage:N,port:z}=$(),{setStarting:E,setRunning:A,setStopping:D,setIdle:L,setError:m}=$(),{workspaceDir:x}=re(),b=s.useCallback(()=>{o.current&&(o.current.onclose=null,o.current.onmessage=null,o.current.onerror=null,o.current.onopen=null,o.current.close(),o.current=null)},[]),h=s.useCallback(async t=>{E(),t.writeln("\x1B[90mStarting local terminal...\x1B[0m");try{const e=await C.post("/api/terminal/start",{workspaceDir:x});if(!e.success||!e.data){const a=e.error||"Failed to start terminal";m(a),t.writeln(`\x1B[31m${a}\x1B[0m`);return}const n=e.data.port??e.data.ttydPort,l=e.data.wsUrl;if(!n||!l){const a="Invalid terminal start response";m(a),t.writeln(`\x1B[31m${a}\x1B[0m`);return}A(n,l),y(e.data.workspaceDir||x);const u=new WebSocket(l);o.current=u,u.onopen=()=>{t.clear(),t.focus(),t.writeln("\x1B[32mConnected to local shell\x1B[0m"),setTimeout(()=>{var a,i;(a=w.current)==null||a.fit(),p(),d.current||(i=c.current)==null||i.scrollToBottom()},50)},u.onmessage=a=>{typeof a.data=="string"&&I(a.data)},u.onerror=()=>{m("Terminal connection error")},u.onclose=()=>{o.current===u&&(o.current=null,m("Terminal disconnected"),t.writeln("\x1B[33mTerminal disconnected\x1B[0m"))}}catch(e){const n=e instanceof Error?e.message:"Unknown error";m(n),t.writeln(`\x1B[31m${n}\x1B[0m`)}},[x,E,A,m,p]),F=s.useCallback(async()=>{b(),D();try{await C.post("/api/terminal/stop")}catch{}L()},[b,D,L]);s.useEffect(()=>{f.current&&C.get("/api/terminal/status").then(t=>{const e=t.success&&t.data?t.data:null;v((e==null?void 0:e.terminalAvailable)!==!1),e!=null&&e.workspaceDir&&y(e.workspaceDir)}).catch(()=>v(!1))},[]),s.useEffect(()=>{if(g!==!0||!f.current)return;const t=new ee.Terminal({theme:ne,fontFamily:'"Cascadia Code", "Fira Code", Consolas, "Courier New", monospace',fontSize:14,lineHeight:1.2,cursorBlink:!0,cursorStyle:"block",scrollback:1e4,convertEol:!0}),e=new te.FitAddon;t.loadAddon(e),t.open(f.current),t.focus(),e.fit(),c.current=t,w.current=e,t.writeln("\x1B[36mDeepSeekCode Local Terminal\x1B[0m"),t.writeln("\x1B[90mRun commands directly on this machine.\x1B[0m");const n=t.onData(i=>{var W;((W=o.current)==null?void 0:W.readyState)===WebSocket.OPEN&&o.current.send(i)}),l=t.onScroll(()=>{const i=t.buffer.active;i.baseY+t.rows<i.length&&(d.current=!0,R(!1))}),u=()=>{var i;(i=w.current)==null||i.fit(),p(),d.current||t.scrollToBottom()};window.addEventListener("resize",u);const a=window.setTimeout(()=>h(t),50);return()=>{clearTimeout(a),window.removeEventListener("resize",u),n.dispose(),l.dispose(),F(),t.dispose(),c.current=null}},[g,h,F,p]);const O=s.useCallback(()=>{var e;const t=(e=c.current)==null?void 0:e.getSelection();t&&(navigator.clipboard.writeText(t),se.success("Copied selection"))},[]),P=s.useCallback(()=>{var t,e;(t=c.current)==null||t.clear(),d.current||(e=c.current)==null||e.scrollToBottom()},[]),Y=s.useCallback(()=>{b(),c.current&&(c.current.clear(),h(c.current))},[b,h]),H=s.useCallback(()=>{R(t=>{var n;const e=!t;return d.current=!e,e&&((n=c.current)==null||n.scrollToBottom()),e})},[]),q=s.useCallback(()=>{const t=`Workspace: ${k||x}
|
|
2
2
|
Terminal session: ${z??""}
|
|
3
3
|
`,e=new Blob([t],{type:"text/plain"}),n=URL.createObjectURL(e),l=document.createElement("a");l.href=n,l.download=`terminal-${Date.now()}.log`,l.click(),URL.revokeObjectURL(n)},[x,k,z]),G=s.useMemo(()=>({idle:"Idle",starting:"Connecting",running:"Connected",stopping:"Stopping",error:"Error"})[T],[T]);return g===!1?r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-[#1e1e1e] gap-3 p-8",children:[r.jsx(U,{size:44,className:"text-dark-muted opacity-40"}),r.jsx("div",{className:"text-sm text-dark-muted",children:"Local terminal unavailable"})]}):r.jsxs("div",{className:`flex flex-col bg-[#1e1e1e] border-t border-dark-border ${j?"fixed inset-0 z-50":"flex-1 min-h-0"}`,children:[r.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2 bg-[#252526] border-b border-[#3c3c3c]",children:[r.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r.jsx(U,{size:14,className:"text-dark-muted shrink-0"}),r.jsx("span",{className:"text-xs text-dark-muted shrink-0",children:"Terminal"}),r.jsx("span",{className:"text-xs text-dark-muted truncate",children:k||x}),r.jsxs("span",{className:"text-xs text-dark-muted",children:["[",G,"]"]}),N&&r.jsx("span",{className:"text-xs text-accent-red truncate max-w-[240px]",children:N})]}),r.jsxs("div",{className:"flex items-center gap-1 flex-wrap justify-end",children:[r.jsx("button",{onClick:H,className:`p-1 rounded hover:bg-[#3c3c3c] ${B?"text-accent-blue":"text-dark-muted"} hover:text-dark-text`,title:B?"璺熼殢杈撳嚭锛氬紑":"璺熼殢杈撳嚭锛氬叧",children:r.jsx(J,{size:12})}),r.jsx("button",{onClick:Y,className:"p-1 rounded hover:bg-[#3c3c3c] text-dark-muted hover:text-dark-text",title:"Restart",children:r.jsx(V,{size:12})}),r.jsx("button",{onClick:O,className:"p-1 rounded hover:bg-[#3c3c3c] text-dark-muted hover:text-dark-text",title:"Copy",children:r.jsx(_,{size:12})}),r.jsx("button",{onClick:q,className:"p-1 rounded hover:bg-[#3c3c3c] text-dark-muted hover:text-dark-text",title:"Download log",children:r.jsx(K,{size:12})}),r.jsx("button",{onClick:P,className:"p-1 rounded hover:bg-[#3c3c3c] text-dark-muted hover:text-dark-text",title:"Clear",children:r.jsx(Q,{size:12})}),r.jsx("button",{onClick:()=>M(t=>!t),className:"p-1 rounded hover:bg-[#3c3c3c] text-dark-muted hover:text-dark-text",title:"Fullscreen",children:j?r.jsx(X,{size:12}):r.jsx(Z,{size:12})})]})]}),r.jsx("div",{ref:f,className:"flex-1 overflow-hidden"})]})}export{de as TerminalView,de as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./markdown-BUScHEtT.js";import{r as a,p as y,o as A,Q as k,y as $,a as R,i as F,a7 as v,a8 as M,a9 as Q}from"./icons-uody4X-4.js";import{u as D,a as w,b as O}from"./index-
|
|
1
|
+
import{j as s}from"./markdown-BUScHEtT.js";import{r as a,p as y,o as A,Q as k,y as $,a as R,i as F,a7 as v,a8 as M,a9 as Q}from"./icons-uody4X-4.js";import{u as D,a as w,b as O}from"./index-DGWtPRgs.js";import"./react-vendor-C5NlWs7r.js";import"./state-DKyBAq9j.js";function G(){const m=D(e=>e.mode),u=m==="normal"?"act":O(m),[d,p]=a.useState([]),[l,b]=a.useState([]),[C,g]=a.useState(!0),[h,i]=a.useState(null),[r,z]=a.useState(""),[c,f]=a.useState(null),[n,j]=a.useState(null),o=async()=>{g(!0),i(null);const e=await w.tools.list();e.success&&Array.isArray(e.data)?(p(e.data),b(e.data)):e.success&&e.data&&!Array.isArray(e.data)?i("服务端返回的工具数据格式异常"):i(e.error||"加载工具失败"),g(!1)};a.useEffect(()=>{o()},[]),a.useEffect(()=>{let e=d;r&&(e=e.filter(t=>t.name.toLowerCase().includes(r.toLowerCase())||t.description.toLowerCase().includes(r.toLowerCase()))),c&&(e=e.filter(t=>t.category===c)),b(e)},[r,c,d]);const S=async(e,t)=>{(await w.tools.toggle(e,!t)).success&&p(L=>L.map(x=>x.id===e?{...x,enabled:!t}:x))},T=[...new Set(d.map(e=>e.category))],E=e=>({file:"bg-accent-blue/20 text-accent-blue",search:"bg-accent-green/20 text-accent-green",git:"bg-accent-yellow/20 text-accent-yellow",web:"bg-accent-purple/20 text-accent-purple",system:"bg-accent-red/20 text-accent-red"})[e]||"bg-dark-hover text-dark-muted";return C?s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"text-center",children:[s.jsx(y,{size:32,className:"animate-spin mx-auto mb-2 text-accent-blue"}),s.jsx("p",{className:"text-dark-muted",children:"加载中..."})]})}):h?s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"text-center",children:[s.jsx(A,{size:32,className:"mx-auto mb-2 text-accent-red"}),s.jsx("p",{className:"text-accent-red mb-4",children:h}),s.jsx("button",{onClick:o,className:"px-4 py-2 bg-accent-blue text-white rounded-lg",children:"重试"})]})}):s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[s.jsx(k,{size:20}),"工具列表",s.jsxs("span",{className:"text-sm font-normal text-dark-muted",children:["(",l.length,")"]})]}),s.jsxs("button",{onClick:o,className:"flex items-center gap-2 px-3 py-1.5 bg-dark-surface border border-dark-border rounded hover:bg-dark-hover transition-colors",children:[s.jsx(y,{size:14}),"刷新"]})]}),s.jsxs("div",{className:"flex gap-3 mb-4",children:[s.jsxs("div",{className:"flex-1 relative",children:[s.jsx($,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-dark-muted"}),s.jsx("input",{type:"text",value:r,onChange:e=>z(e.target.value),placeholder:"搜索工具...",className:"w-full pl-10 pr-4 py-2 bg-dark-surface border border-dark-border rounded-lg text-dark-text placeholder-dark-muted focus:border-accent-blue focus:outline-none"})]}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx("button",{onClick:()=>f(null),className:`px-3 py-2 rounded-lg text-sm transition-colors ${c?"bg-dark-surface border border-dark-border hover:bg-dark-hover":"bg-accent-blue text-white"}`,children:"全部"}),T.slice(0,4).map(e=>s.jsx("button",{onClick:()=>f(e),className:`px-3 py-2 rounded-lg text-sm transition-colors ${c===e?"bg-accent-blue text-white":"bg-dark-surface border border-dark-border hover:bg-dark-hover"}`,children:e},e))]})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:s.jsxs("div",{className:"space-y-2",children:[l.map(e=>s.jsxs("div",{className:`bg-dark-surface border rounded-lg transition-colors ${e.enabled?"border-dark-border":"border-dark-border opacity-60"}`,children:[s.jsxs("div",{className:"flex items-center justify-between p-4 cursor-pointer",onClick:()=>j(n===e.id?null:e.id),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[s.jsx("button",{onClick:t=>{t.stopPropagation(),j(n===e.id?null:e.id)},className:"text-dark-muted",children:n===e.id?s.jsx(R,{size:16}):s.jsx(F,{size:16})}),s.jsx("span",{className:`px-2 py-0.5 rounded text-xs ${E(e.category)}`,children:e.category}),s.jsx("span",{className:"font-medium",children:e.name}),u==="plan"&&(e.category==="File Operation"||e.category==="Execution")&&s.jsx(v,{size:14,className:"text-accent-red ml-1.5"}),u==="plan"&&(e.category==="File Operation"||e.category==="Execution")&&s.jsx(v,{size:14,className:"text-accent-red ml-1.5"})]}),s.jsx("div",{className:"flex items-center gap-3",children:s.jsx("button",{onClick:t=>{t.stopPropagation(),S(e.id,e.enabled)},className:`p-1.5 rounded transition-colors ${e.enabled?"text-accent-green hover:bg-accent-green/10":"text-dark-muted hover:bg-dark-hover"}`,title:e.enabled?"禁用":"启用",children:e.enabled?s.jsx(M,{size:24}):s.jsx(Q,{size:24})})})]}),n===e.id&&s.jsxs("div",{className:"px-4 pb-4 border-t border-dark-border",children:[s.jsx("p",{className:"text-sm text-dark-muted mt-3 mb-3",children:e.description}),e.params&&e.params.length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-dark-muted mb-2",children:"参数"}),s.jsx("div",{className:"space-y-1",children:e.params.map((t,N)=>s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsxs("code",{className:"px-1.5 py-0.5 bg-dark-bg rounded text-accent-blue",children:[t.name,t.required&&s.jsx("span",{className:"text-accent-red",children:"*"})]}),s.jsxs("span",{className:"text-dark-muted text-xs",children:["(",t.type,")"]}),s.jsx("span",{className:"text-dark-muted text-xs",children:t.description})]},N))})]})]})]},e.id)),l.length===0&&s.jsxs("div",{className:"text-center text-dark-muted py-8",children:[s.jsx(k,{size:48,className:"mx-auto mb-2 opacity-50"}),s.jsx("p",{children:"暂无工具"})]})]})})]})}export{G as ToolsView,G as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{q as t,r as s}from"./index-
|
|
1
|
+
import{q as t,r as s}from"./index-DGWtPRgs.js";function o(e,r){switch(t(e,r)){case"critical":return{level:"CRITICAL",reasonKey:"risk_critical"};case"high":return{level:"HIGH",reasonKey:/rm\s+-rf|sudo|chmod\s+777|curl.*\|\s*(ba)?sh|wget.*-O|>\/dev\/|mkfs/i.test(r)?"risk_critical_cmd":/write|edit|save|upload|deploy|publish/i.test(e)?"risk_high_file":/install|uninstall|npm|pip|cargo|gem|apt|brew|choco|yum|dnf/i.test(e)?"risk_high_pkg":"risk_high_shell"};case"low":return{level:"LOW",reasonKey:"risk_low"};default:return{level:"MEDIUM",reasonKey:/git|commit|push|merge|rebase/i.test(e)?"risk_git":"risk_network"}}}const b={CRITICAL:{bg:"bg-red-900/20",border:"border-red-500/40",text:"text-red-400",badge:"bg-red-500/20 text-red-400 border-red-500/30",icon:"🚨"},HIGH:{bg:"bg-orange-900/15",border:"border-orange-500/30",text:"text-orange-400",badge:"bg-orange-500/20 text-orange-400 border-orange-500/30",icon:"⚠️"},MEDIUM:{bg:"bg-yellow-900/10",border:"border-yellow-500/25",text:"text-yellow-400",badge:"bg-yellow-500/15 text-yellow-400 border-yellow-500/25",icon:"📋"},LOW:{bg:"bg-blue-900/10",border:"border-blue-500/25",text:"text-blue-400",badge:"bg-blue-500/15 text-blue-400 border-blue-500/25",icon:"✅"}};function a(e,r){return s(e,r)}export{b as R,o as c,a as e};
|