agent-session-inspector 0.1.7 → 0.1.9
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/VERSION +1 -1
- package/app/.next/BUILD_ID +1 -1
- package/app/.next/app-path-routes-manifest.json +1 -0
- package/app/.next/build-manifest.json +3 -3
- package/app/.next/prerender-manifest.json +3 -3
- package/app/.next/required-server-files.json +1 -1
- package/app/.next/routes-manifest.json +9 -0
- package/app/.next/server/app/_global-error.html +1 -1
- package/app/.next/server/app/_global-error.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/app/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/app/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/app/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/_not-found.html +1 -1
- package/app/.next/server/app/_not-found.rsc +14 -14
- package/app/.next/server/app/_not-found.segments/_full.segment.rsc +14 -14
- package/app/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +13 -13
- package/app/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/api/analytics/route.js +2 -1
- package/app/.next/server/app/api/analytics/route.js.nft.json +1 -1
- package/app/.next/server/app/api/logs/route.js +2 -1
- package/app/.next/server/app/api/logs/route.js.nft.json +1 -1
- package/app/.next/server/app/api/pricing/route.js +2 -1
- package/app/.next/server/app/api/pricing/route.js.nft.json +1 -1
- package/app/.next/server/app/api/providers/route.js +2 -1
- package/app/.next/server/app/api/providers/route.js.nft.json +1 -1
- package/app/.next/server/app/api/search/route.js +3 -2
- package/app/.next/server/app/api/search/route.js.nft.json +1 -1
- package/app/.next/server/app/api/sessions/[provider]/[id]/record/route/app-paths-manifest.json +3 -0
- package/app/.next/server/app/api/sessions/[provider]/[id]/record/route/build-manifest.json +12 -0
- package/app/.next/server/app/api/sessions/[provider]/[id]/record/route/server-reference-manifest.json +4 -0
- package/app/.next/server/app/api/sessions/[provider]/[id]/record/route.js +8 -0
- package/app/.next/server/app/api/sessions/[provider]/[id]/record/route.js.map +5 -0
- package/app/.next/server/app/api/sessions/[provider]/[id]/record/route.js.nft.json +1 -0
- package/app/.next/server/app/api/sessions/[provider]/[id]/record/route_client-reference-manifest.js +3 -0
- package/app/.next/server/app/api/sessions/[provider]/[id]/reveal/route.js +2 -1
- package/app/.next/server/app/api/sessions/[provider]/[id]/reveal/route.js.nft.json +1 -1
- package/app/.next/server/app/api/sessions/[provider]/[id]/route.js +2 -1
- package/app/.next/server/app/api/sessions/[provider]/[id]/route.js.nft.json +1 -1
- package/app/.next/server/app/api/sessions/route.js +2 -1
- package/app/.next/server/app/api/sessions/route.js.nft.json +1 -1
- package/app/.next/server/app/index.html +1 -1
- package/app/.next/server/app/index.rsc +16 -16
- package/app/.next/server/app/index.segments/__PAGE__.segment.rsc +15 -15
- package/app/.next/server/app/index.segments/_full.segment.rsc +16 -16
- package/app/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/app/.next/server/app/page.js.nft.json +1 -1
- package/app/.next/server/app/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app/sessions/[provider]/[id]/page.js.nft.json +1 -1
- package/app/.next/server/app/sessions/[provider]/[id]/page_client-reference-manifest.js +1 -1
- package/app/.next/server/app-paths-manifest.json +1 -0
- package/app/.next/server/chunks/1oeh_server_app_api_sessions_[provider]_[id]_record_route_actions_13lvgh0.js +3 -0
- package/app/.next/server/chunks/[externals]__0xll52b._.js +3 -0
- package/app/.next/server/chunks/[root-of-the-server]__014br-h._.js +3 -0
- package/app/.next/server/chunks/[root-of-the-server]__03bee2l._.js +3 -0
- package/app/.next/server/chunks/[root-of-the-server]__093lyxv._.js +3 -0
- package/app/.next/server/chunks/[root-of-the-server]__0co499t._.js +3 -0
- package/app/.next/server/chunks/[root-of-the-server]__0ne74op._.js +3 -0
- package/app/.next/server/chunks/[root-of-the-server]__0p_hyq8._.js +3 -0
- package/app/.next/server/chunks/[root-of-the-server]__0ryrg2h._.js +3 -0
- package/app/.next/server/chunks/[root-of-the-server]__0uv5tnc._.js +3 -0
- package/app/.next/server/chunks/[root-of-the-server]__0yxic1z._.js +3 -3
- package/app/.next/server/chunks/[root-of-the-server]__1lfc-ga._.js +3 -0
- package/app/.next/server/chunks/[root-of-the-server]__1n_sepq._.js +3 -0
- package/app/.next/server/chunks/ssr/_0f8nmc3._.js +1 -1
- package/app/.next/server/chunks/ssr/_0o294sf._.js +1 -1
- package/app/.next/server/chunks/ssr/_0wfo2z0._.js +1 -1
- package/app/.next/server/chunks/ssr/src_app_sessions_[provider]_[id]_page_tsx_0uf635h._.js +3 -3
- package/app/.next/server/middleware-build-manifest.js +3 -3
- package/app/.next/server/pages/404.html +1 -1
- package/app/.next/server/pages/500.html +1 -1
- package/app/.next/server/server-reference-manifest.js +1 -1
- package/app/.next/server/server-reference-manifest.json +1 -1
- package/app/.next/static/chunks/{33valh9_p24ah.js → 0f_9fwik8mxzl.js} +1 -1
- package/app/.next/static/chunks/{1fe2mxakoweia.js → 18c6__lhilfeo.js} +1 -1
- package/app/.next/static/chunks/28k1og85stfuo.js +6 -0
- package/app/.next/static/chunks/3-49ck9kf466m.css +1 -0
- package/app/package.json +1 -1
- package/app/scripts/demo-data.mjs +3 -1
- package/app/server.js +1 -1
- package/cli/cli.mjs +351 -126
- package/package.json +1 -1
- package/app/.next/server/chunks/[root-of-the-server]__0dyq0rc._.js +0 -3
- package/app/.next/server/chunks/[root-of-the-server]__0kgkqhn._.js +0 -3
- package/app/.next/server/chunks/[root-of-the-server]__10p8y9z._.js +0 -3
- package/app/.next/server/chunks/[root-of-the-server]__1cceere._.js +0 -3
- package/app/.next/server/chunks/[root-of-the-server]__1eclfq8._.js +0 -3
- package/app/.next/server/chunks/[root-of-the-server]__1lz20wm._.js +0 -3
- package/app/.next/server/chunks/[root-of-the-server]__1zdh1mi._.js +0 -3
- package/app/.next/server/chunks/[root-of-the-server]__20epvou._.js +0 -3
- package/app/.next/static/chunks/0slbmtcht4v2w.css +0 -1
- package/app/.next/static/chunks/279fmcw99x0e9.js +0 -6
- /package/app/.next/static/{ji6govOHS2spXukBPOyFL → 7UozMfIH3Lk8P6-UWWQXF}/_buildManifest.js +0 -0
- /package/app/.next/static/{ji6govOHS2spXukBPOyFL → 7UozMfIH3Lk8P6-UWWQXF}/_clientMiddlewareManifest.js +0 -0
- /package/app/.next/static/{ji6govOHS2spXukBPOyFL → 7UozMfIH3Lk8P6-UWWQXF}/_ssgManifest.js +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
module.exports=[75136,a=>{"use strict";var b=a.i(38742),c=a.i(73895),d=a.i(24687),e=a.i(37303),f=a.i(70627);let g=(0,f.default)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),h=(0,f.default)("bookmark",[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]]),i=(0,f.default)("circle-dollar-sign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]),j=(0,f.default)("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]),k=(0,f.default)("file-pen",[["path",{d:"M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34",key:"o6klzx"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z",key:"zhnas1"}]]);var l=a.i(35789);let m=(0,f.default)("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]),n=(0,f.default)("lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);var o=a.i(22598),p=a.i(99570),q=a.i(75083),r=a.i(69876),s=a.i(64151),t=a.i(19608),u=a.i(59561),v=a.i(27936),w=a.i(31049),x=a.i(35540),y=a.i(34597);let z=(0,f.default)("arrow-up-right",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]),A=(0,f.default)("arrow-down-narrow-wide",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h4",key:"6d7r33"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h10",key:"1438ji"}]]),B=(0,f.default)("arrow-up-narrow-wide",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]]),C=(0,f.default)("braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);var D=a.i(12650),D=D,E=a.i(80995);let F=(0,f.default)("chevrons-down-up",[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]),G=(0,f.default)("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]),H=(0,f.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),I=(0,f.default)("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]);var J=a.i(89560);let K=(0,f.default)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),L=(0,f.default)("list-filter",[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]),M=(0,f.default)("radio",[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]),N=(0,f.default)("search-x",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),O=(0,f.default)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]);var P=a.i(61055),Q=a.i(86304),R=a.i(73221),S=a.i(85259),T=a.i(96538),U=a.i(16543),V=a.i(45646);function W(a){let b=[],c=[],d=new Map,e=new Map,f=new Map,g=0,h=0,i=0,j=0,k=null;for(let l of a){if(!0===l.data.inherited){"number"==typeof l.data.costUSD&&(i+=l.data.costUSD);continue}if("user.message"===l.type){j+=1,k={turn:j,prompt:"string"==typeof l.data.content?l.data.content:void 0,eventId:l.id,timestamp:l.timestamp,costUSD:0,requests:0,lines:[],totalUSD:h,compacted:!1},b.push(k),d.set(l.id,k),e.set(l.id,j);continue}k&&e.set(l.id,k.turn),k&&l.type.startsWith("session.compaction")&&(k.compacted=!0);let a=l.data.costUSD,m="number"==typeof a&&a>0,n=Array.isArray(l.data.costLines)?l.data.costLines:[];if(m||k){for(let a of(k||(k={turn:0,eventId:l.id,timestamp:l.timestamp,costUSD:0,requests:0,lines:[],totalUSD:h,compacted:!1},b.push(k)),n))!function(a,b){let c=a.find(a=>a.model===b.model&&a.kind===b.kind&&a.rate===b.rate);c?(c.tokens+=b.tokens,null!==c.usd&&null!==b.usd&&(c.usd+=b.usd)):a.push({...b})}(k.lines,a);n.length>0&&c.push(function(a,b,c,d,e){let f=(...a)=>b.reduce((b,c)=>a.includes(c.kind)?b+c.tokens:b,0),g=(...a)=>b.reduce((b,c)=>a.includes(c.kind)&&null!==c.usd?(b??0)+c.usd:b,null),h=f("input"),i=f("cacheWrite","cacheWrite1h"),j=f("cacheRead");return{n:c,turn:d,eventId:a.id,timestamp:a.timestamp,models:[...new Set(b.map(a=>a.model))],inputTokens:h,cacheWriteTokens:i,cacheReadTokens:j,outputTokens:f("output"),contextTokens:h+i+j,usd:{input:g("input"),cacheWrite:g("cacheWrite","cacheWrite1h"),cacheRead:g("cacheRead"),output:g("output")},costUSD:e}}(l,n,c.length+1,k.turn,m?a:null)),m&&(h+=a,k.costUSD+=a,k.requests+=1,k.totalUSD=h,f.set(l.id,h),g=Math.max(g,a))}}let l=b.findIndex(a=>a.costUSD>0);return{turns:-1===l?[]:b.slice(l),requests:c,turnByPrompt:d,turnOf:e,runningUSD:f,maxEventUSD:g,totalUSD:h,inheritedUSD:i}}var X=a.i(90075),Y=a.i(3541),Z=a.i(87105),$=a.i(68114);let _={"session.start":{label:"Session Start",dotCls:"bg-emerald-100 border-emerald-400 dark:bg-emerald-900/60 dark:border-emerald-700",typeCls:"text-emerald-700 dark:text-emerald-400"},"session.shutdown":{label:"Session Shutdown",dotCls:"bg-red-100 border-red-400 dark:bg-red-900/60 dark:border-red-700",typeCls:"text-red-700 dark:text-red-400"},"session.resume":{label:"Session Resume",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"user.message":{label:"User Message",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"assistant.message":{label:"Assistant",dotCls:"bg-sky-100 border-sky-400 dark:bg-sky-900/60 dark:border-sky-700",typeCls:"text-sky-700 dark:text-sky-400"},"assistant.turn_start":{label:"Turn Start",dotCls:"bg-cyan-100 border-cyan-400 dark:bg-cyan-900/60 dark:border-cyan-700",typeCls:"text-cyan-700 dark:text-cyan-400"},"assistant.turn_end":{label:"Turn End",dotCls:"bg-cyan-100 border-cyan-400 dark:bg-cyan-900/60 dark:border-cyan-700",typeCls:"text-cyan-700 dark:text-cyan-400"},"tool.execution_start":{label:"Tool Start",dotCls:"bg-amber-100 border-amber-400 dark:bg-amber-900/60 dark:border-amber-700",typeCls:"text-amber-700 dark:text-amber-400"},"tool.execution_complete":{label:"Tool Done",dotCls:"bg-amber-100 border-amber-400 dark:bg-amber-900/60 dark:border-amber-700",typeCls:"text-amber-700 dark:text-amber-400"},"external_tool.requested":{label:"External Tool Request",dotCls:"bg-lime-100 border-lime-400 dark:bg-lime-900/60 dark:border-lime-700",typeCls:"text-lime-700 dark:text-lime-400"},"external_tool.completed":{label:"External Tool Done",dotCls:"bg-lime-100 border-lime-400 dark:bg-lime-900/60 dark:border-lime-700",typeCls:"text-lime-700 dark:text-lime-400"},"permission.requested":{label:"Permission",dotCls:"bg-orange-100 border-orange-400 dark:bg-orange-900/60 dark:border-orange-700",typeCls:"text-orange-700 dark:text-orange-400"},"permission.completed":{label:"Permission Done",dotCls:"bg-orange-100 border-orange-400 dark:bg-orange-900/60 dark:border-orange-700",typeCls:"text-orange-700 dark:text-orange-400"},"hook.start":{label:"Hook Start",dotCls:"bg-cyan-100 border-cyan-400 dark:bg-cyan-900/60 dark:border-cyan-700",typeCls:"text-cyan-700 dark:text-cyan-400"},"hook.end":{label:"Hook End",dotCls:"bg-cyan-100 border-cyan-400 dark:bg-cyan-900/60 dark:border-cyan-700",typeCls:"text-cyan-700 dark:text-cyan-400"},"session.auto_mode_resolved":{label:"Auto Mode",dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400"},"session.binary_asset":{label:"Binary Asset",dotCls:"bg-rose-100 border-rose-400 dark:bg-rose-900/60 dark:border-rose-700",typeCls:"text-rose-700 dark:text-rose-400"},"session.usage_checkpoint":{label:"Usage Checkpoint",dotCls:"bg-teal-100 border-teal-400 dark:bg-teal-900/60 dark:border-teal-700",typeCls:"text-teal-700 dark:text-teal-400"},"subagent.deselected":{label:"Subagent Deselected",dotCls:"bg-slate-100 border-slate-400 dark:bg-slate-900/60 dark:border-slate-700",typeCls:"text-slate-700 dark:text-slate-400"},"session.model_change":{label:"Model Change",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"session.compaction_start":{label:"Compaction Start",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"session.compaction_complete":{label:"Compaction Complete",dotCls:"bg-purple-100 border-purple-400 dark:bg-purple-900/60 dark:border-purple-700",typeCls:"text-purple-700 dark:text-purple-400"},"system.message":{label:"System",dotCls:"bg-slate-100 border-slate-400 dark:bg-slate-900/60 dark:border-slate-700",typeCls:"text-slate-700 dark:text-slate-400"},"assistant.thinking":{label:"Thinking",dotCls:"bg-indigo-100 border-indigo-400 dark:bg-indigo-900/60 dark:border-indigo-700",typeCls:"text-indigo-700 dark:text-indigo-400"},"session.error":{label:"Error",dotCls:"bg-red-100 border-red-400 dark:bg-red-900/60 dark:border-red-700",typeCls:"text-red-700 dark:text-red-400"},"context.attachment":{label:"Attachment",dotCls:"bg-stone-100 border-stone-400 dark:bg-stone-900/60 dark:border-stone-700",typeCls:"text-stone-700 dark:text-stone-400"},"file.patch_applied":{label:"Patch Applied",dotCls:"bg-emerald-100 border-emerald-400 dark:bg-emerald-900/60 dark:border-emerald-700",typeCls:"text-emerald-700 dark:text-emerald-400"},"web.search":{label:"Web Search",dotCls:"bg-blue-100 border-blue-400 dark:bg-blue-900/60 dark:border-blue-700",typeCls:"text-blue-700 dark:text-blue-400"},"session.turn_context":{label:"Turn Context",dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400"},"session.world_state":{label:"World State",dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400"},"session.mode_change":{label:"Mode Change",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"session.turn_aborted":{label:"Turn Aborted",dotCls:"bg-orange-100 border-orange-400 dark:bg-orange-900/60 dark:border-orange-700",typeCls:"text-orange-700 dark:text-orange-400"},"session.rollback":{label:"Rollback",dotCls:"bg-orange-100 border-orange-400 dark:bg-orange-900/60 dark:border-orange-700",typeCls:"text-orange-700 dark:text-orange-400"},"subagent.activity":{label:"Subagent",dotCls:"bg-zinc-100 border-zinc-400 dark:bg-zinc-900/60 dark:border-zinc-700",typeCls:"text-zinc-700 dark:text-zinc-400"},"session.plan_changed":{label:"Plan Changed",dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400"},"system.notification":{label:"Notification",dotCls:"bg-slate-100 border-slate-400 dark:bg-slate-900/60 dark:border-slate-700",typeCls:"text-slate-700 dark:text-slate-400"},"subagent.session_start":{label:"Subagent Start",dotCls:"bg-zinc-100 border-zinc-400 dark:bg-zinc-900/60 dark:border-zinc-700",typeCls:"text-zinc-700 dark:text-zinc-400"},"subagent.message":{label:"Subagent Message",dotCls:"bg-zinc-100 border-zinc-400 dark:bg-zinc-900/60 dark:border-zinc-700",typeCls:"text-zinc-700 dark:text-zinc-400"}},aa={label:"Event",dotCls:"bg-muted border-border",typeCls:"text-muted-foreground",chipCls:"border-border bg-muted text-muted-foreground"},ab={session:{dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400",chipCls:"border-fuchsia-300 bg-fuchsia-100 text-fuchsia-800 dark:border-fuchsia-800 dark:bg-fuchsia-900/50 dark:text-fuchsia-300"},user:{dotCls:"bg-pink-100 border-pink-400 dark:bg-pink-900/60 dark:border-pink-700",typeCls:"text-pink-700 dark:text-pink-400",chipCls:"border-pink-300 bg-pink-100 text-pink-800 dark:border-pink-800 dark:bg-pink-900/50 dark:text-pink-300"},assistant:{dotCls:"bg-sky-100 border-sky-400 dark:bg-sky-900/60 dark:border-sky-700",typeCls:"text-sky-700 dark:text-sky-400",chipCls:"border-sky-300 bg-sky-100 text-sky-800 dark:border-sky-800 dark:bg-sky-900/50 dark:text-sky-300"},tool:{dotCls:"bg-amber-100 border-amber-400 dark:bg-amber-900/60 dark:border-amber-700",typeCls:"text-amber-700 dark:text-amber-400",chipCls:"border-amber-300 bg-amber-100 text-amber-800 dark:border-amber-800 dark:bg-amber-900/50 dark:text-amber-300"},external_tool:{dotCls:"bg-lime-100 border-lime-400 dark:bg-lime-900/60 dark:border-lime-700",typeCls:"text-lime-700 dark:text-lime-400",chipCls:"border-lime-300 bg-lime-100 text-lime-800 dark:border-lime-800 dark:bg-lime-900/50 dark:text-lime-300"},permission:{dotCls:"bg-red-100 border-red-400 dark:bg-red-900/60 dark:border-red-700",typeCls:"text-red-700 dark:text-red-400",chipCls:"border-red-300 bg-red-100 text-red-800 dark:border-red-800 dark:bg-red-900/50 dark:text-red-300"},hook:{dotCls:"bg-teal-100 border-teal-400 dark:bg-teal-900/60 dark:border-teal-700",typeCls:"text-teal-700 dark:text-teal-400",chipCls:"border-teal-300 bg-teal-100 text-teal-800 dark:border-teal-800 dark:bg-teal-900/50 dark:text-teal-300"},system:{dotCls:"bg-slate-100 border-slate-400 dark:bg-slate-900/60 dark:border-slate-700",typeCls:"text-slate-700 dark:text-slate-400",chipCls:"border-slate-300 bg-slate-100 text-slate-800 dark:border-slate-700 dark:bg-slate-900/60 dark:text-slate-300"},subagent:{dotCls:"bg-zinc-100 border-zinc-400 dark:bg-zinc-900/60 dark:border-zinc-700",typeCls:"text-zinc-700 dark:text-zinc-400",chipCls:"border-zinc-300 bg-zinc-100 text-zinc-800 dark:border-zinc-700 dark:bg-zinc-900/60 dark:text-zinc-300"},context:{dotCls:"bg-stone-100 border-stone-400 dark:bg-stone-900/60 dark:border-stone-700",typeCls:"text-stone-700 dark:text-stone-400",chipCls:"border-stone-300 bg-stone-100 text-stone-800 dark:border-stone-700 dark:bg-stone-900/60 dark:text-stone-300"},file:{dotCls:"bg-emerald-100 border-emerald-400 dark:bg-emerald-900/60 dark:border-emerald-700",typeCls:"text-emerald-700 dark:text-emerald-400",chipCls:"border-emerald-300 bg-emerald-100 text-emerald-800 dark:border-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-300"},web:{dotCls:"bg-blue-100 border-blue-400 dark:bg-blue-900/60 dark:border-blue-700",typeCls:"text-blue-700 dark:text-blue-400",chipCls:"border-blue-300 bg-blue-100 text-blue-800 dark:border-blue-800 dark:bg-blue-900/50 dark:text-blue-300"}},ac={"session.start":"Session initialization event. Captures the runtime context and selected model when a session begins.","session.resume":"Session resumed from previous state. Indicates context reload and continuation.","session.shutdown":"Session end summary. Usually includes usage, token totals, premium requests, and API timing.","session.auto_mode_resolved":"Auto-mode model selection result. Shows predicted task profile and chosen model settings.","session.binary_asset":"Binary payload captured in the session (typically screenshots/images). Can consume significant context/storage.","session.usage_checkpoint":"Interim usage accounting snapshot (AIU/premium usage/cache state) while session is active.","session.model_change":"Model configuration switched during the session (model/effort/context tier).","session.compaction_start":"Context compaction started. Conversation is being summarized/compressed to reduce token load.","session.compaction_complete":"Compaction finished, with success/failure metadata and request identifiers.","user.message":"User input message that drives the next assistant turn.","assistant.message":"Assistant output message, optionally with model/tool-request and token metadata.","assistant.turn_start":"Start of a single assistant reasoning/execution turn.","assistant.turn_end":"End of the assistant turn after reasoning/tools/output.","tool.execution_start":"A local tool invocation started with tool name and arguments.","tool.execution_complete":"A local tool invocation completed with status and result payload.","external_tool.requested":"Request sent to an external tool bridge/service.","external_tool.completed":"External tool request lifecycle completed.","permission.requested":"Runtime requested user permission for an action (e.g., file/system/network).","permission.completed":"Permission flow resolved (approved/denied).","hook.start":"Lifecycle hook execution started (for example, prompt submission hooks).","hook.end":"Lifecycle hook execution completed with success/failure state.","subagent.deselected":"Subagent focus was cleared and control returned to the main agent context.","system.message":"System-level instruction/context block injected into the conversation runtime.","assistant.thinking":"Extended reasoning the model produced before answering. Billed as output tokens.","session.error":"API or transport error. Each retry re-sends the full request context.","context.attachment":"Context the runtime injected automatically: file snapshots, reminders, tool or skill listings.","file.patch_applied":"A patch the agent applied to the workspace, with the files it touched.","web.search":"Web search issued by the model; results are added to the conversation context.","session.turn_context":"Per-turn runtime configuration: model, effort, sandbox and approval policy.","session.world_state":"Snapshot of the workspace the runtime handed to the model.","session.mode_change":"Interaction or permission mode switched during the session.","session.turn_aborted":"The turn was interrupted before it completed.","session.rollback":"Conversation was rolled back by a number of turns.","subagent.activity":"Activity reported by a subagent working under the main agent.","subagent.message":"Message passed between agents.","subagent.session_start":"A subagent thread started inside this session.","session.plan_changed":"The agent created or updated its working plan.","system.notification":"Runtime notification injected into the conversation, such as a background shell finishing."};function ad(a){return new Date(a).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ae(a){return new Date(a).toLocaleDateString([],{weekday:"long",year:"numeric",month:"long",day:"numeric"})}function af(a,b){return new Date(b).getTime()-new Date(a).getTime()}function ag(a){let[b,...c]=a.split(".");return{category:b||"unknown",subCategory:c.join(".")||"general"}}function ah(a){return!!a&&!1===a.data.success&&(aX.has(a.type)||"file.patch_applied"===a.type)}function ai(a){return a>=1e6?`${(a/1e6).toFixed(2)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:a.toLocaleString()}function aj({data:a}){let d=a.content||"",[e,f]=(0,c.useState)(!1),g=d.slice(0,300),h=d.length>300;return(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:[e?d:g,h&&!e&&"..."]}),h&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>f(!e),className:"h-auto px-0 font-normal text-violet-600 dark:text-violet-400 mt-1",children:e?"Show less":`Show more (${d.length} chars)`})]})}function ak({data:a}){let d=a.content||"",e=a.toolRequests||[],f=a.model,g=a.outputTokens,[h,i]=(0,c.useState)(!1),j=d.slice(0,400),k=d.length>400;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[f&&(0,b.jsx)(Q.Badge,{variant:"secondary",className:"text-xs font-mono",children:f}),void 0!==g&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-violet-100 border border-violet-300 dark:bg-violet-950 dark:border-violet-800 rounded-full text-xs text-violet-700 dark:text-violet-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:"out"}),(0,b.jsx)("span",{className:"font-semibold font-mono",children:g.toLocaleString()}),(0,b.jsx)("span",{className:"opacity-60",children:"tokens"})]})]}),d&&(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:[h?d:j,k&&!h&&"..."]}),k&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>i(!h),className:"h-auto px-0 font-normal text-sky-600 dark:text-sky-400 mt-1",children:h?"Show less":`Show more (${d.length} chars)`})]}),e.length>0&&(0,b.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map((a,c)=>(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-amber-100 border border-amber-300 dark:bg-amber-900/50 dark:border-amber-800 rounded-sm text-xs text-amber-800 dark:text-amber-300 font-mono",children:["🔧 ",a.name]},c))})]})}function al({data:a,type:d}){let e=a.toolName,f=a.arguments,g=a.result,h=a.success,[i,j]=(0,c.useState)(!1),[k,l]=(0,c.useState)(!1);return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"font-mono text-amber-700 dark:text-amber-300 font-semibold",children:e}),"tool.execution_complete"===d&&(0,b.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded-sm font-medium ${h?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/60 dark:text-emerald-400":"bg-red-100 text-red-700 dark:bg-red-900/60 dark:text-red-400"}`,children:h?"success":"failed"})]}),f&&Object.keys(f).length>0&&(0,b.jsxs)("div",{children:[(0,b.jsxs)(p.Button,{variant:"link",size:"xs",onClick:()=>j(!i),className:"h-auto px-0 font-normal text-amber-600 dark:text-amber-500",children:[i?"▼":"▶"," Arguments"]}),i&&(0,b.jsx)("pre",{className:"mt-1 p-2 bg-muted rounded-sm text-xs text-foreground overflow-auto max-h-48 font-mono border border-border",children:JSON.stringify(f,null,2)})]}),g&&(0,b.jsxs)("div",{children:[(0,b.jsxs)(p.Button,{variant:"link",size:"xs",onClick:()=>l(!k),className:"h-auto px-0 font-normal text-amber-600 dark:text-amber-500",children:[k?"▼":"▶"," Result"]}),k&&(0,b.jsx)("pre",{className:"mt-1 p-2 bg-muted rounded-sm text-xs text-foreground overflow-auto max-h-48 font-mono border border-border",children:JSON.stringify(g,null,2)})]})]})}function am({data:a}){let c=a.tokenDetails,d=a.totalApiDurationMs,e=a.totalPremiumRequests,f=a.shutdownType,g=c?.input?.tokenCount,h=c?.output?.tokenCount,i=c?.cache_read?.tokenCount;return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[f&&(0,b.jsx)(Q.Badge,{variant:"outline",className:"text-xs",children:f}),void 0!==e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,b.jsx)("span",{className:"font-semibold text-foreground",children:e})," premium req"]}),void 0!==d&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,b.jsxs)("span",{className:"font-semibold text-foreground",children:[(d/1e3).toFixed(1),"s"]})," API"]})]}),(void 0!==g||void 0!==h)&&(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[void 0!==g&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-cyan-100 border border-cyan-300 dark:bg-cyan-950 dark:border-cyan-800 rounded-full text-xs text-cyan-700 dark:text-cyan-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:"in"}),(0,b.jsx)("span",{className:"font-semibold font-mono",children:g.toLocaleString()})]}),void 0!==h&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-violet-100 border border-violet-300 dark:bg-violet-950 dark:border-violet-800 rounded-full text-xs text-violet-700 dark:text-violet-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:"out"}),(0,b.jsx)("span",{className:"font-semibold font-mono",children:h.toLocaleString()})]}),void 0!==i&&i>0&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-teal-100 border border-teal-300 dark:bg-teal-950 dark:border-teal-800 rounded-full text-xs text-teal-700 dark:text-teal-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:"cache"}),(0,b.jsx)("span",{className:"font-semibold font-mono",children:i.toLocaleString()})]})]})]})}function an({data:a}){let d=a.role,e=a.interactionId,f=a.content||"",[g,h]=(0,c.useState)(!1),i=f.slice(0,420),j=f.length>420;return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[d&&(0,b.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs border border-slate-300 bg-slate-100 text-slate-700 dark:border-slate-700 dark:bg-slate-900/60 dark:text-slate-300 font-mono",children:d}),e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground font-mono",children:["interaction: ",e]})]}),(0,b.jsxs)("div",{className:"rounded-md border border-slate-200/80 dark:border-slate-800/80 bg-background/70 px-3 py-2",children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"System Prompt"}),(0,b.jsxs)("pre",{className:"text-xs text-foreground whitespace-pre-wrap break-words leading-relaxed overflow-auto max-h-72 font-mono",children:[g?f:i,j&&!g&&"..."]})]}),j&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>h(!g),className:"h-auto px-0 font-normal text-slate-700 dark:text-slate-300",children:g?"Show less":`Show full system prompt (${f.length.toLocaleString()} chars)`})]})}function ao({data:a,type:d}){let e=a.hookType,f=a.hookInvocationId,g=a.success,h=a.input,i=h?.prompt,[j,k]=(0,c.useState)(!1),l=(i||"").slice(0,300),m=(i||"").length>300;return(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[e&&(0,b.jsx)(Q.Badge,{variant:"secondary",className:"text-xs font-mono",children:e}),"hook.end"===d&&void 0!==g&&(0,b.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded-sm font-medium border ${g?"bg-emerald-100 text-emerald-700 border-emerald-300 dark:bg-emerald-900/50 dark:text-emerald-300 dark:border-emerald-800":"bg-red-100 text-red-700 border-red-300 dark:bg-red-900/50 dark:text-red-300 dark:border-red-800"}`,children:g?"success":"failed"}),f&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:f})]}),"hook.start"===d&&i&&(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"Prompt Preview"}),(0,b.jsxs)("pre",{className:"text-xs text-foreground whitespace-pre-wrap break-words leading-relaxed overflow-auto max-h-44 font-mono",children:[j?i:l,m&&!j&&"..."]}),m&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>k(!j),className:"h-auto px-0 font-normal text-cyan-700 dark:text-cyan-300 mt-1",children:j?"Show less":`Show more (${i.length.toLocaleString()} chars)`})]})]})}function ap({data:a}){let c=a.chosenModel,d=a.reasoningBucket,e=a.predictedLabel,f=a.confidence,g=a.candidateModels||[],h=a.categoryScores;return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[c&&(0,b.jsx)(Q.Badge,{className:"text-xs font-mono bg-fuchsia-100 text-fuchsia-800 border border-fuchsia-300 dark:bg-fuchsia-900/50 dark:text-fuchsia-300 dark:border-fuchsia-800",children:c}),d&&(0,b.jsxs)(Q.Badge,{variant:"outline",className:"text-xs font-mono",children:["reasoning: ",d]}),e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["label: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:e})]}),"number"==typeof f&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["confidence: ",(0,b.jsxs)("span",{className:"font-mono text-foreground",children:[Math.round(100*f),"%"]})]})]}),g.length>0&&(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"Candidate Models"}),(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5",children:g.slice(0,8).map((a,c)=>(0,b.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-sm border border-fuchsia-300 bg-fuchsia-100/70 text-fuchsia-800 dark:border-fuchsia-800 dark:bg-fuchsia-900/40 dark:text-fuchsia-300 text-xs font-mono",children:String(a)},c))})]}),h&&Object.keys(h).length>0&&(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"Category Scores"}),(0,b.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1.5",children:Object.entries(h).slice(0,6).map(([a,c])=>(0,b.jsxs)("div",{className:"text-xs border border-fuchsia-200 bg-fuchsia-50/70 dark:border-fuchsia-900/80 dark:bg-fuchsia-950/25 rounded-sm px-2 py-1 flex items-center justify-between gap-2",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:a}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:String(c)})]},a))})]})]})}function aq({data:a,type:d}){let e=a.requestId,f=a.toolName,g=a.toolCallId,h=a.workingDirectory,i=a.arguments,[j,k]=(0,c.useState)(!1);return(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,b.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs border font-medium ${"external_tool.requested"===d?"bg-lime-100 text-lime-800 border-lime-300 dark:bg-lime-900/60 dark:text-lime-300 dark:border-lime-800":"bg-emerald-100 text-emerald-700 border-emerald-300 dark:bg-emerald-900/60 dark:text-emerald-300 dark:border-emerald-800"}`,children:"external_tool.requested"===d?"requested":"completed"}),f&&(0,b.jsx)(Q.Badge,{variant:"secondary",className:"text-xs font-mono",children:f}),g&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:g})]}),e&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono",children:["request: ",e]}),"external_tool.requested"===d&&h&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:["cwd: ",(0,b.jsx)("span",{className:"font-mono text-foreground break-all",children:h})]}),"external_tool.requested"===d&&i&&Object.keys(i).length>0&&(0,b.jsxs)("div",{children:[(0,b.jsxs)(p.Button,{variant:"link",size:"xs",onClick:()=>k(!j),className:"h-auto px-0 font-normal text-lime-700 dark:text-lime-400",children:[j?"▼":"▶"," Arguments"]}),j&&(0,b.jsx)("pre",{className:"mt-1 p-2 bg-background/70 rounded-sm text-xs text-foreground overflow-auto max-h-40 font-mono border border-lime-200 dark:border-lime-800 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:JSON.stringify(i,null,2)})]})]})}function ar({data:a}){let c=a.assetId,d=a.type,e=a.mimeType,f=a.byteLength,g=a.data;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[d&&(0,b.jsx)(Q.Badge,{variant:"secondary",className:"text-xs font-mono",children:d}),e&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:e})]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1.5 text-xs",children:[void 0!==f&&(0,b.jsxs)("div",{className:"rounded-sm border border-rose-200 dark:border-rose-900 px-2 py-1 bg-rose-100/60 dark:bg-rose-950/25",children:["size: ",(0,b.jsxs)("span",{className:"font-mono text-foreground",children:[f.toLocaleString()," bytes"]})]}),g&&(0,b.jsxs)("div",{className:"rounded-sm border border-rose-200 dark:border-rose-900 px-2 py-1 bg-rose-100/60 dark:bg-rose-950/25",children:["payload: ",(0,b.jsxs)("span",{className:"font-mono text-foreground",children:[g.length.toLocaleString()," chars"]})]})]}),c&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono break-all",children:["asset: ",c]})]})}function as({data:a}){let c=a.usage,d=a.contextWindow,e=a.totalNanoAiu,f=a.totalPremiumRequests,g=a.modelCacheState,h="number"==typeof e?e/1e9:void 0;return(0,b.jsxs)("div",{className:"space-y-2",children:[c&&(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[[["in",c.inputTokens],["cached",c.cachedInputTokens],["out",c.outputTokens],["reasoning",c.reasoningTokens]].filter(([,a])=>"number"==typeof a&&a>0).map(([a,c])=>(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border border-teal-300 bg-teal-100 px-2 py-0.5 text-teal-700 dark:border-teal-800 dark:bg-teal-950 dark:text-teal-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:a}),(0,b.jsx)("span",{className:"font-mono font-semibold",children:ai(c)})]},a)),d&&(0,b.jsxs)("span",{className:"text-muted-foreground",children:["window ",ai(d)]})]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1.5 text-xs",children:[void 0!==h&&(0,b.jsxs)("div",{className:"rounded-sm border border-teal-200 dark:border-teal-900 px-2 py-1 bg-teal-100/60 dark:bg-teal-950/25",children:["total AIU: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:ai(h)})]}),void 0!==f&&(0,b.jsxs)("div",{className:"rounded-sm border border-teal-200 dark:border-teal-900 px-2 py-1 bg-teal-100/60 dark:bg-teal-950/25",children:["premium req: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:f})]})]}),g&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:["cache state entries: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:g.length})]})]})}function at({data:a}){let c=a.previousModel,d=a.newModel,e=a.reasoningEffort,f=a.contextTier;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"text-sm text-foreground",children:[(0,b.jsx)("span",{className:"font-mono",children:c||"unknown"}),(0,b.jsx)("span",{className:"mx-2 text-muted-foreground",children:"→"}),(0,b.jsx)("span",{className:"font-mono font-semibold",children:d||"unknown"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap text-xs",children:[(0,b.jsxs)("span",{className:"px-2 py-0.5 rounded-sm border border-violet-200 dark:border-violet-900 bg-violet-100/60 dark:bg-violet-950/25 text-muted-foreground",children:["effort: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:e??"default"})]}),(0,b.jsxs)("span",{className:"px-2 py-0.5 rounded-sm border border-violet-200 dark:border-violet-900 bg-violet-100/60 dark:bg-violet-950/25 text-muted-foreground",children:["context: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:f??"default"})]})]})]})}function au({data:a}){let c=a.model,d=a.systemTokens,e=a.conversationTokens,f=a.toolDefinitionsTokens,g=[d,e,f].filter(a=>"number"==typeof a).reduce((a,b)=>a+b,0);return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[c&&(0,b.jsx)(Q.Badge,{variant:"secondary",className:"text-xs font-mono",children:c}),g>0&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["total: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:ai(g)})," tokens"]})]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-1.5 text-xs",children:[void 0!==d&&(0,b.jsxs)("div",{className:"rounded-sm border border-violet-200 dark:border-violet-900 px-2 py-1 bg-violet-100/60 dark:bg-violet-950/25",children:["system: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:ai(d)})]}),void 0!==e&&(0,b.jsxs)("div",{className:"rounded-sm border border-violet-200 dark:border-violet-900 px-2 py-1 bg-violet-100/60 dark:bg-violet-950/25",children:["convo: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:ai(e)})]}),void 0!==f&&(0,b.jsxs)("div",{className:"rounded-sm border border-violet-200 dark:border-violet-900 px-2 py-1 bg-violet-100/60 dark:bg-violet-950/25",children:["tools: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:ai(f)})]})]})]})}function av({data:a}){let c=a.success,d=a.error,e=a.statusCode,f=a.requestId,g=a.serviceRequestId;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,b.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs border font-medium ${c?"bg-emerald-100 text-emerald-700 border-emerald-300 dark:bg-emerald-900/50 dark:text-emerald-300 dark:border-emerald-800":"bg-red-100 text-red-700 border-red-300 dark:bg-red-900/50 dark:text-red-300 dark:border-red-800"}`,children:c?"success":"failed"}),void 0!==e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["status: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:e})]})]}),d&&(0,b.jsx)("div",{className:"text-xs text-red-700 dark:text-red-300 bg-red-100/70 dark:bg-red-950/30 border border-red-200 dark:border-red-900 rounded-sm px-2 py-1.5 font-mono whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:d}),f&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono break-all",children:["requestId: ",f]}),g&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono break-all",children:["serviceRequestId: ",g]})]})}function aw(){return(0,b.jsx)("div",{className:"text-xs text-muted-foreground",children:"Active subagent context was cleared and focus returned to the main agent."})}function ax({data:a,type:c}){let d=a.model,e=a.turnId,f=a.interactionId;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,b.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs border font-medium ${"assistant.turn_start"===c?"bg-emerald-100 text-emerald-700 border-emerald-300 dark:bg-emerald-900/50 dark:text-emerald-300 dark:border-emerald-800":"bg-slate-100 text-slate-700 border-slate-300 dark:bg-slate-900/60 dark:text-slate-300 dark:border-slate-700"}`,children:"assistant.turn_start"===c?"turn started":"turn finished"}),void 0!==e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["turn: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:String(e)})]}),d&&(0,b.jsx)(Q.Badge,{variant:"secondary",className:"text-xs font-mono",children:d})]}),f&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono",children:["interaction: ",f]})]})}function ay({data:a}){let d=a.content||"",e=a.charLength??d.length,[f,g]=(0,c.useState)(!1),h=d.slice(0,400),i=d.length>400;return d?(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsxs)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:["Reasoning · ",e.toLocaleString()," chars"]}),(0,b.jsxs)("div",{className:"text-sm italic leading-relaxed text-muted-foreground whitespace-pre-wrap",children:[f?d:h,i&&!f&&"…"]}),i&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>g(!f),className:"h-auto px-0 font-normal text-indigo-600 dark:text-indigo-400",children:f?"Show less":`Show more (${e.toLocaleString()} chars)`})]}):(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Reasoning was recorded but its content is encrypted in the transcript."})}function az({data:a}){let c=a.message||"Error",d=a.detail;return(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("p",{className:"text-sm font-medium text-destructive",children:c}),d&&d!==c&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d})]})}function aA({items:a,label:d}){let[e,f]=(0,c.useState)(!1);if(0===a.length)return null;let g=e?a:a.slice(0,12);return(0,b.jsxs)("div",{className:"space-y-1",children:[d&&(0,b.jsxs)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:[a.length," ",d]}),(0,b.jsxs)("div",{className:"flex flex-wrap gap-1",children:[g.map(a=>(0,b.jsx)("span",{className:"max-w-full truncate rounded-sm border border-border bg-muted/60 px-1.5 py-0.5 font-mono text-[11px] text-foreground/80",title:a,children:a},a)),!e&&a.length>g.length&&(0,b.jsxs)(p.Button,{variant:"ghost",size:"xs",onClick:()=>f(!0),className:"text-[11px] font-normal text-muted-foreground",children:["+",a.length-g.length," more"]})]})]})}function aB({text:a,charLength:d,limit:e=400,mono:f=!0,accentCls:g="text-muted-foreground"}){let[h,i]=(0,c.useState)(!1);if(!a)return null;let j=a.length>e,k=d??a.length;return(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("pre",{className:(0,$.cn)("max-h-72 overflow-auto whitespace-pre-wrap break-words text-xs leading-relaxed text-foreground/80",f&&"font-mono"),children:[h?a:a.slice(0,e),!h&&j&&"…"]}),j&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>i(!h),className:(0,$.cn)("h-auto px-0 font-normal",g),children:h?"Show less":`Show more (${k.toLocaleString()} chars)`})]})}function aC({data:a}){let c=a.attachmentType||"attachment",d=a.label||c,e=a.subject,f=a.items??[],g=a.itemsLabel,h=a.charLength??0,i=a.content||"";return(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)(Q.Badge,{variant:"secondary",className:"text-xs",children:d}),(0,b.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:c}),h>0&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["~",Math.round(h/4).toLocaleString()," tokens"]})]}),e&&(0,b.jsx)("p",{className:"break-all font-mono text-xs text-foreground/80",children:e}),(0,b.jsx)(aA,{items:f,label:g}),(0,b.jsx)(aB,{text:i,charLength:h,accentCls:"text-stone-600 dark:text-stone-400"})]})}function aD({data:a}){let c=a.success,d=a.changes||[],e=a.stdout||"";return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)("span",{className:`rounded-sm px-1.5 py-0.5 text-xs font-medium ${!1===c?"bg-red-100 text-red-700 dark:bg-red-900/60 dark:text-red-400":"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/60 dark:text-emerald-400"}`,children:!1===c?"failed":"applied"}),(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:[d.length," file",1===d.length?"":"s"]})]}),d.length>0&&(0,b.jsx)("ul",{className:"space-y-1",children:d.slice(0,12).map(a=>(0,b.jsxs)("li",{className:"flex items-center gap-2 text-xs",children:[(0,b.jsx)("span",{className:"rounded-sm border border-emerald-300 bg-emerald-100/70 px-1 font-mono text-[10px] uppercase text-emerald-800 dark:border-emerald-800 dark:bg-emerald-900/40 dark:text-emerald-300",children:a.type}),(0,b.jsx)("span",{className:"truncate font-mono text-foreground/80",title:a.file,children:a.file})]},a.file))}),e&&(0,b.jsx)("pre",{className:"max-h-32 overflow-auto whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:e})]})}function aE({data:a}){let c=a.query||"",d=a.resultCount;return(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("p",{className:"text-sm text-foreground",children:c}),void 0!==d&&(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:[d," result",1===d?"":"s"," returned"]})]})}function aF({facts:a}){let c=a.filter(([,a])=>null!=a&&""!==a);return 0===c.length?null:(0,b.jsx)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:c.map(([a,c])=>(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-sm border border-border bg-muted/40 px-2 py-1 text-xs",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:a}),(0,b.jsx)("span",{className:"min-w-0 truncate font-mono text-foreground",title:String(c),children:String(c)})]},a))})}function aG({data:a}){let c=a.mode||"unknown";return(0,b.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Mode set to"}),(0,b.jsx)(Q.Badge,{variant:"secondary",className:"font-mono",children:c})]})}function aH({data:a}){let c=a.sandboxPolicy,d=a.approvalPolicy,e=c?.writable_roots??[];return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(aF,{facts:[["model",a.model],["effort",a.effort],["personality",a.personality],["sandbox",c?.type],["network",c?.network_access===!0?"enabled":"restricted"],["approval",d?Object.keys(d)[0]:void 0],["cwd",a.cwd]]}),e.length>0&&(0,b.jsx)(aA,{items:e,label:"writable roots"})]})}function aI({data:a}){let c=a.sections??[],d=a.content||"",e=a.charLength??0;return(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsx)(aF,{facts:[["cwd",a.cwd],["shell",a.shell],["date",a.currentDate],["timezone",a.timezone],["snapshot",!0===a.full?"full":"delta"],["size",e?`${e.toLocaleString()} chars`:void 0]]}),(0,b.jsx)(aA,{items:c,label:"state sections"}),(0,b.jsx)(aB,{text:d,charLength:e})]})}function aJ({data:a,type:c}){return"subagent.session_start"===c?(0,b.jsx)(aF,{facts:[["agent",a.agentNickname],["path",a.agentPath],["thread",a.sessionId],["parent",a.parentThreadId],["cwd",a.cwd]]}):"subagent.activity"===c?(0,b.jsx)(aF,{facts:[["activity",a.kind],["path",a.agentPath],["thread",a.agentThreadId]]}):(0,b.jsx)(aO,{data:a})}function aK({data:a}){let c=a.durationMs;return(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,b.jsx)("span",{className:"rounded-sm bg-orange-100 px-1.5 py-0.5 font-medium text-orange-800 dark:bg-orange-900/60 dark:text-orange-300",children:a.reason??"aborted"}),void 0!==c&&(0,b.jsxs)("span",{className:"text-muted-foreground",children:["after"," ",(0,b.jsxs)("span",{className:"font-mono text-foreground",children:[(c/1e3).toFixed(1),"s"]})]}),void 0!==a.turnId&&(0,b.jsxs)("span",{className:"font-mono text-muted-foreground",children:["turn ",String(a.turnId)]})]})}function aL({data:a}){let c=a.turns;return(0,b.jsxs)("p",{className:"text-sm text-foreground",children:["Conversation rolled back"," ",(0,b.jsx)("span",{className:"font-semibold",children:c??"?"})," turn",1===c?"":"s","."]})}function aM({data:a}){return(0,b.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Plan"}),(0,b.jsx)(Q.Badge,{variant:"secondary",className:"font-mono",children:a.operation??"changed"})]})}function aN({data:a}){let c=a.kind,d=a.content||"";return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(aF,{facts:[["kind",c?.type],["shell",c?.shellId],["exit code",c?.exitCode],["description",c?.description]]}),(0,b.jsx)(aB,{text:d,mono:!1})]})}function aO({data:a}){let[d,e]=(0,c.useState)(!1),f=JSON.stringify(a,null,2),g=f.slice(0,300),h=f.length>300;return(0,b.jsxs)("div",{children:[(0,b.jsxs)("pre",{className:"text-xs text-muted-foreground font-mono whitespace-pre-wrap",children:[d?f:g,h&&!d&&"..."]}),h&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>e(!d),className:"h-auto px-0 font-normal text-muted-foreground hover:text-foreground mt-1",children:d?"Collapse":"Expand"})]})}function aP(a,b=150){let c=String(a??"").replace(/\s+/g," ").trim();return c.length>b?`${c.slice(0,b)}…`:c}function aQ(a){if(!a)return"";for(let b of["command","cmd","input","script","filePath","file_path","notebook_path","path","pattern","query","description","url","prompt"])if(a[b])return`${b}: ${aP(a[b],90)}`;return Object.keys(a).length?aP(JSON.stringify(a),90):"(no args)"}let aR=a=>"string"==typeof a&&a.length>0?a.replace(/\n$/,"").split("\n").length:0,aS=new Set(["user.message","assistant.message","assistant.thinking"]);function aT({event:a,prevTimestamp:d,expandAll:e,parallel:f=!1,target:g=!1,merged:h=!1,result:i,runningUSD:j,costShare:k=0,turn:l}){let m,n,o,q,r,t,u=_[a.type]||aa,v=d?af(d,a.timestamp):null,[w,x]=(0,c.useState)(!1),[y,z]=(0,c.useState)(!1),[A,B]=(0,c.useState)({nonce:0,open:aS.has(a.type)||g}),D=e&&e.nonce!==A.nonce?"open"===e.mode:A.open,F=function(a){let b=a.data,c=_[a.type]?.label??ag(a.type).subCategory;switch(a.type){case"user.message":return{label:"User",preview:aP(b.content)};case"assistant.message":{let a=b.toolRequests??[],c=aP(b.content);if(c)return{label:"Assistant",preview:c};if(a.length)return{label:"Assistant",preview:`requests ${a.map(a=>a.name).filter(Boolean).join(", ")}`};return{label:"Assistant",preview:"(no text)"}}case"assistant.turn_start":case"assistant.turn_end":{let c=b.turnId;return{label:"assistant.turn_start"===a.type?"Turn start":"Turn end",preview:[void 0!==c?`turn ${c}`:"",b.model].filter(Boolean).join(" · ")}}case"tool.execution_start":return{label:b.toolName||"Tool",preview:aQ(b.arguments),delta:function(a){if(!a)return null;let b=[a.input,a.patch,a.command].find(a=>"string"==typeof a&&a.includes("*** Begin Patch"));if(b){let a=0,c=0;for(let d of b.split("\n"))d.startsWith("+")&&!d.startsWith("+++")?a+=1:d.startsWith("-")&&!d.startsWith("---")&&(c+=1);return{added:a,removed:c}}let c=Array.isArray(a.edits)?a.edits:[a],d=0,e=0,f=!1;for(let a of c){let b=a.new_string??a.new_str??a.content??a.file_text,c=a.old_string??a.old_str;("string"==typeof b||"string"==typeof c)&&(f=!0,d+=aR(b),e+=aR(c))}return f?{added:d,removed:e}:null}(b.arguments)};case"tool.execution_complete":return{label:b.toolName||"Tool",preview:!1===b.success?"failed":"completed"};case"external_tool.requested":case"external_tool.completed":return{label:b.toolName||"External tool",preview:"external_tool.requested"===a.type?aQ(b.arguments):"completed"};case"session.start":case"session.resume":{let c=b.context;return{label:"session.start"===a.type?"Session start":"Session resume",preview:[c?.branch?`branch ${c.branch}`:"",b.selectedModel?`model ${b.selectedModel}`:""].filter(Boolean).join(" · ")}}case"session.shutdown":return{label:"Shutdown",preview:[b.shutdownType,void 0!==b.totalPremiumRequests?`${b.totalPremiumRequests} premium req`:""].filter(Boolean).join(" · ")};case"session.auto_mode_resolved":return{label:"Auto mode",preview:[b.chosenModel,b.predictedLabel?`label ${b.predictedLabel}`:""].filter(Boolean).join(" · ")};case"session.binary_asset":return{label:"Binary asset",preview:[b.mimeType,"number"==typeof b.byteLength?`${(b.byteLength/1024).toFixed(0)} KB`:""].filter(Boolean).join(" · ")};case"session.usage_checkpoint":{let a=b.usage;if(a)return{label:"Usage checkpoint",preview:`in ${ai(a.inputTokens??0)} \xb7 out ${ai(a.outputTokens??0)}`};return{label:"Usage checkpoint",preview:void 0!==b.totalPremiumRequests?`${b.totalPremiumRequests} premium req`:"usage snapshot"}}case"session.model_change":return{label:"Model change",preview:`${b.previousModel??"unknown"} → ${b.newModel??"unknown"}`};case"session.compaction_start":return{label:"Compaction",preview:`started \xb7 ${b.model??""}`.trim()};case"session.compaction_complete":return{label:"Compaction",preview:b.success?"completed":`failed${b.error?`: ${aP(b.error,80)}`:""}`};case"system.message":{let a=b.charLength||String(b.content??"").length;return{label:"System",preview:`${b.role??"system"} \xb7 ${a.toLocaleString()} chars`}}case"hook.start":case"hook.end":{let c=b.input;if("hook.end"===a.type)return{label:b.hookType||"Hook",preview:!1===b.success?"failed":"success"};return{label:b.hookType||"Hook",preview:aP(c?.prompt,90)||"started"}}case"permission.requested":{let a=b.permissionRequest;return{label:"Permission",preview:[a?.kind,aP(a?.intention,90)].filter(Boolean).join(" · ")}}case"permission.completed":{let a=b.result;return{label:"Permission",preview:a?.kind??"resolved"}}case"subagent.deselected":return{label:"Subagent",preview:"focus returned to main agent"};case"subagent.activity":return{label:"Subagent",preview:[b.kind,b.agentPath].filter(Boolean).join(" · ")};case"subagent.session_start":return{label:"Subagent start",preview:[b.agentNickname,b.agentPath,b.cwd].filter(Boolean).join(" · ")};case"session.plan_changed":return{label:"Plan",preview:String(b.operation??"changed")};case"system.notification":{let a=b.kind;return{label:"Notification",preview:[a?.type,a?.description].filter(Boolean).join(" · ")||aP(b.content,90)}}case"assistant.thinking":{let a=aP(b.content),c=b.charLength??0;return{label:"Thinking",preview:a||(c?`${c.toLocaleString()} chars (encrypted)`:"reasoning")}}case"session.error":return{label:"Error",preview:aP(b.detail||b.message,90)};case"context.attachment":{let a=b.charLength??0,c=b.itemCount??0,d=b.subject||(c?`${c} ${b.itemsLabel??"items"}`:"")||aP(b.content,70);return{label:b.label||"Attachment",preview:[d,a?`${a.toLocaleString()} chars`:""].filter(Boolean).join(" · ")}}case"file.patch_applied":{let a=b.changes??[],c=a[0]?.file.split("/").pop();return{label:"Patch",preview:a.length>1?`${a.length} files \xb7 ${c}, …`:c??(!1===b.success?"failed":"applied")}}case"web.search":return{label:"Web search",preview:aP(b.query,90)};case"session.turn_context":return{label:"Turn context",preview:[b.model,b.effort?`effort ${b.effort}`:""].filter(Boolean).join(" · ")};case"session.world_state":let d;return{label:"World state",preview:(d=(b.sections??[]).length,[!0===b.full?"full snapshot":"delta",`${d} section${1===d?"":"s"}`,`${(b.charLength??0).toLocaleString()} chars`].join(" · "))};case"session.mode_change":return{label:"Mode",preview:String(b.mode??"changed")};case"session.turn_aborted":return{label:"Turn aborted",preview:[b.reason,b.durationMs?`${Math.round(b.durationMs/1e3)}s`:""].filter(Boolean).join(" · ")};case"session.rollback":return{label:"Rollback",preview:`${b.turns??"?"} turn(s)`};default:return{label:c,preview:aP(JSON.stringify(b),90)}}}(a),G=(n=(m=a.data).tokenDetails,o=m.sessionTotals,q=m.usageSummary,r=("number"==typeof m.inputTokens?m.inputTokens:0)||(n?.input?.tokenCount??0)||(q?.inputTokens??0)||(o?.inputTokens??0),t=("number"==typeof m.outputTokens?m.outputTokens:0)||(n?.output?.tokenCount??0)||(q?.outputTokens??0)||(o?.outputTokens??0),0===r&&0===t?null:{input:r,output:t}),H="number"==typeof a.data.costUSD?a.data.costUSD:null,I=ag(a.type),L=ab[I.category]??u,M=ac[a.type]??`Event in "${I.category}" category with "${I.subCategory}" sub-category.`,N=function(){if(h)return(0,b.jsx)(al,{data:i?{...a.data,result:i.data.result,success:i.data.success}:a.data,type:i?"tool.execution_complete":"tool.execution_start"});switch(a.type){case"user.message":return(0,b.jsx)(aj,{data:a.data});case"assistant.message":return(0,b.jsx)(ak,{data:a.data});case"assistant.turn_start":return(0,b.jsx)(ax,{data:a.data,type:"assistant.turn_start"});case"assistant.turn_end":return(0,b.jsx)(ax,{data:a.data,type:"assistant.turn_end"});case"tool.execution_start":case"tool.execution_complete":return(0,b.jsx)(al,{data:a.data,type:a.type});case"external_tool.requested":return(0,b.jsx)(aq,{data:a.data,type:"external_tool.requested"});case"external_tool.completed":return(0,b.jsx)(aq,{data:a.data,type:"external_tool.completed"});case"session.shutdown":return(0,b.jsx)(am,{data:a.data});case"session.start":case"session.resume":{let c=a.data.context;return(0,b.jsx)("div",{className:"text-xs text-muted-foreground space-y-1",children:c&&(0,b.jsxs)("div",{children:["Branch: ",(0,b.jsx)("span",{className:"text-foreground",children:c.branch})," · ","Model: ",(0,b.jsx)("span",{className:"text-foreground",children:a.data.selectedModel})]})})}case"hook.start":return(0,b.jsx)(ao,{data:a.data,type:"hook.start"});case"hook.end":return(0,b.jsx)(ao,{data:a.data,type:"hook.end"});case"session.auto_mode_resolved":return(0,b.jsx)(ap,{data:a.data});case"session.binary_asset":return(0,b.jsx)(ar,{data:a.data});case"session.usage_checkpoint":return(0,b.jsx)(as,{data:a.data});case"subagent.deselected":return(0,b.jsx)(aw,{});case"session.model_change":return(0,b.jsx)(at,{data:a.data});case"session.compaction_start":return(0,b.jsx)(au,{data:a.data});case"session.compaction_complete":return(0,b.jsx)(av,{data:a.data});case"system.message":return(0,b.jsx)(an,{data:a.data});case"assistant.thinking":return(0,b.jsx)(ay,{data:a.data});case"session.error":return(0,b.jsx)(az,{data:a.data});case"context.attachment":return(0,b.jsx)(aC,{data:a.data});case"file.patch_applied":return(0,b.jsx)(aD,{data:a.data});case"web.search":return(0,b.jsx)(aE,{data:a.data});case"session.mode_change":return(0,b.jsx)(aG,{data:a.data});case"session.turn_context":return(0,b.jsx)(aH,{data:a.data});case"session.world_state":return(0,b.jsx)(aI,{data:a.data});case"subagent.session_start":case"subagent.activity":case"subagent.message":return(0,b.jsx)(aJ,{data:a.data,type:a.type});case"session.turn_aborted":return(0,b.jsx)(aK,{data:a.data});case"session.rollback":return(0,b.jsx)(aL,{data:a.data});case"session.plan_changed":return(0,b.jsx)(aM,{data:a.data});case"system.notification":return(0,b.jsx)(aN,{data:a.data});case"permission.requested":{let c=a.data.permissionRequest;return c?(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:[(0,b.jsx)("span",{className:"text-orange-600 dark:text-orange-400 font-medium",children:c.kind})," ",c.intention]}):null}case"permission.completed":{let c=a.data.result;return c?(0,b.jsx)("div",{className:"text-xs",children:(0,b.jsx)("span",{className:"approved"===c.kind?"text-emerald-600 dark:text-emerald-400":"text-destructive",children:c.kind})}):null}default:return(0,b.jsx)(aO,{data:a.data})}}(),O=JSON.stringify(h&&i?[a,i]:a,null,2),P=i?.data.success===!1,Q=i?af(a.timestamp,i.timestamp):null,R=!!N;return(0,b.jsxs)("div",{"data-event-id":a.id,className:"relative scroll-mt-40 border-l-2 border-border pb-1.5 pl-6 last:border-l-transparent",children:[(0,b.jsx)("span",{className:`absolute -left-[5px] top-3 size-2 rounded-full border border-background ${L.dotCls}`,"aria-hidden":!0}),(0,b.jsxs)("div",{className:(0,$.cn)("relative overflow-hidden rounded-lg border border-border bg-card",f&&"border-l-2 border-l-amber-400 dark:border-l-amber-600",g&&"ring-2 ring-brand/60"),children:[k>0&&(0,b.jsx)("span",{className:"pointer-events-none absolute inset-y-0 left-0 w-[3px] bg-emerald-500",style:{opacity:Math.max(.12,k)},"aria-hidden":!0}),(0,b.jsxs)("button",{type:"button","data-event-row":!0,onClick:()=>{let a;return a=!D,B({nonce:e?.nonce??0,open:a})},"aria-expanded":D,className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left transition-colors hover:bg-muted/60 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",children:[(0,b.jsx)(E.ChevronRight,{className:(0,$.cn)("size-3.5 shrink-0 text-muted-foreground transition-transform",D&&"rotate-90"),"aria-hidden":!0}),(0,b.jsx)("span",{className:`max-w-[9rem] shrink-0 truncate rounded-sm px-1.5 py-0.5 font-mono text-[11px] font-semibold ${L.chipCls??u.typeCls}`,title:F.label,children:F.label}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground/90",children:F.preview}),F.delta&&(0,b.jsxs)("span",{className:"shrink-0 font-mono text-[11px] tabular-nums",title:"Lines written and replaced by this call",children:[(0,b.jsxs)("span",{className:"text-emerald-700 dark:text-emerald-400",children:["+",F.delta.added]}),F.delta.removed>0&&(0,b.jsxs)("span",{className:"ml-1 text-red-700 dark:text-red-400",children:["−",F.delta.removed]})]}),h&&(0,b.jsx)("span",{className:(0,$.cn)("shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-[11px] tabular-nums",P?"bg-red-100 text-red-700 dark:bg-red-900/60 dark:text-red-400":"bg-muted text-muted-foreground"),title:i?P?"The call failed":"Time from the call to its result":"No result was recorded for this call",children:i?P?"failed":null!==Q&&Q>=1e3?`${(Q/1e3).toFixed(1)}s`:"done":"no result"}),G&&(0,b.jsxs)("span",{className:"hidden shrink-0 items-center gap-1.5 font-mono text-[11px] tabular-nums text-muted-foreground sm:inline-flex",title:`${G.input.toLocaleString()} input tokens \xb7 ${G.output.toLocaleString()} output tokens`,children:[G.input>0&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5",children:[(0,b.jsx)(T.InputTokensIcon,{className:"size-3","aria-hidden":!0}),(0,b.jsx)("span",{className:"opacity-70",children:"in"})," ",ai(G.input)]}),G.output>0&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5",children:[(0,b.jsx)(T.OutputTokensIcon,{className:"size-3","aria-hidden":!0}),(0,b.jsx)("span",{className:"opacity-70",children:"out"})," ",ai(G.output)]})]}),null!==H&&H>0&&(0,b.jsx)("span",{className:(0,$.cn)("hidden shrink-0 font-mono text-[11px] tabular-nums sm:inline",!0===a.data.inherited?"text-muted-foreground line-through decoration-muted-foreground/50":"text-emerald-700 dark:text-emerald-400"),title:!0===a.data.inherited?"Estimated cost of this request in the forked session it was copied from; not part of this session's cost":"Estimated cost of this request at API list prices",children:(0,X.formatCost)(H)}),void 0!==j&&(0,b.jsxs)("span",{className:"hidden shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground md:inline",title:"Estimated cost of the session up to and including this request",children:["Σ ",(0,X.formatCost)(j)]}),l&&l.costUSD>0&&(0,b.jsxs)("span",{className:"hidden shrink-0 font-mono text-[11px] tabular-nums text-emerald-700 dark:text-emerald-400 sm:inline",title:`Estimated cost of the ${l.requests} ${1===l.requests?"request":"requests"} made to answer this prompt; ${(0,X.formatCost)(l.totalUSD)} for the session by the end of the turn`,children:["turn ",(0,X.formatCost)(l.costUSD)]}),null!==v&&v>5e3&&(0,b.jsxs)("span",{className:"hidden shrink-0 rounded-sm bg-muted px-1.5 py-0.5 font-mono text-[11px] tabular-nums text-muted-foreground sm:inline",title:"Gap since the previous event",children:["+",v>6e4?`${(v/6e4).toFixed(1)}m`:`${(v/1e3).toFixed(1)}s`]}),(0,b.jsx)("span",{className:"shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground",title:`${ae(a.timestamp)}, ${ad(a.timestamp)}`,children:ad(a.timestamp)})]}),D&&(0,b.jsxs)("div",{className:"border-t border-border",children:[R?(0,b.jsx)("div",{className:"px-3 py-2.5",children:N}):(0,b.jsx)("p",{className:"px-3 py-2.5 text-xs text-muted-foreground",children:"No structured detail for this event — see the raw event below."}),(0,b.jsxs)("div",{className:"flex items-center gap-1 border-t border-border bg-muted/30 px-2 py-1.5",children:[(0,b.jsx)("span",{className:"mr-auto truncate pl-1 font-mono text-[11px] text-muted-foreground",children:h&&i?`${a.type} + ${i.type}`:a.type}),(0,b.jsxs)(p.Button,{variant:"ghost",size:"xs",onClick:()=>z(!y),"aria-expanded":y,className:"text-muted-foreground",children:[(0,b.jsx)(J.Info,{className:"size-3.5","aria-hidden":!0}),"About"]}),(0,b.jsxs)(p.Button,{variant:"ghost",size:"xs",onClick:()=>x(!w),"aria-expanded":w,className:"text-muted-foreground",children:[(0,b.jsx)(C,{className:"size-3.5","aria-hidden":!0}),w?"Hide raw":"Raw"]}),(0,b.jsx)(s.CopyButton,{value:()=>{let b=new URL(window.location.href);return b.search="",b.searchParams.set("event",a.id),b.toString()},label:"Copy a link to this event",icon:K,children:"Link"}),(0,b.jsx)(s.CopyButton,{value:O,label:"Copy raw JSON",children:"Copy"})]}),y&&(0,b.jsx)("div",{className:"border-t border-border bg-muted/40 px-3 py-2 text-xs leading-relaxed text-muted-foreground",children:M}),w&&(0,b.jsxs)("div",{className:"border-t border-border px-3 py-2.5",children:[(0,b.jsx)("p",{className:"mb-1.5 text-[11px] uppercase tracking-wide text-muted-foreground",children:"Raw event"}),(0,b.jsx)("pre",{className:"max-h-64 max-w-full overflow-auto whitespace-pre-wrap break-words rounded-md border border-border bg-muted p-2.5 font-mono text-xs leading-relaxed text-foreground [overflow-wrap:anywhere]",children:O})]})]})]})]})}function aU(a){return ab[a]?.chipCls||"border-border bg-muted text-muted-foreground"}let aV=new Set(["system.message","context.attachment","session.world_state"]),aW=new Set(["tool.execution_start","external_tool.requested"]),aX=new Set(["tool.execution_complete","external_tool.completed"]),aY=new Set(["user.message","assistant.thinking","assistant.message"]),aZ=["normal","compact","focused"];function a$(a){let b=Array.from(document.querySelectorAll("[data-event-row]")),c=b.indexOf(document.activeElement),d=-1===c?Math.max(0,b.findIndex(a=>a.getBoundingClientRect().top>160)):Math.min(b.length-1,Math.max(0,c+a));b[d]?.focus({preventScroll:!0}),b[d]?.scrollIntoView({block:"center"})}function a_(a){let{category:b}=ag(a);return aU(b)}function a0({events:a,focusRequest:e,targetEventId:f,forkParentHref:g,live:h=!1,onLiveChange:i,running:j=!1}){let k=(0,c.useMemo)(()=>{if(!f||a.some(a=>a.id===f))return f;let b=f.lastIndexOf(":");if(-1===b)return f;let c=f.slice(0,b+1);return a.findLast(a=>a.id.startsWith(c))?.id??f},[a,f]),l=(0,c.useMemo)(()=>{let b=a.findLast(a=>!0===a.data.inherited);return g&&b?`${g}?event=${encodeURIComponent(b.id)}`:void 0},[a,g]),[m,n]=(0,Z.useQueryParam)("mode","normal"),[o,q]=(0,c.useState)(aZ.includes(m)?m:"normal");(0,c.useEffect)(()=>n(o),[o,n]);let[r,s]=(0,c.useState)("asc"),[t,u]=(0,c.useState)([]),[v,w]=(0,c.useState)([]),[x,y]=(0,c.useState)(""),[C,E]=(0,c.useState)(!0),[J,K]=(0,c.useState)(!1),[Q,R]=(0,c.useState)(!1),[T,X]=(0,c.useState)(!1),_=(0,c.useRef)(null),[aa,ab]=(0,c.useState)(!1);(0,c.useEffect)(()=>{let a=_.current;if(!a)return;let b=getComputedStyle(document.documentElement),c=parseFloat(b.getPropertyValue("--cv-topbar-h"))+parseFloat(b.getPropertyValue("--cv-tabbar-h")),d=new IntersectionObserver(([a])=>ab(!a.isIntersecting&&a.boundingClientRect.top<c),{rootMargin:`-${c}px 0px 0px 0px`});return d.observe(a),()=>d.disconnect()},[]);let ac=(0,c.useRef)(null),[ad,af]=(0,c.useState)(0);(0,c.useEffect)(()=>{let a=ac.current;if(!a)return;let b=new ResizeObserver(()=>af(a.offsetHeight));return b.observe(a),()=>b.disconnect()},[]);let[ai,aj]=(0,c.useState)(null),ak=(0,c.useMemo)(()=>a.map(a=>{let b=ag(a.type);return{...a,category:b.category,subCategory:b.subCategory,subKey:`${b.category}.${b.subCategory}`}}),[a]),al=(0,c.useMemo)(()=>W(a),[a]),am=(0,c.useMemo)(()=>{let b=new Set,c=null,d=()=>{c&&b.add(c),c=null};for(let e of a)"user.message"===e.type?(d(),b.add(e.id)):"assistant.message"===e.type&&String(e.data.content??"").trim()&&(c=e.id);return d(),b},[a]),an=(0,c.useMemo)(()=>{let b=new Map,c=new Set,d=[];for(let e of a)if(aW.has(e.type))d.push(e);else if(aX.has(e.type)){let a=e.data.toolCallId,f=d.findIndex(b=>a?b.data.toolCallId===a:!b.data.toolCallId&&b.data.toolName===e.data.toolName);if(-1===f)continue;b.set(d[f].id,e),c.add(e.id),d.splice(f,1)}return{results:b,consumed:c}},[a]),ao=(0,c.useMemo)(()=>{let b=new Map,c=[],d=()=>{if(c.length>1){let a={key:c[0].id,size:c.length};for(let d of c)b.set(d.id,a)}c=[]};for(let b of a)aW.has(b.type)?c.push(b):d();return d(),b},[a]),ap=(0,c.useMemo)(()=>"normal"===o?ak:ak.filter(a=>"focused"===o?am.has(a.id):!an.consumed.has(a.id)&&(aW.has(a.type)||aX.has(a.type)||aY.has(a.type)&&("assistant.message"!==a.type||String(a.data.content??"").trim()))),[ak,o,am,an]),aq=(0,c.useMemo)(()=>ap.some(a=>aV.has(a.type)),[ap]),ar=(0,c.useMemo)(()=>ap.filter(a=>C||!aV.has(a.type)),[ap,C]),as=(0,c.useMemo)(()=>{let a=new Map;for(let b of ar){let c=a.get(b.category)??{count:0,typeCounts:new Map};c.count+=1,c.typeCounts.set(b.type,(c.typeCounts.get(b.type)||0)+1),a.set(b.category,c)}return Array.from(a.entries()).map(([a,b])=>{let c=Array.from(b.typeCounts.entries()).sort((a,b)=>b[1]-a[1]||a[0].localeCompare(b[0]))[0]?.[0];return{category:a,count:b.count,representativeType:c}}).sort((a,b)=>b.count-a.count||a.category.localeCompare(b.category))},[ar]),at=(0,c.useMemo)(()=>t.filter(a=>as.some(b=>b.category===a)),[t,as]),au=(0,c.useMemo)(()=>{if(0===at.length)return[];let a=new Set(at),b=new Map;for(let c of ar){if(!a.has(c.category))continue;let d=b.get(c.subKey);d?d.count+=1:b.set(c.subKey,{category:c.category,subCategory:c.subCategory,count:1})}return Array.from(b.values()).sort((a,b)=>b.count-a.count||a.subCategory.localeCompare(b.subCategory))},[ar,at]),av=(0,c.useMemo)(()=>{let a=new Set(au.map(a=>`${a.category}.${a.subCategory}`));return v.filter(b=>a.has(b))},[v,au]),[aw,ax]=(0,c.useState)(null);e&&e!==aw&&(ax(e),u(e.categories??[]),w(e.subKeys??[]),y(e.search??""),R(e.failures??!1),((e.categories??[]).includes("system")||(e.subKeys??[]).includes("system.message"))&&E(!0),q("normal"),X(!0));let ay=(0,c.useMemo)(()=>{let a=new Set(at),b=new Set(av),c=x.toLowerCase().split(/\s+/).filter(Boolean),d=ar.filter(d=>{if(a.size>0&&!a.has(d.category)||b.size>0&&!b.has(d.subKey)||J&&!function(a){let b=a.data,c=b.outputTokens;if("number"==typeof c&&c>0)return!0;let d=b.inputTokens;if("number"==typeof d&&d>0)return!0;let e=b.cacheReadTokens;if("number"==typeof e&&e>0)return!0;let f=b.tokenDetails;if(f){let a=f.input?.tokenCount??0,b=f.output?.tokenCount??0,c=f.cache_read?.tokenCount??0;if(a>0||b>0||c>0)return!0}return!1}(d)||Q&&!ah(d)&&!ah(an.results.get(d.id)))return!1;if(c.length>0){let a="compact"===o?an.results.get(d.id):void 0,b=(JSON.stringify(d)+(a?JSON.stringify(a):"")).toLowerCase();return c.every(a=>b.includes(a))}return!0});return"desc"===r?d.reverse():d},[ar,at,av,J,Q,x,o,an,r]),az=`${at.join()}|${av.join()}|${x}|${C}|${J}|${Q}|${o}|${r}`,[aA,aB]=(0,c.useState)({key:az,count:150}),aC=k?ay.findIndex(a=>a.id===k):-1,aD=Math.max(aA.key===az?aA.count:150,aC+1),aE=a=>aB({key:az,count:a}),aF=h&&"asc"===r,aG=(0,c.useMemo)(()=>aF?ay.slice(-aD):ay.slice(0,aD),[ay,aD,aF]);(0,c.useEffect)(()=>{if(!aF)return;let a=requestAnimationFrame(()=>window.scrollTo({top:document.documentElement.scrollHeight}));return()=>cancelAnimationFrame(a)},[aF,a.length]),(0,c.useEffect)(()=>{k&&document.querySelector(`[data-event-id="${CSS.escape(k)}"]`)?.scrollIntoView({block:"center"})},[k,-1!==aC]),(0,Y.useHotkeys)({f:()=>q(a=>aZ[(aZ.indexOf(a)+1)%aZ.length]),o:()=>s(a=>"asc"===a?"desc":"asc"),l:i&&(()=>i(!h)),e:()=>aj({nonce:Date.now(),mode:"open"}),E:()=>aj({nonce:Date.now(),mode:"closed"}),j:()=>a$(1),k:()=>a$(-1)});let aH=(0,c.useMemo)(()=>{let a=[];return aG.forEach((b,c)=>{let d=new Date(b.timestamp).toLocaleDateString([],{month:"short",day:"numeric"}),e=al.turnOf.get(b.id),f=!0===b.data.inherited,g=a[a.length-1];g&&g.date===d&&g.turn===e&&g.inherited===f?g.events.push(b):a.push({date:d,fullDate:ae(b.timestamp),turn:e,inherited:f,start:c,events:[b]})}),a},[aG,al]),aI=at.length+av.length+ +!!J+ +!!Q+(aq&&!C?1:0),aJ=aI+ +!!x;function aK(){u([]),w([]),y(""),K(!1),R(!1),E(!0),q("normal")}let aL=ay.length-aG.length,aM=aL>0&&(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2 py-6",children:[(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Showing ",aF?"the last ":"",aG.length.toLocaleString()," of ",ay.length.toLocaleString()," matching events"]}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsxs)(p.Button,{variant:"outline",size:"sm",onClick:()=>aE(aD+150),children:["Load ",Math.min(150,aL)," ",aF?"earlier":"more"]}),(0,b.jsx)(p.Button,{variant:"ghost",size:"sm",onClick:()=>aE(ay.length),className:"text-muted-foreground",children:"Show all"})]})]});return(0,b.jsxs)("div",{className:"flex flex-col",children:[(0,b.jsx)("div",{ref:_,"aria-hidden":!0}),(0,b.jsxs)("div",{ref:ac,className:(0,$.cn)("sticky top-[calc(var(--cv-topbar-h)+var(--cv-tabbar-h))] z-10 -mx-4 border-b bg-background/90 px-4 pt-1 pb-2.5 backdrop-blur transition-colors supports-[backdrop-filter]:bg-background/75 sm:-mx-6 sm:px-6",aa?"border-border":"border-transparent"),children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)(U.SearchInput,{value:x,onChange:y,shortcut:!0,placeholder:"Search events…","aria-label":"Search events",className:"w-full sm:w-56"}),(0,b.jsx)(V.Segmented,{label:"Transcript view",size:"default",value:o,onChange:q,options:[{value:"normal",label:"Normal"},{value:"compact",label:"Compact"},{value:"focused",label:"Focused"}]}),(0,b.jsxs)(p.Button,{variant:"outline",onClick:()=>X(a=>!a),"aria-expanded":T,className:(0,$.cn)(aI>0?"border-foreground/25 bg-muted":"text-muted-foreground"),children:[(0,b.jsx)(O,{className:"size-3.5","aria-hidden":!0}),"Filters",aI>0&&(0,b.jsx)("span",{className:"rounded-sm bg-foreground/10 px-1 tabular-nums",children:aI}),(0,b.jsx)(D.default,{className:(0,$.cn)("size-3.5 transition-transform",T&&"rotate-180"),"aria-hidden":!0})]}),aJ>0&&(0,b.jsxs)(p.Button,{variant:"ghost",onClick:aK,className:"text-muted-foreground",children:[(0,b.jsx)(P.X,{className:"size-3.5","aria-hidden":!0}),"Clear"]}),(0,b.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:[i&&(0,b.jsx)(a1,{active:h,onClick:()=>i(!h),icon:M,label:"Follow live",title:j?"Follow the session: keep the newest events in view (l)":"Watch for new events and keep the newest in view (l)",pulse:j,iconOnly:!0}),(0,b.jsxs)(S.Tooltip,{children:[(0,b.jsx)(S.TooltipTrigger,{render:(0,b.jsx)(p.Button,{variant:"outline",size:"icon",onClick:()=>s("asc"===r?"desc":"asc"),"aria-label":"asc"===r?"Show newest first":"Show oldest first",className:"text-muted-foreground",children:"asc"===r?(0,b.jsx)(A,{className:"size-3.5","aria-hidden":!0}):(0,b.jsx)(B,{className:"size-3.5","aria-hidden":!0})})}),(0,b.jsxs)(S.TooltipContent,{children:["asc"===r?"Oldest first":"Newest first"," (o)"]})]}),(0,b.jsxs)(S.Tooltip,{children:[(0,b.jsx)(S.TooltipTrigger,{render:(0,b.jsx)(p.Button,{variant:"outline",size:"icon",onClick:()=>aj({nonce:Date.now(),mode:"open"}),"aria-label":"Expand all events",className:"text-muted-foreground",children:(0,b.jsx)(G,{className:"size-3.5","aria-hidden":!0})})}),(0,b.jsx)(S.TooltipContent,{children:"Expand all"})]}),(0,b.jsxs)(S.Tooltip,{children:[(0,b.jsx)(S.TooltipTrigger,{render:(0,b.jsx)(p.Button,{variant:"outline",size:"icon",onClick:()=>aj({nonce:Date.now(),mode:"closed"}),"aria-label":"Collapse all events",className:"text-muted-foreground",children:(0,b.jsx)(F,{className:"size-3.5","aria-hidden":!0})})}),(0,b.jsx)(S.TooltipContent,{children:"Collapse all"})]}),(0,b.jsx)("span",{className:"ml-1 text-xs tabular-nums text-muted-foreground",children:ay.length===a.length?`${a.length} events`:`${ay.length} of ${a.length} events`})]})]}),T&&(0,b.jsxs)("div",{className:"mt-2.5 space-y-2 border-t border-border pt-2.5",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[aq&&(0,b.jsx)(a1,{active:!C,onClick:()=>E(!C),icon:I,label:"Hide context",title:"Hide system prompts, auto-attached context and world-state snapshots"}),(0,b.jsx)(a1,{active:J,onClick:()=>K(!J),icon:L,label:"Token events",title:"Show only events that report token usage"}),(0,b.jsx)(a1,{active:Q,onClick:()=>R(!Q),icon:H,label:"Failures",title:"Show only tool calls that failed"})]}),(0,b.jsx)("div",{className:"flex flex-wrap items-center gap-1.5",children:as.map(({category:a,count:c,representativeType:d})=>{let e=at.includes(a);return(0,b.jsxs)("button",{type:"button","aria-pressed":e,onClick:()=>u(b=>b.includes(a)?b.filter(b=>b!==a):[...b,a]),className:(0,$.cn)("inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 font-mono text-xs transition-all","focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring",d?a_(d):aU(a),e?"ring-2 ring-ring ring-offset-1 ring-offset-background":"opacity-70 hover:opacity-100"),children:[(0,b.jsx)("span",{children:a}),(0,b.jsx)("span",{className:"font-bold tabular-nums",children:c})]},a)})}),at.length>0&&au.length>0&&(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,b.jsx)("span",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Sub-type"}),au.map(({category:a,subCategory:c,count:d})=>{let e=`${a}.${c}`,f=av.includes(e);return(0,b.jsxs)("button",{type:"button","aria-pressed":f,title:e,onClick:()=>w(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e]),className:(0,$.cn)("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-xs transition-all","focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring",a_(e),f?"ring-2 ring-ring ring-offset-1 ring-offset-background":"opacity-70 hover:opacity-100"),children:[at.length>1&&(0,b.jsxs)("span",{className:"opacity-70",children:[a,":"]}),(0,b.jsx)("span",{children:c}),(0,b.jsx)("span",{className:"font-bold tabular-nums",children:d})]},e)})]})]})]}),(0,b.jsxs)("div",{className:"pr-2",children:[aF&&aM,aH.map(a=>(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("div",{className:"absolute inset-x-0 top-[27px] h-px bg-border","aria-hidden":!0}),(0,b.jsx)("div",{className:"pointer-events-none sticky z-[5] flex justify-center py-4",style:{top:`calc(var(--cv-topbar-h) + var(--cv-tabbar-h) + ${ad}px - 0.5rem)`},children:(0,b.jsxs)("span",{className:"pointer-events-auto rounded-full border border-border bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground shadow-sm",title:a.inherited?`${a.fullDate} \xb7 history copied from the forked session; its cost was billed there and is not part of this session`:void 0===a.turn?a.fullDate:`${a.fullDate} \xb7 prompt ${a.turn} and everything the agent did to answer it`,children:[a.date,a.inherited&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"mx-1.5 opacity-50","aria-hidden":!0,children:"·"}),"Inherited",l&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"mx-1.5 opacity-50","aria-hidden":!0,children:"·"}),(0,b.jsxs)(d.default,{href:l,title:"Open the session this one was forked from, at the last event it copied",className:"inline-flex items-center gap-0.5 text-foreground underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring",children:["Open fork point",(0,b.jsx)(z,{className:"size-3","aria-hidden":!0})]})]})]}),void 0!==a.turn&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"mx-1.5 opacity-50","aria-hidden":!0,children:"·"}),(0,b.jsxs)("span",{className:"text-foreground",children:["Turn ",a.turn]})]})]})}),a.events.map((d,e)=>{let f=ao.get(d.id),g=a.start+e,h=aG["asc"===r?g-1:g+1],i=f&&ao.get(aG[g-1]?.id)!==f;return(0,b.jsxs)(c.Fragment,{children:[i&&(0,b.jsxs)("div",{className:"border-l-2 border-border pb-1 pl-6 font-mono text-[11px] text-amber-700 dark:text-amber-400",children:["parallel · ",f.size," calls"]}),(0,b.jsx)(aT,{event:d,prevTimestamp:h?.timestamp,expandAll:ai,parallel:!!f,target:d.id===k,merged:"compact"===o&&aW.has(d.type),result:"compact"===o?an.results.get(d.id):void 0,runningUSD:al.runningUSD.get(d.id),costShare:al.runningUSD.has(d.id)&&"number"==typeof d.data.costUSD?d.data.costUSD/al.maxEventUSD:0,turn:al.turnByPrompt.get(d.id)})]},d.id)})]},`${a.date}|${a.inherited?"inherited":a.turn}`)),!aF&&aM,0===ay.length&&(0,b.jsxs)("div",{className:"mt-4 flex flex-col items-center gap-2 rounded-xl border border-dashed border-border px-6 py-14 text-center",children:[(0,b.jsx)("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground",children:(0,b.jsx)(N,{className:"size-5","aria-hidden":!0})}),(0,b.jsx)("p",{className:"text-sm font-medium text-foreground",children:"No events match your filters"}),(0,b.jsxs)("p",{className:"max-w-sm text-xs text-muted-foreground",children:[a.length.toLocaleString()," events are recorded in this session."]}),(0,b.jsx)(p.Button,{variant:"outline",size:"sm",onClick:aK,className:"mt-2",children:"Clear filters"})]})]})]})}function a1({active:a,onClick:c,icon:d,label:e,title:f,pulse:g=!1,iconOnly:h=!1}){return(0,b.jsxs)(S.Tooltip,{children:[(0,b.jsx)(S.TooltipTrigger,{render:(0,b.jsxs)(R.Toggle,{variant:"outline",pressed:a,onPressedChange:c,"aria-label":h?e:void 0,className:(0,$.cn)("relative gap-1.5 text-muted-foreground aria-pressed:border-foreground/25 aria-pressed:text-foreground",h&&"px-0 aria-pressed:border-emerald-500/60 aria-pressed:text-emerald-600 dark:aria-pressed:text-emerald-400"),children:[(0,b.jsx)(d,{className:"size-3.5","aria-hidden":!0}),!h&&e,g&&(0,b.jsx)("span",{className:(0,$.cn)("size-1.5 animate-pulse rounded-full bg-emerald-500",h&&"absolute top-1 right-1"),"aria-hidden":!0})]})}),(0,b.jsx)(S.TooltipContent,{children:f})]})}var a2=a.i(6015),a3=a.i(56979),a4=a.i(14574);let a5={input:"Uncached input",cacheWrite:"Cache write",cacheWrite1h:"Cache write (1h)",cacheRead:"Cache read",output:"Output"},a6=[["Uncached input","new prompt text the model had not seen before."],["Cache write","context stored so later requests can reuse it. A 1-hour cache costs more to write than the default."],["Cache read","stored context reused at a discount. The whole conversation is re-sent on every request, so this grows fastest in long sessions."],["Output","the model's replies, tool calls and reasoning."]];function a7(a){return`$${a.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4})}`}function a8({cost:a,totalLabel:d}){let e=a.byModel.length>1,f=a.unpricedModels.length>0;return(0,b.jsx)("div",{className:"overflow-hidden rounded-lg border border-border",children:(0,b.jsxs)(a2.Table,{className:"text-xs",children:[(0,b.jsx)(a2.TableHeader,{children:(0,b.jsxs)(a2.TableRow,{className:"bg-muted/60 hover:bg-muted/60",children:[(0,b.jsx)(a2.TableHead,{className:"h-8 px-3 text-muted-foreground",children:"Token type"}),(0,b.jsx)(a2.TableHead,{className:"h-8 px-3 text-right text-muted-foreground",children:"Tokens"}),(0,b.jsx)(a2.TableHead,{className:"h-8 px-3 text-right text-muted-foreground",children:"Rate / 1M"}),(0,b.jsx)(a2.TableHead,{className:"h-8 px-3 text-right text-muted-foreground",children:"Cost"})]})}),(0,b.jsx)(a2.TableBody,{className:"tabular-nums",children:a.byModel.map(d=>(0,b.jsxs)(c.Fragment,{children:[(0,b.jsxs)(a2.TableRow,{className:"bg-muted/30 hover:bg-muted/30",children:[(0,b.jsx)(a2.TableHead,{colSpan:3,scope:"rowgroup",className:"h-auto px-3 py-1.5 font-mono font-semibold",children:d.model}),(0,b.jsx)(a2.TableCell,{className:"px-3 py-1.5 text-right font-mono font-semibold text-foreground",children:e&&null!==d.costUSD&&(0,X.formatCost)(d.costUSD)})]}),a.lines.filter(a=>a.model===d.model).map(a=>(0,b.jsxs)(a2.TableRow,{className:"border-border/60",children:[(0,b.jsx)(a2.TableCell,{className:"px-3 py-1.5 text-foreground",children:a5[a.kind]}),(0,b.jsx)(a2.TableCell,{className:"px-3 py-1.5 text-right font-mono",children:a.tokens.toLocaleString()}),(0,b.jsx)(a2.TableCell,{className:"px-3 py-1.5 text-right font-mono",children:null===a.rate?"—":a7(a.rate)}),(0,b.jsx)(a2.TableCell,{className:"px-3 py-1.5 text-right font-mono text-foreground",children:null===a.usd?(0,b.jsx)("span",{className:"font-sans text-muted-foreground",children:"no price"}):(0,X.formatCost)(a.usd)})]},`${a.kind}-${a.rate}`))]},d.model))}),(0,b.jsx)(a2.TableFooter,{className:"bg-muted/60",children:(0,b.jsxs)(a2.TableRow,{className:"hover:bg-transparent",children:[(0,b.jsx)(a2.TableHead,{colSpan:3,scope:"row",className:"h-auto px-3 py-2 font-semibold",children:d}),(0,b.jsxs)(a2.TableCell,{className:"px-3 py-2 text-right font-mono font-bold tabular-nums text-foreground",children:[(0,X.formatCost)(a.totalUSD),f&&"+"]})]})})]})})}function a9({cost:a,open:d,onOpenChange:e}){let f,g=a.unpricedModels.length>0,h=(f=Object.entries(a.prices).map(([a,b])=>{let c=(b??[{input:0,output:0}]).map(a=>` ${JSON.stringify(a).replace(/([{,:])/g,"$1 ").replace("}"," }")}`).join(",\n");return` ${JSON.stringify(a)}: [
|
|
1
|
+
module.exports=[75136,a=>{"use strict";var b=a.i(38742),c=a.i(73895),d=a.i(24687),e=a.i(37303),f=a.i(70627);let g=(0,f.default)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),h=(0,f.default)("bookmark",[["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]]),i=(0,f.default)("circle-dollar-sign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]),j=(0,f.default)("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]),k=(0,f.default)("file-pen",[["path",{d:"M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34",key:"o6klzx"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z",key:"zhnas1"}]]);var l=a.i(35789);let m=(0,f.default)("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]),n=(0,f.default)("lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);var o=a.i(22598),p=a.i(99570),q=a.i(75083),r=a.i(69876),s=a.i(64151),t=a.i(19608),u=a.i(59561),v=a.i(27936),w=a.i(31049),x=a.i(35540),y=a.i(34597),z=a.i(1442);let A=(0,f.default)("arrow-up-right",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]),B=(0,f.default)("arrow-down-narrow-wide",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h4",key:"6d7r33"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h10",key:"1438ji"}]]),C=(0,f.default)("arrow-up-narrow-wide",[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M11 12h4",key:"q8tih4"}],["path",{d:"M11 16h7",key:"uosisv"}],["path",{d:"M11 20h10",key:"jvxblo"}]]),D=(0,f.default)("braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);var E=a.i(12650),E=E,F=a.i(80995);let G=(0,f.default)("chevrons-down-up",[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]),H=(0,f.default)("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]),I=(0,f.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]),J=(0,f.default)("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]);var K=a.i(89560);let L=(0,f.default)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]),M=(0,f.default)("list-filter",[["path",{d:"M2 5h20",key:"1fs1ex"}],["path",{d:"M6 12h12",key:"8npq4p"}],["path",{d:"M9 19h6",key:"456am0"}]]),N=(0,f.default)("radio",[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]),O=(0,f.default)("search-x",[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]),P=(0,f.default)("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]);var Q=a.i(61055),R=a.i(86304),S=a.i(73221),T=a.i(85259),U=a.i(14574);let V={claude:"JSONL under ~/.claude/projects/<project>/<session>.jsonl: one JSON record per line, typed user, assistant, system, attachment and so on. Every record carries the Claude Code version that wrote it.",cowork:"The Claude Code CLI runs inside each Cowork session and writes the same JSONL transcript, so it is read exactly like Claude Code.",codex:"JSONL under ~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl: {timestamp, type, payload} lines typed session_meta, event_msg, response_item, turn_context. Only session_meta names the CLI version.",copilot:"JSONL under ~/.copilot/session-state/<id>/events.jsonl, already written as {type, data, id, timestamp, parentId} in the same category.subCategory vocabulary this app uses. session.start names the format version and the CLI version.",vscode:"Chat session files (JSON, or JSONL of appended changes) in VS Code's workspace storage, one request/response pair per entry.",gemini:"Session files under ~/.gemini/tmp/<project>/chats. Each message is typed user, gemini, info, warning or error; a message written again replaces its earlier version.",opencode:"SQLite (opencode.db): session, message and part rows, each keeping its content in a JSON column.",cursor:"SQLite stores under ~/.cursor/projects, holding the conversation as bubble rows: 1 for the user, 2 for the agent.",hermes:"SQLite (state.db) under ~/.hermes: sessions and their messages as rows."},W=["The type is renamed to the shared category.subCategory vocabulary, so every agent's events read the same way.","Long text is cut at 20,000 characters. charLength keeps the full length and truncated says it was cut; the original record is uncut.","One record can become several events (a response with text, thinking and tool calls), and some records are skipped as bookkeeping."],X={content:"Text of the message, capped at 20,000 characters.",charLength:"Full length of the text before it was capped.",truncated:"True when the text shown was cut short.",model:"Model that produced this, as the agent named it.",effort:"Reasoning effort the request ran with.",requestId:"API request id, for matching against provider logs.",role:"Where the text came from: system_prompt, instructions, developer, user_context, …",toolName:"Tool the model called; mcp__server__tool for MCP tools.",toolCallId:"Id linking a call to its result.",arguments:"Arguments the model passed to the tool, parsed into JSON.",argumentChars:"Size of the arguments as the model wrote them, which is what they cost in context.",result:"What the tool returned, reduced to {content, format, images?, detail?}.",resultChars:"Full length of the result before it was capped.",success:"False when the call reported failure.",inputTokens:"Input tokens of the request, including tokens written to cache.",outputTokens:"Output tokens of the response, thinking included.",cacheReadTokens:"Input tokens served from the prompt cache.",billedUsage:"Usage split the way it is priced, used for the cost estimate.",costUSD:"Estimated cost of this request at API list prices.",inherited:"Copied from the session this one was forked from; its cost belongs there.",durationMs:"How long it took, in milliseconds.",sessionId:"Id of the session.",context:"Working directory, branch and repository the session ran in.",attachmentType:"The agent's own name for this kind of context.",label:"Readable name for the attachment kind.",subject:"What the attachment is about: a file, a date, a hook…",items:"Names listed by the attachment (tools, skills, agents), at most 200.",itemCount:"How many names the attachment listed in full.",itemsLabel:"What the listed names are.",message:"Error or notice text.",reason:"Why it happened.",mode:"The mode switched to.",trigger:"What started it: manual or auto.",preTokens:"Context size before compaction.",turnId:"Id of the turn.",totalCostUSD:"Session cost the agent itself reported so far.",apiDurationMs:"Total time spent waiting on the API so far.",premiumRequests:"Premium requests counted so far.",sessionTotals:"Session totals the agent reported, used for the session summary.",usage:"Usage totals as the agent reported them.",selectedModel:"Model chosen when the session began.",copilotVersion:"Version of the agent CLI that wrote the session.",cliVersion:"Version of the agent CLI that wrote the session.",entrypoint:"Where the session ran: cli, claude-desktop, …",forkedFrom:"The session this one was forked from."},Y={type:"Event type, category.subCategory.",data:"What the agent recorded, normalized where it is worth normalizing.",id:"Unique id of the event within the session.",timestamp:"When it happened, ISO 8601.",parentId:"Event this one follows from, when the agent records it.",source:"Where the original record is: its line in the transcript, or the agent's own id.",category:"First part of the type, used by the filters.",subCategory:"Rest of the type, used by the filters.",subKey:"Full type, used by the filters.","data.result.content":"Plain text of the result, capped. JSON results are indented.","data.result.format":"text or json.","data.result.images":"Images the tool returned: type and size only.","data.result.detail":"A second rendering some tools add, usually a diff.","data.context.cwd":"Working directory.","data.context.branch":"Git branch.","data.context.repository":"Git repository.","data.billedUsage.model":"Model the usage is priced as.","data.billedUsage.inputTokens":"Input tokens not read from or written to cache.","data.billedUsage.outputTokens":"Output tokens.","data.billedUsage.cacheReadTokens":"Input tokens read from cache.","data.billedUsage.cacheWriteTokens":"Input tokens written to the 5-minute cache.","data.billedUsage.cacheWrite1hTokens":"Input tokens written to the 1-hour cache.","data.billedUsage.fast":"Ran in fast mode, billed at a higher rate.","data.billedUsage.local":"Ran on a local model, which bills nothing."},Z={type:"Record kind: user, assistant, system, attachment, mode, …",subtype:"Kind of system record: api_error, compact_boundary, turn_duration, …",uuid:"Id of the record.",parentUuid:"Record this one follows in the conversation.",isSidechain:"Written by a subagent rather than the main conversation.",timestamp:"When it was written, ISO 8601.",sessionId:"Session the record belongs to; a fork keeps its parent's id on copied records.",cwd:"Working directory.",gitBranch:"Git branch at the time.",version:"Claude Code version that wrote the record.",entrypoint:"Where Claude Code ran: cli, claude-desktop, …",userType:"Who is driving the session.",requestId:"API request id.",promptId:"Prompt the record belongs to.",effort:"Reasoning effort of the request.",message:"The API message, as sent or received.","message.role":"user or assistant.","message.model":"Model that answered; <synthetic> for messages Claude Code wrote itself.","message.id":"API message id; shared by every record of one streamed response.","message.type":"Always message.","message.content":"A string, or a list of content blocks.","message.content[].type":"Block kind: text, thinking, tool_use, tool_result, image.","message.content[].text":"Text of a text block.","message.content[].thinking":"Reasoning of a thinking block.","message.content[].signature":"Signature that lets the thinking be sent back to the API.","message.content[].id":"Id of a tool_use block.","message.content[].name":"Tool a tool_use block calls.","message.content[].input":"Arguments of a tool_use block.","message.content[].tool_use_id":"Call a tool_result block answers.","message.content[].content":"What the tool returned.","message.content[].is_error":"The tool reported failure.","message.stop_reason":"Why the response ended: end_turn, tool_use, max_tokens, …","message.usage":"Token usage of the whole response, repeated on each of its records.","message.usage.input_tokens":"Input tokens not read from or written to cache.","message.usage.output_tokens":"Output tokens.","message.usage.cache_read_input_tokens":"Input tokens read from cache.","message.usage.cache_creation_input_tokens":"Input tokens written to cache.","message.usage.cache_creation":"Cache writes split by time to live.","message.usage.speed":"fast when the request ran in fast mode.",toolUseResult:"Claude Code's own structured copy of a tool result.",attachment:"Context Claude Code injected; its type says which kind.","attachment.type":"Kind of attachment: prompt_snapshot, instructions, file, date, …",content:"Text of a system record.",level:"Severity of a system record.",error:"Error details of an api_error record."},$={claude:Z,cowork:Z,codex:{timestamp:"When the line was written, ISO 8601.",ordinal:"Position of the line in the rollout.",type:"Line kind: session_meta, event_msg, response_item, turn_context, …",payload:"The line's content; its own type says what it is.","payload.type":"Kind of payload: user_message, agent_message, function_call, token_count, …","payload.id":"Id of the session (session_meta) or the item.","payload.cli_version":"Codex CLI version, on session_meta only.","payload.originator":"App that ran Codex.","payload.cwd":"Working directory.","payload.role":"Who a message is from: user, assistant, developer, system.","payload.content":"Content parts of a message.","payload.content[].type":"Part kind: input_text, output_text, …","payload.content[].text":"Text of the part.","payload.message":"Text of an event_msg message.","payload.call_id":"Id linking a tool call to its output.","payload.name":"Tool called.","payload.arguments":"Tool arguments, as a JSON string.","payload.input":"Input of a custom tool call.","payload.output":"What the tool returned.","payload.status":"Status of the call.","payload.turn_id":"Turn the line belongs to.","payload.info":"Token usage: cumulative totals and the last request's."},copilot:{type:"Event type, already in category.subCategory form.",data:"Event data.",id:"Id of the event.",timestamp:"When it happened, ISO 8601.",parentId:"Event this one follows from.","data.version":"Version of the events.jsonl format.","data.copilotVersion":"Copilot CLI version.","data.producer":"What wrote the file.","data.toolCallId":"Id linking a call to its result.","data.toolName":"Tool called.","data.arguments":"Tool arguments.","data.result":"What the tool returned: content, and detailedContent when the tool adds one.","data.error":"Why a failed call failed."}},_=["The result is reduced to plain text in result.content. Images keep only their type and size; the pixels stay on disk.","In the compact view a call and its result are shown as one row, so Raw and Original show two records."],aa="An assistant record with a tool_use block in message.content",ab="A user record with a tool_result block, matched to its call by tool_use_id",ac="Claude Code writes one record per content block of a streamed response, and repeats the response's usage on each. The usage is counted once, on the first event of the response.",ad=a=>({claude:a,cowork:a}),ae={"session.start":{summary:"Session initialization. Captures the runtime context and selected model when a session begins.",sources:{...ad([{record:"No record: Claude Code writes no start record",note:"The app builds one from the cwd, gitBranch, version and entrypoint of the transcript's records, so the timeline opens with the same header for every agent."}]),codex:[{record:"The first session_meta line",note:"Later session_meta lines are sub-agent threads and become subagent.session_start."}],copilot:[{record:"session.start, read as written"}]}},"session.resume":{summary:"Session resumed from a previous state. Indicates context reload and continuation."},"session.shutdown":{summary:"Session end summary. Usually includes usage, token totals, premium requests and API timing.",sources:{copilot:[{record:"session.shutdown",note:"The app derives sessionTotals and usageSummary from it. Totals are cumulative, so only the last shutdown is priced and a resumed session is not counted twice."}]}},"session.auto_mode_resolved":{summary:"Auto-mode model selection result. Shows the predicted task profile and the chosen model settings."},"session.binary_asset":{summary:"Binary payload captured in the session, typically screenshots. Can take up significant context and storage."},"session.usage_checkpoint":{summary:"Interim usage accounting while the session is active.",sources:{...ad([{record:"A cost-state record",note:"totalCostUSD and totalAPIDuration are copied as reported."}]),codex:[{record:"An event_msg line of type token_count",note:"Codex reports cumulative totals, so the app bills only the step since the previous checkpoint, and moves cached tokens out of input_tokens so each is priced once."}],copilot:[{record:"session.usage_checkpoint",note:"Premium/AIU accounting only, no token totals; premiumRequests is copied from totalPremiumRequests."}]}},"session.model_change":{summary:"Model configuration switched during the session (model, effort or context tier).",sources:{codex:[{record:"An event_msg line of type thread_settings_applied"}]}},"session.compaction_start":{summary:"Context compaction started. The conversation is summarized to reduce the tokens sent on every request.",sources:ad([{record:"A system record with subtype compact_boundary",note:"trigger and preTokens come from compactMetadata."}])},"session.compaction_complete":{summary:"Compaction finished, with success or failure metadata and request ids."},"session.error":{summary:"API or transport error. Each retry sends the full request context again.",sources:{...ad([{record:"A system record with subtype api_error"}]),gemini:[{record:"A message of type error"}]}},"session.turn_aborted":{summary:"The turn was interrupted before it completed.",changes:["Each agent marks an interruption differently; they all become this one type."],sources:{...ad([{record:"A user record whose text starts with “[Request interrupted by user”",note:"Claude Code logs the interruption as if the user had typed it; the app does not show it as a prompt."}]),codex:[{record:"An event_msg line of type turn_aborted"}],copilot:[{record:"An abort event",note:"Renamed; the data is kept as written."}]}},"session.mode_change":{summary:"Interaction or permission mode switched during the session.",sources:ad([{record:"A mode or permission-mode record"}])},"session.turn_context":{summary:"Per-turn runtime configuration: model, effort, sandbox and approval policy.",sources:{codex:[{record:"A turn_context line"}]}},"session.world_state":{summary:"Snapshot of the workspace the runtime handed to the model.",sources:{codex:[{record:"A world_state line"}]}},"session.rollback":{summary:"The conversation was rolled back by a number of turns.",sources:{codex:[{record:"An event_msg line of type thread_rolled_back"}]}},"session.plan_changed":{summary:"The agent created or updated its working plan."},"session.info":{summary:"A notice the agent printed: information or a warning.",sources:{gemini:[{record:"A message of type info or warning"}]}},"user.message":{summary:"What the user typed. It drives the next assistant turn.",sources:{...ad([{record:"A user record: message.content as a string, or each text block in it",note:"The same record type also carries tool results, which become tool.execution_complete."}]),codex:[{record:"An event_msg line of type user_message"},{record:"A response_item message with role user, only in older rollouts",note:"Newer rollouts carry the conversation twice, as event_msg (what the user saw) and response_item (what the model saw). The app uses event_msg so turns are not doubled; the response_item copy becomes system.message."}],copilot:[{record:"user.message, read as written"}],gemini:[{record:"A message of type user"}]}},"assistant.message":{summary:"Text the model wrote back, with the model name and token usage.",fields:{phase:"Codex: which part of the turn the message belongs to."},sources:{...ad([{record:"An assistant record with a text block in message.content",note:`${ac} A response with no text, thinking or tool call still becomes an empty message, so its usage is counted.`}]),codex:[{record:"An event_msg line of type agent_message"},{record:"A response_item message with role assistant, only when there is no event_msg copy"}],copilot:[{record:"assistant.message, read as written"}],gemini:[{record:"The content of a message of type gemini"}]}},"assistant.thinking":{summary:"Reasoning the model produced before answering. Billed as output tokens.",sources:{...ad([{record:"An assistant record with a thinking block",note:ac}]),codex:[{record:"An event_msg line of type agent_reasoning"},{record:"A response_item of type reasoning, using its summary",note:"Encrypted-only reasoning has nothing readable and is skipped."}],gemini:[{record:"Each entry of thoughts on a message of type gemini"}]}},"assistant.turn_start":{summary:"Start of one assistant turn.",sources:{codex:[{record:"An event_msg line of type task_started"}]}},"assistant.turn_end":{summary:"End of the assistant turn after its reasoning, tool calls and output.",sources:{...ad([{record:"A system record with subtype turn_duration"}]),codex:[{record:"An event_msg line of type task_complete"}]}},"tool.execution_start":{summary:"The model called a built-in tool, with its name and arguments.",changes:["argumentChars is added: the size of the arguments as written, which is what they cost in context."],sources:{...ad([{record:aa,note:`Tools named mcp__… become external_tool.requested instead. ${ac}`}]),codex:[{record:"A response_item of type function_call, custom_tool_call or local_shell_call",note:"Arguments written as a JSON string are parsed into an object."}],copilot:[{record:"tool.execution_start, read as written"}],gemini:[{record:"Each entry of toolCalls on a message of type gemini"}]}},"tool.execution_complete":{summary:"A built-in tool call finished, with its status and result.",changes:_,sources:{...ad([{record:ab,note:"The tool name comes from the matching call. When the block has no content, the record's toolUseResult is used. success is false when is_error is set."}]),codex:[{record:"A response_item of type function_call_output, custom_tool_call_output or local_shell_call_output",note:"Codex records no success flag; the app marks a call failed when its output reports a non-zero exit code."}],copilot:[{record:"tool.execution_complete",note:"result.content becomes the result text, a failed call's error.message stands in for it, and detailedContent (usually a diff) becomes result.detail."}]}},"external_tool.requested":{summary:"The model called a tool served by an external bridge, usually an MCP server.",changes:["argumentChars is added: the size of the arguments as written, which is what they cost in context."],sources:{...ad([{record:`${aa}, for a tool named mcp__…`}]),copilot:[{record:"external_tool.requested, read as written"}]}},"external_tool.completed":{summary:"An external tool call finished, with its status and result.",changes:_,sources:{...ad([{record:`${ab}, for a tool named mcp__…`}]),codex:[{record:"An event_msg line of type mcp_tool_call_end"}],copilot:[{record:"external_tool.completed",note:"Shaped like tool.execution_complete."}]}},"permission.requested":{summary:"The runtime asked the user for permission for an action (file, system or network)."},"permission.completed":{summary:"The permission request was resolved: approved or denied."},"hook.start":{summary:"A lifecycle hook started, for example on prompt submission."},"hook.end":{summary:"A lifecycle hook finished, with success or failure.",sources:ad([{record:"A system record with subtype stop_hook_summary",note:"success is false when the record lists hook errors."}])},"system.message":{summary:"Instructions the runtime put in front of the model: the system prompt, instruction files or injected context.",detail:"These are sent with every request, so their size adds up over a session. Hidden with the other injected context by the toolbar toggle.",sources:{...ad([{record:"An attachment record of type prompt_snapshot",note:"Claude Code records the system prompt again whenever any part of it changes; the app shows it only when the prompt text itself changed."},{record:"An attachment record of type instructions (CLAUDE.md and AGENTS.md files)"},{record:"A system record of any other subtype"}]),codex:[{record:"base_instructions on the session_meta line"},{record:"A response_item message with role developer or system"},{record:"A response_item message with role user that the runtime injected, shown as role user_context"}]}},"context.attachment":{summary:"Context the runtime added on its own: file snapshots, reminders, tool or skill listings, images.",changes:["Every kind of attachment is flattened to {label, subject, items, content}, so it reads as content rather than raw JSON."],sources:{...ad([{record:"An attachment record (date, file, skill_listing, deferred_tools_delta, …)"},{record:"The tools list of a prompt_snapshot attachment, shown as tool definitions when it changes"},{record:"An image block in a user record",note:"Only that an image was sent is kept; the pixels stay on disk."}]),codex:[{record:"dynamic_tools on the session_meta line, shown as tool definitions"}]}},"system.notification":{summary:"A runtime notification added to the conversation, such as a background shell finishing."},"file.patch_applied":{summary:"A patch the agent applied to the workspace, with the files it touched.",sources:{codex:[{record:"An event_msg line of type patch_apply_end"}]}},"web.search":{summary:"A web search the model ran; its results are added to the context.",sources:{codex:[{record:"An event_msg line of type web_search_end"}]}},"subagent.deselected":{summary:"Subagent focus was cleared and control returned to the main agent."},"subagent.activity":{summary:"Activity reported by a subagent working under the main agent.",sources:{codex:[{record:"An event_msg line of type sub_agent_activity"}]}},"subagent.message":{summary:"A message passed between agents.",sources:{codex:[{record:"An inter_agent_communication_metadata line"}]}},"subagent.session_start":{summary:"A subagent thread started inside this session.",sources:{codex:[{record:"A session_meta line after the first one"}]}}};function af(a){let b=ae[a];if(b)return b;let[c,...d]=a.split(".");return{summary:`An event in the “${c||"unknown"}” category (“${d.join(".")||"general"}”) that has no description yet.`,detail:"The agent wrote a record the app has no mapping for. It is kept with its data as written, so nothing is lost, and shown through the generic card."}}function ag(a,b=()=>void 0,c="",d=0){let e=null===a?"null":Array.isArray(a)?"array":"number"==typeof a?Number.isInteger(a)?"integer":"number":typeof a,f={type:e},g=c?b(c):void 0;if(g&&(f.description=g),Array.isArray(a)){let e=a.slice(0,50).map(a=>ag(a,b,`${c}[]`,d+1));e.length>0&&(f.items=e.reduce(function a(b,c){if(b.type===c.type){let d={...b};if(b.properties||c.properties)for(let[e,f]of(d.properties={...b.properties},Object.entries(c.properties??{})))d.properties[e]=d.properties[e]?a(d.properties[e],f):f;return b.items&&c.items?d.items=a(b.items,c.items):c.items&&(d.items=c.items),d}let d=[...new Set([b.type,c.type].flat().filter(a=>!!a))];return{...b,...c,type:d,properties:void 0,items:void 0}}))}else if("object"===e&&d<5){let e=Object.entries(a);e.length>0&&(f.properties=Object.fromEntries(e.map(([a,e])=>[a,ag(e,b,c?`${c}.${a}`:a,d+1)])))}return f}function ah(a){return JSON.stringify(a,null,2)}var ai=a.i(80153);async function aj(a,b,c){let d=encodeURIComponent(decodeURIComponent(b));return Promise.all(c.map(async b=>{let c=await fetch(`/api/sessions/${a}/${d}/record?source=${encodeURIComponent(b)}`);if(!c.ok)throw Error(String(c.status));return(await c.json()).record}))}function ak({title:a,children:c}){return(0,b.jsxs)("section",{className:"space-y-2 border-t border-border pt-3",children:[(0,b.jsx)("h3",{className:"text-xs font-medium text-foreground",children:a}),c]})}function al(a,b){return{$schema:"https://json-schema.org/draft/2020-12/schema",...1===a.length?a[0]:{type:"array",description:b,prefixItems:a}}}function am({title:a,hint:d,schema:e,placeholder:f}){let[g,h]=(0,c.useState)(!1);return(0,b.jsxs)("div",{className:"overflow-hidden rounded-md border border-border",children:[(0,b.jsxs)("div",{className:"flex items-center gap-1 pr-1.5 transition-colors has-[>button[aria-expanded]:hover]:bg-muted/60",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>h(!g),"aria-expanded":g,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-2.5 py-1.5 text-left text-muted-foreground outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring/50",children:[(0,b.jsx)(F.ChevronRight,{className:`size-3.5 shrink-0 transition-transform ${g?"rotate-90":""}`,"aria-hidden":!0}),(0,b.jsx)("span",{className:"text-xs font-medium text-foreground",children:a}),(0,b.jsx)("span",{className:"truncate text-[11px] text-muted-foreground",children:d})]}),e&&(0,b.jsx)(s.CopyButton,{value:e,label:`Copy the ${a.toLowerCase()}`})]}),g&&(0,b.jsx)("div",{className:"border-t border-border p-2",children:e?(0,b.jsx)("pre",{className:"max-h-96 min-w-0 overflow-auto whitespace-pre-wrap break-words rounded-md border border-border bg-muted p-2.5 font-mono text-[11px] leading-relaxed text-foreground [overflow-wrap:anywhere]",children:e}):(0,b.jsx)("p",{className:"px-0.5 text-xs text-muted-foreground",children:f})})]})}function an({open:a,onOpenChange:d,event:e,result:f,sources:g,clientVersion:h}){let i=(0,z.useParams)(),j=i.provider??"",k=ai.PROVIDER_STYLES[j]?.label??j,l=af(e.type),m=f&&f.type!==e.type?af(f.type):null,[n,o]=(0,c.useState)({status:"idle"}),p=(0,c.useRef)(!1);(0,c.useEffect)(()=>{a&&!p.current&&0!==g.length&&i.provider&&i.id&&(p.current=!0,aj(i.provider,i.id,g).then(a=>o({status:"loaded",records:a})).catch(()=>o({status:"failed"})))},[a,g,i.provider,i.id]);let q=[...(l.sources?.[j]??[]).map(a=>({...a,type:e.type})),...(m?.sources?.[j]??[]).map(a=>({...a,type:f.type}))],r=[...new Set([...l.changes??[],...m?.changes??[]])],s="loaded"===n.status?n.records.map(a=>(function(a,b){if(!b||"object"!=typeof b)return null;let c=a=>"string"==typeof a||"number"==typeof a?String(a):null,d=[];switch(a){case"claude":case"cowork":{let a=c(b.version);a&&d.push({label:"Claude Code",value:a});break}case"codex":{let a=c(b.payload?.cli_version);a&&d.push({label:"Codex CLI",value:a});break}case"copilot":{let a=b.data??{},e=c(a.copilotVersion),f=c(a.version);e&&d.push({label:"Copilot CLI",value:e}),f&&d.push({label:"Event format",value:f})}}return d.length>0?d:null})(j,a)).find(a=>null!==a)??null:null,t=ah(al((f?[e,f]:[e]).map(a=>{let b=af(a.type);return{title:a.type,description:b.summary,...ag(a,a=>(function(a,b){if(Y[b])return Y[b];let c=/^data\.([^.[\]]+)$/.exec(b)?.[1];return c?a.fields?.[c]??X[c]:void 0})(b,a))}}),"A call and its result, shown as one row.")),u="loaded"===n.status?ah(al(n.records.map(a=>({title:`${k} record`,...ag(a,a=>$[j]?.[a])})),"The records the row was read from, in transcript order.")):null;return(0,b.jsx)(U.Dialog,{open:a,onOpenChange:d,children:(0,b.jsxs)(U.DialogContent,{className:"gap-0 overflow-hidden p-0 sm:max-w-3xl",children:[(0,b.jsxs)("div",{className:"flex items-center gap-3 border-b border-border px-5 pt-5 pb-3",children:[(0,b.jsx)("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",children:(0,b.jsx)(K.Info,{className:"size-4","aria-hidden":!0})}),(0,b.jsxs)("div",{className:"min-w-0",children:[(0,b.jsx)(U.DialogTitle,{className:"truncate font-mono text-sm",children:m?`${e.type} + ${f.type}`:e.type}),(0,b.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"About this event type"})]})]}),(0,b.jsxs)("div",{className:"flex min-h-0 shrink! flex-col gap-4 overflow-y-auto px-5 pt-4 pb-5",children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.DialogDescription,{className:"text-sm text-foreground",children:l.summary}),m&&(0,b.jsx)("p",{className:"text-sm text-foreground",children:m.summary}),l.detail&&(0,b.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:l.detail})]}),(0,b.jsxs)(ak,{title:`Where it comes from \xb7 ${k}`,children:[V[j]&&(0,b.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:V[j]}),q.length>0?(0,b.jsx)("ul",{className:"space-y-1.5 text-xs",children:q.map(a=>(0,b.jsxs)("li",{className:"rounded-md border border-border px-2.5 py-1.5",children:[(0,b.jsxs)("p",{className:"text-foreground",children:[a.record,m&&(0,b.jsxs)("span",{className:"ml-1.5 font-mono text-[11px] text-muted-foreground",children:["→ ",a.type]})]}),a.note&&(0,b.jsx)("p",{className:"mt-0.5 leading-relaxed text-muted-foreground",children:a.note})]},`${a.type}:${a.record}`))}):(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:["The record this type is read from is not described for ",k," yet. Compare the two schemas below to see how it maps."]}),(0,b.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs",children:[(0,b.jsx)("dt",{className:"text-muted-foreground",children:"This event"}),(0,b.jsx)("dd",{className:"font-mono text-foreground",children:g.length>0?g.map(a=>("claude"===j||"cowork"===j||"codex"===j||"copilot"===j)&&/^\d+$/.test(a)?`line ${Number(a)+1}`:a).join(", "):"no original record to look up"}),(0,b.jsx)("dt",{className:"text-muted-foreground",children:"Recorded by"}),(0,b.jsx)("dd",{className:"text-foreground",children:s?s.map(a=>(0,b.jsxs)("span",{className:"mr-3 inline-block",children:[a.label," ",(0,b.jsx)("span",{className:"font-mono",children:a.value})]},a.label)):"idle"===n.status&&g.length>0?(0,b.jsx)("span",{className:"text-muted-foreground",children:"Reading the record…"}):h?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"font-mono",children:h}),(0,b.jsx)("span",{className:"text-muted-foreground",children:" · from the session; this record names no version"})]}):(0,b.jsx)("span",{className:"text-muted-foreground",children:"No version recorded"})})]})]}),(0,b.jsx)(ak,{title:"What the app changes",children:(0,b.jsxs)("ul",{className:"list-disc space-y-1 pl-4 text-xs leading-relaxed text-muted-foreground marker:text-border",children:[r.map(a=>(0,b.jsx)("li",{className:"text-foreground",children:a},a)),W.map(a=>(0,b.jsx)("li",{children:a},a))]})}),(0,b.jsxs)(ak,{title:"Format",children:[(0,b.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"JSON Schema of this event and of the record it was read from: each property with its type and meaning, without the values. Raw on the row shows the values."}),(0,b.jsx)(am,{title:"Transformed schema",hint:"the event as this app holds it",schema:t,placeholder:""}),(0,b.jsx)(am,{title:"Original schema",hint:`the record as ${k} wrote it`,schema:u,placeholder:0===g.length?"This event was built by the app, or the agent's records cannot be looked up one by one.":"failed"===n.status?"Could not read the record.":"Reading the record…"})]})]})]})})}var ao=a.i(96538),ap=a.i(16543),aq=a.i(45646);function ar(a){let b=[],c=[],d=new Map,e=new Map,f=new Map,g=0,h=0,i=0,j=0,k=null;for(let l of a){if(!0===l.data.inherited){"number"==typeof l.data.costUSD&&(i+=l.data.costUSD);continue}if("user.message"===l.type){j+=1,k={turn:j,prompt:"string"==typeof l.data.content?l.data.content:void 0,eventId:l.id,timestamp:l.timestamp,costUSD:0,requests:0,lines:[],totalUSD:h,compacted:!1},b.push(k),d.set(l.id,k),e.set(l.id,j);continue}k&&e.set(l.id,k.turn),k&&l.type.startsWith("session.compaction")&&(k.compacted=!0);let a=l.data.costUSD,m="number"==typeof a&&a>0,n=Array.isArray(l.data.costLines)?l.data.costLines:[];if(m||k){for(let a of(k||(k={turn:0,eventId:l.id,timestamp:l.timestamp,costUSD:0,requests:0,lines:[],totalUSD:h,compacted:!1},b.push(k)),n))!function(a,b){let c=a.find(a=>a.model===b.model&&a.kind===b.kind&&a.rate===b.rate);c?(c.tokens+=b.tokens,null!==c.usd&&null!==b.usd&&(c.usd+=b.usd)):a.push({...b})}(k.lines,a);n.length>0&&c.push(function(a,b,c,d,e){let f=(...a)=>b.reduce((b,c)=>a.includes(c.kind)?b+c.tokens:b,0),g=(...a)=>b.reduce((b,c)=>a.includes(c.kind)&&null!==c.usd?(b??0)+c.usd:b,null),h=f("input"),i=f("cacheWrite","cacheWrite1h"),j=f("cacheRead");return{n:c,turn:d,eventId:a.id,timestamp:a.timestamp,models:[...new Set(b.map(a=>a.model))],inputTokens:h,cacheWriteTokens:i,cacheReadTokens:j,outputTokens:f("output"),contextTokens:h+i+j,usd:{input:g("input"),cacheWrite:g("cacheWrite","cacheWrite1h"),cacheRead:g("cacheRead"),output:g("output")},costUSD:e}}(l,n,c.length+1,k.turn,m?a:null)),m&&(h+=a,k.costUSD+=a,k.requests+=1,k.totalUSD=h,f.set(l.id,h),g=Math.max(g,a))}}let l=b.findIndex(a=>a.costUSD>0);return{turns:-1===l?[]:b.slice(l),requests:c,turnByPrompt:d,turnOf:e,runningUSD:f,maxEventUSD:g,totalUSD:h,inheritedUSD:i}}var as=a.i(90075),at=a.i(3541),au=a.i(87105),av=a.i(68114);let aw={"session.start":{label:"Session Start",dotCls:"bg-emerald-100 border-emerald-400 dark:bg-emerald-900/60 dark:border-emerald-700",typeCls:"text-emerald-700 dark:text-emerald-400"},"session.shutdown":{label:"Session Shutdown",dotCls:"bg-red-100 border-red-400 dark:bg-red-900/60 dark:border-red-700",typeCls:"text-red-700 dark:text-red-400"},"session.resume":{label:"Session Resume",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"user.message":{label:"User Message",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"assistant.message":{label:"Assistant",dotCls:"bg-sky-100 border-sky-400 dark:bg-sky-900/60 dark:border-sky-700",typeCls:"text-sky-700 dark:text-sky-400"},"assistant.turn_start":{label:"Turn Start",dotCls:"bg-cyan-100 border-cyan-400 dark:bg-cyan-900/60 dark:border-cyan-700",typeCls:"text-cyan-700 dark:text-cyan-400"},"assistant.turn_end":{label:"Turn End",dotCls:"bg-cyan-100 border-cyan-400 dark:bg-cyan-900/60 dark:border-cyan-700",typeCls:"text-cyan-700 dark:text-cyan-400"},"tool.execution_start":{label:"Tool Start",dotCls:"bg-amber-100 border-amber-400 dark:bg-amber-900/60 dark:border-amber-700",typeCls:"text-amber-700 dark:text-amber-400"},"tool.execution_complete":{label:"Tool Done",dotCls:"bg-amber-100 border-amber-400 dark:bg-amber-900/60 dark:border-amber-700",typeCls:"text-amber-700 dark:text-amber-400"},"external_tool.requested":{label:"External Tool Request",dotCls:"bg-lime-100 border-lime-400 dark:bg-lime-900/60 dark:border-lime-700",typeCls:"text-lime-700 dark:text-lime-400"},"external_tool.completed":{label:"External Tool Done",dotCls:"bg-lime-100 border-lime-400 dark:bg-lime-900/60 dark:border-lime-700",typeCls:"text-lime-700 dark:text-lime-400"},"permission.requested":{label:"Permission",dotCls:"bg-orange-100 border-orange-400 dark:bg-orange-900/60 dark:border-orange-700",typeCls:"text-orange-700 dark:text-orange-400"},"permission.completed":{label:"Permission Done",dotCls:"bg-orange-100 border-orange-400 dark:bg-orange-900/60 dark:border-orange-700",typeCls:"text-orange-700 dark:text-orange-400"},"hook.start":{label:"Hook Start",dotCls:"bg-cyan-100 border-cyan-400 dark:bg-cyan-900/60 dark:border-cyan-700",typeCls:"text-cyan-700 dark:text-cyan-400"},"hook.end":{label:"Hook End",dotCls:"bg-cyan-100 border-cyan-400 dark:bg-cyan-900/60 dark:border-cyan-700",typeCls:"text-cyan-700 dark:text-cyan-400"},"session.auto_mode_resolved":{label:"Auto Mode",dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400"},"session.binary_asset":{label:"Binary Asset",dotCls:"bg-rose-100 border-rose-400 dark:bg-rose-900/60 dark:border-rose-700",typeCls:"text-rose-700 dark:text-rose-400"},"session.usage_checkpoint":{label:"Usage Checkpoint",dotCls:"bg-teal-100 border-teal-400 dark:bg-teal-900/60 dark:border-teal-700",typeCls:"text-teal-700 dark:text-teal-400"},"subagent.deselected":{label:"Subagent Deselected",dotCls:"bg-slate-100 border-slate-400 dark:bg-slate-900/60 dark:border-slate-700",typeCls:"text-slate-700 dark:text-slate-400"},"session.model_change":{label:"Model Change",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"session.compaction_start":{label:"Compaction Start",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"session.compaction_complete":{label:"Compaction Complete",dotCls:"bg-purple-100 border-purple-400 dark:bg-purple-900/60 dark:border-purple-700",typeCls:"text-purple-700 dark:text-purple-400"},"system.message":{label:"System",dotCls:"bg-slate-100 border-slate-400 dark:bg-slate-900/60 dark:border-slate-700",typeCls:"text-slate-700 dark:text-slate-400"},"assistant.thinking":{label:"Thinking",dotCls:"bg-indigo-100 border-indigo-400 dark:bg-indigo-900/60 dark:border-indigo-700",typeCls:"text-indigo-700 dark:text-indigo-400"},"session.error":{label:"Error",dotCls:"bg-red-100 border-red-400 dark:bg-red-900/60 dark:border-red-700",typeCls:"text-red-700 dark:text-red-400"},"context.attachment":{label:"Attachment",dotCls:"bg-stone-100 border-stone-400 dark:bg-stone-900/60 dark:border-stone-700",typeCls:"text-stone-700 dark:text-stone-400"},"file.patch_applied":{label:"Patch Applied",dotCls:"bg-emerald-100 border-emerald-400 dark:bg-emerald-900/60 dark:border-emerald-700",typeCls:"text-emerald-700 dark:text-emerald-400"},"web.search":{label:"Web Search",dotCls:"bg-blue-100 border-blue-400 dark:bg-blue-900/60 dark:border-blue-700",typeCls:"text-blue-700 dark:text-blue-400"},"session.turn_context":{label:"Turn Context",dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400"},"session.world_state":{label:"World State",dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400"},"session.mode_change":{label:"Mode Change",dotCls:"bg-violet-100 border-violet-400 dark:bg-violet-900/60 dark:border-violet-700",typeCls:"text-violet-700 dark:text-violet-400"},"session.turn_aborted":{label:"Turn Aborted",dotCls:"bg-orange-100 border-orange-400 dark:bg-orange-900/60 dark:border-orange-700",typeCls:"text-orange-700 dark:text-orange-400"},"session.rollback":{label:"Rollback",dotCls:"bg-orange-100 border-orange-400 dark:bg-orange-900/60 dark:border-orange-700",typeCls:"text-orange-700 dark:text-orange-400"},"subagent.activity":{label:"Subagent",dotCls:"bg-zinc-100 border-zinc-400 dark:bg-zinc-900/60 dark:border-zinc-700",typeCls:"text-zinc-700 dark:text-zinc-400"},"session.plan_changed":{label:"Plan Changed",dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400"},"system.notification":{label:"Notification",dotCls:"bg-slate-100 border-slate-400 dark:bg-slate-900/60 dark:border-slate-700",typeCls:"text-slate-700 dark:text-slate-400"},"subagent.session_start":{label:"Subagent Start",dotCls:"bg-zinc-100 border-zinc-400 dark:bg-zinc-900/60 dark:border-zinc-700",typeCls:"text-zinc-700 dark:text-zinc-400"},"subagent.message":{label:"Subagent Message",dotCls:"bg-zinc-100 border-zinc-400 dark:bg-zinc-900/60 dark:border-zinc-700",typeCls:"text-zinc-700 dark:text-zinc-400"}},ax={label:"Event",dotCls:"bg-muted border-border",typeCls:"text-muted-foreground",chipCls:"border-border bg-muted text-muted-foreground"},ay={session:{dotCls:"bg-fuchsia-100 border-fuchsia-400 dark:bg-fuchsia-900/60 dark:border-fuchsia-700",typeCls:"text-fuchsia-700 dark:text-fuchsia-400",chipCls:"border-fuchsia-300 bg-fuchsia-100 text-fuchsia-800 dark:border-fuchsia-800 dark:bg-fuchsia-900/50 dark:text-fuchsia-300"},user:{dotCls:"bg-pink-100 border-pink-400 dark:bg-pink-900/60 dark:border-pink-700",typeCls:"text-pink-700 dark:text-pink-400",chipCls:"border-pink-300 bg-pink-100 text-pink-800 dark:border-pink-800 dark:bg-pink-900/50 dark:text-pink-300"},assistant:{dotCls:"bg-sky-100 border-sky-400 dark:bg-sky-900/60 dark:border-sky-700",typeCls:"text-sky-700 dark:text-sky-400",chipCls:"border-sky-300 bg-sky-100 text-sky-800 dark:border-sky-800 dark:bg-sky-900/50 dark:text-sky-300"},tool:{dotCls:"bg-amber-100 border-amber-400 dark:bg-amber-900/60 dark:border-amber-700",typeCls:"text-amber-700 dark:text-amber-400",chipCls:"border-amber-300 bg-amber-100 text-amber-800 dark:border-amber-800 dark:bg-amber-900/50 dark:text-amber-300"},external_tool:{dotCls:"bg-lime-100 border-lime-400 dark:bg-lime-900/60 dark:border-lime-700",typeCls:"text-lime-700 dark:text-lime-400",chipCls:"border-lime-300 bg-lime-100 text-lime-800 dark:border-lime-800 dark:bg-lime-900/50 dark:text-lime-300"},permission:{dotCls:"bg-red-100 border-red-400 dark:bg-red-900/60 dark:border-red-700",typeCls:"text-red-700 dark:text-red-400",chipCls:"border-red-300 bg-red-100 text-red-800 dark:border-red-800 dark:bg-red-900/50 dark:text-red-300"},hook:{dotCls:"bg-teal-100 border-teal-400 dark:bg-teal-900/60 dark:border-teal-700",typeCls:"text-teal-700 dark:text-teal-400",chipCls:"border-teal-300 bg-teal-100 text-teal-800 dark:border-teal-800 dark:bg-teal-900/50 dark:text-teal-300"},system:{dotCls:"bg-slate-100 border-slate-400 dark:bg-slate-900/60 dark:border-slate-700",typeCls:"text-slate-700 dark:text-slate-400",chipCls:"border-slate-300 bg-slate-100 text-slate-800 dark:border-slate-700 dark:bg-slate-900/60 dark:text-slate-300"},subagent:{dotCls:"bg-zinc-100 border-zinc-400 dark:bg-zinc-900/60 dark:border-zinc-700",typeCls:"text-zinc-700 dark:text-zinc-400",chipCls:"border-zinc-300 bg-zinc-100 text-zinc-800 dark:border-zinc-700 dark:bg-zinc-900/60 dark:text-zinc-300"},context:{dotCls:"bg-stone-100 border-stone-400 dark:bg-stone-900/60 dark:border-stone-700",typeCls:"text-stone-700 dark:text-stone-400",chipCls:"border-stone-300 bg-stone-100 text-stone-800 dark:border-stone-700 dark:bg-stone-900/60 dark:text-stone-300"},file:{dotCls:"bg-emerald-100 border-emerald-400 dark:bg-emerald-900/60 dark:border-emerald-700",typeCls:"text-emerald-700 dark:text-emerald-400",chipCls:"border-emerald-300 bg-emerald-100 text-emerald-800 dark:border-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-300"},web:{dotCls:"bg-blue-100 border-blue-400 dark:bg-blue-900/60 dark:border-blue-700",typeCls:"text-blue-700 dark:text-blue-400",chipCls:"border-blue-300 bg-blue-100 text-blue-800 dark:border-blue-800 dark:bg-blue-900/50 dark:text-blue-300"}};function az(a){return new Date(a).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function aA(a){return new Date(a).toLocaleDateString([],{weekday:"long",year:"numeric",month:"long",day:"numeric"})}function aB(a,b){return new Date(b).getTime()-new Date(a).getTime()}function aC(a){let[b,...c]=a.split(".");return{category:b||"unknown",subCategory:c.join(".")||"general"}}function aD(a){return!!a&&!1===a.data.success&&(bo.has(a.type)||"file.patch_applied"===a.type)}function aE(a){return a>=1e6?`${(a/1e6).toFixed(2)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:a.toLocaleString()}function aF({data:a}){let d=a.content||"",[e,f]=(0,c.useState)(!1),g=d.slice(0,300),h=d.length>300;return(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:[e?d:g,h&&!e&&"..."]}),h&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>f(!e),className:"h-auto px-0 font-normal text-violet-600 dark:text-violet-400 mt-1",children:e?"Show less":`Show more (${d.length} chars)`})]})}function aG({data:a}){let d=a.content||"",e=a.toolRequests||[],f=a.model,g=a.outputTokens,[h,i]=(0,c.useState)(!1),j=d.slice(0,400),k=d.length>400;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[f&&(0,b.jsx)(R.Badge,{variant:"secondary",className:"text-xs font-mono",children:f}),void 0!==g&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-violet-100 border border-violet-300 dark:bg-violet-950 dark:border-violet-800 rounded-full text-xs text-violet-700 dark:text-violet-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:"out"}),(0,b.jsx)("span",{className:"font-semibold font-mono",children:g.toLocaleString()}),(0,b.jsx)("span",{className:"opacity-60",children:"tokens"})]})]}),d&&(0,b.jsxs)("div",{children:[(0,b.jsxs)("div",{className:"text-sm text-foreground whitespace-pre-wrap leading-relaxed",children:[h?d:j,k&&!h&&"..."]}),k&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>i(!h),className:"h-auto px-0 font-normal text-sky-600 dark:text-sky-400 mt-1",children:h?"Show less":`Show more (${d.length} chars)`})]}),e.length>0&&(0,b.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map((a,c)=>(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-amber-100 border border-amber-300 dark:bg-amber-900/50 dark:border-amber-800 rounded-sm text-xs text-amber-800 dark:text-amber-300 font-mono",children:["🔧 ",a.name]},c))})]})}function aH(a){return`${a.toLocaleString()} chars \xb7 ~${aE(Math.round(a/4))} tokens`}let aI="max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-sm border border-border bg-muted p-2 font-mono text-xs leading-relaxed text-foreground [overflow-wrap:anywhere]";function aJ({label:a,note:c,copyValue:d}){return(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-xs text-amber-600 dark:text-amber-500",children:a}),c&&(0,b.jsx)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:c}),(0,b.jsx)(s.CopyButton,{value:d,label:`Copy ${a.toLowerCase()}`,className:"-my-1"})]})}function aK({args:a,chars:c}){let d=Object.entries(a);if(0===d.length)return null;let e=c??JSON.stringify(a).length;return(0,b.jsxs)("div",{children:[(0,b.jsx)(aJ,{label:"Arguments",note:aH(e),copyValue:JSON.stringify(a,null,2)}),(0,b.jsx)("dl",{className:"mt-1 space-y-1.5",children:d.map(([a,c])=>{let d="string"==typeof c?c:JSON.stringify(c,null,2)??"",e=d.includes("\n")||d.length>100;return(0,b.jsxs)("div",{className:e?"space-y-0.5":"flex items-baseline gap-2",children:[(0,b.jsx)("dt",{className:"shrink-0 font-mono text-[11px] text-muted-foreground",children:a}),(0,b.jsx)("dd",{className:"min-w-0",children:e?(0,b.jsx)("pre",{className:aI,children:d}):(0,b.jsx)("span",{className:"break-words font-mono text-xs text-foreground [overflow-wrap:anywhere]",children:d})})]},a)})})]})}function aL({result:a,chars:d,truncated:e}){let[f,g]=(0,c.useState)(!1),h="string"==typeof a.content?a.content:"",i=a.images??[],j=i.reduce((a,b)=>a+(b.bytes??0),0),k=d??h.length,l=[k>0?aH(k):0===i.length?"empty":null,"json"===a.format?"JSON":null,i.length>0?`${i.length} image${1===i.length?"":"s"}${j>0?` (${(0,as.formatBytes)(j)})`:""}`:null].filter(Boolean).join(" · ");return(0,b.jsxs)("div",{children:[(0,b.jsx)(aJ,{label:"Result",note:l,copyValue:h}),(0,b.jsxs)("div",{className:"mt-1 space-y-1.5",children:[h&&(0,b.jsx)("pre",{className:aI,children:h}),e&&(0,b.jsxs)("p",{className:"text-[11px] text-amber-700 dark:text-amber-400",children:["Showing the first ",h.length.toLocaleString()," of ",k.toLocaleString()," chars. The whole result is in the original record, under Raw."]}),i.map((a,c)=>(0,b.jsxs)("p",{className:"text-[11px] text-muted-foreground",children:["Image ",c+1,": ",a.mediaType??"unknown type",a.bytes?`, ${(0,as.formatBytes)(a.bytes)}`:""," (not loaded)"]},c)),a.detail&&(0,b.jsxs)("div",{children:[(0,b.jsxs)(p.Button,{variant:"link",size:"xs",onClick:()=>g(!f),"aria-expanded":f,className:"h-auto px-0 font-normal text-muted-foreground",children:[f?"▼":"▶"," Detail"]}),f&&(0,b.jsx)("pre",{className:(0,av.cn)(aI,"mt-1"),children:a.detail})]})]})]})}function aM({data:a,type:c}){let d=a.toolName,e=a.arguments,f=a.result,g=a.success;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"font-mono text-amber-700 dark:text-amber-300 font-semibold",children:d}),"tool.execution_complete"===c&&(0,b.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded-sm font-medium ${g?"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/60 dark:text-emerald-400":"bg-red-100 text-red-700 dark:bg-red-900/60 dark:text-red-400"}`,children:g?"success":"failed"})]}),e&&"object"==typeof e&&(0,b.jsx)(aK,{args:e,chars:a.argumentChars}),f&&(0,b.jsx)(aL,{result:f,chars:a.resultChars,truncated:!0===a.truncated})]})}function aN({data:a}){let c=a.tokenDetails,d=a.totalApiDurationMs,e=a.totalPremiumRequests,f=a.shutdownType,g=c?.input?.tokenCount,h=c?.output?.tokenCount,i=c?.cache_read?.tokenCount;return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[f&&(0,b.jsx)(R.Badge,{variant:"outline",className:"text-xs",children:f}),void 0!==e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,b.jsx)("span",{className:"font-semibold text-foreground",children:e})," premium req"]}),void 0!==d&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:[(0,b.jsxs)("span",{className:"font-semibold text-foreground",children:[(d/1e3).toFixed(1),"s"]})," API"]})]}),(void 0!==g||void 0!==h)&&(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[void 0!==g&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-cyan-100 border border-cyan-300 dark:bg-cyan-950 dark:border-cyan-800 rounded-full text-xs text-cyan-700 dark:text-cyan-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:"in"}),(0,b.jsx)("span",{className:"font-semibold font-mono",children:g.toLocaleString()})]}),void 0!==h&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-violet-100 border border-violet-300 dark:bg-violet-950 dark:border-violet-800 rounded-full text-xs text-violet-700 dark:text-violet-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:"out"}),(0,b.jsx)("span",{className:"font-semibold font-mono",children:h.toLocaleString()})]}),void 0!==i&&i>0&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-teal-100 border border-teal-300 dark:bg-teal-950 dark:border-teal-800 rounded-full text-xs text-teal-700 dark:text-teal-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:"cache"}),(0,b.jsx)("span",{className:"font-semibold font-mono",children:i.toLocaleString()})]})]})]})}function aO({data:a}){let d=a.role,e=a.interactionId,f=a.content||"",[g,h]=(0,c.useState)(!1),i=f.slice(0,420),j=f.length>420;return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[d&&(0,b.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs border border-slate-300 bg-slate-100 text-slate-700 dark:border-slate-700 dark:bg-slate-900/60 dark:text-slate-300 font-mono",children:d}),e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground font-mono",children:["interaction: ",e]})]}),(0,b.jsxs)("div",{className:"rounded-md border border-slate-200/80 dark:border-slate-800/80 bg-background/70 px-3 py-2",children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"System Prompt"}),(0,b.jsxs)("pre",{className:"text-xs text-foreground whitespace-pre-wrap break-words leading-relaxed overflow-auto max-h-72 font-mono",children:[g?f:i,j&&!g&&"..."]})]}),j&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>h(!g),className:"h-auto px-0 font-normal text-slate-700 dark:text-slate-300",children:g?"Show less":`Show full system prompt (${f.length.toLocaleString()} chars)`})]})}function aP({data:a,type:d}){let e=a.hookType,f=a.hookInvocationId,g=a.success,h=a.input,i=h?.prompt,[j,k]=(0,c.useState)(!1),l=(i||"").slice(0,300),m=(i||"").length>300;return(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[e&&(0,b.jsx)(R.Badge,{variant:"secondary",className:"text-xs font-mono",children:e}),"hook.end"===d&&void 0!==g&&(0,b.jsx)("span",{className:`text-xs px-1.5 py-0.5 rounded-sm font-medium border ${g?"bg-emerald-100 text-emerald-700 border-emerald-300 dark:bg-emerald-900/50 dark:text-emerald-300 dark:border-emerald-800":"bg-red-100 text-red-700 border-red-300 dark:bg-red-900/50 dark:text-red-300 dark:border-red-800"}`,children:g?"success":"failed"}),f&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:f})]}),"hook.start"===d&&i&&(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"Prompt Preview"}),(0,b.jsxs)("pre",{className:"text-xs text-foreground whitespace-pre-wrap break-words leading-relaxed overflow-auto max-h-44 font-mono",children:[j?i:l,m&&!j&&"..."]}),m&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>k(!j),className:"h-auto px-0 font-normal text-cyan-700 dark:text-cyan-300 mt-1",children:j?"Show less":`Show more (${i.length.toLocaleString()} chars)`})]})]})}function aQ({data:a}){let c=a.chosenModel,d=a.reasoningBucket,e=a.predictedLabel,f=a.confidence,g=a.candidateModels||[],h=a.categoryScores;return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[c&&(0,b.jsx)(R.Badge,{className:"text-xs font-mono bg-fuchsia-100 text-fuchsia-800 border border-fuchsia-300 dark:bg-fuchsia-900/50 dark:text-fuchsia-300 dark:border-fuchsia-800",children:c}),d&&(0,b.jsxs)(R.Badge,{variant:"outline",className:"text-xs font-mono",children:["reasoning: ",d]}),e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["label: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:e})]}),"number"==typeof f&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["confidence: ",(0,b.jsxs)("span",{className:"font-mono text-foreground",children:[Math.round(100*f),"%"]})]})]}),g.length>0&&(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"Candidate Models"}),(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5",children:g.slice(0,8).map((a,c)=>(0,b.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-sm border border-fuchsia-300 bg-fuchsia-100/70 text-fuchsia-800 dark:border-fuchsia-800 dark:bg-fuchsia-900/40 dark:text-fuchsia-300 text-xs font-mono",children:String(a)},c))})]}),h&&Object.keys(h).length>0&&(0,b.jsxs)("div",{children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground mb-1",children:"Category Scores"}),(0,b.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1.5",children:Object.entries(h).slice(0,6).map(([a,c])=>(0,b.jsxs)("div",{className:"text-xs border border-fuchsia-200 bg-fuchsia-50/70 dark:border-fuchsia-900/80 dark:bg-fuchsia-950/25 rounded-sm px-2 py-1 flex items-center justify-between gap-2",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:a}),(0,b.jsx)("span",{className:"font-mono text-foreground",children:String(c)})]},a))})]})]})}function aR({data:a,type:c}){let d=a.requestId,e=a.toolName,f=a.toolCallId,g=a.workingDirectory,h=a.arguments,i=a.result;return(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,b.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs border font-medium ${"external_tool.requested"===c?"bg-lime-100 text-lime-800 border-lime-300 dark:bg-lime-900/60 dark:text-lime-300 dark:border-lime-800":"bg-emerald-100 text-emerald-700 border-emerald-300 dark:bg-emerald-900/60 dark:text-emerald-300 dark:border-emerald-800"}`,children:"external_tool.requested"===c?"requested":"completed"}),e&&(0,b.jsx)(R.Badge,{variant:"secondary",className:"text-xs font-mono",children:e}),f&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:f})]}),d&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono",children:["request: ",d]}),"external_tool.requested"===c&&g&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:["cwd: ",(0,b.jsx)("span",{className:"font-mono text-foreground break-all",children:g})]}),h&&"object"==typeof h&&(0,b.jsx)(aK,{args:h,chars:a.argumentChars}),"external_tool.completed"===c&&i&&(0,b.jsx)(aL,{result:i,chars:a.resultChars,truncated:!0===a.truncated})]})}function aS({data:a}){let c=a.assetId,d=a.type,e=a.mimeType,f=a.byteLength,g=a.data;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[d&&(0,b.jsx)(R.Badge,{variant:"secondary",className:"text-xs font-mono",children:d}),e&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:e})]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1.5 text-xs",children:[void 0!==f&&(0,b.jsxs)("div",{className:"rounded-sm border border-rose-200 dark:border-rose-900 px-2 py-1 bg-rose-100/60 dark:bg-rose-950/25",children:["size: ",(0,b.jsxs)("span",{className:"font-mono text-foreground",children:[f.toLocaleString()," bytes"]})]}),g&&(0,b.jsxs)("div",{className:"rounded-sm border border-rose-200 dark:border-rose-900 px-2 py-1 bg-rose-100/60 dark:bg-rose-950/25",children:["payload: ",(0,b.jsxs)("span",{className:"font-mono text-foreground",children:[g.length.toLocaleString()," chars"]})]})]}),c&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono break-all",children:["asset: ",c]})]})}function aT({data:a}){let c=a.usage,d=a.contextWindow,e=a.totalNanoAiu,f=a.totalPremiumRequests,g=a.modelCacheState,h="number"==typeof e?e/1e9:void 0;return(0,b.jsxs)("div",{className:"space-y-2",children:[c&&(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[[["in",c.inputTokens],["cached",c.cachedInputTokens],["out",c.outputTokens],["reasoning",c.reasoningTokens]].filter(([,a])=>"number"==typeof a&&a>0).map(([a,c])=>(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border border-teal-300 bg-teal-100 px-2 py-0.5 text-teal-700 dark:border-teal-800 dark:bg-teal-950 dark:text-teal-300",children:[(0,b.jsx)("span",{className:"opacity-60",children:a}),(0,b.jsx)("span",{className:"font-mono font-semibold",children:aE(c)})]},a)),d&&(0,b.jsxs)("span",{className:"text-muted-foreground",children:["window ",aE(d)]})]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-1.5 text-xs",children:[void 0!==h&&(0,b.jsxs)("div",{className:"rounded-sm border border-teal-200 dark:border-teal-900 px-2 py-1 bg-teal-100/60 dark:bg-teal-950/25",children:["total AIU: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:aE(h)})]}),void 0!==f&&(0,b.jsxs)("div",{className:"rounded-sm border border-teal-200 dark:border-teal-900 px-2 py-1 bg-teal-100/60 dark:bg-teal-950/25",children:["premium req: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:f})]})]}),g&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:["cache state entries: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:g.length})]})]})}function aU({data:a}){let c=a.previousModel,d=a.newModel,e=a.reasoningEffort,f=a.contextTier;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"text-sm text-foreground",children:[(0,b.jsx)("span",{className:"font-mono",children:c||"unknown"}),(0,b.jsx)("span",{className:"mx-2 text-muted-foreground",children:"→"}),(0,b.jsx)("span",{className:"font-mono font-semibold",children:d||"unknown"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap text-xs",children:[(0,b.jsxs)("span",{className:"px-2 py-0.5 rounded-sm border border-violet-200 dark:border-violet-900 bg-violet-100/60 dark:bg-violet-950/25 text-muted-foreground",children:["effort: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:e??"default"})]}),(0,b.jsxs)("span",{className:"px-2 py-0.5 rounded-sm border border-violet-200 dark:border-violet-900 bg-violet-100/60 dark:bg-violet-950/25 text-muted-foreground",children:["context: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:f??"default"})]})]})]})}function aV({data:a}){let c=a.model,d=a.systemTokens,e=a.conversationTokens,f=a.toolDefinitionsTokens,g=[d,e,f].filter(a=>"number"==typeof a).reduce((a,b)=>a+b,0);return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[c&&(0,b.jsx)(R.Badge,{variant:"secondary",className:"text-xs font-mono",children:c}),g>0&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["total: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:aE(g)})," tokens"]})]}),(0,b.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-1.5 text-xs",children:[void 0!==d&&(0,b.jsxs)("div",{className:"rounded-sm border border-violet-200 dark:border-violet-900 px-2 py-1 bg-violet-100/60 dark:bg-violet-950/25",children:["system: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:aE(d)})]}),void 0!==e&&(0,b.jsxs)("div",{className:"rounded-sm border border-violet-200 dark:border-violet-900 px-2 py-1 bg-violet-100/60 dark:bg-violet-950/25",children:["convo: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:aE(e)})]}),void 0!==f&&(0,b.jsxs)("div",{className:"rounded-sm border border-violet-200 dark:border-violet-900 px-2 py-1 bg-violet-100/60 dark:bg-violet-950/25",children:["tools: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:aE(f)})]})]})]})}function aW({data:a}){let c=a.success,d=a.error,e=a.statusCode,f=a.requestId,g=a.serviceRequestId;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,b.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs border font-medium ${c?"bg-emerald-100 text-emerald-700 border-emerald-300 dark:bg-emerald-900/50 dark:text-emerald-300 dark:border-emerald-800":"bg-red-100 text-red-700 border-red-300 dark:bg-red-900/50 dark:text-red-300 dark:border-red-800"}`,children:c?"success":"failed"}),void 0!==e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["status: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:e})]})]}),d&&(0,b.jsx)("div",{className:"text-xs text-red-700 dark:text-red-300 bg-red-100/70 dark:bg-red-950/30 border border-red-200 dark:border-red-900 rounded-sm px-2 py-1.5 font-mono whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:d}),f&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono break-all",children:["requestId: ",f]}),g&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono break-all",children:["serviceRequestId: ",g]})]})}function aX(){return(0,b.jsx)("div",{className:"text-xs text-muted-foreground",children:"Active subagent context was cleared and focus returned to the main agent."})}function aY({data:a,type:c}){let d=a.model,e=a.turnId,f=a.interactionId;return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,b.jsx)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs border font-medium ${"assistant.turn_start"===c?"bg-emerald-100 text-emerald-700 border-emerald-300 dark:bg-emerald-900/50 dark:text-emerald-300 dark:border-emerald-800":"bg-slate-100 text-slate-700 border-slate-300 dark:bg-slate-900/60 dark:text-slate-300 dark:border-slate-700"}`,children:"assistant.turn_start"===c?"turn started":"turn finished"}),void 0!==e&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["turn: ",(0,b.jsx)("span",{className:"font-mono text-foreground",children:String(e)})]}),d&&(0,b.jsx)(R.Badge,{variant:"secondary",className:"text-xs font-mono",children:d})]}),f&&(0,b.jsxs)("div",{className:"text-xs text-muted-foreground font-mono",children:["interaction: ",f]})]})}function aZ({data:a}){let d=a.content||"",e=a.charLength??d.length,[f,g]=(0,c.useState)(!1),h=d.slice(0,400),i=d.length>400;return d?(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsxs)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:["Reasoning · ",e.toLocaleString()," chars"]}),(0,b.jsxs)("div",{className:"text-sm italic leading-relaxed text-muted-foreground whitespace-pre-wrap",children:[f?d:h,i&&!f&&"…"]}),i&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>g(!f),className:"h-auto px-0 font-normal text-indigo-600 dark:text-indigo-400",children:f?"Show less":`Show more (${e.toLocaleString()} chars)`})]}):(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Reasoning was recorded but its content is encrypted in the transcript."})}function a$({data:a}){let c=a.message||"Error",d=a.detail;return(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("p",{className:"text-sm font-medium text-destructive",children:c}),d&&d!==c&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:d})]})}function a_({items:a,label:d}){let[e,f]=(0,c.useState)(!1);if(0===a.length)return null;let g=e?a:a.slice(0,12);return(0,b.jsxs)("div",{className:"space-y-1",children:[d&&(0,b.jsxs)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:[a.length," ",d]}),(0,b.jsxs)("div",{className:"flex flex-wrap gap-1",children:[g.map(a=>(0,b.jsx)("span",{className:"max-w-full truncate rounded-sm border border-border bg-muted/60 px-1.5 py-0.5 font-mono text-[11px] text-foreground/80",title:a,children:a},a)),!e&&a.length>g.length&&(0,b.jsxs)(p.Button,{variant:"ghost",size:"xs",onClick:()=>f(!0),className:"text-[11px] font-normal text-muted-foreground",children:["+",a.length-g.length," more"]})]})]})}function a0({text:a,charLength:d,limit:e=400,mono:f=!0,accentCls:g="text-muted-foreground"}){let[h,i]=(0,c.useState)(!1);if(!a)return null;let j=a.length>e,k=d??a.length;return(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsxs)("pre",{className:(0,av.cn)("max-h-72 overflow-auto whitespace-pre-wrap break-words text-xs leading-relaxed text-foreground/80",f&&"font-mono"),children:[h?a:a.slice(0,e),!h&&j&&"…"]}),j&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>i(!h),className:(0,av.cn)("h-auto px-0 font-normal",g),children:h?"Show less":`Show more (${k.toLocaleString()} chars)`})]})}function a1({data:a}){let c=a.attachmentType||"attachment",d=a.label||c,e=a.subject,f=a.items??[],g=a.itemsLabel,h=a.charLength??0,i=a.content||"";return(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)(R.Badge,{variant:"secondary",className:"text-xs",children:d}),(0,b.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:c}),h>0&&(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:["~",Math.round(h/4).toLocaleString()," tokens"]})]}),e&&(0,b.jsx)("p",{className:"break-all font-mono text-xs text-foreground/80",children:e}),(0,b.jsx)(a_,{items:f,label:g}),(0,b.jsx)(a0,{text:i,charLength:h,accentCls:"text-stone-600 dark:text-stone-400"})]})}function a2({data:a}){let c=a.success,d=a.changes||[],e=a.stdout||"";return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)("span",{className:`rounded-sm px-1.5 py-0.5 text-xs font-medium ${!1===c?"bg-red-100 text-red-700 dark:bg-red-900/60 dark:text-red-400":"bg-emerald-100 text-emerald-700 dark:bg-emerald-900/60 dark:text-emerald-400"}`,children:!1===c?"failed":"applied"}),(0,b.jsxs)("span",{className:"text-xs text-muted-foreground",children:[d.length," file",1===d.length?"":"s"]})]}),d.length>0&&(0,b.jsx)("ul",{className:"space-y-1",children:d.slice(0,12).map(a=>(0,b.jsxs)("li",{className:"flex items-center gap-2 text-xs",children:[(0,b.jsx)("span",{className:"rounded-sm border border-emerald-300 bg-emerald-100/70 px-1 font-mono text-[10px] uppercase text-emerald-800 dark:border-emerald-800 dark:bg-emerald-900/40 dark:text-emerald-300",children:a.type}),(0,b.jsx)("span",{className:"truncate font-mono text-foreground/80",title:a.file,children:a.file})]},a.file))}),e&&(0,b.jsx)("pre",{className:"max-h-32 overflow-auto whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:e})]})}function a3({data:a}){let c=a.query||"",d=a.resultCount;return(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)("p",{className:"text-sm text-foreground",children:c}),void 0!==d&&(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:[d," result",1===d?"":"s"," returned"]})]})}function a4({facts:a}){let c=a.filter(([,a])=>null!=a&&""!==a);return 0===c.length?null:(0,b.jsx)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:c.map(([a,c])=>(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 rounded-sm border border-border bg-muted/40 px-2 py-1 text-xs",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:a}),(0,b.jsx)("span",{className:"min-w-0 truncate font-mono text-foreground",title:String(c),children:String(c)})]},a))})}function a5({data:a}){let c=a.mode||"unknown";return(0,b.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Mode set to"}),(0,b.jsx)(R.Badge,{variant:"secondary",className:"font-mono",children:c})]})}function a6({data:a}){let c=a.sandboxPolicy,d=a.approvalPolicy,e=c?.writable_roots??[];return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(a4,{facts:[["model",a.model],["effort",a.effort],["personality",a.personality],["sandbox",c?.type],["network",c?.network_access===!0?"enabled":"restricted"],["approval",d?Object.keys(d)[0]:void 0],["cwd",a.cwd]]}),e.length>0&&(0,b.jsx)(a_,{items:e,label:"writable roots"})]})}function a7({data:a}){let c=a.sections??[],d=a.content||"",e=a.charLength??0;return(0,b.jsxs)("div",{className:"space-y-2.5",children:[(0,b.jsx)(a4,{facts:[["cwd",a.cwd],["shell",a.shell],["date",a.currentDate],["timezone",a.timezone],["snapshot",!0===a.full?"full":"delta"],["size",e?`${e.toLocaleString()} chars`:void 0]]}),(0,b.jsx)(a_,{items:c,label:"state sections"}),(0,b.jsx)(a0,{text:d,charLength:e})]})}function a8({data:a,type:c}){return"subagent.session_start"===c?(0,b.jsx)(a4,{facts:[["agent",a.agentNickname],["path",a.agentPath],["thread",a.sessionId],["parent",a.parentThreadId],["cwd",a.cwd]]}):"subagent.activity"===c?(0,b.jsx)(a4,{facts:[["activity",a.kind],["path",a.agentPath],["thread",a.agentThreadId]]}):(0,b.jsx)(bd,{data:a})}function a9({data:a}){let c=a.durationMs;return(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,b.jsx)("span",{className:"rounded-sm bg-orange-100 px-1.5 py-0.5 font-medium text-orange-800 dark:bg-orange-900/60 dark:text-orange-300",children:a.reason??"aborted"}),void 0!==c&&(0,b.jsxs)("span",{className:"text-muted-foreground",children:["after"," ",(0,b.jsxs)("span",{className:"font-mono text-foreground",children:[(c/1e3).toFixed(1),"s"]})]}),void 0!==a.turnId&&(0,b.jsxs)("span",{className:"font-mono text-muted-foreground",children:["turn ",String(a.turnId)]})]})}function ba({data:a}){let c=a.turns;return(0,b.jsxs)("p",{className:"text-sm text-foreground",children:["Conversation rolled back"," ",(0,b.jsx)("span",{className:"font-semibold",children:c??"?"})," turn",1===c?"":"s","."]})}function bb({data:a}){return(0,b.jsxs)("div",{className:"flex items-center gap-2 text-sm",children:[(0,b.jsx)("span",{className:"text-muted-foreground",children:"Plan"}),(0,b.jsx)(R.Badge,{variant:"secondary",className:"font-mono",children:a.operation??"changed"})]})}function bc({data:a}){let c=a.kind,d=a.content||"";return(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsx)(a4,{facts:[["kind",c?.type],["shell",c?.shellId],["exit code",c?.exitCode],["description",c?.description]]}),(0,b.jsx)(a0,{text:d,mono:!1})]})}function bd({data:a}){let[d,e]=(0,c.useState)(!1),f=JSON.stringify(a,null,2),g=f.slice(0,300),h=f.length>300;return(0,b.jsxs)("div",{children:[(0,b.jsxs)("pre",{className:"text-xs text-muted-foreground font-mono whitespace-pre-wrap",children:[d?f:g,h&&!d&&"..."]}),h&&(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:()=>e(!d),className:"h-auto px-0 font-normal text-muted-foreground hover:text-foreground mt-1",children:d?"Collapse":"Expand"})]})}function be(a,b=150){let c=String(a??"").replace(/\s+/g," ").trim();return c.length>b?`${c.slice(0,b)}…`:c}function bf(a){if(!a)return"";for(let b of["command","cmd","input","script","filePath","file_path","notebook_path","path","pattern","query","description","url","prompt"])if(a[b])return`${b}: ${be(a[b],90)}`;return Object.keys(a).length?be(JSON.stringify(a),90):"(no args)"}let bg=a=>"string"==typeof a&&a.length>0?a.replace(/\n$/,"").split("\n").length:0;function bh(a){let b="number"==typeof a.resultChars?a.resultChars:0;return b>0?`${aE(b)} chars`:""}let bi=new Set(["user.message","assistant.message","assistant.thinking"]);function bj({sources:a}){let d=(0,z.useParams)(),[e,f]=(0,c.useState)({status:"idle"});if(0===a.length||!d.provider||!d.id)return null;async function g(){f({status:"loading"});try{let b=await aj(d.provider??"",d.id??"",a);f({status:"loaded",text:JSON.stringify(1===b.length?b[0]:b,null,2)})}catch{f({status:"failed"})}}return(0,b.jsxs)("div",{className:"mt-2.5",children:[(0,b.jsxs)("div",{className:"mb-1.5 flex items-center gap-2",children:[(0,b.jsx)("p",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Original record"}),"loaded"===e.status?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[e.text.length.toLocaleString()," chars"]}),(0,b.jsx)(s.CopyButton,{value:e.text,label:"Copy the original record",className:"-my-1"})]}):(0,b.jsx)(p.Button,{variant:"link",size:"xs",onClick:g,disabled:"loading"===e.status,className:"h-auto px-0 font-normal",children:"loading"===e.status?"Loading…":"Load from transcript"}),"failed"===e.status&&(0,b.jsx)("span",{className:"text-[11px] text-destructive",children:"Could not read the record."})]}),"loaded"===e.status&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("pre",{className:"max-h-96 max-w-full overflow-auto whitespace-pre-wrap break-words rounded-md border border-border bg-muted p-2.5 font-mono text-xs leading-relaxed text-foreground [overflow-wrap:anywhere]",children:e.text.slice(0,2e5)}),e.text.length>2e5&&(0,b.jsxs)("p",{className:"mt-1 text-[11px] text-muted-foreground",children:["Showing the first ",2e5.toLocaleString()," chars; Copy takes the whole record."]})]})]})}function bk({event:a,prevTimestamp:d,expandAll:e,parallel:f=!1,target:g=!1,merged:h=!1,result:i,runningUSD:j,costShare:k=0,turn:l,clientVersion:m}){let n,o,q,r,t,u,v=aw[a.type]||ax,w=d?aB(d,a.timestamp):null,[x,y]=(0,c.useState)(!1),[z,A]=(0,c.useState)(null),[B,C]=(0,c.useState)({nonce:0,open:bi.has(a.type)||g}),E=e&&e.nonce!==B.nonce?"open"===e.mode:B.open,G=function(a){let b=a.data,c=aw[a.type]?.label??aC(a.type).subCategory;switch(a.type){case"user.message":return{label:"User",preview:be(b.content)};case"assistant.message":{let a=b.toolRequests??[],c=be(b.content);if(c)return{label:"Assistant",preview:c};if(a.length)return{label:"Assistant",preview:`requests ${a.map(a=>a.name).filter(Boolean).join(", ")}`};return{label:"Assistant",preview:"(no text)"}}case"assistant.turn_start":case"assistant.turn_end":{let c=b.turnId;return{label:"assistant.turn_start"===a.type?"Turn start":"Turn end",preview:[void 0!==c?`turn ${c}`:"",b.model].filter(Boolean).join(" · ")}}case"tool.execution_start":return{label:b.toolName||"Tool",preview:bf(b.arguments),delta:function(a){if(!a)return null;let b=[a.input,a.patch,a.command].find(a=>"string"==typeof a&&a.includes("*** Begin Patch"));if(b){let a=0,c=0;for(let d of b.split("\n"))d.startsWith("+")&&!d.startsWith("+++")?a+=1:d.startsWith("-")&&!d.startsWith("---")&&(c+=1);return{added:a,removed:c}}let c=Array.isArray(a.edits)?a.edits:[a],d=0,e=0,f=!1;for(let a of c){let b=a.new_string??a.new_str??a.content??a.file_text,c=a.old_string??a.old_str;("string"==typeof b||"string"==typeof c)&&(f=!0,d+=bg(b),e+=bg(c))}return f?{added:d,removed:e}:null}(b.arguments)};case"tool.execution_complete":return{label:b.toolName||"Tool",preview:[!1===b.success?"failed":"completed",bh(b)].filter(Boolean).join(" · ")};case"external_tool.requested":case"external_tool.completed":return{label:b.toolName||"External tool",preview:"external_tool.requested"===a.type?bf(b.arguments):["completed",bh(b)].filter(Boolean).join(" · ")};case"session.start":case"session.resume":{let c=b.context;return{label:"session.start"===a.type?"Session start":"Session resume",preview:[c?.branch?`branch ${c.branch}`:"",b.selectedModel?`model ${b.selectedModel}`:""].filter(Boolean).join(" · ")}}case"session.shutdown":return{label:"Shutdown",preview:[b.shutdownType,void 0!==b.totalPremiumRequests?`${b.totalPremiumRequests} premium req`:""].filter(Boolean).join(" · ")};case"session.auto_mode_resolved":return{label:"Auto mode",preview:[b.chosenModel,b.predictedLabel?`label ${b.predictedLabel}`:""].filter(Boolean).join(" · ")};case"session.binary_asset":return{label:"Binary asset",preview:[b.mimeType,"number"==typeof b.byteLength?`${(b.byteLength/1024).toFixed(0)} KB`:""].filter(Boolean).join(" · ")};case"session.usage_checkpoint":{let a=b.usage;if(a)return{label:"Usage checkpoint",preview:`in ${aE(a.inputTokens??0)} \xb7 out ${aE(a.outputTokens??0)}`};return{label:"Usage checkpoint",preview:void 0!==b.totalPremiumRequests?`${b.totalPremiumRequests} premium req`:"usage snapshot"}}case"session.model_change":return{label:"Model change",preview:`${b.previousModel??"unknown"} → ${b.newModel??"unknown"}`};case"session.compaction_start":return{label:"Compaction",preview:`started \xb7 ${b.model??""}`.trim()};case"session.compaction_complete":return{label:"Compaction",preview:b.success?"completed":`failed${b.error?`: ${be(b.error,80)}`:""}`};case"system.message":{let a=b.charLength||String(b.content??"").length;return{label:"System",preview:`${b.role??"system"} \xb7 ${a.toLocaleString()} chars`}}case"hook.start":case"hook.end":{let c=b.input;if("hook.end"===a.type)return{label:b.hookType||"Hook",preview:!1===b.success?"failed":"success"};return{label:b.hookType||"Hook",preview:be(c?.prompt,90)||"started"}}case"permission.requested":{let a=b.permissionRequest;return{label:"Permission",preview:[a?.kind,be(a?.intention,90)].filter(Boolean).join(" · ")}}case"permission.completed":{let a=b.result;return{label:"Permission",preview:a?.kind??"resolved"}}case"subagent.deselected":return{label:"Subagent",preview:"focus returned to main agent"};case"subagent.activity":return{label:"Subagent",preview:[b.kind,b.agentPath].filter(Boolean).join(" · ")};case"subagent.session_start":return{label:"Subagent start",preview:[b.agentNickname,b.agentPath,b.cwd].filter(Boolean).join(" · ")};case"session.plan_changed":return{label:"Plan",preview:String(b.operation??"changed")};case"system.notification":{let a=b.kind;return{label:"Notification",preview:[a?.type,a?.description].filter(Boolean).join(" · ")||be(b.content,90)}}case"assistant.thinking":{let a=be(b.content),c=b.charLength??0;return{label:"Thinking",preview:a||(c?`${c.toLocaleString()} chars (encrypted)`:"reasoning")}}case"session.error":return{label:"Error",preview:be(b.detail||b.message,90)};case"context.attachment":{let a=b.charLength??0,c=b.itemCount??0,d=b.subject||(c?`${c} ${b.itemsLabel??"items"}`:"")||be(b.content,70);return{label:b.label||"Attachment",preview:[d,a?`${a.toLocaleString()} chars`:""].filter(Boolean).join(" · ")}}case"file.patch_applied":{let a=b.changes??[],c=a[0]?.file.split("/").pop();return{label:"Patch",preview:a.length>1?`${a.length} files \xb7 ${c}, …`:c??(!1===b.success?"failed":"applied")}}case"web.search":return{label:"Web search",preview:be(b.query,90)};case"session.turn_context":return{label:"Turn context",preview:[b.model,b.effort?`effort ${b.effort}`:""].filter(Boolean).join(" · ")};case"session.world_state":let d;return{label:"World state",preview:(d=(b.sections??[]).length,[!0===b.full?"full snapshot":"delta",`${d} section${1===d?"":"s"}`,`${(b.charLength??0).toLocaleString()} chars`].join(" · "))};case"session.mode_change":return{label:"Mode",preview:String(b.mode??"changed")};case"session.turn_aborted":return{label:"Turn aborted",preview:[b.reason,b.durationMs?`${Math.round(b.durationMs/1e3)}s`:""].filter(Boolean).join(" · ")};case"session.rollback":return{label:"Rollback",preview:`${b.turns??"?"} turn(s)`};default:return{label:c,preview:be(JSON.stringify(b),90)}}}(a),H=(o=(n=a.data).tokenDetails,q=n.sessionTotals,r=n.usageSummary,t=("number"==typeof n.inputTokens?n.inputTokens:0)||(o?.input?.tokenCount??0)||(r?.inputTokens??0)||(q?.inputTokens??0),u=("number"==typeof n.outputTokens?n.outputTokens:0)||(o?.output?.tokenCount??0)||(r?.outputTokens??0)||(q?.outputTokens??0),0===t&&0===u?null:{input:t,output:u}),I="number"==typeof a.data.costUSD?a.data.costUSD:null,J=ay[aC(a.type).category]??v,M=function(){if(h)return(0,b.jsx)(aM,{data:i?{...a.data,result:i.data.result,success:i.data.success,resultChars:i.data.resultChars,truncated:i.data.truncated}:a.data,type:i?"tool.execution_complete":"tool.execution_start"});switch(a.type){case"user.message":return(0,b.jsx)(aF,{data:a.data});case"assistant.message":return(0,b.jsx)(aG,{data:a.data});case"assistant.turn_start":return(0,b.jsx)(aY,{data:a.data,type:"assistant.turn_start"});case"assistant.turn_end":return(0,b.jsx)(aY,{data:a.data,type:"assistant.turn_end"});case"tool.execution_start":case"tool.execution_complete":return(0,b.jsx)(aM,{data:a.data,type:a.type});case"external_tool.requested":return(0,b.jsx)(aR,{data:a.data,type:"external_tool.requested"});case"external_tool.completed":return(0,b.jsx)(aR,{data:a.data,type:"external_tool.completed"});case"session.shutdown":return(0,b.jsx)(aN,{data:a.data});case"session.start":case"session.resume":{let c=a.data.context;return(0,b.jsx)("div",{className:"text-xs text-muted-foreground space-y-1",children:c&&(0,b.jsxs)("div",{children:["Branch: ",(0,b.jsx)("span",{className:"text-foreground",children:c.branch})," · ","Model: ",(0,b.jsx)("span",{className:"text-foreground",children:a.data.selectedModel})]})})}case"hook.start":return(0,b.jsx)(aP,{data:a.data,type:"hook.start"});case"hook.end":return(0,b.jsx)(aP,{data:a.data,type:"hook.end"});case"session.auto_mode_resolved":return(0,b.jsx)(aQ,{data:a.data});case"session.binary_asset":return(0,b.jsx)(aS,{data:a.data});case"session.usage_checkpoint":return(0,b.jsx)(aT,{data:a.data});case"subagent.deselected":return(0,b.jsx)(aX,{});case"session.model_change":return(0,b.jsx)(aU,{data:a.data});case"session.compaction_start":return(0,b.jsx)(aV,{data:a.data});case"session.compaction_complete":return(0,b.jsx)(aW,{data:a.data});case"system.message":return(0,b.jsx)(aO,{data:a.data});case"assistant.thinking":return(0,b.jsx)(aZ,{data:a.data});case"session.error":return(0,b.jsx)(a$,{data:a.data});case"context.attachment":return(0,b.jsx)(a1,{data:a.data});case"file.patch_applied":return(0,b.jsx)(a2,{data:a.data});case"web.search":return(0,b.jsx)(a3,{data:a.data});case"session.mode_change":return(0,b.jsx)(a5,{data:a.data});case"session.turn_context":return(0,b.jsx)(a6,{data:a.data});case"session.world_state":return(0,b.jsx)(a7,{data:a.data});case"subagent.session_start":case"subagent.activity":case"subagent.message":return(0,b.jsx)(a8,{data:a.data,type:a.type});case"session.turn_aborted":return(0,b.jsx)(a9,{data:a.data});case"session.rollback":return(0,b.jsx)(ba,{data:a.data});case"session.plan_changed":return(0,b.jsx)(bb,{data:a.data});case"system.notification":return(0,b.jsx)(bc,{data:a.data});case"permission.requested":{let c=a.data.permissionRequest;return c?(0,b.jsxs)("div",{className:"text-xs text-muted-foreground",children:[(0,b.jsx)("span",{className:"text-orange-600 dark:text-orange-400 font-medium",children:c.kind})," ",c.intention]}):null}case"permission.completed":{let c=a.data.result;return c?(0,b.jsx)("div",{className:"text-xs",children:(0,b.jsx)("span",{className:"approved"===c.kind?"text-emerald-600 dark:text-emerald-400":"text-destructive",children:c.kind})}):null}default:return(0,b.jsx)(bd,{data:a.data})}}(),N=JSON.stringify(h&&i?[a,i]:a,null,2),O=[...new Set([a.source,h?i?.source:void 0])].filter(a=>"string"==typeof a),P=i?.data.success===!1,Q=i?aB(a.timestamp,i.timestamp):null,R=!!M;return(0,b.jsxs)("div",{"data-event-id":a.id,className:"relative scroll-mt-40 border-l-2 border-border pb-1.5 pl-6 last:border-l-transparent",children:[(0,b.jsx)("span",{className:`absolute -left-[5px] top-3 size-2 rounded-full border border-background ${J.dotCls}`,"aria-hidden":!0}),(0,b.jsxs)("div",{className:(0,av.cn)("relative overflow-hidden rounded-lg border border-border bg-card",f&&"border-l-2 border-l-amber-400 dark:border-l-amber-600",g&&"ring-2 ring-brand/60"),children:[k>0&&(0,b.jsx)("span",{className:"pointer-events-none absolute inset-y-0 left-0 w-[3px] bg-emerald-500",style:{opacity:Math.max(.12,k)},"aria-hidden":!0}),(0,b.jsxs)("button",{type:"button","data-event-row":!0,onClick:()=>{let a;return a=!E,C({nonce:e?.nonce??0,open:a})},"aria-expanded":E,className:"flex w-full items-center gap-2 px-2.5 py-1.5 text-left transition-colors hover:bg-muted/60 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",children:[(0,b.jsx)(F.ChevronRight,{className:(0,av.cn)("size-3.5 shrink-0 text-muted-foreground transition-transform",E&&"rotate-90"),"aria-hidden":!0}),(0,b.jsx)("span",{className:`max-w-[9rem] shrink-0 truncate rounded-sm px-1.5 py-0.5 font-mono text-[11px] font-semibold ${J.chipCls??v.typeCls}`,title:G.label,children:G.label}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-foreground/90",children:G.preview}),G.delta&&(0,b.jsxs)("span",{className:"shrink-0 font-mono text-[11px] tabular-nums",title:"Lines written and replaced by this call",children:[(0,b.jsxs)("span",{className:"text-emerald-700 dark:text-emerald-400",children:["+",G.delta.added]}),G.delta.removed>0&&(0,b.jsxs)("span",{className:"ml-1 text-red-700 dark:text-red-400",children:["−",G.delta.removed]})]}),h&&i&&bh(i.data)&&(0,b.jsx)("span",{className:(0,av.cn)("hidden shrink-0 font-mono text-[11px] tabular-nums md:inline",i.data.resultChars>=2e4?"text-amber-700 dark:text-amber-400":"text-muted-foreground"),title:`The result is ${aH(i.data.resultChars)}`,children:bh(i.data)}),h&&(0,b.jsx)("span",{className:(0,av.cn)("shrink-0 rounded-sm px-1.5 py-0.5 font-mono text-[11px] tabular-nums",P?"bg-red-100 text-red-700 dark:bg-red-900/60 dark:text-red-400":"bg-muted text-muted-foreground"),title:i?P?"The call failed":"Time from the call to its result":"No result was recorded for this call",children:i?P?"failed":null!==Q&&Q>=1e3?`${(Q/1e3).toFixed(1)}s`:"done":"no result"}),H&&(0,b.jsxs)("span",{className:"hidden shrink-0 items-center gap-1.5 font-mono text-[11px] tabular-nums text-muted-foreground sm:inline-flex",title:`${H.input.toLocaleString()} input tokens \xb7 ${H.output.toLocaleString()} output tokens`,children:[H.input>0&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5",children:[(0,b.jsx)(ao.InputTokensIcon,{className:"size-3","aria-hidden":!0}),(0,b.jsx)("span",{className:"opacity-70",children:"in"})," ",aE(H.input)]}),H.output>0&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5",children:[(0,b.jsx)(ao.OutputTokensIcon,{className:"size-3","aria-hidden":!0}),(0,b.jsx)("span",{className:"opacity-70",children:"out"})," ",aE(H.output)]})]}),null!==I&&I>0&&(0,b.jsx)("span",{className:(0,av.cn)("hidden shrink-0 font-mono text-[11px] tabular-nums sm:inline",!0===a.data.inherited?"text-muted-foreground line-through decoration-muted-foreground/50":"text-emerald-700 dark:text-emerald-400"),title:!0===a.data.inherited?"Estimated cost of this request in the forked session it was copied from; not part of this session's cost":"Estimated cost of this request at API list prices",children:(0,as.formatCost)(I)}),void 0!==j&&(0,b.jsxs)("span",{className:"hidden shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground md:inline",title:"Estimated cost of the session up to and including this request",children:["Σ ",(0,as.formatCost)(j)]}),l&&l.costUSD>0&&(0,b.jsxs)("span",{className:"hidden shrink-0 font-mono text-[11px] tabular-nums text-emerald-700 dark:text-emerald-400 sm:inline",title:`Estimated cost of the ${l.requests} ${1===l.requests?"request":"requests"} made to answer this prompt; ${(0,as.formatCost)(l.totalUSD)} for the session by the end of the turn`,children:["turn ",(0,as.formatCost)(l.costUSD)]}),null!==w&&w>5e3&&(0,b.jsxs)("span",{className:"hidden shrink-0 rounded-sm bg-muted px-1.5 py-0.5 font-mono text-[11px] tabular-nums text-muted-foreground sm:inline",title:"Gap since the previous event",children:["+",w>6e4?`${(w/6e4).toFixed(1)}m`:`${(w/1e3).toFixed(1)}s`]}),(0,b.jsx)("span",{className:"shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground",title:`${aA(a.timestamp)}, ${az(a.timestamp)}`,children:az(a.timestamp)})]}),E&&(0,b.jsxs)("div",{className:"border-t border-border",children:[R?(0,b.jsx)("div",{className:"px-3 py-2.5",children:M}):(0,b.jsx)("p",{className:"px-3 py-2.5 text-xs text-muted-foreground",children:"No structured detail for this event — see the raw event below."}),(0,b.jsxs)("div",{className:"flex items-center gap-1 border-t border-border bg-muted/30 px-2 py-1.5",children:[(0,b.jsx)("span",{className:"mr-auto truncate pl-1 font-mono text-[11px] text-muted-foreground",children:h&&i?`${a.type} + ${i.type}`:a.type}),(0,b.jsxs)(p.Button,{variant:"ghost",size:"xs",onClick:()=>A(!0),"aria-haspopup":"dialog",className:"text-muted-foreground",children:[(0,b.jsx)(K.Info,{className:"size-3.5","aria-hidden":!0}),"About"]}),(0,b.jsxs)(p.Button,{variant:"ghost",size:"xs",onClick:()=>y(!x),"aria-expanded":x,className:"text-muted-foreground",children:[(0,b.jsx)(D,{className:"size-3.5","aria-hidden":!0}),x?"Hide raw":"Raw"]}),(0,b.jsx)(s.CopyButton,{value:()=>{let b=new URL(window.location.href);return b.search="",b.searchParams.set("event",a.id),b.toString()},label:"Copy a link to this event",icon:L,children:"Link"}),(0,b.jsx)(s.CopyButton,{value:N,label:"Copy raw JSON",children:"Copy"})]}),x&&(0,b.jsxs)("div",{className:"border-t border-border px-3 py-2.5",children:[(0,b.jsx)("p",{className:"mb-1.5 text-[11px] uppercase tracking-wide text-muted-foreground",children:"Raw event"}),(0,b.jsx)("pre",{className:"max-h-64 max-w-full overflow-auto whitespace-pre-wrap break-words rounded-md border border-border bg-muted p-2.5 font-mono text-xs leading-relaxed text-foreground [overflow-wrap:anywhere]",children:N}),(0,b.jsx)(bj,{sources:O})]})]})]}),null!==z&&(0,b.jsx)(an,{open:z,onOpenChange:A,event:a,result:h?i:void 0,sources:O,clientVersion:m})]})}function bl(a){return ay[a]?.chipCls||"border-border bg-muted text-muted-foreground"}let bm=new Set(["system.message","context.attachment","session.world_state"]),bn=new Set(["tool.execution_start","external_tool.requested"]),bo=new Set(["tool.execution_complete","external_tool.completed"]),bp=new Set(["user.message","assistant.thinking","assistant.message"]),bq=["normal","compact","focused"];function br(a){let b=Array.from(document.querySelectorAll("[data-event-row]")),c=b.indexOf(document.activeElement),d=-1===c?Math.max(0,b.findIndex(a=>a.getBoundingClientRect().top>160)):Math.min(b.length-1,Math.max(0,c+a));b[d]?.focus({preventScroll:!0}),b[d]?.scrollIntoView({block:"center"})}function bs(a){let{category:b}=aC(a);return bl(b)}function bt({events:a,focusRequest:e,targetEventId:f,forkParentHref:g,live:h=!1,onLiveChange:i,running:j=!1,clientVersion:k}){let l=(0,c.useMemo)(()=>{if(!f||a.some(a=>a.id===f))return f;let b=f.lastIndexOf(":");if(-1===b)return f;let c=f.slice(0,b+1);return a.findLast(a=>a.id.startsWith(c))?.id??f},[a,f]),m=(0,c.useMemo)(()=>{let b=a.findLast(a=>!0===a.data.inherited);return g&&b?`${g}?event=${encodeURIComponent(b.id)}`:void 0},[a,g]),[n,o]=(0,au.useQueryParam)("mode","normal"),[q,r]=(0,c.useState)(bq.includes(n)?n:"normal");(0,c.useEffect)(()=>o(q),[q,o]);let[s,t]=(0,c.useState)("asc"),[u,v]=(0,c.useState)([]),[w,x]=(0,c.useState)([]),[y,z]=(0,c.useState)(""),[D,F]=(0,c.useState)(!0),[K,L]=(0,c.useState)(!1),[R,S]=(0,c.useState)(!1),[U,V]=(0,c.useState)(!1),W=(0,c.useRef)(null),[X,Y]=(0,c.useState)(!1);(0,c.useEffect)(()=>{let a=W.current;if(!a)return;let b=getComputedStyle(document.documentElement),c=parseFloat(b.getPropertyValue("--cv-topbar-h"))+parseFloat(b.getPropertyValue("--cv-tabbar-h")),d=new IntersectionObserver(([a])=>Y(!a.isIntersecting&&a.boundingClientRect.top<c),{rootMargin:`-${c}px 0px 0px 0px`});return d.observe(a),()=>d.disconnect()},[]);let Z=(0,c.useRef)(null),[$,_]=(0,c.useState)(0);(0,c.useEffect)(()=>{let a=Z.current;if(!a)return;let b=new ResizeObserver(()=>_(a.offsetHeight));return b.observe(a),()=>b.disconnect()},[]);let[aa,ab]=(0,c.useState)(null),ac=(0,c.useMemo)(()=>a.map(a=>{let b=aC(a.type);return{...a,category:b.category,subCategory:b.subCategory,subKey:`${b.category}.${b.subCategory}`}}),[a]),ad=(0,c.useMemo)(()=>ar(a),[a]),ae=(0,c.useMemo)(()=>{let b=new Set,c=null,d=()=>{c&&b.add(c),c=null};for(let e of a)"user.message"===e.type?(d(),b.add(e.id)):"assistant.message"===e.type&&String(e.data.content??"").trim()&&(c=e.id);return d(),b},[a]),af=(0,c.useMemo)(()=>{let b=new Map,c=new Set,d=[];for(let e of a)if(bn.has(e.type))d.push(e);else if(bo.has(e.type)){let a=e.data.toolCallId,f=d.findIndex(b=>a?b.data.toolCallId===a:!b.data.toolCallId&&b.data.toolName===e.data.toolName);if(-1===f)continue;b.set(d[f].id,e),c.add(e.id),d.splice(f,1)}return{results:b,consumed:c}},[a]),ag=(0,c.useMemo)(()=>{let b=new Map,c=[],d=()=>{if(c.length>1){let a={key:c[0].id,size:c.length};for(let d of c)b.set(d.id,a)}c=[]};for(let b of a)bn.has(b.type)?c.push(b):d();return d(),b},[a]),ah=(0,c.useMemo)(()=>"normal"===q?ac:ac.filter(a=>"focused"===q?ae.has(a.id):!af.consumed.has(a.id)&&(bn.has(a.type)||bo.has(a.type)||bp.has(a.type)&&("assistant.message"!==a.type||String(a.data.content??"").trim()))),[ac,q,ae,af]),ai=(0,c.useMemo)(()=>ah.some(a=>bm.has(a.type)),[ah]),aj=(0,c.useMemo)(()=>ah.filter(a=>D||!bm.has(a.type)),[ah,D]),ak=(0,c.useMemo)(()=>{let a=new Map;for(let b of aj){let c=a.get(b.category)??{count:0,typeCounts:new Map};c.count+=1,c.typeCounts.set(b.type,(c.typeCounts.get(b.type)||0)+1),a.set(b.category,c)}return Array.from(a.entries()).map(([a,b])=>{let c=Array.from(b.typeCounts.entries()).sort((a,b)=>b[1]-a[1]||a[0].localeCompare(b[0]))[0]?.[0];return{category:a,count:b.count,representativeType:c}}).sort((a,b)=>b.count-a.count||a.category.localeCompare(b.category))},[aj]),al=(0,c.useMemo)(()=>u.filter(a=>ak.some(b=>b.category===a)),[u,ak]),am=(0,c.useMemo)(()=>{if(0===al.length)return[];let a=new Set(al),b=new Map;for(let c of aj){if(!a.has(c.category))continue;let d=b.get(c.subKey);d?d.count+=1:b.set(c.subKey,{category:c.category,subCategory:c.subCategory,count:1})}return Array.from(b.values()).sort((a,b)=>b.count-a.count||a.subCategory.localeCompare(b.subCategory))},[aj,al]),an=(0,c.useMemo)(()=>{let a=new Set(am.map(a=>`${a.category}.${a.subCategory}`));return w.filter(b=>a.has(b))},[w,am]),[ao,as]=(0,c.useState)(null);e&&e!==ao&&(as(e),v(e.categories??[]),x(e.subKeys??[]),z(e.search??""),S(e.failures??!1),((e.categories??[]).includes("system")||(e.subKeys??[]).includes("system.message"))&&F(!0),r("normal"),V(!0));let aw=(0,c.useMemo)(()=>{let a=new Set(al),b=new Set(an),c=y.toLowerCase().split(/\s+/).filter(Boolean),d=aj.filter(d=>{if(a.size>0&&!a.has(d.category)||b.size>0&&!b.has(d.subKey)||K&&!function(a){let b=a.data,c=b.outputTokens;if("number"==typeof c&&c>0)return!0;let d=b.inputTokens;if("number"==typeof d&&d>0)return!0;let e=b.cacheReadTokens;if("number"==typeof e&&e>0)return!0;let f=b.tokenDetails;if(f){let a=f.input?.tokenCount??0,b=f.output?.tokenCount??0,c=f.cache_read?.tokenCount??0;if(a>0||b>0||c>0)return!0}return!1}(d)||R&&!aD(d)&&!aD(af.results.get(d.id)))return!1;if(c.length>0){let a="compact"===q?af.results.get(d.id):void 0,b=(JSON.stringify(d)+(a?JSON.stringify(a):"")).toLowerCase();return c.every(a=>b.includes(a))}return!0});return"desc"===s?d.reverse():d},[aj,al,an,K,R,y,q,af,s]),ax=`${al.join()}|${an.join()}|${y}|${D}|${K}|${R}|${q}|${s}`,[ay,az]=(0,c.useState)({key:ax,count:150}),aB=l?aw.findIndex(a=>a.id===l):-1,aE=Math.max(ay.key===ax?ay.count:150,aB+1),aF=a=>az({key:ax,count:a}),aG=h&&"asc"===s,aH=(0,c.useMemo)(()=>aG?aw.slice(-aE):aw.slice(0,aE),[aw,aE,aG]);(0,c.useEffect)(()=>{if(!aG)return;let a=requestAnimationFrame(()=>window.scrollTo({top:document.documentElement.scrollHeight}));return()=>cancelAnimationFrame(a)},[aG,a.length]),(0,c.useEffect)(()=>{l&&document.querySelector(`[data-event-id="${CSS.escape(l)}"]`)?.scrollIntoView({block:"center"})},[l,-1!==aB]),(0,at.useHotkeys)({f:()=>r(a=>bq[(bq.indexOf(a)+1)%bq.length]),o:()=>t(a=>"asc"===a?"desc":"asc"),l:i&&(()=>i(!h)),e:()=>ab({nonce:Date.now(),mode:"open"}),E:()=>ab({nonce:Date.now(),mode:"closed"}),j:()=>br(1),k:()=>br(-1)});let aI=(0,c.useMemo)(()=>{let a=[];return aH.forEach((b,c)=>{let d=new Date(b.timestamp).toLocaleDateString([],{month:"short",day:"numeric"}),e=ad.turnOf.get(b.id),f=!0===b.data.inherited,g=a[a.length-1];g&&g.date===d&&g.turn===e&&g.inherited===f?g.events.push(b):a.push({date:d,fullDate:aA(b.timestamp),turn:e,inherited:f,start:c,events:[b]})}),a},[aH,ad]),aJ=al.length+an.length+ +!!K+ +!!R+(ai&&!D?1:0),aK=aJ+ +!!y;function aL(){v([]),x([]),z(""),L(!1),S(!1),F(!0),r("normal")}let aM=aw.length-aH.length,aN=aM>0&&(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2 py-6",children:[(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Showing ",aG?"the last ":"",aH.length.toLocaleString()," of ",aw.length.toLocaleString()," matching events"]}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsxs)(p.Button,{variant:"outline",size:"sm",onClick:()=>aF(aE+150),children:["Load ",Math.min(150,aM)," ",aG?"earlier":"more"]}),(0,b.jsx)(p.Button,{variant:"ghost",size:"sm",onClick:()=>aF(aw.length),className:"text-muted-foreground",children:"Show all"})]})]});return(0,b.jsxs)("div",{className:"flex flex-col",children:[(0,b.jsx)("div",{ref:W,"aria-hidden":!0}),(0,b.jsxs)("div",{ref:Z,className:(0,av.cn)("sticky top-[calc(var(--cv-topbar-h)+var(--cv-tabbar-h))] z-10 -mx-4 border-b bg-background/90 px-4 pt-1 pb-2.5 backdrop-blur transition-colors supports-[backdrop-filter]:bg-background/75 sm:-mx-6 sm:px-6",X?"border-border":"border-transparent"),children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)(ap.SearchInput,{value:y,onChange:z,shortcut:!0,placeholder:"Search events…","aria-label":"Search events",className:"w-full sm:w-56"}),(0,b.jsx)(aq.Segmented,{label:"Transcript view",size:"default",value:q,onChange:r,options:[{value:"normal",label:"Normal"},{value:"compact",label:"Compact"},{value:"focused",label:"Focused"}]}),(0,b.jsxs)(p.Button,{variant:"outline",onClick:()=>V(a=>!a),"aria-expanded":U,className:(0,av.cn)(aJ>0?"border-foreground/25 bg-muted":"text-muted-foreground"),children:[(0,b.jsx)(P,{className:"size-3.5","aria-hidden":!0}),"Filters",aJ>0&&(0,b.jsx)("span",{className:"rounded-sm bg-foreground/10 px-1 tabular-nums",children:aJ}),(0,b.jsx)(E.default,{className:(0,av.cn)("size-3.5 transition-transform",U&&"rotate-180"),"aria-hidden":!0})]}),aK>0&&(0,b.jsxs)(p.Button,{variant:"ghost",onClick:aL,className:"text-muted-foreground",children:[(0,b.jsx)(Q.X,{className:"size-3.5","aria-hidden":!0}),"Clear"]}),(0,b.jsxs)("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:[i&&(0,b.jsx)(bu,{active:h,onClick:()=>i(!h),icon:N,label:"Follow live",title:j?"Follow the session: keep the newest events in view (l)":"Watch for new events and keep the newest in view (l)",pulse:j,iconOnly:!0}),(0,b.jsxs)(T.Tooltip,{children:[(0,b.jsx)(T.TooltipTrigger,{render:(0,b.jsx)(p.Button,{variant:"outline",size:"icon",onClick:()=>t("asc"===s?"desc":"asc"),"aria-label":"asc"===s?"Show newest first":"Show oldest first",className:"text-muted-foreground",children:"asc"===s?(0,b.jsx)(B,{className:"size-3.5","aria-hidden":!0}):(0,b.jsx)(C,{className:"size-3.5","aria-hidden":!0})})}),(0,b.jsxs)(T.TooltipContent,{children:["asc"===s?"Oldest first":"Newest first"," (o)"]})]}),(0,b.jsxs)(T.Tooltip,{children:[(0,b.jsx)(T.TooltipTrigger,{render:(0,b.jsx)(p.Button,{variant:"outline",size:"icon",onClick:()=>ab({nonce:Date.now(),mode:"open"}),"aria-label":"Expand all events",className:"text-muted-foreground",children:(0,b.jsx)(H,{className:"size-3.5","aria-hidden":!0})})}),(0,b.jsx)(T.TooltipContent,{children:"Expand all"})]}),(0,b.jsxs)(T.Tooltip,{children:[(0,b.jsx)(T.TooltipTrigger,{render:(0,b.jsx)(p.Button,{variant:"outline",size:"icon",onClick:()=>ab({nonce:Date.now(),mode:"closed"}),"aria-label":"Collapse all events",className:"text-muted-foreground",children:(0,b.jsx)(G,{className:"size-3.5","aria-hidden":!0})})}),(0,b.jsx)(T.TooltipContent,{children:"Collapse all"})]}),(0,b.jsx)("span",{className:"ml-1 text-xs tabular-nums text-muted-foreground",children:aw.length===a.length?`${a.length} events`:`${aw.length} of ${a.length} events`})]})]}),U&&(0,b.jsxs)("div",{className:"mt-2.5 space-y-2 border-t border-border pt-2.5",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[ai&&(0,b.jsx)(bu,{active:!D,onClick:()=>F(!D),icon:J,label:"Hide context",title:"Hide system prompts, auto-attached context and world-state snapshots"}),(0,b.jsx)(bu,{active:K,onClick:()=>L(!K),icon:M,label:"Token events",title:"Show only events that report token usage"}),(0,b.jsx)(bu,{active:R,onClick:()=>S(!R),icon:I,label:"Failures",title:"Show only tool calls that failed"})]}),(0,b.jsx)("div",{className:"flex flex-wrap items-center gap-1.5",children:ak.map(({category:a,count:c,representativeType:d})=>{let e=al.includes(a);return(0,b.jsxs)("button",{type:"button","aria-pressed":e,onClick:()=>v(b=>b.includes(a)?b.filter(b=>b!==a):[...b,a]),className:(0,av.cn)("inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 font-mono text-xs transition-all","focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring",d?bs(d):bl(a),e?"ring-2 ring-ring ring-offset-1 ring-offset-background":"opacity-70 hover:opacity-100"),children:[(0,b.jsx)("span",{children:a}),(0,b.jsx)("span",{className:"font-bold tabular-nums",children:c})]},a)})}),al.length>0&&am.length>0&&(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,b.jsx)("span",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:"Sub-type"}),am.map(({category:a,subCategory:c,count:d})=>{let e=`${a}.${c}`,f=an.includes(e);return(0,b.jsxs)("button",{type:"button","aria-pressed":f,title:e,onClick:()=>x(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e]),className:(0,av.cn)("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-xs transition-all","focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring",bs(e),f?"ring-2 ring-ring ring-offset-1 ring-offset-background":"opacity-70 hover:opacity-100"),children:[al.length>1&&(0,b.jsxs)("span",{className:"opacity-70",children:[a,":"]}),(0,b.jsx)("span",{children:c}),(0,b.jsx)("span",{className:"font-bold tabular-nums",children:d})]},e)})]})]})]}),(0,b.jsxs)("div",{className:"pr-2",children:[aG&&aN,aI.map(a=>(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("div",{className:"absolute inset-x-0 top-[27px] h-px bg-border","aria-hidden":!0}),(0,b.jsx)("div",{className:"pointer-events-none sticky z-[5] flex justify-center py-4",style:{top:`calc(var(--cv-topbar-h) + var(--cv-tabbar-h) + ${$}px - 0.5rem)`},children:(0,b.jsxs)("span",{className:"pointer-events-auto rounded-full border border-border bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground shadow-sm",title:a.inherited?`${a.fullDate} \xb7 history copied from the forked session; its cost was billed there and is not part of this session`:void 0===a.turn?a.fullDate:`${a.fullDate} \xb7 prompt ${a.turn} and everything the agent did to answer it`,children:[a.date,a.inherited&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"mx-1.5 opacity-50","aria-hidden":!0,children:"·"}),"Inherited",m&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"mx-1.5 opacity-50","aria-hidden":!0,children:"·"}),(0,b.jsxs)(d.default,{href:m,title:"Open the session this one was forked from, at the last event it copied",className:"inline-flex items-center gap-0.5 text-foreground underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring",children:["Open fork point",(0,b.jsx)(A,{className:"size-3","aria-hidden":!0})]})]})]}),void 0!==a.turn&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("span",{className:"mx-1.5 opacity-50","aria-hidden":!0,children:"·"}),(0,b.jsxs)("span",{className:"text-foreground",children:["Turn ",a.turn]})]})]})}),a.events.map((d,e)=>{let f=ag.get(d.id),g=a.start+e,h=aH["asc"===s?g-1:g+1],i=f&&ag.get(aH[g-1]?.id)!==f;return(0,b.jsxs)(c.Fragment,{children:[i&&(0,b.jsxs)("div",{className:"border-l-2 border-border pb-1 pl-6 font-mono text-[11px] text-amber-700 dark:text-amber-400",children:["parallel · ",f.size," calls"]}),(0,b.jsx)(bk,{event:d,prevTimestamp:h?.timestamp,expandAll:aa,parallel:!!f,target:d.id===l,merged:"compact"===q&&bn.has(d.type),result:"compact"===q?af.results.get(d.id):void 0,runningUSD:ad.runningUSD.get(d.id),costShare:ad.runningUSD.has(d.id)&&"number"==typeof d.data.costUSD?d.data.costUSD/ad.maxEventUSD:0,turn:ad.turnByPrompt.get(d.id),clientVersion:k})]},d.id)})]},`${a.date}|${a.inherited?"inherited":a.turn}`)),!aG&&aN,0===aw.length&&(0,b.jsxs)("div",{className:"mt-4 flex flex-col items-center gap-2 rounded-xl border border-dashed border-border px-6 py-14 text-center",children:[(0,b.jsx)("div",{className:"flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground",children:(0,b.jsx)(O,{className:"size-5","aria-hidden":!0})}),(0,b.jsx)("p",{className:"text-sm font-medium text-foreground",children:"No events match your filters"}),(0,b.jsxs)("p",{className:"max-w-sm text-xs text-muted-foreground",children:[a.length.toLocaleString()," events are recorded in this session."]}),(0,b.jsx)(p.Button,{variant:"outline",size:"sm",onClick:aL,className:"mt-2",children:"Clear filters"})]})]})]})}function bu({active:a,onClick:c,icon:d,label:e,title:f,pulse:g=!1,iconOnly:h=!1}){return(0,b.jsxs)(T.Tooltip,{children:[(0,b.jsx)(T.TooltipTrigger,{render:(0,b.jsxs)(S.Toggle,{variant:"outline",pressed:a,onPressedChange:c,"aria-label":h?e:void 0,className:(0,av.cn)("relative gap-1.5 text-muted-foreground aria-pressed:border-foreground/25 aria-pressed:text-foreground",h&&"px-0 aria-pressed:border-emerald-500/60 aria-pressed:text-emerald-600 dark:aria-pressed:text-emerald-400"),children:[(0,b.jsx)(d,{className:"size-3.5","aria-hidden":!0}),!h&&e,g&&(0,b.jsx)("span",{className:(0,av.cn)("size-1.5 animate-pulse rounded-full bg-emerald-500",h&&"absolute top-1 right-1"),"aria-hidden":!0})]})}),(0,b.jsx)(T.TooltipContent,{children:f})]})}var bv=a.i(6015),bw=a.i(56979);let bx={input:"Uncached input",cacheWrite:"Cache write",cacheWrite1h:"Cache write (1h)",cacheRead:"Cache read",output:"Output"},by=[["Uncached input","new prompt text the model had not seen before."],["Cache write","context stored so later requests can reuse it. A 1-hour cache costs more to write than the default."],["Cache read","stored context reused at a discount. The whole conversation is re-sent on every request, so this grows fastest in long sessions."],["Output","the model's replies, tool calls and reasoning."]];function bz(a){return`$${a.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4})}`}function bA({cost:a,totalLabel:d}){let e=a.byModel.length>1,f=a.unpricedModels.length>0;return(0,b.jsx)("div",{className:"overflow-hidden rounded-lg border border-border",children:(0,b.jsxs)(bv.Table,{className:"text-xs",children:[(0,b.jsx)(bv.TableHeader,{children:(0,b.jsxs)(bv.TableRow,{className:"bg-muted/60 hover:bg-muted/60",children:[(0,b.jsx)(bv.TableHead,{className:"h-8 px-3 text-muted-foreground",children:"Token type"}),(0,b.jsx)(bv.TableHead,{className:"h-8 px-3 text-right text-muted-foreground",children:"Tokens"}),(0,b.jsx)(bv.TableHead,{className:"h-8 px-3 text-right text-muted-foreground",children:"Rate / 1M"}),(0,b.jsx)(bv.TableHead,{className:"h-8 px-3 text-right text-muted-foreground",children:"Cost"})]})}),(0,b.jsx)(bv.TableBody,{className:"tabular-nums",children:a.byModel.map(d=>(0,b.jsxs)(c.Fragment,{children:[(0,b.jsxs)(bv.TableRow,{className:"bg-muted/30 hover:bg-muted/30",children:[(0,b.jsx)(bv.TableHead,{colSpan:3,scope:"rowgroup",className:"h-auto px-3 py-1.5 font-mono font-semibold",children:d.model}),(0,b.jsx)(bv.TableCell,{className:"px-3 py-1.5 text-right font-mono font-semibold text-foreground",children:e&&null!==d.costUSD&&(0,as.formatCost)(d.costUSD)})]}),a.lines.filter(a=>a.model===d.model).map(a=>(0,b.jsxs)(bv.TableRow,{className:"border-border/60",children:[(0,b.jsx)(bv.TableCell,{className:"px-3 py-1.5 text-foreground",children:bx[a.kind]}),(0,b.jsx)(bv.TableCell,{className:"px-3 py-1.5 text-right font-mono",children:a.tokens.toLocaleString()}),(0,b.jsx)(bv.TableCell,{className:"px-3 py-1.5 text-right font-mono",children:null===a.rate?"—":bz(a.rate)}),(0,b.jsx)(bv.TableCell,{className:"px-3 py-1.5 text-right font-mono text-foreground",children:null===a.usd?(0,b.jsx)("span",{className:"font-sans text-muted-foreground",children:"no price"}):(0,as.formatCost)(a.usd)})]},`${a.kind}-${a.rate}`))]},d.model))}),(0,b.jsx)(bv.TableFooter,{className:"bg-muted/60",children:(0,b.jsxs)(bv.TableRow,{className:"hover:bg-transparent",children:[(0,b.jsx)(bv.TableHead,{colSpan:3,scope:"row",className:"h-auto px-3 py-2 font-semibold",children:d}),(0,b.jsxs)(bv.TableCell,{className:"px-3 py-2 text-right font-mono font-bold tabular-nums text-foreground",children:[(0,as.formatCost)(a.totalUSD),f&&"+"]})]})})]})})}function bB({cost:a,open:d,onOpenChange:e}){let f,g=a.unpricedModels.length>0,h=(f=Object.entries(a.prices).map(([a,b])=>{let c=(b??[{input:0,output:0}]).map(a=>` ${JSON.stringify(a).replace(/([{,:])/g,"$1 ").replace("}"," }")}`).join(",\n");return` ${JSON.stringify(a)}: [
|
|
2
2
|
${c}
|
|
3
3
|
]`}),`{
|
|
4
4
|
${f.join(",\n")}
|
|
5
|
-
}`),[i,j]=(0,c.useState)(g);return(0,b.jsx)(a4.Dialog,{open:d,onOpenChange:e,children:(0,b.jsxs)(a4.DialogContent,{className:"sm:max-w-xl",children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(a4.DialogTitle,{children:"How this cost is estimated"}),(0,b.jsx)(a4.DialogDescription,{children:"This is what the session’s tokens would cost on the pay-per-token API at list prices. It is not a bill: on a subscription or a request-based plan you pay your plan price, however many tokens a session uses."})]}),(0,b.jsx)(a8,{cost:a,totalLabel:a.inherited?"This session":"Total"}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Each row is tokens ÷ 1,000,000 × rate, using the list price on the day of the request.",g&&(0,b.jsxs)(b.Fragment,{children:[" ","No price is known for ",a.unpricedModels.join(", "),", so the total leaves ",a.unpricedModels.length>1?"them":"it"," out."]})]}),a.inherited&&(0,b.jsxs)("div",{className:"space-y-2 border-t border-border pt-3",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("h3",{className:"text-sm font-medium text-foreground",children:"Inherited from the forked session"}),(0,b.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"This session is a fork, so it opens with a copy of its parent’s history. Those requests were made, and are counted, in the parent session; they are listed here for reference and are not part of this session’s cost or of any usage total."})]}),(0,b.jsx)(a8,{cost:a.inherited,totalLabel:"Inherited"})]}),(0,b.jsx)("dl",{className:"space-y-1.5 border-t border-border pt-3 text-xs leading-relaxed text-muted-foreground",children:a6.map(([a,c])=>(0,b.jsxs)("div",{children:[(0,b.jsxs)("dt",{className:"inline font-medium text-foreground",children:[a,": "]}),(0,b.jsx)("dd",{className:"inline",children:c})]},a))}),(0,b.jsxs)("div",{className:"overflow-hidden rounded-lg border border-border bg-card text-xs",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>j(!i),"aria-expanded":i,"aria-controls":"cost-dialog-prices",className:"flex w-full items-center gap-2 px-3 py-2 text-left font-medium text-foreground transition-colors hover:bg-muted/60 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",children:[(0,b.jsx)(E.ChevronRight,{className:(0,$.cn)("size-3.5 shrink-0 text-muted-foreground transition-transform",i&&"rotate-90"),"aria-hidden":!0}),g?"Add the missing price":"Change these prices"]}),(0,b.jsxs)("div",{id:"cost-dialog-prices",hidden:!i,className:"space-y-2 border-t border-border px-3 py-3 leading-relaxed text-muted-foreground",children:[(0,b.jsxs)("p",{children:["Save the block below as"," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:a.overridePath})," ","and edit the numbers. It replaces the bundled price for the models it lists and takes effect on the next page load."]}),(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("pre",{className:"overflow-x-auto rounded-lg border border-border bg-muted/50 p-3 pr-10 font-mono text-[11px] leading-relaxed text-foreground",children:h}),(0,b.jsx)(s.CopyButton,{value:h,label:"Copy pricing.json",className:"absolute top-1.5 right-1.5"})]}),(0,b.jsxs)("ul",{className:"list-disc space-y-1 pl-4",children:[(0,b.jsx)("li",{children:"All prices are US dollars per million tokens."}),(0,b.jsxs)("li",{children:[(0,b.jsx)("code",{className:"font-mono text-foreground",children:"input"})," and"," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"output"})," are required. ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheRead"}),","," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheWrite"})," and"," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheWrite1h"})," ","are optional: the first two fall back to the input price, and ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheWrite1h"})," ","to ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheWrite"}),"."," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"fast"})," multiplies every price for requests made in a faster, premium speed tier."]}),(0,b.jsxs)("li",{children:["To record a price change, add a second entry with"," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:'"from": "YYYY-MM-DD"'}),". Requests before that day keep the old price."]})]})]})]})]})})}let ba=Object.keys(a5);function bb({events:a,partial:d,onOpenEvent:e}){let{turns:f,totalUSD:g,inheritedUSD:h}=(0,c.useMemo)(()=>W(a),[a]),[i,j]=(0,c.useState)(null);if(f.length<2||g<=0)return null;let k=null!==i&&i<f.length?i:null,l=(0,a3.niceCeil)(Math.max(...f.map(a=>a.costUSD))),m=(0,a3.niceCeil)(g),n=f.reduce((a,b)=>b.costUSD>a.costUSD?b:a),o=a=>`${Math.round(a/g*100)}%`,p=a=>0===a?"Before the first prompt":`Turn ${a}`,q=Math.floor((f.length-1)/2),r=null===k?null:f[k],s=r?[...new Set(r.lines.map(a=>a.model))]:[],t=null===k?0:(k+.5)/f.length*100,u=f.reduce((a,b,c)=>`${a} H${c+.5} V${100-b.totalUSD/m*100}`,"M0,100")+` H${f.length}`;return(0,b.jsxs)("section",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsx)("div",{className:"mb-4 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:(0,b.jsxs)("h2",{className:"text-sm font-semibold text-foreground",children:["Cost by turn",(0,b.jsx)("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:"a turn is one prompt and everything the agent did to answer it"})]})}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsxs)("div",{className:"flex h-40 flex-col justify-between text-right text-[10px] leading-none tabular-nums text-emerald-700 dark:text-emerald-400",children:[(0,b.jsx)("span",{children:(0,X.formatCost)(l)}),(0,b.jsx)("span",{children:(0,X.formatCost)(l/2)}),(0,b.jsx)("span",{children:"$0"})]}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("div",{className:(0,$.cn)("relative flex h-40 items-end border-b border-border",f.length>80?"gap-0":"gap-[2px]"),onMouseLeave:()=>j(null),children:[(0,b.jsx)("span",{className:"pointer-events-none absolute inset-x-0 top-0 border-t border-dashed border-border"}),(0,b.jsx)("span",{className:"pointer-events-none absolute inset-x-0 top-1/2 border-t border-dashed border-border"}),f.map((a,c)=>(0,b.jsxs)("button",{type:"button",onMouseEnter:()=>j(c),onFocus:()=>j(c),onBlur:()=>j(null),onClick:()=>e(a.eventId),"aria-label":`${p(a.turn)}: ${(0,X.formatCost)(a.costUSD)}, ${(0,X.formatCost)(a.totalUSD)} so far. Open in the timeline.`,className:(0,$.cn)("relative flex h-full min-w-0 flex-1 cursor-pointer flex-col justify-end focus-visible:outline-2 focus-visible:outline-ring",null!==k&&k!==c&&"opacity-50"),children:[a.compacted&&(0,b.jsx)("span",{className:"absolute top-1 left-1/2 size-1.5 -translate-x-1/2 rotate-45 bg-amber-500","aria-hidden":!0}),(0,b.jsx)("span",{className:"w-full rounded-t-[3px] bg-emerald-500/60 dark:bg-emerald-500/50",style:{height:`${a.costUSD/l*100}%`,minHeight:2*(a.costUSD>0)}})]},a.eventId)),(0,b.jsx)("svg",{className:"pointer-events-none absolute inset-0 size-full overflow-visible text-foreground",viewBox:`0 0 ${f.length} 100`,preserveAspectRatio:"none","aria-hidden":!0,children:(0,b.jsx)("path",{d:u,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"})}),r&&(0,b.jsxs)("div",{role:"status",className:"pointer-events-none absolute top-full z-20 mt-2 w-80 max-w-full rounded-lg border border-border bg-popover p-3 text-xs text-popover-foreground shadow-lg",style:{left:`${t}%`,transform:`translateX(-${t}%)`},children:[(0,b.jsxs)("div",{className:"flex items-baseline justify-between gap-3 tabular-nums",children:[(0,b.jsxs)("span",{className:"font-semibold",children:[p(r.turn)," · ",(0,X.formatCost)(r.costUSD)]}),(0,b.jsxs)("span",{className:"text-muted-foreground",children:[o(r.costUSD)," of the session"]})]}),(0,b.jsx)("p",{className:"mt-0.5 truncate text-muted-foreground",children:(0,X.firstLine)(r.prompt)??"Requests made before the first prompt."}),(0,b.jsxs)("table",{className:"mt-2 w-full border-t border-border tabular-nums",children:[(0,b.jsx)("thead",{children:(0,b.jsxs)("tr",{className:"text-[10px] text-muted-foreground",children:[(0,b.jsx)("th",{className:"pt-1.5 pb-0.5 text-left font-normal",children:"Token type"}),(0,b.jsx)("th",{className:"pt-1.5 pb-0.5 text-right font-normal",children:"Tokens"}),(0,b.jsx)("th",{className:"pt-1.5 pb-0.5 text-right font-normal",children:"Rate / 1M"}),(0,b.jsx)("th",{className:"pt-1.5 pb-0.5 text-right font-normal",children:"Cost"})]})}),(0,b.jsx)("tbody",{children:s.map(a=>(0,b.jsxs)(c.Fragment,{children:[s.length>1&&(0,b.jsx)("tr",{children:(0,b.jsx)("th",{colSpan:4,scope:"rowgroup",className:"max-w-0 truncate pt-1.5 text-left font-mono font-semibold",children:a})}),r.lines.filter(b=>b.model===a).sort((a,b)=>ba.indexOf(a.kind)-ba.indexOf(b.kind)).map(a=>(0,b.jsxs)("tr",{children:[(0,b.jsx)("td",{className:"py-0.5",children:a5[a.kind]}),(0,b.jsx)("td",{className:"py-0.5 pl-2 text-right font-mono",children:a.tokens.toLocaleString()}),(0,b.jsx)("td",{className:"py-0.5 pl-2 text-right font-mono text-muted-foreground",children:null===a.rate?"—":a7(a.rate)}),(0,b.jsx)("td",{className:"py-0.5 pl-2 text-right font-mono",children:null===a.usd?(0,b.jsx)("span",{className:"font-sans text-muted-foreground",children:"no price"}):(0,X.formatCost)(a.usd)})]},`${a.kind}-${a.rate}`))]},a))})]}),(0,b.jsxs)("p",{className:"mt-2 border-t border-border pt-1.5 tabular-nums text-muted-foreground",children:[1===s.length&&(0,b.jsxs)("span",{className:"font-mono",children:[s[0]," · "]}),r.requests," ",1===r.requests?"request":"requests"," ·"," ",(0,X.formatCost)(r.totalUSD)," so far",r.compacted&&" · context compacted"]})]})]}),(0,b.jsxs)("div",{className:"mt-1.5 flex justify-between text-[10px] text-muted-foreground",children:[(0,b.jsx)("span",{children:p(f[0].turn)}),f.length>4&&(0,b.jsx)("span",{children:f[q].turn}),(0,b.jsx)("span",{children:f[f.length-1].turn})]})]}),(0,b.jsxs)("div",{className:"flex h-40 flex-col justify-between text-[10px] leading-none tabular-nums text-muted-foreground",children:[(0,b.jsx)("span",{children:(0,X.formatCost)(m)}),(0,b.jsx)("span",{children:(0,X.formatCost)(m/2)}),(0,b.jsx)("span",{children:"$0"})]})]}),(0,b.jsxs)("div",{className:"mt-3 space-y-1 text-xs",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5",children:[(0,b.jsxs)("span",{className:"font-medium tabular-nums",children:["Whole session · ",(0,X.formatCost)(g),d&&"+"]}),(0,b.jsxs)("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,b.jsx)("span",{className:"size-2.5 rounded-[3px] bg-emerald-500/60","aria-hidden":!0}),"cost of the turn (left axis)"]}),(0,b.jsxs)("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,b.jsx)("span",{className:"w-3 border-t-2 border-foreground","aria-hidden":!0}),"running total (right axis)"]}),f.some(a=>a.compacted)&&(0,b.jsxs)("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,b.jsx)("span",{className:"size-1.5 rotate-45 bg-amber-500","aria-hidden":!0}),"context compacted"]})]}),(0,b.jsxs)("p",{className:"truncate text-muted-foreground",children:[p(n.turn)," cost the most: ",(0,X.formatCost)(n.costUSD),","," ",o(n.costUSD)," of the session. Hover a bar for its tokens and prices; click it to open the turn in the timeline."]}),h>0&&(0,b.jsxs)("p",{className:"text-muted-foreground",children:["Not charted: ",(0,X.formatCost)(h)," of history copied from the forked session, shown as Inherited in the timeline. The parent session was billed for it."]})]})]})}let bc=[{key:"input",label:"Uncached input"},{key:"cacheWrite",label:"Cache write"},{key:"cacheRead",label:"Cache read"},{key:"output",label:"Output"}],bd=["Context",...bc.map(a=>a.label),"Cost"];function be(a){return{input:a.inputTokens,cacheWrite:a.cacheWriteTokens,cacheRead:a.cacheReadTokens,output:a.outputTokens}}function bf(a){let b={tokens:{input:0,cacheWrite:0,cacheRead:0,output:0},usd:{input:null,cacheWrite:null,cacheRead:null,output:null},costUSD:null};for(let c of a){let a=be(c);for(let{key:d}of bc){b.tokens[d]+=a[d];let e=c.usd[d];null!==e&&(b.usd[d]=(b.usd[d]??0)+e)}null!==c.costUSD&&(b.costUSD=(b.costUSD??0)+c.costUSD)}return b}function bg(a){return a>=.01?(0,X.formatCost)(a):a<1e-4?"<$0.0001":`$${a.toFixed(4)}`}function bh({tokens:a,usd:c,unit:d,sticky:e}){return bc.map(({key:f,label:g})=>{let h=a[f],i=c[f],j=null===i?"no price":bg(i);return(0,b.jsx)(a2.TableCell,{className:(0,$.cn)("py-1.5 pr-0 pl-3 text-right",e),title:h>0?`${g}: ${h.toLocaleString()} tokens, ${j}`:void 0,children:0===h?"—":"tokens"===d?(0,X.formatTokens)(h):null===i?(0,b.jsx)("span",{className:"font-sans",children:"no price"}):bg(i)},f)})}function bi({value:a,max:c}){return(0,b.jsxs)(a2.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",title:a.toLocaleString(),children:[(0,X.formatTokens)(a)??"—",(0,b.jsx)("span",{className:"mt-0.5 block h-0.5 overflow-hidden rounded-full bg-muted","aria-hidden":!0,children:(0,b.jsx)("span",{className:"block h-full rounded-full bg-emerald-500/70",style:{width:`${c>0?a/c*100:0}%`}})})]})}let bj="sticky top-0 z-10 bg-card shadow-[inset_0_-1px_0_var(--border)]",bk="sticky bottom-0 z-10 bg-card shadow-[inset_0_1px_0_var(--border)]";function bl({value:a,className:c}){return(0,b.jsx)(a2.TableCell,{className:(0,$.cn)("py-1.5 pr-0 pl-3 text-right text-foreground",c),children:null===a?(0,b.jsx)("span",{className:"font-sans font-normal text-muted-foreground",children:"no price"}):(0,X.formatCost)(a)})}function bm({events:a,onOpenEvent:d}){let{requests:e,turns:f}=(0,c.useMemo)(()=>W(a),[a]),[g,h]=(0,c.useState)({allOpen:null,flipped:new Set}),[i,j]=(0,c.useState)("tokens"),k=(0,c.useMemo)(()=>{let a=new Map;for(let b of e){let c=a.get(b.turn);c?c.push(b):a.set(b.turn,[b])}let b=new Map(f.map(a=>[a.turn,a.prompt]));return[...a].map(([a,c])=>({turn:a,rows:c,prompt:b.get(a),totals:bf(c)}))},[e,f]);if(e.length<2)return null;let l=g.allOpen??e.length<=60,m=a=>l!==g.flipped.has(a),n=Math.max(...e.map(a=>a.contextTokens)),o=bf(e),q=new Set(e.flatMap(a=>a.models)).size>1,r=o.tokens.cacheRead>0,s=k.some(a=>m(a.turn)),t=null!==o.costUSD;return(0,b.jsxs)("section",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsxs)("div",{className:"mb-2 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[(0,b.jsxs)("h2",{className:"text-sm font-semibold text-foreground",children:["Requests",(0,b.jsx)("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:"every call to the model, grouped by turn"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[t&&(0,b.jsx)(V.Segmented,{label:"Show each token class as",value:i,onChange:j,options:[{value:"tokens",label:"Tokens"},{value:"cost",label:"Cost"}]}),(0,b.jsx)(p.Button,{variant:"outline",size:"sm",onClick:()=>h({allOpen:!s,flipped:new Set}),children:s?"Collapse all":"Expand all"})]})]}),(0,b.jsxs)("p",{className:"mb-3 max-w-3xl text-xs leading-relaxed text-muted-foreground",children:["Each tool round is its own request, and every request sends the whole conversation again."," ",(0,b.jsx)("span",{className:"text-foreground",children:"Context"})," is what one request sent: cache read (already stored), cache write (new since the last request, stored for the next) and uncached input. A turn row adds up its requests, so its cache read is the context multiplied by the number of requests, not the size of the context."]}),(0,b.jsx)("div",{className:"[&>[data-slot=table-container]]:max-h-[70vh] [&>[data-slot=table-container]]:overflow-y-auto",children:(0,b.jsxs)(a2.Table,{className:"min-w-[47rem] table-fixed text-xs",children:[(0,b.jsxs)("colgroup",{children:[(0,b.jsx)("col",{}),bd.map(a=>(0,b.jsx)("col",{className:"Cost"===a?"w-20":"Uncached input"===a?"w-28":"w-24"},a))]}),(0,b.jsx)(a2.TableHeader,{children:(0,b.jsxs)(a2.TableRow,{className:"hover:bg-transparent",children:[(0,b.jsx)(a2.TableHead,{className:(0,$.cn)("h-8 px-0 text-muted-foreground",bj),children:"Turn / request"}),bd.map(a=>(0,b.jsx)(a2.TableHead,{className:(0,$.cn)("h-8 pr-0 pl-3 text-right text-muted-foreground",bj),children:a},a))]})}),(0,b.jsx)(a2.TableBody,{className:"font-mono tabular-nums",children:k.map(({turn:a,rows:f,prompt:g,totals:j})=>{let k=m(a),l=f[f.length-1];return(0,b.jsxs)(c.Fragment,{children:[(0,b.jsxs)(a2.TableRow,{className:"border-border/60 bg-muted/40 font-semibold hover:bg-muted/60",children:[(0,b.jsx)(a2.TableCell,{className:"truncate px-0 py-1.5 font-sans",children:(0,b.jsxs)("button",{type:"button",onClick:()=>h(({allOpen:b,flipped:c})=>{let d=new Set(c);return d.delete(a)||d.add(a),{allOpen:b,flipped:d}}),"aria-expanded":k,className:"flex w-full min-w-0 cursor-pointer items-center gap-1.5 rounded-sm text-left text-foreground focus-visible:outline-2 focus-visible:outline-ring",children:[(0,b.jsx)(E.ChevronRight,{className:(0,$.cn)("size-3.5 shrink-0 transition-transform",k&&"rotate-90"),"aria-hidden":!0}),(0,b.jsx)("span",{className:"shrink-0",children:0===a?"Before the first prompt":`Turn ${a}`}),(0,b.jsxs)("span",{className:"shrink-0 font-normal tabular-nums text-muted-foreground",children:[f.length," ",1===f.length?"request":"requests"]}),(0,b.jsx)("span",{className:"min-w-0 truncate font-normal text-muted-foreground",children:(0,X.firstLine)(g)})]})}),(0,b.jsx)(bi,{value:l.contextTokens,max:n}),(0,b.jsx)(bh,{tokens:j.tokens,usd:j.usd,unit:i}),(0,b.jsx)(bl,{value:j.costUSD})]}),k&&f.map(a=>{let c=e[a.n-2],f=r&&void 0!==c&&a.cacheReadTokens<c.contextTokens/2&&a.inputTokens+a.cacheWriteTokens>a.cacheReadTokens;return(0,b.jsxs)(a2.TableRow,{className:"group border-border/60 text-muted-foreground",children:[(0,b.jsxs)(a2.TableCell,{className:"truncate py-1.5 pr-0 pl-5",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>d(a.eventId),"aria-label":`Request ${a.n}: open in the timeline`,title:"Open in the timeline",className:"inline-flex cursor-pointer items-center gap-1 rounded-sm text-foreground underline-offset-2 hover:text-brand hover:underline focus-visible:outline-2 focus-visible:outline-ring",children:["#",a.n,(0,b.jsx)(z,{className:"size-3 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100","aria-hidden":!0})]}),q&&(0,b.jsx)("span",{className:"ml-2",children:a.models.join(", ")}),f&&(0,b.jsx)("span",{className:"ml-2 rounded-sm bg-amber-500/15 px-1.5 py-0.5 font-sans text-[10px] text-amber-700 dark:text-amber-400",title:"Little of the context came from the cache, so it was sent and stored again at the higher rate. This follows a compaction, a change to the early context, or a pause longer than the cache lifetime.",children:"cache miss"})]}),(0,b.jsx)(bi,{value:a.contextTokens,max:n}),(0,b.jsx)(bh,{tokens:be(a),usd:a.usd,unit:i}),(0,b.jsx)(bl,{value:a.costUSD})]},a.eventId)})]},a)})}),(0,b.jsx)(a2.TableFooter,{className:"bg-transparent font-mono tabular-nums",children:(0,b.jsxs)(a2.TableRow,{className:"hover:bg-transparent",children:[(0,b.jsxs)(a2.TableCell,{className:(0,$.cn)("truncate px-0 py-1.5 font-sans text-foreground",bk),children:["Whole session",(0,b.jsxs)("span",{className:"ml-1.5 font-normal text-muted-foreground",children:[e.length," requests, context peaked at ",(0,X.formatTokens)(n)]})]}),(0,b.jsx)(a2.TableCell,{className:(0,$.cn)("py-1.5 pr-0 pl-3",bk)}),(0,b.jsx)(bh,{tokens:o.tokens,usd:o.usd,unit:i,sticky:bk}),(0,b.jsx)(bl,{value:o.costUSD,className:(0,$.cn)("font-semibold",bk)})]})})]})}),(0,b.jsxs)("p",{className:"mt-3 text-xs text-muted-foreground",children:["Click a request number to open it in the timeline. Hover a value for its exact token count and cost",t&&", or switch the columns between tokens and cost","."]})]})}function bn({cost:a}){let[d,e]=(0,c.useState)(!1);if(0===a.byModel.length)return null;let f=[{label:"Output",note:"replies + reasoning",usd:a.breakdown.output,bar:"bg-sky-400 dark:bg-sky-500"},{label:"Cache writes",note:"new context stored",usd:a.breakdown.cacheWrite,bar:"bg-amber-400 dark:bg-amber-500"},{label:"Cache reads",note:"context re-sent each turn",usd:a.breakdown.cacheRead,bar:"bg-emerald-400 dark:bg-emerald-500"},{label:"Uncached input",usd:a.breakdown.input,bar:"bg-red-400 dark:bg-red-500"}].filter(a=>a.usd>0),g=a.byModel.reduce((a,b)=>a+b.cacheReadTokens,0),h=a.byModel.reduce((a,b)=>a+b.inputTokens+b.cacheWriteTokens+b.cacheReadTokens,0),i=a.unpricedModels.length>0;return(0,b.jsxs)("section",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsxs)("div",{className:"mb-4 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[(0,b.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Estimated cost"}),(0,b.jsxs)("span",{className:"font-mono text-lg font-bold tabular-nums text-foreground",children:[(0,X.formatCost)(a.totalUSD),i&&"+"]})]}),a.totalUSD>0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"mb-4 flex h-2.5 overflow-hidden rounded-full bg-muted",children:f.map(({label:c,usd:d,bar:e})=>(0,b.jsx)("div",{className:e,style:{width:`${d/a.totalUSD*100}%`}},c))}),(0,b.jsx)("div",{className:"grid gap-x-6 gap-y-2 sm:grid-cols-2",children:f.map(({label:c,note:d,usd:e,bar:f})=>(0,b.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,b.jsx)("span",{className:(0,$.cn)("size-2 shrink-0 rounded-full",f),"aria-hidden":!0}),(0,b.jsxs)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:[c,d&&(0,b.jsxs)("span",{className:"ml-1 hidden text-muted-foreground sm:inline",children:["(",d,")"]})]}),(0,b.jsx)("span",{className:"font-mono font-semibold tabular-nums text-foreground",children:(0,X.formatCost)(e)}),(0,b.jsxs)("span",{className:"w-9 text-right tabular-nums text-muted-foreground",children:[Math.round(e/a.totalUSD*100),"%"]})]},c))})]}),(0,b.jsx)("div",{className:"mt-4 border-t border-border pt-1.5",children:(0,b.jsxs)(a2.Table,{className:"text-xs",children:[(0,b.jsx)(a2.TableHeader,{children:(0,b.jsx)(a2.TableRow,{className:"hover:bg-transparent",children:["Model","Input","Cache write","Cache read","Output","Cost"].map((a,c)=>(0,b.jsx)(a2.TableHead,{className:(0,$.cn)("h-8 px-0 text-muted-foreground",c>0&&"pl-3 text-right"),children:a},a))})}),(0,b.jsx)(a2.TableBody,{className:"font-mono tabular-nums",children:a.byModel.map(a=>(0,b.jsxs)(a2.TableRow,{className:"border-border/60",children:[(0,b.jsx)(a2.TableCell,{className:"px-0 py-1.5 text-foreground",children:a.model}),(0,b.jsx)(a2.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",children:(0,X.formatTokens)(a.inputTokens)??"—"}),(0,b.jsx)(a2.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",children:(0,X.formatTokens)(a.cacheWriteTokens)??"—"}),(0,b.jsx)(a2.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",children:(0,X.formatTokens)(a.cacheReadTokens)??"—"}),(0,b.jsx)(a2.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",children:(0,X.formatTokens)(a.outputTokens)??"—"}),(0,b.jsx)(a2.TableCell,{className:"py-1.5 pr-0 pl-3 text-right font-semibold text-foreground",children:null===a.costUSD?(0,b.jsx)("span",{className:"font-sans font-normal text-muted-foreground",children:"no price"}):(0,X.formatCost)(a.costUSD)})]},a.model))})]})}),(0,b.jsxs)("p",{className:"mt-3 text-xs leading-relaxed text-muted-foreground",children:[h>0&&g>0&&(0,b.jsxs)(b.Fragment,{children:[Math.round(g/h*100),"% of input was served from cache."," "]}),"API-equivalent estimate at list prices on the day of each request, not a bill: subscription and request-based plans charge differently."," ",(0,b.jsx)(p.Button,{variant:"link",onClick:()=>e(!0),"aria-haspopup":"dialog",className:"inline h-auto rounded-sm p-0 text-xs text-foreground underline underline-offset-2 hover:text-brand",children:"See the rates and arithmetic"}),i&&(0,b.jsxs)(b.Fragment,{children:[" ","No price is known for ",a.unpricedModels.join(", "),", so the total leaves ",a.unpricedModels.length>1?"them":"it"," out; add one in"," ",(0,b.jsx)("code",{className:"font-mono",children:"~/.agent-session-inspector/pricing.json"}),"."]})]}),(0,b.jsx)(a9,{cost:a,open:d,onOpenChange:e})]})}function bo({cost:a,events:c,onOpenEvent:d}){return 0===a.byModel.length?(0,b.jsx)("p",{className:"rounded-xl border border-border bg-card p-5 text-xs text-muted-foreground",children:"This session recorded no token usage, so there is nothing to price."}):(0,b.jsxs)("div",{className:"space-y-6",children:[(0,b.jsx)(bn,{cost:a}),(0,b.jsx)(bb,{events:c,partial:a.unpricedModels.length>0,onOpenEvent:d}),(0,b.jsx)(bm,{events:c,onOpenEvent:d})]})}var bp=a.i(90892);let bq=/(?<!<)<<(?!<)-?\s*(['"]?)([A-Za-z_]\w*)\1/g,br=/^__heredoc_(\d+)__$/,bs=new Set(["sudo","command","env","time","nohup","exec","xargs"]),bt=/^(ba|z|da)?sh$/,bu=/^(python[\d.]*|node|bun|deno)$/,bv=a=>a.startsWith("-");function bw(a,b=/^-[a-zA-Z]*[ef]$|^--(expression|file)$/){let c=[],d=!1;for(let e=0;e<a.length;e++)b.test(a[e])?(d=!0,e++):bv(a[e])||""===a[e]||c.push(a[e]);return{files:c,scripted:d}}let bx=String.raw`(?:(['"\`])([^'"\`\n]+)\1|([A-Za-z_$][\w$]*))`,by=[RegExp(String.raw`\bopen\(\s*${bx}\s*,\s*(?:mode\s*=\s*)?['"](?=[^'"]*[wax+])[rwaxbt+]+['"]`,"g"),RegExp(String.raw`\bPath\(\s*${bx}\s*\)\s*\.write_(?:text|bytes)\(`,"g"),RegExp(String.raw`\b(?:write|append)File(?:Sync)?\(\s*${bx}`,"g")],bz=/^(\/dev\/|\/tmp\/|\/private\/tmp\/|\/var\/folders\/|\/private\/var\/folders\/)/,bA=a=>""!==a&&"-"!==a&&!/[$`*?{}]/.test(a)&&!a.startsWith("~")&&!bz.test(a);function bB(a,b){if(b.startsWith("/")||!a)return b.replace(/^(\.\/)+/,"");let c=a.split("/");for(let a of b.split("/"))".."===a?c.pop():"."!==a&&""!==a&&c.push(a);return c.join("/")}let bC=["file_path","filePath","notebook_path","path","target_file"],bD=/^(edit|write|multiedit|notebookedit|update|create|patch|apply_patch|replace|search_replace|str_replace\w*|(copilot_)?(write|edit|create|replace|insert)\w*(file|string|edit|notebook)\w*)$/i,bE=/^(bash|sh|zsh|shell|exec|exec_command|shell_command|local_shell|terminal|run_in_terminal|run_terminal_cmd|run_terminal_command\w*|run_shell_command|run_command|execute_command|container\.exec)$/i,bF=/^\*\*\* (?:Add|Update|Delete) File: (.+)$/gm,bG=a=>[...new Set([...a.matchAll(bF)].map(a=>a[1].trim()))];function bH(a,b){let c=new Set;for(let b of a)"file.patch_applied"===b.type&&b.data.callId&&c.add(b.data.callId);let d=[],e={turn:0,timestamp:a[0]?.timestamp??"",files:[],edits:0},f=0,g=(a,b,c)=>{0===e.files.length&&d.push(e),e.edits++;let f=e.files.find(a=>a.path===b);f?(f.count++,f.tools.includes(c)||f.tools.push(c)):e.files.push({path:b,count:1,tools:[c],eventId:a.id})};for(let d of a)if("user.message"===d.type)e={turn:++f,prompt:"string"==typeof d.data.content?d.data.content:void 0,promptEventId:d.id,timestamp:d.timestamp,files:[],edits:0};else if("file.patch_applied"===d.type){if(!1===d.data.success)continue;for(let a of d.data.changes??[])a?.file&&g(d,a.file,"patch")}else if("tool.execution_start"===d.type){let a=function(a){let b=a.toolName??a.name;return"string"==typeof b?b:""}(d.data);if(c.has(d.data.toolCallId))continue;for(let c of bD.test(a)?function(a){let b=a.arguments,c=b&&"object"==typeof b?b:{};for(let a of bC){let b=c[a];if("string"==typeof b&&b)return[b]}let d="string"==typeof b?b:c.input??c.patch??c.patchText;return"string"!=typeof d?[]:bG(d)}(d.data):bE.test(a)?function(a,b){let c=function(a){let b=a.arguments;if("string"==typeof b)return b;let c=b&&"object"==typeof b?b:{},d=c.command??c.cmd??c.script??c.input;return"string"==typeof d?d:Array.isArray(d)&&d.every(a=>"string"==typeof a)?/^-l?c$/.test(d[1]??"")&&3===d.length?d[2]:d.join(" "):void 0}(a);if(!c)return[];let d=bG(c);return d.length>0?d:function a(b,c){let{shell:d,bodies:e}=function(a){let b=[],c=[],d=a.split("\n");for(let a=0;a<d.length;a++){let e=[];for(let f of(b.push(d[a].replace(bq,(a,b,d)=>(e.push(d),`<<__heredoc_${c.length+e.length-1}__`))),e)){let b=[];for(;++a<d.length&&d[a].trim()!==f;)b.push(d[a]);c.push(b.join("\n"))}}return{shell:b.join("\n"),bodies:c}}(b),f=new Set,g=c?.replace(/\/+$/,""),h=a=>{if(!bA(a))return;let b=bB(g,a);bz.test(b)||f.add(b)};for(let{words:b,writes:c,inputs:i}of function(a){let b=[],c={words:[],writes:[],inputs:[]},d=null,e="words",f=()=>{null!==d&&(c[e].push(d),d=null,e="words")},g=()=>{f(),(c.words.length>0||c.writes.length>0)&&b.push(c),c={words:[],writes:[],inputs:[]},e="words"};for(let b=0;b<a.length;b++){let c=a[b];if("\\"===c)"\n"!==a[++b]&&(d=(d??"")+(a[b]??""));else if("'"===c){let c=a.indexOf("'",b+1),e=c<0?a.length:c;d=(d??"")+a.slice(b+1,e),b=e}else if('"'===c){let c="";for(b++;b<a.length&&'"'!==a[b];b++)"\\"===a[b]&&b+1<a.length&&b++,c+=a[b];d=(d??"")+c}else if(" "===c||" "===c)f();else if("#"===c&&null===d)for(;b+1<a.length&&"\n"!==a[b+1];)b++;else if("&"===c&&">"===a[b+1])f();else if("\n"===c||";"===c||"|"===c||"&"===c||"("===c||")"===c)g();else if(">"===c){if(null!==d&&/^\d+$/.test(d)?d=null:f(),(">"===a[b+1]||"|"===a[b+1])&&b++,"&"===a[b+1]){b++;let c=/^[\d-]+/.exec(a.slice(b+1));if(c){b+=c[0].length;continue}}e="writes"}else if("<"===c){for(f();"<"===a[b+1]||"-"===a[b+1];)b++;e="inputs"}else d=(d??"")+c}return g(),b}(d)){let d=0;for(;d<b.length&&(/^\w+=/.test(b[d])||bs.has(b[d]));)d++;let j=b[d]?.split("/").pop()??"",k=b.slice(d+1),l=i.flatMap(a=>e[Number(br.exec(a)?.[1])]??[]);if("cd"===j)k[0]&&bA(k[0])&&(k[0].startsWith("/")||g)&&(g=bB(g,k[0]));else if(bt.test(j)){let b=k.findIndex(a=>/^-[a-zA-Z]*c$/.test(a));for(let c of b>=0?[k[b+1]??""]:l)a(c,g).forEach(a=>f.add(a))}else if(bu.test(j))for(let a of[...k,...l])(function(a){let b=[];for(let c of by)for(let d of a.matchAll(c)){let c=d[2]??function(a,b,c){let d,e=b.replace(/\$/g,"\\$"),f=RegExp(String.raw`(?<![\w$.])${e}\s*=\s*(['"])([^'"\n]+)\1`,"g");for(let b of a.slice(0,c).matchAll(f))d=b[2];return d}(a,d[3],d.index);c&&b.push({index:d.index,path:c})}return b.sort((a,b)=>a.index-b.index).map(a=>a.path)})(a).forEach(h);else(function(a,b){"git"===a&&("mv"===b[0]||"rm"===b[0])&&(a=b[0],b=b.slice(1));let c=b.some(a=>/^-[a-zA-Z]*[rR]/.test(a)||"--recursive"===a);switch(a){case"tee":case"touch":case"mv":return bw(b).files;case"sed":case"gsed":{if(!b.some(a=>/^-[a-zA-Z]*i/.test(a)||a.startsWith("--in-place")))return[];let{files:a,scripted:c}=bw(b);return c?a:a.slice(1)}case"perl":if(!b.some(a=>/^-[a-zA-Z]*i/.test(a)))return[];return bw(b,/^-[a-zA-Z]*e$/).files;case"rm":return c?[]:bw(b).files;case"cp":return c?[]:bw(b).files.slice(-1);default:return[]}})(j,k).forEach(h);c.forEach(h)}return[...f]}(c,b)}(d.data,b):[])g(d,c,a)}return d}let bI=(a,b)=>`${a.toLocaleString()} ${b}${1===a?"":"s"}`;function bJ({events:a,cwd:d,onOpenEvent:e}){let[f,g]=(0,c.useState)(""),h=(0,c.useMemo)(()=>bH(a,d),[a,d]),i=f.trim().toLowerCase(),j=(0,c.useMemo)(()=>i?h.map(a=>({...a,files:a.files.filter(a=>a.path.toLowerCase().includes(i))})).filter(a=>a.files.length>0):h,[h,i]);if(0===h.length)return(0,b.jsx)(bp.EmptyState,{icon:k,title:"No file edits",description:"Files appear here, grouped by prompt, when the agent writes, edits or patches one, or changes one from the shell."});let l=d?`${d.replace(/[\\/]+$/,"")}/`:null,m=new Set(h.flatMap(a=>a.files.map(a=>a.path))).size,n=h.reduce((a,b)=>a+b.edits,0);return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[m>8&&(0,b.jsx)(U.SearchInput,{value:f,onChange:g,placeholder:"Filter files…","aria-label":"Filter edited files",className:"w-full max-w-sm"}),(0,b.jsxs)("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground",children:[bI(m,"file")," · ",bI(n,"edit")," · ",bI(h.length,"turn")]})]}),j.map(a=>(0,b.jsxs)("section",{className:"overflow-hidden rounded-xl border border-border bg-card",children:[(0,b.jsxs)("header",{className:"flex items-baseline gap-3 border-b border-border bg-muted/40 px-3 py-2",children:[(0,b.jsx)("span",{className:"shrink-0 text-xs font-medium tabular-nums text-muted-foreground",children:a.turn>0?`Turn ${a.turn}`:"Start"}),a.promptEventId?(0,b.jsx)("button",{type:"button",onClick:()=>e(a.promptEventId),title:"Open this prompt in the timeline",className:"min-w-0 flex-1 truncate rounded-sm text-left text-sm font-medium hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:(0,X.firstLine)(a.prompt)??"Prompt"}):(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm text-muted-foreground",children:"Before the first prompt"}),(0,b.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[bI(a.files.length,"file")," · ",(0,X.formatDateTime)(a.timestamp)]})]}),(0,b.jsx)("ul",{children:a.files.map(a=>{let c;return(0,b.jsxs)("li",{className:"group flex items-center gap-3 border-b border-border/60 px-3 py-2 text-sm last:border-b-0 hover:bg-muted/50",children:[(0,b.jsx)("button",{type:"button",onClick:()=>e(a.eventId),title:`${a.path}
|
|
6
|
-
Open the edit in the timeline`,className:"min-w-0 flex-1 truncate rounded-sm text-left font-mono text-[13px] hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:(c=a.path,l&&c.startsWith(l)?c.slice(l.length):c)}),(0,b.jsx)("span",{className:"opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",children:(0,b.jsx)(s.CopyButton,{value:a.path,label:"Copy path"})}),(0,b.jsx)("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:a.tools.join(", ")}),(0,b.jsx)("span",{className:"w-8 shrink-0 text-right text-xs tabular-nums text-muted-foreground",children:a.count>1?`\xd7${a.count}`:""})]},a.path)})})]},a.promptEventId??"start")),0===j.length&&(0,b.jsxs)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:["No files match “",f,"”"]})]})}var bK=a.i(73946);let bL=(0,f.default)("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]),bM=(0,f.default)("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);var bN=a.i(21732);let bO=(0,f.default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),bP=(0,f.default)("folder-search",[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]);var bQ=a.i(44264),bR=a.i(14300),bS=a.i(84213);let bT=(0,f.default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);var bU=a.i(89065),bV=a.i(63167),bW=a.i(27855);function bX({health:a,open:c,onOpenChange:d,onFocus:e}){return(0,b.jsx)(a4.Dialog,{open:c,onOpenChange:d,children:(0,b.jsxs)(a4.DialogContent,{children:[(0,b.jsx)(a4.DialogTitle,{children:"Session health"}),(0,b.jsx)(a4.DialogDescription,{children:"A rule-based score read straight off the transcript. It measures how smoothly the session ran, not whether the result was any good."}),(0,b.jsxs)("div",{className:"flex items-center gap-4",children:[(0,b.jsx)(bV.GradeBadge,{grade:a.grade,className:"h-12 min-w-12 rounded-lg text-2xl"}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("div",{className:"flex items-baseline gap-1.5",children:[(0,b.jsx)("span",{className:"text-2xl font-bold leading-none tabular-nums",children:a.score}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:"/ 100"}),(0,b.jsx)("span",{className:"ml-auto text-xs font-medium",children:bW.OUTCOME_LABELS[a.outcome]})]}),(0,b.jsx)("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-muted",children:(0,b.jsx)("div",{className:(0,$.cn)("h-full rounded-full",bW.GRADE_STYLES[a.grade].bar),style:{width:`${a.score}%`}})})]})]}),0===a.signals.length?(0,b.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3 dark:border-emerald-900 dark:bg-emerald-950/30",children:[(0,b.jsx)(bU.CheckCircle2,{className:"size-4 shrink-0 text-emerald-600 dark:text-emerald-400","aria-hidden":!0}),(0,b.jsxs)("p",{className:"text-sm",children:["Nothing went wrong. ",bW.OUTCOME_NOTES[a.outcome]]})]}):(0,b.jsx)("ul",{className:"divide-y divide-border overflow-hidden rounded-lg border border-border",children:a.signals.map(c=>{let f=bW.SIGNAL_INFO[c.id];return(0,b.jsxs)("li",{className:"px-3 py-2.5",children:[(0,b.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,b.jsx)("span",{className:"text-sm font-medium",children:"outcome"===c.id?bW.OUTCOME_LABELS[a.outcome]:f.label}),(0,b.jsxs)("span",{className:"shrink-0 font-mono text-xs font-semibold tabular-nums text-red-600 dark:text-red-400",children:["−",c.penalty]})]}),(0,b.jsxs)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:[f.describe(c,a)," ",f.advice]}),f.focus&&e&&(0,b.jsxs)(p.Button,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>{d(!1),f.focus&&e(f.focus)},children:["View related events",(0,b.jsx)(bT,{"data-icon":"inline-end","aria-hidden":!0})]})]},c.id)})}),(0,b.jsxs)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:["Every session starts at 100 and loses points for each signal above. 90 and up is an A, 80 a B, 70 a C, 60 a D; anything lower is an F.",a.toolResults>0&&0===a.toolFailures&&(0,b.jsxs)(b.Fragment,{children:[" All ",a.toolResults.toLocaleString()," tool results succeeded."]})]})]})})}var bY=a.i(80153),bZ=a.i(75775);function b$(a){return a>=1e6?`${(a/1e6).toFixed(2)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:a.toLocaleString()}function b_({meta:a}){let[d,e]=(0,c.useState)(!1);async function f(){try{let b=await fetch(`/api/sessions/${a.provider}/${encodeURIComponent(a.id)}/reveal`,{method:"POST"});e(!b.ok)}catch{e(!0)}}return(0,b.jsxs)(S.Tooltip,{children:[(0,b.jsx)(S.TooltipTrigger,{render:(0,b.jsxs)(p.Button,{variant:"ghost",size:"xs",onClick:f,className:(0,$.cn)("text-muted-foreground",d&&"text-destructive"),children:[(0,b.jsx)(bP,{className:"size-3.5","aria-hidden":!0}),"Reveal"]})}),(0,b.jsx)(S.TooltipContent,{children:d?"Could not open a file manager here. Copy the path instead.":"Show this session's files in the file manager"})]})}function b0({meta:a,storagePath:e,revealable:f=!1,stats:g,cost:h,context:i,activeMs:j,running:k=!1,onFocusEvents:l}){let m=(0,X.firstLine)(a.name),n=a.title??m,o=a.title?m:void 0,[p,q]=(0,c.useState)(!1),[r,t]=(0,c.useState)(!1),u=a.health,v=(0,bY.providerStyle)(a.provider),w=(0,bZ.resumeCommand)(a),x=g?.totalInputTokens??0,y=g?.totalOutputTokens??0,z=g?.totalCacheReadTokens??0,A=x+y+z;return(0,b.jsx)("div",{className:"border-b border-border bg-card/40",children:(0,b.jsxs)("div",{className:"mx-auto max-w-6xl px-4 py-5 sm:px-6",children:[(0,b.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-4",children:[(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsx)("h1",{className:"text-lg font-bold leading-tight text-foreground sm:text-xl",children:n??(0,b.jsx)("span",{className:"font-normal italic text-muted-foreground",children:"Unnamed session"})}),o&&(0,b.jsx)("p",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:o}),(0,b.jsxs)("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",children:[(0,b.jsx)("span",{className:"truncate font-mono text-xs text-muted-foreground",children:a.id}),(0,b.jsx)(s.CopyButton,{value:a.id,label:"Copy session id"}),w&&(0,b.jsx)(s.CopyButton,{value:w,label:"Copy the command that resumes this session in a terminal",icon:bR.Terminal,className:"ml-1",children:"Resume"}),e&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(s.CopyButton,{value:e,label:`Copy where this session is stored: ${e}`,icon:bO,children:"Path"}),f&&(0,b.jsx)(b_,{meta:a})]})]})]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:shrink-0 sm:justify-end",children:[k&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-emerald-300 bg-emerald-50 px-2.5 py-0.5 text-xs font-medium text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-300",children:[(0,b.jsx)("span",{className:"size-1.5 animate-pulse rounded-full bg-emerald-500","aria-hidden":!0}),"Running"]}),(0,b.jsxs)("span",{className:(0,$.cn)("inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-xs font-medium",v.badgeCls),children:[(0,b.jsx)("span",{className:(0,$.cn)("size-1.5 rounded-full",v.dotCls),"aria-hidden":!0}),v.label]}),a.model&&(0,b.jsx)(Q.Badge,{variant:"secondary",className:"font-mono",children:a.model}),a.client_name&&(0,b.jsx)(Q.Badge,{variant:"secondary",children:a.client_name}),a.host_type&&(0,b.jsx)(Q.Badge,{variant:"outline",children:a.host_type})]})]}),(0,b.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground",children:[a.project&&(0,b.jsxs)(d.default,{href:`/?tab=sessions&project=${encodeURIComponent(a.project)}`,title:a.projectPath,className:"inline-flex min-w-0 items-center gap-1.5 rounded-sm hover:text-foreground hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:[(0,b.jsx)(bN.FolderGit2,{className:"size-3.5 shrink-0 opacity-70","aria-hidden":!0}),(0,b.jsx)("span",{className:"truncate font-medium text-foreground/80",children:a.project})]}),a.repository&&(0,b.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[(0,b.jsx)(bM,{className:"size-3.5 shrink-0 opacity-70","aria-hidden":!0}),(0,b.jsx)("span",{className:"truncate font-mono text-foreground/80",children:a.repository})]}),a.branch&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,b.jsx)(bQ.GitBranch,{className:"size-3.5 opacity-70","aria-hidden":!0}),(0,b.jsx)("span",{className:"font-mono",children:a.branch})]}),a.created_at&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,b.jsx)(bK.CalendarDays,{className:"size-3.5 opacity-70","aria-hidden":!0}),(0,X.formatFullDateTime)(a.created_at)]}),a.updated_at&&(0,b.jsxs)(S.Tooltip,{children:[(0,b.jsx)(S.TooltipTrigger,{render:(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,b.jsx)(bL,{className:"size-3.5 opacity-70","aria-hidden":!0}),"Updated ",(0,X.timeAgo)(a.updated_at)]})}),(0,b.jsx)(S.TooltipContent,{children:(0,X.formatFullDateTime)(a.updated_at)})]})]}),g&&(0,b.jsxs)("div",{className:"mt-4",children:[(0,b.jsxs)(bS.StatCardGrid,{children:[(0,b.jsx)(bS.StatCard,{label:"Events",value:g.eventCount.toLocaleString(),sub:"recorded in session"}),(0,b.jsx)(bS.StatCard,{label:"Messages",value:(g.totalUserMessages+g.totalAssistantMessages).toLocaleString(),sub:`${g.totalUserMessages} user \xb7 ${g.totalAssistantMessages} assistant`}),(0,b.jsx)(bS.StatCard,{label:"Tool calls",value:g.totalToolCalls.toLocaleString(),sub:"local + external"}),(0,b.jsx)(bS.StatCard,{label:"Total tokens",value:A>0?b$(A):"—",sub:"in + out + cache",accent:!0}),i&&(0,b.jsx)(bS.StatCard,{label:"Context",value:b$(i.latest),sub:i.peak>i.latest?`sent by the last request \xb7 peak ${b$(i.peak)}`:"sent by the last request"}),h&&(h.inherited||h.byModel.some(a=>null!==a.costUSD))&&(0,b.jsx)(bS.StatCard,{label:"Est. cost",value:`${(0,X.formatCost)(h.totalUSD)}${h.unpricedModels.length>0?"+":""}`,sub:h.unpricedModels.length>0?`excludes ${h.unpricedModels.join(", ")}`:h.inherited?`+ ${(0,X.formatCost)(h.inherited.totalUSD)} inherited`:"at API list prices",onClick:()=>q(!0)}),u&&(0,b.jsx)(bS.StatCard,{label:"Health",value:(0,bW.healthSummary)(u),sub:u.signals.length>0?`${bW.OUTCOME_LABELS[u.outcome].toLowerCase()} \xb7 ${u.signals.length} signal${1===u.signals.length?"":"s"}`:bW.OUTCOME_LABELS[u.outcome].toLowerCase(),onClick:()=>t(!0)}),x>0&&(0,b.jsx)(bS.StatCard,{label:"Input tokens",value:b$(x),sub:"fresh input"}),y>0&&(0,b.jsx)(bS.StatCard,{label:"Output tokens",value:b$(y),sub:"generated"}),z>0&&(0,b.jsx)(bS.StatCard,{label:"Cache reads",value:b$(z),sub:"reused context"}),g.totalPremiumRequests>0&&(0,b.jsx)(bS.StatCard,{label:"Premium req",value:g.totalPremiumRequests.toLocaleString(),sub:"billed requests"}),g.totalApiDurationMs>0&&(0,b.jsx)(bS.StatCard,{label:"API time",value:(0,X.formatDuration)(g.totalApiDurationMs),sub:"waiting on the model"}),null!=j&&j>0&&(0,b.jsx)(bS.StatCard,{label:"Time span",value:(0,X.formatDuration)(j),sub:"first to last event"})]}),h&&(0,b.jsx)(a9,{cost:h,open:p,onOpenChange:q}),u&&(0,b.jsx)(bX,{health:u,open:r,onOpenChange:t,onFocus:l})]})]})})}var b1=a.i(24848),b2=a.i(66535),b2=b2,b3=a.i(4888);let b4={high:{label:"High impact",Icon:b2.default,card:"border-red-200 bg-red-50 dark:border-red-900 dark:bg-red-950/30",icon:"text-red-600 dark:text-red-400"},medium:{label:"Medium impact",Icon:b2.default,card:"border-amber-200 bg-amber-50 dark:border-amber-900 dark:bg-amber-950/30",icon:"text-amber-600 dark:text-amber-400"},low:{label:"Info",Icon:J.Info,card:"border-emerald-200 bg-emerald-50 dark:border-emerald-900 dark:bg-emerald-950/30",icon:"text-emerald-600 dark:text-emerald-400"}},b5=["high","medium","low"];function b6({analysis:a,stats:c,eventTypeCounts:d,onFocusHint:e}){let f=[{label:"System context",note:"agent managed",chars:a.systemContextChars,bar:"bg-red-400 dark:bg-red-500",text:"text-red-700 dark:text-red-400"},{label:"Tool results",chars:a.toolResultChars,bar:"bg-amber-400 dark:bg-amber-500",text:"text-amber-700 dark:text-amber-400"},{label:"Assistant replies",chars:a.assistantChars,bar:"bg-sky-400 dark:bg-sky-500",text:"text-sky-700 dark:text-sky-400"}],g=f.reduce((a,b)=>a+b.chars,0),h=b5.flatMap(b=>a.hints.filter(a=>a.severity===b));return(0,b.jsxs)("div",{className:"space-y-6",children:[(0,b.jsxs)("section",{children:[(0,b.jsxs)("h2",{className:"mb-3 flex items-center gap-2 text-sm font-semibold text-foreground",children:[(0,b.jsx)(n,{className:"size-4 text-brand","aria-hidden":!0}),"Optimization hints",h.length>0&&(0,b.jsx)("span",{className:"rounded-sm bg-muted px-1.5 text-xs font-normal tabular-nums text-muted-foreground",children:h.length})]}),0===h.length?(0,b.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3 dark:border-emerald-900 dark:bg-emerald-950/30",children:[(0,b.jsx)(bU.CheckCircle2,{className:"size-4 shrink-0 text-emerald-600 dark:text-emerald-400","aria-hidden":!0}),(0,b.jsx)("p",{className:"text-sm text-foreground",children:"No issues detected in this session’s context usage."})]}):(0,b.jsx)("div",{className:"space-y-3",children:h.map(a=>{let c=b4[a.severity];return(0,b.jsx)("article",{className:(0,$.cn)("rounded-xl border p-4",c.card),children:(0,b.jsxs)("div",{className:"flex items-start gap-3",children:[(0,b.jsx)(c.Icon,{className:(0,$.cn)("mt-0.5 size-4 shrink-0",c.icon),"aria-hidden":!0}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:a.category}),(0,b.jsx)("span",{className:"sr-only",children:c.label}),a.saving&&(0,b.jsxs)("span",{className:"rounded-sm border border-border bg-background px-1.5 py-0.5 font-mono text-xs text-foreground",children:["save ~",a.saving]})]}),(0,b.jsx)("p",{className:"mt-0.5 text-sm font-semibold text-foreground",children:a.title}),(0,b.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:a.description}),a.focus&&(0,b.jsxs)(p.Button,{variant:"outline",size:"sm",onClick:()=>a.focus&&e(a.focus),className:"mt-2.5",children:["View related events",(0,b.jsx)(bT,{"data-icon":"inline-end","aria-hidden":!0})]})]})]})},`${a.category}-${a.title}`)})})]}),(0,b.jsxs)("section",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsx)("h2",{className:"mb-4 text-sm font-semibold text-foreground",children:"Context usage breakdown"}),0===g?(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"No measurable context recorded for this session."}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"mb-4 flex h-2.5 overflow-hidden rounded-full bg-muted",children:f.map(({label:a,chars:c,bar:d})=>(0,b.jsx)("div",{className:d,style:{width:`${c/g*100}%`}},a))}),(0,b.jsx)("div",{className:"space-y-2.5",children:f.map(({label:a,note:c,chars:d,bar:e,text:f})=>{let h=Math.round(d/g*100);return(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsxs)("div",{className:"flex w-36 shrink-0 items-center gap-2 sm:w-60",children:[(0,b.jsx)("span",{className:(0,$.cn)("size-2 shrink-0 rounded-full",e),"aria-hidden":!0}),(0,b.jsxs)("span",{className:"truncate text-xs text-foreground",children:[a,c&&(0,b.jsxs)("span",{className:"ml-1 hidden text-muted-foreground sm:inline",children:["(",c,")"]})]})]}),(0,b.jsx)("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:(0,b.jsx)("div",{className:(0,$.cn)("h-full rounded-full",e),style:{width:`${h}%`}})}),(0,b.jsxs)("span",{className:(0,$.cn)("w-20 text-right font-mono text-xs font-semibold tabular-nums",f),children:[(d/1e3).toFixed(0),"K chars"]}),(0,b.jsxs)("span",{className:"w-9 text-right text-xs tabular-nums text-muted-foreground",children:[h,"%"]})]},a)})})]}),(0,b.jsx)("div",{className:"mt-5 grid grid-cols-2 gap-3 border-t border-border pt-4 sm:grid-cols-4",children:[{label:"Output tokens",value:c.totalOutputTokens>0?`${(c.totalOutputTokens/1e3).toFixed(1)}K`:"—"},{label:"Input tokens",value:c.totalInputTokens>0?`${(c.totalInputTokens/1e3).toFixed(1)}K`:"N/A (active)"},{label:"Compactions",value:String(a.compactionCount)},{label:"Hook events",value:String(a.hookEventCount)}].map(({label:a,value:c})=>(0,b.jsxs)("div",{className:"text-center",children:[(0,b.jsx)("div",{className:"font-mono text-base font-bold tabular-nums text-foreground",children:c}),(0,b.jsx)("div",{className:"mt-0.5 text-xs text-muted-foreground",children:a})]},a))})]}),(0,b.jsxs)("section",{className:"grid gap-4 md:grid-cols-2",children:[(0,b.jsxs)("div",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsx)("h3",{className:"mb-3 text-sm font-semibold text-foreground",children:"Tool usage"}),(0,b.jsx)(b3.BarList,{items:a.topToolsByCount.map(({name:a,count:b})=>({name:a,value:b})),color:"bg-chart-3",emptyLabel:"No tool calls recorded."})]}),(0,b.jsxs)("div",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsx)("h3",{className:"mb-3 text-sm font-semibold text-foreground",children:"Event types"}),(0,b.jsx)(b3.BarList,{items:d,color:"bg-brand-2",limit:10,emptyLabel:"No events recorded."})]})]})]})}function b7({checkpoints:a}){let[d,e]=(0,c.useState)(new Set);return 0===a.length?(0,b.jsx)(bp.EmptyState,{icon:h,title:"No checkpoints",description:"Copilot CLI writes checkpoint files when it summarizes progress. Claude Code and Codex sessions have none."}):(0,b.jsx)("div",{className:"space-y-2",children:a.map(a=>{let c=d.has(a.name);return(0,b.jsxs)("div",{className:"overflow-hidden rounded-xl border border-border",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>{var b;return b=a.name,void e(a=>{let c=new Set(a);return c.has(b)?c.delete(b):c.add(b),c})},"aria-expanded":c,className:"flex w-full items-center gap-3 bg-muted/60 px-4 py-3 text-left transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",children:[(0,b.jsx)(E.ChevronRight,{className:(0,$.cn)("size-4 shrink-0 text-muted-foreground transition-transform",c&&"rotate-90"),"aria-hidden":!0}),(0,b.jsx)(l.FileText,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-sm font-medium text-foreground",children:a.name}),a.content&&(0,b.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[a.content.length.toLocaleString()," chars"]})]}),c&&(a.content?(0,b.jsxs)("div",{className:"border-t border-border",children:[(0,b.jsx)("div",{className:"flex justify-end border-b border-border bg-background px-2 py-1",children:(0,b.jsx)(s.CopyButton,{value:a.content,label:"Copy checkpoint"})}),(0,b.jsx)(r.ScrollArea,{className:"h-[60vh] w-full",children:(0,b.jsx)("pre",{className:"w-max min-w-full p-4 font-mono text-xs text-foreground",children:a.content})})]}):(0,b.jsx)("p",{className:"border-t border-border p-4 text-sm text-muted-foreground",children:"Empty file"}))]},a.name)})})}function b8({paths:a,kind:d}){let[e,f]=(0,c.useState)(""),g=e.trim().toLowerCase(),h=g?a.filter(a=>a.toLowerCase().includes(g)):a,i="research"===d?m:l.FileText;return 0===a.length?(0,b.jsx)(bp.EmptyState,{icon:i,title:"research"===d?"No research files":"No files",description:"research"===d?"Research notes appear here when the agent saves its findings.":"No files recorded. Copilot lists its workspace files here; Claude Code and Codex list the files the session edited."}):(0,b.jsxs)("div",{className:"space-y-2",children:[a.length>8&&(0,b.jsx)(U.SearchInput,{value:e,onChange:f,placeholder:"Filter paths…","aria-label":"Filter paths",className:"w-full max-w-sm"}),h.map(a=>(0,b.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-card px-3 py-2.5 text-sm transition-colors hover:bg-muted/50",children:[(0,b.jsx)(i,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:a}),(0,b.jsx)(s.CopyButton,{value:a,label:"Copy path"})]},a)),0===h.length&&(0,b.jsxs)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:["No paths match “",e,"”"]})]})}let b9=["events","checkpoints","files","edits","research","workspace","cost","optimizer"];function ca({value:a}){return(0,b.jsx)("span",{className:"ml-1 rounded-sm bg-foreground/10 px-1.5 text-[11px] tabular-nums",children:a})}function cb({provider:a,id:f}){let[z,A]=(0,Z.useTabParam)(b9,"events"),[B,C]=(0,c.useState)(null),[D,E]=(0,c.useState)(!0),[F,G]=(0,c.useState)(null),[H,I]=(0,c.useState)(null),[J]=(0,Z.useQueryParam)("q",""),K=(0,c.useMemo)(()=>J?{nonce:0,search:J}:null,[J]),[L,M]=(0,c.useState)(J);J!==L&&(M(J),I(null));let[N,O]=(0,Z.useQueryParam)("event",""),[P,Q]=(0,c.useState)(0),R=(0,c.useRef)(null),S=(0,c.useRef)(!1);(0,c.useEffect)(()=>{let b=!1;return(async()=>{try{let c=await fetch(`/api/sessions/${a}/${f}?probe=1`),d=c.ok?(await c.json()).revision:null,e=await fetch(`/api/sessions/${a}/${f}`);if(!e.ok)throw Error("Request failed");let g=await e.json();if(!g?.meta)throw Error("Not found");b||(R.current=d,S.current=!0,C(g))}catch{b||S.current||G("This session could not be loaded. It may have been removed.")}finally{b||E(!1)}})(),()=>{b=!0}},[a,f,P]);let[T,U]=(0,c.useState)(!1),V=(0,bZ.isRunning)(B?.meta.updated_at),[,Y]=(0,c.useState)(0),$=null!==B&&(T||V),_=B?.meta.updated_at;(0,c.useEffect)(()=>{if(!$)return;let b=!1,c=window.setInterval(async()=>{if(!document.hidden)try{let c=await fetch(`/api/sessions/${a}/${f}?probe=1`);if(!c.ok||b)return;let d=(await c.json()).revision;if(b)return;d!==R.current?Q(a=>a+1):(0,bZ.isRunning)(_)||Y(a=>a+1)}catch{}},3e3);return()=>{b=!0,window.clearInterval(c)}},[$,a,f,_]);let aa=(0,c.useMemo)(()=>{let a=new Map;for(let b of B?.events??[])a.set(b.type,(a.get(b.type)??0)+1);return Array.from(a,([a,b])=>({name:a,value:b}))},[B]),ab=(0,c.useMemo)(()=>{let{requests:a}=W(B?.events??[]);if(!(a.length<2))return{latest:a[a.length-1].contextTokens,peak:Math.max(...a.map(a=>a.contextTokens))}},[B]),ac=(0,c.useMemo)(()=>bH(B?.events??[],B?.meta.cwd).reduce((a,b)=>a+b.edits,0),[B]),ad=(0,c.useMemo)(()=>{let a=B?.events??[];if(a.length<2)return null;let b=a.map(a=>new Date(a.timestamp).getTime()).filter(a=>Number.isFinite(a));return b.length<2?null:Math.max(...b)-Math.min(...b)},[B]);function ae(a){A("events"),I({nonce:Date.now(),...a})}let[af,ag]=(0,c.useState)(null);function ah(a){O(a),A("events"),ag({eventId:a,nonce:Date.now()})}(0,c.useEffect)(()=>{if(!af||"events"!==z)return;let a=requestAnimationFrame(()=>document.querySelector(`[data-event-id="${CSS.escape(af.eventId)}"]`)?.scrollIntoView({block:"center"}));return()=>cancelAnimationFrame(a)},[af,z]);let ai="checkpoints"===z&&B?.checkpoints.length===0||"research"===z&&B?.research.length===0?"events":z,aj=B?B.meta.title??(0,X.firstLine)(B.meta.name)??B.meta.id:f;return(0,b.jsxs)("div",{className:"min-h-screen bg-background text-foreground",children:[(0,b.jsx)("div",{className:"sticky top-0 z-30 border-b border-border bg-background/85 backdrop-blur supports-[backdrop-filter]:bg-background/70",children:(0,b.jsxs)("div",{className:"mx-auto flex h-[var(--cv-topbar-h)] max-w-6xl items-center gap-3 px-4 sm:px-6",children:[(0,b.jsx)(b1.SidebarTrigger,{className:"-ml-2 shrink-0"}),(0,b.jsxs)(p.Button,{variant:"ghost",nativeButton:!1,render:(0,b.jsx)(d.default,{href:"/?tab=sessions"}),className:"text-muted-foreground",children:[(0,b.jsx)(g,{"aria-hidden":!0}),(0,b.jsx)("span",{className:"hidden sm:inline",children:"Sessions"})]}),(0,b.jsx)("span",{className:"text-muted-foreground/50","aria-hidden":!0,children:"/"}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:aj}),(0,b.jsx)(w.SearchTrigger,{className:"shrink-0"}),(0,b.jsx)(b1.ShortcutsTrigger,{className:"hidden shrink-0 sm:inline-flex"}),(0,b.jsx)(v.PalettePicker,{className:"shrink-0"}),(0,b.jsx)(x.ThemeToggle,{className:"shrink-0"}),(0,b.jsx)(y.AboutDialog,{className:"shrink-0"})]})}),D?(0,b.jsxs)("div",{className:"mx-auto max-w-6xl space-y-4 px-4 py-8 sm:px-6",children:[(0,b.jsx)(u.Skeleton,{className:"h-7 w-2/3"}),(0,b.jsx)(u.Skeleton,{className:"h-4 w-1/3"}),(0,b.jsx)("div",{className:"flex flex-wrap gap-2 pt-2",children:Array.from({length:6},(a,c)=>(0,b.jsx)(u.Skeleton,{className:"h-11 w-24"},c))}),(0,b.jsx)(u.Skeleton,{className:"h-9 w-96"}),(0,b.jsx)("div",{className:"space-y-3 pt-4",children:Array.from({length:6},(a,c)=>(0,b.jsx)(u.Skeleton,{className:"h-20 w-full"},c))})]}):F||!B?(0,b.jsx)("div",{className:"mx-auto max-w-6xl px-4 py-16 sm:px-6",children:(0,b.jsxs)("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed border-border px-6 py-14 text-center",children:[(0,b.jsx)(e.AlertTriangle,{className:"size-6 text-destructive","aria-hidden":!0}),(0,b.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Session unavailable"}),(0,b.jsx)("p",{className:"max-w-sm text-xs text-muted-foreground",children:F}),(0,b.jsxs)("div",{className:"mt-2 flex gap-2",children:[(0,b.jsx)(p.Button,{variant:"outline",size:"sm",onClick:function(){E(!0),G(null),Q(a=>a+1)},children:"Retry"}),(0,b.jsx)(p.Button,{size:"sm",nativeButton:!1,render:(0,b.jsx)(d.default,{href:"/?tab=sessions"}),children:"Back to sessions"})]})]})}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(b0,{meta:B.meta,storagePath:B.storagePath,revealable:B.revealable,stats:B.stats,cost:B.cost,context:ab,activeMs:ad,running:V,onFocusEvents:ae}),(0,b.jsx)("main",{id:"main",className:"mx-auto max-w-6xl px-4 pt-2 pb-5 sm:px-6",children:(0,b.jsxs)(q.Tabs,{value:ai,onValueChange:A,className:"gap-0",children:[(0,b.jsx)("div",{className:"sticky top-[var(--cv-topbar-h)] z-20 -mx-4 overflow-x-auto scrollbar-none bg-background/85 px-4 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/70 sm:-mx-6 sm:px-6",children:(0,b.jsxs)(q.TabsList,{className:"w-max",children:[(0,b.jsxs)(q.TabsTrigger,{value:"events",className:"px-3",children:[(0,b.jsx)(o.Zap,{className:"size-4","aria-hidden":!0}),"Events",(0,b.jsx)(ca,{value:B.events.length})]}),B.checkpoints.length>0&&(0,b.jsxs)(q.TabsTrigger,{value:"checkpoints",className:"px-3",children:[(0,b.jsx)(h,{className:"size-4","aria-hidden":!0}),"Checkpoints",(0,b.jsx)(ca,{value:B.checkpoints.length})]}),(0,b.jsxs)(q.TabsTrigger,{value:"files",className:"px-3",children:[(0,b.jsx)(l.FileText,{className:"size-4","aria-hidden":!0}),"Files",(0,b.jsx)(ca,{value:B.files.length})]}),(0,b.jsxs)(q.TabsTrigger,{value:"edits",className:"px-3",children:[(0,b.jsx)(k,{className:"size-4","aria-hidden":!0}),"Edits",(0,b.jsx)(ca,{value:ac})]}),B.research.length>0&&(0,b.jsxs)(q.TabsTrigger,{value:"research",className:"px-3",children:[(0,b.jsx)(m,{className:"size-4","aria-hidden":!0}),"Research",(0,b.jsx)(ca,{value:B.research.length})]}),(0,b.jsxs)(q.TabsTrigger,{value:"workspace",className:"px-3",children:[(0,b.jsx)(j,{className:"size-4","aria-hidden":!0}),"Metadata"]}),(0,b.jsxs)(q.TabsTrigger,{value:"cost",className:"px-3",children:[(0,b.jsx)(i,{className:"size-4","aria-hidden":!0}),"Cost"]}),(0,b.jsxs)(q.TabsTrigger,{value:"optimizer",className:"px-3",children:[(0,b.jsx)(n,{className:"size-4","aria-hidden":!0}),"Token Optimizer",B.tokenAnalysis?.hints.some(a=>"high"===a.severity)&&(0,b.jsx)("span",{className:"ml-1 inline-flex size-4 items-center justify-center rounded-full bg-red-500 text-[10px] font-bold text-white",title:"High-impact hints",children:B.tokenAnalysis.hints.filter(a=>"high"===a.severity).length})]})]})}),(0,b.jsx)(q.TabsContent,{value:"events",children:(0,b.jsx)(a0,{events:B.events,focusRequest:H??K,targetEventId:N||void 0,forkParentHref:B.meta.forkedFrom?`/sessions/${a}/${encodeURIComponent(B.meta.forkedFrom)}`:void 0,live:T,onLiveChange:U,running:V})}),(0,b.jsx)(q.TabsContent,{value:"checkpoints",className:"pt-2",children:(0,b.jsx)(b7,{checkpoints:B.checkpoints})}),(0,b.jsx)(q.TabsContent,{value:"files",className:"pt-2",children:(0,b.jsx)(b8,{paths:B.files,kind:"file"})}),(0,b.jsx)(q.TabsContent,{value:"edits",className:"pt-2",children:(0,b.jsx)(bJ,{events:B.events,cwd:B.meta.cwd,onOpenEvent:ah})}),(0,b.jsx)(q.TabsContent,{value:"research",className:"pt-2",children:(0,b.jsx)(b8,{paths:B.research,kind:"research"})}),(0,b.jsx)(q.TabsContent,{value:"workspace",className:"pt-2",children:(0,b.jsxs)("div",{className:"overflow-hidden rounded-xl border border-border",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 border-b border-border bg-muted/60 px-4 py-2",children:[(0,b.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:B.rawMeta.name}),B.rawMeta.content&&(0,b.jsx)(s.CopyButton,{value:B.rawMeta.content,label:`Copy ${B.rawMeta.name}`,className:"ml-auto"})]}),(0,b.jsx)(r.ScrollArea,{className:"h-[60vh] w-full",children:(0,b.jsx)("pre",{className:"w-max min-w-full p-4 font-mono text-xs text-foreground",children:B.rawMeta.content||"No session metadata found"})})]})}),(0,b.jsx)(q.TabsContent,{value:"cost",className:"pt-2",children:(0,b.jsx)(bo,{cost:B.cost,events:B.events,onOpenEvent:ah})}),(0,b.jsx)(q.TabsContent,{value:"optimizer",className:"pt-2",children:(0,b.jsx)(b6,{analysis:B.tokenAnalysis,stats:B.stats,eventTypeCounts:aa,onFocusHint:ae})})]})})]}),(0,b.jsx)(t.ScrollToTop,{})]})}a.s(["default",0,function(a){let{provider:d,id:e}=(0,c.use)(a.params);return(0,b.jsx)(c.Suspense,{children:(0,b.jsx)(cb,{provider:d,id:e},`${d}/${e}`)})}],75136)}];
|
|
5
|
+
}`),[i,j]=(0,c.useState)(g);return(0,b.jsx)(U.Dialog,{open:d,onOpenChange:e,children:(0,b.jsxs)(U.DialogContent,{className:"sm:max-w-xl",children:[(0,b.jsxs)("div",{className:"space-y-1.5",children:[(0,b.jsx)(U.DialogTitle,{children:"How this cost is estimated"}),(0,b.jsx)(U.DialogDescription,{children:"This is what the session’s tokens would cost on the pay-per-token API at list prices. It is not a bill: on a subscription or a request-based plan you pay your plan price, however many tokens a session uses."})]}),(0,b.jsx)(bA,{cost:a,totalLabel:a.inherited?"This session":"Total"}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Each row is tokens ÷ 1,000,000 × rate, using the list price on the day of the request.",g&&(0,b.jsxs)(b.Fragment,{children:[" ","No price is known for ",a.unpricedModels.join(", "),", so the total leaves ",a.unpricedModels.length>1?"them":"it"," out."]})]}),a.inherited&&(0,b.jsxs)("div",{className:"space-y-2 border-t border-border pt-3",children:[(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("h3",{className:"text-sm font-medium text-foreground",children:"Inherited from the forked session"}),(0,b.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"This session is a fork, so it opens with a copy of its parent’s history. Those requests were made, and are counted, in the parent session; they are listed here for reference and are not part of this session’s cost or of any usage total."})]}),(0,b.jsx)(bA,{cost:a.inherited,totalLabel:"Inherited"})]}),(0,b.jsx)("dl",{className:"space-y-1.5 border-t border-border pt-3 text-xs leading-relaxed text-muted-foreground",children:by.map(([a,c])=>(0,b.jsxs)("div",{children:[(0,b.jsxs)("dt",{className:"inline font-medium text-foreground",children:[a,": "]}),(0,b.jsx)("dd",{className:"inline",children:c})]},a))}),(0,b.jsxs)("div",{className:"overflow-hidden rounded-lg border border-border bg-card text-xs",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>j(!i),"aria-expanded":i,"aria-controls":"cost-dialog-prices",className:"flex w-full items-center gap-2 px-3 py-2 text-left font-medium text-foreground transition-colors hover:bg-muted/60 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",children:[(0,b.jsx)(F.ChevronRight,{className:(0,av.cn)("size-3.5 shrink-0 text-muted-foreground transition-transform",i&&"rotate-90"),"aria-hidden":!0}),g?"Add the missing price":"Change these prices"]}),(0,b.jsxs)("div",{id:"cost-dialog-prices",hidden:!i,className:"space-y-2 border-t border-border px-3 py-3 leading-relaxed text-muted-foreground",children:[(0,b.jsxs)("p",{children:["Save the block below as"," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:a.overridePath})," ","and edit the numbers. It replaces the bundled price for the models it lists and takes effect on the next page load."]}),(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("pre",{className:"overflow-x-auto rounded-lg border border-border bg-muted/50 p-3 pr-10 font-mono text-[11px] leading-relaxed text-foreground",children:h}),(0,b.jsx)(s.CopyButton,{value:h,label:"Copy pricing.json",className:"absolute top-1.5 right-1.5"})]}),(0,b.jsxs)("ul",{className:"list-disc space-y-1 pl-4",children:[(0,b.jsx)("li",{children:"All prices are US dollars per million tokens."}),(0,b.jsxs)("li",{children:[(0,b.jsx)("code",{className:"font-mono text-foreground",children:"input"})," and"," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"output"})," are required. ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheRead"}),","," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheWrite"})," and"," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheWrite1h"})," ","are optional: the first two fall back to the input price, and ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheWrite1h"})," ","to ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"cacheWrite"}),"."," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:"fast"})," multiplies every price for requests made in a faster, premium speed tier."]}),(0,b.jsxs)("li",{children:["To record a price change, add a second entry with"," ",(0,b.jsx)("code",{className:"font-mono text-foreground",children:'"from": "YYYY-MM-DD"'}),". Requests before that day keep the old price."]})]})]})]})]})})}let bC=Object.keys(bx);function bD({events:a,partial:d,onOpenEvent:e}){let{turns:f,totalUSD:g,inheritedUSD:h}=(0,c.useMemo)(()=>ar(a),[a]),[i,j]=(0,c.useState)(null);if(f.length<2||g<=0)return null;let k=null!==i&&i<f.length?i:null,l=(0,bw.niceCeil)(Math.max(...f.map(a=>a.costUSD))),m=(0,bw.niceCeil)(g),n=f.reduce((a,b)=>b.costUSD>a.costUSD?b:a),o=a=>`${Math.round(a/g*100)}%`,p=a=>0===a?"Before the first prompt":`Turn ${a}`,q=Math.floor((f.length-1)/2),r=null===k?null:f[k],s=r?[...new Set(r.lines.map(a=>a.model))]:[],t=null===k?0:(k+.5)/f.length*100,u=f.reduce((a,b,c)=>`${a} H${c+.5} V${100-b.totalUSD/m*100}`,"M0,100")+` H${f.length}`;return(0,b.jsxs)("section",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsx)("div",{className:"mb-4 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:(0,b.jsxs)("h2",{className:"text-sm font-semibold text-foreground",children:["Cost by turn",(0,b.jsx)("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:"a turn is one prompt and everything the agent did to answer it"})]})}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsxs)("div",{className:"flex h-40 flex-col justify-between text-right text-[10px] leading-none tabular-nums text-emerald-700 dark:text-emerald-400",children:[(0,b.jsx)("span",{children:(0,as.formatCost)(l)}),(0,b.jsx)("span",{children:(0,as.formatCost)(l/2)}),(0,b.jsx)("span",{children:"$0"})]}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("div",{className:(0,av.cn)("relative flex h-40 items-end border-b border-border",f.length>80?"gap-0":"gap-[2px]"),onMouseLeave:()=>j(null),children:[(0,b.jsx)("span",{className:"pointer-events-none absolute inset-x-0 top-0 border-t border-dashed border-border"}),(0,b.jsx)("span",{className:"pointer-events-none absolute inset-x-0 top-1/2 border-t border-dashed border-border"}),f.map((a,c)=>(0,b.jsxs)("button",{type:"button",onMouseEnter:()=>j(c),onFocus:()=>j(c),onBlur:()=>j(null),onClick:()=>e(a.eventId),"aria-label":`${p(a.turn)}: ${(0,as.formatCost)(a.costUSD)}, ${(0,as.formatCost)(a.totalUSD)} so far. Open in the timeline.`,className:(0,av.cn)("relative flex h-full min-w-0 flex-1 cursor-pointer flex-col justify-end focus-visible:outline-2 focus-visible:outline-ring",null!==k&&k!==c&&"opacity-50"),children:[a.compacted&&(0,b.jsx)("span",{className:"absolute top-1 left-1/2 size-1.5 -translate-x-1/2 rotate-45 bg-amber-500","aria-hidden":!0}),(0,b.jsx)("span",{className:"w-full rounded-t-[3px] bg-emerald-500/60 dark:bg-emerald-500/50",style:{height:`${a.costUSD/l*100}%`,minHeight:2*(a.costUSD>0)}})]},a.eventId)),(0,b.jsx)("svg",{className:"pointer-events-none absolute inset-0 size-full overflow-visible text-foreground",viewBox:`0 0 ${f.length} 100`,preserveAspectRatio:"none","aria-hidden":!0,children:(0,b.jsx)("path",{d:u,fill:"none",stroke:"currentColor",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"})}),r&&(0,b.jsxs)("div",{role:"status",className:"pointer-events-none absolute top-full z-20 mt-2 w-80 max-w-full rounded-lg border border-border bg-popover p-3 text-xs text-popover-foreground shadow-lg",style:{left:`${t}%`,transform:`translateX(-${t}%)`},children:[(0,b.jsxs)("div",{className:"flex items-baseline justify-between gap-3 tabular-nums",children:[(0,b.jsxs)("span",{className:"font-semibold",children:[p(r.turn)," · ",(0,as.formatCost)(r.costUSD)]}),(0,b.jsxs)("span",{className:"text-muted-foreground",children:[o(r.costUSD)," of the session"]})]}),(0,b.jsx)("p",{className:"mt-0.5 truncate text-muted-foreground",children:(0,as.firstLine)(r.prompt)??"Requests made before the first prompt."}),(0,b.jsxs)("table",{className:"mt-2 w-full border-t border-border tabular-nums",children:[(0,b.jsx)("thead",{children:(0,b.jsxs)("tr",{className:"text-[10px] text-muted-foreground",children:[(0,b.jsx)("th",{className:"pt-1.5 pb-0.5 text-left font-normal",children:"Token type"}),(0,b.jsx)("th",{className:"pt-1.5 pb-0.5 text-right font-normal",children:"Tokens"}),(0,b.jsx)("th",{className:"pt-1.5 pb-0.5 text-right font-normal",children:"Rate / 1M"}),(0,b.jsx)("th",{className:"pt-1.5 pb-0.5 text-right font-normal",children:"Cost"})]})}),(0,b.jsx)("tbody",{children:s.map(a=>(0,b.jsxs)(c.Fragment,{children:[s.length>1&&(0,b.jsx)("tr",{children:(0,b.jsx)("th",{colSpan:4,scope:"rowgroup",className:"max-w-0 truncate pt-1.5 text-left font-mono font-semibold",children:a})}),r.lines.filter(b=>b.model===a).sort((a,b)=>bC.indexOf(a.kind)-bC.indexOf(b.kind)).map(a=>(0,b.jsxs)("tr",{children:[(0,b.jsx)("td",{className:"py-0.5",children:bx[a.kind]}),(0,b.jsx)("td",{className:"py-0.5 pl-2 text-right font-mono",children:a.tokens.toLocaleString()}),(0,b.jsx)("td",{className:"py-0.5 pl-2 text-right font-mono text-muted-foreground",children:null===a.rate?"—":bz(a.rate)}),(0,b.jsx)("td",{className:"py-0.5 pl-2 text-right font-mono",children:null===a.usd?(0,b.jsx)("span",{className:"font-sans text-muted-foreground",children:"no price"}):(0,as.formatCost)(a.usd)})]},`${a.kind}-${a.rate}`))]},a))})]}),(0,b.jsxs)("p",{className:"mt-2 border-t border-border pt-1.5 tabular-nums text-muted-foreground",children:[1===s.length&&(0,b.jsxs)("span",{className:"font-mono",children:[s[0]," · "]}),r.requests," ",1===r.requests?"request":"requests"," ·"," ",(0,as.formatCost)(r.totalUSD)," so far",r.compacted&&" · context compacted"]})]})]}),(0,b.jsxs)("div",{className:"mt-1.5 flex justify-between text-[10px] text-muted-foreground",children:[(0,b.jsx)("span",{children:p(f[0].turn)}),f.length>4&&(0,b.jsx)("span",{children:f[q].turn}),(0,b.jsx)("span",{children:f[f.length-1].turn})]})]}),(0,b.jsxs)("div",{className:"flex h-40 flex-col justify-between text-[10px] leading-none tabular-nums text-muted-foreground",children:[(0,b.jsx)("span",{children:(0,as.formatCost)(m)}),(0,b.jsx)("span",{children:(0,as.formatCost)(m/2)}),(0,b.jsx)("span",{children:"$0"})]})]}),(0,b.jsxs)("div",{className:"mt-3 space-y-1 text-xs",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1.5",children:[(0,b.jsxs)("span",{className:"font-medium tabular-nums",children:["Whole session · ",(0,as.formatCost)(g),d&&"+"]}),(0,b.jsxs)("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,b.jsx)("span",{className:"size-2.5 rounded-[3px] bg-emerald-500/60","aria-hidden":!0}),"cost of the turn (left axis)"]}),(0,b.jsxs)("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,b.jsx)("span",{className:"w-3 border-t-2 border-foreground","aria-hidden":!0}),"running total (right axis)"]}),f.some(a=>a.compacted)&&(0,b.jsxs)("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,b.jsx)("span",{className:"size-1.5 rotate-45 bg-amber-500","aria-hidden":!0}),"context compacted"]})]}),(0,b.jsxs)("p",{className:"truncate text-muted-foreground",children:[p(n.turn)," cost the most: ",(0,as.formatCost)(n.costUSD),","," ",o(n.costUSD)," of the session. Hover a bar for its tokens and prices; click it to open the turn in the timeline."]}),h>0&&(0,b.jsxs)("p",{className:"text-muted-foreground",children:["Not charted: ",(0,as.formatCost)(h)," of history copied from the forked session, shown as Inherited in the timeline. The parent session was billed for it."]})]})]})}let bE=[{key:"input",label:"Uncached input"},{key:"cacheWrite",label:"Cache write"},{key:"cacheRead",label:"Cache read"},{key:"output",label:"Output"}],bF=["Context",...bE.map(a=>a.label),"Cost"];function bG(a){return{input:a.inputTokens,cacheWrite:a.cacheWriteTokens,cacheRead:a.cacheReadTokens,output:a.outputTokens}}function bH(a){let b={tokens:{input:0,cacheWrite:0,cacheRead:0,output:0},usd:{input:null,cacheWrite:null,cacheRead:null,output:null},costUSD:null};for(let c of a){let a=bG(c);for(let{key:d}of bE){b.tokens[d]+=a[d];let e=c.usd[d];null!==e&&(b.usd[d]=(b.usd[d]??0)+e)}null!==c.costUSD&&(b.costUSD=(b.costUSD??0)+c.costUSD)}return b}function bI(a){return a>=.01?(0,as.formatCost)(a):a<1e-4?"<$0.0001":`$${a.toFixed(4)}`}function bJ({tokens:a,usd:c,unit:d,sticky:e}){return bE.map(({key:f,label:g})=>{let h=a[f],i=c[f],j=null===i?"no price":bI(i);return(0,b.jsx)(bv.TableCell,{className:(0,av.cn)("py-1.5 pr-0 pl-3 text-right",e),title:h>0?`${g}: ${h.toLocaleString()} tokens, ${j}`:void 0,children:0===h?"—":"tokens"===d?(0,as.formatTokens)(h):null===i?(0,b.jsx)("span",{className:"font-sans",children:"no price"}):bI(i)},f)})}function bK({value:a,max:c}){return(0,b.jsxs)(bv.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",title:a.toLocaleString(),children:[(0,as.formatTokens)(a)??"—",(0,b.jsx)("span",{className:"mt-0.5 block h-0.5 overflow-hidden rounded-full bg-muted","aria-hidden":!0,children:(0,b.jsx)("span",{className:"block h-full rounded-full bg-emerald-500/70",style:{width:`${c>0?a/c*100:0}%`}})})]})}let bL="sticky top-0 z-10 bg-card shadow-[inset_0_-1px_0_var(--border)]",bM="sticky bottom-0 z-10 bg-card shadow-[inset_0_1px_0_var(--border)]";function bN({value:a,className:c}){return(0,b.jsx)(bv.TableCell,{className:(0,av.cn)("py-1.5 pr-0 pl-3 text-right text-foreground",c),children:null===a?(0,b.jsx)("span",{className:"font-sans font-normal text-muted-foreground",children:"no price"}):(0,as.formatCost)(a)})}function bO({events:a,onOpenEvent:d}){let{requests:e,turns:f}=(0,c.useMemo)(()=>ar(a),[a]),[g,h]=(0,c.useState)({allOpen:null,flipped:new Set}),[i,j]=(0,c.useState)("tokens"),k=(0,c.useMemo)(()=>{let a=new Map;for(let b of e){let c=a.get(b.turn);c?c.push(b):a.set(b.turn,[b])}let b=new Map(f.map(a=>[a.turn,a.prompt]));return[...a].map(([a,c])=>({turn:a,rows:c,prompt:b.get(a),totals:bH(c)}))},[e,f]);if(e.length<2)return null;let l=g.allOpen??e.length<=60,m=a=>l!==g.flipped.has(a),n=Math.max(...e.map(a=>a.contextTokens)),o=bH(e),q=new Set(e.flatMap(a=>a.models)).size>1,r=o.tokens.cacheRead>0,s=k.some(a=>m(a.turn)),t=null!==o.costUSD;return(0,b.jsxs)("section",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsxs)("div",{className:"mb-2 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[(0,b.jsxs)("h2",{className:"text-sm font-semibold text-foreground",children:["Requests",(0,b.jsx)("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:"every call to the model, grouped by turn"})]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[t&&(0,b.jsx)(aq.Segmented,{label:"Show each token class as",value:i,onChange:j,options:[{value:"tokens",label:"Tokens"},{value:"cost",label:"Cost"}]}),(0,b.jsx)(p.Button,{variant:"outline",size:"sm",onClick:()=>h({allOpen:!s,flipped:new Set}),children:s?"Collapse all":"Expand all"})]})]}),(0,b.jsxs)("p",{className:"mb-3 max-w-3xl text-xs leading-relaxed text-muted-foreground",children:["Each tool round is its own request, and every request sends the whole conversation again."," ",(0,b.jsx)("span",{className:"text-foreground",children:"Context"})," is what one request sent: cache read (already stored), cache write (new since the last request, stored for the next) and uncached input. A turn row adds up its requests, so its cache read is the context multiplied by the number of requests, not the size of the context."]}),(0,b.jsx)("div",{className:"[&>[data-slot=table-container]]:max-h-[70vh] [&>[data-slot=table-container]]:overflow-y-auto",children:(0,b.jsxs)(bv.Table,{className:"min-w-[47rem] table-fixed text-xs",children:[(0,b.jsxs)("colgroup",{children:[(0,b.jsx)("col",{}),bF.map(a=>(0,b.jsx)("col",{className:"Cost"===a?"w-20":"Uncached input"===a?"w-28":"w-24"},a))]}),(0,b.jsx)(bv.TableHeader,{children:(0,b.jsxs)(bv.TableRow,{className:"hover:bg-transparent",children:[(0,b.jsx)(bv.TableHead,{className:(0,av.cn)("h-8 px-0 text-muted-foreground",bL),children:"Turn / request"}),bF.map(a=>(0,b.jsx)(bv.TableHead,{className:(0,av.cn)("h-8 pr-0 pl-3 text-right text-muted-foreground",bL),children:a},a))]})}),(0,b.jsx)(bv.TableBody,{className:"font-mono tabular-nums",children:k.map(({turn:a,rows:f,prompt:g,totals:j})=>{let k=m(a),l=f[f.length-1];return(0,b.jsxs)(c.Fragment,{children:[(0,b.jsxs)(bv.TableRow,{className:"border-border/60 bg-muted/40 font-semibold hover:bg-muted/60",children:[(0,b.jsx)(bv.TableCell,{className:"truncate px-0 py-1.5 font-sans",children:(0,b.jsxs)("button",{type:"button",onClick:()=>h(({allOpen:b,flipped:c})=>{let d=new Set(c);return d.delete(a)||d.add(a),{allOpen:b,flipped:d}}),"aria-expanded":k,className:"flex w-full min-w-0 cursor-pointer items-center gap-1.5 rounded-sm text-left text-foreground focus-visible:outline-2 focus-visible:outline-ring",children:[(0,b.jsx)(F.ChevronRight,{className:(0,av.cn)("size-3.5 shrink-0 transition-transform",k&&"rotate-90"),"aria-hidden":!0}),(0,b.jsx)("span",{className:"shrink-0",children:0===a?"Before the first prompt":`Turn ${a}`}),(0,b.jsxs)("span",{className:"shrink-0 font-normal tabular-nums text-muted-foreground",children:[f.length," ",1===f.length?"request":"requests"]}),(0,b.jsx)("span",{className:"min-w-0 truncate font-normal text-muted-foreground",children:(0,as.firstLine)(g)})]})}),(0,b.jsx)(bK,{value:l.contextTokens,max:n}),(0,b.jsx)(bJ,{tokens:j.tokens,usd:j.usd,unit:i}),(0,b.jsx)(bN,{value:j.costUSD})]}),k&&f.map(a=>{let c=e[a.n-2],f=r&&void 0!==c&&a.cacheReadTokens<c.contextTokens/2&&a.inputTokens+a.cacheWriteTokens>a.cacheReadTokens;return(0,b.jsxs)(bv.TableRow,{className:"group border-border/60 text-muted-foreground",children:[(0,b.jsxs)(bv.TableCell,{className:"truncate py-1.5 pr-0 pl-5",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>d(a.eventId),"aria-label":`Request ${a.n}: open in the timeline`,title:"Open in the timeline",className:"inline-flex cursor-pointer items-center gap-1 rounded-sm text-foreground underline-offset-2 hover:text-brand hover:underline focus-visible:outline-2 focus-visible:outline-ring",children:["#",a.n,(0,b.jsx)(A,{className:"size-3 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100","aria-hidden":!0})]}),q&&(0,b.jsx)("span",{className:"ml-2",children:a.models.join(", ")}),f&&(0,b.jsx)("span",{className:"ml-2 rounded-sm bg-amber-500/15 px-1.5 py-0.5 font-sans text-[10px] text-amber-700 dark:text-amber-400",title:"Little of the context came from the cache, so it was sent and stored again at the higher rate. This follows a compaction, a change to the early context, or a pause longer than the cache lifetime.",children:"cache miss"})]}),(0,b.jsx)(bK,{value:a.contextTokens,max:n}),(0,b.jsx)(bJ,{tokens:bG(a),usd:a.usd,unit:i}),(0,b.jsx)(bN,{value:a.costUSD})]},a.eventId)})]},a)})}),(0,b.jsx)(bv.TableFooter,{className:"bg-transparent font-mono tabular-nums",children:(0,b.jsxs)(bv.TableRow,{className:"hover:bg-transparent",children:[(0,b.jsxs)(bv.TableCell,{className:(0,av.cn)("truncate px-0 py-1.5 font-sans text-foreground",bM),children:["Whole session",(0,b.jsxs)("span",{className:"ml-1.5 font-normal text-muted-foreground",children:[e.length," requests, context peaked at ",(0,as.formatTokens)(n)]})]}),(0,b.jsx)(bv.TableCell,{className:(0,av.cn)("py-1.5 pr-0 pl-3",bM)}),(0,b.jsx)(bJ,{tokens:o.tokens,usd:o.usd,unit:i,sticky:bM}),(0,b.jsx)(bN,{value:o.costUSD,className:(0,av.cn)("font-semibold",bM)})]})})]})}),(0,b.jsxs)("p",{className:"mt-3 text-xs text-muted-foreground",children:["Click a request number to open it in the timeline. Hover a value for its exact token count and cost",t&&", or switch the columns between tokens and cost","."]})]})}function bP({cost:a}){let[d,e]=(0,c.useState)(!1);if(0===a.byModel.length)return null;let f=[{label:"Output",note:"replies + reasoning",usd:a.breakdown.output,bar:"bg-sky-400 dark:bg-sky-500"},{label:"Cache writes",note:"new context stored",usd:a.breakdown.cacheWrite,bar:"bg-amber-400 dark:bg-amber-500"},{label:"Cache reads",note:"context re-sent each turn",usd:a.breakdown.cacheRead,bar:"bg-emerald-400 dark:bg-emerald-500"},{label:"Uncached input",usd:a.breakdown.input,bar:"bg-red-400 dark:bg-red-500"}].filter(a=>a.usd>0),g=a.byModel.reduce((a,b)=>a+b.cacheReadTokens,0),h=a.byModel.reduce((a,b)=>a+b.inputTokens+b.cacheWriteTokens+b.cacheReadTokens,0),i=a.unpricedModels.length>0;return(0,b.jsxs)("section",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsxs)("div",{className:"mb-4 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",children:[(0,b.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"Estimated cost"}),(0,b.jsxs)("span",{className:"font-mono text-lg font-bold tabular-nums text-foreground",children:[(0,as.formatCost)(a.totalUSD),i&&"+"]})]}),a.totalUSD>0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"mb-4 flex h-2.5 overflow-hidden rounded-full bg-muted",children:f.map(({label:c,usd:d,bar:e})=>(0,b.jsx)("div",{className:e,style:{width:`${d/a.totalUSD*100}%`}},c))}),(0,b.jsx)("div",{className:"grid gap-x-6 gap-y-2 sm:grid-cols-2",children:f.map(({label:c,note:d,usd:e,bar:f})=>(0,b.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,b.jsx)("span",{className:(0,av.cn)("size-2 shrink-0 rounded-full",f),"aria-hidden":!0}),(0,b.jsxs)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:[c,d&&(0,b.jsxs)("span",{className:"ml-1 hidden text-muted-foreground sm:inline",children:["(",d,")"]})]}),(0,b.jsx)("span",{className:"font-mono font-semibold tabular-nums text-foreground",children:(0,as.formatCost)(e)}),(0,b.jsxs)("span",{className:"w-9 text-right tabular-nums text-muted-foreground",children:[Math.round(e/a.totalUSD*100),"%"]})]},c))})]}),(0,b.jsx)("div",{className:"mt-4 border-t border-border pt-1.5",children:(0,b.jsxs)(bv.Table,{className:"text-xs",children:[(0,b.jsx)(bv.TableHeader,{children:(0,b.jsx)(bv.TableRow,{className:"hover:bg-transparent",children:["Model","Input","Cache write","Cache read","Output","Cost"].map((a,c)=>(0,b.jsx)(bv.TableHead,{className:(0,av.cn)("h-8 px-0 text-muted-foreground",c>0&&"pl-3 text-right"),children:a},a))})}),(0,b.jsx)(bv.TableBody,{className:"font-mono tabular-nums",children:a.byModel.map(a=>(0,b.jsxs)(bv.TableRow,{className:"border-border/60",children:[(0,b.jsx)(bv.TableCell,{className:"px-0 py-1.5 text-foreground",children:a.model}),(0,b.jsx)(bv.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",children:(0,as.formatTokens)(a.inputTokens)??"—"}),(0,b.jsx)(bv.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",children:(0,as.formatTokens)(a.cacheWriteTokens)??"—"}),(0,b.jsx)(bv.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",children:(0,as.formatTokens)(a.cacheReadTokens)??"—"}),(0,b.jsx)(bv.TableCell,{className:"py-1.5 pr-0 pl-3 text-right",children:(0,as.formatTokens)(a.outputTokens)??"—"}),(0,b.jsx)(bv.TableCell,{className:"py-1.5 pr-0 pl-3 text-right font-semibold text-foreground",children:null===a.costUSD?(0,b.jsx)("span",{className:"font-sans font-normal text-muted-foreground",children:"no price"}):(0,as.formatCost)(a.costUSD)})]},a.model))})]})}),(0,b.jsxs)("p",{className:"mt-3 text-xs leading-relaxed text-muted-foreground",children:[h>0&&g>0&&(0,b.jsxs)(b.Fragment,{children:[Math.round(g/h*100),"% of input was served from cache."," "]}),"API-equivalent estimate at list prices on the day of each request, not a bill: subscription and request-based plans charge differently."," ",(0,b.jsx)(p.Button,{variant:"link",onClick:()=>e(!0),"aria-haspopup":"dialog",className:"inline h-auto rounded-sm p-0 text-xs text-foreground underline underline-offset-2 hover:text-brand",children:"See the rates and arithmetic"}),i&&(0,b.jsxs)(b.Fragment,{children:[" ","No price is known for ",a.unpricedModels.join(", "),", so the total leaves ",a.unpricedModels.length>1?"them":"it"," out; add one in"," ",(0,b.jsx)("code",{className:"font-mono",children:"~/.agent-session-inspector/pricing.json"}),"."]})]}),(0,b.jsx)(bB,{cost:a,open:d,onOpenChange:e})]})}function bQ({cost:a,events:c,onOpenEvent:d}){return 0===a.byModel.length?(0,b.jsx)("p",{className:"rounded-xl border border-border bg-card p-5 text-xs text-muted-foreground",children:"This session recorded no token usage, so there is nothing to price."}):(0,b.jsxs)("div",{className:"space-y-6",children:[(0,b.jsx)(bP,{cost:a}),(0,b.jsx)(bD,{events:c,partial:a.unpricedModels.length>0,onOpenEvent:d}),(0,b.jsx)(bO,{events:c,onOpenEvent:d})]})}var bR=a.i(90892);let bS=/(?<!<)<<(?!<)-?\s*(['"]?)([A-Za-z_]\w*)\1/g,bT=/^__heredoc_(\d+)__$/,bU=new Set(["sudo","command","env","time","nohup","exec","xargs"]),bV=/^(ba|z|da)?sh$/,bW=/^(python[\d.]*|node|bun|deno)$/,bX=a=>a.startsWith("-");function bY(a,b=/^-[a-zA-Z]*[ef]$|^--(expression|file)$/){let c=[],d=!1;for(let e=0;e<a.length;e++)b.test(a[e])?(d=!0,e++):bX(a[e])||""===a[e]||c.push(a[e]);return{files:c,scripted:d}}let bZ=String.raw`(?:(['"\`])([^'"\`\n]+)\1|([A-Za-z_$][\w$]*))`,b$=[RegExp(String.raw`\bopen\(\s*${bZ}\s*,\s*(?:mode\s*=\s*)?['"](?=[^'"]*[wax+])[rwaxbt+]+['"]`,"g"),RegExp(String.raw`\bPath\(\s*${bZ}\s*\)\s*\.write_(?:text|bytes)\(`,"g"),RegExp(String.raw`\b(?:write|append)File(?:Sync)?\(\s*${bZ}`,"g")],b_=/^(\/dev\/|\/tmp\/|\/private\/tmp\/|\/var\/folders\/|\/private\/var\/folders\/)/,b0=a=>""!==a&&"-"!==a&&!/[$`*?{}]/.test(a)&&!a.startsWith("~")&&!b_.test(a);function b1(a,b){if(b.startsWith("/")||!a)return b.replace(/^(\.\/)+/,"");let c=a.split("/");for(let a of b.split("/"))".."===a?c.pop():"."!==a&&""!==a&&c.push(a);return c.join("/")}let b2=["file_path","filePath","notebook_path","path","target_file"],b3=/^(edit|write|multiedit|notebookedit|update|create|patch|apply_patch|replace|search_replace|str_replace\w*|(copilot_)?(write|edit|create|replace|insert)\w*(file|string|edit|notebook)\w*)$/i,b4=/^(bash|sh|zsh|shell|exec|exec_command|shell_command|local_shell|terminal|run_in_terminal|run_terminal_cmd|run_terminal_command\w*|run_shell_command|run_command|execute_command|container\.exec)$/i,b5=/^\*\*\* (?:Add|Update|Delete) File: (.+)$/gm,b6=a=>[...new Set([...a.matchAll(b5)].map(a=>a[1].trim()))];function b7(a,b){let c=new Set;for(let b of a)"file.patch_applied"===b.type&&b.data.callId&&c.add(b.data.callId);let d=[],e={turn:0,timestamp:a[0]?.timestamp??"",files:[],edits:0},f=0,g=(a,b,c)=>{0===e.files.length&&d.push(e),e.edits++;let f=e.files.find(a=>a.path===b);f?(f.count++,f.tools.includes(c)||f.tools.push(c)):e.files.push({path:b,count:1,tools:[c],eventId:a.id})};for(let d of a)if("user.message"===d.type)e={turn:++f,prompt:"string"==typeof d.data.content?d.data.content:void 0,promptEventId:d.id,timestamp:d.timestamp,files:[],edits:0};else if("file.patch_applied"===d.type){if(!1===d.data.success)continue;for(let a of d.data.changes??[])a?.file&&g(d,a.file,"patch")}else if("tool.execution_start"===d.type){let a=function(a){let b=a.toolName??a.name;return"string"==typeof b?b:""}(d.data);if(c.has(d.data.toolCallId))continue;for(let c of b3.test(a)?function(a){let b=a.arguments,c=b&&"object"==typeof b?b:{};for(let a of b2){let b=c[a];if("string"==typeof b&&b)return[b]}let d="string"==typeof b?b:c.input??c.patch??c.patchText;return"string"!=typeof d?[]:b6(d)}(d.data):b4.test(a)?function(a,b){let c=function(a){let b=a.arguments;if("string"==typeof b)return b;let c=b&&"object"==typeof b?b:{},d=c.command??c.cmd??c.script??c.input;return"string"==typeof d?d:Array.isArray(d)&&d.every(a=>"string"==typeof a)?/^-l?c$/.test(d[1]??"")&&3===d.length?d[2]:d.join(" "):void 0}(a);if(!c)return[];let d=b6(c);return d.length>0?d:function a(b,c){let{shell:d,bodies:e}=function(a){let b=[],c=[],d=a.split("\n");for(let a=0;a<d.length;a++){let e=[];for(let f of(b.push(d[a].replace(bS,(a,b,d)=>(e.push(d),`<<__heredoc_${c.length+e.length-1}__`))),e)){let b=[];for(;++a<d.length&&d[a].trim()!==f;)b.push(d[a]);c.push(b.join("\n"))}}return{shell:b.join("\n"),bodies:c}}(b),f=new Set,g=c?.replace(/\/+$/,""),h=a=>{if(!b0(a))return;let b=b1(g,a);b_.test(b)||f.add(b)};for(let{words:b,writes:c,inputs:i}of function(a){let b=[],c={words:[],writes:[],inputs:[]},d=null,e="words",f=()=>{null!==d&&(c[e].push(d),d=null,e="words")},g=()=>{f(),(c.words.length>0||c.writes.length>0)&&b.push(c),c={words:[],writes:[],inputs:[]},e="words"};for(let b=0;b<a.length;b++){let c=a[b];if("\\"===c)"\n"!==a[++b]&&(d=(d??"")+(a[b]??""));else if("'"===c){let c=a.indexOf("'",b+1),e=c<0?a.length:c;d=(d??"")+a.slice(b+1,e),b=e}else if('"'===c){let c="";for(b++;b<a.length&&'"'!==a[b];b++)"\\"===a[b]&&b+1<a.length&&b++,c+=a[b];d=(d??"")+c}else if(" "===c||" "===c)f();else if("#"===c&&null===d)for(;b+1<a.length&&"\n"!==a[b+1];)b++;else if("&"===c&&">"===a[b+1])f();else if("\n"===c||";"===c||"|"===c||"&"===c||"("===c||")"===c)g();else if(">"===c){if(null!==d&&/^\d+$/.test(d)?d=null:f(),(">"===a[b+1]||"|"===a[b+1])&&b++,"&"===a[b+1]){b++;let c=/^[\d-]+/.exec(a.slice(b+1));if(c){b+=c[0].length;continue}}e="writes"}else if("<"===c){for(f();"<"===a[b+1]||"-"===a[b+1];)b++;e="inputs"}else d=(d??"")+c}return g(),b}(d)){let d=0;for(;d<b.length&&(/^\w+=/.test(b[d])||bU.has(b[d]));)d++;let j=b[d]?.split("/").pop()??"",k=b.slice(d+1),l=i.flatMap(a=>e[Number(bT.exec(a)?.[1])]??[]);if("cd"===j)k[0]&&b0(k[0])&&(k[0].startsWith("/")||g)&&(g=b1(g,k[0]));else if(bV.test(j)){let b=k.findIndex(a=>/^-[a-zA-Z]*c$/.test(a));for(let c of b>=0?[k[b+1]??""]:l)a(c,g).forEach(a=>f.add(a))}else if(bW.test(j))for(let a of[...k,...l])(function(a){let b=[];for(let c of b$)for(let d of a.matchAll(c)){let c=d[2]??function(a,b,c){let d,e=b.replace(/\$/g,"\\$"),f=RegExp(String.raw`(?<![\w$.])${e}\s*=\s*(['"])([^'"\n]+)\1`,"g");for(let b of a.slice(0,c).matchAll(f))d=b[2];return d}(a,d[3],d.index);c&&b.push({index:d.index,path:c})}return b.sort((a,b)=>a.index-b.index).map(a=>a.path)})(a).forEach(h);else(function(a,b){"git"===a&&("mv"===b[0]||"rm"===b[0])&&(a=b[0],b=b.slice(1));let c=b.some(a=>/^-[a-zA-Z]*[rR]/.test(a)||"--recursive"===a);switch(a){case"tee":case"touch":case"mv":return bY(b).files;case"sed":case"gsed":{if(!b.some(a=>/^-[a-zA-Z]*i/.test(a)||a.startsWith("--in-place")))return[];let{files:a,scripted:c}=bY(b);return c?a:a.slice(1)}case"perl":if(!b.some(a=>/^-[a-zA-Z]*i/.test(a)))return[];return bY(b,/^-[a-zA-Z]*e$/).files;case"rm":return c?[]:bY(b).files;case"cp":return c?[]:bY(b).files.slice(-1);default:return[]}})(j,k).forEach(h);c.forEach(h)}return[...f]}(c,b)}(d.data,b):[])g(d,c,a)}return d}let b8=(a,b)=>`${a.toLocaleString()} ${b}${1===a?"":"s"}`;function b9({events:a,cwd:d,onOpenEvent:e}){let[f,g]=(0,c.useState)(""),h=(0,c.useMemo)(()=>b7(a,d),[a,d]),i=f.trim().toLowerCase(),j=(0,c.useMemo)(()=>i?h.map(a=>({...a,files:a.files.filter(a=>a.path.toLowerCase().includes(i))})).filter(a=>a.files.length>0):h,[h,i]);if(0===h.length)return(0,b.jsx)(bR.EmptyState,{icon:k,title:"No file edits",description:"Files appear here, grouped by prompt, when the agent writes, edits or patches one, or changes one from the shell."});let l=d?`${d.replace(/[\\/]+$/,"")}/`:null,m=new Set(h.flatMap(a=>a.files.map(a=>a.path))).size,n=h.reduce((a,b)=>a+b.edits,0);return(0,b.jsxs)("div",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[m>8&&(0,b.jsx)(ap.SearchInput,{value:f,onChange:g,placeholder:"Filter files…","aria-label":"Filter edited files",className:"w-full max-w-sm"}),(0,b.jsxs)("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground",children:[b8(m,"file")," · ",b8(n,"edit")," · ",b8(h.length,"turn")]})]}),j.map(a=>(0,b.jsxs)("section",{className:"overflow-hidden rounded-xl border border-border bg-card",children:[(0,b.jsxs)("header",{className:"flex items-baseline gap-3 border-b border-border bg-muted/40 px-3 py-2",children:[(0,b.jsx)("span",{className:"shrink-0 text-xs font-medium tabular-nums text-muted-foreground",children:a.turn>0?`Turn ${a.turn}`:"Start"}),a.promptEventId?(0,b.jsx)("button",{type:"button",onClick:()=>e(a.promptEventId),title:"Open this prompt in the timeline",className:"min-w-0 flex-1 truncate rounded-sm text-left text-sm font-medium hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:(0,as.firstLine)(a.prompt)??"Prompt"}):(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm text-muted-foreground",children:"Before the first prompt"}),(0,b.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[b8(a.files.length,"file")," · ",(0,as.formatDateTime)(a.timestamp)]})]}),(0,b.jsx)("ul",{children:a.files.map(a=>{let c;return(0,b.jsxs)("li",{className:"group flex items-center gap-3 border-b border-border/60 px-3 py-2 text-sm last:border-b-0 hover:bg-muted/50",children:[(0,b.jsx)("button",{type:"button",onClick:()=>e(a.eventId),title:`${a.path}
|
|
6
|
+
Open the edit in the timeline`,className:"min-w-0 flex-1 truncate rounded-sm text-left font-mono text-[13px] hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:(c=a.path,l&&c.startsWith(l)?c.slice(l.length):c)}),(0,b.jsx)("span",{className:"opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",children:(0,b.jsx)(s.CopyButton,{value:a.path,label:"Copy path"})}),(0,b.jsx)("span",{className:"shrink-0 font-mono text-xs text-muted-foreground",children:a.tools.join(", ")}),(0,b.jsx)("span",{className:"w-8 shrink-0 text-right text-xs tabular-nums text-muted-foreground",children:a.count>1?`\xd7${a.count}`:""})]},a.path)})})]},a.promptEventId??"start")),0===j.length&&(0,b.jsxs)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:["No files match “",f,"”"]})]})}var ca=a.i(73946);let cb=(0,f.default)("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]),cc=(0,f.default)("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);var cd=a.i(21732);let ce=(0,f.default)("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]),cf=(0,f.default)("folder-search",[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]);var cg=a.i(44264),ch=a.i(14300),ci=a.i(84213);let cj=(0,f.default)("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);var ck=a.i(89065),cl=a.i(63167),cm=a.i(27855);function cn({health:a,open:c,onOpenChange:d,onFocus:e}){return(0,b.jsx)(U.Dialog,{open:c,onOpenChange:d,children:(0,b.jsxs)(U.DialogContent,{children:[(0,b.jsx)(U.DialogTitle,{children:"Session health"}),(0,b.jsx)(U.DialogDescription,{children:"A rule-based score read straight off the transcript. It measures how smoothly the session ran, not whether the result was any good."}),(0,b.jsxs)("div",{className:"flex items-center gap-4",children:[(0,b.jsx)(cl.GradeBadge,{grade:a.grade,className:"h-12 min-w-12 rounded-lg text-2xl"}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("div",{className:"flex items-baseline gap-1.5",children:[(0,b.jsx)("span",{className:"text-2xl font-bold leading-none tabular-nums",children:a.score}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:"/ 100"}),(0,b.jsx)("span",{className:"ml-auto text-xs font-medium",children:cm.OUTCOME_LABELS[a.outcome]})]}),(0,b.jsx)("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-muted",children:(0,b.jsx)("div",{className:(0,av.cn)("h-full rounded-full",cm.GRADE_STYLES[a.grade].bar),style:{width:`${a.score}%`}})})]})]}),0===a.signals.length?(0,b.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3 dark:border-emerald-900 dark:bg-emerald-950/30",children:[(0,b.jsx)(ck.CheckCircle2,{className:"size-4 shrink-0 text-emerald-600 dark:text-emerald-400","aria-hidden":!0}),(0,b.jsxs)("p",{className:"text-sm",children:["Nothing went wrong. ",cm.OUTCOME_NOTES[a.outcome]]})]}):(0,b.jsx)("ul",{className:"divide-y divide-border overflow-hidden rounded-lg border border-border",children:a.signals.map(c=>{let f=cm.SIGNAL_INFO[c.id];return(0,b.jsxs)("li",{className:"px-3 py-2.5",children:[(0,b.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,b.jsx)("span",{className:"text-sm font-medium",children:"outcome"===c.id?cm.OUTCOME_LABELS[a.outcome]:f.label}),(0,b.jsxs)("span",{className:"shrink-0 font-mono text-xs font-semibold tabular-nums text-red-600 dark:text-red-400",children:["−",c.penalty]})]}),(0,b.jsxs)("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:[f.describe(c,a)," ",f.advice]}),f.focus&&e&&(0,b.jsxs)(p.Button,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>{d(!1),f.focus&&e(f.focus)},children:["View related events",(0,b.jsx)(cj,{"data-icon":"inline-end","aria-hidden":!0})]})]},c.id)})}),(0,b.jsxs)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:["Every session starts at 100 and loses points for each signal above. 90 and up is an A, 80 a B, 70 a C, 60 a D; anything lower is an F.",a.toolResults>0&&0===a.toolFailures&&(0,b.jsxs)(b.Fragment,{children:[" All ",a.toolResults.toLocaleString()," tool results succeeded."]})]})]})})}var co=a.i(75775);function cp(a){return a>=1e6?`${(a/1e6).toFixed(2)}M`:a>=1e3?`${(a/1e3).toFixed(1)}K`:a.toLocaleString()}function cq({meta:a}){let[d,e]=(0,c.useState)(!1);async function f(){try{let b=await fetch(`/api/sessions/${a.provider}/${encodeURIComponent(a.id)}/reveal`,{method:"POST"});e(!b.ok)}catch{e(!0)}}return(0,b.jsxs)(T.Tooltip,{children:[(0,b.jsx)(T.TooltipTrigger,{render:(0,b.jsxs)(p.Button,{variant:"ghost",size:"xs",onClick:f,className:(0,av.cn)("text-muted-foreground",d&&"text-destructive"),children:[(0,b.jsx)(cf,{className:"size-3.5","aria-hidden":!0}),"Reveal"]})}),(0,b.jsx)(T.TooltipContent,{children:d?"Could not open a file manager here. Copy the path instead.":"Show this session's files in the file manager"})]})}function cr({meta:a,storagePath:e,revealable:f=!1,stats:g,cost:h,context:i,activeMs:j,running:k=!1,onFocusEvents:l}){let m=(0,as.firstLine)(a.name),n=a.title??m,o=a.title?m:void 0,[p,q]=(0,c.useState)(!1),[r,t]=(0,c.useState)(!1),u=a.health,v=(0,ai.providerStyle)(a.provider),w=(0,co.resumeCommand)(a),x=g?.totalInputTokens??0,y=g?.totalOutputTokens??0,z=g?.totalCacheReadTokens??0,A=x+y+z;return(0,b.jsx)("div",{className:"border-b border-border bg-card/40",children:(0,b.jsxs)("div",{className:"mx-auto max-w-6xl px-4 py-5 sm:px-6",children:[(0,b.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between sm:gap-4",children:[(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsx)("h1",{className:"text-lg font-bold leading-tight text-foreground sm:text-xl",children:n??(0,b.jsx)("span",{className:"font-normal italic text-muted-foreground",children:"Unnamed session"})}),o&&(0,b.jsx)("p",{className:"mt-1 line-clamp-2 text-xs text-muted-foreground",children:o}),(0,b.jsxs)("div",{className:"mt-1.5 flex flex-wrap items-center gap-1",children:[(0,b.jsx)("span",{className:"truncate font-mono text-xs text-muted-foreground",children:a.id}),(0,b.jsx)(s.CopyButton,{value:a.id,label:"Copy session id"}),w&&(0,b.jsx)(s.CopyButton,{value:w,label:"Copy the command that resumes this session in a terminal",icon:ch.Terminal,className:"ml-1",children:"Resume"}),e&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(s.CopyButton,{value:e,label:`Copy where this session is stored: ${e}`,icon:ce,children:"Path"}),f&&(0,b.jsx)(cq,{meta:a})]})]})]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:shrink-0 sm:justify-end",children:[k&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-emerald-300 bg-emerald-50 px-2.5 py-0.5 text-xs font-medium text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-300",children:[(0,b.jsx)("span",{className:"size-1.5 animate-pulse rounded-full bg-emerald-500","aria-hidden":!0}),"Running"]}),(0,b.jsxs)("span",{className:(0,av.cn)("inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-xs font-medium",v.badgeCls),children:[(0,b.jsx)("span",{className:(0,av.cn)("size-1.5 rounded-full",v.dotCls),"aria-hidden":!0}),v.label]}),a.model&&(0,b.jsx)(R.Badge,{variant:"secondary",className:"font-mono",children:a.model}),a.client_name&&(0,b.jsx)(R.Badge,{variant:"secondary",children:a.client_name}),a.host_type&&(0,b.jsx)(R.Badge,{variant:"outline",children:a.host_type})]})]}),(0,b.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-x-4 gap-y-1.5 text-xs text-muted-foreground",children:[a.project&&(0,b.jsxs)(d.default,{href:`/?tab=sessions&project=${encodeURIComponent(a.project)}`,title:a.projectPath,className:"inline-flex min-w-0 items-center gap-1.5 rounded-sm hover:text-foreground hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:[(0,b.jsx)(cd.FolderGit2,{className:"size-3.5 shrink-0 opacity-70","aria-hidden":!0}),(0,b.jsx)("span",{className:"truncate font-medium text-foreground/80",children:a.project})]}),a.repository&&(0,b.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[(0,b.jsx)(cc,{className:"size-3.5 shrink-0 opacity-70","aria-hidden":!0}),(0,b.jsx)("span",{className:"truncate font-mono text-foreground/80",children:a.repository})]}),a.branch&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,b.jsx)(cg.GitBranch,{className:"size-3.5 opacity-70","aria-hidden":!0}),(0,b.jsx)("span",{className:"font-mono",children:a.branch})]}),a.created_at&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,b.jsx)(ca.CalendarDays,{className:"size-3.5 opacity-70","aria-hidden":!0}),(0,as.formatFullDateTime)(a.created_at)]}),a.updated_at&&(0,b.jsxs)(T.Tooltip,{children:[(0,b.jsx)(T.TooltipTrigger,{render:(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,b.jsx)(cb,{className:"size-3.5 opacity-70","aria-hidden":!0}),"Updated ",(0,as.timeAgo)(a.updated_at)]})}),(0,b.jsx)(T.TooltipContent,{children:(0,as.formatFullDateTime)(a.updated_at)})]})]}),g&&(0,b.jsxs)("div",{className:"mt-4",children:[(0,b.jsxs)(ci.StatCardGrid,{children:[(0,b.jsx)(ci.StatCard,{label:"Events",value:g.eventCount.toLocaleString(),sub:"recorded in session"}),(0,b.jsx)(ci.StatCard,{label:"Messages",value:(g.totalUserMessages+g.totalAssistantMessages).toLocaleString(),sub:`${g.totalUserMessages} user \xb7 ${g.totalAssistantMessages} assistant`}),(0,b.jsx)(ci.StatCard,{label:"Tool calls",value:g.totalToolCalls.toLocaleString(),sub:"local + external"}),(0,b.jsx)(ci.StatCard,{label:"Total tokens",value:A>0?cp(A):"—",sub:"in + out + cache",accent:!0}),i&&(0,b.jsx)(ci.StatCard,{label:"Context",value:cp(i.latest),sub:i.peak>i.latest?`sent by the last request \xb7 peak ${cp(i.peak)}`:"sent by the last request"}),h&&(h.inherited||h.byModel.some(a=>null!==a.costUSD))&&(0,b.jsx)(ci.StatCard,{label:"Est. cost",value:`${(0,as.formatCost)(h.totalUSD)}${h.unpricedModels.length>0?"+":""}`,sub:h.unpricedModels.length>0?`excludes ${h.unpricedModels.join(", ")}`:h.inherited?`+ ${(0,as.formatCost)(h.inherited.totalUSD)} inherited`:"at API list prices",onClick:()=>q(!0)}),u&&(0,b.jsx)(ci.StatCard,{label:"Health",value:(0,cm.healthSummary)(u),sub:u.signals.length>0?`${cm.OUTCOME_LABELS[u.outcome].toLowerCase()} \xb7 ${u.signals.length} signal${1===u.signals.length?"":"s"}`:cm.OUTCOME_LABELS[u.outcome].toLowerCase(),onClick:()=>t(!0)}),x>0&&(0,b.jsx)(ci.StatCard,{label:"Input tokens",value:cp(x),sub:"fresh input"}),y>0&&(0,b.jsx)(ci.StatCard,{label:"Output tokens",value:cp(y),sub:"generated"}),z>0&&(0,b.jsx)(ci.StatCard,{label:"Cache reads",value:cp(z),sub:"reused context"}),g.totalPremiumRequests>0&&(0,b.jsx)(ci.StatCard,{label:"Premium req",value:g.totalPremiumRequests.toLocaleString(),sub:"billed requests"}),g.totalApiDurationMs>0&&(0,b.jsx)(ci.StatCard,{label:"API time",value:(0,as.formatDuration)(g.totalApiDurationMs),sub:"waiting on the model"}),null!=j&&j>0&&(0,b.jsx)(ci.StatCard,{label:"Time span",value:(0,as.formatDuration)(j),sub:"first to last event"})]}),h&&(0,b.jsx)(bB,{cost:h,open:p,onOpenChange:q}),u&&(0,b.jsx)(cn,{health:u,open:r,onOpenChange:t,onFocus:l})]})]})})}var cs=a.i(24848),ct=a.i(66535),ct=ct,cu=a.i(4888);let cv={high:{label:"High impact",Icon:ct.default,card:"border-red-200 bg-red-50 dark:border-red-900 dark:bg-red-950/30",icon:"text-red-600 dark:text-red-400"},medium:{label:"Medium impact",Icon:ct.default,card:"border-amber-200 bg-amber-50 dark:border-amber-900 dark:bg-amber-950/30",icon:"text-amber-600 dark:text-amber-400"},low:{label:"Info",Icon:K.Info,card:"border-emerald-200 bg-emerald-50 dark:border-emerald-900 dark:bg-emerald-950/30",icon:"text-emerald-600 dark:text-emerald-400"}},cw=["high","medium","low"];function cx({analysis:a,stats:c,eventTypeCounts:d,onFocusHint:e}){let f=[{label:"System context",note:"agent managed",chars:a.systemContextChars,bar:"bg-red-400 dark:bg-red-500",text:"text-red-700 dark:text-red-400"},{label:"Tool results",chars:a.toolResultChars,bar:"bg-amber-400 dark:bg-amber-500",text:"text-amber-700 dark:text-amber-400"},{label:"Assistant replies",chars:a.assistantChars,bar:"bg-sky-400 dark:bg-sky-500",text:"text-sky-700 dark:text-sky-400"}],g=f.reduce((a,b)=>a+b.chars,0),h=cw.flatMap(b=>a.hints.filter(a=>a.severity===b));return(0,b.jsxs)("div",{className:"space-y-6",children:[(0,b.jsxs)("section",{children:[(0,b.jsxs)("h2",{className:"mb-3 flex items-center gap-2 text-sm font-semibold text-foreground",children:[(0,b.jsx)(n,{className:"size-4 text-brand","aria-hidden":!0}),"Optimization hints",h.length>0&&(0,b.jsx)("span",{className:"rounded-sm bg-muted px-1.5 text-xs font-normal tabular-nums text-muted-foreground",children:h.length})]}),0===h.length?(0,b.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3 dark:border-emerald-900 dark:bg-emerald-950/30",children:[(0,b.jsx)(ck.CheckCircle2,{className:"size-4 shrink-0 text-emerald-600 dark:text-emerald-400","aria-hidden":!0}),(0,b.jsx)("p",{className:"text-sm text-foreground",children:"No issues detected in this session’s context usage."})]}):(0,b.jsx)("div",{className:"space-y-3",children:h.map(a=>{let c=cv[a.severity];return(0,b.jsx)("article",{className:(0,av.cn)("rounded-xl border p-4",c.card),children:(0,b.jsxs)("div",{className:"flex items-start gap-3",children:[(0,b.jsx)(c.Icon,{className:(0,av.cn)("mt-0.5 size-4 shrink-0",c.icon),"aria-hidden":!0}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,b.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:a.category}),(0,b.jsx)("span",{className:"sr-only",children:c.label}),a.saving&&(0,b.jsxs)("span",{className:"rounded-sm border border-border bg-background px-1.5 py-0.5 font-mono text-xs text-foreground",children:["save ~",a.saving]})]}),(0,b.jsx)("p",{className:"mt-0.5 text-sm font-semibold text-foreground",children:a.title}),(0,b.jsx)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:a.description}),a.focus&&(0,b.jsxs)(p.Button,{variant:"outline",size:"sm",onClick:()=>a.focus&&e(a.focus),className:"mt-2.5",children:["View related events",(0,b.jsx)(cj,{"data-icon":"inline-end","aria-hidden":!0})]})]})]})},`${a.category}-${a.title}`)})})]}),(0,b.jsxs)("section",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsx)("h2",{className:"mb-4 text-sm font-semibold text-foreground",children:"Context usage breakdown"}),0===g?(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"No measurable context recorded for this session."}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"mb-4 flex h-2.5 overflow-hidden rounded-full bg-muted",children:f.map(({label:a,chars:c,bar:d})=>(0,b.jsx)("div",{className:d,style:{width:`${c/g*100}%`}},a))}),(0,b.jsx)("div",{className:"space-y-2.5",children:f.map(({label:a,note:c,chars:d,bar:e,text:f})=>{let h=Math.round(d/g*100);return(0,b.jsxs)("div",{className:"flex items-center gap-3",children:[(0,b.jsxs)("div",{className:"flex w-36 shrink-0 items-center gap-2 sm:w-60",children:[(0,b.jsx)("span",{className:(0,av.cn)("size-2 shrink-0 rounded-full",e),"aria-hidden":!0}),(0,b.jsxs)("span",{className:"truncate text-xs text-foreground",children:[a,c&&(0,b.jsxs)("span",{className:"ml-1 hidden text-muted-foreground sm:inline",children:["(",c,")"]})]})]}),(0,b.jsx)("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:(0,b.jsx)("div",{className:(0,av.cn)("h-full rounded-full",e),style:{width:`${h}%`}})}),(0,b.jsxs)("span",{className:(0,av.cn)("w-20 text-right font-mono text-xs font-semibold tabular-nums",f),children:[(d/1e3).toFixed(0),"K chars"]}),(0,b.jsxs)("span",{className:"w-9 text-right text-xs tabular-nums text-muted-foreground",children:[h,"%"]})]},a)})})]}),(0,b.jsx)("div",{className:"mt-5 grid grid-cols-2 gap-3 border-t border-border pt-4 sm:grid-cols-4",children:[{label:"Output tokens",value:c.totalOutputTokens>0?`${(c.totalOutputTokens/1e3).toFixed(1)}K`:"—"},{label:"Input tokens",value:c.totalInputTokens>0?`${(c.totalInputTokens/1e3).toFixed(1)}K`:"N/A (active)"},{label:"Compactions",value:String(a.compactionCount)},{label:"Hook events",value:String(a.hookEventCount)}].map(({label:a,value:c})=>(0,b.jsxs)("div",{className:"text-center",children:[(0,b.jsx)("div",{className:"font-mono text-base font-bold tabular-nums text-foreground",children:c}),(0,b.jsx)("div",{className:"mt-0.5 text-xs text-muted-foreground",children:a})]},a))})]}),(0,b.jsxs)("section",{className:"grid gap-4 md:grid-cols-2",children:[(0,b.jsxs)("div",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsx)("h3",{className:"mb-3 text-sm font-semibold text-foreground",children:"Tool usage"}),(0,b.jsx)(cu.BarList,{items:a.topToolsByCount.map(({name:a,count:b})=>({name:a,value:b})),color:"bg-chart-3",emptyLabel:"No tool calls recorded."})]}),(0,b.jsxs)("div",{className:"rounded-xl border border-border bg-card p-5",children:[(0,b.jsx)("h3",{className:"mb-3 text-sm font-semibold text-foreground",children:"Event types"}),(0,b.jsx)(cu.BarList,{items:d,color:"bg-brand-2",limit:10,emptyLabel:"No events recorded."})]})]})]})}function cy({checkpoints:a}){let[d,e]=(0,c.useState)(new Set);return 0===a.length?(0,b.jsx)(bR.EmptyState,{icon:h,title:"No checkpoints",description:"Copilot CLI writes checkpoint files when it summarizes progress. Claude Code and Codex sessions have none."}):(0,b.jsx)("div",{className:"space-y-2",children:a.map(a=>{let c=d.has(a.name);return(0,b.jsxs)("div",{className:"overflow-hidden rounded-xl border border-border",children:[(0,b.jsxs)("button",{type:"button",onClick:()=>{var b;return b=a.name,void e(a=>{let c=new Set(a);return c.has(b)?c.delete(b):c.add(b),c})},"aria-expanded":c,className:"flex w-full items-center gap-3 bg-muted/60 px-4 py-3 text-left transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring",children:[(0,b.jsx)(F.ChevronRight,{className:(0,av.cn)("size-4 shrink-0 text-muted-foreground transition-transform",c&&"rotate-90"),"aria-hidden":!0}),(0,b.jsx)(l.FileText,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-sm font-medium text-foreground",children:a.name}),a.content&&(0,b.jsxs)("span",{className:"shrink-0 text-xs tabular-nums text-muted-foreground",children:[a.content.length.toLocaleString()," chars"]})]}),c&&(a.content?(0,b.jsxs)("div",{className:"border-t border-border",children:[(0,b.jsx)("div",{className:"flex justify-end border-b border-border bg-background px-2 py-1",children:(0,b.jsx)(s.CopyButton,{value:a.content,label:"Copy checkpoint"})}),(0,b.jsx)(r.ScrollArea,{className:"h-[60vh] w-full",children:(0,b.jsx)("pre",{className:"w-max min-w-full p-4 font-mono text-xs text-foreground",children:a.content})})]}):(0,b.jsx)("p",{className:"border-t border-border p-4 text-sm text-muted-foreground",children:"Empty file"}))]},a.name)})})}function cz({paths:a,kind:d}){let[e,f]=(0,c.useState)(""),g=e.trim().toLowerCase(),h=g?a.filter(a=>a.toLowerCase().includes(g)):a,i="research"===d?m:l.FileText;return 0===a.length?(0,b.jsx)(bR.EmptyState,{icon:i,title:"research"===d?"No research files":"No files",description:"research"===d?"Research notes appear here when the agent saves its findings.":"No files recorded. Copilot lists its workspace files here; Claude Code and Codex list the files the session edited."}):(0,b.jsxs)("div",{className:"space-y-2",children:[a.length>8&&(0,b.jsx)(ap.SearchInput,{value:e,onChange:f,placeholder:"Filter paths…","aria-label":"Filter paths",className:"w-full max-w-sm"}),h.map(a=>(0,b.jsxs)("div",{className:"flex items-center gap-3 rounded-lg border border-border bg-card px-3 py-2.5 text-sm transition-colors hover:bg-muted/50",children:[(0,b.jsx)(i,{className:"size-4 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate font-mono text-foreground",children:a}),(0,b.jsx)(s.CopyButton,{value:a,label:"Copy path"})]},a)),0===h.length&&(0,b.jsxs)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:["No paths match “",e,"”"]})]})}let cA=["events","checkpoints","files","edits","research","workspace","cost","optimizer"];function cB({value:a}){return(0,b.jsx)("span",{className:"ml-1 rounded-sm bg-foreground/10 px-1.5 text-[11px] tabular-nums",children:a})}function cC({provider:a,id:f}){let[z,A]=(0,au.useTabParam)(cA,"events"),[B,C]=(0,c.useState)(null),[D,E]=(0,c.useState)(!0),[F,G]=(0,c.useState)(null),[H,I]=(0,c.useState)(null),[J]=(0,au.useQueryParam)("q",""),K=(0,c.useMemo)(()=>J?{nonce:0,search:J}:null,[J]),[L,M]=(0,c.useState)(J);J!==L&&(M(J),I(null));let[N,O]=(0,au.useQueryParam)("event",""),[P,Q]=(0,c.useState)(0),R=(0,c.useRef)(null),S=(0,c.useRef)(!1);(0,c.useEffect)(()=>{let b=!1;return(async()=>{try{let c=await fetch(`/api/sessions/${a}/${f}?probe=1`),d=c.ok?(await c.json()).revision:null,e=await fetch(`/api/sessions/${a}/${f}`);if(!e.ok)throw Error("Request failed");let g=await e.json();if(!g?.meta)throw Error("Not found");b||(R.current=d,S.current=!0,C(g))}catch{b||S.current||G("This session could not be loaded. It may have been removed.")}finally{b||E(!1)}})(),()=>{b=!0}},[a,f,P]);let[T,U]=(0,c.useState)(!1),V=(0,co.isRunning)(B?.meta.updated_at),[,W]=(0,c.useState)(0),X=null!==B&&(T||V),Y=B?.meta.updated_at;(0,c.useEffect)(()=>{if(!X)return;let b=!1,c=window.setInterval(async()=>{if(!document.hidden)try{let c=await fetch(`/api/sessions/${a}/${f}?probe=1`);if(!c.ok||b)return;let d=(await c.json()).revision;if(b)return;d!==R.current?Q(a=>a+1):(0,co.isRunning)(Y)||W(a=>a+1)}catch{}},3e3);return()=>{b=!0,window.clearInterval(c)}},[X,a,f,Y]);let Z=(0,c.useMemo)(()=>{let a=new Map;for(let b of B?.events??[])a.set(b.type,(a.get(b.type)??0)+1);return Array.from(a,([a,b])=>({name:a,value:b}))},[B]),$=(0,c.useMemo)(()=>{let{requests:a}=ar(B?.events??[]);if(!(a.length<2))return{latest:a[a.length-1].contextTokens,peak:Math.max(...a.map(a=>a.contextTokens))}},[B]),_=(0,c.useMemo)(()=>b7(B?.events??[],B?.meta.cwd).reduce((a,b)=>a+b.edits,0),[B]),aa=(0,c.useMemo)(()=>{let a=B?.events??[];if(a.length<2)return null;let b=a.map(a=>new Date(a.timestamp).getTime()).filter(a=>Number.isFinite(a));return b.length<2?null:Math.max(...b)-Math.min(...b)},[B]);function ab(a){A("events"),I({nonce:Date.now(),...a})}let[ac,ad]=(0,c.useState)(null);function ae(a){O(a),A("events"),ad({eventId:a,nonce:Date.now()})}(0,c.useEffect)(()=>{if(!ac||"events"!==z)return;let a=requestAnimationFrame(()=>document.querySelector(`[data-event-id="${CSS.escape(ac.eventId)}"]`)?.scrollIntoView({block:"center"}));return()=>cancelAnimationFrame(a)},[ac,z]);let af="checkpoints"===z&&B?.checkpoints.length===0||"research"===z&&B?.research.length===0?"events":z,ag=B?B.meta.title??(0,as.firstLine)(B.meta.name)??B.meta.id:f;return(0,b.jsxs)("div",{className:"min-h-screen bg-background text-foreground",children:[(0,b.jsx)("div",{className:"sticky top-0 z-30 border-b border-border bg-background/85 backdrop-blur supports-[backdrop-filter]:bg-background/70",children:(0,b.jsxs)("div",{className:"mx-auto flex h-[var(--cv-topbar-h)] max-w-6xl items-center gap-3 px-4 sm:px-6",children:[(0,b.jsx)(cs.SidebarTrigger,{className:"-ml-2 shrink-0"}),(0,b.jsxs)(p.Button,{variant:"ghost",nativeButton:!1,render:(0,b.jsx)(d.default,{href:"/?tab=sessions"}),className:"text-muted-foreground",children:[(0,b.jsx)(g,{"aria-hidden":!0}),(0,b.jsx)("span",{className:"hidden sm:inline",children:"Sessions"})]}),(0,b.jsx)("span",{className:"text-muted-foreground/50","aria-hidden":!0,children:"/"}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-foreground",children:ag}),(0,b.jsx)(w.SearchTrigger,{className:"shrink-0"}),(0,b.jsx)(cs.ShortcutsTrigger,{className:"hidden shrink-0 sm:inline-flex"}),(0,b.jsx)(v.PalettePicker,{className:"shrink-0"}),(0,b.jsx)(x.ThemeToggle,{className:"shrink-0"}),(0,b.jsx)(y.AboutDialog,{className:"shrink-0"})]})}),D?(0,b.jsxs)("div",{className:"mx-auto max-w-6xl space-y-4 px-4 py-8 sm:px-6",children:[(0,b.jsx)(u.Skeleton,{className:"h-7 w-2/3"}),(0,b.jsx)(u.Skeleton,{className:"h-4 w-1/3"}),(0,b.jsx)("div",{className:"flex flex-wrap gap-2 pt-2",children:Array.from({length:6},(a,c)=>(0,b.jsx)(u.Skeleton,{className:"h-11 w-24"},c))}),(0,b.jsx)(u.Skeleton,{className:"h-9 w-96"}),(0,b.jsx)("div",{className:"space-y-3 pt-4",children:Array.from({length:6},(a,c)=>(0,b.jsx)(u.Skeleton,{className:"h-20 w-full"},c))})]}):F||!B?(0,b.jsx)("div",{className:"mx-auto max-w-6xl px-4 py-16 sm:px-6",children:(0,b.jsxs)("div",{className:"flex flex-col items-center gap-3 rounded-xl border border-dashed border-border px-6 py-14 text-center",children:[(0,b.jsx)(e.AlertTriangle,{className:"size-6 text-destructive","aria-hidden":!0}),(0,b.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Session unavailable"}),(0,b.jsx)("p",{className:"max-w-sm text-xs text-muted-foreground",children:F}),(0,b.jsxs)("div",{className:"mt-2 flex gap-2",children:[(0,b.jsx)(p.Button,{variant:"outline",size:"sm",onClick:function(){E(!0),G(null),Q(a=>a+1)},children:"Retry"}),(0,b.jsx)(p.Button,{size:"sm",nativeButton:!1,render:(0,b.jsx)(d.default,{href:"/?tab=sessions"}),children:"Back to sessions"})]})]})}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(cr,{meta:B.meta,storagePath:B.storagePath,revealable:B.revealable,stats:B.stats,cost:B.cost,context:$,activeMs:aa,running:V,onFocusEvents:ab}),(0,b.jsx)("main",{id:"main",className:"mx-auto max-w-6xl px-4 pt-2 pb-5 sm:px-6",children:(0,b.jsxs)(q.Tabs,{value:af,onValueChange:function(a){"events"!==a&&O(""),A(a)},className:"gap-0",children:[(0,b.jsx)("div",{className:"sticky top-[var(--cv-topbar-h)] z-20 -mx-4 overflow-x-auto scrollbar-none bg-background/85 px-4 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/70 sm:-mx-6 sm:px-6",children:(0,b.jsxs)(q.TabsList,{className:"w-max",children:[(0,b.jsxs)(q.TabsTrigger,{value:"events",className:"px-3",children:[(0,b.jsx)(o.Zap,{className:"size-4","aria-hidden":!0}),"Events",(0,b.jsx)(cB,{value:B.events.length})]}),B.checkpoints.length>0&&(0,b.jsxs)(q.TabsTrigger,{value:"checkpoints",className:"px-3",children:[(0,b.jsx)(h,{className:"size-4","aria-hidden":!0}),"Checkpoints",(0,b.jsx)(cB,{value:B.checkpoints.length})]}),(0,b.jsxs)(q.TabsTrigger,{value:"files",className:"px-3",children:[(0,b.jsx)(l.FileText,{className:"size-4","aria-hidden":!0}),"Files",(0,b.jsx)(cB,{value:B.files.length})]}),(0,b.jsxs)(q.TabsTrigger,{value:"edits",className:"px-3",children:[(0,b.jsx)(k,{className:"size-4","aria-hidden":!0}),"Edits",(0,b.jsx)(cB,{value:_})]}),B.research.length>0&&(0,b.jsxs)(q.TabsTrigger,{value:"research",className:"px-3",children:[(0,b.jsx)(m,{className:"size-4","aria-hidden":!0}),"Research",(0,b.jsx)(cB,{value:B.research.length})]}),(0,b.jsxs)(q.TabsTrigger,{value:"workspace",className:"px-3",children:[(0,b.jsx)(j,{className:"size-4","aria-hidden":!0}),"Metadata"]}),(0,b.jsxs)(q.TabsTrigger,{value:"cost",className:"px-3",children:[(0,b.jsx)(i,{className:"size-4","aria-hidden":!0}),"Cost"]}),(0,b.jsxs)(q.TabsTrigger,{value:"optimizer",className:"px-3",children:[(0,b.jsx)(n,{className:"size-4","aria-hidden":!0}),"Token Optimizer",B.tokenAnalysis?.hints.some(a=>"high"===a.severity)&&(0,b.jsx)("span",{className:"ml-1 inline-flex size-4 items-center justify-center rounded-full bg-red-500 text-[10px] font-bold text-white",title:"High-impact hints",children:B.tokenAnalysis.hints.filter(a=>"high"===a.severity).length})]})]})}),(0,b.jsx)(q.TabsContent,{value:"events",children:(0,b.jsx)(bt,{events:B.events,focusRequest:H??K,targetEventId:N||void 0,forkParentHref:B.meta.forkedFrom?`/sessions/${a}/${encodeURIComponent(B.meta.forkedFrom)}`:void 0,live:T,onLiveChange:U,running:V,clientVersion:B.meta.client_name})}),(0,b.jsx)(q.TabsContent,{value:"checkpoints",className:"pt-2",children:(0,b.jsx)(cy,{checkpoints:B.checkpoints})}),(0,b.jsx)(q.TabsContent,{value:"files",className:"pt-2",children:(0,b.jsx)(cz,{paths:B.files,kind:"file"})}),(0,b.jsx)(q.TabsContent,{value:"edits",className:"pt-2",children:(0,b.jsx)(b9,{events:B.events,cwd:B.meta.cwd,onOpenEvent:ae})}),(0,b.jsx)(q.TabsContent,{value:"research",className:"pt-2",children:(0,b.jsx)(cz,{paths:B.research,kind:"research"})}),(0,b.jsx)(q.TabsContent,{value:"workspace",className:"pt-2",children:(0,b.jsxs)("div",{className:"overflow-hidden rounded-xl border border-border",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 border-b border-border bg-muted/60 px-4 py-2",children:[(0,b.jsx)("span",{className:"font-mono text-xs text-muted-foreground",children:B.rawMeta.name}),B.rawMeta.content&&(0,b.jsx)(s.CopyButton,{value:B.rawMeta.content,label:`Copy ${B.rawMeta.name}`,className:"ml-auto"})]}),(0,b.jsx)(r.ScrollArea,{className:"h-[60vh] w-full",children:(0,b.jsx)("pre",{className:"w-max min-w-full p-4 font-mono text-xs text-foreground",children:B.rawMeta.content||"No session metadata found"})})]})}),(0,b.jsx)(q.TabsContent,{value:"cost",className:"pt-2",children:(0,b.jsx)(bQ,{cost:B.cost,events:B.events,onOpenEvent:ae})}),(0,b.jsx)(q.TabsContent,{value:"optimizer",className:"pt-2",children:(0,b.jsx)(cx,{analysis:B.tokenAnalysis,stats:B.stats,eventTypeCounts:Z,onFocusHint:ab})})]})})]}),(0,b.jsx)(t.ScrollToTop,{})]})}a.s(["default",0,function(a){let{provider:d,id:e}=(0,c.use)(a.params);return(0,b.jsx)(c.Suspense,{children:(0,b.jsx)(cC,{provider:d,id:e},`${d}/${e}`)})}],75136)}];
|
|
7
7
|
|
|
8
8
|
//# sourceMappingURL=src_app_sessions_%5Bprovider%5D_%5Bid%5D_page_tsx_0uf635h._.js.map
|