@opentiny/next-sdk 0.1.14 → 0.1.15-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/agent/AgentModelProvider.ts +546 -22
  2. package/agent/type.ts +12 -6
  3. package/agent/utils/generateReActPrompt.ts +55 -0
  4. package/agent/utils/parseReActAction.ts +34 -0
  5. package/dist/McpSdk.d.ts +14 -0
  6. package/dist/WebAgent.d.ts +5 -0
  7. package/dist/WebMcp.d.ts +20 -0
  8. package/dist/WebMcpClient.d.ts +389 -1152
  9. package/dist/WebMcpServer.d.ts +79 -78
  10. package/dist/Zod.d.ts +1 -0
  11. package/dist/agent/AgentModelProvider.d.ts +40 -4
  12. package/dist/agent/type.d.ts +13 -3
  13. package/dist/agent/utils/generateReActPrompt.d.ts +9 -0
  14. package/dist/agent/utils/getAISDKTools.d.ts +1 -0
  15. package/dist/agent/utils/parseReActAction.d.ts +14 -0
  16. package/dist/index.d.ts +2 -1
  17. package/dist/index.es.dev.js +36353 -34348
  18. package/dist/index.es.js +28821 -25466
  19. package/dist/index.js +3880 -25
  20. package/dist/index.umd.dev.js +34230 -32225
  21. package/dist/index.umd.js +220 -128
  22. package/dist/mcpsdk@1.24.3.dev.js +22539 -0
  23. package/dist/mcpsdk@1.24.3.es.dev.js +22537 -0
  24. package/dist/mcpsdk@1.24.3.es.js +16781 -0
  25. package/dist/mcpsdk@1.24.3.js +43 -0
  26. package/dist/remoter/createRemoter.d.ts +9 -0
  27. package/dist/remoter/tooltips.d.ts +36 -0
  28. package/dist/script/utils.d.ts +1 -0
  29. package/dist/transport/ExtensionClientTransport.d.ts +3 -2
  30. package/dist/transport/ExtensionContentServerTransport.d.ts +3 -2
  31. package/dist/transport/ExtensionPageServerTransport.d.ts +4 -4
  32. package/dist/vite-build-tsc.d.ts +2 -0
  33. package/dist/vite.config.d.ts +2 -0
  34. package/dist/vite.config.mcpSdk.d.ts +2 -0
  35. package/dist/vite.config.webAgent.d.ts +2 -0
  36. package/dist/vite.config.webMcp.d.ts +2 -0
  37. package/dist/vite.config.webMcpFull.d.ts +2 -0
  38. package/dist/vite.config.zod.d.ts +2 -0
  39. package/dist/webagent.dev.js +24569 -20836
  40. package/dist/webagent.es.dev.js +23907 -20174
  41. package/dist/webagent.es.js +25326 -20723
  42. package/dist/webagent.js +209 -110
  43. package/dist/webmcp-full.dev.js +21225 -20021
  44. package/dist/webmcp-full.es.dev.js +21223 -20019
  45. package/dist/webmcp-full.es.js +16710 -14437
  46. package/dist/webmcp-full.js +42 -15
  47. package/dist/webmcp.dev.js +14 -22
  48. package/dist/webmcp.es.dev.js +12 -20
  49. package/dist/webmcp.es.js +172 -179
  50. package/dist/webmcp.js +1 -1
  51. package/dist/zod@3.25.76.dev.js +30 -32
  52. package/dist/zod@3.25.76.es.dev.js +28 -30
  53. package/dist/zod@3.25.76.es.js +143 -145
  54. package/dist/zod@3.25.76.js +1 -1
  55. package/package.json +11 -9
  56. package/remoter/createRemoter.ts +126 -71
  57. package/remoter/tooltips.ts +260 -0
  58. package/transport/ExtensionPageServerTransport.ts +2 -4
  59. package/tsconfig.json +5 -3
  60. package/vite-build-tsc.ts +60 -0
  61. package/vite-env.d.ts +5 -0
  62. package/dist/WebMcpClient.js +0 -363
  63. package/dist/WebMcpServer.js +0 -283
  64. package/dist/agent/AgentModelProvider.js +0 -293
  65. package/dist/agent/type.js +0 -1
  66. package/dist/agent/utils/getAISDKTools.js +0 -36
  67. package/dist/mcpsdk@1.17.0.dev.js +0 -21391
  68. package/dist/mcpsdk@1.17.0.es.dev.js +0 -21389
  69. package/dist/mcpsdk@1.17.0.es.js +0 -14505
  70. package/dist/mcpsdk@1.17.0.js +0 -16
  71. package/dist/remoter/QrCode.js +0 -55
  72. package/dist/remoter/createRemoter.js +0 -743
  73. package/dist/transport/ExtensionClientTransport.js +0 -81
  74. package/dist/transport/ExtensionContentServerTransport.js +0 -128
  75. package/dist/transport/ExtensionPageServerTransport.js +0 -118
  76. package/dist/transport/messages.js +0 -51
  77. package/dist/utils/uuid.js +0 -10
package/dist/index.js CHANGED
@@ -1,25 +1,3880 @@
1
- // 从相关包中,导出一些常用变量,方便用户导入
2
- import Ajv from 'ajv';
3
- export { Ajv };
4
- export { z } from 'zod';
5
- export { AuthClientProvider } from '@opentiny/next';
6
- export { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
7
- export { UriTemplate } from '@modelcontextprotocol/sdk/shared/uriTemplate.js';
8
- export { completable } from '@modelcontextprotocol/sdk/server/completable.js';
9
- export { getDisplayName } from '@modelcontextprotocol/sdk/shared/metadataUtils.js';
10
- export { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js';
11
- // 2大核心模块
12
- export * from './WebMcpServer';
13
- export * from './WebMcpClient';
14
- // 浏览器扩展自定义传输层
15
- export * from './transport/ExtensionClientTransport';
16
- export * from './transport/ExtensionPageServerTransport';
17
- export * from './transport/ExtensionContentServerTransport';
18
- // 快速创建一个悬浮图标和菜单,是扫码和聊天框的入口
19
- export * from './remoter/createRemoter';
20
- // 一个通用的ai-sdk的agent封装
21
- export { AgentModelProvider } from './agent/AgentModelProvider';
22
- // 快速 从官方 mcp WebMcpClient 这2种client中, 抽取成 ai-sdk 所需要的 tool的对象
23
- export { getAISDKTools } from './agent/utils/getAISDKTools';
24
- // 方便的二维码类
25
- export { QrCode } from './remoter/QrCode';
1
+ import { default as O0 } from "ajv";
2
+ import { z as q0 } from "zod";
3
+ import { MessageChannelServerTransport as i2, createTransportPair as K2, MessageChannelClientTransport as n2, sseOptions as Q2, streamOptions as X2, createSseProxy as ee, createSocketProxy as te, createStreamProxy as re, MessageChannelTransport as se } from "@opentiny/next";
4
+ import { AuthClientProvider as H0 } from "@opentiny/next";
5
+ import { McpServer as P2 } from "@modelcontextprotocol/sdk/server/mcp.js";
6
+ import { ResourceTemplate as z0 } from "@modelcontextprotocol/sdk/server/mcp.js";
7
+ import { UriTemplate as D0 } from "@modelcontextprotocol/sdk/shared/uriTemplate.js";
8
+ import { completable as B0 } from "@modelcontextprotocol/sdk/server/completable.js";
9
+ import { getDisplayName as J0 } from "@modelcontextprotocol/sdk/shared/metadataUtils.js";
10
+ import { InMemoryTransport as oe } from "@modelcontextprotocol/sdk/inMemory.js";
11
+ import { InMemoryTransport as G0 } from "@modelcontextprotocol/sdk/inMemory.js";
12
+ import { SetLevelRequestSchema as m2, SubscribeRequestSchema as ie, UnsubscribeRequestSchema as ne, ListResourcesRequestSchema as ae, RootsListChangedNotificationSchema as ce, CallToolResultSchema as le, ElicitRequestSchema as he, CreateMessageRequestSchema as de, ListRootsRequestSchema as pe, ToolListChangedNotificationSchema as ue, PromptListChangedNotificationSchema as me, ResourceListChangedNotificationSchema as ge, ResourceUpdatedNotificationSchema as fe, LoggingMessageNotificationSchema as Ce, JSONRPCMessageSchema as a2 } from "@modelcontextprotocol/sdk/types.js";
13
+ import { Client as k2 } from "@modelcontextprotocol/sdk/client/index.js";
14
+ import { SSEClientTransport as c2 } from "@modelcontextprotocol/sdk/client/sse.js";
15
+ import { StreamableHTTPClientTransport as G } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
16
+ import { WebSocketClientTransport as we } from "@modelcontextprotocol/sdk/client/websocket.js";
17
+ import g2 from "qrcode";
18
+ import { dynamicTool as ye, jsonSchema as ve, generateText as f2, streamText as X, stepCountIs as _e } from "ai";
19
+ import { InvalidArgumentError as be, AISDKError as Z } from "@ai-sdk/provider";
20
+ import { z as o } from "zod/v4";
21
+ import "zod/v3";
22
+ import { createOpenAI as xe } from "@ai-sdk/openai";
23
+ import { createDeepSeek as Le } from "@ai-sdk/deepseek";
24
+ class w0 {
25
+ constructor(e, t) {
26
+ const s = {
27
+ name: "web-mcp-server",
28
+ version: "1.0.0"
29
+ }, i = {
30
+ prompts: { listChanged: !0 },
31
+ resources: { subscribe: !0, listChanged: !0 },
32
+ tools: { listChanged: !0 },
33
+ completions: {},
34
+ logging: {}
35
+ };
36
+ this.server = new P2(e || s, t || { capabilities: i }), this.server.server.oninitialized = () => {
37
+ this.oninitialized?.();
38
+ }, this.server.server.onclose = () => {
39
+ this.onclose?.();
40
+ }, this.server.server.onerror = (n) => {
41
+ this.onerror?.(n);
42
+ }, this.server.server.setRequestHandler(m2, async () => ({}));
43
+ }
44
+ /**
45
+ * Connects the server to a transport via the specified option.
46
+ */
47
+ async connect(e) {
48
+ return typeof e.start == "function" ? (this.transport = e, this.transport.onclose = void 0, this.transport.onerror = void 0, this.transport.onmessage = void 0) : (this.transport = new i2(e), await this.transport.listen()), await this.server.connect(this.transport), this.transport;
49
+ }
50
+ /**
51
+ * Closes the connection.
52
+ */
53
+ async close() {
54
+ await this.server.close();
55
+ }
56
+ /**
57
+ * Registers a tool with a config object and callback.
58
+ */
59
+ registerTool(e, t, s) {
60
+ return this.server.registerTool(e, t, s);
61
+ }
62
+ /**
63
+ * Registers a prompt with a config object and callback.
64
+ */
65
+ registerPrompt(e, t, s) {
66
+ return this.server.registerPrompt(e, t, s);
67
+ }
68
+ registerResource(e, t, s, i) {
69
+ return typeof t == "string" ? this.server.registerResource(e, t, s, i) : this.server.registerResource(e, t, s, i);
70
+ }
71
+ /**
72
+ * Checks if the server is connected to a transport.
73
+ * @returns True if the server is connected
74
+ */
75
+ isConnected() {
76
+ return this.server.isConnected();
77
+ }
78
+ /**
79
+ * Sends a resource list changed event to the client, if connected.
80
+ */
81
+ sendResourceListChanged() {
82
+ this.server.sendResourceListChanged();
83
+ }
84
+ /**
85
+ * Sends a tool list changed event to the client, if connected.
86
+ */
87
+ sendToolListChanged() {
88
+ this.server.sendToolListChanged();
89
+ }
90
+ /**
91
+ * Sends a prompt list changed event to the client, if connected.
92
+ */
93
+ sendPromptListChanged() {
94
+ this.server.sendPromptListChanged();
95
+ }
96
+ /**
97
+ * After initialization has completed, this will be populated with the client's reported capabilities.
98
+ */
99
+ getClientCapabilities() {
100
+ return this.server.server.getClientCapabilities();
101
+ }
102
+ /**
103
+ * After initialization has completed, this will be populated with information about the client's name and version.
104
+ */
105
+ getClientVersion() {
106
+ return this.server.server.getClientVersion();
107
+ }
108
+ /**
109
+ * Sends a ping to the client to check if it is still connected.
110
+ */
111
+ async ping() {
112
+ return await this.server.server.ping();
113
+ }
114
+ /**
115
+ * Creates a LLM message to be sent to the client.
116
+ */
117
+ async createMessage(e, t) {
118
+ return await this.server.server.createMessage(e, t);
119
+ }
120
+ /**
121
+ * Elicits input from the client, such as a prompt or resource.
122
+ */
123
+ async elicitInput(e, t) {
124
+ return await this.server.server.elicitInput(e, t);
125
+ }
126
+ /**
127
+ * Lists the root resources available to the client.
128
+ */
129
+ async listRoots(e, t) {
130
+ return await this.server.server.listRoots(e, t);
131
+ }
132
+ /**
133
+ * Sends a logging message to the client.
134
+ */
135
+ async sendLoggingMessage(e) {
136
+ return await this.server.server.sendLoggingMessage(e);
137
+ }
138
+ /**
139
+ * Sends a resource updated notification to the client.
140
+ */
141
+ async sendResourceUpdated(e) {
142
+ return await this.server.server.sendResourceUpdated(e);
143
+ }
144
+ /**
145
+ * Sends a request and wait for a response.
146
+ *
147
+ * Do not use this method to emit notifications! Use notification() instead.
148
+ */
149
+ request(e, t, s) {
150
+ return this.server.server.request(e, t, s);
151
+ }
152
+ /**
153
+ * Emits a notification, which is a one-way message that does not expect a response.
154
+ */
155
+ async notification(e, t) {
156
+ return await this.server.server.notification(e, t);
157
+ }
158
+ /**
159
+ * Registers a handler to invoke when this protocol object receives a request with the given method.
160
+ *
161
+ * Note that this will replace any previous request handler for the same method.
162
+ */
163
+ setRequestHandler(e, t) {
164
+ this.server.server.setRequestHandler(e, t);
165
+ }
166
+ /**
167
+ * Removes the request handler for the given method.
168
+ */
169
+ removeRequestHandler(e) {
170
+ this.server.server.removeRequestHandler(e);
171
+ }
172
+ /**
173
+ * Registers a handler to invoke when this protocol object receives a notification with the given method.
174
+ *
175
+ * Note that this will replace any previous notification handler for the same method.
176
+ */
177
+ setNotificationHandler(e, t) {
178
+ this.server.server.setNotificationHandler(e, t);
179
+ }
180
+ /**
181
+ * Removes the notification handler for the given method.
182
+ */
183
+ removeNotificationHandler(e) {
184
+ this.server.server.removeNotificationHandler(e);
185
+ }
186
+ /**
187
+ * Registers a handler for the subscribe request.
188
+ */
189
+ onSubscribe(e) {
190
+ this.server.server.setRequestHandler(ie, e);
191
+ }
192
+ /**
193
+ * Registers a handler for the unsubscribe request.
194
+ */
195
+ onUnsubscribe(e) {
196
+ this.server.server.setRequestHandler(ne, e);
197
+ }
198
+ /**
199
+ * Registers a handler for the set log level request.
200
+ */
201
+ onSetLogLevel(e) {
202
+ this.server.server.setRequestHandler(m2, e);
203
+ }
204
+ /**
205
+ * Registers a handler for the list tools request.
206
+ */
207
+ onListResources(e) {
208
+ this.server.server.setRequestHandler(ae, e);
209
+ }
210
+ /**
211
+ * Registers a handler for the roots list changed notification.
212
+ */
213
+ onRootsListChanged(e) {
214
+ this.server.server.setNotificationHandler(ce, e);
215
+ }
216
+ /**
217
+ * Close the transport for window.addEventListener('pagehide')
218
+ */
219
+ async onPagehide(e) {
220
+ e.persisted || this.transport && typeof this.transport.close == "function" && await this.transport.close();
221
+ }
222
+ }
223
+ const y0 = (r, e) => new i2(r, e), v0 = () => K2(), _0 = (r) => r instanceof i2, b0 = (r) => r instanceof P2;
224
+ class Se {
225
+ constructor(e, t) {
226
+ const s = {
227
+ name: "web-mcp-client",
228
+ version: "1.0.0"
229
+ }, i = {
230
+ roots: { listChanged: !0 },
231
+ sampling: {},
232
+ elicitation: {}
233
+ };
234
+ this.client = new k2(e || s, t || { capabilities: i }), this.client.onclose = () => {
235
+ this.onclose?.();
236
+ }, this.client.onerror = (n) => {
237
+ this.onerror?.(n);
238
+ };
239
+ }
240
+ /**
241
+ * Connects the client to a transport via the specified option.
242
+ */
243
+ async connect(e) {
244
+ if (typeof e.start == "function")
245
+ return this.transport = e, this.transport.onclose = void 0, this.transport.onerror = void 0, this.transport.onmessage = void 0, await this.client.connect(this.transport), { transport: this.transport, sessionId: this.transport.sessionId };
246
+ const { url: t, token: s, sessionId: i, type: n, agent: a, onError: l } = e;
247
+ if (a === !0) {
248
+ const d = { client: this.client, url: t, token: s, sessionId: i };
249
+ let g;
250
+ return await (async () => {
251
+ const { transport: C, sessionId: f } = n === "sse" ? await ee(d) : n === "socket" ? await te(d) : await re(d);
252
+ C.onerror = async (u) => {
253
+ l?.(u);
254
+ }, g = { transport: C, sessionId: f };
255
+ })(), g;
256
+ }
257
+ const h = new URL(t);
258
+ let c;
259
+ if (n === "channel" && (c = new n2(t), await this.client.connect(c)), n === "sse") {
260
+ const d = Q2(s, i);
261
+ c = new c2(h, d), await this.client.connect(c);
262
+ }
263
+ if (n === "socket" && (c = new we(new URL(`${t}?sessionId=${i}&token=${s}`)), c.sessionId = i, await this.client.connect(c)), typeof c > "u") {
264
+ const d = X2(s, i);
265
+ c = new G(h, d), await this.client.connect(c);
266
+ }
267
+ return this.transport = c, { transport: this.transport, sessionId: this.transport.sessionId };
268
+ }
269
+ /**
270
+ * Closes the connection.
271
+ */
272
+ async close() {
273
+ await this.client.close();
274
+ }
275
+ /**
276
+ * After initialization has completed, this will be populated with the server's reported capabilities.
277
+ */
278
+ getServerCapabilities() {
279
+ return this.client.getServerCapabilities();
280
+ }
281
+ /**
282
+ * After initialization has completed, this will be populated with information about the server's name and version.
283
+ */
284
+ getServerVersion() {
285
+ return this.client.getServerVersion();
286
+ }
287
+ /**
288
+ * After initialization has completed, this may be populated with information about the server's instructions.
289
+ */
290
+ getInstructions() {
291
+ return this.client.getInstructions();
292
+ }
293
+ /**
294
+ * Sends a ping to the server to check if it is still connected.
295
+ */
296
+ async ping(e) {
297
+ return await this.client.ping(e);
298
+ }
299
+ /**
300
+ * Sends a completion request to the server.
301
+ */
302
+ async complete(e, t) {
303
+ return await this.client.complete(e, t);
304
+ }
305
+ /**
306
+ * Sends a request for setting the logging level to the server.
307
+ */
308
+ async setLoggingLevel(e, t) {
309
+ return await this.client.setLoggingLevel(e, t);
310
+ }
311
+ /**
312
+ * Gets the prompt with the given params from the server.
313
+ */
314
+ async getPrompt(e, t) {
315
+ return await this.client.getPrompt(e, t);
316
+ }
317
+ /**
318
+ * Lists all prompts available on the server.
319
+ */
320
+ async listPrompts(e, t) {
321
+ return await this.client.listPrompts(e, t);
322
+ }
323
+ /**
324
+ * Lists all resources available on the server.
325
+ */
326
+ async listResources(e, t) {
327
+ return await this.client.listResources(e, t);
328
+ }
329
+ /**
330
+ * Lists all resource templates available on the server.
331
+ */
332
+ async listResourceTemplates(e, t) {
333
+ return await this.client.listResourceTemplates(e, t);
334
+ }
335
+ /**
336
+ * Reads the resource with the given params from the server.
337
+ */
338
+ async readResource(e, t) {
339
+ return await this.client.readResource(e, t);
340
+ }
341
+ /**
342
+ * Subscribes to a resource on the server.
343
+ */
344
+ async subscribeResource(e, t) {
345
+ return await this.client.subscribeResource(e, t);
346
+ }
347
+ /**
348
+ * Unsubscribes from a resource on the server.
349
+ */
350
+ async unsubscribeResource(e, t) {
351
+ return await this.client.unsubscribeResource(e, t);
352
+ }
353
+ /**
354
+ * Calls a tool on the server with the given parameters.
355
+ */
356
+ async callTool(e, t) {
357
+ return await this.client.callTool(e, le, t);
358
+ }
359
+ /**
360
+ * Lists all tools available on the server.
361
+ */
362
+ async listTools(e, t) {
363
+ return await this.client.listTools(e, t);
364
+ }
365
+ /**
366
+ * Sends a notification for the roots list changed event to the server.
367
+ */
368
+ async sendRootsListChanged() {
369
+ return await this.client.sendRootsListChanged();
370
+ }
371
+ /**
372
+ * Sends a request and wait for a response.
373
+ *
374
+ * Do not use this method to emit notifications! Use notification() instead.
375
+ */
376
+ request(e, t, s) {
377
+ return this.client.request(e, t, s);
378
+ }
379
+ /**
380
+ * Emits a notification, which is a one-way message that does not expect a response.
381
+ */
382
+ async notification(e, t) {
383
+ return await this.client.notification(e, t);
384
+ }
385
+ /**
386
+ * Registers a handler to invoke when this protocol object receives a request with the given method.
387
+ *
388
+ * Note that this will replace any previous request handler for the same method.
389
+ */
390
+ setRequestHandler(e, t) {
391
+ this.client.setRequestHandler(e, t);
392
+ }
393
+ /**
394
+ * Removes the request handler for the given method.
395
+ */
396
+ removeRequestHandler(e) {
397
+ this.client.removeRequestHandler(e);
398
+ }
399
+ /**
400
+ * Registers a handler to invoke when this protocol object receives a notification with the given method.
401
+ *
402
+ * Note that this will replace any previous notification handler for the same method.
403
+ */
404
+ setNotificationHandler(e, t) {
405
+ this.client.setNotificationHandler(e, t);
406
+ }
407
+ /**
408
+ * Removes the notification handler for the given method.
409
+ */
410
+ removeNotificationHandler(e) {
411
+ this.client.removeNotificationHandler(e);
412
+ }
413
+ /**
414
+ * Registers a handler for the elicitation request.
415
+ */
416
+ onElicit(e) {
417
+ this.client.setRequestHandler(he, e);
418
+ }
419
+ /**
420
+ * Registers a handler for the create LLM message request.
421
+ */
422
+ onCreateMessage(e) {
423
+ this.client.setRequestHandler(de, e);
424
+ }
425
+ /**
426
+ * Registers a handler for the list roots request.
427
+ */
428
+ onListRoots(e) {
429
+ this.client.setRequestHandler(pe, e);
430
+ }
431
+ /**
432
+ * Registers a handler for the tool list changed notification.
433
+ */
434
+ onToolListChanged(e) {
435
+ this.client.setNotificationHandler(ue, e);
436
+ }
437
+ /**
438
+ * Registers a handler for the prompt list changed notification.
439
+ */
440
+ onPromptListChanged(e) {
441
+ this.client.setNotificationHandler(me, e);
442
+ }
443
+ /**
444
+ * Registers a handler for the resource list changed notification.
445
+ */
446
+ onResourceListChanged(e) {
447
+ this.client.setNotificationHandler(ge, e);
448
+ }
449
+ /**
450
+ * Registers a handler for the resource updated notification.
451
+ */
452
+ onResourceUpdated(e) {
453
+ this.client.setNotificationHandler(fe, e);
454
+ }
455
+ /**
456
+ * Registers a handler for the logging message notification.
457
+ */
458
+ onLoggingMessage(e) {
459
+ this.client.setNotificationHandler(Ce, e);
460
+ }
461
+ /**
462
+ * Close the transport for window.addEventListener('pagehide')
463
+ */
464
+ async onPagehide(e) {
465
+ e.persisted || (Re(this.transport) ? await this.transport.terminateSession() : this.transport && typeof this.transport.close == "function" && await this.transport.close());
466
+ }
467
+ }
468
+ const x0 = (r, e) => new c2(r, e), L0 = (r, e) => new G(r, e), S0 = (r, e) => new n2(r, e), R0 = (r) => r instanceof c2, Re = (r) => r instanceof G, T0 = (r) => r instanceof n2, M0 = (r) => r instanceof k2, A = (r, e, t) => {
469
+ window.postMessage({ type: r, direction: t, data: e }, "*");
470
+ }, C2 = (r, e, t) => {
471
+ const s = async function(i) {
472
+ i.source === window && i.data.type === r && i.data.direction === t && await e(i.data.data);
473
+ };
474
+ return window.addEventListener("message", s), () => window.removeEventListener("message", s);
475
+ }, r2 = (r, e, t) => {
476
+ if (t.endsWith("content"))
477
+ chrome.tabs.query({}, (s) => {
478
+ s.forEach((i) => {
479
+ chrome.tabs.sendMessage(i.id, { type: r, data: e, direction: t, tabId: i.id });
480
+ });
481
+ });
482
+ else
483
+ return chrome.runtime.sendMessage({ direction: t, type: r, data: e });
484
+ }, s2 = (r, e, t, s) => {
485
+ const i = (n, a, l) => {
486
+ if (n.type === r && n.direction === t && (!s || s && n.tabId === s)) {
487
+ const { data: h } = n;
488
+ e(h, a, l), l(a);
489
+ }
490
+ };
491
+ return chrome.runtime.onMessage.addListener(i), () => chrome.runtime.onMessage.removeListener(i);
492
+ };
493
+ class w2 {
494
+ constructor(e) {
495
+ this._isStarted = !1, this._isClosed = !1, this.targetSessionId = e, this._messageListener = s2(
496
+ "mcp-server-to-client",
497
+ (t) => {
498
+ try {
499
+ if (t.sessionId !== this.targetSessionId) return;
500
+ const s = a2.parse(t.mcpMessage);
501
+ this.onmessage?.(s);
502
+ } catch (s) {
503
+ console.log("【Client Transport】处理server消息错误:", s);
504
+ }
505
+ },
506
+ "content->side"
507
+ );
508
+ }
509
+ // 是否已关闭
510
+ _throwError(e, t) {
511
+ if (e()) {
512
+ const s = new Error(t);
513
+ throw console.log(t, s), this.onerror && this.onerror(s), s;
514
+ }
515
+ }
516
+ /** 启动 transport,开始监听消息 */
517
+ async start() {
518
+ this._throwError(() => this._isClosed, "【Client Transport】 未启动,无法重新启动"), this._isStarted = !0;
519
+ }
520
+ /** 发送消息到 MCP Server */
521
+ async send(e, t) {
522
+ this._throwError(() => !this._isStarted, "【Client Transport】 未启动,无法发送消息"), this._throwError(() => this._isClosed, "【Client Transport】 已关闭,无法发送消息");
523
+ const s = chrome.sessionRegistry.get(this.targetSessionId);
524
+ this._throwError(() => !s, `【Client Transport】sessionRegistry中未找到${this.targetSessionId}`);
525
+ const i = s.tabIds[s.tabIds.length - 1];
526
+ r2(
527
+ "mcp-client-to-server",
528
+ { sessionId: this.targetSessionId, tabId: i, mcpMessage: e },
529
+ "side->content"
530
+ );
531
+ }
532
+ /** 关闭 transport */
533
+ async close() {
534
+ if (!this._isClosed)
535
+ try {
536
+ this._isClosed = !0, this._isStarted = !1, this._messageListener && this._messageListener(), this.onclose && this.onclose();
537
+ } catch {
538
+ this._throwError(() => !0, "【Client Transport】 关闭时发生错误");
539
+ }
540
+ }
541
+ }
542
+ const I2 = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r) => {
543
+ const e = Math.random() * 16 | 0;
544
+ return (r === "x" ? e : e & 3 | 8).toString(16);
545
+ });
546
+ class E0 {
547
+ constructor(e = null) {
548
+ this._isStarted = !1, this._isClosed = !1, this._lastRegistration = null, this.sessionId = e || I2(), this._messageListener1 = C2(
549
+ "sidepanel-ready-to-page",
550
+ () => {
551
+ this._lastRegistration && this._isStarted && this.notifyRegistration(this._lastRegistration).catch((t) => {
552
+ console.error("【Page Svr Transport】 notifyRegistration失败:", t);
553
+ });
554
+ },
555
+ "content->page"
556
+ ), this._messageListener2 = C2(
557
+ "mcp-client-to-server-to-page",
558
+ (t) => {
559
+ if (t.sessionId !== this.sessionId) return;
560
+ console.log("【Page Svr Transport】 即将处理 mcpMessage", t.mcpMessage);
561
+ const s = a2.parse(t.mcpMessage);
562
+ this.onmessage?.(s), t.mcpMessage.params?.name && A(
563
+ "update-page-app-message",
564
+ { status: "run", message: t.mcpMessage.params?.name },
565
+ "page->content"
566
+ );
567
+ },
568
+ "content->page"
569
+ );
570
+ }
571
+ // 最后一次注册信息(用于 Sidepanel 刷新后重新注册)
572
+ _throwError(e, t) {
573
+ if (e()) {
574
+ const s = new Error(t);
575
+ throw console.log(t, s), this.onerror && this.onerror(s), s;
576
+ }
577
+ }
578
+ /** 启动 transport,开始监听消息 */
579
+ async start() {
580
+ if (!this._isStarted) {
581
+ if (this._isClosed) throw new Error("【Page Svr Transport】 已关闭,无法重新启动");
582
+ this._isStarted = !0;
583
+ }
584
+ }
585
+ /** 发送消息到 MCP Client */
586
+ async send(e, t) {
587
+ this._throwError(() => !this._isStarted, "【Page Svr Transport】 未启动,无法发送消息"), this._throwError(() => this._isClosed, "【Page Svr Transport】 已关闭,无法发送消息"), A(
588
+ "mcp-server-to-client-from-page",
589
+ {
590
+ sessionId: this.sessionId,
591
+ mcpMessage: e
592
+ },
593
+ "page->content"
594
+ ), "result" in e && e.result?.content && A(
595
+ "update-page-app-message",
596
+ { status: "ready", message: "" },
597
+ "page->content"
598
+ // 此处应该是 content->content, 但为了和pageServerTransport统一。
599
+ );
600
+ }
601
+ /** 通知 Sidepanel 此 Server 已启动并准备接受连接 */
602
+ async notifyRegistration(e) {
603
+ this._throwError(() => !this._isStarted, "【Page Svr Transport】 未启动,无法注册消息"), this._lastRegistration = e;
604
+ try {
605
+ A(
606
+ "mcp-server-register-from-page",
607
+ {
608
+ sessionId: this.sessionId,
609
+ serverInfo: {
610
+ ...e,
611
+ url: window.location.origin,
612
+ title: document.title
613
+ }
614
+ },
615
+ "page->content"
616
+ );
617
+ } catch (t) {
618
+ this._throwError(() => !0, "【Page Svr Transport】 注册 server 失败" + String(t));
619
+ }
620
+ }
621
+ /** 关闭 transport */
622
+ async close() {
623
+ if (!this._isClosed)
624
+ try {
625
+ this._messageListener1 && this._messageListener1(), this._messageListener2 && this._messageListener2(), this._isClosed = !0, this._isStarted = !1, this.onclose && this.onclose();
626
+ } catch (e) {
627
+ this._throwError(() => !0, "【Page Svr Transport】 关闭时发生错误" + String(e));
628
+ }
629
+ }
630
+ }
631
+ class P0 {
632
+ constructor(e = null, t) {
633
+ this._isStarted = !1, this._isClosed = !1, this._lastRegistration = null, this.sessionId = e || I2(), this.tabId = t, s2(
634
+ "sidepanel-ready",
635
+ () => {
636
+ this._lastRegistration && this._isStarted && this.notifyRegistration(this._lastRegistration).catch((s) => {
637
+ console.log("【Content Svr Transport】 notifyRegistration 失败", s);
638
+ });
639
+ },
640
+ "side->content",
641
+ this.tabId
642
+ );
643
+ }
644
+ // 最后一次注册信息(用于 Sidepanel 刷新后重新注册)
645
+ _throwError(e, t) {
646
+ if (e()) {
647
+ const s = new Error(t);
648
+ throw console.log(t, s), this.onerror && this.onerror(s), s;
649
+ }
650
+ }
651
+ /** 启动 transport,开始监听MCP client 消息 */
652
+ async start() {
653
+ if (console.log("【Content Svr Transport】 启动 start", this.sessionId), !this._isStarted) {
654
+ if (this._isClosed) throw new Error("【Content Svr Transport】 已关闭,无法重新启动");
655
+ s2(
656
+ "mcp-client-to-server",
657
+ (e) => {
658
+ if (!(e.sessionId !== this.sessionId || e.tabId !== this.tabId))
659
+ try {
660
+ console.log("【Content Svr Transport】 即将处理 mcpMessage", e.mcpMessage);
661
+ const t = a2.parse(e.mcpMessage);
662
+ this.onmessage?.(t), e.mcpMessage.params?.name && A(
663
+ "update-page-app-message",
664
+ { status: "run", message: e.mcpMessage.params?.name },
665
+ "page->content"
666
+ // 此处应该是 content->content, 但为了和pageServerTransport统一。
667
+ );
668
+ } catch (t) {
669
+ console.log("【Content Svr Transport】 处理消息时发生错误:", t);
670
+ }
671
+ },
672
+ "side->content",
673
+ this.tabId
674
+ ), this._isStarted = !0;
675
+ }
676
+ }
677
+ /** 发送消息到 MCP Client */
678
+ async send(e, t) {
679
+ this._throwError(() => !this._isStarted, "【Content Svr Transport】 未启动,无法发送消息"), this._throwError(() => this._isClosed, "【Content Svr Transport】 已关闭,无法发送消息");
680
+ try {
681
+ console.log("【Content Svr Transport】 发送消息到 MCP Client", e), r2(
682
+ "mcp-server-to-client",
683
+ {
684
+ sessionId: this.sessionId,
685
+ mcpMessage: e
686
+ },
687
+ "content->side"
688
+ ), "result" in e && e.result?.content && A(
689
+ "update-page-app-message",
690
+ { status: "ready", message: "" },
691
+ "page->content"
692
+ // 此处应该是 content->content, 但为了和pageServerTransport统一。
693
+ );
694
+ } catch (s) {
695
+ this._throwError(() => !0, "【Content Svr Transport】发送消息失败" + String(s));
696
+ }
697
+ }
698
+ /** 通知 Sidepanel 此 Server 已启动并准备接受连接 */
699
+ async notifyRegistration(e) {
700
+ this._isStarted && (this._lastRegistration = e, r2(
701
+ "mcp-server-register",
702
+ {
703
+ sessionId: this.sessionId,
704
+ serverInfo: {
705
+ ...e,
706
+ url: window.location.origin,
707
+ title: document.title
708
+ }
709
+ },
710
+ "content->side"
711
+ ));
712
+ }
713
+ async close() {
714
+ if (!this._isClosed)
715
+ try {
716
+ this._isClosed = !0, this._isStarted = !1, this.onclose && this.onclose();
717
+ } catch (e) {
718
+ this._throwError(() => !0, "【Content Svr Transport】 关闭时发生错误" + String(e));
719
+ }
720
+ }
721
+ }
722
+ class Te {
723
+ constructor(e, { size: t = 200, margin: s = 4, color: i = "#000", bgColor: n = "#fff" }) {
724
+ this.value = e, this.size = t, this.margin = s, this.color = i, this.bgColor = n;
725
+ }
726
+ get qrCodeOption() {
727
+ return {
728
+ width: this.size,
729
+ margin: this.margin,
730
+ color: {
731
+ dark: this.color,
732
+ // 前景色
733
+ light: this.bgColor
734
+ // 背景色
735
+ }
736
+ };
737
+ }
738
+ /** 生成二维码的 Data URL(base64 图片) */
739
+ async toDataURL() {
740
+ return g2.toDataURL(this.value, this.qrCodeOption);
741
+ }
742
+ /** 渲染二维码到指定的 canvas 元素 */
743
+ async toCanvas(e) {
744
+ return g2.toCanvas(e, this.value, this.qrCodeOption);
745
+ }
746
+ /** 渲染二维码到指定的 img 元素 */
747
+ async toImage(e) {
748
+ e.src = await this.toDataURL();
749
+ }
750
+ }
751
+ const Me = {
752
+ content: "",
753
+ placement: "top",
754
+ trigger: "hover",
755
+ delay: 150,
756
+ hideDelay: 150,
757
+ container: document.body,
758
+ className: "tiny-remoter-native-tooltip"
759
+ };
760
+ class Ee {
761
+ constructor(e, t = {}) {
762
+ if (this.tip = null, this.showTimer = 0, this.hideTimer = 0, this.clickOutside = null, this.el = typeof e == "string" ? document.querySelector(e) : e, !this.el) throw new Error("Tooltip: invalid element");
763
+ this.opts = { ...Me, ...t }, this.bindEvents();
764
+ }
765
+ /* 公开 API */
766
+ open() {
767
+ this.isShown() || (this.clearTimer(), this.showTimer = window.setTimeout(() => {
768
+ this.render(), this.opts.container.appendChild(this.tip), this.reposition(), this.attachExtraEvents();
769
+ }, this.opts.delay));
770
+ }
771
+ close() {
772
+ this.clearTimer(), this.hideTimer = window.setTimeout(() => {
773
+ this.tip?.remove(), this.detachExtraEvents();
774
+ }, this.opts.hideDelay);
775
+ }
776
+ toggle() {
777
+ this.isShown() ? this.close() : this.open();
778
+ }
779
+ destroy() {
780
+ this.close();
781
+ const e = this.opts.trigger;
782
+ this.el.removeEventListener("mouseenter", this.open), this.el.removeEventListener("mouseleave", this.close), this.el.removeEventListener("focus", this.open), this.el.removeEventListener("blur", this.close), e === "click" && this.el.removeEventListener("click", this.toggle);
783
+ }
784
+ /* 私有方法 */
785
+ bindEvents() {
786
+ const e = this.opts.trigger;
787
+ e === "hover" ? (this.el.addEventListener("mouseenter", () => this.open()), this.el.addEventListener("mouseleave", () => this.close())) : e === "focus" ? (this.el.addEventListener("focus", () => this.open()), this.el.addEventListener("blur", () => this.close())) : e === "click" && this.el.addEventListener("click", () => this.toggle());
788
+ }
789
+ render() {
790
+ if (this.tip) return;
791
+ const e = typeof this.opts.content == "function" ? this.opts.content() : this.opts.content;
792
+ this.tip = document.createElement("div"), this.tip.className = `${this.opts.className} ${this.opts.className}--${this.opts.placement}`, this.tip.innerHTML = `
793
+ <div class="${this.opts.className}__arrow"></div>
794
+ <div class="${this.opts.className}__inner">${e}</div>
795
+ `;
796
+ }
797
+ reposition() {
798
+ const e = this.placementList(this.opts.placement);
799
+ for (const t of e) {
800
+ const s = this.calcStyle(t);
801
+ if (this.checkViewport(s)) {
802
+ this.applyStyle(s), this.tip.className = `${this.opts.className} ${this.opts.className}--${t}`;
803
+ return;
804
+ }
805
+ }
806
+ this.applyStyle(this.calcStyle("top"));
807
+ }
808
+ calcStyle(e) {
809
+ const t = this.el.getBoundingClientRect(), s = this.tip.getBoundingClientRect(), i = window.pageYOffset || document.documentElement.scrollTop, n = window.pageXOffset || document.documentElement.scrollLeft, a = 6, [l, h = "center"] = e.split("-");
810
+ let c = 0, d = 0;
811
+ return l === "top" ? c = t.top + i - s.height - a : l === "bottom" ? c = t.bottom + i + a : l === "left" ? d = t.left + n - s.width - a : l === "right" && (d = t.right + n + a), (l === "top" || l === "bottom") && (h === "start" ? d = t.left + n : h === "end" ? d = t.right + n - s.width : d = (t.left + t.right) / 2 + n - s.width / 2), (l === "left" || l === "right") && (h === "start" ? c = t.top + i : h === "end" ? c = t.bottom + i - s.height : c = (t.top + t.bottom) / 2 + i - s.height / 2), { top: Math.round(c), left: Math.round(d) };
812
+ }
813
+ applyStyle({ top: e, left: t }) {
814
+ Object.assign(this.tip.style, {
815
+ position: "absolute",
816
+ top: `${e}px`,
817
+ left: `${t}px`
818
+ });
819
+ }
820
+ checkViewport({ top: e, left: t }) {
821
+ const i = window.innerWidth, n = window.innerHeight, a = this.tip.getBoundingClientRect();
822
+ return t >= 5 && e >= 5 && t + a.width <= i - 5 && e + a.height <= n - 5;
823
+ }
824
+ placementList(e) {
825
+ const t = {
826
+ top: ["top", "bottom", "top-start", "bottom-start", "top-end", "bottom-end"],
827
+ bottom: ["bottom", "top", "bottom-start", "top-start", "bottom-end", "top-end"],
828
+ left: ["left", "right", "left-start", "right-start", "left-end", "right-end"],
829
+ right: ["right", "left", "right-start", "left-start", "right-end", "left-end"]
830
+ };
831
+ return t[e.split("-")[0]] || t.top;
832
+ }
833
+ attachExtraEvents() {
834
+ this.opts.trigger === "click" ? (this.clickOutside = (e) => {
835
+ const t = e.composedPath();
836
+ !t.includes(this.el) && !t.includes(this.tip) && this.close();
837
+ }, document.addEventListener("mousedown", this.clickOutside)) : this.opts.trigger === "hover" && (this.tip.addEventListener("mouseenter", () => this.clearTimer()), this.tip.addEventListener("mouseleave", () => this.close()));
838
+ }
839
+ detachExtraEvents() {
840
+ this.clickOutside && (document.removeEventListener("mousedown", this.clickOutside), this.clickOutside = null);
841
+ }
842
+ clearTimer() {
843
+ clearTimeout(this.showTimer), clearTimeout(this.hideTimer);
844
+ }
845
+ isShown() {
846
+ return !!this.tip?.parentNode;
847
+ }
848
+ }
849
+ const y2 = "tiny-remoter-native-tooltip-style";
850
+ (() => {
851
+ if (document.getElementById(y2)) return;
852
+ const r = document.createElement("style");
853
+ r.id = y2, r.textContent = `
854
+ .tiny-remoter-native-tooltip {
855
+ position: absolute;
856
+ z-index: 9999;
857
+ max-width: 200px;
858
+ padding: 6px 10px;
859
+ font-size: 12px;
860
+ line-height: 1.4;
861
+ color: #fff;
862
+ background: #191919;
863
+ border-radius: 4px;
864
+ pointer-events: none;
865
+ box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.2);
866
+ }
867
+ .tiny-remoter-native-tooltip__arrow {
868
+ position: absolute;
869
+ width: 0; height: 0;
870
+ border: 6px solid transparent;
871
+ }
872
+ .tiny-remoter-native-tooltip--top
873
+ .tiny-remoter-native-tooltip__arrow {
874
+ bottom: -12px;
875
+ left: 50%; transform:
876
+ translateX(-50%);
877
+ border-top-color: rgba(0,0,0,.75);
878
+ }
879
+ .tiny-remoter-native-tooltip--bottom
880
+ .tiny-remoter-native-tooltip__arrow {
881
+ top: -12px;
882
+ left: 50%; transform:
883
+ translateX(-50%);
884
+ border-bottom-color: rgba(0,0,0,.75);
885
+ }
886
+ .tiny-remoter-native-tooltip--left
887
+ .tiny-remoter-native-tooltip__arrow {
888
+ right: -12px;
889
+ top: 50%;
890
+ transform: translateY(-50%);
891
+ border-left-color: rgba(0,0,0,.75);
892
+ }
893
+ .tiny-remoter-native-tooltip--right
894
+ .tiny-remoter-native-tooltip__arrow {
895
+ left: -12px;
896
+ top: 50%;
897
+ transform: translateY(-50%);
898
+ border-right-color: rgba(0,0,0,.75);
899
+ }
900
+ `, document.head.appendChild(r);
901
+ })();
902
+ const Pe = "data:image/svg+xml,%3csvg%20viewBox='0%200%2040%2039.9692'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='40.000000'%20height='39.969238'%20fill='none'%20customFrame='url(%23clipPath_3)'%3e%3cdefs%3e%3cclipPath%20id='clipPath_3'%3e%3crect%20width='40.000000'%20height='39.969238'%20x='0.000000'%20y='0.000000'%20rx='12.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_4'%3e%3crect%20width='24.000000'%20height='24.000000'%20x='8.000000'%20y='7.984619'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_5'%3e%3crect%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='9.984619'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_6'%3e%3crect%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='9.984619'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_7'%3e%3crect%20width='21.666666'%20height='13.333333'%20x='20.000000'%20y='9.984619'%20rx='6.666667'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_8'%3e%3crect%20width='6.666667'%20height='6.666667'%20x='23.333496'%20y='9.984619'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3c/defs%3e%3crect%20id='2'%20width='40.000000'%20height='39.969238'%20x='0.000000'%20y='0.000000'%20rx='12.000000'%20fill='rgb(239,246,255)'%20/%3e%3cg%20id='物业'%20clip-path='url(%23clipPath_4)'%20customFrame='url(%23clipPath_4)'%3e%3crect%20id='物业'%20width='24.000000'%20height='24.000000'%20x='8.000000'%20y='7.984619'%20/%3e%3cg%20id='物业服务'%3e%3cg%20id='00公共/红点/图标+红点'%20customFrame='url(%23clipPath_5)'%3e%3crect%20id='00公共/红点/图标+红点'%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='9.984619'%20/%3e%3cg%20id='common_chats_line'%20customFrame='url(%23clipPath_6)'%3e%3crect%20id='common_chats_line'%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='9.984619'%20/%3e%3cpath%20id='形状'%20d='M28.3332%2019.9847C28.3332%2015.3823%2024.6022%2011.6514%2019.9998%2011.6514C15.3975%2011.6514%2011.6665%2015.3823%2011.6665%2019.9847C11.6665%2024.5871%2015.3975%2028.318%2019.9998%2028.318C21.0018%2028.318%2021.9624%2028.1412%2022.8522%2027.8171L26.581%2028.1578C26.7205%2028.1706%2026.8611%2028.1598%2026.9971%2028.1259C27.6669%2027.959%2028.0746%2027.2806%2027.9077%2026.6108L27.2716%2024.0578C27.9477%2022.8535%2028.3332%2021.4641%2028.3332%2019.9847ZM19.9998%2013.1514C16.2259%2013.1514%2013.1665%2016.2108%2013.1665%2019.9847C13.1665%2023.7586%2016.2259%2026.818%2019.9998%2026.818C20.8089%2026.818%2021.5967%2026.678%2022.3388%2026.4077C22.505%2026.3471%2022.6803%2026.3166%2022.8565%2026.3171L22.9887%2026.3233L26.3665%2026.6322L25.8161%2024.4205C25.7352%2024.0958%2025.7655%2023.7548%2025.8997%2023.4512L25.9636%2023.3236C26.5311%2022.3126%2026.8332%2021.1723%2026.8332%2019.9847C26.8332%2016.2108%2023.7738%2013.1514%2019.9998%2013.1514ZM23.1152%2021.2468C23.352%2020.9069%2023.2684%2020.4394%2022.9286%2020.2026C22.5887%2019.9659%2022.1212%2020.0494%2021.8845%2020.3893C21.2894%2021.2433%2020.4268%2021.7347%2019.5102%2021.7347C18.9513%2021.7347%2018.4132%2021.554%2017.9375%2021.2122C17.6011%2020.9705%2017.1325%2021.0472%2016.8908%2021.3836C16.6491%2021.7199%2016.7258%2022.1886%2017.0622%2022.4303C17.7879%2022.9518%2018.6305%2023.2347%2019.5102%2023.2347C20.9394%2023.2347%2022.2505%2022.4878%2023.1152%2021.2468Z'%20fill='rgb(65,142,255)'%20fill-rule='evenodd'%20/%3e%3c/g%3e%3cg%20id='00公共/3位数红点'%20opacity='0'%20customFrame='url(%23clipPath_7)'%3e%3crect%20id='00公共/3位数红点'%20width='21.666666'%20height='13.333333'%20x='20.000000'%20y='9.984619'%20rx='6.666667'%20opacity='0'%20fill='rgb(243,111,100)'%20/%3e%3cpath%20id='文本'%20d='M26.0421%2013.4421C26.4259%2013.4421%2026.7677%2013.5255%2027.0675%2013.6923C27.3672%2013.8591%2027.6005%2014.0931%2027.7673%2014.3942C27.9342%2014.694%2028.0176%2015.0351%2028.0176%2015.4176C28.0176%2015.7173%2027.9633%2015.994%2027.8548%2016.2476C27.7463%2016.4999%2027.5673%2016.8315%2027.3177%2017.2425L25.859%2019.6432L25.0167%2019.6432L26.276%2017.5924C26.3534%2017.4704%2026.4307%2017.3564%2026.508%2017.2507C26.3357%2017.3063%2026.1445%2017.3341%2025.9342%2017.3341C25.5721%2017.3341%2025.2493%2017.2479%2024.9658%2017.0757C24.6837%2016.9034%2024.4633%2016.6701%2024.3046%2016.3758C24.1459%2016.0815%2024.0666%2015.7566%2024.0666%2015.4013C24.0666%2015.0351%2024.1513%2014.7021%2024.3209%2014.4023C24.4904%2014.1012%2024.7264%2013.8659%2025.0289%2013.6964C25.3314%2013.5268%2025.6691%2013.4421%2026.0421%2013.4421ZM26.0421%2016.6505C26.4029%2016.6505%2026.6904%2016.5325%2026.9047%2016.2965C27.119%2016.0605%2027.2262%2015.7539%2027.2262%2015.3769C27.2262%2014.9985%2027.119%2014.694%2026.9047%2014.4634C26.6904%2014.2328%2026.4029%2014.1175%2026.0421%2014.1175C25.6867%2014.1175%2025.4019%2014.2342%2025.1876%2014.4674C24.9733%2014.7007%2024.8661%2015.0039%2024.8661%2015.3769C24.8661%2015.7539%2024.9719%2016.0605%2025.1835%2016.2965C25.3951%2016.5325%2025.6813%2016.6505%2026.0421%2016.6505ZM30.7921%2013.4421C31.1759%2013.4421%2031.5177%2013.5255%2031.8175%2013.6923C32.1172%2013.8591%2032.3505%2014.0931%2032.5173%2014.3942C32.6842%2014.694%2032.7676%2015.0351%2032.7676%2015.4176C32.7676%2015.7173%2032.7133%2015.994%2032.6048%2016.2476C32.4963%2016.4999%2032.3173%2016.8315%2032.0677%2017.2425L30.609%2019.6432L29.7667%2019.6432L31.026%2017.5924C31.1034%2017.4704%2031.1807%2017.3564%2031.258%2017.2507C31.0857%2017.3063%2030.8945%2017.3341%2030.6842%2017.3341C30.3221%2017.3341%2029.9993%2017.2479%2029.7158%2017.0757C29.4337%2016.9034%2029.2133%2016.6701%2029.0546%2016.3758C28.8959%2016.0815%2028.8166%2015.7566%2028.8166%2015.4013C28.8166%2015.0351%2028.9013%2014.7021%2029.0709%2014.4023C29.2404%2014.1012%2029.4764%2013.8659%2029.7789%2013.6964C30.0814%2013.5268%2030.4191%2013.4421%2030.7921%2013.4421ZM30.7921%2016.6505C31.1529%2016.6505%2031.4404%2016.5325%2031.6547%2016.2965C31.869%2016.0605%2031.9762%2015.7539%2031.9762%2015.3769C31.9762%2014.9985%2031.869%2014.694%2031.6547%2014.4634C31.4404%2014.2328%2031.1529%2014.1175%2030.7921%2014.1175C30.4367%2014.1175%2030.1519%2014.2342%2029.9376%2014.4674C29.7233%2014.7007%2029.6161%2015.0039%2029.6161%2015.3769C29.6161%2015.7539%2029.7219%2016.0605%2029.9335%2016.2965C30.1451%2016.5325%2030.4313%2016.6505%2030.7921%2016.6505ZM35.2674%2014.6851L35.9001%2014.6851L35.9001%2016.3188L37.5339%2016.3188L37.5339%2016.9516L35.9001%2016.9516L35.9001%2018.5853L35.2674%2018.5853L35.2674%2016.9516L33.6337%2016.9516L33.6337%2016.3188L35.2674%2016.3188L35.2674%2014.6851Z'%20fill='rgb(255,255,255)'%20fill-rule='nonzero'%20/%3e%3c/g%3e%3cg%20id='00公共/单红点'%20opacity='0'%20customFrame='url(%23clipPath_8)'%3e%3crect%20id='00公共/单红点'%20width='6.666667'%20height='6.666667'%20x='23.333496'%20y='9.984619'%20opacity='0'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20/%3e%3ccircle%20id='红点'%20cx='26.6668301'%20cy='13.3179522'%20r='3.33333325'%20fill='rgb(243,111,100)'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e", ke = "data:image/svg+xml,%3csvg%20viewBox='0%200%2040%2040'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='40.000000'%20height='40.000000'%20fill='none'%20customFrame='url(%23clipPath_12)'%3e%3cdefs%3e%3cclipPath%20id='clipPath_12'%3e%3crect%20width='40.000000'%20height='40.000000'%20x='0.000000'%20y='0.000000'%20rx='12.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_13'%3e%3crect%20width='24.000000'%20height='24.000000'%20x='8.000000'%20y='8.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_14'%3e%3crect%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='10.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3c/defs%3e%3crect%20id='4'%20width='40.000000'%20height='40.000000'%20x='0.000000'%20y='0.000000'%20rx='12.000000'%20fill='rgb(234,255,244)'%20/%3e%3cg%20id='我的信息'%20clip-path='url(%23clipPath_13)'%20customFrame='url(%23clipPath_13)'%3e%3crect%20id='我的信息'%20width='24.000000'%20height='24.000000'%20x='8.000000'%20y='8.000000'%20/%3e%3cg%20id='组合%208'%20customFrame='url(%23clipPath_14)'%3e%3crect%20id='组合%208'%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='10.000000'%20/%3e%3cpath%20id='合并'%20d='M28.4994%2012.3142C28.4994%2012.2578%2028.4937%2012.2018%2028.4825%2012.1465C28.4713%2012.0911%2028.4547%2012.0373%2028.4327%2011.9851C28.4107%2011.933%2028.3836%2011.8835%2028.3516%2011.8365C28.3197%2011.7896%2028.2834%2011.7461%2028.2427%2011.7062C28.202%2011.6663%2028.1579%2011.6307%2028.1101%2011.5993C28.0622%2011.568%2028.0117%2011.5415%2027.9585%2011.5199C27.9054%2011.4983%2027.8506%2011.4819%2027.7942%2011.4709C27.7378%2011.4599%2027.6806%2011.4544%2027.6231%2011.4544L24.1832%2011.5199L24.1832%2010L29.0796%2010C29.1472%2010%2029.2143%2010.0065%2029.2806%2010.0194C29.347%2010.0324%2029.4114%2010.0516%2029.4739%2010.077C29.5364%2010.1024%2029.5961%2010.1336%2029.6523%2010.1705C29.7086%2010.2074%2029.7605%2010.2493%2029.8084%2010.2963C29.8562%2010.3433%2029.8991%2010.3944%2029.9367%2010.4496C29.9743%2010.5048%2030.006%2010.5631%2030.0319%2010.6244C30.0578%2010.6858%2030.0773%2010.7491%2030.0905%2010.8142C30.1037%2010.8794%2030.1104%2010.9451%2030.1104%2011.0115L30.1832%2014.4522L28.4992%2014.5L28.4994%2012.3142ZM11.6995%2012.3143C11.6995%2012.2579%2011.7051%2012.2019%2011.7163%2012.1466C11.7275%2012.0912%2011.7441%2012.0374%2011.7661%2011.9852C11.7882%2011.9331%2011.8152%2011.8836%2011.8472%2011.8366C11.8791%2011.7897%2011.9155%2011.7462%2011.9562%2011.7063C11.9968%2011.6664%2012.0409%2011.6308%2012.0888%2011.5994C12.1366%2011.5681%2012.1871%2011.5416%2012.2403%2011.52C12.2934%2011.4984%2012.3482%2011.482%2012.4046%2011.471C12.4611%2011.46%2012.5182%2011.4545%2012.5758%2011.4545L16.0157%2011.52L16.0157%2010.0001L11.1193%2010.0001C11.0516%2010.0001%2010.9846%2010.0066%2010.9182%2010.0196C10.8518%2010.0325%2010.7874%2010.0517%2010.7249%2010.0771C10.6624%2010.1025%2010.6028%2010.1337%2010.5465%2010.1706C10.4902%2010.2075%2010.4383%2010.2494%2010.3904%2010.2964C10.3426%2010.3434%2010.2997%2010.3945%2010.2621%2010.4497C10.2245%2010.5049%2010.1929%2010.5632%2010.167%2010.6245C10.1411%2010.6859%2010.1215%2010.7492%2010.1083%2010.8143C10.0951%2010.8795%2010.0885%2010.9452%2010.0884%2011.0116L10.0157%2014.4523L11.6997%2014.5L11.6995%2012.3143ZM25.3135%2021.8051L25.3135%2022.8167C25.7656%2022.8929%2026.2209%2022.9249%2026.6792%2022.9127C28.3381%2022.9127%2029.1675%2022.326%2029.1675%2021.1527C29.1733%2020.9869%2029.151%2020.825%2029.1006%2020.667C29.0503%2020.509%2028.9747%2020.3641%2028.8742%2020.2322C28.767%2020.1025%2028.6403%2019.9963%2028.4938%2019.9134C28.3474%2019.8306%2028.191%2019.7767%2028.0246%2019.7517L28.0246%2019.7011C28.0971%2019.6839%2028.1676%2019.6606%2028.236%2019.6311C28.3044%2019.6016%2028.3698%2019.5665%2028.4321%2019.5257C28.4944%2019.4848%2028.5526%2019.4389%2028.6069%2019.3879C28.6613%2019.3369%2028.7109%2019.2816%2028.7556%2019.222C28.8003%2019.1624%2028.8394%2019.0994%2028.8732%2019.033C28.9069%2018.9665%2028.9346%2018.8977%2028.9564%2018.8265C28.9782%2018.7552%2028.9937%2018.6826%2029.0028%2018.6086C29.0119%2018.5347%2029.0145%2018.4605%2029.0107%2018.3861C29.0217%2018.2675%2029.0176%2018.1495%2028.9984%2018.0319C28.9791%2017.9144%2028.9454%2017.8012%2028.8971%2017.6923C28.8489%2017.5834%2028.7875%2017.4823%2028.7134%2017.3891C28.6393%2017.2959%2028.5547%2017.2135%2028.4595%2017.1419C28.219%2017.0003%2027.963%2016.8972%2027.6915%2016.8326C27.4199%2016.7679%2027.1449%2016.7446%2026.8664%2016.7626C26.6258%2016.7621%2026.3864%2016.7791%2026.1482%2016.8132C25.9479%2016.8386%2025.7504%2016.8791%2025.5563%2016.9346L25.5563%2017.8854C25.743%2017.8264%2025.9337%2017.7842%2026.128%2017.759C26.3276%2017.73%2026.5282%2017.7148%2026.7298%2017.7134C27.0252%2017.6949%2027.3049%2017.7523%2027.5692%2017.8854C27.6168%2017.9161%2027.6595%2017.9525%2027.6972%2017.9947C27.7348%2018.037%2027.766%2018.0835%2027.791%2018.1343C27.816%2018.1851%2027.8337%2018.2383%2027.8441%2018.294C27.8545%2018.3496%2027.8573%2018.4056%2027.8525%2018.462C27.8566%2018.5278%2027.8514%2018.5927%2027.8367%2018.657C27.822%2018.7212%2027.7986%2018.7821%2027.7663%2018.8395C27.734%2018.897%2027.694%2018.9487%2027.6468%2018.9946C27.5995%2019.0405%2027.5468%2019.0787%2027.4885%2019.1093C27.1544%2019.2631%2026.8037%2019.3306%2026.4364%2019.3117L25.9862%2019.3117L25.9862%2020.1917L26.4466%2020.1917C26.8409%2020.1669%2027.2202%2020.2309%2027.5845%2020.3839C27.6459%2020.4167%2027.7011%2020.4576%2027.7505%2020.5066C27.7999%2020.5556%2027.8412%2020.6107%2027.8745%2020.6718C27.9077%2020.733%2027.9315%2020.7976%2027.9458%2020.8656C27.9602%2020.9337%2027.9644%2021.0024%2027.9587%2021.0717C27.9648%2021.1402%2027.9612%2021.2083%2027.9478%2021.2757C27.9344%2021.3432%2027.912%2021.4074%2027.8801%2021.4683C27.8483%2021.5293%2027.8086%2021.5846%2027.7609%2021.6341C27.7132%2021.6837%2027.6593%2021.7254%2027.5996%2021.7596C27.2884%2021.9045%2026.9613%2021.9685%2026.6184%2021.9518C26.1786%2021.9465%2025.7436%2021.8977%2025.3135%2021.8051ZM21.3382%2018.6238C21.3445%2018.5593%2021.343%2018.495%2021.3335%2018.4308C21.3241%2018.3667%2021.3069%2018.3046%2021.2822%2018.2447C21.2575%2018.1847%2021.226%2018.1287%2021.1876%2018.0765C21.1492%2018.0242%2021.1049%2017.9774%2021.055%2017.936C20.9359%2017.8608%2020.808%2017.806%2020.6714%2017.7714C20.5349%2017.7368%2020.3964%2017.7242%2020.2558%2017.7337C19.8009%2017.7395%2019.356%2017.8087%2018.9208%2017.9411L18.9208%2016.9598C19.4252%2016.8181%2019.9393%2016.7524%2020.4633%2016.7626C20.7322%2016.7484%2020.9964%2016.7773%2021.256%2016.8491C21.5156%2016.9209%2021.7571%2017.032%2021.9806%2017.1824C22.0729%2017.2601%2022.1548%2017.3474%2022.2263%2017.4446C22.2978%2017.5418%2022.3567%2017.646%2022.4034%2017.7573C22.45%2017.8686%2022.483%2017.9838%2022.5021%2018.1029C22.5213%2018.222%2022.5261%2018.3417%2022.5167%2018.462C22.5245%2018.7882%2022.4655%2019.1017%2022.3396%2019.4027C22.1879%2019.7384%2021.984%2020.0384%2021.7277%2020.3029C21.3021%2020.7337%2020.8502%2021.135%2020.3721%2021.5067L19.9928%2021.8051L19.9928%2021.8759L22.6938%2021.8759L22.6938%2022.8419L18.5464%2022.8419L18.5464%2021.7697C19.2882%2021.1796%2019.8579%2020.6975%2020.2558%2020.3232C20.574%2020.0432%2020.8523%2019.728%2021.0905%2019.3774C21.1675%2019.2665%2021.2269%2019.1469%2021.2691%2019.0187C21.3113%2018.8904%2021.3344%2018.7588%2021.3382%2018.6238ZM12.3102%2017.2127L12.3102%2018.1939L13.7769%2017.9107L13.7769%2022.8419L14.9605%2022.8419L14.9605%2016.8486L14.0957%2016.8486L12.3102%2017.2127ZM28.5524%2028.0475C28.5524%2028.104%2028.5467%2028.1599%2028.5353%2028.2152C28.5239%2028.2706%2028.5071%2028.3244%2028.4849%2028.3766C28.4626%2028.4287%2028.4352%2028.4782%2028.4028%2028.5252C28.3705%2028.5721%2028.3337%2028.6156%2028.2925%2028.6555C28.2513%2028.6954%2028.2067%2028.731%2028.1583%2028.7624C28.1098%2028.7937%2028.0587%2028.8202%2028.0049%2028.8418C27.9511%2028.8634%2027.8957%2028.8798%2027.8385%2028.8908C27.7814%2028.9018%2027.7235%2028.9073%2027.6653%2028.9073L24.1832%2028.8418L24.1832%2030.3617L29.1397%2030.3617C29.2082%2030.3617%2029.276%2030.3552%2029.3432%2030.3423C29.4104%2030.3293%2029.4756%2030.3101%2029.5389%2030.2847C29.6022%2030.2593%2029.6625%2030.2281%2029.7195%2030.1912C29.7765%2030.1543%2029.829%2030.1124%2029.8774%2030.0654C29.9259%2030.0184%2029.9693%2029.9673%2030.0074%2029.9121C30.0454%2029.8569%2030.0774%2029.7986%2030.1037%2029.7373C30.1299%2029.6759%2030.1497%2029.6126%2030.163%2029.5475C30.1764%2029.4823%2030.1831%2029.4166%2030.1832%2029.3502L30.1832%2026.0478L28.4785%2026L28.5524%2028.0475ZM11.6308%2028.0099C11.6308%2028.0664%2011.6365%2028.1223%2011.6479%2028.1777C11.6592%2028.233%2011.676%2028.2868%2011.6983%2028.339C11.7206%2028.3911%2011.748%2028.4406%2011.7803%2028.4876C11.8127%2028.5345%2011.8495%2028.578%2011.8906%2028.6179C11.9318%2028.6578%2011.9765%2028.6934%2012.0249%2028.7248C12.0733%2028.7562%2012.1244%2028.7826%2012.1783%2028.8042C12.2321%2028.8259%2012.2875%2028.8422%2012.3446%2028.8532C12.4017%2028.8642%2012.4596%2028.8697%2012.5178%2028.8698L16%2028.8042L16%2030.3241L11.0435%2030.3241C10.975%2030.3241%2010.9071%2030.3176%2010.8399%2030.3047C10.7727%2030.2917%2010.7076%2030.2725%2010.6443%2030.2471C10.581%2030.2217%2010.5206%2030.1906%2010.4637%2030.1537C10.4067%2030.1168%2010.3542%2030.0748%2010.3057%2030.0278C10.2573%2029.9809%2010.2138%2029.9298%2010.1758%2029.8745C10.1377%2029.8193%2010.1057%2029.7611%2010.0795%2029.6997C10.0533%2029.6383%2010.0335%2029.575%2010.0201%2029.5099C10.0068%2029.4448%2010%2029.379%2010%2029.3126L10%2026.0478L11.7047%2026L11.6308%2028.0099Z'%20fill='rgb(14,191,241)'%20fill-rule='evenodd'%20/%3e%3c/g%3e%3c/g%3e%3c/svg%3e", Ie = "data:image/svg+xml,%3csvg%20viewBox='0%200%2040%2040'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='40.000000'%20height='40.000000'%20fill='none'%20customFrame='url(%23clipPath_9)'%3e%3cdefs%3e%3cclipPath%20id='clipPath_9'%3e%3crect%20width='40.000000'%20height='40.000000'%20x='0.000000'%20y='0.000000'%20rx='12.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_10'%3e%3crect%20width='24.000000'%20height='24.000000'%20x='8.000000'%20y='8.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_11'%3e%3crect%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='10.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3c/defs%3e%3crect%20id='3'%20width='40.000000'%20height='40.000000'%20x='0.000000'%20y='0.000000'%20rx='12.000000'%20fill='rgb(236,250,254)'%20/%3e%3cg%20id='画板%202310'%20customFrame='url(%23clipPath_10)'%3e%3crect%20id='画板%202310'%20width='24.000000'%20height='24.000000'%20x='8.000000'%20y='8.000000'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20/%3e%3cg%20id='人事服务'%3e%3cg%20id='ic_public_link'%20clip-path='url(%23clipPath_11)'%20customFrame='url(%23clipPath_11)'%3e%3crect%20id='ic_public_link'%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='10.000000'%20/%3e%3cpath%20id='path1'%20d='M9.9999%2019.9917C9.9999%2018.4292%209.99573%2016.8667%209.9999%2015.3042C9.99573%2014.5459%2010.0916%2013.7917%2010.2749%2013.0626C10.6874%2011.5126%2011.6957%2010.5917%2013.2457%2010.2334C14.0207%2010.0667%2014.8166%209.98756%2015.6082%2010.0001C18.6041%2010.0001%2021.5999%2010.0001%2024.5999%2010.0001C25.3541%209.99589%2026.1082%2010.0792%2026.8457%2010.2584C28.4416%2010.6459%2029.3999%2011.6584%2029.7624%2013.2501C29.9291%2014.0001%2030.0041%2014.7667%2029.9957%2015.5376C29.9957%2018.5667%2029.9957%2021.5959%2029.9957%2024.6209C29.9999%2025.3709%2029.9166%2026.1209%2029.7416%2026.8459C29.3499%2028.4459%2028.3332%2029.3959%2026.7457%2029.7626C25.9666%2029.9292%2025.1749%2030.0084%2024.3791%2029.9959C21.3957%2029.9959%2018.4124%2029.9959%2015.4291%2029.9959C14.6666%2030.0042%2013.9082%2029.9167%2013.1666%2029.7417C11.5624%2029.3542%2010.5999%2028.3376%2010.2374%2026.7376C10.0499%2025.9251%209.9999%2025.1126%209.9999%2024.2917C9.9999%2022.8584%209.9999%2021.4251%209.9999%2019.9917Z'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20fill-rule='evenodd'%20/%3e%3ccircle%20id='path2'%20cx='20'%20cy='20'%20r='10'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20/%3e%3cpath%20id='path3'%20d='M25.0333%2021.8666L26.9%2020C28.8083%2018.0916%2028.8083%2015%2026.9%2013.0958C24.9958%2011.1875%2021.9041%2011.1875%2020%2013.0958L18.1291%2014.9625M21.8666%2025.0333L20%2026.9C18.0916%2028.8083%2015%2028.8083%2013.0958%2026.9C11.1875%2024.9958%2011.1875%2021.9041%2013.0958%2020L14.9625%2018.1291'%20fill-rule='nonzero'%20stroke='rgb(14,191,241)'%20stroke-linecap='round'%20stroke-width='1.25'%20/%3e%3cpath%20id='pah4'%20d='M18.125%2021.875L21.875%2018.125'%20stroke='rgb(14,191,241)'%20stroke-linecap='round'%20stroke-linejoin='round'%20stroke-width='1.25'%20/%3e%3cpath%20id='path5'%20d='M25.8207%2019.2626L24.0457%2021.0376C23.7998%2021.2834%2023.6748%2021.5292%2023.6748%2021.7751C23.6748%2022.0209%2023.7998%2022.2667%2024.0457%2022.5126C24.1498%2022.6167%2024.2665%2022.6959%2024.3915%2022.7459C24.5123%2022.7917%2024.6415%2022.8167%2024.779%2022.8167C24.9207%2022.8167%2025.0498%2022.7917%2025.1665%2022.7459C25.2957%2022.6959%2025.4123%2022.6167%2025.5165%2022.5126L27.2915%2020.7334C27.8165%2020.2126%2028.2165%2019.6334%2028.4957%2019.0001C28.5082%2018.9667%2028.5248%2018.9334%2028.5373%2018.8959C28.554%2018.8626%2028.5665%2018.8292%2028.579%2018.7917C28.8332%2018.1501%2028.9582%2017.4584%2028.9582%2016.7209C28.9582%2015.9792%2028.8332%2015.2876%2028.579%2014.6459C28.5665%2014.6084%2028.554%2014.5751%2028.5373%2014.5417C28.5248%2014.5042%2028.5082%2014.4709%2028.4957%2014.4376C28.2165%2013.8042%2027.8165%2013.2292%2027.2915%2012.7042C26.7707%2012.1792%2026.1915%2011.7792%2025.5582%2011.5001C25.5248%2011.4876%2025.4915%2011.4709%2025.454%2011.4584C25.4207%2011.4417%2025.3873%2011.4292%2025.354%2011.4167C24.7082%2011.1667%2024.0165%2011.0417%2023.279%2011.0417C22.5373%2011.0417%2021.8457%2011.1667%2021.204%2011.4167C21.1665%2011.4292%2021.1332%2011.4417%2021.0998%2011.4584C21.0623%2011.4709%2021.029%2011.4876%2020.9957%2011.5001C20.3623%2011.7792%2019.7832%2012.1792%2019.2623%2012.7042L17.4832%2014.4792C17.379%2014.5834%2017.2998%2014.7001%2017.2498%2014.8292C17.204%2014.9501%2017.179%2015.0751%2017.179%2015.2167C17.179%2015.3542%2017.204%2015.4834%2017.2498%2015.6042C17.2998%2015.7292%2017.379%2015.8459%2017.4832%2015.9542C17.5915%2016.0584%2017.7082%2016.1376%2017.8332%2016.1876C17.954%2016.2334%2018.0832%2016.2584%2018.2207%2016.2584C18.3623%2016.2584%2018.4915%2016.2334%2018.6082%2016.1876C18.7373%2016.1376%2018.854%2016.0584%2018.9582%2015.9542L20.7332%2014.1751C21.0873%2013.8209%2021.4748%2013.5584%2021.8957%2013.3834C22.3165%2013.2084%2022.779%2013.1251%2023.279%2013.1251C23.7748%2013.1251%2024.2373%2013.2084%2024.6582%2013.3834C25.079%2013.5584%2025.4665%2013.8209%2025.8207%2014.1751C26.1748%2014.5292%2026.4373%2014.9167%2026.6123%2015.3376C26.7873%2015.7584%2026.8748%2016.2167%2026.8748%2016.7209C26.8748%2017.2209%2026.7873%2017.6792%2026.6123%2018.1001C26.4373%2018.5209%2026.1748%2018.9084%2025.8207%2019.2626ZM13.3832%2021.8959C13.5582%2021.4751%2013.8207%2021.0876%2014.1748%2020.7334L15.954%2018.9584C16.0582%2018.8542%2016.1373%2018.7376%2016.1873%2018.6084C16.2332%2018.4876%2016.2582%2018.3626%2016.2582%2018.2209C16.2582%2018.0834%2016.2332%2017.9542%2016.1873%2017.8334C16.1373%2017.7084%2016.0582%2017.5917%2015.954%2017.4834C15.7082%2017.2417%2015.4623%2017.1167%2015.2165%2017.1167C14.9707%2017.1167%2014.7248%2017.2417%2014.479%2017.4834L12.704%2019.2626C12.179%2019.7876%2011.779%2020.3626%2011.4998%2020.9959C11.4873%2021.0292%2011.4707%2021.0626%2011.4582%2021.1001C11.4415%2021.1334%2011.429%2021.1667%2011.4165%2021.2042C11.1665%2021.8459%2011.0415%2022.5376%2011.0415%2023.2792C11.0415%2024.0167%2011.1665%2024.7084%2011.4165%2025.3542C11.429%2025.3876%2011.4415%2025.4209%2011.4582%2025.4584C11.4707%2025.4917%2011.4873%2025.5251%2011.4998%2025.5584C11.779%2026.1917%2012.179%2026.7709%2012.704%2027.2917C13.2248%2027.8167%2013.804%2028.2167%2014.4373%2028.4959C14.4707%2028.5084%2014.504%2028.5251%2014.5415%2028.5376C14.5748%2028.5542%2014.6082%2028.5667%2014.6457%2028.5792C15.2873%2028.8292%2015.979%2028.9584%2016.7207%2028.9584C17.4582%2028.9584%2018.1498%2028.8292%2018.7915%2028.5792C18.829%2028.5667%2018.8623%2028.5542%2018.8957%2028.5376C18.9332%2028.5251%2018.9665%2028.5084%2018.9998%2028.4959C19.6332%2028.2167%2020.2123%2027.8167%2020.7332%2027.2917L22.5123%2025.5167C22.6165%2025.4126%2022.6957%2025.2959%2022.7457%2025.1667C22.7915%2025.0459%2022.8165%2024.9209%2022.8165%2024.7792C22.8165%2024.6417%2022.7915%2024.5126%2022.7457%2024.3917C22.6957%2024.2667%2022.6165%2024.1501%2022.5123%2024.0417C22.2665%2023.8001%2022.0207%2023.6751%2021.7748%2023.6751C21.529%2023.6751%2021.2832%2023.8001%2021.0373%2024.0417L19.2623%2025.8209C18.9082%2026.1751%2018.5207%2026.4376%2018.0998%2026.6126C17.679%2026.7876%2017.2165%2026.8751%2016.7207%2026.8751C16.2207%2026.8751%2015.7582%2026.7876%2015.3373%2026.6126C14.9165%2026.4376%2014.529%2026.1751%2014.1748%2025.8209C13.8207%2025.4667%2013.5582%2025.0792%2013.3832%2024.6584C13.2082%2024.2376%2013.1248%2023.7792%2013.1248%2023.2792C13.1248%2022.7751%2013.2082%2022.3167%2013.3832%2021.8959Z'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20fill-rule='evenodd'%20/%3e%3cpath%20id='path6'%20d='M21.8127%2016.7458C21.746%2016.7874%2021.6877%2016.8374%2021.6293%2016.8916L16.8918%2021.6291C16.8377%2021.6874%2016.7877%2021.7499%2016.746%2021.8124C16.7127%2021.8624%2016.6877%2021.9166%2016.6627%2021.9749C16.6377%2022.0374%2016.6168%2022.1041%2016.6043%2022.1708C16.5918%2022.2333%2016.5835%2022.2999%2016.5835%2022.3666C16.5835%2022.4333%2016.5918%2022.4999%2016.6043%2022.5666C16.6168%2022.6333%2016.6377%2022.6999%2016.6627%2022.7624C16.6877%2022.8166%2016.7127%2022.8708%2016.746%2022.9208C16.7877%2022.9874%2016.8377%2023.0499%2016.8918%2023.1041C16.946%2023.1583%2017.0085%2023.2083%2017.0752%2023.2499C17.1252%2023.2833%2017.1793%2023.3083%2017.2335%2023.3333C17.3002%2023.3583%2017.3627%2023.3791%2017.4293%2023.3916C17.496%2023.4041%2017.5627%2023.4124%2017.6293%2023.4124C17.696%2023.4124%2017.7627%2023.4041%2017.8252%2023.3916C17.8918%2023.3791%2017.9585%2023.3583%2018.021%2023.3333C18.0793%2023.3083%2018.1335%2023.2833%2018.1835%2023.2499C18.246%2023.2083%2018.3085%2023.1583%2018.3668%2023.1041L23.1043%2018.3666C23.1585%2018.3083%2023.2085%2018.2499%2023.2502%2018.1833C23.2835%2018.1333%2023.3085%2018.0791%2023.3335%2018.0208C23.3585%2017.9583%2023.3793%2017.8916%2023.3918%2017.8249C23.4043%2017.7624%2023.4127%2017.6958%2023.4127%2017.6291C23.4127%2017.5624%2023.4043%2017.4958%2023.3918%2017.4291C23.3793%2017.3624%2023.3585%2017.2999%2023.3335%2017.2333C23.3085%2017.1791%2023.2835%2017.1249%2023.2502%2017.0749C23.2085%2017.0083%2023.1585%2016.9458%2023.1043%2016.8916C23.046%2016.8374%2022.9877%2016.7874%2022.921%2016.7458C22.871%2016.7124%2022.8168%2016.6874%2022.7627%2016.6624C22.696%2016.6374%2022.6335%2016.6166%2022.5668%2016.6041C22.5002%2016.5916%2022.4335%2016.5833%2022.3668%2016.5833C22.3002%2016.5833%2022.2335%2016.5916%2022.171%2016.6041C22.1043%2016.6166%2022.0377%2016.6374%2021.9752%2016.6624C21.9168%2016.6874%2021.8627%2016.7124%2021.8127%2016.7458Z'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20fill-rule='evenodd'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e", Ue = "data:image/svg+xml,%3csvg%20viewBox='0%200%2040%2040'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='40.000000'%20height='40.000000'%20fill='none'%20customFrame='url(%23clipPath_0)'%3e%3cdefs%3e%3cclipPath%20id='clipPath_0'%3e%3crect%20width='40.000000'%20height='40.000000'%20x='0.000000'%20y='0.000000'%20rx='12.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_1'%3e%3crect%20width='24.000000'%20height='24.000000'%20x='8.000000'%20y='8.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3cclipPath%20id='clipPath_2'%3e%3crect%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='10.000000'%20fill='rgb(255,255,255)'%20/%3e%3c/clipPath%3e%3c/defs%3e%3crect%20id='1'%20width='40.000000'%20height='40.000000'%20x='0.000000'%20y='0.000000'%20rx='12.000000'%20fill='rgb(236,250,254)'%20/%3e%3cg%20id='车辆'%20clip-path='url(%23clipPath_1)'%20customFrame='url(%23clipPath_1)'%3e%3crect%20id='车辆'%20width='24.000000'%20height='24.000000'%20x='8.000000'%20y='8.000000'%20/%3e%3cg%20id='编组'%3e%3cg%20id='ic_public_qrcode'%20clip-path='url(%23clipPath_2)'%20customFrame='url(%23clipPath_2)'%3e%3crect%20id='ic_public_qrcode'%20width='20.000000'%20height='20.000000'%20x='10.000000'%20y='10.000000'%20/%3e%3cg%20id='ic_public_qrcode_1_1'%3e%3cpath%20id='ic_public_qrcode_2_0'%20d='M10.6273%2019.9924C10.6273%2018.5277%2010.6222%2017.0631%2010.6273%2015.5985C10.6243%2014.8898%2010.7114%2014.1836%2010.8865%2013.4968C11.2702%2012.0432%2012.2171%2011.1805%2013.6693%2010.8458C14.3974%2010.6885%2015.1411%2010.6148%2015.886%2010.6261C18.6946%2010.6261%2021.5035%2010.6261%2024.3127%2010.6261C25.0221%2010.6217%2025.7295%2010.7029%2026.4195%2010.8678C27.9156%2011.2339%2028.8134%2012.1816%2029.1554%2013.6725C29.3092%2014.3772%2029.3826%2015.097%2029.3744%2015.8182C29.3744%2018.6571%2029.3744%2021.4963%2029.3744%2024.3357C29.3782%2025.0383%2029.2973%2025.7388%2029.1334%2026.422C28.7673%2027.9189%2027.8153%2028.8123%2026.3243%2029.1543C25.5961%2029.311%2024.8524%2029.3847%2024.1076%2029.374C21.3107%2029.374%2018.514%2029.374%2015.7176%2029.374C15.0027%2029.3798%2014.2897%2029.2999%2013.5939%2029.136C12.0912%2028.7698%2011.189%2027.8178%2010.8477%2026.3195C10.6734%2025.5579%2010.6273%2024.7941%2010.6273%2024.0237C10.6273%2022.6802%2010.6273%2021.3364%2010.6273%2019.9924Z'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20fill-rule='nonzero'%20/%3e%3cpath%20id='ic_public_qrcode_2_0'%20d='M10.6273%2015.5985C10.6243%2014.8898%2010.7114%2014.1836%2010.8865%2013.4968C11.2702%2012.0432%2012.2171%2011.1805%2013.6693%2010.8458C14.3974%2010.6885%2015.1411%2010.6148%2015.886%2010.6261C18.6946%2010.6261%2021.5035%2010.6261%2024.3127%2010.6261C25.0221%2010.6217%2025.7295%2010.7029%2026.4195%2010.8678C27.9156%2011.2339%2028.8134%2012.1816%2029.1554%2013.6725C29.3092%2014.3772%2029.3826%2015.097%2029.3744%2015.8182C29.3744%2018.6571%2029.3744%2021.4963%2029.3744%2024.3357C29.3782%2025.0383%2029.2973%2025.7388%2029.1334%2026.422C28.7673%2027.9189%2027.8153%2028.8123%2026.3243%2029.1543C25.5961%2029.311%2024.8524%2029.3847%2024.1076%2029.374C21.3107%2029.374%2018.514%2029.374%2015.7176%2029.374C15.0027%2029.3798%2014.2897%2029.2999%2013.5939%2029.136C12.0912%2028.7698%2011.189%2027.8178%2010.8477%2026.3195C10.6734%2025.5579%2010.6273%2024.7941%2010.6273%2024.0237C10.6273%2022.6802%2010.6273%2021.3364%2010.6273%2019.9924C10.6273%2018.5277%2010.6222%2017.0631%2010.6273%2015.5985Z'%20fill-rule='nonzero'%20stroke='rgb(255,255,255)'%20stroke-opacity='0'%20stroke-width='1.25'%20/%3e%3cpath%20id='ic_public_qrcode_2_1'%20d='M10.6273%2015.5985C10.6243%2014.8898%2010.7114%2014.1836%2010.8865%2013.4968C11.2702%2012.0432%2012.2171%2011.1805%2013.6693%2010.8458C14.3974%2010.6885%2015.1411%2010.6148%2015.886%2010.6261C18.6946%2010.6261%2021.5035%2010.6261%2024.3127%2010.6261C25.0221%2010.6217%2025.7295%2010.7029%2026.4195%2010.8678C27.9156%2011.2339%2028.8134%2012.1816%2029.1554%2013.6725C29.3092%2014.3772%2029.3826%2015.097%2029.3744%2015.8182C29.3744%2018.6571%2029.3744%2021.4963%2029.3744%2024.3357C29.3782%2025.0383%2029.2973%2025.7388%2029.1334%2026.422C28.7673%2027.9189%2027.8153%2028.8123%2026.3243%2029.1543C25.5961%2029.311%2024.8524%2029.3847%2024.1076%2029.374C21.3107%2029.374%2018.514%2029.374%2015.7176%2029.374C15.0027%2029.3798%2014.2897%2029.2999%2013.5939%2029.136C12.0912%2028.7698%2011.189%2027.8178%2010.8477%2026.3195C10.6734%2025.5579%2010.6273%2024.7941%2010.6273%2024.0237C10.6273%2022.6802%2010.6273%2021.3364%2010.6273%2019.9924C10.6273%2018.5277%2010.6222%2017.0631%2010.6273%2015.5985Z'%20opacity='0.200000003'%20fill-rule='nonzero'%20stroke='rgb(255,255,255)'%20stroke-opacity='0'%20stroke-width='1.25'%20/%3e%3ccircle%20id='ic_public_qrcode_2_2'%20cx='20'%20cy='20'%20r='10'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20/%3e%3cpath%20id='ic_public_qrcode_2_3'%20d='M17.5%2011.25C17.9602%2011.25%2018.3333%2011.6231%2018.3333%2012.0833L18.3333%2017.5C18.3333%2017.9602%2017.9602%2018.3333%2017.5%2018.3333L12.0833%2018.3333C11.6231%2018.3333%2011.25%2017.9602%2011.25%2017.5L11.25%2012.0833C11.25%2011.6231%2011.6231%2011.25%2012.0833%2011.25L17.5%2011.25ZM17.5%2021.6667C17.9602%2021.6667%2018.3333%2022.0398%2018.3333%2022.5L18.3333%2027.9167C18.3333%2028.3769%2017.9602%2028.75%2017.5%2028.75L12.0833%2028.75C11.6231%2028.75%2011.25%2028.3769%2011.25%2027.9167L11.25%2022.5C11.25%2022.0398%2011.6231%2021.6667%2012.0833%2021.6667L17.5%2021.6667ZM27.9167%2011.25C28.3769%2011.25%2028.75%2011.6231%2028.75%2012.0833L28.75%2017.5C28.75%2017.9602%2028.3769%2018.3333%2027.9167%2018.3333L22.5%2018.3333C22.0398%2018.3333%2021.6667%2017.9602%2021.6667%2017.5L21.6667%2012.0833C21.6667%2011.6231%2022.0398%2011.25%2022.5%2011.25L27.9167%2011.25Z'%20fill-rule='evenodd'%20stroke='rgb(14,191,241)'%20stroke-linecap='round'%20stroke-linejoin='round'%20stroke-width='1.25'%20/%3e%3cpath%20id='ic_public_qrcode_2_4'%20d='M17.5002%2010.8333C18.1905%2010.8333%2018.7502%2011.3929%2018.7502%2012.0833L18.7502%2017.4999C18.7502%2018.1903%2018.1905%2018.7499%2017.5002%2018.7499L12.0835%2018.7499C11.3931%2018.7499%2010.8335%2018.1903%2010.8335%2017.4999L10.8335%2012.0833C10.8335%2011.3929%2011.3931%2010.8333%2012.0835%2010.8333L17.5002%2010.8333ZM17.5002%2011.6666L12.0835%2011.6666C11.8534%2011.6666%2011.6668%2011.8531%2011.6668%2012.0833L11.6668%2017.4999C11.6668%2017.73%2011.8534%2017.9166%2012.0835%2017.9166L17.5002%2017.9166C17.7303%2017.9166%2017.9168%2017.73%2017.9168%2017.4999L17.9168%2012.0833C17.9168%2011.8531%2017.7303%2011.6666%2017.5002%2011.6666ZM17.5002%2021.2499C18.1905%2021.2499%2018.7502%2021.8096%2018.7502%2022.4999L18.7502%2027.9166C18.7502%2028.6069%2018.1905%2029.1666%2017.5002%2029.1666L12.0835%2029.1666C11.3931%2029.1666%2010.8335%2028.6069%2010.8335%2027.9166L10.8335%2022.4999C10.8335%2021.8096%2011.3931%2021.2499%2012.0835%2021.2499L17.5002%2021.2499ZM17.5002%2022.0833L12.0835%2022.0833C11.8534%2022.0833%2011.6668%2022.2698%2011.6668%2022.4999L11.6668%2027.9166C11.6668%2028.1467%2011.8534%2028.3333%2012.0835%2028.3333L17.5002%2028.3333C17.7303%2028.3333%2017.9168%2028.1467%2017.9168%2027.9166L17.9168%2022.4999C17.9168%2022.2698%2017.7303%2022.0833%2017.5002%2022.0833ZM27.9168%2010.8333C28.6072%2010.8333%2029.1668%2011.3929%2029.1668%2012.0833L29.1668%2017.4999C29.1668%2018.1903%2028.6072%2018.7499%2027.9168%2018.7499L22.5002%2018.7499C21.8098%2018.7499%2021.2502%2018.1903%2021.2502%2017.4999L21.2502%2012.0833C21.2502%2011.3929%2021.8098%2010.8333%2022.5002%2010.8333L27.9168%2010.8333ZM27.9168%2011.6666L22.5002%2011.6666C22.27%2011.6666%2022.0835%2011.8531%2022.0835%2012.0833L22.0835%2017.4999C22.0835%2017.73%2022.27%2017.9166%2022.5002%2017.9166L27.9168%2017.9166C28.1469%2017.9166%2028.3335%2017.73%2028.3335%2017.4999L28.3335%2012.0833C28.3335%2011.8531%2028.1469%2011.6666%2027.9168%2011.6666Z'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20fill-rule='nonzero'%20/%3e%3cpath%20id='ic_public_qrcode_2_4'%20d='M18.7502%2012.0833L18.7502%2017.4999C18.7502%2018.1903%2018.1905%2018.7499%2017.5002%2018.7499L12.0835%2018.7499C11.3931%2018.7499%2010.8335%2018.1903%2010.8335%2017.4999L10.8335%2012.0833C10.8335%2011.3929%2011.3931%2010.8333%2012.0835%2010.8333L17.5002%2010.8333C18.1905%2010.8333%2018.7502%2011.3929%2018.7502%2012.0833ZM12.0835%2011.6666C11.8534%2011.6666%2011.6668%2011.8531%2011.6668%2012.0833L11.6668%2017.4999C11.6668%2017.73%2011.8534%2017.9166%2012.0835%2017.9166L17.5002%2017.9166C17.7303%2017.9166%2017.9168%2017.73%2017.9168%2017.4999L17.9168%2012.0833C17.9168%2011.8531%2017.7303%2011.6666%2017.5002%2011.6666L12.0835%2011.6666ZM18.7502%2022.4999L18.7502%2027.9166C18.7502%2028.6069%2018.1905%2029.1666%2017.5002%2029.1666L12.0835%2029.1666C11.3931%2029.1666%2010.8335%2028.6069%2010.8335%2027.9166L10.8335%2022.4999C10.8335%2021.8096%2011.3931%2021.2499%2012.0835%2021.2499L17.5002%2021.2499C18.1905%2021.2499%2018.7502%2021.8096%2018.7502%2022.4999ZM12.0835%2022.0833C11.8534%2022.0833%2011.6668%2022.2698%2011.6668%2022.4999L11.6668%2027.9166C11.6668%2028.1467%2011.8534%2028.3333%2012.0835%2028.3333L17.5002%2028.3333C17.7303%2028.3333%2017.9168%2028.1467%2017.9168%2027.9166L17.9168%2022.4999C17.9168%2022.2698%2017.7303%2022.0833%2017.5002%2022.0833L12.0835%2022.0833ZM29.1668%2012.0833L29.1668%2017.4999C29.1668%2018.1903%2028.6072%2018.7499%2027.9168%2018.7499L22.5002%2018.7499C21.8098%2018.7499%2021.2502%2018.1903%2021.2502%2017.4999L21.2502%2012.0833C21.2502%2011.3929%2021.8098%2010.8333%2022.5002%2010.8333L27.9168%2010.8333C28.6072%2010.8333%2029.1668%2011.3929%2029.1668%2012.0833ZM22.5002%2011.6666C22.27%2011.6666%2022.0835%2011.8531%2022.0835%2012.0833L22.0835%2017.4999C22.0835%2017.73%2022.27%2017.9166%2022.5002%2017.9166L27.9168%2017.9166C28.1469%2017.9166%2028.3335%2017.73%2028.3335%2017.4999L28.3335%2012.0833C28.3335%2011.8531%2028.1469%2011.6666%2027.9168%2011.6666L22.5002%2011.6666Z'%20fill-rule='nonzero'%20stroke='rgb(255,255,255)'%20stroke-opacity='0'%20stroke-linejoin='round'%20stroke-width='1.25'%20/%3e%3cpath%20id='ic_public_qrcode_2_5'%20d='M27.9165%2021.6667L27.9165%2024.5834L28.7498%2024.5834L28.7498%2021.6667L27.9165%2021.6667ZM24.5832%2021.6667L24.5832%2022.639L24.5828%2022.6388L24.5832%2024.5834L23.6109%2024.5834L23.6107%2022.6388L21.6665%2022.639L21.6665%2021.6667L24.5832%2021.6667ZM21.6665%2025.8334L21.6665%2028.7501L22.4998%2028.7501L22.4998%2025.8334L21.6665%2025.8334ZM27.9165%2027.9167L27.9165%2028.7501L28.7498%2028.7501L28.7498%2027.9167L27.9165%2027.9167ZM25.8332%2025.8334L25.8332%2026.6667L26.6665%2026.6667L26.6665%2025.8334L25.8332%2025.8334Z'%20fill='rgb(14,191,241)'%20fill-rule='nonzero'%20/%3e%3cpath%20id='ic_public_qrcode_2_5'%20d='M27.9165%2024.5834L28.7498%2024.5834L28.7498%2021.6667L27.9165%2021.6667L27.9165%2024.5834ZM24.5832%2022.639L24.5828%2022.6388L24.5832%2024.5834L23.6109%2024.5834L23.6107%2022.6388L21.6665%2022.639L21.6665%2021.6667L24.5832%2021.6667L24.5832%2022.639ZM21.6665%2028.7501L22.4998%2028.7501L22.4998%2025.8334L21.6665%2025.8334L21.6665%2028.7501ZM27.9165%2028.7501L28.7498%2028.7501L28.7498%2027.9167L27.9165%2027.9167L27.9165%2028.7501ZM25.8332%2026.6667L26.6665%2026.6667L26.6665%2025.8334L25.8332%2025.8334L25.8332%2026.6667Z'%20fill-rule='nonzero'%20stroke='rgb(14,191,241)'%20stroke-linejoin='round'%20stroke-width='1.25'%20/%3e%3cpath%20id='ic_public_qrcode_2_6'%20d='M14.375%2014.375L14.375%2015.2083L15.2083%2015.2083L15.2083%2014.375L14.375%2014.375ZM14.375%2024.7917L14.375%2025.625L15.2083%2025.625L15.2083%2024.7917L14.375%2024.7917ZM24.7917%2014.375L24.7917%2015.2083L25.625%2015.2083L25.625%2014.375L24.7917%2014.375Z'%20fill='rgb(14,191,241)'%20fill-rule='nonzero'%20/%3e%3cpath%20id='ic_public_qrcode_2_6'%20d='M14.375%2015.2083L15.2083%2015.2083L15.2083%2014.375L14.375%2014.375L14.375%2015.2083ZM14.375%2025.625L15.2083%2025.625L15.2083%2024.7917L14.375%2024.7917L14.375%2025.625ZM24.7917%2015.2083L25.625%2015.2083L25.625%2014.375L24.7917%2014.375L24.7917%2015.2083Z'%20fill-rule='nonzero'%20stroke='rgb(14,191,241)'%20stroke-linejoin='round'%20stroke-width='1.25'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e", Ae = "data:image/svg+xml,%3csvg%20viewBox='0%200%2012%2012'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20width='12.000000'%20height='12.000000'%20fill='none'%3e%3cdefs%3e%3cfilter%20id='pixso_custom_mask_type_luminance'%3e%3cfeColorMatrix%20type='matrix'%20values='1%200%200%200%200%200%201%200%200%200%200%200%201%200%200%200%200%200%201%200%20'%20/%3e%3c/filter%3e%3c/defs%3e%3cmask%20id='mask_0'%20width='11.999876'%20height='11.999876'%20x='0.000000'%20y='0.000000'%20maskUnits='userSpaceOnUse'%3e%3cg%20filter='url(%23pixso_custom_mask_type_luminance)'%3e%3cg%20id='mask401_19830'%3e%3cpath%20id='蒙版'%20d='M0%200L11.9999%200L11.9999%2011.9999L0%2011.9999L0%200ZM2.69992%201.34999L8.09977%201.34999C9.5082%201.34999%2010.6498%202.49167%2010.6498%203.89998L10.6498%209.2999C10.6498%2010.7082%209.5082%2011.8499%208.09977%2011.8499L2.69992%2011.8499C1.29149%2011.8499%200.149901%2010.7082%200.149901%209.2999L0.149901%203.89998C0.149901%202.49167%201.29149%201.34999%202.69992%201.34999Z'%20fill='rgb(196,196,196)'%20fill-rule='evenodd'%20/%3e%3c/g%3e%3c/g%3e%3c/mask%3e%3crect%20id='ic_public_copy'%20width='12.000000'%20height='12.000000'%20x='0.000000'%20y='0.000000'%20/%3e%3crect%20id='ic_public_copy-复制/base/ic_public_copy'%20width='11.999876'%20height='11.999876'%20x='0.000000'%20y='0.000000'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20/%3e%3cpath%20id='path1'%20d='M0.000134537%205.99497C0.000134537%205.05748%20-0.00236544%204.11999%200.000134537%203.1825C-0.00236544%202.72751%200.055134%202.27501%200.165133%201.83752C0.41263%200.907526%201.01762%200.355032%201.94761%200.140034C2.41261%200.040035%202.8901%20-0.00746449%203.3651%203.54269e-05C5.16258%203.54269e-05%206.96006%203.54269e-05%208.76004%203.54269e-05C9.21254%20-0.00246455%209.66503%200.0475349%2010.1075%200.155034C11.065%200.387531%2011.64%200.995025%2011.8575%201.95002C11.9575%202.40001%2012.005%202.86001%2011.9975%203.3225C11.9975%205.13998%2011.9975%206.95746%2011.9975%208.77244C12%209.22244%2011.95%209.67243%2011.845%2010.1099C11.61%2011.0674%2011%2011.6374%2010.0475%2011.8574C9.58003%2011.9574%209.10504%2012.0049%208.62754%2011.9974C6.83756%2011.9974%205.04758%2011.9974%203.2576%2011.9974C2.80011%2012.0024%202.34511%2011.9499%201.90011%2011.8449C0.937625%2011.6124%200.360131%2011.0024%200.142633%2010.0424C0.0301342%209.55494%200.000134537%209.06744%200.000134537%208.57495C0.000134537%207.71495%200.000134537%206.85496%200.000134537%205.99497Z'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20fill-rule='evenodd'%20/%3e%3ccircle%20id='path2'%20cx='5.99993801'%20cy='5.99993801'%20r='5.99993801'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20/%3e%3cg%20id='mask'%20mask='url(%23mask_0)'%3e%3cg%20id='组合%208'%3e%3cpath%20id='path'%20d='M11.1%203.89993L11.1%206.8999C11.1%208.55488%209.75502%209.89737%208.10004%209.89737L5.10007%209.89737C3.44258%209.89737%202.1001%208.55488%202.1001%206.8999L2.1001%203.89993C2.1001%202.24245%203.44258%200.897461%205.10007%200.897461L8.10004%200.897461C9.75502%200.897461%2011.1%202.24245%2011.1%203.89993Z'%20fill-rule='nonzero'%20stroke='rgb(25,25,25)'%20stroke-linejoin='round'%20stroke-width='0.749992251'%20/%3e%3c/g%3e%3c/g%3e%3cpath%20id='path4'%20d='M2.10008%202.39746L8.10002%202.39746C8.92751%202.39746%209.6%203.06995%209.6%203.89995L9.6%209.89738C9.6%2010.7274%208.92751%2011.3999%208.10002%2011.3999L2.10008%2011.3999C1.27009%2011.3999%200.600098%2010.7274%200.600098%209.89738L0.600098%203.89995C0.600098%203.06995%201.27009%202.39746%202.10008%202.39746Z'%20fill='rgb(255,255,255)'%20fill-opacity='0'%20fill-rule='evenodd'%20/%3e%3cpath%20id='path4'%20d='M9.6%203.89995L9.6%209.89738C9.6%2010.7274%208.92751%2011.3999%208.10002%2011.3999L2.10008%2011.3999C1.27009%2011.3999%200.600098%2010.7274%200.600098%209.89738L0.600098%203.89995C0.600098%203.06995%201.27009%202.39746%202.10008%202.39746L8.10002%202.39746C8.92751%202.39746%209.6%203.06995%209.6%203.89995Z'%20fill-rule='nonzero'%20stroke='rgb(25,25,25)'%20stroke-linejoin='round'%20stroke-width='0.749992251'%20/%3e%3c/svg%3e", Oe = "https://agent.opentiny.design/tiny-robot", v2 = "https://ai.opentiny.design/next-remoter", _2 = (r) => [
903
+ {
904
+ action: "qr-code",
905
+ show: !0,
906
+ text: "扫码登录",
907
+ desc: "使用手机遥控页面",
908
+ icon: Ue
909
+ },
910
+ {
911
+ action: "ai-chat",
912
+ show: !0,
913
+ text: "打开对话框",
914
+ desc: "支持在网页端操作AI",
915
+ icon: Pe
916
+ },
917
+ {
918
+ action: "remote-url",
919
+ show: !0,
920
+ text: "遥控器链接",
921
+ desc: `${r.remoteUrl}`,
922
+ active: !0,
923
+ tip: r.remoteUrl,
924
+ showCopyIcon: !0,
925
+ icon: Ie
926
+ },
927
+ {
928
+ action: "remote-control",
929
+ show: !0,
930
+ text: "识别码",
931
+ desc: `${r.sessionId.slice(-6)}`,
932
+ know: !0,
933
+ showCopyIcon: !0,
934
+ icon: ke
935
+ }
936
+ ];
937
+ class $e {
938
+ constructor(e) {
939
+ if (this.isExpanded = !1, this.getImageUrl = (t) => {
940
+ if (!t) return;
941
+ const s = new Image();
942
+ return s.src = t, s;
943
+ }, this.renderItem = () => {
944
+ this.menuItems.filter((t) => t.show !== !1).map(
945
+ (t) => {
946
+ const s = document.getElementById(`tiny-remoter-icon-item-${t.action}`);
947
+ if (!s) return;
948
+ s.innerHTML = "";
949
+ const i = this.getImageUrl(t.icon);
950
+ i && s.appendChild(i);
951
+ }
952
+ );
953
+ }, this.readyTips = (t) => {
954
+ const s = document.getElementById(t);
955
+ s && new Ee(s, {
956
+ content: "复制",
957
+ placement: "top",
958
+ trigger: "hover"
959
+ });
960
+ }, !e.sessionId)
961
+ throw new Error("sessionId is required");
962
+ this.options = {
963
+ ...e,
964
+ qrCodeUrl: e.qrCodeUrl || v2,
965
+ remoteUrl: e.remoteUrl || Oe
966
+ }, this.menuItems = this.mergeMenuItems(e.menuItems), this.init();
967
+ }
968
+ // 计算 sessionPrefix 属性
969
+ get sessionPrefix() {
970
+ return this.options.qrCodeUrl?.includes("?") ? "&sessionId=" : "?sessionId=";
971
+ }
972
+ /**
973
+ * 合并菜单项配置
974
+ * @param userMenuItems 用户自定义菜单项配置
975
+ * @returns 合并后的菜单项配置
976
+ */
977
+ mergeMenuItems(e) {
978
+ return e ? _2(this.options).map((t) => {
979
+ const s = e.find((i) => i.action === t.action);
980
+ return s ? {
981
+ ...t,
982
+ ...s,
983
+ // 确保show属性存在,默认为true
984
+ show: s.show !== void 0 ? s.show : t.show
985
+ } : t;
986
+ }) : _2(this.options);
987
+ }
988
+ init() {
989
+ this.createFloatingBlock(), this.createDropdownMenu(), this.bindEvents(), this.addStyles();
990
+ }
991
+ // 创建主浮动块
992
+ createFloatingBlock() {
993
+ this.floatingBlock = document.createElement("div"), this.floatingBlock.className = "tiny-remoter-floating-block", this.floatingBlock.innerHTML = `
994
+ <div class="tiny-remoter-floating-block__icon">
995
+ <img style="display: block; width: 56px;" src="${v2}/svgs/logo-next-no-bg-left.svg" alt="icon" />
996
+ </div>
997
+ `, document.body.appendChild(this.floatingBlock);
998
+ }
999
+ // 创建下拉菜单
1000
+ createDropdownMenu() {
1001
+ this.dropdownMenu = document.createElement("div"), this.dropdownMenu.className = "tiny-remoter-floating-dropdown";
1002
+ const e = this.menuItems.filter((t) => t.show !== !1).map(
1003
+ (t) => `
1004
+ <div class="tiny-remoter-dropdown-item" data-action="${t.action}">
1005
+ <div id="tiny-remoter-icon-item-${t.action}" class="tiny-remoter-dropdown-item__icon">
1006
+ </div>
1007
+ <div class="tiny-remoter-dropdown-item__content">
1008
+ <div title="${t.tip}">${t.text}</div>
1009
+ <div class="tiny-remoter-dropdown-item__desc-wrapper">
1010
+ <div class="tiny-remoter-dropdown-item__desc ${t.active ? "tiny-remoter-dropdown-item__desc--active" : ""} ${t.know ? "tiny-remoter-dropdown-item__desc--know" : ""}">${t.desc}</div>
1011
+ <div>
1012
+ ${t.showCopyIcon ? `
1013
+ <div class="tiny-remoter-copy-icon" id="${t.action}" data-action="${t.action}">
1014
+ <img src="${Ae}"/>
1015
+ </div>
1016
+ ` : ""}
1017
+ </div>
1018
+ </div>
1019
+ </div>
1020
+ </div>
1021
+ `
1022
+ ).join("");
1023
+ this.dropdownMenu.innerHTML = e, document.body.appendChild(this.dropdownMenu), this.renderItem(), this.readyTips("remote-control"), this.readyTips("remote-url");
1024
+ }
1025
+ bindEvents() {
1026
+ this.floatingBlock.addEventListener("click", () => {
1027
+ this.toggleDropdown();
1028
+ }), this.dropdownMenu.addEventListener("click", (e) => {
1029
+ const t = e.target, s = t.closest(".tiny-remoter-copy-icon");
1030
+ if (s) {
1031
+ e.stopPropagation();
1032
+ const a = s.dataset.action;
1033
+ a && this.handleAction(a);
1034
+ return;
1035
+ }
1036
+ const n = t.closest(".tiny-remoter-dropdown-item")?.dataset.action;
1037
+ n && this.handleAction(n);
1038
+ }), document.addEventListener("click", (e) => {
1039
+ const t = e.target;
1040
+ !this.floatingBlock.contains(t) && !this.dropdownMenu.contains(t) && this.closeDropdown();
1041
+ }), document.addEventListener("keydown", (e) => {
1042
+ e.key === "Escape" && this.closeDropdown();
1043
+ });
1044
+ }
1045
+ toggleDropdown() {
1046
+ this.isExpanded ? this.closeDropdown() : this.openDropdown();
1047
+ }
1048
+ openDropdown() {
1049
+ this.isExpanded = !0, this.floatingBlock.classList.add("expanded"), this.dropdownMenu.classList.add("show");
1050
+ }
1051
+ closeDropdown() {
1052
+ this.isExpanded = !1, this.floatingBlock.classList.remove("expanded"), this.dropdownMenu.classList.remove("show");
1053
+ }
1054
+ handleAction(e) {
1055
+ switch (e) {
1056
+ case "qr-code":
1057
+ this.showQRCode();
1058
+ break;
1059
+ case "ai-chat":
1060
+ this.showAIChat();
1061
+ break;
1062
+ case "remote-control":
1063
+ this.copyRemoteControl();
1064
+ break;
1065
+ case "remote-url":
1066
+ this.copyRemoteURL();
1067
+ break;
1068
+ }
1069
+ this.closeDropdown();
1070
+ }
1071
+ copyRemoteControl() {
1072
+ this.copyToClipboard(this.options.sessionId.slice(-6));
1073
+ }
1074
+ copyRemoteURL() {
1075
+ this.copyToClipboard(this.options.remoteUrl + this.sessionPrefix + this.options.sessionId);
1076
+ }
1077
+ // 实现复制到剪贴板功能
1078
+ async copyToClipboard(e) {
1079
+ try {
1080
+ if (navigator.clipboard && window.isSecureContext)
1081
+ await navigator.clipboard.writeText(e), this.showCopyFeedback(!0);
1082
+ else {
1083
+ const t = document.createElement("textarea");
1084
+ t.value = e, t.style.position = "fixed", t.style.left = "-999999px", t.style.top = "-999999px", document.body.appendChild(t), t.focus(), t.select();
1085
+ const s = document.execCommand("copy");
1086
+ document.body.removeChild(t), s ? this.showCopyFeedback(!0) : this.showCopyFeedback(!1);
1087
+ }
1088
+ } catch (t) {
1089
+ console.error("复制失败:", t), this.showCopyFeedback(!1);
1090
+ }
1091
+ }
1092
+ // 显示复制反馈提示
1093
+ showCopyFeedback(e) {
1094
+ const t = e ? "复制成功!" : "复制失败,请手动复制", s = document.createElement("div");
1095
+ s.className = `tiny-remoter-copy-feedback ${e ? "success" : "error"}`, s.textContent = t, document.body.appendChild(s), setTimeout(() => s.classList.add("show"), 10), setTimeout(() => {
1096
+ s.classList.remove("show"), setTimeout(() => {
1097
+ s.parentNode && s.parentNode.removeChild(s);
1098
+ }, 300);
1099
+ }, 1500);
1100
+ }
1101
+ // 创建二维码弹窗
1102
+ async showQRCode() {
1103
+ const t = await new Te((this.options.qrCodeUrl || "") + this.sessionPrefix + this.options.sessionId, {}).toDataURL(), s = this.createModal(
1104
+ "扫码前往智能遥控器",
1105
+ `
1106
+ <div style="text-align: center; padding: 32px;">
1107
+ <!-- 二维码容器 - 添加渐变背景和阴影效果 -->
1108
+ <div style="
1109
+ width: 240px;
1110
+ height: 240px;
1111
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
1112
+ margin: 0 auto 24px;
1113
+ display: flex;
1114
+ align-items: center;
1115
+ justify-content: center;
1116
+ border-radius: 20px;
1117
+ box-shadow: 0 20px 40px rgba(102, 126, 234, 0.3);
1118
+ position: relative;
1119
+ overflow: hidden;
1120
+ ">
1121
+ <!-- 装饰性背景元素 -->
1122
+ <div style="
1123
+ position: absolute;
1124
+ top: -50%;
1125
+ left: -50%;
1126
+ width: 200%;
1127
+ height: 200%;
1128
+ background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
1129
+ animation: rotate 20s linear infinite;
1130
+ "></div>
1131
+
1132
+ <!-- 二维码图片容器 -->
1133
+ <div style="
1134
+ width: 200px;
1135
+ height: 200px;
1136
+ background: white;
1137
+ border-radius: 16px;
1138
+ padding: 16px;
1139
+ box-shadow: 0 8px 32px rgba(0,0,0,0.1);
1140
+ position: relative;
1141
+ z-index: 1;
1142
+ ">
1143
+ <img src="${t}" alt="二维码" style="
1144
+ width: 100%;
1145
+ height: 100%;
1146
+ object-fit: contain;
1147
+ border-radius: 8px;
1148
+ ">
1149
+ </div>
1150
+ </div>
1151
+
1152
+ <!-- 标题文字 -->
1153
+ <h3 style="
1154
+ color: #333;
1155
+ margin: 0 0 12px 0;
1156
+ font-size: 20px;
1157
+ font-weight: 600;
1158
+ letter-spacing: 0.5px;
1159
+ ">扫描二维码</h3>
1160
+
1161
+ <!-- 描述文字 -->
1162
+ <p style="
1163
+ color: #666;
1164
+ margin: 0 auto;
1165
+ margin-bottom: 20px;
1166
+ font-size: 14px;
1167
+ line-height: 1.6;
1168
+ max-width: 280px;
1169
+ ">请使用手机微信或者浏览器扫描二维码跳转到智能遥控器</p>
1170
+
1171
+ <!-- 提示图标和文字 -->
1172
+ <div style="
1173
+ display: flex;
1174
+ align-items: center;
1175
+ justify-content: center;
1176
+ gap: 8px;
1177
+ color: #999;
1178
+ font-size: 12px;
1179
+ ">
1180
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" style="opacity: 0.7;">
1181
+ <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" fill="currentColor"/>
1182
+ </svg>
1183
+ <span>支持微信、浏览器等多种方式</span>
1184
+ </div>
1185
+ </div>
1186
+ `
1187
+ );
1188
+ this.showModal(s);
1189
+ }
1190
+ // 创建AI对话弹窗--- 暂时调 “用户函数”
1191
+ showAIChat() {
1192
+ this.options.onShowAIChat?.();
1193
+ }
1194
+ createModal(e, t) {
1195
+ const s = document.createElement("div");
1196
+ s.className = "tiny-remoter-floating-modal", s.innerHTML = `
1197
+ <div class="tiny-remoter-modal-overlay"></div>
1198
+ <div class="tiny-remoter-modal-content">
1199
+ <div class="tiny-remoter-modal-header">
1200
+ <h3>${e}</h3>
1201
+ <button class="tiny-remoter-modal-close">&times;</button>
1202
+ </div>
1203
+ <div class="tiny-remoter-modal-body">
1204
+ ${t}
1205
+ </div>
1206
+ </div>
1207
+ `;
1208
+ const i = s.querySelector(".tiny-remoter-modal-close"), n = s.querySelector(".tiny-remoter-modal-overlay");
1209
+ return i.addEventListener("click", () => this.hideModal(s)), n.addEventListener("click", () => this.hideModal(s)), s;
1210
+ }
1211
+ showModal(e) {
1212
+ document.body.appendChild(e), setTimeout(() => e.classList.add("show"), 10);
1213
+ }
1214
+ hideModal(e) {
1215
+ e.classList.remove("show"), setTimeout(() => {
1216
+ e.parentNode && e.parentNode.removeChild(e);
1217
+ }, 100);
1218
+ }
1219
+ // 创建样式表
1220
+ addStyles() {
1221
+ const e = document.createElement("style");
1222
+ e.textContent = `
1223
+ /* 浮动块样式 */
1224
+ .tiny-remoter-floating-block {
1225
+ position: fixed;
1226
+ bottom: 30px;
1227
+ right: 30px;
1228
+ width: 60px;
1229
+ height: 60px;
1230
+ cursor: pointer;
1231
+ display: flex;
1232
+ align-items: center;
1233
+ justify-content: center;
1234
+ color: white;
1235
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
1236
+ z-index: 99;
1237
+ overflow: hidden;
1238
+ border-radius: 50%;
1239
+ }
1240
+
1241
+ .tiny-remoter-floating-block__icon {
1242
+ transform: scale(0.8);
1243
+ transition: transform 0.3s ease;
1244
+ }
1245
+
1246
+ .tiny-remoter-floating-block__icon:hover {
1247
+ transform: scale(1.1);
1248
+ }
1249
+
1250
+ .tiny-remoter-floating-block.expanded .tiny-remoter-floating-block__icon {
1251
+ transform: scale(1.1);
1252
+ }
1253
+
1254
+ /* 下拉菜单样式 */
1255
+ .tiny-remoter-floating-dropdown {
1256
+ position: fixed;
1257
+ bottom: 100px;
1258
+ right: 30px;
1259
+ background: white;
1260
+ border-radius: 18px;
1261
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
1262
+ padding: 24px 24px 0px 24px;
1263
+ opacity: 0;
1264
+ visibility: hidden;
1265
+ transform: translateY(20px) scale(0.95);
1266
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
1267
+ z-index: 999;
1268
+ min-width: 200px;
1269
+ width: 223px;
1270
+ height: auto;
1271
+ }
1272
+
1273
+ .tiny-remoter-floating-dropdown.show {
1274
+ opacity: 1;
1275
+ visibility: visible;
1276
+ transform: translateY(0) scale(1);
1277
+ }
1278
+
1279
+ .tiny-remoter-dropdown-item {
1280
+ display: flex;
1281
+ align-items: center;
1282
+ border-radius: 12px;
1283
+ cursor: pointer;
1284
+ transition: all 0.2s ease;
1285
+ color: #333;
1286
+ margin-bottom: 24px;
1287
+ height: 40px;
1288
+ }
1289
+
1290
+ .tiny-remoter-dropdown-item:last-child {
1291
+ margin-bottom: 32px;
1292
+ }
1293
+
1294
+ .tiny-remoter-dropdown-item > span {
1295
+ flex: 1;
1296
+ overflow: hidden;
1297
+ max-width: 120px;
1298
+ text-overflow: ellipsis;
1299
+ white-space: nowrap;
1300
+ }
1301
+
1302
+ .tiny-remoter-dropdown-item__icon {
1303
+ display: flex;
1304
+ align-items: center;
1305
+ justify-content: center;
1306
+ width: 40px;
1307
+ height: 40px;
1308
+ background: #f8f9fa;
1309
+ border-radius: 8px;
1310
+ color: #667eea;
1311
+ }
1312
+
1313
+ .tiny-remoter-dropdown-item__content {
1314
+ flex: 1;
1315
+ display: flex;
1316
+ flex-direction: column;
1317
+ gap: 4px;
1318
+ overflow: hidden;
1319
+ font-size: 12px;
1320
+ margin-left: 16px;
1321
+ }
1322
+
1323
+ .tiny-remoter-dropdown-item__desc-wrapper {
1324
+ display: flex;
1325
+ align-items: center;
1326
+ gap: 4px;
1327
+ }
1328
+
1329
+ .tiny-remoter-dropdown-item__desc {
1330
+ color: #808080;
1331
+ overflow: hidden;
1332
+ white-space: nowrap;
1333
+ text-overflow: ellipsis;
1334
+ }
1335
+
1336
+ .tiny-remoter-dropdown-item__desc--active {
1337
+ color: #1476ff;
1338
+ }
1339
+
1340
+ .tiny-remoter-dropdown-item__desc--know {
1341
+ color: #191919;
1342
+ }
1343
+
1344
+ /* 复制图标样式 */
1345
+ .tiny-remoter-copy-icon {
1346
+ display: flex;
1347
+ align-items: center;
1348
+ justify-content: center;
1349
+ width: 24px;
1350
+ height: 24px;
1351
+ background: #f0f0f0;
1352
+ border-radius: 6px;
1353
+ color: #666;
1354
+ cursor: pointer;
1355
+ transition: all 0.2s ease;
1356
+ opacity: 0.7;
1357
+ margin-left: auto;
1358
+ }
1359
+
1360
+ .tiny-remoter-copy-icon:hover {
1361
+ background: #e0e0e0;
1362
+ color: #333;
1363
+ opacity: 1;
1364
+ transform: scale(1.1);
1365
+ }
1366
+
1367
+ .tiny-remoter-copy-icon:active {
1368
+ transform: scale(0.95);
1369
+ }
1370
+
1371
+ /* 弹窗样式 */
1372
+ .tiny-remoter-floating-modal {
1373
+ position: fixed;
1374
+ top: 0;
1375
+ left: 0;
1376
+ width: 100%;
1377
+ height: 100%;
1378
+ z-index: 2000;
1379
+ display: flex;
1380
+ align-items: center;
1381
+ justify-content: center;
1382
+ }
1383
+
1384
+ .tiny-remoter-modal-overlay {
1385
+ position: absolute;
1386
+ top: 0;
1387
+ left: 0;
1388
+ width: 100%;
1389
+ height: 100%;
1390
+ background: rgba(0, 0, 0, 0.5);
1391
+ backdrop-filter: blur(4px);
1392
+ opacity: 0;
1393
+ transition: opacity 0.3s ease;
1394
+ }
1395
+
1396
+ .tiny-remoter-modal-content {
1397
+ background: white;
1398
+ border-radius: 16px;
1399
+ box-shadow: 0 25px 80px rgba(0, 0, 0, 0.2);
1400
+ max-width: 500px;
1401
+ width: 90%;
1402
+ max-height: 80vh;
1403
+ overflow: hidden;
1404
+ transform: scale(0.9) translateY(20px);
1405
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
1406
+ }
1407
+
1408
+ .tiny-remoter-floating-modal.show .tiny-remoter-modal-overlay {
1409
+ opacity: 1;
1410
+ }
1411
+
1412
+ .tiny-remoter-floating-modal.show .tiny-remoter-modal-content {
1413
+ transform: scale(1) translateY(0);
1414
+ }
1415
+
1416
+ .tiny-remoter-modal-header {
1417
+ display: flex;
1418
+ align-items: center;
1419
+ justify-content: space-between;
1420
+ padding: 20px 24px;
1421
+ border-bottom: 1px solid #f0f0f0;
1422
+ }
1423
+
1424
+ .tiny-remoter-modal-header h3 {
1425
+ margin: 0;
1426
+ font-size: 18px;
1427
+ font-weight: 600;
1428
+ color: #333;
1429
+ }
1430
+
1431
+ .tiny-remoter-modal-close {
1432
+ background: none;
1433
+ border: none;
1434
+ font-size: 24px;
1435
+ cursor: pointer;
1436
+ color: #999;
1437
+ padding: 0;
1438
+ width: 32px;
1439
+ height: 32px;
1440
+ border-radius: 50%;
1441
+ display: flex;
1442
+ align-items: center;
1443
+ justify-content: center;
1444
+ transition: all 0.2s ease;
1445
+ }
1446
+
1447
+ .tiny-remoter-modal-close:hover {
1448
+ background: #f5f5f5;
1449
+ color: #666;
1450
+ }
1451
+
1452
+ .tiny-remoter-modal-body {
1453
+ padding: 24px;
1454
+ }
1455
+
1456
+ /* 二维码弹窗动画 */
1457
+ @keyframes rotate {
1458
+ from {
1459
+ transform: rotate(0deg);
1460
+ }
1461
+ to {
1462
+ transform: rotate(360deg);
1463
+ }
1464
+ }
1465
+
1466
+ /* 响应式设计 */
1467
+ @media (max-width: 768px) {
1468
+ .tiny-remoter-floating-block {
1469
+ bottom: 20px;
1470
+ right: 20px;
1471
+ width: 56px;
1472
+ height: 56px;
1473
+ }
1474
+
1475
+ .tiny-remoter-floating-dropdown {
1476
+ bottom: 90px;
1477
+ right: 20px;
1478
+ min-width: 180px;
1479
+ }
1480
+
1481
+ .tiny-remoter-modal-content {
1482
+ width: 95%;
1483
+ margin: 20px;
1484
+ }
1485
+ }
1486
+
1487
+ /* 复制反馈提示样式 */
1488
+ .tiny-remoter-copy-feedback {
1489
+ position: fixed;
1490
+ top: 50%;
1491
+ left: 50%;
1492
+ transform: translate(-50%, -50%);
1493
+ background: rgba(0, 0, 0, 0.8);
1494
+ color: white;
1495
+ padding: 12px 24px;
1496
+ border-radius: 8px;
1497
+ font-size: 14px;
1498
+ font-weight: 500;
1499
+ z-index: 10000;
1500
+ opacity: 0;
1501
+ visibility: hidden;
1502
+ transition: all 0.3s ease;
1503
+ backdrop-filter: blur(4px);
1504
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
1505
+ }
1506
+
1507
+ .tiny-remoter-copy-feedback.show {
1508
+ opacity: 1;
1509
+ visibility: visible;
1510
+ transform: translate(-50%, -50%) scale(1);
1511
+ }
1512
+
1513
+ .tiny-remoter-copy-feedback.success {
1514
+ background: rgba(34, 197, 94, 0.9);
1515
+ }
1516
+
1517
+ .tiny-remoter-copy-feedback.error {
1518
+ background: rgba(239, 68, 68, 0.9);
1519
+ }
1520
+
1521
+ /* 深色主题支持 */
1522
+ @media (prefers-color-scheme: dark) {
1523
+ .tiny-remoter-floating-dropdown {
1524
+ background: #1a1a1a;
1525
+ color: white;
1526
+ }
1527
+
1528
+ .tiny-remoter-dropdown-item {
1529
+ color: white;
1530
+ }
1531
+
1532
+
1533
+ .tiny-remoter-copy-icon {
1534
+ background: #2a2a2a;
1535
+ color: #ccc;
1536
+ }
1537
+
1538
+ .tiny-remoter-copy-icon:hover {
1539
+ background: #3a3a3a;
1540
+ color: white;
1541
+ }
1542
+
1543
+ .tiny-remoter-modal-content {
1544
+ background: #1a1a1a;
1545
+ color: white;
1546
+ }
1547
+
1548
+ .tiny-remoter-modal-header {
1549
+ border-bottom-color: #333;
1550
+ }
1551
+
1552
+ .tiny-remoter-modal-header h3 {
1553
+ color: white;
1554
+ }
1555
+ }
1556
+ `, document.head.appendChild(e);
1557
+ }
1558
+ // 销毁组件
1559
+ destroy() {
1560
+ this.floatingBlock.parentNode && this.floatingBlock.parentNode.removeChild(this.floatingBlock), this.dropdownMenu.parentNode && this.dropdownMenu.parentNode.removeChild(this.dropdownMenu);
1561
+ }
1562
+ }
1563
+ const k0 = (r = {}) => new $e(r);
1564
+ class b2 extends Error {
1565
+ constructor(e, t) {
1566
+ super(e), this.name = "ParseError", this.type = t.type, this.field = t.field, this.value = t.value, this.line = t.line;
1567
+ }
1568
+ }
1569
+ function e2(r) {
1570
+ }
1571
+ function qe(r) {
1572
+ if (typeof r == "function")
1573
+ throw new TypeError(
1574
+ "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
1575
+ );
1576
+ const { onEvent: e = e2, onError: t = e2, onRetry: s = e2, onComment: i } = r;
1577
+ let n = "", a = !0, l, h = "", c = "";
1578
+ function d(u) {
1579
+ const m = a ? u.replace(/^\xEF\xBB\xBF/, "") : u, [w, v] = je(`${n}${m}`);
1580
+ for (const _ of w)
1581
+ g(_);
1582
+ n = v, a = !1;
1583
+ }
1584
+ function g(u) {
1585
+ if (u === "") {
1586
+ C();
1587
+ return;
1588
+ }
1589
+ if (u.startsWith(":")) {
1590
+ i && i(u.slice(u.startsWith(": ") ? 2 : 1));
1591
+ return;
1592
+ }
1593
+ const m = u.indexOf(":");
1594
+ if (m !== -1) {
1595
+ const w = u.slice(0, m), v = u[m + 1] === " " ? 2 : 1, _ = u.slice(m + v);
1596
+ p(w, _, u);
1597
+ return;
1598
+ }
1599
+ p(u, "", u);
1600
+ }
1601
+ function p(u, m, w) {
1602
+ switch (u) {
1603
+ case "event":
1604
+ c = m;
1605
+ break;
1606
+ case "data":
1607
+ h = `${h}${m}
1608
+ `;
1609
+ break;
1610
+ case "id":
1611
+ l = m.includes("\0") ? void 0 : m;
1612
+ break;
1613
+ case "retry":
1614
+ /^\d+$/.test(m) ? s(parseInt(m, 10)) : t(
1615
+ new b2(`Invalid \`retry\` value: "${m}"`, {
1616
+ type: "invalid-retry",
1617
+ value: m,
1618
+ line: w
1619
+ })
1620
+ );
1621
+ break;
1622
+ default:
1623
+ t(
1624
+ new b2(
1625
+ `Unknown field "${u.length > 20 ? `${u.slice(0, 20)}…` : u}"`,
1626
+ { type: "unknown-field", field: u, value: m, line: w }
1627
+ )
1628
+ );
1629
+ break;
1630
+ }
1631
+ }
1632
+ function C() {
1633
+ h.length > 0 && e({
1634
+ id: l,
1635
+ event: c || void 0,
1636
+ // If the data buffer's last character is a U+000A LINE FEED (LF) character,
1637
+ // then remove the last character from the data buffer.
1638
+ data: h.endsWith(`
1639
+ `) ? h.slice(0, -1) : h
1640
+ }), l = void 0, h = "", c = "";
1641
+ }
1642
+ function f(u = {}) {
1643
+ n && u.consume && g(n), a = !0, l = void 0, h = "", c = "", n = "";
1644
+ }
1645
+ return { feed: d, reset: f };
1646
+ }
1647
+ function je(r) {
1648
+ const e = [];
1649
+ let t = "", s = 0;
1650
+ for (; s < r.length; ) {
1651
+ const i = r.indexOf("\r", s), n = r.indexOf(`
1652
+ `, s);
1653
+ let a = -1;
1654
+ if (i !== -1 && n !== -1 ? a = Math.min(i, n) : i !== -1 ? i === r.length - 1 ? a = -1 : a = i : n !== -1 && (a = n), a === -1) {
1655
+ t = r.slice(s);
1656
+ break;
1657
+ } else {
1658
+ const l = r.slice(s, a);
1659
+ e.push(l), s = a + 1, r[s - 1] === "\r" && r[s] === `
1660
+ ` && s++;
1661
+ }
1662
+ }
1663
+ return [e, t];
1664
+ }
1665
+ class o2 extends TransformStream {
1666
+ constructor({ onError: e, onRetry: t, onComment: s } = {}) {
1667
+ let i;
1668
+ super({
1669
+ start(n) {
1670
+ i = qe({
1671
+ onEvent: (a) => {
1672
+ n.enqueue(a);
1673
+ },
1674
+ onError(a) {
1675
+ e === "terminate" ? n.error(a) : typeof e == "function" && e(a);
1676
+ },
1677
+ onRetry: t,
1678
+ onComment: s
1679
+ });
1680
+ },
1681
+ transform(n) {
1682
+ i.feed(n);
1683
+ }
1684
+ });
1685
+ }
1686
+ }
1687
+ var He = ({
1688
+ prefix: r,
1689
+ size: e = 16,
1690
+ alphabet: t = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
1691
+ separator: s = "-"
1692
+ } = {}) => {
1693
+ const i = () => {
1694
+ const n = t.length, a = new Array(e);
1695
+ for (let l = 0; l < e; l++)
1696
+ a[l] = t[Math.random() * n | 0];
1697
+ return a.join("");
1698
+ };
1699
+ if (r == null)
1700
+ return i;
1701
+ if (t.includes(s))
1702
+ throw new be({
1703
+ argument: "separator",
1704
+ message: `The separator "${s}" must not be part of the alphabet "${t}".`
1705
+ });
1706
+ return () => `${r}${s}${i()}`;
1707
+ };
1708
+ He();
1709
+ function U2(r = globalThis) {
1710
+ var e, t, s;
1711
+ return r.window ? "runtime/browser" : (e = r.navigator) != null && e.userAgent ? `runtime/${r.navigator.userAgent.toLowerCase()}` : (s = (t = r.process) == null ? void 0 : t.versions) != null && s.node ? `runtime/node.js/${r.process.version.substring(0)}` : r.EdgeRuntime ? "runtime/vercel-edge" : "runtime/unknown";
1712
+ }
1713
+ function Ne(r) {
1714
+ if (r == null)
1715
+ return {};
1716
+ const e = {};
1717
+ if (r instanceof Headers)
1718
+ r.forEach((t, s) => {
1719
+ e[s.toLowerCase()] = t;
1720
+ });
1721
+ else {
1722
+ Array.isArray(r) || (r = Object.entries(r));
1723
+ for (const [t, s] of r)
1724
+ s != null && (e[t.toLowerCase()] = s);
1725
+ }
1726
+ return e;
1727
+ }
1728
+ function A2(r, ...e) {
1729
+ const t = new Headers(Ne(r)), s = t.get("user-agent") || "";
1730
+ return t.set(
1731
+ "user-agent",
1732
+ [s, ...e].filter(Boolean).join(" ")
1733
+ ), Object.fromEntries(t.entries());
1734
+ }
1735
+ var ze = Symbol.for("vercel.ai.validator");
1736
+ function Ze(r) {
1737
+ return { ...r, type: "dynamic" };
1738
+ }
1739
+ new Set(
1740
+ "ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789"
1741
+ );
1742
+ var De = Symbol.for("vercel.ai.schema");
1743
+ function Fe(r, {
1744
+ validate: e
1745
+ } = {}) {
1746
+ return {
1747
+ [De]: !0,
1748
+ _type: void 0,
1749
+ // should never be used directly
1750
+ [ze]: !0,
1751
+ get jsonSchema() {
1752
+ return typeof r == "function" && (r = r()), r;
1753
+ },
1754
+ validate: e
1755
+ };
1756
+ }
1757
+ let l2;
1758
+ l2 = globalThis.crypto;
1759
+ async function Be(r) {
1760
+ return (await l2).getRandomValues(new Uint8Array(r));
1761
+ }
1762
+ async function Ve(r) {
1763
+ const e = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~", t = Math.pow(2, 8) - Math.pow(2, 8) % e.length;
1764
+ let s = "";
1765
+ for (; s.length < r; ) {
1766
+ const i = await Be(r - s.length);
1767
+ for (const n of i)
1768
+ n < t && (s += e[n % e.length]);
1769
+ }
1770
+ return s;
1771
+ }
1772
+ async function Je(r) {
1773
+ return await Ve(r);
1774
+ }
1775
+ async function We(r) {
1776
+ const e = await (await l2).subtle.digest("SHA-256", new TextEncoder().encode(r));
1777
+ return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g, "_").replace(/\+/g, "-").replace(/=/g, "");
1778
+ }
1779
+ async function Ge(r) {
1780
+ if (r || (r = 43), r < 43 || r > 128)
1781
+ throw `Expected a length between 43 and 128. Received ${r}.`;
1782
+ const e = await Je(r), t = await We(e);
1783
+ return {
1784
+ code_verifier: e,
1785
+ code_challenge: t
1786
+ };
1787
+ }
1788
+ var Ye = "AI_MCPClientError", O2 = `vercel.ai.error.${Ye}`, Ke = Symbol.for(O2), x2, L2, y = class extends (L2 = Z, x2 = Ke, L2) {
1789
+ constructor({
1790
+ name: r = "MCPClientError",
1791
+ message: e,
1792
+ cause: t,
1793
+ data: s,
1794
+ code: i
1795
+ }) {
1796
+ super({ name: r, message: e, cause: t }), this[x2] = !0, this.data = s, this.code = i;
1797
+ }
1798
+ static isInstance(r) {
1799
+ return Z.hasMarker(r, O2);
1800
+ }
1801
+ }, $ = "2025-06-18", Qe = [
1802
+ $,
1803
+ "2025-03-26",
1804
+ "2024-11-05"
1805
+ ], Xe = o.looseObject({
1806
+ name: o.string(),
1807
+ version: o.string()
1808
+ }), Y = o.looseObject({
1809
+ _meta: o.optional(o.object({}).loose())
1810
+ }), M = Y, $2 = o.object({
1811
+ method: o.string(),
1812
+ params: o.optional(Y)
1813
+ }), q2 = o.object({
1814
+ applyDefaults: o.optional(o.boolean())
1815
+ }).loose(), et = o.looseObject({
1816
+ experimental: o.optional(o.object({}).loose()),
1817
+ logging: o.optional(o.object({}).loose()),
1818
+ prompts: o.optional(
1819
+ o.looseObject({
1820
+ listChanged: o.optional(o.boolean())
1821
+ })
1822
+ ),
1823
+ resources: o.optional(
1824
+ o.looseObject({
1825
+ subscribe: o.optional(o.boolean()),
1826
+ listChanged: o.optional(o.boolean())
1827
+ })
1828
+ ),
1829
+ tools: o.optional(
1830
+ o.looseObject({
1831
+ listChanged: o.optional(o.boolean())
1832
+ })
1833
+ ),
1834
+ elicitation: o.optional(q2)
1835
+ });
1836
+ o.object({
1837
+ elicitation: o.optional(q2)
1838
+ }).loose();
1839
+ var tt = M.extend({
1840
+ protocolVersion: o.string(),
1841
+ capabilities: et,
1842
+ serverInfo: Xe,
1843
+ instructions: o.optional(o.string())
1844
+ }), h2 = M.extend({
1845
+ nextCursor: o.optional(o.string())
1846
+ }), rt = o.object({
1847
+ name: o.string(),
1848
+ description: o.optional(o.string()),
1849
+ inputSchema: o.object({
1850
+ type: o.literal("object"),
1851
+ properties: o.optional(o.object({}).loose())
1852
+ }).loose()
1853
+ }).loose(), st = h2.extend({
1854
+ tools: o.array(rt)
1855
+ }), j2 = o.object({
1856
+ type: o.literal("text"),
1857
+ text: o.string()
1858
+ }).loose(), H2 = o.object({
1859
+ type: o.literal("image"),
1860
+ data: o.base64(),
1861
+ mimeType: o.string()
1862
+ }).loose(), ot = o.object({
1863
+ uri: o.string(),
1864
+ name: o.string(),
1865
+ title: o.optional(o.string()),
1866
+ description: o.optional(o.string()),
1867
+ mimeType: o.optional(o.string()),
1868
+ size: o.optional(o.number())
1869
+ }).loose(), it = h2.extend({
1870
+ resources: o.array(ot)
1871
+ }), N2 = o.object({
1872
+ /**
1873
+ * The URI of this resource.
1874
+ */
1875
+ uri: o.string(),
1876
+ /**
1877
+ * Optional display name of the resource content.
1878
+ */
1879
+ name: o.optional(o.string()),
1880
+ /**
1881
+ * Optional human readable title.
1882
+ */
1883
+ title: o.optional(o.string()),
1884
+ /**
1885
+ * The MIME type of this resource, if known.
1886
+ */
1887
+ mimeType: o.optional(o.string())
1888
+ }).loose(), z2 = N2.extend({
1889
+ text: o.string()
1890
+ }), Z2 = N2.extend({
1891
+ blob: o.base64()
1892
+ }), D2 = o.object({
1893
+ type: o.literal("resource"),
1894
+ resource: o.union([z2, Z2])
1895
+ }).loose(), nt = M.extend({
1896
+ content: o.array(
1897
+ o.union([j2, H2, D2])
1898
+ ),
1899
+ isError: o.boolean().default(!1).optional()
1900
+ }).or(
1901
+ M.extend({
1902
+ toolResult: o.unknown()
1903
+ })
1904
+ ), at = o.object({
1905
+ uriTemplate: o.string(),
1906
+ name: o.string(),
1907
+ title: o.optional(o.string()),
1908
+ description: o.optional(o.string()),
1909
+ mimeType: o.optional(o.string())
1910
+ }).loose(), ct = M.extend({
1911
+ resourceTemplates: o.array(at)
1912
+ }), lt = M.extend({
1913
+ contents: o.array(
1914
+ o.union([z2, Z2])
1915
+ )
1916
+ }), ht = o.object({
1917
+ name: o.string(),
1918
+ description: o.optional(o.string()),
1919
+ required: o.optional(o.boolean())
1920
+ }).loose(), dt = o.object({
1921
+ name: o.string(),
1922
+ title: o.optional(o.string()),
1923
+ description: o.optional(o.string()),
1924
+ arguments: o.optional(o.array(ht))
1925
+ }).loose(), pt = h2.extend({
1926
+ prompts: o.array(dt)
1927
+ }), ut = o.object({
1928
+ role: o.union([o.literal("user"), o.literal("assistant")]),
1929
+ content: o.union([
1930
+ j2,
1931
+ H2,
1932
+ D2
1933
+ ])
1934
+ }).loose(), mt = M.extend({
1935
+ description: o.optional(o.string()),
1936
+ messages: o.array(ut)
1937
+ }), gt = Y.extend({
1938
+ message: o.string(),
1939
+ requestedSchema: o.unknown()
1940
+ }), S2 = $2.extend({
1941
+ method: o.literal("elicitation/create"),
1942
+ params: gt
1943
+ }), ft = M.extend({
1944
+ action: o.union([
1945
+ o.literal("accept"),
1946
+ o.literal("decline"),
1947
+ o.literal("cancel")
1948
+ ]),
1949
+ content: o.optional(o.record(o.string(), o.unknown()))
1950
+ }), K = "2.0", Ct = o.object({
1951
+ jsonrpc: o.literal(K),
1952
+ id: o.union([o.string(), o.number().int()])
1953
+ }).merge($2).strict(), wt = o.object({
1954
+ jsonrpc: o.literal(K),
1955
+ id: o.union([o.string(), o.number().int()]),
1956
+ result: M
1957
+ }).strict(), yt = o.object({
1958
+ jsonrpc: o.literal(K),
1959
+ id: o.union([o.string(), o.number().int()]),
1960
+ error: o.object({
1961
+ code: o.number().int(),
1962
+ message: o.string(),
1963
+ data: o.optional(o.unknown())
1964
+ })
1965
+ }).strict(), vt = o.object({
1966
+ jsonrpc: o.literal(K)
1967
+ }).merge(
1968
+ o.object({
1969
+ method: o.string(),
1970
+ params: o.optional(Y)
1971
+ })
1972
+ ).strict(), q = o.union([
1973
+ Ct,
1974
+ vt,
1975
+ wt,
1976
+ yt
1977
+ ]), F2 = typeof __PACKAGE_VERSION__ < "u" ? __PACKAGE_VERSION__ : "0.0.0-test", B2 = o.object({
1978
+ access_token: o.string(),
1979
+ id_token: o.string().optional(),
1980
+ // Optional for OAuth 2.1, but necessary in OpenID Connect
1981
+ token_type: o.string(),
1982
+ expires_in: o.number().optional(),
1983
+ scope: o.string().optional(),
1984
+ refresh_token: o.string().optional()
1985
+ }).strip(), x = o.string().url().superRefine((r, e) => {
1986
+ if (!URL.canParse(r))
1987
+ return e.addIssue({
1988
+ code: o.ZodIssueCode.custom,
1989
+ message: "URL must be parseable",
1990
+ fatal: !0
1991
+ }), o.NEVER;
1992
+ }).refine(
1993
+ (r) => {
1994
+ const e = new URL(r);
1995
+ return e.protocol !== "javascript:" && e.protocol !== "data:" && e.protocol !== "vbscript:";
1996
+ },
1997
+ { message: "URL cannot use javascript:, data:, or vbscript: scheme" }
1998
+ ), _t = o.object({
1999
+ resource: o.string().url(),
2000
+ authorization_servers: o.array(x).optional(),
2001
+ jwks_uri: o.string().url().optional(),
2002
+ scopes_supported: o.array(o.string()).optional(),
2003
+ bearer_methods_supported: o.array(o.string()).optional(),
2004
+ resource_signing_alg_values_supported: o.array(o.string()).optional(),
2005
+ resource_name: o.string().optional(),
2006
+ resource_documentation: o.string().optional(),
2007
+ resource_policy_uri: o.string().url().optional(),
2008
+ resource_tos_uri: o.string().url().optional(),
2009
+ tls_client_certificate_bound_access_tokens: o.boolean().optional(),
2010
+ authorization_details_types_supported: o.array(o.string()).optional(),
2011
+ dpop_signing_alg_values_supported: o.array(o.string()).optional(),
2012
+ dpop_bound_access_tokens_required: o.boolean().optional()
2013
+ }).passthrough(), V2 = o.object({
2014
+ issuer: o.string(),
2015
+ authorization_endpoint: x,
2016
+ token_endpoint: x,
2017
+ registration_endpoint: x.optional(),
2018
+ scopes_supported: o.array(o.string()).optional(),
2019
+ response_types_supported: o.array(o.string()),
2020
+ grant_types_supported: o.array(o.string()).optional(),
2021
+ code_challenge_methods_supported: o.array(o.string()),
2022
+ token_endpoint_auth_methods_supported: o.array(o.string()).optional(),
2023
+ token_endpoint_auth_signing_alg_values_supported: o.array(o.string()).optional()
2024
+ }).passthrough(), bt = o.object({
2025
+ issuer: o.string(),
2026
+ authorization_endpoint: x,
2027
+ token_endpoint: x,
2028
+ userinfo_endpoint: x.optional(),
2029
+ jwks_uri: x,
2030
+ registration_endpoint: x.optional(),
2031
+ scopes_supported: o.array(o.string()).optional(),
2032
+ response_types_supported: o.array(o.string()),
2033
+ grant_types_supported: o.array(o.string()).optional(),
2034
+ subject_types_supported: o.array(o.string()),
2035
+ id_token_signing_alg_values_supported: o.array(o.string()),
2036
+ claims_supported: o.array(o.string()).optional(),
2037
+ token_endpoint_auth_methods_supported: o.array(o.string()).optional()
2038
+ }).passthrough(), xt = bt.merge(
2039
+ V2.pick({
2040
+ code_challenge_methods_supported: !0
2041
+ })
2042
+ ), Lt = o.object({
2043
+ client_id: o.string(),
2044
+ client_secret: o.string().optional(),
2045
+ client_id_issued_at: o.number().optional(),
2046
+ client_secret_expires_at: o.number().optional()
2047
+ }).strip(), St = o.object({
2048
+ redirect_uris: o.array(x),
2049
+ token_endpoint_auth_method: o.string().optional(),
2050
+ grant_types: o.array(o.string()).optional(),
2051
+ response_types: o.array(o.string()).optional(),
2052
+ client_name: o.string().optional(),
2053
+ client_uri: x.optional(),
2054
+ logo_uri: x.optional(),
2055
+ scope: o.string().optional(),
2056
+ contacts: o.array(o.string()).optional(),
2057
+ tos_uri: x.optional(),
2058
+ policy_uri: o.string().optional(),
2059
+ jwks_uri: x.optional(),
2060
+ jwks: o.any().optional(),
2061
+ software_id: o.string().optional(),
2062
+ software_version: o.string().optional(),
2063
+ software_statement: o.string().optional()
2064
+ }).strip(), Rt = o.object({
2065
+ error: o.string(),
2066
+ error_description: o.string().optional(),
2067
+ error_uri: o.string().optional()
2068
+ }), Tt = St.merge(
2069
+ Lt
2070
+ ), Mt = "AI_MCPClientOAuthError", J2 = `vercel.ai.error.${Mt}`, Et = Symbol.for(J2), R2, T2, j = class extends (T2 = Z, R2 = Et, T2) {
2071
+ constructor({
2072
+ name: r = "MCPClientOAuthError",
2073
+ message: e,
2074
+ cause: t
2075
+ }) {
2076
+ super({ name: r, message: e, cause: t }), this[R2] = !0;
2077
+ }
2078
+ static isInstance(r) {
2079
+ return Z.hasMarker(r, J2);
2080
+ }
2081
+ }, O = class extends j {
2082
+ };
2083
+ O.errorCode = "server_error";
2084
+ var D = class extends j {
2085
+ };
2086
+ D.errorCode = "invalid_client";
2087
+ var F = class extends j {
2088
+ };
2089
+ F.errorCode = "invalid_grant";
2090
+ var B = class extends j {
2091
+ };
2092
+ B.errorCode = "unauthorized_client";
2093
+ var Pt = {
2094
+ [O.errorCode]: O,
2095
+ [D.errorCode]: D,
2096
+ [F.errorCode]: F,
2097
+ [B.errorCode]: B
2098
+ };
2099
+ function kt(r) {
2100
+ const e = typeof r == "string" ? new URL(r) : new URL(r.href);
2101
+ return e.hash = "", e;
2102
+ }
2103
+ function It({
2104
+ requestedResource: r,
2105
+ configuredResource: e
2106
+ }) {
2107
+ const t = typeof r == "string" ? new URL(r) : new URL(r.href), s = typeof e == "string" ? new URL(e) : new URL(e.href);
2108
+ if (t.origin !== s.origin || t.pathname.length < s.pathname.length)
2109
+ return !1;
2110
+ const i = t.pathname.endsWith("/") ? t.pathname : t.pathname + "/", n = s.pathname.endsWith("/") ? s.pathname : s.pathname + "/";
2111
+ return i.startsWith(n);
2112
+ }
2113
+ var V = class extends Error {
2114
+ constructor(r = "Unauthorized") {
2115
+ super(r), this.name = "UnauthorizedError";
2116
+ }
2117
+ };
2118
+ function J(r) {
2119
+ var e;
2120
+ const t = (e = r.headers.get("www-authenticate")) != null ? e : r.headers.get("WWW-Authenticate");
2121
+ if (!t)
2122
+ return;
2123
+ const [s, i] = t.split(" ");
2124
+ if (s.toLowerCase() !== "bearer" || !i)
2125
+ return;
2126
+ const n = /resource_metadata="([^"]*)"/, a = t.match(n);
2127
+ if (a)
2128
+ try {
2129
+ return new URL(a[1]);
2130
+ } catch {
2131
+ return;
2132
+ }
2133
+ }
2134
+ function Ut(r, e = "", t = {}) {
2135
+ return e.endsWith("/") && (e = e.slice(0, -1)), t.prependPathname ? `${e}/.well-known/${r}` : `/.well-known/${r}${e}`;
2136
+ }
2137
+ async function d2(r, e, t = fetch) {
2138
+ try {
2139
+ return await t(r, { headers: e });
2140
+ } catch (s) {
2141
+ if (s instanceof TypeError)
2142
+ return e ? d2(r, void 0, t) : void 0;
2143
+ throw s;
2144
+ }
2145
+ }
2146
+ async function M2(r, e, t = fetch) {
2147
+ return await d2(r, {
2148
+ "MCP-Protocol-Version": e
2149
+ }, t);
2150
+ }
2151
+ function At(r, e) {
2152
+ return !r || r.status >= 400 && r.status < 500 && e !== "/";
2153
+ }
2154
+ async function Ot(r, e, t, s) {
2155
+ var i, n;
2156
+ const a = new URL(r), l = (i = s?.protocolVersion) != null ? i : $;
2157
+ let h;
2158
+ if (s?.metadataUrl)
2159
+ h = new URL(s.metadataUrl);
2160
+ else {
2161
+ const d = Ut(e, a.pathname);
2162
+ h = new URL(d, (n = s?.metadataServerUrl) != null ? n : a), h.search = a.search;
2163
+ }
2164
+ let c = await M2(h, l, t);
2165
+ if (!s?.metadataUrl && At(c, a.pathname)) {
2166
+ const d = new URL(`/.well-known/${e}`, a);
2167
+ c = await M2(d, l, t);
2168
+ }
2169
+ return c;
2170
+ }
2171
+ async function $t(r, e, t = fetch) {
2172
+ const s = await Ot(
2173
+ r,
2174
+ "oauth-protected-resource",
2175
+ t,
2176
+ {
2177
+ protocolVersion: e?.protocolVersion,
2178
+ metadataUrl: e?.resourceMetadataUrl
2179
+ }
2180
+ );
2181
+ if (!s || s.status === 404)
2182
+ throw new Error(
2183
+ "Resource server does not implement OAuth 2.0 Protected Resource Metadata."
2184
+ );
2185
+ if (!s.ok)
2186
+ throw new Error(
2187
+ `HTTP ${s.status} trying to load well-known OAuth protected resource metadata.`
2188
+ );
2189
+ return _t.parse(await s.json());
2190
+ }
2191
+ function qt(r) {
2192
+ const e = typeof r == "string" ? new URL(r) : r, t = e.pathname !== "/", s = [];
2193
+ if (!t)
2194
+ return s.push({
2195
+ url: new URL("/.well-known/oauth-authorization-server", e.origin),
2196
+ type: "oauth"
2197
+ }), s.push({
2198
+ url: new URL("/.well-known/openid-configuration", e.origin),
2199
+ type: "oidc"
2200
+ }), s;
2201
+ let i = e.pathname;
2202
+ return i.endsWith("/") && (i = i.slice(0, -1)), s.push({
2203
+ url: new URL(
2204
+ `/.well-known/oauth-authorization-server${i}`,
2205
+ e.origin
2206
+ ),
2207
+ type: "oauth"
2208
+ }), s.push({
2209
+ url: new URL("/.well-known/oauth-authorization-server", e.origin),
2210
+ type: "oauth"
2211
+ }), s.push({
2212
+ url: new URL(`/.well-known/openid-configuration${i}`, e.origin),
2213
+ type: "oidc"
2214
+ }), s.push({
2215
+ url: new URL(`${i}/.well-known/openid-configuration`, e.origin),
2216
+ type: "oidc"
2217
+ }), s;
2218
+ }
2219
+ async function jt(r, {
2220
+ fetchFn: e = fetch,
2221
+ protocolVersion: t = $
2222
+ } = {}) {
2223
+ var s;
2224
+ const i = { "MCP-Protocol-Version": t }, n = qt(r);
2225
+ for (const { url: a, type: l } of n) {
2226
+ const h = await d2(a, i, e);
2227
+ if (h) {
2228
+ if (!h.ok) {
2229
+ if (h.status >= 400 && h.status < 500)
2230
+ continue;
2231
+ throw new Error(
2232
+ `HTTP ${h.status} trying to load ${l === "oauth" ? "OAuth" : "OpenID provider"} metadata from ${a}`
2233
+ );
2234
+ }
2235
+ if (l === "oauth")
2236
+ return V2.parse(await h.json());
2237
+ {
2238
+ const c = xt.parse(
2239
+ await h.json()
2240
+ );
2241
+ if (!((s = c.code_challenge_methods_supported) != null && s.includes("S256")))
2242
+ throw new Error(
2243
+ `Incompatible OIDC provider at ${a}: does not support S256 code challenge method required by MCP specification`
2244
+ );
2245
+ return c;
2246
+ }
2247
+ }
2248
+ }
2249
+ }
2250
+ async function Ht(r, {
2251
+ metadata: e,
2252
+ clientInformation: t,
2253
+ redirectUrl: s,
2254
+ scope: i,
2255
+ state: n,
2256
+ resource: a
2257
+ }) {
2258
+ const l = "code", h = "S256";
2259
+ let c;
2260
+ if (e) {
2261
+ if (c = new URL(e.authorization_endpoint), !e.response_types_supported.includes(l))
2262
+ throw new Error(
2263
+ `Incompatible auth server: does not support response type ${l}`
2264
+ );
2265
+ if (!e.code_challenge_methods_supported || !e.code_challenge_methods_supported.includes(h))
2266
+ throw new Error(
2267
+ `Incompatible auth server: does not support code challenge method ${h}`
2268
+ );
2269
+ } else
2270
+ c = new URL("/authorize", r);
2271
+ const d = await Ge(), g = d.code_verifier, p = d.code_challenge;
2272
+ return c.searchParams.set("response_type", l), c.searchParams.set("client_id", t.client_id), c.searchParams.set("code_challenge", p), c.searchParams.set(
2273
+ "code_challenge_method",
2274
+ h
2275
+ ), c.searchParams.set("redirect_uri", String(s)), n && c.searchParams.set("state", n), i && c.searchParams.set("scope", i), i?.includes("offline_access") && c.searchParams.append("prompt", "consent"), a && c.searchParams.set("resource", a.href), { authorizationUrl: c, codeVerifier: g };
2276
+ }
2277
+ function W2(r, e) {
2278
+ const t = r.client_secret !== void 0;
2279
+ return e.length === 0 ? t ? "client_secret_post" : "none" : t && e.includes("client_secret_basic") ? "client_secret_basic" : t && e.includes("client_secret_post") ? "client_secret_post" : e.includes("none") ? "none" : t ? "client_secret_post" : "none";
2280
+ }
2281
+ function G2(r, e, t, s) {
2282
+ const { client_id: i, client_secret: n } = e;
2283
+ switch (r) {
2284
+ case "client_secret_basic":
2285
+ Nt(i, n, t);
2286
+ return;
2287
+ case "client_secret_post":
2288
+ zt(i, n, s);
2289
+ return;
2290
+ case "none":
2291
+ Zt(i, s);
2292
+ return;
2293
+ default:
2294
+ throw new Error(`Unsupported client authentication method: ${r}`);
2295
+ }
2296
+ }
2297
+ function Nt(r, e, t) {
2298
+ if (!e)
2299
+ throw new Error(
2300
+ "client_secret_basic authentication requires a client_secret"
2301
+ );
2302
+ const s = btoa(`${r}:${e}`);
2303
+ t.set("Authorization", `Basic ${s}`);
2304
+ }
2305
+ function zt(r, e, t) {
2306
+ t.set("client_id", r), e && t.set("client_secret", e);
2307
+ }
2308
+ function Zt(r, e) {
2309
+ e.set("client_id", r);
2310
+ }
2311
+ async function p2(r) {
2312
+ const e = r instanceof Response ? r.status : void 0, t = r instanceof Response ? await r.text() : r;
2313
+ try {
2314
+ const s = Rt.parse(JSON.parse(t)), { error: i, error_description: n, error_uri: a } = s, l = Pt[i] || O;
2315
+ return new l({
2316
+ message: n || "",
2317
+ cause: a
2318
+ });
2319
+ } catch (s) {
2320
+ const i = `${e ? `HTTP ${e}: ` : ""}Invalid OAuth error response: ${s}. Raw body: ${t}`;
2321
+ return new O({ message: i });
2322
+ }
2323
+ }
2324
+ async function Dt(r, {
2325
+ metadata: e,
2326
+ clientInformation: t,
2327
+ authorizationCode: s,
2328
+ codeVerifier: i,
2329
+ redirectUri: n,
2330
+ resource: a,
2331
+ addClientAuthentication: l,
2332
+ fetchFn: h
2333
+ }) {
2334
+ var c;
2335
+ const d = "authorization_code", g = e?.token_endpoint ? new URL(e.token_endpoint) : new URL("/token", r);
2336
+ if (e?.grant_types_supported && !e.grant_types_supported.includes(d))
2337
+ throw new Error(
2338
+ `Incompatible auth server: does not support grant type ${d}`
2339
+ );
2340
+ const p = new Headers({
2341
+ "Content-Type": "application/x-www-form-urlencoded",
2342
+ Accept: "application/json"
2343
+ }), C = new URLSearchParams({
2344
+ grant_type: d,
2345
+ code: s,
2346
+ code_verifier: i,
2347
+ redirect_uri: String(n)
2348
+ });
2349
+ if (l)
2350
+ l(p, C, r, e);
2351
+ else {
2352
+ const u = (c = e?.token_endpoint_auth_methods_supported) != null ? c : [], m = W2(
2353
+ t,
2354
+ u
2355
+ );
2356
+ G2(m, t, p, C);
2357
+ }
2358
+ a && C.set("resource", a.href);
2359
+ const f = await (h ?? fetch)(g, {
2360
+ method: "POST",
2361
+ headers: p,
2362
+ body: C
2363
+ });
2364
+ if (!f.ok)
2365
+ throw await p2(f);
2366
+ return B2.parse(await f.json());
2367
+ }
2368
+ async function Ft(r, {
2369
+ metadata: e,
2370
+ clientInformation: t,
2371
+ refreshToken: s,
2372
+ resource: i,
2373
+ addClientAuthentication: n,
2374
+ fetchFn: a
2375
+ }) {
2376
+ var l;
2377
+ const h = "refresh_token";
2378
+ let c;
2379
+ if (e) {
2380
+ if (c = new URL(e.token_endpoint), e.grant_types_supported && !e.grant_types_supported.includes(h))
2381
+ throw new Error(
2382
+ `Incompatible auth server: does not support grant type ${h}`
2383
+ );
2384
+ } else
2385
+ c = new URL("/token", r);
2386
+ const d = new Headers({
2387
+ "Content-Type": "application/x-www-form-urlencoded"
2388
+ }), g = new URLSearchParams({
2389
+ grant_type: h,
2390
+ refresh_token: s
2391
+ });
2392
+ if (n)
2393
+ n(d, g, r, e);
2394
+ else {
2395
+ const C = (l = e?.token_endpoint_auth_methods_supported) != null ? l : [], f = W2(
2396
+ t,
2397
+ C
2398
+ );
2399
+ G2(f, t, d, g);
2400
+ }
2401
+ i && g.set("resource", i.href);
2402
+ const p = await (a ?? fetch)(c, {
2403
+ method: "POST",
2404
+ headers: d,
2405
+ body: g
2406
+ });
2407
+ if (!p.ok)
2408
+ throw await p2(p);
2409
+ return B2.parse({
2410
+ refresh_token: s,
2411
+ ...await p.json()
2412
+ });
2413
+ }
2414
+ async function Bt(r, {
2415
+ metadata: e,
2416
+ clientMetadata: t,
2417
+ fetchFn: s
2418
+ }) {
2419
+ let i;
2420
+ if (e) {
2421
+ if (!e.registration_endpoint)
2422
+ throw new Error(
2423
+ "Incompatible auth server: does not support dynamic client registration"
2424
+ );
2425
+ i = new URL(e.registration_endpoint);
2426
+ } else
2427
+ i = new URL("/register", r);
2428
+ const n = await (s ?? fetch)(i, {
2429
+ method: "POST",
2430
+ headers: {
2431
+ "Content-Type": "application/json"
2432
+ },
2433
+ body: JSON.stringify(t)
2434
+ });
2435
+ if (!n.ok)
2436
+ throw await p2(n);
2437
+ return Tt.parse(await n.json());
2438
+ }
2439
+ async function W(r, e) {
2440
+ var t, s;
2441
+ try {
2442
+ return await t2(r, e);
2443
+ } catch (i) {
2444
+ if (i instanceof D || i instanceof B)
2445
+ return await ((t = r.invalidateCredentials) == null ? void 0 : t.call(r, "all")), await t2(r, e);
2446
+ if (i instanceof F)
2447
+ return await ((s = r.invalidateCredentials) == null ? void 0 : s.call(r, "tokens")), await t2(r, e);
2448
+ throw i;
2449
+ }
2450
+ }
2451
+ async function Vt(r, e, t) {
2452
+ const s = kt(r);
2453
+ if (e.validateResourceURL)
2454
+ return await e.validateResourceURL(
2455
+ s,
2456
+ t?.resource
2457
+ );
2458
+ if (t) {
2459
+ if (!It({
2460
+ requestedResource: s,
2461
+ configuredResource: t.resource
2462
+ }))
2463
+ throw new Error(
2464
+ `Protected resource ${t.resource} does not match expected ${s} (or origin)`
2465
+ );
2466
+ return new URL(t.resource);
2467
+ }
2468
+ }
2469
+ async function t2(r, {
2470
+ serverUrl: e,
2471
+ authorizationCode: t,
2472
+ scope: s,
2473
+ resourceMetadataUrl: i,
2474
+ fetchFn: n
2475
+ }) {
2476
+ let a, l;
2477
+ try {
2478
+ a = await $t(
2479
+ e,
2480
+ { resourceMetadataUrl: i },
2481
+ n
2482
+ ), a.authorization_servers && a.authorization_servers.length > 0 && (l = a.authorization_servers[0]);
2483
+ } catch {
2484
+ }
2485
+ l || (l = e);
2486
+ const h = await Vt(
2487
+ e,
2488
+ r,
2489
+ a
2490
+ ), c = await jt(
2491
+ l,
2492
+ {
2493
+ fetchFn: n
2494
+ }
2495
+ );
2496
+ let d = await Promise.resolve(r.clientInformation());
2497
+ if (!d) {
2498
+ if (t !== void 0)
2499
+ throw new Error(
2500
+ "Existing OAuth client information is required when exchanging an authorization code"
2501
+ );
2502
+ if (!r.saveClientInformation)
2503
+ throw new Error(
2504
+ "OAuth client information must be saveable for dynamic registration"
2505
+ );
2506
+ const u = await Bt(l, {
2507
+ metadata: c,
2508
+ clientMetadata: r.clientMetadata,
2509
+ fetchFn: n
2510
+ });
2511
+ await r.saveClientInformation(u), d = u;
2512
+ }
2513
+ if (t !== void 0) {
2514
+ const u = await r.codeVerifier(), m = await Dt(l, {
2515
+ metadata: c,
2516
+ clientInformation: d,
2517
+ authorizationCode: t,
2518
+ codeVerifier: u,
2519
+ redirectUri: r.redirectUrl,
2520
+ resource: h,
2521
+ addClientAuthentication: r.addClientAuthentication,
2522
+ fetchFn: n
2523
+ });
2524
+ return await r.saveTokens(m), "AUTHORIZED";
2525
+ }
2526
+ const g = await r.tokens();
2527
+ if (g?.refresh_token)
2528
+ try {
2529
+ const u = await Ft(l, {
2530
+ metadata: c,
2531
+ clientInformation: d,
2532
+ refreshToken: g.refresh_token,
2533
+ resource: h,
2534
+ addClientAuthentication: r.addClientAuthentication,
2535
+ fetchFn: n
2536
+ });
2537
+ return await r.saveTokens(u), "AUTHORIZED";
2538
+ } catch (u) {
2539
+ if (
2540
+ // If this is a ServerError, or an unknown type, log it out and try to continue. Otherwise, escalate so we can fix things and retry.
2541
+ !(!(u instanceof j) || u instanceof O)
2542
+ ) throw u;
2543
+ }
2544
+ const p = r.state ? await r.state() : void 0, { authorizationUrl: C, codeVerifier: f } = await Ht(
2545
+ l,
2546
+ {
2547
+ metadata: c,
2548
+ clientInformation: d,
2549
+ state: p,
2550
+ redirectUrl: r.redirectUrl,
2551
+ scope: s || r.clientMetadata.scope,
2552
+ resource: h
2553
+ }
2554
+ );
2555
+ return await r.saveCodeVerifier(f), await r.redirectToAuthorization(C), "REDIRECT";
2556
+ }
2557
+ var Jt = class {
2558
+ constructor({
2559
+ url: r,
2560
+ headers: e,
2561
+ authProvider: t
2562
+ }) {
2563
+ this.connected = !1, this.url = new URL(r), this.headers = e, this.authProvider = t;
2564
+ }
2565
+ async commonHeaders(r) {
2566
+ const e = {
2567
+ ...this.headers,
2568
+ ...r,
2569
+ "mcp-protocol-version": $
2570
+ };
2571
+ if (this.authProvider) {
2572
+ const t = await this.authProvider.tokens();
2573
+ t?.access_token && (e.Authorization = `Bearer ${t.access_token}`);
2574
+ }
2575
+ return A2(
2576
+ e,
2577
+ `ai-sdk/${F2}`,
2578
+ U2()
2579
+ );
2580
+ }
2581
+ async start() {
2582
+ return new Promise((r, e) => {
2583
+ if (this.connected)
2584
+ return r();
2585
+ this.abortController = new AbortController();
2586
+ const t = async (s = !1) => {
2587
+ var i, n, a, l, h;
2588
+ try {
2589
+ const c = await this.commonHeaders({
2590
+ Accept: "text/event-stream"
2591
+ }), d = await fetch(this.url.href, {
2592
+ headers: c,
2593
+ signal: (i = this.abortController) == null ? void 0 : i.signal
2594
+ });
2595
+ if (d.status === 401 && this.authProvider && !s) {
2596
+ this.resourceMetadataUrl = J(d);
2597
+ try {
2598
+ if (await W(this.authProvider, {
2599
+ serverUrl: this.url,
2600
+ resourceMetadataUrl: this.resourceMetadataUrl
2601
+ }) !== "AUTHORIZED") {
2602
+ const u = new V();
2603
+ return (n = this.onerror) == null || n.call(this, u), e(u);
2604
+ }
2605
+ } catch (f) {
2606
+ return (a = this.onerror) == null || a.call(this, f), e(f);
2607
+ }
2608
+ return t(!0);
2609
+ }
2610
+ if (!d.ok || !d.body) {
2611
+ let f = `MCP SSE Transport Error: ${d.status} ${d.statusText}`;
2612
+ d.status === 405 && (f += ". This server does not support SSE transport. Try using `http` transport instead");
2613
+ const u = new y({
2614
+ message: f
2615
+ });
2616
+ return (l = this.onerror) == null || l.call(this, u), e(u);
2617
+ }
2618
+ const p = d.body.pipeThrough(new TextDecoderStream()).pipeThrough(new o2()).getReader(), C = async () => {
2619
+ var f, u, m;
2620
+ try {
2621
+ for (; ; ) {
2622
+ const { done: w, value: v } = await p.read();
2623
+ if (w) {
2624
+ if (this.connected)
2625
+ throw this.connected = !1, new y({
2626
+ message: "MCP SSE Transport Error: Connection closed unexpectedly"
2627
+ });
2628
+ return;
2629
+ }
2630
+ const { event: _, data: S } = v;
2631
+ if (_ === "endpoint") {
2632
+ if (this.endpoint = new URL(S, this.url), this.endpoint.origin !== this.url.origin)
2633
+ throw new y({
2634
+ message: `MCP SSE Transport Error: Endpoint origin does not match connection origin: ${this.endpoint.origin}`
2635
+ });
2636
+ this.connected = !0, r();
2637
+ } else if (_ === "message")
2638
+ try {
2639
+ const L = q.parse(
2640
+ JSON.parse(S)
2641
+ );
2642
+ (f = this.onmessage) == null || f.call(this, L);
2643
+ } catch (L) {
2644
+ const b = new y({
2645
+ message: "MCP SSE Transport Error: Failed to parse message",
2646
+ cause: L
2647
+ });
2648
+ (u = this.onerror) == null || u.call(this, b);
2649
+ }
2650
+ }
2651
+ } catch (w) {
2652
+ if (w instanceof Error && w.name === "AbortError")
2653
+ return;
2654
+ (m = this.onerror) == null || m.call(this, w), e(w);
2655
+ }
2656
+ };
2657
+ this.sseConnection = {
2658
+ close: () => p.cancel()
2659
+ }, C();
2660
+ } catch (c) {
2661
+ if (c instanceof Error && c.name === "AbortError")
2662
+ return;
2663
+ (h = this.onerror) == null || h.call(this, c), e(c);
2664
+ }
2665
+ };
2666
+ t();
2667
+ });
2668
+ }
2669
+ async close() {
2670
+ var r, e, t;
2671
+ this.connected = !1, (r = this.sseConnection) == null || r.close(), (e = this.abortController) == null || e.abort(), (t = this.onclose) == null || t.call(this);
2672
+ }
2673
+ async send(r) {
2674
+ if (!this.endpoint || !this.connected)
2675
+ throw new y({
2676
+ message: "MCP SSE Transport Error: Not connected"
2677
+ });
2678
+ const e = this.endpoint, t = async (s = !1) => {
2679
+ var i, n, a, l, h;
2680
+ try {
2681
+ const d = {
2682
+ method: "POST",
2683
+ headers: await this.commonHeaders({
2684
+ "Content-Type": "application/json"
2685
+ }),
2686
+ body: JSON.stringify(r),
2687
+ signal: (i = this.abortController) == null ? void 0 : i.signal
2688
+ }, g = await fetch(e, d);
2689
+ if (g.status === 401 && this.authProvider && !s) {
2690
+ this.resourceMetadataUrl = J(g);
2691
+ try {
2692
+ if (await W(this.authProvider, {
2693
+ serverUrl: this.url,
2694
+ resourceMetadataUrl: this.resourceMetadataUrl
2695
+ }) !== "AUTHORIZED") {
2696
+ const C = new V();
2697
+ (n = this.onerror) == null || n.call(this, C);
2698
+ return;
2699
+ }
2700
+ } catch (p) {
2701
+ (a = this.onerror) == null || a.call(this, p);
2702
+ return;
2703
+ }
2704
+ return t(!0);
2705
+ }
2706
+ if (!g.ok) {
2707
+ const p = await g.text().catch(() => null), C = new y({
2708
+ message: `MCP SSE Transport Error: POSTing to endpoint (HTTP ${g.status}): ${p}`
2709
+ });
2710
+ (l = this.onerror) == null || l.call(this, C);
2711
+ return;
2712
+ }
2713
+ } catch (c) {
2714
+ (h = this.onerror) == null || h.call(this, c);
2715
+ return;
2716
+ }
2717
+ };
2718
+ await t();
2719
+ }
2720
+ }, Wt = class {
2721
+ constructor({
2722
+ url: r,
2723
+ headers: e,
2724
+ authProvider: t
2725
+ }) {
2726
+ this.inboundReconnectAttempts = 0, this.reconnectionOptions = {
2727
+ initialReconnectionDelay: 1e3,
2728
+ maxReconnectionDelay: 3e4,
2729
+ reconnectionDelayGrowFactor: 1.5,
2730
+ maxRetries: 2
2731
+ }, this.url = new URL(r), this.headers = e, this.authProvider = t;
2732
+ }
2733
+ async commonHeaders(r) {
2734
+ const e = {
2735
+ ...this.headers,
2736
+ ...r,
2737
+ "mcp-protocol-version": $
2738
+ };
2739
+ if (this.sessionId && (e["mcp-session-id"] = this.sessionId), this.authProvider) {
2740
+ const t = await this.authProvider.tokens();
2741
+ t?.access_token && (e.Authorization = `Bearer ${t.access_token}`);
2742
+ }
2743
+ return A2(
2744
+ e,
2745
+ `ai-sdk/${F2}`,
2746
+ U2()
2747
+ );
2748
+ }
2749
+ async start() {
2750
+ if (this.abortController)
2751
+ throw new y({
2752
+ message: "MCP HTTP Transport Error: Transport already started. Note: client.connect() calls start() automatically."
2753
+ });
2754
+ this.abortController = new AbortController(), this.openInboundSse();
2755
+ }
2756
+ async close() {
2757
+ var r, e, t;
2758
+ (r = this.inboundSseConnection) == null || r.close();
2759
+ try {
2760
+ if (this.sessionId && this.abortController && !this.abortController.signal.aborted) {
2761
+ const s = await this.commonHeaders({});
2762
+ await fetch(this.url, {
2763
+ method: "DELETE",
2764
+ headers: s,
2765
+ signal: this.abortController.signal
2766
+ }).catch(() => {
2767
+ });
2768
+ }
2769
+ } catch {
2770
+ }
2771
+ (e = this.abortController) == null || e.abort(), (t = this.onclose) == null || t.call(this);
2772
+ }
2773
+ async send(r) {
2774
+ const e = async (t = !1) => {
2775
+ var s, i, n, a, l, h, c;
2776
+ try {
2777
+ const g = {
2778
+ method: "POST",
2779
+ headers: await this.commonHeaders({
2780
+ "Content-Type": "application/json",
2781
+ Accept: "application/json, text/event-stream"
2782
+ }),
2783
+ body: JSON.stringify(r),
2784
+ signal: (s = this.abortController) == null ? void 0 : s.signal
2785
+ }, p = await fetch(this.url, g), C = p.headers.get("mcp-session-id");
2786
+ if (C && (this.sessionId = C), p.status === 401 && this.authProvider && !t) {
2787
+ this.resourceMetadataUrl = J(p);
2788
+ try {
2789
+ if (await W(this.authProvider, {
2790
+ serverUrl: this.url,
2791
+ resourceMetadataUrl: this.resourceMetadataUrl
2792
+ }) !== "AUTHORIZED")
2793
+ throw new V();
2794
+ } catch (m) {
2795
+ throw (i = this.onerror) == null || i.call(this, m), m;
2796
+ }
2797
+ return e(!0);
2798
+ }
2799
+ if (p.status === 202) {
2800
+ this.inboundSseConnection || this.openInboundSse();
2801
+ return;
2802
+ }
2803
+ if (!p.ok) {
2804
+ const m = await p.text().catch(() => null);
2805
+ let w = `MCP HTTP Transport Error: POSTing to endpoint (HTTP ${p.status}): ${m}`;
2806
+ p.status === 404 && (w += ". This server does not support HTTP transport. Try using `sse` transport instead");
2807
+ const v = new y({
2808
+ message: w
2809
+ });
2810
+ throw (n = this.onerror) == null || n.call(this, v), v;
2811
+ }
2812
+ const f = p.headers.get("content-type") || "";
2813
+ if (f.includes("application/json")) {
2814
+ const m = await p.json(), w = Array.isArray(m) ? m.map((v) => q.parse(v)) : [q.parse(m)];
2815
+ for (const v of w) (a = this.onmessage) == null || a.call(this, v);
2816
+ return;
2817
+ }
2818
+ if (f.includes("text/event-stream")) {
2819
+ if (!p.body) {
2820
+ const _ = new y({
2821
+ message: "MCP HTTP Transport Error: text/event-stream response without body"
2822
+ });
2823
+ throw (l = this.onerror) == null || l.call(this, _), _;
2824
+ }
2825
+ const w = p.body.pipeThrough(new TextDecoderStream()).pipeThrough(new o2()).getReader();
2826
+ (async () => {
2827
+ var _, S, L;
2828
+ try {
2829
+ for (; ; ) {
2830
+ const { done: b, value: E } = await w.read();
2831
+ if (b) return;
2832
+ const { event: U, data: R } = E;
2833
+ if (U === "message")
2834
+ try {
2835
+ const P = q.parse(JSON.parse(R));
2836
+ (_ = this.onmessage) == null || _.call(this, P);
2837
+ } catch (P) {
2838
+ const Q = new y({
2839
+ message: "MCP HTTP Transport Error: Failed to parse message",
2840
+ cause: P
2841
+ });
2842
+ (S = this.onerror) == null || S.call(this, Q);
2843
+ }
2844
+ }
2845
+ } catch (b) {
2846
+ if (b instanceof Error && b.name === "AbortError")
2847
+ return;
2848
+ (L = this.onerror) == null || L.call(this, b);
2849
+ }
2850
+ })();
2851
+ return;
2852
+ }
2853
+ const u = new y({
2854
+ message: `MCP HTTP Transport Error: Unexpected content type: ${f}`
2855
+ });
2856
+ throw (h = this.onerror) == null || h.call(this, u), u;
2857
+ } catch (d) {
2858
+ throw (c = this.onerror) == null || c.call(this, d), d;
2859
+ }
2860
+ };
2861
+ await e();
2862
+ }
2863
+ getNextReconnectionDelay(r) {
2864
+ const {
2865
+ initialReconnectionDelay: e,
2866
+ reconnectionDelayGrowFactor: t,
2867
+ maxReconnectionDelay: s
2868
+ } = this.reconnectionOptions;
2869
+ return Math.min(
2870
+ e * Math.pow(t, r),
2871
+ s
2872
+ );
2873
+ }
2874
+ scheduleInboundSseReconnection() {
2875
+ var r;
2876
+ const { maxRetries: e } = this.reconnectionOptions;
2877
+ if (e > 0 && this.inboundReconnectAttempts >= e) {
2878
+ (r = this.onerror) == null || r.call(
2879
+ this,
2880
+ new y({
2881
+ message: `MCP HTTP Transport Error: Maximum reconnection attempts (${e}) exceeded.`
2882
+ })
2883
+ );
2884
+ return;
2885
+ }
2886
+ const t = this.getNextReconnectionDelay(this.inboundReconnectAttempts);
2887
+ this.inboundReconnectAttempts += 1, setTimeout(async () => {
2888
+ var s;
2889
+ (s = this.abortController) != null && s.signal.aborted || await this.openInboundSse(!1, this.lastInboundEventId);
2890
+ }, t);
2891
+ }
2892
+ // Open optional inbound SSE stream; best-effort and resumable
2893
+ async openInboundSse(r = !1, e) {
2894
+ var t, s, i, n, a, l;
2895
+ try {
2896
+ const h = await this.commonHeaders({
2897
+ Accept: "text/event-stream"
2898
+ });
2899
+ e && (h["last-event-id"] = e);
2900
+ const c = await fetch(this.url.href, {
2901
+ method: "GET",
2902
+ headers: h,
2903
+ signal: (t = this.abortController) == null ? void 0 : t.signal
2904
+ }), d = c.headers.get("mcp-session-id");
2905
+ if (d && (this.sessionId = d), c.status === 401 && this.authProvider && !r) {
2906
+ this.resourceMetadataUrl = J(c);
2907
+ try {
2908
+ if (await W(this.authProvider, {
2909
+ serverUrl: this.url,
2910
+ resourceMetadataUrl: this.resourceMetadataUrl
2911
+ }) !== "AUTHORIZED") {
2912
+ const u = new V();
2913
+ (s = this.onerror) == null || s.call(this, u);
2914
+ return;
2915
+ }
2916
+ } catch (f) {
2917
+ (i = this.onerror) == null || i.call(this, f);
2918
+ return;
2919
+ }
2920
+ return this.openInboundSse(!0, e);
2921
+ }
2922
+ if (c.status === 405)
2923
+ return;
2924
+ if (!c.ok || !c.body) {
2925
+ const f = new y({
2926
+ message: `MCP HTTP Transport Error: GET SSE failed: ${c.status} ${c.statusText}`
2927
+ });
2928
+ (n = this.onerror) == null || n.call(this, f);
2929
+ return;
2930
+ }
2931
+ const p = c.body.pipeThrough(new TextDecoderStream()).pipeThrough(new o2()).getReader(), C = async () => {
2932
+ var f, u, m, w;
2933
+ try {
2934
+ for (; ; ) {
2935
+ const { done: v, value: _ } = await p.read();
2936
+ if (v) return;
2937
+ const { event: S, data: L, id: b } = _;
2938
+ if (b && (this.lastInboundEventId = b), S === "message")
2939
+ try {
2940
+ const E = q.parse(JSON.parse(L));
2941
+ (f = this.onmessage) == null || f.call(this, E);
2942
+ } catch (E) {
2943
+ const U = new y({
2944
+ message: "MCP HTTP Transport Error: Failed to parse message",
2945
+ cause: E
2946
+ });
2947
+ (u = this.onerror) == null || u.call(this, U);
2948
+ }
2949
+ }
2950
+ } catch (v) {
2951
+ if (v instanceof Error && v.name === "AbortError")
2952
+ return;
2953
+ (m = this.onerror) == null || m.call(this, v), (w = this.abortController) != null && w.signal.aborted || this.scheduleInboundSseReconnection();
2954
+ }
2955
+ };
2956
+ this.inboundSseConnection = {
2957
+ close: () => p.cancel()
2958
+ }, this.inboundReconnectAttempts = 0, C();
2959
+ } catch (h) {
2960
+ if (h instanceof Error && h.name === "AbortError")
2961
+ return;
2962
+ (a = this.onerror) == null || a.call(this, h), (l = this.abortController) != null && l.signal.aborted || this.scheduleInboundSseReconnection();
2963
+ }
2964
+ }
2965
+ };
2966
+ function Gt(r) {
2967
+ switch (r.type) {
2968
+ case "sse":
2969
+ return new Jt(r);
2970
+ case "http":
2971
+ return new Wt(r);
2972
+ default:
2973
+ throw new y({
2974
+ message: "Unsupported or invalid transport configuration. If you are using a custom transport, make sure it implements the MCPTransport interface."
2975
+ });
2976
+ }
2977
+ }
2978
+ function Yt(r) {
2979
+ return "start" in r && typeof r.start == "function" && "send" in r && typeof r.send == "function" && "close" in r && typeof r.close == "function";
2980
+ }
2981
+ var Kt = "1.0.0";
2982
+ async function Qt(r) {
2983
+ const e = new Xt(r);
2984
+ return await e.init(), e;
2985
+ }
2986
+ var Xt = class {
2987
+ constructor({
2988
+ transport: r,
2989
+ name: e = "ai-sdk-mcp-client",
2990
+ version: t = Kt,
2991
+ onUncaughtError: s,
2992
+ capabilities: i
2993
+ }) {
2994
+ this.requestMessageId = 0, this.responseHandlers = /* @__PURE__ */ new Map(), this.serverCapabilities = {}, this.isClosed = !0, this.onUncaughtError = s, this.clientCapabilities = i ?? {}, Yt(r) ? this.transport = r : this.transport = Gt(r), this.transport.onclose = () => this.onClose(), this.transport.onerror = (n) => this.onError(n), this.transport.onmessage = (n) => {
2995
+ if ("method" in n) {
2996
+ "id" in n ? this.onRequestMessage(n) : this.onError(
2997
+ new y({
2998
+ message: "Unsupported message type"
2999
+ })
3000
+ );
3001
+ return;
3002
+ }
3003
+ this.onResponse(n);
3004
+ }, this.clientInfo = {
3005
+ name: e,
3006
+ version: t
3007
+ };
3008
+ }
3009
+ async init() {
3010
+ try {
3011
+ await this.transport.start(), this.isClosed = !1;
3012
+ const r = await this.request({
3013
+ request: {
3014
+ method: "initialize",
3015
+ params: {
3016
+ protocolVersion: $,
3017
+ capabilities: this.clientCapabilities,
3018
+ clientInfo: this.clientInfo
3019
+ }
3020
+ },
3021
+ resultSchema: tt
3022
+ });
3023
+ if (r === void 0)
3024
+ throw new y({
3025
+ message: "Server sent invalid initialize result"
3026
+ });
3027
+ if (!Qe.includes(r.protocolVersion))
3028
+ throw new y({
3029
+ message: `Server's protocol version is not supported: ${r.protocolVersion}`
3030
+ });
3031
+ return this.serverCapabilities = r.capabilities, await this.notification({
3032
+ method: "notifications/initialized"
3033
+ }), this;
3034
+ } catch (r) {
3035
+ throw await this.close(), r;
3036
+ }
3037
+ }
3038
+ async close() {
3039
+ var r;
3040
+ this.isClosed || (await ((r = this.transport) == null ? void 0 : r.close()), this.onClose());
3041
+ }
3042
+ assertCapability(r) {
3043
+ switch (r) {
3044
+ case "initialize":
3045
+ break;
3046
+ case "tools/list":
3047
+ case "tools/call":
3048
+ if (!this.serverCapabilities.tools)
3049
+ throw new y({
3050
+ message: "Server does not support tools"
3051
+ });
3052
+ break;
3053
+ case "resources/list":
3054
+ case "resources/read":
3055
+ case "resources/templates/list":
3056
+ if (!this.serverCapabilities.resources)
3057
+ throw new y({
3058
+ message: "Server does not support resources"
3059
+ });
3060
+ break;
3061
+ case "prompts/list":
3062
+ case "prompts/get":
3063
+ if (!this.serverCapabilities.prompts)
3064
+ throw new y({
3065
+ message: "Server does not support prompts"
3066
+ });
3067
+ break;
3068
+ default:
3069
+ throw new y({
3070
+ message: `Unsupported method: ${r}`
3071
+ });
3072
+ }
3073
+ }
3074
+ async request({
3075
+ request: r,
3076
+ resultSchema: e,
3077
+ options: t
3078
+ }) {
3079
+ return new Promise((s, i) => {
3080
+ if (this.isClosed)
3081
+ return i(
3082
+ new y({
3083
+ message: "Attempted to send a request from a closed client"
3084
+ })
3085
+ );
3086
+ this.assertCapability(r.method);
3087
+ const n = t?.signal;
3088
+ n?.throwIfAborted();
3089
+ const a = this.requestMessageId++, l = {
3090
+ ...r,
3091
+ jsonrpc: "2.0",
3092
+ id: a
3093
+ }, h = () => {
3094
+ this.responseHandlers.delete(a);
3095
+ };
3096
+ this.responseHandlers.set(a, (c) => {
3097
+ if (n?.aborted)
3098
+ return i(
3099
+ new y({
3100
+ message: "Request was aborted",
3101
+ cause: n.reason
3102
+ })
3103
+ );
3104
+ if (c instanceof Error)
3105
+ return i(c);
3106
+ try {
3107
+ const d = e.parse(c.result);
3108
+ s(d);
3109
+ } catch (d) {
3110
+ const g = new y({
3111
+ message: "Failed to parse server response",
3112
+ cause: d
3113
+ });
3114
+ i(g);
3115
+ }
3116
+ }), this.transport.send(l).catch((c) => {
3117
+ h(), i(c);
3118
+ });
3119
+ });
3120
+ }
3121
+ async listTools({
3122
+ params: r,
3123
+ options: e
3124
+ } = {}) {
3125
+ try {
3126
+ return this.request({
3127
+ request: { method: "tools/list", params: r },
3128
+ resultSchema: st,
3129
+ options: e
3130
+ });
3131
+ } catch (t) {
3132
+ throw t;
3133
+ }
3134
+ }
3135
+ async callTool({
3136
+ name: r,
3137
+ args: e,
3138
+ options: t
3139
+ }) {
3140
+ try {
3141
+ return this.request({
3142
+ request: { method: "tools/call", params: { name: r, arguments: e } },
3143
+ resultSchema: nt,
3144
+ options: {
3145
+ signal: t?.abortSignal
3146
+ }
3147
+ });
3148
+ } catch (s) {
3149
+ throw s;
3150
+ }
3151
+ }
3152
+ async listResourcesInternal({
3153
+ params: r,
3154
+ options: e
3155
+ } = {}) {
3156
+ try {
3157
+ return this.request({
3158
+ request: { method: "resources/list", params: r },
3159
+ resultSchema: it,
3160
+ options: e
3161
+ });
3162
+ } catch (t) {
3163
+ throw t;
3164
+ }
3165
+ }
3166
+ async readResourceInternal({
3167
+ uri: r,
3168
+ options: e
3169
+ }) {
3170
+ try {
3171
+ return this.request({
3172
+ request: { method: "resources/read", params: { uri: r } },
3173
+ resultSchema: lt,
3174
+ options: e
3175
+ });
3176
+ } catch (t) {
3177
+ throw t;
3178
+ }
3179
+ }
3180
+ async listResourceTemplatesInternal({
3181
+ options: r
3182
+ } = {}) {
3183
+ try {
3184
+ return this.request({
3185
+ request: { method: "resources/templates/list" },
3186
+ resultSchema: ct,
3187
+ options: r
3188
+ });
3189
+ } catch (e) {
3190
+ throw e;
3191
+ }
3192
+ }
3193
+ async listPromptsInternal({
3194
+ params: r,
3195
+ options: e
3196
+ } = {}) {
3197
+ try {
3198
+ return this.request({
3199
+ request: { method: "prompts/list", params: r },
3200
+ resultSchema: pt,
3201
+ options: e
3202
+ });
3203
+ } catch (t) {
3204
+ throw t;
3205
+ }
3206
+ }
3207
+ async getPromptInternal({
3208
+ name: r,
3209
+ args: e,
3210
+ options: t
3211
+ }) {
3212
+ try {
3213
+ return this.request({
3214
+ request: { method: "prompts/get", params: { name: r, arguments: e } },
3215
+ resultSchema: mt,
3216
+ options: t
3217
+ });
3218
+ } catch (s) {
3219
+ throw s;
3220
+ }
3221
+ }
3222
+ async notification(r) {
3223
+ const e = {
3224
+ ...r,
3225
+ jsonrpc: "2.0"
3226
+ };
3227
+ await this.transport.send(e);
3228
+ }
3229
+ /**
3230
+ * Returns a set of AI SDK tools from the MCP server
3231
+ * @returns A record of tool names to their implementations
3232
+ */
3233
+ async tools({
3234
+ schemas: r = "automatic"
3235
+ } = {}) {
3236
+ var e;
3237
+ const t = {};
3238
+ try {
3239
+ const s = await this.listTools();
3240
+ for (const { name: i, description: n, inputSchema: a } of s.tools) {
3241
+ if (r !== "automatic" && !(i in r))
3242
+ continue;
3243
+ const l = this, h = async (d, g) => {
3244
+ var p;
3245
+ return (p = g?.abortSignal) == null || p.throwIfAborted(), l.callTool({ name: i, args: d, options: g });
3246
+ }, c = r === "automatic" ? Ze({
3247
+ description: n,
3248
+ inputSchema: Fe({
3249
+ ...a,
3250
+ properties: (e = a.properties) != null ? e : {},
3251
+ additionalProperties: !1
3252
+ }),
3253
+ execute: h
3254
+ }) : {
3255
+ description: n,
3256
+ inputSchema: r[i].inputSchema,
3257
+ execute: h
3258
+ };
3259
+ t[i] = c;
3260
+ }
3261
+ return t;
3262
+ } catch (s) {
3263
+ throw s;
3264
+ }
3265
+ }
3266
+ listResources({
3267
+ params: r,
3268
+ options: e
3269
+ } = {}) {
3270
+ return this.listResourcesInternal({ params: r, options: e });
3271
+ }
3272
+ readResource({
3273
+ uri: r,
3274
+ options: e
3275
+ }) {
3276
+ return this.readResourceInternal({ uri: r, options: e });
3277
+ }
3278
+ listResourceTemplates({
3279
+ options: r
3280
+ } = {}) {
3281
+ return this.listResourceTemplatesInternal({ options: r });
3282
+ }
3283
+ listPrompts({
3284
+ params: r,
3285
+ options: e
3286
+ } = {}) {
3287
+ return this.listPromptsInternal({ params: r, options: e });
3288
+ }
3289
+ getPrompt({
3290
+ name: r,
3291
+ arguments: e,
3292
+ options: t
3293
+ }) {
3294
+ return this.getPromptInternal({ name: r, args: e, options: t });
3295
+ }
3296
+ onElicitationRequest(r, e) {
3297
+ if (r !== S2)
3298
+ throw new y({
3299
+ message: "Unsupported request schema. Only ElicitationRequestSchema is supported."
3300
+ });
3301
+ this.elicitationRequestHandler = e;
3302
+ }
3303
+ async onRequestMessage(r) {
3304
+ try {
3305
+ if (r.method !== "elicitation/create") {
3306
+ await this.transport.send({
3307
+ jsonrpc: "2.0",
3308
+ id: r.id,
3309
+ error: {
3310
+ code: -32601,
3311
+ message: `Unsupported request method: ${r.method}`
3312
+ }
3313
+ });
3314
+ return;
3315
+ }
3316
+ if (!this.elicitationRequestHandler) {
3317
+ await this.transport.send({
3318
+ jsonrpc: "2.0",
3319
+ id: r.id,
3320
+ error: {
3321
+ code: -32601,
3322
+ message: "No elicitation handler registered on client"
3323
+ }
3324
+ });
3325
+ return;
3326
+ }
3327
+ const e = S2.safeParse({
3328
+ method: r.method,
3329
+ params: r.params
3330
+ });
3331
+ if (!e.success) {
3332
+ await this.transport.send({
3333
+ jsonrpc: "2.0",
3334
+ id: r.id,
3335
+ error: {
3336
+ code: -32602,
3337
+ message: `Invalid elicitation request: ${e.error.message}`,
3338
+ data: e.error.issues
3339
+ }
3340
+ });
3341
+ return;
3342
+ }
3343
+ try {
3344
+ const t = await this.elicitationRequestHandler(e.data), s = ft.parse(t);
3345
+ await this.transport.send({
3346
+ jsonrpc: "2.0",
3347
+ id: r.id,
3348
+ result: s
3349
+ });
3350
+ } catch (t) {
3351
+ await this.transport.send({
3352
+ jsonrpc: "2.0",
3353
+ id: r.id,
3354
+ error: {
3355
+ code: -32603,
3356
+ message: t instanceof Error ? t.message : "Failed to handle elicitation request"
3357
+ }
3358
+ }), this.onError(t);
3359
+ }
3360
+ } catch (e) {
3361
+ this.onError(e);
3362
+ }
3363
+ }
3364
+ onClose() {
3365
+ if (this.isClosed) return;
3366
+ this.isClosed = !0;
3367
+ const r = new y({
3368
+ message: "Connection closed"
3369
+ });
3370
+ for (const e of this.responseHandlers.values())
3371
+ e(r);
3372
+ this.responseHandlers.clear();
3373
+ }
3374
+ onError(r) {
3375
+ this.onUncaughtError && this.onUncaughtError(r);
3376
+ }
3377
+ onResponse(r) {
3378
+ const e = Number(r.id), t = this.responseHandlers.get(e);
3379
+ if (t === void 0)
3380
+ throw new y({
3381
+ message: `Protocol error: Received a response for an unknown message ID: ${JSON.stringify(
3382
+ r
3383
+ )}`
3384
+ });
3385
+ this.responseHandlers.delete(e), t(
3386
+ "result" in r ? r : new y({
3387
+ message: r.error.message,
3388
+ code: r.error.code,
3389
+ data: r.error.data,
3390
+ cause: r.error
3391
+ })
3392
+ );
3393
+ }
3394
+ };
3395
+ const e0 = async (r) => {
3396
+ const e = {};
3397
+ try {
3398
+ const t = await r.listTools();
3399
+ for (const { name: s, description: i, inputSchema: n } of t.tools) {
3400
+ const a = async (l, h) => r.callTool({ name: s, arguments: l }, { signal: h?.abortSignal });
3401
+ e[s] = ye({
3402
+ description: i,
3403
+ inputSchema: ve({
3404
+ ...n,
3405
+ properties: n.properties ?? {},
3406
+ additionalProperties: !1
3407
+ }),
3408
+ execute: a
3409
+ });
3410
+ }
3411
+ return e;
3412
+ } catch (t) {
3413
+ throw t;
3414
+ }
3415
+ };
3416
+ function t0(r) {
3417
+ const e = Object.entries(r);
3418
+ if (e.length === 0)
3419
+ return "";
3420
+ let t = `
3421
+
3422
+ # 工具调用
3423
+
3424
+ `;
3425
+ return t += `你可以根据需要调用以下工具:
3426
+
3427
+ `, t += `<tools>
3428
+ `, e.forEach(([s, i]) => {
3429
+ const n = i, a = n.description || "无描述", l = n.parameters || n.inputSchema || {};
3430
+ t += `${JSON.stringify({
3431
+ name: s,
3432
+ description: a,
3433
+ parameters: l
3434
+ }, null, 2)}
3435
+ `;
3436
+ }), t += `</tools>
3437
+
3438
+ `, t += `## 工具调用格式
3439
+
3440
+ `, t += `要调用工具,请使用以下 XML 格式:
3441
+ `, t += `Thought: [你的思考过程]
3442
+ `, t += `<tool_call>{"name": "toolName", "arguments": {"arg1": "value1"}}</tool_call>
3443
+
3444
+ `, t += `工具执行后,你将收到 <tool_response> 格式的结果。你可以继续思考或调用其他工具。
3445
+
3446
+ `, t += `## 使用示例
3447
+
3448
+ `, t += `如果用户要求"获取今天的日期",你可以这样调用工具:
3449
+ `, t += `Thought: 用户想要获取今天的日期,我需要调用日期相关的工具。
3450
+ `, t += `<tool_call>{"name": "get-today", "arguments": {}}</tool_call>
3451
+
3452
+ `, t += `然后等待工具返回结果(Observation),再根据结果给出最终答案。
3453
+
3454
+ `, t += `## 任务完成
3455
+
3456
+ `, t += `当任务完成或无法继续时,直接给出最终答案即可。
3457
+
3458
+ `, t += `**重要提示**:
3459
+ `, t += `- 必须严格按照 XML 格式调用工具
3460
+ `, t += `- arguments 必须是有效的 JSON 格式
3461
+ `, t += `- 如果不需要调用工具,直接给出最终答案即可
3462
+ `, t;
3463
+ }
3464
+ function E2(r, e) {
3465
+ if (!r || typeof r != "string")
3466
+ return null;
3467
+ const t = r.match(/<tool_call>([\s\S]*?)<\/tool_call>/i);
3468
+ if (t)
3469
+ try {
3470
+ const s = t[1].trim(), i = JSON.parse(s), n = i.name || i.action || i.tool, a = i.arguments || i.args || i.input || {};
3471
+ if (n && e[n])
3472
+ return { toolName: n, arguments: a };
3473
+ } catch {
3474
+ }
3475
+ return null;
3476
+ }
3477
+ const r0 = {
3478
+ openai: xe,
3479
+ deepseek: Le
3480
+ };
3481
+ class I0 {
3482
+ constructor({ llmConfig: e, mcpServers: t }) {
3483
+ if (this.mcpServers = {}, this.mcpClients = {}, this.mcpTools = {}, this.ignoreToolnames = [], this.messages = [], this.useReActMode = !1, !e)
3484
+ throw new Error("llmConfig is required to initialize AgentModelProvider");
3485
+ if (this.mcpServers = t || {}, this.mcpClients = {}, this.mcpTools = {}, e.llm)
3486
+ this.llm = e.llm;
3487
+ else if (e.providerType) {
3488
+ const s = e.providerType;
3489
+ let i;
3490
+ typeof s == "string" ? i = r0[s] : i = s, this.llm = i({
3491
+ apiKey: e.apiKey,
3492
+ baseURL: e.baseURL
3493
+ });
3494
+ } else
3495
+ throw new Error("Either llmConfig.llm or llmConfig.providerType must be provided");
3496
+ this.useReActMode = e.useReActMode ?? !1;
3497
+ }
3498
+ /** 创建一个 ai-sdk的 mcpClient, 创建失败则返回 null */
3499
+ async _createOneClient(e) {
3500
+ try {
3501
+ let t;
3502
+ if ("type" in e && e.type.toLocaleLowerCase() === "streamablehttp" ? t = new G(new URL(e.url)) : "type" in e && e.type === "extension" ? t = new w2(e.sessionId) : t = e, e.useAISdkClient ?? !1) {
3503
+ const i = await Qt({ transport: t });
3504
+ return i.__transport__ = t, i;
3505
+ } else {
3506
+ const i = new Se(
3507
+ { name: "mcp-web-client", version: "1.0.0" },
3508
+ { capabilities: { roots: { listChanged: !0 }, sampling: {}, elicitation: {} } }
3509
+ );
3510
+ return await i.connect(t), i.__transport__ = t, i;
3511
+ }
3512
+ } catch (t) {
3513
+ return this.onError && this.onError(t?.message || "Failed to create MCP client", t), console.error("Failed to create MCP client", e, t), null;
3514
+ }
3515
+ }
3516
+ /** 关闭一个 mcpClient */
3517
+ async _closeOneClient(e) {
3518
+ try {
3519
+ const t = e.__transport__;
3520
+ if (t && t instanceof oe || t && t instanceof se || t && t instanceof w2)
3521
+ return;
3522
+ await t?.terminateSession?.(), await t?.close?.(), await e?.close?.();
3523
+ } catch {
3524
+ }
3525
+ }
3526
+ /** 创建所有 mcpClients */
3527
+ async _createMpcClients() {
3528
+ const e = Object.entries(this.mcpServers), t = await Promise.all(
3529
+ e.map(async ([s, i]) => {
3530
+ const n = await this._createOneClient(i);
3531
+ return { serverName: s, client: n };
3532
+ })
3533
+ );
3534
+ this.mcpClients = {}, t.forEach(({ serverName: s, client: i }) => {
3535
+ this.mcpClients[s] = i;
3536
+ });
3537
+ }
3538
+ /** 兼容两种 client 类型的 tools 获取方法 */
3539
+ async _getClientTools(e, t) {
3540
+ if (!e)
3541
+ return null;
3542
+ try {
3543
+ return typeof e.tools == "function" ? await e.tools() : await e0(e);
3544
+ } catch (s) {
3545
+ return this.onError && this.onError(s?.message || `Failed to query tools for ${t}`, s), console.error(`Failed to query tools for ${t}`, s), null;
3546
+ }
3547
+ }
3548
+ /** 查询所有 mcpClients 的 tools, 失败则保存为null */
3549
+ async _createMpcTools() {
3550
+ const e = Object.entries(this.mcpClients), t = await Promise.all(
3551
+ e.map(async ([s, i]) => {
3552
+ const n = await this._getClientTools(i, s);
3553
+ return { serverName: s, tools: n };
3554
+ })
3555
+ );
3556
+ this.mcpTools = {}, t.forEach(({ serverName: s, tools: i }) => {
3557
+ const n = i && typeof i == "object" ? i : {};
3558
+ this.mcpTools[s] = n;
3559
+ });
3560
+ }
3561
+ /** 关闭所有的 clients */
3562
+ async closeAll() {
3563
+ await Promise.all(
3564
+ Object.values(this.mcpClients).map(async (e) => {
3565
+ try {
3566
+ await this._closeOneClient(e);
3567
+ } catch (t) {
3568
+ this.onError && this.onError(t?.message || "Failed to close client", t), console.error("Failed to close client", t);
3569
+ }
3570
+ })
3571
+ );
3572
+ }
3573
+ /** 创建所有的 mcpClients,并更新它们的tools */
3574
+ async initClientsAndTools() {
3575
+ await this._createMpcClients(), await this._createMpcTools(), this.onUpdatedTools?.();
3576
+ }
3577
+ /** 全量更新所有的 mcpServers */
3578
+ async updateMcpServers(e) {
3579
+ await this.closeAll(), this.mcpServers = e || this.mcpServers, await this.initClientsAndTools();
3580
+ }
3581
+ /** 插入一个新的mcpServer,如果已经存在则返回false */
3582
+ async insertMcpServer(e, t) {
3583
+ if (this.mcpServers[e])
3584
+ return !1;
3585
+ const s = await this._createOneClient(t);
3586
+ if (!s)
3587
+ return this.onError?.(`Failed to create MCP client: ${e}`), null;
3588
+ this.mcpClients[e] = s;
3589
+ const i = await this._getClientTools(s, e);
3590
+ return this.mcpTools[e] = i && typeof i == "object" ? i : {}, this.mcpServers[e] = t, this.onUpdatedTools?.(), s;
3591
+ }
3592
+ /** 通过服务器名称删除mcpServer: mcpServers mcpClients mcpTools ignoreToolnames */
3593
+ async removeMcpServer(e) {
3594
+ if (!this.mcpServers[e])
3595
+ return;
3596
+ delete this.mcpServers[e];
3597
+ const t = this.mcpClients[e];
3598
+ delete this.mcpClients[e];
3599
+ try {
3600
+ await this._closeOneClient(t);
3601
+ } catch {
3602
+ }
3603
+ const s = this.mcpTools[e];
3604
+ delete this.mcpTools[e], s && Object.keys(s).forEach((i) => {
3605
+ this.ignoreToolnames = this.ignoreToolnames.filter((n) => n !== i);
3606
+ }), this.onUpdatedTools?.();
3607
+ }
3608
+ /** 创建临时允许调用的tools集合 */
3609
+ _tempMergeTools(e = {}) {
3610
+ const t = Object.values(this.mcpTools).reduce((s, i) => ({ ...s, ...i }), {});
3611
+ return Object.assign(t, e), this.ignoreToolnames.forEach((s) => {
3612
+ delete t[s];
3613
+ }), t;
3614
+ }
3615
+ /** 生成 ReAct 模式的系统提示词(包含工具描述) */
3616
+ _generateReActSystemPrompt(e, t, s) {
3617
+ const i = t0(e);
3618
+ return s ? `${s}${i}` : `你是一个智能助手,可以通过调用工具来完成任务。
3619
+ ${i}`;
3620
+ }
3621
+ /** 执行 ReAct 模式下的工具调用 */
3622
+ async _executeReActToolCall(e, t, s) {
3623
+ const i = s[e];
3624
+ if (!i)
3625
+ return { success: !1, error: `工具 ${e} 不存在` };
3626
+ try {
3627
+ const n = i, a = n.execute || n.call;
3628
+ return typeof a != "function" ? { success: !1, error: `工具 ${e} 没有可执行的函数` } : { success: !0, result: await a(t, {}) };
3629
+ } catch (n) {
3630
+ return { success: !1, error: n?.message || String(n) || "工具执行失败" };
3631
+ }
3632
+ }
3633
+ /** ReAct 模式的对话实现 */
3634
+ async _chatReAct(e, { model: t, maxSteps: s = 5, ...i }) {
3635
+ if (!this.llm)
3636
+ throw new Error("LLM is not initialized");
3637
+ await this.initClientsAndTools();
3638
+ const n = this._tempMergeTools(i.tools);
3639
+ if (Object.keys(n).length === 0)
3640
+ return this._chat(e, { model: t, maxSteps: s, ...i });
3641
+ let l = [];
3642
+ i.message && !i.messages ? l.push({ role: "user", content: i.message }) : i.messages ? l = [...i.messages] : l = [...this.messages];
3643
+ const h = typeof t == "string" ? t : t?.modelId || "default-model", d = { role: "system", content: this._generateReActSystemPrompt(n, h, i.system) }, g = l[0]?.role === "system" ? l : [d, ...l];
3644
+ return e === X ? this._chatReActStream(g, n, h, s, i) : this._chatReActNonStream(g, n, h, s, i);
3645
+ }
3646
+ /**
3647
+ * 检查消息内容是否包含图片
3648
+ * @param content 消息内容
3649
+ * @returns 是否包含图片
3650
+ */
3651
+ _messageHasImage(e) {
3652
+ return e && Array.isArray(e) ? e.some((t) => t && t.type === "image") : !1;
3653
+ }
3654
+ /**
3655
+ * 从消息中移除图片,但保留文本内容
3656
+ * @param message 原始消息
3657
+ * @returns 移除图片后的消息(如果只有图片没有文本,返回 null)
3658
+ */
3659
+ _removeImageFromMessage(e) {
3660
+ if (!e || !e.content)
3661
+ return null;
3662
+ if (!Array.isArray(e.content))
3663
+ return e;
3664
+ const t = e.content.filter((s) => s && s.type !== "image");
3665
+ return t.length === 0 ? null : {
3666
+ ...e,
3667
+ content: t
3668
+ };
3669
+ }
3670
+ /**
3671
+ * 构建用于模型调用的消息列表(magentic-ui 风格)
3672
+ * 策略:保留所有文本消息,仅限制图片数量(类似 magentic-ui 的 maybe_remove_old_screenshots)
3673
+ *
3674
+ * @param systemMessage 系统提示词
3675
+ * @param allMessages 所有消息历史(包括初始消息和后续对话)
3676
+ * @param maxImages 最多保留的图片数量(默认3张)
3677
+ * @returns 构建好的消息列表
3678
+ */
3679
+ _buildMessagesForModel(e, t, s = 3) {
3680
+ const i = [];
3681
+ e && i.push(e);
3682
+ let n = 0;
3683
+ const a = [];
3684
+ for (let l = t.length - 1; l >= 0; l--) {
3685
+ const h = t[l];
3686
+ if (this._messageHasImage(h.content))
3687
+ if (n < s)
3688
+ a.unshift(h), n++;
3689
+ else {
3690
+ const d = this._removeImageFromMessage(h);
3691
+ d && a.unshift(d);
3692
+ }
3693
+ else
3694
+ a.unshift(h);
3695
+ }
3696
+ return i.push(...a), i;
3697
+ }
3698
+ /** ReAct 模式非流式对话 */
3699
+ async _chatReActNonStream(e, t, s, i, n) {
3700
+ let a = [...e];
3701
+ const l = e[0]?.role === "system" ? e[0] : null, h = l ? e.slice(1) : e;
3702
+ let c = 0;
3703
+ const d = n.maxImages ?? 3;
3704
+ for (; c < i; ) {
3705
+ c++;
3706
+ const p = this._buildMessagesForModel(l, h, d), { tools: C, ...f } = n, m = (await f2({
3707
+ // @ts-ignore ProviderV2 是所有llm的父类,在每一个具体的llm类都有一个选择model的函数用法
3708
+ model: this.llm(s),
3709
+ messages: p,
3710
+ ...f
3711
+ })).text, w = { role: "assistant", content: m };
3712
+ h.push(w), a.push(w);
3713
+ const v = E2(m, t);
3714
+ if (!v)
3715
+ return this.messages = a, {
3716
+ text: m,
3717
+ response: { messages: a }
3718
+ };
3719
+ const _ = await this._executeReActToolCall(v.toolName, v.arguments, t), b = {
3720
+ role: "user",
3721
+ content: `<tool_response>
3722
+ ${_.success ? JSON.stringify(_.result) : `工具执行失败 - ${_.error}`}
3723
+ </tool_response>`
3724
+ };
3725
+ h.push(b), a.push(b);
3726
+ }
3727
+ return this.messages = a, {
3728
+ text: a[a.length - 2]?.content || "",
3729
+ response: { messages: a }
3730
+ };
3731
+ }
3732
+ /** ReAct 模式流式对话 */
3733
+ _chatReActStream(e, t, s, i, n) {
3734
+ const a = this, l = this.llm(s);
3735
+ let h, c;
3736
+ const d = new Promise((p, C) => {
3737
+ h = p, c = C;
3738
+ });
3739
+ return {
3740
+ fullStream: new ReadableStream({
3741
+ async start(p) {
3742
+ let C = [...e];
3743
+ const f = e[0]?.role === "system" ? e[0] : null, u = f ? e.slice(1) : [...e];
3744
+ let m = 0, w = "";
3745
+ const v = n.maxImages ?? 3;
3746
+ try {
3747
+ for (; m < i; ) {
3748
+ m++;
3749
+ const _ = a._buildMessagesForModel(f, u, v), { tools: S, ...L } = n;
3750
+ delete L.system;
3751
+ const b = await X({
3752
+ ...L,
3753
+ model: l,
3754
+ messages: _
3755
+ });
3756
+ let E = "";
3757
+ for await (const I of b.fullStream)
3758
+ I.type === "text-delta" ? (E += I.text || "", p.enqueue({
3759
+ type: "text-delta",
3760
+ text: I.text
3761
+ })) : I.type === "text-start" ? p.enqueue({ type: "text-start" }) : I.type === "text-end" || p.enqueue(I);
3762
+ w += E;
3763
+ const U = { role: "assistant", content: w };
3764
+ u.push(U), C.push(U);
3765
+ const R = E2(w, t);
3766
+ if (!R) {
3767
+ p.enqueue({ type: "text-end" }), p.close(), a.messages = C, h({ messages: C });
3768
+ return;
3769
+ }
3770
+ if (R.toolName === "computer" && R.arguments?.action === "terminate") {
3771
+ p.enqueue({ type: "text-end" }), p.close(), a.messages = C, h({ messages: C });
3772
+ return;
3773
+ }
3774
+ const P = `react-${Date.now()}`;
3775
+ p.enqueue({
3776
+ type: "tool-input-start",
3777
+ id: P,
3778
+ toolName: R.toolName
3779
+ });
3780
+ const Q = JSON.stringify(R.arguments, null, 2);
3781
+ p.enqueue({
3782
+ type: "tool-input-delta",
3783
+ id: P,
3784
+ delta: Q
3785
+ });
3786
+ const T = await a._executeReActToolCall(R.toolName, R.arguments, t);
3787
+ let H, k = T.result;
3788
+ if (T.success && T.result && typeof T.result == "object" && T.result.screenshot) {
3789
+ H = T.result.screenshot;
3790
+ const { screenshot: I, ...Y2 } = T.result;
3791
+ k = Y2;
3792
+ }
3793
+ let N = "";
3794
+ T.success ? k && Array.isArray(k.content) && k.content.length > 0 && k.content[0].text ? N = k.content[0].text : N = JSON.stringify(k) : N = `工具执行失败 - ${T.error}`;
3795
+ let z = `<tool_response>
3796
+ ${N}
3797
+ </tool_response>`;
3798
+ H && (z += `
3799
+ 请检查截图以确认操作是否成功。如果成功,请继续下一步;如果失败,请重试。`), p.enqueue({
3800
+ type: "tool-result",
3801
+ toolCallId: P,
3802
+ result: z
3803
+ });
3804
+ const u2 = H ? {
3805
+ role: "user",
3806
+ content: [
3807
+ { type: "text", text: z },
3808
+ { type: "image", image: H }
3809
+ ]
3810
+ } : {
3811
+ role: "user",
3812
+ content: z
3813
+ };
3814
+ u.push(u2), C.push(u2), w = "";
3815
+ }
3816
+ p.enqueue({ type: "text-end" }), p.close(), a.messages = C, h({ messages: C });
3817
+ } catch (_) {
3818
+ p.error(_), c(_);
3819
+ }
3820
+ }
3821
+ }),
3822
+ response: d
3823
+ };
3824
+ }
3825
+ async _chat(e, { model: t, maxSteps: s = 5, ...i }) {
3826
+ if (this.useReActMode)
3827
+ return this._chatReAct(e, { model: t, maxSteps: s, ...i });
3828
+ if (!this.llm)
3829
+ throw new Error("LLM is not initialized");
3830
+ await this.initClientsAndTools();
3831
+ const n = {
3832
+ // @ts-ignore ProviderV2 是所有llm的父类, 在每一个具体的llm 类都有一个选择model的函数用法
3833
+ model: this.llm(t),
3834
+ stopWhen: _e(s),
3835
+ ...i,
3836
+ tools: this._tempMergeTools(i.tools)
3837
+ };
3838
+ i.message && !i.messages && (this.messages.push({ role: "user", content: i.message }), n.messages = [...this.messages]);
3839
+ const a = e(n);
3840
+ return a?.response?.then((l) => {
3841
+ this.messages.push(...l.messages);
3842
+ }), a;
3843
+ }
3844
+ async chat(e) {
3845
+ return this._chat(f2, e);
3846
+ }
3847
+ async chatStream(e) {
3848
+ return this._chat(X, e);
3849
+ }
3850
+ }
3851
+ export {
3852
+ I0 as AgentModelProvider,
3853
+ O0 as Ajv,
3854
+ H0 as AuthClientProvider,
3855
+ P0 as ContentScriptServerTransport,
3856
+ w2 as ExtensionClientTransport,
3857
+ E0 as ExtensionPageServerTransport,
3858
+ G0 as InMemoryTransport,
3859
+ Te as QrCode,
3860
+ z0 as ResourceTemplate,
3861
+ D0 as UriTemplate,
3862
+ Se as WebMcpClient,
3863
+ w0 as WebMcpServer,
3864
+ B0 as completable,
3865
+ S0 as createMessageChannelClientTransport,
3866
+ v0 as createMessageChannelPairTransport,
3867
+ y0 as createMessageChannelServerTransport,
3868
+ k0 as createRemoter,
3869
+ x0 as createSSEClientTransport,
3870
+ L0 as createStreamableHTTPClientTransport,
3871
+ e0 as getAISDKTools,
3872
+ J0 as getDisplayName,
3873
+ M0 as isMcpClient,
3874
+ b0 as isMcpServer,
3875
+ T0 as isMessageChannelClientTransport,
3876
+ _0 as isMessageChannelServerTransport,
3877
+ R0 as isSSEClientTransport,
3878
+ Re as isStreamableHTTPClientTransport,
3879
+ q0 as z
3880
+ };