@opentiny/next-sdk 0.1.14-alpha.0 → 0.1.15-beta.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.
- package/agent/AgentModelProvider.ts +490 -1
- package/agent/type.ts +8 -2
- package/agent/utils/generateReActPrompt.ts +55 -0
- package/agent/utils/parseReActAction.ts +34 -0
- package/dist/WebMcpClient.d.ts +165 -26
- package/dist/WebMcpServer.d.ts +36 -147
- package/dist/agent/AgentModelProvider.d.ts +35 -1
- package/dist/agent/type.d.ts +8 -2
- package/dist/agent/utils/generateReActPrompt.d.ts +9 -0
- package/dist/agent/utils/parseReActAction.d.ts +14 -0
- package/dist/index.es.dev.js +14874 -11156
- package/dist/index.es.js +20957 -18178
- package/dist/index.js +2411 -320
- package/dist/index.umd.dev.js +14899 -11181
- package/dist/index.umd.js +111 -71
- package/dist/{mcpsdk@1.23.0.dev.js → mcpsdk@1.24.3.dev.js} +8866 -7205
- package/dist/{mcpsdk@1.23.0.es.dev.js → mcpsdk@1.24.3.es.dev.js} +8864 -7203
- package/dist/mcpsdk@1.24.3.es.js +16781 -0
- package/dist/mcpsdk@1.24.3.js +43 -0
- package/dist/transport/ExtensionPageServerTransport.d.ts +1 -2
- package/dist/webagent.dev.js +13963 -10522
- package/dist/webagent.es.dev.js +13949 -10508
- package/dist/webagent.es.js +18247 -15690
- package/dist/webagent.js +105 -65
- package/dist/webmcp-full.dev.js +8874 -7257
- package/dist/webmcp-full.es.dev.js +8872 -7255
- package/dist/webmcp-full.es.js +10395 -9241
- package/dist/webmcp-full.js +32 -32
- package/dist/webmcp.dev.js +14 -22
- package/dist/webmcp.es.dev.js +12 -20
- package/dist/webmcp.es.js +172 -179
- package/dist/webmcp.js +1 -1
- package/dist/zod@3.25.76.dev.js +30 -32
- package/dist/zod@3.25.76.es.dev.js +28 -30
- package/dist/zod@3.25.76.es.js +143 -145
- package/dist/zod@3.25.76.js +1 -1
- package/package.json +9 -8
- package/transport/ExtensionPageServerTransport.ts +2 -4
- package/dist/mcpsdk@1.23.0.es.js +0 -15584
- package/dist/mcpsdk@1.23.0.js +0 -43
package/dist/WebMcpClient.d.ts
CHANGED
|
@@ -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?:
|
|
71
|
+
_meta?: {
|
|
72
|
+
[x: string]: unknown;
|
|
73
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
74
|
+
[x: string]: unknown;
|
|
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?:
|
|
90
|
+
_meta?: {
|
|
91
|
+
[x: string]: unknown;
|
|
92
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
93
|
+
[x: string]: unknown;
|
|
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?:
|
|
102
|
+
_meta?: {
|
|
103
|
+
[x: string]: unknown;
|
|
104
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
105
|
+
[x: string]: unknown;
|
|
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,37 @@ export declare class WebMcpClient {
|
|
|
99
117
|
content: {
|
|
100
118
|
type: "text";
|
|
101
119
|
text: string;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
+
/**
|
|
142
|
+
* Unsubscribes from a resource on the server.
|
|
143
|
+
*/
|
|
144
|
+
? /**
|
|
145
|
+
* Unsubscribes from a resource on the server.
|
|
146
|
+
*/: {
|
|
147
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
148
|
+
priority?: number | undefined;
|
|
149
|
+
lastModified?: string | undefined;
|
|
150
|
+
} | undefined;
|
|
118
151
|
_meta?: Record<string, unknown> | undefined;
|
|
119
152
|
} | {
|
|
120
153
|
type: "resource";
|
|
@@ -129,6 +162,11 @@ export declare class WebMcpClient {
|
|
|
129
162
|
mimeType?: string | undefined;
|
|
130
163
|
_meta?: Record<string, unknown> | undefined;
|
|
131
164
|
};
|
|
165
|
+
annotations?: {
|
|
166
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
167
|
+
priority?: number | undefined;
|
|
168
|
+
lastModified?: string | undefined;
|
|
169
|
+
} | undefined;
|
|
132
170
|
_meta?: Record<string, unknown> | undefined;
|
|
133
171
|
} | {
|
|
134
172
|
uri: string;
|
|
@@ -136,6 +174,11 @@ export declare class WebMcpClient {
|
|
|
136
174
|
type: "resource_link";
|
|
137
175
|
description?: string | undefined;
|
|
138
176
|
mimeType?: string | undefined;
|
|
177
|
+
annotations?: {
|
|
178
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
179
|
+
priority?: number | undefined;
|
|
180
|
+
lastModified?: string | undefined;
|
|
181
|
+
} | undefined;
|
|
139
182
|
_meta?: {
|
|
140
183
|
[x: string]: unknown;
|
|
141
184
|
} | undefined;
|
|
@@ -147,7 +190,13 @@ export declare class WebMcpClient {
|
|
|
147
190
|
title?: string | undefined;
|
|
148
191
|
};
|
|
149
192
|
}[];
|
|
150
|
-
_meta?:
|
|
193
|
+
_meta?: {
|
|
194
|
+
[x: string]: unknown;
|
|
195
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
196
|
+
[x: string]: unknown;
|
|
197
|
+
taskId: string;
|
|
198
|
+
} | undefined;
|
|
199
|
+
} | undefined;
|
|
151
200
|
description?: string | undefined;
|
|
152
201
|
}>;
|
|
153
202
|
/**
|
|
@@ -171,9 +220,17 @@ export declare class WebMcpClient {
|
|
|
171
220
|
mimeType?: string | undefined;
|
|
172
221
|
sizes?: string[] | undefined;
|
|
173
222
|
}[] | undefined;
|
|
174
|
-
title
|
|
223
|
+
title? /**
|
|
224
|
+
* Registers a handler for the elicitation request.
|
|
225
|
+
*/: string | undefined;
|
|
175
226
|
}[];
|
|
176
|
-
_meta?:
|
|
227
|
+
_meta?: {
|
|
228
|
+
[x: string]: unknown;
|
|
229
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
230
|
+
[x: string]: unknown;
|
|
231
|
+
taskId: string;
|
|
232
|
+
} | undefined;
|
|
233
|
+
} | undefined;
|
|
177
234
|
nextCursor?: string | undefined;
|
|
178
235
|
}>;
|
|
179
236
|
/**
|
|
@@ -186,6 +243,11 @@ export declare class WebMcpClient {
|
|
|
186
243
|
name: string;
|
|
187
244
|
description?: string | undefined;
|
|
188
245
|
mimeType?: string | undefined;
|
|
246
|
+
annotations?: {
|
|
247
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
248
|
+
priority?: number | undefined;
|
|
249
|
+
lastModified?: string | undefined;
|
|
250
|
+
} | undefined;
|
|
189
251
|
_meta?: {
|
|
190
252
|
[x: string]: unknown;
|
|
191
253
|
} | undefined;
|
|
@@ -196,7 +258,13 @@ export declare class WebMcpClient {
|
|
|
196
258
|
}[] | undefined;
|
|
197
259
|
title?: string | undefined;
|
|
198
260
|
}[];
|
|
199
|
-
_meta?:
|
|
261
|
+
_meta?: {
|
|
262
|
+
[x: string]: unknown;
|
|
263
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
264
|
+
[x: string]: unknown;
|
|
265
|
+
taskId: string;
|
|
266
|
+
} | undefined;
|
|
267
|
+
} | undefined;
|
|
200
268
|
nextCursor?: string | undefined;
|
|
201
269
|
}>;
|
|
202
270
|
/**
|
|
@@ -207,12 +275,13 @@ export declare class WebMcpClient {
|
|
|
207
275
|
resourceTemplates: {
|
|
208
276
|
uriTemplate: string;
|
|
209
277
|
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;
|
|
278
|
+
description?: string | undefined;
|
|
215
279
|
mimeType?: string | undefined;
|
|
280
|
+
annotations?: {
|
|
281
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
282
|
+
priority?: number | undefined;
|
|
283
|
+
lastModified?: string | undefined;
|
|
284
|
+
} | undefined;
|
|
216
285
|
_meta?: {
|
|
217
286
|
[x: string]: unknown;
|
|
218
287
|
} | undefined;
|
|
@@ -223,7 +292,13 @@ export declare class WebMcpClient {
|
|
|
223
292
|
}[] | undefined;
|
|
224
293
|
title?: string | undefined;
|
|
225
294
|
}[];
|
|
226
|
-
_meta?:
|
|
295
|
+
_meta?: {
|
|
296
|
+
[x: string]: unknown;
|
|
297
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
298
|
+
[x: string]: unknown;
|
|
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?:
|
|
320
|
+
_meta?: {
|
|
321
|
+
[x: string]: unknown;
|
|
322
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
323
|
+
[x: string]: unknown;
|
|
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?:
|
|
332
|
+
_meta?: {
|
|
333
|
+
[x: string]: unknown;
|
|
334
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
335
|
+
[x: string]: unknown;
|
|
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?:
|
|
344
|
+
_meta?: {
|
|
345
|
+
[x: string]: unknown;
|
|
346
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
347
|
+
[x: string]: unknown;
|
|
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;
|
|
@@ -305,13 +423,25 @@ export declare class WebMcpClient {
|
|
|
305
423
|
}[] | undefined;
|
|
306
424
|
title?: string | undefined;
|
|
307
425
|
})[];
|
|
308
|
-
_meta?:
|
|
426
|
+
_meta?: {
|
|
427
|
+
[x: string]: unknown;
|
|
428
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
429
|
+
[x: string]: unknown;
|
|
430
|
+
taskId: string;
|
|
431
|
+
} | undefined;
|
|
432
|
+
} | undefined;
|
|
309
433
|
structuredContent?: Record<string, unknown> | undefined;
|
|
310
434
|
isError?: boolean | undefined;
|
|
311
435
|
} | {
|
|
312
436
|
[x: string]: unknown;
|
|
313
437
|
toolResult: unknown;
|
|
314
|
-
_meta?:
|
|
438
|
+
_meta?: {
|
|
439
|
+
[x: string]: unknown;
|
|
440
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
441
|
+
[x: string]: unknown;
|
|
442
|
+
taskId: string;
|
|
443
|
+
} | undefined;
|
|
444
|
+
} | undefined;
|
|
315
445
|
}>;
|
|
316
446
|
/**
|
|
317
447
|
* Lists all tools available on the server.
|
|
@@ -340,6 +470,9 @@ export declare class WebMcpClient {
|
|
|
340
470
|
idempotentHint?: boolean | undefined;
|
|
341
471
|
openWorldHint?: boolean | undefined;
|
|
342
472
|
} | undefined;
|
|
473
|
+
execution?: {
|
|
474
|
+
taskSupport?: "optional" | "required" | "forbidden" | undefined;
|
|
475
|
+
} | undefined;
|
|
343
476
|
_meta?: Record<string, unknown> | undefined;
|
|
344
477
|
icons?: {
|
|
345
478
|
src: string;
|
|
@@ -348,7 +481,13 @@ export declare class WebMcpClient {
|
|
|
348
481
|
}[] | undefined;
|
|
349
482
|
title?: string | undefined;
|
|
350
483
|
}[];
|
|
351
|
-
_meta?:
|
|
484
|
+
_meta?: {
|
|
485
|
+
[x: string]: unknown;
|
|
486
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
487
|
+
[x: string]: unknown;
|
|
488
|
+
taskId: string;
|
|
489
|
+
} | undefined;
|
|
490
|
+
} | undefined;
|
|
352
491
|
nextCursor?: string | undefined;
|
|
353
492
|
}>;
|
|
354
493
|
/**
|
package/dist/WebMcpServer.d.ts
CHANGED
|
@@ -98,7 +98,13 @@ export declare class WebMcpServer {
|
|
|
98
98
|
* Sends a ping to the client to check if it is still connected.
|
|
99
99
|
*/
|
|
100
100
|
ping(): Promise<{
|
|
101
|
-
_meta?:
|
|
101
|
+
_meta?: {
|
|
102
|
+
[x: string]: unknown;
|
|
103
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
104
|
+
[x: string]: unknown;
|
|
105
|
+
taskId: string;
|
|
106
|
+
} | undefined;
|
|
107
|
+
} | undefined;
|
|
102
108
|
}>;
|
|
103
109
|
/**
|
|
104
110
|
* Creates a LLM message to be sent to the client.
|
|
@@ -110,169 +116,46 @@ export declare class WebMcpServer {
|
|
|
110
116
|
content: {
|
|
111
117
|
type: "text";
|
|
112
118
|
text: string;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
mimeType: string;
|
|
118
|
-
_meta?: Record<string, unknown> | undefined;
|
|
119
|
-
} | {
|
|
120
|
-
type: "audio";
|
|
121
|
-
data: string;
|
|
122
|
-
mimeType: string;
|
|
123
|
-
_meta?: Record<string, unknown> | undefined;
|
|
124
|
-
} | {
|
|
125
|
-
[x: string]: unknown;
|
|
126
|
-
type: "tool_use";
|
|
127
|
-
name: string;
|
|
128
|
-
id: string;
|
|
129
|
-
input: {
|
|
130
|
-
[x: string]: unknown;
|
|
131
|
-
};
|
|
132
|
-
_meta?: {
|
|
133
|
-
[x: string]: unknown;
|
|
119
|
+
annotations?: {
|
|
120
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
121
|
+
priority?: number | undefined;
|
|
122
|
+
lastModified?: string | undefined;
|
|
134
123
|
} | undefined;
|
|
135
|
-
} | {
|
|
136
|
-
[x: string]: unknown;
|
|
137
|
-
type: "tool_result";
|
|
138
|
-
toolUseId: string;
|
|
139
|
-
content: ({
|
|
140
|
-
type: "text";
|
|
141
|
-
text: string;
|
|
142
|
-
_meta?: Record<string, unknown> | undefined;
|
|
143
|
-
} | {
|
|
144
|
-
type: "image";
|
|
145
|
-
data: string;
|
|
146
|
-
mimeType: string;
|
|
147
|
-
_meta?: Record<string, unknown> | undefined;
|
|
148
|
-
} | {
|
|
149
|
-
type: "audio";
|
|
150
|
-
data: string;
|
|
151
|
-
mimeType: string;
|
|
152
|
-
_meta?: Record<string, unknown> | undefined;
|
|
153
|
-
} | {
|
|
154
|
-
type: "resource";
|
|
155
|
-
resource: {
|
|
156
|
-
uri: string;
|
|
157
|
-
text: string;
|
|
158
|
-
mimeType?: string | undefined;
|
|
159
|
-
_meta?: Record<string, unknown> | undefined;
|
|
160
|
-
} | {
|
|
161
|
-
uri: string;
|
|
162
|
-
blob: string;
|
|
163
|
-
mimeType?: string | undefined;
|
|
164
|
-
_meta?: Record<string, unknown> | undefined;
|
|
165
|
-
};
|
|
166
|
-
_meta?: Record<string, unknown> | undefined;
|
|
167
|
-
} | {
|
|
168
|
-
uri: string;
|
|
169
|
-
name: string;
|
|
170
|
-
type: "resource_link";
|
|
171
|
-
description?: string | undefined;
|
|
172
|
-
mimeType?: string | undefined;
|
|
173
|
-
_meta?: {
|
|
174
|
-
[x: string]: unknown;
|
|
175
|
-
} | undefined;
|
|
176
|
-
icons?: {
|
|
177
|
-
src: string;
|
|
178
|
-
mimeType?: string | undefined;
|
|
179
|
-
sizes?: string[] | undefined;
|
|
180
|
-
}[] | undefined;
|
|
181
|
-
title?: string | undefined;
|
|
182
|
-
})[];
|
|
183
|
-
structuredContent?: {
|
|
184
|
-
[x: string]: unknown;
|
|
185
|
-
} | undefined;
|
|
186
|
-
isError?: boolean | undefined;
|
|
187
124
|
_meta?: {
|
|
188
125
|
[x: string]: unknown;
|
|
189
126
|
} | undefined;
|
|
190
|
-
} | ({
|
|
191
|
-
type: "text";
|
|
192
|
-
text: string;
|
|
193
|
-
_meta?: Record<string, unknown> | undefined;
|
|
194
127
|
} | {
|
|
195
128
|
type: "image";
|
|
196
129
|
data: string;
|
|
197
130
|
mimeType: string;
|
|
198
|
-
|
|
131
|
+
annotations?: {
|
|
132
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
133
|
+
priority?: number | undefined;
|
|
134
|
+
lastModified?: string | undefined;
|
|
135
|
+
} | undefined;
|
|
136
|
+
_meta?: {
|
|
137
|
+
[x: string]: unknown;
|
|
138
|
+
} | undefined;
|
|
199
139
|
} | {
|
|
200
140
|
type: "audio";
|
|
201
141
|
data: string;
|
|
202
142
|
mimeType: string;
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
id: string;
|
|
209
|
-
input: {
|
|
210
|
-
[x: string]: unknown;
|
|
211
|
-
};
|
|
143
|
+
annotations?: {
|
|
144
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
145
|
+
priority?: number | undefined;
|
|
146
|
+
lastModified?: string | undefined;
|
|
147
|
+
} | undefined;
|
|
212
148
|
_meta?: {
|
|
213
149
|
[x: string]: unknown;
|
|
214
150
|
} | undefined;
|
|
215
|
-
}
|
|
151
|
+
};
|
|
152
|
+
_meta?: {
|
|
216
153
|
[x: string]: unknown;
|
|
217
|
-
|
|
218
|
-
toolUseId: string;
|
|
219
|
-
content: ({
|
|
220
|
-
type: "text";
|
|
221
|
-
text: string;
|
|
222
|
-
_meta?: Record<string, unknown> | undefined;
|
|
223
|
-
} | {
|
|
224
|
-
type: "image";
|
|
225
|
-
data: string;
|
|
226
|
-
mimeType: string;
|
|
227
|
-
_meta?: Record<string, unknown> | undefined;
|
|
228
|
-
} | {
|
|
229
|
-
type: "audio";
|
|
230
|
-
data: string;
|
|
231
|
-
mimeType: string;
|
|
232
|
-
_meta?: Record<string, unknown> | undefined;
|
|
233
|
-
} | {
|
|
234
|
-
type: "resource";
|
|
235
|
-
resource: {
|
|
236
|
-
uri: string;
|
|
237
|
-
text: string;
|
|
238
|
-
mimeType?: string | undefined;
|
|
239
|
-
_meta?: Record<string, unknown> | undefined;
|
|
240
|
-
} | {
|
|
241
|
-
uri: string;
|
|
242
|
-
blob: string;
|
|
243
|
-
mimeType?: string | undefined;
|
|
244
|
-
_meta?: Record<string, unknown> | undefined;
|
|
245
|
-
};
|
|
246
|
-
_meta?: Record<string, unknown> | undefined;
|
|
247
|
-
} | {
|
|
248
|
-
uri: string;
|
|
249
|
-
name: string;
|
|
250
|
-
type: "resource_link";
|
|
251
|
-
description?: string | undefined;
|
|
252
|
-
mimeType?: string | undefined;
|
|
253
|
-
_meta? /**
|
|
254
|
-
* Registers a handler to invoke when this protocol object receives a notification with the given method.
|
|
255
|
-
*
|
|
256
|
-
* Note that this will replace any previous notification handler for the same method.
|
|
257
|
-
*/: {
|
|
258
|
-
[x: string]: unknown;
|
|
259
|
-
} | undefined;
|
|
260
|
-
icons?: {
|
|
261
|
-
src: string;
|
|
262
|
-
mimeType?: string | undefined;
|
|
263
|
-
sizes?: string[] | undefined;
|
|
264
|
-
}[] | undefined;
|
|
265
|
-
title?: string | undefined;
|
|
266
|
-
})[];
|
|
267
|
-
structuredContent?: {
|
|
268
|
-
[x: string]: unknown;
|
|
269
|
-
} | undefined;
|
|
270
|
-
isError?: boolean | undefined;
|
|
271
|
-
_meta?: {
|
|
154
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
272
155
|
[x: string]: unknown;
|
|
156
|
+
taskId: string;
|
|
273
157
|
} | undefined;
|
|
274
|
-
}
|
|
275
|
-
_meta?: Record<string, unknown> | undefined;
|
|
158
|
+
} | undefined;
|
|
276
159
|
stopReason?: string | undefined;
|
|
277
160
|
}>;
|
|
278
161
|
/**
|
|
@@ -289,7 +172,13 @@ export declare class WebMcpServer {
|
|
|
289
172
|
name?: string | undefined;
|
|
290
173
|
_meta?: Record<string, unknown> | undefined;
|
|
291
174
|
}[];
|
|
292
|
-
_meta?:
|
|
175
|
+
_meta?: {
|
|
176
|
+
[x: string]: unknown;
|
|
177
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
178
|
+
[x: string]: unknown;
|
|
179
|
+
taskId: string;
|
|
180
|
+
} | undefined;
|
|
181
|
+
} | undefined;
|
|
293
182
|
}>;
|
|
294
183
|
/**
|
|
295
184
|
* Sends a logging message to the client.
|
|
@@ -32,6 +32,8 @@ export declare class AgentModelProvider {
|
|
|
32
32
|
onClientDisconnected?: (serverName: string, reason?: string) => void;
|
|
33
33
|
/** 缓存 ai-sdk response 中的 多轮会话的上下文 */
|
|
34
34
|
messages: any[];
|
|
35
|
+
/** 是否使用 ReAct 模式(通过提示词而非 function calling 进行工具调用) */
|
|
36
|
+
useReActMode: boolean;
|
|
35
37
|
constructor({ llmConfig, mcpServers }: IAgentModelProviderOption);
|
|
36
38
|
/** 创建一个 ai-sdk的 mcpClient, 创建失败则返回 null */
|
|
37
39
|
private _createOneClient;
|
|
@@ -50,11 +52,43 @@ export declare class AgentModelProvider {
|
|
|
50
52
|
/** 全量更新所有的 mcpServers */
|
|
51
53
|
updateMcpServers(mcpServers?: Record<string, McpServerConfig>): Promise<void>;
|
|
52
54
|
/** 插入一个新的mcpServer,如果已经存在则返回false */
|
|
53
|
-
insertMcpServer(serverName: string, mcpServer: McpServerConfig): Promise<false | WebMcpClient | import('ai').experimental_MCPClient | null>;
|
|
55
|
+
insertMcpServer(serverName: string, mcpServer: McpServerConfig): Promise<false | WebMcpClient | import('@ai-sdk/mcp').experimental_MCPClient | null>;
|
|
54
56
|
/** 通过服务器名称删除mcpServer: mcpServers mcpClients mcpTools ignoreToolnames */
|
|
55
57
|
removeMcpServer(serverName: string): Promise<void>;
|
|
56
58
|
/** 创建临时允许调用的tools集合 */
|
|
57
59
|
private _tempMergeTools;
|
|
60
|
+
/** 生成 ReAct 模式的系统提示词(包含工具描述) */
|
|
61
|
+
private _generateReActSystemPrompt;
|
|
62
|
+
/** 执行 ReAct 模式下的工具调用 */
|
|
63
|
+
private _executeReActToolCall;
|
|
64
|
+
/** ReAct 模式的对话实现 */
|
|
65
|
+
private _chatReAct;
|
|
66
|
+
/**
|
|
67
|
+
* 检查消息内容是否包含图片
|
|
68
|
+
* @param content 消息内容
|
|
69
|
+
* @returns 是否包含图片
|
|
70
|
+
*/
|
|
71
|
+
private _messageHasImage;
|
|
72
|
+
/**
|
|
73
|
+
* 从消息中移除图片,但保留文本内容
|
|
74
|
+
* @param message 原始消息
|
|
75
|
+
* @returns 移除图片后的消息(如果只有图片没有文本,返回 null)
|
|
76
|
+
*/
|
|
77
|
+
private _removeImageFromMessage;
|
|
78
|
+
/**
|
|
79
|
+
* 构建用于模型调用的消息列表(magentic-ui 风格)
|
|
80
|
+
* 策略:保留所有文本消息,仅限制图片数量(类似 magentic-ui 的 maybe_remove_old_screenshots)
|
|
81
|
+
*
|
|
82
|
+
* @param systemMessage 系统提示词
|
|
83
|
+
* @param allMessages 所有消息历史(包括初始消息和后续对话)
|
|
84
|
+
* @param maxImages 最多保留的图片数量(默认3张)
|
|
85
|
+
* @returns 构建好的消息列表
|
|
86
|
+
*/
|
|
87
|
+
private _buildMessagesForModel;
|
|
88
|
+
/** ReAct 模式非流式对话 */
|
|
89
|
+
private _chatReActNonStream;
|
|
90
|
+
/** ReAct 模式流式对话 */
|
|
91
|
+
private _chatReActStream;
|
|
58
92
|
private _chat;
|
|
59
93
|
chat(options: Parameters<typeof generateText>[0] & {
|
|
60
94
|
maxSteps?: number;
|
package/dist/agent/type.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ProviderV2 } from '@ai-sdk/provider';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { experimental_MCPClientConfig as MCPClientConfig } from '@ai-sdk/mcp';
|
|
3
|
+
|
|
4
|
+
export type MCPTransport = MCPClientConfig['transport'];
|
|
4
5
|
type ProviderFactory = 'openai' | 'deepseek' | ((options: any) => ProviderV2);
|
|
5
6
|
type LlmFactoryConfig = {
|
|
6
7
|
/** API密钥 */
|
|
@@ -11,6 +12,8 @@ type LlmFactoryConfig = {
|
|
|
11
12
|
providerType: ProviderFactory;
|
|
12
13
|
/** 互斥:当使用 providerType 分支时不允许传入 llm */
|
|
13
14
|
llm?: never;
|
|
15
|
+
/** 是否使用 ReAct 模式(通过提示词而非 function calling 进行工具调用),默认为 false */
|
|
16
|
+
useReActMode?: boolean;
|
|
14
17
|
};
|
|
15
18
|
type LlmInstanceConfig = {
|
|
16
19
|
/** 自定义 Provider 实例,优先级最高 */
|
|
@@ -19,6 +22,8 @@ type LlmInstanceConfig = {
|
|
|
19
22
|
apiKey?: never;
|
|
20
23
|
baseURL?: never;
|
|
21
24
|
providerType?: never;
|
|
25
|
+
/** 是否使用 ReAct 模式(通过提示词而非 function calling 进行工具调用),默认为 false */
|
|
26
|
+
useReActMode?: boolean;
|
|
22
27
|
};
|
|
23
28
|
/** 代理模型提供器的大语言配置对象, 通过 XOR 表达二选一 */
|
|
24
29
|
export type IAgentModelProviderLlmConfig = LlmFactoryConfig | LlmInstanceConfig;
|
|
@@ -47,3 +52,4 @@ export interface IAgentModelProviderOption {
|
|
|
47
52
|
/** Mcp Server的配置对象的集合,键为服务器名称,值为配置对象 */
|
|
48
53
|
mcpServers?: Record<string, McpServerConfig>;
|
|
49
54
|
}
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ToolSet } from 'ai';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 解析 ReAct 格式的工具调用
|
|
5
|
+
* 从模型输出文本中提取工具名称和参数
|
|
6
|
+
* 现在统一使用 XML 格式(<call> 标签),同时保留对其他格式的兼容性支持
|
|
7
|
+
* @param text - 模型输出的文本
|
|
8
|
+
* @param availableTools - 可用的工具集合,用于验证工具名称
|
|
9
|
+
* @returns 解析出的工具调用信息,如果未找到则返回 null
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseReActAction(text: string, availableTools: ToolSet): {
|
|
12
|
+
toolName: string;
|
|
13
|
+
arguments: any;
|
|
14
|
+
} | null;
|