@tonyclaw/agent-inspector 3.0.29 → 3.0.31

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 (156) hide show
  1. package/.output/cli.js +791 -191
  2. package/.output/nitro.json +1 -1
  3. package/.output/public/assets/CompareDrawer-DB2KggLE.js +1 -0
  4. package/.output/public/assets/InspectorPet-CfwDw6kD.js +4108 -0
  5. package/.output/public/assets/ProxyViewerContainer-PcrO96_F.js +126 -0
  6. package/.output/public/assets/{ReplayDialog-CctnITbt.js → ReplayDialog-3Pl7EKjp.js} +1 -1
  7. package/.output/public/assets/{RequestAnatomy-BrN0RBbL.js → RequestAnatomy-BcPjcHLX.js} +1 -1
  8. package/.output/public/assets/ResponseView-DOx51wV3.js +2 -0
  9. package/.output/public/assets/StreamingChunkSequence-LkYJWM1A.js +1 -0
  10. package/.output/public/assets/_sessionId-BSg32vC6.js +1 -0
  11. package/.output/public/assets/{_sessionId-DKM91udC.js → _sessionId-C0CA68QV.js} +1 -1
  12. package/.output/public/assets/{index-Bq-nqolG.js → index-BpBUqdAB.js} +1 -1
  13. package/.output/public/assets/index-D93dCgAQ.js +1 -0
  14. package/.output/public/assets/{index-DPiESBo2.js → index-FV5sxqx3.js} +6 -6
  15. package/.output/public/assets/index-VUsF4nhf.js +76 -0
  16. package/.output/public/assets/index-hyQHZeQI.css +1 -0
  17. package/.output/public/assets/{json-viewer-CfaDJwx8.js → json-viewer-WctIbAh_.js} +1 -1
  18. package/.output/public/assets/jszip.min-DnSIoTix.js +2 -0
  19. package/.output/public/assets/qwen-mMn3f5ul.webp +0 -0
  20. package/.output/server/_libs/jszip.mjs +35 -9
  21. package/.output/server/_libs/lucide-react.mjs +80 -80
  22. package/.output/server/_libs/radix-ui__react-dialog.mjs +3 -3
  23. package/.output/server/_libs/tanstack__react-router.mjs +1 -1
  24. package/.output/server/{_sessionId-CwGXPD4C.mjs → _sessionId-BHBK3VbF.mjs} +15 -15
  25. package/.output/server/_sessionId-CyuJ6Kfl.mjs +81 -0
  26. package/.output/server/_ssr/{CompareDrawer-R_P1-VNr.mjs → CompareDrawer-27amlv_a.mjs} +138 -103
  27. package/.output/server/_ssr/InspectorPet-CQnGXfLs.mjs +925 -0
  28. package/.output/server/_ssr/{ProxyViewerContainer-DUgxRNbj.mjs → ProxyViewerContainer-DlAl0uF-.mjs} +1569 -1646
  29. package/.output/server/_ssr/{ReplayDialog-De9wKKzS.mjs → ReplayDialog-5m2jtlLa.mjs} +18 -18
  30. package/.output/server/_ssr/{RequestAnatomy-Db4MxUYo.mjs → RequestAnatomy--1WtQNY9.mjs} +58 -58
  31. package/.output/server/_ssr/{ResponseView-8rDXOiNB.mjs → ResponseView-CgbqS8sr.mjs} +60 -71
  32. package/.output/server/_ssr/{StreamingChunkSequence-N9teZHkA.mjs → StreamingChunkSequence-BwpnopWx.mjs} +16 -16
  33. package/.output/server/_ssr/{index-D4DvByuW.mjs → index-CNVi1TzT.mjs} +15 -15
  34. package/.output/server/_ssr/index-DMCjH_4V.mjs +81 -0
  35. package/.output/server/_ssr/index.mjs +2 -2
  36. package/.output/server/_ssr/{json-viewer-BjoHRbjS.mjs → json-viewer-DNGN2uoe.mjs} +58 -58
  37. package/.output/server/_ssr/{router-BYlePDj8.mjs → router-CgsqLnk5.mjs} +16007 -12632
  38. package/.output/server/_tanstack-start-manifest_v-BH5f_kWV.mjs +4 -0
  39. package/.output/server/index.mjs +99 -71
  40. package/.output/workers/logFinalizer.worker.js +16908 -0
  41. package/.output/workers/sessionWorkerEntry.js +16904 -0
  42. package/README.md +21 -5
  43. package/package.json +6 -2
  44. package/src/assets/logos/qwen.webp +0 -0
  45. package/src/cli.ts +85 -10
  46. package/src/components/OnboardingBanner.tsx +41 -21
  47. package/src/components/ProxyViewer.tsx +198 -269
  48. package/src/components/ProxyViewerContainer.tsx +128 -17
  49. package/src/components/ecosystem/AgentLabDialog.tsx +166 -19
  50. package/src/components/errors/SafeErrorBoundary.tsx +201 -0
  51. package/src/components/pi-agent/PiAgentPanel.tsx +209 -35
  52. package/src/components/pi-agent/piAgentChatLogic.ts +263 -0
  53. package/src/components/providers/ImportWizardDialog.tsx +18 -42
  54. package/src/components/providers/ProviderLogo.tsx +1 -1
  55. package/src/components/providers/ProvidersPanel.tsx +8 -5
  56. package/src/components/providers/SettingsDialog.tsx +34 -11
  57. package/src/components/proxy-viewer/ApplicationBar.tsx +63 -0
  58. package/src/components/proxy-viewer/CompareDrawer.tsx +92 -49
  59. package/src/components/proxy-viewer/LiveConnectionStatus.tsx +186 -0
  60. package/src/components/proxy-viewer/LogEntry.tsx +283 -275
  61. package/src/components/proxy-viewer/RawExportWarning.tsx +77 -0
  62. package/src/components/proxy-viewer/SessionLoadProgressBar.tsx +61 -0
  63. package/src/components/proxy-viewer/ThreadConnector.tsx +16 -1
  64. package/src/components/proxy-viewer/TurnGroup.tsx +13 -2
  65. package/src/components/proxy-viewer/accessibility.ts +8 -0
  66. package/src/components/proxy-viewer/lazy.ts +4 -0
  67. package/src/components/proxy-viewer/liveConnectionState.ts +158 -0
  68. package/src/components/proxy-viewer/proxyViewerLogic.ts +10 -0
  69. package/src/components/proxy-viewer/viewerState.ts +2 -6
  70. package/src/components/ui/select.tsx +1 -1
  71. package/src/components/ui/tabs.tsx +3 -3
  72. package/src/components/ui/transient-toast.tsx +7 -6
  73. package/src/lib/apiClient.ts +17 -2
  74. package/src/lib/ecosystemContract.ts +34 -0
  75. package/src/lib/export-logs.ts +1 -1
  76. package/src/lib/piAgentContract.ts +80 -0
  77. package/src/lib/providerContract.ts +70 -4
  78. package/src/lib/providerImportContract.ts +27 -0
  79. package/src/lib/providerModelMetadata.ts +16 -7
  80. package/src/lib/resourceLimits.ts +152 -0
  81. package/src/lib/safeDiagnostic.ts +38 -0
  82. package/src/lib/useProviders.ts +4 -4
  83. package/src/mcp/server.ts +39 -6
  84. package/src/mcp/toolHandlers.ts +131 -4
  85. package/src/proxy/chunkStorage.ts +20 -6
  86. package/src/proxy/config.ts +20 -6
  87. package/src/proxy/dataDir.ts +3 -0
  88. package/src/proxy/ecosystemExecutionConfirmation.ts +114 -0
  89. package/src/proxy/ecosystemExecutionRoute.ts +116 -0
  90. package/src/proxy/ecosystemTasks.ts +48 -0
  91. package/src/proxy/evidenceExporter.ts +23 -9
  92. package/src/proxy/groupEvidenceExporter.ts +26 -5
  93. package/src/proxy/groupStore.ts +13 -3
  94. package/src/proxy/handler.ts +103 -20
  95. package/src/proxy/identityProxy.ts +333 -14
  96. package/src/proxy/logFinalizer.ts +73 -6
  97. package/src/proxy/logImportUpload.ts +128 -0
  98. package/src/proxy/logImporter.ts +321 -70
  99. package/src/proxy/logIndex.ts +16 -6
  100. package/src/proxy/logger.ts +294 -41
  101. package/src/proxy/privateDataPath.ts +183 -0
  102. package/src/proxy/providerScanStore.ts +87 -0
  103. package/src/proxy/providerSecretStore.ts +58 -19
  104. package/src/proxy/providers.ts +175 -58
  105. package/src/proxy/rawStreamCapture.ts +66 -5
  106. package/src/proxy/runStore.ts +13 -3
  107. package/src/proxy/runtimeAdmission.ts +52 -0
  108. package/src/proxy/runtimeHealth.ts +206 -0
  109. package/src/proxy/runtimeShutdown.ts +75 -0
  110. package/src/proxy/sessionArchive.ts +15 -2
  111. package/src/proxy/sessionProcess.ts +19 -0
  112. package/src/proxy/sessionRuntime.ts +7 -0
  113. package/src/proxy/shutdownCoordinator.ts +90 -0
  114. package/src/proxy/sqliteLogIndex.ts +18 -2
  115. package/src/proxy/store.ts +18 -2
  116. package/src/routes/__root.tsx +18 -1
  117. package/src/routes/api/alerts.summary.ts +12 -8
  118. package/src/routes/api/alerts.ts +27 -9
  119. package/src/routes/api/ecosystem.packages.$packageId.help.ts +3 -8
  120. package/src/routes/api/ecosystem.packages.$packageId.install.ts +3 -8
  121. package/src/routes/api/ecosystem.packages.$packageId.runner-presets.ts +3 -11
  122. package/src/routes/api/ecosystem.packages.$packageId.upgrade.ts +3 -8
  123. package/src/routes/api/ecosystem.recipes.$recipeId.run.ts +3 -8
  124. package/src/routes/api/health.ts +9 -2
  125. package/src/routes/api/knowledge.project-context.ts +11 -0
  126. package/src/routes/api/knowledge.search.ts +33 -2
  127. package/src/routes/api/logs.$id.body.ts +16 -2
  128. package/src/routes/api/logs.import.ts +7 -18
  129. package/src/routes/api/logs.stream.ts +147 -69
  130. package/src/routes/api/logs.ts +55 -14
  131. package/src/routes/api/providers.$providerId.model-metadata.ts +22 -4
  132. package/src/routes/api/providers.$providerId.ts +37 -6
  133. package/src/routes/api/providers.export.ts +34 -16
  134. package/src/routes/api/providers.import.ts +42 -8
  135. package/src/routes/api/providers.scan.ts +13 -8
  136. package/src/routes/api/providers.ts +36 -5
  137. package/src/routes/api/runs.ts +12 -12
  138. package/src/routes/api/sessions.ts +15 -8
  139. package/src/routes/index.tsx +6 -0
  140. package/src/routes/livez.ts +13 -0
  141. package/src/routes/readyz.ts +18 -0
  142. package/src/routes/session/$sessionId.tsx +6 -0
  143. package/src/services/piAgent.ts +131 -102
  144. package/src/services/piAgentRetrieval.ts +1180 -0
  145. package/styles/globals.css +19 -3
  146. package/.output/public/assets/CompareDrawer-Cb5ccPeX.js +0 -1
  147. package/.output/public/assets/ProxyViewerContainer-COBe5GTT.js +0 -4234
  148. package/.output/public/assets/ResponseView-Cqq87lX_.js +0 -3
  149. package/.output/public/assets/StreamingChunkSequence-CnTa9mCr.js +0 -1
  150. package/.output/public/assets/index-DTLNVcgc.js +0 -76
  151. package/.output/public/assets/index-DliqmwUw.css +0 -1
  152. package/.output/public/assets/qwen-CONDcHqt.png +0 -0
  153. package/.output/server/_tanstack-start-manifest_v-DMCA8KK3.mjs +0 -4
  154. package/src/assets/logos/mcp.png +0 -0
  155. package/src/assets/logos/qwen.png +0 -0
  156. package/src/components/ui/mcp-logo.tsx +0 -20
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DPiESBo2.js","assets/index-DTLNVcgc.js"])))=>i.map(i=>d[i]);
2
- import{r as l,j as e,_ as M}from"./index-DTLNVcgc.js";import{c as J,Z as F,b as B,_ as g,$ as j,a0 as H,B as m,Y as N,h as v,a1 as y,a2 as k,a3 as S,a4 as A,a5 as O,a6 as w,f as d,a7 as p,g as $,a8 as U,a9 as W}from"./ProxyViewerContainer-COBe5GTT.js";const X=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],z=J("circle-stop",X);var Z="Separator",C="horizontal",Y=["horizontal","vertical"],L=l.forwardRef((n,t)=>{const{decorative:o,orientation:r=C,...s}=n,a=q(r)?r:C,c=o?{role:"none"}:{"aria-orientation":a==="vertical"?a:void 0,role:"separator"};return e.jsx(F.div,{"data-orientation":a,...c,...s,ref:t})});L.displayName=Z;function q(n){return Y.includes(n)}var Q=L;const ee=l.lazy(()=>M(()=>import("./index-DPiESBo2.js"),__vite__mapDeps([0,1]))),te="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 _({text:n}){return e.jsx("div",{className:te,children:e.jsx(l.Suspense,{fallback:e.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading Markdown..."}),children:e.jsx(ee,{children:n})})})}function E({className:n,orientation:t="horizontal",decorative:o=!0,...r}){return e.jsx(Q,{"data-slot":"separator",decorative:o,orientation:t,className:B("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",n),...r})}const ne=/<think>([\s\S]*?)<\/think>/gi,se=/<think>([\s\S]*?)<\/think>/i;function G(n){const t=se.exec(n);if(!t||t[1]===void 0)return{thinking:null,remainingText:n};const o=t[1].trim(),r=n.replace(ne,"").trim();return{thinking:o,remainingText:r}}function oe(n){return e.jsx(e.Fragment,{})}function re({text:n}){const[t,o]=l.useState(!1);return e.jsxs(g,{open:t,onOpenChange:o,children:[e.jsxs(j,{className:"flex items-center gap-1.5 py-0.5 cursor-pointer hover:opacity-80 transition-opacity group",children:[t?e.jsx(N,{className:"size-3 text-muted-foreground"}):e.jsx(v,{className:"size-3 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground text-xs italic select-none opacity-60",children:"[system-reminder]"})]}),e.jsx(y,{children:e.jsx("div",{className:"pl-4 pt-1",children:e.jsx(_,{text:n})})})]})}const ae=l.memo(function({text:t}){if(t.includes("<system-reminder>"))return e.jsx(re,{text:t});const{thinking:o,remainingText:r}=G(t);return e.jsxs("div",{className:"space-y-2",children:[o!==null&&e.jsx(b,{thinking:o}),r.length>0&&e.jsx(_,{text:r}),o===null&&r.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Empty text block"})]})}),b=l.memo(function({thinking:t}){const[o,r]=l.useState(!1);return e.jsx(g,{open:o,onOpenChange:r,children:e.jsxs("div",{className:"border-l-2 border-purple-500/40 my-1",children:[e.jsxs(j,{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:[e.jsx(H,{className:"size-3.5 text-purple-400 shrink-0"}),e.jsx("span",{className:"text-xs font-medium text-purple-400",children:"Thinking"}),e.jsxs(m,{variant:"ghost",className:"text-[10px] text-muted-foreground px-1.5 py-0 h-4 font-mono",children:[t.length.toLocaleString()," chars"]}),e.jsx("span",{className:"flex-1"}),o?e.jsx(N,{className:"size-3 text-muted-foreground"}):e.jsx(v,{className:"size-3 text-muted-foreground"})]}),e.jsx(y,{children:e.jsx("div",{className:"px-3 pb-2",children:e.jsx(k,{className:"max-h-[60vh]",children:e.jsx("pre",{className:"text-xs text-muted-foreground whitespace-pre-wrap font-mono leading-relaxed",children:t})})})})]})})}),ie=l.memo(function({name:t,input:o,toolIndex:r,toolFocus:s}){const[a,i]=l.useState(!1),c=l.useRef(null),x=s?.focusedToolIndex===r;return l.useEffect(()=>{if(!x||s===void 0||s.toolFocusNonce<=0)return;i(!0);const u=window.setTimeout(()=>{const f=c.current;f!==null&&(f.scrollIntoView({block:"center",behavior:"smooth"}),f.focus({preventScroll:!0}))},0);return()=>window.clearTimeout(u)},[x,s,s?.toolFocusNonce]),e.jsx(g,{open:a,onOpenChange:i,children:e.jsxs("div",{className:"border-l-2 border-sky-400/25 my-1","data-response-tool-index":r,children:[e.jsxs(j,{ref:c,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 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[e.jsx(S,{className:"size-3.5 text-sky-400/70 shrink-0"}),e.jsx(m,{variant:"outline",className:"text-[10px] font-mono px-1.5 py-0 h-4",children:t}),e.jsx("span",{className:"flex-1"}),a?e.jsx(N,{className:"size-3 text-muted-foreground"}):e.jsx(v,{className:"size-3 text-muted-foreground"})]}),e.jsx(y,{children:a&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx(k,{className:"max-h-[60vh]",children:e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:e.jsx(A,{data:O(o),defaultExpandDepth:0})})})})})]})})}),ce=l.memo(function({block:t,toolIndex:o,toolFocus:r}){switch(t.type){case"text":return e.jsx(ae,{text:t.text});case"thinking":case"think":return e.jsx(b,{thinking:t.thinking});case"tool_use":return e.jsx(ie,{name:t.name,input:t.input,toolIndex:o??0,toolFocus:r});default:return oe()}}),le=l.memo(function({response:t,toolFocus:o}){let r=0;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(m,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-5 font-mono",children:t.model}),t.stop_reason!==null&&e.jsxs(m,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-5 font-mono flex items-center gap-1",children:[e.jsx(z,{className:"size-2.5"}),t.stop_reason]}),e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs",children:[e.jsx(w,{className:"size-3"}),e.jsxs("span",{className:"font-mono tabular-nums",children:[d(t.usage.input_tokens??0)," in /"," ",d(t.usage.output_tokens??0)," out"]}),t.usage.cache_creation_input_tokens!==void 0&&t.usage.cache_creation_input_tokens!==null&&t.usage.cache_creation_input_tokens>0&&e.jsxs("span",{className:"font-mono tabular-nums text-emerald-400",children:["KV Cache +",d(t.usage.cache_creation_input_tokens)]}),t.usage.cache_read_input_tokens!==void 0&&t.usage.cache_read_input_tokens!==null&&t.usage.cache_read_input_tokens>0&&e.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",d(t.usage.cache_read_input_tokens)]})]})]}),e.jsx(E,{className:"opacity-50"}),e.jsxs("div",{className:"space-y-2",children:[t.content.map((s,a)=>{const i=s.type==="tool_use"?r:void 0;return s.type==="tool_use"&&(r+=1),e.jsx(ce,{block:s,toolIndex:i,toolFocus:o},a)}),t.content.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Empty response content"})]})]})});function P(n){if(n===void 0||n==="")return{};try{return JSON.parse(n)}catch{return null}}function D({toolIndex:n,toolFocus:t,setOpen:o}){const r=l.useRef(null),s=t?.focusedToolIndex===n;return l.useEffect(()=>{if(!s||t===void 0||t.toolFocusNonce<=0)return;o(!0);const a=window.setTimeout(()=>{const i=r.current;i!==null&&(i.scrollIntoView({block:"center",behavior:"smooth"}),i.focus({preventScroll:!0}))},0);return()=>window.clearTimeout(a)},[o,s,t,t?.toolFocusNonce]),r}function ue({name:n,argumentsText:t,toolIndex:o,toolFocus:r}){const s=l.useRef(null),a=r?.focusedToolIndex===o;return l.useEffect(()=>{if(!a||r===void 0||r.toolFocusNonce<=0)return;const i=window.setTimeout(()=>{const c=s.current;c!==null&&(c.scrollIntoView({block:"center",behavior:"smooth"}),c.focus({preventScroll:!0}))},0);return()=>window.clearTimeout(i)},[a,r,r?.toolFocusNonce]),e.jsxs("div",{ref:s,tabIndex:-1,className:"border border-sky-400/20 rounded-md p-3 bg-muted/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","data-response-tool-index":o,children:[e.jsx("div",{className:"text-xs text-sky-400/80 font-mono mb-1",children:"function_call"}),e.jsxs("div",{className:"font-mono text-xs",children:[e.jsx("span",{className:"text-foreground/80",children:n}),e.jsxs("span",{className:"text-muted-foreground",children:["(",t,")"]})]})]})}function de({call:n,toolIndex:t,toolFocus:o}){const[r,s]=l.useState(!1),a=n.function.name??"(unnamed tool)",i=r?P(n.function.arguments):{},c=D({toolIndex:t,toolFocus:o,setOpen:s});return e.jsx(g,{open:r,onOpenChange:s,children:e.jsxs("div",{className:"border-l-2 border-sky-400/25 my-1","data-response-tool-index":t,children:[e.jsxs(j,{ref:c,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 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[e.jsx(S,{className:"size-3.5 text-sky-400/70 shrink-0"}),e.jsx(m,{variant:"outline",className:"text-[10px] font-mono px-1.5 py-0 h-4",children:a}),n.id!==void 0&&n.id!==""&&e.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/60 truncate",children:n.id}),e.jsx("span",{className:"flex-1"}),r?e.jsx(N,{className:"size-3 text-muted-foreground"}):e.jsx(v,{className:"size-3 text-muted-foreground"})]}),e.jsx(y,{children:r&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx(k,{className:"max-h-[60vh]",children:i===null?e.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap break-words text-rose-300/90",children:n.function.arguments}):e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:e.jsx(A,{data:O(i),defaultExpandDepth:0})})})})})]})})}function xe(n){if(n.output_text!==void 0&&n.output_text.length>0)return n.output_text;const t=[];for(const o of n.output??[]){if(p(o,"type")!=="message")continue;const r=p(o,"content");if(Array.isArray(r))for(const s of r){const a=p(s,"type"),i=p(s,"text");(a==="output_text"||a==="text")&&typeof i=="string"&&t.push(i)}}return t.join(`
3
- `)}function me(n){const t=[];for(const o of n.output??[]){if(p(o,"type")!=="function_call")continue;const r=p(o,"name");if(typeof r!="string"||r.length===0)continue;const s=p(o,"id"),a=p(o,"call_id"),i=p(o,"arguments"),c=p(o,"status");t.push({id:typeof s=="string"&&s.length>0?s:null,callId:typeof a=="string"&&a.length>0?a:null,name:r,argumentsText:typeof i=="string"?i:"",status:typeof c=="string"&&c.length>0?c:null})}return t}function pe({call:n,toolIndex:t,toolFocus:o}){const[r,s]=l.useState(!1),a=r?P(n.argumentsText):{},i=n.callId??n.id,c=D({toolIndex:t,toolFocus:o,setOpen:s});return e.jsx(g,{open:r,onOpenChange:s,children:e.jsxs("div",{className:"border-l-2 border-sky-400/25 my-1","data-response-tool-index":t,children:[e.jsxs(j,{ref:c,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 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[e.jsx(S,{className:"size-3.5 text-sky-400/70 shrink-0"}),e.jsx(m,{variant:"outline",className:"text-[10px] font-mono px-1.5 py-0 h-4",children:n.name}),i!==null&&e.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/60 truncate",children:i}),n.status!==null&&e.jsx(m,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-4 font-mono",children:n.status}),e.jsx("span",{className:"flex-1"}),r?e.jsx(N,{className:"size-3 text-muted-foreground"}):e.jsx(v,{className:"size-3 text-muted-foreground"})]}),e.jsx(y,{children:r&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx(k,{className:"max-h-[60vh]",children:a===null?e.jsx("pre",{className:"font-mono text-xs whitespace-pre-wrap break-words text-rose-300/90",children:n.argumentsText}):e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:e.jsx(A,{data:O(a),defaultExpandDepth:0})})})})})]})})}const fe=l.memo(function({response:t,toolFocus:o}){const r=t.choices[0],s=r?.message,a=s?.tool_calls??[];return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(m,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-5 font-mono",children:t.model}),r?.finish_reason!==null&&r?.finish_reason!==void 0&&e.jsxs(m,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-5 font-mono flex items-center gap-1",children:[e.jsx(z,{className:"size-2.5"}),r.finish_reason]}),e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs",children:[e.jsx(w,{className:"size-3"}),e.jsxs("span",{className:"font-mono tabular-nums",children:[d(t.usage.prompt_tokens??0)," in /"," ",d(t.usage.completion_tokens??0)," out"]})]})]}),e.jsx(E,{className:"opacity-50"}),e.jsxs("div",{className:"space-y-2",children:[s?.reasoning_content!==null&&s?.reasoning_content!==void 0&&s.reasoning_content.length>0&&e.jsx(b,{thinking:s.reasoning_content}),s?.content!==null&&s?.content!==void 0&&s.content.length>0&&(()=>{const i=s.reasoning_content!==null&&s.reasoning_content!==void 0&&s.reasoning_content.length>0,{thinking:c,remainingText:x}=G(s.content);return e.jsxs("div",{className:"space-y-2",children:[c!==null&&!i&&e.jsx(b,{thinking:c}),x.length>0&&e.jsx(_,{text:x})]})})(),a.map((i,c)=>e.jsx(de,{call:i,toolIndex:c,toolFocus:o},i.id??`tc-${c}`)),s?.function_call!==null&&s?.function_call!==void 0&&e.jsx(ue,{name:s.function_call.name,argumentsText:s.function_call.arguments,toolIndex:a.length,toolFocus:o}),(s?.content===null||s?.content===void 0||s.content.length===0)&&(s?.reasoning_content===null||s?.reasoning_content===void 0||s.reasoning_content.length===0)&&(s?.function_call===null||s?.function_call===void 0)&&a.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Empty response content"})]})]})}),he=l.memo(function({response:t,toolFocus:o}){const r=xe(t),s=me(t),a=t.status??null,i=t.usage?.input_tokens??0,c=t.usage?.output_tokens??0;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.model!==void 0&&t.model.length>0&&e.jsx(m,{variant:"secondary",className:"text-[10px] px-1.5 py-0 h-5 font-mono",children:t.model}),a!==null&&e.jsxs(m,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-5 font-mono flex items-center gap-1",children:[e.jsx(z,{className:"size-2.5"}),a]}),e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs",children:[e.jsx(w,{className:"size-3"}),e.jsxs("span",{className:"font-mono tabular-nums",children:[d(i)," in / ",d(c)," out"]})]})]}),e.jsx(E,{className:"opacity-50"}),e.jsxs("div",{className:"space-y-2",children:[r.length>0&&e.jsx(_,{text:r}),s.map((x,u)=>e.jsx(pe,{call:x,toolIndex:u,toolFocus:o},x.callId??x.id??`call-${u}`)),r.length===0&&s.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Empty response content"})]})]})});function I(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function ge(n){return I(n)&&n.object==="chat.completion"}function je(n){return I(n)&&n.object==="response"}function Ne(n){return I(n)&&n.type==="message"&&Array.isArray(n.content)}function ve(n,t,o){return n==="openai"&&ge(t)?e.jsx(fe,{response:t,toolFocus:o}):n==="openai"&&je(t)?e.jsx(he,{response:t,toolFocus:o}):n==="anthropic"&&Ne(t)?e.jsx(le,{response:t,toolFocus:o}):null}function ye(n){switch(n){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 h({status:n}){const t=W(n),o=ye(t);return n===null?e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"pending"}):e.jsxs("span",{className:B("flex items-center gap-1 text-xs font-mono font-semibold",o),children:[t==="server_error"&&e.jsx(U,{className:"size-3"}),n]})}function V({text:n}){return e.jsx("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-3",children:e.jsx("pre",{className:"text-xs text-red-300 whitespace-pre-wrap font-mono leading-relaxed overflow-auto max-h-[60vh]",children:n})})}function _e({text:n}){return e.jsx(_,{text:n})}const Re=l.memo(function({responseText:t,responseStatus:o,streaming:r,inputTokens:s,outputTokens:a,cacheCreationInputTokens:i,cacheReadInputTokens:c,apiFormat:x,error:u,focusedToolIndex:f=null,toolFocusNonce:K=0}){const R=x??"unknown",T=l.useMemo(()=>$(R).analyzeResponse(t).parsed,[R,t]);return t===null&&u===void 0?e.jsxs("div",{className:"flex items-center gap-2 py-3",children:[e.jsx(h,{status:o}),e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No response"})]}):o!==null&&o>=400?e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{status:o}),e.jsx(V,{text:t??""}),u!=null&&e.jsxs("div",{className:"rounded border border-destructive/50 bg-destructive/10 p-3 text-xs",children:[e.jsx("div",{className:"font-semibold text-destructive mb-1",children:"SSE Error"}),e.jsx("div",{className:"text-muted-foreground font-mono",children:u})]})]}):u!=null?e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{status:o}),e.jsxs("div",{className:"rounded border border-destructive/50 bg-destructive/10 p-3 text-xs",children:[e.jsx("div",{className:"font-semibold text-destructive mb-1",children:"SSE Error"}),e.jsx("div",{className:"text-muted-foreground font-mono",children:u})]}),t!==null&&e.jsx("div",{className:"mt-2",children:e.jsx(V,{text:t})})]}):T!==null?e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{status:o}),ve(R,T,{focusedToolIndex:f,toolFocusNonce:K})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(h,{status:o}),r&&(s!==null||a!==null)&&e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-xs",children:[e.jsx(w,{className:"size-3"}),e.jsxs("span",{className:"font-mono tabular-nums",children:[s!==null?d(s):"—"," in /"," ",a!==null?d(a):"—"," out"]}),i!=null&&i>0&&e.jsxs("span",{className:"font-mono tabular-nums text-emerald-400",children:["KV Cache +",d(i)]}),c!=null&&c>0&&e.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",d(c)]})]})]}),e.jsx(_e,{text:t??""})]})});export{Re as ResponseView};
@@ -1 +0,0 @@
1
- import{r,j as e}from"./index-DTLNVcgc.js";import{l as b,w as v,x as N,y as k,Y as u,h as x,B as S,z as C,A as y,I as E,F as w,aa as T,a4 as z,ab as R}from"./ProxyViewerContainer-COBe5GTT.js";const L=y({chunks:w(R),truncated:E().optional()}),M=1e4,J=r.memo(function({logId:o,truncated:m}){const[i,h]=r.useState(!1),[a,d]=r.useState({status:"idle"}),[p,f]=r.useState(new Set),c=r.useRef(null);r.useEffect(()=>{if(!i||c.current===o)return;const s=new AbortController;return d({status:"loading"}),b(`/api/logs/${o}/chunks`,L,M,{signal:s.signal},()=>"Chunks not found").then(t=>{c.current=o,d({status:"success",chunks:t.chunks})}).catch(t=>{t instanceof DOMException&&t.name==="AbortError"||(c.current=null,d({status:"error",message:t instanceof Error?t.message:"Chunk data unavailable"}))}),()=>{s.abort()}},[i,o]);const l=r.useMemo(()=>{if(a.status!=="success")return[];const s=new Map;for(const t of a.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)},[a]),g=s=>{f(t=>{const n=new Set(t);return n.has(s)?n.delete(s):n.add(s),n})};function j(){return a.status==="idle"||a.status==="loading"?e.jsxs("div",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",children:[e.jsx(T,{className:"size-3 animate-spin"}),e.jsx("span",{children:"Loading chunks..."})]}):a.status==="error"?e.jsx("div",{className:"py-2 text-xs text-muted-foreground italic",children:a.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:[l.length," index group",l.length!==1?"s":""," available"]}),l.map(s=>{const t=p.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:()=>g(s.index),children:[t?e.jsx(u,{className:"size-3 text-muted-foreground"}):e.jsx(x,{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(r.Suspense,{fallback:e.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:e.jsx(z,{data:n,defaultExpandDepth:0,showCopy:!0})})]},n.index))})]},s.index)})]})}return e.jsxs("div",{className:"space-y-1",children:[e.jsx(v,{children:e.jsxs(N,{children:[e.jsx(k,{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:()=>h(s=>!s),children:[i?e.jsx(u,{className:"size-3"}):e.jsx(x,{className:"size-3"}),e.jsx("span",{children:"Raw SSE Events"}),e.jsxs(S,{variant:"outline",className:"text-[9px] px-1 py-0 h-4 font-mono ml-1",children:[o,m===!0?"+":""]})]})}),e.jsx(C,{children:"Server-Sent Events streaming chunks from the provider"})]})}),i===!0?e.jsx("div",{className:"rounded-md border border-border bg-muted/20 overflow-auto max-h-64",children:j()}):null]})});export{J as StreamingChunkSequence};