@wrongstack/webui 0.296.2 → 0.296.4
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/assets/{AgentRosterView-CG7hiTO5.js → AgentRosterView-DTbg5NoZ.js} +1 -1
- package/dist/assets/{AnalyticsDashboard-BQH6L1S1.js → AnalyticsDashboard-Xc8aG4ev.js} +1 -1
- package/dist/assets/{AudienceMemoryPanel-DX4uLxnp.js → AudienceMemoryPanel-C1mj_XOq.js} +1 -1
- package/dist/assets/{ChangesView-B2DsGWiA.js → ChangesView-W_UTPolz.js} +1 -1
- package/dist/assets/{ChronicleDashboard-DI6fBbLJ.js → ChronicleDashboard-BivxCmdl.js} +1 -1
- package/dist/assets/{CodeEditor-CgXWP1-I.js → CodeEditor-NAOGCzZS.js} +1 -1
- package/dist/assets/{CronJobsPanel-ByrWTFMO.js → CronJobsPanel-0virGKLS.js} +1 -1
- package/dist/assets/DeadCodeScanPanel-DHsw8Nn4.js +2 -0
- package/dist/assets/{DebugDashboard-C4jNeXwd.js → DebugDashboard-DYEVc0PA.js} +1 -1
- package/dist/assets/{DesignGalleryView-DR2MqDGO.js → DesignGalleryView-BSBDNBNf.js} +1 -1
- package/dist/assets/{GoalView-BsZXe4sN.js → GoalView-C_wodXvj.js} +1 -1
- package/dist/assets/{KanbanView-CjAQz5ko.js → KanbanView-D7SKeieE.js} +1 -1
- package/dist/assets/{LazyMarkdown-BGp00cAh.js → LazyMarkdown-Bt3iw3ZV.js} +1 -1
- package/dist/assets/{MailboxDetailView-D2zOtsHb.js → MailboxDetailView-BaFQIyhC.js} +1 -1
- package/dist/assets/{MemoryManager-C0c6SLEn.js → MemoryManager-CWkdwf8F.js} +1 -1
- package/dist/assets/{ModelPicker-HVIA8pKx.js → ModelPicker-CJBOoZME.js} +1 -1
- package/dist/assets/{OfficeMapPanel-DtMjwPJ2.js → OfficeMapPanel-BopbmfGN.js} +1 -1
- package/dist/assets/{ProcessMonitor-Es5rkf_W.js → ProcessMonitor-d_5Iwyo7.js} +1 -1
- package/dist/assets/{QueuePanel-BO4V720k.js → QueuePanel-DlNF8CUn.js} +1 -1
- package/dist/assets/{RefreshDebugView-CnOMdm5p.js → RefreshDebugView-gPMro5jy.js} +1 -1
- package/dist/assets/{SageTabs-C630-UtZ.js → SageTabs-yP5fr4lP.js} +2 -2
- package/dist/assets/{SddHub-BUPmZYcI.js → SddHub-DjeM7IaL.js} +1 -1
- package/dist/assets/{SessionsDashboard-_a7mqxAP.js → SessionsDashboard-D7b7aEse.js} +1 -1
- package/dist/assets/SetupScreen-Dsek43zs.js +1 -0
- package/dist/assets/{SkillDetailView-BucSq6E1.js → SkillDetailView-DxdqTQ5E.js} +1 -1
- package/dist/assets/{SpecsView-C4BODULT.js → SpecsView-Bu8xHf5j.js} +1 -1
- package/dist/assets/{TechStackView-CibHS3rz.js → TechStackView--7TPHg0R.js} +1 -1
- package/dist/assets/{TerminalPanel-AM_WVT3e.js → TerminalPanel-gA6ThdVE.js} +1 -1
- package/dist/assets/{Toaster-C6a7sphP.js → Toaster-DTJHnKyl.js} +1 -1
- package/dist/assets/{i18n-CIqbHugq.js → i18n-C2VyJ0Kz.js} +2 -2
- package/dist/assets/index-3CuRO3-V.css +1 -0
- package/dist/assets/{index-Dy7C2V-G.js → index-DSXHr5yP.js} +31 -30
- package/dist/assets/{progress-ring-D8StLpFh.js → progress-ring-BEsRLdjq.js} +1 -1
- package/dist/assets/{roster-ws-DOgj2SAo.js → roster-ws-CVCrt_ih.js} +1 -1
- package/dist/assets/settings-C5F2tQ7C.js +1 -0
- package/dist/assets/settings-Cdk8i_p6.js +1 -0
- package/dist/assets/settings-D6wFOw5n.js +1 -0
- package/dist/assets/settings-DCEOkxYE.js +1 -0
- package/dist/assets/settings-DEmKlLmn.js +1 -0
- package/dist/assets/settings-DsflqNn0.js +1 -0
- package/dist/assets/settings-skShEZ2B.js +1 -0
- package/dist/assets/{stores-nxVpq1NP.js → stores-hEu6z1qz.js} +1 -1
- package/dist/assets/ui-store-BI3LH2q8.js +1 -0
- package/dist/assets/{useWebSocket-DLQNx26C.js → useWebSocket-Ba38Sknk.js} +2 -2
- package/dist/assets/{view-navigation-DuOBOluC.js → view-navigation-BSA3_knE.js} +1 -1
- package/dist/assets/ws-client-eyEv8wbm.js +1 -0
- package/dist/components/AgentOfficeDetails.d.ts.map +1 -1
- package/dist/components/AgentOfficeView.d.ts.map +1 -1
- package/dist/components/AgentRosterView.d.ts.map +1 -1
- package/dist/components/ChatInput.d.ts.map +1 -1
- package/dist/components/ChatView/index.d.ts.map +1 -1
- package/dist/components/CodeMap.d.ts.map +1 -1
- package/dist/components/DeadCodeScanPanel/DeadCodeScanPanel.d.ts.map +1 -1
- package/dist/components/MessageBubble/ToolLedgerCard.d.ts.map +1 -1
- package/dist/components/MessageBubble/index.d.ts.map +1 -1
- package/dist/components/NextStepsBar.d.ts +9 -3
- package/dist/components/NextStepsBar.d.ts.map +1 -1
- package/dist/components/OfficeMapCanvas/CanvasPanels.d.ts.map +1 -1
- package/dist/components/OfficeMapCanvas.d.ts.map +1 -1
- package/dist/components/SettingsPanel/ConnectionsHealthSection.d.ts.map +1 -1
- package/dist/components/SetupScreen/ProviderKeyCard.d.ts.map +1 -1
- package/dist/components/SetupScreen.d.ts.map +1 -1
- package/dist/components/ToolResult.d.ts +8 -1
- package/dist/components/ToolResult.d.ts.map +1 -1
- package/dist/components/context-editor/ContextWindowEditor.d.ts.map +1 -1
- package/dist/hooks/ws-handlers/chat-handlers.d.ts.map +1 -1
- package/dist/index.html +12 -12
- package/dist/index.js +3285 -2912
- package/dist/index.js.map +4 -4
- package/dist/lib/sage-block.d.ts.map +1 -1
- package/dist/lib/ws-client.d.ts +11 -1
- package/dist/lib/ws-client.d.ts.map +1 -1
- package/dist/stores/local-prefs.d.ts +1 -1
- package/dist/stores/local-prefs.d.ts.map +1 -1
- package/dist/stores/types.d.ts +9 -0
- package/dist/stores/types.d.ts.map +1 -1
- package/dist/types/client-message.d.ts +6 -0
- package/dist/types/client-message.d.ts.map +1 -1
- package/dist/types/connections.d.ts +6 -0
- package/dist/types/connections.d.ts.map +1 -1
- package/dist/types/protocol-core.d.ts +6 -0
- package/dist/types/protocol-core.d.ts.map +1 -1
- package/dist/types/server-message.d.ts +4 -1
- package/dist/types/server-message.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/assets/DeadCodeScanPanel-mREO2zoW.js +0 -2
- package/dist/assets/SetupScreen-BiOzT5PT.js +0 -1
- package/dist/assets/index-B_lRId11.css +0 -1
- package/dist/assets/settings-BHVrMeiB.js +0 -1
- package/dist/assets/settings-BNkUdI3D.js +0 -1
- package/dist/assets/settings-ByapDpso.js +0 -1
- package/dist/assets/settings-DDjoc06u.js +0 -1
- package/dist/assets/settings-DgZ3cEL3.js +0 -1
- package/dist/assets/settings-iiGjrvpU.js +0 -1
- package/dist/assets/settings-oGMBWYjV.js +0 -1
- package/dist/assets/ui-store-CBdBem9f.js +0 -1
- package/dist/assets/ws-client-D0KuNwAk.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-DaSs2P3S.js";import{Ai as n,Ct as r,Ir as i,It as a,Ji as o,Kn as s,Li as c,Si as l,Ut as u,Xi as d,Yi as f,Zt as p,ai as m,at as h,bt as g,cn as _,et as v,gi as y,ii as b,it as x,ot as S,pa as C,qt as w,rr as T,tr as E,xa as D}from"./vendor-9hC4n4Me.js";import{n as O}from"./ui-store-CBdBem9f.js";import{t as k}from"./ws-client-D0KuNwAk.js";import{t as A}from"./utils-DzRQUvln.js";import{x as j}from"./stores-nxVpq1NP.js";import{n as M}from"./Toaster-C6a7sphP.js";import{n as N,t as P}from"./ModelPicker-HVIA8pKx.js";import{u as F}from"./index-Dy7C2V-G.js";import{t as I}from"./roster-ws-DOgj2SAo.js";var L=e(D(),1),R=v(),z=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],B=[[`timeoutMs`,`Total timeout (ms)`],[`idleTimeoutMs`,`Idle timeout (ms)`],[`maxIterations`,`Max iterations`],[`maxToolCalls`,`Max tool calls`],[`maxTokens`,`Max tokens`],[`maxCostUsd`,`Max cost (USD)`]];function V(e){return`${e.provider}/${e.model}`}function H(e){let t=e.indexOf(`/`);return t<0?{provider:``,model:e}:{provider:e.slice(0,t),model:e.slice(t+1)}}function U(e){return Array.isArray(e)?e.join(`, `):``}function W(e){return[...new Set(e.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean))]}function G({initialConfig:e,systemProtected:t,saving:n,onSave:r,onCancel:i}){let[a,o]=(0,L.useState)(()=>structuredClone(e)),s=N(!0),c=a.modelPolicy,l=(0,L.useMemo)(()=>(c?.allowed??[]).map(V),[c?.allowed]),d=(0,L.useMemo)(()=>(c?.fallbacks??[]).map(V),[c?.fallbacks]),f=e=>o(t=>({...t,...e})),p=(e,t)=>{let n=W(t);o(t=>{let r={...t};return n.length?r[e]=n:delete r[e],r})},m=(e,t)=>{o(n=>{let r={...n.budget??{}};t===``?delete r[e]:r[e]=Number(t);let i={...n};return Object.keys(r).length?i.budget=r:delete i.budget,i})},h=e=>{let t=e.map(H),n=new Set(e);o(e=>({...e,modelPolicy:{allowed:t,fallbacks:(e.modelPolicy?.fallbacks??[]).filter(e=>n.has(V(e))),strict:e.modelPolicy?.strict??!0}}))};return(0,R.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-border bg-card/40 p-4`,children:[t&&(0,R.jsxs)(`div`,{className:`flex gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 p-2 text-[11px] text-muted-foreground`,children:[(0,R.jsx)(u,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-500`}),(0,R.jsx)(`span`,{children:`Protected system agent: required tools and capabilities are retained, minimum budgets are enforced, working hours remain advisory, and emergency model recovery stays enabled so core operations cannot be disabled.`})]}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsx)(`h4`,{className:`text-xs font-semibold`,children:`Provider and model policy`}),(0,R.jsx)(P,{candidates:s,provider:a.provider,value:a.model,placeholder:`Use project default model`,resetLabel:`Use project default`,onReset:()=>{o(e=>{let t={...e};return delete t.provider,delete t.model,t})},onPick:(e,t)=>{let n=`${t}/${e}`;f({provider:t,model:e}),c&&!l.includes(n)&&h([...l,n])}}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:!!c,onChange:e=>{if(e.target.checked){let e=a.provider&&a.model?[{provider:a.provider,model:a.model}]:s[0]?[{provider:s[0].provider,model:s[0].model}]:[];e.length&&f({modelPolicy:{allowed:e,strict:!0}})}else o(e=>{let t={...e};return delete t.modelPolicy,t})}}),`Restrict this agent to an explicit model allowlist`]}),c&&(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-medium`,children:`Allowed models`}),(0,R.jsx)(F,{value:l,candidates:s,onChange:h,placeholder:`Add allowed model`,emptyHint:`At least one model is required`})]}),(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-medium`,children:`Ordered fallback chain`}),(0,R.jsx)(F,{value:d,candidates:s,onChange:e=>{let t=[...new Set([...l,...e])];o(n=>({...n,modelPolicy:{allowed:t.map(H),fallbacks:e.map(H),strict:n.modelPolicy?.strict??!0}}))},placeholder:`Add fallback model`,emptyHint:`No fallback; primary failure stops the task`})]})]})]}),(0,R.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[[`tools`,`Tools`,`read_file, search, bash`],[`skillNames`,`Skills`,`security-check, browser`],[`allowedCapabilities`,`Capabilities`,`fs.read, fs.write`]].map(([e,t,n])=>(0,R.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:t}),(0,R.jsx)(`textarea`,{value:U(a[e]),onChange:t=>p(e,t.target.value),placeholder:n,className:`h-20 w-full resize-y rounded border border-border bg-background p-2 font-mono`})]},e))}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsx)(`h4`,{className:`text-xs font-semibold`,children:`Workspace and isolation`}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,R.jsx)(`span`,{children:`Project-relative working directory`}),(0,R.jsx)(`input`,{value:a.cwd??``,onChange:e=>f({cwd:e.target.value||void 0}),placeholder:`packages/webui`,className:`h-8 w-full rounded border border-border bg-background px-2 font-mono`})]}),(0,R.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,R.jsx)(`span`,{children:`Git worktree isolation`}),(0,R.jsxs)(`select`,{value:String(a.worktree??`auto`),onChange:e=>f({worktree:e.target.value}),className:`h-8 w-full rounded border border-border bg-background px-2`,children:[(0,R.jsx)(`option`,{value:`auto`,children:`Automatic`}),(0,R.jsx)(`option`,{value:`required`,children:`Required`}),(0,R.jsx)(`option`,{value:`off`,children:`Off`})]})]})]})]}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsx)(`h4`,{className:`text-xs font-semibold`,children:`Limits`}),(0,R.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:B.map(([e,t])=>(0,R.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,R.jsx)(`span`,{children:t}),(0,R.jsx)(`input`,{type:`number`,min:`0`,step:e===`maxCostUsd`?`0.01`:`1`,value:a.budget?.[e]??``,onChange:t=>m(e,t.target.value),className:`h-8 w-full rounded border border-border bg-background px-2`})]},e))})]}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-xs font-semibold`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:!!a.availability,onChange:e=>{e.target.checked?f({availability:{timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`,days:[1,2,3,4,5],start:`09:00`,end:`18:00`,mode:t?`advisory`:`enforce`}}):o(e=>{let t={...e};return delete t.availability,t})}}),`Working hours`]}),a.availability&&(0,R.jsxs)(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:z.map((e,t)=>(0,R.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px]`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:a.availability?.days.includes(t)??!1,onChange:e=>{let n=a.availability;if(!n)return;let r=e.target.checked?[...new Set([...n.days,t])].sort():n.days.filter(e=>e!==t);f({availability:{...n,days:r}})}}),e]},e))}),(0,R.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-4`,children:[(0,R.jsx)(`input`,{value:a.availability.timezone,onChange:e=>f({availability:{...a.availability,timezone:e.target.value}}),placeholder:`Europe/Kiev`,className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,R.jsx)(`input`,{type:`time`,value:a.availability.start,onChange:e=>f({availability:{...a.availability,start:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,R.jsx)(`input`,{type:`time`,value:a.availability.end,onChange:e=>f({availability:{...a.availability,end:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,R.jsxs)(`select`,{value:t?`advisory`:a.availability.mode??`enforce`,disabled:t,onChange:e=>f({availability:{...a.availability,mode:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`,children:[(0,R.jsx)(`option`,{value:`enforce`,children:`Enforce`}),(0,R.jsx)(`option`,{value:`advisory`,children:`Advisory`})]})]})]})]}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:n||!!(c&&c.allowed.length===0),onClick:()=>r(a),className:`rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50`,children:n?`Saving…`:`Save runtime policy`}),(0,R.jsx)(`button`,{type:`button`,onClick:i,className:`rounded border border-border px-3 py-1.5 text-xs hover:bg-accent`,children:`Cancel`})]})]})}var K=[{id:`live`,icon:(0,R.jsx)(C,{className:`h-4 w-4`}),label:`Live Fleet`},{id:`catalog`,icon:(0,R.jsx)(f,{className:`h-4 w-4`}),label:`Roster Catalog`},{id:`learning`,icon:(0,R.jsx)(d,{className:`h-4 w-4`}),label:`Self-Learning`},{id:`customize`,icon:(0,R.jsx)(w,{className:`h-4 w-4`}),label:`Customization`}],q=[{role:`generic`,name:`Generic Project Agent`,summary:`Flexible template that can be cloned into independently learning project roles.`,tools:0,budget:{maxIterations:2500,maxToolCalls:7500}},{role:`audit-log`,name:`Audit Log`,summary:`Analyzes session logs, event streams, and system traces.`,tools:12,budget:{timeoutMs:108e5,maxIterations:2500,maxToolCalls:7500}},{role:`bug-hunter`,name:`Bug Hunter`,summary:`Scans code for bugs, code smells, and anti-patterns.`,tools:15,budget:{timeoutMs:18e6,maxIterations:4e3,maxToolCalls:1e4}},{role:`refactor-planner`,name:`Refactor Planner`,summary:`Analyzes code structure and produces phased refactoring plans.`,tools:14,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:9e3}},{role:`security-scanner`,name:`Security Scanner`,summary:`Scans code, configs, and dependencies for security issues.`,tools:18,budget:{timeoutMs:18e6,maxIterations:4e3,maxToolCalls:1e4}},{role:`critic`,name:`Critic`,summary:`Evaluates decisions, plans, and implementations.`,tools:10,budget:{timeoutMs:108e5,maxIterations:2e3,maxToolCalls:5e3}},{role:`shadow-agent`,name:`Shadow Agent`,summary:`Background monitoring agent that watches fleet health.`,tools:8,budget:{timeoutMs:36e6,maxIterations:500,maxToolCalls:2e3}},{role:`executor`,name:`Executor`,summary:`General-purpose task executor for delegated work.`,tools:20,budget:{timeoutMs:72e5,maxIterations:1500,maxToolCalls:4e3}},{role:`chimera`,name:`Chimera`,summary:`Post-session code quality review of changed files.`,tools:10,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`researcher`,name:`Researcher`,summary:`Web research and data gathering specialist.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`tech-stack`,name:`Tech Stack Validator`,summary:`Validates package/library/framework choices.`,tools:9,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`orchestrator`,name:`Orchestrator`,summary:`Coordinates multi-agent task execution.`,tools:12,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:8e3}},{role:`supervisor`,name:`Supervisor`,summary:`Oversees subagent execution and handles escalations.`,tools:10,budget:{timeoutMs:144e5,maxIterations:2e3,maxToolCalls:6e3}},{role:`quality-gate`,name:`Quality Gate`,summary:`Enforces quality gates on implementations.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`architect`,name:`Architect`,summary:`Makes design and architecture decisions.`,tools:14,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:8e3}},{role:`prompt-engineer`,name:`Prompt Engineer`,summary:`Designs and optimizes system prompts.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`mnemosyne`,name:`Mnemosyne`,summary:`Memory curator — reviews and maintains SAGE integrity.`,tools:6,budget:{timeoutMs:72e5,maxIterations:500,maxToolCalls:2e3}},{role:`autophase`,name:`AutoPhase`,summary:`Manages multi-phase autonomous task execution.`,tools:10,budget:{timeoutMs:144e5,maxIterations:2e3,maxToolCalls:6e3}}];function J({customStats:e,rosterLoading:t,onRefresh:n}){return(0,R.jsx)(`div`,{className:`shrink-0 border-b border-border/70 bg-card/80 px-4 py-2.5`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-nowrap min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 overflow-hidden`,children:[(0,R.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 shrink-0 rounded-lg bg-primary/10`,children:(0,R.jsx)(E,{className:`h-4 w-4 text-primary`})}),(0,R.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[(0,R.jsx)(`h1`,{className:`text-sm font-semibold truncate`,children:`Agent Roster`}),(0,R.jsxs)(`p`,{className:`text-[10px] text-muted-foreground truncate`,children:[e.filter(e=>e.exists||e.hasIdentity||e.hasConfig||e.hasKnowledge).length,` `,`customized · `,e.reduce((e,t)=>e+t.entryCount,0),` learned entries`]})]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[t&&(0,R.jsx)(s,{className:`h-4 w-4 animate-spin text-muted-foreground shrink-0`}),(0,R.jsxs)(`button`,{type:`button`,onClick:n,className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors shrink-0 whitespace-nowrap`,title:`Refresh roster data`,children:[(0,R.jsx)(_,{className:`h-3 w-3`}),` Refresh`]})]})]})})}function Y({activeTab:e,onTabChange:t}){return(0,R.jsx)(`div`,{className:`shrink-0 border-b border-border/50 bg-muted/20 px-3 flex gap-0`,children:K.map(n=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id),className:A(`flex items-center gap-1.5 px-3 py-2 text-[10px] font-medium border-b-2 transition-colors`,e===n.id?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground hover:border-muted-foreground/30`),children:[n.icon,n.label]},n.id))})}function X({customStats:e,onRefresh:r}){let[i,o]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),[u,p]=(0,L.useState)({}),[m,h]=(0,L.useState)(``),[_,v]=(0,L.useState)(null),[y,S]=(0,L.useState)(!1),[C,w]=(0,L.useState)(!1),[T,E]=(0,L.useState)(null),[D,j]=(0,L.useState)(!1),[N,P]=(0,L.useState)(!1),F=(0,L.useMemo)(()=>[...e].sort((e,t)=>e.role.localeCompare(t.role)),[e]),z=(0,L.useMemo)(()=>i?F.find(e=>e.role===i):null,[i,F]),B=(0,L.useCallback)(async e=>{w(!0),l(null);try{let t=await I(`agent-roster.read-learned`,{role:e});l(t.entries??[]),p({})}catch{}w(!1)},[]),V=(0,L.useCallback)(async()=>{if(!i||!c)return;S(!0);let e=c.filter((e,t)=>u[t]!==`drop`).join(`
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-DaSs2P3S.js";import{Ai as n,Ct as r,Ir as i,It as a,Ji as o,Kn as s,Li as c,Si as l,Ut as u,Xi as d,Yi as f,Zt as p,ai as m,at as h,bt as g,cn as _,et as v,gi as y,ii as b,it as x,ot as S,pa as C,qt as w,rr as T,tr as E,xa as D}from"./vendor-9hC4n4Me.js";import{n as O}from"./ui-store-BI3LH2q8.js";import{t as k}from"./ws-client-eyEv8wbm.js";import{t as A}from"./utils-DzRQUvln.js";import{x as j}from"./stores-hEu6z1qz.js";import{n as M}from"./Toaster-DTJHnKyl.js";import{n as N,t as P}from"./ModelPicker-CJBOoZME.js";import{u as F}from"./index-DSXHr5yP.js";import{t as I}from"./roster-ws-CVCrt_ih.js";var L=e(D(),1),R=v(),z=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],B=[[`timeoutMs`,`Total timeout (ms)`],[`idleTimeoutMs`,`Idle timeout (ms)`],[`maxIterations`,`Max iterations`],[`maxToolCalls`,`Max tool calls`],[`maxTokens`,`Max tokens`],[`maxCostUsd`,`Max cost (USD)`]];function V(e){return`${e.provider}/${e.model}`}function H(e){let t=e.indexOf(`/`);return t<0?{provider:``,model:e}:{provider:e.slice(0,t),model:e.slice(t+1)}}function U(e){return Array.isArray(e)?e.join(`, `):``}function W(e){return[...new Set(e.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean))]}function G({initialConfig:e,systemProtected:t,saving:n,onSave:r,onCancel:i}){let[a,o]=(0,L.useState)(()=>structuredClone(e)),s=N(!0),c=a.modelPolicy,l=(0,L.useMemo)(()=>(c?.allowed??[]).map(V),[c?.allowed]),d=(0,L.useMemo)(()=>(c?.fallbacks??[]).map(V),[c?.fallbacks]),f=e=>o(t=>({...t,...e})),p=(e,t)=>{let n=W(t);o(t=>{let r={...t};return n.length?r[e]=n:delete r[e],r})},m=(e,t)=>{o(n=>{let r={...n.budget??{}};t===``?delete r[e]:r[e]=Number(t);let i={...n};return Object.keys(r).length?i.budget=r:delete i.budget,i})},h=e=>{let t=e.map(H),n=new Set(e);o(e=>({...e,modelPolicy:{allowed:t,fallbacks:(e.modelPolicy?.fallbacks??[]).filter(e=>n.has(V(e))),strict:e.modelPolicy?.strict??!0}}))};return(0,R.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-border bg-card/40 p-4`,children:[t&&(0,R.jsxs)(`div`,{className:`flex gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 p-2 text-[11px] text-muted-foreground`,children:[(0,R.jsx)(u,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-500`}),(0,R.jsx)(`span`,{children:`Protected system agent: required tools and capabilities are retained, minimum budgets are enforced, working hours remain advisory, and emergency model recovery stays enabled so core operations cannot be disabled.`})]}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsx)(`h4`,{className:`text-xs font-semibold`,children:`Provider and model policy`}),(0,R.jsx)(P,{candidates:s,provider:a.provider,value:a.model,placeholder:`Use project default model`,resetLabel:`Use project default`,onReset:()=>{o(e=>{let t={...e};return delete t.provider,delete t.model,t})},onPick:(e,t)=>{let n=`${t}/${e}`;f({provider:t,model:e}),c&&!l.includes(n)&&h([...l,n])}}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:!!c,onChange:e=>{if(e.target.checked){let e=a.provider&&a.model?[{provider:a.provider,model:a.model}]:s[0]?[{provider:s[0].provider,model:s[0].model}]:[];e.length&&f({modelPolicy:{allowed:e,strict:!0}})}else o(e=>{let t={...e};return delete t.modelPolicy,t})}}),`Restrict this agent to an explicit model allowlist`]}),c&&(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-medium`,children:`Allowed models`}),(0,R.jsx)(F,{value:l,candidates:s,onChange:h,placeholder:`Add allowed model`,emptyHint:`At least one model is required`})]}),(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-medium`,children:`Ordered fallback chain`}),(0,R.jsx)(F,{value:d,candidates:s,onChange:e=>{let t=[...new Set([...l,...e])];o(n=>({...n,modelPolicy:{allowed:t.map(H),fallbacks:e.map(H),strict:n.modelPolicy?.strict??!0}}))},placeholder:`Add fallback model`,emptyHint:`No fallback; primary failure stops the task`})]})]})]}),(0,R.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[[`tools`,`Tools`,`read_file, search, bash`],[`skillNames`,`Skills`,`security-check, browser`],[`allowedCapabilities`,`Capabilities`,`fs.read, fs.write`]].map(([e,t,n])=>(0,R.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:t}),(0,R.jsx)(`textarea`,{value:U(a[e]),onChange:t=>p(e,t.target.value),placeholder:n,className:`h-20 w-full resize-y rounded border border-border bg-background p-2 font-mono`})]},e))}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsx)(`h4`,{className:`text-xs font-semibold`,children:`Workspace and isolation`}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,R.jsx)(`span`,{children:`Project-relative working directory`}),(0,R.jsx)(`input`,{value:a.cwd??``,onChange:e=>f({cwd:e.target.value||void 0}),placeholder:`packages/webui`,className:`h-8 w-full rounded border border-border bg-background px-2 font-mono`})]}),(0,R.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,R.jsx)(`span`,{children:`Git worktree isolation`}),(0,R.jsxs)(`select`,{value:String(a.worktree??`auto`),onChange:e=>f({worktree:e.target.value}),className:`h-8 w-full rounded border border-border bg-background px-2`,children:[(0,R.jsx)(`option`,{value:`auto`,children:`Automatic`}),(0,R.jsx)(`option`,{value:`required`,children:`Required`}),(0,R.jsx)(`option`,{value:`off`,children:`Off`})]})]})]})]}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsx)(`h4`,{className:`text-xs font-semibold`,children:`Limits`}),(0,R.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:B.map(([e,t])=>(0,R.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,R.jsx)(`span`,{children:t}),(0,R.jsx)(`input`,{type:`number`,min:`0`,step:e===`maxCostUsd`?`0.01`:`1`,value:a.budget?.[e]??``,onChange:t=>m(e,t.target.value),className:`h-8 w-full rounded border border-border bg-background px-2`})]},e))})]}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-xs font-semibold`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:!!a.availability,onChange:e=>{e.target.checked?f({availability:{timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`,days:[1,2,3,4,5],start:`09:00`,end:`18:00`,mode:t?`advisory`:`enforce`}}):o(e=>{let t={...e};return delete t.availability,t})}}),`Working hours`]}),a.availability&&(0,R.jsxs)(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:z.map((e,t)=>(0,R.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px]`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:a.availability?.days.includes(t)??!1,onChange:e=>{let n=a.availability;if(!n)return;let r=e.target.checked?[...new Set([...n.days,t])].sort():n.days.filter(e=>e!==t);f({availability:{...n,days:r}})}}),e]},e))}),(0,R.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-4`,children:[(0,R.jsx)(`input`,{value:a.availability.timezone,onChange:e=>f({availability:{...a.availability,timezone:e.target.value}}),placeholder:`Europe/Kiev`,className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,R.jsx)(`input`,{type:`time`,value:a.availability.start,onChange:e=>f({availability:{...a.availability,start:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,R.jsx)(`input`,{type:`time`,value:a.availability.end,onChange:e=>f({availability:{...a.availability,end:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,R.jsxs)(`select`,{value:t?`advisory`:a.availability.mode??`enforce`,disabled:t,onChange:e=>f({availability:{...a.availability,mode:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`,children:[(0,R.jsx)(`option`,{value:`enforce`,children:`Enforce`}),(0,R.jsx)(`option`,{value:`advisory`,children:`Advisory`})]})]})]})]}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:n||!!(c&&c.allowed.length===0),onClick:()=>r(a),className:`rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50`,children:n?`Saving…`:`Save runtime policy`}),(0,R.jsx)(`button`,{type:`button`,onClick:i,className:`rounded border border-border px-3 py-1.5 text-xs hover:bg-accent`,children:`Cancel`})]})]})}var K=[{id:`live`,icon:(0,R.jsx)(C,{className:`h-4 w-4`}),label:`Live Fleet`},{id:`catalog`,icon:(0,R.jsx)(f,{className:`h-4 w-4`}),label:`Roster Catalog`},{id:`learning`,icon:(0,R.jsx)(d,{className:`h-4 w-4`}),label:`Self-Learning`},{id:`customize`,icon:(0,R.jsx)(w,{className:`h-4 w-4`}),label:`Customization`}],q=[{role:`generic`,name:`Generic Project Agent`,summary:`Flexible template that can be cloned into independently learning project roles.`,tools:0,budget:{maxIterations:2500,maxToolCalls:7500}},{role:`audit-log`,name:`Audit Log`,summary:`Analyzes session logs, event streams, and system traces.`,tools:12,budget:{timeoutMs:108e5,maxIterations:2500,maxToolCalls:7500}},{role:`bug-hunter`,name:`Bug Hunter`,summary:`Scans code for bugs, code smells, and anti-patterns.`,tools:15,budget:{timeoutMs:18e6,maxIterations:4e3,maxToolCalls:1e4}},{role:`refactor-planner`,name:`Refactor Planner`,summary:`Analyzes code structure and produces phased refactoring plans.`,tools:14,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:9e3}},{role:`security-scanner`,name:`Security Scanner`,summary:`Scans code, configs, and dependencies for security issues.`,tools:18,budget:{timeoutMs:18e6,maxIterations:4e3,maxToolCalls:1e4}},{role:`critic`,name:`Critic`,summary:`Evaluates decisions, plans, and implementations.`,tools:10,budget:{timeoutMs:108e5,maxIterations:2e3,maxToolCalls:5e3}},{role:`shadow-agent`,name:`Shadow Agent`,summary:`Background monitoring agent that watches fleet health.`,tools:8,budget:{timeoutMs:36e6,maxIterations:500,maxToolCalls:2e3}},{role:`executor`,name:`Executor`,summary:`General-purpose task executor for delegated work.`,tools:20,budget:{timeoutMs:72e5,maxIterations:1500,maxToolCalls:4e3}},{role:`chimera`,name:`Chimera`,summary:`Post-session code quality review of changed files.`,tools:10,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`researcher`,name:`Researcher`,summary:`Web research and data gathering specialist.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`tech-stack`,name:`Tech Stack Validator`,summary:`Validates package/library/framework choices.`,tools:9,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`orchestrator`,name:`Orchestrator`,summary:`Coordinates multi-agent task execution.`,tools:12,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:8e3}},{role:`supervisor`,name:`Supervisor`,summary:`Oversees subagent execution and handles escalations.`,tools:10,budget:{timeoutMs:144e5,maxIterations:2e3,maxToolCalls:6e3}},{role:`quality-gate`,name:`Quality Gate`,summary:`Enforces quality gates on implementations.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`architect`,name:`Architect`,summary:`Makes design and architecture decisions.`,tools:14,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:8e3}},{role:`prompt-engineer`,name:`Prompt Engineer`,summary:`Designs and optimizes system prompts.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`mnemosyne`,name:`Mnemosyne`,summary:`Memory curator — reviews and maintains SAGE integrity.`,tools:6,budget:{timeoutMs:72e5,maxIterations:500,maxToolCalls:2e3}},{role:`autophase`,name:`AutoPhase`,summary:`Manages multi-phase autonomous task execution.`,tools:10,budget:{timeoutMs:144e5,maxIterations:2e3,maxToolCalls:6e3}}];function J({customStats:e,rosterLoading:t,onRefresh:n}){return(0,R.jsx)(`div`,{className:`shrink-0 border-b border-border/70 bg-card/80 px-4 py-2.5`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-nowrap min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 overflow-hidden`,children:[(0,R.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 shrink-0 rounded-lg bg-primary/10`,children:(0,R.jsx)(E,{className:`h-4 w-4 text-primary`})}),(0,R.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[(0,R.jsx)(`h1`,{className:`text-sm font-semibold truncate`,children:`Agent Roster`}),(0,R.jsxs)(`p`,{className:`text-[10px] text-muted-foreground truncate`,children:[e.filter(e=>e.exists||e.hasIdentity||e.hasConfig||e.hasKnowledge).length,` `,`customized · `,e.reduce((e,t)=>e+t.entryCount,0),` learned entries`]})]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[t&&(0,R.jsx)(s,{className:`h-4 w-4 animate-spin text-muted-foreground shrink-0`}),(0,R.jsxs)(`button`,{type:`button`,onClick:n,className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors shrink-0 whitespace-nowrap`,title:`Refresh roster data`,children:[(0,R.jsx)(_,{className:`h-3 w-3`}),` Refresh`]})]})]})})}function Y({activeTab:e,onTabChange:t}){return(0,R.jsx)(`div`,{className:`shrink-0 border-b border-border/50 bg-muted/20 px-3 flex gap-0`,children:K.map(n=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id),className:A(`flex items-center gap-1.5 px-3 py-2 text-[10px] font-medium border-b-2 transition-colors`,e===n.id?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground hover:border-muted-foreground/30`),children:[n.icon,n.label]},n.id))})}function X({customStats:e,onRefresh:r}){let[i,o]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),[u,p]=(0,L.useState)({}),[m,h]=(0,L.useState)(``),[_,v]=(0,L.useState)(null),[y,S]=(0,L.useState)(!1),[C,w]=(0,L.useState)(!1),[T,E]=(0,L.useState)(null),[D,j]=(0,L.useState)(!1),[N,P]=(0,L.useState)(!1),F=(0,L.useMemo)(()=>[...e].sort((e,t)=>e.role.localeCompare(t.role)),[e]),z=(0,L.useMemo)(()=>i?F.find(e=>e.role===i):null,[i,F]),B=(0,L.useCallback)(async e=>{w(!0),l(null);try{let t=await I(`agent-roster.read-learned`,{role:e});l(t.entries??[]),p({})}catch{}w(!1)},[]),V=(0,L.useCallback)(async()=>{if(!i||!c)return;S(!0);let e=c.filter((e,t)=>u[t]!==`drop`).join(`
|
|
2
2
|
|
|
3
3
|
---
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bi as t,Fn as n,Kn as r,Tt as i,bt as a,et as o,ft as s,ga as c,oi as l,pa as u,ri as d,xa as f,xt as p}from"./vendor-9hC4n4Me.js";import"./i18n-CIqbHugq.js";import{t as m}from"./ws-client-D0KuNwAk.js";import{M as h}from"./stores-nxVpq1NP.js";import{b as g,f as _,p as v}from"./index-Dy7C2V-G.js";var y=e(f(),1),b=o();function x(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function S(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function C(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function w(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function T(e){return e.includes(`error`)||e.includes(`fail`)?`text-destructive`:e.includes(`warn`)?`text-warning`:e.includes(`success`)||e.includes(`complete`)?`text-success`:`text-muted-foreground`}function E({icon:e,label:t,value:n,sub:r,color:i=`text-muted-foreground`}){return(0,b.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsx)(`div`,{className:`mt-0.5 ${i}`,children:e}),(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-2xl font-semibold tabular-nums text-foreground`,children:n}),(0,b.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t}),r?(0,b.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground/70`,children:r}):null]})]})}function D(){let{t:e}=c(),[o,f]=(0,y.useState)(null),[D,O]=(0,y.useState)([]),[k,A]=(0,y.useState)([]),[j,M]=(0,y.useState)(null),[N,P]=(0,y.useState)(!0),[F,I]=(0,y.useState)(!1),L=(0,y.useRef)(null),R=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/analytics/summary`);if(e.ok){let t=await e.json();f(t)}}catch{}},[]),z=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/analytics?limit=50`);if(e.ok){let t=await e.json();O(t.events)}}catch{}},[]),B=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/sessions`);if(e.ok){let t=await e.json();A(t)}}catch{}},[]),V=(0,y.useCallback)(async()=>{if(!F){I(!0);try{let e=m(h.getState().wsUrl);L.current=e;let t=e.on(`stats.get`,e=>{let n=e.payload;M(n),I(!1),t()});e.getStats({echoToChat:!1}),setTimeout(()=>{I(!1),t()},8e3)}catch{I(!1)}}},[F]);(0,y.useEffect)(()=>{let e=()=>{Promise.all([R(),z(),B(),V()]).finally(()=>P(!1))};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[R,z,B,V]);let{totalAgents:H,activeAgents:U,totalToolCalls:W,totalIterations:G}=(0,y.useMemo)(()=>{let e=0,t=0,n=0,r=0;for(let i of k)for(let a of i.agents)e++,a.status===`running`&&t++,n+=a.toolCalls,r+=a.iterations;return{totalAgents:e,activeAgents:t,totalToolCalls:n,totalIterations:r}},[k]),K=(0,y.useMemo)(()=>o?Object.entries(o.categoryBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,8):[],[o]),q=(0,y.useMemo)(()=>o?Object.entries(o.eventBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,10):[],[o]),J=(0,y.useMemo)(()=>{if(!o)return 0;let e=0;for(let[t,n]of Object.entries(o.eventBreakdown))t.toLowerCase().includes(`error`)&&(e+=n);return e},[o]),Y=(0,y.useMemo)(()=>{if(!o)return 0;let e=0;for(let[t,n]of Object.entries(o.eventBreakdown))t.toLowerCase().includes(`warn`)&&(e+=n);return e},[o]),X=v((0,y.useMemo)(()=>[...D].reverse(),[D]),20);return N?(0,b.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,b.jsxs)(`div`,{className:`ws-surface flex items-center gap-2 rounded-xl px-4 py-3 text-sm text-muted-foreground`,children:[(0,b.jsx)(r,{className:`h-4 w-4 animate-spin text-primary`}),e(`activity:analytics.loading`)]})}):(0,b.jsx)(`div`,{ref:g(`analytics`),className:`h-full min-h-0 min-w-0 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,b.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-5`,children:[(0,b.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(t,{className:`h-4 w-4 text-primary`}),(0,b.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:e(`activity:analytics.heading`)})]}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.autoRefresh`)})]})}),(0,b.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3`,children:[(0,b.jsx)(E,{icon:(0,b.jsx)(u,{className:`h-4 w-4`}),label:e(`activity:analytics.liveSessions`),value:k.length,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(s,{className:`h-4 w-4`}),label:e(`activity:analytics.agents`),value:`${U}/${H}`,sub:U>0?e(`activity:analytics.agentsActive`,{count:U}):void 0,color:`text-success`}),(0,b.jsx)(E,{icon:(0,b.jsx)(n,{className:`h-4 w-4`}),label:e(`activity:analytics.totalEvents`),value:o?.totalEvents??0,sub:e(`activity:analytics.categoriesSub`,{count:o?.uniqueCategories??0}),color:`text-warning`}),(0,b.jsx)(E,{icon:(0,b.jsx)(i,{className:`h-4 w-4`}),label:e(`activity:analytics.toolCalls`),value:W,sub:e(`activity:analytics.iterationsSub`,{count:G}),color:`text-success`}),(0,b.jsx)(E,{icon:(0,b.jsx)(d,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionCost`),value:j?C(j.cost):`—`,sub:j?e(`activity:analytics.tokensSub`,{input:S(j.usage.input),output:S(j.usage.output)}):void 0,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(l,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionDuration`),value:j?x(j.elapsedMs):`—`,sub:j?e(`activity:analytics.messagesSub`,{count:j.messages}):void 0,color:`text-muted-foreground`})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(p,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.eventsByCategory`)]}),K.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noEvents`)}):(0,b.jsx)(`div`,{className:`space-y-1.5`,children:K.map(([e,t])=>{let n=K[0]?.[1]??1,r=Math.round(t/n*100);return(0,b.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,7rem)_minmax(0,1fr)_2.5rem] items-center gap-2 text-xs`,children:[(0,b.jsx)(`span`,{className:`min-w-0 truncate text-foreground`,children:e}),(0,b.jsx)(`div`,{className:`h-4 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-primary/70 transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,b.jsx)(`span`,{className:`text-right tabular-nums text-muted-foreground`,children:t})]},e)})})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(t,{className:`h-3.5 w-3.5 text-warning`}),e(`activity:analytics.topEvents`)]}),q.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noEvents`)}):(0,b.jsx)(`div`,{className:`space-y-1.5`,children:q.map(([e,t])=>{let n=q[0]?.[1]??1,r=Math.round(t/n*100);return(0,b.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,9rem)_minmax(0,1fr)_2.5rem] items-center gap-2 text-xs`,children:[(0,b.jsx)(`span`,{className:`min-w-0 truncate ${T(e)}`,children:e}),(0,b.jsx)(`div`,{className:`h-4 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-warning/70 transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,b.jsx)(`span`,{className:`text-right tabular-nums text-muted-foreground`,children:t})]},e)})})]})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(d,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.activeSessionUsage`)]}),j?(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-xs`,children:[(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.provider`)}),(0,b.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-foreground`,children:j.provider})]}),(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.model`)}),(0,b.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-foreground`,children:j.model})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.inputTokens`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:S(j.usage.input)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.outputTokens`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:S(j.usage.output)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.cacheRatio`)}),(0,b.jsxs)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:[(j.cache.ratio*100).toFixed(1),`%`]})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.filesRead`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:j.readFiles})]})]}):(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noSession`)})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(a,{className:`h-3.5 w-3.5 text-warning`}),e(`activity:analytics.healthErrors`)]}),(0,b.jsx)(`div`,{className:`space-y-2 text-xs`,children:o?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.errorEvents`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-destructive`,children:J})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.warningEvents`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-warning`,children:Y})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.cacheHitRate`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-success`,children:j?`${(j.cache.ratio*100).toFixed(1)}%`:`—`})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.totalCategories`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-foreground`,children:o.uniqueCategories})]})]}):(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:e(`activity:analytics.waitingData`)})})]})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(u,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.recentEvents`)]}),D.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noRecentEvents`)}):(0,b.jsx)(`div`,{className:`max-h-64 space-y-1 overflow-y-auto`,children:X.pageItems.map((e,t)=>(0,b.jsxs)(`div`,{className:`grid grid-cols-[4rem_minmax(0,7rem)_minmax(0,6rem)_minmax(0,1fr)] items-start gap-2 rounded px-2 py-1 text-xs hover:bg-muted/60`,children:[(0,b.jsx)(`span`,{className:`tabular-nums text-muted-foreground/70`,children:w(e.timestamp)}),(0,b.jsx)(`span`,{className:`min-w-0 truncate ${T(e.event)}`,children:e.event}),(0,b.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:e.category}),(0,b.jsx)(`span`,{className:`min-w-0 truncate text-foreground/80`,children:e.label??e.sessionId??``})]},`${e.timestamp}-${t}`))}),(0,b.jsx)(_,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,compact:!0,itemLabel:`events`,className:`mt-3 rounded-lg border`})]})]})]})})}export{D as AnalyticsDashboard};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bi as t,Fn as n,Kn as r,Tt as i,bt as a,et as o,ft as s,ga as c,oi as l,pa as u,ri as d,xa as f,xt as p}from"./vendor-9hC4n4Me.js";import"./i18n-C2VyJ0Kz.js";import{t as m}from"./ws-client-eyEv8wbm.js";import{M as h}from"./stores-hEu6z1qz.js";import{b as g,f as _,p as v}from"./index-DSXHr5yP.js";var y=e(f(),1),b=o();function x(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function S(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function C(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function w(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function T(e){return e.includes(`error`)||e.includes(`fail`)?`text-destructive`:e.includes(`warn`)?`text-warning`:e.includes(`success`)||e.includes(`complete`)?`text-success`:`text-muted-foreground`}function E({icon:e,label:t,value:n,sub:r,color:i=`text-muted-foreground`}){return(0,b.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsx)(`div`,{className:`mt-0.5 ${i}`,children:e}),(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-2xl font-semibold tabular-nums text-foreground`,children:n}),(0,b.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t}),r?(0,b.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground/70`,children:r}):null]})]})}function D(){let{t:e}=c(),[o,f]=(0,y.useState)(null),[D,O]=(0,y.useState)([]),[k,A]=(0,y.useState)([]),[j,M]=(0,y.useState)(null),[N,P]=(0,y.useState)(!0),[F,I]=(0,y.useState)(!1),L=(0,y.useRef)(null),R=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/analytics/summary`);if(e.ok){let t=await e.json();f(t)}}catch{}},[]),z=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/analytics?limit=50`);if(e.ok){let t=await e.json();O(t.events)}}catch{}},[]),B=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/sessions`);if(e.ok){let t=await e.json();A(t)}}catch{}},[]),V=(0,y.useCallback)(async()=>{if(!F){I(!0);try{let e=m(h.getState().wsUrl);L.current=e;let t=e.on(`stats.get`,e=>{let n=e.payload;M(n),I(!1),t()});e.getStats({echoToChat:!1}),setTimeout(()=>{I(!1),t()},8e3)}catch{I(!1)}}},[F]);(0,y.useEffect)(()=>{let e=()=>{Promise.all([R(),z(),B(),V()]).finally(()=>P(!1))};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[R,z,B,V]);let{totalAgents:H,activeAgents:U,totalToolCalls:W,totalIterations:G}=(0,y.useMemo)(()=>{let e=0,t=0,n=0,r=0;for(let i of k)for(let a of i.agents)e++,a.status===`running`&&t++,n+=a.toolCalls,r+=a.iterations;return{totalAgents:e,activeAgents:t,totalToolCalls:n,totalIterations:r}},[k]),K=(0,y.useMemo)(()=>o?Object.entries(o.categoryBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,8):[],[o]),q=(0,y.useMemo)(()=>o?Object.entries(o.eventBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,10):[],[o]),J=(0,y.useMemo)(()=>{if(!o)return 0;let e=0;for(let[t,n]of Object.entries(o.eventBreakdown))t.toLowerCase().includes(`error`)&&(e+=n);return e},[o]),Y=(0,y.useMemo)(()=>{if(!o)return 0;let e=0;for(let[t,n]of Object.entries(o.eventBreakdown))t.toLowerCase().includes(`warn`)&&(e+=n);return e},[o]),X=v((0,y.useMemo)(()=>[...D].reverse(),[D]),20);return N?(0,b.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,b.jsxs)(`div`,{className:`ws-surface flex items-center gap-2 rounded-xl px-4 py-3 text-sm text-muted-foreground`,children:[(0,b.jsx)(r,{className:`h-4 w-4 animate-spin text-primary`}),e(`activity:analytics.loading`)]})}):(0,b.jsx)(`div`,{ref:g(`analytics`),className:`h-full min-h-0 min-w-0 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,b.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-5`,children:[(0,b.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(t,{className:`h-4 w-4 text-primary`}),(0,b.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:e(`activity:analytics.heading`)})]}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.autoRefresh`)})]})}),(0,b.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3`,children:[(0,b.jsx)(E,{icon:(0,b.jsx)(u,{className:`h-4 w-4`}),label:e(`activity:analytics.liveSessions`),value:k.length,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(s,{className:`h-4 w-4`}),label:e(`activity:analytics.agents`),value:`${U}/${H}`,sub:U>0?e(`activity:analytics.agentsActive`,{count:U}):void 0,color:`text-success`}),(0,b.jsx)(E,{icon:(0,b.jsx)(n,{className:`h-4 w-4`}),label:e(`activity:analytics.totalEvents`),value:o?.totalEvents??0,sub:e(`activity:analytics.categoriesSub`,{count:o?.uniqueCategories??0}),color:`text-warning`}),(0,b.jsx)(E,{icon:(0,b.jsx)(i,{className:`h-4 w-4`}),label:e(`activity:analytics.toolCalls`),value:W,sub:e(`activity:analytics.iterationsSub`,{count:G}),color:`text-success`}),(0,b.jsx)(E,{icon:(0,b.jsx)(d,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionCost`),value:j?C(j.cost):`—`,sub:j?e(`activity:analytics.tokensSub`,{input:S(j.usage.input),output:S(j.usage.output)}):void 0,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(l,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionDuration`),value:j?x(j.elapsedMs):`—`,sub:j?e(`activity:analytics.messagesSub`,{count:j.messages}):void 0,color:`text-muted-foreground`})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(p,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.eventsByCategory`)]}),K.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noEvents`)}):(0,b.jsx)(`div`,{className:`space-y-1.5`,children:K.map(([e,t])=>{let n=K[0]?.[1]??1,r=Math.round(t/n*100);return(0,b.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,7rem)_minmax(0,1fr)_2.5rem] items-center gap-2 text-xs`,children:[(0,b.jsx)(`span`,{className:`min-w-0 truncate text-foreground`,children:e}),(0,b.jsx)(`div`,{className:`h-4 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-primary/70 transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,b.jsx)(`span`,{className:`text-right tabular-nums text-muted-foreground`,children:t})]},e)})})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(t,{className:`h-3.5 w-3.5 text-warning`}),e(`activity:analytics.topEvents`)]}),q.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noEvents`)}):(0,b.jsx)(`div`,{className:`space-y-1.5`,children:q.map(([e,t])=>{let n=q[0]?.[1]??1,r=Math.round(t/n*100);return(0,b.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,9rem)_minmax(0,1fr)_2.5rem] items-center gap-2 text-xs`,children:[(0,b.jsx)(`span`,{className:`min-w-0 truncate ${T(e)}`,children:e}),(0,b.jsx)(`div`,{className:`h-4 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-warning/70 transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,b.jsx)(`span`,{className:`text-right tabular-nums text-muted-foreground`,children:t})]},e)})})]})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(d,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.activeSessionUsage`)]}),j?(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-xs`,children:[(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.provider`)}),(0,b.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-foreground`,children:j.provider})]}),(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.model`)}),(0,b.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-foreground`,children:j.model})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.inputTokens`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:S(j.usage.input)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.outputTokens`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:S(j.usage.output)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.cacheRatio`)}),(0,b.jsxs)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:[(j.cache.ratio*100).toFixed(1),`%`]})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.filesRead`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:j.readFiles})]})]}):(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noSession`)})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(a,{className:`h-3.5 w-3.5 text-warning`}),e(`activity:analytics.healthErrors`)]}),(0,b.jsx)(`div`,{className:`space-y-2 text-xs`,children:o?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.errorEvents`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-destructive`,children:J})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.warningEvents`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-warning`,children:Y})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.cacheHitRate`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-success`,children:j?`${(j.cache.ratio*100).toFixed(1)}%`:`—`})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.totalCategories`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-foreground`,children:o.uniqueCategories})]})]}):(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:e(`activity:analytics.waitingData`)})})]})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(u,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.recentEvents`)]}),D.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noRecentEvents`)}):(0,b.jsx)(`div`,{className:`max-h-64 space-y-1 overflow-y-auto`,children:X.pageItems.map((e,t)=>(0,b.jsxs)(`div`,{className:`grid grid-cols-[4rem_minmax(0,7rem)_minmax(0,6rem)_minmax(0,1fr)] items-start gap-2 rounded px-2 py-1 text-xs hover:bg-muted/60`,children:[(0,b.jsx)(`span`,{className:`tabular-nums text-muted-foreground/70`,children:w(e.timestamp)}),(0,b.jsx)(`span`,{className:`min-w-0 truncate ${T(e.event)}`,children:e.event}),(0,b.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:e.category}),(0,b.jsx)(`span`,{className:`min-w-0 truncate text-foreground/80`,children:e.label??e.sessionId??``})]},`${e.timestamp}-${t}`))}),(0,b.jsx)(_,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,compact:!0,itemLabel:`events`,className:`mt-3 rounded-lg border`})]})]})]})})}export{D as AnalyticsDashboard};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ct as t,Dt as n,Ht as r,Zt as i,at as a,cn as o,et as s,ni as c,pn as l,vt as u,wr as d,xa as f}from"./vendor-9hC4n4Me.js";import{t as p}from"./useWebSocket-DLQNx26C.js";import{t as m}from"./utils-DzRQUvln.js";import{a as h,i as g,n as _,o as v,r as y,t as b}from"./dialog-BLr7olIX.js";import{t as x}from"./button-Bmh1yFe5.js";import{t as S}from"./input-BRS2rHSR.js";import{f as C,p as w}from"./index-Dy7C2V-G.js";import{g as T,i as E,r as D,y as O}from"./shared-DYL4K3aB.js";var k=e(f(),1),A=s();function j(e){if(!Array.isArray(e))return;let t=[...new Set(e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean))];return t.length>0?t:void 0}function M(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n={roles:j(t.roles),taskTypes:j(t.taskTypes),modes:j(t.modes)};return n.roles||n.taskTypes||n.modes?n:void 0}function N(e){let t=e.trim().replace(/^```(?:json)?\s*/i,``).replace(/\s*```$/,``),n=JSON.parse(t);if(!Array.isArray(n))throw Error(`Input must be a JSON array.`);let r=[],i=0;for(let e of n){if(!e||typeof e!=`object`||Array.isArray(e)){i++;continue}let t=e,n=typeof t.text==`string`?t.text.trim():``,a=M(t.audience);if(!n||!a){i++;continue}let o=typeof t.kind==`string`&&E.some(e=>e===t.kind)?t.kind:void 0,s=j(t.tags);r.push({text:n,audience:a,kind:o,tags:s,importance:typeof t.importance==`number`?t.importance:void 0,confidence:typeof t.confidence==`number`?t.confidence:void 0})}return{entries:r,skipped:i}}function P(e,t){if(!t)return!0;let n=e.audience;return[e.text,e.kind,e.status,...n?.roles??[],...n?.taskTypes??[],...n?.modes??[]].join(` `).toLocaleLowerCase().includes(t.toLocaleLowerCase())}function F(e,t){return[...new Set(e.flatMap(e=>e.audience?.[t]??[]).filter(e=>e.length>0))].sort((e,t)=>e.localeCompare(t))}function I(){let e=p(),[r,s]=(0,k.useState)([]),[f,E]=(0,k.useState)(!0),[D,O]=(0,k.useState)(null),[j,M]=(0,k.useState)(``),[I,z]=(0,k.useState)(!1),[B,V]=(0,k.useState)(!1),[H,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(!1),[K,q]=(0,k.useState)(!1),J=(0,k.useRef)(null),Y=(0,k.useCallback)(()=>{E(!0),O(null),e.listSageMemories({echoToChat:!1})},[e.listSageMemories]);(0,k.useEffect)(()=>{let t=e.client,n=t.on(`memory.sage.list`,e=>{let t=e.payload;t.error?O({tone:`error`,text:t.error}):s(t.memories??[]),E(!1)}),r=t.on(`memory.sage.remember`,e=>{let t=e.payload;if(G(!1),t.error){O({tone:`error`,text:t.error});return}t.memory&&(s(e=>[t.memory,...e.filter(e=>e.id!==t.memory.id)]),z(!1))}),i=t.on(`memory.sage.update`,e=>{let t=e.payload;t.error?O({tone:`error`,text:t.error}):t.memory&&(s(e=>e.map(e=>e.id===t.memory.id?t.memory:e)),t.memory.audience||O({tone:`success`,text:`Audience scope removed. The memory is now general.`}))}),a=t.on(`memory.sage.delete`,e=>{let t=e.payload,n=J.current;t.success&&n?(s(e=>e.filter(e=>e.id!==n)),O({tone:`success`,text:`Audience memory deleted.`}),U(null),q(!1),J.current=null):t.success?Y():(O({tone:`error`,text:t.message??`Could not delete the memory.`}),q(!1),J.current=null)});return Y(),()=>{n(),r(),i(),a()}},[Y,e.client]);let X=(0,k.useMemo)(()=>r.filter(e=>{let t=e.audience;return!!(t&&(t.roles?.length||t.taskTypes?.length||t.modes?.length))}),[r]),Z=j.trim(),Q=(0,k.useMemo)(()=>X.filter(e=>P(e,Z)),[Z,X]),$=w(Q,16,Z),ie=(0,k.useMemo)(()=>F(X,`roles`),[X]),ae=(0,k.useMemo)(()=>F(X,`taskTypes`),[X]),oe=(0,k.useMemo)(()=>F(X,`modes`),[X]),se=t=>{O(null),e.updateSage(t,{audience:void 0},{echoToChat:!1})},ce=()=>{H&&(J.current=H,q(!0),O(null),e.deleteSage(H,`Removed from the audience memory panel.`))},le=async()=>{let e=X.map(e=>({id:e.id,text:e.text,kind:e.kind,status:e.status,audience:e.audience,tags:e.tags,importance:e.importance,confidence:e.confidence}));try{if(!navigator.clipboard)throw Error(`Clipboard access is unavailable.`);await navigator.clipboard.writeText(JSON.stringify(e,null,2)),O({tone:`success`,text:`${e.length} audience memor${e.length===1?`y`:`ies`} copied as JSON.`})}catch(e){O({tone:`error`,text:e instanceof Error?e.message:`Failed to copy JSON to the clipboard.`})}};return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-card/20`,"aria-labelledby":`audience-memory-title`,children:[(0,A.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 p-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,A.jsx)(`div`,{className:`min-w-0`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,A.jsx)(n,{className:`size-3.5`})}),(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h2`,{id:`audience-memory-title`,className:`truncate text-sm font-semibold`,children:`Audience Memory`}),(0,A.jsx)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:`Guidance routed to matching agents`})]})]})}),(0,A.jsxs)(x,{variant:`default`,size:`sm`,className:`h-7 shrink-0 gap-1 px-2 text-xs`,onClick:()=>z(!0),children:[(0,A.jsx)(l,{className:`size-3`}),`Add`]})]}),(0,A.jsxs)(`div`,{className:`mt-3 grid grid-cols-4 gap-px overflow-hidden rounded-md border border-border/60 bg-border/60`,children:[(0,A.jsx)(L,{value:X.length,label:`Memories`}),(0,A.jsx)(L,{value:ie.length,label:`Roles`}),(0,A.jsx)(L,{value:ae.length,label:`Tasks`}),(0,A.jsx)(L,{value:oe.length,label:`Modes`})]}),(0,A.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,A.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,A.jsx)(i,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,A.jsx)(S,{value:j,onChange:e=>M(e.target.value),placeholder:`Search text, role, task or mode…`,"aria-label":`Search audience memories`,className:`h-8 pl-8 pr-8 text-xs`}),j&&(0,A.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:text-foreground`,onClick:()=>M(``),"aria-label":`Clear audience memory search`,children:(0,A.jsx)(a,{className:`size-3`})})]}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:Y,"aria-label":`Refresh audience memories`,title:`Refresh`,children:(0,A.jsx)(o,{className:m(`size-3.5`,f&&`animate-spin`)})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>V(!0),"aria-label":`Import audience memories`,title:`Import JSON`,children:(0,A.jsx)(u,{className:`size-3.5`})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>void le(),"aria-label":`Copy audience memories as JSON`,title:`Copy JSON`,disabled:X.length===0,children:(0,A.jsx)(c,{className:`size-3.5`})})]})]}),D&&(0,A.jsxs)(`div`,{role:D.tone===`error`?`alert`:`status`,className:m(`mx-3 mt-3 flex shrink-0 items-start justify-between gap-2 rounded-md border px-2.5 py-2 text-[11px]`,D.tone===`error`?`border-destructive/30 bg-destructive/5 text-destructive`:`border-success/30 bg-success/5 text-success`),children:[(0,A.jsx)(`span`,{children:D.text}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>O(null),className:`shrink-0 rounded-sm opacity-70 hover:opacity-100`,"aria-label":`Dismiss message`,children:(0,A.jsx)(a,{className:`size-3`})})]}),(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[!f&&X.length>0&&(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-3 pb-1.5 pt-3 text-[10px] text-muted-foreground`,children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(d,{className:`size-3`}),Z?`${Q.length} of ${X.length}`:`${X.length} scoped`]}),Z&&(0,A.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,onClick:()=>M(``),children:`Clear filter`})]}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[f?(0,A.jsx)(ee,{}):X.length===0?(0,A.jsx)(te,{onAdd:()=>z(!0)}):Q.length===0?(0,A.jsxs)(`div`,{className:`flex h-full min-h-32 flex-col items-center justify-center px-4 text-center`,children:[(0,A.jsx)(i,{className:`mb-2 size-5 text-muted-foreground/60`}),(0,A.jsx)(`p`,{className:`text-xs font-medium`,children:`No matching memories`}),(0,A.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Try another role, task, mode, or phrase.`}),(0,A.jsx)(x,{variant:`ghost`,size:`sm`,className:`mt-2 h-7 text-xs`,onClick:()=>M(``),children:`Clear search`})]}):(0,A.jsx)(`ul`,{className:`space-y-2`,children:$.pageItems.map(e=>(0,A.jsx)(R,{memory:e,onFilter:M,onClearScope:()=>se(e.id),onDelete:()=>U(e.id)},e.id))}),(0,A.jsx)(C,{page:$.page,pageSize:$.pageSize,totalItems:$.totalItems,onPageChange:$.setPage,compact:!0,itemLabel:`memories`})]})]})]}),(0,A.jsx)(ne,{open:I,busy:W,onOpenChange:e=>{W||z(e)},onCreate:t=>{O(null),G(!0),e.rememberSage({text:t.text,kind:t.kind,audience:{roles:t.roles.length>0?t.roles:void 0,taskTypes:t.taskTypes.length>0?t.taskTypes:void 0,modes:t.modes.length>0?t.modes:void 0}},{echoToChat:!1})}}),(0,A.jsx)(re,{open:B,onOpenChange:V,onImport:t=>{try{let{entries:n,skipped:r}=N(t);if(n.length===0)return O({tone:`error`,text:`No valid audience-scoped memories were found in the JSON.`}),!1;for(let t of n)e.rememberSage(t,{echoToChat:!1});return O({tone:`success`,text:`${n.length} memor${n.length===1?`y`:`ies`} queued for import${r?`; ${r} invalid ${r===1?`entry was`:`entries were`} skipped`:``}.`}),V(!1),!0}catch(e){return O({tone:`error`,text:e instanceof Error?e.message:`Invalid JSON.`}),!1}}}),(0,A.jsx)(b,{open:!!H,onOpenChange:e=>{!e&&!K&&U(null)},children:(0,A.jsxs)(_,{className:`max-w-md`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Delete this audience memory?`}),(0,A.jsx)(y,{children:`This removes the memory from active use. To keep it as general project guidance, cancel and use the un-scope action instead.`})]}),(0,A.jsx)(`div`,{className:`rounded-md border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:T(r.find(e=>e.id===H)?.text??``,180)}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>U(null),disabled:K,children:`Cancel`}),(0,A.jsxs)(x,{variant:`destructive`,onClick:ce,disabled:K,children:[(0,A.jsx)(t,{className:`size-4`}),K?`Deleting…`:`Delete memory`]})]})]})})]})}function L({value:e,label:t}){return(0,A.jsxs)(`div`,{className:`bg-card/95 px-1.5 py-2 text-center`,children:[(0,A.jsx)(`p`,{className:`text-sm font-semibold tabular-nums`,children:e}),(0,A.jsx)(`p`,{className:`truncate text-[9px] uppercase tracking-wide text-muted-foreground`,children:t})]})}function R({memory:e,onFilter:n,onClearScope:i,onDelete:a}){return(0,A.jsxs)(`li`,{className:`group rounded-md border border-border/65 bg-card/55 p-2.5 transition-colors hover:border-border hover:bg-card/85`,children:[(0,A.jsx)(`p`,{className:`break-words text-xs leading-5`,children:e.text}),e.audience&&(0,A.jsx)(z,{audience:e.audience,onFilter:n}),(0,A.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 border-t border-border/45 pt-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[9px] uppercase tracking-wide text-muted-foreground`,children:[(0,A.jsx)(`span`,{className:`truncate`,children:D[e.kind]??e.kind}),(0,A.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,A.jsx)(`span`,{children:e.status})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:i,"aria-label":`Remove audience scope from ${T(e.text,42)}`,title:`Make general memory`,children:(0,A.jsx)(r,{className:`size-3`})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6 text-destructive hover:text-destructive`,onClick:a,"aria-label":`Delete ${T(e.text,42)}`,title:`Delete`,children:(0,A.jsx)(t,{className:`size-3`})})]})]})]})}function z({audience:e,onFilter:t}){return(0,A.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[...(e.roles??[]).map(e=>({label:`role`,value:e})),...(e.taskTypes??[]).map(e=>({label:`task`,value:e})),...(e.modes??[]).map(e=>({label:`mode`,value:e}))].map(({label:e,value:n})=>(0,A.jsxs)(`button`,{type:`button`,className:`max-w-full truncate rounded border border-primary/15 bg-primary/7 px-1.5 py-0.5 font-mono text-[9px] text-primary/90 transition-colors hover:border-primary/35 hover:bg-primary/12`,onClick:()=>t(n),title:`Filter by ${e}: ${n}`,children:[e,`:`,n]},`${e}:${n}`))})}function ee(){return(0,A.jsx)(`div`,{className:`space-y-2 pt-3`,role:`status`,"aria-label":`Loading audience memories`,children:[0,1,2].map(e=>(0,A.jsxs)(`div`,{className:`animate-pulse rounded-md border border-border/50 p-3`,children:[(0,A.jsx)(`div`,{className:`h-2.5 w-full rounded bg-muted`}),(0,A.jsx)(`div`,{className:`mt-2 h-2.5 w-2/3 rounded bg-muted`}),(0,A.jsx)(`div`,{className:`mt-3 h-4 w-24 rounded bg-muted`})]},e))})}function te({onAdd:e}){return(0,A.jsxs)(`div`,{className:`flex h-full min-h-44 flex-col items-center justify-center px-5 text-center`,children:[(0,A.jsx)(`span`,{className:`mb-3 flex size-10 items-center justify-center rounded-full border border-dashed border-primary/35 bg-primary/5 text-primary`,children:(0,A.jsx)(n,{className:`size-4`})}),(0,A.jsx)(`p`,{className:`text-xs font-medium`,children:`Route guidance to the right agents`}),(0,A.jsx)(`p`,{className:`mt-1 max-w-52 text-[10px] leading-4 text-muted-foreground`,children:`Scope a memory by role, task type, or operating mode. Matching agents receive it automatically.`}),(0,A.jsxs)(x,{variant:`outline`,size:`sm`,className:`mt-3 h-7 gap-1 text-xs`,onClick:e,children:[(0,A.jsx)(l,{className:`size-3`}),`Add scoped memory`]})]})}function ne({open:e,busy:t,onOpenChange:n,onCreate:r}){let[i,a]=(0,k.useState)(``),[o,s]=(0,k.useState)(`workflow`),[c,l]=(0,k.useState)(``),[u,d]=(0,k.useState)(``),[f,p]=(0,k.useState)(``);(0,k.useEffect)(()=>{e||(a(``),s(`workflow`),l(``),d(``),p(``))},[e]);let m=O(c),S=O(u),C=O(f),w=i.trim().length>0&&(m.length>0||S.length>0||C.length>0);return(0,A.jsx)(b,{open:e,onOpenChange:n,children:(0,A.jsxs)(_,{className:`max-w-xl`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Add audience-scoped memory`}),(0,A.jsx)(y,{children:`This guidance is injected only when an agent matches at least one supplied selector.`})]}),(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-text`,className:`mb-1.5 block text-xs font-medium`,children:`Memory`}),(0,A.jsx)(`textarea`,{id:`audience-memory-text`,value:i,onChange:e=>a(e.target.value),placeholder:`What should matching agents remember?`,rows:4,autoFocus:!0,className:`w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-kind`,className:`mb-1.5 block text-xs font-medium`,children:`Kind`}),(0,A.jsx)(`select`,{id:`audience-memory-kind`,value:o,onChange:e=>s(e.target.value),className:`h-9 w-full rounded-md border border-input bg-background px-3 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:E.map(e=>(0,A.jsx)(`option`,{value:e,children:D[e]??e},e))})]}),(0,A.jsxs)(`fieldset`,{className:`space-y-3 rounded-md border border-border/70 bg-background/35 p-3`,children:[(0,A.jsx)(`legend`,{className:`px-1 text-xs font-medium`,children:`Audience selectors`}),(0,A.jsx)(B,{id:`audience-memory-roles`,label:`Roles`,value:c,onChange:l,placeholder:`reviewer, refactor-planner`}),(0,A.jsx)(B,{id:`audience-memory-task-types`,label:`Task types`,value:u,onChange:d,placeholder:`review, refactor, bugfix`}),(0,A.jsx)(B,{id:`audience-memory-modes`,label:`Modes`,value:f,onChange:p,placeholder:`teach, code-review`}),(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Comma-separate multiple values. At least one selector is required.`})]})]}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>n(!1),disabled:t,children:`Cancel`}),(0,A.jsx)(x,{onClick:()=>r({text:i.trim(),kind:o,roles:m,taskTypes:S,modes:C}),disabled:!w||t,children:t?`Remembering…`:`Remember`})]})]})})}function B({id:e,label:t,value:n,placeholder:r,onChange:i}){return(0,A.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[6rem_1fr] sm:items-center`,children:[(0,A.jsx)(`label`,{htmlFor:e,className:`text-[11px] font-medium text-muted-foreground`,children:t}),(0,A.jsx)(S,{id:e,value:n,onChange:e=>i(e.target.value),placeholder:r,className:`h-8 font-mono text-xs`})]})}function re({open:e,onOpenChange:t,onImport:n}){let[r,i]=(0,k.useState)(``);return(0,k.useEffect)(()=>{e||i(``)},[e]),(0,A.jsx)(b,{open:e,onOpenChange:t,children:(0,A.jsxs)(_,{className:`max-w-xl`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Import audience memories`}),(0,A.jsxs)(y,{children:[`Paste the JSON produced here or by `,(0,A.jsx)(`code`,{children:`/memory audience export`}),`. Entries without a valid audience selector are skipped.`]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-import`,className:`mb-1.5 block text-xs font-medium`,children:`JSON array`}),(0,A.jsx)(`textarea`,{id:`audience-memory-import`,value:r,onChange:e=>i(e.target.value),placeholder:`[
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ct as t,Dt as n,Ht as r,Zt as i,at as a,cn as o,et as s,ni as c,pn as l,vt as u,wr as d,xa as f}from"./vendor-9hC4n4Me.js";import{t as p}from"./useWebSocket-Ba38Sknk.js";import{t as m}from"./utils-DzRQUvln.js";import{a as h,i as g,n as _,o as v,r as y,t as b}from"./dialog-BLr7olIX.js";import{t as x}from"./button-Bmh1yFe5.js";import{t as S}from"./input-BRS2rHSR.js";import{f as C,p as w}from"./index-DSXHr5yP.js";import{g as T,i as E,r as D,y as O}from"./shared-DYL4K3aB.js";var k=e(f(),1),A=s();function j(e){if(!Array.isArray(e))return;let t=[...new Set(e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean))];return t.length>0?t:void 0}function M(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n={roles:j(t.roles),taskTypes:j(t.taskTypes),modes:j(t.modes)};return n.roles||n.taskTypes||n.modes?n:void 0}function N(e){let t=e.trim().replace(/^```(?:json)?\s*/i,``).replace(/\s*```$/,``),n=JSON.parse(t);if(!Array.isArray(n))throw Error(`Input must be a JSON array.`);let r=[],i=0;for(let e of n){if(!e||typeof e!=`object`||Array.isArray(e)){i++;continue}let t=e,n=typeof t.text==`string`?t.text.trim():``,a=M(t.audience);if(!n||!a){i++;continue}let o=typeof t.kind==`string`&&E.some(e=>e===t.kind)?t.kind:void 0,s=j(t.tags);r.push({text:n,audience:a,kind:o,tags:s,importance:typeof t.importance==`number`?t.importance:void 0,confidence:typeof t.confidence==`number`?t.confidence:void 0})}return{entries:r,skipped:i}}function P(e,t){if(!t)return!0;let n=e.audience;return[e.text,e.kind,e.status,...n?.roles??[],...n?.taskTypes??[],...n?.modes??[]].join(` `).toLocaleLowerCase().includes(t.toLocaleLowerCase())}function F(e,t){return[...new Set(e.flatMap(e=>e.audience?.[t]??[]).filter(e=>e.length>0))].sort((e,t)=>e.localeCompare(t))}function I(){let e=p(),[r,s]=(0,k.useState)([]),[f,E]=(0,k.useState)(!0),[D,O]=(0,k.useState)(null),[j,M]=(0,k.useState)(``),[I,z]=(0,k.useState)(!1),[B,V]=(0,k.useState)(!1),[H,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(!1),[K,q]=(0,k.useState)(!1),J=(0,k.useRef)(null),Y=(0,k.useCallback)(()=>{E(!0),O(null),e.listSageMemories({echoToChat:!1})},[e.listSageMemories]);(0,k.useEffect)(()=>{let t=e.client,n=t.on(`memory.sage.list`,e=>{let t=e.payload;t.error?O({tone:`error`,text:t.error}):s(t.memories??[]),E(!1)}),r=t.on(`memory.sage.remember`,e=>{let t=e.payload;if(G(!1),t.error){O({tone:`error`,text:t.error});return}t.memory&&(s(e=>[t.memory,...e.filter(e=>e.id!==t.memory.id)]),z(!1))}),i=t.on(`memory.sage.update`,e=>{let t=e.payload;t.error?O({tone:`error`,text:t.error}):t.memory&&(s(e=>e.map(e=>e.id===t.memory.id?t.memory:e)),t.memory.audience||O({tone:`success`,text:`Audience scope removed. The memory is now general.`}))}),a=t.on(`memory.sage.delete`,e=>{let t=e.payload,n=J.current;t.success&&n?(s(e=>e.filter(e=>e.id!==n)),O({tone:`success`,text:`Audience memory deleted.`}),U(null),q(!1),J.current=null):t.success?Y():(O({tone:`error`,text:t.message??`Could not delete the memory.`}),q(!1),J.current=null)});return Y(),()=>{n(),r(),i(),a()}},[Y,e.client]);let X=(0,k.useMemo)(()=>r.filter(e=>{let t=e.audience;return!!(t&&(t.roles?.length||t.taskTypes?.length||t.modes?.length))}),[r]),Z=j.trim(),Q=(0,k.useMemo)(()=>X.filter(e=>P(e,Z)),[Z,X]),$=w(Q,16,Z),ie=(0,k.useMemo)(()=>F(X,`roles`),[X]),ae=(0,k.useMemo)(()=>F(X,`taskTypes`),[X]),oe=(0,k.useMemo)(()=>F(X,`modes`),[X]),se=t=>{O(null),e.updateSage(t,{audience:void 0},{echoToChat:!1})},ce=()=>{H&&(J.current=H,q(!0),O(null),e.deleteSage(H,`Removed from the audience memory panel.`))},le=async()=>{let e=X.map(e=>({id:e.id,text:e.text,kind:e.kind,status:e.status,audience:e.audience,tags:e.tags,importance:e.importance,confidence:e.confidence}));try{if(!navigator.clipboard)throw Error(`Clipboard access is unavailable.`);await navigator.clipboard.writeText(JSON.stringify(e,null,2)),O({tone:`success`,text:`${e.length} audience memor${e.length===1?`y`:`ies`} copied as JSON.`})}catch(e){O({tone:`error`,text:e instanceof Error?e.message:`Failed to copy JSON to the clipboard.`})}};return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-card/20`,"aria-labelledby":`audience-memory-title`,children:[(0,A.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 p-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,A.jsx)(`div`,{className:`min-w-0`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,A.jsx)(n,{className:`size-3.5`})}),(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h2`,{id:`audience-memory-title`,className:`truncate text-sm font-semibold`,children:`Audience Memory`}),(0,A.jsx)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:`Guidance routed to matching agents`})]})]})}),(0,A.jsxs)(x,{variant:`default`,size:`sm`,className:`h-7 shrink-0 gap-1 px-2 text-xs`,onClick:()=>z(!0),children:[(0,A.jsx)(l,{className:`size-3`}),`Add`]})]}),(0,A.jsxs)(`div`,{className:`mt-3 grid grid-cols-4 gap-px overflow-hidden rounded-md border border-border/60 bg-border/60`,children:[(0,A.jsx)(L,{value:X.length,label:`Memories`}),(0,A.jsx)(L,{value:ie.length,label:`Roles`}),(0,A.jsx)(L,{value:ae.length,label:`Tasks`}),(0,A.jsx)(L,{value:oe.length,label:`Modes`})]}),(0,A.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,A.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,A.jsx)(i,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,A.jsx)(S,{value:j,onChange:e=>M(e.target.value),placeholder:`Search text, role, task or mode…`,"aria-label":`Search audience memories`,className:`h-8 pl-8 pr-8 text-xs`}),j&&(0,A.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:text-foreground`,onClick:()=>M(``),"aria-label":`Clear audience memory search`,children:(0,A.jsx)(a,{className:`size-3`})})]}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:Y,"aria-label":`Refresh audience memories`,title:`Refresh`,children:(0,A.jsx)(o,{className:m(`size-3.5`,f&&`animate-spin`)})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>V(!0),"aria-label":`Import audience memories`,title:`Import JSON`,children:(0,A.jsx)(u,{className:`size-3.5`})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>void le(),"aria-label":`Copy audience memories as JSON`,title:`Copy JSON`,disabled:X.length===0,children:(0,A.jsx)(c,{className:`size-3.5`})})]})]}),D&&(0,A.jsxs)(`div`,{role:D.tone===`error`?`alert`:`status`,className:m(`mx-3 mt-3 flex shrink-0 items-start justify-between gap-2 rounded-md border px-2.5 py-2 text-[11px]`,D.tone===`error`?`border-destructive/30 bg-destructive/5 text-destructive`:`border-success/30 bg-success/5 text-success`),children:[(0,A.jsx)(`span`,{children:D.text}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>O(null),className:`shrink-0 rounded-sm opacity-70 hover:opacity-100`,"aria-label":`Dismiss message`,children:(0,A.jsx)(a,{className:`size-3`})})]}),(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[!f&&X.length>0&&(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-3 pb-1.5 pt-3 text-[10px] text-muted-foreground`,children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(d,{className:`size-3`}),Z?`${Q.length} of ${X.length}`:`${X.length} scoped`]}),Z&&(0,A.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,onClick:()=>M(``),children:`Clear filter`})]}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[f?(0,A.jsx)(ee,{}):X.length===0?(0,A.jsx)(te,{onAdd:()=>z(!0)}):Q.length===0?(0,A.jsxs)(`div`,{className:`flex h-full min-h-32 flex-col items-center justify-center px-4 text-center`,children:[(0,A.jsx)(i,{className:`mb-2 size-5 text-muted-foreground/60`}),(0,A.jsx)(`p`,{className:`text-xs font-medium`,children:`No matching memories`}),(0,A.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Try another role, task, mode, or phrase.`}),(0,A.jsx)(x,{variant:`ghost`,size:`sm`,className:`mt-2 h-7 text-xs`,onClick:()=>M(``),children:`Clear search`})]}):(0,A.jsx)(`ul`,{className:`space-y-2`,children:$.pageItems.map(e=>(0,A.jsx)(R,{memory:e,onFilter:M,onClearScope:()=>se(e.id),onDelete:()=>U(e.id)},e.id))}),(0,A.jsx)(C,{page:$.page,pageSize:$.pageSize,totalItems:$.totalItems,onPageChange:$.setPage,compact:!0,itemLabel:`memories`})]})]})]}),(0,A.jsx)(ne,{open:I,busy:W,onOpenChange:e=>{W||z(e)},onCreate:t=>{O(null),G(!0),e.rememberSage({text:t.text,kind:t.kind,audience:{roles:t.roles.length>0?t.roles:void 0,taskTypes:t.taskTypes.length>0?t.taskTypes:void 0,modes:t.modes.length>0?t.modes:void 0}},{echoToChat:!1})}}),(0,A.jsx)(re,{open:B,onOpenChange:V,onImport:t=>{try{let{entries:n,skipped:r}=N(t);if(n.length===0)return O({tone:`error`,text:`No valid audience-scoped memories were found in the JSON.`}),!1;for(let t of n)e.rememberSage(t,{echoToChat:!1});return O({tone:`success`,text:`${n.length} memor${n.length===1?`y`:`ies`} queued for import${r?`; ${r} invalid ${r===1?`entry was`:`entries were`} skipped`:``}.`}),V(!1),!0}catch(e){return O({tone:`error`,text:e instanceof Error?e.message:`Invalid JSON.`}),!1}}}),(0,A.jsx)(b,{open:!!H,onOpenChange:e=>{!e&&!K&&U(null)},children:(0,A.jsxs)(_,{className:`max-w-md`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Delete this audience memory?`}),(0,A.jsx)(y,{children:`This removes the memory from active use. To keep it as general project guidance, cancel and use the un-scope action instead.`})]}),(0,A.jsx)(`div`,{className:`rounded-md border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:T(r.find(e=>e.id===H)?.text??``,180)}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>U(null),disabled:K,children:`Cancel`}),(0,A.jsxs)(x,{variant:`destructive`,onClick:ce,disabled:K,children:[(0,A.jsx)(t,{className:`size-4`}),K?`Deleting…`:`Delete memory`]})]})]})})]})}function L({value:e,label:t}){return(0,A.jsxs)(`div`,{className:`bg-card/95 px-1.5 py-2 text-center`,children:[(0,A.jsx)(`p`,{className:`text-sm font-semibold tabular-nums`,children:e}),(0,A.jsx)(`p`,{className:`truncate text-[9px] uppercase tracking-wide text-muted-foreground`,children:t})]})}function R({memory:e,onFilter:n,onClearScope:i,onDelete:a}){return(0,A.jsxs)(`li`,{className:`group rounded-md border border-border/65 bg-card/55 p-2.5 transition-colors hover:border-border hover:bg-card/85`,children:[(0,A.jsx)(`p`,{className:`break-words text-xs leading-5`,children:e.text}),e.audience&&(0,A.jsx)(z,{audience:e.audience,onFilter:n}),(0,A.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 border-t border-border/45 pt-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[9px] uppercase tracking-wide text-muted-foreground`,children:[(0,A.jsx)(`span`,{className:`truncate`,children:D[e.kind]??e.kind}),(0,A.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,A.jsx)(`span`,{children:e.status})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:i,"aria-label":`Remove audience scope from ${T(e.text,42)}`,title:`Make general memory`,children:(0,A.jsx)(r,{className:`size-3`})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6 text-destructive hover:text-destructive`,onClick:a,"aria-label":`Delete ${T(e.text,42)}`,title:`Delete`,children:(0,A.jsx)(t,{className:`size-3`})})]})]})]})}function z({audience:e,onFilter:t}){return(0,A.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[...(e.roles??[]).map(e=>({label:`role`,value:e})),...(e.taskTypes??[]).map(e=>({label:`task`,value:e})),...(e.modes??[]).map(e=>({label:`mode`,value:e}))].map(({label:e,value:n})=>(0,A.jsxs)(`button`,{type:`button`,className:`max-w-full truncate rounded border border-primary/15 bg-primary/7 px-1.5 py-0.5 font-mono text-[9px] text-primary/90 transition-colors hover:border-primary/35 hover:bg-primary/12`,onClick:()=>t(n),title:`Filter by ${e}: ${n}`,children:[e,`:`,n]},`${e}:${n}`))})}function ee(){return(0,A.jsx)(`div`,{className:`space-y-2 pt-3`,role:`status`,"aria-label":`Loading audience memories`,children:[0,1,2].map(e=>(0,A.jsxs)(`div`,{className:`animate-pulse rounded-md border border-border/50 p-3`,children:[(0,A.jsx)(`div`,{className:`h-2.5 w-full rounded bg-muted`}),(0,A.jsx)(`div`,{className:`mt-2 h-2.5 w-2/3 rounded bg-muted`}),(0,A.jsx)(`div`,{className:`mt-3 h-4 w-24 rounded bg-muted`})]},e))})}function te({onAdd:e}){return(0,A.jsxs)(`div`,{className:`flex h-full min-h-44 flex-col items-center justify-center px-5 text-center`,children:[(0,A.jsx)(`span`,{className:`mb-3 flex size-10 items-center justify-center rounded-full border border-dashed border-primary/35 bg-primary/5 text-primary`,children:(0,A.jsx)(n,{className:`size-4`})}),(0,A.jsx)(`p`,{className:`text-xs font-medium`,children:`Route guidance to the right agents`}),(0,A.jsx)(`p`,{className:`mt-1 max-w-52 text-[10px] leading-4 text-muted-foreground`,children:`Scope a memory by role, task type, or operating mode. Matching agents receive it automatically.`}),(0,A.jsxs)(x,{variant:`outline`,size:`sm`,className:`mt-3 h-7 gap-1 text-xs`,onClick:e,children:[(0,A.jsx)(l,{className:`size-3`}),`Add scoped memory`]})]})}function ne({open:e,busy:t,onOpenChange:n,onCreate:r}){let[i,a]=(0,k.useState)(``),[o,s]=(0,k.useState)(`workflow`),[c,l]=(0,k.useState)(``),[u,d]=(0,k.useState)(``),[f,p]=(0,k.useState)(``);(0,k.useEffect)(()=>{e||(a(``),s(`workflow`),l(``),d(``),p(``))},[e]);let m=O(c),S=O(u),C=O(f),w=i.trim().length>0&&(m.length>0||S.length>0||C.length>0);return(0,A.jsx)(b,{open:e,onOpenChange:n,children:(0,A.jsxs)(_,{className:`max-w-xl`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Add audience-scoped memory`}),(0,A.jsx)(y,{children:`This guidance is injected only when an agent matches at least one supplied selector.`})]}),(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-text`,className:`mb-1.5 block text-xs font-medium`,children:`Memory`}),(0,A.jsx)(`textarea`,{id:`audience-memory-text`,value:i,onChange:e=>a(e.target.value),placeholder:`What should matching agents remember?`,rows:4,autoFocus:!0,className:`w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-kind`,className:`mb-1.5 block text-xs font-medium`,children:`Kind`}),(0,A.jsx)(`select`,{id:`audience-memory-kind`,value:o,onChange:e=>s(e.target.value),className:`h-9 w-full rounded-md border border-input bg-background px-3 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:E.map(e=>(0,A.jsx)(`option`,{value:e,children:D[e]??e},e))})]}),(0,A.jsxs)(`fieldset`,{className:`space-y-3 rounded-md border border-border/70 bg-background/35 p-3`,children:[(0,A.jsx)(`legend`,{className:`px-1 text-xs font-medium`,children:`Audience selectors`}),(0,A.jsx)(B,{id:`audience-memory-roles`,label:`Roles`,value:c,onChange:l,placeholder:`reviewer, refactor-planner`}),(0,A.jsx)(B,{id:`audience-memory-task-types`,label:`Task types`,value:u,onChange:d,placeholder:`review, refactor, bugfix`}),(0,A.jsx)(B,{id:`audience-memory-modes`,label:`Modes`,value:f,onChange:p,placeholder:`teach, code-review`}),(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Comma-separate multiple values. At least one selector is required.`})]})]}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>n(!1),disabled:t,children:`Cancel`}),(0,A.jsx)(x,{onClick:()=>r({text:i.trim(),kind:o,roles:m,taskTypes:S,modes:C}),disabled:!w||t,children:t?`Remembering…`:`Remember`})]})]})})}function B({id:e,label:t,value:n,placeholder:r,onChange:i}){return(0,A.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[6rem_1fr] sm:items-center`,children:[(0,A.jsx)(`label`,{htmlFor:e,className:`text-[11px] font-medium text-muted-foreground`,children:t}),(0,A.jsx)(S,{id:e,value:n,onChange:e=>i(e.target.value),placeholder:r,className:`h-8 font-mono text-xs`})]})}function re({open:e,onOpenChange:t,onImport:n}){let[r,i]=(0,k.useState)(``);return(0,k.useEffect)(()=>{e||i(``)},[e]),(0,A.jsx)(b,{open:e,onOpenChange:t,children:(0,A.jsxs)(_,{className:`max-w-xl`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Import audience memories`}),(0,A.jsxs)(y,{children:[`Paste the JSON produced here or by `,(0,A.jsx)(`code`,{children:`/memory audience export`}),`. Entries without a valid audience selector are skipped.`]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-import`,className:`mb-1.5 block text-xs font-medium`,children:`JSON array`}),(0,A.jsx)(`textarea`,{id:`audience-memory-import`,value:r,onChange:e=>i(e.target.value),placeholder:`[
|
|
2
2
|
{ "text": "…", "audience": { "roles": ["reviewer"] } }
|
|
3
3
|
]`,rows:10,autoFocus:!0,spellCheck:!1,className:`w-full resize-y rounded-md border border-input bg-background p-3 font-mono text-xs outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,A.jsxs)(x,{onClick:()=>n(r),disabled:!r.trim(),children:[(0,A.jsx)(u,{className:`size-4`}),`Import memories`]})]})]})})}export{I as AudienceMemoryPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Kn as t,Ri as n,Ur as r,b as i,cn as a,en as o,et as s,fi as c,ga as l,tn as u,xa as d}from"./vendor-9hC4n4Me.js";import"./i18n-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Kn as t,Ri as n,Ur as r,b as i,cn as a,en as o,et as s,fi as c,ga as l,tn as u,xa as d}from"./vendor-9hC4n4Me.js";import"./i18n-C2VyJ0Kz.js";import{a as f,n as p,t as m}from"./monaco-BLUV5g0U.js";import{t as h}from"./ws-client-eyEv8wbm.js";import{t as g}from"./utils-DzRQUvln.js";import{M as _,g as v}from"./stores-hEu6z1qz.js";import{w as y}from"./index-DSXHr5yP.js";import{t as b}from"./empty-state-DoEewhfx.js";import{t as x}from"./monaco-theme-DSeCDzQy.js";var S=e(d(),1),C=s();p.config({monaco:m});var w={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,json:`json`,css:`css`,scss:`scss`,html:`html`,md:`markdown`,py:`python`,go:`go`,rs:`rust`,java:`java`,c:`c`,cpp:`cpp`,cs:`csharp`,rb:`ruby`,php:`php`,sh:`shell`,bash:`shell`,yml:`yaml`,yaml:`yaml`,toml:`toml`,sql:`sql`};function T(e){return w[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function E({path:e,oldText:r,newText:a}){let{t:s}=l(),c=(0,S.useRef)(null),[u,d]=(0,S.useState)(!1),[p,m]=(0,S.useState)(!1),[g,v]=(0,S.useState)(null);(0,S.useEffect)(()=>{d(!1),m(!1),v(null)},[]);let y=(0,S.useCallback)(e=>{c.current=e,f.setTheme(x()),e.getModifiedEditor().onDidChangeModelContent(()=>d(!0))},[]),b=(0,S.useCallback)(()=>{let t=c.current?.getModifiedEditor().getValue();if(t==null)return;m(!0);let n=h(_.getState().wsUrl),r=n.on(`files.written`,t=>{t.type===`files.written`&&t.payload.filePath===e&&(r(),clearTimeout(i),m(!1),t.payload.success&&(d(!1),v(Date.now())))}),i=setTimeout(()=>{r(),m(!1)},5e3);n.send({type:`files.write`,payload:{filePath:e,content:t}})},[e]),w=T(e);return(0,C.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,C.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 px-2 py-1.5 border-b border-border/40`,children:[(0,C.jsx)(`span`,{className:`text-xs font-mono text-muted-foreground truncate`,children:e}),(0,C.jsxs)(`button`,{type:`button`,onClick:b,disabled:!u||p,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md border border-border text-xs font-medium disabled:opacity-40 enabled:hover:bg-muted transition-colors`,title:s(`activity:monacoDiff.applyTitle`),children:[p?(0,C.jsx)(t,{className:`h-3.5 w-3.5 animate-spin`}):g&&!u?(0,C.jsx)(n,{className:`h-3.5 w-3.5 text-success`}):(0,C.jsx)(o,{className:`h-3.5 w-3.5`}),s(p?`activity:monacoDiff.applying`:g&&!u?`activity:monacoDiff.applied`:`activity:monacoDiff.apply`)]})]}),(0,C.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-hidden`,children:(0,C.jsx)(i,{original:r,modified:a,language:w,theme:x(),onMount:y,options:{renderSideBySide:!0,readOnly:!1,originalEditable:!1,minimap:{enabled:!1},fontSize:13,scrollBeyondLastLine:!1,automaticLayout:!0}})})]})}var D=1e4;function O({className:e}){let{t:n}=l(),i=v(e=>e.selectedPath),o=v(e=>e.diff),s=v(e=>e.loadingDiff),[d,f]=(0,S.useState)(`unified`),[p,m]=(0,S.useState)(!1),x=!!i&&(s||!o);(0,S.useEffect)(()=>{if(m(!1),!x)return;let e=setTimeout(()=>m(!0),D);return()=>clearTimeout(e)},[x,i]);let w=()=>{i&&(m(!1),v.getState().setDiffLoading(!0),h(_.getState().wsUrl).getGitDiff?.(i))};if(!i)return(0,C.jsx)(b,{icon:(0,C.jsx)(r,{className:`h-6 w-6`}),title:`Source changes`,description:n(`activity:changes.selectPrompt`),className:e});let T=o&&!o.error&&!o.binary&&!o.tooLarge;return(0,C.jsx)(`div`,{className:g(`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-[hsl(var(--surface-2)/0.45)] p-3`,e),children:(0,C.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border/70 bg-card/75 shadow-sm`,children:[(0,C.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border/70 px-3 py-2`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-[10px] font-semibold uppercase text-muted-foreground`,children:`Source control`}),(0,C.jsx)(`div`,{className:`truncate font-mono text-xs text-foreground`,title:i,children:i})]}),T&&(0,C.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,C.jsxs)(`button`,{type:`button`,onClick:()=>f(`unified`),title:n(`activity:changes.unifiedTitle`),className:g(`inline-flex h-8 items-center gap-1 rounded-md border px-2 text-xs transition-colors`,d===`unified`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,C.jsx)(u,{className:`h-3.5 w-3.5`}),` `,n(`activity:changes.unified`)]}),(0,C.jsxs)(`button`,{type:`button`,onClick:()=>f(`edit`),title:n(`activity:changes.editTitle`),className:g(`inline-flex h-8 items-center gap-1 rounded-md border px-2 text-xs transition-colors`,d===`edit`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,C.jsx)(c,{className:`h-3.5 w-3.5`}),` `,n(`activity:changes.edit`)]})]})]}),(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:s||!o?p?(0,C.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-4 text-center`,children:[(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`activity:changes.diffTimeout`)}),(0,C.jsxs)(`button`,{type:`button`,onClick:w,className:`inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-3 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:[(0,C.jsx)(a,{className:`h-3.5 w-3.5`}),` `,n(`common:action.retry`)]})]}):(0,C.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,C.jsx)(t,{className:`h-4 w-4 animate-spin`}),` `,n(`activity:changes.loadingDiff`)]}):o.error?(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-destructive`,children:o.error}):o.binary?(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:n(`activity:changes.binary`)}):o.tooLarge?(0,C.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center text-sm text-muted-foreground`,children:n(`activity:changes.tooLarge`)}):d===`edit`?(0,C.jsx)(E,{path:o.path,oldText:o.oldText??``,newText:o.newText??``},o.path):(0,C.jsx)(y,{oldText:o.oldText,newText:o.newText,caption:o.path,fill:!0})})]})})}export{O as ChangesView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Fi as t,Gi as n,Ji as r,Kr as i,Nt as a,Qn as o,Ut as s,Zt as c,_i as ee,at as l,br as u,bt as d,cn as f,et as p,ii as m,in as te,pa as h,wr as g,xa as _}from"./vendor-9hC4n4Me.js";import{t as ne}from"./ws-client-D0KuNwAk.js";import{t as v}from"./utils-DzRQUvln.js";import{f as re,p as ie}from"./index-Dy7C2V-G.js";var y=e(_(),1),b=p();function ae({status:e}){return(0,b.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-primary/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,title:e.chronicleDirectory,children:[(0,b.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:`Chronicle ownership`}),(0,b.jsxs)(`span`,{children:[`collect `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.collection})]}),(0,b.jsxs)(`span`,{children:[`process `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.processing})]}),(0,b.jsxs)(`span`,{children:[`serve `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.serving})]}),(0,b.jsxs)(`span`,{children:[`PID `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.pid}),` · `,e.clients,` clients`]}),(0,b.jsxs)(`span`,{children:[`watcher`,` `,(0,b.jsx)(`b`,{className:v(e.watcher.active?`text-success`:`text-warning`),children:e.watcher.active?`active`:`inactive`}),` `,`· `,e.watcher.watchedFiles,` files`]}),(0,b.jsxs)(`span`,{children:[`store `,(0,b.jsx)(`b`,{className:`text-foreground`,children:x(e.pipeline.storage)})]}),e.mode===`inline`&&(0,b.jsx)(`span`,{className:`font-sans font-semibold text-warning`,children:`INLINE FALLBACK`})]})}function x(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).slice(-3).join(`/`)}var S=[`eventType`,`providerId`,`modelId`,`outcome`,`resourceKind`],C=1440*60*1e3;function w(){return{limit:300,order:`desc`,from:new Date(Date.now()-C).toISOString()}}var T=[{id:`all`,label:`All signals`,icon:(0,b.jsx)(h,{})},{id:`llm`,label:`LLM`,icon:(0,b.jsx)(n,{})},{id:`agents`,label:`Agents`,icon:(0,b.jsx)(r,{})},{id:`tools`,label:`Tools`,icon:(0,b.jsx)(a,{})},{id:`files`,label:`Files`,icon:(0,b.jsx)(i,{})},{id:`failures`,label:`Failures`,icon:(0,b.jsx)(d,{})}];function E(){let e=ne(),[t,s]=(0,y.useState)([]),[u,d]=(0,y.useState)(null),[p,m]=(0,y.useState)({}),[h,_]=(0,y.useState)(w()),[x,C]=(0,y.useState)({text:``,path:``,providerId:``,modelId:``,sessionId:``}),[E,D]=(0,y.useState)(`all`),[A,P]=(0,y.useState)({total:0,scannedEvents:0,sourceFiles:0,invalidLines:0}),[I,de]=(0,y.useState)(O),[L,R]=(0,y.useState)(!0),[z,B]=(0,y.useState)(null),[V,H]=(0,y.useState)(null),[U,fe]=(0,y.useState)([]),[W,pe]=(0,y.useState)([]),[G,me]=(0,y.useState)(null),K=(0,y.useCallback)(t=>{if(!e.supportsCapability(`chronicle.query`)){R(!1),B(`Restart the backend once to activate Chronicle protocol support.`);return}if(R(!0),B(null),_(t),m({}),e.send({type:`chronicle.query`,payload:{query:t}}),e.supportsCapability(`chronicle.facets`))e.send({type:`chronicle.facets`,payload:{fields:[...S],query:t,limit:12}});else for(let n of S)e.send({type:`chronicle.facet`,payload:{field:n,query:t,limit:12}})},[e]),q=(0,y.useCallback)(()=>{e.supportsCapability(`chronicle.metrics`)&&(e.send({type:`chronicle.metrics`,payload:{view:`providers`}}),e.send({type:`chronicle.metrics`,payload:{view:`tasks`,limit:200}}))},[e]),J=(0,y.useCallback)(()=>{e.supportsCapability(`chronicle.status`)&&e.send({type:`chronicle.status`})},[e]);(0,y.useEffect)(()=>{let t=e.on(`chronicle.query_result`,e=>{e.type===`chronicle.query_result`&&(s(e.payload.events),P(e.payload),de(e.payload.summary??O),R(!1))}),n=e.on(`chronicle.facet_result`,e=>{e.type===`chronicle.facet_result`&&m(t=>({...t,[e.payload.field]:e.payload.values}))}),r=e.on(`chronicle.facets_result`,e=>{e.type===`chronicle.facets_result`&&m(e.payload.values)}),i=e.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(B(e.payload.message),R(!1))}),a=e.on(`chronicle.graph_result`,e=>{e.type===`chronicle.graph_result`&&H(e.payload)}),o=e.on(`chronicle.metrics_result`,e=>{e.type===`chronicle.metrics_result`&&(e.payload.view===`providers`?fe(e.payload.data):e.payload.view===`tasks`&&pe(e.payload.data))}),c=e.on(`chronicle.status_result`,e=>{e.type===`chronicle.status_result`&&me(e.payload)});return K(w()),q(),J(),()=>{t(),n(),r(),i(),a(),o(),c()}},[e,K,q,J]);let Y=(0,y.useMemo)(()=>t.filter(e=>se(e,E)),[t,E]),X=ie(Y,25,E),Z=(0,y.useMemo)(()=>{let e=t.find(e=>e.eventType===`metrics.rollup`&&e.attributes?.signal===`runtime.health`)?.attributes?.stats;if(!e)return;let n=t=>e[t]?.last;return{eventLoop:{utilization:n(`eventLoop.utilization`),delayP95Ms:n(`eventLoop.delayP95Ms`)},memory:{heapUsedBytes:n(`memory.heapUsedBytes`)},chronicle:{pendingEvents:n(`chronicle.pendingEvents`),rejectedEvents:n(`chronicle.rejectedEvents`)}}},[t]),Q=(0,y.useMemo)(()=>{let e={};for(let t of W)e[t.status]=(e[t.status]??0)+1;let t=(e.completed??0)+(e.merged??0)+(e.failed??0)+(e.conflict??0),n=(e.completed??0)+(e.merged??0),r=[...W].sort((e,t)=>(t.endedAt??t.startedAt??``).localeCompare(e.endedAt??e.startedAt??``)).slice(0,8);return{counts:e,total:W.length,terminal:t,successRate:t>0?n/t*100:100,recent:r}},[W]),$=()=>K({...w(),...x.text?{text:x.text}:{},...x.path?{path:x.path}:{},...x.providerId?{providerId:x.providerId}:{},...x.modelId?{modelId:x.modelId}:{},...x.sessionId?{sessionId:x.sessionId}:{}}),he=()=>{C({text:``,path:``,providerId:``,modelId:``,sessionId:``}),D(`all`),K(w())},ge=t=>{d(t),H(null),e.supportsCapability(`chronicle.graph`)&&e.send({type:`chronicle.graph`,payload:{seed:{eventId:t.eventId},hops:2,maxNodes:250}})};return(0,b.jsxs)(`div`,{className:`flex h-full min-h-0 bg-background`,"data-testid":`chronicle-dashboard`,children:[(0,b.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,b.jsx)(`header`,{className:`border-b border-border/70 bg-gradient-to-r from-primary/[0.045] via-background to-background px-5 py-4`,children:(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(n,{className:`h-5 w-5 text-primary`}),(0,b.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Coding Intelligence`}),(0,b.jsx)(`span`,{className:`rounded-full border border-primary/20 bg-primary/10 px-2 py-0.5 text-[9px] font-semibold tracking-wider text-primary`,children:`CHRONICLE`})]}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`LLM, agent, tool and file evidence — connected from decision to code change.`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:v(`h-2 w-2 rounded-full`,z?`bg-destructive`:L?`animate-pulse bg-warning`:`bg-success`)}),(0,b.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:L?`Reading journal`:z?`Unavailable`:`Live evidence`}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>{K(h),q(),J()},className:`ml-2 rounded-md border border-border bg-card p-2 hover:bg-muted`,title:`Refresh evidence`,children:(0,b.jsx)(f,{className:v(`h-4 w-4`,L&&`animate-spin`)})})]})]})}),(0,b.jsxs)(`section`,{className:`grid grid-cols-2 border-b border-border/70 xl:grid-cols-6`,children:[(0,b.jsx)(N,{icon:(0,b.jsx)(n,{}),label:`LLM requests`,value:I.logicalRequests,detail:`${I.modelAttempts} attempts · ${I.providers} providers · ${I.models} models`}),(0,b.jsx)(N,{icon:(0,b.jsx)(r,{}),label:`Agent work`,value:I.agentEvents,detail:`${I.uniqueAgents} correlated agents · ${I.decisions} decisions`}),(0,b.jsx)(N,{icon:(0,b.jsx)(a,{}),label:`Tool calls`,value:I.toolCalls,detail:`${I.failedTools} failed · ${I.processes} processes`}),(0,b.jsx)(N,{icon:(0,b.jsx)(i,{}),label:`File evidence`,value:I.fileEvents,detail:`${I.uniqueFiles} unique paths`}),(0,b.jsx)(N,{icon:(0,b.jsx)(te,{}),label:`Retries`,value:I.scheduledRetries,detail:`${I.failures} failures · ${I.fallbacks} fallbacks`,tone:I.failures?`danger`:`normal`}),(0,b.jsx)(N,{icon:(0,b.jsx)(ee,{}),label:`Provider p95`,value:j(I.providerP95DurationMs),detail:`${j(I.providerAvgDurationMs)} average · all matches`})]}),(0,b.jsxs)(`section`,{className:`flex flex-wrap gap-x-6 gap-y-1 border-b border-border/60 bg-primary/[0.018] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:`Token economics`}),(0,b.jsxs)(`span`,{children:[`fresh input `,(0,b.jsx)(`b`,{className:`text-foreground`,children:I.inputTokens.toLocaleString()})]}),(0,b.jsxs)(`span`,{children:[`output `,(0,b.jsx)(`b`,{className:`text-foreground`,children:I.outputTokens.toLocaleString()})]}),(0,b.jsxs)(`span`,{children:[`cache read `,(0,b.jsx)(`b`,{className:`text-foreground`,children:I.cacheReadTokens.toLocaleString()})]}),(0,b.jsxs)(`span`,{children:[`cache write`,` `,(0,b.jsx)(`b`,{className:`text-foreground`,children:I.cacheWriteTokens.toLocaleString()})]}),(0,b.jsxs)(`span`,{children:[`cache hit `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[k(I).toFixed(1),`%`]})]}),(0,b.jsxs)(`span`,{children:[`estimated cost `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[`$`,I.estimatedCostUsd.toFixed(4)]})]})]}),U.length>0&&(0,b.jsxs)(`section`,{className:`flex items-center gap-3 overflow-x-auto border-b border-border/60 bg-muted/[0.14] px-4 py-1.5`,children:[(0,b.jsx)(`span`,{className:`shrink-0 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Model reliability`}),U.slice(0,6).map(e=>{let t=e.completed+e.failed,n=t>0?e.completed/t*100:100;return(0,b.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 rounded-full border border-border bg-card px-2.5 py-0.5 font-mono text-[9px]`,title:`${e.day} · ${e.attempts} attempts · avg ${j(e.avgDurationMs)} · ${e.inputTokens.toLocaleString()} in / ${e.outputTokens.toLocaleString()} out`,children:[(0,b.jsx)(`span`,{className:v(`h-1.5 w-1.5 rounded-full`,n>=99?`bg-success`:n>=90?`bg-warning`:`bg-destructive`)}),(0,b.jsxs)(`span`,{className:`max-w-[180px] truncate`,children:[e.providerId,`/`,e.modelId]}),(0,b.jsxs)(`b`,{className:`text-foreground`,children:[n.toFixed(0),`%`]}),(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e.day.slice(5)})]},`${e.day}-${e.providerId}-${e.modelId}`)})]}),Q.total>0&&(0,b.jsxs)(`section`,{className:`flex items-center gap-3 overflow-x-auto border-b border-border/60 bg-muted/[0.10] px-4 py-1.5`,children:[(0,b.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,b.jsx)(o,{className:`h-3 w-3`}),`Task outcomes`]}),(0,b.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 rounded-full border border-border bg-card px-2.5 py-0.5 font-mono text-[9px]`,title:`${Q.total} tasks tracked · ${Q.terminal} finished`,children:[(0,b.jsx)(`span`,{className:v(`h-1.5 w-1.5 rounded-full`,Q.successRate>=90?`bg-success`:Q.successRate>=60?`bg-warning`:`bg-destructive`)}),(0,b.jsxs)(`b`,{className:`text-foreground`,children:[Q.successRate.toFixed(0),`%`]}),(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[`success · `,Q.total,` tasks`]})]}),[`completed`,`merged`,`failed`,`conflict`,`started`].filter(e=>Q.counts[e]).map(e=>(0,b.jsxs)(`span`,{className:`shrink-0 font-mono text-[9px] text-muted-foreground`,children:[e,` `,(0,b.jsx)(`b`,{className:v(e===`failed`||e===`conflict`?`text-destructive`:`text-foreground`),children:Q.counts[e]})]},e)),(0,b.jsx)(`span`,{className:`mx-1 h-3 w-px shrink-0 bg-border`}),Q.recent.map(e=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>K({limit:300,order:`desc`,taskId:e.taskId}),className:`flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-card px-2 py-0.5 font-mono text-[9px] hover:border-primary/50`,title:`${e.taskId}${e.boardId?` · board ${e.boardId}`:``}${e.sessionId?` · ${e.sessionId}`:``} · ${e.filesTouched} files${e.retries?` · ${e.retries} retries`:``}${e.verificationFailures?` · ${e.verificationFailures} verify-fails`:``}`,children:[(0,b.jsx)(`span`,{className:v(`h-1.5 w-1.5 rounded-full`,e.status===`completed`||e.status===`merged`?`bg-success`:e.status===`failed`||e.status===`conflict`?`bg-destructive`:`bg-primary`)}),(0,b.jsx)(`span`,{className:`max-w-[84px] truncate`,children:e.taskId}),e.durationMs!==null&&(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:j(e.durationMs)}),e.filesTouched>0&&(0,b.jsxs)(`span`,{className:`flex items-center gap-0.5 text-muted-foreground`,children:[(0,b.jsx)(i,{className:`h-2.5 w-2.5`}),e.filesTouched]})]},e.taskId))]}),(0,b.jsx)(`section`,{className:`border-b border-border/70 px-4 py-3`,children:(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 xl:grid-cols-[1.35fr_1fr_1fr_1fr_1fr_auto]`,children:[(0,b.jsx)(M,{icon:(0,b.jsx)(c,{}),placeholder:`Search event evidence`,value:x.text,onChange:e=>C(t=>({...t,text:e})),onEnter:$}),(0,b.jsx)(M,{placeholder:`File or directory`,value:x.path,onChange:e=>C(t=>({...t,path:e})),onEnter:$}),(0,b.jsx)(M,{placeholder:`Provider`,value:x.providerId,onChange:e=>C(t=>({...t,providerId:e})),onEnter:$}),(0,b.jsx)(M,{placeholder:`Model`,value:x.modelId,onChange:e=>C(t=>({...t,modelId:e})),onEnter:$}),(0,b.jsx)(M,{placeholder:`Session`,value:x.sessionId,onChange:e=>C(t=>({...t,sessionId:e})),onEnter:$}),(0,b.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:$,className:`rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground`,children:[(0,b.jsx)(g,{className:`mr-1 inline h-3 w-3`}),`Apply`]}),(0,b.jsx)(`button`,{type:`button`,onClick:he,className:`rounded-md border border-border px-2.5 text-xs hover:bg-muted`,children:`Clear`})]})]})}),(0,b.jsxs)(`section`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/70 px-4 py-2`,children:[T.map(e=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>D(e.id),className:v(`flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1.5 text-[11px] transition-colors [&>svg]:h-3.5 [&>svg]:w-3.5`,E===e.id?`bg-primary/10 font-medium text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[e.icon,e.label,(0,b.jsx)(`span`,{className:`ml-1 rounded bg-background/70 px-1 font-mono text-[9px]`,children:oe(I,e.id,A.total)})]},e.id)),(0,b.jsxs)(`div`,{className:`ml-auto hidden items-center gap-3 pl-4 text-[9px] text-muted-foreground lg:flex`,children:[(0,b.jsxs)(`span`,{children:[A.total.toLocaleString(),` matched`]}),(0,b.jsxs)(`span`,{children:[A.sourceFiles,` journal files`]}),A.invalidLines>0&&(0,b.jsxs)(`span`,{className:`text-warning`,children:[A.invalidLines,` invalid lines`]})]})]}),G&&(0,b.jsx)(ae,{status:G}),Z&&(0,b.jsx)(ce,{health:Z}),(0,b.jsx)(`section`,{className:`flex gap-4 overflow-x-auto border-b border-border/60 bg-muted/[0.18] px-4 py-2`,children:[`providerId`,`modelId`,`outcome`].map(e=>(0,b.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,b.jsx)(`span`,{className:`mr-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.replace(`Id`,``)}),(p[e]??[]).slice(0,4).map(t=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>K({...h,[e]:t.value}),className:`rounded-full border border-border bg-card px-2 py-0.5 text-[9px] hover:border-primary/50`,children:[t.value,` `,(0,b.jsx)(`b`,{children:t.count})]},t.value))]},e))}),(0,b.jsxs)(`div`,{className:`grid grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] gap-3 border-b border-border/60 bg-muted/20 px-4 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,b.jsx)(`span`,{children:`Time`}),(0,b.jsx)(`span`,{children:`Signal`}),(0,b.jsx)(`span`,{children:`Outcome`}),(0,b.jsx)(`span`,{children:`Model / agent`}),(0,b.jsx)(`span`,{children:`Resource`}),(0,b.jsx)(`span`,{})]}),(0,b.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:z?(0,b.jsx)(F,{text:z}):!L&&Y.length===0?(0,b.jsx)(F,{text:`No coding evidence matches these filters.`}):(0,b.jsx)(`div`,{className:`divide-y divide-border/40`,children:X.pageItems.map(e=>(0,b.jsx)(le,{event:e,active:u?.eventId===e.eventId,onClick:()=>ge(e)},e.eventId))})}),(0,b.jsx)(re,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,itemLabel:`events`})]}),u&&(0,b.jsxs)(`aside`,{className:`w-[440px] max-w-[48vw] shrink-0 overflow-auto border-l border-border bg-card/60 shadow-[-12px_0_32px_hsl(var(--background)/.35)]`,children:[(0,b.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between border-b border-border bg-card/95 px-4 py-3 backdrop-blur`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-xs font-semibold`,children:`Evidence & lineage`}),(0,b.jsxs)(`div`,{className:`mt-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,u.sequence,` · `,u.eventId]})]}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>d(null),className:`rounded p-1 hover:bg-muted`,children:(0,b.jsx)(l,{className:`h-4 w-4`})})]}),(0,b.jsx)(ue,{event:u,graph:V})]})]})}var D={llm:0,agent:0,tool:0,file:0,memory:0,task:0,decision:0,runtime:0},O={logicalRequests:0,modelAttempts:0,completedAttempts:0,failedAttempts:0,scheduledRetries:0,fallbacks:0,providers:0,models:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,estimatedCostUsd:0,providerAvgDurationMs:0,providerP95DurationMs:0,toolCalls:0,completedTools:0,failedTools:0,toolAvgDurationMs:0,processes:0,failedProcesses:0,fileEvents:0,uniqueFiles:0,agentEvents:0,uniqueAgents:0,decisions:0,escalations:0,failures:0,cancellations:0,families:{...D},failuresByFamily:{...D}};function oe(e,t,n){return t===`all`?n:t===`llm`?e.families.llm:t===`agents`?e.families.agent:t===`tools`?e.families.tool:t===`files`?e.families.file:e.failures}function k(e){let t=e.inputTokens+e.cacheReadTokens;return t?e.cacheReadTokens/t*100:0}function se(e,t){return t===`all`?!0:t===`llm`?/^(provider|token|context|compaction)\./.test(e.eventType):t===`agents`?/^(agent|subagent|delegate|fleet|sdd)\./.test(e.eventType):t===`tools`?/^(tool|process|mcp|network)\./.test(e.eventType):t===`files`?e.resource?.kind===`file`||/^(file|worktree|storage)\./.test(e.eventType):e.outcome===`failure`||/(?:failed|error|retry|fallback|blocked|conflict)/i.test(e.eventType)}function A(e){if(!e)return`—`;let t=e/1e6;return t<1?`${(e/1e3).toFixed(0)}µs`:t<1e3?`${t.toFixed(1)}ms`:`${(t/1e3).toFixed(1)}s`}function j(e){return e?e<1?`${(e*1e3).toFixed(0)}µs`:e<1e3?`${e.toFixed(1)}ms`:`${(e/1e3).toFixed(1)}s`:`—`}function M({placeholder:e,value:t,onChange:n,onEnter:r,icon:i}){return(0,b.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-2.5 py-2 focus-within:border-primary/60`,children:[i&&(0,b.jsx)(`span`,{className:`text-muted-foreground [&>svg]:h-3.5 [&>svg]:w-3.5`,children:i}),(0,b.jsx)(`input`,{className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground/70`,placeholder:e,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r()}})]})}function N({icon:e,label:t,value:n,detail:r,tone:i=`normal`}){return(0,b.jsxs)(`div`,{className:`min-w-0 border-r border-border/60 px-4 py-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`text-primary [&>svg]:h-3.5 [&>svg]:w-3.5`,children:e}),t]}),(0,b.jsx)(`div`,{className:v(`mt-1 text-xl font-semibold tabular-nums`,i===`danger`&&`text-destructive`),children:typeof n==`number`?n.toLocaleString():n}),(0,b.jsx)(`div`,{className:`mt-0.5 truncate text-[9px] text-muted-foreground`,children:r})]})}function ce({health:e}){return(0,b.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-success/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-success`,children:`Collector healthy`}),(0,b.jsxs)(`span`,{children:[`ELU`,` `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[((e.eventLoop?.utilization??0)*100).toFixed(1),`%`]})]}),(0,b.jsxs)(`span`,{children:[`p95 `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[(e.eventLoop?.delayP95Ms??0).toFixed(1),`ms`]})]}),(0,b.jsxs)(`span`,{children:[`heap`,` `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[((e.memory?.heapUsedBytes??0)/1048576).toFixed(0),`MB`]})]}),(0,b.jsxs)(`span`,{children:[`queue `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.chronicle?.pendingEvents??0})]}),(0,b.jsxs)(`span`,{children:[`dropped`,` `,(0,b.jsx)(`b`,{className:v((e.chronicle?.rejectedEvents??0)>0&&`text-destructive`),children:e.chronicle?.rejectedEvents??0})]})]})}function le({event:e,active:n,onClick:r}){let i=e.occurredAt??e.observedAt,a=e.runtime?.modelId??e.scope.agentId??e.runtime?.providerId??`—`,o=e.resource?.path??e.resource?.id??e.correlation.toolCallId??`—`;return(0,b.jsxs)(`button`,{type:`button`,onClick:r,className:v(`grid w-full grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] items-center gap-3 px-4 py-2.5 text-left hover:bg-muted/45`,n&&`bg-primary/[0.07]`),children:[(0,b.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(i).toLocaleTimeString()}),(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(`span`,{className:v(`h-1.5 w-1.5 shrink-0 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,b.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium`,children:e.eventType})]}),(0,b.jsx)(`span`,{className:v(`w-fit rounded px-1.5 py-0.5 text-[9px]`,I(e.outcome)),children:e.outcome??`unknown`}),(0,b.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:a}),(0,b.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:o}),(0,b.jsx)(t,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}function ue({event:e,graph:t}){let n=(0,y.useMemo)(()=>[[`Scope`,e.scope],[`Correlation`,e.correlation],[`Runtime`,e.runtime],[`Resource`,e.resource],[`Attributes`,e.attributes],[`Tags`,e.tags]],[e]);return(0,b.jsxs)(`div`,{className:`p-4`,children:[(0,b.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/60 p-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:v(`h-2 w-2 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,b.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:e.eventType})]}),(0,b.jsxs)(`div`,{className:`mt-2 flex gap-4 text-[9px] text-muted-foreground`,children:[(0,b.jsx)(`span`,{children:new Date(e.occurredAt??e.observedAt).toLocaleString()}),(0,b.jsx)(`span`,{children:A(Number(e.durationNs??0))})]})]}),(0,b.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,b.jsx)(P,{icon:(0,b.jsx)(s,{}),label:`Evidence hash`,value:e.hash.slice(0,16)}),(0,b.jsx)(P,{icon:(0,b.jsx)(m,{}),label:`Sequence`,value:String(e.sequence)})]}),t&&(0,b.jsxs)(`section`,{className:`mb-4`,children:[(0,b.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,b.jsx)(u,{className:`h-3 w-3`}),`Lineage · `,t.nodes.length,` nodes · `,t.edges.length,` edges`]}),(0,b.jsx)(`div`,{className:`space-y-1 rounded-md border border-border bg-background/70 p-2`,children:t.edges.slice(0,40).map((e,n)=>(0,b.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[9px]`,children:[(0,b.jsx)(`span`,{className:v(`rounded px-1`,e.confidence===`explicit`?`bg-success/10 text-success`:e.confidence===`inferred`?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.confidence}),(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e.kind}),(0,b.jsxs)(`span`,{className:`truncate`,children:[t.nodes.find(t=>t.eventId===e.from)?.eventType,` →`,` `,t.nodes.find(t=>t.eventId===e.to)?.eventType]})]},`${e.from}-${e.to}-${e.kind}-${n}`))}),t.truncated&&(0,b.jsx)(`p`,{className:`mt-1 text-[9px] text-warning`,children:`Lineage truncated at safety limit.`})]}),n.map(([e,t])=>t&&(0,b.jsxs)(`section`,{className:`mb-4`,children:[(0,b.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),(0,b.jsx)(`pre`,{className:`overflow-auto rounded-md border border-border bg-background/70 p-3 font-mono text-[9px] leading-relaxed`,children:JSON.stringify(t,null,2)})]},e))]})}function P({icon:e,label:t,value:n}){return(0,b.jsxs)(`div`,{className:`rounded-md border border-border p-2`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px] uppercase text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`[&>svg]:h-3 [&>svg]:w-3`,children:e}),t]}),(0,b.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px]`,children:n})]})}function F({text:e}){return(0,b.jsx)(`div`,{className:`flex h-48 items-center justify-center text-sm text-muted-foreground`,children:e})}function I(e){return e===`failure`?`bg-destructive/10 text-destructive`:e===`success`?`bg-success/10 text-success`:e===`started`?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`}export{E as ChronicleDashboard};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Fi as t,Gi as n,Ji as r,Kr as i,Nt as a,Qn as o,Ut as s,Zt as c,_i as ee,at as l,br as u,bt as d,cn as f,et as p,ii as m,in as te,pa as h,wr as g,xa as _}from"./vendor-9hC4n4Me.js";import{t as ne}from"./ws-client-eyEv8wbm.js";import{t as v}from"./utils-DzRQUvln.js";import{f as re,p as ie}from"./index-DSXHr5yP.js";var y=e(_(),1),b=p();function ae({status:e}){return(0,b.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-primary/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,title:e.chronicleDirectory,children:[(0,b.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:`Chronicle ownership`}),(0,b.jsxs)(`span`,{children:[`collect `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.collection})]}),(0,b.jsxs)(`span`,{children:[`process `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.processing})]}),(0,b.jsxs)(`span`,{children:[`serve `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.serving})]}),(0,b.jsxs)(`span`,{children:[`PID `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.pid}),` · `,e.clients,` clients`]}),(0,b.jsxs)(`span`,{children:[`watcher`,` `,(0,b.jsx)(`b`,{className:v(e.watcher.active?`text-success`:`text-warning`),children:e.watcher.active?`active`:`inactive`}),` `,`· `,e.watcher.watchedFiles,` files`]}),(0,b.jsxs)(`span`,{children:[`store `,(0,b.jsx)(`b`,{className:`text-foreground`,children:x(e.pipeline.storage)})]}),e.mode===`inline`&&(0,b.jsx)(`span`,{className:`font-sans font-semibold text-warning`,children:`INLINE FALLBACK`})]})}function x(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).slice(-3).join(`/`)}var S=[`eventType`,`providerId`,`modelId`,`outcome`,`resourceKind`],C=1440*60*1e3;function w(){return{limit:300,order:`desc`,from:new Date(Date.now()-C).toISOString()}}var T=[{id:`all`,label:`All signals`,icon:(0,b.jsx)(h,{})},{id:`llm`,label:`LLM`,icon:(0,b.jsx)(n,{})},{id:`agents`,label:`Agents`,icon:(0,b.jsx)(r,{})},{id:`tools`,label:`Tools`,icon:(0,b.jsx)(a,{})},{id:`files`,label:`Files`,icon:(0,b.jsx)(i,{})},{id:`failures`,label:`Failures`,icon:(0,b.jsx)(d,{})}];function E(){let e=ne(),[t,s]=(0,y.useState)([]),[u,d]=(0,y.useState)(null),[p,m]=(0,y.useState)({}),[h,_]=(0,y.useState)(w()),[x,C]=(0,y.useState)({text:``,path:``,providerId:``,modelId:``,sessionId:``}),[E,D]=(0,y.useState)(`all`),[A,P]=(0,y.useState)({total:0,scannedEvents:0,sourceFiles:0,invalidLines:0}),[I,de]=(0,y.useState)(O),[L,R]=(0,y.useState)(!0),[z,B]=(0,y.useState)(null),[V,H]=(0,y.useState)(null),[U,fe]=(0,y.useState)([]),[W,pe]=(0,y.useState)([]),[G,me]=(0,y.useState)(null),K=(0,y.useCallback)(t=>{if(!e.supportsCapability(`chronicle.query`)){R(!1),B(`Restart the backend once to activate Chronicle protocol support.`);return}if(R(!0),B(null),_(t),m({}),e.send({type:`chronicle.query`,payload:{query:t}}),e.supportsCapability(`chronicle.facets`))e.send({type:`chronicle.facets`,payload:{fields:[...S],query:t,limit:12}});else for(let n of S)e.send({type:`chronicle.facet`,payload:{field:n,query:t,limit:12}})},[e]),q=(0,y.useCallback)(()=>{e.supportsCapability(`chronicle.metrics`)&&(e.send({type:`chronicle.metrics`,payload:{view:`providers`}}),e.send({type:`chronicle.metrics`,payload:{view:`tasks`,limit:200}}))},[e]),J=(0,y.useCallback)(()=>{e.supportsCapability(`chronicle.status`)&&e.send({type:`chronicle.status`})},[e]);(0,y.useEffect)(()=>{let t=e.on(`chronicle.query_result`,e=>{e.type===`chronicle.query_result`&&(s(e.payload.events),P(e.payload),de(e.payload.summary??O),R(!1))}),n=e.on(`chronicle.facet_result`,e=>{e.type===`chronicle.facet_result`&&m(t=>({...t,[e.payload.field]:e.payload.values}))}),r=e.on(`chronicle.facets_result`,e=>{e.type===`chronicle.facets_result`&&m(e.payload.values)}),i=e.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(B(e.payload.message),R(!1))}),a=e.on(`chronicle.graph_result`,e=>{e.type===`chronicle.graph_result`&&H(e.payload)}),o=e.on(`chronicle.metrics_result`,e=>{e.type===`chronicle.metrics_result`&&(e.payload.view===`providers`?fe(e.payload.data):e.payload.view===`tasks`&&pe(e.payload.data))}),c=e.on(`chronicle.status_result`,e=>{e.type===`chronicle.status_result`&&me(e.payload)});return K(w()),q(),J(),()=>{t(),n(),r(),i(),a(),o(),c()}},[e,K,q,J]);let Y=(0,y.useMemo)(()=>t.filter(e=>se(e,E)),[t,E]),X=ie(Y,25,E),Z=(0,y.useMemo)(()=>{let e=t.find(e=>e.eventType===`metrics.rollup`&&e.attributes?.signal===`runtime.health`)?.attributes?.stats;if(!e)return;let n=t=>e[t]?.last;return{eventLoop:{utilization:n(`eventLoop.utilization`),delayP95Ms:n(`eventLoop.delayP95Ms`)},memory:{heapUsedBytes:n(`memory.heapUsedBytes`)},chronicle:{pendingEvents:n(`chronicle.pendingEvents`),rejectedEvents:n(`chronicle.rejectedEvents`)}}},[t]),Q=(0,y.useMemo)(()=>{let e={};for(let t of W)e[t.status]=(e[t.status]??0)+1;let t=(e.completed??0)+(e.merged??0)+(e.failed??0)+(e.conflict??0),n=(e.completed??0)+(e.merged??0),r=[...W].sort((e,t)=>(t.endedAt??t.startedAt??``).localeCompare(e.endedAt??e.startedAt??``)).slice(0,8);return{counts:e,total:W.length,terminal:t,successRate:t>0?n/t*100:100,recent:r}},[W]),$=()=>K({...w(),...x.text?{text:x.text}:{},...x.path?{path:x.path}:{},...x.providerId?{providerId:x.providerId}:{},...x.modelId?{modelId:x.modelId}:{},...x.sessionId?{sessionId:x.sessionId}:{}}),he=()=>{C({text:``,path:``,providerId:``,modelId:``,sessionId:``}),D(`all`),K(w())},ge=t=>{d(t),H(null),e.supportsCapability(`chronicle.graph`)&&e.send({type:`chronicle.graph`,payload:{seed:{eventId:t.eventId},hops:2,maxNodes:250}})};return(0,b.jsxs)(`div`,{className:`flex h-full min-h-0 bg-background`,"data-testid":`chronicle-dashboard`,children:[(0,b.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,b.jsx)(`header`,{className:`border-b border-border/70 bg-gradient-to-r from-primary/[0.045] via-background to-background px-5 py-4`,children:(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(n,{className:`h-5 w-5 text-primary`}),(0,b.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:`Coding Intelligence`}),(0,b.jsx)(`span`,{className:`rounded-full border border-primary/20 bg-primary/10 px-2 py-0.5 text-[9px] font-semibold tracking-wider text-primary`,children:`CHRONICLE`})]}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`LLM, agent, tool and file evidence — connected from decision to code change.`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:v(`h-2 w-2 rounded-full`,z?`bg-destructive`:L?`animate-pulse bg-warning`:`bg-success`)}),(0,b.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:L?`Reading journal`:z?`Unavailable`:`Live evidence`}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>{K(h),q(),J()},className:`ml-2 rounded-md border border-border bg-card p-2 hover:bg-muted`,title:`Refresh evidence`,children:(0,b.jsx)(f,{className:v(`h-4 w-4`,L&&`animate-spin`)})})]})]})}),(0,b.jsxs)(`section`,{className:`grid grid-cols-2 border-b border-border/70 xl:grid-cols-6`,children:[(0,b.jsx)(N,{icon:(0,b.jsx)(n,{}),label:`LLM requests`,value:I.logicalRequests,detail:`${I.modelAttempts} attempts · ${I.providers} providers · ${I.models} models`}),(0,b.jsx)(N,{icon:(0,b.jsx)(r,{}),label:`Agent work`,value:I.agentEvents,detail:`${I.uniqueAgents} correlated agents · ${I.decisions} decisions`}),(0,b.jsx)(N,{icon:(0,b.jsx)(a,{}),label:`Tool calls`,value:I.toolCalls,detail:`${I.failedTools} failed · ${I.processes} processes`}),(0,b.jsx)(N,{icon:(0,b.jsx)(i,{}),label:`File evidence`,value:I.fileEvents,detail:`${I.uniqueFiles} unique paths`}),(0,b.jsx)(N,{icon:(0,b.jsx)(te,{}),label:`Retries`,value:I.scheduledRetries,detail:`${I.failures} failures · ${I.fallbacks} fallbacks`,tone:I.failures?`danger`:`normal`}),(0,b.jsx)(N,{icon:(0,b.jsx)(ee,{}),label:`Provider p95`,value:j(I.providerP95DurationMs),detail:`${j(I.providerAvgDurationMs)} average · all matches`})]}),(0,b.jsxs)(`section`,{className:`flex flex-wrap gap-x-6 gap-y-1 border-b border-border/60 bg-primary/[0.018] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:`Token economics`}),(0,b.jsxs)(`span`,{children:[`fresh input `,(0,b.jsx)(`b`,{className:`text-foreground`,children:I.inputTokens.toLocaleString()})]}),(0,b.jsxs)(`span`,{children:[`output `,(0,b.jsx)(`b`,{className:`text-foreground`,children:I.outputTokens.toLocaleString()})]}),(0,b.jsxs)(`span`,{children:[`cache read `,(0,b.jsx)(`b`,{className:`text-foreground`,children:I.cacheReadTokens.toLocaleString()})]}),(0,b.jsxs)(`span`,{children:[`cache write`,` `,(0,b.jsx)(`b`,{className:`text-foreground`,children:I.cacheWriteTokens.toLocaleString()})]}),(0,b.jsxs)(`span`,{children:[`cache hit `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[k(I).toFixed(1),`%`]})]}),(0,b.jsxs)(`span`,{children:[`estimated cost `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[`$`,I.estimatedCostUsd.toFixed(4)]})]})]}),U.length>0&&(0,b.jsxs)(`section`,{className:`flex items-center gap-3 overflow-x-auto border-b border-border/60 bg-muted/[0.14] px-4 py-1.5`,children:[(0,b.jsx)(`span`,{className:`shrink-0 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Model reliability`}),U.slice(0,6).map(e=>{let t=e.completed+e.failed,n=t>0?e.completed/t*100:100;return(0,b.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 rounded-full border border-border bg-card px-2.5 py-0.5 font-mono text-[9px]`,title:`${e.day} · ${e.attempts} attempts · avg ${j(e.avgDurationMs)} · ${e.inputTokens.toLocaleString()} in / ${e.outputTokens.toLocaleString()} out`,children:[(0,b.jsx)(`span`,{className:v(`h-1.5 w-1.5 rounded-full`,n>=99?`bg-success`:n>=90?`bg-warning`:`bg-destructive`)}),(0,b.jsxs)(`span`,{className:`max-w-[180px] truncate`,children:[e.providerId,`/`,e.modelId]}),(0,b.jsxs)(`b`,{className:`text-foreground`,children:[n.toFixed(0),`%`]}),(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e.day.slice(5)})]},`${e.day}-${e.providerId}-${e.modelId}`)})]}),Q.total>0&&(0,b.jsxs)(`section`,{className:`flex items-center gap-3 overflow-x-auto border-b border-border/60 bg-muted/[0.10] px-4 py-1.5`,children:[(0,b.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,b.jsx)(o,{className:`h-3 w-3`}),`Task outcomes`]}),(0,b.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 rounded-full border border-border bg-card px-2.5 py-0.5 font-mono text-[9px]`,title:`${Q.total} tasks tracked · ${Q.terminal} finished`,children:[(0,b.jsx)(`span`,{className:v(`h-1.5 w-1.5 rounded-full`,Q.successRate>=90?`bg-success`:Q.successRate>=60?`bg-warning`:`bg-destructive`)}),(0,b.jsxs)(`b`,{className:`text-foreground`,children:[Q.successRate.toFixed(0),`%`]}),(0,b.jsxs)(`span`,{className:`text-muted-foreground`,children:[`success · `,Q.total,` tasks`]})]}),[`completed`,`merged`,`failed`,`conflict`,`started`].filter(e=>Q.counts[e]).map(e=>(0,b.jsxs)(`span`,{className:`shrink-0 font-mono text-[9px] text-muted-foreground`,children:[e,` `,(0,b.jsx)(`b`,{className:v(e===`failed`||e===`conflict`?`text-destructive`:`text-foreground`),children:Q.counts[e]})]},e)),(0,b.jsx)(`span`,{className:`mx-1 h-3 w-px shrink-0 bg-border`}),Q.recent.map(e=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>K({limit:300,order:`desc`,taskId:e.taskId}),className:`flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-card px-2 py-0.5 font-mono text-[9px] hover:border-primary/50`,title:`${e.taskId}${e.boardId?` · board ${e.boardId}`:``}${e.sessionId?` · ${e.sessionId}`:``} · ${e.filesTouched} files${e.retries?` · ${e.retries} retries`:``}${e.verificationFailures?` · ${e.verificationFailures} verify-fails`:``}`,children:[(0,b.jsx)(`span`,{className:v(`h-1.5 w-1.5 rounded-full`,e.status===`completed`||e.status===`merged`?`bg-success`:e.status===`failed`||e.status===`conflict`?`bg-destructive`:`bg-primary`)}),(0,b.jsx)(`span`,{className:`max-w-[84px] truncate`,children:e.taskId}),e.durationMs!==null&&(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:j(e.durationMs)}),e.filesTouched>0&&(0,b.jsxs)(`span`,{className:`flex items-center gap-0.5 text-muted-foreground`,children:[(0,b.jsx)(i,{className:`h-2.5 w-2.5`}),e.filesTouched]})]},e.taskId))]}),(0,b.jsx)(`section`,{className:`border-b border-border/70 px-4 py-3`,children:(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 xl:grid-cols-[1.35fr_1fr_1fr_1fr_1fr_auto]`,children:[(0,b.jsx)(M,{icon:(0,b.jsx)(c,{}),placeholder:`Search event evidence`,value:x.text,onChange:e=>C(t=>({...t,text:e})),onEnter:$}),(0,b.jsx)(M,{placeholder:`File or directory`,value:x.path,onChange:e=>C(t=>({...t,path:e})),onEnter:$}),(0,b.jsx)(M,{placeholder:`Provider`,value:x.providerId,onChange:e=>C(t=>({...t,providerId:e})),onEnter:$}),(0,b.jsx)(M,{placeholder:`Model`,value:x.modelId,onChange:e=>C(t=>({...t,modelId:e})),onEnter:$}),(0,b.jsx)(M,{placeholder:`Session`,value:x.sessionId,onChange:e=>C(t=>({...t,sessionId:e})),onEnter:$}),(0,b.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,b.jsxs)(`button`,{type:`button`,onClick:$,className:`rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground`,children:[(0,b.jsx)(g,{className:`mr-1 inline h-3 w-3`}),`Apply`]}),(0,b.jsx)(`button`,{type:`button`,onClick:he,className:`rounded-md border border-border px-2.5 text-xs hover:bg-muted`,children:`Clear`})]})]})}),(0,b.jsxs)(`section`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/70 px-4 py-2`,children:[T.map(e=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>D(e.id),className:v(`flex shrink-0 items-center gap-1.5 rounded-md px-2.5 py-1.5 text-[11px] transition-colors [&>svg]:h-3.5 [&>svg]:w-3.5`,E===e.id?`bg-primary/10 font-medium text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[e.icon,e.label,(0,b.jsx)(`span`,{className:`ml-1 rounded bg-background/70 px-1 font-mono text-[9px]`,children:oe(I,e.id,A.total)})]},e.id)),(0,b.jsxs)(`div`,{className:`ml-auto hidden items-center gap-3 pl-4 text-[9px] text-muted-foreground lg:flex`,children:[(0,b.jsxs)(`span`,{children:[A.total.toLocaleString(),` matched`]}),(0,b.jsxs)(`span`,{children:[A.sourceFiles,` journal files`]}),A.invalidLines>0&&(0,b.jsxs)(`span`,{className:`text-warning`,children:[A.invalidLines,` invalid lines`]})]})]}),G&&(0,b.jsx)(ae,{status:G}),Z&&(0,b.jsx)(ce,{health:Z}),(0,b.jsx)(`section`,{className:`flex gap-4 overflow-x-auto border-b border-border/60 bg-muted/[0.18] px-4 py-2`,children:[`providerId`,`modelId`,`outcome`].map(e=>(0,b.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,b.jsx)(`span`,{className:`mr-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.replace(`Id`,``)}),(p[e]??[]).slice(0,4).map(t=>(0,b.jsxs)(`button`,{type:`button`,onClick:()=>K({...h,[e]:t.value}),className:`rounded-full border border-border bg-card px-2 py-0.5 text-[9px] hover:border-primary/50`,children:[t.value,` `,(0,b.jsx)(`b`,{children:t.count})]},t.value))]},e))}),(0,b.jsxs)(`div`,{className:`grid grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] gap-3 border-b border-border/60 bg-muted/20 px-4 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,b.jsx)(`span`,{children:`Time`}),(0,b.jsx)(`span`,{children:`Signal`}),(0,b.jsx)(`span`,{children:`Outcome`}),(0,b.jsx)(`span`,{children:`Model / agent`}),(0,b.jsx)(`span`,{children:`Resource`}),(0,b.jsx)(`span`,{})]}),(0,b.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:z?(0,b.jsx)(F,{text:z}):!L&&Y.length===0?(0,b.jsx)(F,{text:`No coding evidence matches these filters.`}):(0,b.jsx)(`div`,{className:`divide-y divide-border/40`,children:X.pageItems.map(e=>(0,b.jsx)(le,{event:e,active:u?.eventId===e.eventId,onClick:()=>ge(e)},e.eventId))})}),(0,b.jsx)(re,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,itemLabel:`events`})]}),u&&(0,b.jsxs)(`aside`,{className:`w-[440px] max-w-[48vw] shrink-0 overflow-auto border-l border-border bg-card/60 shadow-[-12px_0_32px_hsl(var(--background)/.35)]`,children:[(0,b.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between border-b border-border bg-card/95 px-4 py-3 backdrop-blur`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(`div`,{className:`text-xs font-semibold`,children:`Evidence & lineage`}),(0,b.jsxs)(`div`,{className:`mt-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,u.sequence,` · `,u.eventId]})]}),(0,b.jsx)(`button`,{type:`button`,onClick:()=>d(null),className:`rounded p-1 hover:bg-muted`,children:(0,b.jsx)(l,{className:`h-4 w-4`})})]}),(0,b.jsx)(ue,{event:u,graph:V})]})]})}var D={llm:0,agent:0,tool:0,file:0,memory:0,task:0,decision:0,runtime:0},O={logicalRequests:0,modelAttempts:0,completedAttempts:0,failedAttempts:0,scheduledRetries:0,fallbacks:0,providers:0,models:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheWriteTokens:0,estimatedCostUsd:0,providerAvgDurationMs:0,providerP95DurationMs:0,toolCalls:0,completedTools:0,failedTools:0,toolAvgDurationMs:0,processes:0,failedProcesses:0,fileEvents:0,uniqueFiles:0,agentEvents:0,uniqueAgents:0,decisions:0,escalations:0,failures:0,cancellations:0,families:{...D},failuresByFamily:{...D}};function oe(e,t,n){return t===`all`?n:t===`llm`?e.families.llm:t===`agents`?e.families.agent:t===`tools`?e.families.tool:t===`files`?e.families.file:e.failures}function k(e){let t=e.inputTokens+e.cacheReadTokens;return t?e.cacheReadTokens/t*100:0}function se(e,t){return t===`all`?!0:t===`llm`?/^(provider|token|context|compaction)\./.test(e.eventType):t===`agents`?/^(agent|subagent|delegate|fleet|sdd)\./.test(e.eventType):t===`tools`?/^(tool|process|mcp|network)\./.test(e.eventType):t===`files`?e.resource?.kind===`file`||/^(file|worktree|storage)\./.test(e.eventType):e.outcome===`failure`||/(?:failed|error|retry|fallback|blocked|conflict)/i.test(e.eventType)}function A(e){if(!e)return`—`;let t=e/1e6;return t<1?`${(e/1e3).toFixed(0)}µs`:t<1e3?`${t.toFixed(1)}ms`:`${(t/1e3).toFixed(1)}s`}function j(e){return e?e<1?`${(e*1e3).toFixed(0)}µs`:e<1e3?`${e.toFixed(1)}ms`:`${(e/1e3).toFixed(1)}s`:`—`}function M({placeholder:e,value:t,onChange:n,onEnter:r,icon:i}){return(0,b.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border border-border bg-card px-2.5 py-2 focus-within:border-primary/60`,children:[i&&(0,b.jsx)(`span`,{className:`text-muted-foreground [&>svg]:h-3.5 [&>svg]:w-3.5`,children:i}),(0,b.jsx)(`input`,{className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground/70`,placeholder:e,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&r()}})]})}function N({icon:e,label:t,value:n,detail:r,tone:i=`normal`}){return(0,b.jsxs)(`div`,{className:`min-w-0 border-r border-border/60 px-4 py-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`text-primary [&>svg]:h-3.5 [&>svg]:w-3.5`,children:e}),t]}),(0,b.jsx)(`div`,{className:v(`mt-1 text-xl font-semibold tabular-nums`,i===`danger`&&`text-destructive`),children:typeof n==`number`?n.toLocaleString():n}),(0,b.jsx)(`div`,{className:`mt-0.5 truncate text-[9px] text-muted-foreground`,children:r})]})}function ce({health:e}){return(0,b.jsxs)(`section`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-border/60 bg-success/[0.025] px-4 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-success`,children:`Collector healthy`}),(0,b.jsxs)(`span`,{children:[`ELU`,` `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[((e.eventLoop?.utilization??0)*100).toFixed(1),`%`]})]}),(0,b.jsxs)(`span`,{children:[`p95 `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[(e.eventLoop?.delayP95Ms??0).toFixed(1),`ms`]})]}),(0,b.jsxs)(`span`,{children:[`heap`,` `,(0,b.jsxs)(`b`,{className:`text-foreground`,children:[((e.memory?.heapUsedBytes??0)/1048576).toFixed(0),`MB`]})]}),(0,b.jsxs)(`span`,{children:[`queue `,(0,b.jsx)(`b`,{className:`text-foreground`,children:e.chronicle?.pendingEvents??0})]}),(0,b.jsxs)(`span`,{children:[`dropped`,` `,(0,b.jsx)(`b`,{className:v((e.chronicle?.rejectedEvents??0)>0&&`text-destructive`),children:e.chronicle?.rejectedEvents??0})]})]})}function le({event:e,active:n,onClick:r}){let i=e.occurredAt??e.observedAt,a=e.runtime?.modelId??e.scope.agentId??e.runtime?.providerId??`—`,o=e.resource?.path??e.resource?.id??e.correlation.toolCallId??`—`;return(0,b.jsxs)(`button`,{type:`button`,onClick:r,className:v(`grid w-full grid-cols-[92px_minmax(190px,1.25fr)_110px_minmax(180px,1fr)_minmax(140px,.8fr)_24px] items-center gap-3 px-4 py-2.5 text-left hover:bg-muted/45`,n&&`bg-primary/[0.07]`),children:[(0,b.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(i).toLocaleTimeString()}),(0,b.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(`span`,{className:v(`h-1.5 w-1.5 shrink-0 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,b.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium`,children:e.eventType})]}),(0,b.jsx)(`span`,{className:v(`w-fit rounded px-1.5 py-0.5 text-[9px]`,I(e.outcome)),children:e.outcome??`unknown`}),(0,b.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:a}),(0,b.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:o}),(0,b.jsx)(t,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}function ue({event:e,graph:t}){let n=(0,y.useMemo)(()=>[[`Scope`,e.scope],[`Correlation`,e.correlation],[`Runtime`,e.runtime],[`Resource`,e.resource],[`Attributes`,e.attributes],[`Tags`,e.tags]],[e]);return(0,b.jsxs)(`div`,{className:`p-4`,children:[(0,b.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/60 p-3`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:v(`h-2 w-2 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,b.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:e.eventType})]}),(0,b.jsxs)(`div`,{className:`mt-2 flex gap-4 text-[9px] text-muted-foreground`,children:[(0,b.jsx)(`span`,{children:new Date(e.occurredAt??e.observedAt).toLocaleString()}),(0,b.jsx)(`span`,{children:A(Number(e.durationNs??0))})]})]}),(0,b.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,b.jsx)(P,{icon:(0,b.jsx)(s,{}),label:`Evidence hash`,value:e.hash.slice(0,16)}),(0,b.jsx)(P,{icon:(0,b.jsx)(m,{}),label:`Sequence`,value:String(e.sequence)})]}),t&&(0,b.jsxs)(`section`,{className:`mb-4`,children:[(0,b.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,b.jsx)(u,{className:`h-3 w-3`}),`Lineage · `,t.nodes.length,` nodes · `,t.edges.length,` edges`]}),(0,b.jsx)(`div`,{className:`space-y-1 rounded-md border border-border bg-background/70 p-2`,children:t.edges.slice(0,40).map((e,n)=>(0,b.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[9px]`,children:[(0,b.jsx)(`span`,{className:v(`rounded px-1`,e.confidence===`explicit`?`bg-success/10 text-success`:e.confidence===`inferred`?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.confidence}),(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e.kind}),(0,b.jsxs)(`span`,{className:`truncate`,children:[t.nodes.find(t=>t.eventId===e.from)?.eventType,` →`,` `,t.nodes.find(t=>t.eventId===e.to)?.eventType]})]},`${e.from}-${e.to}-${e.kind}-${n}`))}),t.truncated&&(0,b.jsx)(`p`,{className:`mt-1 text-[9px] text-warning`,children:`Lineage truncated at safety limit.`})]}),n.map(([e,t])=>t&&(0,b.jsxs)(`section`,{className:`mb-4`,children:[(0,b.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),(0,b.jsx)(`pre`,{className:`overflow-auto rounded-md border border-border bg-background/70 p-3 font-mono text-[9px] leading-relaxed`,children:JSON.stringify(t,null,2)})]},e))]})}function P({icon:e,label:t,value:n}){return(0,b.jsxs)(`div`,{className:`rounded-md border border-border p-2`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px] uppercase text-muted-foreground`,children:[(0,b.jsx)(`span`,{className:`[&>svg]:h-3 [&>svg]:w-3`,children:e}),t]}),(0,b.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px]`,children:n})]})}function F({text:e}){return(0,b.jsx)(`div`,{className:`flex h-48 items-center justify-center text-sm text-muted-foreground`,children:e})}function I(e){return e===`failure`?`bg-destructive/10 text-destructive`:e===`success`?`bg-success/10 text-success`:e===`started`?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`}export{E as ChronicleDashboard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ir as t,Ji as n,Kn as r,Li as i,Nt as a,Pi as o,Ur as s,Wt as c,Xt as l,at as u,br as d,cn as f,et as p,ft as m,ga as h,ki as g,pa as _,qn as v,qr as y,xa as b,xi as x,y as S}from"./vendor-9hC4n4Me.js";import"./i18n-CIqbHugq.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./monaco-BLUV5g0U.js";import{t as ee}from"./ws-client-D0KuNwAk.js";import{t as k}from"./utils-DzRQUvln.js";import{i as te}from"./codemap-activity-store-CkJTt5go.js";import{D as A,M as ne,k as j,o as re,u as ie}from"./stores-nxVpq1NP.js";import{o as M}from"./view-navigation-DuOBOluC.js";import{T as N,d as P,w as ae}from"./index-Dy7C2V-G.js";import{t as F}from"./empty-state-DoEewhfx.js";import{t as I}from"./monaco-theme-DSeCDzQy.js";var L={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,css:`css`,html:`html`,svg:`xml`,md:`markdown`,yml:`yaml`,yaml:`yaml`,toml:`toml`,sh:`shell`,bash:`shell`,ps1:`powershell`,py:`python`,rs:`rust`,go:`go`,rb:`ruby`,java:`java`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,sql:`sql`,xml:`xml`},R=Array.from(new Set(Object.values(L))).filter(e=>e!==`plaintext`),z=12e3,B=4e3,oe=5e3,V=1e4;function H(e){return L[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function U(e){return e.match(/([A-Za-z_$][\w$]*)$/)?.[1]??``}function W(e,t){return e.triggerCharacter?!0:t.length>=3}function G(e,t){return e.triggerCharacter===`.`||!e.triggerCharacter&&/^(findBy|findAllBy|create|update|delete|remove|get[A-Z_]|set[A-Z_]|use[A-Z_])/.test(t)}function K(e){return[e.filePath,e.language,e.lineNumber,e.column,e.versionId??``,e.triggerCharacter??``,e.linePrefix.slice(-160),e.suffix.slice(0,160)].join(`\0`)}var q=e(b(),1),J=p();function se(e){let t=new Set,n=new Set,r=new Set,i=new Set,a=new Set,o,s;for(let c of e)c.sessionId&&t.add(c.sessionId),c.taskId&&n.add(c.taskId),c.boardId&&r.add(c.boardId),c.toolName&&i.add(c.toolName),c.modelId&&a.add(c.modelId),(!o||c.occurredAt<o)&&(o=c.occurredAt),(!s||c.occurredAt>s)&&(s=c.occurredAt);return{mutations:e.length,sessions:t.size,tasks:n.size,boards:r.size,tools:[...i],models:[...a],firstAt:o,lastAt:s}}var Y=150,ce=224,le=38,X=/(write|edit|update|create|delete|rename|modified|changed)/i;function Z(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}function Q(e,t){let n=Z(e),r=Z(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function ue(e,t=Date.now()){let n=e.filter(e=>t-e.at<=30*6e4),r=n.filter(e=>X.test(e.action)),i=new Set(n.map(e=>e.sessionId).filter(Boolean)).size,a=new Set(n.map(e=>e.actor).filter(Boolean)).size,o=new Set(n.map(e=>e.taskId).filter(Boolean)).size;return{level:r.length>=8||r.length>=4&&a>=3?`churn`:r.length>0?`active`:`quiet`,mutationCount:r.length,sessionCount:i,actorCount:a,taskCount:o}}function $(e){return typeof e==`string`&&e.length>0?e:void 0}function de(e){let t=Date.parse(e.occurredAt??e.observedAt);return Number.isFinite(t)?t:Date.now()}function fe(e){let t=e.attributes??{},n=$(t.operation)??e.eventType,r=e.scope.agentId,i=e.runtime?.providerId,a=e.runtime?.modelId;return{id:e.eventId,at:de(e),action:n,actor:r??i??$(t.actor)??`external`,source:$(t.source)??e.tags?.collector??`chronicle`,summary:[e.eventType,i&&a?`${i}/${a}`:i,e.outcome].filter(Boolean).join(` · `),sessionId:e.scope.sessionId,agentId:r,taskId:e.scope.taskId??$(t.taskId),boardId:$(t.boardId)??e.scope.boardId,tool:$(t.toolName),status:e.outcome,raw:e}}function pe(e){return{id:e.id??`${e.filePath}:${e.timestamp}:${e.type}`,at:e.timestamp,action:e.type,actor:e.agentName??e.agent??e.agentId??`external`,source:e.source??`live`,summary:e.summary,sessionId:e.sessionId,agentId:e.agentId,tool:e.toolName,status:e.status,raw:e}}function me(e){let t=new Set;return e.sort((e,t)=>t.at-e.at).filter(e=>{let n=`${e.id}:${e.at}`;return t.has(n)?!1:(t.add(n),!0)})}function he(e){return e?e.split(/\r?\n/).length:0}function ge(e){return new TextEncoder().encode(e).length}function _e(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ve(e){return e.length>18?`${e.slice(0,8)}…${e.slice(-6)}`:e}function ye(e,t){let n=N(e,t);return n?{added:n.filter(e=>e.kind===`add`).length,removed:n.filter(e=>e.kind===`del`).length,large:!1}:{added:0,removed:0,large:!0}}function be({file:e}){let{t}=h(),[n,r]=(0,q.useState)(!0),[c,l]=(0,q.useState)(ce),[u,p]=(0,q.useState)(`overview`),[m,b]=(0,q.useState)([]),[x,S]=(0,q.useState)([]),[C,w]=(0,q.useState)(!1),[T,E]=(0,q.useState)(null),[D,O]=(0,q.useState)(null),A=(0,q.useRef)(null),j=ne(e=>e.wsUrl),M=te(e=>e.history),N=te(e=>e.activeOperations),P=ie(e=>e.activeBoard),F=re(e=>e.snapshot),I=(0,q.useMemo)(()=>ee(j),[j]),L=(0,q.useCallback)(()=>{E(null),w(!0),typeof I.getGitDiff==`function`&&I.getGitDiff(e.path);let t=typeof I.supportsCapability==`function`?I.supportsCapability.bind(I):null;t?.(`chronicle.query`)?I.send({type:`chronicle.query`,payload:{query:{path:e.path,resourceKind:`file`,order:`desc`,limit:150}}}):w(!1),t?.(`chronicle.metrics`)&&I.send({type:`chronicle.metrics`,payload:{view:`files`,path:e.path,limit:1e3}})},[I,e.path]);(0,q.useEffect)(()=>{b([]),S([]),O(null);let t=I.on(`chronicle.query_result`,t=>{if(t.type!==`chronicle.query_result`)return;let n=t.payload.events.filter(t=>t.resource?.path&&Q(t.resource.path,e.path));t.payload.events.length>0&&n.length===0||(b(n),w(!1))}),n=I.on(`chronicle.metrics_result`,t=>{t.type!==`chronicle.metrics_result`||t.payload.view!==`files`||S(t.payload.data.filter(t=>Q(t.path,e.path)))}),r=I.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(E(e.payload.message),w(!1))}),i=I.on(`git.diff`,t=>{if(t.type!==`git.diff`||!Q(t.payload.path,e.path))return;let n=t.payload;if(n.error||n.binary||n.tooLarge){O({text:e.savedContent,available:!1,error:n.error});return}O({text:n.oldText??``,available:!0})});return L(),()=>{t(),n(),r(),i()}},[I,e.path,e.savedContent,L]),(0,q.useEffect)(()=>{let e=e=>{if(!A.current)return;let t=A.current.startY-e.clientY,n=Math.max(Y,Math.floor(window.innerHeight*.62));l(Math.min(n,Math.max(Y,A.current.startHeight+t)))},t=()=>{A.current=null,document.body.style.cursor=``,document.body.style.userSelect=``};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[]);let R=(0,q.useMemo)(()=>{let t=[];for(let[n,r]of M)Q(n,e.path)&&t.push(...r);for(let n of N.values())t.push(...n.filter(t=>Q(t.filePath,e.path)));return t},[N,e.path,M]),z=(0,q.useMemo)(()=>me([...R.map(pe),...m.map(fe)]),[m,R]),B=(0,q.useMemo)(()=>ue(z),[z]),oe=(0,q.useMemo)(()=>se(x),[x]),V=D?.text??e.savedContent,H=(0,q.useMemo)(()=>ye(V,e.content),[V,e.content]),U=(0,q.useMemo)(()=>[...new Set(z.map(e=>e.sessionId).filter(e=>!!e))],[z]),W=(0,q.useMemo)(()=>[...new Set(z.map(e=>e.actor).filter(Boolean))],[z]),G=(0,q.useMemo)(()=>[...new Set(z.map(e=>e.taskId).filter(e=>!!e))],[z]),K=(0,q.useCallback)(e=>{let t=P?.tasks.find(t=>t.id===e),n=F?.tasks.find(t=>t.id===e||t.shortId===e);return t?.title??n?.title??e},[P,F]),X=e=>{n||r(!0),A.current={startY:e.clientY,startHeight:n?c:Y},document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`},Z=[{id:`overview`,label:t(`activity:fileActivity.overview`),icon:(0,J.jsx)(_,{})},{id:`changes`,label:t(`activity:fileActivity.changes`),icon:(0,J.jsx)(s,{})},{id:`context`,label:t(`activity:fileActivity.context`),icon:(0,J.jsx)(v,{})},{id:`logs`,label:t(`activity:fileActivity.logs`),icon:(0,J.jsx)(a,{})}];return(0,J.jsxs)(`section`,{className:`flex shrink-0 flex-col overflow-hidden border-t border-border bg-card/95 shadow-[0_-10px_30px_hsl(var(--background)/0.24)] backdrop-blur`,style:{height:n?c:le},"data-testid":`file-activity-drawer`,children:[(0,J.jsx)(`button`,{type:`button`,"aria-label":t(`activity:fileActivity.resizeHint`),className:`group relative block h-2 w-full cursor-ns-resize touch-none`,onPointerDown:X,onDoubleClick:()=>{r(!0),l(ce)},title:t(`activity:fileActivity.resizeHint`),children:(0,J.jsx)(`span`,{className:`absolute left-1/2 top-0.5 h-1 w-10 -translate-x-1/2 rounded-full bg-border transition-colors group-hover:bg-primary/60`})}),(0,J.jsxs)(`header`,{className:`flex h-[30px] min-w-0 items-center gap-2 border-b border-border/70 px-2.5`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`inline-flex min-w-0 items-center gap-1.5 rounded px-1.5 py-1 text-[11px] font-semibold hover:bg-muted`,"aria-expanded":n,children:[(0,J.jsx)(y,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,J.jsx)(`span`,{className:`truncate`,children:t(`activity:fileActivity.title`)}),n?(0,J.jsx)(i,{className:`h-3 w-3`}):(0,J.jsx)(o,{className:`h-3 w-3`})]}),(0,J.jsx)(`span`,{className:`hidden h-3 w-px bg-border sm:block`}),(0,J.jsx)(xe,{label:`${he(e.content)} ${t(`activity:fileActivity.lines`)}`}),(0,J.jsx)(xe,{label:_e(ge(e.content))}),!H.large&&(H.added>0||H.removed>0)&&(0,J.jsxs)(`span`,{className:`hidden items-center gap-1 font-mono text-[10px] md:flex`,children:[(0,J.jsxs)(`span`,{className:`text-success`,children:[`+`,H.added]}),(0,J.jsxs)(`span`,{className:`text-destructive`,children:[`−`,H.removed]})]}),(0,J.jsxs)(`span`,{className:k(`ml-auto inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[9px] font-semibold uppercase tracking-wide`,B.level===`churn`&&`bg-destructive/10 text-destructive`,B.level===`active`&&`bg-warning/10 text-warning`,B.level===`quiet`&&`bg-success/10 text-success`),children:[(0,J.jsx)(g,{className:`h-2.5 w-2.5`}),t(`activity:fileActivity.level.${B.level}`)]}),(0,J.jsx)(`span`,{className:`hidden text-[9px] text-muted-foreground lg:inline`,children:t(`activity:fileActivity.evidenceCount`,{count:z.length})}),n&&(0,J.jsx)(`button`,{type:`button`,onClick:L,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:t(`activity:fileActivity.refresh`),children:(0,J.jsx)(f,{className:k(`h-3.5 w-3.5`,C&&`animate-spin`)})})]}),n&&(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,J.jsxs)(`nav`,{className:`flex shrink-0 items-center gap-0.5 border-b border-border/60 bg-muted/20 px-2`,children:[Z.map(e=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>p(e.id),className:k(`inline-flex h-7 items-center gap-1.5 border-b-2 px-2 text-[10px] transition-colors [&>svg]:h-3 [&>svg]:w-3`,u===e.id?`border-primary font-medium text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.icon,e.label]},e.id)),T&&(0,J.jsx)(`span`,{className:`ml-auto truncate px-2 text-[9px] text-warning`,children:T})]}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[u===`overview`&&(0,J.jsx)(Se,{analysis:B,lifetime:oe,records:z,sessions:U,agents:W,tasks:G,taskLabel:K}),u===`changes`&&(0,J.jsxs)(`div`,{className:`h-full min-h-[120px] p-2`,children:[(0,J.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-[9px] text-muted-foreground`,children:[(0,J.jsx)(d,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:D?.available?t(`activity:fileActivity.gitToBuffer`):t(`activity:fileActivity.savedToBuffer`)}),e.dirty&&(0,J.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:t(`activity:fileActivity.unsaved`)}),D?.error&&(0,J.jsx)(`span`,{className:`truncate text-warning`,children:D.error})]}),(0,J.jsx)(`div`,{className:`h-[calc(100%-24px)] min-h-[90px]`,children:(0,J.jsx)(ae,{oldText:V,newText:e.content,caption:e.path,fill:!0})})]}),u===`context`&&(0,J.jsx)(we,{sessions:U,agents:W,tasks:G,records:z,taskLabel:K,boardTitle:P?.title??F?.title}),u===`logs`&&(0,J.jsx)(De,{records:z,loading:C})]})]})]})}function xe({label:e}){return(0,J.jsx)(`span`,{className:`hidden whitespace-nowrap font-mono text-[9px] text-muted-foreground sm:inline`,children:e})}function Se({analysis:e,lifetime:t,records:r,sessions:i,agents:a,tasks:o,taskLabel:l}){let{t:u}=h();return(0,J.jsxs)(`div`,{className:`grid min-h-full grid-cols-1 gap-2 p-2 lg:grid-cols-[minmax(360px,.9fr)_minmax(420px,1.35fr)]`,children:[(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:[{label:u(`activity:fileActivity.mutations30m`),value:e.mutationCount,icon:(0,J.jsx)(s,{})},{label:u(`activity:fileActivity.sessions`),value:i.length,icon:(0,J.jsx)(m,{})},{label:u(`activity:fileActivity.actors`),value:a.length,icon:(0,J.jsx)(n,{})},{label:u(`activity:fileActivity.linkedWork`),value:o.length,icon:(0,J.jsx)(v,{})}].map(e=>(0,J.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-background/45 px-2 py-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e.icon,(0,J.jsx)(`span`,{className:`truncate`,children:e.label})]}),(0,J.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-semibold`,children:e.value})]},e.label))}),t.mutations>0&&(0,J.jsx)(Ce,{lifetime:t}),(0,J.jsxs)(`div`,{className:k(`flex items-start gap-2 rounded-md border px-2.5 py-2 text-[10px]`,e.level===`churn`?`border-destructive/25 bg-destructive/[0.055]`:`border-border/70 bg-background/45`),children:[(0,J.jsx)(c,{className:k(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.level===`churn`?`text-destructive`:`text-primary`)}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`font-semibold`,children:u(`activity:fileActivity.analysisTitle.${e.level}`)}),(0,J.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:u(`activity:fileActivity.analysisBody.${e.level}`,{mutations:e.mutationCount,actors:e.actorCount,sessions:e.sessionCount})})]})]}),o.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[9px]`,children:[(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[u(`activity:fileActivity.workLinks`),`:`]}),o.slice(0,4).map(e=>(0,J.jsx)(`span`,{className:`max-w-[180px] truncate rounded border border-primary/20 bg-primary/5 px-1.5 py-0.5 text-primary`,title:e,children:l(e)},e))]})]}),(0,J.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border/70 bg-background/35`,children:[(0,J.jsx)(`div`,{className:`border-b border-border/60 px-2.5 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:u(`activity:fileActivity.recentActivity`)}),(0,J.jsx)(`div`,{className:`divide-y divide-border/40`,children:r.length===0?(0,J.jsx)(ke,{text:u(`activity:fileActivity.noEvidence`)}):r.slice(0,5).map(e=>(0,J.jsx)(Oe,{record:e},`${e.id}:${e.at}`))})]})]})}function Ce({lifetime:e}){let{t}=h(),n=[{value:e.mutations,label:t(`activity:fileActivity.lifetimeChanges`)},{value:e.sessions,label:t(`activity:fileActivity.lifetimeSessions`)},{value:e.tasks,label:t(`activity:fileActivity.lifetimeTasks`)},{value:e.boards,label:t(`activity:fileActivity.lifetimeBoards`)}],r=e.firstAt?new Date(e.firstAt).toLocaleDateString():void 0;return(0,J.jsxs)(`div`,{className:`rounded-md border border-primary/15 bg-primary/[0.03] px-2.5 py-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[9px] font-semibold uppercase tracking-wider text-primary [&>svg]:h-3 [&>svg]:w-3`,children:[(0,J.jsx)(y,{}),t(`activity:fileActivity.lifetimeTitle`)]}),(0,J.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[9px] text-muted-foreground`,children:[n.map(e=>(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{className:`text-foreground`,children:e.value.toLocaleString()}),` `,e.label]},e.label)),r&&(0,J.jsx)(`span`,{children:t(`activity:fileActivity.lifetimeSince`,{date:r})})]}),e.tools.length>0&&(0,J.jsx)(`div`,{className:`mt-1 truncate font-mono text-[8px] text-muted-foreground`,title:e.tools.join(`, `),children:t(`activity:fileActivity.lifetimeTools`,{tools:e.tools.slice(0,6).join(`, `)})})]})}function we({sessions:e,agents:t,tasks:r,records:i,taskLabel:a,boardTitle:o}){let{t:s}=h();return(0,J.jsxs)(`div`,{className:`grid min-h-full grid-cols-1 divide-y divide-border/50 md:grid-cols-3 md:divide-x md:divide-y-0`,children:[(0,J.jsx)(Te,{icon:(0,J.jsx)(m,{}),title:s(`activity:fileActivity.sessions`),empty:s(`activity:fileActivity.noSessions`),children:e.map(e=>(0,J.jsx)(Ee,{title:ve(e),subtitle:`${i.filter(t=>t.sessionId===e).length} ${s(`activity:fileActivity.events`)}`,raw:e},e))}),(0,J.jsx)(Te,{icon:(0,J.jsx)(n,{}),title:s(`activity:fileActivity.actors`),empty:s(`activity:fileActivity.noActors`),children:t.map(e=>(0,J.jsx)(Ee,{title:e,subtitle:`${i.filter(t=>t.actor===e).length} ${s(`activity:fileActivity.events`)}`},e))}),(0,J.jsx)(Te,{icon:(0,J.jsx)(v,{}),title:s(`activity:fileActivity.workLinks`),empty:s(`activity:fileActivity.noWorkLinks`),children:r.map(e=>(0,J.jsx)(Ee,{title:a(e),subtitle:o??s(`activity:fileActivity.taskOrTodo`),raw:e},e))})]})}function Te({icon:e,title:t,empty:n,children:r}){let i=Array.isArray(r)?r.length>0:!!r;return(0,J.jsxs)(`section`,{className:`min-w-0 p-2`,children:[(0,J.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e,t]}),(0,J.jsx)(`div`,{className:`space-y-1`,children:i?r:(0,J.jsx)(ke,{text:n})})]})}function Ee({title:e,subtitle:t,raw:n}){return(0,J.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-background/45 px-2 py-1.5`,title:n,children:[(0,J.jsx)(`div`,{className:`truncate text-[10px] font-medium`,children:e}),(0,J.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[8px] text-muted-foreground`,children:t})]})}function De({records:e,loading:t}){let{t:n}=h();return t&&e.length===0?(0,J.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-[10px] text-muted-foreground`,children:[(0,J.jsx)(r,{className:`h-3.5 w-3.5 animate-spin`}),n(`activity:fileActivity.loadingEvidence`)]}):e.length===0?(0,J.jsx)(ke,{text:n(`activity:fileActivity.noEvidence`)}):(0,J.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map(e=>(0,J.jsx)(Oe,{record:e,raw:!0},`${e.id}:${e.at}`))})}function Oe({record:e,raw:t=!1}){let n=(0,J.jsxs)(`div`,{className:`grid grid-cols-[62px_74px_minmax(90px,.7fr)_minmax(160px,1.5fr)] items-center gap-2 text-[9px]`,children:[(0,J.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:new Date(e.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}),(0,J.jsx)(`span`,{className:k(`w-fit rounded px-1.5 py-0.5 font-mono`,X.test(e.action)?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.action}),(0,J.jsx)(`span`,{className:`truncate`,title:e.agentId,children:e.actor}),(0,J.jsx)(`span`,{className:`truncate text-muted-foreground`,title:e.summary,children:e.summary})]});return t?(0,J.jsxs)(`details`,{className:`group cursor-pointer px-2.5 py-1.5`,children:[(0,J.jsx)(`summary`,{className:`list-none [&::-webkit-details-marker]:hidden`,children:n}),(0,J.jsx)(`pre`,{className:`mt-1.5 max-h-48 overflow-auto rounded border border-border/60 bg-background/60 p-2 font-mono text-[8px] leading-relaxed text-muted-foreground`,children:JSON.stringify(e.raw,null,2)})]}):(0,J.jsx)(`div`,{className:`px-2.5 py-1.5`,children:n})}function ke({text:e}){return(0,J.jsx)(`div`,{className:`px-3 py-3 text-center text-[10px] text-muted-foreground`,children:e})}T.config({monaco:O});function Ae(e){switch(e){case`method`:return E.CompletionItemKind.Method;case`function`:return E.CompletionItemKind.Function;case`constructor`:return E.CompletionItemKind.Constructor;case`field`:return E.CompletionItemKind.Field;case`variable`:return E.CompletionItemKind.Variable;case`class`:return E.CompletionItemKind.Class;case`interface`:return E.CompletionItemKind.Interface;case`module`:return E.CompletionItemKind.Module;case`property`:return E.CompletionItemKind.Property;case`unit`:return E.CompletionItemKind.Unit;case`value`:return E.CompletionItemKind.Value;case`enum`:return E.CompletionItemKind.Enum;case`keyword`:return E.CompletionItemKind.Keyword;case`snippet`:return E.CompletionItemKind.Snippet;case`file`:return E.CompletionItemKind.File;case`reference`:return E.CompletionItemKind.Reference;default:return E.CompletionItemKind.Text}}function je(){let e=A(e=>e.openFiles),t=A(e=>e.activeFilePath),n=A(e=>e.setActiveFile),r=A(e=>e.closeFile);return e.length===0?null:(0,J.jsx)(`div`,{className:`flex items-center border-b bg-muted/40 overflow-x-auto shrink-0`,children:e.map(e=>{let i=e.path===t,a=e.path.split(`/`).pop()??e.path;return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>n(e.path),onMouseDown:t=>{t.button===1&&(t.preventDefault(),r(e.path))},className:k(`group flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r whitespace-nowrap min-w-0 max-w-[180px] transition-colors`,i?`bg-background border-t-2 border-t-primary text-foreground -mb-px`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),title:e.path,children:[e.dirty&&(0,J.jsx)(x,{className:`h-2 w-2 fill-current text-primary shrink-0`}),(0,J.jsx)(`span`,{className:`truncate`,children:a}),(0,J.jsx)(u,{className:k(`h-3 w-3 shrink-0 rounded-sm hover:bg-muted-foreground/20 opacity-0 group-hover:opacity-100 transition-opacity`,i&&`opacity-100`),onClick:t=>{t.stopPropagation(),r(e.path)}})]},e.path)})})}function Me(){let{t:e}=h(),n=A(e=>e.openFiles),r=A(e=>e.activeFilePath),i=A(e=>e.updateContent),{theme:a}=P(),o=(0,q.useRef)(null),s=(0,q.useRef)(r),c=(0,q.useRef)(new Map),u=(0,q.useMemo)(()=>n.find(e=>e.path===r)??null,[n,r]),d=r?H(r):`plaintext`,f=I(),[p,m]=(0,q.useState)(!1);(0,q.useEffect)(()=>{s.current=r},[r]),(0,q.useEffect)(()=>{let e=I();C.setTheme(e)},[a]),(0,q.useEffect)(()=>{let e=R.map(e=>E.registerCompletionItemProvider(e,{triggerCharacters:[`.`,`_`],provideCompletionItems:async(e,t,n,r)=>{let i=s.current;if(!i)return{suggestions:[]};let a=e.getOffsetAt(t),o=e.getValue(),l=o.slice(Math.max(0,a-z),a),u=o.slice(a,a+B),d=e.getLineContent(t.lineNumber).slice(0,Math.max(0,t.column-1)),f=U(d),p={triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind};if(!W(p,f))return{suggestions:[]};let m=`cmp_${Date.now()}_${Math.random().toString(36).slice(2)}`,h=e.getWordUntilPosition(t),g={startLineNumber:t.lineNumber,endLineNumber:t.lineNumber,startColumn:h.startColumn,endColumn:t.column},_=ee(ne.getState().wsUrl),v=e=>e.map((e,t)=>({label:e.label,kind:Ae(e.kind),insertText:e.insertText,detail:e.detail??(e.source?`WrongStack ${e.source}`:void 0),documentation:e.documentation,sortText:e.sortText??`${String(t).padStart(3,`0`)}-${e.label}`,range:g,insertTextRules:e.kind===`snippet`?E.CompletionItemInsertTextRule.InsertAsSnippet:void 0})),y=K({filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,versionId:e.getVersionId(),triggerCharacter:n.triggerCharacter,linePrefix:d,suffix:u}),b=c.current.get(y);return b&&b.expiresAt>Date.now()?{suggestions:v(b.items)}:await new Promise(a=>{let s=!1,d=()=>{},h=null,g,b=e=>{s||(s=!0,d(),g!==void 0&&window.clearTimeout(g),h?.dispose(),a({suggestions:e}))};d=_.on(`completion.result`,e=>{let t=e;t.payload.requestId===m&&(c.current.set(y,{expiresAt:Date.now()+V,items:t.payload.items}),b(v(t.payload.items)))}),g=window.setTimeout(()=>b([]),oe),h=r.onCancellationRequested(()=>b([])),_.requestCompletion({requestId:m,filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,content:o.length<=5e5?o:void 0,prefix:l,suffix:u,triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind,allowLlm:G(p,f)})})}}));return()=>{e.forEach(e=>{e.dispose()})}},[]);let g=(0,q.useCallback)(()=>{let e=o.current;if(!e)return null;let t=e.getSelection();if(!t||t.isEmpty())return null;let n=e.getModel();if(!n)return null;let r=n.getValueInRange(t);return r.trim()?{content:r,startLine:t.startLineNumber,endLine:t.endLineNumber}:null},[]),_=(0,q.useCallback)(()=>{M(`chat`),requestAnimationFrame(()=>{document.querySelector(`[data-chat-textarea]`)?.focus()})},[]),v=(0,q.useCallback)(()=>{let e=s.current;if(!e)return;let t=g();t&&(j.getState().addRef({kind:`snippet`,path:e,startLine:t.startLine,endLine:t.endLine,content:t.content}),_())},[g,_]),y=(0,q.useCallback)(()=>{let e=s.current;e&&(j.getState().addRef({kind:`file`,path:e}),_())},[_]),b=(0,q.useCallback)(t=>{o.current=t,C.setTheme(I()),t.onDidChangeCursorSelection(()=>{let e=t.getSelection();m(!!e&&!e.isEmpty())}),t.addAction({id:`wrongstack-send-to-chat`,label:e(`activity:codeEditor.sendSelectionAction`),contextMenuGroupId:`wrongstack`,contextMenuOrder:0,precondition:void 0,keybindings:[w.CtrlCmd|w.Shift|D.KeyL],run:e=>{let t=e.getSelection();t&&!t.isEmpty()?v():y()}})},[v,y]),x=(0,q.useCallback)(e=>{r&&e!==void 0&&i(r,e)},[r,i]);return(0,q.useEffect)(()=>{let e=e=>{let t=e.ctrlKey||e.metaKey,n=e.target?.tagName?.toLowerCase()===`textarea`||e.target?.closest(`.monaco-editor`)!==null;!t||!n||(e.key.toLowerCase()===`s`&&(e.preventDefault(),window.dispatchEvent(new CustomEvent(`wrongstack:save-file`,{detail:{filePath:r}}))),e.key.toLowerCase()===`w`&&(e.preventDefault(),r&&A.getState().closeFile(r)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),n.length===0?(0,J.jsx)(F,{title:e(`activity:codeEditor.noFilesOpen`),description:e(`activity:codeEditor.selectToEdit`)}):(0,J.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,J.jsx)(je,{}),(0,J.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(p||u)&&(0,J.jsx)(`div`,{className:`absolute top-2 right-2 z-10 flex items-center gap-1 rounded-lg border border-border bg-popover/95 backdrop-blur shadow-md p-1`,children:(0,J.jsxs)(`button`,{type:`button`,onClick:p?v:y,className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[11px] text-foreground hover:bg-accent transition-colors`,title:e(p?`activity:codeEditor.sendSelectedTitle`:`activity:codeEditor.mentionFileTitle`),children:[p?(0,J.jsx)(l,{className:`h-3 w-3`}):(0,J.jsx)(t,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:e(p?`activity:codeEditor.sendToChat`:`activity:codeEditor.mentionFile`)})]})}),u?(0,J.jsx)(S,{language:d,value:u.content,onChange:x,theme:f,onMount:b,loading:(0,J.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,J.jsx)(`span`,{className:`text-[11px] text-muted-foreground animate-pulse`,children:e(`activity:codeEditor.loadingEditor`)})}),options:{minimap:{enabled:!1},fontSize:13,fontFamily:`'IBM Plex Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace`,lineNumbers:`on`,renderWhitespace:`selection`,scrollBeyondLastLine:!1,wordWrap:`off`,tabSize:2,smoothScrolling:!0,cursorBlinking:`smooth`,cursorSmoothCaretAnimation:`on`,bracketPairColorization:{enabled:!0},"semanticHighlighting.enabled":!0,automaticLayout:!0,padding:{top:8}}},u.path):(0,J.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,J.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`activity:codeEditor.selectTab`)})})]}),u&&(0,J.jsx)(be,{file:u})]})}export{Me as CodeEditor};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ir as t,Ji as n,Kn as r,Li as i,Nt as a,Pi as o,Ur as s,Wt as c,Xt as l,at as u,br as d,cn as f,et as p,ft as m,ga as h,ki as g,pa as _,qn as v,qr as y,xa as b,xi as x,y as S}from"./vendor-9hC4n4Me.js";import"./i18n-C2VyJ0Kz.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./monaco-BLUV5g0U.js";import{t as ee}from"./ws-client-eyEv8wbm.js";import{t as k}from"./utils-DzRQUvln.js";import{i as te}from"./codemap-activity-store-CkJTt5go.js";import{D as A,M as ne,k as j,o as re,u as ie}from"./stores-hEu6z1qz.js";import{o as M}from"./view-navigation-BSA3_knE.js";import{T as N,d as P,w as ae}from"./index-DSXHr5yP.js";import{t as F}from"./empty-state-DoEewhfx.js";import{t as I}from"./monaco-theme-DSeCDzQy.js";var L={ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,json:`json`,css:`css`,html:`html`,svg:`xml`,md:`markdown`,yml:`yaml`,yaml:`yaml`,toml:`toml`,sh:`shell`,bash:`shell`,ps1:`powershell`,py:`python`,rs:`rust`,go:`go`,rb:`ruby`,java:`java`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,sql:`sql`,xml:`xml`},R=Array.from(new Set(Object.values(L))).filter(e=>e!==`plaintext`),z=12e3,B=4e3,oe=5e3,V=1e4;function H(e){return L[e.split(`.`).pop()?.toLowerCase()??``]??`plaintext`}function U(e){return e.match(/([A-Za-z_$][\w$]*)$/)?.[1]??``}function W(e,t){return e.triggerCharacter?!0:t.length>=3}function G(e,t){return e.triggerCharacter===`.`||!e.triggerCharacter&&/^(findBy|findAllBy|create|update|delete|remove|get[A-Z_]|set[A-Z_]|use[A-Z_])/.test(t)}function K(e){return[e.filePath,e.language,e.lineNumber,e.column,e.versionId??``,e.triggerCharacter??``,e.linePrefix.slice(-160),e.suffix.slice(0,160)].join(`\0`)}var q=e(b(),1),J=p();function se(e){let t=new Set,n=new Set,r=new Set,i=new Set,a=new Set,o,s;for(let c of e)c.sessionId&&t.add(c.sessionId),c.taskId&&n.add(c.taskId),c.boardId&&r.add(c.boardId),c.toolName&&i.add(c.toolName),c.modelId&&a.add(c.modelId),(!o||c.occurredAt<o)&&(o=c.occurredAt),(!s||c.occurredAt>s)&&(s=c.occurredAt);return{mutations:e.length,sessions:t.size,tasks:n.size,boards:r.size,tools:[...i],models:[...a],firstAt:o,lastAt:s}}var Y=150,ce=224,le=38,X=/(write|edit|update|create|delete|rename|modified|changed)/i;function Z(e){return e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/\/{2,}/g,`/`).toLowerCase()}function Q(e,t){let n=Z(e),r=Z(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function ue(e,t=Date.now()){let n=e.filter(e=>t-e.at<=30*6e4),r=n.filter(e=>X.test(e.action)),i=new Set(n.map(e=>e.sessionId).filter(Boolean)).size,a=new Set(n.map(e=>e.actor).filter(Boolean)).size,o=new Set(n.map(e=>e.taskId).filter(Boolean)).size;return{level:r.length>=8||r.length>=4&&a>=3?`churn`:r.length>0?`active`:`quiet`,mutationCount:r.length,sessionCount:i,actorCount:a,taskCount:o}}function $(e){return typeof e==`string`&&e.length>0?e:void 0}function de(e){let t=Date.parse(e.occurredAt??e.observedAt);return Number.isFinite(t)?t:Date.now()}function fe(e){let t=e.attributes??{},n=$(t.operation)??e.eventType,r=e.scope.agentId,i=e.runtime?.providerId,a=e.runtime?.modelId;return{id:e.eventId,at:de(e),action:n,actor:r??i??$(t.actor)??`external`,source:$(t.source)??e.tags?.collector??`chronicle`,summary:[e.eventType,i&&a?`${i}/${a}`:i,e.outcome].filter(Boolean).join(` · `),sessionId:e.scope.sessionId,agentId:r,taskId:e.scope.taskId??$(t.taskId),boardId:$(t.boardId)??e.scope.boardId,tool:$(t.toolName),status:e.outcome,raw:e}}function pe(e){return{id:e.id??`${e.filePath}:${e.timestamp}:${e.type}`,at:e.timestamp,action:e.type,actor:e.agentName??e.agent??e.agentId??`external`,source:e.source??`live`,summary:e.summary,sessionId:e.sessionId,agentId:e.agentId,tool:e.toolName,status:e.status,raw:e}}function me(e){let t=new Set;return e.sort((e,t)=>t.at-e.at).filter(e=>{let n=`${e.id}:${e.at}`;return t.has(n)?!1:(t.add(n),!0)})}function he(e){return e?e.split(/\r?\n/).length:0}function ge(e){return new TextEncoder().encode(e).length}function _e(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ve(e){return e.length>18?`${e.slice(0,8)}…${e.slice(-6)}`:e}function ye(e,t){let n=N(e,t);return n?{added:n.filter(e=>e.kind===`add`).length,removed:n.filter(e=>e.kind===`del`).length,large:!1}:{added:0,removed:0,large:!0}}function be({file:e}){let{t}=h(),[n,r]=(0,q.useState)(!0),[c,l]=(0,q.useState)(ce),[u,p]=(0,q.useState)(`overview`),[m,b]=(0,q.useState)([]),[x,S]=(0,q.useState)([]),[C,w]=(0,q.useState)(!1),[T,E]=(0,q.useState)(null),[D,O]=(0,q.useState)(null),A=(0,q.useRef)(null),j=ne(e=>e.wsUrl),M=te(e=>e.history),N=te(e=>e.activeOperations),P=ie(e=>e.activeBoard),F=re(e=>e.snapshot),I=(0,q.useMemo)(()=>ee(j),[j]),L=(0,q.useCallback)(()=>{E(null),w(!0),typeof I.getGitDiff==`function`&&I.getGitDiff(e.path);let t=typeof I.supportsCapability==`function`?I.supportsCapability.bind(I):null;t?.(`chronicle.query`)?I.send({type:`chronicle.query`,payload:{query:{path:e.path,resourceKind:`file`,order:`desc`,limit:150}}}):w(!1),t?.(`chronicle.metrics`)&&I.send({type:`chronicle.metrics`,payload:{view:`files`,path:e.path,limit:1e3}})},[I,e.path]);(0,q.useEffect)(()=>{b([]),S([]),O(null);let t=I.on(`chronicle.query_result`,t=>{if(t.type!==`chronicle.query_result`)return;let n=t.payload.events.filter(t=>t.resource?.path&&Q(t.resource.path,e.path));t.payload.events.length>0&&n.length===0||(b(n),w(!1))}),n=I.on(`chronicle.metrics_result`,t=>{t.type!==`chronicle.metrics_result`||t.payload.view!==`files`||S(t.payload.data.filter(t=>Q(t.path,e.path)))}),r=I.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(E(e.payload.message),w(!1))}),i=I.on(`git.diff`,t=>{if(t.type!==`git.diff`||!Q(t.payload.path,e.path))return;let n=t.payload;if(n.error||n.binary||n.tooLarge){O({text:e.savedContent,available:!1,error:n.error});return}O({text:n.oldText??``,available:!0})});return L(),()=>{t(),n(),r(),i()}},[I,e.path,e.savedContent,L]),(0,q.useEffect)(()=>{let e=e=>{if(!A.current)return;let t=A.current.startY-e.clientY,n=Math.max(Y,Math.floor(window.innerHeight*.62));l(Math.min(n,Math.max(Y,A.current.startHeight+t)))},t=()=>{A.current=null,document.body.style.cursor=``,document.body.style.userSelect=``};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},[]);let R=(0,q.useMemo)(()=>{let t=[];for(let[n,r]of M)Q(n,e.path)&&t.push(...r);for(let n of N.values())t.push(...n.filter(t=>Q(t.filePath,e.path)));return t},[N,e.path,M]),z=(0,q.useMemo)(()=>me([...R.map(pe),...m.map(fe)]),[m,R]),B=(0,q.useMemo)(()=>ue(z),[z]),oe=(0,q.useMemo)(()=>se(x),[x]),V=D?.text??e.savedContent,H=(0,q.useMemo)(()=>ye(V,e.content),[V,e.content]),U=(0,q.useMemo)(()=>[...new Set(z.map(e=>e.sessionId).filter(e=>!!e))],[z]),W=(0,q.useMemo)(()=>[...new Set(z.map(e=>e.actor).filter(Boolean))],[z]),G=(0,q.useMemo)(()=>[...new Set(z.map(e=>e.taskId).filter(e=>!!e))],[z]),K=(0,q.useCallback)(e=>{let t=P?.tasks.find(t=>t.id===e),n=F?.tasks.find(t=>t.id===e||t.shortId===e);return t?.title??n?.title??e},[P,F]),X=e=>{n||r(!0),A.current={startY:e.clientY,startHeight:n?c:Y},document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`},Z=[{id:`overview`,label:t(`activity:fileActivity.overview`),icon:(0,J.jsx)(_,{})},{id:`changes`,label:t(`activity:fileActivity.changes`),icon:(0,J.jsx)(s,{})},{id:`context`,label:t(`activity:fileActivity.context`),icon:(0,J.jsx)(v,{})},{id:`logs`,label:t(`activity:fileActivity.logs`),icon:(0,J.jsx)(a,{})}];return(0,J.jsxs)(`section`,{className:`flex shrink-0 flex-col overflow-hidden border-t border-border bg-card/95 shadow-[0_-10px_30px_hsl(var(--background)/0.24)] backdrop-blur`,style:{height:n?c:le},"data-testid":`file-activity-drawer`,children:[(0,J.jsx)(`button`,{type:`button`,"aria-label":t(`activity:fileActivity.resizeHint`),className:`group relative block h-2 w-full cursor-ns-resize touch-none`,onPointerDown:X,onDoubleClick:()=>{r(!0),l(ce)},title:t(`activity:fileActivity.resizeHint`),children:(0,J.jsx)(`span`,{className:`absolute left-1/2 top-0.5 h-1 w-10 -translate-x-1/2 rounded-full bg-border transition-colors group-hover:bg-primary/60`})}),(0,J.jsxs)(`header`,{className:`flex h-[30px] min-w-0 items-center gap-2 border-b border-border/70 px-2.5`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`inline-flex min-w-0 items-center gap-1.5 rounded px-1.5 py-1 text-[11px] font-semibold hover:bg-muted`,"aria-expanded":n,children:[(0,J.jsx)(y,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,J.jsx)(`span`,{className:`truncate`,children:t(`activity:fileActivity.title`)}),n?(0,J.jsx)(i,{className:`h-3 w-3`}):(0,J.jsx)(o,{className:`h-3 w-3`})]}),(0,J.jsx)(`span`,{className:`hidden h-3 w-px bg-border sm:block`}),(0,J.jsx)(xe,{label:`${he(e.content)} ${t(`activity:fileActivity.lines`)}`}),(0,J.jsx)(xe,{label:_e(ge(e.content))}),!H.large&&(H.added>0||H.removed>0)&&(0,J.jsxs)(`span`,{className:`hidden items-center gap-1 font-mono text-[10px] md:flex`,children:[(0,J.jsxs)(`span`,{className:`text-success`,children:[`+`,H.added]}),(0,J.jsxs)(`span`,{className:`text-destructive`,children:[`−`,H.removed]})]}),(0,J.jsxs)(`span`,{className:k(`ml-auto inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[9px] font-semibold uppercase tracking-wide`,B.level===`churn`&&`bg-destructive/10 text-destructive`,B.level===`active`&&`bg-warning/10 text-warning`,B.level===`quiet`&&`bg-success/10 text-success`),children:[(0,J.jsx)(g,{className:`h-2.5 w-2.5`}),t(`activity:fileActivity.level.${B.level}`)]}),(0,J.jsx)(`span`,{className:`hidden text-[9px] text-muted-foreground lg:inline`,children:t(`activity:fileActivity.evidenceCount`,{count:z.length})}),n&&(0,J.jsx)(`button`,{type:`button`,onClick:L,className:`rounded p-1 text-muted-foreground hover:bg-muted hover:text-foreground`,title:t(`activity:fileActivity.refresh`),children:(0,J.jsx)(f,{className:k(`h-3.5 w-3.5`,C&&`animate-spin`)})})]}),n&&(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,J.jsxs)(`nav`,{className:`flex shrink-0 items-center gap-0.5 border-b border-border/60 bg-muted/20 px-2`,children:[Z.map(e=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>p(e.id),className:k(`inline-flex h-7 items-center gap-1.5 border-b-2 px-2 text-[10px] transition-colors [&>svg]:h-3 [&>svg]:w-3`,u===e.id?`border-primary font-medium text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.icon,e.label]},e.id)),T&&(0,J.jsx)(`span`,{className:`ml-auto truncate px-2 text-[9px] text-warning`,children:T})]}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[u===`overview`&&(0,J.jsx)(Se,{analysis:B,lifetime:oe,records:z,sessions:U,agents:W,tasks:G,taskLabel:K}),u===`changes`&&(0,J.jsxs)(`div`,{className:`h-full min-h-[120px] p-2`,children:[(0,J.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2 text-[9px] text-muted-foreground`,children:[(0,J.jsx)(d,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:D?.available?t(`activity:fileActivity.gitToBuffer`):t(`activity:fileActivity.savedToBuffer`)}),e.dirty&&(0,J.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:t(`activity:fileActivity.unsaved`)}),D?.error&&(0,J.jsx)(`span`,{className:`truncate text-warning`,children:D.error})]}),(0,J.jsx)(`div`,{className:`h-[calc(100%-24px)] min-h-[90px]`,children:(0,J.jsx)(ae,{oldText:V,newText:e.content,caption:e.path,fill:!0})})]}),u===`context`&&(0,J.jsx)(we,{sessions:U,agents:W,tasks:G,records:z,taskLabel:K,boardTitle:P?.title??F?.title}),u===`logs`&&(0,J.jsx)(De,{records:z,loading:C})]})]})]})}function xe({label:e}){return(0,J.jsx)(`span`,{className:`hidden whitespace-nowrap font-mono text-[9px] text-muted-foreground sm:inline`,children:e})}function Se({analysis:e,lifetime:t,records:r,sessions:i,agents:a,tasks:o,taskLabel:l}){let{t:u}=h();return(0,J.jsxs)(`div`,{className:`grid min-h-full grid-cols-1 gap-2 p-2 lg:grid-cols-[minmax(360px,.9fr)_minmax(420px,1.35fr)]`,children:[(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:[{label:u(`activity:fileActivity.mutations30m`),value:e.mutationCount,icon:(0,J.jsx)(s,{})},{label:u(`activity:fileActivity.sessions`),value:i.length,icon:(0,J.jsx)(m,{})},{label:u(`activity:fileActivity.actors`),value:a.length,icon:(0,J.jsx)(n,{})},{label:u(`activity:fileActivity.linkedWork`),value:o.length,icon:(0,J.jsx)(v,{})}].map(e=>(0,J.jsxs)(`div`,{className:`rounded-md border border-border/70 bg-background/45 px-2 py-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1 text-[9px] text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e.icon,(0,J.jsx)(`span`,{className:`truncate`,children:e.label})]}),(0,J.jsx)(`div`,{className:`mt-0.5 font-mono text-sm font-semibold`,children:e.value})]},e.label))}),t.mutations>0&&(0,J.jsx)(Ce,{lifetime:t}),(0,J.jsxs)(`div`,{className:k(`flex items-start gap-2 rounded-md border px-2.5 py-2 text-[10px]`,e.level===`churn`?`border-destructive/25 bg-destructive/[0.055]`:`border-border/70 bg-background/45`),children:[(0,J.jsx)(c,{className:k(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.level===`churn`?`text-destructive`:`text-primary`)}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`font-semibold`,children:u(`activity:fileActivity.analysisTitle.${e.level}`)}),(0,J.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:u(`activity:fileActivity.analysisBody.${e.level}`,{mutations:e.mutationCount,actors:e.actorCount,sessions:e.sessionCount})})]})]}),o.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 text-[9px]`,children:[(0,J.jsxs)(`span`,{className:`text-muted-foreground`,children:[u(`activity:fileActivity.workLinks`),`:`]}),o.slice(0,4).map(e=>(0,J.jsx)(`span`,{className:`max-w-[180px] truncate rounded border border-primary/20 bg-primary/5 px-1.5 py-0.5 text-primary`,title:e,children:l(e)},e))]})]}),(0,J.jsxs)(`div`,{className:`min-w-0 rounded-md border border-border/70 bg-background/35`,children:[(0,J.jsx)(`div`,{className:`border-b border-border/60 px-2.5 py-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:u(`activity:fileActivity.recentActivity`)}),(0,J.jsx)(`div`,{className:`divide-y divide-border/40`,children:r.length===0?(0,J.jsx)(ke,{text:u(`activity:fileActivity.noEvidence`)}):r.slice(0,5).map(e=>(0,J.jsx)(Oe,{record:e},`${e.id}:${e.at}`))})]})]})}function Ce({lifetime:e}){let{t}=h(),n=[{value:e.mutations,label:t(`activity:fileActivity.lifetimeChanges`)},{value:e.sessions,label:t(`activity:fileActivity.lifetimeSessions`)},{value:e.tasks,label:t(`activity:fileActivity.lifetimeTasks`)},{value:e.boards,label:t(`activity:fileActivity.lifetimeBoards`)}],r=e.firstAt?new Date(e.firstAt).toLocaleDateString():void 0;return(0,J.jsxs)(`div`,{className:`rounded-md border border-primary/15 bg-primary/[0.03] px-2.5 py-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[9px] font-semibold uppercase tracking-wider text-primary [&>svg]:h-3 [&>svg]:w-3`,children:[(0,J.jsx)(y,{}),t(`activity:fileActivity.lifetimeTitle`)]}),(0,J.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[9px] text-muted-foreground`,children:[n.map(e=>(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{className:`text-foreground`,children:e.value.toLocaleString()}),` `,e.label]},e.label)),r&&(0,J.jsx)(`span`,{children:t(`activity:fileActivity.lifetimeSince`,{date:r})})]}),e.tools.length>0&&(0,J.jsx)(`div`,{className:`mt-1 truncate font-mono text-[8px] text-muted-foreground`,title:e.tools.join(`, `),children:t(`activity:fileActivity.lifetimeTools`,{tools:e.tools.slice(0,6).join(`, `)})})]})}function we({sessions:e,agents:t,tasks:r,records:i,taskLabel:a,boardTitle:o}){let{t:s}=h();return(0,J.jsxs)(`div`,{className:`grid min-h-full grid-cols-1 divide-y divide-border/50 md:grid-cols-3 md:divide-x md:divide-y-0`,children:[(0,J.jsx)(Te,{icon:(0,J.jsx)(m,{}),title:s(`activity:fileActivity.sessions`),empty:s(`activity:fileActivity.noSessions`),children:e.map(e=>(0,J.jsx)(Ee,{title:ve(e),subtitle:`${i.filter(t=>t.sessionId===e).length} ${s(`activity:fileActivity.events`)}`,raw:e},e))}),(0,J.jsx)(Te,{icon:(0,J.jsx)(n,{}),title:s(`activity:fileActivity.actors`),empty:s(`activity:fileActivity.noActors`),children:t.map(e=>(0,J.jsx)(Ee,{title:e,subtitle:`${i.filter(t=>t.actor===e).length} ${s(`activity:fileActivity.events`)}`},e))}),(0,J.jsx)(Te,{icon:(0,J.jsx)(v,{}),title:s(`activity:fileActivity.workLinks`),empty:s(`activity:fileActivity.noWorkLinks`),children:r.map(e=>(0,J.jsx)(Ee,{title:a(e),subtitle:o??s(`activity:fileActivity.taskOrTodo`),raw:e},e))})]})}function Te({icon:e,title:t,empty:n,children:r}){let i=Array.isArray(r)?r.length>0:!!r;return(0,J.jsxs)(`section`,{className:`min-w-0 p-2`,children:[(0,J.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground [&>svg]:h-3 [&>svg]:w-3`,children:[e,t]}),(0,J.jsx)(`div`,{className:`space-y-1`,children:i?r:(0,J.jsx)(ke,{text:n})})]})}function Ee({title:e,subtitle:t,raw:n}){return(0,J.jsxs)(`div`,{className:`rounded-md border border-border/60 bg-background/45 px-2 py-1.5`,title:n,children:[(0,J.jsx)(`div`,{className:`truncate text-[10px] font-medium`,children:e}),(0,J.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[8px] text-muted-foreground`,children:t})]})}function De({records:e,loading:t}){let{t:n}=h();return t&&e.length===0?(0,J.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-[10px] text-muted-foreground`,children:[(0,J.jsx)(r,{className:`h-3.5 w-3.5 animate-spin`}),n(`activity:fileActivity.loadingEvidence`)]}):e.length===0?(0,J.jsx)(ke,{text:n(`activity:fileActivity.noEvidence`)}):(0,J.jsx)(`div`,{className:`divide-y divide-border/40`,children:e.map(e=>(0,J.jsx)(Oe,{record:e,raw:!0},`${e.id}:${e.at}`))})}function Oe({record:e,raw:t=!1}){let n=(0,J.jsxs)(`div`,{className:`grid grid-cols-[62px_74px_minmax(90px,.7fr)_minmax(160px,1.5fr)] items-center gap-2 text-[9px]`,children:[(0,J.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:new Date(e.at).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}),(0,J.jsx)(`span`,{className:k(`w-fit rounded px-1.5 py-0.5 font-mono`,X.test(e.action)?`bg-warning/10 text-warning`:`bg-primary/10 text-primary`),children:e.action}),(0,J.jsx)(`span`,{className:`truncate`,title:e.agentId,children:e.actor}),(0,J.jsx)(`span`,{className:`truncate text-muted-foreground`,title:e.summary,children:e.summary})]});return t?(0,J.jsxs)(`details`,{className:`group cursor-pointer px-2.5 py-1.5`,children:[(0,J.jsx)(`summary`,{className:`list-none [&::-webkit-details-marker]:hidden`,children:n}),(0,J.jsx)(`pre`,{className:`mt-1.5 max-h-48 overflow-auto rounded border border-border/60 bg-background/60 p-2 font-mono text-[8px] leading-relaxed text-muted-foreground`,children:JSON.stringify(e.raw,null,2)})]}):(0,J.jsx)(`div`,{className:`px-2.5 py-1.5`,children:n})}function ke({text:e}){return(0,J.jsx)(`div`,{className:`px-3 py-3 text-center text-[10px] text-muted-foreground`,children:e})}T.config({monaco:O});function Ae(e){switch(e){case`method`:return E.CompletionItemKind.Method;case`function`:return E.CompletionItemKind.Function;case`constructor`:return E.CompletionItemKind.Constructor;case`field`:return E.CompletionItemKind.Field;case`variable`:return E.CompletionItemKind.Variable;case`class`:return E.CompletionItemKind.Class;case`interface`:return E.CompletionItemKind.Interface;case`module`:return E.CompletionItemKind.Module;case`property`:return E.CompletionItemKind.Property;case`unit`:return E.CompletionItemKind.Unit;case`value`:return E.CompletionItemKind.Value;case`enum`:return E.CompletionItemKind.Enum;case`keyword`:return E.CompletionItemKind.Keyword;case`snippet`:return E.CompletionItemKind.Snippet;case`file`:return E.CompletionItemKind.File;case`reference`:return E.CompletionItemKind.Reference;default:return E.CompletionItemKind.Text}}function je(){let e=A(e=>e.openFiles),t=A(e=>e.activeFilePath),n=A(e=>e.setActiveFile),r=A(e=>e.closeFile);return e.length===0?null:(0,J.jsx)(`div`,{className:`flex items-center border-b bg-muted/40 overflow-x-auto shrink-0`,children:e.map(e=>{let i=e.path===t,a=e.path.split(`/`).pop()??e.path;return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>n(e.path),onMouseDown:t=>{t.button===1&&(t.preventDefault(),r(e.path))},className:k(`group flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r whitespace-nowrap min-w-0 max-w-[180px] transition-colors`,i?`bg-background border-t-2 border-t-primary text-foreground -mb-px`:`text-muted-foreground hover:bg-muted/60 hover:text-foreground`),title:e.path,children:[e.dirty&&(0,J.jsx)(x,{className:`h-2 w-2 fill-current text-primary shrink-0`}),(0,J.jsx)(`span`,{className:`truncate`,children:a}),(0,J.jsx)(u,{className:k(`h-3 w-3 shrink-0 rounded-sm hover:bg-muted-foreground/20 opacity-0 group-hover:opacity-100 transition-opacity`,i&&`opacity-100`),onClick:t=>{t.stopPropagation(),r(e.path)}})]},e.path)})})}function Me(){let{t:e}=h(),n=A(e=>e.openFiles),r=A(e=>e.activeFilePath),i=A(e=>e.updateContent),{theme:a}=P(),o=(0,q.useRef)(null),s=(0,q.useRef)(r),c=(0,q.useRef)(new Map),u=(0,q.useMemo)(()=>n.find(e=>e.path===r)??null,[n,r]),d=r?H(r):`plaintext`,f=I(),[p,m]=(0,q.useState)(!1);(0,q.useEffect)(()=>{s.current=r},[r]),(0,q.useEffect)(()=>{let e=I();C.setTheme(e)},[a]),(0,q.useEffect)(()=>{let e=R.map(e=>E.registerCompletionItemProvider(e,{triggerCharacters:[`.`,`_`],provideCompletionItems:async(e,t,n,r)=>{let i=s.current;if(!i)return{suggestions:[]};let a=e.getOffsetAt(t),o=e.getValue(),l=o.slice(Math.max(0,a-z),a),u=o.slice(a,a+B),d=e.getLineContent(t.lineNumber).slice(0,Math.max(0,t.column-1)),f=U(d),p={triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind};if(!W(p,f))return{suggestions:[]};let m=`cmp_${Date.now()}_${Math.random().toString(36).slice(2)}`,h=e.getWordUntilPosition(t),g={startLineNumber:t.lineNumber,endLineNumber:t.lineNumber,startColumn:h.startColumn,endColumn:t.column},_=ee(ne.getState().wsUrl),v=e=>e.map((e,t)=>({label:e.label,kind:Ae(e.kind),insertText:e.insertText,detail:e.detail??(e.source?`WrongStack ${e.source}`:void 0),documentation:e.documentation,sortText:e.sortText??`${String(t).padStart(3,`0`)}-${e.label}`,range:g,insertTextRules:e.kind===`snippet`?E.CompletionItemInsertTextRule.InsertAsSnippet:void 0})),y=K({filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,versionId:e.getVersionId(),triggerCharacter:n.triggerCharacter,linePrefix:d,suffix:u}),b=c.current.get(y);return b&&b.expiresAt>Date.now()?{suggestions:v(b.items)}:await new Promise(a=>{let s=!1,d=()=>{},h=null,g,b=e=>{s||(s=!0,d(),g!==void 0&&window.clearTimeout(g),h?.dispose(),a({suggestions:e}))};d=_.on(`completion.result`,e=>{let t=e;t.payload.requestId===m&&(c.current.set(y,{expiresAt:Date.now()+V,items:t.payload.items}),b(v(t.payload.items)))}),g=window.setTimeout(()=>b([]),oe),h=r.onCancellationRequested(()=>b([])),_.requestCompletion({requestId:m,filePath:i,language:e.getLanguageId(),lineNumber:t.lineNumber,column:t.column,content:o.length<=5e5?o:void 0,prefix:l,suffix:u,triggerCharacter:n.triggerCharacter,triggerKind:n.triggerKind,allowLlm:G(p,f)})})}}));return()=>{e.forEach(e=>{e.dispose()})}},[]);let g=(0,q.useCallback)(()=>{let e=o.current;if(!e)return null;let t=e.getSelection();if(!t||t.isEmpty())return null;let n=e.getModel();if(!n)return null;let r=n.getValueInRange(t);return r.trim()?{content:r,startLine:t.startLineNumber,endLine:t.endLineNumber}:null},[]),_=(0,q.useCallback)(()=>{M(`chat`),requestAnimationFrame(()=>{document.querySelector(`[data-chat-textarea]`)?.focus()})},[]),v=(0,q.useCallback)(()=>{let e=s.current;if(!e)return;let t=g();t&&(j.getState().addRef({kind:`snippet`,path:e,startLine:t.startLine,endLine:t.endLine,content:t.content}),_())},[g,_]),y=(0,q.useCallback)(()=>{let e=s.current;e&&(j.getState().addRef({kind:`file`,path:e}),_())},[_]),b=(0,q.useCallback)(t=>{o.current=t,C.setTheme(I()),t.onDidChangeCursorSelection(()=>{let e=t.getSelection();m(!!e&&!e.isEmpty())}),t.addAction({id:`wrongstack-send-to-chat`,label:e(`activity:codeEditor.sendSelectionAction`),contextMenuGroupId:`wrongstack`,contextMenuOrder:0,precondition:void 0,keybindings:[w.CtrlCmd|w.Shift|D.KeyL],run:e=>{let t=e.getSelection();t&&!t.isEmpty()?v():y()}})},[v,y]),x=(0,q.useCallback)(e=>{r&&e!==void 0&&i(r,e)},[r,i]);return(0,q.useEffect)(()=>{let e=e=>{let t=e.ctrlKey||e.metaKey,n=e.target?.tagName?.toLowerCase()===`textarea`||e.target?.closest(`.monaco-editor`)!==null;!t||!n||(e.key.toLowerCase()===`s`&&(e.preventDefault(),window.dispatchEvent(new CustomEvent(`wrongstack:save-file`,{detail:{filePath:r}}))),e.key.toLowerCase()===`w`&&(e.preventDefault(),r&&A.getState().closeFile(r)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]),n.length===0?(0,J.jsx)(F,{title:e(`activity:codeEditor.noFilesOpen`),description:e(`activity:codeEditor.selectToEdit`)}):(0,J.jsxs)(`div`,{className:`flex h-full min-w-0 flex-col overflow-hidden`,children:[(0,J.jsx)(je,{}),(0,J.jsxs)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(p||u)&&(0,J.jsx)(`div`,{className:`absolute top-2 right-2 z-10 flex items-center gap-1 rounded-lg border border-border bg-popover/95 backdrop-blur shadow-md p-1`,children:(0,J.jsxs)(`button`,{type:`button`,onClick:p?v:y,className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[11px] text-foreground hover:bg-accent transition-colors`,title:e(p?`activity:codeEditor.sendSelectedTitle`:`activity:codeEditor.mentionFileTitle`),children:[p?(0,J.jsx)(l,{className:`h-3 w-3`}):(0,J.jsx)(t,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:e(p?`activity:codeEditor.sendToChat`:`activity:codeEditor.mentionFile`)})]})}),u?(0,J.jsx)(S,{language:d,value:u.content,onChange:x,theme:f,onMount:b,loading:(0,J.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,J.jsx)(`span`,{className:`text-[11px] text-muted-foreground animate-pulse`,children:e(`activity:codeEditor.loadingEditor`)})}),options:{minimap:{enabled:!1},fontSize:13,fontFamily:`'IBM Plex Mono', 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace`,lineNumbers:`on`,renderWhitespace:`selection`,scrollBeyondLastLine:!1,wordWrap:`off`,tabSize:2,smoothScrolling:!0,cursorBlinking:`smooth`,cursorSmoothCaretAnimation:`on`,bracketPairColorization:{enabled:!0},"semanticHighlighting.enabled":!0,automaticLayout:!0,padding:{top:8}}},u.path):(0,J.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,J.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e(`activity:codeEditor.selectTab`)})})]}),u&&(0,J.jsx)(be,{file:u})]})}export{Me as CodeEditor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Di as t,Ei as n,et as r,gi as i,rn as a,xa as o}from"./vendor-9hC4n4Me.js";import{A as s}from"./stores-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Di as t,Ei as n,et as r,gi as i,rn as a,xa as o}from"./vendor-9hC4n4Me.js";import{A as s}from"./stores-hEu6z1qz.js";import{a as c,n as l,o as u,r as d,t as f}from"./dialog-BLr7olIX.js";import{l as p,y as m}from"./index-DSXHr5yP.js";var h=e(o(),1),g=r();function _(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:e<36e5?`${(e/6e4).toFixed(1)}m`:`${(e/36e5).toFixed(1)}h`}function v(e){if(!e)return`—`;let t=new Date(e),n=Date.now(),r=t.getTime()-n,i=Math.abs(r);if(i<6e4)return r>=0?`<1m`:`<1m ago`;if(i<36e5){let e=Math.round(i/6e4);return r>=0?`${e}m`:`${e}m ago`}if(i<864e5){let e=Math.round(i/36e5);return r>=0?`${e}h`:`${e}h ago`}return t.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function y({enabled:e,overdue:r}){return e?r?(0,g.jsxs)(p,{variant:`destructive`,className:`gap-1`,children:[(0,g.jsx)(i,{className:`h-3 w-3`}),`Overdue`]}):(0,g.jsxs)(p,{variant:`default`,className:`gap-1 bg-emerald-600 hover:bg-emerald-600`,children:[(0,g.jsx)(n,{className:`h-3 w-3`}),`Active`]}):(0,g.jsxs)(p,{variant:`secondary`,className:`gap-1`,children:[(0,g.jsx)(t,{className:`h-3 w-3`}),`Disabled`]})}function b({open:e,onClose:t}){let n=s(e=>e.snapshot),r=s(e=>e.lastFiredAt);s(e=>e.revision);let o=n?.jobs??[],p=n?.count??0,b=n?.maxConcurrent??0,x=o.filter(e=>e.overdue).length,S=o.filter(e=>e.enabled).length,C=o.reduce((e,t)=>e+t.runCount,0);return(0,g.jsx)(f,{open:e,onOpenChange:(0,h.useCallback)(e=>{e||t()},[t]),children:(0,g.jsxs)(l,{className:`max-w-3xl max-h-[80vh] flex flex-col`,children:[(0,g.jsxs)(c,{children:[(0,g.jsxs)(u,{className:`flex items-center gap-2`,children:[(0,g.jsx)(a,{className:`h-5 w-5`}),`Cron Jobs`]}),(0,g.jsx)(d,{children:`Scheduled recurring tasks managed by the cron plugin.`})]}),p>0&&(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-sm text-muted-foreground border-b border-border/70 pb-3`,children:[(0,g.jsxs)(`span`,{className:`font-medium text-foreground`,children:[p,` job`,p===1?``:`s`]}),(0,g.jsxs)(`span`,{className:`text-emerald-500`,children:[S,` enabled`]}),x>0&&(0,g.jsxs)(`span`,{className:`text-destructive`,children:[x,` overdue`]}),(0,g.jsxs)(`span`,{children:[C,` total runs`]}),(0,g.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[`max `,b,` concurrent`]})]}),p===0&&(0,g.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-12 text-muted-foreground`,children:[(0,g.jsx)(i,{className:`h-8 w-8 opacity-40`}),(0,g.jsx)(`p`,{className:`text-sm`,children:`No cron jobs scheduled.`}),(0,g.jsxs)(`p`,{className:`text-xs`,children:[`Use `,(0,g.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:`cron_schedule`}),` to add one.`]})]}),p>0&&(0,g.jsx)(m,{className:`flex-1 -mx-6 px-6`,children:(0,g.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{className:`border-b border-border/50 text-left text-xs text-muted-foreground`,children:[(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Status`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Name`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Interval`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium text-right`,children:`Runs`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Next Run`}),(0,g.jsx)(`th`,{className:`pb-2 pr-3 font-medium`,children:`Last Run`}),(0,g.jsx)(`th`,{className:`pb-2 font-medium`,children:`Action`})]})}),(0,g.jsx)(`tbody`,{children:o.map(e=>(0,g.jsxs)(`tr`,{className:`border-b border-border/30 last:border-0`,children:[(0,g.jsx)(`td`,{className:`py-2.5 pr-3`,children:(0,g.jsx)(y,{enabled:e.enabled,overdue:e.overdue})}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs font-medium max-w-[160px] truncate`,title:e.name,children:e.name}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:_(e.intervalMs)}),(0,g.jsxs)(`td`,{className:`py-2.5 pr-3 text-right font-mono text-xs tabular-nums`,children:[e.runCount,r[e.name]&&(0,g.jsx)(`span`,{className:`ml-1 text-emerald-500`,title:`Last fired at ${r[e.name]}`,children:`●`})]}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:v(e.nextRun)}),(0,g.jsx)(`td`,{className:`py-2.5 pr-3 font-mono text-xs tabular-nums`,children:v(e.lastRun)}),(0,g.jsx)(`td`,{className:`py-2.5 font-mono text-xs max-w-[200px] truncate text-muted-foreground`,title:e.action,children:e.action})]},e.name))})]})}),p>0&&(0,g.jsxs)(`p`,{className:`text-xs text-muted-foreground pt-3 border-t border-border/70`,children:[`Use `,(0,g.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-[11px]`,children:`cron_schedule`}),` to add,`,(0,g.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-[11px] ml-1`,children:`cron_cancel`}),` to remove.`]})]})})}export{b as CronJobsPanel};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{et as t,xa as n}from"./vendor-9hC4n4Me.js";var r=e(n(),1),i=t(),a={0:`P0 Dead Package`,1:`P1 Dead File`,2:`P2 Dead Symbol`},o={0:`hsl(var(--destructive))`,1:`hsl(var(--warning))`,2:`hsl(var(--info))`};async function s(e){let t=await e.text();try{return JSON.parse(t)}catch{let e=t.length>300?`${t.slice(0,300)}…`:t;throw console.warn(JSON.stringify({level:`warn`,event:`deadcode_parse_error`,preview:e,timestamp:new Date().toISOString()})),Error(`The server returned a non-JSON response (possibly an HTML error page). Check that the backend is running and the /api/deadcode/* routes are wired.`)}}function c({projectRoot:e}){let[t,n]=(0,r.useState)(`idle`),[c,l]=(0,r.useState)(`idle`),[p,m]=(0,r.useState)(null),[h,g]=(0,r.useState)(null),[_,v]=(0,r.useState)(null),y=(0,r.useCallback)(async()=>{n(`scanning`),v(null),m(null),g(null),l(`idle`);try{let e=await fetch(`/api/deadcode/scan`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})});if(!e.ok){let t=await s(e);throw Error(t.detail??t.error??`HTTP ${e.status}`)}let t=await s(e);m(t),n(`done`)}catch(e){v(e instanceof Error?e.message:String(e)),n(`error`)}},[]),b=(0,r.useCallback)(async()=>{if(p){l(`generating`),v(null);try{let e=await fetch(`/api/deadcode/action-plan`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(p)});if(!e.ok){let t=await s(e);throw Error(t.detail??t.error??`HTTP ${e.status}`)}let t=await s(e);g(t),l(`ready`)}catch(e){v(e instanceof Error?e.message:String(e)),l(`idle`)}}},[p]),x=(0,r.useCallback)(()=>{if(!h)return;l(`executing`);let e=[`# Dead-Code Cleanup Plan`,``,h.summary,``,`## Files to address (in priority order)`,...h.files.map((e,t)=>`${t+1}. [${a[e.priority]}] ${e.file} — ${e.symbolCount} symbol(s) to remove`+(e.symbols.length>0?`\n Symbols: ${e.symbols.slice(0,5).join(`, `)}${e.symbols.length>5?` and ${e.symbols.length-5} more`:``}`:``))].join(`
|
|
2
|
+
`),t=window.__WS;t&&t.readyState===WebSocket.OPEN?t.send(JSON.stringify({type:`user.message`,payload:{text:e,action:`send`}})):(navigator.clipboard.writeText(e),v(`Agent not connected. Plan copied to clipboard — paste it into the chat.`)),l(`idle`)},[h]);return(0,i.jsxs)(`div`,{style:{padding:`16px`,fontFamily:`var(--font-sans, system-ui, sans-serif)`,color:`hsl(var(--foreground))`,background:`hsl(var(--background))`},children:[(0,i.jsx)(`h2`,{style:{margin:`0 0 16px`,fontSize:`18px`,fontWeight:600,color:`hsl(var(--foreground))`},children:`🔍 Dead-Code Scan`}),(0,i.jsx)(`button`,{onClick:y,disabled:t===`scanning`,style:{padding:`8px 16px`,fontSize:`14px`,fontWeight:500,background:t===`scanning`?`hsl(var(--muted))`:`hsl(var(--primary))`,color:t===`scanning`?`hsl(var(--muted-foreground))`:`hsl(var(--primary-foreground))`,border:`1px solid hsl(var(--border))`,borderRadius:`0`,cursor:t===`scanning`?`not-allowed`:`pointer`},children:t===`scanning`?`Scanning…`:`Scan for Dead Code`}),_&&(0,i.jsxs)(`div`,{style:{marginTop:`12px`,padding:`8px 12px`,background:`hsl(var(--destructive) / 0.1)`,color:`hsl(var(--destructive))`,border:`1px solid hsl(var(--destructive) / 0.3)`,borderRadius:`0`,fontSize:`13px`},children:[_,(0,i.jsx)(`button`,{onClick:()=>v(null),style:{marginLeft:`12px`,background:`none`,border:`none`,cursor:`pointer`,fontWeight:600,color:`hsl(var(--destructive))`},children:`✕`})]}),p&&(0,i.jsxs)(`div`,{style:{marginTop:`16px`},children:[(0,i.jsxs)(`div`,{style:{display:`flex`,gap:`12px`,marginBottom:`12px`},children:[(0,i.jsx)(u,{label:`Total Symbols`,value:p.stats.totalSymbols,token:`info`}),(0,i.jsx)(u,{label:`Alive`,value:p.stats.alive,token:`success`}),(0,i.jsx)(u,{label:`Dead`,value:p.stats.dead,token:`destructive`})]}),p.deadPackages.length>0&&(0,i.jsx)(d,{title:`Dead Packages (${p.deadPackages.length})`,token:`destructive`,children:p.deadPackages.map(e=>(0,i.jsx)(f,{columns:[e.package,e.path,`${e.fileCount} file(s)`]},e.package))}),p.deadFiles.length>0&&(0,i.jsx)(d,{title:`Dead Files (${p.deadFiles.length})`,token:`warning`,children:p.deadFiles.map(e=>(0,i.jsx)(f,{columns:[e.file,`${e.symbolCount} symbol(s)`,e.lang]},e.file))}),p.deadSymbols.length>0&&(0,i.jsxs)(d,{title:`Dead Symbols (${p.deadSymbols.length})`,token:`info`,children:[p.deadSymbols.slice(0,50).map(e=>(0,i.jsx)(f,{columns:[e.name,e.kind,e.file.split(`/`).pop()??e.file,`line ${e.line}`]},`${e.file}:${e.line}:${e.name}`)),p.deadSymbols.length>50&&(0,i.jsxs)(`div`,{style:{padding:`6px 8px`,color:`hsl(var(--muted-foreground))`,fontSize:`12px`},children:[`… and `,p.deadSymbols.length-50,` more`]})]}),t===`done`&&(0,i.jsx)(`button`,{onClick:b,disabled:c===`generating`,style:{marginTop:`12px`,padding:`8px 16px`,fontSize:`14px`,fontWeight:500,background:c===`generating`?`hsl(var(--muted))`:`hsl(var(--accent))`,color:c===`generating`?`hsl(var(--muted-foreground))`:`hsl(var(--accent-foreground))`,border:`1px solid hsl(var(--border))`,borderRadius:`0`,cursor:c===`generating`?`not-allowed`:`pointer`},children:c===`generating`?`Generating…`:`Generate Action Plan`})]}),h&&(0,i.jsxs)(`div`,{style:{marginTop:`16px`,border:`1px solid hsl(var(--border))`,borderRadius:`0`,padding:`12px`,background:`hsl(var(--card))`},children:[(0,i.jsx)(`h3`,{style:{margin:`0 0 8px`,fontSize:`15px`,fontWeight:600,color:`hsl(var(--card-foreground))`},children:`📋 Action Plan`}),(0,i.jsx)(`p`,{style:{fontSize:`13px`,color:`hsl(var(--muted-foreground))`,margin:`0 0 12px`},children:h.summary}),h.files.map((e,t)=>(0,i.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:`8px`,padding:`6px 0`,borderBottom:t<h.files.length-1?`1px solid hsl(var(--border))`:`none`,fontSize:`13px`},children:[(0,i.jsx)(`span`,{style:{background:o[e.priority]??`hsl(var(--muted-foreground))`,color:`hsl(var(--primary-foreground))`,borderRadius:`0`,padding:`2px 6px`,fontSize:`11px`,fontWeight:600,whiteSpace:`nowrap`,flexShrink:0},children:a[e.priority]??`P${e.priority}`}),(0,i.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,i.jsx)(`div`,{style:{fontWeight:500,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,color:`hsl(var(--foreground))`},children:e.file}),(0,i.jsxs)(`div`,{style:{color:`hsl(var(--muted-foreground))`,fontSize:`12px`},children:[e.symbolCount,` symbol(s)`,e.symbols.length>0&&` · ${e.symbols.slice(0,2).join(`, `)}${e.symbols.length>2?`…`:``}`]})]})]},e.file)),(0,i.jsx)(`button`,{onClick:x,disabled:c===`executing`,style:{marginTop:`12px`,padding:`8px 16px`,fontSize:`14px`,fontWeight:500,background:c===`executing`?`hsl(var(--muted))`:`hsl(var(--success))`,color:`hsl(var(--primary-foreground))`,border:`1px solid hsl(var(--border))`,borderRadius:`0`,cursor:c===`executing`?`not-allowed`:`pointer`},children:c===`executing`?`Sending…`:`Execute Plan via Agent`})]})]})}var l={success:`hsl(var(--success))`,warning:`hsl(var(--warning))`,info:`hsl(var(--info))`,destructive:`hsl(var(--destructive))`,primary:`hsl(var(--primary))`};function u({label:e,value:t,token:n}){let r=l[n];return(0,i.jsxs)(`div`,{style:{flex:1,padding:`10px`,borderRadius:`0`,border:`1px solid hsl(var(--border))`,background:`hsl(var(--card))`,textAlign:`center`},children:[(0,i.jsx)(`div`,{style:{fontSize:`24px`,fontWeight:700,color:r},children:t}),(0,i.jsx)(`div`,{style:{fontSize:`12px`,color:`hsl(var(--muted-foreground))`,marginTop:`2px`},children:e})]})}function d({title:e,token:t,children:n}){let r=l[t];return(0,i.jsxs)(`div`,{style:{marginBottom:`12px`},children:[(0,i.jsx)(`h3`,{style:{margin:`0 0 6px`,fontSize:`14px`,fontWeight:600,color:r,borderLeft:`3px solid ${r}`,paddingLeft:`8px`},children:e}),(0,i.jsx)(`div`,{style:{border:`1px solid hsl(var(--border))`,borderRadius:`0`,overflow:`hidden`,fontSize:`13px`},children:n})]})}function f({columns:e}){return(0,i.jsx)(`div`,{style:{display:`flex`,gap:`8px`,padding:`5px 8px`,borderBottom:`1px solid hsl(var(--border))`,fontSize:`13px`,fontFamily:`var(--font-mono, monospace)`,background:`hsl(var(--card))`,color:`hsl(var(--card-foreground))`},children:e.map((e,t)=>(0,i.jsx)(`span`,{style:{flex:t===0?2:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e},t))})}export{c as DeadCodeScanPanel};
|