agent-tower 0.5.2-beta.1 → 0.5.2-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/dist/app.d.ts.map +1 -1
  2. package/dist/app.js +9 -2
  3. package/dist/app.js.map +1 -1
  4. package/dist/app.test.js +67 -0
  5. package/dist/app.test.js.map +1 -1
  6. package/dist/cli.js +2 -0
  7. package/dist/cli.js.map +1 -1
  8. package/dist/core/container.d.ts +2 -0
  9. package/dist/core/container.d.ts.map +1 -1
  10. package/dist/core/container.js +9 -1
  11. package/dist/core/container.js.map +1 -1
  12. package/dist/core/event-bus.d.ts +2 -1
  13. package/dist/core/event-bus.d.ts.map +1 -1
  14. package/dist/core/event-bus.js.map +1 -1
  15. package/dist/executors/__tests__/base.executor.test.d.ts +2 -0
  16. package/dist/executors/__tests__/base.executor.test.d.ts.map +1 -0
  17. package/dist/executors/__tests__/base.executor.test.js +264 -0
  18. package/dist/executors/__tests__/base.executor.test.js.map +1 -0
  19. package/dist/executors/__tests__/codex.executor.test.js +18 -1
  20. package/dist/executors/__tests__/codex.executor.test.js.map +1 -1
  21. package/dist/executors/base.executor.d.ts.map +1 -1
  22. package/dist/executors/base.executor.js +61 -33
  23. package/dist/executors/base.executor.js.map +1 -1
  24. package/dist/executors/codex.executor.d.ts.map +1 -1
  25. package/dist/executors/codex.executor.js +3 -4
  26. package/dist/executors/codex.executor.js.map +1 -1
  27. package/dist/executors/execution-env.d.ts +7 -1
  28. package/dist/executors/execution-env.d.ts.map +1 -1
  29. package/dist/executors/execution-env.js +41 -2
  30. package/dist/executors/execution-env.js.map +1 -1
  31. package/dist/index.js +2 -0
  32. package/dist/index.js.map +1 -1
  33. package/dist/mcp/http-client.d.ts +8 -2
  34. package/dist/mcp/http-client.d.ts.map +1 -1
  35. package/dist/mcp/http-client.js +4 -4
  36. package/dist/mcp/http-client.js.map +1 -1
  37. package/dist/mcp/server.d.ts.map +1 -1
  38. package/dist/mcp/server.js +48 -5
  39. package/dist/mcp/server.js.map +1 -1
  40. package/dist/mcp/types.d.ts +6 -6
  41. package/dist/routes/__tests__/tasks.test.js +179 -0
  42. package/dist/routes/__tests__/tasks.test.js.map +1 -1
  43. package/dist/routes/git.d.ts.map +1 -1
  44. package/dist/routes/git.js +41 -1
  45. package/dist/routes/git.js.map +1 -1
  46. package/dist/routes/tasks.d.ts.map +1 -1
  47. package/dist/routes/tasks.js +10 -2
  48. package/dist/routes/tasks.js.map +1 -1
  49. package/dist/routes/team-runs.d.ts.map +1 -1
  50. package/dist/routes/team-runs.js +92 -2
  51. package/dist/routes/team-runs.js.map +1 -1
  52. package/dist/services/__tests__/project.service.test.js +85 -1
  53. package/dist/services/__tests__/project.service.test.js.map +1 -1
  54. package/dist/services/__tests__/session-manager.team-run.test.js +84 -1
  55. package/dist/services/__tests__/session-manager.team-run.test.js.map +1 -1
  56. package/dist/services/__tests__/task.service.test.js +190 -0
  57. package/dist/services/__tests__/task.service.test.js.map +1 -1
  58. package/dist/services/__tests__/team-reconciler.service.test.js +173 -5
  59. package/dist/services/__tests__/team-reconciler.service.test.js.map +1 -1
  60. package/dist/services/__tests__/team-run.service.test.js +162 -1
  61. package/dist/services/__tests__/team-run.service.test.js.map +1 -1
  62. package/dist/services/__tests__/team-scheduler.service.test.js +177 -5
  63. package/dist/services/__tests__/team-scheduler.service.test.js.map +1 -1
  64. package/dist/services/__tests__/workspace-git-watcher.service.test.d.ts +2 -0
  65. package/dist/services/__tests__/workspace-git-watcher.service.test.d.ts.map +1 -0
  66. package/dist/services/__tests__/workspace-git-watcher.service.test.js +148 -0
  67. package/dist/services/__tests__/workspace-git-watcher.service.test.js.map +1 -0
  68. package/dist/services/__tests__/workspace.service.test.js +43 -1
  69. package/dist/services/__tests__/workspace.service.test.js.map +1 -1
  70. package/dist/services/project.service.d.ts +28 -24
  71. package/dist/services/project.service.d.ts.map +1 -1
  72. package/dist/services/project.service.js +11 -0
  73. package/dist/services/project.service.js.map +1 -1
  74. package/dist/services/session-manager.d.ts +44 -43
  75. package/dist/services/session-manager.d.ts.map +1 -1
  76. package/dist/services/session-manager.js +30 -3
  77. package/dist/services/session-manager.js.map +1 -1
  78. package/dist/services/task-cleanup.service.d.ts +3 -1
  79. package/dist/services/task-cleanup.service.d.ts.map +1 -1
  80. package/dist/services/task-cleanup.service.js +6 -1
  81. package/dist/services/task-cleanup.service.js.map +1 -1
  82. package/dist/services/task.service.d.ts +96 -65
  83. package/dist/services/task.service.d.ts.map +1 -1
  84. package/dist/services/task.service.js +208 -15
  85. package/dist/services/task.service.js.map +1 -1
  86. package/dist/services/team-run.service.d.ts +18 -0
  87. package/dist/services/team-run.service.d.ts.map +1 -1
  88. package/dist/services/team-run.service.js +234 -13
  89. package/dist/services/team-run.service.js.map +1 -1
  90. package/dist/services/team-scheduler.service.d.ts +8 -4
  91. package/dist/services/team-scheduler.service.d.ts.map +1 -1
  92. package/dist/services/team-scheduler.service.js +42 -13
  93. package/dist/services/team-scheduler.service.js.map +1 -1
  94. package/dist/services/workspace-git-watcher.service.d.ts +62 -0
  95. package/dist/services/workspace-git-watcher.service.d.ts.map +1 -0
  96. package/dist/services/workspace-git-watcher.service.js +427 -0
  97. package/dist/services/workspace-git-watcher.service.js.map +1 -0
  98. package/dist/services/workspace.service.d.ts +99 -108
  99. package/dist/services/workspace.service.d.ts.map +1 -1
  100. package/dist/services/workspace.service.js +43 -6
  101. package/dist/services/workspace.service.js.map +1 -1
  102. package/dist/socket/events.d.ts +1 -1
  103. package/dist/socket/events.d.ts.map +1 -1
  104. package/dist/socket/events.js.map +1 -1
  105. package/dist/socket/socket-gateway.d.ts.map +1 -1
  106. package/dist/socket/socket-gateway.js +5 -1
  107. package/dist/socket/socket-gateway.js.map +1 -1
  108. package/dist/utils/process-launch.d.ts.map +1 -1
  109. package/dist/utils/process-launch.js +52 -9
  110. package/dist/utils/process-launch.js.map +1 -1
  111. package/dist/utils/process-launch.test.js +65 -1
  112. package/dist/utils/process-launch.test.js.map +1 -1
  113. package/dist/web/assets/AgentDemoPage-DRtgA1-w.js +1 -0
  114. package/dist/web/assets/{DemoPage-dkmp8Vvn.js → DemoPage-8g4kqlV1.js} +3 -3
  115. package/dist/web/assets/GeneralSettingsPage-b2dViAif.js +1 -0
  116. package/dist/web/assets/{MemberAvatar-pwugXGL4.js → MemberAvatar-BuaKw8fE.js} +1 -1
  117. package/dist/web/assets/NotificationSettingsPage-DCtnFBrk.js +1 -0
  118. package/dist/web/assets/ProfileSettingsPage-Hplbudpu.js +3 -0
  119. package/dist/web/assets/ProjectKanbanPage-UJVkISeV.js +89 -0
  120. package/dist/web/assets/ProjectSettingsPage-CnG-6FVF.js +2 -0
  121. package/dist/web/assets/ProviderSettingsPage-B-u7Av-v.js +54 -0
  122. package/dist/web/assets/SettingsMasterDetail-C7L4KTOf.js +1 -0
  123. package/dist/web/assets/TeamSettingsPage-DCsq_ojZ.js +1 -0
  124. package/dist/web/assets/arrow-left-BSle2OYV.js +1 -0
  125. package/dist/web/assets/check-COf1UbPe.js +1 -0
  126. package/dist/web/assets/chevron-down-Dj8_pYCl.js +1 -0
  127. package/dist/web/assets/chevron-right-BUCnUjsN.js +1 -0
  128. package/dist/web/assets/{chevron-up-BnCoaejn.js → chevron-up-BhzmceCN.js} +1 -1
  129. package/dist/web/assets/{code-block-OCS4YCEC-DkMlYSza.js → code-block-OCS4YCEC-C9ZDvx5q.js} +1 -1
  130. package/dist/web/assets/{confirm-dialog-wsb35VpE.js → confirm-dialog-NY6uLJRk.js} +1 -1
  131. package/dist/web/assets/folder-picker-B5loyQsl.js +1 -0
  132. package/dist/web/assets/index-3iFMFw1l.css +1 -0
  133. package/dist/web/assets/index-DSFOeuuj.js +13 -0
  134. package/dist/web/assets/input-D67geHKZ.js +1 -0
  135. package/dist/web/assets/layers-Dl9LLqoY.js +1 -0
  136. package/dist/web/assets/loader-circle-CP1oxYjb.js +1 -0
  137. package/dist/web/assets/{mermaid-NOHMQCX5-DoPzf-UA.js → mermaid-NOHMQCX5-C-bBE9vu.js} +4 -4
  138. package/dist/web/assets/message-square-Bwt_cqko.js +1 -0
  139. package/dist/web/assets/modal-0iwqEf_V.js +1 -0
  140. package/dist/web/assets/{pencil-CaJR6Dqm.js → pencil-CAgGPSMf.js} +1 -1
  141. package/dist/web/assets/rotate-ccw-CnfGwAnp.js +1 -0
  142. package/dist/web/assets/{select-CzeTYLO4.js → select-C0X1iRxk.js} +1 -1
  143. package/dist/web/assets/switch-D_KOTssd.js +1 -0
  144. package/dist/web/assets/textarea-DS-Evqsv.js +1 -0
  145. package/dist/web/assets/{upload-_2T21rVP.js → upload-CTsJ3wDk.js} +1 -1
  146. package/dist/web/assets/{use-profiles-BaCwGP06.js → use-profiles-CzdxiQuG.js} +1 -1
  147. package/dist/web/assets/{use-providers-Bwl7R5Ql.js → use-providers-BdxKwaE3.js} +1 -1
  148. package/dist/web/favicon.ico +0 -0
  149. package/dist/web/index.html +4 -4
  150. package/node_modules/@agent-tower/shared/dist/socket/events.d.ts +10 -1
  151. package/node_modules/@agent-tower/shared/dist/socket/events.d.ts.map +1 -1
  152. package/node_modules/@agent-tower/shared/dist/socket/events.js +1 -0
  153. package/node_modules/@agent-tower/shared/dist/socket/events.js.map +1 -1
  154. package/node_modules/@agent-tower/shared/dist/types.d.ts +25 -1
  155. package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
  156. package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
  157. package/node_modules/@prisma/client/.prisma/client/edge.js +6 -5
  158. package/node_modules/@prisma/client/.prisma/client/index-browser.js +1 -0
  159. package/node_modules/@prisma/client/.prisma/client/index.d.ts +43 -0
  160. package/node_modules/@prisma/client/.prisma/client/index.js +6 -5
  161. package/node_modules/@prisma/client/.prisma/client/package.json +1 -1
  162. package/node_modules/@prisma/client/.prisma/client/schema.prisma +2 -0
  163. package/node_modules/@prisma/client/.prisma/client/wasm.js +1 -0
  164. package/package.json +1 -1
  165. package/prisma/migrations/20260609000000_add_team_member_membership_status/migration.sql +3 -0
  166. package/prisma/schema.prisma +2 -0
  167. package/dist/web/assets/AgentDemoPage-CkhVcgZo.js +0 -1
  168. package/dist/web/assets/GeneralSettingsPage-B4DH6g3D.js +0 -1
  169. package/dist/web/assets/NotificationSettingsPage-C-bPU_ZE.js +0 -1
  170. package/dist/web/assets/ProfileSettingsPage-Dlr6BmHb.js +0 -3
  171. package/dist/web/assets/ProjectKanbanPage-7oEfjjWV.js +0 -89
  172. package/dist/web/assets/ProjectSettingsPage-DZZksq5G.js +0 -2
  173. package/dist/web/assets/ProviderSettingsPage-BWN7CEG6.js +0 -54
  174. package/dist/web/assets/SettingsSection-C-sMhXpf.js +0 -1
  175. package/dist/web/assets/TeamSettingsPage-924xpocx.js +0 -1
  176. package/dist/web/assets/arrow-left-UHjQiY5K.js +0 -1
  177. package/dist/web/assets/button-CUTjpRqw.js +0 -1
  178. package/dist/web/assets/check-CPkZgPjx.js +0 -1
  179. package/dist/web/assets/chevron-down-Bby7sJEv.js +0 -1
  180. package/dist/web/assets/chevron-right-DCC0lyoB.js +0 -1
  181. package/dist/web/assets/circle-check-BscClK07.js +0 -1
  182. package/dist/web/assets/folder-picker-B-X_nrS1.js +0 -1
  183. package/dist/web/assets/index-4hNWw0yi.css +0 -1
  184. package/dist/web/assets/index-CUJoWIuo.js +0 -13
  185. package/dist/web/assets/loader-circle-Cul4BuAa.js +0 -1
  186. package/dist/web/assets/message-square-C7Q71jFj.js +0 -1
  187. package/dist/web/assets/modal-25-qs8P5.js +0 -1
  188. package/dist/web/assets/rotate-ccw-Bvz7590n.js +0 -1
@@ -0,0 +1 @@
1
+ import{h as P,i as q,k as E,l as k,q as v,m as h,u as R,r as o,j as e,S as g,K as B,d as L,e as j,M,B as W,f as z,J as A}from"./index-DSFOeuuj.js";import{S as K}from"./select-C0X1iRxk.js";import{I as d}from"./input-D67geHKZ.js";import{S as Q,C as O}from"./switch-D_KOTssd.js";import{M as _}from"./message-square-Bwt_cqko.js";import{L as D,C as H}from"./loader-circle-CP1oxYjb.js";import"./chevron-down-Dj8_pYCl.js";import"./check-COf1UbPe.js";const J=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],G=P("link",J);function V(){return q({queryKey:v.notifications.settings,queryFn:()=>h.get("/notifications/settings")})}function X(){const t=E();return k({mutationFn:i=>h.put("/notifications/settings",i),onSuccess:()=>{t.invalidateQueries({queryKey:v.notifications.settings})}})}function Y(){return k({mutationFn:t=>h.post("/notifications/test",t)})}function oe(){const{t}=R(),{data:i,isLoading:y}=V(),l=X(),n=Y(),N=[{value:"none",label:t("关闭")},{value:"feishu",label:t("飞书 Webhook")}],[a,x]=o.useState({webhookUrl:"",baseUrl:"",titleTemplate:"",bodyTemplate:""}),[m,p]=o.useState(!1),[f,r]=o.useState("idle"),u=o.useRef(void 0);if(o.useEffect(()=>{i&&!m&&x({webhookUrl:i.feishuWebhookUrl??"",baseUrl:i.thirdPartyBaseUrl??"",titleTemplate:i.taskInReviewTitleTemplate??"",bodyTemplate:i.taskInReviewBodyTemplate??""})},[i,m]),o.useEffect(()=>(n.isSuccess?(r("success"),u.current=setTimeout(()=>r("idle"),3e3)):n.isError&&(r("error"),u.current=setTimeout(()=>r("idle"),5e3)),()=>clearTimeout(u.current)),[n.isSuccess,n.isError]),y)return e.jsx(g,{children:e.jsx(B,{rows:3})});const T=i?.osNotificationEnabled??!0,b=i?.thirdPartyChannel??"none",c=(s,I)=>{x(F=>({...F,[s]:I})),p(!0)},S=s=>{l.mutate({osNotificationEnabled:s})},C=s=>{l.mutate({thirdPartyChannel:s})},U=()=>{l.mutate({feishuWebhookUrl:a.webhookUrl.trim()||null,thirdPartyBaseUrl:a.baseUrl.trim()||null,taskInReviewTitleTemplate:a.titleTemplate.trim()||"Agent Tower",taskInReviewBodyTemplate:a.bodyTemplate.trim()||t('✅ "{taskTitle}" 已完成,等待审查')},{onSuccess:()=>p(!1)})},w=()=>{a.webhookUrl.trim()&&n.mutate({channel:"feishu",webhookUrl:a.webhookUrl.trim(),baseUrl:a.baseUrl.trim()||void 0})};return e.jsxs(g,{children:[e.jsx(L,{title:t("通知设置"),className:"mb-1"}),e.jsxs("div",{className:"divide-y divide-border/60",children:[e.jsx(j,{icon:M,label:t("桌面通知"),description:t("任务完成时弹出系统通知"),align:"center",controlWidth:"auto",children:e.jsx(Q,{checked:T,onCheckedChange:S,"aria-label":t("桌面通知")})}),e.jsxs("div",{className:"py-5",children:[e.jsx(j,{icon:_,label:t("第三方通知"),description:t("推送到外部渠道(飞书群机器人等)"),align:"center",className:"py-0",children:e.jsx(K,{value:b,onChange:s=>C(s),options:N})}),b==="feishu"&&e.jsxs("div",{className:"mt-4 space-y-4 sm:pl-11",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"feishu-webhook-url",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:"Webhook URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(d,{id:"feishu-webhook-url",value:a.webhookUrl,onChange:s=>c("webhookUrl",s.target.value),placeholder:"https://open.feishu.cn/open-apis/bot/v2/hook/...",className:"min-w-0 flex-1 font-mono"}),e.jsxs(W,{size:"sm",variant:"outline",onClick:w,disabled:!a.webhookUrl.trim()||n.isPending,className:"h-auto shrink-0",children:[n.isPending&&e.jsx(D,{size:12,className:"mr-1 animate-spin motion-reduce:animate-none"}),t("测试")]})]}),f==="success"&&e.jsxs("div",{role:"status",className:"mt-2 flex items-center gap-1.5 text-xs text-success",children:[e.jsx(O,{size:12,"aria-hidden":"true"}),t("测试消息发送成功")]}),f==="error"&&e.jsxs("div",{role:"alert",className:"mt-2 flex items-center gap-1.5 text-xs text-destructive",children:[e.jsx(H,{size:12,"aria-hidden":"true"}),t("发送失败,请检查 Webhook 地址")]})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"feishu-base-url",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(G,{size:11,"aria-hidden":"true"}),t("跳转地址")]})}),e.jsx(d,{id:"feishu-base-url",value:a.baseUrl,onChange:s=>c("baseUrl",s.target.value),placeholder:"http://localhost:5173",className:"font-mono"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t('通知卡片中的"查看任务"按钮跳转地址前缀')})]})]})]}),e.jsxs("div",{className:"py-5",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx(z,{children:t("通知模板")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:t("支持变量: {taskTitle}, {taskId}, {projectId}, {projectName}, {status}",{taskTitle:"{taskTitle}",taskId:"{taskId}",projectId:"{projectId}",projectName:"{projectName}",status:"{status}"})})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"notification-title-template",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:t("标题")}),e.jsx(d,{id:"notification-title-template",value:a.titleTemplate,onChange:s=>c("titleTemplate",s.target.value),placeholder:"Agent Tower"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"notification-body-template",className:"mb-1.5 block text-xs font-medium text-muted-foreground",children:t("内容")}),e.jsx(d,{id:"notification-body-template",value:a.bodyTemplate,onChange:s=>c("bodyTemplate",s.target.value),placeholder:t('✅ "{taskTitle}" 已完成,等待审查')})]})]})]})]}),m&&e.jsx(A,{saving:l.isPending,onSave:U})]})}export{oe as NotificationSettingsPage};
@@ -0,0 +1,3 @@
1
+ import{u as T,r as g,j as e,S,d as J,n as M,o as w,B as E,p,g as P}from"./index-DSFOeuuj.js";import{u as U,a as _,b as z,c as B}from"./use-profiles-CzdxiQuG.js";import{M as F,P as G,T as $}from"./modal-0iwqEf_V.js";import{C as R}from"./confirm-dialog-NY6uLJRk.js";import{I as H}from"./input-D67geHKZ.js";import{T as q}from"./textarea-DS-Evqsv.js";import{L as K}from"./layers-Dl9LLqoY.js";import{C as Q}from"./chevron-down-Dj8_pYCl.js";import{P as W}from"./pencil-CAgGPSMf.js";function X(t){const a=Object.entries(t);return a.length===0?"(empty)":a.map(([m,c])=>`${m}: ${JSON.stringify(c)}`).join(", ")}const y={CLAUDE_CODE:"Claude Code",GEMINI_CLI:"Gemini CLI",CURSOR_AGENT:"Cursor Agent"};function Y({agentType:t,variants:a,isBuiltIn:m,onEdit:c,onNew:h,onDelete:j}){const{t:n}=T(),[r,b]=g.useState(!0),u=Object.entries(a);return e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 bg-muted/40 px-4 py-3",children:[e.jsxs("button",{type:"button",onClick:()=>b(i=>!i),"aria-expanded":r,className:"flex items-center gap-3 rounded-md transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[e.jsx("h3",{className:"text-[13px] font-semibold text-foreground",children:y[t]??t}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[u.length," ",n("个变体")]}),e.jsx(Q,{size:14,"aria-hidden":"true",className:P("text-muted-foreground transition-transform motion-reduce:transition-none",r&&"rotate-180")})]}),e.jsxs("button",{type:"button",onClick:h,className:"flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground transition-colors hover:bg-background hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[e.jsx(G,{size:12,"aria-hidden":"true"}),n("新增")]})]}),r&&e.jsxs("div",{className:"divide-y divide-border/60",children:[u.map(([i,x])=>{const f=m(i);return e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 transition-colors hover:bg-muted/40",children:[e.jsx("span",{className:P("inline-flex shrink-0 items-center rounded px-2 py-0.5 text-[11px] font-semibold tracking-wide",i==="DEFAULT"?"bg-primary/[0.06] text-primary":"bg-muted text-muted-foreground"),children:i}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",children:X(x)}),f&&e.jsx("span",{className:"shrink-0 text-[10px] font-medium text-muted-foreground/70",children:n("内置")}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx("button",{onClick:()=>c(i,x),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",title:n("编辑"),"aria-label":n("编辑"),children:e.jsx(W,{size:12})}),!f&&e.jsx("button",{onClick:()=>j(i),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",title:n("删除"),"aria-label":n("删除"),children:e.jsx($,{size:12})})]})]},i)}),u.length===0&&e.jsx("div",{className:"px-4 py-4 text-center text-xs text-muted-foreground",children:n("暂无变体")})]})]})}function Z(){return e.jsxs("div",{role:"status","aria-label":"Loading",children:[e.jsx(p,{className:"h-7 w-36"}),e.jsx(p,{className:"mt-2 h-3.5 w-72 max-w-full"}),e.jsx("div",{className:"mt-5 space-y-3",children:Array.from({length:2}).map((t,a)=>e.jsxs("div",{className:"overflow-hidden rounded-lg border border-border",children:[e.jsxs("div",{className:"flex items-center gap-3 bg-muted/40 px-4 py-3",children:[e.jsx(p,{className:"h-4 w-28"}),e.jsx(p,{className:"h-3 w-14"})]}),e.jsx("div",{className:"divide-y divide-border/60",children:Array.from({length:2}).map((m,c)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[e.jsx(p,{className:"h-5 w-16 rounded"}),e.jsx(p,{className:"h-3.5 flex-1"})]},c))})]},a))})]})}function de(){const{t}=T(),{data:a,isLoading:m}=U(),{data:c}=_(),h=z(),j=B(),[n,r]=g.useState(null),[b,u]=g.useState(""),[i,x]=g.useState(""),[f,v]=g.useState(""),[o,N]=g.useState(null),k=(s,l,d)=>{r({agentType:s,variant:l,config:d,isNew:!1}),x(l),u(JSON.stringify(d,null,2)),v("")},O=s=>{r({agentType:s,variant:"",config:{},isNew:!0}),x(""),u(`{
2
+
3
+ }`),v("")},D=()=>{if(!(!n||!i.trim()))try{const s=JSON.parse(b);v(""),h.mutate({agentType:n.agentType,variant:i.trim().toUpperCase(),config:s},{onSuccess:()=>r(null)})}catch{v(t("JSON 格式错误"))}},L=(s,l)=>{N({agentType:s,variant:l})},A=()=>{o&&j.mutate({agentType:o.agentType,variant:o.variant},{onSettled:()=>N(null)})},I=(s,l)=>!!c?.executors[s]?.[l];if(m)return e.jsx(S,{children:e.jsx(Z,{})});const C=a?.executors??{};return e.jsxs(S,{children:[e.jsx(J,{title:t("Profile 配置"),description:t("管理 Agent 执行器的配置变体。每个变体定义一组运行参数。"),className:"mb-4"}),e.jsx("div",{className:"space-y-3",children:Object.entries(C).map(([s,l])=>e.jsx(Y,{agentType:s,variants:l,isBuiltIn:d=>I(s,d),onEdit:(d,V)=>k(s,d,V),onNew:()=>O(s),onDelete:d=>L(s,d)},s))}),Object.keys(C).length===0&&e.jsx(M,{icon:K,message:t("暂无 Profile 配置")}),e.jsx(F,{isOpen:!!n,onClose:()=>r(null),title:n?.isNew?t("新增 Variant — {agentType}",{agentType:y[n.agentType]??n.agentType}):t("编辑 {variant}",{variant:n?.variant??""}),action:e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"outline",onClick:()=>r(null),children:t("取消")}),e.jsx(E,{onClick:D,disabled:h.isPending,children:h.isPending?t("保存中..."):t("保存")})]}),children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(w,{label:t("Variant 名称"),htmlFor:"profile-variant-name",children:e.jsx(H,{id:"profile-variant-name",value:i,onChange:s=>x(s.target.value),disabled:!n?.isNew,placeholder:t("例如: CUSTOM"),className:"font-mono"})}),e.jsxs(w,{label:t("配置 (JSON)"),htmlFor:"profile-variant-json",children:[e.jsx(q,{id:"profile-variant-json",value:b,onChange:s=>{u(s.target.value),v("")},rows:6,className:"resize-none font-mono","aria-invalid":!!f}),f&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-destructive",children:f})]})]})}),e.jsx(R,{isOpen:o!==null,onClose:()=>{j.isPending||N(null)},onConfirm:A,title:t("删除 Profile Variant"),description:o?t('确定删除 "{name}"?此操作不可撤销。',{name:`${y[o.agentType]??o.agentType} / ${o.variant}`}):"",confirmText:t("删除"),cancelText:t("取消"),variant:"danger",isLoading:j.isPending})]})}export{de as ProfileSettingsPage};