agent-tower 0.3.19 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/routes/app-settings.d.ts.map +1 -1
- package/dist/routes/app-settings.js +20 -5
- package/dist/routes/app-settings.js.map +1 -1
- package/dist/routes/tasks.js +1 -1
- package/dist/routes/tasks.js.map +1 -1
- package/dist/services/commit-message.service.d.ts +5 -0
- package/dist/services/commit-message.service.d.ts.map +1 -1
- package/dist/services/commit-message.service.js +52 -15
- package/dist/services/commit-message.service.js.map +1 -1
- package/dist/services/task.service.d.ts.map +1 -1
- package/dist/services/task.service.js +18 -2
- package/dist/services/task.service.js.map +1 -1
- package/dist/web/assets/{AgentDemoPage-2AqgX6Cf.js → AgentDemoPage-BWRAHFkt.js} +1 -1
- package/dist/web/assets/{DemoPage-DyFtRa8x.js → DemoPage-BZ5M1SAB.js} +1 -1
- package/dist/web/assets/GeneralSettingsPage-BaOOwCVS.js +1 -0
- package/dist/web/assets/{NotificationSettingsPage-B0m5t4qH.js → NotificationSettingsPage-BN6EqfjU.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-CwRQ5Wr1.js → ProfileSettingsPage-CIP6uixV.js} +1 -1
- package/dist/web/assets/{ProjectKanbanPage-DwSI2gad.js → ProjectKanbanPage-CFUQT6JK.js} +14 -14
- package/dist/web/assets/{ProjectSettingsPage-BxGCUc3h.js → ProjectSettingsPage-CfNoBWSi.js} +1 -1
- package/dist/web/assets/{ProviderSettingsPage-BF3I_Oba.js → ProviderSettingsPage-DwDw9zUR.js} +2 -2
- package/dist/web/assets/{button-Dh8FHptl.js → button-D_HFYACB.js} +1 -1
- package/dist/web/assets/{chevron-down-B-UCtkpw.js → chevron-down-9WClAEn8.js} +1 -1
- package/dist/web/assets/chevron-right-BtN8Zto2.js +1 -0
- package/dist/web/assets/circle-alert-HHdlJNqe.js +1 -0
- package/dist/web/assets/{circle-check-MgjzSuSN.js → circle-check-cTH6ieYz.js} +1 -1
- package/dist/web/assets/{code-block-OCS4YCEC-DVFIuiT3.js → code-block-OCS4YCEC-CZZdDA2x.js} +1 -1
- package/dist/web/assets/confirm-dialog-CDJoysvO.js +1 -0
- package/dist/web/assets/{folder-picker-CzSKXweo.js → folder-picker-N8GypL3a.js} +1 -1
- package/dist/web/assets/{index-CFjAe6OM.js → index-D7K8KUJH.js} +6 -6
- package/dist/web/assets/index-vg6PeELc.css +1 -0
- package/dist/web/assets/loader-circle-lo-fmqx0.js +1 -0
- package/dist/web/assets/{mermaid-NOHMQCX5-BeW1Fb1_.js → mermaid-NOHMQCX5-CvKYIlPK.js} +3 -3
- package/dist/web/assets/{modal-hQOddjel.js → modal-CUBMvXmY.js} +1 -1
- package/dist/web/assets/{pencil-Ca4AsZLH.js → pencil-DYpEk25M.js} +1 -1
- package/dist/web/assets/rotate-ccw-CzrmYvZT.js +1 -0
- package/dist/web/assets/{select-DN0KH4Bi.js → select-DfuMoG1o.js} +1 -1
- package/dist/web/assets/use-profiles-Dne_0dqT.js +1 -0
- package/dist/web/assets/use-providers-BU-lcRuU.js +1 -0
- package/dist/web/index.html +2 -2
- package/node_modules/@agent-tower/shared/dist/types.d.ts +2 -0
- package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/prisma/schema.prisma +2 -0
- package/dist/web/assets/GeneralSettingsPage-B6uXd3Wp.js +0 -1
- package/dist/web/assets/chevron-right-CIJ95cIu.js +0 -1
- package/dist/web/assets/circle-alert-DwzV6nbB.js +0 -1
- package/dist/web/assets/confirm-dialog-B4CDGom7.js +0 -1
- package/dist/web/assets/index-CnQr7qh9.css +0 -1
- package/dist/web/assets/loader-circle-BiT33tiH.js +0 -1
- package/dist/web/assets/rotate-ccw-Dx6ZIa1R.js +0 -1
- package/dist/web/assets/use-profiles-CUlWd_po.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e as se,u as B,r as l,d as ne,j as e,f as re,g as le,h as ae,i as ie,t as T}from"./index-CFjAe6OM.js";import{B as S}from"./button-Dh8FHptl.js";import{S as oe}from"./select-DN0KH4Bi.js";import{a as W,F as _,R as ce}from"./rotate-ccw-Dx6ZIa1R.js";import{X as J,P as Q,T as de,M as G}from"./modal-hQOddjel.js";import{FolderPicker as ue}from"./folder-picker-CzSKXweo.js";import"./utils-CkSf8FUe.js";import"./chevron-down-B-UCtkpw.js";import"./chevron-right-CIJ95cIu.js";import"./loader-circle-BiT33tiH.js";import"./circle-alert-DwzV6nbB.js";const xe=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],me=se("folder-plus",xe);function pe({value:t,onChange:g,repoPath:b,placeholder:v}){const{t:o}=B(),[i,c]=l.useState(""),[x,h]=l.useState([]),[N,r]=l.useState(!1),[u,y]=l.useState(-1),m=l.useRef(null),f=l.useRef(null),P=l.useRef(void 0),F=l.useCallback(async s=>{if(!b||!s){h([]),r(!1);return}try{const a=await ne.get("/filesystem/complete",{params:{basePath:b,prefix:s}});h(a.results),r(a.results.length>0),y(-1)}catch{h([]),r(!1)}},[b]);l.useEffect(()=>{if(clearTimeout(P.current),!i){h([]),r(!1);return}return P.current=setTimeout(()=>F(i),200),()=>clearTimeout(P.current)},[i,F]),l.useEffect(()=>{const s=a=>{f.current&&!f.current.contains(a.target)&&m.current&&!m.current.contains(a.target)&&r(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[]);const k=s=>{const a=s.trim();!a||t.includes(a)||(g([...t,a]),c(""),r(!1),m.current?.focus())},z=s=>{g(t.filter((a,w)=>w!==s))},D=s=>{s.type==="directory"?(c(s.path),m.current?.focus()):k(s.path)},C=(s,a)=>{a.stopPropagation(),k(s.path.replace(/\/$/,""))},A=s=>{s.nativeEvent.isComposing||s.nativeEvent.keyCode===229||(N&&x.length>0?s.key==="ArrowDown"?(s.preventDefault(),y(a=>Math.min(a+1,x.length-1))):s.key==="ArrowUp"?(s.preventDefault(),y(a=>Math.max(a-1,-1))):s.key==="Enter"?(s.preventDefault(),u>=0?D(x[u]):k(i)):s.key==="Escape"&&r(!1):s.key==="Enter"&&(s.preventDefault(),k(i)))};return e.jsxs("div",{children:[t.length>0&&e.jsx("div",{className:"border border-neutral-200 rounded-lg mb-2 divide-y divide-neutral-100",children:t.map((s,a)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 group",children:[s.includes(".")&&!s.endsWith("/")?e.jsx(W,{size:14,className:"text-neutral-400 shrink-0"}):e.jsx(_,{size:14,className:"text-amber-500 shrink-0"}),e.jsx("span",{className:"text-sm font-mono text-neutral-700 truncate flex-1",children:s}),e.jsx("button",{onClick:()=>z(a),className:"p-0.5 text-neutral-300 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:e.jsx(J,{size:14})})]},s))}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:m,type:"text",value:i,onChange:s=>c(s.target.value),onKeyDown:A,onFocus:()=>{i&&x.length>0&&r(!0)},placeholder:v??o("输入文件路径..."),className:"flex-1 px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsxs("button",{onClick:()=>k(i),disabled:!i.trim(),className:"flex items-center gap-1 px-3 py-2 text-sm bg-neutral-900 text-white rounded-lg hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:[e.jsx(Q,{size:14}),e.jsx("span",{children:o("添加")})]})]}),N&&e.jsx("div",{ref:f,className:"absolute z-50 left-0 right-0 mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg max-h-[200px] overflow-y-auto",children:x.map((s,a)=>e.jsxs("button",{onClick:()=>D(s),className:`w-full flex items-center gap-2 px-3 py-1.5 text-sm text-left hover:bg-neutral-50 transition-colors ${a===u?"bg-neutral-100":""}`,children:[s.type==="directory"?e.jsx(_,{size:14,className:"text-amber-500 shrink-0"}):e.jsx(W,{size:14,className:"text-neutral-400 shrink-0"}),e.jsx("span",{className:"font-mono text-neutral-700 truncate flex-1",children:s.path}),s.type==="directory"&&e.jsx("span",{onClick:w=>C(s,w),className:"p-0.5 text-neutral-300 hover:text-emerald-600 shrink-0",title:o("添加此目录"),children:e.jsx(me,{size:14})})]},s.path))})]})]})}function he({value:t,onChange:g}){const{t:b}=B(),[v,o]=l.useState(""),[i,c]=l.useState(""),x=()=>{const r=v.trim(),u=i.trim();!r||!u||(g([...t,{name:r,command:u}]),o(""),c(""))},h=r=>{g(t.filter((u,y)=>y!==r))},N=r=>{r.key==="Enter"&&!r.nativeEvent.isComposing&&r.nativeEvent.keyCode!==229&&(r.preventDefault(),x())};return e.jsxs("div",{children:[t.length>0&&e.jsx("div",{className:"border border-neutral-200 rounded-lg mb-2 divide-y divide-neutral-100",children:t.map((r,u)=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 group",children:[e.jsx("span",{className:"text-sm font-medium text-neutral-700 w-28 shrink-0 truncate",children:r.name}),e.jsx("span",{className:"text-sm font-mono text-neutral-500 flex-1 truncate",children:r.command}),e.jsx("button",{onClick:()=>h(u),className:"p-0.5 text-neutral-300 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:e.jsx(J,{size:14})})]},u))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:v,onChange:r=>o(r.target.value),onKeyDown:N,placeholder:b("名称"),className:"w-28 shrink-0 px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsx("input",{type:"text",value:i,onChange:r=>c(r.target.value),onKeyDown:N,placeholder:b("命令"),className:"flex-1 px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsxs("button",{onClick:x,disabled:!v.trim()||!i.trim(),className:"flex items-center gap-1 px-3 py-2 text-sm bg-neutral-900 text-white rounded-lg hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed transition-colors shrink-0",children:[e.jsx(Q,{size:14}),e.jsx("span",{children:b("添加")})]})]})]})}function fe(t){return t?t.split(",").map(g=>g.trim()).filter(Boolean):[]}function je(t){if(!t)return[];try{return JSON.parse(t)}catch{return[]}}function $(t){return typeof t.color!="string"||t.color.trim()===""?"bg-neutral-400":t.color.startsWith("bg-")?t.color:t.color.startsWith("text-")?t.color.replace("text-","bg-"):"bg-neutral-400"}function De(){const{t}=B(),{data:g,isLoading:b}=re({limit:100,includeArchived:!0}),v=le(),o=ae(),i=ie(),[c,x]=l.useState(""),[h,N]=l.useState(null),[r,u]=l.useState({copyFiles:[],setupScript:"",quickCommands:[]}),[y,m]=l.useState(!1),[f,P]=l.useState(null),[F,k]=l.useState(!1),[z,D]=l.useState(!1),[C,A]=l.useState(!1),[s,a]=l.useState(!1),[w,I]=l.useState(""),R=g?.data??[],j=l.useMemo(()=>R.filter(n=>!n.archivedAt),[R]),E=l.useMemo(()=>R.filter(n=>n.archivedAt),[R]),d=j.find(n=>n.id===c),q=l.useMemo(()=>R.find(n=>n.id===f)??null,[f,R]);if(l.useEffect(()=>{!c&&j.length>0&&x(j[0].id)},[j,c]),l.useEffect(()=>{if(h){j.some(n=>n.id===h)&&(x(h),N(null));return}c&&!j.some(n=>n.id===c)&&(x(j[0]?.id??""),m(!1))},[j,h,c]),l.useEffect(()=>{d&&!y&&u({copyFiles:fe(d.copyFiles),setupScript:d.setupScript??"",quickCommands:je(d.quickCommands)})},[d,y]),b)return e.jsx("div",{className:"p-6 text-sm text-neutral-400",children:t("加载中...")});if(R.length===0)return e.jsx("div",{className:"p-6 text-sm text-neutral-400",children:t("暂无项目,请先创建项目")});const H=j.map(n=>({value:n.id,label:n.name})),V=()=>{c&&v.mutate({id:c,copyFiles:r.copyFiles.length>0?r.copyFiles.join(", "):null,setupScript:r.setupScript.trim()||null,quickCommands:r.quickCommands.length>0?JSON.stringify(r.quickCommands):null},{onSuccess:()=>m(!1)})},X=n=>{N(null),x(n),m(!1)},Z=()=>{d&&(P(d.id),A(!1),a(!1),k(!0))},O=()=>{o.isPending||(k(!1),P(null),A(!1),a(!1))},Y=async()=>{if(f)try{await o.mutateAsync({id:f,deleteRepo:C}),T.success(t(C?"项目已删除,并清理了本地文件":"项目已删除")),m(!1),O()}catch{}},ee=n=>{const p=E.find(U=>U.id===n);P(n),I(p?.repoDeletedAt?p.repoPath:""),D(!0)},M=()=>{i.isPending||(D(!1),P(null),I(""))},te=async()=>{if(!(!f||q?.repoDeletedAt&&!w.trim()))try{const p=await i.mutateAsync({id:f,repoPath:w.trim()||void 0});T.success(t("项目已恢复"));for(const U of p.warnings)T.warning(U);m(!1),N(p.project.id),x(p.project.id),M()}catch{}},K=q?.name??t("this project"),L=!!q?.repoDeletedAt;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-10 py-6 mx-auto w-full max-w-4xl space-y-8",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("项目配置")}),e.jsx("p",{className:"text-[12px] text-neutral-400",children:t("配置当前项目的 worktree 初始化行为,并在此页统一管理删除与恢复。")})]}),j.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-700 mb-2",children:t("选择项目")}),e.jsx(oe,{value:c,onChange:X,options:H,placeholder:t("选择项目...")})]}),d?e.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-4",children:e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${$(d)}`}),e.jsx("p",{className:"text-sm font-medium text-neutral-900",children:d.name})]}),e.jsx("p",{className:"text-xs text-neutral-500 break-all",children:d.repoPath}),d.repoRemoteUrl?e.jsxs("p",{className:"text-xs text-neutral-400 break-all",children:[t("Remote"),": ",d.repoRemoteUrl]}):null]}),e.jsxs("div",{className:"flex flex-col items-stretch gap-2 md:items-end",children:[e.jsxs(S,{size:"sm",variant:"destructive",onClick:Z,disabled:o.isPending||i.isPending,children:[e.jsx(de,{size:14}),t("删除项目")]}),e.jsx("p",{className:"text-[11px] text-neutral-500 md:max-w-56 md:text-right",children:t("删除后项目会从默认列表隐藏,但历史任务、workspace 与会话记录仍会保留。")})]})]})}):null]}):e.jsx("div",{className:"rounded-xl border border-dashed border-neutral-200 bg-neutral-50 px-4 py-5 text-sm text-neutral-500",children:t("当前没有可配置的项目。你可以先创建项目,或在下方恢复已删除项目。")})]}),d?e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("自动复制文件")}),e.jsx("p",{className:"text-[12px] text-neutral-400 mb-3",children:t("创建 worktree 时自动从主仓库复制的文件或目录。支持 glob 模式。")}),e.jsx(pe,{value:r.copyFiles,onChange:n=>{u(p=>({...p,copyFiles:n})),m(!0)},repoPath:d.repoPath}),e.jsx("p",{className:"text-[11px] text-neutral-400 mt-2",children:t("适用于不在 git 管理中但启动必需的文件,如 .env、node_modules、数据库文件等")})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("Setup 脚本")}),e.jsx("p",{className:"text-[12px] text-neutral-400 mb-3",children:t("创建 worktree 后自动执行的命令,每行一条,按顺序执行。")}),e.jsx("textarea",{value:r.setupScript,onChange:n=>{u(p=>({...p,setupScript:n.target.value})),m(!0)},placeholder:`pnpm install
|
|
1
|
+
import{h as se,u as B,r as l,g as ne,j as e,i as re,k as le,l as ae,m as ie,t as T}from"./index-D7K8KUJH.js";import{B as S}from"./button-D_HFYACB.js";import{S as oe}from"./select-DfuMoG1o.js";import{a as W,F as _,R as ce}from"./rotate-ccw-CzrmYvZT.js";import{X as J,P as Q,T as de,M as G}from"./modal-CUBMvXmY.js";import{FolderPicker as ue}from"./folder-picker-N8GypL3a.js";import"./utils-CkSf8FUe.js";import"./chevron-down-9WClAEn8.js";import"./chevron-right-BtN8Zto2.js";import"./loader-circle-lo-fmqx0.js";import"./circle-alert-HHdlJNqe.js";const xe=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],me=se("folder-plus",xe);function pe({value:t,onChange:g,repoPath:b,placeholder:v}){const{t:o}=B(),[i,c]=l.useState(""),[x,h]=l.useState([]),[N,r]=l.useState(!1),[u,y]=l.useState(-1),m=l.useRef(null),f=l.useRef(null),P=l.useRef(void 0),F=l.useCallback(async s=>{if(!b||!s){h([]),r(!1);return}try{const a=await ne.get("/filesystem/complete",{params:{basePath:b,prefix:s}});h(a.results),r(a.results.length>0),y(-1)}catch{h([]),r(!1)}},[b]);l.useEffect(()=>{if(clearTimeout(P.current),!i){h([]),r(!1);return}return P.current=setTimeout(()=>F(i),200),()=>clearTimeout(P.current)},[i,F]),l.useEffect(()=>{const s=a=>{f.current&&!f.current.contains(a.target)&&m.current&&!m.current.contains(a.target)&&r(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[]);const k=s=>{const a=s.trim();!a||t.includes(a)||(g([...t,a]),c(""),r(!1),m.current?.focus())},z=s=>{g(t.filter((a,w)=>w!==s))},D=s=>{s.type==="directory"?(c(s.path),m.current?.focus()):k(s.path)},C=(s,a)=>{a.stopPropagation(),k(s.path.replace(/\/$/,""))},A=s=>{s.nativeEvent.isComposing||s.nativeEvent.keyCode===229||(N&&x.length>0?s.key==="ArrowDown"?(s.preventDefault(),y(a=>Math.min(a+1,x.length-1))):s.key==="ArrowUp"?(s.preventDefault(),y(a=>Math.max(a-1,-1))):s.key==="Enter"?(s.preventDefault(),u>=0?D(x[u]):k(i)):s.key==="Escape"&&r(!1):s.key==="Enter"&&(s.preventDefault(),k(i)))};return e.jsxs("div",{children:[t.length>0&&e.jsx("div",{className:"border border-neutral-200 rounded-lg mb-2 divide-y divide-neutral-100",children:t.map((s,a)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 group",children:[s.includes(".")&&!s.endsWith("/")?e.jsx(W,{size:14,className:"text-neutral-400 shrink-0"}):e.jsx(_,{size:14,className:"text-amber-500 shrink-0"}),e.jsx("span",{className:"text-sm font-mono text-neutral-700 truncate flex-1",children:s}),e.jsx("button",{onClick:()=>z(a),className:"p-0.5 text-neutral-300 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:e.jsx(J,{size:14})})]},s))}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:m,type:"text",value:i,onChange:s=>c(s.target.value),onKeyDown:A,onFocus:()=>{i&&x.length>0&&r(!0)},placeholder:v??o("输入文件路径..."),className:"flex-1 px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsxs("button",{onClick:()=>k(i),disabled:!i.trim(),className:"flex items-center gap-1 px-3 py-2 text-sm bg-neutral-900 text-white rounded-lg hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:[e.jsx(Q,{size:14}),e.jsx("span",{children:o("添加")})]})]}),N&&e.jsx("div",{ref:f,className:"absolute z-50 left-0 right-0 mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg max-h-[200px] overflow-y-auto",children:x.map((s,a)=>e.jsxs("button",{onClick:()=>D(s),className:`w-full flex items-center gap-2 px-3 py-1.5 text-sm text-left hover:bg-neutral-50 transition-colors ${a===u?"bg-neutral-100":""}`,children:[s.type==="directory"?e.jsx(_,{size:14,className:"text-amber-500 shrink-0"}):e.jsx(W,{size:14,className:"text-neutral-400 shrink-0"}),e.jsx("span",{className:"font-mono text-neutral-700 truncate flex-1",children:s.path}),s.type==="directory"&&e.jsx("span",{onClick:w=>C(s,w),className:"p-0.5 text-neutral-300 hover:text-emerald-600 shrink-0",title:o("添加此目录"),children:e.jsx(me,{size:14})})]},s.path))})]})]})}function he({value:t,onChange:g}){const{t:b}=B(),[v,o]=l.useState(""),[i,c]=l.useState(""),x=()=>{const r=v.trim(),u=i.trim();!r||!u||(g([...t,{name:r,command:u}]),o(""),c(""))},h=r=>{g(t.filter((u,y)=>y!==r))},N=r=>{r.key==="Enter"&&!r.nativeEvent.isComposing&&r.nativeEvent.keyCode!==229&&(r.preventDefault(),x())};return e.jsxs("div",{children:[t.length>0&&e.jsx("div",{className:"border border-neutral-200 rounded-lg mb-2 divide-y divide-neutral-100",children:t.map((r,u)=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 group",children:[e.jsx("span",{className:"text-sm font-medium text-neutral-700 w-28 shrink-0 truncate",children:r.name}),e.jsx("span",{className:"text-sm font-mono text-neutral-500 flex-1 truncate",children:r.command}),e.jsx("button",{onClick:()=>h(u),className:"p-0.5 text-neutral-300 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:e.jsx(J,{size:14})})]},u))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:v,onChange:r=>o(r.target.value),onKeyDown:N,placeholder:b("名称"),className:"w-28 shrink-0 px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsx("input",{type:"text",value:i,onChange:r=>c(r.target.value),onKeyDown:N,placeholder:b("命令"),className:"flex-1 px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300"}),e.jsxs("button",{onClick:x,disabled:!v.trim()||!i.trim(),className:"flex items-center gap-1 px-3 py-2 text-sm bg-neutral-900 text-white rounded-lg hover:bg-neutral-800 disabled:opacity-30 disabled:cursor-not-allowed transition-colors shrink-0",children:[e.jsx(Q,{size:14}),e.jsx("span",{children:b("添加")})]})]})]})}function fe(t){return t?t.split(",").map(g=>g.trim()).filter(Boolean):[]}function je(t){if(!t)return[];try{return JSON.parse(t)}catch{return[]}}function $(t){return typeof t.color!="string"||t.color.trim()===""?"bg-neutral-400":t.color.startsWith("bg-")?t.color:t.color.startsWith("text-")?t.color.replace("text-","bg-"):"bg-neutral-400"}function De(){const{t}=B(),{data:g,isLoading:b}=re({limit:100,includeArchived:!0}),v=le(),o=ae(),i=ie(),[c,x]=l.useState(""),[h,N]=l.useState(null),[r,u]=l.useState({copyFiles:[],setupScript:"",quickCommands:[]}),[y,m]=l.useState(!1),[f,P]=l.useState(null),[F,k]=l.useState(!1),[z,D]=l.useState(!1),[C,A]=l.useState(!1),[s,a]=l.useState(!1),[w,I]=l.useState(""),R=g?.data??[],j=l.useMemo(()=>R.filter(n=>!n.archivedAt),[R]),E=l.useMemo(()=>R.filter(n=>n.archivedAt),[R]),d=j.find(n=>n.id===c),q=l.useMemo(()=>R.find(n=>n.id===f)??null,[f,R]);if(l.useEffect(()=>{!c&&j.length>0&&x(j[0].id)},[j,c]),l.useEffect(()=>{if(h){j.some(n=>n.id===h)&&(x(h),N(null));return}c&&!j.some(n=>n.id===c)&&(x(j[0]?.id??""),m(!1))},[j,h,c]),l.useEffect(()=>{d&&!y&&u({copyFiles:fe(d.copyFiles),setupScript:d.setupScript??"",quickCommands:je(d.quickCommands)})},[d,y]),b)return e.jsx("div",{className:"p-6 text-sm text-neutral-400",children:t("加载中...")});if(R.length===0)return e.jsx("div",{className:"p-6 text-sm text-neutral-400",children:t("暂无项目,请先创建项目")});const H=j.map(n=>({value:n.id,label:n.name})),V=()=>{c&&v.mutate({id:c,copyFiles:r.copyFiles.length>0?r.copyFiles.join(", "):null,setupScript:r.setupScript.trim()||null,quickCommands:r.quickCommands.length>0?JSON.stringify(r.quickCommands):null},{onSuccess:()=>m(!1)})},X=n=>{N(null),x(n),m(!1)},Z=()=>{d&&(P(d.id),A(!1),a(!1),k(!0))},O=()=>{o.isPending||(k(!1),P(null),A(!1),a(!1))},Y=async()=>{if(f)try{await o.mutateAsync({id:f,deleteRepo:C}),T.success(t(C?"项目已删除,并清理了本地文件":"项目已删除")),m(!1),O()}catch{}},ee=n=>{const p=E.find(U=>U.id===n);P(n),I(p?.repoDeletedAt?p.repoPath:""),D(!0)},M=()=>{i.isPending||(D(!1),P(null),I(""))},te=async()=>{if(!(!f||q?.repoDeletedAt&&!w.trim()))try{const p=await i.mutateAsync({id:f,repoPath:w.trim()||void 0});T.success(t("项目已恢复"));for(const U of p.warnings)T.warning(U);m(!1),N(p.project.id),x(p.project.id),M()}catch{}},K=q?.name??t("this project"),L=!!q?.repoDeletedAt;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-10 py-6 mx-auto w-full max-w-4xl space-y-8",children:[e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("项目配置")}),e.jsx("p",{className:"text-[12px] text-neutral-400",children:t("配置当前项目的 worktree 初始化行为,并在此页统一管理删除与恢复。")})]}),j.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-700 mb-2",children:t("选择项目")}),e.jsx(oe,{value:c,onChange:X,options:H,placeholder:t("选择项目...")})]}),d?e.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-4",children:e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${$(d)}`}),e.jsx("p",{className:"text-sm font-medium text-neutral-900",children:d.name})]}),e.jsx("p",{className:"text-xs text-neutral-500 break-all",children:d.repoPath}),d.repoRemoteUrl?e.jsxs("p",{className:"text-xs text-neutral-400 break-all",children:[t("Remote"),": ",d.repoRemoteUrl]}):null]}),e.jsxs("div",{className:"flex flex-col items-stretch gap-2 md:items-end",children:[e.jsxs(S,{size:"sm",variant:"destructive",onClick:Z,disabled:o.isPending||i.isPending,children:[e.jsx(de,{size:14}),t("删除项目")]}),e.jsx("p",{className:"text-[11px] text-neutral-500 md:max-w-56 md:text-right",children:t("删除后项目会从默认列表隐藏,但历史任务、workspace 与会话记录仍会保留。")})]})]})}):null]}):e.jsx("div",{className:"rounded-xl border border-dashed border-neutral-200 bg-neutral-50 px-4 py-5 text-sm text-neutral-500",children:t("当前没有可配置的项目。你可以先创建项目,或在下方恢复已删除项目。")})]}),d?e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("自动复制文件")}),e.jsx("p",{className:"text-[12px] text-neutral-400 mb-3",children:t("创建 worktree 时自动从主仓库复制的文件或目录。支持 glob 模式。")}),e.jsx(pe,{value:r.copyFiles,onChange:n=>{u(p=>({...p,copyFiles:n})),m(!0)},repoPath:d.repoPath}),e.jsx("p",{className:"text-[11px] text-neutral-400 mt-2",children:t("适用于不在 git 管理中但启动必需的文件,如 .env、node_modules、数据库文件等")})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("Setup 脚本")}),e.jsx("p",{className:"text-[12px] text-neutral-400 mb-3",children:t("创建 worktree 后自动执行的命令,每行一条,按顺序执行。")}),e.jsx("textarea",{value:r.setupScript,onChange:n=>{u(p=>({...p,setupScript:n.target.value})),m(!0)},placeholder:`pnpm install
|
|
2
2
|
pnpm run setup`,rows:4,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm font-mono focus:outline-none focus:ring-1 focus:ring-neutral-300 resize-none"}),e.jsx("p",{className:"text-[11px] text-neutral-400 mt-1",children:t("命令在 worktree 目录下执行,单条命令超时 5 分钟,失败不会阻断后续命令")})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("常用命令")}),e.jsx("p",{className:"text-[12px] text-neutral-400 mb-3",children:t("在终端中可快速执行的命令,不会自动运行。")}),e.jsx(he,{value:r.quickCommands,onChange:n=>{u(p=>({...p,quickCommands:n})),m(!0)}})]})]}):null,e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900 mb-1",children:t("已删除项目")}),e.jsx("p",{className:"text-[12px] text-neutral-400",children:t("这些项目不会出现在主看板里,但历史记录仍保留;如源码已删除,恢复时需要重新绑定 repoPath。")})]}),e.jsx("span",{className:"rounded-full bg-neutral-100 px-2.5 py-1 text-[11px] font-medium text-neutral-500",children:E.length})]}),E.length===0?e.jsx("div",{className:"rounded-xl border border-dashed border-neutral-200 bg-neutral-50 px-4 py-5 text-sm text-neutral-500",children:t("暂无已删除项目")}):e.jsx("div",{className:"space-y-3",children:E.map(n=>e.jsx("div",{className:"rounded-xl border border-neutral-200 bg-white px-4 py-4",children:e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-start md:justify-between",children:[e.jsxs("div",{className:"space-y-2 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${$(n)}`}),e.jsx("p",{className:"text-sm font-medium text-neutral-900",children:n.name}),e.jsx("span",{className:"rounded-full bg-neutral-100 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:t("已删除")}),n.repoDeletedAt?e.jsx("span",{className:"rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-medium text-amber-700",children:t("源码已删除")}):null]}),n.repoDeletedAt?e.jsx("p",{className:"text-xs text-neutral-500",children:t("本地源码目录已删除,相关 Git/代码能力已禁用。恢复时需要重新绑定一个有效仓库路径。")}):e.jsx("p",{className:"text-xs text-neutral-500 break-all",children:n.repoPath}),n.repoRemoteUrl?e.jsxs("p",{className:"text-xs text-neutral-400 break-all",children:[t("Remote"),": ",n.repoRemoteUrl]}):null]}),e.jsxs(S,{size:"sm",variant:"outline",onClick:()=>ee(n.id),disabled:o.isPending||i.isPending,children:[e.jsx(ce,{size:14}),t("恢复")]})]})},n.id))})]}),y&&d?e.jsx("div",{className:"sticky bottom-6 flex justify-end",children:e.jsx(S,{size:"sm",onClick:V,disabled:v.isPending,children:v.isPending?t("保存中..."):t("保存")})}):null]}),e.jsx(G,{isOpen:F,onClose:O,title:t("Delete Project"),action:e.jsxs(e.Fragment,{children:[e.jsx(S,{variant:"outline",onClick:O,disabled:o.isPending,children:t("Cancel")}),e.jsx(S,{variant:"destructive",onClick:Y,disabled:o.isPending||C&&!s,children:o.isPending?t("Deleting..."):t("Delete Project")})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-neutral-600 leading-relaxed",children:t("项目「{title}」将从默认项目列表隐藏,但历史任务、workspace 和会话记录仍会保留。",{title:K})}),e.jsxs("label",{className:"flex items-start gap-3 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-3",children:[e.jsx("input",{type:"checkbox",checked:C,onChange:n=>{A(n.target.checked),n.target.checked||a(!1)},className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-neutral-900",children:t("同时删除本地项目文件")}),e.jsx("p",{className:"mt-1 text-xs text-neutral-500",children:t("勾选后会删除 repoPath 指向的本地仓库目录,并禁用代码/Git 相关能力。")})]})]}),C?e.jsxs("div",{className:"rounded-lg border border-red-200 bg-red-50 px-3 py-3",children:[e.jsx("p",{className:"text-sm font-medium text-red-700",children:t("勾选后会连项目文件一起删除,请谨慎选择。")}),e.jsx("p",{className:"mt-1 text-xs text-red-600",children:t("恢复该项目时需要重新绑定一个有效的 Git 仓库路径。")}),e.jsxs("label",{className:"mt-3 flex items-start gap-2 text-xs text-red-700",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:n=>a(n.target.checked),className:"mt-0.5"}),e.jsx("span",{children:t("我已确认这会删除本地项目文件")})]})]}):null,o.isError?e.jsx("p",{className:"text-xs text-red-500",children:o.error instanceof Error?o.error.message:t("Failed to delete project")}):null]})}),e.jsx(G,{isOpen:z,onClose:M,title:t("Restore Project"),action:e.jsxs(e.Fragment,{children:[e.jsx(S,{variant:"outline",onClick:M,disabled:i.isPending,children:t("Cancel")}),e.jsx(S,{onClick:te,disabled:i.isPending||L&&!w.trim(),children:i.isPending?t("Restoring..."):t("Restore Project")})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-neutral-600 leading-relaxed",children:L?t("项目「{title}」的本地仓库文件已删除。恢复前需要重新绑定一个有效的 Git 仓库路径。",{title:K}):t("恢复后,项目会重新出现在默认项目列表中。")}),L?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:t("Repository Path")}),e.jsx(ue,{value:w,onChange:I}),e.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:t("Agent Tower 会尽量校验仓库 identity;如果 remote URL 或目录名不同,会给出警告但允许继续。")})]}):null,i.isError?e.jsx("p",{className:"text-xs text-red-500",children:i.error instanceof Error?i.error.message:t("Failed to restore project")}):null]})})]})}export{De as ProjectSettingsPage};
|
package/dist/web/assets/{ProviderSettingsPage-BF3I_Oba.js → ProviderSettingsPage-DwDw9zUR.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h as X,d as be,q as ve,g as ye,u as T,r as w,j as n,t as P,n as Q}from"./index-D7K8KUJH.js";import{u as je,a as we,b as Ne,c as Ce,d as Ee,e as ke,f as Pe}from"./use-providers-BU-lcRuU.js";import{B as E}from"./button-D_HFYACB.js";import{C as _e,A as N}from"./confirm-dialog-CDJoysvO.js";import{P as re,T as se,M as q}from"./modal-CUBMvXmY.js";import{S as le}from"./select-DfuMoG1o.js";import"./log-adapter-50wgehrc.js";import{c as U}from"./utils-CkSf8FUe.js";import{C as ae}from"./chevron-down-9WClAEn8.js";import{P as Oe}from"./pencil-DYpEk25M.js";import{C as Ie}from"./circle-check-cTH6ieYz.js";const Te=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Ae=X("circle-x",Te);const Se=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],De=X("download",Se);const Le=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],Re=X("upload",Le);function Me(e,t){let l=e.slice(0,t).split(/\r\n|\n|\r/g);return[l.length,l.pop().length+1]}function Fe(e,t,l){let i=e.split(/\r\n|\n|\r/g),a="",s=(Math.log10(t+1)|0)+1;for(let r=t-1;r<=t+1;r++){let o=i[r-1];o&&(a+=r.toString().padEnd(s," "),a+=": ",a+=o,a+=`
|
|
2
2
|
`,r===t&&(a+=" ".repeat(s+l+2),a+=`^
|
|
3
3
|
`))}return a}class f extends Error{line;column;codeblock;constructor(t,l){const[i,a]=Me(l.toml,l.ptr),s=Fe(l.toml,i,a);super(`Invalid TOML document: ${t}
|
|
4
4
|
|
|
@@ -51,4 +51,4 @@ ${s}`,l),this.line=i,this.column=a,this.codeblock=s}}function Ue(e,t){let l=0;fo
|
|
|
51
51
|
# name = "Ollama"
|
|
52
52
|
# base_url = "http://localhost:11434/v1"
|
|
53
53
|
# wire_api = "responses"
|
|
54
|
-
`;function z(e){return e===N.CLAUDE_CODE?et:e===N.CODEX?tt:""}function nt(e){return e===N.CLAUDE_CODE||e===N.CODEX}const rt=Object.values(J).flat().reduce((e,t)=>(e[t.key]||(e[t.key]=t.label),e),{}),st=Object.values(J).flat().reduce((e,t)=>(t.options&&(e[t.key]=Object.fromEntries(t.options.map(l=>[l.value,l.label]))),e),{});function lt(e,t){return typeof t=="boolean"?t?Q("是"):Q("否"):typeof t=="string"&&t?st[e]?.[t]??t:String(t)}function M(e,t){return e instanceof Error?e.message:t}function at(e){return`agent-tower-provider-backup-${e.replace(/[:.]/g,"-")}.json`}function it(e,t){const l=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),i=URL.createObjectURL(l),a=document.createElement("a");a.href=i,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function ot(e){switch(e){case"CREATE":return{label:"新增",className:"text-green-700 bg-green-50"};case"OVERWRITE":return{label:"覆盖",className:"text-amber-700 bg-amber-50"};case"SKIP":return{label:"跳过",className:"text-neutral-600 bg-neutral-100"}}}function ct({type:e}){const{t}=T();return e==="LOGIN_DETECTED"||e==="INSTALLATION_FOUND"?n.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs text-green-700 bg-green-50 rounded",children:[n.jsx(Ie,{size:12}),t("可用")]}):n.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs text-neutral-500 bg-neutral-50 rounded",children:[n.jsx(Ae,{size:12}),t("不可用")]})}function B({title:e,defaultOpen:t=!1,children:l}){const[i,a]=w.useState(t);return n.jsxs("div",{className:"border border-neutral-200 rounded-lg",children:[n.jsxs("button",{type:"button",onClick:()=>a(s=>!s),className:"w-full flex items-center justify-between px-4 py-2.5 text-sm font-medium text-neutral-700 hover:bg-neutral-50 transition-colors rounded-lg",children:[e,n.jsx(ae,{size:14,className:`transition-transform ${i?"rotate-180":""}`})]}),i&&n.jsx("div",{className:"px-4 pb-4 space-y-3",children:l})]})}function dt({agentType:e,config:t,onChange:l}){const{t:i}=T(),a=J[e]??[];if(a.length===0)return n.jsx("p",{className:"text-xs text-neutral-400",children:i("该类型暂无运行配置")});const s=(r,o)=>{l({...t,[r]:o})};return n.jsx("div",{className:"space-y-3",children:a.map(r=>r.type==="textarea"?n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm text-neutral-700 mb-1",children:i(r.label)}),n.jsx("textarea",{value:t[r.key]??"",onChange:o=>s(r.key,o.target.value||void 0),placeholder:r.placeholder?i(r.placeholder):void 0,rows:r.rows??3,className:"w-full px-3 py-1.5 text-sm border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900"})]},r.key):r.type==="cursor_model"?n.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start",children:[n.jsx("label",{className:"text-sm text-neutral-700 w-32 shrink-0 sm:pt-2",children:i(r.label)}),n.jsx(Qe,{value:t[r.key]??"",onChange:o=>s(r.key,o)})]},r.key):n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("label",{className:"text-sm text-neutral-700 w-32 shrink-0",children:i(r.label)}),r.type==="switch"&&n.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:!!t[r.key],onChange:o=>s(r.key,o.target.checked),className:"sr-only peer"}),n.jsx("div",{className:"w-9 h-5 bg-neutral-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-neutral-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-neutral-900"})]}),r.type==="input"&&n.jsx("input",{type:"text",value:t[r.key]??"",onChange:o=>s(r.key,o.target.value||void 0),placeholder:r.placeholder?i(r.placeholder):void 0,className:"flex-1 px-3 py-1.5 text-sm border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900"}),r.type==="select"&&r.options&&n.jsx(le,{value:t[r.key]??"",onChange:o=>s(r.key,o||void 0),options:r.options,placeholder:i("选择...")})]},r.key))})}function ut({isOpen:e,onClose:t,initialData:l,onSave:i}){const{t:a}=T(),[s,r]=w.useState(l??{name:"",agentType:N.CLAUDE_CODE,config:ne(),settings:"",env:[],isDefault:!1}),[o,d]=w.useState("");w.useEffect(()=>{if(!l&&!s.settings){const u=z(s.agentType);u&&r(g=>({...g,settings:u}))}},[]);const c=u=>{r(g=>({...g,agentType:u,config:ne(),settings:z(u)}))},p=()=>{d("");const u=K(s.agentType,s.config),g={};for(const[j,_]of Object.entries(u))_!==void 0&&_!==""&&(g[j]=_);const y=s.settings.trim();if(y){if(s.agentType===N.CODEX)try{He(y)}catch(j){d(a("TOML 语法错误: {message}",{message:j instanceof Error?j.message:String(j)}));return}else if(s.agentType===N.CLAUDE_CODE)try{JSON.parse(y)}catch{d(a("JSON 语法错误"));return}}const b={};for(const{key:j,value:_}of s.env){const D=j.trim();D&&(b[D]=_)}const C={name:s.name,agentType:s.agentType,config:g,settings:y||void 0,env:Object.keys(b).length>0?b:void 0,isDefault:s.isDefault};i(C)};if(!e)return null;const v=nt(s.agentType),h=s.agentType===N.CODEX;return n.jsx(q,{isOpen:e,onClose:t,title:a(l?"编辑 Provider":"新建 Provider"),className:"max-w-2xl",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-medium text-neutral-700 mb-1",children:a("名称")}),n.jsx("input",{type:"text",value:s.name,onChange:u=>r(g=>({...g,name:u.target.value})),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900",placeholder:a("例如: Claude Code (官方)")})]}),!l&&n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-medium text-neutral-700 mb-1",children:a("Agent 类型")}),n.jsx(le,{value:s.agentType,onChange:u=>c(u),options:Object.values(N).map(u=>({value:u,label:Z[u]??u})),placeholder:a("选择 Agent 类型")})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",id:"isDefault",checked:s.isDefault,onChange:u=>r(g=>({...g,isDefault:u.target.checked})),className:"w-4 h-4"}),n.jsx("label",{htmlFor:"isDefault",className:"text-sm text-neutral-700",children:a("设为该类型的默认 Provider")})]}),n.jsx(B,{title:a("运行配置"),defaultOpen:!0,children:n.jsx(dt,{agentType:s.agentType,config:s.config,onChange:u=>r(g=>({...g,config:u}))})}),n.jsxs(B,{title:a("环境变量"),defaultOpen:s.env.length>0,children:[n.jsxs("p",{className:"text-xs text-neutral-500 mb-2",children:[a("注入到 Agent 进程的环境变量。Codex 的")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"env_key"})," ",a("指定的是变量名,实际值需在此处设置。")]}),n.jsxs("div",{className:"space-y-2",children:[s.env.map((u,g)=>n.jsxs("div",{className:"flex gap-2 items-center",children:[n.jsx("input",{type:"text",value:u.key,onChange:y=>{const b=[...s.env];b[g]={...b[g],key:y.target.value},r(C=>({...C,env:b}))},placeholder:a("变量名,如 AZURE_OPENAI_API_KEY"),className:"flex-1 px-3 py-1.5 text-sm font-mono border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900"}),n.jsx("input",{type:"text",value:u.value,onChange:y=>{const b=[...s.env];b[g]={...b[g],value:y.target.value},r(C=>({...C,env:b}))},placeholder:a("值"),className:"flex-1 px-3 py-1.5 text-sm font-mono border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900"}),n.jsx("button",{type:"button",onClick:()=>{const y=s.env.filter((b,C)=>C!==g);r(b=>({...b,env:y}))},className:"p-1.5 text-neutral-400 hover:text-red-500",children:n.jsx(se,{size:14})})]},g)),n.jsxs(E,{variant:"outline",size:"sm",onClick:()=>r(u=>({...u,env:[...u.env,{key:"",value:""}]})),children:[n.jsx(re,{size:12,className:"mr-1"}),a("添加变量")]})]})]}),v&&n.jsxs(B,{title:a(h?"CLI 原生配置 (config.toml)":"CLI 原生配置 (settings.json)"),children:[n.jsx("p",{className:"text-xs text-neutral-500 mb-2",children:h?n.jsxs(n.Fragment,{children:[a("直接填写 Codex")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"config.toml"})," ",a("格式的配置片段,通过")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"-c"})," ",a("参数注入。不会修改你的")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"~/.codex/config.toml"})," ",a("文件。")]}):n.jsxs(n.Fragment,{children:[a("对应 Claude Code 的")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"~/.claude/settings.json"}),",",a("通过")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"--settings"})," ",a("参数注入。在")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"env"})," ",a("中设置 ANTHROPIC_API_KEY、ANTHROPIC_BASE_URL 等。")]})}),n.jsx("textarea",{value:s.settings,onChange:u=>{r(g=>({...g,settings:u.target.value})),d("")},rows:10,className:"w-full px-3 py-2 text-sm font-mono border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900 bg-neutral-50",placeholder:z(s.agentType)}),o&&n.jsx("p",{className:"mt-1 text-xs text-red-600",children:o})]}),n.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[n.jsx(E,{variant:"outline",onClick:t,children:a("取消")}),n.jsx(E,{onClick:p,disabled:!s.name.trim(),children:a("保存")})]})]})})}function mt({isOpen:e,onClose:t,onConfirm:l,acknowledged:i,onAcknowledgedChange:a,isLoading:s}){const{t:r}=T();return n.jsx(q,{isOpen:e,onClose:t,title:r("导出 Provider 备份"),className:"max-w-xl",action:n.jsxs(n.Fragment,{children:[n.jsx(E,{variant:"outline",onClick:t,disabled:s,children:r("取消")}),n.jsx(E,{onClick:l,disabled:!i||s,children:r(s?"导出中...":"导出备份")})]}),children:n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900",children:r("导出的备份文件将包含完整的 Provider 配置,包括环境变量、CLI settings 等敏感信息。任何拿到文件的人都可能直接使用这些 Provider。")}),n.jsxs("div",{className:"text-sm text-neutral-600 space-y-2",children:[n.jsx("p",{children:r("这个功能用于备份和迁移,不用于分享配置。")}),n.jsx("p",{children:r("导出内容只包含用户层配置:自定义 Provider,以及对内置 Provider 的覆盖。")})]}),n.jsxs("label",{className:"flex items-start gap-3 rounded-lg border border-neutral-200 px-4 py-3 text-sm text-neutral-700",children:[n.jsx("input",{type:"checkbox",checked:i,onChange:o=>a(o.target.checked),className:"mt-0.5 h-4 w-4"}),n.jsx("span",{children:r("我已知晓该备份文件包含敏感信息,只会保存在安全位置。")})]})]})})}function xt({isOpen:e,onClose:t,preview:l,backup:i,onConfirm:a,isLoading:s}){const{t:r}=T();if(!l||!i)return null;const o=l.summary.create+l.summary.overwrite,d=[...l.items].sort((c,p)=>{const v={CREATE:0,OVERWRITE:1,SKIP:2};return v[c.action]-v[p.action]});return n.jsx(q,{isOpen:e,onClose:t,title:r("导入 Provider 备份"),className:"max-w-3xl",action:n.jsxs(n.Fragment,{children:[n.jsx(E,{variant:"outline",onClick:t,disabled:s,children:r("取消")}),n.jsx(E,{onClick:a,disabled:o===0||s,children:s?r("导入中..."):r("确认导入 {count} 项",{count:o})})]}),children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-600",children:[n.jsx("div",{children:r("导出时间:{value}",{value:new Date(i.exportedAt).toLocaleString()})}),n.jsx("div",{children:r("模式:完整备份(含敏感信息)")}),n.jsx("div",{children:r("文件内 Provider 数量:{count}",{count:i.providers.length})})]}),n.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[n.jsxs("div",{className:"rounded-lg border border-green-200 bg-green-50 px-4 py-3",children:[n.jsx("div",{className:"text-xs text-green-700",children:r("新增")}),n.jsx("div",{className:"text-lg font-semibold text-green-900",children:l.summary.create})]}),n.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3",children:[n.jsx("div",{className:"text-xs text-amber-700",children:r("覆盖")}),n.jsx("div",{className:"text-lg font-semibold text-amber-900",children:l.summary.overwrite})]}),n.jsxs("div",{className:"rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3",children:[n.jsx("div",{className:"text-xs text-neutral-500",children:r("跳过")}),n.jsx("div",{className:"text-lg font-semibold text-neutral-900",children:l.summary.skip})]})]}),n.jsx("div",{className:"max-h-[420px] overflow-y-auto space-y-3 pr-1",children:d.map(c=>{const p=ot(c.action);return n.jsxs("div",{className:"rounded-lg border border-neutral-200 px-4 py-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-3",children:n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("h4",{className:"truncate text-sm font-medium text-neutral-900",children:c.incoming.name}),n.jsx("span",{className:`inline-flex rounded px-2 py-0.5 text-xs ${p.className}`,children:r(p.label)})]}),n.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[Z[c.incoming.agentType]??c.incoming.agentType," · ",n.jsx("code",{className:"rounded bg-neutral-100 px-1 py-0.5",children:c.incoming.id})]})]})}),c.action==="OVERWRITE"&&c.existing&&n.jsx("p",{className:"mt-2 text-xs text-amber-700",children:r("将覆盖当前已有的 Provider:{name}",{name:c.existing.name})}),c.action==="SKIP"&&n.jsx("p",{className:"mt-2 text-xs text-neutral-500",children:r("当前同 ID Provider 配置一致,本次不会重复写入。")}),c.action==="CREATE"&&n.jsx("p",{className:"mt-2 text-xs text-green-700",children:r("当前不存在同 ID Provider,将直接新增。")})]},c.incoming.id)})})]})})}function Ct(){const{t:e}=T(),{data:t,isLoading:l}=je(),i=we(),a=Ne(),s=Ce(),r=Ee(),o=ke(),d=Pe(),c=w.useRef(null),[p,v]=w.useState(null),[h,u]=w.useState(null),[g,y]=w.useState(!1),[b,C]=w.useState(!1),[j,_]=w.useState(null),D=m=>{i.mutate(m,{onSuccess:()=>v(null)})},ce=(m,x)=>{a.mutate({id:m,data:x},{onSuccess:()=>v(null)})},de=m=>{if(!(m.deletable??!m.builtIn)){P.error(e("系统内置 Provider 不可删除"));return}u({id:m.id,name:m.name,builtIn:m.builtIn})},ue=()=>{h&&s.mutate(h.id,{onSuccess:()=>{P.success(h.builtIn?e("已恢复默认 Provider 配置"):e("Provider 已删除")),u(null)},onError:m=>{P.error(M(m,e("删除 Provider 失败")))}})},Y=()=>{y(!1),C(!1)},H=()=>{_(null)},me=()=>{r.mutate(void 0,{onSuccess:m=>{it(at(m.exportedAt),m),P.success(e("Provider 备份已导出")),Y()},onError:m=>{P.error(M(m,e("导出 Provider 备份失败")))}})},xe=()=>{c.current&&(c.current.value="",c.current.click())},fe=async m=>{const x=m.target.files?.[0];if(m.target.value="",!x)return;let O;try{O=JSON.parse(await x.text())}catch{P.error(e("备份文件不是有效的 JSON"));return}o.mutate(O,{onSuccess:I=>{_({backup:O,preview:I})},onError:I=>{P.error(M(I,e("导入预览失败")))}})},pe=()=>{j&&d.mutate(j.backup,{onSuccess:m=>{const x=m.summary.create+m.summary.overwrite;P.success(x===0?e("导入完成,当前配置无需变更"):e("导入完成:新增 {create},覆盖 {overwrite},跳过 {skip}",{create:m.summary.create,overwrite:m.summary.overwrite,skip:m.summary.skip})),H()},onError:m=>{P.error(M(m,e("导入 Provider 备份失败")))}})},he=m=>{const x=m.provider,O=x.env?Object.entries(x.env).map(([I,L])=>({key:I,value:L})):[];v({id:x.id,data:{name:x.name,agentType:x.agentType,config:K(x.agentType,x.config),settings:x.settings??"",env:O,isDefault:x.isDefault}})};if(l)return n.jsx("div",{className:"p-6 text-sm text-neutral-400",children:e("加载中...")});const W=t??[];return n.jsxs("div",{className:"px-10 py-6 mx-auto w-full max-w-4xl",children:[n.jsx("input",{ref:c,type:"file",accept:".json,application/json",className:"hidden",onChange:fe}),n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold text-neutral-900",children:e("Provider 配置")}),n.jsx("p",{className:"text-sm text-neutral-500 mt-1",children:e("管理 AI Agent 的连接配置和运行参数")})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(E,{variant:"outline",onClick:xe,disabled:o.isPending||d.isPending,children:[n.jsx(Re,{size:14}),e("导入备份")]}),n.jsxs(E,{variant:"outline",onClick:()=>y(!0),disabled:r.isPending,children:[n.jsx(De,{size:14}),e("导出备份")]}),n.jsxs(E,{onClick:()=>v({}),children:[n.jsx(re,{size:14,className:"mr-1"}),e("新建 Provider")]})]})]}),W.length===0?n.jsx("div",{className:"text-center py-12 text-sm text-neutral-400",children:e("暂无 Provider 配置")}):n.jsx("div",{className:"space-y-3",children:W.map(m=>{const x=m.provider,O=m.availability,I=K(x.agentType,x.config),L=Object.entries(I).filter(([A])=>A!=="cmd");return n.jsx("div",{className:"border border-neutral-200 rounded-lg p-4 hover:border-neutral-300 transition-colors",children:n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{className:"flex-1",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx("h3",{className:"text-sm font-medium text-neutral-900",children:x.name}),n.jsx(ct,{type:O.type}),x.isDefault&&n.jsx("span",{className:"px-2 py-0.5 text-xs text-blue-700 bg-blue-50 rounded",children:e("默认")}),x.builtIn&&n.jsx("span",{className:"px-2 py-0.5 text-xs text-neutral-500 bg-neutral-50 rounded",children:e("内置")})]}),n.jsx("p",{className:"text-xs text-neutral-500 mb-2",children:Z[x.agentType]??x.agentType}),L.length>0&&n.jsx("div",{className:"text-xs text-neutral-600 mb-1",children:L.map(([A,ge])=>n.jsxs("span",{className:"inline-flex items-center mr-3",children:[n.jsxs("span",{className:"font-medium",children:[e(rt[A]??A),":"]})," ",lt(A,ge)]},A))}),x.settings?.trim()&&n.jsxs("div",{className:"text-xs text-neutral-600",children:[n.jsx("span",{className:"font-medium",children:e("CLI 配置:")})," ",e("已配置")]}),Object.keys(x.env).length>0&&!x.settings&&n.jsxs("div",{className:"text-xs text-neutral-600",children:[n.jsx("span",{className:"font-medium",children:e("环境变量:")})," ",Object.keys(x.env).join(", ")]})]}),n.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[n.jsx("button",{onClick:()=>he(m),className:"p-2 text-neutral-400 hover:text-neutral-900 transition-colors",title:e("编辑"),children:n.jsx(Oe,{size:14})}),n.jsx("button",{onClick:()=>de(x),className:"p-2 text-neutral-400 hover:text-red-600 transition-colors",title:x.deletable===!1?e("系统内置 Provider 不可删除"):x.builtIn?e("删除自定义覆盖并恢复默认"):e("删除"),disabled:x.deletable===!1,children:n.jsx(se,{size:14})})]})]})},x.id)})}),p&&n.jsx(ut,{isOpen:!0,onClose:()=>v(null),initialData:p.data,onSave:m=>{p.id?ce(p.id,m):D(m)}}),n.jsx(_e,{isOpen:h!==null,onClose:()=>{s.isPending||u(null)},onConfirm:ue,title:h?.builtIn?e("恢复默认 Provider"):e("删除 Provider"),description:h?.builtIn?e('确定删除 "{name}" 的自定义覆盖,并恢复系统默认配置?',{name:h?.name}):e('确定删除 "{name}"?此操作不可撤销。',{name:h?.name}),confirmText:h?.builtIn?e("恢复默认"):e("删除"),cancelText:e("取消"),variant:"danger",isLoading:s.isPending}),n.jsx(mt,{isOpen:g,onClose:Y,onConfirm:me,acknowledged:b,onAcknowledgedChange:C,isLoading:r.isPending}),n.jsx(xt,{isOpen:!!j,onClose:H,preview:j?.preview??null,backup:j?.backup??null,onConfirm:pe,isLoading:d.isPending})]})}export{Ct as ProviderSettingsPage};
|
|
54
|
+
`;function z(e){return e===N.CLAUDE_CODE?et:e===N.CODEX?tt:""}function nt(e){return e===N.CLAUDE_CODE||e===N.CODEX}const rt=Object.values(J).flat().reduce((e,t)=>(e[t.key]||(e[t.key]=t.label),e),{}),st=Object.values(J).flat().reduce((e,t)=>(t.options&&(e[t.key]=Object.fromEntries(t.options.map(l=>[l.value,l.label]))),e),{});function lt(e,t){return typeof t=="boolean"?t?Q("是"):Q("否"):typeof t=="string"&&t?st[e]?.[t]??t:String(t)}function M(e,t){return e instanceof Error?e.message:t}function at(e){return`agent-tower-provider-backup-${e.replace(/[:.]/g,"-")}.json`}function it(e,t){const l=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),i=URL.createObjectURL(l),a=document.createElement("a");a.href=i,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function ot(e){switch(e){case"CREATE":return{label:"新增",className:"text-green-700 bg-green-50"};case"OVERWRITE":return{label:"覆盖",className:"text-amber-700 bg-amber-50"};case"SKIP":return{label:"跳过",className:"text-neutral-600 bg-neutral-100"}}}function ct({type:e}){const{t}=T();return e==="LOGIN_DETECTED"||e==="INSTALLATION_FOUND"?n.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs text-green-700 bg-green-50 rounded",children:[n.jsx(Ie,{size:12}),t("可用")]}):n.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-xs text-neutral-500 bg-neutral-50 rounded",children:[n.jsx(Ae,{size:12}),t("不可用")]})}function B({title:e,defaultOpen:t=!1,children:l}){const[i,a]=w.useState(t);return n.jsxs("div",{className:"border border-neutral-200 rounded-lg",children:[n.jsxs("button",{type:"button",onClick:()=>a(s=>!s),className:"w-full flex items-center justify-between px-4 py-2.5 text-sm font-medium text-neutral-700 hover:bg-neutral-50 transition-colors rounded-lg",children:[e,n.jsx(ae,{size:14,className:`transition-transform ${i?"rotate-180":""}`})]}),i&&n.jsx("div",{className:"px-4 pb-4 space-y-3",children:l})]})}function dt({agentType:e,config:t,onChange:l}){const{t:i}=T(),a=J[e]??[];if(a.length===0)return n.jsx("p",{className:"text-xs text-neutral-400",children:i("该类型暂无运行配置")});const s=(r,o)=>{l({...t,[r]:o})};return n.jsx("div",{className:"space-y-3",children:a.map(r=>r.type==="textarea"?n.jsxs("div",{children:[n.jsx("label",{className:"block text-sm text-neutral-700 mb-1",children:i(r.label)}),n.jsx("textarea",{value:t[r.key]??"",onChange:o=>s(r.key,o.target.value||void 0),placeholder:r.placeholder?i(r.placeholder):void 0,rows:r.rows??3,className:"w-full px-3 py-1.5 text-sm border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900"})]},r.key):r.type==="cursor_model"?n.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start",children:[n.jsx("label",{className:"text-sm text-neutral-700 w-32 shrink-0 sm:pt-2",children:i(r.label)}),n.jsx(Qe,{value:t[r.key]??"",onChange:o=>s(r.key,o)})]},r.key):n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("label",{className:"text-sm text-neutral-700 w-32 shrink-0",children:i(r.label)}),r.type==="switch"&&n.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[n.jsx("input",{type:"checkbox",checked:!!t[r.key],onChange:o=>s(r.key,o.target.checked),className:"sr-only peer"}),n.jsx("div",{className:"w-9 h-5 bg-neutral-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-neutral-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-neutral-900"})]}),r.type==="input"&&n.jsx("input",{type:"text",value:t[r.key]??"",onChange:o=>s(r.key,o.target.value||void 0),placeholder:r.placeholder?i(r.placeholder):void 0,className:"flex-1 px-3 py-1.5 text-sm border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900"}),r.type==="select"&&r.options&&n.jsx(le,{value:t[r.key]??"",onChange:o=>s(r.key,o||void 0),options:r.options,placeholder:i("选择...")})]},r.key))})}function ut({isOpen:e,onClose:t,initialData:l,onSave:i}){const{t:a}=T(),[s,r]=w.useState(l??{name:"",agentType:N.CLAUDE_CODE,config:ne(),settings:"",env:[],isDefault:!1}),[o,d]=w.useState("");w.useEffect(()=>{if(!l&&!s.settings){const u=z(s.agentType);u&&r(g=>({...g,settings:u}))}},[]);const c=u=>{r(g=>({...g,agentType:u,config:ne(),settings:z(u)}))},p=()=>{d("");const u=K(s.agentType,s.config),g={};for(const[j,_]of Object.entries(u))_!==void 0&&_!==""&&(g[j]=_);const y=s.settings.trim();if(y){if(s.agentType===N.CODEX)try{He(y)}catch(j){d(a("TOML 语法错误: {message}",{message:j instanceof Error?j.message:String(j)}));return}else if(s.agentType===N.CLAUDE_CODE)try{JSON.parse(y)}catch{d(a("JSON 语法错误"));return}}const b={};for(const{key:j,value:_}of s.env){const D=j.trim();D&&(b[D]=_)}const C={name:s.name,agentType:s.agentType,config:g,settings:y||void 0,env:Object.keys(b).length>0?b:void 0,isDefault:s.isDefault};i(C)};if(!e)return null;const v=nt(s.agentType),h=s.agentType===N.CODEX;return n.jsx(q,{isOpen:e,onClose:t,title:a(l?"编辑 Provider":"新建 Provider"),className:"max-w-2xl",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-medium text-neutral-700 mb-1",children:a("名称")}),n.jsx("input",{type:"text",value:s.name,onChange:u=>r(g=>({...g,name:u.target.value})),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900",placeholder:a("例如: Claude Code (官方)")})]}),!l&&n.jsxs("div",{children:[n.jsx("label",{className:"block text-xs font-medium text-neutral-700 mb-1",children:a("Agent 类型")}),n.jsx(le,{value:s.agentType,onChange:u=>c(u),options:Object.values(N).map(u=>({value:u,label:Z[u]??u})),placeholder:a("选择 Agent 类型")})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("input",{type:"checkbox",id:"isDefault",checked:s.isDefault,onChange:u=>r(g=>({...g,isDefault:u.target.checked})),className:"w-4 h-4"}),n.jsx("label",{htmlFor:"isDefault",className:"text-sm text-neutral-700",children:a("设为该类型的默认 Provider")})]}),n.jsx(B,{title:a("运行配置"),defaultOpen:!0,children:n.jsx(dt,{agentType:s.agentType,config:s.config,onChange:u=>r(g=>({...g,config:u}))})}),n.jsxs(B,{title:a("环境变量"),defaultOpen:s.env.length>0,children:[n.jsxs("p",{className:"text-xs text-neutral-500 mb-2",children:[a("注入到 Agent 进程的环境变量。Codex 的")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"env_key"})," ",a("指定的是变量名,实际值需在此处设置。")]}),n.jsxs("div",{className:"space-y-2",children:[s.env.map((u,g)=>n.jsxs("div",{className:"flex gap-2 items-center",children:[n.jsx("input",{type:"text",value:u.key,onChange:y=>{const b=[...s.env];b[g]={...b[g],key:y.target.value},r(C=>({...C,env:b}))},placeholder:a("变量名,如 AZURE_OPENAI_API_KEY"),className:"flex-1 px-3 py-1.5 text-sm font-mono border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900"}),n.jsx("input",{type:"text",value:u.value,onChange:y=>{const b=[...s.env];b[g]={...b[g],value:y.target.value},r(C=>({...C,env:b}))},placeholder:a("值"),className:"flex-1 px-3 py-1.5 text-sm font-mono border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900"}),n.jsx("button",{type:"button",onClick:()=>{const y=s.env.filter((b,C)=>C!==g);r(b=>({...b,env:y}))},className:"p-1.5 text-neutral-400 hover:text-red-500",children:n.jsx(se,{size:14})})]},g)),n.jsxs(E,{variant:"outline",size:"sm",onClick:()=>r(u=>({...u,env:[...u.env,{key:"",value:""}]})),children:[n.jsx(re,{size:12,className:"mr-1"}),a("添加变量")]})]})]}),v&&n.jsxs(B,{title:a(h?"CLI 原生配置 (config.toml)":"CLI 原生配置 (settings.json)"),children:[n.jsx("p",{className:"text-xs text-neutral-500 mb-2",children:h?n.jsxs(n.Fragment,{children:[a("直接填写 Codex")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"config.toml"})," ",a("格式的配置片段,通过")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"-c"})," ",a("参数注入。不会修改你的")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"~/.codex/config.toml"})," ",a("文件。")]}):n.jsxs(n.Fragment,{children:[a("对应 Claude Code 的")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"~/.claude/settings.json"}),",",a("通过")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"--settings"})," ",a("参数注入。在")," ",n.jsx("code",{className:"bg-neutral-100 px-1 rounded",children:"env"})," ",a("中设置 ANTHROPIC_API_KEY、ANTHROPIC_BASE_URL 等。")]})}),n.jsx("textarea",{value:s.settings,onChange:u=>{r(g=>({...g,settings:u.target.value})),d("")},rows:10,className:"w-full px-3 py-2 text-sm font-mono border border-neutral-200 rounded focus:outline-none focus:ring-1 focus:ring-neutral-900 bg-neutral-50",placeholder:z(s.agentType)}),o&&n.jsx("p",{className:"mt-1 text-xs text-red-600",children:o})]}),n.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[n.jsx(E,{variant:"outline",onClick:t,children:a("取消")}),n.jsx(E,{onClick:p,disabled:!s.name.trim(),children:a("保存")})]})]})})}function mt({isOpen:e,onClose:t,onConfirm:l,acknowledged:i,onAcknowledgedChange:a,isLoading:s}){const{t:r}=T();return n.jsx(q,{isOpen:e,onClose:t,title:r("导出 Provider 备份"),className:"max-w-xl",action:n.jsxs(n.Fragment,{children:[n.jsx(E,{variant:"outline",onClick:t,disabled:s,children:r("取消")}),n.jsx(E,{onClick:l,disabled:!i||s,children:r(s?"导出中...":"导出备份")})]}),children:n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900",children:r("导出的备份文件将包含完整的 Provider 配置,包括环境变量、CLI settings 等敏感信息。任何拿到文件的人都可能直接使用这些 Provider。")}),n.jsxs("div",{className:"text-sm text-neutral-600 space-y-2",children:[n.jsx("p",{children:r("这个功能用于备份和迁移,不用于分享配置。")}),n.jsx("p",{children:r("导出内容只包含用户层配置:自定义 Provider,以及对内置 Provider 的覆盖。")})]}),n.jsxs("label",{className:"flex items-start gap-3 rounded-lg border border-neutral-200 px-4 py-3 text-sm text-neutral-700",children:[n.jsx("input",{type:"checkbox",checked:i,onChange:o=>a(o.target.checked),className:"mt-0.5 h-4 w-4"}),n.jsx("span",{children:r("我已知晓该备份文件包含敏感信息,只会保存在安全位置。")})]})]})})}function xt({isOpen:e,onClose:t,preview:l,backup:i,onConfirm:a,isLoading:s}){const{t:r}=T();if(!l||!i)return null;const o=l.summary.create+l.summary.overwrite,d=[...l.items].sort((c,p)=>{const v={CREATE:0,OVERWRITE:1,SKIP:2};return v[c.action]-v[p.action]});return n.jsx(q,{isOpen:e,onClose:t,title:r("导入 Provider 备份"),className:"max-w-3xl",action:n.jsxs(n.Fragment,{children:[n.jsx(E,{variant:"outline",onClick:t,disabled:s,children:r("取消")}),n.jsx(E,{onClick:a,disabled:o===0||s,children:s?r("导入中..."):r("确认导入 {count} 项",{count:o})})]}),children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-600",children:[n.jsx("div",{children:r("导出时间:{value}",{value:new Date(i.exportedAt).toLocaleString()})}),n.jsx("div",{children:r("模式:完整备份(含敏感信息)")}),n.jsx("div",{children:r("文件内 Provider 数量:{count}",{count:i.providers.length})})]}),n.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[n.jsxs("div",{className:"rounded-lg border border-green-200 bg-green-50 px-4 py-3",children:[n.jsx("div",{className:"text-xs text-green-700",children:r("新增")}),n.jsx("div",{className:"text-lg font-semibold text-green-900",children:l.summary.create})]}),n.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 px-4 py-3",children:[n.jsx("div",{className:"text-xs text-amber-700",children:r("覆盖")}),n.jsx("div",{className:"text-lg font-semibold text-amber-900",children:l.summary.overwrite})]}),n.jsxs("div",{className:"rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3",children:[n.jsx("div",{className:"text-xs text-neutral-500",children:r("跳过")}),n.jsx("div",{className:"text-lg font-semibold text-neutral-900",children:l.summary.skip})]})]}),n.jsx("div",{className:"max-h-[420px] overflow-y-auto space-y-3 pr-1",children:d.map(c=>{const p=ot(c.action);return n.jsxs("div",{className:"rounded-lg border border-neutral-200 px-4 py-3",children:[n.jsx("div",{className:"flex items-center justify-between gap-3",children:n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("h4",{className:"truncate text-sm font-medium text-neutral-900",children:c.incoming.name}),n.jsx("span",{className:`inline-flex rounded px-2 py-0.5 text-xs ${p.className}`,children:r(p.label)})]}),n.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[Z[c.incoming.agentType]??c.incoming.agentType," · ",n.jsx("code",{className:"rounded bg-neutral-100 px-1 py-0.5",children:c.incoming.id})]})]})}),c.action==="OVERWRITE"&&c.existing&&n.jsx("p",{className:"mt-2 text-xs text-amber-700",children:r("将覆盖当前已有的 Provider:{name}",{name:c.existing.name})}),c.action==="SKIP"&&n.jsx("p",{className:"mt-2 text-xs text-neutral-500",children:r("当前同 ID Provider 配置一致,本次不会重复写入。")}),c.action==="CREATE"&&n.jsx("p",{className:"mt-2 text-xs text-green-700",children:r("当前不存在同 ID Provider,将直接新增。")})]},c.incoming.id)})})]})})}function Et(){const{t:e}=T(),{data:t,isLoading:l}=je(),i=we(),a=Ne(),s=Ce(),r=Ee(),o=ke(),d=Pe(),c=w.useRef(null),[p,v]=w.useState(null),[h,u]=w.useState(null),[g,y]=w.useState(!1),[b,C]=w.useState(!1),[j,_]=w.useState(null),D=m=>{i.mutate(m,{onSuccess:()=>v(null)})},ce=(m,x)=>{a.mutate({id:m,data:x},{onSuccess:()=>v(null)})},de=m=>{if(!(m.deletable??!m.builtIn)){P.error(e("系统内置 Provider 不可删除"));return}u({id:m.id,name:m.name,builtIn:m.builtIn})},ue=()=>{h&&s.mutate(h.id,{onSuccess:()=>{P.success(h.builtIn?e("已恢复默认 Provider 配置"):e("Provider 已删除")),u(null)},onError:m=>{P.error(M(m,e("删除 Provider 失败")))}})},Y=()=>{y(!1),C(!1)},H=()=>{_(null)},me=()=>{r.mutate(void 0,{onSuccess:m=>{it(at(m.exportedAt),m),P.success(e("Provider 备份已导出")),Y()},onError:m=>{P.error(M(m,e("导出 Provider 备份失败")))}})},xe=()=>{c.current&&(c.current.value="",c.current.click())},fe=async m=>{const x=m.target.files?.[0];if(m.target.value="",!x)return;let O;try{O=JSON.parse(await x.text())}catch{P.error(e("备份文件不是有效的 JSON"));return}o.mutate(O,{onSuccess:I=>{_({backup:O,preview:I})},onError:I=>{P.error(M(I,e("导入预览失败")))}})},pe=()=>{j&&d.mutate(j.backup,{onSuccess:m=>{const x=m.summary.create+m.summary.overwrite;P.success(x===0?e("导入完成,当前配置无需变更"):e("导入完成:新增 {create},覆盖 {overwrite},跳过 {skip}",{create:m.summary.create,overwrite:m.summary.overwrite,skip:m.summary.skip})),H()},onError:m=>{P.error(M(m,e("导入 Provider 备份失败")))}})},he=m=>{const x=m.provider,O=x.env?Object.entries(x.env).map(([I,L])=>({key:I,value:L})):[];v({id:x.id,data:{name:x.name,agentType:x.agentType,config:K(x.agentType,x.config),settings:x.settings??"",env:O,isDefault:x.isDefault}})};if(l)return n.jsx("div",{className:"p-6 text-sm text-neutral-400",children:e("加载中...")});const W=t??[];return n.jsxs("div",{className:"px-10 py-6 mx-auto w-full max-w-4xl",children:[n.jsx("input",{ref:c,type:"file",accept:".json,application/json",className:"hidden",onChange:fe}),n.jsxs("div",{className:"flex items-center justify-between mb-6",children:[n.jsxs("div",{children:[n.jsx("h2",{className:"text-lg font-semibold text-neutral-900",children:e("Provider 配置")}),n.jsx("p",{className:"text-sm text-neutral-500 mt-1",children:e("管理 AI Agent 的连接配置和运行参数")})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(E,{variant:"outline",onClick:xe,disabled:o.isPending||d.isPending,children:[n.jsx(Re,{size:14}),e("导入备份")]}),n.jsxs(E,{variant:"outline",onClick:()=>y(!0),disabled:r.isPending,children:[n.jsx(De,{size:14}),e("导出备份")]}),n.jsxs(E,{onClick:()=>v({}),children:[n.jsx(re,{size:14,className:"mr-1"}),e("新建 Provider")]})]})]}),W.length===0?n.jsx("div",{className:"text-center py-12 text-sm text-neutral-400",children:e("暂无 Provider 配置")}):n.jsx("div",{className:"space-y-3",children:W.map(m=>{const x=m.provider,O=m.availability,I=K(x.agentType,x.config),L=Object.entries(I).filter(([A])=>A!=="cmd");return n.jsx("div",{className:"border border-neutral-200 rounded-lg p-4 hover:border-neutral-300 transition-colors",children:n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{className:"flex-1",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx("h3",{className:"text-sm font-medium text-neutral-900",children:x.name}),n.jsx(ct,{type:O.type}),x.isDefault&&n.jsx("span",{className:"px-2 py-0.5 text-xs text-blue-700 bg-blue-50 rounded",children:e("默认")}),x.builtIn&&n.jsx("span",{className:"px-2 py-0.5 text-xs text-neutral-500 bg-neutral-50 rounded",children:e("内置")})]}),n.jsx("p",{className:"text-xs text-neutral-500 mb-2",children:Z[x.agentType]??x.agentType}),L.length>0&&n.jsx("div",{className:"text-xs text-neutral-600 mb-1",children:L.map(([A,ge])=>n.jsxs("span",{className:"inline-flex items-center mr-3",children:[n.jsxs("span",{className:"font-medium",children:[e(rt[A]??A),":"]})," ",lt(A,ge)]},A))}),x.settings?.trim()&&n.jsxs("div",{className:"text-xs text-neutral-600",children:[n.jsx("span",{className:"font-medium",children:e("CLI 配置:")})," ",e("已配置")]}),Object.keys(x.env).length>0&&!x.settings&&n.jsxs("div",{className:"text-xs text-neutral-600",children:[n.jsx("span",{className:"font-medium",children:e("环境变量:")})," ",Object.keys(x.env).join(", ")]})]}),n.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[n.jsx("button",{onClick:()=>he(m),className:"p-2 text-neutral-400 hover:text-neutral-900 transition-colors",title:e("编辑"),children:n.jsx(Oe,{size:14})}),n.jsx("button",{onClick:()=>de(x),className:"p-2 text-neutral-400 hover:text-red-600 transition-colors",title:x.deletable===!1?e("系统内置 Provider 不可删除"):x.builtIn?e("删除自定义覆盖并恢复默认"):e("删除"),disabled:x.deletable===!1,children:n.jsx(se,{size:14})})]})]})},x.id)})}),p&&n.jsx(ut,{isOpen:!0,onClose:()=>v(null),initialData:p.data,onSave:m=>{p.id?ce(p.id,m):D(m)}}),n.jsx(_e,{isOpen:h!==null,onClose:()=>{s.isPending||u(null)},onConfirm:ue,title:h?.builtIn?e("恢复默认 Provider"):e("删除 Provider"),description:h?.builtIn?e('确定删除 "{name}" 的自定义覆盖,并恢复系统默认配置?',{name:h?.name}):e('确定删除 "{name}"?此操作不可撤销。',{name:h?.name}),confirmText:h?.builtIn?e("恢复默认"):e("删除"),cancelText:e("取消"),variant:"danger",isLoading:s.isPending}),n.jsx(mt,{isOpen:g,onClose:Y,onConfirm:me,acknowledged:b,onAcknowledgedChange:C,isLoading:r.isPending}),n.jsx(xt,{isOpen:!!j,onClose:H,preview:j?.preview??null,backup:j?.backup??null,onConfirm:pe,isLoading:d.isPending})]})}export{Et as ProviderSettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,j as p}from"./index-
|
|
1
|
+
import{r as a,j as p}from"./index-D7K8KUJH.js";import{a as V,c as k}from"./utils-CkSf8FUe.js";const y=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,b=V,E=(t,n)=>e=>{var i;if(n?.variants==null)return b(t,e?.class,e?.className);const{variants:r,defaultVariants:s}=n,u=Object.keys(r).map(o=>{const c=e?.[o],d=s?.[o];if(c===null)return null;const v=y(c)||y(d);return r[o][v]}),l=e&&Object.entries(e).reduce((o,c)=>{let[d,v]=c;return v===void 0||(o[d]=v),o},{}),f=n==null||(i=n.compoundVariants)===null||i===void 0?void 0:i.reduce((o,c)=>{let{class:d,className:v,...x}=c;return Object.entries(x).every(C=>{let[m,g]=C;return Array.isArray(g)?g.includes({...s,...l}[m]):{...s,...l}[m]===g})?[...o,d,v]:o},[]);return b(t,u,f,e?.class,e?.className)};function h(t,n){if(typeof t=="function")return t(n);t!=null&&(t.current=n)}function S(...t){return n=>{let e=!1;const i=t.map(r=>{const s=h(r,n);return!e&&typeof s=="function"&&(e=!0),s});if(e)return()=>{for(let r=0;r<i.length;r++){const s=i[r];typeof s=="function"?s():h(t[r],null)}}}}function j(t){const n=_(t),e=a.forwardRef((i,r)=>{const{children:s,...u}=i,l=a.Children.toArray(s),f=l.find(R);if(f){const o=f.props.children,c=l.map(d=>d===f?a.Children.count(o)>1?a.Children.only(null):a.isValidElement(o)?o.props.children:null:d);return p.jsx(n,{...u,ref:r,children:a.isValidElement(o)?a.cloneElement(o,void 0,c):null})}return p.jsx(n,{...u,ref:r,children:s})});return e.displayName=`${t}.Slot`,e}var z=j("Slot");function _(t){const n=a.forwardRef((e,i)=>{const{children:r,...s}=e;if(a.isValidElement(r)){const u=w(r),l=O(s,r.props);return r.type!==a.Fragment&&(l.ref=i?S(i,u):u),a.cloneElement(r,l)}return a.Children.count(r)>1?a.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}var N=Symbol("radix.slottable");function R(t){return a.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===N}function O(t,n){const e={...n};for(const i in n){const r=t[i],s=n[i];/^on[A-Z]/.test(i)?r&&s?e[i]=(...l)=>{const f=s(...l);return r(...l),f}:r&&(e[i]=r):i==="style"?e[i]={...r,...s}:i==="className"&&(e[i]=[r,s].filter(Boolean).join(" "))}return{...t,...e}}function w(t){let n=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,e=n&&"isReactWarning"in n&&n.isReactWarning;return e?t.ref:(n=Object.getOwnPropertyDescriptor(t,"ref")?.get,e=n&&"isReactWarning"in n&&n.isReactWarning,e?t.props.ref:t.props.ref||t.ref)}const P=E("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function I({className:t,variant:n="default",size:e="default",asChild:i=!1,...r}){const s=i?z:"button";return p.jsx(s,{"data-slot":"button","data-variant":n,"data-size":e,className:k(P({variant:n,size:e,className:t})),...r})}export{I as B};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h as o}from"./index-D7K8KUJH.js";const c=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],t=o("check",c);const e=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],s=o("chevron-down",e);export{s as C,t as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as o}from"./index-D7K8KUJH.js";const t=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],h=o("chevron-right",t);export{h as C};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as e}from"./index-D7K8KUJH.js";const c=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],y=e("circle-alert",c);export{y as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h as c}from"./index-D7K8KUJH.js";const e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],r=c("circle-check",e);export{r as C};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{L as h,Z as x,I as p,g as u}from"./mermaid-NOHMQCX5-
|
|
1
|
+
import{L as h,Z as x,I as p,g as u}from"./mermaid-NOHMQCX5-CvKYIlPK.js";import{r as i,j as a}from"./index-D7K8KUJH.js";import"./log-adapter-50wgehrc.js";import"./chevron-right-BtN8Zto2.js";import"./chevron-down-9WClAEn8.js";import"./utils-CkSf8FUe.js";var v=u("block","before:content-[counter(line)]","before:inline-block","before:[counter-increment:line]","before:w-6","before:mr-4","before:text-[13px]","before:text-right","before:text-muted-foreground/50","before:font-mono","before:select-none"),k=r=>{let e={};for(let l of r.split(";")){let o=l.indexOf(":");if(o>0){let c=l.slice(0,o).trim(),n=l.slice(o+1).trim();c&&n&&(e[c]=n)}}return e},j=i.memo(({children:r,result:e,language:l,className:o,...c})=>{let n=i.useMemo(()=>{let s={};return e.bg&&(s["--sdm-bg"]=e.bg),e.fg&&(s["--sdm-fg"]=e.fg),e.rootStyle&&Object.assign(s,k(e.rootStyle)),s},[e.bg,e.fg,e.rootStyle]);return a.jsx("pre",{className:u(o,"p-4 text-sm","bg-[var(--sdm-bg,transparent)]","dark:bg-[var(--shiki-dark-bg,var(--sdm-bg,transparent))]"),"data-language":l,"data-streamdown":"code-block-body",style:n,...c,children:a.jsx("code",{className:"[counter-increment:line_0] [counter-reset:line]",children:e.tokens.map((s,d)=>a.jsx("span",{className:v,children:s.map((t,b)=>a.jsx("span",{className:u("text-[var(--sdm-c,inherit)]","dark:text-[var(--shiki-dark,var(--sdm-c,inherit))]",t.bgColor&&"bg-[var(--sdm-tbg)]",t.bgColor&&"dark:bg-[var(--shiki-dark-bg,var(--sdm-tbg))]"),style:{...t.color?{"--sdm-c":t.color}:{},...t.bgColor?{"--sdm-tbg":t.bgColor}:{},...t.htmlStyle},...t.htmlAttrs,children:t.content},b))},d))})})},(r,e)=>r.result===e.result&&r.language===e.language&&r.className===e.className),y=({className:r,language:e,style:l,...o})=>a.jsx("div",{className:u("my-4 w-full overflow-hidden rounded-xl border border-border",r),"data-language":e,"data-streamdown":"code-block",style:{contentVisibility:"auto",containIntrinsicSize:"auto 200px",...l},...o}),N=({language:r,children:e})=>a.jsxs("div",{className:"flex items-center justify-between bg-muted/80 p-3 text-muted-foreground text-xs","data-language":r,"data-streamdown":"code-block-header",children:[a.jsx("span",{className:"ml-1 font-mono lowercase",children:r}),a.jsx("div",{className:"flex items-center gap-2",children:e})]}),w=/\n+$/,O=({code:r,language:e,className:l,children:o,...c})=>{let{shikiTheme:n}=i.useContext(h),s=x(),d=i.useMemo(()=>r.replace(w,""),[r]),t=i.useMemo(()=>({bg:"transparent",fg:"inherit",tokens:d.split(`
|
|
2
2
|
`).map(g=>[{content:g,color:"inherit",bgColor:"transparent",htmlStyle:{},offset:0}])}),[d]),[b,m]=i.useState(t);return i.useEffect(()=>{if(!s){m(t);return}let g=s.highlight({code:d,language:e,themes:n},f=>{m(f)});if(g){m(g);return}m(t)},[d,e,n,s,t]),a.jsx(p.Provider,{value:{code:r},children:a.jsxs(y,{language:e,children:[a.jsx(N,{language:e,children:o}),a.jsx(j,{className:l,language:e,result:b,...c})]})})};export{O as CodeBlock};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as A,u as h,j as t}from"./index-D7K8KUJH.js";import{M as O}from"./modal-CUBMvXmY.js";import{c as u}from"./utils-CkSf8FUe.js";const R=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],f=A("triangle-alert",R);var i;(function(e){e.TODO="TODO",e.IN_PROGRESS="IN_PROGRESS",e.IN_REVIEW="IN_REVIEW",e.DONE="DONE",e.CANCELLED="CANCELLED"})(i||(i={}));var l;(function(e){e.ACTIVE="ACTIVE",e.MERGED="MERGED",e.ABANDONED="ABANDONED"})(l||(l={}));var s;(function(e){e.CLAUDE_CODE="CLAUDE_CODE",e.GEMINI_CLI="GEMINI_CLI",e.CURSOR_AGENT="CURSOR_AGENT",e.CODEX="CODEX"})(s||(s={}));var c;(function(e){e.PENDING="PENDING",e.RUNNING="RUNNING",e.COMPLETED="COMPLETED",e.FAILED="FAILED",e.CANCELLED="CANCELLED"})(c||(c={}));var o;(function(e){e.CHAT="CHAT",e.COMMIT_MSG="COMMIT_MSG"})(o||(o={}));var d;(function(e){e.REBASE="REBASE",e.MERGE="MERGE"})(d||(d={}));const L=({isOpen:e,onClose:E,onConfirm:N,title:C,description:m,confirmText:D="确认",cancelText:x="取消",variant:I="default",isLoading:a=!1})=>{const{t:r}=h(),n=I==="danger";return t.jsx(O,{isOpen:e,onClose:E,title:C,className:"max-w-sm",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:E,disabled:a,className:"px-4 py-2 text-sm font-medium text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r(x)}),t.jsx("button",{onClick:N,disabled:a,className:u("px-4 py-2 text-sm font-medium rounded-lg transition-colors disabled:opacity-50",n?"bg-red-500 text-white hover:bg-red-600":"bg-neutral-900 text-white hover:bg-black"),children:r(a?"处理中...":D)})]}),children:t.jsxs("div",{className:"flex gap-4",children:[n&&t.jsx("div",{className:"shrink-0 w-10 h-10 rounded-full bg-red-50 flex items-center justify-center",children:t.jsx(f,{size:20,className:"text-red-500"})}),t.jsx("div",{className:"text-sm text-neutral-600 leading-relaxed pt-1",children:m})]})})};export{s as A,L as C,c as S,f as T,d as a,i as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as A,r as a,
|
|
1
|
+
import{u as A,r as a,g as k,j as e,F as C}from"./index-D7K8KUJH.js";import{c}from"./utils-CkSf8FUe.js";import{C as w}from"./chevron-right-BtN8Zto2.js";import{L as E}from"./loader-circle-lo-fmqx0.js";import{C as z}from"./circle-alert-HHdlJNqe.js";import{F as S}from"./rotate-ccw-CzrmYvZT.js";function Q({value:l,onChange:m,placeholder:G}){const{t:D}=A(),[x,R]=a.useState(""),[p,V]=a.useState([]),[h,F]=a.useState(""),[L,f]=a.useState(!1),[j,g]=a.useState(null),[d,N]=a.useState(l),[b,n]=a.useState(null),[P,v]=a.useState(!1),y=a.useRef(!1);a.useEffect(()=>{N(l)},[l]);const r=a.useCallback(async t=>{f(!0),g(null);try{const s={};t&&(s.path=t);const u=await k.get("/filesystem/browse",{params:s});R(u.current),F(u.parent),V(u.dirs)}catch(s){g(s instanceof Error?s.message:"Failed to browse directory")}finally{f(!1)}},[]);a.useEffect(()=>{y.current||(y.current=!0,r())},[r]);const i=a.useCallback(async t=>{v(!0),n(null);try{const s=await k.get("/filesystem/validate",{params:{path:t}});s.valid?(m(t),n(null)):n(s.error??"Not a Git repository")}catch(s){n(s instanceof Error?s.message:"Validation failed")}finally{v(!1)}},[m]),I=a.useCallback(t=>{t.isGitRepo?(i(t.path),r(t.path)):(r(t.path),n(null))},[i,r]),o=x?x.split("/").filter(Boolean):[],B=a.useCallback(t=>{const s="/"+o.slice(0,t+1).join("/");r(s),n(null)},[o,r]),K=a.useCallback(t=>{if(t.key==="Enter"&&!t.nativeEvent.isComposing&&t.nativeEvent.keyCode!==229){t.preventDefault();const s=d.trim();s&&(r(s),i(s))}},[d,r,i]);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",value:d,onChange:t=>N(t.target.value),onKeyDown:K,placeholder:G??"e.g., /Users/me/projects/my-repo",className:c("w-full px-3 py-2 border rounded-lg text-sm font-mono focus:outline-none transition-colors pr-8",l?"border-emerald-300 bg-emerald-50/50 focus:border-emerald-400":"border-neutral-200 focus:border-neutral-400")}),l&&e.jsx(C,{size:14,className:"absolute right-3 top-1/2 -translate-y-1/2 text-emerald-500"})]}),e.jsx("p",{className:"text-xs text-neutral-400",children:D("Browse and select a Git repository, or type a path and press Enter")}),e.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-neutral-500 overflow-x-auto pb-1 scrollbar-none",children:[e.jsx("button",{onClick:()=>r("/"),className:"hover:text-neutral-900 transition-colors flex-shrink-0 px-1 py-0.5 rounded hover:bg-neutral-100",children:"/"}),o.map((t,s)=>e.jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[e.jsx(w,{size:10,className:"text-neutral-300"}),e.jsx("button",{onClick:()=>B(s),className:c("px-1 py-0.5 rounded transition-colors truncate max-w-[120px]",s===o.length-1?"font-medium text-neutral-900":"hover:text-neutral-900 hover:bg-neutral-100"),children:t})]},s))]}),e.jsx("div",{className:"border border-neutral-200 rounded-lg overflow-hidden",children:e.jsx("div",{className:"max-h-[200px] overflow-y-auto",children:L?e.jsxs("div",{className:"flex items-center justify-center py-8 text-neutral-400",children:[e.jsx(E,{size:16,className:"animate-spin mr-2"}),e.jsx("span",{className:"text-xs",children:"Loading..."})]}):j?e.jsxs("div",{className:"flex items-center justify-center py-8 text-red-500 gap-2",children:[e.jsx(z,{size:14}),e.jsx("span",{className:"text-xs",children:j})]}):p.length===0?e.jsx("div",{className:"flex items-center justify-center py-8 text-neutral-400",children:e.jsx("span",{className:"text-xs",children:"No subdirectories"})}):e.jsxs("ul",{className:"divide-y divide-neutral-100",children:[x!==h&&e.jsx("li",{children:e.jsxs("button",{onClick:()=>r(h),className:"w-full flex items-center gap-2.5 px-3 py-2 text-left hover:bg-neutral-50 transition-colors group",children:[e.jsx(S,{size:14,className:"text-neutral-400 flex-shrink-0"}),e.jsx("span",{className:"text-xs text-neutral-500 group-hover:text-neutral-700",children:".."})]})}),p.map(t=>e.jsx("li",{children:e.jsxs("button",{onClick:()=>I(t),className:c("w-full flex items-center gap-2.5 px-3 py-2 text-left transition-colors group",t.path===l?"bg-emerald-50":"hover:bg-neutral-50"),children:[t.isGitRepo?e.jsx(C,{size:14,className:"text-emerald-500 flex-shrink-0"}):e.jsx(S,{size:14,className:"text-neutral-400 flex-shrink-0"}),e.jsx("span",{className:c("text-xs truncate",t.path===l?"font-medium text-emerald-700":"text-neutral-700 group-hover:text-neutral-900"),children:t.name}),t.isGitRepo&&e.jsx("span",{className:"ml-auto flex-shrink-0 text-[10px] font-medium bg-emerald-100 text-emerald-600 px-1.5 py-0.5 rounded",children:"Git"}),!t.isGitRepo&&e.jsx(w,{size:12,className:"ml-auto text-neutral-300 group-hover:text-neutral-400 flex-shrink-0"})]})},t.path))]})})}),P&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-400",children:[e.jsx(E,{size:12,className:"animate-spin"}),e.jsx("span",{children:"Validating..."})]}),b&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-red-500",children:[e.jsx(z,{size:12}),e.jsx("span",{children:b})]})]})}export{Q as FolderPicker};
|