@winspan/claude-forge 8.33.0 → 8.33.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/cli/commands/init.d.ts.map +1 -1
  2. package/dist/cli/commands/init.js +82 -2
  3. package/dist/cli/commands/init.js.map +1 -1
  4. package/dist/web/static/assets/AIConfig-Dw13rVtT.js +2 -0
  5. package/dist/web/static/assets/AIConfig-Dw13rVtT.js.map +1 -0
  6. package/dist/web/static/assets/Agents-D1p3JhQs.js +2 -0
  7. package/dist/web/static/assets/Agents-D1p3JhQs.js.map +1 -0
  8. package/dist/web/static/assets/{Events-BoQ8Fo5k.js → Events-DqzBTrly.js} +2 -2
  9. package/dist/web/static/assets/{Events-BoQ8Fo5k.js.map → Events-DqzBTrly.js.map} +1 -1
  10. package/dist/web/static/assets/{ExecutionTrace-sFZ_vHNf.js → ExecutionTrace-Z-zlH0KH.js} +2 -2
  11. package/dist/web/static/assets/{ExecutionTrace-sFZ_vHNf.js.map → ExecutionTrace-Z-zlH0KH.js.map} +1 -1
  12. package/dist/web/static/assets/Methodologies-Br5KOWuF.js +5 -0
  13. package/dist/web/static/assets/Methodologies-Br5KOWuF.js.map +1 -0
  14. package/dist/web/static/assets/{Sessions-Bjf-Mvwb.js → Sessions-DOd65EkN.js} +2 -2
  15. package/dist/web/static/assets/{Sessions-Bjf-Mvwb.js.map → Sessions-DOd65EkN.js.map} +1 -1
  16. package/dist/web/static/assets/Skills-zacj_uSW.js +2 -0
  17. package/dist/web/static/assets/Skills-zacj_uSW.js.map +1 -0
  18. package/dist/web/static/assets/auth-Bnf8ZcqN.js +2 -0
  19. package/dist/web/static/assets/auth-Bnf8ZcqN.js.map +1 -0
  20. package/dist/web/static/assets/index-BVpUTHdp.js +3 -0
  21. package/dist/web/static/assets/{index-D23sAOAt.js.map → index-BVpUTHdp.js.map} +1 -1
  22. package/dist/web/static/index.html +1 -1
  23. package/package.json +2 -2
  24. package/dist/web/static/assets/AIConfig-D-vrYoJ3.js +0 -2
  25. package/dist/web/static/assets/AIConfig-D-vrYoJ3.js.map +0 -1
  26. package/dist/web/static/assets/Agents-DAGWYsJj.js +0 -2
  27. package/dist/web/static/assets/Agents-DAGWYsJj.js.map +0 -1
  28. package/dist/web/static/assets/Methodologies-C0-Keokj.js +0 -5
  29. package/dist/web/static/assets/Methodologies-C0-Keokj.js.map +0 -1
  30. package/dist/web/static/assets/Skills-CrLshkrJ.js +0 -2
  31. package/dist/web/static/assets/Skills-CrLshkrJ.js.map +0 -1
  32. package/dist/web/static/assets/index-D23sAOAt.js +0 -3
@@ -1 +1 @@
1
- {"version":3,"file":"ExecutionTrace-sFZ_vHNf.js","sources":["../../src/pages/ExecutionTrace.tsx"],"sourcesContent":["import { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useState, useEffect, useMemo } from 'react'\nimport { format } from 'date-fns'\nimport { CheckCircle, XCircle, HelpCircle, Activity, Wifi, WifiOff, Download } from 'lucide-react'\nimport clsx from 'clsx'\nimport Drawer from '../components/Drawer'\nimport CodeBlock from '../components/CodeBlock'\nimport SearchInput from '../components/SearchInput'\nimport { downloadJSON, downloadCSV, getTimestamp } from '../utils/export'\nimport { useToast } from '../components/Toast'\n\ninterface RoutingEvent {\n id: number\n session_id: string\n project_path: string\n ts: number\n prompt: string\n intent_json: string\n routed_to_type: string\n routed_to_name: string\n is_forced: number\n obeyed: number | null\n classification_ms: number\n fallback_used: number\n refusal_reason: string | null\n first_tool_name: string | null\n first_tool_ts: number | null\n completed_ts: number | null\n total_execution_ms: number | null\n completion_reason: string | null\n}\n\nasync function fetchRoutingEvents(filter?: string): Promise<RoutingEvent[]> {\n let url = '/api/routing/events?limit=200'\n if (filter === 'obeyed') url += '&obeyed=1'\n else if (filter === 'refused') url += '&obeyed=0'\n else if (filter === 'unknown') url += '&obeyed=null'\n const res = await fetch(url)\n if (!res.ok) throw new Error('Failed to fetch')\n return res.json()\n}\n\nconst filters = [\n { value: '', label: '全部' },\n { value: 'obeyed', label: '✅ 遵守' },\n { value: 'refused', label: '❌ 违抗' },\n { value: 'unknown', label: '? 未判定' },\n]\n\nexport default function ExecutionTrace() {\n const [filter, setFilter] = useState('')\n const [search, setSearch] = useState('')\n const [selectedEvent, setSelectedEvent] = useState<RoutingEvent | null>(null)\n const [sseConnected, setSseConnected] = useState(false)\n const [showExportMenu, setShowExportMenu] = useState(false)\n const toast = useToast()\n const queryClient = useQueryClient()\n\n useEffect(() => {\n const eventSource = new EventSource('/api/execution-trace/stream')\n eventSource.onopen = () => setSseConnected(true)\n eventSource.onerror = () => setSseConnected(false)\n eventSource.onmessage = (e) => {\n try {\n const data = JSON.parse(e.data)\n if (data.type === 'execution-status') {\n queryClient.invalidateQueries({ queryKey: ['routing-events'] })\n }\n } catch { /* ignore */ }\n }\n return () => {\n eventSource.close()\n setSseConnected(false)\n }\n }, [queryClient])\n\n const { data: events, isLoading } = useQuery({\n queryKey: ['routing-events', filter],\n queryFn: () => fetchRoutingEvents(filter),\n refetchInterval: 10000,\n })\n\n const filteredEvents = useMemo(() => {\n if (!events) return []\n if (!search.trim()) return events\n const q = search.toLowerCase()\n return events.filter(e =>\n e.prompt?.toLowerCase().includes(q) ||\n e.routed_to_name?.toLowerCase().includes(q) ||\n e.first_tool_name?.toLowerCase().includes(q)\n )\n }, [events, search])\n\n const handleExport = (exportFormat: 'json' | 'csv') => {\n const ts = getTimestamp()\n if (exportFormat === 'json') {\n downloadJSON(`routing-events-${ts}.json`, filteredEvents)\n } else {\n const flat = filteredEvents.map(e => {\n let intent: { taskType?: string; complexity?: string } = {}\n try { intent = JSON.parse(e.intent_json || '{}') } catch { /* ignore */ }\n return {\n id: e.id,\n ts: e.ts ? format(e.ts, 'yyyy-MM-dd HH:mm:ss') : '',\n prompt: e.prompt,\n taskType: intent.taskType || '',\n complexity: intent.complexity || '',\n routed_to: e.routed_to_name || '',\n obeyed: e.obeyed === 1 ? 'yes' : e.obeyed === 0 ? 'no' : '',\n first_tool: e.first_tool_name || '',\n duration_ms: e.total_execution_ms || '',\n refusal_reason: e.refusal_reason || '',\n }\n })\n downloadCSV(`routing-events-${ts}.csv`, flat)\n }\n toast.success(`已导出 ${filteredEvents.length} 条追踪记录`)\n setShowExportMenu(false)\n }\n\n return (\n <div>\n <div className=\"flex items-center justify-between mb-4 flex-wrap gap-3\">\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900\">执行追踪</h1>\n <div className=\"flex items-center gap-2 mt-1\">\n {sseConnected ? (\n <>\n <Wifi className=\"h-3 w-3 text-green-500\" />\n <span className=\"text-xs text-green-600\">实时流已连接</span>\n </>\n ) : (\n <>\n <WifiOff className=\"h-3 w-3 text-gray-400\" />\n <span className=\"text-xs text-gray-500\">实时流未连接</span>\n </>\n )}\n </div>\n </div>\n <div className=\"flex items-center gap-2 flex-wrap\">\n <SearchInput\n value={search}\n onChange={setSearch}\n placeholder=\"搜索 prompt / agent / tool...\"\n className=\"w-56\"\n />\n <div className=\"flex items-center gap-1\">\n {filters.map((f) => (\n <button\n key={f.value}\n onClick={() => setFilter(f.value)}\n className={clsx(\n 'px-2.5 py-1.5 text-xs rounded-md',\n filter === f.value\n ? 'bg-indigo-100 text-indigo-700'\n : 'bg-white text-gray-600 border border-gray-300 hover:bg-gray-50'\n )}\n >\n {f.label}\n </button>\n ))}\n </div>\n <div className=\"relative\">\n <button\n onClick={() => setShowExportMenu(v => !v)}\n disabled={filteredEvents.length === 0}\n className=\"inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-white border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50\"\n >\n <Download className=\"h-4 w-4\" />\n 导出\n </button>\n {showExportMenu && (\n <>\n <div className=\"fixed inset-0 z-10\" onClick={() => setShowExportMenu(false)} />\n <div className=\"absolute right-0 mt-1 bg-white border border-gray-200 rounded-md shadow-lg z-20\">\n <button\n onClick={() => handleExport('json')}\n className=\"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50\"\n >\n 导出为 JSON\n </button>\n <button\n onClick={() => handleExport('csv')}\n className=\"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50\"\n >\n 导出为 CSV\n </button>\n </div>\n </>\n )}\n </div>\n </div>\n </div>\n\n <div className=\"text-sm text-gray-500 mb-3\">\n 显示 {filteredEvents.length} 条 {search && `(已过滤)`}\n </div>\n\n <div className=\"bg-white rounded-lg shadow overflow-hidden\">\n {isLoading ? (\n <div className=\"p-6\">加载中...</div>\n ) : (\n <table className=\"min-w-full divide-y divide-gray-200\">\n <thead className=\"bg-gray-50\">\n <tr>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">时间</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">提示</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">路由到</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">遵守</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">首工具</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">耗时</th>\n </tr>\n </thead>\n <tbody className=\"bg-white divide-y divide-gray-200\">\n {filteredEvents.map((e) => {\n let intent: any = {}\n try { intent = JSON.parse(e.intent_json || '{}') } catch { /* ignore */ }\n return (\n <tr\n key={e.id}\n className=\"hover:bg-gray-50 cursor-pointer\"\n onClick={() => setSelectedEvent(e)}\n >\n <td className=\"px-4 py-2 whitespace-nowrap text-xs font-mono text-gray-500\">\n {format(e.ts, 'MM-dd HH:mm:ss')}\n </td>\n <td className=\"px-4 py-2 max-w-xs\">\n <p className=\"text-xs text-gray-700 truncate\" title={e.prompt}>{e.prompt}</p>\n <p className=\"text-xs text-gray-400 mt-0.5\">\n {intent.taskType} / {intent.complexity}\n </p>\n </td>\n <td className=\"px-4 py-2 whitespace-nowrap\">\n {e.routed_to_name ? (\n <span className=\"px-2 py-0.5 text-xs font-medium bg-indigo-100 text-indigo-700 rounded\">\n {e.routed_to_name}\n </span>\n ) : (\n <span className=\"text-xs text-gray-400\">未路由</span>\n )}\n </td>\n <td className=\"px-4 py-2 whitespace-nowrap\">\n {e.obeyed === 1 ? (\n <span className=\"inline-flex items-center gap-1 text-green-600 text-xs\">\n <CheckCircle className=\"h-4 w-4\" />遵守\n </span>\n ) : e.obeyed === 0 ? (\n <span className=\"inline-flex items-center gap-1 text-red-600 text-xs\">\n <XCircle className=\"h-4 w-4\" />违抗\n </span>\n ) : (\n <span className=\"inline-flex items-center gap-1 text-gray-400 text-xs\">\n <HelpCircle className=\"h-4 w-4\" />?\n </span>\n )}\n </td>\n <td className=\"px-4 py-2 whitespace-nowrap text-xs text-gray-700\">\n {e.first_tool_name || '-'}\n </td>\n <td className=\"px-4 py-2 whitespace-nowrap text-xs font-mono text-gray-500\">\n {e.total_execution_ms ? `${(e.total_execution_ms / 1000).toFixed(1)}s` : '-'}\n </td>\n </tr>\n )\n })}\n {filteredEvents.length === 0 && (\n <tr>\n <td colSpan={6} className=\"px-4 py-12 text-center text-gray-500\">\n <Activity className=\"h-12 w-12 text-gray-300 mx-auto mb-2\" />\n {search ? '无匹配结果' : '暂无追踪记录'}\n </td>\n </tr>\n )}\n </tbody>\n </table>\n )}\n </div>\n\n <Drawer\n open={selectedEvent !== null}\n onClose={() => setSelectedEvent(null)}\n title=\"路由决策详情\"\n >\n {selectedEvent && (() => {\n let intent: any = {}\n try { intent = JSON.parse(selectedEvent.intent_json || '{}') } catch { /* ignore */ }\n return (\n <div className=\"space-y-4\">\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">用户提示</div>\n <div className=\"bg-purple-50 rounded p-3 text-sm text-gray-800 whitespace-pre-wrap\">\n {selectedEvent.prompt}\n </div>\n </div>\n\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">路由结果</div>\n <div className=\"text-sm font-medium\">\n {selectedEvent.routed_to_name || '未路由'}\n </div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">遵守状态</div>\n <div>\n {selectedEvent.obeyed === 1 && <span className=\"text-green-600 text-sm\">✅ 遵守</span>}\n {selectedEvent.obeyed === 0 && <span className=\"text-red-600 text-sm\">❌ 违抗</span>}\n {selectedEvent.obeyed === null && <span className=\"text-gray-400 text-sm\">未判定</span>}\n </div>\n </div>\n </div>\n\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">意图分类</div>\n <CodeBlock data={intent} language=\"json\" maxHeight=\"200px\" />\n </div>\n\n <div className=\"grid grid-cols-2 gap-3 text-sm\">\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">首工具</div>\n <div className=\"font-mono\">{selectedEvent.first_tool_name || '-'}</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">分类耗时</div>\n <div className=\"font-mono\">{selectedEvent.classification_ms}ms</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">总执行时间</div>\n <div className=\"font-mono\">\n {selectedEvent.total_execution_ms\n ? `${(selectedEvent.total_execution_ms / 1000).toFixed(2)}s`\n : '-'}\n </div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">完成原因</div>\n <div>{selectedEvent.completion_reason || '-'}</div>\n </div>\n </div>\n\n {selectedEvent.refusal_reason && (\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">违抗原因</div>\n <div className=\"bg-red-50 rounded p-3 text-sm text-red-700\">\n {selectedEvent.refusal_reason}\n </div>\n </div>\n )}\n\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">Session</div>\n <div className=\"text-xs font-mono text-gray-700\">{selectedEvent.session_id}</div>\n </div>\n </div>\n )\n })()}\n </Drawer>\n </div>\n )\n}\n"],"names":["fetchRoutingEvents","filter","url","res","filters","ExecutionTrace","setFilter","useState","search","setSearch","selectedEvent","setSelectedEvent","sseConnected","setSseConnected","showExportMenu","setShowExportMenu","toast","useToast","queryClient","useQueryClient","useEffect","eventSource","e","events","isLoading","useQuery","filteredEvents","useMemo","q","_a","_b","_c","handleExport","exportFormat","ts","getTimestamp","downloadJSON","flat","intent","format","downloadCSV","jsxs","jsx","Fragment","Wifi","WifiOff","SearchInput","f","clsx","v","Download","CheckCircle","XCircle","HelpCircle","Activity","Drawer","CodeBlock"],"mappings":"mhBAgCA,eAAeA,EAAmBC,EAA0C,CAC1E,IAAIC,EAAM,gCACND,IAAW,SAAUC,GAAO,YACvBD,IAAW,UAAWC,GAAO,YAC7BD,IAAW,YAAWC,GAAO,gBACtC,MAAMC,EAAM,MAAM,MAAMD,CAAG,EAC3B,GAAI,CAACC,EAAI,GAAI,MAAM,IAAI,MAAM,iBAAiB,EAC9C,OAAOA,EAAI,KAAA,CACb,CAEA,MAAMC,EAAU,CACd,CAAE,MAAO,GAAI,MAAO,IAAA,EACpB,CAAE,MAAO,SAAU,MAAO,MAAA,EAC1B,CAAE,MAAO,UAAW,MAAO,MAAA,EAC3B,CAAE,MAAO,UAAW,MAAO,OAAA,CAC7B,EAEA,SAAwBC,IAAiB,CACvC,KAAM,CAACJ,EAAQK,CAAS,EAAIC,EAAAA,SAAS,EAAE,EACjC,CAACC,EAAQC,CAAS,EAAIF,EAAAA,SAAS,EAAE,EACjC,CAACG,EAAeC,CAAgB,EAAIJ,EAAAA,SAA8B,IAAI,EACtE,CAACK,EAAcC,CAAe,EAAIN,EAAAA,SAAS,EAAK,EAChD,CAACO,EAAgBC,CAAiB,EAAIR,EAAAA,SAAS,EAAK,EACpDS,EAAQC,EAAA,EACRC,EAAcC,EAAA,EAEpBC,EAAAA,UAAU,IAAM,CACd,MAAMC,EAAc,IAAI,YAAY,6BAA6B,EACjE,OAAAA,EAAY,OAAS,IAAMR,EAAgB,EAAI,EAC/CQ,EAAY,QAAU,IAAMR,EAAgB,EAAK,EACjDQ,EAAY,UAAaC,GAAM,CAC7B,GAAI,CACW,KAAK,MAAMA,EAAE,IAAI,EACrB,OAAS,oBAChBJ,EAAY,kBAAkB,CAAE,SAAU,CAAC,gBAAgB,EAAG,CAElE,MAA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AAA,CAC/C,CAAA,EACF,EAECA,EAAc,gBACb+B,EAAAA,KAAC,MAAA,CACC,SAAA,CAAAC,EAAAA,IAAC,MAAA,CAAI,UAAU,6BAA6B,SAAA,OAAI,EAChDA,EAAAA,IAAC,MAAA,CAAI,UAAU,6CACZ,WAAc,cAAA,CACjB,CAAA,EACF,SAGD,MAAA,CACC,SAAA,CAAAA,EAAAA,IAAC,MAAA,CAAI,UAAU,6BAA6B,SAAA,UAAO,EACnDA,EAAAA,IAAC,MAAA,CAAI,UAAU,kCAAmC,WAAc,UAAA,CAAW,CAAA,CAAA,CAC7E,CAAA,EACF,CAEJ,GAAA,CAAG,CAAA,CACL,EACF,CAEJ"}
1
+ {"version":3,"file":"ExecutionTrace-Z-zlH0KH.js","sources":["../../src/pages/ExecutionTrace.tsx"],"sourcesContent":["import { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useState, useEffect, useMemo } from 'react'\nimport { format } from 'date-fns'\nimport { CheckCircle, XCircle, HelpCircle, Activity, Wifi, WifiOff, Download } from 'lucide-react'\nimport clsx from 'clsx'\nimport Drawer from '../components/Drawer'\nimport CodeBlock from '../components/CodeBlock'\nimport SearchInput from '../components/SearchInput'\nimport { downloadJSON, downloadCSV, getTimestamp } from '../utils/export'\nimport { useToast } from '../components/Toast'\n\ninterface RoutingEvent {\n id: number\n session_id: string\n project_path: string\n ts: number\n prompt: string\n intent_json: string\n routed_to_type: string\n routed_to_name: string\n is_forced: number\n obeyed: number | null\n classification_ms: number\n fallback_used: number\n refusal_reason: string | null\n first_tool_name: string | null\n first_tool_ts: number | null\n completed_ts: number | null\n total_execution_ms: number | null\n completion_reason: string | null\n}\n\nasync function fetchRoutingEvents(filter?: string): Promise<RoutingEvent[]> {\n let url = '/api/routing/events?limit=200'\n if (filter === 'obeyed') url += '&obeyed=1'\n else if (filter === 'refused') url += '&obeyed=0'\n else if (filter === 'unknown') url += '&obeyed=null'\n const res = await fetch(url)\n if (!res.ok) throw new Error('Failed to fetch')\n return res.json()\n}\n\nconst filters = [\n { value: '', label: '全部' },\n { value: 'obeyed', label: '✅ 遵守' },\n { value: 'refused', label: '❌ 违抗' },\n { value: 'unknown', label: '? 未判定' },\n]\n\nexport default function ExecutionTrace() {\n const [filter, setFilter] = useState('')\n const [search, setSearch] = useState('')\n const [selectedEvent, setSelectedEvent] = useState<RoutingEvent | null>(null)\n const [sseConnected, setSseConnected] = useState(false)\n const [showExportMenu, setShowExportMenu] = useState(false)\n const toast = useToast()\n const queryClient = useQueryClient()\n\n useEffect(() => {\n const eventSource = new EventSource('/api/execution-trace/stream')\n eventSource.onopen = () => setSseConnected(true)\n eventSource.onerror = () => setSseConnected(false)\n eventSource.onmessage = (e) => {\n try {\n const data = JSON.parse(e.data)\n if (data.type === 'execution-status') {\n queryClient.invalidateQueries({ queryKey: ['routing-events'] })\n }\n } catch { /* ignore */ }\n }\n return () => {\n eventSource.close()\n setSseConnected(false)\n }\n }, [queryClient])\n\n const { data: events, isLoading } = useQuery({\n queryKey: ['routing-events', filter],\n queryFn: () => fetchRoutingEvents(filter),\n refetchInterval: 10000,\n })\n\n const filteredEvents = useMemo(() => {\n if (!events) return []\n if (!search.trim()) return events\n const q = search.toLowerCase()\n return events.filter(e =>\n e.prompt?.toLowerCase().includes(q) ||\n e.routed_to_name?.toLowerCase().includes(q) ||\n e.first_tool_name?.toLowerCase().includes(q)\n )\n }, [events, search])\n\n const handleExport = (exportFormat: 'json' | 'csv') => {\n const ts = getTimestamp()\n if (exportFormat === 'json') {\n downloadJSON(`routing-events-${ts}.json`, filteredEvents)\n } else {\n const flat = filteredEvents.map(e => {\n let intent: { taskType?: string; complexity?: string } = {}\n try { intent = JSON.parse(e.intent_json || '{}') } catch { /* ignore */ }\n return {\n id: e.id,\n ts: e.ts ? format(e.ts, 'yyyy-MM-dd HH:mm:ss') : '',\n prompt: e.prompt,\n taskType: intent.taskType || '',\n complexity: intent.complexity || '',\n routed_to: e.routed_to_name || '',\n obeyed: e.obeyed === 1 ? 'yes' : e.obeyed === 0 ? 'no' : '',\n first_tool: e.first_tool_name || '',\n duration_ms: e.total_execution_ms || '',\n refusal_reason: e.refusal_reason || '',\n }\n })\n downloadCSV(`routing-events-${ts}.csv`, flat)\n }\n toast.success(`已导出 ${filteredEvents.length} 条追踪记录`)\n setShowExportMenu(false)\n }\n\n return (\n <div>\n <div className=\"flex items-center justify-between mb-4 flex-wrap gap-3\">\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900\">执行追踪</h1>\n <div className=\"flex items-center gap-2 mt-1\">\n {sseConnected ? (\n <>\n <Wifi className=\"h-3 w-3 text-green-500\" />\n <span className=\"text-xs text-green-600\">实时流已连接</span>\n </>\n ) : (\n <>\n <WifiOff className=\"h-3 w-3 text-gray-400\" />\n <span className=\"text-xs text-gray-500\">实时流未连接</span>\n </>\n )}\n </div>\n </div>\n <div className=\"flex items-center gap-2 flex-wrap\">\n <SearchInput\n value={search}\n onChange={setSearch}\n placeholder=\"搜索 prompt / agent / tool...\"\n className=\"w-56\"\n />\n <div className=\"flex items-center gap-1\">\n {filters.map((f) => (\n <button\n key={f.value}\n onClick={() => setFilter(f.value)}\n className={clsx(\n 'px-2.5 py-1.5 text-xs rounded-md',\n filter === f.value\n ? 'bg-indigo-100 text-indigo-700'\n : 'bg-white text-gray-600 border border-gray-300 hover:bg-gray-50'\n )}\n >\n {f.label}\n </button>\n ))}\n </div>\n <div className=\"relative\">\n <button\n onClick={() => setShowExportMenu(v => !v)}\n disabled={filteredEvents.length === 0}\n className=\"inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-white border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50\"\n >\n <Download className=\"h-4 w-4\" />\n 导出\n </button>\n {showExportMenu && (\n <>\n <div className=\"fixed inset-0 z-10\" onClick={() => setShowExportMenu(false)} />\n <div className=\"absolute right-0 mt-1 bg-white border border-gray-200 rounded-md shadow-lg z-20\">\n <button\n onClick={() => handleExport('json')}\n className=\"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50\"\n >\n 导出为 JSON\n </button>\n <button\n onClick={() => handleExport('csv')}\n className=\"block w-full text-left px-4 py-2 text-sm hover:bg-gray-50\"\n >\n 导出为 CSV\n </button>\n </div>\n </>\n )}\n </div>\n </div>\n </div>\n\n <div className=\"text-sm text-gray-500 mb-3\">\n 显示 {filteredEvents.length} 条 {search && `(已过滤)`}\n </div>\n\n <div className=\"bg-white rounded-lg shadow overflow-hidden\">\n {isLoading ? (\n <div className=\"p-6\">加载中...</div>\n ) : (\n <table className=\"min-w-full divide-y divide-gray-200\">\n <thead className=\"bg-gray-50\">\n <tr>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">时间</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">提示</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">路由到</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">遵守</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">首工具</th>\n <th className=\"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase\">耗时</th>\n </tr>\n </thead>\n <tbody className=\"bg-white divide-y divide-gray-200\">\n {filteredEvents.map((e) => {\n let intent: any = {}\n try { intent = JSON.parse(e.intent_json || '{}') } catch { /* ignore */ }\n return (\n <tr\n key={e.id}\n className=\"hover:bg-gray-50 cursor-pointer\"\n onClick={() => setSelectedEvent(e)}\n >\n <td className=\"px-4 py-2 whitespace-nowrap text-xs font-mono text-gray-500\">\n {format(e.ts, 'MM-dd HH:mm:ss')}\n </td>\n <td className=\"px-4 py-2 max-w-xs\">\n <p className=\"text-xs text-gray-700 truncate\" title={e.prompt}>{e.prompt}</p>\n <p className=\"text-xs text-gray-400 mt-0.5\">\n {intent.taskType} / {intent.complexity}\n </p>\n </td>\n <td className=\"px-4 py-2 whitespace-nowrap\">\n {e.routed_to_name ? (\n <span className=\"px-2 py-0.5 text-xs font-medium bg-indigo-100 text-indigo-700 rounded\">\n {e.routed_to_name}\n </span>\n ) : (\n <span className=\"text-xs text-gray-400\">未路由</span>\n )}\n </td>\n <td className=\"px-4 py-2 whitespace-nowrap\">\n {e.obeyed === 1 ? (\n <span className=\"inline-flex items-center gap-1 text-green-600 text-xs\">\n <CheckCircle className=\"h-4 w-4\" />遵守\n </span>\n ) : e.obeyed === 0 ? (\n <span className=\"inline-flex items-center gap-1 text-red-600 text-xs\">\n <XCircle className=\"h-4 w-4\" />违抗\n </span>\n ) : (\n <span className=\"inline-flex items-center gap-1 text-gray-400 text-xs\">\n <HelpCircle className=\"h-4 w-4\" />?\n </span>\n )}\n </td>\n <td className=\"px-4 py-2 whitespace-nowrap text-xs text-gray-700\">\n {e.first_tool_name || '-'}\n </td>\n <td className=\"px-4 py-2 whitespace-nowrap text-xs font-mono text-gray-500\">\n {e.total_execution_ms ? `${(e.total_execution_ms / 1000).toFixed(1)}s` : '-'}\n </td>\n </tr>\n )\n })}\n {filteredEvents.length === 0 && (\n <tr>\n <td colSpan={6} className=\"px-4 py-12 text-center text-gray-500\">\n <Activity className=\"h-12 w-12 text-gray-300 mx-auto mb-2\" />\n {search ? '无匹配结果' : '暂无追踪记录'}\n </td>\n </tr>\n )}\n </tbody>\n </table>\n )}\n </div>\n\n <Drawer\n open={selectedEvent !== null}\n onClose={() => setSelectedEvent(null)}\n title=\"路由决策详情\"\n >\n {selectedEvent && (() => {\n let intent: any = {}\n try { intent = JSON.parse(selectedEvent.intent_json || '{}') } catch { /* ignore */ }\n return (\n <div className=\"space-y-4\">\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">用户提示</div>\n <div className=\"bg-purple-50 rounded p-3 text-sm text-gray-800 whitespace-pre-wrap\">\n {selectedEvent.prompt}\n </div>\n </div>\n\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">路由结果</div>\n <div className=\"text-sm font-medium\">\n {selectedEvent.routed_to_name || '未路由'}\n </div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">遵守状态</div>\n <div>\n {selectedEvent.obeyed === 1 && <span className=\"text-green-600 text-sm\">✅ 遵守</span>}\n {selectedEvent.obeyed === 0 && <span className=\"text-red-600 text-sm\">❌ 违抗</span>}\n {selectedEvent.obeyed === null && <span className=\"text-gray-400 text-sm\">未判定</span>}\n </div>\n </div>\n </div>\n\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">意图分类</div>\n <CodeBlock data={intent} language=\"json\" maxHeight=\"200px\" />\n </div>\n\n <div className=\"grid grid-cols-2 gap-3 text-sm\">\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">首工具</div>\n <div className=\"font-mono\">{selectedEvent.first_tool_name || '-'}</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">分类耗时</div>\n <div className=\"font-mono\">{selectedEvent.classification_ms}ms</div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">总执行时间</div>\n <div className=\"font-mono\">\n {selectedEvent.total_execution_ms\n ? `${(selectedEvent.total_execution_ms / 1000).toFixed(2)}s`\n : '-'}\n </div>\n </div>\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">完成原因</div>\n <div>{selectedEvent.completion_reason || '-'}</div>\n </div>\n </div>\n\n {selectedEvent.refusal_reason && (\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">违抗原因</div>\n <div className=\"bg-red-50 rounded p-3 text-sm text-red-700\">\n {selectedEvent.refusal_reason}\n </div>\n </div>\n )}\n\n <div>\n <div className=\"text-xs text-gray-500 mb-1\">Session</div>\n <div className=\"text-xs font-mono text-gray-700\">{selectedEvent.session_id}</div>\n </div>\n </div>\n )\n })()}\n </Drawer>\n </div>\n )\n}\n"],"names":["fetchRoutingEvents","filter","url","res","filters","ExecutionTrace","setFilter","useState","search","setSearch","selectedEvent","setSelectedEvent","sseConnected","setSseConnected","showExportMenu","setShowExportMenu","toast","useToast","queryClient","useQueryClient","useEffect","eventSource","e","events","isLoading","useQuery","filteredEvents","useMemo","q","_a","_b","_c","handleExport","exportFormat","ts","getTimestamp","downloadJSON","flat","intent","format","downloadCSV","jsxs","jsx","Fragment","Wifi","WifiOff","SearchInput","f","clsx","v","Download","CheckCircle","XCircle","HelpCircle","Activity","Drawer","CodeBlock"],"mappings":"mhBAgCA,eAAeA,EAAmBC,EAA0C,CAC1E,IAAIC,EAAM,gCACND,IAAW,SAAUC,GAAO,YACvBD,IAAW,UAAWC,GAAO,YAC7BD,IAAW,YAAWC,GAAO,gBACtC,MAAMC,EAAM,MAAM,MAAMD,CAAG,EAC3B,GAAI,CAACC,EAAI,GAAI,MAAM,IAAI,MAAM,iBAAiB,EAC9C,OAAOA,EAAI,KAAA,CACb,CAEA,MAAMC,EAAU,CACd,CAAE,MAAO,GAAI,MAAO,IAAA,EACpB,CAAE,MAAO,SAAU,MAAO,MAAA,EAC1B,CAAE,MAAO,UAAW,MAAO,MAAA,EAC3B,CAAE,MAAO,UAAW,MAAO,OAAA,CAC7B,EAEA,SAAwBC,IAAiB,CACvC,KAAM,CAACJ,EAAQK,CAAS,EAAIC,EAAAA,SAAS,EAAE,EACjC,CAACC,EAAQC,CAAS,EAAIF,EAAAA,SAAS,EAAE,EACjC,CAACG,EAAeC,CAAgB,EAAIJ,EAAAA,SAA8B,IAAI,EACtE,CAACK,EAAcC,CAAe,EAAIN,EAAAA,SAAS,EAAK,EAChD,CAACO,EAAgBC,CAAiB,EAAIR,EAAAA,SAAS,EAAK,EACpDS,EAAQC,EAAA,EACRC,EAAcC,EAAA,EAEpBC,EAAAA,UAAU,IAAM,CACd,MAAMC,EAAc,IAAI,YAAY,6BAA6B,EACjE,OAAAA,EAAY,OAAS,IAAMR,EAAgB,EAAI,EAC/CQ,EAAY,QAAU,IAAMR,EAAgB,EAAK,EACjDQ,EAAY,UAAaC,GAAM,CAC7B,GAAI,CACW,KAAK,MAAMA,EAAE,IAAI,EACrB,OAAS,oBAChBJ,EAAY,kBAAkB,CAAE,SAAU,CAAC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AAqB,GAAA,CAAI,CAAA,CAAA,CAC/C,CAAA,EACF,EAECA,EAAc,gBACb+B,EAAAA,KAAC,MAAA,CACC,SAAA,CAAAC,EAAAA,IAAC,MAAA,CAAI,UAAU,6BAA6B,SAAA,OAAI,EAChDA,EAAAA,IAAC,MAAA,CAAI,UAAU,6CACZ,WAAc,cAAA,CACjB,CAAA,EACF,SAGD,MAAA,CACC,SAAA,CAAAA,EAAAA,IAAC,MAAA,CAAI,UAAU,6BAA6B,SAAA,UAAO,EACnDA,EAAAA,IAAC,MAAA,CAAI,UAAU,kCAAmC,WAAc,UAAA,CAAW,CAAA,CAAA,CAC7E,CAAA,EACF,CAEJ,GAAA,CAAG,CAAA,CACL,EACF,CAEJ"}
@@ -0,0 +1,5 @@
1
+ import{r as b,j as e}from"./react-vendor-CSp-GLFF.js";import{b as q,u as C,c as E}from"./query-C99w429o.js";import{b as M,L as $}from"./react-router-I-HqunH7.js";import{d as p}from"./vendor-CMMjVdZs.js";import{u as D,a as F}from"./index-BVpUTHdp.js";import{a as A}from"./auth-Bnf8ZcqN.js";import{P as K,G as S,C as T,n as P,g as Q,c as O,e as R,d as H,o as B,p as L,f as _}from"./lucide-DjB4fWNj.js";import{a as U,z as X}from"./date-fns-CZ_bHujz.js";import"./syntax-highlighter-44FakypI.js";async function z(){const t=await fetch("/api/methodology-executions?limit=50");if(!t.ok)throw new Error("Failed to fetch");return t.json()}async function G(){const t=await fetch("/api/methodologies");if(!t.ok)throw new Error("Failed to fetch methodologies");return t.json()}async function J(){const t=await fetch("/api/worker-auth-status");if(!t.ok)throw new Error("Failed to fetch worker auth status");return t.json()}async function Y(t){const a=await A(`/api/methodology-executions/${t}/cancel`,{method:"POST"});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.error||"Cancel failed")}}async function W(t){if(!(await A(`/api/methodology-executions/${t}`,{method:"DELETE"})).ok)throw new Error("Delete failed")}async function V(t){const a=await A("/api/methodology-executions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){const o=await a.json().catch(()=>({})),i=new Error(o.error||`Start failed (HTTP ${a.status})`);throw typeof o.code=="string"&&(i.code=o.code),i}return a.json()}const Z={"harness-engineering":"Harness Engineering",bmad:"BMad (敏捷开发)"};function ce(){const t=q(),a=D(),o=F(),i=M(),[j,d]=b.useState(!1),{data:r,isLoading:g,error:f}=C({queryKey:["methodology-executions"],queryFn:z,refetchInterval:5e3}),{data:c}=C({queryKey:["methodologies"],queryFn:G}),{data:N}=C({queryKey:["worker-auth-status"],queryFn:J,staleTime:3e4}),m=E({mutationFn:Y,onSuccess:()=>{a.success("方法论执行已取消"),t.invalidateQueries({queryKey:["methodology-executions"]})},onError:s=>a.error(`取消失败: ${s.message}`)}),y=E({mutationFn:W,onSuccess:()=>{a.success("记录已删除"),t.invalidateQueries({queryKey:["methodology-executions"]})},onError:s=>a.error(`删除失败: ${s.message}`)}),x=E({mutationFn:V,onSuccess:s=>{a.success(`已启动执行 #${s.id}`),d(!1),t.invalidateQueries({queryKey:["methodology-executions"]}),t.invalidateQueries({queryKey:["worker-auth-status"]})},onError:async s=>{const l=s.message||"";if(s.code==="AUTH_REQUIRED"||l.includes("Background mode requires")||l.includes("AUTH_REQUIRED")){t.invalidateQueries({queryKey:["worker-auth-status"]}),await o({title:"需要配置 Claude API",message:`后台模式需要 Claude API 认证(ANTHROPIC_API_KEY 或 OAuth)。
2
+ 请先在 AI 配置页设置后再启动执行。
3
+
4
+ 详细信息:${l}`,confirmText:"去 AI 配置",cancelText:"留在此页",variant:"warning"})&&(d(!1),i("/ai-config"));return}a.error(`启动失败: ${l}`)}}),h=async s=>{await o({title:"取消方法论执行",message:"确定要取消这个运行中的方法论吗?已完成的阶段不会受影响,但当前进行中的阶段将停止。",confirmText:"确认取消",variant:"warning"})&&m.mutate(s)},w=async s=>{await o({title:"删除执行记录",message:"确定要删除这条方法论执行记录吗?此操作不可恢复。",confirmText:"删除",variant:"danger"})&&y.mutate(s)};if(g)return e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-6",children:"方法论执行"}),e.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:e.jsx("p",{className:"text-gray-600",children:"加载中..."})})]});if(f)return e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 mb-6",children:"方法论执行"}),e.jsx("div",{className:"bg-white rounded-lg shadow p-6",children:e.jsxs("p",{className:"text-red-600",children:["加载失败: ",f.message]})})]});const u=(r==null?void 0:r.filter(s=>s.status==="running").length)||0,n=(r==null?void 0:r.filter(s=>s.status==="completed").length)||0;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"方法论执行"}),e.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[e.jsxs("span",{className:"text-gray-500",children:["共 ",(r==null?void 0:r.length)||0," 个实例"]}),u>0&&e.jsxs("span",{className:"text-blue-600",children:["· 运行中 ",u]}),n>0&&e.jsxs("span",{className:"text-green-600",children:["· 已完成 ",n]}),e.jsxs("button",{onClick:()=>d(!0),className:"ml-3 inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-indigo-600 text-white rounded-md hover:bg-indigo-700",children:[e.jsx(K,{className:"h-4 w-4"})," 新建执行"]})]})]}),j&&e.jsx(ee,{methodologies:c??[],authStatus:N??null,onCancel:()=>d(!1),onSubmit:s=>x.mutate(s),onGoToAIConfig:()=>{d(!1),i("/ai-config")},submitting:x.isPending}),e.jsxs("div",{className:"space-y-4",children:[r==null?void 0:r.map(s=>{const l=JSON.parse(s.plan_json),v=l.phases[s.current_phase_index],I=s.status==="completed"?100:Math.round(s.current_phase_index/l.phases.length*100);return e.jsx("div",{className:"bg-white rounded-lg shadow",children:e.jsxs("div",{className:"p-6 flex items-start justify-between gap-4",children:[e.jsxs($,{to:`/methodologies/${s.id}`,className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(S,{className:"h-5 w-5 text-indigo-600 flex-shrink-0"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900",children:Z[s.methodology_id]||s.methodology_id}),e.jsxs("span",{className:p("px-2 py-1 text-xs font-medium rounded-full",s.status==="running"&&"bg-blue-100 text-blue-700",s.status==="completed"&&"bg-green-100 text-green-700",s.status==="failed"&&"bg-red-100 text-red-700",s.status==="cancelled"&&"bg-gray-100 text-gray-600"),children:[s.status==="running"&&"运行中",s.status==="completed"&&"已完成",s.status==="failed"&&"失败",s.status==="cancelled"&&"已取消"]}),s.mode&&e.jsxs("span",{className:p("inline-flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full",s.mode==="background"?"bg-purple-100 text-purple-700":"bg-sky-100 text-sky-700"),title:s.mode==="background"?"独立 claude -p 子进程":"主会话内执行",children:[s.mode==="background"?e.jsx(T,{className:"h-3 w-3"}):e.jsx(P,{className:"h-3 w-3"}),s.mode==="background"?"后台":"前台"]})]}),e.jsxs("p",{className:"text-sm text-gray-600 mb-3 font-mono",children:["Session: ",s.session_id.slice(0,12),"..."]}),e.jsx("div",{className:"w-full bg-gray-200 rounded-full h-1.5 mb-3",children:e.jsx("div",{className:p("h-1.5 rounded-full transition-all",s.status==="completed"?"bg-green-500":s.status==="cancelled"?"bg-gray-400":"bg-indigo-600"),style:{width:`${I}%`}})}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-gray-500",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Q,{className:"h-4 w-4"}),U(s.started_at,{addSuffix:!0,locale:X})]}),s.status==="running"&&v&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(O,{className:"h-4 w-4"}),"Phase ",s.current_phase_index+1,"/",l.phases.length,": ",v.id]}),s.status==="completed"&&e.jsxs("div",{className:"flex items-center gap-1 text-green-600",children:[e.jsx(R,{className:"h-4 w-4"}),"完成 ",l.phases.length," 个阶段"]}),s.status==="cancelled"&&e.jsxs("div",{className:"flex items-center gap-1 text-gray-500",children:[e.jsx(H,{className:"h-4 w-4"}),"已取消于 Phase ",s.current_phase_index+1]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.status==="running"&&e.jsx("button",{onClick:k=>{k.preventDefault(),h(s.id)},className:"p-2 text-orange-600 hover:bg-orange-50 rounded-md",title:"取消执行",children:e.jsx(B,{className:"h-4 w-4"})}),s.status!=="running"&&e.jsx("button",{onClick:k=>{k.preventDefault(),w(s.id)},className:"p-2 text-gray-500 hover:bg-red-50 hover:text-red-600 rounded-md",title:"删除记录",children:e.jsx(L,{className:"h-4 w-4"})})]})]})},s.id)}),(!r||r.length===0)&&e.jsxs("div",{className:"bg-white rounded-lg shadow p-12 text-center",children:[e.jsx(S,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600",children:"暂无方法论执行记录"}),e.jsx("p",{className:"text-xs text-gray-500 mt-2",children:'当你输入复杂任务(如"重构 XXX 模块")时,系统会自动匹配方法论并生成执行计划'})]})]})]})}function ee({methodologies:t,authStatus:a,submitting:o,onSubmit:i,onCancel:j,onGoToAIConfig:d}){var u;const r=`manual-${Date.now().toString(36)}`,[g,f]=b.useState(r),[c,N]=b.useState(((u=t[0])==null?void 0:u.id)??""),[m,y]=b.useState("background"),x=a!==null&&a.available===!1,h=x&&m==="background",w=n=>{n.preventDefault(),!(!g.trim()||!c)&&(h||i({session_id:g.trim(),methodology_id:c,mode:m}))};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:e.jsxs("form",{onSubmit:w,className:"w-full max-w-md bg-white rounded-lg shadow-xl border border-gray-200",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-gray-100",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900",children:"新建方法论执行"}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"选择方法论模板和执行模式"})]}),e.jsxs("div",{className:"px-5 py-4 space-y-4 text-sm",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-gray-700",children:"方法论"}),e.jsxs("select",{className:"mt-1 w-full border border-gray-300 rounded-md px-2 py-1.5",value:c,onChange:n=>N(n.target.value),required:!0,children:[t.length===0&&e.jsx("option",{value:"",children:"(未发现方法论)"}),t.map(n=>e.jsx("option",{value:n.id,children:n.name||n.id},n.id))]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-gray-700",children:"Session ID"}),e.jsx("input",{type:"text",className:"mt-1 w-full border border-gray-300 rounded-md px-2 py-1.5 font-mono text-xs",value:g,onChange:n=>f(n.target.value),required:!0}),e.jsx("span",{className:"mt-1 block text-xs text-gray-500",children:"后台模式下用于追踪;建议保留默认或自定义一个可识别值"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-700",children:"执行模式"}),e.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>y("background"),className:p("rounded-md border px-3 py-2 text-left",m==="background"?"border-indigo-500 bg-indigo-50":"border-gray-200 hover:border-gray-300",x&&"ring-1 ring-amber-200"),children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium text-gray-900",children:[e.jsx(T,{className:"h-4 w-4 text-purple-600"})," 后台",x&&e.jsx("span",{className:"ml-auto text-[10px] font-normal text-amber-700 bg-amber-100 px-1.5 py-0.5 rounded",children:"需先配置 API"})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"独立 claude -p 子进程,无需用户在主会话输入"})]}),e.jsxs("button",{type:"button",onClick:()=>y("foreground"),className:p("rounded-md border px-3 py-2 text-left",m==="foreground"?"border-indigo-500 bg-indigo-50":"border-gray-200 hover:border-gray-300"),children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium text-gray-900",children:[e.jsx(P,{className:"h-4 w-4 text-sky-600"})," 前台"]}),e.jsxs("p",{className:"text-xs text-amber-700 mt-1 flex items-start gap-1",children:[e.jsx(_,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),e.jsxs("span",{children:["需要你在主会话里输入任意内容才会推进;期间可用 ",e.jsx("code",{className:"px-1 rounded bg-amber-50",children:"/forge methodology status"})," 查看"]})]})]})]})]}),h&&e.jsx("div",{className:"rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-800",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(_,{className:"h-4 w-4 mt-0.5 shrink-0 text-amber-600"}),e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"font-medium",children:"后台模式需要 Claude API 认证"}),e.jsxs("div",{className:"text-amber-700",children:["未检测到 ",e.jsx("code",{className:"px-1 rounded bg-amber-100",children:"ANTHROPIC_API_KEY"})," 或 OAuth 凭据",a!=null&&a.message?`(${a.message})`:"","。 请先在 AI 配置页完成设置,或切换到前台模式。"]}),e.jsx("button",{type:"button",onClick:d,className:"mt-1 inline-flex items-center gap-1 px-2 py-1 text-xs font-medium text-white bg-amber-600 rounded hover:bg-amber-700",children:"去 AI 配置"})]})]})})]}),e.jsxs("div",{className:"px-5 py-3 border-t border-gray-100 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:j,className:"px-3 py-1.5 text-sm text-gray-700 hover:bg-gray-100 rounded-md",children:"取消"}),e.jsx("button",{type:"submit",disabled:o||!c||h,title:h?"后台模式需要先配置 Claude API":void 0,className:"inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-indigo-600 text-white rounded-md hover:bg-indigo-700 disabled:opacity-50 disabled:cursor-not-allowed",children:o?"启动中...":"启动"})]})]})})}export{ce as default};
5
+ //# sourceMappingURL=Methodologies-Br5KOWuF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Methodologies-Br5KOWuF.js","sources":["../../src/pages/Methodologies.tsx"],"sourcesContent":["import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'\nimport { Link, useNavigate } from 'react-router-dom'\nimport { useState } from 'react'\nimport { formatDistanceToNow } from 'date-fns'\nimport { zhCN } from 'date-fns/locale'\nimport { GitBranch, Clock, CheckCircle, AlertCircle, XCircle, Trash2, StopCircle, Plus, Monitor, Cpu, AlertTriangle } from 'lucide-react'\nimport clsx from 'clsx'\nimport { useToast } from '../components/Toast'\nimport { useConfirm } from '../components/Confirm'\nimport { authFetch } from '../utils/auth'\n\ninterface MethodologyExecution {\n id: number\n session_id: string\n methodology_id: string\n plan_json: string\n current_phase_index: number\n status: 'running' | 'completed' | 'failed' | 'cancelled'\n mode?: 'foreground' | 'background'\n worker_pid?: number | null\n worker_session_id?: string | null\n started_at: number\n completed_at: number | null\n}\n\ninterface MethodologyMeta {\n id: string\n name: string\n description?: string\n}\n\ninterface WorkerAuthStatus {\n available: boolean\n method: 'api-key-env' | 'oauth-token' | 'keychain' | 'unknown' | 'none'\n message: string\n}\n\nasync function fetchMethodologyExecutions(): Promise<MethodologyExecution[]> {\n const res = await fetch('/api/methodology-executions?limit=50')\n if (!res.ok) throw new Error('Failed to fetch')\n return res.json()\n}\n\nasync function fetchMethodologies(): Promise<MethodologyMeta[]> {\n const res = await fetch('/api/methodologies')\n if (!res.ok) throw new Error('Failed to fetch methodologies')\n return res.json()\n}\n\nasync function fetchWorkerAuthStatus(): Promise<WorkerAuthStatus> {\n const res = await fetch('/api/worker-auth-status')\n if (!res.ok) throw new Error('Failed to fetch worker auth status')\n return res.json()\n}\n\nasync function cancelExecution(id: number): Promise<void> {\n const res = await authFetch(`/api/methodology-executions/${id}/cancel`, { method: 'POST' })\n if (!res.ok) {\n const data = await res.json().catch(() => ({}))\n throw new Error(data.error || 'Cancel failed')\n }\n}\n\nasync function deleteExecution(id: number): Promise<void> {\n const res = await authFetch(`/api/methodology-executions/${id}`, { method: 'DELETE' })\n if (!res.ok) throw new Error('Delete failed')\n}\n\nasync function startExecution(payload: {\n session_id: string\n methodology_id: string\n mode: 'foreground' | 'background'\n}): Promise<{ id: number }> {\n const res = await authFetch('/api/methodology-executions', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(payload),\n })\n if (!res.ok) {\n const data = await res.json().catch(() => ({}))\n const err = new Error(data.error || `Start failed (HTTP ${res.status})`) as Error & { code?: string }\n if (typeof data.code === 'string') err.code = data.code\n throw err\n }\n return res.json()\n}\n\nconst methodologyNames: Record<string, string> = {\n 'harness-engineering': 'Harness Engineering',\n 'bmad': 'BMad (敏捷开发)',\n}\n\nexport default function Methodologies() {\n const queryClient = useQueryClient()\n const toast = useToast()\n const confirm = useConfirm()\n const navigate = useNavigate()\n const [showStart, setShowStart] = useState(false)\n\n const { data: executions, isLoading, error } = useQuery({\n queryKey: ['methodology-executions'],\n queryFn: fetchMethodologyExecutions,\n refetchInterval: 5000,\n })\n\n const { data: methodologies } = useQuery({\n queryKey: ['methodologies'],\n queryFn: fetchMethodologies,\n })\n\n const { data: authStatus } = useQuery({\n queryKey: ['worker-auth-status'],\n queryFn: fetchWorkerAuthStatus,\n // 只在打开 Modal 时或进入页面时查一次;后续可手动刷新\n staleTime: 30_000,\n })\n\n const cancelMutation = useMutation({\n mutationFn: cancelExecution,\n onSuccess: () => {\n toast.success('方法论执行已取消')\n queryClient.invalidateQueries({ queryKey: ['methodology-executions'] })\n },\n onError: (e: Error) => toast.error(`取消失败: ${e.message}`),\n })\n\n const deleteMutation = useMutation({\n mutationFn: deleteExecution,\n onSuccess: () => {\n toast.success('记录已删除')\n queryClient.invalidateQueries({ queryKey: ['methodology-executions'] })\n },\n onError: (e: Error) => toast.error(`删除失败: ${e.message}`),\n })\n\n const startMutation = useMutation({\n mutationFn: startExecution,\n onSuccess: (data) => {\n toast.success(`已启动执行 #${data.id}`)\n setShowStart(false)\n queryClient.invalidateQueries({ queryKey: ['methodology-executions'] })\n // 成功启动后顺手刷新 auth 状态(虽然理论上没变,但保持一致)\n queryClient.invalidateQueries({ queryKey: ['worker-auth-status'] })\n },\n onError: async (e: Error & { code?: string }) => {\n const msg = e.message || ''\n const isAuthError =\n e.code === 'AUTH_REQUIRED' ||\n msg.includes('Background mode requires') ||\n msg.includes('AUTH_REQUIRED')\n if (isAuthError) {\n // 提前刷一下认证状态,确保 Modal 下次打开时 banner 即时更新\n queryClient.invalidateQueries({ queryKey: ['worker-auth-status'] })\n const go = await confirm({\n title: '需要配置 Claude API',\n message:\n '后台模式需要 Claude API 认证(ANTHROPIC_API_KEY 或 OAuth)。\\n' +\n '请先在 AI 配置页设置后再启动执行。\\n\\n' +\n `详细信息:${msg}`,\n confirmText: '去 AI 配置',\n cancelText: '留在此页',\n variant: 'warning',\n })\n if (go) {\n setShowStart(false)\n navigate('/ai-config')\n }\n return\n }\n toast.error(`启动失败: ${msg}`)\n },\n })\n\n const handleCancel = async (id: number) => {\n const ok = await confirm({\n title: '取消方法论执行',\n message: '确定要取消这个运行中的方法论吗?已完成的阶段不会受影响,但当前进行中的阶段将停止。',\n confirmText: '确认取消',\n variant: 'warning',\n })\n if (ok) cancelMutation.mutate(id)\n }\n\n const handleDelete = async (id: number) => {\n const ok = await confirm({\n title: '删除执行记录',\n message: '确定要删除这条方法论执行记录吗?此操作不可恢复。',\n confirmText: '删除',\n variant: 'danger',\n })\n if (ok) deleteMutation.mutate(id)\n }\n\n if (isLoading) {\n return (\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900 mb-6\">方法论执行</h1>\n <div className=\"bg-white rounded-lg shadow p-6\">\n <p className=\"text-gray-600\">加载中...</p>\n </div>\n </div>\n )\n }\n\n if (error) {\n return (\n <div>\n <h1 className=\"text-2xl font-bold text-gray-900 mb-6\">方法论执行</h1>\n <div className=\"bg-white rounded-lg shadow p-6\">\n <p className=\"text-red-600\">加载失败: {(error as Error).message}</p>\n </div>\n </div>\n )\n }\n\n const runningCount = executions?.filter(e => e.status === 'running').length || 0\n const completedCount = executions?.filter(e => e.status === 'completed').length || 0\n\n return (\n <div>\n <div className=\"flex items-center justify-between mb-6\">\n <h1 className=\"text-2xl font-bold text-gray-900\">方法论执行</h1>\n <div className=\"flex items-center gap-4 text-sm\">\n <span className=\"text-gray-500\">共 {executions?.length || 0} 个实例</span>\n {runningCount > 0 && <span className=\"text-blue-600\">· 运行中 {runningCount}</span>}\n {completedCount > 0 && <span className=\"text-green-600\">· 已完成 {completedCount}</span>}\n <button\n onClick={() => setShowStart(true)}\n className=\"ml-3 inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-indigo-600 text-white rounded-md hover:bg-indigo-700\"\n >\n <Plus className=\"h-4 w-4\" /> 新建执行\n </button>\n </div>\n </div>\n\n {showStart && (\n <StartExecutionModal\n methodologies={methodologies ?? []}\n authStatus={authStatus ?? null}\n onCancel={() => setShowStart(false)}\n onSubmit={(payload) => startMutation.mutate(payload)}\n onGoToAIConfig={() => {\n setShowStart(false)\n navigate('/ai-config')\n }}\n submitting={startMutation.isPending}\n />\n )}\n\n <div className=\"space-y-4\">\n {executions?.map((execution) => {\n const plan = JSON.parse(execution.plan_json)\n const currentPhase = plan.phases[execution.current_phase_index]\n const progress = execution.status === 'completed'\n ? 100\n : Math.round((execution.current_phase_index / plan.phases.length) * 100)\n\n return (\n <div key={execution.id} className=\"bg-white rounded-lg shadow\">\n <div className=\"p-6 flex items-start justify-between gap-4\">\n <Link to={`/methodologies/${execution.id}`} className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-3 mb-2\">\n <GitBranch className=\"h-5 w-5 text-indigo-600 flex-shrink-0\" />\n <h3 className=\"text-lg font-semibold text-gray-900\">\n {methodologyNames[execution.methodology_id] || execution.methodology_id}\n </h3>\n <span className={clsx(\n 'px-2 py-1 text-xs font-medium rounded-full',\n execution.status === 'running' && 'bg-blue-100 text-blue-700',\n execution.status === 'completed' && 'bg-green-100 text-green-700',\n execution.status === 'failed' && 'bg-red-100 text-red-700',\n execution.status === 'cancelled' && 'bg-gray-100 text-gray-600'\n )}>\n {execution.status === 'running' && '运行中'}\n {execution.status === 'completed' && '已完成'}\n {execution.status === 'failed' && '失败'}\n {execution.status === 'cancelled' && '已取消'}\n </span>\n {execution.mode && (\n <span\n className={clsx(\n 'inline-flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-full',\n execution.mode === 'background'\n ? 'bg-purple-100 text-purple-700'\n : 'bg-sky-100 text-sky-700'\n )}\n title={execution.mode === 'background' ? '独立 claude -p 子进程' : '主会话内执行'}\n >\n {execution.mode === 'background' ? <Cpu className=\"h-3 w-3\" /> : <Monitor className=\"h-3 w-3\" />}\n {execution.mode === 'background' ? '后台' : '前台'}\n </span>\n )}\n </div>\n\n <p className=\"text-sm text-gray-600 mb-3 font-mono\">\n Session: {execution.session_id.slice(0, 12)}...\n </p>\n\n {/* Progress bar */}\n <div className=\"w-full bg-gray-200 rounded-full h-1.5 mb-3\">\n <div\n className={clsx(\n 'h-1.5 rounded-full transition-all',\n execution.status === 'completed' ? 'bg-green-500' :\n execution.status === 'cancelled' ? 'bg-gray-400' : 'bg-indigo-600'\n )}\n style={{ width: `${progress}%` }}\n />\n </div>\n\n <div className=\"flex items-center gap-4 text-sm text-gray-500\">\n <div className=\"flex items-center gap-1\">\n <Clock className=\"h-4 w-4\" />\n {formatDistanceToNow(execution.started_at, { addSuffix: true, locale: zhCN })}\n </div>\n {execution.status === 'running' && currentPhase && (\n <div className=\"flex items-center gap-1\">\n <AlertCircle className=\"h-4 w-4\" />\n Phase {execution.current_phase_index + 1}/{plan.phases.length}: {currentPhase.id}\n </div>\n )}\n {execution.status === 'completed' && (\n <div className=\"flex items-center gap-1 text-green-600\">\n <CheckCircle className=\"h-4 w-4\" />\n 完成 {plan.phases.length} 个阶段\n </div>\n )}\n {execution.status === 'cancelled' && (\n <div className=\"flex items-center gap-1 text-gray-500\">\n <XCircle className=\"h-4 w-4\" />\n 已取消于 Phase {execution.current_phase_index + 1}\n </div>\n )}\n </div>\n </Link>\n\n {/* Actions */}\n <div className=\"flex items-center gap-1 flex-shrink-0\">\n {execution.status === 'running' && (\n <button\n onClick={(e) => {\n e.preventDefault()\n handleCancel(execution.id)\n }}\n className=\"p-2 text-orange-600 hover:bg-orange-50 rounded-md\"\n title=\"取消执行\"\n >\n <StopCircle className=\"h-4 w-4\" />\n </button>\n )}\n {execution.status !== 'running' && (\n <button\n onClick={(e) => { e.preventDefault(); handleDelete(execution.id) }}\n className=\"p-2 text-gray-500 hover:bg-red-50 hover:text-red-600 rounded-md\"\n title=\"删除记录\"\n >\n <Trash2 className=\"h-4 w-4\" />\n </button>\n )}\n </div>\n </div>\n </div>\n )\n })}\n\n {(!executions || executions.length === 0) && (\n <div className=\"bg-white rounded-lg shadow p-12 text-center\">\n <GitBranch className=\"h-12 w-12 text-gray-400 mx-auto mb-4\" />\n <p className=\"text-gray-600\">暂无方法论执行记录</p>\n <p className=\"text-xs text-gray-500 mt-2\">\n 当你输入复杂任务(如\"重构 XXX 模块\")时,系统会自动匹配方法论并生成执行计划\n </p>\n </div>\n )}\n </div>\n </div>\n )\n}\n\ninterface StartExecutionModalProps {\n methodologies: MethodologyMeta[]\n authStatus: WorkerAuthStatus | null\n submitting: boolean\n onSubmit: (payload: { session_id: string; methodology_id: string; mode: 'foreground' | 'background' }) => void\n onCancel: () => void\n onGoToAIConfig: () => void\n}\n\nfunction StartExecutionModal({ methodologies, authStatus, submitting, onSubmit, onCancel, onGoToAIConfig }: StartExecutionModalProps) {\n const defaultSession = `manual-${Date.now().toString(36)}`\n const [sessionId, setSessionId] = useState(defaultSession)\n const [methodologyId, setMethodologyId] = useState(methodologies[0]?.id ?? '')\n const [mode, setMode] = useState<'foreground' | 'background'>('background')\n\n const authMissing = authStatus !== null && authStatus.available === false\n const blockedByAuth = authMissing && mode === 'background'\n\n const submit = (e: React.FormEvent) => {\n e.preventDefault()\n if (!sessionId.trim() || !methodologyId) return\n if (blockedByAuth) return\n onSubmit({ session_id: sessionId.trim(), methodology_id: methodologyId, mode })\n }\n\n return (\n <div className=\"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4\">\n <form\n onSubmit={submit}\n className=\"w-full max-w-md bg-white rounded-lg shadow-xl border border-gray-200\"\n >\n <div className=\"px-5 py-4 border-b border-gray-100\">\n <h2 className=\"text-lg font-semibold text-gray-900\">新建方法论执行</h2>\n <p className=\"text-xs text-gray-500 mt-0.5\">选择方法论模板和执行模式</p>\n </div>\n\n <div className=\"px-5 py-4 space-y-4 text-sm\">\n <label className=\"block\">\n <span className=\"text-gray-700\">方法论</span>\n <select\n className=\"mt-1 w-full border border-gray-300 rounded-md px-2 py-1.5\"\n value={methodologyId}\n onChange={(e) => setMethodologyId(e.target.value)}\n required\n >\n {methodologies.length === 0 && <option value=\"\">(未发现方法论)</option>}\n {methodologies.map(m => (\n <option key={m.id} value={m.id}>{m.name || m.id}</option>\n ))}\n </select>\n </label>\n\n <label className=\"block\">\n <span className=\"text-gray-700\">Session ID</span>\n <input\n type=\"text\"\n className=\"mt-1 w-full border border-gray-300 rounded-md px-2 py-1.5 font-mono text-xs\"\n value={sessionId}\n onChange={(e) => setSessionId(e.target.value)}\n required\n />\n <span className=\"mt-1 block text-xs text-gray-500\">\n 后台模式下用于追踪;建议保留默认或自定义一个可识别值\n </span>\n </label>\n\n <div>\n <span className=\"text-gray-700\">执行模式</span>\n <div className=\"mt-2 grid grid-cols-2 gap-2\">\n <button\n type=\"button\"\n onClick={() => setMode('background')}\n className={clsx(\n 'rounded-md border px-3 py-2 text-left',\n mode === 'background'\n ? 'border-indigo-500 bg-indigo-50'\n : 'border-gray-200 hover:border-gray-300',\n authMissing && 'ring-1 ring-amber-200'\n )}\n >\n <div className=\"flex items-center gap-2 font-medium text-gray-900\">\n <Cpu className=\"h-4 w-4 text-purple-600\" /> 后台\n {authMissing && (\n <span className=\"ml-auto text-[10px] font-normal text-amber-700 bg-amber-100 px-1.5 py-0.5 rounded\">\n 需先配置 API\n </span>\n )}\n </div>\n <p className=\"text-xs text-gray-500 mt-1\">\n 独立 claude -p 子进程,无需用户在主会话输入\n </p>\n </button>\n <button\n type=\"button\"\n onClick={() => setMode('foreground')}\n className={clsx(\n 'rounded-md border px-3 py-2 text-left',\n mode === 'foreground'\n ? 'border-indigo-500 bg-indigo-50'\n : 'border-gray-200 hover:border-gray-300'\n )}\n >\n <div className=\"flex items-center gap-2 font-medium text-gray-900\">\n <Monitor className=\"h-4 w-4 text-sky-600\" /> 前台\n </div>\n <p className=\"text-xs text-amber-700 mt-1 flex items-start gap-1\">\n <AlertTriangle className=\"h-3.5 w-3.5 mt-0.5 shrink-0\" />\n <span>需要你在主会话里输入任意内容才会推进;期间可用 <code className=\"px-1 rounded bg-amber-50\">/forge methodology status</code> 查看</span>\n </p>\n </button>\n </div>\n </div>\n\n {blockedByAuth && (\n <div className=\"rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-800\">\n <div className=\"flex items-start gap-2\">\n <AlertTriangle className=\"h-4 w-4 mt-0.5 shrink-0 text-amber-600\" />\n <div className=\"flex-1 space-y-1\">\n <div className=\"font-medium\">后台模式需要 Claude API 认证</div>\n <div className=\"text-amber-700\">\n 未检测到 <code className=\"px-1 rounded bg-amber-100\">ANTHROPIC_API_KEY</code> 或 OAuth 凭据\n {authStatus?.message ? `(${authStatus.message})` : ''}。\n 请先在 AI 配置页完成设置,或切换到前台模式。\n </div>\n <button\n type=\"button\"\n onClick={onGoToAIConfig}\n className=\"mt-1 inline-flex items-center gap-1 px-2 py-1 text-xs font-medium text-white bg-amber-600 rounded hover:bg-amber-700\"\n >\n 去 AI 配置\n </button>\n </div>\n </div>\n </div>\n )}\n </div>\n\n <div className=\"px-5 py-3 border-t border-gray-100 flex justify-end gap-2\">\n <button\n type=\"button\"\n onClick={onCancel}\n className=\"px-3 py-1.5 text-sm text-gray-700 hover:bg-gray-100 rounded-md\"\n >\n 取消\n </button>\n <button\n type=\"submit\"\n disabled={submitting || !methodologyId || blockedByAuth}\n title={blockedByAuth ? '后台模式需要先配置 Claude API' : undefined}\n className=\"inline-flex items-center gap-1 px-3 py-1.5 text-sm bg-indigo-600 text-white rounded-md hover:bg-indigo-700 disabled:opacity-50 disabled:cursor-not-allowed\"\n >\n {submitting ? '启动中...' : '启动'}\n </button>\n </div>\n </form>\n </div>\n )\n}\n"],"names":["fetchMethodologyExecutions","res","fetchMethodologies","fetchWorkerAuthStatus","cancelExecution","id","authFetch","data","deleteExecution","startExecution","payload","err","methodologyNames","Methodologies","queryClient","useQueryClient","toast","useToast","confirm","useConfirm","navigate","useNavigate","showStart","setShowStart","useState","executions","isLoading","error","useQuery","methodologies","authStatus","cancelMutation","useMutation","e","deleteMutation","startMutation","msg","handleCancel","handleDelete","jsx","jsxs","runningCount","completedCount","Plus","StartExecutionModal","execution","plan","currentPhase","progress","Link","GitBranch","clsx","Cpu","Monitor","Clock","formatDistanceToNow","zhCN","AlertCircle","CheckCircle","XCircle","StopCircle","Trash2","submitting","onSubmit","onCancel","onGoToAIConfig","defaultSession","sessionId","setSessionId","methodologyId","setMethodologyId","_a","mode","setMode","authMissing","blockedByAuth","submit","m","AlertTriangle"],"mappings":"2eAqCA,eAAeA,GAA8D,CAC3E,MAAMC,EAAM,MAAM,MAAM,sCAAsC,EAC9D,GAAI,CAACA,EAAI,GAAI,MAAM,IAAI,MAAM,iBAAiB,EAC9C,OAAOA,EAAI,KAAA,CACb,CAEA,eAAeC,GAAiD,CAC9D,MAAMD,EAAM,MAAM,MAAM,oBAAoB,EAC5C,GAAI,CAACA,EAAI,GAAI,MAAM,IAAI,MAAM,+BAA+B,EAC5D,OAAOA,EAAI,KAAA,CACb,CAEA,eAAeE,GAAmD,CAChE,MAAMF,EAAM,MAAM,MAAM,yBAAyB,EACjD,GAAI,CAACA,EAAI,GAAI,MAAM,IAAI,MAAM,oCAAoC,EACjE,OAAOA,EAAI,KAAA,CACb,CAEA,eAAeG,EAAgBC,EAA2B,CACxD,MAAMJ,EAAM,MAAMK,EAAU,+BAA+BD,CAAE,UAAW,CAAE,OAAQ,OAAQ,EAC1F,GAAI,CAACJ,EAAI,GAAI,CACX,MAAMM,EAAO,MAAMN,EAAI,KAAA,EAAO,MAAM,KAAO,CAAA,EAAG,EAC9C,MAAM,IAAI,MAAMM,EAAK,OAAS,eAAe,CAC/C,CACF,CAEA,eAAeC,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fwJ.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-DjB4fWNj.js";import{S as q,g as M,d as z,a as I}from"./export-CEzDNM66.js";import{u as L}from"./index-D23sAOAt.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-Bjf-Mvwb.js.map
1
+ import{j as e,r as o}from"./react-vendor-CSp-GLFF.js";import{u as j}from"./query-C99w429o.js";import{D as y}from"./Drawer-DeKukfwJ.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-DjB4fWNj.js";import{S as q,g as M,d as z,a as I}from"./export-CEzDNM66.js";import{u as L}from"./index-BVpUTHdp.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-DOd65EkN.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Sessions-Bjf-Mvwb.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,CAA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,WAAA,CAAA,CACX,CAAA,CACF,QACC,KAAA,CAAG,UAAU,oDACZ,SAAAvC,EAAAA,KAAC,OAAA,CAAK,UAAU,iCACd,SAAA,CAAAD,EAAAA,IAAC0C,EAAA,CAAM,UAAU,SAAA,CAAU,EAC1BF,EAAQ,WACLG,EAAoB,IAAI,KAAKH,EAAQ,UAAU,EAAG,CAChD,UAAW,GACX,OAAQI,CAAA,CACT,EACD,GAAA,CAAA,CACN,CAAA,CACF,CAAA,CAAA,EA/BKJ,EAAQ,UAAA,CAiChB,EACAd,EAAiB,SAAW,GAC3B1B,EAAAA,IAAC,MACC,SAAAA,EAAAA,IAAC,KAAA,CAAG,QAAS,EAAG,UAAU,uCACvB,SAAAmB,EAAS,QAAU,SACtB,CAAA,CACF,CAAA,CAAA,CAEJ,CAAA,CAAA,CACF,CAAA,CACF,EAEAnB,EAAAA,IAAC6C,EAAA,CACC,KAAM7B,IAAsB,KAC5B,QAAS,IAAMC,EAAqB,IAAI,EACxC,MAAM,OACN,MAAM,YAEL,SAAAD,GAAqBhB,EAAAA,IAACN,EAAA,CAAqB,UAAWsB,CAAA,CAAmB,CAAA,CAAA,CAC5E,EACF,CAEJ"}
1
+ {"version":3,"file":"Sessions-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,EAC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A,CACX,CAAA,CACF,QACC,KAAA,CAAG,UAAU,oDACZ,SAAAvC,EAAAA,KAAC,OAAA,CAAK,UAAU,iCACd,SAAA,CAAAD,EAAAA,IAAC0C,EAAA,CAAM,UAAU,SAAA,CAAU,EAC1BF,EAAQ,WACLG,EAAoB,IAAI,KAAKH,EAAQ,UAAU,EAAG,CAChD,UAAW,GACX,OAAQI,CAAA,CACT,EACD,GAAA,CAAA,CACN,CAAA,CACF,CAAA,CAAA,EA/BKJ,EAAQ,UAAA,CAiChB,EACAd,EAAiB,SAAW,GAC3B1B,EAAAA,IAAC,MACC,SAAAA,EAAAA,IAAC,KAAA,CAAG,QAAS,EAAG,UAAU,uCACvB,SAAAmB,EAAS,QAAU,SACtB,CAAA,CACF,CAAA,CAAA,CAEJ,CAAA,CAAA,CACF,CAAA,CACF,EAEAnB,EAAAA,IAAC6C,EAAA,CACC,KAAM7B,IAAsB,KAC5B,QAAS,IAAMC,EAAqB,IAAI,EACxC,MAAM,OACN,MAAM,YAEL,SAAAD,GAAqBhB,EAAAA,IAACN,EAAA,CAAqB,UAAWsB,CAAA,CAAmB,CAAA,CAAA,CAC5E,EACF,CAEJ"}
@@ -0,0 +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-DeKukfwJ.js";import{M as w}from"./MarkdownRenderer-CCIz1MOz.js";import{u as v}from"./index-BVpUTHdp.js";import{a as b}from"./auth-Bnf8ZcqN.js";import{b as g,u as N,X as k,v as S}from"./lucide-DjB4fWNj.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 b(`/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=v(),{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-zacj_uSW.js.map
@@ -0,0 +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,EAC7C,GAAI,CAACH,EAAI,GAAI,MAAM,IAA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B,QAASf,EAAO,SAAW,EAAA,CAAI,CAAA,CACnD,EAEDE,EAAS,SACRK,OAAC,MAAA,CAAI,UAAU,4BAA4B,SAAA,CAAA,QAAOL,EAAS,MAAgB,OAAA,CAAA,CAAQ,CAAA,CAAA,CAEvF,CAAA,CAAA,CACF,CAAA,CAAA,CAEJ,EACF,CAEJ"}
@@ -0,0 +1,2 @@
1
+ let a=null,n=null;async function l(){return a||n||(n=(async()=>{try{const e=await fetch("/api/auth/token");return e.ok?(a=(await e.json()).token??null,a):null}catch{return null}finally{n=null}})(),n)}function i(){a=null}async function h(e,t={}){const o=await l(),r=new Headers(t.headers??{});o&&!r.has("Authorization")&&r.set("Authorization",`Bearer ${o}`);const s=await fetch(e,{...t,headers:r});if(s.status===401){i();const u=await l();if(u){const c=new Headers(t.headers??{});return c.set("Authorization",`Bearer ${u}`),fetch(e,{...t,headers:c})}}return s}export{h as a};
2
+ //# sourceMappingURL=auth-Bnf8ZcqN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-Bnf8ZcqN.js","sources":["../../src/utils/auth.ts"],"sourcesContent":["/**\n * Frontend auth helper — fetches the daemon's bearer token from the\n * local-only /api/auth/token endpoint and wraps fetch() to attach\n * the Authorization header on write calls.\n *\n * Token fetch is cached for the lifetime of the page load. On 401, the\n * cache is invalidated and refetched once before giving up.\n */\n\nlet cachedToken: string | null = null\nlet inflight: Promise<string | null> | null = null\n\nasync function fetchToken(): Promise<string | null> {\n if (cachedToken) return cachedToken\n if (inflight) return inflight\n inflight = (async () => {\n try {\n const res = await fetch('/api/auth/token')\n if (!res.ok) return null\n const data = (await res.json()) as { token?: string }\n cachedToken = data.token ?? null\n return cachedToken\n } catch {\n return null\n } finally {\n inflight = null\n }\n })()\n return inflight\n}\n\n/** 清除 token 缓存(收到 401 时调用) */\nexport function invalidateToken(): void {\n cachedToken = null\n}\n\n/**\n * 带鉴权的 fetch:自动附加 Authorization: Bearer <token>\n * 写操作(POST/PUT/DELETE)应统一用这个函数\n */\nexport async function authFetch(input: RequestInfo | URL, init: RequestInit = {}): Promise<Response> {\n const token = await fetchToken()\n const headers = new Headers(init.headers ?? {})\n if (token && !headers.has('Authorization')) {\n headers.set('Authorization', `Bearer ${token}`)\n }\n const res = await fetch(input, { ...init, headers })\n if (res.status === 401) {\n // 失效重试一次(token 可能被 daemon 轮换)\n invalidateToken()\n const retryToken = await fetchToken()\n if (retryToken) {\n const retryHeaders = new Headers(init.headers ?? {})\n retryHeaders.set('Authorization', `Bearer ${retryToken}`)\n return fetch(input, { ...init, headers: retryHeaders })\n }\n }\n return res\n}\n"],"names":["cachedToken","inflight","fetchToken","res","invalidateToken","authFetch","input","init","token","headers","retryToken","retryHeaders"],"mappings":"AASA,IAAIA,EAA6B,KAC7BC,EAA0C,KAE9C,eAAeC,GAAqC,CAClD,OAAIF,GACAC,IACJA,GAAY,SAAY,CACtB,GAAI,CACF,MAAME,EAAM,MAAM,MAAM,iBAAiB,EACzC,OAAKA,EAAI,IAETH,GADc,MAAMG,EAAI,KAAA,GACL,OAAS,KACrBH,GAHa,IAItB,MAAQ,CACN,OAAO,IACT,QAAA,CACEC,EAAW,IACb,CACF,GAAA,EACOA,EACT,CAGO,SAASG,GAAwB,CACtCJ,EAAc,IAChB,CAMA,eAAsBK,EAAUC,EAA0BC,EAAoB,GAAuB,CACnG,MAAMC,EAAQ,MAAMN,EAAA,EACdO,EAAU,IAAI,QAAQF,EAAK,SAAW,CAAA,CAAE,EAC1CC,GAAS,CAACC,EAAQ,IAAI,eAAe,GACvCA,EAAQ,IAAI,gBAAiB,UAAUD,CAAK,EAAE,EAEhD,MAAML,EAAM,MAAM,MAAMG,EAAO,CAAE,GAAGC,EAAM,QAAAE,EAAS,EACnD,GAAIN,EAAI,SAAW,IAAK,CAEtBC,EAAA,EACA,MAAMM,EAAa,MAAMR,EAAA,EACzB,GAAIQ,EAAY,CACd,MAAMC,EAAe,IAAI,QAAQJ,EAAK,SAAW,CAAA,CAAE,EACnD,OAAAI,EAAa,IAAI,gBAAiB,UAAUD,CAAU,EAAE,EACjD,MAAMJ,EAAO,CAAE,GAAGC,EAAM,QAASI,EAAc,CACxD,CACF,CACA,OAAOR,CACT"}
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-qUCxXFSI.js","assets/react-vendor-CSp-GLFF.js","assets/query-C99w429o.js","assets/react-router-I-HqunH7.js","assets/vendor-CMMjVdZs.js","assets/lucide-DjB4fWNj.js","assets/charts-CLrM0_uM.js","assets/Sessions-DOd65EkN.js","assets/Drawer-DeKukfwJ.js","assets/date-fns-CZ_bHujz.js","assets/export-CEzDNM66.js","assets/syntax-highlighter-44FakypI.js","assets/SessionDetail-DzTue2xK.js","assets/Events-DqzBTrly.js","assets/CodeBlock--H53gk46.js","assets/ExecutionTrace-Z-zlH0KH.js","assets/Methodologies-Br5KOWuF.js","assets/auth-Bnf8ZcqN.js","assets/MethodologyDetail-Do1taSKM.js","assets/Agents-D1p3JhQs.js","assets/MarkdownRenderer-CCIz1MOz.js","assets/Skills-zacj_uSW.js","assets/Routing-CFmM7JuB.js","assets/AIConfig-Dw13rVtT.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-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-BVpUTHdp.js.map