botmux 3.12.1 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.runtime-build-id +1 -1
- package/dist/bot-registry.d.ts +7 -0
- package/dist/bot-registry.d.ts.map +1 -1
- package/dist/bot-registry.js +46 -13
- package/dist/bot-registry.js.map +1 -1
- package/dist/core/config-dir.d.ts +167 -0
- package/dist/core/config-dir.d.ts.map +1 -0
- package/dist/core/config-dir.js +152 -0
- package/dist/core/config-dir.js.map +1 -0
- package/dist/core/dashboard-ipc-server.d.ts.map +1 -1
- package/dist/core/dashboard-ipc-server.js +48 -0
- package/dist/core/dashboard-ipc-server.js.map +1 -1
- package/dist/core/per-bot-env.d.ts.map +1 -1
- package/dist/core/per-bot-env.js +9 -0
- package/dist/core/per-bot-env.js.map +1 -1
- package/dist/core/session-discovery.d.ts.map +1 -1
- package/dist/core/session-discovery.js +19 -2
- package/dist/core/session-discovery.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +44 -3
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/trigger-session.d.ts.map +1 -1
- package/dist/core/trigger-session.js +499 -63
- package/dist/core/trigger-session.js.map +1 -1
- package/dist/core/types.d.ts +26 -4
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/worker-pool.d.ts +64 -0
- package/dist/core/worker-pool.d.ts.map +1 -1
- package/dist/core/worker-pool.js +301 -10
- package/dist/core/worker-pool.js.map +1 -1
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +13 -6
- package/dist/daemon.js.map +1 -1
- package/dist/dashboard/auth.d.ts +8 -0
- package/dist/dashboard/auth.d.ts.map +1 -1
- package/dist/dashboard/auth.js +16 -11
- package/dist/dashboard/auth.js.map +1 -1
- package/dist/dashboard/web/bot-multi-select.d.ts +33 -0
- package/dist/dashboard/web/bot-multi-select.d.ts.map +1 -0
- package/dist/dashboard/web/bot-multi-select.js +34 -0
- package/dist/dashboard/web/bot-multi-select.js.map +1 -0
- package/dist/dashboard/web/groups-page.d.ts +13 -0
- package/dist/dashboard/web/groups-page.d.ts.map +1 -1
- package/dist/dashboard/web/groups-page.js +25 -7
- package/dist/dashboard/web/groups-page.js.map +1 -1
- package/dist/dashboard/web/i18n.d.ts.map +1 -1
- package/dist/dashboard/web/i18n.js +8 -4
- package/dist/dashboard/web/i18n.js.map +1 -1
- package/dist/dashboard/web/sessions-page.d.ts.map +1 -1
- package/dist/dashboard/web/sessions-page.js +15 -23
- package/dist/dashboard/web/sessions-page.js.map +1 -1
- package/dist/dashboard/web/sessions.d.ts +13 -0
- package/dist/dashboard/web/sessions.d.ts.map +1 -1
- package/dist/dashboard/web/sessions.js +25 -0
- package/dist/dashboard/web/sessions.js.map +1 -1
- package/dist/dashboard-web/app.js +1 -1
- package/dist/dashboard-web/chunks/{bot-defaults-page-HL655CNR.js → bot-defaults-page-NQJFJ45Z.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-BFUTTYVK.js → chunk-5QJB24I2.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-ELL53D62.js → chunk-6JTZJRQJ.js} +2 -2
- package/dist/dashboard-web/chunks/{chunk-5ZL7NLR5.js → chunk-CU4SUKK3.js} +1 -1
- package/dist/dashboard-web/chunks/{chunk-5PAYQ3KT.js → chunk-KEEYQ3WF.js} +1 -1
- package/dist/dashboard-web/chunks/chunk-WLIVBPJC.js +1 -0
- package/dist/dashboard-web/chunks/{connectors-page-3QQACF23.js → connectors-page-HADHZXXZ.js} +1 -1
- package/dist/dashboard-web/chunks/groups-page-5TYF46RS.js +8 -0
- package/dist/dashboard-web/chunks/{insights-page-ZZ3JEJ6L.js → insights-page-EVGGJI5L.js} +1 -1
- package/dist/dashboard-web/chunks/{monitor-room-ROJ5GZ4N.js → monitor-room-HRGR2ENP.js} +1 -1
- package/dist/dashboard-web/chunks/{monitoring-page-IATV7KJF.js → monitoring-page-LBU7TTTW.js} +1 -1
- package/dist/dashboard-web/chunks/{office-page-TYO5OIIT.js → office-page-DF6RRBMN.js} +1 -1
- package/dist/dashboard-web/chunks/{overview-page-VJUULZF2.js → overview-page-ZB6QH2EX.js} +1 -1
- package/dist/dashboard-web/chunks/{roles-page-7RJJKZGK.js → roles-page-ZBZGHIIF.js} +1 -1
- package/dist/dashboard-web/chunks/{schedules-page-JTEJ5IXW.js → schedules-page-NQVQC3QY.js} +1 -1
- package/dist/dashboard-web/chunks/sessions-page-DXBCDWCS.js +8 -0
- package/dist/dashboard-web/chunks/{settings-page-7CTTFBRS.js → settings-page-E7NN4NVQ.js} +1 -1
- package/dist/dashboard-web/chunks/{skills-page-57NZECJ3.js → skills-page-2QAVB2SA.js} +1 -1
- package/dist/dashboard-web/chunks/{team-federation-page-6YYIMJG3.js → team-federation-page-VGWL53AE.js} +1 -1
- package/dist/dashboard-web/chunks/{v3-page-ZGKBSBK3.js → v3-page-AY35LKCX.js} +1 -1
- package/dist/dashboard-web/chunks/{whiteboards-page-AACJF6DB.js → whiteboards-page-BNWUU4KG.js} +1 -1
- package/dist/dashboard-web/style.css +61 -53
- package/dist/features/codex-notifier/internal-turn.d.ts +1 -2
- package/dist/features/codex-notifier/internal-turn.d.ts.map +1 -1
- package/dist/features/codex-notifier/internal-turn.js +1 -13
- package/dist/features/codex-notifier/internal-turn.js.map +1 -1
- package/dist/i18n/en.js +2 -2
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/zh.js +2 -2
- package/dist/i18n/zh.js.map +1 -1
- package/dist/platform/secure-host-file.d.ts +63 -0
- package/dist/platform/secure-host-file.d.ts.map +1 -1
- package/dist/platform/secure-host-file.js +90 -25
- package/dist/platform/secure-host-file.js.map +1 -1
- package/dist/services/async-trigger-store.d.ts +24 -4
- package/dist/services/async-trigger-store.d.ts.map +1 -1
- package/dist/services/async-trigger-store.js +81 -19
- package/dist/services/async-trigger-store.js.map +1 -1
- package/dist/services/codex-session-meta.d.ts +4 -0
- package/dist/services/codex-session-meta.d.ts.map +1 -0
- package/dist/services/codex-session-meta.js +15 -0
- package/dist/services/codex-session-meta.js.map +1 -0
- package/dist/services/idempotency-store.d.ts +18 -3
- package/dist/services/idempotency-store.d.ts.map +1 -1
- package/dist/services/idempotency-store.js +30 -12
- package/dist/services/idempotency-store.js.map +1 -1
- package/dist/services/traex-transcript.d.ts +7 -5
- package/dist/services/traex-transcript.d.ts.map +1 -1
- package/dist/services/traex-transcript.js +139 -33
- package/dist/services/traex-transcript.js.map +1 -1
- package/dist/services/trigger-types.d.ts +14 -1
- package/dist/services/trigger-types.d.ts.map +1 -1
- package/dist/services/trigger-types.js +35 -0
- package/dist/services/trigger-types.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/child-env.d.ts +1 -1
- package/dist/utils/child-env.d.ts.map +1 -1
- package/dist/utils/child-env.js +18 -0
- package/dist/utils/child-env.js.map +1 -1
- package/dist/worker.js +35 -2
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
- package/dist/dashboard-web/chunks/chunk-6ALR252E.js +0 -1
- package/dist/dashboard-web/chunks/groups-page-SDZMJ7UV.js +0 -8
- package/dist/dashboard-web/chunks/sessions-page-KD7HDT3U.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Me}from"./chunk-FDZ7WOBW.js";import{c as Re}from"./chunk-
|
|
1
|
+
import{a as Me}from"./chunk-FDZ7WOBW.js";import{c as Re}from"./chunk-KEEYQ3WF.js";import{c as Ct,h as $e,q as rt}from"./chunk-5CJMHTT4.js";import{D as ke,F as V,u as o,v as Vt,w as Mt}from"./chunk-6JTZJRQJ.js";import{a as Ie}from"./chunk-SYC6D5XU.js";import{a as Ds,b as Fs,d as Te}from"./chunk-5THX4DI2.js";import{c as Rt}from"./chunk-7SZRL6FY.js";var b=Rt(Ds(),1),gs=Rt(Fs(),1);var tt={bad:0,warn:1,info:2},Ae=["research","edit","run","delegate","discuss"],G=["research","edit","run","delegate","discuss"],Gt=[{key:"overview",label:"insights.tabOverview"},{key:"sessions",label:"insights.tabSessions"},{key:"flow",label:"insights.tabFlow"},{key:"dist",label:"insights.tabDist"},{key:"hot",label:"insights.tabHot"}],Ut=[{key:"all",label:"insights.timeAll",days:0},{key:"1d",label:"insights.time1d",days:1},{key:"7d",label:"insights.time7d",days:7},{key:"30d",label:"insights.time30d",days:30}],Yt=["all","review","failed","slow"],Es=["overview","sessions","flow","dist","hot"],Le=[{key:"recent",label:"insights.sortRecent"},{key:"review",label:"insights.sortReview"},{key:"spans",label:"insights.sortSpans"},{key:"fails",label:"insights.sortFails"},{key:"slow",label:"insights.sortSlow"},{key:"agent",label:"insights.sortAgent"}],De=["recent","review","spans","fails","slow","agent"],Jt=["failure","slow","retry","read_write_imbalance"],Fe=[{key:"all",label:"spanAll"},{key:"user",label:"senderHuman"},{key:"a2a_agent",label:"senderA2A"},{key:"system",label:"senderSystem"}],Ee=[{key:"all",label:"spanAll"},{key:"failure",label:"tag.failure"},{key:"slow",label:"tag.slow"}],lt=new Set(["tool_error","test_failed","typecheck_failed","lint_failed","command_failed","timeout","no_output"]);function Qt(){return{messages:[],total:0,hasMore:!1,nextOffset:0,loading:!1,q:"",role:"all",tag:"all",openOps:new Set}}function T(e){return Number.isFinite(e)?Math.round(e).toLocaleString("en-US"):"-"}function O(e){return e==null||!Number.isFinite(e)?"-":e<1e3?`${Math.round(e)}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.round(e/6e4)}m`}function _e(e){return e==="error"?"!":e==="running"?"~":"OK"}function Pt(e,s){return s||(e?e.status==="unsupported_cli"?o("insights.unsupported"):e.status==="transcript_missing"?o("insights.noTranscript"):e.status==="parse_error"?o("insights.parseError"):e.status:"-")}function q(e){return String(e.title??"").replace(/^(?:@\S+\s*)+/,"").trim()||String(e.sessionId??"")}function Xt(e){return e==="bad"?o("insights.sevBad"):e==="warn"?o("insights.sevWarn"):o("insights.sevInfo")}function je(e,s){let n=o(e);return n===e?s:n}function He(e){return je(`insights.suggestion.${e.id}.title`,e.title)}function U(e){let s=`insights.phase.${e}`,n=o(s);return n===s?e:n}function ct(e){return String(e||"unknown").replace(/[^a-z0-9_-]/gi,"-")}function W(e){return`phase-${ct(e)}`}function Ot(e){return!e||e.status!=="ok"?!1:e.agg.failedSpans>0||e.agg.slowSpans>0||e.suggestions.some(s=>s.severity!=="info")}function Be(e){return{session:{sessionId:e.sessionId,cliId:e.cliId,cliSessionId:e.cliSessionId,title:e.title,botName:e.botName,larkAppId:e.larkAppId,workingDir:e.workingDir,status:e.status,lastMessageAt:e.lastMessageAt},report:e.report}}function At(e){return String(e.session.cliId??"unknown")}var Ce=["claude-code","seed","relay","aiden","codex","traex","antigravity"];function qe(e){let s=new Map;for(let n of e){let i=At(n);s.set(i,(s.get(i)??0)+1)}return[...s.entries()].map(([n,i])=>({id:n,count:i})).sort((n,i)=>{let r=Ce.indexOf(n.id),l=Ce.indexOf(i.id);return(r<0?99:r)-(l<0?99:l)||n.id.localeCompare(i.id)})}function dt(e){let s=String(e.session.workingDir??"").replace(/\/+$/,"");return s?s.split("/").pop()||s:""}function We(e){let s=new Map;for(let n of e){let i=dt(n);i&&s.set(i,(s.get(i)??0)+1)}return[...s.entries()].map(([n,i])=>({id:n,count:i})).sort((n,i)=>i.count-n.count||n.id.localeCompare(i.id))}function Lt(e,s,n,i=new Set,r={}){let l=n.trim().toLowerCase();return e.filter(g=>{let c=g.session,d=g.report;return r.analyzableOnly&&d?.status!=="ok"||r.project&&dt(g)!==r.project||r.sinceMs&&Number(c.lastMessageAt??c.spawnedAt??0)<r.sinceMs||i.size&&!i.has(At(g))||s==="review"&&!Ot(d)||s==="failed"&&!(d?.status==="ok"&&d.agg.failedSpans>0)||s==="slow"&&!(d?.status==="ok"&&d.agg.slowSpans>0)?!1:l?`${q(c)} ${V(c)} ${c.cliId??""} ${c.workingDir??""} ${c.sessionId??""}`.toLowerCase().includes(l):!0})}function Ke(e){let s={totalSpans:0,failedSpans:0,slowSpans:0,failByTool:{},phase:{research:{count:0,ms:0},edit:{count:0,ms:0},run:{count:0,ms:0},delegate:{count:0,ms:0},discuss:{count:0,ms:0}},readWriteRatio:null,compactions:0,subagentCostShare:null},n=0,i=new Map;for(let l of e){let g=l.report;if(!g||g.status!=="ok")continue;n+=1;let c=g.agg;s.totalSpans+=c.totalSpans,s.failedSpans+=c.failedSpans,s.slowSpans+=c.slowSpans,s.compactions+=c.compactions;for(let[d,a]of Object.entries(c.failByTool??{}))s.failByTool[d]=(s.failByTool[d]??0)+a;for(let d of Ae){let a=c.phase?.[d];a&&(s.phase[d].count+=a.count,s.phase[d].ms+=a.ms)}for(let d of g.suggestions??[]){let a=i.get(d.id);a?a.count+=1:i.set(d.id,{id:d.id,title:d.title,severity:d.severity,count:1,evidence:d.evidence??[],action:d.action})}}s.readWriteRatio=s.phase.edit.count>0?Number((s.phase.research.count/s.phase.edit.count).toFixed(2)):null;let r=Object.entries(s.failByTool).map(([l,g])=>({tool:l,count:g})).sort((l,g)=>g.count-l.count).slice(0,5);return{totalCount:e.length,analyzedCount:n,agg:s,topFailedTools:r,suggestions:[...i.values()]}}function Z(e){return Ae.reduce((s,n)=>s+(e.agg.phase?.[n]?.ms??0),0)}function ze(e){return e.map(s=>s.report).filter(s=>!!s&&s.status==="ok")}function Ve(e){if(!e.length)return 0;let s=[...e].sort((i,r)=>i-r),n=Math.floor(s.length/2);return s.length%2?s[n]:(s[n-1]+s[n])/2}function _s(e){return e?.status==="ok"?e.agg.failedSpans*6+e.agg.slowSpans*3+e.suggestions.filter(s=>s.severity==="bad").length*5:0}function Ge(e,s){let n=r=>Number(r.session.lastMessageAt??0),i=r=>{let l=r.report,g=l?.status==="ok"?l.agg:null;switch(s){case"spans":return g?.totalSpans??-1;case"fails":return g?.failedSpans??-1;case"slow":return g?.slowSpans??-1;case"agent":return l?.status==="ok"?Z(l):-1;case"review":return _s(l);default:return 0}};return[...e].sort((r,l)=>s==="recent"?n(l)-n(r):i(l)-i(r)||n(l)-n(r))}function Ue(e){let s=`insights.intent.${e}`,n=o(s);return n===s?e:n}function et(e){let s=`insights.result.${e}`,n=o(s);return n===s?e:n}function st(e){let s=`insights.tag.${e}`,n=o(s);return n===s?e:n}function K(e,s){let n=`insights.${e}.${s.id}`,i=o(n,s.params);return i===n?s.id:i}function Ye(e){return K("turnHeadline",e)}var Pe={"shell command":"insights.struct.shell","file edit":"insights.struct.fileEdit","read/search":"insights.struct.readSearch","agent task":"insights.struct.agentTask","tool input":"insights.struct.toolInput","tool result":"insights.struct.toolResult","tool error":"insights.struct.toolError","patch failed":"insights.struct.patchFailed","patch applied":"insights.struct.patchApplied"};function Zt(e){if(!e)return"";let s=e.match(/^exit (-?\d+)$/);return s?o("insights.struct.exit",{code:s[1]}):Pe[e]?je(Pe[e],e):e}function Je(e){return e.status==="error"||!!e.result&<.has(e.result.category)}function Dt(e,s){return e&&e.kind!=="unknown"?Ue(e.kind):s}function te(e){return Dt(e.intent,e.tool)}function Ft(e){return e?[e.kind!=="unknown"?Ue(e.kind):"",e.subject,e.detail].filter(Boolean).join(" \xB7 "):""}var js=["failure","retry","read_write_imbalance","slow"];function Qe(e){for(let s of js)if(e.includes(s)){let n=o(`insights.advice.${s}`);if(n!==`insights.advice.${s}`)return n}return""}function Xe(e,s){let n=e.spans??[],i=s?(e.recommendations??[]).find(l=>l.id===s)??null:null;if(!i)return{rec:null,spanIdx:new Set,turnIdx:new Set};let r=(i.evidence?.spanIndexes??[]).filter(l=>Number.isInteger(l)&&l>=0&&l<n.length);return{rec:i,spanIdx:new Set(r),turnIdx:new Set(i.evidence?.turnIndexes??[])}}function Et(e){return e.replace(/<(mentions|attachments|available_bots|system-reminder|quoted_messages|sender)\b[\s\S]*?<\/\1>/g," ").replace(/<botmux_reminder>[\s\S]*?<\/botmux_reminder>/g," ").replace(/<\/?(user_message|local-command-[a-z]+)>/g," ").replace(/<sender\b[^>]*\/?>/g," ").replace(/<mention\b[^>]*\/?>/g," ").replace(/\[用户引用了消息[\s\S]*?\]/g," ").replace(/\[来自[^\]]*@mention\]/g," ").replace(/\[(图片|文件)\s*\d+[^\]\n]*\][^\n]*/g," ").replace(/[ \t]+/g," ").replace(/ *\n */g,`
|
|
2
2
|
`).replace(/\n{3,}/g,`
|
|
3
3
|
|
|
4
4
|
`).trim()}var _t=new Me({html:!1,linkify:!0,breaks:!0});_t.validateLink=e=>/^(https?:|mailto:)/i.test(e.trim());var Oe=_t.renderer.rules.link_open;_t.renderer.rules.link_open=(e,s,n,i,r)=>(e[s].attrSet("target","_blank"),e[s].attrSet("rel","noopener noreferrer nofollow"),Oe?Oe(e,s,n,i,r):r.renderToken(e,s,n));function Ze(e){try{return _t.render(e).trim()||`<p>${Vt(e)}</p>`}catch{return`<p>${Vt(e)}</p>`}}function wt(e){return e.prompt?.source?.kind??"user"}function ts(e){let s=[];for(let n of e)if(n.role==="agent"){let i=s[s.length-1];i&&i.kind==="ops"&&i.turnIndex===n.turnIndex?i.msgs.push(n):s.push({kind:"ops",turnIndex:n.turnIndex,msgs:[n]})}else s.push({kind:"prompt",msg:n});return s}function es(e){let s=new Map;for(let r of e.events??[])r.phase&&s.set(r.phase,(s.get(r.phase)??0)+(r.durationMs??0)+1);let n="discuss",i=-1;for(let[r,l]of s)l>i&&(i=l,n=r);return n}function ss(e,s,n){let i=Ut.find(l=>l.key===e),r=i&&i.days>0?Date.now()-i.days*864e5:void 0;return{project:s||void 0,sinceMs:r,analyzableOnly:!n}}function ee(){let e=typeof location<"u"&&location.hash||"",s=e.indexOf("?");if(s<0)return{};let n={};for(let[i,r]of new URLSearchParams(e.slice(s+1)))n[i]=r;return n}function ns(e){let s=new URLSearchParams;for(let[i,r]of Object.entries(e))r&&s.set(i,r);let n=s.toString();return"#/insights"+(n?`?${n}`:"")}function as(){let e=ee();return Es.includes(e.tab)?e.tab:"overview"}async function is(){let e=await fetch("/api/insights/summary?limit=200",{cache:"no-store"}),s=await e.json().catch(()=>({}));if(!e.ok||s?.ok===!1||!s.overview)throw new Error(String(s?.error??e.status));return s.overview}async function os(e){let s=await fetch(`/api/sessions/${encodeURIComponent(e)}/insight?detail=spans`,{cache:"no-store"}),n=await s.json().catch(()=>({}));if(!s.ok||n?.ok===!1)throw new Error(String(n?.error??s.status));return n.report}async function rs(e,s){let n=new URLSearchParams({detail:"conversation",offset:String(s.offset),limit:String(s.limit)});s.q&&n.set("q",s.q),s.role&&s.role!=="all"&&n.set("role",s.role),s.tag&&s.tag!=="all"&&n.set("tag",s.tag);let i=await fetch(`/api/sessions/${encodeURIComponent(e)}/insight?${n.toString()}`,{cache:"no-store"}),r=await i.json().catch(()=>({}));if(!i.ok||r?.ok===!1)throw new Error(String(r?.error??i.status));let l=r?.conversation;return{messages:l?.messages??[],total:l?.total??0,hasMore:!!l?.hasMore,nextOffset:l?.nextOffset??s.offset+(l?.messages?.length??0)}}async function ls(e,s){let n=await fetch(`/api/sessions/${encodeURIComponent(e)}/insight/turn/${s}?offset=0&limit=40000`,{cache:"no-store"}),i=await n.json().catch(()=>({}));if(!n.ok||i?.ok===!1)throw new Error(String(i?.error??n.status));return i?.turn?.prompt??{text:"",truncated:!1}}function cs(e){let s=e.session;return`${V(s)} \xB7 ${String(s.cliId??"-")}${s.workingDir?` \xB7 ${dt(e)}`:""} \xB7 ${Mt(s.lastMessageAt??s.spawnedAt??0)}`}var t=Rt(Te(),1),se="__all__";function ds(e,s,n){return Math.min(Math.max(e,s),n)}function Hs(e){let s=e.getBoundingClientRect(),n=12,i=Math.min(420,Math.max(280,window.innerWidth-n*2)),r=ds(Math.round(s.left+s.width/2-i/2),n,Math.max(n,window.innerWidth-i-n)),l=Math.round(s.bottom+8),g=ds(l,n,Math.max(n,window.innerHeight-132)),c=Math.max(140,Math.floor(window.innerHeight-g-n));return{top:g,left:r,width:i,maxHeight:c}}function pt(e,s){let n=new Set(e);return n.has(s)?n.delete(s):n.add(s),n}function us(e,s){let n=new Set(e);return n.add(s),n}function Ht({text:e,className:s="md-body"}){return(0,t.jsx)("div",{className:s,dangerouslySetInnerHTML:{__html:Ze(e)}})}function Bs({tip:e}){return(0,t.jsx)("div",{id:"insight-tip",className:"ins-tip",role:"tooltip",hidden:!e.visible,style:{left:e.x,top:e.y},children:e.text})}function Y({label:e,value:s,sub:n}){return(0,t.jsxs)("div",{className:"card",children:[(0,t.jsx)("div",{className:"cv",children:s}),(0,t.jsx)("div",{className:"cl",children:e}),n?(0,t.jsx)("div",{className:"cs",children:n}):null]})}function ae(){return(0,t.jsxs)("p",{className:"insight-disclosure",children:["\u2696\uFE0E ",o("insights.disclosure")]})}function ie({phase:e}){let s=Object.entries(e??{}).filter(([,n])=>n.count>0||n.ms>0);return s.length?(0,t.jsx)("div",{className:"mph",children:s.map(([n,i])=>{let r=Math.max(1,i.ms||i.count);return(0,t.jsx)("i",{className:W(n),style:{flex:r},title:`${U(n)} \xB7 ${i.count} \xB7 ${O(i.ms)}`},n)})}):null}function qs({active:e,onChange:s}){return(0,t.jsx)("div",{className:"insight-tabs",role:"tablist",children:Gt.map(n=>(0,t.jsx)("button",{type:"button",className:`itab${n.key===e?" on":""}`,role:"tab","aria-selected":n.key===e,onClick:()=>s(n.key),children:o(n.label)},n.key))})}function Ws({data:e}){let s=e.agg,n=s.readWriteRatio===null?"-":s.readWriteRatio.toFixed(1),i=e.topFailedTools.slice(0,5),r=[...e.suggestions].sort((l,g)=>tt[l.severity]-tt[g.severity]||g.count-l.count).slice(0,6);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"cards insights-metrics",children:[(0,t.jsx)(Y,{label:o("insights.metricSessions"),value:T(e.totalCount),sub:o("insights.metricAnalyzed",{count:e.analyzedCount})}),(0,t.jsx)(Y,{label:o("insights.metricSpans"),value:T(s.totalSpans),sub:o("insights.metricSafe")}),(0,t.jsx)(Y,{label:o("insights.metricFailed"),value:T(s.failedSpans),sub:i[0]?`${i[0].tool} \xD7${i[0].count}`:""}),(0,t.jsx)(Y,{label:o("insights.metricSlow"),value:T(s.slowSpans)}),(0,t.jsx)(Y,{label:o("insights.metricRw"),value:n,sub:o("insights.metricCompactions",{count:s.compactions})})]}),(0,t.jsxs)("div",{className:"insights-overview-grid",children:[(0,t.jsxs)("section",{className:"block recblock",children:[(0,t.jsx)("h3",{children:o("insights.recommendations")}),(0,t.jsx)("div",{className:"reclist",children:r.length?r.map(l=>(0,t.jsxs)("div",{className:`rec ${l.severity}`,children:[(0,t.jsxs)("div",{className:"rectop",children:[(0,t.jsx)("b",{children:He(l)}),(0,t.jsx)("span",{children:Xt(l.severity)})]}),(0,t.jsx)("div",{className:"recev",children:o("insights.seenInSessions",{count:l.count})})]},l.id)):(0,t.jsx)("p",{className:"mut",children:o("insights.noRecommendations")})})]}),(0,t.jsxs)("section",{className:"block",children:[(0,t.jsx)("h3",{children:o("insights.toolFailures")}),(0,t.jsx)(ms,{rows:i.map(l=>({key:l.tool,label:l.tool,count:l.count})),empty:o("insights.noFailures")})]})]}),(0,t.jsx)(ae,{})]})}function ms({rows:e,empty:s,renderValue:n,onRowClick:i}){if(!e.length)return(0,t.jsx)("div",{className:"hbars",children:(0,t.jsx)("p",{className:"mut",children:s})});let r=Math.max(1,...e.map(l=>l.count));return(0,t.jsx)("div",{className:"hbars",children:e.map(l=>{let g=Math.max(l.count?4:0,Math.round(l.count/r*100)),c=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"hblabel",title:l.label,children:l.label}),(0,t.jsx)("div",{className:"hbtrack",children:(0,t.jsx)("div",{className:"hbfill",style:{width:`${g}%`}})}),(0,t.jsxs)("div",{className:"hbval",children:[n?n(l):T(l.count),l.sub]})]});return i?(0,t.jsx)("button",{type:"button",className:"hbrow hbrow-click",onClick:()=>i(l),children:c},l.key):(0,t.jsx)("div",{className:"hbrow",children:c},l.key)})})}function Ks({records:e}){let i=Date.now(),r=new Array(28).fill(0);for(let c of e){let d=Number(c.session.lastMessageAt??0);if(!d)continue;let a=Math.floor((i-d)/864e5);a>=0&&a<28&&(r[27-a]+=1)}let l=r.reduce((c,d)=>c+d,0);if(!l)return null;let g=Math.max(1,...r);return(0,t.jsxs)("section",{className:"block trend-block",children:[(0,t.jsxs)("div",{className:"ihist-head",children:[(0,t.jsx)("h3",{children:o("insights.distTrend")}),(0,t.jsxs)("span",{className:"mut",children:[o("insights.distTrendSub")," \xB7 ",l]})]}),(0,t.jsx)("div",{className:"trend",children:r.map((c,d)=>{let a=new Date(i-(27-d)*864e5),v=`${a.getMonth()+1}-${a.getDate()} \xB7 ${c}`;return(0,t.jsx)("i",{className:"trendbar",style:{height:`${c?Math.max(8,Math.round(c/g*100)):2}%`},title:v},d)})})]})}function ut({title:e,values:s,bins:n,fmtMedian:i=T,sortKey:r,onSort:l}){let g=n.map(a=>({label:a.label,count:s.filter(a.test).length})),c=Math.max(1,...g.map(a=>a.count)),d=Math.max(1,s.length);return(0,t.jsxs)("section",{className:"block ihist",children:[(0,t.jsxs)("div",{className:"ihist-head",children:[(0,t.jsx)("h3",{children:e}),(0,t.jsx)("span",{className:"mut",children:o("insights.distMedian",{v:i(Ve(s))})}),r?(0,t.jsxs)("button",{type:"button",className:"ihist-jump",onClick:()=>l?.(r),children:[o("insights.viewSessions")," \u203A"]}):null]}),(0,t.jsx)("div",{className:"hbars",children:g.map(a=>{let v=Math.max(a.count?4:0,Math.round(a.count/c*100)),p=Math.round(a.count/d*100);return(0,t.jsxs)("div",{className:"hbrow",children:[(0,t.jsx)("div",{className:"hblabel",children:a.label}),(0,t.jsx)("div",{className:"hbtrack",children:(0,t.jsx)("div",{className:"hbfill",style:{width:`${v}%`}})}),(0,t.jsxs)("div",{className:"hbval",children:[T(a.count),(0,t.jsxs)("small",{children:[p,"%"]})]})]},a.label)})})]})}function zs({records:e,onSort:s}){let n=ze(e);if(!n.length)return(0,t.jsx)("div",{className:"insight-empty",children:o("insights.distEmpty")});let i=n.map(a=>(a.hot?.files??[]).reduce((v,p)=>v+(p.added??0)+(p.removed??0),0)),r=n.map(a=>a.agg.totalSpans),l=n.map(a=>a.agg.failedSpans),g=n.map(a=>a.agg.slowSpans),c=n.map(a=>Z(a)/6e4),d=n.map(a=>a.agg.readWriteRatio).filter(a=>a!==null&&Number.isFinite(a));return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"mut ins-hint",children:o("insights.distHint")}),(0,t.jsxs)("div",{className:"ihist-grid",children:[(0,t.jsx)(Ks,{records:e}),(0,t.jsx)(ut,{title:o("insights.distSpans"),values:r,onSort:s,sortKey:"spans",bins:[{label:"0-10",test:a=>a<=10},{label:"11-50",test:a=>a>10&&a<=50},{label:"51-200",test:a=>a>50&&a<=200},{label:"201-500",test:a=>a>200&&a<=500},{label:"500+",test:a=>a>500}]}),(0,t.jsx)(ut,{title:o("insights.distFailed"),values:l,onSort:s,sortKey:"fails",bins:[{label:"0",test:a=>a===0},{label:"1-2",test:a=>a>=1&&a<=2},{label:"3-5",test:a=>a>=3&&a<=5},{label:"6-10",test:a=>a>=6&&a<=10},{label:"10+",test:a=>a>10}]}),(0,t.jsx)(ut,{title:o("insights.distSlow"),values:g,onSort:s,sortKey:"slow",bins:[{label:"0",test:a=>a===0},{label:"1-2",test:a=>a>=1&&a<=2},{label:"3-5",test:a=>a>=3&&a<=5},{label:"5+",test:a=>a>5}]}),(0,t.jsx)(ut,{title:o("insights.distAgentTime"),values:c,onSort:s,sortKey:"agent",fmtMedian:a=>`${Math.round(a)}m`,bins:[{label:"<1m",test:a=>a<1},{label:"1-5m",test:a=>a>=1&&a<5},{label:"5-30m",test:a=>a>=5&&a<30},{label:"30m-2h",test:a=>a>=30&&a<120},{label:"2h+",test:a=>a>=120}]}),d.length?(0,t.jsx)(ut,{title:o("insights.distRw"),values:d,fmtMedian:a=>a.toFixed(1),bins:[{label:"0",test:a=>a===0},{label:"0-1",test:a=>a>0&&a<1},{label:"1-3",test:a=>a>=1&&a<3},{label:"3+",test:a=>a>=3}]}):null,(0,t.jsx)(ut,{title:o("insights.distChurn"),values:i,bins:[{label:"0",test:a=>a===0},{label:"1-100",test:a=>a>0&&a<=100},{label:"100-1k",test:a=>a>100&&a<=1e3},{label:"1k-10k",test:a=>a>1e3&&a<=1e4},{label:"10k+",test:a=>a>1e4}]})]}),(0,t.jsx)(ae,{})]})}function Vs({records:e,onSession:s}){let n=e.filter(c=>c.report&&c.report.status==="ok"&&c.report.agg);if(!n.length)return(0,t.jsx)("div",{className:"insight-empty",children:o("insights.distEmpty")});let i={};for(let c of G)i[c]={count:0,ms:0};for(let c of n)for(let d of G){let a=c.report.agg.phase?.[d];a&&(i[d].count+=a.count,i[d].ms+=a.ms)}let r=G.reduce((c,d)=>c+i[d].count,0)||1,l=G.reduce((c,d)=>c+i[d].ms,0)||1,g=[...n].sort((c,d)=>Z(d.report)-Z(c.report)).slice(0,40);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"mut ins-hint",children:o("insights.flowHint")}),(0,t.jsxs)("section",{className:"block flow-pipe-block",children:[(0,t.jsx)("h3",{children:o("insights.flowPipeline")}),(0,t.jsx)("p",{className:"mut flow-sub",children:o("insights.flowPipeSub")}),(0,t.jsx)("div",{className:"flow-pipe",children:G.map((c,d)=>{let a=i[c],v=Math.round(a.count/r*100),p=Math.round(a.ms/l*100);return(0,t.jsxs)("span",{style:{display:"contents"},children:[(0,t.jsxs)("div",{className:"flow-node",children:[(0,t.jsx)("i",{className:`flow-dot ${W(c)}`}),(0,t.jsx)("strong",{children:U(c)}),(0,t.jsxs)("span",{className:"flow-n",children:[T(a.count),(0,t.jsxs)("em",{children:[" \xB7 ",v,"%"]})]}),(0,t.jsxs)("span",{className:"flow-t",children:[O(a.ms),(0,t.jsxs)("em",{children:[" \xB7 ",p,"%"]})]})]}),d<G.length-1?(0,t.jsx)("span",{className:"flow-arrow",children:"\u2192"}):null]},c)})})]}),(0,t.jsxs)("div",{className:"insights-overview-grid",children:[(0,t.jsxs)("section",{className:"block",children:[(0,t.jsx)("h3",{children:o("insights.flowShares")}),(0,t.jsxs)("div",{className:"flow-bhead",children:[(0,t.jsx)("span",{}),(0,t.jsx)("span",{children:o("insights.flowActShare")}),(0,t.jsx)("span",{children:o("insights.flowTimeShare")})]}),(0,t.jsx)("div",{className:"flow-bars",children:G.map(c=>{let d=i[c],a=d.count/r*100,v=d.ms/l*100;return(0,t.jsxs)("div",{className:"flow-brow",children:[(0,t.jsxs)("span",{className:"flow-blabel",children:[(0,t.jsx)("i",{className:W(c)}),U(c)]}),(0,t.jsxs)("span",{className:"flow-btrack",children:[(0,t.jsx)("span",{className:`flow-bfill ${W(c)}`,style:{width:`${Math.max(2,a).toFixed(1)}%`}}),(0,t.jsxs)("em",{children:[Math.round(a),"%"]})]}),(0,t.jsxs)("span",{className:"flow-btrack",children:[(0,t.jsx)("span",{className:`flow-bfill ${W(c)}`,style:{width:`${Math.max(2,v).toFixed(1)}%`}}),(0,t.jsxs)("em",{children:[Math.round(v),"%"]})]})]},c)})})]}),(0,t.jsxs)("section",{className:"block",children:[(0,t.jsx)("h3",{children:o("insights.flowRhythm")}),(0,t.jsx)("div",{className:"flow-rhythm",children:g.map(c=>(0,t.jsxs)("button",{type:"button",className:"flow-sess",onClick:()=>s(String(c.session.sessionId)),children:[(0,t.jsx)("span",{className:"flow-stitle",children:q(c.session)}),(0,t.jsx)(ie,{phase:c.report.agg.phase}),(0,t.jsx)("span",{className:"flow-stime",children:O(Z(c.report))})]},String(c.session.sessionId)))}),(0,t.jsx)("div",{className:"rl-legend",children:G.map(c=>(0,t.jsxs)("span",{className:"rl-item",children:[(0,t.jsx)("i",{className:W(c)}),U(c)]},c))})]})]}),(0,t.jsx)(ae,{})]})}function Gs({records:e,openHot:s,onToggleHot:n,onProject:i,onSession:r}){let l=e.filter(m=>!!m.report&&m.report.status==="ok");if(!l.length)return(0,t.jsx)("div",{className:"insight-empty",children:o("insights.distEmpty")});let g=new Map,c=new Map,d=new Map,a=(m,f,P,C,h)=>{let N=m.get(f);return N||(N={key:f,label:P,sessions:[],reads:0,edits:0,runs:0,fails:0,count:0},m.set(f,N)),N.sessions.some(D=>D.id===C)||N.sessions.push({id:C,title:h}),N};for(let m of l){let f=String(m.session.sessionId),P=q(m.session),C=m.report.hot;for(let h of C?.files??[]){let N=a(g,`file:${h.path}`,h.path,f,P);N.reads+=h.reads,N.edits+=h.edits}for(let h of C?.cmds??[]){let N=a(c,`cmd:${h.cmd}`,h.cmd,f,P);N.runs+=h.runs,N.fails+=h.fails}for(let h of C?.errs??[]){let N=a(d,`err:${h.tool} ${h.result}`,`${h.tool} \xB7 ${et(h.result)}`,f,P);N.count+=h.count}}let v=(m,f)=>f.sessions.length-m.sessions.length,p=[...g.values()].sort((m,f)=>v(m,f)||f.edits+f.reads-(m.edits+m.reads)).slice(0,12),w=[...c.values()].sort((m,f)=>v(m,f)||f.fails-m.fails||f.runs-m.runs).slice(0,12),y=[...d.values()].sort((m,f)=>v(m,f)||f.count-m.count).slice(0,10),x=new Map;for(let m of l){let f=dt(m);if(!f)continue;let P=x.get(f)??{sessions:0,fails:0};P.sessions+=1,P.fails+=m.report.agg.failedSpans,x.set(f,P)}let M=[...x.entries()].map(([m,f])=>({id:m,...f})).sort((m,f)=>f.fails-m.fails||f.sessions-m.sessions).slice(0,10).map(m=>({key:m.id,label:m.id,count:m.sessions,sub:(0,t.jsxs)("small",{children:[m.fails," ",o("insights.hotFailsCol")]})})),k=[...l].filter(m=>m.report.agg.slowSpans>0).sort((m,f)=>f.report.agg.slowSpans-m.report.agg.slowSpans).slice(0,8);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"mut ins-hint",children:o("insights.hotHint")}),(0,t.jsxs)("div",{className:"hot-grid",children:[(0,t.jsx)(ne,{title:o("insights.hotFiles"),rows:p,openHot:s,onToggle:n,onSession:r,meta:m=>`${o("insights.readsShort")}${m.reads} \xB7 ${o("insights.editsShort")}${m.edits}`}),(0,t.jsx)(ne,{title:o("insights.hotCommands"),rows:w,openHot:s,onToggle:n,onSession:r,meta:m=>(0,t.jsxs)(t.Fragment,{children:[m.runs,"\xD7",m.fails?(0,t.jsxs)(t.Fragment,{children:[" \xB7 ",(0,t.jsxs)("span",{className:"bad",children:[m.fails," ",o("insights.hotFailsCol")]})]}):null]})}),(0,t.jsx)(ne,{title:o("insights.hotErrors"),rows:y,openHot:s,onToggle:n,onSession:r,meta:m=>`${m.count}\xD7`}),(0,t.jsxs)("section",{className:"block",children:[(0,t.jsx)("h3",{children:o("insights.hotProjects")}),(0,t.jsx)(ms,{rows:M,empty:"-",onRowClick:m=>i(m.key),renderValue:m=>T(m.count)})]}),(0,t.jsxs)("section",{className:"block hot-sessions",children:[(0,t.jsx)("h3",{children:o("insights.hotSlowSessions")}),(0,t.jsx)("div",{className:"slist",children:k.length?k.map(m=>{let f=m.report.agg;return(0,t.jsxs)("button",{type:"button",className:"srow",onClick:()=>r(String(m.session.sessionId)),children:[(0,t.jsxs)("div",{className:"srmain",children:[(0,t.jsx)("strong",{children:q(m.session)}),(0,t.jsxs)("small",{children:[V(m.session)," \xB7 ",String(m.session.cliId??"-")]})]}),(0,t.jsxs)("div",{className:"srstats",children:[(0,t.jsxs)("b",{children:[o("insights.hotSlowCol"),(0,t.jsx)("em",{children:T(f.slowSpans)})]}),(0,t.jsxs)("b",{children:["span",(0,t.jsx)("em",{children:T(f.totalSpans)})]})]})]},String(m.session.sessionId))}):(0,t.jsx)("p",{className:"mut",children:"-"})})]})]})]})}function ne({title:e,rows:s,openHot:n,onToggle:i,onSession:r,meta:l}){return(0,t.jsxs)("section",{className:"block",children:[(0,t.jsx)("h3",{children:e}),(0,t.jsx)("div",{className:"hotlist",children:s.length?s.map(g=>{let c=n.has(g.key);return(0,t.jsxs)("div",{className:`hotitem${c?" open":""}`,children:[(0,t.jsxs)("button",{type:"button",className:"hotrow","aria-expanded":c,onClick:()=>i(g.key),children:[(0,t.jsx)("span",{className:"hotlabel",title:g.label,children:g.label}),(0,t.jsx)("span",{className:"hotmeta",children:l(g)}),(0,t.jsxs)("span",{className:"hotses",children:[g.sessions.length," ",o("insights.hotSessionsCol")]})]}),c?(0,t.jsx)("div",{className:"hot-sess",children:g.sessions.map(d=>(0,t.jsx)("button",{type:"button",className:"hot-sesslink",onClick:()=>r(d.id),children:d.title||d.id},d.id))}):null]},g.key)}):(0,t.jsx)("p",{className:"mut",children:"-"})})]})}function Us({sort:e,layout:s,onSort:n,onLayout:i}){let r=Le.map(g=>({value:g.key,label:o(g.label)})),l=r.find(g=>g.value===e)?.label??o("insights.sortLabel");return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(rt,{id:"insight-session-sort",className:"insight-sort-menu",ariaLabel:o("insights.sortLabel"),label:l,value:e,options:r,onChange:n}),(0,t.jsx)("div",{className:"insight-layout-switch",role:"group","aria-label":`${o("insights.layoutCard")} / ${o("insights.layoutTable")}`,children:[["card","insights.layoutCard"],["table","insights.layoutTable"]].map(([g,c])=>(0,t.jsx)("button",{type:"button",className:s===g?"active":"","aria-pressed":s===g,onClick:()=>i(g),children:o(c)},g))})]})}function Ys({records:e,selectedId:s,wide:n,onSelect:i,emptyHint:r}){if(!e.length)return(0,t.jsxs)("div",{className:"insight-empty",children:[o("insights.empty"),r?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("br",{}),(0,t.jsx)("span",{className:"mut",children:r})]}):null]});let l=(g,c,d=!1)=>(0,t.jsxs)("b",{className:d?"bad":void 0,children:[g,(0,t.jsx)("em",{children:c})]});return(0,t.jsx)("div",{className:`slist${n?" wide":""}`,children:e.map(g=>{let c=g.session,d=g.report,a=d?.status==="ok",v=d?.agg,p=v?.phase?.research?.count??0,w=v?.phase?.edit?.count??0;return(0,t.jsxs)("button",{type:"button",className:`srow${c.sessionId===s?" on":""}${Ot(d)?" review":""}`,onClick:()=>i(String(c.sessionId)),children:[(0,t.jsxs)("div",{className:"srmain",children:[(0,t.jsx)("strong",{children:q(c)}),(0,t.jsx)("small",{children:cs(g)}),a?(0,t.jsx)(ie,{phase:d.agg.phase}):null]}),a?(0,t.jsxs)("div",{className:"srstats",children:[l(o("insights.spansShort"),T(v.totalSpans)),l(o("insights.failedShort"),T(v.failedSpans),v.failedSpans>0),l(o("insights.slowShort"),T(v.slowSpans)),n?(0,t.jsxs)(t.Fragment,{children:[l(o("insights.readsShort"),T(p)),l(o("insights.editsShort"),T(w)),l(o("insights.durShort"),O(Z(d)))]}):null,l(o("insights.rwShort"),v.readWriteRatio!==null?v.readWriteRatio.toFixed(1):"-")]}):(0,t.jsx)("div",{className:"srmsg",children:Pt(d,g.error)})]},String(c.sessionId))})})}function Js({records:e,selectedId:s,onSelect:n,emptyHint:i}){return e.length?(0,t.jsxs)("div",{className:"stable",children:[(0,t.jsxs)("div",{className:"strow sthead",children:[(0,t.jsx)("span",{className:"stc-title",children:o("insights.colTitle")}),(0,t.jsx)("span",{className:"stc-proj",children:o("insights.colProject")}),(0,t.jsx)("span",{className:"stc-num",children:o("insights.spansShort")}),(0,t.jsx)("span",{className:"stc-num",children:o("insights.failedShort")}),(0,t.jsx)("span",{className:"stc-num",children:o("insights.slowShort")}),(0,t.jsx)("span",{className:"stc-num",children:o("insights.rwShort")}),(0,t.jsx)("span",{className:"stc-num",children:o("insights.durShort")}),(0,t.jsx)("span",{className:"stc-num",children:o("insights.colTime")})]}),e.map(r=>{let l=r.session,g=r.report,c=g?.status==="ok",d=g?.agg;return(0,t.jsxs)("button",{type:"button",className:`strow${l.sessionId===s?" on":""}${Ot(g)?" review":""}${c?"":" nostat"}`,onClick:()=>n(String(l.sessionId)),children:[(0,t.jsxs)("span",{className:"stc-title",children:[(0,t.jsx)("strong",{children:q(l)}),(0,t.jsxs)("small",{children:[V(l)," \xB7 ",String(l.cliId??"-")]})]}),(0,t.jsx)("span",{className:"stc-proj",children:l.workingDir?dt(r):"-"}),c?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"stc-num",children:T(d.totalSpans)}),(0,t.jsx)("span",{className:`stc-num${d.failedSpans?" bad":""}`,children:T(d.failedSpans)}),(0,t.jsx)("span",{className:"stc-num",children:T(d.slowSpans)}),(0,t.jsx)("span",{className:"stc-num",children:d.readWriteRatio!==null?d.readWriteRatio.toFixed(1):"-"}),(0,t.jsx)("span",{className:"stc-num",children:O(Z(g))})]}):(0,t.jsx)("span",{className:"stc-msg",children:Pt(g,r.error)}),(0,t.jsx)("span",{className:"stc-num stc-time",children:Mt(l.lastMessageAt??l.spawnedAt??0)})]},String(l.sessionId))})]}):(0,t.jsxs)("div",{className:"insight-empty",children:[o("insights.empty"),i?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("br",{}),(0,t.jsx)("span",{className:"mut",children:i})]}):null]})}function jt({label:e,preview:s}){return s?.text?(0,t.jsxs)("div",{className:"span-io",children:[(0,t.jsx)("span",{className:"span-io-label",children:e}),(0,t.jsxs)("pre",{className:"span-io-text",children:[s.text,s.truncated?`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as T,b as B,d as I,e as N,f as P,g as _}from"./chunk-XJ7BGPJH.js";import{D as O,F as S,H as W,a as E,u as r,v as n,w as C,z as x}from"./chunk-
|
|
1
|
+
import{a as T,b as B,d as I,e as N,f as P,g as _}from"./chunk-XJ7BGPJH.js";import{D as O,F as S,H as W,a as E,u as r,v as n,w as C,z as x}from"./chunk-6JTZJRQJ.js";import"./chunk-7SZRL6FY.js";function z(t){let o=String(t??"unknown"),e=`sessions.status.${o}`,i=r(e);return i===e?o:i}function F(t){return String(t??"unknown").toLowerCase().replace(/[^a-z0-9_-]/g,"-")}function D(t){let o=String(t??"unknown");return`<span class="status status-${n(F(o))}">${n(z(o))}</span>`}function q(t){return W(t?.title)||String(t?.sessionId??"")}var A=14,G=49,K=18;function U(){let t=[...E.sessions.values()].filter(o=>typeof o?.sessionId=="string"&&o.sessionId&&o.status!=="closed").sort((o,e)=>Number(e.lastMessageAt??0)-Number(o.lastMessageAt??0));return[...new Set(t.map(o=>String(o.sessionId)))]}function j(t,o,e){let i=Math.max(0,Math.floor(e)),s=Math.max(1,t.width),m=Math.max(1,t.height),a=s/m,l=Math.max(1,o.width),p=Math.max(180,m-Math.max(0,o.top)-K);if(i<=0)return{columns:1,rows:0,frameWidth:Math.floor(l),frameHeight:Math.floor(l/a),ratio:a};let d=null;for(let u=1;u<=i;u+=1){let b=Math.ceil(i/u),f=(l-A*(u-1))/u,L=(p-A*(b-1)-G*b)/b;if(f<=0||L<=0)continue;let h=Math.max(1,Math.min(f,L*a)),M=h/a,c=h*M;(!d||c>d.score)&&(d={columns:u,rows:b,frameWidth:h,frameHeight:M,score:c})}if(!d){let u=Math.min(i,Math.max(1,Math.floor(l/220))),b=Math.ceil(i/u),f=Math.max(1,(l-A*(u-1))/u);return{columns:u,rows:b,frameWidth:Math.floor(f),frameHeight:Math.floor(f/a),ratio:a}}return{columns:d.columns,rows:d.rows,frameWidth:Math.floor(d.frameWidth),frameHeight:Math.floor(d.frameHeight),ratio:a}}function J(t,o){let e=Math.max(1,Math.floor(t.width)),i=Math.max(1,Math.floor(t.height)),s=Math.max(1,o.width),m=Math.max(1,o.height),a=Math.min(1,s/e,m/i);return{width:e,height:i,scale:a}}function Q(t,o){return t?`frame:${T(t,o)??"none"}`:"missing"}function V(t,o){let e=E.sessions.get(t),i=o?et(t):"";if(!e)return`<div class="monitor-room-card-title">
|
|
2
2
|
<strong>${n(t)}</strong>
|
|
3
3
|
<span>${n(r("monitorRoom.missing"))}</span>
|
|
4
4
|
</div>${i}`;let s=q(e),m=T(e),a=S(e),l=m?nt(t):"";return`<div class="monitor-room-card-title">
|
package/dist/dashboard-web/chunks/{monitoring-page-IATV7KJF.js → monitoring-page-LBU7TTTW.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as k}from"./chunk-5PAYQ3KT.js";import{c as G,d as f,j as _,m as H,n as T,o as D,p as A}from"./chunk-5CJMHTT4.js";import"./chunk-ELL53D62.js";import{a as U}from"./chunk-SYC6D5XU.js";import{a as Y,d as K}from"./chunk-5THX4DI2.js";import{c as $}from"./chunk-7SZRL6FY.js";var g=$(Y(),1);var e=$(K(),1);function b(n){let s=Number(n);return!Number.isFinite(s)||s<=0?"-":s>=1024**3?`${(s/1024**3).toFixed(1)} GiB`:s>=1024**2?`${(s/1024**2).toFixed(0)} MiB`:`${Math.max(1,Math.round(s/1024))} KiB`}function N(n){let s=Number(n);return Number.isFinite(s)?`${s.toFixed(1)}%`:"-"}function S(n,s){return s?N(n):"-"}function q(n){return n?.cpuReady!==!1}function d(n){let s=Number(n);return Number.isFinite(s)?String(s):"-"}function E(n){let s=Number(n);if(!Number.isFinite(s)||s<0)return"-";if(s===0)return"0s";if(s<6e4)return`${Math.max(1,Math.floor(s/1e3))}s`;let r=Math.floor(s/6e4);if(r<60)return`${Math.max(1,r)}m`;let t=Math.floor(r/60),o=r%60;return o?`${t}h ${o}m`:`${t}h`}function Z(n){return n==="fresh"||n==="stale"||n==="unsupported"?n:"unknown"}function j(n){return n?`${n.botName||"-"} \xB7 ${n.title||n.sessionId}`:"-"}function W(n,s){return s==="cpu"?Number(n.current?.cpu1mPct??n.current?.cpuPct??0):s==="rss"?Number(n.current?.rssBytes??0):s==="growth"?Number(n.current?.rssGrowth5mBytes??0):s==="bot"?n.botName??"":n.status??""}function ee(n,s){return[...n].sort((r,t)=>{let o=W(r,s),u=W(t,s);return typeof o=="number"&&typeof u=="number"?u-o||r.sessionId.localeCompare(t.sessionId):String(o).localeCompare(String(u))||r.sessionId.localeCompare(t.sessionId)})}function V(n,s){return s==="bytes"?b(n):N(n)}function F(n,s,r){let t=(n??[]).filter(Number.isFinite);if(t.length<2)return r("monitoring.chartNoData");let o=t[0],u=Number.isFinite(s)?Number(s):Date.now(),a=Math.max(0,u-o),m=Math.max(1,Math.round(a/6e4));if(m<60)return r("monitoring.chartMinutesAgo",{value:m});let p=Math.round(m/60);return p<48?r("monitoring.chartHoursAgo",{value:p}):r("monitoring.chartDaysAgo",{value:Math.round(p/24)})}function C(n){let s=(n??[]).filter(Number.isFinite);return s.length?s[s.length-1]:void 0}function R({values:n,timestamps:s,unit:r="pct",startLabel:t,endLabel:o,emptyLabel:u,className:a}){let m=(n??[]).filter(Number.isFinite),p=m.length?Math.min(...m):0,x=m.length?Math.max(...m):0,w=x-p,c=m.length>1?m.map((L,i)=>{let l=i/(m.length-1)*100,h=w>0?100-(L-p)/w*100:50;return`${l},${h}`}).join(" "):"",P=c?`0,100 ${c} 100,100`:"",B=c?c.split(" "):[],v=B.length?B[B.length-1].split(",").map(Number):null;return(0,e.jsxs)("div",{className:["resource-chart",a].filter(Boolean).join(" "),children:[(0,e.jsxs)("div",{className:"resource-chart-y","aria-hidden":"true",children:[(0,e.jsx)("span",{children:m.length?V(x,r):"-"}),(0,e.jsx)("span",{children:m.length?V(p,r):"-"})]}),(0,e.jsxs)("div",{className:"resource-chart-plot",children:[(0,e.jsxs)("div",{className:"resource-spark-wrap",children:[(0,e.jsxs)("svg",{className:"resource-spark",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-label":m.length>1?void 0:u,children:[(0,e.jsx)("line",{x1:"0",y1:"12",x2:"100",y2:"12",className:"resource-grid-line"}),(0,e.jsx)("line",{x1:"0",y1:"50",x2:"100",y2:"50",className:"resource-grid-line"}),(0,e.jsx)("line",{x1:"0",y1:"88",x2:"100",y2:"88",className:"resource-grid-line"}),P?(0,e.jsx)("polygon",{className:"resource-spark-area",points:P}):null,c?(0,e.jsx)("polyline",{points:c}):null]}),v&&Number.isFinite(v[0])&&Number.isFinite(v[1])?(0,e.jsx)("span",{className:"resource-spark-dot","aria-hidden":"true",style:{left:`${v[0]}%`,top:`${v[1]}%`}}):null]}),(0,e.jsxs)("div",{className:"resource-chart-x","aria-hidden":"true",children:[(0,e.jsx)("span",{children:m.length>1?t:u}),(0,e.jsx)("span",{children:m.length>1?o:""})]})]})]})}function I(n){let s=r=>r instanceof Element&&!!r.closest(".ui-info-tip");return(0,e.jsx)("section",{className:"metric-card","data-resource-expandable":"",role:"button",tabIndex:0,"aria-label":n.label,onClick:r=>{s(r.target)||n.onOpen()},onKeyDown:r=>{s(r.target)||r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),n.onOpen())},children:n.children})}function M(n){return(0,e.jsx)("article",{className:"resource-trend-cell","data-resource-expandable":"",role:"button",tabIndex:0,"aria-label":n.label,onClick:n.onOpen,onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),n.onOpen())},children:n.children})}function te(n){let s=k(),r=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let t=r.current;if(t)if(n.detail){if(!t.open)try{t.showModal()}catch{}}else t.open&&t.close()},[n.detail]),(0,g.useEffect)(()=>()=>{let t=r.current;t?.open&&t.close()},[]),(0,e.jsx)("dialog",{ref:r,className:"resource-detail-modal",onCancel:t=>{t.preventDefault(),n.onClose()},onClose:n.onClose,onClick:t=>{t.target===t.currentTarget&&n.onClose()},children:n.detail?(0,e.jsxs)("article",{className:"resource-detail-modal-card",children:[(0,e.jsxs)("header",{className:"resource-detail-modal-head",children:[(0,e.jsx)("h3",{children:n.detail.title}),(0,e.jsx)("button",{type:"button",className:"resource-detail-modal-close","aria-label":s("monitoring.modalClose"),title:s("monitoring.modalClose"),onClick:n.onClose})]}),(0,e.jsxs)("div",{className:"resource-detail-modal-body",children:[(0,e.jsxs)("section",{className:"resource-detail-summary",children:[(0,e.jsx)("strong",{children:n.detail.value}),(0,e.jsx)("p",{children:n.detail.detail})]}),n.detail.chart?(0,e.jsx)(R,{className:"resource-detail-chart",values:n.detail.chart.values,timestamps:n.detail.chart.timestamps,unit:n.detail.chart.unit,startLabel:n.detail.chart.startLabel,endLabel:n.detail.chart.endLabel,emptyLabel:n.detail.chart.emptyLabel}):(0,e.jsx)("p",{className:"resource-detail-empty",children:n.detail.emptyText})]})]}):null})}function ne({reasons:n}){return(0,e.jsx)("span",{className:"resource-reasons",children:(n??[]).join(", ")||"-"})}function y({label:n,value:s,tone:r}){return(0,e.jsxs)("span",{className:`resource-pill${r?` ${r}`:""}`,children:[(0,e.jsx)("span",{children:n}),(0,e.jsx)("b",{children:s})]})}function se({bots:n,cpuReady:s=!0}){let r=k();return(0,e.jsx)("div",{className:"resource-list-shell",children:(0,e.jsx)(H,{className:"resource-runtime-list",children:n.length?n.map(t=>{let o=t.runtime?.sessions,u=t.runtime?.daemonStatus??t.daemonStatus??"unknown",a=u==="online"?"ok":u==="offline"?"off":"warn";return(0,e.jsxs)(T,{className:"resource-list-item resource-bot-item",children:[(0,e.jsxs)(D,{children:[(0,e.jsx)("strong",{title:t.botName,children:t.botName}),(0,e.jsxs)("span",{children:[r("monitoring.sessionsCount")," ",d(o?.total??t.sessions?.count)]})]}),(0,e.jsx)(A,{children:(0,e.jsxs)("div",{className:"resource-pill-group",children:[(0,e.jsx)(y,{label:r("monitoring.daemon"),value:u,tone:a}),(0,e.jsx)(y,{label:r("monitoring.working"),value:d(o?.working),tone:"accent"}),(0,e.jsx)(y,{label:r("monitoring.starting"),value:d(o?.starting)}),(0,e.jsx)(y,{label:r("monitoring.cpu"),value:S(t.total?.cpuPct,s)}),(0,e.jsx)(y,{label:r("monitoring.rss"),value:b(t.total?.rssBytes)})]})})]},t.larkAppId)}):(0,e.jsx)("li",{className:"empty",children:r("overview.noSessions")})})})}function re({sessions:n,cpuReady:s=!0}){let r=k();return(0,e.jsx)("div",{className:"resource-list-shell resource-session-shell",children:(0,e.jsx)(H,{className:"resource-runtime-list resource-session-list",children:n.length?n.map(t=>(0,e.jsxs)(T,{className:`resource-list-item resource-session-item${t.tracked?" is-tracked":""}`,children:[(0,e.jsxs)(D,{children:[(0,e.jsx)("strong",{title:t.title||t.sessionId,children:t.title||t.sessionId}),(0,e.jsxs)("span",{title:t.sessionId,children:[t.botName," \xB7 ",t.sessionId]})]}),(0,e.jsx)(A,{children:(0,e.jsxs)("div",{className:"resource-pill-group",children:[(0,e.jsx)(y,{label:r("monitoring.cpu"),value:S(t.current?.cpu1mPct??t.current?.cpuPct,s),tone:"accent"}),(0,e.jsx)(y,{label:r("monitoring.rss"),value:b(t.current?.rssBytes)}),(0,e.jsx)(y,{label:r("monitoring.growth"),value:b(t.current?.rssGrowth5mBytes)}),(0,e.jsx)(y,{label:r("monitoring.confidence"),value:t.confidence??"unknown",tone:t.tracked?"ok":void 0}),(0,e.jsxs)("span",{className:"resource-pill resource-rank-pill",children:[(0,e.jsx)("span",{children:r("monitoring.rank")}),(0,e.jsx)(ne,{reasons:t.rankReasons})]})]})})]},t.sessionId)):(0,e.jsx)("li",{className:"empty",children:r("overview.noSessions")})})})}function oe({current:n}){let s=k(),r=n.runtime,t=q(n),o=Z(r?.sampleHealth?.status),u=r?.daemons?.total,a=r?.daemons?.online,m=r?.daemons?.offline??(Number.isFinite(Number(u))&&Number.isFinite(Number(a))?Math.max(0,Number(u)-Number(a)):void 0),p=r?.sessions?.total,x=r?.sessions?.working,w=r?.sessions?.starting;return(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:s("monitoring.runtimeHealth")}),(0,e.jsx)("section",{className:"panel runtime-health-panel",children:(0,e.jsxs)("div",{className:"runtime-health-grid",children:[(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.sampleHealth")}),(0,e.jsx)("strong",{children:(0,e.jsx)("span",{className:`runtime-status-pill ${o}`,children:s(`monitoring.sample.${o}`)})}),(0,e.jsxs)("small",{children:[s("monitoring.sampleAge")," ",E(r?.sampleHealth?.ageMs)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.daemonHealth")}),(0,e.jsxs)("strong",{children:[d(a),"/",d(u)]}),(0,e.jsxs)("small",{children:[d(m)," ",s("monitoring.offline")]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.sessionHealth")}),(0,e.jsx)("strong",{children:d(p)}),(0,e.jsxs)("small",{children:[s("monitoring.working")," ",d(x)," \xB7 ",s("monitoring.starting")," ",d(w)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.resourcePressure")}),(0,e.jsx)("strong",{children:S(n.host?.cpuPct,t)}),(0,e.jsxs)("small",{children:[s("monitoring.hostMemory")," ",N(n.host?.memUsedPct)," \xB7 RSS ",b(n.botmux?.rssBytes)]})]})]})})]})}function ae({runtime:n}){let s=k(),r=n?.sessions,t=r?.longestRunning,o=r?.longestWaiting;return(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:s("monitoring.sessionPressure")}),(0,e.jsx)("section",{className:"panel runtime-session-pressure",children:(0,e.jsxs)("div",{className:"runtime-session-grid",children:[(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.statusDistribution")}),(0,e.jsx)("strong",{children:d(r?.total)}),(0,e.jsxs)("small",{children:[s("monitoring.working")," ",d(r?.working)," \xB7 ",s("monitoring.starting")," ",d(r?.starting)," \xB7 ",s("monitoring.waiting")," ",d(r?.waiting)," \xB7 ",s("monitoring.idle")," ",d(r?.idle)," \xB7 ",s("monitoring.unknown")," ",d(r?.unknown)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.longestRunning")}),(0,e.jsx)("strong",{children:j(t)}),(0,e.jsx)("small",{children:E(t?.durationMs)})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.longestWaiting")}),(0,e.jsx)("strong",{children:j(o)}),(0,e.jsx)("small",{children:E(o?.durationMs)})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.unattributedSessions")}),(0,e.jsx)("strong",{children:d(r?.unattributed)}),(0,e.jsx)("small",{children:s("monitoring.unattributedHint")})]})]})})]})}function ie({initialCurrent:n=null,initialHistory:s=null,poll:r=!0}={}){let t=k(),[o,u]=(0,g.useState)(n),[a,m]=(0,g.useState)(s),[p,x]=(0,g.useState)("cpu"),[w,c]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!r)return;let l=!1;async function h(){try{let[z,J]=await Promise.all([fetch("/api/resources/current",{cache:"no-store"}),fetch("/api/resources/history?range=3h",{cache:"no-store"})]),[Q,X]=await Promise.all([z.json(),J.json()]);l||(u(Q),m(X))}catch{l||(u({supported:!1,reason:"fetch_failed",bots:[],sessions:[]}),m({supported:!1,bots:[],sessions:[]}))}}h();let O=window.setInterval(()=>{h()},1e4);return()=>{l=!0,window.clearInterval(O)}},[r]);let P=o!==null&&a!==null,B=(0,g.useMemo)(()=>ee(o?.sessions??[],p),[o?.sessions,p]),v=o?.supported!==!1,L=q(o),i={hostStartLabel:F(a?.host?.timestamps,o?.sampledAt,t),botmuxStartLabel:F(a?.botmux?.timestamps,o?.sampledAt,t),endLabel:t("monitoring.chartNow"),emptyLabel:t("monitoring.chartNoData")};return(0,e.jsxs)("section",{className:"page resource-page",children:[(0,e.jsx)("div",{className:"page-heading",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("monitoring.eyebrow")}),(0,e.jsx)("h1",{children:t("monitoring.runtimeTitle")})]})}),P?null:(0,e.jsx)(G,{label:t("common.loading")}),P?(0,e.jsxs)(e.Fragment,{children:[o?(0,e.jsx)(oe,{current:o}):null,v?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("section",{className:"overview-block resource-block resource-pressure-block",children:[(0,e.jsx)(f,{title:t("monitoring.resourcePressure")}),(0,e.jsx)("section",{className:"panel resource-pressure",children:(0,e.jsxs)("div",{className:"resource-metrics runtime-pressure-grid",children:[(0,e.jsxs)(I,{label:t("monitoring.hostCpu"),onOpen:()=>c({title:t("monitoring.hostCpu"),value:S(o?.host?.cpuPct,L),detail:`load ${Number(o?.host?.load1??0).toFixed(2)}`,chart:{values:a?.host?.cpuPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("span",{children:t("monitoring.hostCpu")}),(0,e.jsx)("strong",{children:S(o?.host?.cpuPct,L)}),(0,e.jsxs)("small",{children:["load ",Number(o?.host?.load1??0).toFixed(2)]})]}),(0,e.jsxs)(I,{label:t("monitoring.hostMemory"),onOpen:()=>c({title:t("monitoring.hostMemory"),value:N(o?.host?.memUsedPct),detail:t("monitoring.memoryOnly"),chart:{values:a?.host?.memUsedPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("span",{children:t("monitoring.hostMemory")}),(0,e.jsx)("strong",{children:N(o?.host?.memUsedPct)}),(0,e.jsx)("small",{children:t("monitoring.memoryOnly")})]}),(0,e.jsxs)(I,{label:t("monitoring.botmuxRss"),onOpen:()=>c({title:t("monitoring.botmuxRss"),value:b(o?.botmux?.rssBytes),detail:o?.botmuxBreakdown?`${t("monitoring.botmuxSelf")} ${b((o.botmuxBreakdown.daemon.rssBytes??0)+(o.botmuxBreakdown.worker.rssBytes??0))}
|
|
1
|
+
import{c as k}from"./chunk-KEEYQ3WF.js";import{c as G,d as f,j as _,m as H,n as T,o as D,p as A}from"./chunk-5CJMHTT4.js";import"./chunk-6JTZJRQJ.js";import{a as U}from"./chunk-SYC6D5XU.js";import{a as Y,d as K}from"./chunk-5THX4DI2.js";import{c as $}from"./chunk-7SZRL6FY.js";var g=$(Y(),1);var e=$(K(),1);function b(n){let s=Number(n);return!Number.isFinite(s)||s<=0?"-":s>=1024**3?`${(s/1024**3).toFixed(1)} GiB`:s>=1024**2?`${(s/1024**2).toFixed(0)} MiB`:`${Math.max(1,Math.round(s/1024))} KiB`}function N(n){let s=Number(n);return Number.isFinite(s)?`${s.toFixed(1)}%`:"-"}function S(n,s){return s?N(n):"-"}function q(n){return n?.cpuReady!==!1}function d(n){let s=Number(n);return Number.isFinite(s)?String(s):"-"}function E(n){let s=Number(n);if(!Number.isFinite(s)||s<0)return"-";if(s===0)return"0s";if(s<6e4)return`${Math.max(1,Math.floor(s/1e3))}s`;let r=Math.floor(s/6e4);if(r<60)return`${Math.max(1,r)}m`;let t=Math.floor(r/60),o=r%60;return o?`${t}h ${o}m`:`${t}h`}function Z(n){return n==="fresh"||n==="stale"||n==="unsupported"?n:"unknown"}function j(n){return n?`${n.botName||"-"} \xB7 ${n.title||n.sessionId}`:"-"}function W(n,s){return s==="cpu"?Number(n.current?.cpu1mPct??n.current?.cpuPct??0):s==="rss"?Number(n.current?.rssBytes??0):s==="growth"?Number(n.current?.rssGrowth5mBytes??0):s==="bot"?n.botName??"":n.status??""}function ee(n,s){return[...n].sort((r,t)=>{let o=W(r,s),u=W(t,s);return typeof o=="number"&&typeof u=="number"?u-o||r.sessionId.localeCompare(t.sessionId):String(o).localeCompare(String(u))||r.sessionId.localeCompare(t.sessionId)})}function V(n,s){return s==="bytes"?b(n):N(n)}function F(n,s,r){let t=(n??[]).filter(Number.isFinite);if(t.length<2)return r("monitoring.chartNoData");let o=t[0],u=Number.isFinite(s)?Number(s):Date.now(),a=Math.max(0,u-o),m=Math.max(1,Math.round(a/6e4));if(m<60)return r("monitoring.chartMinutesAgo",{value:m});let p=Math.round(m/60);return p<48?r("monitoring.chartHoursAgo",{value:p}):r("monitoring.chartDaysAgo",{value:Math.round(p/24)})}function C(n){let s=(n??[]).filter(Number.isFinite);return s.length?s[s.length-1]:void 0}function R({values:n,timestamps:s,unit:r="pct",startLabel:t,endLabel:o,emptyLabel:u,className:a}){let m=(n??[]).filter(Number.isFinite),p=m.length?Math.min(...m):0,x=m.length?Math.max(...m):0,w=x-p,c=m.length>1?m.map((L,i)=>{let l=i/(m.length-1)*100,h=w>0?100-(L-p)/w*100:50;return`${l},${h}`}).join(" "):"",P=c?`0,100 ${c} 100,100`:"",B=c?c.split(" "):[],v=B.length?B[B.length-1].split(",").map(Number):null;return(0,e.jsxs)("div",{className:["resource-chart",a].filter(Boolean).join(" "),children:[(0,e.jsxs)("div",{className:"resource-chart-y","aria-hidden":"true",children:[(0,e.jsx)("span",{children:m.length?V(x,r):"-"}),(0,e.jsx)("span",{children:m.length?V(p,r):"-"})]}),(0,e.jsxs)("div",{className:"resource-chart-plot",children:[(0,e.jsxs)("div",{className:"resource-spark-wrap",children:[(0,e.jsxs)("svg",{className:"resource-spark",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-label":m.length>1?void 0:u,children:[(0,e.jsx)("line",{x1:"0",y1:"12",x2:"100",y2:"12",className:"resource-grid-line"}),(0,e.jsx)("line",{x1:"0",y1:"50",x2:"100",y2:"50",className:"resource-grid-line"}),(0,e.jsx)("line",{x1:"0",y1:"88",x2:"100",y2:"88",className:"resource-grid-line"}),P?(0,e.jsx)("polygon",{className:"resource-spark-area",points:P}):null,c?(0,e.jsx)("polyline",{points:c}):null]}),v&&Number.isFinite(v[0])&&Number.isFinite(v[1])?(0,e.jsx)("span",{className:"resource-spark-dot","aria-hidden":"true",style:{left:`${v[0]}%`,top:`${v[1]}%`}}):null]}),(0,e.jsxs)("div",{className:"resource-chart-x","aria-hidden":"true",children:[(0,e.jsx)("span",{children:m.length>1?t:u}),(0,e.jsx)("span",{children:m.length>1?o:""})]})]})]})}function I(n){let s=r=>r instanceof Element&&!!r.closest(".ui-info-tip");return(0,e.jsx)("section",{className:"metric-card","data-resource-expandable":"",role:"button",tabIndex:0,"aria-label":n.label,onClick:r=>{s(r.target)||n.onOpen()},onKeyDown:r=>{s(r.target)||r.key!=="Enter"&&r.key!==" "||(r.preventDefault(),n.onOpen())},children:n.children})}function M(n){return(0,e.jsx)("article",{className:"resource-trend-cell","data-resource-expandable":"",role:"button",tabIndex:0,"aria-label":n.label,onClick:n.onOpen,onKeyDown:s=>{s.key!=="Enter"&&s.key!==" "||(s.preventDefault(),n.onOpen())},children:n.children})}function te(n){let s=k(),r=(0,g.useRef)(null);return(0,g.useEffect)(()=>{let t=r.current;if(t)if(n.detail){if(!t.open)try{t.showModal()}catch{}}else t.open&&t.close()},[n.detail]),(0,g.useEffect)(()=>()=>{let t=r.current;t?.open&&t.close()},[]),(0,e.jsx)("dialog",{ref:r,className:"resource-detail-modal",onCancel:t=>{t.preventDefault(),n.onClose()},onClose:n.onClose,onClick:t=>{t.target===t.currentTarget&&n.onClose()},children:n.detail?(0,e.jsxs)("article",{className:"resource-detail-modal-card",children:[(0,e.jsxs)("header",{className:"resource-detail-modal-head",children:[(0,e.jsx)("h3",{children:n.detail.title}),(0,e.jsx)("button",{type:"button",className:"resource-detail-modal-close","aria-label":s("monitoring.modalClose"),title:s("monitoring.modalClose"),onClick:n.onClose})]}),(0,e.jsxs)("div",{className:"resource-detail-modal-body",children:[(0,e.jsxs)("section",{className:"resource-detail-summary",children:[(0,e.jsx)("strong",{children:n.detail.value}),(0,e.jsx)("p",{children:n.detail.detail})]}),n.detail.chart?(0,e.jsx)(R,{className:"resource-detail-chart",values:n.detail.chart.values,timestamps:n.detail.chart.timestamps,unit:n.detail.chart.unit,startLabel:n.detail.chart.startLabel,endLabel:n.detail.chart.endLabel,emptyLabel:n.detail.chart.emptyLabel}):(0,e.jsx)("p",{className:"resource-detail-empty",children:n.detail.emptyText})]})]}):null})}function ne({reasons:n}){return(0,e.jsx)("span",{className:"resource-reasons",children:(n??[]).join(", ")||"-"})}function y({label:n,value:s,tone:r}){return(0,e.jsxs)("span",{className:`resource-pill${r?` ${r}`:""}`,children:[(0,e.jsx)("span",{children:n}),(0,e.jsx)("b",{children:s})]})}function se({bots:n,cpuReady:s=!0}){let r=k();return(0,e.jsx)("div",{className:"resource-list-shell",children:(0,e.jsx)(H,{className:"resource-runtime-list",children:n.length?n.map(t=>{let o=t.runtime?.sessions,u=t.runtime?.daemonStatus??t.daemonStatus??"unknown",a=u==="online"?"ok":u==="offline"?"off":"warn";return(0,e.jsxs)(T,{className:"resource-list-item resource-bot-item",children:[(0,e.jsxs)(D,{children:[(0,e.jsx)("strong",{title:t.botName,children:t.botName}),(0,e.jsxs)("span",{children:[r("monitoring.sessionsCount")," ",d(o?.total??t.sessions?.count)]})]}),(0,e.jsx)(A,{children:(0,e.jsxs)("div",{className:"resource-pill-group",children:[(0,e.jsx)(y,{label:r("monitoring.daemon"),value:u,tone:a}),(0,e.jsx)(y,{label:r("monitoring.working"),value:d(o?.working),tone:"accent"}),(0,e.jsx)(y,{label:r("monitoring.starting"),value:d(o?.starting)}),(0,e.jsx)(y,{label:r("monitoring.cpu"),value:S(t.total?.cpuPct,s)}),(0,e.jsx)(y,{label:r("monitoring.rss"),value:b(t.total?.rssBytes)})]})})]},t.larkAppId)}):(0,e.jsx)("li",{className:"empty",children:r("overview.noSessions")})})})}function re({sessions:n,cpuReady:s=!0}){let r=k();return(0,e.jsx)("div",{className:"resource-list-shell resource-session-shell",children:(0,e.jsx)(H,{className:"resource-runtime-list resource-session-list",children:n.length?n.map(t=>(0,e.jsxs)(T,{className:`resource-list-item resource-session-item${t.tracked?" is-tracked":""}`,children:[(0,e.jsxs)(D,{children:[(0,e.jsx)("strong",{title:t.title||t.sessionId,children:t.title||t.sessionId}),(0,e.jsxs)("span",{title:t.sessionId,children:[t.botName," \xB7 ",t.sessionId]})]}),(0,e.jsx)(A,{children:(0,e.jsxs)("div",{className:"resource-pill-group",children:[(0,e.jsx)(y,{label:r("monitoring.cpu"),value:S(t.current?.cpu1mPct??t.current?.cpuPct,s),tone:"accent"}),(0,e.jsx)(y,{label:r("monitoring.rss"),value:b(t.current?.rssBytes)}),(0,e.jsx)(y,{label:r("monitoring.growth"),value:b(t.current?.rssGrowth5mBytes)}),(0,e.jsx)(y,{label:r("monitoring.confidence"),value:t.confidence??"unknown",tone:t.tracked?"ok":void 0}),(0,e.jsxs)("span",{className:"resource-pill resource-rank-pill",children:[(0,e.jsx)("span",{children:r("monitoring.rank")}),(0,e.jsx)(ne,{reasons:t.rankReasons})]})]})})]},t.sessionId)):(0,e.jsx)("li",{className:"empty",children:r("overview.noSessions")})})})}function oe({current:n}){let s=k(),r=n.runtime,t=q(n),o=Z(r?.sampleHealth?.status),u=r?.daemons?.total,a=r?.daemons?.online,m=r?.daemons?.offline??(Number.isFinite(Number(u))&&Number.isFinite(Number(a))?Math.max(0,Number(u)-Number(a)):void 0),p=r?.sessions?.total,x=r?.sessions?.working,w=r?.sessions?.starting;return(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:s("monitoring.runtimeHealth")}),(0,e.jsx)("section",{className:"panel runtime-health-panel",children:(0,e.jsxs)("div",{className:"runtime-health-grid",children:[(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.sampleHealth")}),(0,e.jsx)("strong",{children:(0,e.jsx)("span",{className:`runtime-status-pill ${o}`,children:s(`monitoring.sample.${o}`)})}),(0,e.jsxs)("small",{children:[s("monitoring.sampleAge")," ",E(r?.sampleHealth?.ageMs)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.daemonHealth")}),(0,e.jsxs)("strong",{children:[d(a),"/",d(u)]}),(0,e.jsxs)("small",{children:[d(m)," ",s("monitoring.offline")]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.sessionHealth")}),(0,e.jsx)("strong",{children:d(p)}),(0,e.jsxs)("small",{children:[s("monitoring.working")," ",d(x)," \xB7 ",s("monitoring.starting")," ",d(w)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-health-card",children:[(0,e.jsx)("span",{children:s("monitoring.resourcePressure")}),(0,e.jsx)("strong",{children:S(n.host?.cpuPct,t)}),(0,e.jsxs)("small",{children:[s("monitoring.hostMemory")," ",N(n.host?.memUsedPct)," \xB7 RSS ",b(n.botmux?.rssBytes)]})]})]})})]})}function ae({runtime:n}){let s=k(),r=n?.sessions,t=r?.longestRunning,o=r?.longestWaiting;return(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:s("monitoring.sessionPressure")}),(0,e.jsx)("section",{className:"panel runtime-session-pressure",children:(0,e.jsxs)("div",{className:"runtime-session-grid",children:[(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.statusDistribution")}),(0,e.jsx)("strong",{children:d(r?.total)}),(0,e.jsxs)("small",{children:[s("monitoring.working")," ",d(r?.working)," \xB7 ",s("monitoring.starting")," ",d(r?.starting)," \xB7 ",s("monitoring.waiting")," ",d(r?.waiting)," \xB7 ",s("monitoring.idle")," ",d(r?.idle)," \xB7 ",s("monitoring.unknown")," ",d(r?.unknown)]})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.longestRunning")}),(0,e.jsx)("strong",{children:j(t)}),(0,e.jsx)("small",{children:E(t?.durationMs)})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.longestWaiting")}),(0,e.jsx)("strong",{children:j(o)}),(0,e.jsx)("small",{children:E(o?.durationMs)})]}),(0,e.jsxs)("section",{className:"metric-card runtime-session-card",children:[(0,e.jsx)("span",{children:s("monitoring.unattributedSessions")}),(0,e.jsx)("strong",{children:d(r?.unattributed)}),(0,e.jsx)("small",{children:s("monitoring.unattributedHint")})]})]})})]})}function ie({initialCurrent:n=null,initialHistory:s=null,poll:r=!0}={}){let t=k(),[o,u]=(0,g.useState)(n),[a,m]=(0,g.useState)(s),[p,x]=(0,g.useState)("cpu"),[w,c]=(0,g.useState)(null);(0,g.useEffect)(()=>{if(!r)return;let l=!1;async function h(){try{let[z,J]=await Promise.all([fetch("/api/resources/current",{cache:"no-store"}),fetch("/api/resources/history?range=3h",{cache:"no-store"})]),[Q,X]=await Promise.all([z.json(),J.json()]);l||(u(Q),m(X))}catch{l||(u({supported:!1,reason:"fetch_failed",bots:[],sessions:[]}),m({supported:!1,bots:[],sessions:[]}))}}h();let O=window.setInterval(()=>{h()},1e4);return()=>{l=!0,window.clearInterval(O)}},[r]);let P=o!==null&&a!==null,B=(0,g.useMemo)(()=>ee(o?.sessions??[],p),[o?.sessions,p]),v=o?.supported!==!1,L=q(o),i={hostStartLabel:F(a?.host?.timestamps,o?.sampledAt,t),botmuxStartLabel:F(a?.botmux?.timestamps,o?.sampledAt,t),endLabel:t("monitoring.chartNow"),emptyLabel:t("monitoring.chartNoData")};return(0,e.jsxs)("section",{className:"page resource-page",children:[(0,e.jsx)("div",{className:"page-heading",children:(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"eyebrow",children:t("monitoring.eyebrow")}),(0,e.jsx)("h1",{children:t("monitoring.runtimeTitle")})]})}),P?null:(0,e.jsx)(G,{label:t("common.loading")}),P?(0,e.jsxs)(e.Fragment,{children:[o?(0,e.jsx)(oe,{current:o}):null,v?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("section",{className:"overview-block resource-block resource-pressure-block",children:[(0,e.jsx)(f,{title:t("monitoring.resourcePressure")}),(0,e.jsx)("section",{className:"panel resource-pressure",children:(0,e.jsxs)("div",{className:"resource-metrics runtime-pressure-grid",children:[(0,e.jsxs)(I,{label:t("monitoring.hostCpu"),onOpen:()=>c({title:t("monitoring.hostCpu"),value:S(o?.host?.cpuPct,L),detail:`load ${Number(o?.host?.load1??0).toFixed(2)}`,chart:{values:a?.host?.cpuPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("span",{children:t("monitoring.hostCpu")}),(0,e.jsx)("strong",{children:S(o?.host?.cpuPct,L)}),(0,e.jsxs)("small",{children:["load ",Number(o?.host?.load1??0).toFixed(2)]})]}),(0,e.jsxs)(I,{label:t("monitoring.hostMemory"),onOpen:()=>c({title:t("monitoring.hostMemory"),value:N(o?.host?.memUsedPct),detail:t("monitoring.memoryOnly"),chart:{values:a?.host?.memUsedPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("span",{children:t("monitoring.hostMemory")}),(0,e.jsx)("strong",{children:N(o?.host?.memUsedPct)}),(0,e.jsx)("small",{children:t("monitoring.memoryOnly")})]}),(0,e.jsxs)(I,{label:t("monitoring.botmuxRss"),onOpen:()=>c({title:t("monitoring.botmuxRss"),value:b(o?.botmux?.rssBytes),detail:o?.botmuxBreakdown?`${t("monitoring.botmuxSelf")} ${b((o.botmuxBreakdown.daemon.rssBytes??0)+(o.botmuxBreakdown.worker.rssBytes??0))}
|
|
2
2
|
${t("monitoring.botmuxCli")} ${b(o.botmuxBreakdown.cli.rssBytes)}`:S(o?.botmux?.cpuPct,L),chart:{values:a?.botmux?.rssBytes,timestamps:a?.botmux?.timestamps,unit:"bytes",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsxs)("div",{className:"metric-label-with-help",children:[(0,e.jsx)("span",{children:t("monitoring.botmuxRss")}),(0,e.jsx)(_,{label:t("monitoring.rssHelpLabel"),children:t("monitoring.rssHelp")})]}),(0,e.jsx)("strong",{children:b(o?.botmux?.rssBytes)}),o?.botmuxBreakdown&&(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("small",{className:"metric-breakdown",children:[t("monitoring.botmuxSelf")," ",b((o.botmuxBreakdown.daemon.rssBytes??0)+(o.botmuxBreakdown.worker.rssBytes??0)),(0,e.jsxs)("span",{className:"metric-breakdown-detail",children:[" (",t("monitoring.botmuxDaemon")," ",b(o.botmuxBreakdown.daemon.rssBytes)," \xB7 ",t("monitoring.botmuxWorker")," ",b(o.botmuxBreakdown.worker.rssBytes),")"]})]}),(0,e.jsxs)("small",{className:"metric-breakdown",children:[t("monitoring.botmuxCli")," ",b(o.botmuxBreakdown.cli.rssBytes)]})]})]}),(0,e.jsxs)(I,{label:t("monitoring.trackedSessions"),onOpen:()=>c({title:t("monitoring.trackedSessions"),value:d(o?.rankings?.tracked?.length),detail:`${t("monitoring.currentSessions")} ${(o?.sessions??[]).length}`,emptyText:t("monitoring.trackedSessionHint")}),children:[(0,e.jsx)("span",{children:t("monitoring.trackedSessions")}),(0,e.jsx)("strong",{children:o?.rankings?.tracked?.length??0}),(0,e.jsxs)("small",{children:[t("monitoring.currentSessions")," ",(o?.sessions??[]).length]})]})]})})]}),(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:t("monitoring.trends")}),(0,e.jsx)("section",{className:"panel resource-trends",children:(0,e.jsxs)("div",{className:"resource-trend-grid",children:[(0,e.jsxs)(M,{label:t("monitoring.trendHostCpu"),onOpen:()=>c({title:t("monitoring.trendHostCpu"),value:N(C(a?.host?.cpuPct)),detail:`load ${Number(o?.host?.load1??0).toFixed(2)}`,chart:{values:a?.host?.cpuPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{children:t("monitoring.trendHostCpu")}),(0,e.jsx)(R,{values:a?.host?.cpuPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]}),(0,e.jsxs)(M,{label:t("monitoring.trendHostMemory"),onOpen:()=>c({title:t("monitoring.trendHostMemory"),value:N(C(a?.host?.memUsedPct)),detail:t("monitoring.memoryOnly"),chart:{values:a?.host?.memUsedPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{children:t("monitoring.trendHostMemory")}),(0,e.jsx)(R,{values:a?.host?.memUsedPct,timestamps:a?.host?.timestamps,unit:"pct",startLabel:i.hostStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]}),(0,e.jsxs)(M,{label:t("monitoring.trendBotmuxCpu"),onOpen:()=>c({title:t("monitoring.trendBotmuxCpu"),value:N(C(a?.botmux?.cpuPct)),detail:t("monitoring.botRuntime"),chart:{values:a?.botmux?.cpuPct,timestamps:a?.botmux?.timestamps,unit:"pct",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{children:t("monitoring.trendBotmuxCpu")}),(0,e.jsx)(R,{values:a?.botmux?.cpuPct,timestamps:a?.botmux?.timestamps,unit:"pct",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]}),(0,e.jsxs)(M,{label:t("monitoring.botmuxRss"),onOpen:()=>c({title:t("monitoring.botmuxRss"),value:b(C(a?.botmux?.rssBytes)),detail:t("monitoring.memoryOnly"),chart:{values:a?.botmux?.rssBytes,timestamps:a?.botmux?.timestamps,unit:"bytes",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{children:t("monitoring.botmuxRss")}),(0,e.jsx)(R,{values:a?.botmux?.rssBytes,timestamps:a?.botmux?.timestamps,unit:"bytes",startLabel:i.botmuxStartLabel,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]})]})})]})]}):(0,e.jsx)("section",{className:"panel resource-unavailable",children:(0,e.jsxs)("div",{className:"resource-unavailable-card",children:[(0,e.jsx)("span",{className:"resource-unavailable-status","aria-hidden":"true"}),(0,e.jsxs)("div",{className:"resource-unavailable-copy",children:[(0,e.jsx)("span",{children:t("monitoring.unsupportedKicker")}),(0,e.jsx)("h2",{children:t("monitoring.unsupportedTitle")}),(0,e.jsx)("p",{children:t("monitoring.unsupportedHint")})]}),(0,e.jsxs)("div",{className:"resource-unavailable-tags","aria-label":t("monitoring.unsupported"),children:[(0,e.jsx)("span",{children:t("monitoring.unsupportedRuntimeOk")}),(0,e.jsx)("span",{children:t("monitoring.unsupportedResourceOnly")})]})]})}),o?(0,e.jsx)(ae,{runtime:o.runtime}):null,v?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:t("monitoring.botRuntime")}),(0,e.jsx)("section",{className:"panel",children:(0,e.jsx)(se,{bots:o?.bots??[],cpuReady:L})})]}),(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:t("monitoring.sessions"),children:(0,e.jsx)("div",{className:"resource-sortbar resource-sortbar-inline dashboard-toolbar",role:"group","aria-label":t("monitoring.sort"),children:(0,e.jsx)("div",{className:"segmented resource-sort-switch",children:["cpu","rss","growth","bot","status"].map(l=>(0,e.jsx)("button",{type:"button",className:p===l?"active":void 0,"aria-pressed":p===l,onClick:()=>x(l),children:t(`monitoring.sort.${l}`)},l))})})}),(0,e.jsx)("section",{className:"panel",children:(0,e.jsx)(re,{sessions:B,cpuReady:L})})]}),(0,e.jsxs)("section",{className:"overview-block resource-block",children:[(0,e.jsx)(f,{title:t("monitoring.trackedSessionTrends")}),(0,e.jsx)("section",{className:"panel",children:(0,e.jsxs)("div",{className:"resource-trend-grid",children:[(a?.sessions??[]).map(l=>{let h=`${l.botName} \xB7 ${l.title||l.sessionId}`,O=F(l.series?.timestamps,o?.sampledAt,t);return(0,e.jsxs)(M,{label:h,onOpen:()=>c({title:h,value:b(C(l.series?.rssBytes)),detail:l.sessionId,chart:{values:l.series?.rssBytes,timestamps:l.series?.timestamps,unit:"bytes",startLabel:O,endLabel:i.endLabel,emptyLabel:i.emptyLabel}}),children:[(0,e.jsx)("b",{title:h,children:h}),(0,e.jsx)(R,{values:l.series?.rssBytes,timestamps:l.series?.timestamps,unit:"bytes",startLabel:O,endLabel:i.endLabel,emptyLabel:i.emptyLabel})]},l.sessionId)}),(a?.sessions??[]).length?null:(0,e.jsx)("div",{className:"empty",children:t("monitoring.noTrackedHistory")})]})})]})]}):null]}):null,(0,e.jsx)(te,{detail:w,onClose:()=>c(null)})]})}function ce(n){return U(n,(0,e.jsx)(ie,{}))}export{ie as MonitoringPage,re as SessionResourceTable,ce as renderMonitoringPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as w}from"./chunk-
|
|
1
|
+
import{c as w}from"./chunk-KEEYQ3WF.js";import"./chunk-6JTZJRQJ.js";import{a as p}from"./chunk-SYC6D5XU.js";import{a as S,d as x}from"./chunk-5THX4DI2.js";import{c as g}from"./chunk-7SZRL6FY.js";var n=g(S(),1);var e=g(x(),1),u=78222186;function y(t){return(t/1048576).toFixed(0)}function T(){let t=w(),[i,a]=(0,n.useState)(null),[c,l]=(0,n.useState)(""),[m,h]=(0,n.useState)(!1),d=(0,n.useRef)(null),r=(0,n.useRef)(!1),v=()=>{d.current&&(clearTimeout(d.current),d.current=null)};async function f(){if(!r.current)try{let s=await fetch("/api/game/status");if(r.current)return;if(!s.ok){a({state:"absent",received:0,total:u});return}let o=await s.json();if(r.current)return;a(o),typeof o.proxy=="string"&&l(o.proxy),o.state==="downloading"&&(d.current=setTimeout(()=>{f()},700))}catch{r.current||(d.current=setTimeout(()=>{f()},1500))}}(0,n.useEffect)(()=>(r.current=!1,f(),()=>{r.current=!0,v()}),[]);async function b(){v(),h(!0),a({state:"downloading",received:0,total:u});try{let s=await fetch("/api/game/download",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({proxy:c.trim()})});if(r.current)return;if(!s.ok)throw new Error(`HTTP ${s.status}`);let o=await s.json();if(r.current)return;a(o),typeof o.proxy=="string"&&l(o.proxy),o.state==="downloading"&&(d.current=setTimeout(()=>{f()},700))}catch(s){if(r.current)return;a({state:"error",received:0,total:u,error:s instanceof Error?s.message:String(s)})}finally{r.current||h(!1)}}return i?.state==="ready"?(0,e.jsx)("div",{className:"office-frame-shell",children:(0,e.jsx)("iframe",{className:"office-game-frame",src:"/game/index.html",title:"HD2D Office",allow:"autoplay"})}):(0,e.jsx)(P,{status:i??{state:"absent",received:0,total:u},title:t("nav.office"),proxy:c,starting:m,onProxyChange:l,onStart:()=>{b()}})}function P(t){let i=t.status.total||u,a=(0,n.useMemo)(()=>i?Math.min(100,Math.round(t.status.received/i*100)):0,[t.status.received,i]),c=t.status.state==="downloading",l=t.status.state==="error";return(0,e.jsxs)("div",{style:{margin:"auto",textAlign:"center",maxWidth:440,padding:32,color:"var(--fg,#e6e6e6)"},children:[(0,e.jsx)("h1",{style:{fontSize:18,fontWeight:600,lineHeight:1.2,margin:"0 0 8px"},children:t.title}),(0,e.jsxs)("div",{style:{fontSize:13,opacity:.7,lineHeight:1.7,marginBottom:20},children:["\u628A\u6BCF\u4E2A\u4F1A\u8BDD\u53D8\u6210\u529E\u516C\u5BA4\u91CC\u7684\u4E00\u4E2A\u673A\u5668\u4EBA\uFF0C\u5B9E\u65F6\u6620\u5C04\u5C4F\u5E55\u72B6\u6001\u3002",(0,e.jsx)("br",{}),"\u9996\u6B21\u8FDB\u5165\u9700\u4E0B\u8F7D\u7EA6 ",y(i)," MB \u6E38\u620F\u8D44\u6E90\uFF08\u4EC5\u4E00\u6B21\uFF0C\u4E4B\u540E\u672C\u5730\u7F13\u5B58\uFF09\u3002"]}),l?(0,e.jsxs)("div",{style:{color:"#e06c75",fontSize:12,marginBottom:14},children:["\u4E0A\u6B21\u4E0B\u8F7D\u5931\u8D25\uFF1A",t.status.error??"\u672A\u77E5\u9519\u8BEF",(0,e.jsx)("br",{}),(0,e.jsx)("span",{style:{opacity:.7},children:"\u586B\u4EE3\u7406\u540E\u70B9\u91CD\u8BD5"})]}):null,c?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("div",{style:{background:"var(--surface-muted)",borderRadius:"var(--radius-lg)",height:10,overflow:"hidden",marginBottom:10},children:(0,e.jsx)("div",{style:{height:"100%",width:`${a}%`,background:"var(--accent)",transition:"width .3s"}})}),(0,e.jsxs)("div",{style:{fontSize:12,opacity:.7},children:["\u4E0B\u8F7D\u4E2D... ",y(t.status.received)," / ",y(i)," MB\uFF08",a,"%\uFF09"]})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("input",{id:"hd2d-proxy",className:"office-proxy-input",type:"text",value:t.proxy,onChange:m=>t.onProxyChange(m.currentTarget.value),placeholder:"HTTP \u4EE3\u7406\uFF08\u53EF\u9009\uFF0C\u5982 http://127.0.0.1:7890\uFF09"}),(0,e.jsx)("div",{style:{fontSize:11,opacity:.5,marginBottom:14,textAlign:"left"},children:"\u8FDE\u4E0D\u4E0A GitHub \u65F6\u586B\u4EE3\u7406\uFF08\u4EC5\u7528\u4E8E\u4E0B\u8F7D\u672C\u8D44\u6E90\uFF0C\u4F1A\u8BB0\u4F4F\uFF09\u3002\u7559\u7A7A\u8D70\u76F4\u8FDE/\u7CFB\u7EDF\u4EE3\u7406\u73AF\u5883\u53D8\u91CF\u3002"}),(0,e.jsxs)("button",{id:"hd2d-load",type:"button",className:"page-primary-action office-load-button",disabled:t.starting,onClick:t.onStart,children:[l?"\u91CD\u8BD5":"\u52A0\u8F7D\u529E\u516C\u5BA4","\uFF08\u7EA6 ",y(i)," MB\uFF09"]})]})]})}function B(t){let i={maxWidth:t.style.maxWidth,padding:t.style.padding,flex:t.style.flex,minHeight:t.style.minHeight,minWidth:t.style.minWidth,display:t.style.display,overflow:t.style.overflow};t.style.maxWidth="none",t.style.padding="0",t.style.flex="1 1 auto",t.style.minHeight="0",t.style.minWidth="0",t.style.display="flex",t.style.overflow="hidden";let a=p(t,(0,e.jsx)(T,{}));return()=>{a(),t.style.maxWidth=i.maxWidth,t.style.padding=i.padding,t.style.flex=i.flex,t.style.minHeight=i.minHeight,t.style.minWidth=i.minWidth,t.style.display=i.display,t.style.overflow=i.overflow}}export{B as renderOfficePage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Q,b as ee}from"./chunk-
|
|
1
|
+
import{a as Q,b as ee}from"./chunk-5QJB24I2.js";import{a as j,c as N}from"./chunk-KEEYQ3WF.js";import{b as x,d as T,e as k,f as I,k as X,m as O,n as P,o as _,p as G,r as J}from"./chunk-5CJMHTT4.js";import{D as q,F as H,G as V,H as M,I as g,J as A,w as L,y as $,z as C}from"./chunk-6JTZJRQJ.js";import{a as W}from"./chunk-SYC6D5XU.js";import{a as re,d as K}from"./chunk-5THX4DI2.js";import{c as E}from"./chunk-7SZRL6FY.js";var r=E(re(),1);var t=E(K(),1),le=new Set(["working","analyzing","active","starting"]),ce=new Set(["idle","dormant"]),te="botmux.overview.teamExpanded",ne="botmux.overview.activeSort",z=5,B=1,ve=260;function de(){try{return window.localStorage.getItem(te)==="1"}catch{return!1}}function me(e){try{window.localStorage.setItem(te,e?"1":"0")}catch{}}function ue(e){return e==="attention"?"attention":"time"}function pe(){try{return ue(window.localStorage.getItem(ne))}catch{return"time"}}function we(e){try{window.localStorage.setItem(ne,e)}catch{}}function fe(e,o){let s=(i,a)=>Number(a.lastMessageAt??0)-Number(i.lastMessageAt??0);return o==="attention"?[...e].sort((i,a)=>{let v=g(i)?0:1,c=g(a)?0:1;if(v!==c)return v-c;if(v===0){let d=A(i)-A(a);if(d!==0)return d}return s(i,a)}):[...e].sort(s)}function ge(e){return String(e??"unknown").toLowerCase().replace(/[^a-z0-9_-]/g,"-")}function Se(e,o){let s=String(e??"unknown"),i=`sessions.status.${s}`,a=o(i);return a===i?s:a}function he(e){if(!e)return B*z;let o=window.getComputedStyle(e).gridTemplateColumns.split(/\s+/).filter(i=>Number.parseFloat(i)>0);return Math.max(1,o.length||z)*B}function be(e,o){if(!e)return;let s=document.querySelector(".sidebar");if(!s||window.matchMedia("(max-width: 980px)").matches){e.style.removeProperty(o);return}let i=s.getBoundingClientRect().bottom,a=e.getBoundingClientRect().top,c=`${Math.max(ve,Math.round(i-a))}px`;e.style.getPropertyValue(o)!==c&&e.style.setProperty(o,c)}function Ae({card:e}){let o=N(),s=$(e.larkAppId,e.brand),i=!e.online&&e.active.length===0,a=e.attention.length>0,v=e.busy.length>0,c=a?"warn":v?"busy":i?"off":"ok",d;if(a){let u=[...e.attention].sort((h,f)=>A(h)-A(f))[0];d=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("b",{children:(M(u.title)||u.sessionId).slice(0,60)})," \xB7 ",g(u)??""]})}else if(v){let u=[...e.busy].sort((h,f)=>Number(f.lastMessageAt??0)-Number(h.lastMessageAt??0))[0];d=(0,t.jsx)("b",{children:(M(u.title)||u.sessionId).slice(0,60)})}else i?d=o("overview.botOffline"):d=o("overview.botIdle");let S=a?(0,t.jsx)("span",{className:"tag tag-warn",children:o("overview.botNeedsYou")}):v?(0,t.jsx)("span",{className:"tag tag-run",children:o("overview.botBusy",{count:e.busy.length})}):i?(0,t.jsx)("span",{className:"tag tag-off",children:o("overview.botOff")}):(0,t.jsx)("span",{className:"tag tag-ok",children:o("overview.botReady")});return(0,t.jsxs)("article",{className:`mate${a?" mate-attn":""}${i?" mate-off":""}`,children:[s?(0,t.jsx)("a",{className:"mate-console",href:s,target:"_blank",rel:"noopener noreferrer","data-tip":o("overview.botConsole"),"aria-label":o("overview.botConsole"),children:(0,t.jsx)("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,t.jsx)("path",{d:"M7 17 17 7M9 7h8v8"})})}):null,(0,t.jsxs)("div",{className:"mate-top",children:[(0,t.jsx)(x,{html:C({name:e.botName,larkAppId:e.larkAppId,avatarUrl:e.botAvatarUrl,dot:c})}),(0,t.jsxs)("div",{className:"mate-id",children:[(0,t.jsx)("b",{children:e.botName}),(0,t.jsx)("span",{className:"mate-role",children:e.cliId})]})]}),(0,t.jsx)("div",{className:"mate-task",children:d}),(0,t.jsxs)("div",{className:"mate-foot",children:[S,(0,t.jsx)("span",{children:e.lastActiveAt?o("overview.lastActive",{time:L(e.lastActiveAt)}):o("common.never")})]})]})}function Ne({session:e}){let o=N(),s=H(e),i=String(e.status??"unknown"),a=g(e);return(0,t.jsxs)(P,{kind:"session",children:[(0,t.jsx)(x,{html:C({name:s,larkAppId:e.larkAppId,size:"sm"})}),(0,t.jsxs)(_,{children:[(0,t.jsx)("b",{children:(M(e.title)||e.sessionId).slice(0,64)}),(0,t.jsxs)("span",{children:[s," \xB7 ",V(e)??e.cliId??"unknown"," \xB7 ",L(e.lastMessageAt)]})]}),(0,t.jsx)(G,{children:a?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("a",{className:"overview-list-action",href:"#/sessions",children:o("strip.handle")}),(0,t.jsx)("span",{className:"status overview-list-status status-attention",children:a})]}):(0,t.jsx)("span",{className:`status overview-list-status status-${ge(i)}`,children:Se(i,o)})})]})}function ye({schedule:e,timeZone:o}){let s=e.nextRunAt?new Date(e.nextRunAt).toLocaleString(void 0,o?{timeZone:o,timeZoneName:"short"}:void 0):"-";return(0,t.jsxs)(P,{kind:"schedule",children:[(0,t.jsxs)(_,{children:[(0,t.jsx)("strong",{children:e.name??e.id}),(0,t.jsxs)("span",{children:[H(e)," \xB7 ",e.parsed?.display??""]})]}),(0,t.jsx)("span",{className:"overview-list-meta",children:(0,t.jsx)(X,{text:s,showPopover:!1,durationMs:2600})})]})}function Me({mode:e,onModeChange:o}){let s=N(),i=s(e==="attention"?"overview.sortAttentionFirst":"overview.sortByTime");return(0,t.jsx)(J,{className:"overview-active-sort-menu",label:i,value:e,options:[{value:"time",label:s("overview.sortByTime")},{value:"attention",label:s("overview.sortAttentionFirst")}],onChange:o})}function Te(){let e=N(),o=(0,r.useRef)(null),s=(0,r.useRef)(null),i=(0,r.useRef)(null),[a,v]=(0,r.useState)(de),[c,d]=(0,r.useState)(pe),[S,u]=(0,r.useState)(B*z),[h,f]=(0,r.useState)(0),{sessions:y,schedules:D,scheduleTimeZone:oe}=j(n=>({sessions:[...n.sessions.values()],schedules:[...n.schedules.values()],scheduleTimeZone:n.scheduleTimeZone}));(0,r.useEffect)(()=>{let n=0,m=()=>{window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{let w=he(o.current);u(l=>l===w?l:w)})};m();let p=typeof ResizeObserver>"u"||!o.current?null:new ResizeObserver(m);return p&&o.current&&p.observe(o.current),window.addEventListener("resize",m),()=>{window.cancelAnimationFrame(n),p?.disconnect(),window.removeEventListener("resize",m)}},[]),(0,r.useEffect)(()=>{Q().then(()=>f(n=>n+1)),q().then(()=>f(n=>n+1))},[]);let F=(0,r.useMemo)(()=>y.filter(n=>n.status!=="closed"),[y]),b=(0,r.useMemo)(()=>ee(y),[y,h]),U=a?b:b.slice(0,S),Y=(0,r.useMemo)(()=>fe(F.filter(n=>g(n)||le.has(n.status)||ce.has(n.status)),c).slice(0,7),[F,c]),R=(0,r.useMemo)(()=>D.filter(n=>n.nextRunAt).sort((n,m)=>Date.parse(n.nextRunAt)-Date.parse(m.nextRunAt)).slice(0,5),[D]);(0,r.useEffect)(()=>{let n=[{el:s.current,propertyName:"--active-sessions-min-height"},{el:i.current,propertyName:"--schedules-panel-min-height"}].filter(l=>!!l.el);if(!n.length)return;let m=0,p=()=>{window.cancelAnimationFrame(m),m=window.requestAnimationFrame(()=>{for(let l of n)be(l.el,l.propertyName)})};p();let w=typeof ResizeObserver>"u"?null:new ResizeObserver(p);if(w){for(let ae of n)w.observe(ae.el);let l=document.querySelector(".sidebar"),Z=n[0].el.closest(".page");l&&w.observe(l),Z&&w.observe(Z)}return window.addEventListener("resize",p),()=>{window.cancelAnimationFrame(m),w?.disconnect(),window.removeEventListener("resize",p);for(let l of n)l.el.style.removeProperty(l.propertyName)}},[a,S,b.length,R.length]);let se=()=>{v(n=>(me(!n),!n))},ie=n=>{d(n),we(n)};return(0,t.jsxs)("section",{className:"page hero-page",children:[(0,t.jsx)("div",{className:"page-heading",children:(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"eyebrow",children:e("app.subtitle")}),(0,t.jsx)("h1",{children:e("overview.title")})]})}),(0,t.jsxs)("div",{className:"overview-layout",children:[(0,t.jsxs)("div",{className:"overview-main",children:[(0,t.jsxs)("section",{className:"overview-block team-section",children:[(0,t.jsx)(T,{title:e("overview.team"),count:e("overview.teamCount",{count:b.length}),hint:e("overview.teamHint"),children:(0,t.jsx)(I,{children:(0,t.jsx)(k,{href:"#/bot-defaults",children:e("overview.viewAllPlain")})})}),(0,t.jsx)("div",{className:"team-grid",id:"team-grid",ref:o,children:U.length?U.map(n=>(0,t.jsx)(Ae,{card:n},n.larkAppId??n.botName)):(0,t.jsx)("div",{className:"empty",children:e("overview.noSessions")})}),b.length>S?(0,t.jsx)("button",{type:"button",className:"team-toggle",id:"team-toggle",onClick:se,children:e(a?"overview.teamCollapse":"overview.teamExpand")}):null]}),(0,t.jsxs)("section",{className:"overview-block",children:[(0,t.jsx)(T,{title:e("overview.activeSessions"),children:(0,t.jsxs)(I,{children:[(0,t.jsx)(Me,{mode:c,onModeChange:ie}),(0,t.jsx)(k,{href:"#/sessions",children:e("overview.viewAllPlain")})]})}),(0,t.jsx)("section",{className:"panel active-sessions-panel",ref:s,children:(0,t.jsx)(O,{id:"recent-sessions",children:Y.length?Y.map(n=>(0,t.jsx)(Ne,{session:n},n.sessionId)):(0,t.jsx)("li",{className:"empty",children:e("overview.noSessions")})})})]})]}),(0,t.jsx)("aside",{className:"overview-side",children:(0,t.jsxs)("section",{className:"overview-block",children:[(0,t.jsx)(T,{title:e("overview.nextSchedules"),children:(0,t.jsx)(k,{href:"#/schedules",children:e("overview.viewAllPlain")})}),(0,t.jsx)("section",{className:"panel schedules-panel",ref:i,children:(0,t.jsx)(O,{id:"next-schedules",children:R.length?R.map(n=>(0,t.jsx)(ye,{schedule:n,timeZone:oe},n.id)):(0,t.jsx)("li",{className:"empty",children:e("overview.noSchedules")})})})]})})]})]})}function He(e){e.classList.add("overview-root");let o=W(e,(0,t.jsx)(Te,{}));return()=>{o(),e.classList.remove("overview-root")}}export{He as renderOverviewPage};
|