@tonyclaw/agent-inspector 3.0.32 → 3.0.34
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/.output/nitro.json +1 -1
- package/.output/public/assets/{CompareDrawer-CONqySRK.js → CompareDrawer-hkDPH0fn.js} +1 -1
- package/.output/public/assets/{InspectorPet-B6oMiG2V.js → InspectorPet-CA5p_sKZ.js} +1 -1
- package/.output/public/assets/{ProxyViewerContainer-Ce_WtVu2.js → ProxyViewerContainer-BI8mJZEm.js} +44 -44
- package/.output/public/assets/ReplayDialog-DYQdKnLy.js +1 -0
- package/.output/public/assets/{RequestAnatomy-gyMOB2oK.js → RequestAnatomy-CLWPhe7O.js} +1 -1
- package/.output/public/assets/ResponseView-CmKzB3ef.js +2 -0
- package/.output/public/assets/StreamingChunkSequence-pUlWbVcB.js +1 -0
- package/.output/public/assets/{_sessionId-DRRig28i.js → _sessionId-CUxLgyb5.js} +1 -1
- package/.output/public/assets/{_sessionId-BW1YYf5W.js → _sessionId-DHvUgaat.js} +1 -1
- package/.output/public/assets/{index-BzL-q9eN.js → index-4H-j0aS5.js} +1 -1
- package/.output/public/assets/{index-CbFGlzA-.js → index-CeoArIMR.js} +1 -1
- package/.output/public/assets/{index-iN9QtGKF.js → index-DD2OkbP7.js} +1 -1
- package/.output/public/assets/{index-BTor51ZC.js → index-sBAb_qFx.js} +2 -2
- package/.output/public/assets/json-viewer-hDs5IHIL.js +1 -0
- package/.output/public/assets/{jszip.min-aHTREmPV.js → jszip.min-DVJw8OAI.js} +1 -1
- package/.output/server/_libs/lucide-react.mjs +184 -176
- package/.output/server/{_sessionId-RGCARWul.mjs → _sessionId-Ci_EMh_S.mjs} +1 -1
- package/.output/server/{_sessionId-CuTfM9Wy.mjs → _sessionId-VR4I9Q9_.mjs} +2 -2
- package/.output/server/_ssr/{CompareDrawer-mUnxKFwp.mjs → CompareDrawer-DuqQ0e6l.mjs} +3 -3
- package/.output/server/_ssr/{InspectorPet-J0mv5NOp.mjs → InspectorPet-Bfbhn0ap.mjs} +2 -2
- package/.output/server/_ssr/{ProxyViewerContainer-C7Wx7SjJ.mjs → ProxyViewerContainer-DmGPK-AE.mjs} +59 -10
- package/.output/server/_ssr/{ReplayDialog-C_zNrriu.mjs → ReplayDialog-0u4cndNH.mjs} +4 -4
- package/.output/server/_ssr/{RequestAnatomy-lvR2Uz9j.mjs → RequestAnatomy-Ce-NTi7F.mjs} +2 -2
- package/.output/server/_ssr/{ResponseView-CRcqekgn.mjs → ResponseView-DFRnVFw7.mjs} +3 -3
- package/.output/server/_ssr/{StreamingChunkSequence-CJLR-ZYV.mjs → StreamingChunkSequence-DR-YGqy7.mjs} +2 -2
- package/.output/server/_ssr/{index-urTy0DU2.mjs → index-BCfDaKgt.mjs} +2 -2
- package/.output/server/_ssr/{index-BhL5Yn1J.mjs → index-kmjlky6J.mjs} +1 -1
- package/.output/server/_ssr/index.mjs +2 -2
- package/.output/server/_ssr/{json-viewer-BcooIEu5.mjs → json-viewer-BPYmlvZw.mjs} +3 -3
- package/.output/server/_ssr/{router-D-PJYphE.mjs → router-DMdBkU6i.mjs} +5 -5
- package/.output/server/{_tanstack-start-manifest_v-DhxDbp_1.mjs → _tanstack-start-manifest_v-7YTvkFnH.mjs} +1 -1
- package/.output/server/index.mjs +92 -92
- package/package.json +1 -1
- package/src/components/proxy-viewer/ApplicationBar.tsx +60 -1
- package/.output/public/assets/ReplayDialog-BauSX4Hj.js +0 -1
- package/.output/public/assets/ResponseView-CUQvY1eb.js +0 -2
- package/.output/public/assets/StreamingChunkSequence-CE6R5CKU.js +0 -1
- package/.output/public/assets/json-viewer-cR8mD7Tl.js +0 -1
|
@@ -1,9 +1,67 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Maximize2, Minimize2 } from "lucide-react";
|
|
2
|
+
import { type JSX, type ReactNode, useCallback, useEffect, useState } from "react";
|
|
2
3
|
import packageJson from "../../../package.json";
|
|
4
|
+
import { Button } from "../ui/button";
|
|
3
5
|
import { CrabLogo } from "../ui/crab-logo";
|
|
6
|
+
import { INSPECTOR_ICON_TRIGGER_CLASS } from "../ui/icon-trigger";
|
|
4
7
|
import { LiveConnectionBadge } from "./LiveConnectionStatus";
|
|
5
8
|
import type { LiveConnectionState } from "./liveConnectionState";
|
|
6
9
|
|
|
10
|
+
function FullscreenAction(): JSX.Element {
|
|
11
|
+
const [isFullscreen, setIsFullscreen] = useState(false);
|
|
12
|
+
const [isSupported, setIsSupported] = useState(false);
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const syncFullscreenState = (): void => {
|
|
16
|
+
setIsFullscreen(document.fullscreenElement !== null);
|
|
17
|
+
setIsSupported(
|
|
18
|
+
document.fullscreenEnabled &&
|
|
19
|
+
document.documentElement.requestFullscreen !== undefined &&
|
|
20
|
+
document.exitFullscreen !== undefined,
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
syncFullscreenState();
|
|
25
|
+
document.addEventListener("fullscreenchange", syncFullscreenState);
|
|
26
|
+
return () => {
|
|
27
|
+
document.removeEventListener("fullscreenchange", syncFullscreenState);
|
|
28
|
+
};
|
|
29
|
+
}, []);
|
|
30
|
+
|
|
31
|
+
const toggleFullscreen = useCallback((): void => {
|
|
32
|
+
if (!isSupported) return;
|
|
33
|
+
if (document.fullscreenElement === null) {
|
|
34
|
+
void document.documentElement.requestFullscreen().catch(() => {
|
|
35
|
+
setIsFullscreen(document.fullscreenElement !== null);
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
void document.exitFullscreen().catch(() => {
|
|
41
|
+
setIsFullscreen(document.fullscreenElement !== null);
|
|
42
|
+
});
|
|
43
|
+
}, [isSupported]);
|
|
44
|
+
|
|
45
|
+
const label = isFullscreen ? "Exit fullscreen" : "Enter fullscreen";
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Button
|
|
49
|
+
type="button"
|
|
50
|
+
variant="ghost"
|
|
51
|
+
size="icon"
|
|
52
|
+
className={INSPECTOR_ICON_TRIGGER_CLASS}
|
|
53
|
+
aria-label={label}
|
|
54
|
+
aria-pressed={isFullscreen}
|
|
55
|
+
title={label}
|
|
56
|
+
disabled={!isSupported}
|
|
57
|
+
onClick={toggleFullscreen}
|
|
58
|
+
>
|
|
59
|
+
{isFullscreen ? <Minimize2 className="size-4" /> : <Maximize2 className="size-4" />}
|
|
60
|
+
<span className="sr-only">{label}</span>
|
|
61
|
+
</Button>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
7
65
|
export function ApplicationBar({
|
|
8
66
|
liveConnection,
|
|
9
67
|
alertsAction,
|
|
@@ -54,6 +112,7 @@ export function ApplicationBar({
|
|
|
54
112
|
aria-label="Application actions"
|
|
55
113
|
className="order-2 flex shrink-0 items-center justify-end gap-1 sm:order-3"
|
|
56
114
|
>
|
|
115
|
+
<FullscreenAction />
|
|
57
116
|
{alertsAction}
|
|
58
117
|
{settingsAction}
|
|
59
118
|
</nav>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as l,j as s,B as y}from"./index-BTor51ZC.js";import{c as U,u as le,i as D,D as oe,j as ie,k as de,l as ue,m as L,T as N,n as R,o as d,p as u,q as ce,s as pe,t as me,v as xe,w as G,x as j,y as fe,z as he,A as ye,E as A,F as V,G as je}from"./ProxyViewerContainer-Ce_WtVu2.js";import{ResponseView as O}from"./ResponseView-CUQvY1eb.js";const be=[["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"}]],ge=U("braces",be);const ve=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Te=U("minimize-2",ve);function W(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ne(e){return e==null?null:new TextEncoder().encode(e).length}function Re(e){try{const t=JSON.parse(e);if(!W(t))return null;const a=t.model;return typeof a=="string"&&a.length>0?a:null}catch{return null}}function ke(e,t){try{const a=JSON.parse(e);return W(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 H(e){return{status:e.status??null,elapsedMs:e.elapsedMs??null,inputTokens:e.inputTokens??null,outputTokens:e.outputTokens??null,responseBytes:Ne(e.responseText),streaming:e.streaming===!0}}function g(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:g(e.status,t.status)},{id:"elapsed",label:"Elapsed",original:e.elapsedMs,replay:t.elapsedMs,delta:g(e.elapsedMs,t.elapsedMs)},{id:"input",label:"Input",original:e.inputTokens,replay:t.inputTokens,delta:g(e.inputTokens,t.inputTokens)},{id:"output",label:"Output",original:e.outputTokens,replay:t.outputTokens,delta:g(e.outputTokens,t.outputTokens)},{id:"bytes",label:"Bytes",original:e.responseBytes,replay:t.responseBytes,delta:g(e.responseBytes,t.responseBytes)},{id:"streaming",label:"Stream",original:e.streaming,replay:t.streaming,delta:null}]}const we=G({success:A(),error:V().optional(),responseStatus:j().nullable().optional(),responseText:V().nullable().optional(),inputTokens:j().nullable().optional(),outputTokens:j().nullable().optional(),elapsedMs:j().nullable().optional(),streaming:A().optional(),replayLogId:j().optional()}),Me=G({logs:fe(je),total:j()}),Ce=6e4,Oe=1e4;function k(e){try{const t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}function Ee(e){try{const t=JSON.parse(e);return JSON.stringify(t)}catch{return e}}function Je(e){try{return JSON.parse(e),{valid:!0,message:"Valid JSON"}}catch(t){return{valid:!1,message:t instanceof Error?t.message:"Invalid JSON"}}}function E(e){return e<1e3?`${String(e)}ms`:`${(e/1e3).toFixed(1)}s`}function P(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 Be(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 _e(e){return e===null||e===0?"text-muted-foreground":e>0?"text-amber-400":"text-emerald-400"}function Y({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:P(t.original,t.id)}),s.jsx("span",{className:"font-mono",children:P(t.replay,t.id)}),s.jsx("span",{className:`font-mono ${_e(t.delta)}`,children:Be(t.delta,t.id)})]},t.id))]})}function Ie({log:e,displayNumber:t,open:a,onOpenChange:J}){const{providers:B}=le(),_=e.rawRequestBody??"{}",[c,K]=l.useState(()=>k(_)),[r,v]=l.useState(null),[Q,X]=l.useState([]),[$,S]=l.useState(!1),[w,p]=l.useState(null),m=l.useRef(null),x=l.useRef(0),f=l.useMemo(()=>Je(c),[c]),M=l.useCallback(()=>{x.current+=1,m.current?.abort(),m.current=null,S(!1)},[]),T=l.useCallback(async()=>{if(a)try{const n=await D(`/api/logs?replayOf=${String(e.id)}`,Me,Oe);X(n.logs)}catch{}},[e.id,a]);l.useEffect(()=>{T()},[T]),l.useEffect(()=>{a||M()},[M,a]),l.useEffect(()=>()=>{x.current+=1,m.current?.abort(),m.current=null},[]);async function Z(){if(!f.valid){p("Request body must be valid JSON before replay.");return}m.current?.abort();const n=x.current+1;x.current=n;const i=new AbortController;m.current=i,S(!0),p(null),v(null);try{const o=await D(`/api/logs/${e.id}/replay`,we,Ce,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({modifiedBody:c}),signal:i.signal});if(x.current!==n)return;v(o),await T(),o.success||p(o.error??"Replay failed")}catch(o){if(x.current!==n)return;if(o instanceof ye||o instanceof DOMException&&o.name==="AbortError"){p("Replay timed out or was canceled.");return}p(o instanceof Error?o.message:"Network error")}finally{x.current===n&&(m.current=null,S(!1))}}function ee(){M(),v(null),p(null),J(!1)}function b(n){K(n),v(null),p(null)}function se(){b(k(c))}function te(){b(Ee(c))}function ne(){b(k(_))}function q(n){window.location.hash=`log-${String(n)}`,he({logId:n,tab:"request"}),J(!1)}const C=l.useMemo(()=>{const n=[];for(const i of B)for(const o of i.models)o.trim().length!==0&&n.push({key:`${i.id}:${o}`,providerName:i.name,model:o});return n},[B]),h=Re(c)??e.model??"";function re(n){const i=ke(c,n);if(i.error!==null){p(i.error);return}b(k(i.body))}const ae=H({status:e.responseStatus,elapsedMs:e.elapsedMs,inputTokens:e.inputTokens,outputTokens:e.outputTokens,responseText:e.responseText,streaming:e.streaming}),F=r===null?null:H({status:r.responseStatus,elapsedMs:r.elapsedMs,inputTokens:r.inputTokens,outputTokens:r.outputTokens,responseText:r.responseText,streaming:r.streaming}),I=F===null?[]:Se(ae,F),z=Q.slice(-5).reverse();return s.jsx(oe,{open:a,onOpenChange:ee,children:s.jsxs(ie,{className:"max-w-4xl max-h-[85vh] overflow-auto",children:[s.jsx(de,{children:s.jsxs(ue,{className:"flex items-center gap-2",children:[s.jsx(L,{className:"size-4"}),s.jsxs("span",{title:`Log ID ${String(e.id)}`,children:["Replay Request #",t]})]})}),s.jsxs(N,{defaultValue:"modified",children:[s.jsxs(R,{children:[s.jsx(d,{value:"modified",children:"Modified Request"}),s.jsx(d,{value:"original",children:"Original Response"}),r&&s.jsx(d,{value:"replay",children:"Replay Response"}),r&&s.jsx(d,{value:"compare",children:"Compare"})]}),s.jsxs(u,{value:"modified",className:"space-y-4",children:[C.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:h,onChange:n=>re(n.currentTarget.value),className:"h-8 rounded-md border border-input bg-background px-2 text-sm",children:[h===""&&s.jsx("option",{value:"",children:"Select model"}),h!==""&&!C.some(n=>n.model===h)&&s.jsx("option",{value:h,children:h}),C.map(n=>s.jsxs("option",{value:n.model,children:[n.providerName," / ",n.model]},n.key))]})]}),z.length>0&&s.jsxs("div",{className:"space-y-2 rounded-md border border-border bg-muted/20 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"text-xs font-medium",children:"Replay history"}),s.jsx(y,{type:"button",variant:"ghost",size:"sm",onClick:()=>{T()},children:"Refresh"})]}),s.jsx("div",{className:"grid gap-1",children:z.map(n=>s.jsxs("button",{type:"button",onClick:()=>q(n.id),className:"grid grid-cols-[auto_1fr_auto_auto] items-center gap-2 rounded-sm px-2 py-1 text-left text-xs hover:bg-muted",children:[s.jsxs("span",{className:"font-mono text-emerald-600",children:["#",n.id]}),s.jsx("span",{className:"truncate font-mono text-muted-foreground",children:n.model??"unknown"}),s.jsx("span",{className:"font-mono text-muted-foreground",children:n.responseStatus??"-"}),s.jsx("span",{className:"font-mono text-muted-foreground",children:n.elapsedMs===null?"-":E(n.elapsedMs)})]},n.id))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsx("label",{htmlFor:`replay-body-${String(e.id)}`,className:"text-sm font-medium",children:"Request Body"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:f.valid?"text-xs text-emerald-500":"text-xs text-destructive",children:f.message}),s.jsxs(y,{type:"button",variant:"outline",size:"sm",onClick:se,disabled:!f.valid,title:"Format JSON",children:[s.jsx(ge,{className:"size-3.5"}),"Format"]}),s.jsxs(y,{type:"button",variant:"outline",size:"sm",onClick:te,disabled:!f.valid,title:"Compact JSON",children:[s.jsx(Te,{className:"size-3.5"}),"Compact"]}),s.jsxs(y,{type:"button",variant:"ghost",size:"sm",onClick:ne,title:"Reset to original request",children:[s.jsx(L,{className:"size-3.5"}),"Reset"]})]})]}),s.jsx(ce,{children:s.jsxs(pe,{children:[s.jsx(me,{asChild:!0,children:s.jsx("textarea",{id:`replay-body-${String(e.id)}`,className:"w-full min-h-80 p-3 font-mono text-xs leading-5 bg-muted rounded-md border border-input resize-y tabular-nums focus:outline-none focus:ring-2 focus:ring-ring",value:c,onChange:n=>b(n.target.value),spellCheck:!1})}),s.jsx(xe,{children:"Edit formatted JSON before re-sending to the provider"})]})})]}),w!==null&&w!==""&&s.jsx("div",{className:"text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md",children:w}),s.jsx("div",{className:"flex justify-end",children:s.jsx(y,{onClick:()=>{Z()},disabled:$||!f.valid,children:$?"Replaying...":"Replay"})}),r!==null&&s.jsx(Y,{comparisons:I.slice(0,4)}),r?.success===!0&&r.replayLogId!==void 0&&s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-emerald-500/25 bg-emerald-500/10 px-3 py-2 text-xs text-emerald-600",children:[s.jsxs("span",{children:["Replay saved as test log #",r.replayLogId,"."]}),s.jsx(y,{type:"button",variant:"outline",size:"sm",onClick:()=>q(r.replayLogId??e.id),children:"Open saved log"})]}),r&&r.success&&s.jsxs(N,{defaultValue:"parsed",children:[s.jsxs(R,{children:[s.jsx(d,{value:"parsed",children:"Response"}),s.jsx(d,{value:"raw",children:"Raw Response"})]}),s.jsx(u,{value:"parsed",children:s.jsx(O,{responseText:r.responseText??null,responseStatus:r.responseStatus??null,streaming:r.streaming??!1,inputTokens:r.inputTokens??null,outputTokens:r.outputTokens??null,apiFormat:e.apiFormat})}),s.jsx(u,{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:r.responseText??"No response"})})]})]}),s.jsx(u,{value:"original",children:e.responseText!==null?s.jsxs(N,{defaultValue:"parsed",children:[s.jsxs(R,{children:[s.jsx(d,{value:"parsed",children:"Response"}),s.jsx(d,{value:"raw",children:"Raw Response"})]}),s.jsx(u,{value:"parsed",children:s.jsx(O,{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(u,{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"})}),r&&r.success&&s.jsx(u,{value:"replay",children:(r.responseText??null)!==null?s.jsxs(N,{defaultValue:"parsed",children:[s.jsxs(R,{children:[s.jsx(d,{value:"parsed",children:"Response"}),s.jsx(d,{value:"raw",children:"Raw Response"})]}),s.jsx(u,{value:"parsed",children:s.jsx(O,{responseText:r.responseText??null,responseStatus:r.responseStatus??null,streaming:r.streaming??!1,inputTokens:r.inputTokens??null,outputTokens:r.outputTokens??null,apiFormat:e.apiFormat})}),s.jsx(u,{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:r.responseText??""})})]}):s.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No replay response"})}),r&&s.jsxs(u,{value:"compare",className:"space-y-3",children:[s.jsx(Y,{comparisons:I}),r.success?null:s.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:r.error??"Replay failed"})]})]})]})})}export{Ie as ReplayDialog};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as c,j as e,k as B,o as d,t as D}from"./index-BTor51ZC.js";import{Q as F,U as g,V as j,W as H,B as m,O as N,e as v,Y as y,Z as k,_ as O,$ as z,a0 as S,a1 as b,a2 as T,a3 as w,a4 as p,g as M,a5 as U}from"./ProxyViewerContainer-Ce_WtVu2.js";var $="Separator",C="horizontal",X=["horizontal","vertical"],G=c.forwardRef((n,t)=>{const{decorative:o,orientation:r=C,...s}=n,a=Z(r)?r:C,l=o?{role:"none"}:{"aria-orientation":a==="vertical"?a:void 0,role:"separator"};return e.jsx(F.div,{"data-orientation":a,...l,...s,ref:t})});G.displayName=$;function Z(n){return X.includes(n)}var Q=G;function A({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 W=/<think>([\s\S]*?)<\/think>/gi,Y=/<think>([\s\S]*?)<\/think>/i;function L(n){const t=Y.exec(n);if(!t||t[1]===void 0)return{thinking:null,remainingText:n};const o=t[1].trim(),r=n.replace(W,"").trim();return{thinking:o,remainingText:r}}function q(n){return e.jsx(e.Fragment,{})}function ee({text:n}){const[t,o]=c.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(b,{text:n})})})]})}const te=c.memo(function({text:t}){if(t.includes("<system-reminder>"))return e.jsx(ee,{text:t});const{thinking:o,remainingText:r}=L(t);return e.jsxs("div",{className:"space-y-2",children:[o!==null&&e.jsx(_,{thinking:o}),r.length>0&&e.jsx(b,{text:r}),o===null&&r.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"Empty text block"})]})}),_=c.memo(function({thinking:t}){const[o,r]=c.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})})})})]})})}),ne=c.memo(function({name:t,input:o,toolIndex:r,toolFocus:s}){const[a,i]=c.useState(!1),l=c.useRef(null),x=s?.focusedToolIndex===r;return c.useEffect(()=>{if(!x||s===void 0||s.toolFocusNonce<=0)return;i(!0);const u=window.setTimeout(()=>{const f=l.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:l,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(O,{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(c.Suspense,{fallback:e.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:e.jsx(z,{data:S(o),defaultExpandDepth:0})})})})})]})})}),se=c.memo(function({block:t,toolIndex:o,toolFocus:r}){switch(t.type){case"text":return e.jsx(te,{text:t.text});case"thinking":case"think":return e.jsx(_,{thinking:t.thinking});case"tool_use":return e.jsx(ne,{name:t.name,input:t.input,toolIndex:o??0,toolFocus:r});default:return q()}}),oe=c.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(T,{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(A,{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(se,{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 J(n){if(n===void 0||n==="")return{};try{return JSON.parse(n)}catch{return null}}function K({toolIndex:n,toolFocus:t,setOpen:o}){const r=c.useRef(null),s=t?.focusedToolIndex===n;return c.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 re({name:n,argumentsText:t,toolIndex:o,toolFocus:r}){const s=c.useRef(null),a=r?.focusedToolIndex===o;return c.useEffect(()=>{if(!a||r===void 0||r.toolFocusNonce<=0)return;const i=window.setTimeout(()=>{const l=s.current;l!==null&&(l.scrollIntoView({block:"center",behavior:"smooth"}),l.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 ae({call:n,toolIndex:t,toolFocus:o}){const[r,s]=c.useState(!1),a=n.function.name??"(unnamed tool)",i=r?J(n.function.arguments):{},l=K({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:l,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(O,{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(c.Suspense,{fallback:e.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:e.jsx(z,{data:S(i),defaultExpandDepth:0})})})})})]})})}function ie(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(`
|
|
2
|
-
`)}function le(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"),l=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 l=="string"&&l.length>0?l:null})}return t}function ce({call:n,toolIndex:t,toolFocus:o}){const[r,s]=c.useState(!1),a=r?J(n.argumentsText):{},i=n.callId??n.id,l=K({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:l,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(O,{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(c.Suspense,{fallback:e.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:e.jsx(z,{data:S(a),defaultExpandDepth:0})})})})})]})})}const ue=c.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(T,{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(A,{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(_,{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:l,remainingText:x}=L(s.content);return e.jsxs("div",{className:"space-y-2",children:[l!==null&&!i&&e.jsx(_,{thinking:l}),x.length>0&&e.jsx(b,{text:x})]})})(),a.map((i,l)=>e.jsx(ae,{call:i,toolIndex:l,toolFocus:o},i.id??`tc-${l}`)),s?.function_call!==null&&s?.function_call!==void 0&&e.jsx(re,{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"})]})]})}),de=c.memo(function({response:t,toolFocus:o}){const r=ie(t),s=le(t),a=t.status??null,i=t.usage?.input_tokens??0,l=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(T,{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(l)," out"]})]})]}),e.jsx(A,{className:"opacity-50"}),e.jsxs("div",{className:"space-y-2",children:[r.length>0&&e.jsx(b,{text:r}),s.map((x,u)=>e.jsx(ce,{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 E(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function xe(n){return E(n)&&n.object==="chat.completion"}function me(n){return E(n)&&n.object==="response"}function pe(n){return E(n)&&n.type==="message"&&Array.isArray(n.content)}function fe(n,t,o){return n==="openai"&&xe(t)?e.jsx(ue,{response:t,toolFocus:o}):n==="openai"&&me(t)?e.jsx(de,{response:t,toolFocus:o}):n==="anthropic"&&pe(t)?e.jsx(oe,{response:t,toolFocus:o}):null}function he(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=D(n),o=he(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 ge({text:n}){return e.jsx(b,{text:n})}const ye=c.memo(function({responseText:t,responseStatus:o,streaming:r,inputTokens:s,outputTokens:a,cacheCreationInputTokens:i,cacheReadInputTokens:l,apiFormat:x,error:u,focusedToolIndex:f=null,toolFocusNonce:P=0}){const R=x??"unknown",I=c.useMemo(()=>M(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})})]}):I!==null?e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{status:o}),fe(R,I,{focusedToolIndex:f,toolFocusNonce:P})]}):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)]}),l!=null&&l>0&&e.jsxs("span",{className:"font-mono tabular-nums text-purple-400",children:["KV Cache ~",d(l)]})]})]}),e.jsx(ge,{text:t??""})]})});export{ye as ResponseView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r,j as e}from"./index-BTor51ZC.js";import{i as b,q as v,s as N,t as k,O as l,e as x,B as S,v as C,w as y,E,y as w,a6 as T,$ as z,a7 as R}from"./ProxyViewerContainer-Ce_WtVu2.js";const L=y({chunks:w(R),truncated:E().optional()}),M=1e4,B=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 u=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:[u.length," index group",u.length!==1?"s":""," available"]}),u.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(l,{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(l,{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{B as StreamingChunkSequence};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as i,j as e,k as m,s as R}from"./index-BTor51ZC.js";import{q as D,a8 as q,f as V,h as z,O as G,e as U,s as W,t as H,v as Q,a9 as X}from"./ProxyViewerContainer-Ce_WtVu2.js";function M(s){if(s===null)return"null";if(Array.isArray(s))return"array";switch(typeof s){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"object":return"object";case"bigint":case"symbol":case"undefined":case"function":return"object"}}function g(s){return s!==null&&(Array.isArray(s)||typeof s=="object")}function $(s){return Array.isArray(s)?s.map((t,n)=>[String(n),t]):typeof s=="object"&&s!==null?Object.entries(s):[]}const J=120;function O({text:s}){return e.jsx("span",{className:"whitespace-pre-wrap break-words",children:s})}function Z({text:s}){const[t,n]=i.useState(!1);return s.length>J?e.jsxs("span",{className:"text-emerald-400 break-all",children:['"',t?e.jsx("span",{className:"cursor-pointer",onClick:r=>{r.stopPropagation(),n(!1)},onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.stopPropagation(),n(!1))},role:"button",tabIndex:0,children:e.jsx(O,{text:s})}):e.jsxs(W,{delayDuration:300,children:[e.jsxs(H,{onClick:r=>{r.stopPropagation(),n(!0)},className:"text-left cursor-pointer",children:[e.jsx("span",{children:s.slice(0,J)}),e.jsx("span",{className:"text-emerald-400/50",children:"..."})]}),e.jsxs(Q,{side:"bottom",className:"max-w-md text-xs p-2 break-words whitespace-pre-wrap",children:[s.slice(0,500),s.length>500?"...":""]})]}),'"']}):e.jsxs("span",{className:"text-emerald-400 break-all",children:['"',e.jsx(O,{text:s}),'"']})}function B({value:s}){if(s===null)return e.jsx("span",{className:"text-rose-400 italic",children:"null"});switch(typeof s){case"string":return e.jsx(Z,{text:s});case"number":return e.jsx("span",{className:"text-amber-400",children:s});case"boolean":return e.jsx("span",{className:"text-blue-400",children:s?"true":"false"});case"object":case"bigint":case"symbol":case"undefined":case"function":return e.jsx("span",{className:"text-muted-foreground",children:JSON.stringify(s)})}}function A({value:s}){const[t,n]=i.useState(!1);function a(r){r.stopPropagation(),R(JSON.stringify(s,null,2)).then(d=>{d&&(n(!0),setTimeout(()=>{n(!1)},2e3))})}return e.jsx("button",{type:"button",onClick:a,className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors","aria-label":t?"Copied JSON":"Copy JSON",title:"Copy JSON",children:t?e.jsx(V,{className:"size-3 text-green-500"}):e.jsx(z,{className:"size-3"})})}function ee({value:s}){const[t,n]=i.useState(!1);function a(r){r.stopPropagation(),R(JSON.stringify(s,null,2)).then(d=>{d&&(n(!0),setTimeout(()=>{n(!1)},2e3))})}return e.jsx("button",{type:"button",onClick:a,className:"opacity-0 group-hover/row:opacity-100 hover:bg-muted p-0.5 rounded transition-opacity shrink-0","aria-label":t?"Copied JSON value":"Copy JSON value",title:"Copy to clipboard",children:t?e.jsx(V,{className:"size-3 text-green-500"}):e.jsx(z,{className:"size-3 text-muted-foreground"})})}function se({onClick:s}){return e.jsx("button",{type:"button",onClick:s,className:"opacity-0 group-hover/row:opacity-100 hover:bg-muted p-0.5 rounded transition-opacity shrink-0",title:"Expand all descendants",children:e.jsx(X,{className:"size-3.5 text-muted-foreground"})})}const ne=i.memo(function s({name:t,value:n,level:a,defaultExpandDepth:r,isArrayItem:d,path:l,expandTargetPath:u,anatomyPaths:f}){const h=i.useMemo(()=>u===null?!1:l===""?u.length>0:u===l||u.startsWith(`${l}/`),[u,l]),C=a<r||h&&g(n),[p,j]=i.useState(C);i.useEffect(()=>{h&&g(n)&&!p&&j(!0)},[u]);const[y,x]=i.useState(0),[N,w]=i.useState(null),c=g(n),v=N===Number.POSITIVE_INFINITY,b=i.useMemo(()=>$(n),[n]),S=i.useMemo(()=>b.some(([,o])=>g(o)),[b]),k=M(n),F=k==="array"?"[":"{",T=k==="array"?"]":"}",K=f!==null&&f.has(l);function E(){j(!0),w(Number.POSITIVE_INFINITY),x(o=>o+1)}function P(){j(!1),w(0),x(o=>o+1)}function I(){v?P():j(!p)}function _(o){o.stopPropagation(),E()}const L=N??r;return e.jsxs("div",{className:m(a>0&&"border-l border-border/50 ml-2"),children:[e.jsxs("div",{className:m("flex items-start gap-1 py-0.5 px-1 -ml-1 rounded-sm group/row",c&&"cursor-pointer hover:bg-muted/50"),"data-anatomy-path":K?l:void 0,onClick:c?I:void 0,onKeyDown:c?o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),I())}:void 0,onDoubleClick:c&&S?()=>E():void 0,role:c?"button":void 0,tabIndex:c?0:void 0,children:[c?e.jsx("span",{className:"w-4 h-5 flex items-center justify-center shrink-0",children:p?e.jsx(G,{className:"size-3 text-muted-foreground"}):e.jsx(U,{className:"size-3 text-muted-foreground"})}):e.jsx("span",{className:"w-4 shrink-0"}),e.jsx("span",{className:m("shrink-0",d?"text-muted-foreground":"text-cyan-400"),children:d?t:`"${t}"`}),e.jsx("span",{className:"text-muted-foreground shrink-0",children:c?"":":"}),c?e.jsxs("span",{className:"text-muted-foreground",children:[F,e.jsxs("span",{className:"text-muted-foreground/60 text-xs",children:[" ",b.length," ",b.length===1?"item":"items"," ",T]})]}):e.jsx("span",{className:"min-w-0",children:e.jsx(B,{value:n})}),c&&S&&!v&&e.jsx(se,{onClick:_}),e.jsx(ee,{value:n})]}),c&&p&&e.jsxs("div",{className:"pl-4",children:[b.map(([o,Y])=>e.jsx(s,{name:o,value:Y,level:a+1,defaultExpandDepth:L,isArrayItem:k==="array",path:l===""?`/${o}`:`${l}/${o}`,expandTargetPath:u,anatomyPaths:f},o)),e.jsx("div",{className:"text-muted-foreground py-0.5 px-1",children:T})]},y)]})});function te({data:s,defaultExpandDepth:t=0,className:n,showCopy:a=!1,bulkDepth:r,bulkRevision:d,anatomyPaths:l=null,expandToPath:u=null}){const f=g(s),h=i.useMemo(()=>$(s),[s]),C=r??t,p=d??0;if(!f)return e.jsx(D,{children:e.jsx("div",{className:m("font-mono text-xs leading-relaxed",n),children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(B,{value:s}),a&&e.jsx(A,{value:s})]})})});const y=M(s)==="array";return e.jsx(D,{children:e.jsxs("div",{className:m("font-mono text-xs leading-relaxed",n),children:[a&&e.jsx("div",{className:"mb-2 flex items-center justify-end gap-2",children:e.jsx(A,{value:s})}),h.length===0&&e.jsxs("div",{className:"rounded-md border border-white/10 bg-black/20 px-3 py-2 text-muted-foreground",children:[e.jsx("span",{className:"text-cyan-300",children:y?"[]":"{}"}),e.jsx("span",{className:"ml-2 text-[10px] uppercase",children:"0 items"})]}),e.jsx("div",{children:h.map(([x,N])=>e.jsx(ne,{name:x,value:N,level:0,defaultExpandDepth:C,isArrayItem:y,path:`/${x}`,expandTargetPath:u,anatomyPaths:l},x))},p)]})})}const ae=i.memo(function({text:t,defaultExpandDepth:n=0,className:a,bulkDepth:r,bulkRevision:d}){const l=i.useMemo(()=>q(t),[t]);return l.kind==="json"?e.jsx(te,{data:l.data,defaultExpandDepth:n,className:a,bulkDepth:r,bulkRevision:d}):e.jsx("pre",{className:m("font-mono text-xs whitespace-pre-wrap break-words",a),children:t})});export{te as JsonViewer,ae as JsonViewerFromString};
|