@tonyclaw/agent-inspector 2.1.13 → 2.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/CompareDrawer-DjgjIFx7.js +1 -0
  3. package/.output/public/assets/ProxyViewerContainer-CWUQZLYy.js +106 -0
  4. package/.output/public/assets/{ReplayDialog-sBA1KAYD.js → ReplayDialog-CU0Tbb2c.js} +1 -1
  5. package/.output/public/assets/{RequestAnatomy-BjlBT-Cy.js → RequestAnatomy-BNahe83D.js} +1 -1
  6. package/.output/public/assets/ResponseView-DSOnGqi6.js +3 -0
  7. package/.output/public/assets/{StreamingChunkSequence-D2_SMhlE.js → StreamingChunkSequence-BEKTDklB.js} +1 -1
  8. package/.output/public/assets/_sessionId-Cif8JZdn.js +1 -0
  9. package/.output/public/assets/index-DWOkqdCa.js +14 -0
  10. package/.output/public/assets/index-D_WfwzUi.js +1 -0
  11. package/.output/public/assets/index-DtLuQrs0.css +1 -0
  12. package/.output/public/assets/json-viewer-C2JpgcW0.js +1 -0
  13. package/.output/public/assets/{main-Dtspb4Ui.js → main-CSONBwwn.js} +2 -2
  14. package/.output/server/_libs/lucide-react.mjs +20 -20
  15. package/.output/server/_libs/react-markdown.mjs +90 -2
  16. package/.output/server/{_sessionId-CXDcLuvi.mjs → _sessionId-CPAa37n5.mjs} +6 -57
  17. package/.output/server/_ssr/{CompareDrawer-CMoCAoeq.mjs → CompareDrawer-ceW5VxMo.mjs} +17 -62
  18. package/.output/server/_ssr/{ProxyViewerContainer-BW2vVCBN.mjs → ProxyViewerContainer-CDfEE_w-.mjs} +872 -688
  19. package/.output/server/_ssr/{ReplayDialog-ChXL1t8H.mjs → ReplayDialog-V0s_eEbR.mjs} +8 -59
  20. package/.output/server/_ssr/{RequestAnatomy-DtKzIlfU.mjs → RequestAnatomy-f1ccwR9d.mjs} +6 -57
  21. package/.output/server/_ssr/{ResponseView-B5I8drzc.mjs → ResponseView-BIRrqG4H.mjs} +138 -60
  22. package/.output/server/_ssr/{StreamingChunkSequence-DvwjQNcO.mjs → StreamingChunkSequence-V3JFjCgX.mjs} +13 -58
  23. package/.output/server/_ssr/{index-D_ZHtRfl.mjs → index-DsykulzS.mjs} +6 -57
  24. package/.output/server/_ssr/index.mjs +2 -2
  25. package/.output/server/_ssr/json-viewer-Dcnm0Ivf.mjs +478 -0
  26. package/.output/server/_ssr/{router-DhL9Wp3N.mjs → router-4bdm6Mt2.mjs} +674 -173
  27. package/.output/server/{_tanstack-start-manifest_v-BHgoAmxZ.mjs → _tanstack-start-manifest_v-Xp4CO64V.mjs} +1 -1
  28. package/.output/server/index.mjs +76 -62
  29. package/package.json +1 -1
  30. package/src/components/ProxyViewerContainer.tsx +25 -17
  31. package/src/components/providers/ImportWizardDialog.tsx +7 -1
  32. package/src/components/providers/ProviderCard.tsx +10 -1
  33. package/src/components/providers/ProviderForm.tsx +157 -41
  34. package/src/components/providers/ProvidersPanel.tsx +5 -1
  35. package/src/components/proxy-viewer/AnswerMarkdown.tsx +8 -3
  36. package/src/components/proxy-viewer/CompareDrawer.tsx +20 -6
  37. package/src/components/proxy-viewer/ConversationGroup.tsx +11 -15
  38. package/src/components/proxy-viewer/LogEntry.tsx +31 -11
  39. package/src/components/proxy-viewer/LogEntryHeader.tsx +111 -40
  40. package/src/components/proxy-viewer/RequestToolsPanel.tsx +19 -13
  41. package/src/components/proxy-viewer/StreamingChunkSequence.tsx +9 -3
  42. package/src/components/proxy-viewer/TurnGroup.tsx +53 -7
  43. package/src/components/proxy-viewer/TurnGroupList.tsx +153 -0
  44. package/src/components/proxy-viewer/anatomy/sessionContextSummary.ts +74 -2
  45. package/src/components/proxy-viewer/formats/anthropic/ContentBlocks.tsx +13 -7
  46. package/src/components/proxy-viewer/formats/index.tsx +10 -3
  47. package/src/components/proxy-viewer/formats/openai/ResponseView.tsx +185 -17
  48. package/src/components/proxy-viewer/log-formats/openai.ts +107 -15
  49. package/src/components/proxy-viewer/logFocus.ts +15 -2
  50. package/src/components/proxy-viewer/requestTools.ts +7 -3
  51. package/src/components/proxy-viewer/viewerState.ts +72 -3
  52. package/src/components/ui/json-viewer-bulk.ts +41 -6
  53. package/src/components/ui/json-viewer.tsx +9 -8
  54. package/src/contracts/index.ts +15 -1
  55. package/src/contracts/openai.ts +94 -0
  56. package/src/lib/providerContract.ts +1 -0
  57. package/src/lib/providerModelMetadata.ts +7 -1
  58. package/src/lib/stopReason.ts +12 -0
  59. package/src/lib/upstreamUrl.ts +46 -0
  60. package/src/mcp/previewExtractor.ts +73 -3
  61. package/src/mcp/server.ts +2 -0
  62. package/src/mcp/toolHandlers.ts +2 -0
  63. package/src/proxy/constants.ts +2 -0
  64. package/src/proxy/formats/openai/handler.ts +40 -9
  65. package/src/proxy/formats/openai/index.ts +7 -0
  66. package/src/proxy/formats/openai/schemas.ts +15 -1
  67. package/src/proxy/formats/openai/stream.ts +529 -135
  68. package/src/proxy/formats/registry.ts +9 -1
  69. package/src/proxy/providerImporters.ts +45 -5
  70. package/src/proxy/providers.ts +31 -11
  71. package/src/proxy/schemas.ts +6 -0
  72. package/src/proxy/toolSchemaWarnings.ts +25 -3
  73. package/src/proxy/upstream.ts +18 -37
  74. package/src/routes/api/providers.$providerId.ts +1 -0
  75. package/src/routes/api/providers.ts +2 -0
  76. package/.output/public/assets/CompareDrawer-Cz_1vIpR.js +0 -1
  77. package/.output/public/assets/ProxyViewerContainer-7QSiluMf.js +0 -117
  78. package/.output/public/assets/ResponseView-PtEKzml9.js +0 -1
  79. package/.output/public/assets/_sessionId-DZfB4ruK.js +0 -1
  80. package/.output/public/assets/index-B-QQLbpz.js +0 -1
  81. package/.output/public/assets/index-CmtfjQPv.css +0 -1
@@ -1,6 +1,6 @@
1
- import { P as ProxyViewerContainer } from "./ProxyViewerContainer-BW2vVCBN.mjs";
1
+ import { P as ProxyViewerContainer } from "./ProxyViewerContainer-CDfEE_w-.mjs";
2
2
  import "../_libs/react.mjs";
3
- import "./router-DhL9Wp3N.mjs";
3
+ import "./router-4bdm6Mt2.mjs";
4
4
  import "../_libs/modelcontextprotocol__server.mjs";
5
5
  import "../_libs/jszip.mjs";
6
6
  import "../_libs/swr.mjs";
@@ -38,9 +38,9 @@ import "../_libs/use-sidecar.mjs";
38
38
  import "../_libs/use-callback-ref.mjs";
39
39
  import "../_libs/aria-hidden.mjs";
40
40
  import "../_libs/class-variance-authority.mjs";
41
- import "../_libs/diff.mjs";
42
41
  import "../_libs/tanstack__react-virtual.mjs";
43
42
  import "../_libs/tanstack__virtual-core.mjs";
43
+ import "../_libs/diff.mjs";
44
44
  import "../_libs/radix-ui__react-select.mjs";
45
45
  import "../_libs/radix-ui__number.mjs";
46
46
  import "../_libs/radix-ui__react-collection.mjs";
@@ -55,60 +55,6 @@ import "../_libs/radix-ui__react-use-size.mjs";
55
55
  import "../_libs/radix-ui__react-use-previous.mjs";
56
56
  import "../_libs/@radix-ui/react-visually-hidden+[...].mjs";
57
57
  import "../_libs/lucide-react.mjs";
58
- import "../_libs/react-markdown.mjs";
59
- import "../_libs/devlop.mjs";
60
- import "../_libs/unified.mjs";
61
- import "../_libs/bail.mjs";
62
- import "../_libs/extend.mjs";
63
- import "../_libs/is-plain-obj.mjs";
64
- import "../_libs/trough.mjs";
65
- import "../_libs/vfile.mjs";
66
- import "../_libs/vfile-message.mjs";
67
- import "../_libs/unist-util-stringify-position.mjs";
68
- import "node:process";
69
- import "node:path";
70
- import "node:url";
71
- import "../_libs/remark-parse.mjs";
72
- import "../_libs/mdast-util-from-markdown.mjs";
73
- import "../_libs/micromark-util-decode-numeric-character-reference+[...].mjs";
74
- import "../_libs/micromark-util-decode-string.mjs";
75
- import "../_libs/decode-named-character-reference+[...].mjs";
76
- import "../_libs/character-entities.mjs";
77
- import "../_libs/micromark-util-normalize-identifier+[...].mjs";
78
- import "../_libs/micromark.mjs";
79
- import "../_libs/micromark-util-combine-extensions+[...].mjs";
80
- import "../_libs/micromark-util-chunked.mjs";
81
- import "../_libs/micromark-factory-space.mjs";
82
- import "../_libs/micromark-util-character.mjs";
83
- import "../_libs/micromark-core-commonmark.mjs";
84
- import "../_libs/micromark-util-classify-character+[...].mjs";
85
- import "../_libs/micromark-util-resolve-all.mjs";
86
- import "../_libs/micromark-util-subtokenize.mjs";
87
- import "../_libs/micromark-factory-destination.mjs";
88
- import "../_libs/micromark-factory-label.mjs";
89
- import "../_libs/micromark-factory-title.mjs";
90
- import "../_libs/micromark-factory-whitespace.mjs";
91
- import "../_libs/micromark-util-html-tag-name.mjs";
92
- import "../_libs/mdast-util-to-string.mjs";
93
- import "../_libs/remark-rehype.mjs";
94
- import "../_libs/mdast-util-to-hast.mjs";
95
- import "../_libs/ungap__structured-clone.mjs";
96
- import "../_libs/micromark-util-sanitize-uri.mjs";
97
- import "../_libs/unist-util-position.mjs";
98
- import "../_libs/trim-lines.mjs";
99
- import "../_libs/unist-util-visit.mjs";
100
- import "../_libs/unist-util-visit-parents.mjs";
101
- import "../_libs/unist-util-is.mjs";
102
- import "../_libs/hast-util-to-jsx-runtime.mjs";
103
- import "../_libs/comma-separated-tokens.mjs";
104
- import "../_libs/property-information.mjs";
105
- import "../_libs/space-separated-tokens.mjs";
106
- import "../_libs/style-to-js.mjs";
107
- import "../_libs/style-to-object.mjs";
108
- import "../_libs/inline-style-parser.mjs";
109
- import "../_libs/hast-util-whitespace.mjs";
110
- import "../_libs/estree-util-is-identifier-name.mjs";
111
- import "../_libs/html-url-attributes.mjs";
112
58
  import "../_libs/zod.mjs";
113
59
  import "../_libs/radix-ui__react-tabs.mjs";
114
60
  import "../_libs/radix-ui__react-roving-focus.mjs";
@@ -130,10 +76,13 @@ import "node:fs";
130
76
  import "node:fs/promises";
131
77
  import "node:readline";
132
78
  import "node:buffer";
79
+ import "node:path";
133
80
  import "node:crypto";
134
81
  import "node:child_process";
82
+ import "node:url";
135
83
  import "../_libs/conf.mjs";
136
84
  import "node:util";
85
+ import "node:process";
137
86
  import "node:assert";
138
87
  import "../_libs/dot-prop.mjs";
139
88
  import "../_libs/env-paths.mjs";
@@ -198,7 +198,7 @@ function getResponse() {
198
198
  return event.res;
199
199
  }
200
200
  async function getStartManifest(matchedRoutes) {
201
- const { tsrStartManifest } = await import("../_tanstack-start-manifest_v-BHgoAmxZ.mjs");
201
+ const { tsrStartManifest } = await import("../_tanstack-start-manifest_v-Xp4CO64V.mjs");
202
202
  const startManifest = tsrStartManifest();
203
203
  const rootRoute = startManifest.routes[rootRouteId] = startManifest.routes[rootRouteId] || {};
204
204
  rootRoute.assets = rootRoute.assets || [];
@@ -776,7 +776,7 @@ let entriesPromise;
776
776
  let baseManifestPromise;
777
777
  let cachedFinalManifestPromise;
778
778
  async function loadEntries() {
779
- const routerEntry = await import("./router-DhL9Wp3N.mjs").then((n) => n.y);
779
+ const routerEntry = await import("./router-4bdm6Mt2.mjs").then((n) => n.E);
780
780
  const startEntry = await import("./start-HYkvq4Ni.mjs");
781
781
  return { startEntry, routerEntry };
782
782
  }
@@ -0,0 +1,478 @@
1
+ import { r as reactExports, j as jsxRuntimeExports } from "../_libs/react.mjs";
2
+ import { G as parseJsonText, c as cn, m as TooltipProvider, n as Tooltip, o as TooltipTrigger, p as TooltipContent, b as copyTextToClipboard } from "./ProxyViewerContainer-CDfEE_w-.mjs";
3
+ import "./router-4bdm6Mt2.mjs";
4
+ import "../_libs/modelcontextprotocol__server.mjs";
5
+ import "../_libs/jszip.mjs";
6
+ import { a as Check, c as Copy, C as ChevronDown, f as ChevronRight, a7 as ChevronsDown } 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/radix-ui__react-dialog.mjs";
13
+ import "../_libs/radix-ui__primitive.mjs";
14
+ import "../_libs/radix-ui__react-compose-refs.mjs";
15
+ import "../_libs/radix-ui__react-context.mjs";
16
+ import "../_libs/radix-ui__react-id.mjs";
17
+ import "../_libs/@radix-ui/react-use-layout-effect+[...].mjs";
18
+ import "../_libs/@radix-ui/react-use-controllable-state+[...].mjs";
19
+ import "../_libs/@radix-ui/react-dismissable-layer+[...].mjs";
20
+ import "../_libs/radix-ui__react-primitive.mjs";
21
+ import "../_libs/react-dom.mjs";
22
+ import "util";
23
+ import "async_hooks";
24
+ import "stream";
25
+ import "crypto";
26
+ import "../_libs/radix-ui__react-slot.mjs";
27
+ import "../_libs/@radix-ui/react-use-callback-ref+[...].mjs";
28
+ import "../_libs/@radix-ui/react-use-escape-keydown+[...].mjs";
29
+ import "../_libs/radix-ui__react-focus-scope.mjs";
30
+ import "../_libs/radix-ui__react-portal.mjs";
31
+ import "../_libs/radix-ui__react-presence.mjs";
32
+ import "../_libs/radix-ui__react-focus-guards.mjs";
33
+ import "../_libs/react-remove-scroll.mjs";
34
+ import "tslib";
35
+ import "../_libs/react-remove-scroll-bar.mjs";
36
+ import "../_libs/react-style-singleton.mjs";
37
+ import "../_libs/get-nonce.mjs";
38
+ import "../_libs/use-sidecar.mjs";
39
+ import "../_libs/use-callback-ref.mjs";
40
+ import "../_libs/aria-hidden.mjs";
41
+ import "../_libs/class-variance-authority.mjs";
42
+ import "../_libs/tanstack__react-virtual.mjs";
43
+ import "../_libs/tanstack__virtual-core.mjs";
44
+ import "../_libs/diff.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-tabs.mjs";
60
+ import "../_libs/radix-ui__react-roving-focus.mjs";
61
+ import "../_libs/radix-ui__react-tooltip.mjs";
62
+ import "../_libs/radix-ui__react-collapsible.mjs";
63
+ import "../_libs/radix-ui__react-scroll-area.mjs";
64
+ import "../_libs/tanstack__react-router.mjs";
65
+ import "../_libs/tiny-warning.mjs";
66
+ import "../_libs/tanstack__router-core.mjs";
67
+ import "../_libs/cookie-es.mjs";
68
+ import "../_libs/seroval.mjs";
69
+ import "../_libs/seroval-plugins.mjs";
70
+ import "../_libs/tanstack__history.mjs";
71
+ import "../_libs/tiny-invariant.mjs";
72
+ import "node:stream/web";
73
+ import "node:stream";
74
+ import "../_libs/isbot.mjs";
75
+ import "node:fs";
76
+ import "node:fs/promises";
77
+ import "node:readline";
78
+ import "node:buffer";
79
+ import "node:path";
80
+ import "node:crypto";
81
+ import "node:child_process";
82
+ import "node:url";
83
+ import "../_libs/conf.mjs";
84
+ import "node:util";
85
+ import "node:process";
86
+ import "node:assert";
87
+ import "../_libs/dot-prop.mjs";
88
+ import "../_libs/env-paths.mjs";
89
+ import "node:os";
90
+ import "../_libs/atomically.mjs";
91
+ import "../_libs/stubborn-fs.mjs";
92
+ import "../_libs/stubborn-utils.mjs";
93
+ import "../_libs/when-exit.mjs";
94
+ import "../_libs/ajv.mjs";
95
+ import "../_libs/fast-deep-equal.mjs";
96
+ import "../_libs/json-schema-traverse.mjs";
97
+ import "../_libs/fast-uri.mjs";
98
+ import "../_libs/ajv-formats.mjs";
99
+ import "../_libs/debounce-fn.mjs";
100
+ import "../_libs/mimic-function.mjs";
101
+ import "../_libs/semver.mjs";
102
+ import "../_libs/uint8array-extras.mjs";
103
+ import "node:worker_threads";
104
+ import "../_libs/readable-stream.mjs";
105
+ import "events";
106
+ import "node:string_decoder";
107
+ import "../_libs/process-nextick-args.mjs";
108
+ import "../_libs/isarray.mjs";
109
+ import "../_libs/safe-buffer.mjs";
110
+ import "buffer";
111
+ import "../_libs/core-util-is.mjs";
112
+ import "../_libs/inherits.mjs";
113
+ import "../_libs/util-deprecate.mjs";
114
+ import "../_libs/lie.mjs";
115
+ import "../_libs/immediate.mjs";
116
+ import "../_libs/setimmediate.mjs";
117
+ import "../_libs/pako.mjs";
118
+ function classifyValue(value) {
119
+ if (value === null) return "null";
120
+ if (Array.isArray(value)) return "array";
121
+ switch (typeof value) {
122
+ case "string":
123
+ return "string";
124
+ case "number":
125
+ return "number";
126
+ case "boolean":
127
+ return "boolean";
128
+ case "object":
129
+ return "object";
130
+ case "bigint":
131
+ case "symbol":
132
+ case "undefined":
133
+ case "function":
134
+ return "object";
135
+ }
136
+ }
137
+ function isExpandable(value) {
138
+ return value !== null && (Array.isArray(value) || typeof value === "object");
139
+ }
140
+ function getEntries(value) {
141
+ if (Array.isArray(value)) {
142
+ return value.map((item, index) => [String(index), item]);
143
+ }
144
+ if (typeof value === "object" && value !== null) {
145
+ return Object.entries(value);
146
+ }
147
+ return [];
148
+ }
149
+ const STRING_TRUNCATE_LIMIT = 120;
150
+ function JsonStringText({ text }) {
151
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "whitespace-pre-wrap break-words", children: text });
152
+ }
153
+ function StringValue({ text }) {
154
+ const [expanded, setExpanded] = reactExports.useState(false);
155
+ const isLong = text.length > STRING_TRUNCATE_LIMIT;
156
+ if (!isLong) {
157
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-emerald-400 break-all", children: [
158
+ '"',
159
+ /* @__PURE__ */ jsxRuntimeExports.jsx(JsonStringText, { text }),
160
+ '"'
161
+ ] });
162
+ }
163
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-emerald-400 break-all", children: [
164
+ '"',
165
+ expanded ? /* @__PURE__ */ jsxRuntimeExports.jsx(
166
+ "span",
167
+ {
168
+ className: "cursor-pointer",
169
+ onClick: (e) => {
170
+ e.stopPropagation();
171
+ setExpanded(false);
172
+ },
173
+ onKeyDown: (e) => {
174
+ if (e.key === "Enter" || e.key === " ") {
175
+ e.stopPropagation();
176
+ setExpanded(false);
177
+ }
178
+ },
179
+ role: "button",
180
+ tabIndex: 0,
181
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(JsonStringText, { text })
182
+ }
183
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { delayDuration: 300, children: [
184
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
185
+ TooltipTrigger,
186
+ {
187
+ onClick: (e) => {
188
+ e.stopPropagation();
189
+ setExpanded(true);
190
+ },
191
+ className: "text-left cursor-pointer",
192
+ children: [
193
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: text.slice(0, STRING_TRUNCATE_LIMIT) }),
194
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-emerald-400/50", children: "..." })
195
+ ]
196
+ }
197
+ ),
198
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
199
+ TooltipContent,
200
+ {
201
+ side: "bottom",
202
+ className: "max-w-md text-xs p-2 break-words whitespace-pre-wrap",
203
+ children: [
204
+ text.slice(0, 500),
205
+ text.length > 500 ? "..." : ""
206
+ ]
207
+ }
208
+ )
209
+ ] }),
210
+ '"'
211
+ ] });
212
+ }
213
+ function PrimitiveValue({ value }) {
214
+ if (value === null) {
215
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-rose-400 italic", children: "null" });
216
+ }
217
+ switch (typeof value) {
218
+ case "string":
219
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(StringValue, { text: value });
220
+ case "number":
221
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-amber-400", children: value });
222
+ case "boolean":
223
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-blue-400", children: value ? "true" : "false" });
224
+ case "object":
225
+ case "bigint":
226
+ case "symbol":
227
+ case "undefined":
228
+ case "function":
229
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-muted-foreground", children: JSON.stringify(value) });
230
+ }
231
+ }
232
+ function CopyValueButton({ value }) {
233
+ const [copied, setCopied] = reactExports.useState(false);
234
+ function handleCopy(e) {
235
+ e.stopPropagation();
236
+ void copyTextToClipboard(JSON.stringify(value, null, 2)).then((success) => {
237
+ if (!success) return;
238
+ setCopied(true);
239
+ setTimeout(() => {
240
+ setCopied(false);
241
+ }, 2e3);
242
+ });
243
+ }
244
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
245
+ "button",
246
+ {
247
+ type: "button",
248
+ onClick: handleCopy,
249
+ className: "inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors",
250
+ "aria-label": copied ? "Copied JSON" : "Copy JSON",
251
+ title: "Copy JSON",
252
+ children: copied ? /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "size-3 text-green-500" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Copy, { className: "size-3" })
253
+ }
254
+ );
255
+ }
256
+ function CopyButton({ value }) {
257
+ const [copied, setCopied] = reactExports.useState(false);
258
+ function handleCopy(e) {
259
+ e.stopPropagation();
260
+ void copyTextToClipboard(JSON.stringify(value, null, 2)).then((success) => {
261
+ if (!success) return;
262
+ setCopied(true);
263
+ setTimeout(() => {
264
+ setCopied(false);
265
+ }, 2e3);
266
+ });
267
+ }
268
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
269
+ "button",
270
+ {
271
+ type: "button",
272
+ onClick: handleCopy,
273
+ className: "opacity-0 group-hover/row:opacity-100 hover:bg-muted p-0.5 rounded transition-opacity shrink-0",
274
+ "aria-label": copied ? "Copied JSON value" : "Copy JSON value",
275
+ title: "Copy to clipboard",
276
+ children: copied ? /* @__PURE__ */ jsxRuntimeExports.jsx(Check, { className: "size-3 text-green-500" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Copy, { className: "size-3 text-muted-foreground" })
277
+ }
278
+ );
279
+ }
280
+ function ExpandCollapseButton({
281
+ onClick
282
+ }) {
283
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
284
+ "button",
285
+ {
286
+ type: "button",
287
+ onClick,
288
+ className: "opacity-0 group-hover/row:opacity-100 hover:bg-muted p-0.5 rounded transition-opacity shrink-0",
289
+ title: "Expand all descendants",
290
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronsDown, { className: "size-3.5 text-muted-foreground" })
291
+ }
292
+ );
293
+ }
294
+ const JsonNode = reactExports.memo(function JsonNode2({
295
+ name,
296
+ value,
297
+ level,
298
+ defaultExpandDepth,
299
+ isArrayItem,
300
+ path,
301
+ expandTargetPath,
302
+ anatomyPaths
303
+ }) {
304
+ const isAncestorOfTarget = reactExports.useMemo(() => {
305
+ if (expandTargetPath === null) return false;
306
+ if (path === "") return expandTargetPath.length > 0;
307
+ return expandTargetPath === path || expandTargetPath.startsWith(`${path}/`);
308
+ }, [expandTargetPath, path]);
309
+ const initialExpanded = level < defaultExpandDepth || isAncestorOfTarget && isExpandable(value);
310
+ const [expanded, setExpanded] = reactExports.useState(initialExpanded);
311
+ reactExports.useEffect(() => {
312
+ if (isAncestorOfTarget && isExpandable(value) && !expanded) {
313
+ setExpanded(true);
314
+ }
315
+ }, [expandTargetPath]);
316
+ const [childResetKey, setChildResetKey] = reactExports.useState(0);
317
+ const [childDepthOverride, setChildDepthOverride] = reactExports.useState(null);
318
+ const expandable = isExpandable(value);
319
+ const fullyExpanded = childDepthOverride === Number.POSITIVE_INFINITY;
320
+ const entries = reactExports.useMemo(() => getEntries(value), [value]);
321
+ const hasExpandableChild = reactExports.useMemo(
322
+ () => entries.some(([, child]) => isExpandable(child)),
323
+ [entries]
324
+ );
325
+ const dataType = classifyValue(value);
326
+ const openBracket = dataType === "array" ? "[" : "{";
327
+ const closeBracket = dataType === "array" ? "]" : "}";
328
+ const hasAnatomyPath = anatomyPaths !== null && anatomyPaths.has(path);
329
+ function expandAllDeep() {
330
+ setExpanded(true);
331
+ setChildDepthOverride(Number.POSITIVE_INFINITY);
332
+ setChildResetKey((k) => k + 1);
333
+ }
334
+ function collapseToDefault() {
335
+ setExpanded(false);
336
+ setChildDepthOverride(0);
337
+ setChildResetKey((k) => k + 1);
338
+ }
339
+ function handleRowToggle() {
340
+ if (fullyExpanded) {
341
+ collapseToDefault();
342
+ } else {
343
+ setExpanded(!expanded);
344
+ }
345
+ }
346
+ function handleExpandAll(e) {
347
+ e.stopPropagation();
348
+ expandAllDeep();
349
+ }
350
+ const effectiveChildDepth = childDepthOverride ?? defaultExpandDepth;
351
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn(level > 0 && "border-l border-border/50 ml-2"), children: [
352
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
353
+ "div",
354
+ {
355
+ className: cn(
356
+ "flex items-start gap-1 py-0.5 px-1 -ml-1 rounded-sm group/row",
357
+ expandable && "cursor-pointer hover:bg-muted/50"
358
+ ),
359
+ "data-anatomy-path": hasAnatomyPath ? path : void 0,
360
+ onClick: expandable ? handleRowToggle : void 0,
361
+ onKeyDown: expandable ? (e) => {
362
+ if (e.key === "Enter" || e.key === " ") {
363
+ e.preventDefault();
364
+ handleRowToggle();
365
+ }
366
+ } : void 0,
367
+ onDoubleClick: expandable && hasExpandableChild ? () => expandAllDeep() : void 0,
368
+ role: expandable ? "button" : void 0,
369
+ tabIndex: expandable ? 0 : void 0,
370
+ children: [
371
+ expandable ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "w-4 h-5 flex items-center justify-center shrink-0", children: expanded ? /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "size-3 text-muted-foreground" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "size-3 text-muted-foreground" }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "w-4 shrink-0" }),
372
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: cn("shrink-0", isArrayItem ? "text-muted-foreground" : "text-cyan-400"), children: isArrayItem ? name : `"${name}"` }),
373
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-muted-foreground shrink-0", children: expandable ? "" : ":" }),
374
+ expandable ? /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-muted-foreground", children: [
375
+ openBracket,
376
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "text-muted-foreground/60 text-xs", children: [
377
+ " ",
378
+ entries.length,
379
+ " ",
380
+ entries.length === 1 ? "item" : "items",
381
+ " ",
382
+ closeBracket
383
+ ] })
384
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "min-w-0", children: /* @__PURE__ */ jsxRuntimeExports.jsx(PrimitiveValue, { value }) }),
385
+ expandable && hasExpandableChild && !fullyExpanded && /* @__PURE__ */ jsxRuntimeExports.jsx(ExpandCollapseButton, { onClick: handleExpandAll }),
386
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CopyButton, { value })
387
+ ]
388
+ }
389
+ ),
390
+ expandable && expanded && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "pl-4", children: [
391
+ entries.map(([key, childValue]) => /* @__PURE__ */ jsxRuntimeExports.jsx(
392
+ JsonNode2,
393
+ {
394
+ name: key,
395
+ value: childValue,
396
+ level: level + 1,
397
+ defaultExpandDepth: effectiveChildDepth,
398
+ isArrayItem: dataType === "array",
399
+ path: path === "" ? `/${key}` : `${path}/${key}`,
400
+ expandTargetPath,
401
+ anatomyPaths
402
+ },
403
+ key
404
+ )),
405
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-muted-foreground py-0.5 px-1", children: closeBracket })
406
+ ] }, childResetKey)
407
+ ] });
408
+ });
409
+ function JsonViewer({
410
+ data,
411
+ defaultExpandDepth = 0,
412
+ className,
413
+ showCopy = false,
414
+ bulkDepth: controlledBulkDepth,
415
+ bulkRevision: controlledBulkRevision,
416
+ anatomyPaths = null,
417
+ expandToPath = null
418
+ }) {
419
+ const expandable = isExpandable(data);
420
+ const entries = reactExports.useMemo(() => getEntries(data), [data]);
421
+ const bulkDepth = controlledBulkDepth ?? defaultExpandDepth;
422
+ const bulkRevision = controlledBulkRevision ?? 0;
423
+ if (!expandable) {
424
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: cn("font-mono text-xs leading-relaxed", className), children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1", children: [
425
+ /* @__PURE__ */ jsxRuntimeExports.jsx(PrimitiveValue, { value: data }),
426
+ showCopy && /* @__PURE__ */ jsxRuntimeExports.jsx(CopyValueButton, { value: data })
427
+ ] }) }) });
428
+ }
429
+ const dataType = classifyValue(data);
430
+ const isArray = dataType === "array";
431
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("font-mono text-xs leading-relaxed", className), children: [
432
+ showCopy && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-2 flex items-center justify-end gap-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyValueButton, { value: data }) }),
433
+ entries.length === 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-md border border-white/10 bg-black/20 px-3 py-2 text-muted-foreground", children: [
434
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-cyan-300", children: isArray ? "[]" : "{}" }),
435
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ml-2 text-[10px] uppercase", children: "0 items" })
436
+ ] }),
437
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: entries.map(([key, childValue]) => /* @__PURE__ */ jsxRuntimeExports.jsx(
438
+ JsonNode,
439
+ {
440
+ name: key,
441
+ value: childValue,
442
+ level: 0,
443
+ defaultExpandDepth: bulkDepth,
444
+ isArrayItem: isArray,
445
+ path: `/${key}`,
446
+ expandTargetPath: expandToPath,
447
+ anatomyPaths
448
+ },
449
+ key
450
+ )) }, bulkRevision)
451
+ ] }) });
452
+ }
453
+ const JsonViewerFromString = reactExports.memo(function JsonViewerFromString2({
454
+ text,
455
+ defaultExpandDepth = 0,
456
+ className,
457
+ bulkDepth,
458
+ bulkRevision
459
+ }) {
460
+ const parsed = reactExports.useMemo(() => parseJsonText(text), [text]);
461
+ if (parsed.kind === "json") {
462
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
463
+ JsonViewer,
464
+ {
465
+ data: parsed.data,
466
+ defaultExpandDepth,
467
+ className,
468
+ bulkDepth,
469
+ bulkRevision
470
+ }
471
+ );
472
+ }
473
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { className: cn("font-mono text-xs whitespace-pre-wrap break-words", className), children: text });
474
+ });
475
+ export {
476
+ JsonViewer,
477
+ JsonViewerFromString
478
+ };