@opentiny/next-sdk 0.2.0 → 0.2.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.
- package/WebMcpClient.ts +17 -19
- package/WebMcpServer.ts +11 -8
- package/agent/AgentModelProvider.ts +2 -2
- package/agent/type.ts +1 -1
- package/dist/WebMcpClient.d.ts +176 -35
- package/dist/WebMcpServer.d.ts +43 -154
- package/dist/agent/AgentModelProvider.d.ts +0 -2
- package/dist/agent/type.d.ts +1 -0
- package/dist/index.es.dev.js +2433 -5635
- package/dist/index.es.js +13476 -16094
- package/dist/index.js +1 -1
- package/dist/index.umd.dev.js +2395 -5597
- package/dist/index.umd.js +52 -52
- package/dist/{mcpsdk@1.23.1.dev.js → mcpsdk@1.25.2.dev.js} +2047 -482
- package/dist/{mcpsdk@1.23.1.es.dev.js → mcpsdk@1.25.2.es.dev.js} +2047 -482
- package/dist/mcpsdk@1.25.2.es.js +16796 -0
- package/dist/mcpsdk@1.25.2.js +43 -0
- package/dist/webagent.dev.js +10248 -13732
- package/dist/webagent.es.dev.js +10231 -13715
- package/dist/webagent.es.js +13559 -16396
- package/dist/webagent.js +45 -45
- package/dist/webmcp-full.dev.js +2443 -5645
- package/dist/webmcp-full.es.dev.js +2422 -5624
- package/dist/webmcp-full.es.js +8284 -10901
- package/dist/webmcp-full.js +28 -28
- package/package.json +3 -3
- package/dist/mcpsdk@1.23.1.es.js +0 -15530
- package/dist/mcpsdk@1.23.1.js +0 -43
package/dist/WebMcpServer.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MessageChannelServerTransport } from '@opentiny/next';
|
|
2
2
|
import { McpServer, ToolCallback, RegisteredTool, PromptCallback, RegisteredPrompt, ResourceMetadata, ResourceTemplate, RegisteredResource, ReadResourceCallback, RegisteredResourceTemplate, ReadResourceTemplateCallback } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { z, ZodObject, ZodLiteral, ZodType, ZodOptional, ZodRawShape, ZodTypeDef } from 'zod';
|
|
4
|
-
import {
|
|
4
|
+
import { Result, Request, Notification, Implementation, ToolAnnotations, ClientCapabilities, ElicitResult, ElicitRequest, ListRootsRequest, CreateMessageRequest, LoggingMessageNotification, ResourceUpdatedNotification, SubscribeRequest, UnsubscribeRequest, SetLevelRequest, ListResourcesRequest, RootsListChangedNotification } from '@modelcontextprotocol/sdk/types.js';
|
|
5
5
|
import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
|
|
6
6
|
import { ServerOptions } from '@modelcontextprotocol/sdk/server/index.js';
|
|
7
7
|
import { RequestOptions, NotificationOptions, RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
@@ -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
|
+
progressToken?: string | number | undefined;
|
|
104
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
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;
|
|
134
|
-
} | 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;
|
|
119
|
+
annotations?: {
|
|
120
|
+
audience?: ("user" | "assistant")[] | undefined;
|
|
121
|
+
priority?: number | undefined;
|
|
122
|
+
lastModified?: string | undefined;
|
|
185
123
|
} | 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
|
-
|
|
219
|
-
|
|
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;
|
|
154
|
+
progressToken?: string | number | undefined;
|
|
155
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
156
|
+
taskId: string;
|
|
269
157
|
} | undefined;
|
|
270
|
-
|
|
271
|
-
_meta?: {
|
|
272
|
-
[x: string]: unknown;
|
|
273
|
-
} | 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
|
+
progressToken?: string | number | undefined;
|
|
178
|
+
"io.modelcontextprotocol/related-task"?: {
|
|
179
|
+
taskId: string;
|
|
180
|
+
} | undefined;
|
|
181
|
+
} | undefined;
|
|
293
182
|
}>;
|
|
294
183
|
/**
|
|
295
184
|
* Sends a logging message to the client.
|
|
@@ -336,23 +225,23 @@ export declare class WebMcpServer {
|
|
|
336
225
|
/**
|
|
337
226
|
* Registers a handler for the subscribe request.
|
|
338
227
|
*/
|
|
339
|
-
onSubscribe(handler: (request:
|
|
228
|
+
onSubscribe(handler: (request: SubscribeRequest, extra: RequestHandlerExtra<SendRequestT, SendNotificationT>) => SendResultT | Promise<SendResultT>): void;
|
|
340
229
|
/**
|
|
341
230
|
* Registers a handler for the unsubscribe request.
|
|
342
231
|
*/
|
|
343
|
-
onUnsubscribe(handler: (request:
|
|
232
|
+
onUnsubscribe(handler: (request: UnsubscribeRequest, extra: RequestHandlerExtra<SendRequestT, SendNotificationT>) => SendResultT | Promise<SendResultT>): void;
|
|
344
233
|
/**
|
|
345
234
|
* Registers a handler for the set log level request.
|
|
346
235
|
*/
|
|
347
|
-
onSetLogLevel(handler: (request:
|
|
236
|
+
onSetLogLevel(handler: (request: SetLevelRequest, extra: RequestHandlerExtra<SendRequestT, SendNotificationT>) => SendResultT | Promise<SendResultT>): void;
|
|
348
237
|
/**
|
|
349
238
|
* Registers a handler for the list tools request.
|
|
350
239
|
*/
|
|
351
|
-
onListResources(handler: (request:
|
|
240
|
+
onListResources(handler: (request: ListResourcesRequest, extra: RequestHandlerExtra<SendRequestT, SendNotificationT>) => SendResultT | Promise<SendResultT>): void;
|
|
352
241
|
/**
|
|
353
242
|
* Registers a handler for the roots list changed notification.
|
|
354
243
|
*/
|
|
355
|
-
onRootsListChanged(handler: (notification:
|
|
244
|
+
onRootsListChanged(handler: (notification: RootsListChangedNotification) => void | Promise<void>): void;
|
|
356
245
|
/**
|
|
357
246
|
* Close the transport for window.addEventListener('pagehide')
|
|
358
247
|
*/
|
|
@@ -28,8 +28,6 @@ export declare class AgentModelProvider {
|
|
|
28
28
|
onUpdatedTools: (() => void) | undefined;
|
|
29
29
|
/** Agent 内部报错时,抛出的错误事件 */
|
|
30
30
|
onError: ((msg: string, err?: any) => void) | undefined;
|
|
31
|
-
/** MCP Client 断开连接时的回调 */
|
|
32
|
-
onClientDisconnected?: (serverName: string, reason?: string) => void;
|
|
33
31
|
/** 缓存 ai-sdk response 中的 多轮会话的上下文 */
|
|
34
32
|
messages: any[];
|
|
35
33
|
/** 是否使用 ReAct 模式(通过提示词而非 function calling 进行工具调用) */
|