@opentiny/next-sdk 0.1.15 → 0.2.1

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 (42) hide show
  1. package/WebMcpClient.ts +17 -19
  2. package/WebMcpServer.ts +11 -8
  3. package/agent/AgentModelProvider.ts +495 -2
  4. package/agent/type.ts +9 -3
  5. package/agent/utils/generateReActPrompt.ts +55 -0
  6. package/agent/utils/parseReActAction.ts +34 -0
  7. package/dist/WebMcpClient.d.ts +176 -35
  8. package/dist/WebMcpServer.d.ts +43 -154
  9. package/dist/agent/AgentModelProvider.d.ts +35 -1
  10. package/dist/agent/type.d.ts +9 -2
  11. package/dist/agent/utils/generateReActPrompt.d.ts +9 -0
  12. package/dist/agent/utils/parseReActAction.d.ts +14 -0
  13. package/dist/index.es.dev.js +16154 -12116
  14. package/dist/index.es.js +22208 -19236
  15. package/dist/index.js +2411 -320
  16. package/dist/index.umd.dev.js +16147 -12109
  17. package/dist/index.umd.js +109 -67
  18. package/dist/{mcpsdk@1.23.0.dev.js → mcpsdk@1.25.2.dev.js} +8592 -6902
  19. package/dist/{mcpsdk@1.23.0.es.dev.js → mcpsdk@1.25.2.es.dev.js} +8601 -6911
  20. package/dist/mcpsdk@1.25.2.es.js +16796 -0
  21. package/dist/mcpsdk@1.25.2.js +43 -0
  22. package/dist/transport/ExtensionPageServerTransport.d.ts +1 -2
  23. package/dist/webagent.dev.js +15216 -11451
  24. package/dist/webagent.es.dev.js +15260 -11495
  25. package/dist/webagent.es.js +17923 -15160
  26. package/dist/webagent.js +96 -54
  27. package/dist/webmcp-full.dev.js +9872 -8168
  28. package/dist/webmcp-full.es.dev.js +9870 -8166
  29. package/dist/webmcp-full.es.js +10712 -9513
  30. package/dist/webmcp-full.js +31 -31
  31. package/dist/webmcp.dev.js +666 -640
  32. package/dist/webmcp.es.dev.js +664 -638
  33. package/dist/webmcp.es.js +651 -619
  34. package/dist/webmcp.js +1 -1
  35. package/dist/zod@3.25.76.dev.js +30 -32
  36. package/dist/zod@3.25.76.es.dev.js +28 -30
  37. package/dist/zod@3.25.76.es.js +143 -145
  38. package/dist/zod@3.25.76.js +1 -1
  39. package/package.json +10 -9
  40. package/transport/ExtensionPageServerTransport.ts +2 -4
  41. package/dist/mcpsdk@1.23.0.es.js +0 -15584
  42. package/dist/mcpsdk@1.23.0.js +0 -43
@@ -2,8 +2,8 @@ import { Client, ClientOptions } from '@modelcontextprotocol/sdk/client/index.js
2
2
  import { SSEClientTransport, SSEClientTransportOptions } from '@modelcontextprotocol/sdk/client/sse.js';
3
3
  import { StreamableHTTPClientTransport, StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
4
4
  import { z, ZodObject, ZodLiteral, ZodType } from 'zod';
5
- import { ElicitRequestSchema, ListRootsRequestSchema, CreateMessageRequestSchema, LoggingMessageNotificationSchema, ToolListChangedNotificationSchema, ResourceUpdatedNotificationSchema, PromptListChangedNotificationSchema, ResourceListChangedNotificationSchema, Result, Request, Notification, Implementation, ServerCapabilities, LoggingLevel, CompleteRequest, CallToolRequest, ListToolsRequest, GetPromptRequest, SubscribeRequest, UnsubscribeRequest, ListPromptsRequest, ReadResourceRequest, ListResourcesRequest, ListResourceTemplatesRequest } from '@modelcontextprotocol/sdk/types.js';
6
5
  import { MessageChannelClientTransport } from '@opentiny/next';
6
+ import { Result, Request, Notification, Implementation, ServerCapabilities, LoggingLevel, CompleteRequest, CallToolRequest, ListToolsRequest, GetPromptRequest, SubscribeRequest, UnsubscribeRequest, ListPromptsRequest, ReadResourceRequest, ListResourcesRequest, ListResourceTemplatesRequest, ElicitRequest, CreateMessageRequest, ListRootsRequest, ToolListChangedNotification, PromptListChangedNotification, ResourceListChangedNotification, ResourceUpdatedNotification, LoggingMessageNotification } from '@modelcontextprotocol/sdk/types.js';
7
7
  import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
8
8
  import { RequestOptions, NotificationOptions, RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
9
9
 
@@ -68,7 +68,13 @@ export declare class WebMcpClient {
68
68
  * Sends a ping to the server to check if it is still connected.
69
69
  */
70
70
  ping(options?: RequestOptions): Promise<{
71
- _meta?: Record<string, unknown> | undefined;
71
+ _meta?: {
72
+ [x: string]: unknown;
73
+ progressToken?: string | number | undefined;
74
+ "io.modelcontextprotocol/related-task"?: {
75
+ taskId: string;
76
+ } | undefined;
77
+ } | undefined;
72
78
  }>;
73
79
  /**
74
80
  * Sends a completion request to the server.
@@ -81,13 +87,25 @@ export declare class WebMcpClient {
81
87
  total?: number | undefined;
82
88
  hasMore?: boolean | undefined;
83
89
  };
84
- _meta?: Record<string, unknown> | undefined;
90
+ _meta?: {
91
+ [x: string]: unknown;
92
+ progressToken?: string | number | undefined;
93
+ "io.modelcontextprotocol/related-task"?: {
94
+ taskId: string;
95
+ } | undefined;
96
+ } | undefined;
85
97
  }>;
86
98
  /**
87
99
  * Sends a request for setting the logging level to the server.
88
100
  */
89
101
  setLoggingLevel(level: LoggingLevel, options?: RequestOptions): Promise<{
90
- _meta?: Record<string, unknown> | undefined;
102
+ _meta?: {
103
+ [x: string]: unknown;
104
+ progressToken?: string | number | undefined;
105
+ "io.modelcontextprotocol/related-task"?: {
106
+ taskId: string;
107
+ } | undefined;
108
+ } | undefined;
91
109
  }>;
92
110
  /**
93
111
  * Gets the prompt with the given params from the server.
@@ -99,22 +117,33 @@ export declare class WebMcpClient {
99
117
  content: {
100
118
  type: "text";
101
119
  text: string;
102
- _meta
103
- /**
104
- * Sends a ping to the server to check if it is still connected.
105
- */
106
- ? /**
107
- * Sends a ping to the server to check if it is still connected.
108
- */: Record<string, unknown> | undefined;
120
+ annotations?: {
121
+ audience?: ("user" | "assistant")[] | undefined;
122
+ priority?: number | undefined;
123
+ lastModified?: string | undefined;
124
+ } | undefined;
125
+ _meta?: Record<string, unknown> | undefined;
109
126
  } | {
110
127
  type: "image";
111
128
  data: string;
112
129
  mimeType: string;
130
+ annotations?: {
131
+ audience?: ("user" | "assistant")[] | undefined;
132
+ priority?: number | undefined;
133
+ lastModified?: string | undefined;
134
+ } | undefined;
113
135
  _meta?: Record<string, unknown> | undefined;
114
136
  } | {
115
137
  type: "audio";
116
138
  data: string;
117
139
  mimeType: string;
140
+ annotations?: {
141
+ audience?: ("user" | "assistant")[] | undefined;
142
+ priority? /**
143
+ * Emits a notification, which is a one-way message that does not expect a response.
144
+ */: number | undefined;
145
+ lastModified?: string | undefined;
146
+ } | undefined;
118
147
  _meta?: Record<string, unknown> | undefined;
119
148
  } | {
120
149
  type: "resource";
@@ -129,6 +158,11 @@ export declare class WebMcpClient {
129
158
  mimeType?: string | undefined;
130
159
  _meta?: Record<string, unknown> | undefined;
131
160
  };
161
+ annotations?: {
162
+ audience?: ("user" | "assistant")[] | undefined;
163
+ priority?: number | undefined;
164
+ lastModified?: string | undefined;
165
+ } | undefined;
132
166
  _meta?: Record<string, unknown> | undefined;
133
167
  } | {
134
168
  uri: string;
@@ -136,6 +170,11 @@ export declare class WebMcpClient {
136
170
  type: "resource_link";
137
171
  description?: string | undefined;
138
172
  mimeType?: string | undefined;
173
+ annotations?: {
174
+ audience?: ("user" | "assistant")[] | undefined;
175
+ priority?: number | undefined;
176
+ lastModified?: string | undefined;
177
+ } | undefined;
139
178
  _meta?: {
140
179
  [x: string]: unknown;
141
180
  } | undefined;
@@ -143,11 +182,18 @@ export declare class WebMcpClient {
143
182
  src: string;
144
183
  mimeType?: string | undefined;
145
184
  sizes?: string[] | undefined;
185
+ theme?: "light" | "dark" | undefined;
146
186
  }[] | undefined;
147
187
  title?: string | undefined;
148
188
  };
149
189
  }[];
150
- _meta?: Record<string, unknown> | undefined;
190
+ _meta?: {
191
+ [x: string]: unknown;
192
+ progressToken?: string | number | undefined;
193
+ "io.modelcontextprotocol/related-task"?: {
194
+ taskId: string;
195
+ } | undefined;
196
+ } | undefined;
151
197
  description?: string | undefined;
152
198
  }>;
153
199
  /**
@@ -170,10 +216,17 @@ export declare class WebMcpClient {
170
216
  src: string;
171
217
  mimeType?: string | undefined;
172
218
  sizes?: string[] | undefined;
219
+ theme?: "light" | "dark" | undefined;
173
220
  }[] | undefined;
174
221
  title?: string | undefined;
175
222
  }[];
176
- _meta?: Record<string, unknown> | undefined;
223
+ _meta?: {
224
+ [x: string]: unknown;
225
+ progressToken?: string | number | undefined;
226
+ "io.modelcontextprotocol/related-task"?: {
227
+ taskId: string;
228
+ } | undefined;
229
+ } | undefined;
177
230
  nextCursor?: string | undefined;
178
231
  }>;
179
232
  /**
@@ -185,7 +238,14 @@ export declare class WebMcpClient {
185
238
  uri: string;
186
239
  name: string;
187
240
  description?: string | undefined;
188
- mimeType?: string | undefined;
241
+ mimeType? /**
242
+ * Registers a handler for the resource updated notification.
243
+ */: string | undefined;
244
+ annotations?: {
245
+ audience?: ("user" | "assistant")[] | undefined;
246
+ priority?: number | undefined;
247
+ lastModified?: string | undefined;
248
+ } | undefined;
189
249
  _meta?: {
190
250
  [x: string]: unknown;
191
251
  } | undefined;
@@ -193,10 +253,17 @@ export declare class WebMcpClient {
193
253
  src: string;
194
254
  mimeType?: string | undefined;
195
255
  sizes?: string[] | undefined;
256
+ theme?: "light" | "dark" | undefined;
196
257
  }[] | undefined;
197
258
  title?: string | undefined;
198
259
  }[];
199
- _meta?: Record<string, unknown> | undefined;
260
+ _meta?: {
261
+ [x: string]: unknown;
262
+ progressToken?: string | number | undefined;
263
+ "io.modelcontextprotocol/related-task"?: {
264
+ taskId: string;
265
+ } | undefined;
266
+ } | undefined;
200
267
  nextCursor?: string | undefined;
201
268
  }>;
202
269
  /**
@@ -207,12 +274,13 @@ export declare class WebMcpClient {
207
274
  resourceTemplates: {
208
275
  uriTemplate: string;
209
276
  name: string;
210
- description? /**
211
- * Registers a handler to invoke when this protocol object receives a request with the given method.
212
- *
213
- * Note that this will replace any previous request handler for the same method.
214
- */: string | undefined;
277
+ description?: string | undefined;
215
278
  mimeType?: string | undefined;
279
+ annotations?: {
280
+ audience?: ("user" | "assistant")[] | undefined;
281
+ priority?: number | undefined;
282
+ lastModified?: string | undefined;
283
+ } | undefined;
216
284
  _meta?: {
217
285
  [x: string]: unknown;
218
286
  } | undefined;
@@ -220,10 +288,17 @@ export declare class WebMcpClient {
220
288
  src: string;
221
289
  mimeType?: string | undefined;
222
290
  sizes?: string[] | undefined;
291
+ theme?: "light" | "dark" | undefined;
223
292
  }[] | undefined;
224
293
  title?: string | undefined;
225
294
  }[];
226
- _meta?: Record<string, unknown> | undefined;
295
+ _meta?: {
296
+ [x: string]: unknown;
297
+ progressToken?: string | number | undefined;
298
+ "io.modelcontextprotocol/related-task"?: {
299
+ taskId: string;
300
+ } | undefined;
301
+ } | undefined;
227
302
  nextCursor?: string | undefined;
228
303
  }>;
229
304
  /**
@@ -242,19 +317,37 @@ export declare class WebMcpClient {
242
317
  mimeType?: string | undefined;
243
318
  _meta?: Record<string, unknown> | undefined;
244
319
  })[];
245
- _meta?: Record<string, unknown> | undefined;
320
+ _meta?: {
321
+ [x: string]: unknown;
322
+ progressToken?: string | number | undefined;
323
+ "io.modelcontextprotocol/related-task"?: {
324
+ taskId: string;
325
+ } | undefined;
326
+ } | undefined;
246
327
  }>;
247
328
  /**
248
329
  * Subscribes to a resource on the server.
249
330
  */
250
331
  subscribeResource(params: SubscribeRequest['params'], options?: RequestOptions): Promise<{
251
- _meta?: Record<string, unknown> | undefined;
332
+ _meta?: {
333
+ [x: string]: unknown;
334
+ progressToken?: string | number | undefined;
335
+ "io.modelcontextprotocol/related-task"?: {
336
+ taskId: string;
337
+ } | undefined;
338
+ } | undefined;
252
339
  }>;
253
340
  /**
254
341
  * Unsubscribes from a resource on the server.
255
342
  */
256
343
  unsubscribeResource(params: UnsubscribeRequest['params'], options?: RequestOptions): Promise<{
257
- _meta?: Record<string, unknown> | undefined;
344
+ _meta?: {
345
+ [x: string]: unknown;
346
+ progressToken?: string | number | undefined;
347
+ "io.modelcontextprotocol/related-task"?: {
348
+ taskId: string;
349
+ } | undefined;
350
+ } | undefined;
258
351
  }>;
259
352
  /**
260
353
  * Calls a tool on the server with the given parameters.
@@ -264,16 +357,31 @@ export declare class WebMcpClient {
264
357
  content: ({
265
358
  type: "text";
266
359
  text: string;
360
+ annotations?: {
361
+ audience?: ("user" | "assistant")[] | undefined;
362
+ priority?: number | undefined;
363
+ lastModified?: string | undefined;
364
+ } | undefined;
267
365
  _meta?: Record<string, unknown> | undefined;
268
366
  } | {
269
367
  type: "image";
270
368
  data: string;
271
369
  mimeType: string;
370
+ annotations?: {
371
+ audience?: ("user" | "assistant")[] | undefined;
372
+ priority?: number | undefined;
373
+ lastModified?: string | undefined;
374
+ } | undefined;
272
375
  _meta?: Record<string, unknown> | undefined;
273
376
  } | {
274
377
  type: "audio";
275
378
  data: string;
276
379
  mimeType: string;
380
+ annotations?: {
381
+ audience?: ("user" | "assistant")[] | undefined;
382
+ priority?: number | undefined;
383
+ lastModified?: string | undefined;
384
+ } | undefined;
277
385
  _meta?: Record<string, unknown> | undefined;
278
386
  } | {
279
387
  type: "resource";
@@ -288,6 +396,11 @@ export declare class WebMcpClient {
288
396
  mimeType?: string | undefined;
289
397
  _meta?: Record<string, unknown> | undefined;
290
398
  };
399
+ annotations?: {
400
+ audience?: ("user" | "assistant")[] | undefined;
401
+ priority?: number | undefined;
402
+ lastModified?: string | undefined;
403
+ } | undefined;
291
404
  _meta?: Record<string, unknown> | undefined;
292
405
  } | {
293
406
  uri: string;
@@ -295,6 +408,11 @@ export declare class WebMcpClient {
295
408
  type: "resource_link";
296
409
  description?: string | undefined;
297
410
  mimeType?: string | undefined;
411
+ annotations?: {
412
+ audience?: ("user" | "assistant")[] | undefined;
413
+ priority?: number | undefined;
414
+ lastModified?: string | undefined;
415
+ } | undefined;
298
416
  _meta?: {
299
417
  [x: string]: unknown;
300
418
  } | undefined;
@@ -302,16 +420,29 @@ export declare class WebMcpClient {
302
420
  src: string;
303
421
  mimeType?: string | undefined;
304
422
  sizes?: string[] | undefined;
423
+ theme?: "light" | "dark" | undefined;
305
424
  }[] | undefined;
306
425
  title?: string | undefined;
307
426
  })[];
308
- _meta?: Record<string, unknown> | undefined;
427
+ _meta?: {
428
+ [x: string]: unknown;
429
+ progressToken?: string | number | undefined;
430
+ "io.modelcontextprotocol/related-task"?: {
431
+ taskId: string;
432
+ } | undefined;
433
+ } | undefined;
309
434
  structuredContent?: Record<string, unknown> | undefined;
310
435
  isError?: boolean | undefined;
311
436
  } | {
312
437
  [x: string]: unknown;
313
438
  toolResult: unknown;
314
- _meta?: Record<string, unknown> | undefined;
439
+ _meta?: {
440
+ [x: string]: unknown;
441
+ progressToken?: string | number | undefined;
442
+ "io.modelcontextprotocol/related-task"?: {
443
+ taskId: string;
444
+ } | undefined;
445
+ } | undefined;
315
446
  }>;
316
447
  /**
317
448
  * Lists all tools available on the server.
@@ -340,15 +471,25 @@ export declare class WebMcpClient {
340
471
  idempotentHint?: boolean | undefined;
341
472
  openWorldHint?: boolean | undefined;
342
473
  } | undefined;
474
+ execution?: {
475
+ taskSupport?: "optional" | "required" | "forbidden" | undefined;
476
+ } | undefined;
343
477
  _meta?: Record<string, unknown> | undefined;
344
478
  icons?: {
345
479
  src: string;
346
480
  mimeType?: string | undefined;
347
481
  sizes?: string[] | undefined;
482
+ theme?: "light" | "dark" | undefined;
348
483
  }[] | undefined;
349
484
  title?: string | undefined;
350
485
  }[];
351
- _meta?: Record<string, unknown> | undefined;
486
+ _meta?: {
487
+ [x: string]: unknown;
488
+ progressToken?: string | number | undefined;
489
+ "io.modelcontextprotocol/related-task"?: {
490
+ taskId: string;
491
+ } | undefined;
492
+ } | undefined;
352
493
  nextCursor?: string | undefined;
353
494
  }>;
354
495
  /**
@@ -392,35 +533,35 @@ export declare class WebMcpClient {
392
533
  /**
393
534
  * Registers a handler for the elicitation request.
394
535
  */
395
- onElicit(handler: (request: z.infer<typeof ElicitRequestSchema>, extra: RequestHandlerExtra<SendRequestT, SendNotificationT>) => SendResultT | Promise<SendResultT>): void;
536
+ onElicit(handler: (request: ElicitRequest, extra: RequestHandlerExtra<SendRequestT, SendNotificationT>) => SendResultT | Promise<SendResultT>): void;
396
537
  /**
397
538
  * Registers a handler for the create LLM message request.
398
539
  */
399
- onCreateMessage(handler: (request: z.infer<typeof CreateMessageRequestSchema>, extra: RequestHandlerExtra<SendRequestT, SendNotificationT>) => SendResultT | Promise<SendResultT>): void;
540
+ onCreateMessage(handler: (request: CreateMessageRequest, extra: RequestHandlerExtra<SendRequestT, SendNotificationT>) => SendResultT | Promise<SendResultT>): void;
400
541
  /**
401
542
  * Registers a handler for the list roots request.
402
543
  */
403
- onListRoots(handler: (request: z.infer<typeof ListRootsRequestSchema>, extra: RequestHandlerExtra<SendRequestT, SendNotificationT>) => SendResultT | Promise<SendResultT>): void;
544
+ onListRoots(handler: (request: ListRootsRequest, extra: RequestHandlerExtra<SendRequestT, SendNotificationT>) => SendResultT | Promise<SendResultT>): void;
404
545
  /**
405
546
  * Registers a handler for the tool list changed notification.
406
547
  */
407
- onToolListChanged(handler: (notification: z.infer<typeof ToolListChangedNotificationSchema>) => void | Promise<void>): void;
548
+ onToolListChanged(handler: (notification: ToolListChangedNotification) => void | Promise<void>): void;
408
549
  /**
409
550
  * Registers a handler for the prompt list changed notification.
410
551
  */
411
- onPromptListChanged(handler: (notification: z.infer<typeof PromptListChangedNotificationSchema>) => void | Promise<void>): void;
552
+ onPromptListChanged(handler: (notification: PromptListChangedNotification) => void | Promise<void>): void;
412
553
  /**
413
554
  * Registers a handler for the resource list changed notification.
414
555
  */
415
- onResourceListChanged(handler: (notification: z.infer<typeof ResourceListChangedNotificationSchema>) => void | Promise<void>): void;
556
+ onResourceListChanged(handler: (notification: ResourceListChangedNotification) => void | Promise<void>): void;
416
557
  /**
417
558
  * Registers a handler for the resource updated notification.
418
559
  */
419
- onResourceUpdated(handler: (notification: z.infer<typeof ResourceUpdatedNotificationSchema>) => void | Promise<void>): void;
560
+ onResourceUpdated(handler: (notification: ResourceUpdatedNotification) => void | Promise<void>): void;
420
561
  /**
421
562
  * Registers a handler for the logging message notification.
422
563
  */
423
- onLoggingMessage(handler: (notification: z.infer<typeof LoggingMessageNotificationSchema>) => void | Promise<void>): void;
564
+ onLoggingMessage(handler: (notification: LoggingMessageNotification) => void | Promise<void>): void;
424
565
  /**
425
566
  * Close the transport for window.addEventListener('pagehide')
426
567
  */