@tonyclaw/agent-inspector 2.0.5 → 2.0.7
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-BhRYPp6T.js +1 -0
- package/.output/public/assets/ProxyViewerContainer-BHq0dkQG.js +114 -0
- package/.output/public/assets/ReplayDialog-Ch0gwg6B.js +1 -0
- package/.output/public/assets/RequestAnatomy-CKbvIgaN.js +1 -0
- package/.output/public/assets/ResponseView-hRLar32x.js +1 -0
- package/.output/public/assets/StreamingChunkSequence-DCJ_gUHa.js +1 -0
- package/.output/public/assets/_sessionId-BJTz6t5l.js +1 -0
- package/.output/public/assets/index-Cf9U0Ekq.js +1 -0
- package/.output/public/assets/index-DTdv7nzl.css +1 -0
- package/.output/public/assets/{main-2NlGzgOe.js → main-BlDtK0Nn.js} +2 -2
- package/.output/server/_libs/lucide-react.mjs +170 -108
- package/.output/server/_libs/radix-ui__react-collapsible.mjs +2 -2
- package/.output/server/{_sessionId-DWCTasJU.mjs → _sessionId-Dy7rsLS4.mjs} +58 -5
- package/.output/server/_ssr/{CompareDrawer-DhrN1uC2.mjs → CompareDrawer-CkVX-ARV.mjs} +9 -8
- package/.output/server/_ssr/{ProxyViewerContainer-DRl51s_n.mjs → ProxyViewerContainer-B5a9p3j5.mjs} +856 -32
- package/.output/server/_ssr/{ReplayDialog-BQT_ygxC.mjs → ReplayDialog-hXY6H9fB.mjs} +7 -8
- package/.output/server/_ssr/RequestAnatomy-B6MS7VvA.mjs +576 -0
- package/.output/server/_ssr/{ResponseView-e0kL2C3x.mjs → ResponseView-ByjxwUnp.mjs} +5 -74
- package/.output/server/_ssr/{StreamingChunkSequence-BJG-m7xs.mjs → StreamingChunkSequence-C5Kb8siT.mjs} +8 -7
- package/.output/server/_ssr/{index-Dea3OeRw.mjs → index-BZXtj42m.mjs} +58 -5
- package/.output/server/_ssr/index.mjs +2 -2
- package/.output/server/_ssr/{router-Dl7oh0zx.mjs → router-CVQaVF_3.mjs} +5 -5
- package/.output/server/{_tanstack-start-manifest_v-m-FJNBVf.mjs → _tanstack-start-manifest_v-Bpe5ZC56.mjs} +1 -1
- package/.output/server/index.mjs +58 -65
- package/package.json +1 -1
- package/src/components/proxy-viewer/LogEntry.tsx +18 -4
- package/src/components/proxy-viewer/LogEntryHeader.tsx +3 -3
- package/src/components/proxy-viewer/RequestToolsPanel.tsx +292 -0
- package/src/components/proxy-viewer/anatomy/RequestAnatomy.tsx +196 -45
- package/src/components/proxy-viewer/anatomy/SegmentBar.tsx +92 -67
- package/src/components/proxy-viewer/anatomy/types.ts +15 -13
- package/src/components/proxy-viewer/log-formats/anthropic.ts +1 -1
- package/src/components/proxy-viewer/log-formats/openai.ts +1 -1
- package/src/components/proxy-viewer/log-formats/types.ts +1 -1
- package/src/components/proxy-viewer/requestTools.ts +213 -0
- package/src/components/ui/json-viewer.tsx +1 -1
- package/.output/public/assets/CompareDrawer-3nRwtk8J.js +0 -1
- package/.output/public/assets/ProxyViewerContainer-CbW5VRER.js +0 -101
- package/.output/public/assets/ReplayDialog-Cl62N9PI.js +0 -1
- package/.output/public/assets/RequestAnatomy-DgQWGvjs.js +0 -1
- package/.output/public/assets/ResponseView-Cvc-ct4E.js +0 -1
- package/.output/public/assets/StreamingChunkSequence-BCQaCAIe.js +0 -1
- package/.output/public/assets/_sessionId-CcD_aLGq.js +0 -1
- package/.output/public/assets/index-B_dffD3u.js +0 -1
- package/.output/public/assets/index-CX796gvi.css +0 -1
- package/.output/public/assets/json-viewer-IXejqXB0.js +0 -14
- package/.output/server/_ssr/RequestAnatomy-DS2tZOgq.mjs +0 -353
- package/.output/server/_ssr/json-viewer-DDU55MLK.mjs +0 -515
|
@@ -1,353 +0,0 @@
|
|
|
1
|
-
import { r as reactExports, j as jsxRuntimeExports } from "../_libs/react.mjs";
|
|
2
|
-
import { k as TooltipProvider, f as formatTokens, c as cn, l as Tooltip, m as TooltipTrigger, n as TooltipContent } from "./ProxyViewerContainer-DRl51s_n.mjs";
|
|
3
|
-
import "./router-Dl7oh0zx.mjs";
|
|
4
|
-
import "../_libs/modelcontextprotocol__server.mjs";
|
|
5
|
-
import "../_libs/jszip.mjs";
|
|
6
|
-
import { a4 as Info } from "../_libs/lucide-react.mjs";
|
|
7
|
-
import "../_libs/swr.mjs";
|
|
8
|
-
import "../_libs/use-sync-external-store.mjs";
|
|
9
|
-
import "../_libs/dequal.mjs";
|
|
10
|
-
import "../_libs/clsx.mjs";
|
|
11
|
-
import "../_libs/tailwind-merge.mjs";
|
|
12
|
-
import "../_libs/class-variance-authority.mjs";
|
|
13
|
-
import "../_libs/radix-ui__react-dialog.mjs";
|
|
14
|
-
import "../_libs/radix-ui__primitive.mjs";
|
|
15
|
-
import "../_libs/radix-ui__react-compose-refs.mjs";
|
|
16
|
-
import "../_libs/radix-ui__react-context.mjs";
|
|
17
|
-
import "../_libs/radix-ui__react-id.mjs";
|
|
18
|
-
import "../_libs/@radix-ui/react-use-layout-effect+[...].mjs";
|
|
19
|
-
import "../_libs/@radix-ui/react-use-controllable-state+[...].mjs";
|
|
20
|
-
import "../_libs/@radix-ui/react-dismissable-layer+[...].mjs";
|
|
21
|
-
import "../_libs/radix-ui__react-primitive.mjs";
|
|
22
|
-
import "../_libs/react-dom.mjs";
|
|
23
|
-
import "util";
|
|
24
|
-
import "async_hooks";
|
|
25
|
-
import "stream";
|
|
26
|
-
import "crypto";
|
|
27
|
-
import "../_libs/radix-ui__react-slot.mjs";
|
|
28
|
-
import "../_libs/@radix-ui/react-use-callback-ref+[...].mjs";
|
|
29
|
-
import "../_libs/@radix-ui/react-use-escape-keydown+[...].mjs";
|
|
30
|
-
import "../_libs/radix-ui__react-focus-scope.mjs";
|
|
31
|
-
import "../_libs/radix-ui__react-portal.mjs";
|
|
32
|
-
import "../_libs/radix-ui__react-presence.mjs";
|
|
33
|
-
import "../_libs/radix-ui__react-focus-guards.mjs";
|
|
34
|
-
import "../_libs/react-remove-scroll.mjs";
|
|
35
|
-
import "tslib";
|
|
36
|
-
import "../_libs/react-remove-scroll-bar.mjs";
|
|
37
|
-
import "../_libs/react-style-singleton.mjs";
|
|
38
|
-
import "../_libs/get-nonce.mjs";
|
|
39
|
-
import "../_libs/use-sidecar.mjs";
|
|
40
|
-
import "../_libs/use-callback-ref.mjs";
|
|
41
|
-
import "../_libs/aria-hidden.mjs";
|
|
42
|
-
import "../_libs/diff.mjs";
|
|
43
|
-
import "../_libs/tanstack__react-virtual.mjs";
|
|
44
|
-
import "../_libs/tanstack__virtual-core.mjs";
|
|
45
|
-
import "../_libs/radix-ui__react-select.mjs";
|
|
46
|
-
import "../_libs/radix-ui__number.mjs";
|
|
47
|
-
import "../_libs/radix-ui__react-collection.mjs";
|
|
48
|
-
import "../_libs/radix-ui__react-direction.mjs";
|
|
49
|
-
import "../_libs/radix-ui__react-popper.mjs";
|
|
50
|
-
import "../_libs/floating-ui__react-dom.mjs";
|
|
51
|
-
import "../_libs/floating-ui__dom.mjs";
|
|
52
|
-
import "../_libs/floating-ui__core.mjs";
|
|
53
|
-
import "../_libs/floating-ui__utils.mjs";
|
|
54
|
-
import "../_libs/radix-ui__react-arrow.mjs";
|
|
55
|
-
import "../_libs/radix-ui__react-use-size.mjs";
|
|
56
|
-
import "../_libs/radix-ui__react-use-previous.mjs";
|
|
57
|
-
import "../_libs/@radix-ui/react-visually-hidden+[...].mjs";
|
|
58
|
-
import "../_libs/zod.mjs";
|
|
59
|
-
import "../_libs/radix-ui__react-tooltip.mjs";
|
|
60
|
-
import "../_libs/radix-ui__react-tabs.mjs";
|
|
61
|
-
import "../_libs/radix-ui__react-roving-focus.mjs";
|
|
62
|
-
import "../_libs/tanstack__react-router.mjs";
|
|
63
|
-
import "../_libs/tiny-warning.mjs";
|
|
64
|
-
import "../_libs/tanstack__router-core.mjs";
|
|
65
|
-
import "../_libs/cookie-es.mjs";
|
|
66
|
-
import "../_libs/tanstack__history.mjs";
|
|
67
|
-
import "../_libs/tiny-invariant.mjs";
|
|
68
|
-
import "../_libs/seroval.mjs";
|
|
69
|
-
import "../_libs/seroval-plugins.mjs";
|
|
70
|
-
import "node:stream/web";
|
|
71
|
-
import "node:stream";
|
|
72
|
-
import "../_libs/isbot.mjs";
|
|
73
|
-
import "node:fs";
|
|
74
|
-
import "node:fs/promises";
|
|
75
|
-
import "node:buffer";
|
|
76
|
-
import "node:path";
|
|
77
|
-
import "node:child_process";
|
|
78
|
-
import "node:url";
|
|
79
|
-
import "../_libs/conf.mjs";
|
|
80
|
-
import "node:util";
|
|
81
|
-
import "node:process";
|
|
82
|
-
import "node:crypto";
|
|
83
|
-
import "node:assert";
|
|
84
|
-
import "../_libs/dot-prop.mjs";
|
|
85
|
-
import "../_libs/env-paths.mjs";
|
|
86
|
-
import "node:os";
|
|
87
|
-
import "../_libs/atomically.mjs";
|
|
88
|
-
import "../_libs/stubborn-fs.mjs";
|
|
89
|
-
import "../_libs/stubborn-utils.mjs";
|
|
90
|
-
import "../_libs/when-exit.mjs";
|
|
91
|
-
import "../_libs/ajv.mjs";
|
|
92
|
-
import "../_libs/fast-deep-equal.mjs";
|
|
93
|
-
import "../_libs/json-schema-traverse.mjs";
|
|
94
|
-
import "../_libs/fast-uri.mjs";
|
|
95
|
-
import "../_libs/ajv-formats.mjs";
|
|
96
|
-
import "../_libs/debounce-fn.mjs";
|
|
97
|
-
import "../_libs/mimic-function.mjs";
|
|
98
|
-
import "../_libs/semver.mjs";
|
|
99
|
-
import "../_libs/uint8array-extras.mjs";
|
|
100
|
-
import "node:worker_threads";
|
|
101
|
-
import "../_libs/readable-stream.mjs";
|
|
102
|
-
import "events";
|
|
103
|
-
import "node:string_decoder";
|
|
104
|
-
import "../_libs/process-nextick-args.mjs";
|
|
105
|
-
import "../_libs/isarray.mjs";
|
|
106
|
-
import "../_libs/safe-buffer.mjs";
|
|
107
|
-
import "buffer";
|
|
108
|
-
import "../_libs/core-util-is.mjs";
|
|
109
|
-
import "../_libs/inherits.mjs";
|
|
110
|
-
import "../_libs/util-deprecate.mjs";
|
|
111
|
-
import "../_libs/lie.mjs";
|
|
112
|
-
import "../_libs/immediate.mjs";
|
|
113
|
-
import "../_libs/setimmediate.mjs";
|
|
114
|
-
import "../_libs/pako.mjs";
|
|
115
|
-
const ROLE_COLOR_CLASSES = {
|
|
116
|
-
system: "bg-sky-500/70",
|
|
117
|
-
user: "bg-emerald-500/70",
|
|
118
|
-
assistant: "bg-violet-500/70",
|
|
119
|
-
tool: "bg-sky-400/55",
|
|
120
|
-
tools: "bg-slate-500/70"
|
|
121
|
-
};
|
|
122
|
-
const ROLE_FOCUS_RING = {
|
|
123
|
-
system: "focus-visible:ring-sky-300",
|
|
124
|
-
user: "focus-visible:ring-emerald-300",
|
|
125
|
-
assistant: "focus-visible:ring-violet-300",
|
|
126
|
-
tool: "focus-visible:ring-sky-300",
|
|
127
|
-
tools: "focus-visible:ring-slate-300"
|
|
128
|
-
};
|
|
129
|
-
const MAX_VISIBLE_SEGMENTS = 12;
|
|
130
|
-
const MIN_SEGMENT_PERCENT = 1;
|
|
131
|
-
const TOOLTIP_PREVIEW_LIMIT = 80;
|
|
132
|
-
const LABEL_TRUNCATE_LIMIT = 24;
|
|
133
|
-
function truncateLabel(label) {
|
|
134
|
-
if (label.length <= LABEL_TRUNCATE_LIMIT) return label;
|
|
135
|
-
return `${label.slice(0, LABEL_TRUNCATE_LIMIT - 1)}…`;
|
|
136
|
-
}
|
|
137
|
-
function truncatePreview(text) {
|
|
138
|
-
const singleLine = text.replace(/\s+/g, " ").trim();
|
|
139
|
-
if (singleLine.length <= TOOLTIP_PREVIEW_LIMIT) return singleLine;
|
|
140
|
-
return `${singleLine.slice(0, TOOLTIP_PREVIEW_LIMIT)}…`;
|
|
141
|
-
}
|
|
142
|
-
const SegmentBar = reactExports.memo(function SegmentBar2({
|
|
143
|
-
segments,
|
|
144
|
-
totalTokens,
|
|
145
|
-
onActivate
|
|
146
|
-
}) {
|
|
147
|
-
const total = reactExports.useMemo(() => {
|
|
148
|
-
if (totalTokens > 0) return totalTokens;
|
|
149
|
-
return segments.reduce((sum, s) => sum + s.size, 0);
|
|
150
|
-
}, [segments, totalTokens]);
|
|
151
|
-
const visibleSegments = segments.slice(0, MAX_VISIBLE_SEGMENTS);
|
|
152
|
-
const overflowSegments = segments.slice(MAX_VISIBLE_SEGMENTS);
|
|
153
|
-
const overflowSize = overflowSegments.reduce((sum, s) => sum + s.size, 0);
|
|
154
|
-
const overflowCount = overflowSegments.length;
|
|
155
|
-
const overflowStartIndex = MAX_VISIBLE_SEGMENTS;
|
|
156
|
-
const overflowEndIndex = overflowStartIndex + overflowCount - 1;
|
|
157
|
-
const hasOverflow = overflowCount > 0;
|
|
158
|
-
const visibleTotal = reactExports.useMemo(
|
|
159
|
-
() => visibleSegments.reduce((sum, s) => sum + s.size, 0),
|
|
160
|
-
[visibleSegments]
|
|
161
|
-
);
|
|
162
|
-
const ariaLabel = reactExports.useMemo(
|
|
163
|
-
() => `Request anatomy: ~${formatTokens(total)} tokens across ${segments.length} segment${segments.length === 1 ? "" : "s"}`,
|
|
164
|
-
[segments.length, total]
|
|
165
|
-
);
|
|
166
|
-
if (segments.length === 0 || total <= 0) {
|
|
167
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { role: "img", "aria-label": ariaLabel, className: "h-6" });
|
|
168
|
-
}
|
|
169
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipProvider, { delayDuration: 150, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { role: "img", "aria-label": ariaLabel, className: "flex flex-col gap-1.5", children: [
|
|
170
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
171
|
-
"div",
|
|
172
|
-
{
|
|
173
|
-
className: "relative flex h-6 w-full overflow-hidden rounded border border-border/40 bg-muted/30",
|
|
174
|
-
"data-testid": "anatomy-segment-bar",
|
|
175
|
-
children: [
|
|
176
|
-
visibleSegments.map((segment, index) => {
|
|
177
|
-
const rawPercent = total > 0 ? segment.size / total * 100 : 0;
|
|
178
|
-
const percent = Math.max(MIN_SEGMENT_PERCENT, rawPercent);
|
|
179
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
180
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
181
|
-
"button",
|
|
182
|
-
{
|
|
183
|
-
type: "button",
|
|
184
|
-
role: "button",
|
|
185
|
-
tabIndex: 0,
|
|
186
|
-
onClick: () => onActivate?.(segment),
|
|
187
|
-
onKeyDown: (e) => {
|
|
188
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
189
|
-
e.preventDefault();
|
|
190
|
-
onActivate?.(segment);
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
"data-anatomy-path": segment.path,
|
|
194
|
-
"aria-label": `${segment.label}, ~${formatTokens(segment.size)} tokens`,
|
|
195
|
-
className: cn(
|
|
196
|
-
"h-full border-r border-background/80 last:border-r-0",
|
|
197
|
-
"opacity-90 hover:opacity-100 focus:opacity-100",
|
|
198
|
-
"focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-background",
|
|
199
|
-
ROLE_COLOR_CLASSES[segment.role],
|
|
200
|
-
ROLE_FOCUS_RING[segment.role]
|
|
201
|
-
),
|
|
202
|
-
style: { width: `${percent}%` }
|
|
203
|
-
}
|
|
204
|
-
) }),
|
|
205
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(TooltipContent, { side: "bottom", className: "max-w-sm text-xs p-2 space-y-0.5", children: [
|
|
206
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "font-semibold", children: [
|
|
207
|
-
segment.label,
|
|
208
|
-
" · ~",
|
|
209
|
-
formatTokens(segment.size),
|
|
210
|
-
" tokens"
|
|
211
|
-
] }),
|
|
212
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-muted-foreground", children: [
|
|
213
|
-
segment.characters.toLocaleString(),
|
|
214
|
-
" chars"
|
|
215
|
-
] }),
|
|
216
|
-
segment.text.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-muted-foreground/90 break-words whitespace-pre-wrap", children: truncatePreview(segment.text) })
|
|
217
|
-
] })
|
|
218
|
-
] }, `${segment.path}-${index}`);
|
|
219
|
-
}),
|
|
220
|
-
hasOverflow && /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
221
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
222
|
-
"div",
|
|
223
|
-
{
|
|
224
|
-
role: "img",
|
|
225
|
-
"aria-label": `${overflowCount} additional segments`,
|
|
226
|
-
className: "flex h-full items-center justify-center bg-muted-foreground/30 px-1.5 text-[10px] font-mono text-background",
|
|
227
|
-
style: {
|
|
228
|
-
width: `${Math.max(MIN_SEGMENT_PERCENT, overflowSize / total * 100)}%`
|
|
229
|
-
},
|
|
230
|
-
children: [
|
|
231
|
-
"… +",
|
|
232
|
-
overflowCount
|
|
233
|
-
]
|
|
234
|
-
}
|
|
235
|
-
) }),
|
|
236
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs(TooltipContent, { side: "bottom", className: "text-xs", children: [
|
|
237
|
-
overflowCount,
|
|
238
|
-
" more segment",
|
|
239
|
-
overflowCount === 1 ? "" : "s",
|
|
240
|
-
" (indices",
|
|
241
|
-
" ",
|
|
242
|
-
overflowStartIndex,
|
|
243
|
-
"–",
|
|
244
|
-
overflowEndIndex,
|
|
245
|
-
")"
|
|
246
|
-
] })
|
|
247
|
-
] })
|
|
248
|
-
]
|
|
249
|
-
}
|
|
250
|
-
),
|
|
251
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-full gap-1 text-[10px] text-muted-foreground", children: [
|
|
252
|
-
visibleSegments.map((segment, index) => {
|
|
253
|
-
const rawPercent = total > 0 ? segment.size / total * 100 : 0;
|
|
254
|
-
const percent = Math.max(MIN_SEGMENT_PERCENT, rawPercent);
|
|
255
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
256
|
-
"div",
|
|
257
|
-
{
|
|
258
|
-
className: "flex flex-col gap-0.5 truncate",
|
|
259
|
-
style: { width: `${percent}%` },
|
|
260
|
-
title: `${segment.label} · ~${formatTokens(segment.size)} tokens`,
|
|
261
|
-
children: [
|
|
262
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate font-mono text-foreground/80", children: truncateLabel(segment.label) }),
|
|
263
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "truncate font-mono text-muted-foreground/70", children: [
|
|
264
|
-
"~",
|
|
265
|
-
formatTokens(segment.size)
|
|
266
|
-
] })
|
|
267
|
-
]
|
|
268
|
-
},
|
|
269
|
-
`label-${segment.path}-${index}`
|
|
270
|
-
);
|
|
271
|
-
}),
|
|
272
|
-
hasOverflow && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
273
|
-
"div",
|
|
274
|
-
{
|
|
275
|
-
className: "flex flex-col gap-0.5 truncate text-muted-foreground",
|
|
276
|
-
style: { width: `${Math.max(MIN_SEGMENT_PERCENT, overflowSize / total * 100)}%` },
|
|
277
|
-
children: [
|
|
278
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "truncate font-mono text-foreground/60", children: [
|
|
279
|
-
"… +",
|
|
280
|
-
overflowCount
|
|
281
|
-
] }),
|
|
282
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "truncate font-mono text-muted-foreground/60", children: [
|
|
283
|
-
"~",
|
|
284
|
-
formatTokens(overflowSize)
|
|
285
|
-
] })
|
|
286
|
-
]
|
|
287
|
-
}
|
|
288
|
-
)
|
|
289
|
-
] }),
|
|
290
|
-
visibleTotal < total * 0.1 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-0" })
|
|
291
|
-
] }) });
|
|
292
|
-
});
|
|
293
|
-
const DIVERGENCE_AMBER_THRESHOLD = 0.25;
|
|
294
|
-
function RequestAnatomy({
|
|
295
|
-
parsed,
|
|
296
|
-
inputTokens,
|
|
297
|
-
onSegmentActivate,
|
|
298
|
-
segments: providedSegments
|
|
299
|
-
}) {
|
|
300
|
-
const segments = reactExports.useMemo(() => providedSegments ?? null, [providedSegments]);
|
|
301
|
-
const total = reactExports.useMemo(() => (segments ?? []).reduce((sum, s) => sum + s.size, 0), [segments]);
|
|
302
|
-
const showDivergenceWarning = reactExports.useMemo(() => {
|
|
303
|
-
if (segments === null || segments === void 0) return false;
|
|
304
|
-
if (inputTokens === null) return false;
|
|
305
|
-
if (total === 0) return false;
|
|
306
|
-
const ratio = Math.abs(inputTokens - total) / Math.max(inputTokens, total);
|
|
307
|
-
return ratio >= DIVERGENCE_AMBER_THRESHOLD;
|
|
308
|
-
}, [inputTokens, segments, total]);
|
|
309
|
-
const summaryColorClass = reactExports.useMemo(() => {
|
|
310
|
-
if (inputTokens === null) return "text-muted-foreground";
|
|
311
|
-
if (showDivergenceWarning) return "text-amber-400";
|
|
312
|
-
return "text-muted-foreground";
|
|
313
|
-
}, [inputTokens, showDivergenceWarning]);
|
|
314
|
-
if (segments === null || segments === void 0) {
|
|
315
|
-
return null;
|
|
316
|
-
}
|
|
317
|
-
if (segments.length === 0) {
|
|
318
|
-
return null;
|
|
319
|
-
}
|
|
320
|
-
if (parsed === null && providedSegments === void 0) {
|
|
321
|
-
return null;
|
|
322
|
-
}
|
|
323
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipProvider, { delayDuration: 150, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "px-4 py-3 space-y-2", "data-testid": "anatomy-root", children: [
|
|
324
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 text-xs", children: [
|
|
325
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "font-mono tabular-nums text-foreground", children: [
|
|
326
|
-
"~",
|
|
327
|
-
formatTokens(total),
|
|
328
|
-
" tokens"
|
|
329
|
-
] }),
|
|
330
|
-
inputTokens !== null && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: cn("font-mono tabular-nums", summaryColorClass), children: [
|
|
331
|
-
"(server: ",
|
|
332
|
-
formatTokens(inputTokens),
|
|
333
|
-
")"
|
|
334
|
-
] }),
|
|
335
|
-
showDivergenceWarning && /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
336
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
337
|
-
"button",
|
|
338
|
-
{
|
|
339
|
-
type: "button",
|
|
340
|
-
className: "inline-flex items-center text-amber-400 hover:text-amber-300",
|
|
341
|
-
"aria-label": "Token estimate diverges from server",
|
|
342
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(Info, { className: "size-3.5" })
|
|
343
|
-
}
|
|
344
|
-
) }),
|
|
345
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "max-w-xs text-xs", children: "Bar uses a token estimate heuristic (~4 ASCII chars / token, ~1 CJK / emoji char per token). The server's reported value is the source of truth for cost." })
|
|
346
|
-
] })
|
|
347
|
-
] }),
|
|
348
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(SegmentBar, { segments, totalTokens: total, onActivate: onSegmentActivate })
|
|
349
|
-
] }) });
|
|
350
|
-
}
|
|
351
|
-
export {
|
|
352
|
-
RequestAnatomy
|
|
353
|
-
};
|