@winspan/claude-forge 8.33.3 → 8.34.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.
- package/dist/agents/definition.d.ts +3 -0
- package/dist/agents/definition.d.ts.map +1 -1
- package/dist/agents/definition.js +3 -0
- package/dist/agents/definition.js.map +1 -1
- package/dist/agents/official-agents.d.ts.map +1 -1
- package/dist/agents/official-agents.js +6 -3
- package/dist/agents/official-agents.js.map +1 -1
- package/dist/agents/registry.d.ts +17 -1
- package/dist/agents/registry.d.ts.map +1 -1
- package/dist/agents/registry.js +106 -7
- package/dist/agents/registry.js.map +1 -1
- package/dist/cli/commands/executions.d.ts +3 -0
- package/dist/cli/commands/executions.d.ts.map +1 -0
- package/dist/cli/commands/executions.js +109 -0
- package/dist/cli/commands/executions.js.map +1 -0
- package/dist/cli/commands/skills.d.ts.map +1 -1
- package/dist/cli/commands/skills.js +83 -20
- package/dist/cli/commands/skills.js.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/core/storage/rows.d.ts +14 -0
- package/dist/core/storage/rows.d.ts.map +1 -1
- package/dist/core/storage/schema.sql +26 -0
- package/dist/core/storage/sqlite.d.ts +11 -2
- package/dist/core/storage/sqlite.d.ts.map +1 -1
- package/dist/core/storage/sqlite.js +32 -0
- package/dist/core/storage/sqlite.js.map +1 -1
- package/dist/daemon/handlers/stop.d.ts +5 -1
- package/dist/daemon/handlers/stop.d.ts.map +1 -1
- package/dist/daemon/handlers/stop.js +27 -1
- package/dist/daemon/handlers/stop.js.map +1 -1
- package/dist/daemon/handlers/user-prompt.d.ts +3 -1
- package/dist/daemon/handlers/user-prompt.d.ts.map +1 -1
- package/dist/daemon/handlers/user-prompt.js +37 -4
- package/dist/daemon/handlers/user-prompt.js.map +1 -1
- package/dist/daemon/index.d.ts.map +1 -1
- package/dist/daemon/index.js +10 -4
- package/dist/daemon/index.js.map +1 -1
- package/dist/daemon/routing-observer.d.ts.map +1 -1
- package/dist/daemon/routing-observer.js +25 -2
- package/dist/daemon/routing-observer.js.map +1 -1
- package/dist/engine/conventions/routing.yaml +11 -0
- package/dist/intelligence/execution-doc-builder.d.ts +61 -0
- package/dist/intelligence/execution-doc-builder.d.ts.map +1 -0
- package/dist/intelligence/execution-doc-builder.js +601 -0
- package/dist/intelligence/execution-doc-builder.js.map +1 -0
- package/dist/skills/invocation-guard.d.ts +45 -0
- package/dist/skills/invocation-guard.d.ts.map +1 -0
- package/dist/skills/invocation-guard.js +82 -0
- package/dist/skills/invocation-guard.js.map +1 -0
- package/dist/skills/registry.d.ts +22 -0
- package/dist/skills/registry.d.ts.map +1 -1
- package/dist/skills/registry.js +30 -2
- package/dist/skills/registry.js.map +1 -1
- package/dist/skills/tools/skill-invoke.d.ts +36 -0
- package/dist/skills/tools/skill-invoke.d.ts.map +1 -0
- package/dist/skills/tools/skill-invoke.js +82 -0
- package/dist/skills/tools/skill-invoke.js.map +1 -0
- package/dist/skills/tools/skill-list.d.ts +26 -0
- package/dist/skills/tools/skill-list.d.ts.map +1 -0
- package/dist/skills/tools/skill-list.js +35 -0
- package/dist/skills/tools/skill-list.js.map +1 -0
- package/dist/web/routes/ai.d.ts.map +1 -1
- package/dist/web/routes/ai.js +2 -7
- package/dist/web/routes/ai.js.map +1 -1
- package/dist/web/routes/execution-trace.d.ts +8 -0
- package/dist/web/routes/execution-trace.d.ts.map +1 -1
- package/dist/web/routes/execution-trace.js +46 -1
- package/dist/web/routes/execution-trace.js.map +1 -1
- package/dist/web/routes/routing.d.ts.map +1 -1
- package/dist/web/routes/routing.js +11 -1
- package/dist/web/routes/routing.js.map +1 -1
- package/dist/web/routes/skill-stats.d.ts +12 -0
- package/dist/web/routes/skill-stats.d.ts.map +1 -0
- package/dist/web/routes/skill-stats.js +72 -0
- package/dist/web/routes/skill-stats.js.map +1 -0
- package/dist/web/static/assets/{AIConfig-Dw13rVtT.js → AIConfig-DiUFET_Q.js} +2 -2
- package/dist/web/static/assets/{AIConfig-Dw13rVtT.js.map → AIConfig-DiUFET_Q.js.map} +1 -1
- package/dist/web/static/assets/{Agents-D1p3JhQs.js → Agents-bNNGbQnL.js} +2 -2
- package/dist/web/static/assets/{Agents-D1p3JhQs.js.map → Agents-bNNGbQnL.js.map} +1 -1
- package/dist/web/static/assets/{Dashboard-qUCxXFSI.js → Dashboard-Ciyyw6ph.js} +2 -2
- package/dist/web/static/assets/{Dashboard-qUCxXFSI.js.map → Dashboard-Ciyyw6ph.js.map} +1 -1
- package/dist/web/static/assets/{Drawer-DeKukfwJ.js → Drawer-DOUcx6m1.js} +2 -2
- package/dist/web/static/assets/{Drawer-DeKukfwJ.js.map → Drawer-DOUcx6m1.js.map} +1 -1
- package/dist/web/static/assets/{Events-DqzBTrly.js → Events-DQHP6Uaq.js} +2 -2
- package/dist/web/static/assets/{Events-DqzBTrly.js.map → Events-DQHP6Uaq.js.map} +1 -1
- package/dist/web/static/assets/ExecutionTrace-Co8ARdg-.js +3 -0
- package/dist/web/static/assets/ExecutionTrace-Co8ARdg-.js.map +1 -0
- package/dist/web/static/assets/{Methodologies-Br5KOWuF.js → Methodologies-CXNrDXwG.js} +2 -2
- package/dist/web/static/assets/{Methodologies-Br5KOWuF.js.map → Methodologies-CXNrDXwG.js.map} +1 -1
- package/dist/web/static/assets/{MethodologyDetail-Do1taSKM.js → MethodologyDetail-rV3W1utf.js} +2 -2
- package/dist/web/static/assets/{MethodologyDetail-Do1taSKM.js.map → MethodologyDetail-rV3W1utf.js.map} +1 -1
- package/dist/web/static/assets/{Routing-CFmM7JuB.js → Routing-BW3eGD-8.js} +2 -2
- package/dist/web/static/assets/{Routing-CFmM7JuB.js.map → Routing-BW3eGD-8.js.map} +1 -1
- package/dist/web/static/assets/{SessionDetail-DzTue2xK.js → SessionDetail-Cbd7Jwox.js} +2 -2
- package/dist/web/static/assets/{SessionDetail-DzTue2xK.js.map → SessionDetail-Cbd7Jwox.js.map} +1 -1
- package/dist/web/static/assets/{Sessions-DOd65EkN.js → Sessions-ZQSCgXyy.js} +2 -2
- package/dist/web/static/assets/{Sessions-DOd65EkN.js.map → Sessions-ZQSCgXyy.js.map} +1 -1
- package/dist/web/static/assets/{Skills-zacj_uSW.js → Skills-C5-5zOSH.js} +2 -2
- package/dist/web/static/assets/{Skills-zacj_uSW.js.map → Skills-C5-5zOSH.js.map} +1 -1
- package/dist/web/static/assets/{export-CEzDNM66.js → export-CbQTOt71.js} +2 -2
- package/dist/web/static/assets/{export-CEzDNM66.js.map → export-CbQTOt71.js.map} +1 -1
- package/dist/web/static/assets/{index-BVpUTHdp.js → index-DJK5beK6.js} +3 -3
- package/dist/web/static/assets/{index-BVpUTHdp.js.map → index-DJK5beK6.js.map} +1 -1
- package/dist/web/static/assets/index-phpuytMI.css +1 -0
- package/dist/web/static/assets/{lucide-DjB4fWNj.js → lucide-BanPULT1.js} +35 -40
- package/dist/web/static/assets/lucide-BanPULT1.js.map +1 -0
- package/dist/web/static/index.html +3 -3
- package/package.json +1 -1
- package/dist/web/static/assets/ExecutionTrace-Z-zlH0KH.js +0 -2
- package/dist/web/static/assets/ExecutionTrace-Z-zlH0KH.js.map +0 -1
- package/dist/web/static/assets/index-Drpf7sLl.css +0 -1
- package/dist/web/static/assets/lucide-DjB4fWNj.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e}from"./react-vendor-CSp-GLFF.js";import{u as c}from"./query-C99w429o.js";import{b as m}from"./react-router-I-HqunH7.js";import{A as o,e as h,f as p,T as g}from"./lucide-
|
|
2
|
-
//# sourceMappingURL=Routing-
|
|
1
|
+
import{j as e}from"./react-vendor-CSp-GLFF.js";import{u as c}from"./query-C99w429o.js";import{b as m}from"./react-router-I-HqunH7.js";import{A as o,e as h,f as p,T as g}from"./lucide-BanPULT1.js";import"./vendor-CMMjVdZs.js";async function y(){const a=await fetch("/api/routing/stats?window=168");if(!a.ok)throw new Error("Failed to fetch");return a.json()}function w(){var n,i;const a=m(),{data:t,isLoading:x}=c({queryKey:["routing-stats"],queryFn:y,refetchInterval:1e4});if(x)return e.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:"加载中..."});if(!t)return e.jsx("div",{className:"bg-white rounded-lg shadow p-6 text-red-600",children:"加载失败"});const d=t.obedienceRate!==null&&t.obedienceRate!==void 0?(t.obedienceRate*100).toFixed(1):"-",r=Object.entries(t.byAgent||{}).map(([s,l])=>({agent:s,...l,refusalRate:l.total>0?l.refused/l.total:null}));return e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-6",children:"Agent 路由"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-white rounded-lg shadow p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm text-gray-500",children:"总路由次数"}),e.jsx(o,{className:"h-4 w-4 text-gray-400"})]}),e.jsx("div",{className:"text-2xl font-bold text-gray-900",children:t.total}),e.jsx("div",{className:"text-xs text-gray-500 mt-1",children:"最近 7 天"})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm text-gray-500",children:"遵守率"}),e.jsx(h,{className:"h-4 w-4 text-green-500"})]}),e.jsxs("div",{className:"text-2xl font-bold text-gray-900",children:[d,"%"]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:[t.obeyedCount," / ",t.obeyedCount+t.refusedCount]})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm text-gray-500",children:"违抗率"}),e.jsx(p,{className:"h-4 w-4 text-red-500"})]}),e.jsxs("div",{className:"text-2xl font-bold text-gray-900",children:[t.refusalRate!==null&&t.refusalRate!==void 0?(t.refusalRate*100).toFixed(1):"-","%"]}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:[t.refusedCount," 次"]})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm text-gray-500",children:"平均分类耗时"}),e.jsx(g,{className:"h-4 w-4 text-blue-500"})]}),e.jsx("div",{className:"text-2xl font-bold text-gray-900",children:(n=t.latency)!=null&&n.p50?`${t.latency.p50}ms`:"-"}),e.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:["p95: ",(i=t.latency)!=null&&i.p95?`${t.latency.p95}ms`:"-"]})]})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow overflow-hidden",children:[e.jsx("div",{className:"px-6 py-4 border-b border-gray-200",children:e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:"按 Agent 统计"})}),e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"Agent"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"总次数"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"遵守"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"违抗"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase",children:"未判定"}),e.jsx("th",{className:"px-6 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:[r.map(s=>e.jsxs("tr",{className:"hover:bg-gray-50 cursor-pointer",onClick:()=>a(`/execution-trace?agent=${encodeURIComponent(s.agent)}`),children:[e.jsx("td",{className:"px-6 py-3 whitespace-nowrap",children:e.jsx("span",{className:"text-sm font-medium text-indigo-600",children:s.agent})}),e.jsx("td",{className:"px-6 py-3 whitespace-nowrap text-sm text-gray-700",children:s.total}),e.jsx("td",{className:"px-6 py-3 whitespace-nowrap text-sm text-green-600",children:s.obeyed}),e.jsx("td",{className:"px-6 py-3 whitespace-nowrap text-sm text-red-600",children:s.refused}),e.jsx("td",{className:"px-6 py-3 whitespace-nowrap text-sm text-gray-400",children:s.unknown}),e.jsx("td",{className:"px-6 py-3 whitespace-nowrap text-sm text-gray-700",children:s.refusalRate!==null?`${(s.refusalRate*100).toFixed(1)}%`:"-"})]},s.agent)),r.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-6 py-12 text-center text-gray-500",children:"暂无数据"})})]})]})]})]})}export{w as default};
|
|
2
|
+
//# sourceMappingURL=Routing-BW3eGD-8.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Routing-CFmM7JuB.js","sources":["../../src/pages/Routing.tsx"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\nimport { useNavigate } from 'react-router-dom'\nimport { TrendingUp, AlertTriangle, CheckCircle, Activity } from 'lucide-react'\n\ninterface AgentStats {\n total: number\n obeyed: number\n refused: number\n unknown: number\n}\n\ninterface RoutingStats {\n windowHours: number\n total: number\n forced: number\n obeyedCount: number\n refusedCount: number\n unknownCount: number\n obedienceRate: number | null\n refusalRate: number | null\n fallbackUsedCount?: number\n latency?: { p50?: number; p95?: number; p99?: number; count?: number }\n byAgent: Record<string, AgentStats>\n}\n\nasync function fetchRoutingStats(): Promise<RoutingStats> {\n const res = await fetch('/api/routing/stats?window=168')\n if (!res.ok) throw new Error('Failed to fetch')\n return res.json()\n}\n\nexport default function Routing() {\n const navigate = useNavigate()\n const { data: stats, isLoading } = useQuery({\n queryKey: ['routing-stats'],\n queryFn: fetchRoutingStats,\n refetchInterval: 10000,\n })\n\n if (isLoading) {\n return <div className=\"bg-white rounded-lg shadow p-6\">加载中...</div>\n }\n\n if (!stats) {\n return <div className=\"bg-white rounded-lg shadow p-6 text-red-600\">加载失败</div>\n }\n\n const obediencePercent = stats.obedienceRate !== null && stats.obedienceRate !== undefined\n ? (stats.obedienceRate * 100).toFixed(1)\n : '-'\n\n // 把 byAgent 对象转成数组\n const byAgentArray = Object.entries(stats.byAgent || {}).map(([agent, s]) => ({\n agent,\n ...s,\n refusalRate: s.total > 0 ? s.refused / s.total : null,\n }))\n\n return (\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900 mb-6\">Agent 路由</h1>\n\n {/* Stats cards */}\n <div className=\"grid grid-cols-1 md:grid-cols-4 gap-4 mb-6\">\n <div className=\"bg-white rounded-lg shadow p-5\">\n <div className=\"flex items-center justify-between mb-2\">\n <span className=\"text-sm text-gray-500\">总路由次数</span>\n <Activity className=\"h-4 w-4 text-gray-400\" />\n </div>\n <div className=\"text-2xl font-bold text-gray-900\">{stats.total}</div>\n <div className=\"text-xs text-gray-500 mt-1\">最近 7 天</div>\n </div>\n\n <div className=\"bg-white rounded-lg shadow p-5\">\n <div className=\"flex items-center justify-between mb-2\">\n <span className=\"text-sm text-gray-500\">遵守率</span>\n <CheckCircle className=\"h-4 w-4 text-green-500\" />\n </div>\n <div className=\"text-2xl font-bold text-gray-900\">{obediencePercent}%</div>\n <div className=\"text-xs text-gray-500 mt-1\">{stats.obeyedCount} / {stats.obeyedCount + stats.refusedCount}</div>\n </div>\n\n <div className=\"bg-white rounded-lg shadow p-5\">\n <div className=\"flex items-center justify-between mb-2\">\n <span className=\"text-sm text-gray-500\">违抗率</span>\n <AlertTriangle className=\"h-4 w-4 text-red-500\" />\n </div>\n <div className=\"text-2xl font-bold text-gray-900\">\n {stats.refusalRate !== null && stats.refusalRate !== undefined\n ? (stats.refusalRate * 100).toFixed(1)\n : '-'}%\n </div>\n <div className=\"text-xs text-gray-500 mt-1\">{stats.refusedCount} 次</div>\n </div>\n\n <div className=\"bg-white rounded-lg shadow p-5\">\n <div className=\"flex items-center justify-between mb-2\">\n <span className=\"text-sm text-gray-500\">平均分类耗时</span>\n <TrendingUp className=\"h-4 w-4 text-blue-500\" />\n </div>\n <div className=\"text-2xl font-bold text-gray-900\">\n {stats.latency?.p50 ? `${stats.latency.p50}ms` : '-'}\n </div>\n <div className=\"text-xs text-gray-500 mt-1\">\n p95: {stats.latency?.p95 ? `${stats.latency.p95}ms` : '-'}\n </div>\n </div>\n </div>\n\n {/* By Agent table */}\n <div className=\"bg-white rounded-lg shadow overflow-hidden\">\n <div className=\"px-6 py-4 border-b border-gray-200\">\n <h3 className=\"text-lg font-semibold text-gray-900\">按 Agent 统计</h3>\n </div>\n <table className=\"min-w-full divide-y divide-gray-200\">\n <thead className=\"bg-gray-50\">\n <tr>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">Agent</th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">总次数</th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">遵守</th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">违抗</th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">未判定</th>\n <th className=\"px-6 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 {byAgentArray.map((row) => (\n <tr\n key={row.agent}\n className=\"hover:bg-gray-50 cursor-pointer\"\n onClick={() => navigate(`/execution-trace?agent=${encodeURIComponent(row.agent)}`)}\n >\n <td className=\"px-6 py-3 whitespace-nowrap\">\n <span className=\"text-sm font-medium text-indigo-600\">{row.agent}</span>\n </td>\n <td className=\"px-6 py-3 whitespace-nowrap text-sm text-gray-700\">{row.total}</td>\n <td className=\"px-6 py-3 whitespace-nowrap text-sm text-green-600\">{row.obeyed}</td>\n <td className=\"px-6 py-3 whitespace-nowrap text-sm text-red-600\">{row.refused}</td>\n <td className=\"px-6 py-3 whitespace-nowrap text-sm text-gray-400\">{row.unknown}</td>\n <td className=\"px-6 py-3 whitespace-nowrap text-sm text-gray-700\">\n {row.refusalRate !== null ? `${(row.refusalRate * 100).toFixed(1)}%` : '-'}\n </td>\n </tr>\n ))}\n {byAgentArray.length === 0 && (\n <tr>\n <td colSpan={6} className=\"px-6 py-12 text-center text-gray-500\">暂无数据</td>\n </tr>\n )}\n </tbody>\n </table>\n </div>\n </div>\n )\n}\n"],"names":["fetchRoutingStats","res","Routing","navigate","useNavigate","stats","isLoading","useQuery","jsx","obediencePercent","byAgentArray","agent","s","jsxs","Activity","CheckCircle","AlertTriangle","TrendingUp","_a","_b","row"],"mappings":"iOAyBA,eAAeA,GAA2C,CACxD,MAAMC,EAAM,MAAM,MAAM,+BAA+B,EACvD,GAAI,CAACA,EAAI,GAAI,MAAM,IAAI,MAAM,iBAAiB,EAC9C,OAAOA,EAAI,KAAA,CACb,CAEA,SAAwBC,GAAU,SAChC,MAAMC,EAAWC,EAAA,EACX,CAAE,KAAMC,EAAO,UAAAC,CAAA,EAAcC,EAAS,CAC1C,SAAU,CAAC,eAAe,EAC1B,QAASP,EACT,gBAAiB,GAAA,CAClB,EAED,GAAIM,EACF,OAAOE,EAAAA,IAAC,MAAA,CAAI,UAAU,iCAAiC,SAAA,SAAM,EAG/D,GAAI,CAACH,EACH,OAAOG,EAAAA,IAAC,MAAA,CAAI,UAAU,8CAA8C,SAAA,OAAI,EAG1E,MAAMC,EAAmBJ,EAAM,gBAAkB,MAAQA,EAAM,gBAAkB,QAC5EA,EAAM,cAAgB,KAAK,QAAQ,CAAC,EACrC,IAGEK,EAAe,OAAO,QAAQL,EAAM,SAAW,EAAE,EAAE,IAAI,CAAC,CAACM,EAAOC,CAAC,KAAO,CAC5E,MAAAD,EACA,GAAGC,EACH,YAAaA,EAAE,MAAQ,EAAIA,EAAE,QAAUA,EAAE,MAAQ,IAAA,EACjD,EAEF,cACG,MAAA,CACC,SAAA,CAAAJ,EAAAA,IAAC,KAAA,CAAG,UAAU,wCAAwC,SAAA,WAAQ,EAG9DK,EAAAA,KAAC,MAAA,CAAI,UAAU,6CACb,SAAA,CAAAA,EAAAA,KAAC,MAAA,CAAI,U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AAA,KAAC,QAAA,CAAM,UAAU,oCACd,SAAA,CAAAH,EAAa,IAAKU,GACjBP,EAAAA,KAAC,KAAA,CAEC,UAAU,kCACV,QAAS,IAAMV,EAAS,0BAA0B,mBAAmBiB,EAAI,KAAK,CAAC,EAAE,EAEjF,SAAA,CAAAZ,EAAAA,IAAC,KAAA,CAAG,UAAU,8BACZ,SAAAA,EAAAA,IAAC,QAAK,UAAU,sCAAuC,SAAAY,EAAI,KAAA,CAAM,CAAA,CACnE,EACAZ,EAAAA,IAAC,KAAA,CAAG,UAAU,oDAAqD,WAAI,MAAM,EAC7EA,EAAAA,IAAC,KAAA,CAAG,UAAU,qDAAsD,WAAI,OAAO,EAC/EA,EAAAA,IAAC,KAAA,CAAG,UAAU,mDAAoD,WAAI,QAAQ,EAC9EA,EAAAA,IAAC,KAAA,CAAG,UAAU,oDAAqD,WAAI,QAAQ,EAC/EA,EAAAA,IAAC,KAAA,CAAG,UAAU,oDACX,WAAI,cAAgB,KAAO,IAAIY,EAAI,YAAc,KAAK,QAAQ,CAAC,CAAC,IAAM,GAAA,CACzE,CAAA,CAAA,EAbKA,EAAI,KAAA,CAeZ,EACAV,EAAa,SAAW,GACvBF,EAAAA,IAAC,KAAA,CACC,SAAAA,EAAAA,IAAC,KAAA,CAAG,QAAS,EAAG,UAAU,uCAAuC,SAAA,MAAA,CAAI,CAAA,CACvE,CAAA,CAAA,CAEJ,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAAA,EACF,CAEJ"}
|
|
1
|
+
{"version":3,"file":"Routing-BW3eGD-8.js","sources":["../../src/pages/Routing.tsx"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\nimport { useNavigate } from 'react-router-dom'\nimport { TrendingUp, AlertTriangle, CheckCircle, Activity } from 'lucide-react'\n\ninterface AgentStats {\n total: number\n obeyed: number\n refused: number\n unknown: number\n}\n\ninterface RoutingStats {\n windowHours: number\n total: number\n forced: number\n obeyedCount: number\n refusedCount: number\n unknownCount: number\n obedienceRate: number | null\n refusalRate: number | null\n fallbackUsedCount?: number\n latency?: { p50?: number; p95?: number; p99?: number; count?: number }\n byAgent: Record<string, AgentStats>\n}\n\nasync function fetchRoutingStats(): Promise<RoutingStats> {\n const res = await fetch('/api/routing/stats?window=168')\n if (!res.ok) throw new Error('Failed to fetch')\n return res.json()\n}\n\nexport default function Routing() {\n const navigate = useNavigate()\n const { data: stats, isLoading } = useQuery({\n queryKey: ['routing-stats'],\n queryFn: fetchRoutingStats,\n refetchInterval: 10000,\n })\n\n if (isLoading) {\n return <div className=\"bg-white rounded-lg shadow p-6\">加载中...</div>\n }\n\n if (!stats) {\n return <div className=\"bg-white rounded-lg shadow p-6 text-red-600\">加载失败</div>\n }\n\n const obediencePercent = stats.obedienceRate !== null && stats.obedienceRate !== undefined\n ? (stats.obedienceRate * 100).toFixed(1)\n : '-'\n\n // 把 byAgent 对象转成数组\n const byAgentArray = Object.entries(stats.byAgent || {}).map(([agent, s]) => ({\n agent,\n ...s,\n refusalRate: s.total > 0 ? s.refused / s.total : null,\n }))\n\n return (\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900 mb-6\">Agent 路由</h1>\n\n {/* Stats cards */}\n <div className=\"grid grid-cols-1 md:grid-cols-4 gap-4 mb-6\">\n <div className=\"bg-white rounded-lg shadow p-5\">\n <div className=\"flex items-center justify-between mb-2\">\n <span className=\"text-sm text-gray-500\">总路由次数</span>\n <Activity className=\"h-4 w-4 text-gray-400\" />\n </div>\n <div className=\"text-2xl font-bold text-gray-900\">{stats.total}</div>\n <div className=\"text-xs text-gray-500 mt-1\">最近 7 天</div>\n </div>\n\n <div className=\"bg-white rounded-lg shadow p-5\">\n <div className=\"flex items-center justify-between mb-2\">\n <span className=\"text-sm text-gray-500\">遵守率</span>\n <CheckCircle className=\"h-4 w-4 text-green-500\" />\n </div>\n <div className=\"text-2xl font-bold text-gray-900\">{obediencePercent}%</div>\n <div className=\"text-xs text-gray-500 mt-1\">{stats.obeyedCount} / {stats.obeyedCount + stats.refusedCount}</div>\n </div>\n\n <div className=\"bg-white rounded-lg shadow p-5\">\n <div className=\"flex items-center justify-between mb-2\">\n <span className=\"text-sm text-gray-500\">违抗率</span>\n <AlertTriangle className=\"h-4 w-4 text-red-500\" />\n </div>\n <div className=\"text-2xl font-bold text-gray-900\">\n {stats.refusalRate !== null && stats.refusalRate !== undefined\n ? (stats.refusalRate * 100).toFixed(1)\n : '-'}%\n </div>\n <div className=\"text-xs text-gray-500 mt-1\">{stats.refusedCount} 次</div>\n </div>\n\n <div className=\"bg-white rounded-lg shadow p-5\">\n <div className=\"flex items-center justify-between mb-2\">\n <span className=\"text-sm text-gray-500\">平均分类耗时</span>\n <TrendingUp className=\"h-4 w-4 text-blue-500\" />\n </div>\n <div className=\"text-2xl font-bold text-gray-900\">\n {stats.latency?.p50 ? `${stats.latency.p50}ms` : '-'}\n </div>\n <div className=\"text-xs text-gray-500 mt-1\">\n p95: {stats.latency?.p95 ? `${stats.latency.p95}ms` : '-'}\n </div>\n </div>\n </div>\n\n {/* By Agent table */}\n <div className=\"bg-white rounded-lg shadow overflow-hidden\">\n <div className=\"px-6 py-4 border-b border-gray-200\">\n <h3 className=\"text-lg font-semibold text-gray-900\">按 Agent 统计</h3>\n </div>\n <table className=\"min-w-full divide-y divide-gray-200\">\n <thead className=\"bg-gray-50\">\n <tr>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">Agent</th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">总次数</th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">遵守</th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">违抗</th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase\">未判定</th>\n <th className=\"px-6 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 {byAgentArray.map((row) => (\n <tr\n key={row.agent}\n className=\"hover:bg-gray-50 cursor-pointer\"\n onClick={() => navigate(`/execution-trace?agent=${encodeURIComponent(row.agent)}`)}\n >\n <td className=\"px-6 py-3 whitespace-nowrap\">\n <span className=\"text-sm font-medium text-indigo-600\">{row.agent}</span>\n </td>\n <td className=\"px-6 py-3 whitespace-nowrap text-sm text-gray-700\">{row.total}</td>\n <td className=\"px-6 py-3 whitespace-nowrap text-sm text-green-600\">{row.obeyed}</td>\n <td className=\"px-6 py-3 whitespace-nowrap text-sm text-red-600\">{row.refused}</td>\n <td className=\"px-6 py-3 whitespace-nowrap text-sm text-gray-400\">{row.unknown}</td>\n <td className=\"px-6 py-3 whitespace-nowrap text-sm text-gray-700\">\n {row.refusalRate !== null ? `${(row.refusalRate * 100).toFixed(1)}%` : '-'}\n </td>\n </tr>\n ))}\n {byAgentArray.length === 0 && (\n <tr>\n <td colSpan={6} className=\"px-6 py-12 text-center text-gray-500\">暂无数据</td>\n </tr>\n )}\n </tbody>\n </table>\n </div>\n </div>\n )\n}\n"],"names":["fetchRoutingStats","res","Routing","navigate","useNavigate","stats","isLoading","useQuery","jsx","obediencePercent","byAgentArray","agent","s","jsxs","Activity","CheckCircle","AlertTriangle","TrendingUp","_a","_b","row"],"mappings":"iOAyBA,eAAeA,GAA2C,CACxD,MAAMC,EAAM,MAAM,MAAM,+BAA+B,EACvD,GAAI,CAACA,EAAI,GAAI,MAAM,IAAI,MAAM,iBAAiB,EAC9C,OAAOA,EAAI,KAAA,CACb,CAEA,SAAwBC,GAAU,SAChC,MAAMC,EAAWC,EAAA,EACX,CAAE,KAAMC,EAAO,UAAAC,CAAA,EAAcC,EAAS,CAC1C,SAAU,CAAC,eAAe,EAC1B,QAASP,EACT,gBAAiB,GAAA,CAClB,EAED,GAAIM,EACF,OAAOE,EAAAA,IAAC,MAAA,CAAI,UAAU,iCAAiC,SAAA,SAAM,EAG/D,GAAI,CAACH,EACH,OAAOG,EAAAA,IAAC,MAAA,CAAI,UAAU,8CAA8C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,KAAA,CACC,SAAAA,EAAAA,IAAC,KAAA,CAAG,QAAS,EAAG,UAAU,uCAAuC,SAAA,MAAA,CAAI,CAAA,CACvE,CAAA,CAAA,CAEJ,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAAA,EACF,CAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as s}from"./react-vendor-CSp-GLFF.js";import{c,L as l}from"./react-router-I-HqunH7.js";import{u as m}from"./query-C99w429o.js";import{d as o}from"./vendor-CMMjVdZs.js";import{j as n,h,F as g,i as j,a as p}from"./lucide-
|
|
2
|
-
//# sourceMappingURL=SessionDetail-
|
|
1
|
+
import{j as s}from"./react-vendor-CSp-GLFF.js";import{c,L as l}from"./react-router-I-HqunH7.js";import{u as m}from"./query-C99w429o.js";import{d as o}from"./vendor-CMMjVdZs.js";import{j as n,h,F as g,i as j,a as p}from"./lucide-BanPULT1.js";import{f as N}from"./date-fns-CZ_bHujz.js";async function f(a){const t=await fetch(`/api/sessions/${a}/detail`);if(!t.ok)throw new Error("Failed to fetch session detail");return t.json()}function L(){const{id:a}=c(),{data:t,isLoading:d,error:x}=m({queryKey:["session-detail",a],queryFn:()=>f(a),enabled:!!a});return d?s.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:s.jsx("p",{className:"text-gray-600",children:"加载中..."})}):x||!t?s.jsxs("div",{children:[s.jsxs(l,{to:"/sessions",className:"inline-flex items-center text-sm text-gray-500 hover:text-gray-700 mb-4",children:[s.jsx(n,{className:"h-4 w-4 mr-1"}),"返回"]}),s.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:s.jsx("p",{className:"text-red-600",children:"加载失败"})})]}):s.jsxs("div",{children:[s.jsxs(l,{to:"/sessions",className:"inline-flex items-center text-sm text-gray-500 hover:text-gray-700 mb-4",children:[s.jsx(n,{className:"h-4 w-4 mr-1"}),"返回会话列表"]}),s.jsxs("div",{className:"bg-white rounded-lg shadow p-6 mb-6",children:[s.jsx("h1",{className:"text-xl font-bold text-gray-900 mb-2",children:"会话详情"}),s.jsx("p",{className:"text-sm text-gray-500 font-mono mb-4",children:t.session.session_id}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-gray-500",children:"事件数"}),s.jsx("div",{className:"text-lg font-semibold",children:t.session.event_count})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-gray-500",children:"任务数"}),s.jsx("div",{className:"text-lg font-semibold",children:t.tasks.length})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-gray-500",children:"开始时间"}),s.jsx("div",{className:"text-sm",children:t.session.start_time?N(new Date(t.session.start_time),"MM-dd HH:mm:ss"):"-"})]})]})]}),s.jsx("div",{className:"space-y-4",children:t.tasks.map(e=>s.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:e.title}),s.jsx("span",{className:o("px-2 py-1 text-xs font-medium rounded-full",e.status==="completed"&&"bg-green-100 text-green-700",e.status==="active"&&"bg-blue-100 text-blue-700",e.status==="abandoned"&&"bg-gray-100 text-gray-600"),children:e.status})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-4 text-sm",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"text-xs text-gray-500 mb-1 flex items-center gap-1",children:[s.jsx(h,{className:"h-3 w-3"}),"工具使用"]}),s.jsx("div",{className:"space-y-1",children:Object.entries(e.summary.toolUsage).slice(0,5).map(([i,r])=>s.jsxs("div",{className:"flex justify-between text-xs",children:[s.jsx("span",{className:"text-gray-600",children:i}),s.jsx("span",{className:"font-mono text-gray-900",children:r})]},i))})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"text-xs text-gray-500 mb-1 flex items-center gap-1",children:[s.jsx(g,{className:"h-3 w-3"}),"文件变更"]}),s.jsxs("div",{className:"text-xs text-gray-700",children:[e.summary.filesChanged.length," 个文件"]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"text-xs text-gray-500 mb-1 flex items-center gap-1",children:[s.jsx(j,{className:"h-3 w-3"}),"提交"]}),s.jsxs("div",{className:"text-xs text-gray-700",children:[e.summary.commits.length," 次"]})]})]}),e.prompts.length>0&&s.jsxs("div",{className:"border-t pt-3",children:[s.jsxs("div",{className:"text-xs text-gray-500 mb-2 flex items-center gap-1",children:[s.jsx(p,{className:"h-3 w-3"}),"用户提示"]}),s.jsx("div",{className:"space-y-2",children:e.prompts.slice(0,3).map((i,r)=>s.jsx("div",{className:"text-sm bg-gray-50 rounded p-2",children:s.jsx("p",{className:"text-gray-700 line-clamp-2",children:i.content})},r))})]})]},e.id))})]})}export{L as default};
|
|
2
|
+
//# sourceMappingURL=SessionDetail-Cbd7Jwox.js.map
|
package/dist/web/static/assets/{SessionDetail-DzTue2xK.js.map → SessionDetail-Cbd7Jwox.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SessionDetail-
|
|
1
|
+
{"version":3,"file":"SessionDetail-Cbd7Jwox.js","sources":["../../src/pages/SessionDetail.tsx"],"sourcesContent":["import { useParams, Link } from 'react-router-dom'\nimport { useQuery } from '@tanstack/react-query'\nimport { format } from 'date-fns'\nimport { ArrowLeft, MessageSquare, FileEdit, Terminal, GitCommit } from 'lucide-react'\nimport clsx from 'clsx'\n\ninterface TaskDetail {\n id: string\n title: string\n start_time: string\n end_time?: string\n status: string\n event_count: number\n prompts: Array<{ timestamp: string; content: string }>\n events: Array<any>\n injections: Array<any>\n summary: {\n toolUsage: Record<string, number>\n filesChanged: string[]\n commits: Array<{ timestamp: string; message: string }>\n }\n}\n\ninterface SessionDetail {\n session: {\n session_id: string\n first_prompt: string\n event_count: number\n start_time: string\n end_time: string\n }\n tasks: TaskDetail[]\n}\n\nasync function fetchSessionDetail(id: string): Promise<SessionDetail> {\n const res = await fetch(`/api/sessions/${id}/detail`)\n if (!res.ok) throw new Error('Failed to fetch session detail')\n return res.json()\n}\n\nexport default function SessionDetail() {\n const { id } = useParams<{ id: string }>()\n const { data, isLoading, error } = useQuery({\n queryKey: ['session-detail', id],\n queryFn: () => fetchSessionDetail(id!),\n enabled: !!id,\n })\n\n if (isLoading) {\n return (\n <div className=\"bg-white rounded-lg shadow p-6\">\n <p className=\"text-gray-600\">加载中...</p>\n </div>\n )\n }\n\n if (error || !data) {\n return (\n <div>\n <Link to=\"/sessions\" className=\"inline-flex items-center text-sm text-gray-500 hover:text-gray-700 mb-4\">\n <ArrowLeft className=\"h-4 w-4 mr-1\" />返回\n </Link>\n <div className=\"bg-white rounded-lg shadow p-6\">\n <p className=\"text-red-600\">加载失败</p>\n </div>\n </div>\n )\n }\n\n return (\n <div>\n <Link to=\"/sessions\" className=\"inline-flex items-center text-sm text-gray-500 hover:text-gray-700 mb-4\">\n <ArrowLeft className=\"h-4 w-4 mr-1\" />返回会话列表\n </Link>\n\n <div className=\"bg-white rounded-lg shadow p-6 mb-6\">\n <h1 className=\"text-xl font-bold text-gray-900 mb-2\">\n 会话详情\n </h1>\n <p className=\"text-sm text-gray-500 font-mono mb-4\">{data.session.session_id}</p>\n <div className=\"grid grid-cols-3 gap-4\">\n <div>\n <div className=\"text-xs text-gray-500\">事件数</div>\n <div className=\"text-lg font-semibold\">{data.session.event_count}</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500\">任务数</div>\n <div className=\"text-lg font-semibold\">{data.tasks.length}</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500\">开始时间</div>\n <div className=\"text-sm\">\n {data.session.start_time ? format(new Date(data.session.start_time), 'MM-dd HH:mm:ss') : '-'}\n </div>\n </div>\n </div>\n </div>\n\n <div className=\"space-y-4\">\n {data.tasks.map((task) => (\n <div key={task.id} className=\"bg-white rounded-lg shadow p-6\">\n <div className=\"flex items-center justify-between mb-4\">\n <h3 className=\"text-lg font-semibold text-gray-900\">{task.title}</h3>\n <span className={clsx(\n 'px-2 py-1 text-xs font-medium rounded-full',\n task.status === 'completed' && 'bg-green-100 text-green-700',\n task.status === 'active' && 'bg-blue-100 text-blue-700',\n task.status === 'abandoned' && 'bg-gray-100 text-gray-600'\n )}>\n {task.status}\n </span>\n </div>\n\n <div className=\"grid grid-cols-3 gap-4 mb-4 text-sm\">\n <div>\n <div className=\"text-xs text-gray-500 mb-1 flex items-center gap-1\">\n <Terminal className=\"h-3 w-3\" />工具使用\n </div>\n <div className=\"space-y-1\">\n {Object.entries(task.summary.toolUsage).slice(0, 5).map(([tool, count]) => (\n <div key={tool} className=\"flex justify-between text-xs\">\n <span className=\"text-gray-600\">{tool}</span>\n <span className=\"font-mono text-gray-900\">{count}</span>\n </div>\n ))}\n </div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1 flex items-center gap-1\">\n <FileEdit className=\"h-3 w-3\" />文件变更\n </div>\n <div className=\"text-xs text-gray-700\">{task.summary.filesChanged.length} 个文件</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1 flex items-center gap-1\">\n <GitCommit className=\"h-3 w-3\" />提交\n </div>\n <div className=\"text-xs text-gray-700\">{task.summary.commits.length} 次</div>\n </div>\n </div>\n\n {task.prompts.length > 0 && (\n <div className=\"border-t pt-3\">\n <div className=\"text-xs text-gray-500 mb-2 flex items-center gap-1\">\n <MessageSquare className=\"h-3 w-3\" />用户提示\n </div>\n <div className=\"space-y-2\">\n {task.prompts.slice(0, 3).map((p, i) => (\n <div key={i} className=\"text-sm bg-gray-50 rounded p-2\">\n <p className=\"text-gray-700 line-clamp-2\">{p.content}</p>\n </div>\n ))}\n </div>\n </div>\n )}\n </div>\n ))}\n </div>\n </div>\n )\n}\n"],"names":["fetchSessionDetail","id","res","SessionDetail","useParams","data","isLoading","error","useQuery","jsx","jsxs","Link","ArrowLeft","format","task","clsx","Terminal","tool","count","FileEdit","GitCommit","MessageSquare","p","i"],"mappings":"4RAkCA,eAAeA,EAAmBC,EAAoC,CACpE,MAAMC,EAAM,MAAM,MAAM,iBAAiBD,CAAE,SA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CAAA,EACF,CAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e,r as o}from"./react-vendor-CSp-GLFF.js";import{u as j}from"./query-C99w429o.js";import{D as y}from"./Drawer-
|
|
2
|
-
//# sourceMappingURL=Sessions-
|
|
1
|
+
import{j as e,r as o}from"./react-vendor-CSp-GLFF.js";import{u as j}from"./query-C99w429o.js";import{D as y}from"./Drawer-DOUcx6m1.js";import{d as N}from"./vendor-CMMjVdZs.js";import{f as v,a as b,z as w}from"./date-fns-CZ_bHujz.js";import{h as S,F as C,i as _,a as f,D,A as E,g as F}from"./lucide-BanPULT1.js";import{S as q,g as M,d as z,a as I}from"./export-CbQTOt71.js";import{u as L}from"./index-DJK5beK6.js";import"./react-router-I-HqunH7.js";import"./syntax-highlighter-44FakypI.js";async function T(r){const a=await fetch(`/api/sessions/${r}/detail`);if(!a.ok)throw new Error("Failed to fetch session detail");return a.json()}function $({sessionId:r}){const{data:a,isLoading:l,error:m}=j({queryKey:["session-detail",r],queryFn:()=>T(r),enabled:!!r});return l?e.jsx("div",{className:"p-6 text-gray-500",children:"加载中..."}):m||!a?e.jsx("div",{className:"p-6 text-red-600",children:"加载失败"}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Session ID"}),e.jsx("div",{className:"text-sm font-mono text-gray-900 break-all",children:a.session.session_id})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 pb-4 border-b border-gray-200",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"事件数"}),e.jsx("div",{className:"text-lg font-semibold",children:a.session.event_count})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"任务数"}),e.jsx("div",{className:"text-lg font-semibold",children:a.tasks.length})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500",children:"开始时间"}),e.jsx("div",{className:"text-sm",children:a.session.start_time?v(new Date(a.session.start_time),"MM-dd HH:mm:ss"):"-"})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-gray-700 mb-3",children:"任务列表"}),e.jsx("div",{className:"space-y-3",children:a.tasks.map(s=>e.jsxs("div",{className:"border border-gray-200 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-900 flex-1 mr-2",children:s.title}),e.jsx("span",{className:N("px-2 py-0.5 text-xs font-medium rounded-full whitespace-nowrap",s.status==="completed"&&"bg-green-100 text-green-700",s.status==="active"&&"bg-blue-100 text-blue-700",s.status==="abandoned"&&"bg-gray-100 text-gray-600"),children:s.status})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-3 text-xs",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-gray-500 mb-1 flex items-center gap-1",children:[e.jsx(S,{className:"h-3 w-3"}),"工具使用"]}),e.jsx("div",{className:"space-y-0.5",children:Object.entries(s.summary.toolUsage).slice(0,4).map(([i,c])=>e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-gray-600",children:i}),e.jsx("span",{className:"font-mono text-gray-900",children:c})]},i))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-gray-500 mb-1 flex items-center gap-1",children:[e.jsx(C,{className:"h-3 w-3"}),"文件变更"]}),e.jsxs("div",{className:"text-gray-700",children:[s.summary.filesChanged.length," 个"]}),s.summary.filesChanged.slice(0,3).map(i=>e.jsx("div",{className:"text-gray-500 truncate text-[10px]",title:i,children:i.split("/").pop()},i))]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-gray-500 mb-1 flex items-center gap-1",children:[e.jsx(_,{className:"h-3 w-3"}),"提交"]}),e.jsxs("div",{className:"text-gray-700",children:[s.summary.commits.length," 次"]})]})]}),s.prompts.length>0&&e.jsxs("div",{className:"border-t border-gray-100 pt-3",children:[e.jsxs("div",{className:"text-xs text-gray-500 mb-2 flex items-center gap-1",children:[e.jsx(f,{className:"h-3 w-3"}),"用户提示 (",s.prompts.length,")"]}),e.jsxs("div",{className:"space-y-1.5",children:[s.prompts.slice(0,3).map((i,c)=>e.jsx("div",{className:"text-xs bg-gray-50 rounded p-2",children:e.jsx("p",{className:"text-gray-700 line-clamp-2",children:i.content})},c)),s.prompts.length>3&&e.jsxs("div",{className:"text-xs text-gray-400",children:["还有 ",s.prompts.length-3," 条..."]})]})]})]},s.id))})]})]})}async function k(){const r=await fetch("/api/sessions?limit=200");if(!r.ok)throw new Error("Failed to fetch sessions");return r.json()}function U(){const[r,a]=o.useState(null),[l,m]=o.useState(""),[s,i]=o.useState(!1),c=L(),{data:x,isLoading:u,error:h}=j({queryKey:["sessions"],queryFn:k,refetchInterval:1e4}),n=o.useMemo(()=>{if(!x)return[];if(!l.trim())return x;const t=l.toLowerCase();return x.filter(d=>{var g;return((g=d.first_prompt)==null?void 0:g.toLowerCase().includes(t))||d.session_id.toLowerCase().includes(t)})},[x,l]),p=t=>{const d=M();t==="json"?z(`sessions-${d}.json`,n):I(`sessions-${d}.csv`,n),c.success(`已导出 ${n.length} 个会话`),i(!1)};return u?e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-6",children:"会话"}),e.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:e.jsx("p",{className:"text-gray-600",children:"加载中..."})})]}):h?e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-6",children:"会话"}),e.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:e.jsxs("p",{className:"text-red-600",children:["加载失败: ",h.message]})})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 flex-wrap gap-3",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"会话"}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(q,{value:l,onChange:m,placeholder:"搜索 session / 提示...",className:"w-64"}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>i(t=>!t),disabled:n.length===0,className:"inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-white border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50",children:[e.jsx(D,{className:"h-4 w-4"}),"导出"]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>i(!1)}),e.jsxs("div",{className:"absolute right-0 mt-1 bg-white border border-gray-200 rounded-md shadow-lg z-20",children:[e.jsx("button",{onClick:()=>p("json"),className:"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50",children:"导出为 JSON"}),e.jsx("button",{onClick:()=>p("csv"),className:"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50",children:"导出为 CSV"})]})]})]})]})]}),e.jsxs("div",{className:"text-sm text-gray-500 mb-3",children:["显示 ",n.length," 个 ",l&&"(已过滤)"]}),e.jsx("div",{className:"bg-white rounded-lg shadow overflow-hidden",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Session ID"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"首次提示"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"事件数"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"时间"})]})}),e.jsxs("tbody",{className:"bg-white divide-y divide-gray-200",children:[n.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50 cursor-pointer",onClick:()=>a(t.session_id),children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-indigo-600 font-mono",children:[e.jsx(f,{className:"h-4 w-4"}),t.session_id.slice(0,12),"..."]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("p",{className:"text-sm text-gray-900 max-w-md truncate",children:t.first_prompt||"(无提示)"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsxs("span",{className:"inline-flex items-center gap-1 text-sm text-gray-600",children:[e.jsx(E,{className:"h-4 w-4"}),t.event_count]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-500",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(F,{className:"h-4 w-4"}),t.start_time?b(new Date(t.start_time),{addSuffix:!0,locale:w}):"-"]})})]},t.session_id)),n.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-6 py-12 text-center text-gray-500",children:l?"无匹配结果":"暂无会话记录"})})]})]})}),e.jsx(y,{open:r!==null,onClose:()=>a(null),title:"会话详情",width:"w-[800px]",children:r&&e.jsx($,{sessionId:r})})]})}export{U as default};
|
|
2
|
+
//# sourceMappingURL=Sessions-ZQSCgXyy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sessions-DOd65EkN.js","sources":["../../src/components/SessionDetailContent.tsx","../../src/pages/Sessions.tsx"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\nimport { format } from 'date-fns'\nimport { MessageSquare, FileEdit, Terminal, GitCommit } from 'lucide-react'\nimport clsx from 'clsx'\n\ninterface TaskDetail {\n id: string\n title: string\n start_time: string\n end_time?: string\n status: string\n event_count: number\n prompts: Array<{ timestamp: string; content: string }>\n events: Array<any>\n injections: Array<any>\n summary: {\n toolUsage: Record<string, number>\n filesChanged: string[]\n commits: Array<{ timestamp: string; message: string }>\n }\n}\n\ninterface SessionDetailData {\n session: {\n session_id: string\n first_prompt: string\n event_count: number\n start_time: string\n end_time: string\n }\n tasks: TaskDetail[]\n}\n\nasync function fetchSessionDetail(id: string): Promise<SessionDetailData> {\n const res = await fetch(`/api/sessions/${id}/detail`)\n if (!res.ok) throw new Error('Failed to fetch session detail')\n return res.json()\n}\n\ninterface Props {\n sessionId: string\n}\n\nexport default function SessionDetailContent({ sessionId }: Props) {\n const { data, isLoading, error } = useQuery({\n queryKey: ['session-detail', sessionId],\n queryFn: () => fetchSessionDetail(sessionId),\n enabled: !!sessionId,\n })\n\n if (isLoading) {\n return <div className=\"p-6 text-gray-500\">加载中...</div>\n }\n\n if (error || !data) {\n return <div className=\"p-6 text-red-600\">加载失败</div>\n }\n\n return (\n <div className=\"space-y-4\">\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">Session ID</div>\n <div className=\"text-sm font-mono text-gray-900 break-all\">{data.session.session_id}</div>\n </div>\n\n <div className=\"grid grid-cols-3 gap-4 pb-4 border-b border-gray-200\">\n <div>\n <div className=\"text-xs text-gray-500\">事件数</div>\n <div className=\"text-lg font-semibold\">{data.session.event_count}</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500\">任务数</div>\n <div className=\"text-lg font-semibold\">{data.tasks.length}</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500\">开始时间</div>\n <div className=\"text-sm\">\n {data.session.start_time ? format(new Date(data.session.start_time), 'MM-dd HH:mm:ss') : '-'}\n </div>\n </div>\n </div>\n\n <div>\n <h3 className=\"text-sm font-semibold text-gray-700 mb-3\">任务列表</h3>\n <div className=\"space-y-3\">\n {data.tasks.map((task) => (\n <div key={task.id} className=\"border border-gray-200 rounded-lg p-4\">\n <div className=\"flex items-center justify-between mb-3\">\n <h4 className=\"text-sm font-semibold text-gray-900 flex-1 mr-2\">{task.title}</h4>\n <span className={clsx(\n 'px-2 py-0.5 text-xs font-medium rounded-full whitespace-nowrap',\n task.status === 'completed' && 'bg-green-100 text-green-700',\n task.status === 'active' && 'bg-blue-100 text-blue-700',\n task.status === 'abandoned' && 'bg-gray-100 text-gray-600'\n )}>\n {task.status}\n </span>\n </div>\n\n <div className=\"grid grid-cols-3 gap-3 mb-3 text-xs\">\n <div>\n <div className=\"text-gray-500 mb-1 flex items-center gap-1\">\n <Terminal className=\"h-3 w-3\" />工具使用\n </div>\n <div className=\"space-y-0.5\">\n {Object.entries(task.summary.toolUsage).slice(0, 4).map(([tool, count]) => (\n <div key={tool} className=\"flex justify-between\">\n <span className=\"text-gray-600\">{tool}</span>\n <span className=\"font-mono text-gray-900\">{count}</span>\n </div>\n ))}\n </div>\n </div>\n <div>\n <div className=\"text-gray-500 mb-1 flex items-center gap-1\">\n <FileEdit className=\"h-3 w-3\" />文件变更\n </div>\n <div className=\"text-gray-700\">{task.summary.filesChanged.length} 个</div>\n {task.summary.filesChanged.slice(0, 3).map(f => (\n <div key={f} className=\"text-gray-500 truncate text-[10px]\" title={f}>\n {f.split('/').pop()}\n </div>\n ))}\n </div>\n <div>\n <div className=\"text-gray-500 mb-1 flex items-center gap-1\">\n <GitCommit className=\"h-3 w-3\" />提交\n </div>\n <div className=\"text-gray-700\">{task.summary.commits.length} 次</div>\n </div>\n </div>\n\n {task.prompts.length > 0 && (\n <div className=\"border-t border-gray-100 pt-3\">\n <div className=\"text-xs text-gray-500 mb-2 flex items-center gap-1\">\n <MessageSquare className=\"h-3 w-3\" />用户提示 ({task.prompts.length})\n </div>\n <div className=\"space-y-1.5\">\n {task.prompts.slice(0, 3).map((p, i) => (\n <div key={i} className=\"text-xs bg-gray-50 rounded p-2\">\n <p className=\"text-gray-700 line-clamp-2\">{p.content}</p>\n </div>\n ))}\n {task.prompts.length > 3 && (\n <div className=\"text-xs text-gray-400\">还有 {task.prompts.length - 3} 条...</div>\n )}\n </div>\n </div>\n )}\n </div>\n ))}\n </div>\n </div>\n </div>\n )\n}\n","import { useQuery } from '@tanstack/react-query'\nimport { useState, useMemo } from 'react'\nimport { formatDistanceToNow } from 'date-fns'\nimport { zhCN } from 'date-fns/locale'\nimport { MessageSquare, Clock, Activity, Download } from 'lucide-react'\nimport Drawer from '../components/Drawer'\nimport SessionDetailContent from '../components/SessionDetailContent'\nimport SearchInput from '../components/SearchInput'\nimport { downloadJSON, downloadCSV, getTimestamp } from '../utils/export'\nimport { useToast } from '../components/Toast'\n\ninterface Session {\n session_id: string\n first_prompt: string\n event_count: number\n start_time: string\n end_time: string\n}\n\nasync function fetchSessions(): Promise<Session[]> {\n const res = await fetch('/api/sessions?limit=200')\n if (!res.ok) throw new Error('Failed to fetch sessions')\n return res.json()\n}\n\nexport default function Sessions() {\n const [selectedSessionId, setSelectedSessionId] = useState<string | null>(null)\n const [search, setSearch] = useState('')\n const [showExportMenu, setShowExportMenu] = useState(false)\n const toast = useToast()\n\n const { data: sessions, isLoading, error } = useQuery({\n queryKey: ['sessions'],\n queryFn: fetchSessions,\n refetchInterval: 10000,\n })\n\n const filteredSessions = useMemo(() => {\n if (!sessions) return []\n if (!search.trim()) return sessions\n const q = search.toLowerCase()\n return sessions.filter(s =>\n s.first_prompt?.toLowerCase().includes(q) ||\n s.session_id.toLowerCase().includes(q)\n )\n }, [sessions, search])\n\n const handleExport = (format: 'json' | 'csv') => {\n const ts = getTimestamp()\n if (format === 'json') {\n downloadJSON(`sessions-${ts}.json`, filteredSessions)\n } else {\n downloadCSV(`sessions-${ts}.csv`, filteredSessions)\n }\n toast.success(`已导出 ${filteredSessions.length} 个会话`)\n setShowExportMenu(false)\n }\n\n if (isLoading) {\n return (\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900 mb-6\">会话</h1>\n <div className=\"bg-white rounded-lg shadow p-6\">\n <p className=\"text-gray-600\">加载中...</p>\n </div>\n </div>\n )\n }\n\n if (error) {\n return (\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900 mb-6\">会话</h1>\n <div className=\"bg-white rounded-lg shadow p-6\">\n <p className=\"text-red-600\">加载失败: {(error as Error).message}</p>\n </div>\n </div>\n )\n }\n\n return (\n <div>\n <div className=\"flex items-center justify-between mb-4 flex-wrap gap-3\">\n <h1 className=\"text-2xl font-bold text-gray-900\">会话</h1>\n <div className=\"flex items-center gap-2 flex-wrap\">\n <SearchInput\n value={search}\n onChange={setSearch}\n placeholder=\"搜索 session / 提示...\"\n className=\"w-64\"\n />\n <div className=\"relative\">\n <button\n onClick={() => setShowExportMenu(v => !v)}\n disabled={filteredSessions.length === 0}\n className=\"inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-white border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50\"\n >\n <Download className=\"h-4 w-4\" />\n 导出\n </button>\n {showExportMenu && (\n <>\n <div className=\"fixed inset-0 z-10\" onClick={() => setShowExportMenu(false)} />\n <div className=\"absolute right-0 mt-1 bg-white border border-gray-200 rounded-md shadow-lg z-20\">\n <button\n onClick={() => handleExport('json')}\n className=\"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50\"\n >\n 导出为 JSON\n </button>\n <button\n onClick={() => handleExport('csv')}\n className=\"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50\"\n >\n 导出为 CSV\n </button>\n </div>\n </>\n )}\n </div>\n </div>\n </div>\n\n <div className=\"text-sm text-gray-500 mb-3\">\n 显示 {filteredSessions.length} 个 {search && `(已过滤)`}\n </div>\n\n <div className=\"bg-white rounded-lg shadow overflow-hidden\">\n <table className=\"min-w-full divide-y divide-gray-200\">\n <thead className=\"bg-gray-50\">\n <tr>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n Session ID\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n 首次提示\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n 事件数\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n 时间\n </th>\n </tr>\n </thead>\n <tbody className=\"bg-white divide-y divide-gray-200\">\n {filteredSessions.map((session) => (\n <tr\n key={session.session_id}\n className=\"hover:bg-gray-50 cursor-pointer\"\n onClick={() => setSelectedSessionId(session.session_id)}\n >\n <td className=\"px-6 py-4 whitespace-nowrap\">\n <div className=\"flex items-center gap-2 text-sm text-indigo-600 font-mono\">\n <MessageSquare className=\"h-4 w-4\" />\n {session.session_id.slice(0, 12)}...\n </div>\n </td>\n <td className=\"px-6 py-4\">\n <p className=\"text-sm text-gray-900 max-w-md truncate\">\n {session.first_prompt || '(无提示)'}\n </p>\n </td>\n <td className=\"px-6 py-4 whitespace-nowrap\">\n <span className=\"inline-flex items-center gap-1 text-sm text-gray-600\">\n <Activity className=\"h-4 w-4\" />\n {session.event_count}\n </span>\n </td>\n <td className=\"px-6 py-4 whitespace-nowrap text-sm text-gray-500\">\n <span className=\"inline-flex items-center gap-1\">\n <Clock className=\"h-4 w-4\" />\n {session.start_time\n ? formatDistanceToNow(new Date(session.start_time), {\n addSuffix: true,\n locale: zhCN,\n })\n : '-'}\n </span>\n </td>\n </tr>\n ))}\n {filteredSessions.length === 0 && (\n <tr>\n <td colSpan={4} className=\"px-6 py-12 text-center text-gray-500\">\n {search ? '无匹配结果' : '暂无会话记录'}\n </td>\n </tr>\n )}\n </tbody>\n </table>\n </div>\n\n <Drawer\n open={selectedSessionId !== null}\n onClose={() => setSelectedSessionId(null)}\n title=\"会话详情\"\n width=\"w-[800px]\"\n >\n {selectedSessionId && <SessionDetailContent sessionId={selectedSessionId} />}\n </Drawer>\n </div>\n )\n}\n"],"names":["fetchSessionDetail","id","res","SessionDetailContent","sessionId","data","isLoading","error","useQuery","jsx","jsxs","format","task","clsx","Terminal","tool","count","FileEdit","f","GitCommit","MessageSquare","p","i","fetchSessions","Sessions","selectedSessionId","setSelectedSessionId","useState","search","setSearch","showExportMenu","setShowExportMenu","toast","useToast","sessions","filteredSessions","useMemo","q","s","_a","handleExport","ts","getTimestamp","downloadJSON","downloadCSV","SearchInput","v","Download","Fragment","session","Activity","Clock","formatDistanceToNow","zhCN","Drawer"],"mappings":"yeAiCA,eAAeA,EAAmBC,EAAwC,CACxE,MAAMC,EAAM,MAAM,MAAM,iBAAiBD,CAAE,SAAS,EACpD,GAAI,CAACC,EAAI,GAAI,MAAM,IAAI,MAAM,gCAAgC,EAC7D,OAAOA,EAAI,KAAA,CACb,CAMA,SAAwBC,EAAqB,CAAE,UAAA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C0C,EAAA,CAAM,UAAU,SAAA,CAAU,EAC1BF,EAAQ,WACLG,EAAoB,IAAI,KAAKH,EAAQ,UAAU,EAAG,CAChD,UAAW,GACX,OAAQI,CAAA,CACT,EACD,GAAA,CAAA,CACN,CAAA,CACF,CAAA,CAAA,EA/BKJ,EAAQ,UAAA,CAiChB,EACAd,EAAiB,SAAW,GAC3B1B,EAAAA,IAAC,MACC,SAAAA,EAAAA,IAAC,KAAA,CAAG,QAAS,EAAG,UAAU,uCACvB,SAAAmB,EAAS,QAAU,SACtB,CAAA,CACF,CAAA,CAAA,CAEJ,CAAA,CAAA,CACF,CAAA,CACF,EAEAnB,EAAAA,IAAC6C,EAAA,CACC,KAAM7B,IAAsB,KAC5B,QAAS,IAAMC,EAAqB,IAAI,EACxC,MAAM,OACN,MAAM,YAEL,SAAAD,GAAqBhB,EAAAA,IAACN,EAAA,CAAqB,UAAWsB,CAAA,CAAmB,CAAA,CAAA,CAC5E,EACF,CAEJ"}
|
|
1
|
+
{"version":3,"file":"Sessions-ZQSCgXyy.js","sources":["../../src/components/SessionDetailContent.tsx","../../src/pages/Sessions.tsx"],"sourcesContent":["import { useQuery } from '@tanstack/react-query'\nimport { format } from 'date-fns'\nimport { MessageSquare, FileEdit, Terminal, GitCommit } from 'lucide-react'\nimport clsx from 'clsx'\n\ninterface TaskDetail {\n id: string\n title: string\n start_time: string\n end_time?: string\n status: string\n event_count: number\n prompts: Array<{ timestamp: string; content: string }>\n events: Array<any>\n injections: Array<any>\n summary: {\n toolUsage: Record<string, number>\n filesChanged: string[]\n commits: Array<{ timestamp: string; message: string }>\n }\n}\n\ninterface SessionDetailData {\n session: {\n session_id: string\n first_prompt: string\n event_count: number\n start_time: string\n end_time: string\n }\n tasks: TaskDetail[]\n}\n\nasync function fetchSessionDetail(id: string): Promise<SessionDetailData> {\n const res = await fetch(`/api/sessions/${id}/detail`)\n if (!res.ok) throw new Error('Failed to fetch session detail')\n return res.json()\n}\n\ninterface Props {\n sessionId: string\n}\n\nexport default function SessionDetailContent({ sessionId }: Props) {\n const { data, isLoading, error } = useQuery({\n queryKey: ['session-detail', sessionId],\n queryFn: () => fetchSessionDetail(sessionId),\n enabled: !!sessionId,\n })\n\n if (isLoading) {\n return <div className=\"p-6 text-gray-500\">加载中...</div>\n }\n\n if (error || !data) {\n return <div className=\"p-6 text-red-600\">加载失败</div>\n }\n\n return (\n <div className=\"space-y-4\">\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">Session ID</div>\n <div className=\"text-sm font-mono text-gray-900 break-all\">{data.session.session_id}</div>\n </div>\n\n <div className=\"grid grid-cols-3 gap-4 pb-4 border-b border-gray-200\">\n <div>\n <div className=\"text-xs text-gray-500\">事件数</div>\n <div className=\"text-lg font-semibold\">{data.session.event_count}</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500\">任务数</div>\n <div className=\"text-lg font-semibold\">{data.tasks.length}</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500\">开始时间</div>\n <div className=\"text-sm\">\n {data.session.start_time ? format(new Date(data.session.start_time), 'MM-dd HH:mm:ss') : '-'}\n </div>\n </div>\n </div>\n\n <div>\n <h3 className=\"text-sm font-semibold text-gray-700 mb-3\">任务列表</h3>\n <div className=\"space-y-3\">\n {data.tasks.map((task) => (\n <div key={task.id} className=\"border border-gray-200 rounded-lg p-4\">\n <div className=\"flex items-center justify-between mb-3\">\n <h4 className=\"text-sm font-semibold text-gray-900 flex-1 mr-2\">{task.title}</h4>\n <span className={clsx(\n 'px-2 py-0.5 text-xs font-medium rounded-full whitespace-nowrap',\n task.status === 'completed' && 'bg-green-100 text-green-700',\n task.status === 'active' && 'bg-blue-100 text-blue-700',\n task.status === 'abandoned' && 'bg-gray-100 text-gray-600'\n )}>\n {task.status}\n </span>\n </div>\n\n <div className=\"grid grid-cols-3 gap-3 mb-3 text-xs\">\n <div>\n <div className=\"text-gray-500 mb-1 flex items-center gap-1\">\n <Terminal className=\"h-3 w-3\" />工具使用\n </div>\n <div className=\"space-y-0.5\">\n {Object.entries(task.summary.toolUsage).slice(0, 4).map(([tool, count]) => (\n <div key={tool} className=\"flex justify-between\">\n <span className=\"text-gray-600\">{tool}</span>\n <span className=\"font-mono text-gray-900\">{count}</span>\n </div>\n ))}\n </div>\n </div>\n <div>\n <div className=\"text-gray-500 mb-1 flex items-center gap-1\">\n <FileEdit className=\"h-3 w-3\" />文件变更\n </div>\n <div className=\"text-gray-700\">{task.summary.filesChanged.length} 个</div>\n {task.summary.filesChanged.slice(0, 3).map(f => (\n <div key={f} className=\"text-gray-500 truncate text-[10px]\" title={f}>\n {f.split('/').pop()}\n </div>\n ))}\n </div>\n <div>\n <div className=\"text-gray-500 mb-1 flex items-center gap-1\">\n <GitCommit className=\"h-3 w-3\" />提交\n </div>\n <div className=\"text-gray-700\">{task.summary.commits.length} 次</div>\n </div>\n </div>\n\n {task.prompts.length > 0 && (\n <div className=\"border-t border-gray-100 pt-3\">\n <div className=\"text-xs text-gray-500 mb-2 flex items-center gap-1\">\n <MessageSquare className=\"h-3 w-3\" />用户提示 ({task.prompts.length})\n </div>\n <div className=\"space-y-1.5\">\n {task.prompts.slice(0, 3).map((p, i) => (\n <div key={i} className=\"text-xs bg-gray-50 rounded p-2\">\n <p className=\"text-gray-700 line-clamp-2\">{p.content}</p>\n </div>\n ))}\n {task.prompts.length > 3 && (\n <div className=\"text-xs text-gray-400\">还有 {task.prompts.length - 3} 条...</div>\n )}\n </div>\n </div>\n )}\n </div>\n ))}\n </div>\n </div>\n </div>\n )\n}\n","import { useQuery } from '@tanstack/react-query'\nimport { useState, useMemo } from 'react'\nimport { formatDistanceToNow } from 'date-fns'\nimport { zhCN } from 'date-fns/locale'\nimport { MessageSquare, Clock, Activity, Download } from 'lucide-react'\nimport Drawer from '../components/Drawer'\nimport SessionDetailContent from '../components/SessionDetailContent'\nimport SearchInput from '../components/SearchInput'\nimport { downloadJSON, downloadCSV, getTimestamp } from '../utils/export'\nimport { useToast } from '../components/Toast'\n\ninterface Session {\n session_id: string\n first_prompt: string\n event_count: number\n start_time: string\n end_time: string\n}\n\nasync function fetchSessions(): Promise<Session[]> {\n const res = await fetch('/api/sessions?limit=200')\n if (!res.ok) throw new Error('Failed to fetch sessions')\n return res.json()\n}\n\nexport default function Sessions() {\n const [selectedSessionId, setSelectedSessionId] = useState<string | null>(null)\n const [search, setSearch] = useState('')\n const [showExportMenu, setShowExportMenu] = useState(false)\n const toast = useToast()\n\n const { data: sessions, isLoading, error } = useQuery({\n queryKey: ['sessions'],\n queryFn: fetchSessions,\n refetchInterval: 10000,\n })\n\n const filteredSessions = useMemo(() => {\n if (!sessions) return []\n if (!search.trim()) return sessions\n const q = search.toLowerCase()\n return sessions.filter(s =>\n s.first_prompt?.toLowerCase().includes(q) ||\n s.session_id.toLowerCase().includes(q)\n )\n }, [sessions, search])\n\n const handleExport = (format: 'json' | 'csv') => {\n const ts = getTimestamp()\n if (format === 'json') {\n downloadJSON(`sessions-${ts}.json`, filteredSessions)\n } else {\n downloadCSV(`sessions-${ts}.csv`, filteredSessions)\n }\n toast.success(`已导出 ${filteredSessions.length} 个会话`)\n setShowExportMenu(false)\n }\n\n if (isLoading) {\n return (\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900 mb-6\">会话</h1>\n <div className=\"bg-white rounded-lg shadow p-6\">\n <p className=\"text-gray-600\">加载中...</p>\n </div>\n </div>\n )\n }\n\n if (error) {\n return (\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900 mb-6\">会话</h1>\n <div className=\"bg-white rounded-lg shadow p-6\">\n <p className=\"text-red-600\">加载失败: {(error as Error).message}</p>\n </div>\n </div>\n )\n }\n\n return (\n <div>\n <div className=\"flex items-center justify-between mb-4 flex-wrap gap-3\">\n <h1 className=\"text-2xl font-bold text-gray-900\">会话</h1>\n <div className=\"flex items-center gap-2 flex-wrap\">\n <SearchInput\n value={search}\n onChange={setSearch}\n placeholder=\"搜索 session / 提示...\"\n className=\"w-64\"\n />\n <div className=\"relative\">\n <button\n onClick={() => setShowExportMenu(v => !v)}\n disabled={filteredSessions.length === 0}\n className=\"inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-white border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50\"\n >\n <Download className=\"h-4 w-4\" />\n 导出\n </button>\n {showExportMenu && (\n <>\n <div className=\"fixed inset-0 z-10\" onClick={() => setShowExportMenu(false)} />\n <div className=\"absolute right-0 mt-1 bg-white border border-gray-200 rounded-md shadow-lg z-20\">\n <button\n onClick={() => handleExport('json')}\n className=\"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50\"\n >\n 导出为 JSON\n </button>\n <button\n onClick={() => handleExport('csv')}\n className=\"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50\"\n >\n 导出为 CSV\n </button>\n </div>\n </>\n )}\n </div>\n </div>\n </div>\n\n <div className=\"text-sm text-gray-500 mb-3\">\n 显示 {filteredSessions.length} 个 {search && `(已过滤)`}\n </div>\n\n <div className=\"bg-white rounded-lg shadow overflow-hidden\">\n <table className=\"min-w-full divide-y divide-gray-200\">\n <thead className=\"bg-gray-50\">\n <tr>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n Session ID\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n 首次提示\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n 事件数\n </th>\n <th className=\"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider\">\n 时间\n </th>\n </tr>\n </thead>\n <tbody className=\"bg-white divide-y divide-gray-200\">\n {filteredSessions.map((session) => (\n <tr\n key={session.session_id}\n className=\"hover:bg-gray-50 cursor-pointer\"\n onClick={() => setSelectedSessionId(session.session_id)}\n >\n <td className=\"px-6 py-4 whitespace-nowrap\">\n <div className=\"flex items-center gap-2 text-sm text-indigo-600 font-mono\">\n <MessageSquare className=\"h-4 w-4\" />\n {session.session_id.slice(0, 12)}...\n </div>\n </td>\n <td className=\"px-6 py-4\">\n <p className=\"text-sm text-gray-900 max-w-md truncate\">\n {session.first_prompt || '(无提示)'}\n </p>\n </td>\n <td className=\"px-6 py-4 whitespace-nowrap\">\n <span className=\"inline-flex items-center gap-1 text-sm text-gray-600\">\n <Activity className=\"h-4 w-4\" />\n {session.event_count}\n </span>\n </td>\n <td className=\"px-6 py-4 whitespace-nowrap text-sm text-gray-500\">\n <span className=\"inline-flex items-center gap-1\">\n <Clock className=\"h-4 w-4\" />\n {session.start_time\n ? formatDistanceToNow(new Date(session.start_time), {\n addSuffix: true,\n locale: zhCN,\n })\n : '-'}\n </span>\n </td>\n </tr>\n ))}\n {filteredSessions.length === 0 && (\n <tr>\n <td colSpan={4} className=\"px-6 py-12 text-center text-gray-500\">\n {search ? '无匹配结果' : '暂无会话记录'}\n </td>\n </tr>\n )}\n </tbody>\n </table>\n </div>\n\n <Drawer\n open={selectedSessionId !== null}\n onClose={() => setSelectedSessionId(null)}\n title=\"会话详情\"\n width=\"w-[800px]\"\n >\n {selectedSessionId && <SessionDetailContent sessionId={selectedSessionId} />}\n </Drawer>\n </div>\n )\n}\n"],"names":["fetchSessionDetail","id","res","SessionDetailContent","sessionId","data","isLoading","error","useQuery","jsx","jsxs","format","task","clsx","Terminal","tool","count","FileEdit","f","GitCommit","MessageSquare","p","i","fetchSessions","Sessions","selectedSessionId","setSelectedSessionId","useState","search","setSearch","showExportMenu","setShowExportMenu","toast","useToast","sessions","filteredSessions","useMemo","q","s","_a","handleExport","ts","getTimestamp","downloadJSON","downloadCSV","SearchInput","v","Download","Fragment","session","Activity","Clock","formatDistanceToNow","zhCN","Drawer"],"mappings":"yeAiCA,eAAeA,EAAmBC,EAAwC,CACxE,MAAMC,EAAM,MAAM,MAAM,iBAAiBD,CAAE,SAAS,EACpD,GAAI,CAACC,EAAI,GAAI,MAAM,IAAI,MAAM,gCAAgC,EAC7D,OAAOA,EAAI,KAAA,CACb,CAMA,SAAwBC,EAAqB,CAAE,UAAAC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0C,EAAA,CAAM,UAAU,SAAA,CAAU,EAC1BF,EAAQ,WACLG,EAAoB,IAAI,KAAKH,EAAQ,UAAU,EAAG,CAChD,UAAW,GACX,OAAQI,CAAA,CACT,EACD,GAAA,CAAA,CACN,CAAA,CACF,CAAA,CAAA,EA/BKJ,EAAQ,UAAA,CAiChB,EACAd,EAAiB,SAAW,GAC3B1B,EAAAA,IAAC,MACC,SAAAA,EAAAA,IAAC,KAAA,CAAG,QAAS,EAAG,UAAU,uCACvB,SAAAmB,EAAS,QAAU,SACtB,CAAA,CACF,CAAA,CAAA,CAEJ,CAAA,CAAA,CACF,CAAA,CACF,EAEAnB,EAAAA,IAAC6C,EAAA,CACC,KAAM7B,IAAsB,KAC5B,QAAS,IAAMC,EAAqB,IAAI,EACxC,MAAM,OACN,MAAM,YAEL,SAAAD,GAAqBhB,EAAAA,IAACN,EAAA,CAAqB,UAAWsB,CAAA,CAAmB,CAAA,CAAA,CAC5E,EACF,CAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as c,j as e}from"./react-vendor-CSp-GLFF.js";import{b as p,u,c as j}from"./query-C99w429o.js";import{D as y}from"./Drawer-
|
|
2
|
-
//# sourceMappingURL=Skills-
|
|
1
|
+
import{r as c,j as e}from"./react-vendor-CSp-GLFF.js";import{b as p,u,c as j}from"./query-C99w429o.js";import{D as y}from"./Drawer-DOUcx6m1.js";import{M as w}from"./MarkdownRenderer-CCIz1MOz.js";import{u as b}from"./index-DJK5beK6.js";import{a as v}from"./auth-Bnf8ZcqN.js";import{b as g,t as N,X as k,u as S}from"./lucide-BanPULT1.js";import"./vendor-CMMjVdZs.js";import"./syntax-highlighter-44FakypI.js";import"./react-router-I-HqunH7.js";async function C(){const i=await fetch("/api/skills");if(!i.ok)throw new Error("Failed to fetch skills");const s=await i.json();return Array.isArray(s)?s:s.skills||[]}async function E(i){const s=await fetch(`/api/skills/${i}`);if(!s.ok)throw new Error("Failed to fetch");return s.json()}async function F(i,s){if(!(await v(`/api/skills/${i}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s})})).ok)throw new Error("Failed to save")}function R(){const i=p(),s=b(),{data:n,isLoading:f}=u({queryKey:["skills"],queryFn:C}),[r,x]=c.useState(null),[m,l]=c.useState(!1),[h,d]=c.useState(""),{data:t}=u({queryKey:["skill-detail",r],queryFn:()=>E(r),enabled:!!r});c.useEffect(()=>{t!=null&&t.content&&d(t.content),l(!1)},[t]);const o=j({mutationFn:a=>F(a.name,a.content),onSuccess:()=>{s.success("Skill 已保存"),l(!1),i.invalidateQueries({queryKey:["skill-detail",r]}),i.invalidateQueries({queryKey:["skills"]})},onError:a=>s.error(`保存失败: ${a.message}`)});return f?e.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:"加载中..."}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Skill 管理"}),e.jsxs("div",{className:"text-sm text-gray-500",children:["共 ",(n==null?void 0:n.length)||0," 个 Skill"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:n==null?void 0:n.map(a=>e.jsx("div",{className:"bg-white rounded-lg shadow p-5 hover:shadow-md transition-shadow cursor-pointer",onClick:()=>x(a.name),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-100 flex items-center justify-center flex-shrink-0",children:e.jsx(g,{className:"h-5 w-5 text-purple-600"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-gray-900 truncate",children:a.name}),e.jsx("p",{className:"text-xs text-gray-500 mt-1 line-clamp-3",children:a.description||"(无描述)"})]})]})},a.name))}),e.jsx(y,{open:r!==null,onClose:()=>{x(null),l(!1)},title:`Skill: ${r}`,width:"w-[800px]",children:t&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(g,{className:"h-5 w-5 text-purple-600"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:t.name})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"描述"}),e.jsx("div",{className:"text-sm text-gray-800",children:t.description})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:"text-xs text-gray-500",children:"完整内容 (Markdown)"}),e.jsx("div",{className:"flex items-center gap-2",children:m?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>{l(!1),d(t.content||"")},className:"inline-flex items-center gap-1 text-xs text-gray-600 hover:text-gray-700",children:[e.jsx(k,{className:"h-3 w-3"}),"取消"]}),e.jsxs("button",{onClick:()=>o.mutate({name:t.name,content:h}),disabled:o.isPending,className:"inline-flex items-center gap-1 text-xs bg-indigo-600 text-white px-2 py-1 rounded hover:bg-indigo-700 disabled:bg-gray-400",children:[e.jsx(S,{className:"h-3 w-3"}),o.isPending?"保存中...":"保存"]})]}):e.jsxs("button",{onClick:()=>l(!0),className:"inline-flex items-center gap-1 text-xs text-indigo-600 hover:text-indigo-700",children:[e.jsx(N,{className:"h-3 w-3"}),"编辑"]})})]}),m?e.jsx("textarea",{value:h,onChange:a=>d(a.target.value),className:"w-full font-mono text-xs bg-gray-50 rounded p-3 border border-gray-300 focus:border-indigo-500 focus:outline-none",rows:20}):e.jsx("div",{className:"bg-white rounded p-3 border border-gray-200 max-h-[500px] overflow-y-auto",children:e.jsx(w,{content:t.content||""})}),o.isError&&e.jsxs("div",{className:"text-xs text-red-600 mt-1",children:["保存失败:",o.error.message]})]})]})})]})}export{R as default};
|
|
2
|
+
//# sourceMappingURL=Skills-C5-5zOSH.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Skills-zacj_uSW.js","sources":["../../src/pages/Skills.tsx"],"sourcesContent":["import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'\nimport { useState, useEffect } from 'react'\nimport { BookOpen, Edit2, Save, X } from 'lucide-react'\nimport Drawer from '../components/Drawer'\nimport MarkdownRenderer from '../components/MarkdownRenderer'\nimport { useToast } from '../components/Toast'\nimport { authFetch } from '../utils/auth'\n\ninterface Skill {\n name: string\n description: string\n content?: string\n}\n\ninterface SkillsResponse {\n skills?: Skill[]\n}\n\nasync function fetchSkills(): Promise<Skill[]> {\n const res = await fetch('/api/skills')\n if (!res.ok) throw new Error('Failed to fetch skills')\n const data: SkillsResponse | Skill[] = await res.json()\n if (Array.isArray(data)) return data\n return data.skills || []\n}\n\nasync function fetchSkillDetail(name: string): Promise<Skill> {\n const res = await fetch(`/api/skills/${name}`)\n if (!res.ok) throw new Error('Failed to fetch')\n return res.json()\n}\n\nasync function saveSkill(name: string, content: string): Promise<void> {\n const res = await authFetch(`/api/skills/${name}`, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ content }),\n })\n if (!res.ok) throw new Error('Failed to save')\n}\n\nexport default function Skills() {\n const queryClient = useQueryClient()\n const toast = useToast()\n const { data: skills, isLoading } = useQuery({\n queryKey: ['skills'],\n queryFn: fetchSkills,\n })\n\n const [selectedSkill, setSelectedSkill] = useState<string | null>(null)\n const [editing, setEditing] = useState(false)\n const [editContent, setEditContent] = useState('')\n\n const { data: detail } = useQuery({\n queryKey: ['skill-detail', selectedSkill],\n queryFn: () => fetchSkillDetail(selectedSkill!),\n enabled: !!selectedSkill,\n })\n\n useEffect(() => {\n if (detail?.content) setEditContent(detail.content)\n setEditing(false)\n }, [detail])\n\n const mutation = useMutation({\n mutationFn: (vars: { name: string; content: string }) => saveSkill(vars.name, vars.content),\n onSuccess: () => {\n toast.success('Skill 已保存')\n setEditing(false)\n queryClient.invalidateQueries({ queryKey: ['skill-detail', selectedSkill] })\n queryClient.invalidateQueries({ queryKey: ['skills'] })\n },\n onError: (e: Error) => toast.error(`保存失败: ${e.message}`),\n })\n\n if (isLoading) {\n return <div className=\"bg-white rounded-lg shadow p-6\">加载中...</div>\n }\n\n return (\n <div>\n <div className=\"flex items-center justify-between mb-6\">\n <h1 className=\"text-2xl font-bold text-gray-900\">Skill 管理</h1>\n <div className=\"text-sm text-gray-500\">共 {skills?.length || 0} 个 Skill</div>\n </div>\n\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4\">\n {skills?.map((skill) => (\n <div\n key={skill.name}\n className=\"bg-white rounded-lg shadow p-5 hover:shadow-md transition-shadow cursor-pointer\"\n onClick={() => setSelectedSkill(skill.name)}\n >\n <div className=\"flex items-start gap-3\">\n <div className=\"w-10 h-10 rounded-lg bg-purple-100 flex items-center justify-center flex-shrink-0\">\n <BookOpen className=\"h-5 w-5 text-purple-600\" />\n </div>\n <div className=\"flex-1 min-w-0\">\n <h3 className=\"font-semibold text-gray-900 truncate\">{skill.name}</h3>\n <p className=\"text-xs text-gray-500 mt-1 line-clamp-3\">\n {skill.description || '(无描述)'}\n </p>\n </div>\n </div>\n </div>\n ))}\n </div>\n\n {/* Skill Detail Drawer */}\n <Drawer\n open={selectedSkill !== null}\n onClose={() => { setSelectedSkill(null); setEditing(false) }}\n title={`Skill: ${selectedSkill}`}\n width=\"w-[800px]\"\n >\n {detail && (\n <div className=\"space-y-4\">\n <div className=\"flex items-center gap-2 mb-2\">\n <BookOpen className=\"h-5 w-5 text-purple-600\" />\n <h3 className=\"text-lg font-semibold text-gray-900\">{detail.name}</h3>\n </div>\n\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">描述</div>\n <div className=\"text-sm text-gray-800\">{detail.description}</div>\n </div>\n\n <div>\n <div className=\"flex items-center justify-between mb-2\">\n <div className=\"text-xs text-gray-500\">完整内容 (Markdown)</div>\n <div className=\"flex items-center gap-2\">\n {!editing ? (\n <button\n onClick={() => setEditing(true)}\n className=\"inline-flex items-center gap-1 text-xs text-indigo-600 hover:text-indigo-700\"\n >\n <Edit2 className=\"h-3 w-3\" />编辑\n </button>\n ) : (\n <>\n <button\n onClick={() => { setEditing(false); setEditContent(detail.content || '') }}\n className=\"inline-flex items-center gap-1 text-xs text-gray-600 hover:text-gray-700\"\n >\n <X className=\"h-3 w-3\" />取消\n </button>\n <button\n onClick={() => mutation.mutate({ name: detail.name, content: editContent })}\n disabled={mutation.isPending}\n className=\"inline-flex items-center gap-1 text-xs bg-indigo-600 text-white px-2 py-1 rounded hover:bg-indigo-700 disabled:bg-gray-400\"\n >\n <Save className=\"h-3 w-3\" />\n {mutation.isPending ? '保存中...' : '保存'}\n </button>\n </>\n )}\n </div>\n </div>\n {editing ? (\n <textarea\n value={editContent}\n onChange={(e) => setEditContent(e.target.value)}\n className=\"w-full font-mono text-xs bg-gray-50 rounded p-3 border border-gray-300 focus:border-indigo-500 focus:outline-none\"\n rows={20}\n />\n ) : (\n <div className=\"bg-white rounded p-3 border border-gray-200 max-h-[500px] overflow-y-auto\">\n <MarkdownRenderer content={detail.content || ''} />\n </div>\n )}\n {mutation.isError && (\n <div className=\"text-xs text-red-600 mt-1\">保存失败:{(mutation.error as Error).message}</div>\n )}\n </div>\n </div>\n )}\n </Drawer>\n </div>\n )\n}\n"],"names":["fetchSkills","res","data","fetchSkillDetail","name","saveSkill","content","authFetch","Skills","queryClient","useQueryClient","toast","useToast","skills","isLoading","useQuery","selectedSkill","setSelectedSkill","useState","editing","setEditing","editContent","setEditContent","detail","useEffect","mutation","useMutation","vars","e","jsx","jsxs","skill","BookOpen","Drawer","Fragment","X","Save","Edit2","MarkdownRenderer"],"mappings":"ybAkBA,eAAeA,GAAgC,CAC7C,MAAMC,EAAM,MAAM,MAAM,aAAa,EACrC,GAAI,CAACA,EAAI,GAAI,MAAM,IAAI,MAAM,wBAAwB,EACrD,MAAMC,EAAiC,MAAMD,EAAI,KAAA,EACjD,OAAI,MAAM,QAAQC,CAAI,EAAUA,EACzBA,EAAK,QAAU,CAAA,CACxB,CAEA,eAAeC,EAAiBC,EAA8B,CAC5D,MAAMH,EAAM,MAAM,MAAM,eAAeG,CAAI,EAAE,E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U,4EACb,SAAAA,EAAAA,IAACS,EAAA,CAAiB,QAASf,EAAO,SAAW,EAAA,CAAI,CAAA,CACnD,EAEDE,EAAS,SACRK,OAAC,MAAA,CAAI,UAAU,4BAA4B,SAAA,CAAA,QAAOL,EAAS,MAAgB,OAAA,CAAA,CAAQ,CAAA,CAAA,CAEvF,CAAA,CAAA,CACF,CAAA,CAAA,CAEJ,EACF,CAEJ"}
|
|
1
|
+
{"version":3,"file":"Skills-C5-5zOSH.js","sources":["../../src/pages/Skills.tsx"],"sourcesContent":["import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'\nimport { useState, useEffect } from 'react'\nimport { BookOpen, Edit2, Save, X } from 'lucide-react'\nimport Drawer from '../components/Drawer'\nimport MarkdownRenderer from '../components/MarkdownRenderer'\nimport { useToast } from '../components/Toast'\nimport { authFetch } from '../utils/auth'\n\ninterface Skill {\n name: string\n description: string\n content?: string\n}\n\ninterface SkillsResponse {\n skills?: Skill[]\n}\n\nasync function fetchSkills(): Promise<Skill[]> {\n const res = await fetch('/api/skills')\n if (!res.ok) throw new Error('Failed to fetch skills')\n const data: SkillsResponse | Skill[] = await res.json()\n if (Array.isArray(data)) return data\n return data.skills || []\n}\n\nasync function fetchSkillDetail(name: string): Promise<Skill> {\n const res = await fetch(`/api/skills/${name}`)\n if (!res.ok) throw new Error('Failed to fetch')\n return res.json()\n}\n\nasync function saveSkill(name: string, content: string): Promise<void> {\n const res = await authFetch(`/api/skills/${name}`, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ content }),\n })\n if (!res.ok) throw new Error('Failed to save')\n}\n\nexport default function Skills() {\n const queryClient = useQueryClient()\n const toast = useToast()\n const { data: skills, isLoading } = useQuery({\n queryKey: ['skills'],\n queryFn: fetchSkills,\n })\n\n const [selectedSkill, setSelectedSkill] = useState<string | null>(null)\n const [editing, setEditing] = useState(false)\n const [editContent, setEditContent] = useState('')\n\n const { data: detail } = useQuery({\n queryKey: ['skill-detail', selectedSkill],\n queryFn: () => fetchSkillDetail(selectedSkill!),\n enabled: !!selectedSkill,\n })\n\n useEffect(() => {\n if (detail?.content) setEditContent(detail.content)\n setEditing(false)\n }, [detail])\n\n const mutation = useMutation({\n mutationFn: (vars: { name: string; content: string }) => saveSkill(vars.name, vars.content),\n onSuccess: () => {\n toast.success('Skill 已保存')\n setEditing(false)\n queryClient.invalidateQueries({ queryKey: ['skill-detail', selectedSkill] })\n queryClient.invalidateQueries({ queryKey: ['skills'] })\n },\n onError: (e: Error) => toast.error(`保存失败: ${e.message}`),\n })\n\n if (isLoading) {\n return <div className=\"bg-white rounded-lg shadow p-6\">加载中...</div>\n }\n\n return (\n <div>\n <div className=\"flex items-center justify-between mb-6\">\n <h1 className=\"text-2xl font-bold text-gray-900\">Skill 管理</h1>\n <div className=\"text-sm text-gray-500\">共 {skills?.length || 0} 个 Skill</div>\n </div>\n\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4\">\n {skills?.map((skill) => (\n <div\n key={skill.name}\n className=\"bg-white rounded-lg shadow p-5 hover:shadow-md transition-shadow cursor-pointer\"\n onClick={() => setSelectedSkill(skill.name)}\n >\n <div className=\"flex items-start gap-3\">\n <div className=\"w-10 h-10 rounded-lg bg-purple-100 flex items-center justify-center flex-shrink-0\">\n <BookOpen className=\"h-5 w-5 text-purple-600\" />\n </div>\n <div className=\"flex-1 min-w-0\">\n <h3 className=\"font-semibold text-gray-900 truncate\">{skill.name}</h3>\n <p className=\"text-xs text-gray-500 mt-1 line-clamp-3\">\n {skill.description || '(无描述)'}\n </p>\n </div>\n </div>\n </div>\n ))}\n </div>\n\n {/* Skill Detail Drawer */}\n <Drawer\n open={selectedSkill !== null}\n onClose={() => { setSelectedSkill(null); setEditing(false) }}\n title={`Skill: ${selectedSkill}`}\n width=\"w-[800px]\"\n >\n {detail && (\n <div className=\"space-y-4\">\n <div className=\"flex items-center gap-2 mb-2\">\n <BookOpen className=\"h-5 w-5 text-purple-600\" />\n <h3 className=\"text-lg font-semibold text-gray-900\">{detail.name}</h3>\n </div>\n\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">描述</div>\n <div className=\"text-sm text-gray-800\">{detail.description}</div>\n </div>\n\n <div>\n <div className=\"flex items-center justify-between mb-2\">\n <div className=\"text-xs text-gray-500\">完整内容 (Markdown)</div>\n <div className=\"flex items-center gap-2\">\n {!editing ? (\n <button\n onClick={() => setEditing(true)}\n className=\"inline-flex items-center gap-1 text-xs text-indigo-600 hover:text-indigo-700\"\n >\n <Edit2 className=\"h-3 w-3\" />编辑\n </button>\n ) : (\n <>\n <button\n onClick={() => { setEditing(false); setEditContent(detail.content || '') }}\n className=\"inline-flex items-center gap-1 text-xs text-gray-600 hover:text-gray-700\"\n >\n <X className=\"h-3 w-3\" />取消\n </button>\n <button\n onClick={() => mutation.mutate({ name: detail.name, content: editContent })}\n disabled={mutation.isPending}\n className=\"inline-flex items-center gap-1 text-xs bg-indigo-600 text-white px-2 py-1 rounded hover:bg-indigo-700 disabled:bg-gray-400\"\n >\n <Save className=\"h-3 w-3\" />\n {mutation.isPending ? '保存中...' : '保存'}\n </button>\n </>\n )}\n </div>\n </div>\n {editing ? (\n <textarea\n value={editContent}\n onChange={(e) => setEditContent(e.target.value)}\n className=\"w-full font-mono text-xs bg-gray-50 rounded p-3 border border-gray-300 focus:border-indigo-500 focus:outline-none\"\n rows={20}\n />\n ) : (\n <div className=\"bg-white rounded p-3 border border-gray-200 max-h-[500px] overflow-y-auto\">\n <MarkdownRenderer content={detail.content || ''} />\n </div>\n )}\n {mutation.isError && (\n <div className=\"text-xs text-red-600 mt-1\">保存失败:{(mutation.error as Error).message}</div>\n )}\n </div>\n </div>\n )}\n </Drawer>\n </div>\n )\n}\n"],"names":["fetchSkills","res","data","fetchSkillDetail","name","saveSkill","content","authFetch","Skills","queryClient","useQueryClient","toast","useToast","skills","isLoading","useQuery","selectedSkill","setSelectedSkill","useState","editing","setEditing","editContent","setEditContent","detail","useEffect","mutation","useMut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,IAAA,CAAA,CAAA,CACnC,CAAA,CACF,EAtBAK,EAAAA,KAAC,SAAA,CACC,QAAS,IAAMV,EAAW,EAAI,EAC9B,UAAU,+EAEV,SAAA,CAAAS,EAAAA,IAACQ,EAAA,CAAM,UAAU,SAAA,CAAU,EAAE,IAAA,CAAA,CAAA,CAkB/B,CAEJ,CAAA,EACF,EACClB,EACCU,EAAAA,IAAC,WAAA,CACC,MAAOR,EACP,SAAWO,GAAMN,EAAeM,EAAE,OAAO,KAAK,EAC9C,UAAU,oHACV,KAAM,EAAA,CAAA,EAGRC,EAAAA,IAAC,MAAA,CAAI,UAAU,4EACb,SAAAA,EAAAA,IAACS,EAAA,CAAiB,QAASf,EAAO,SAAW,EAAA,CAAI,CAAA,CACnD,EAEDE,EAAS,SACRK,OAAC,MAAA,CAAI,UAAU,4BAA4B,SAAA,CAAA,QAAOL,EAAS,MAAgB,OAAA,CAAA,CAAQ,CAAA,CAAA,CAEvF,CAAA,CAAA,CACF,CAAA,CAAA,CAEJ,EACF,CAEJ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as r}from"./react-vendor-CSp-GLFF.js";import{S as l,X as d}from"./lucide-
|
|
1
|
+
import{j as r}from"./react-vendor-CSp-GLFF.js";import{S as l,X as d}from"./lucide-BanPULT1.js";function m({value:e,onChange:t,placeholder:n,className:o=""}){return r.jsxs("div",{className:`relative ${o}`,children:[r.jsx(l,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400"}),r.jsx("input",{type:"text",value:e,onChange:s=>t(s.target.value),placeholder:n||"搜索...",className:"w-full pl-8 pr-8 py-1.5 text-sm border border-gray-300 rounded-md bg-white focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500"}),e&&r.jsx("button",{onClick:()=>t(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:r.jsx(d,{className:"h-4 w-4"})})]})}function u(e,t){const n=JSON.stringify(t,null,2),o=new Blob([n],{type:"application/json"});c(e,o)}function b(e,t){if(!t||t.length===0){u(e.replace(/\.csv$/,".json"),t);return}const n=Object.keys(t[0]),o=[n.join(","),...t.map(a=>n.map(i=>p(a[i])).join(","))].join(`
|
|
2
2
|
`),s=new Blob(["\uFEFF"+o],{type:"text/csv;charset=utf-8"});c(e,s)}function p(e){if(e==null)return"";const t=typeof e=="object"?JSON.stringify(e):String(e);return t.includes(",")||t.includes('"')||t.includes(`
|
|
3
3
|
`)?`"${t.replace(/"/g,'""')}"`:t}function c(e,t){const n=URL.createObjectURL(t),o=document.createElement("a");o.href=n,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}function h(){const e=new Date,t=n=>String(n).padStart(2,"0");return`${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}`}export{m as S,b as a,u as d,h as g};
|
|
4
|
-
//# sourceMappingURL=export-
|
|
4
|
+
//# sourceMappingURL=export-CbQTOt71.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export-
|
|
1
|
+
{"version":3,"file":"export-CbQTOt71.js","sources":["../../src/components/SearchInput.tsx","../../src/utils/export.ts"],"sourcesContent":["import { Search, X } from 'lucide-react'\n\ninterface Props {\n value: string\n onChange: (value: string) => void\n placeholder?: string\n className?: string\n}\n\nexport default function SearchInput({ value, onChange, placeholder, className = '' }: Props) {\n return (\n <div className={`relative ${className}`}>\n <Search className=\"absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400\" />\n <input\n type=\"text\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n placeholder={placeholder || '搜索...'}\n className=\"w-full pl-8 pr-8 py-1.5 text-sm border border-gray-300 rounded-md bg-white focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500\"\n />\n {value && (\n <button\n onClick={() => onChange('')}\n className=\"absolute right-2 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600\"\n >\n <X className=\"h-4 w-4\" />\n </button>\n )}\n </div>\n )\n}\n","/**\n * 导出工具函数:JSON / CSV\n */\n\nexport function downloadJSON(filename: string, data: unknown): void {\n const content = JSON.stringify(data, null, 2)\n const blob = new Blob([content], { type: 'application/json' })\n triggerDownload(filename, blob)\n}\n\nexport function downloadCSV<T extends object>(filename: string, rows: T[]): void {\n if (!rows || rows.length === 0) {\n downloadJSON(filename.replace(/\\.csv$/, '.json'), rows)\n return\n }\n\n const headers = Object.keys(rows[0]) as (keyof T & string)[]\n const csv = [\n headers.join(','),\n ...rows.map(row =>\n headers.map(h => escapeCSV(row[h])).join(',')\n ),\n ].join('\\n')\n\n // 添加 BOM 让 Excel 识别 UTF-8\n const blob = new Blob(['' + csv], { type: 'text/csv;charset=utf-8' })\n triggerDownload(filename, blob)\n}\n\nfunction escapeCSV(value: unknown): string {\n if (value === null || value === undefined) return ''\n const str = typeof value === 'object' ? JSON.stringify(value) : String(value)\n if (str.includes(',') || str.includes('\"') || str.includes('\\n')) {\n return `\"${str.replace(/\"/g, '\"\"')}\"`\n }\n return str\n}\n\nfunction triggerDownload(filename: string, blob: Blob): void {\n const url = URL.createObjectURL(blob)\n const a = document.createElement('a')\n a.href = url\n a.download = filename\n document.body.appendChild(a)\n a.click()\n document.body.removeChild(a)\n URL.revokeObjectURL(url)\n}\n\nexport function getTimestamp(): string {\n const now = new Date()\n const pad = (n: number) => String(n).padStart(2, '0')\n return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`\n}\n"],"names":["SearchInput","value","onChange","placeholder","className","jsxs","jsx","Search","e","X","downloadJSON","filename","data","content","blob","triggerDownload","downloadCSV","rows","headers","csv","row","h","escapeCSV","str","url","a","getTimestamp","now","pad"],"mappings":"+FASA,SAAwBA,EAAY,CAAE,MAAAC,EAAO,SAAAC,EAAU,YAAAC,EAAa,UAAAC,EAAY,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I,OAAOA,CAAK,EAC5E,OAAIsB,EAAI,SAAS,GAAG,GAAKA,EAAI,SAAS,GAAG,GAAKA,EAAI,SAAS;AAAA,CAAI,EACtD,IAAIA,EAAI,QAAQ,KAAM,IAAI,CAAC,IAE7BA,CACT,CAEA,SAASR,EAAgBJ,EAAkBG,EAAkB,CAC3D,MAAMU,EAAM,IAAI,gBAAgBV,CAAI,EAC9BW,EAAI,SAAS,cAAc,GAAG,EACpCA,EAAE,KAAOD,EACTC,EAAE,SAAWd,EACb,SAAS,KAAK,YAAYc,CAAC,EAC3BA,EAAE,MAAA,EACF,SAAS,KAAK,YAAYA,CAAC,EAC3B,IAAI,gBAAgBD,CAAG,CACzB,CAEO,SAASE,GAAuB,CACrC,MAAMC,MAAU,KACVC,EAAO,GAAc,OAAO,CAAC,EAAE,SAAS,EAAG,GAAG,EACpD,MAAO,GAAGD,EAAI,YAAA,CAAa,GAAGC,EAAID,EAAI,SAAA,EAAa,CAAC,CAAC,GAAGC,EAAID,EAAI,SAAS,CAAC,IAAIC,EAAID,EAAI,SAAA,CAAU,CAAC,GAAGC,EAAID,EAAI,WAAA,CAAY,CAAC,GAAGC,EAAID,EAAI,WAAA,CAAY,CAAC,EACnJ"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-
|
|
2
|
-
import{r as s,j as e,e as y,d as v}from"./react-vendor-CSp-GLFF.js";import{u as N,O as w,L as _,R as C,a as c,N as k,B as E}from"./react-router-I-HqunH7.js";import{Q as P,a as T}from"./query-C99w429o.js";import{_ as x}from"./syntax-highlighter-44FakypI.js";import{d as f}from"./vendor-CMMjVdZs.js";import{X as p,M as O,L as A,a as S,A as L,T as I,G as R,B as z,b as D,N as V,C as F,I as B,c as M,d as q,e as Q,f as G}from"./lucide-DjB4fWNj.js";(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))l(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const t of n.addedNodes)t.tagName==="LINK"&&t.rel==="modulepreload"&&l(t)}).observe(document,{childList:!0,subtree:!0});function a(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function l(r){if(r.ep)return;r.ep=!0;const n=a(r);fetch(r.href,n)}})();const W=[{title:"总览",items:[{name:"仪表盘",href:"/dashboard",icon:A}]},{title:"活动",items:[{name:"会话",href:"/sessions",icon:S},{name:"事件",href:"/events",icon:L},{name:"执行追踪",href:"/execution-trace",icon:I},{name:"方法论执行",href:"/methodologies",icon:R}]},{title:"配置",items:[{name:"Agent 管理",href:"/agents",icon:z},{name:"Skill 管理",href:"/skills",icon:D},{name:"Agent 路由",href:"/routing",icon:V},{name:"AI 配置",href:"/ai-config",icon:F}]}];function X(){const o=N(),[i,a]=s.useState(!1),l=r=>e.jsx(e.Fragment,{children:W.map(n=>e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"px-3 py-2 text-xs font-semibold text-gray-400 uppercase tracking-wider",children:n.title}),n.items.map(t=>{const u=t.icon,m=o.pathname===t.href||o.pathname.startsWith(t.href+"/");return e.jsxs(_,{to:t.href,onClick:r,className:f("group flex items-center px-3 py-2 text-sm font-medium rounded-md mb-0.5",m?"bg-indigo-50 text-indigo-600":"text-gray-700 hover:bg-gray-50"),children:[e.jsx(u,{className:f("mr-3 h-4 w-4",m?"text-indigo-600":"text-gray-400")}),t.name]},t.name)})]},n.title))});return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsxs("div",{className:f("fixed inset-0 z-40 lg:hidden",i?"block":"hidden"),children:[e.jsx("div",{className:"fixed inset-0 bg-gray-600 bg-opacity-75",onClick:()=>a(!1)}),e.jsxs("div",{className:"fixed inset-y-0 left-0 flex w-64 flex-col bg-white",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center text-white font-bold text-sm",children:"CF"}),e.jsx("h1",{className:"text-base font-bold text-gray-900",children:"Claude Forge"})]}),e.jsx("button",{onClick:()=>a(!1),className:"text-gray-500",children:e.jsx(p,{className:"h-5 w-5"})})]}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-2 py-4",children:l(()=>a(!1))})]})]}),e.jsx("div",{className:"hidden lg:fixed lg:inset-y-0 lg:flex lg:w-64 lg:flex-col",children:e.jsxs("div",{className:"flex flex-col flex-grow border-r border-gray-200 bg-white",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-4 border-b",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center text-white font-bold text-sm",children:"CF"}),e.jsx("h1",{className:"text-base font-bold text-gray-900",children:"Claude Forge"})]}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-2 py-4",children:l()})]})}),e.jsxs("div",{className:"lg:pl-64",children:[e.jsxs("div",{className:"sticky top-0 z-10 flex h-14 flex-shrink-0 bg-white border-b border-gray-200 lg:hidden",children:[e.jsx("button",{onClick:()=>a(!0),className:"px-4 text-gray-500 focus:outline-none",children:e.jsx(O,{className:"h-5 w-5"})}),e.jsx("div",{className:"flex flex-1 items-center px-4",children:e.jsx("h1",{className:"text-base font-semibold text-gray-900",children:"Claude Forge"})})]}),e.jsx("main",{className:"py-6",children:e.jsx("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8",children:e.jsx(w,{})})})]})]})}const $=s.lazy(()=>x(()=>import("./Dashboard-qUCxXFSI.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),K=s.lazy(()=>x(()=>import("./Sessions-DOd65EkN.js"),__vite__mapDeps([7,1,2,8,4,5,9,10,3,11]))),U=s.lazy(()=>x(()=>import("./SessionDetail-DzTue2xK.js"),__vite__mapDeps([12,1,3,4,2,5,9]))),H=s.lazy(()=>x(()=>import("./Events-DqzBTrly.js"),__vite__mapDeps([13,1,2,4,8,5,14,11,10,9,3]))),J=s.lazy(()=>x(()=>import("./ExecutionTrace-Z-zlH0KH.js"),__vite__mapDeps([15,1,2,4,8,5,14,11,10,9,3]))),Y=s.lazy(()=>x(()=>import("./Methodologies-Br5KOWuF.js"),__vite__mapDeps([16,1,2,3,4,17,5,9,11]))),Z=s.lazy(()=>x(()=>import("./MethodologyDetail-Do1taSKM.js"),__vite__mapDeps([18,1,3,4,2,5,9]))),ee=s.lazy(()=>x(()=>import("./Agents-D1p3JhQs.js"),__vite__mapDeps([19,1,2,8,4,5,20,11,17,3]))),se=s.lazy(()=>x(()=>import("./Skills-zacj_uSW.js"),__vite__mapDeps([21,1,2,8,4,5,20,11,17,3]))),te=s.lazy(()=>x(()=>import("./Routing-CFmM7JuB.js"),__vite__mapDeps([22,1,2,3,4,5]))),re=s.lazy(()=>x(()=>import("./AIConfig-Dw13rVtT.js"),__vite__mapDeps([23,1,2,17,5,3,4,11])));function d(){return e.jsx("div",{className:"flex items-center justify-center h-full py-16",children:e.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-500",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"}),"加载中..."]})})}function ne(){return e.jsx(C,{children:e.jsxs(c,{path:"/",element:e.jsx(X,{}),children:[e.jsx(c,{index:!0,element:e.jsx(k,{to:"/dashboard",replace:!0})}),e.jsx(c,{path:"dashboard",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx($,{})})}),e.jsx(c,{path:"sessions",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(K,{})})}),e.jsx(c,{path:"sessions/:id",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(U,{})})}),e.jsx(c,{path:"events",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(H,{})})}),e.jsx(c,{path:"execution-trace",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(J,{})})}),e.jsx(c,{path:"methodologies",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(Y,{})})}),e.jsx(c,{path:"methodologies/:id",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(Z,{})})}),e.jsx(c,{path:"agents",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(ee,{})})}),e.jsx(c,{path:"skills",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(se,{})})}),e.jsx(c,{path:"routing",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(te,{})})}),e.jsx(c,{path:"ai-config",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(re,{})})})]})})}const g=s.createContext(null);function pe(){const o=s.useContext(g);if(!o)throw new Error("useToast must be used within ToastProvider");return o}let ie=1;function oe({children:o}){const[i,a]=s.useState([]),l=s.useCallback(t=>{a(u=>u.filter(m=>m.id!==t))},[]),r=s.useCallback((t,u)=>{const m=ie++;a(h=>[...h,{id:m,type:t,message:u}]),setTimeout(()=>l(m),4e3)},[l]),n={show:r,success:t=>r("success",t),error:t=>r("error",t),warning:t=>r("warning",t),info:t=>r("info",t)};return e.jsxs(g.Provider,{value:n,children:[o,e.jsx("div",{className:"fixed top-4 right-4 z-[9999] space-y-2 max-w-md",children:i.map(t=>e.jsx(ae,{toast:t,onClose:()=>l(t.id)},t.id))})]})}function ae({toast:o,onClose:i}){const a={success:e.jsx(Q,{className:"h-5 w-5 text-green-500"}),error:e.jsx(q,{className:"h-5 w-5 text-red-500"}),warning:e.jsx(M,{className:"h-5 w-5 text-yellow-500"}),info:e.jsx(B,{className:"h-5 w-5 text-blue-500"})},l={success:"border-green-200",error:"border-red-200",warning:"border-yellow-200",info:"border-blue-200"};return e.jsxs("div",{className:f("bg-white shadow-lg rounded-lg border px-4 py-3 flex items-start gap-3 animate-in slide-in-from-right",l[o.type]),children:[a[o.type],e.jsx("div",{className:"flex-1 text-sm text-gray-800",children:o.message}),e.jsx("button",{onClick:i,className:"text-gray-400 hover:text-gray-600",children:e.jsx(p,{className:"h-4 w-4"})})]})}const j=s.createContext(null);function ge(){const o=s.useContext(j);if(!o)throw new Error("useConfirm must be used within ConfirmProvider");return o.confirm}function le({children:o}){var m;const[i,a]=s.useState({open:!1,options:null,resolve:null}),l=s.useCallback(h=>new Promise(b=>{a({open:!0,options:h,resolve:b})}),[]),r=h=>{i.resolve&&i.resolve(h),a({open:!1,options:null,resolve:null})},n=((m=i.options)==null?void 0:m.variant)||"danger",t={danger:"text-red-600",warning:"text-yellow-600",info:"text-blue-600"}[n],u={danger:"bg-red-600 hover:bg-red-700",warning:"bg-yellow-600 hover:bg-yellow-700",info:"bg-indigo-600 hover:bg-indigo-700"}[n];return e.jsxs(j.Provider,{value:{confirm:l},children:[o,i.open&&i.options&&e.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black bg-opacity-50",onClick:()=>r(!1)}),e.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl max-w-md w-full mx-4 p-6",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:`flex-shrink-0 ${t}`,children:e.jsx(G,{className:"h-6 w-6"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:i.options.title}),e.jsx("p",{className:"text-sm text-gray-600 whitespace-pre-wrap",children:i.options.message})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-6",children:[e.jsx("button",{onClick:()=>r(!1),className:"px-4 py-2 text-sm text-gray-700 bg-white border border-gray-300 rounded hover:bg-gray-50",children:i.options.cancelText||"取消"}),e.jsx("button",{onClick:()=>r(!0),className:`px-4 py-2 text-sm text-white rounded ${u}`,children:i.options.confirmText||"确定"})]})]})]})]})}const ce=new P({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}});y.createRoot(document.getElementById("root")).render(e.jsx(v.StrictMode,{children:e.jsx(T,{client:ce,children:e.jsx(oe,{children:e.jsx(le,{children:e.jsx(E,{children:e.jsx(ne,{})})})})})}));export{ge as a,pe as u};
|
|
3
|
-
//# sourceMappingURL=index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-Ciyyw6ph.js","assets/react-vendor-CSp-GLFF.js","assets/query-C99w429o.js","assets/react-router-I-HqunH7.js","assets/vendor-CMMjVdZs.js","assets/lucide-BanPULT1.js","assets/charts-CLrM0_uM.js","assets/Sessions-ZQSCgXyy.js","assets/Drawer-DOUcx6m1.js","assets/date-fns-CZ_bHujz.js","assets/export-CbQTOt71.js","assets/syntax-highlighter-44FakypI.js","assets/SessionDetail-Cbd7Jwox.js","assets/Events-DQHP6Uaq.js","assets/CodeBlock--H53gk46.js","assets/ExecutionTrace-Co8ARdg-.js","assets/Methodologies-CXNrDXwG.js","assets/auth-Bnf8ZcqN.js","assets/MethodologyDetail-rV3W1utf.js","assets/Agents-bNNGbQnL.js","assets/MarkdownRenderer-CCIz1MOz.js","assets/Skills-C5-5zOSH.js","assets/Routing-BW3eGD-8.js","assets/AIConfig-DiUFET_Q.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as s,j as e,e as y,d as v}from"./react-vendor-CSp-GLFF.js";import{u as N,O as w,L as _,R as C,a as c,N as k,B as E}from"./react-router-I-HqunH7.js";import{Q as P,a as T}from"./query-C99w429o.js";import{_ as x}from"./syntax-highlighter-44FakypI.js";import{d as f}from"./vendor-CMMjVdZs.js";import{X as p,M as O,L as A,a as S,A as L,T as I,G as R,B as z,b as D,N as V,C as F,I as B,c as M,d as q,e as Q,f as G}from"./lucide-BanPULT1.js";(function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))l(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const t of n.addedNodes)t.tagName==="LINK"&&t.rel==="modulepreload"&&l(t)}).observe(document,{childList:!0,subtree:!0});function a(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function l(r){if(r.ep)return;r.ep=!0;const n=a(r);fetch(r.href,n)}})();const W=[{title:"总览",items:[{name:"仪表盘",href:"/dashboard",icon:A}]},{title:"活动",items:[{name:"会话",href:"/sessions",icon:S},{name:"事件",href:"/events",icon:L},{name:"执行追踪",href:"/execution-trace",icon:I},{name:"方法论执行",href:"/methodologies",icon:R}]},{title:"配置",items:[{name:"Agent 管理",href:"/agents",icon:z},{name:"Skill 管理",href:"/skills",icon:D},{name:"Agent 路由",href:"/routing",icon:V},{name:"AI 配置",href:"/ai-config",icon:F}]}];function X(){const o=N(),[i,a]=s.useState(!1),l=r=>e.jsx(e.Fragment,{children:W.map(n=>e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"px-3 py-2 text-xs font-semibold text-gray-400 uppercase tracking-wider",children:n.title}),n.items.map(t=>{const u=t.icon,m=o.pathname===t.href||o.pathname.startsWith(t.href+"/");return e.jsxs(_,{to:t.href,onClick:r,className:f("group flex items-center px-3 py-2 text-sm font-medium rounded-md mb-0.5",m?"bg-indigo-50 text-indigo-600":"text-gray-700 hover:bg-gray-50"),children:[e.jsx(u,{className:f("mr-3 h-4 w-4",m?"text-indigo-600":"text-gray-400")}),t.name]},t.name)})]},n.title))});return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsxs("div",{className:f("fixed inset-0 z-40 lg:hidden",i?"block":"hidden"),children:[e.jsx("div",{className:"fixed inset-0 bg-gray-600 bg-opacity-75",onClick:()=>a(!1)}),e.jsxs("div",{className:"fixed inset-y-0 left-0 flex w-64 flex-col bg-white",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-4 border-b",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center text-white font-bold text-sm",children:"CF"}),e.jsx("h1",{className:"text-base font-bold text-gray-900",children:"Claude Forge"})]}),e.jsx("button",{onClick:()=>a(!1),className:"text-gray-500",children:e.jsx(p,{className:"h-5 w-5"})})]}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-2 py-4",children:l(()=>a(!1))})]})]}),e.jsx("div",{className:"hidden lg:fixed lg:inset-y-0 lg:flex lg:w-64 lg:flex-col",children:e.jsxs("div",{className:"flex flex-col flex-grow border-r border-gray-200 bg-white",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-4 border-b",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center text-white font-bold text-sm",children:"CF"}),e.jsx("h1",{className:"text-base font-bold text-gray-900",children:"Claude Forge"})]}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-2 py-4",children:l()})]})}),e.jsxs("div",{className:"lg:pl-64",children:[e.jsxs("div",{className:"sticky top-0 z-10 flex h-14 flex-shrink-0 bg-white border-b border-gray-200 lg:hidden",children:[e.jsx("button",{onClick:()=>a(!0),className:"px-4 text-gray-500 focus:outline-none",children:e.jsx(O,{className:"h-5 w-5"})}),e.jsx("div",{className:"flex flex-1 items-center px-4",children:e.jsx("h1",{className:"text-base font-semibold text-gray-900",children:"Claude Forge"})})]}),e.jsx("main",{className:"py-6",children:e.jsx("div",{className:"mx-auto max-w-7xl px-4 sm:px-6 lg:px-8",children:e.jsx(w,{})})})]})]})}const $=s.lazy(()=>x(()=>import("./Dashboard-Ciyyw6ph.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),K=s.lazy(()=>x(()=>import("./Sessions-ZQSCgXyy.js"),__vite__mapDeps([7,1,2,8,4,5,9,10,3,11]))),U=s.lazy(()=>x(()=>import("./SessionDetail-Cbd7Jwox.js"),__vite__mapDeps([12,1,3,4,2,5,9]))),H=s.lazy(()=>x(()=>import("./Events-DQHP6Uaq.js"),__vite__mapDeps([13,1,2,4,8,5,14,11,10,9,3]))),J=s.lazy(()=>x(()=>import("./ExecutionTrace-Co8ARdg-.js"),__vite__mapDeps([15,1,2,4,8,5,14,11,10,9,3]))),Y=s.lazy(()=>x(()=>import("./Methodologies-CXNrDXwG.js"),__vite__mapDeps([16,1,2,3,4,17,5,9,11]))),Z=s.lazy(()=>x(()=>import("./MethodologyDetail-rV3W1utf.js"),__vite__mapDeps([18,1,3,4,2,5,9]))),ee=s.lazy(()=>x(()=>import("./Agents-bNNGbQnL.js"),__vite__mapDeps([19,1,2,8,4,5,20,11,17,3]))),se=s.lazy(()=>x(()=>import("./Skills-C5-5zOSH.js"),__vite__mapDeps([21,1,2,8,4,5,20,11,17,3]))),te=s.lazy(()=>x(()=>import("./Routing-BW3eGD-8.js"),__vite__mapDeps([22,1,2,3,4,5]))),re=s.lazy(()=>x(()=>import("./AIConfig-DiUFET_Q.js"),__vite__mapDeps([23,1,2,17,5,3,4,11])));function d(){return e.jsx("div",{className:"flex items-center justify-center h-full py-16",children:e.jsxs("div",{className:"flex items-center gap-3 text-sm text-gray-500",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-gray-300 border-t-blue-500 rounded-full animate-spin"}),"加载中..."]})})}function ne(){return e.jsx(C,{children:e.jsxs(c,{path:"/",element:e.jsx(X,{}),children:[e.jsx(c,{index:!0,element:e.jsx(k,{to:"/dashboard",replace:!0})}),e.jsx(c,{path:"dashboard",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx($,{})})}),e.jsx(c,{path:"sessions",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(K,{})})}),e.jsx(c,{path:"sessions/:id",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(U,{})})}),e.jsx(c,{path:"events",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(H,{})})}),e.jsx(c,{path:"execution-trace",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(J,{})})}),e.jsx(c,{path:"methodologies",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(Y,{})})}),e.jsx(c,{path:"methodologies/:id",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(Z,{})})}),e.jsx(c,{path:"agents",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(ee,{})})}),e.jsx(c,{path:"skills",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(se,{})})}),e.jsx(c,{path:"routing",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(te,{})})}),e.jsx(c,{path:"ai-config",element:e.jsx(s.Suspense,{fallback:e.jsx(d,{}),children:e.jsx(re,{})})})]})})}const g=s.createContext(null);function pe(){const o=s.useContext(g);if(!o)throw new Error("useToast must be used within ToastProvider");return o}let ie=1;function oe({children:o}){const[i,a]=s.useState([]),l=s.useCallback(t=>{a(u=>u.filter(m=>m.id!==t))},[]),r=s.useCallback((t,u)=>{const m=ie++;a(h=>[...h,{id:m,type:t,message:u}]),setTimeout(()=>l(m),4e3)},[l]),n={show:r,success:t=>r("success",t),error:t=>r("error",t),warning:t=>r("warning",t),info:t=>r("info",t)};return e.jsxs(g.Provider,{value:n,children:[o,e.jsx("div",{className:"fixed top-4 right-4 z-[9999] space-y-2 max-w-md",children:i.map(t=>e.jsx(ae,{toast:t,onClose:()=>l(t.id)},t.id))})]})}function ae({toast:o,onClose:i}){const a={success:e.jsx(Q,{className:"h-5 w-5 text-green-500"}),error:e.jsx(q,{className:"h-5 w-5 text-red-500"}),warning:e.jsx(M,{className:"h-5 w-5 text-yellow-500"}),info:e.jsx(B,{className:"h-5 w-5 text-blue-500"})},l={success:"border-green-200",error:"border-red-200",warning:"border-yellow-200",info:"border-blue-200"};return e.jsxs("div",{className:f("bg-white shadow-lg rounded-lg border px-4 py-3 flex items-start gap-3 animate-in slide-in-from-right",l[o.type]),children:[a[o.type],e.jsx("div",{className:"flex-1 text-sm text-gray-800",children:o.message}),e.jsx("button",{onClick:i,className:"text-gray-400 hover:text-gray-600",children:e.jsx(p,{className:"h-4 w-4"})})]})}const j=s.createContext(null);function ge(){const o=s.useContext(j);if(!o)throw new Error("useConfirm must be used within ConfirmProvider");return o.confirm}function le({children:o}){var m;const[i,a]=s.useState({open:!1,options:null,resolve:null}),l=s.useCallback(h=>new Promise(b=>{a({open:!0,options:h,resolve:b})}),[]),r=h=>{i.resolve&&i.resolve(h),a({open:!1,options:null,resolve:null})},n=((m=i.options)==null?void 0:m.variant)||"danger",t={danger:"text-red-600",warning:"text-yellow-600",info:"text-blue-600"}[n],u={danger:"bg-red-600 hover:bg-red-700",warning:"bg-yellow-600 hover:bg-yellow-700",info:"bg-indigo-600 hover:bg-indigo-700"}[n];return e.jsxs(j.Provider,{value:{confirm:l},children:[o,i.open&&i.options&&e.jsxs("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black bg-opacity-50",onClick:()=>r(!1)}),e.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl max-w-md w-full mx-4 p-6",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:`flex-shrink-0 ${t}`,children:e.jsx(G,{className:"h-6 w-6"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:i.options.title}),e.jsx("p",{className:"text-sm text-gray-600 whitespace-pre-wrap",children:i.options.message})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-6",children:[e.jsx("button",{onClick:()=>r(!1),className:"px-4 py-2 text-sm text-gray-700 bg-white border border-gray-300 rounded hover:bg-gray-50",children:i.options.cancelText||"取消"}),e.jsx("button",{onClick:()=>r(!0),className:`px-4 py-2 text-sm text-white rounded ${u}`,children:i.options.confirmText||"确定"})]})]})]})]})}const ce=new P({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}});y.createRoot(document.getElementById("root")).render(e.jsx(v.StrictMode,{children:e.jsx(T,{client:ce,children:e.jsx(oe,{children:e.jsx(le,{children:e.jsx(E,{children:e.jsx(ne,{})})})})})}));export{ge as a,pe as u};
|
|
3
|
+
//# sourceMappingURL=index-DJK5beK6.js.map
|