@mcp-use/inspector 20.0.0-beta.3 → 20.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/{ChatTab-BS5Tlm2y.js → ChatTab-UQAPDRQG.js} +6 -6
- package/dist/cdn/{ConnectionSettingsForm-BFsZpwK4.js → ConnectionSettingsForm-DrY1p-NO.js} +1 -1
- package/dist/cdn/{ConnectionSettingsTab-DDk06dhT.js → ConnectionSettingsTab-B1cRD7hz.js} +1 -1
- package/dist/cdn/{MarkdownRenderer-_aYcof42.js → MarkdownRenderer-BoDJE8tP.js} +1 -1
- package/dist/cdn/{OAuthCallback-C4n2hqKU.js → OAuthCallback-C9AvCkOn.js} +1 -1
- package/dist/cdn/{PromptsTab-BajHFLa3.js → PromptsTab-CkAWyWVb.js} +1 -1
- package/dist/cdn/{ResourcesTab-BgeMlTdR.js → ResourcesTab-BtBKxd4c.js} +5 -5
- package/dist/cdn/{SamplingTab-CnJB229N.js → SamplingTab-Czp7Rmhz.js} +3 -3
- package/dist/cdn/{ToolsTab-ACLxPxR6.js → ToolsTab-Dm4vCB8D.js} +4 -4
- package/dist/cdn/{ViewPreview-DsPwZAwO.js → ViewPreview-CZvl_7x-.js} +4 -3
- package/dist/cdn/{WidgetWrapper-CwlpDv17.js → WidgetWrapper-DeiogRXV.js} +2 -2
- package/dist/cdn/{dist-B0eL32Gb.js → dist-3QLh0dt8.js} +3 -3
- package/dist/cdn/{index-browser-QDjRGsPo.js → index-browser-CIoYSwCt.js} +1 -1
- package/dist/cdn/inspector.js +5 -5
- package/dist/cdn/{react-Dn8PWXwP.js → react-0oJnFpBS.js} +593 -585
- package/dist/cdn/{telemetry-gHF-tMli.js → telemetry-BbhH1Z_E.js} +2 -2
- package/dist/cdn/{useConfig-BWcNCqwi.js → useConfig-BNpU7Atw.js} +2 -2
- package/dist/cdn/{useViewHostProps-DIIlz3tJ.js → useViewHostProps-ru80AnlT.js} +3 -2
- package/dist/cli.js +1 -1
- package/dist/client/hooks/useViewHostProps.d.ts +1 -1
- package/dist/client/hooks/useViewHostProps.d.ts.map +1 -1
- package/dist/client/index.js +2 -1
- package/dist/server/cdn-shell.js +2 -2
- package/dist/server/{chunk-W3PVQLOP.js → chunk-5L3HMC5B.js} +1 -1
- package/dist/server/{chunk-HGPQON3P.js → chunk-BEJGHVKM.js} +1 -1
- package/dist/server/{chunk-H7UBATRR.js → chunk-PGN3B3MQ.js} +1 -1
- package/dist/server/cli.js +2 -2
- package/dist/server/index.js +3 -3
- package/dist/server/middleware.js +3 -3
- package/dist/server/version.js +1 -1
- package/dist/web/assets/{ChatTab-C2FtENBM.js → ChatTab-B_5S87J1.js} +1 -1
- package/dist/web/assets/{ConnectionSettingsTab-B2sUjytG.js → ConnectionSettingsTab-XwjwKfsO.js} +1 -1
- package/dist/web/assets/{ElicitationTab-DwH08kDC.js → ElicitationTab-BD1tfmYR.js} +1 -1
- package/dist/web/assets/{ManufactOAuthCallback-Btu4B6u6.js → ManufactOAuthCallback-DD3qfIC3.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-DpIEt9wb.js → MarkdownRenderer-DH-7vpw0.js} +1 -1
- package/dist/web/assets/{NotificationsTab-CHB8mtSz.js → NotificationsTab-Cg48O6IH.js} +1 -1
- package/dist/web/assets/{OAuthCallback-DV4MgX4Z.js → OAuthCallback-4i2i3YpE.js} +1 -1
- package/dist/web/assets/{PromptsTab-0GIapoSs.js → PromptsTab-pAR6izrQ.js} +1 -1
- package/dist/web/assets/{ResourcesTab-N9xjsI_b.js → ResourcesTab-CgvfWrsU.js} +1 -1
- package/dist/web/assets/{SamplingTab-Dw0vpi4t.js → SamplingTab-DfIWMQFY.js} +1 -1
- package/dist/web/assets/{ServerMetadataTab-D-eQpLBF.js → ServerMetadataTab-Dsz8Qhyr.js} +1 -1
- package/dist/web/assets/{ToolsTab-BMrMJ5JV.js → ToolsTab-ln9w58BW.js} +1 -1
- package/dist/web/assets/{ViewPreview-N_cpEO0W.js → ViewPreview-CQ3G3VP0.js} +1 -1
- package/dist/web/assets/{WidgetWrapper-pDgNVq9y.js → WidgetWrapper-A-zaxY5s.js} +1 -1
- package/dist/web/assets/{checkbox-CrnXSMh2.js → checkbox-DZWS_U_i.js} +1 -1
- package/dist/web/assets/{dist-CeWSydFI.js → dist-DxRFPg-B.js} +4 -4
- package/dist/web/assets/{index-Cfuv_gb3.js → index-CoRK2C3M.js} +30 -13
- package/dist/web/assets/{shared-B1GD9FMm.js → shared-Dbc2GbRx.js} +1 -1
- package/dist/web/assets/{tabs-subtle-CG5cjC_N.js → tabs-subtle-CxMZqhP6.js} +1 -1
- package/dist/web/assets/{useConfig-BTp15Lle.js → useConfig-Cg-BtSHA.js} +1 -1
- package/dist/web/assets/{useViewHostProps-BQlaFC2Q.js → useViewHostProps-CMgPpdfy.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +4 -4
|
@@ -1,144 +1,144 @@
|
|
|
1
1
|
import { a as e, s as t, t as n } from "./react-BIs9pQ3H.js";
|
|
2
|
-
import { A as r, C as i, D as a, E as o, I as s, M as c, N as l, O as u, P as d, S as f, T as p, _ as m, a as h, b as g, c as _, d as v, f as ee, g as te, h as y, i as b, j as x, k as S, l as C, m as ne, n as w, o as re, p as T, r as E, s as
|
|
2
|
+
import { A as r, C as i, D as a, E as o, I as s, M as c, N as l, O as u, P as d, S as f, T as p, _ as m, a as h, b as g, c as _, d as v, f as ee, g as te, h as y, i as b, j as x, k as S, l as C, m as ne, n as w, o as re, p as T, r as E, s as ie, t as D, v as O, w as k, x as ae, y as A } from "./cfWorker-Bxcs9rNe.js";
|
|
3
3
|
//#region ../../node_modules/.pnpm/@modelcontextprotocol+core@2.0.0-beta.4/node_modules/@modelcontextprotocol/core/dist/auth-DFgbUATV.mjs
|
|
4
|
-
var
|
|
4
|
+
var j = /* @__PURE__ */ t(n(), 1), oe = "io.modelcontextprotocol/related-task", M = "io.modelcontextprotocol/subscriptionId", N = ae(() => x([
|
|
5
5
|
r(),
|
|
6
6
|
p(),
|
|
7
|
-
|
|
7
|
+
O(),
|
|
8
8
|
ne(),
|
|
9
|
-
S(r(),
|
|
10
|
-
m(
|
|
11
|
-
])),
|
|
12
|
-
m(
|
|
13
|
-
var
|
|
14
|
-
progressToken:
|
|
15
|
-
[
|
|
16
|
-
}),
|
|
9
|
+
S(r(), N),
|
|
10
|
+
m(N)
|
|
11
|
+
])), P = S(r(), N);
|
|
12
|
+
m(N);
|
|
13
|
+
var se = x([r(), p().int()]), F = r(), ce = o({ ttl: p().optional() }), le = o({ taskId: r() }), ue = i({
|
|
14
|
+
progressToken: se.optional(),
|
|
15
|
+
[oe]: le.optional()
|
|
16
|
+
}), I = o({ _meta: ue.optional() }), de = I.extend({ task: ce.optional() }), L = o({
|
|
17
17
|
method: r(),
|
|
18
|
-
params:
|
|
19
|
-
}),
|
|
18
|
+
params: I.loose().optional()
|
|
19
|
+
}), R = o({ _meta: ue.optional() }), z = o({
|
|
20
20
|
method: r(),
|
|
21
|
-
params:
|
|
22
|
-
}),
|
|
21
|
+
params: R.loose().optional()
|
|
22
|
+
}), B = i({ _meta: ue.optional() }), fe = x([r(), p().int()]), pe = o({
|
|
23
23
|
jsonrpc: f("2.0"),
|
|
24
|
-
id:
|
|
25
|
-
...
|
|
26
|
-
}).strict(), pe = o({
|
|
27
|
-
jsonrpc: f("2.0"),
|
|
28
|
-
...B.shape
|
|
24
|
+
id: fe,
|
|
25
|
+
...L.shape
|
|
29
26
|
}).strict(), me = o({
|
|
30
27
|
jsonrpc: f("2.0"),
|
|
31
|
-
|
|
32
|
-
result: V
|
|
28
|
+
...z.shape
|
|
33
29
|
}).strict(), he = o({
|
|
34
30
|
jsonrpc: f("2.0"),
|
|
35
|
-
id:
|
|
31
|
+
id: fe,
|
|
32
|
+
result: B
|
|
33
|
+
}).strict(), ge = o({
|
|
34
|
+
jsonrpc: f("2.0"),
|
|
35
|
+
id: fe.optional(),
|
|
36
36
|
error: o({
|
|
37
37
|
code: p().int(),
|
|
38
38
|
message: r(),
|
|
39
39
|
data: c().optional()
|
|
40
40
|
})
|
|
41
|
-
}).strict(),
|
|
42
|
-
fe,
|
|
41
|
+
}).strict(), _e = x([
|
|
43
42
|
pe,
|
|
44
43
|
me,
|
|
45
|
-
he
|
|
44
|
+
he,
|
|
45
|
+
ge
|
|
46
46
|
]);
|
|
47
|
-
x([
|
|
48
|
-
var
|
|
49
|
-
requestId:
|
|
47
|
+
x([he, ge]);
|
|
48
|
+
var ve = B.strict(), ye = R.extend({
|
|
49
|
+
requestId: fe.optional(),
|
|
50
50
|
reason: r().optional()
|
|
51
|
-
}),
|
|
51
|
+
}), be = z.extend({
|
|
52
52
|
method: f("notifications/cancelled"),
|
|
53
|
-
params:
|
|
54
|
-
}),
|
|
53
|
+
params: ye
|
|
54
|
+
}), xe = o({ icons: m(o({
|
|
55
55
|
src: r(),
|
|
56
56
|
mimeType: r().optional(),
|
|
57
57
|
sizes: m(r()).optional(),
|
|
58
58
|
theme: T(["light", "dark"]).optional()
|
|
59
|
-
})).optional() }),
|
|
59
|
+
})).optional() }), V = o({
|
|
60
60
|
name: r(),
|
|
61
61
|
title: r().optional()
|
|
62
|
-
}),
|
|
63
|
-
...
|
|
64
|
-
...
|
|
62
|
+
}), Se = V.extend({
|
|
63
|
+
...V.shape,
|
|
64
|
+
...xe.shape,
|
|
65
65
|
version: r(),
|
|
66
66
|
websiteUrl: r().optional(),
|
|
67
67
|
description: r().optional()
|
|
68
|
-
}),
|
|
69
|
-
form: g(o({ applyDefaults:
|
|
70
|
-
url:
|
|
71
|
-
}),
|
|
72
|
-
list:
|
|
73
|
-
cancel:
|
|
68
|
+
}), Ce = u((e) => e && typeof e == "object" && !Array.isArray(e) && Object.keys(e).length === 0 ? { form: {} } : e, g(o({
|
|
69
|
+
form: g(o({ applyDefaults: O().optional() }), P).optional(),
|
|
70
|
+
url: P.optional()
|
|
71
|
+
}), P.optional())), we = i({
|
|
72
|
+
list: P.optional(),
|
|
73
|
+
cancel: P.optional(),
|
|
74
74
|
requests: i({
|
|
75
|
-
sampling: i({ createMessage:
|
|
76
|
-
elicitation: i({ create:
|
|
75
|
+
sampling: i({ createMessage: P.optional() }).optional(),
|
|
76
|
+
elicitation: i({ create: P.optional() }).optional()
|
|
77
77
|
}).optional()
|
|
78
|
-
}),
|
|
79
|
-
list:
|
|
80
|
-
cancel:
|
|
81
|
-
requests: i({ tools: i({ call:
|
|
82
|
-
}),
|
|
83
|
-
experimental: S(r(),
|
|
78
|
+
}), Te = i({
|
|
79
|
+
list: P.optional(),
|
|
80
|
+
cancel: P.optional(),
|
|
81
|
+
requests: i({ tools: i({ call: P.optional() }).optional() }).optional()
|
|
82
|
+
}), Ee = o({
|
|
83
|
+
experimental: S(r(), P).optional(),
|
|
84
84
|
sampling: o({
|
|
85
|
-
context:
|
|
86
|
-
tools:
|
|
85
|
+
context: P.optional(),
|
|
86
|
+
tools: P.optional()
|
|
87
87
|
}).optional(),
|
|
88
|
-
elicitation:
|
|
89
|
-
roots: o({ listChanged:
|
|
90
|
-
tasks:
|
|
91
|
-
extensions: S(r(),
|
|
92
|
-
}),
|
|
88
|
+
elicitation: Ce.optional(),
|
|
89
|
+
roots: o({ listChanged: O().optional() }).optional(),
|
|
90
|
+
tasks: we.optional(),
|
|
91
|
+
extensions: S(r(), P).optional()
|
|
92
|
+
}), De = I.extend({
|
|
93
93
|
protocolVersion: r(),
|
|
94
|
-
capabilities:
|
|
95
|
-
clientInfo:
|
|
96
|
-
}),
|
|
94
|
+
capabilities: Ee,
|
|
95
|
+
clientInfo: Se
|
|
96
|
+
}), Oe = L.extend({
|
|
97
97
|
method: f("initialize"),
|
|
98
|
-
params:
|
|
99
|
-
}),
|
|
100
|
-
experimental: S(r(),
|
|
101
|
-
logging:
|
|
102
|
-
completions:
|
|
103
|
-
prompts: o({ listChanged:
|
|
98
|
+
params: De
|
|
99
|
+
}), ke = o({
|
|
100
|
+
experimental: S(r(), P).optional(),
|
|
101
|
+
logging: P.optional(),
|
|
102
|
+
completions: P.optional(),
|
|
103
|
+
prompts: o({ listChanged: O().optional() }).optional(),
|
|
104
104
|
resources: o({
|
|
105
|
-
subscribe:
|
|
106
|
-
listChanged:
|
|
105
|
+
subscribe: O().optional(),
|
|
106
|
+
listChanged: O().optional()
|
|
107
107
|
}).optional(),
|
|
108
|
-
tools: o({ listChanged:
|
|
109
|
-
tasks:
|
|
110
|
-
extensions: S(r(),
|
|
111
|
-
}),
|
|
108
|
+
tools: o({ listChanged: O().optional() }).optional(),
|
|
109
|
+
tasks: Te.optional(),
|
|
110
|
+
extensions: S(r(), P).optional()
|
|
111
|
+
}), Ae = B.extend({
|
|
112
112
|
protocolVersion: r(),
|
|
113
|
-
capabilities:
|
|
114
|
-
serverInfo:
|
|
113
|
+
capabilities: ke,
|
|
114
|
+
serverInfo: Se,
|
|
115
115
|
instructions: r().optional()
|
|
116
|
-
}),
|
|
116
|
+
}), je = z.extend({
|
|
117
117
|
method: f("notifications/initialized"),
|
|
118
|
-
params:
|
|
119
|
-
}),
|
|
118
|
+
params: R.optional()
|
|
119
|
+
}), Me = L.extend({
|
|
120
120
|
method: f("server/discover"),
|
|
121
|
-
params:
|
|
122
|
-
}),
|
|
121
|
+
params: I.optional()
|
|
122
|
+
}), Ne = B.extend({
|
|
123
123
|
supportedVersions: m(r()),
|
|
124
|
-
capabilities:
|
|
125
|
-
serverInfo:
|
|
124
|
+
capabilities: ke,
|
|
125
|
+
serverInfo: Se,
|
|
126
126
|
instructions: r().optional()
|
|
127
|
-
}),
|
|
127
|
+
}), Pe = L.extend({
|
|
128
128
|
method: f("ping"),
|
|
129
|
-
params:
|
|
130
|
-
}),
|
|
129
|
+
params: I.optional()
|
|
130
|
+
}), Fe = o({
|
|
131
131
|
progress: p(),
|
|
132
132
|
total: a(p()),
|
|
133
133
|
message: a(r())
|
|
134
|
-
}),
|
|
135
|
-
...
|
|
136
|
-
...
|
|
137
|
-
progressToken:
|
|
138
|
-
}), Ie =
|
|
134
|
+
}), H = o({
|
|
135
|
+
...R.shape,
|
|
136
|
+
...Fe.shape,
|
|
137
|
+
progressToken: se
|
|
138
|
+
}), Ie = z.extend({
|
|
139
139
|
method: f("notifications/progress"),
|
|
140
|
-
params:
|
|
141
|
-
}), Le =
|
|
140
|
+
params: H
|
|
141
|
+
}), Le = I.extend({ cursor: F.optional() }), U = L.extend({ params: Le.optional() }), Re = B.extend({ nextCursor: F.optional() }), W = o({
|
|
142
142
|
uri: r(),
|
|
143
143
|
mimeType: a(r()),
|
|
144
144
|
_meta: S(r(), c()).optional()
|
|
@@ -153,8 +153,8 @@ var _e = V.strict(), ve = z.extend({
|
|
|
153
153
|
priority: p().min(0).max(1).optional(),
|
|
154
154
|
lastModified: d({ offset: !0 }).optional()
|
|
155
155
|
}), He = o({
|
|
156
|
-
...
|
|
157
|
-
...
|
|
156
|
+
...V.shape,
|
|
157
|
+
...xe.shape,
|
|
158
158
|
uri: r(),
|
|
159
159
|
description: a(r()),
|
|
160
160
|
mimeType: a(r()),
|
|
@@ -162,53 +162,53 @@ var _e = V.strict(), ve = z.extend({
|
|
|
162
162
|
annotations: Ve.optional(),
|
|
163
163
|
_meta: a(i({}))
|
|
164
164
|
}), Ue = o({
|
|
165
|
-
...
|
|
166
|
-
...
|
|
165
|
+
...V.shape,
|
|
166
|
+
...xe.shape,
|
|
167
167
|
uriTemplate: r(),
|
|
168
168
|
description: a(r()),
|
|
169
169
|
mimeType: a(r()),
|
|
170
170
|
annotations: Ve.optional(),
|
|
171
171
|
_meta: a(i({}))
|
|
172
|
-
}), We = U.extend({ method: f("resources/list") }), q = Re.extend({ resources: m(He) }), Ge = U.extend({ method: f("resources/templates/list") }), Ke = Re.extend({ resourceTemplates: m(Ue) }), qe =
|
|
172
|
+
}), We = U.extend({ method: f("resources/list") }), q = Re.extend({ resources: m(He) }), Ge = U.extend({ method: f("resources/templates/list") }), Ke = Re.extend({ resourceTemplates: m(Ue) }), qe = I.extend({ uri: r() }), Je = qe, Ye = L.extend({
|
|
173
173
|
method: f("resources/read"),
|
|
174
174
|
params: Je
|
|
175
|
-
}), Xe =
|
|
175
|
+
}), Xe = B.extend({ contents: m(x([ze, K])) }), Ze = z.extend({
|
|
176
176
|
method: f("notifications/resources/list_changed"),
|
|
177
|
-
params:
|
|
178
|
-
}), Qe = qe, $e =
|
|
177
|
+
params: R.optional()
|
|
178
|
+
}), Qe = qe, $e = L.extend({
|
|
179
179
|
method: f("resources/subscribe"),
|
|
180
180
|
params: Qe
|
|
181
|
-
}), et = qe, tt =
|
|
181
|
+
}), et = qe, tt = L.extend({
|
|
182
182
|
method: f("resources/unsubscribe"),
|
|
183
183
|
params: et
|
|
184
184
|
}), nt = o({
|
|
185
|
-
toolsListChanged:
|
|
186
|
-
promptsListChanged:
|
|
187
|
-
resourcesListChanged:
|
|
185
|
+
toolsListChanged: O().optional(),
|
|
186
|
+
promptsListChanged: O().optional(),
|
|
187
|
+
resourcesListChanged: O().optional(),
|
|
188
188
|
resourceSubscriptions: m(r()).optional()
|
|
189
|
-
}), J =
|
|
189
|
+
}), J = I.extend({ notifications: nt }), rt = L.extend({
|
|
190
190
|
method: f("subscriptions/listen"),
|
|
191
191
|
params: J
|
|
192
|
-
}), it =
|
|
192
|
+
}), it = R.extend({ notifications: nt }), Y = z.extend({
|
|
193
193
|
method: f("notifications/subscriptions/acknowledged"),
|
|
194
194
|
params: it
|
|
195
|
-
}), at = i({ [
|
|
195
|
+
}), at = i({ [M]: fe }), ot = B.extend({ _meta: at }), st = R.extend({ uri: r() }), ct = z.extend({
|
|
196
196
|
method: f("notifications/resources/updated"),
|
|
197
197
|
params: st
|
|
198
198
|
}), lt = o({
|
|
199
199
|
name: r(),
|
|
200
200
|
description: a(r()),
|
|
201
|
-
required: a(
|
|
201
|
+
required: a(O())
|
|
202
202
|
}), ut = o({
|
|
203
|
-
...
|
|
204
|
-
...
|
|
203
|
+
...V.shape,
|
|
204
|
+
...xe.shape,
|
|
205
205
|
description: a(r()),
|
|
206
206
|
arguments: a(m(lt)),
|
|
207
207
|
_meta: a(i({}))
|
|
208
|
-
}), dt = U.extend({ method: f("prompts/list") }), ft = Re.extend({ prompts: m(ut) }), pt =
|
|
208
|
+
}), dt = U.extend({ method: f("prompts/list") }), ft = Re.extend({ prompts: m(ut) }), pt = I.extend({
|
|
209
209
|
name: r(),
|
|
210
210
|
arguments: S(r(), r()).optional()
|
|
211
|
-
}), mt =
|
|
211
|
+
}), mt = L.extend({
|
|
212
212
|
method: f("prompts/get"),
|
|
213
213
|
params: pt
|
|
214
214
|
}), ht = o({
|
|
@@ -248,53 +248,53 @@ var _e = V.strict(), ve = z.extend({
|
|
|
248
248
|
]), St = o({
|
|
249
249
|
role: Be,
|
|
250
250
|
content: xt
|
|
251
|
-
}), Ct =
|
|
251
|
+
}), Ct = B.extend({
|
|
252
252
|
description: r().optional(),
|
|
253
253
|
messages: m(St)
|
|
254
|
-
}), wt =
|
|
254
|
+
}), wt = z.extend({
|
|
255
255
|
method: f("notifications/prompts/list_changed"),
|
|
256
|
-
params:
|
|
256
|
+
params: R.optional()
|
|
257
257
|
}), Tt = o({
|
|
258
258
|
title: r().optional(),
|
|
259
|
-
readOnlyHint:
|
|
260
|
-
destructiveHint:
|
|
261
|
-
idempotentHint:
|
|
262
|
-
openWorldHint:
|
|
259
|
+
readOnlyHint: O().optional(),
|
|
260
|
+
destructiveHint: O().optional(),
|
|
261
|
+
idempotentHint: O().optional(),
|
|
262
|
+
openWorldHint: O().optional()
|
|
263
263
|
}), Et = o({ taskSupport: T([
|
|
264
264
|
"required",
|
|
265
265
|
"optional",
|
|
266
266
|
"forbidden"
|
|
267
267
|
]).optional() }), Dt = o({
|
|
268
|
-
...
|
|
269
|
-
...
|
|
268
|
+
...V.shape,
|
|
269
|
+
...xe.shape,
|
|
270
270
|
description: r().optional(),
|
|
271
271
|
inputSchema: o({
|
|
272
272
|
type: f("object"),
|
|
273
|
-
properties: S(r(),
|
|
273
|
+
properties: S(r(), N).optional(),
|
|
274
274
|
required: m(r()).optional()
|
|
275
275
|
}).catchall(c()),
|
|
276
276
|
outputSchema: i({ $schema: r().optional() }).optional(),
|
|
277
277
|
annotations: Tt.optional(),
|
|
278
278
|
execution: Et.optional(),
|
|
279
279
|
_meta: S(r(), c()).optional()
|
|
280
|
-
}), Ot = U.extend({ method: f("tools/list") }), kt = Re.extend({ tools: m(Dt) }), At =
|
|
280
|
+
}), Ot = U.extend({ method: f("tools/list") }), kt = Re.extend({ tools: m(Dt) }), At = B.extend({
|
|
281
281
|
content: m(xt).default([]),
|
|
282
282
|
structuredContent: c().optional(),
|
|
283
|
-
isError:
|
|
283
|
+
isError: O().optional()
|
|
284
284
|
});
|
|
285
|
-
At.or(
|
|
286
|
-
var jt =
|
|
285
|
+
At.or(B.extend({ toolResult: c() }));
|
|
286
|
+
var jt = de.extend({
|
|
287
287
|
name: r(),
|
|
288
288
|
arguments: S(r(), c()).optional()
|
|
289
|
-
}), Mt =
|
|
289
|
+
}), Mt = L.extend({
|
|
290
290
|
method: f("tools/call"),
|
|
291
291
|
params: jt
|
|
292
|
-
}), Nt =
|
|
292
|
+
}), Nt = z.extend({
|
|
293
293
|
method: f("notifications/tools/list_changed"),
|
|
294
|
-
params:
|
|
294
|
+
params: R.optional()
|
|
295
295
|
});
|
|
296
296
|
o({
|
|
297
|
-
autoRefresh:
|
|
297
|
+
autoRefresh: O().default(!0),
|
|
298
298
|
debounceMs: p().int().nonnegative().default(300)
|
|
299
299
|
});
|
|
300
300
|
var Pt = T([
|
|
@@ -306,14 +306,14 @@ var Pt = T([
|
|
|
306
306
|
"critical",
|
|
307
307
|
"alert",
|
|
308
308
|
"emergency"
|
|
309
|
-
]), Ft =
|
|
309
|
+
]), Ft = I.extend({ level: Pt }), It = L.extend({
|
|
310
310
|
method: f("logging/setLevel"),
|
|
311
311
|
params: Ft
|
|
312
|
-
}), Lt =
|
|
312
|
+
}), Lt = R.extend({
|
|
313
313
|
level: Pt,
|
|
314
314
|
logger: r().optional(),
|
|
315
315
|
data: c()
|
|
316
|
-
}), Rt =
|
|
316
|
+
}), Rt = z.extend({
|
|
317
317
|
method: f("notifications/message"),
|
|
318
318
|
params: Lt
|
|
319
319
|
}), zt = o({
|
|
@@ -330,13 +330,13 @@ var Pt = T([
|
|
|
330
330
|
toolUseId: r().describe("The unique identifier for the corresponding tool call."),
|
|
331
331
|
content: m(xt),
|
|
332
332
|
structuredContent: c().optional(),
|
|
333
|
-
isError:
|
|
333
|
+
isError: O().optional(),
|
|
334
334
|
_meta: S(r(), c()).optional()
|
|
335
|
-
}), Ht =
|
|
335
|
+
}), Ht = A("type", [
|
|
336
336
|
ht,
|
|
337
337
|
gt,
|
|
338
338
|
_t
|
|
339
|
-
]), Ut =
|
|
339
|
+
]), Ut = A("type", [
|
|
340
340
|
ht,
|
|
341
341
|
gt,
|
|
342
342
|
_t,
|
|
@@ -346,7 +346,7 @@ var Pt = T([
|
|
|
346
346
|
role: Be,
|
|
347
347
|
content: x([Ut, m(Ut)]),
|
|
348
348
|
_meta: S(r(), c()).optional()
|
|
349
|
-
}), Gt =
|
|
349
|
+
}), Gt = de.extend({
|
|
350
350
|
messages: m(Wt),
|
|
351
351
|
modelPreferences: zt.optional(),
|
|
352
352
|
systemPrompt: r().optional(),
|
|
@@ -358,13 +358,13 @@ var Pt = T([
|
|
|
358
358
|
temperature: p().optional(),
|
|
359
359
|
maxTokens: p().int(),
|
|
360
360
|
stopSequences: m(r()).optional(),
|
|
361
|
-
metadata:
|
|
361
|
+
metadata: P.optional(),
|
|
362
362
|
tools: m(Dt).optional(),
|
|
363
363
|
toolChoice: Bt.optional()
|
|
364
|
-
}), Kt =
|
|
364
|
+
}), Kt = L.extend({
|
|
365
365
|
method: f("sampling/createMessage"),
|
|
366
366
|
params: Gt
|
|
367
|
-
}), qt =
|
|
367
|
+
}), qt = B.extend({
|
|
368
368
|
model: r(),
|
|
369
369
|
stopReason: a(T([
|
|
370
370
|
"endTurn",
|
|
@@ -373,7 +373,7 @@ var Pt = T([
|
|
|
373
373
|
]).or(r())),
|
|
374
374
|
role: Be,
|
|
375
375
|
content: Ht
|
|
376
|
-
}), Jt =
|
|
376
|
+
}), Jt = B.extend({
|
|
377
377
|
model: r(),
|
|
378
378
|
stopReason: a(T([
|
|
379
379
|
"endTurn",
|
|
@@ -387,7 +387,7 @@ var Pt = T([
|
|
|
387
387
|
type: f("boolean"),
|
|
388
388
|
title: r().optional(),
|
|
389
389
|
description: r().optional(),
|
|
390
|
-
default:
|
|
390
|
+
default: O().optional()
|
|
391
391
|
}), Xt = o({
|
|
392
392
|
type: f("string"),
|
|
393
393
|
title: r().optional(),
|
|
@@ -461,7 +461,7 @@ var Pt = T([
|
|
|
461
461
|
Yt,
|
|
462
462
|
Xt,
|
|
463
463
|
Zt
|
|
464
|
-
]), tn = x([
|
|
464
|
+
]), tn = x([de.extend({
|
|
465
465
|
mode: f("form").optional(),
|
|
466
466
|
message: r(),
|
|
467
467
|
requestedSchema: o({
|
|
@@ -469,18 +469,18 @@ var Pt = T([
|
|
|
469
469
|
properties: S(r(), en),
|
|
470
470
|
required: m(r()).optional()
|
|
471
471
|
}).catchall(c())
|
|
472
|
-
}),
|
|
472
|
+
}), de.extend({
|
|
473
473
|
mode: f("url"),
|
|
474
474
|
message: r(),
|
|
475
475
|
elicitationId: r(),
|
|
476
476
|
url: r().url()
|
|
477
|
-
})]), nn =
|
|
477
|
+
})]), nn = L.extend({
|
|
478
478
|
method: f("elicitation/create"),
|
|
479
479
|
params: tn
|
|
480
|
-
}), rn =
|
|
480
|
+
}), rn = R.extend({ elicitationId: r() }), an = z.extend({
|
|
481
481
|
method: f("notifications/elicitation/complete"),
|
|
482
482
|
params: rn
|
|
483
|
-
}), on =
|
|
483
|
+
}), on = B.extend({
|
|
484
484
|
action: T([
|
|
485
485
|
"accept",
|
|
486
486
|
"decline",
|
|
@@ -489,7 +489,7 @@ var Pt = T([
|
|
|
489
489
|
content: u((e) => e === null ? void 0 : e, S(r(), x([
|
|
490
490
|
r(),
|
|
491
491
|
p(),
|
|
492
|
-
|
|
492
|
+
O(),
|
|
493
493
|
m(r())
|
|
494
494
|
])).optional())
|
|
495
495
|
}), sn = o({
|
|
@@ -498,30 +498,30 @@ var Pt = T([
|
|
|
498
498
|
}), cn = o({
|
|
499
499
|
type: f("ref/prompt"),
|
|
500
500
|
name: r()
|
|
501
|
-
}), ln =
|
|
501
|
+
}), ln = I.extend({
|
|
502
502
|
ref: x([cn, sn]),
|
|
503
503
|
argument: o({
|
|
504
504
|
name: r(),
|
|
505
505
|
value: r()
|
|
506
506
|
}),
|
|
507
507
|
context: o({ arguments: S(r(), r()).optional() }).optional()
|
|
508
|
-
}), un =
|
|
508
|
+
}), un = L.extend({
|
|
509
509
|
method: f("completion/complete"),
|
|
510
510
|
params: ln
|
|
511
|
-
}), dn =
|
|
511
|
+
}), dn = B.extend({ completion: i({
|
|
512
512
|
values: m(r()).max(100),
|
|
513
513
|
total: a(p().int()),
|
|
514
|
-
hasMore: a(
|
|
514
|
+
hasMore: a(O())
|
|
515
515
|
}) }), fn = o({
|
|
516
516
|
uri: r().startsWith("file://"),
|
|
517
517
|
name: r().optional(),
|
|
518
518
|
_meta: S(r(), c()).optional()
|
|
519
|
-
}), pn =
|
|
519
|
+
}), pn = L.extend({
|
|
520
520
|
method: f("roots/list"),
|
|
521
|
-
params:
|
|
522
|
-
}), mn =
|
|
521
|
+
params: I.optional()
|
|
522
|
+
}), mn = B.extend({ roots: m(fn) }), hn = z.extend({
|
|
523
523
|
method: f("notifications/roots/list_changed"),
|
|
524
|
-
params:
|
|
524
|
+
params: R.optional()
|
|
525
525
|
});
|
|
526
526
|
i({
|
|
527
527
|
ttl: p().optional(),
|
|
@@ -542,24 +542,24 @@ var gn = T([
|
|
|
542
542
|
pollInterval: a(p()),
|
|
543
543
|
statusMessage: a(r())
|
|
544
544
|
});
|
|
545
|
-
|
|
546
|
-
var vn =
|
|
547
|
-
|
|
545
|
+
B.extend({ task: _n });
|
|
546
|
+
var vn = R.merge(_n);
|
|
547
|
+
z.extend({
|
|
548
548
|
method: f("notifications/tasks/status"),
|
|
549
549
|
params: vn
|
|
550
|
-
}),
|
|
550
|
+
}), L.extend({
|
|
551
551
|
method: f("tasks/get"),
|
|
552
|
-
params:
|
|
553
|
-
}),
|
|
552
|
+
params: I.extend({ taskId: r() })
|
|
553
|
+
}), B.merge(_n), L.extend({
|
|
554
554
|
method: f("tasks/result"),
|
|
555
|
-
params:
|
|
556
|
-
}),
|
|
555
|
+
params: I.extend({ taskId: r() })
|
|
556
|
+
}), B.loose(), U.extend({ method: f("tasks/list") }), Re.extend({ tasks: m(_n) }), L.extend({
|
|
557
557
|
method: f("tasks/cancel"),
|
|
558
|
-
params:
|
|
559
|
-
}),
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
558
|
+
params: I.extend({ taskId: r() })
|
|
559
|
+
}), B.merge(_n), x([
|
|
560
|
+
Pe,
|
|
561
|
+
Oe,
|
|
562
|
+
Me,
|
|
563
563
|
un,
|
|
564
564
|
It,
|
|
565
565
|
mt,
|
|
@@ -573,23 +573,23 @@ B.extend({
|
|
|
573
573
|
Mt,
|
|
574
574
|
Ot
|
|
575
575
|
]), x([
|
|
576
|
-
|
|
576
|
+
be,
|
|
577
577
|
Ie,
|
|
578
|
-
|
|
578
|
+
je,
|
|
579
579
|
hn
|
|
580
580
|
]), x([
|
|
581
|
-
|
|
581
|
+
ve,
|
|
582
582
|
qt,
|
|
583
583
|
Jt,
|
|
584
584
|
on,
|
|
585
585
|
mn
|
|
586
586
|
]), x([
|
|
587
|
-
|
|
587
|
+
Pe,
|
|
588
588
|
Kt,
|
|
589
589
|
nn,
|
|
590
590
|
pn
|
|
591
591
|
]), x([
|
|
592
|
-
|
|
592
|
+
be,
|
|
593
593
|
Ie,
|
|
594
594
|
Rt,
|
|
595
595
|
ct,
|
|
@@ -599,9 +599,9 @@ B.extend({
|
|
|
599
599
|
Y,
|
|
600
600
|
an
|
|
601
601
|
]), x([
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
602
|
+
ve,
|
|
603
|
+
Ae,
|
|
604
|
+
Ne,
|
|
605
605
|
dn,
|
|
606
606
|
Ct,
|
|
607
607
|
ft,
|
|
@@ -633,10 +633,10 @@ i({
|
|
|
633
633
|
resource_documentation: r().optional(),
|
|
634
634
|
resource_policy_uri: r().url().optional(),
|
|
635
635
|
resource_tos_uri: r().url().optional(),
|
|
636
|
-
tls_client_certificate_bound_access_tokens:
|
|
636
|
+
tls_client_certificate_bound_access_tokens: O().optional(),
|
|
637
637
|
authorization_details_types_supported: m(r()).optional(),
|
|
638
638
|
dpop_signing_alg_values_supported: m(r()).optional(),
|
|
639
|
-
dpop_bound_access_tokens_required:
|
|
639
|
+
dpop_bound_access_tokens_required: O().optional()
|
|
640
640
|
});
|
|
641
641
|
var yn = i({
|
|
642
642
|
issuer: r(),
|
|
@@ -657,8 +657,8 @@ var yn = i({
|
|
|
657
657
|
introspection_endpoint_auth_methods_supported: m(r()).optional(),
|
|
658
658
|
introspection_endpoint_auth_signing_alg_values_supported: m(r()).optional(),
|
|
659
659
|
code_challenge_methods_supported: m(r()).optional(),
|
|
660
|
-
client_id_metadata_document_supported:
|
|
661
|
-
authorization_response_iss_parameter_supported:
|
|
660
|
+
client_id_metadata_document_supported: O().optional(),
|
|
661
|
+
authorization_response_iss_parameter_supported: O().optional().catch(void 0)
|
|
662
662
|
});
|
|
663
663
|
o({
|
|
664
664
|
...i({
|
|
@@ -691,14 +691,14 @@ o({
|
|
|
691
691
|
service_documentation: r().optional(),
|
|
692
692
|
claims_locales_supported: m(r()).optional(),
|
|
693
693
|
ui_locales_supported: m(r()).optional(),
|
|
694
|
-
claims_parameter_supported:
|
|
695
|
-
request_parameter_supported:
|
|
696
|
-
request_uri_parameter_supported:
|
|
697
|
-
require_request_uri_registration:
|
|
694
|
+
claims_parameter_supported: O().optional(),
|
|
695
|
+
request_parameter_supported: O().optional(),
|
|
696
|
+
request_uri_parameter_supported: O().optional(),
|
|
697
|
+
require_request_uri_registration: O().optional(),
|
|
698
698
|
op_policy_uri: X.optional(),
|
|
699
699
|
op_tos_uri: X.optional(),
|
|
700
|
-
client_id_metadata_document_supported:
|
|
701
|
-
authorization_response_iss_parameter_supported:
|
|
700
|
+
client_id_metadata_document_supported: O().optional(),
|
|
701
|
+
authorization_response_iss_parameter_supported: O().optional().catch(void 0)
|
|
702
702
|
}).shape,
|
|
703
703
|
...yn.pick({ code_challenge_methods_supported: !0 }).shape
|
|
704
704
|
}), o({
|
|
@@ -868,7 +868,7 @@ var Cn = class {
|
|
|
868
868
|
]).describe("CSS variable keys available to MCP apps for theming.").describe("Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record<K, string | undefined>` rather than `Partial<Record<K, string>>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation."), x([r(), y()]).describe("Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record<K, string | undefined>` rather than `Partial<Record<K, string>>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation.")).describe("Style variables for theming MCP apps.\n\nIndividual style keys are optional - hosts may provide any subset of these values.\nValues are strings containing CSS values (colors, sizes, font stacks, etc.).\n\nNote: This type uses `Record<K, string | undefined>` rather than `Partial<Record<K, string>>`\nfor compatibility with Zod schema generation. Both are functionally equivalent for validation."), On = o({
|
|
869
869
|
method: f("ui/open-link"),
|
|
870
870
|
params: o({ url: r().describe("URL to open in the host's browser") })
|
|
871
|
-
}), kn = o({ isError:
|
|
871
|
+
}), kn = o({ isError: O().optional().describe("True if the host failed to open the URL (e.g., due to security policy).") }).passthrough(), An = o({ isError: O().optional().describe("True if the download failed (e.g., user cancelled or host denied).") }).passthrough(), jn = o({ isError: O().optional().describe("True if the host rejected or failed to deliver the message.") }).passthrough(), Mn = o({
|
|
872
872
|
method: f("ui/notifications/sandbox-proxy-ready"),
|
|
873
873
|
params: o({})
|
|
874
874
|
}), Nn = o({
|
|
@@ -920,8 +920,8 @@ var Rn = S(r(), c()), zn = o({
|
|
|
920
920
|
experimental: o({}).optional().describe("Experimental features (structure TBD)."),
|
|
921
921
|
openLinks: o({}).optional().describe("Host supports opening external URLs."),
|
|
922
922
|
downloadFile: o({}).optional().describe("Host supports file downloads via ui/download-file."),
|
|
923
|
-
serverTools: o({ listChanged:
|
|
924
|
-
serverResources: o({ listChanged:
|
|
923
|
+
serverTools: o({ listChanged: O().optional().describe("Host supports tools/list_changed notifications.") }).optional().describe("Host can proxy tool calls to the MCP server."),
|
|
924
|
+
serverResources: o({ listChanged: O().optional().describe("Host supports resources/list_changed notifications.") }).optional().describe("Host can proxy resource reads to the MCP server."),
|
|
925
925
|
logging: o({}).optional().describe("Host accepts log messages."),
|
|
926
926
|
sandbox: o({
|
|
927
927
|
permissions: Pn.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),
|
|
@@ -932,7 +932,7 @@ var Rn = S(r(), c()), zn = o({
|
|
|
932
932
|
sampling: o({ tools: o({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.") }).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")
|
|
933
933
|
}), Hn = o({
|
|
934
934
|
experimental: o({}).optional().describe("Experimental features (structure TBD)."),
|
|
935
|
-
tools: o({ listChanged:
|
|
935
|
+
tools: o({ listChanged: O().optional().describe("App supports tools/list_changed notifications.") }).optional().describe("App exposes MCP-style tools that the host can call."),
|
|
936
936
|
availableDisplayModes: m(En).optional().describe("Display modes the app supports.")
|
|
937
937
|
}), Un = o({
|
|
938
938
|
method: f("ui/notifications/initialized"),
|
|
@@ -942,7 +942,7 @@ o({
|
|
|
942
942
|
csp: Nn.optional().describe("Content Security Policy configuration for UI resources."),
|
|
943
943
|
permissions: Pn.optional().describe("Sandbox permissions requested by the UI resource."),
|
|
944
944
|
domain: r().optional().describe("Dedicated origin for view sandbox.\n\nUseful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.\n\n**Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include:\n- Hash-based subdomains (e.g., `{hash}.claudemcpcontent.com`)\n- URL-derived subdomains (e.g., `www-example-com.oaiusercontent.com`)\n\nIf omitted, host uses default sandbox origin (typically per-conversation)."),
|
|
945
|
-
prefersBorder:
|
|
945
|
+
prefersBorder: O().optional().describe("Visual boundary preference - true if view prefers a visible border.\n\nBoolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.\n\n- `true`: request visible border + background\n- `false`: request no visible border + background\n- omitted: host decides border")
|
|
946
946
|
});
|
|
947
947
|
var Wn = o({
|
|
948
948
|
method: f("ui/request-display-mode"),
|
|
@@ -951,8 +951,8 @@ var Wn = o({
|
|
|
951
951
|
o({
|
|
952
952
|
resourceUri: r().optional(),
|
|
953
953
|
visibility: m(Kn).optional().describe("Who can access this tool. Default: [\"model\", \"app\"]\n- \"model\": Tool visible to and callable by the agent\n- \"app\": Tool callable by the app from this server only"),
|
|
954
|
-
csp:
|
|
955
|
-
permissions:
|
|
954
|
+
csp: k().optional(),
|
|
955
|
+
permissions: k().optional()
|
|
956
956
|
}), o({ mimeTypes: m(r()).optional().describe("Array of supported MIME types for UI resources.\nMust include `\"text/html;profile=mcp-app\"` for MCP Apps support.") });
|
|
957
957
|
var qn = o({
|
|
958
958
|
method: f("ui/download-file"),
|
|
@@ -978,7 +978,7 @@ o({
|
|
|
978
978
|
});
|
|
979
979
|
var Yn = o({
|
|
980
980
|
toolInfo: o({
|
|
981
|
-
id:
|
|
981
|
+
id: fe.optional().describe("JSON-RPC id of the tools/call request."),
|
|
982
982
|
tool: Dt.describe("Tool definition including name, inputSchema, etc.")
|
|
983
983
|
}).optional().describe("Metadata of the tool call that instantiated this App."),
|
|
984
984
|
theme: Tn.optional().describe("Current color theme preference."),
|
|
@@ -995,8 +995,8 @@ var Yn = o({
|
|
|
995
995
|
f("mobile")
|
|
996
996
|
]).optional().describe("Platform type for responsive design decisions."),
|
|
997
997
|
deviceCapabilities: o({
|
|
998
|
-
touch:
|
|
999
|
-
hover:
|
|
998
|
+
touch: O().optional().describe("Whether the device supports touch input."),
|
|
999
|
+
hover: O().optional().describe("Whether the device supports hover interactions.")
|
|
1000
1000
|
}).optional().describe("Device input capabilities."),
|
|
1001
1001
|
safeAreaInsets: o({
|
|
1002
1002
|
top: p().describe("Top safe area inset in pixels."),
|
|
@@ -1018,13 +1018,13 @@ var Xn = o({
|
|
|
1018
1018
|
}), Zn = o({
|
|
1019
1019
|
method: f("ui/initialize"),
|
|
1020
1020
|
params: o({
|
|
1021
|
-
appInfo:
|
|
1021
|
+
appInfo: Se.describe("App identification (name and version)."),
|
|
1022
1022
|
appCapabilities: Hn.describe("Features and capabilities this app provides."),
|
|
1023
1023
|
protocolVersion: r().describe("Protocol version this app supports.")
|
|
1024
1024
|
})
|
|
1025
1025
|
}), Qn = o({
|
|
1026
1026
|
protocolVersion: r().describe("Negotiated protocol version string (e.g., \"2025-11-21\")."),
|
|
1027
|
-
hostInfo:
|
|
1027
|
+
hostInfo: Se.describe("Host application identification and version."),
|
|
1028
1028
|
hostCapabilities: Vn.describe("Features and capabilities provided by the host."),
|
|
1029
1029
|
hostContext: Yn.describe("Rich context about the host environment.")
|
|
1030
1030
|
}).passthrough(), $n = class {
|
|
@@ -1037,7 +1037,7 @@ var Xn = o({
|
|
|
1037
1037
|
console.debug("Ignoring message from unknown source", e);
|
|
1038
1038
|
return;
|
|
1039
1039
|
}
|
|
1040
|
-
let n =
|
|
1040
|
+
let n = _e.safeParse(e.data);
|
|
1041
1041
|
n.success ? (console.debug("Parsed message", n.data), this.onmessage?.(n.data)) : e.data?.jsonrpc === "2.0" ? (console.error("Failed to parse message", n.error.message, e), this.onerror?.(Error("Invalid JSON-RPC message received: " + n.error.message))) : console.debug("Ignoring non-JSON-RPC message", n.error.message, e);
|
|
1042
1042
|
};
|
|
1043
1043
|
}
|
|
@@ -1061,7 +1061,7 @@ function tr(e) {
|
|
|
1061
1061
|
let t = [];
|
|
1062
1062
|
return e.camera && t.push("camera"), e.microphone && t.push("microphone"), e.geolocation && t.push("geolocation"), e.clipboardWrite && t.push("clipboard-write"), t.join("; ");
|
|
1063
1063
|
}
|
|
1064
|
-
var nr = [wn], rr = class extends
|
|
1064
|
+
var nr = [wn], rr = class extends ie {
|
|
1065
1065
|
_client;
|
|
1066
1066
|
_hostInfo;
|
|
1067
1067
|
_hostCapabilities;
|
|
@@ -1219,7 +1219,7 @@ var nr = [wn], rr = class extends D {
|
|
|
1219
1219
|
set onupdatemodelcontext(e) {
|
|
1220
1220
|
this.warnIfRequestHandlerReplaced("onupdatemodelcontext", this._onupdatemodelcontext, e), this._onupdatemodelcontext = e, this.setRequestHandler("ui/update-model-context", {
|
|
1221
1221
|
params: Xn.shape.params,
|
|
1222
|
-
result:
|
|
1222
|
+
result: ve
|
|
1223
1223
|
}, async (e, t) => {
|
|
1224
1224
|
if (!this._onupdatemodelcontext) throw Error("No onupdatemodelcontext handler set");
|
|
1225
1225
|
return this._onupdatemodelcontext(e, t);
|
|
@@ -2135,7 +2135,7 @@ var Vr = class extends Rr {
|
|
|
2135
2135
|
a = this.opts.wrapTransport(a, e);
|
|
2136
2136
|
}
|
|
2137
2137
|
let o = this.buildClientOptions();
|
|
2138
|
-
Z.debug("Creating Client with capabilities:", JSON.stringify(o.capabilities, null, 2)), this.client = new
|
|
2138
|
+
Z.debug("Creating Client with capabilities:", JSON.stringify(o.capabilities, null, 2)), this.client = new D(this.clientInfo, o), this.setupRootsHandler(), this.setupSamplingHandler(), this.setupElicitationHandler(), Z.debug("Roots/sampling/elicitation handlers registered before connect");
|
|
2139
2139
|
try {
|
|
2140
2140
|
let e;
|
|
2141
2141
|
if (await Promise.race([this.client.connect(a), new Promise((t, n) => {
|
|
@@ -2198,7 +2198,7 @@ var Vr = class extends Rr {
|
|
|
2198
2198
|
}
|
|
2199
2199
|
await super.cleanupResources();
|
|
2200
2200
|
}
|
|
2201
|
-
}, Hr = "2.0.0-beta.
|
|
2201
|
+
}, Hr = "2.0.0-beta.2";
|
|
2202
2202
|
function Ur() {
|
|
2203
2203
|
return Hr;
|
|
2204
2204
|
}
|
|
@@ -3577,7 +3577,7 @@ function la(e, t) {
|
|
|
3577
3577
|
return n;
|
|
3578
3578
|
}
|
|
3579
3579
|
function ua(e) {
|
|
3580
|
-
let t = (0,
|
|
3580
|
+
let t = (0, j.useCallback)(async (t, n, r) => {
|
|
3581
3581
|
let i = la(e, `call tool "${t}"`);
|
|
3582
3582
|
e.addLog("info", `Calling tool: ${t}`, n);
|
|
3583
3583
|
let a = Date.now();
|
|
@@ -3596,12 +3596,12 @@ function ua(e) {
|
|
|
3596
3596
|
executionTimeMs: Date.now() - a
|
|
3597
3597
|
}).catch(() => {}), n;
|
|
3598
3598
|
}
|
|
3599
|
-
}, [e.addLog]), n = (0,
|
|
3599
|
+
}, [e.addLog]), n = (0, j.useCallback)(async () => {
|
|
3600
3600
|
let t = la(e, "list resources");
|
|
3601
3601
|
e.addLog("info", "Listing resources");
|
|
3602
3602
|
let n = await t.listAllResources();
|
|
3603
3603
|
e.setResources(n.resources || []);
|
|
3604
|
-
}, [e.addLog]), r = (0,
|
|
3604
|
+
}, [e.addLog]), r = (0, j.useCallback)(async (t) => {
|
|
3605
3605
|
let n = la(e, "read resource");
|
|
3606
3606
|
e.addLog("info", `Reading resource: ${t}`);
|
|
3607
3607
|
try {
|
|
@@ -3617,32 +3617,32 @@ function ua(e) {
|
|
|
3617
3617
|
errorType: e instanceof Error ? e.name : "UnknownError"
|
|
3618
3618
|
}).catch(() => {}), e;
|
|
3619
3619
|
}
|
|
3620
|
-
}, [e.addLog]), i = (0,
|
|
3620
|
+
}, [e.addLog]), i = (0, j.useCallback)(async () => {
|
|
3621
3621
|
let t = la(e, "list prompts");
|
|
3622
3622
|
e.addLog("info", "Listing prompts");
|
|
3623
3623
|
let n = await t.listPrompts();
|
|
3624
3624
|
e.setPrompts(n.prompts || []);
|
|
3625
|
-
}, [e.addLog]), a = (0,
|
|
3625
|
+
}, [e.addLog]), a = (0, j.useCallback)(async () => {
|
|
3626
3626
|
if (!(e.stateRef.current !== "ready" || !e.connectionRef.current)) try {
|
|
3627
3627
|
e.setTools(await e.connectionRef.current.listTools() || []);
|
|
3628
3628
|
} catch (t) {
|
|
3629
3629
|
e.addLog("error", "Failed to refresh tools:", t);
|
|
3630
3630
|
}
|
|
3631
|
-
}, [e.addLog]), o = (0,
|
|
3631
|
+
}, [e.addLog]), o = (0, j.useCallback)(async () => {
|
|
3632
3632
|
if (!(e.stateRef.current !== "ready" || !e.connectionRef.current)) try {
|
|
3633
3633
|
let t = await e.connectionRef.current.listAllResources();
|
|
3634
3634
|
e.setResources(t.resources || []);
|
|
3635
3635
|
} catch (t) {
|
|
3636
3636
|
e.addLog("warn", "Failed to refresh resources:", t);
|
|
3637
3637
|
}
|
|
3638
|
-
}, [e.addLog]), s = (0,
|
|
3638
|
+
}, [e.addLog]), s = (0, j.useCallback)(async () => {
|
|
3639
3639
|
if (!(e.stateRef.current !== "ready" || !e.connectionRef.current)) try {
|
|
3640
3640
|
let t = await e.connectionRef.current.listPrompts();
|
|
3641
3641
|
e.setPrompts(t.prompts || []);
|
|
3642
3642
|
} catch (t) {
|
|
3643
3643
|
e.addLog("warn", "Failed to refresh prompts:", t);
|
|
3644
3644
|
}
|
|
3645
|
-
}, [e.addLog]), c = (0,
|
|
3645
|
+
}, [e.addLog]), c = (0, j.useCallback)(async () => {
|
|
3646
3646
|
let t = await la(e, "refresh resource templates").listResourceTemplates();
|
|
3647
3647
|
e.isMounted() && e.setResourceTemplates(t.resourceTemplates || []);
|
|
3648
3648
|
}, [e.addLog]);
|
|
@@ -3655,7 +3655,7 @@ function ua(e) {
|
|
|
3655
3655
|
refreshResources: o,
|
|
3656
3656
|
refreshPrompts: s,
|
|
3657
3657
|
refreshResourceTemplates: c,
|
|
3658
|
-
refreshAll: (0,
|
|
3658
|
+
refreshAll: (0, j.useCallback)(() => Promise.all([
|
|
3659
3659
|
a(),
|
|
3660
3660
|
o(),
|
|
3661
3661
|
c(),
|
|
@@ -3666,26 +3666,26 @@ function ua(e) {
|
|
|
3666
3666
|
c,
|
|
3667
3667
|
s
|
|
3668
3668
|
]),
|
|
3669
|
-
getPrompt: (0,
|
|
3670
|
-
complete: (0,
|
|
3669
|
+
getPrompt: (0, j.useCallback)(async (t, n) => la(e, "get prompt").getPrompt(t, n || {}), [e.addLog]),
|
|
3670
|
+
complete: (0, j.useCallback)(async (t) => la(e, "request completion").complete(t), [e.addLog])
|
|
3671
3671
|
};
|
|
3672
3672
|
}
|
|
3673
3673
|
var da = 3e3, fa = 5e3;
|
|
3674
3674
|
function pa(e) {
|
|
3675
|
-
let { url: t, enabled: n = !0, callbackUrl: r = typeof window < "u" ? Yr(new URL("/oauth/callback", window.location.origin).toString()) : "/oauth/callback", storageKeyPrefix: i = "mcp:auth", authProvider: a, headers: o, proxyConfig: s, oauthProxyUrl: c, autoProxyFallback: l = !1, logLevel: u = "silent", autoRetry: d = !1, autoReconnect: f = !0, reconnectionOptions: p, preventAutoAuth: m = !0, useRedirectFlow: h = !1, onPopupWindow: g, timeout: _ = 3e4, wrapTransport: v, serverId: ee, fetch: te, clientOptions: y, protocolNegotiation: x, onNotification: S, onSampling: C, onElicitation: ne, oauth: w } = e, re = "http", T = w?.clientId?.trim() || void 0, E = w?.clientMetadataUrl?.trim() || void 0,
|
|
3675
|
+
let { url: t, enabled: n = !0, callbackUrl: r = typeof window < "u" ? Yr(new URL("/oauth/callback", window.location.origin).toString()) : "/oauth/callback", storageKeyPrefix: i = "mcp:auth", authProvider: a, headers: o, proxyConfig: s, oauthProxyUrl: c, autoProxyFallback: l = !1, logLevel: u = "silent", autoRetry: d = !1, autoReconnect: f = !0, reconnectionOptions: p, preventAutoAuth: m = !0, useRedirectFlow: h = !1, onPopupWindow: g, timeout: _ = 3e4, wrapTransport: v, serverId: ee, fetch: te, clientOptions: y, protocolNegotiation: x, onNotification: S, onSampling: C, onElicitation: ne, oauth: w } = e, re = "http", T = w?.clientId?.trim() || void 0, E = w?.clientMetadataUrl?.trim() || void 0, ie = w?.scope?.trim() || void 0, D = (0, j.useMemo)(() => T ? { client_id: T } : void 0, [T]), O = (0, j.useMemo)(() => {
|
|
3676
3676
|
let e = `useMcp:${t || "no-url"}`, n = pr.get(e);
|
|
3677
3677
|
return u && (n.level = u), n;
|
|
3678
|
-
}, [t, u]),
|
|
3678
|
+
}, [t, u]), k = o ?? {}, ae = (0, j.useMemo)(() => Jr(y), [y]), A = C, oe = ne, M = (0, j.useMemo)(() => ({
|
|
3679
3679
|
name: "mcp-use",
|
|
3680
3680
|
title: "mcp-use",
|
|
3681
3681
|
version: Ur(),
|
|
3682
3682
|
description: "mcp-use is a complete TypeScript framework for building and using MCP",
|
|
3683
3683
|
icons: [{ src: "https://mcp-use.com/logo.png" }],
|
|
3684
3684
|
websiteUrl: "https://mcp-use.com"
|
|
3685
|
-
}), []),
|
|
3686
|
-
...
|
|
3685
|
+
}), []), N = (0, j.useMemo)(() => e.clientInfo ? {
|
|
3686
|
+
...M,
|
|
3687
3687
|
...e.clientInfo
|
|
3688
|
-
} :
|
|
3688
|
+
} : M, [e.clientInfo, M]), P = (0, j.useMemo)(() => ia(N), [N]), se = (0, j.useMemo)(() => {
|
|
3689
3689
|
if (!l) return {
|
|
3690
3690
|
enabled: !1,
|
|
3691
3691
|
proxyAddress: void 0
|
|
@@ -3702,7 +3702,7 @@ function pa(e) {
|
|
|
3702
3702
|
enabled: l.enabled !== !1 && !!e,
|
|
3703
3703
|
proxyAddress: e
|
|
3704
3704
|
};
|
|
3705
|
-
}, [l, s]),
|
|
3705
|
+
}, [l, s]), F = (0, j.useMemo)(() => f === !1 ? {
|
|
3706
3706
|
enabled: !1,
|
|
3707
3707
|
initialDelay: 0,
|
|
3708
3708
|
healthCheckInterval: !1,
|
|
@@ -3722,66 +3722,66 @@ function pa(e) {
|
|
|
3722
3722
|
initialDelay: f.initialDelay ?? da,
|
|
3723
3723
|
healthCheckInterval: f.healthCheckInterval ?? 1e4,
|
|
3724
3724
|
healthCheckTimeout: f.healthCheckTimeout ?? 3e4
|
|
3725
|
-
}, [f]), [
|
|
3726
|
-
(0,
|
|
3727
|
-
|
|
3725
|
+
}, [f]), [ce, le] = (0, j.useState)(void 0);
|
|
3726
|
+
(0, j.useEffect)(() => {
|
|
3727
|
+
le(void 0);
|
|
3728
3728
|
}, [t, s]);
|
|
3729
|
-
let
|
|
3730
|
-
if (!
|
|
3729
|
+
let ue = (0, j.useMemo)(() => {
|
|
3730
|
+
if (!ce?.proxyAddress) return s;
|
|
3731
3731
|
let e = s?.headers ?? {};
|
|
3732
3732
|
return {
|
|
3733
|
-
...
|
|
3733
|
+
...ce,
|
|
3734
3734
|
headers: {
|
|
3735
3735
|
...e,
|
|
3736
|
-
...
|
|
3736
|
+
...ce.headers ?? {}
|
|
3737
3737
|
}
|
|
3738
3738
|
};
|
|
3739
|
-
}, [
|
|
3740
|
-
...
|
|
3741
|
-
...
|
|
3742
|
-
}), [
|
|
3743
|
-
|
|
3744
|
-
let et = (0,
|
|
3739
|
+
}, [ce, s]), I = ue?.proxyAddress, de = ue?.headers ?? {}, L = (0, j.useMemo)(() => t || "", [t]), R = (0, j.useMemo)(() => ({
|
|
3740
|
+
...de,
|
|
3741
|
+
...k
|
|
3742
|
+
}), [de, k]), [z, B] = (0, j.useState)("discovering"), [fe, pe] = (0, j.useState)([]), [me, he] = (0, j.useState)([]), [ge, _e] = (0, j.useState)([]), [ve, ye] = (0, j.useState)([]), [be, xe] = (0, j.useState)(e._initialServerInfo?.name ? e._initialServerInfo : void 0), [V, Se] = (0, j.useState)(), [Ce, we] = (0, j.useState)(void 0), [Te, Ee] = (0, j.useState)(void 0), [De, Oe] = (0, j.useState)(), [ke, Ae] = (0, j.useState)({}), [je, Me] = (0, j.useState)(void 0), [Ne, Pe] = (0, j.useState)([]), [Fe, H] = (0, j.useState)(void 0), [Ie, Le] = (0, j.useState)(void 0), U = (0, j.useRef)(null), Re = (0, j.useRef)(null), W = (0, j.useRef)(a ?? null), ze = (0, j.useRef)(null), G = (0, j.useRef)(!1), K = (0, j.useRef)(!0), Be = (0, j.useRef)(0), Ve = (0, j.useRef)(0), He = (0, j.useRef)(null), Ue = (0, j.useRef)(!1), We = (0, j.useRef)(!1), q = (0, j.useRef)(z), Ge = (0, j.useRef)(f), Ke = (0, j.useRef)(null), qe = (0, j.useRef)(null), Je = (0, j.useRef)(null), Ye = (0, j.useRef)(A), Xe = (0, j.useRef)(oe), Ze = (0, j.useRef)(A !== void 0), Qe = (0, j.useRef)(oe !== void 0), $e = (0, j.useRef)(S);
|
|
3743
|
+
A !== void 0 && (Ye.current = A), oe !== void 0 && (Xe.current = oe), Ze.current = A !== void 0, Qe.current = oe !== void 0, $e.current = S;
|
|
3744
|
+
let et = (0, j.useCallback)(async (e) => Ye.current(e), []), tt = (0, j.useCallback)(async (e) => Xe.current(e), []), nt = (0, j.useCallback)((e) => {
|
|
3745
3745
|
$e.current?.(e);
|
|
3746
3746
|
}, []);
|
|
3747
|
-
(0,
|
|
3748
|
-
q.current =
|
|
3749
|
-
}, [
|
|
3747
|
+
(0, j.useEffect)(() => {
|
|
3748
|
+
q.current = z, Ge.current = f;
|
|
3749
|
+
}, [z, f]), (0, j.useEffect)(() => {
|
|
3750
3750
|
W.current = a ?? null;
|
|
3751
3751
|
}, [a]);
|
|
3752
|
-
let J = (0,
|
|
3752
|
+
let J = (0, j.useCallback)((e, t, ...n) => {
|
|
3753
3753
|
let r = n.length > 0 ? `${t} ${n.map((e) => JSON.stringify(e)).join(" ")}` : t, i = `[useMcp] ${r}`;
|
|
3754
3754
|
switch (e) {
|
|
3755
3755
|
case "error":
|
|
3756
|
-
|
|
3756
|
+
O.error(i);
|
|
3757
3757
|
break;
|
|
3758
3758
|
case "warn":
|
|
3759
|
-
|
|
3759
|
+
O.warn(i);
|
|
3760
3760
|
break;
|
|
3761
3761
|
case "info":
|
|
3762
|
-
|
|
3762
|
+
O.info(i);
|
|
3763
3763
|
break;
|
|
3764
3764
|
case "debug":
|
|
3765
|
-
|
|
3765
|
+
O.debug(i);
|
|
3766
3766
|
break;
|
|
3767
|
-
default:
|
|
3767
|
+
default: O.info(i);
|
|
3768
3768
|
}
|
|
3769
|
-
K.current &&
|
|
3769
|
+
K.current && Pe((t) => [...t.slice(-100), {
|
|
3770
3770
|
level: e,
|
|
3771
3771
|
message: r,
|
|
3772
3772
|
timestamp: Date.now()
|
|
3773
3773
|
}]);
|
|
3774
|
-
}, [
|
|
3774
|
+
}, [O]), rt = ua({
|
|
3775
3775
|
stateRef: q,
|
|
3776
3776
|
connectionRef: Re,
|
|
3777
3777
|
hasClient: () => U.current !== null,
|
|
3778
3778
|
isMounted: () => K.current,
|
|
3779
|
-
setTools:
|
|
3780
|
-
setResources:
|
|
3781
|
-
setResourceTemplates:
|
|
3782
|
-
setPrompts:
|
|
3779
|
+
setTools: pe,
|
|
3780
|
+
setResources: he,
|
|
3781
|
+
setResourceTemplates: _e,
|
|
3782
|
+
setPrompts: ye,
|
|
3783
3783
|
addLog: J
|
|
3784
|
-
}), it = (0,
|
|
3784
|
+
}), it = (0, j.useCallback)(async (e = !1) => {
|
|
3785
3785
|
e || J("info", "Disconnecting..."), G.current = !1, He.current && clearTimeout(He.current), He.current = null;
|
|
3786
3786
|
let t = Ve.current, n = U.current;
|
|
3787
3787
|
if (n) try {
|
|
@@ -3791,17 +3791,17 @@ function pa(e) {
|
|
|
3791
3791
|
e || J("warn", "Error closing connection:", t);
|
|
3792
3792
|
}
|
|
3793
3793
|
let r = Ve.current !== t;
|
|
3794
|
-
U.current === n && !r && (U.current = null, Re.current = null), K.current && !e && !r && (
|
|
3795
|
-
}, [J]), Y = (0,
|
|
3794
|
+
U.current === n && !r && (U.current = null, Re.current = null), K.current && !e && !r && (B("discovering"), pe([]), he([]), _e([]), ye([]), Me(void 0), H(void 0), Le(void 0), xe(void 0), Se(void 0), we(void 0), Ee(void 0), Oe(void 0), Ae({}));
|
|
3795
|
+
}, [J]), Y = (0, j.useCallback)((e, n) => {
|
|
3796
3796
|
J("error", e, n ?? "");
|
|
3797
|
-
let r = n && "code" in n ? n.code : void 0, i =
|
|
3798
|
-
if (i && (o || s || typeof r == "number" && r >= 404 && r < 500) && !(r === 401 || r === 403)) return J("info", `Direct connection failed with ${o ? "CORS error" : s ? "HTTP 400 (Bad Request)" : "HTTP 4xx error"}. Trying with proxy...`), U.current = null, a || (W.current = null), J("debug", "Cleared client and auth provider for proxy fallback"),
|
|
3797
|
+
let r = n && "code" in n ? n.code : void 0, i = se.enabled && !ue?.proxyAddress, o = e.includes("CORS") || e.includes("blocked by CORS policy") || e.includes("Failed to fetch"), s = r === 400;
|
|
3798
|
+
if (i && (o || s || typeof r == "number" && r >= 404 && r < 500) && !(r === 401 || r === 403)) return J("info", `Direct connection failed with ${o ? "CORS error" : s ? "HTTP 400 (Bad Request)" : "HTTP 4xx error"}. Trying with proxy...`), U.current = null, a || (W.current = null), J("debug", "Cleared client and auth provider for proxy fallback"), le({ proxyAddress: se.proxyAddress }), K.current && B("discovering"), setTimeout(() => {
|
|
3799
3799
|
K.current && qe.current?.();
|
|
3800
3800
|
}, 1e3), !0;
|
|
3801
3801
|
if (K.current) {
|
|
3802
|
-
J("info", "Setting state to FAILED:", e),
|
|
3802
|
+
J("info", "Setting state to FAILED:", e), B("failed"), Me(e);
|
|
3803
3803
|
let t = W.current?.getLastAttemptedAuthUrl?.();
|
|
3804
|
-
t && (
|
|
3804
|
+
t && (H(t), J("info", "Manual authentication URL may be available.", t));
|
|
3805
3805
|
}
|
|
3806
3806
|
return G.current = !1, t && Pi.getInstance().trackUseMcpConnection({
|
|
3807
3807
|
url: t,
|
|
@@ -3816,10 +3816,10 @@ function pa(e) {
|
|
|
3816
3816
|
J,
|
|
3817
3817
|
t,
|
|
3818
3818
|
re,
|
|
3819
|
-
|
|
3820
|
-
|
|
3819
|
+
se,
|
|
3820
|
+
ue,
|
|
3821
3821
|
a
|
|
3822
|
-
]), at = (0,
|
|
3822
|
+
]), at = (0, j.useCallback)(async () => {
|
|
3823
3823
|
if (!n || !t) {
|
|
3824
3824
|
J("debug", n ? "No server URL provided, skipping connection." : "Connection disabled via enabled flag.");
|
|
3825
3825
|
return;
|
|
@@ -3832,23 +3832,23 @@ function pa(e) {
|
|
|
3832
3832
|
J("debug", "Connect called after unmount, aborting.");
|
|
3833
3833
|
return;
|
|
3834
3834
|
}
|
|
3835
|
-
if (G.current = !0, Ve.current += 1, Be.current += 1,
|
|
3835
|
+
if (G.current = !0, Ve.current += 1, Be.current += 1, Me(void 0), H(void 0), Ke.current = null, B("discovering"), pe([]), he([]), _e([]), ye([]), xe(void 0), Se(void 0), we(void 0), Ee(void 0), Oe(void 0), Ae({}), J("info", `Connecting attempt #${Be.current} to ${t}...`), !W.current) {
|
|
3836
3836
|
let { provider: e, oauthProxyUrl: t } = sa({
|
|
3837
|
-
effectiveOAuthUrl:
|
|
3837
|
+
effectiveOAuthUrl: L,
|
|
3838
3838
|
storageKeyPrefix: i,
|
|
3839
|
-
oauthClientConfig:
|
|
3839
|
+
oauthClientConfig: P,
|
|
3840
3840
|
callbackUrl: r,
|
|
3841
3841
|
preventAutoAuth: m,
|
|
3842
3842
|
useRedirectFlow: h,
|
|
3843
|
-
gatewayUrl:
|
|
3843
|
+
gatewayUrl: I,
|
|
3844
3844
|
oauthProxyUrl: c,
|
|
3845
3845
|
onPopupWindow: g,
|
|
3846
3846
|
proxyOAuthRequests: !0,
|
|
3847
|
-
staticClientInfo:
|
|
3847
|
+
staticClientInfo: D,
|
|
3848
3848
|
clientMetadataUrl: E,
|
|
3849
|
-
scope:
|
|
3849
|
+
scope: ie
|
|
3850
3850
|
});
|
|
3851
|
-
W.current = e, t && J("debug", `OAuth BFF enabled: ${t}`), J("debug", `BrowserOAuthClientProvider initialized with URL: ${
|
|
3851
|
+
W.current = e, t && J("debug", `OAuth BFF enabled: ${t}`), J("debug", `BrowserOAuthClientProvider initialized with URL: ${L}, proxy: ${t ? "enabled" : "disabled"}, gateway: ${I ? "enabled" : "disabled"}`);
|
|
3852
3852
|
}
|
|
3853
3853
|
U.current ? J("debug", "BrowserMCPClient already exists, reusing.") : (U.current = new Ki(), J("debug", "BrowserMCPClient initialized in connect."));
|
|
3854
3854
|
let e = async (n) => {
|
|
@@ -3858,16 +3858,16 @@ function pa(e) {
|
|
|
3858
3858
|
let e = ea, r = {
|
|
3859
3859
|
url: t,
|
|
3860
3860
|
timeout: _,
|
|
3861
|
-
clientInfo:
|
|
3861
|
+
clientInfo: N,
|
|
3862
3862
|
...(() => {
|
|
3863
3863
|
let e = W.current?.getProxyFetch?.(te) ?? te;
|
|
3864
3864
|
return e ? { fetch: e } : {};
|
|
3865
3865
|
})(),
|
|
3866
|
-
...
|
|
3866
|
+
...ae && { clientOptions: ae },
|
|
3867
3867
|
...x !== void 0 && { protocolNegotiation: x },
|
|
3868
3868
|
...p ? { reconnectionOptions: p } : f === !1 ? { reconnectionOptions: { maxRetries: 0 } } : {}
|
|
3869
3869
|
};
|
|
3870
|
-
if (
|
|
3870
|
+
if (I && (r.gatewayUrl = I, J("debug", `Using proxy gateway: ${I} for target: ${t}`)), R && Object.keys(R).length > 0 && (r.headers = R), !U.current) {
|
|
3871
3871
|
if (!K.current) return J("debug", "Connection aborted - component unmounted, client cleaned up"), "failed";
|
|
3872
3872
|
let e = /* @__PURE__ */ Error("Client not initialized - this is a bug in the connection flow");
|
|
3873
3873
|
throw J("error", "Client ref is null in tryConnectWithTransport but component is still mounted"), e;
|
|
@@ -3884,10 +3884,10 @@ function pa(e) {
|
|
|
3884
3884
|
});
|
|
3885
3885
|
let i = await U.current.connect(e);
|
|
3886
3886
|
if (Re.current = i, !K.current) return J("debug", "Connection aborted after connection creation - component unmounted"), "failed";
|
|
3887
|
-
J("info", "✅ Successfully connected to MCP server"), J("info", "Server info:", i.info.server), J("info", "Server capabilities:", i.info.capabilities),
|
|
3888
|
-
gatewayUrl:
|
|
3887
|
+
J("info", "✅ Successfully connected to MCP server"), J("info", "Server info:", i.info.server), J("info", "Server capabilities:", i.info.capabilities), F.enabled && F.healthCheckInterval !== !1 && (i._healthCheckCleanup = ca({
|
|
3888
|
+
gatewayUrl: I,
|
|
3889
3889
|
url: t,
|
|
3890
|
-
allHeaders:
|
|
3890
|
+
allHeaders: R,
|
|
3891
3891
|
getAuthHeaders: async () => {
|
|
3892
3892
|
try {
|
|
3893
3893
|
let e = await W.current?.tokens?.();
|
|
@@ -3901,12 +3901,12 @@ function pa(e) {
|
|
|
3901
3901
|
isMountedRef: K,
|
|
3902
3902
|
stateRef: q,
|
|
3903
3903
|
autoReconnectRef: Ge,
|
|
3904
|
-
setState:
|
|
3904
|
+
setState: B,
|
|
3905
3905
|
addLog: J,
|
|
3906
3906
|
connect: at,
|
|
3907
|
-
defaultReconnectDelay:
|
|
3908
|
-
healthCheckIntervalMs:
|
|
3909
|
-
healthCheckTimeoutMs:
|
|
3907
|
+
defaultReconnectDelay: F.initialDelay,
|
|
3908
|
+
healthCheckIntervalMs: F.healthCheckInterval,
|
|
3909
|
+
healthCheckTimeoutMs: F.healthCheckTimeout
|
|
3910
3910
|
})), Pi.getInstance().trackUseMcpConnection({
|
|
3911
3911
|
url: t,
|
|
3912
3912
|
transportType: n,
|
|
@@ -3914,28 +3914,28 @@ function pa(e) {
|
|
|
3914
3914
|
hasOAuth: !!W.current,
|
|
3915
3915
|
hasSampling: Ze.current,
|
|
3916
3916
|
hasElicitation: Qe.current
|
|
3917
|
-
}).catch(() => {}),
|
|
3917
|
+
}).catch(() => {}), pe(i.tools || []);
|
|
3918
3918
|
let [a, o, s] = await Promise.all([
|
|
3919
3919
|
i.listAllResources(),
|
|
3920
3920
|
i.listPrompts(),
|
|
3921
3921
|
i.supports("resources") ? i.listResourceTemplates() : Promise.resolve({ resourceTemplates: [] })
|
|
3922
3922
|
]);
|
|
3923
3923
|
if (!K.current) return J("debug", "Connection aborted after discovery - component unmounted"), "failed";
|
|
3924
|
-
|
|
3924
|
+
he(a.resources || []), ye(o.prompts || []), _e(s.resourceTemplates || []);
|
|
3925
3925
|
let { server: c, capabilities: l, protocolEra: u, protocolVersion: d, instructions: m, extensions: h } = i.info;
|
|
3926
|
-
if (K.current && (
|
|
3926
|
+
if (K.current && (we(u), Ee(d), Oe(m), Ae(h)), c) {
|
|
3927
3927
|
if (J("debug", "Server info:", c), !K.current) return J("debug", "Skipping state update - component unmounted"), "failed";
|
|
3928
|
-
|
|
3928
|
+
xe(c), ze.current = na({
|
|
3929
3929
|
serverInfo: c,
|
|
3930
3930
|
url: t,
|
|
3931
3931
|
isMounted: () => K.current,
|
|
3932
|
-
setServerInfo:
|
|
3932
|
+
setServerInfo: xe,
|
|
3933
3933
|
addLog: J
|
|
3934
3934
|
});
|
|
3935
3935
|
}
|
|
3936
3936
|
if (l) {
|
|
3937
3937
|
if (J("debug", "Server capabilities:", l), !K.current) return J("debug", "Skipping state update - component unmounted"), "failed";
|
|
3938
|
-
|
|
3938
|
+
Se(l);
|
|
3939
3939
|
}
|
|
3940
3940
|
if (W.current) {
|
|
3941
3941
|
let e = await W.current.tokens?.();
|
|
@@ -3965,20 +3965,20 @@ function pa(e) {
|
|
|
3965
3965
|
});
|
|
3966
3966
|
}
|
|
3967
3967
|
}
|
|
3968
|
-
return Ke.current = n,
|
|
3968
|
+
return Ke.current = n, B("ready"), "success";
|
|
3969
3969
|
} catch (r) {
|
|
3970
3970
|
let i = r, a = i?.message || String(r), o = W.current?.getLastAttemptedAuthUrl?.();
|
|
3971
|
-
if (o && W.current && m) return J("info", "OAuth already discovered (stored auth URL present); awaiting manual authentication."), K.current && (
|
|
3971
|
+
if (o && W.current && m) return J("info", "OAuth already discovered (stored auth URL present); awaiting manual authentication."), K.current && (B("pending_auth"), H(o)), G.current = !1, "auth_redirect";
|
|
3972
3972
|
let s = aa(r), c = Ii(r);
|
|
3973
|
-
if (s &&
|
|
3974
|
-
if (s && (!
|
|
3973
|
+
if (s && k && Object.keys(k).length > 0) return Y("Authentication failed (HTTP 401). Server does not support OAuth. Check your Authorization header value is correct."), "failed";
|
|
3974
|
+
if (s && (!k || Object.keys(k).length === 0)) return Y("Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."), "failed";
|
|
3975
3975
|
if (c) {
|
|
3976
3976
|
if (s) return Y("Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."), "failed";
|
|
3977
3977
|
if (W.current) if (J("info", "Authentication required. OAuth provider available."), m) {
|
|
3978
3978
|
if (J("info", "Waiting for user to initiate authentication flow..."), K.current) {
|
|
3979
|
-
|
|
3979
|
+
B("pending_auth");
|
|
3980
3980
|
let e = W.current?.getLastAttemptedAuthUrl?.();
|
|
3981
|
-
e && (
|
|
3981
|
+
e && (H(e), J("info", "Retrieved stored auth URL for manual authentication"));
|
|
3982
3982
|
}
|
|
3983
3983
|
return G.current = !1, "auth_redirect";
|
|
3984
3984
|
} else {
|
|
@@ -4001,7 +4001,7 @@ function pa(e) {
|
|
|
4001
4001
|
return Y(`Automatic OAuth authentication failed: ${e instanceof Error ? e.message : String(e)}`, e instanceof Error ? e : Error(String(e))), "failed";
|
|
4002
4002
|
}
|
|
4003
4003
|
}
|
|
4004
|
-
return
|
|
4004
|
+
return k && Object.keys(k).length > 0 ? (Y("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."), "failed") : (Y("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."), "failed");
|
|
4005
4005
|
}
|
|
4006
4006
|
return Y(a, i instanceof Error ? i : Error(String(i))) ? "auth_redirect" : "failed";
|
|
4007
4007
|
}
|
|
@@ -4014,37 +4014,37 @@ function pa(e) {
|
|
|
4014
4014
|
t,
|
|
4015
4015
|
i,
|
|
4016
4016
|
r,
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
O,
|
|
4022
|
-
E,
|
|
4017
|
+
P.name,
|
|
4018
|
+
P.version,
|
|
4019
|
+
P.uri,
|
|
4020
|
+
P.logo_uri,
|
|
4023
4021
|
D,
|
|
4024
|
-
|
|
4022
|
+
E,
|
|
4023
|
+
ie,
|
|
4024
|
+
k,
|
|
4025
4025
|
re,
|
|
4026
4026
|
m,
|
|
4027
4027
|
h,
|
|
4028
4028
|
g,
|
|
4029
4029
|
n,
|
|
4030
4030
|
_,
|
|
4031
|
-
|
|
4032
|
-
|
|
4031
|
+
N,
|
|
4032
|
+
ae,
|
|
4033
4033
|
x,
|
|
4034
|
-
|
|
4034
|
+
I,
|
|
4035
4035
|
c,
|
|
4036
|
-
z,
|
|
4037
4036
|
R,
|
|
4037
|
+
L,
|
|
4038
4038
|
et,
|
|
4039
4039
|
tt,
|
|
4040
4040
|
nt
|
|
4041
4041
|
]);
|
|
4042
|
-
(0,
|
|
4042
|
+
(0, j.useEffect)(() => {
|
|
4043
4043
|
qe.current = at, Je.current = Y;
|
|
4044
4044
|
}, [at, Y]);
|
|
4045
|
-
let ot = (0,
|
|
4045
|
+
let ot = (0, j.useCallback)(() => {
|
|
4046
4046
|
q.current === "failed" ? (J("info", "Retry requested..."), qe.current?.()) : J("warn", `Retry called but state is not 'failed' (state: ${q.current}). Ignoring.`);
|
|
4047
|
-
}, [J]), st = (0,
|
|
4047
|
+
}, [J]), st = (0, j.useCallback)(async () => {
|
|
4048
4048
|
J("info", "Manual authentication requested...");
|
|
4049
4049
|
let e = q.current;
|
|
4050
4050
|
if (e === "failed") J("info", "Attempting to reconnect and authenticate via retry..."), ot();
|
|
@@ -4060,15 +4060,15 @@ function pa(e) {
|
|
|
4060
4060
|
}), qe.current?.();
|
|
4061
4061
|
return;
|
|
4062
4062
|
}
|
|
4063
|
-
J("info", `Cleared ${W.current.clearStorage?.() ?? 0} OAuth storage item(s) for fresh authentication`),
|
|
4063
|
+
J("info", `Cleared ${W.current.clearStorage?.() ?? 0} OAuth storage item(s) for fresh authentication`), B("authenticating");
|
|
4064
4064
|
let e = null, n = null, { provider: o, oauthProxyUrl: s } = sa({
|
|
4065
|
-
effectiveOAuthUrl:
|
|
4065
|
+
effectiveOAuthUrl: L,
|
|
4066
4066
|
storageKeyPrefix: i,
|
|
4067
|
-
oauthClientConfig:
|
|
4067
|
+
oauthClientConfig: P,
|
|
4068
4068
|
callbackUrl: r,
|
|
4069
4069
|
preventAutoAuth: !1,
|
|
4070
4070
|
useRedirectFlow: h,
|
|
4071
|
-
gatewayUrl:
|
|
4071
|
+
gatewayUrl: I,
|
|
4072
4072
|
oauthProxyUrl: c,
|
|
4073
4073
|
onPopupWindow: (t, r, i) => {
|
|
4074
4074
|
e = i;
|
|
@@ -4078,9 +4078,9 @@ function pa(e) {
|
|
|
4078
4078
|
g?.(t, r, i);
|
|
4079
4079
|
},
|
|
4080
4080
|
proxyOAuthRequests: !0,
|
|
4081
|
-
staticClientInfo:
|
|
4081
|
+
staticClientInfo: D,
|
|
4082
4082
|
clientMetadataUrl: E,
|
|
4083
|
-
scope:
|
|
4083
|
+
scope: ie
|
|
4084
4084
|
});
|
|
4085
4085
|
s && J("info", "Scoped OAuth proxy fetch enabled for manual auth"), W.current = o, J("info", "Triggering fresh OAuth authorization...");
|
|
4086
4086
|
let l = new URL(t), u = l.origin + l.pathname.replace(/\/+$/, "");
|
|
@@ -4093,7 +4093,7 @@ function pa(e) {
|
|
|
4093
4093
|
J("info", "OAuth flow initiated (popup/redirect):", e instanceof Error ? e.message : "Redirecting...");
|
|
4094
4094
|
}
|
|
4095
4095
|
let d = o.getLastAttemptedAuthUrl?.();
|
|
4096
|
-
if (d && (
|
|
4096
|
+
if (d && (H(d), J("info", "Updated auth URL for fallback:", d), !n)) try {
|
|
4097
4097
|
n = new URL(d).searchParams.get("state");
|
|
4098
4098
|
} catch {}
|
|
4099
4099
|
if (h) return;
|
|
@@ -4119,10 +4119,10 @@ function pa(e) {
|
|
|
4119
4119
|
J("info", "Authentication succeeded; reconnecting to MCP server..."), G.current = !1, qe.current?.();
|
|
4120
4120
|
break;
|
|
4121
4121
|
case "cancelled":
|
|
4122
|
-
J("warn", "Authentication popup was closed before completing. Returning to pending_auth."),
|
|
4122
|
+
J("warn", "Authentication popup was closed before completing. Returning to pending_auth."), B("pending_auth");
|
|
4123
4123
|
break;
|
|
4124
4124
|
case "timeout":
|
|
4125
|
-
J("warn", "Authentication timed out waiting for the popup. Returning to pending_auth."),
|
|
4125
|
+
J("warn", "Authentication timed out waiting for the popup. Returning to pending_auth."), B("pending_auth");
|
|
4126
4126
|
break;
|
|
4127
4127
|
case "error":
|
|
4128
4128
|
Y(`Authentication failed: ${p.error}`);
|
|
@@ -4131,39 +4131,39 @@ function pa(e) {
|
|
|
4131
4131
|
}
|
|
4132
4132
|
} catch (e) {
|
|
4133
4133
|
if (!K.current) return;
|
|
4134
|
-
|
|
4134
|
+
B("pending_auth"), J("error", `Manual authentication failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
4135
4135
|
}
|
|
4136
4136
|
} else if (e === "authenticating") {
|
|
4137
4137
|
J("warn", "Already attempting authentication. Check for blocked popups or wait for timeout.");
|
|
4138
4138
|
let e = W.current?.getLastAttemptedAuthUrl?.();
|
|
4139
|
-
e && !
|
|
4139
|
+
e && !Fe && (H(e), J("info", "Manual authentication URL retrieved:", e));
|
|
4140
4140
|
} else J("info", `Client not in a state requiring manual authentication trigger (state: ${e}). If needed, try disconnecting and reconnecting.`);
|
|
4141
4141
|
}, [
|
|
4142
4142
|
J,
|
|
4143
4143
|
ot,
|
|
4144
4144
|
Y,
|
|
4145
|
-
|
|
4145
|
+
Fe,
|
|
4146
4146
|
t,
|
|
4147
4147
|
h,
|
|
4148
4148
|
g,
|
|
4149
4149
|
i,
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
O,
|
|
4154
|
-
E,
|
|
4150
|
+
P.name,
|
|
4151
|
+
P.uri,
|
|
4152
|
+
P.logo_uri,
|
|
4155
4153
|
D,
|
|
4154
|
+
E,
|
|
4155
|
+
ie,
|
|
4156
4156
|
r,
|
|
4157
|
-
|
|
4157
|
+
N,
|
|
4158
4158
|
a
|
|
4159
|
-
]), ct = (0,
|
|
4160
|
-
W.current?.clearStorage ? (J("info", `Cleared ${W.current.clearStorage()} item(s) from localStorage for ${t}.`),
|
|
4159
|
+
]), ct = (0, j.useCallback)(() => {
|
|
4160
|
+
W.current?.clearStorage ? (J("info", `Cleared ${W.current.clearStorage()} item(s) from localStorage for ${t}.`), H(void 0), it()) : J("warn", "Auth provider not initialized, cannot clear storage.");
|
|
4161
4161
|
}, [
|
|
4162
4162
|
t,
|
|
4163
4163
|
J,
|
|
4164
4164
|
it
|
|
4165
4165
|
]);
|
|
4166
|
-
(0,
|
|
4166
|
+
(0, j.useEffect)(() => {
|
|
4167
4167
|
if (typeof window > "u") return;
|
|
4168
4168
|
let e = (e, t) => {
|
|
4169
4169
|
if (We.current) {
|
|
@@ -4206,28 +4206,28 @@ function pa(e) {
|
|
|
4206
4206
|
}
|
|
4207
4207
|
He.current && clearTimeout(He.current);
|
|
4208
4208
|
};
|
|
4209
|
-
}, [J]), (0,
|
|
4210
|
-
if (K.current = !0, !n || !t) return J("debug", n ? "No server URL provided, skipping connection." : "Connection disabled via enabled flag."),
|
|
4209
|
+
}, [J]), (0, j.useEffect)(() => {
|
|
4210
|
+
if (K.current = !0, !n || !t) return J("debug", n ? "No server URL provided, skipping connection." : "Connection disabled via enabled flag."), B("discovering"), () => {
|
|
4211
4211
|
K.current = !1;
|
|
4212
4212
|
};
|
|
4213
4213
|
if (J("debug", "useMcp mounted, initiating connection."), Be.current = 0, a) W.current = a, J("debug", "Using externally provided authProvider");
|
|
4214
|
-
else if (!W.current || W.current.serverUrl !==
|
|
4214
|
+
else if (!W.current || W.current.serverUrl !== L) {
|
|
4215
4215
|
let { provider: e, oauthProxyUrl: t } = sa({
|
|
4216
|
-
effectiveOAuthUrl:
|
|
4216
|
+
effectiveOAuthUrl: L,
|
|
4217
4217
|
storageKeyPrefix: i,
|
|
4218
|
-
oauthClientConfig:
|
|
4218
|
+
oauthClientConfig: P,
|
|
4219
4219
|
callbackUrl: r,
|
|
4220
4220
|
preventAutoAuth: m,
|
|
4221
4221
|
useRedirectFlow: h,
|
|
4222
|
-
gatewayUrl:
|
|
4222
|
+
gatewayUrl: I,
|
|
4223
4223
|
oauthProxyUrl: c,
|
|
4224
4224
|
onPopupWindow: g,
|
|
4225
4225
|
proxyOAuthRequests: !0,
|
|
4226
|
-
staticClientInfo:
|
|
4226
|
+
staticClientInfo: D,
|
|
4227
4227
|
clientMetadataUrl: E,
|
|
4228
|
-
scope:
|
|
4228
|
+
scope: ie
|
|
4229
4229
|
});
|
|
4230
|
-
W.current = e, t && J("debug", `OAuth proxy URL in effect: ${t}`), J("debug", `BrowserOAuthClientProvider initialized/updated with URL: ${
|
|
4230
|
+
W.current = e, t && J("debug", `OAuth proxy URL in effect: ${t}`), J("debug", `BrowserOAuthClientProvider initialized/updated with URL: ${L}, proxy: ${t ? "enabled" : "disabled"}, gateway: ${I ? "enabled" : "disabled"}`);
|
|
4231
4231
|
}
|
|
4232
4232
|
return at(), () => {
|
|
4233
4233
|
K.current = !1, J("debug", "useMcp unmounting, disconnecting."), it(!0);
|
|
@@ -4237,25 +4237,25 @@ function pa(e) {
|
|
|
4237
4237
|
n,
|
|
4238
4238
|
i,
|
|
4239
4239
|
r,
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
O,
|
|
4245
|
-
E,
|
|
4240
|
+
P.name,
|
|
4241
|
+
P.version,
|
|
4242
|
+
P.uri,
|
|
4243
|
+
P.logo_uri,
|
|
4246
4244
|
D,
|
|
4245
|
+
E,
|
|
4246
|
+
ie,
|
|
4247
4247
|
h,
|
|
4248
|
-
|
|
4249
|
-
|
|
4248
|
+
N,
|
|
4249
|
+
L,
|
|
4250
4250
|
s,
|
|
4251
4251
|
a
|
|
4252
4252
|
]);
|
|
4253
|
-
let lt = (0,
|
|
4254
|
-
(0,
|
|
4253
|
+
let lt = (0, j.useRef)(ot), ut = (0, j.useRef)(J);
|
|
4254
|
+
(0, j.useEffect)(() => {
|
|
4255
4255
|
lt.current = ot, ut.current = J;
|
|
4256
|
-
}, [ot, J]), (0,
|
|
4256
|
+
}, [ot, J]), (0, j.useEffect)(() => {
|
|
4257
4257
|
let e = null;
|
|
4258
|
-
if (
|
|
4258
|
+
if (z === "failed" && d && Be.current > 0) {
|
|
4259
4259
|
if (!Ue.current) {
|
|
4260
4260
|
Ue.current = !0;
|
|
4261
4261
|
let t = typeof d == "number" ? d : fa;
|
|
@@ -4263,28 +4263,28 @@ function pa(e) {
|
|
|
4263
4263
|
Ue.current = !1, K.current && q.current === "failed" && lt.current();
|
|
4264
4264
|
}, t);
|
|
4265
4265
|
}
|
|
4266
|
-
} else
|
|
4266
|
+
} else z !== "failed" && (Ue.current = !1);
|
|
4267
4267
|
return () => {
|
|
4268
4268
|
e && (clearTimeout(e), Ue.current = !1);
|
|
4269
4269
|
};
|
|
4270
|
-
}, [
|
|
4271
|
-
let dt = (0,
|
|
4270
|
+
}, [z, d]);
|
|
4271
|
+
let dt = (0, j.useCallback)(async () => q.current === "ready" ? be?.icon ? be.icon : ze.current ? (J("debug", "Waiting for icon to finish loading..."), await ze.current) : (J("debug", "No icon available and no loading in progress"), null) : (J("warn", "Cannot ensure icon loaded - not connected"), null), [be, J]);
|
|
4272
4272
|
return {
|
|
4273
|
-
state:
|
|
4274
|
-
name:
|
|
4275
|
-
tools:
|
|
4276
|
-
resources:
|
|
4277
|
-
resourceTemplates:
|
|
4278
|
-
prompts:
|
|
4279
|
-
serverInfo:
|
|
4280
|
-
capabilities:
|
|
4281
|
-
protocolEra:
|
|
4282
|
-
protocolVersion:
|
|
4283
|
-
instructions:
|
|
4284
|
-
extensions:
|
|
4285
|
-
error:
|
|
4286
|
-
log:
|
|
4287
|
-
authUrl:
|
|
4273
|
+
state: z,
|
|
4274
|
+
name: be?.name || t || "",
|
|
4275
|
+
tools: fe,
|
|
4276
|
+
resources: me,
|
|
4277
|
+
resourceTemplates: ge,
|
|
4278
|
+
prompts: ve,
|
|
4279
|
+
serverInfo: be,
|
|
4280
|
+
capabilities: V,
|
|
4281
|
+
protocolEra: Ce,
|
|
4282
|
+
protocolVersion: Te,
|
|
4283
|
+
instructions: De,
|
|
4284
|
+
extensions: ke,
|
|
4285
|
+
error: je,
|
|
4286
|
+
log: Ne,
|
|
4287
|
+
authUrl: Fe,
|
|
4288
4288
|
authTokens: Ie,
|
|
4289
4289
|
client: U.current,
|
|
4290
4290
|
...rt,
|
|
@@ -4459,14 +4459,14 @@ function Ea(e) {
|
|
|
4459
4459
|
}
|
|
4460
4460
|
var Da = 500, Oa = 5 * 6e4;
|
|
4461
4461
|
function ka(e) {
|
|
4462
|
-
let [t, n] = (0,
|
|
4462
|
+
let [t, n] = (0, j.useState)([]), [r, i] = (0, j.useState)([]), [a, o] = (0, j.useState)([]), s = (0, j.useRef)(0), c = (0, j.useRef)(0), l = (0, j.useRef)(/* @__PURE__ */ new Map()), u = (0, j.useRef)(/* @__PURE__ */ new Map()), d = (0, j.useCallback)((e) => {
|
|
4463
4463
|
for (let t of l.current.values()) clearTimeout(t.timeout), t.reject(Error(e));
|
|
4464
4464
|
l.current.clear();
|
|
4465
4465
|
for (let t of u.current.values()) clearTimeout(t.timeout), t.reject(Error(e));
|
|
4466
4466
|
u.current.clear(), i([]), o([]);
|
|
4467
4467
|
}, []);
|
|
4468
|
-
(0,
|
|
4469
|
-
let f = (0,
|
|
4468
|
+
(0, j.useEffect)(() => () => d("MCP server connection was removed"), [d]);
|
|
4469
|
+
let f = (0, j.useCallback)((t) => {
|
|
4470
4470
|
let r = {
|
|
4471
4471
|
id: globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random()}`,
|
|
4472
4472
|
method: t.method,
|
|
@@ -4475,13 +4475,13 @@ function ka(e) {
|
|
|
4475
4475
|
read: !1
|
|
4476
4476
|
};
|
|
4477
4477
|
n((e) => [r, ...e].slice(0, Da)), e.onNotificationReceived?.(r);
|
|
4478
|
-
}, [e.onNotificationReceived]), p = (0,
|
|
4478
|
+
}, [e.onNotificationReceived]), p = (0, j.useCallback)((e, t) => {
|
|
4479
4479
|
let n = l.current.get(e);
|
|
4480
4480
|
n && (clearTimeout(n.timeout), l.current.delete(e), i((t) => t.filter((t) => t.id !== e)), n.resolve(t));
|
|
4481
|
-
}, []), m = (0,
|
|
4481
|
+
}, []), m = (0, j.useCallback)((e, t) => {
|
|
4482
4482
|
let n = l.current.get(e);
|
|
4483
4483
|
n && (clearTimeout(n.timeout), l.current.delete(e), i((t) => t.filter((t) => t.id !== e)), n.reject(Error(t ?? "User rejected sampling request")));
|
|
4484
|
-
}, []), h = (0,
|
|
4484
|
+
}, []), h = (0, j.useCallback)((t) => new Promise((n, r) => {
|
|
4485
4485
|
let a = `sampling-${s.current++}`, o = {
|
|
4486
4486
|
id: a,
|
|
4487
4487
|
request: {
|
|
@@ -4500,13 +4500,13 @@ function ka(e) {
|
|
|
4500
4500
|
p,
|
|
4501
4501
|
e,
|
|
4502
4502
|
m
|
|
4503
|
-
]), g = (0,
|
|
4503
|
+
]), g = (0, j.useCallback)((e, t) => {
|
|
4504
4504
|
let n = u.current.get(e);
|
|
4505
4505
|
n && (clearTimeout(n.timeout), u.current.delete(e), o((t) => t.filter((t) => t.id !== e)), n.resolve(t));
|
|
4506
|
-
}, []), _ = (0,
|
|
4506
|
+
}, []), _ = (0, j.useCallback)((e, t) => {
|
|
4507
4507
|
let n = u.current.get(e);
|
|
4508
4508
|
n && (clearTimeout(n.timeout), u.current.delete(e), o((t) => t.filter((t) => t.id !== e)), n.reject(Error(t ?? "User rejected elicitation request")));
|
|
4509
|
-
}, []), v = (0,
|
|
4509
|
+
}, []), v = (0, j.useCallback)((t) => new Promise((n, r) => {
|
|
4510
4510
|
let i = `elicitation-${c.current++}`, a = {
|
|
4511
4511
|
id: i,
|
|
4512
4512
|
request: t,
|
|
@@ -4522,15 +4522,15 @@ function ka(e) {
|
|
|
4522
4522
|
g,
|
|
4523
4523
|
e,
|
|
4524
4524
|
_
|
|
4525
|
-
]), ee = (0,
|
|
4525
|
+
]), ee = (0, j.useCallback)((e) => {
|
|
4526
4526
|
n((t) => t.map((t) => t.id === e ? {
|
|
4527
4527
|
...t,
|
|
4528
4528
|
read: !0
|
|
4529
4529
|
} : t));
|
|
4530
|
-
}, []), te = (0,
|
|
4530
|
+
}, []), te = (0, j.useCallback)(() => n((e) => e.map((e) => ({
|
|
4531
4531
|
...e,
|
|
4532
4532
|
read: !0
|
|
4533
|
-
}))), []), y = (0,
|
|
4533
|
+
}))), []), y = (0, j.useCallback)(() => n([]), []);
|
|
4534
4534
|
return {
|
|
4535
4535
|
notifications: t,
|
|
4536
4536
|
pendingSamplingRequests: r,
|
|
@@ -4549,7 +4549,7 @@ function ka(e) {
|
|
|
4549
4549
|
rejectAll: d
|
|
4550
4550
|
};
|
|
4551
4551
|
}
|
|
4552
|
-
var Q = pr.get("McpClientProvider"), Aa = (0,
|
|
4552
|
+
var Q = pr.get("McpClientProvider"), Aa = (0, j.createContext)(null);
|
|
4553
4553
|
function $(e, t) {
|
|
4554
4554
|
return JSON.stringify(e) === JSON.stringify(t);
|
|
4555
4555
|
}
|
|
@@ -4557,7 +4557,7 @@ function ja(e, t) {
|
|
|
4557
4557
|
return e.id === t.id && $(Ta(e), Ta(t)) && e.name === t.name && e.state === t.state && e.error === t.error && e.authUrl === t.authUrl && $(e.authTokens, t.authTokens) && e.protocolEra === t.protocolEra && e.protocolVersion === t.protocolVersion && $(e.serverInfo, t.serverInfo) && $(e.capabilities, t.capabilities) && e.instructions === t.instructions && $(e.extensions, t.extensions) && $(e.tools, t.tools) && $(e.resources, t.resources) && $(e.resourceTemplates, t.resourceTemplates) && $(e.prompts, t.prompts) && $(e.notifications, t.notifications) && e.unreadNotificationCount === t.unreadNotificationCount && $(e.pendingSamplingRequests, t.pendingSamplingRequests) && $(e.pendingElicitationRequests, t.pendingElicitationRequests) && e.client === t.client;
|
|
4558
4558
|
}
|
|
4559
4559
|
function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r, defaultProxyConfig: i, defaultAutoProxyFallback: a, clientInfo: o, cachedMetadata: s, onUpdate: c, onUpdateConfig: l, onUpdateDisplayName: u, onReconnect: d, rpcWrapTransport: f, onGlobalSamplingRequest: p, onGlobalElicitationRequest: m }) {
|
|
4560
|
-
let { displayName: h, onSamplingRequest: g, onElicitationRequest: _, onNotificationReceived: v, wrapTransport: ee } = t, te = (0,
|
|
4560
|
+
let { displayName: h, onSamplingRequest: g, onElicitationRequest: _, onNotificationReceived: v, wrapTransport: ee } = t, te = (0, j.useMemo)(() => {
|
|
4561
4561
|
let { displayName: c, onSamplingRequest: l, onElicitationRequest: u, onNotificationReceived: d, wrapTransport: f, ...p } = t;
|
|
4562
4562
|
return {
|
|
4563
4563
|
...p,
|
|
@@ -4580,7 +4580,7 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
|
|
|
4580
4580
|
a,
|
|
4581
4581
|
o,
|
|
4582
4582
|
s
|
|
4583
|
-
]), y = (0,
|
|
4583
|
+
]), y = (0, j.useMemo)(() => {
|
|
4584
4584
|
if (!(!f && !ee)) return (t) => {
|
|
4585
4585
|
let n = t;
|
|
4586
4586
|
return f && (n = f(n, e)), ee && (n = ee(n, e)), n;
|
|
@@ -4604,10 +4604,10 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
|
|
|
4604
4604
|
onElicitation: b.onElicitation,
|
|
4605
4605
|
wrapTransport: y
|
|
4606
4606
|
});
|
|
4607
|
-
(0,
|
|
4607
|
+
(0, j.useEffect)(() => {
|
|
4608
4608
|
x.state !== "ready" && b.rejectAll("MCP server connection is no longer active");
|
|
4609
4609
|
}, [x.state, b.rejectAll]);
|
|
4610
|
-
let S = (0,
|
|
4610
|
+
let S = (0, j.useCallback)((t) => l(e, t), [e, l]), C = (0, j.useCallback)((n) => {
|
|
4611
4611
|
let r = t.proxyConfig?.proxyAddress?.trim();
|
|
4612
4612
|
return t.connectionMode === "proxy" && r ? l(e, {
|
|
4613
4613
|
proxyConfig: {
|
|
@@ -4622,10 +4622,10 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
|
|
|
4622
4622
|
t.connectionMode,
|
|
4623
4623
|
t.proxyConfig,
|
|
4624
4624
|
l
|
|
4625
|
-
]), ne = (0,
|
|
4626
|
-
return (0,
|
|
4625
|
+
]), ne = (0, j.useCallback)((t) => u(e, t), [e, u]), w = (0, j.useCallback)(() => d(e), [e, d]), re = (0, j.useRef)(c), T = (0, j.useRef)(null);
|
|
4626
|
+
return (0, j.useEffect)(() => {
|
|
4627
4627
|
re.current = c;
|
|
4628
|
-
}, [c]), (0,
|
|
4628
|
+
}, [c]), (0, j.useEffect)(() => {
|
|
4629
4629
|
let n = {
|
|
4630
4630
|
...Ea(t),
|
|
4631
4631
|
...x,
|
|
@@ -4675,12 +4675,12 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
|
|
|
4675
4675
|
]), null;
|
|
4676
4676
|
}
|
|
4677
4677
|
function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r, defaultProxyConfig: i, defaultAutoProxyFallback: a = !1, defaultServerConfig: o, clientInfo: s, storageProvider: c, enableRpcLogging: l = !1, onServerAdded: u, onServerRemoved: d, onServerStateChange: f, onSamplingRequest: p, onElicitationRequest: m }) {
|
|
4678
|
-
let [h, g] = (0,
|
|
4679
|
-
(0,
|
|
4678
|
+
let [h, g] = (0, j.useState)([]), [_, v] = (0, j.useState)([]), [ee, te] = (0, j.useState)({}), [y, b] = (0, j.useState)(!1), x = (0, j.useRef)(!1), S = (0, j.useRef)([]);
|
|
4679
|
+
(0, j.useEffect)(() => {
|
|
4680
4680
|
S.current = _;
|
|
4681
4681
|
}, [_]);
|
|
4682
|
-
let C = (0,
|
|
4683
|
-
(0,
|
|
4682
|
+
let C = (0, j.useRef)({}), [ne, w] = (0, j.useState)(void 0), [re, T] = (0, j.useState)(!1);
|
|
4683
|
+
(0, j.useEffect)(() => {
|
|
4684
4684
|
if (!l || typeof window > "u") {
|
|
4685
4685
|
w(void 0), T(!0);
|
|
4686
4686
|
return;
|
|
@@ -4690,7 +4690,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
|
|
|
4690
4690
|
}).catch((e) => {
|
|
4691
4691
|
Q.error("[McpClientProvider] Failed to load RPC logger:", e), w(void 0), T(!0);
|
|
4692
4692
|
});
|
|
4693
|
-
}, [l]), (0,
|
|
4693
|
+
}, [l]), (0, j.useEffect)(() => {
|
|
4694
4694
|
if (!re) {
|
|
4695
4695
|
Q.debug("[McpClientProvider] Waiting for RPC logging to be ready before loading servers");
|
|
4696
4696
|
return;
|
|
@@ -4734,7 +4734,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
|
|
|
4734
4734
|
c,
|
|
4735
4735
|
t,
|
|
4736
4736
|
re
|
|
4737
|
-
]), (0,
|
|
4737
|
+
]), (0, j.useEffect)(() => {
|
|
4738
4738
|
!c || !y || (async () => {
|
|
4739
4739
|
try {
|
|
4740
4740
|
let e = h.reduce((e, t) => (e[t.id] = Ea(t.options), e), {});
|
|
@@ -4748,7 +4748,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
|
|
|
4748
4748
|
c,
|
|
4749
4749
|
y
|
|
4750
4750
|
]);
|
|
4751
|
-
let E = (0,
|
|
4751
|
+
let E = (0, j.useCallback)((e) => {
|
|
4752
4752
|
Q.debug(`[McpClientProvider] handleServerUpdate called for server ${e.id}`, {
|
|
4753
4753
|
toolCount: e.tools.length,
|
|
4754
4754
|
state: e.state
|
|
@@ -4786,12 +4786,12 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
|
|
|
4786
4786
|
u,
|
|
4787
4787
|
f,
|
|
4788
4788
|
c
|
|
4789
|
-
]),
|
|
4789
|
+
]), ie = (0, j.useCallback)((e, t) => {
|
|
4790
4790
|
g((n) => n.find((t) => t.id === e) ? n : (Q.debug("[McpClientProvider] Adding new server to configs:", e), [...n, {
|
|
4791
4791
|
id: e,
|
|
4792
4792
|
options: t
|
|
4793
4793
|
}]));
|
|
4794
|
-
}, []),
|
|
4794
|
+
}, []), D = (0, j.useCallback)(async (e, t) => {
|
|
4795
4795
|
let n = S.current.find((t) => t.id === e);
|
|
4796
4796
|
if (v((t) => t.filter((t) => t.id !== e)), g((t) => t.filter((t) => t.id !== e)), te((t) => {
|
|
4797
4797
|
let { [e]: n, ...r } = t;
|
|
@@ -4801,7 +4801,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
|
|
|
4801
4801
|
t(e);
|
|
4802
4802
|
}
|
|
4803
4803
|
d?.(e);
|
|
4804
|
-
}, [l, d]),
|
|
4804
|
+
}, [l, d]), O = (0, j.useCallback)(async (e, t) => {
|
|
4805
4805
|
let n = h.find((t) => t.id === e);
|
|
4806
4806
|
if (!n) {
|
|
4807
4807
|
Q.warn(`[McpClientProvider] Cannot update server "${e}" - not found`);
|
|
@@ -4818,7 +4818,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
|
|
|
4818
4818
|
...t,
|
|
4819
4819
|
[e]: (t[e] ?? 0) + 1
|
|
4820
4820
|
})));
|
|
4821
|
-
}, [h]),
|
|
4821
|
+
}, [h]), k = (0, j.useCallback)(async (e) => {
|
|
4822
4822
|
if (!h.find((t) => t.id === e)) {
|
|
4823
4823
|
Q.warn(`[McpClientProvider] Cannot reconnect server "${e}" - not found`);
|
|
4824
4824
|
return;
|
|
@@ -4827,7 +4827,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
|
|
|
4827
4827
|
...t,
|
|
4828
4828
|
[e]: (t[e] ?? 0) + 1
|
|
4829
4829
|
}));
|
|
4830
|
-
}, [h]),
|
|
4830
|
+
}, [h]), ae = (0, j.useCallback)(async (e, t) => new Promise((n) => {
|
|
4831
4831
|
let r = h.find((t) => t.id === e);
|
|
4832
4832
|
if (!r) {
|
|
4833
4833
|
Q.warn(`[McpClientProvider] Cannot update server metadata for "${e}" - not found`), n();
|
|
@@ -4847,33 +4847,33 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
|
|
|
4847
4847
|
} : t);
|
|
4848
4848
|
return setTimeout(() => n(), 0), r;
|
|
4849
4849
|
});
|
|
4850
|
-
}), [h]),
|
|
4850
|
+
}), [h]), A = (0, j.useCallback)((e) => _.find((t) => t.id === e), [_]), oe = (0, j.useMemo)(() => ({
|
|
4851
4851
|
servers: _,
|
|
4852
|
-
addServer:
|
|
4853
|
-
removeServer:
|
|
4854
|
-
updateServerMetadata:
|
|
4855
|
-
updateServer:
|
|
4856
|
-
getServer:
|
|
4852
|
+
addServer: ie,
|
|
4853
|
+
removeServer: D,
|
|
4854
|
+
updateServerMetadata: ae,
|
|
4855
|
+
updateServer: O,
|
|
4856
|
+
getServer: A,
|
|
4857
4857
|
storageLoaded: y
|
|
4858
4858
|
}), [
|
|
4859
4859
|
_,
|
|
4860
|
+
ie,
|
|
4860
4861
|
D,
|
|
4862
|
+
ae,
|
|
4861
4863
|
O,
|
|
4862
|
-
|
|
4863
|
-
k,
|
|
4864
|
-
ie,
|
|
4864
|
+
A,
|
|
4865
4865
|
y
|
|
4866
|
-
]), { capabilities:
|
|
4866
|
+
]), { capabilities: M, ...N } = s || {}, P = (0, j.useMemo)(() => Object.keys(N).length ? N : void 0, [s]), se = (0, j.useMemo)(() => h.map((e) => {
|
|
4867
4867
|
let t = o ? {
|
|
4868
4868
|
...o,
|
|
4869
4869
|
...e.options
|
|
4870
4870
|
} : e.options;
|
|
4871
|
-
return
|
|
4871
|
+
return M && (t = {
|
|
4872
4872
|
...t,
|
|
4873
4873
|
clientOptions: {
|
|
4874
4874
|
...t.clientOptions,
|
|
4875
4875
|
capabilities: {
|
|
4876
|
-
...
|
|
4876
|
+
...M,
|
|
4877
4877
|
...t.clientOptions?.capabilities
|
|
4878
4878
|
}
|
|
4879
4879
|
}
|
|
@@ -4883,10 +4883,10 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
|
|
|
4883
4883
|
};
|
|
4884
4884
|
}), [
|
|
4885
4885
|
h,
|
|
4886
|
-
|
|
4886
|
+
M,
|
|
4887
4887
|
o
|
|
4888
|
-
]),
|
|
4889
|
-
return /* @__PURE__ */
|
|
4888
|
+
]), F = typeof window < "u" && /\/oauth\/callback\/?$/.test(window.location.pathname);
|
|
4889
|
+
return /* @__PURE__ */ j.createElement(Aa.Provider, { value: oe }, e, !F && se.map((e) => /* @__PURE__ */ j.createElement(Ma, {
|
|
4890
4890
|
key: `${e.id}-v${ee[e.id] ?? 0}`,
|
|
4891
4891
|
id: e.id,
|
|
4892
4892
|
options: e.options,
|
|
@@ -4894,19 +4894,19 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
|
|
|
4894
4894
|
defaultOAuthProxyUrl: r,
|
|
4895
4895
|
defaultProxyConfig: i,
|
|
4896
4896
|
defaultAutoProxyFallback: a,
|
|
4897
|
-
clientInfo:
|
|
4897
|
+
clientInfo: P,
|
|
4898
4898
|
cachedMetadata: C.current[e.id],
|
|
4899
4899
|
onUpdate: E,
|
|
4900
|
-
onUpdateConfig:
|
|
4901
|
-
onUpdateDisplayName: (e, t) =>
|
|
4902
|
-
onReconnect:
|
|
4900
|
+
onUpdateConfig: O,
|
|
4901
|
+
onUpdateDisplayName: (e, t) => ae(e, { name: t }),
|
|
4902
|
+
onReconnect: k,
|
|
4903
4903
|
rpcWrapTransport: ne,
|
|
4904
4904
|
onGlobalSamplingRequest: p,
|
|
4905
4905
|
onGlobalElicitationRequest: m
|
|
4906
4906
|
})));
|
|
4907
4907
|
}
|
|
4908
4908
|
function Pa() {
|
|
4909
|
-
let e = (0,
|
|
4909
|
+
let e = (0, j.useContext)(Aa);
|
|
4910
4910
|
if (!e) throw Error("useMcpClient must be used within a McpClientProvider");
|
|
4911
4911
|
return e;
|
|
4912
4912
|
}
|
|
@@ -4987,7 +4987,11 @@ function Ia(e) {
|
|
|
4987
4987
|
else t[n] = r;
|
|
4988
4988
|
return t;
|
|
4989
4989
|
}
|
|
4990
|
-
|
|
4990
|
+
var La = "<script>\n(function () {\n var files = new Map();\n window.openai = window.openai || {};\n window.openai.uploadFile = async function (file) {\n var fileId = crypto.randomUUID();\n files.set(fileId, file);\n return { fileId: fileId };\n };\n window.openai.getFileDownloadUrl = async function (ref) {\n var file = files.get(ref.fileId);\n if (!file) {\n throw new Error(\"File not found: \" + ref.fileId);\n }\n return { downloadUrl: URL.createObjectURL(file) };\n };\n})();\n<\/script>";
|
|
4991
|
+
function Ra(e) {
|
|
4992
|
+
return e.includes("<head>") ? e.replace("<head>", "<head>" + La) : e.includes("<HEAD>") ? e.replace("<HEAD>", "<HEAD>" + La) : e.includes("<html>") ? e.replace("<html>", "<html><head>" + La + "</head>") : e.includes("<HTML>") ? e.replace("<HTML>", "<HTML><head>" + La + "</head>") : e.includes("<!DOCTYPE") || e.includes("<!doctype") ? e.replace(/(<!DOCTYPE[^>]*>|<!doctype[^>]*>)/i, "$1<head>" + La + "</head>") : La + e;
|
|
4993
|
+
}
|
|
4994
|
+
function za(e) {
|
|
4991
4995
|
let { resourceResult: t, listingResource: n, cspMode: r, resourceUri: i } = e, a = (Array.isArray(t?.contents) ? t.contents : [])[0], o = "", s;
|
|
4992
4996
|
if (a && (s = a.mimeType, typeof a.text == "string" ? o = a.text : typeof a.blob == "string" && (o = atob(a.blob))), !o) throw Error("No HTML content in resource");
|
|
4993
4997
|
let c = n?._meta?.ui, l = a?._meta?.ui, u = c || l ? {
|
|
@@ -5005,7 +5009,7 @@ function La(e) {
|
|
|
5005
5009
|
mimeTypeWarning: h
|
|
5006
5010
|
};
|
|
5007
5011
|
}
|
|
5008
|
-
function
|
|
5012
|
+
function Ba(e, t) {
|
|
5009
5013
|
let { cspMode: n, permissions: r, widgetCsp: i } = t;
|
|
5010
5014
|
e.searchParams.set("v", JSON.stringify({
|
|
5011
5015
|
cspMode: n,
|
|
@@ -5013,77 +5017,78 @@ function Ra(e, t) {
|
|
|
5013
5017
|
widgetCsp: i
|
|
5014
5018
|
})), e.searchParams.set("csp_mode", n), r && Object.keys(r).length > 0 && e.searchParams.set("permissions", JSON.stringify(r)), i && Object.keys(i).length > 0 && e.searchParams.set("widget_csp", JSON.stringify(i));
|
|
5015
5019
|
}
|
|
5016
|
-
function
|
|
5020
|
+
function Va(e) {
|
|
5017
5021
|
let t = new URL("https://sandbox.invalid/");
|
|
5018
|
-
|
|
5019
|
-
let n =
|
|
5022
|
+
Ba(t, e);
|
|
5023
|
+
let n = Ua(t.search);
|
|
5020
5024
|
return new URL(URL.createObjectURL(new Blob([n], { type: "text/html" })));
|
|
5021
5025
|
}
|
|
5022
|
-
var Ba = "<!doctype html>\n<html>\n <head>\n <meta charset=\"utf-8\" />\n <meta\n http-equiv=\"Content-Security-Policy\"\n content=\"default-src 'self'; img-src * data: blob: 'unsafe-inline'; media-src * blob: data:; font-src * blob: data:; script-src * 'wasm-unsafe-eval' 'unsafe-inline' 'unsafe-eval' blob: data:; style-src * blob: data: 'unsafe-inline'; connect-src * data: blob: about:; frame-src * blob: data: http://localhost:* https://localhost:* http://127.0.0.1:* https://127.0.0.1:*;\"\n />\n <title>MCP Apps Sandbox Proxy</title>\n <style>\n html, body { margin: 0; padding: 0; height: 100%; width: 100%; overflow: hidden; }\n * { box-sizing: border-box; }\n iframe { display: block; background-color: transparent; border: 0px none transparent; padding: 0px; width: 100%; height: 100%; }\n </style>\n </head>\n <body>\n <script>\n function sanitizeDomain(domain) {\n if (typeof domain !== \"string\") return \"\";\n return domain.replace(/['\"<>;]/g, \"\").trim();\n }\n\n function buildAllowAttribute(permissions) {\n if (!permissions) return \"\";\n const allowList = [];\n if (permissions.camera) allowList.push(\"camera *\");\n if (permissions.microphone) allowList.push(\"microphone *\");\n if (permissions.geolocation) allowList.push(\"geolocation *\");\n if (permissions.clipboardWrite) allowList.push(\"clipboard-write *\");\n return allowList.join(\"; \");\n }\n\n function buildCSP(csp) {\n if (!csp) {\n return [\n \"default-src 'none'\",\n \"script-src 'unsafe-inline'\",\n \"style-src 'unsafe-inline'\",\n \"img-src data:\",\n \"font-src data:\",\n \"media-src data:\",\n \"connect-src 'none'\",\n \"frame-src 'none'\",\n \"object-src 'none'\",\n \"base-uri 'none'\",\n ].join(\"; \");\n }\n\n const connectDomains = (csp.connectDomains || []).map(sanitizeDomain).filter(Boolean);\n const resourceDomains = (csp.resourceDomains || []).map(sanitizeDomain).filter(Boolean);\n const frameDomains = (csp.frameDomains || []).map(sanitizeDomain).filter(Boolean);\n const baseUriDomains = (csp.baseUriDomains || []).map(sanitizeDomain).filter(Boolean);\n const scriptDirectives = (csp.scriptDirectives || []).filter(function(d) { return typeof d === \"string\" && d.length > 0; });\n\n const connectSrc = connectDomains.length > 0 ? connectDomains.join(\" \") : \"'none'\";\n const resourceSrc = resourceDomains.length > 0 ? [\"data:\", \"blob:\", ...resourceDomains].join(\" \") : \"data: blob:\";\n const frameSrc = frameDomains.length > 0 ? frameDomains.join(\" \") : \"'none'\";\n const baseUri = baseUriDomains.length > 0 ? baseUriDomains.join(\" \") : \"'none'\";\n const scriptSrcParts = [\"'unsafe-inline'\", resourceSrc];\n if (scriptDirectives.length > 0) scriptSrcParts.push(scriptDirectives.join(\" \"));\n\n return [\n \"default-src 'none'\",\n \"script-src \" + scriptSrcParts.join(\" \"),\n \"style-src 'unsafe-inline' \" + resourceSrc,\n \"img-src \" + resourceSrc,\n \"font-src \" + resourceSrc,\n \"media-src \" + resourceSrc,\n \"connect-src \" + connectSrc,\n \"frame-src \" + frameSrc,\n \"object-src 'none'\",\n \"base-uri \" + baseUri,\n ].join(\"; \");\n }\n\n function buildViolationListenerScript() {\n return `<script>\ndocument.addEventListener('securitypolicyviolation', function(e) {\n var violation = {\n type: 'mcp-apps:csp-violation',\n directive: e.violatedDirective,\n blockedUri: e.blockedURI,\n sourceFile: e.sourceFile || null,\n lineNumber: e.lineNumber || null,\n columnNumber: e.columnNumber || null,\n effectiveDirective: e.effectiveDirective,\n originalPolicy: e.originalPolicy,\n disposition: e.disposition,\n timestamp: Date.now()\n };\n console.warn('[MCP Apps CSP Violation]', violation.directive, ':', violation.blockedUri);\n window.parent.postMessage(violation, '*');\n});\n\nfunction serializeConsoleArgs(args) {\n try {\n return Array.from(args || []).map(function(arg) {\n if (arg instanceof Error) {\n return {\n type: 'Error',\n message: arg.message,\n stack: arg.stack,\n name: arg.name,\n };\n }\n if (typeof arg === 'object' && arg !== null) {\n try {\n return JSON.parse(JSON.stringify(arg));\n } catch (e) {\n return String(arg);\n }\n }\n return arg;\n });\n } catch (e) {\n return [String(args)];\n }\n}\n\nfunction sendConsoleToParent(level, args) {\n try {\n window.parent.postMessage({\n type: 'iframe-console-log',\n level: level,\n args: serializeConsoleArgs(args),\n timestamp: new Date().toISOString(),\n url: window.location.href,\n }, '*');\n } catch (e) {}\n}\n\nvar originalConsoleError = console.error.bind(console);\nconsole.error = function() {\n var args = Array.from(arguments);\n originalConsoleError.apply(console, args);\n sendConsoleToParent('error', args);\n};\n\nwindow.addEventListener('error', function(event) {\n sendConsoleToParent('error', [{\n message: event.message,\n filename: event.filename,\n lineno: event.lineno,\n colno: event.colno,\n error: event.error ? {\n message: event.error.message,\n stack: event.error.stack,\n name: event.error.name,\n } : null,\n }]);\n});\n\nwindow.addEventListener('unhandledrejection', function(event) {\n sendConsoleToParent('error', [{\n message: 'Unhandled Promise Rejection',\n reason: event.reason ? String(event.reason) : 'Unknown',\n error: event.reason instanceof Error ? {\n message: event.reason.message,\n stack: event.reason.stack,\n name: event.reason.name,\n } : null,\n }]);\n});\n</` + `script>`;\n }\n\n function injectCSP(html, cspValue) {\n const cspMeta = '<meta http-equiv=\"Content-Security-Policy\" content=\"' + cspValue + '\">';\n const violationListener = buildViolationListenerScript();\n const injection = cspMeta + violationListener;\n\n if (html.includes(\"<head>\")) {\n return html.replace(\"<head>\", \"<head>\" + injection);\n } else if (html.includes(\"<HEAD>\")) {\n return html.replace(\"<HEAD>\", \"<HEAD>\" + injection);\n } else if (html.includes(\"<html>\")) {\n return html.replace(\"<html>\", \"<html><head>\" + injection + \"</head>\");\n } else if (html.includes(\"<HTML>\")) {\n return html.replace(\"<HTML>\", \"<HTML><head>\" + injection + \"</head>\");\n } else if (html.includes(\"<!DOCTYPE\") || html.includes(\"<!doctype\")) {\n return html.replace(/(<!DOCTYPE[^>]*>|<!doctype[^>]*>)/i, \"$1<head>\" + injection + \"</head>\");\n } else {\n return injection + html;\n }\n }\n\n // Query params from host (csp_mode, permissions, widget_csp). AppFrame only\n // sends { html, csp } in sandbox-resource-ready; we carry the rest on the URL.\n // Blob URLs cannot reliably carry search params, so the CDN shell injects\n // window.__SANDBOX_SEARCH__ via buildSandboxProxyBlobHtml.\n const query = new URLSearchParams(\n typeof window.__SANDBOX_SEARCH__ === \"string\"\n ? window.__SANDBOX_SEARCH__\n : location.search\n );\n const queryCspMode = query.get(\"csp_mode\") || \"permissive\";\n let queryPermissions = null;\n let queryWidgetCsp = null;\n try {\n const rawPerm = query.get(\"permissions\");\n if (rawPerm) queryPermissions = JSON.parse(rawPerm);\n } catch (e) {}\n try {\n const rawCsp = query.get(\"widget_csp\");\n if (rawCsp) queryWidgetCsp = JSON.parse(rawCsp);\n } catch (e) {}\n\n const inner = document.createElement(\"iframe\");\n inner.style = \"width:100%; height:100%; border:none;\";\n inner.setAttribute(\"sandbox\", \"allow-scripts allow-same-origin allow-forms\");\n document.body.appendChild(inner);\n\n window.addEventListener(\"message\", async (event) => {\n if (event.source === window.parent) {\n if (event.data && event.data.method === \"ui/notifications/sandbox-resource-ready\") {\n const params = event.data.params || {};\n const html = params.html;\n const sandbox = params.sandbox;\n // Prefer message csp when present; fall back to URL widget_csp\n const csp = params.csp != null ? params.csp : queryWidgetCsp;\n const permissions = params.permissions != null ? params.permissions : queryPermissions;\n const permissive =\n typeof params.permissive === \"boolean\"\n ? params.permissive\n : queryCspMode === \"permissive\";\n if (typeof sandbox === \"string\") {\n inner.setAttribute(\"sandbox\", sandbox);\n }\n const allowAttribute = buildAllowAttribute(permissions);\n if (allowAttribute) {\n inner.setAttribute(\"allow\", allowAttribute);\n }\n if (typeof html === \"string\") {\n if (permissive) {\n const permissiveCsp = [\n \"default-src * 'unsafe-inline' 'unsafe-eval' data: blob: filesystem: about:\",\n \"script-src * 'unsafe-inline' 'unsafe-eval' data: blob:\",\n \"style-src * 'unsafe-inline' data: blob:\",\n \"img-src * data: blob: https: http:\",\n \"media-src * data: blob: https: http:\",\n \"font-src * data: blob: https: http:\",\n \"connect-src * data: blob: https: http: ws: wss: about:\",\n \"frame-src * data: blob: https: http: about:\",\n \"object-src * data: blob:\",\n \"base-uri *\",\n \"form-action *\",\n ].join(\"; \");\n const processedHtml = injectCSP(html, permissiveCsp);\n inner.srcdoc = processedHtml;\n } else {\n const cspValue = buildCSP(csp);\n const processedHtml = injectCSP(html, cspValue);\n inner.srcdoc = processedHtml;\n }\n }\n } else {\n if (inner && inner.contentWindow) {\n inner.contentWindow.postMessage(event.data, \"*\");\n }\n }\n } else if (event.source === inner.contentWindow) {\n window.parent.postMessage(event.data, \"*\");\n }\n });\n\n window.parent.postMessage({\n jsonrpc: \"2.0\",\n method: \"ui/notifications/sandbox-proxy-ready\",\n params: {},\n }, \"*\");\n <\/script>\n </body>\n</html>";
|
|
5023
|
-
function
|
|
5026
|
+
var Ha = "<!doctype html>\n<html>\n <head>\n <meta charset=\"utf-8\" />\n <meta\n http-equiv=\"Content-Security-Policy\"\n content=\"default-src 'self'; img-src * data: blob: 'unsafe-inline'; media-src * blob: data:; font-src * blob: data:; script-src * 'wasm-unsafe-eval' 'unsafe-inline' 'unsafe-eval' blob: data:; style-src * blob: data: 'unsafe-inline'; connect-src * data: blob: about:; frame-src * blob: data: http://localhost:* https://localhost:* http://127.0.0.1:* https://127.0.0.1:*;\"\n />\n <title>MCP Apps Sandbox Proxy</title>\n <style>\n html, body { margin: 0; padding: 0; height: 100%; width: 100%; overflow: hidden; }\n * { box-sizing: border-box; }\n iframe { display: block; background-color: transparent; border: 0px none transparent; padding: 0px; width: 100%; height: 100%; }\n </style>\n </head>\n <body>\n <script>\n function sanitizeDomain(domain) {\n if (typeof domain !== \"string\") return \"\";\n return domain.replace(/['\"<>;]/g, \"\").trim();\n }\n\n function buildAllowAttribute(permissions) {\n if (!permissions) return \"\";\n const allowList = [];\n if (permissions.camera) allowList.push(\"camera *\");\n if (permissions.microphone) allowList.push(\"microphone *\");\n if (permissions.geolocation) allowList.push(\"geolocation *\");\n if (permissions.clipboardWrite) allowList.push(\"clipboard-write *\");\n return allowList.join(\"; \");\n }\n\n function buildCSP(csp) {\n if (!csp) {\n return [\n \"default-src 'none'\",\n \"script-src 'unsafe-inline'\",\n \"style-src 'unsafe-inline'\",\n \"img-src data:\",\n \"font-src data:\",\n \"media-src data:\",\n \"connect-src 'none'\",\n \"frame-src 'none'\",\n \"object-src 'none'\",\n \"base-uri 'none'\",\n ].join(\"; \");\n }\n\n const connectDomains = (csp.connectDomains || []).map(sanitizeDomain).filter(Boolean);\n const resourceDomains = (csp.resourceDomains || []).map(sanitizeDomain).filter(Boolean);\n const frameDomains = (csp.frameDomains || []).map(sanitizeDomain).filter(Boolean);\n const baseUriDomains = (csp.baseUriDomains || []).map(sanitizeDomain).filter(Boolean);\n const scriptDirectives = (csp.scriptDirectives || []).filter(function(d) { return typeof d === \"string\" && d.length > 0; });\n\n const connectSrc = connectDomains.length > 0 ? connectDomains.join(\" \") : \"'none'\";\n const resourceSrc = resourceDomains.length > 0 ? [\"data:\", \"blob:\", ...resourceDomains].join(\" \") : \"data: blob:\";\n const frameSrc = frameDomains.length > 0 ? frameDomains.join(\" \") : \"'none'\";\n const baseUri = baseUriDomains.length > 0 ? baseUriDomains.join(\" \") : \"'none'\";\n const scriptSrcParts = [\"'unsafe-inline'\", resourceSrc];\n if (scriptDirectives.length > 0) scriptSrcParts.push(scriptDirectives.join(\" \"));\n\n return [\n \"default-src 'none'\",\n \"script-src \" + scriptSrcParts.join(\" \"),\n \"style-src 'unsafe-inline' \" + resourceSrc,\n \"img-src \" + resourceSrc,\n \"font-src \" + resourceSrc,\n \"media-src \" + resourceSrc,\n \"connect-src \" + connectSrc,\n \"frame-src \" + frameSrc,\n \"object-src 'none'\",\n \"base-uri \" + baseUri,\n ].join(\"; \");\n }\n\n function buildViolationListenerScript() {\n return `<script>\ndocument.addEventListener('securitypolicyviolation', function(e) {\n var violation = {\n type: 'mcp-apps:csp-violation',\n directive: e.violatedDirective,\n blockedUri: e.blockedURI,\n sourceFile: e.sourceFile || null,\n lineNumber: e.lineNumber || null,\n columnNumber: e.columnNumber || null,\n effectiveDirective: e.effectiveDirective,\n originalPolicy: e.originalPolicy,\n disposition: e.disposition,\n timestamp: Date.now()\n };\n console.warn('[MCP Apps CSP Violation]', violation.directive, ':', violation.blockedUri);\n window.parent.postMessage(violation, '*');\n});\n\nfunction serializeConsoleArgs(args) {\n try {\n return Array.from(args || []).map(function(arg) {\n if (arg instanceof Error) {\n return {\n type: 'Error',\n message: arg.message,\n stack: arg.stack,\n name: arg.name,\n };\n }\n if (typeof arg === 'object' && arg !== null) {\n try {\n return JSON.parse(JSON.stringify(arg));\n } catch (e) {\n return String(arg);\n }\n }\n return arg;\n });\n } catch (e) {\n return [String(args)];\n }\n}\n\nfunction sendConsoleToParent(level, args) {\n try {\n window.parent.postMessage({\n type: 'iframe-console-log',\n level: level,\n args: serializeConsoleArgs(args),\n timestamp: new Date().toISOString(),\n url: window.location.href,\n }, '*');\n } catch (e) {}\n}\n\nvar originalConsoleError = console.error.bind(console);\nconsole.error = function() {\n var args = Array.from(arguments);\n originalConsoleError.apply(console, args);\n sendConsoleToParent('error', args);\n};\n\nwindow.addEventListener('error', function(event) {\n sendConsoleToParent('error', [{\n message: event.message,\n filename: event.filename,\n lineno: event.lineno,\n colno: event.colno,\n error: event.error ? {\n message: event.error.message,\n stack: event.error.stack,\n name: event.error.name,\n } : null,\n }]);\n});\n\nwindow.addEventListener('unhandledrejection', function(event) {\n sendConsoleToParent('error', [{\n message: 'Unhandled Promise Rejection',\n reason: event.reason ? String(event.reason) : 'Unknown',\n error: event.reason instanceof Error ? {\n message: event.reason.message,\n stack: event.reason.stack,\n name: event.reason.name,\n } : null,\n }]);\n});\n</` + `script>`;\n }\n\n function injectCSP(html, cspValue) {\n const cspMeta = '<meta http-equiv=\"Content-Security-Policy\" content=\"' + cspValue + '\">';\n const violationListener = buildViolationListenerScript();\n const injection = cspMeta + violationListener;\n\n if (html.includes(\"<head>\")) {\n return html.replace(\"<head>\", \"<head>\" + injection);\n } else if (html.includes(\"<HEAD>\")) {\n return html.replace(\"<HEAD>\", \"<HEAD>\" + injection);\n } else if (html.includes(\"<html>\")) {\n return html.replace(\"<html>\", \"<html><head>\" + injection + \"</head>\");\n } else if (html.includes(\"<HTML>\")) {\n return html.replace(\"<HTML>\", \"<HTML><head>\" + injection + \"</head>\");\n } else if (html.includes(\"<!DOCTYPE\") || html.includes(\"<!doctype\")) {\n return html.replace(/(<!DOCTYPE[^>]*>|<!doctype[^>]*>)/i, \"$1<head>\" + injection + \"</head>\");\n } else {\n return injection + html;\n }\n }\n\n // Query params from host (csp_mode, permissions, widget_csp). AppFrame only\n // sends { html, csp } in sandbox-resource-ready; we carry the rest on the URL.\n // Blob URLs cannot reliably carry search params, so the CDN shell injects\n // window.__SANDBOX_SEARCH__ via buildSandboxProxyBlobHtml.\n const query = new URLSearchParams(\n typeof window.__SANDBOX_SEARCH__ === \"string\"\n ? window.__SANDBOX_SEARCH__\n : location.search\n );\n const queryCspMode = query.get(\"csp_mode\") || \"permissive\";\n let queryPermissions = null;\n let queryWidgetCsp = null;\n try {\n const rawPerm = query.get(\"permissions\");\n if (rawPerm) queryPermissions = JSON.parse(rawPerm);\n } catch (e) {}\n try {\n const rawCsp = query.get(\"widget_csp\");\n if (rawCsp) queryWidgetCsp = JSON.parse(rawCsp);\n } catch (e) {}\n\n const inner = document.createElement(\"iframe\");\n inner.style = \"width:100%; height:100%; border:none;\";\n inner.setAttribute(\"sandbox\", \"allow-scripts allow-same-origin allow-forms\");\n document.body.appendChild(inner);\n\n window.addEventListener(\"message\", async (event) => {\n if (event.source === window.parent) {\n if (event.data && event.data.method === \"ui/notifications/sandbox-resource-ready\") {\n const params = event.data.params || {};\n const html = params.html;\n const sandbox = params.sandbox;\n // Prefer message csp when present; fall back to URL widget_csp\n const csp = params.csp != null ? params.csp : queryWidgetCsp;\n const permissions = params.permissions != null ? params.permissions : queryPermissions;\n const permissive =\n typeof params.permissive === \"boolean\"\n ? params.permissive\n : queryCspMode === \"permissive\";\n if (typeof sandbox === \"string\") {\n inner.setAttribute(\"sandbox\", sandbox);\n }\n const allowAttribute = buildAllowAttribute(permissions);\n if (allowAttribute) {\n inner.setAttribute(\"allow\", allowAttribute);\n }\n if (typeof html === \"string\") {\n if (permissive) {\n const permissiveCsp = [\n \"default-src * 'unsafe-inline' 'unsafe-eval' data: blob: filesystem: about:\",\n \"script-src * 'unsafe-inline' 'unsafe-eval' data: blob:\",\n \"style-src * 'unsafe-inline' data: blob:\",\n \"img-src * data: blob: https: http:\",\n \"media-src * data: blob: https: http:\",\n \"font-src * data: blob: https: http:\",\n \"connect-src * data: blob: https: http: ws: wss: about:\",\n \"frame-src * data: blob: https: http: about:\",\n \"object-src * data: blob:\",\n \"base-uri *\",\n \"form-action *\",\n ].join(\"; \");\n const processedHtml = injectCSP(html, permissiveCsp);\n inner.srcdoc = processedHtml;\n } else {\n const cspValue = buildCSP(csp);\n const processedHtml = injectCSP(html, cspValue);\n inner.srcdoc = processedHtml;\n }\n }\n } else {\n if (inner && inner.contentWindow) {\n inner.contentWindow.postMessage(event.data, \"*\");\n }\n }\n } else if (event.source === inner.contentWindow) {\n window.parent.postMessage(event.data, \"*\");\n }\n });\n\n window.parent.postMessage({\n jsonrpc: \"2.0\",\n method: \"ui/notifications/sandbox-proxy-ready\",\n params: {},\n }, \"*\");\n <\/script>\n </body>\n</html>";
|
|
5027
|
+
function Ua(e) {
|
|
5024
5028
|
let t = "<script>window.__SANDBOX_SEARCH__ = " + JSON.stringify(e).replace(/</g, "\\u003c") + ";<\/script>";
|
|
5025
|
-
return
|
|
5029
|
+
return Ha.replace("<body>", "<body>" + t);
|
|
5026
5030
|
}
|
|
5027
|
-
var
|
|
5031
|
+
var Wa = "fixed inset-0 z-[100] w-full h-full min-h-0 bg-background flex flex-col [&:fullscreen]:h-full [&:fullscreen]:w-full [&:fullscreen]:bg-background", Ga = [
|
|
5028
5032
|
"fixed top-4 left-1/2 -translate-x-1/2 z-[100]",
|
|
5029
5033
|
"rounded-3xl w-full min-w-[300px] h-[400px]",
|
|
5030
5034
|
"shadow-2xl border overflow-hidden",
|
|
5031
5035
|
"bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",
|
|
5032
5036
|
"flex flex-col"
|
|
5033
|
-
].join(" "),
|
|
5034
|
-
function
|
|
5035
|
-
(0,
|
|
5037
|
+
].join(" "), Ka = "data-mcp-widget-fullscreen", qa = "data-mcp-widget-display-mode";
|
|
5038
|
+
function Ja(e) {
|
|
5039
|
+
(0, j.useEffect)(() => {
|
|
5036
5040
|
if (!(typeof document > "u")) {
|
|
5037
|
-
if (e === "pip" || e === "fullscreen") return document.documentElement.setAttribute(
|
|
5038
|
-
document.documentElement.removeAttribute(
|
|
5041
|
+
if (e === "pip" || e === "fullscreen") return document.documentElement.setAttribute(qa, e), e === "fullscreen" ? document.documentElement.setAttribute(Ka, "") : document.documentElement.removeAttribute(Ka), () => {
|
|
5042
|
+
document.documentElement.removeAttribute(qa), document.documentElement.removeAttribute(Ka);
|
|
5039
5043
|
};
|
|
5040
|
-
document.documentElement.removeAttribute(
|
|
5044
|
+
document.documentElement.removeAttribute(qa), document.documentElement.removeAttribute(Ka);
|
|
5041
5045
|
}
|
|
5042
5046
|
}, [e]);
|
|
5043
5047
|
}
|
|
5044
|
-
function
|
|
5048
|
+
function Ya({ displayMode: e, setDisplayMode: t }) {
|
|
5045
5049
|
let n = e === "fullscreen", r = e === "pip";
|
|
5046
|
-
return
|
|
5047
|
-
handleDisplayModeChange: (0,
|
|
5048
|
-
fullscreenShellClassName: n ?
|
|
5049
|
-
pipShellClassName: r ?
|
|
5050
|
+
return Ja(e), {
|
|
5051
|
+
handleDisplayModeChange: (0, j.useCallback)((e) => t(e), [t]),
|
|
5052
|
+
fullscreenShellClassName: n ? Wa : void 0,
|
|
5053
|
+
pipShellClassName: r ? Ga : void 0,
|
|
5050
5054
|
isFullscreen: n,
|
|
5051
5055
|
isPip: r
|
|
5052
5056
|
};
|
|
5053
5057
|
}
|
|
5054
|
-
var
|
|
5058
|
+
var Xa = {
|
|
5055
5059
|
PIP_MAX_WIDTH: 700,
|
|
5056
5060
|
DEFAULT_HEIGHT: 400
|
|
5057
5061
|
};
|
|
5058
|
-
function
|
|
5062
|
+
function Za(e) {
|
|
5059
5063
|
let t = e?.ui;
|
|
5060
5064
|
return t && typeof t == "object" && "resourceUri" in t && typeof t.resourceUri == "string" ? t.resourceUri : null;
|
|
5061
5065
|
}
|
|
5062
|
-
function
|
|
5063
|
-
return
|
|
5066
|
+
function Qa(e) {
|
|
5067
|
+
return Za(e) !== null;
|
|
5064
5068
|
}
|
|
5065
|
-
function
|
|
5069
|
+
function $a(e) {
|
|
5066
5070
|
return e === er;
|
|
5067
5071
|
}
|
|
5068
|
-
var
|
|
5072
|
+
var eo = {
|
|
5069
5073
|
name: "mcp-use-client",
|
|
5070
5074
|
version: "2.0.0"
|
|
5071
|
-
},
|
|
5075
|
+
}, to = 6e5, no = "ui/notifications/sandbox-proxy-ready", ro = {
|
|
5072
5076
|
openLinks: {},
|
|
5073
5077
|
serverTools: {},
|
|
5074
5078
|
serverResources: {},
|
|
5075
5079
|
logging: {},
|
|
5076
|
-
updateModelContext: { text: {} }
|
|
5080
|
+
updateModelContext: { text: {} },
|
|
5081
|
+
message: { text: {} }
|
|
5077
5082
|
};
|
|
5078
|
-
function
|
|
5083
|
+
function io(e) {
|
|
5079
5084
|
return new Promise((t) => {
|
|
5080
5085
|
let n = (r) => {
|
|
5081
|
-
r.source === e.contentWindow && r.data?.method ===
|
|
5086
|
+
r.source === e.contentWindow && r.data?.method === no && (window.removeEventListener("message", n), t());
|
|
5082
5087
|
};
|
|
5083
5088
|
window.addEventListener("message", n);
|
|
5084
5089
|
});
|
|
5085
5090
|
}
|
|
5086
|
-
function
|
|
5091
|
+
function ao(e) {
|
|
5087
5092
|
let t = e.oninitialized;
|
|
5088
5093
|
return new Promise((n) => {
|
|
5089
5094
|
e.oninitialized = (...r) => {
|
|
@@ -5091,67 +5096,69 @@ function ro(e) {
|
|
|
5091
5096
|
};
|
|
5092
5097
|
});
|
|
5093
5098
|
}
|
|
5094
|
-
function
|
|
5099
|
+
function oo(e, t) {
|
|
5095
5100
|
let n = Ia(t);
|
|
5096
5101
|
return Object.keys(n).length > 0 ? {
|
|
5097
5102
|
...typeof e == "object" && e ? e : {},
|
|
5098
5103
|
structuredContent: n
|
|
5099
5104
|
} : e ?? null;
|
|
5100
5105
|
}
|
|
5101
|
-
function
|
|
5102
|
-
let D = (0,
|
|
5106
|
+
function so({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInput: i, toolOutput: a, partialToolInput: o, customProps: s, cancelled: c, hostInfo: l = eo, hostContext: u, hostCapabilities: d, cspMode: f = "widget-declared", displayMode: p, onDisplayModeChange: m, inlineMaxWidth: h = 768, chromeless: g, onMessage: _, onModelContextUpdate: v, onLog: ee, onReady: te, onLifecycleChange: y, onError: b, onCspViolation: x, onResourceResolved: S, wrapTransport: C, toolCallTimeout: ne = to, mockOpenAiFileApis: w = !1, className: re, testId: T = "mcp-app-frame", invoking: E, invoked: ie }) {
|
|
5107
|
+
let D = (0, j.useRef)(null), O = (0, j.useRef)(null), k = (0, j.useRef)(null), ae = (0, j.useRef)(t.kind === "live" ? t.connection : null), [A, oe] = (0, j.useState)(null), [M, N] = (0, j.useState)(null), [P, se] = (0, j.useState)(null), [F, ce] = (0, j.useState)(0), [le, ue] = (0, j.useState)(!0), [I, de] = (0, j.useState)(Xa.DEFAULT_HEIGHT), [L, R] = (0, j.useState)("inline"), z = p ?? L, B = (0, j.useRef)(u);
|
|
5103
5108
|
B.current = u;
|
|
5104
|
-
let
|
|
5105
|
-
|
|
5106
|
-
let
|
|
5107
|
-
|
|
5108
|
-
let
|
|
5109
|
-
|
|
5110
|
-
let
|
|
5111
|
-
|
|
5112
|
-
let
|
|
5113
|
-
|
|
5114
|
-
let
|
|
5115
|
-
|
|
5116
|
-
let
|
|
5117
|
-
|
|
5118
|
-
let
|
|
5119
|
-
|
|
5120
|
-
let
|
|
5121
|
-
|
|
5122
|
-
let
|
|
5123
|
-
|
|
5124
|
-
let
|
|
5125
|
-
|
|
5126
|
-
let
|
|
5127
|
-
|
|
5128
|
-
let
|
|
5129
|
-
|
|
5130
|
-
let
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5109
|
+
let fe = (0, j.useRef)(_);
|
|
5110
|
+
fe.current = _;
|
|
5111
|
+
let pe = (0, j.useRef)(i);
|
|
5112
|
+
pe.current = i;
|
|
5113
|
+
let me = (0, j.useRef)(a);
|
|
5114
|
+
me.current = a;
|
|
5115
|
+
let he = (0, j.useRef)(s);
|
|
5116
|
+
he.current = s;
|
|
5117
|
+
let ge = (0, j.useRef)(S);
|
|
5118
|
+
ge.current = S;
|
|
5119
|
+
let _e = (0, j.useRef)(v);
|
|
5120
|
+
_e.current = v;
|
|
5121
|
+
let ve = (0, j.useRef)(ee);
|
|
5122
|
+
ve.current = ee;
|
|
5123
|
+
let ye = (0, j.useRef)(b);
|
|
5124
|
+
ye.current = b;
|
|
5125
|
+
let be = (0, j.useRef)(x);
|
|
5126
|
+
be.current = x;
|
|
5127
|
+
let xe = (0, j.useRef)(te);
|
|
5128
|
+
xe.current = te;
|
|
5129
|
+
let V = (0, j.useRef)(y);
|
|
5130
|
+
V.current = y;
|
|
5131
|
+
let Se = (0, j.useRef)(n);
|
|
5132
|
+
Se.current = n;
|
|
5133
|
+
let Ce = (0, j.useRef)(f);
|
|
5134
|
+
Ce.current = f;
|
|
5135
|
+
let we = (0, j.useRef)(w);
|
|
5136
|
+
we.current = w;
|
|
5137
|
+
let Te = (0, j.useCallback)((e) => {
|
|
5138
|
+
let t = Se.current;
|
|
5139
|
+
return t ? typeof t == "function" ? t(e) : t : Va({
|
|
5140
|
+
cspMode: Ce.current,
|
|
5134
5141
|
permissions: e.permissions,
|
|
5135
5142
|
widgetCsp: e.declaredCsp
|
|
5136
5143
|
});
|
|
5137
|
-
}, []), { handleDisplayModeChange:
|
|
5144
|
+
}, []), { handleDisplayModeChange: Ee, fullscreenShellClassName: De, pipShellClassName: Oe, isFullscreen: ke, isPip: Ae } = Ya({
|
|
5138
5145
|
containerRef: k,
|
|
5139
5146
|
displayMode: z,
|
|
5140
|
-
setDisplayMode: (0,
|
|
5147
|
+
setDisplayMode: (0, j.useCallback)((e) => {
|
|
5141
5148
|
m ? m(e) : R(e);
|
|
5142
5149
|
}, [m])
|
|
5143
|
-
}),
|
|
5144
|
-
|
|
5145
|
-
let
|
|
5146
|
-
|
|
5147
|
-
let
|
|
5148
|
-
t.kind === "live" && (
|
|
5150
|
+
}), je = (0, j.useRef)(Ee);
|
|
5151
|
+
je.current = Ee;
|
|
5152
|
+
let Me = (0, j.useRef)(z);
|
|
5153
|
+
Me.current = z;
|
|
5154
|
+
let Ne = t.kind === "live" ? t.resourceUri : void 0, Pe = t.kind === "preloaded" ? t.html : void 0;
|
|
5155
|
+
t.kind === "live" && (ae.current = t.connection), (0, j.useEffect)(() => {
|
|
5149
5156
|
let e = !1;
|
|
5150
|
-
|
|
5157
|
+
V.current?.({ status: "resolving" });
|
|
5151
5158
|
let n = (e) => {
|
|
5152
|
-
|
|
5153
|
-
let t =
|
|
5154
|
-
|
|
5159
|
+
oe(e), V.current?.({ status: "sandbox-loading" });
|
|
5160
|
+
let t = Te(e);
|
|
5161
|
+
N((e) => e?.href === t.href ? e : t), ge.current?.(e);
|
|
5155
5162
|
};
|
|
5156
5163
|
if (t.kind === "preloaded") {
|
|
5157
5164
|
n({
|
|
@@ -5167,11 +5174,11 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5167
5174
|
return;
|
|
5168
5175
|
}
|
|
5169
5176
|
let { connection: r, resourceUri: i } = t;
|
|
5170
|
-
return
|
|
5177
|
+
return ae.current = r, (async () => {
|
|
5171
5178
|
try {
|
|
5172
5179
|
let t = await r.readResource(i);
|
|
5173
5180
|
if (e) return;
|
|
5174
|
-
let a = r.resources?.find((e) => e.uri === i), o =
|
|
5181
|
+
let a = r.resources?.find((e) => e.uri === i), o = za({
|
|
5175
5182
|
resourceResult: t,
|
|
5176
5183
|
listingResource: a,
|
|
5177
5184
|
cspMode: f,
|
|
@@ -5179,7 +5186,7 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5179
5186
|
});
|
|
5180
5187
|
if (!o.mimeTypeValid) {
|
|
5181
5188
|
let e = o.mimeTypeWarning || "Invalid MIME type - SEP-1865 requires \"text/html;profile=mcp-app\"";
|
|
5182
|
-
|
|
5189
|
+
se(e), V.current?.({
|
|
5183
5190
|
status: "error",
|
|
5184
5191
|
error: e
|
|
5185
5192
|
});
|
|
@@ -5188,7 +5195,7 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5188
5195
|
n(o);
|
|
5189
5196
|
} catch (t) {
|
|
5190
5197
|
if (e) return;
|
|
5191
|
-
|
|
5198
|
+
se(t instanceof Error ? t.message : "Failed to prepare view"), V.current?.({
|
|
5192
5199
|
status: "error",
|
|
5193
5200
|
error: t instanceof Error ? t.message : "Failed to prepare view"
|
|
5194
5201
|
});
|
|
@@ -5198,30 +5205,30 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5198
5205
|
};
|
|
5199
5206
|
}, [
|
|
5200
5207
|
t.kind,
|
|
5201
|
-
|
|
5202
|
-
|
|
5208
|
+
Ne,
|
|
5209
|
+
Pe,
|
|
5203
5210
|
f,
|
|
5204
|
-
|
|
5205
|
-
]), (0,
|
|
5206
|
-
let e =
|
|
5211
|
+
Te
|
|
5212
|
+
]), (0, j.useEffect)(() => {
|
|
5213
|
+
let e = M;
|
|
5207
5214
|
return () => {
|
|
5208
5215
|
e?.protocol === "blob:" && URL.revokeObjectURL(e.href);
|
|
5209
5216
|
};
|
|
5210
|
-
}, [
|
|
5211
|
-
let
|
|
5217
|
+
}, [M]);
|
|
5218
|
+
let Fe = M?.protocol === "blob:", H = !M || Fe ? null : (() => {
|
|
5212
5219
|
try {
|
|
5213
|
-
return
|
|
5220
|
+
return M.origin;
|
|
5214
5221
|
} catch {
|
|
5215
5222
|
return null;
|
|
5216
5223
|
}
|
|
5217
5224
|
})();
|
|
5218
|
-
(0,
|
|
5219
|
-
if (!
|
|
5225
|
+
(0, j.useEffect)(() => {
|
|
5226
|
+
if (!H && !Fe) return;
|
|
5220
5227
|
let e = (e) => {
|
|
5221
5228
|
let t = D.current;
|
|
5222
|
-
if (t?.contentWindow && e.source === t.contentWindow && !(!
|
|
5229
|
+
if (t?.contentWindow && e.source === t.contentWindow && !(!Fe && e.origin !== H && H !== "*")) {
|
|
5223
5230
|
if (e.data?.type === "mcp-apps:csp-violation") {
|
|
5224
|
-
|
|
5231
|
+
be.current?.({
|
|
5225
5232
|
directive: e.data.directive,
|
|
5226
5233
|
effectiveDirective: e.data.effectiveDirective,
|
|
5227
5234
|
blockedUri: e.data.blockedUri,
|
|
@@ -5233,33 +5240,33 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5233
5240
|
});
|
|
5234
5241
|
return;
|
|
5235
5242
|
}
|
|
5236
|
-
e.data?.type === "iframe-console-log" &&
|
|
5243
|
+
e.data?.type === "iframe-console-log" && ve.current && ve.current({
|
|
5237
5244
|
level: e.data.level ?? "log",
|
|
5238
5245
|
data: e.data.args
|
|
5239
5246
|
});
|
|
5240
5247
|
}
|
|
5241
5248
|
};
|
|
5242
5249
|
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
5243
|
-
}, [
|
|
5244
|
-
if (!
|
|
5250
|
+
}, [H, Fe]), (0, j.useEffect)(() => {
|
|
5251
|
+
if (!A || !M) return;
|
|
5245
5252
|
let t = D.current;
|
|
5246
5253
|
if (!t) return;
|
|
5247
5254
|
let n = !1, r = null;
|
|
5248
5255
|
return (async () => {
|
|
5249
5256
|
try {
|
|
5250
|
-
|
|
5251
|
-
let i = tr(
|
|
5257
|
+
V.current?.({ status: "connecting" }), t.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms");
|
|
5258
|
+
let i = tr(A.permissions);
|
|
5252
5259
|
i && t.setAttribute("allow", i);
|
|
5253
|
-
let a =
|
|
5254
|
-
if (t.src =
|
|
5260
|
+
let a = io(t);
|
|
5261
|
+
if (t.src = M.href, await a, n) return;
|
|
5255
5262
|
r = new rr(null, l, {
|
|
5256
|
-
...d ??
|
|
5263
|
+
...d ?? ro,
|
|
5257
5264
|
sandbox: {
|
|
5258
|
-
csp: f === "permissive" ? void 0 :
|
|
5259
|
-
permissions:
|
|
5265
|
+
csp: f === "permissive" ? void 0 : A.csp,
|
|
5266
|
+
permissions: A.permissions
|
|
5260
5267
|
}
|
|
5261
|
-
}, { hostContext: B.current }), r.onmessage = async ({ content: e }) => (e.length > 0 &&
|
|
5262
|
-
let n =
|
|
5268
|
+
}, { hostContext: B.current }), r.onmessage = async ({ content: e }) => (e.length > 0 && fe.current && fe.current(e), {}), r.onopenlink = async ({ url: e }) => (e && window.open(e, "_blank", "noopener,noreferrer"), {}), r.oncalltool = (async ({ name: e, arguments: t }) => {
|
|
5269
|
+
let n = ae.current;
|
|
5263
5270
|
if (!n) throw Error("Server connection not available");
|
|
5264
5271
|
try {
|
|
5265
5272
|
return await n.callTool(e, t || {}, {
|
|
@@ -5270,11 +5277,11 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5270
5277
|
throw r?.sendToolCancelled({ reason: e instanceof Error ? e.message : String(e) }), e;
|
|
5271
5278
|
}
|
|
5272
5279
|
}), r.onreadresource = (async ({ uri: e }) => {
|
|
5273
|
-
let t =
|
|
5280
|
+
let t = ae.current;
|
|
5274
5281
|
if (!t) throw Error("Server connection not available");
|
|
5275
5282
|
return await t.readResource(e);
|
|
5276
5283
|
}), r.onlistresources = (async () => {
|
|
5277
|
-
let e =
|
|
5284
|
+
let e = ae.current;
|
|
5278
5285
|
if (!e) throw Error("Server connection not available");
|
|
5279
5286
|
return { resources: [...e.resources ?? []] };
|
|
5280
5287
|
}), r.onrequestdisplaymode = async ({ mode: e }) => {
|
|
@@ -5282,35 +5289,35 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5282
5289
|
"inline",
|
|
5283
5290
|
"pip",
|
|
5284
5291
|
"fullscreen"
|
|
5285
|
-
]).includes(t) ? t :
|
|
5286
|
-
return await
|
|
5287
|
-
}, r.onupdatemodelcontext = async ({ content: e, structuredContent: t }) => (
|
|
5292
|
+
]).includes(t) ? t : Me.current;
|
|
5293
|
+
return await je.current(n), { mode: n };
|
|
5294
|
+
}, r.onupdatemodelcontext = async ({ content: e, structuredContent: t }) => (_e.current?.({
|
|
5288
5295
|
content: e,
|
|
5289
5296
|
structuredContent: t
|
|
5290
|
-
}), {}), r.onloggingmessage = async ({ level: e, data: t }) => (
|
|
5297
|
+
}), {}), r.onloggingmessage = async ({ level: e, data: t }) => (ve.current?.({
|
|
5291
5298
|
level: e,
|
|
5292
5299
|
data: t
|
|
5293
5300
|
}), {}), r.onsizechange = async ({ height: e }) => {
|
|
5294
|
-
|
|
5301
|
+
Me.current === "inline" && e !== void 0 && de(e);
|
|
5295
5302
|
};
|
|
5296
|
-
let o =
|
|
5303
|
+
let o = ao(r), s = new $n(t.contentWindow, t.contentWindow);
|
|
5297
5304
|
if (C && (s = C(s, e)), await r.connect(s), n || (await r.sendSandboxResourceReady({
|
|
5298
|
-
html:
|
|
5299
|
-
csp:
|
|
5300
|
-
permissions:
|
|
5305
|
+
html: we.current ? Ra(A.html) : A.html,
|
|
5306
|
+
csp: A.csp,
|
|
5307
|
+
permissions: A.permissions
|
|
5301
5308
|
}), await o, n)) return;
|
|
5302
|
-
O.current = r,
|
|
5309
|
+
O.current = r, ce((e) => e + 1), V.current?.({ status: "initialized" });
|
|
5303
5310
|
let c = {
|
|
5304
|
-
...
|
|
5305
|
-
...Ia(
|
|
5311
|
+
...pe.current,
|
|
5312
|
+
...Ia(he.current)
|
|
5306
5313
|
};
|
|
5307
5314
|
r.sendToolInput({ arguments: c });
|
|
5308
|
-
let u =
|
|
5309
|
-
u && r.sendToolResult(u),
|
|
5315
|
+
let u = oo(me.current, he.current);
|
|
5316
|
+
u && r.sendToolResult(u), V.current?.({ status: "ready" });
|
|
5310
5317
|
} catch (e) {
|
|
5311
5318
|
if (!n) {
|
|
5312
5319
|
let t = e instanceof Error ? e.message : "Failed to connect view";
|
|
5313
|
-
|
|
5320
|
+
se(t), ye.current?.(t), V.current?.({
|
|
5314
5321
|
status: "error",
|
|
5315
5322
|
error: t
|
|
5316
5323
|
});
|
|
@@ -5319,99 +5326,100 @@ function ao({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5319
5326
|
})(), () => {
|
|
5320
5327
|
n = !0;
|
|
5321
5328
|
let e = r;
|
|
5322
|
-
O.current = null, e && (
|
|
5329
|
+
O.current = null, e && (V.current?.({ status: "tearing-down" }), (async () => {
|
|
5323
5330
|
try {
|
|
5324
5331
|
await Promise.race([e.teardownResource({}), new Promise((e, t) => setTimeout(() => t(/* @__PURE__ */ Error("teardown timeout")), 2e3))]);
|
|
5325
5332
|
} catch {} finally {
|
|
5326
|
-
e.close().catch(() => {}),
|
|
5333
|
+
e.close().catch(() => {}), V.current?.({ status: "closed" });
|
|
5327
5334
|
}
|
|
5328
5335
|
})());
|
|
5329
5336
|
};
|
|
5330
5337
|
}, [
|
|
5331
|
-
|
|
5332
|
-
|
|
5338
|
+
A,
|
|
5339
|
+
M,
|
|
5333
5340
|
l,
|
|
5334
5341
|
d,
|
|
5335
5342
|
f,
|
|
5336
5343
|
e,
|
|
5337
5344
|
C,
|
|
5338
|
-
ne
|
|
5339
|
-
|
|
5345
|
+
ne,
|
|
5346
|
+
w
|
|
5347
|
+
]), (0, j.useEffect)(() => {
|
|
5340
5348
|
let e = O.current;
|
|
5341
|
-
!e ||
|
|
5342
|
-
}, [u,
|
|
5349
|
+
!e || F === 0 || !u || e.setHostContext(u);
|
|
5350
|
+
}, [u, F]), (0, j.useEffect)(() => {
|
|
5343
5351
|
let e = O.current;
|
|
5344
|
-
!e ||
|
|
5345
|
-
}, [
|
|
5352
|
+
!e || F === 0 || !o || e.sendToolInputPartial({ arguments: o });
|
|
5353
|
+
}, [F, o]), (0, j.useEffect)(() => {
|
|
5346
5354
|
let e = O.current;
|
|
5347
|
-
if (!e ||
|
|
5355
|
+
if (!e || F === 0) return;
|
|
5348
5356
|
let t = {
|
|
5349
5357
|
...i,
|
|
5350
5358
|
...Ia(s)
|
|
5351
5359
|
};
|
|
5352
5360
|
e.sendToolInput({ arguments: t });
|
|
5353
5361
|
}, [
|
|
5354
|
-
|
|
5362
|
+
F,
|
|
5355
5363
|
i,
|
|
5356
5364
|
s
|
|
5357
|
-
]), (0,
|
|
5365
|
+
]), (0, j.useEffect)(() => {
|
|
5358
5366
|
let e = O.current;
|
|
5359
|
-
if (!e ||
|
|
5360
|
-
let t =
|
|
5367
|
+
if (!e || F === 0) return;
|
|
5368
|
+
let t = oo(a, s);
|
|
5361
5369
|
t && e.sendToolResult(t);
|
|
5362
5370
|
}, [
|
|
5363
|
-
|
|
5371
|
+
F,
|
|
5364
5372
|
a,
|
|
5365
5373
|
s
|
|
5366
|
-
]), (0,
|
|
5374
|
+
]), (0, j.useEffect)(() => {
|
|
5367
5375
|
let e = O.current;
|
|
5368
|
-
!e ||
|
|
5369
|
-
}, [c,
|
|
5370
|
-
let
|
|
5371
|
-
if ((0,
|
|
5372
|
-
|
|
5373
|
-
}, [
|
|
5374
|
-
if (
|
|
5375
|
-
let e = setTimeout(() =>
|
|
5376
|
+
!e || F === 0 || !c || e.sendToolCancelled({ reason: "Cancelled by user" });
|
|
5377
|
+
}, [c, F]);
|
|
5378
|
+
let Ie = (0, j.useRef)(!1);
|
|
5379
|
+
if ((0, j.useEffect)(() => {
|
|
5380
|
+
Ie.current || F === 0 || (Ie.current = !0, xe.current?.());
|
|
5381
|
+
}, [F]), (0, j.useEffect)(() => {
|
|
5382
|
+
if (F === 0 || !le) return;
|
|
5383
|
+
let e = setTimeout(() => ue(!1), 300);
|
|
5376
5384
|
return () => clearTimeout(e);
|
|
5377
|
-
}, [
|
|
5378
|
-
if (!
|
|
5379
|
-
let
|
|
5380
|
-
height:
|
|
5385
|
+
}, [F, le]), P) return /* @__PURE__ */ j.createElement("div", { className: re }, /* @__PURE__ */ j.createElement("div", { className: "border border-red-200/50 dark:border-red-800/50 bg-red-50/30 dark:bg-red-950/20 rounded-lg p-4" }, /* @__PURE__ */ j.createElement("p", { className: "text-sm text-red-600 dark:text-red-400" }, "Failed to load view: ", P)));
|
|
5386
|
+
if (!A) return /* @__PURE__ */ j.createElement("div", { className: re }, /* @__PURE__ */ j.createElement("div", { className: "flex items-center justify-center w-full h-[200px]" }, /* @__PURE__ */ j.createElement("span", { className: "text-sm text-muted-foreground" }, "Loading view…")));
|
|
5387
|
+
let Le = De ?? Oe ?? "flex group flex-1 items-center justify-center", U = {
|
|
5388
|
+
height: ke || Ae ? "100%" : `${I}px`,
|
|
5381
5389
|
width: "100%",
|
|
5382
5390
|
maxWidth: z === "inline" ? `${h}px` : "100%",
|
|
5383
|
-
transition:
|
|
5384
|
-
},
|
|
5391
|
+
transition: ke || Ae ? void 0 : "height 300ms ease-out"
|
|
5392
|
+
}, Re = /* @__PURE__ */ j.createElement("div", {
|
|
5385
5393
|
ref: k,
|
|
5386
|
-
className:
|
|
5387
|
-
style:
|
|
5388
|
-
height:
|
|
5389
|
-
maxWidth:
|
|
5394
|
+
className: Le,
|
|
5395
|
+
style: Ae ? {
|
|
5396
|
+
height: Xa.DEFAULT_HEIGHT,
|
|
5397
|
+
maxWidth: Xa.PIP_MAX_WIDTH,
|
|
5390
5398
|
zIndex: 100
|
|
5391
|
-
} :
|
|
5392
|
-
}, (
|
|
5399
|
+
} : ke ? { zIndex: 100 } : void 0
|
|
5400
|
+
}, (ke || Ae) && /* @__PURE__ */ j.createElement("button", {
|
|
5393
5401
|
type: "button",
|
|
5394
|
-
"data-testid":
|
|
5395
|
-
"aria-label":
|
|
5402
|
+
"data-testid": ke ? "debugger-exit-fullscreen-button" : "debugger-exit-pip-button",
|
|
5403
|
+
"aria-label": ke ? "Exit fullscreen" : "Exit picture-in-picture",
|
|
5396
5404
|
className: "absolute right-3 top-3 z-[110] flex size-8 items-center justify-center rounded-full border border-border bg-background/90 text-lg leading-none text-foreground shadow-sm backdrop-blur-sm hover:bg-background",
|
|
5397
5405
|
style: { zIndex: 110 },
|
|
5398
|
-
onClick: () => void
|
|
5399
|
-
}, "×"), /* @__PURE__ */
|
|
5400
|
-
"data-testid":
|
|
5406
|
+
onClick: () => void Ee("inline")
|
|
5407
|
+
}, "×"), /* @__PURE__ */ j.createElement("div", { className: ke || Ae ? "relative w-full h-full min-h-0 flex flex-1 flex-col" : "relative w-full flex flex-1 justify-center items-center" }, le && /* @__PURE__ */ j.createElement("div", { className: "flex absolute inset-0 items-center justify-center z-10" }, /* @__PURE__ */ j.createElement("span", { className: "text-sm text-muted-foreground" }, "Loading…")), !Ae && !ke && (E || ie) && /* @__PURE__ */ j.createElement("div", { className: "absolute -top-8 left-2 z-10 whitespace-nowrap pointer-events-none text-xs text-muted-foreground" }, E && !a ? E : ie), /* @__PURE__ */ j.createElement("div", {
|
|
5408
|
+
"data-testid": T,
|
|
5401
5409
|
"data-mcp-app-tool": r,
|
|
5402
5410
|
className: z === "fullscreen" ? "w-full h-full overflow-hidden" : "w-full overflow-hidden",
|
|
5403
|
-
style:
|
|
5404
|
-
}, /* @__PURE__ */
|
|
5411
|
+
style: U
|
|
5412
|
+
}, /* @__PURE__ */ j.createElement("iframe", {
|
|
5405
5413
|
ref: D,
|
|
5406
5414
|
title: `MCP App: ${r}`,
|
|
5407
5415
|
className: "w-full h-full border-0 bg-transparent",
|
|
5408
|
-
style: { border:
|
|
5416
|
+
style: { border: A.prefersBorder && z !== "fullscreen" ? void 0 : "none" }
|
|
5409
5417
|
}))));
|
|
5410
|
-
return /* @__PURE__ */
|
|
5418
|
+
return /* @__PURE__ */ j.createElement("div", { className: re }, Re);
|
|
5411
5419
|
}
|
|
5412
|
-
function
|
|
5413
|
-
return !(e.viewId !== t.viewId || e.source !== t.source || e.sandboxUrl !== t.sandboxUrl || e.displayMode !== t.displayMode || e.cancelled !== t.cancelled || e.toolInput !== t.toolInput || e.toolOutput !== t.toolOutput || e.partialToolInput !== t.partialToolInput || e.customProps !== t.customProps || e.hostContext !== t.hostContext || e.hostCapabilities !== t.hostCapabilities || e.cspMode !== t.cspMode || e.className !== t.className || e.onReady !== t.onReady || e.onLifecycleChange !== t.onLifecycleChange);
|
|
5420
|
+
function co(e, t) {
|
|
5421
|
+
return !(e.viewId !== t.viewId || e.source !== t.source || e.sandboxUrl !== t.sandboxUrl || e.displayMode !== t.displayMode || e.cancelled !== t.cancelled || e.toolInput !== t.toolInput || e.toolOutput !== t.toolOutput || e.partialToolInput !== t.partialToolInput || e.customProps !== t.customProps || e.hostContext !== t.hostContext || e.hostCapabilities !== t.hostCapabilities || e.cspMode !== t.cspMode || e.mockOpenAiFileApis !== t.mockOpenAiFileApis || e.className !== t.className || e.onReady !== t.onReady || e.onLifecycleChange !== t.onLifecycleChange);
|
|
5414
5422
|
}
|
|
5415
|
-
var
|
|
5423
|
+
var lo = (0, j.memo)(so, co);
|
|
5416
5424
|
//#endregion
|
|
5417
|
-
export { _r as a,
|
|
5425
|
+
export { _r as a, Qa as c, Pa as d, yr as i, Sa as l, Na as n, Za as o, lo as r, $a as s, Fa as t, vr as u };
|