@winspan/claude-forge 8.28.2 → 8.30.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 (111) hide show
  1. package/README.md +68 -215
  2. package/dist/capability/execution-manager.d.ts +59 -0
  3. package/dist/capability/execution-manager.d.ts.map +1 -0
  4. package/dist/capability/execution-manager.js +168 -0
  5. package/dist/capability/execution-manager.js.map +1 -0
  6. package/dist/capability/executor/background-executor.d.ts +57 -0
  7. package/dist/capability/executor/background-executor.d.ts.map +1 -0
  8. package/dist/capability/executor/background-executor.js +299 -0
  9. package/dist/capability/executor/background-executor.js.map +1 -0
  10. package/dist/capability/executor/foreground-executor.d.ts +26 -0
  11. package/dist/capability/executor/foreground-executor.d.ts.map +1 -0
  12. package/dist/capability/executor/foreground-executor.js +82 -0
  13. package/dist/capability/executor/foreground-executor.js.map +1 -0
  14. package/dist/capability/executor/orchestrator.d.ts +25 -0
  15. package/dist/capability/executor/orchestrator.d.ts.map +1 -0
  16. package/dist/capability/executor/orchestrator.js +79 -0
  17. package/dist/capability/executor/orchestrator.js.map +1 -0
  18. package/dist/capability/executor/stream-parser.d.ts +73 -0
  19. package/dist/capability/executor/stream-parser.d.ts.map +1 -0
  20. package/dist/capability/executor/stream-parser.js +56 -0
  21. package/dist/capability/executor/stream-parser.js.map +1 -0
  22. package/dist/capability/executor/types.d.ts +44 -0
  23. package/dist/capability/executor/types.d.ts.map +1 -0
  24. package/dist/capability/executor/types.js +9 -0
  25. package/dist/capability/executor/types.js.map +1 -0
  26. package/dist/capability/executor/worker-auth-probe.d.ts +30 -0
  27. package/dist/capability/executor/worker-auth-probe.d.ts.map +1 -0
  28. package/dist/capability/executor/worker-auth-probe.js +99 -0
  29. package/dist/capability/executor/worker-auth-probe.js.map +1 -0
  30. package/dist/capability/types.d.ts +10 -1
  31. package/dist/capability/types.d.ts.map +1 -1
  32. package/dist/core/storage/sqlite.d.ts +18 -0
  33. package/dist/core/storage/sqlite.d.ts.map +1 -1
  34. package/dist/core/storage/sqlite.js +75 -4
  35. package/dist/core/storage/sqlite.js.map +1 -1
  36. package/dist/daemon/handlers/methodology-formatter.d.ts +7 -0
  37. package/dist/daemon/handlers/methodology-formatter.d.ts.map +1 -1
  38. package/dist/daemon/handlers/methodology-formatter.js +46 -0
  39. package/dist/daemon/handlers/methodology-formatter.js.map +1 -1
  40. package/dist/daemon/handlers/stop.d.ts +6 -1
  41. package/dist/daemon/handlers/stop.d.ts.map +1 -1
  42. package/dist/daemon/handlers/stop.js +45 -1
  43. package/dist/daemon/handlers/stop.js.map +1 -1
  44. package/dist/daemon/handlers/user-prompt.d.ts.map +1 -1
  45. package/dist/daemon/handlers/user-prompt.js +34 -1
  46. package/dist/daemon/handlers/user-prompt.js.map +1 -1
  47. package/dist/daemon/index.d.ts.map +1 -1
  48. package/dist/daemon/index.js +20 -1
  49. package/dist/daemon/index.js.map +1 -1
  50. package/dist/daemon/methodology-pending-queue.d.ts +33 -0
  51. package/dist/daemon/methodology-pending-queue.d.ts.map +1 -0
  52. package/dist/daemon/methodology-pending-queue.js +120 -0
  53. package/dist/daemon/methodology-pending-queue.js.map +1 -0
  54. package/dist/web/server.d.ts +6 -0
  55. package/dist/web/server.d.ts.map +1 -1
  56. package/dist/web/server.js +127 -7
  57. package/dist/web/server.js.map +1 -1
  58. package/dist/web/static/assets/AIConfig-nZgwaowr.js +2 -0
  59. package/dist/web/static/assets/AIConfig-nZgwaowr.js.map +1 -0
  60. package/dist/web/static/assets/Agents-BZGXKWC7.js +2 -0
  61. package/dist/web/static/assets/Agents-BZGXKWC7.js.map +1 -0
  62. package/dist/web/static/assets/CodeBlock--H53gk46.js +2 -0
  63. package/dist/web/static/assets/CodeBlock--H53gk46.js.map +1 -0
  64. package/dist/web/static/assets/Dashboard-qUCxXFSI.js +2 -0
  65. package/dist/web/static/assets/Dashboard-qUCxXFSI.js.map +1 -0
  66. package/dist/web/static/assets/Drawer-DeKukfwJ.js +2 -0
  67. package/dist/web/static/assets/Drawer-DeKukfwJ.js.map +1 -0
  68. package/dist/web/static/assets/Events-CnA3f740.js +2 -0
  69. package/dist/web/static/assets/Events-CnA3f740.js.map +1 -0
  70. package/dist/web/static/assets/ExecutionTrace-ClPfFIQa.js +2 -0
  71. package/dist/web/static/assets/ExecutionTrace-ClPfFIQa.js.map +1 -0
  72. package/dist/web/static/assets/MarkdownRenderer-CCIz1MOz.js +2 -0
  73. package/dist/web/static/assets/MarkdownRenderer-CCIz1MOz.js.map +1 -0
  74. package/dist/web/static/assets/Methodologies-CAXUXeox.js +2 -0
  75. package/dist/web/static/assets/Methodologies-CAXUXeox.js.map +1 -0
  76. package/dist/web/static/assets/MethodologyDetail-Do1taSKM.js +2 -0
  77. package/dist/web/static/assets/MethodologyDetail-Do1taSKM.js.map +1 -0
  78. package/dist/web/static/assets/Routing-CFmM7JuB.js +2 -0
  79. package/dist/web/static/assets/Routing-CFmM7JuB.js.map +1 -0
  80. package/dist/web/static/assets/SessionDetail-DzTue2xK.js +2 -0
  81. package/dist/web/static/assets/SessionDetail-DzTue2xK.js.map +1 -0
  82. package/dist/web/static/assets/Sessions-DwWOKgnl.js +2 -0
  83. package/dist/web/static/assets/Sessions-DwWOKgnl.js.map +1 -0
  84. package/dist/web/static/assets/Skills-DhM6ALhr.js +2 -0
  85. package/dist/web/static/assets/Skills-DhM6ALhr.js.map +1 -0
  86. package/dist/web/static/assets/charts-CLrM0_uM.js +37 -0
  87. package/dist/web/static/assets/charts-CLrM0_uM.js.map +1 -0
  88. package/dist/web/static/assets/date-fns-CZ_bHujz.js +2 -0
  89. package/dist/web/static/assets/date-fns-CZ_bHujz.js.map +1 -0
  90. package/dist/web/static/assets/export-CEzDNM66.js +4 -0
  91. package/dist/web/static/assets/export-CEzDNM66.js.map +1 -0
  92. package/dist/web/static/assets/index-CVWult53.css +1 -0
  93. package/dist/web/static/assets/index-DUYj2ek1.js +3 -0
  94. package/dist/web/static/assets/index-DUYj2ek1.js.map +1 -0
  95. package/dist/web/static/assets/lucide-DjB4fWNj.js +227 -0
  96. package/dist/web/static/assets/lucide-DjB4fWNj.js.map +1 -0
  97. package/dist/web/static/assets/query-C99w429o.js +2 -0
  98. package/dist/web/static/assets/query-C99w429o.js.map +1 -0
  99. package/dist/web/static/assets/react-router-I-HqunH7.js +20 -0
  100. package/dist/web/static/assets/react-router-I-HqunH7.js.map +1 -0
  101. package/dist/web/static/assets/react-vendor-CSp-GLFF.js +49 -0
  102. package/dist/web/static/assets/react-vendor-CSp-GLFF.js.map +1 -0
  103. package/dist/web/static/assets/syntax-highlighter-44FakypI.js +9 -0
  104. package/dist/web/static/assets/syntax-highlighter-44FakypI.js.map +1 -0
  105. package/dist/web/static/assets/vendor-CMMjVdZs.js +64 -0
  106. package/dist/web/static/assets/vendor-CMMjVdZs.js.map +1 -0
  107. package/dist/web/static/index.html +8 -2
  108. package/package.json +1 -1
  109. package/dist/web/static/assets/index-CtylfoaN.css +0 -1
  110. package/dist/web/static/assets/index-DnaQt27h.js +0 -388
  111. package/dist/web/static/assets/index-DnaQt27h.js.map +0 -1
@@ -0,0 +1,2 @@
1
+ import{r as m,j as e}from"./react-vendor-CSp-GLFF.js";import{b as v,u as p,c as y}from"./query-C99w429o.js";import{u as w}from"./index-DUYj2ek1.js";import{C as N,E as k,w as _,e as C,d as P,q as S,Z as E,v as A}from"./lucide-DjB4fWNj.js";import"./react-router-I-HqunH7.js";import"./vendor-CMMjVdZs.js";import"./syntax-highlighter-44FakypI.js";async function I(){const a=await fetch("/api/config/ai");if(!a.ok)throw new Error("Failed to fetch config");return a.json()}async function F(a,i){const r=new URLSearchParams;a&&r.set("api_key",a),i&&r.set("base_url",i);const o=await fetch(`/api/ai/models?${r.toString()}`);return o.ok?(await o.json()).data||[]:[]}async function q(a){if(!(await fetch("/api/config/ai",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)})).ok)throw new Error("Failed to save config")}async function K(a){const i=await fetch("/api/ai/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),r=await i.json().catch(()=>({}));if(!i.ok)throw new Error(r.error||"Test failed");return r}function U(){const a=v(),i=w(),{data:r,isLoading:o}=p({queryKey:["ai-config"],queryFn:I}),[t,n]=m.useState({api_key:"",base_url:"",model:""}),[u,f]=m.useState(!1),[d,h]=m.useState(null);m.useEffect(()=>{r&&n(r)},[r]);const{data:l,refetch:b,isFetching:g}=p({queryKey:["ai-models",t.api_key,t.base_url],queryFn:()=>F(t.api_key,t.base_url),enabled:!!t.api_key&&!!t.base_url}),x=y({mutationFn:q,onSuccess:()=>{i.success("AI 配置已保存"),a.invalidateQueries({queryKey:["ai-config"]})},onError:s=>i.error(`保存失败: ${s.message}`)}),c=y({mutationFn:K,onSuccess:s=>{const j=(s==null?void 0:s.model)||t.model;h({ok:!0,message:`连接成功!模型: ${j}`}),i.success("API 连接测试通过")},onError:s=>{h({ok:!1,message:s.message}),i.error("API 连接测试失败")}});return o?e.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:"加载中..."}):e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-6",children:"AI 配置"}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-6 max-w-2xl",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-6",children:[e.jsx(N,{className:"h-5 w-5 text-indigo-600"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"Anthropic API 配置"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"API Key"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:u?"text":"password",value:t.api_key||"",onChange:s=>n({...t,api_key:s.target.value}),placeholder:"sk-...",className:"w-full px-3 py-2 pr-10 border border-gray-300 rounded-md text-sm font-mono"}),e.jsx("button",{type:"button",onClick:()=>f(!u),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:u?e.jsx(k,{className:"h-4 w-4"}):e.jsx(_,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Base URL"}),e.jsx("input",{type:"text",value:t.base_url||"",onChange:s=>n({...t,base_url:s.target.value}),placeholder:"https://api.anthropic.com",className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"主模型 (Distill / QualityGate)"}),e.jsx("button",{type:"button",onClick:()=>b(),disabled:!t.api_key||!t.base_url||g,className:"text-xs text-indigo-600 hover:text-indigo-700 disabled:text-gray-400",children:g?"加载中...":"🔄 刷新模型列表"})]}),l&&l.length>0?e.jsxs("select",{value:t.model||"",onChange:s=>n({...t,model:s.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm bg-white",children:[e.jsx("option",{value:"",children:"-- 选择模型 --"}),l.map(s=>e.jsxs("option",{value:s.id,children:[s.id," ",s.owned_by&&`(${s.owned_by})`]},s.id))]}):e.jsx("input",{type:"text",value:t.model||"",onChange:s=>n({...t,model:s.target.value}),placeholder:"claude-sonnet-4-6",className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:l&&l.length>0?`发现 ${l.length} 个可用模型`:"填入 API Key 和 Base URL 后可自动发现模型"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"分类器模型(可选,便宜+快的模型)"}),l&&l.length>0?e.jsxs("select",{value:t.classifier_model||"",onChange:s=>n({...t,classifier_model:s.target.value}),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm bg-white",children:[e.jsx("option",{value:"",children:"-- 不指定 (使用主模型) --"}),l.map(s=>e.jsx("option",{value:s.id,children:s.id},s.id))]}):e.jsx("input",{type:"text",value:t.classifier_model||"",onChange:s=>n({...t,classifier_model:s.target.value}),placeholder:"claude-haiku-4-5-20251001",className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"分类器超时 (ms)"}),e.jsx("input",{type:"number",value:t.classifier_timeout||1e4,onChange:s=>n({...t,classifier_timeout:parseInt(s.target.value)}),className:"w-full px-3 py-2 border border-gray-300 rounded-md text-sm"})]}),d&&e.jsxs("div",{className:`flex items-start gap-2 p-3 rounded text-sm ${d.ok?"bg-green-50 text-green-800":"bg-red-50 text-red-800"}`,children:[d.ok?e.jsx(C,{className:"h-4 w-4 flex-shrink-0 mt-0.5"}):e.jsx(P,{className:"h-4 w-4 flex-shrink-0 mt-0.5"}),e.jsx("div",{className:"flex-1 break-all",children:d.message})]}),e.jsx("div",{className:"flex items-center justify-end pt-4 border-t",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>c.mutate({api_key:t.api_key,base_url:t.base_url,model:t.model}),disabled:c.isPending||!t.api_key||!t.model,className:"inline-flex items-center gap-2 px-4 py-2 bg-gray-100 text-gray-700 text-sm font-medium rounded-md hover:bg-gray-200 disabled:bg-gray-50 disabled:text-gray-400",children:[c.isPending?e.jsx(S,{className:"h-4 w-4 animate-spin"}):e.jsx(E,{className:"h-4 w-4"}),c.isPending?"测试中...":"测试连接"]}),e.jsxs("button",{onClick:()=>x.mutate(t),disabled:x.isPending,className:"inline-flex items-center gap-2 px-4 py-2 bg-indigo-600 text-white text-sm font-medium rounded-md hover:bg-indigo-700 disabled:bg-gray-400",children:[e.jsx(A,{className:"h-4 w-4"}),x.isPending?"保存中...":"保存配置"]})]})})]})]})]})}export{U as default};
2
+ //# sourceMappingURL=AIConfig-nZgwaowr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AIConfig-nZgwaowr.js","sources":["../../src/pages/AIConfig.tsx"],"sourcesContent":["import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'\nimport { useState, useEffect } from 'react'\nimport { Save, Eye, EyeOff, Cpu, Zap, CheckCircle, XCircle, Loader2 } from 'lucide-react'\nimport { useToast } from '../components/Toast'\n\ninterface AIConfig {\n api_key: string\n base_url: string\n model: string\n provider?: string\n classifier_model?: string\n classifier_timeout?: number\n}\n\ninterface ModelOption {\n id: string\n owned_by?: string\n}\n\nasync function fetchConfig(): Promise<AIConfig> {\n const res = await fetch('/api/config/ai')\n if (!res.ok) throw new Error('Failed to fetch config')\n return res.json()\n}\n\nasync function fetchModels(api_key?: string, base_url?: string): Promise<ModelOption[]> {\n const params = new URLSearchParams()\n if (api_key) params.set('api_key', api_key)\n if (base_url) params.set('base_url', base_url)\n const res = await fetch(`/api/ai/models?${params.toString()}`)\n if (!res.ok) return []\n const data = await res.json()\n return data.data || []\n}\n\nasync function saveConfig(config: AIConfig): Promise<void> {\n const res = await fetch('/api/config/ai', {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(config),\n })\n if (!res.ok) throw new Error('Failed to save config')\n}\n\nasync function testConnection(config: { api_key: string; base_url: string; model: string }): Promise<any> {\n const res = await fetch('/api/ai/test', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(config),\n })\n const data = await res.json().catch(() => ({}))\n if (!res.ok) throw new Error(data.error || 'Test failed')\n return data\n}\n\nexport default function AIConfig() {\n const queryClient = useQueryClient()\n const toast = useToast()\n const { data: config, isLoading } = useQuery({\n queryKey: ['ai-config'],\n queryFn: fetchConfig,\n })\n\n const [form, setForm] = useState<AIConfig>({\n api_key: '',\n base_url: '',\n model: '',\n })\n const [showKey, setShowKey] = useState(false)\n const [testResult, setTestResult] = useState<{ ok: boolean; message: string } | null>(null)\n\n useEffect(() => {\n if (config) setForm(config)\n }, [config])\n\n const { data: models, refetch: refetchModels, isFetching: loadingModels } = useQuery({\n queryKey: ['ai-models', form.api_key, form.base_url],\n queryFn: () => fetchModels(form.api_key, form.base_url),\n enabled: !!form.api_key && !!form.base_url,\n })\n\n const saveMutation = useMutation({\n mutationFn: saveConfig,\n onSuccess: () => {\n toast.success('AI 配置已保存')\n queryClient.invalidateQueries({ queryKey: ['ai-config'] })\n },\n onError: (e: Error) => toast.error(`保存失败: ${e.message}`),\n })\n\n const testMutation = useMutation({\n mutationFn: testConnection,\n onSuccess: (data) => {\n const modelName = data?.model || form.model\n setTestResult({ ok: true, message: `连接成功!模型: ${modelName}` })\n toast.success('API 连接测试通过')\n },\n onError: (err: Error) => {\n setTestResult({ ok: false, message: err.message })\n toast.error('API 连接测试失败')\n },\n })\n\n if (isLoading) {\n return <div className=\"bg-white rounded-lg shadow p-6\">加载中...</div>\n }\n\n return (\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900 mb-6\">AI 配置</h1>\n\n <div className=\"bg-white rounded-lg shadow p-6 max-w-2xl\">\n <div className=\"flex items-center gap-2 mb-6\">\n <Cpu className=\"h-5 w-5 text-indigo-600\" />\n <h3 className=\"text-lg font-semibold text-gray-900\">Anthropic API 配置</h3>\n </div>\n\n <div className=\"space-y-4\">\n <div>\n <label className=\"block text-sm font-medium text-gray-700 mb-1\">API Key</label>\n <div className=\"relative\">\n <input\n type={showKey ? 'text' : 'password'}\n value={form.api_key || ''}\n onChange={(e) => setForm({ ...form, api_key: e.target.value })}\n placeholder=\"sk-...\"\n className=\"w-full px-3 py-2 pr-10 border border-gray-300 rounded-md text-sm font-mono\"\n />\n <button\n type=\"button\"\n onClick={() => setShowKey(!showKey)}\n className=\"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600\"\n >\n {showKey ? <EyeOff className=\"h-4 w-4\" /> : <Eye className=\"h-4 w-4\" />}\n </button>\n </div>\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 mb-1\">Base URL</label>\n <input\n type=\"text\"\n value={form.base_url || ''}\n onChange={(e) => setForm({ ...form, base_url: e.target.value })}\n placeholder=\"https://api.anthropic.com\"\n className=\"w-full px-3 py-2 border border-gray-300 rounded-md text-sm\"\n />\n </div>\n\n <div>\n <div className=\"flex items-center justify-between mb-1\">\n <label className=\"block text-sm font-medium text-gray-700\">主模型 (Distill / QualityGate)</label>\n <button\n type=\"button\"\n onClick={() => refetchModels()}\n disabled={!form.api_key || !form.base_url || loadingModels}\n className=\"text-xs text-indigo-600 hover:text-indigo-700 disabled:text-gray-400\"\n >\n {loadingModels ? '加载中...' : '🔄 刷新模型列表'}\n </button>\n </div>\n {models && models.length > 0 ? (\n <select\n value={form.model || ''}\n onChange={(e) => setForm({ ...form, model: e.target.value })}\n className=\"w-full px-3 py-2 border border-gray-300 rounded-md text-sm bg-white\"\n >\n <option value=\"\">-- 选择模型 --</option>\n {models.map((m) => (\n <option key={m.id} value={m.id}>\n {m.id} {m.owned_by && `(${m.owned_by})`}\n </option>\n ))}\n </select>\n ) : (\n <input\n type=\"text\"\n value={form.model || ''}\n onChange={(e) => setForm({ ...form, model: e.target.value })}\n placeholder=\"claude-sonnet-4-6\"\n className=\"w-full px-3 py-2 border border-gray-300 rounded-md text-sm\"\n />\n )}\n <p className=\"text-xs text-gray-500 mt-1\">\n {models && models.length > 0\n ? `发现 ${models.length} 个可用模型`\n : '填入 API Key 和 Base URL 后可自动发现模型'}\n </p>\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 mb-1\">分类器模型(可选,便宜+快的模型)</label>\n {models && models.length > 0 ? (\n <select\n value={form.classifier_model || ''}\n onChange={(e) => setForm({ ...form, classifier_model: e.target.value })}\n className=\"w-full px-3 py-2 border border-gray-300 rounded-md text-sm bg-white\"\n >\n <option value=\"\">-- 不指定 (使用主模型) --</option>\n {models.map((m) => (\n <option key={m.id} value={m.id}>{m.id}</option>\n ))}\n </select>\n ) : (\n <input\n type=\"text\"\n value={form.classifier_model || ''}\n onChange={(e) => setForm({ ...form, classifier_model: e.target.value })}\n placeholder=\"claude-haiku-4-5-20251001\"\n className=\"w-full px-3 py-2 border border-gray-300 rounded-md text-sm\"\n />\n )}\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-700 mb-1\">分类器超时 (ms)</label>\n <input\n type=\"number\"\n value={form.classifier_timeout || 10000}\n onChange={(e) => setForm({ ...form, classifier_timeout: parseInt(e.target.value) })}\n className=\"w-full px-3 py-2 border border-gray-300 rounded-md text-sm\"\n />\n </div>\n\n {/* Test result */}\n {testResult && (\n <div className={`flex items-start gap-2 p-3 rounded text-sm ${\n testResult.ok ? 'bg-green-50 text-green-800' : 'bg-red-50 text-red-800'\n }`}>\n {testResult.ok ? (\n <CheckCircle className=\"h-4 w-4 flex-shrink-0 mt-0.5\" />\n ) : (\n <XCircle className=\"h-4 w-4 flex-shrink-0 mt-0.5\" />\n )}\n <div className=\"flex-1 break-all\">{testResult.message}</div>\n </div>\n )}\n\n <div className=\"flex items-center justify-end pt-4 border-t\">\n <div className=\"flex items-center gap-2\">\n <button\n onClick={() => testMutation.mutate({ api_key: form.api_key, base_url: form.base_url, model: form.model })}\n disabled={testMutation.isPending || !form.api_key || !form.model}\n className=\"inline-flex items-center gap-2 px-4 py-2 bg-gray-100 text-gray-700 text-sm font-medium rounded-md hover:bg-gray-200 disabled:bg-gray-50 disabled:text-gray-400\"\n >\n {testMutation.isPending ? (\n <Loader2 className=\"h-4 w-4 animate-spin\" />\n ) : (\n <Zap className=\"h-4 w-4\" />\n )}\n {testMutation.isPending ? '测试中...' : '测试连接'}\n </button>\n <button\n onClick={() => saveMutation.mutate(form)}\n disabled={saveMutation.isPending}\n className=\"inline-flex items-center gap-2 px-4 py-2 bg-indigo-600 text-white text-sm font-medium rounded-md hover:bg-indigo-700 disabled:bg-gray-400\"\n >\n <Save className=\"h-4 w-4\" />\n {saveMutation.isPending ? '保存中...' : '保存配置'}\n </button>\n </div>\n </div>\n </div>\n </div>\n </div>\n )\n}\n"],"names":["fetchConfig","res","fetchModels","api_key","base_url","params","saveConfig","config","testConnection","data","AIConfig","queryClient","useQueryClient","toast","useToast","isLoading","useQuery","form","setForm","useState","showKey","setShowKey","testResult","setTestResult","useEffect","models","refetchModels","loadingModels","saveMutation","useMutation","e","testMutation","modelName","err","jsx","jsxs","Cpu","EyeOff","Eye","m","CheckCircle","XCircle","Loader2","Zap","Save"],"mappings":"uVAmBA,eAAeA,GAAiC,CAC9C,MAAMC,EAAM,MAAM,MAAM,gBAAgB,EACxC,GAAI,CAACA,EAAI,GAAI,MAAM,IAAI,MAAM,wBAAwB,EACrD,OAAOA,EAAI,KAAA,CACb,CAEA,eAAeC,EAAYC,EAAkBC,EAA2C,CACtF,MAAMC,EAAS,IAAI,gBACfF,GAASE,EAAO,IAAI,UAAWF,CAAO,EACtCC,GAAUC,EAAO,IAAI,WAAYD,CAAQ,EAC7C,MAAMH,EAAM,MAAM,MAAM,kBAAkBI,EAAO,SAAA,CAAU,EAAE,EAC7D,OAAKJ,EAAI,IACI,MAAMA,EAAI,KAAA,GACX,MAAQ,CAAA,EAFA,CAAA,CAGtB,CAEA,eAAeK,EAAWC,EAAiC,CAMzD,GAAI,EALQ,MAAM,MAAM,iBAAkB,CACxC,OAAQ,MACR,QAAS,CAAE,eAAgB,kBAAA,EAC3B,KAAM,KAAK,UAAUA,CAAM,CAAA,CAC5B,GACQ,GAAI,MAAM,IAAI,MAAM,uBAAuB,CACtD,CAEA,eAAeC,EAAeD,EAA4E,CACxG,MAAMN,EAAM,MAAM,MAAM,eAAgB,CACtC,OAAQ,OACR,QAAS,CAAE,eAAgB,kBAAA,EAC3B,KAAM,KAAK,UAAUM,CAAM,CAAA,CAC5B,EACKE,EAAO,MAAMR,EAAI,KAAA,EAAO,MAAM,KAAO,CAAA,EAAG,EAC9C,GAAI,CAACA,EAAI,GAAI,MAAM,IAAI,MAAMQ,EAAK,OAAS,aAAa,EACxD,OAAOA,CACT,CAEA,SAAwBC,GAAW,CACjC,MAAMC,EAAcC,EAAA,EACdC,EAAQC,EAAA,EACR,CAAE,KAAMP,EAAQ,UAAAQ,CAAA,EAAcC,EAAS,CAC3C,SAAU,CAAC,WAAW,EACtB,QAA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EAEvCI,EAAAA,KAAC,SAAA,CACC,QAAS,IAAMP,EAAa,OAAOX,CAAI,EACvC,SAAUW,EAAa,UACvB,UAAU,4IAEV,SAAA,CAAAM,EAAAA,IAACU,EAAA,CAAK,UAAU,SAAA,CAAU,EACzBhB,EAAa,UAAY,SAAW,MAAA,CAAA,CAAA,CACvC,CAAA,CACF,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAAA,EACF,CAEJ"}
@@ -0,0 +1,2 @@
1
+ import{r as d,j as e}from"./react-vendor-CSp-GLFF.js";import{b as v,u as p,c as N}from"./query-C99w429o.js";import{D as w}from"./Drawer-DeKukfwJ.js";import{M as b}from"./MarkdownRenderer-CCIz1MOz.js";import{u as A}from"./index-DUYj2ek1.js";import{B as j,t as C,u as k,X as E,v as F}from"./lucide-DjB4fWNj.js";import"./vendor-CMMjVdZs.js";import"./syntax-highlighter-44FakypI.js";import"./react-router-I-HqunH7.js";async function q(){const n=await fetch("/api/agents");if(!n.ok)throw new Error("Failed to fetch agents");const a=await n.json();return Array.isArray(a)?a:[...a.official||[],...a.user||[]]}async function S(n){const a=await fetch(`/api/agents/${n}`);if(!a.ok)throw new Error("Failed to fetch");return a.json()}async function K(n,a){if(!(await fetch(`/api/agents/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:a})})).ok)throw new Error("Failed to save")}function L(){const n=v(),a=A(),{data:r,isLoading:y}=p({queryKey:["agents"],queryFn:q}),[l,m]=d.useState(null),[g,c]=d.useState(!1),[h,x]=d.useState(""),{data:t}=p({queryKey:["agent-detail",l],queryFn:()=>S(l),enabled:!!l});d.useEffect(()=>{t!=null&&t.content&&x(t.content),c(!1)},[t]);const o=N({mutationFn:s=>K(s.name,s.content),onSuccess:()=>{a.success("Agent 已保存"),c(!1),n.invalidateQueries({queryKey:["agent-detail",l]}),n.invalidateQueries({queryKey:["agents"]})},onError:s=>a.error(`保存失败: ${s.message}`)}),u=s=>s?typeof s=="string"?s.split(",").map(i=>i.trim()):s:[];return y?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:"Agent 管理"}),e.jsxs("div",{className:"text-sm text-gray-500",children:["共 ",(r==null?void 0:r.length)||0," 个 Agent"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:r==null?void 0:r.map(s=>{const i=u(s.tools);return e.jsxs("div",{className:"bg-white rounded-lg shadow p-5 hover:shadow-md transition-shadow cursor-pointer",onClick:()=>m(s.name),children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-indigo-100 flex items-center justify-center flex-shrink-0",children:e.jsx(j,{className:"h-5 w-5 text-indigo-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-gray-900 truncate",children:s.name}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 line-clamp-2",children:s.description||"(无描述)"})]})]}),i.length>0&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-100",children:[e.jsxs("div",{className:"flex items-center gap-1 text-xs text-gray-500 mb-2",children:[e.jsx(C,{className:"h-3 w-3"}),"可用工具 (",i.length,")"]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[i.slice(0,5).map(f=>e.jsx("span",{className:"px-2 py-0.5 text-xs bg-gray-100 text-gray-700 rounded",children:f},f)),i.length>5&&e.jsxs("span",{className:"text-xs text-gray-400",children:["+",i.length-5]})]})]})]},s.name)})}),e.jsx(w,{open:l!==null,onClose:()=>{m(null),c(!1)},title:`Agent: ${l}`,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(j,{className:"h-5 w-5 text-indigo-600"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:t.name}),t.version&&e.jsxs("span",{className:"text-xs text-gray-500",children:["v",t.version]})]}),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})]}),t.tools&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"可用工具"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:u(t.tools).map(s=>e.jsx("span",{className:"px-2 py-0.5 text-xs bg-gray-100 text-gray-700 rounded",children:s},s))})]}),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:g?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{c(!1),x(t.content||"")},className:"inline-flex items-center gap-1 text-xs text-gray-600 hover:text-gray-700",children:[e.jsx(E,{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(F,{className:"h-3 w-3"}),o.isPending?"保存中...":"保存"]})]}):e.jsxs("button",{onClick:()=>c(!0),className:"inline-flex items-center gap-1 text-xs text-indigo-600 hover:text-indigo-700",children:[e.jsx(k,{className:"h-3 w-3"}),"编辑"]})})]}),g?e.jsx("textarea",{value:h,onChange:s=>x(s.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(b,{content:t.content||""})}),o.isError&&e.jsxs("div",{className:"text-xs text-red-600 mt-1",children:["保存失败:",o.error.message]})]})]})})]})}export{L as default};
2
+ //# sourceMappingURL=Agents-BZGXKWC7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Agents-BZGXKWC7.js","sources":["../../src/pages/Agents.tsx"],"sourcesContent":["import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'\nimport { useState, useEffect } from 'react'\nimport { Bot, FileCode, Edit2, Save, X } from 'lucide-react'\nimport Drawer from '../components/Drawer'\nimport MarkdownRenderer from '../components/MarkdownRenderer'\nimport { useToast } from '../components/Toast'\n\ninterface Agent {\n name: string\n description: string\n tools?: string | string[]\n content?: string\n version?: string\n category?: string\n source?: string\n}\n\ninterface AgentsResponse {\n official?: Agent[]\n user?: Agent[]\n}\n\nasync function fetchAgents(): Promise<Agent[]> {\n const res = await fetch('/api/agents')\n if (!res.ok) throw new Error('Failed to fetch agents')\n const data: AgentsResponse | Agent[] = await res.json()\n // API 可能返回 { official: [...], user: [...] } 或直接返回数组\n if (Array.isArray(data)) return data\n return [...(data.official || []), ...(data.user || [])]\n}\n\nasync function fetchAgentDetail(name: string): Promise<Agent> {\n const res = await fetch(`/api/agents/${name}`)\n if (!res.ok) throw new Error('Failed to fetch')\n return res.json()\n}\n\nasync function saveAgent(name: string, content: string): Promise<void> {\n const res = await fetch(`/api/agents/${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 Agents() {\n const queryClient = useQueryClient()\n const toast = useToast()\n const { data: agents, isLoading } = useQuery({\n queryKey: ['agents'],\n queryFn: fetchAgents,\n })\n\n const [selectedAgent, setSelectedAgent] = useState<string | null>(null)\n const [editing, setEditing] = useState(false)\n const [editContent, setEditContent] = useState('')\n\n const { data: detail } = useQuery({\n queryKey: ['agent-detail', selectedAgent],\n queryFn: () => fetchAgentDetail(selectedAgent!),\n enabled: !!selectedAgent,\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 }) => saveAgent(vars.name, vars.content),\n onSuccess: () => {\n toast.success('Agent 已保存')\n setEditing(false)\n queryClient.invalidateQueries({ queryKey: ['agent-detail', selectedAgent] })\n queryClient.invalidateQueries({ queryKey: ['agents'] })\n },\n onError: (e: Error) => toast.error(`保存失败: ${e.message}`),\n })\n\n const renderTools = (tools?: string | string[]) => {\n if (!tools) return []\n if (typeof tools === 'string') return tools.split(',').map(t => t.trim())\n return tools\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\">Agent 管理</h1>\n <div className=\"text-sm text-gray-500\">共 {agents?.length || 0} 个 Agent</div>\n </div>\n\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4\">\n {agents?.map((agent) => {\n const tools = renderTools(agent.tools)\n return (\n <div\n key={agent.name}\n className=\"bg-white rounded-lg shadow p-5 hover:shadow-md transition-shadow cursor-pointer\"\n onClick={() => setSelectedAgent(agent.name)}\n >\n <div className=\"flex items-start gap-3 mb-3\">\n <div className=\"w-10 h-10 rounded-lg bg-indigo-100 flex items-center justify-center flex-shrink-0\">\n <Bot className=\"h-5 w-5 text-indigo-600\" />\n </div>\n <div className=\"flex-1 min-w-0\">\n <h3 className=\"font-semibold text-gray-900 truncate\">{agent.name}</h3>\n <p className=\"text-xs text-gray-500 mt-1 line-clamp-2\">\n {agent.description || '(无描述)'}\n </p>\n </div>\n </div>\n\n {tools.length > 0 && (\n <div className=\"mt-3 pt-3 border-t border-gray-100\">\n <div className=\"flex items-center gap-1 text-xs text-gray-500 mb-2\">\n <FileCode className=\"h-3 w-3\" />可用工具 ({tools.length})\n </div>\n <div className=\"flex flex-wrap gap-1\">\n {tools.slice(0, 5).map((tool) => (\n <span key={tool} className=\"px-2 py-0.5 text-xs bg-gray-100 text-gray-700 rounded\">\n {tool}\n </span>\n ))}\n {tools.length > 5 && (\n <span className=\"text-xs text-gray-400\">+{tools.length - 5}</span>\n )}\n </div>\n </div>\n )}\n </div>\n )\n })}\n </div>\n\n {/* Agent Detail Drawer */}\n <Drawer\n open={selectedAgent !== null}\n onClose={() => { setSelectedAgent(null); setEditing(false) }}\n title={`Agent: ${selectedAgent}`}\n width=\"w-[800px]\"\n >\n {detail && (\n <div className=\"space-y-4\">\n <div className=\"flex items-center gap-2 mb-2\">\n <Bot className=\"h-5 w-5 text-indigo-600\" />\n <h3 className=\"text-lg font-semibold text-gray-900\">{detail.name}</h3>\n {detail.version && (\n <span className=\"text-xs text-gray-500\">v{detail.version}</span>\n )}\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 {detail.tools && (\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">可用工具</div>\n <div className=\"flex flex-wrap gap-1\">\n {renderTools(detail.tools).map(tool => (\n <span key={tool} className=\"px-2 py-0.5 text-xs bg-gray-100 text-gray-700 rounded\">\n {tool}\n </span>\n ))}\n </div>\n </div>\n )}\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":["fetchAgents","res","data","fetchAgentDetail","name","saveAgent","content","Agents","queryClient","useQueryClient","toast","useToast","agents","isLoading","useQuery","selectedAgent","setSelectedAgent","useState","editing","setEditing","editContent","setEditContent","detail","useEffect","mutation","useMutation","vars","e","renderTools","tools","t","jsx","jsxs","agent","Bot","FileCode","tool","Drawer","Fragment","X","Save","Edit2","MarkdownRenderer"],"mappings":"8ZAsBA,eAAeA,GAAgC,CAC7C,MAAMC,EAAM,MAAM,MAAM,aAAa,EACrC,GAAI,CAACA,EAAI,GAAI,MAAM,IAAI,MAAM,wBAAwB,EACrD,MAAMC,EAAiC,MAAMD,EAAI,KAAA,EAEjD,OAAI,MAAM,QAAQC,CAAI,EAAUA,EACzB,CAAC,GAAIA,EAAK,UAAY,CAAA,EAAK,GAAIA,EAAK,MAAQ,EAAG,CACxD,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,MAAM,MAAM,eAAeF,CAAI,GAAI,CAC7C,OAAQ,MACR,QAAS,CAAE,eAAgB,kBAAA,EAC3B,KAAM,KAA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,SAACb,EAQAc,EAAAA,KAAAM,WAAA,CACE,SAAA,CAAAN,EAAAA,KAAC,SAAA,CACC,QAAS,IAAM,CAAEb,EAAW,EAAK,EAAGE,EAAeC,EAAO,SAAW,EAAE,CAAE,EACzE,UAAU,2EAEV,SAAA,CAAAS,EAAAA,IAACQ,EAAA,CAAE,UAAU,SAAA,CAAU,EAAE,IAAA,CAAA,CAAA,EAE3BP,EAAAA,KAAC,SAAA,CACC,QAAS,IAAMR,EAAS,OAAO,CAAE,KAAMF,EAAO,KAAM,QAASF,EAAa,EAC1E,SAAUI,EAAS,UACnB,UAAU,6HAEV,SAAA,CAAAO,EAAAA,IAACS,EAAA,CAAK,UAAU,SAAA,CAAU,EACzBhB,EAAS,UAAY,SAAW,IAAA,CAAA,CAAA,CACnC,CAAA,CACF,EAtBAQ,EAAAA,KAAC,SAAA,CACC,QAAS,IAAMb,EAAW,EAAI,EAC9B,UAAU,+EAEV,SAAA,CAAAY,EAAAA,IAACU,EAAA,CAAM,UAAU,SAAA,CAAU,EAAE,IAAA,CAAA,CAAA,CAkB/B,CAEJ,CAAA,EACF,EACCvB,EACCa,EAAAA,IAAC,WAAA,CACC,MAAOX,EACP,SAAWO,GAAMN,EAAeM,EAAE,OAAO,KAAK,EAC9C,UAAU,oHACV,KAAM,EAAA,CAAA,EAGRI,EAAAA,IAAC,MAAA,CAAI,UAAU,4EACb,SAAAA,EAAAA,IAACW,EAAA,CAAiB,QAASpB,EAAO,SAAW,EAAA,CAAI,CAAA,CACnD,EAEDE,EAAS,SACRQ,OAAC,MAAA,CAAI,UAAU,4BAA4B,SAAA,CAAA,QAAOR,EAAS,MAAgB,OAAA,CAAA,CAAQ,CAAA,CAAA,CAEvF,CAAA,CAAA,CACF,CAAA,CAAA,CAEJ,EACF,CAEJ"}
@@ -0,0 +1,2 @@
1
+ import{j as n}from"./react-vendor-CSp-GLFF.js";import{h as i,o as s}from"./syntax-highlighter-44FakypI.js";function c({data:o,language:e="json",maxHeight:t="400px"}){const r=typeof o=="string"?o:JSON.stringify(o,null,2);return n.jsx("div",{className:"rounded overflow-hidden",style:{maxHeight:t,overflowY:"auto"},children:n.jsx(i,{language:e,style:s,customStyle:{margin:0,fontSize:"12px",padding:"12px",background:"#f9fafb"},children:r})})}export{c as C};
2
+ //# sourceMappingURL=CodeBlock--H53gk46.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeBlock--H53gk46.js","sources":["../../src/components/CodeBlock.tsx"],"sourcesContent":["import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'\nimport { oneLight } from 'react-syntax-highlighter/dist/esm/styles/prism'\n\ninterface Props {\n data: any\n language?: string\n maxHeight?: string\n}\n\nexport default function CodeBlock({ data, language = 'json', maxHeight = '400px' }: Props) {\n const content = typeof data === 'string'\n ? data\n : JSON.stringify(data, null, 2)\n\n return (\n <div className=\"rounded overflow-hidden\" style={{ maxHeight, overflowY: 'auto' }}>\n <SyntaxHighlighter\n language={language}\n style={oneLight}\n customStyle={{\n margin: 0,\n fontSize: '12px',\n padding: '12px',\n background: '#f9fafb',\n }}\n >\n {content}\n </SyntaxHighlighter>\n </div>\n )\n}\n"],"names":["CodeBlock","data","language","maxHeight","content","jsx","SyntaxHighlighter","oneLight"],"mappings":"2GASA,SAAwBA,EAAU,CAAE,KAAAC,EAAM,SAAAC,EAAW,OAAQ,UAAAC,EAAY,SAAkB,CACzF,MAAMC,EAAU,OAAOH,GAAS,SAC5BA,EACA,KAAK,UAAUA,EAAM,KAAM,CAAC,EAEhC,OACEI,MAAC,OAAI,UAAU,0BAA0B,MAAO,CAAE,UAAAF,EAAW,UAAW,MAAA,EACtE,SAAAE,EAAAA,IAACC,EAAA,CACC,SAAAJ,EACA,MAAOK,EACP,YAAa,CACX,OAAQ,EACR,SAAU,OACV,QAAS,OACT,WAAY,SAAA,EAGb,SAAAH,CAAA,CAAA,EAEL,CAEJ"}
@@ -0,0 +1,2 @@
1
+ import{j as e}from"./react-vendor-CSp-GLFF.js";import{u as d}from"./query-C99w429o.js";import{b as w}from"./react-router-I-HqunH7.js";import{A as C,a as k,G as L,Z as $,g as q}from"./lucide-DjB4fWNj.js";import{R as m,A as R,C as j,X as g,Y as y,T as u,a as F,B as K,b as A,P as S,c as D,d as M,L as O}from"./charts-CLrM0_uM.js";import"./vendor-CMMjVdZs.js";async function E(){const s=await fetch("/api/status");if(!s.ok)throw new Error("Failed");return s.json()}async function P(){const s=await fetch("/api/stats");if(!s.ok)throw new Error("Failed");return s.json()}async function U(){const s=await fetch("/api/sessions?limit=1000");return s.ok?(await s.json()).length:0}async function B(){const s=await fetch("/api/routing/stats?window=168");return s.ok?s.json():null}async function I(){const s=await fetch("/api/methodology-executions?limit=1000");return s.ok?(await s.json()).length:0}function z(s){const t=Math.floor(s/86400),a=Math.floor(s%86400/3600),l=Math.floor(s%3600/60);return t>0?`${t}天 ${a}小时`:a>0?`${a}小时 ${l}分钟`:`${l}分钟`}const r={primary:"#6366f1",green:"#10b981",red:"#ef4444",yellow:"#f59e0b",blue:"#3b82f6",purple:"#8b5cf6"},b=[r.primary,r.green,r.yellow,r.red,r.purple,r.blue];function Q(){var f;const s=w(),{data:t}=d({queryKey:["status"],queryFn:E,refetchInterval:5e3}),{data:a}=d({queryKey:["system-stats"],queryFn:P,refetchInterval:3e4}),{data:l}=d({queryKey:["sessions-count"],queryFn:U}),{data:n}=d({queryKey:["dashboard-routing"],queryFn:B}),{data:c}=d({queryKey:["methodology-count"],queryFn:I}),p=(n==null?void 0:n.obedienceRate)!==null&&(n==null?void 0:n.obedienceRate)!==void 0?(n.obedienceRate*100).toFixed(0):"-",v=a!=null&&a.toolUsage?Object.entries(a.toolUsage).sort(([,i],[,o])=>o-i).slice(0,8).map(([i,o])=>({name:i,count:o})):[],h=a!=null&&a.decisionLevels?[{name:"允许",value:a.decisionLevels.allow,fill:r.green},{name:"警告",value:a.decisionLevels.warn,fill:r.yellow},{name:"阻断",value:a.decisionLevels.block,fill:r.red},{name:"确认",value:a.decisionLevels.confirm,fill:r.blue}].filter(i=>i.value>0):[],N=(a==null?void 0:a.dailyActivity)||[];return e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-6",children:"仪表盘"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-6",children:[e.jsx(x,{icon:C,label:"总事件",value:((f=t==null?void 0:t.eventCount)==null?void 0:f.toString())||"-",color:"blue",onClick:()=>s("/events")}),e.jsx(x,{icon:k,label:"会话数",value:(l==null?void 0:l.toString())||"-",color:"purple",onClick:()=>s("/sessions")}),e.jsx(x,{icon:L,label:"方法论执行",value:(c==null?void 0:c.toString())||"-",color:"indigo",onClick:()=>s("/methodologies")}),e.jsx(x,{icon:$,label:"路由遵守率",value:`${p}%`,color:"green",onClick:()=>s("/routing")})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"最近 7 天活动"}),e.jsx("button",{onClick:()=>s("/events"),className:"text-xs text-indigo-600 hover:text-indigo-700",children:"查看全部事件 →"})]}),e.jsx(m,{width:"100%",height:240,children:e.jsxs(R,{data:N,onClick:()=>s("/events"),style:{cursor:"pointer"},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"colorEvents",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:r.primary,stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:r.primary,stopOpacity:0})]})}),e.jsx(j,{strokeDasharray:"3 3",stroke:"#f3f4f6"}),e.jsx(g,{dataKey:"date",tick:{fontSize:11},tickFormatter:i=>i==null?void 0:i.slice(5)}),e.jsx(y,{tick:{fontSize:11}}),e.jsx(u,{}),e.jsx(F,{type:"monotone",dataKey:"eventCount",stroke:r.primary,strokeWidth:2,fill:"url(#colorEvents)",name:"事件"})]})})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"工具使用分布"}),e.jsx("button",{onClick:()=>s("/events"),className:"text-xs text-indigo-600 hover:text-indigo-700",children:"查看详情 →"})]}),e.jsx(m,{width:"100%",height:240,children:e.jsxs(K,{data:v,layout:"vertical",onClick:i=>{i!=null&&i.activeLabel&&s(`/events?tool=${encodeURIComponent(i.activeLabel)}`)},style:{cursor:"pointer"},children:[e.jsx(j,{strokeDasharray:"3 3",stroke:"#f3f4f6"}),e.jsx(g,{type:"number",tick:{fontSize:11}}),e.jsx(y,{dataKey:"name",type:"category",tick:{fontSize:11},width:80}),e.jsx(u,{}),e.jsx(A,{dataKey:"count",fill:r.primary,radius:[0,4,4,0]})]})})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:"治理决策分布"}),e.jsx("button",{onClick:()=>s("/execution-trace"),className:"text-xs text-indigo-600 hover:text-indigo-700",children:"查看追踪 →"})]}),h.length>0?e.jsx(m,{width:"100%",height:240,children:e.jsxs(S,{children:[e.jsx(D,{data:h,cx:"50%",cy:"50%",labelLine:!1,label:i=>`${i.name}: ${i.value}`,outerRadius:80,dataKey:"value",style:{cursor:"pointer"},onClick:()=>s("/execution-trace"),children:h.map((i,o)=>e.jsx(M,{fill:b[o%b.length]},o))}),e.jsx(u,{}),e.jsx(O,{})]})}):e.jsx("div",{className:"h-60 flex items-center justify-center text-gray-400 text-sm",children:"暂无决策数据"})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-base font-semibold text-gray-900 mb-4",children:[e.jsx(q,{className:"h-4 w-4 text-indigo-600"}),"系统状态"]}),e.jsxs("dl",{className:"space-y-3 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-gray-500",children:"PID"}),e.jsx("dd",{className:"font-mono text-gray-900",children:(t==null?void 0:t.pid)||"-"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-gray-500",children:"运行时间"}),e.jsx("dd",{className:"text-gray-900",children:t!=null&&t.uptime?z(t.uptime):"-"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-gray-500",children:"内存使用"}),e.jsx("dd",{className:"text-gray-900",children:t!=null&&t.memory?`${Math.round(t.memory.heapUsed/1024/1024)} MB`:"-"})]}),n&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t pt-3 mt-3",children:e.jsx("dt",{className:"text-xs font-semibold text-gray-700 mb-2",children:"路由 (近 7 天)"})}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-gray-500",children:"总路由"}),e.jsx("dd",{className:"font-mono text-gray-900",children:n.total})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-gray-500",children:"遵守 / 违抗"}),e.jsxs("dd",{className:"font-mono",children:[e.jsx("span",{className:"text-green-600",children:n.obeyedCount}),e.jsx("span",{className:"text-gray-400 mx-1",children:"/"}),e.jsx("span",{className:"text-red-600",children:n.refusedCount})]})]})]})]})]})]})]})}function x({icon:s,label:t,value:a,color:l,onClick:n}){const c={blue:"bg-blue-100 text-blue-600",purple:"bg-purple-100 text-purple-600",indigo:"bg-indigo-100 text-indigo-600",green:"bg-green-100 text-green-600"};return e.jsxs("div",{className:`bg-white rounded-lg shadow p-5 ${n?"cursor-pointer hover:shadow-md transition-shadow":""}`,onClick:n,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-sm text-gray-500",children:t}),e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${c[l]}`,children:e.jsx(s,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"text-2xl font-bold text-gray-900",children:a})]})}export{Q as default};
2
+ //# sourceMappingURL=Dashboard-qUCxXFSI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dashboard-qUCxXFSI.js","sources":["../../src/pages/Dashboard.tsx"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\nimport { useNavigate } from 'react-router-dom'\nimport { Activity, MessageSquare, GitBranch, Clock, Zap } from 'lucide-react'\nimport {\n AreaChart, Area, BarChart, Bar, PieChart, Pie, Cell,\n XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Legend,\n} from 'recharts'\n\ninterface Stats {\n pid: number\n uptime: number\n memory: any\n eventCount: number\n}\n\ninterface SystemStats {\n totalSessions: number\n totalEvents: number\n totalDecisions: number\n toolUsage: Record<string, number>\n decisionLevels: { block: number; warn: number; confirm: number; allow: number }\n dailyActivity: Array<{ date: string; eventCount: number; sessionCount: number }>\n}\n\nasync function fetchStatus(): Promise<Stats> {\n const res = await fetch('/api/status')\n if (!res.ok) throw new Error('Failed')\n return res.json()\n}\n\nasync function fetchSystemStats(): Promise<SystemStats> {\n const res = await fetch('/api/stats')\n if (!res.ok) throw new Error('Failed')\n return res.json()\n}\n\nasync function fetchSessionsCount(): Promise<number> {\n const res = await fetch('/api/sessions?limit=1000')\n if (!res.ok) return 0\n const sessions = await res.json()\n return sessions.length\n}\n\nasync function fetchRoutingStats() {\n const res = await fetch('/api/routing/stats?window=168')\n if (!res.ok) return null\n return res.json()\n}\n\nasync function fetchMethodologyCount(): Promise<number> {\n const res = await fetch('/api/methodology-executions?limit=1000')\n if (!res.ok) return 0\n const executions = await res.json()\n return executions.length\n}\n\nfunction formatUptime(seconds: number): string {\n const days = Math.floor(seconds / 86400)\n const hours = Math.floor((seconds % 86400) / 3600)\n const minutes = Math.floor((seconds % 3600) / 60)\n if (days > 0) return `${days}天 ${hours}小时`\n if (hours > 0) return `${hours}小时 ${minutes}分钟`\n return `${minutes}分钟`\n}\n\nconst COLORS = {\n primary: '#6366f1',\n green: '#10b981',\n red: '#ef4444',\n yellow: '#f59e0b',\n blue: '#3b82f6',\n purple: '#8b5cf6',\n gray: '#6b7280',\n}\n\nconst PIE_COLORS = [COLORS.primary, COLORS.green, COLORS.yellow, COLORS.red, COLORS.purple, COLORS.blue]\n\nexport default function Dashboard() {\n const navigate = useNavigate()\n const { data: status } = useQuery({ queryKey: ['status'], queryFn: fetchStatus, refetchInterval: 5000 })\n const { data: systemStats } = useQuery({ queryKey: ['system-stats'], queryFn: fetchSystemStats, refetchInterval: 30000 })\n const { data: sessionsCount } = useQuery({ queryKey: ['sessions-count'], queryFn: fetchSessionsCount })\n const { data: routingStats } = useQuery({ queryKey: ['dashboard-routing'], queryFn: fetchRoutingStats })\n const { data: methodologyCount } = useQuery({ queryKey: ['methodology-count'], queryFn: fetchMethodologyCount })\n\n const obediencePercent = routingStats?.obedienceRate !== null && routingStats?.obedienceRate !== undefined\n ? (routingStats.obedienceRate * 100).toFixed(0)\n : '-'\n\n // 准备图表数据\n const toolUsageData = systemStats?.toolUsage\n ? Object.entries(systemStats.toolUsage)\n .sort(([, a], [, b]) => b - a)\n .slice(0, 8)\n .map(([name, count]) => ({ name, count }))\n : []\n\n const decisionData = systemStats?.decisionLevels\n ? [\n { name: '允许', value: systemStats.decisionLevels.allow, fill: COLORS.green },\n { name: '警告', value: systemStats.decisionLevels.warn, fill: COLORS.yellow },\n { name: '阻断', value: systemStats.decisionLevels.block, fill: COLORS.red },\n { name: '确认', value: systemStats.decisionLevels.confirm, fill: COLORS.blue },\n ].filter(d => d.value > 0)\n : []\n\n const dailyData = systemStats?.dailyActivity || []\n\n return (\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900 mb-6\">仪表盘</h1>\n\n {/* Stats grid */}\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-6\">\n <StatCard icon={Activity} label=\"总事件\" value={status?.eventCount?.toString() || '-'} color=\"blue\" onClick={() => navigate('/events')} />\n <StatCard icon={MessageSquare} label=\"会话数\" value={sessionsCount?.toString() || '-'} color=\"purple\" onClick={() => navigate('/sessions')} />\n <StatCard icon={GitBranch} label=\"方法论执行\" value={methodologyCount?.toString() || '-'} color=\"indigo\" onClick={() => navigate('/methodologies')} />\n <StatCard icon={Zap} label=\"路由遵守率\" value={`${obediencePercent}%`} color=\"green\" onClick={() => navigate('/routing')} />\n </div>\n\n {/* Charts */}\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-4 mb-6\">\n {/* Daily activity */}\n <div className=\"bg-white rounded-lg shadow p-6\">\n <div className=\"flex items-center justify-between mb-4\">\n <h3 className=\"text-base font-semibold text-gray-900\">最近 7 天活动</h3>\n <button\n onClick={() => navigate('/events')}\n className=\"text-xs text-indigo-600 hover:text-indigo-700\"\n >\n 查看全部事件 →\n </button>\n </div>\n <ResponsiveContainer width=\"100%\" height={240}>\n <AreaChart\n data={dailyData}\n onClick={() => navigate('/events')}\n style={{ cursor: 'pointer' }}\n >\n <defs>\n <linearGradient id=\"colorEvents\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n <stop offset=\"5%\" stopColor={COLORS.primary} stopOpacity={0.3} />\n <stop offset=\"95%\" stopColor={COLORS.primary} stopOpacity={0} />\n </linearGradient>\n </defs>\n <CartesianGrid strokeDasharray=\"3 3\" stroke=\"#f3f4f6\" />\n <XAxis dataKey=\"date\" tick={{ fontSize: 11 }} tickFormatter={(d) => d?.slice(5)} />\n <YAxis tick={{ fontSize: 11 }} />\n <Tooltip />\n <Area\n type=\"monotone\"\n dataKey=\"eventCount\"\n stroke={COLORS.primary}\n strokeWidth={2}\n fill=\"url(#colorEvents)\"\n name=\"事件\"\n />\n </AreaChart>\n </ResponsiveContainer>\n </div>\n\n {/* Tool usage */}\n <div className=\"bg-white rounded-lg shadow p-6\">\n <div className=\"flex items-center justify-between mb-4\">\n <h3 className=\"text-base font-semibold text-gray-900\">工具使用分布</h3>\n <button\n onClick={() => navigate('/events')}\n className=\"text-xs text-indigo-600 hover:text-indigo-700\"\n >\n 查看详情 →\n </button>\n </div>\n <ResponsiveContainer width=\"100%\" height={240}>\n <BarChart\n data={toolUsageData}\n layout=\"vertical\"\n onClick={(e: any) => {\n if (e?.activeLabel) {\n navigate(`/events?tool=${encodeURIComponent(e.activeLabel)}`)\n }\n }}\n style={{ cursor: 'pointer' }}\n >\n <CartesianGrid strokeDasharray=\"3 3\" stroke=\"#f3f4f6\" />\n <XAxis type=\"number\" tick={{ fontSize: 11 }} />\n <YAxis dataKey=\"name\" type=\"category\" tick={{ fontSize: 11 }} width={80} />\n <Tooltip />\n <Bar dataKey=\"count\" fill={COLORS.primary} radius={[0, 4, 4, 0]} />\n </BarChart>\n </ResponsiveContainer>\n </div>\n\n {/* Decision distribution */}\n <div className=\"bg-white rounded-lg shadow p-6\">\n <div className=\"flex items-center justify-between mb-4\">\n <h3 className=\"text-base font-semibold text-gray-900\">治理决策分布</h3>\n <button\n onClick={() => navigate('/execution-trace')}\n className=\"text-xs text-indigo-600 hover:text-indigo-700\"\n >\n 查看追踪 →\n </button>\n </div>\n {decisionData.length > 0 ? (\n <ResponsiveContainer width=\"100%\" height={240}>\n <PieChart>\n <Pie\n data={decisionData}\n cx=\"50%\"\n cy=\"50%\"\n labelLine={false}\n label={(entry) => `${entry.name}: ${entry.value}`}\n outerRadius={80}\n dataKey=\"value\"\n style={{ cursor: 'pointer' }}\n onClick={() => navigate('/execution-trace')}\n >\n {decisionData.map((_, i) => (\n <Cell key={i} fill={PIE_COLORS[i % PIE_COLORS.length]} />\n ))}\n </Pie>\n <Tooltip />\n <Legend />\n </PieChart>\n </ResponsiveContainer>\n ) : (\n <div className=\"h-60 flex items-center justify-center text-gray-400 text-sm\">暂无决策数据</div>\n )}\n </div>\n\n {/* System info */}\n <div className=\"bg-white rounded-lg shadow p-6\">\n <h3 className=\"flex items-center gap-2 text-base font-semibold text-gray-900 mb-4\">\n <Clock className=\"h-4 w-4 text-indigo-600\" />\n 系统状态\n </h3>\n <dl className=\"space-y-3 text-sm\">\n <div className=\"flex justify-between\">\n <dt className=\"text-gray-500\">PID</dt>\n <dd className=\"font-mono text-gray-900\">{status?.pid || '-'}</dd>\n </div>\n <div className=\"flex justify-between\">\n <dt className=\"text-gray-500\">运行时间</dt>\n <dd className=\"text-gray-900\">{status?.uptime ? formatUptime(status.uptime) : '-'}</dd>\n </div>\n <div className=\"flex justify-between\">\n <dt className=\"text-gray-500\">内存使用</dt>\n <dd className=\"text-gray-900\">\n {status?.memory ? `${Math.round(status.memory.heapUsed / 1024 / 1024)} MB` : '-'}\n </dd>\n </div>\n {routingStats && (\n <>\n <div className=\"border-t pt-3 mt-3\">\n <dt className=\"text-xs font-semibold text-gray-700 mb-2\">路由 (近 7 天)</dt>\n </div>\n <div className=\"flex justify-between\">\n <dt className=\"text-gray-500\">总路由</dt>\n <dd className=\"font-mono text-gray-900\">{routingStats.total}</dd>\n </div>\n <div className=\"flex justify-between\">\n <dt className=\"text-gray-500\">遵守 / 违抗</dt>\n <dd className=\"font-mono\">\n <span className=\"text-green-600\">{routingStats.obeyedCount}</span>\n <span className=\"text-gray-400 mx-1\">/</span>\n <span className=\"text-red-600\">{routingStats.refusedCount}</span>\n </dd>\n </div>\n </>\n )}\n </dl>\n </div>\n </div>\n </div>\n )\n}\n\nfunction StatCard({ icon: Icon, label, value, color, onClick }: {\n icon: any, label: string, value: string, color: string, onClick?: () => void\n}) {\n const colorClass: Record<string, string> = {\n blue: 'bg-blue-100 text-blue-600',\n purple: 'bg-purple-100 text-purple-600',\n indigo: 'bg-indigo-100 text-indigo-600',\n green: 'bg-green-100 text-green-600',\n }\n return (\n <div\n className={`bg-white rounded-lg shadow p-5 ${onClick ? 'cursor-pointer hover:shadow-md transition-shadow' : ''}`}\n onClick={onClick}\n >\n <div className=\"flex items-center justify-between mb-3\">\n <span className=\"text-sm text-gray-500\">{label}</span>\n <div className={`w-8 h-8 rounded-lg flex items-center justify-center ${colorClass[color]}`}>\n <Icon className=\"h-4 w-4\" />\n </div>\n </div>\n <div className=\"text-2xl font-bold text-gray-900\">{value}</div>\n </div>\n )\n}\n"],"names":["fetchStatus","res","fetchSystemStats","fetchSessionsCount","fetchRoutingStats","fetchMethodologyCount","formatUptime","seconds","days","hours","minutes","COLORS","PIE_COLORS","Dashboard","navigate","useNavigate","status","useQuery","systemStats","sessionsCount","routingStats","methodologyCount","obediencePercent","toolUsageData","a","b","name","count","decisionData","d","dailyData","jsx","jsxs","StatCard","Activity","_a","MessageSquare","GitBranch","Zap","ResponsiveContainer","AreaChart","CartesianGrid","XAxis","YAxis","Tooltip","Area","BarChart","e","Bar","PieChart","Pie","entry","_","i","Cell","Legend","Clock","Fragment","Icon","label","value","color","onClick","colorClass"],"mappings":"qWAwBA,eAAeA,GAA8B,CAC3C,MAAMC,EAAM,MAAM,MAAM,aAAa,EACrC,GAAI,CAACA,EAAI,GAAI,MAAM,IAAI,MAAM,QAAQ,EACrC,OAAOA,EAAI,KAAA,CACb,CAEA,eAAeC,GAAyC,CACtD,MAAMD,EAAM,MAAM,MAAM,YAAY,EACpC,GAAI,CAACA,EAAI,GAAI,MAAM,IAAI,MAAM,QAAQ,EACrC,OAAOA,EAAI,KAAA,CACb,CAEA,eAAeE,GAAsC,CACnD,MAAMF,EAAM,MAAM,MAAM,0BAA0B,EAClD,OAAKA,EAAI,IACQ,MAAMA,EAAI,KAAA,GACX,OAFI,CAGtB,CAEA,eAAeG,GAAoB,CACjC,MAAMH,EAAM,MAAM,MAAM,+BAA+B,EACvD,OAAKA,EAAI,GACFA,EAAI,KAAA,EADS,IAEtB,CAEA,eAAeI,GAAyC,CACtD,MAAMJ,EAAM,MAAM,MAAM,wCAAwC,EAChE,OAAKA,EAAI,IACU,MAAMA,EAAI,KAAA,GACX,OAFE,CAGtB,CAEA,SAASK,EAAaC,EAAyB,CAC7C,MAAMC,EAAO,KAAK,MAAMD,EAAU,KAAK,EACjCE,EAAQ,KAAK,MAAOF,EAAU,MAAS,IAAI,EAC3CG,EAAU,KAAK,MAAOH,EAAU,KA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CACb,SAAA,CAAAD,EAAAA,IAAC,OAAA,CAAK,UAAU,wBAAyB,SAAA4B,EAAM,EAC/C5B,EAAAA,IAAC,MAAA,CAAI,UAAW,uDAAuDgC,EAAWF,CAAK,CAAC,GACtF,SAAA9B,EAAAA,IAAC2B,EAAA,CAAK,UAAU,SAAA,CAAU,CAAA,CAC5B,CAAA,EACF,EACA3B,EAAAA,IAAC,MAAA,CAAI,UAAU,mCAAoC,SAAA6B,CAAA,CAAM,CAAA,CAAA,CAAA,CAG/D"}
@@ -0,0 +1,2 @@
1
+ import{r as c,j as e}from"./react-vendor-CSp-GLFF.js";import{d as i}from"./vendor-CMMjVdZs.js";import{X as x}from"./lucide-DjB4fWNj.js";function y({open:t,onClose:s,title:a,children:n,width:o="w-[600px]"}){return c.useEffect(()=>{const r=l=>{l.key==="Escape"&&s()};return t&&(document.addEventListener("keydown",r),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",r),document.body.style.overflow=""}},[t,s]),e.jsxs(e.Fragment,{children:[e.jsx("div",{className:i("fixed inset-0 bg-gray-600 transition-opacity z-40",t?"bg-opacity-50 visible":"bg-opacity-0 invisible pointer-events-none"),onClick:s}),e.jsxs("div",{className:i("fixed inset-y-0 right-0 bg-white shadow-xl z-50 transform transition-transform flex flex-col",o,"max-w-full",t?"translate-x-0":"translate-x-full"),children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200 flex-shrink-0",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:a}),e.jsx("button",{onClick:s,className:"text-gray-400 hover:text-gray-600 transition-colors",children:e.jsx(x,{className:"h-5 w-5"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:n})]})]})}export{y as D};
2
+ //# sourceMappingURL=Drawer-DeKukfwJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Drawer-DeKukfwJ.js","sources":["../../src/components/Drawer.tsx"],"sourcesContent":["import { ReactNode, useEffect } from 'react'\nimport { X } from 'lucide-react'\nimport clsx from 'clsx'\n\ninterface DrawerProps {\n open: boolean\n onClose: () => void\n title: string\n children: ReactNode\n width?: string\n}\n\nexport default function Drawer({ open, onClose, title, children, width = 'w-[600px]' }: DrawerProps) {\n useEffect(() => {\n const handleEsc = (e: KeyboardEvent) => {\n if (e.key === 'Escape') onClose()\n }\n if (open) {\n document.addEventListener('keydown', handleEsc)\n document.body.style.overflow = 'hidden'\n }\n return () => {\n document.removeEventListener('keydown', handleEsc)\n document.body.style.overflow = ''\n }\n }, [open, onClose])\n\n return (\n <>\n <div\n className={clsx(\n 'fixed inset-0 bg-gray-600 transition-opacity z-40',\n open ? 'bg-opacity-50 visible' : 'bg-opacity-0 invisible pointer-events-none'\n )}\n onClick={onClose}\n />\n <div\n className={clsx(\n 'fixed inset-y-0 right-0 bg-white shadow-xl z-50 transform transition-transform flex flex-col',\n width,\n 'max-w-full',\n open ? 'translate-x-0' : 'translate-x-full'\n )}\n >\n <div className=\"flex items-center justify-between px-6 py-4 border-b border-gray-200 flex-shrink-0\">\n <h2 className=\"text-lg font-semibold text-gray-900\">{title}</h2>\n <button\n onClick={onClose}\n className=\"text-gray-400 hover:text-gray-600 transition-colors\"\n >\n <X className=\"h-5 w-5\" />\n </button>\n </div>\n <div className=\"flex-1 overflow-y-auto p-6\">\n {children}\n </div>\n </div>\n </>\n )\n}\n"],"names":["Drawer","open","onClose","title","children","width","useEffect","handleEsc","e","jsxs","Fragment","jsx","clsx","X"],"mappings":"wIAYA,SAAwBA,EAAO,CAAE,KAAAC,EAAM,QAAAC,EAAS,MAAAC,EAAO,SAAAC,EAAU,MAAAC,EAAQ,aAA4B,CACnGC,OAAAA,EAAAA,UAAU,IAAM,CACd,MAAMC,EAAaC,GAAqB,CAClCA,EAAE,MAAQ,UAAUN,EAAA,CAC1B,EACA,OAAID,IACF,SAAS,iBAAiB,UAAWM,CAAS,EAC9C,SAAS,KAAK,MAAM,SAAW,UAE1B,IAAM,CACX,SAAS,oBAAoB,UAAWA,CAAS,EACjD,SAAS,KAAK,MAAM,SAAW,EACjC,CACF,EAAG,CAACN,EAAMC,CAAO,CAAC,EAGhBO,EAAAA,KAAAC,WAAA,CACE,SAAA,CAAAC,EAAAA,IAAC,MAAA,CACC,UAAWC,EACT,oDACAX,EAAO,wBAA0B,4CAAA,EAEnC,QAASC,CAAA,CAAA,EAEXO,EAAAA,KAAC,MAAA,CACC,UAAWG,EACT,+FACAP,EACA,aACAJ,EAAO,gBAAkB,kBAAA,EAG3B,SAAA,CAAAQ,EAAAA,KAAC,MAAA,CAAI,UAAU,qFACb,SAAA,CAAAE,EAAAA,IAAC,KAAA,CAAG,UAAU,sCAAuC,SAAAR,EAAM,EAC3DQ,EAAAA,IAAC,SAAA,CACC,QAAST,EACT,UAAU,sDAEV,SAAAS,EAAAA,IAACE,EAAA,CAAE,UAAU,SAAA,CAAU,CAAA,CAAA,CACzB,EACF,EACAF,EAAAA,IAAC,MAAA,CAAI,UAAU,6BACZ,SAAAP,CAAA,CACH,CAAA,CAAA,CAAA,CACF,EACF,CAEJ"}
@@ -0,0 +1,2 @@
1
+ import{r as n,j as e}from"./react-vendor-CSp-GLFF.js";import{u as N}from"./query-C99w429o.js";import{d as u}from"./vendor-CMMjVdZs.js";import{D as w}from"./Drawer-DeKukfwJ.js";import{C as g}from"./CodeBlock--H53gk46.js";import{S as _,g as k,d as S,a as C}from"./export-CEzDNM66.js";import{u as E}from"./index-DUYj2ek1.js";import{k as P,D as U,A as T}from"./lucide-DjB4fWNj.js";import{f as y}from"./date-fns-CZ_bHujz.js";import"./syntax-highlighter-44FakypI.js";import"./react-router-I-HqunH7.js";async function D(i){const c=`/api/events?limit=500${i?`&hook_type=${i}`:""}`,r=await fetch(c);if(!r.ok)throw new Error("Failed to fetch events");return r.json()}const H=["","UserPromptSubmit","PreToolUse","PostToolUse","Stop","Notification"];function B(){const[i,c]=n.useState(""),[r,j]=n.useState(""),[s,p]=n.useState(null),[v,m]=n.useState(!1),f=E(),{data:x,isLoading:b}=N({queryKey:["events",i],queryFn:()=>D(i),refetchInterval:5e3}),o=n.useMemo(()=>{if(!x)return[];if(!r.trim())return x;const t=r.toLowerCase();return x.filter(l=>{var d,a;return((d=l.tool_name)==null?void 0:d.toLowerCase().includes(t))||((a=l.user_prompt)==null?void 0:a.toLowerCase().includes(t))||l.session_id.toLowerCase().includes(t)||JSON.stringify(l.tool_input||"").toLowerCase().includes(t)})},[x,r]),h=t=>{const l=k();if(t==="json")S(`events-${l}.json`,o);else{const d=o.map(a=>({event_id:a.event_id,session_id:a.session_id,timestamp:a.timestamp,hook_type:a.hook_type,tool_name:a.tool_name||"",user_prompt:a.user_prompt||"",tool_input:a.tool_input?JSON.stringify(a.tool_input).slice(0,500):""}));C(`events-${l}.csv`,d)}f.success(`已导出 ${o.length} 条事件`),m(!1)};return 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(_,{value:r,onChange:j,placeholder:"搜索提示/工具/session...",className:"w-64"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(P,{className:"h-4 w-4 text-gray-500"}),e.jsx("select",{value:i,onChange:t=>c(t.target.value),className:"text-sm border border-gray-300 rounded-md px-2 py-1.5 bg-white",children:H.map(t=>e.jsx("option",{value:t,children:t||"全部类型"},t))})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>m(t=>!t),disabled:o.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(U,{className:"h-4 w-4"}),"导出"]}),v&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>m(!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:()=>h("json"),className:"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50",children:"导出为 JSON"}),e.jsx("button",{onClick:()=>h("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:["显示 ",o.length," 条 ",r&&"(已过滤)"]}),e.jsx("div",{className:"bg-white rounded-lg shadow overflow-hidden",children:b?e.jsx("div",{className:"p-6 text-gray-600",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",children:"时间"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"类型"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"工具"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"详情"})]})}),e.jsxs("tbody",{className:"bg-white divide-y divide-gray-200",children:[o.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50 cursor-pointer",onClick:()=>p(t),children:[e.jsx("td",{className:"px-4 py-2 whitespace-nowrap text-xs font-mono text-gray-500",children:t.timestamp?y(new Date(t.timestamp),"HH:mm:ss"):"-"}),e.jsx("td",{className:"px-4 py-2 whitespace-nowrap",children:e.jsx("span",{className:u("px-2 py-0.5 text-xs font-medium rounded",t.hook_type==="UserPromptSubmit"&&"bg-purple-100 text-purple-700",t.hook_type==="PreToolUse"&&"bg-blue-100 text-blue-700",t.hook_type==="PostToolUse"&&"bg-green-100 text-green-700",t.hook_type==="Stop"&&"bg-gray-100 text-gray-700",t.hook_type==="Notification"&&"bg-yellow-100 text-yellow-700"),children:t.hook_type})}),e.jsx("td",{className:"px-4 py-2 whitespace-nowrap text-sm text-gray-700",children:t.tool_name||"-"}),e.jsx("td",{className:"px-4 py-2 max-w-xl",children:e.jsx("p",{className:"text-xs text-gray-600 truncate",children:t.user_prompt||(t.tool_input?JSON.stringify(t.tool_input).slice(0,100):"-")})})]},t.event_id)),o.length===0&&e.jsx("tr",{children:e.jsxs("td",{colSpan:4,className:"px-4 py-12 text-center text-gray-500",children:[e.jsx(T,{className:"h-12 w-12 text-gray-300 mx-auto mb-2"}),r?"无匹配结果":"暂无事件"]})})]})]})}),e.jsx(w,{open:s!==null,onClose:()=>p(null),title:"事件详情",children:s&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"事件 ID"}),e.jsx("div",{className:"text-sm font-mono text-gray-900",children:s.event_id})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"类型"}),e.jsx("span",{className:u("px-2 py-1 text-xs font-medium rounded",s.hook_type==="UserPromptSubmit"&&"bg-purple-100 text-purple-700",s.hook_type==="PreToolUse"&&"bg-blue-100 text-blue-700",s.hook_type==="PostToolUse"&&"bg-green-100 text-green-700"),children:s.hook_type})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"时间"}),e.jsx("div",{className:"text-sm text-gray-900",children:s.timestamp?y(new Date(s.timestamp),"yyyy-MM-dd HH:mm:ss"):"-"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Session"}),e.jsx("div",{className:"text-sm font-mono text-gray-700",children:s.session_id})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"项目路径"}),e.jsx("div",{className:"text-sm font-mono text-gray-700 break-all",children:s.project_path})]}),s.tool_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-900",children:s.tool_name})]}),s.user_prompt&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"用户提示"}),e.jsx("div",{className:"bg-purple-50 rounded p-3 text-sm text-gray-800 whitespace-pre-wrap",children:s.user_prompt})]}),s.tool_input&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"工具输入"}),e.jsx(g,{data:s.tool_input,language:"json",maxHeight:"300px"})]}),s.tool_output&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"工具输出"}),e.jsx(g,{data:s.tool_output,language:typeof s.tool_output=="string"?"text":"json",maxHeight:"400px"})]})]})})]})}export{B as default};
2
+ //# sourceMappingURL=Events-CnA3f740.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Events-CnA3f740.js","sources":["../../src/pages/Events.tsx"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\nimport { useState, useMemo } from 'react'\nimport { format } from 'date-fns'\nimport { Activity, Filter, Download } from 'lucide-react'\nimport clsx from 'clsx'\nimport Drawer from '../components/Drawer'\nimport CodeBlock from '../components/CodeBlock'\nimport SearchInput from '../components/SearchInput'\nimport { downloadJSON, downloadCSV, getTimestamp } from '../utils/export'\nimport { useToast } from '../components/Toast'\n\ninterface Event {\n event_id: string\n session_id: string\n project_path: string\n timestamp: string\n hook_type: string\n tool_name?: string\n tool_input?: any\n tool_output?: any\n user_prompt?: string\n ai_response?: string\n}\n\nasync function fetchEvents(hookType?: string): Promise<Event[]> {\n const url = `/api/events?limit=500${hookType ? `&hook_type=${hookType}` : ''}`\n const res = await fetch(url)\n if (!res.ok) throw new Error('Failed to fetch events')\n return res.json()\n}\n\nconst hookTypes = ['', 'UserPromptSubmit', 'PreToolUse', 'PostToolUse', 'Stop', 'Notification']\n\nexport default function Events() {\n const [filter, setFilter] = useState('')\n const [search, setSearch] = useState('')\n const [selectedEvent, setSelectedEvent] = useState<Event | null>(null)\n const [showExportMenu, setShowExportMenu] = useState(false)\n const toast = useToast()\n\n const { data: events, isLoading } = useQuery({\n queryKey: ['events', filter],\n queryFn: () => fetchEvents(filter),\n refetchInterval: 5000,\n })\n\n // 客户端搜索过滤\n const filteredEvents = useMemo(() => {\n if (!events) return []\n if (!search.trim()) return events\n const q = search.toLowerCase()\n return events.filter(e =>\n e.tool_name?.toLowerCase().includes(q) ||\n e.user_prompt?.toLowerCase().includes(q) ||\n e.session_id.toLowerCase().includes(q) ||\n JSON.stringify(e.tool_input || '').toLowerCase().includes(q)\n )\n }, [events, search])\n\n const handleExport = (exportFormat: 'json' | 'csv') => {\n const ts = getTimestamp()\n if (exportFormat === 'json') {\n downloadJSON(`events-${ts}.json`, filteredEvents)\n } else {\n // CSV 导出扁平化\n const flat = filteredEvents.map(e => ({\n event_id: e.event_id,\n session_id: e.session_id,\n timestamp: e.timestamp,\n hook_type: e.hook_type,\n tool_name: e.tool_name || '',\n user_prompt: e.user_prompt || '',\n tool_input: e.tool_input ? JSON.stringify(e.tool_input).slice(0, 500) : '',\n }))\n downloadCSV(`events-${ts}.csv`, flat)\n }\n toast.success(`已导出 ${filteredEvents.length} 条事件`)\n setShowExportMenu(false)\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=\"flex items-center gap-1\">\n <Filter className=\"h-4 w-4 text-gray-500\" />\n <select\n value={filter}\n onChange={(e) => setFilter(e.target.value)}\n className=\"text-sm border border-gray-300 rounded-md px-2 py-1.5 bg-white\"\n >\n {hookTypes.map((t) => (\n <option key={t} value={t}>{t || '全部类型'}</option>\n ))}\n </select>\n </div>\n <div className=\"relative\">\n <button\n onClick={() => setShowExportMenu(v => !v)}\n disabled={filteredEvents.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 显示 {filteredEvents.length} 条 {search && `(已过滤)`}\n </div>\n\n <div className=\"bg-white rounded-lg shadow overflow-hidden\">\n {isLoading ? (\n <div className=\"p-6 text-gray-600\">加载中...</div>\n ) : (\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\">时间</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">类型</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">工具</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">详情</th>\n </tr>\n </thead>\n <tbody className=\"bg-white divide-y divide-gray-200\">\n {filteredEvents.map((e) => (\n <tr\n key={e.event_id}\n className=\"hover:bg-gray-50 cursor-pointer\"\n onClick={() => setSelectedEvent(e)}\n >\n <td className=\"px-4 py-2 whitespace-nowrap text-xs font-mono text-gray-500\">\n {e.timestamp ? format(new Date(e.timestamp), 'HH:mm:ss') : '-'}\n </td>\n <td className=\"px-4 py-2 whitespace-nowrap\">\n <span className={clsx(\n 'px-2 py-0.5 text-xs font-medium rounded',\n e.hook_type === 'UserPromptSubmit' && 'bg-purple-100 text-purple-700',\n e.hook_type === 'PreToolUse' && 'bg-blue-100 text-blue-700',\n e.hook_type === 'PostToolUse' && 'bg-green-100 text-green-700',\n e.hook_type === 'Stop' && 'bg-gray-100 text-gray-700',\n e.hook_type === 'Notification' && 'bg-yellow-100 text-yellow-700'\n )}>\n {e.hook_type}\n </span>\n </td>\n <td className=\"px-4 py-2 whitespace-nowrap text-sm text-gray-700\">\n {e.tool_name || '-'}\n </td>\n <td className=\"px-4 py-2 max-w-xl\">\n <p className=\"text-xs text-gray-600 truncate\">\n {e.user_prompt || (e.tool_input ? JSON.stringify(e.tool_input).slice(0, 100) : '-')}\n </p>\n </td>\n </tr>\n ))}\n {filteredEvents.length === 0 && (\n <tr>\n <td colSpan={4} className=\"px-4 py-12 text-center text-gray-500\">\n <Activity className=\"h-12 w-12 text-gray-300 mx-auto mb-2\" />\n {search ? '无匹配结果' : '暂无事件'}\n </td>\n </tr>\n )}\n </tbody>\n </table>\n )}\n </div>\n\n {/* Event Detail Drawer */}\n <Drawer\n open={selectedEvent !== null}\n onClose={() => setSelectedEvent(null)}\n title=\"事件详情\"\n >\n {selectedEvent && (\n <div className=\"space-y-4\">\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">事件 ID</div>\n <div className=\"text-sm font-mono text-gray-900\">{selectedEvent.event_id}</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">类型</div>\n <span className={clsx(\n 'px-2 py-1 text-xs font-medium rounded',\n selectedEvent.hook_type === 'UserPromptSubmit' && 'bg-purple-100 text-purple-700',\n selectedEvent.hook_type === 'PreToolUse' && 'bg-blue-100 text-blue-700',\n selectedEvent.hook_type === 'PostToolUse' && 'bg-green-100 text-green-700',\n )}>\n {selectedEvent.hook_type}\n </span>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">时间</div>\n <div className=\"text-sm text-gray-900\">\n {selectedEvent.timestamp ? format(new Date(selectedEvent.timestamp), 'yyyy-MM-dd HH:mm:ss') : '-'}\n </div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">Session</div>\n <div className=\"text-sm font-mono text-gray-700\">{selectedEvent.session_id}</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">项目路径</div>\n <div className=\"text-sm font-mono text-gray-700 break-all\">{selectedEvent.project_path}</div>\n </div>\n {selectedEvent.tool_name && (\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">工具</div>\n <div className=\"text-sm text-gray-900\">{selectedEvent.tool_name}</div>\n </div>\n )}\n {selectedEvent.user_prompt && (\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">用户提示</div>\n <div className=\"bg-purple-50 rounded p-3 text-sm text-gray-800 whitespace-pre-wrap\">\n {selectedEvent.user_prompt}\n </div>\n </div>\n )}\n {selectedEvent.tool_input && (\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">工具输入</div>\n <CodeBlock data={selectedEvent.tool_input} language=\"json\" maxHeight=\"300px\" />\n </div>\n )}\n {selectedEvent.tool_output && (\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">工具输出</div>\n <CodeBlock\n data={selectedEvent.tool_output}\n language={typeof selectedEvent.tool_output === 'string' ? 'text' : 'json'}\n maxHeight=\"400px\"\n />\n </div>\n )}\n </div>\n )}\n </Drawer>\n </div>\n )\n}\n"],"names":["fetchEvents","hookType","url","res","hookTypes","Events","filter","setFilter","useState","search","setSearch","selectedEvent","setSelectedEvent","showExportMenu","setShowExportMenu","toast","useToast","events","isLoading","useQuery","filteredEvents","useMemo","q","e","_a","_b","handleExport","exportFormat","ts","getTimestamp","downloadJSON","flat","downloadCSV","jsxs","jsx","SearchInput","Filter","v","Download","Fragment","format","clsx","Activity","Drawer","CodeBlock"],"mappings":"gfAwBA,eAAeA,EAAYC,EAAqC,CAC9D,MAAMC,EAAM,wBAAwBD,EAAW,cAAcA,CAAQ,GAAK,EAAE,GACtEE,EAAM,MAAM,MAAMD,CAAG,EAC3B,GAAI,CAACC,EAAI,GAAI,MAAM,IAAI,MAAM,wBAAwB,EACrD,OAAOA,EAAI,KAAA,CACb,CAEA,MAAMC,EAAY,CAAC,GAAI,mBAAo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OAAOA,EAAc,aAAgB,SAAW,OAAS,OACnE,UAAU,OAAA,CAAA,CACZ,CAAA,CACF,CAAA,CAAA,CAEJ,CAAA,CAAA,CAEJ,EACF,CAEJ"}
@@ -0,0 +1,2 @@
1
+ import{r as x,j as e}from"./react-vendor-CSp-GLFF.js";import{b as _,u as C}from"./query-C99w429o.js";import{d as S}from"./vendor-CMMjVdZs.js";import{D as k}from"./Drawer-DeKukfwJ.js";import{C as E}from"./CodeBlock--H53gk46.js";import{S as F,g as M,d as O,a as H}from"./export-CEzDNM66.js";import{u as J}from"./index-DUYj2ek1.js";import{W as T,l as q,D as L,e as $,d as D,m as Q,A as W}from"./lucide-DjB4fWNj.js";import{f as j}from"./date-fns-CZ_bHujz.js";import"./syntax-highlighter-44FakypI.js";import"./react-router-I-HqunH7.js";async function z(l){let c="/api/routing/events?limit=200";l==="obeyed"?c+="&obeyed=1":l==="refused"?c+="&obeyed=0":l==="unknown"&&(c+="&obeyed=null");const n=await fetch(c);if(!n.ok)throw new Error("Failed to fetch");return n.json()}const A=[{value:"",label:"全部"},{value:"obeyed",label:"✅ 遵守"},{value:"refused",label:"❌ 违抗"},{value:"unknown",label:"? 未判定"}];function ee(){const[l,c]=x.useState(""),[n,f]=x.useState(""),[t,u]=x.useState(null),[v,p]=x.useState(!1),[N,h]=x.useState(!1),b=J(),g=_();x.useEffect(()=>{const s=new EventSource("/api/execution-trace/stream");return s.onopen=()=>p(!0),s.onerror=()=>p(!1),s.onmessage=r=>{try{JSON.parse(r.data).type==="execution-status"&&g.invalidateQueries({queryKey:["routing-events"]})}catch{}},()=>{s.close(),p(!1)}},[g]);const{data:m,isLoading:w}=C({queryKey:["routing-events",l],queryFn:()=>z(l),refetchInterval:1e4}),i=x.useMemo(()=>{if(!m)return[];if(!n.trim())return m;const s=n.toLowerCase();return m.filter(r=>{var o,a,d;return((o=r.prompt)==null?void 0:o.toLowerCase().includes(s))||((a=r.routed_to_name)==null?void 0:a.toLowerCase().includes(s))||((d=r.first_tool_name)==null?void 0:d.toLowerCase().includes(s))})},[m,n]),y=s=>{const r=M();if(s==="json")O(`routing-events-${r}.json`,i);else{const o=i.map(a=>{let d={};try{d=JSON.parse(a.intent_json||"{}")}catch{}return{id:a.id,ts:a.ts?j(a.ts,"yyyy-MM-dd HH:mm:ss"):"",prompt:a.prompt,taskType:d.taskType||"",complexity:d.complexity||"",routed_to:a.routed_to_name||"",obeyed:a.obeyed===1?"yes":a.obeyed===0?"no":"",first_tool:a.first_tool_name||"",duration_ms:a.total_execution_ms||"",refusal_reason:a.refusal_reason||""}});H(`routing-events-${r}.csv`,o)}b.success(`已导出 ${i.length} 条追踪记录`),h(!1)};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 flex-wrap gap-3",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"执行追踪"}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:v?e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"h-3 w-3 text-green-500"}),e.jsx("span",{className:"text-xs text-green-600",children:"实时流已连接"})]}):e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"h-3 w-3 text-gray-400"}),e.jsx("span",{className:"text-xs text-gray-500",children:"实时流未连接"})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(F,{value:n,onChange:f,placeholder:"搜索 prompt / agent / tool...",className:"w-56"}),e.jsx("div",{className:"flex items-center gap-1",children:A.map(s=>e.jsx("button",{onClick:()=>c(s.value),className:S("px-2.5 py-1.5 text-xs rounded-md",l===s.value?"bg-indigo-100 text-indigo-700":"bg-white text-gray-600 border border-gray-300 hover:bg-gray-50"),children:s.label},s.value))}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>h(s=>!s),disabled:i.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(L,{className:"h-4 w-4"}),"导出"]}),N&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>h(!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:()=>y("json"),className:"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50",children:"导出为 JSON"}),e.jsx("button",{onClick:()=>y("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:["显示 ",i.length," 条 ",n&&"(已过滤)"]}),e.jsx("div",{className:"bg-white rounded-lg shadow overflow-hidden",children:w?e.jsx("div",{className:"p-6",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",children:"时间"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"提示"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"路由到"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"遵守"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"首工具"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"耗时"})]})}),e.jsxs("tbody",{className:"bg-white divide-y divide-gray-200",children:[i.map(s=>{let r={};try{r=JSON.parse(s.intent_json||"{}")}catch{}return e.jsxs("tr",{className:"hover:bg-gray-50 cursor-pointer",onClick:()=>u(s),children:[e.jsx("td",{className:"px-4 py-2 whitespace-nowrap text-xs font-mono text-gray-500",children:j(s.ts,"MM-dd HH:mm:ss")}),e.jsxs("td",{className:"px-4 py-2 max-w-xs",children:[e.jsx("p",{className:"text-xs text-gray-700 truncate",title:s.prompt,children:s.prompt}),e.jsxs("p",{className:"text-xs text-gray-400 mt-0.5",children:[r.taskType," / ",r.complexity]})]}),e.jsx("td",{className:"px-4 py-2 whitespace-nowrap",children:s.routed_to_name?e.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-indigo-100 text-indigo-700 rounded",children:s.routed_to_name}):e.jsx("span",{className:"text-xs text-gray-400",children:"未路由"})}),e.jsx("td",{className:"px-4 py-2 whitespace-nowrap",children:s.obeyed===1?e.jsxs("span",{className:"inline-flex items-center gap-1 text-green-600 text-xs",children:[e.jsx($,{className:"h-4 w-4"}),"遵守"]}):s.obeyed===0?e.jsxs("span",{className:"inline-flex items-center gap-1 text-red-600 text-xs",children:[e.jsx(D,{className:"h-4 w-4"}),"违抗"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-gray-400 text-xs",children:[e.jsx(Q,{className:"h-4 w-4"}),"?"]})}),e.jsx("td",{className:"px-4 py-2 whitespace-nowrap text-xs text-gray-700",children:s.first_tool_name||"-"}),e.jsx("td",{className:"px-4 py-2 whitespace-nowrap text-xs font-mono text-gray-500",children:s.total_execution_ms?`${(s.total_execution_ms/1e3).toFixed(1)}s`:"-"})]},s.id)}),i.length===0&&e.jsx("tr",{children:e.jsxs("td",{colSpan:6,className:"px-4 py-12 text-center text-gray-500",children:[e.jsx(W,{className:"h-12 w-12 text-gray-300 mx-auto mb-2"}),n?"无匹配结果":"暂无追踪记录"]})})]})]})}),e.jsx(k,{open:t!==null,onClose:()=>u(null),title:"路由决策详情",children:t&&(()=>{let s={};try{s=JSON.parse(t.intent_json||"{}")}catch{}return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"用户提示"}),e.jsx("div",{className:"bg-purple-50 rounded p-3 text-sm text-gray-800 whitespace-pre-wrap",children:t.prompt})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"路由结果"}),e.jsx("div",{className:"text-sm font-medium",children:t.routed_to_name||"未路由"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"遵守状态"}),e.jsxs("div",{children:[t.obeyed===1&&e.jsx("span",{className:"text-green-600 text-sm",children:"✅ 遵守"}),t.obeyed===0&&e.jsx("span",{className:"text-red-600 text-sm",children:"❌ 违抗"}),t.obeyed===null&&e.jsx("span",{className:"text-gray-400 text-sm",children:"未判定"})]})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"意图分类"}),e.jsx(E,{data:s,language:"json",maxHeight:"200px"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"首工具"}),e.jsx("div",{className:"font-mono",children:t.first_tool_name||"-"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"分类耗时"}),e.jsxs("div",{className:"font-mono",children:[t.classification_ms,"ms"]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"总执行时间"}),e.jsx("div",{className:"font-mono",children:t.total_execution_ms?`${(t.total_execution_ms/1e3).toFixed(2)}s`:"-"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"完成原因"}),e.jsx("div",{children:t.completion_reason||"-"})]})]}),t.refusal_reason&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"违抗原因"}),e.jsx("div",{className:"bg-red-50 rounded p-3 text-sm text-red-700",children:t.refusal_reason})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Session"}),e.jsx("div",{className:"text-xs font-mono text-gray-700",children:t.session_id})]})]})})()})]})}export{ee as default};
2
+ //# sourceMappingURL=ExecutionTrace-ClPfFIQa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExecutionTrace-ClPfFIQa.js","sources":["../../src/pages/ExecutionTrace.tsx"],"sourcesContent":["import { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useState, useEffect, useMemo } from 'react'\nimport { format } from 'date-fns'\nimport { CheckCircle, XCircle, HelpCircle, Activity, Wifi, WifiOff, Download } from 'lucide-react'\nimport clsx from 'clsx'\nimport Drawer from '../components/Drawer'\nimport CodeBlock from '../components/CodeBlock'\nimport SearchInput from '../components/SearchInput'\nimport { downloadJSON, downloadCSV, getTimestamp } from '../utils/export'\nimport { useToast } from '../components/Toast'\n\ninterface RoutingEvent {\n id: number\n session_id: string\n project_path: string\n ts: number\n prompt: string\n intent_json: string\n routed_to_type: string\n routed_to_name: string\n is_forced: number\n obeyed: number | null\n classification_ms: number\n fallback_used: number\n refusal_reason: string | null\n first_tool_name: string | null\n first_tool_ts: number | null\n completed_ts: number | null\n total_execution_ms: number | null\n completion_reason: string | null\n}\n\nasync function fetchRoutingEvents(filter?: string): Promise<RoutingEvent[]> {\n let url = '/api/routing/events?limit=200'\n if (filter === 'obeyed') url += '&obeyed=1'\n else if (filter === 'refused') url += '&obeyed=0'\n else if (filter === 'unknown') url += '&obeyed=null'\n const res = await fetch(url)\n if (!res.ok) throw new Error('Failed to fetch')\n return res.json()\n}\n\nconst filters = [\n { value: '', label: '全部' },\n { value: 'obeyed', label: '✅ 遵守' },\n { value: 'refused', label: '❌ 违抗' },\n { value: 'unknown', label: '? 未判定' },\n]\n\nexport default function ExecutionTrace() {\n const [filter, setFilter] = useState('')\n const [search, setSearch] = useState('')\n const [selectedEvent, setSelectedEvent] = useState<RoutingEvent | null>(null)\n const [sseConnected, setSseConnected] = useState(false)\n const [showExportMenu, setShowExportMenu] = useState(false)\n const toast = useToast()\n const queryClient = useQueryClient()\n\n useEffect(() => {\n const eventSource = new EventSource('/api/execution-trace/stream')\n eventSource.onopen = () => setSseConnected(true)\n eventSource.onerror = () => setSseConnected(false)\n eventSource.onmessage = (e) => {\n try {\n const data = JSON.parse(e.data)\n if (data.type === 'execution-status') {\n queryClient.invalidateQueries({ queryKey: ['routing-events'] })\n }\n } catch { /* ignore */ }\n }\n return () => {\n eventSource.close()\n setSseConnected(false)\n }\n }, [queryClient])\n\n const { data: events, isLoading } = useQuery({\n queryKey: ['routing-events', filter],\n queryFn: () => fetchRoutingEvents(filter),\n refetchInterval: 10000,\n })\n\n const filteredEvents = useMemo(() => {\n if (!events) return []\n if (!search.trim()) return events\n const q = search.toLowerCase()\n return events.filter(e =>\n e.prompt?.toLowerCase().includes(q) ||\n e.routed_to_name?.toLowerCase().includes(q) ||\n e.first_tool_name?.toLowerCase().includes(q)\n )\n }, [events, search])\n\n const handleExport = (exportFormat: 'json' | 'csv') => {\n const ts = getTimestamp()\n if (exportFormat === 'json') {\n downloadJSON(`routing-events-${ts}.json`, filteredEvents)\n } else {\n const flat = filteredEvents.map(e => {\n let intent: { taskType?: string; complexity?: string } = {}\n try { intent = JSON.parse(e.intent_json || '{}') } catch { /* ignore */ }\n return {\n id: e.id,\n ts: e.ts ? format(e.ts, 'yyyy-MM-dd HH:mm:ss') : '',\n prompt: e.prompt,\n taskType: intent.taskType || '',\n complexity: intent.complexity || '',\n routed_to: e.routed_to_name || '',\n obeyed: e.obeyed === 1 ? 'yes' : e.obeyed === 0 ? 'no' : '',\n first_tool: e.first_tool_name || '',\n duration_ms: e.total_execution_ms || '',\n refusal_reason: e.refusal_reason || '',\n }\n })\n downloadCSV(`routing-events-${ts}.csv`, flat)\n }\n toast.success(`已导出 ${filteredEvents.length} 条追踪记录`)\n setShowExportMenu(false)\n }\n\n return (\n <div>\n <div className=\"flex items-center justify-between mb-4 flex-wrap gap-3\">\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900\">执行追踪</h1>\n <div className=\"flex items-center gap-2 mt-1\">\n {sseConnected ? (\n <>\n <Wifi className=\"h-3 w-3 text-green-500\" />\n <span className=\"text-xs text-green-600\">实时流已连接</span>\n </>\n ) : (\n <>\n <WifiOff className=\"h-3 w-3 text-gray-400\" />\n <span className=\"text-xs text-gray-500\">实时流未连接</span>\n </>\n )}\n </div>\n </div>\n <div className=\"flex items-center gap-2 flex-wrap\">\n <SearchInput\n value={search}\n onChange={setSearch}\n placeholder=\"搜索 prompt / agent / tool...\"\n className=\"w-56\"\n />\n <div className=\"flex items-center gap-1\">\n {filters.map((f) => (\n <button\n key={f.value}\n onClick={() => setFilter(f.value)}\n className={clsx(\n 'px-2.5 py-1.5 text-xs rounded-md',\n filter === f.value\n ? 'bg-indigo-100 text-indigo-700'\n : 'bg-white text-gray-600 border border-gray-300 hover:bg-gray-50'\n )}\n >\n {f.label}\n </button>\n ))}\n </div>\n <div className=\"relative\">\n <button\n onClick={() => setShowExportMenu(v => !v)}\n disabled={filteredEvents.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 显示 {filteredEvents.length} 条 {search && `(已过滤)`}\n </div>\n\n <div className=\"bg-white rounded-lg shadow overflow-hidden\">\n {isLoading ? (\n <div className=\"p-6\">加载中...</div>\n ) : (\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\">时间</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">提示</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">路由到</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">遵守</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">首工具</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">耗时</th>\n </tr>\n </thead>\n <tbody className=\"bg-white divide-y divide-gray-200\">\n {filteredEvents.map((e) => {\n let intent: any = {}\n try { intent = JSON.parse(e.intent_json || '{}') } catch { /* ignore */ }\n return (\n <tr\n key={e.id}\n className=\"hover:bg-gray-50 cursor-pointer\"\n onClick={() => setSelectedEvent(e)}\n >\n <td className=\"px-4 py-2 whitespace-nowrap text-xs font-mono text-gray-500\">\n {format(e.ts, 'MM-dd HH:mm:ss')}\n </td>\n <td className=\"px-4 py-2 max-w-xs\">\n <p className=\"text-xs text-gray-700 truncate\" title={e.prompt}>{e.prompt}</p>\n <p className=\"text-xs text-gray-400 mt-0.5\">\n {intent.taskType} / {intent.complexity}\n </p>\n </td>\n <td className=\"px-4 py-2 whitespace-nowrap\">\n {e.routed_to_name ? (\n <span className=\"px-2 py-0.5 text-xs font-medium bg-indigo-100 text-indigo-700 rounded\">\n {e.routed_to_name}\n </span>\n ) : (\n <span className=\"text-xs text-gray-400\">未路由</span>\n )}\n </td>\n <td className=\"px-4 py-2 whitespace-nowrap\">\n {e.obeyed === 1 ? (\n <span className=\"inline-flex items-center gap-1 text-green-600 text-xs\">\n <CheckCircle className=\"h-4 w-4\" />遵守\n </span>\n ) : e.obeyed === 0 ? (\n <span className=\"inline-flex items-center gap-1 text-red-600 text-xs\">\n <XCircle className=\"h-4 w-4\" />违抗\n </span>\n ) : (\n <span className=\"inline-flex items-center gap-1 text-gray-400 text-xs\">\n <HelpCircle className=\"h-4 w-4\" />?\n </span>\n )}\n </td>\n <td className=\"px-4 py-2 whitespace-nowrap text-xs text-gray-700\">\n {e.first_tool_name || '-'}\n </td>\n <td className=\"px-4 py-2 whitespace-nowrap text-xs font-mono text-gray-500\">\n {e.total_execution_ms ? `${(e.total_execution_ms / 1000).toFixed(1)}s` : '-'}\n </td>\n </tr>\n )\n })}\n {filteredEvents.length === 0 && (\n <tr>\n <td colSpan={6} className=\"px-4 py-12 text-center text-gray-500\">\n <Activity className=\"h-12 w-12 text-gray-300 mx-auto mb-2\" />\n {search ? '无匹配结果' : '暂无追踪记录'}\n </td>\n </tr>\n )}\n </tbody>\n </table>\n )}\n </div>\n\n <Drawer\n open={selectedEvent !== null}\n onClose={() => setSelectedEvent(null)}\n title=\"路由决策详情\"\n >\n {selectedEvent && (() => {\n let intent: any = {}\n try { intent = JSON.parse(selectedEvent.intent_json || '{}') } catch { /* ignore */ }\n return (\n <div className=\"space-y-4\">\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">用户提示</div>\n <div className=\"bg-purple-50 rounded p-3 text-sm text-gray-800 whitespace-pre-wrap\">\n {selectedEvent.prompt}\n </div>\n </div>\n\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">路由结果</div>\n <div className=\"text-sm font-medium\">\n {selectedEvent.routed_to_name || '未路由'}\n </div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">遵守状态</div>\n <div>\n {selectedEvent.obeyed === 1 && <span className=\"text-green-600 text-sm\">✅ 遵守</span>}\n {selectedEvent.obeyed === 0 && <span className=\"text-red-600 text-sm\">❌ 违抗</span>}\n {selectedEvent.obeyed === null && <span className=\"text-gray-400 text-sm\">未判定</span>}\n </div>\n </div>\n </div>\n\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">意图分类</div>\n <CodeBlock data={intent} language=\"json\" maxHeight=\"200px\" />\n </div>\n\n <div className=\"grid grid-cols-2 gap-3 text-sm\">\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">首工具</div>\n <div className=\"font-mono\">{selectedEvent.first_tool_name || '-'}</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">分类耗时</div>\n <div className=\"font-mono\">{selectedEvent.classification_ms}ms</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">总执行时间</div>\n <div className=\"font-mono\">\n {selectedEvent.total_execution_ms\n ? `${(selectedEvent.total_execution_ms / 1000).toFixed(2)}s`\n : '-'}\n </div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">完成原因</div>\n <div>{selectedEvent.completion_reason || '-'}</div>\n </div>\n </div>\n\n {selectedEvent.refusal_reason && (\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">违抗原因</div>\n <div className=\"bg-red-50 rounded p-3 text-sm text-red-700\">\n {selectedEvent.refusal_reason}\n </div>\n </div>\n )}\n\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">Session</div>\n <div className=\"text-xs font-mono text-gray-700\">{selectedEvent.session_id}</div>\n </div>\n </div>\n )\n })()}\n </Drawer>\n </div>\n )\n}\n"],"names":["fetchRoutingEvents","filter","url","res","filters","ExecutionTrace","setFilter","useState","search","setSearch","selectedEvent","setSelectedEvent","sseConnected","setSseConnected","showExportMenu","setShowExportMenu","toast","useToast","queryClient","useQueryClient","useEffect","eventSource","e","events","isLoading","useQuery","filteredEvents","useMemo","q","_a","_b","_c","handleExport","exportFormat","ts","getTimestamp","downloadJSON","flat","intent","format","downloadCSV","jsxs","jsx","Fragment","Wifi","WifiOff","SearchInput","f","clsx","v","Download","CheckCircle","XCircle","HelpCircle","Activity","Drawer","CodeBlock"],"mappings":"mhBAgCA,eAAeA,EAAmBC,EAA0C,CAC1E,IAAIC,EAAM,gCACND,IAAW,SAAUC,GAAO,YACvBD,IAAW,UAAWC,GAAO,YAC7BD,IAAW,YAAWC,GAAO,gBACtC,MAAMC,EAAM,MAAM,MAAMD,CAAG,EAC3B,GAAI,CAACC,EAAI,GAAI,MAAM,IAAI,MAAM,iBAAiB,EAC9C,OAAOA,EAA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ACL,EACF,CAEJ"}
@@ -0,0 +1,2 @@
1
+ import{j as s}from"./react-vendor-CSp-GLFF.js";import{N as n,O as i}from"./vendor-CMMjVdZs.js";import{h as d,o as c}from"./syntax-highlighter-44FakypI.js";function p({content:m,className:x=""}){return s.jsx("div",{className:`prose prose-sm max-w-none ${x}`,children:s.jsx(n,{remarkPlugins:[i],components:{code({inline:e,className:t,children:r,...o}){const a=/language-(\w+)/.exec(t||""),l=a==null?void 0:a[1];return!e&&l?s.jsx(d,{style:c,language:l,PreTag:"div",customStyle:{margin:0,borderRadius:"6px",fontSize:"12px",padding:"12px"},...o,children:String(r).replace(/\n$/,"")}):s.jsx("code",{className:"bg-gray-100 text-gray-800 px-1 py-0.5 rounded text-xs font-mono",...o,children:r})},h1:({children:e})=>s.jsx("h1",{className:"text-lg font-bold text-gray-900 mt-4 mb-2",children:e}),h2:({children:e})=>s.jsx("h2",{className:"text-base font-bold text-gray-900 mt-3 mb-2",children:e}),h3:({children:e})=>s.jsx("h3",{className:"text-sm font-semibold text-gray-900 mt-2 mb-1",children:e}),p:({children:e})=>s.jsx("p",{className:"text-sm text-gray-700 my-2",children:e}),ul:({children:e})=>s.jsx("ul",{className:"list-disc list-inside text-sm text-gray-700 my-2 space-y-0.5",children:e}),ol:({children:e})=>s.jsx("ol",{className:"list-decimal list-inside text-sm text-gray-700 my-2 space-y-0.5",children:e}),li:({children:e})=>s.jsx("li",{className:"text-sm",children:e}),a:({children:e,href:t})=>s.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-indigo-600 hover:text-indigo-700 underline",children:e}),blockquote:({children:e})=>s.jsx("blockquote",{className:"border-l-4 border-gray-300 pl-3 italic text-gray-600 my-2",children:e}),table:({children:e})=>s.jsx("div",{className:"overflow-x-auto my-2",children:s.jsx("table",{className:"min-w-full border border-gray-200 text-sm",children:e})}),th:({children:e})=>s.jsx("th",{className:"border border-gray-200 px-2 py-1 bg-gray-50 font-semibold text-left",children:e}),td:({children:e})=>s.jsx("td",{className:"border border-gray-200 px-2 py-1",children:e})},children:m})})}export{p as M};
2
+ //# sourceMappingURL=MarkdownRenderer-CCIz1MOz.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkdownRenderer-CCIz1MOz.js","sources":["../../src/components/MarkdownRenderer.tsx"],"sourcesContent":["import ReactMarkdown from 'react-markdown'\nimport remarkGfm from 'remark-gfm'\nimport { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'\nimport { oneLight } from 'react-syntax-highlighter/dist/esm/styles/prism'\n\ninterface Props {\n content: string\n className?: string\n}\n\nexport default function MarkdownRenderer({ content, className = '' }: Props) {\n return (\n <div className={`prose prose-sm max-w-none ${className}`}>\n <ReactMarkdown\n remarkPlugins={[remarkGfm]}\n components={{\n code({ inline, className, children, ...props }: any) {\n const match = /language-(\\w+)/.exec(className || '')\n const lang = match?.[1]\n if (!inline && lang) {\n return (\n <SyntaxHighlighter\n style={oneLight}\n language={lang}\n PreTag=\"div\"\n customStyle={{\n margin: 0,\n borderRadius: '6px',\n fontSize: '12px',\n padding: '12px',\n }}\n {...props}\n >\n {String(children).replace(/\\n$/, '')}\n </SyntaxHighlighter>\n )\n }\n return (\n <code\n className=\"bg-gray-100 text-gray-800 px-1 py-0.5 rounded text-xs font-mono\"\n {...props}\n >\n {children}\n </code>\n )\n },\n h1: ({ children }) => <h1 className=\"text-lg font-bold text-gray-900 mt-4 mb-2\">{children}</h1>,\n h2: ({ children }) => <h2 className=\"text-base font-bold text-gray-900 mt-3 mb-2\">{children}</h2>,\n h3: ({ children }) => <h3 className=\"text-sm font-semibold text-gray-900 mt-2 mb-1\">{children}</h3>,\n p: ({ children }) => <p className=\"text-sm text-gray-700 my-2\">{children}</p>,\n ul: ({ children }) => <ul className=\"list-disc list-inside text-sm text-gray-700 my-2 space-y-0.5\">{children}</ul>,\n ol: ({ children }) => <ol className=\"list-decimal list-inside text-sm text-gray-700 my-2 space-y-0.5\">{children}</ol>,\n li: ({ children }) => <li className=\"text-sm\">{children}</li>,\n a: ({ children, href }) => (\n <a href={href} target=\"_blank\" rel=\"noopener noreferrer\" className=\"text-indigo-600 hover:text-indigo-700 underline\">\n {children}\n </a>\n ),\n blockquote: ({ children }) => (\n <blockquote className=\"border-l-4 border-gray-300 pl-3 italic text-gray-600 my-2\">\n {children}\n </blockquote>\n ),\n table: ({ children }) => (\n <div className=\"overflow-x-auto my-2\">\n <table className=\"min-w-full border border-gray-200 text-sm\">{children}</table>\n </div>\n ),\n th: ({ children }) => <th className=\"border border-gray-200 px-2 py-1 bg-gray-50 font-semibold text-left\">{children}</th>,\n td: ({ children }) => <td className=\"border border-gray-200 px-2 py-1\">{children}</td>,\n }}\n >\n {content}\n </ReactMarkdown>\n </div>\n )\n}\n"],"names":["MarkdownRenderer","content","className","jsx","ReactMarkdown","remarkGfm","inline","children","props","match","lang","SyntaxHighlighter","oneLight","href"],"mappings":"2JAUA,SAAwBA,EAAiB,CAAE,QAAAC,EAAS,UAAAC,EAAY,IAAa,CAC3E,OACEC,EAAAA,IAAC,MAAA,CAAI,UAAW,6BAA6BD,CAAS,GACpD,SAAAC,EAAAA,IAACC,EAAA,CACC,cAAe,CAACC,CAAS,EACzB,WAAY,CACV,KAAK,CAAE,OAAAC,EAAQ,UAAAJ,EAAW,SAAAK,EAAU,GAAGC,GAAc,CACnD,MAAMC,EAAQ,iBAAiB,KAAKP,GAAa,EAAE,EAC7CQ,EAAOD,GAAA,YAAAA,EAAQ,GACrB,MAAI,CAACH,GAAUI,EAEXP,EAAAA,IAACQ,EAAA,CACC,MAAOC,EACP,SAAUF,EACV,OAAO,MACP,YAAa,CACX,OAAQ,EACR,aAAc,MACd,SAAU,OACV,QAAS,MAAA,EAEV,GAAGF,EAEH,SAAA,OAAOD,CAAQ,EAAE,QAAQ,MAAO,EAAE,CAAA,CAAA,EAKvCJ,EAAAA,IAAC,OAAA,CACC,UAAU,kEACT,GAAGK,EAEH,SAAAD,CAAA,CAAA,CAGP,EACA,GAAI,CAAC,CAAE,SA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AI,CAAA,CAAS,CAAA,EAGlF,SAAAN,CAAA,CAAA,EAEL,CAEJ"}
@@ -0,0 +1,2 @@
1
+ import{r as u,j as e}from"./react-vendor-CSp-GLFF.js";import{b as M,u as k,c as j}from"./query-C99w429o.js";import{L as T}from"./react-router-I-HqunH7.js";import{d as m}from"./vendor-CMMjVdZs.js";import{u as q,a as $}from"./index-DUYj2ek1.js";import{P as D,G as C,C as S,n as E,g as P,c as F,e as I,d as K,o as Q,p as L,f as O}from"./lucide-DjB4fWNj.js";import{a as X,z}from"./date-fns-CZ_bHujz.js";import"./syntax-highlighter-44FakypI.js";async function B(){const t=await fetch("/api/methodology-executions?limit=50");if(!t.ok)throw new Error("Failed to fetch");return t.json()}async function A(){const t=await fetch("/api/methodologies");if(!t.ok)throw new Error("Failed to fetch methodologies");return t.json()}async function G(t){const a=await fetch(`/api/methodology-executions/${t}/cancel`,{method:"POST"});if(!a.ok){const l=await a.json().catch(()=>({}));throw new Error(l.error||"Cancel failed")}}async function H(t){if(!(await fetch(`/api/methodology-executions/${t}`,{method:"DELETE"})).ok)throw new Error("Delete failed")}async function J(t){const a=await fetch("/api/methodology-executions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){const l=await a.json().catch(()=>({}));throw new Error(l.error||`Start failed (HTTP ${a.status})`)}return a.json()}const R={"harness-engineering":"Harness Engineering",bmad:"BMad (敏捷开发)"};function re(){const t=M(),a=q(),l=$(),[p,i]=u.useState(!1),{data:r,isLoading:f,error:o}=k({queryKey:["methodology-executions"],queryFn:B,refetchInterval:5e3}),{data:y}=k({queryKey:["methodologies"],queryFn:A}),c=j({mutationFn:G,onSuccess:()=>{a.success("方法论执行已取消"),t.invalidateQueries({queryKey:["methodology-executions"]})},onError:s=>a.error(`取消失败: ${s.message}`)}),h=j({mutationFn:H,onSuccess:()=>{a.success("记录已删除"),t.invalidateQueries({queryKey:["methodology-executions"]})},onError:s=>a.error(`删除失败: ${s.message}`)}),x=j({mutationFn:J,onSuccess:s=>{a.success(`已启动执行 #${s.id}`),i(!1),t.invalidateQueries({queryKey:["methodology-executions"]})},onError:s=>a.error(`启动失败: ${s.message}`)}),g=async s=>{await l({title:"取消方法论执行",message:"确定要取消这个运行中的方法论吗?已完成的阶段不会受影响,但当前进行中的阶段将停止。",confirmText:"确认取消",variant:"warning"})&&c.mutate(s)},n=async s=>{await l({title:"删除执行记录",message:"确定要删除这条方法论执行记录吗?此操作不可恢复。",confirmText:"删除",variant:"danger"})&&h.mutate(s)};if(f)return 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:"加载中..."})})]});if(o)return 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:["加载失败: ",o.message]})})]});const N=(r==null?void 0:r.filter(s=>s.status==="running").length)||0,w=(r==null?void 0:r.filter(s=>s.status==="completed").length)||0;return 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:"方法论执行"}),e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("span",{className:"text-gray-500",children:["共 ",(r==null?void 0:r.length)||0," 个实例"]}),N>0&&e.jsxs("span",{className:"text-blue-600",children:["· 运行中 ",N]}),w>0&&e.jsxs("span",{className:"text-green-600",children:["· 已完成 ",w]}),e.jsxs("button",{onClick:()=>i(!0),className:"ml-3 inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-indigo-600 text-white rounded-md hover:bg-indigo-700",children:[e.jsx(D,{className:"h-4 w-4"})," 新建执行"]})]})]}),p&&e.jsx(U,{methodologies:y??[],onCancel:()=>i(!1),onSubmit:s=>x.mutate(s),submitting:x.isPending}),e.jsxs("div",{className:"space-y-4",children:[r==null?void 0:r.map(s=>{const d=JSON.parse(s.plan_json),v=d.phases[s.current_phase_index],_=s.status==="completed"?100:Math.round(s.current_phase_index/d.phases.length*100);return e.jsx("div",{className:"bg-white rounded-lg shadow",children:e.jsxs("div",{className:"p-6 flex items-start justify-between gap-4",children:[e.jsxs(T,{to:`/methodologies/${s.id}`,className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(C,{className:"h-5 w-5 text-indigo-600 flex-shrink-0"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:R[s.methodology_id]||s.methodology_id}),e.jsxs("span",{className:m("px-2 py-1 text-xs font-medium rounded-full",s.status==="running"&&"bg-blue-100 text-blue-700",s.status==="completed"&&"bg-green-100 text-green-700",s.status==="failed"&&"bg-red-100 text-red-700",s.status==="cancelled"&&"bg-gray-100 text-gray-600"),children:[s.status==="running"&&"运行中",s.status==="completed"&&"已完成",s.status==="failed"&&"失败",s.status==="cancelled"&&"已取消"]}),s.mode&&e.jsxs("span",{className:m("inline-flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full",s.mode==="background"?"bg-purple-100 text-purple-700":"bg-sky-100 text-sky-700"),title:s.mode==="background"?"独立 claude -p 子进程":"主会话内执行",children:[s.mode==="background"?e.jsx(S,{className:"h-3 w-3"}):e.jsx(E,{className:"h-3 w-3"}),s.mode==="background"?"后台":"前台"]})]}),e.jsxs("p",{className:"text-sm text-gray-600 mb-3 font-mono",children:["Session: ",s.session_id.slice(0,12),"..."]}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-1.5 mb-3",children:e.jsx("div",{className:m("h-1.5 rounded-full transition-all",s.status==="completed"?"bg-green-500":s.status==="cancelled"?"bg-gray-400":"bg-indigo-600"),style:{width:`${_}%`}})}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-500",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(P,{className:"h-4 w-4"}),X(s.started_at,{addSuffix:!0,locale:z})]}),s.status==="running"&&v&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F,{className:"h-4 w-4"}),"Phase ",s.current_phase_index+1,"/",d.phases.length,": ",v.id]}),s.status==="completed"&&e.jsxs("div",{className:"flex items-center gap-1 text-green-600",children:[e.jsx(I,{className:"h-4 w-4"}),"完成 ",d.phases.length," 个阶段"]}),s.status==="cancelled"&&e.jsxs("div",{className:"flex items-center gap-1 text-gray-500",children:[e.jsx(K,{className:"h-4 w-4"}),"已取消于 Phase ",s.current_phase_index+1]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.status==="running"&&e.jsx("button",{onClick:b=>{b.preventDefault(),g(s.id)},className:"p-2 text-orange-600 hover:bg-orange-50 rounded-md",title:"取消执行",children:e.jsx(Q,{className:"h-4 w-4"})}),s.status!=="running"&&e.jsx("button",{onClick:b=>{b.preventDefault(),n(s.id)},className:"p-2 text-gray-500 hover:bg-red-50 hover:text-red-600 rounded-md",title:"删除记录",children:e.jsx(L,{className:"h-4 w-4"})})]})]})},s.id)}),(!r||r.length===0)&&e.jsxs("div",{className:"bg-white rounded-lg shadow p-12 text-center",children:[e.jsx(C,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600",children:"暂无方法论执行记录"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:'当你输入复杂任务(如"重构 XXX 模块")时,系统会自动匹配方法论并生成执行计划'})]})]})]})}function U({methodologies:t,submitting:a,onSubmit:l,onCancel:p}){var g;const i=`manual-${Date.now().toString(36)}`,[r,f]=u.useState(i),[o,y]=u.useState(((g=t[0])==null?void 0:g.id)??""),[c,h]=u.useState("background"),x=n=>{n.preventDefault(),!(!r.trim()||!o)&&l({session_id:r.trim(),methodology_id:o,mode:c})};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:e.jsxs("form",{onSubmit:x,className:"w-full max-w-md bg-white rounded-lg shadow-xl border border-gray-200",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-gray-100",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"新建方法论执行"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"选择方法论模板和执行模式"})]}),e.jsxs("div",{className:"px-5 py-4 space-y-4 text-sm",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-gray-700",children:"方法论"}),e.jsxs("select",{className:"mt-1 w-full border border-gray-300 rounded-md px-2 py-1.5",value:o,onChange:n=>y(n.target.value),required:!0,children:[t.length===0&&e.jsx("option",{value:"",children:"(未发现方法论)"}),t.map(n=>e.jsx("option",{value:n.id,children:n.name||n.id},n.id))]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-gray-700",children:"Session ID"}),e.jsx("input",{type:"text",className:"mt-1 w-full border border-gray-300 rounded-md px-2 py-1.5 font-mono text-xs",value:r,onChange:n=>f(n.target.value),required:!0}),e.jsx("span",{className:"mt-1 block text-xs text-gray-500",children:"后台模式下用于追踪;建议保留默认或自定义一个可识别值"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-700",children:"执行模式"}),e.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>h("background"),className:m("rounded-md border px-3 py-2 text-left",c==="background"?"border-indigo-500 bg-indigo-50":"border-gray-200 hover:border-gray-300"),children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium text-gray-900",children:[e.jsx(S,{className:"h-4 w-4 text-purple-600"})," 后台"]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"独立 claude -p 子进程,无需用户在主会话输入"})]}),e.jsxs("button",{type:"button",onClick:()=>h("foreground"),className:m("rounded-md border px-3 py-2 text-left",c==="foreground"?"border-indigo-500 bg-indigo-50":"border-gray-200 hover:border-gray-300"),children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium text-gray-900",children:[e.jsx(E,{className:"h-4 w-4 text-sky-600"})," 前台"]}),e.jsxs("p",{className:"text-xs text-amber-700 mt-1 flex items-start gap-1",children:[e.jsx(O,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsxs("span",{children:["需要你在主会话里输入任意内容才会推进;期间可用 ",e.jsx("code",{className:"px-1 rounded bg-amber-50",children:"/forge methodology status"})," 查看"]})]})]})]})]})]}),e.jsxs("div",{className:"px-5 py-3 border-t border-gray-100 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:p,className:"px-3 py-1.5 text-sm text-gray-700 hover:bg-gray-100 rounded-md",children:"取消"}),e.jsx("button",{type:"submit",disabled:a||!o,className:"inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-indigo-600 text-white rounded-md hover:bg-indigo-700 disabled:opacity-50",children:a?"启动中...":"启动"})]})]})})}export{re as default};
2
+ //# sourceMappingURL=Methodologies-CAXUXeox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Methodologies-CAXUXeox.js","sources":["../../src/pages/Methodologies.tsx"],"sourcesContent":["import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'\nimport { Link } from 'react-router-dom'\nimport { useState } from 'react'\nimport { formatDistanceToNow } from 'date-fns'\nimport { zhCN } from 'date-fns/locale'\nimport { GitBranch, Clock, CheckCircle, AlertCircle, XCircle, Trash2, StopCircle, Plus, Monitor, Cpu, AlertTriangle } from 'lucide-react'\nimport clsx from 'clsx'\nimport { useToast } from '../components/Toast'\nimport { useConfirm } from '../components/Confirm'\n\ninterface MethodologyExecution {\n id: number\n session_id: string\n methodology_id: string\n plan_json: string\n current_phase_index: number\n status: 'running' | 'completed' | 'failed' | 'cancelled'\n mode?: 'foreground' | 'background'\n worker_pid?: number | null\n worker_session_id?: string | null\n started_at: number\n completed_at: number | null\n}\n\ninterface MethodologyMeta {\n id: string\n name: string\n description?: string\n}\n\nasync function fetchMethodologyExecutions(): Promise<MethodologyExecution[]> {\n const res = await fetch('/api/methodology-executions?limit=50')\n if (!res.ok) throw new Error('Failed to fetch')\n return res.json()\n}\n\nasync function fetchMethodologies(): Promise<MethodologyMeta[]> {\n const res = await fetch('/api/methodologies')\n if (!res.ok) throw new Error('Failed to fetch methodologies')\n return res.json()\n}\n\nasync function cancelExecution(id: number): Promise<void> {\n const res = await fetch(`/api/methodology-executions/${id}/cancel`, { method: 'POST' })\n if (!res.ok) {\n const data = await res.json().catch(() => ({}))\n throw new Error(data.error || 'Cancel failed')\n }\n}\n\nasync function deleteExecution(id: number): Promise<void> {\n const res = await fetch(`/api/methodology-executions/${id}`, { method: 'DELETE' })\n if (!res.ok) throw new Error('Delete failed')\n}\n\nasync function startExecution(payload: {\n session_id: string\n methodology_id: string\n mode: 'foreground' | 'background'\n}): Promise<{ id: number }> {\n const res = await fetch('/api/methodology-executions', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n })\n if (!res.ok) {\n const data = await res.json().catch(() => ({}))\n throw new Error(data.error || `Start failed (HTTP ${res.status})`)\n }\n return res.json()\n}\n\nconst methodologyNames: Record<string, string> = {\n 'harness-engineering': 'Harness Engineering',\n 'bmad': 'BMad (敏捷开发)',\n}\n\nexport default function Methodologies() {\n const queryClient = useQueryClient()\n const toast = useToast()\n const confirm = useConfirm()\n const [showStart, setShowStart] = useState(false)\n\n const { data: executions, isLoading, error } = useQuery({\n queryKey: ['methodology-executions'],\n queryFn: fetchMethodologyExecutions,\n refetchInterval: 5000,\n })\n\n const { data: methodologies } = useQuery({\n queryKey: ['methodologies'],\n queryFn: fetchMethodologies,\n })\n\n const cancelMutation = useMutation({\n mutationFn: cancelExecution,\n onSuccess: () => {\n toast.success('方法论执行已取消')\n queryClient.invalidateQueries({ queryKey: ['methodology-executions'] })\n },\n onError: (e: Error) => toast.error(`取消失败: ${e.message}`),\n })\n\n const deleteMutation = useMutation({\n mutationFn: deleteExecution,\n onSuccess: () => {\n toast.success('记录已删除')\n queryClient.invalidateQueries({ queryKey: ['methodology-executions'] })\n },\n onError: (e: Error) => toast.error(`删除失败: ${e.message}`),\n })\n\n const startMutation = useMutation({\n mutationFn: startExecution,\n onSuccess: (data) => {\n toast.success(`已启动执行 #${data.id}`)\n setShowStart(false)\n queryClient.invalidateQueries({ queryKey: ['methodology-executions'] })\n },\n onError: (e: Error) => toast.error(`启动失败: ${e.message}`),\n })\n\n const handleCancel = async (id: number) => {\n const ok = await confirm({\n title: '取消方法论执行',\n message: '确定要取消这个运行中的方法论吗?已完成的阶段不会受影响,但当前进行中的阶段将停止。',\n confirmText: '确认取消',\n variant: 'warning',\n })\n if (ok) cancelMutation.mutate(id)\n }\n\n const handleDelete = async (id: number) => {\n const ok = await confirm({\n title: '删除执行记录',\n message: '确定要删除这条方法论执行记录吗?此操作不可恢复。',\n confirmText: '删除',\n variant: 'danger',\n })\n if (ok) deleteMutation.mutate(id)\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 const runningCount = executions?.filter(e => e.status === 'running').length || 0\n const completedCount = executions?.filter(e => e.status === 'completed').length || 0\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\">方法论执行</h1>\n <div className=\"flex items-center gap-4 text-sm\">\n <span className=\"text-gray-500\">共 {executions?.length || 0} 个实例</span>\n {runningCount > 0 && <span className=\"text-blue-600\">· 运行中 {runningCount}</span>}\n {completedCount > 0 && <span className=\"text-green-600\">· 已完成 {completedCount}</span>}\n <button\n onClick={() => setShowStart(true)}\n className=\"ml-3 inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-indigo-600 text-white rounded-md hover:bg-indigo-700\"\n >\n <Plus className=\"h-4 w-4\" /> 新建执行\n </button>\n </div>\n </div>\n\n {showStart && (\n <StartExecutionModal\n methodologies={methodologies ?? []}\n onCancel={() => setShowStart(false)}\n onSubmit={(payload) => startMutation.mutate(payload)}\n submitting={startMutation.isPending}\n />\n )}\n\n <div className=\"space-y-4\">\n {executions?.map((execution) => {\n const plan = JSON.parse(execution.plan_json)\n const currentPhase = plan.phases[execution.current_phase_index]\n const progress = execution.status === 'completed'\n ? 100\n : Math.round((execution.current_phase_index / plan.phases.length) * 100)\n\n return (\n <div key={execution.id} className=\"bg-white rounded-lg shadow\">\n <div className=\"p-6 flex items-start justify-between gap-4\">\n <Link to={`/methodologies/${execution.id}`} className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-3 mb-2\">\n <GitBranch className=\"h-5 w-5 text-indigo-600 flex-shrink-0\" />\n <h3 className=\"text-lg font-semibold text-gray-900\">\n {methodologyNames[execution.methodology_id] || execution.methodology_id}\n </h3>\n <span className={clsx(\n 'px-2 py-1 text-xs font-medium rounded-full',\n execution.status === 'running' && 'bg-blue-100 text-blue-700',\n execution.status === 'completed' && 'bg-green-100 text-green-700',\n execution.status === 'failed' && 'bg-red-100 text-red-700',\n execution.status === 'cancelled' && 'bg-gray-100 text-gray-600'\n )}>\n {execution.status === 'running' && '运行中'}\n {execution.status === 'completed' && '已完成'}\n {execution.status === 'failed' && '失败'}\n {execution.status === 'cancelled' && '已取消'}\n </span>\n {execution.mode && (\n <span\n className={clsx(\n 'inline-flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full',\n execution.mode === 'background'\n ? 'bg-purple-100 text-purple-700'\n : 'bg-sky-100 text-sky-700'\n )}\n title={execution.mode === 'background' ? '独立 claude -p 子进程' : '主会话内执行'}\n >\n {execution.mode === 'background' ? <Cpu className=\"h-3 w-3\" /> : <Monitor className=\"h-3 w-3\" />}\n {execution.mode === 'background' ? '后台' : '前台'}\n </span>\n )}\n </div>\n\n <p className=\"text-sm text-gray-600 mb-3 font-mono\">\n Session: {execution.session_id.slice(0, 12)}...\n </p>\n\n {/* Progress bar */}\n <div className=\"w-full bg-gray-200 rounded-full h-1.5 mb-3\">\n <div\n className={clsx(\n 'h-1.5 rounded-full transition-all',\n execution.status === 'completed' ? 'bg-green-500' :\n execution.status === 'cancelled' ? 'bg-gray-400' : 'bg-indigo-600'\n )}\n style={{ width: `${progress}%` }}\n />\n </div>\n\n <div className=\"flex items-center gap-4 text-sm text-gray-500\">\n <div className=\"flex items-center gap-1\">\n <Clock className=\"h-4 w-4\" />\n {formatDistanceToNow(execution.started_at, { addSuffix: true, locale: zhCN })}\n </div>\n {execution.status === 'running' && currentPhase && (\n <div className=\"flex items-center gap-1\">\n <AlertCircle className=\"h-4 w-4\" />\n Phase {execution.current_phase_index + 1}/{plan.phases.length}: {currentPhase.id}\n </div>\n )}\n {execution.status === 'completed' && (\n <div className=\"flex items-center gap-1 text-green-600\">\n <CheckCircle className=\"h-4 w-4\" />\n 完成 {plan.phases.length} 个阶段\n </div>\n )}\n {execution.status === 'cancelled' && (\n <div className=\"flex items-center gap-1 text-gray-500\">\n <XCircle className=\"h-4 w-4\" />\n 已取消于 Phase {execution.current_phase_index + 1}\n </div>\n )}\n </div>\n </Link>\n\n {/* Actions */}\n <div className=\"flex items-center gap-1 flex-shrink-0\">\n {execution.status === 'running' && (\n <button\n onClick={(e) => {\n e.preventDefault()\n handleCancel(execution.id)\n }}\n className=\"p-2 text-orange-600 hover:bg-orange-50 rounded-md\"\n title=\"取消执行\"\n >\n <StopCircle className=\"h-4 w-4\" />\n </button>\n )}\n {execution.status !== 'running' && (\n <button\n onClick={(e) => { e.preventDefault(); handleDelete(execution.id) }}\n className=\"p-2 text-gray-500 hover:bg-red-50 hover:text-red-600 rounded-md\"\n title=\"删除记录\"\n >\n <Trash2 className=\"h-4 w-4\" />\n </button>\n )}\n </div>\n </div>\n </div>\n )\n })}\n\n {(!executions || executions.length === 0) && (\n <div className=\"bg-white rounded-lg shadow p-12 text-center\">\n <GitBranch className=\"h-12 w-12 text-gray-400 mx-auto mb-4\" />\n <p className=\"text-gray-600\">暂无方法论执行记录</p>\n <p className=\"text-xs text-gray-500 mt-2\">\n 当你输入复杂任务(如\"重构 XXX 模块\")时,系统会自动匹配方法论并生成执行计划\n </p>\n </div>\n )}\n </div>\n </div>\n )\n}\n\ninterface StartExecutionModalProps {\n methodologies: MethodologyMeta[]\n submitting: boolean\n onSubmit: (payload: { session_id: string; methodology_id: string; mode: 'foreground' | 'background' }) => void\n onCancel: () => void\n}\n\nfunction StartExecutionModal({ methodologies, submitting, onSubmit, onCancel }: StartExecutionModalProps) {\n const defaultSession = `manual-${Date.now().toString(36)}`\n const [sessionId, setSessionId] = useState(defaultSession)\n const [methodologyId, setMethodologyId] = useState(methodologies[0]?.id ?? '')\n const [mode, setMode] = useState<'foreground' | 'background'>('background')\n\n const submit = (e: React.FormEvent) => {\n e.preventDefault()\n if (!sessionId.trim() || !methodologyId) return\n onSubmit({ session_id: sessionId.trim(), methodology_id: methodologyId, mode })\n }\n\n return (\n <div className=\"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4\">\n <form\n onSubmit={submit}\n className=\"w-full max-w-md bg-white rounded-lg shadow-xl border border-gray-200\"\n >\n <div className=\"px-5 py-4 border-b border-gray-100\">\n <h2 className=\"text-lg font-semibold text-gray-900\">新建方法论执行</h2>\n <p className=\"text-xs text-gray-500 mt-0.5\">选择方法论模板和执行模式</p>\n </div>\n\n <div className=\"px-5 py-4 space-y-4 text-sm\">\n <label className=\"block\">\n <span className=\"text-gray-700\">方法论</span>\n <select\n className=\"mt-1 w-full border border-gray-300 rounded-md px-2 py-1.5\"\n value={methodologyId}\n onChange={(e) => setMethodologyId(e.target.value)}\n required\n >\n {methodologies.length === 0 && <option value=\"\">(未发现方法论)</option>}\n {methodologies.map(m => (\n <option key={m.id} value={m.id}>{m.name || m.id}</option>\n ))}\n </select>\n </label>\n\n <label className=\"block\">\n <span className=\"text-gray-700\">Session ID</span>\n <input\n type=\"text\"\n className=\"mt-1 w-full border border-gray-300 rounded-md px-2 py-1.5 font-mono text-xs\"\n value={sessionId}\n onChange={(e) => setSessionId(e.target.value)}\n required\n />\n <span className=\"mt-1 block text-xs text-gray-500\">\n 后台模式下用于追踪;建议保留默认或自定义一个可识别值\n </span>\n </label>\n\n <div>\n <span className=\"text-gray-700\">执行模式</span>\n <div className=\"mt-2 grid grid-cols-2 gap-2\">\n <button\n type=\"button\"\n onClick={() => setMode('background')}\n className={clsx(\n 'rounded-md border px-3 py-2 text-left',\n mode === 'background'\n ? 'border-indigo-500 bg-indigo-50'\n : 'border-gray-200 hover:border-gray-300'\n )}\n >\n <div className=\"flex items-center gap-2 font-medium text-gray-900\">\n <Cpu className=\"h-4 w-4 text-purple-600\" /> 后台\n </div>\n <p className=\"text-xs text-gray-500 mt-1\">\n 独立 claude -p 子进程,无需用户在主会话输入\n </p>\n </button>\n <button\n type=\"button\"\n onClick={() => setMode('foreground')}\n className={clsx(\n 'rounded-md border px-3 py-2 text-left',\n mode === 'foreground'\n ? 'border-indigo-500 bg-indigo-50'\n : 'border-gray-200 hover:border-gray-300'\n )}\n >\n <div className=\"flex items-center gap-2 font-medium text-gray-900\">\n <Monitor className=\"h-4 w-4 text-sky-600\" /> 前台\n </div>\n <p className=\"text-xs text-amber-700 mt-1 flex items-start gap-1\">\n <AlertTriangle className=\"h-3.5 w-3.5 mt-0.5 shrink-0\" />\n <span>需要你在主会话里输入任意内容才会推进;期间可用 <code className=\"px-1 rounded bg-amber-50\">/forge methodology status</code> 查看</span>\n </p>\n </button>\n </div>\n </div>\n </div>\n\n <div className=\"px-5 py-3 border-t border-gray-100 flex justify-end gap-2\">\n <button\n type=\"button\"\n onClick={onCancel}\n className=\"px-3 py-1.5 text-sm text-gray-700 hover:bg-gray-100 rounded-md\"\n >\n 取消\n </button>\n <button\n type=\"submit\"\n disabled={submitting || !methodologyId}\n className=\"inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-indigo-600 text-white rounded-md hover:bg-indigo-700 disabled:opacity-50\"\n >\n {submitting ? '启动中...' : '启动'}\n </button>\n </div>\n </form>\n </div>\n )\n}\n"],"names":["fetchMethodologyExecutions","res","fetchMethodologies","cancelExecution","id","data","deleteExecution","startExecution","payload","methodologyNames","Methodologies","queryClient","useQueryClient","toast","useToast","confirm","useConfirm","showStart","setShowStart","useState","executions","isLoading","error","useQuery","methodologies","cancelMutation","useMutation","e","deleteMutation","startMutation","handleCancel","handleDelete","jsx","jsxs","runningCount","completedCount","Plus","StartExecutionModal","execution","plan","currentPhase","progress","Link","GitBranch","clsx","Cpu","Monitor","Clock","formatDistanceToNow","zhCN","AlertCircle","CheckCircle","XCircle","StopCircle","Trash2","submitting","onSubmit","onCancel","defaultSession","sessionId","setSessionId","methodologyId","setMethodologyId","_a","mode","setMode","submit","m","AlertTriangle"],"mappings":"wbA8BA,eAAeA,GAA8D,CAC3E,MAAMC,EAAM,MAAM,MAAM,sCAAsC,EAC9D,GAAI,CAACA,EAAI,GAAI,MAAM,IAAI,MAAM,iBAAiB,EAC9C,OAAOA,EAAI,KAAA,CACb,CAEA,eAAeC,GAAiD,CAC9D,MAAMD,EAAM,MAAM,MAAM,oBAAoB,EAC5C,GAAI,CAACA,EAAI,GAAI,MAAM,IAAI,MAAM,+BAA+B,EAC5D,OAAOA,EAAI,KAAA,CACb,CAEA,eAAeE,EAAgBC,EAA2B,CACxD,MAAMH,EAAM,MAAM,MAAM,+BAA+BG,CAAE,UAAW,CAAE,OAAQ,OAAQ,EACtF,GAAI,CAACH,EAAI,GAAI,CACX,MAAMI,EAAO,MAAMJ,EAAI,KAAA,EAAO,MAAM,KAAO,CAAA,EAAG,EAC9C,MAAM,IAAI,MAAMI,EAAK,OAAS,eAAe,CAC/C,CACF,CAEA,eAAeC,EAAgBF,EAA2B,CAExD,GAAI,EADQ,MAAM,MAAM,+BAA+BA,CAAE,GAAI,CAAE,OAAQ,SAAU,GACxE,G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