@mcp-use/inspector 20.0.0-beta.13 → 20.0.0-beta.15

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 (145) hide show
  1. package/README.md +4 -4
  2. package/dist/cdn/inspector.js +76858 -9272
  3. package/dist/cli.js +69 -24
  4. package/dist/server/asset-urls.d.ts +1 -4
  5. package/dist/server/asset-urls.d.ts.map +1 -1
  6. package/dist/server/asset-urls.js +3 -7
  7. package/dist/server/cdn-shell.d.ts.map +1 -1
  8. package/dist/server/cdn-shell.js +3 -3
  9. package/dist/server/{chunk-H6ZCIKBS.js → chunk-JZT7N2BJ.js} +10 -15
  10. package/dist/server/{chunk-YAYRN4DW.js → chunk-WNQGHIZ3.js} +61 -15
  11. package/dist/server/{chunk-QQP554HG.js → chunk-XKCUJ6ZJ.js} +1 -1
  12. package/dist/server/{chunk-2XQWLYOZ.js → chunk-ZPGABKXL.js} +1 -1
  13. package/dist/server/cli.js +3 -3
  14. package/dist/server/index.js +4 -4
  15. package/dist/server/middleware.js +4 -4
  16. package/dist/server/version.js +1 -1
  17. package/dist/web/assets/index-Bqfsh_Rp.js +643 -0
  18. package/dist/web/index.html +2 -10
  19. package/package.json +2 -2
  20. package/dist/cdn/AnimatePresence-D1bZ5_-l.js +0 -394
  21. package/dist/cdn/ChatTab-CokP5UlL.js +0 -6811
  22. package/dist/cdn/CheckboxIndicator-BjF73mGX.js +0 -252
  23. package/dist/cdn/ConnectionSettingsForm-CXCKdMZh.js +0 -929
  24. package/dist/cdn/ConnectionSettingsTab-Ag4WD55h.js +0 -151
  25. package/dist/cdn/ElicitationTab-PEmEDvC5.js +0 -655
  26. package/dist/cdn/FormContext-NtUiZclE.js +0 -135
  27. package/dist/cdn/InspectorContext-BBKCdfmK.js +0 -123
  28. package/dist/cdn/JSONDisplay-BJqMz7Ny.js +0 -324
  29. package/dist/cdn/ListTabHeader-DzmTtN1e.js +0 -89
  30. package/dist/cdn/MCPAppsDebugControls-C01DPDJv.js +0 -2174
  31. package/dist/cdn/ManufactOAuthCallback-ChbbjFIT.js +0 -31
  32. package/dist/cdn/MarkdownRenderer-CrG5JHAZ.js +0 -3610
  33. package/dist/cdn/McpAppsViewPanel-07_iHrne.js +0 -56
  34. package/dist/cdn/NotificationsTab-B7uebqMV.js +0 -290
  35. package/dist/cdn/OAuthCallback-Cku-R2uM.js +0 -58
  36. package/dist/cdn/PromptsTab-98ugje_q.js +0 -902
  37. package/dist/cdn/ResourcesTab-CxHilZjd.js +0 -566
  38. package/dist/cdn/SamplingTab-gOUjg7bt.js +0 -659
  39. package/dist/cdn/ServerMetadataTab-BM3VhSLf.js +0 -244
  40. package/dist/cdn/StatusIcon-Q3n3YRtE.js +0 -65
  41. package/dist/cdn/ToolsTab-Dm6n5OxE.js +0 -2045
  42. package/dist/cdn/ViewPreview-CCKWd8Qt.js +0 -238
  43. package/dist/cdn/WidgetDebugContext-B6yoOVVV.js +0 -314
  44. package/dist/cdn/WidgetWrapper-BlbQAh_X.js +0 -12
  45. package/dist/cdn/basePath-B8HuhIMu.js +0 -25
  46. package/dist/cdn/bell-GrTZcnD2.js +0 -10
  47. package/dist/cdn/browser-DG2Z8392.js +0 -42
  48. package/dist/cdn/brush-CelVvMGp.js +0 -17
  49. package/dist/cdn/button-CB4uOoUV.js +0 -2509
  50. package/dist/cdn/card-BA-DQk-G.js +0 -41
  51. package/dist/cdn/cfWorker-Bxcs9rNe.js +0 -10799
  52. package/dist/cdn/checkbox-kwVa4gRX.js +0 -20
  53. package/dist/cdn/chunk-QUQL4437-XnDcYQEx.js +0 -1508
  54. package/dist/cdn/clock-YMF8Gtw5.js +0 -12
  55. package/dist/cdn/code-C8sN2OGR.js +0 -10
  56. package/dist/cdn/createLucideIcon-BONxC1L5.js +0 -213
  57. package/dist/cdn/dialog-CJGnC5Ag.js +0 -1028
  58. package/dist/cdn/dist-C-AJLM5q.js +0 -2307
  59. package/dist/cdn/dist-CTJnCYmk.js +0 -616
  60. package/dist/cdn/external-link-Bo4lQxr1.js +0 -17
  61. package/dist/cdn/eye-pSGG7nvf.js +0 -29
  62. package/dist/cdn/folder-open-aM8CPtBO.js +0 -7
  63. package/dist/cdn/hash-DDs2vE1k.js +0 -33
  64. package/dist/cdn/history-BfUFpL1d.js +0 -17
  65. package/dist/cdn/index-browser-CCygKh3z.js +0 -1853
  66. package/dist/cdn/info-BMkB68mB.js +0 -19
  67. package/dist/cdn/input-BCpgLXU1.js +0 -9654
  68. package/dist/cdn/inspector-settings-layout-0VDsjeqb.js +0 -4
  69. package/dist/cdn/label-A0UGV8FE.js +0 -60
  70. package/dist/cdn/loader-circle-BKRHJEB7.js +0 -7
  71. package/dist/cdn/manufact-auth-BQMHhbLV.js +0 -423
  72. package/dist/cdn/maximize-2-DdrB_spi.js +0 -21
  73. package/dist/cdn/maximize-hSOCz133.js +0 -21
  74. package/dist/cdn/message-square-D3tKB3uJ.js +0 -7
  75. package/dist/cdn/not-found-BajFyZpp.js +0 -32
  76. package/dist/cdn/play-B1leulYf.js +0 -7
  77. package/dist/cdn/providerMeta-CjGU4rID.js +0 -436
  78. package/dist/cdn/react-BIs9pQ3H.js +0 -926
  79. package/dist/cdn/react-BiVEwoxA.js +0 -5421
  80. package/dist/cdn/refresh-cw-CyvXrS91.js +0 -21
  81. package/dist/cdn/save-CmdEPUAm.js +0 -34
  82. package/dist/cdn/schemaHelpers-DTV38jGq.js +0 -16
  83. package/dist/cdn/select-CCFHjOGk.js +0 -2595
  84. package/dist/cdn/servers-Dd0Vcp81.js +0 -30
  85. package/dist/cdn/shared-CJVHJhag.js +0 -1700
  86. package/dist/cdn/sheet-oyq1mIyg.js +0 -2078
  87. package/dist/cdn/sparkles-CxeZpVtX.js +0 -23
  88. package/dist/cdn/spinner-Be1GlSGX.js +0 -15
  89. package/dist/cdn/square-check-big-C_4wbfwF.js +0 -10
  90. package/dist/cdn/switch-DHXEA_N5.js +0 -665
  91. package/dist/cdn/tabs-subtle-Dubd6Kj8.js +0 -788
  92. package/dist/cdn/telemetry-DyrOzsAR.js +0 -208
  93. package/dist/cdn/textarea-CwmI8_uI.js +0 -14
  94. package/dist/cdn/trash-2-BhumJAFE.js +0 -25
  95. package/dist/cdn/useAriaLabelledBy-Cra6w3YY.js +0 -30
  96. package/dist/cdn/useCompositeItem-Dhnm-7el.js +0 -26
  97. package/dist/cdn/useConfig-BTDwEhra.js +0 -235
  98. package/dist/cdn/useSavedRequests-mSIsDd4c.js +0 -51
  99. package/dist/cdn/useViewHostProps-C5NRGTzJ.js +0 -364
  100. package/dist/cdn/wrench-DvK20LUT.js +0 -7
  101. package/dist/cdn/x-EilKPiCX.js +0 -10
  102. package/dist/cdn/zap-0Wr9QO7N.js +0 -10
  103. package/dist/web/assets/AnimatePresence-FfDQQNFJ.js +0 -9
  104. package/dist/web/assets/ChatTab-BEfFVccY.js +0 -18
  105. package/dist/web/assets/ConnectionSettingsTab-Bb_6a0Iv.js +0 -1
  106. package/dist/web/assets/ElicitationTab-BP4GKiyX.js +0 -1
  107. package/dist/web/assets/FormContext-sV-yByKz.js +0 -1
  108. package/dist/web/assets/ListTabHeader-CrGae306.js +0 -1
  109. package/dist/web/assets/MCPAppsDebugControls-BIyFdqol.js +0 -34
  110. package/dist/web/assets/ManufactOAuthCallback-C7FmBqhm.js +0 -1
  111. package/dist/web/assets/MarkdownRenderer-Dh79xxF3.js +0 -47
  112. package/dist/web/assets/McpAppsViewPanel-eC3j1-Vq.js +0 -1
  113. package/dist/web/assets/NotificationsTab-BiZcGnsE.js +0 -1
  114. package/dist/web/assets/OAuthCallback-0QMKMr_h.js +0 -1
  115. package/dist/web/assets/PromptsTab-DP25ApgP.js +0 -15
  116. package/dist/web/assets/ResourcesTab-CptaN3NT.js +0 -2
  117. package/dist/web/assets/SamplingTab-BcdnfiwQ.js +0 -1
  118. package/dist/web/assets/ServerMetadataTab-DfM-a-Kp.js +0 -1
  119. package/dist/web/assets/ToolsTab-hSGwy5-P.js +0 -8
  120. package/dist/web/assets/ViewPreview-r5Me72Dm.js +0 -1
  121. package/dist/web/assets/WidgetWrapper-cv_BM1bY.js +0 -1
  122. package/dist/web/assets/brush-DX0UZ_pI.js +0 -1
  123. package/dist/web/assets/button-C8Xa2k4x.js +0 -1
  124. package/dist/web/assets/checkbox-CiCqaf9B.js +0 -1
  125. package/dist/web/assets/code-B14rVdNt.js +0 -1
  126. package/dist/web/assets/createLucideIcon-BEHeJH0M.js +0 -1
  127. package/dist/web/assets/dist-igO5zKmw.js +0 -21
  128. package/dist/web/assets/index-lCF-0iyi.js +0 -499
  129. package/dist/web/assets/input-C0OQCUZy.js +0 -1
  130. package/dist/web/assets/inspector-settings-layout-yjKRJDai.js +0 -1
  131. package/dist/web/assets/label-CI7JWQOo.js +0 -1
  132. package/dist/web/assets/maximize-2-Br1WQzT2.js +0 -1
  133. package/dist/web/assets/maximize-CJNgRe6S.js +0 -1
  134. package/dist/web/assets/react-CU_d2d5K.js +0 -1
  135. package/dist/web/assets/refresh-cw-B5iaAZKn.js +0 -1
  136. package/dist/web/assets/save-TM6fvNrt.js +0 -1
  137. package/dist/web/assets/schemaHelpers-DLNTQr_6.js +0 -1
  138. package/dist/web/assets/select-D6jzbLJn.js +0 -1
  139. package/dist/web/assets/shared-ChslWC1c.js +0 -1
  140. package/dist/web/assets/sparkles-BGYTDThM.js +0 -1
  141. package/dist/web/assets/tabs-subtle-BqKfSXAk.js +0 -1
  142. package/dist/web/assets/textarea-CRTXuRmE.js +0 -1
  143. package/dist/web/assets/useConfig-BoaEj10z.js +0 -1
  144. package/dist/web/assets/useViewHostProps-BUcH84Z-.js +0 -1
  145. package/dist/web/assets/zap-BDWHCVHU.js +0 -1
@@ -1,2045 +0,0 @@
1
- import { s as e, t } from "./react-BIs9pQ3H.js";
2
- import { a as n, f as r, n as i, r as a, sr as o, t as s } from "./input-BCpgLXU1.js";
3
- import { n as c, t as l } from "./createLucideIcon-BONxC1L5.js";
4
- import { U as u, i as d, n as f, t as p } from "./button-CB4uOoUV.js";
5
- import { t as m } from "./label-A0UGV8FE.js";
6
- import { t as h } from "./AnimatePresence-D1bZ5_-l.js";
7
- import { a as g, i as _, n as v, r as y, t as b } from "./select-CCFHjOGk.js";
8
- import { A as x, _ as S, c as C, d as w, g as T, h as E, m as D, n as O, o as k, p as A, r as j, s as M, t as ee, v as N } from "./dialog-CJGnC5Ag.js";
9
- import { n as P, t as F } from "./MCPAppsDebugControls-C01DPDJv.js";
10
- import { a as te, i as I, t as L } from "./browser-DG2Z8392.js";
11
- import { n as R, t as z } from "./zap-0Wr9QO7N.js";
12
- import { t as B } from "./code-C8sN2OGR.js";
13
- import { t as V } from "./JSONDisplay-BJqMz7Ny.js";
14
- import { a as H, i as U, n as W, o as G, r as ne, s as re } from "./shared-CJVHJhag.js";
15
- import { t as ie } from "./history-BfUFpL1d.js";
16
- import { t as ae } from "./maximize-hSOCz133.js";
17
- import { n as oe, t as K } from "./save-CmdEPUAm.js";
18
- import { n as se, t as ce } from "./useSavedRequests-mSIsDd4c.js";
19
- import { t as le } from "./play-B1leulYf.js";
20
- import { t as q } from "./trash-2-BhumJAFE.js";
21
- import { t as ue } from "./wrench-DvK20LUT.js";
22
- import { t as de } from "./x-EilKPiCX.js";
23
- import { t as fe } from "./switch-DHXEA_N5.js";
24
- import { t as pe } from "./not-found-BajFyZpp.js";
25
- import { _ as J, t as me, v as he } from "./telemetry-DyrOzsAR.js";
26
- import { c as Y, o as ge } from "./react-BiVEwoxA.js";
27
- import { n as _e } from "./dist-CTJnCYmk.js";
28
- import { t as X } from "./spinner-Be1GlSGX.js";
29
- import { n as ve } from "./InspectorContext-BBKCdfmK.js";
30
- import { t as ye } from "./textarea-CwmI8_uI.js";
31
- import { t as be } from "./WidgetWrapper-BlbQAh_X.js";
32
- import { t as xe } from "./McpAppsViewPanel-07_iHrne.js";
33
- import { t as Se } from "./ListTabHeader-DzmTtN1e.js";
34
- var Ce = l("chevron-up", [["path", {
35
- d: "m18 15-6-6-6 6",
36
- key: "153udz"
37
- }]]), Z = /* @__PURE__ */ e(t(), 1), Q = c();
38
- function we({ savedRequests: e, selectedRequest: t, onLoadRequest: r, onDeleteRequest: o, focusedIndex: s }) {
39
- if (e.length === 0) return /* @__PURE__ */ (0, Q.jsxs)("div", {
40
- className: "flex flex-1 flex-col items-center justify-center p-4 text-center",
41
- children: [
42
- /* @__PURE__ */ (0, Q.jsx)(P, { className: "h-12 w-12 text-gray-400 dark:text-gray-600 mb-3" }),
43
- /* @__PURE__ */ (0, Q.jsx)("p", {
44
- className: "text-gray-500 dark:text-gray-400 mb-2",
45
- children: "No saved requests yet"
46
- }),
47
- /* @__PURE__ */ (0, Q.jsx)("p", {
48
- className: "text-xs text-gray-400 dark:text-gray-500",
49
- children: "Execute a tool and click Save to store requests"
50
- })
51
- ]
52
- });
53
- let c = (e, t) => {
54
- e.stopPropagation(), t();
55
- };
56
- return /* @__PURE__ */ (0, Q.jsx)("div", { children: e.map((e, l) => /* @__PURE__ */ (0, Q.jsxs)("div", {
57
- className: "relative group",
58
- children: [/* @__PURE__ */ (0, Q.jsx)(ne, {
59
- id: `saved-${e.id}`,
60
- isSelected: t?.id === e.id,
61
- isFocused: s === l,
62
- title: e.name,
63
- description: e.toolName,
64
- metadata: /* @__PURE__ */ (0, Q.jsx)("div", {
65
- className: "flex flex-col gap-1",
66
- children: /* @__PURE__ */ (0, Q.jsx)("span", {
67
- className: "text-xs text-gray-400 dark:text-gray-500",
68
- children: new Date(e.savedAt).toLocaleString()
69
- })
70
- }),
71
- onClick: () => r(e)
72
- }), /* @__PURE__ */ (0, Q.jsx)("div", {
73
- className: "absolute top-1/2 right-2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity z-10",
74
- children: /* @__PURE__ */ (0, Q.jsxs)(i, { children: [/* @__PURE__ */ (0, Q.jsx)(n, {
75
- render: /* @__PURE__ */ (0, Q.jsx)(p, {
76
- variant: "secondary",
77
- size: "sm",
78
- onClick: (t) => c(t, () => o(e.id)),
79
- className: "h-8 w-8 p-0",
80
- children: /* @__PURE__ */ (0, Q.jsx)(q, { className: "h-4 w-4" })
81
- }),
82
- nativeButton: !0
83
- }), /* @__PURE__ */ (0, Q.jsx)(a, { children: /* @__PURE__ */ (0, Q.jsx)("p", { children: "Delete saved request" }) })] })
84
- })]
85
- }, e.id)) });
86
- }
87
- //#endregion
88
- //#region src/client/components/tools/SaveRequestDialog.tsx
89
- function Te({ isOpen: e, requestName: t, defaultPlaceholder: n, onRequestNameChange: r, onSave: i, onCancel: a }) {
90
- return e ? /* @__PURE__ */ (0, Q.jsx)("div", {
91
- className: "fixed inset-0 bg-black/50 flex items-center justify-center z-50",
92
- onClick: a,
93
- children: /* @__PURE__ */ (0, Q.jsxs)("div", {
94
- className: "bg-white dark:bg-zinc-800 rounded-lg p-6 w-[400px] shadow-xl border border-gray-200 dark:border-zinc-700",
95
- onClick: (e) => e.stopPropagation(),
96
- children: [/* @__PURE__ */ (0, Q.jsx)("h3", {
97
- className: "text-lg font-semibold mb-4 text-gray-900 dark:text-gray-100",
98
- children: "Save Request"
99
- }), /* @__PURE__ */ (0, Q.jsxs)("div", {
100
- className: "space-y-4",
101
- children: [/* @__PURE__ */ (0, Q.jsxs)("div", { children: [/* @__PURE__ */ (0, Q.jsx)(m, {
102
- htmlFor: "request-name",
103
- children: "Request Name (optional)"
104
- }), /* @__PURE__ */ (0, Q.jsx)(s, {
105
- id: "request-name",
106
- value: t,
107
- onChange: (e) => r(e.target.value),
108
- placeholder: n,
109
- className: "mt-2",
110
- onKeyDown: (e) => {
111
- e.key === "Enter" && i();
112
- },
113
- autoFocus: !0
114
- })] }), /* @__PURE__ */ (0, Q.jsxs)("div", {
115
- className: "flex justify-end gap-2",
116
- children: [/* @__PURE__ */ (0, Q.jsx)(p, {
117
- variant: "outline",
118
- onClick: a,
119
- children: "Cancel"
120
- }), /* @__PURE__ */ (0, Q.jsxs)(p, {
121
- onClick: i,
122
- children: [/* @__PURE__ */ (0, Q.jsx)(K, { className: "h-4 w-4 mr-2" }), "Save"]
123
- })]
124
- })]
125
- })]
126
- })
127
- }) : null;
128
- }
129
- //#endregion
130
- //#region src/client/components/tools/schema-utils.ts
131
- function Ee(e, t) {
132
- if (!e?.$ref) return e;
133
- let n = e.$ref;
134
- if (!n.startsWith("#/")) return e;
135
- let r = n.substring(2).split("/"), i = t;
136
- for (let t of r) if (i && typeof i == "object" && t in i) i = i[t];
137
- else return e;
138
- return i;
139
- }
140
- function De(e, t) {
141
- if (e?.anyOf && Array.isArray(e.anyOf)) {
142
- let n = e.anyOf.find((e) => Ee(e, t)?.type !== "null");
143
- if (n) return {
144
- ...Ee(n, t),
145
- nullable: !0
146
- };
147
- }
148
- return e;
149
- }
150
- function Oe(e, t) {
151
- let n = De(e || {}, t);
152
- return n = Ee(n, t), n;
153
- }
154
- function ke(e, t) {
155
- let n = Oe(e, t);
156
- if (typeof n.type == "string") return n.type;
157
- if (Array.isArray(n.type)) {
158
- let e = n.type.find((e) => e !== "null");
159
- return typeof e == "string" ? e : void 0;
160
- }
161
- }
162
- function Ae(e) {
163
- let t = e?.enum;
164
- return Array.isArray(t) && t.every((e) => typeof e == "string") ? t : null;
165
- }
166
- function je(e) {
167
- let t = e.trim().toLowerCase();
168
- return [
169
- "true",
170
- "1",
171
- "yes",
172
- "on"
173
- ].includes(t) ? !0 : [
174
- "false",
175
- "0",
176
- "no",
177
- "off"
178
- ].includes(t) ? !1 : e;
179
- }
180
- function Me(e, t) {
181
- if (t === "number" || t === "integer") {
182
- let t = e.trim();
183
- if (!t) return e;
184
- let n = Number(t);
185
- return Number.isFinite(n) ? n : e;
186
- }
187
- return t === "boolean" ? je(e) : e;
188
- }
189
- function Ne(e, t) {
190
- if (e === void 0) return e;
191
- if (t === "object" || t === "array") {
192
- if (typeof e == "string") try {
193
- return JSON.parse(e);
194
- } catch {
195
- return e;
196
- }
197
- return e;
198
- }
199
- if (t === "number" || t === "integer") {
200
- if (typeof e == "number") return e;
201
- if (typeof e == "string") {
202
- let t = e.trim();
203
- if (!t) return e;
204
- let n = Number(t);
205
- return Number.isFinite(n) ? n : e;
206
- }
207
- return e;
208
- }
209
- return t === "boolean" ? typeof e == "boolean" ? e : typeof e == "string" ? je(e) : e : e;
210
- }
211
- function Pe(e) {
212
- let t = "", n = 0, r = !1, i = !1;
213
- for (; n < e.length;) {
214
- let a = e[n];
215
- if (i) {
216
- t += a, i = !1, n++;
217
- continue;
218
- }
219
- if (a === "\\") {
220
- i = !0, t += a, n++;
221
- continue;
222
- }
223
- if (a === "`") {
224
- r ? (t += "\"", r = !1) : (t += "\"", r = !0), n++;
225
- continue;
226
- }
227
- if (r && a === "\"") {
228
- t += "\\\"", n++;
229
- continue;
230
- }
231
- t += a, n++;
232
- }
233
- return t;
234
- }
235
- function Fe(e) {
236
- if (!e || typeof e != "string") return null;
237
- let t = e.trim();
238
- if (!t.startsWith("{")) return null;
239
- try {
240
- let e = JSON.parse(t);
241
- if (e && typeof e == "object" && !Array.isArray(e)) return e;
242
- } catch {
243
- try {
244
- let e = Pe(t), n = JSON.parse(e);
245
- if (n && typeof n == "object" && !Array.isArray(n)) return n;
246
- } catch {
247
- return null;
248
- }
249
- }
250
- return null;
251
- }
252
- //#endregion
253
- //#region src/client/components/tools/ToolInputForm.tsx
254
- function Ie({ selectedTool: e, toolArgs: t, onArgChange: n, onBulkPaste: r, autoFilledFields: i, setFields: a, sendEmptyFields: o, onToggleEmpty: c }) {
255
- let l = e?.inputSchema?.properties || {}, u = e?.inputSchema?.required || [], d = Object.keys(l).length > 0, f = async (e, t) => {
256
- r && await r(e.clipboardData.getData("text"), t) && e.preventDefault();
257
- };
258
- return d ? /* @__PURE__ */ (0, Q.jsx)("div", {
259
- className: "space-y-4",
260
- children: Object.entries(l).map(([r, l]) => {
261
- let d = Oe(l, e?.inputSchema || {}), p = Ae(d), h = d.type === "string" && p !== null, x = d, S = u.includes(r), C = t[r], w = "";
262
- C != null && (w = typeof C == "string" ? C : typeof C == "object" && C ? JSON.stringify(C, null, 2) : String(C));
263
- let T = x.type === "object" || x.type === "array", E = T ? x.type === "array" ? "array" : "object" : "string", D = a?.has(r) ?? !0, O = c && (x.type === "string" || T);
264
- return T ? /* @__PURE__ */ (0, Q.jsxs)("div", {
265
- className: "space-y-2",
266
- children: [/* @__PURE__ */ (0, Q.jsxs)("div", {
267
- className: "flex items-start justify-between gap-2",
268
- children: [/* @__PURE__ */ (0, Q.jsxs)("div", {
269
- className: "min-w-0 flex-1",
270
- children: [/* @__PURE__ */ (0, Q.jsxs)(m, {
271
- htmlFor: r,
272
- className: "text-sm font-medium",
273
- children: [r, S && /* @__PURE__ */ (0, Q.jsx)("span", {
274
- className: "text-red-500 ml-1",
275
- children: "*"
276
- })]
277
- }), x?.description && /* @__PURE__ */ (0, Q.jsx)("p", {
278
- className: "mt-0.5 text-xs text-gray-500 dark:text-gray-400",
279
- children: x.description
280
- })]
281
- }), O && c && /* @__PURE__ */ (0, Q.jsxs)("div", {
282
- className: "flex items-center gap-2 shrink-0",
283
- children: [/* @__PURE__ */ (0, Q.jsx)("span", {
284
- className: "text-xs text-muted-foreground whitespace-nowrap",
285
- children: E === "array" ? "Send empty array explicitly" : "Send empty object explicitly"
286
- }), /* @__PURE__ */ (0, Q.jsx)(fe, {
287
- checked: o?.has(r) ?? !1,
288
- onCheckedChange: (e) => c(r, E, e),
289
- "aria-label": E === "array" ? "Send empty array" : "Send empty object",
290
- title: E === "array" ? "Send empty array []" : "Send empty object {}"
291
- })]
292
- })]
293
- }), /* @__PURE__ */ (0, Q.jsx)(ye, {
294
- id: r,
295
- "data-testid": `tool-param-${r}`,
296
- value: w,
297
- onChange: (e) => n(r, e.target.value),
298
- onPaste: (e) => f(e, r),
299
- placeholder: `Enter ${r}`,
300
- disabled: o?.has(r) ?? !1,
301
- className: `min-h-[100px] ${D ? "" : "opacity-70"} ${i?.has(r) ? "animate-pulse ring-2 ring-green-500 dark:ring-green-400" : ""}`
302
- })]
303
- }, r) : h && p ? /* @__PURE__ */ (0, Q.jsxs)("div", {
304
- className: "space-y-2",
305
- children: [/* @__PURE__ */ (0, Q.jsxs)("div", { children: [/* @__PURE__ */ (0, Q.jsxs)(m, {
306
- htmlFor: r,
307
- className: "text-sm font-medium",
308
- children: [r, S && /* @__PURE__ */ (0, Q.jsx)("span", {
309
- className: "text-red-500 ml-1",
310
- children: "*"
311
- })]
312
- }), x.description && /* @__PURE__ */ (0, Q.jsx)("p", {
313
- className: "mt-0.5 text-xs text-gray-500 dark:text-gray-400",
314
- children: x.description
315
- })] }), /* @__PURE__ */ (0, Q.jsxs)(b, {
316
- value: String(t[r] || ""),
317
- onValueChange: (e) => n(r, e),
318
- children: [/* @__PURE__ */ (0, Q.jsx)(_, {
319
- id: r,
320
- className: `w-full ${D ? "" : "opacity-70"}`,
321
- "data-testid": `tool-param-${r}`,
322
- children: /* @__PURE__ */ (0, Q.jsx)(g, { placeholder: "Select an option" })
323
- }), /* @__PURE__ */ (0, Q.jsx)(v, { children: p.map((e, t) => /* @__PURE__ */ (0, Q.jsx)(y, {
324
- value: e,
325
- children: x.enumNames?.[t] || e
326
- }, e)) })]
327
- })]
328
- }, r) : /* @__PURE__ */ (0, Q.jsxs)("div", {
329
- className: "space-y-2",
330
- children: [/* @__PURE__ */ (0, Q.jsxs)("div", {
331
- className: "flex items-start justify-between gap-2",
332
- children: [/* @__PURE__ */ (0, Q.jsxs)("div", {
333
- className: "min-w-0 flex-1",
334
- children: [/* @__PURE__ */ (0, Q.jsxs)(m, {
335
- htmlFor: r,
336
- className: "text-sm font-medium",
337
- children: [r, S && /* @__PURE__ */ (0, Q.jsx)("span", {
338
- className: "text-red-500 ml-1",
339
- children: "*"
340
- })]
341
- }), x?.description && /* @__PURE__ */ (0, Q.jsx)("p", {
342
- className: "mt-0.5 text-xs text-gray-500 dark:text-gray-400",
343
- children: x.description
344
- })]
345
- }), O && c && /* @__PURE__ */ (0, Q.jsxs)("div", {
346
- className: "flex items-center gap-2 shrink-0",
347
- children: [/* @__PURE__ */ (0, Q.jsx)("span", {
348
- className: "text-xs text-muted-foreground whitespace-nowrap",
349
- children: "Send empty string"
350
- }), /* @__PURE__ */ (0, Q.jsx)(fe, {
351
- checked: o?.has(r) ?? !1,
352
- onCheckedChange: (e) => c(r, "string", e),
353
- "aria-label": "Send empty string",
354
- title: "Send empty string"
355
- })]
356
- })]
357
- }), /* @__PURE__ */ (0, Q.jsx)(s, {
358
- id: r,
359
- "data-testid": `tool-param-${r}`,
360
- value: w,
361
- onChange: (e) => n(r, e.target.value),
362
- onPaste: (e) => f(e, r),
363
- placeholder: `Enter ${r}`,
364
- disabled: o?.has(r) ?? !1,
365
- className: `${D ? "" : "opacity-70"} ${i?.has(r) ? "animate-pulse ring-2 ring-green-500 dark:ring-green-400" : ""}`
366
- })]
367
- }, r);
368
- })
369
- }) : /* @__PURE__ */ (0, Q.jsx)("div", {
370
- className: "flex items-center justify-center h-32 text-gray-500 dark:text-gray-400 text-sm",
371
- children: "No parameters required"
372
- });
373
- }
374
- //#endregion
375
- //#region src/client/components/tools/ToolExecutionPanel.tsx
376
- function Le({ selectedTool: e, toolArgs: t, payloadToSend: r, isExecuting: o, isConnected: s, onArgChange: c, onExecute: l, onSave: m, onCancel: h, onBulkPaste: g, autoFilledFields: _, setFields: v, sendEmptyFields: y, onToggleEmpty: b }) {
377
- let S = "hidden @[700px]/tool-exec:inline", w = "hidden @[700px]/tool-exec:inline shrink-0 text-[10px] leading-none border border-current/30 p-1 rounded-full", T = "@max-[699px]/tool-exec:size-8 @max-[699px]/tool-exec:min-w-8 @max-[699px]/tool-exec:shrink-0 @max-[699px]/tool-exec:gap-0 @max-[699px]/tool-exec:rounded-full @max-[699px]/tool-exec:!px-0 @max-[699px]/tool-exec:!py-0", E = "@max-[699px]/tool-exec:!pr-0", [D, A] = (0, Z.useState)(!1), [N, P] = (0, Z.useState)(!1), [F, R] = (0, Z.useState)(!1), [z, H] = (0, Z.useState)(!1), [U, W] = (0, Z.useState)(!1), G = (0, Z.useRef)(null);
378
- return (0, Z.useEffect)(() => {
379
- if (G.current && e?.description) {
380
- let e = G.current, t = parseFloat(getComputedStyle(e).lineHeight), n = e.scrollHeight;
381
- W(Math.round(n / t) > 3), H(!1);
382
- }
383
- }, [e?.description]), (0, Z.useEffect)(() => {
384
- let t = (t) => {
385
- (t.metaKey || t.ctrlKey) && t.key === "Enter" && e && !o && s && (t.preventDefault(), l()), t.key === "Escape" && o && h && (t.preventDefault(), h());
386
- };
387
- return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
388
- }, [
389
- e,
390
- o,
391
- s,
392
- l,
393
- h
394
- ]), e ? /* @__PURE__ */ (0, Q.jsxs)("div", {
395
- className: "flex flex-col h-full @container/tool-exec",
396
- children: [
397
- /* @__PURE__ */ (0, Q.jsx)("div", {
398
- className: "shrink-0 p-3 sm:p-5 pt-3 sm:pt-4 pb-2 sm:pb-2 sm:pr-4",
399
- children: /* @__PURE__ */ (0, Q.jsx)("div", { children: /* @__PURE__ */ (0, Q.jsxs)("div", {
400
- className: "flex flex-row items-center justify-between mb-0 gap-2",
401
- children: [/* @__PURE__ */ (0, Q.jsx)("h3", {
402
- className: "text-base sm:text-lg font-semibold",
403
- "data-testid": "tool-execution-title",
404
- children: e.name
405
- }), /* @__PURE__ */ (0, Q.jsxs)("div", {
406
- className: "flex gap-2 shrink-0",
407
- children: [
408
- /* @__PURE__ */ (0, Q.jsxs)(i, { children: [/* @__PURE__ */ (0, Q.jsx)(n, {
409
- render: /* @__PURE__ */ (0, Q.jsxs)(p, {
410
- "data-testid": "tool-execution-metadata-button",
411
- variant: N ? "default" : "outline",
412
- onClick: () => P(!N),
413
- disabled: o,
414
- size: "sm",
415
- className: u(d, T),
416
- title: "View tool metadata",
417
- children: [/* @__PURE__ */ (0, Q.jsx)(B, {}), /* @__PURE__ */ (0, Q.jsx)("span", {
418
- className: S,
419
- children: "Metadata"
420
- })]
421
- }),
422
- nativeButton: !0
423
- }), /* @__PURE__ */ (0, Q.jsx)(a, { children: /* @__PURE__ */ (0, Q.jsx)("p", { children: "View tool definition metadata" }) })] }),
424
- /* @__PURE__ */ (0, Q.jsxs)(i, { children: [/* @__PURE__ */ (0, Q.jsx)(n, {
425
- render: /* @__PURE__ */ (0, Q.jsxs)(p, {
426
- "data-testid": "tool-execution-copy-payload-button",
427
- variant: "outline",
428
- onClick: async () => {
429
- if (e) try {
430
- await L(JSON.stringify(r ?? t, null, 2)), R(!0), setTimeout(() => R(!1), 2e3);
431
- } catch {}
432
- },
433
- disabled: o,
434
- size: "sm",
435
- className: u(d, T),
436
- title: "Copy payload as JSON",
437
- children: [F ? /* @__PURE__ */ (0, Q.jsx)(te, { className: "text-green-600" }) : /* @__PURE__ */ (0, Q.jsx)(I, {}), /* @__PURE__ */ (0, Q.jsx)("span", {
438
- className: S,
439
- children: F ? "Copied!" : "Payload"
440
- })]
441
- }),
442
- nativeButton: !0
443
- }), /* @__PURE__ */ (0, Q.jsx)(a, { children: /* @__PURE__ */ (0, Q.jsx)("p", { children: "Copy payload as JSON" }) })] }),
444
- /* @__PURE__ */ (0, Q.jsxs)(i, { children: [/* @__PURE__ */ (0, Q.jsx)(n, {
445
- render: /* @__PURE__ */ (0, Q.jsxs)(p, {
446
- "data-testid": "tool-execution-save-button",
447
- variant: "outline",
448
- onClick: m,
449
- disabled: o,
450
- size: "sm",
451
- className: u(d, T),
452
- title: "Save request",
453
- children: [/* @__PURE__ */ (0, Q.jsx)(K, {}), /* @__PURE__ */ (0, Q.jsx)("span", {
454
- className: S,
455
- children: "Save"
456
- })]
457
- }),
458
- nativeButton: !0
459
- }), /* @__PURE__ */ (0, Q.jsx)(a, { children: /* @__PURE__ */ (0, Q.jsx)("p", { children: "Save request" }) })] }),
460
- o && h ? /* @__PURE__ */ (0, Q.jsxs)(i, {
461
- open: D ? void 0 : !1,
462
- children: [/* @__PURE__ */ (0, Q.jsx)(n, {
463
- render: /* @__PURE__ */ (0, Q.jsx)("div", {
464
- onMouseEnter: () => A(!0),
465
- onMouseLeave: () => A(!1),
466
- className: "relative",
467
- children: /* @__PURE__ */ (0, Q.jsx)(p, {
468
- "data-testid": "tool-execution-cancel-button",
469
- onClick: h,
470
- variant: D ? "destructive" : "default",
471
- size: "sm",
472
- className: u(f, T, E, "transition-all"),
473
- children: D ? /* @__PURE__ */ (0, Q.jsxs)(Q.Fragment, { children: [
474
- /* @__PURE__ */ (0, Q.jsx)(de, {}),
475
- /* @__PURE__ */ (0, Q.jsx)("span", {
476
- className: S,
477
- children: "Cancel"
478
- }),
479
- /* @__PURE__ */ (0, Q.jsx)("span", {
480
- className: w,
481
- children: "Esc"
482
- })
483
- ] }) : /* @__PURE__ */ (0, Q.jsxs)(Q.Fragment, { children: [/* @__PURE__ */ (0, Q.jsx)(X, {}), /* @__PURE__ */ (0, Q.jsx)("span", {
484
- className: S,
485
- children: "Executing..."
486
- })] })
487
- })
488
- }),
489
- nativeButton: !1
490
- }), /* @__PURE__ */ (0, Q.jsx)(a, { children: /* @__PURE__ */ (0, Q.jsx)("p", { children: "Hover to cancel (or press Esc)" }) })]
491
- }) : /* @__PURE__ */ (0, Q.jsx)(p, {
492
- "data-testid": "tool-execution-execute-button",
493
- onClick: l,
494
- disabled: o || !s,
495
- size: "sm",
496
- className: u(f, T, E),
497
- children: o ? /* @__PURE__ */ (0, Q.jsxs)(Q.Fragment, { children: [/* @__PURE__ */ (0, Q.jsx)(X, {}), /* @__PURE__ */ (0, Q.jsx)("span", {
498
- className: S,
499
- children: "Executing..."
500
- })] }) : /* @__PURE__ */ (0, Q.jsxs)(Q.Fragment, { children: [
501
- /* @__PURE__ */ (0, Q.jsx)(le, {}),
502
- /* @__PURE__ */ (0, Q.jsx)("span", {
503
- className: S,
504
- children: "Execute"
505
- }),
506
- /* @__PURE__ */ (0, Q.jsx)("span", {
507
- className: w,
508
- children: "⌘↵"
509
- })
510
- ] })
511
- })
512
- ]
513
- })]
514
- }) })
515
- }),
516
- /* @__PURE__ */ (0, Q.jsxs)("div", {
517
- className: "flex-1 overflow-y-auto px-3 sm:px-5 pb-4 pr-3",
518
- children: [e.description && /* @__PURE__ */ (0, Q.jsxs)("div", {
519
- className: "relative mb-6",
520
- children: [/* @__PURE__ */ (0, Q.jsxs)("div", {
521
- className: "relative",
522
- children: [/* @__PURE__ */ (0, Q.jsx)("p", {
523
- ref: G,
524
- "data-testid": "tool-execution-description",
525
- className: `text-sm text-gray-600 dark:text-gray-400 leading-relaxed transition-all duration-300 ${!z && U ? "line-clamp-3" : ""}`,
526
- children: e.description
527
- }), U && !z && /* @__PURE__ */ (0, Q.jsx)("div", { className: "absolute bottom-0 left-0 right-0 h-[1.4em] bg-linear-to-t from-white/95 dark:from-black/95 via-white/55 dark:via-black/55 to-transparent pointer-events-none" })]
528
- }), U && /* @__PURE__ */ (0, Q.jsx)("div", {
529
- className: "flex justify-end",
530
- children: /* @__PURE__ */ (0, Q.jsx)("button", {
531
- onClick: () => H(!z),
532
- className: "relative z-10 inline-flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 mt-1 transition-colors",
533
- children: z ? /* @__PURE__ */ (0, Q.jsxs)(Q.Fragment, { children: ["Show less", /* @__PURE__ */ (0, Q.jsx)(Ce, { className: "h-3 w-3" })] }) : /* @__PURE__ */ (0, Q.jsxs)(Q.Fragment, { children: ["Show more", /* @__PURE__ */ (0, Q.jsx)(x, { className: "h-3 w-3" })] })
534
- })
535
- })]
536
- }), /* @__PURE__ */ (0, Q.jsx)(Ie, {
537
- selectedTool: e,
538
- toolArgs: t,
539
- onArgChange: c,
540
- onBulkPaste: g,
541
- autoFilledFields: _,
542
- setFields: v,
543
- sendEmptyFields: y,
544
- onToggleEmpty: b
545
- })]
546
- }),
547
- /* @__PURE__ */ (0, Q.jsx)(ee, {
548
- open: N,
549
- onOpenChange: P,
550
- children: /* @__PURE__ */ (0, Q.jsxs)(j, {
551
- scrollable: !0,
552
- className: "max-w-3xl max-h-[80vh]",
553
- children: [/* @__PURE__ */ (0, Q.jsx)(k, {
554
- sticky: !0,
555
- children: /* @__PURE__ */ (0, Q.jsx)(C, { children: "Tool Definition" })
556
- }), /* @__PURE__ */ (0, Q.jsx)(O, { children: /* @__PURE__ */ (0, Q.jsx)(M, {
557
- onCopy: async () => {
558
- e && await L(JSON.stringify(e, null, 2));
559
- },
560
- children: /* @__PURE__ */ (0, Q.jsx)(V, {
561
- data: e,
562
- filename: `tool-definition-${e.name}-${Date.now()}.json`
563
- })
564
- }) })]
565
- })
566
- })
567
- ]
568
- }) : /* @__PURE__ */ (0, Q.jsxs)("div", {
569
- className: "flex flex-col items-center justify-center h-full p-4 text-center",
570
- children: [/* @__PURE__ */ (0, Q.jsx)("p", {
571
- className: "text-gray-500 dark:text-gray-400 mb-2",
572
- children: "Select a tool to get started"
573
- }), /* @__PURE__ */ (0, Q.jsx)("p", {
574
- className: "text-xs text-gray-400 dark:text-gray-500",
575
- children: "Choose a tool from the list to view its details and execute it"
576
- })]
577
- });
578
- }
579
- //#endregion
580
- //#region src/client/components/tools/ToolResultDisplay.tsx
581
- function Re({ timestamp: e }) {
582
- let [t, n] = (0, Z.useState)(() => ze(e));
583
- return (0, Z.useEffect)(() => {
584
- let t = () => n(ze(e));
585
- t();
586
- let r = setInterval(t, 1e3);
587
- return () => clearInterval(r);
588
- }, [e]), /* @__PURE__ */ (0, Q.jsx)("span", { children: t });
589
- }
590
- function ze(e) {
591
- let t = Date.now() - e, n = Math.floor(t / 1e3), r = Math.floor(n / 60), i = Math.floor(r / 60), a = Math.floor(i / 24);
592
- return n < 10 ? "now" : n < 60 ? `${n}s ago` : r < 60 ? `${r}m ago` : i < 24 ? `${i}h ago` : `${a}d ago`;
593
- }
594
- function Be(e) {
595
- if (!e?.isError) return null;
596
- let t = e.content;
597
- if (Array.isArray(t)) {
598
- let e = t.filter((e) => e.type === "text").map((e) => e.text).filter(Boolean);
599
- if (e.length > 0) return e.join("\n");
600
- }
601
- return "An error occurred";
602
- }
603
- function $(e) {
604
- try {
605
- return JSON.parse(e), !0;
606
- } catch {
607
- return !1;
608
- }
609
- }
610
- function Ve({ content: e }) {
611
- let [t, n] = (0, Z.useState)(/* @__PURE__ */ new Set()), r = (0, Z.useCallback)((e) => {
612
- n((t) => {
613
- let n = new Set(t);
614
- return n.has(e) ? n.delete(e) : n.add(e), n;
615
- });
616
- }, []);
617
- return !Array.isArray(e) || e.length === 0 ? /* @__PURE__ */ (0, Q.jsx)("div", {
618
- className: "text-sm text-gray-500 dark:text-gray-400",
619
- children: "No content"
620
- }) : /* @__PURE__ */ (0, Q.jsx)("div", {
621
- className: "space-y-4",
622
- children: e.map((e, n) => {
623
- if (e.type === "text") {
624
- let i = e.text || "", a = t.has(n), o = $(i), s = o ? (() => {
625
- try {
626
- return JSON.parse(i);
627
- } catch {
628
- return null;
629
- }
630
- })() : null;
631
- return /* @__PURE__ */ (0, Q.jsxs)("div", {
632
- className: "space-y-2",
633
- children: [/* @__PURE__ */ (0, Q.jsxs)("div", {
634
- className: "flex items-center justify-between gap-2",
635
- children: [/* @__PURE__ */ (0, Q.jsxs)("div", {
636
- className: "text-xs font-medium text-gray-500 dark:text-gray-400",
637
- children: ["Text Content", a ? " (formatted)" : ""]
638
- }), o && /* @__PURE__ */ (0, Q.jsx)("button", {
639
- type: "button",
640
- onClick: () => r(n),
641
- className: "text-xs text-blue-600 dark:text-blue-400 hover:underline",
642
- "data-testid": `tool-result-format-toggle-${n}`,
643
- children: a ? "Show as text" : "Try to format"
644
- })]
645
- }), a && s !== null ? /* @__PURE__ */ (0, Q.jsx)(V, {
646
- data: s,
647
- filename: `content-${n}.json`
648
- }) : /* @__PURE__ */ (0, Q.jsx)("div", {
649
- className: "bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 font-mono text-sm whitespace-pre-wrap break-words",
650
- "data-testid": "tool-execution-results-text-content",
651
- children: i
652
- })]
653
- }, n);
654
- }
655
- if (e.type === "image") return /* @__PURE__ */ (0, Q.jsxs)("div", {
656
- className: "space-y-2",
657
- children: [/* @__PURE__ */ (0, Q.jsx)("div", {
658
- className: "text-xs font-medium text-gray-500 dark:text-gray-400",
659
- children: "Image Content"
660
- }), /* @__PURE__ */ (0, Q.jsxs)("div", {
661
- className: "bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",
662
- children: [/* @__PURE__ */ (0, Q.jsx)("img", {
663
- src: `data:${e.mimeType || "image/png"};base64,${e.data}`,
664
- alt: "Result",
665
- className: "max-w-full rounded",
666
- "data-testid": "tool-execution-results-image-content"
667
- }), e.annotations && /* @__PURE__ */ (0, Q.jsx)("div", {
668
- className: "mt-2 text-xs text-gray-500 dark:text-gray-400",
669
- children: /* @__PURE__ */ (0, Q.jsx)(V, {
670
- data: e.annotations,
671
- filename: `image-annotations-${n}.json`,
672
- "data-testid": "tool-execution-results-image-annotations"
673
- })
674
- })]
675
- })]
676
- }, n);
677
- if (e.type === "audio") return /* @__PURE__ */ (0, Q.jsxs)("div", {
678
- className: "space-y-2",
679
- children: [/* @__PURE__ */ (0, Q.jsx)("div", {
680
- className: "text-xs font-medium text-gray-500 dark:text-gray-400",
681
- children: "Audio Content"
682
- }), /* @__PURE__ */ (0, Q.jsxs)("div", {
683
- className: "bg-gray-50 dark:bg-zinc-900 rounded-lg p-3",
684
- children: [/* @__PURE__ */ (0, Q.jsx)("audio", {
685
- controls: !0,
686
- src: `data:${e.mimeType || "audio/wav"};base64,${e.data}`,
687
- className: "w-full",
688
- "data-testid": "tool-execution-results-audio-content"
689
- }), e.annotations && /* @__PURE__ */ (0, Q.jsx)("div", {
690
- className: "mt-2 text-xs text-gray-500 dark:text-gray-400",
691
- children: /* @__PURE__ */ (0, Q.jsx)(V, {
692
- data: e.annotations,
693
- filename: `audio-annotations-${n}.json`,
694
- "data-testid": "tool-execution-results-audio-annotations"
695
- })
696
- })]
697
- })]
698
- }, n);
699
- if (e.type === "resource_link") return /* @__PURE__ */ (0, Q.jsxs)("div", {
700
- className: "space-y-2",
701
- children: [/* @__PURE__ */ (0, Q.jsx)("div", {
702
- className: "text-xs font-medium text-gray-500 dark:text-gray-400",
703
- children: "Resource Link"
704
- }), /* @__PURE__ */ (0, Q.jsxs)("div", {
705
- className: "bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",
706
- children: [
707
- /* @__PURE__ */ (0, Q.jsxs)("div", {
708
- className: "font-mono text-sm break-all",
709
- children: [
710
- /* @__PURE__ */ (0, Q.jsx)("span", {
711
- className: "text-gray-600 dark:text-gray-400",
712
- children: "URI:"
713
- }),
714
- " ",
715
- e.uri
716
- ]
717
- }),
718
- e.name && /* @__PURE__ */ (0, Q.jsxs)("div", {
719
- className: "text-sm",
720
- children: [
721
- /* @__PURE__ */ (0, Q.jsx)("span", {
722
- className: "text-gray-600 dark:text-gray-400",
723
- children: "Name:"
724
- }),
725
- " ",
726
- e.name
727
- ]
728
- }),
729
- e.description && /* @__PURE__ */ (0, Q.jsxs)("div", {
730
- className: "text-sm",
731
- children: [
732
- /* @__PURE__ */ (0, Q.jsx)("span", {
733
- className: "text-gray-600 dark:text-gray-400",
734
- children: "Description:"
735
- }),
736
- " ",
737
- e.description
738
- ]
739
- }),
740
- e.mimeType && /* @__PURE__ */ (0, Q.jsxs)("div", {
741
- className: "text-sm",
742
- children: [
743
- /* @__PURE__ */ (0, Q.jsx)("span", {
744
- className: "text-gray-600 dark:text-gray-400",
745
- children: "MIME Type:"
746
- }),
747
- " ",
748
- e.mimeType
749
- ]
750
- }),
751
- e.annotations && /* @__PURE__ */ (0, Q.jsxs)("div", {
752
- className: "mt-2",
753
- children: [/* @__PURE__ */ (0, Q.jsx)("div", {
754
- className: "text-xs text-gray-500 dark:text-gray-400 mb-1",
755
- children: "Annotations:"
756
- }), /* @__PURE__ */ (0, Q.jsx)(V, {
757
- data: e.annotations,
758
- filename: `resource-link-annotations-${n}.json`,
759
- "data-testid": "tool-execution-results-resource-link-annotations"
760
- })]
761
- })
762
- ]
763
- })]
764
- }, n);
765
- if (e.type === "resource") {
766
- let t = e.resource || {};
767
- return /* @__PURE__ */ (0, Q.jsxs)("div", {
768
- className: "space-y-2",
769
- children: [/* @__PURE__ */ (0, Q.jsx)("div", {
770
- className: "text-xs font-medium text-gray-500 dark:text-gray-400",
771
- children: "Embedded Resource"
772
- }), /* @__PURE__ */ (0, Q.jsxs)("div", {
773
- className: "bg-gray-50 dark:bg-zinc-900 rounded-lg p-3 space-y-2",
774
- children: [
775
- /* @__PURE__ */ (0, Q.jsxs)("div", {
776
- className: "font-mono text-sm break-all",
777
- "data-testid": "tool-execution-results-resource-uri",
778
- children: [
779
- /* @__PURE__ */ (0, Q.jsx)("span", {
780
- className: "text-gray-600 dark:text-gray-400",
781
- children: "URI:"
782
- }),
783
- " ",
784
- t.uri
785
- ]
786
- }),
787
- t.mimeType && /* @__PURE__ */ (0, Q.jsxs)("div", {
788
- className: "text-sm",
789
- children: [
790
- /* @__PURE__ */ (0, Q.jsx)("span", {
791
- className: "text-gray-600 dark:text-gray-400",
792
- "data-testid": "tool-execution-results-mime-type",
793
- children: "MIME Type:"
794
- }),
795
- " ",
796
- t.mimeType
797
- ]
798
- }),
799
- t.text && /* @__PURE__ */ (0, Q.jsxs)("div", {
800
- "data-testid": "tool-execution-results-resource-text-content",
801
- children: [/* @__PURE__ */ (0, Q.jsx)("div", {
802
- className: "text-xs text-gray-500 dark:text-gray-400 mb-1",
803
- children: "Content:"
804
- }), /* @__PURE__ */ (0, Q.jsx)("div", {
805
- className: "bg-white dark:bg-black rounded p-2 font-mono text-sm whitespace-pre-wrap break-words max-h-60 overflow-y-auto",
806
- children: t.text
807
- })]
808
- }),
809
- t.blob && /* @__PURE__ */ (0, Q.jsxs)("div", {
810
- className: "text-sm text-gray-600 dark:text-gray-400",
811
- children: [
812
- "[Binary content: ",
813
- t.blob.length || 0,
814
- " bytes]"
815
- ]
816
- }),
817
- t.annotations && /* @__PURE__ */ (0, Q.jsxs)("div", {
818
- className: "mt-2",
819
- children: [/* @__PURE__ */ (0, Q.jsx)("div", {
820
- className: "text-xs text-gray-500 dark:text-gray-400 mb-1",
821
- children: "Annotations:"
822
- }), /* @__PURE__ */ (0, Q.jsx)(V, {
823
- data: t.annotations,
824
- filename: `resource-annotations-${n}.json`,
825
- "data-testid": "tool-execution-results-resource-annotations"
826
- })]
827
- })
828
- ]
829
- })]
830
- }, n);
831
- }
832
- return /* @__PURE__ */ (0, Q.jsxs)("div", {
833
- className: "space-y-2",
834
- children: [/* @__PURE__ */ (0, Q.jsxs)("div", {
835
- className: "text-xs font-medium text-gray-500 dark:text-gray-400",
836
- children: ["Unknown Content Type: ", e.type || "N/A"]
837
- }), /* @__PURE__ */ (0, Q.jsx)(V, {
838
- data: e,
839
- filename: `content-${n}.json`,
840
- "data-testid": "tool-execution-results-unknown-content"
841
- })]
842
- }, n);
843
- })
844
- });
845
- }
846
- function He({ results: e, copiedResult: t, serverId: n, readResource: r, onCopy: i, onMaximize: a, isMaximized: o = !1, onRerunTool: s, onWidgetHeightChange: c }) {
847
- let [l, u] = (0, Z.useState)(0), [d, f] = (0, Z.useState)(!0), [m, h] = (0, Z.useState)(null), [g, x] = (0, Z.useState)("inline"), [S, C] = (0, Z.useState)(null), w = (0, Z.useRef)(!1), T = e[0], E = T ? e.filter((e) => e.toolName === T.toolName) : [], D = E[l] || E[0], O = e.findIndex((e) => e === D), k = (D ? D.error || Be(D.result) : null) ?? (D == null ? "" : JSON.stringify(D.result, null, 2));
848
- (0, Z.useEffect)(() => {
849
- E.length > 0 && l >= E.length && u(0);
850
- }, [E.length, l]), (0, Z.useEffect)(() => {
851
- w.current = !1, h(null);
852
- }, [T?.toolName]);
853
- let A = (0, Z.useMemo)(() => D?.args, [D?.timestamp, l]), j = (0, Z.useMemo)(() => D?.result, [
854
- D?.timestamp,
855
- D?.duration,
856
- l
857
- ]), M = (0, Z.useCallback)((e) => r(e), [r]), ee = (0, Z.useCallback)((e) => {
858
- let t = e.filter((e) => e.type === "text" && "text" in e).map((e) => e.text).join("\n"), n = e.filter((e) => e.type === "image").length, r = e.filter((e) => e.type === "resource").length, i = [n > 0 && `${n} image${n > 1 ? "s" : ""}`, r > 0 && `${r} resource${r > 1 ? "s" : ""}`].filter(Boolean).join(", ");
859
- _e.info("Widget follow-up", {
860
- description: [t, i].filter(Boolean).join(" — "),
861
- duration: 5e3
862
- });
863
- }, []), N = (0, Z.useMemo)(() => D && Y(D.toolMeta) ? "mcp-apps" : null, [D]), P = (0, Z.useMemo)(() => D?.toolMeta ? ge(D.toolMeta) : null, [D?.toolMeta]), L = (0, Z.useMemo)(() => N === "mcp-apps" && !!P, [N, P]), R = (0, Z.useMemo)(() => D?.result?.content || [], [D]), B = (0, Z.useMemo)(() => P || null, [P]), H = (0, Z.useMemo)(() => !!(R && R.length > 0 || D?.result?.structuredContent), [R, D]), U = (0, Z.useMemo)(() => !L && H, [L, H]), W = (0, Z.useMemo)(() => {
864
- let e = [];
865
- return L && P && e.push({
866
- mode: "mcp-apps",
867
- label: "Component (MCP Apps)"
868
- }), e.push({
869
- mode: "json",
870
- label: "Raw JSON"
871
- }), e;
872
- }, [L, P]);
873
- return (0, Z.useEffect)(() => {
874
- if (W.length === 0) return;
875
- let e = m && W.some((e) => e.mode === m), t = W.find((e) => e.mode !== "json");
876
- if (t) {
877
- let n = w.current;
878
- if (w.current = !0, !m || !e || m === "json" && !n) {
879
- h(t.mode);
880
- return;
881
- }
882
- } else (!m || !e) && h("json");
883
- }, [W, m]), (0, Z.useEffect)(() => {
884
- c && (e.length === 0 || m !== "mcp-apps" || g !== "inline" || !L) && c(null);
885
- }, [
886
- c,
887
- e.length,
888
- m,
889
- g,
890
- L
891
- ]), e.length === 0 ? /* @__PURE__ */ (0, Q.jsx)("div", {
892
- className: "flex flex-col h-full bg-white dark:bg-black",
893
- children: /* @__PURE__ */ (0, Q.jsx)("div", {
894
- className: "flex-1 overflow-y-auto h-full",
895
- children: /* @__PURE__ */ (0, Q.jsx)("div", {
896
- className: "flex items-center justify-center h-full",
897
- children: /* @__PURE__ */ (0, Q.jsx)("div", {
898
- className: "text-center",
899
- children: /* @__PURE__ */ (0, Q.jsx)(pe, {
900
- vertical: !0,
901
- noBorder: !0,
902
- message: "No Results yet"
903
- })
904
- })
905
- })
906
- })
907
- }) : /* @__PURE__ */ (0, Q.jsxs)("div", {
908
- className: "relative flex flex-col h-full bg-white dark:bg-black",
909
- children: [/* @__PURE__ */ (0, Q.jsx)("div", {
910
- className: "flex-1 overflow-y-auto h-full",
911
- children: /* @__PURE__ */ (0, Q.jsxs)("div", {
912
- className: "space-y-0 flex flex-col flex-1 h-full",
913
- children: [/* @__PURE__ */ (0, Q.jsxs)("div", {
914
- className: `sticky top-0 z-40 flex items-center gap-2 px-4 pt-2 backdrop-blur-xs bg-white/50 dark:bg-black/50 ${L || U ? "border-b border-gray-200 dark:border-zinc-600 pb-2" : ""}`,
915
- children: [
916
- /* @__PURE__ */ (0, Q.jsx)("h3", {
917
- className: "text-sm font-medium hidden sm:block",
918
- children: "Response"
919
- }),
920
- D.duration !== void 0 && /* @__PURE__ */ (0, Q.jsxs)("div", {
921
- className: "hidden sm:flex items-center gap-1",
922
- children: [/* @__PURE__ */ (0, Q.jsx)(z, { className: "h-3 w-3 text-gray-400" }), /* @__PURE__ */ (0, Q.jsxs)("span", {
923
- className: "text-xs text-gray-500 dark:text-gray-400",
924
- children: [D.duration, "ms"]
925
- })]
926
- }),
927
- L && /* @__PURE__ */ (0, Q.jsx)("div", {
928
- className: "flex items-center gap-4 sm:ml-4",
929
- children: /* @__PURE__ */ (0, Q.jsx)("div", {
930
- className: "flex items-center gap-2",
931
- children: W.map((e, t) => /* @__PURE__ */ (0, Q.jsxs)(Z.Fragment, { children: [t > 0 && /* @__PURE__ */ (0, Q.jsx)("span", {
932
- className: "text-xs text-zinc-400",
933
- children: "|"
934
- }), /* @__PURE__ */ (0, Q.jsx)("button", {
935
- "data-testid": `tool-result-view-${e.mode}`,
936
- onClick: () => h(e.mode),
937
- className: `text-xs font-medium ${m === e.mode ? "text-black dark:text-white" : "text-zinc-500 dark:text-zinc-400"}`,
938
- children: e.label
939
- })] }, e.mode))
940
- })
941
- }),
942
- U && /* @__PURE__ */ (0, Q.jsxs)("div", {
943
- className: "flex items-center gap-2 sm:ml-4",
944
- children: [
945
- /* @__PURE__ */ (0, Q.jsx)("button", {
946
- onClick: () => f(!0),
947
- className: `text-xs font-medium ${d ? "text-black dark:text-white" : "text-zinc-500 dark:text-zinc-400"}`,
948
- children: "Formatted"
949
- }),
950
- /* @__PURE__ */ (0, Q.jsx)("span", {
951
- className: "text-xs text-zinc-400",
952
- children: "|"
953
- }),
954
- /* @__PURE__ */ (0, Q.jsx)("button", {
955
- onClick: () => f(!1),
956
- className: `text-xs font-medium ${d ? "text-zinc-500 dark:text-zinc-400" : "text-black dark:text-white"}`,
957
- children: "Raw"
958
- })
959
- ]
960
- }),
961
- /* @__PURE__ */ (0, Q.jsxs)("div", {
962
- className: "ml-auto flex items-center gap-1",
963
- children: [
964
- o && s && /* @__PURE__ */ (0, Q.jsxs)(p, {
965
- "data-testid": "tool-result-rerun",
966
- variant: "ghost",
967
- size: "sm",
968
- onClick: s,
969
- title: "Re-run with same arguments",
970
- children: [/* @__PURE__ */ (0, Q.jsx)(le, { className: "h-4 w-4" }), /* @__PURE__ */ (0, Q.jsx)("span", {
971
- className: "hidden sm:inline ml-1",
972
- children: "Re-run"
973
- })]
974
- }),
975
- L && a && /* @__PURE__ */ (0, Q.jsx)(p, {
976
- "data-testid": "tool-result-maximize",
977
- variant: "ghost",
978
- size: "sm",
979
- onClick: a,
980
- title: o ? "Restore" : "Maximize",
981
- children: o ? /* @__PURE__ */ (0, Q.jsx)(oe, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, Q.jsx)(ae, { className: "h-4 w-4" })
982
- }),
983
- E.length > 1 && /* @__PURE__ */ (0, Q.jsxs)(b, {
984
- value: l.toString(),
985
- onValueChange: (e) => u(parseInt(e)),
986
- children: [/* @__PURE__ */ (0, Q.jsx)(_, {
987
- className: "w-[140px] h-8 text-xs",
988
- leading: /* @__PURE__ */ (0, Q.jsxs)("div", {
989
- className: "flex items-center gap-1",
990
- children: [/* @__PURE__ */ (0, Q.jsx)(ie, { className: "h-3 w-3" }), /* @__PURE__ */ (0, Q.jsx)(Re, { timestamp: D.timestamp })]
991
- })
992
- }), /* @__PURE__ */ (0, Q.jsx)(v, { children: E.map((e, t) => /* @__PURE__ */ (0, Q.jsx)(y, {
993
- value: t.toString(),
994
- children: /* @__PURE__ */ (0, Q.jsxs)("div", {
995
- className: "flex items-center gap-2",
996
- children: [
997
- /* @__PURE__ */ (0, Q.jsx)(ie, { className: "h-3 w-3" }),
998
- /* @__PURE__ */ (0, Q.jsx)("span", { children: ze(e.timestamp) }),
999
- /* @__PURE__ */ (0, Q.jsxs)("span", {
1000
- className: "text-xs text-muted-foreground",
1001
- children: [
1002
- "(",
1003
- new Date(e.timestamp).toLocaleTimeString(),
1004
- ")"
1005
- ]
1006
- })
1007
- ]
1008
- })
1009
- }, t)) })]
1010
- }),
1011
- /* @__PURE__ */ (0, Q.jsx)(p, {
1012
- "data-testid": `tool-result-copy-${O}`,
1013
- variant: "ghost",
1014
- size: "sm",
1015
- onClick: () => i(O, k),
1016
- children: t === O ? /* @__PURE__ */ (0, Q.jsx)(te, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, Q.jsx)(I, { className: "h-4 w-4" })
1017
- })
1018
- ]
1019
- })
1020
- ]
1021
- }), (() => {
1022
- let e = D.error || Be(D.result);
1023
- return e ? /* @__PURE__ */ (0, Q.jsxs)("div", {
1024
- className: "bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3 mx-4 mt-4",
1025
- children: [/* @__PURE__ */ (0, Q.jsx)("p", {
1026
- className: "text-red-800 dark:text-red-300 font-medium",
1027
- children: "Error:"
1028
- }), /* @__PURE__ */ (0, Q.jsx)("p", {
1029
- className: "text-red-700 dark:text-red-400 text-sm",
1030
- children: e
1031
- })]
1032
- }) : (() => {
1033
- if (!m) return /* @__PURE__ */ (0, Q.jsx)("div", {
1034
- className: "flex items-center justify-center w-full h-[200px]",
1035
- children: /* @__PURE__ */ (0, Q.jsx)(X, { className: "size-5" })
1036
- });
1037
- switch (m) {
1038
- case "mcp-apps": return !L || !P ? /* @__PURE__ */ (0, Q.jsx)("div", {
1039
- className: "px-4 pt-4",
1040
- children: /* @__PURE__ */ (0, Q.jsx)("div", {
1041
- className: "bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded p-3",
1042
- children: /* @__PURE__ */ (0, Q.jsx)("p", {
1043
- className: "text-sm text-red-600 dark:text-red-400",
1044
- children: "MCP Apps resource not available"
1045
- })
1046
- })
1047
- }) : /* @__PURE__ */ (0, Q.jsxs)(be, {
1048
- className: "relative flex flex-1 w-full min-h-[240px] items-stretch",
1049
- children: [/* @__PURE__ */ (0, Q.jsx)("div", {
1050
- className: "absolute top-2 right-2 z-30 flex items-center gap-2",
1051
- children: /* @__PURE__ */ (0, Q.jsx)(F, {
1052
- toolCallId: `tool-${D.timestamp}`,
1053
- displayMode: g,
1054
- onDisplayModeChange: x,
1055
- propsContext: "tool",
1056
- resourceUri: P,
1057
- toolInput: D.args,
1058
- resourceAnnotations: D.toolMeta,
1059
- llmConfig: null,
1060
- resource: null,
1061
- onPropsChange: C
1062
- })
1063
- }), /* @__PURE__ */ (0, Q.jsx)("div", {
1064
- className: "flex min-h-0 flex-1 flex-col pt-11",
1065
- children: /* @__PURE__ */ (0, Q.jsx)(xe, {
1066
- serverId: n,
1067
- viewId: `tool-${D.timestamp}`,
1068
- toolName: D.toolName,
1069
- toolInput: A,
1070
- toolOutput: j,
1071
- toolMetadata: D.toolMeta,
1072
- resourceUri: P,
1073
- readResource: M,
1074
- customProps: S || void 0,
1075
- displayMode: g,
1076
- onDisplayModeChange: x,
1077
- onSendFollowUp: ee,
1078
- onWidgetHeightChange: c ? (e) => c(e) : void 0,
1079
- noWrapper: !0
1080
- }, `mcp-apps-${D.timestamp}`)
1081
- })]
1082
- });
1083
- case "json":
1084
- if (U && d) {
1085
- let e = D.result?.structuredContent;
1086
- return /* @__PURE__ */ (0, Q.jsxs)("div", {
1087
- className: "px-4 pt-4 space-y-4",
1088
- "data-testid": "tool-execution-results-content",
1089
- children: [
1090
- e && /* @__PURE__ */ (0, Q.jsxs)("div", {
1091
- className: "space-y-2",
1092
- "data-testid": "tool-execution-results-structured-content",
1093
- children: [/* @__PURE__ */ (0, Q.jsx)("div", {
1094
- className: "text-xs font-medium text-gray-500 dark:text-gray-400",
1095
- children: "Structured Content"
1096
- }), /* @__PURE__ */ (0, Q.jsx)(V, {
1097
- data: e,
1098
- filename: `structured-content-${D.toolName}-${Date.now()}.json`
1099
- })]
1100
- }),
1101
- R && R.length > 0 && /* @__PURE__ */ (0, Q.jsx)(Ve, { content: R }),
1102
- !e && (!R || R.length === 0) && /* @__PURE__ */ (0, Q.jsx)("div", {
1103
- className: "text-sm text-gray-500 dark:text-gray-400",
1104
- "data-testid": "tool-execution-results-no-content",
1105
- children: "No content to display"
1106
- })
1107
- ]
1108
- });
1109
- }
1110
- return /* @__PURE__ */ (0, Q.jsx)("div", {
1111
- className: "px-4 pt-4",
1112
- children: /* @__PURE__ */ (0, Q.jsx)(V, {
1113
- data: D.result,
1114
- filename: `tool-result-${D.toolName}-${Date.now()}.json`
1115
- })
1116
- });
1117
- default: return null;
1118
- }
1119
- })();
1120
- })()]
1121
- })
1122
- }), B && m === "mcp-apps" && /* @__PURE__ */ (0, Q.jsx)("div", {
1123
- className: "absolute bottom-0 left-1/2 -translate-x-1/2 z-40 pointer-events-none",
1124
- children: /* @__PURE__ */ (0, Q.jsx)("span", {
1125
- className: "text-[11px] bg-gray-200 dark:bg-zinc-800 text-gray-500 dark:text-gray-400 px-3 py-0.5 rounded-t-xl font-mono max-w-[320px] truncate block",
1126
- children: B
1127
- })
1128
- })]
1129
- });
1130
- }
1131
- //#endregion
1132
- //#region src/client/components/tools/ToolsList.tsx
1133
- function Ue({ tools: e, selectedTool: t, onToolSelect: r, focusedIndex: s }) {
1134
- if (e.length === 0) return /* @__PURE__ */ (0, Q.jsxs)("div", {
1135
- className: "flex flex-1 flex-col items-center justify-center p-4 text-center",
1136
- children: [/* @__PURE__ */ (0, Q.jsx)(ue, { className: "h-12 w-12 text-gray-400 dark:text-gray-600 mb-3" }), /* @__PURE__ */ (0, Q.jsx)("p", {
1137
- className: "text-gray-500 dark:text-gray-400",
1138
- children: "No tools available"
1139
- })]
1140
- });
1141
- let c = e.some((e) => e.inputSchema?.properties && Object.keys(e.inputSchema.properties).length > 0);
1142
- return /* @__PURE__ */ (0, Q.jsx)("div", { children: e.map((e, l) => {
1143
- let u = e._meta, d = Y(u) ? "mcp-apps" : null, f = e.inputSchema?.properties, p = f ? Object.keys(f).length : 0, m = c && p > 0 && /* @__PURE__ */ (0, Q.jsxs)(o, {
1144
- variant: "outline",
1145
- className: "text-xs border-gray-300 dark:border-zinc-600 text-gray-600 dark:text-gray-400",
1146
- children: [p, " params"]
1147
- }), h = d === "mcp-apps" || m ? /* @__PURE__ */ (0, Q.jsxs)("div", {
1148
- className: "flex items-center gap-1.5",
1149
- children: [d === "mcp-apps" && /* @__PURE__ */ (0, Q.jsxs)(i, { children: [/* @__PURE__ */ (0, Q.jsx)(n, {
1150
- render: /* @__PURE__ */ (0, Q.jsx)("span", {
1151
- className: "inline-flex",
1152
- children: /* @__PURE__ */ (0, Q.jsx)(se, { className: "h-3.5 w-3.5" })
1153
- }),
1154
- nativeButton: !1
1155
- }), /* @__PURE__ */ (0, Q.jsx)(a, { children: /* @__PURE__ */ (0, Q.jsx)("p", { children: "UI widget" }) })] }), m]
1156
- }) : void 0;
1157
- return /* @__PURE__ */ (0, Q.jsx)(ne, {
1158
- id: `tool-${e.name}`,
1159
- "data-testid": `tool-item-${e.name}`,
1160
- isSelected: t?.name === e.name,
1161
- isFocused: s === l,
1162
- title: e.name,
1163
- description: e.description,
1164
- metadata: h,
1165
- onClick: () => r(e)
1166
- }, e.name);
1167
- }) });
1168
- }
1169
- //#endregion
1170
- //#region ../../node_modules/.pnpm/@base-ui+react@1.6.0_@types+react@19.2.17_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@base-ui/react/alert-dialog/root/AlertDialogRoot.mjs
1171
- function We(e) {
1172
- return A(e, "alert-dialog");
1173
- }
1174
- //#endregion
1175
- //#region src/client/components/ui/alert-dialog.tsx
1176
- function Ge({ ...e }) {
1177
- return /* @__PURE__ */ (0, Q.jsx)(We, {
1178
- "data-slot": "alert-dialog",
1179
- ...e
1180
- });
1181
- }
1182
- function Ke({ ...e }) {
1183
- return /* @__PURE__ */ (0, Q.jsx)(D, {
1184
- "data-slot": "alert-dialog-portal",
1185
- ...e
1186
- });
1187
- }
1188
- function qe({ className: e, ...t }) {
1189
- return /* @__PURE__ */ (0, Q.jsx)(N, {
1190
- "data-slot": "alert-dialog-overlay",
1191
- className: u("fixed inset-0 isolate z-50 bg-black/50 duration-100 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0", e),
1192
- ...t
1193
- });
1194
- }
1195
- function Je({ className: e, size: t = "default", ...n }) {
1196
- return /* @__PURE__ */ (0, Q.jsxs)(Ke, { children: [/* @__PURE__ */ (0, Q.jsx)(qe, {}), /* @__PURE__ */ (0, Q.jsx)(E, {
1197
- "data-slot": "alert-dialog-content",
1198
- "data-size": t,
1199
- className: u("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl bg-popover p-6 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", e),
1200
- ...n
1201
- })] });
1202
- }
1203
- function Ye({ className: e, ...t }) {
1204
- return /* @__PURE__ */ (0, Q.jsx)("div", {
1205
- "data-slot": "alert-dialog-header",
1206
- className: u("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]", e),
1207
- ...t
1208
- });
1209
- }
1210
- function Xe({ className: e, ...t }) {
1211
- return /* @__PURE__ */ (0, Q.jsx)("div", {
1212
- "data-slot": "alert-dialog-footer",
1213
- className: u("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end", e),
1214
- ...t
1215
- });
1216
- }
1217
- function Ze({ className: e, ...t }) {
1218
- return /* @__PURE__ */ (0, Q.jsx)(w, {
1219
- "data-slot": "alert-dialog-title",
1220
- className: u("text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2", e),
1221
- ...t
1222
- });
1223
- }
1224
- function Qe({ className: e, ...t }) {
1225
- return /* @__PURE__ */ (0, Q.jsx)(T, {
1226
- "data-slot": "alert-dialog-description",
1227
- className: u("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground", e),
1228
- ...t
1229
- });
1230
- }
1231
- function $e({ className: e, ...t }) {
1232
- return /* @__PURE__ */ (0, Q.jsx)(p, {
1233
- "data-slot": "alert-dialog-action",
1234
- className: u(e),
1235
- ...t
1236
- });
1237
- }
1238
- function et({ className: e, variant: t = "outline", size: n = "default", ...r }) {
1239
- return /* @__PURE__ */ (0, Q.jsx)(S, {
1240
- "data-slot": "alert-dialog-cancel",
1241
- className: u(e),
1242
- render: /* @__PURE__ */ (0, Q.jsx)(p, {
1243
- variant: t,
1244
- size: n
1245
- }),
1246
- ...r
1247
- });
1248
- }
1249
- //#endregion
1250
- //#region src/client/components/tools/useToolExecution.ts
1251
- function tt({ selectedTool: e, payloadToSend: t, toolArgs: n, callTool: r, readResource: i, serverId: a }) {
1252
- let [o, s] = (0, Z.useState)([]), [c, l] = (0, Z.useState)(!1), [u, d] = (0, Z.useState)(null), [f, p] = (0, Z.useState)(null), m = (0, Z.useCallback)(async () => {
1253
- if (!e || c) return;
1254
- let o = new AbortController();
1255
- p(o), l(!0);
1256
- let u = Date.now();
1257
- try {
1258
- let c = t, l = e?._meta || e?.metadata, d = l?.ui?.resourceUri;
1259
- if (d && typeof d == "string") {
1260
- try {
1261
- await i(d);
1262
- } catch {}
1263
- s([{
1264
- toolName: e.name,
1265
- args: c,
1266
- result: null,
1267
- timestamp: u,
1268
- duration: 0,
1269
- toolMeta: l
1270
- }]);
1271
- }
1272
- let f = await r(e.name, c, {
1273
- timeout: 6e5,
1274
- resetTimeoutOnProgress: !0,
1275
- signal: o.signal
1276
- }), p = Date.now() - u, m = f?._meta ?? l;
1277
- me(new J({
1278
- toolName: e.name,
1279
- serverId: a,
1280
- success: !0,
1281
- duration: p
1282
- })).catch(() => {}), window.dispatchEvent(new Event("mcp-tool-executed")), s(d && typeof d == "string" ? (e) => e.map((e, t) => t === 0 ? {
1283
- ...e,
1284
- result: f,
1285
- duration: p,
1286
- toolMeta: m
1287
- } : e) : (t) => [{
1288
- toolName: e.name,
1289
- args: n,
1290
- result: f,
1291
- timestamp: u,
1292
- duration: p,
1293
- toolMeta: m
1294
- }, ...t]);
1295
- } catch (t) {
1296
- let r = Date.now() - u;
1297
- me(new J({
1298
- toolName: e.name,
1299
- serverId: a,
1300
- success: !1,
1301
- duration: r,
1302
- error: t instanceof Error ? t.message : String(t)
1303
- })).catch(() => {}), window.dispatchEvent(new Event("mcp-tool-executed"));
1304
- let i = e?._meta || e?.metadata, o = {
1305
- toolName: e.name,
1306
- args: n,
1307
- result: null,
1308
- error: t instanceof Error ? t.message : String(t),
1309
- timestamp: u,
1310
- duration: r,
1311
- toolMeta: i
1312
- };
1313
- i?.ui?.resourceUri ? s([o]) : s((e) => [o, ...e]);
1314
- } finally {
1315
- l(!1);
1316
- }
1317
- }, [
1318
- e,
1319
- t,
1320
- n,
1321
- c,
1322
- r,
1323
- i,
1324
- a
1325
- ]), h = (0, Z.useCallback)(async (e, t) => {
1326
- try {
1327
- await L(t), d(e), setTimeout(() => d(null), 2e3);
1328
- } catch (e) {
1329
- console.error("[ToolsTab] Failed to copy result:", e);
1330
- }
1331
- }, []), g = (0, Z.useCallback)((e) => {
1332
- s((t) => t.filter((t, n) => n !== e));
1333
- }, []), _ = (0, Z.useMemo)(() => e ? o.filter((t) => t.toolName === e.name) : [], [o, e]);
1334
- return {
1335
- results: o,
1336
- setResults: s,
1337
- isExecuting: c,
1338
- copiedResult: u,
1339
- executeTool: m,
1340
- handleCopyResult: h,
1341
- handleDeleteResult: g,
1342
- handleFullscreen: (0, Z.useCallback)((e) => {
1343
- let t = _[e];
1344
- if (!t) return;
1345
- let n = window.open("", "_blank", "width=800,height=600");
1346
- n && (n.document.write(`
1347
- <html>
1348
- <head><title>${t.toolName} Result</title></head>
1349
- <body><pre>${JSON.stringify(t.result, null, 2)}</pre></body>
1350
- </html>
1351
- `), n.document.close());
1352
- }, [_]),
1353
- filteredResults: _,
1354
- cancelExecution: (0, Z.useCallback)(() => {
1355
- f?.abort(), p(null), l(!1);
1356
- }, [f])
1357
- };
1358
- }
1359
- //#endregion
1360
- //#region src/client/components/tools/useToolsTabNavigation.ts
1361
- function nt({ ref: e, activeTab: t, filteredTools: n, savedRequests: r, searchQuery: i, setSearchQuery: a, selectedTool: o, results: s, isExecuting: c, handleToolSelect: l, loadSavedRequest: u, refreshTools: d, selectedToolName: f, tools: p, setSelectedToolName: m }) {
1362
- let [h, g] = (0, Z.useState)(!1), [_, v] = (0, Z.useState)(-1), y = (0, Z.useRef)(null), [b, x] = (0, Z.useState)(!1), [S, C] = (0, Z.useState)("list"), [w, T] = (0, Z.useState)(!1);
1363
- (0, Z.useEffect)(() => {
1364
- let e = () => x(window.innerWidth < 1024);
1365
- return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
1366
- }, []), (0, Z.useEffect)(() => {
1367
- C(o ? "detail" : "list");
1368
- }, [o]), (0, Z.useEffect)(() => {
1369
- if (!b || s.length === 0) return;
1370
- let e = s[0];
1371
- (!c || e?.result === null) && C("response");
1372
- }, [
1373
- s,
1374
- c,
1375
- b
1376
- ]), (0, Z.useImperativeHandle)(e, () => ({
1377
- focusSearch: () => {
1378
- g(!0), setTimeout(() => y.current?.focus(), 0);
1379
- },
1380
- blurSearch: () => {
1381
- a(""), g(!1), y.current?.blur();
1382
- }
1383
- })), (0, Z.useEffect)(() => {
1384
- h && y.current?.focus();
1385
- }, [h]);
1386
- let E = (0, Z.useCallback)(() => {
1387
- i.trim() || g(!1);
1388
- }, [i]), D = (0, Z.useCallback)(async () => {
1389
- if (d) {
1390
- T(!0);
1391
- try {
1392
- await d();
1393
- } finally {
1394
- T(!1);
1395
- }
1396
- }
1397
- }, [d]);
1398
- return (0, Z.useEffect)(() => {
1399
- t !== "tools" && g(!1);
1400
- }, [t]), (0, Z.useEffect)(() => {
1401
- v(-1);
1402
- }, [i, t]), (0, Z.useEffect)(() => {
1403
- let e = (e) => {
1404
- let i = e.target;
1405
- if (i.tagName === "INPUT" || i.tagName === "TEXTAREA" || i.contentEditable === "true" || e.metaKey || e.ctrlKey || e.altKey) return;
1406
- let a = t === "tools" ? n : r;
1407
- if (e.key === "ArrowDown") e.preventDefault(), v((e) => e + 1 >= a.length ? 0 : e + 1);
1408
- else if (e.key === "ArrowUp") e.preventDefault(), v((e) => e - 1 < 0 ? a.length - 1 : e - 1);
1409
- else if (e.key === "Enter" && _ >= 0) if (e.preventDefault(), t === "tools") {
1410
- let e = n[_];
1411
- e && l(e);
1412
- } else {
1413
- let e = r[_];
1414
- e && u(e);
1415
- }
1416
- };
1417
- return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
1418
- }, [
1419
- _,
1420
- n,
1421
- r,
1422
- t,
1423
- l,
1424
- u
1425
- ]), (0, Z.useEffect)(() => {
1426
- if (_ >= 0) {
1427
- let e = t === "tools" ? `tool-${n[_]?.name}` : `saved-${r[_]?.id}`;
1428
- document.getElementById(e)?.scrollIntoView({
1429
- behavior: "smooth",
1430
- block: "nearest"
1431
- });
1432
- }
1433
- }, [
1434
- _,
1435
- n,
1436
- r,
1437
- t
1438
- ]), (0, Z.useEffect)(() => {
1439
- if (!f || p.length === 0) return;
1440
- let e = p.find((e) => e.name === f);
1441
- if (e) {
1442
- m(null);
1443
- let t = setTimeout(() => {
1444
- l(e), document.getElementById(`tool-${e.name}`)?.scrollIntoView({
1445
- behavior: "smooth",
1446
- block: "nearest"
1447
- });
1448
- }, 100);
1449
- return () => clearTimeout(t);
1450
- }
1451
- }, [
1452
- f,
1453
- p,
1454
- l,
1455
- m
1456
- ]), {
1457
- isSearchExpanded: h,
1458
- setIsSearchExpanded: g,
1459
- focusedIndex: _,
1460
- searchInputRef: y,
1461
- isMobile: b,
1462
- mobileView: S,
1463
- setMobileView: C,
1464
- isRefreshing: w,
1465
- handleSearchBlur: E,
1466
- handleRefresh: D
1467
- };
1468
- }
1469
- //#endregion
1470
- //#region src/client/components/ToolsTab.tsx
1471
- var rt = 200, it = 140;
1472
- function at({ ref: e, tools: t, callTool: n, readResource: i, serverId: a, isConnected: o, refreshTools: s }) {
1473
- let [c, l] = (0, Z.useState)(null), [u, d] = (0, Z.useState)(null), { selectedToolName: f, setSelectedToolName: m } = ve(), [g, _] = (0, Z.useState)({}), [v, y] = (0, Z.useState)(/* @__PURE__ */ new Set()), [b, x] = (0, Z.useState)(/* @__PURE__ */ new Set()), [S, C] = (0, Z.useState)(""), [w, T] = (0, Z.useState)("tools"), { savedRequests: E, saveSavedRequests: D } = ce(), [O, k] = (0, Z.useState)(!1), [A, j] = (0, Z.useState)(""), [M, ee] = (0, Z.useState)(!1), [N, F] = (0, Z.useState)({
1474
- open: !1,
1475
- parsedObject: {},
1476
- fieldsToUpdate: [],
1477
- newFields: [],
1478
- resolve: null
1479
- }), [te, I] = (0, Z.useState)(/* @__PURE__ */ new Set()), L = re(), z = re(), B = re(), V = (0, Z.useRef)(null), ne = (0, Z.useRef)(!1), ie = (0, Z.useRef)(!1), ae = (0, Z.useRef)(!0), oe = (0, Z.useCallback)(() => {
1480
- M ? (L.current && L.current.expand(), z.current && z.current.expand(), ee(!1)) : (L.current && L.current.collapse(), z.current && z.current.collapse(), ee(!0));
1481
- }, [
1482
- M,
1483
- L,
1484
- z
1485
- ]), K = (0, Z.useMemo)(() => {
1486
- if (!S.trim()) return t;
1487
- let e = S.toLowerCase();
1488
- return t.filter((t) => t.name.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e));
1489
- }, [t, S]), se = (0, Z.useCallback)((e) => {
1490
- l(e);
1491
- let t = {}, n = /* @__PURE__ */ new Set();
1492
- e.inputSchema?.properties && Object.entries(e.inputSchema.properties).forEach(([e, r]) => {
1493
- let i = r;
1494
- i.default !== void 0 && (t[e] = i.default, n.add(e));
1495
- }), _(t), y(n), x(/* @__PURE__ */ new Set());
1496
- }, []), le = (0, Z.useCallback)((e) => {
1497
- let n = t.find((t) => t.name === e.toolName);
1498
- n && (l(n), _(e.args), y(new Set(Object.keys(e.args))), x(/* @__PURE__ */ new Set()), d(e));
1499
- }, [t]);
1500
- (0, Z.useEffect)(() => {
1501
- if (c) {
1502
- let e = t.find((e) => e.name === c.name);
1503
- e ? e !== c && (JSON.stringify(e.inputSchema) !== JSON.stringify(c.inputSchema) || e.description !== c.description || JSON.stringify(e?._meta) !== JSON.stringify(c?._meta)) && l(e) : (l(null), m(null));
1504
- }
1505
- }, [
1506
- t,
1507
- c,
1508
- m
1509
- ]);
1510
- let q = (0, Z.useCallback)((e, t) => {
1511
- let n = c?.inputSchema || {}, r = c?.inputSchema?.properties?.[e], i = r ? ke(r, n) : "string", a;
1512
- a = i === "object" || i === "array" || i === "string" ? t : Me(t, i), _((t) => ({
1513
- ...t,
1514
- [e]: a
1515
- }));
1516
- let o = String(t).trim() === "";
1517
- y((t) => {
1518
- let n = new Set(t);
1519
- return o ? n.delete(e) : n.add(e), n;
1520
- }), x((t) => {
1521
- let n = new Set(t);
1522
- return n.delete(e), n;
1523
- });
1524
- }, [c]), de = (0, Z.useCallback)((e, t, n) => {
1525
- if (n) {
1526
- let n = t === "array" ? "[]" : t === "object" ? "{}" : "";
1527
- _((t) => ({
1528
- ...t,
1529
- [e]: n
1530
- })), y((t) => new Set(t).add(e)), x((t) => new Set(t).add(e));
1531
- } else x((t) => {
1532
- let n = new Set(t);
1533
- return n.delete(e), n;
1534
- }), y((t) => {
1535
- let n = new Set(t);
1536
- return n.delete(e), n;
1537
- });
1538
- }, []), fe = (0, Z.useCallback)(async (e, t) => {
1539
- if (!c) return !1;
1540
- let n = Fe(e);
1541
- if (!n) return !1;
1542
- let r = c.inputSchema?.properties || {}, i = Object.keys(r), a = c.inputSchema || {}, o = [], s = [];
1543
- return Object.entries(n).forEach(([e, t]) => {
1544
- if (i.includes(e)) {
1545
- let n = r[e], i = ke(n, a), c = t;
1546
- i === "object" || i === "array" ? typeof t == "object" && t ? c = JSON.stringify(t, null, 2) : typeof t == "string" && (c = t) : c = typeof t == "object" && t ? JSON.stringify(t) : String(t);
1547
- let l = g[e];
1548
- l != null && l !== "" ? o.push({
1549
- key: e,
1550
- oldValue: l,
1551
- newValue: c
1552
- }) : (s.push(e), q(e, String(c)));
1553
- }
1554
- }), o.length === 0 && s.length === 0 ? !1 : o.length === 0 ? (I(new Set(s)), setTimeout(() => I(/* @__PURE__ */ new Set()), 2e3), !0) : new Promise((e) => {
1555
- F({
1556
- open: !0,
1557
- parsedObject: n,
1558
- fieldsToUpdate: o,
1559
- newFields: s,
1560
- resolve: e
1561
- });
1562
- });
1563
- }, [
1564
- c,
1565
- g,
1566
- q
1567
- ]), pe = (0, Z.useCallback)(() => {
1568
- if (!N.resolve) return;
1569
- N.fieldsToUpdate.forEach(({ key: e, newValue: t }) => {
1570
- q(e, String(t));
1571
- });
1572
- let e = [...N.fieldsToUpdate.map((e) => e.key), ...N.newFields];
1573
- I(new Set(e)), setTimeout(() => I(/* @__PURE__ */ new Set()), 2e3), N.resolve(!0), F({
1574
- open: !1,
1575
- parsedObject: {},
1576
- fieldsToUpdate: [],
1577
- newFields: [],
1578
- resolve: null
1579
- });
1580
- }, [N, q]), J = (0, Z.useCallback)(() => {
1581
- N.resolve && (N.resolve(!1), F({
1582
- open: !1,
1583
- parsedObject: {},
1584
- fieldsToUpdate: [],
1585
- newFields: [],
1586
- resolve: null
1587
- }));
1588
- }, [N]), Y = (0, Z.useMemo)(() => {
1589
- if (!c?.inputSchema?.properties) return {};
1590
- let e = c.inputSchema || {}, t = {};
1591
- for (let n of v) {
1592
- let r = c.inputSchema.properties[n];
1593
- if (!r) continue;
1594
- let i = ke(r, e);
1595
- t[n] = Ne(b.has(n) ? i === "array" ? "[]" : i === "object" ? "{}" : "" : g[n], i);
1596
- }
1597
- return t;
1598
- }, [
1599
- c,
1600
- g,
1601
- v,
1602
- b
1603
- ]), { isExecuting: ge, copiedResult: _e, executeTool: X, handleCopyResult: ye, handleDeleteResult: be, handleFullscreen: xe, filteredResults: Ce, cancelExecution: Ee, results: De } = tt({
1604
- selectedTool: c,
1605
- payloadToSend: Y,
1606
- toolArgs: g,
1607
- callTool: n,
1608
- readResource: i,
1609
- serverId: a
1610
- }), Oe = Ce[0]?.timestamp;
1611
- (0, Z.useEffect)(() => {
1612
- ne.current = !1, ae.current = !0;
1613
- let e = requestAnimationFrame(() => {
1614
- ae.current = !1;
1615
- });
1616
- return () => cancelAnimationFrame(e);
1617
- }, [Oe]);
1618
- let Ae = (0, Z.useCallback)(() => {
1619
- ie.current || ae.current || (ne.current = !0);
1620
- }, []), je = (0, Z.useCallback)((e) => {
1621
- if (e === null || M || ne.current) return;
1622
- let t = B.current, n = V.current;
1623
- if (!t || !n) return;
1624
- let r = n.offsetHeight;
1625
- if (r <= 0) return;
1626
- let i = t.getSize().inPixels, a = e + it, o = r - rt;
1627
- if (a <= i || o <= i) return;
1628
- let s = Math.min(a, o);
1629
- s <= i || (ie.current = !0, t.resize(s), requestAnimationFrame(() => {
1630
- ie.current = !1;
1631
- }));
1632
- }, [M, B]), { isSearchExpanded: Pe, setIsSearchExpanded: Ie, focusedIndex: Re, searchInputRef: ze, isMobile: Be, mobileView: $, setMobileView: Ve, isRefreshing: We, handleSearchBlur: Ke, handleRefresh: qe } = nt({
1633
- ref: e,
1634
- activeTab: w,
1635
- filteredTools: K,
1636
- savedRequests: E,
1637
- searchQuery: S,
1638
- setSearchQuery: C,
1639
- selectedTool: c,
1640
- results: De,
1641
- isExecuting: ge,
1642
- handleToolSelect: se,
1643
- loadSavedRequest: le,
1644
- refreshTools: s,
1645
- selectedToolName: f,
1646
- tools: t,
1647
- setSelectedToolName: m
1648
- }), at = (0, Z.useCallback)(() => {
1649
- c && (j(""), k(!0));
1650
- }, [c]), ot = (0, Z.useCallback)(() => {
1651
- if (!c) return;
1652
- let e = {
1653
- id: `${Date.now()}-${Math.random()}`,
1654
- name: A.trim() || `${c.name} - ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
1655
- toolName: c.name,
1656
- args: Y,
1657
- savedAt: Date.now(),
1658
- serverId: c._serverId,
1659
- serverName: c._serverName
1660
- };
1661
- D([...E, e]), me(new he({
1662
- toolName: c.name,
1663
- serverId: a
1664
- })).catch(() => {}), k(!1), j("");
1665
- }, [
1666
- c,
1667
- A,
1668
- Y,
1669
- E,
1670
- D,
1671
- a
1672
- ]), st = (0, Z.useCallback)((e) => {
1673
- D(E.filter((t) => t.id !== e)), u?.id === e && d(null);
1674
- }, [
1675
- E,
1676
- D,
1677
- u
1678
- ]);
1679
- return Be ? /* @__PURE__ */ (0, Q.jsxs)("div", {
1680
- className: "h-full flex flex-col overflow-hidden relative bg-background",
1681
- children: [
1682
- $ !== "list" && /* @__PURE__ */ (0, Q.jsxs)("div", {
1683
- className: "flex items-center gap-2 p-2 border-b shrink-0 bg-background z-10",
1684
- children: [/* @__PURE__ */ (0, Q.jsx)(p, {
1685
- variant: "ghost",
1686
- size: "sm",
1687
- onClick: () => {
1688
- $ === "response" ? Ve("detail") : (l(null), Ve("list"));
1689
- },
1690
- className: "p-0 h-8 w-8",
1691
- children: /* @__PURE__ */ (0, Q.jsx)(R, { className: "h-4 w-4" })
1692
- }), /* @__PURE__ */ (0, Q.jsxs)("div", {
1693
- className: "flex items-center text-sm font-medium",
1694
- children: [
1695
- /* @__PURE__ */ (0, Q.jsx)("button", {
1696
- onClick: () => {
1697
- l(null), Ve("list");
1698
- },
1699
- className: "text-muted-foreground hover:text-foreground hover:underline cursor-pointer",
1700
- children: "Tools"
1701
- }),
1702
- $ === "detail" && /* @__PURE__ */ (0, Q.jsxs)(Q.Fragment, { children: [/* @__PURE__ */ (0, Q.jsx)("span", {
1703
- className: "mx-2 text-muted-foreground",
1704
- children: "/"
1705
- }), /* @__PURE__ */ (0, Q.jsx)("button", {
1706
- onClick: () => {
1707
- Ve("response");
1708
- },
1709
- className: $ === "detail" ? "text-foreground hover:underline" : $ === "response" ? "text-muted-foreground hover:text-foreground hover:underline cursor-pointer" : "text-muted-foreground",
1710
- children: "Execute"
1711
- })] }),
1712
- $ === "response" && /* @__PURE__ */ (0, Q.jsxs)(Q.Fragment, { children: [/* @__PURE__ */ (0, Q.jsx)("span", {
1713
- className: "mx-2 text-muted-foreground",
1714
- children: "/"
1715
- }), /* @__PURE__ */ (0, Q.jsx)("span", {
1716
- className: "text-foreground",
1717
- children: "Response"
1718
- })] })
1719
- ]
1720
- })]
1721
- }),
1722
- /* @__PURE__ */ (0, Q.jsx)("div", {
1723
- className: "flex-1 relative overflow-hidden",
1724
- children: /* @__PURE__ */ (0, Q.jsxs)(h, {
1725
- initial: !1,
1726
- mode: "popLayout",
1727
- children: [
1728
- $ === "list" && /* @__PURE__ */ (0, Q.jsx)(r.div, {
1729
- initial: { x: "-100%" },
1730
- animate: { x: 0 },
1731
- exit: { x: "-100%" },
1732
- transition: {
1733
- type: "spring",
1734
- stiffness: 300,
1735
- damping: 30
1736
- },
1737
- className: "absolute inset-0 flex flex-col bg-background z-0",
1738
- children: /* @__PURE__ */ (0, Q.jsx)(W, { children: (e) => /* @__PURE__ */ (0, Q.jsxs)(Q.Fragment, { children: [/* @__PURE__ */ (0, Q.jsx)(Se, {
1739
- isScrolled: e,
1740
- activeTab: w,
1741
- isSearchExpanded: Pe,
1742
- searchQuery: S,
1743
- primaryTabName: "tools",
1744
- secondaryTabName: "saved",
1745
- primaryTabTitle: "Tools",
1746
- secondaryTabTitle: "Saved",
1747
- primaryCount: K.length,
1748
- secondaryCount: E.length,
1749
- primaryIcon: ue,
1750
- secondaryIcon: P,
1751
- searchPlaceholder: "Search tools...",
1752
- onSearchExpand: () => Ie(!0),
1753
- onSearchChange: C,
1754
- onSearchBlur: Ke,
1755
- onTabSwitch: () => T(w === "tools" ? "saved" : "tools"),
1756
- searchInputRef: ze,
1757
- onRefresh: s ? qe : void 0,
1758
- isRefreshing: We
1759
- }), w === "tools" ? /* @__PURE__ */ (0, Q.jsx)(Ue, {
1760
- tools: K,
1761
- selectedTool: c,
1762
- onToolSelect: se,
1763
- focusedIndex: Re
1764
- }) : /* @__PURE__ */ (0, Q.jsx)(we, {
1765
- savedRequests: E,
1766
- selectedRequest: u,
1767
- onLoadRequest: le,
1768
- onDeleteRequest: st,
1769
- focusedIndex: Re
1770
- })] }) })
1771
- }, "list"),
1772
- $ === "detail" && /* @__PURE__ */ (0, Q.jsx)(r.div, {
1773
- initial: { x: "100%" },
1774
- animate: { x: 0 },
1775
- exit: { x: "-100%" },
1776
- transition: {
1777
- type: "spring",
1778
- stiffness: 300,
1779
- damping: 30
1780
- },
1781
- className: "absolute inset-0 bg-background z-10",
1782
- children: /* @__PURE__ */ (0, Q.jsx)(Le, {
1783
- selectedTool: c,
1784
- toolArgs: g,
1785
- payloadToSend: Y,
1786
- isExecuting: ge,
1787
- isConnected: o,
1788
- onArgChange: q,
1789
- onExecute: X,
1790
- onSave: at,
1791
- onBulkPaste: fe,
1792
- autoFilledFields: te,
1793
- setFields: v,
1794
- sendEmptyFields: b,
1795
- onToggleEmpty: de
1796
- })
1797
- }, "detail"),
1798
- $ === "response" && /* @__PURE__ */ (0, Q.jsx)(r.div, {
1799
- initial: { x: "100%" },
1800
- animate: { x: 0 },
1801
- exit: { x: "100%" },
1802
- transition: {
1803
- type: "spring",
1804
- stiffness: 300,
1805
- damping: 30
1806
- },
1807
- className: "absolute inset-0 bg-background z-20",
1808
- children: /* @__PURE__ */ (0, Q.jsx)(He, {
1809
- results: Ce,
1810
- copiedResult: _e,
1811
- serverId: a,
1812
- readResource: i,
1813
- onCopy: ye,
1814
- onDelete: be,
1815
- onFullscreen: xe,
1816
- onRerunTool: X
1817
- })
1818
- }, "response")
1819
- ]
1820
- })
1821
- }),
1822
- /* @__PURE__ */ (0, Q.jsx)(Te, {
1823
- isOpen: O,
1824
- requestName: A,
1825
- defaultPlaceholder: `${c?.name} - ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
1826
- onRequestNameChange: j,
1827
- onSave: ot,
1828
- onCancel: () => k(!1)
1829
- }),
1830
- /* @__PURE__ */ (0, Q.jsx)(Ge, {
1831
- open: N.open,
1832
- onOpenChange: (e) => {
1833
- e || J();
1834
- },
1835
- children: /* @__PURE__ */ (0, Q.jsxs)(Je, { children: [/* @__PURE__ */ (0, Q.jsxs)(Ye, { children: [/* @__PURE__ */ (0, Q.jsx)(Ze, { children: "Auto-fill fields from pasted object?" }), /* @__PURE__ */ (0, Q.jsxs)(Qe, { children: [N.fieldsToUpdate.length > 0 && /* @__PURE__ */ (0, Q.jsxs)("div", {
1836
- className: "mb-3",
1837
- children: [/* @__PURE__ */ (0, Q.jsx)("p", {
1838
- className: "font-medium mb-2",
1839
- children: "The following fields will be updated:"
1840
- }), /* @__PURE__ */ (0, Q.jsx)("ul", {
1841
- className: "text-sm space-y-1 max-h-[200px] overflow-y-auto",
1842
- children: N.fieldsToUpdate.map(({ key: e, oldValue: t, newValue: n }) => /* @__PURE__ */ (0, Q.jsxs)("li", {
1843
- className: "font-mono",
1844
- children: [
1845
- /* @__PURE__ */ (0, Q.jsxs)("span", {
1846
- className: "font-semibold",
1847
- children: [e, ":"]
1848
- }),
1849
- " ",
1850
- /* @__PURE__ */ (0, Q.jsx)("span", {
1851
- className: "text-red-600 dark:text-red-400 line-through",
1852
- children: typeof t == "object" ? JSON.stringify(t).substring(0, 30) + "..." : String(t).substring(0, 30)
1853
- }),
1854
- " ",
1855
- "→",
1856
- " ",
1857
- /* @__PURE__ */ (0, Q.jsx)("span", {
1858
- className: "text-green-600 dark:text-green-400",
1859
- children: typeof n == "string" && n.length > 30 ? n.substring(0, 30) + "..." : String(n).substring(0, 30)
1860
- })
1861
- ]
1862
- }, e))
1863
- })]
1864
- }), N.newFields.length > 0 && /* @__PURE__ */ (0, Q.jsxs)("div", { children: [/* @__PURE__ */ (0, Q.jsx)("p", {
1865
- className: "font-medium mb-1",
1866
- children: "New fields to be filled:"
1867
- }), /* @__PURE__ */ (0, Q.jsx)("p", {
1868
- className: "text-sm font-mono",
1869
- children: N.newFields.join(", ")
1870
- })] })] })] }), /* @__PURE__ */ (0, Q.jsxs)(Xe, { children: [/* @__PURE__ */ (0, Q.jsx)(et, {
1871
- onClick: J,
1872
- children: "Cancel"
1873
- }), /* @__PURE__ */ (0, Q.jsx)($e, {
1874
- onClick: pe,
1875
- children: "Auto-fill"
1876
- })] })] })
1877
- })
1878
- ]
1879
- }) : /* @__PURE__ */ (0, Q.jsxs)(G, {
1880
- orientation: "horizontal",
1881
- className: "h-full",
1882
- children: [
1883
- /* @__PURE__ */ (0, Q.jsx)(H, {
1884
- id: "left-panel",
1885
- defaultSize: "33%",
1886
- minSize: 250,
1887
- collapsedSize: 0,
1888
- collapsible: !0,
1889
- className: "flex flex-col h-full relative",
1890
- panelRef: L,
1891
- children: /* @__PURE__ */ (0, Q.jsx)("div", {
1892
- className: "flex h-full flex-col overflow-hidden",
1893
- children: /* @__PURE__ */ (0, Q.jsx)(W, { children: (e) => /* @__PURE__ */ (0, Q.jsxs)(Q.Fragment, { children: [/* @__PURE__ */ (0, Q.jsx)(Se, {
1894
- isScrolled: e,
1895
- activeTab: w,
1896
- isSearchExpanded: Pe,
1897
- searchQuery: S,
1898
- primaryTabName: "tools",
1899
- secondaryTabName: "saved",
1900
- primaryTabTitle: "Tools",
1901
- secondaryTabTitle: "Saved",
1902
- primaryCount: K.length,
1903
- secondaryCount: E.length,
1904
- primaryIcon: ue,
1905
- secondaryIcon: P,
1906
- searchPlaceholder: "Search tools...",
1907
- onSearchExpand: () => Ie(!0),
1908
- onSearchChange: C,
1909
- onSearchBlur: Ke,
1910
- onTabSwitch: () => T(w === "tools" ? "saved" : "tools"),
1911
- searchInputRef: ze,
1912
- onRefresh: s ? qe : void 0,
1913
- isRefreshing: We
1914
- }), w === "tools" ? /* @__PURE__ */ (0, Q.jsx)(Ue, {
1915
- tools: K,
1916
- selectedTool: c,
1917
- onToolSelect: se,
1918
- focusedIndex: Re
1919
- }) : /* @__PURE__ */ (0, Q.jsx)(we, {
1920
- savedRequests: E,
1921
- selectedRequest: u,
1922
- onLoadRequest: le,
1923
- onDeleteRequest: st,
1924
- focusedIndex: Re
1925
- })] }) })
1926
- })
1927
- }),
1928
- /* @__PURE__ */ (0, Q.jsx)(U, { withHandle: !0 }),
1929
- /* @__PURE__ */ (0, Q.jsx)(H, {
1930
- defaultSize: "67%",
1931
- children: /* @__PURE__ */ (0, Q.jsxs)(G, {
1932
- orientation: "vertical",
1933
- elementRef: V,
1934
- onLayoutChanged: Ae,
1935
- children: [
1936
- /* @__PURE__ */ (0, Q.jsx)(H, {
1937
- id: "tool-params",
1938
- defaultSize: "40%",
1939
- minSize: `${rt}px`,
1940
- collapsible: !0,
1941
- panelRef: z,
1942
- children: /* @__PURE__ */ (0, Q.jsx)(Le, {
1943
- selectedTool: c,
1944
- toolArgs: g,
1945
- payloadToSend: Y,
1946
- isExecuting: ge,
1947
- isConnected: o,
1948
- onArgChange: q,
1949
- onExecute: X,
1950
- onSave: at,
1951
- onCancel: Ee,
1952
- onBulkPaste: fe,
1953
- autoFilledFields: te,
1954
- setFields: v,
1955
- sendEmptyFields: b,
1956
- onToggleEmpty: de
1957
- })
1958
- }),
1959
- /* @__PURE__ */ (0, Q.jsx)(U, { withHandle: !0 }),
1960
- /* @__PURE__ */ (0, Q.jsx)(H, {
1961
- id: "tool-result",
1962
- defaultSize: "60%",
1963
- panelRef: B,
1964
- children: /* @__PURE__ */ (0, Q.jsx)("div", {
1965
- className: "flex flex-col h-full",
1966
- children: /* @__PURE__ */ (0, Q.jsx)(He, {
1967
- results: Ce,
1968
- copiedResult: _e,
1969
- serverId: a,
1970
- readResource: i,
1971
- onCopy: ye,
1972
- onDelete: be,
1973
- onFullscreen: xe,
1974
- onMaximize: oe,
1975
- isMaximized: M,
1976
- onRerunTool: X,
1977
- onWidgetHeightChange: je
1978
- })
1979
- })
1980
- })
1981
- ]
1982
- })
1983
- }),
1984
- /* @__PURE__ */ (0, Q.jsx)(Te, {
1985
- isOpen: O,
1986
- requestName: A,
1987
- defaultPlaceholder: `${c?.name} - ${(/* @__PURE__ */ new Date()).toLocaleString()}`,
1988
- onRequestNameChange: j,
1989
- onSave: ot,
1990
- onCancel: () => k(!1)
1991
- }),
1992
- /* @__PURE__ */ (0, Q.jsx)(Ge, {
1993
- open: N.open,
1994
- onOpenChange: (e) => {
1995
- e || J();
1996
- },
1997
- children: /* @__PURE__ */ (0, Q.jsxs)(Je, { children: [/* @__PURE__ */ (0, Q.jsxs)(Ye, { children: [/* @__PURE__ */ (0, Q.jsx)(Ze, { children: "Auto-fill fields from pasted object?" }), /* @__PURE__ */ (0, Q.jsxs)(Qe, { children: [N.fieldsToUpdate.length > 0 && /* @__PURE__ */ (0, Q.jsxs)("div", {
1998
- className: "mb-3",
1999
- children: [/* @__PURE__ */ (0, Q.jsx)("p", {
2000
- className: "font-medium mb-2",
2001
- children: "The following fields will be updated:"
2002
- }), /* @__PURE__ */ (0, Q.jsx)("ul", {
2003
- className: "text-sm space-y-1 max-h-[200px] overflow-y-auto",
2004
- children: N.fieldsToUpdate.map(({ key: e, oldValue: t, newValue: n }) => /* @__PURE__ */ (0, Q.jsxs)("li", {
2005
- className: "font-mono",
2006
- children: [
2007
- /* @__PURE__ */ (0, Q.jsxs)("span", {
2008
- className: "font-semibold",
2009
- children: [e, ":"]
2010
- }),
2011
- " ",
2012
- /* @__PURE__ */ (0, Q.jsx)("span", {
2013
- className: "text-red-600 dark:text-red-400 line-through",
2014
- children: typeof t == "object" ? JSON.stringify(t).substring(0, 30) + "..." : String(t).substring(0, 30)
2015
- }),
2016
- " ",
2017
- "→",
2018
- " ",
2019
- /* @__PURE__ */ (0, Q.jsx)("span", {
2020
- className: "text-green-600 dark:text-green-400",
2021
- children: typeof n == "string" && n.length > 30 ? n.substring(0, 30) + "..." : String(n).substring(0, 30)
2022
- })
2023
- ]
2024
- }, e))
2025
- })]
2026
- }), N.newFields.length > 0 && /* @__PURE__ */ (0, Q.jsxs)("div", { children: [/* @__PURE__ */ (0, Q.jsx)("p", {
2027
- className: "font-medium mb-1",
2028
- children: "New fields to be filled:"
2029
- }), /* @__PURE__ */ (0, Q.jsx)("p", {
2030
- className: "text-sm font-mono",
2031
- children: N.newFields.join(", ")
2032
- })] })] })] }), /* @__PURE__ */ (0, Q.jsxs)(Xe, { children: [/* @__PURE__ */ (0, Q.jsx)(et, {
2033
- onClick: J,
2034
- children: "Cancel"
2035
- }), /* @__PURE__ */ (0, Q.jsx)($e, {
2036
- onClick: pe,
2037
- children: "Auto-fill"
2038
- })] })] })
2039
- })
2040
- ]
2041
- });
2042
- }
2043
- at.displayName = "ToolsTab";
2044
- //#endregion
2045
- export { at as ToolsTab };