maestro-flow 0.3.8 → 0.3.9

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 (211) hide show
  1. package/.claude/commands/learn-decompose.md +3 -3
  2. package/.claude/commands/learn-follow.md +5 -5
  3. package/.claude/commands/learn-investigate.md +3 -3
  4. package/.claude/commands/learn-retro.md +6 -6
  5. package/.claude/commands/learn-second-opinion.md +3 -3
  6. package/.claude/commands/maestro-analyze.md +123 -99
  7. package/.claude/commands/maestro-brainstorm.md +2 -2
  8. package/.claude/commands/maestro-execute.md +137 -97
  9. package/.claude/commands/maestro-fork.md +111 -0
  10. package/.claude/commands/maestro-init.md +6 -6
  11. package/.claude/commands/maestro-merge.md +77 -0
  12. package/.claude/commands/maestro-milestone-audit.md +72 -60
  13. package/.claude/commands/maestro-milestone-complete.md +67 -59
  14. package/.claude/commands/maestro-milestone-release.md +6 -6
  15. package/.claude/commands/maestro-plan.md +151 -130
  16. package/.claude/commands/maestro-quick.md +4 -4
  17. package/.claude/commands/maestro-roadmap.md +5 -5
  18. package/.claude/commands/maestro-spec-generate.md +5 -5
  19. package/.claude/commands/maestro-ui-design.md +3 -3
  20. package/.claude/commands/maestro-verify.md +106 -87
  21. package/.claude/commands/maestro.md +10 -4
  22. package/.claude/commands/manage-codebase-rebuild.md +4 -4
  23. package/.claude/commands/manage-codebase-refresh.md +1 -1
  24. package/.claude/commands/manage-harvest.md +5 -5
  25. package/.claude/commands/manage-issue-discover.md +1 -1
  26. package/.claude/commands/manage-issue-execute.md +6 -6
  27. package/.claude/commands/manage-issue.md +6 -6
  28. package/.claude/commands/manage-learn.md +2 -2
  29. package/.claude/commands/manage-memory-capture.md +4 -4
  30. package/.claude/commands/manage-memory.md +2 -2
  31. package/.claude/commands/manage-status.md +24 -24
  32. package/.claude/commands/quality-business-test.md +5 -5
  33. package/.claude/commands/quality-debug.md +4 -4
  34. package/.claude/commands/quality-integration-test.md +4 -4
  35. package/.claude/commands/quality-refactor.md +3 -3
  36. package/.claude/commands/quality-retrospective.md +2 -2
  37. package/.claude/commands/quality-review.md +4 -4
  38. package/.claude/commands/quality-sync.md +3 -3
  39. package/.claude/commands/quality-test-gen.md +4 -4
  40. package/.claude/commands/quality-test.md +9 -9
  41. package/.claude/commands/spec-add.md +2 -2
  42. package/.claude/commands/spec-load.md +1 -1
  43. package/.claude/commands/spec-setup.md +5 -5
  44. package/.claude/commands/wiki-connect.md +3 -3
  45. package/.claude/commands/wiki-digest.md +4 -4
  46. package/.codex/skills/maestro-analyze/SKILL.md +52 -14
  47. package/.codex/skills/maestro-execute/SKILL.md +27 -26
  48. package/.codex/skills/maestro-milestone-audit/SKILL.md +103 -209
  49. package/.codex/skills/maestro-milestone-complete/SKILL.md +149 -158
  50. package/.codex/skills/maestro-plan/SKILL.md +47 -17
  51. package/.codex/skills/maestro-roadmap/SKILL.md +3 -2
  52. package/.codex/skills/team-coordinate/roles/coordinator/commands/monitor.md +2 -2
  53. package/.codex/skills/team-executor/roles/executor/commands/monitor.md +1 -1
  54. package/.codex/skills/team-lifecycle-v4/roles/coordinator/commands/monitor.md +2 -2
  55. package/.codex/skills/team-lifecycle-v4/specs/knowledge-transfer.md +2 -2
  56. package/.codex/skills/team-quality-assurance/roles/coordinator/commands/monitor.md +1 -1
  57. package/.codex/skills/team-review/roles/coordinator/commands/monitor.md +1 -1
  58. package/.codex/skills/team-tech-debt/roles/coordinator/commands/monitor.md +1 -1
  59. package/.codex/skills/team-testing/roles/coordinator/commands/monitor.md +1 -1
  60. package/README.md +19 -14
  61. package/README.zh-CN.md +16 -12
  62. package/bin/maestro-mcp.js +1 -1
  63. package/chains/_intent-map.json +21 -9
  64. package/chains/_router.json +30 -77
  65. package/chains/brainstorm-driven.json +17 -6
  66. package/chains/full-lifecycle.json +22 -23
  67. package/chains/milestone-close.json +20 -7
  68. package/chains/milestone-fork-merge.json +50 -0
  69. package/chains/roadmap-driven.json +17 -6
  70. package/chains/spec-driven.json +17 -6
  71. package/dashboard/dist/assets/{ArtifactsPage-BmPOu8sO.js → ArtifactsPage-DZNCi6tn.js} +12 -7
  72. package/dashboard/dist/assets/ChatInput-Bvr-FeEq.js +49 -0
  73. package/dashboard/dist/assets/ChatPage-D9zTkJZo.js +22 -0
  74. package/dashboard/dist/assets/CollabPage-B4NAHXS2.js +1 -0
  75. package/dashboard/dist/assets/ExecutionPanel-CFt4LJyq.js +1 -0
  76. package/dashboard/dist/assets/KanbanPage-C8USth6H.js +21 -0
  77. package/dashboard/dist/assets/{MarkdownRenderer-BjZ43aSa.js → MarkdownRenderer-X4af_WNb.js} +1 -1
  78. package/dashboard/dist/assets/McpPage-BKfCVIyU.js +21 -0
  79. package/dashboard/dist/assets/OutputPanel-BlBQFJSW.js +1 -0
  80. package/dashboard/dist/assets/ProblemsPanel-De3DLvoI.js +1 -0
  81. package/dashboard/dist/assets/{RequirementBoardPage-B7yRL0s_.js → RequirementBoardPage-Bf1trzqs.js} +2 -2
  82. package/dashboard/dist/assets/{RequirementPage-D8J_-b6O.js → RequirementPage-Bllxe2XI.js} +10 -5
  83. package/dashboard/dist/assets/{SpecsPage-6lO8v8_C.js → SpecsPage-9lwxKT27.js} +2 -2
  84. package/dashboard/dist/assets/{SupervisorPage-Ds5N378a.js → SupervisorPage-SusdfHFq.js} +1 -1
  85. package/dashboard/dist/assets/{TeamsPage-DrkKr17T.js → TeamsPage-DsuM6OwC.js} +2 -2
  86. package/dashboard/dist/assets/TreeBrowser-Q12qobZs.js +6 -0
  87. package/dashboard/dist/assets/WorkflowPage-D_Fzdy3_.js +6 -0
  88. package/dashboard/dist/assets/{arrow-left-CadP5YgU.js → arrow-left-Bqtb2hle.js} +1 -1
  89. package/dashboard/dist/assets/{check-5xufDzS8.js → check-u6fGOwQO.js} +1 -1
  90. package/dashboard/dist/assets/{chevron-right-CYbpR4ev.js → chevron-right-Csu22t58.js} +1 -1
  91. package/dashboard/dist/assets/{circle-Bm-5Q-Yh.js → circle-CMrkbRNg.js} +1 -1
  92. package/dashboard/dist/assets/{circle-alert-BqcYuT7x.js → circle-alert-c3tH1P4z.js} +1 -1
  93. package/dashboard/dist/assets/{circle-check-big-yyzAFysU.js → circle-check-big-TDSeWstm.js} +1 -1
  94. package/dashboard/dist/assets/{circle-check-DEVzW_lm.js → circle-check-gYxxSYuH.js} +1 -1
  95. package/dashboard/dist/assets/{code-BBdC8Wmw.js → code-CFN2uX9V.js} +1 -1
  96. package/dashboard/dist/assets/{columns-3-CQ9Trztr.js → columns-3-38xIDlzy.js} +1 -1
  97. package/dashboard/dist/assets/{download-DayuF-sn.js → download-DC7KkKyP.js} +1 -1
  98. package/dashboard/dist/assets/{folder-CqXeSKeC.js → folder-CWq_lAnf.js} +1 -1
  99. package/dashboard/dist/assets/index-DWG-WrzT.js +231 -0
  100. package/dashboard/dist/assets/{index-Dru5HYy0.js → index-Do71weNR.js} +1 -1
  101. package/dashboard/dist/assets/index-GUNJodSR.css +1 -0
  102. package/dashboard/dist/assets/{list-DBOD6IUt.js → list-CgIP_2A-.js} +1 -1
  103. package/dashboard/dist/assets/{minus-fQI1Syn2.js → minus-DYoN5UGk.js} +1 -1
  104. package/dashboard/dist/assets/{pen-line-Bkbbngl5.js → pen-line-Bh_WKYHm.js} +1 -1
  105. package/dashboard/dist/assets/{proxy-teW12DdZ.js → proxy-BKxDAKTj.js} +1 -1
  106. package/dashboard/dist/assets/{search-Bq3ygFUW.js → search-SieXnOgr.js} +1 -1
  107. package/dashboard/dist/assets/{shallow-22ZN8sFt.js → shallow-Bme1JY57.js} +1 -1
  108. package/dashboard/dist/assets/{table-BEYtdWc4.js → table-llyEtj-7.js} +1 -1
  109. package/dashboard/dist/assets/terminal-BB3Xfuv5.js +6 -0
  110. package/dashboard/dist/assets/{trash-2-DMqGBgcF.js → trash-2-C8f4vFFM.js} +1 -1
  111. package/dashboard/dist/assets/{zap-9DVkGVtt.js → zap-4uwlzVm0.js} +1 -1
  112. package/dashboard/dist/index.html +2 -2
  113. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js +8 -4
  114. package/dashboard/dist-server/dashboard/src/server/agents/claude-code-adapter.js.map +1 -1
  115. package/dashboard/dist-server/dashboard/src/server/agents/entry-normalizer.d.ts +1 -0
  116. package/dashboard/dist-server/dashboard/src/server/agents/entry-normalizer.js +2 -1
  117. package/dashboard/dist-server/dashboard/src/server/agents/entry-normalizer.js.map +1 -1
  118. package/dashboard/dist-server/dashboard/src/server/agents/stream-json-adapter.js +20 -10
  119. package/dashboard/dist-server/dashboard/src/server/agents/stream-json-adapter.js.map +1 -1
  120. package/dashboard/dist-server/dashboard/src/server/routes/git.d.ts +2 -0
  121. package/dashboard/dist-server/dashboard/src/server/routes/git.js +79 -0
  122. package/dashboard/dist-server/dashboard/src/server/routes/git.js.map +1 -0
  123. package/dashboard/dist-server/dashboard/src/server/routes/index.js +3 -0
  124. package/dashboard/dist-server/dashboard/src/server/routes/index.js.map +1 -1
  125. package/dashboard/dist-server/dashboard/src/server/routes/workspace.js +43 -0
  126. package/dashboard/dist-server/dashboard/src/server/routes/workspace.js.map +1 -1
  127. package/dashboard/dist-server/dashboard/src/server/state/state-manager.js +43 -3
  128. package/dashboard/dist-server/dashboard/src/server/state/state-manager.js.map +1 -1
  129. package/dashboard/package.json +59 -59
  130. package/dist/src/cli.js +3 -1
  131. package/dist/src/cli.js.map +1 -1
  132. package/dist/src/commands/{team.d.ts → collab.d.ts} +2 -2
  133. package/dist/src/commands/collab.d.ts.map +1 -0
  134. package/dist/src/commands/{team.js → collab.js} +391 -24
  135. package/dist/src/commands/collab.js.map +1 -0
  136. package/dist/src/commands/msg.d.ts.map +1 -1
  137. package/dist/src/commands/msg.js +4 -3
  138. package/dist/src/commands/msg.js.map +1 -1
  139. package/dist/src/hooks/team-monitor.d.ts.map +1 -1
  140. package/dist/src/hooks/team-monitor.js +16 -0
  141. package/dist/src/hooks/team-monitor.js.map +1 -1
  142. package/dist/src/tools/collab-adapter.d.ts +85 -0
  143. package/dist/src/tools/collab-adapter.d.ts.map +1 -0
  144. package/dist/src/tools/collab-adapter.js +320 -0
  145. package/dist/src/tools/collab-adapter.js.map +1 -0
  146. package/dist/src/tools/namespace-guard.d.ts +2 -0
  147. package/dist/src/tools/namespace-guard.d.ts.map +1 -1
  148. package/dist/src/tools/namespace-guard.js +12 -0
  149. package/dist/src/tools/namespace-guard.js.map +1 -1
  150. package/dist/src/tools/phase-gate-evaluator.d.ts +45 -0
  151. package/dist/src/tools/phase-gate-evaluator.d.ts.map +1 -0
  152. package/dist/src/tools/phase-gate-evaluator.js +42 -0
  153. package/dist/src/tools/phase-gate-evaluator.js.map +1 -0
  154. package/dist/src/tools/team-members.d.ts +18 -0
  155. package/dist/src/tools/team-members.d.ts.map +1 -1
  156. package/dist/src/tools/team-members.js +50 -0
  157. package/dist/src/tools/team-members.js.map +1 -1
  158. package/dist/src/tools/team-tasks.d.ts +120 -0
  159. package/dist/src/tools/team-tasks.d.ts.map +1 -0
  160. package/dist/src/tools/team-tasks.js +365 -0
  161. package/dist/src/tools/team-tasks.js.map +1 -0
  162. package/dist/src/tools/transition-recorder.d.ts +3 -0
  163. package/dist/src/tools/transition-recorder.d.ts.map +1 -1
  164. package/dist/src/tools/transition-recorder.js +52 -1
  165. package/dist/src/tools/transition-recorder.js.map +1 -1
  166. package/dist/src/utils/get-version.d.ts.map +1 -1
  167. package/dist/src/utils/get-version.js +15 -4
  168. package/dist/src/utils/get-version.js.map +1 -1
  169. package/package.json +1 -1
  170. package/templates/config.json +7 -0
  171. package/templates/worktree-scope.json +10 -0
  172. package/templates/worktrees.json +27 -0
  173. package/workflows/analyze.md +86 -36
  174. package/workflows/brainstorm.md +17 -37
  175. package/workflows/execute.md +94 -28
  176. package/workflows/fork.md +309 -0
  177. package/workflows/init.md +10 -1
  178. package/workflows/issue.md +66 -7
  179. package/workflows/maestro-coordinate.md +23 -16
  180. package/workflows/maestro.md +52 -35
  181. package/workflows/merge.md +285 -0
  182. package/workflows/milestone-audit.md +89 -70
  183. package/workflows/milestone-complete.md +89 -156
  184. package/workflows/plan.md +122 -17
  185. package/workflows/retrospective.md +3 -3
  186. package/workflows/roadmap.md +11 -3
  187. package/workflows/spec-generate.md +9 -0
  188. package/workflows/status.md +76 -27
  189. package/workflows/ui-design.md +14 -12
  190. package/workflows/verify.md +44 -8
  191. package/.claude/commands/maestro-phase-add.md +0 -63
  192. package/.claude/commands/maestro-phase-transition.md +0 -75
  193. package/.codex/skills/maestro-phase-add/SKILL.md +0 -154
  194. package/.codex/skills/maestro-phase-transition/SKILL.md +0 -173
  195. package/chains/singles/phase-add.json +0 -31
  196. package/chains/singles/phase-transition.json +0 -23
  197. package/dashboard/dist/assets/ChatInput-CL8YDfOU.js +0 -67
  198. package/dashboard/dist/assets/ChatPage-CT-ozBK2.js +0 -8
  199. package/dashboard/dist/assets/CollabPage-C0rWMden.js +0 -1
  200. package/dashboard/dist/assets/KanbanPage-C6WbAlwI.js +0 -16
  201. package/dashboard/dist/assets/McpPage-BPIXADQi.js +0 -16
  202. package/dashboard/dist/assets/TreeBrowser-g_QUKemL.js +0 -11
  203. package/dashboard/dist/assets/WorkflowPage-X8aNkDEr.js +0 -6
  204. package/dashboard/dist/assets/git-branch-SqFf4Ru5.js +0 -6
  205. package/dashboard/dist/assets/index-D2Mtyw7I.css +0 -1
  206. package/dashboard/dist/assets/index-nufWop4p.js +0 -231
  207. package/dashboard/dist/assets/wrench-B84-zdLI.js +0 -11
  208. package/dist/src/commands/team.d.ts.map +0 -1
  209. package/dist/src/commands/team.js.map +0 -1
  210. package/workflows/phase-add.md +0 -252
  211. package/workflows/phase-transition.md +0 -399
@@ -1,4 +1,4 @@
1
- import{o as _e,u as T,b as R,j as e,v as Be,t as Me,r as g,s as X,Y as _}from"./index-nufWop4p.js";const m=_e((r,o)=>({activeTab:"commander",learningStats:null,learningPatterns:[],knowledgeEntries:[],scheduledTasks:[],extensions:[],promptModes:[],promptBindings:{},error:null,onLearningUpdate:t=>r({learningStats:t,learningPatterns:t.topPatterns}),onScheduleUpdate:t=>r({scheduledTasks:t}),onScheduleTriggered:t=>r(n=>{const s=new Date().toISOString();return{scheduledTasks:n.scheduledTasks.map(a=>{if(a.id!==t.taskId)return a;const v=a.lastRun?new Date(a.lastRun).getTime():0,p=v>0?Date.now()-v:0;return{...a,lastRun:s,history:[...a.history,{timestamp:s,status:"success",duration:p}]}})}}),onExtensionLoaded:t=>r({extensions:t.extensions}),onExtensionError:t=>r(n=>({extensions:n.extensions.map(x=>x.name!==t.name?x:{...x,status:"disabled"})})),fetchLearningStats:async()=>{try{const t=await fetch("/api/supervisor/learning/stats");if(!t.ok){r({error:`Failed to fetch learning stats: ${t.status}`});return}const n=await t.json();if(n&&typeof n=="object"&&"topPatterns"in n){const s=n;r({learningStats:s,learningPatterns:s.topPatterns,error:null})}}catch(t){r({error:`Failed to fetch learning stats: ${t instanceof Error?t.message:String(t)}`})}},fetchSchedules:async()=>{try{const t=await fetch("/api/supervisor/schedules");if(!t.ok){r({error:`Failed to fetch schedules: ${t.status}`});return}const n=await t.json(),s=n&&typeof n=="object"&&"tasks"in n?n.tasks:Array.isArray(n)?n:[];r({scheduledTasks:s,error:null})}catch(t){r({error:`Failed to fetch schedules: ${t instanceof Error?t.message:String(t)}`})}},fetchExtensions:async()=>{try{const t=await fetch("/api/supervisor/extensions");if(!t.ok){r({error:`Failed to fetch extensions: ${t.status}`});return}const n=await t.json(),s=n&&typeof n=="object"&&"extensions"in n?n.extensions:Array.isArray(n)?n:[];r({extensions:s,error:null})}catch(t){r({error:`Failed to fetch extensions: ${t instanceof Error?t.message:String(t)}`})}},fetchPromptModes:async()=>{try{const t=await fetch("/api/supervisor/prompts");if(!t.ok){r({error:`Failed to fetch prompt modes: ${t.status}`});return}const n=await t.json();if(n&&typeof n=="object"){const s=n,x=Array.isArray(s.builders)?s.builders:[],a=s.bindings&&typeof s.bindings=="object"?s.bindings:{};r({promptModes:x,promptBindings:a,error:null})}}catch(t){r({error:`Failed to fetch prompt modes: ${t instanceof Error?t.message:String(t)}`})}},createSchedule:async t=>{try{const n=await fetch("/api/supervisor/schedules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){r({error:`Failed to create schedule: ${n.status}`});return}const s=await n.json();if(s&&typeof s=="object"&&"task"in s){const x=s.task;r(a=>({scheduledTasks:[...a.scheduledTasks,x],error:null}))}}catch(n){r({error:`Failed to create schedule: ${n instanceof Error?n.message:String(n)}`})}},updateSchedule:async(t,n)=>{try{const s=await fetch(`/api/supervisor/schedules/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!s.ok){r({error:`Failed to update schedule: ${s.status}`});return}const x=await s.json();if(x&&typeof x=="object"&&"task"in x){const a=x.task;r(v=>({scheduledTasks:v.scheduledTasks.map(p=>p.id===t?a:p),error:null}))}}catch(s){r({error:`Failed to update schedule: ${s instanceof Error?s.message:String(s)}`})}},deleteSchedule:async t=>{try{const n=await fetch(`/api/supervisor/schedules/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok){r({error:`Failed to delete schedule: ${n.status}`});return}r(s=>({scheduledTasks:s.scheduledTasks.filter(x=>x.id!==t),error:null}))}catch(n){r({error:`Failed to delete schedule: ${n instanceof Error?n.message:String(n)}`})}},toggleSchedule:async(t,n)=>{await o().updateSchedule(t,{enabled:n})},runSchedule:async t=>{try{const n=await fetch(`/api/supervisor/schedules/${encodeURIComponent(t)}/run`,{method:"POST"});n.ok||r({error:`Failed to run schedule: ${n.status}`})}catch(n){r({error:`Failed to run schedule: ${n instanceof Error?n.message:String(n)}`})}},setActiveTab:t=>r({activeTab:t}),clearError:()=>r({error:null})}));function $e(r){const o=Date.now()-new Date(r).getTime(),t=Math.floor(o/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function Ae(){var y;const{t:r}=T(),o=R(i=>i.slots),t=R(i=>i.queue),n=R(i=>i.supervisorStatus),s=Object.values(o),x=(n==null?void 0:n.stats.totalDispatched)??0,a=(n==null?void 0:n.stats.totalCompleted)??0,v=(n==null?void 0:n.stats.totalFailed)??0,p=x>0?Math.round(a/x*100):0;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflowY:"auto",padding:24,gap:20},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12},children:[e.jsx(Z,{label:r("supervisor.overview.dispatched"),value:String(x),sub:`${s.length} ${r("supervisor.overview.active")}`}),e.jsx(Z,{label:r("supervisor.overview.success_rate"),value:x?`${p}%`:"-",valueColor:"var(--color-accent-green)",sub:`${a} ${r("supervisor.overview.completed")}`}),e.jsx(Z,{label:r("supervisor.overview.queued"),value:String(t.length),sub:`${((y=n==null?void 0:n.retrying)==null?void 0:y.length)??0} retrying`}),e.jsx(Z,{label:"Failed",value:String(v),valueColor:v>0?"var(--color-accent-red)":void 0,sub:x>0?`${Math.round(v/x*100)}% fail rate`:"-"})]}),e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r("supervisor.overview.active_executions")}),e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)"},children:r("supervisor.overview.running_count",{count:s.length})})]}),e.jsx("div",{children:s.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:16},children:"No active executions"}):s.map(i=>{const d=Be[i.executor]??"var(--color-text-tertiary)",k=Me[i.executor]??i.executor;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:d,flexShrink:0}}),e.jsx("span",{style:{fontSize:12,fontWeight:500,color:"var(--color-text-primary)"},children:i.issueId}),e.jsx("span",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:k}),e.jsxs("span",{style:{fontSize:11,color:"var(--color-text-tertiary)"},children:["Turn ",i.turnNumber,"/",i.maxTurns]}),e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",marginLeft:"auto"},children:$e(i.startedAt)})]},i.processId)})})]}),t.length>0&&e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:["Queue (",t.length,")"]})}),e.jsx("div",{children:t.map((i,d)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsxs("span",{style:{fontSize:10,fontWeight:600,color:"var(--color-text-tertiary)",minWidth:20},children:["#",d+1]}),e.jsx("span",{style:{fontSize:12,fontWeight:500,color:"var(--color-text-primary)"},children:i})]},i))})]})]})}function Z({label:r,value:o,sub:t,valueColor:n}){return e.jsxs("div",{style:{flex:1,background:"var(--color-bg-primary)",borderRadius:10,padding:14,border:"1px solid var(--color-border-divider)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:r}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:n??"var(--color-text-primary)",marginTop:2},children:o}),e.jsx("div",{style:{fontSize:10,color:"var(--color-text-secondary)"},children:t})]})}const De={optimize:"var(--color-accent-green)",alert:"var(--color-accent-orange)",automate:"var(--color-accent-purple)"};function Ee(){const{t:r}=T(),o=R(i=>i.commanderState),t=R(i=>i.commanderConfig),n=R(i=>i.fetchCommanderConfig),s=R(i=>i.recentDecisions),x=m(i=>i.setActiveTab),a=m(i=>i.learningStats);g.useEffect(()=>{n()},[n]);const v=()=>X({action:"commander:stop"}),p=s.length>0?s[s.length-1]:null,y=(a==null?void 0:a.suggestions)??[];return e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px 40px"},children:[e.jsxs("div",{style:re,children:[e.jsxs("div",{style:K,children:[e.jsx("div",{style:Q,children:r("supervisor.commander.metrics")}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{type:"button",onClick:()=>x("executions"),style:Pe,children:r("supervisor.commander.view_executions")??"View Executions"}),e.jsx("button",{type:"button",onClick:v,style:Ne,children:r("supervisor.commander.stop")})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12},children:[e.jsx(ge,{label:r("supervisor.commander.ticks"),value:String((o==null?void 0:o.tickCount)??0),sub:o!=null&&o.sessionId?`Session ${o.sessionId.slice(0,8)}`:void 0}),e.jsx(ge,{label:r("supervisor.commander.workers"),value:String((o==null?void 0:o.activeWorkers)??0),sub:t?`Max: ${t.maxConcurrentWorkers}`:void 0}),e.jsx(ge,{label:r("supervisor.commander.last_tick"),value:o!=null&&o.lastTickAt?we(o.lastTickAt):"--:--:--",valueStyle:{fontSize:16},sub:o!=null&&o.lastTickAt?Fe(o.lastTickAt):void 0})]})]}),t&&e.jsxs("div",{style:re,children:[e.jsx("div",{style:K,children:e.jsx("div",{style:Q,children:r("supervisor.commander.config")})}),e.jsxs("div",{style:He,children:[e.jsx(ee,{label:r("supervisor.commander.profile"),desc:r("supervisor.commander.profile_desc")??"Environment-specific behavior preset",children:e.jsx("select",{value:t.profile,onChange:i=>X({action:"commander:config",config:{profile:i.target.value}}),style:fe,children:["development","staging","production"].map(i=>e.jsx("option",{value:i,children:i},i))})}),e.jsx(ee,{label:r("supervisor.commander.decision_model"),desc:r("supervisor.commander.decision_model_desc")??"AI model for orchestration decisions",children:e.jsx("select",{value:t.decisionModel,onChange:i=>X({action:"commander:config",config:{decisionModel:i.target.value}}),style:fe,children:["haiku","sonnet","opus"].map(i=>e.jsx("option",{value:i,children:i},i))})}),e.jsx(ee,{label:r("supervisor.commander.auto_approve"),desc:r("supervisor.commander.auto_approve_desc")??"Confidence threshold for auto-approval",children:e.jsx("select",{value:t.autoApproveThreshold,onChange:i=>X({action:"commander:config",config:{autoApproveThreshold:i.target.value}}),style:fe,children:["low","medium","high"].map(i=>e.jsx("option",{value:i,children:i},i))})}),e.jsx(ee,{label:r("supervisor.commander.max_workers")??"Max Workers",desc:r("supervisor.commander.max_workers_desc")??"Maximum parallel agent executions",isLast:!0,children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",padding:"4px 10px"},children:t.maxConcurrentWorkers})})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{style:re,children:[e.jsxs("div",{style:K,children:[e.jsx("div",{style:Q,children:r("supervisor.commander.decision_history")}),e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r("supervisor.commander.decisions_count",{count:s.length})})]}),e.jsx("div",{style:ye,children:e.jsx("div",{style:{padding:"14px 16px"},children:s.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:16},children:r("supervisor.commander.no_decisions")}):s.slice().reverse().map((i,d,k)=>{const j=we(i.timestamp),f=i.actions.length>0?"var(--color-accent-green)":"var(--color-accent-gray)",I=d===k.length-1;return e.jsxs("div",{style:{display:"flex",gap:12,padding:"10px 0",position:"relative"},children:[!I&&e.jsx("div",{style:{position:"absolute",left:11,top:30,bottom:-10,width:1,background:"var(--color-border-divider)"}}),e.jsx("div",{style:qe,children:e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:f}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,fontFamily:"'SF Mono', Consolas, monospace",color:"var(--color-text-placeholder)"},children:j}),e.jsxs("div",{style:{fontSize:12,color:"var(--color-text-primary)"},children:[i.trigger," - ",i.actions.length," action",i.actions.length!==1?"s":""]}),i.deferred.length>0&&e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:[i.deferred.length," deferred"]})]})]},i.id)})})})]}),e.jsxs("div",{style:re,children:[e.jsx("div",{style:K,children:e.jsx("div",{style:Q,children:r("supervisor.commander.latest_assessment")})}),e.jsx("div",{style:ye,children:e.jsx("div",{style:{padding:"14px 16px"},children:p!=null&&p.assessment?e.jsxs(e.Fragment,{children:[p.assessment.observations.length>0&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:Ce,children:r("supervisor.commander.observations")}),e.jsx("div",{style:{fontSize:11,color:"var(--color-text-secondary)",paddingLeft:8,lineHeight:1.8},children:p.assessment.observations.map((i,d)=>e.jsxs("div",{children:["- ",i]},d))})]}),p.assessment.risks.length>0&&e.jsxs("div",{children:[e.jsx("div",{style:Ce,children:r("supervisor.commander.risks")}),e.jsx("div",{style:{fontSize:11,color:"var(--color-accent-red)",paddingLeft:8,lineHeight:1.8},children:p.assessment.risks.map((i,d)=>e.jsxs("div",{children:["- ",i]},d))})]})]}):e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:8},children:r("supervisor.commander.no_decisions")})})}),e.jsxs("div",{style:{marginTop:16},children:[e.jsxs("div",{style:K,children:[e.jsx("div",{style:Q,children:r("supervisor.commander.suggestions")??"Suggestions"}),y.length>0&&e.jsxs("span",{style:{fontSize:9,fontWeight:700,padding:"2px 8px",borderRadius:100,background:"var(--color-tint-verifying)",color:"var(--color-accent-orange)"},children:[y.length," new"]})]}),e.jsx("div",{style:ye,children:e.jsx("div",{style:{padding:"14px 16px"},children:y.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:8},children:r("supervisor.commander.no_suggestions")??"No suggestions"}):y.map((i,d)=>e.jsxs("div",{style:{display:"flex",gap:10,padding:"10px 0",borderBottom:d<y.length-1?"1px solid var(--color-border-divider)":"none"},children:[e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",marginTop:5,flexShrink:0,background:De[i.type]??"var(--color-accent-gray)"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:i.title}),e.jsxs("div",{style:{fontSize:11,color:"var(--color-text-secondary)",marginTop:1},children:[i.description," (",Math.round(i.confidence*100),"%)"]})]})]},d))})})]})]})]})]})}function ge({label:r,value:o,sub:t,valueStyle:n}){return e.jsxs("div",{style:Oe,children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:r}),e.jsx("div",{style:{fontSize:20,fontWeight:800,color:"var(--color-text-primary)",marginTop:2,...n},children:o}),t&&e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:t})]})}function ee({label:r,desc:o,children:t,isLast:n}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:n?"none":"1px solid var(--color-border-divider)"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:500,color:"var(--color-text-primary)"},children:r}),e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)",marginTop:2},children:o})]}),t]})}function we(r){const o=new Date(r);return`${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}:${String(o.getSeconds()).padStart(2,"0")}`}function Fe(r){const o=Math.floor((Date.now()-new Date(r).getTime())/1e3);return o<60?`${o}s ago`:o<3600?`${Math.floor(o/60)} min ago`:`${Math.floor(o/3600)}h ago`}const re={marginBottom:24},K={display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},Q={fontSize:13,fontWeight:700,color:"var(--color-text-primary)"},ye={background:"var(--color-bg-card)",borderRadius:12,border:"1px solid var(--color-border-divider)",overflow:"hidden"},Oe={background:"var(--color-bg-card)",borderRadius:10,padding:"14px 16px",border:"1px solid var(--color-border-divider)"},He={background:"var(--color-bg-card)",borderRadius:12,border:"1px solid var(--color-border-divider)",overflow:"hidden"},fe={fontSize:12,fontWeight:600,color:"var(--color-text-primary)",padding:"4px 10px",borderRadius:6,border:"1px solid var(--color-border)",background:"var(--color-bg-primary)",minWidth:100,textAlign:"center",cursor:"pointer"},qe={width:22,height:22,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"2px solid var(--color-bg-primary)"},Ce={fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".06em",color:"var(--color-text-tertiary)",marginBottom:6},Ie={fontSize:11,fontWeight:600,padding:"5px 12px",borderRadius:8,border:"1px solid var(--color-border)",background:"none",cursor:"pointer",color:"var(--color-text-secondary)",transition:"all 150ms"},Pe={...Ie},Ne={...Ie,color:"var(--color-accent-red)",borderColor:"var(--color-accent-red)"},Ye=["claude","gemini","codex","qwen","opencode"],oe={running:{bg:"var(--color-tint-running)",color:"var(--color-accent-blue)"},awaiting_clarification:{bg:"var(--color-tint-verifying)",color:"var(--color-accent-orange)"},completed:{bg:"var(--color-tint-completed)",color:"var(--color-accent-green)"},failed:{bg:"var(--color-tint-failed)",color:"var(--color-accent-red)"},paused:{bg:"var(--color-tint-pending)",color:"var(--color-accent-gray)"},idle:{bg:"var(--color-tint-pending)",color:"var(--color-accent-gray)"}},P={completed:{bg:"var(--color-tint-completed)",dot:"var(--color-accent-green)"},running:{bg:"var(--color-tint-running)",dot:"var(--color-accent-blue)"},pending:{bg:"transparent",dot:"var(--color-accent-gray)"},failed:{bg:"var(--color-tint-failed)",dot:"var(--color-accent-red)"},skipped:{bg:"var(--color-tint-pending)",dot:"var(--color-accent-gray)"}};function Ke(){const{t:r}=T(),o=_(l=>l.session),t=_(l=>l.selectedStepIndex),n=_(l=>l.clarificationQuestion),s=_(l=>l.start),x=_(l=>l.stop),a=_(l=>l.resume),v=_(l=>l.selectStep),p=_(l=>l.sendClarification),[y,i]=g.useState(""),[d,k]=g.useState("claude"),[j,f]=g.useState(!0),[I,$]=g.useState(""),[L,B]=g.useState(""),C=g.useRef(null),b=o!=null&&o.status!=="idle",u=b&&o.status==="running",E=(o==null?void 0:o.status)==="awaiting_clarification",w=(o==null?void 0:o.steps)??[],h=t!=null?w[t]??null:null,z=w.filter(l=>l.status==="completed"),F=w.length,he=F>0?Math.round(z.length/F*100):0,O=(o==null?void 0:o.avgQuality)??(z.length>0?z.reduce((l,S)=>l+(S.qualityScore??0),0)/z.length:null),H=g.useCallback(()=>{var q;if(!o||!w.length)return"--";const l=(q=w[0])==null?void 0:q.startedAt;if(!l)return"--";const S=Date.now()-new Date(l).getTime();if(S<0)return"--";const W=Math.floor(S/1e3),M=Math.floor(W/60),J=Math.floor(M/60);return J>0?`${J}h ${M%60}m`:M>0?`${M}m ${W%60}s`:`${W}s`},[o,w]);g.useEffect(()=>(u?(B(H()),C.current=setInterval(()=>B(H()),1e3)):(B(H()),C.current&&clearInterval(C.current)),()=>{C.current&&clearInterval(C.current)}),[u,H]),g.useEffect(()=>{if(!b||t!=null)return;const l=w.findIndex(S=>S.status==="running");l>=0?v(l):w.length>0&&v(0)},[b,w,t,v]);const G=()=>{y.trim()&&(s(y.trim(),d,j),i(""))},c=()=>{!I.trim()||!o||(p(o.sessionId,I.trim()),$(""))},Y=l=>{if(l.durationMs!=null){const S=Math.floor(l.durationMs/1e3),W=Math.floor(S/60);return W>0?`${W}m ${S%60}s`:`${S}s`}if(l.status==="running"&&l.startedAt){const S=Math.floor((Date.now()-new Date(l.startedAt).getTime())/1e3),W=Math.floor(S/60);return W>0?`${W}m ${S%60}s...`:`${S}s...`}return""},A=l=>l>=70?"var(--color-accent-green)":l>=40?"var(--color-accent-orange)":"var(--color-accent-red)",ke=l=>l>=70?"var(--color-tint-completed)":l>=40?"var(--color-tint-verifying)":"var(--color-tint-failed)",Le=l=>{switch(l){case"running":return"Running";case"awaiting_clarification":return"Needs Clarification";case"completed":return"Completed";case"failed":return"Failed";case"paused":return"Paused";default:return l}};return e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px 40px"},children:[e.jsxs("div",{style:V,children:[e.jsxs("div",{style:te,children:[e.jsx("div",{style:ne,children:r("supervisor.coordinator.title")}),b&&e.jsxs("div",{style:{display:"flex",gap:6},children:[u&&e.jsx("button",{type:"button",onClick:x,style:Ve,children:r("supervisor.coordinator.stop")}),(o.status==="paused"||o.status==="failed")&&e.jsx("button",{type:"button",onClick:()=>a(),style:Ue,children:r("supervisor.coordinator.resume")})]})]}),e.jsx("div",{style:Ge,children:e.jsxs("div",{style:Je,children:[e.jsx("input",{style:Xe,placeholder:r("supervisor.coordinator.describe_intent"),value:y,onChange:l=>i(l.target.value),onKeyDown:l=>{l.key==="Enter"&&G()}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[e.jsx("select",{style:Ze,value:d,onChange:l=>k(l.target.value),children:Ye.map(l=>e.jsx("option",{value:l,children:l},l))}),e.jsx("button",{type:"button",style:j?er:rr,onClick:()=>f(!j),children:r(j?"supervisor.coordinator.auto":"supervisor.coordinator.manual")}),e.jsx("button",{type:"button",style:Qe,onClick:G,children:r("supervisor.coordinator.start")})]})]})})]}),b&&e.jsxs("div",{style:V,children:[e.jsxs("div",{style:te,children:[e.jsx("div",{style:ne,children:"Session"}),e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"2px 8px",borderRadius:100,background:(oe[o.status]??oe.idle).bg,color:(oe[o.status]??oe.idle).color},children:Le(o.status)})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12},children:[e.jsxs("div",{style:ie,children:[e.jsx("div",{style:se,children:r("supervisor.coordinator.chain")}),e.jsx("div",{style:{...le,fontSize:16},children:o.chainName??"--"}),e.jsx("div",{style:ae,children:o.intent||"--"})]}),e.jsxs("div",{style:ie,children:[e.jsx("div",{style:se,children:r("supervisor.coordinator.progress")}),e.jsxs("div",{style:le,children:[z.length,e.jsxs("span",{style:{fontSize:13,fontWeight:500,color:"var(--color-text-tertiary)"},children:[" / ",F]})]}),e.jsx("div",{style:ae,children:e.jsx("div",{style:{height:3,background:"rgba(0,0,0,0.06)",borderRadius:100,overflow:"hidden",marginTop:4},children:e.jsx("div",{style:{height:"100%",borderRadius:100,background:"linear-gradient(90deg, var(--color-accent-blue), var(--color-accent-green))",width:`${he}%`,transition:"width 0.6s"}})})})]}),e.jsxs("div",{style:ie,children:[e.jsx("div",{style:se,children:r("supervisor.coordinator.avg_quality")}),e.jsx("div",{style:{...le,color:O!=null?A(O):"var(--color-text-primary)"},children:O!=null?O.toFixed(1):"--"}),e.jsx("div",{style:ae,children:z.length>0?r("supervisor.coordinator.from_steps",{count:z.length}):"--"})]}),e.jsxs("div",{style:ie,children:[e.jsx("div",{style:se,children:r("supervisor.coordinator.elapsed")}),e.jsx("div",{style:{...le,fontSize:16},children:L}),e.jsxs("div",{style:ae,children:[r("supervisor.coordinator.tool_label"),": ",o.tool??d]})]})]})]}),E&&n&&e.jsx("div",{style:V,children:e.jsxs("div",{style:or,children:[e.jsxs("div",{style:tr,children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),e.jsx("span",{style:nr,children:r("supervisor.coordinator.clarification_needed")})]}),e.jsxs("div",{style:{padding:"14px 16px"},children:[e.jsx("div",{style:ir,children:n}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{style:sr,placeholder:r("supervisor.coordinator.type_response"),value:I,onChange:l=>$(l.target.value),onKeyDown:l=>{l.key==="Enter"&&c()}}),e.jsxs("button",{type:"button",style:lr,onClick:c,children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),e.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]}),r("supervisor.coordinator.send")]})]})]})]})}),b&&w.length>0&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{style:V,children:[e.jsxs("div",{style:te,children:[e.jsx("div",{style:ne,children:r("supervisor.coordinator.chain_steps")}),e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r("supervisor.coordinator.steps_count",{count:F})})]}),e.jsx("div",{style:D,children:e.jsx("div",{style:{padding:"14px 16px"},children:w.map((l,S)=>{const W=P[l.status]??P.pending,M=t===S,J=S===w.length-1,q=Y(l);return e.jsxs("div",{onClick:()=>v(S),style:{display:"flex",gap:12,padding:"10px 8px",position:"relative",cursor:"pointer",background:M?"var(--color-bg-hover)":"transparent",borderRadius:M?8:0,margin:M?"0 -8px":"0"},children:[!J&&e.jsx("div",{style:{position:"absolute",left:M?19:11,top:30,bottom:-10,width:1,background:l.status==="completed"?"var(--color-accent-green)":"var(--color-border-divider)",opacity:l.status==="completed"?.4:1}}),e.jsx("div",{style:{width:22,height:22,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,background:W.bg,border:"2px solid var(--color-bg-primary)"},children:e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:W.dot,animation:l.status==="running"?"pulse 2s infinite":void 0}})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:l.cmd}),l.args&&e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:l.args}),(q||l.qualityScore!=null||l.status==="running")&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:3},children:[q&&e.jsx("span",{style:{fontSize:10,fontFamily:"'SF Mono', Consolas, monospace",color:"var(--color-text-placeholder)"},children:q}),l.qualityScore!=null&&e.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 7px",borderRadius:100,background:ke(l.qualityScore),color:A(l.qualityScore)},children:l.qualityScore}),l.status==="running"&&l.qualityScore==null&&e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"2px 8px",borderRadius:100,background:"var(--color-tint-running)",color:"var(--color-accent-blue)"},children:"running"})]})]})]},l.index)})})})]}),e.jsx("div",{style:V,children:h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:te,children:[e.jsxs("div",{style:ne,children:["Step ",(t??0)+1,": ",h.cmd]}),e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"2px 8px",borderRadius:100,background:(P[h.status]??P.pending).bg||"var(--color-tint-pending)",color:(P[h.status]??P.pending).dot},children:h.status})]}),h.status==="completed"&&h.qualityScore!=null&&e.jsx("div",{style:{marginBottom:16},children:e.jsxs("div",{style:D,children:[e.jsxs("div",{style:je,children:[e.jsx("span",{style:me,children:r("supervisor.coordinator.quality_score")}),e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"2px 8px",borderRadius:100,background:ke(h.qualityScore),color:A(h.qualityScore)},children:h.qualityScore})]}),e.jsx("div",{style:{padding:"14px 16px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[e.jsxs("div",{style:{width:48,height:48,position:"relative",flexShrink:0},children:[e.jsxs("svg",{viewBox:"0 0 36 36",width:"48",height:"48",style:{transform:"rotate(-90deg)"},children:[e.jsx("circle",{cx:"18",cy:"18",r:"15.9",fill:"none",stroke:"var(--color-bg-secondary)",strokeWidth:"5"}),e.jsx("circle",{cx:"18",cy:"18",r:"15.9",fill:"none",stroke:A(h.qualityScore),strokeWidth:"5",strokeLinecap:"round",strokeDasharray:"100",strokeDashoffset:100-h.qualityScore})]}),e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:800,color:"var(--color-text-primary)"},children:h.qualityScore})]}),h.summary&&e.jsx("div",{style:{flex:1,fontSize:11,color:"var(--color-text-secondary)",lineHeight:1.6},children:h.summary})]})})]})}),h.status==="completed"&&h.summary&&e.jsx("div",{style:{marginBottom:16},children:e.jsxs("div",{style:D,children:[e.jsx("div",{style:je,children:e.jsx("span",{style:me,children:r("supervisor.coordinator.summary")})}),e.jsx("div",{style:{padding:"14px 16px"},children:e.jsx("div",{style:{fontSize:12,color:"var(--color-text-primary)",lineHeight:1.7},children:h.summary})})]})}),(h.status==="running"||h.status==="completed")&&h.analysis&&e.jsx("div",{style:{marginBottom:16},children:e.jsxs("div",{style:D,children:[e.jsx("div",{style:je,children:e.jsx("span",{style:me,children:r("supervisor.coordinator.analysis")})}),e.jsx("pre",{style:ar,children:h.analysis})]})}),(h.status==="pending"||h.status==="skipped")&&e.jsx("div",{style:D,children:e.jsx("div",{style:{padding:"14px 16px"},children:e.jsxs("div",{style:{textAlign:"center",padding:"48px 20px",color:"var(--color-text-tertiary)"},children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.2,margin:"0 auto 10px",display:"block"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--color-text-secondary)"},children:r("supervisor.coordinator.waiting_execute")}),e.jsx("div",{style:{fontSize:11,marginTop:4,maxWidth:300,marginLeft:"auto",marginRight:"auto",lineHeight:1.6},children:r("supervisor.coordinator.pending_desc")})]})})})]}):e.jsx("div",{style:D,children:e.jsx("div",{style:{padding:"14px 16px"},children:e.jsx("div",{style:{textAlign:"center",padding:"48px 20px",color:"var(--color-text-tertiary)",fontSize:11},children:"Select a step to view details"})})})})]}),!b&&e.jsx("div",{style:D,children:e.jsx("div",{style:{padding:"14px 16px"},children:e.jsxs("div",{style:{textAlign:"center",padding:"48px 20px",color:"var(--color-text-tertiary)"},children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.2,margin:"0 auto 10px",display:"block"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 5.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.6a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--color-text-secondary)"},children:r("supervisor.coordinator.no_session")}),e.jsx("div",{style:{fontSize:11,marginTop:4,maxWidth:300,marginLeft:"auto",marginRight:"auto",lineHeight:1.6},children:r("supervisor.coordinator.no_session_desc")})]})})})]})}const V={marginBottom:24},te={display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},ne={fontSize:13,fontWeight:700,color:"var(--color-text-primary)"},D={background:"var(--color-bg-card)",borderRadius:12,border:"1px solid var(--color-border-divider)",overflow:"hidden"},je={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},me={fontSize:12,fontWeight:700,color:"var(--color-text-primary)"},ie={background:"var(--color-bg-card)",borderRadius:10,padding:"14px 16px",border:"1px solid var(--color-border-divider)"},se={fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},le={fontSize:20,fontWeight:800,color:"var(--color-text-primary)",marginTop:2},ae={fontSize:10,color:"var(--color-text-tertiary)"},Se={fontSize:11,fontWeight:600,padding:"5px 12px",borderRadius:8,border:"1px solid var(--color-border)",background:"none",cursor:"pointer",color:"var(--color-text-secondary)",transition:"all 150ms"},Qe={...Se,background:"var(--color-text-primary)",color:"#fff",borderColor:"var(--color-text-primary)"},Ve={...Se,color:"var(--color-accent-red)",borderColor:"var(--color-accent-red)"},Ue={...Se,color:"var(--color-accent-green)",borderColor:"var(--color-accent-green)"},Ge={background:"var(--color-bg-card)",borderRadius:12,border:"1px solid var(--color-border-divider)",overflow:"hidden"},Je={display:"flex",alignItems:"center",gap:10,padding:"10px 16px"},Xe={flex:1,border:"none",background:"transparent",fontSize:13,color:"var(--color-text-primary)",outline:"none",fontFamily:"inherit",lineHeight:1.5},Ze={padding:"4px 8px",borderRadius:6,fontSize:11,fontWeight:600,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-primary)",color:"var(--color-text-secondary)",cursor:"pointer",outline:"none"},er={fontSize:9,fontWeight:700,padding:"3px 8px",borderRadius:100,border:"none",cursor:"pointer",transition:"all 150ms",background:"var(--color-tint-completed)",color:"var(--color-accent-green)"},rr={fontSize:9,fontWeight:700,padding:"3px 8px",borderRadius:100,border:"none",cursor:"pointer",transition:"all 150ms",background:"var(--color-tint-pending)",color:"var(--color-accent-gray)"},or={background:"var(--color-bg-card)",borderRadius:12,border:"2px solid var(--color-accent-orange)",overflow:"hidden"},tr={display:"flex",alignItems:"center",gap:8,padding:"10px 16px",background:"var(--color-tint-verifying)",color:"var(--color-accent-orange)"},nr={fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:".04em"},ir={fontSize:12,color:"var(--color-text-primary)",lineHeight:1.6,marginBottom:10},sr={flex:1,padding:"7px 12px",fontSize:12,borderRadius:8,border:"1px solid var(--color-border)",background:"var(--color-bg-primary)",color:"var(--color-text-primary)",outline:"none"},lr={padding:"7px 14px",border:"none",borderRadius:8,background:"var(--color-accent-orange)",color:"#fff",fontSize:11,fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:4},ar={margin:0,padding:"14px 16px",fontSize:11,lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"'SF Mono', Consolas, monospace",background:"#2C2723",color:"#D9D0C4",borderRadius:"0 0 12px 12px",maxHeight:220,overflowY:"auto"};function dr(){const{t:r}=T(),o=m(d=>d.promptModes),t=m(d=>d.promptBindings),[n,s]=g.useState(null),[x,a]=g.useState(""),[v,p]=g.useState(""),y=v?o.filter(d=>d.toLowerCase().includes(v.toLowerCase())):o,i=d=>{s(d),a(t[d]??"")};return e.jsxs("div",{className:"flex h-full overflow-hidden",children:[e.jsxs("div",{style:{width:320,background:"var(--color-bg-primary)",borderRight:"1px solid var(--color-border)",flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--color-text-primary)"},children:r("supervisor.prompts.title")}),e.jsx("span",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r("supervisor.prompts.builders_count",{count:o.length})})]}),e.jsx("input",{value:v,onChange:d=>p(d.target.value),placeholder:r("supervisor.prompts.filter"),style:{margin:"10px 12px 6px",padding:"8px 12px",borderRadius:8,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-card)",fontSize:12,color:"var(--color-text-primary)",outline:"none"}}),e.jsx("div",{style:{flex:1,overflowY:"auto"},children:y.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:16},children:r(v?"supervisor.prompts.no_matches":"supervisor.prompts.no_modes")}):y.map(d=>{const k=d===n,j=!!t[d];return e.jsxs("button",{type:"button",onClick:()=>i(d),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 16px",cursor:"pointer",border:"none",width:"100%",textAlign:"left",background:k?"var(--color-tint-exploring)":"none",borderLeft:`3px solid ${k?"var(--color-accent-blue)":"transparent"}`,transition:"all 120ms"},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-planning)",color:"var(--color-accent-purple)",flexShrink:0},children:e.jsxs("svg",{style:{width:14,height:14,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 7 4 4 20 4 20 7"}),e.jsx("line",{x1:"9",y1:"20",x2:"15",y2:"20"}),e.jsx("line",{x1:"12",y1:"4",x2:"12",y2:"20"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:d}),e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r(j?"supervisor.prompts.bound":"supervisor.prompts.unbound")})]}),j&&e.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"2px 8px",borderRadius:100,background:"rgba(90,158,120,0.12)",color:"var(--color-accent-green)"},children:"active"})]},d)})})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column"},children:n?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--color-border-divider)",flexShrink:0},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-planning)",color:"var(--color-accent-purple)"},children:e.jsxs("svg",{style:{width:18,height:18,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 7 4 4 20 4 20 7"}),e.jsx("line",{x1:"9",y1:"20",x2:"15",y2:"20"}),e.jsx("line",{x1:"12",y1:"4",x2:"12",y2:"20"})]})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--color-text-primary)"},children:n}),e.jsx("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:r("supervisor.prompts.prompt_builder")})]})]})}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"flex",flexDirection:"column",gap:20},children:[e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r("supervisor.prompts.binding")})}),e.jsxs("div",{style:{padding:"14px 16px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 0",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:120,flexShrink:0},children:r("supervisor.prompts.mode")}),e.jsx("span",{style:{fontSize:12,color:"var(--color-text-primary)",fontWeight:500},children:n})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 0"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:120,flexShrink:0},children:r("supervisor.prompts.status")}),e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:t[n]?"rgba(90,158,120,0.12)":"rgba(160,157,151,0.12)",color:t[n]?"var(--color-accent-green)":"var(--color-accent-gray)"},children:t[n]?r("supervisor.prompts.bound"):r("supervisor.prompts.unbound")})]})]})]}),e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r("supervisor.prompts.template")})}),e.jsx("div",{style:{padding:"14px 16px"},children:e.jsx("textarea",{value:x,onChange:d=>a(d.target.value),placeholder:r("supervisor.prompts.edit_placeholder"),style:{width:"100%",minHeight:160,resize:"vertical",borderRadius:8,padding:12,fontSize:12,fontFamily:"'SF Mono', Consolas, monospace",lineHeight:1.6,background:"var(--color-bg-secondary)",color:"var(--color-text-primary)",border:"1px solid var(--color-border-divider)",outline:"none"}})})]}),x&&e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r("supervisor.prompts.preview")})}),e.jsx("div",{style:{padding:0},children:e.jsx("pre",{style:{margin:0,padding:16,fontSize:11,lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"'SF Mono', Consolas, monospace",maxHeight:200,overflowY:"auto",background:"var(--color-text-primary)",color:"#d4d0ca",borderRadius:"0 0 12px 12px"},children:x})})]})]})]}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",fontSize:13},children:r("supervisor.prompts.select_detail")})})]})}const pe={strategy:{bg:"var(--color-tint-exploring)",fg:"var(--color-accent-blue)"},builder:{bg:"var(--color-tint-completed)",fg:"var(--color-accent-green)"},adapter:{bg:"var(--color-tint-verifying)",fg:"var(--color-accent-orange)"},task:{bg:"var(--color-tint-planning)",fg:"var(--color-accent-purple)"},tool:{bg:"var(--color-tint-pending)",fg:"var(--color-accent-gray)"}},xe={strategy:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),e.jsx("path",{d:"M2 17l10 5 10-5"}),e.jsx("path",{d:"M2 12l10 5 10-5"})]}),builder:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),e.jsx("line",{x1:"9",y1:"21",x2:"9",y2:"9"})]}),adapter:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"16 18 22 12 16 6"}),e.jsx("polyline",{points:"8 6 2 12 8 18"})]}),task:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),tool:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09"})]})};function cr(){const{t:r}=T(),o=m(p=>p.extensions),[t,n]=g.useState(null),[s,x]=g.useState(""),a=s?o.filter(p=>p.name.toLowerCase().includes(s.toLowerCase())||p.type.toLowerCase().includes(s.toLowerCase())):o,v=o.find(p=>p.name===t)??null;return e.jsxs("div",{className:"flex h-full overflow-hidden",children:[e.jsxs("div",{style:{width:320,background:"var(--color-bg-primary)",borderRight:"1px solid var(--color-border)",flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--color-text-primary)"},children:r("supervisor.extensions.title")}),e.jsx("span",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r("supervisor.extensions.loaded_count",{count:o.length})})]}),e.jsx("input",{value:s,onChange:p=>x(p.target.value),placeholder:r("supervisor.extensions.filter"),style:{margin:"10px 12px 6px",padding:"8px 12px",borderRadius:8,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-card)",fontSize:12,color:"var(--color-text-primary)",outline:"none"}}),e.jsx("div",{style:{flex:1,overflowY:"auto"},children:a.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:16},children:r(s?"supervisor.extensions.no_matches":"supervisor.extensions.no_extensions")}):a.map(p=>{const y=p.name===t,i=pe[p.type]??pe.tool;return e.jsxs("button",{type:"button",onClick:()=>n(p.name),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 16px",cursor:"pointer",border:"none",width:"100%",textAlign:"left",background:y?"var(--color-tint-exploring)":"none",borderLeft:`3px solid ${y?"var(--color-accent-blue)":"transparent"}`,transition:"all 120ms"},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:i.bg,color:i.fg,flexShrink:0},children:e.jsx("span",{style:{width:14,height:14,strokeWidth:1.8,display:"flex"},children:xe[p.type]??xe.tool})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:p.name}),e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)",display:"flex",gap:8},children:[e.jsxs("span",{children:["v",p.version]}),e.jsx("span",{children:p.type})]})]}),e.jsx("div",{style:{flexShrink:0},children:e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",display:"inline-block",background:p.status==="enabled"?"var(--color-accent-green)":"var(--color-text-tertiary)"}})})]},p.name)})})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column"},children:v?e.jsx(pr,{ext:v}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",fontSize:13},children:r("supervisor.extensions.select_detail")})})]})}function pr({ext:r}){const{t:o}=T(),t=pe[r.type]??pe.tool;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--color-border-divider)",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:t.bg,color:t.fg},children:e.jsx("span",{style:{width:18,height:18,strokeWidth:1.8,display:"flex"},children:xe[r.type]??xe.tool})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--color-text-primary)"},children:r.name}),e.jsxs("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:["v",r.version]})]})]}),e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:r.status==="enabled"?"rgba(90,158,120,0.12)":"rgba(160,157,151,0.12)",color:r.status==="enabled"?"var(--color-accent-green)":"var(--color-accent-gray)"},children:r.status})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"flex",flexDirection:"column",gap:20},children:[e.jsx(ze,{title:o("supervisor.extensions.about"),children:e.jsx("div",{style:{fontSize:12,color:"var(--color-text-primary)",lineHeight:1.6},children:r.description||o("supervisor.extensions.no_description")})}),e.jsxs(ze,{title:o("supervisor.extensions.details"),children:[e.jsx(de,{label:o("supervisor.extensions.name"),value:r.name}),e.jsx(de,{label:o("supervisor.extensions.version"),value:r.version}),e.jsx(de,{label:o("supervisor.extensions.type"),value:r.type}),e.jsx(de,{label:o("supervisor.extensions.status"),value:r.status})]})]})]})}function ze({title:r,children:o}){return e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r})}),e.jsx("div",{style:{padding:"14px 16px"},children:o})]})}function de({label:r,value:o}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 0",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:120,flexShrink:0},children:r}),e.jsx("span",{style:{fontSize:12,color:"var(--color-text-primary)",fontWeight:500},children:o})]})}const xr={optimize:"var(--color-accent-blue)",alert:"var(--color-accent-red)",automate:"var(--color-accent-green)"};function ur(){const{t:r}=T(),o=m(i=>i.learningStats),t=m(i=>i.learningPatterns),n=m(i=>i.knowledgeEntries),[s,x]=g.useState(""),[a,v]=g.useState(null),p=s?n.filter(i=>i.topic.toLowerCase().includes(s.toLowerCase())||i.content.toLowerCase().includes(s.toLowerCase())||i.tags.some(d=>d.toLowerCase().includes(s.toLowerCase()))):n,y=t.reduce((i,d)=>Math.max(i,d.frequency),1);return e.jsxs("div",{className:"flex h-full overflow-hidden",children:[e.jsxs("div",{style:{width:320,background:"var(--color-bg-primary)",borderRight:"1px solid var(--color-border)",flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--color-text-primary)"},children:r("supervisor.learning.title")}),o&&e.jsx("span",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r("supervisor.learning.cmds_patterns",{cmds:o.totalCommands,patterns:o.uniquePatterns})})]}),e.jsx("input",{value:s,onChange:i=>x(i.target.value),placeholder:r("supervisor.learning.search"),style:{margin:"10px 12px 6px",padding:"8px 12px",borderRadius:8,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-card)",fontSize:12,color:"var(--color-text-primary)",outline:"none"}}),e.jsxs("div",{style:{flex:1,overflowY:"auto"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".06em",color:"var(--color-text-tertiary)",padding:"10px 16px 4px"},children:r("supervisor.learning.command_patterns")}),t.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:12},children:r("supervisor.learning.no_patterns")}):t.map(i=>{const d=(a==null?void 0:a.type)==="pattern"&&a.data.command===i.command;return e.jsxs("button",{type:"button",onClick:()=>v({type:"pattern",data:i}),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 16px",cursor:"pointer",border:"none",width:"100%",textAlign:"left",background:d?"var(--color-tint-exploring)":"none",borderLeft:`3px solid ${d?"var(--color-accent-blue)":"transparent"}`,transition:"all 120ms"},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-exploring)",color:"var(--color-accent-blue)",flexShrink:0},children:e.jsxs("svg",{style:{width:14,height:14,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 17 10 11 4 5"}),e.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i.command}),e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)",display:"flex",gap:8},children:[e.jsxs("span",{children:["x",i.frequency]}),e.jsxs("span",{children:[Math.round(i.successRate*100),"% ",r("supervisor.learning.success_label")]})]})]})]},i.command)}),e.jsxs("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".06em",color:"var(--color-text-tertiary)",padding:"10px 16px 4px"},children:[r("supervisor.learning.knowledge_base")," (",p.length,")"]}),p.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:12},children:r(s?"supervisor.learning.no_matches":"supervisor.learning.empty")}):p.map(i=>{const d=(a==null?void 0:a.type)==="knowledge"&&a.data.id===i.id;return e.jsxs("button",{type:"button",onClick:()=>v({type:"knowledge",data:i}),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 16px",cursor:"pointer",border:"none",width:"100%",textAlign:"left",background:d?"var(--color-tint-exploring)":"none",borderLeft:`3px solid ${d?"var(--color-accent-blue)":"transparent"}`,transition:"all 120ms"},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-completed)",color:"var(--color-accent-green)",flexShrink:0},children:e.jsxs("svg",{style:{width:14,height:14,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"}),e.jsx("path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i.topic}),e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)",display:"flex",gap:8},children:[e.jsx("span",{children:i.source}),e.jsx("span",{children:r("supervisor.learning.used_count",{count:i.usageCount})})]})]})]},i.id)})]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column"},children:a?a.type==="pattern"?e.jsx(vr,{pattern:a.data,maxFrequency:y,suggestions:(o==null?void 0:o.suggestions)??[]}):e.jsx(hr,{entry:a.data}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",fontSize:13},children:r("supervisor.learning.select_detail")})})]})}function vr({pattern:r,maxFrequency:o,suggestions:t}){const{t:n}=T(),s=Math.round(r.frequency/o*100),x=r.successRate>=.9?"var(--color-accent-green)":r.successRate>=.7?"var(--color-accent-blue)":"var(--color-accent-yellow)";return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--color-border-divider)",flexShrink:0},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-exploring)",color:"var(--color-accent-blue)"},children:e.jsxs("svg",{style:{width:18,height:18,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 17 10 11 4 5"}),e.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--color-text-primary)"},children:r.command}),e.jsx("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:n("supervisor.learning.command_pattern")})]})]})}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"flex",flexDirection:"column",gap:20},children:[e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsx(N,{label:n("supervisor.learning.frequency"),value:String(r.frequency)}),e.jsx(N,{label:n("supervisor.learning.success_rate"),value:`${Math.round(r.successRate*100)}%`,valueColor:x}),e.jsx(N,{label:n("supervisor.learning.avg_duration"),value:`${Math.round(r.avgDuration/1e3)}s`})]}),e.jsxs(U,{title:n("supervisor.learning.usage"),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"8px 0"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:80},children:n("supervisor.learning.relative")}),e.jsx("div",{style:{flex:1,height:6,background:"rgba(0,0,0,0.04)",borderRadius:100,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${s}%`,borderRadius:100,background:x}})}),e.jsxs("span",{style:{fontSize:11,color:"var(--color-text-tertiary)"},children:[s,"%"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 0",borderTop:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:120},children:n("supervisor.learning.last_used")}),e.jsx("span",{style:{fontSize:12,color:"var(--color-text-primary)",fontWeight:500},children:r.lastUsed?new Date(r.lastUsed).toLocaleString():"-"})]})]}),r.contexts&&r.contexts.length>0&&e.jsx(U,{title:n("supervisor.learning.contexts"),children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:r.contexts.map(a=>e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:"rgba(145,120,181,0.12)",color:"var(--color-accent-purple)"},children:a},a))})}),t.length>0&&e.jsx(U,{title:n("supervisor.learning.suggestions"),children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:t.map((a,v)=>e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:xr[a.type]??"var(--color-bg-tertiary)",color:"#fff",flexShrink:0},children:a.type}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:a.title}),e.jsx("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:a.description})]})]},v))})})]})]})}function hr({entry:r}){const{t:o}=T();return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--color-border-divider)",flexShrink:0},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-completed)",color:"var(--color-accent-green)"},children:e.jsxs("svg",{style:{width:18,height:18,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"}),e.jsx("path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"})]})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--color-text-primary)"},children:r.topic}),e.jsxs("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:[o("supervisor.learning.knowledge_entry")," - ",r.source]})]})]})}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"flex",flexDirection:"column",gap:20},children:[e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsx(N,{label:o("supervisor.learning.usage_count"),value:String(r.usageCount)}),e.jsx(N,{label:o("supervisor.learning.source"),value:r.source}),e.jsx(N,{label:o("supervisor.learning.last_accessed"),value:r.lastAccessed?new Date(r.lastAccessed).toLocaleDateString():"-"})]}),e.jsx(U,{title:o("supervisor.learning.content"),children:e.jsx("div",{style:{fontSize:12,color:"var(--color-text-primary)",lineHeight:1.6,whiteSpace:"pre-wrap"},children:r.content})}),r.tags.length>0&&e.jsx(U,{title:o("supervisor.learning.tags"),children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:r.tags.map(t=>e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:"rgba(91,141,184,0.12)",color:"var(--color-accent-blue)"},children:t},t))})})]})]})}function N({label:r,value:o,valueColor:t}){return e.jsxs("div",{style:{flex:1,background:"var(--color-bg-primary)",borderRadius:10,padding:14,border:"1px solid var(--color-border-divider)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:r}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:t??"var(--color-text-primary)",marginTop:2},children:o})]})}function U({title:r,children:o}){return e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r})}),e.jsx("div",{style:{padding:"14px 16px"},children:o})]})}const gr=["auto-dispatch","cleanup","report","health-check","learning-analysis","custom"],ue={"auto-dispatch":{bg:"var(--color-tint-verifying)",fg:"var(--color-accent-orange)"},cleanup:{bg:"var(--color-tint-exploring)",fg:"var(--color-accent-blue)"},report:{bg:"var(--color-tint-planning)",fg:"var(--color-accent-purple)"},"health-check":{bg:"var(--color-tint-completed)",fg:"var(--color-accent-green)"},"learning-analysis":{bg:"var(--color-tint-executing)",fg:"var(--color-accent-yellow)"},custom:{bg:"var(--color-tint-pending)",fg:"var(--color-accent-gray)"}},ve={"auto-dispatch":e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"13 17 18 12 13 7"}),e.jsx("polyline",{points:"6 17 11 12 6 7"})]}),cleanup:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),report:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]}),"health-check":e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),"learning-analysis":e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"}),e.jsx("path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"})]}),custom:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09"})]})};function yr(){const{t:r}=T(),o=m(u=>u.scheduledTasks),t=m(u=>u.createSchedule),n=m(u=>u.deleteSchedule),s=m(u=>u.toggleSchedule),x=m(u=>u.runSchedule),[a,v]=g.useState(null),[p,y]=g.useState(""),[i,d]=g.useState(!1),[k,j]=g.useState(""),[f,I]=g.useState(""),[$,L]=g.useState("custom"),B=p?o.filter(u=>u.name.toLowerCase().includes(p.toLowerCase())):o,C=o.find(u=>u.id===a)??null,b=async()=>{!k.trim()||!f.trim()||(await t({name:k.trim(),cronExpression:f.trim(),taskType:$,config:{},enabled:!0}),j(""),I(""),L("custom"),d(!1))};return e.jsxs("div",{className:"flex h-full overflow-hidden",children:[e.jsxs("div",{style:{width:320,background:"var(--color-bg-primary)",borderRight:"1px solid var(--color-border)",flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--color-text-primary)"},children:r("supervisor.schedule.title")}),e.jsx("button",{type:"button",onClick:()=>d(!i),style:{fontSize:12,fontWeight:600,padding:"7px 16px",borderRadius:8,border:"none",cursor:"pointer",background:"var(--color-text-primary)",color:"#fff"},children:r(i?"supervisor.schedule.cancel":"supervisor.schedule.new")})]}),i&&e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)",display:"flex",flexDirection:"column",gap:8},children:[e.jsx("input",{value:k,onChange:u=>j(u.target.value),placeholder:r("supervisor.schedule.task_name"),style:{...be}}),e.jsx("input",{value:f,onChange:u=>I(u.target.value),placeholder:"*/5 * * * *",style:{...be,fontFamily:"'SF Mono', Consolas, monospace"}}),e.jsx("select",{value:$,onChange:u=>L(u.target.value),style:{...be},children:gr.map(u=>e.jsx("option",{value:u,children:u},u))}),e.jsx("button",{type:"button",onClick:b,disabled:!k.trim()||!f.trim(),style:{fontSize:12,fontWeight:600,padding:"7px 16px",borderRadius:8,border:"none",cursor:"pointer",background:"var(--color-accent-green)",color:"#fff",opacity:!k.trim()||!f.trim()?.4:1},children:r("supervisor.schedule.create")})]}),e.jsx("input",{value:p,onChange:u=>y(u.target.value),placeholder:r("supervisor.schedule.filter"),style:{margin:"10px 12px 6px",padding:"8px 12px",borderRadius:8,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-card)",fontSize:12,color:"var(--color-text-primary)",outline:"none"}}),e.jsx("div",{style:{flex:1,overflowY:"auto"},children:B.map(u=>{const E=u.id===a,w=ue[u.taskType]??ue.custom;return e.jsxs("button",{type:"button",onClick:()=>v(u.id),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 16px",cursor:"pointer",border:"none",background:E?"var(--color-tint-exploring)":"none",borderLeft:`3px solid ${E?"var(--color-accent-blue)":"transparent"}`,width:"100%",textAlign:"left",transition:"all 120ms"},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:w.bg,color:w.fg,flexShrink:0},children:e.jsx("span",{style:{width:14,height:14,strokeWidth:1.8,display:"flex"},children:ve[u.taskType]??ve.custom})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.name}),e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)",display:"flex",gap:8},children:[e.jsx("span",{style:{fontFamily:"'SF Mono', Consolas, monospace"},children:u.cronExpression}),u.lastRun&&e.jsx("span",{children:mr(u.lastRun)})]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:2,flexShrink:0},children:e.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"2px 8px",borderRadius:100,background:u.enabled?"rgba(90,158,120,0.12)":"rgba(160,157,151,0.12)",color:u.enabled?"var(--color-accent-green)":"var(--color-accent-gray)"},children:u.enabled?r("supervisor.schedule.active"):r("supervisor.schedule.paused")})})]},u.id)})})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column"},children:C?e.jsx(fr,{task:C,onToggle:s,onRun:x,onDelete:n}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",fontSize:13},children:r("supervisor.schedule.select_detail")})})]})}function fr({task:r,onToggle:o,onRun:t,onDelete:n}){const{t:s}=T(),x=ue[r.taskType]??ue.custom;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--color-border-divider)",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:x.bg,color:x.fg},children:e.jsx("span",{style:{width:18,height:18,strokeWidth:1.8,display:"flex"},children:ve[r.taskType]??ve.custom})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--color-text-primary)"},children:r.name}),e.jsx("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:r.taskType})]})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{type:"button",onClick:()=>t(r.id),style:{...Re},children:s("supervisor.schedule.run_now")}),e.jsx(jr,{on:r.enabled,onToggle:()=>o(r.id,!r.enabled)}),e.jsx("button",{type:"button",onClick:()=>n(r.id),style:{...Re,color:"var(--color-accent-red)"},children:s("supervisor.schedule.delete")})]})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"flex",flexDirection:"column",gap:20},children:[e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsxs("div",{style:{flex:1,background:"var(--color-bg-primary)",borderRadius:10,padding:14,border:"1px solid var(--color-border-divider)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:s("supervisor.schedule.total_runs")}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:"var(--color-text-primary)",marginTop:2},children:r.history.length})]}),e.jsxs("div",{style:{flex:1,background:"var(--color-bg-primary)",borderRadius:10,padding:14,border:"1px solid var(--color-border-divider)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:s("supervisor.schedule.success_rate")}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:"var(--color-accent-green)",marginTop:2},children:r.history.length>0?`${Math.round(r.history.filter(a=>a.status==="success").length/r.history.length*100)}%`:"-"})]}),e.jsxs("div",{style:{flex:1,background:"var(--color-bg-primary)",borderRadius:10,padding:14,border:"1px solid var(--color-border-divider)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:s("supervisor.schedule.next_run")}),e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--color-text-primary)",marginTop:6},children:r.nextRun?new Date(r.nextRun).toLocaleString():"-"})]})]}),e.jsxs(We,{title:s("supervisor.schedule.configuration"),children:[e.jsx(ce,{label:s("supervisor.schedule.schedule_label"),value:r.cronExpression,mono:!0}),e.jsx(ce,{label:s("supervisor.schedule.type"),value:r.taskType}),e.jsx(ce,{label:s("supervisor.schedule.last_run"),value:r.lastRun?new Date(r.lastRun).toLocaleString():s("supervisor.schedule.never")}),Object.entries(r.config).map(([a,v])=>e.jsx(ce,{label:a,value:String(v)},a))]}),e.jsx(We,{title:s("supervisor.schedule.run_history"),children:r.history.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:"8px 0"},children:s("supervisor.schedule.no_runs")}):e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:r.history.slice(-10).reverse().map((a,v)=>{const p=a.status==="success"?"var(--color-accent-green)":a.status==="failed"?"var(--color-accent-red)":"var(--color-accent-gray)";return e.jsxs("div",{style:{display:"flex",gap:12,padding:"8px 0",position:"relative"},children:[v<Math.min(r.history.length,10)-1&&e.jsx("div",{style:{position:"absolute",left:11,top:24,bottom:-8,width:1,background:"var(--color-border-divider)"}}),e.jsx("div",{style:{width:22,height:22,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"2px solid var(--color-bg-card)"},children:e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:p}})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:10,color:"var(--color-text-placeholder)",fontFamily:"'SF Mono', Consolas, monospace"},children:new Date(a.timestamp).toLocaleString()}),e.jsx("div",{style:{fontSize:12,color:"var(--color-text-primary)"},children:a.status}),a.duration!=null&&e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:[Math.round(a.duration/1e3),"s"]})]})]},v)})})})]})]})}function We({title:r,children:o}){return e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r})}),e.jsx("div",{style:{padding:"14px 16px"},children:o})]})}function ce({label:r,value:o,mono:t}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 0",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:120,flexShrink:0},children:r}),e.jsx("span",{style:{fontSize:12,color:"var(--color-text-primary)",fontWeight:500,fontFamily:t?"'SF Mono', Consolas, monospace":void 0},children:o})]})}function jr({on:r,onToggle:o}){return e.jsx("button",{type:"button",onClick:o,style:{width:36,height:20,borderRadius:100,background:r?"var(--color-accent-green)":"var(--color-border)",border:"none",cursor:"pointer",position:"relative",transition:"background 200ms"},children:e.jsx("span",{style:{position:"absolute",top:2,left:r?18:2,width:16,height:16,borderRadius:"50%",background:"#fff",transition:"left 200ms",boxShadow:"0 1px 3px rgba(0,0,0,0.15)"}})})}function mr(r){const o=Date.now()-new Date(r).getTime(),t=Math.floor(o/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;const n=Math.floor(t/60);return n<24?`${n}h ago`:new Date(r).toLocaleDateString()}const be={padding:"8px 12px",borderRadius:8,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-card)",fontSize:12,color:"var(--color-text-primary)",outline:"none"},Re={fontSize:11,fontWeight:600,padding:"5px 12px",borderRadius:8,border:"1px solid var(--color-border)",background:"none",color:"var(--color-text-secondary)",cursor:"pointer"},Te=[{id:"commander",labelKey:"supervisor.tabs.commander",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),e.jsx("path",{d:"M2 17l10 5 10-5"}),e.jsx("path",{d:"M2 12l10 5 10-5"})]})},{id:"executions",labelKey:"supervisor.tabs.executions",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]})},{id:"schedule",labelKey:"supervisor.tabs.schedules",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]})},{id:"learning",labelKey:"supervisor.tabs.learning",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"}),e.jsx("path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"})]})},{id:"extensions",labelKey:"supervisor.tabs.extensions",icon:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M14.7 6.3a1 1 0 000 1.4l1.6 1.6a1 1 0 001.4 0l3.77-3.77a6 6 0 01-7.94 7.94l-6.91 6.91a2.12 2.12 0 01-3-3l6.91-6.91a6 6 0 017.94-7.94l-3.76 3.76z"})})},{id:"prompts",labelKey:"supervisor.tabs.prompts",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 7 4 4 20 4 20 7"}),e.jsx("line",{x1:"9",y1:"20",x2:"15",y2:"20"}),e.jsx("line",{x1:"12",y1:"4",x2:"12",y2:"20"})]})},{id:"coordinator",labelKey:"supervisor.tabs.coordinator",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}];function Sr(){const{t:r}=T(),o=m(c=>c.activeTab),t=m(c=>c.setActiveTab),n=m(c=>c.fetchLearningStats),s=m(c=>c.fetchSchedules),x=m(c=>c.fetchExtensions),a=m(c=>c.fetchPromptModes),v=m(c=>c.scheduledTasks),p=m(c=>c.extensions),y=R(c=>c.slots),i=R(c=>c.queue),d=R(c=>c.supervisorStatus),k=R(c=>c.toggleSupervisor),j=R(c=>c.commanderState),f=_(c=>c.session),I=_(c=>c.start),$=_(c=>c.stop),[L,B]=g.useState(!1);g.useEffect(()=>{n(),s(),x(),a()},[n,s,x,a]);const C=g.useMemo(()=>Object.values(y),[y]),b=(d==null?void 0:d.enabled)??!1,u=(d==null?void 0:d.stats.totalDispatched)??0,E=(d==null?void 0:d.stats.totalCompleted)??0,w=u>0?`${Math.round(E/u*100)}%`:"-",h=f!=null&&f.status!=="idle"&&f.status!=="completed"&&f.status!=="failed",z=(f==null?void 0:f.steps)??[],F=z.filter(c=>c.status==="completed"||c.status==="skipped").length,he=g.useCallback(async()=>{await k(!b)},[k,b]),O=g.useCallback(()=>{h?$():I("continue",void 0,!0)},[h,$,I]),H=g.useCallback(c=>{t(c),B(!1)},[t]),G={schedule:v.length,extensions:p.length};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",background:"var(--color-bg-primary)"},children:[e.jsx("nav",{style:{flexShrink:0,display:"flex",alignItems:"center",padding:"0 24px",background:"var(--color-bg-secondary)",borderBottom:"1px solid var(--color-border)"},children:Te.map(c=>{const Y=o===c.id,A=G[c.id]??0;return e.jsxs("button",{type:"button",onClick:()=>t(c.id),style:{display:"flex",alignItems:"center",gap:6,padding:"10px 16px",fontSize:12,fontWeight:Y?600:500,color:Y?"var(--color-text-primary)":"var(--color-text-tertiary)",background:"none",border:"none",borderBottom:`2px solid ${Y?"var(--color-text-primary)":"transparent"}`,cursor:"pointer",transition:"color 120ms, border-color 120ms"},children:[e.jsx("span",{style:{width:14,height:14,display:"flex"},children:c.icon}),r(c.labelKey),A>0&&e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"1px 6px",borderRadius:100,background:"var(--color-bg-card)",color:"var(--color-text-tertiary)"},children:A})]},c.id)})}),e.jsxs("main",{style:{flex:1,minHeight:0,overflow:"hidden"},children:[o==="commander"&&e.jsx(Ee,{}),o==="executions"&&e.jsx(Ae,{}),o==="coordinator"&&e.jsx(Ke,{}),o==="prompts"&&e.jsx(dr,{}),o==="extensions"&&e.jsx(cr,{}),o==="learning"&&e.jsx(ur,{}),o==="schedule"&&e.jsx(yr,{})]}),L&&e.jsx("div",{onClick:()=>B(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.25)",zIndex:90,transition:"opacity 200ms"}}),e.jsxs("div",{style:{position:"fixed",left:0,right:0,bottom:36,maxHeight:L?"60vh":0,overflow:"hidden",background:"var(--color-bg-card)",borderTop:L?"1px solid var(--color-border)":"none",borderRadius:"12px 12px 0 0",zIndex:91,transition:"max-height 300ms cubic-bezier(0.4,0,0.2,1)",boxShadow:L?"0 -4px 24px rgba(0,0,0,0.08)":"none"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"8px 0 4px",cursor:"pointer"},onClick:()=>B(!1),children:e.jsx("div",{style:{width:32,height:4,borderRadius:2,background:"var(--color-border)"}})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"180px 1fr 1fr",gap:16,padding:"8px 24px 24px",overflowY:"auto",maxHeight:"calc(60vh - 40px)"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)",padding:"4px 8px",marginBottom:4},children:"Navigate"}),Te.map(c=>e.jsxs("button",{type:"button",onClick:()=>H(c.id),style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",fontSize:12,fontWeight:o===c.id?600:400,color:o===c.id?"var(--color-text-primary)":"var(--color-text-secondary)",background:o===c.id?"var(--color-bg-active)":"none",border:"none",borderRadius:6,cursor:"pointer",textAlign:"left",transition:"background 120ms"},children:[e.jsx("span",{style:{width:14,height:14,display:"flex"},children:c.icon}),r(c.labelKey)]},c.id))]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{borderRadius:10,border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--color-border-divider)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--color-accent-blue)"},children:"Issue Executions"}),e.jsxs("span",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:[C.length," running"]})]}),e.jsx("div",{style:{padding:"8px 14px"},children:C.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",padding:"4px 0"},children:"No active slots"}):C.slice(0,5).map(c=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 0",fontSize:11},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--color-accent-blue)",flexShrink:0}}),e.jsx("span",{style:{fontWeight:500,color:"var(--color-text-primary)"},children:c.issueId}),e.jsx("span",{style:{color:"var(--color-text-tertiary)",marginLeft:"auto"},children:c.executor})]},c.processId))})]}),e.jsxs("div",{style:{borderRadius:10,border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--color-border-divider)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--color-accent-purple)"},children:"Workflow Sessions"}),e.jsx("span",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:f?f.status:"idle"})]}),e.jsx("div",{style:{padding:"8px 14px"},children:f?e.jsxs("div",{style:{fontSize:11},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 0"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--color-text-primary)"},children:f.chainName??"Session"}),e.jsxs("span",{style:{color:"var(--color-text-tertiary)"},children:["Step ",f.currentStep+1,"/",z.length]})]}),f.intent&&e.jsx("div",{style:{color:"var(--color-text-secondary)",padding:"2px 0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.intent})]}):e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",padding:"4px 0"},children:"No active session"})})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{borderRadius:10,border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--color-text-primary)"},children:"Commander"})}),e.jsxs("div",{style:{padding:"8px 14px",fontSize:11},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 0"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--color-text-secondary)"},children:"Status:"}),e.jsx("span",{style:{fontWeight:600,color:(j==null?void 0:j.status)==="dispatching"?"var(--color-accent-green)":(j==null?void 0:j.status)==="thinking"?"var(--color-accent-blue)":"var(--color-text-tertiary)"},children:(j==null?void 0:j.status)??"idle"})]}),(d==null?void 0:d.isCommanderActive)!==void 0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 0"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--color-text-secondary)"},children:"Active:"}),e.jsx("span",{style:{color:d.isCommanderActive?"var(--color-accent-green)":"var(--color-text-tertiary)"},children:d.isCommanderActive?"Yes":"No"})]})]})]}),e.jsxs("div",{style:{borderRadius:10,border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--color-text-primary)"},children:"Suggestions"})}),e.jsx("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--color-text-tertiary)"},children:"No suggestions"})]})]})]})]}),e.jsxs("footer",{style:{flexShrink:0,display:"flex",alignItems:"center",height:36,padding:"0 16px",background:"var(--color-bg-secondary)",borderTop:"1px solid var(--color-border)",gap:12,fontSize:11,zIndex:92},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontWeight:600,color:"var(--color-text-primary)"},children:"Supervisor"}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:b?"rgba(90,158,120,0.12)":"rgba(160,157,151,0.12)",color:b?"var(--color-accent-green)":"var(--color-accent-gray)"},children:[b&&e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--color-accent-green)",animation:"pulse 2s ease-in-out infinite"}}),b?"Active":"Inactive"]})]}),e.jsx("div",{style:{width:1,height:16,background:"var(--color-border-divider)"}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,color:"var(--color-accent-blue)"},children:"Issues"}),e.jsxs("span",{style:{color:"var(--color-text-secondary)"},children:[C.length," running"]}),e.jsxs("span",{style:{color:"var(--color-text-tertiary)"},children:[i.length," queued"]}),e.jsxs("span",{style:{color:"var(--color-text-secondary)"},children:[w," success"]})]}),e.jsx("div",{style:{width:1,height:16,background:"var(--color-border-divider)"}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,color:"var(--color-accent-purple)"},children:"Workflow"}),e.jsx("span",{style:{color:"var(--color-text-secondary)"},children:h?"1 running":"0 running"}),e.jsx("span",{style:{color:"var(--color-text-tertiary)"},children:z.length>0?`${F}/${z.length} steps`:"-"})]}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:8},children:[e.jsxs("button",{type:"button",onClick:()=>B(c=>!c),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 10px",fontSize:10,fontWeight:600,borderRadius:6,border:"1px solid var(--color-border)",background:L?"var(--color-bg-active)":"none",color:"var(--color-text-secondary)",cursor:"pointer",transition:"background 120ms"},children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{width:12,height:12},children:e.jsx("polyline",{points:L?"6 15 12 9 18 15":"6 9 12 15 18 9"})}),"Overview"]}),e.jsx("button",{type:"button",onClick:he,style:{padding:"3px 10px",fontSize:10,fontWeight:600,borderRadius:6,border:"1px solid",borderColor:b?"var(--color-accent-blue)":"var(--color-border)",background:b?"rgba(91,141,184,0.12)":"none",color:b?"var(--color-accent-blue)":"var(--color-text-tertiary)",cursor:"pointer",transition:"all 120ms"},children:"Issues"}),e.jsx("button",{type:"button",onClick:O,style:{padding:"3px 10px",fontSize:10,fontWeight:600,borderRadius:6,border:"1px solid",borderColor:h?"var(--color-accent-purple)":"var(--color-border)",background:h?"rgba(145,120,181,0.12)":"none",color:h?"var(--color-accent-purple)":"var(--color-text-tertiary)",cursor:"pointer",transition:"all 120ms"},children:"Workflow"})]})]}),e.jsx("style",{children:`
1
+ import{o as _e,u as T,b as R,j as e,z as Be,w as Me,r as g,s as X,$ as _}from"./index-DWG-WrzT.js";const m=_e((r,o)=>({activeTab:"commander",learningStats:null,learningPatterns:[],knowledgeEntries:[],scheduledTasks:[],extensions:[],promptModes:[],promptBindings:{},error:null,onLearningUpdate:t=>r({learningStats:t,learningPatterns:t.topPatterns}),onScheduleUpdate:t=>r({scheduledTasks:t}),onScheduleTriggered:t=>r(n=>{const s=new Date().toISOString();return{scheduledTasks:n.scheduledTasks.map(a=>{if(a.id!==t.taskId)return a;const v=a.lastRun?new Date(a.lastRun).getTime():0,p=v>0?Date.now()-v:0;return{...a,lastRun:s,history:[...a.history,{timestamp:s,status:"success",duration:p}]}})}}),onExtensionLoaded:t=>r({extensions:t.extensions}),onExtensionError:t=>r(n=>({extensions:n.extensions.map(x=>x.name!==t.name?x:{...x,status:"disabled"})})),fetchLearningStats:async()=>{try{const t=await fetch("/api/supervisor/learning/stats");if(!t.ok){r({error:`Failed to fetch learning stats: ${t.status}`});return}const n=await t.json();if(n&&typeof n=="object"&&"topPatterns"in n){const s=n;r({learningStats:s,learningPatterns:s.topPatterns,error:null})}}catch(t){r({error:`Failed to fetch learning stats: ${t instanceof Error?t.message:String(t)}`})}},fetchSchedules:async()=>{try{const t=await fetch("/api/supervisor/schedules");if(!t.ok){r({error:`Failed to fetch schedules: ${t.status}`});return}const n=await t.json(),s=n&&typeof n=="object"&&"tasks"in n?n.tasks:Array.isArray(n)?n:[];r({scheduledTasks:s,error:null})}catch(t){r({error:`Failed to fetch schedules: ${t instanceof Error?t.message:String(t)}`})}},fetchExtensions:async()=>{try{const t=await fetch("/api/supervisor/extensions");if(!t.ok){r({error:`Failed to fetch extensions: ${t.status}`});return}const n=await t.json(),s=n&&typeof n=="object"&&"extensions"in n?n.extensions:Array.isArray(n)?n:[];r({extensions:s,error:null})}catch(t){r({error:`Failed to fetch extensions: ${t instanceof Error?t.message:String(t)}`})}},fetchPromptModes:async()=>{try{const t=await fetch("/api/supervisor/prompts");if(!t.ok){r({error:`Failed to fetch prompt modes: ${t.status}`});return}const n=await t.json();if(n&&typeof n=="object"){const s=n,x=Array.isArray(s.builders)?s.builders:[],a=s.bindings&&typeof s.bindings=="object"?s.bindings:{};r({promptModes:x,promptBindings:a,error:null})}}catch(t){r({error:`Failed to fetch prompt modes: ${t instanceof Error?t.message:String(t)}`})}},createSchedule:async t=>{try{const n=await fetch("/api/supervisor/schedules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){r({error:`Failed to create schedule: ${n.status}`});return}const s=await n.json();if(s&&typeof s=="object"&&"task"in s){const x=s.task;r(a=>({scheduledTasks:[...a.scheduledTasks,x],error:null}))}}catch(n){r({error:`Failed to create schedule: ${n instanceof Error?n.message:String(n)}`})}},updateSchedule:async(t,n)=>{try{const s=await fetch(`/api/supervisor/schedules/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!s.ok){r({error:`Failed to update schedule: ${s.status}`});return}const x=await s.json();if(x&&typeof x=="object"&&"task"in x){const a=x.task;r(v=>({scheduledTasks:v.scheduledTasks.map(p=>p.id===t?a:p),error:null}))}}catch(s){r({error:`Failed to update schedule: ${s instanceof Error?s.message:String(s)}`})}},deleteSchedule:async t=>{try{const n=await fetch(`/api/supervisor/schedules/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok){r({error:`Failed to delete schedule: ${n.status}`});return}r(s=>({scheduledTasks:s.scheduledTasks.filter(x=>x.id!==t),error:null}))}catch(n){r({error:`Failed to delete schedule: ${n instanceof Error?n.message:String(n)}`})}},toggleSchedule:async(t,n)=>{await o().updateSchedule(t,{enabled:n})},runSchedule:async t=>{try{const n=await fetch(`/api/supervisor/schedules/${encodeURIComponent(t)}/run`,{method:"POST"});n.ok||r({error:`Failed to run schedule: ${n.status}`})}catch(n){r({error:`Failed to run schedule: ${n instanceof Error?n.message:String(n)}`})}},setActiveTab:t=>r({activeTab:t}),clearError:()=>r({error:null})}));function $e(r){const o=Date.now()-new Date(r).getTime(),t=Math.floor(o/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function Ae(){var y;const{t:r}=T(),o=R(i=>i.slots),t=R(i=>i.queue),n=R(i=>i.supervisorStatus),s=Object.values(o),x=(n==null?void 0:n.stats.totalDispatched)??0,a=(n==null?void 0:n.stats.totalCompleted)??0,v=(n==null?void 0:n.stats.totalFailed)??0,p=x>0?Math.round(a/x*100):0;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflowY:"auto",padding:24,gap:20},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12},children:[e.jsx(Z,{label:r("supervisor.overview.dispatched"),value:String(x),sub:`${s.length} ${r("supervisor.overview.active")}`}),e.jsx(Z,{label:r("supervisor.overview.success_rate"),value:x?`${p}%`:"-",valueColor:"var(--color-accent-green)",sub:`${a} ${r("supervisor.overview.completed")}`}),e.jsx(Z,{label:r("supervisor.overview.queued"),value:String(t.length),sub:`${((y=n==null?void 0:n.retrying)==null?void 0:y.length)??0} retrying`}),e.jsx(Z,{label:"Failed",value:String(v),valueColor:v>0?"var(--color-accent-red)":void 0,sub:x>0?`${Math.round(v/x*100)}% fail rate`:"-"})]}),e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r("supervisor.overview.active_executions")}),e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)"},children:r("supervisor.overview.running_count",{count:s.length})})]}),e.jsx("div",{children:s.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:16},children:"No active executions"}):s.map(i=>{const d=Be[i.executor]??"var(--color-text-tertiary)",k=Me[i.executor]??i.executor;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:d,flexShrink:0}}),e.jsx("span",{style:{fontSize:12,fontWeight:500,color:"var(--color-text-primary)"},children:i.issueId}),e.jsx("span",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:k}),e.jsxs("span",{style:{fontSize:11,color:"var(--color-text-tertiary)"},children:["Turn ",i.turnNumber,"/",i.maxTurns]}),e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",marginLeft:"auto"},children:$e(i.startedAt)})]},i.processId)})})]}),t.length>0&&e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:["Queue (",t.length,")"]})}),e.jsx("div",{children:t.map((i,d)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsxs("span",{style:{fontSize:10,fontWeight:600,color:"var(--color-text-tertiary)",minWidth:20},children:["#",d+1]}),e.jsx("span",{style:{fontSize:12,fontWeight:500,color:"var(--color-text-primary)"},children:i})]},i))})]})]})}function Z({label:r,value:o,sub:t,valueColor:n}){return e.jsxs("div",{style:{flex:1,background:"var(--color-bg-primary)",borderRadius:10,padding:14,border:"1px solid var(--color-border-divider)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:r}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:n??"var(--color-text-primary)",marginTop:2},children:o}),e.jsx("div",{style:{fontSize:10,color:"var(--color-text-secondary)"},children:t})]})}const De={optimize:"var(--color-accent-green)",alert:"var(--color-accent-orange)",automate:"var(--color-accent-purple)"};function Ee(){const{t:r}=T(),o=R(i=>i.commanderState),t=R(i=>i.commanderConfig),n=R(i=>i.fetchCommanderConfig),s=R(i=>i.recentDecisions),x=m(i=>i.setActiveTab),a=m(i=>i.learningStats);g.useEffect(()=>{n()},[n]);const v=()=>X({action:"commander:stop"}),p=s.length>0?s[s.length-1]:null,y=(a==null?void 0:a.suggestions)??[];return e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px 40px"},children:[e.jsxs("div",{style:re,children:[e.jsxs("div",{style:K,children:[e.jsx("div",{style:Q,children:r("supervisor.commander.metrics")}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{type:"button",onClick:()=>x("executions"),style:Pe,children:r("supervisor.commander.view_executions")??"View Executions"}),e.jsx("button",{type:"button",onClick:v,style:Ne,children:r("supervisor.commander.stop")})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12},children:[e.jsx(ge,{label:r("supervisor.commander.ticks"),value:String((o==null?void 0:o.tickCount)??0),sub:o!=null&&o.sessionId?`Session ${o.sessionId.slice(0,8)}`:void 0}),e.jsx(ge,{label:r("supervisor.commander.workers"),value:String((o==null?void 0:o.activeWorkers)??0),sub:t?`Max: ${t.maxConcurrentWorkers}`:void 0}),e.jsx(ge,{label:r("supervisor.commander.last_tick"),value:o!=null&&o.lastTickAt?we(o.lastTickAt):"--:--:--",valueStyle:{fontSize:16},sub:o!=null&&o.lastTickAt?Fe(o.lastTickAt):void 0})]})]}),t&&e.jsxs("div",{style:re,children:[e.jsx("div",{style:K,children:e.jsx("div",{style:Q,children:r("supervisor.commander.config")})}),e.jsxs("div",{style:He,children:[e.jsx(ee,{label:r("supervisor.commander.profile"),desc:r("supervisor.commander.profile_desc")??"Environment-specific behavior preset",children:e.jsx("select",{value:t.profile,onChange:i=>X({action:"commander:config",config:{profile:i.target.value}}),style:fe,children:["development","staging","production"].map(i=>e.jsx("option",{value:i,children:i},i))})}),e.jsx(ee,{label:r("supervisor.commander.decision_model"),desc:r("supervisor.commander.decision_model_desc")??"AI model for orchestration decisions",children:e.jsx("select",{value:t.decisionModel,onChange:i=>X({action:"commander:config",config:{decisionModel:i.target.value}}),style:fe,children:["haiku","sonnet","opus"].map(i=>e.jsx("option",{value:i,children:i},i))})}),e.jsx(ee,{label:r("supervisor.commander.auto_approve"),desc:r("supervisor.commander.auto_approve_desc")??"Confidence threshold for auto-approval",children:e.jsx("select",{value:t.autoApproveThreshold,onChange:i=>X({action:"commander:config",config:{autoApproveThreshold:i.target.value}}),style:fe,children:["low","medium","high"].map(i=>e.jsx("option",{value:i,children:i},i))})}),e.jsx(ee,{label:r("supervisor.commander.max_workers")??"Max Workers",desc:r("supervisor.commander.max_workers_desc")??"Maximum parallel agent executions",isLast:!0,children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",padding:"4px 10px"},children:t.maxConcurrentWorkers})})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{style:re,children:[e.jsxs("div",{style:K,children:[e.jsx("div",{style:Q,children:r("supervisor.commander.decision_history")}),e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r("supervisor.commander.decisions_count",{count:s.length})})]}),e.jsx("div",{style:ye,children:e.jsx("div",{style:{padding:"14px 16px"},children:s.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:16},children:r("supervisor.commander.no_decisions")}):s.slice().reverse().map((i,d,k)=>{const j=we(i.timestamp),f=i.actions.length>0?"var(--color-accent-green)":"var(--color-accent-gray)",I=d===k.length-1;return e.jsxs("div",{style:{display:"flex",gap:12,padding:"10px 0",position:"relative"},children:[!I&&e.jsx("div",{style:{position:"absolute",left:11,top:30,bottom:-10,width:1,background:"var(--color-border-divider)"}}),e.jsx("div",{style:qe,children:e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:f}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,fontFamily:"'SF Mono', Consolas, monospace",color:"var(--color-text-placeholder)"},children:j}),e.jsxs("div",{style:{fontSize:12,color:"var(--color-text-primary)"},children:[i.trigger," - ",i.actions.length," action",i.actions.length!==1?"s":""]}),i.deferred.length>0&&e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:[i.deferred.length," deferred"]})]})]},i.id)})})})]}),e.jsxs("div",{style:re,children:[e.jsx("div",{style:K,children:e.jsx("div",{style:Q,children:r("supervisor.commander.latest_assessment")})}),e.jsx("div",{style:ye,children:e.jsx("div",{style:{padding:"14px 16px"},children:p!=null&&p.assessment?e.jsxs(e.Fragment,{children:[p.assessment.observations.length>0&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:Ce,children:r("supervisor.commander.observations")}),e.jsx("div",{style:{fontSize:11,color:"var(--color-text-secondary)",paddingLeft:8,lineHeight:1.8},children:p.assessment.observations.map((i,d)=>e.jsxs("div",{children:["- ",i]},d))})]}),p.assessment.risks.length>0&&e.jsxs("div",{children:[e.jsx("div",{style:Ce,children:r("supervisor.commander.risks")}),e.jsx("div",{style:{fontSize:11,color:"var(--color-accent-red)",paddingLeft:8,lineHeight:1.8},children:p.assessment.risks.map((i,d)=>e.jsxs("div",{children:["- ",i]},d))})]})]}):e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:8},children:r("supervisor.commander.no_decisions")})})}),e.jsxs("div",{style:{marginTop:16},children:[e.jsxs("div",{style:K,children:[e.jsx("div",{style:Q,children:r("supervisor.commander.suggestions")??"Suggestions"}),y.length>0&&e.jsxs("span",{style:{fontSize:9,fontWeight:700,padding:"2px 8px",borderRadius:100,background:"var(--color-tint-verifying)",color:"var(--color-accent-orange)"},children:[y.length," new"]})]}),e.jsx("div",{style:ye,children:e.jsx("div",{style:{padding:"14px 16px"},children:y.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:8},children:r("supervisor.commander.no_suggestions")??"No suggestions"}):y.map((i,d)=>e.jsxs("div",{style:{display:"flex",gap:10,padding:"10px 0",borderBottom:d<y.length-1?"1px solid var(--color-border-divider)":"none"},children:[e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",marginTop:5,flexShrink:0,background:De[i.type]??"var(--color-accent-gray)"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:i.title}),e.jsxs("div",{style:{fontSize:11,color:"var(--color-text-secondary)",marginTop:1},children:[i.description," (",Math.round(i.confidence*100),"%)"]})]})]},d))})})]})]})]})]})}function ge({label:r,value:o,sub:t,valueStyle:n}){return e.jsxs("div",{style:Oe,children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:r}),e.jsx("div",{style:{fontSize:20,fontWeight:800,color:"var(--color-text-primary)",marginTop:2,...n},children:o}),t&&e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:t})]})}function ee({label:r,desc:o,children:t,isLast:n}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:n?"none":"1px solid var(--color-border-divider)"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:500,color:"var(--color-text-primary)"},children:r}),e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)",marginTop:2},children:o})]}),t]})}function we(r){const o=new Date(r);return`${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}:${String(o.getSeconds()).padStart(2,"0")}`}function Fe(r){const o=Math.floor((Date.now()-new Date(r).getTime())/1e3);return o<60?`${o}s ago`:o<3600?`${Math.floor(o/60)} min ago`:`${Math.floor(o/3600)}h ago`}const re={marginBottom:24},K={display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},Q={fontSize:13,fontWeight:700,color:"var(--color-text-primary)"},ye={background:"var(--color-bg-card)",borderRadius:12,border:"1px solid var(--color-border-divider)",overflow:"hidden"},Oe={background:"var(--color-bg-card)",borderRadius:10,padding:"14px 16px",border:"1px solid var(--color-border-divider)"},He={background:"var(--color-bg-card)",borderRadius:12,border:"1px solid var(--color-border-divider)",overflow:"hidden"},fe={fontSize:12,fontWeight:600,color:"var(--color-text-primary)",padding:"4px 10px",borderRadius:6,border:"1px solid var(--color-border)",background:"var(--color-bg-primary)",minWidth:100,textAlign:"center",cursor:"pointer"},qe={width:22,height:22,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"2px solid var(--color-bg-primary)"},Ce={fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".06em",color:"var(--color-text-tertiary)",marginBottom:6},Ie={fontSize:11,fontWeight:600,padding:"5px 12px",borderRadius:8,border:"1px solid var(--color-border)",background:"none",cursor:"pointer",color:"var(--color-text-secondary)",transition:"all 150ms"},Pe={...Ie},Ne={...Ie,color:"var(--color-accent-red)",borderColor:"var(--color-accent-red)"},Ye=["claude","gemini","codex","qwen","opencode"],oe={running:{bg:"var(--color-tint-running)",color:"var(--color-accent-blue)"},awaiting_clarification:{bg:"var(--color-tint-verifying)",color:"var(--color-accent-orange)"},completed:{bg:"var(--color-tint-completed)",color:"var(--color-accent-green)"},failed:{bg:"var(--color-tint-failed)",color:"var(--color-accent-red)"},paused:{bg:"var(--color-tint-pending)",color:"var(--color-accent-gray)"},idle:{bg:"var(--color-tint-pending)",color:"var(--color-accent-gray)"}},P={completed:{bg:"var(--color-tint-completed)",dot:"var(--color-accent-green)"},running:{bg:"var(--color-tint-running)",dot:"var(--color-accent-blue)"},pending:{bg:"transparent",dot:"var(--color-accent-gray)"},failed:{bg:"var(--color-tint-failed)",dot:"var(--color-accent-red)"},skipped:{bg:"var(--color-tint-pending)",dot:"var(--color-accent-gray)"}};function Ke(){const{t:r}=T(),o=_(l=>l.session),t=_(l=>l.selectedStepIndex),n=_(l=>l.clarificationQuestion),s=_(l=>l.start),x=_(l=>l.stop),a=_(l=>l.resume),v=_(l=>l.selectStep),p=_(l=>l.sendClarification),[y,i]=g.useState(""),[d,k]=g.useState("claude"),[j,f]=g.useState(!0),[I,$]=g.useState(""),[L,B]=g.useState(""),C=g.useRef(null),b=o!=null&&o.status!=="idle",u=b&&o.status==="running",E=(o==null?void 0:o.status)==="awaiting_clarification",w=(o==null?void 0:o.steps)??[],h=t!=null?w[t]??null:null,z=w.filter(l=>l.status==="completed"),F=w.length,he=F>0?Math.round(z.length/F*100):0,O=(o==null?void 0:o.avgQuality)??(z.length>0?z.reduce((l,S)=>l+(S.qualityScore??0),0)/z.length:null),H=g.useCallback(()=>{var q;if(!o||!w.length)return"--";const l=(q=w[0])==null?void 0:q.startedAt;if(!l)return"--";const S=Date.now()-new Date(l).getTime();if(S<0)return"--";const W=Math.floor(S/1e3),M=Math.floor(W/60),J=Math.floor(M/60);return J>0?`${J}h ${M%60}m`:M>0?`${M}m ${W%60}s`:`${W}s`},[o,w]);g.useEffect(()=>(u?(B(H()),C.current=setInterval(()=>B(H()),1e3)):(B(H()),C.current&&clearInterval(C.current)),()=>{C.current&&clearInterval(C.current)}),[u,H]),g.useEffect(()=>{if(!b||t!=null)return;const l=w.findIndex(S=>S.status==="running");l>=0?v(l):w.length>0&&v(0)},[b,w,t,v]);const G=()=>{y.trim()&&(s(y.trim(),d,j),i(""))},c=()=>{!I.trim()||!o||(p(o.sessionId,I.trim()),$(""))},Y=l=>{if(l.durationMs!=null){const S=Math.floor(l.durationMs/1e3),W=Math.floor(S/60);return W>0?`${W}m ${S%60}s`:`${S}s`}if(l.status==="running"&&l.startedAt){const S=Math.floor((Date.now()-new Date(l.startedAt).getTime())/1e3),W=Math.floor(S/60);return W>0?`${W}m ${S%60}s...`:`${S}s...`}return""},A=l=>l>=70?"var(--color-accent-green)":l>=40?"var(--color-accent-orange)":"var(--color-accent-red)",ke=l=>l>=70?"var(--color-tint-completed)":l>=40?"var(--color-tint-verifying)":"var(--color-tint-failed)",Le=l=>{switch(l){case"running":return"Running";case"awaiting_clarification":return"Needs Clarification";case"completed":return"Completed";case"failed":return"Failed";case"paused":return"Paused";default:return l}};return e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px 40px"},children:[e.jsxs("div",{style:V,children:[e.jsxs("div",{style:te,children:[e.jsx("div",{style:ne,children:r("supervisor.coordinator.title")}),b&&e.jsxs("div",{style:{display:"flex",gap:6},children:[u&&e.jsx("button",{type:"button",onClick:x,style:Ve,children:r("supervisor.coordinator.stop")}),(o.status==="paused"||o.status==="failed")&&e.jsx("button",{type:"button",onClick:()=>a(),style:Ue,children:r("supervisor.coordinator.resume")})]})]}),e.jsx("div",{style:Ge,children:e.jsxs("div",{style:Je,children:[e.jsx("input",{style:Xe,placeholder:r("supervisor.coordinator.describe_intent"),value:y,onChange:l=>i(l.target.value),onKeyDown:l=>{l.key==="Enter"&&G()}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[e.jsx("select",{style:Ze,value:d,onChange:l=>k(l.target.value),children:Ye.map(l=>e.jsx("option",{value:l,children:l},l))}),e.jsx("button",{type:"button",style:j?er:rr,onClick:()=>f(!j),children:r(j?"supervisor.coordinator.auto":"supervisor.coordinator.manual")}),e.jsx("button",{type:"button",style:Qe,onClick:G,children:r("supervisor.coordinator.start")})]})]})})]}),b&&e.jsxs("div",{style:V,children:[e.jsxs("div",{style:te,children:[e.jsx("div",{style:ne,children:"Session"}),e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"2px 8px",borderRadius:100,background:(oe[o.status]??oe.idle).bg,color:(oe[o.status]??oe.idle).color},children:Le(o.status)})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12},children:[e.jsxs("div",{style:ie,children:[e.jsx("div",{style:se,children:r("supervisor.coordinator.chain")}),e.jsx("div",{style:{...le,fontSize:16},children:o.chainName??"--"}),e.jsx("div",{style:ae,children:o.intent||"--"})]}),e.jsxs("div",{style:ie,children:[e.jsx("div",{style:se,children:r("supervisor.coordinator.progress")}),e.jsxs("div",{style:le,children:[z.length,e.jsxs("span",{style:{fontSize:13,fontWeight:500,color:"var(--color-text-tertiary)"},children:[" / ",F]})]}),e.jsx("div",{style:ae,children:e.jsx("div",{style:{height:3,background:"rgba(0,0,0,0.06)",borderRadius:100,overflow:"hidden",marginTop:4},children:e.jsx("div",{style:{height:"100%",borderRadius:100,background:"linear-gradient(90deg, var(--color-accent-blue), var(--color-accent-green))",width:`${he}%`,transition:"width 0.6s"}})})})]}),e.jsxs("div",{style:ie,children:[e.jsx("div",{style:se,children:r("supervisor.coordinator.avg_quality")}),e.jsx("div",{style:{...le,color:O!=null?A(O):"var(--color-text-primary)"},children:O!=null?O.toFixed(1):"--"}),e.jsx("div",{style:ae,children:z.length>0?r("supervisor.coordinator.from_steps",{count:z.length}):"--"})]}),e.jsxs("div",{style:ie,children:[e.jsx("div",{style:se,children:r("supervisor.coordinator.elapsed")}),e.jsx("div",{style:{...le,fontSize:16},children:L}),e.jsxs("div",{style:ae,children:[r("supervisor.coordinator.tool_label"),": ",o.tool??d]})]})]})]}),E&&n&&e.jsx("div",{style:V,children:e.jsxs("div",{style:or,children:[e.jsxs("div",{style:tr,children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),e.jsx("span",{style:nr,children:r("supervisor.coordinator.clarification_needed")})]}),e.jsxs("div",{style:{padding:"14px 16px"},children:[e.jsx("div",{style:ir,children:n}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{style:sr,placeholder:r("supervisor.coordinator.type_response"),value:I,onChange:l=>$(l.target.value),onKeyDown:l=>{l.key==="Enter"&&c()}}),e.jsxs("button",{type:"button",style:lr,onClick:c,children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),e.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]}),r("supervisor.coordinator.send")]})]})]})]})}),b&&w.length>0&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{style:V,children:[e.jsxs("div",{style:te,children:[e.jsx("div",{style:ne,children:r("supervisor.coordinator.chain_steps")}),e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r("supervisor.coordinator.steps_count",{count:F})})]}),e.jsx("div",{style:D,children:e.jsx("div",{style:{padding:"14px 16px"},children:w.map((l,S)=>{const W=P[l.status]??P.pending,M=t===S,J=S===w.length-1,q=Y(l);return e.jsxs("div",{onClick:()=>v(S),style:{display:"flex",gap:12,padding:"10px 8px",position:"relative",cursor:"pointer",background:M?"var(--color-bg-hover)":"transparent",borderRadius:M?8:0,margin:M?"0 -8px":"0"},children:[!J&&e.jsx("div",{style:{position:"absolute",left:M?19:11,top:30,bottom:-10,width:1,background:l.status==="completed"?"var(--color-accent-green)":"var(--color-border-divider)",opacity:l.status==="completed"?.4:1}}),e.jsx("div",{style:{width:22,height:22,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,background:W.bg,border:"2px solid var(--color-bg-primary)"},children:e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:W.dot,animation:l.status==="running"?"pulse 2s infinite":void 0}})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:l.cmd}),l.args&&e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:l.args}),(q||l.qualityScore!=null||l.status==="running")&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:3},children:[q&&e.jsx("span",{style:{fontSize:10,fontFamily:"'SF Mono', Consolas, monospace",color:"var(--color-text-placeholder)"},children:q}),l.qualityScore!=null&&e.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 7px",borderRadius:100,background:ke(l.qualityScore),color:A(l.qualityScore)},children:l.qualityScore}),l.status==="running"&&l.qualityScore==null&&e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"2px 8px",borderRadius:100,background:"var(--color-tint-running)",color:"var(--color-accent-blue)"},children:"running"})]})]})]},l.index)})})})]}),e.jsx("div",{style:V,children:h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:te,children:[e.jsxs("div",{style:ne,children:["Step ",(t??0)+1,": ",h.cmd]}),e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"2px 8px",borderRadius:100,background:(P[h.status]??P.pending).bg||"var(--color-tint-pending)",color:(P[h.status]??P.pending).dot},children:h.status})]}),h.status==="completed"&&h.qualityScore!=null&&e.jsx("div",{style:{marginBottom:16},children:e.jsxs("div",{style:D,children:[e.jsxs("div",{style:je,children:[e.jsx("span",{style:me,children:r("supervisor.coordinator.quality_score")}),e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"2px 8px",borderRadius:100,background:ke(h.qualityScore),color:A(h.qualityScore)},children:h.qualityScore})]}),e.jsx("div",{style:{padding:"14px 16px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[e.jsxs("div",{style:{width:48,height:48,position:"relative",flexShrink:0},children:[e.jsxs("svg",{viewBox:"0 0 36 36",width:"48",height:"48",style:{transform:"rotate(-90deg)"},children:[e.jsx("circle",{cx:"18",cy:"18",r:"15.9",fill:"none",stroke:"var(--color-bg-secondary)",strokeWidth:"5"}),e.jsx("circle",{cx:"18",cy:"18",r:"15.9",fill:"none",stroke:A(h.qualityScore),strokeWidth:"5",strokeLinecap:"round",strokeDasharray:"100",strokeDashoffset:100-h.qualityScore})]}),e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:800,color:"var(--color-text-primary)"},children:h.qualityScore})]}),h.summary&&e.jsx("div",{style:{flex:1,fontSize:11,color:"var(--color-text-secondary)",lineHeight:1.6},children:h.summary})]})})]})}),h.status==="completed"&&h.summary&&e.jsx("div",{style:{marginBottom:16},children:e.jsxs("div",{style:D,children:[e.jsx("div",{style:je,children:e.jsx("span",{style:me,children:r("supervisor.coordinator.summary")})}),e.jsx("div",{style:{padding:"14px 16px"},children:e.jsx("div",{style:{fontSize:12,color:"var(--color-text-primary)",lineHeight:1.7},children:h.summary})})]})}),(h.status==="running"||h.status==="completed")&&h.analysis&&e.jsx("div",{style:{marginBottom:16},children:e.jsxs("div",{style:D,children:[e.jsx("div",{style:je,children:e.jsx("span",{style:me,children:r("supervisor.coordinator.analysis")})}),e.jsx("pre",{style:ar,children:h.analysis})]})}),(h.status==="pending"||h.status==="skipped")&&e.jsx("div",{style:D,children:e.jsx("div",{style:{padding:"14px 16px"},children:e.jsxs("div",{style:{textAlign:"center",padding:"48px 20px",color:"var(--color-text-tertiary)"},children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.2,margin:"0 auto 10px",display:"block"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--color-text-secondary)"},children:r("supervisor.coordinator.waiting_execute")}),e.jsx("div",{style:{fontSize:11,marginTop:4,maxWidth:300,marginLeft:"auto",marginRight:"auto",lineHeight:1.6},children:r("supervisor.coordinator.pending_desc")})]})})})]}):e.jsx("div",{style:D,children:e.jsx("div",{style:{padding:"14px 16px"},children:e.jsx("div",{style:{textAlign:"center",padding:"48px 20px",color:"var(--color-text-tertiary)",fontSize:11},children:"Select a step to view details"})})})})]}),!b&&e.jsx("div",{style:D,children:e.jsx("div",{style:{padding:"14px 16px"},children:e.jsxs("div",{style:{textAlign:"center",padding:"48px 20px",color:"var(--color-text-tertiary)"},children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.2,margin:"0 auto 10px",display:"block"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 5.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.6a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--color-text-secondary)"},children:r("supervisor.coordinator.no_session")}),e.jsx("div",{style:{fontSize:11,marginTop:4,maxWidth:300,marginLeft:"auto",marginRight:"auto",lineHeight:1.6},children:r("supervisor.coordinator.no_session_desc")})]})})})]})}const V={marginBottom:24},te={display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},ne={fontSize:13,fontWeight:700,color:"var(--color-text-primary)"},D={background:"var(--color-bg-card)",borderRadius:12,border:"1px solid var(--color-border-divider)",overflow:"hidden"},je={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},me={fontSize:12,fontWeight:700,color:"var(--color-text-primary)"},ie={background:"var(--color-bg-card)",borderRadius:10,padding:"14px 16px",border:"1px solid var(--color-border-divider)"},se={fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},le={fontSize:20,fontWeight:800,color:"var(--color-text-primary)",marginTop:2},ae={fontSize:10,color:"var(--color-text-tertiary)"},Se={fontSize:11,fontWeight:600,padding:"5px 12px",borderRadius:8,border:"1px solid var(--color-border)",background:"none",cursor:"pointer",color:"var(--color-text-secondary)",transition:"all 150ms"},Qe={...Se,background:"var(--color-text-primary)",color:"#fff",borderColor:"var(--color-text-primary)"},Ve={...Se,color:"var(--color-accent-red)",borderColor:"var(--color-accent-red)"},Ue={...Se,color:"var(--color-accent-green)",borderColor:"var(--color-accent-green)"},Ge={background:"var(--color-bg-card)",borderRadius:12,border:"1px solid var(--color-border-divider)",overflow:"hidden"},Je={display:"flex",alignItems:"center",gap:10,padding:"10px 16px"},Xe={flex:1,border:"none",background:"transparent",fontSize:13,color:"var(--color-text-primary)",outline:"none",fontFamily:"inherit",lineHeight:1.5},Ze={padding:"4px 8px",borderRadius:6,fontSize:11,fontWeight:600,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-primary)",color:"var(--color-text-secondary)",cursor:"pointer",outline:"none"},er={fontSize:9,fontWeight:700,padding:"3px 8px",borderRadius:100,border:"none",cursor:"pointer",transition:"all 150ms",background:"var(--color-tint-completed)",color:"var(--color-accent-green)"},rr={fontSize:9,fontWeight:700,padding:"3px 8px",borderRadius:100,border:"none",cursor:"pointer",transition:"all 150ms",background:"var(--color-tint-pending)",color:"var(--color-accent-gray)"},or={background:"var(--color-bg-card)",borderRadius:12,border:"2px solid var(--color-accent-orange)",overflow:"hidden"},tr={display:"flex",alignItems:"center",gap:8,padding:"10px 16px",background:"var(--color-tint-verifying)",color:"var(--color-accent-orange)"},nr={fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:".04em"},ir={fontSize:12,color:"var(--color-text-primary)",lineHeight:1.6,marginBottom:10},sr={flex:1,padding:"7px 12px",fontSize:12,borderRadius:8,border:"1px solid var(--color-border)",background:"var(--color-bg-primary)",color:"var(--color-text-primary)",outline:"none"},lr={padding:"7px 14px",border:"none",borderRadius:8,background:"var(--color-accent-orange)",color:"#fff",fontSize:11,fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:4},ar={margin:0,padding:"14px 16px",fontSize:11,lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"'SF Mono', Consolas, monospace",background:"#2C2723",color:"#D9D0C4",borderRadius:"0 0 12px 12px",maxHeight:220,overflowY:"auto"};function dr(){const{t:r}=T(),o=m(d=>d.promptModes),t=m(d=>d.promptBindings),[n,s]=g.useState(null),[x,a]=g.useState(""),[v,p]=g.useState(""),y=v?o.filter(d=>d.toLowerCase().includes(v.toLowerCase())):o,i=d=>{s(d),a(t[d]??"")};return e.jsxs("div",{className:"flex h-full overflow-hidden",children:[e.jsxs("div",{style:{width:320,background:"var(--color-bg-primary)",borderRight:"1px solid var(--color-border)",flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--color-text-primary)"},children:r("supervisor.prompts.title")}),e.jsx("span",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r("supervisor.prompts.builders_count",{count:o.length})})]}),e.jsx("input",{value:v,onChange:d=>p(d.target.value),placeholder:r("supervisor.prompts.filter"),style:{margin:"10px 12px 6px",padding:"8px 12px",borderRadius:8,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-card)",fontSize:12,color:"var(--color-text-primary)",outline:"none"}}),e.jsx("div",{style:{flex:1,overflowY:"auto"},children:y.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:16},children:r(v?"supervisor.prompts.no_matches":"supervisor.prompts.no_modes")}):y.map(d=>{const k=d===n,j=!!t[d];return e.jsxs("button",{type:"button",onClick:()=>i(d),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 16px",cursor:"pointer",border:"none",width:"100%",textAlign:"left",background:k?"var(--color-tint-exploring)":"none",borderLeft:`3px solid ${k?"var(--color-accent-blue)":"transparent"}`,transition:"all 120ms"},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-planning)",color:"var(--color-accent-purple)",flexShrink:0},children:e.jsxs("svg",{style:{width:14,height:14,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 7 4 4 20 4 20 7"}),e.jsx("line",{x1:"9",y1:"20",x2:"15",y2:"20"}),e.jsx("line",{x1:"12",y1:"4",x2:"12",y2:"20"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:d}),e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r(j?"supervisor.prompts.bound":"supervisor.prompts.unbound")})]}),j&&e.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"2px 8px",borderRadius:100,background:"rgba(90,158,120,0.12)",color:"var(--color-accent-green)"},children:"active"})]},d)})})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column"},children:n?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--color-border-divider)",flexShrink:0},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-planning)",color:"var(--color-accent-purple)"},children:e.jsxs("svg",{style:{width:18,height:18,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 7 4 4 20 4 20 7"}),e.jsx("line",{x1:"9",y1:"20",x2:"15",y2:"20"}),e.jsx("line",{x1:"12",y1:"4",x2:"12",y2:"20"})]})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--color-text-primary)"},children:n}),e.jsx("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:r("supervisor.prompts.prompt_builder")})]})]})}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"flex",flexDirection:"column",gap:20},children:[e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r("supervisor.prompts.binding")})}),e.jsxs("div",{style:{padding:"14px 16px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 0",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:120,flexShrink:0},children:r("supervisor.prompts.mode")}),e.jsx("span",{style:{fontSize:12,color:"var(--color-text-primary)",fontWeight:500},children:n})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 0"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:120,flexShrink:0},children:r("supervisor.prompts.status")}),e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:t[n]?"rgba(90,158,120,0.12)":"rgba(160,157,151,0.12)",color:t[n]?"var(--color-accent-green)":"var(--color-accent-gray)"},children:t[n]?r("supervisor.prompts.bound"):r("supervisor.prompts.unbound")})]})]})]}),e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r("supervisor.prompts.template")})}),e.jsx("div",{style:{padding:"14px 16px"},children:e.jsx("textarea",{value:x,onChange:d=>a(d.target.value),placeholder:r("supervisor.prompts.edit_placeholder"),style:{width:"100%",minHeight:160,resize:"vertical",borderRadius:8,padding:12,fontSize:12,fontFamily:"'SF Mono', Consolas, monospace",lineHeight:1.6,background:"var(--color-bg-secondary)",color:"var(--color-text-primary)",border:"1px solid var(--color-border-divider)",outline:"none"}})})]}),x&&e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r("supervisor.prompts.preview")})}),e.jsx("div",{style:{padding:0},children:e.jsx("pre",{style:{margin:0,padding:16,fontSize:11,lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"'SF Mono', Consolas, monospace",maxHeight:200,overflowY:"auto",background:"var(--color-text-primary)",color:"#d4d0ca",borderRadius:"0 0 12px 12px"},children:x})})]})]})]}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",fontSize:13},children:r("supervisor.prompts.select_detail")})})]})}const pe={strategy:{bg:"var(--color-tint-exploring)",fg:"var(--color-accent-blue)"},builder:{bg:"var(--color-tint-completed)",fg:"var(--color-accent-green)"},adapter:{bg:"var(--color-tint-verifying)",fg:"var(--color-accent-orange)"},task:{bg:"var(--color-tint-planning)",fg:"var(--color-accent-purple)"},tool:{bg:"var(--color-tint-pending)",fg:"var(--color-accent-gray)"}},xe={strategy:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),e.jsx("path",{d:"M2 17l10 5 10-5"}),e.jsx("path",{d:"M2 12l10 5 10-5"})]}),builder:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),e.jsx("line",{x1:"9",y1:"21",x2:"9",y2:"9"})]}),adapter:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"16 18 22 12 16 6"}),e.jsx("polyline",{points:"8 6 2 12 8 18"})]}),task:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),tool:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09"})]})};function cr(){const{t:r}=T(),o=m(p=>p.extensions),[t,n]=g.useState(null),[s,x]=g.useState(""),a=s?o.filter(p=>p.name.toLowerCase().includes(s.toLowerCase())||p.type.toLowerCase().includes(s.toLowerCase())):o,v=o.find(p=>p.name===t)??null;return e.jsxs("div",{className:"flex h-full overflow-hidden",children:[e.jsxs("div",{style:{width:320,background:"var(--color-bg-primary)",borderRight:"1px solid var(--color-border)",flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--color-text-primary)"},children:r("supervisor.extensions.title")}),e.jsx("span",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r("supervisor.extensions.loaded_count",{count:o.length})})]}),e.jsx("input",{value:s,onChange:p=>x(p.target.value),placeholder:r("supervisor.extensions.filter"),style:{margin:"10px 12px 6px",padding:"8px 12px",borderRadius:8,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-card)",fontSize:12,color:"var(--color-text-primary)",outline:"none"}}),e.jsx("div",{style:{flex:1,overflowY:"auto"},children:a.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:16},children:r(s?"supervisor.extensions.no_matches":"supervisor.extensions.no_extensions")}):a.map(p=>{const y=p.name===t,i=pe[p.type]??pe.tool;return e.jsxs("button",{type:"button",onClick:()=>n(p.name),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 16px",cursor:"pointer",border:"none",width:"100%",textAlign:"left",background:y?"var(--color-tint-exploring)":"none",borderLeft:`3px solid ${y?"var(--color-accent-blue)":"transparent"}`,transition:"all 120ms"},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:i.bg,color:i.fg,flexShrink:0},children:e.jsx("span",{style:{width:14,height:14,strokeWidth:1.8,display:"flex"},children:xe[p.type]??xe.tool})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:p.name}),e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)",display:"flex",gap:8},children:[e.jsxs("span",{children:["v",p.version]}),e.jsx("span",{children:p.type})]})]}),e.jsx("div",{style:{flexShrink:0},children:e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",display:"inline-block",background:p.status==="enabled"?"var(--color-accent-green)":"var(--color-text-tertiary)"}})})]},p.name)})})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column"},children:v?e.jsx(pr,{ext:v}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",fontSize:13},children:r("supervisor.extensions.select_detail")})})]})}function pr({ext:r}){const{t:o}=T(),t=pe[r.type]??pe.tool;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--color-border-divider)",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:t.bg,color:t.fg},children:e.jsx("span",{style:{width:18,height:18,strokeWidth:1.8,display:"flex"},children:xe[r.type]??xe.tool})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--color-text-primary)"},children:r.name}),e.jsxs("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:["v",r.version]})]})]}),e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:r.status==="enabled"?"rgba(90,158,120,0.12)":"rgba(160,157,151,0.12)",color:r.status==="enabled"?"var(--color-accent-green)":"var(--color-accent-gray)"},children:r.status})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"flex",flexDirection:"column",gap:20},children:[e.jsx(ze,{title:o("supervisor.extensions.about"),children:e.jsx("div",{style:{fontSize:12,color:"var(--color-text-primary)",lineHeight:1.6},children:r.description||o("supervisor.extensions.no_description")})}),e.jsxs(ze,{title:o("supervisor.extensions.details"),children:[e.jsx(de,{label:o("supervisor.extensions.name"),value:r.name}),e.jsx(de,{label:o("supervisor.extensions.version"),value:r.version}),e.jsx(de,{label:o("supervisor.extensions.type"),value:r.type}),e.jsx(de,{label:o("supervisor.extensions.status"),value:r.status})]})]})]})}function ze({title:r,children:o}){return e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r})}),e.jsx("div",{style:{padding:"14px 16px"},children:o})]})}function de({label:r,value:o}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 0",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:120,flexShrink:0},children:r}),e.jsx("span",{style:{fontSize:12,color:"var(--color-text-primary)",fontWeight:500},children:o})]})}const xr={optimize:"var(--color-accent-blue)",alert:"var(--color-accent-red)",automate:"var(--color-accent-green)"};function ur(){const{t:r}=T(),o=m(i=>i.learningStats),t=m(i=>i.learningPatterns),n=m(i=>i.knowledgeEntries),[s,x]=g.useState(""),[a,v]=g.useState(null),p=s?n.filter(i=>i.topic.toLowerCase().includes(s.toLowerCase())||i.content.toLowerCase().includes(s.toLowerCase())||i.tags.some(d=>d.toLowerCase().includes(s.toLowerCase()))):n,y=t.reduce((i,d)=>Math.max(i,d.frequency),1);return e.jsxs("div",{className:"flex h-full overflow-hidden",children:[e.jsxs("div",{style:{width:320,background:"var(--color-bg-primary)",borderRight:"1px solid var(--color-border)",flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--color-text-primary)"},children:r("supervisor.learning.title")}),o&&e.jsx("span",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r("supervisor.learning.cmds_patterns",{cmds:o.totalCommands,patterns:o.uniquePatterns})})]}),e.jsx("input",{value:s,onChange:i=>x(i.target.value),placeholder:r("supervisor.learning.search"),style:{margin:"10px 12px 6px",padding:"8px 12px",borderRadius:8,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-card)",fontSize:12,color:"var(--color-text-primary)",outline:"none"}}),e.jsxs("div",{style:{flex:1,overflowY:"auto"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".06em",color:"var(--color-text-tertiary)",padding:"10px 16px 4px"},children:r("supervisor.learning.command_patterns")}),t.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:12},children:r("supervisor.learning.no_patterns")}):t.map(i=>{const d=(a==null?void 0:a.type)==="pattern"&&a.data.command===i.command;return e.jsxs("button",{type:"button",onClick:()=>v({type:"pattern",data:i}),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 16px",cursor:"pointer",border:"none",width:"100%",textAlign:"left",background:d?"var(--color-tint-exploring)":"none",borderLeft:`3px solid ${d?"var(--color-accent-blue)":"transparent"}`,transition:"all 120ms"},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-exploring)",color:"var(--color-accent-blue)",flexShrink:0},children:e.jsxs("svg",{style:{width:14,height:14,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 17 10 11 4 5"}),e.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i.command}),e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)",display:"flex",gap:8},children:[e.jsxs("span",{children:["x",i.frequency]}),e.jsxs("span",{children:[Math.round(i.successRate*100),"% ",r("supervisor.learning.success_label")]})]})]})]},i.command)}),e.jsxs("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".06em",color:"var(--color-text-tertiary)",padding:"10px 16px 4px"},children:[r("supervisor.learning.knowledge_base")," (",p.length,")"]}),p.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:12},children:r(s?"supervisor.learning.no_matches":"supervisor.learning.empty")}):p.map(i=>{const d=(a==null?void 0:a.type)==="knowledge"&&a.data.id===i.id;return e.jsxs("button",{type:"button",onClick:()=>v({type:"knowledge",data:i}),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 16px",cursor:"pointer",border:"none",width:"100%",textAlign:"left",background:d?"var(--color-tint-exploring)":"none",borderLeft:`3px solid ${d?"var(--color-accent-blue)":"transparent"}`,transition:"all 120ms"},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-completed)",color:"var(--color-accent-green)",flexShrink:0},children:e.jsxs("svg",{style:{width:14,height:14,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"}),e.jsx("path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i.topic}),e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)",display:"flex",gap:8},children:[e.jsx("span",{children:i.source}),e.jsx("span",{children:r("supervisor.learning.used_count",{count:i.usageCount})})]})]})]},i.id)})]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column"},children:a?a.type==="pattern"?e.jsx(vr,{pattern:a.data,maxFrequency:y,suggestions:(o==null?void 0:o.suggestions)??[]}):e.jsx(hr,{entry:a.data}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",fontSize:13},children:r("supervisor.learning.select_detail")})})]})}function vr({pattern:r,maxFrequency:o,suggestions:t}){const{t:n}=T(),s=Math.round(r.frequency/o*100),x=r.successRate>=.9?"var(--color-accent-green)":r.successRate>=.7?"var(--color-accent-blue)":"var(--color-accent-yellow)";return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--color-border-divider)",flexShrink:0},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-exploring)",color:"var(--color-accent-blue)"},children:e.jsxs("svg",{style:{width:18,height:18,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 17 10 11 4 5"}),e.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--color-text-primary)"},children:r.command}),e.jsx("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:n("supervisor.learning.command_pattern")})]})]})}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"flex",flexDirection:"column",gap:20},children:[e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsx(N,{label:n("supervisor.learning.frequency"),value:String(r.frequency)}),e.jsx(N,{label:n("supervisor.learning.success_rate"),value:`${Math.round(r.successRate*100)}%`,valueColor:x}),e.jsx(N,{label:n("supervisor.learning.avg_duration"),value:`${Math.round(r.avgDuration/1e3)}s`})]}),e.jsxs(U,{title:n("supervisor.learning.usage"),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"8px 0"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:80},children:n("supervisor.learning.relative")}),e.jsx("div",{style:{flex:1,height:6,background:"rgba(0,0,0,0.04)",borderRadius:100,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${s}%`,borderRadius:100,background:x}})}),e.jsxs("span",{style:{fontSize:11,color:"var(--color-text-tertiary)"},children:[s,"%"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 0",borderTop:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:120},children:n("supervisor.learning.last_used")}),e.jsx("span",{style:{fontSize:12,color:"var(--color-text-primary)",fontWeight:500},children:r.lastUsed?new Date(r.lastUsed).toLocaleString():"-"})]})]}),r.contexts&&r.contexts.length>0&&e.jsx(U,{title:n("supervisor.learning.contexts"),children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:r.contexts.map(a=>e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:"rgba(145,120,181,0.12)",color:"var(--color-accent-purple)"},children:a},a))})}),t.length>0&&e.jsx(U,{title:n("supervisor.learning.suggestions"),children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:t.map((a,v)=>e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:xr[a.type]??"var(--color-bg-tertiary)",color:"#fff",flexShrink:0},children:a.type}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:a.title}),e.jsx("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:a.description})]})]},v))})})]})]})}function hr({entry:r}){const{t:o}=T();return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--color-border-divider)",flexShrink:0},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-completed)",color:"var(--color-accent-green)"},children:e.jsxs("svg",{style:{width:18,height:18,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"}),e.jsx("path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"})]})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--color-text-primary)"},children:r.topic}),e.jsxs("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:[o("supervisor.learning.knowledge_entry")," - ",r.source]})]})]})}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"flex",flexDirection:"column",gap:20},children:[e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsx(N,{label:o("supervisor.learning.usage_count"),value:String(r.usageCount)}),e.jsx(N,{label:o("supervisor.learning.source"),value:r.source}),e.jsx(N,{label:o("supervisor.learning.last_accessed"),value:r.lastAccessed?new Date(r.lastAccessed).toLocaleDateString():"-"})]}),e.jsx(U,{title:o("supervisor.learning.content"),children:e.jsx("div",{style:{fontSize:12,color:"var(--color-text-primary)",lineHeight:1.6,whiteSpace:"pre-wrap"},children:r.content})}),r.tags.length>0&&e.jsx(U,{title:o("supervisor.learning.tags"),children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:r.tags.map(t=>e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:"rgba(91,141,184,0.12)",color:"var(--color-accent-blue)"},children:t},t))})})]})]})}function N({label:r,value:o,valueColor:t}){return e.jsxs("div",{style:{flex:1,background:"var(--color-bg-primary)",borderRadius:10,padding:14,border:"1px solid var(--color-border-divider)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:r}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:t??"var(--color-text-primary)",marginTop:2},children:o})]})}function U({title:r,children:o}){return e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r})}),e.jsx("div",{style:{padding:"14px 16px"},children:o})]})}const gr=["auto-dispatch","cleanup","report","health-check","learning-analysis","custom"],ue={"auto-dispatch":{bg:"var(--color-tint-verifying)",fg:"var(--color-accent-orange)"},cleanup:{bg:"var(--color-tint-exploring)",fg:"var(--color-accent-blue)"},report:{bg:"var(--color-tint-planning)",fg:"var(--color-accent-purple)"},"health-check":{bg:"var(--color-tint-completed)",fg:"var(--color-accent-green)"},"learning-analysis":{bg:"var(--color-tint-executing)",fg:"var(--color-accent-yellow)"},custom:{bg:"var(--color-tint-pending)",fg:"var(--color-accent-gray)"}},ve={"auto-dispatch":e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"13 17 18 12 13 7"}),e.jsx("polyline",{points:"6 17 11 12 6 7"})]}),cleanup:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),report:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]}),"health-check":e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),"learning-analysis":e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"}),e.jsx("path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"})]}),custom:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09"})]})};function yr(){const{t:r}=T(),o=m(u=>u.scheduledTasks),t=m(u=>u.createSchedule),n=m(u=>u.deleteSchedule),s=m(u=>u.toggleSchedule),x=m(u=>u.runSchedule),[a,v]=g.useState(null),[p,y]=g.useState(""),[i,d]=g.useState(!1),[k,j]=g.useState(""),[f,I]=g.useState(""),[$,L]=g.useState("custom"),B=p?o.filter(u=>u.name.toLowerCase().includes(p.toLowerCase())):o,C=o.find(u=>u.id===a)??null,b=async()=>{!k.trim()||!f.trim()||(await t({name:k.trim(),cronExpression:f.trim(),taskType:$,config:{},enabled:!0}),j(""),I(""),L("custom"),d(!1))};return e.jsxs("div",{className:"flex h-full overflow-hidden",children:[e.jsxs("div",{style:{width:320,background:"var(--color-bg-primary)",borderRight:"1px solid var(--color-border)",flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--color-text-primary)"},children:r("supervisor.schedule.title")}),e.jsx("button",{type:"button",onClick:()=>d(!i),style:{fontSize:12,fontWeight:600,padding:"7px 16px",borderRadius:8,border:"none",cursor:"pointer",background:"var(--color-text-primary)",color:"#fff"},children:r(i?"supervisor.schedule.cancel":"supervisor.schedule.new")})]}),i&&e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)",display:"flex",flexDirection:"column",gap:8},children:[e.jsx("input",{value:k,onChange:u=>j(u.target.value),placeholder:r("supervisor.schedule.task_name"),style:{...be}}),e.jsx("input",{value:f,onChange:u=>I(u.target.value),placeholder:"*/5 * * * *",style:{...be,fontFamily:"'SF Mono', Consolas, monospace"}}),e.jsx("select",{value:$,onChange:u=>L(u.target.value),style:{...be},children:gr.map(u=>e.jsx("option",{value:u,children:u},u))}),e.jsx("button",{type:"button",onClick:b,disabled:!k.trim()||!f.trim(),style:{fontSize:12,fontWeight:600,padding:"7px 16px",borderRadius:8,border:"none",cursor:"pointer",background:"var(--color-accent-green)",color:"#fff",opacity:!k.trim()||!f.trim()?.4:1},children:r("supervisor.schedule.create")})]}),e.jsx("input",{value:p,onChange:u=>y(u.target.value),placeholder:r("supervisor.schedule.filter"),style:{margin:"10px 12px 6px",padding:"8px 12px",borderRadius:8,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-card)",fontSize:12,color:"var(--color-text-primary)",outline:"none"}}),e.jsx("div",{style:{flex:1,overflowY:"auto"},children:B.map(u=>{const E=u.id===a,w=ue[u.taskType]??ue.custom;return e.jsxs("button",{type:"button",onClick:()=>v(u.id),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 16px",cursor:"pointer",border:"none",background:E?"var(--color-tint-exploring)":"none",borderLeft:`3px solid ${E?"var(--color-accent-blue)":"transparent"}`,width:"100%",textAlign:"left",transition:"all 120ms"},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:w.bg,color:w.fg,flexShrink:0},children:e.jsx("span",{style:{width:14,height:14,strokeWidth:1.8,display:"flex"},children:ve[u.taskType]??ve.custom})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.name}),e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)",display:"flex",gap:8},children:[e.jsx("span",{style:{fontFamily:"'SF Mono', Consolas, monospace"},children:u.cronExpression}),u.lastRun&&e.jsx("span",{children:mr(u.lastRun)})]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:2,flexShrink:0},children:e.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"2px 8px",borderRadius:100,background:u.enabled?"rgba(90,158,120,0.12)":"rgba(160,157,151,0.12)",color:u.enabled?"var(--color-accent-green)":"var(--color-accent-gray)"},children:u.enabled?r("supervisor.schedule.active"):r("supervisor.schedule.paused")})})]},u.id)})})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column"},children:C?e.jsx(fr,{task:C,onToggle:s,onRun:x,onDelete:n}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",fontSize:13},children:r("supervisor.schedule.select_detail")})})]})}function fr({task:r,onToggle:o,onRun:t,onDelete:n}){const{t:s}=T(),x=ue[r.taskType]??ue.custom;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--color-border-divider)",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:x.bg,color:x.fg},children:e.jsx("span",{style:{width:18,height:18,strokeWidth:1.8,display:"flex"},children:ve[r.taskType]??ve.custom})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--color-text-primary)"},children:r.name}),e.jsx("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:r.taskType})]})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{type:"button",onClick:()=>t(r.id),style:{...Re},children:s("supervisor.schedule.run_now")}),e.jsx(jr,{on:r.enabled,onToggle:()=>o(r.id,!r.enabled)}),e.jsx("button",{type:"button",onClick:()=>n(r.id),style:{...Re,color:"var(--color-accent-red)"},children:s("supervisor.schedule.delete")})]})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"flex",flexDirection:"column",gap:20},children:[e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsxs("div",{style:{flex:1,background:"var(--color-bg-primary)",borderRadius:10,padding:14,border:"1px solid var(--color-border-divider)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:s("supervisor.schedule.total_runs")}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:"var(--color-text-primary)",marginTop:2},children:r.history.length})]}),e.jsxs("div",{style:{flex:1,background:"var(--color-bg-primary)",borderRadius:10,padding:14,border:"1px solid var(--color-border-divider)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:s("supervisor.schedule.success_rate")}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:"var(--color-accent-green)",marginTop:2},children:r.history.length>0?`${Math.round(r.history.filter(a=>a.status==="success").length/r.history.length*100)}%`:"-"})]}),e.jsxs("div",{style:{flex:1,background:"var(--color-bg-primary)",borderRadius:10,padding:14,border:"1px solid var(--color-border-divider)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:s("supervisor.schedule.next_run")}),e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--color-text-primary)",marginTop:6},children:r.nextRun?new Date(r.nextRun).toLocaleString():"-"})]})]}),e.jsxs(We,{title:s("supervisor.schedule.configuration"),children:[e.jsx(ce,{label:s("supervisor.schedule.schedule_label"),value:r.cronExpression,mono:!0}),e.jsx(ce,{label:s("supervisor.schedule.type"),value:r.taskType}),e.jsx(ce,{label:s("supervisor.schedule.last_run"),value:r.lastRun?new Date(r.lastRun).toLocaleString():s("supervisor.schedule.never")}),Object.entries(r.config).map(([a,v])=>e.jsx(ce,{label:a,value:String(v)},a))]}),e.jsx(We,{title:s("supervisor.schedule.run_history"),children:r.history.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:"8px 0"},children:s("supervisor.schedule.no_runs")}):e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:r.history.slice(-10).reverse().map((a,v)=>{const p=a.status==="success"?"var(--color-accent-green)":a.status==="failed"?"var(--color-accent-red)":"var(--color-accent-gray)";return e.jsxs("div",{style:{display:"flex",gap:12,padding:"8px 0",position:"relative"},children:[v<Math.min(r.history.length,10)-1&&e.jsx("div",{style:{position:"absolute",left:11,top:24,bottom:-8,width:1,background:"var(--color-border-divider)"}}),e.jsx("div",{style:{width:22,height:22,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"2px solid var(--color-bg-card)"},children:e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:p}})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:10,color:"var(--color-text-placeholder)",fontFamily:"'SF Mono', Consolas, monospace"},children:new Date(a.timestamp).toLocaleString()}),e.jsx("div",{style:{fontSize:12,color:"var(--color-text-primary)"},children:a.status}),a.duration!=null&&e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:[Math.round(a.duration/1e3),"s"]})]})]},v)})})})]})]})}function We({title:r,children:o}){return e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r})}),e.jsx("div",{style:{padding:"14px 16px"},children:o})]})}function ce({label:r,value:o,mono:t}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 0",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:120,flexShrink:0},children:r}),e.jsx("span",{style:{fontSize:12,color:"var(--color-text-primary)",fontWeight:500,fontFamily:t?"'SF Mono', Consolas, monospace":void 0},children:o})]})}function jr({on:r,onToggle:o}){return e.jsx("button",{type:"button",onClick:o,style:{width:36,height:20,borderRadius:100,background:r?"var(--color-accent-green)":"var(--color-border)",border:"none",cursor:"pointer",position:"relative",transition:"background 200ms"},children:e.jsx("span",{style:{position:"absolute",top:2,left:r?18:2,width:16,height:16,borderRadius:"50%",background:"#fff",transition:"left 200ms",boxShadow:"0 1px 3px rgba(0,0,0,0.15)"}})})}function mr(r){const o=Date.now()-new Date(r).getTime(),t=Math.floor(o/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;const n=Math.floor(t/60);return n<24?`${n}h ago`:new Date(r).toLocaleDateString()}const be={padding:"8px 12px",borderRadius:8,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-card)",fontSize:12,color:"var(--color-text-primary)",outline:"none"},Re={fontSize:11,fontWeight:600,padding:"5px 12px",borderRadius:8,border:"1px solid var(--color-border)",background:"none",color:"var(--color-text-secondary)",cursor:"pointer"},Te=[{id:"commander",labelKey:"supervisor.tabs.commander",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),e.jsx("path",{d:"M2 17l10 5 10-5"}),e.jsx("path",{d:"M2 12l10 5 10-5"})]})},{id:"executions",labelKey:"supervisor.tabs.executions",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]})},{id:"schedule",labelKey:"supervisor.tabs.schedules",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]})},{id:"learning",labelKey:"supervisor.tabs.learning",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"}),e.jsx("path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"})]})},{id:"extensions",labelKey:"supervisor.tabs.extensions",icon:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M14.7 6.3a1 1 0 000 1.4l1.6 1.6a1 1 0 001.4 0l3.77-3.77a6 6 0 01-7.94 7.94l-6.91 6.91a2.12 2.12 0 01-3-3l6.91-6.91a6 6 0 017.94-7.94l-3.76 3.76z"})})},{id:"prompts",labelKey:"supervisor.tabs.prompts",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 7 4 4 20 4 20 7"}),e.jsx("line",{x1:"9",y1:"20",x2:"15",y2:"20"}),e.jsx("line",{x1:"12",y1:"4",x2:"12",y2:"20"})]})},{id:"coordinator",labelKey:"supervisor.tabs.coordinator",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}];function Sr(){const{t:r}=T(),o=m(c=>c.activeTab),t=m(c=>c.setActiveTab),n=m(c=>c.fetchLearningStats),s=m(c=>c.fetchSchedules),x=m(c=>c.fetchExtensions),a=m(c=>c.fetchPromptModes),v=m(c=>c.scheduledTasks),p=m(c=>c.extensions),y=R(c=>c.slots),i=R(c=>c.queue),d=R(c=>c.supervisorStatus),k=R(c=>c.toggleSupervisor),j=R(c=>c.commanderState),f=_(c=>c.session),I=_(c=>c.start),$=_(c=>c.stop),[L,B]=g.useState(!1);g.useEffect(()=>{n(),s(),x(),a()},[n,s,x,a]);const C=g.useMemo(()=>Object.values(y),[y]),b=(d==null?void 0:d.enabled)??!1,u=(d==null?void 0:d.stats.totalDispatched)??0,E=(d==null?void 0:d.stats.totalCompleted)??0,w=u>0?`${Math.round(E/u*100)}%`:"-",h=f!=null&&f.status!=="idle"&&f.status!=="completed"&&f.status!=="failed",z=(f==null?void 0:f.steps)??[],F=z.filter(c=>c.status==="completed"||c.status==="skipped").length,he=g.useCallback(async()=>{await k(!b)},[k,b]),O=g.useCallback(()=>{h?$():I("continue",void 0,!0)},[h,$,I]),H=g.useCallback(c=>{t(c),B(!1)},[t]),G={schedule:v.length,extensions:p.length};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",background:"var(--color-bg-primary)"},children:[e.jsx("nav",{style:{flexShrink:0,display:"flex",alignItems:"center",padding:"0 24px",background:"var(--color-bg-secondary)",borderBottom:"1px solid var(--color-border)"},children:Te.map(c=>{const Y=o===c.id,A=G[c.id]??0;return e.jsxs("button",{type:"button",onClick:()=>t(c.id),style:{display:"flex",alignItems:"center",gap:6,padding:"10px 16px",fontSize:12,fontWeight:Y?600:500,color:Y?"var(--color-text-primary)":"var(--color-text-tertiary)",background:"none",border:"none",borderBottom:`2px solid ${Y?"var(--color-text-primary)":"transparent"}`,cursor:"pointer",transition:"color 120ms, border-color 120ms"},children:[e.jsx("span",{style:{width:14,height:14,display:"flex"},children:c.icon}),r(c.labelKey),A>0&&e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"1px 6px",borderRadius:100,background:"var(--color-bg-card)",color:"var(--color-text-tertiary)"},children:A})]},c.id)})}),e.jsxs("main",{style:{flex:1,minHeight:0,overflow:"hidden"},children:[o==="commander"&&e.jsx(Ee,{}),o==="executions"&&e.jsx(Ae,{}),o==="coordinator"&&e.jsx(Ke,{}),o==="prompts"&&e.jsx(dr,{}),o==="extensions"&&e.jsx(cr,{}),o==="learning"&&e.jsx(ur,{}),o==="schedule"&&e.jsx(yr,{})]}),L&&e.jsx("div",{onClick:()=>B(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.25)",zIndex:90,transition:"opacity 200ms"}}),e.jsxs("div",{style:{position:"fixed",left:0,right:0,bottom:36,maxHeight:L?"60vh":0,overflow:"hidden",background:"var(--color-bg-card)",borderTop:L?"1px solid var(--color-border)":"none",borderRadius:"12px 12px 0 0",zIndex:91,transition:"max-height 300ms cubic-bezier(0.4,0,0.2,1)",boxShadow:L?"0 -4px 24px rgba(0,0,0,0.08)":"none"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"8px 0 4px",cursor:"pointer"},onClick:()=>B(!1),children:e.jsx("div",{style:{width:32,height:4,borderRadius:2,background:"var(--color-border)"}})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"180px 1fr 1fr",gap:16,padding:"8px 24px 24px",overflowY:"auto",maxHeight:"calc(60vh - 40px)"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)",padding:"4px 8px",marginBottom:4},children:"Navigate"}),Te.map(c=>e.jsxs("button",{type:"button",onClick:()=>H(c.id),style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",fontSize:12,fontWeight:o===c.id?600:400,color:o===c.id?"var(--color-text-primary)":"var(--color-text-secondary)",background:o===c.id?"var(--color-bg-active)":"none",border:"none",borderRadius:6,cursor:"pointer",textAlign:"left",transition:"background 120ms"},children:[e.jsx("span",{style:{width:14,height:14,display:"flex"},children:c.icon}),r(c.labelKey)]},c.id))]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{borderRadius:10,border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--color-border-divider)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--color-accent-blue)"},children:"Issue Executions"}),e.jsxs("span",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:[C.length," running"]})]}),e.jsx("div",{style:{padding:"8px 14px"},children:C.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",padding:"4px 0"},children:"No active slots"}):C.slice(0,5).map(c=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 0",fontSize:11},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--color-accent-blue)",flexShrink:0}}),e.jsx("span",{style:{fontWeight:500,color:"var(--color-text-primary)"},children:c.issueId}),e.jsx("span",{style:{color:"var(--color-text-tertiary)",marginLeft:"auto"},children:c.executor})]},c.processId))})]}),e.jsxs("div",{style:{borderRadius:10,border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--color-border-divider)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--color-accent-purple)"},children:"Workflow Sessions"}),e.jsx("span",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:f?f.status:"idle"})]}),e.jsx("div",{style:{padding:"8px 14px"},children:f?e.jsxs("div",{style:{fontSize:11},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 0"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--color-text-primary)"},children:f.chainName??"Session"}),e.jsxs("span",{style:{color:"var(--color-text-tertiary)"},children:["Step ",f.currentStep+1,"/",z.length]})]}),f.intent&&e.jsx("div",{style:{color:"var(--color-text-secondary)",padding:"2px 0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.intent})]}):e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",padding:"4px 0"},children:"No active session"})})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{borderRadius:10,border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--color-text-primary)"},children:"Commander"})}),e.jsxs("div",{style:{padding:"8px 14px",fontSize:11},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 0"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--color-text-secondary)"},children:"Status:"}),e.jsx("span",{style:{fontWeight:600,color:(j==null?void 0:j.status)==="dispatching"?"var(--color-accent-green)":(j==null?void 0:j.status)==="thinking"?"var(--color-accent-blue)":"var(--color-text-tertiary)"},children:(j==null?void 0:j.status)??"idle"})]}),(d==null?void 0:d.isCommanderActive)!==void 0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 0"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--color-text-secondary)"},children:"Active:"}),e.jsx("span",{style:{color:d.isCommanderActive?"var(--color-accent-green)":"var(--color-text-tertiary)"},children:d.isCommanderActive?"Yes":"No"})]})]})]}),e.jsxs("div",{style:{borderRadius:10,border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--color-text-primary)"},children:"Suggestions"})}),e.jsx("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--color-text-tertiary)"},children:"No suggestions"})]})]})]})]}),e.jsxs("footer",{style:{flexShrink:0,display:"flex",alignItems:"center",height:36,padding:"0 16px",background:"var(--color-bg-secondary)",borderTop:"1px solid var(--color-border)",gap:12,fontSize:11,zIndex:92},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontWeight:600,color:"var(--color-text-primary)"},children:"Supervisor"}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:b?"rgba(90,158,120,0.12)":"rgba(160,157,151,0.12)",color:b?"var(--color-accent-green)":"var(--color-accent-gray)"},children:[b&&e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--color-accent-green)",animation:"pulse 2s ease-in-out infinite"}}),b?"Active":"Inactive"]})]}),e.jsx("div",{style:{width:1,height:16,background:"var(--color-border-divider)"}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,color:"var(--color-accent-blue)"},children:"Issues"}),e.jsxs("span",{style:{color:"var(--color-text-secondary)"},children:[C.length," running"]}),e.jsxs("span",{style:{color:"var(--color-text-tertiary)"},children:[i.length," queued"]}),e.jsxs("span",{style:{color:"var(--color-text-secondary)"},children:[w," success"]})]}),e.jsx("div",{style:{width:1,height:16,background:"var(--color-border-divider)"}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,color:"var(--color-accent-purple)"},children:"Workflow"}),e.jsx("span",{style:{color:"var(--color-text-secondary)"},children:h?"1 running":"0 running"}),e.jsx("span",{style:{color:"var(--color-text-tertiary)"},children:z.length>0?`${F}/${z.length} steps`:"-"})]}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:8},children:[e.jsxs("button",{type:"button",onClick:()=>B(c=>!c),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 10px",fontSize:10,fontWeight:600,borderRadius:6,border:"1px solid var(--color-border)",background:L?"var(--color-bg-active)":"none",color:"var(--color-text-secondary)",cursor:"pointer",transition:"background 120ms"},children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{width:12,height:12},children:e.jsx("polyline",{points:L?"6 15 12 9 18 15":"6 9 12 15 18 9"})}),"Overview"]}),e.jsx("button",{type:"button",onClick:he,style:{padding:"3px 10px",fontSize:10,fontWeight:600,borderRadius:6,border:"1px solid",borderColor:b?"var(--color-accent-blue)":"var(--color-border)",background:b?"rgba(91,141,184,0.12)":"none",color:b?"var(--color-accent-blue)":"var(--color-text-tertiary)",cursor:"pointer",transition:"all 120ms"},children:"Issues"}),e.jsx("button",{type:"button",onClick:O,style:{padding:"3px 10px",fontSize:10,fontWeight:600,borderRadius:6,border:"1px solid",borderColor:h?"var(--color-accent-purple)":"var(--color-border)",background:h?"rgba(145,120,181,0.12)":"none",color:h?"var(--color-accent-purple)":"var(--color-text-tertiary)",cursor:"pointer",transition:"all 120ms"},children:"Workflow"})]})]}),e.jsx("style",{children:`
2
2
  @keyframes pulse {
3
3
  0%, 100% { opacity: 1; }
4
4
  50% { opacity: 0.4; }