mcp-use 1.9.1-canary.1 → 1.10.0-canary.3
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/README.md +9 -6
- package/dist/.tsbuildinfo +1 -1
- package/dist/{chunk-QREDNTLS.js → chunk-F5MMLHUR.js} +1 -1
- package/dist/{chunk-33U4IA4N.js → chunk-L6P6GBCW.js} +84 -3
- package/dist/{chunk-ZQUCGISK.js → chunk-LTA4LQTH.js} +6 -4
- package/dist/{chunk-D22NUQTL.js → chunk-QBTQXCAI.js} +185 -1
- package/dist/{chunk-MUZ5WYE3.js → chunk-VPHP7ERH.js} +18 -9
- package/dist/{chunk-U5BX3ISQ.js → chunk-YMJL66MY.js} +10 -6
- package/dist/index.cjs +220 -20
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -12
- package/dist/src/agents/index.cjs +10 -6
- package/dist/src/agents/index.js +3 -3
- package/dist/src/agents/mcp_agent.d.ts.map +1 -1
- package/dist/src/browser.cjs +200 -10
- package/dist/src/browser.js +7 -7
- package/dist/src/client/prompts.js +2 -2
- package/dist/src/connectors/base.d.ts +2 -2
- package/dist/src/connectors/base.d.ts.map +1 -1
- package/dist/src/oauth-helper.d.ts.map +1 -1
- package/dist/src/react/WidgetControls.d.ts.map +1 -1
- package/dist/src/react/index.cjs +207 -12
- package/dist/src/react/index.js +4 -4
- package/dist/src/react/useMcp.d.ts.map +1 -1
- package/dist/src/server/endpoints/mount-mcp.d.ts +4 -1
- package/dist/src/server/endpoints/mount-mcp.d.ts.map +1 -1
- package/dist/src/server/index.cjs +268 -125
- package/dist/src/server/index.d.ts +2 -2
- package/dist/src/server/index.d.ts.map +1 -1
- package/dist/src/server/index.js +188 -126
- package/dist/src/server/mcp-server.d.ts +21 -10
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/dist/src/server/oauth/middleware.d.ts.map +1 -1
- package/dist/src/server/oauth/providers/auth0.d.ts +1 -1
- package/dist/src/server/oauth/providers/auth0.d.ts.map +1 -1
- package/dist/src/server/oauth/providers/custom.d.ts +4 -2
- package/dist/src/server/oauth/providers/custom.d.ts.map +1 -1
- package/dist/src/server/oauth/providers/keycloak.d.ts +1 -1
- package/dist/src/server/oauth/providers/keycloak.d.ts.map +1 -1
- package/dist/src/server/oauth/providers/supabase.d.ts +1 -1
- package/dist/src/server/oauth/providers/supabase.d.ts.map +1 -1
- package/dist/src/server/oauth/providers/types.d.ts +9 -5
- package/dist/src/server/oauth/providers/types.d.ts.map +1 -1
- package/dist/src/server/oauth/providers.d.ts +27 -9
- package/dist/src/server/oauth/providers.d.ts.map +1 -1
- package/dist/src/server/oauth/setup.d.ts +5 -4
- package/dist/src/server/oauth/setup.d.ts.map +1 -1
- package/dist/src/server/oauth/utils.d.ts +3 -2
- package/dist/src/server/oauth/utils.d.ts.map +1 -1
- package/dist/src/server/prompts/index.d.ts +5 -4
- package/dist/src/server/prompts/index.d.ts.map +1 -1
- package/dist/src/server/resources/index.d.ts +43 -24
- package/dist/src/server/resources/index.d.ts.map +1 -1
- package/dist/src/server/sessions/session-manager.d.ts +11 -5
- package/dist/src/server/sessions/session-manager.d.ts.map +1 -1
- package/dist/src/server/tools/tool-execution-helpers.d.ts +31 -8
- package/dist/src/server/tools/tool-execution-helpers.d.ts.map +1 -1
- package/dist/src/server/tools/tool-registration.d.ts +21 -7
- package/dist/src/server/tools/tool-registration.d.ts.map +1 -1
- package/dist/src/server/types/common.d.ts +25 -9
- package/dist/src/server/types/common.d.ts.map +1 -1
- package/dist/src/server/types/index.d.ts +3 -3
- package/dist/src/server/types/index.d.ts.map +1 -1
- package/dist/src/server/types/prompt.d.ts +2 -1
- package/dist/src/server/types/prompt.d.ts.map +1 -1
- package/dist/src/server/types/resource.d.ts +54 -9
- package/dist/src/server/types/resource.d.ts.map +1 -1
- package/dist/src/server/types/tool-context.d.ts +115 -0
- package/dist/src/server/types/tool-context.d.ts.map +1 -1
- package/dist/src/server/types/tool.d.ts +1 -1
- package/dist/src/server/types/tool.d.ts.map +1 -1
- package/dist/src/server/types/widget.d.ts +2 -1
- package/dist/src/server/types/widget.d.ts.map +1 -1
- package/dist/src/server/widgets/index.d.ts +3 -3
- package/dist/src/server/widgets/index.d.ts.map +1 -1
- package/dist/src/server/widgets/mount-widgets-dev.d.ts.map +1 -1
- package/dist/src/server/widgets/ui-resource-registration.d.ts +11 -25
- package/dist/src/server/widgets/ui-resource-registration.d.ts.map +1 -1
- package/dist/src/server/widgets/widget-helpers.d.ts +11 -6
- package/dist/src/server/widgets/widget-helpers.d.ts.map +1 -1
- package/dist/src/server/widgets/widget-types.d.ts +3 -3
- package/dist/src/server/widgets/widget-types.d.ts.map +1 -1
- package/dist/src/session.d.ts +337 -2
- package/dist/src/session.d.ts.map +1 -1
- package/dist/{tool-execution-helpers-BQJTPWPN.js → tool-execution-helpers-2LGVSS7L.js} +1 -1
- package/package.json +3 -3
|
@@ -227,9 +227,10 @@ function createElicitMethod(elicitInput) {
|
|
|
227
227
|
data: validatedData
|
|
228
228
|
};
|
|
229
229
|
} catch (error) {
|
|
230
|
+
const err = error;
|
|
230
231
|
throw new ElicitationValidationError(
|
|
231
|
-
`Elicitation data validation failed: ${
|
|
232
|
-
|
|
232
|
+
`Elicitation data validation failed: ${err.message}`,
|
|
233
|
+
err
|
|
233
234
|
);
|
|
234
235
|
}
|
|
235
236
|
}
|
|
@@ -305,7 +306,70 @@ function createLogMethod(sendNotification, minLogLevel) {
|
|
|
305
306
|
};
|
|
306
307
|
}
|
|
307
308
|
__name(createLogMethod, "createLogMethod");
|
|
308
|
-
function
|
|
309
|
+
function createClientCapabilityChecker(clientCapabilities) {
|
|
310
|
+
const caps = clientCapabilities || {};
|
|
311
|
+
return {
|
|
312
|
+
can(capability) {
|
|
313
|
+
return capability in caps;
|
|
314
|
+
},
|
|
315
|
+
capabilities() {
|
|
316
|
+
return { ...caps };
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
__name(createClientCapabilityChecker, "createClientCapabilityChecker");
|
|
321
|
+
function createSendNotificationMethod(sessionId, sessions) {
|
|
322
|
+
if (!sessionId || !sessions) {
|
|
323
|
+
return void 0;
|
|
324
|
+
}
|
|
325
|
+
return async (method, params) => {
|
|
326
|
+
const session = sessions.get(sessionId);
|
|
327
|
+
if (!session?.sendNotification) {
|
|
328
|
+
console.warn(
|
|
329
|
+
`[MCP] Cannot send notification to session ${sessionId} - no sendNotification function`
|
|
330
|
+
);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
try {
|
|
334
|
+
await session.sendNotification({
|
|
335
|
+
method,
|
|
336
|
+
params: params || {}
|
|
337
|
+
});
|
|
338
|
+
} catch (error) {
|
|
339
|
+
console.error(
|
|
340
|
+
`[MCP] Error sending notification to session ${sessionId}:`,
|
|
341
|
+
error
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
__name(createSendNotificationMethod, "createSendNotificationMethod");
|
|
347
|
+
function createSendNotificationToSessionMethod(sessions) {
|
|
348
|
+
if (!sessions) {
|
|
349
|
+
return void 0;
|
|
350
|
+
}
|
|
351
|
+
return async (sessionId, method, params) => {
|
|
352
|
+
const session = sessions.get(sessionId);
|
|
353
|
+
if (!session?.sendNotification) {
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
try {
|
|
357
|
+
await session.sendNotification({
|
|
358
|
+
method,
|
|
359
|
+
params: params || {}
|
|
360
|
+
});
|
|
361
|
+
return true;
|
|
362
|
+
} catch (error) {
|
|
363
|
+
console.error(
|
|
364
|
+
`[MCP] Error sending notification to session ${sessionId}:`,
|
|
365
|
+
error
|
|
366
|
+
);
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
__name(createSendNotificationToSessionMethod, "createSendNotificationToSessionMethod");
|
|
372
|
+
function createEnhancedContext(baseContext, createMessage, elicitInput, progressToken, sendNotification, minLogLevel, clientCapabilities, sessionId, sessions) {
|
|
309
373
|
const enhancedContext = baseContext ? Object.create(baseContext) : {};
|
|
310
374
|
enhancedContext.sample = createSampleMethod(
|
|
311
375
|
createMessage,
|
|
@@ -318,6 +382,23 @@ function createEnhancedContext(baseContext, createMessage, elicitInput, progress
|
|
|
318
382
|
sendNotification
|
|
319
383
|
);
|
|
320
384
|
enhancedContext.log = createLogMethod(sendNotification, minLogLevel);
|
|
385
|
+
enhancedContext.client = createClientCapabilityChecker(clientCapabilities);
|
|
386
|
+
if (sessionId) {
|
|
387
|
+
enhancedContext.session = {
|
|
388
|
+
sessionId
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
const sendNotificationMethod = createSendNotificationMethod(
|
|
392
|
+
sessionId,
|
|
393
|
+
sessions
|
|
394
|
+
);
|
|
395
|
+
if (sendNotificationMethod) {
|
|
396
|
+
enhancedContext.sendNotification = sendNotificationMethod;
|
|
397
|
+
}
|
|
398
|
+
const sendNotificationToSessionMethod = createSendNotificationToSessionMethod(sessions);
|
|
399
|
+
if (sendNotificationToSessionMethod) {
|
|
400
|
+
enhancedContext.sendNotificationToSession = sendNotificationToSessionMethod;
|
|
401
|
+
}
|
|
321
402
|
return enhancedContext;
|
|
322
403
|
}
|
|
323
404
|
__name(createEnhancedContext, "createEnhancedContext");
|
|
@@ -238,7 +238,7 @@ var BaseConnector = class {
|
|
|
238
238
|
}
|
|
239
239
|
logger.debug("Caching server capabilities & tools");
|
|
240
240
|
const capabilities = this.client.getServerCapabilities();
|
|
241
|
-
this.capabilitiesCache = capabilities;
|
|
241
|
+
this.capabilitiesCache = capabilities || null;
|
|
242
242
|
const serverInfo = this.client.getServerVersion();
|
|
243
243
|
this.serverInfoCache = serverInfo || null;
|
|
244
244
|
const listToolsRes = await this.client.listTools(
|
|
@@ -260,7 +260,7 @@ var BaseConnector = class {
|
|
|
260
260
|
}
|
|
261
261
|
/** Expose cached server capabilities. */
|
|
262
262
|
get serverCapabilities() {
|
|
263
|
-
return this.capabilitiesCache;
|
|
263
|
+
return this.capabilitiesCache || {};
|
|
264
264
|
}
|
|
265
265
|
/** Expose cached server info. */
|
|
266
266
|
get serverInfo() {
|
|
@@ -327,7 +327,8 @@ var BaseConnector = class {
|
|
|
327
327
|
} while (cursor);
|
|
328
328
|
return { resources: allResources };
|
|
329
329
|
} catch (err) {
|
|
330
|
-
|
|
330
|
+
const error = err;
|
|
331
|
+
if (error.code === -32601) {
|
|
331
332
|
logger.debug("Server advertised resources but method not found");
|
|
332
333
|
return { resources: [] };
|
|
333
334
|
}
|
|
@@ -394,7 +395,8 @@ var BaseConnector = class {
|
|
|
394
395
|
logger.debug("Listing prompts");
|
|
395
396
|
return await this.client.listPrompts();
|
|
396
397
|
} catch (err) {
|
|
397
|
-
|
|
398
|
+
const error = err;
|
|
399
|
+
if (error.code === -32601) {
|
|
398
400
|
logger.debug("Server advertised prompts but method not found");
|
|
399
401
|
return { prompts: [] };
|
|
400
402
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseConnector
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LTA4LQTH.js";
|
|
4
4
|
import {
|
|
5
5
|
logger
|
|
6
6
|
} from "./chunk-34R6SIER.js";
|
|
@@ -82,6 +82,190 @@ var MCPSession = class {
|
|
|
82
82
|
getRoots() {
|
|
83
83
|
return this.connector.getRoots();
|
|
84
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Get the cached list of tools from the server.
|
|
87
|
+
*
|
|
88
|
+
* @returns Array of available tools
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const tools = session.tools;
|
|
93
|
+
* console.log(`Available tools: ${tools.map(t => t.name).join(", ")}`);
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
get tools() {
|
|
97
|
+
return this.connector.tools;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get the server capabilities advertised during initialization.
|
|
101
|
+
*
|
|
102
|
+
* @returns Server capabilities object
|
|
103
|
+
*/
|
|
104
|
+
get serverCapabilities() {
|
|
105
|
+
return this.connector.serverCapabilities;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get the server information (name and version).
|
|
109
|
+
*
|
|
110
|
+
* @returns Server info object or null if not available
|
|
111
|
+
*/
|
|
112
|
+
get serverInfo() {
|
|
113
|
+
return this.connector.serverInfo;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Call a tool on the server.
|
|
117
|
+
*
|
|
118
|
+
* @param name - Name of the tool to call
|
|
119
|
+
* @param args - Arguments to pass to the tool
|
|
120
|
+
* @param options - Optional request options (timeout, progress handlers, etc.)
|
|
121
|
+
* @returns Result from the tool execution
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* const result = await session.callTool("add", { a: 5, b: 3 });
|
|
126
|
+
* console.log(`Result: ${result.content[0].text}`);
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
async callTool(name, args, options) {
|
|
130
|
+
return this.connector.callTool(name, args, options);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* List resources from the server with optional pagination.
|
|
134
|
+
*
|
|
135
|
+
* @param cursor - Optional cursor for pagination
|
|
136
|
+
* @param options - Request options
|
|
137
|
+
* @returns Resource list with optional nextCursor for pagination
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* const result = await session.listResources();
|
|
142
|
+
* console.log(`Found ${result.resources.length} resources`);
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
async listResources(cursor, options) {
|
|
146
|
+
return this.connector.listResources(cursor, options);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* List all resources from the server, automatically handling pagination.
|
|
150
|
+
*
|
|
151
|
+
* @param options - Request options
|
|
152
|
+
* @returns Complete list of all resources
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* const result = await session.listAllResources();
|
|
157
|
+
* console.log(`Total resources: ${result.resources.length}`);
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
async listAllResources(options) {
|
|
161
|
+
return this.connector.listAllResources(options);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* List resource templates from the server.
|
|
165
|
+
*
|
|
166
|
+
* @param options - Request options
|
|
167
|
+
* @returns List of available resource templates
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* const result = await session.listResourceTemplates();
|
|
172
|
+
* console.log(`Available templates: ${result.resourceTemplates.length}`);
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
async listResourceTemplates(options) {
|
|
176
|
+
return this.connector.listResourceTemplates(options);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Read a resource by URI.
|
|
180
|
+
*
|
|
181
|
+
* @param uri - URI of the resource to read
|
|
182
|
+
* @param options - Request options
|
|
183
|
+
* @returns Resource content
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* const resource = await session.readResource("file:///path/to/file.txt");
|
|
188
|
+
* console.log(resource.contents);
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
async readResource(uri, options) {
|
|
192
|
+
return this.connector.readResource(uri, options);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Subscribe to resource updates.
|
|
196
|
+
*
|
|
197
|
+
* @param uri - URI of the resource to subscribe to
|
|
198
|
+
* @param options - Request options
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```typescript
|
|
202
|
+
* await session.subscribeToResource("file:///path/to/file.txt");
|
|
203
|
+
* // Now you'll receive notifications when this resource changes
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
async subscribeToResource(uri, options) {
|
|
207
|
+
return this.connector.subscribeToResource(uri, options);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Unsubscribe from resource updates.
|
|
211
|
+
*
|
|
212
|
+
* @param uri - URI of the resource to unsubscribe from
|
|
213
|
+
* @param options - Request options
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```typescript
|
|
217
|
+
* await session.unsubscribeFromResource("file:///path/to/file.txt");
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
async unsubscribeFromResource(uri, options) {
|
|
221
|
+
return this.connector.unsubscribeFromResource(uri, options);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* List available prompts from the server.
|
|
225
|
+
*
|
|
226
|
+
* @returns List of available prompts
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```typescript
|
|
230
|
+
* const result = await session.listPrompts();
|
|
231
|
+
* console.log(`Available prompts: ${result.prompts.length}`);
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
async listPrompts() {
|
|
235
|
+
return this.connector.listPrompts();
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Get a specific prompt with arguments.
|
|
239
|
+
*
|
|
240
|
+
* @param name - Name of the prompt to get
|
|
241
|
+
* @param args - Arguments for the prompt
|
|
242
|
+
* @returns Prompt result
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```typescript
|
|
246
|
+
* const prompt = await session.getPrompt("greeting", { name: "Alice" });
|
|
247
|
+
* console.log(prompt.messages);
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
async getPrompt(name, args) {
|
|
251
|
+
return this.connector.getPrompt(name, args);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Send a raw request through the client.
|
|
255
|
+
*
|
|
256
|
+
* @param method - MCP method name
|
|
257
|
+
* @param params - Request parameters
|
|
258
|
+
* @param options - Request options
|
|
259
|
+
* @returns Response from the server
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* const result = await session.request("custom/method", { key: "value" });
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
async request(method, params = null, options) {
|
|
267
|
+
return this.connector.request(method, params, options);
|
|
268
|
+
}
|
|
85
269
|
};
|
|
86
270
|
|
|
87
271
|
// src/connectors/http.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BrowserMCPClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QBTQXCAI.js";
|
|
4
4
|
import {
|
|
5
5
|
BrowserOAuthClientProvider,
|
|
6
6
|
sanitizeUrl
|
|
@@ -260,8 +260,9 @@ function useMcp(options) {
|
|
|
260
260
|
}
|
|
261
261
|
return "success";
|
|
262
262
|
} catch (err) {
|
|
263
|
-
const
|
|
264
|
-
|
|
263
|
+
const error2 = err;
|
|
264
|
+
const errorMessage = error2?.message || String(err);
|
|
265
|
+
if (error2.code === 401 || errorMessage.includes("401") || errorMessage.includes("Unauthorized")) {
|
|
265
266
|
if (authProviderRef.current) {
|
|
266
267
|
addLog(
|
|
267
268
|
"info",
|
|
@@ -309,7 +310,10 @@ function useMcp(options) {
|
|
|
309
310
|
);
|
|
310
311
|
return "failed";
|
|
311
312
|
}
|
|
312
|
-
failConnection(
|
|
313
|
+
failConnection(
|
|
314
|
+
errorMessage,
|
|
315
|
+
error2 instanceof Error ? error2 : new Error(String(error2))
|
|
316
|
+
);
|
|
313
317
|
return "failed";
|
|
314
318
|
}
|
|
315
319
|
}, "tryConnectWithTransport");
|
|
@@ -1183,7 +1187,8 @@ function WidgetControls({
|
|
|
1183
1187
|
const result = await callTool(toolName, args);
|
|
1184
1188
|
setActionResult(`Success: ${JSON.stringify(result, null, 2)}`);
|
|
1185
1189
|
} catch (error) {
|
|
1186
|
-
|
|
1190
|
+
const err = error;
|
|
1191
|
+
setActionResult(`Error: ${err.message}`);
|
|
1187
1192
|
}
|
|
1188
1193
|
}, "handleCallTool");
|
|
1189
1194
|
const handleSendFollowUpMessage = /* @__PURE__ */ __name(async () => {
|
|
@@ -1192,7 +1197,8 @@ function WidgetControls({
|
|
|
1192
1197
|
await sendFollowUpMessage(followUpMessage);
|
|
1193
1198
|
setActionResult("Follow-up message sent successfully");
|
|
1194
1199
|
} catch (error) {
|
|
1195
|
-
|
|
1200
|
+
const err = error;
|
|
1201
|
+
setActionResult(`Error: ${err.message}`);
|
|
1196
1202
|
}
|
|
1197
1203
|
}, "handleSendFollowUpMessage");
|
|
1198
1204
|
const handleOpenExternal = /* @__PURE__ */ __name(() => {
|
|
@@ -1200,7 +1206,8 @@ function WidgetControls({
|
|
|
1200
1206
|
openExternal(externalUrl);
|
|
1201
1207
|
setActionResult(`Opened external link: ${externalUrl}`);
|
|
1202
1208
|
} catch (error) {
|
|
1203
|
-
|
|
1209
|
+
const err = error;
|
|
1210
|
+
setActionResult(`Error: ${err.message}`);
|
|
1204
1211
|
}
|
|
1205
1212
|
}, "handleOpenExternal");
|
|
1206
1213
|
const handleRequestDisplayMode = /* @__PURE__ */ __name(async (mode) => {
|
|
@@ -1209,7 +1216,8 @@ function WidgetControls({
|
|
|
1209
1216
|
const result = await requestDisplayMode(mode);
|
|
1210
1217
|
setActionResult(`Display mode granted: ${result.mode}`);
|
|
1211
1218
|
} catch (error) {
|
|
1212
|
-
|
|
1219
|
+
const err = error;
|
|
1220
|
+
setActionResult(`Error: ${err.message}`);
|
|
1213
1221
|
}
|
|
1214
1222
|
}, "handleRequestDisplayMode");
|
|
1215
1223
|
const handleSetState = /* @__PURE__ */ __name(async () => {
|
|
@@ -1219,7 +1227,8 @@ function WidgetControls({
|
|
|
1219
1227
|
await setState(newState);
|
|
1220
1228
|
setActionResult(`State updated: ${JSON.stringify(newState, null, 2)}`);
|
|
1221
1229
|
} catch (error) {
|
|
1222
|
-
|
|
1230
|
+
const err = error;
|
|
1231
|
+
setActionResult(`Error: ${err.message}`);
|
|
1223
1232
|
}
|
|
1224
1233
|
}, "handleSetState");
|
|
1225
1234
|
const handleFullscreen = /* @__PURE__ */ __name(async () => {
|
|
@@ -2857,7 +2857,7 @@ var MCPAgent = class {
|
|
|
2857
2857
|
const historyToUse = externalHistory ?? this.conversationHistory;
|
|
2858
2858
|
const langchainHistory = [];
|
|
2859
2859
|
for (const msg of historyToUse) {
|
|
2860
|
-
if (this._isHumanMessageLike(msg) || this._isAIMessageLike(msg)) {
|
|
2860
|
+
if (this._isHumanMessageLike(msg) || this._isAIMessageLike(msg) || this._isToolMessageLike(msg)) {
|
|
2861
2861
|
langchainHistory.push(msg);
|
|
2862
2862
|
}
|
|
2863
2863
|
}
|
|
@@ -2990,9 +2990,9 @@ var MCPAgent = class {
|
|
|
2990
2990
|
}
|
|
2991
2991
|
}
|
|
2992
2992
|
if (this.memoryEnabled) {
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
this.addToHistory(
|
|
2993
|
+
const newMessages = accumulatedMessages.slice(langchainHistory.length);
|
|
2994
|
+
for (const msg of newMessages) {
|
|
2995
|
+
this.addToHistory(msg);
|
|
2996
2996
|
}
|
|
2997
2997
|
}
|
|
2998
2998
|
if (outputSchema && finalOutput) {
|
|
@@ -3427,7 +3427,9 @@ ${formatPrompt}`
|
|
|
3427
3427
|
let chunkCount = 0;
|
|
3428
3428
|
for await (const chunk of stream) {
|
|
3429
3429
|
chunkCount++;
|
|
3430
|
-
logger.
|
|
3430
|
+
logger.debug(
|
|
3431
|
+
`Chunk ${chunkCount}: ${JSON.stringify(chunk, null, 2)}`
|
|
3432
|
+
);
|
|
3431
3433
|
if (typeof chunk === "string") {
|
|
3432
3434
|
try {
|
|
3433
3435
|
structuredResult = JSON.parse(chunk);
|
|
@@ -3444,7 +3446,9 @@ ${formatPrompt}`
|
|
|
3444
3446
|
}
|
|
3445
3447
|
}
|
|
3446
3448
|
if (chunkCount % 10 === 0) {
|
|
3447
|
-
logger.
|
|
3449
|
+
logger.debug(
|
|
3450
|
+
`\u{1F504} Structured output streaming: ${chunkCount} chunks`
|
|
3451
|
+
);
|
|
3448
3452
|
}
|
|
3449
3453
|
}
|
|
3450
3454
|
logger.info(
|