1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5405],{24911:(e,s,t)=>{t.d(s,{W:()=>h});var n=t(95155),r=t(12115),l=t(27529),a=t(13364),i=t(40980),o=t(86846);let d="bg-foreground/75",u="bg-foreground/25";function c(e,s){return new Date(`${e}T00:00:00Z`).toLocaleDateString("en-AU",{timeZone:"UTC",...s})}function m(e){return(e.managed_credits??0)+(e.compute_credits??0)}function h({agentId:e,basePath:s=`/api/agents/${e}`,className:t}){let[x,p]=(0,r.useState)(null),[f,g]=(0,r.useState)(!1),[j,b]=(0,r.useState)(null);if((0,r.useEffect)(()=>{let e=!1;return(0,l.nr)(`${s}/spend`).then(s=>!e&&p(s)).catch(()=>!e&&g(!0)),()=>{e=!0}},[s]),f)return null;if(!x)return(0,n.jsxs)("div",{className:(0,i.cn)("mt-6 border-t pt-5",t),"aria-hidden":"true",children:[(0,n.jsx)(o.E,{className:"h-3 w-40"}),(0,n.jsx)(o.E,{className:"mt-4 h-24 w-full"})]});let v=x.days,y=Math.max(0,...v.map(m)),w=v.reduce((e,s)=>e+m(s),0),N=y>0?v.find(e=>m(e)===y):void 0,$=x.compute_billed&&v.some(e=>(e.managed_credits??0)>0)&&v.some(e=>(e.compute_credits??0)>0),k=v.some(e=>null===e.managed_credits),C=v.length-1;return(0,n.jsxs)("div",{className:(0,i.cn)("mt-6 border-t pt-5",t),children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[(0,n.jsx)("h3",{className:"text-sm font-medium",children:"Last 14 days"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground tabular-nums",children:w>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"text-foreground",children:(0,a.rh)(w)})," credits",N&&(0,n.jsxs)(n.Fragment,{children:[" \xb7 busiest ",c(N.date,{weekday:"short",day:"numeric",month:"short"})]})]}):"No spend in the last 14 days"})]}),(0,n.jsxs)("div",{className:"relative mt-4",children:[(0,n.jsx)("div",{className:"flex h-28 items-end gap-1 sm:gap-1.5",role:"list","aria-label":"Credits used per day",children:v.map((e,s)=>{let t=m(e),r=y>0?t/y*100:0,l=e.managed_credits??0,o=e.compute_credits??0,h=`${c(e.date,{weekday:"long",day:"numeric",month:"long"})}${s===C?" (so far)":""}: ${(0,a.rh)(t)} credits, ${e.replies} ${1===e.replies?"reply":"replies"}`;return(0,n.jsx)("button",{type:"button",role:"listitem","aria-label":h,onPointerEnter:()=>b(s),onPointerLeave:()=>b(null),onFocus:()=>b(s),onBlur:()=>b(null),className:"group/bar relative flex h-full min-w-0 flex-1 flex-col items-center justify-end rounded-sm outline-none focus-visible:ring-2 focus-visible:ring-ring",children:t>0?(0,n.jsxs)("span",{className:(0,i.cn)("flex w-full max-w-8 flex-col gap-[2px] overflow-hidden rounded-t-[4px] transition-[height,opacity] duration-500 ease-out",null!==j&&j!==s&&"opacity-50"),style:{height:`max(${r}%, 3px)`},children:[l>0&&(0,n.jsx)("span",{className:(0,i.cn)("w-full",d),style:{flexGrow:l}}),o>0&&(0,n.jsx)("span",{className:(0,i.cn)("w-full",u),style:{flexGrow:o}})]}):(0,n.jsx)("span",{className:"h-px w-full max-w-8 bg-border"})},e.date)})}),null!==j&&(0,n.jsxs)("div",{className:"pointer-events-none absolute bottom-full z-10 mb-2 whitespace-nowrap rounded-md border bg-popover px-2.5 py-1.5 text-xs text-popover-foreground shadow-md",style:{left:`${(j+.5)/v.length*100}%`,transform:`translateX(${j<3?"-15%":j>v.length-4?"-85%":"-50%"})`},children:[(0,n.jsxs)("div",{className:"text-muted-foreground",children:[c(v[j].date,{weekday:"short",day:"numeric",month:"short"}),j===C&&" \xb7 so far"]}),(0,n.jsxs)("div",{className:"mt-0.5 font-medium tabular-nums",children:[(0,a.rh)(m(v[j]))," credits"]}),$&&(0,n.jsxs)("div",{className:"mt-0.5 space-y-0.5 tabular-nums text-muted-foreground",children:[(0,n.jsxs)("div",{children:["Replies & tools ",(0,a.rh)(v[j].managed_credits??0)]}),(0,n.jsxs)("div",{children:["Compute ",(0,a.rh)(v[j].compute_credits??0)]})]}),(0,n.jsxs)("div",{className:"mt-0.5 tabular-nums text-muted-foreground",children:[v[j].replies," ",1===v[j].replies?"reply":"replies"]})]}),(0,n.jsxs)("div",{className:"mt-2 flex justify-between text-[11px] text-muted-foreground tabular-nums",children:[(0,n.jsx)("span",{children:c(v[0].date,{day:"numeric",month:"short"})}),(0,n.jsx)("span",{children:c(v[Math.floor(C/2)].date,{day:"numeric",month:"short"})}),(0,n.jsx)("span",{children:"Today"})]})]}),($||k)&&(0,n.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[$&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("span",{className:(0,i.cn)("h-2 w-2 rounded-[2px]",d),"aria-hidden":"true"}),"Replies & tools"]}),(0,n.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,n.jsx)("span",{className:(0,i.cn)("h-2 w-2 rounded-[2px]",u),"aria-hidden":"true"}),"Compute"]})]}
1),k&&(0,n.jsx)("span",{children:"Some days' reply spend isn't available yet."})]})]})}},30227:(e,s,t)=>{t.d(s,{u:()=>c});var n=t(95155),r=t(12115),l=t(20986),a=t(27529),i=t(40980),o=t(89239),d=t(86846);let u=[{hours:1,label:"1h"},{hours:24,label:"24h"},{hours:168,label:"7d"}];function c({agentId:e,basePath:s=`/api/agents/${e}`}){let[t,u]=(0,r.useState)(24),[x,p]=(0,r.useState)(null),[f,g]=(0,r.useState)(!1),[j,b]=(0,r.useState)(!0),v=(0,r.useCallback)(async e=>{try{let t=await (0,a.nr)(`${s}/health?hours=${e}`);p(t),g(!1)}catch{g(!0)}finally{b(!1)}},[s]);(0,r.useEffect)(()=>{b(!0),v(t);let e=()=>"visible"===document.visibilityState&&void v(t),s=setInterval(e,6e4);return document.addEventListener("visibilitychange",e),()=>{clearInterval(s),document.removeEventListener("visibilitychange",e)}},[t,v]);let y=x?.health??null,w=y?[y.restart_count>0?`${y.restart_count} ${1===y.restart_count?"restart":"restarts"}`:null,y.exit_code?`last exit ${y.exit_code}`:null].filter(Boolean):[],N=x?.metrics??null,$=!!N&&N.cpu.every(([,e])=>null===e)&&N.memory.every(([,e])=>null===e);return(0,n.jsxs)("section",{className:"rounded-lg border bg-card p-6","aria-busy":j,children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,n.jsxs)("div",{className:"min-w-0",children:[(0,n.jsx)("h2",{className:"text-base font-semibold",children:"Compute usage"}),(0,n.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:w.length?w.join(" \xb7 "):y?"No restarts. Readings update every minute.":"How hard this agent is working, read every minute."})]}),(0,n.jsx)(m,{value:t,onChange:u})]}),(0,n.jsx)("div",{className:"mt-5",children:j&&!x?(0,n.jsx)("div",{className:"grid gap-4 lg:grid-cols-3",children:Array.from({length:3}).map((e,s)=>(0,n.jsxs)("div",{className:"rounded-md border p-4",children:[(0,n.jsx)(d.E,{className:"h-3 w-14"}),(0,n.jsx)(d.E,{className:"mt-2 h-6 w-24"}),(0,n.jsx)(d.E,{className:"mt-3 h-16 w-full"})]},s))}):N?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:(0,i.cn)("grid gap-4 lg:grid-cols-3",j&&"opacity-60 transition-opacity"),children:[(0,n.jsx)(h,{label:"CPU",points:N.cpu,limit:N.limits.cpu,hours:x.hours,format:e=>`${e<10?e.toFixed(2):e.toFixed(1)}`,unit:"vCPU"}),(0,n.jsx)(h,{label:"Memory",points:N.memory,limit:N.limits.memory,hours:x.hours,format:e=>e.toFixed(e<10?2:1),unit:"GB"}),(0,n.jsx)(h,{label:"Disk",points:N.disk,limit:N.limits.disk,hours:x.hours,format:e=>e.toFixed(e<10?2:1),unit:"GB"})]}),(0,n.jsxs)("p",{className:"mt-3 flex items-center gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:"inline-block h-2.5 w-4 rounded-[2px] bg-muted","aria-hidden":"true"}),$?"Asleep for this whole window. CPU and memory come back when it wakes; disk keeps reporting.":"Shaded stretches are when the agent was asleep or stopped."]})]}):(0,n.jsxs)("div",{className:"flex flex-col items-start gap-3 rounded-md border border-dashed p-5 text-sm text-muted-foreground sm:flex-row sm:items-center sm:justify-between",children:[(0,n.jsx)("span",{children:f?"Couldn't load compute readings.":"Readings are catching up. Try again in a minute."}),(0,n.jsxs)(o.$,{size:"sm",variant:"outline",onClick:()=>void v(t),children:[(0,n.jsx)(l.A,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Retry"]})]})})]})}function m({value:e,onChange:s}){return(0,n.jsx)("div",{role:"radiogroup","aria-label":"Time range",className:"inline-flex shrink-0 rounded-md border bg-muted/40 p-0.5",children:u.map(t=>{let r=t.hours===e;return(0,n.jsx)("button",{type:"button",role:"radio","aria-checked":r,onClick:()=>s(t.hours),className:(0,i.cn)("rounded-[5px] px-2.5 py-1 text-xs font-medium tabular-nums transition-[background-color,color,box-shadow] duration-150 ease-out","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",r?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:t.label},t.hours)})})}function h({label:e,points:s,limit:t,hours:l,format:a,unit:o}){var d;let u,c,[m,x]=(0,r.useState)(null),p=(0,r.useId)(),f=(0,r.useMemo)(()=>[...s].reverse().find(([,e])=>null!==e)?.[1]??null,[s]),g=Math.max(t,(0,r.useMemo)(()=>s.reduce((e,[,s])=>null!==s&&s>e?s:e,0),[s]))||1,j=s.length,b=e=>j<=1?0:e/(j-1)*300,v=e=>8+(1-e/g)*64,{line:y,area:w,gaps:N}=(0,r.useMemo)(()=>{let e="",t="",n=[],r=null,l=null;
1return s.forEach(([,s],a)=>{if(null===s){null!==r&&(t+=`L${b(a-1)},72Z`,r=null),null===l&&(l=a);return}null!==l&&(n.push([l,a]),l=null),null===r?(r=a,e+=`M${b(a)},${v(s)}`,t+=`M${b(a)},72L${b(a)},${v(s)}`):(e+=`L${b(a)},${v(s)}`,t+=`L${b(a)},${v(s)}`)}),null!==r&&(t+=`L${b(j-1)},72Z`),null!==l&&n.push([l,j]),{line:e,area:t,gaps:n}},[s,g]),$=null!==f&&t>0?Math.round(f/t*100):null,k=null!==m?s[m]:null;return(0,n.jsxs)("div",{className:"rounded-md border p-4",children:[(0,n.jsxs)("div",{className:"flex items-center justify-between gap-2 text-xs text-muted-foreground",children:[(0,n.jsx)("span",{className:"flex items-center gap-1.5",children:e}),k?(0,n.jsx)("span",{className:"tabular-nums text-foreground",children:(d=k[0],c=(u=new Date(1e3*d)).toLocaleTimeString("en-AU",{hour:"numeric",minute:"2-digit"}),l>24?`${u.toLocaleDateString("en-AU",{weekday:"short",day:"numeric"})}, ${c}`:c)}):null!==$&&(0,n.jsxs)("span",{className:"tabular-nums",children:[$,"% of limit"]})]}),(0,n.jsxs)("div",{className:"mt-1 flex items-baseline gap-1.5",children:[(0,n.jsx)("span",{className:"text-xl font-semibold tracking-tight tabular-nums",children:k?null===k[1]?"Asleep":a(k[1]):null===f?"â":a(f)}),(0,n.jsxs)("span",{className:(0,i.cn)("text-xs text-muted-foreground tabular-nums",k&&null===k[1]&&"invisible"),children:[o,t>0&&` of ${Number.isInteger(t)?t:a(t)}`]})]}),(0,n.jsxs)("div",{className:"relative mt-3",children:[(0,n.jsxs)("svg",{viewBox:"0 0 300 72",preserveAspectRatio:"none",className:"block h-[72px] w-full touch-none text-brand-ink outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card rounded-sm",role:"img","aria-label":`${e} over the last ${168===l?"7 days":`${l} hour${1===l?"":"s"}`}: now ${null===f?"no reading":`${a(f)} ${o}`}${t>0?` of ${a(t)} ${o}`:""}`,tabIndex:0,onPointerMove:e=>{var s;let t,n;return s=e.clientX,n=Math.round((s-(t=e.currentTarget.getBoundingClientRect()).left)/t.width*(j-1)),void x(Math.max(0,Math.min(j-1,n)))},onPointerLeave:()=>x(null),onBlur:()=>x(null),onKeyDown:e=>{("ArrowLeft"===e.key||"ArrowRight"===e.key)&&(e.preventDefault(),x(s=>Math.max(0,Math.min(j-1,(s??j-1)+("ArrowRight"===e.key?1:-1)))))},children:[(0,n.jsxs)("defs",{children:[(0,n.jsxs)("linearGradient",{id:`${p}-fade`,x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,n.jsx)("stop",{offset:"0%",stopColor:"currentColor",stopOpacity:.2}),(0,n.jsx)("stop",{offset:"100%",stopColor:"currentColor",stopOpacity:0})]}),(0,n.jsx)("clipPath",{id:p,children:(0,n.jsx)("rect",{x:"0",y:"0",width:300,height:72})})]}),(0,n.jsxs)("g",{clipPath:`url(#${p})`,children:[N.map(([e,s])=>(0,n.jsx)("rect",{x:b(Math.max(0,e-.5)),y:0,width:Math.max(1,b(Math.min(j-1,s-.5))-b(Math.max(0,e-.5))
1),height:72,className:"fill-muted"},e)),t>0&&(0,n.jsx)("line",{x1:0,x2:300,y1:v(t),y2:v(t),className:"stroke-muted-foreground/50",strokeDasharray:"3 3",vectorEffect:"non-scaling-stroke"}),(0,n.jsx)("path",{d:w,fill:`url(#${p}-fade)`}),(0,n.jsx)("path",{d:y,fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"}),null!==m&&(0,n.jsx)("line",{x1:b(m),x2:b(m),y1:0,y2:72,className:"stroke-foreground/30",vectorEffect:"non-scaling-stroke"})]})]}),null!==m&&k&&(0,n.jsx)(n.Fragment,{children:null!==k[1]&&(0,n.jsx)("span",{className:"pointer-events-none absolute h-2 w-2 -translate-x-1/2 -translate-y-1/2 rounded-full bg-foreground ring-2 ring-card",style:{left:`${b(m)/300*100}%`,top:`${v(k[1])/72*100}%`}})})]})]})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.