@tonyclaw/agent-inspector 3.0.17 → 3.0.19
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/cli.js +1255 -504
- package/.output/nitro.json +3 -3
- package/.output/public/assets/CompareDrawer-DR3WgrId.js +1 -0
- package/.output/public/assets/ProxyViewerContainer-B7PZaz5j.js +127 -0
- package/.output/public/assets/ReplayDialog-Bt9jgdvJ.js +1 -0
- package/.output/public/assets/RequestAnatomy-C-4630lw.js +1 -0
- package/.output/public/assets/ResponseView-f_JrN1iQ.js +3 -0
- package/.output/public/assets/StreamingChunkSequence-D8dBm1d8.js +1 -0
- package/.output/public/assets/_sessionId-CtoSDXDC.js +1 -0
- package/.output/public/assets/index-B-rVc2xu.js +12 -0
- package/.output/public/assets/index-B3YOj8-_.css +1 -0
- package/.output/public/assets/{index-DPc2wzgW.js → index-BNCySZM-.js} +1 -1
- package/.output/public/assets/index-BtCnkWve.js +1 -0
- package/.output/public/assets/json-viewer-DT6QQY81.js +1 -0
- package/.output/server/_chunks/ssr-renderer.mjs +18 -2
- package/.output/server/_libs/@radix-ui/react-dismissable-layer+[...].mjs +165 -31
- package/.output/server/_libs/@radix-ui/react-use-callback-ref+[...].mjs +1 -1
- package/.output/server/_libs/@radix-ui/react-use-controllable-state+[...].mjs +2 -2
- package/.output/server/_libs/@radix-ui/react-use-is-hydrated+[...].mjs +28 -1
- package/.output/server/_libs/mistralai__mistralai.mjs +1 -1
- package/.output/server/_libs/modelcontextprotocol__server.mjs +11571 -8127
- package/.output/server/_libs/radix-ui__primitive.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-collapsible.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-collection.mjs +8 -8
- package/.output/server/_libs/radix-ui__react-compose-refs.mjs +0 -1
- package/.output/server/_libs/radix-ui__react-context.mjs +4 -18
- package/.output/server/_libs/radix-ui__react-dialog.mjs +41 -88
- package/.output/server/_libs/radix-ui__react-focus-guards.mjs +15 -5
- package/.output/server/_libs/radix-ui__react-focus-scope.mjs +6 -2
- package/.output/server/_libs/radix-ui__react-id.mjs +3 -3
- package/.output/server/_libs/radix-ui__react-popper.mjs +62 -8
- package/.output/server/_libs/radix-ui__react-portal.mjs +2 -2
- package/.output/server/_libs/radix-ui__react-presence.mjs +50 -5
- package/.output/server/_libs/radix-ui__react-roving-focus.mjs +15 -4
- package/.output/server/_libs/radix-ui__react-scroll-area.mjs +30 -20
- package/.output/server/_libs/radix-ui__react-select.mjs +167 -123
- package/.output/server/_libs/radix-ui__react-slot.mjs +74 -41
- package/.output/server/_libs/radix-ui__react-tabs.mjs +6 -1
- package/.output/server/_libs/radix-ui__react-tooltip.mjs +6 -3
- package/.output/server/_libs/react-dom.mjs +13 -15
- package/.output/server/_libs/react.mjs +45 -45
- package/.output/server/_libs/srvx.mjs +409 -53
- package/.output/server/_libs/swr.mjs +10 -2
- package/.output/server/_libs/tailwind-merge.mjs +286 -41
- package/.output/server/_libs/tanstack__history.mjs +9 -13
- package/.output/server/_libs/tanstack__react-router.mjs +788 -1092
- package/.output/server/_libs/tanstack__react-store.mjs +1 -1
- package/.output/server/_libs/tanstack__react-virtual.mjs +82 -7
- package/.output/server/_libs/tanstack__router-core.mjs +1841 -2060
- package/.output/server/_libs/tanstack__virtual-core.mjs +116 -45
- package/.output/server/_libs/use-sync-external-store.mjs +1 -1
- package/.output/server/_libs/zod-to-json-schema.mjs +1 -1
- package/.output/server/_libs/zod.mjs +5085 -200
- package/.output/server/{_sessionId-DL2JQJwR.mjs → _sessionId-DbRqqzqz.mjs} +30 -32
- package/.output/server/_ssr/{CompareDrawer-hPTOTmyU.mjs → CompareDrawer-CVhUSZu1.mjs} +29 -31
- package/.output/server/_ssr/{ProxyViewerContainer-k0mFaufl.mjs → ProxyViewerContainer-BNnDYtc5.mjs} +106 -71
- package/.output/server/_ssr/{ReplayDialog-t6QdwnZh.mjs → ReplayDialog-DVkGajZU.mjs} +30 -32
- package/.output/server/_ssr/{RequestAnatomy-BnvWxyac.mjs → RequestAnatomy-_FIfVjDR.mjs} +29 -31
- package/.output/server/_ssr/{ResponseView-BhhozRRl.mjs → ResponseView-Bnv5ejVA.mjs} +29 -31
- package/.output/server/_ssr/{StreamingChunkSequence-Dl_laTbX.mjs → StreamingChunkSequence-vtwzxw7A.mjs} +29 -31
- package/.output/server/_ssr/empty-plugin-adapters-BFgPZ6_d.mjs +6 -0
- package/.output/server/_ssr/{index-D1-t1D8F.mjs → index-DFJbRoyq.mjs} +31 -33
- package/.output/server/_ssr/index.mjs +1102 -784
- package/.output/server/_ssr/{json-viewer-D5Lh2yBU.mjs → json-viewer-BkweASh3.mjs} +29 -31
- package/.output/server/_ssr/{router-DaLFEeWW.mjs → router-gFd3g7WM.mjs} +10 -7
- package/.output/server/_tanstack-start-manifest_v-DeLutIlq.mjs +4 -0
- package/.output/server/index.mjs +85 -103
- package/package.json +17 -8
- package/src/components/clients/ClientLogo.tsx +5 -1
- package/src/components/proxy-viewer/LogEntry.tsx +54 -19
- package/src/components/proxy-viewer/RequestToolsPanel.tsx +1 -0
- package/src/components/proxy-viewer/ResponseView.tsx +1 -0
- package/src/components/proxy-viewer/StreamingChunkSequence.tsx +1 -0
- package/src/components/proxy-viewer/TurnGroup.tsx +1 -0
- package/src/components/proxy-viewer/anatomy/SegmentBar.tsx +1 -0
- package/src/components/proxy-viewer/formats/anthropic/ContentBlocks.tsx +4 -0
- package/src/components/proxy-viewer/formats/anthropic/ResponseView.tsx +1 -0
- package/src/components/proxy-viewer/formats/openai/ResponseView.tsx +2 -0
- package/src/components/proxy-viewer/logEntryVisibility.ts +22 -0
- package/src/components/ui/dialog.tsx +1 -1
- package/src/components/ui/json-viewer.tsx +2 -0
- package/src/components/ui/select.tsx +1 -1
- package/src/router.tsx +9 -0
- package/.output/public/assets/CompareDrawer-Lx-WeJNC.js +0 -1
- package/.output/public/assets/ProxyViewerContainer-BNehwMI0.js +0 -106
- package/.output/public/assets/ReplayDialog-CADaXFPE.js +0 -1
- package/.output/public/assets/RequestAnatomy-CGoL8ACh.js +0 -1
- package/.output/public/assets/ResponseView-BSwM1dCH.js +0 -3
- package/.output/public/assets/StreamingChunkSequence-qhWtSx3D.js +0 -1
- package/.output/public/assets/_sessionId-2uq_HB8p.js +0 -1
- package/.output/public/assets/index-BHXN1Fsx.css +0 -1
- package/.output/public/assets/index-T0u1foYL.js +0 -1
- package/.output/public/assets/json-viewer-uIwLntt-.js +0 -1
- package/.output/public/assets/main-DuFBHsus.js +0 -18
- package/.output/server/_libs/@radix-ui/react-use-escape-keydown+[...].mjs +0 -17
- package/.output/server/_libs/cfworker__json-schema.mjs +0 -1
- package/.output/server/_libs/tiny-invariant.mjs +0 -12
- package/.output/server/_libs/tiny-warning.mjs +0 -5
- package/.output/server/_tanstack-start-manifest_v-DsSiD2gY.mjs +0 -4
|
@@ -66,6 +66,7 @@ function MarkdownFallbackView({ text }: { text: string }): JSX.Element {
|
|
|
66
66
|
return <AnswerMarkdown text={text} />;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow -- named function gives React DevTools a readable displayName
|
|
69
70
|
export const ResponseView = memo(function ResponseView({
|
|
70
71
|
responseText,
|
|
71
72
|
responseStatus,
|
|
@@ -30,6 +30,7 @@ const StreamingChunksResponseSchema = z.object({
|
|
|
30
30
|
|
|
31
31
|
const CHUNK_FETCH_TIMEOUT_MS = 10_000;
|
|
32
32
|
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow -- named function gives React DevTools a readable displayName
|
|
33
34
|
export const StreamingChunkSequence = memo(function StreamingChunkSequence({
|
|
34
35
|
logId,
|
|
35
36
|
truncated,
|
|
@@ -51,6 +51,7 @@ export type TurnGroupProps = {
|
|
|
51
51
|
showLogClientMetadata?: boolean;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow -- named function gives React DevTools a readable displayName
|
|
54
55
|
export const TurnGroup = memo(function TurnGroup({
|
|
55
56
|
entries,
|
|
56
57
|
viewMode,
|
|
@@ -54,6 +54,7 @@ export type SegmentBarProps = {
|
|
|
54
54
|
* context segment. Segment mode can activate a JSON path; aggregate modes stay
|
|
55
55
|
* static so they do not imply a misleading jump target.
|
|
56
56
|
*/
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow -- named function gives React DevTools a readable displayName
|
|
57
58
|
export const SegmentBar = memo(function SegmentBar({
|
|
58
59
|
segments,
|
|
59
60
|
totalTokens,
|
|
@@ -38,6 +38,7 @@ function SystemReminderBlock({ text }: { text: string }): JSX.Element {
|
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow -- named function gives React DevTools a readable displayName
|
|
41
42
|
export const TextBlock = memo(function TextBlock({ text }: { text: string }): JSX.Element {
|
|
42
43
|
if (text.includes("<system-reminder>")) {
|
|
43
44
|
return <SystemReminderBlock text={text} />;
|
|
@@ -57,6 +58,7 @@ export const TextBlock = memo(function TextBlock({ text }: { text: string }): JS
|
|
|
57
58
|
);
|
|
58
59
|
});
|
|
59
60
|
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow -- named function gives React DevTools a readable displayName
|
|
60
62
|
export const ThinkingBlock = memo(function ThinkingBlock({
|
|
61
63
|
thinking,
|
|
62
64
|
}: {
|
|
@@ -97,6 +99,7 @@ export const ThinkingBlock = memo(function ThinkingBlock({
|
|
|
97
99
|
);
|
|
98
100
|
});
|
|
99
101
|
|
|
102
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow -- named function gives React DevTools a readable displayName
|
|
100
103
|
export const ToolUseBlock = memo(function ToolUseBlock({
|
|
101
104
|
name,
|
|
102
105
|
input,
|
|
@@ -160,6 +163,7 @@ export const ToolUseBlock = memo(function ToolUseBlock({
|
|
|
160
163
|
);
|
|
161
164
|
});
|
|
162
165
|
|
|
166
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow -- named function gives React DevTools a readable displayName
|
|
163
167
|
export const ResponseContentBlockRenderer = memo(function ResponseContentBlockRenderer({
|
|
164
168
|
block,
|
|
165
169
|
toolIndex,
|
|
@@ -7,6 +7,7 @@ import { Separator } from "../../../ui/separator";
|
|
|
7
7
|
import type { ResponseToolFocus } from "../index";
|
|
8
8
|
import { ResponseContentBlockRenderer } from "./ContentBlocks";
|
|
9
9
|
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow -- named function gives React DevTools a readable displayName
|
|
10
11
|
export const StructuredResponseViewAnthropic = memo(function StructuredResponseViewAnthropic({
|
|
11
12
|
response,
|
|
12
13
|
toolFocus,
|
|
@@ -283,6 +283,7 @@ function ResponsesFunctionCallBlock({
|
|
|
283
283
|
);
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow -- named function gives React DevTools a readable displayName
|
|
286
287
|
export const OpenAIResponseView = memo(function OpenAIResponseView({
|
|
287
288
|
response,
|
|
288
289
|
toolFocus,
|
|
@@ -378,6 +379,7 @@ export const OpenAIResponseView = memo(function OpenAIResponseView({
|
|
|
378
379
|
);
|
|
379
380
|
});
|
|
380
381
|
|
|
382
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow -- named function gives React DevTools a readable displayName
|
|
381
383
|
export const OpenAIResponsesResponseView = memo(function OpenAIResponsesResponseView({
|
|
382
384
|
response,
|
|
383
385
|
toolFocus,
|
|
@@ -23,6 +23,28 @@ export function shouldShowHeadersDiffButton(
|
|
|
23
23
|
return viewMode === "full" && hasRawHeaders;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Pure visibility rule for the `Raw Headers` tab. Inherits the same mode
|
|
28
|
+
* constraint as `shouldShowHeadersDiffButton` (full mode required to surface
|
|
29
|
+
* raw capture data), and additionally requires that the log actually has at
|
|
30
|
+
* least one captured header — otherwise the tab would render an empty panel.
|
|
31
|
+
*/
|
|
32
|
+
export function shouldShowRawHeadersTab(
|
|
33
|
+
viewMode: "simple" | "full",
|
|
34
|
+
hasRawHeaders: boolean,
|
|
35
|
+
): boolean {
|
|
36
|
+
return viewMode === "full" && hasRawHeaders;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Pure visibility rule for the `Headers` tab. Mirrors `shouldShowRawHeadersTab`
|
|
41
|
+
* but against the processed outgoing headers (rather than the raw inbound
|
|
42
|
+
* headers). Like its sibling it requires full mode AND a non-empty capture.
|
|
43
|
+
*/
|
|
44
|
+
export function shouldShowHeadersTab(viewMode: "simple" | "full", hasHeaders: boolean): boolean {
|
|
45
|
+
return viewMode === "full" && hasHeaders;
|
|
46
|
+
}
|
|
47
|
+
|
|
26
48
|
/**
|
|
27
49
|
* Pure visibility rule for the "Diff with Raw" button in the Request tab.
|
|
28
50
|
* Mirrors the conditions for the `Raw Request` tab itself: full mode plus
|
|
@@ -220,6 +220,7 @@ function ExpandCollapseButton({
|
|
|
220
220
|
);
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow -- named function gives React DevTools a readable displayName
|
|
223
224
|
const JsonNode = memo(function JsonNode({
|
|
224
225
|
name,
|
|
225
226
|
value,
|
|
@@ -479,6 +480,7 @@ export type JsonViewerFromStringProps = {
|
|
|
479
480
|
bulkRevision?: number;
|
|
480
481
|
};
|
|
481
482
|
|
|
483
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow -- named function gives React DevTools a readable displayName
|
|
482
484
|
export const JsonViewerFromString = memo(function JsonViewerFromString({
|
|
483
485
|
text,
|
|
484
486
|
defaultExpandDepth = 0,
|
package/src/router.tsx
CHANGED
|
@@ -13,6 +13,15 @@ export function getRouter() {
|
|
|
13
13
|
function attachServerSsrStoreCompatibility(
|
|
14
14
|
router: Readonly<{ state: Readonly<{ matches: unknown }> }>,
|
|
15
15
|
): void {
|
|
16
|
+
// TanStack >= 1.168 refactored `state` from an own data property into a
|
|
17
|
+
// prototype getter backed by lazily-created `stores` (`this.stores.__store`).
|
|
18
|
+
// Installing a `stores` value here would shadow that lazy init
|
|
19
|
+
// (`if (!this.stores && this.latestLocation) { this.stores = … }`) and break
|
|
20
|
+
// `router.state`. When `state` is already a prototype accessor the new store
|
|
21
|
+
// architecture handles SSR natively and this shim is obsolete.
|
|
22
|
+
const stateDesc = Object.getOwnPropertyDescriptor(router, "state");
|
|
23
|
+
if (stateDesc === undefined) return;
|
|
24
|
+
|
|
16
25
|
const existingStores = Object.getOwnPropertyDescriptor(router, "stores");
|
|
17
26
|
if (existingStores !== undefined) return;
|
|
18
27
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as h,j as t}from"./main-DuFBHsus.js";import{c as Z,g as $,r as L,a as q,X as ee,b as m,B as te,f as P,R as re,C as ne,M as V,d as _,e as M,h as B,i as se,j as ae,k as oe,L as ie}from"./ProxyViewerContainer-BNehwMI0.js";const de=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],le=Z("equal",de),ce="";function j(e){if(e.length===0)return ce;let r="";for(let n=0;n<e.length;n++){const a=e[n];a!==void 0&&(typeof a=="number"?r+=`[${a}]`:n===0?r+=a:r+=`.${a}`)}return r}function ue(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function D(e){if(typeof e=="string")try{return C(JSON.parse(e))}catch{return{kind:"primitive",value:e}}return C(e)}function C(e){if(e===null)return{kind:"primitive",value:null};if(typeof e=="string")return{kind:"primitive",value:e};if(typeof e=="number")return{kind:"primitive",value:e};if(typeof e=="boolean")return{kind:"primitive",value:e};if(Array.isArray(e))return{kind:"array",value:e.map(r=>C(r))};if(ue(e)){const r={};for(const n of Object.keys(e).sort())r[n]=C(e[n]);return{kind:"object",value:r}}return{kind:"primitive",value:null}}function xe(e,r){const n=[];return R([],e,r,n),n}function R(e,r,n,a){const d=j(e);if(S(r,n)){a.push({kind:"equal",path:d,value:r});return}if(r.kind!==n.kind){a.push({kind:"changed",path:d,left:r,right:n});return}if(r.kind==="primitive"&&n.kind==="primitive"){a.push({kind:"changed",path:d,left:r,right:n});return}if(r.kind==="object"&&n.kind==="object"){const i=Object.keys(r.value),s=Object.keys(n.value),o=new Set(s);for(const l of i){const f=r.value[l];if(f!==void 0)if(!o.has(l))a.push({kind:"removed",path:j([...e,l]),value:f});else{const p=n.value[l];if(p===void 0)continue;R([...e,l],f,p,a)}}for(const l of s){if(i.includes(l))continue;const f=n.value[l];f!==void 0&&a.push({kind:"added",path:j([...e,l]),value:f})}return}if(r.kind==="array"&&n.kind==="array"){const i=Math.min(r.value.length,n.value.length);for(let s=0;s<i;s++){const o=r.value[s],l=n.value[s];o===void 0||l===void 0||R([...e,s],o,l,a)}for(let s=i;s<n.value.length;s++){const o=n.value[s];o!==void 0&&a.push({kind:"added",path:j([...e,s]),value:o})}for(let s=i;s<r.value.length;s++){const o=r.value[s];o!==void 0&&a.push({kind:"removed",path:j([...e,s]),value:o})}}}function S(e,r){if(e.kind!==r.kind)return!1;if(e.kind==="primitive"&&r.kind==="primitive")return e.value===r.value;if(e.kind==="array"&&r.kind==="array"){if(e.value.length!==r.value.length)return!1;for(let n=0;n<e.value.length;n++){const a=e.value[n],d=r.value[n];if(a===void 0||d===void 0||!S(a,d))return!1}return!0}if(e.kind==="object"&&r.kind==="object"){const n=Object.keys(e.value),a=Object.keys(r.value);if(n.length!==a.length)return!1;for(const d of n){const i=e.value[d],s=r.value[d];if(i===void 0||s===void 0||!S(i,s))return!1}return!0}return!1}function v(e,r=80){let n;switch(e.kind){case"primitive":n=e.value===null?"null":JSON.stringify(e.value);break;case"array":n=`[… ${e.value.length} items]`;break;case"object":n=`{… ${Object.keys(e.value).length} keys}`;break}return n.length>r&&(n=`${n.slice(0,r-1)}…`),n}function N(e,r=2){return JSON.stringify(E(e),null,r)}function E(e){switch(e.kind){case"primitive":return e.value;case"array":return e.value.map(E);case"object":{const r={};for(const[n,a]of Object.entries(e.value))r[n]=E(a);return r}}}function w({text:e,defaultExpandDepth:r}){return t.jsx(h.Suspense,{fallback:t.jsx("div",{className:"text-xs text-muted-foreground",children:"Loading JSON..."}),children:t.jsx(ie,{text:e,defaultExpandDepth:r})})}function K(e){if(e==="")return"";for(let r=e.length-1;r>=0;r--){const n=e[r];if(n==="."||n==="[")return e.substring(0,r)}return""}function A(e){return e.kind==="equal"&&(e.value.kind==="object"||e.value.kind==="array")}function me(e){const r=[];let n=0;for(;n<e.length;){const a=e[n];if(a!==void 0&&A(a)){const d=K(a.path);let i=n+1;for(;i<e.length;){const s=e[i];if(s===void 0||!A(s)||K(s.path)!==d)break;i++}if(i-n>1){const s=[];for(let o=n;o<i;o++){const l=e[o];l!==void 0&&l.kind==="equal"&&s.push(l)}r.push({kind:"equal-run",ops:s}),n=i;continue}}a!==void 0&&r.push({kind:"single",op:a}),n++}return r}const F={added:{icon:_,accent:"text-emerald-600 dark:text-emerald-400",bg:"bg-emerald-500/5 hover:bg-emerald-500/10",border:"border-l-emerald-500",label:"ADDED"},removed:{icon:V,accent:"text-rose-600 dark:text-rose-400",bg:"bg-rose-500/5 hover:bg-rose-500/10",border:"border-l-rose-500",label:"REMOVED"},changed:{icon:M,accent:"text-amber-600 dark:text-amber-400",bg:"bg-amber-500/5 hover:bg-amber-500/10",border:"border-l-amber-500",label:"CHANGED"},equal:{icon:le,accent:"text-muted-foreground/70",bg:"bg-muted/20 hover:bg-muted/30",border:"border-l-muted-foreground/20",label:"EQUAL"}};function fe({ops:e,expanded:r,onToggle:n}){const a=e[0],d=e[e.length-1];if(a===void 0||d===void 0)return t.jsx("div",{className:"text-muted-foreground/40 text-xs",children:"—"});const i=a.path,s=d.path,o=e.length===1?i:`${i} … ${s}`,l=a.value.kind==="array"?`${e.length} equal arrays`:a.value.kind==="object"?`${e.length} equal objects`:"equal",f=F.equal;return t.jsxs("div",{className:m("border-l-4 rounded-sm",f.border,f.bg),children:[t.jsxs("button",{type:"button",onClick:n,className:"w-full text-left flex items-center gap-2 px-3 py-1.5 text-xs text-muted-foreground cursor-pointer",children:[t.jsx(B,{className:m("size-3 transition-transform shrink-0",r&&"rotate-90")}),t.jsx(f.icon,{className:m("size-3 shrink-0",f.accent)}),t.jsx("span",{className:"font-mono truncate flex-1",title:`${i} … ${s}`,children:o}),t.jsx("span",{className:m("text-[10px] uppercase tracking-wider shrink-0",f.accent),children:f.label}),t.jsxs("span",{className:"text-muted-foreground/60 shrink-0",children:["(",l,")"]})]}),r&&t.jsx("div",{className:"ml-5 mt-1 mb-2 space-y-2 pr-2",children:e.map(p=>t.jsxs("div",{className:"border border-border/50 rounded p-2 bg-muted/20",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-1",children:p.path}),t.jsx(w,{text:N(p.value),defaultExpandDepth:0})]},p.path))})]})}function pe({op:e,idx:r,copiedPath:n,onCopyPath:a,expanded:d,onToggle:i}){const s=F[e.kind],o=s.icon,l=e.kind==="added"||e.kind==="removed"?e.value.kind==="object"||e.value.kind==="array":e.kind==="changed"?e.left.kind==="object"||e.left.kind==="array"||e.right.kind==="object"||e.right.kind==="array":!1,f=e.kind==="changed"?[{text:v(e.left,400),tone:"text-rose-700 dark:text-rose-300 line-through"},{text:v(e.right,400),tone:"text-emerald-700 dark:text-emerald-300"}]:e.kind==="removed"?[{text:v(e.value,400),tone:"text-rose-700 dark:text-rose-300 line-through"}]:e.kind==="added"?[{text:v(e.value,400),tone:"text-emerald-700 dark:text-emerald-300"}]:[{text:v(e.value,400),tone:"text-muted-foreground"}],p=n===e.path&&e.path!=="";return t.jsxs("div",{"data-diff-idx":r,"data-diff-kind":e.kind,className:m("border-l-4 rounded-sm px-3 py-2 my-0.5 transition-colors",s.border,s.bg),children:[t.jsxs("button",{type:"button",onClick:i,disabled:!l,className:m("w-full flex items-center gap-2 text-xs text-left rounded-sm",l?"cursor-pointer":"cursor-default"),"aria-expanded":l?d:void 0,"aria-label":l?d?`Collapse ${e.path||"root"}`:`Expand ${e.path||"root"}`:void 0,children:[l?t.jsx(B,{className:m("size-3 shrink-0 transition-transform",s.accent,d&&"rotate-90")}):t.jsx("span",{className:"size-3 shrink-0","aria-hidden":"true"}),t.jsx(o,{className:m("size-3.5 shrink-0",s.accent),strokeWidth:2.5}),t.jsx("span",{className:"font-mono truncate flex-1 min-w-0",title:e.path||"(root)",children:e.path===""?"(root)":e.path}),t.jsx("span",{className:m("text-[9px] font-bold uppercase tracking-wider shrink-0 px-1.5 py-0.5 rounded",s.accent,e.kind==="equal"?"bg-muted/40":"bg-background/60"),children:s.label}),e.path!==""&&t.jsx("span",{role:"button",tabIndex:0,onClick:b=>{b.stopPropagation(),a(e.path)},onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.stopPropagation(),b.preventDefault(),a(e.path))},className:m("shrink-0 p-1 rounded transition-colors cursor-pointer inline-flex items-center justify-center",p?"text-emerald-500":"text-muted-foreground/50 hover:text-foreground hover:bg-muted"),"aria-label":p?"Copied":"Copy",title:p?"Copied!":"Copy",children:p?t.jsx(se,{className:"size-3"}):t.jsx(ae,{className:"size-3"})})]}),f.map((b,y)=>t.jsx("div",{className:m("font-mono text-xs mt-1 break-all pl-5",b.tone),children:b.text},y)),t.jsx("div",{className:"overflow-hidden transition-all duration-200",style:{maxHeight:d&&l?"2000px":"0"},"aria-hidden":!d,children:d&&l&&e.kind!=="equal"?t.jsx(he,{op:e}):null})]})}function he({op:e}){if(e.kind==="added"||e.kind==="removed")return t.jsx("div",{className:"pl-5 mt-2 border border-border/50 rounded p-2 bg-muted/20",children:t.jsx(w,{text:N(e.value),defaultExpandDepth:0})});const r=e.left.kind==="object"||e.left.kind==="array",n=e.right.kind==="object"||e.right.kind==="array";return!r&&!n?t.jsx("div",{className:"pl-5 mt-2 text-xs text-muted-foreground/70 italic",children:"Primitive values are shown inline above."}):t.jsxs("div",{className:"pl-5 mt-2 grid grid-cols-1 md:grid-cols-2 gap-2",children:[t.jsxs("div",{className:"border border-rose-500/30 rounded p-2 bg-rose-500/5",children:[t.jsx("div",{className:"text-[10px] uppercase tracking-wider text-rose-500 mb-1",children:"Old"}),t.jsx(w,{text:N(e.left),defaultExpandDepth:0})]}),t.jsxs("div",{className:"border border-emerald-500/30 rounded p-2 bg-emerald-500/5",children:[t.jsx("div",{className:"text-[10px] uppercase tracking-wider text-emerald-500 mb-1",children:"New"}),t.jsx(w,{text:N(e.right),defaultExpandDepth:0})]})]})}function be({counts:e,onJumpTo:r}){const n=e.added+e.removed+e.changed;return t.jsxs("div",{className:"px-4 py-2 border-b border-border bg-muted/20 flex items-center gap-2 text-xs flex-wrap",children:[t.jsxs("span",{className:"text-muted-foreground font-medium",children:[n," ",n===1?"change":"changes"]}),t.jsxs("button",{type:"button",onClick:()=>r("removed"),disabled:e.removed===0,className:m("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.removed>0?"border-rose-500/40 text-rose-600 dark:text-rose-400 bg-rose-500/10 hover:bg-rose-500/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.removed>0?"Jump to first removed":"No removals",children:[t.jsx(V,{className:"size-3"}),e.removed," removed"]}),t.jsxs("button",{type:"button",onClick:()=>r("added"),disabled:e.added===0,className:m("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.added>0?"border-emerald-500/40 text-emerald-600 dark:text-emerald-400 bg-emerald-500/10 hover:bg-emerald-500/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.added>0?"Jump to first added":"No additions",children:[t.jsx(_,{className:"size-3"}),e.added," added"]}),t.jsxs("button",{type:"button",onClick:()=>r("changed"),disabled:e.changed===0,className:m("inline-flex items-center gap-1 px-2 py-0.5 rounded-full border cursor-pointer transition-colors",e.changed>0?"border-amber-500/40 text-amber-600 dark:text-amber-400 bg-amber-500/10 hover:bg-amber-500/20":"border-border text-muted-foreground/40 cursor-not-allowed"),title:e.changed>0?"Jump to first changed":"No changes",children:[t.jsx(M,{className:"size-3"}),e.changed," changed"]})]})}function ve({mode:e,onChange:r}){return t.jsxs("div",{className:"inline-flex rounded-md border border-border overflow-hidden",children:[t.jsxs("button",{type:"button",onClick:()=>r("unified"),"aria-pressed":e==="unified",className:m("flex items-center gap-1 px-2 py-1 text-xs transition-colors cursor-pointer",e==="unified"?"bg-muted text-foreground":"hover:bg-muted/50 text-muted-foreground"),title:"Unified view (single column, emphasized diffs)",children:[t.jsx(re,{className:"size-3"}),"Unified"]}),t.jsxs("button",{type:"button",onClick:()=>r("split"),"aria-pressed":e==="split",className:m("flex items-center gap-1 px-2 py-1 text-xs transition-colors border-l border-border cursor-pointer",e==="split"?"bg-muted text-foreground":"hover:bg-muted/50 text-muted-foreground"),title:"Split view (path | left | right)",children:[t.jsx(ne,{className:"size-3"}),"Split"]})]})}function J({log:e,side:r,displayNumber:n}){const a=q(e);return t.jsxs("div",{className:"flex-1 min-w-0 space-y-1 text-xs",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(te,{variant:"outline",className:m("text-[10px] px-1.5 py-0 h-5 font-mono shrink-0",r==="left"?"border-rose-500/40 text-rose-400":"border-emerald-500/40 text-emerald-400"),children:r==="left"?"← Left":"Right →"}),t.jsxs("span",{className:"font-mono text-blue-400/80",title:`Log ID ${String(e.id)}`,children:["#",n]}),e.model!==null&&t.jsx("span",{className:"font-mono leading-snug text-muted-foreground",children:e.model})]}),t.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground font-mono",children:[e.cacheCreationInputTokens!==null&&e.cacheCreationInputTokens>0&&t.jsxs("span",{className:"text-emerald-400",children:["KV Cache +",P(e.cacheCreationInputTokens)]}),e.cacheReadInputTokens!==null&&e.cacheReadInputTokens>0&&t.jsxs("span",{className:"text-purple-400",children:["KV Cache ~",P(e.cacheReadInputTokens)]}),t.jsx("span",{className:"truncate",title:e.timestamp,children:e.timestamp})]}),t.jsxs("div",{className:"text-muted-foreground/70 font-mono truncate",title:a,children:["session: ",a]})]})}function ye({left:e,right:r,leftDisplayNumber:n,rightDisplayNumber:a,onClose:d}){const i=h.useMemo(()=>{const c=$(L(e)).analyzeRequest(e.rawRequestBody),u=$(L(r)).analyzeRequest(r.rawRequestBody),x=D(c.comparisonValue),g=D(u.comparisonValue);return xe(x,g)},[e.apiFormat,e.path,e.rawRequestBody,r.apiFormat,r.path,r.rawRequestBody]),s=h.useMemo(()=>me(i),[i]),o=h.useMemo(()=>{let c=0,u=0,x=0;for(const g of s)if(g.kind==="single")switch(g.op.kind){case"added":c++;break;case"removed":u++;break;case"changed":x++;break}return{added:c,removed:u,changed:x}},[s]),[l,f]=h.useState(new Set),p=c=>{f(u=>{const x=new Set(u);return x.has(c)?x.delete(c):x.add(c),x})},[b,y]=h.useState(new Set),U=c=>{y(u=>{const x=new Set(u);return x.has(c)?x.delete(c):x.add(c),x})};h.useEffect(()=>{y(new Set)},[e.id,r.id]);const[T,H]=h.useState("unified"),I=h.useRef(null),[G,z]=h.useState(null),k=h.useRef(null),Q=c=>{oe(c).then(u=>{u&&(z(c),k.current!==null&&clearTimeout(k.current),k.current=setTimeout(()=>z(null),1500))})};h.useEffect(()=>()=>{k.current!==null&&clearTimeout(k.current)},[]);const W=c=>{const u=s.findIndex(O=>O.kind==="single"&&O.op.kind===c);if(u===-1)return;const x=I.current;if(x===null)return;const g=x.querySelector(`[data-diff-idx="${u}"]`);g!==null&&g.scrollIntoView({behavior:"smooth",block:"center"})};h.useEffect(()=>{const c=x=>{x.key==="Escape"&&d()};document.addEventListener("keydown",c);const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",c),document.body.style.overflow=u}},[d]);const X=q(e)===q(r),Y=i.length===1&&i[0]?.kind==="equal";return t.jsxs("div",{className:"fixed inset-0 z-50 flex justify-end",role:"dialog","aria-modal":"true","aria-label":"Compare two log requests",children:[t.jsx("button",{type:"button",onClick:d,"aria-label":"Close compare drawer",className:"absolute inset-0 bg-black/40 cursor-default",tabIndex:-1}),t.jsxs("div",{className:m("relative bg-background border-l border-border shadow-xl","w-full md:w-[70vw] max-w-[1100px] flex flex-col h-full"),onClick:c=>c.stopPropagation(),onKeyDown:c=>c.stopPropagation(),children:[t.jsxs("div",{className:"flex items-start gap-4 px-4 py-3 border-b border-border",children:[t.jsxs("div",{className:"flex-1 flex gap-4 min-w-0",children:[t.jsx(J,{log:e,side:"left",displayNumber:n}),t.jsx(J,{log:r,side:"right",displayNumber:a})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.jsx(ve,{mode:T,onChange:H}),t.jsx("button",{type:"button",onClick:d,"aria-label":"Close",className:"p-1 rounded text-muted-foreground hover:text-foreground hover:bg-muted cursor-pointer",children:t.jsx(ee,{className:"size-4"})})]})]}),!X&&t.jsx("div",{className:"px-4 py-1.5 text-xs text-amber-400 bg-amber-500/10 border-b border-border",children:"Heads up: the two selected logs are from different sessions."}),Y?t.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto flex items-center justify-center text-muted-foreground text-sm",children:"The two Request payloads are identical."}):t.jsxs(t.Fragment,{children:[t.jsx(be,{counts:o,onJumpTo:W}),t.jsx("div",{ref:I,className:"flex-1 min-h-0 overflow-y-auto",children:T==="unified"?t.jsx("div",{className:"px-3 py-2 space-y-0.5",children:s.map((c,u)=>{if(c.kind==="equal-run")return t.jsx(fe,{ops:c.ops,expanded:l.has(u),onToggle:()=>p(u)},`r${u}`);const x=c.op;return t.jsx(pe,{op:x,idx:u,copiedPath:G,onCopyPath:Q,expanded:b.has(u),onToggle:()=>U(u)},`o${u}`)})}):t.jsx(ge,{grouped:s,left:e,right:r,leftDisplayNumber:n,rightDisplayNumber:a})})]})]})]})}function ge({grouped:e,left:r,right:n,leftDisplayNumber:a,rightDisplayNumber:d}){return t.jsxs("div",{className:"grid grid-cols-[200px_1fr_1fr] gap-x-2 gap-y-0.5 px-3 py-2 text-xs",children:[t.jsxs("div",{className:"grid grid-cols-[200px_1fr_1fr] gap-x-2 col-span-3 pb-2 mb-2 border-b border-border text-[10px] uppercase tracking-wider text-muted-foreground",children:[t.jsx("span",{children:"Path"}),t.jsxs("span",{title:`Log ID ${String(r.id)}`,children:["Left (Log #",a,")"]}),t.jsxs("span",{title:`Log ID ${String(n.id)}`,children:["Right (Log #",d,")"]})]}),e.map((i,s)=>{if(i.kind==="equal-run")return t.jsxs("div",{className:"col-span-3 px-2 py-1 text-xs text-muted-foreground/60",children:[i.ops.length," equal siblings collapsed — switch to Unified to expand"]},s);const o=i.op;return o.kind==="equal"?t.jsxs("div",{className:"col-span-3 grid grid-cols-[200px_1fr_1fr] gap-x-2 px-2 py-0.5 text-muted-foreground",children:[t.jsx("span",{className:"font-mono text-xs truncate",title:o.path,children:o.path}),t.jsx("span",{className:"font-mono text-xs break-all opacity-60",children:v(o.value,200)}),t.jsx("span",{className:"font-mono text-xs break-all opacity-60",children:v(o.value,200)})]},s):o.kind==="added"?t.jsxs("div",{className:"col-span-3 px-2 py-1 rounded text-xs border-l-2 border-l-emerald-400/70 bg-emerald-500/5",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-0.5",children:o.path}),t.jsxs("div",{className:"font-mono break-all text-emerald-300/90",children:["+ ",v(o.value,400)]})]},s):o.kind==="removed"?t.jsxs("div",{className:"col-span-3 px-2 py-1 rounded text-xs border-l-2 border-l-rose-400/70 bg-rose-500/5",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-0.5",children:o.path}),t.jsxs("div",{className:"font-mono break-all text-rose-300/90 line-through",children:["− ",v(o.value,400)]})]},s):t.jsxs("div",{className:"col-span-3 px-2 py-1 rounded text-xs border-l-2 border-l-amber-400/70 bg-amber-500/5",children:[t.jsx("div",{className:"font-mono text-xs text-muted-foreground mb-1",children:o.path}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("div",{className:"font-mono text-rose-300/90 break-all line-through",children:v(o.left,400)}),t.jsx("div",{className:"font-mono text-emerald-300/90 break-all",children:v(o.right,400)})]})]},s)})]})}export{ye as CompareDrawer};
|