agent-tower 0.5.2-beta.1 → 0.5.2-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mcp/http-client.d.ts +8 -2
- package/dist/mcp/http-client.d.ts.map +1 -1
- package/dist/mcp/http-client.js +4 -4
- package/dist/mcp/http-client.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +48 -5
- package/dist/mcp/server.js.map +1 -1
- package/dist/routes/team-runs.d.ts.map +1 -1
- package/dist/routes/team-runs.js +92 -2
- package/dist/routes/team-runs.js.map +1 -1
- package/dist/services/__tests__/team-reconciler.service.test.js +171 -3
- package/dist/services/__tests__/team-reconciler.service.test.js.map +1 -1
- package/dist/services/__tests__/team-run.service.test.js +87 -0
- package/dist/services/__tests__/team-run.service.test.js.map +1 -1
- package/dist/services/__tests__/team-scheduler.service.test.js +131 -0
- package/dist/services/__tests__/team-scheduler.service.test.js.map +1 -1
- package/dist/services/session-manager.d.ts.map +1 -1
- package/dist/services/session-manager.js +11 -0
- package/dist/services/session-manager.js.map +1 -1
- package/dist/services/team-run.service.d.ts +16 -0
- package/dist/services/team-run.service.d.ts.map +1 -1
- package/dist/services/team-run.service.js +196 -4
- package/dist/services/team-run.service.js.map +1 -1
- package/dist/services/team-scheduler.service.d.ts +8 -4
- package/dist/services/team-scheduler.service.d.ts.map +1 -1
- package/dist/services/team-scheduler.service.js +26 -9
- package/dist/services/team-scheduler.service.js.map +1 -1
- package/dist/utils/process-launch.d.ts.map +1 -1
- package/dist/utils/process-launch.js +52 -9
- package/dist/utils/process-launch.js.map +1 -1
- package/dist/utils/process-launch.test.js +65 -1
- package/dist/utils/process-launch.test.js.map +1 -1
- package/dist/web/assets/{AgentDemoPage-CkhVcgZo.js → AgentDemoPage-Co63rtls.js} +1 -1
- package/dist/web/assets/{DemoPage-dkmp8Vvn.js → DemoPage-PD8AX5pI.js} +1 -1
- package/dist/web/assets/{GeneralSettingsPage-B4DH6g3D.js → GeneralSettingsPage-C5eiEeTZ.js} +1 -1
- package/dist/web/assets/{MemberAvatar-pwugXGL4.js → MemberAvatar-BDXmryjB.js} +1 -1
- package/dist/web/assets/{NotificationSettingsPage-C-bPU_ZE.js → NotificationSettingsPage-BjjPan2M.js} +1 -1
- package/dist/web/assets/{ProfileSettingsPage-Dlr6BmHb.js → ProfileSettingsPage-BRpeNq6u.js} +1 -1
- package/dist/web/assets/ProjectKanbanPage-DUUu2EYy.js +89 -0
- package/dist/web/assets/{ProjectSettingsPage-DZZksq5G.js → ProjectSettingsPage-avctMKfk.js} +1 -1
- package/dist/web/assets/{ProviderSettingsPage-BWN7CEG6.js → ProviderSettingsPage-BIUYN2e0.js} +1 -1
- package/dist/web/assets/{SettingsSection-C-sMhXpf.js → SettingsSection-pLJ3msrT.js} +1 -1
- package/dist/web/assets/{TeamSettingsPage-924xpocx.js → TeamSettingsPage-BjKW9nT8.js} +1 -1
- package/dist/web/assets/{arrow-left-UHjQiY5K.js → arrow-left-lFz8nyZM.js} +1 -1
- package/dist/web/assets/{button-CUTjpRqw.js → button-BUA8P726.js} +1 -1
- package/dist/web/assets/check-BYuuXc71.js +1 -0
- package/dist/web/assets/{chevron-down-Bby7sJEv.js → chevron-down-B931AgE2.js} +1 -1
- package/dist/web/assets/{chevron-right-DCC0lyoB.js → chevron-right-F9i4wey6.js} +1 -1
- package/dist/web/assets/{chevron-up-BnCoaejn.js → chevron-up-BEHjZ-SB.js} +1 -1
- package/dist/web/assets/{circle-check-BscClK07.js → circle-check-C7xXtl8B.js} +1 -1
- package/dist/web/assets/{code-block-OCS4YCEC-DkMlYSza.js → code-block-OCS4YCEC-6FHTyCN2.js} +1 -1
- package/dist/web/assets/{confirm-dialog-wsb35VpE.js → confirm-dialog-B_wk_zqm.js} +1 -1
- package/dist/web/assets/{folder-picker-B-X_nrS1.js → folder-picker-BEHS3b2Q.js} +1 -1
- package/dist/web/assets/index-DEQhT5sD.css +1 -0
- package/dist/web/assets/{index-CUJoWIuo.js → index-RxbHMWXV.js} +7 -7
- package/dist/web/assets/{loader-circle-Cul4BuAa.js → loader-circle-stJcjnm-.js} +1 -1
- package/dist/web/assets/{mermaid-NOHMQCX5-DoPzf-UA.js → mermaid-NOHMQCX5-fubZbKyF.js} +3 -3
- package/dist/web/assets/{message-square-C7Q71jFj.js → message-square-C8lb-TDo.js} +1 -1
- package/dist/web/assets/{modal-25-qs8P5.js → modal-UGrjU63G.js} +1 -1
- package/dist/web/assets/{pencil-CaJR6Dqm.js → pencil-uRBgB4qA.js} +1 -1
- package/dist/web/assets/{rotate-ccw-Bvz7590n.js → rotate-ccw-CWaMrTz4.js} +1 -1
- package/dist/web/assets/{select-CzeTYLO4.js → select-BMlH2AuL.js} +1 -1
- package/dist/web/assets/{upload-_2T21rVP.js → upload-B-Mpvu9j.js} +1 -1
- package/dist/web/assets/{use-profiles-BaCwGP06.js → use-profiles-D6cZwU1R.js} +1 -1
- package/dist/web/assets/{use-providers-Bwl7R5Ql.js → use-providers-DVP6emIi.js} +1 -1
- package/dist/web/index.html +2 -2
- package/node_modules/@agent-tower/shared/dist/socket/events.d.ts +1 -1
- package/node_modules/@agent-tower/shared/dist/socket/events.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/types.d.ts +4 -1
- package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
- package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
- package/node_modules/@prisma/client/.prisma/client/edge.js +6 -5
- package/node_modules/@prisma/client/.prisma/client/index-browser.js +1 -0
- package/node_modules/@prisma/client/.prisma/client/index.d.ts +43 -0
- package/node_modules/@prisma/client/.prisma/client/index.js +6 -5
- package/node_modules/@prisma/client/.prisma/client/package.json +1 -1
- package/node_modules/@prisma/client/.prisma/client/schema.prisma +2 -0
- package/node_modules/@prisma/client/.prisma/client/wasm.js +1 -0
- package/package.json +1 -1
- package/prisma/migrations/20260609000000_add_team_member_membership_status/migration.sql +3 -0
- package/prisma/schema.prisma +2 -0
- package/dist/web/assets/ProjectKanbanPage-7oEfjjWV.js +0 -89
- package/dist/web/assets/check-CPkZgPjx.js +0 -1
- package/dist/web/assets/index-4hNWw0yi.css +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{e as ae,u as W,r as a,i as le,j as e,X,d as R,t as B}from"./index-CUJoWIuo.js";import{F as Q,a as $,u as ie,b as oe,c as ce,d as de,e as ue}from"./folder-picker-B-X_nrS1.js";import{B as D}from"./button-CUTjpRqw.js";import{P as Z,a as xe,T as me,M as H}from"./modal-25-qs8P5.js";import{S as K}from"./SettingsSection-C-sMhXpf.js";import{R as he}from"./rotate-ccw-Bvz7590n.js";import{A as pe}from"./arrow-left-UHjQiY5K.js";import"./chevron-right-DCC0lyoB.js";import"./loader-circle-Cul4BuAa.js";import"./check-CPkZgPjx.js";const fe=[["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"}]],je=ae("folder-plus",fe);function ge({value:t,onChange:g,repoPath:b,placeholder:v}){const{t:o}=W(),[i,c]=a.useState(""),[x,p]=a.useState([]),[N,n]=a.useState(!1),[u,y]=a.useState(-1),m=a.useRef(null),j=a.useRef(null),P=a.useRef(void 0),z=a.useCallback(async s=>{if(!b||!s){p([]),n(!1);return}try{const l=await le.get("/filesystem/complete",{params:{basePath:b,prefix:s}});p(l.results),n(l.results.length>0),y(-1)}catch{p([]),n(!1)}},[b]);a.useEffect(()=>{if(clearTimeout(P.current),!i){p([]),n(!1);return}return P.current=setTimeout(()=>z(i),200),()=>clearTimeout(P.current)},[i,z]),a.useEffect(()=>{const s=l=>{j.current&&!j.current.contains(l.target)&&m.current&&!m.current.contains(l.target)&&n(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[]);const k=s=>{const l=s.trim();!l||t.includes(l)||(g([...t,l]),c(""),n(!1),m.current?.focus())},I=s=>{g(t.filter((l,w)=>w!==s))},A=s=>{s.type==="directory"?(c(s.path),m.current?.focus()):k(s.path)},C=(s,l)=>{l.stopPropagation(),k(s.path.replace(/\/$/,""))},F=s=>{s.nativeEvent.isComposing||s.nativeEvent.keyCode===229||(N&&x.length>0?s.key==="ArrowDown"?(s.preventDefault(),y(l=>Math.min(l+1,x.length-1))):s.key==="ArrowUp"?(s.preventDefault(),y(l=>Math.max(l-1,-1))):s.key==="Enter"?(s.preventDefault(),u>=0?A(x[u]):k(i)):s.key==="Escape"&&n(!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,l)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 group",children:[s.includes(".")&&!s.endsWith("/")?e.jsx(Q,{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:()=>I(l),className:"p-0.5 text-neutral-300 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:e.jsx(X,{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:F,onFocus:()=>{i&&x.length>0&&n(!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(Z,{size:14}),e.jsx("span",{children:o("添加")})]})]}),N&&e.jsx("div",{ref:j,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,l)=>e.jsxs("button",{onClick:()=>A(s),className:`w-full flex items-center gap-2 px-3 py-1.5 text-sm text-left hover:bg-neutral-50 transition-colors ${l===u?"bg-neutral-100":""}`,children:[s.type==="directory"?e.jsx($,{size:14,className:"text-amber-500 shrink-0"}):e.jsx(Q,{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(je,{size:14})})]},s.path))})]})]})}function be({value:t,onChange:g}){const{t:b}=W(),[v,o]=a.useState(""),[i,c]=a.useState(""),x=()=>{const n=v.trim(),u=i.trim();!n||!u||(g([...t,{name:n,command:u}]),o(""),c(""))},p=n=>{g(t.filter((u,y)=>y!==n))},N=n=>{n.key==="Enter"&&!n.nativeEvent.isComposing&&n.nativeEvent.keyCode!==229&&(n.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((n,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:n.name}),e.jsx("span",{className:"text-sm font-mono text-neutral-500 flex-1 truncate",children:n.command}),e.jsx("button",{onClick:()=>p(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(X,{size:14})})]},u))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:v,onChange:n=>o(n.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:n=>c(n.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(Z,{size:14}),e.jsx("span",{children:b("添加")})]})]})]})}function ve(t){return t?t.split(",").map(g=>g.trim()).filter(Boolean):[]}function Ne(t){if(!t)return[];try{return JSON.parse(t)}catch{return[]}}function V(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 Ee(){const{t}=W(),{data:g,isLoading:b}=ie({limit:100,includeArchived:!0}),v=oe(),o=ce(),i=de(),[c,x]=a.useState(""),[p,N]=a.useState(null),[n,u]=a.useState({copyFiles:[],setupScript:"",quickCommands:[]}),[y,m]=a.useState(!1),[j,P]=a.useState(null),[z,k]=a.useState(!1),[I,A]=a.useState(!1),[C,F]=a.useState(!1),[s,l]=a.useState(!1),[w,q]=a.useState(""),[G,U]=a.useState(!1),S=g?.data??[],f=a.useMemo(()=>S.filter(r=>!r.archivedAt),[S]),E=a.useMemo(()=>S.filter(r=>r.archivedAt),[S]),h=f.find(r=>r.id===c),M=a.useMemo(()=>S.find(r=>r.id===j)??null,[j,S]);if(a.useEffect(()=>{!c&&f.length>0&&x(f[0].id)},[f,c]),a.useEffect(()=>{if(p){f.some(r=>r.id===p)&&(x(p),N(null));return}c&&!f.some(r=>r.id===c)&&(x(f[0]?.id??""),m(!1))},[f,p,c]),a.useEffect(()=>{h&&!y&&u({copyFiles:ve(h.copyFiles),setupScript:h.setupScript??"",quickCommands:Ne(h.quickCommands)})},[h,y]),b)return e.jsx(K,{className:"max-w-5xl",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-neutral-200 border-t-neutral-600"})})});if(S.length===0)return e.jsxs(K,{className:"max-w-5xl",children:[e.jsx("h2",{className:"text-base font-semibold text-neutral-900 mb-5",children:t("项目配置")}),e.jsx("div",{className:"rounded-xl border border-dashed border-neutral-200 bg-neutral-50/50 py-16 text-center",children:e.jsx("p",{className:"text-sm text-neutral-400",children:t("暂无项目,请先创建项目")})})]});const Y=()=>{c&&v.mutate({id:c,copyFiles:n.copyFiles.length>0?n.copyFiles.join(", "):null,setupScript:n.setupScript.trim()||null,quickCommands:n.quickCommands.length>0?JSON.stringify(n.quickCommands):null},{onSuccess:()=>m(!1)})},ee=r=>{N(null),x(r),m(!1)},te=()=>{h&&(P(h.id),F(!1),l(!1),k(!0))},O=()=>{o.isPending||(k(!1),P(null),F(!1),l(!1))},se=async()=>{if(j)try{await o.mutateAsync({id:j,deleteRepo:C}),B.success(t(C?"项目已删除,并清理了本地文件":"项目已删除")),m(!1),O()}catch{}},re=r=>{const d=E.find(_=>_.id===r);P(r),q(d?.repoDeletedAt?d.repoPath:""),A(!0)},L=()=>{i.isPending||(A(!1),P(null),q(""))},ne=async()=>{if(!(!j||M?.repoDeletedAt&&!w.trim()))try{const d=await i.mutateAsync({id:j,repoPath:w.trim()||void 0});B.success(t("项目已恢复"));for(const _ of d.warnings)B.warning(_);m(!1),N(d.project.id),x(d.project.id),L()}catch{}},J=M?.name??t("this project"),T=!!M?.repoDeletedAt;return e.jsxs(e.Fragment,{children:[e.jsxs(K,{className:"max-w-5xl",children:[e.jsx("h2",{className:"text-base font-semibold text-neutral-900 mb-5",children:t("项目配置")}),f.length===0&&E.length===0?e.jsx("div",{className:"rounded-xl border border-dashed border-neutral-200 bg-neutral-50/50 py-16 text-center",children:e.jsx("p",{className:"text-sm text-neutral-400",children:t("暂无项目,请先创建项目")})}):e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[240px_minmax(0,1fr)] lg:h-[calc(100vh-16rem)] lg:max-h-[640px]",children:[e.jsxs("div",{className:R("space-y-1 lg:overflow-y-auto lg:pr-1 scrollbar-app-thin",G&&"hidden lg:block"),children:[f.map(r=>{const d=r.id===c;return e.jsxs("button",{onClick:()=>{ee(r.id),U(!0)},className:R("flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left transition-all",d?"bg-neutral-900 text-white":"hover:bg-neutral-50 text-neutral-700"),children:[e.jsx("span",{className:R("h-2 w-2 rounded-full shrink-0",d?"bg-white/60":V(r))}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13px] font-medium",children:r.name}),e.jsx("div",{className:R("truncate text-[11px] font-mono",d?"text-neutral-300":"text-neutral-400"),children:r.repoPath.split("/").pop()})]})]},r.id)}),E.length>0&&e.jsxs("div",{className:"pt-3 mt-2 border-t border-neutral-100",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 mb-1",children:[e.jsx("span",{className:"text-[11px] font-medium text-neutral-400",children:t("已删除")}),e.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:E.length})]}),E.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg px-3 py-2 text-neutral-500",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:"truncate text-[12px] text-neutral-500",children:r.name})}),e.jsx("button",{onClick:()=>re(r.id),disabled:i.isPending,className:"shrink-0 text-[11px] text-neutral-400 hover:text-neutral-900 transition-colors",children:e.jsx(he,{size:12})})]},r.id))]})]}),e.jsxs("div",{className:R("rounded-xl border border-neutral-200 bg-white lg:overflow-y-auto scrollbar-app-thin",!G&&"hidden lg:block"),children:[e.jsxs("button",{onClick:()=>U(!1),className:"flex items-center gap-1.5 text-xs text-neutral-500 hover:text-neutral-900 transition-colors px-5 pt-3 lg:hidden",children:[e.jsx(pe,{size:14}),t("返回列表")]}),h?e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:R("h-2.5 w-2.5 rounded-full shrink-0",V(h))}),e.jsx("h3",{className:"text-base font-semibold text-neutral-900",children:h.name})]}),e.jsx("p",{className:"text-[11px] text-neutral-400 font-mono mb-5",children:h.repoPath}),e.jsxs("div",{className:"divide-y divide-neutral-100",children:[e.jsxs("div",{className:"py-5 first:pt-0",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-[13px] font-medium text-neutral-900",children:t("自动复制文件")}),e.jsx("p",{className:"text-[11px] text-neutral-400 mt-0.5",children:t("创建 worktree 时自动从主仓库复制的文件或目录,适用于 .env、node_modules 等不在 git 管理中的文件。支持 glob。")})]}),e.jsx(ge,{value:n.copyFiles,onChange:r=>{u(d=>({...d,copyFiles:r})),m(!0)},repoPath:h.repoPath})]}),e.jsxs("div",{className:"py-5",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-[13px] font-medium text-neutral-900",children:t("Setup 脚本")}),e.jsx("p",{className:"text-[11px] text-neutral-400 mt-0.5",children:t("创建 worktree 后自动执行的命令,每行一条。在 worktree 目录下执行,单条超时 5 分钟。")})]}),e.jsx("textarea",{value:n.setupScript,onChange:r=>{u(d=>({...d,setupScript:r.target.value})),m(!0)},placeholder:`pnpm install
|
|
1
|
+
import{e as ae,u as W,r as a,i as le,j as e,X,d as R,t as B}from"./index-RxbHMWXV.js";import{F as Q,a as $,u as ie,b as oe,c as ce,d as de,e as ue}from"./folder-picker-BEHS3b2Q.js";import{B as D}from"./button-BUA8P726.js";import{P as Z,a as xe,T as me,M as H}from"./modal-UGrjU63G.js";import{S as K}from"./SettingsSection-pLJ3msrT.js";import{R as he}from"./rotate-ccw-CWaMrTz4.js";import{A as pe}from"./arrow-left-lFz8nyZM.js";import"./chevron-right-F9i4wey6.js";import"./loader-circle-stJcjnm-.js";import"./check-BYuuXc71.js";const fe=[["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"}]],je=ae("folder-plus",fe);function ge({value:t,onChange:g,repoPath:b,placeholder:v}){const{t:o}=W(),[i,c]=a.useState(""),[x,p]=a.useState([]),[N,n]=a.useState(!1),[u,y]=a.useState(-1),m=a.useRef(null),j=a.useRef(null),P=a.useRef(void 0),z=a.useCallback(async s=>{if(!b||!s){p([]),n(!1);return}try{const l=await le.get("/filesystem/complete",{params:{basePath:b,prefix:s}});p(l.results),n(l.results.length>0),y(-1)}catch{p([]),n(!1)}},[b]);a.useEffect(()=>{if(clearTimeout(P.current),!i){p([]),n(!1);return}return P.current=setTimeout(()=>z(i),200),()=>clearTimeout(P.current)},[i,z]),a.useEffect(()=>{const s=l=>{j.current&&!j.current.contains(l.target)&&m.current&&!m.current.contains(l.target)&&n(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[]);const k=s=>{const l=s.trim();!l||t.includes(l)||(g([...t,l]),c(""),n(!1),m.current?.focus())},I=s=>{g(t.filter((l,w)=>w!==s))},A=s=>{s.type==="directory"?(c(s.path),m.current?.focus()):k(s.path)},C=(s,l)=>{l.stopPropagation(),k(s.path.replace(/\/$/,""))},F=s=>{s.nativeEvent.isComposing||s.nativeEvent.keyCode===229||(N&&x.length>0?s.key==="ArrowDown"?(s.preventDefault(),y(l=>Math.min(l+1,x.length-1))):s.key==="ArrowUp"?(s.preventDefault(),y(l=>Math.max(l-1,-1))):s.key==="Enter"?(s.preventDefault(),u>=0?A(x[u]):k(i)):s.key==="Escape"&&n(!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,l)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 group",children:[s.includes(".")&&!s.endsWith("/")?e.jsx(Q,{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:()=>I(l),className:"p-0.5 text-neutral-300 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:e.jsx(X,{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:F,onFocus:()=>{i&&x.length>0&&n(!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(Z,{size:14}),e.jsx("span",{children:o("添加")})]})]}),N&&e.jsx("div",{ref:j,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,l)=>e.jsxs("button",{onClick:()=>A(s),className:`w-full flex items-center gap-2 px-3 py-1.5 text-sm text-left hover:bg-neutral-50 transition-colors ${l===u?"bg-neutral-100":""}`,children:[s.type==="directory"?e.jsx($,{size:14,className:"text-amber-500 shrink-0"}):e.jsx(Q,{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(je,{size:14})})]},s.path))})]})]})}function be({value:t,onChange:g}){const{t:b}=W(),[v,o]=a.useState(""),[i,c]=a.useState(""),x=()=>{const n=v.trim(),u=i.trim();!n||!u||(g([...t,{name:n,command:u}]),o(""),c(""))},p=n=>{g(t.filter((u,y)=>y!==n))},N=n=>{n.key==="Enter"&&!n.nativeEvent.isComposing&&n.nativeEvent.keyCode!==229&&(n.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((n,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:n.name}),e.jsx("span",{className:"text-sm font-mono text-neutral-500 flex-1 truncate",children:n.command}),e.jsx("button",{onClick:()=>p(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(X,{size:14})})]},u))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:v,onChange:n=>o(n.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:n=>c(n.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(Z,{size:14}),e.jsx("span",{children:b("添加")})]})]})]})}function ve(t){return t?t.split(",").map(g=>g.trim()).filter(Boolean):[]}function Ne(t){if(!t)return[];try{return JSON.parse(t)}catch{return[]}}function V(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 Ee(){const{t}=W(),{data:g,isLoading:b}=ie({limit:100,includeArchived:!0}),v=oe(),o=ce(),i=de(),[c,x]=a.useState(""),[p,N]=a.useState(null),[n,u]=a.useState({copyFiles:[],setupScript:"",quickCommands:[]}),[y,m]=a.useState(!1),[j,P]=a.useState(null),[z,k]=a.useState(!1),[I,A]=a.useState(!1),[C,F]=a.useState(!1),[s,l]=a.useState(!1),[w,q]=a.useState(""),[G,U]=a.useState(!1),S=g?.data??[],f=a.useMemo(()=>S.filter(r=>!r.archivedAt),[S]),E=a.useMemo(()=>S.filter(r=>r.archivedAt),[S]),h=f.find(r=>r.id===c),M=a.useMemo(()=>S.find(r=>r.id===j)??null,[j,S]);if(a.useEffect(()=>{!c&&f.length>0&&x(f[0].id)},[f,c]),a.useEffect(()=>{if(p){f.some(r=>r.id===p)&&(x(p),N(null));return}c&&!f.some(r=>r.id===c)&&(x(f[0]?.id??""),m(!1))},[f,p,c]),a.useEffect(()=>{h&&!y&&u({copyFiles:ve(h.copyFiles),setupScript:h.setupScript??"",quickCommands:Ne(h.quickCommands)})},[h,y]),b)return e.jsx(K,{className:"max-w-5xl",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-neutral-200 border-t-neutral-600"})})});if(S.length===0)return e.jsxs(K,{className:"max-w-5xl",children:[e.jsx("h2",{className:"text-base font-semibold text-neutral-900 mb-5",children:t("项目配置")}),e.jsx("div",{className:"rounded-xl border border-dashed border-neutral-200 bg-neutral-50/50 py-16 text-center",children:e.jsx("p",{className:"text-sm text-neutral-400",children:t("暂无项目,请先创建项目")})})]});const Y=()=>{c&&v.mutate({id:c,copyFiles:n.copyFiles.length>0?n.copyFiles.join(", "):null,setupScript:n.setupScript.trim()||null,quickCommands:n.quickCommands.length>0?JSON.stringify(n.quickCommands):null},{onSuccess:()=>m(!1)})},ee=r=>{N(null),x(r),m(!1)},te=()=>{h&&(P(h.id),F(!1),l(!1),k(!0))},O=()=>{o.isPending||(k(!1),P(null),F(!1),l(!1))},se=async()=>{if(j)try{await o.mutateAsync({id:j,deleteRepo:C}),B.success(t(C?"项目已删除,并清理了本地文件":"项目已删除")),m(!1),O()}catch{}},re=r=>{const d=E.find(_=>_.id===r);P(r),q(d?.repoDeletedAt?d.repoPath:""),A(!0)},L=()=>{i.isPending||(A(!1),P(null),q(""))},ne=async()=>{if(!(!j||M?.repoDeletedAt&&!w.trim()))try{const d=await i.mutateAsync({id:j,repoPath:w.trim()||void 0});B.success(t("项目已恢复"));for(const _ of d.warnings)B.warning(_);m(!1),N(d.project.id),x(d.project.id),L()}catch{}},J=M?.name??t("this project"),T=!!M?.repoDeletedAt;return e.jsxs(e.Fragment,{children:[e.jsxs(K,{className:"max-w-5xl",children:[e.jsx("h2",{className:"text-base font-semibold text-neutral-900 mb-5",children:t("项目配置")}),f.length===0&&E.length===0?e.jsx("div",{className:"rounded-xl border border-dashed border-neutral-200 bg-neutral-50/50 py-16 text-center",children:e.jsx("p",{className:"text-sm text-neutral-400",children:t("暂无项目,请先创建项目")})}):e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[240px_minmax(0,1fr)] lg:h-[calc(100vh-16rem)] lg:max-h-[640px]",children:[e.jsxs("div",{className:R("space-y-1 lg:overflow-y-auto lg:pr-1 scrollbar-app-thin",G&&"hidden lg:block"),children:[f.map(r=>{const d=r.id===c;return e.jsxs("button",{onClick:()=>{ee(r.id),U(!0)},className:R("flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left transition-all",d?"bg-neutral-900 text-white":"hover:bg-neutral-50 text-neutral-700"),children:[e.jsx("span",{className:R("h-2 w-2 rounded-full shrink-0",d?"bg-white/60":V(r))}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13px] font-medium",children:r.name}),e.jsx("div",{className:R("truncate text-[11px] font-mono",d?"text-neutral-300":"text-neutral-400"),children:r.repoPath.split("/").pop()})]})]},r.id)}),E.length>0&&e.jsxs("div",{className:"pt-3 mt-2 border-t border-neutral-100",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 mb-1",children:[e.jsx("span",{className:"text-[11px] font-medium text-neutral-400",children:t("已删除")}),e.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:E.length})]}),E.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg px-3 py-2 text-neutral-500",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:"truncate text-[12px] text-neutral-500",children:r.name})}),e.jsx("button",{onClick:()=>re(r.id),disabled:i.isPending,className:"shrink-0 text-[11px] text-neutral-400 hover:text-neutral-900 transition-colors",children:e.jsx(he,{size:12})})]},r.id))]})]}),e.jsxs("div",{className:R("rounded-xl border border-neutral-200 bg-white lg:overflow-y-auto scrollbar-app-thin",!G&&"hidden lg:block"),children:[e.jsxs("button",{onClick:()=>U(!1),className:"flex items-center gap-1.5 text-xs text-neutral-500 hover:text-neutral-900 transition-colors px-5 pt-3 lg:hidden",children:[e.jsx(pe,{size:14}),t("返回列表")]}),h?e.jsxs("div",{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:R("h-2.5 w-2.5 rounded-full shrink-0",V(h))}),e.jsx("h3",{className:"text-base font-semibold text-neutral-900",children:h.name})]}),e.jsx("p",{className:"text-[11px] text-neutral-400 font-mono mb-5",children:h.repoPath}),e.jsxs("div",{className:"divide-y divide-neutral-100",children:[e.jsxs("div",{className:"py-5 first:pt-0",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-[13px] font-medium text-neutral-900",children:t("自动复制文件")}),e.jsx("p",{className:"text-[11px] text-neutral-400 mt-0.5",children:t("创建 worktree 时自动从主仓库复制的文件或目录,适用于 .env、node_modules 等不在 git 管理中的文件。支持 glob。")})]}),e.jsx(ge,{value:n.copyFiles,onChange:r=>{u(d=>({...d,copyFiles:r})),m(!0)},repoPath:h.repoPath})]}),e.jsxs("div",{className:"py-5",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-[13px] font-medium text-neutral-900",children:t("Setup 脚本")}),e.jsx("p",{className:"text-[11px] text-neutral-400 mt-0.5",children:t("创建 worktree 后自动执行的命令,每行一条。在 worktree 目录下执行,单条超时 5 分钟。")})]}),e.jsx("textarea",{value:n.setupScript,onChange:r=>{u(d=>({...d,setupScript:r.target.value})),m(!0)},placeholder:`pnpm install
|
|
2
2
|
pnpm run setup`,rows:4,className:"w-full rounded-lg border border-neutral-200 bg-neutral-50/50 px-3 py-2 text-sm font-mono transition-colors focus:border-neutral-400 focus:bg-white focus:outline-none resize-none"})]}),e.jsxs("div",{className:"py-5",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("h3",{className:"text-[13px] font-medium text-neutral-900",children:t("常用命令")}),e.jsx("p",{className:"text-[11px] text-neutral-400 mt-0.5",children:t("在终端中可快速执行的命令,不会自动运行。")})]}),e.jsx(be,{value:n.quickCommands,onChange:r=>{u(d=>({...d,quickCommands:r})),m(!0)}})]})]}),e.jsx("div",{className:"mt-2 rounded-lg border border-red-200/60 bg-red-50/30 p-4",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(xe,{size:15,className:"text-red-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[13px] font-medium text-red-900",children:t("删除项目")}),e.jsx("p",{className:"text-[11px] text-red-600/70 mt-0.5",children:t("项目将从默认列表隐藏,历史记录保留。可选同时删除本地文件。")})]})]}),e.jsxs(D,{size:"sm",variant:"destructive",className:"shrink-0",onClick:te,disabled:o.isPending||i.isPending,children:[e.jsx(me,{size:13}),t("删除项目")]})]})}),y&&e.jsx("div",{className:"sticky bottom-0 -mx-5 px-5 py-3 mt-4 bg-white/90 backdrop-blur border-t border-neutral-100",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-neutral-500",children:t("有未保存的更改")}),e.jsx(D,{size:"sm",onClick:Y,disabled:v.isPending,children:v.isPending?t("保存中..."):t("保存")})]})})]}):e.jsx("div",{className:"py-16 text-center text-sm text-neutral-400",children:f.length>0?t("选择一个项目查看配置"):t("当前没有可配置的项目")})]})]})]}),e.jsx(H,{isOpen:z,onClose:O,title:t("Delete Project"),action:e.jsxs(e.Fragment,{children:[e.jsx(D,{variant:"outline",onClick:O,disabled:o.isPending,children:t("Cancel")}),e.jsx(D,{variant:"destructive",onClick:se,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:J})}),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:r=>{F(r.target.checked),r.target.checked||l(!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:r=>l(r.target.checked),className:"mt-0.5"}),e.jsx("span",{children:t("我已确认这会删除本地项目文件")})]})]}),o.isError&&e.jsx("p",{className:"text-xs text-red-500",children:o.error instanceof Error?o.error.message:t("Failed to delete project")})]})}),e.jsx(H,{isOpen:I,onClose:L,title:t("Restore Project"),action:e.jsxs(e.Fragment,{children:[e.jsx(D,{variant:"outline",onClick:L,disabled:i.isPending,children:t("Cancel")}),e.jsx(D,{onClick:ne,disabled:i.isPending||T&&!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:T?t("项目「{title}」的本地仓库文件已删除。恢复前需要重新绑定一个有效的 Git 仓库路径。",{title:J}):t("恢复后,项目会重新出现在默认项目列表中。")}),T&&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:q}),e.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:t("Agent Tower 会尽量校验仓库 identity;如果 remote URL 或目录名不同,会给出警告但允许继续。")})]}),i.isError&&e.jsx("p",{className:"text-xs text-red-500",children:i.error instanceof Error?i.error.message:t("Failed to restore project")})]})})]})}export{Ee as ProjectSettingsPage};
|
package/dist/web/assets/{ProviderSettingsPage-BWN7CEG6.js → ProviderSettingsPage-BIUYN2e0.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as je,f as we,q as Ne,i as Ce,u as T,r as v,j as n,d as I,t as _,E as te}from"./index-
|
|
1
|
+
import{e as je,f as we,q as Ne,i as Ce,u as T,r as v,j as n,d as I,t as _,E as te}from"./index-RxbHMWXV.js";import{u as Ee,a as ke,b as Pe,c as Oe,d as _e,e as Ie,f as Te}from"./use-providers-DVP6emIi.js";import{B as N}from"./button-BUA8P726.js";import{C as Ae}from"./confirm-dialog-B_wk_zqm.js";import{P as $,T as ae,M as q}from"./modal-UGrjU63G.js";import{S as ie}from"./select-BMlH2AuL.js";import{A as w}from"./log-adapter-CtvxzS4j.js";import{C as oe}from"./chevron-down-B931AgE2.js";import{S as ne}from"./SettingsSection-pLJ3msrT.js";import{U as Se,C as De}from"./upload-B-Mpvu9j.js";import{A as Le}from"./arrow-left-lFz8nyZM.js";import{P as Re}from"./pencil-uRBgB4qA.js";import{R as ze}from"./rotate-ccw-CWaMrTz4.js";import{C as Fe}from"./circle-check-C7xXtl8B.js";import"./check-BYuuXc71.js";const Ue=[["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"}]],Me=je("download",Ue);function Be(e,t){let a=e.slice(0,t).split(/\r\n|\n|\r/g);return[a.length,a.pop().length+1]}function Ge(e,t,a){let i=e.split(/\r\n|\n|\r/g),l="",s=(Math.log10(t+1)|0)+1;for(let r=t-1;r<=t+1;r++){let o=i[r-1];o&&(l+=r.toString().padEnd(s," "),l+=": ",l+=o,l+=`
|
|
2
2
|
`,r===t&&(l+=" ".repeat(s+a+2),l+=`^
|
|
3
3
|
`))}return l}class p extends Error{line;column;codeblock;constructor(t,a){const[i,l]=Be(a.toml,a.ptr),s=Ge(a.toml,i,l);super(`Invalid TOML document: ${t}
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as a,d as x}from"./index-
|
|
1
|
+
import{j as a,d as x}from"./index-RxbHMWXV.js";function n({children:s,className:t}){return a.jsx("div",{className:x("mx-auto w-full max-w-4xl px-5 py-5 sm:px-8 sm:py-6",t),children:s})}export{n as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as $e,k as pt,l as bt,m as ht,n as gt,o as vt,p as ft,s as jt,v as yt,r as i,j as e,d as B,t as d}from"./index-CUJoWIuo.js";import{B as p}from"./button-CUTjpRqw.js";import{C as Ee}from"./confirm-dialog-wsb35VpE.js";import{T as ue,P as O,M as Nt}from"./modal-25-qs8P5.js";import{S as R}from"./select-CzeTYLO4.js";import{M as U}from"./MemberAvatar-pwugXGL4.js";import{u as Pt}from"./use-providers-Bwl7R5Ql.js";import{S as Ae}from"./SettingsSection-C-sMhXpf.js";import{A as Me}from"./arrow-left-UHjQiY5K.js";import{C as wt}from"./chevron-up-BnCoaejn.js";import{C as Tt}from"./chevron-down-Bby7sJEv.js";import"./check-CPkZgPjx.js";const l="/avatars/presets",kt=[{id:"developer",label:"Developer",src:`${l}/avatar-preset-01-developer.png`},{id:"architect",label:"Architect",src:`${l}/avatar-preset-02-architect.png`},{id:"tester",label:"Tester",src:`${l}/avatar-preset-03-tester.png`},{id:"devops",label:"DevOps",src:`${l}/avatar-preset-04-devops.png`},{id:"data-scientist",label:"Data scientist",src:`${l}/avatar-preset-05-data-scientist.png`},{id:"frontend",label:"Frontend",src:`${l}/avatar-preset-06-frontend.png`},{id:"backend",label:"Backend",src:`${l}/avatar-preset-07-backend.png`},{id:"security",label:"Security",src:`${l}/avatar-preset-08-security.png`},{id:"project-manager",label:"Project manager",src:`${l}/avatar-preset-09-project-manager.png`},{id:"product-manager",label:"Product manager",src:`${l}/avatar-preset-10-product-manager.png`},{id:"scrum-master",label:"Scrum master",src:`${l}/avatar-preset-11-scrum-master.png`},{id:"tech-lead",label:"Tech lead",src:`${l}/avatar-preset-12-tech-lead.png`},{id:"coordinator",label:"Coordinator",src:`${l}/avatar-preset-13-coordinator.png`},{id:"mentor",label:"Mentor",src:`${l}/avatar-preset-14-mentor.png`},{id:"reviewer",label:"Reviewer",src:`${l}/avatar-preset-15-reviewer.png`},{id:"ui-designer",label:"UI designer",src:`${l}/avatar-preset-16-ui-designer.png`},{id:"ux-researcher",label:"UX researcher",src:`${l}/avatar-preset-17-ux-researcher.png`},{id:"documenter",label:"Documenter",src:`${l}/avatar-preset-18-documenter.png`},{id:"translator",label:"Translator",src:`${l}/avatar-preset-19-translator.png`},{id:"analyst",label:"Analyst",src:`${l}/avatar-preset-20-analyst.png`},{id:"consultant",label:"Consultant",src:`${l}/avatar-preset-21-consultant.png`},{id:"creative-director",label:"Creative director",src:`${l}/avatar-preset-22-creative-director.png`},{id:"support",label:"Support",src:`${l}/avatar-preset-23-support.png`},{id:"assistant",label:"Assistant",src:`${l}/avatar-preset-24-assistant.png`},{id:"robot",label:"Robot",src:`${l}/avatar-preset-25-robot.png`}],Oe="/api",Ct=2*1024*1024,It=[],St=[],Et=[],Re=[{key:"readRoom",label:"读房间"},{key:"postRoomMessage",label:"发房间消息"},{key:"mentionMembers",label:"提及成员"},{key:"stopMemberWork",label:"停止成员工作"},{key:"markReadyForReview",label:"标记可审查"},{key:"readFiles",label:"读文件"},{key:"writeFiles",label:"写文件"},{key:"runCommands",label:"运行命令"},{key:"readDiff",label:"读 diff"},{key:"mergeWorkspace",label:"合并工作区"}],De={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},_e=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],At=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],Mt=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],_t=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function Y(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...De},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function xe(a){return{name:a.name,aliasesText:a.aliases.join(", "),providerId:a.providerId,rolePrompt:a.rolePrompt,capabilities:{...De,...a.capabilities},workspacePolicy:a.workspacePolicy,triggerPolicy:a.triggerPolicy,sessionPolicy:a.sessionPolicy,queueManagementPolicy:a.queueManagementPolicy,avatar:a.avatar??""}}function q(){return{name:"",memberPresetIds:[]}}function pe(a){return{name:a.name,memberPresetIds:a.members?.map(o=>o.memberPresetId)??[]}}function Ft(a,o,c,m){if(c.filter(M=>M===m).length<=1)return a;const G=c.slice(0,o+1).filter(M=>M===m).length;return`${a} #${G}`}function $t(a){return Array.from(new Set(a.split(/[\n,]/).map(o=>o.trim()).filter(Boolean)))}function Ot(a){return a.trim()||null}function Fe(a){return Re.reduce((o,c)=>o+(a[c.key]?1:0),0)}function A(a,o){return a instanceof Error?a.message:o}function Rt(a){return["image/png","image/jpeg","image/webp"].includes(a.type)}async function Dt(a){const o=new FormData;o.append("file",a);const c=await fetch(`${Oe}/attachments/upload`,{method:"POST",body:o});if(!c.ok){const m=await c.json().catch(()=>({}));throw new Error(m.error||m.message||`Upload failed (${c.status})`)}return c.json()}function W({title:a,error:o,isFetching:c,onRetry:m}){const{t:T}=$e();return e.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium",children:a}),e.jsx("div",{className:"mt-1 text-xs text-red-600",children:A(o,T("请稍后重试。"))})]}),e.jsx(p,{type:"button",size:"sm",variant:"outline",onClick:m,disabled:c,children:T(c?"加载中...":"重试")})]})})}function Jt(){const{t:a}=$e(),{data:o,error:c,isError:m,isFetching:T,isLoading:G,refetch:M}=Pt(),{data:ze,error:be,isError:k,isFetching:he,isLoading:V,refetch:ge}=pt(),{data:Le,error:Be,isError:D,isFetching:Ue,isLoading:Q,refetch:Ye}=bt(),X=ht(),H=gt(),ve=vt(),J=ft(),K=jt(),fe=yt(),[Z,je]=i.useState("presets"),[C,ee]=i.useState("edit"),[g,te]=i.useState(null),[r,f]=i.useState(Y()),[ye,_]=i.useState(!1),[j,ae]=i.useState(null),[qe,se]=i.useState(!1),[Ne,Pe]=i.useState(!1),we=i.useRef(null),[I,re]=i.useState("edit"),[v,ne]=i.useState(null),[y,b]=i.useState(q()),[Te,N]=i.useState(!1),[P,le]=i.useState(null),[ke,F]=i.useState(!1),u=ze??It,h=Le??St,z=o??Et,$=i.useMemo(()=>new Map(u.map(t=>[t.id,t])),[u]),ie=i.useMemo(()=>new Map(h.map(t=>[t.id,t])),[h]),We=i.useMemo(()=>{const t=z.map(({provider:s,availability:n})=>({value:s.id,label:s.name+(n.type==="NOT_FOUND"?a(" (不可用)"):""),disabled:n.type==="NOT_FOUND"}));return r.providerId&&!t.some(s=>s.value===r.providerId)&&t.unshift({value:r.providerId,label:`${r.providerId}${a(" (不可用)")}`,disabled:!0}),t},[r.providerId,z,a]),oe=g?$.get(g)??null:null,ce=v?ie.get(v)??null:null,Ge=i.useMemo(()=>new Map(z.map(({provider:t,availability:s})=>[t.id,t.name+(s.type==="NOT_FOUND"?a(" (不可用)"):"")])),[z,a]);if(i.useEffect(()=>{if(!(V||k||ye)){if(C==="create"){f(Y());return}if(g){const t=$.get(g);t&&f(xe(t));return}if(u.length>0){const t=u[0];te(t.id),ee("edit"),f(xe(t));return}ee("create"),te(null),f(Y())}},[$,ye,C,u,k,V,g]),i.useEffect(()=>{if(!(Q||D||Te)){if(I==="create"){b(q());return}if(v){const t=ie.get(v);t&&b(pe(t));return}if(h.length>0){const t=h[0];ne(t.id),re("edit"),b(pe(t));return}re("create"),ne(null),b(q())}},[v,ie,Te,I,h,D,Q]),G||V||Q)return e.jsx(Ae,{className:"max-w-6xl",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-neutral-200 border-t-neutral-600"})})});const x=(t,s)=>{f(n=>({...n,[t]:s})),_(!0)},Ve=(t,s)=>{f(n=>({...n,capabilities:{...n.capabilities,[t]:s}})),_(!0)},Qe=t=>{x("avatar",t),se(!1)},Xe=()=>{x("avatar","")},He=async t=>{const s=t.target.files?.[0];if(t.target.value="",!!s){if(!Rt(s)){d.error(a("仅支持 PNG、JPG、WebP 头像。"));return}if(s.size>Ct){d.error(a("头像图片不能超过 2MB。"));return}Pe(!0);try{const n=await Dt(s);x("avatar",`${Oe}${n.url}`),d.success(a("头像已上传"))}catch(n){d.error(A(n,a("头像上传失败")))}finally{Pe(!1)}}},S=(t,s)=>{ee(t),te(s?.id??null),f(s?xe(s):Y()),_(!1)},Je=(t,s)=>{b(n=>({...n,[t]:s})),N(!0)},E=(t,s)=>{re(t),ne(s?.id??null),b(s?pe(s):q()),N(!1)},Ke=async()=>{const t={name:r.name.trim(),aliases:$t(r.aliasesText),providerId:r.providerId.trim(),rolePrompt:r.rolePrompt.trim(),capabilities:{...r.capabilities},workspacePolicy:r.workspacePolicy,triggerPolicy:r.triggerPolicy,sessionPolicy:r.sessionPolicy,queueManagementPolicy:r.queueManagementPolicy,avatar:Ot(r.avatar)};try{if(C==="create"||!g){const s=await X.mutateAsync(t);S("edit",s),d.success(a("已创建"))}else{const s=await H.mutateAsync({id:g,data:t});S("edit",s),d.success(a("已保存"))}}catch(s){d.error(A(s,a("保存失败")))}},Ze=async()=>{if(j)try{await ve.mutateAsync(j.id),d.success(a("Deleted"));const t=u.filter(s=>s.id!==j.id);g===j.id&&(t.length>0?S("edit",t[0]):S("create",null)),ae(null)}catch(t){d.error(A(t,a("删除失败")))}},et=async()=>{const t={name:y.name.trim(),memberPresetIds:y.memberPresetIds};try{if(I==="create"||!v){const s=await J.mutateAsync(t);E("edit",s),d.success(a("已创建"))}else{const s=await K.mutateAsync({id:v,data:t});E("edit",s),d.success(a("已保存"))}}catch(s){d.error(A(s,a("保存失败")))}},tt=async()=>{if(P)try{await fe.mutateAsync(P.id),d.success(a("Deleted"));const t=h.filter(s=>s.id!==P.id);v===P.id&&(t.length>0?E("edit",t[0]):E("create",null)),le(null)}catch(t){d.error(A(t,a("删除失败")))}},at=Fe(r.capabilities),st=!!r.name.trim()&&!!r.providerId.trim()&&!!r.rolePrompt.trim()&&!m&&!k&&!X.isPending&&!H.isPending,rt=!!y.name.trim()&&!D&&!k&&!J.isPending&&!K.isPending,de=y.memberPresetIds.map(t=>$.get(t)).filter(t=>!!t),nt=t=>{_(!1),S("edit",t)},lt=()=>{_(!1),S("create",null)},it=t=>{N(!1),E("edit",t)},ot=()=>{N(!1),E("create",null)},ct=t=>{b(s=>({...s,memberPresetIds:[...s.memberPresetIds,t]})),N(!0)},dt=t=>{b(s=>({...s,memberPresetIds:s.memberPresetIds.filter((n,w)=>w!==t)})),N(!0)},Ce=(t,s)=>{b(n=>{const w=t+s;if(w<0||w>=n.memberPresetIds.length)return n;const me=[...n.memberPresetIds],[xt]=me.splice(t,1);return me.splice(w,0,xt),{...n,memberPresetIds:me}}),N(!0)},mt=t=>{nt(t),F(!0)},Ie=()=>{lt(),F(!0)},ut=t=>{it(t),F(!0)},Se=()=>{ot(),F(!0)},L=()=>F(!1);return e.jsxs(Ae,{className:"max-w-6xl",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-5",children:[e.jsx("h2",{className:"text-base font-semibold text-neutral-900",children:a("团队协作设置")}),e.jsxs("div",{className:"inline-flex rounded-lg border border-neutral-200 bg-neutral-50/80 p-0.5",children:[e.jsx("button",{type:"button",onClick:()=>{je("presets"),L()},className:B("rounded-md px-3 py-1.5 text-[12px] font-medium transition-all",Z==="presets"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:a("成员预设")}),e.jsx("button",{type:"button",onClick:()=>{je("templates"),L()},className:B("rounded-md px-3 py-1.5 text-[12px] font-medium transition-all",Z==="templates"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:a("团队模板")})]})]}),m&&e.jsx(W,{title:a("Provider 列表加载失败"),error:c,isFetching:T,onRetry:()=>{M()}}),Z==="presets"?ke?e.jsxs("div",{className:"rounded-xl border border-neutral-200 bg-white",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-100 px-5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:L,className:"flex items-center gap-1.5 text-xs text-neutral-500 hover:text-neutral-900 transition-colors",children:[e.jsx(Me,{size:14}),a("返回")]}),e.jsx("span",{className:"text-neutral-200",children:"|"}),e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900",children:C==="create"?a("创建新预设"):oe?.name??a("编辑预设")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[C==="edit"&&oe&&e.jsx("button",{onClick:()=>ae(oe),className:"flex h-7 w-7 items-center justify-center rounded-md text-neutral-400 hover:text-red-500 hover:bg-red-50 transition-colors",title:a("删除"),children:e.jsx(ue,{size:14})}),e.jsx(p,{size:"sm",onClick:Ke,disabled:!st,children:X.isPending||H.isPending?a("保存中..."):a(C==="create"?"创建":"保存")})]})]}),e.jsxs("div",{className:"p-5 space-y-5",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("div",{className:"shrink-0",children:[e.jsx(U,{name:r.name||a("Agent"),avatar:r.avatar,className:"h-14 w-14 text-sm"}),e.jsxs("div",{className:"flex justify-center gap-1 mt-2",children:[e.jsx("button",{type:"button",onClick:()=>se(!0),className:"text-[10px] text-neutral-400 hover:text-neutral-700 transition-colors",children:a("选择")}),e.jsx("span",{className:"text-[10px] text-neutral-300",children:"·"}),e.jsx("button",{type:"button",onClick:()=>we.current?.click(),disabled:Ne,className:"text-[10px] text-neutral-400 hover:text-neutral-700 transition-colors",children:a(Ne?"...":"上传")}),r.avatar.trim()&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[10px] text-neutral-300",children:"·"}),e.jsx("button",{type:"button",onClick:Xe,className:"text-[10px] text-neutral-400 hover:text-red-500 transition-colors",children:a("清除")})]})]}),e.jsx("input",{ref:we,type:"file",accept:"image/png,image/jpeg,image/webp",className:"hidden",onChange:He})]}),e.jsxs("div",{className:"flex-1 min-w-0 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("名称")}),e.jsx("input",{value:r.name,onChange:t=>x("name",t.target.value),className:"w-full rounded-lg border border-neutral-200 bg-white px-3 py-2 text-sm transition-colors focus:border-neutral-400 focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("别名")}),e.jsx("input",{value:r.aliasesText,onChange:t=>x("aliasesText",t.target.value),placeholder:a("alice, a, reviewer"),className:"w-full rounded-lg border border-neutral-200 bg-white px-3 py-2 text-sm transition-colors focus:border-neutral-400 focus:outline-none"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("Provider")}),e.jsx(R,{value:r.providerId,onChange:t=>x("providerId",t),options:We,disabled:m}),m&&e.jsx("p",{className:"mt-1 text-[11px] text-red-500",children:a("Provider 列表加载失败。")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("角色提示词")}),e.jsx("textarea",{value:r.rolePrompt,onChange:t=>x("rolePrompt",t.target.value),rows:4,className:"w-full rounded-lg border border-neutral-200 bg-neutral-50/50 px-3 py-2 text-sm font-mono transition-colors focus:border-neutral-400 focus:bg-white focus:outline-none resize-y"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-end justify-between gap-3 mb-2",children:[e.jsx("label",{className:"text-[12px] font-medium text-neutral-600",children:a("可用能力")}),e.jsxs("span",{className:"text-[11px] text-neutral-400",children:[at,"/10"]})]}),e.jsx("div",{className:"grid gap-1 sm:grid-cols-2 xl:grid-cols-3",children:Re.map(t=>e.jsxs("label",{className:"flex items-center gap-2 rounded px-2.5 py-1.5 text-[12px] text-neutral-700 hover:bg-neutral-50 transition-colors cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r.capabilities[t.key],onChange:s=>Ve(t.key,s.target.checked),className:"h-3.5 w-3.5 rounded border-neutral-300"}),e.jsx("span",{children:a(t.label)})]},t.key))})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("工作区")}),e.jsx(R,{value:r.workspacePolicy,onChange:t=>x("workspacePolicy",t),options:_e.map(t=>({value:t.value,label:a(t.label)}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("触发")}),e.jsx(R,{value:r.triggerPolicy,onChange:t=>x("triggerPolicy",t),options:At.map(t=>({value:t.value,label:a(t.label)}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("会话")}),e.jsx(R,{value:r.sessionPolicy,onChange:t=>x("sessionPolicy",t),options:Mt.map(t=>({value:t.value,label:a(t.label)}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("队列")}),e.jsx(R,{value:r.queueManagementPolicy,onChange:t=>x("queueManagementPolicy",t),options:_t.map(t=>({value:t.value,label:a(t.label)}))})]})]})]})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[e.jsx("span",{className:"text-[12px] text-neutral-400",children:a("{count} 个成员预设",{count:u.length})}),e.jsxs(p,{size:"sm",variant:"outline",onClick:Ie,children:[e.jsx(O,{size:13})," ",a("新增预设")]})]}),k?e.jsx(W,{title:a("加载失败"),error:be,isFetching:he,onRetry:()=>{ge()}}):u.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-neutral-200 bg-neutral-50/50 py-16 text-center",children:[e.jsx("p",{className:"text-sm text-neutral-400",children:a("暂无成员预设")}),e.jsxs(p,{size:"sm",className:"mt-3",onClick:Ie,children:[e.jsx(O,{size:13,className:"mr-1"})," ",a("新增预设")]})]}):e.jsx("div",{className:"grid gap-3 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",children:u.map(t=>{const s=Fe(t.capabilities);return e.jsxs("button",{type:"button",onClick:()=>mt(t),className:"flex items-start gap-3 rounded-xl border border-neutral-200 bg-white p-4 text-left transition-all hover:border-neutral-300 hover:shadow-sm",children:[e.jsx(U,{name:t.name,avatar:t.avatar,className:"h-10 w-10 text-xs shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13px] font-semibold text-neutral-900",children:t.name}),t.aliases.length>0&&e.jsx("div",{className:"truncate text-[11px] text-neutral-400 mt-0.5",children:t.aliases.join(", ")}),e.jsx("div",{className:"truncate text-[11px] text-neutral-500 mt-1",children:Ge.get(t.providerId)??t.providerId}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-2",children:[e.jsx("span",{className:"rounded bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-600",children:a(_e.find(n=>n.value===t.workspacePolicy)?.label??t.workspacePolicy)}),e.jsxs("span",{className:"rounded bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-600",children:[s,"/10 ",a("能力")]})]})]})]},t.id)})})]}):ke?e.jsxs("div",{className:"rounded-xl border border-neutral-200 bg-white",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-100 px-5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:L,className:"flex items-center gap-1.5 text-xs text-neutral-500 hover:text-neutral-900 transition-colors",children:[e.jsx(Me,{size:14}),a("返回")]}),e.jsx("span",{className:"text-neutral-200",children:"|"}),e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900",children:I==="create"?a("创建新模板"):ce?.name??a("编辑模板")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[I==="edit"&&ce&&e.jsx("button",{onClick:()=>le(ce),className:"flex h-7 w-7 items-center justify-center rounded-md text-neutral-400 hover:text-red-500 hover:bg-red-50 transition-colors",title:a("删除"),children:e.jsx(ue,{size:14})}),e.jsx(p,{size:"sm",onClick:et,disabled:!rt,children:J.isPending||K.isPending?a("保存中..."):a(I==="create"?"创建":"保存")})]})]}),e.jsxs("div",{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("模板名称")}),e.jsx("input",{value:y.name,onChange:t=>Je("name",t.target.value),className:"w-full rounded-lg border border-neutral-200 bg-white px-3 py-2 text-sm transition-colors focus:border-neutral-400 focus:outline-none"})]}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-2",children:a("可用预设")}),e.jsx("div",{className:"max-h-[400px] space-y-1 overflow-y-auto scrollbar-app-thin",children:k?e.jsx(W,{title:a("加载失败"),error:be,isFetching:he,onRetry:()=>{ge()}}):u.length===0?e.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 p-3 text-center text-[12px] text-neutral-400",children:a("先创建成员预设")}):u.map(t=>{const s=y.memberPresetIds.filter(n=>n===t.id).length;return e.jsxs("button",{type:"button",onClick:()=>ct(t.id),className:B("flex w-full items-center gap-2.5 rounded-lg border px-3 py-2 text-left transition-all",s>0?"border-neutral-900 bg-neutral-50":"border-neutral-200 bg-white hover:border-neutral-300"),children:[e.jsx(U,{name:t.name,avatar:t.avatar,className:"h-7 w-7 text-[10px] shrink-0"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:"truncate text-[12px] font-medium text-neutral-900",children:t.name})}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s>0&&e.jsxs("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:["x",s]}),e.jsx(O,{size:13,className:"text-neutral-400"})]})]},t.id)})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-2",children:a("已选成员")}),e.jsx("div",{className:"max-h-[400px] space-y-1 overflow-y-auto scrollbar-app-thin",children:de.length===0?e.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 p-3 text-center text-[12px] text-neutral-400",children:a("尚未选择")}):de.map((t,s)=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg border border-neutral-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(U,{name:t.name,avatar:t.avatar,className:"h-7 w-7 text-[10px] shrink-0"}),e.jsx("span",{className:"truncate text-[12px] font-medium text-neutral-900",children:Ft(t.name,s,y.memberPresetIds,t.id)})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e.jsx(p,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>Ce(s,-1),disabled:s===0,children:e.jsx(wt,{size:13})}),e.jsx(p,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>Ce(s,1),disabled:s===de.length-1,children:e.jsx(Tt,{size:13})}),e.jsx(p,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>dt(s),children:e.jsx(ue,{size:13})})]})]},`${t.id}-${s}`))})]})]})]})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[e.jsx("span",{className:"text-[12px] text-neutral-400",children:a("{count} 个团队模板",{count:h.length})}),e.jsxs(p,{size:"sm",variant:"outline",onClick:Se,children:[e.jsx(O,{size:13})," ",a("新增模板")]})]}),D?e.jsx(W,{title:a("加载失败"),error:Be,isFetching:Ue,onRetry:()=>{Ye()}}):h.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-neutral-200 bg-neutral-50/50 py-16 text-center",children:[e.jsx("p",{className:"text-sm text-neutral-400",children:a("暂无团队模板")}),e.jsxs(p,{size:"sm",className:"mt-3",onClick:Se,children:[e.jsx(O,{size:13,className:"mr-1"})," ",a("新增模板")]})]}):e.jsx("div",{className:"grid gap-3 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",children:h.map(t=>{const s=t.members?.length??0,n=(t.members??[]).slice(0,3).map(w=>$.get(w.memberPresetId)?.name).filter(Boolean);return e.jsxs("button",{type:"button",onClick:()=>ut(t),className:"flex flex-col rounded-xl border border-neutral-200 bg-white p-4 text-left transition-all hover:border-neutral-300 hover:shadow-sm",children:[e.jsx("div",{className:"truncate text-[13px] font-semibold text-neutral-900",children:t.name}),e.jsx("div",{className:"text-[11px] text-neutral-400 mt-1",children:a("{count} 个成员",{count:s})}),n.length>0&&e.jsxs("div",{className:"truncate text-[11px] text-neutral-500 mt-1.5",children:[n.join(", "),s>3?` +${s-3}`:""]})]},t.id)})})]}),e.jsx(Ee,{isOpen:!!j,onClose:()=>ae(null),onConfirm:Ze,title:a("删除"),description:j?a('确定删除 "{name}"?此操作不可撤销。',{name:j.name}):"",variant:"danger",confirmText:a("删除"),cancelText:a("取消"),isLoading:ve.isPending}),e.jsx(Nt,{isOpen:qe,onClose:()=>se(!1),title:a("选择预设头像"),className:"max-w-2xl",children:e.jsx("div",{className:"grid grid-cols-4 gap-2 sm:grid-cols-5",children:kt.map(t=>{const s=r.avatar===t.src;return e.jsxs("button",{type:"button",onClick:()=>Qe(t.src),className:B("group rounded-xl border bg-white p-2 text-center transition-all hover:border-neutral-400 hover:bg-neutral-50 focus:outline-none focus:ring-2 focus:ring-neutral-900/15",s?"border-neutral-900 ring-2 ring-neutral-900/10":"border-neutral-200"),"aria-pressed":s,"aria-label":a("选择 {name} 头像",{name:t.label}),children:[e.jsx("img",{src:t.src,alt:t.label,loading:"lazy",className:"mx-auto h-14 w-14 rounded-full object-cover sm:h-16 sm:w-16"}),e.jsx("span",{className:"mt-1 block truncate text-[10px] font-medium text-neutral-500",children:t.label})]},t.id)})})}),e.jsx(Ee,{isOpen:!!P,onClose:()=>le(null),onConfirm:tt,title:a("删除"),description:P?a('确定删除 "{name}"?此操作不可撤销。',{name:P.name}):"",variant:"danger",confirmText:a("删除"),cancelText:a("取消"),isLoading:fe.isPending})]})}export{Jt as TeamSettingsPage};
|
|
1
|
+
import{u as $e,k as pt,l as bt,m as ht,n as gt,o as vt,p as ft,s as jt,v as yt,r as i,j as e,d as B,t as d}from"./index-RxbHMWXV.js";import{B as p}from"./button-BUA8P726.js";import{C as Ee}from"./confirm-dialog-B_wk_zqm.js";import{T as ue,P as O,M as Nt}from"./modal-UGrjU63G.js";import{S as R}from"./select-BMlH2AuL.js";import{M as U}from"./MemberAvatar-BDXmryjB.js";import{u as Pt}from"./use-providers-DVP6emIi.js";import{S as Ae}from"./SettingsSection-pLJ3msrT.js";import{A as Me}from"./arrow-left-lFz8nyZM.js";import{C as wt}from"./chevron-up-BEHjZ-SB.js";import{C as Tt}from"./chevron-down-B931AgE2.js";import"./check-BYuuXc71.js";const l="/avatars/presets",kt=[{id:"developer",label:"Developer",src:`${l}/avatar-preset-01-developer.png`},{id:"architect",label:"Architect",src:`${l}/avatar-preset-02-architect.png`},{id:"tester",label:"Tester",src:`${l}/avatar-preset-03-tester.png`},{id:"devops",label:"DevOps",src:`${l}/avatar-preset-04-devops.png`},{id:"data-scientist",label:"Data scientist",src:`${l}/avatar-preset-05-data-scientist.png`},{id:"frontend",label:"Frontend",src:`${l}/avatar-preset-06-frontend.png`},{id:"backend",label:"Backend",src:`${l}/avatar-preset-07-backend.png`},{id:"security",label:"Security",src:`${l}/avatar-preset-08-security.png`},{id:"project-manager",label:"Project manager",src:`${l}/avatar-preset-09-project-manager.png`},{id:"product-manager",label:"Product manager",src:`${l}/avatar-preset-10-product-manager.png`},{id:"scrum-master",label:"Scrum master",src:`${l}/avatar-preset-11-scrum-master.png`},{id:"tech-lead",label:"Tech lead",src:`${l}/avatar-preset-12-tech-lead.png`},{id:"coordinator",label:"Coordinator",src:`${l}/avatar-preset-13-coordinator.png`},{id:"mentor",label:"Mentor",src:`${l}/avatar-preset-14-mentor.png`},{id:"reviewer",label:"Reviewer",src:`${l}/avatar-preset-15-reviewer.png`},{id:"ui-designer",label:"UI designer",src:`${l}/avatar-preset-16-ui-designer.png`},{id:"ux-researcher",label:"UX researcher",src:`${l}/avatar-preset-17-ux-researcher.png`},{id:"documenter",label:"Documenter",src:`${l}/avatar-preset-18-documenter.png`},{id:"translator",label:"Translator",src:`${l}/avatar-preset-19-translator.png`},{id:"analyst",label:"Analyst",src:`${l}/avatar-preset-20-analyst.png`},{id:"consultant",label:"Consultant",src:`${l}/avatar-preset-21-consultant.png`},{id:"creative-director",label:"Creative director",src:`${l}/avatar-preset-22-creative-director.png`},{id:"support",label:"Support",src:`${l}/avatar-preset-23-support.png`},{id:"assistant",label:"Assistant",src:`${l}/avatar-preset-24-assistant.png`},{id:"robot",label:"Robot",src:`${l}/avatar-preset-25-robot.png`}],Oe="/api",Ct=2*1024*1024,It=[],St=[],Et=[],Re=[{key:"readRoom",label:"读房间"},{key:"postRoomMessage",label:"发房间消息"},{key:"mentionMembers",label:"提及成员"},{key:"stopMemberWork",label:"停止成员工作"},{key:"markReadyForReview",label:"标记可审查"},{key:"readFiles",label:"读文件"},{key:"writeFiles",label:"写文件"},{key:"runCommands",label:"运行命令"},{key:"readDiff",label:"读 diff"},{key:"mergeWorkspace",label:"合并工作区"}],De={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},_e=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],At=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],Mt=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],_t=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function Y(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...De},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function xe(a){return{name:a.name,aliasesText:a.aliases.join(", "),providerId:a.providerId,rolePrompt:a.rolePrompt,capabilities:{...De,...a.capabilities},workspacePolicy:a.workspacePolicy,triggerPolicy:a.triggerPolicy,sessionPolicy:a.sessionPolicy,queueManagementPolicy:a.queueManagementPolicy,avatar:a.avatar??""}}function q(){return{name:"",memberPresetIds:[]}}function pe(a){return{name:a.name,memberPresetIds:a.members?.map(o=>o.memberPresetId)??[]}}function Ft(a,o,c,m){if(c.filter(M=>M===m).length<=1)return a;const G=c.slice(0,o+1).filter(M=>M===m).length;return`${a} #${G}`}function $t(a){return Array.from(new Set(a.split(/[\n,]/).map(o=>o.trim()).filter(Boolean)))}function Ot(a){return a.trim()||null}function Fe(a){return Re.reduce((o,c)=>o+(a[c.key]?1:0),0)}function A(a,o){return a instanceof Error?a.message:o}function Rt(a){return["image/png","image/jpeg","image/webp"].includes(a.type)}async function Dt(a){const o=new FormData;o.append("file",a);const c=await fetch(`${Oe}/attachments/upload`,{method:"POST",body:o});if(!c.ok){const m=await c.json().catch(()=>({}));throw new Error(m.error||m.message||`Upload failed (${c.status})`)}return c.json()}function W({title:a,error:o,isFetching:c,onRetry:m}){const{t:T}=$e();return e.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium",children:a}),e.jsx("div",{className:"mt-1 text-xs text-red-600",children:A(o,T("请稍后重试。"))})]}),e.jsx(p,{type:"button",size:"sm",variant:"outline",onClick:m,disabled:c,children:T(c?"加载中...":"重试")})]})})}function Jt(){const{t:a}=$e(),{data:o,error:c,isError:m,isFetching:T,isLoading:G,refetch:M}=Pt(),{data:ze,error:be,isError:k,isFetching:he,isLoading:V,refetch:ge}=pt(),{data:Le,error:Be,isError:D,isFetching:Ue,isLoading:Q,refetch:Ye}=bt(),X=ht(),H=gt(),ve=vt(),J=ft(),K=jt(),fe=yt(),[Z,je]=i.useState("presets"),[C,ee]=i.useState("edit"),[g,te]=i.useState(null),[r,f]=i.useState(Y()),[ye,_]=i.useState(!1),[j,ae]=i.useState(null),[qe,se]=i.useState(!1),[Ne,Pe]=i.useState(!1),we=i.useRef(null),[I,re]=i.useState("edit"),[v,ne]=i.useState(null),[y,b]=i.useState(q()),[Te,N]=i.useState(!1),[P,le]=i.useState(null),[ke,F]=i.useState(!1),u=ze??It,h=Le??St,z=o??Et,$=i.useMemo(()=>new Map(u.map(t=>[t.id,t])),[u]),ie=i.useMemo(()=>new Map(h.map(t=>[t.id,t])),[h]),We=i.useMemo(()=>{const t=z.map(({provider:s,availability:n})=>({value:s.id,label:s.name+(n.type==="NOT_FOUND"?a(" (不可用)"):""),disabled:n.type==="NOT_FOUND"}));return r.providerId&&!t.some(s=>s.value===r.providerId)&&t.unshift({value:r.providerId,label:`${r.providerId}${a(" (不可用)")}`,disabled:!0}),t},[r.providerId,z,a]),oe=g?$.get(g)??null:null,ce=v?ie.get(v)??null:null,Ge=i.useMemo(()=>new Map(z.map(({provider:t,availability:s})=>[t.id,t.name+(s.type==="NOT_FOUND"?a(" (不可用)"):"")])),[z,a]);if(i.useEffect(()=>{if(!(V||k||ye)){if(C==="create"){f(Y());return}if(g){const t=$.get(g);t&&f(xe(t));return}if(u.length>0){const t=u[0];te(t.id),ee("edit"),f(xe(t));return}ee("create"),te(null),f(Y())}},[$,ye,C,u,k,V,g]),i.useEffect(()=>{if(!(Q||D||Te)){if(I==="create"){b(q());return}if(v){const t=ie.get(v);t&&b(pe(t));return}if(h.length>0){const t=h[0];ne(t.id),re("edit"),b(pe(t));return}re("create"),ne(null),b(q())}},[v,ie,Te,I,h,D,Q]),G||V||Q)return e.jsx(Ae,{className:"max-w-6xl",children:e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-neutral-200 border-t-neutral-600"})})});const x=(t,s)=>{f(n=>({...n,[t]:s})),_(!0)},Ve=(t,s)=>{f(n=>({...n,capabilities:{...n.capabilities,[t]:s}})),_(!0)},Qe=t=>{x("avatar",t),se(!1)},Xe=()=>{x("avatar","")},He=async t=>{const s=t.target.files?.[0];if(t.target.value="",!!s){if(!Rt(s)){d.error(a("仅支持 PNG、JPG、WebP 头像。"));return}if(s.size>Ct){d.error(a("头像图片不能超过 2MB。"));return}Pe(!0);try{const n=await Dt(s);x("avatar",`${Oe}${n.url}`),d.success(a("头像已上传"))}catch(n){d.error(A(n,a("头像上传失败")))}finally{Pe(!1)}}},S=(t,s)=>{ee(t),te(s?.id??null),f(s?xe(s):Y()),_(!1)},Je=(t,s)=>{b(n=>({...n,[t]:s})),N(!0)},E=(t,s)=>{re(t),ne(s?.id??null),b(s?pe(s):q()),N(!1)},Ke=async()=>{const t={name:r.name.trim(),aliases:$t(r.aliasesText),providerId:r.providerId.trim(),rolePrompt:r.rolePrompt.trim(),capabilities:{...r.capabilities},workspacePolicy:r.workspacePolicy,triggerPolicy:r.triggerPolicy,sessionPolicy:r.sessionPolicy,queueManagementPolicy:r.queueManagementPolicy,avatar:Ot(r.avatar)};try{if(C==="create"||!g){const s=await X.mutateAsync(t);S("edit",s),d.success(a("已创建"))}else{const s=await H.mutateAsync({id:g,data:t});S("edit",s),d.success(a("已保存"))}}catch(s){d.error(A(s,a("保存失败")))}},Ze=async()=>{if(j)try{await ve.mutateAsync(j.id),d.success(a("Deleted"));const t=u.filter(s=>s.id!==j.id);g===j.id&&(t.length>0?S("edit",t[0]):S("create",null)),ae(null)}catch(t){d.error(A(t,a("删除失败")))}},et=async()=>{const t={name:y.name.trim(),memberPresetIds:y.memberPresetIds};try{if(I==="create"||!v){const s=await J.mutateAsync(t);E("edit",s),d.success(a("已创建"))}else{const s=await K.mutateAsync({id:v,data:t});E("edit",s),d.success(a("已保存"))}}catch(s){d.error(A(s,a("保存失败")))}},tt=async()=>{if(P)try{await fe.mutateAsync(P.id),d.success(a("Deleted"));const t=h.filter(s=>s.id!==P.id);v===P.id&&(t.length>0?E("edit",t[0]):E("create",null)),le(null)}catch(t){d.error(A(t,a("删除失败")))}},at=Fe(r.capabilities),st=!!r.name.trim()&&!!r.providerId.trim()&&!!r.rolePrompt.trim()&&!m&&!k&&!X.isPending&&!H.isPending,rt=!!y.name.trim()&&!D&&!k&&!J.isPending&&!K.isPending,de=y.memberPresetIds.map(t=>$.get(t)).filter(t=>!!t),nt=t=>{_(!1),S("edit",t)},lt=()=>{_(!1),S("create",null)},it=t=>{N(!1),E("edit",t)},ot=()=>{N(!1),E("create",null)},ct=t=>{b(s=>({...s,memberPresetIds:[...s.memberPresetIds,t]})),N(!0)},dt=t=>{b(s=>({...s,memberPresetIds:s.memberPresetIds.filter((n,w)=>w!==t)})),N(!0)},Ce=(t,s)=>{b(n=>{const w=t+s;if(w<0||w>=n.memberPresetIds.length)return n;const me=[...n.memberPresetIds],[xt]=me.splice(t,1);return me.splice(w,0,xt),{...n,memberPresetIds:me}}),N(!0)},mt=t=>{nt(t),F(!0)},Ie=()=>{lt(),F(!0)},ut=t=>{it(t),F(!0)},Se=()=>{ot(),F(!0)},L=()=>F(!1);return e.jsxs(Ae,{className:"max-w-6xl",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 mb-5",children:[e.jsx("h2",{className:"text-base font-semibold text-neutral-900",children:a("团队协作设置")}),e.jsxs("div",{className:"inline-flex rounded-lg border border-neutral-200 bg-neutral-50/80 p-0.5",children:[e.jsx("button",{type:"button",onClick:()=>{je("presets"),L()},className:B("rounded-md px-3 py-1.5 text-[12px] font-medium transition-all",Z==="presets"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:a("成员预设")}),e.jsx("button",{type:"button",onClick:()=>{je("templates"),L()},className:B("rounded-md px-3 py-1.5 text-[12px] font-medium transition-all",Z==="templates"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:a("团队模板")})]})]}),m&&e.jsx(W,{title:a("Provider 列表加载失败"),error:c,isFetching:T,onRetry:()=>{M()}}),Z==="presets"?ke?e.jsxs("div",{className:"rounded-xl border border-neutral-200 bg-white",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-100 px-5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:L,className:"flex items-center gap-1.5 text-xs text-neutral-500 hover:text-neutral-900 transition-colors",children:[e.jsx(Me,{size:14}),a("返回")]}),e.jsx("span",{className:"text-neutral-200",children:"|"}),e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900",children:C==="create"?a("创建新预设"):oe?.name??a("编辑预设")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[C==="edit"&&oe&&e.jsx("button",{onClick:()=>ae(oe),className:"flex h-7 w-7 items-center justify-center rounded-md text-neutral-400 hover:text-red-500 hover:bg-red-50 transition-colors",title:a("删除"),children:e.jsx(ue,{size:14})}),e.jsx(p,{size:"sm",onClick:Ke,disabled:!st,children:X.isPending||H.isPending?a("保存中..."):a(C==="create"?"创建":"保存")})]})]}),e.jsxs("div",{className:"p-5 space-y-5",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("div",{className:"shrink-0",children:[e.jsx(U,{name:r.name||a("Agent"),avatar:r.avatar,className:"h-14 w-14 text-sm"}),e.jsxs("div",{className:"flex justify-center gap-1 mt-2",children:[e.jsx("button",{type:"button",onClick:()=>se(!0),className:"text-[10px] text-neutral-400 hover:text-neutral-700 transition-colors",children:a("选择")}),e.jsx("span",{className:"text-[10px] text-neutral-300",children:"·"}),e.jsx("button",{type:"button",onClick:()=>we.current?.click(),disabled:Ne,className:"text-[10px] text-neutral-400 hover:text-neutral-700 transition-colors",children:a(Ne?"...":"上传")}),r.avatar.trim()&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[10px] text-neutral-300",children:"·"}),e.jsx("button",{type:"button",onClick:Xe,className:"text-[10px] text-neutral-400 hover:text-red-500 transition-colors",children:a("清除")})]})]}),e.jsx("input",{ref:we,type:"file",accept:"image/png,image/jpeg,image/webp",className:"hidden",onChange:He})]}),e.jsxs("div",{className:"flex-1 min-w-0 grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("名称")}),e.jsx("input",{value:r.name,onChange:t=>x("name",t.target.value),className:"w-full rounded-lg border border-neutral-200 bg-white px-3 py-2 text-sm transition-colors focus:border-neutral-400 focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("别名")}),e.jsx("input",{value:r.aliasesText,onChange:t=>x("aliasesText",t.target.value),placeholder:a("alice, a, reviewer"),className:"w-full rounded-lg border border-neutral-200 bg-white px-3 py-2 text-sm transition-colors focus:border-neutral-400 focus:outline-none"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("Provider")}),e.jsx(R,{value:r.providerId,onChange:t=>x("providerId",t),options:We,disabled:m}),m&&e.jsx("p",{className:"mt-1 text-[11px] text-red-500",children:a("Provider 列表加载失败。")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("角色提示词")}),e.jsx("textarea",{value:r.rolePrompt,onChange:t=>x("rolePrompt",t.target.value),rows:4,className:"w-full rounded-lg border border-neutral-200 bg-neutral-50/50 px-3 py-2 text-sm font-mono transition-colors focus:border-neutral-400 focus:bg-white focus:outline-none resize-y"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-end justify-between gap-3 mb-2",children:[e.jsx("label",{className:"text-[12px] font-medium text-neutral-600",children:a("可用能力")}),e.jsxs("span",{className:"text-[11px] text-neutral-400",children:[at,"/10"]})]}),e.jsx("div",{className:"grid gap-1 sm:grid-cols-2 xl:grid-cols-3",children:Re.map(t=>e.jsxs("label",{className:"flex items-center gap-2 rounded px-2.5 py-1.5 text-[12px] text-neutral-700 hover:bg-neutral-50 transition-colors cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r.capabilities[t.key],onChange:s=>Ve(t.key,s.target.checked),className:"h-3.5 w-3.5 rounded border-neutral-300"}),e.jsx("span",{children:a(t.label)})]},t.key))})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("工作区")}),e.jsx(R,{value:r.workspacePolicy,onChange:t=>x("workspacePolicy",t),options:_e.map(t=>({value:t.value,label:a(t.label)}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("触发")}),e.jsx(R,{value:r.triggerPolicy,onChange:t=>x("triggerPolicy",t),options:At.map(t=>({value:t.value,label:a(t.label)}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("会话")}),e.jsx(R,{value:r.sessionPolicy,onChange:t=>x("sessionPolicy",t),options:Mt.map(t=>({value:t.value,label:a(t.label)}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("队列")}),e.jsx(R,{value:r.queueManagementPolicy,onChange:t=>x("queueManagementPolicy",t),options:_t.map(t=>({value:t.value,label:a(t.label)}))})]})]})]})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[e.jsx("span",{className:"text-[12px] text-neutral-400",children:a("{count} 个成员预设",{count:u.length})}),e.jsxs(p,{size:"sm",variant:"outline",onClick:Ie,children:[e.jsx(O,{size:13})," ",a("新增预设")]})]}),k?e.jsx(W,{title:a("加载失败"),error:be,isFetching:he,onRetry:()=>{ge()}}):u.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-neutral-200 bg-neutral-50/50 py-16 text-center",children:[e.jsx("p",{className:"text-sm text-neutral-400",children:a("暂无成员预设")}),e.jsxs(p,{size:"sm",className:"mt-3",onClick:Ie,children:[e.jsx(O,{size:13,className:"mr-1"})," ",a("新增预设")]})]}):e.jsx("div",{className:"grid gap-3 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",children:u.map(t=>{const s=Fe(t.capabilities);return e.jsxs("button",{type:"button",onClick:()=>mt(t),className:"flex items-start gap-3 rounded-xl border border-neutral-200 bg-white p-4 text-left transition-all hover:border-neutral-300 hover:shadow-sm",children:[e.jsx(U,{name:t.name,avatar:t.avatar,className:"h-10 w-10 text-xs shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13px] font-semibold text-neutral-900",children:t.name}),t.aliases.length>0&&e.jsx("div",{className:"truncate text-[11px] text-neutral-400 mt-0.5",children:t.aliases.join(", ")}),e.jsx("div",{className:"truncate text-[11px] text-neutral-500 mt-1",children:Ge.get(t.providerId)??t.providerId}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-2",children:[e.jsx("span",{className:"rounded bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-600",children:a(_e.find(n=>n.value===t.workspacePolicy)?.label??t.workspacePolicy)}),e.jsxs("span",{className:"rounded bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-600",children:[s,"/10 ",a("能力")]})]})]})]},t.id)})})]}):ke?e.jsxs("div",{className:"rounded-xl border border-neutral-200 bg-white",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-100 px-5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:L,className:"flex items-center gap-1.5 text-xs text-neutral-500 hover:text-neutral-900 transition-colors",children:[e.jsx(Me,{size:14}),a("返回")]}),e.jsx("span",{className:"text-neutral-200",children:"|"}),e.jsx("h3",{className:"text-[13px] font-semibold text-neutral-900",children:I==="create"?a("创建新模板"):ce?.name??a("编辑模板")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[I==="edit"&&ce&&e.jsx("button",{onClick:()=>le(ce),className:"flex h-7 w-7 items-center justify-center rounded-md text-neutral-400 hover:text-red-500 hover:bg-red-50 transition-colors",title:a("删除"),children:e.jsx(ue,{size:14})}),e.jsx(p,{size:"sm",onClick:et,disabled:!rt,children:J.isPending||K.isPending?a("保存中..."):a(I==="create"?"创建":"保存")})]})]}),e.jsxs("div",{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-1",children:a("模板名称")}),e.jsx("input",{value:y.name,onChange:t=>Je("name",t.target.value),className:"w-full rounded-lg border border-neutral-200 bg-white px-3 py-2 text-sm transition-colors focus:border-neutral-400 focus:outline-none"})]}),e.jsxs("div",{className:"grid gap-4 xl:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-2",children:a("可用预设")}),e.jsx("div",{className:"max-h-[400px] space-y-1 overflow-y-auto scrollbar-app-thin",children:k?e.jsx(W,{title:a("加载失败"),error:be,isFetching:he,onRetry:()=>{ge()}}):u.length===0?e.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 p-3 text-center text-[12px] text-neutral-400",children:a("先创建成员预设")}):u.map(t=>{const s=y.memberPresetIds.filter(n=>n===t.id).length;return e.jsxs("button",{type:"button",onClick:()=>ct(t.id),className:B("flex w-full items-center gap-2.5 rounded-lg border px-3 py-2 text-left transition-all",s>0?"border-neutral-900 bg-neutral-50":"border-neutral-200 bg-white hover:border-neutral-300"),children:[e.jsx(U,{name:t.name,avatar:t.avatar,className:"h-7 w-7 text-[10px] shrink-0"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:"truncate text-[12px] font-medium text-neutral-900",children:t.name})}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s>0&&e.jsxs("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:["x",s]}),e.jsx(O,{size:13,className:"text-neutral-400"})]})]},t.id)})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[12px] font-medium text-neutral-600 mb-2",children:a("已选成员")}),e.jsx("div",{className:"max-h-[400px] space-y-1 overflow-y-auto scrollbar-app-thin",children:de.length===0?e.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 p-3 text-center text-[12px] text-neutral-400",children:a("尚未选择")}):de.map((t,s)=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-lg border border-neutral-200 bg-white px-3 py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(U,{name:t.name,avatar:t.avatar,className:"h-7 w-7 text-[10px] shrink-0"}),e.jsx("span",{className:"truncate text-[12px] font-medium text-neutral-900",children:Ft(t.name,s,y.memberPresetIds,t.id)})]}),e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e.jsx(p,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>Ce(s,-1),disabled:s===0,children:e.jsx(wt,{size:13})}),e.jsx(p,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>Ce(s,1),disabled:s===de.length-1,children:e.jsx(Tt,{size:13})}),e.jsx(p,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>dt(s),children:e.jsx(ue,{size:13})})]})]},`${t.id}-${s}`))})]})]})]})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[e.jsx("span",{className:"text-[12px] text-neutral-400",children:a("{count} 个团队模板",{count:h.length})}),e.jsxs(p,{size:"sm",variant:"outline",onClick:Se,children:[e.jsx(O,{size:13})," ",a("新增模板")]})]}),D?e.jsx(W,{title:a("加载失败"),error:Be,isFetching:Ue,onRetry:()=>{Ye()}}):h.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-neutral-200 bg-neutral-50/50 py-16 text-center",children:[e.jsx("p",{className:"text-sm text-neutral-400",children:a("暂无团队模板")}),e.jsxs(p,{size:"sm",className:"mt-3",onClick:Se,children:[e.jsx(O,{size:13,className:"mr-1"})," ",a("新增模板")]})]}):e.jsx("div",{className:"grid gap-3 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",children:h.map(t=>{const s=t.members?.length??0,n=(t.members??[]).slice(0,3).map(w=>$.get(w.memberPresetId)?.name).filter(Boolean);return e.jsxs("button",{type:"button",onClick:()=>ut(t),className:"flex flex-col rounded-xl border border-neutral-200 bg-white p-4 text-left transition-all hover:border-neutral-300 hover:shadow-sm",children:[e.jsx("div",{className:"truncate text-[13px] font-semibold text-neutral-900",children:t.name}),e.jsx("div",{className:"text-[11px] text-neutral-400 mt-1",children:a("{count} 个成员",{count:s})}),n.length>0&&e.jsxs("div",{className:"truncate text-[11px] text-neutral-500 mt-1.5",children:[n.join(", "),s>3?` +${s-3}`:""]})]},t.id)})})]}),e.jsx(Ee,{isOpen:!!j,onClose:()=>ae(null),onConfirm:Ze,title:a("删除"),description:j?a('确定删除 "{name}"?此操作不可撤销。',{name:j.name}):"",variant:"danger",confirmText:a("删除"),cancelText:a("取消"),isLoading:ve.isPending}),e.jsx(Nt,{isOpen:qe,onClose:()=>se(!1),title:a("选择预设头像"),className:"max-w-2xl",children:e.jsx("div",{className:"grid grid-cols-4 gap-2 sm:grid-cols-5",children:kt.map(t=>{const s=r.avatar===t.src;return e.jsxs("button",{type:"button",onClick:()=>Qe(t.src),className:B("group rounded-xl border bg-white p-2 text-center transition-all hover:border-neutral-400 hover:bg-neutral-50 focus:outline-none focus:ring-2 focus:ring-neutral-900/15",s?"border-neutral-900 ring-2 ring-neutral-900/10":"border-neutral-200"),"aria-pressed":s,"aria-label":a("选择 {name} 头像",{name:t.label}),children:[e.jsx("img",{src:t.src,alt:t.label,loading:"lazy",className:"mx-auto h-14 w-14 rounded-full object-cover sm:h-16 sm:w-16"}),e.jsx("span",{className:"mt-1 block truncate text-[10px] font-medium text-neutral-500",children:t.label})]},t.id)})})}),e.jsx(Ee,{isOpen:!!P,onClose:()=>le(null),onConfirm:tt,title:a("删除"),description:P?a('确定删除 "{name}"?此操作不可撤销。',{name:P.name}):"",variant:"danger",confirmText:a("删除"),cancelText:a("取消"),isLoading:fe.isPending})]})}export{Jt as TeamSettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e}from"./index-
|
|
1
|
+
import{e}from"./index-RxbHMWXV.js";const o=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],r=e("arrow-left",o);export{r as A};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as V,r as a,j as p,d as k}from"./index-
|
|
1
|
+
import{D as V,r as a,j as p,d as k}from"./index-RxbHMWXV.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 d=e?.[o],c=s?.[o];if(d===null)return null;const v=y(d)||y(c);return r[o][v]}),l=e&&Object.entries(e).reduce((o,d)=>{let[c,v]=d;return v===void 0||(o[c]=v),o},{}),f=n==null||(i=n.compoundVariants)===null||i===void 0?void 0:i.reduce((o,d)=>{let{class:c,className:v,...x}=d;return Object.entries(x).every(C=>{let[m,g]=C;return Array.isArray(g)?g.includes({...s,...l}[m]):{...s,...l}[m]===g})?[...o,c,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,d=l.map(c=>c===f?a.Children.count(o)>1?a.Children.only(null):a.isValidElement(o)?o.props.children:null:c);return p.jsx(n,{...u,ref:r,children:a.isValidElement(o)?a.cloneElement(o,void 0,d):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 W({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{W as B};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as c}from"./index-RxbHMWXV.js";const e=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],t=c("check",e);export{t as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as o}from"./index-
|
|
1
|
+
import{e as o}from"./index-RxbHMWXV.js";const e=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],c=o("chevron-down",e);export{c as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as o}from"./index-
|
|
1
|
+
import{e as o}from"./index-RxbHMWXV.js";const e=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],c=o("chevron-right",e);export{c as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as o}from"./index-
|
|
1
|
+
import{e as o}from"./index-RxbHMWXV.js";const e=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],n=o("chevron-up",e);export{n as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as c}from"./index-
|
|
1
|
+
import{e as c}from"./index-RxbHMWXV.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-fubZbKyF.js";import{r as i,j as a}from"./index-RxbHMWXV.js";import"./log-adapter-CtvxzS4j.js";import"./chevron-right-F9i4wey6.js";import"./chevron-down-B931AgE2.js";import"./check-BYuuXc71.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as m,j as e,d as u}from"./index-
|
|
1
|
+
import{u as m,j as e,d as u}from"./index-RxbHMWXV.js";import{M as h,a as b}from"./modal-UGrjU63G.js";const g=({isOpen:l,onClose:a,onConfirm:n,title:i,description:d,confirmText:c="确认",cancelText:o="取消",variant:x="default",isLoading:t=!1})=>{const{t:s}=m(),r=x==="danger";return e.jsx(h,{isOpen:l,onClose:a,title:i,className:"max-w-sm",action:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:a,disabled:t,className:"px-4 py-2 text-sm font-medium text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:s(o)}),e.jsx("button",{onClick:n,disabled:t,className:u("px-4 py-2 text-sm font-medium rounded-lg transition-colors disabled:opacity-50",r?"bg-red-500 text-white hover:bg-red-600":"bg-neutral-900 text-white hover:bg-black"),children:s(t?"处理中...":c)})]}),children:e.jsxs("div",{className:"flex gap-4",children:[r&&e.jsx("div",{className:"shrink-0 w-10 h-10 rounded-full bg-red-50 flex items-center justify-center",children:e.jsx(b,{size:20,className:"text-red-500"})}),e.jsx("div",{className:"text-sm text-neutral-600 leading-relaxed pt-1",children:d})]})})};export{g as C};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as V,f as A,g as j,h as y,q as i,i as p,u as O,r as n,j as e,d as x,F as Q}from"./index-
|
|
1
|
+
import{e as V,f as A,g as j,h as y,q as i,i as p,u as O,r as n,j as e,d as x,F as Q}from"./index-RxbHMWXV.js";import{C as P}from"./chevron-right-F9i4wey6.js";import{L as D,C as R}from"./loader-circle-stJcjnm-.js";import{C as T}from"./check-BYuuXc71.js";const X=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],ne=V("file",X);const Y=[["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"}]],v=V("folder",Y);function le(t){const a={};return t?.page!=null&&(a.page=String(t.page)),t?.limit!=null&&(a.limit=String(t.limit)),t?.includeArchived&&(a.includeArchived="true"),A({queryKey:i.projects.list(t),queryFn:()=>p.get("/projects",{params:a})})}function ie(t){return A({queryKey:i.projects.detail(t),queryFn:()=>p.get(`/projects/${t}`),enabled:!!t})}function oe(){const t=j();return y({mutationFn:a=>p.post("/projects",a),onSuccess:()=>{t.invalidateQueries({queryKey:i.projects.all})}})}function ce(){const t=j();return y({mutationFn:({id:a,...l})=>p.put(`/projects/${a}`,l),onSuccess:(a,l)=>{t.invalidateQueries({queryKey:i.projects.all}),t.invalidateQueries({queryKey:i.projects.detail(l.id)})}})}function ue(){const t=j();return y({mutationFn:({id:a,deleteRepo:l})=>p.post(`/projects/${a}/archive`,{deleteRepo:l??!1}),onSuccess:(a,l)=>{t.invalidateQueries({queryKey:i.projects.all}),t.invalidateQueries({queryKey:i.projects.detail(l.id)}),t.invalidateQueries({queryKey:i.tasks.all}),t.invalidateQueries({queryKey:i.workspaces.all})}})}function de(){const t=j();return y({mutationFn:({id:a,repoPath:l})=>p.post(`/projects/${a}/restore`,l?{repoPath:l}:{}),onSuccess:(a,l)=>{t.invalidateQueries({queryKey:i.projects.all}),t.invalidateQueries({queryKey:i.projects.detail(l.id)}),t.invalidateQueries({queryKey:i.tasks.all}),t.invalidateQueries({queryKey:i.workspaces.all})}})}function ee(t){return t.isGitRepo?"select-and-browse":"browse"}function pe({value:t,onChange:a,validationMode:l="git",placeholder:G}){const{t:g}=O(),[u,L]=n.useState(""),[N,_]=n.useState([]),[k,I]=n.useState(""),[$,B]=n.useState("/"),[C,U]=n.useState([]),[W,w]=n.useState(!1),[q,S]=n.useState(null),[b,K]=n.useState(t),[z,d]=n.useState(null),[Z,E]=n.useState(!1),F=n.useRef(!1);n.useEffect(()=>{K(t)},[t]);const o=n.useCallback(async s=>{w(!0),S(null);try{const r={};s&&(r.path=s);const c=await p.get("/filesystem/browse",{params:r});L(c.current),I(c.parent),B(c.sep||"/"),_(c.dirs),c.drives&&U(c.drives)}catch(r){S(r instanceof Error?r.message:"Failed to browse directory")}finally{w(!1)}},[]);n.useEffect(()=>{F.current||(F.current=!0,o())},[o]);const m=n.useCallback(async s=>{if(l==="directory"){a(s),d(null);return}E(!0),d(null);try{const r=await p.get("/filesystem/validate",{params:{path:s}});r.valid?(a(s),d(null)):d(r.error??"Not a Git repository")}catch(r){d(r instanceof Error?r.message:"Validation failed")}finally{E(!1)}},[a,l]),H=n.useCallback(s=>{ee(s)==="select-and-browse"?(m(s.path),o(s.path)):(o(s.path),d(null))},[m,o]),h=$==="\\",f=n.useMemo(()=>u?u.split(/[\\/]/).filter(Boolean):[],[u]),M=n.useCallback(s=>{const r=f.slice(0,s+1);let c;h?(c=r.join("\\"),r.length===1&&/^[A-Za-z]:$/.test(r[0])&&(c+="\\")):c="/"+r.join("/"),o(c),d(null)},[f,o,h]),J=n.useCallback(s=>{if(s.key==="Enter"&&!s.nativeEvent.isComposing&&s.nativeEvent.keyCode!==229){s.preventDefault();const r=b.trim();r&&(o(r),m(r))}},[b,o,m]);return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"text",value:b,onChange:s=>K(s.target.value),onKeyDown:J,placeholder:G??"e.g., /Users/me/projects/my-repo",className:x("w-full px-3 py-2 border rounded-lg text-sm font-mono focus:outline-none transition-colors pr-8",t?"border-emerald-300 bg-emerald-50/50 focus:border-emerald-400":"border-neutral-200 focus:border-neutral-400")}),t&&(l==="git"?e.jsx(Q,{size:14,className:"absolute right-3 top-1/2 -translate-y-1/2 text-emerald-500"}):e.jsx(v,{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:g(l==="git"?"Browse and select a Git repository, or type a path and press Enter":"Browse and select a directory, or type a path and press Enter")}),C.length>0&&e.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:C.map(s=>e.jsx("button",{onClick:()=>{o(s),d(null)},className:x("px-2 py-0.5 rounded text-xs font-mono transition-colors border",u.toUpperCase().startsWith(s.toUpperCase())?"bg-neutral-900 text-white border-neutral-900":"border-neutral-200 text-neutral-600 hover:bg-neutral-100"),children:s.replace("\\","")},s))}),e.jsxs("div",{className:"flex items-center gap-0.5 text-xs text-neutral-500 overflow-x-auto pb-1 scrollbar-none",children:[!h&&e.jsx("button",{onClick:()=>o("/"),className:"hover:text-neutral-900 transition-colors flex-shrink-0 px-1 py-0.5 rounded hover:bg-neutral-100",children:"/"}),f.map((s,r)=>e.jsxs("span",{className:"flex items-center gap-0.5 flex-shrink-0",children:[(h?r>0:!0)&&e.jsx(P,{size:10,className:"text-neutral-300"}),e.jsx("button",{onClick:()=>M(r),className:x("px-1 py-0.5 rounded transition-colors truncate max-w-[120px]",r===f.length-1?"font-medium text-neutral-900":"hover:text-neutral-900 hover:bg-neutral-100"),children:s})]},r))]}),e.jsx("div",{className:"border border-neutral-200 rounded-lg overflow-hidden",children:e.jsx("div",{className:"max-h-[200px] overflow-y-auto",children:W?e.jsxs("div",{className:"flex items-center justify-center py-8 text-neutral-400",children:[e.jsx(D,{size:16,className:"animate-spin mr-2"}),e.jsx("span",{className:"text-xs",children:"Loading..."})]}):q?e.jsxs("div",{className:"flex items-center justify-center py-8 text-red-500 gap-2",children:[e.jsx(R,{size:14}),e.jsx("span",{className:"text-xs",children:q})]}):N.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-8 text-neutral-400",children:[e.jsx("span",{className:"text-xs",children:"No subdirectories"}),l==="directory"&&u&&e.jsxs("button",{type:"button",onClick:()=>m(u),className:x("inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs font-medium transition-colors",u===t?"border-emerald-200 bg-emerald-50 text-emerald-700":"border-neutral-200 bg-white text-neutral-700 hover:bg-neutral-50"),children:[e.jsx(T,{size:13}),e.jsx("span",{children:g("Select Current")})]})]}):e.jsxs("ul",{className:"divide-y divide-neutral-100",children:[u!==k&&e.jsx("li",{children:e.jsxs("button",{onClick:()=>o(k),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(v,{size:14,className:"text-neutral-400 flex-shrink-0"}),e.jsx("span",{className:"text-xs text-neutral-500 group-hover:text-neutral-700",children:".."})]})}),N.map(s=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>H(s),className:x("w-full flex items-center gap-2.5 px-3 py-2 text-left transition-colors group",s.path===t?"bg-emerald-50":"hover:bg-neutral-50"),children:[s.isGitRepo?e.jsx(Q,{size:14,className:"text-emerald-500 flex-shrink-0"}):e.jsx(v,{size:14,className:"text-neutral-400 flex-shrink-0"}),e.jsx("span",{className:x("text-xs truncate",s.path===t?"font-medium text-emerald-700":"text-neutral-700 group-hover:text-neutral-900"),children:s.name}),s.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"}),!s.isGitRepo&&e.jsx(P,{size:12,className:"ml-auto text-neutral-300 group-hover:text-neutral-400 flex-shrink-0"})]})},s.path))]})})}),Z&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-400",children:[e.jsx(D,{size:12,className:"animate-spin"}),e.jsx("span",{children:"Validating..."})]}),z&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-red-500",children:[e.jsx(R,{size:12}),e.jsx("span",{children:z})]})]})}export{ne as F,v as a,ce as b,ue as c,de as d,pe as e,ie as f,oe as g,le as u};
|