@tonyclaw/agent-inspector 2.0.4 → 2.0.6

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.
Files changed (61) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/{CompareDrawer-BCH_fsLm.js → CompareDrawer-DDmqSAfl.js} +1 -1
  3. package/.output/public/assets/ProxyViewerContainer-Cxpdziwd.js +101 -0
  4. package/.output/public/assets/ReplayDialog-Bt5DGzlh.js +1 -0
  5. package/.output/public/assets/RequestAnatomy-BxX3_N9S.js +1 -0
  6. package/.output/public/assets/ResponseView-Bl_5S9gZ.js +1 -0
  7. package/.output/public/assets/StreamingChunkSequence-RJMwNf6F.js +1 -0
  8. package/.output/public/assets/_sessionId-b4isaoDp.js +1 -0
  9. package/.output/public/assets/index-BZ4x5UI6.js +1 -0
  10. package/.output/public/assets/{index-CobXD0yH.css → index-C624DUk9.css} +1 -1
  11. package/.output/public/assets/{json-viewer-BrzjD7qI.js → json-viewer-CRL_gWEZ.js} +1 -1
  12. package/.output/public/assets/{main-mgxeUdZQ.js → main-CKnTJ4-O.js} +6 -6
  13. package/.output/server/_libs/lucide-react.mjs +181 -114
  14. package/.output/server/{_sessionId-C4xsxIWm.mjs → _sessionId-B-x9fRY3.mjs} +3 -3
  15. package/.output/server/_ssr/{CompareDrawer-DuWEpqQ7.mjs → CompareDrawer-BQVNsAY2.mjs} +6 -6
  16. package/.output/server/_ssr/{ProxyViewerContainer-Cckz5qKu.mjs → ProxyViewerContainer-CYm2Dw19.mjs} +766 -122
  17. package/.output/server/_ssr/{ReplayDialog-BDRcr8E5.mjs → ReplayDialog-CaMQBc79.mjs} +240 -14
  18. package/.output/server/_ssr/{RequestAnatomy-BoO2_Ij0.mjs → RequestAnatomy--P5arRH2.mjs} +236 -66
  19. package/.output/server/_ssr/{ResponseView-DZiPBxvO.mjs → ResponseView-RtFwNvgD.mjs} +8 -8
  20. package/.output/server/_ssr/{StreamingChunkSequence-D-be7KEL.mjs → StreamingChunkSequence-B5HPkzab.mjs} +3 -3
  21. package/.output/server/_ssr/{index-5RImHKfu.mjs → index-CZIKZU43.mjs} +2 -2
  22. package/.output/server/_ssr/index.mjs +2 -2
  23. package/.output/server/_ssr/{json-viewer-aJhb93ZK.mjs → json-viewer-d4obyRaA.mjs} +3 -3
  24. package/.output/server/_ssr/{router-Dgkv5nKP.mjs → router-DGPt3MUc.mjs} +145 -71
  25. package/.output/server/_tanstack-start-manifest_v-BzH4pNaI.mjs +4 -0
  26. package/.output/server/index.mjs +64 -64
  27. package/package.json +1 -1
  28. package/src/components/OnboardingBanner.tsx +11 -19
  29. package/src/components/ProxyViewer.tsx +1 -1
  30. package/src/components/providers/ProviderCard.tsx +6 -20
  31. package/src/components/providers/SettingsDialog.tsx +95 -2
  32. package/src/components/proxy-viewer/AgentTraceSummary.tsx +639 -38
  33. package/src/components/proxy-viewer/CompareDrawer.tsx +4 -2
  34. package/src/components/proxy-viewer/LogEntry.tsx +4 -4
  35. package/src/components/proxy-viewer/LogEntryHeader.tsx +15 -25
  36. package/src/components/proxy-viewer/ReplayDialog.tsx +190 -8
  37. package/src/components/proxy-viewer/ResponseView.tsx +2 -2
  38. package/src/components/proxy-viewer/ToolTraceEvents.tsx +37 -16
  39. package/src/components/proxy-viewer/TurnGroup.tsx +14 -2
  40. package/src/components/proxy-viewer/anatomy/RequestAnatomy.tsx +196 -45
  41. package/src/components/proxy-viewer/anatomy/SegmentBar.tsx +92 -67
  42. package/src/components/proxy-viewer/anatomy/types.ts +15 -13
  43. package/src/components/proxy-viewer/formats/anthropic/ResponseView.tsx +2 -2
  44. package/src/components/proxy-viewer/log-formats/anthropic.ts +1 -1
  45. package/src/components/proxy-viewer/log-formats/openai.ts +1 -1
  46. package/src/components/proxy-viewer/log-formats/types.ts +1 -1
  47. package/src/components/proxy-viewer/replayComparison.ts +131 -0
  48. package/src/components/proxy-viewer/useKeyboardNavigation.ts +64 -22
  49. package/src/components/proxy-viewer/viewerState.ts +14 -2
  50. package/src/components/ui/json-viewer.tsx +1 -1
  51. package/src/knowledge/candidateStore.ts +32 -1
  52. package/src/routes/api/knowledge.candidates.$candidateId.ts +50 -0
  53. package/src/routes/api/knowledge.sessions.$sessionId.candidates.ts +12 -2
  54. package/.output/public/assets/ProxyViewerContainer-D85_UANk.js +0 -101
  55. package/.output/public/assets/ReplayDialog-DTeaHHit.js +0 -1
  56. package/.output/public/assets/RequestAnatomy-DZ8grAih.js +0 -1
  57. package/.output/public/assets/ResponseView-Cldm6RCi.js +0 -1
  58. package/.output/public/assets/StreamingChunkSequence-3x4p-yT7.js +0 -1
  59. package/.output/public/assets/_sessionId-YqWFBu6d.js +0 -1
  60. package/.output/public/assets/index-BIw2H6jO.js +0 -1
  61. package/.output/server/_tanstack-start-manifest_v-B8rrWXjr.mjs +0 -4
@@ -0,0 +1 @@
1
+ import{r as c,j as s}from"./main-CKnTJ4-O.js";import{u as _,D as L,k as P,l as z,m as A,n as H,T as f,o as j,p as l,q as o,s as G,t as K,v as Q,w as U,x as W,y as X,z as C,A as T,E as O}from"./ProxyViewerContainer-Cxpdziwd.js";import{ResponseView as k}from"./ResponseView-Bl_5S9gZ.js";import"./json-viewer-CRL_gWEZ.js";function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Y(e){return e==null?null:new TextEncoder().encode(e).length}function Z(e){try{const t=JSON.parse(e);if(!D(t))return null;const a=t.model;return typeof a=="string"&&a.length>0?a:null}catch{return null}}function ee(e,t){try{const a=JSON.parse(e);return D(a)?{body:JSON.stringify({...a,model:t},null,2),error:null}:{body:e,error:"Request body must be a JSON object."}}catch{return{body:e,error:"Request body must be valid JSON before changing the replay model."}}}function $(e){return{status:e.status??null,elapsedMs:e.elapsedMs??null,inputTokens:e.inputTokens??null,outputTokens:e.outputTokens??null,responseBytes:Y(e.responseText),streaming:e.streaming===!0}}function m(e,t){return e===null||t===null?null:t-e}function se(e,t){return[{id:"status",label:"Status",original:e.status,replay:t.status,delta:m(e.status,t.status)},{id:"elapsed",label:"Elapsed",original:e.elapsedMs,replay:t.elapsedMs,delta:m(e.elapsedMs,t.elapsedMs)},{id:"input",label:"Input",original:e.inputTokens,replay:t.inputTokens,delta:m(e.inputTokens,t.inputTokens)},{id:"output",label:"Output",original:e.outputTokens,replay:t.outputTokens,delta:m(e.outputTokens,t.outputTokens)},{id:"bytes",label:"Bytes",original:e.responseBytes,replay:t.responseBytes,delta:m(e.responseBytes,t.responseBytes)},{id:"streaming",label:"Stream",original:e.streaming,replay:t.streaming,delta:null}]}const te=X({success:C(),error:O().optional(),responseStatus:T().nullable().optional(),responseText:O().nullable().optional(),inputTokens:T().nullable().optional(),outputTokens:T().nullable().optional(),elapsedMs:T().nullable().optional(),streaming:C().optional()});function E(e){return e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`}function B(e,t){if(e===null)return"-";if(typeof e=="boolean")return e?"stream":"non-stream";switch(t){case"elapsed":return E(e);case"input":case"output":case"bytes":return e.toLocaleString();case"status":return String(e);case"streaming":return e?"stream":"non-stream"}}function ne(e,t){if(e===null)return"-";const a=e>0?"+":"";switch(t){case"elapsed":return`${a}${E(e)}`;case"input":case"output":case"bytes":case"status":return`${a}${e.toLocaleString()}`;case"streaming":return"-"}}function re(e){return e===null||e===0?"text-muted-foreground":e>0?"text-amber-400":"text-emerald-400"}function q({comparisons:e}){return s.jsxs("div",{className:"overflow-hidden rounded-md border border-border",children:[s.jsxs("div",{className:"grid grid-cols-[1fr_1fr_1fr_1fr] bg-muted/40 px-3 py-2 text-[11px] font-medium text-muted-foreground",children:[s.jsx("span",{children:"Metric"}),s.jsx("span",{children:"Original"}),s.jsx("span",{children:"Replay"}),s.jsx("span",{children:"Delta"})]}),e.map(t=>s.jsxs("div",{className:"grid grid-cols-[1fr_1fr_1fr_1fr] border-t border-border px-3 py-2 text-xs",children:[s.jsx("span",{className:"text-muted-foreground",children:t.label}),s.jsx("span",{className:"font-mono",children:B(t.original,t.id)}),s.jsx("span",{className:"font-mono",children:B(t.replay,t.id)}),s.jsx("span",{className:`font-mono ${re(t.delta)}`,children:ne(t.delta,t.id)})]},t.id))]})}function ie({log:e,open:t,onOpenChange:a}){const{providers:R}=_(),[x,N]=c.useState(()=>e.rawRequestBody??"{}"),[n,h]=c.useState(null),[w,b]=c.useState(!1),[y,i]=c.useState(null);async function F(){b(!0),i(null),h(null);try{const u=await(await fetch(`/api/logs/${e.id}/replay`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modifiedBody:x})})).json(),p=te.safeParse(u);if(!p.success){i("Invalid response from server"),b(!1);return}const v=p.data;h(v),v.success||i(v.error??"Replay failed")}catch(r){i(r instanceof Error?r.message:"Network error")}finally{b(!1)}}function J(){h(null),i(null),a(!1)}const g=c.useMemo(()=>{const r=[];for(const u of R)for(const p of u.models)p.trim().length!==0&&r.push({key:`${u.id}:${p}`,providerName:u.name,model:p});return r},[R]),d=Z(x)??e.model??"";function I(r){const u=ee(x,r);if(u.error!==null){i(u.error);return}N(u.body),h(null),i(null)}const V=$({status:e.responseStatus,elapsedMs:e.elapsedMs,inputTokens:e.inputTokens,outputTokens:e.outputTokens,responseText:e.responseText,streaming:e.streaming}),S=n===null?null:$({status:n.responseStatus,elapsedMs:n.elapsedMs,inputTokens:n.inputTokens,outputTokens:n.outputTokens,responseText:n.responseText,streaming:n.streaming}),M=S===null?[]:se(V,S);return s.jsx(L,{open:t,onOpenChange:J,children:s.jsxs(P,{className:"max-w-4xl max-h-[85vh] overflow-auto",children:[s.jsx(z,{children:s.jsxs(A,{className:"flex items-center gap-2",children:[s.jsx(H,{className:"size-4"}),"Replay Request #",e.id]})}),s.jsxs(f,{defaultValue:"modified",children:[s.jsxs(j,{children:[s.jsx(l,{value:"modified",children:"Modified Request"}),s.jsx(l,{value:"original",children:"Original Response"}),n&&s.jsx(l,{value:"replay",children:"Replay Response"}),n&&s.jsx(l,{value:"compare",children:"Compare"})]}),s.jsxs(o,{value:"modified",className:"space-y-4",children:[g.length>0&&s.jsxs("div",{className:"grid gap-1.5",children:[s.jsx("label",{htmlFor:`replay-model-${String(e.id)}`,className:"text-sm font-medium",children:"Replay target"}),s.jsxs("select",{id:`replay-model-${String(e.id)}`,value:d,onChange:r=>I(r.currentTarget.value),className:"h-8 rounded-md border border-input bg-background px-2 text-sm",children:[d===""&&s.jsx("option",{value:"",children:"Select model"}),d!==""&&!g.some(r=>r.model===d)&&s.jsx("option",{value:d,children:d}),g.map(r=>s.jsxs("option",{value:r.model,children:[r.providerName," / ",r.model]},r.key))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Request Body (JSON)"}),s.jsx(G,{children:s.jsxs(K,{children:[s.jsx(Q,{asChild:!0,children:s.jsx("textarea",{className:"w-full h-64 p-3 font-mono text-xs bg-muted rounded-md border border-input resize-none focus:outline-none focus:ring-2 focus:ring-ring",value:x,onChange:r=>N(r.target.value),spellCheck:!1})}),s.jsx(U,{children:"Edit the request body before re-sending to the provider"})]})})]}),y!==null&&y!==""&&s.jsx("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:y}),s.jsx("div",{className:"flex justify-end",children:s.jsx(W,{onClick:()=>{F()},disabled:w,children:w?"Replaying...":"Replay"})}),n!==null&&s.jsx(q,{comparisons:M.slice(0,4)}),n&&n.success&&s.jsxs(f,{defaultValue:"parsed",children:[s.jsxs(j,{children:[s.jsx(l,{value:"parsed",children:"Response"}),s.jsx(l,{value:"raw",children:"Raw Response"})]}),s.jsx(o,{value:"parsed",children:s.jsx(k,{responseText:n.responseText??null,responseStatus:n.responseStatus??null,streaming:n.streaming??!1,inputTokens:n.inputTokens??null,outputTokens:n.outputTokens??null,apiFormat:e.apiFormat})}),s.jsx(o,{value:"raw",children:s.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap bg-muted p-3 rounded-md max-h-96 overflow-auto",children:n.responseText??"No response"})})]})]}),s.jsx(o,{value:"original",children:e.responseText!==null?s.jsxs(f,{defaultValue:"parsed",children:[s.jsxs(j,{children:[s.jsx(l,{value:"parsed",children:"Response"}),s.jsx(l,{value:"raw",children:"Raw Response"})]}),s.jsx(o,{value:"parsed",children:s.jsx(k,{responseText:e.responseText,responseStatus:e.responseStatus,streaming:e.streaming,inputTokens:e.inputTokens,outputTokens:e.outputTokens,cacheCreationInputTokens:e.cacheCreationInputTokens,cacheReadInputTokens:e.cacheReadInputTokens,apiFormat:e.apiFormat})}),s.jsx(o,{value:"raw",children:s.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap bg-muted p-3 rounded-md max-h-96 overflow-auto",children:e.responseText})})]}):s.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No original response"})}),n&&n.success&&s.jsx(o,{value:"replay",children:(n.responseText??null)!==null?s.jsxs(f,{defaultValue:"parsed",children:[s.jsxs(j,{children:[s.jsx(l,{value:"parsed",children:"Response"}),s.jsx(l,{value:"raw",children:"Raw Response"})]}),s.jsx(o,{value:"parsed",children:s.jsx(k,{responseText:n.responseText??null,responseStatus:n.responseStatus??null,streaming:n.streaming??!1,inputTokens:n.inputTokens??null,outputTokens:n.outputTokens??null,apiFormat:e.apiFormat})}),s.jsx(o,{value:"raw",children:s.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap bg-muted p-3 rounded-md max-h-96 overflow-auto",children:n.responseText??""})})]}):s.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No replay response"})}),n&&s.jsxs(o,{value:"compare",className:"space-y-3",children:[s.jsx(q,{comparisons:M}),n.success?null:s.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:n.error??"Replay failed"})]})]})]})})}export{ie as ReplayDialog};
@@ -0,0 +1 @@
1
+ import{r as f,j as e}from"./main-CKnTJ4-O.js";import{c as A,f as h,s as D,b as y,t as R,v as L,w as T}from"./ProxyViewerContainer-Cxpdziwd.js";const F=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],U=A("info",F),B={system:"System",user:"User",assistant:"Assistant",tool:"Tool Results",tools:"Tool Definitions"},_={system:"bg-sky-500/70",user:"bg-emerald-500/70",assistant:"bg-violet-500/70",tool:"bg-sky-400/55",tools:"bg-slate-500/70"},V={system:"focus-visible:ring-sky-300",user:"focus-visible:ring-emerald-300",assistant:"focus-visible:ring-violet-300",tool:"focus-visible:ring-sky-300",tools:"focus-visible:ring-slate-300"},C=12,$=1,I=80,O=24;function q(o){return o.length<=O?o:`${o.slice(0,O-3)}...`}function G(o){const r=o.replace(/\s+/g," ").trim();return r.length<=I?r:`${r.slice(0,I)}...`}function E(o){return o>=10?`${o.toFixed(0)}%`:o>=1?`${o.toFixed(1)}%`:o>0?"<1%":"0%"}const W=f.memo(function({segments:r,totalTokens:i,showLabels:x=!0,onActivate:m}){const c=f.useMemo(()=>i>0?i:r.reduce((s,t)=>s+t.size,0),[r,i]),n=r.slice(0,C),l=r.slice(C),u=l.reduce((s,t)=>s+t.size,0),d=l.length,p=C,M=p+d-1,b=d>0,g=m!==void 0,S=f.useMemo(()=>n.reduce((s,t)=>s+t.size,0),[n]),w=f.useMemo(()=>`Request context: ~${h(c)} tokens across ${r.length} segment${r.length===1?"":"s"}`,[r.length,c]);return r.length===0||c<=0?e.jsx("div",{role:"img","aria-label":w,className:"h-6"}):e.jsx(D,{delayDuration:150,children:e.jsxs("div",{role:"img","aria-label":w,className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"relative flex h-6 w-full overflow-hidden rounded border border-border/40 bg-muted/30","data-testid":"anatomy-segment-bar",children:[n.map((s,t)=>{const a=c>0?s.size/c*100:0,v=Math.max($,a),j=y("h-full border-r border-background/80 last:border-r-0",g?"opacity-90 hover:opacity-100 focus:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-background":"opacity-90",_[s.role],g?V[s.role]:""),N={width:`${v}%`},z=`${s.label}, ${E(a)}, ~${h(s.size)} tokens`;return e.jsxs(R,{children:[e.jsx(L,{asChild:!0,children:g?e.jsx("button",{type:"button",role:"button",tabIndex:0,onClick:()=>m(s),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),m(s))},"data-anatomy-path":s.path,"aria-label":z,className:j,style:N}):e.jsx("span",{"aria-label":z,className:j,style:N})}),e.jsxs(T,{side:"bottom",className:"max-w-sm text-xs p-2 space-y-0.5",children:[e.jsxs("div",{className:"font-semibold",children:[s.label," - ",E(a)," - ~",h(s.size)," ","tokens"]}),e.jsx("div",{className:"text-muted-foreground",children:B[s.role]}),e.jsxs("div",{className:"text-muted-foreground",children:[s.characters.toLocaleString()," chars"]}),s.text.length>0&&e.jsx("div",{className:"text-muted-foreground/90 break-words whitespace-pre-wrap",children:G(s.text)})]})]},`${s.path}-${t}`)}),b&&e.jsxs(R,{children:[e.jsx(L,{asChild:!0,children:e.jsxs("div",{role:"img","aria-label":`${d} additional segments`,className:"flex h-full items-center justify-center bg-muted-foreground/30 px-1.5 text-[10px] font-mono text-background",style:{width:`${Math.max($,u/c*100)}%`},children:["... +",d]})}),e.jsxs(T,{side:"bottom",className:"text-xs",children:[d," more segment",d===1?"":"s"," (indices"," ",p,"-",M,")"]})]})]}),x&&e.jsxs("div",{className:"flex w-full gap-1 text-[10px] text-muted-foreground",children:[n.map((s,t)=>{const a=c>0?s.size/c*100:0,v=Math.max($,a);return e.jsxs("div",{className:"flex flex-col gap-0.5 truncate",style:{width:`${v}%`},title:`${s.label} - ${E(a)} - ~${h(s.size)} tokens`,children:[e.jsx("span",{className:"truncate font-mono text-foreground/80",children:q(s.label)}),e.jsxs("span",{className:"truncate font-mono text-muted-foreground/70",children:[E(a)," - ~",h(s.size)]})]},`label-${s.path}-${t}`)}),b&&e.jsxs("div",{className:"flex flex-col gap-0.5 truncate text-muted-foreground",style:{width:`${Math.max($,u/c*100)}%`},children:[e.jsxs("span",{className:"truncate font-mono text-foreground/60",children:["... +",d]}),e.jsxs("span",{className:"truncate font-mono text-muted-foreground/60",children:["~",h(u)]})]})]}),S<c*.1&&e.jsx("div",{className:"h-0"})]})})}),H=.25,J=5,K=["system","user","assistant","tool","tools"],X={system:"instructions",user:"user turns",assistant:"assistant turns",tool:"tool results",tools:"tool schemas"},Y=[{value:"role",label:"By Role"},{value:"segment",label:"By Segment"}];function P(o){return o>=10?`${o.toFixed(0)}%`:o>=1?`${o.toFixed(1)}%`:o>0?"<1%":"0%"}function Q(o){const r=[];for(const i of K){const x=o.filter(u=>u.role===i);if(x.length===0)continue;const m=x.reduce((u,d)=>u+d.size,0),c=x.reduce((u,d)=>u+d.characters,0),n=B[i],l=`${x.length} segment${x.length===1?"":"s"} grouped as ${X[i]}`;r.push({role:i,label:n,size:m,characters:c,text:l,path:`role:${i}`})}return r}function Z(o){return[...o].sort((r,i)=>i.size-r.size).slice(0,J)}function se({parsed:o,inputTokens:r,onSegmentActivate:i,segments:x}){const[m,c]=f.useState("role"),n=f.useMemo(()=>x??null,[x]),l=f.useMemo(()=>(n??[]).reduce((t,a)=>t+a.size,0),[n]),u=f.useMemo(()=>n===null?[]:Q(n),[n]),d=f.useMemo(()=>n===null?[]:Z(n),[n]),p=f.useMemo(()=>n===null||r===null||l===0?!1:Math.abs(r-l)/Math.max(r,l)>=H,[r,n,l]);if(n===null||n.length===0||o===null&&x===void 0)return null;const M=r!==null&&p?"text-amber-400":"text-muted-foreground",b=m==="role"?u:n,g=l>0?l:b.reduce((t,a)=>t+a.size,0),S=m==="segment"?i:void 0,w=`${String(n.length)} segment${n.length===1?"":"s"}`,s=r===null?"Provider input unknown":`Provider input ${h(r)}`;return e.jsx(D,{delayDuration:150,children:e.jsxs("div",{className:"px-4 py-3 space-y-3","data-testid":"anatomy-root",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-foreground",children:"Request Context"}),e.jsxs("div",{className:y("mt-0.5 text-xs font-mono tabular-nums",M),children:["Estimated ~",h(l)," tokens | ",s," | ",w]})]}),e.jsx("div",{className:"inline-flex shrink-0 rounded border border-border bg-muted/20 p-0.5",role:"group","aria-label":"Context breakdown mode",children:Y.map(t=>e.jsx("button",{type:"button","aria-pressed":m===t.value,onClick:()=>c(t.value),className:y("h-6 rounded-sm px-2 text-[11px] font-medium transition-colors",m===t.value?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:t.label},t.value))})]}),p&&e.jsxs("div",{className:"inline-flex items-center gap-1.5 text-xs text-amber-400",children:[e.jsxs(R,{children:[e.jsx(L,{asChild:!0,children:e.jsx("button",{type:"button",className:"inline-flex items-center hover:text-amber-300","aria-label":"Token estimate differs from provider input",children:e.jsx(U,{className:"size-3.5"})})}),e.jsx(T,{className:"max-w-xs text-xs",children:"The bar uses a local token estimate. Provider input tokens remain the source of truth for billing and context-window usage."})]}),"Estimate differs from provider-reported input."]}),e.jsx(W,{segments:b,totalTokens:g,showLabels:m==="segment",onActivate:S}),e.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5 text-[11px] text-muted-foreground",children:u.map(t=>{const a=l>0?t.size/l*100:0;return e.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",className:y("size-2.5 rounded-[2px]",_[t.role])}),e.jsx("span",{children:t.label}),e.jsx("span",{className:"font-mono text-muted-foreground/70",children:P(a)})]},t.role)})}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-xs font-medium text-foreground",children:"Top Contributors"}),e.jsx("div",{className:"grid gap-1",children:d.map((t,a)=>{const v=l>0?t.size/l*100:0,j=i,N=e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-5 shrink-0 text-right font-mono text-muted-foreground/70",children:String(a+1)}),e.jsx("span",{"aria-hidden":"true",className:y("size-2.5 shrink-0 rounded-[2px]",_[t.role])}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:t.label}),e.jsxs("span",{className:"shrink-0 font-mono text-muted-foreground",children:[P(v)," | ~",h(t.size)]})]});return j!==void 0?e.jsx("button",{type:"button",onClick:()=>j(t),className:"flex h-7 items-center gap-2 rounded px-1.5 text-xs text-muted-foreground hover:bg-muted/40 hover:text-foreground",title:"Jump to this request block",children:N},`${t.path}-${a}`):e.jsx("div",{className:"flex h-7 items-center gap-2 rounded px-1.5 text-xs text-muted-foreground",children:N},`${t.path}-${a}`)})})]})]})})}export{se as RequestAnatomy};
@@ -0,0 +1 @@
1
+ import{r as l,j as t}from"./main-CKnTJ4-O.js";import{c as He,F as Ve,G as _,H as We,I as C,J as D,K as P,L as ue,N as me,O as Me,Q as R,S as Be,b as X,U as Fe,B as E,V as U,h as Y,W as he,Y as xe,Z as ee,f as w,g as Xe,_ as Ue,$ as Ye}from"./ProxyViewerContainer-Cxpdziwd.js";import{M as $e,a as fe}from"./json-viewer-CRL_gWEZ.js";const Ge=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],pe=He("circle-stop",Ge);var $="Collapsible",[Ke]=me($),[Je,te]=Ke($),ge=l.forwardRef((e,n)=>{const{__scopeCollapsible:r,open:o,defaultOpen:s,disabled:a,onOpenChange:i,...c}=e,[d,u]=Ve({prop:o,defaultProp:s??!1,onChange:i,caller:$});return t.jsx(Je,{scope:r,disabled:a,contentId:We(),open:d,onOpenToggle:l.useCallback(()=>u(m=>!m),[u]),children:t.jsx(_.div,{"data-state":re(d),"data-disabled":a?"":void 0,...c,ref:n})})});ge.displayName=$;var ve="CollapsibleTrigger",be=l.forwardRef((e,n)=>{const{__scopeCollapsible:r,...o}=e,s=te(ve,r);return t.jsx(_.button,{type:"button","aria-controls":s.contentId,"aria-expanded":s.open||!1,"data-state":re(s.open),"data-disabled":s.disabled?"":void 0,disabled:s.disabled,...o,ref:n,onClick:C(e.onClick,s.onOpenToggle)})});be.displayName=ve;var ne="CollapsibleContent",Se=l.forwardRef((e,n)=>{const{forceMount:r,...o}=e,s=te(ne,e.__scopeCollapsible);return t.jsx(D,{present:r||s.open,children:({present:a})=>t.jsx(qe,{...o,ref:n,present:a})})});Se.displayName=ne;var qe=l.forwardRef((e,n)=>{const{__scopeCollapsible:r,present:o,children:s,...a}=e,i=te(ne,r),[c,d]=l.useState(o),u=l.useRef(null),m=P(n,u),x=l.useRef(0),h=x.current,f=l.useRef(0),v=f.current,y=i.open||c,A=l.useRef(y),b=l.useRef(void 0);return l.useEffect(()=>{const g=requestAnimationFrame(()=>A.current=!1);return()=>cancelAnimationFrame(g)},[]),ue(()=>{const g=u.current;if(g){b.current=b.current||{transitionDuration:g.style.transitionDuration,animationName:g.style.animationName},g.style.transitionDuration="0s",g.style.animationName="none";const T=g.getBoundingClientRect();x.current=T.height,f.current=T.width,A.current||(g.style.transitionDuration=b.current.transitionDuration,g.style.animationName=b.current.animationName),d(o)}},[i.open,o]),t.jsx(_.div,{"data-state":re(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!y,...a,ref:m,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":v?`${v}px`:void 0,...e.style},children:y&&s})});function re(e){return e?"open":"closed"}var Ze=ge;function Qe(e,n){return l.useReducer((r,o)=>n[r][o]??r,e)}var oe="ScrollArea",[je]=me(oe),[et,S]=je(oe),we=l.forwardRef((e,n)=>{const{__scopeScrollArea:r,type:o="hover",dir:s,scrollHideDelay:a=600,...i}=e,[c,d]=l.useState(null),[u,m]=l.useState(null),[x,h]=l.useState(null),[f,v]=l.useState(null),[y,A]=l.useState(null),[b,g]=l.useState(0),[T,I]=l.useState(0),[H,O]=l.useState(!1),[V,W]=l.useState(!1),p=P(n,k=>d(k)),j=Me(s);return t.jsx(et,{scope:r,type:o,dir:j,scrollHideDelay:a,scrollArea:c,viewport:u,onViewportChange:m,content:x,onContentChange:h,scrollbarX:f,onScrollbarXChange:v,scrollbarXEnabled:H,onScrollbarXEnabledChange:O,scrollbarY:y,onScrollbarYChange:A,scrollbarYEnabled:V,onScrollbarYEnabledChange:W,onCornerWidthChange:g,onCornerHeightChange:I,children:t.jsx(_.div,{dir:j,...i,ref:p,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":T+"px",...e.style}})})});we.displayName=oe;var Ne="ScrollAreaViewport",ye=l.forwardRef((e,n)=>{const{__scopeScrollArea:r,children:o,nonce:s,...a}=e,i=S(Ne,r),c=l.useRef(null),d=P(n,c,i.onViewportChange);return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),t.jsx(_.div,{"data-radix-scroll-area-viewport":"",...a,ref:d,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:t.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})});ye.displayName=Ne;var N="ScrollAreaScrollbar",_e=l.forwardRef((e,n)=>{const{forceMount:r,...o}=e,s=S(N,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:i}=s,c=e.orientation==="horizontal";return l.useEffect(()=>(c?a(!0):i(!0),()=>{c?a(!1):i(!1)}),[c,a,i]),s.type==="hover"?t.jsx(tt,{...o,ref:n,forceMount:r}):s.type==="scroll"?t.jsx(nt,{...o,ref:n,forceMount:r}):s.type==="auto"?t.jsx(Ce,{...o,ref:n,forceMount:r}):s.type==="always"?t.jsx(se,{...o,ref:n}):null});_e.displayName=N;var tt=l.forwardRef((e,n)=>{const{forceMount:r,...o}=e,s=S(N,e.__scopeScrollArea),[a,i]=l.useState(!1);return l.useEffect(()=>{const c=s.scrollArea;let d=0;if(c){const u=()=>{window.clearTimeout(d),i(!0)},m=()=>{d=window.setTimeout(()=>i(!1),s.scrollHideDelay)};return c.addEventListener("pointerenter",u),c.addEventListener("pointerleave",m),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",u),c.removeEventListener("pointerleave",m)}}},[s.scrollArea,s.scrollHideDelay]),t.jsx(D,{present:r||a,children:t.jsx(Ce,{"data-state":a?"visible":"hidden",...o,ref:n})})}),nt=l.forwardRef((e,n)=>{const{forceMount:r,...o}=e,s=S(N,e.__scopeScrollArea),a=e.orientation==="horizontal",i=K(()=>d("SCROLL_END"),100),[c,d]=Qe("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return l.useEffect(()=>{if(c==="idle"){const u=window.setTimeout(()=>d("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(u)}},[c,s.scrollHideDelay,d]),l.useEffect(()=>{const u=s.viewport,m=a?"scrollLeft":"scrollTop";if(u){let x=u[m];const h=()=>{const f=u[m];x!==f&&(d("SCROLL"),i()),x=f};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[s.viewport,a,d,i]),t.jsx(D,{present:r||c!=="hidden",children:t.jsx(se,{"data-state":c==="hidden"?"hidden":"visible",...o,ref:n,onPointerEnter:C(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:C(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),Ce=l.forwardRef((e,n)=>{const r=S(N,e.__scopeScrollArea),{forceMount:o,...s}=e,[a,i]=l.useState(!1),c=e.orientation==="horizontal",d=K(()=>{if(r.viewport){const u=r.viewport.offsetWidth<r.viewport.scrollWidth,m=r.viewport.offsetHeight<r.viewport.scrollHeight;i(c?u:m)}},10);return L(r.viewport,d),L(r.content,d),t.jsx(D,{present:o||a,children:t.jsx(se,{"data-state":a?"visible":"hidden",...s,ref:n})})}),se=l.forwardRef((e,n)=>{const{orientation:r="vertical",...o}=e,s=S(N,e.__scopeScrollArea),a=l.useRef(null),i=l.useRef(0),[c,d]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=Te(c.viewport,c.content),m={...o,sizes:c,onSizesChange:d,hasThumb:u>0&&u<1,onThumbChange:h=>a.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function x(h,f){return it(h,i.current,c,f)}return r==="horizontal"?t.jsx(rt,{...m,ref:n,onThumbPositionChange:()=>{if(s.viewport&&a.current){const h=s.viewport.scrollLeft,f=ie(h,c,s.dir);a.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:h=>{s.viewport&&(s.viewport.scrollLeft=h)},onDragScroll:h=>{s.viewport&&(s.viewport.scrollLeft=x(h,s.dir))}}):r==="vertical"?t.jsx(ot,{...m,ref:n,onThumbPositionChange:()=>{if(s.viewport&&a.current){const h=s.viewport.scrollTop,f=ie(h,c);a.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:h=>{s.viewport&&(s.viewport.scrollTop=h)},onDragScroll:h=>{s.viewport&&(s.viewport.scrollTop=x(h))}}):null}),rt=l.forwardRef((e,n)=>{const{sizes:r,onSizesChange:o,...s}=e,a=S(N,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),u=P(n,d,a.onScrollbarXChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),t.jsx(Ee,{"data-orientation":"horizontal",...s,ref:u,sizes:r,style:{bottom:0,left:a.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:a.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":G(r)+"px",...e.style},onThumbPointerDown:m=>e.onThumbPointerDown(m.x),onDragScroll:m=>e.onDragScroll(m.x),onWheelScroll:(m,x)=>{if(a.viewport){const h=a.viewport.scrollLeft+m.deltaX;e.onWheelScroll(h),Le(h,x)&&m.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&o({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:B(i.paddingLeft),paddingEnd:B(i.paddingRight)}})}})}),ot=l.forwardRef((e,n)=>{const{sizes:r,onSizesChange:o,...s}=e,a=S(N,e.__scopeScrollArea),[i,c]=l.useState(),d=l.useRef(null),u=P(n,d,a.onScrollbarYChange);return l.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),t.jsx(Ee,{"data-orientation":"vertical",...s,ref:u,sizes:r,style:{top:0,right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":G(r)+"px",...e.style},onThumbPointerDown:m=>e.onThumbPointerDown(m.y),onDragScroll:m=>e.onDragScroll(m.y),onWheelScroll:(m,x)=>{if(a.viewport){const h=a.viewport.scrollTop+m.deltaY;e.onWheelScroll(h),Le(h,x)&&m.preventDefault()}},onResize:()=>{d.current&&a.viewport&&i&&o({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:B(i.paddingTop),paddingEnd:B(i.paddingBottom)}})}})}),[st,Re]=je(N),Ee=l.forwardRef((e,n)=>{const{__scopeScrollArea:r,sizes:o,hasThumb:s,onThumbChange:a,onThumbPointerUp:i,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:u,onWheelScroll:m,onResize:x,...h}=e,f=S(N,r),[v,y]=l.useState(null),A=P(n,p=>y(p)),b=l.useRef(null),g=l.useRef(""),T=f.viewport,I=o.content-o.viewport,H=R(m),O=R(d),V=K(x,10);function W(p){if(b.current){const j=p.clientX-b.current.left,k=p.clientY-b.current.top;u({x:j,y:k})}}return l.useEffect(()=>{const p=j=>{const k=j.target;v?.contains(k)&&H(j,I)};return document.addEventListener("wheel",p,{passive:!1}),()=>document.removeEventListener("wheel",p,{passive:!1})},[T,v,I,H]),l.useEffect(O,[o,O]),L(v,V),L(f.content,V),t.jsx(st,{scope:r,scrollbar:v,hasThumb:s,onThumbChange:R(a),onThumbPointerUp:R(i),onThumbPositionChange:O,onThumbPointerDown:R(c),children:t.jsx(_.div,{...h,ref:A,style:{position:"absolute",...h.style},onPointerDown:C(e.onPointerDown,p=>{p.button===0&&(p.target.setPointerCapture(p.pointerId),b.current=v.getBoundingClientRect(),g.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",f.viewport&&(f.viewport.style.scrollBehavior="auto"),W(p))}),onPointerMove:C(e.onPointerMove,W),onPointerUp:C(e.onPointerUp,p=>{const j=p.target;j.hasPointerCapture(p.pointerId)&&j.releasePointerCapture(p.pointerId),document.body.style.webkitUserSelect=g.current,f.viewport&&(f.viewport.style.scrollBehavior=""),b.current=null})})})}),M="ScrollAreaThumb",Pe=l.forwardRef((e,n)=>{const{forceMount:r,...o}=e,s=Re(M,e.__scopeScrollArea);return t.jsx(D,{present:r||s.hasThumb,children:t.jsx(lt,{ref:n,...o})})}),lt=l.forwardRef((e,n)=>{const{__scopeScrollArea:r,style:o,...s}=e,a=S(M,r),i=Re(M,r),{onThumbPositionChange:c}=i,d=P(n,x=>i.onThumbChange(x)),u=l.useRef(void 0),m=K(()=>{u.current&&(u.current(),u.current=void 0)},100);return l.useEffect(()=>{const x=a.viewport;if(x){const h=()=>{if(m(),!u.current){const f=ct(x,c);u.current=f,c()}};return c(),x.addEventListener("scroll",h),()=>x.removeEventListener("scroll",h)}},[a.viewport,m,c]),t.jsx(_.div,{"data-state":i.hasThumb?"visible":"hidden",...s,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:C(e.onPointerDownCapture,x=>{const f=x.target.getBoundingClientRect(),v=x.clientX-f.left,y=x.clientY-f.top;i.onThumbPointerDown({x:v,y})}),onPointerUp:C(e.onPointerUp,i.onThumbPointerUp)})});Pe.displayName=M;var le="ScrollAreaCorner",Ae=l.forwardRef((e,n)=>{const r=S(le,e.__scopeScrollArea),o=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&o?t.jsx(at,{...e,ref:n}):null});Ae.displayName=le;var at=l.forwardRef((e,n)=>{const{__scopeScrollArea:r,...o}=e,s=S(le,r),[a,i]=l.useState(0),[c,d]=l.useState(0),u=!!(a&&c);return L(s.scrollbarX,()=>{const m=s.scrollbarX?.offsetHeight||0;s.onCornerHeightChange(m),d(m)}),L(s.scrollbarY,()=>{const m=s.scrollbarY?.offsetWidth||0;s.onCornerWidthChange(m),i(m)}),u?t.jsx(_.div,{...o,ref:n,style:{width:a,height:c,position:"absolute",right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function B(e){return e?parseInt(e,10):0}function Te(e,n){const r=e/n;return isNaN(r)?0:r}function G(e){const n=Te(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-r)*n;return Math.max(o,18)}function it(e,n,r,o="ltr"){const s=G(r),a=s/2,i=n||a,c=s-i,d=r.scrollbar.paddingStart+i,u=r.scrollbar.size-r.scrollbar.paddingEnd-c,m=r.content-r.viewport,x=o==="ltr"?[0,m]:[m*-1,0];return ke([d,u],x)(e)}function ie(e,n,r="ltr"){const o=G(n),s=n.scrollbar.paddingStart+n.scrollbar.paddingEnd,a=n.scrollbar.size-s,i=n.content-n.viewport,c=a-o,d=r==="ltr"?[0,i]:[i*-1,0],u=Be(e,d);return ke([0,i],[0,c])(u)}function ke(e,n){return r=>{if(e[0]===e[1]||n[0]===n[1])return n[0];const o=(n[1]-n[0])/(e[1]-e[0]);return n[0]+o*(r-e[0])}}function Le(e,n){return e>0&&e<n}var ct=(e,n=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},o=0;return(function s(){const a={left:e.scrollLeft,top:e.scrollTop},i=r.left!==a.left,c=r.top!==a.top;(i||c)&&n(),r=a,o=window.requestAnimationFrame(s)})(),()=>window.cancelAnimationFrame(o)};function K(e,n){const r=R(e),o=l.useRef(0);return l.useEffect(()=>()=>window.clearTimeout(o.current),[]),l.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(r,n)},[r,n])}function L(e,n){const r=R(n);ue(()=>{let o=0;if(e){const s=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(r)});return s.observe(e),()=>{window.cancelAnimationFrame(o),s.unobserve(e)}}},[e,r])}var dt=we,ut=ye,mt=Ae,ht="Separator",ce="horizontal",xt=["horizontal","vertical"],Oe=l.forwardRef((e,n)=>{const{decorative:r,orientation:o=ce,...s}=e,a=ft(o)?o:ce,c=r?{role:"none"}:{"aria-orientation":a==="vertical"?a:void 0,role:"separator"};return t.jsx(_.div,{"data-orientation":a,...c,...s,ref:n})});Oe.displayName=ht;function ft(e){return xt.includes(e)}var pt=Oe;const gt="prose prose-sm dark:prose-invert max-w-none text-[13px] leading-[1.65] [&_pre]:bg-muted [&_pre]:text-foreground [&_code]:text-[0.8em] [&_p]:my-1 [&_p]:leading-[1.65] [&_ul]:my-1 [&_ol]:my-1 [&_li]:my-0.5 [&_li]:leading-[1.6]";function J({text:e}){return t.jsx("div",{className:gt,children:t.jsx($e,{children:e})})}function ze({className:e,orientation:n="horizontal",decorative:r=!0,...o}){return t.jsx(pt,{"data-slot":"separator",decorative:r,orientation:n,className:X("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...o})}function q({...e}){return t.jsx(Ze,{"data-slot":"collapsible",...e})}function Z({...e}){return t.jsx(be,{"data-slot":"collapsible-trigger",...e})}function Q({...e}){return t.jsx(Se,{"data-slot":"collapsible-content",...e})}function ae({className:e,children:n,...r}){return t.jsxs(dt,{"data-slot":"scroll-area",className:X("relative",e),...r,children:[t.jsx(ut,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1",children:n}),t.jsx(vt,{}),t.jsx(mt,{})]})}function vt({className:e,orientation:n="vertical",...r}){return t.jsx(_e,{"data-slot":"scroll-area-scrollbar",orientation:n,className:X("flex touch-none p-px transition-colors select-none",n==="vertical"&&"h-full w-2.5 border-l border-l-transparent",n==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent",e),...r,children:t.jsx(Pe,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}const bt=/<think>([\s\S]*?)<\/think>/gi,St=/<think>([\s\S]*?)<\/think>/i;function De(e){const n=St.exec(e);if(!n||n[1]===void 0)return{thinking:null,remainingText:e};const r=n[1].trim(),o=e.replace(bt,"").trim();return{thinking:r,remainingText:o}}function jt(e){return t.jsx(t.Fragment,{})}function wt({text:e}){const[n,r]=l.useState(!1);return t.jsxs(q,{open:n,onOpenChange:r,children:[t.jsxs(Z,{className:"flex items-center gap-1.5 py-0.5 cursor-pointer hover:opacity-80 transition-opacity group",children:[n?t.jsx(U,{className:"size-3 text-muted-foreground"}):t.jsx(Y,{className:"size-3 text-muted-foreground"}),t.jsx("span",{className:"text-muted-foreground text-xs italic select-none opacity-60",children:"[system-reminder]"})]}),t.jsx(Q,{children:t.jsx("div",{className:"pl-4 pt-1",children:t.jsx(J,{text:e})})})]})}const Nt=l.memo(function({text:n}){if(n.includes("<system-reminder>"))return t.jsx(wt,{text:n});const{thinking:r,remainingText:o}=De(n);return t.jsxs("div",{className:"space-y-2",children:[r!==null&&t.jsx(F,{thinking:r}),o.length>0&&t.jsx(J,{text:o}),r===null&&o.length===0&&t.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Empty text block"})]})}),F=l.memo(function({thinking:n}){const[r,o]=l.useState(!1);return t.jsx(q,{open:r,onOpenChange:o,children:t.jsxs("div",{className:"border-l-2 border-purple-500/40 my-1",children:[t.jsxs(Z,{className:"flex items-center gap-1.5 px-3 py-1 w-full text-left cursor-pointer hover:bg-purple-500/5 transition-colors rounded-r-sm group",children:[t.jsx(Fe,{className:"size-3.5 text-purple-400 shrink-0"}),t.jsx("span",{className:"text-xs font-medium text-purple-400",children:"Thinking"}),t.jsxs(E,{variant:"ghost",className:"text-[10px] text-muted-foreground px-1.5 py-0 h-4 font-mono",children:[n.length.toLocaleString()," chars"]}),t.jsx("span",{className:"flex-1"}),r?t.jsx(U,{className:"size-3 text-muted-foreground"}):t.jsx(Y,{className:"size-3 text-muted-foreground"})]}),t.jsx(Q,{children:t.jsx("div",{className:"px-3 pb-2",children:t.jsx(ae,{className:"max-h-[60vh]",children:t.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap font-mono leading-relaxed",children:n})})})})]})})}),yt=l.memo(function({name:n,input:r}){const[o,s]=l.useState(!1);return t.jsx(q,{open:o,onOpenChange:s,children:t.jsxs("div",{className:"border-l-2 border-sky-400/25 my-1",children:[t.jsxs(Z,{className:"flex items-center gap-1.5 px-3 py-1 w-full text-left cursor-pointer hover:bg-sky-400/[0.04] transition-colors rounded-r-sm group",children:[t.jsx(he,{className:"size-3.5 text-sky-400/70 shrink-0"}),t.jsx(E,{variant:"outline",className:"text-[10px] font-mono px-1.5 py-0 h-4",children:n}),t.jsx("span",{className:"flex-1"}),o?t.jsx(U,{className:"size-3 text-muted-foreground"}):t.jsx(Y,{className:"size-3 text-muted-foreground"})]}),t.jsx(Q,{children:t.jsx("div",{className:"px-3 pb-2",children:t.jsx(ae,{className:"max-h-[60vh]",children:t.jsx(fe,{data:xe(r),defaultExpandDepth:0})})})})]})})}),_t=l.memo(function({block:n}){switch(n.type){case"text":return t.jsx(Nt,{text:n.text});case"thinking":case"think":return t.jsx(F,{thinking:n.thinking});case"tool_use":return t.jsx(yt,{name:n.name,input:n.input});default:return jt()}}),Ct=l.memo(function({response:n}){return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx(E,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-5 font-mono",children:n.model}),n.stop_reason!==null&&t.jsxs(E,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-5 font-mono flex items-center gap-1",children:[t.jsx(pe,{className:"size-2.5"}),n.stop_reason]}),t.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs",children:[t.jsx(ee,{className:"size-3"}),t.jsxs("span",{className:"font-mono tabular-nums",children:[w(n.usage.input_tokens??0)," in /"," ",w(n.usage.output_tokens??0)," out"]}),n.usage.cache_creation_input_tokens!==void 0&&n.usage.cache_creation_input_tokens!==null&&n.usage.cache_creation_input_tokens>0&&t.jsxs("span",{className:"font-mono tabular-nums text-emerald-400",children:["KV Cache +",w(n.usage.cache_creation_input_tokens)]}),n.usage.cache_read_input_tokens!==void 0&&n.usage.cache_read_input_tokens!==null&&n.usage.cache_read_input_tokens>0&&t.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",w(n.usage.cache_read_input_tokens)]})]})]}),t.jsx(ze,{className:"opacity-50"}),t.jsxs("div",{className:"space-y-2",children:[n.content.map((r,o)=>t.jsx(_t,{block:r},o)),n.content.length===0&&t.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Empty response content"})]})]})});function Rt(e){if(e===void 0||e==="")return{};try{return JSON.parse(e)}catch{return null}}function Et({call:e}){const[n,r]=l.useState(!1),o=e.function.name??"(unnamed tool)",s=Rt(e.function.arguments);return t.jsx(q,{open:n,onOpenChange:r,children:t.jsxs("div",{className:"border-l-2 border-sky-400/25 my-1",children:[t.jsxs(Z,{className:"flex items-center gap-1.5 px-3 py-1 w-full text-left cursor-pointer hover:bg-sky-400/[0.04] transition-colors rounded-r-sm group",children:[t.jsx(he,{className:"size-3.5 text-sky-400/70 shrink-0"}),t.jsx(E,{variant:"outline",className:"text-[10px] font-mono px-1.5 py-0 h-4",children:o}),e.id!==void 0&&e.id!==""&&t.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/60 truncate",children:e.id}),t.jsx("span",{className:"flex-1"}),n?t.jsx(U,{className:"size-3 text-muted-foreground"}):t.jsx(Y,{className:"size-3 text-muted-foreground"})]}),t.jsx(Q,{children:t.jsx("div",{className:"px-3 pb-2",children:t.jsx(ae,{className:"max-h-[60vh]",children:s===null?t.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap break-words text-rose-300/90",children:e.function.arguments}):t.jsx(fe,{data:xe(s),defaultExpandDepth:0})})})})]})})}const Pt=l.memo(function({response:n}){const r=n.choices[0],o=r?.message,s=o?.tool_calls??[];return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx(E,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-5 font-mono",children:n.model}),r?.finish_reason!==null&&r?.finish_reason!==void 0&&t.jsxs(E,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-5 font-mono flex items-center gap-1",children:[t.jsx(pe,{className:"size-2.5"}),r.finish_reason]}),t.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs",children:[t.jsx(ee,{className:"size-3"}),t.jsxs("span",{className:"font-mono tabular-nums",children:[w(n.usage.prompt_tokens??0)," in /"," ",w(n.usage.completion_tokens??0)," out"]})]})]}),t.jsx(ze,{className:"opacity-50"}),t.jsxs("div",{className:"space-y-2",children:[o?.reasoning_content!==null&&o?.reasoning_content!==void 0&&o.reasoning_content.length>0&&t.jsx(F,{thinking:o.reasoning_content}),o?.content!==null&&o?.content!==void 0&&o.content.length>0&&(()=>{const a=o.reasoning_content!==null&&o.reasoning_content!==void 0&&o.reasoning_content.length>0,{thinking:i,remainingText:c}=De(o.content);return t.jsxs("div",{className:"space-y-2",children:[i!==null&&!a&&t.jsx(F,{thinking:i}),c.length>0&&t.jsx(J,{text:c})]})})(),s.map((a,i)=>t.jsx(Et,{call:a},a.id??`tc-${i}`)),o?.function_call!==null&&o?.function_call!==void 0&&t.jsxs("div",{className:"border border-sky-400/20 rounded-md p-3 bg-muted/20",children:[t.jsx("div",{className:"text-xs text-sky-400/80 font-mono mb-1",children:"function_call"}),t.jsxs("div",{className:"font-mono text-xs",children:[t.jsx("span",{className:"text-foreground/80",children:o.function_call.name}),t.jsxs("span",{className:"text-muted-foreground",children:["(",o.function_call.arguments,")"]})]})]}),(o?.content===null||o?.content===void 0||o.content.length===0)&&(o?.reasoning_content===null||o?.reasoning_content===void 0||o.reasoning_content.length===0)&&(o?.function_call===null||o?.function_call===void 0)&&s.length===0&&t.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Empty response content"})]})]})});function Ie(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function At(e){return Ie(e)&&e.object==="chat.completion"}function Tt(e){return Ie(e)&&e.type==="message"&&Array.isArray(e.content)}function kt(e,n){return e==="openai"&&At(n)?t.jsx(Pt,{response:n}):e==="anthropic"&&Tt(n)?t.jsx(Ct,{response:n}):null}function Lt(e){switch(e){case"success":return"text-emerald-400";case"client_error":return"text-amber-400";case"server_error":return"text-red-400";case"pending":return"text-muted-foreground"}}function z({status:e}){const n=Ye(e),r=Lt(n);return e===null?t.jsx("span",{className:"text-xs text-muted-foreground italic",children:"pending"}):t.jsxs("span",{className:X("flex items-center gap-1 text-xs font-mono font-semibold",r),children:[n==="server_error"&&t.jsx(Ue,{className:"size-3"}),e]})}function de({text:e}){return t.jsx("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-3",children:t.jsx("pre",{className:"text-xs text-red-300 whitespace-pre-wrap font-mono leading-relaxed overflow-auto max-h-[60vh]",children:e})})}function Ot({text:e}){return t.jsx(J,{text:e})}const Vt=l.memo(function({responseText:n,responseStatus:r,streaming:o,inputTokens:s,outputTokens:a,cacheCreationInputTokens:i,cacheReadInputTokens:c,apiFormat:d,error:u}){const m=d??"unknown",x=l.useMemo(()=>Xe(m).analyzeResponse(n).parsed,[m,n]);return n===null&&u===void 0?t.jsxs("div",{className:"flex items-center gap-2 py-3",children:[t.jsx(z,{status:r}),t.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No response"})]}):r!==null&&r>=400?t.jsxs("div",{className:"space-y-2",children:[t.jsx(z,{status:r}),t.jsx(de,{text:n??""}),u!=null&&t.jsxs("div",{className:"rounded border border-destructive/50 bg-destructive/10 p-3 text-xs",children:[t.jsx("div",{className:"font-semibold text-destructive mb-1",children:"SSE Error"}),t.jsx("div",{className:"text-muted-foreground font-mono",children:u})]})]}):u!=null?t.jsxs("div",{className:"space-y-2",children:[t.jsx(z,{status:r}),t.jsxs("div",{className:"rounded border border-destructive/50 bg-destructive/10 p-3 text-xs",children:[t.jsx("div",{className:"font-semibold text-destructive mb-1",children:"SSE Error"}),t.jsx("div",{className:"text-muted-foreground font-mono",children:u})]}),n!==null&&t.jsx("div",{className:"mt-2",children:t.jsx(de,{text:n})})]}):x!==null?t.jsxs("div",{className:"space-y-2",children:[t.jsx(z,{status:r}),kt(m,x)]}):t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(z,{status:r}),o&&(s!==null||a!==null)&&t.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs",children:[t.jsx(ee,{className:"size-3"}),t.jsxs("span",{className:"font-mono tabular-nums",children:[s!==null?w(s):"—"," in /"," ",a!==null?w(a):"—"," out"]}),i!=null&&i>0&&t.jsxs("span",{className:"font-mono tabular-nums text-emerald-400",children:["KV Cache +",w(i)]}),c!=null&&c>0&&t.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",w(c)]})]})]}),t.jsx(Ot,{text:n??""})]})});export{Vt as ResponseView};
@@ -0,0 +1 @@
1
+ import{r as a,j as e}from"./main-CKnTJ4-O.js";import{s as j,t as v,v as b,V as l,h as u,B as N,w as k,a0 as S}from"./ProxyViewerContainer-Cxpdziwd.js";import{a as y}from"./json-viewer-CRL_gWEZ.js";const T=a.memo(function({logId:d,truncated:x}){const[o,m]=a.useState(!1),[r,i]=a.useState({status:"idle"}),[h,p]=a.useState(new Set);a.useEffect(()=>{if(!o||r.status!=="idle")return;let s=!1;return i({status:"loading"}),fetch(`/api/logs/${d}/chunks`).then(t=>t.ok?t.json():Promise.reject(new Error("Chunks not found"))).then(t=>{s||i({status:"success",chunks:t.chunks})}).catch(()=>{s||i({status:"error",message:"Chunk data unavailable"})}),()=>{s=!0}},[o,d]);const c=a.useMemo(()=>{if(r.status!=="success")return[];const s=new Map;for(const t of r.chunks){const n=s.get(t.index);n?n.push(t):s.set(t.index,[t])}return Array.from(s.entries()).map(([t,n])=>({index:t,chunks:n})).sort((t,n)=>t.index-n.index)},[r]),f=s=>{p(t=>{const n=new Set(t);return n.has(s)?n.delete(s):n.add(s),n})};function g(){return r.status==="idle"||r.status==="loading"?e.jsxs("div",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",children:[e.jsx(S,{className:"size-3 animate-spin"}),e.jsx("span",{children:"Loading chunks..."})]}):r.status==="error"?e.jsx("div",{className:"py-2 text-xs text-muted-foreground italic",children:r.message}):e.jsxs("div",{className:"p-2 space-y-1",children:[e.jsxs("div",{className:"text-[10px] text-muted-foreground font-mono mb-2",children:[c.length," index group",c.length!==1?"s":""," available"]}),c.map(s=>{const t=h.has(s.index);return e.jsxs("div",{className:"rounded border border-border bg-background",children:[e.jsxs("button",{type:"button",className:"flex items-center gap-2 w-full px-2 py-1.5 text-left hover:bg-muted/50 transition-colors cursor-pointer",onClick:()=>f(s.index),children:[t?e.jsx(l,{className:"size-3 text-muted-foreground"}):e.jsx(u,{className:"size-3 text-muted-foreground"}),e.jsxs("span",{className:"text-[10px] text-muted-foreground font-mono",children:["[",s.index,"] ",s.chunks[0]?.type??""]}),e.jsxs("span",{className:"text-[10px] text-muted-foreground font-mono",children:[s.chunks.length," chunk",s.chunks.length!==1?"s":""]})]}),t&&e.jsx("div",{className:"px-2 pb-2 space-y-1",children:s.chunks.map(n=>e.jsxs("div",{className:"rounded border border-border bg-muted/20 p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsxs("span",{className:"text-[10px] text-muted-foreground font-mono",children:["+",n.timestamp,"ms"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground font-mono",children:n.type})]}),e.jsx(y,{data:n,defaultExpandDepth:0,showCopy:!0})]},n.index))})]},s.index)})]})}return e.jsxs("div",{className:"space-y-1",children:[e.jsx(j,{children:e.jsxs(v,{children:[e.jsx(b,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer",onClick:()=>m(s=>!s),children:[o?e.jsx(l,{className:"size-3"}):e.jsx(u,{className:"size-3"}),e.jsx("span",{children:"Raw SSE Events"}),e.jsxs(N,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono ml-1",children:[d,x===!0?"+":""]})]})}),e.jsx(k,{children:"Server-Sent Events streaming chunks from the provider"})]})}),o===!0?e.jsx("div",{className:"rounded-md border border-border bg-muted/20 overflow-auto max-h-64",children:g()}):null]})});export{T as StreamingChunkSequence};
@@ -0,0 +1 @@
1
+ import{R as s,j as e}from"./main-CKnTJ4-O.js";import{P as i}from"./ProxyViewerContainer-Cxpdziwd.js";function t(){const{sessionId:o}=s.useParams();return e.jsx(i,{initialSessionId:o},o)}export{t as component};
@@ -0,0 +1 @@
1
+ import{P as o}from"./ProxyViewerContainer-Cxpdziwd.js";import"./main-CKnTJ4-O.js";const r=o;export{r as component};