@wrongstack/webui 0.309.1 → 0.310.1
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-CBiLW8dV.js → AgentRosterView-DAci8zSJ.js} +1 -1
- package/dist/assets/{AnalyticsDashboard-Grpp3QKX.js → AnalyticsDashboard-BltY_7sZ.js} +1 -1
- package/dist/assets/{AudienceMemoryPanel-DU3hUuUl.js → AudienceMemoryPanel-uMGOcvUl.js} +1 -1
- package/dist/assets/{ChangesView-DOrw4udd.js → ChangesView-QgbkAV21.js} +1 -1
- package/dist/assets/{ChronicleDashboard-DlCuQRB8.js → ChronicleDashboard-CjC3Tpdp.js} +1 -1
- package/dist/assets/{CodeEditor-CU6zP0r8.js → CodeEditor-BjIBUPk8.js} +1 -1
- package/dist/assets/{CodeMap-BkJqVDg2.js → CodeMap-BpOQHHcp.js} +1 -1
- package/dist/assets/{ConfirmModal-BJOVE-JI.js → ConfirmModal-DNp4NzCY.js} +1 -1
- package/dist/assets/{CronJobsPanel-B3UJP0mn.js → CronJobsPanel-DyxLGNzd.js} +1 -1
- package/dist/assets/{DeadCodeScanPanel-_iUu5-90.js → DeadCodeScanPanel-Qf3HU4hj.js} +1 -1
- package/dist/assets/{DebugDashboard-NTiN0je2.js → DebugDashboard-D0nD5Mi-.js} +1 -1
- package/dist/assets/{DesignGalleryView-BG2Nr8wy.js → DesignGalleryView-CzSTqD9U.js} +1 -1
- package/dist/assets/{GoalView-Dakf9ZR8.js → GoalView-CZHQeAKT.js} +1 -1
- package/dist/assets/{KanbanView-BR07PhbR.js → KanbanView-DRox56Vn.js} +1 -1
- package/dist/assets/{MailboxDetailView-D31IhaK_.js → MailboxDetailView-D6Ywy9n_.js} +1 -1
- package/dist/assets/{MemoryDrawer-6n0Etoz4.js → MemoryDrawer--0NW-5zb.js} +1 -1
- package/dist/assets/{MemoryManager-7DSVhxZf.js → MemoryManager-Dpsvz_n_.js} +1 -1
- package/dist/assets/{ModelPicker-C72kprRH.js → ModelPicker-CBQqO9xG.js} +1 -1
- package/dist/assets/{OfficeMapPanel-Dc8-4CiU.js → OfficeMapPanel-D1oaHb4z.js} +1 -1
- package/dist/assets/{ProcessMonitor-BGLc3yNM.js → ProcessMonitor-Bhu8vdfD.js} +1 -1
- package/dist/assets/{PromptJournalView-CxDiqUkN.js → PromptJournalView-C1-hyXix.js} +1 -1
- package/dist/assets/{QueuePanel-B2f1HbN0.js → QueuePanel-CuDxuazR.js} +1 -1
- package/dist/assets/{RefreshDebugView-D8F95QxF.js → RefreshDebugView-BxVmfUp2.js} +1 -1
- package/dist/assets/{RequirementIntakeView-BRolSCpk.js → RequirementIntakeView-BiEvDV41.js} +1 -1
- package/dist/assets/{SageTabs-DblSyqzB.js → SageTabs-BE4m8VUY.js} +2 -2
- package/dist/assets/{SddFlowGraph-YOPsSaFc.js → SddFlowGraph-_8Xuc_cU.js} +1 -1
- package/dist/assets/{SddHub-IusMUP2D.js → SddHub-B2kE8AiT.js} +1 -1
- package/dist/assets/{SessionInspectView-B633Bi0X.js → SessionInspectView-DOLLUo3T.js} +1 -1
- package/dist/assets/{SessionList-BCE6NSCu.js → SessionList-BhXjS40z.js} +1 -1
- package/dist/assets/{SessionsDashboard-N__p7_i5.js → SessionsDashboard-tfMU0z-y.js} +1 -1
- package/dist/assets/{SetupScreen-B06asuJC.js → SetupScreen-CXE-RhNU.js} +1 -1
- package/dist/assets/{SkillDetailView-BxpQcgfh.js → SkillDetailView-DCkPQZ5H.js} +3 -3
- package/dist/assets/{SpecsView-Ddbow1sn.js → SpecsView-DKAxgGNr.js} +1 -1
- package/dist/assets/{TechStackView-HTZUTbuu.js → TechStackView-99ogOMkD.js} +1 -1
- package/dist/assets/{TerminalPanel-Bi3CmRvI.js → TerminalPanel-CUwCc0Hv.js} +1 -1
- package/dist/assets/{Toaster-COVFFUKo.js → Toaster-AH2vaxrX.js} +1 -1
- package/dist/assets/{activity-Dt0RpmkN.js → activity-BA8C9ueU.js} +1 -1
- package/dist/assets/{activity-7Sj9fdO-.js → activity-BYnOci5N.js} +1 -1
- package/dist/assets/{activity-B7hiQ_IX.js → activity-COQ9xSFu.js} +1 -1
- package/dist/assets/{activity-B-LcgiXm.js → activity-CuJqhGz7.js} +1 -1
- package/dist/assets/{activity-JmCi-KcX.js → activity-D3ZccGOh.js} +1 -1
- package/dist/assets/{activity-Cq0Lqtgz.js → activity-YMES6OPI.js} +1 -1
- package/dist/assets/{activity-DVuAYnoi.js → activity-zlMMaNE1.js} +1 -1
- package/dist/assets/{button-DAT5OnLL.js → button-Dhmop_yM.js} +1 -1
- package/dist/assets/{chat-store-CtIMb3sU.js → chat-store-BiEXyguk.js} +1 -1
- package/dist/assets/{codemap-activity-store-CA_14DHd.js → codemap-activity-store-BWt_a7Gs.js} +1 -1
- package/dist/assets/codemap-index-store-CDhApwWQ.js +1 -0
- package/dist/assets/{dialog-BMrjwjA6.js → dialog-DPl7DolS.js} +1 -1
- package/dist/assets/{empty-state-Bf05Z1d2.js → empty-state-IT10GzRA.js} +1 -1
- package/dist/assets/i18n-n_1tBMdC.js +2 -0
- package/dist/assets/index-B8J_xxU5.css +1 -0
- package/dist/assets/{index-cUeJ0FkT.js → index-gKjRx1pQ.js} +55 -55
- package/dist/assets/{input-Ccsxvwz6.js → input-C3rIQ26u.js} +1 -1
- package/dist/assets/{mailbox-store-BWD7JeF9.js → mailbox-store-DhAVkVJQ.js} +1 -1
- package/dist/assets/{roster-ws-lMIf13ag.js → roster-ws-Vj_HH49O.js} +1 -1
- package/dist/assets/session-store-CKpAwNIm.js +1 -0
- package/dist/assets/{settings-DfID_cS9.js → settings-BhmwkYVs.js} +1 -1
- package/dist/assets/settings-BpSRCuSL.js +1 -0
- package/dist/assets/settings-BvbMvXxL.js +1 -0
- package/dist/assets/settings-Dk78XWnd.js +1 -0
- package/dist/assets/settings-Mh81dlWD.js +1 -0
- package/dist/assets/settings-_V6PolUx.js +1 -0
- package/dist/assets/settings-koX3yNr7.js +1 -0
- package/dist/assets/{shared-Y6T3EEnd.js → shared-BUXBOqyO.js} +1 -1
- package/dist/assets/{stores-BUtRik4k.js → stores-d8rhzRAc.js} +1 -1
- package/dist/assets/ui-store-3HoYrTu5.js +1 -0
- package/dist/assets/useWebSocket-Co9oG6EI.js +29 -0
- package/dist/assets/{utils-B5X3DKef.js → utils-BecmXwgG.js} +1 -1
- package/dist/assets/{vector-memory-panel-CnBqV6GK.js → vector-memory-panel-CBA4CK6N.js} +1 -1
- package/dist/assets/{vendor-DLS502Zs.js → vendor-DZ9_OO6N.js} +20 -20
- package/dist/assets/{view-navigation-Hd631M1W.js → view-navigation-C1UDTk5R.js} +1 -1
- package/dist/assets/ws-client-DXT4gi-N.js +1 -0
- package/dist/components/ChatView/AgentTabs.d.ts +16 -0
- package/dist/components/ChatView/SubagentTranscriptView.d.ts +16 -0
- package/dist/components/ChatView/useChatViewState.d.ts +7 -0
- package/dist/components/SettingsPanel/LogsSettingsTab.d.ts +1 -1
- package/dist/components/SettingsPanel/MCPSection.d.ts +2 -12
- package/dist/components/SettingsPanel/ModelSchemaEditor.d.ts +7 -0
- package/dist/components/SettingsPanel/contracts.d.ts +29 -0
- package/dist/components/SettingsPanel/official-servers.d.ts +1 -1
- package/dist/hooks/useLiveContextDebug.d.ts +97 -0
- package/dist/index.html +23 -23
- package/dist/index.js +11010 -10233
- package/dist/protocol-compatibility.d.ts +1 -1
- package/dist/stores/local-prefs.d.ts +13 -0
- package/dist/stores/session-store.d.ts +9 -1
- package/dist/stores/ui-store.d.ts +12 -0
- package/dist/types/system.d.ts +12 -0
- package/package.json +12 -11
- package/dist/assets/codemap-index-store-BlPxA13l.js +0 -1
- package/dist/assets/i18n-CYYBUSJB.js +0 -2
- package/dist/assets/index-D2tx76V0.css +0 -1
- package/dist/assets/session-store-D4PNeAGe.js +0 -1
- package/dist/assets/settings-B36QpLU8.js +0 -1
- package/dist/assets/settings-B8Hgh9_X.js +0 -1
- package/dist/assets/settings-B8uABeWU.js +0 -1
- package/dist/assets/settings-CSwU_zzD.js +0 -1
- package/dist/assets/settings-FXJ8SsEh.js +0 -1
- package/dist/assets/settings-RQKnX4dA.js +0 -1
- package/dist/assets/ui-store-DxMnhARg.js +0 -1
- package/dist/assets/useWebSocket-Ew1Bbjci.js +0 -29
- package/dist/assets/ws-client-DYrfK01f.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./chat-store-CtIMb3sU.js";import{Ba as n,Ga as r,Ji as i,Ni as a,Ot as o,Pa as s,Qr as c,Si as l,Wt as u,Zt as d,_r as f,an as p,dt as m,ft as h,ga as g,ha as _,hr as v,jt as y,lt as b,ma as x,na as S,or as C,tn as w,ut as T,xi as E,yn as D,zi as O}from"./vendor-DLS502Zs.js";import"./i18n-CYYBUSJB.js";import{t as k}from"./ws-client-DYrfK01f.js";import{t as A}from"./utils-B5X3DKef.js";import{E as j}from"./stores-BUtRik4k.js";import{n as M}from"./ui-store-DxMnhARg.js";import{i as N}from"./view-navigation-Hd631M1W.js";import{n as P}from"./Toaster-COVFFUKo.js";import{n as F,t as I}from"./ModelPicker-C72kprRH.js";import{s as L}from"./index-cUeJ0FkT.js";import{t as R}from"./roster-ws-lMIf13ag.js";var z=e(r(),1),B=b(),V=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],H=[[`timeoutMs`,`Total timeout (ms)`],[`idleTimeoutMs`,`Idle timeout (ms)`],[`maxIterations`,`Max iterations`],[`maxToolCalls`,`Max tool calls`],[`maxTokens`,`Max tokens`],[`maxCostUsd`,`Max cost (USD)`]];function U(e){return`${e.provider}/${e.model}`}function W(e){let t=e.indexOf(`/`);return t<0?{provider:``,model:e}:{provider:e.slice(0,t),model:e.slice(t+1)}}function G(e){return Array.isArray(e)?e.join(`, `):``}function K(e){return[...new Set(e.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean))]}function q({initialConfig:e,systemProtected:t,saving:r,onSave:i,onCancel:a}){let{t:o}=n(),[s,c]=(0,z.useState)(()=>structuredClone(e)),l=F(!0),u=s.modelPolicy,f=(0,z.useMemo)(()=>(u?.allowed??[]).map(U),[u?.allowed]),p=(0,z.useMemo)(()=>(u?.fallbacks??[]).map(U),[u?.fallbacks]),m=e=>c(t=>({...t,...e})),h=(e,t)=>{let n=K(t);c(t=>{let r={...t};return n.length?r[e]=n:delete r[e],r})},g=(e,t)=>{c(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})},_=e=>{let t=e.map(W),n=new Set(e);c(e=>({...e,modelPolicy:{allowed:t,fallbacks:(e.modelPolicy?.fallbacks??[]).filter(e=>n.has(U(e))),strict:e.modelPolicy?.strict??!0}}))};return(0,B.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-border bg-card/40 p-4`,children:[t&&(0,B.jsxs)(`div`,{className:`flex gap-2 rounded-md border border-warning/30 bg-warning/5 p-2 text-[11px] text-muted-foreground`,children:[(0,B.jsx)(d,{className:`mt-0.5 h-4 w-4 shrink-0 text-warning`}),(0,B.jsx)(`span`,{children:o(`activity:runtimePolicy.protectedSystemAgentRequiredToolsAnd`)})]}),(0,B.jsxs)(`section`,{className:`space-y-2`,children:[(0,B.jsx)(`h4`,{className:`text-xs font-semibold`,children:o(`activity:runtimePolicy.providerAndModelPolicy`)}),(0,B.jsx)(I,{candidates:l,provider:s.provider,value:s.model,placeholder:o(`activity:runtimePolicy.useProjectDefaultModel`),resetLabel:`Use project default`,onReset:()=>{c(e=>{let t={...e};return delete t.provider,delete t.model,t})},onPick:(e,t)=>{let n=`${t}/${e}`;m({provider:t,model:e}),u&&!f.includes(n)&&_([...f,n])}}),(0,B.jsxs)(`label`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:!!u,onChange:e=>{if(e.target.checked){let e=s.provider&&s.model?[{provider:s.provider,model:s.model}]:l[0]?[{provider:l[0].provider,model:l[0].model}]:[];e.length&&m({modelPolicy:{allowed:e,strict:!0}})}else c(e=>{let t={...e};return delete t.modelPolicy,t})}}),o(`activity:runtimePolicy.restrictThisAgentToAnExplicit`)]}),u&&(0,B.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`span`,{className:`text-[10px] font-medium`,children:o(`activity:runtimePolicy.allowedModels`)}),(0,B.jsx)(L,{value:f,candidates:l,onChange:_,placeholder:o(`activity:runtimePolicy.addAllowedModel`),emptyHint:`At least one model is required`})]}),(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`span`,{className:`text-[10px] font-medium`,children:o(`activity:runtimePolicy.orderedFallbackChain`)}),(0,B.jsx)(L,{value:p,candidates:l,onChange:e=>{let t=[...new Set([...f,...e])];c(n=>({...n,modelPolicy:{allowed:t.map(W),fallbacks:e.map(W),strict:n.modelPolicy?.strict??!0}}))},placeholder:o(`activity:runtimePolicy.addFallbackModel`),emptyHint:`No fallback; primary failure stops the task`})]})]})]}),(0,B.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,B.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:t}),(0,B.jsx)(`textarea`,{value:G(s[e]),onChange:t=>h(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,B.jsxs)(`section`,{className:`space-y-2`,children:[(0,B.jsx)(`h4`,{className:`text-xs font-semibold`,children:o(`activity:runtimePolicy.workspaceAndIsolation`)}),(0,B.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,B.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,B.jsx)(`span`,{children:o(`activity:runtimePolicy.projectRelativeWorkingDirectory`)}),(0,B.jsx)(`input`,{value:s.cwd??``,onChange:e=>m({cwd:e.target.value||void 0}),placeholder:o(`activity:runtimePolicy.packagesWebui`),className:`h-8 w-full rounded border border-border bg-background px-2 font-mono`})]}),(0,B.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,B.jsx)(`span`,{children:o(`activity:runtimePolicy.gitWorktreeIsolation`)}),(0,B.jsxs)(`select`,{value:String(s.worktree??`auto`),onChange:e=>m({worktree:e.target.value}),className:`h-8 w-full rounded border border-border bg-background px-2`,children:[(0,B.jsx)(`option`,{value:`auto`,children:o(`activity:runtimePolicy.automatic`)}),(0,B.jsx)(`option`,{value:`required`,children:o(`activity:runtimePolicy.required`)}),(0,B.jsx)(`option`,{value:`off`,children:o(`activity:runtimePolicy.off`)})]})]})]})]}),(0,B.jsxs)(`section`,{className:`space-y-2`,children:[(0,B.jsx)(`h4`,{className:`text-xs font-semibold`,children:o(`activity:runtimePolicy.limits`)}),(0,B.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:H.map(([e,t])=>(0,B.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,B.jsx)(`span`,{children:t}),(0,B.jsx)(`input`,{type:`number`,min:`0`,step:e===`maxCostUsd`?`0.01`:`1`,value:s.budget?.[e]??``,onChange:t=>g(e,t.target.value),className:`h-8 w-full rounded border border-border bg-background px-2`})]},e))})]}),(0,B.jsxs)(`section`,{className:`space-y-2`,children:[(0,B.jsxs)(`label`,{className:`flex items-center gap-2 text-xs font-semibold`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:!!s.availability,onChange:e=>{e.target.checked?m({availability:{timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`,days:[1,2,3,4,5],start:`09:00`,end:`18:00`,mode:t?`advisory`:`enforce`}}):c(e=>{let t={...e};return delete t.availability,t})}}),o(`activity:runtimePolicy.workingHours`)]}),s.availability&&(0,B.jsxs)(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[(0,B.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:V.map((e,t)=>(0,B.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px]`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:s.availability?.days.includes(t)??!1,onChange:e=>{let n=s.availability;if(!n)return;let r=e.target.checked?[...new Set([...n.days,t])].sort():n.days.filter(e=>e!==t);m({availability:{...n,days:r}})}}),e]},e))}),(0,B.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-4`,children:[(0,B.jsx)(`input`,{value:s.availability.timezone,onChange:e=>m({availability:{...s.availability,timezone:e.target.value}}),placeholder:o(`activity:runtimePolicy.europeKiev`),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,B.jsx)(`input`,{type:`time`,value:s.availability.start,onChange:e=>m({availability:{...s.availability,start:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,B.jsx)(`input`,{type:`time`,value:s.availability.end,onChange:e=>m({availability:{...s.availability,end:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,B.jsxs)(`select`,{value:t?`advisory`:s.availability.mode??`enforce`,disabled:t,onChange:e=>m({availability:{...s.availability,mode:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`,children:[(0,B.jsx)(`option`,{value:`enforce`,children:o(`activity:runtimePolicy.enforce`)}),(0,B.jsx)(`option`,{value:`advisory`,children:o(`activity:runtimePolicy.advisory`)})]})]})]})]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,disabled:r||!!(u&&u.allowed.length===0),onClick:()=>i(s),className:`rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50`,children:r?`Saving…`:`Save runtime policy`}),(0,B.jsx)(`button`,{type:`button`,onClick:a,className:`rounded border border-border px-3 py-1.5 text-xs hover:bg-accent`,children:o(`activity:runtimePolicy.cancel`)})]})]})}var J=[{id:`live`,icon:(0,B.jsx)(s,{className:`h-4 w-4`}),labelKey:`activity:agentRoster.tabLive`},{id:`catalog`,icon:(0,B.jsx)(_,{className:`h-4 w-4`}),labelKey:`activity:agentRoster.tabCatalog`},{id:`learning`,icon:(0,B.jsx)(g,{className:`h-4 w-4`}),labelKey:`activity:agentRoster.tabLearning`},{id:`customize`,icon:(0,B.jsx)(w,{className:`h-4 w-4`}),labelKey:`activity:agentRoster.tabCustomize`}],Y=[{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 X({customStats:e,rosterLoading:t,onRefresh:r}){let{t:i}=n();return(0,B.jsx)(`div`,{className:`shrink-0 border-b border-border/70 bg-card/80 px-4 py-2.5`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-nowrap min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 overflow-hidden`,children:[(0,B.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 shrink-0 rounded-lg bg-primary/10`,children:(0,B.jsx)(v,{className:`h-4 w-4 text-primary`})}),(0,B.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[(0,B.jsx)(`h1`,{className:`text-sm font-semibold truncate`,children:i(`activity:agentRoster.heading`)}),(0,B.jsx)(`p`,{className:`text-[10px] text-muted-foreground truncate`,children:i(`activity:agentRoster.headerSummary`,{customized:e.filter(e=>e.exists||e.hasIdentity||e.hasConfig||e.hasKnowledge).length,entries:e.reduce((e,t)=>e+t.entryCount,0)})})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[t&&(0,B.jsx)(C,{className:`h-4 w-4 animate-spin text-muted-foreground shrink-0`}),(0,B.jsxs)(`button`,{type:`button`,onClick:r,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:i(`activity:agentRoster.refreshRosterData`),children:[(0,B.jsx)(D,{className:`h-3 w-3`}),` `,i(`common:action.refresh`)]})]})]})})}function Z({activeTab:e,onTabChange:t}){let{t:r}=n();return(0,B.jsx)(`div`,{className:`shrink-0 border-b border-border/50 bg-muted/20 px-3 flex gap-0`,children:J.map(n=>(0,B.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,r(n.labelKey)]},n.id))})}function ee({populated:e,selectedRole:t,onSelectRole:r,onBulkOptimize:i,bulkOptimizing:a}){let{t:o}=n(),s=e.filter(e=>e.needsSummarization);return(0,B.jsxs)(`div`,{className:A(`flex flex-col min-h-0 min-w-0 overflow-hidden border-r border-border/50`,t?`w-80 shrink-0`:`flex-1`),children:[(0,B.jsxs)(`div`,{className:`shrink-0 px-3 py-2 border-b border-border/50`,children:[(0,B.jsxs)(`h3`,{className:`text-xs font-semibold flex items-center gap-1.5`,children:[(0,B.jsx)(E,{className:`h-3.5 w-3.5 text-brand-2`}),o(`activity:agentRoster.allRosterAgents`)]}),s.length>0&&(0,B.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1.5 rounded border border-warning/40 bg-warning/10 px-2 py-1.5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(T,{className:`h-3 w-3 text-warning shrink-0`}),(0,B.jsxs)(`span`,{className:`text-[10px] text-warning leading-tight`,children:[s.length,` agent`,s.length>1?`s`:``,` need`,s.length===1?`s`:``,` optimization`]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{let e=s[0];e&&r(e.role)},className:`ml-auto text-[9px] text-warning underline hover:text-warning/80 shrink-0`,children:o(`activity:agentRoster.review`)})]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>i(s.map(e=>e.role)),disabled:a,className:`flex items-center justify-center gap-1 rounded bg-warning/20 border border-warning/40 px-2 py-1 text-[10px] font-medium text-warning hover:bg-warning/30 transition-colors disabled:opacity-50`,children:[a?(0,B.jsx)(C,{className:`h-3 w-3 animate-spin`}):(0,B.jsx)(T,{className:`h-3 w-3`}),a?o(`activity:agentRoster.optimizing`):o(`activity:agentRoster.optimizeAll`,{count:s.length})]})]})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2 space-y-1`,children:e.map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>r(e.role),className:A(`w-full text-left rounded-lg border px-3 py-2 transition-colors`,t===e.role?`border-primary/50 bg-primary/[0.06]`:`border-border/60 hover:border-primary/30`,e.needsSummarization&&t!==e.role&&`border-warning/40`),children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`text-xs font-semibold`,children:e.role}),(0,B.jsx)(`span`,{className:A(`text-[9px] tabular-nums`,e.learningEnabled?`text-success`:`text-muted-foreground`),children:e.learningEnabled?o(`activity:agentRoster.learning`):o(`activity:agentRoster.paused`)})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-[9px] text-muted-foreground`,children:[(0,B.jsxs)(`span`,{className:`tabular-nums`,children:[e.entryCount,` entries`]}),e.sessionCaptureCount>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,B.jsxs)(`span`,{className:`text-success tabular-nums`,children:[`+`,e.sessionCaptureCount]})]}),typeof e.directiveHitRate==`number`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,B.jsxs)(`span`,{className:A(`tabular-nums`,e.directiveHitRate>=.7?`text-success`:e.directiveHitRate<.4&&`text-warning`),title:`Share of directive applications that ended in a successful task`,children:[Math.round(e.directiveHitRate*100),`%`]})]}),e.lastCapture&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,B.jsx)(`span`,{children:new Date(e.lastCapture).toLocaleDateString()})]}),e.needsSummarization&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-warning font-medium`,children:[(0,B.jsx)(T,{className:`h-2.5 w-2.5`}),`optimize`]})]})]},e.role))})]})}var te={size:`buffer reached the size threshold`,"pending-skills":`directives are waiting to reach their skill`,disabled:`auto-optimization is off`,"learning-paused":`learning is paused for this agent`,"too-few-entries":`not enough directives yet`,"below-threshold":`below the threshold`,"cooling-down":`recently optimized — cooling down`};function ne({selectedRole:e,selectedStats:t,saving:r,setLearningEnabled:a,optimizing:s,runOptimize:c,autoStatus:l,consolidatedContent:d,loadConsolidated:f,setConsolidatedContent:p,skills:m,toggleSkillBody:h,toggleSkillPin:v,openSkill:y,retired:b,showRetired:x,setShowRetired:S,loadEntries:w,loadingEntries:D,reviewEntries:O,reviewDecisions:k,setReviewEntries:j,setReviewDecisions:M,applyReview:N,teachInput:P,setTeachInput:F,runTeach:I,teachFeedback:L}){let{t:R}=n();return(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`h3`,{className:`text-base font-semibold`,children:e}),(0,B.jsx)(`div`,{className:`flex gap-1`,children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>a(e,!t.learningEnabled),disabled:r,className:A(`inline-flex items-center gap-1 rounded border px-2 py-1 text-[10px] transition-colors disabled:opacity-50`,t.learningEnabled?`border-success/40 text-success hover:bg-success/10`:`border-border/50 text-muted-foreground hover:bg-accent`),children:[(0,B.jsx)(E,{className:`h-3 w-3`}),` `,t.learningEnabled?R(`activity:agentRoster.learningOn`):R(`activity:agentRoster.learningPaused`)]})})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:R(`activity:agentRoster.entries`)}),(0,B.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:t.entryCount})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:R(`activity:agentRoster.size`)}),(0,B.jsxs)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:[t.totalBytes,`B`]})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:R(`activity:agentRoster.lifetimeCaptures`)}),(0,B.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:t.lifetimeCaptureCount})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:R(`activity:agentRoster.lastCapture`)}),(0,B.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:t.lastCapture?new Date(t.lastCapture).toLocaleDateString():`—`})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,title:`Share of directive applications that ended in a successful task. Blank until a directive has actually been exercised on one.`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:R(`activity:agentRoster.hitRate`)}),(0,B.jsxs)(`div`,{className:A(`text-lg font-mono font-semibold mt-0.5`,typeof t.directiveHitRate==`number`&&(t.directiveHitRate>=.7?`text-success`:t.directiveHitRate<.4&&`text-warning`)),children:[typeof t.directiveHitRate==`number`?`${Math.round(t.directiveHitRate*100)}%`:`—`,typeof t.appliedEntryCount==`number`&&t.appliedEntryCount>0&&(0,B.jsxs)(`span`,{className:`text-[9px] text-muted-foreground font-sans ml-1`,children:[`of `,t.appliedEntryCount]})]})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,title:`Directives that have never been exercised on a task. Anchors — exact commands, paths, package names — are what let the runtime tell that a directive was applied.`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:R(`activity:agentRoster.neverUsed`)}),(0,B.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:typeof t.deadEntryCount==`number`?t.deadEntryCount:`—`})]})]}),t.needsSummarization&&(0,B.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-warning bg-warning/10 rounded-lg px-3 py-2.5`,children:[(0,B.jsx)(o,{className:`h-4 w-4 shrink-0`}),(0,B.jsx)(`span`,{className:`flex-1`,children:R(`activity:agentRoster.learningsLimitExceeded`,{bytes:t.totalBytes.toLocaleString()})}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>c(e),disabled:s,className:`inline-flex items-center gap-1 rounded bg-warning/20 text-warning border border-warning/40 px-2.5 py-1 text-[10px] font-medium hover:bg-warning/30 transition-colors disabled:opacity-50 shrink-0`,children:[s?(0,B.jsx)(C,{className:`h-3 w-3 animate-spin`}):(0,B.jsx)(T,{className:`h-3 w-3`}),s?R(`activity:agentRoster.optimizing`):`Optimize Now`]})]}),(0,B.jsxs)(`div`,{className:`space-y-2 border border-border rounded-lg p-3 bg-card`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(u,{className:`h-4 w-4 text-primary`}),(0,B.jsx)(`span`,{className:`text-xs font-semibold`,children:R(`activity:agentRoster.optimizeLearnings`)})]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>c(e),disabled:s||t.entryCount===0,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,title:t.entryCount===0?`No raw entries to optimize`:`Synthesize raw entries into a consolidated, narrowly-scoped document`,children:[s?(0,B.jsx)(C,{className:`h-3.5 w-3.5 animate-spin`}):(0,B.jsx)(T,{className:`h-3.5 w-3.5`}),s?R(`activity:agentRoster.optimizing`):`Optimize`]})]}),l&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px]`,children:[(0,B.jsx)(`span`,{className:A(`inline-block h-1.5 w-1.5 rounded-full`,l.enabled?l.eligible?`bg-warning`:`bg-success`:`bg-muted-foreground`)}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:l.enabled?l.eligible?`Queued automatically: ${te[l.reason]??l.reason}.`:`Automatic — ${te[l.reason]??l.reason}.`:`Automatic optimization is off — run it manually.`})]}),(0,B.jsxs)(`p`,{className:`text-[10px] text-muted-foreground leading-relaxed`,children:[`Synthesizes all `,t.entryCount,` raw entries into a single reviewed document — narrowly scoped to this agent's skills, preserving every fact but reducing context volume. The result replaces raw entries in the agent's prompt.`]}),t.isConsolidated&&t.consolidation&&(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground pt-1 border-t border-border/50`,children:[(0,B.jsx)(i,{className:`h-3 w-3 text-success`}),(0,B.jsxs)(`span`,{children:[`Consolidated`,` `,new Date(t.consolidation.consolidatedAt).toLocaleDateString(),` ·`,` `,t.consolidation.sourceBytes,`B →`,` `,t.consolidation.consolidatedBytes,`B`,t.consolidation.sourceEntryCount<t.entryCount&&(0,B.jsxs)(`span`,{className:`text-warning ml-1`,children:[`· `,t.entryCount-t.consolidation.sourceEntryCount,` `,R(`activity:agentRoster.newPending`)]})]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{d===null?f(e):p(null)},className:`ml-auto underline text-primary hover:text-primary/80`,children:d===null?R(`activity:agentRoster.viewAction`):`Hide`})]}),d!==null&&(0,B.jsxs)(`div`,{className:`mt-2 max-h-72 overflow-y-auto rounded border border-border/50 bg-background/50 p-2`,children:[(0,B.jsxs)(`div`,{className:`text-[10px] text-muted-foreground mb-1 font-medium`,children:[`Consolidated knowledge for `,e]}),(0,B.jsx)(`pre`,{className:`text-[10px] whitespace-pre-wrap font-sans leading-relaxed`,children:d||`(empty)`})]})]}),m&&m.length>0&&(0,B.jsxs)(`div`,{className:`space-y-2 border border-border rounded-lg p-3 bg-card`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(g,{className:`h-4 w-4 text-brand-2`}),(0,B.jsx)(`span`,{className:`text-xs font-semibold`,children:`Skills`}),(0,B.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[m.filter(e=>e.developed).length,` of `,m.length,` developed for this project`]})]}),(0,B.jsxs)(`p`,{className:`text-[10px] text-muted-foreground leading-relaxed`,children:[`A developed skill carries a project addendum injected right after the bundled skill body — the agent reads one skill, refined for this codebase. Only the highest-ranked few are loaded per spawn; `,(0,B.jsx)(`span`,{className:`text-primary`,children:`loaded`}),` marks those.`]}),(0,B.jsx)(`div`,{className:`space-y-1`,children:m.map(t=>(0,B.jsxs)(`div`,{className:`rounded border border-border/60`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>h(e,t.skill),disabled:!t.developed,className:A(`text-[11px] font-mono text-left flex-1 truncate`,t.developed?`text-primary hover:underline`:`text-muted-foreground cursor-default`),children:t.skill}),t.eager&&(0,B.jsx)(`span`,{className:`text-[9px] rounded bg-primary/15 text-primary px-1.5 py-0.5`,title:`Ranked high enough to be loaded into a spawn of this role`,children:`loaded`}),t.developed&&(0,B.jsx)(`span`,{className:`text-[9px] rounded bg-success/15 text-success px-1.5 py-0.5`,children:`developed`}),t.affinity&&(0,B.jsxs)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,children:[t.affinity.learned>0&&`${t.affinity.learned} learned · `,t.affinity.succeeded,`✓/`,t.affinity.failed,`✗`]}),typeof t.score==`number`&&(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,title:`Project affinity score — higher is loaded first`,children:t.score.toFixed(2)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>v(e,t.skill,!t.affinity?.pinned),className:A(`text-[9px] rounded border px-1.5 py-0.5 transition-colors`,t.affinity?.pinned?`border-primary/50 text-primary`:`border-border/50 text-muted-foreground hover:bg-accent`),children:t.affinity?.pinned?`pinned`:`pin`})]}),y?.skill===t.skill&&(0,B.jsx)(`div`,{className:`max-h-60 overflow-y-auto border-t border-border/50 bg-background/50 p-2`,children:(0,B.jsx)(`pre`,{className:`text-[10px] whitespace-pre-wrap font-sans leading-relaxed`,children:y.content||`(empty)`})})]},t.skill))})]}),b&&b.length>0&&(0,B.jsxs)(`div`,{className:`space-y-2 border border-border rounded-lg p-3 bg-card`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>S(e=>!e),className:`flex w-full items-center gap-1.5 text-left`,children:[(0,B.jsx)(o,{className:`h-4 w-4 text-warning`}),(0,B.jsx)(`span`,{className:`text-xs font-semibold`,children:`Retired`}),(0,B.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[b.length,` directive`,b.length===1?``:`s`,` no longer injected`]}),(0,B.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:x?`hide`:`show`})]}),x&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`text-[10px] text-muted-foreground leading-relaxed`,children:`Each of these was exercised repeatedly and kept correlating with failed tasks, so it was removed from the buffer and scrubbed out of the distilled documents.`}),(0,B.jsx)(`ul`,{className:`space-y-1`,children:b.map(e=>(0,B.jsxs)(`li`,{className:`rounded border border-border/60 px-2 py-1.5 text-[10px] leading-relaxed`,children:[e.skill&&(0,B.jsx)(`span`,{className:`mr-1.5 rounded bg-muted px-1 py-0.5 font-mono text-[9px] text-muted-foreground`,children:e.skill}),(0,B.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.what})]},e.what))})]})]}),t.entryCount>0&&(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>w(e),disabled:D,className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[D?(0,B.jsx)(C,{className:`h-3 w-3 animate-spin`}):(0,B.jsx)(_,{className:`h-3 w-3`}),`Review Learned Entries (`,t.entryCount,`)`]})}),O&&(0,B.jsxs)(`div`,{className:`space-y-2 border border-border rounded-lg p-3 bg-card`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`span`,{className:`text-xs font-medium`,children:[O.filter((e,t)=>k[t]!==`drop`).length,`/`,O.length,` kept`]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:N,disabled:r,className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[10px] text-primary-foreground hover:bg-primary/90 transition-colors`,children:r?R(`activity:agentRoster.applying`):`Apply Selection`}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{j(null),M({})},className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors`,children:R(`activity:agentRoster.cancel`)})]})]}),(0,B.jsx)(`div`,{className:`max-h-72 overflow-y-auto space-y-2`,children:O.map((e,t)=>{let n=k[t]??`keep`,r=e.length>200?e.slice(0,200)+`…`:e;return(0,B.jsx)(`div`,{className:A(`rounded-lg border p-2 transition-colors`,n===`drop`?`border-destructive/40 bg-destructive/5 opacity-60`:`border-border`),children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,B.jsx)(`pre`,{className:`text-[10px] whitespace-pre-wrap flex-1 leading-relaxed font-sans`,children:r}),(0,B.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>M(e=>({...e,[t]:`keep`})),className:A(`px-2 py-1 text-[9px] rounded`,n===`keep`?`bg-success/20 text-success`:`bg-muted text-muted-foreground`),children:R(`activity:agentRoster.keep`)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>M(e=>({...e,[t]:`drop`})),className:A(`px-2 py-1 text-[9px] rounded`,n===`drop`?`bg-destructive/20 text-destructive`:`bg-muted text-muted-foreground`),children:R(`activity:agentRoster.drop`)})]})]})},t)})})]})]}),(0,B.jsxs)(`div`,{className:`space-y-2 pt-4 border-t border-border`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1 text-sm font-medium`,children:[(0,B.jsx)(g,{className:`h-4 w-4 text-brand-2`}),` `,R(`activity:agentRoster.teachThisAgent`)]}),(0,B.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:R(`activity:agentRoster.describeACommandPatternOrBehavior`)}),(0,B.jsx)(`textarea`,{className:`w-full h-20 text-xs p-2 bg-card border border-border rounded resize-y`,value:P,onChange:e=>F(e.target.value),placeholder:R(`activity:agentRoster.eGAlwaysUsePnpmForThisProject`)}),(0,B.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:I,disabled:!P.trim()||r,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:[(0,B.jsx)(g,{className:`h-3.5 w-3.5`}),` `,R(`activity:agentRoster.teach`)]}),L&&(0,B.jsx)(`span`,{className:A(`text-xs`,L.ok?`text-success`:`text-destructive`),children:L.msg})]})]})]})}function re({customStats:e,onRefresh:r}){let{t:i}=n(),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)({}),[d,f]=(0,z.useState)(``),[p,m]=(0,z.useState)(null),[h,g]=(0,z.useState)(!1),[_,v]=(0,z.useState)(!1),[y,b]=(0,z.useState)(null),[x,S]=(0,z.useState)(!1),[C,w]=(0,z.useState)(!1),[T,E]=(0,z.useState)(null),[D,O]=(0,z.useState)(null),[A,j]=(0,z.useState)(!1),[N,F]=(0,z.useState)(null),[I,L]=(0,z.useState)(null),B=(0,z.useMemo)(()=>[...e].sort((e,t)=>e.role.localeCompare(t.role)),[e]),V=(0,z.useMemo)(()=>a?B.find(e=>e.role===a):null,[a,B]),H=(0,z.useCallback)(async e=>{v(!0),c(null);try{let t=await R(`agent-roster.read-learned`,{role:e});c(t.entries??[]),u({})}catch{}v(!1)},[]),U=(0,z.useCallback)(async()=>{if(!a||!s)return;g(!0);let e=s.filter((e,t)=>l[t]!==`drop`).join(`
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./chat-store-BiEXyguk.js";import{Ba as n,Ga as r,Ji as i,Ni as a,Ot as o,Pa as s,Qr as c,Si as l,Wt as u,Zt as d,_r as f,an as p,dt as m,ft as h,ga as g,ha as _,hr as v,jt as y,lt as b,ma as x,na as S,or as C,tn as w,ut as T,xi as E,yn as D,zi as O}from"./vendor-DZ9_OO6N.js";import"./i18n-n_1tBMdC.js";import{t as k}from"./ws-client-DXT4gi-N.js";import{t as A}from"./utils-BecmXwgG.js";import{E as j}from"./stores-d8rhzRAc.js";import{n as M}from"./ui-store-3HoYrTu5.js";import{i as N}from"./view-navigation-C1UDTk5R.js";import{n as P}from"./Toaster-AH2vaxrX.js";import{n as F,t as I}from"./ModelPicker-CBQqO9xG.js";import{s as L}from"./index-gKjRx1pQ.js";import{t as R}from"./roster-ws-Vj_HH49O.js";var z=e(r(),1),B=b(),V=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],H=[[`timeoutMs`,`Total timeout (ms)`],[`idleTimeoutMs`,`Idle timeout (ms)`],[`maxIterations`,`Max iterations`],[`maxToolCalls`,`Max tool calls`],[`maxTokens`,`Max tokens`],[`maxCostUsd`,`Max cost (USD)`]];function U(e){return`${e.provider}/${e.model}`}function W(e){let t=e.indexOf(`/`);return t<0?{provider:``,model:e}:{provider:e.slice(0,t),model:e.slice(t+1)}}function G(e){return Array.isArray(e)?e.join(`, `):``}function K(e){return[...new Set(e.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean))]}function q({initialConfig:e,systemProtected:t,saving:r,onSave:i,onCancel:a}){let{t:o}=n(),[s,c]=(0,z.useState)(()=>structuredClone(e)),l=F(!0),u=s.modelPolicy,f=(0,z.useMemo)(()=>(u?.allowed??[]).map(U),[u?.allowed]),p=(0,z.useMemo)(()=>(u?.fallbacks??[]).map(U),[u?.fallbacks]),m=e=>c(t=>({...t,...e})),h=(e,t)=>{let n=K(t);c(t=>{let r={...t};return n.length?r[e]=n:delete r[e],r})},g=(e,t)=>{c(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})},_=e=>{let t=e.map(W),n=new Set(e);c(e=>({...e,modelPolicy:{allowed:t,fallbacks:(e.modelPolicy?.fallbacks??[]).filter(e=>n.has(U(e))),strict:e.modelPolicy?.strict??!0}}))};return(0,B.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-border bg-card/40 p-4`,children:[t&&(0,B.jsxs)(`div`,{className:`flex gap-2 rounded-md border border-warning/30 bg-warning/5 p-2 text-[11px] text-muted-foreground`,children:[(0,B.jsx)(d,{className:`mt-0.5 h-4 w-4 shrink-0 text-warning`}),(0,B.jsx)(`span`,{children:o(`activity:runtimePolicy.protectedSystemAgentRequiredToolsAnd`)})]}),(0,B.jsxs)(`section`,{className:`space-y-2`,children:[(0,B.jsx)(`h4`,{className:`text-xs font-semibold`,children:o(`activity:runtimePolicy.providerAndModelPolicy`)}),(0,B.jsx)(I,{candidates:l,provider:s.provider,value:s.model,placeholder:o(`activity:runtimePolicy.useProjectDefaultModel`),resetLabel:`Use project default`,onReset:()=>{c(e=>{let t={...e};return delete t.provider,delete t.model,t})},onPick:(e,t)=>{let n=`${t}/${e}`;m({provider:t,model:e}),u&&!f.includes(n)&&_([...f,n])}}),(0,B.jsxs)(`label`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:!!u,onChange:e=>{if(e.target.checked){let e=s.provider&&s.model?[{provider:s.provider,model:s.model}]:l[0]?[{provider:l[0].provider,model:l[0].model}]:[];e.length&&m({modelPolicy:{allowed:e,strict:!0}})}else c(e=>{let t={...e};return delete t.modelPolicy,t})}}),o(`activity:runtimePolicy.restrictThisAgentToAnExplicit`)]}),u&&(0,B.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`span`,{className:`text-[10px] font-medium`,children:o(`activity:runtimePolicy.allowedModels`)}),(0,B.jsx)(L,{value:f,candidates:l,onChange:_,placeholder:o(`activity:runtimePolicy.addAllowedModel`),emptyHint:`At least one model is required`})]}),(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`span`,{className:`text-[10px] font-medium`,children:o(`activity:runtimePolicy.orderedFallbackChain`)}),(0,B.jsx)(L,{value:p,candidates:l,onChange:e=>{let t=[...new Set([...f,...e])];c(n=>({...n,modelPolicy:{allowed:t.map(W),fallbacks:e.map(W),strict:n.modelPolicy?.strict??!0}}))},placeholder:o(`activity:runtimePolicy.addFallbackModel`),emptyHint:`No fallback; primary failure stops the task`})]})]})]}),(0,B.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,B.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:t}),(0,B.jsx)(`textarea`,{value:G(s[e]),onChange:t=>h(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,B.jsxs)(`section`,{className:`space-y-2`,children:[(0,B.jsx)(`h4`,{className:`text-xs font-semibold`,children:o(`activity:runtimePolicy.workspaceAndIsolation`)}),(0,B.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,B.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,B.jsx)(`span`,{children:o(`activity:runtimePolicy.projectRelativeWorkingDirectory`)}),(0,B.jsx)(`input`,{value:s.cwd??``,onChange:e=>m({cwd:e.target.value||void 0}),placeholder:o(`activity:runtimePolicy.packagesWebui`),className:`h-8 w-full rounded border border-border bg-background px-2 font-mono`})]}),(0,B.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,B.jsx)(`span`,{children:o(`activity:runtimePolicy.gitWorktreeIsolation`)}),(0,B.jsxs)(`select`,{value:String(s.worktree??`auto`),onChange:e=>m({worktree:e.target.value}),className:`h-8 w-full rounded border border-border bg-background px-2`,children:[(0,B.jsx)(`option`,{value:`auto`,children:o(`activity:runtimePolicy.automatic`)}),(0,B.jsx)(`option`,{value:`required`,children:o(`activity:runtimePolicy.required`)}),(0,B.jsx)(`option`,{value:`off`,children:o(`activity:runtimePolicy.off`)})]})]})]})]}),(0,B.jsxs)(`section`,{className:`space-y-2`,children:[(0,B.jsx)(`h4`,{className:`text-xs font-semibold`,children:o(`activity:runtimePolicy.limits`)}),(0,B.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:H.map(([e,t])=>(0,B.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,B.jsx)(`span`,{children:t}),(0,B.jsx)(`input`,{type:`number`,min:`0`,step:e===`maxCostUsd`?`0.01`:`1`,value:s.budget?.[e]??``,onChange:t=>g(e,t.target.value),className:`h-8 w-full rounded border border-border bg-background px-2`})]},e))})]}),(0,B.jsxs)(`section`,{className:`space-y-2`,children:[(0,B.jsxs)(`label`,{className:`flex items-center gap-2 text-xs font-semibold`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:!!s.availability,onChange:e=>{e.target.checked?m({availability:{timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`,days:[1,2,3,4,5],start:`09:00`,end:`18:00`,mode:t?`advisory`:`enforce`}}):c(e=>{let t={...e};return delete t.availability,t})}}),o(`activity:runtimePolicy.workingHours`)]}),s.availability&&(0,B.jsxs)(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[(0,B.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:V.map((e,t)=>(0,B.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px]`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:s.availability?.days.includes(t)??!1,onChange:e=>{let n=s.availability;if(!n)return;let r=e.target.checked?[...new Set([...n.days,t])].sort():n.days.filter(e=>e!==t);m({availability:{...n,days:r}})}}),e]},e))}),(0,B.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-4`,children:[(0,B.jsx)(`input`,{value:s.availability.timezone,onChange:e=>m({availability:{...s.availability,timezone:e.target.value}}),placeholder:o(`activity:runtimePolicy.europeKiev`),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,B.jsx)(`input`,{type:`time`,value:s.availability.start,onChange:e=>m({availability:{...s.availability,start:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,B.jsx)(`input`,{type:`time`,value:s.availability.end,onChange:e=>m({availability:{...s.availability,end:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,B.jsxs)(`select`,{value:t?`advisory`:s.availability.mode??`enforce`,disabled:t,onChange:e=>m({availability:{...s.availability,mode:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`,children:[(0,B.jsx)(`option`,{value:`enforce`,children:o(`activity:runtimePolicy.enforce`)}),(0,B.jsx)(`option`,{value:`advisory`,children:o(`activity:runtimePolicy.advisory`)})]})]})]})]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,disabled:r||!!(u&&u.allowed.length===0),onClick:()=>i(s),className:`rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50`,children:r?`Saving…`:`Save runtime policy`}),(0,B.jsx)(`button`,{type:`button`,onClick:a,className:`rounded border border-border px-3 py-1.5 text-xs hover:bg-accent`,children:o(`activity:runtimePolicy.cancel`)})]})]})}var J=[{id:`live`,icon:(0,B.jsx)(s,{className:`h-4 w-4`}),labelKey:`activity:agentRoster.tabLive`},{id:`catalog`,icon:(0,B.jsx)(_,{className:`h-4 w-4`}),labelKey:`activity:agentRoster.tabCatalog`},{id:`learning`,icon:(0,B.jsx)(g,{className:`h-4 w-4`}),labelKey:`activity:agentRoster.tabLearning`},{id:`customize`,icon:(0,B.jsx)(w,{className:`h-4 w-4`}),labelKey:`activity:agentRoster.tabCustomize`}],Y=[{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 X({customStats:e,rosterLoading:t,onRefresh:r}){let{t:i}=n();return(0,B.jsx)(`div`,{className:`shrink-0 border-b border-border/70 bg-card/80 px-4 py-2.5`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-nowrap min-w-0`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 overflow-hidden`,children:[(0,B.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 shrink-0 rounded-lg bg-primary/10`,children:(0,B.jsx)(v,{className:`h-4 w-4 text-primary`})}),(0,B.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[(0,B.jsx)(`h1`,{className:`text-sm font-semibold truncate`,children:i(`activity:agentRoster.heading`)}),(0,B.jsx)(`p`,{className:`text-[10px] text-muted-foreground truncate`,children:i(`activity:agentRoster.headerSummary`,{customized:e.filter(e=>e.exists||e.hasIdentity||e.hasConfig||e.hasKnowledge).length,entries:e.reduce((e,t)=>e+t.entryCount,0)})})]})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[t&&(0,B.jsx)(C,{className:`h-4 w-4 animate-spin text-muted-foreground shrink-0`}),(0,B.jsxs)(`button`,{type:`button`,onClick:r,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:i(`activity:agentRoster.refreshRosterData`),children:[(0,B.jsx)(D,{className:`h-3 w-3`}),` `,i(`common:action.refresh`)]})]})]})})}function Z({activeTab:e,onTabChange:t}){let{t:r}=n();return(0,B.jsx)(`div`,{className:`shrink-0 border-b border-border/50 bg-muted/20 px-3 flex gap-0`,children:J.map(n=>(0,B.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,r(n.labelKey)]},n.id))})}function ee({populated:e,selectedRole:t,onSelectRole:r,onBulkOptimize:i,bulkOptimizing:a}){let{t:o}=n(),s=e.filter(e=>e.needsSummarization);return(0,B.jsxs)(`div`,{className:A(`flex flex-col min-h-0 min-w-0 overflow-hidden border-r border-border/50`,t?`w-80 shrink-0`:`flex-1`),children:[(0,B.jsxs)(`div`,{className:`shrink-0 px-3 py-2 border-b border-border/50`,children:[(0,B.jsxs)(`h3`,{className:`text-xs font-semibold flex items-center gap-1.5`,children:[(0,B.jsx)(E,{className:`h-3.5 w-3.5 text-brand-2`}),o(`activity:agentRoster.allRosterAgents`)]}),s.length>0&&(0,B.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1.5 rounded border border-warning/40 bg-warning/10 px-2 py-1.5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(T,{className:`h-3 w-3 text-warning shrink-0`}),(0,B.jsxs)(`span`,{className:`text-[10px] text-warning leading-tight`,children:[s.length,` agent`,s.length>1?`s`:``,` need`,s.length===1?`s`:``,` optimization`]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{let e=s[0];e&&r(e.role)},className:`ml-auto text-[9px] text-warning underline hover:text-warning/80 shrink-0`,children:o(`activity:agentRoster.review`)})]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>i(s.map(e=>e.role)),disabled:a,className:`flex items-center justify-center gap-1 rounded bg-warning/20 border border-warning/40 px-2 py-1 text-[10px] font-medium text-warning hover:bg-warning/30 transition-colors disabled:opacity-50`,children:[a?(0,B.jsx)(C,{className:`h-3 w-3 animate-spin`}):(0,B.jsx)(T,{className:`h-3 w-3`}),a?o(`activity:agentRoster.optimizing`):o(`activity:agentRoster.optimizeAll`,{count:s.length})]})]})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2 space-y-1`,children:e.map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>r(e.role),className:A(`w-full text-left rounded-lg border px-3 py-2 transition-colors`,t===e.role?`border-primary/50 bg-primary/[0.06]`:`border-border/60 hover:border-primary/30`,e.needsSummarization&&t!==e.role&&`border-warning/40`),children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`span`,{className:`text-xs font-semibold`,children:e.role}),(0,B.jsx)(`span`,{className:A(`text-[9px] tabular-nums`,e.learningEnabled?`text-success`:`text-muted-foreground`),children:e.learningEnabled?o(`activity:agentRoster.learning`):o(`activity:agentRoster.paused`)})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-[9px] text-muted-foreground`,children:[(0,B.jsxs)(`span`,{className:`tabular-nums`,children:[e.entryCount,` entries`]}),e.sessionCaptureCount>0&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,B.jsxs)(`span`,{className:`text-success tabular-nums`,children:[`+`,e.sessionCaptureCount]})]}),typeof e.directiveHitRate==`number`&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,B.jsxs)(`span`,{className:A(`tabular-nums`,e.directiveHitRate>=.7?`text-success`:e.directiveHitRate<.4&&`text-warning`),title:`Share of directive applications that ended in a successful task`,children:[Math.round(e.directiveHitRate*100),`%`]})]}),e.lastCapture&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,B.jsx)(`span`,{children:new Date(e.lastCapture).toLocaleDateString()})]}),e.needsSummarization&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-warning font-medium`,children:[(0,B.jsx)(T,{className:`h-2.5 w-2.5`}),`optimize`]})]})]},e.role))})]})}var te={size:`buffer reached the size threshold`,"pending-skills":`directives are waiting to reach their skill`,disabled:`auto-optimization is off`,"learning-paused":`learning is paused for this agent`,"too-few-entries":`not enough directives yet`,"below-threshold":`below the threshold`,"cooling-down":`recently optimized — cooling down`};function ne({selectedRole:e,selectedStats:t,saving:r,setLearningEnabled:a,optimizing:s,runOptimize:c,autoStatus:l,consolidatedContent:d,loadConsolidated:f,setConsolidatedContent:p,skills:m,toggleSkillBody:h,toggleSkillPin:v,openSkill:y,retired:b,showRetired:x,setShowRetired:S,loadEntries:w,loadingEntries:D,reviewEntries:O,reviewDecisions:k,setReviewEntries:j,setReviewDecisions:M,applyReview:N,teachInput:P,setTeachInput:F,runTeach:I,teachFeedback:L}){let{t:R}=n();return(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsx)(`h3`,{className:`text-base font-semibold`,children:e}),(0,B.jsx)(`div`,{className:`flex gap-1`,children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>a(e,!t.learningEnabled),disabled:r,className:A(`inline-flex items-center gap-1 rounded border px-2 py-1 text-[10px] transition-colors disabled:opacity-50`,t.learningEnabled?`border-success/40 text-success hover:bg-success/10`:`border-border/50 text-muted-foreground hover:bg-accent`),children:[(0,B.jsx)(E,{className:`h-3 w-3`}),` `,t.learningEnabled?R(`activity:agentRoster.learningOn`):R(`activity:agentRoster.learningPaused`)]})})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:R(`activity:agentRoster.entries`)}),(0,B.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:t.entryCount})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:R(`activity:agentRoster.size`)}),(0,B.jsxs)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:[t.totalBytes,`B`]})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:R(`activity:agentRoster.lifetimeCaptures`)}),(0,B.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:t.lifetimeCaptureCount})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:R(`activity:agentRoster.lastCapture`)}),(0,B.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:t.lastCapture?new Date(t.lastCapture).toLocaleDateString():`—`})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,title:`Share of directive applications that ended in a successful task. Blank until a directive has actually been exercised on one.`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:R(`activity:agentRoster.hitRate`)}),(0,B.jsxs)(`div`,{className:A(`text-lg font-mono font-semibold mt-0.5`,typeof t.directiveHitRate==`number`&&(t.directiveHitRate>=.7?`text-success`:t.directiveHitRate<.4&&`text-warning`)),children:[typeof t.directiveHitRate==`number`?`${Math.round(t.directiveHitRate*100)}%`:`—`,typeof t.appliedEntryCount==`number`&&t.appliedEntryCount>0&&(0,B.jsxs)(`span`,{className:`text-[9px] text-muted-foreground font-sans ml-1`,children:[`of `,t.appliedEntryCount]})]})]}),(0,B.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,title:`Directives that have never been exercised on a task. Anchors — exact commands, paths, package names — are what let the runtime tell that a directive was applied.`,children:[(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:R(`activity:agentRoster.neverUsed`)}),(0,B.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:typeof t.deadEntryCount==`number`?t.deadEntryCount:`—`})]})]}),t.needsSummarization&&(0,B.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-warning bg-warning/10 rounded-lg px-3 py-2.5`,children:[(0,B.jsx)(o,{className:`h-4 w-4 shrink-0`}),(0,B.jsx)(`span`,{className:`flex-1`,children:R(`activity:agentRoster.learningsLimitExceeded`,{bytes:t.totalBytes.toLocaleString()})}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>c(e),disabled:s,className:`inline-flex items-center gap-1 rounded bg-warning/20 text-warning border border-warning/40 px-2.5 py-1 text-[10px] font-medium hover:bg-warning/30 transition-colors disabled:opacity-50 shrink-0`,children:[s?(0,B.jsx)(C,{className:`h-3 w-3 animate-spin`}):(0,B.jsx)(T,{className:`h-3 w-3`}),s?R(`activity:agentRoster.optimizing`):`Optimize Now`]})]}),(0,B.jsxs)(`div`,{className:`space-y-2 border border-border rounded-lg p-3 bg-card`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(u,{className:`h-4 w-4 text-primary`}),(0,B.jsx)(`span`,{className:`text-xs font-semibold`,children:R(`activity:agentRoster.optimizeLearnings`)})]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>c(e),disabled:s||t.entryCount===0,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,title:t.entryCount===0?`No raw entries to optimize`:`Synthesize raw entries into a consolidated, narrowly-scoped document`,children:[s?(0,B.jsx)(C,{className:`h-3.5 w-3.5 animate-spin`}):(0,B.jsx)(T,{className:`h-3.5 w-3.5`}),s?R(`activity:agentRoster.optimizing`):`Optimize`]})]}),l&&(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px]`,children:[(0,B.jsx)(`span`,{className:A(`inline-block h-1.5 w-1.5 rounded-full`,l.enabled?l.eligible?`bg-warning`:`bg-success`:`bg-muted-foreground`)}),(0,B.jsx)(`span`,{className:`text-muted-foreground`,children:l.enabled?l.eligible?`Queued automatically: ${te[l.reason]??l.reason}.`:`Automatic — ${te[l.reason]??l.reason}.`:`Automatic optimization is off — run it manually.`})]}),(0,B.jsxs)(`p`,{className:`text-[10px] text-muted-foreground leading-relaxed`,children:[`Synthesizes all `,t.entryCount,` raw entries into a single reviewed document — narrowly scoped to this agent's skills, preserving every fact but reducing context volume. The result replaces raw entries in the agent's prompt.`]}),t.isConsolidated&&t.consolidation&&(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground pt-1 border-t border-border/50`,children:[(0,B.jsx)(i,{className:`h-3 w-3 text-success`}),(0,B.jsxs)(`span`,{children:[`Consolidated`,` `,new Date(t.consolidation.consolidatedAt).toLocaleDateString(),` ·`,` `,t.consolidation.sourceBytes,`B →`,` `,t.consolidation.consolidatedBytes,`B`,t.consolidation.sourceEntryCount<t.entryCount&&(0,B.jsxs)(`span`,{className:`text-warning ml-1`,children:[`· `,t.entryCount-t.consolidation.sourceEntryCount,` `,R(`activity:agentRoster.newPending`)]})]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{d===null?f(e):p(null)},className:`ml-auto underline text-primary hover:text-primary/80`,children:d===null?R(`activity:agentRoster.viewAction`):`Hide`})]}),d!==null&&(0,B.jsxs)(`div`,{className:`mt-2 max-h-72 overflow-y-auto rounded border border-border/50 bg-background/50 p-2`,children:[(0,B.jsxs)(`div`,{className:`text-[10px] text-muted-foreground mb-1 font-medium`,children:[`Consolidated knowledge for `,e]}),(0,B.jsx)(`pre`,{className:`text-[10px] whitespace-pre-wrap font-sans leading-relaxed`,children:d||`(empty)`})]})]}),m&&m.length>0&&(0,B.jsxs)(`div`,{className:`space-y-2 border border-border rounded-lg p-3 bg-card`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(g,{className:`h-4 w-4 text-brand-2`}),(0,B.jsx)(`span`,{className:`text-xs font-semibold`,children:`Skills`}),(0,B.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[m.filter(e=>e.developed).length,` of `,m.length,` developed for this project`]})]}),(0,B.jsxs)(`p`,{className:`text-[10px] text-muted-foreground leading-relaxed`,children:[`A developed skill carries a project addendum injected right after the bundled skill body — the agent reads one skill, refined for this codebase. Only the highest-ranked few are loaded per spawn; `,(0,B.jsx)(`span`,{className:`text-primary`,children:`loaded`}),` marks those.`]}),(0,B.jsx)(`div`,{className:`space-y-1`,children:m.map(t=>(0,B.jsxs)(`div`,{className:`rounded border border-border/60`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>h(e,t.skill),disabled:!t.developed,className:A(`text-[11px] font-mono text-left flex-1 truncate`,t.developed?`text-primary hover:underline`:`text-muted-foreground cursor-default`),children:t.skill}),t.eager&&(0,B.jsx)(`span`,{className:`text-[9px] rounded bg-primary/15 text-primary px-1.5 py-0.5`,title:`Ranked high enough to be loaded into a spawn of this role`,children:`loaded`}),t.developed&&(0,B.jsx)(`span`,{className:`text-[9px] rounded bg-success/15 text-success px-1.5 py-0.5`,children:`developed`}),t.affinity&&(0,B.jsxs)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,children:[t.affinity.learned>0&&`${t.affinity.learned} learned · `,t.affinity.succeeded,`✓/`,t.affinity.failed,`✗`]}),typeof t.score==`number`&&(0,B.jsx)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,title:`Project affinity score — higher is loaded first`,children:t.score.toFixed(2)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>v(e,t.skill,!t.affinity?.pinned),className:A(`text-[9px] rounded border px-1.5 py-0.5 transition-colors`,t.affinity?.pinned?`border-primary/50 text-primary`:`border-border/50 text-muted-foreground hover:bg-accent`),children:t.affinity?.pinned?`pinned`:`pin`})]}),y?.skill===t.skill&&(0,B.jsx)(`div`,{className:`max-h-60 overflow-y-auto border-t border-border/50 bg-background/50 p-2`,children:(0,B.jsx)(`pre`,{className:`text-[10px] whitespace-pre-wrap font-sans leading-relaxed`,children:y.content||`(empty)`})})]},t.skill))})]}),b&&b.length>0&&(0,B.jsxs)(`div`,{className:`space-y-2 border border-border rounded-lg p-3 bg-card`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>S(e=>!e),className:`flex w-full items-center gap-1.5 text-left`,children:[(0,B.jsx)(o,{className:`h-4 w-4 text-warning`}),(0,B.jsx)(`span`,{className:`text-xs font-semibold`,children:`Retired`}),(0,B.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[b.length,` directive`,b.length===1?``:`s`,` no longer injected`]}),(0,B.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:x?`hide`:`show`})]}),x&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`text-[10px] text-muted-foreground leading-relaxed`,children:`Each of these was exercised repeatedly and kept correlating with failed tasks, so it was removed from the buffer and scrubbed out of the distilled documents.`}),(0,B.jsx)(`ul`,{className:`space-y-1`,children:b.map(e=>(0,B.jsxs)(`li`,{className:`rounded border border-border/60 px-2 py-1.5 text-[10px] leading-relaxed`,children:[e.skill&&(0,B.jsx)(`span`,{className:`mr-1.5 rounded bg-muted px-1 py-0.5 font-mono text-[9px] text-muted-foreground`,children:e.skill}),(0,B.jsx)(`span`,{className:`text-muted-foreground line-through`,children:e.what})]},e.what))})]})]}),t.entryCount>0&&(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>w(e),disabled:D,className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[D?(0,B.jsx)(C,{className:`h-3 w-3 animate-spin`}):(0,B.jsx)(_,{className:`h-3 w-3`}),`Review Learned Entries (`,t.entryCount,`)`]})}),O&&(0,B.jsxs)(`div`,{className:`space-y-2 border border-border rounded-lg p-3 bg-card`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`span`,{className:`text-xs font-medium`,children:[O.filter((e,t)=>k[t]!==`drop`).length,`/`,O.length,` kept`]}),(0,B.jsxs)(`div`,{className:`flex gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:N,disabled:r,className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[10px] text-primary-foreground hover:bg-primary/90 transition-colors`,children:r?R(`activity:agentRoster.applying`):`Apply Selection`}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{j(null),M({})},className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors`,children:R(`activity:agentRoster.cancel`)})]})]}),(0,B.jsx)(`div`,{className:`max-h-72 overflow-y-auto space-y-2`,children:O.map((e,t)=>{let n=k[t]??`keep`,r=e.length>200?e.slice(0,200)+`…`:e;return(0,B.jsx)(`div`,{className:A(`rounded-lg border p-2 transition-colors`,n===`drop`?`border-destructive/40 bg-destructive/5 opacity-60`:`border-border`),children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,B.jsx)(`pre`,{className:`text-[10px] whitespace-pre-wrap flex-1 leading-relaxed font-sans`,children:r}),(0,B.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>M(e=>({...e,[t]:`keep`})),className:A(`px-2 py-1 text-[9px] rounded`,n===`keep`?`bg-success/20 text-success`:`bg-muted text-muted-foreground`),children:R(`activity:agentRoster.keep`)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>M(e=>({...e,[t]:`drop`})),className:A(`px-2 py-1 text-[9px] rounded`,n===`drop`?`bg-destructive/20 text-destructive`:`bg-muted text-muted-foreground`),children:R(`activity:agentRoster.drop`)})]})]})},t)})})]})]}),(0,B.jsxs)(`div`,{className:`space-y-2 pt-4 border-t border-border`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1 text-sm font-medium`,children:[(0,B.jsx)(g,{className:`h-4 w-4 text-brand-2`}),` `,R(`activity:agentRoster.teachThisAgent`)]}),(0,B.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:R(`activity:agentRoster.describeACommandPatternOrBehavior`)}),(0,B.jsx)(`textarea`,{className:`w-full h-20 text-xs p-2 bg-card border border-border rounded resize-y`,value:P,onChange:e=>F(e.target.value),placeholder:R(`activity:agentRoster.eGAlwaysUsePnpmForThisProject`)}),(0,B.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:I,disabled:!P.trim()||r,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:[(0,B.jsx)(g,{className:`h-3.5 w-3.5`}),` `,R(`activity:agentRoster.teach`)]}),L&&(0,B.jsx)(`span`,{className:A(`text-xs`,L.ok?`text-success`:`text-destructive`),children:L.msg})]})]})]})}function re({customStats:e,onRefresh:r}){let{t:i}=n(),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)({}),[d,f]=(0,z.useState)(``),[p,m]=(0,z.useState)(null),[h,g]=(0,z.useState)(!1),[_,v]=(0,z.useState)(!1),[y,b]=(0,z.useState)(null),[x,S]=(0,z.useState)(!1),[C,w]=(0,z.useState)(!1),[T,E]=(0,z.useState)(null),[D,O]=(0,z.useState)(null),[A,j]=(0,z.useState)(!1),[N,F]=(0,z.useState)(null),[I,L]=(0,z.useState)(null),B=(0,z.useMemo)(()=>[...e].sort((e,t)=>e.role.localeCompare(t.role)),[e]),V=(0,z.useMemo)(()=>a?B.find(e=>e.role===a):null,[a,B]),H=(0,z.useCallback)(async e=>{v(!0),c(null);try{let t=await R(`agent-roster.read-learned`,{role:e});c(t.entries??[]),u({})}catch{}v(!1)},[]),U=(0,z.useCallback)(async()=>{if(!a||!s)return;g(!0);let e=s.filter((e,t)=>l[t]!==`drop`).join(`
|
|
2
2
|
|
|
3
3
|
---
|
|
4
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ba as t,Ci as n,Ga as r,Nt as i,Ot as a,Pa as o,Yn as s,bi as c,kt as l,lt as u,oa as d,or as f,yt as p}from"./vendor-DLS502Zs.js";import"./i18n-CYYBUSJB.js";import{t as m}from"./ws-client-DYrfK01f.js";import{R as h}from"./stores-BUtRik4k.js";import{b as g,c as _,x as v}from"./index-cUeJ0FkT.js";var y=e(r(),1),b=u();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}=t(),[r,u]=(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();u(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)return;I(!0);let e=null,t=null;try{let n=m(h.getState().wsUrl);L.current=n,t=n.on(`stats.get`,n=>{let r=n.payload;M(r),I(!1),t?.(),e!==null&&clearTimeout(e)}),n.getStats({echoToChat:!1}),e=setTimeout(()=>{t?.(),I(!1)},8e3)}catch{t?.(),e!==null&&clearTimeout(e),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)(()=>r?Object.entries(r.categoryBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,8):[],[r]),q=(0,y.useMemo)(()=>r?Object.entries(r.eventBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,10):[],[r]),J=(0,y.useMemo)(()=>{if(!r)return 0;let e=0;for(let[t,n]of Object.entries(r.eventBreakdown))t.toLowerCase().includes(`error`)&&(e+=n);return e},[r]),Y=(0,y.useMemo)(()=>{if(!r)return 0;let e=0;for(let[t,n]of Object.entries(r.eventBreakdown))t.toLowerCase().includes(`warn`)&&(e+=n);return e},[r]),X=(0,y.useMemo)(()=>[...D].reverse(),[D]),Z=v(X,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)(f,{className:`h-4 w-4 animate-spin text-primary`}),e(`activity:analytics.loading`)]})}):(0,b.jsx)(`div`,{ref:_(`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)(d,{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)(o,{className:`h-4 w-4`}),label:e(`activity:analytics.liveSessions`),value:k.length,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(p,{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)(s,{className:`h-4 w-4`}),label:e(`activity:analytics.totalEvents`),value:r?.totalEvents??0,sub:e(`activity:analytics.categoriesSub`,{count:r?.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)(c,{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)(n,{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)(l,{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)(d,{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)(c,{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:r?(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:r.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)(o,{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:Z.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)(g,{page:Z.page,pageSize:Z.pageSize,totalItems:Z.totalItems,onPageChange:Z.setPage,compact:!0,itemLabel:`events`,className:`mt-3 rounded-lg border`})]})]})]})})}export{D as AnalyticsDashboard};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ba as t,Ci as n,Ga as r,Nt as i,Ot as a,Pa as o,Yn as s,bi as c,kt as l,lt as u,oa as d,or as f,yt as p}from"./vendor-DZ9_OO6N.js";import"./i18n-n_1tBMdC.js";import{t as m}from"./ws-client-DXT4gi-N.js";import{R as h}from"./stores-d8rhzRAc.js";import{b as g,c as _,x as v}from"./index-gKjRx1pQ.js";var y=e(r(),1),b=u();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}=t(),[r,u]=(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();u(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)return;I(!0);let e=null,t=null;try{let n=m(h.getState().wsUrl);L.current=n,t=n.on(`stats.get`,n=>{let r=n.payload;M(r),I(!1),t?.(),e!==null&&clearTimeout(e)}),n.getStats({echoToChat:!1}),e=setTimeout(()=>{t?.(),I(!1)},8e3)}catch{t?.(),e!==null&&clearTimeout(e),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)(()=>r?Object.entries(r.categoryBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,8):[],[r]),q=(0,y.useMemo)(()=>r?Object.entries(r.eventBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,10):[],[r]),J=(0,y.useMemo)(()=>{if(!r)return 0;let e=0;for(let[t,n]of Object.entries(r.eventBreakdown))t.toLowerCase().includes(`error`)&&(e+=n);return e},[r]),Y=(0,y.useMemo)(()=>{if(!r)return 0;let e=0;for(let[t,n]of Object.entries(r.eventBreakdown))t.toLowerCase().includes(`warn`)&&(e+=n);return e},[r]),X=(0,y.useMemo)(()=>[...D].reverse(),[D]),Z=v(X,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)(f,{className:`h-4 w-4 animate-spin text-primary`}),e(`activity:analytics.loading`)]})}):(0,b.jsx)(`div`,{ref:_(`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)(d,{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)(o,{className:`h-4 w-4`}),label:e(`activity:analytics.liveSessions`),value:k.length,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(p,{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)(s,{className:`h-4 w-4`}),label:e(`activity:analytics.totalEvents`),value:r?.totalEvents??0,sub:e(`activity:analytics.categoriesSub`,{count:r?.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)(c,{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)(n,{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)(l,{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)(d,{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)(c,{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.hitRatio*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})]}),(j.cache.providers?.length??0)>0?(0,b.jsxs)(`div`,{className:`col-span-2 rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:`Provider cache breakdown`}),(0,b.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:j.cache.providers?.map(e=>(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 font-mono`,children:[(0,b.jsx)(`span`,{className:`text-foreground`,children:e.provider}),(0,b.jsxs)(`span`,{className:`tabular-nums text-success`,children:[(e.hitRatio*100).toFixed(1),`% hit`]}),(0,b.jsxs)(`span`,{className:`tabular-nums text-muted-foreground`,children:[S(e.cacheRead),` read · `,S(e.cacheWrite),` write`]})]},e.provider))})]}):null]}):(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:r?(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.hitRatio*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:r.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)(o,{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:Z.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)(g,{page:Z.page,pageSize:Z.pageSize,totalItems:Z.totalItems,onPageChange:Z.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-hePW80VL.js";import{Ba as t,Ft as n,Ga as r,Tn as i,Tt as a,Xt as o,an as s,dt as c,jt as l,lt as u,yi as d,yn as f,zr as p}from"./vendor-DLS502Zs.js";import"./i18n-CYYBUSJB.js";import{t as m}from"./useWebSocket-Ew1Bbjci.js";import{t as h}from"./utils-B5X3DKef.js";import{a as g,i as _,n as v,o as y,r as b,t as x}from"./dialog-BMrjwjA6.js";import{t as S}from"./button-DAT5OnLL.js";import{t as C}from"./input-Ccsxvwz6.js";import{b as w,x as T}from"./index-cUeJ0FkT.js";import{g as E,i as D,r as O,y as k}from"./shared-Y6T3EEnd.js";var A=e(r(),1),j=u();function M(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 N(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n={roles:M(t.roles),taskTypes:M(t.taskTypes),modes:M(t.modes)};return n.roles||n.taskTypes||n.modes?n:void 0}function P(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=N(t.audience);if(!n||!a){i++;continue}let o=typeof t.kind==`string`&&D.some(e=>e===t.kind)?t.kind:void 0,s=M(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 F(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 I(e,t){return[...new Set(e.flatMap(e=>e.audience?.[t]??[]).filter(e=>e.length>0))].sort((e,t)=>e.localeCompare(t))}function L(){let{t:e}=t(),r=m(),[o,u]=(0,A.useState)([]),[D,O]=(0,A.useState)(!0),[k,M]=(0,A.useState)(null),[N,L]=(0,A.useState)(``),[z,B]=(0,A.useState)(!1),[ae,V]=(0,A.useState)(!1),[H,U]=(0,A.useState)(null),[W,G]=(0,A.useState)(!1),[K,q]=(0,A.useState)(!1),J=(0,A.useRef)(null),Y=(0,A.useCallback)(()=>{O(!0),M(null),r.listSageMemories({echoToChat:!1})},[r.listSageMemories]);(0,A.useEffect)(()=>{let t=r.client,n=t.on(`memory.sage.list`,e=>{let t=e.payload;t.error?M({tone:`error`,text:t.error}):u(t.memories??[]),O(!1)}),i=t.on(`memory.sage.remember`,e=>{let t=e.payload;if(G(!1),t.error){M({tone:`error`,text:t.error});return}t.memory&&(u(e=>[t.memory,...e.filter(e=>e.id!==t.memory.id)]),B(!1))}),a=t.on(`memory.sage.update`,t=>{let n=t.payload;n.error?M({tone:`error`,text:n.error}):n.memory&&(u(e=>e.map(e=>e.id===n.memory.id?n.memory:e)),n.memory.audience||M({tone:`success`,text:e(`activity:audienceMem.scopeRemoved`)}))}),o=t.on(`memory.sage.delete`,t=>{let n=t.payload,r=J.current;n.success&&r?(u(e=>e.filter(e=>e.id!==r)),M({tone:`success`,text:e(`activity:audienceMem.deleted`)}),U(null),q(!1),J.current=null):n.success?Y():(M({tone:`error`,text:n.message??`Could not delete the memory.`}),q(!1),J.current=null)});return Y(),()=>{n(),i(),a(),o()}},[Y,r.client]);let X=(0,A.useMemo)(()=>o.filter(e=>{let t=e.audience;return!!(t&&(t.roles?.length||t.taskTypes?.length||t.modes?.length))}),[o]),Z=N.trim(),Q=(0,A.useMemo)(()=>X.filter(e=>F(e,Z)),[Z,X]),$=T(Q,16,Z),oe=(0,A.useMemo)(()=>I(X,`roles`),[X]),se=(0,A.useMemo)(()=>I(X,`taskTypes`),[X]),ce=(0,A.useMemo)(()=>I(X,`modes`),[X]),le=e=>{M(null),r.updateSage(e,{audience:void 0},{echoToChat:!1})},ue=()=>{H&&(J.current=H,q(!0),M(null),r.deleteSage(H,`Removed from the audience memory panel.`))},de=async()=>{let t=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(t,null,2)),M({tone:`success`,text:e(`activity:audienceMem.copiedAsJson`,{count:t.length})})}catch(t){M({tone:`error`,text:t instanceof Error?t.message:e(`activity:audienceMem.copyFailed`)})}};return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-card/20`,"aria-labelledby":`audience-memory-title`,children:[(0,j.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 p-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,j.jsx)(`div`,{className:`min-w-0`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.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,j.jsx)(n,{className:`size-3.5`})}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h2`,{id:`audience-memory-title`,className:`truncate text-sm font-semibold`,children:e(`activity:audienceMem.heading`)}),(0,j.jsx)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:e(`activity:audienceMem.subheading`)})]})]})}),(0,j.jsxs)(S,{variant:`default`,size:`sm`,className:`h-7 shrink-0 gap-1 px-2 text-xs`,onClick:()=>B(!0),children:[(0,j.jsx)(i,{className:`size-3`}),e(`common:action.add`)]})]}),(0,j.jsxs)(`div`,{className:`mt-3 grid grid-cols-4 gap-px overflow-hidden rounded-md border border-border/60 bg-border/60`,children:[(0,j.jsx)(R,{value:X.length,label:e(`activity:audienceMem.statMemories`)}),(0,j.jsx)(R,{value:oe.length,label:e(`activity:audienceMem.statRoles`)}),(0,j.jsx)(R,{value:se.length,label:e(`activity:audienceMem.statTasks`)}),(0,j.jsx)(R,{value:ce.length,label:e(`activity:audienceMem.statModes`)})]}),(0,j.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,j.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,j.jsx)(s,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,j.jsx)(C,{value:N,onChange:e=>L(e.target.value),placeholder:e(`activity:audienceMem.searchTextRoleTaskOrMode`),"aria-label":e(`activity:audienceMem.searchAudienceMemories`),className:`h-8 pl-8 pr-8 text-xs`}),N&&(0,j.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:()=>L(``),"aria-label":e(`activity:audienceMem.clearAudienceMemorySearch`),children:(0,j.jsx)(c,{className:`size-3`})})]}),(0,j.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:Y,"aria-label":e(`activity:audienceMem.refreshAudienceMemories`),title:e(`activity:audienceMem.refresh`),children:(0,j.jsx)(f,{className:h(`size-3.5`,D&&`animate-spin`)})}),(0,j.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>V(!0),"aria-label":e(`activity:audienceMem.importAudienceMemories`),title:e(`activity:audienceMem.importJson`),children:(0,j.jsx)(a,{className:`size-3.5`})}),(0,j.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>void de(),"aria-label":e(`activity:audienceMem.copyAudienceMemoriesAsJson`),title:e(`activity:audienceMem.copyJson`),disabled:X.length===0,children:(0,j.jsx)(d,{className:`size-3.5`})})]})]}),k&&(0,j.jsxs)(`div`,{role:k.tone===`error`?`alert`:`status`,className:h(`mx-3 mt-3 flex shrink-0 items-start justify-between gap-2 rounded-md border px-2.5 py-2 text-[11px]`,k.tone===`error`?`border-destructive/30 bg-destructive/5 text-destructive`:`border-success/30 bg-success/5 text-success`),children:[(0,j.jsx)(`span`,{children:k.text}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>M(null),className:`shrink-0 rounded-sm opacity-70 hover:opacity-100`,"aria-label":e(`activity:audienceMem.dismissMessage`),children:(0,j.jsx)(c,{className:`size-3`})})]}),(0,j.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[!D&&X.length>0&&(0,j.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-3 pb-1.5 pt-3 text-[10px] text-muted-foreground`,children:[(0,j.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(p,{className:`size-3`}),Z?`${Q.length} of ${X.length}`:`${X.length} scoped`]}),Z&&(0,j.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,onClick:()=>L(``),children:e(`activity:audienceMem.clearFilter`)})]}),(0,j.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[D?(0,j.jsx)(te,{}):X.length===0?(0,j.jsx)(ne,{onAdd:()=>B(!0)}):Q.length===0?(0,j.jsxs)(`div`,{className:`flex h-full min-h-32 flex-col items-center justify-center px-4 text-center`,children:[(0,j.jsx)(s,{className:`mb-2 size-5 text-muted-foreground/60`}),(0,j.jsx)(`p`,{className:`text-xs font-medium`,children:e(`activity:audienceMem.noMatching`)}),(0,j.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:e(`activity:audienceMem.noMatchingHint`)}),(0,j.jsx)(S,{variant:`ghost`,size:`sm`,className:`mt-2 h-7 text-xs`,onClick:()=>L(``),children:e(`activity:audienceMemoryPanel.clearSearch`)})]}):(0,j.jsx)(`ul`,{className:`space-y-2`,children:$.pageItems.map(e=>(0,j.jsx)(ee,{memory:e,onFilter:L,onClearScope:()=>le(e.id),onDelete:()=>U(e.id)},e.id))}),(0,j.jsx)(w,{page:$.page,pageSize:$.pageSize,totalItems:$.totalItems,onPageChange:$.setPage,compact:!0,itemLabel:`memories`})]})]})]}),(0,j.jsx)(re,{open:z,busy:W,onOpenChange:e=>{W||B(e)},onCreate:e=>{M(null),G(!0),r.rememberSage({text:e.text,kind:e.kind,audience:{roles:e.roles.length>0?e.roles:void 0,taskTypes:e.taskTypes.length>0?e.taskTypes:void 0,modes:e.modes.length>0?e.modes:void 0}},{echoToChat:!1})}}),(0,j.jsx)(ie,{open:ae,onOpenChange:V,onImport:t=>{try{let{entries:n,skipped:i}=P(t);if(n.length===0)return M({tone:`error`,text:e(`activity:audienceMem.noValidInJson`)}),!1;for(let e of n)r.rememberSage(e,{echoToChat:!1});return M({tone:`success`,text:e(`activity:audienceMem.queuedForImport`,{count:n.length})+(i?e(`activity:audienceMem.skippedSuffix`,{count:i}):`.`)}),V(!1),!0}catch(t){return M({tone:`error`,text:t instanceof Error?t.message:e(`activity:customRoster.invalidJson`)}),!1}}}),(0,j.jsx)(x,{open:!!H,onOpenChange:e=>{!e&&!K&&U(null)},children:(0,j.jsxs)(v,{className:`max-w-md`,children:[(0,j.jsxs)(g,{children:[(0,j.jsx)(y,{children:e(`activity:audienceMem.deleteTitle`)}),(0,j.jsx)(b,{children:e(`activity:audienceMem.deleteBody`)})]}),(0,j.jsx)(`div`,{className:`rounded-md border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:E(o.find(e=>e.id===H)?.text??``,180)}),(0,j.jsxs)(_,{children:[(0,j.jsx)(S,{variant:`outline`,onClick:()=>U(null),disabled:K,children:`Cancel`}),(0,j.jsxs)(S,{variant:`destructive`,onClick:ue,disabled:K,children:[(0,j.jsx)(l,{className:`size-4`}),K?`Deleting…`:`Delete memory`]})]})]})})]})}function R({value:e,label:t}){return(0,j.jsxs)(`div`,{className:`bg-card/95 px-1.5 py-2 text-center`,children:[(0,j.jsx)(`p`,{className:`text-sm font-semibold tabular-nums`,children:e}),(0,j.jsx)(`p`,{className:`truncate text-[9px] uppercase tracking-wide text-muted-foreground`,children:t})]})}function ee({memory:e,onFilter:n,onClearScope:r,onDelete:i}){let{t:a}=t();return(0,j.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,j.jsx)(`p`,{className:`break-words text-xs leading-5`,children:e.text}),e.audience&&(0,j.jsx)(z,{audience:e.audience,onFilter:n}),(0,j.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 border-t border-border/45 pt-2`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[9px] uppercase tracking-wide text-muted-foreground`,children:[(0,j.jsx)(`span`,{className:`truncate`,children:O[e.kind]??e.kind}),(0,j.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,j.jsx)(`span`,{children:e.status})]}),(0,j.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,j.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:r,"aria-label":`Remove audience scope from ${E(e.text,42)}`,title:a(`activity:audienceMem.makeGeneralMemory`),children:(0,j.jsx)(o,{className:`size-3`})}),(0,j.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-6 text-destructive hover:text-destructive`,onClick:i,"aria-label":`Delete ${E(e.text,42)}`,title:a(`activity:audienceMem.delete`),children:(0,j.jsx)(l,{className:`size-3`})})]})]})]})}function z({audience:e,onFilter:t}){let n=[...(e.roles??[]).map(e=>({label:`role`,value:e})),...(e.taskTypes??[]).map(e=>({label:`task`,value:e})),...(e.modes??[]).map(e=>({label:`mode`,value:e}))];return(0,j.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:n.map(({label:e,value:n})=>(0,j.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 te(){let{t:e}=t();return(0,j.jsx)(`div`,{className:`space-y-2 pt-3`,role:`status`,"aria-label":e(`activity:audienceMem.loadingAudienceMemories`),children:[0,1,2].map(e=>(0,j.jsxs)(`div`,{className:`animate-pulse rounded-md border border-border/50 p-3`,children:[(0,j.jsx)(`div`,{className:`h-2.5 w-full rounded bg-muted`}),(0,j.jsx)(`div`,{className:`mt-2 h-2.5 w-2/3 rounded bg-muted`}),(0,j.jsx)(`div`,{className:`mt-3 h-4 w-24 rounded bg-muted`})]},e))})}function ne({onAdd:e}){let{t:r}=t();return(0,j.jsxs)(`div`,{className:`flex h-full min-h-44 flex-col items-center justify-center px-5 text-center`,children:[(0,j.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,j.jsx)(n,{className:`size-4`})}),(0,j.jsx)(`p`,{className:`text-xs font-medium`,children:r(`activity:audienceMem.emptyTitle`)}),(0,j.jsx)(`p`,{className:`mt-1 max-w-52 text-[10px] leading-4 text-muted-foreground`,children:r(`activity:audienceMem.emptyBody`)}),(0,j.jsxs)(S,{variant:`outline`,size:`sm`,className:`mt-3 h-7 gap-1 text-xs`,onClick:e,children:[(0,j.jsx)(i,{className:`size-3`}),r(`activity:audienceMem.addScoped`)]})]})}function re({open:e,busy:n,onOpenChange:r,onCreate:i}){let{t:a}=t(),[o,s]=(0,A.useState)(``),[c,l]=(0,A.useState)(`workflow`),[u,d]=(0,A.useState)(``),[f,p]=(0,A.useState)(``),[m,h]=(0,A.useState)(``);(0,A.useEffect)(()=>{e||(s(``),l(`workflow`),d(``),p(``),h(``))},[e]);let C=k(u),w=k(f),T=k(m),E=o.trim().length>0&&(C.length>0||w.length>0||T.length>0);return(0,j.jsx)(x,{open:e,onOpenChange:r,children:(0,j.jsxs)(v,{className:`max-w-xl`,children:[(0,j.jsxs)(g,{children:[(0,j.jsx)(y,{children:a(`activity:audienceMem.createTitle`)}),(0,j.jsx)(b,{children:a(`activity:audienceMem.createBody`)})]}),(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`audience-memory-text`,className:`mb-1.5 block text-xs font-medium`,children:a(`activity:audienceMem.fieldMemory`)}),(0,j.jsx)(`textarea`,{id:`audience-memory-text`,value:o,onChange:e=>s(e.target.value),placeholder:a(`activity:audienceMem.whatShouldMatchingAgentsRemember`),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,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`audience-memory-kind`,className:`mb-1.5 block text-xs font-medium`,children:a(`activity:audienceMem.fieldKind`)}),(0,j.jsx)(`select`,{id:`audience-memory-kind`,value:c,onChange:e=>l(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:D.map(e=>(0,j.jsx)(`option`,{value:e,children:O[e]??e},e))})]}),(0,j.jsxs)(`fieldset`,{className:`space-y-3 rounded-md border border-border/70 bg-background/35 p-3`,children:[(0,j.jsx)(`legend`,{className:`px-1 text-xs font-medium`,children:a(`activity:audienceMem.selectors`)}),(0,j.jsx)(B,{id:`audience-memory-roles`,label:a(`activity:audienceMem.statRoles`),value:u,onChange:d,placeholder:a(`activity:audienceMem.reviewerRefactorPlanner`)}),(0,j.jsx)(B,{id:`audience-memory-task-types`,label:a(`activity:audienceMem.fieldTaskTypes`),value:f,onChange:p,placeholder:a(`activity:audienceMem.reviewRefactorBugfix`)}),(0,j.jsx)(B,{id:`audience-memory-modes`,label:a(`activity:audienceMem.statModes`),value:m,onChange:h,placeholder:a(`activity:audienceMem.teachCodeReview`)}),(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:a(`activity:audienceMem.selectorsHint`)})]})]}),(0,j.jsxs)(_,{children:[(0,j.jsx)(S,{variant:`outline`,onClick:()=>r(!1),disabled:n,children:a(`common:action.cancel`)}),(0,j.jsx)(S,{onClick:()=>i({text:o.trim(),kind:c,roles:C,taskTypes:w,modes:T}),disabled:!E||n,children:n?`Remembering…`:`Remember`})]})]})})}function B({id:e,label:t,value:n,placeholder:r,onChange:i}){return(0,j.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[6rem_1fr] sm:items-center`,children:[(0,j.jsx)(`label`,{htmlFor:e,className:`text-[11px] font-medium text-muted-foreground`,children:t}),(0,j.jsx)(C,{id:e,value:n,onChange:e=>i(e.target.value),placeholder:r,className:`h-8 font-mono text-xs`})]})}function ie({open:e,onOpenChange:n,onImport:r}){let{t:i}=t(),[o,s]=(0,A.useState)(``);return(0,A.useEffect)(()=>{e||s(``)},[e]),(0,j.jsx)(x,{open:e,onOpenChange:n,children:(0,j.jsxs)(v,{className:`max-w-xl`,children:[(0,j.jsxs)(g,{children:[(0,j.jsx)(y,{children:i(`activity:audienceMem.importTitle`)}),(0,j.jsxs)(b,{children:[i(`activity:audienceMem.importBodyBefore`),` `,(0,j.jsx)(`code`,{children:i(`activity:audienceMemoryPanel.memoryAudienceExport`)}),`.`,` `,i(`activity:audienceMem.importBodyAfter`)]})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`audience-memory-import`,className:`mb-1.5 block text-xs font-medium`,children:i(`activity:audienceMem.jsonArray`)}),(0,j.jsx)(`textarea`,{id:`audience-memory-import`,value:o,onChange:e=>s(e.target.value),placeholder:`[
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ba as t,Ft as n,Ga as r,Tn as i,Tt as a,Xt as o,an as s,dt as c,jt as l,lt as u,yi as d,yn as f,zr as p}from"./vendor-DZ9_OO6N.js";import"./i18n-n_1tBMdC.js";import{t as m}from"./useWebSocket-Co9oG6EI.js";import{t as h}from"./utils-BecmXwgG.js";import{a as g,i as _,n as v,o as y,r as b,t as x}from"./dialog-DPl7DolS.js";import{t as S}from"./button-Dhmop_yM.js";import{t as C}from"./input-C3rIQ26u.js";import{b as w,x as T}from"./index-gKjRx1pQ.js";import{g as E,i as D,r as O,y as k}from"./shared-BUXBOqyO.js";var A=e(r(),1),j=u();function M(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 N(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n={roles:M(t.roles),taskTypes:M(t.taskTypes),modes:M(t.modes)};return n.roles||n.taskTypes||n.modes?n:void 0}function P(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=N(t.audience);if(!n||!a){i++;continue}let o=typeof t.kind==`string`&&D.some(e=>e===t.kind)?t.kind:void 0,s=M(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 F(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 I(e,t){return[...new Set(e.flatMap(e=>e.audience?.[t]??[]).filter(e=>e.length>0))].sort((e,t)=>e.localeCompare(t))}function L(){let{t:e}=t(),r=m(),[o,u]=(0,A.useState)([]),[D,O]=(0,A.useState)(!0),[k,M]=(0,A.useState)(null),[N,L]=(0,A.useState)(``),[z,B]=(0,A.useState)(!1),[ae,V]=(0,A.useState)(!1),[H,U]=(0,A.useState)(null),[W,G]=(0,A.useState)(!1),[K,q]=(0,A.useState)(!1),J=(0,A.useRef)(null),Y=(0,A.useCallback)(()=>{O(!0),M(null),r.listSageMemories({echoToChat:!1})},[r.listSageMemories]);(0,A.useEffect)(()=>{let t=r.client,n=t.on(`memory.sage.list`,e=>{let t=e.payload;t.error?M({tone:`error`,text:t.error}):u(t.memories??[]),O(!1)}),i=t.on(`memory.sage.remember`,e=>{let t=e.payload;if(G(!1),t.error){M({tone:`error`,text:t.error});return}t.memory&&(u(e=>[t.memory,...e.filter(e=>e.id!==t.memory.id)]),B(!1))}),a=t.on(`memory.sage.update`,t=>{let n=t.payload;n.error?M({tone:`error`,text:n.error}):n.memory&&(u(e=>e.map(e=>e.id===n.memory.id?n.memory:e)),n.memory.audience||M({tone:`success`,text:e(`activity:audienceMem.scopeRemoved`)}))}),o=t.on(`memory.sage.delete`,t=>{let n=t.payload,r=J.current;n.success&&r?(u(e=>e.filter(e=>e.id!==r)),M({tone:`success`,text:e(`activity:audienceMem.deleted`)}),U(null),q(!1),J.current=null):n.success?Y():(M({tone:`error`,text:n.message??`Could not delete the memory.`}),q(!1),J.current=null)});return Y(),()=>{n(),i(),a(),o()}},[Y,r.client]);let X=(0,A.useMemo)(()=>o.filter(e=>{let t=e.audience;return!!(t&&(t.roles?.length||t.taskTypes?.length||t.modes?.length))}),[o]),Z=N.trim(),Q=(0,A.useMemo)(()=>X.filter(e=>F(e,Z)),[Z,X]),$=T(Q,16,Z),oe=(0,A.useMemo)(()=>I(X,`roles`),[X]),se=(0,A.useMemo)(()=>I(X,`taskTypes`),[X]),ce=(0,A.useMemo)(()=>I(X,`modes`),[X]),le=e=>{M(null),r.updateSage(e,{audience:void 0},{echoToChat:!1})},ue=()=>{H&&(J.current=H,q(!0),M(null),r.deleteSage(H,`Removed from the audience memory panel.`))},de=async()=>{let t=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(t,null,2)),M({tone:`success`,text:e(`activity:audienceMem.copiedAsJson`,{count:t.length})})}catch(t){M({tone:`error`,text:t instanceof Error?t.message:e(`activity:audienceMem.copyFailed`)})}};return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-card/20`,"aria-labelledby":`audience-memory-title`,children:[(0,j.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 p-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,j.jsx)(`div`,{className:`min-w-0`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.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,j.jsx)(n,{className:`size-3.5`})}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h2`,{id:`audience-memory-title`,className:`truncate text-sm font-semibold`,children:e(`activity:audienceMem.heading`)}),(0,j.jsx)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:e(`activity:audienceMem.subheading`)})]})]})}),(0,j.jsxs)(S,{variant:`default`,size:`sm`,className:`h-7 shrink-0 gap-1 px-2 text-xs`,onClick:()=>B(!0),children:[(0,j.jsx)(i,{className:`size-3`}),e(`common:action.add`)]})]}),(0,j.jsxs)(`div`,{className:`mt-3 grid grid-cols-4 gap-px overflow-hidden rounded-md border border-border/60 bg-border/60`,children:[(0,j.jsx)(R,{value:X.length,label:e(`activity:audienceMem.statMemories`)}),(0,j.jsx)(R,{value:oe.length,label:e(`activity:audienceMem.statRoles`)}),(0,j.jsx)(R,{value:se.length,label:e(`activity:audienceMem.statTasks`)}),(0,j.jsx)(R,{value:ce.length,label:e(`activity:audienceMem.statModes`)})]}),(0,j.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,j.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,j.jsx)(s,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,j.jsx)(C,{value:N,onChange:e=>L(e.target.value),placeholder:e(`activity:audienceMem.searchTextRoleTaskOrMode`),"aria-label":e(`activity:audienceMem.searchAudienceMemories`),className:`h-8 pl-8 pr-8 text-xs`}),N&&(0,j.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:()=>L(``),"aria-label":e(`activity:audienceMem.clearAudienceMemorySearch`),children:(0,j.jsx)(c,{className:`size-3`})})]}),(0,j.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:Y,"aria-label":e(`activity:audienceMem.refreshAudienceMemories`),title:e(`activity:audienceMem.refresh`),children:(0,j.jsx)(f,{className:h(`size-3.5`,D&&`animate-spin`)})}),(0,j.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>V(!0),"aria-label":e(`activity:audienceMem.importAudienceMemories`),title:e(`activity:audienceMem.importJson`),children:(0,j.jsx)(a,{className:`size-3.5`})}),(0,j.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>void de(),"aria-label":e(`activity:audienceMem.copyAudienceMemoriesAsJson`),title:e(`activity:audienceMem.copyJson`),disabled:X.length===0,children:(0,j.jsx)(d,{className:`size-3.5`})})]})]}),k&&(0,j.jsxs)(`div`,{role:k.tone===`error`?`alert`:`status`,className:h(`mx-3 mt-3 flex shrink-0 items-start justify-between gap-2 rounded-md border px-2.5 py-2 text-[11px]`,k.tone===`error`?`border-destructive/30 bg-destructive/5 text-destructive`:`border-success/30 bg-success/5 text-success`),children:[(0,j.jsx)(`span`,{children:k.text}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>M(null),className:`shrink-0 rounded-sm opacity-70 hover:opacity-100`,"aria-label":e(`activity:audienceMem.dismissMessage`),children:(0,j.jsx)(c,{className:`size-3`})})]}),(0,j.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[!D&&X.length>0&&(0,j.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-3 pb-1.5 pt-3 text-[10px] text-muted-foreground`,children:[(0,j.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,j.jsx)(p,{className:`size-3`}),Z?`${Q.length} of ${X.length}`:`${X.length} scoped`]}),Z&&(0,j.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,onClick:()=>L(``),children:e(`activity:audienceMem.clearFilter`)})]}),(0,j.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[D?(0,j.jsx)(te,{}):X.length===0?(0,j.jsx)(ne,{onAdd:()=>B(!0)}):Q.length===0?(0,j.jsxs)(`div`,{className:`flex h-full min-h-32 flex-col items-center justify-center px-4 text-center`,children:[(0,j.jsx)(s,{className:`mb-2 size-5 text-muted-foreground/60`}),(0,j.jsx)(`p`,{className:`text-xs font-medium`,children:e(`activity:audienceMem.noMatching`)}),(0,j.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:e(`activity:audienceMem.noMatchingHint`)}),(0,j.jsx)(S,{variant:`ghost`,size:`sm`,className:`mt-2 h-7 text-xs`,onClick:()=>L(``),children:e(`activity:audienceMemoryPanel.clearSearch`)})]}):(0,j.jsx)(`ul`,{className:`space-y-2`,children:$.pageItems.map(e=>(0,j.jsx)(ee,{memory:e,onFilter:L,onClearScope:()=>le(e.id),onDelete:()=>U(e.id)},e.id))}),(0,j.jsx)(w,{page:$.page,pageSize:$.pageSize,totalItems:$.totalItems,onPageChange:$.setPage,compact:!0,itemLabel:`memories`})]})]})]}),(0,j.jsx)(re,{open:z,busy:W,onOpenChange:e=>{W||B(e)},onCreate:e=>{M(null),G(!0),r.rememberSage({text:e.text,kind:e.kind,audience:{roles:e.roles.length>0?e.roles:void 0,taskTypes:e.taskTypes.length>0?e.taskTypes:void 0,modes:e.modes.length>0?e.modes:void 0}},{echoToChat:!1})}}),(0,j.jsx)(ie,{open:ae,onOpenChange:V,onImport:t=>{try{let{entries:n,skipped:i}=P(t);if(n.length===0)return M({tone:`error`,text:e(`activity:audienceMem.noValidInJson`)}),!1;for(let e of n)r.rememberSage(e,{echoToChat:!1});return M({tone:`success`,text:e(`activity:audienceMem.queuedForImport`,{count:n.length})+(i?e(`activity:audienceMem.skippedSuffix`,{count:i}):`.`)}),V(!1),!0}catch(t){return M({tone:`error`,text:t instanceof Error?t.message:e(`activity:customRoster.invalidJson`)}),!1}}}),(0,j.jsx)(x,{open:!!H,onOpenChange:e=>{!e&&!K&&U(null)},children:(0,j.jsxs)(v,{className:`max-w-md`,children:[(0,j.jsxs)(g,{children:[(0,j.jsx)(y,{children:e(`activity:audienceMem.deleteTitle`)}),(0,j.jsx)(b,{children:e(`activity:audienceMem.deleteBody`)})]}),(0,j.jsx)(`div`,{className:`rounded-md border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:E(o.find(e=>e.id===H)?.text??``,180)}),(0,j.jsxs)(_,{children:[(0,j.jsx)(S,{variant:`outline`,onClick:()=>U(null),disabled:K,children:`Cancel`}),(0,j.jsxs)(S,{variant:`destructive`,onClick:ue,disabled:K,children:[(0,j.jsx)(l,{className:`size-4`}),K?`Deleting…`:`Delete memory`]})]})]})})]})}function R({value:e,label:t}){return(0,j.jsxs)(`div`,{className:`bg-card/95 px-1.5 py-2 text-center`,children:[(0,j.jsx)(`p`,{className:`text-sm font-semibold tabular-nums`,children:e}),(0,j.jsx)(`p`,{className:`truncate text-[9px] uppercase tracking-wide text-muted-foreground`,children:t})]})}function ee({memory:e,onFilter:n,onClearScope:r,onDelete:i}){let{t:a}=t();return(0,j.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,j.jsx)(`p`,{className:`break-words text-xs leading-5`,children:e.text}),e.audience&&(0,j.jsx)(z,{audience:e.audience,onFilter:n}),(0,j.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 border-t border-border/45 pt-2`,children:[(0,j.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[9px] uppercase tracking-wide text-muted-foreground`,children:[(0,j.jsx)(`span`,{className:`truncate`,children:O[e.kind]??e.kind}),(0,j.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,j.jsx)(`span`,{children:e.status})]}),(0,j.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,j.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:r,"aria-label":`Remove audience scope from ${E(e.text,42)}`,title:a(`activity:audienceMem.makeGeneralMemory`),children:(0,j.jsx)(o,{className:`size-3`})}),(0,j.jsx)(S,{variant:`ghost`,size:`icon`,className:`size-6 text-destructive hover:text-destructive`,onClick:i,"aria-label":`Delete ${E(e.text,42)}`,title:a(`activity:audienceMem.delete`),children:(0,j.jsx)(l,{className:`size-3`})})]})]})]})}function z({audience:e,onFilter:t}){let n=[...(e.roles??[]).map(e=>({label:`role`,value:e})),...(e.taskTypes??[]).map(e=>({label:`task`,value:e})),...(e.modes??[]).map(e=>({label:`mode`,value:e}))];return(0,j.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:n.map(({label:e,value:n})=>(0,j.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 te(){let{t:e}=t();return(0,j.jsx)(`div`,{className:`space-y-2 pt-3`,role:`status`,"aria-label":e(`activity:audienceMem.loadingAudienceMemories`),children:[0,1,2].map(e=>(0,j.jsxs)(`div`,{className:`animate-pulse rounded-md border border-border/50 p-3`,children:[(0,j.jsx)(`div`,{className:`h-2.5 w-full rounded bg-muted`}),(0,j.jsx)(`div`,{className:`mt-2 h-2.5 w-2/3 rounded bg-muted`}),(0,j.jsx)(`div`,{className:`mt-3 h-4 w-24 rounded bg-muted`})]},e))})}function ne({onAdd:e}){let{t:r}=t();return(0,j.jsxs)(`div`,{className:`flex h-full min-h-44 flex-col items-center justify-center px-5 text-center`,children:[(0,j.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,j.jsx)(n,{className:`size-4`})}),(0,j.jsx)(`p`,{className:`text-xs font-medium`,children:r(`activity:audienceMem.emptyTitle`)}),(0,j.jsx)(`p`,{className:`mt-1 max-w-52 text-[10px] leading-4 text-muted-foreground`,children:r(`activity:audienceMem.emptyBody`)}),(0,j.jsxs)(S,{variant:`outline`,size:`sm`,className:`mt-3 h-7 gap-1 text-xs`,onClick:e,children:[(0,j.jsx)(i,{className:`size-3`}),r(`activity:audienceMem.addScoped`)]})]})}function re({open:e,busy:n,onOpenChange:r,onCreate:i}){let{t:a}=t(),[o,s]=(0,A.useState)(``),[c,l]=(0,A.useState)(`workflow`),[u,d]=(0,A.useState)(``),[f,p]=(0,A.useState)(``),[m,h]=(0,A.useState)(``);(0,A.useEffect)(()=>{e||(s(``),l(`workflow`),d(``),p(``),h(``))},[e]);let C=k(u),w=k(f),T=k(m),E=o.trim().length>0&&(C.length>0||w.length>0||T.length>0);return(0,j.jsx)(x,{open:e,onOpenChange:r,children:(0,j.jsxs)(v,{className:`max-w-xl`,children:[(0,j.jsxs)(g,{children:[(0,j.jsx)(y,{children:a(`activity:audienceMem.createTitle`)}),(0,j.jsx)(b,{children:a(`activity:audienceMem.createBody`)})]}),(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`audience-memory-text`,className:`mb-1.5 block text-xs font-medium`,children:a(`activity:audienceMem.fieldMemory`)}),(0,j.jsx)(`textarea`,{id:`audience-memory-text`,value:o,onChange:e=>s(e.target.value),placeholder:a(`activity:audienceMem.whatShouldMatchingAgentsRemember`),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,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`audience-memory-kind`,className:`mb-1.5 block text-xs font-medium`,children:a(`activity:audienceMem.fieldKind`)}),(0,j.jsx)(`select`,{id:`audience-memory-kind`,value:c,onChange:e=>l(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:D.map(e=>(0,j.jsx)(`option`,{value:e,children:O[e]??e},e))})]}),(0,j.jsxs)(`fieldset`,{className:`space-y-3 rounded-md border border-border/70 bg-background/35 p-3`,children:[(0,j.jsx)(`legend`,{className:`px-1 text-xs font-medium`,children:a(`activity:audienceMem.selectors`)}),(0,j.jsx)(B,{id:`audience-memory-roles`,label:a(`activity:audienceMem.statRoles`),value:u,onChange:d,placeholder:a(`activity:audienceMem.reviewerRefactorPlanner`)}),(0,j.jsx)(B,{id:`audience-memory-task-types`,label:a(`activity:audienceMem.fieldTaskTypes`),value:f,onChange:p,placeholder:a(`activity:audienceMem.reviewRefactorBugfix`)}),(0,j.jsx)(B,{id:`audience-memory-modes`,label:a(`activity:audienceMem.statModes`),value:m,onChange:h,placeholder:a(`activity:audienceMem.teachCodeReview`)}),(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:a(`activity:audienceMem.selectorsHint`)})]})]}),(0,j.jsxs)(_,{children:[(0,j.jsx)(S,{variant:`outline`,onClick:()=>r(!1),disabled:n,children:a(`common:action.cancel`)}),(0,j.jsx)(S,{onClick:()=>i({text:o.trim(),kind:c,roles:C,taskTypes:w,modes:T}),disabled:!E||n,children:n?`Remembering…`:`Remember`})]})]})})}function B({id:e,label:t,value:n,placeholder:r,onChange:i}){return(0,j.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[6rem_1fr] sm:items-center`,children:[(0,j.jsx)(`label`,{htmlFor:e,className:`text-[11px] font-medium text-muted-foreground`,children:t}),(0,j.jsx)(C,{id:e,value:n,onChange:e=>i(e.target.value),placeholder:r,className:`h-8 font-mono text-xs`})]})}function ie({open:e,onOpenChange:n,onImport:r}){let{t:i}=t(),[o,s]=(0,A.useState)(``);return(0,A.useEffect)(()=>{e||s(``)},[e]),(0,j.jsx)(x,{open:e,onOpenChange:n,children:(0,j.jsxs)(v,{className:`max-w-xl`,children:[(0,j.jsxs)(g,{children:[(0,j.jsx)(y,{children:i(`activity:audienceMem.importTitle`)}),(0,j.jsxs)(b,{children:[i(`activity:audienceMem.importBodyBefore`),` `,(0,j.jsx)(`code`,{children:i(`activity:audienceMemoryPanel.memoryAudienceExport`)}),`.`,` `,i(`activity:audienceMem.importBodyAfter`)]})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`audience-memory-import`,className:`mb-1.5 block text-xs font-medium`,children:i(`activity:audienceMem.jsonArray`)}),(0,j.jsx)(`textarea`,{id:`audience-memory-import`,value:o,onChange:e=>s(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,j.jsxs)(_,{children:[(0,j.jsx)(S,{variant:`outline`,onClick:()=>n(!1),children:i(`common:action.cancel`)}),(0,j.jsxs)(S,{onClick:()=>r(o),disabled:!o.trim(),children:[(0,j.jsx)(a,{className:`size-4`}),i(`activity:audienceMem.importAction`)]})]})]})})}export{L as AudienceMemoryPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ba as t,Ga as n,b as r,dn as i,ki as a,lt as o,oi as s,or as c,ra as l,un as u,yn as d}from"./vendor-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ba as t,Ga as n,b as r,dn as i,ki as a,lt as o,oi as s,or as c,ra as l,un as u,yn as d}from"./vendor-DZ9_OO6N.js";import"./i18n-n_1tBMdC.js";import{a as f,n as p,t as m}from"./monaco-BCqJp2xW.js";import{t as h}from"./ws-client-DXT4gi-N.js";import{t as g}from"./utils-BecmXwgG.js";import{R as _,x as v}from"./stores-d8rhzRAc.js";import{v as y}from"./index-gKjRx1pQ.js";import{t as b}from"./empty-state-IT10GzRA.js";import{t as x}from"./monaco-theme-CR1QvFi2.js";var S=e(n(),1),C=o();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:n,newText:i}){let{t:a}=t(),o=(0,S.useRef)(null),[s,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=>{o.current=e,f.setTheme(x()),e.getModifiedEditor().onDidChangeModelContent(()=>d(!0))},[]),b=(0,S.useCallback)(()=>{let t=o.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:!s||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:a(`activity:monacoDiff.applyTitle`),children:[p?(0,C.jsx)(c,{className:`h-3.5 w-3.5 animate-spin`}):g&&!s?(0,C.jsx)(l,{className:`h-3.5 w-3.5 text-success`}):(0,C.jsx)(u,{className:`h-3.5 w-3.5`}),a(p?`activity:monacoDiff.applying`:g&&!s?`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)(r,{original:n,modified:i,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}=t(),r=v(e=>e.selectedPath),o=v(e=>e.diff),l=v(e=>e.loadingDiff),[u,f]=(0,S.useState)(`unified`),[p,m]=(0,S.useState)(!1),x=!!r&&(l||!o);(0,S.useEffect)(()=>{if(m(!1),!x)return;let e=setTimeout(()=>m(!0),D);return()=>clearTimeout(e)},[x,r]);let w=()=>{r&&(m(!1),v.getState().setDiffLoading(!0),h(_.getState().wsUrl).getGitDiff?.(r))};if(!r)return(0,C.jsx)(b,{icon:(0,C.jsx)(s,{className:`h-6 w-6`}),title:n(`activity:changesView.sourceChanges`),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:n(`activity:changesView.sourceControl`)}),(0,C.jsx)(`div`,{className:`truncate font-mono text-xs text-foreground`,title:r,children:r})]}),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`,u===`unified`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,C.jsx)(i,{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`,u===`edit`?`border-primary/40 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:bg-muted`),children:[(0,C.jsx)(a,{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:l||!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)(d,{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)(c,{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`)}):u===`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-hePW80VL.js";import{Ba as t,Ga as n,Ot as r,Pa as i,Pi as a,Pr as o,Vt as s,Zt as c,an as ee,ci as l,da as u,dt as d,fr as te,lt as f,ma as p,mn as ne,ta as m,xi as h,yn as re,zr as g}from"./vendor-DLS502Zs.js";import"./i18n-CYYBUSJB.js";import{t as ie}from"./ws-client-DYrfK01f.js";import{t as _}from"./utils-B5X3DKef.js";import{b as ae,x as oe}from"./index-cUeJ0FkT.js";var v=e(n(),1),y=f();function b({status:e}){let{t:n}=t();return(0,y.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,y.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:n(`activity:chroniclePipelineStrip.chronicleOwnership`)}),(0,y.jsxs)(`span`,{children:[`collect `,(0,y.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.collection})]}),(0,y.jsxs)(`span`,{children:[`process `,(0,y.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.processing})]}),(0,y.jsxs)(`span`,{children:[`serve `,(0,y.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.serving})]}),(0,y.jsxs)(`span`,{children:[`PID `,(0,y.jsx)(`b`,{className:`text-foreground`,children:e.pid}),` · `,e.clients,` clients`]}),(0,y.jsxs)(`span`,{children:[`watcher`,` `,(0,y.jsx)(`b`,{className:_(e.watcher.active?`text-success`:`text-warning`),children:e.watcher.active?`active`:`inactive`}),` `,`· `,e.watcher.watchedFiles,` files`]}),(0,y.jsxs)(`span`,{children:[`store `,(0,y.jsx)(`b`,{className:`text-foreground`,children:x(e.pipeline.storage)})]}),e.mode===`inline`&&(0,y.jsx)(`span`,{className:`font-sans font-semibold text-warning`,children:n(`activity:chroniclePipelineStrip.inlineFallback`)})]})}function x(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).slice(-3).join(`/`)}var S=[`eventType`,`providerId`,`modelId`,`outcome`,`resourceKind`],C=864e5;function w(){return{limit:300,order:`desc`,from:new Date(Date.now()-C).toISOString()}}var se=[{id:`all`,labelKey:`activity:chronicle.signalAllSignals`,icon:(0,y.jsx)(i,{})},{id:`llm`,labelKey:`activity:chronicle.signalLlm`,icon:(0,y.jsx)(u,{})},{id:`agents`,labelKey:`activity:chronicle.signalAgents`,icon:(0,y.jsx)(p,{})},{id:`tools`,labelKey:`activity:chronicle.signalTools`,icon:(0,y.jsx)(s,{})},{id:`files`,labelKey:`activity:chronicle.signalFiles`,icon:(0,y.jsx)(l,{})},{id:`failures`,labelKey:`activity:chronicle.signalFailures`,icon:(0,y.jsx)(r,{})}];function T(){let{t:e}=t(),n=ie(),[r,i]=(0,v.useState)([]),[o,c]=(0,v.useState)(null),[f,m]=(0,v.useState)({}),[h,x]=(0,v.useState)(w()),[C,T]=(0,v.useState)({text:``,path:``,providerId:``,modelId:``,sessionId:``}),[E,O]=(0,v.useState)(`all`),[N,F]=(0,v.useState)({total:0,scannedEvents:0,sourceFiles:0,invalidLines:0}),[I,pe]=(0,v.useState)(D),[L,R]=(0,v.useState)(!0),[z,B]=(0,v.useState)(null),[me,V]=(0,v.useState)(null),[H,he]=(0,v.useState)([]),[U,ge]=(0,v.useState)([]),[W,_e]=(0,v.useState)(null),G=(0,v.useRef)(h);G.current=h;let K=(0,v.useCallback)(e=>{if(!n.supportsCapability(`chronicle.query`)){R(!1),B(`Restart the backend once to activate Chronicle protocol support.`);return}if(R(!0),B(null),x(e),m({}),n.send({type:`chronicle.query`,payload:{query:e}}),n.supportsCapability(`chronicle.facets`))n.send({type:`chronicle.facets`,payload:{fields:[...S],query:e,limit:12}});else for(let t of S)n.send({type:`chronicle.facet`,payload:{field:t,query:e,limit:12}})},[n]),q=(0,v.useCallback)(()=>{n.supportsCapability(`chronicle.metrics`)&&(n.send({type:`chronicle.metrics`,payload:{view:`providers`}}),n.send({type:`chronicle.metrics`,payload:{view:`tasks`,limit:200}}))},[n]),J=(0,v.useCallback)(()=>{n.supportsCapability(`chronicle.status`)&&n.send({type:`chronicle.status`})},[n]);(0,v.useEffect)(()=>{let e=n.on(`chronicle.query_result`,e=>{e.type===`chronicle.query_result`&&(i(e.payload.events),F(e.payload),pe(e.payload.summary??D),R(!1))}),t=n.on(`chronicle.facet_result`,e=>{e.type===`chronicle.facet_result`&&m(t=>({...t,[e.payload.field]:e.payload.values}))}),r=n.on(`chronicle.facets_result`,e=>{e.type===`chronicle.facets_result`&&m(e.payload.values)}),a=n.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(B(e.payload.message),R(!1))}),o=n.on(`chronicle.graph_result`,e=>{e.type===`chronicle.graph_result`&&V(e.payload)}),s=n.on(`chronicle.metrics_result`,e=>{e.type===`chronicle.metrics_result`&&(e.payload.view===`providers`?he(e.payload.data):e.payload.view===`tasks`&&ge(e.payload.data))}),c=n.on(`chronicle.status_result`,e=>{e.type===`chronicle.status_result`&&_e(e.payload)});return K(G.current),q(),J(),()=>{e(),t(),r(),a(),o(),s(),c()}},[n,K,q,J]);let Y=(0,v.useMemo)(()=>r.filter(e=>ue(e,E)),[r,E]),X=oe(Y,25,E),Z=(0,v.useMemo)(()=>{let e=r.find(e=>e.eventType===`metrics.rollup`&&e.attributes?.signal===`runtime.health`)?.attributes?.stats;if(!e)return;let t=t=>e[t]?.last;return{eventLoop:{utilization:t(`eventLoop.utilization`),delayP95Ms:t(`eventLoop.delayP95Ms`)},memory:{heapUsedBytes:t(`memory.heapUsedBytes`)},chronicle:{pendingEvents:t(`chronicle.pendingEvents`),rejectedEvents:t(`chronicle.rejectedEvents`)}}},[r]),Q=(0,v.useMemo)(()=>{let e={};for(let t of U)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=[...U].sort((e,t)=>(t.endedAt??t.startedAt??``).localeCompare(e.endedAt??e.startedAt??``)).slice(0,8);return{counts:e,total:U.length,terminal:t,successRate:t>0?n/t*100:100,recent:r}},[U]),$=()=>K({...w(),...C.text?{text:C.text}:{},...C.path?{path:C.path}:{},...C.providerId?{providerId:C.providerId}:{},...C.modelId?{modelId:C.modelId}:{},...C.sessionId?{sessionId:C.sessionId}:{}}),ve=()=>{T({text:``,path:``,providerId:``,modelId:``,sessionId:``}),O(`all`),K(w())},ye=e=>{c(e),V(null),n.supportsCapability(`chronicle.graph`)&&n.send({type:`chronicle.graph`,payload:{seed:{eventId:e.eventId},hops:2,maxNodes:250}})};return(0,y.jsxs)(`div`,{className:`flex h-full min-h-0 bg-background`,"data-testid":`chronicle-dashboard`,children:[(0,y.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,y.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,y.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(u,{className:`h-5 w-5 text-primary`}),(0,y.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:e(`activity:chronicle.codingIntelligence`)}),(0,y.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:e(`activity:chronicle.chronicle`)})]}),(0,y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`activity:chronicle.llmAgentToolAndFileEvidence`)})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:_(`h-2 w-2 rounded-full`,z?`bg-destructive`:L?`animate-pulse bg-warning`:`bg-success`)}),(0,y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:L?`Reading journal`:z?`Unavailable`:`Live evidence`}),(0,y.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:e(`activity:chronicle.refreshEvidence`),children:(0,y.jsx)(re,{className:_(`h-4 w-4`,L&&`animate-spin`)})})]})]})}),(0,y.jsxs)(`section`,{className:`grid grid-cols-2 border-b border-border/70 xl:grid-cols-6`,children:[(0,y.jsx)(j,{icon:(0,y.jsx)(u,{}),label:e(`activity:chronicle.llmRequests`),value:I.logicalRequests,detail:`${I.modelAttempts} attempts · ${I.providers} providers · ${I.models} models`}),(0,y.jsx)(j,{icon:(0,y.jsx)(p,{}),label:e(`activity:chronicle.agentWork`),value:I.agentEvents,detail:`${I.uniqueAgents} correlated agents · ${I.decisions} decisions`}),(0,y.jsx)(j,{icon:(0,y.jsx)(s,{}),label:e(`activity:chronicle.toolCalls`),value:I.toolCalls,detail:`${I.failedTools} failed · ${I.processes} processes`}),(0,y.jsx)(j,{icon:(0,y.jsx)(l,{}),label:e(`activity:chronicle.fileEvidence`),value:I.fileEvents,detail:`${I.uniqueFiles} unique paths`}),(0,y.jsx)(j,{icon:(0,y.jsx)(ne,{}),label:e(`activity:chronicle.retries`),value:I.scheduledRetries,detail:`${I.failures} failures · ${I.fallbacks} fallbacks`,tone:I.failures?`danger`:`normal`}),(0,y.jsx)(j,{icon:(0,y.jsx)(a,{}),label:e(`activity:chronicle.providerP95`),value:k(I.providerP95DurationMs),detail:`${k(I.providerAvgDurationMs)} average · all matches`})]}),(0,y.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,y.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:e(`activity:chronicle.tokenEconomics`)}),(0,y.jsxs)(`span`,{children:[e(`activity:chronicle.freshInput`),` `,(0,y.jsx)(`b`,{className:`text-foreground`,children:I.inputTokens.toLocaleString()})]}),(0,y.jsxs)(`span`,{children:[`output `,(0,y.jsx)(`b`,{className:`text-foreground`,children:I.outputTokens.toLocaleString()})]}),(0,y.jsxs)(`span`,{children:[e(`activity:chronicle.cacheRead`),` `,(0,y.jsx)(`b`,{className:`text-foreground`,children:I.cacheReadTokens.toLocaleString()})]}),(0,y.jsxs)(`span`,{children:[`cache write`,` `,(0,y.jsx)(`b`,{className:`text-foreground`,children:I.cacheWriteTokens.toLocaleString()})]}),(0,y.jsxs)(`span`,{children:[e(`activity:chronicle.cacheHit`),` `,(0,y.jsxs)(`b`,{className:`text-foreground`,children:[le(I).toFixed(1),`%`]})]}),(0,y.jsxs)(`span`,{children:[e(`activity:chronicle.estimatedCost`),` `,(0,y.jsxs)(`b`,{className:`text-foreground`,children:[`$`,I.estimatedCostUsd.toFixed(4)]})]})]}),H.length>0&&(0,y.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,y.jsx)(`span`,{className:`shrink-0 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`activity:chronicle.modelReliability`)}),H.slice(0,6).map(e=>{let t=e.completed+e.failed,n=t>0?e.completed/t*100:100;return(0,y.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 ${k(e.avgDurationMs)} · ${e.inputTokens.toLocaleString()} in / ${e.outputTokens.toLocaleString()} out`,children:[(0,y.jsx)(`span`,{className:_(`h-1.5 w-1.5 rounded-full`,n>=99?`bg-success`:n>=90?`bg-warning`:`bg-destructive`)}),(0,y.jsxs)(`span`,{className:`max-w-[180px] truncate`,children:[e.providerId,`/`,e.modelId]}),(0,y.jsxs)(`b`,{className:`text-foreground`,children:[n.toFixed(0),`%`]}),(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:e.day.slice(5)})]},`${e.day}-${e.providerId}-${e.modelId}`)})]}),Q.total>0&&(0,y.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,y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,y.jsx)(te,{className:`h-3 w-3`}),e(`activity:chronicle.taskOutcomes`)]}),(0,y.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,y.jsx)(`span`,{className:_(`h-1.5 w-1.5 rounded-full`,Q.successRate>=90?`bg-success`:Q.successRate>=60?`bg-warning`:`bg-destructive`)}),(0,y.jsxs)(`b`,{className:`text-foreground`,children:[Q.successRate.toFixed(0),`%`]}),(0,y.jsxs)(`span`,{className:`text-muted-foreground`,children:[`success · `,Q.total,` tasks`]})]}),[`completed`,`merged`,`failed`,`conflict`,`started`].filter(e=>Q.counts[e]).map(e=>(0,y.jsxs)(`span`,{className:`shrink-0 font-mono text-[9px] text-muted-foreground`,children:[e,` `,(0,y.jsx)(`b`,{className:_(e===`failed`||e===`conflict`?`text-destructive`:`text-foreground`),children:Q.counts[e]})]},e)),(0,y.jsx)(`span`,{className:`mx-1 h-3 w-px shrink-0 bg-border`}),Q.recent.map(e=>(0,y.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,y.jsx)(`span`,{className:_(`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,y.jsx)(`span`,{className:`max-w-[84px] truncate`,children:e.taskId}),e.durationMs!==null&&(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:k(e.durationMs)}),e.filesTouched>0&&(0,y.jsxs)(`span`,{className:`flex items-center gap-0.5 text-muted-foreground`,children:[(0,y.jsx)(l,{className:`h-2.5 w-2.5`}),e.filesTouched]})]},e.taskId))]}),(0,y.jsx)(`section`,{className:`border-b border-border/70 px-4 py-3`,children:(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 xl:grid-cols-[1.35fr_1fr_1fr_1fr_1fr_auto]`,children:[(0,y.jsx)(A,{icon:(0,y.jsx)(ee,{}),placeholder:e(`activity:chronicle.searchEventEvidence`),value:C.text,onChange:e=>T(t=>({...t,text:e})),onEnter:$}),(0,y.jsx)(A,{placeholder:e(`activity:chronicle.fileOrDirectory`),value:C.path,onChange:e=>T(t=>({...t,path:e})),onEnter:$}),(0,y.jsx)(A,{placeholder:e(`activity:chronicle.provider`),value:C.providerId,onChange:e=>T(t=>({...t,providerId:e})),onEnter:$}),(0,y.jsx)(A,{placeholder:e(`activity:chronicle.model`),value:C.modelId,onChange:e=>T(t=>({...t,modelId:e})),onEnter:$}),(0,y.jsx)(A,{placeholder:e(`activity:chronicle.session`),value:C.sessionId,onChange:e=>T(t=>({...t,sessionId:e})),onEnter:$}),(0,y.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,y.jsxs)(`button`,{type:`button`,onClick:$,className:`rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground`,children:[(0,y.jsx)(g,{className:`mr-1 inline h-3 w-3`}),e(`activity:chronicle.apply`)]}),(0,y.jsx)(`button`,{type:`button`,onClick:ve,className:`rounded-md border border-border px-2.5 text-xs hover:bg-muted`,children:e(`activity:chronicle.clear`)})]})]})}),(0,y.jsxs)(`section`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/70 px-4 py-2`,children:[se.map(t=>(0,y.jsxs)(`button`,{type:`button`,onClick:()=>O(t.id),className:_(`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===t.id?`bg-primary/10 font-medium text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[t.icon,e(t.labelKey),(0,y.jsx)(`span`,{className:`ml-1 rounded bg-background/70 px-1 font-mono text-[9px]`,children:ce(I,t.id,N.total)})]},t.id)),(0,y.jsxs)(`div`,{className:`ml-auto hidden items-center gap-3 pl-4 text-[9px] text-muted-foreground lg:flex`,children:[(0,y.jsxs)(`span`,{children:[N.total.toLocaleString(),` matched`]}),(0,y.jsxs)(`span`,{children:[N.sourceFiles,` journal files`]}),N.invalidLines>0&&(0,y.jsxs)(`span`,{className:`text-warning`,children:[N.invalidLines,` invalid lines`]})]})]}),W&&(0,y.jsx)(b,{status:W}),Z&&(0,y.jsx)(de,{health:Z}),(0,y.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,y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,y.jsx)(`span`,{className:`mr-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.replace(`Id`,``)}),(f[e]??[]).slice(0,4).map(t=>(0,y.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,y.jsx)(`b`,{children:t.count})]},t.value))]},e))}),(0,y.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,y.jsx)(`span`,{children:e(`activity:chronicle.time`)}),(0,y.jsx)(`span`,{children:e(`activity:chronicle.signal`)}),(0,y.jsx)(`span`,{children:e(`activity:chronicle.outcome`)}),(0,y.jsx)(`span`,{children:e(`activity:chronicle.modelAgent`)}),(0,y.jsx)(`span`,{children:e(`activity:chronicle.resource`)}),(0,y.jsx)(`span`,{})]}),(0,y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:z?(0,y.jsx)(P,{text:z}):!L&&Y.length===0?(0,y.jsx)(P,{text:`No coding evidence matches these filters.`}):(0,y.jsx)(`div`,{className:`divide-y divide-border/40`,children:X.pageItems.map(e=>(0,y.jsx)(M,{event:e,active:o?.eventId===e.eventId,onClick:()=>ye(e)},e.eventId))})}),(0,y.jsx)(ae,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,itemLabel:`events`})]}),o&&(0,y.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,y.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,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-xs font-semibold`,children:e(`activity:chronicle.evidenceLineage`)}),(0,y.jsxs)(`div`,{className:`mt-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,o.sequence,` · `,o.eventId]})]}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`rounded p-1 hover:bg-muted`,children:(0,y.jsx)(d,{className:`h-4 w-4`})})]}),(0,y.jsx)(fe,{event:o,graph:me})]})]})}var E={llm:0,agent:0,tool:0,file:0,memory:0,task:0,decision:0,runtime:0},D={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:{...E},failuresByFamily:{...E}};function ce(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 le(e){let t=e.inputTokens+e.cacheReadTokens;return t?e.cacheReadTokens/t*100:0}function ue(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 O(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 k(e){return e?e<1?`${(e*1e3).toFixed(0)}µs`:e<1e3?`${e.toFixed(1)}ms`:`${(e/1e3).toFixed(1)}s`:`—`}function A({placeholder:e,value:t,onChange:n,onEnter:r,icon:i}){return(0,y.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,y.jsx)(`span`,{className:`text-muted-foreground [&>svg]:h-3.5 [&>svg]:w-3.5`,children:i}),(0,y.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 j({icon:e,label:t,value:n,detail:r,tone:i=`normal`}){return(0,y.jsxs)(`div`,{className:`min-w-0 border-r border-border/60 px-4 py-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,y.jsx)(`span`,{className:`text-primary [&>svg]:h-3.5 [&>svg]:w-3.5`,children:e}),t]}),(0,y.jsx)(`div`,{className:_(`mt-1 text-xl font-semibold tabular-nums`,i===`danger`&&`text-destructive`),children:typeof n==`number`?n.toLocaleString():n}),(0,y.jsx)(`div`,{className:`mt-0.5 truncate text-[9px] text-muted-foreground`,children:r})]})}function de({health:e}){let{t:n}=t();return(0,y.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,y.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-success`,children:n(`activity:chronicle.collectorHealthy`)}),(0,y.jsxs)(`span`,{children:[`ELU`,` `,(0,y.jsxs)(`b`,{className:`text-foreground`,children:[((e.eventLoop?.utilization??0)*100).toFixed(1),`%`]})]}),(0,y.jsxs)(`span`,{children:[`p95 `,(0,y.jsxs)(`b`,{className:`text-foreground`,children:[(e.eventLoop?.delayP95Ms??0).toFixed(1),`ms`]})]}),(0,y.jsxs)(`span`,{children:[`heap`,` `,(0,y.jsxs)(`b`,{className:`text-foreground`,children:[((e.memory?.heapUsedBytes??0)/1048576).toFixed(0),`MB`]})]}),(0,y.jsxs)(`span`,{children:[`queue `,(0,y.jsx)(`b`,{className:`text-foreground`,children:e.chronicle?.pendingEvents??0})]}),(0,y.jsxs)(`span`,{children:[`dropped`,` `,(0,y.jsx)(`b`,{className:_((e.chronicle?.rejectedEvents??0)>0&&`text-destructive`),children:e.chronicle?.rejectedEvents??0})]})]})}function M({event:e,active:t,onClick:n}){let r=e.occurredAt??e.observedAt,i=e.runtime?.modelId??e.scope.agentId??e.runtime?.providerId??`—`,a=e.resource?.path??e.resource?.id??e.correlation.toolCallId??`—`;return(0,y.jsxs)(`button`,{type:`button`,onClick:n,className:_(`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`,t&&`bg-primary/[0.07]`),children:[(0,y.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(r).toLocaleTimeString()}),(0,y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,y.jsx)(`span`,{className:_(`h-1.5 w-1.5 shrink-0 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,y.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium`,children:e.eventType})]}),(0,y.jsx)(`span`,{className:_(`w-fit rounded px-1.5 py-0.5 text-[9px]`,F(e.outcome)),children:e.outcome??`unknown`}),(0,y.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:i}),(0,y.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:a}),(0,y.jsx)(m,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}function fe({event:e,graph:n}){let{t:r}=t(),i=(0,v.useMemo)(()=>[[`Scope`,e.scope],[`Correlation`,e.correlation],[`Runtime`,e.runtime],[`Resource`,e.resource],[`Attributes`,e.attributes],[`Tags`,e.tags]],[e]);return(0,y.jsxs)(`div`,{className:`p-4`,children:[(0,y.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/60 p-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:_(`h-2 w-2 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,y.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:e.eventType})]}),(0,y.jsxs)(`div`,{className:`mt-2 flex gap-4 text-[9px] text-muted-foreground`,children:[(0,y.jsx)(`span`,{children:new Date(e.occurredAt??e.observedAt).toLocaleString()}),(0,y.jsx)(`span`,{children:O(Number(e.durationNs??0))})]})]}),(0,y.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,y.jsx)(N,{icon:(0,y.jsx)(c,{}),label:r(`activity:chronicle.evidenceHash`),value:e.hash.slice(0,16)}),(0,y.jsx)(N,{icon:(0,y.jsx)(h,{}),label:r(`activity:chronicle.sequence`),value:String(e.sequence)})]}),n&&(0,y.jsxs)(`section`,{className:`mb-4`,children:[(0,y.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,y.jsx)(o,{className:`h-3 w-3`}),`Lineage · `,n.nodes.length,` nodes · `,n.edges.length,` edges`]}),(0,y.jsx)(`div`,{className:`space-y-1 rounded-md border border-border bg-background/70 p-2`,children:n.edges.slice(0,40).map((e,t)=>(0,y.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[9px]`,children:[(0,y.jsx)(`span`,{className:_(`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,y.jsx)(`span`,{className:`text-muted-foreground`,children:e.kind}),(0,y.jsxs)(`span`,{className:`truncate`,children:[n.nodes.find(t=>t.eventId===e.from)?.eventType,` →`,` `,n.nodes.find(t=>t.eventId===e.to)?.eventType]})]},`${e.from}-${e.to}-${e.kind}-${t}`))}),n.truncated&&(0,y.jsx)(`p`,{className:`mt-1 text-[9px] text-warning`,children:r(`activity:chronicle.lineageTruncatedAtSafetyLimit`)})]}),i.map(([e,t])=>t&&(0,y.jsxs)(`section`,{className:`mb-4`,children:[(0,y.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),(0,y.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 N({icon:e,label:t,value:n}){return(0,y.jsxs)(`div`,{className:`rounded-md border border-border p-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px] uppercase text-muted-foreground`,children:[(0,y.jsx)(`span`,{className:`[&>svg]:h-3 [&>svg]:w-3`,children:e}),t]}),(0,y.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px]`,children:n})]})}function P({text:e}){return(0,y.jsx)(`div`,{className:`flex h-48 items-center justify-center text-sm text-muted-foreground`,children:e})}function F(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{T as ChronicleDashboard};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ba as t,Ga as n,Ot as r,Pa as i,Pi as a,Pr as o,Vt as s,Zt as c,an as ee,ci as l,da as u,dt as d,fr as te,lt as f,ma as p,mn as ne,ta as m,xi as h,yn as re,zr as g}from"./vendor-DZ9_OO6N.js";import"./i18n-n_1tBMdC.js";import{t as ie}from"./ws-client-DXT4gi-N.js";import{t as _}from"./utils-BecmXwgG.js";import{b as ae,x as oe}from"./index-gKjRx1pQ.js";var v=e(n(),1),y=f();function b({status:e}){let{t:n}=t();return(0,y.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,y.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:n(`activity:chroniclePipelineStrip.chronicleOwnership`)}),(0,y.jsxs)(`span`,{children:[`collect `,(0,y.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.collection})]}),(0,y.jsxs)(`span`,{children:[`process `,(0,y.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.processing})]}),(0,y.jsxs)(`span`,{children:[`serve `,(0,y.jsx)(`b`,{className:`text-foreground`,children:e.pipeline.serving})]}),(0,y.jsxs)(`span`,{children:[`PID `,(0,y.jsx)(`b`,{className:`text-foreground`,children:e.pid}),` · `,e.clients,` clients`]}),(0,y.jsxs)(`span`,{children:[`watcher`,` `,(0,y.jsx)(`b`,{className:_(e.watcher.active?`text-success`:`text-warning`),children:e.watcher.active?`active`:`inactive`}),` `,`· `,e.watcher.watchedFiles,` files`]}),(0,y.jsxs)(`span`,{children:[`store `,(0,y.jsx)(`b`,{className:`text-foreground`,children:x(e.pipeline.storage)})]}),e.mode===`inline`&&(0,y.jsx)(`span`,{className:`font-sans font-semibold text-warning`,children:n(`activity:chroniclePipelineStrip.inlineFallback`)})]})}function x(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).slice(-3).join(`/`)}var S=[`eventType`,`providerId`,`modelId`,`outcome`,`resourceKind`],C=864e5;function w(){return{limit:300,order:`desc`,from:new Date(Date.now()-C).toISOString()}}var se=[{id:`all`,labelKey:`activity:chronicle.signalAllSignals`,icon:(0,y.jsx)(i,{})},{id:`llm`,labelKey:`activity:chronicle.signalLlm`,icon:(0,y.jsx)(u,{})},{id:`agents`,labelKey:`activity:chronicle.signalAgents`,icon:(0,y.jsx)(p,{})},{id:`tools`,labelKey:`activity:chronicle.signalTools`,icon:(0,y.jsx)(s,{})},{id:`files`,labelKey:`activity:chronicle.signalFiles`,icon:(0,y.jsx)(l,{})},{id:`failures`,labelKey:`activity:chronicle.signalFailures`,icon:(0,y.jsx)(r,{})}];function T(){let{t:e}=t(),n=ie(),[r,i]=(0,v.useState)([]),[o,c]=(0,v.useState)(null),[f,m]=(0,v.useState)({}),[h,x]=(0,v.useState)(w()),[C,T]=(0,v.useState)({text:``,path:``,providerId:``,modelId:``,sessionId:``}),[E,O]=(0,v.useState)(`all`),[N,F]=(0,v.useState)({total:0,scannedEvents:0,sourceFiles:0,invalidLines:0}),[I,pe]=(0,v.useState)(D),[L,R]=(0,v.useState)(!0),[z,B]=(0,v.useState)(null),[me,V]=(0,v.useState)(null),[H,he]=(0,v.useState)([]),[U,ge]=(0,v.useState)([]),[W,_e]=(0,v.useState)(null),G=(0,v.useRef)(h);G.current=h;let K=(0,v.useCallback)(e=>{if(!n.supportsCapability(`chronicle.query`)){R(!1),B(`Restart the backend once to activate Chronicle protocol support.`);return}if(R(!0),B(null),x(e),m({}),n.send({type:`chronicle.query`,payload:{query:e}}),n.supportsCapability(`chronicle.facets`))n.send({type:`chronicle.facets`,payload:{fields:[...S],query:e,limit:12}});else for(let t of S)n.send({type:`chronicle.facet`,payload:{field:t,query:e,limit:12}})},[n]),q=(0,v.useCallback)(()=>{n.supportsCapability(`chronicle.metrics`)&&(n.send({type:`chronicle.metrics`,payload:{view:`providers`}}),n.send({type:`chronicle.metrics`,payload:{view:`tasks`,limit:200}}))},[n]),J=(0,v.useCallback)(()=>{n.supportsCapability(`chronicle.status`)&&n.send({type:`chronicle.status`})},[n]);(0,v.useEffect)(()=>{let e=n.on(`chronicle.query_result`,e=>{e.type===`chronicle.query_result`&&(i(e.payload.events),F(e.payload),pe(e.payload.summary??D),R(!1))}),t=n.on(`chronicle.facet_result`,e=>{e.type===`chronicle.facet_result`&&m(t=>({...t,[e.payload.field]:e.payload.values}))}),r=n.on(`chronicle.facets_result`,e=>{e.type===`chronicle.facets_result`&&m(e.payload.values)}),a=n.on(`chronicle.error`,e=>{e.type===`chronicle.error`&&(B(e.payload.message),R(!1))}),o=n.on(`chronicle.graph_result`,e=>{e.type===`chronicle.graph_result`&&V(e.payload)}),s=n.on(`chronicle.metrics_result`,e=>{e.type===`chronicle.metrics_result`&&(e.payload.view===`providers`?he(e.payload.data):e.payload.view===`tasks`&&ge(e.payload.data))}),c=n.on(`chronicle.status_result`,e=>{e.type===`chronicle.status_result`&&_e(e.payload)});return K(G.current),q(),J(),()=>{e(),t(),r(),a(),o(),s(),c()}},[n,K,q,J]);let Y=(0,v.useMemo)(()=>r.filter(e=>ue(e,E)),[r,E]),X=oe(Y,25,E),Z=(0,v.useMemo)(()=>{let e=r.find(e=>e.eventType===`metrics.rollup`&&e.attributes?.signal===`runtime.health`)?.attributes?.stats;if(!e)return;let t=t=>e[t]?.last;return{eventLoop:{utilization:t(`eventLoop.utilization`),delayP95Ms:t(`eventLoop.delayP95Ms`)},memory:{heapUsedBytes:t(`memory.heapUsedBytes`)},chronicle:{pendingEvents:t(`chronicle.pendingEvents`),rejectedEvents:t(`chronicle.rejectedEvents`)}}},[r]),Q=(0,v.useMemo)(()=>{let e={};for(let t of U)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=[...U].sort((e,t)=>(t.endedAt??t.startedAt??``).localeCompare(e.endedAt??e.startedAt??``)).slice(0,8);return{counts:e,total:U.length,terminal:t,successRate:t>0?n/t*100:100,recent:r}},[U]),$=()=>K({...w(),...C.text?{text:C.text}:{},...C.path?{path:C.path}:{},...C.providerId?{providerId:C.providerId}:{},...C.modelId?{modelId:C.modelId}:{},...C.sessionId?{sessionId:C.sessionId}:{}}),ve=()=>{T({text:``,path:``,providerId:``,modelId:``,sessionId:``}),O(`all`),K(w())},ye=e=>{c(e),V(null),n.supportsCapability(`chronicle.graph`)&&n.send({type:`chronicle.graph`,payload:{seed:{eventId:e.eventId},hops:2,maxNodes:250}})};return(0,y.jsxs)(`div`,{className:`flex h-full min-h-0 bg-background`,"data-testid":`chronicle-dashboard`,children:[(0,y.jsxs)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,y.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,y.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(u,{className:`h-5 w-5 text-primary`}),(0,y.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight`,children:e(`activity:chronicle.codingIntelligence`)}),(0,y.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:e(`activity:chronicle.chronicle`)})]}),(0,y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e(`activity:chronicle.llmAgentToolAndFileEvidence`)})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:_(`h-2 w-2 rounded-full`,z?`bg-destructive`:L?`animate-pulse bg-warning`:`bg-success`)}),(0,y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:L?`Reading journal`:z?`Unavailable`:`Live evidence`}),(0,y.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:e(`activity:chronicle.refreshEvidence`),children:(0,y.jsx)(re,{className:_(`h-4 w-4`,L&&`animate-spin`)})})]})]})}),(0,y.jsxs)(`section`,{className:`grid grid-cols-2 border-b border-border/70 xl:grid-cols-6`,children:[(0,y.jsx)(j,{icon:(0,y.jsx)(u,{}),label:e(`activity:chronicle.llmRequests`),value:I.logicalRequests,detail:`${I.modelAttempts} attempts · ${I.providers} providers · ${I.models} models`}),(0,y.jsx)(j,{icon:(0,y.jsx)(p,{}),label:e(`activity:chronicle.agentWork`),value:I.agentEvents,detail:`${I.uniqueAgents} correlated agents · ${I.decisions} decisions`}),(0,y.jsx)(j,{icon:(0,y.jsx)(s,{}),label:e(`activity:chronicle.toolCalls`),value:I.toolCalls,detail:`${I.failedTools} failed · ${I.processes} processes`}),(0,y.jsx)(j,{icon:(0,y.jsx)(l,{}),label:e(`activity:chronicle.fileEvidence`),value:I.fileEvents,detail:`${I.uniqueFiles} unique paths`}),(0,y.jsx)(j,{icon:(0,y.jsx)(ne,{}),label:e(`activity:chronicle.retries`),value:I.scheduledRetries,detail:`${I.failures} failures · ${I.fallbacks} fallbacks`,tone:I.failures?`danger`:`normal`}),(0,y.jsx)(j,{icon:(0,y.jsx)(a,{}),label:e(`activity:chronicle.providerP95`),value:k(I.providerP95DurationMs),detail:`${k(I.providerAvgDurationMs)} average · all matches`})]}),(0,y.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,y.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-primary`,children:e(`activity:chronicle.tokenEconomics`)}),(0,y.jsxs)(`span`,{children:[e(`activity:chronicle.freshInput`),` `,(0,y.jsx)(`b`,{className:`text-foreground`,children:I.inputTokens.toLocaleString()})]}),(0,y.jsxs)(`span`,{children:[`output `,(0,y.jsx)(`b`,{className:`text-foreground`,children:I.outputTokens.toLocaleString()})]}),(0,y.jsxs)(`span`,{children:[e(`activity:chronicle.cacheRead`),` `,(0,y.jsx)(`b`,{className:`text-foreground`,children:I.cacheReadTokens.toLocaleString()})]}),(0,y.jsxs)(`span`,{children:[`cache write`,` `,(0,y.jsx)(`b`,{className:`text-foreground`,children:I.cacheWriteTokens.toLocaleString()})]}),(0,y.jsxs)(`span`,{children:[e(`activity:chronicle.cacheHit`),` `,(0,y.jsxs)(`b`,{className:`text-foreground`,children:[le(I).toFixed(1),`%`]})]}),(0,y.jsxs)(`span`,{children:[e(`activity:chronicle.estimatedCost`),` `,(0,y.jsxs)(`b`,{className:`text-foreground`,children:[`$`,I.estimatedCostUsd.toFixed(4)]})]})]}),H.length>0&&(0,y.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,y.jsx)(`span`,{className:`shrink-0 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e(`activity:chronicle.modelReliability`)}),H.slice(0,6).map(e=>{let t=e.completed+e.failed,n=t>0?e.completed/t*100:100;return(0,y.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 ${k(e.avgDurationMs)} · ${e.inputTokens.toLocaleString()} in / ${e.outputTokens.toLocaleString()} out`,children:[(0,y.jsx)(`span`,{className:_(`h-1.5 w-1.5 rounded-full`,n>=99?`bg-success`:n>=90?`bg-warning`:`bg-destructive`)}),(0,y.jsxs)(`span`,{className:`max-w-[180px] truncate`,children:[e.providerId,`/`,e.modelId]}),(0,y.jsxs)(`b`,{className:`text-foreground`,children:[n.toFixed(0),`%`]}),(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:e.day.slice(5)})]},`${e.day}-${e.providerId}-${e.modelId}`)})]}),Q.total>0&&(0,y.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,y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,y.jsx)(te,{className:`h-3 w-3`}),e(`activity:chronicle.taskOutcomes`)]}),(0,y.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,y.jsx)(`span`,{className:_(`h-1.5 w-1.5 rounded-full`,Q.successRate>=90?`bg-success`:Q.successRate>=60?`bg-warning`:`bg-destructive`)}),(0,y.jsxs)(`b`,{className:`text-foreground`,children:[Q.successRate.toFixed(0),`%`]}),(0,y.jsxs)(`span`,{className:`text-muted-foreground`,children:[`success · `,Q.total,` tasks`]})]}),[`completed`,`merged`,`failed`,`conflict`,`started`].filter(e=>Q.counts[e]).map(e=>(0,y.jsxs)(`span`,{className:`shrink-0 font-mono text-[9px] text-muted-foreground`,children:[e,` `,(0,y.jsx)(`b`,{className:_(e===`failed`||e===`conflict`?`text-destructive`:`text-foreground`),children:Q.counts[e]})]},e)),(0,y.jsx)(`span`,{className:`mx-1 h-3 w-px shrink-0 bg-border`}),Q.recent.map(e=>(0,y.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,y.jsx)(`span`,{className:_(`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,y.jsx)(`span`,{className:`max-w-[84px] truncate`,children:e.taskId}),e.durationMs!==null&&(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:k(e.durationMs)}),e.filesTouched>0&&(0,y.jsxs)(`span`,{className:`flex items-center gap-0.5 text-muted-foreground`,children:[(0,y.jsx)(l,{className:`h-2.5 w-2.5`}),e.filesTouched]})]},e.taskId))]}),(0,y.jsx)(`section`,{className:`border-b border-border/70 px-4 py-3`,children:(0,y.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 xl:grid-cols-[1.35fr_1fr_1fr_1fr_1fr_auto]`,children:[(0,y.jsx)(A,{icon:(0,y.jsx)(ee,{}),placeholder:e(`activity:chronicle.searchEventEvidence`),value:C.text,onChange:e=>T(t=>({...t,text:e})),onEnter:$}),(0,y.jsx)(A,{placeholder:e(`activity:chronicle.fileOrDirectory`),value:C.path,onChange:e=>T(t=>({...t,path:e})),onEnter:$}),(0,y.jsx)(A,{placeholder:e(`activity:chronicle.provider`),value:C.providerId,onChange:e=>T(t=>({...t,providerId:e})),onEnter:$}),(0,y.jsx)(A,{placeholder:e(`activity:chronicle.model`),value:C.modelId,onChange:e=>T(t=>({...t,modelId:e})),onEnter:$}),(0,y.jsx)(A,{placeholder:e(`activity:chronicle.session`),value:C.sessionId,onChange:e=>T(t=>({...t,sessionId:e})),onEnter:$}),(0,y.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,y.jsxs)(`button`,{type:`button`,onClick:$,className:`rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground`,children:[(0,y.jsx)(g,{className:`mr-1 inline h-3 w-3`}),e(`activity:chronicle.apply`)]}),(0,y.jsx)(`button`,{type:`button`,onClick:ve,className:`rounded-md border border-border px-2.5 text-xs hover:bg-muted`,children:e(`activity:chronicle.clear`)})]})]})}),(0,y.jsxs)(`section`,{className:`flex items-center gap-1 overflow-x-auto border-b border-border/70 px-4 py-2`,children:[se.map(t=>(0,y.jsxs)(`button`,{type:`button`,onClick:()=>O(t.id),className:_(`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===t.id?`bg-primary/10 font-medium text-primary`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[t.icon,e(t.labelKey),(0,y.jsx)(`span`,{className:`ml-1 rounded bg-background/70 px-1 font-mono text-[9px]`,children:ce(I,t.id,N.total)})]},t.id)),(0,y.jsxs)(`div`,{className:`ml-auto hidden items-center gap-3 pl-4 text-[9px] text-muted-foreground lg:flex`,children:[(0,y.jsxs)(`span`,{children:[N.total.toLocaleString(),` matched`]}),(0,y.jsxs)(`span`,{children:[N.sourceFiles,` journal files`]}),N.invalidLines>0&&(0,y.jsxs)(`span`,{className:`text-warning`,children:[N.invalidLines,` invalid lines`]})]})]}),W&&(0,y.jsx)(b,{status:W}),Z&&(0,y.jsx)(de,{health:Z}),(0,y.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,y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,y.jsx)(`span`,{className:`mr-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e.replace(`Id`,``)}),(f[e]??[]).slice(0,4).map(t=>(0,y.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,y.jsx)(`b`,{children:t.count})]},t.value))]},e))}),(0,y.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,y.jsx)(`span`,{children:e(`activity:chronicle.time`)}),(0,y.jsx)(`span`,{children:e(`activity:chronicle.signal`)}),(0,y.jsx)(`span`,{children:e(`activity:chronicle.outcome`)}),(0,y.jsx)(`span`,{children:e(`activity:chronicle.modelAgent`)}),(0,y.jsx)(`span`,{children:e(`activity:chronicle.resource`)}),(0,y.jsx)(`span`,{})]}),(0,y.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:z?(0,y.jsx)(P,{text:z}):!L&&Y.length===0?(0,y.jsx)(P,{text:`No coding evidence matches these filters.`}):(0,y.jsx)(`div`,{className:`divide-y divide-border/40`,children:X.pageItems.map(e=>(0,y.jsx)(M,{event:e,active:o?.eventId===e.eventId,onClick:()=>ye(e)},e.eventId))})}),(0,y.jsx)(ae,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,itemLabel:`events`})]}),o&&(0,y.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,y.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,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-xs font-semibold`,children:e(`activity:chronicle.evidenceLineage`)}),(0,y.jsxs)(`div`,{className:`mt-0.5 font-mono text-[9px] text-muted-foreground`,children:[`#`,o.sequence,` · `,o.eventId]})]}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>c(null),className:`rounded p-1 hover:bg-muted`,children:(0,y.jsx)(d,{className:`h-4 w-4`})})]}),(0,y.jsx)(fe,{event:o,graph:me})]})]})}var E={llm:0,agent:0,tool:0,file:0,memory:0,task:0,decision:0,runtime:0},D={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:{...E},failuresByFamily:{...E}};function ce(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 le(e){let t=e.inputTokens+e.cacheReadTokens;return t?e.cacheReadTokens/t*100:0}function ue(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 O(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 k(e){return e?e<1?`${(e*1e3).toFixed(0)}µs`:e<1e3?`${e.toFixed(1)}ms`:`${(e/1e3).toFixed(1)}s`:`—`}function A({placeholder:e,value:t,onChange:n,onEnter:r,icon:i}){return(0,y.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,y.jsx)(`span`,{className:`text-muted-foreground [&>svg]:h-3.5 [&>svg]:w-3.5`,children:i}),(0,y.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 j({icon:e,label:t,value:n,detail:r,tone:i=`normal`}){return(0,y.jsxs)(`div`,{className:`min-w-0 border-r border-border/60 px-4 py-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:[(0,y.jsx)(`span`,{className:`text-primary [&>svg]:h-3.5 [&>svg]:w-3.5`,children:e}),t]}),(0,y.jsx)(`div`,{className:_(`mt-1 text-xl font-semibold tabular-nums`,i===`danger`&&`text-destructive`),children:typeof n==`number`?n.toLocaleString():n}),(0,y.jsx)(`div`,{className:`mt-0.5 truncate text-[9px] text-muted-foreground`,children:r})]})}function de({health:e}){let{t:n}=t();return(0,y.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,y.jsx)(`span`,{className:`font-sans font-semibold uppercase tracking-wider text-success`,children:n(`activity:chronicle.collectorHealthy`)}),(0,y.jsxs)(`span`,{children:[`ELU`,` `,(0,y.jsxs)(`b`,{className:`text-foreground`,children:[((e.eventLoop?.utilization??0)*100).toFixed(1),`%`]})]}),(0,y.jsxs)(`span`,{children:[`p95 `,(0,y.jsxs)(`b`,{className:`text-foreground`,children:[(e.eventLoop?.delayP95Ms??0).toFixed(1),`ms`]})]}),(0,y.jsxs)(`span`,{children:[`heap`,` `,(0,y.jsxs)(`b`,{className:`text-foreground`,children:[((e.memory?.heapUsedBytes??0)/1048576).toFixed(0),`MB`]})]}),(0,y.jsxs)(`span`,{children:[`queue `,(0,y.jsx)(`b`,{className:`text-foreground`,children:e.chronicle?.pendingEvents??0})]}),(0,y.jsxs)(`span`,{children:[`dropped`,` `,(0,y.jsx)(`b`,{className:_((e.chronicle?.rejectedEvents??0)>0&&`text-destructive`),children:e.chronicle?.rejectedEvents??0})]})]})}function M({event:e,active:t,onClick:n}){let r=e.occurredAt??e.observedAt,i=e.runtime?.modelId??e.scope.agentId??e.runtime?.providerId??`—`,a=e.resource?.path??e.resource?.id??e.correlation.toolCallId??`—`;return(0,y.jsxs)(`button`,{type:`button`,onClick:n,className:_(`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`,t&&`bg-primary/[0.07]`),children:[(0,y.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(r).toLocaleTimeString()}),(0,y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,y.jsx)(`span`,{className:_(`h-1.5 w-1.5 shrink-0 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,y.jsx)(`span`,{className:`truncate font-mono text-[11px] font-medium`,children:e.eventType})]}),(0,y.jsx)(`span`,{className:_(`w-fit rounded px-1.5 py-0.5 text-[9px]`,F(e.outcome)),children:e.outcome??`unknown`}),(0,y.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:i}),(0,y.jsx)(`span`,{className:`truncate font-mono text-[9px] text-muted-foreground`,children:a}),(0,y.jsx)(m,{className:`h-3.5 w-3.5 text-muted-foreground`})]})}function fe({event:e,graph:n}){let{t:r}=t(),i=(0,v.useMemo)(()=>[[`Scope`,e.scope],[`Correlation`,e.correlation],[`Runtime`,e.runtime],[`Resource`,e.resource],[`Attributes`,e.attributes],[`Tags`,e.tags]],[e]);return(0,y.jsxs)(`div`,{className:`p-4`,children:[(0,y.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/60 p-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:_(`h-2 w-2 rounded-full`,e.outcome===`failure`?`bg-destructive`:e.outcome===`success`?`bg-success`:`bg-primary`)}),(0,y.jsx)(`span`,{className:`font-mono text-xs font-semibold`,children:e.eventType})]}),(0,y.jsxs)(`div`,{className:`mt-2 flex gap-4 text-[9px] text-muted-foreground`,children:[(0,y.jsx)(`span`,{children:new Date(e.occurredAt??e.observedAt).toLocaleString()}),(0,y.jsx)(`span`,{children:O(Number(e.durationNs??0))})]})]}),(0,y.jsxs)(`div`,{className:`mb-4 grid grid-cols-2 gap-2`,children:[(0,y.jsx)(N,{icon:(0,y.jsx)(c,{}),label:r(`activity:chronicle.evidenceHash`),value:e.hash.slice(0,16)}),(0,y.jsx)(N,{icon:(0,y.jsx)(h,{}),label:r(`activity:chronicle.sequence`),value:String(e.sequence)})]}),n&&(0,y.jsxs)(`section`,{className:`mb-4`,children:[(0,y.jsxs)(`h3`,{className:`mb-1.5 flex items-center gap-1 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[(0,y.jsx)(o,{className:`h-3 w-3`}),`Lineage · `,n.nodes.length,` nodes · `,n.edges.length,` edges`]}),(0,y.jsx)(`div`,{className:`space-y-1 rounded-md border border-border bg-background/70 p-2`,children:n.edges.slice(0,40).map((e,t)=>(0,y.jsxs)(`div`,{className:`flex items-center gap-2 font-mono text-[9px]`,children:[(0,y.jsx)(`span`,{className:_(`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,y.jsx)(`span`,{className:`text-muted-foreground`,children:e.kind}),(0,y.jsxs)(`span`,{className:`truncate`,children:[n.nodes.find(t=>t.eventId===e.from)?.eventType,` →`,` `,n.nodes.find(t=>t.eventId===e.to)?.eventType]})]},`${e.from}-${e.to}-${e.kind}-${t}`))}),n.truncated&&(0,y.jsx)(`p`,{className:`mt-1 text-[9px] text-warning`,children:r(`activity:chronicle.lineageTruncatedAtSafetyLimit`)})]}),i.map(([e,t])=>t&&(0,y.jsxs)(`section`,{className:`mb-4`,children:[(0,y.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-semibold uppercase tracking-wider text-muted-foreground`,children:e}),(0,y.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 N({icon:e,label:t,value:n}){return(0,y.jsxs)(`div`,{className:`rounded-md border border-border p-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-1 text-[8px] uppercase text-muted-foreground`,children:[(0,y.jsx)(`span`,{className:`[&>svg]:h-3 [&>svg]:w-3`,children:e}),t]}),(0,y.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px]`,children:n})]})}function P({text:e}){return(0,y.jsx)(`div`,{className:`flex h-48 items-center justify-center text-sm text-muted-foreground`,children:e})}function F(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{T as ChronicleDashboard};
|