@winspan/claude-forge 8.37.0 → 8.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/dist/agents/definition.d.ts +8 -2
  2. package/dist/agents/definition.d.ts.map +1 -1
  3. package/dist/agents/definition.js.map +1 -1
  4. package/dist/agents/methodologies/agent-builder.d.ts +21 -0
  5. package/dist/agents/methodologies/agent-builder.d.ts.map +1 -0
  6. package/dist/agents/methodologies/agent-builder.js +102 -0
  7. package/dist/agents/methodologies/agent-builder.js.map +1 -0
  8. package/dist/agents/methodologies/phases/bmad/analyze.d.ts +3 -0
  9. package/dist/agents/methodologies/phases/bmad/analyze.d.ts.map +1 -0
  10. package/dist/agents/methodologies/phases/bmad/analyze.js +18 -0
  11. package/dist/agents/methodologies/phases/bmad/analyze.js.map +1 -0
  12. package/dist/agents/methodologies/phases/bmad/design.d.ts +3 -0
  13. package/dist/agents/methodologies/phases/bmad/design.d.ts.map +1 -0
  14. package/dist/agents/methodologies/phases/bmad/design.js +17 -0
  15. package/dist/agents/methodologies/phases/bmad/design.js.map +1 -0
  16. package/dist/agents/methodologies/phases/bmad/implement.d.ts +3 -0
  17. package/dist/agents/methodologies/phases/bmad/implement.d.ts.map +1 -0
  18. package/dist/agents/methodologies/phases/bmad/implement.js +16 -0
  19. package/dist/agents/methodologies/phases/bmad/implement.js.map +1 -0
  20. package/dist/agents/methodologies/phases/bmad/index.d.ts +6 -0
  21. package/dist/agents/methodologies/phases/bmad/index.d.ts.map +1 -0
  22. package/dist/agents/methodologies/phases/bmad/index.js +6 -0
  23. package/dist/agents/methodologies/phases/bmad/index.js.map +1 -0
  24. package/dist/agents/methodologies/phases/bmad/review.d.ts +3 -0
  25. package/dist/agents/methodologies/phases/bmad/review.d.ts.map +1 -0
  26. package/dist/agents/methodologies/phases/bmad/review.js +16 -0
  27. package/dist/agents/methodologies/phases/bmad/review.js.map +1 -0
  28. package/dist/agents/methodologies/phases/bmad/test.d.ts +3 -0
  29. package/dist/agents/methodologies/phases/bmad/test.d.ts.map +1 -0
  30. package/dist/agents/methodologies/phases/bmad/test.js +20 -0
  31. package/dist/agents/methodologies/phases/bmad/test.js.map +1 -0
  32. package/dist/agents/methodologies/phases/harness/fix.d.ts +3 -0
  33. package/dist/agents/methodologies/phases/harness/fix.d.ts.map +1 -0
  34. package/dist/agents/methodologies/phases/harness/fix.js +16 -0
  35. package/dist/agents/methodologies/phases/harness/fix.js.map +1 -0
  36. package/dist/agents/methodologies/phases/harness/index.d.ts +6 -0
  37. package/dist/agents/methodologies/phases/harness/index.d.ts.map +1 -0
  38. package/dist/agents/methodologies/phases/harness/index.js +6 -0
  39. package/dist/agents/methodologies/phases/harness/index.js.map +1 -0
  40. package/dist/agents/methodologies/phases/harness/reproduce.d.ts +3 -0
  41. package/dist/agents/methodologies/phases/harness/reproduce.d.ts.map +1 -0
  42. package/dist/agents/methodologies/phases/harness/reproduce.js +19 -0
  43. package/dist/agents/methodologies/phases/harness/reproduce.js.map +1 -0
  44. package/dist/agents/methodologies/phases/harness/root-cause.d.ts +3 -0
  45. package/dist/agents/methodologies/phases/harness/root-cause.d.ts.map +1 -0
  46. package/dist/agents/methodologies/phases/harness/root-cause.js +20 -0
  47. package/dist/agents/methodologies/phases/harness/root-cause.js.map +1 -0
  48. package/dist/agents/methodologies/phases/harness/safety-net.d.ts +3 -0
  49. package/dist/agents/methodologies/phases/harness/safety-net.d.ts.map +1 -0
  50. package/dist/agents/methodologies/phases/harness/safety-net.js +16 -0
  51. package/dist/agents/methodologies/phases/harness/safety-net.js.map +1 -0
  52. package/dist/agents/methodologies/phases/harness/verify.d.ts +3 -0
  53. package/dist/agents/methodologies/phases/harness/verify.d.ts.map +1 -0
  54. package/dist/agents/methodologies/phases/harness/verify.js +21 -0
  55. package/dist/agents/methodologies/phases/harness/verify.js.map +1 -0
  56. package/dist/agents/methodologies/presets.d.ts +10 -0
  57. package/dist/agents/methodologies/presets.d.ts.map +1 -0
  58. package/dist/agents/methodologies/presets.js +79 -0
  59. package/dist/agents/methodologies/presets.js.map +1 -0
  60. package/dist/agents/methodologies/types.d.ts +43 -0
  61. package/dist/agents/methodologies/types.d.ts.map +1 -0
  62. package/dist/agents/methodologies/types.js +10 -0
  63. package/dist/agents/methodologies/types.js.map +1 -0
  64. package/dist/agents/methodologies/user-config-loader.d.ts +30 -0
  65. package/dist/agents/methodologies/user-config-loader.d.ts.map +1 -0
  66. package/dist/agents/methodologies/user-config-loader.js +159 -0
  67. package/dist/agents/methodologies/user-config-loader.js.map +1 -0
  68. package/dist/agents/official-agents.d.ts.map +1 -1
  69. package/dist/agents/official-agents.js +3 -0
  70. package/dist/agents/official-agents.js.map +1 -1
  71. package/dist/agents/registry.d.ts +17 -4
  72. package/dist/agents/registry.d.ts.map +1 -1
  73. package/dist/agents/registry.js +58 -4
  74. package/dist/agents/registry.js.map +1 -1
  75. package/dist/cli/commands/agents.js +3 -3
  76. package/dist/cli/commands/agents.js.map +1 -1
  77. package/dist/cli/commands/mcp.d.ts +39 -3
  78. package/dist/cli/commands/mcp.d.ts.map +1 -1
  79. package/dist/cli/commands/mcp.js +87 -38
  80. package/dist/cli/commands/mcp.js.map +1 -1
  81. package/dist/core/storage/rows.d.ts +4 -0
  82. package/dist/core/storage/rows.d.ts.map +1 -1
  83. package/dist/core/storage/schema.sql +9 -0
  84. package/dist/core/storage/sqlite.d.ts +25 -0
  85. package/dist/core/storage/sqlite.d.ts.map +1 -1
  86. package/dist/core/storage/sqlite.js +89 -3
  87. package/dist/core/storage/sqlite.js.map +1 -1
  88. package/dist/engine/conventions/routing.yaml +160 -4
  89. package/dist/skills/tools/skill-invoke.d.ts +15 -0
  90. package/dist/skills/tools/skill-invoke.d.ts.map +1 -1
  91. package/dist/skills/tools/skill-invoke.js +29 -0
  92. package/dist/skills/tools/skill-invoke.js.map +1 -1
  93. package/dist/web/routes/workflows.d.ts +19 -0
  94. package/dist/web/routes/workflows.d.ts.map +1 -0
  95. package/dist/web/routes/workflows.js +86 -0
  96. package/dist/web/routes/workflows.js.map +1 -0
  97. package/dist/web/server.d.ts.map +1 -1
  98. package/dist/web/server.js +2 -0
  99. package/dist/web/server.js.map +1 -1
  100. package/dist/web/static/assets/{AIConfig-D4VglzCl.js → AIConfig-R5wZ3ZKT.js} +2 -2
  101. package/dist/web/static/assets/{AIConfig-D4VglzCl.js.map → AIConfig-R5wZ3ZKT.js.map} +1 -1
  102. package/dist/web/static/assets/{Agents-ne5lXc7V.js → Agents-Beg34V1g.js} +2 -2
  103. package/dist/web/static/assets/{Agents-ne5lXc7V.js.map → Agents-Beg34V1g.js.map} +1 -1
  104. package/dist/web/static/assets/{Dashboard-D4j0Zmek.js → Dashboard-Cy1xsj1J.js} +2 -2
  105. package/dist/web/static/assets/{Dashboard-D4j0Zmek.js.map → Dashboard-Cy1xsj1J.js.map} +1 -1
  106. package/dist/web/static/assets/{Drawer-Lo5ihVP-.js → Drawer-DcU3ln98.js} +2 -2
  107. package/dist/web/static/assets/{Drawer-Lo5ihVP-.js.map → Drawer-DcU3ln98.js.map} +1 -1
  108. package/dist/web/static/assets/{Events-DBJ1B7OW.js → Events-mFhXl4zI.js} +2 -2
  109. package/dist/web/static/assets/{Events-DBJ1B7OW.js.map → Events-mFhXl4zI.js.map} +1 -1
  110. package/dist/web/static/assets/{ExecutionTrace-Du9XADc1.js → ExecutionTrace-DG901hLR.js} +2 -2
  111. package/dist/web/static/assets/{ExecutionTrace-Du9XADc1.js.map → ExecutionTrace-DG901hLR.js.map} +1 -1
  112. package/dist/web/static/assets/{Routing-BNQ09OlH.js → Routing-B7BFLfjh.js} +2 -2
  113. package/dist/web/static/assets/{Routing-BNQ09OlH.js.map → Routing-B7BFLfjh.js.map} +1 -1
  114. package/dist/web/static/assets/{SessionDetail-BPrPyMNa.js → SessionDetail-BT0l4RrK.js} +2 -2
  115. package/dist/web/static/assets/{SessionDetail-BPrPyMNa.js.map → SessionDetail-BT0l4RrK.js.map} +1 -1
  116. package/dist/web/static/assets/{Sessions-o3EXsXz9.js → Sessions-C6J_HQ_u.js} +2 -2
  117. package/dist/web/static/assets/{Sessions-o3EXsXz9.js.map → Sessions-C6J_HQ_u.js.map} +1 -1
  118. package/dist/web/static/assets/{Skills-Czt5mkyc.js → Skills-4DQWLaTv.js} +2 -2
  119. package/dist/web/static/assets/{Skills-Czt5mkyc.js.map → Skills-4DQWLaTv.js.map} +1 -1
  120. package/dist/web/static/assets/WorkflowDetail-zhNqUkBE.js +2 -0
  121. package/dist/web/static/assets/WorkflowDetail-zhNqUkBE.js.map +1 -0
  122. package/dist/web/static/assets/Workflows-Btvi-lGw.js +2 -0
  123. package/dist/web/static/assets/Workflows-Btvi-lGw.js.map +1 -0
  124. package/dist/web/static/assets/{export-C0mlC4AT.js → export-BQQZLaHV.js} +2 -2
  125. package/dist/web/static/assets/{export-C0mlC4AT.js.map → export-BQQZLaHV.js.map} +1 -1
  126. package/dist/web/static/assets/index-Cgr9qMtq.js +3 -0
  127. package/dist/web/static/assets/index-Cgr9qMtq.js.map +1 -0
  128. package/dist/web/static/assets/index-CngWb5gC.css +1 -0
  129. package/dist/web/static/assets/{lucide-Bu44HVAM.js → lucide-53bR2rki.js} +46 -31
  130. package/dist/web/static/assets/lucide-53bR2rki.js.map +1 -0
  131. package/dist/web/static/index.html +3 -3
  132. package/package.json +1 -1
  133. package/dist/web/static/assets/index-B1J7nBu0.js +0 -3
  134. package/dist/web/static/assets/index-B1J7nBu0.js.map +0 -1
  135. package/dist/web/static/assets/index-BVqk4bSO.css +0 -1
  136. package/dist/web/static/assets/lucide-Bu44HVAM.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{j as e,r as o}from"./react-vendor-CSp-GLFF.js";import{u as j}from"./query-C99w429o.js";import{D as y}from"./Drawer-Lo5ihVP-.js";import{d as N}from"./vendor-CMMjVdZs.js";import{f as v,a as b,z as w}from"./date-fns-CZ_bHujz.js";import{h as S,F as C,G as _,a as f,D,A as E,g as F}from"./lucide-Bu44HVAM.js";import{S as q,g as M,d as z,a as I}from"./export-C0mlC4AT.js";import{u as L}from"./index-B1J7nBu0.js";import"./react-router-I-HqunH7.js";import"./syntax-highlighter-44FakypI.js";async function T(r){const a=await fetch(`/api/sessions/${r}/detail`);if(!a.ok)throw new Error("Failed to fetch session detail");return a.json()}function $({sessionId:r}){const{data:a,isLoading:l,error:m}=j({queryKey:["session-detail",r],queryFn:()=>T(r),enabled:!!r});return l?e.jsx("div",{className:"p-6 text-gray-500",children:"加载中..."}):m||!a?e.jsx("div",{className:"p-6 text-red-600",children:"加载失败"}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Session ID"}),e.jsx("div",{className:"text-sm font-mono text-gray-900 break-all",children:a.session.session_id})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 pb-4 border-b border-gray-200",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"事件数"}),e.jsx("div",{className:"text-lg font-semibold",children:a.session.event_count})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"任务数"}),e.jsx("div",{className:"text-lg font-semibold",children:a.tasks.length})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"开始时间"}),e.jsx("div",{className:"text-sm",children:a.session.start_time?v(new Date(a.session.start_time),"MM-dd HH:mm:ss"):"-"})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-700 mb-3",children:"任务列表"}),e.jsx("div",{className:"space-y-3",children:a.tasks.map(s=>e.jsxs("div",{className:"border border-gray-200 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-900 flex-1 mr-2",children:s.title}),e.jsx("span",{className:N("px-2 py-0.5 text-xs font-medium rounded-full whitespace-nowrap",s.status==="completed"&&"bg-green-100 text-green-700",s.status==="active"&&"bg-blue-100 text-blue-700",s.status==="abandoned"&&"bg-gray-100 text-gray-600"),children:s.status})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-3 text-xs",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-gray-500 mb-1 flex items-center gap-1",children:[e.jsx(S,{className:"h-3 w-3"}),"工具使用"]}),e.jsx("div",{className:"space-y-0.5",children:Object.entries(s.summary.toolUsage).slice(0,4).map(([i,c])=>e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-600",children:i}),e.jsx("span",{className:"font-mono text-gray-900",children:c})]},i))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-gray-500 mb-1 flex items-center gap-1",children:[e.jsx(C,{className:"h-3 w-3"}),"文件变更"]}),e.jsxs("div",{className:"text-gray-700",children:[s.summary.filesChanged.length," 个"]}),s.summary.filesChanged.slice(0,3).map(i=>e.jsx("div",{className:"text-gray-500 truncate text-[10px]",title:i,children:i.split("/").pop()},i))]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-gray-500 mb-1 flex items-center gap-1",children:[e.jsx(_,{className:"h-3 w-3"}),"提交"]}),e.jsxs("div",{className:"text-gray-700",children:[s.summary.commits.length," 次"]})]})]}),s.prompts.length>0&&e.jsxs("div",{className:"border-t border-gray-100 pt-3",children:[e.jsxs("div",{className:"text-xs text-gray-500 mb-2 flex items-center gap-1",children:[e.jsx(f,{className:"h-3 w-3"}),"用户提示 (",s.prompts.length,")"]}),e.jsxs("div",{className:"space-y-1.5",children:[s.prompts.slice(0,3).map((i,c)=>e.jsx("div",{className:"text-xs bg-gray-50 rounded p-2",children:e.jsx("p",{className:"text-gray-700 line-clamp-2",children:i.content})},c)),s.prompts.length>3&&e.jsxs("div",{className:"text-xs text-gray-400",children:["还有 ",s.prompts.length-3," 条..."]})]})]})]},s.id))})]})]})}async function k(){const r=await fetch("/api/sessions?limit=200");if(!r.ok)throw new Error("Failed to fetch sessions");return r.json()}function U(){const[r,a]=o.useState(null),[l,m]=o.useState(""),[s,i]=o.useState(!1),c=L(),{data:x,isLoading:u,error:h}=j({queryKey:["sessions"],queryFn:k,refetchInterval:1e4}),n=o.useMemo(()=>{if(!x)return[];if(!l.trim())return x;const t=l.toLowerCase();return x.filter(d=>{var g;return((g=d.first_prompt)==null?void 0:g.toLowerCase().includes(t))||d.session_id.toLowerCase().includes(t)})},[x,l]),p=t=>{const d=M();t==="json"?z(`sessions-${d}.json`,n):I(`sessions-${d}.csv`,n),c.success(`已导出 ${n.length} 个会话`),i(!1)};return u?e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-6",children:"会话"}),e.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:e.jsx("p",{className:"text-gray-600",children:"加载中..."})})]}):h?e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-6",children:"会话"}),e.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:e.jsxs("p",{className:"text-red-600",children:["加载失败: ",h.message]})})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 flex-wrap gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"会话"}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(q,{value:l,onChange:m,placeholder:"搜索 session / 提示...",className:"w-64"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>i(t=>!t),disabled:n.length===0,className:"inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-white border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50",children:[e.jsx(D,{className:"h-4 w-4"}),"导出"]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>i(!1)}),e.jsxs("div",{className:"absolute right-0 mt-1 bg-white border border-gray-200 rounded-md shadow-lg z-20",children:[e.jsx("button",{onClick:()=>p("json"),className:"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50",children:"导出为 JSON"}),e.jsx("button",{onClick:()=>p("csv"),className:"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50",children:"导出为 CSV"})]})]})]})]})]}),e.jsxs("div",{className:"text-sm text-gray-500 mb-3",children:["显示 ",n.length," 个 ",l&&"(已过滤)"]}),e.jsx("div",{className:"bg-white rounded-lg shadow overflow-hidden",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Session ID"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"首次提示"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"事件数"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"时间"})]})}),e.jsxs("tbody",{className:"bg-white divide-y divide-gray-200",children:[n.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50 cursor-pointer",onClick:()=>a(t.session_id),children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-indigo-600 font-mono",children:[e.jsx(f,{className:"h-4 w-4"}),t.session_id.slice(0,12),"..."]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("p",{className:"text-sm text-gray-900 max-w-md truncate",children:t.first_prompt||"(无提示)"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("span",{className:"inline-flex items-center gap-1 text-sm text-gray-600",children:[e.jsx(E,{className:"h-4 w-4"}),t.event_count]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(F,{className:"h-4 w-4"}),t.start_time?b(new Date(t.start_time),{addSuffix:!0,locale:w}):"-"]})})]},t.session_id)),n.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-6 py-12 text-center text-gray-500",children:l?"无匹配结果":"暂无会话记录"})})]})]})}),e.jsx(y,{open:r!==null,onClose:()=>a(null),title:"会话详情",width:"w-[800px]",children:r&&e.jsx($,{sessionId:r})})]})}export{U as default};
2
- //# sourceMappingURL=Sessions-o3EXsXz9.js.map
1
+ import{j as e,r as o}from"./react-vendor-CSp-GLFF.js";import{u as j}from"./query-C99w429o.js";import{D as y}from"./Drawer-DcU3ln98.js";import{d as N}from"./vendor-CMMjVdZs.js";import{f as v,a as b,z as w}from"./date-fns-CZ_bHujz.js";import{h as S,F as C,i as _,a as f,D,A as E,g as F}from"./lucide-53bR2rki.js";import{S as q,g as M,d as z,a as I}from"./export-BQQZLaHV.js";import{u as L}from"./index-Cgr9qMtq.js";import"./react-router-I-HqunH7.js";import"./syntax-highlighter-44FakypI.js";async function T(r){const a=await fetch(`/api/sessions/${r}/detail`);if(!a.ok)throw new Error("Failed to fetch session detail");return a.json()}function $({sessionId:r}){const{data:a,isLoading:l,error:m}=j({queryKey:["session-detail",r],queryFn:()=>T(r),enabled:!!r});return l?e.jsx("div",{className:"p-6 text-gray-500",children:"加载中..."}):m||!a?e.jsx("div",{className:"p-6 text-red-600",children:"加载失败"}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Session ID"}),e.jsx("div",{className:"text-sm font-mono text-gray-900 break-all",children:a.session.session_id})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 pb-4 border-b border-gray-200",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"事件数"}),e.jsx("div",{className:"text-lg font-semibold",children:a.session.event_count})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"任务数"}),e.jsx("div",{className:"text-lg font-semibold",children:a.tasks.length})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"开始时间"}),e.jsx("div",{className:"text-sm",children:a.session.start_time?v(new Date(a.session.start_time),"MM-dd HH:mm:ss"):"-"})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-700 mb-3",children:"任务列表"}),e.jsx("div",{className:"space-y-3",children:a.tasks.map(s=>e.jsxs("div",{className:"border border-gray-200 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-900 flex-1 mr-2",children:s.title}),e.jsx("span",{className:N("px-2 py-0.5 text-xs font-medium rounded-full whitespace-nowrap",s.status==="completed"&&"bg-green-100 text-green-700",s.status==="active"&&"bg-blue-100 text-blue-700",s.status==="abandoned"&&"bg-gray-100 text-gray-600"),children:s.status})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-3 text-xs",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-gray-500 mb-1 flex items-center gap-1",children:[e.jsx(S,{className:"h-3 w-3"}),"工具使用"]}),e.jsx("div",{className:"space-y-0.5",children:Object.entries(s.summary.toolUsage).slice(0,4).map(([i,c])=>e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-600",children:i}),e.jsx("span",{className:"font-mono text-gray-900",children:c})]},i))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-gray-500 mb-1 flex items-center gap-1",children:[e.jsx(C,{className:"h-3 w-3"}),"文件变更"]}),e.jsxs("div",{className:"text-gray-700",children:[s.summary.filesChanged.length," 个"]}),s.summary.filesChanged.slice(0,3).map(i=>e.jsx("div",{className:"text-gray-500 truncate text-[10px]",title:i,children:i.split("/").pop()},i))]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-gray-500 mb-1 flex items-center gap-1",children:[e.jsx(_,{className:"h-3 w-3"}),"提交"]}),e.jsxs("div",{className:"text-gray-700",children:[s.summary.commits.length," 次"]})]})]}),s.prompts.length>0&&e.jsxs("div",{className:"border-t border-gray-100 pt-3",children:[e.jsxs("div",{className:"text-xs text-gray-500 mb-2 flex items-center gap-1",children:[e.jsx(f,{className:"h-3 w-3"}),"用户提示 (",s.prompts.length,")"]}),e.jsxs("div",{className:"space-y-1.5",children:[s.prompts.slice(0,3).map((i,c)=>e.jsx("div",{className:"text-xs bg-gray-50 rounded p-2",children:e.jsx("p",{className:"text-gray-700 line-clamp-2",children:i.content})},c)),s.prompts.length>3&&e.jsxs("div",{className:"text-xs text-gray-400",children:["还有 ",s.prompts.length-3," 条..."]})]})]})]},s.id))})]})]})}async function k(){const r=await fetch("/api/sessions?limit=200");if(!r.ok)throw new Error("Failed to fetch sessions");return r.json()}function U(){const[r,a]=o.useState(null),[l,m]=o.useState(""),[s,i]=o.useState(!1),c=L(),{data:x,isLoading:u,error:h}=j({queryKey:["sessions"],queryFn:k,refetchInterval:1e4}),n=o.useMemo(()=>{if(!x)return[];if(!l.trim())return x;const t=l.toLowerCase();return x.filter(d=>{var g;return((g=d.first_prompt)==null?void 0:g.toLowerCase().includes(t))||d.session_id.toLowerCase().includes(t)})},[x,l]),p=t=>{const d=M();t==="json"?z(`sessions-${d}.json`,n):I(`sessions-${d}.csv`,n),c.success(`已导出 ${n.length} 个会话`),i(!1)};return u?e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-6",children:"会话"}),e.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:e.jsx("p",{className:"text-gray-600",children:"加载中..."})})]}):h?e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-6",children:"会话"}),e.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:e.jsxs("p",{className:"text-red-600",children:["加载失败: ",h.message]})})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 flex-wrap gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"会话"}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(q,{value:l,onChange:m,placeholder:"搜索 session / 提示...",className:"w-64"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>i(t=>!t),disabled:n.length===0,className:"inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-white border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50",children:[e.jsx(D,{className:"h-4 w-4"}),"导出"]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>i(!1)}),e.jsxs("div",{className:"absolute right-0 mt-1 bg-white border border-gray-200 rounded-md shadow-lg z-20",children:[e.jsx("button",{onClick:()=>p("json"),className:"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50",children:"导出为 JSON"}),e.jsx("button",{onClick:()=>p("csv"),className:"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50",children:"导出为 CSV"})]})]})]})]})]}),e.jsxs("div",{className:"text-sm text-gray-500 mb-3",children:["显示 ",n.length," 个 ",l&&"(已过滤)"]}),e.jsx("div",{className:"bg-white rounded-lg shadow overflow-hidden",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Session ID"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"首次提示"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"事件数"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"时间"})]})}),e.jsxs("tbody",{className:"bg-white divide-y divide-gray-200",children:[n.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50 cursor-pointer",onClick:()=>a(t.session_id),children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-indigo-600 font-mono",children:[e.jsx(f,{className:"h-4 w-4"}),t.session_id.slice(0,12),"..."]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("p",{className:"text-sm text-gray-900 max-w-md truncate",children:t.first_prompt||"(无提示)"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("span",{className:"inline-flex items-center gap-1 text-sm text-gray-600",children:[e.jsx(E,{className:"h-4 w-4"}),t.event_count]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(F,{className:"h-4 w-4"}),t.start_time?b(new Date(t.start_time),{addSuffix:!0,locale:w}):"-"]})})]},t.session_id)),n.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-6 py-12 text-center text-gray-500",children:l?"无匹配结果":"暂无会话记录"})})]})]})}),e.jsx(y,{open:r!==null,onClose:()=>a(null),title:"会话详情",width:"w-[800px]",children:r&&e.jsx($,{sessionId:r})})]})}export{U as default};
2
+ //# sourceMappingURL=Sessions-C6J_HQ_u.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Sessions-o3EXsXz9.js","sources":["../../src/components/SessionDetailContent.tsx","../../src/pages/Sessions.tsx"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\nimport { format } from 'date-fns'\nimport { MessageSquare, FileEdit, Terminal, GitCommit } from 'lucide-react'\nimport clsx from 'clsx'\n\ninterface TaskDetail {\n id: string\n title: string\n start_time: string\n end_time?: string\n status: string\n event_count: number\n prompts: Array<{ timestamp: string; content: string }>\n events: Array<any>\n injections: Array<any>\n summary: {\n toolUsage: Record<string, number>\n filesChanged: string[]\n commits: Array<{ timestamp: string; message: string }>\n }\n}\n\ninterface SessionDetailData {\n session: {\n session_id: string\n first_prompt: string\n event_count: number\n start_time: string\n end_time: string\n }\n tasks: TaskDetail[]\n}\n\nasync function fetchSessionDetail(id: string): Promise<SessionDetailData> {\n const res = await fetch(`/api/sessions/${id}/detail`)\n if (!res.ok) throw new Error('Failed to fetch session detail')\n return res.json()\n}\n\ninterface Props {\n sessionId: string\n}\n\nexport default function SessionDetailContent({ sessionId }: Props) {\n const { data, isLoading, error } = useQuery({\n queryKey: ['session-detail', sessionId],\n queryFn: () => fetchSessionDetail(sessionId),\n enabled: !!sessionId,\n })\n\n if (isLoading) {\n return <div className=\"p-6 text-gray-500\">加载中...</div>\n }\n\n if (error || !data) {\n return <div className=\"p-6 text-red-600\">加载失败</div>\n }\n\n return (\n <div className=\"space-y-4\">\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">Session ID</div>\n <div className=\"text-sm font-mono text-gray-900 break-all\">{data.session.session_id}</div>\n </div>\n\n <div className=\"grid grid-cols-3 gap-4 pb-4 border-b border-gray-200\">\n <div>\n <div className=\"text-xs text-gray-500\">事件数</div>\n <div className=\"text-lg font-semibold\">{data.session.event_count}</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500\">任务数</div>\n <div className=\"text-lg font-semibold\">{data.tasks.length}</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500\">开始时间</div>\n <div className=\"text-sm\">\n {data.session.start_time ? format(new Date(data.session.start_time), 'MM-dd HH:mm:ss') : '-'}\n </div>\n </div>\n </div>\n\n <div>\n <h3 className=\"text-sm font-semibold text-gray-700 mb-3\">任务列表</h3>\n <div className=\"space-y-3\">\n {data.tasks.map((task) => (\n <div key={task.id} className=\"border border-gray-200 rounded-lg p-4\">\n <div className=\"flex items-center justify-between mb-3\">\n <h4 className=\"text-sm font-semibold text-gray-900 flex-1 mr-2\">{task.title}</h4>\n <span className={clsx(\n 'px-2 py-0.5 text-xs font-medium rounded-full whitespace-nowrap',\n task.status === 'completed' && 'bg-green-100 text-green-700',\n task.status === 'active' && 'bg-blue-100 text-blue-700',\n task.status === 'abandoned' && 'bg-gray-100 text-gray-600'\n )}>\n {task.status}\n </span>\n </div>\n\n <div className=\"grid grid-cols-3 gap-3 mb-3 text-xs\">\n <div>\n <div className=\"text-gray-500 mb-1 flex items-center gap-1\">\n <Terminal className=\"h-3 w-3\" />工具使用\n </div>\n <div className=\"space-y-0.5\">\n {Object.entries(task.summary.toolUsage).slice(0, 4).map(([tool, count]) => (\n <div key={tool} className=\"flex justify-between\">\n <span className=\"text-gray-600\">{tool}</span>\n <span className=\"font-mono text-gray-900\">{count}</span>\n </div>\n ))}\n </div>\n </div>\n <div>\n <div className=\"text-gray-500 mb-1 flex items-center gap-1\">\n <FileEdit className=\"h-3 w-3\" />文件变更\n </div>\n <div className=\"text-gray-700\">{task.summary.filesChanged.length} 个</div>\n {task.summary.filesChanged.slice(0, 3).map(f => (\n <div key={f} className=\"text-gray-500 truncate text-[10px]\" title={f}>\n {f.split('/').pop()}\n </div>\n ))}\n </div>\n <div>\n <div className=\"text-gray-500 mb-1 flex items-center gap-1\">\n <GitCommit className=\"h-3 w-3\" />提交\n </div>\n <div className=\"text-gray-700\">{task.summary.commits.length} 次</div>\n </div>\n </div>\n\n {task.prompts.length > 0 && (\n <div className=\"border-t border-gray-100 pt-3\">\n <div className=\"text-xs text-gray-500 mb-2 flex items-center gap-1\">\n <MessageSquare className=\"h-3 w-3\" />用户提示 ({task.prompts.length})\n </div>\n <div className=\"space-y-1.5\">\n {task.prompts.slice(0, 3).map((p, i) => (\n <div key={i} className=\"text-xs bg-gray-50 rounded p-2\">\n <p className=\"text-gray-700 line-clamp-2\">{p.content}</p>\n </div>\n ))}\n {task.prompts.length > 3 && (\n <div className=\"text-xs text-gray-400\">还有 {task.prompts.length - 3} 条...</div>\n )}\n </div>\n </div>\n )}\n </div>\n ))}\n </div>\n </div>\n </div>\n )\n}\n","import { useQuery } from '@tanstack/react-query'\nimport { useState, useMemo } from 'react'\nimport { formatDistanceToNow } from 'date-fns'\nimport { zhCN } from 'date-fns/locale'\nimport { MessageSquare, Clock, Activity, Download } from 'lucide-react'\nimport Drawer from '../components/Drawer'\nimport SessionDetailContent from '../components/SessionDetailContent'\nimport SearchInput from '../components/SearchInput'\nimport { downloadJSON, downloadCSV, getTimestamp } from '../utils/export'\nimport { useToast } from '../components/Toast'\n\ninterface Session {\n session_id: string\n first_prompt: string\n event_count: number\n start_time: string\n end_time: string\n}\n\nasync function fetchSessions(): Promise<Session[]> {\n const res = await fetch('/api/sessions?limit=200')\n if (!res.ok) throw new Error('Failed to fetch sessions')\n return res.json()\n}\n\nexport default function Sessions() {\n const [selectedSessionId, setSelectedSessionId] = useState<string | null>(null)\n const [search, setSearch] = useState('')\n const [showExportMenu, setShowExportMenu] = useState(false)\n const toast = useToast()\n\n const { data: sessions, isLoading, error } = useQuery({\n queryKey: ['sessions'],\n queryFn: fetchSessions,\n refetchInterval: 10000,\n })\n\n const filteredSessions = useMemo(() => {\n if (!sessions) return []\n if (!search.trim()) return sessions\n const q = search.toLowerCase()\n return sessions.filter(s =>\n s.first_prompt?.toLowerCase().includes(q) ||\n s.session_id.toLowerCase().includes(q)\n )\n }, [sessions, search])\n\n const handleExport = (format: 'json' | 'csv') => {\n const ts = getTimestamp()\n if (format === 'json') {\n downloadJSON(`sessions-${ts}.json`, filteredSessions)\n } else {\n downloadCSV(`sessions-${ts}.csv`, filteredSessions)\n }\n toast.success(`已导出 ${filteredSessions.length} 个会话`)\n setShowExportMenu(false)\n }\n\n if (isLoading) {\n return (\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900 mb-6\">会话</h1>\n <div className=\"bg-white rounded-lg shadow p-6\">\n <p className=\"text-gray-600\">加载中...</p>\n </div>\n </div>\n )\n }\n\n if (error) {\n return (\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900 mb-6\">会话</h1>\n <div className=\"bg-white rounded-lg shadow p-6\">\n <p className=\"text-red-600\">加载失败: {(error as Error).message}</p>\n </div>\n </div>\n )\n }\n\n return (\n <div>\n <div className=\"flex items-center justify-between mb-4 flex-wrap gap-3\">\n <h1 className=\"text-2xl font-bold text-gray-900\">会话</h1>\n <div className=\"flex items-center gap-2 flex-wrap\">\n <SearchInput\n value={search}\n onChange={setSearch}\n placeholder=\"搜索 session / 提示...\"\n className=\"w-64\"\n />\n <div className=\"relative\">\n <button\n onClick={() => setShowExportMenu(v => !v)}\n disabled={filteredSessions.length === 0}\n className=\"inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-white border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50\"\n >\n <Download className=\"h-4 w-4\" />\n 导出\n </button>\n {showExportMenu && (\n <>\n <div className=\"fixed inset-0 z-10\" onClick={() => setShowExportMenu(false)} />\n <div className=\"absolute right-0 mt-1 bg-white border border-gray-200 rounded-md shadow-lg z-20\">\n <button\n onClick={() => handleExport('json')}\n className=\"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50\"\n >\n 导出为 JSON\n </button>\n <button\n onClick={() => handleExport('csv')}\n className=\"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50\"\n >\n 导出为 CSV\n </button>\n </div>\n </>\n )}\n </div>\n </div>\n </div>\n\n <div className=\"text-sm text-gray-500 mb-3\">\n 显示 {filteredSessions.length} 个 {search && `(已过滤)`}\n </div>\n\n <div className=\"bg-white rounded-lg shadow overflow-hidden\">\n <table className=\"min-w-full divide-y divide-gray-200\">\n <thead className=\"bg-gray-50\">\n <tr>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n Session ID\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n 首次提示\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n 事件数\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n 时间\n </th>\n </tr>\n </thead>\n <tbody className=\"bg-white divide-y divide-gray-200\">\n {filteredSessions.map((session) => (\n <tr\n key={session.session_id}\n className=\"hover:bg-gray-50 cursor-pointer\"\n onClick={() => setSelectedSessionId(session.session_id)}\n >\n <td className=\"px-6 py-4 whitespace-nowrap\">\n <div className=\"flex items-center gap-2 text-sm text-indigo-600 font-mono\">\n <MessageSquare className=\"h-4 w-4\" />\n {session.session_id.slice(0, 12)}...\n </div>\n </td>\n <td className=\"px-6 py-4\">\n <p className=\"text-sm text-gray-900 max-w-md truncate\">\n {session.first_prompt || '(无提示)'}\n </p>\n </td>\n <td className=\"px-6 py-4 whitespace-nowrap\">\n <span className=\"inline-flex items-center gap-1 text-sm text-gray-600\">\n <Activity className=\"h-4 w-4\" />\n {session.event_count}\n </span>\n </td>\n <td className=\"px-6 py-4 whitespace-nowrap text-sm text-gray-500\">\n <span className=\"inline-flex items-center gap-1\">\n <Clock className=\"h-4 w-4\" />\n {session.start_time\n ? formatDistanceToNow(new Date(session.start_time), {\n addSuffix: true,\n locale: zhCN,\n })\n : '-'}\n </span>\n </td>\n </tr>\n ))}\n {filteredSessions.length === 0 && (\n <tr>\n <td colSpan={4} className=\"px-6 py-12 text-center text-gray-500\">\n {search ? '无匹配结果' : '暂无会话记录'}\n </td>\n </tr>\n )}\n </tbody>\n </table>\n </div>\n\n <Drawer\n open={selectedSessionId !== null}\n onClose={() => setSelectedSessionId(null)}\n title=\"会话详情\"\n width=\"w-[800px]\"\n >\n {selectedSessionId && <SessionDetailContent sessionId={selectedSessionId} />}\n </Drawer>\n </div>\n )\n}\n"],"names":["fetchSessionDetail","id","res","SessionDetailContent","sessionId","data","isLoading","error","useQuery","jsx","jsxs","format","task","clsx","Terminal","tool","count","FileEdit","f","GitCommit","MessageSquare","p","i","fetchSessions","Sessions","selectedSessionId","setSelectedSessionId","useState","search","setSearch","showExportMenu","setShowExportMenu","toast","useToast","sessions","filteredSessions","useMemo","q","s","_a","handleExport","ts","getTimestamp","downloadJSON","downloadCSV","SearchInput","v","Download","Fragment","session","Activity","Clock","formatDistanceToNow","zhCN","Drawer"],"mappings":"yeAiCA,eAAeA,EAAmBC,EAAwC,CACxE,MAAMC,EAAM,MAAM,MAAM,iBAAiBD,CAAE,SAAS,EACpD,GAAI,CAACC,EAAI,GAAI,MAAM,IAAI,MAAM,gCAAgC,EAC7D,OAAOA,EAAI,KAAA,CACb,CAMA,SAAwBC,EAAqB,CAAE,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,IAAC0C,EAAA,CAAM,UAAU,SAAA,CAAU,EAC1BF,EAAQ,WACLG,EAAoB,IAAI,KAAKH,EAAQ,UAAU,EAAG,CAChD,UAAW,GACX,OAAQI,CAAA,CACT,EACD,GAAA,CAAA,CACN,CAAA,CACF,CAAA,CAAA,EA/BKJ,EAAQ,UAAA,CAiChB,EACAd,EAAiB,SAAW,GAC3B1B,EAAAA,IAAC,MACC,SAAAA,EAAAA,IAAC,KAAA,CAAG,QAAS,EAAG,UAAU,uCACvB,SAAAmB,EAAS,QAAU,SACtB,CAAA,CACF,CAAA,CAAA,CAEJ,CAAA,CAAA,CACF,CAAA,CACF,EAEAnB,EAAAA,IAAC6C,EAAA,CACC,KAAM7B,IAAsB,KAC5B,QAAS,IAAMC,EAAqB,IAAI,EACxC,MAAM,OACN,MAAM,YAEL,SAAAD,GAAqBhB,EAAAA,IAACN,EAAA,CAAqB,UAAWsB,CAAA,CAAmB,CAAA,CAAA,CAC5E,EACF,CAEJ"}
1
+ {"version":3,"file":"Sessions-C6J_HQ_u.js","sources":["../../src/components/SessionDetailContent.tsx","../../src/pages/Sessions.tsx"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\nimport { format } from 'date-fns'\nimport { MessageSquare, FileEdit, Terminal, GitCommit } from 'lucide-react'\nimport clsx from 'clsx'\n\ninterface TaskDetail {\n id: string\n title: string\n start_time: string\n end_time?: string\n status: string\n event_count: number\n prompts: Array<{ timestamp: string; content: string }>\n events: Array<any>\n injections: Array<any>\n summary: {\n toolUsage: Record<string, number>\n filesChanged: string[]\n commits: Array<{ timestamp: string; message: string }>\n }\n}\n\ninterface SessionDetailData {\n session: {\n session_id: string\n first_prompt: string\n event_count: number\n start_time: string\n end_time: string\n }\n tasks: TaskDetail[]\n}\n\nasync function fetchSessionDetail(id: string): Promise<SessionDetailData> {\n const res = await fetch(`/api/sessions/${id}/detail`)\n if (!res.ok) throw new Error('Failed to fetch session detail')\n return res.json()\n}\n\ninterface Props {\n sessionId: string\n}\n\nexport default function SessionDetailContent({ sessionId }: Props) {\n const { data, isLoading, error } = useQuery({\n queryKey: ['session-detail', sessionId],\n queryFn: () => fetchSessionDetail(sessionId),\n enabled: !!sessionId,\n })\n\n if (isLoading) {\n return <div className=\"p-6 text-gray-500\">加载中...</div>\n }\n\n if (error || !data) {\n return <div className=\"p-6 text-red-600\">加载失败</div>\n }\n\n return (\n <div className=\"space-y-4\">\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">Session ID</div>\n <div className=\"text-sm font-mono text-gray-900 break-all\">{data.session.session_id}</div>\n </div>\n\n <div className=\"grid grid-cols-3 gap-4 pb-4 border-b border-gray-200\">\n <div>\n <div className=\"text-xs text-gray-500\">事件数</div>\n <div className=\"text-lg font-semibold\">{data.session.event_count}</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500\">任务数</div>\n <div className=\"text-lg font-semibold\">{data.tasks.length}</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500\">开始时间</div>\n <div className=\"text-sm\">\n {data.session.start_time ? format(new Date(data.session.start_time), 'MM-dd HH:mm:ss') : '-'}\n </div>\n </div>\n </div>\n\n <div>\n <h3 className=\"text-sm font-semibold text-gray-700 mb-3\">任务列表</h3>\n <div className=\"space-y-3\">\n {data.tasks.map((task) => (\n <div key={task.id} className=\"border border-gray-200 rounded-lg p-4\">\n <div className=\"flex items-center justify-between mb-3\">\n <h4 className=\"text-sm font-semibold text-gray-900 flex-1 mr-2\">{task.title}</h4>\n <span className={clsx(\n 'px-2 py-0.5 text-xs font-medium rounded-full whitespace-nowrap',\n task.status === 'completed' && 'bg-green-100 text-green-700',\n task.status === 'active' && 'bg-blue-100 text-blue-700',\n task.status === 'abandoned' && 'bg-gray-100 text-gray-600'\n )}>\n {task.status}\n </span>\n </div>\n\n <div className=\"grid grid-cols-3 gap-3 mb-3 text-xs\">\n <div>\n <div className=\"text-gray-500 mb-1 flex items-center gap-1\">\n <Terminal className=\"h-3 w-3\" />工具使用\n </div>\n <div className=\"space-y-0.5\">\n {Object.entries(task.summary.toolUsage).slice(0, 4).map(([tool, count]) => (\n <div key={tool} className=\"flex justify-between\">\n <span className=\"text-gray-600\">{tool}</span>\n <span className=\"font-mono text-gray-900\">{count}</span>\n </div>\n ))}\n </div>\n </div>\n <div>\n <div className=\"text-gray-500 mb-1 flex items-center gap-1\">\n <FileEdit className=\"h-3 w-3\" />文件变更\n </div>\n <div className=\"text-gray-700\">{task.summary.filesChanged.length} 个</div>\n {task.summary.filesChanged.slice(0, 3).map(f => (\n <div key={f} className=\"text-gray-500 truncate text-[10px]\" title={f}>\n {f.split('/').pop()}\n </div>\n ))}\n </div>\n <div>\n <div className=\"text-gray-500 mb-1 flex items-center gap-1\">\n <GitCommit className=\"h-3 w-3\" />提交\n </div>\n <div className=\"text-gray-700\">{task.summary.commits.length} 次</div>\n </div>\n </div>\n\n {task.prompts.length > 0 && (\n <div className=\"border-t border-gray-100 pt-3\">\n <div className=\"text-xs text-gray-500 mb-2 flex items-center gap-1\">\n <MessageSquare className=\"h-3 w-3\" />用户提示 ({task.prompts.length})\n </div>\n <div className=\"space-y-1.5\">\n {task.prompts.slice(0, 3).map((p, i) => (\n <div key={i} className=\"text-xs bg-gray-50 rounded p-2\">\n <p className=\"text-gray-700 line-clamp-2\">{p.content}</p>\n </div>\n ))}\n {task.prompts.length > 3 && (\n <div className=\"text-xs text-gray-400\">还有 {task.prompts.length - 3} 条...</div>\n )}\n </div>\n </div>\n )}\n </div>\n ))}\n </div>\n </div>\n </div>\n )\n}\n","import { useQuery } from '@tanstack/react-query'\nimport { useState, useMemo } from 'react'\nimport { formatDistanceToNow } from 'date-fns'\nimport { zhCN } from 'date-fns/locale'\nimport { MessageSquare, Clock, Activity, Download } from 'lucide-react'\nimport Drawer from '../components/Drawer'\nimport SessionDetailContent from '../components/SessionDetailContent'\nimport SearchInput from '../components/SearchInput'\nimport { downloadJSON, downloadCSV, getTimestamp } from '../utils/export'\nimport { useToast } from '../components/Toast'\n\ninterface Session {\n session_id: string\n first_prompt: string\n event_count: number\n start_time: string\n end_time: string\n}\n\nasync function fetchSessions(): Promise<Session[]> {\n const res = await fetch('/api/sessions?limit=200')\n if (!res.ok) throw new Error('Failed to fetch sessions')\n return res.json()\n}\n\nexport default function Sessions() {\n const [selectedSessionId, setSelectedSessionId] = useState<string | null>(null)\n const [search, setSearch] = useState('')\n const [showExportMenu, setShowExportMenu] = useState(false)\n const toast = useToast()\n\n const { data: sessions, isLoading, error } = useQuery({\n queryKey: ['sessions'],\n queryFn: fetchSessions,\n refetchInterval: 10000,\n })\n\n const filteredSessions = useMemo(() => {\n if (!sessions) return []\n if (!search.trim()) return sessions\n const q = search.toLowerCase()\n return sessions.filter(s =>\n s.first_prompt?.toLowerCase().includes(q) ||\n s.session_id.toLowerCase().includes(q)\n )\n }, [sessions, search])\n\n const handleExport = (format: 'json' | 'csv') => {\n const ts = getTimestamp()\n if (format === 'json') {\n downloadJSON(`sessions-${ts}.json`, filteredSessions)\n } else {\n downloadCSV(`sessions-${ts}.csv`, filteredSessions)\n }\n toast.success(`已导出 ${filteredSessions.length} 个会话`)\n setShowExportMenu(false)\n }\n\n if (isLoading) {\n return (\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900 mb-6\">会话</h1>\n <div className=\"bg-white rounded-lg shadow p-6\">\n <p className=\"text-gray-600\">加载中...</p>\n </div>\n </div>\n )\n }\n\n if (error) {\n return (\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900 mb-6\">会话</h1>\n <div className=\"bg-white rounded-lg shadow p-6\">\n <p className=\"text-red-600\">加载失败: {(error as Error).message}</p>\n </div>\n </div>\n )\n }\n\n return (\n <div>\n <div className=\"flex items-center justify-between mb-4 flex-wrap gap-3\">\n <h1 className=\"text-2xl font-bold text-gray-900\">会话</h1>\n <div className=\"flex items-center gap-2 flex-wrap\">\n <SearchInput\n value={search}\n onChange={setSearch}\n placeholder=\"搜索 session / 提示...\"\n className=\"w-64\"\n />\n <div className=\"relative\">\n <button\n onClick={() => setShowExportMenu(v => !v)}\n disabled={filteredSessions.length === 0}\n className=\"inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-white border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50\"\n >\n <Download className=\"h-4 w-4\" />\n 导出\n </button>\n {showExportMenu && (\n <>\n <div className=\"fixed inset-0 z-10\" onClick={() => setShowExportMenu(false)} />\n <div className=\"absolute right-0 mt-1 bg-white border border-gray-200 rounded-md shadow-lg z-20\">\n <button\n onClick={() => handleExport('json')}\n className=\"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50\"\n >\n 导出为 JSON\n </button>\n <button\n onClick={() => handleExport('csv')}\n className=\"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50\"\n >\n 导出为 CSV\n </button>\n </div>\n </>\n )}\n </div>\n </div>\n </div>\n\n <div className=\"text-sm text-gray-500 mb-3\">\n 显示 {filteredSessions.length} 个 {search && `(已过滤)`}\n </div>\n\n <div className=\"bg-white rounded-lg shadow overflow-hidden\">\n <table className=\"min-w-full divide-y divide-gray-200\">\n <thead className=\"bg-gray-50\">\n <tr>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n Session ID\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n 首次提示\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n 事件数\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n 时间\n </th>\n </tr>\n </thead>\n <tbody className=\"bg-white divide-y divide-gray-200\">\n {filteredSessions.map((session) => (\n <tr\n key={session.session_id}\n className=\"hover:bg-gray-50 cursor-pointer\"\n onClick={() => setSelectedSessionId(session.session_id)}\n >\n <td className=\"px-6 py-4 whitespace-nowrap\">\n <div className=\"flex items-center gap-2 text-sm text-indigo-600 font-mono\">\n <MessageSquare className=\"h-4 w-4\" />\n {session.session_id.slice(0, 12)}...\n </div>\n </td>\n <td className=\"px-6 py-4\">\n <p className=\"text-sm text-gray-900 max-w-md truncate\">\n {session.first_prompt || '(无提示)'}\n </p>\n </td>\n <td className=\"px-6 py-4 whitespace-nowrap\">\n <span className=\"inline-flex items-center gap-1 text-sm text-gray-600\">\n <Activity className=\"h-4 w-4\" />\n {session.event_count}\n </span>\n </td>\n <td className=\"px-6 py-4 whitespace-nowrap text-sm text-gray-500\">\n <span className=\"inline-flex items-center gap-1\">\n <Clock className=\"h-4 w-4\" />\n {session.start_time\n ? formatDistanceToNow(new Date(session.start_time), {\n addSuffix: true,\n locale: zhCN,\n })\n : '-'}\n </span>\n </td>\n </tr>\n ))}\n {filteredSessions.length === 0 && (\n <tr>\n <td colSpan={4} className=\"px-6 py-12 text-center text-gray-500\">\n {search ? '无匹配结果' : '暂无会话记录'}\n </td>\n </tr>\n )}\n </tbody>\n </table>\n </div>\n\n <Drawer\n open={selectedSessionId !== null}\n onClose={() => setSelectedSessionId(null)}\n title=\"会话详情\"\n width=\"w-[800px]\"\n >\n {selectedSessionId && <SessionDetailContent sessionId={selectedSessionId} />}\n </Drawer>\n </div>\n )\n}\n"],"names":["fetchSessionDetail","id","res","SessionDetailContent","sessionId","data","isLoading","error","useQuery","jsx","jsxs","format","task","clsx","Terminal","tool","count","FileEdit","f","GitCommit","MessageSquare","p","i","fetchSessions","Sessions","selectedSessionId","setSelectedSessionId","useState","search","setSearch","showExportMenu","setShowExportMenu","toast","useToast","sessions","filteredSessions","useMemo","q","s","_a","handleExport","ts","getTimestamp","downloadJSON","downloadCSV","SearchInput","v","Download","Fragment","session","Activity","Clock","formatDistanceToNow","zhCN","Drawer"],"mappings":"yeAiCA,eAAeA,EAAmBC,EAAwC,CACxE,MAAMC,EAAM,MAAM,MAAM,iBAAiBD,CAAE,SAAS,EACpD,GAAI,CAACC,EAAI,GAAI,MAAM,IAAI,MAAM,gCAAgC,EAC7D,OAAOA,EAAI,KAAA,CACb,CAMA,SAAwBC,EAAqB,CAAE,UAAAC,G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,EAAA,CAAM,UAAU,SAAA,CAAU,EAC1BF,EAAQ,WACLG,EAAoB,IAAI,KAAKH,EAAQ,UAAU,EAAG,CAChD,UAAW,GACX,OAAQI,CAAA,CACT,EACD,GAAA,CAAA,CACN,CAAA,CACF,CAAA,CAAA,EA/BKJ,EAAQ,UAAA,CAiChB,EACAd,EAAiB,SAAW,GAC3B1B,EAAAA,IAAC,MACC,SAAAA,EAAAA,IAAC,KAAA,CAAG,QAAS,EAAG,UAAU,uCACvB,SAAAmB,EAAS,QAAU,SACtB,CAAA,CACF,CAAA,CAAA,CAEJ,CAAA,CAAA,CACF,CAAA,CACF,EAEAnB,EAAAA,IAAC6C,EAAA,CACC,KAAM7B,IAAsB,KAC5B,QAAS,IAAMC,EAAqB,IAAI,EACxC,MAAM,OACN,MAAM,YAEL,SAAAD,GAAqBhB,EAAAA,IAACN,EAAA,CAAqB,UAAWsB,CAAA,CAAmB,CAAA,CAAA,CAC5E,EACF,CAEJ"}
@@ -1,2 +1,2 @@
1
- import{r as c,j as e}from"./react-vendor-CSp-GLFF.js";import{b as p,u,c as j}from"./query-C99w429o.js";import{D as y}from"./Drawer-Lo5ihVP-.js";import{M as w}from"./MarkdownRenderer-CCIz1MOz.js";import{u as b}from"./index-B1J7nBu0.js";import{a as v}from"./auth-Bnf8ZcqN.js";import{b as g,P as N,X as k,m as S}from"./lucide-Bu44HVAM.js";import"./vendor-CMMjVdZs.js";import"./syntax-highlighter-44FakypI.js";import"./react-router-I-HqunH7.js";async function C(){const i=await fetch("/api/skills");if(!i.ok)throw new Error("Failed to fetch skills");const s=await i.json();return Array.isArray(s)?s:s.skills||[]}async function E(i){const s=await fetch(`/api/skills/${i}`);if(!s.ok)throw new Error("Failed to fetch");return s.json()}async function F(i,s){if(!(await v(`/api/skills/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s})})).ok)throw new Error("Failed to save")}function R(){const i=p(),s=b(),{data:n,isLoading:f}=u({queryKey:["skills"],queryFn:C}),[r,x]=c.useState(null),[m,l]=c.useState(!1),[h,d]=c.useState(""),{data:t}=u({queryKey:["skill-detail",r],queryFn:()=>E(r),enabled:!!r});c.useEffect(()=>{t!=null&&t.content&&d(t.content),l(!1)},[t]);const o=j({mutationFn:a=>F(a.name,a.content),onSuccess:()=>{s.success("Skill 已保存"),l(!1),i.invalidateQueries({queryKey:["skill-detail",r]}),i.invalidateQueries({queryKey:["skills"]})},onError:a=>s.error(`保存失败: ${a.message}`)});return f?e.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:"加载中..."}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Skill 管理"}),e.jsxs("div",{className:"text-sm text-gray-500",children:["共 ",(n==null?void 0:n.length)||0," 个 Skill"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:n==null?void 0:n.map(a=>e.jsx("div",{className:"bg-white rounded-lg shadow p-5 hover:shadow-md transition-shadow cursor-pointer",onClick:()=>x(a.name),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-100 flex items-center justify-center flex-shrink-0",children:e.jsx(g,{className:"h-5 w-5 text-purple-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-gray-900 truncate",children:a.name}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 line-clamp-3",children:a.description||"(无描述)"})]})]})},a.name))}),e.jsx(y,{open:r!==null,onClose:()=>{x(null),l(!1)},title:`Skill: ${r}`,width:"w-[800px]",children:t&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(g,{className:"h-5 w-5 text-purple-600"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:t.name})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"描述"}),e.jsx("div",{className:"text-sm text-gray-800",children:t.description})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:"text-xs text-gray-500",children:"完整内容 (Markdown)"}),e.jsx("div",{className:"flex items-center gap-2",children:m?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{l(!1),d(t.content||"")},className:"inline-flex items-center gap-1 text-xs text-gray-600 hover:text-gray-700",children:[e.jsx(k,{className:"h-3 w-3"}),"取消"]}),e.jsxs("button",{onClick:()=>o.mutate({name:t.name,content:h}),disabled:o.isPending,className:"inline-flex items-center gap-1 text-xs bg-indigo-600 text-white px-2 py-1 rounded hover:bg-indigo-700 disabled:bg-gray-400",children:[e.jsx(S,{className:"h-3 w-3"}),o.isPending?"保存中...":"保存"]})]}):e.jsxs("button",{onClick:()=>l(!0),className:"inline-flex items-center gap-1 text-xs text-indigo-600 hover:text-indigo-700",children:[e.jsx(N,{className:"h-3 w-3"}),"编辑"]})})]}),m?e.jsx("textarea",{value:h,onChange:a=>d(a.target.value),className:"w-full font-mono text-xs bg-gray-50 rounded p-3 border border-gray-300 focus:border-indigo-500 focus:outline-none",rows:20}):e.jsx("div",{className:"bg-white rounded p-3 border border-gray-200 max-h-[500px] overflow-y-auto",children:e.jsx(w,{content:t.content||""})}),o.isError&&e.jsxs("div",{className:"text-xs text-red-600 mt-1",children:["保存失败:",o.error.message]})]})]})})]})}export{R as default};
2
- //# sourceMappingURL=Skills-Czt5mkyc.js.map
1
+ import{r as c,j as e}from"./react-vendor-CSp-GLFF.js";import{b as p,u,c as j}from"./query-C99w429o.js";import{D as y}from"./Drawer-DcU3ln98.js";import{M as w}from"./MarkdownRenderer-CCIz1MOz.js";import{u as b}from"./index-Cgr9qMtq.js";import{a as v}from"./auth-Bnf8ZcqN.js";import{b as g,P as N,X as k,n as S}from"./lucide-53bR2rki.js";import"./vendor-CMMjVdZs.js";import"./syntax-highlighter-44FakypI.js";import"./react-router-I-HqunH7.js";async function C(){const i=await fetch("/api/skills");if(!i.ok)throw new Error("Failed to fetch skills");const s=await i.json();return Array.isArray(s)?s:s.skills||[]}async function E(i){const s=await fetch(`/api/skills/${i}`);if(!s.ok)throw new Error("Failed to fetch");return s.json()}async function F(i,s){if(!(await v(`/api/skills/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s})})).ok)throw new Error("Failed to save")}function R(){const i=p(),s=b(),{data:n,isLoading:f}=u({queryKey:["skills"],queryFn:C}),[r,x]=c.useState(null),[m,l]=c.useState(!1),[h,d]=c.useState(""),{data:t}=u({queryKey:["skill-detail",r],queryFn:()=>E(r),enabled:!!r});c.useEffect(()=>{t!=null&&t.content&&d(t.content),l(!1)},[t]);const o=j({mutationFn:a=>F(a.name,a.content),onSuccess:()=>{s.success("Skill 已保存"),l(!1),i.invalidateQueries({queryKey:["skill-detail",r]}),i.invalidateQueries({queryKey:["skills"]})},onError:a=>s.error(`保存失败: ${a.message}`)});return f?e.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:"加载中..."}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Skill 管理"}),e.jsxs("div",{className:"text-sm text-gray-500",children:["共 ",(n==null?void 0:n.length)||0," 个 Skill"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:n==null?void 0:n.map(a=>e.jsx("div",{className:"bg-white rounded-lg shadow p-5 hover:shadow-md transition-shadow cursor-pointer",onClick:()=>x(a.name),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-100 flex items-center justify-center flex-shrink-0",children:e.jsx(g,{className:"h-5 w-5 text-purple-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-gray-900 truncate",children:a.name}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 line-clamp-3",children:a.description||"(无描述)"})]})]})},a.name))}),e.jsx(y,{open:r!==null,onClose:()=>{x(null),l(!1)},title:`Skill: ${r}`,width:"w-[800px]",children:t&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(g,{className:"h-5 w-5 text-purple-600"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:t.name})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"描述"}),e.jsx("div",{className:"text-sm text-gray-800",children:t.description})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:"text-xs text-gray-500",children:"完整内容 (Markdown)"}),e.jsx("div",{className:"flex items-center gap-2",children:m?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{l(!1),d(t.content||"")},className:"inline-flex items-center gap-1 text-xs text-gray-600 hover:text-gray-700",children:[e.jsx(k,{className:"h-3 w-3"}),"取消"]}),e.jsxs("button",{onClick:()=>o.mutate({name:t.name,content:h}),disabled:o.isPending,className:"inline-flex items-center gap-1 text-xs bg-indigo-600 text-white px-2 py-1 rounded hover:bg-indigo-700 disabled:bg-gray-400",children:[e.jsx(S,{className:"h-3 w-3"}),o.isPending?"保存中...":"保存"]})]}):e.jsxs("button",{onClick:()=>l(!0),className:"inline-flex items-center gap-1 text-xs text-indigo-600 hover:text-indigo-700",children:[e.jsx(N,{className:"h-3 w-3"}),"编辑"]})})]}),m?e.jsx("textarea",{value:h,onChange:a=>d(a.target.value),className:"w-full font-mono text-xs bg-gray-50 rounded p-3 border border-gray-300 focus:border-indigo-500 focus:outline-none",rows:20}):e.jsx("div",{className:"bg-white rounded p-3 border border-gray-200 max-h-[500px] overflow-y-auto",children:e.jsx(w,{content:t.content||""})}),o.isError&&e.jsxs("div",{className:"text-xs text-red-600 mt-1",children:["保存失败:",o.error.message]})]})]})})]})}export{R as default};
2
+ //# sourceMappingURL=Skills-4DQWLaTv.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Skills-Czt5mkyc.js","sources":["../../src/pages/Skills.tsx"],"sourcesContent":["import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'\nimport { useState, useEffect } from 'react'\nimport { BookOpen, Edit2, Save, X } from 'lucide-react'\nimport Drawer from '../components/Drawer'\nimport MarkdownRenderer from '../components/MarkdownRenderer'\nimport { useToast } from '../components/Toast'\nimport { authFetch } from '../utils/auth'\n\ninterface Skill {\n name: string\n description: string\n content?: string\n}\n\ninterface SkillsResponse {\n skills?: Skill[]\n}\n\nasync function fetchSkills(): Promise<Skill[]> {\n const res = await fetch('/api/skills')\n if (!res.ok) throw new Error('Failed to fetch skills')\n const data: SkillsResponse | Skill[] = await res.json()\n if (Array.isArray(data)) return data\n return data.skills || []\n}\n\nasync function fetchSkillDetail(name: string): Promise<Skill> {\n const res = await fetch(`/api/skills/${name}`)\n if (!res.ok) throw new Error('Failed to fetch')\n return res.json()\n}\n\nasync function saveSkill(name: string, content: string): Promise<void> {\n const res = await authFetch(`/api/skills/${name}`, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ content }),\n })\n if (!res.ok) throw new Error('Failed to save')\n}\n\nexport default function Skills() {\n const queryClient = useQueryClient()\n const toast = useToast()\n const { data: skills, isLoading } = useQuery({\n queryKey: ['skills'],\n queryFn: fetchSkills,\n })\n\n const [selectedSkill, setSelectedSkill] = useState<string | null>(null)\n const [editing, setEditing] = useState(false)\n const [editContent, setEditContent] = useState('')\n\n const { data: detail } = useQuery({\n queryKey: ['skill-detail', selectedSkill],\n queryFn: () => fetchSkillDetail(selectedSkill!),\n enabled: !!selectedSkill,\n })\n\n useEffect(() => {\n if (detail?.content) setEditContent(detail.content)\n setEditing(false)\n }, [detail])\n\n const mutation = useMutation({\n mutationFn: (vars: { name: string; content: string }) => saveSkill(vars.name, vars.content),\n onSuccess: () => {\n toast.success('Skill 已保存')\n setEditing(false)\n queryClient.invalidateQueries({ queryKey: ['skill-detail', selectedSkill] })\n queryClient.invalidateQueries({ queryKey: ['skills'] })\n },\n onError: (e: Error) => toast.error(`保存失败: ${e.message}`),\n })\n\n if (isLoading) {\n return <div className=\"bg-white rounded-lg shadow p-6\">加载中...</div>\n }\n\n return (\n <div>\n <div className=\"flex items-center justify-between mb-6\">\n <h1 className=\"text-2xl font-bold text-gray-900\">Skill 管理</h1>\n <div className=\"text-sm text-gray-500\">共 {skills?.length || 0} 个 Skill</div>\n </div>\n\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4\">\n {skills?.map((skill) => (\n <div\n key={skill.name}\n className=\"bg-white rounded-lg shadow p-5 hover:shadow-md transition-shadow cursor-pointer\"\n onClick={() => setSelectedSkill(skill.name)}\n >\n <div className=\"flex items-start gap-3\">\n <div className=\"w-10 h-10 rounded-lg bg-purple-100 flex items-center justify-center flex-shrink-0\">\n <BookOpen className=\"h-5 w-5 text-purple-600\" />\n </div>\n <div className=\"flex-1 min-w-0\">\n <h3 className=\"font-semibold text-gray-900 truncate\">{skill.name}</h3>\n <p className=\"text-xs text-gray-500 mt-1 line-clamp-3\">\n {skill.description || '(无描述)'}\n </p>\n </div>\n </div>\n </div>\n ))}\n </div>\n\n {/* Skill Detail Drawer */}\n <Drawer\n open={selectedSkill !== null}\n onClose={() => { setSelectedSkill(null); setEditing(false) }}\n title={`Skill: ${selectedSkill}`}\n width=\"w-[800px]\"\n >\n {detail && (\n <div className=\"space-y-4\">\n <div className=\"flex items-center gap-2 mb-2\">\n <BookOpen className=\"h-5 w-5 text-purple-600\" />\n <h3 className=\"text-lg font-semibold text-gray-900\">{detail.name}</h3>\n </div>\n\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">描述</div>\n <div className=\"text-sm text-gray-800\">{detail.description}</div>\n </div>\n\n <div>\n <div className=\"flex items-center justify-between mb-2\">\n <div className=\"text-xs text-gray-500\">完整内容 (Markdown)</div>\n <div className=\"flex items-center gap-2\">\n {!editing ? (\n <button\n onClick={() => setEditing(true)}\n className=\"inline-flex items-center gap-1 text-xs text-indigo-600 hover:text-indigo-700\"\n >\n <Edit2 className=\"h-3 w-3\" />编辑\n </button>\n ) : (\n <>\n <button\n onClick={() => { setEditing(false); setEditContent(detail.content || '') }}\n className=\"inline-flex items-center gap-1 text-xs text-gray-600 hover:text-gray-700\"\n >\n <X className=\"h-3 w-3\" />取消\n </button>\n <button\n onClick={() => mutation.mutate({ name: detail.name, content: editContent })}\n disabled={mutation.isPending}\n className=\"inline-flex items-center gap-1 text-xs bg-indigo-600 text-white px-2 py-1 rounded hover:bg-indigo-700 disabled:bg-gray-400\"\n >\n <Save className=\"h-3 w-3\" />\n {mutation.isPending ? '保存中...' : '保存'}\n </button>\n </>\n )}\n </div>\n </div>\n {editing ? (\n <textarea\n value={editContent}\n onChange={(e) => setEditContent(e.target.value)}\n className=\"w-full font-mono text-xs bg-gray-50 rounded p-3 border border-gray-300 focus:border-indigo-500 focus:outline-none\"\n rows={20}\n />\n ) : (\n <div className=\"bg-white rounded p-3 border border-gray-200 max-h-[500px] overflow-y-auto\">\n <MarkdownRenderer content={detail.content || ''} />\n </div>\n )}\n {mutation.isError && (\n <div className=\"text-xs text-red-600 mt-1\">保存失败:{(mutation.error as Error).message}</div>\n )}\n </div>\n </div>\n )}\n </Drawer>\n </div>\n )\n}\n"],"names":["fetchSkills","res","data","fetchSkillDetail","name","saveSkill","content","authFetch","Skills","queryClient","useQueryClient","toast","useToast","skills","isLoading","useQuery","selectedSkill","setSelectedSkill","useState","editing","setEditing","editContent","setEditContent","detail","useEffect","mutation","useMutation","vars","e","jsx","jsxs","skill","BookOpen","Drawer","Fragment","X","Save","Edit2","MarkdownRenderer"],"mappings":"ybAkBA,eAAeA,GAAgC,CAC7C,MAAMC,EAAM,MAAM,MAAM,aAAa,EACrC,GAAI,CAACA,EAAI,GAAI,MAAM,IAAI,MAAM,wBAAwB,EACrD,MAAMC,EAAiC,MAAMD,EAAI,KAAA,EAC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EAAAA,IAAC,WAAA,CACC,MAAOR,EACP,SAAWO,GAAMN,EAAeM,EAAE,OAAO,KAAK,EAC9C,UAAU,oHACV,KAAM,EAAA,CAAA,EAGRC,EAAAA,IAAC,MAAA,CAAI,UAAU,4EACb,SAAAA,EAAAA,IAACS,EAAA,CAAiB,QAASf,EAAO,SAAW,EAAA,CAAI,CAAA,CACnD,EAEDE,EAAS,SACRK,OAAC,MAAA,CAAI,UAAU,4BAA4B,SAAA,CAAA,QAAOL,EAAS,MAAgB,OAAA,CAAA,CAAQ,CAAA,CAAA,CAEvF,CAAA,CAAA,CACF,CAAA,CAAA,CAEJ,EACF,CAEJ"}
1
+ {"version":3,"file":"Skills-4DQWLaTv.js","sources":["../../src/pages/Skills.tsx"],"sourcesContent":["import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'\nimport { useState, useEffect } from 'react'\nimport { BookOpen, Edit2, Save, X } from 'lucide-react'\nimport Drawer from '../components/Drawer'\nimport MarkdownRenderer from '../components/MarkdownRenderer'\nimport { useToast } from '../components/Toast'\nimport { authFetch } from '../utils/auth'\n\ninterface Skill {\n name: string\n description: string\n content?: string\n}\n\ninterface SkillsResponse {\n skills?: Skill[]\n}\n\nasync function fetchSkills(): Promise<Skill[]> {\n const res = await fetch('/api/skills')\n if (!res.ok) throw new Error('Failed to fetch skills')\n const data: SkillsResponse | Skill[] = await res.json()\n if (Array.isArray(data)) return data\n return data.skills || []\n}\n\nasync function fetchSkillDetail(name: string): Promise<Skill> {\n const res = await fetch(`/api/skills/${name}`)\n if (!res.ok) throw new Error('Failed to fetch')\n return res.json()\n}\n\nasync function saveSkill(name: string, content: string): Promise<void> {\n const res = await authFetch(`/api/skills/${name}`, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ content }),\n })\n if (!res.ok) throw new Error('Failed to save')\n}\n\nexport default function Skills() {\n const queryClient = useQueryClient()\n const toast = useToast()\n const { data: skills, isLoading } = useQuery({\n queryKey: ['skills'],\n queryFn: fetchSkills,\n })\n\n const [selectedSkill, setSelectedSkill] = useState<string | null>(null)\n const [editing, setEditing] = useState(false)\n const [editContent, setEditContent] = useState('')\n\n const { data: detail } = useQuery({\n queryKey: ['skill-detail', selectedSkill],\n queryFn: () => fetchSkillDetail(selectedSkill!),\n enabled: !!selectedSkill,\n })\n\n useEffect(() => {\n if (detail?.content) setEditContent(detail.content)\n setEditing(false)\n }, [detail])\n\n const mutation = useMutation({\n mutationFn: (vars: { name: string; content: string }) => saveSkill(vars.name, vars.content),\n onSuccess: () => {\n toast.success('Skill 已保存')\n setEditing(false)\n queryClient.invalidateQueries({ queryKey: ['skill-detail', selectedSkill] })\n queryClient.invalidateQueries({ queryKey: ['skills'] })\n },\n onError: (e: Error) => toast.error(`保存失败: ${e.message}`),\n })\n\n if (isLoading) {\n return <div className=\"bg-white rounded-lg shadow p-6\">加载中...</div>\n }\n\n return (\n <div>\n <div className=\"flex items-center justify-between mb-6\">\n <h1 className=\"text-2xl font-bold text-gray-900\">Skill 管理</h1>\n <div className=\"text-sm text-gray-500\">共 {skills?.length || 0} 个 Skill</div>\n </div>\n\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4\">\n {skills?.map((skill) => (\n <div\n key={skill.name}\n className=\"bg-white rounded-lg shadow p-5 hover:shadow-md transition-shadow cursor-pointer\"\n onClick={() => setSelectedSkill(skill.name)}\n >\n <div className=\"flex items-start gap-3\">\n <div className=\"w-10 h-10 rounded-lg bg-purple-100 flex items-center justify-center flex-shrink-0\">\n <BookOpen className=\"h-5 w-5 text-purple-600\" />\n </div>\n <div className=\"flex-1 min-w-0\">\n <h3 className=\"font-semibold text-gray-900 truncate\">{skill.name}</h3>\n <p className=\"text-xs text-gray-500 mt-1 line-clamp-3\">\n {skill.description || '(无描述)'}\n </p>\n </div>\n </div>\n </div>\n ))}\n </div>\n\n {/* Skill Detail Drawer */}\n <Drawer\n open={selectedSkill !== null}\n onClose={() => { setSelectedSkill(null); setEditing(false) }}\n title={`Skill: ${selectedSkill}`}\n width=\"w-[800px]\"\n >\n {detail && (\n <div className=\"space-y-4\">\n <div className=\"flex items-center gap-2 mb-2\">\n <BookOpen className=\"h-5 w-5 text-purple-600\" />\n <h3 className=\"text-lg font-semibold text-gray-900\">{detail.name}</h3>\n </div>\n\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">描述</div>\n <div className=\"text-sm text-gray-800\">{detail.description}</div>\n </div>\n\n <div>\n <div className=\"flex items-center justify-between mb-2\">\n <div className=\"text-xs text-gray-500\">完整内容 (Markdown)</div>\n <div className=\"flex items-center gap-2\">\n {!editing ? (\n <button\n onClick={() => setEditing(true)}\n className=\"inline-flex items-center gap-1 text-xs text-indigo-600 hover:text-indigo-700\"\n >\n <Edit2 className=\"h-3 w-3\" />编辑\n </button>\n ) : (\n <>\n <button\n onClick={() => { setEditing(false); setEditContent(detail.content || '') }}\n className=\"inline-flex items-center gap-1 text-xs text-gray-600 hover:text-gray-700\"\n >\n <X className=\"h-3 w-3\" />取消\n </button>\n <button\n onClick={() => mutation.mutate({ name: detail.name, content: editContent })}\n disabled={mutation.isPending}\n className=\"inline-flex items-center gap-1 text-xs bg-indigo-600 text-white px-2 py-1 rounded hover:bg-indigo-700 disabled:bg-gray-400\"\n >\n <Save className=\"h-3 w-3\" />\n {mutation.isPending ? '保存中...' : '保存'}\n </button>\n </>\n )}\n </div>\n </div>\n {editing ? (\n <textarea\n value={editContent}\n onChange={(e) => setEditContent(e.target.value)}\n className=\"w-full font-mono text-xs bg-gray-50 rounded p-3 border border-gray-300 focus:border-indigo-500 focus:outline-none\"\n rows={20}\n />\n ) : (\n <div className=\"bg-white rounded p-3 border border-gray-200 max-h-[500px] overflow-y-auto\">\n <MarkdownRenderer content={detail.content || ''} />\n </div>\n )}\n {mutation.isError && (\n <div className=\"text-xs text-red-600 mt-1\">保存失败:{(mutation.error as Error).message}</div>\n )}\n </div>\n </div>\n )}\n </Drawer>\n </div>\n )\n}\n"],"names":["fetchSkills","res","data","fetchSkillDetail","name","saveSkill","content","authFetch","Skills","queryClient","useQueryClient","toast","useToast","skills","isLoading","useQuery","selectedSkill","setSelectedSkill","useState","editing","setEditing","editContent","setEditContent","detail","useEffect","mutation","useMutation","vars","e","jsx","jsxs","skill","BookOpen","Drawer","Fragment","X","Save","Edit2","MarkdownRenderer"],"mappings":"ybAkBA,eAAeA,GAAgC,CAC7C,MAAMC,EAAM,MAAM,MAAM,aAAa,EACrC,GAAI,CAACA,EAAI,GAAI,MAAM,IAAI,MAAM,wBAAwB,EACrD,MAAMC,EAAiC,MAAMD,EAAI,KAAA,EACjD,OAAI,MAAM,QAAQC,CAAI,EAAUA,EACzBA,EAAK,QAAU,CAAA,CACxB,CAEA,eAAeC,EAAiBC,EAA8B,CAC5D,MAAMH,EAAM,MAAM,MAAM,eAAeG,CAAI,EAAE,EAC7C,GAAI,CAACH,EAAI,GAAI,MAAM,IAAI,MAAM,iBAAiB,EAC9C,OAAOA,EAAI,KAAA,CACb,CAEA,eAAeI,EAAUD,EAAcE,EAAgC,CAMrE,GAAI,EALQ,MAAMC,EAAU,eAAeH,CAAI,GAAI,CACjD,OAAQ,MACR,QAAS,CAAE,eAAgB,kBAAA,EAC3B,KAAM,KAAK,UAAU,CAAE,QAAAE,EAAS,CAAA,CACjC,GACQ,GAAI,MAAM,IAAI,MAAM,gBAAgB,CAC/C,CAEA,SAAwBE,GAAS,CAC/B,MAAMC,EAAcC,EAAA,EACdC,EAAQC,EAAA,EACR,CAAE,KAAMC,EAAQ,UAAAC,CAAA,EAAcC,EAAS,CAC3C,SAAU,CAAC,QAAQ,EACnB,QAASf,CAAA,CACV,EAEK,CAACgB,EAAeC,CAAgB,EAAIC,EAAAA,SAAwB,IAAI,EAChE,CAACC,EAASC,CAAU,EAAIF,EAAAA,SAAS,EAAK,EACtC,CAACG,EAAaC,CAAc,EAAIJ,EAAAA,SAAS,EAAE,EAE3C,CAAE,KAAMK,CAAA,EAAWR,EAAS,CAChC,SAAU,CAAC,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AO,KAAM,QAASF,EAAa,EAC1E,SAAUI,EAAS,UACnB,UAAU,6HAEV,SAAA,CAAAI,EAAAA,IAACO,EAAA,CAAK,UAAU,SAAA,CAAU,EACzBX,EAAS,UAAY,SAAW,IAAA,CAAA,CAAA,CACnC,CAAA,CACF,EAtBAK,EAAAA,KAAC,SAAA,CACC,QAAS,IAAMV,EAAW,EAAI,EAC9B,UAAU,+EAEV,SAAA,CAAAS,EAAAA,IAACQ,EAAA,CAAM,UAAU,SAAA,CAAU,EAAE,IAAA,CAAA,CAAA,CAkB/B,CAEJ,CAAA,EACF,EACClB,EACCU,EAAAA,IAAC,WAAA,CACC,MAAOR,EACP,SAAWO,GAAMN,EAAeM,EAAE,OAAO,KAAK,EAC9C,UAAU,oHACV,KAAM,EAAA,CAAA,EAGRC,EAAAA,IAAC,MAAA,CAAI,UAAU,4EACb,SAAAA,EAAAA,IAACS,EAAA,CAAiB,QAASf,EAAO,SAAW,EAAA,CAAI,CAAA,CACnD,EAEDE,EAAS,SACRK,OAAC,MAAA,CAAI,UAAU,4BAA4B,SAAA,CAAA,QAAOL,EAAS,MAAgB,OAAA,CAAA,CAAQ,CAAA,CAAA,CAEvF,CAAA,CAAA,CACF,CAAA,CAAA,CAEJ,EACF,CAEJ"}
@@ -0,0 +1,2 @@
1
+ import{j as e}from"./react-vendor-CSp-GLFF.js";import{c as j,L as u}from"./react-router-I-HqunH7.js";import{u as y}from"./query-C99w429o.js";import{d as w}from"./vendor-CMMjVdZs.js";import{G as N,q as b,d as v,r as k,j as _}from"./lucide-53bR2rki.js";import{f as n}from"./date-fns-CZ_bHujz.js";const H={bmad:["analyze","design","implement","test","review"],harness:["reproduce","safety-net","root-cause","fix","verify"]};async function S(a){const t=await fetch(`/api/workflows/${encodeURIComponent(a)}`);if(!t.ok)throw new Error(`Failed: ${t.status}`);return t.json()}function F(){const{routeRequestId:a}=j(),{data:t,isLoading:d,error:o}=y({queryKey:["workflow-detail",a],queryFn:()=>S(a),enabled:!!a,refetchInterval:5e3});if(d)return e.jsxs("div",{children:[e.jsx(c,{}),e.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:e.jsx("p",{className:"text-gray-600",children:"加载中..."})})]});if(o||!t)return e.jsxs("div",{children:[e.jsx(c,{}),e.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:e.jsx("p",{className:"text-red-600",children:"加载失败"})})]});const r=Array.from(new Set(t.invocations.filter(s=>s.phase!=null&&s.success).map(s=>s.phase))),l=t.workflow?H[t.workflow]??r:r,m=new Set(r),h=l.length>0?r.length/l.length*100:0,p=t.workflow==="bmad",g=t.workflow==="harness",f=p?"bg-blue-100 text-blue-800":g?"bg-orange-100 text-orange-800":"bg-gray-100 text-gray-700";return e.jsxs("div",{children:[e.jsx(c,{}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-6 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3 flex-wrap",children:[e.jsx(N,{className:"h-5 w-5 text-gray-400"}),e.jsx("h1",{className:"text-xl font-bold text-gray-900",children:"工作流详情"}),t.workflow&&e.jsx("span",{className:`px-2 py-1 rounded text-xs font-mono font-semibold ${f}`,children:t.workflow.toUpperCase()}),t.feature_slug&&e.jsx("span",{className:"text-sm text-gray-700 font-medium",children:t.feature_slug})]}),e.jsxs("p",{className:"text-xs text-gray-500 font-mono mb-4 break-all",children:["route_request_id: ",t.route_request_id]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"调用次数"}),e.jsx("div",{className:"text-lg font-semibold",children:t.invocations.length})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"已完成 Phase"}),e.jsxs("div",{className:"text-lg font-semibold",children:[r.length," / ",l.length]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"开始时间"}),e.jsx("div",{className:"text-sm",children:n(new Date(t.first_at),"MM-dd HH:mm:ss")})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"最后更新"}),e.jsx("div",{className:"text-sm",children:n(new Date(t.last_at),"MM-dd HH:mm:ss")})]})]}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2 mb-3 overflow-hidden",children:e.jsx("div",{className:"bg-green-500 h-2 rounded-full transition-all duration-300",style:{width:`${h}%`}})}),e.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2",children:l.map((s,x)=>{const i=m.has(s);return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium ${i?"bg-green-500 text-white":"bg-gray-200 text-gray-500"}`,children:i?"✓":x+1}),e.jsx("span",{className:`text-sm ${i?"text-gray-900":"text-gray-400"}`,children:s})]},s)})})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-4 border-b border-gray-200",children:[e.jsx("h2",{className:"text-base font-semibold text-gray-900",children:"调用流水"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"按时间正序排列"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"#"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Phase"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Skill"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"时间"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"状态"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"产物"})]})}),e.jsxs("tbody",{className:"bg-white divide-y divide-gray-200",children:[t.invocations.map((s,x)=>e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-4 py-3 text-sm text-gray-500 font-mono",children:x+1}),e.jsx("td",{className:"px-4 py-3",children:s.phase?e.jsx("span",{className:"text-sm font-mono text-gray-900",children:s.phase}):e.jsx("span",{className:"text-xs text-gray-400",children:"—"})}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"text-sm font-mono text-indigo-600",children:s.skill_id}),s.reason&&e.jsx("div",{className:"text-xs text-gray-500 mt-0.5 max-w-md truncate",children:s.reason})]}),e.jsx("td",{className:"px-4 py-3 text-sm text-gray-500 whitespace-nowrap",children:n(new Date(s.timestamp),"HH:mm:ss")}),e.jsx("td",{className:"px-4 py-3",children:s.success?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-green-700",children:[e.jsx(b,{className:"h-3.5 w-3.5"}),"成功"]}):e.jsxs("span",{className:w("inline-flex items-center gap-1 text-xs text-red-700",s.error&&"cursor-help"),title:s.error??void 0,children:[e.jsx(v,{className:"h-3.5 w-3.5"}),"失败"]})}),e.jsx("td",{className:"px-4 py-3",children:s.artifact_path?e.jsxs("a",{href:`file://${s.artifact_path}`,className:"inline-flex items-center gap-1 text-xs text-blue-600 hover:underline max-w-xs truncate",title:s.artifact_path,children:[e.jsx(k,{className:"h-3.5 w-3.5 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:s.artifact_path.split("/").pop()})]}):e.jsx("span",{className:"text-xs text-gray-400",children:"—"})})]},s.id)),t.invocations.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-4 py-12 text-center text-gray-500 text-sm",children:"暂无调用记录"})})]})]})})]})]})}function c(){return e.jsxs(u,{to:"/workflows",className:"inline-flex items-center text-sm text-gray-500 hover:text-gray-700 mb-4",children:[e.jsx(_,{className:"h-4 w-4 mr-1"}),"返回工作流列表"]})}export{F as default};
2
+ //# sourceMappingURL=WorkflowDetail-zhNqUkBE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkflowDetail-zhNqUkBE.js","sources":["../../src/pages/WorkflowDetail.tsx"],"sourcesContent":["import { useParams, Link } from 'react-router-dom'\nimport { useQuery } from '@tanstack/react-query'\nimport { format } from 'date-fns'\nimport { ArrowLeft, CheckCircle2, XCircle, FileText, GitBranch } from 'lucide-react'\nimport clsx from 'clsx'\n\ninterface Invocation {\n id: string\n skill_id: string\n phase: string | null\n workflow: string | null\n feature_slug: string | null\n reason: string | null\n invocation_type: 'static' | 'dynamic' | 'slash_command'\n success: boolean\n error: string | null\n timestamp: number\n artifact_path: string | null\n}\n\ninterface WorkflowDetailData {\n route_request_id: string\n workflow: string | null\n feature_slug: string | null\n session_id: string\n agent_id: string | null\n first_at: number\n last_at: number\n invocations: Invocation[]\n}\n\nconst WORKFLOW_PHASES: Record<string, string[]> = {\n bmad: ['analyze', 'design', 'implement', 'test', 'review'],\n harness: ['reproduce', 'safety-net', 'root-cause', 'fix', 'verify'],\n}\n\nasync function fetchDetail(routeRequestId: string): Promise<WorkflowDetailData> {\n const res = await fetch(`/api/workflows/${encodeURIComponent(routeRequestId)}`)\n if (!res.ok) throw new Error(`Failed: ${res.status}`)\n return res.json()\n}\n\nexport default function WorkflowDetail() {\n const { routeRequestId } = useParams<{ routeRequestId: string }>()\n const { data, isLoading, error } = useQuery({\n queryKey: ['workflow-detail', routeRequestId],\n queryFn: () => fetchDetail(routeRequestId!),\n enabled: !!routeRequestId,\n refetchInterval: 5000,\n })\n\n if (isLoading) {\n return (\n <div>\n <BackLink />\n <div className=\"bg-white rounded-lg shadow p-6\">\n <p className=\"text-gray-600\">加载中...</p>\n </div>\n </div>\n )\n }\n\n if (error || !data) {\n return (\n <div>\n <BackLink />\n <div className=\"bg-white rounded-lg shadow p-6\">\n <p className=\"text-red-600\">加载失败</p>\n </div>\n </div>\n )\n }\n\n const completedPhases = Array.from(\n new Set(\n data.invocations\n .filter(inv => inv.phase != null && inv.success)\n .map(inv => inv.phase as string),\n ),\n )\n const allPhases = data.workflow ? WORKFLOW_PHASES[data.workflow] ?? completedPhases : completedPhases\n const completedSet = new Set(completedPhases)\n const progress = allPhases.length > 0 ? (completedPhases.length / allPhases.length) * 100 : 0\n\n const isBmad = data.workflow === 'bmad'\n const isHarness = data.workflow === 'harness'\n const badgeClass = isBmad\n ? 'bg-blue-100 text-blue-800'\n : isHarness\n ? 'bg-orange-100 text-orange-800'\n : 'bg-gray-100 text-gray-700'\n\n return (\n <div>\n <BackLink />\n\n {/* 头部信息卡 */}\n <div className=\"bg-white rounded-lg shadow p-6 mb-4\">\n <div className=\"flex items-center gap-3 mb-3 flex-wrap\">\n <GitBranch className=\"h-5 w-5 text-gray-400\" />\n <h1 className=\"text-xl font-bold text-gray-900\">工作流详情</h1>\n {data.workflow && (\n <span className={`px-2 py-1 rounded text-xs font-mono font-semibold ${badgeClass}`}>\n {data.workflow.toUpperCase()}\n </span>\n )}\n {data.feature_slug && (\n <span className=\"text-sm text-gray-700 font-medium\">{data.feature_slug}</span>\n )}\n </div>\n <p className=\"text-xs text-gray-500 font-mono mb-4 break-all\">\n route_request_id: {data.route_request_id}\n </p>\n\n <div className=\"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4\">\n <div>\n <div className=\"text-xs text-gray-500\">调用次数</div>\n <div className=\"text-lg font-semibold\">{data.invocations.length}</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500\">已完成 Phase</div>\n <div className=\"text-lg font-semibold\">\n {completedPhases.length} / {allPhases.length}\n </div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500\">开始时间</div>\n <div className=\"text-sm\">{format(new Date(data.first_at), 'MM-dd HH:mm:ss')}</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500\">最后更新</div>\n <div className=\"text-sm\">{format(new Date(data.last_at), 'MM-dd HH:mm:ss')}</div>\n </div>\n </div>\n\n {/* 进度条 */}\n <div className=\"w-full bg-gray-200 rounded-full h-2 mb-3 overflow-hidden\">\n <div\n className=\"bg-green-500 h-2 rounded-full transition-all duration-300\"\n style={{ width: `${progress}%` }}\n />\n </div>\n\n {/* Phase 时间线 */}\n <div className=\"flex flex-wrap gap-x-3 gap-y-2\">\n {allPhases.map((phase, idx) => {\n const completed = completedSet.has(phase)\n return (\n <div key={phase} className=\"flex items-center gap-1.5\">\n <span\n className={`w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium ${\n completed ? 'bg-green-500 text-white' : 'bg-gray-200 text-gray-500'\n }`}\n >\n {completed ? '✓' : idx + 1}\n </span>\n <span className={`text-sm ${completed ? 'text-gray-900' : 'text-gray-400'}`}>\n {phase}\n </span>\n </div>\n )\n })}\n </div>\n </div>\n\n {/* 调用流水表 */}\n <div className=\"bg-white rounded-lg shadow overflow-hidden\">\n <div className=\"px-6 py-4 border-b border-gray-200\">\n <h2 className=\"text-base font-semibold text-gray-900\">调用流水</h2>\n <p className=\"text-xs text-gray-500 mt-1\">按时间正序排列</p>\n </div>\n <div className=\"overflow-x-auto\">\n <table className=\"min-w-full divide-y divide-gray-200\">\n <thead className=\"bg-gray-50\">\n <tr>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n #\n </th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n Phase\n </th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n Skill\n </th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n 时间\n </th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n 状态\n </th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n 产物\n </th>\n </tr>\n </thead>\n <tbody className=\"bg-white divide-y divide-gray-200\">\n {data.invocations.map((inv, idx) => (\n <tr key={inv.id} className=\"hover:bg-gray-50\">\n <td className=\"px-4 py-3 text-sm text-gray-500 font-mono\">{idx + 1}</td>\n <td className=\"px-4 py-3\">\n {inv.phase ? (\n <span className=\"text-sm font-mono text-gray-900\">{inv.phase}</span>\n ) : (\n <span className=\"text-xs text-gray-400\">—</span>\n )}\n </td>\n <td className=\"px-4 py-3\">\n <div className=\"text-sm font-mono text-indigo-600\">{inv.skill_id}</div>\n {inv.reason && (\n <div className=\"text-xs text-gray-500 mt-0.5 max-w-md truncate\">\n {inv.reason}\n </div>\n )}\n </td>\n <td className=\"px-4 py-3 text-sm text-gray-500 whitespace-nowrap\">\n {format(new Date(inv.timestamp), 'HH:mm:ss')}\n </td>\n <td className=\"px-4 py-3\">\n {inv.success ? (\n <span className=\"inline-flex items-center gap-1 text-xs text-green-700\">\n <CheckCircle2 className=\"h-3.5 w-3.5\" />\n 成功\n </span>\n ) : (\n <span\n className={clsx(\n 'inline-flex items-center gap-1 text-xs text-red-700',\n inv.error && 'cursor-help',\n )}\n title={inv.error ?? undefined}\n >\n <XCircle className=\"h-3.5 w-3.5\" />\n 失败\n </span>\n )}\n </td>\n <td className=\"px-4 py-3\">\n {inv.artifact_path ? (\n <a\n href={`file://${inv.artifact_path}`}\n className=\"inline-flex items-center gap-1 text-xs text-blue-600 hover:underline max-w-xs truncate\"\n title={inv.artifact_path}\n >\n <FileText className=\"h-3.5 w-3.5 flex-shrink-0\" />\n <span className=\"truncate\">{inv.artifact_path.split('/').pop()}</span>\n </a>\n ) : (\n <span className=\"text-xs text-gray-400\">—</span>\n )}\n </td>\n </tr>\n ))}\n {data.invocations.length === 0 && (\n <tr>\n <td colSpan={6} className=\"px-4 py-12 text-center text-gray-500 text-sm\">\n 暂无调用记录\n </td>\n </tr>\n )}\n </tbody>\n </table>\n </div>\n </div>\n </div>\n )\n}\n\nfunction BackLink() {\n return (\n <Link\n to=\"/workflows\"\n className=\"inline-flex items-center text-sm text-gray-500 hover:text-gray-700 mb-4\"\n >\n <ArrowLeft className=\"h-4 w-4 mr-1\" />\n 返回工作流列表\n </Link>\n )\n}\n"],"names":["WORKFLOW_PHASES","fetchDetail","routeRequestId","res","WorkflowDetail","useParams","data","isLoading","error","useQuery","jsx","BackLink","completedPhases","inv","allPhases","completedSet","progress","isBmad","isHarness","badgeClass","jsxs","GitBranch","format","phase","idx","completed","CheckCircle2","clsx","XCircle","FileText","Link","ArrowLeft"],"mappings":"sSA+BA,MAAMA,EAA4C,CAChD,KAAM,CAAC,UAAW,SAAU,YAAa,OAAQ,QAAQ,EACzD,QAAS,CAAC,YAAa,aAAc,aAAc,MAAO,QAAQ,CACpE,EAEA,eAAeC,EAAYC,EAAqD,CAC9E,MAAMC,EAAM,MAAM,MAAM,kBAAkB,mBAAmBD,CAAc,CAAC,EAAE,EAC9E,GAAI,CAACC,EAAI,GAAI,MAAM,IAAI,MAAM,WAAWA,EAAI,MAAM,EAAE,EACpD,OAAOA,EAAI,KAAA,CACb,CAEA,SAAwBC,GAAiB,CACvC,KAAM,CAAE,eAAAF,CAAA,EAAmBG,EAAA,EACrB,CAAE,KAAAC,EAAM,UAAAC,EAAW,MAAAC,CAAA,EAAUC,EAAS,CAC1C,SAAU,CAAC,kBAAmBP,CAAc,EAC5C,QAAS,IAAMD,EAAYC,CAAe,EAC1C,QAAS,CAAC,CAACA,EACX,gBAAiB,GAAA,CAClB,EAED,GAAIK,EACF,cACG,MAAA,CACC,SAAA,CAAAG,EAAAA,IAACC,EAAA,EAAS,EACVD,EAAAA,IAAC,OAAI,UAAU,iCACb,eAAC,IAAA,CAAE,UAAU,gBAAgB,SAAA,QAAA,CAAM,CAAA,CACrC,CAAA,EACF,EAIJ,GAAIF,GAAS,CAACF,EACZ,cACG,MAAA,CACC,SAAA,CAAAI,EAAAA,IAACC,EAAA,EAAS,EACVD,EAAAA,IAAC,OAAI,UAAU,iCACb,eAAC,IAAA,CAAE,UAAU,eAAe,SAAA,MAAA,CAAI,CAAA,CAClC,CAAA,EACF,EAIJ,MAAME,EAAkB,MAAM,KAC5B,IAAI,IACFN,EAAK,YACF,OAAOO,GAAOA,E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1,2 @@
1
+ import{j as e}from"./react-vendor-CSp-GLFF.js";import{u as o}from"./query-C99w429o.js";import{L as m}from"./react-router-I-HqunH7.js";import{G as h,g}from"./lucide-53bR2rki.js";import{a as p,z as u}from"./date-fns-CZ_bHujz.js";import"./vendor-CMMjVdZs.js";const f={bmad:["analyze","design","implement","test","review"],harness:["reproduce","safety-net","root-cause","fix","verify"]};async function j(){const s=await fetch("/api/workflows");if(!s.ok)throw new Error("Failed to fetch workflows");return s.json()}function q(){const{data:s,isLoading:t,error:a}=o({queryKey:["workflows"],queryFn:j,refetchInterval:5e3});return t?e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-6",children:"工作流进度"}),e.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:e.jsx("p",{className:"text-gray-600",children:"加载中..."})})]}):a?e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-6",children:"工作流进度"}),e.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:e.jsxs("p",{className:"text-red-600",children:["加载失败: ",a.message]})})]}):s?e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-between mb-4 flex-wrap gap-3",children:e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"工作流进度"})}),e.jsxs("p",{className:"text-sm text-gray-500 mb-4",children:["共 ",s.total," 个 BMAD / Harness 工作流(每 5 秒自动刷新)"]}),s.items.length===0?e.jsxs("div",{className:"bg-white rounded-lg shadow p-12 text-center",children:[e.jsx(h,{className:"h-10 w-10 text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-500 text-sm",children:"暂无工作流记录"}),e.jsx("p",{className:"text-gray-400 text-xs mt-2",children:"触发 BMAD / Harness 工作流后,进度将自动显示在这里"})]}):e.jsx("div",{className:"space-y-4",children:s.items.map(r=>e.jsx(y,{workflow:r},r.route_request_id))})]}):null}function y({workflow:s}){const t=f[s.workflow]??s.phases_completed,a=new Set(s.phases_completed),r=t.length>0?s.phases_completed.length/t.length*100:0,i=s.workflow==="bmad",c=s.workflow==="harness",d=i?"bg-blue-100 text-blue-800":c?"bg-orange-100 text-orange-800":"bg-gray-100 text-gray-700";return e.jsxs("div",{className:"border border-gray-200 rounded-lg p-4 bg-white shadow-sm hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:`px-2 py-1 rounded text-xs font-mono font-semibold ${d}`,children:s.workflow.toUpperCase()}),s.feature_slug&&e.jsx("span",{className:"text-sm text-gray-700 font-medium",children:s.feature_slug}),e.jsxs("span",{className:"text-xs text-gray-400 font-mono",children:[s.route_request_id.slice(0,12),"..."]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-gray-500",children:[e.jsx(g,{className:"h-3 w-3"}),s.last_at?p(new Date(s.last_at),{addSuffix:!0,locale:u}):"-"]})]}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2 mb-2 overflow-hidden",children:e.jsx("div",{className:"bg-green-500 h-2 rounded-full transition-all duration-300",style:{width:`${r}%`}})}),e.jsxs("div",{className:"text-xs text-gray-500 mb-3 flex items-center gap-3",children:[e.jsxs("span",{children:[s.phases_completed.length," / ",t.length," phases"]}),e.jsx("span",{className:"text-gray-300",children:"·"}),e.jsxs("span",{children:["调用 ",e.jsx("span",{className:"text-green-600 font-medium",children:s.success_count}),e.jsxs("span",{className:"text-gray-400",children:[" / ",s.total_invocations]})," 成功"]})]}),e.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-2 mb-3",children:t.map((n,x)=>{const l=a.has(n);return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium ${l?"bg-green-500 text-white":"bg-gray-200 text-gray-500"}`,children:l?"✓":x+1}),e.jsx("span",{className:`text-sm ${l?"text-gray-900":"text-gray-400"}`,children:n})]},n)})}),e.jsx(m,{to:`/workflows/${encodeURIComponent(s.route_request_id)}`,className:"text-blue-600 text-sm hover:underline inline-block",children:"查看详情 →"})]})}export{q as default};
2
+ //# sourceMappingURL=Workflows-Btvi-lGw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Workflows-Btvi-lGw.js","sources":["../../src/pages/Workflows.tsx"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\nimport { Link } from 'react-router-dom'\nimport { GitBranch, Clock } from 'lucide-react'\nimport { formatDistanceToNow } from 'date-fns'\nimport { zhCN } from 'date-fns/locale'\n\ninterface WorkflowProgress {\n route_request_id: string\n workflow: string\n phases_completed: string[]\n feature_slug: string | null\n total_invocations: number\n success_count: number\n first_at: number\n last_at: number\n}\n\ninterface WorkflowsResponse {\n total: number\n items: WorkflowProgress[]\n}\n\n/**\n * BMAD / Harness 等内置工作流的 phase 顺序定义。用于在卡片上画完整的进度条 —\n * 已完成的 phase 标记为绿色实心圆,未完成的 phase 留灰色。\n *\n * 与后端 routing/skill 注册保持一致;如果遇到这里没有列出的 workflow(自定义工作流),\n * 渲染时退化为只展示 phases_completed 本身,不画 placeholder。\n */\nconst WORKFLOW_PHASES: Record<string, string[]> = {\n bmad: ['analyze', 'design', 'implement', 'test', 'review'],\n harness: ['reproduce', 'safety-net', 'root-cause', 'fix', 'verify'],\n}\n\nasync function fetchWorkflows(): Promise<WorkflowsResponse> {\n const res = await fetch('/api/workflows')\n if (!res.ok) throw new Error('Failed to fetch workflows')\n return res.json()\n}\n\nexport default function Workflows() {\n const { data, isLoading, error } = useQuery({\n queryKey: ['workflows'],\n queryFn: fetchWorkflows,\n refetchInterval: 5000, // 5s 轮询,便于实时观察 phase 推进\n })\n\n if (isLoading) {\n return (\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900 mb-6\">工作流进度</h1>\n <div className=\"bg-white rounded-lg shadow p-6\">\n <p className=\"text-gray-600\">加载中...</p>\n </div>\n </div>\n )\n }\n\n if (error) {\n return (\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900 mb-6\">工作流进度</h1>\n <div className=\"bg-white rounded-lg shadow p-6\">\n <p className=\"text-red-600\">加载失败: {(error as Error).message}</p>\n </div>\n </div>\n )\n }\n\n if (!data) return null\n\n return (\n <div>\n <div className=\"flex items-center justify-between mb-4 flex-wrap gap-3\">\n <h1 className=\"text-2xl font-bold text-gray-900\">工作流进度</h1>\n </div>\n\n <p className=\"text-sm text-gray-500 mb-4\">\n 共 {data.total} 个 BMAD / Harness 工作流(每 5 秒自动刷新)\n </p>\n\n {data.items.length === 0 ? (\n <div className=\"bg-white rounded-lg shadow p-12 text-center\">\n <GitBranch className=\"h-10 w-10 text-gray-300 mx-auto mb-3\" />\n <p className=\"text-gray-500 text-sm\">暂无工作流记录</p>\n <p className=\"text-gray-400 text-xs mt-2\">\n 触发 BMAD / Harness 工作流后,进度将自动显示在这里\n </p>\n </div>\n ) : (\n <div className=\"space-y-4\">\n {data.items.map(wf => (\n <WorkflowCard key={wf.route_request_id} workflow={wf} />\n ))}\n </div>\n )}\n </div>\n )\n}\n\nfunction WorkflowCard({ workflow }: { workflow: WorkflowProgress }) {\n const allPhases = WORKFLOW_PHASES[workflow.workflow] ?? workflow.phases_completed\n const completedSet = new Set(workflow.phases_completed)\n const progress = allPhases.length > 0\n ? (workflow.phases_completed.length / allPhases.length) * 100\n : 0\n\n const isBmad = workflow.workflow === 'bmad'\n const isHarness = workflow.workflow === 'harness'\n const badgeClass = isBmad\n ? 'bg-blue-100 text-blue-800'\n : isHarness\n ? 'bg-orange-100 text-orange-800'\n : 'bg-gray-100 text-gray-700'\n\n return (\n <div className=\"border border-gray-200 rounded-lg p-4 bg-white shadow-sm hover:shadow-md transition-shadow\">\n <div className=\"flex justify-between items-start mb-3\">\n <div className=\"flex items-center gap-2 flex-wrap\">\n <span className={`px-2 py-1 rounded text-xs font-mono font-semibold ${badgeClass}`}>\n {workflow.workflow.toUpperCase()}\n </span>\n {workflow.feature_slug && (\n <span className=\"text-sm text-gray-700 font-medium\">{workflow.feature_slug}</span>\n )}\n <span className=\"text-xs text-gray-400 font-mono\">\n {workflow.route_request_id.slice(0, 12)}...\n </span>\n </div>\n <div className=\"flex items-center gap-1 text-xs text-gray-500\">\n <Clock className=\"h-3 w-3\" />\n {workflow.last_at\n ? formatDistanceToNow(new Date(workflow.last_at), { addSuffix: true, locale: zhCN })\n : '-'}\n </div>\n </div>\n\n {/* 进度条 */}\n <div className=\"w-full bg-gray-200 rounded-full h-2 mb-2 overflow-hidden\">\n <div\n className=\"bg-green-500 h-2 rounded-full transition-all duration-300\"\n style={{ width: `${progress}%` }}\n />\n </div>\n <div className=\"text-xs text-gray-500 mb-3 flex items-center gap-3\">\n <span>\n {workflow.phases_completed.length} / {allPhases.length} phases\n </span>\n <span className=\"text-gray-300\">·</span>\n <span>\n 调用 <span className=\"text-green-600 font-medium\">{workflow.success_count}</span>\n <span className=\"text-gray-400\"> / {workflow.total_invocations}</span> 成功\n </span>\n </div>\n\n {/* Phase 列表 */}\n <div className=\"flex flex-wrap gap-x-3 gap-y-2 mb-3\">\n {allPhases.map((phase, idx) => {\n const completed = completedSet.has(phase)\n return (\n <div key={phase} className=\"flex items-center gap-1.5\">\n <span\n className={`w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium ${\n completed\n ? 'bg-green-500 text-white'\n : 'bg-gray-200 text-gray-500'\n }`}\n >\n {completed ? '✓' : idx + 1}\n </span>\n <span className={`text-sm ${completed ? 'text-gray-900' : 'text-gray-400'}`}>\n {phase}\n </span>\n </div>\n )\n })}\n </div>\n\n <Link\n to={`/workflows/${encodeURIComponent(workflow.route_request_id)}`}\n className=\"text-blue-600 text-sm hover:underline inline-block\"\n >\n 查看详情 →\n </Link>\n </div>\n )\n}\n"],"names":["WORKFLOW_PHASES","fetchWorkflows","res","Workflows","data","isLoading","error","useQuery","jsx","jsxs","GitBranch","wf","WorkflowCard","workflow","allPhases","completedSet","progress","isBmad","isHarness","badgeClass","Clock","formatDistanceToNow","zhCN","phase","idx","completed","Link"],"mappings":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ange:t,placeholder:n,className:o=""}){return r.jsxs("div",{className:`relative ${o}`,children:[r.jsx(l,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),r.jsx("input",{type:"text",value:e,onChange:s=>t(s.target.value),placeholder:n||"搜索...",className:"w-full pl-8 pr-8 py-1.5 text-sm border border-gray-300 rounded-md bg-white focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500"}),e&&r.jsx("button",{onClick:()=>t(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:r.jsx(d,{className:"h-4 w-4"})})]})}function u(e,t){const n=JSON.stringify(t,null,2),o=new Blob([n],{type:"application/json"});c(e,o)}function b(e,t){if(!t||t.length===0){u(e.replace(/\.csv$/,".json"),t);return}const n=Object.keys(t[0]),o=[n.join(","),...t.map(a=>n.map(i=>p(a[i])).join(","))].join(`
1
+ import{j as r}from"./react-vendor-CSp-GLFF.js";import{S as l,X as d}from"./lucide-53bR2rki.js";function m({value:e,onChange:t,placeholder:n,className:o=""}){return r.jsxs("div",{className:`relative ${o}`,children:[r.jsx(l,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),r.jsx("input",{type:"text",value:e,onChange:s=>t(s.target.value),placeholder:n||"搜索...",className:"w-full pl-8 pr-8 py-1.5 text-sm border border-gray-300 rounded-md bg-white focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500"}),e&&r.jsx("button",{onClick:()=>t(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:r.jsx(d,{className:"h-4 w-4"})})]})}function u(e,t){const n=JSON.stringify(t,null,2),o=new Blob([n],{type:"application/json"});c(e,o)}function b(e,t){if(!t||t.length===0){u(e.replace(/\.csv$/,".json"),t);return}const n=Object.keys(t[0]),o=[n.join(","),...t.map(a=>n.map(i=>p(a[i])).join(","))].join(`
2
2
  `),s=new Blob(["\uFEFF"+o],{type:"text/csv;charset=utf-8"});c(e,s)}function p(e){if(e==null)return"";const t=typeof e=="object"?JSON.stringify(e):String(e);return t.includes(",")||t.includes('"')||t.includes(`
3
3
  `)?`"${t.replace(/"/g,'""')}"`:t}function c(e,t){const n=URL.createObjectURL(t),o=document.createElement("a");o.href=n,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}function h(){const e=new Date,t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}`}export{m as S,b as a,u as d,h as g};
4
- //# sourceMappingURL=export-C0mlC4AT.js.map
4
+ //# sourceMappingURL=export-BQQZLaHV.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"export-C0mlC4AT.js","sources":["../../src/components/SearchInput.tsx","../../src/utils/export.ts"],"sourcesContent":["import { Search, X } from 'lucide-react'\n\ninterface Props {\n value: string\n onChange: (value: string) => void\n placeholder?: string\n className?: string\n}\n\nexport default function SearchInput({ value, onChange, placeholder, className = '' }: Props) {\n return (\n <div className={`relative ${className}`}>\n <Search className=\"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400\" />\n <input\n type=\"text\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n placeholder={placeholder || '搜索...'}\n className=\"w-full pl-8 pr-8 py-1.5 text-sm border border-gray-300 rounded-md bg-white focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500\"\n />\n {value && (\n <button\n onClick={() => onChange('')}\n className=\"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600\"\n >\n <X className=\"h-4 w-4\" />\n </button>\n )}\n </div>\n )\n}\n","/**\n * 导出工具函数:JSON / CSV\n */\n\nexport function downloadJSON(filename: string, data: unknown): void {\n const content = JSON.stringify(data, null, 2)\n const blob = new Blob([content], { type: 'application/json' })\n triggerDownload(filename, blob)\n}\n\nexport function downloadCSV<T extends object>(filename: string, rows: T[]): void {\n if (!rows || rows.length === 0) {\n downloadJSON(filename.replace(/\\.csv$/, '.json'), rows)\n return\n }\n\n const headers = Object.keys(rows[0]) as (keyof T & string)[]\n const csv = [\n headers.join(','),\n ...rows.map(row =>\n headers.map(h => escapeCSV(row[h])).join(',')\n ),\n ].join('\\n')\n\n // 添加 BOM 让 Excel 识别 UTF-8\n const blob = new Blob(['' + csv], { type: 'text/csv;charset=utf-8' })\n triggerDownload(filename, blob)\n}\n\nfunction escapeCSV(value: unknown): string {\n if (value === null || value === undefined) return ''\n const str = typeof value === 'object' ? JSON.stringify(value) : String(value)\n if (str.includes(',') || str.includes('\"') || str.includes('\\n')) {\n return `\"${str.replace(/\"/g, '\"\"')}\"`\n }\n return str\n}\n\nfunction triggerDownload(filename: string, blob: Blob): void {\n const url = URL.createObjectURL(blob)\n const a = document.createElement('a')\n a.href = url\n a.download = filename\n document.body.appendChild(a)\n a.click()\n document.body.removeChild(a)\n URL.revokeObjectURL(url)\n}\n\nexport function getTimestamp(): string {\n const now = new Date()\n const pad = (n: number) => String(n).padStart(2, '0')\n return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`\n}\n"],"names":["SearchInput","value","onChange","placeholder","className","jsxs","jsx","Search","e","X","downloadJSON","filename","data","content","blob","triggerDownload","downloadCSV","rows","headers","csv","row","h","escapeCSV","str","url","a","getTimestamp","now","pad"],"mappings":"+FASA,SAAwBA,EAAY,CAAE,MAAAC,EAAO,SAAAC,EAAU,YAAAC,EAAa,UAAAC,EAAY,IAAa,CAC3F,OACEC,EAAAA,KAAC,MAAA,CAAI,UAAW,YAAYD,CAAS,GACnC,SAAA,CAAAE,EAAAA,IAACC,EAAA,CAAO,UAAU,kEAAA,CAAmE,EACrFD,EAAAA,IAAC,QAAA,CACC,KAAK,OACL,MAAAL,EACA,SAAWO,GAAMN,EAASM,EAAE,OAAO,KAAK,EACxC,YAAaL,GA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CAAI,EAC9BW,EAAI,SAAS,cAAc,GAAG,EACpCA,EAAE,KAAOD,EACTC,EAAE,SAAWd,EACb,SAAS,KAAK,YAAYc,CAAC,EAC3BA,EAAE,MAAA,EACF,SAAS,KAAK,YAAYA,CAAC,EAC3B,IAAI,gBAAgBD,CAAG,CACzB,CAEO,SAASE,GAAuB,CACrC,MAAMC,MAAU,KACVC,EAAO,GAAc,OAAO,CAAC,EAAE,SAAS,EAAG,GAAG,EACpD,MAAO,GAAGD,EAAI,YAAA,CAAa,GAAGC,EAAID,EAAI,SAAA,EAAa,CAAC,CAAC,GAAGC,EAAID,EAAI,SAAS,CAAC,IAAIC,EAAID,EAAI,SAAA,CAAU,CAAC,GAAGC,EAAID,EAAI,WAAA,CAAY,CAAC,GAAGC,EAAID,EAAI,WAAA,CAAY,CAAC,EACnJ"}
1
+ {"version":3,"file":"export-BQQZLaHV.js","sources":["../../src/components/SearchInput.tsx","../../src/utils/export.ts"],"sourcesContent":["import { Search, X } from 'lucide-react'\n\ninterface Props {\n value: string\n onChange: (value: string) => void\n placeholder?: string\n className?: string\n}\n\nexport default function SearchInput({ value, onChange, placeholder, className = '' }: Props) {\n return (\n <div className={`relative ${className}`}>\n <Search className=\"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400\" />\n <input\n type=\"text\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n placeholder={placeholder || '搜索...'}\n className=\"w-full pl-8 pr-8 py-1.5 text-sm border border-gray-300 rounded-md bg-white focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500\"\n />\n {value && (\n <button\n onClick={() => onChange('')}\n className=\"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600\"\n >\n <X className=\"h-4 w-4\" />\n </button>\n )}\n </div>\n )\n}\n","/**\n * 导出工具函数:JSON / CSV\n */\n\nexport function downloadJSON(filename: string, data: unknown): void {\n const content = JSON.stringify(data, null, 2)\n const blob = new Blob([content], { type: 'application/json' })\n triggerDownload(filename, blob)\n}\n\nexport function downloadCSV<T extends object>(filename: string, rows: T[]): void {\n if (!rows || rows.length === 0) {\n downloadJSON(filename.replace(/\\.csv$/, '.json'), rows)\n return\n }\n\n const headers = Object.keys(rows[0]) as (keyof T & string)[]\n const csv = [\n headers.join(','),\n ...rows.map(row =>\n headers.map(h => escapeCSV(row[h])).join(',')\n ),\n ].join('\\n')\n\n // 添加 BOM 让 Excel 识别 UTF-8\n const blob = new Blob(['' + csv], { type: 'text/csv;charset=utf-8' })\n triggerDownload(filename, blob)\n}\n\nfunction escapeCSV(value: unknown): string {\n if (value === null || value === undefined) return ''\n const str = typeof value === 'object' ? JSON.stringify(value) : String(value)\n if (str.includes(',') || str.includes('\"') || str.includes('\\n')) {\n return `\"${str.replace(/\"/g, '\"\"')}\"`\n }\n return str\n}\n\nfunction triggerDownload(filename: string, blob: Blob): void {\n const url = URL.createObjectURL(blob)\n const a = document.createElement('a')\n a.href = url\n a.download = filename\n document.body.appendChild(a)\n a.click()\n document.body.removeChild(a)\n URL.revokeObjectURL(url)\n}\n\nexport function getTimestamp(): string {\n const now = new Date()\n const pad = (n: number) => String(n).padStart(2, '0')\n return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`\n}\n"],"names":["SearchInput","value","onChange","placeholder","className","jsxs","jsx","Search","e","X","downloadJSON","filename","data","content","blob","triggerDownload","downloadCSV","rows","headers","csv","row","h","escapeCSV","str","url","a","getTimestamp","now","pad"],"mappings":"+FASA,SAAwBA,EAAY,CAAE,MAAAC,EAAO,SAAAC,EAAU,YAAAC,EAAa,UAAAC,EAAY,IAAa,CAC3F,OACEC,EAAAA,KAAC,MAAA,CAAI,UAAW,YAAYD,CAAS,GACnC,SAAA,CAAAE,EAAAA,IAACC,EAAA,CAAO,UAAU,kEAAA,CAAmE,EACrFD,EAAAA,IAAC,QAAA,CACC,KAAK,OACL,MAAAL,EACA,S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,EAAkBG,EAAkB,CAC3D,MAAMU,EAAM,IAAI,gBAAgBV,CAAI,EAC9BW,EAAI,SAAS,cAAc,GAAG,EACpCA,EAAE,KAAOD,EACTC,EAAE,SAAWd,EACb,SAAS,KAAK,YAAYc,CAAC,EAC3BA,EAAE,MAAA,EACF,SAAS,KAAK,YAAYA,CAAC,EAC3B,IAAI,gBAAgBD,CAAG,CACzB,CAEO,SAASE,GAAuB,CACrC,MAAMC,MAAU,KACVC,EAAO,GAAc,OAAO,CAAC,EAAE,SAAS,EAAG,GAAG,EACpD,MAAO,GAAGD,EAAI,YAAA,CAAa,GAAGC,EAAID,EAAI,SAAA,EAAa,CAAC,CAAC,GAAGC,EAAID,EAAI,SAAS,CAAC,IAAIC,EAAID,EAAI,SAAA,CAAU,CAAC,GAAGC,EAAID,EAAI,WAAA,CAAY,CAAC,GAAGC,EAAID,EAAI,WAAA,CAAY,CAAC,EACnJ"}
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-Cy1xsj1J.js","assets/react-vendor-CSp-GLFF.js","assets/query-C99w429o.js","assets/react-router-I-HqunH7.js","assets/vendor-CMMjVdZs.js","assets/lucide-53bR2rki.js","assets/charts-CLrM0_uM.js","assets/Sessions-C6J_HQ_u.js","assets/Drawer-DcU3ln98.js","assets/date-fns-CZ_bHujz.js","assets/export-BQQZLaHV.js","assets/syntax-highlighter-44FakypI.js","assets/SessionDetail-BT0l4RrK.js","assets/Events-mFhXl4zI.js","assets/CodeBlock--H53gk46.js","assets/ExecutionTrace-DG901hLR.js","assets/Agents-Beg34V1g.js","assets/MarkdownRenderer-CCIz1MOz.js","assets/auth-Bnf8ZcqN.js","assets/Skills-4DQWLaTv.js","assets/Routing-B7BFLfjh.js","assets/AIConfig-R5wZ3ZKT.js","assets/Workflows-Btvi-lGw.js","assets/WorkflowDetail-zhNqUkBE.js"])))=>i.map(i=>d[i]);
2
+ import{r as s,j as e,e as b,d as y}from"./react-vendor-CSp-GLFF.js";import{u as v,O as w,L as N,R as _,a as c,N as C,B as k}from"./react-router-I-HqunH7.js";import{Q as E,a as T}from"./query-C99w429o.js";import{_ as x}from"./syntax-highlighter-44FakypI.js";import{d as h}from"./vendor-CMMjVdZs.js";import{X as p,M as O,L as P,a as A,A as S,T as L,G as I,B as R,b as z,N as D,C as V,I as F,c as B,d as q,e as M,f as W}from"./lucide-53bR2rki.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const t of n.addedNodes)t.tagName==="LINK"&&t.rel==="modulepreload"&&o(t)}).observe(document,{childList:!0,subtree:!0});function l(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function o(r){if(r.ep)return;r.ep=!0;const n=l(r);fetch(r.href,n)}})();const Q=[{title:"总览",items:[{name:"仪表盘",href:"/dashboard",icon:P}]},{title:"活动",items:[{name:"会话",href:"/sessions",icon:A},{name:"事件",href:"/events",icon:S},{name:"执行追踪",href:"/execution-trace",icon:L},{name:"工作流进度",href:"/workflows",icon:I}]},{title:"配置",items:[{name:"Agent 管理",href:"/agents",icon:R},{name:"Skill 管理",href:"/skills",icon:z},{name:"Agent 路由",href:"/routing",icon:D},{name:"AI 配置",href:"/ai-config",icon:V}]}];function G(){const i=v(),[a,l]=s.useState(!1),o=r=>e.jsx(e.Fragment,{children:Q.map(n=>e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"px-3 py-2 text-xs font-semibold text-gray-400 uppercase tracking-wider",children:n.title}),n.items.map(t=>{const u=t.icon,m=i.pathname===t.href||i.pathname.startsWith(t.href+"/");return e.jsxs(N,{to:t.href,onClick:r,className:h("group flex items-center px-3 py-2 text-sm font-medium rounded-md mb-0.5",m?"bg-indigo-50 text-indigo-600":"text-gray-700 hover:bg-gray-50"),children:[e.jsx(u,{className:h("mr-3 h-4 w-4",m?"text-indigo-600":"text-gray-400")}),t.name]},t.name)})]},n.title))});return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsxs("div",{className:h("fixed inset-0 z-40 lg:hidden",a?"block":"hidden"),children:[e.jsx("div",{className:"fixed inset-0 bg-gray-600 bg-opacity-75",onClick:()=>l(!1)}),e.jsxs("div",{className:"fixed inset-y-0 left-0 flex w-64 flex-col bg-white",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center text-white font-bold text-sm",children:"CF"}),e.jsx("h1",{className:"text-base font-bold text-gray-900",children:"Claude Forge"})]}),e.jsx("button",{onClick:()=>l(!1),className:"text-gray-500",children:e.jsx(p,{className:"h-5 w-5"})})]}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-2 py-4",children:o(()=>l(!1))})]})]}),e.jsx("div",{className:"hidden lg:fixed lg:inset-y-0 lg:flex lg:w-64 lg:flex-col",children:e.jsxs("div",{className:"flex flex-col flex-grow border-r border-gray-200 bg-white",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-4 border-b",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center text-white font-bold text-sm",children:"CF"}),e.jsx("h1",{className:"text-base font-bold text-gray-900",children:"Claude Forge"})]}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-2 py-4",children:o()})]})}),e.jsxs("div",{className:"lg:pl-64",children:[e.jsxs("div",{className:"sticky top-0 z-10 flex h-14 flex-shrink-0 bg-white border-b border-gray-200 lg:hidden",children:[e.jsx("button",{onClick:()=>l(!0),className:"px-4 text-gray-500 focus:outline-none",children:e.jsx(O,{className:"h-5 w-5"})}),e.jsx("div",{className:"flex flex-1 items-center px-4",children:e.jsx("h1",{className:"text-base font-semibold text-gray-900",children:"Claude Forge"})})]}),e.jsx("main",{className:"py-6",children:e.jsx("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8",children:e.jsx(w,{})})})]})]})}const X=s.lazy(()=>x(()=>import("./Dashboard-Cy1xsj1J.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),$=s.lazy(()=>x(()=>import("./Sessions-C6J_HQ_u.js"),__vite__mapDeps([7,1,2,8,4,5,9,10,3,11]))),K=s.lazy(()=>x(()=>import("./SessionDetail-BT0l4RrK.js"),__vite__mapDeps([12,1,3,4,2,5,9]))),U=s.lazy(()=>x(()=>import("./Events-mFhXl4zI.js"),__vite__mapDeps([13,1,2,4,8,5,14,11,10,9,3]))),H=s.lazy(()=>x(()=>import("./ExecutionTrace-DG901hLR.js"),__vite__mapDeps([15,1,2,4,8,5,14,11,10,9,3]))),J=s.lazy(()=>x(()=>import("./Agents-Beg34V1g.js"),__vite__mapDeps([16,1,2,8,4,5,17,11,18,3]))),Y=s.lazy(()=>x(()=>import("./Skills-4DQWLaTv.js"),__vite__mapDeps([19,1,2,8,4,5,17,11,18,3]))),Z=s.lazy(()=>x(()=>import("./Routing-B7BFLfjh.js"),__vite__mapDeps([20,1,2,3,4,5]))),ee=s.lazy(()=>x(()=>import("./AIConfig-R5wZ3ZKT.js"),__vite__mapDeps([21,1,2,18,5,3,4,11]))),se=s.lazy(()=>x(()=>import("./Workflows-Btvi-lGw.js"),__vite__mapDeps([22,1,2,3,4,5,9]))),te=s.lazy(()=>x(()=>import("./WorkflowDetail-zhNqUkBE.js"),__vite__mapDeps([23,1,3,4,2,5,9])));function d(){return e.jsx("div",{className:"flex items-center justify-center h-full py-16",children:e.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-500",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"}),"加载中..."]})})}function re(){return e.jsx(_,{children:e.jsxs(c,{path:"/",element:e.jsx(G,{}),children:[e.jsx(c,{index:!0,element:e.jsx(C,{to:"/dashboard",replace:!0})}),e.jsx(c,{path:"dashboard",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(X,{})})}),e.jsx(c,{path:"sessions",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx($,{})})}),e.jsx(c,{path:"sessions/:id",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(K,{})})}),e.jsx(c,{path:"events",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(U,{})})}),e.jsx(c,{path:"execution-trace",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(H,{})})}),e.jsx(c,{path:"agents",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(J,{})})}),e.jsx(c,{path:"skills",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(Y,{})})}),e.jsx(c,{path:"routing",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(Z,{})})}),e.jsx(c,{path:"ai-config",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(ee,{})})}),e.jsx(c,{path:"workflows",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(se,{})})}),e.jsx(c,{path:"workflows/:routeRequestId",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(te,{})})})]})})}const g=s.createContext(null);function pe(){const i=s.useContext(g);if(!i)throw new Error("useToast must be used within ToastProvider");return i}let ne=1;function ae({children:i}){const[a,l]=s.useState([]),o=s.useCallback(t=>{l(u=>u.filter(m=>m.id!==t))},[]),r=s.useCallback((t,u)=>{const m=ne++;l(f=>[...f,{id:m,type:t,message:u}]),setTimeout(()=>o(m),4e3)},[o]),n={show:r,success:t=>r("success",t),error:t=>r("error",t),warning:t=>r("warning",t),info:t=>r("info",t)};return e.jsxs(g.Provider,{value:n,children:[i,e.jsx("div",{className:"fixed top-4 right-4 z-[9999] space-y-2 max-w-md",children:a.map(t=>e.jsx(ie,{toast:t,onClose:()=>o(t.id)},t.id))})]})}function ie({toast:i,onClose:a}){const l={success:e.jsx(M,{className:"h-5 w-5 text-green-500"}),error:e.jsx(q,{className:"h-5 w-5 text-red-500"}),warning:e.jsx(B,{className:"h-5 w-5 text-yellow-500"}),info:e.jsx(F,{className:"h-5 w-5 text-blue-500"})},o={success:"border-green-200",error:"border-red-200",warning:"border-yellow-200",info:"border-blue-200"};return e.jsxs("div",{className:h("bg-white shadow-lg rounded-lg border px-4 py-3 flex items-start gap-3 animate-in slide-in-from-right",o[i.type]),children:[l[i.type],e.jsx("div",{className:"flex-1 text-sm text-gray-800",children:i.message}),e.jsx("button",{onClick:a,className:"text-gray-400 hover:text-gray-600",children:e.jsx(p,{className:"h-4 w-4"})})]})}const le=s.createContext(null);function oe({children:i}){var m;const[a,l]=s.useState({open:!1,options:null,resolve:null}),o=s.useCallback(f=>new Promise(j=>{l({open:!0,options:f,resolve:j})}),[]),r=f=>{a.resolve&&a.resolve(f),l({open:!1,options:null,resolve:null})},n=((m=a.options)==null?void 0:m.variant)||"danger",t={danger:"text-red-600",warning:"text-yellow-600",info:"text-blue-600"}[n],u={danger:"bg-red-600 hover:bg-red-700",warning:"bg-yellow-600 hover:bg-yellow-700",info:"bg-indigo-600 hover:bg-indigo-700"}[n];return e.jsxs(le.Provider,{value:{confirm:o},children:[i,a.open&&a.options&&e.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black bg-opacity-50",onClick:()=>r(!1)}),e.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl max-w-md w-full mx-4 p-6",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:`flex-shrink-0 ${t}`,children:e.jsx(W,{className:"h-6 w-6"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:a.options.title}),e.jsx("p",{className:"text-sm text-gray-600 whitespace-pre-wrap",children:a.options.message})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-6",children:[e.jsx("button",{onClick:()=>r(!1),className:"px-4 py-2 text-sm text-gray-700 bg-white border border-gray-300 rounded hover:bg-gray-50",children:a.options.cancelText||"取消"}),e.jsx("button",{onClick:()=>r(!0),className:`px-4 py-2 text-sm text-white rounded ${u}`,children:a.options.confirmText||"确定"})]})]})]})]})}const ce=new E({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}});b.createRoot(document.getElementById("root")).render(e.jsx(y.StrictMode,{children:e.jsx(T,{client:ce,children:e.jsx(ae,{children:e.jsx(oe,{children:e.jsx(k,{children:e.jsx(re,{})})})})})}));export{pe as u};
3
+ //# sourceMappingURL=index-Cgr9qMtq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"mappings":";koCA4BA,MAAMA,EAAyB,CAC7B,CACE,MAAO,KACP,MAAO,CACL,CAAE,KAAM,MAAO,KAAM,aAAc,KAAMC,CAAA,CAAgB,CAC3D,EAEF,CACE,MAAO,KACP,MAAO,CACL,CAAE,KAAM,KAAM,KAAM,YAAa,KAAMC,CAAA,EACvC,CAAE,KAAM,KAAM,KAAM,UAAW,KAAMC,CAAA,EACrC,CAAE,KAAM,OAAQ,KAAM,mBAAoB,KAAMC,CAAA,EAChD,CAAE,KAAM,QAAS,KAAM,aAAc,KAAMC,CAAA,CAAU,CACvD,EAEF,CACE,MAAO,KACP,MAAO,CACL,CAAE,KAAM,WAAY,KAAM,UAAW,KAAMC,CAAA,EAC3C,CAAE,KAAM,WAAY,KAAM,UAAW,KAAMC,CAAA,EAC3C,CAAE,KAAM,WAAY,KAAM,WAAY,KAAMC,CAAA,EAC5C,CAAE,KAAM,QAAS,KAAM,aAAc,KAAMC,CAAA,CAAI,CACjD,CAEJ,EAEA,SAAwBC,GAA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,EAAM,MAAQA,EAAM,SACnB1D,OAAC,OAAI,UAAU,0DACb,UAAAH,MAAC,OACC,UAAU,0CACV,QAAS,IAAMkE,EAAY,EAAK,IAElC/D,OAAC,OAAI,UAAU,kEACb,UAAAA,OAAC,OAAI,UAAU,yBACb,UAAAH,MAAC,OAAI,UAAW,iBAAiBsE,CAAS,GACxC,SAAAtE,MAACwE,EAAA,CAAc,UAAU,UAAU,EACrC,EACArE,OAAC,OAAI,UAAU,SACb,UAAAH,MAAC,MAAG,UAAU,2CACX,SAAA6D,EAAM,QAAQ,MACjB,QACC,KAAE,UAAU,4CACV,SAAAA,EAAM,QAAQ,QACjB,GACF,GACF,EACA1D,OAAC,OAAI,UAAU,8BACb,UAAAH,MAAC,UACC,QAAS,IAAMkE,EAAY,EAAK,EAChC,UAAU,2FAET,SAAAL,EAAM,QAAQ,YAAc,OAE/B7D,MAAC,UACC,QAAS,IAAMkE,EAAY,EAAI,EAC/B,UAAW,wCAAwCK,CAAQ,GAE1D,SAAAV,EAAM,QAAQ,aAAe,MAChC,EACF,GACF,GACF,GAEJ,CAEJ,CCtFA,MAAMY,GAAc,IAAIC,EAAY,CAClC,eAAgB,CACd,QAAS,CACP,qBAAsB,GACtB,MAAO,EACT,CAEJ,CAAC,EAEDC,EAAS,WAAW,SAAS,eAAe,MAAM,CAAE,EAAE,OACpD3E,MAAC4E,EAAM,WAAN,CACC,eAACC,EAAA,CAAoB,OAAQJ,GAC3B,SAAAzE,MAACoC,GAAA,CACC,eAACwB,GAAA,CACC,SAAA5D,MAAC8E,GACC,SAAA9E,MAACyB,GAAA,EAAI,EACP,EACF,EACF,EACF,EACF,CACF","names":["sections","LayoutDashboard","MessageSquare","Activity","TrendingUp","GitBranch","Bot","BookOpen","Network","Cpu","Layout","location","useLocation","sidebarOpen","setSidebarOpen","useState","renderNav","onClick","jsx","Fragment","section","jsxs","item","Icon","isActive","Link","clsx","X","Menu","Outlet","Dashboard","lazy","Sessions","SessionDetail","Events","ExecutionTrace","Agents","Skills","Routing","AIConfig","Workflows","WorkflowDetail","PageFallback","App","Routes","Route","Navigate","Suspense","ToastContext","createContext","useToast","ctx","useContext","nextId","ToastProvider","children","toasts","setToasts","remove","useCallback","id","prev","t","show","type","message","value","msg","ToastItem","toast","onClose","icons","CheckCircle","XCircle","AlertCircle","Info","borderColors","ConfirmContext","ConfirmProvider","state","setState","confirm","options","resolve","handleClose","result","variant","_a","iconColor","btnColor","AlertTriangle","queryClient","QueryClient","ReactDOM","React","QueryClientProvider","BrowserRouter"],"ignoreList":[],"sources":["../../src/components/Layout.tsx","../../src/App.tsx","../../src/components/Toast.tsx","../../src/components/Confirm.tsx","../../src/main.tsx"],"sourcesContent":["import { Outlet, Link, useLocation } from 'react-router-dom'\nimport {\n LayoutDashboard,\n MessageSquare,\n Activity,\n Menu,\n X,\n Bot,\n BookOpen,\n Network,\n Cpu,\n TrendingUp,\n GitBranch,\n} from 'lucide-react'\nimport { useState } from 'react'\nimport clsx from 'clsx'\n\ninterface NavItem {\n name: string\n href: string\n icon: any\n}\n\ninterface NavSection {\n title: string\n items: NavItem[]\n}\n\nconst sections: NavSection[] = [\n {\n title: '总览',\n items: [\n { name: '仪表盘', href: '/dashboard', icon: LayoutDashboard },\n ],\n },\n {\n title: '活动',\n items: [\n { name: '会话', href: '/sessions', icon: MessageSquare },\n { name: '事件', href: '/events', icon: Activity },\n { name: '执行追踪', href: '/execution-trace', icon: TrendingUp },\n { name: '工作流进度', href: '/workflows', icon: GitBranch },\n ],\n },\n {\n title: '配置',\n items: [\n { name: 'Agent 管理', href: '/agents', icon: Bot },\n { name: 'Skill 管理', href: '/skills', icon: BookOpen },\n { name: 'Agent 路由', href: '/routing', icon: Network },\n { name: 'AI 配置', href: '/ai-config', icon: Cpu },\n ],\n },\n]\n\nexport default function Layout() {\n const location = useLocation()\n const [sidebarOpen, setSidebarOpen] = useState(false)\n\n const renderNav = (onClick?: () => void) => (\n <>\n {sections.map((section) => (\n <div key={section.title} className=\"mb-4\">\n <div className=\"px-3 py-2 text-xs font-semibold text-gray-400 uppercase tracking-wider\">\n {section.title}\n </div>\n {section.items.map((item) => {\n const Icon = item.icon\n const isActive = location.pathname === item.href || location.pathname.startsWith(item.href + '/')\n return (\n <Link\n key={item.name}\n to={item.href}\n onClick={onClick}\n className={clsx(\n 'group flex items-center px-3 py-2 text-sm font-medium rounded-md mb-0.5',\n isActive\n ? 'bg-indigo-50 text-indigo-600'\n : 'text-gray-700 hover:bg-gray-50'\n )}\n >\n <Icon className={clsx('mr-3 h-4 w-4', isActive ? 'text-indigo-600' : 'text-gray-400')} />\n {item.name}\n </Link>\n )\n })}\n </div>\n ))}\n </>\n )\n\n return (\n <div className=\"min-h-screen bg-gray-50\">\n {/* Mobile sidebar */}\n <div className={clsx('fixed inset-0 z-40 lg:hidden', sidebarOpen ? 'block' : 'hidden')}>\n <div className=\"fixed inset-0 bg-gray-600 bg-opacity-75\" onClick={() => setSidebarOpen(false)} />\n <div className=\"fixed inset-y-0 left-0 flex w-64 flex-col bg-white\">\n <div className=\"flex items-center justify-between px-4 py-4 border-b\">\n <div className=\"flex items-center gap-2\">\n <div className=\"w-8 h-8 rounded-lg bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center text-white font-bold text-sm\">\n CF\n </div>\n <h1 className=\"text-base font-bold text-gray-900\">Claude Forge</h1>\n </div>\n <button onClick={() => setSidebarOpen(false)} className=\"text-gray-500\">\n <X className=\"h-5 w-5\" />\n </button>\n </div>\n <nav className=\"flex-1 overflow-y-auto px-2 py-4\">\n {renderNav(() => setSidebarOpen(false))}\n </nav>\n </div>\n </div>\n\n {/* Desktop sidebar */}\n <div className=\"hidden lg:fixed lg:inset-y-0 lg:flex lg:w-64 lg:flex-col\">\n <div className=\"flex flex-col flex-grow border-r border-gray-200 bg-white\">\n <div className=\"flex items-center gap-2 px-4 py-4 border-b\">\n <div className=\"w-8 h-8 rounded-lg bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center text-white font-bold text-sm\">\n CF\n </div>\n <h1 className=\"text-base font-bold text-gray-900\">Claude Forge</h1>\n </div>\n <nav className=\"flex-1 overflow-y-auto px-2 py-4\">{renderNav()}</nav>\n </div>\n </div>\n\n {/* Main content */}\n <div className=\"lg:pl-64\">\n <div className=\"sticky top-0 z-10 flex h-14 flex-shrink-0 bg-white border-b border-gray-200 lg:hidden\">\n <button\n onClick={() => setSidebarOpen(true)}\n className=\"px-4 text-gray-500 focus:outline-none\"\n >\n <Menu className=\"h-5 w-5\" />\n </button>\n <div className=\"flex flex-1 items-center px-4\">\n <h1 className=\"text-base font-semibold text-gray-900\">Claude Forge</h1>\n </div>\n </div>\n <main className=\"py-6\">\n <div className=\"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8\">\n <Outlet />\n </div>\n </main>\n </div>\n </div>\n )\n}\n","import { lazy, Suspense } from 'react'\nimport { Routes, Route, Navigate } from 'react-router-dom'\nimport Layout from './components/Layout'\n\n// 路由级代码分割:按需加载 page 组件,缩小主 bundle\nconst Dashboard = lazy(() => import('./pages/Dashboard'))\nconst Sessions = lazy(() => import('./pages/Sessions'))\nconst SessionDetail = lazy(() => import('./pages/SessionDetail'))\nconst Events = lazy(() => import('./pages/Events'))\nconst ExecutionTrace = lazy(() => import('./pages/ExecutionTrace'))\nconst Agents = lazy(() => import('./pages/Agents'))\nconst Skills = lazy(() => import('./pages/Skills'))\nconst Routing = lazy(() => import('./pages/Routing'))\nconst AIConfig = lazy(() => import('./pages/AIConfig'))\nconst Workflows = lazy(() => import('./pages/Workflows'))\nconst WorkflowDetail = lazy(() => import('./pages/WorkflowDetail'))\n\nfunction PageFallback() {\n return (\n <div className=\"flex items-center justify-center h-full py-16\">\n <div className=\"flex items-center gap-3 text-sm text-gray-500\">\n <div className=\"w-4 h-4 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin\" />\n 加载中...\n </div>\n </div>\n )\n}\n\nexport default function App() {\n return (\n <Routes>\n <Route path=\"/\" element={<Layout />}>\n <Route\n index\n element={<Navigate to=\"/dashboard\" replace />}\n />\n <Route\n path=\"dashboard\"\n element={\n <Suspense fallback={<PageFallback />}>\n <Dashboard />\n </Suspense>\n }\n />\n <Route\n path=\"sessions\"\n element={\n <Suspense fallback={<PageFallback />}>\n <Sessions />\n </Suspense>\n }\n />\n <Route\n path=\"sessions/:id\"\n element={\n <Suspense fallback={<PageFallback />}>\n <SessionDetail />\n </Suspense>\n }\n />\n <Route\n path=\"events\"\n element={\n <Suspense fallback={<PageFallback />}>\n <Events />\n </Suspense>\n }\n />\n <Route\n path=\"execution-trace\"\n element={\n <Suspense fallback={<PageFallback />}>\n <ExecutionTrace />\n </Suspense>\n }\n />\n <Route\n path=\"agents\"\n element={\n <Suspense fallback={<PageFallback />}>\n <Agents />\n </Suspense>\n }\n />\n <Route\n path=\"skills\"\n element={\n <Suspense fallback={<PageFallback />}>\n <Skills />\n </Suspense>\n }\n />\n <Route\n path=\"routing\"\n element={\n <Suspense fallback={<PageFallback />}>\n <Routing />\n </Suspense>\n }\n />\n <Route\n path=\"ai-config\"\n element={\n <Suspense fallback={<PageFallback />}>\n <AIConfig />\n </Suspense>\n }\n />\n <Route\n path=\"workflows\"\n element={\n <Suspense fallback={<PageFallback />}>\n <Workflows />\n </Suspense>\n }\n />\n <Route\n path=\"workflows/:routeRequestId\"\n element={\n <Suspense fallback={<PageFallback />}>\n <WorkflowDetail />\n </Suspense>\n }\n />\n </Route>\n </Routes>\n )\n}\n","import { createContext, useContext, useState, useCallback, ReactNode } from 'react'\nimport { CheckCircle, XCircle, AlertCircle, Info, X } from 'lucide-react'\nimport clsx from 'clsx'\n\ntype ToastType = 'success' | 'error' | 'warning' | 'info'\n\ninterface Toast {\n id: number\n type: ToastType\n message: string\n}\n\ninterface ToastContextValue {\n show: (type: ToastType, message: string) => void\n success: (message: string) => void\n error: (message: string) => void\n warning: (message: string) => void\n info: (message: string) => void\n}\n\nconst ToastContext = createContext<ToastContextValue | null>(null)\n\nexport function useToast() {\n const ctx = useContext(ToastContext)\n if (!ctx) throw new Error('useToast must be used within ToastProvider')\n return ctx\n}\n\nlet nextId = 1\n\nexport function ToastProvider({ children }: { children: ReactNode }) {\n const [toasts, setToasts] = useState<Toast[]>([])\n\n const remove = useCallback((id: number) => {\n setToasts(prev => prev.filter(t => t.id !== id))\n }, [])\n\n const show = useCallback((type: ToastType, message: string) => {\n const id = nextId++\n setToasts(prev => [...prev, { id, type, message }])\n setTimeout(() => remove(id), 4000)\n }, [remove])\n\n const value: ToastContextValue = {\n show,\n success: (msg) => show('success', msg),\n error: (msg) => show('error', msg),\n warning: (msg) => show('warning', msg),\n info: (msg) => show('info', msg),\n }\n\n return (\n <ToastContext.Provider value={value}>\n {children}\n <div className=\"fixed top-4 right-4 z-[9999] space-y-2 max-w-md\">\n {toasts.map(t => (\n <ToastItem key={t.id} toast={t} onClose={() => remove(t.id)} />\n ))}\n </div>\n </ToastContext.Provider>\n )\n}\n\nfunction ToastItem({ toast, onClose }: { toast: Toast; onClose: () => void }) {\n const icons = {\n success: <CheckCircle className=\"h-5 w-5 text-green-500\" />,\n error: <XCircle className=\"h-5 w-5 text-red-500\" />,\n warning: <AlertCircle className=\"h-5 w-5 text-yellow-500\" />,\n info: <Info className=\"h-5 w-5 text-blue-500\" />,\n }\n const borderColors = {\n success: 'border-green-200',\n error: 'border-red-200',\n warning: 'border-yellow-200',\n info: 'border-blue-200',\n }\n\n return (\n <div\n className={clsx(\n 'bg-white shadow-lg rounded-lg border px-4 py-3 flex items-start gap-3 animate-in slide-in-from-right',\n borderColors[toast.type]\n )}\n >\n {icons[toast.type]}\n <div className=\"flex-1 text-sm text-gray-800\">{toast.message}</div>\n <button onClick={onClose} className=\"text-gray-400 hover:text-gray-600\">\n <X className=\"h-4 w-4\" />\n </button>\n </div>\n )\n}\n","import { createContext, useContext, useState, useCallback, ReactNode } from 'react'\nimport { AlertTriangle } from 'lucide-react'\n\ninterface ConfirmOptions {\n title: string\n message: string\n confirmText?: string\n cancelText?: string\n variant?: 'danger' | 'warning' | 'info'\n}\n\ninterface ConfirmContextValue {\n confirm: (options: ConfirmOptions) => Promise<boolean>\n}\n\nconst ConfirmContext = createContext<ConfirmContextValue | null>(null)\n\nexport function useConfirm() {\n const ctx = useContext(ConfirmContext)\n if (!ctx) throw new Error('useConfirm must be used within ConfirmProvider')\n return ctx.confirm\n}\n\nexport function ConfirmProvider({ children }: { children: ReactNode }) {\n const [state, setState] = useState<{\n open: boolean\n options: ConfirmOptions | null\n resolve: ((value: boolean) => void) | null\n }>({ open: false, options: null, resolve: null })\n\n const confirm = useCallback((options: ConfirmOptions): Promise<boolean> => {\n return new Promise((resolve) => {\n setState({ open: true, options, resolve })\n })\n }, [])\n\n const handleClose = (result: boolean) => {\n if (state.resolve) state.resolve(result)\n setState({ open: false, options: null, resolve: null })\n }\n\n const variant = state.options?.variant || 'danger'\n const iconColor = {\n danger: 'text-red-600',\n warning: 'text-yellow-600',\n info: 'text-blue-600',\n }[variant]\n const btnColor = {\n danger: 'bg-red-600 hover:bg-red-700',\n warning: 'bg-yellow-600 hover:bg-yellow-700',\n info: 'bg-indigo-600 hover:bg-indigo-700',\n }[variant]\n\n return (\n <ConfirmContext.Provider value={{ confirm }}>\n {children}\n {state.open && state.options && (\n <div className=\"fixed inset-0 z-[9999] flex items-center justify-center\">\n <div\n className=\"absolute inset-0 bg-black bg-opacity-50\"\n onClick={() => handleClose(false)}\n />\n <div className=\"relative bg-white rounded-lg shadow-xl max-w-md w-full mx-4 p-6\">\n <div className=\"flex items-start gap-4\">\n <div className={`flex-shrink-0 ${iconColor}`}>\n <AlertTriangle className=\"h-6 w-6\" />\n </div>\n <div className=\"flex-1\">\n <h3 className=\"text-lg font-semibold text-gray-900 mb-2\">\n {state.options.title}\n </h3>\n <p className=\"text-sm text-gray-600 whitespace-pre-wrap\">\n {state.options.message}\n </p>\n </div>\n </div>\n <div className=\"flex justify-end gap-2 mt-6\">\n <button\n onClick={() => handleClose(false)}\n className=\"px-4 py-2 text-sm text-gray-700 bg-white border border-gray-300 rounded hover:bg-gray-50\"\n >\n {state.options.cancelText || '取消'}\n </button>\n <button\n onClick={() => handleClose(true)}\n className={`px-4 py-2 text-sm text-white rounded ${btnColor}`}\n >\n {state.options.confirmText || '确定'}\n </button>\n </div>\n </div>\n </div>\n )}\n </ConfirmContext.Provider>\n )\n}\n","import React from 'react'\nimport ReactDOM from 'react-dom/client'\nimport { BrowserRouter } from 'react-router-dom'\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query'\nimport App from './App'\nimport { ToastProvider } from './components/Toast'\nimport { ConfirmProvider } from './components/Confirm'\nimport './index.css'\n\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n refetchOnWindowFocus: false,\n retry: 1,\n },\n },\n})\n\nReactDOM.createRoot(document.getElementById('root')!).render(\n <React.StrictMode>\n <QueryClientProvider client={queryClient}>\n <ToastProvider>\n <ConfirmProvider>\n <BrowserRouter>\n <App />\n </BrowserRouter>\n </ConfirmProvider>\n </ToastProvider>\n </QueryClientProvider>\n </React.StrictMode>,\n)\n"],"file":"assets/index-Cgr9qMtq.js"}