@agimon-ai/po-cloudflare 0.0.2-alpha.11 → 0.0.2-alpha.13
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/agent-DYFqCLl2.js +6850 -0
- package/dist/assets/plugins/assets/base-C3j1WCCq.css +2 -0
- package/dist/assets/plugins/chunks/po-web-runtime-Czm_C4SJ.js +1 -0
- package/dist/assets/plugins/compositions.json +1 -1
- package/dist/assets/plugins/slots/approval.8b3f37d9-CqQk6XG_.js +2 -0
- package/dist/assets/plugins/slots/artifacts.47d00f81-D-vQ-7Iz.js +1 -0
- package/dist/assets/plugins/slots/autocompact.9a92993d-B3KTYwW1.js +1 -0
- package/dist/assets/plugins/slots/builtin-tools.939bbfff-CZRYQVIP.js +7 -0
- package/dist/assets/plugins/slots/codemode.782e5bb1-Bzl_K_vt.js +10 -0
- package/dist/assets/plugins/slots/domain.21790b66-CvnpuKCY.js +1 -0
- package/dist/assets/plugins/slots/edit.c7c85129-kaxIknZ-.js +7 -0
- package/dist/assets/plugins/slots/files.bbcef824-wuB8gcQA.js +2 -0
- package/dist/assets/plugins/slots/grep.3dfd3214-3FnU8p-d.js +1 -0
- package/dist/assets/plugins/slots/log.33bc7d38-C0PXQ0O1.js +4 -0
- package/dist/assets/plugins/slots/mcp.59c68bcb-D0CkHnIw.js +109 -0
- package/dist/assets/plugins/slots/{profile.ab16dcec-B5yt7eny.js → profile.ea55f5e1-BSY3iYfJ.js} +1 -1
- package/dist/assets/plugins/slots/prompts.9957cc84-xdCkNkoA.js +3 -0
- package/dist/assets/plugins/slots/read.30a617e7-qqaxVlEX.js +1 -0
- package/dist/assets/plugins/slots/runner.9f3559b0-DfO2Z9HG.js +8 -0
- package/dist/assets/plugins/slots/skill.f506a5ea-CL_n-l4h.js +4 -0
- package/dist/assets/plugins/slots/vault.01657352-DbG3F_on.js +1 -0
- package/dist/{atomicJson-C_lN9leA.js → atomicJson-BF1fVXy1.js} +1 -1
- package/dist/browser-BWf8OMfl.js +3 -0
- package/dist/childSession-Cf2-kH4O.js +22 -0
- package/dist/{server-D190dXDN.js → dist-B-vqs6tA.js} +1 -546
- package/dist/{domains-CPX1dEVa.js → domains-Bl6T2dKV.js} +2 -2
- package/dist/{server-C5wixba6.js → esm-BKJy3O9-.js} +3 -296
- package/dist/{exports-2Vv52b9v.js → exports-CxkWsXI9.js} +7 -6
- package/dist/{exports-BF12Ftrd.js → exports-DlcCEAe3.js} +2 -9
- package/dist/{extensionFile-DpVvh-ud.js → extensionFile-D7wk8tFr.js} +11 -1
- package/dist/harnessStore-Bap8lsAg.js +1 -0
- package/dist/{harnessStore-Ct329wxJ.js → harnessStore-flLz1I0F.js} +2 -2
- package/dist/help-DjybmnPW.js +91 -0
- package/dist/{hubChannel-kFgtfJnv.js → hubChannel-Bi3PQrfD.js} +3 -27
- package/dist/hubRevisions-58pU2dW5.js +363 -0
- package/dist/index.edge-C9_xuXyy.js +57 -0
- package/dist/{index.edge-DhV_hfZA.js → index.edge-CJ2TFpgF.js} +2 -2
- package/dist/index.edge-COJJ_Dv2.js +937 -0
- package/dist/index.edge-ChYa2LU4.js +14 -0
- package/dist/index.edge-ClLTmPFz.js +191 -0
- package/dist/{index.edge-BNElrrHY.js → index.edge-uSjRpm6Z.js} +5 -0
- package/dist/iso-BPQViXM8.js +10 -0
- package/dist/{layeredConfig-BhFC6TBD.js → layeredConfig-B4s0eZ5o.js} +11 -4
- package/dist/{majorModes-CZqrWarh.js → majorModes-IygGmbb8.js} +2 -2
- package/dist/majorModes-xpLK9HpD.js +1 -0
- package/dist/notification-bGq1frYG.js +99 -0
- package/dist/piConfig-CcoMX-1L.js +127 -0
- package/dist/{platformFiles-BTDsAsmT.js → platformFiles-Ccj9HCvA.js} +24 -2
- package/dist/pluginContributions-Be9EnCAW.js +16 -0
- package/dist/sealedChannel-BeWNTWys.js +27 -0
- package/dist/server-4CmqIbH2.js +1476 -0
- package/dist/{server-DesPQYzJ.js → server-5vLvBTTs.js} +1 -1
- package/dist/server-BHhb0oir.js +505 -0
- package/dist/server-Bm6pAAw8.js +935 -0
- package/dist/server-C82Qzoh3.js +2658 -0
- package/dist/server-C8HyW7wN.js +489 -0
- package/dist/{server-DSusAvqK.js → server-C9gff7gU.js} +1 -1
- package/dist/{server-CTIkoJXM.js → server-CIhwIcbA.js} +4 -4
- package/dist/{server-DbmCxFL-.js → server-CMaTba5B.js} +1 -1
- package/dist/{server-DolHpEoY.js → server-COE7BKSa.js} +1 -1
- package/dist/server-CQXqMpeC.js +1744 -0
- package/dist/{server-BG6gwBcv.js → server-CTSvwoDy.js} +5 -4
- package/dist/server-C_34VM3M.js +217 -0
- package/dist/{server-CuGXhVFA.js → server-C_3jK2WM.js} +5 -5
- package/dist/server-CcNMwEFQ.js +190 -0
- package/dist/{server-D-zQp04y.js → server-CjsKNdSN.js} +1 -1
- package/dist/{server-DQy8hVXg.js → server-ClsNJwdv.js} +8 -8
- package/dist/{server-DfBHHyQo.js → server-Co57A8MH.js} +2 -9
- package/dist/{server-CRtXiNBP.js → server-CpJNq249.js} +5 -5
- package/dist/{server-zYYAg7ki.js → server-CxGGQFJs.js} +5 -16
- package/dist/{server-DpVsUiA-.js → server-DSu_uLDX.js} +4 -4
- package/dist/server-DeSuziRK.js +680 -0
- package/dist/{server-BIjpcE0Y.js → server-ZsazKk-n.js} +3 -3
- package/dist/{server-CZoHLCxk.js → server-il_s2Ycz.js} +5 -93
- package/dist/server-ziNfBZ2M.js +295 -0
- package/dist/{sessionConfig-BLmM5XLM.js → sessionConfig-DzAs6Pt-.js} +64 -499
- package/dist/{notification-qvyJJ_Df.js → telemetry-Csv1ZxAn.js} +1 -99
- package/dist/truncate-M3KbFyVj.js +89 -0
- package/dist/web-Cfvbn9H1.js +3 -0
- package/dist/worker.js +4545 -12244
- package/dist/workflow-w5JPZXgc.js +23 -0
- package/package.json +32 -24
- package/dist/assets/plugins/assets/base-_m1hGahv.css +0 -2
- package/dist/assets/plugins/chunks/po-web-runtime-CGjOl_1I.js +0 -1
- package/dist/assets/plugins/slots/approval.09e72f36-BW92gZQg.js +0 -2
- package/dist/assets/plugins/slots/artifacts.50b639bb-B6zDJhex.js +0 -1
- package/dist/assets/plugins/slots/builtin-tools.75108f21-DS-dJ07p.js +0 -7
- package/dist/assets/plugins/slots/codemode.c58fb583--t-nrGeQ.js +0 -10
- package/dist/assets/plugins/slots/domain.753f9f92-DWSqP3Jw.js +0 -1
- package/dist/assets/plugins/slots/mcp.82cc1ff5-jPY2OCuu.js +0 -109
- package/dist/assets/plugins/slots/skill.62a0a1b3-GtWLT33O.js +0 -4
- package/dist/assets/plugins/slots/vault.3cbfcdc3-B7BKfR_H.js +0 -1
- package/dist/harnessStore-BDI-s999.js +0 -1
- package/dist/majorModes-CzAWXyaf.js +0 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{B as e,Bn as t,Cn as n,Hn as r,I as i,It as a,L as o,Ln as s,Pn as c,R as l,S as u,Sn as d,Tn as f,Tt as p,V as m,W as h,Wt as g,a as _,b as v,f as y,i as b,l as x,n as S,o as C,ot as w,p as T,st as ee,u as te,un as ne,vt as E,w as D,x as O,y as k,z as A}from"../chunks/po-web-runtime-Czm_C4SJ.js";var re=[`session`,`agent`,`model`,`provider`],ie=[`day`,`week`,`month`,`all`],j={dimension:`dimension`,period:`period`,focus:`focus`};function M(e){return`unavailable`in e}function ae(e){return`unavailable`in e}var oe=f({metrics:{method:`GET`,path:`/metrics`,query:[j.dimension,j.period,j.focus],response:d()},issues:{method:`GET`,path:`/issues`,query:[j.focus],response:d()},ingestLogs:{method:`POST`,path:`/v1/logs`,response:d()}}),N=n(oe,{scopes:[`global`,`workspace`,`session`],basePath:`log`,transport:(e,t)=>S.fetch(e,t),sessionAddress:r}),se=`The cockpit hub is unreachable.`,ce=`This cockpit is running a bundle without the log package API, so there are no metrics to read.`,le={unavailable:`no-api`,detail:ce};function ue(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function de(e,t){if(e.status===0)return{error:t?.aborted===!0?``:se};let n=`The hub answered ${String(e.status)}.`;return e.data===void 0?e.ok?{noApi:!0}:{error:n}:ue(e.data)?e.ok?{body:e.data}:{error:e.error===``?n:e.error}:{error:`The hub returned a response the cockpit could not read.`}}async function fe(e,t,n,r){let i=de(await N.global.metrics({query:{[j.dimension]:e,[j.period]:t,[j.focus]:n===``?void 0:n},...r===void 0?{}:{signal:r}}),r);if(`error`in i)return{error:i.error};if(`noApi`in i)return{report:le};let a=i.body;return!M(a)&&!Array.isArray(a.groups)?{error:`The hub returned a report the cockpit could not read.`}:{report:a}}async function pe(e,t,n={}){let r=de(await N.global.issues({query:{[j.focus]:e===``?void 0:e,...n},...t===void 0?{}:{signal:t}}),t);return`error`in r?{error:r.error}:`noApi`in r?{issues:{unavailable:`no-api`,detail:ce}}:{issues:r.body}}function P(e,t){return!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<=0?0:Math.min(1,e/t)}function F(e){return e.reduce((e,t)=>Number.isFinite(t)&&t>e?t:e,0)}function I(e){return Number.isFinite(e)?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e)):`Not reported`}var L=5;function me({groups:e,totalTokens:t,focus:n,onFocus:r}){let[i,a]=T(!1),o=[...e].sort((e,t)=>t.totalTokens-e.totalTokens||e.key.localeCompare(t.key)),s=i?o:o.slice(0,L),c=t??F(e.map(e=>e.totalTokens));return C(`div`,{className:`flex flex-col gap-3`,children:[e.length===0?_(`p`,{className:`rounded-md border border-dashed border-po-border p-5 text-sm text-po-dim`,children:`No grouped usage was recorded for this selection.`}):null,_(`ul`,{className:`flex flex-col gap-1`,"data-testid":`metrics-group-bars`,children:s.map(e=>{let i=n===e.key,a=e.key===`unknown`||e.key===``,o=r!==void 0&&!a,s=P(e.totalTokens,c)*100,l=C(b,{children:[C(`span`,{className:`flex items-start justify-between gap-3`,children:[_(`span`,{className:`min-w-0 break-all text-left font-medium text-po-hi`,title:e.key,children:a?`Unattributed`:e.key}),_(`span`,{className:`shrink-0 text-right font-semibold tabular-nums text-po-hi`,title:String(e.totalTokens),children:I(e.totalTokens)})]}),_(`span`,{"aria-hidden":`true`,className:`mt-2 block h-1.5 overflow-hidden rounded-full bg-po-border`,children:_(`span`,{className:`block h-full rounded-full ${a?`bg-po-yellow`:`bg-po-blue`}`,style:{width:`${s}%`}})}),C(`span`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-sm text-po-dim`,children:[_(`span`,{children:t!==void 0&&c>0?`${s.toFixed(1)}% of total`:`Relative token volume`}),C(`span`,{className:e.issueCount>0||e.failed?`text-po-yellow`:`text-po-dim`,children:[e.failed?`Failed · `:``,I(e.issueCount),` `,e.issueCount===1?`issue`:`issues`]})]})]});return _(`li`,{children:o?_(`button`,{type:`button`,onClick:()=>r?.(i?``:e.key),"aria-pressed":i,"aria-label":`Filter to ${e.key}`,"data-testid":`metrics-group-${e.key}`,className:`block w-full rounded-md p-3 text-base hover:bg-po-tint-blue focus-visible:outline focus-visible:outline-1 focus-visible:outline-po-blue ${i?`bg-po-tint-blue`:``}`,children:l}):_(`div`,{className:`rounded-md p-3 text-base`,children:l})},e.key)})}),e.length>L?_(E,{variant:`ghost`,size:`sm`,onClick:()=>a(!i),"aria-expanded":i,children:i?`Show top 5`:`Show all ${e.length} returned groups`}):null]})}var R=[{key:`totalTokens`,label:`Total`},{key:`inputTokens`,label:`Input`},{key:`outputTokens`,label:`Output`}],z=600,B=160,he=48;function ge({buckets:e,bucketUnit:t,onShorterPeriod:n}){let[r,i]=T(`totalTokens`),[a,o]=T(``),s=e.find(e=>e.label===a)??e.at(-1),c=F(e.map(e=>e[r])),l=t?`${t} `:``,u=z/Math.max(1,e.length),d=Math.min(he,u*.65);return e.length===0?_(`p`,{className:`rounded-md border border-dashed border-po-border p-5 text-sm text-po-dim`,"data-testid":`metrics-timeline-chart`,children:`No timeline buckets were recorded for this selection.`}):e.length===1&&s!==void 0?_(`div`,{className:`flex flex-col gap-4`,"data-testid":`metrics-timeline-chart`,children:C(`div`,{className:`rounded-md border border-po-border bg-po-deep p-5`,children:[_(`p`,{className:`text-sm text-po-dim`,children:s.label}),C(`p`,{className:`mt-2 text-lg font-semibold tabular-nums text-po-blue`,title:String(s.totalTokens),children:[I(s.totalTokens),` tokens`]}),C(`p`,{className:`mt-3 text-sm leading-relaxed text-po-dim`,children:[`Only one `,l,`bucket was recorded. There is not enough history to show a trend.`]}),_(`p`,{className:`mt-2 text-sm text-po-dim`,children:`For more detail, pick a shorter period when one is available.`}),n===void 0?null:_(E,{variant:`ghost`,size:`sm`,className:`mt-3`,onClick:n,children:`View hourly detail`})]})}):C(`div`,{className:`flex flex-col gap-3`,"data-testid":`metrics-timeline-chart`,children:[C(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[_(`div`,{className:`flex gap-1`,role:`group`,"aria-label":`Timeline token counter`,children:R.map(e=>_(E,{size:`sm`,variant:r===e.key?`primary`:`ghost`,"aria-pressed":r===e.key,onClick:()=>i(e.key),children:e.label},e.key))}),C(`span`,{className:`text-sm text-po-dim`,children:[e.length,` recorded `,l,`buckets`]})]}),C(`div`,{className:`flex gap-3`,children:[C(`div`,{"aria-hidden":`true`,className:`flex w-12 shrink-0 flex-col justify-between text-right text-sm tabular-nums text-po-dim`,children:[_(`span`,{children:I(c)}),_(`span`,{children:I(c/2)}),_(`span`,{children:`0`})]}),C(`svg`,{viewBox:`0 0 ${z} ${B}`,preserveAspectRatio:`none`,className:`h-40 min-w-0 flex-1 overflow-visible`,role:`group`,"aria-label":`tokens per bucket, peak ${I(c)}`,children:[[0,B/2,B].map(e=>_(`line`,{x1:`0`,x2:z,y1:e,y2:e,className:`text-po-border`,stroke:`currentColor`,vectorEffect:`non-scaling-stroke`},e)),e.map((e,t)=>{let n=P(e[r],c)*B,i=`${e.label}: ${I(e[r])} ${R.find(e=>e.key===r)?.label.toLowerCase()} tokens`;return C(`g`,{children:[_(`rect`,{x:t*u+(u-d)/2,y:B-n,width:d,height:n,rx:`2`,fill:`currentColor`,className:s?.label===e.label?`text-po-cyan`:`text-po-blue`}),_(`rect`,{x:t*u,y:`0`,width:u,height:B,fill:`transparent`,tabIndex:0,role:`button`,"aria-label":i,"aria-pressed":s?.label===e.label,onMouseEnter:()=>o(e.label),onFocus:()=>o(e.label),onClick:()=>o(e.label),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),o(e.label))},className:`cursor-pointer focus-visible:outline focus-visible:outline-1 focus-visible:outline-po-cyan`,children:_(`title`,{children:i})})]},e.label)})]})]}),C(`div`,{className:`ml-15 flex justify-between gap-3 text-sm text-po-dim`,children:[_(`span`,{children:e[0]?.label}),_(`span`,{className:`text-right`,children:e.at(-1)?.label})]}),C(`div`,{className:`flex flex-wrap justify-between gap-2 rounded-md bg-po-deep px-3 py-2 text-sm tabular-nums`,"aria-live":`polite`,"aria-atomic":`true`,children:[_(`span`,{className:`text-po-dim`,children:s?.label}),C(`span`,{className:`text-po-hi`,children:[I(s?.[r]??NaN),` `,R.find(e=>e.key===r)?.label.toLowerCase(),` tokens`]})]}),c===0?C(`p`,{className:`text-sm text-po-dim`,children:[`Recorded buckets contain zero `,R.find(e=>e.key===r)?.label.toLowerCase(),` tokens.`]}):null,C(`details`,{className:`text-sm text-po-dim`,children:[_(`summary`,{className:`cursor-pointer rounded-sm focus-visible:outline focus-visible:outline-1 focus-visible:outline-po-blue`,children:`View exact bucket values`}),_(`div`,{className:`mt-3 overflow-x-auto`,children:C(`table`,{className:`w-full text-right tabular-nums`,children:[_(`caption`,{className:`sr-only`,children:`Independent token counters by recorded bucket`}),_(`thead`,{children:C(`tr`,{children:[_(`th`,{scope:`col`,className:`py-2 text-left`,children:`Bucket`}),_(`th`,{scope:`col`,className:`pl-3`,children:`Total`}),_(`th`,{scope:`col`,className:`pl-3`,children:`Input`}),_(`th`,{scope:`col`,className:`pl-3`,children:`Output`})]})}),_(`tbody`,{children:e.map(e=>C(`tr`,{className:`border-t border-po-border`,children:[_(`th`,{scope:`row`,className:`py-2 text-left font-normal`,children:e.label}),R.map(t=>_(`td`,{className:`pl-3`,children:Number.isFinite(e[t.key])?e[t.key].toLocaleString(`en-US`):`Not reported`},t.key))]},e.label))})]})})]})]})}function _e(e){return`${e.fingerprint===``?`${e.category}|${e.message}`:e.fingerprint}|${e.detail}`}function ve(e){let t=new Map;for(let n of e){let e=_e(n),r=t.get(e);r===void 0?t.set(e,{key:e,occurrences:n.occurrenceCount,category:n.category,detail:n.detail,tool:n.tool,errorType:n.errorType,agentName:n.agentName,model:n.model,statusCode:n.statusCode,lastSeen:n.timestamp,members:[n]}):(r.occurrences+=n.occurrenceCount,r.members.push(n),n.timestamp>r.lastSeen&&(r.lastSeen=n.timestamp),r.tool??=n.tool,r.errorType??=n.errorType,r.agentName??=n.agentName,r.model??=n.model,r.statusCode??=n.statusCode)}return[...t.values()].sort((e,t)=>t.occurrences-e.occurrences||e.detail.localeCompare(t.detail))}function V(e){return Object.entries(e).sort(([,e],[,t])=>t-e)}function ye(e){return e.errorType===null?e.tool===null?e.category:`${e.tool} failed`:e.errorType}function be({group:e,max:t,tools:n}){let[r,i]=T(!1),a=`${(P(e.occurrences,t)*100).toFixed(2)}%`,o=n.find(t=>t.name===e.tool)?.calls;return C(`li`,{className:`flex flex-col rounded-md border border-po-border`,children:[C(`div`,{className:`relative`,children:[_(`span`,{"aria-hidden":`true`,className:`absolute bottom-0 left-0 h-1 rounded-xs bg-po-yellow/40`,style:{width:a}}),C(`button`,{type:`button`,onClick:()=>i(!r),"aria-expanded":r,"data-testid":`metrics-issue-${e.key}`,className:`relative flex min-h-10 w-full flex-wrap items-start gap-3 rounded-md p-3 text-left text-base hover:bg-po-tint-blue focus-visible:outline focus-visible:outline-1 focus-visible:outline-po-blue`,children:[_(`span`,{className:`w-8 shrink-0 text-right font-semibold text-po-yellow`,children:e.occurrences}),_(`span`,{className:`w-24 shrink-0 break-words font-medium text-po-hi`,children:ye(e)}),_(`span`,{className:`min-w-40 flex-1 break-words text-po-dim`,children:e.detail}),o===void 0?null:C(`span`,{className:`shrink-0 text-po-dim`,children:[o,` token samples`]})]})]}),r?C(`div`,{className:`flex flex-col gap-1 px-3 py-3 text-base`,"data-testid":`metrics-issue-body-${e.key}`,children:[C(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-sm text-po-dim`,children:[C(`span`,{children:[`category `,e.category]}),e.tool===null?null:C(`span`,{children:[`tool `,e.tool]}),e.errorType===null?null:C(`span`,{children:[`error `,e.errorType]}),e.statusCode===null?null:C(`span`,{children:[`status `,e.statusCode]}),e.agentName===null?null:C(`span`,{children:[`agent `,e.agentName]}),e.model===null?null:C(`span`,{children:[`model `,e.model]}),C(`span`,{children:[`last seen `,e.lastSeen]})]}),_(`span`,{className:`break-words text-po-dim`,children:e.detail}),_(`ul`,{className:`flex flex-col gap-1 text-sm text-po-dim`,children:e.members.map((e,t)=>C(`li`,{className:`flex flex-wrap gap-x-2`,children:[_(`span`,{children:e.timestamp}),_(`span`,{children:e.level}),C(`span`,{children:[e.occurrenceCount,`×`]}),_(`span`,{className:`min-w-0 truncate`,children:e.message})]},`${e.timestamp}-${String(t)}`))})]}):null]})}function xe({view:e,tools:t,summaryCount:n}){let r=ve(e.samples),i=r[0]?.occurrences??0,a=new Map(t.map(e=>[e.name,e.calls]));return C(`div`,{className:`flex flex-col gap-3`,children:[n!==void 0&&n!==e.totalIssues?C(`p`,{className:`rounded-md border border-po-edge-yellow bg-po-tint-yellow p-3 text-sm leading-relaxed text-po-yellow`,role:`status`,"data-testid":`metrics-issue-count-mismatch`,children:[`The summary reports `,n,` `,n===1?`issue`:`issues`,`; incident analysis returned`,` `,e.totalIssues,`. The counts differ, so these details should not be treated as a complete explanation of the summary.`]}):null,C(`span`,{className:`text-sm text-po-dim`,children:[_(`span`,{className:`text-po-hi`,children:e.totalIssues}),` occurrences of`,` `,_(`span`,{className:`text-po-hi`,children:r.length}),` distinct problems in the returned samples, most frequent first`]}),r.length===0?_(`p`,{className:`rounded-md border border-dashed border-po-border p-4 text-sm text-po-dim`,children:e.totalIssues===0?`No issues were detected in the returned analysis. This does not establish coverage of unrecorded activity.`:`The analysis counted issues but returned no incident samples.`}):_(`ul`,{className:`flex flex-col gap-2`,"data-testid":`metrics-issue-groups`,children:r.map(e=>_(be,{group:e,max:i,tools:t},e.key))}),Object.keys(e.byTool).length===0?null:C(`div`,{className:`flex flex-col gap-2 overflow-x-auto`,children:[_(`h4`,{className:`text-base font-semibold text-po-hi`,children:`Failures by tool`}),C(`table`,{className:`w-full text-sm`,"data-testid":`metrics-issues-tools`,children:[_(`thead`,{children:C(`tr`,{className:`text-sm text-po-dim`,children:[_(`th`,{scope:`col`,className:`py-2 text-left font-normal`,children:`Tool`}),_(`th`,{scope:`col`,className:`text-right font-normal`,children:`Failures`}),_(`th`,{scope:`col`,className:`text-right font-normal`,children:`Attribution context`})]})}),_(`tbody`,{children:V(e.byTool).map(([e,t])=>{let n=a.get(e);return C(`tr`,{className:`border-b border-po-border/40`,children:[_(`td`,{className:`min-w-0 break-all py-2 text-po-dim`,children:e}),_(`td`,{className:`w-16 py-2 text-right text-po-red`,children:t}),_(`td`,{className:`w-28 py-2 text-right text-po-dim`,children:n===void 0?`no token samples`:`${String(n)} token samples`})]},e)})})]})]}),C(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-sm text-po-dim`,children:[_(`span`,{className:`text-sm font-semibold text-po-dim`,children:`by category`}),V(e.byCategory).map(([e,t])=>C(`span`,{children:[e,` `,_(`span`,{className:`text-po-hi`,children:t})]},e))]})]})}function Se({tools:e,focus:t,count:n,startTime:r,endTime:i,broaderScope:a=!1}){let[o,s]=T(),[c,l]=T(``),[u,d]=T(!1),[f,p]=T(!1),m=y(void 0),h=te();return x(()=>(m.current?.abort(),s(void 0),l(``),d(!1),p(!1),()=>m.current?.abort()),[t,r,i]),C(`section`,{className:`flex min-w-0 flex-col gap-3 rounded-lg border border-po-border bg-po-panel p-4`,"data-testid":`metrics-issues`,children:[C(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[C(`div`,{children:[C(`h3`,{className:`text-lg font-semibold text-po-hi`,children:[`Issues to investigate`,n===void 0?``:` · ${n} ${n===1?`issue`:`issues`}`]}),_(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Inspect recurring failures and the evidence behind them.`})]}),C(`div`,{className:`flex items-center gap-2`,children:[u?_(w,{label:`Reading issue details`}):null,_(E,{variant:`outline`,size:`md`,disabled:u,onClick:()=>{m.current?.abort();let e=new AbortController;m.current=e,p(!0),d(!0),l(``),s(void 0),pe(t,e.signal,{startTime:r,endTime:i}).then(t=>{e.signal.aborted||(d(!1),`error`in t?l(t.error||`Issue details could not be loaded.`):ae(t.issues)?l(t.issues.detail):s(t.issues))}).catch(t=>{e.signal.aborted||(d(!1),l(t instanceof Error?t.message:`Issue details could not be loaded.`))})},"aria-expanded":f,"aria-controls":h,"data-testid":f?`metrics-issues-reload`:`metrics-issues-open`,children:f?`Reload details`:`Inspect issues`}),f?_(E,{variant:`ghost`,size:`md`,onClick:()=>{m.current?.abort(),d(!1),p(!1)},"aria-controls":h,children:`Hide`}):null]})]}),C(`p`,{className:`text-sm leading-relaxed text-po-dim`,children:[`Details are loaded on demand.`,` `,r===void 0?i===void 0?`This hub did not report a time window; details cover all available history.`:`Details cover available history up to report time; no start bound was supplied.`:`Details use the report’s recorded time window.`,` `,a?`LogSink cannot filter issue details by model, provider or agent, so this analysis covers all groups in that window.`:t===void 0?`Analysis covers all groups.`:`Filtered to this session.`]}),C(`div`,{id:h,hidden:!f,"aria-busy":u,children:[c===``?null:_(`p`,{role:`alert`,className:`rounded-md border border-po-edge-yellow bg-po-tint-yellow p-3 text-sm text-po-yellow`,"data-testid":`metrics-issues-message`,children:c}),u?_(`p`,{role:`status`,className:`py-3 text-sm text-po-dim`,children:`Reading recorded incidents...`}):null,o===void 0?null:_(xe,{view:o,tools:a?[]:e,summaryCount:a?void 0:n})]})]})}function Ce({totals:e}){let t=[{label:`Total tokens`,value:e.totalTokens,detail:`Provider-reported total`,color:`text-po-blue`},{label:`Input tokens`,value:e.inputTokens,detail:`Reported input counter`,color:`text-po-hi`},{label:`Output tokens`,value:e.outputTokens,detail:`Reported output counter`,color:`text-po-hi`},{label:`Recorded issues`,value:e.issueCount,detail:`Detected in this selection`,color:e.issueCount>0?`text-po-yellow`:`text-po-hi`}];return _(`dl`,{className:`grid grid-cols-2 gap-3 @3xl:grid-cols-4`,"data-testid":`metrics-summary`,children:t.map(e=>C(`div`,{className:`min-w-0 rounded-lg border border-po-border bg-po-panel p-4`,children:[_(`dt`,{className:`text-sm text-po-dim`,children:e.label}),_(`dd`,{className:`mt-2 text-lg font-semibold tabular-nums ${e.color}`,title:Number.isFinite(e.value)?e.value.toLocaleString(`en-US`):`Not reported`,children:I(e.value)}),_(`dd`,{className:`mt-1 text-sm text-po-dim`,children:e.detail})]},e.label))})}function we({tools:e}){let[t,n]=T(`p90TotalTokens`),r=[...e].sort((e,n)=>n[t]-e[t]||e.name.localeCompare(n.name));return C(`section`,{className:`flex min-w-0 flex-col gap-4 rounded-lg border border-po-border bg-po-panel p-4`,"aria-label":`Tool token samples`,children:[C(`div`,{children:[_(`h3`,{className:`text-lg font-semibold text-po-hi`,children:`Tool token samples`}),_(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Which tools participate in token-heavy turns?`})]}),r.length===0?C(`div`,{className:`flex flex-1 flex-col justify-center gap-2 rounded-md border border-dashed border-po-border p-5`,"data-testid":`metrics-tools-empty`,children:[_(`p`,{className:`text-base font-semibold text-po-hi`,children:`No token-attributed tool calls`}),_(`p`,{className:`text-sm leading-relaxed text-po-dim`,children:`Tool execution logs may exist, but this selection has no samples that connect tools to model usage. This does not mean no tools ran.`})]}):C(b,{children:[C(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":`Rank tool samples by`,children:[_(E,{size:`sm`,variant:t===`p90TotalTokens`?`primary`:`ghost`,"aria-pressed":t===`p90TotalTokens`,onClick:()=>n(`p90TotalTokens`),children:`P90 turn tokens`}),_(E,{size:`sm`,variant:t===`calls`?`primary`:`ghost`,"aria-pressed":t===`calls`,onClick:()=>n(`calls`),children:`Sampled calls`})]}),_(`div`,{className:`overflow-x-auto`,children:C(`table`,{className:`w-full text-base tabular-nums`,"data-testid":`metrics-tools`,children:[C(`caption`,{className:`sr-only`,children:[`Tools ranked by `,t===`calls`?`sampled calls`:`90th percentile whole-turn tokens`]}),_(`thead`,{children:C(`tr`,{className:`border-b border-po-border text-sm text-po-dim`,children:[_(`th`,{scope:`col`,className:`pb-2 text-left font-normal`,children:`Tool`}),_(`th`,{scope:`col`,className:`pb-2 pl-3 text-right font-normal`,children:`Sampled calls`}),_(`th`,{scope:`col`,className:`pb-2 pl-3 text-right font-normal`,children:`P90 turn tokens`})]})}),_(`tbody`,{children:r.map(e=>C(`tr`,{className:`border-b border-po-border/40`,children:[_(`th`,{scope:`row`,className:`max-w-48 break-all py-3 text-left font-normal text-po-hi`,children:e.name}),_(`td`,{className:`py-3 pl-3 text-right text-po-dim`,children:I(e.calls)}),_(`td`,{className:`py-3 pl-3 text-right text-po-blue`,title:String(e.p90TotalTokens),children:I(e.p90TotalTokens)})]},e.name))})]})})]}),C(`details`,{className:`text-sm leading-relaxed text-po-dim`,children:[_(`summary`,{className:`cursor-pointer rounded-sm focus-visible:outline focus-visible:outline-1 focus-visible:outline-po-blue`,children:`How these samples are counted`}),_(`p`,{className:`mt-2`,children:`This view includes only calls with recorded token attribution; external MCP calls remain in the logs. P90 is the 90th percentile of the whole turn, not each tool's own consumption. Several tools may share a turn, so do not add these values together.`})]})]})}var H={session:`session`,agent:`agent`,model:`model`,provider:`provider`},U={session:`Session ids are hashed before export. Select a row to filter usage, not to open a session.`};function Te({report:e,onFocus:t,onPeriodChange:n}){let r=H[e.dimension],i=e.groups.filter(e=>e.key===`unknown`||e.key===``).reduce((e,t)=>e+t.totalTokens,0),a=[{name:`Cache reads`,value:e.totals.cachedTokens},{name:`Reasoning tokens`,value:e.totals.reasoningTokens},{name:`Usage events`,value:e.totals.usageEventCount},{name:`Log and span records`,value:e.totals.totalRecords}],o=new Date(e.generatedAt);return C(`div`,{className:`@container flex w-full min-w-0 flex-col gap-4`,"data-testid":`metrics-report`,children:[_(Ce,{totals:e.totals}),C(`div`,{className:`grid min-w-0 grid-cols-1 gap-4 @3xl:grid-cols-3`,children:[C(`section`,{className:`flex min-w-0 flex-col gap-4 rounded-lg border border-po-border bg-po-panel p-4 @3xl:col-span-2`,"aria-label":`Usage over time`,children:[C(`div`,{children:[_(`h3`,{className:`text-lg font-semibold text-po-hi`,children:`Usage over time`}),_(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Recorded tokens, not estimated spend.`})]}),_(ge,{buckets:e.timeline,bucketUnit:e.bucketUnit,onShorterPeriod:e.period===`day`||n===void 0?void 0:()=>n(`day`)})]}),C(`section`,{className:`flex min-w-0 flex-col gap-4 rounded-lg border border-po-border bg-po-panel p-4`,"aria-label":`Reported counters`,children:[_(`h3`,{className:`text-lg font-semibold text-po-hi`,children:`Reported counters`}),_(`dl`,{className:`flex flex-col gap-3`,children:a.map(e=>C(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1 border-b border-po-border/40 pb-3`,children:[_(`dt`,{className:`text-sm text-po-dim`,children:e.name}),_(`dd`,{className:`text-base font-semibold tabular-nums text-po-hi`,title:e.value===void 0?`Not reported`:String(e.value),children:I(e.value??NaN)})]},e.name))}),_(`p`,{className:`text-sm leading-relaxed text-po-dim`,children:`Monetary cost is not included in this metrics report.`}),C(`details`,{className:`text-sm leading-relaxed text-po-dim`,children:[_(`summary`,{className:`cursor-pointer rounded-sm focus-visible:outline focus-visible:outline-1 focus-visible:outline-po-blue`,children:`Why the counters may not add up`}),_(`p`,{className:`mt-2`,children:`The total is reported by providers. Input, output, cache reads and reasoning are independent counters and may overlap or be incomplete. They are not a breakdown and may not sum to the total. A gap is not evidence of cache traffic. Missing fields say Not reported; a recorded zero stays zero.`})]})]})]}),C(`div`,{className:`grid min-w-0 grid-cols-1 items-start gap-4 @3xl:grid-cols-2`,children:[C(`section`,{className:`flex min-w-0 flex-col gap-3 rounded-lg border border-po-border bg-po-panel p-4`,"aria-label":`Tokens by ${r}`,children:[C(`div`,{children:[C(`h3`,{className:`text-lg font-semibold text-po-hi`,children:[`Tokens by `,r]}),_(`p`,{className:`mt-1 text-sm text-po-dim`,children:`Largest recorded consumers. Select a named row to filter.`})]}),i>0?C(`div`,{className:`rounded-md border border-po-edge-yellow bg-po-tint-yellow p-3`,"data-testid":`metrics-attribution-notice`,children:[C(`p`,{className:`text-sm font-semibold text-po-yellow`,children:[r.charAt(0).toUpperCase()+r.slice(1),` attribution missing`]}),C(`p`,{className:`mt-1 text-sm leading-relaxed text-po-dim`,children:[I(i),` tokens have no `,r,` recorded. They are included in the total, but cannot be assigned to a named `,r,`.`]})]}):null,U[e.dimension]===void 0?null:_(`p`,{className:`text-sm leading-relaxed text-po-dim`,children:U[e.dimension]}),_(me,{groups:e.groups,totalTokens:e.totals.totalTokens,focus:e.focus,onFocus:t},`${e.dimension}:${e.focus??``}`),C(`p`,{className:`text-sm text-po-dim`,children:[`Showing `,e.groups.length,` of `,I(e.totals.groupCount),` `,r,` groups. Bars show share of the reported total.`]}),e.totals.failedGroups>0?C(`p`,{className:`text-sm text-po-yellow`,children:[e.totals.failedGroups,` of `,e.totals.groupCount,` `,r,`s failed`]}):null]}),_(we,{tools:e.tools})]}),_(Se,{tools:e.tools,focus:e.dimension===`session`?e.focus:void 0,count:e.totals.issueCount,startTime:e.startTime,endTime:e.endTime,broaderScope:e.focus!==void 0&&e.dimension!==`session`},`${e.generatedAt}:${e.dimension}:${e.focus??``}`),C(`footer`,{className:`flex flex-wrap justify-between gap-2 border-t border-po-border pt-3 text-sm text-po-dim`,"data-testid":`metrics-provenance`,children:[C(`span`,{children:[`Source: LogSink ·`,` `,e.transport===`http`?`HTTP`:e.transport===`worker`?`database worker`:`transport not reported`]}),C(`span`,{title:e.generatedAt,children:[`Report generated `,Number.isNaN(o.getTime())?e.generatedAt:o.toLocaleString()]})]})]})}var Ee={"no-sink":`no log sink`,"no-data":`nothing recorded yet`,"no-api":`metrics not installed`,"query-error":`metrics could not be loaded`};function De({response:e}){return _(ne,{title:Ee[e.unavailable],description:e.detail,"data-testid":`metrics-empty`})}function Oe({requested:e,applied:t,dimension:n,onClear:r}){return e===``?null:t===void 0?C(`span`,{className:`rounded-md border border-po-edge-yellow bg-po-tint-yellow p-3 text-sm text-po-yellow`,"data-testid":`metrics-focus-refused`,children:[`this log sink does not support narrowing by `,H[n],`, so the numbers below are still everything`,_(E,{variant:`ghost`,size:`md`,className:`ml-2`,onClick:r,children:`clear`})]}):C(`span`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-po-border bg-po-panel p-3 text-sm text-po-dim`,"data-testid":`metrics-focus`,children:[`narrowed to `,_(`span`,{className:`min-w-0 break-all text-po-hi`,children:t}),_(E,{variant:`ghost`,size:`md`,className:`ml-2`,onClick:r,children:`clear`})]})}function ke(){return C(`div`,{className:`flex flex-col gap-4`,role:`status`,"aria-live":`polite`,"data-testid":`metrics-loading`,children:[_(`span`,{className:`text-sm text-po-dim`,children:`Loading recorded metrics...`}),_(`div`,{"aria-hidden":`true`,className:`grid grid-cols-2 gap-3 @3xl:grid-cols-4`,children:[0,1,2,3].map(e=>_(`div`,{className:`h-24 animate-pulse rounded-lg border border-po-border bg-po-panel motion-reduce:animate-none`},e))}),_(`div`,{"aria-hidden":`true`,className:`h-48 animate-pulse rounded-lg border border-po-border bg-po-panel motion-reduce:animate-none`})]})}var Ae={day:`Past day`,week:`Past week`,month:`Past month`,all:`All history`};function je(t){let[n,r]=T(`model`),[i,a]=T(`week`),[s,c]=T(``),[u,d]=T(0),[f,p]=T(),h=JSON.stringify([n,i,s,u]);x(()=>{let e=new AbortController;return fe(n,i,s,e.signal).then(t=>{e.signal.aborted||p({key:h,result:t})}).catch(t=>{e.signal.aborted||p({key:h,result:{error:t instanceof Error?t.message:`Metrics could not be loaded.`}})}),()=>e.abort()},[n,i,s,h]);let g=f?.key===h?f.result:void 0,v=g===void 0,y=g!==void 0&&`report`in g?g.report:void 0,S=y===void 0||M(y)?void 0:y,w=g!==void 0&&`error`in g?g.error:``;return C(`div`,{className:`@container flex w-full min-w-0 flex-col gap-4`,"data-testid":`metrics-panel`,"aria-busy":v,children:[C(`div`,{className:`flex min-w-0 flex-wrap items-end gap-3 rounded-lg border border-po-border bg-po-panel p-3`,children:[C(`div`,{className:`flex flex-col gap-2`,children:[_(`span`,{className:`text-base font-medium text-po-text`,children:`Group by`}),C(o,{value:n,onValueChange:e=>{c(``),r(e)},children:[_(e,{"aria-label":`Group metrics by`,"data-testid":`metrics-dimension`,className:`w-40 `,children:_(m,{})}),_(l,{children:re.map(e=>_(A,{value:e,children:H[e]},e))})]})]}),C(`div`,{className:`flex flex-col gap-2`,children:[_(`span`,{className:`text-base font-medium text-po-text`,children:`Period`}),C(o,{value:i,onValueChange:e=>a(e),children:[_(e,{"aria-label":`Metrics period`,"data-testid":`metrics-period`,className:`w-40 `,children:_(m,{})}),_(l,{children:ie.map(e=>_(A,{value:e,children:Ae[e]},e))})]})]}),_(E,{variant:`outline`,size:`md`,className:`ml-auto`,onClick:()=>d(e=>e+1),disabled:v,"data-testid":`metrics-refresh`,children:v?`Loading...`:`Refresh`})]}),v?_(ke,{}):null,w===``?null:C(`p`,{role:`alert`,className:`rounded-lg border border-po-edge-red bg-po-tint-red p-4 text-sm text-po-red`,"data-testid":`metrics-error`,children:[w,` Use Refresh to try again.`]}),y!==void 0&&M(y)?_(De,{response:y}):null,S===void 0?null:C(b,{children:[_(Oe,{requested:s,applied:S.focus,dimension:S.dimension,onClear:()=>c(``)}),_(Te,{report:S,onFocus:c,onPeriodChange:a})]})]})}var Me=c({label:`metrics`,detail:`recorded usage, token attribution and issues`,icon:g,component:je});function Ne(e){return e.split(`
|
|
2
|
+
`).filter(Boolean)}var Pe=new Set([`tool_failure`,`infrastructure_failure`,`api_error`,`api_retries_exhausted`,`log_error`]),Fe=/[^.]*empty data[^.]*\.?/i,W=e=>typeof e==`object`&&!!e&&!Array.isArray(e),G=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0?e:void 0,K=e=>typeof e==`string`&&e.trim()!==``?e.trim():void 0;function Ie(e){return W(e)?Object.entries(e).flatMap(([e,t])=>{let n=G(t);return n!==void 0&&n>0&&e.trim()!==``?[{key:e,label:e.replaceAll(`_`,` `),count:n,failure:Pe.has(e)}]:[]}).sort((e,t)=>t.count-e.count):[]}function Le(e){return Array.isArray(e)?e.flatMap(e=>{if(!W(e))return[];let t=K(e.name);return t===void 0?[]:[{name:t,invocations:G(e.invocations),p90TurnTokens:G(e.p90TurnTokens)}]}):[]}function Re(e){let t;try{t=JSON.parse(e)}catch{return null}if(!W(t))return null;let n=W(t.usage)?t.usage:{},r={scope:K(t.scope),period:K(t.period),evidence:K(t.evidence),code:K(t.code),capturedRecords:G(t.capturedRecords),capturedIssues:G(t.capturedIssues),categories:Ie(t.issuesByCategory),inputTokens:G(n.inputTokens),outputTokens:G(n.outputTokens),tokenCoveragePercent:G(n.tokenCoveragePercent),tools:Le(t.tools),limitReached:typeof t.limitReached==`boolean`?t.limitReached:void 0,captureCompleteness:K(t.captureCompleteness),limitations:K(t.limitations)};return Object.values(r).some(e=>Array.isArray(e)?e.length>0:e!==void 0)?r:null}function q(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(Math.round(e))}var J=e=>e.replaceAll(/[-_]/g,` `);function ze(e){let t=[e.scope,e.period].flatMap(e=>e?[J(e)]:[]).join(` · `),n=e.capturedIssues,r=e.evidence===`unavailable`?`Telemetry unavailable`:e.evidence===`empty`?`Nothing captured`:n===void 0?`Captured agent evidence`:n===0?`No issues`:`${String(n)} ${n===1?`issue`:`issues`}`;return t===``?{primary:r}:{primary:r,context:t}}function Be(e){let t=[];if(e.capturedRecords!==void 0&&t.push({label:`Records`,value:e.capturedRecords.toLocaleString(`en-US`),failure:!1}),e.capturedIssues!==void 0){let n=e.capturedIssues>0&&e.categories.some(e=>e.failure);t.push({label:`Issues`,value:e.capturedIssues.toLocaleString(`en-US`),failure:n})}if(e.inputTokens!==void 0||e.outputTokens!==void 0){let n=e=>e===void 0?`?`:q(e);t.push({label:`Tokens in / out`,value:`${n(e.inputTokens)} / ${n(e.outputTokens)}`,failure:!1})}return e.tokenCoveragePercent!==void 0&&t.push({label:`Token coverage`,value:`${String(e.tokenCoveragePercent)}%`,failure:!1}),t}function Ve(e){let t=[e.captureCompleteness?`Capture completeness: ${J(e.captureCompleteness)}.`:void 0,e.limitations].filter(e=>e!==void 0);return t.length>0?t.join(` `):void 0}function He(e){return e.limitations?.match(Fe)?.[0].trim()??`Empty data is not proof of a healthy run.`}var Y=`Captured agent evidence`;function Ue({toolName:e,output:t,running:n,isError:r}){let i=a({running:n,isError:r}),o=n||r?null:Re(t);if(o)return _(We,{toolName:e,tone:i,report:o});let s=Ne(t);if(r)return C(k,{tone:i,children:[_(O,{title:e,children:_(`span`,{className:`min-w-0 truncate text-po-faint`,children:Y})}),s.length>0?_(v,{children:_(`p`,{className:`whitespace-pre-wrap break-words text-po-red`,children:s.join(`
|
|
3
|
+
`)})}):null]});let c=s.map(e=>({text:e,tone:`text`}));return _(k,{tone:i,expandable:c.length>12,children:({expanded:t})=>{let r=p(c,12,t);return C(b,{children:[_(O,{title:e,children:_(`span`,{className:`min-w-0 truncate text-po-faint`,children:Y})}),r.shown.length>0||n?C(v,{children:[_(D,{lines:r.shown}),r.hidden>0?C(u,{expands:!0,children:[r.hidden,` more lines`]}):null,n?_(u,{tone:`running`,children:`Reading session telemetry`}):null]}):null]})}})}function We({toolName:e,tone:t,report:n}){let r=ze(n),a=Be(n),o=Ve(n),s=n.evidence===`empty`,c=n.evidence===`unavailable`,l=He(n),u=s&&o===l?void 0:o,d=s||c?u!==void 0:n.categories.length>0||n.tools.length>0||o!==void 0;return _(k,{tone:c?`neutral`:t,expandable:d,children:({expanded:t})=>C(b,{children:[C(O,{title:e,children:[_(`span`,{className:`max-w-[60%] shrink-0 truncate text-po-text`,children:r.primary}),r.context?C(`span`,{className:`min-w-0 truncate text-po-faint`,children:[`· `,r.context]}):null]}),C(v,{className:`flex flex-col gap-4`,children:[c?C(`div`,{className:`flex flex-wrap items-center gap-2`,children:[_(`span`,{className:`text-po-dim`,children:`The session's telemetry could not be read.`}),n.code?_(ee,{size:`xs`,className:`font-mono`,children:n.code}):null]}):s?C(`div`,{className:`flex flex-col gap-1`,children:[_(`p`,{className:`text-po-text`,children:`No records were captured in this window.`}),_(`p`,{className:`text-sm text-po-dim`,children:l})]}):a.length>0?_(`dl`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:a.map(e=>C(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[_(`dt`,{className:`truncate text-sm text-po-dim`,children:e.label}),_(`dd`,{className:e.failure?`truncate text-lg font-semibold tabular-nums text-po-red`:`truncate text-lg font-semibold tabular-nums text-po-hi`,children:e.value})]},e.label))}):null,t&&!s&&!c&&n.categories.length>0?C(`section`,{className:`flex flex-col gap-2`,children:[_(i,{children:`Issues by category`}),_(`div`,{className:`flex flex-wrap gap-2`,children:n.categories.map(e=>C(h,{tone:e.failure?`red`:`neutral`,children:[_(`span`,{children:e.label}),_(`span`,{className:`font-semibold tabular-nums`,children:e.count})]},e.key))})]}):null,t&&!s&&!c&&n.tools.length>0?C(`section`,{className:`flex flex-col gap-2`,children:[_(i,{children:`Tools`}),C(`table`,{className:`w-full text-base`,children:[_(`thead`,{children:C(`tr`,{className:`text-sm text-po-dim`,children:[_(`th`,{className:`w-full pb-1 text-left font-normal`,children:`Name`}),_(`th`,{className:`whitespace-nowrap pb-1 pl-4 text-right font-normal`,children:`Calls`}),_(`th`,{className:`whitespace-nowrap pb-1 pl-4 text-right font-normal`,children:`p90 turn tokens`})]})}),_(`tbody`,{children:n.tools.map(e=>C(`tr`,{className:`border-t border-po-border-soft`,children:[_(`td`,{className:`max-w-0 truncate py-1 font-mono text-po-text`,children:e.name}),_(`td`,{className:`whitespace-nowrap py-1 pl-4 text-right tabular-nums text-po-text`,children:e.invocations===void 0?`?`:e.invocations.toLocaleString(`en-US`)}),_(`td`,{className:`whitespace-nowrap py-1 pl-4 text-right tabular-nums text-po-text`,children:e.p90TurnTokens===void 0?`?`:q(e.p90TurnTokens)})]},e.name))})]}),n.limitReached?C(`p`,{className:`text-sm text-po-dim`,children:[`Showing the first `,n.tools.length,` tools.`]}):null]}):null,t&&u?_(`p`,{className:`text-sm text-po-faint`,children:u}):null]})]})})}var Ge=s({tools:[`diagnose_agent`],message:Ue}),Ke=[`logsink_status`,`logsink_search`,`logsink_agent_issues`,`logsink_trace`,`logsink_stats`,`logsink_services`,`logsink_metrics`];function X(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function Z(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function qe(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=100}function Q(e){return typeof e==`string`&&/^\d{4}-\d{2}-\d{2}T/.test(e)&&Number.isFinite(Date.parse(e))}function Je(e){let t=X(e);if(!(!t||t.kind!==`session`&&t.kind!==`history`)&&(t.sessionId===void 0||typeof t.sessionId==`string`)&&(t.startTime===void 0||Q(t.startTime))&&(t.endTime===void 0||Q(t.endTime))&&(t.kind!==`history`||Q(t.startTime)&&Q(t.endTime))&&!(Q(t.startTime)&&Q(t.endTime)&&Date.parse(t.startTime)>Date.parse(t.endTime)))return[t.kind===`session`?`This session`:`History`,t.startTime,t.endTime,t.kind===`history`?t.sessionId:void 0].filter(Boolean).join(` · `)}function Ye(e){return Ke.some(t=>t===e)}function Xe({toolName:e,args:t,result:n,output:r,running:i,isError:a}){let o=n?.details;if(o==null)try{o=JSON.parse(r)}catch{o=void 0}let s=X(o),c=Je(s?.scope),l=t.scope===`history`?[`Requested history`,t.startTime,t.endTime,t.sessionId].filter(e=>typeof e==`string`).join(` · `):`This session`,u=o===void 0?r:JSON.stringify(o,null,2),d={scope:c??l,evidence:u};if(i)return{...d,scope:l,state:`running`,heading:`Reading captured agent evidence`,note:`Only retained records are inspected.`};if(a)return{...d,state:`query-error`,heading:`Log query could not be completed.`,note:`No collector changes were made.`};let f={...d,state:`unavailable`,heading:`Log summary is unavailable.`,note:`Inspect the retained evidence for details.`},p=X(s?.data);if(!c||!p)return f;let m={...d,state:`populated`,heading:``},h={...d,state:`empty`,heading:`No captured records in this window.`,note:`This does not establish that the run was healthy.`};switch(e){case`logsink_status`:return p.available===!1&&p.reason===`missing-database`?{...d,state:`missing`,heading:`No retained log database is available.`,note:`No collector changes were made.`}:p.available===!0?{...m,heading:`Retained log database is available.`,note:`This does not establish that the collector is capturing now.`}:f;case`logsink_search`:return!Z(p.count)||!Z(p.total)||typeof p.truncated!=`boolean`||!Array.isArray(p.results)?f:{...p.total===0?h:m,heading:p.total===0?h.heading:`Captured log records`,summary:`${p.count} returned · ${p.total} records`,note:p.truncated?`Results are truncated.`:p.total===0?h.note:void 0};case`logsink_agent_issues`:{if(!Z(p.matchingLogs)||!Z(p.uniqueIncidents)||!Z(p.scanned)||!qe(p.coveragePercent)||typeof p.truncated!=`boolean`||!Array.isArray(p.issues))return f;let e=X(p.byTool);return!e||!Object.values(e).every(Z)?f:{...p.matchingLogs===0?h:m,heading:p.matchingLogs===0?`No captured agent issues in this window.`:`Captured agent issues`,summary:`${p.matchingLogs} records · ${p.uniqueIncidents} incidents`,coverage:`Coverage ${p.coveragePercent}% · ${p.scanned} scanned${p.truncated?` · Scan truncated`:``}`,tools:Object.entries(e).map(([e,t])=>({name:e,count:t})),note:p.matchingLogs===0?h.note:`Repeated events may describe one incident.`}}case`logsink_trace`:return!Z(p.count)||typeof p.truncated!=`boolean`||!Array.isArray(p.timeline)?f:{...p.count===0?h:m,heading:p.count===0?h.heading:`Captured trace timeline`,summary:`${p.count} entries`,note:p.truncated?`Timeline is truncated.`:p.count===0?h.note:void 0};case`logsink_stats`:return!Z(p.totalEntries)||!Array.isArray(p.statistics)||!p.statistics.every(e=>{let t=X(e);return Z(t?.count)&&typeof t?.service==`string`&&typeof t?.level==`string`})?f:{...p.totalEntries===0?h:m,heading:p.totalEntries===0?h.heading:`Retained entry statistics`,summary:`${p.totalEntries} entries · ${p.statistics.length} group${p.statistics.length===1?``:`s`}`,tools:p.statistics.map(e=>{let t=e;return{name:[t.service,t.level].filter(Boolean).join(` · `),count:t.count}})};case`logsink_services`:return!Z(p.count)||typeof p.truncated!=`boolean`||!Array.isArray(p.services)||!p.services.every(e=>typeof e==`string`)?f:{...p.count===0?h:m,heading:p.count===0?h.heading:`Services with retained records`,summary:`${p.count} service${p.count===1?``:`s`}`,note:p.truncated?`Service list is truncated.`:p.count===0?h.note:void 0};case`logsink_metrics`:{let e=X(p.totals);return!e||!Z(e.totalRecords)||!Z(e.totalTokens)||!Z(e.issueCount)||!qe(e.tokenCoveragePercent)?f:{...e.totalRecords===0?h:m,heading:e.totalRecords===0?h.heading:`Captured usage and issues`,summary:`${e.totalRecords} records · ${e.totalTokens} tokens · ${e.issueCount} issues`,coverage:`Token coverage ${e.tokenCoveragePercent}%`,note:`${e.totalRecords===0?`${h.note} `:``}Tool turn costs are not exclusive per-tool token shares.`}}default:return f}}function Ze({toolName:e,running:t,isError:n,fixture:r,defaultExpanded:i=!1}){let o=r.state===`missing`,s=r.state===`unavailable`,c=r.evidence.split(`
|
|
4
|
+
`).map(e=>({text:e,tone:`text`}));return _(k,{tone:o||s?`neutral`:a({running:t,isError:n}),expandable:r.evidence.length>0,defaultExpanded:i,children:({expanded:i})=>C(b,{children:[_(O,{title:e,badge:n?`Query failed`:o?`No data`:void 0,children:_(`span`,{className:`truncate text-po-dim max-sm:hidden`,children:r.scope})}),C(v,{className:`flex flex-col gap-3`,children:[_(`p`,{className:`break-words text-sm text-po-dim sm:hidden`,children:r.scope}),C(`div`,{className:`flex flex-col gap-1`,children:[_(`p`,{className:`text-base font-semibold text-po-hi`,children:r.heading}),r.summary?_(`p`,{className:`text-base text-po-text`,children:r.summary}):null,r.coverage?_(`p`,{className:`text-sm text-po-dim`,children:r.coverage}):null]}),r.tools?_(`div`,{className:`flex flex-col gap-2 border-t border-po-border-soft pt-3`,children:r.tools.map(e=>C(`p`,{className:`flex flex-wrap items-center gap-4 text-base`,children:[_(`span`,{className:`font-mono text-po-text`,children:e.name}),C(`span`,{className:`text-po-dim`,children:[e.count,` occurrences`]})]},e.name))}):null,r.note?_(`p`,{className:`text-sm text-po-dim`,children:r.note}):null,t?_(u,{tone:`running`,children:`Reading telemetry`}):null,r.evidence?C(`div`,{className:`flex flex-col gap-3 border-t border-po-border-soft pt-3`,children:[_(u,{expands:!0,glyph:i?`⌄`:`›`,className:`text-sm text-po-dim`,children:i?`Hide evidence`:`Show evidence`}),i?_(D,{lines:c}):null]}):null]})]})})}function Qe(e){return _(Ze,{...e,fixture:Xe(e)})}var $e=s({tools:[`logsink_status`,`logsink_search`,`logsink_agent_issues`,`logsink_trace`,`logsink_stats`,`logsink_services`,`logsink_metrics`],matches:Ye,message:Qe}),$=(e,t)=>t===void 0?void 0:{...e,...t},et=t({id:`log`,global:{get settingsPanels(){return[$({id:`metrics`},Me)]}},session:{get toolRenderers(){return[$({tools:[`diagnose_agent`]},Ge),$({tools:[`logsink`]},$e)]}}});export{et as webPlugin};
|