@mcpjam/sdk 0.1.4 → 0.8.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/dist/index.d.ts CHANGED
@@ -1,9 +1,1942 @@
1
- export { ElicitationHandler, ExecuteToolArguments, MCPClientManager, MCPClientManagerConfig, MCPConnectionStatus, MCPConvertedToolSet, MCPGetPromptResult, MCPPrompt, MCPPromptListResult, MCPReadResourceResult, MCPResource, MCPResourceListResult, MCPServerConfig, MCPServerSummary, MCPToolSchemaOverrides } from './mcp-client-manager/index.js';
2
- import 'zod';
3
- import '@modelcontextprotocol/sdk/client/index.js';
4
- import '@modelcontextprotocol/sdk/client/sse.js';
5
- import '@modelcontextprotocol/sdk/client/streamableHttp.js';
6
- import '@modelcontextprotocol/sdk/shared/protocol.js';
7
- import '@modelcontextprotocol/sdk/types.js';
8
- import 'ai';
9
- import '@ai-sdk/provider-utils';
1
+ import { ClientOptions, Client } from '@modelcontextprotocol/sdk/client/index.js';
2
+ import { StreamableHTTPClientTransportOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
3
+ import { SSEClientTransportOptions } from '@modelcontextprotocol/sdk/client/sse.js';
4
+ import { RequestOptions } from '@modelcontextprotocol/sdk/shared/protocol.js';
5
+ import { ElicitResult, ElicitRequest, Tool as Tool$1, CallToolResult, ServerCapabilities, LoggingLevel } from '@modelcontextprotocol/sdk/types.js';
6
+ export { ElicitResult } from '@modelcontextprotocol/sdk/types.js';
7
+ import { ToolSet, dynamicTool, AssistantModelMessage, ModelMessage, ToolModelMessage, UserModelMessage } from 'ai';
8
+ import { createOpenAI } from '@ai-sdk/openai';
9
+
10
+ /**
11
+ * TypeScript types and interfaces for MCPClientManager
12
+ */
13
+
14
+ /**
15
+ * Client capability options extracted from MCP SDK ClientOptions
16
+ */
17
+ type ClientCapabilityOptions = NonNullable<ClientOptions["capabilities"]>;
18
+ /**
19
+ * Base configuration shared by all server types
20
+ */
21
+ type BaseServerConfig = {
22
+ /** Client capabilities to advertise to this server */
23
+ capabilities?: ClientCapabilityOptions;
24
+ /** Request timeout in milliseconds */
25
+ timeout?: number;
26
+ /** Client version to report */
27
+ version?: string;
28
+ /** Error handler for this server */
29
+ onError?: (error: unknown) => void;
30
+ /** Enable simple console logging of JSON-RPC traffic */
31
+ logJsonRpc?: boolean;
32
+ /** Custom logger for JSON-RPC traffic (overrides logJsonRpc) */
33
+ rpcLogger?: RpcLogger;
34
+ };
35
+ /**
36
+ * Configuration for stdio-based MCP servers (subprocess)
37
+ */
38
+ type StdioServerConfig = BaseServerConfig & {
39
+ /** Command to execute */
40
+ command: string;
41
+ /** Command arguments */
42
+ args?: string[];
43
+ /** Environment variables */
44
+ env?: Record<string, string>;
45
+ url?: never;
46
+ accessToken?: never;
47
+ requestInit?: never;
48
+ eventSourceInit?: never;
49
+ authProvider?: never;
50
+ reconnectionOptions?: never;
51
+ sessionId?: never;
52
+ preferSSE?: never;
53
+ };
54
+ /**
55
+ * Configuration for HTTP-based MCP servers (SSE or Streamable HTTP)
56
+ */
57
+ type HttpServerConfig = BaseServerConfig & {
58
+ /** Server URL */
59
+ url: string;
60
+ /**
61
+ * Access token for Bearer authentication.
62
+ * If provided, adds `Authorization: Bearer <accessToken>` header to requests.
63
+ */
64
+ accessToken?: string;
65
+ /** Additional request initialization options */
66
+ requestInit?: StreamableHTTPClientTransportOptions["requestInit"];
67
+ /** SSE-specific event source options */
68
+ eventSourceInit?: SSEClientTransportOptions["eventSourceInit"];
69
+ /** OAuth auth provider */
70
+ authProvider?: StreamableHTTPClientTransportOptions["authProvider"];
71
+ /** Reconnection options for Streamable HTTP */
72
+ reconnectionOptions?: StreamableHTTPClientTransportOptions["reconnectionOptions"];
73
+ /** Session ID for Streamable HTTP */
74
+ sessionId?: StreamableHTTPClientTransportOptions["sessionId"];
75
+ /** Prefer SSE transport over Streamable HTTP */
76
+ preferSSE?: boolean;
77
+ command?: never;
78
+ args?: never;
79
+ env?: never;
80
+ };
81
+ /**
82
+ * Union type for all server configurations
83
+ */
84
+ type MCPServerConfig = StdioServerConfig | HttpServerConfig;
85
+ /**
86
+ * Configuration map for multiple servers (serverId -> config)
87
+ */
88
+ type MCPClientManagerConfig = Record<string, MCPServerConfig>;
89
+ /**
90
+ * Connection status for a server
91
+ */
92
+ type MCPConnectionStatus = "connected" | "connecting" | "disconnected";
93
+ /**
94
+ * Summary information for a server
95
+ */
96
+ type ServerSummary = {
97
+ id: string;
98
+ status: MCPConnectionStatus;
99
+ config?: MCPServerConfig;
100
+ };
101
+ /**
102
+ * Event passed to RPC loggers
103
+ */
104
+ type RpcLogEvent = {
105
+ direction: "send" | "receive";
106
+ message: unknown;
107
+ serverId: string;
108
+ };
109
+ /**
110
+ * Function type for JSON-RPC logging
111
+ */
112
+ type RpcLogger = (event: RpcLogEvent) => void;
113
+ /**
114
+ * Progress event from server operations
115
+ */
116
+ type ProgressEvent = {
117
+ serverId: string;
118
+ progressToken: string | number;
119
+ progress: number;
120
+ total?: number;
121
+ message?: string;
122
+ };
123
+ /**
124
+ * Function type for progress handling
125
+ */
126
+ type ProgressHandler = (event: ProgressEvent) => void;
127
+ /**
128
+ * Options for MCPClientManager constructor
129
+ */
130
+ interface MCPClientManagerOptions {
131
+ /** Default client name to report to servers */
132
+ defaultClientName?: string;
133
+ /** Default client version to report */
134
+ defaultClientVersion?: string;
135
+ /** Default capabilities to advertise */
136
+ defaultCapabilities?: ClientCapabilityOptions;
137
+ /** Default request timeout in milliseconds */
138
+ defaultTimeout?: number;
139
+ /** Enable JSON-RPC logging for all servers by default */
140
+ defaultLogJsonRpc?: boolean;
141
+ /** Global JSON-RPC logger */
142
+ rpcLogger?: RpcLogger;
143
+ /** Global progress handler */
144
+ progressHandler?: ProgressHandler;
145
+ }
146
+ /**
147
+ * Arguments passed to tool execution
148
+ */
149
+ type ExecuteToolArguments = Record<string, unknown>;
150
+ /**
151
+ * Options for task-augmented tool calls
152
+ */
153
+ type TaskOptions = {
154
+ /** Time-to-live for the task in milliseconds */
155
+ ttl?: number;
156
+ };
157
+ /**
158
+ * Handler for server-specific elicitation requests
159
+ */
160
+ type ElicitationHandler = (params: ElicitRequest["params"]) => Promise<ElicitResult> | ElicitResult;
161
+ /**
162
+ * Request passed to global elicitation callback
163
+ */
164
+ type ElicitationCallbackRequest = {
165
+ requestId: string;
166
+ message: string;
167
+ schema: unknown;
168
+ /** Task ID if this elicitation is related to a task (MCP Tasks spec 2025-11-25) */
169
+ relatedTaskId?: string;
170
+ };
171
+ /**
172
+ * Global callback for handling elicitation requests
173
+ */
174
+ type ElicitationCallback = (request: ElicitationCallbackRequest) => Promise<ElicitResult> | ElicitResult;
175
+ /**
176
+ * Task status values
177
+ */
178
+ type MCPTaskStatus = "working" | "input_required" | "completed" | "failed" | "cancelled";
179
+ /**
180
+ * MCP Task object
181
+ */
182
+ type MCPTask = {
183
+ taskId: string;
184
+ status: MCPTaskStatus;
185
+ statusMessage?: string;
186
+ createdAt: string;
187
+ lastUpdatedAt: string;
188
+ ttl: number | null;
189
+ pollInterval?: number;
190
+ };
191
+ /**
192
+ * Result from listing tasks
193
+ */
194
+ type MCPListTasksResult = {
195
+ tasks: MCPTask[];
196
+ nextCursor?: string;
197
+ };
198
+ type ClientRequestOptions = RequestOptions;
199
+ type ListResourcesParams = Parameters<Client["listResources"]>[0];
200
+ type ListResourceTemplatesParams = Parameters<Client["listResourceTemplates"]>[0];
201
+ type ReadResourceParams = Parameters<Client["readResource"]>[0];
202
+ type SubscribeResourceParams = Parameters<Client["subscribeResource"]>[0];
203
+ type UnsubscribeResourceParams = Parameters<Client["unsubscribeResource"]>[0];
204
+ type ListPromptsParams = Parameters<Client["listPrompts"]>[0];
205
+ type GetPromptParams = Parameters<Client["getPrompt"]>[0];
206
+ type ListToolsResult = Awaited<ReturnType<Client["listTools"]>>;
207
+ type MCPPromptListResult = Awaited<ReturnType<Client["listPrompts"]>>;
208
+ type MCPPrompt = MCPPromptListResult["prompts"][number];
209
+ type MCPGetPromptResult = Awaited<ReturnType<Client["getPrompt"]>>;
210
+ type MCPResourceListResult = Awaited<ReturnType<Client["listResources"]>>;
211
+ type MCPResource = MCPResourceListResult["resources"][number];
212
+ type MCPReadResourceResult = Awaited<ReturnType<Client["readResource"]>>;
213
+ type MCPResourceTemplateListResult = Awaited<ReturnType<Client["listResourceTemplates"]>>;
214
+ type MCPResourceTemplate = MCPResourceTemplateListResult["resourceTemplates"][number];
215
+ type MCPServerSummary = ServerSummary;
216
+ /**
217
+ * An MCP tool with an execute function pre-wired to call the manager.
218
+ * Extends the official MCP SDK Tool type.
219
+ * Returned by MCPClientManager.getTools().
220
+ */
221
+ /** Options for tool execution */
222
+ interface ToolExecuteOptions {
223
+ /** Abort signal for cancellation */
224
+ signal?: AbortSignal;
225
+ }
226
+ interface Tool extends Tool$1 {
227
+ /** Execute the tool with the given arguments */
228
+ execute: (args: Record<string, unknown>, options?: ToolExecuteOptions) => Promise<CallToolResult>;
229
+ _meta?: {
230
+ _serverId: string;
231
+ [key: string]: unknown;
232
+ };
233
+ }
234
+
235
+ /**
236
+ * AI SDK compatible tool set (Record<string, CoreTool>).
237
+ * Returned by MCPClientManager.getToolsForAiSdk().
238
+ * Can be passed directly to AI SDK's generateText().
239
+ */
240
+ type AiSdkTool = ToolSet;
241
+
242
+ /**
243
+ * Notification handler management for MCPClientManager
244
+ */
245
+
246
+ type NotificationSchema = Parameters<Client["setNotificationHandler"]>[0];
247
+ type NotificationHandler = Parameters<Client["setNotificationHandler"]>[1];
248
+
249
+ /**
250
+ * Tool conversion utilities for integrating MCP tools with Vercel AI SDK
251
+ */
252
+
253
+ /**
254
+ * Input schema type for tool definitions
255
+ */
256
+ type ToolInputSchema = Parameters<typeof dynamicTool>[0]["inputSchema"];
257
+ /**
258
+ * Schema overrides for specific tools
259
+ * Maps tool name to custom input schema definition
260
+ */
261
+ type ToolSchemaOverrides = Record<string, {
262
+ inputSchema: ToolInputSchema;
263
+ }>;
264
+ /**
265
+ * Checks whether a tool is an MCP App by inspecting its _meta for a UI resource URI.
266
+ *
267
+ * @param toolMeta - The tool's _meta field from listTools result
268
+ * @returns true if the tool is an MCP App
269
+ */
270
+ declare function isMcpAppTool(toolMeta: Record<string, unknown> | undefined): boolean;
271
+ /**
272
+ * Checks whether a tool is a ChatGPT App by inspecting its _meta for an output template.
273
+ *
274
+ * @param toolMeta - The tool's _meta field from listTools result
275
+ * @returns true if the tool is a ChatGPT App
276
+ */
277
+ declare function isChatGPTAppTool(toolMeta: Record<string, unknown> | undefined): boolean;
278
+ /**
279
+ * Removes only the _meta field from a tool result (shallow copy).
280
+ *
281
+ * @param result - The full tool call result
282
+ * @returns A shallow copy of the result without _meta
283
+ */
284
+ declare function scrubMetaFromToolResult(result: CallToolResult): CallToolResult;
285
+ /**
286
+ * Returns a shallow copy of a CallToolResult with _meta and structuredContent removed.
287
+ *
288
+ * @param result - The full tool call result
289
+ * @returns A scrubbed shallow copy without _meta and structuredContent
290
+ */
291
+ declare function scrubMetaAndStructuredContentFromToolResult(result: CallToolResult): CallToolResult;
292
+
293
+ /**
294
+ * Manages multiple MCP server connections with support for tools, resources,
295
+ * prompts, notifications, elicitation, and tasks.
296
+ *
297
+ * @example
298
+ * ```typescript
299
+ * const manager = new MCPClientManager({
300
+ * everything: {
301
+ * command: "npx",
302
+ * args: ["-y", "@modelcontextprotocol/server-everything"],
303
+ * },
304
+ * myServer: {
305
+ * url: "https://my-server.com/mcp",
306
+ * accessToken: "my-token",
307
+ * },
308
+ * });
309
+ *
310
+ * const tools = await manager.listTools("everything");
311
+ * const result = await manager.executeTool("everything", "add", { a: 1, b: 2 });
312
+ * ```
313
+ */
314
+ declare class MCPClientManager {
315
+ private readonly clientStates;
316
+ private readonly toolsMetadataCache;
317
+ private readonly notificationManager;
318
+ private readonly elicitationManager;
319
+ private readonly defaultClientName;
320
+ private readonly defaultClientVersion;
321
+ private readonly defaultCapabilities;
322
+ private readonly defaultTimeout;
323
+ private readonly defaultLogJsonRpc;
324
+ private readonly defaultRpcLogger?;
325
+ private readonly defaultProgressHandler?;
326
+ private progressTokenCounter;
327
+ /**
328
+ * Creates a new MCPClientManager.
329
+ *
330
+ * @param servers - Configuration map of server IDs to server configs
331
+ * @param options - Global options for the manager
332
+ */
333
+ constructor(servers?: MCPClientManagerConfig, options?: MCPClientManagerOptions);
334
+ /**
335
+ * Lists all registered server IDs.
336
+ */
337
+ listServers(): string[];
338
+ /**
339
+ * Checks if a server is registered.
340
+ */
341
+ hasServer(serverId: string): boolean;
342
+ /**
343
+ * Gets summaries for all registered servers.
344
+ */
345
+ getServerSummaries(): ServerSummary[];
346
+ /**
347
+ * Gets the connection status for a server.
348
+ */
349
+ getConnectionStatus(serverId: string): MCPConnectionStatus;
350
+ /**
351
+ * Gets the configuration for a server.
352
+ */
353
+ getServerConfig(serverId: string): MCPServerConfig | undefined;
354
+ /**
355
+ * Gets the capabilities reported by a server.
356
+ */
357
+ getServerCapabilities(serverId: string): ServerCapabilities | undefined;
358
+ /**
359
+ * Gets the underlying MCP Client for a server.
360
+ */
361
+ getClient(serverId: string): Client | undefined;
362
+ /**
363
+ * Gets initialization information for a connected server.
364
+ */
365
+ getInitializationInfo(serverId: string): {
366
+ protocolVersion: string | undefined;
367
+ transport: string;
368
+ serverCapabilities: {
369
+ experimental?: {
370
+ [x: string]: object;
371
+ } | undefined;
372
+ logging?: object | undefined;
373
+ completions?: object | undefined;
374
+ prompts?: {
375
+ listChanged?: boolean | undefined;
376
+ } | undefined;
377
+ resources?: {
378
+ subscribe?: boolean | undefined;
379
+ listChanged?: boolean | undefined;
380
+ } | undefined;
381
+ tools?: {
382
+ listChanged?: boolean | undefined;
383
+ } | undefined;
384
+ tasks?: {
385
+ [x: string]: unknown;
386
+ list?: object | undefined;
387
+ cancel?: object | undefined;
388
+ requests?: {
389
+ [x: string]: unknown;
390
+ tools?: {
391
+ [x: string]: unknown;
392
+ call?: object | undefined;
393
+ } | undefined;
394
+ } | undefined;
395
+ } | undefined;
396
+ } | undefined;
397
+ serverVersion: {
398
+ version: string;
399
+ name: string;
400
+ websiteUrl?: string | undefined;
401
+ description?: string | undefined;
402
+ icons?: {
403
+ src: string;
404
+ mimeType?: string | undefined;
405
+ sizes?: string[] | undefined;
406
+ theme?: "light" | "dark" | undefined;
407
+ }[] | undefined;
408
+ title?: string | undefined;
409
+ } | undefined;
410
+ instructions: string | undefined;
411
+ clientCapabilities: {
412
+ experimental?: {
413
+ [x: string]: object;
414
+ } | undefined;
415
+ sampling?: {
416
+ context?: object | undefined;
417
+ tools?: object | undefined;
418
+ } | undefined;
419
+ elicitation?: {
420
+ [x: string]: unknown;
421
+ form?: {
422
+ [x: string]: unknown;
423
+ applyDefaults?: boolean | undefined;
424
+ } | undefined;
425
+ url?: object | undefined;
426
+ } | undefined;
427
+ roots?: {
428
+ listChanged?: boolean | undefined;
429
+ } | undefined;
430
+ tasks?: {
431
+ [x: string]: unknown;
432
+ list?: object | undefined;
433
+ cancel?: object | undefined;
434
+ requests?: {
435
+ [x: string]: unknown;
436
+ sampling?: {
437
+ [x: string]: unknown;
438
+ createMessage?: object | undefined;
439
+ } | undefined;
440
+ elicitation?: {
441
+ [x: string]: unknown;
442
+ create?: object | undefined;
443
+ } | undefined;
444
+ } | undefined;
445
+ } | undefined;
446
+ };
447
+ } | undefined;
448
+ /**
449
+ * Connects to an MCP server.
450
+ *
451
+ * @param serverId - Unique identifier for the server
452
+ * @param config - Server configuration
453
+ * @returns The connected MCP Client
454
+ */
455
+ connectToServer(serverId: string, config: MCPServerConfig): Promise<Client>;
456
+ /**
457
+ * Disconnects from a server.
458
+ */
459
+ disconnectServer(serverId: string): Promise<void>;
460
+ /**
461
+ * Removes a server from the manager entirely.
462
+ */
463
+ removeServer(serverId: string): Promise<void>;
464
+ /**
465
+ * Disconnects from all servers.
466
+ */
467
+ disconnectAllServers(): Promise<void>;
468
+ /**
469
+ * Lists tools available from a server.
470
+ */
471
+ listTools(serverId: string, params?: Parameters<Client["listTools"]>[0], options?: ClientRequestOptions): Promise<ListToolsResult>;
472
+ /**
473
+ * Gets tools from multiple servers (or all servers if none specified).
474
+ * Returns tools with execute functions pre-wired to call this manager.
475
+ *
476
+ * @param serverIds - Server IDs to get tools from (or all if omitted)
477
+ * @returns Array of executable tools
478
+ *
479
+ * @example
480
+ * ```typescript
481
+ * const tools = await manager.getTools(["asana"]);
482
+ * const agent = new TestAgent({ tools, model: "openai/gpt-4o", apiKey });
483
+ * ```
484
+ */
485
+ getTools(serverIds?: string[]): Promise<Tool[]>;
486
+ /**
487
+ * Gets cached tool metadata for a server.
488
+ */
489
+ getAllToolsMetadata(serverId: string): Record<string, Record<string, any>>;
490
+ /**
491
+ * Gets tools formatted for Vercel AI SDK.
492
+ *
493
+ * @param serverIds - Server IDs to get tools from (or all if omitted)
494
+ * @param options - Schema options
495
+ * @returns AiSdkTool compatible with Vercel AI SDK's generateText()
496
+ */
497
+ getToolsForAiSdk(serverIds?: string[] | string, options?: {
498
+ schemas?: ToolSchemaOverrides | "automatic";
499
+ }): Promise<AiSdkTool>;
500
+ /**
501
+ * Executes a tool on a server.
502
+ *
503
+ * @param serverId - The server ID
504
+ * @param toolName - The tool name
505
+ * @param args - Tool arguments
506
+ * @param options - Request options
507
+ * @param taskOptions - Task options for async execution
508
+ */
509
+ executeTool(serverId: string, toolName: string, args?: ExecuteToolArguments, options?: ClientRequestOptions, taskOptions?: TaskOptions): Promise<{
510
+ [x: string]: unknown;
511
+ content: ({
512
+ type: "text";
513
+ text: string;
514
+ annotations?: {
515
+ audience?: ("user" | "assistant")[] | undefined;
516
+ priority?: number | undefined;
517
+ lastModified?: string | undefined;
518
+ } | undefined;
519
+ _meta?: Record<string, unknown> | undefined;
520
+ } | {
521
+ type: "image";
522
+ data: string;
523
+ mimeType: string;
524
+ annotations?: {
525
+ audience?: ("user" | "assistant")[] | undefined;
526
+ priority?: number | undefined;
527
+ lastModified?: string | undefined;
528
+ } | undefined;
529
+ _meta?: Record<string, unknown> | undefined;
530
+ } | {
531
+ type: "audio";
532
+ data: string;
533
+ mimeType: string;
534
+ annotations
535
+ /**
536
+ * Lists prompts available from a server.
537
+ */
538
+ ?: {
539
+ audience?: ("user" | "assistant")[] | undefined;
540
+ priority? /**
541
+ * Lists prompts available from a server.
542
+ */: number | undefined;
543
+ lastModified?: string | undefined;
544
+ } | undefined;
545
+ _meta?: Record<string, unknown> | undefined;
546
+ } | {
547
+ type: "resource";
548
+ resource: {
549
+ uri: string;
550
+ text: string;
551
+ mimeType?: string | undefined;
552
+ _meta?: Record<string, unknown> | undefined;
553
+ } | {
554
+ uri: string;
555
+ blob: string;
556
+ mimeType?: string | undefined;
557
+ _meta?: Record<string, unknown> | undefined;
558
+ };
559
+ annotations?: {
560
+ audience?: ("user" | "assistant")[] | undefined;
561
+ priority?: number | undefined;
562
+ lastModified?: string | undefined;
563
+ } | undefined;
564
+ _meta?: Record<string, unknown> | undefined;
565
+ } | {
566
+ uri: string;
567
+ name: string;
568
+ type: "resource_link";
569
+ description?: string | undefined;
570
+ mimeType?: string | undefined;
571
+ annotations?: {
572
+ audience?: ("user" | "assistant")[] | undefined;
573
+ priority?: number | undefined;
574
+ lastModified?: string | undefined;
575
+ } | undefined;
576
+ _meta?: {
577
+ [x: string]: unknown;
578
+ } | undefined;
579
+ icons?: {
580
+ src: string;
581
+ mimeType?: string | undefined;
582
+ sizes?: string[] | undefined;
583
+ theme?: "light" | "dark" | undefined;
584
+ }[] | undefined;
585
+ title?: string | undefined;
586
+ })[];
587
+ _meta?: {
588
+ [x: string]: unknown;
589
+ progressToken?: string | number | undefined;
590
+ "io.modelcontextprotocol/related-task"?: {
591
+ taskId: string;
592
+ } | undefined;
593
+ } | undefined;
594
+ structuredContent?: Record<string, unknown> | undefined;
595
+ isError?: boolean | undefined;
596
+ } | {
597
+ [x: string]: unknown;
598
+ toolResult: unknown;
599
+ _meta?: {
600
+ [x: string]: unknown;
601
+ progressToken?: string | number | undefined;
602
+ "io.modelcontextprotocol/related-task"?: {
603
+ taskId: string;
604
+ } | undefined;
605
+ } | undefined;
606
+ } | {
607
+ task: {
608
+ taskId: string;
609
+ status: "working" | "input_required" | "completed" | "failed" | "cancelled";
610
+ ttl: number | null;
611
+ createdAt: string;
612
+ lastUpdatedAt: string;
613
+ pollInterval?: number | undefined;
614
+ statusMessage?: string | undefined;
615
+ };
616
+ _meta: {
617
+ "io.modelcontextprotocol/model-immediate-response": string;
618
+ };
619
+ }>;
620
+ /**
621
+ * Lists resources available from a server.
622
+ */
623
+ listResources(serverId: string, params?: ListResourcesParams, options?: ClientRequestOptions): Promise<{
624
+ [x: string]: unknown;
625
+ resources: {
626
+ uri: string;
627
+ name: string;
628
+ description?: string | undefined;
629
+ mimeType?: string | undefined;
630
+ annotations?: {
631
+ audience?: ("user" | "assistant")[] | undefined;
632
+ priority?: number | undefined;
633
+ lastModified?: string | undefined;
634
+ } | undefined;
635
+ _meta?: {
636
+ [x: string]: unknown;
637
+ } | undefined;
638
+ icons?: {
639
+ src: string;
640
+ mimeType?: string | undefined;
641
+ sizes?: string[] | undefined;
642
+ theme?: "light" | "dark" | undefined;
643
+ }[] | undefined;
644
+ title?: string | undefined;
645
+ }[];
646
+ _meta?: {
647
+ [x: string]: unknown;
648
+ progressToken?: string | number | undefined;
649
+ "io.modelcontextprotocol/related-task"?: {
650
+ taskId: string;
651
+ } | undefined;
652
+ } | undefined;
653
+ nextCursor?: string | undefined;
654
+ }>;
655
+ /**
656
+ * Reads a resource from a server.
657
+ */
658
+ readResource(serverId: string, params: ReadResourceParams, options?: ClientRequestOptions): Promise<{
659
+ [x: string]: unknown;
660
+ contents: ({
661
+ uri: string;
662
+ text: string;
663
+ mimeType?: string | undefined;
664
+ _meta?: Record<string, unknown> | undefined;
665
+ } | {
666
+ uri: string;
667
+ blob: string;
668
+ mimeType?: string | undefined;
669
+ _meta
670
+ /**
671
+ * Lists resources available from a server.
672
+ */
673
+ ?: Record<string, unknown> | undefined;
674
+ })[];
675
+ _meta?: {
676
+ [x: string]: unknown;
677
+ progressToken?: string | number | undefined;
678
+ "io.modelcontextprotocol/related-task"?: {
679
+ taskId: string;
680
+ } | undefined;
681
+ } | undefined;
682
+ }>;
683
+ /**
684
+ * Subscribes to resource updates.
685
+ */
686
+ subscribeResource(serverId: string, params: SubscribeResourceParams, options?: ClientRequestOptions): Promise<{
687
+ _meta?: {
688
+ [x: string]: unknown;
689
+ progressToken?: string | number | undefined;
690
+ "io.modelcontextprotocol/related-task"?: {
691
+ taskId: string;
692
+ } | undefined;
693
+ } | undefined;
694
+ }>;
695
+ /**
696
+ * Unsubscribes from resource updates.
697
+ */
698
+ unsubscribeResource(serverId: string, params: UnsubscribeResourceParams, options?: ClientRequestOptions): Promise<{
699
+ _meta?: {
700
+ [x: string]: unknown;
701
+ progressToken?: string | number | undefined;
702
+ "io.modelcontextprotocol/related-task"?: {
703
+ taskId: string;
704
+ } | undefined;
705
+ } | undefined;
706
+ }>;
707
+ /**
708
+ * Lists resource templates from a server.
709
+ */
710
+ listResourceTemplates(serverId: string, params?: ListResourceTemplatesParams, options?: ClientRequestOptions): Promise<{
711
+ [x: string]: unknown;
712
+ resourceTemplates: {
713
+ uriTemplate: string;
714
+ name: string;
715
+ description?: string | undefined;
716
+ mimeType?: string | undefined;
717
+ annotations?: {
718
+ audience?: ("user" | "assistant")[] | undefined;
719
+ priority?: number | undefined;
720
+ lastModified?: string | undefined;
721
+ } | undefined;
722
+ _meta?: {
723
+ [x: string]: unknown;
724
+ } | undefined;
725
+ icons?: {
726
+ src: string;
727
+ mimeType?: string | undefined;
728
+ sizes?: string[] | undefined;
729
+ theme?: "light" | "dark" | undefined;
730
+ }[] | undefined;
731
+ title?: string | undefined;
732
+ }[];
733
+ _meta?: {
734
+ [x: string]: unknown;
735
+ progressToken?: string | number | undefined;
736
+ "io.modelcontextprotocol/related-task"?: {
737
+ taskId: string;
738
+ } | undefined;
739
+ } | undefined;
740
+ nextCursor?: string | undefined;
741
+ }>;
742
+ /**
743
+ * Lists prompts available from a server.
744
+ */
745
+ listPrompts(serverId: string, params?: ListPromptsParams, options?: ClientRequestOptions): Promise<{
746
+ [x: string]: unknown;
747
+ prompts: {
748
+ name: string;
749
+ description?: string | undefined;
750
+ arguments?: {
751
+ name: string;
752
+ description?: string | undefined;
753
+ required?: boolean | undefined;
754
+ }[] | undefined;
755
+ _meta?: {
756
+ [x: string]: unknown;
757
+ } | undefined;
758
+ icons? /**
759
+ * Gets tools formatted for Vercel AI SDK.
760
+ *
761
+ * @param serverIds - Server IDs to get tools from (or all if omitted)
762
+ * @param options - Schema options
763
+ * @returns AiSdkTool compatible with Vercel AI SDK's generateText()
764
+ */: {
765
+ src: string;
766
+ mimeType?: string | undefined;
767
+ sizes?: string[] | undefined;
768
+ theme?: "light" | "dark" | undefined;
769
+ }[] | undefined;
770
+ title?: string | undefined;
771
+ }[];
772
+ _meta?: {
773
+ [x: string]: unknown;
774
+ progressToken?: string | number | undefined;
775
+ "io.modelcontextprotocol/related-task"?: {
776
+ taskId: string;
777
+ } | undefined;
778
+ } | undefined;
779
+ nextCursor?: string | undefined;
780
+ }>;
781
+ /**
782
+ * Gets a prompt from a server.
783
+ */
784
+ getPrompt(serverId: string, params: GetPromptParams, options?: ClientRequestOptions): Promise<{
785
+ [x: string]: unknown;
786
+ messages: {
787
+ role: "user" | "assistant";
788
+ content: {
789
+ type: "text";
790
+ text: string;
791
+ annotations?: {
792
+ audience?: ("user" | "assistant")[] | undefined;
793
+ priority?: number | undefined;
794
+ lastModified?: string | undefined;
795
+ } | undefined;
796
+ _meta?: Record<string, unknown> | undefined;
797
+ } | {
798
+ type: "image";
799
+ data: string;
800
+ mimeType: string;
801
+ annotations?: {
802
+ audience?: ("user" | "assistant")[] | undefined;
803
+ priority?: number | undefined;
804
+ lastModified?: string | undefined;
805
+ } | undefined;
806
+ _meta?: Record<string, unknown> | undefined;
807
+ } | {
808
+ type: "audio";
809
+ data: string;
810
+ mimeType: string;
811
+ annotations?: {
812
+ audience?: ("user" | "assistant")[] | undefined;
813
+ priority?: number | undefined;
814
+ lastModified?: string | undefined;
815
+ } | undefined;
816
+ _meta?: Record<string, unknown> | undefined;
817
+ } | {
818
+ type: "resource";
819
+ resource: {
820
+ uri: string;
821
+ text: string;
822
+ mimeType?: string | undefined;
823
+ _meta?: Record<string, unknown> | undefined;
824
+ } | {
825
+ uri: string;
826
+ blob: string;
827
+ mimeType?: string | undefined;
828
+ _meta?: Record<string, unknown> | undefined;
829
+ };
830
+ annotations?: {
831
+ audience?: ("user" | "assistant")[] | undefined;
832
+ priority?: number | undefined;
833
+ lastModified?: string | undefined;
834
+ } | undefined;
835
+ _meta?: Record<string, unknown> | undefined;
836
+ } | {
837
+ uri: string;
838
+ name: string;
839
+ type: "resource_link";
840
+ description?: string | undefined;
841
+ mimeType?: string | undefined;
842
+ annotations?: {
843
+ audience?: ("user" | "assistant")[] | undefined;
844
+ priority?: number | undefined;
845
+ lastModified?: string | undefined;
846
+ } | undefined;
847
+ _meta?: {
848
+ [x: string]: unknown;
849
+ } | undefined;
850
+ icons?: {
851
+ src: string;
852
+ mimeType?: string | undefined;
853
+ sizes?: string[] | undefined;
854
+ theme?: "light" | "dark" | undefined;
855
+ }[] | undefined;
856
+ title?: string | undefined;
857
+ };
858
+ }[];
859
+ _meta?: {
860
+ [x: string]: unknown;
861
+ progressToken?: string | number | undefined;
862
+ "io.modelcontextprotocol/related-task"?: {
863
+ taskId: string;
864
+ } | undefined;
865
+ } | undefined;
866
+ description?: string | undefined;
867
+ }>;
868
+ /**
869
+ * Pings a server to check connectivity.
870
+ */
871
+ pingServer(serverId: string, options?: RequestOptions): void;
872
+ /**
873
+ * Sets the logging level for a server.
874
+ */
875
+ setLoggingLevel(serverId: string, level?: LoggingLevel): Promise<void>;
876
+ /**
877
+ * Gets the session ID for a Streamable HTTP server.
878
+ */
879
+ getSessionIdByServer(serverId: string): string | undefined;
880
+ /**
881
+ * Adds a notification handler for a server.
882
+ */
883
+ addNotificationHandler(serverId: string, schema: NotificationSchema, handler: NotificationHandler): void;
884
+ /**
885
+ * Registers a handler for resource list changes.
886
+ */
887
+ onResourceListChanged(serverId: string, handler: NotificationHandler): void;
888
+ /**
889
+ * Registers a handler for resource updates.
890
+ */
891
+ onResourceUpdated(serverId: string, handler: NotificationHandler): void;
892
+ /**
893
+ * Registers a handler for prompt list changes.
894
+ */
895
+ onPromptListChanged(serverId: string, handler: NotificationHandler): void;
896
+ /**
897
+ * Registers a handler for task status changes.
898
+ */
899
+ onTaskStatusChanged(serverId: string, handler: NotificationHandler): void;
900
+ /**
901
+ * Sets a server-specific elicitation handler.
902
+ */
903
+ setElicitationHandler(serverId: string, handler: ElicitationHandler): void;
904
+ /**
905
+ * Clears a server-specific elicitation handler.
906
+ */
907
+ clearElicitationHandler(serverId: string): void;
908
+ /**
909
+ * Sets a global elicitation callback for all servers.
910
+ */
911
+ setElicitationCallback(callback: ElicitationCallback): void;
912
+ /**
913
+ * Clears the global elicitation callback.
914
+ */
915
+ clearElicitationCallback(): void;
916
+ /**
917
+ * Gets the pending elicitations map for external resolvers.
918
+ */
919
+ getPendingElicitations(): Map<string, {
920
+ resolve: (value: ElicitResult) => void;
921
+ reject: (error: unknown) => void;
922
+ }>;
923
+ /**
924
+ * Responds to a pending elicitation.
925
+ */
926
+ respondToElicitation(requestId: string, response: ElicitResult): boolean;
927
+ /**
928
+ * Lists tasks from a server.
929
+ */
930
+ listTasks(serverId: string, cursor?: string, options?: ClientRequestOptions): Promise<MCPListTasksResult>;
931
+ /**
932
+ * Gets a task by ID.
933
+ */
934
+ getTask(serverId: string, taskId: string, options?: ClientRequestOptions): Promise<MCPTask>;
935
+ /**
936
+ * Gets the result of a completed task.
937
+ */
938
+ getTaskResult(serverId: string, taskId: string, options?: ClientRequestOptions): Promise<unknown>;
939
+ /**
940
+ * Cancels a task.
941
+ */
942
+ cancelTask(serverId: string, taskId: string, options?: ClientRequestOptions): Promise<MCPTask>;
943
+ /**
944
+ * Checks if server supports task-augmented tool calls.
945
+ */
946
+ supportsTasksForToolCalls(serverId: string): boolean;
947
+ /**
948
+ * Checks if server supports listing tasks.
949
+ */
950
+ supportsTasksList(serverId: string): boolean;
951
+ /**
952
+ * Checks if server supports canceling tasks.
953
+ */
954
+ supportsTasksCancel(serverId: string): boolean;
955
+ private performConnection;
956
+ private connectViaStdio;
957
+ private connectViaHttp;
958
+ private safeCloseTransport;
959
+ private ensureConnected;
960
+ private getClientOrThrow;
961
+ private resetState;
962
+ private withTimeout;
963
+ private withProgressHandler;
964
+ private buildCapabilities;
965
+ private resolveRpcLogger;
966
+ private cacheToolsMetadata;
967
+ private isStdioConfig;
968
+ }
969
+
970
+ /**
971
+ * Custom error classes for MCP SDK
972
+ */
973
+ /**
974
+ * Base error class for all MCP SDK errors
975
+ */
976
+ declare class MCPError extends Error {
977
+ readonly code: string;
978
+ constructor(message: string, code: string, options?: {
979
+ cause?: unknown;
980
+ });
981
+ }
982
+ /**
983
+ * Authentication error - thrown for 401, token expired, invalid token, etc.
984
+ */
985
+ declare class MCPAuthError extends MCPError {
986
+ readonly statusCode?: number | undefined;
987
+ constructor(message: string, statusCode?: number | undefined, options?: {
988
+ cause?: unknown;
989
+ });
990
+ }
991
+ /**
992
+ * Type guard to check if an error is an MCPAuthError
993
+ */
994
+ declare function isMCPAuthError(error: unknown): error is MCPAuthError;
995
+ /**
996
+ * Checks if an error is an authentication-related error.
997
+ * Detects auth errors by:
998
+ * 1. Error class name (UnauthorizedError from MCP SDK)
999
+ * 2. HTTP status codes (401, 403) from transport errors
1000
+ * 3. Common auth-related patterns in error messages (case-insensitive)
1001
+ */
1002
+ declare function isAuthError(error: unknown): {
1003
+ isAuth: boolean;
1004
+ statusCode?: number;
1005
+ };
1006
+
1007
+ /**
1008
+ * Core types for SDK evals functionality
1009
+ */
1010
+
1011
+ type CoreMessage = ModelMessage;
1012
+ type CoreUserMessage = UserModelMessage;
1013
+ type CoreAssistantMessage = AssistantModelMessage;
1014
+ type CoreToolMessage = ToolModelMessage;
1015
+ /**
1016
+ * Built-in LLM providers with native SDK support
1017
+ */
1018
+ type LLMProvider = "anthropic" | "openai" | "azure" | "deepseek" | "google" | "ollama" | "mistral" | "openrouter" | "xai";
1019
+ /**
1020
+ * Compatible API protocols for custom providers
1021
+ */
1022
+ type CompatibleProtocol = "openai-compatible" | "anthropic-compatible";
1023
+ /**
1024
+ * Configuration for a custom provider (user-defined)
1025
+ */
1026
+ interface CustomProvider {
1027
+ /** Unique name for this provider (used in model strings, e.g., "groq/llama-3") */
1028
+ name: string;
1029
+ /** API protocol this provider is compatible with */
1030
+ protocol: CompatibleProtocol;
1031
+ /** Base URL for the API endpoint */
1032
+ baseUrl: string;
1033
+ /** List of available model IDs */
1034
+ modelIds: string[];
1035
+ /** Optional API key (can also be provided at runtime) */
1036
+ apiKey?: string;
1037
+ /** Environment variable name to read API key from (fallback) */
1038
+ apiKeyEnvVar?: string;
1039
+ /**
1040
+ * Use Chat Completions API (.chat()) instead of default.
1041
+ * Required for some OpenAI-compatible providers like LiteLLM.
1042
+ * Only applies to openai-compatible protocol.
1043
+ */
1044
+ useChatCompletions?: boolean;
1045
+ }
1046
+ /**
1047
+ * Configuration for an LLM
1048
+ */
1049
+ interface LLMConfig {
1050
+ provider: LLMProvider;
1051
+ model: string;
1052
+ apiKey: string;
1053
+ }
1054
+ /**
1055
+ * Represents a tool call made by the LLM
1056
+ */
1057
+ interface ToolCall {
1058
+ toolName: string;
1059
+ arguments: Record<any, any>;
1060
+ }
1061
+ /**
1062
+ * Token usage statistics
1063
+ */
1064
+ interface TokenUsage {
1065
+ inputTokens: number;
1066
+ outputTokens: number;
1067
+ totalTokens: number;
1068
+ }
1069
+ /**
1070
+ * Latency breakdown for prompt execution
1071
+ */
1072
+ interface LatencyBreakdown {
1073
+ /** Total wall-clock time in milliseconds */
1074
+ e2eMs: number;
1075
+ /** LLM API time in milliseconds */
1076
+ llmMs: number;
1077
+ /** MCP tool execution time in milliseconds */
1078
+ mcpMs: number;
1079
+ }
1080
+ /**
1081
+ * Raw prompt result data (used internally)
1082
+ */
1083
+ interface PromptResultData {
1084
+ /** The original prompt/query that was sent */
1085
+ prompt: string;
1086
+ /** The full conversation history (user, assistant, tool messages) */
1087
+ messages: ModelMessage[];
1088
+ text: string;
1089
+ toolCalls: ToolCall[];
1090
+ usage: TokenUsage;
1091
+ latency: LatencyBreakdown;
1092
+ error?: string;
1093
+ }
1094
+
1095
+ /**
1096
+ * PromptResult class - wraps the result of a TestAgent prompt
1097
+ */
1098
+
1099
+ /**
1100
+ * Represents the result of a TestAgent prompt.
1101
+ * Provides convenient methods to inspect tool calls, token usage, and errors.
1102
+ */
1103
+ declare class PromptResult {
1104
+ /** The original prompt/query that was sent */
1105
+ readonly prompt: string;
1106
+ /** The text response from the LLM */
1107
+ readonly text: string;
1108
+ /** The full conversation history */
1109
+ private readonly _messages;
1110
+ /** Latency breakdown (e2e, llm, mcp) */
1111
+ private readonly _latency;
1112
+ /** Tool calls made during the prompt */
1113
+ private readonly _toolCalls;
1114
+ /** Token usage statistics */
1115
+ private readonly _usage;
1116
+ /** Error message if the prompt failed */
1117
+ private readonly _error?;
1118
+ /**
1119
+ * Create a new PromptResult
1120
+ * @param data - The raw prompt result data
1121
+ */
1122
+ constructor(data: PromptResultData);
1123
+ /**
1124
+ * Get the original query/prompt that was sent.
1125
+ *
1126
+ * @returns The original prompt string
1127
+ */
1128
+ getPrompt(): string;
1129
+ /**
1130
+ * Get the full conversation history (user, assistant, tool messages).
1131
+ * Returns a copy to prevent external modification.
1132
+ *
1133
+ * @returns Array of CoreMessage objects
1134
+ */
1135
+ getMessages(): CoreMessage[];
1136
+ /**
1137
+ * Get only user messages from the conversation.
1138
+ *
1139
+ * @returns Array of CoreUserMessage objects
1140
+ */
1141
+ getUserMessages(): CoreUserMessage[];
1142
+ /**
1143
+ * Get only assistant messages from the conversation.
1144
+ *
1145
+ * @returns Array of CoreAssistantMessage objects
1146
+ */
1147
+ getAssistantMessages(): CoreAssistantMessage[];
1148
+ /**
1149
+ * Get only tool result messages from the conversation.
1150
+ *
1151
+ * @returns Array of CoreToolMessage objects
1152
+ */
1153
+ getToolMessages(): CoreToolMessage[];
1154
+ /**
1155
+ * Get the end-to-end latency in milliseconds.
1156
+ * This is the total wall-clock time for the prompt.
1157
+ *
1158
+ * @returns End-to-end latency in milliseconds
1159
+ */
1160
+ e2eLatencyMs(): number;
1161
+ /**
1162
+ * Get the LLM API latency in milliseconds.
1163
+ * This is the time spent waiting for LLM responses (excluding tool execution).
1164
+ *
1165
+ * @returns LLM latency in milliseconds
1166
+ */
1167
+ llmLatencyMs(): number;
1168
+ /**
1169
+ * Get the MCP tool execution latency in milliseconds.
1170
+ * This is the time spent executing MCP tools.
1171
+ *
1172
+ * @returns MCP tool latency in milliseconds
1173
+ */
1174
+ mcpLatencyMs(): number;
1175
+ /**
1176
+ * Get the full latency breakdown.
1177
+ *
1178
+ * @returns LatencyBreakdown object with e2eMs, llmMs, and mcpMs
1179
+ */
1180
+ getLatency(): LatencyBreakdown;
1181
+ /**
1182
+ * Get the names of all tools that were called during this prompt.
1183
+ * Returns a standard string[] that can be used with .includes().
1184
+ *
1185
+ * @returns Array of tool names
1186
+ */
1187
+ toolsCalled(): string[];
1188
+ /**
1189
+ * Check if a specific tool was called during this prompt.
1190
+ * Case-sensitive exact match.
1191
+ *
1192
+ * @param toolName - The name of the tool to check for
1193
+ * @returns true if the tool was called
1194
+ */
1195
+ hasToolCall(toolName: string): boolean;
1196
+ /**
1197
+ * Get all tool calls with their arguments.
1198
+ *
1199
+ * @returns Array of ToolCall objects
1200
+ */
1201
+ getToolCalls(): ToolCall[];
1202
+ /**
1203
+ * Get the arguments passed to a specific tool call.
1204
+ * Returns undefined if the tool was not called.
1205
+ * If the tool was called multiple times, returns the first call's arguments.
1206
+ *
1207
+ * @param toolName - The name of the tool
1208
+ * @returns The arguments object or undefined
1209
+ */
1210
+ getToolArguments(toolName: string): Record<string, unknown> | undefined;
1211
+ /**
1212
+ * Get the total number of tokens used.
1213
+ *
1214
+ * @returns Total tokens (input + output)
1215
+ */
1216
+ totalTokens(): number;
1217
+ /**
1218
+ * Get the number of input tokens used.
1219
+ *
1220
+ * @returns Input token count
1221
+ */
1222
+ inputTokens(): number;
1223
+ /**
1224
+ * Get the number of output tokens used.
1225
+ *
1226
+ * @returns Output token count
1227
+ */
1228
+ outputTokens(): number;
1229
+ /**
1230
+ * Get the full token usage statistics.
1231
+ *
1232
+ * @returns TokenUsage object
1233
+ */
1234
+ getUsage(): TokenUsage;
1235
+ /**
1236
+ * Check if this prompt resulted in an error.
1237
+ *
1238
+ * @returns true if there was an error
1239
+ */
1240
+ hasError(): boolean;
1241
+ /**
1242
+ * Get the error message if the prompt failed.
1243
+ *
1244
+ * @returns The error message or undefined
1245
+ */
1246
+ getError(): string | undefined;
1247
+ /**
1248
+ * Create a PromptResult from raw data.
1249
+ * Factory method for convenience.
1250
+ *
1251
+ * @param data - The raw prompt result data
1252
+ * @returns A new PromptResult instance
1253
+ */
1254
+ static from(data: PromptResultData): PromptResult;
1255
+ /**
1256
+ * Create an error PromptResult.
1257
+ * Factory method for error cases.
1258
+ *
1259
+ * @param error - The error message
1260
+ * @param latency - The latency breakdown or e2e time in milliseconds
1261
+ * @returns A new PromptResult instance with error state
1262
+ */
1263
+ static error(error: string, latency?: LatencyBreakdown | number, prompt?: string): PromptResult;
1264
+ /**
1265
+ * Format the conversation trace as a JSON string.
1266
+ * Useful for debugging failed evaluations.
1267
+ *
1268
+ * @returns A JSON string of the conversation messages
1269
+ */
1270
+ formatTrace(): string;
1271
+ }
1272
+
1273
+ /**
1274
+ * TestAgent - Runs LLM prompts with tool calling for evals
1275
+ */
1276
+
1277
+ /**
1278
+ * Configuration for creating a TestAgent
1279
+ */
1280
+ interface TestAgentConfig {
1281
+ /** Tools to provide to the LLM (Tool[] from manager.getTools() or AiSdkTool from manager.getToolsForAiSdk()) */
1282
+ tools: Tool[] | AiSdkTool;
1283
+ /** LLM provider and model string (e.g., "openai/gpt-4o", "anthropic/claude-3-5-sonnet-20241022") */
1284
+ model: string;
1285
+ /** API key for the LLM provider */
1286
+ apiKey: string;
1287
+ /** System prompt for the LLM (default: "You are a helpful assistant.") */
1288
+ systemPrompt?: string;
1289
+ /** Temperature for LLM responses (0-2). If undefined, uses model default. Some models (e.g., reasoning models) don't support temperature. */
1290
+ temperature?: number;
1291
+ /** Maximum number of agentic steps/tool calls (default: 10) */
1292
+ maxSteps?: number;
1293
+ /** Custom providers registry for non-standard LLM providers */
1294
+ customProviders?: Map<string, CustomProvider> | Record<string, CustomProvider>;
1295
+ }
1296
+ /**
1297
+ * Options for the prompt() method
1298
+ */
1299
+ interface PromptOptions {
1300
+ /** Previous PromptResult(s) to include as conversation context for multi-turn conversations */
1301
+ context?: PromptResult | PromptResult[];
1302
+ }
1303
+ /**
1304
+ * Agent for running LLM prompts with tool calling.
1305
+ * Wraps the AI SDK generateText function with proper tool integration.
1306
+ *
1307
+ * @example
1308
+ * ```typescript
1309
+ * const manager = new MCPClientManager({
1310
+ * everything: { command: "npx", args: ["-y", "@modelcontextprotocol/server-everything"] },
1311
+ * });
1312
+ * await manager.connectToServer("everything");
1313
+ *
1314
+ * const agent = new TestAgent({
1315
+ * tools: await manager.getToolsForAiSdk(["everything"]),
1316
+ * model: "openai/gpt-4o",
1317
+ * apiKey: process.env.OPENAI_API_KEY!,
1318
+ * });
1319
+ *
1320
+ * const result = await agent.prompt("Add 2 and 3");
1321
+ * console.log(result.toolsCalled()); // ["add"]
1322
+ * console.log(result.text); // "The result of adding 2 and 3 is 5."
1323
+ * ```
1324
+ */
1325
+ declare class TestAgent {
1326
+ private readonly tools;
1327
+ private readonly model;
1328
+ private readonly apiKey;
1329
+ private systemPrompt;
1330
+ private temperature;
1331
+ private readonly maxSteps;
1332
+ private readonly customProviders?;
1333
+ /** The result of the last prompt (for toolsCalled() convenience method) */
1334
+ private lastResult;
1335
+ /** History of all prompt results during a test execution */
1336
+ private promptHistory;
1337
+ /**
1338
+ * Create a new TestAgent
1339
+ * @param config - Agent configuration
1340
+ */
1341
+ constructor(config: TestAgentConfig);
1342
+ /**
1343
+ * Create instrumented tools that track execution latency.
1344
+ * @param onLatency - Callback to report latency for each tool execution
1345
+ * @returns ToolSet with instrumented execute functions
1346
+ */
1347
+ private createInstrumentedTools;
1348
+ /**
1349
+ * Build an array of ModelMessages from previous PromptResult(s) for multi-turn context.
1350
+ * @param context - Single PromptResult or array of PromptResults to include as context
1351
+ * @returns Array of ModelMessages representing the conversation history
1352
+ */
1353
+ private buildContextMessages;
1354
+ /**
1355
+ * Run a prompt with the LLM, allowing tool calls.
1356
+ * Never throws - errors are returned in the PromptResult.
1357
+ *
1358
+ * @param message - The user message to send to the LLM
1359
+ * @param options - Optional settings including context for multi-turn conversations
1360
+ * @returns PromptResult with text response, tool calls, token usage, and latency breakdown
1361
+ *
1362
+ * @example
1363
+ * // Single-turn (default)
1364
+ * const result = await agent.prompt("Show me workspaces");
1365
+ *
1366
+ * @example
1367
+ * // Multi-turn with context
1368
+ * const r1 = await agent.prompt("Show me workspaces");
1369
+ * const r2 = await agent.prompt("Now show tasks", { context: r1 });
1370
+ *
1371
+ * @example
1372
+ * // Multi-turn with multiple context results
1373
+ * const r1 = await agent.prompt("Show workspaces");
1374
+ * const r2 = await agent.prompt("Pick the first", { context: r1 });
1375
+ * const r3 = await agent.prompt("Show tasks", { context: [r1, r2] });
1376
+ */
1377
+ prompt(message: string, options?: PromptOptions): Promise<PromptResult>;
1378
+ /**
1379
+ * Get the names of tools called in the last prompt.
1380
+ * Convenience method for quick checks in eval functions.
1381
+ *
1382
+ * @returns Array of tool names from the last prompt, or empty array if no prompt has been run
1383
+ */
1384
+ toolsCalled(): string[];
1385
+ /**
1386
+ * Create a new TestAgent with modified options.
1387
+ * Useful for creating variants for different test scenarios.
1388
+ *
1389
+ * @param options - Partial config to override
1390
+ * @returns A new TestAgent instance with the merged configuration
1391
+ */
1392
+ withOptions(options: Partial<TestAgentConfig>): TestAgent;
1393
+ /**
1394
+ * Get the configured tools
1395
+ */
1396
+ getTools(): ToolSet;
1397
+ /**
1398
+ * Get the LLM provider/model string
1399
+ */
1400
+ getModel(): string;
1401
+ /**
1402
+ * Get the API key
1403
+ */
1404
+ getApiKey(): string;
1405
+ /**
1406
+ * Get the current system prompt
1407
+ */
1408
+ getSystemPrompt(): string;
1409
+ /**
1410
+ * Set a new system prompt
1411
+ */
1412
+ setSystemPrompt(prompt: string): void;
1413
+ /**
1414
+ * Get the current temperature (undefined means model default)
1415
+ */
1416
+ getTemperature(): number | undefined;
1417
+ /**
1418
+ * Set the temperature (must be between 0 and 2)
1419
+ */
1420
+ setTemperature(temperature: number): void;
1421
+ /**
1422
+ * Get the max steps configuration
1423
+ */
1424
+ getMaxSteps(): number;
1425
+ /**
1426
+ * Get the result of the last prompt
1427
+ */
1428
+ getLastResult(): PromptResult | undefined;
1429
+ /**
1430
+ * Reset the prompt history.
1431
+ * Call this before each test iteration to clear previous results.
1432
+ */
1433
+ resetPromptHistory(): void;
1434
+ /**
1435
+ * Get the history of all prompt results since the last reset.
1436
+ * Returns a copy of the array to prevent external modification.
1437
+ */
1438
+ getPromptHistory(): PromptResult[];
1439
+ }
1440
+
1441
+ /**
1442
+ * Validators for matching tool calls in eval tests
1443
+ *
1444
+ * All matching is case-sensitive and uses exact strings only (no wildcards).
1445
+ */
1446
+
1447
+ /**
1448
+ * Exact match - all expected tools must be present in exact order.
1449
+ * Case-sensitive exact string comparison.
1450
+ *
1451
+ * @param expected - The expected tool names in order
1452
+ * @param actual - The actual tool names that were called
1453
+ * @returns true if actual matches expected exactly
1454
+ *
1455
+ * @example
1456
+ * matchToolCalls(['add', 'multiply'], ['add', 'multiply']) // true
1457
+ * matchToolCalls(['add', 'multiply'], ['multiply', 'add']) // false (wrong order)
1458
+ * matchToolCalls(['add'], ['add', 'multiply']) // false (extra tool)
1459
+ */
1460
+ declare function matchToolCalls(expected: string[], actual: string[]): boolean;
1461
+ /**
1462
+ * Subset match - all expected tools must be present, order doesn't matter.
1463
+ * Case-sensitive exact string comparison.
1464
+ *
1465
+ * @param expected - The expected tool names (any order)
1466
+ * @param actual - The actual tool names that were called
1467
+ * @returns true if all expected tools are present in actual
1468
+ *
1469
+ * @example
1470
+ * matchToolCallsSubset(['add', 'multiply'], ['multiply', 'add']) // true
1471
+ * matchToolCallsSubset(['add'], ['add', 'multiply']) // true
1472
+ * matchToolCallsSubset(['add', 'subtract'], ['add', 'multiply']) // false (missing subtract)
1473
+ */
1474
+ declare function matchToolCallsSubset(expected: string[], actual: string[]): boolean;
1475
+ /**
1476
+ * Any match - at least one expected tool must be present.
1477
+ * Case-sensitive exact string comparison.
1478
+ *
1479
+ * @param expected - The expected tool names (at least one must match)
1480
+ * @param actual - The actual tool names that were called
1481
+ * @returns true if at least one expected tool is present in actual
1482
+ *
1483
+ * @example
1484
+ * matchAnyToolCall(['add', 'subtract'], ['multiply', 'add']) // true
1485
+ * matchAnyToolCall(['add', 'subtract'], ['multiply', 'divide']) // false
1486
+ * matchAnyToolCall([], ['add']) // false (empty expected)
1487
+ */
1488
+ declare function matchAnyToolCall(expected: string[], actual: string[]): boolean;
1489
+ /**
1490
+ * Count match - check if a specific tool was called exactly N times.
1491
+ * Case-sensitive exact string comparison.
1492
+ *
1493
+ * @param toolName - The tool name to count
1494
+ * @param actual - The actual tool names that were called
1495
+ * @param count - The expected number of times the tool should be called
1496
+ * @returns true if the tool was called exactly count times
1497
+ *
1498
+ * @example
1499
+ * matchToolCallCount('add', ['add', 'add', 'multiply'], 2) // true
1500
+ * matchToolCallCount('add', ['add', 'multiply'], 2) // false
1501
+ */
1502
+ declare function matchToolCallCount(toolName: string, actual: string[], count: number): boolean;
1503
+ /**
1504
+ * No tools match - check that no tools were called.
1505
+ *
1506
+ * @param actual - The actual tool names that were called
1507
+ * @returns true if no tools were called
1508
+ *
1509
+ * @example
1510
+ * matchNoToolCalls([]) // true
1511
+ * matchNoToolCalls(['add']) // false
1512
+ */
1513
+ declare function matchNoToolCalls(actual: string[]): boolean;
1514
+ /**
1515
+ * Check if tool was called with exact arguments (deep equality).
1516
+ * Returns true if any call to the tool has exactly matching arguments.
1517
+ * Case-sensitive for tool names.
1518
+ *
1519
+ * @param toolName - The tool name to match
1520
+ * @param expectedArgs - The expected arguments (exact match)
1521
+ * @param toolCalls - The actual tool calls made
1522
+ * @returns true if any call to the tool has exactly matching arguments
1523
+ *
1524
+ * @example
1525
+ * matchToolCallWithArgs('add', {a: 2, b: 3}, toolCalls) // true if add({a:2, b:3}) was called
1526
+ * matchToolCallWithArgs('add', {a: 2}, [{toolName:'add', arguments:{a:2, b:3}}]) // false (extra arg)
1527
+ */
1528
+ declare function matchToolCallWithArgs(toolName: string, expectedArgs: Record<string, unknown>, toolCalls: ToolCall[]): boolean;
1529
+ /**
1530
+ * Check if tool was called with at least these arguments (partial match).
1531
+ * Allows extra arguments in the actual call.
1532
+ * Case-sensitive for tool names.
1533
+ *
1534
+ * @param toolName - The tool name to match
1535
+ * @param expectedArgs - The expected arguments (partial match)
1536
+ * @param toolCalls - The actual tool calls made
1537
+ * @returns true if any call to the tool contains all expected arguments
1538
+ *
1539
+ * @example
1540
+ * matchToolCallWithPartialArgs('add', {a: 2}, [{toolName:'add', arguments:{a:2, b:3}}]) // true
1541
+ * matchToolCallWithPartialArgs('add', {a: 2, c: 5}, [{toolName:'add', arguments:{a:2, b:3}}]) // false
1542
+ */
1543
+ declare function matchToolCallWithPartialArgs(toolName: string, expectedArgs: Record<string, unknown>, toolCalls: ToolCall[]): boolean;
1544
+ /**
1545
+ * Check if a specific argument has a specific value in any call to the tool.
1546
+ * Case-sensitive for tool names.
1547
+ *
1548
+ * @param toolName - The tool name to match
1549
+ * @param argKey - The argument key to check
1550
+ * @param expectedValue - The expected value for the argument
1551
+ * @param toolCalls - The actual tool calls made
1552
+ * @returns true if any call to the tool has the specified argument value
1553
+ *
1554
+ * @example
1555
+ * matchToolArgument('add', 'a', 2, toolCalls) // true if any add() call had a=2
1556
+ */
1557
+ declare function matchToolArgument(toolName: string, argKey: string, expectedValue: unknown, toolCalls: ToolCall[]): boolean;
1558
+ /**
1559
+ * Check if argument value matches a predicate function.
1560
+ * Useful for partial matches, type checks, or range validation.
1561
+ * Case-sensitive for tool names.
1562
+ *
1563
+ * @param toolName - The tool name to match
1564
+ * @param argKey - The argument key to check
1565
+ * @param predicate - Function that tests the argument value
1566
+ * @param toolCalls - The actual tool calls made
1567
+ * @returns true if any call to the tool has an argument value that passes the predicate
1568
+ *
1569
+ * @example
1570
+ * matchToolArgumentWith('echo', 'message', (v) => typeof v === 'string' && v.includes('hello'), toolCalls)
1571
+ * matchToolArgumentWith('add', 'a', (v) => typeof v === 'number' && v > 0, toolCalls)
1572
+ */
1573
+ declare function matchToolArgumentWith(toolName: string, argKey: string, predicate: (value: unknown) => boolean, toolCalls: ToolCall[]): boolean;
1574
+
1575
+ /**
1576
+ * Statistics for latency values
1577
+ */
1578
+ interface LatencyStats {
1579
+ /** Minimum value */
1580
+ min: number;
1581
+ /** Maximum value */
1582
+ max: number;
1583
+ /** Mean (average) value */
1584
+ mean: number;
1585
+ /** 50th percentile (median) */
1586
+ p50: number;
1587
+ /** 95th percentile */
1588
+ p95: number;
1589
+ /** Number of values */
1590
+ count: number;
1591
+ }
1592
+
1593
+ /**
1594
+ * Configuration for an EvalTest
1595
+ *
1596
+ * All tests use the multi-turn pattern with a test function that receives a TestAgent.
1597
+ */
1598
+ interface EvalTestConfig {
1599
+ name: string;
1600
+ test: (agent: TestAgent) => boolean | Promise<boolean>;
1601
+ }
1602
+ /**
1603
+ * Options for running an EvalTest
1604
+ */
1605
+ interface EvalTestRunOptions {
1606
+ iterations: number;
1607
+ concurrency?: number;
1608
+ retries?: number;
1609
+ timeoutMs?: number;
1610
+ onProgress?: (completed: number, total: number) => void;
1611
+ /** Called with a failure report if any iterations fail */
1612
+ onFailure?: (report: string) => void;
1613
+ }
1614
+ /**
1615
+ * Result details for a single iteration
1616
+ */
1617
+ interface IterationResult {
1618
+ passed: boolean;
1619
+ latencies: LatencyBreakdown[];
1620
+ tokens: {
1621
+ total: number;
1622
+ input: number;
1623
+ output: number;
1624
+ };
1625
+ error?: string;
1626
+ retryCount?: number;
1627
+ /** The prompt results from this iteration */
1628
+ prompts?: PromptResult[];
1629
+ }
1630
+ /**
1631
+ * Result of running an EvalTest
1632
+ */
1633
+ interface EvalRunResult {
1634
+ iterations: number;
1635
+ successes: number;
1636
+ failures: number;
1637
+ results: boolean[];
1638
+ iterationDetails: IterationResult[];
1639
+ tokenUsage: {
1640
+ total: number;
1641
+ input: number;
1642
+ output: number;
1643
+ perIteration: {
1644
+ total: number;
1645
+ input: number;
1646
+ output: number;
1647
+ }[];
1648
+ };
1649
+ latency: {
1650
+ e2e: LatencyStats;
1651
+ llm: LatencyStats;
1652
+ mcp: LatencyStats;
1653
+ perIteration: LatencyBreakdown[];
1654
+ };
1655
+ }
1656
+ /**
1657
+ * EvalTest - Runs a single test scenario with iterations
1658
+ *
1659
+ * Can be run standalone or as part of an EvalSuite.
1660
+ *
1661
+ * @example
1662
+ * ```ts
1663
+ * const test = new EvalTest({
1664
+ * name: "addition",
1665
+ * test: async (agent) => {
1666
+ * const result = await agent.prompt("Add 2+3");
1667
+ * return result.hasToolCall("add");
1668
+ * },
1669
+ * });
1670
+ * await test.run(agent, { iterations: 30 });
1671
+ * console.log(test.accuracy()); // 0.97
1672
+ * ```
1673
+ */
1674
+ declare class EvalTest {
1675
+ private config;
1676
+ private lastRunResult;
1677
+ constructor(config: EvalTestConfig);
1678
+ /**
1679
+ * Run this test with the given agent and options
1680
+ */
1681
+ run(agent: TestAgent, options: EvalTestRunOptions): Promise<EvalRunResult>;
1682
+ private aggregateResults;
1683
+ /**
1684
+ * Get the accuracy of the last run (success rate)
1685
+ */
1686
+ accuracy(): number;
1687
+ /**
1688
+ * Get the recall (true positive rate) of the last run
1689
+ */
1690
+ recall(): number;
1691
+ /**
1692
+ * Get the precision of the last run
1693
+ */
1694
+ precision(): number;
1695
+ /**
1696
+ * Get the true positive rate (same as recall)
1697
+ */
1698
+ truePositiveRate(): number;
1699
+ /**
1700
+ * Get the false positive rate
1701
+ */
1702
+ falsePositiveRate(): number;
1703
+ /**
1704
+ * Get the average token use per iteration
1705
+ */
1706
+ averageTokenUse(): number;
1707
+ /**
1708
+ * Get the full results of the last run
1709
+ */
1710
+ getResults(): EvalRunResult | null;
1711
+ /**
1712
+ * Get the name of this test
1713
+ */
1714
+ getName(): string;
1715
+ /**
1716
+ * Get the configuration of this test
1717
+ */
1718
+ getConfig(): EvalTestConfig;
1719
+ /**
1720
+ * Get all iteration details from the last run
1721
+ */
1722
+ getAllIterations(): IterationResult[];
1723
+ /**
1724
+ * Get only the failed iterations from the last run
1725
+ */
1726
+ getFailedIterations(): IterationResult[];
1727
+ /**
1728
+ * Get only the successful iterations from the last run
1729
+ */
1730
+ getSuccessfulIterations(): IterationResult[];
1731
+ /**
1732
+ * Get a failure report with traces from all failed iterations.
1733
+ * Useful for debugging why evaluations failed.
1734
+ *
1735
+ * @returns A formatted string with failure details
1736
+ */
1737
+ getFailureReport(): string;
1738
+ }
1739
+
1740
+ /**
1741
+ * Configuration for an EvalSuite
1742
+ */
1743
+ interface EvalSuiteConfig {
1744
+ name?: string;
1745
+ }
1746
+ /**
1747
+ * Result for a single test within the suite
1748
+ */
1749
+ interface TestResult {
1750
+ name: string;
1751
+ result: EvalRunResult;
1752
+ }
1753
+ /**
1754
+ * Result of running an EvalSuite
1755
+ */
1756
+ interface EvalSuiteResult {
1757
+ tests: Map<string, EvalRunResult>;
1758
+ aggregate: {
1759
+ iterations: number;
1760
+ successes: number;
1761
+ failures: number;
1762
+ accuracy: number;
1763
+ tokenUsage: {
1764
+ total: number;
1765
+ perTest: number[];
1766
+ };
1767
+ latency: {
1768
+ e2e: LatencyStats;
1769
+ llm: LatencyStats;
1770
+ mcp: LatencyStats;
1771
+ };
1772
+ };
1773
+ }
1774
+ /**
1775
+ * EvalSuite - Groups multiple EvalTests and provides aggregate metrics
1776
+ *
1777
+ * @example
1778
+ * ```ts
1779
+ * const suite = new EvalSuite({ name: "Math" });
1780
+ * suite.add(new EvalTest({
1781
+ * name: "addition",
1782
+ * test: async (agent) => {
1783
+ * const r = await agent.prompt("Add 2+3");
1784
+ * return r.hasToolCall("add");
1785
+ * },
1786
+ * }));
1787
+ * suite.add(new EvalTest({
1788
+ * name: "multiply",
1789
+ * test: async (agent) => {
1790
+ * const r = await agent.prompt("Multiply 4*5");
1791
+ * return r.hasToolCall("multiply");
1792
+ * },
1793
+ * }));
1794
+ *
1795
+ * await suite.run(agent, { iterations: 30 });
1796
+ * console.log(suite.accuracy()); // Aggregate: 0.95
1797
+ * console.log(suite.get("addition").accuracy()); // Individual: 0.97
1798
+ * ```
1799
+ */
1800
+ declare class EvalSuite {
1801
+ private name;
1802
+ private tests;
1803
+ private lastRunResult;
1804
+ constructor(config?: EvalSuiteConfig);
1805
+ /**
1806
+ * Add a test to the suite
1807
+ */
1808
+ add(test: EvalTest): void;
1809
+ /**
1810
+ * Get a test by name
1811
+ */
1812
+ get(name: string): EvalTest | undefined;
1813
+ /**
1814
+ * Get all tests in the suite
1815
+ */
1816
+ getAll(): EvalTest[];
1817
+ /**
1818
+ * Run all tests in the suite with the given agent and options
1819
+ */
1820
+ run(agent: TestAgent, options: EvalTestRunOptions): Promise<EvalSuiteResult>;
1821
+ private aggregateResults;
1822
+ /**
1823
+ * Get the aggregate accuracy across all tests
1824
+ */
1825
+ accuracy(): number;
1826
+ /**
1827
+ * Get the aggregate recall (same as accuracy in basic context)
1828
+ */
1829
+ recall(): number;
1830
+ /**
1831
+ * Get the aggregate precision (same as accuracy in basic context)
1832
+ */
1833
+ precision(): number;
1834
+ /**
1835
+ * Get the aggregate true positive rate (same as recall)
1836
+ */
1837
+ truePositiveRate(): number;
1838
+ /**
1839
+ * Get the aggregate false positive rate
1840
+ */
1841
+ falsePositiveRate(): number;
1842
+ /**
1843
+ * Get the average token use per iteration across all tests
1844
+ */
1845
+ averageTokenUse(): number;
1846
+ /**
1847
+ * Get the full suite results
1848
+ */
1849
+ getResults(): EvalSuiteResult | null;
1850
+ /**
1851
+ * Get the name of the suite
1852
+ */
1853
+ getName(): string;
1854
+ /**
1855
+ * Get the number of tests in the suite
1856
+ */
1857
+ size(): number;
1858
+ }
1859
+
1860
+ /**
1861
+ * Model factory for creating AI SDK language models from provider/model strings.
1862
+ * Supports both built-in providers and user-defined custom providers.
1863
+ */
1864
+
1865
+ /**
1866
+ * Custom base URLs for built-in providers that support them.
1867
+ */
1868
+ interface BaseUrls {
1869
+ ollama?: string;
1870
+ azure?: string;
1871
+ anthropic?: string;
1872
+ openai?: string;
1873
+ }
1874
+ /**
1875
+ * Options for creating a model.
1876
+ */
1877
+ interface CreateModelOptions {
1878
+ apiKey: string;
1879
+ baseUrls?: BaseUrls;
1880
+ /** Custom providers registry (name -> config) */
1881
+ customProviders?: Map<string, CustomProvider> | Record<string, CustomProvider>;
1882
+ }
1883
+ /**
1884
+ * Result of parsing an LLM string
1885
+ */
1886
+ type ParsedLLMString = {
1887
+ type: "builtin";
1888
+ provider: LLMProvider;
1889
+ model: string;
1890
+ } | {
1891
+ type: "custom";
1892
+ providerName: string;
1893
+ model: string;
1894
+ };
1895
+ /**
1896
+ * Parse an LLM string into provider and model components.
1897
+ * Supports both built-in providers and custom provider names.
1898
+ *
1899
+ * @param llmString - String in format "provider/model" (e.g., "openai/gpt-4o" or "my-litellm/gpt-4")
1900
+ * @param customProviderNames - Optional set of registered custom provider names for validation
1901
+ * @returns Parsed result with type discriminator
1902
+ */
1903
+ declare function parseLLMString(llmString: string, customProviderNames?: Set<string>): ParsedLLMString;
1904
+ /**
1905
+ * Model type returned by provider factories.
1906
+ */
1907
+ type ProviderLanguageModel = ReturnType<ReturnType<typeof createOpenAI>>;
1908
+ /**
1909
+ * Create a language model from an LLM string.
1910
+ * @param llmString - String in format "provider/model" (e.g., "openai/gpt-4o" or "my-provider/model")
1911
+ * @param options - API key, optional base URLs, and custom providers registry
1912
+ * @returns AI SDK language model instance
1913
+ */
1914
+ declare function createModelFromString(llmString: string, options: CreateModelOptions): ProviderLanguageModel;
1915
+ /**
1916
+ * Parse a comma-separated string of model IDs into an array.
1917
+ * Handles whitespace and empty entries.
1918
+ */
1919
+ declare function parseModelIds(modelIdsString: string): string[];
1920
+ /**
1921
+ * Create a CustomProvider configuration from user input.
1922
+ * This is a helper for building the configuration from form inputs.
1923
+ */
1924
+ declare function createCustomProvider(config: {
1925
+ name: string;
1926
+ protocol: "openai-compatible" | "anthropic-compatible";
1927
+ baseUrl: string;
1928
+ modelIds: string | string[];
1929
+ apiKey?: string;
1930
+ apiKeyEnvVar?: string;
1931
+ useChatCompletions?: boolean;
1932
+ }): CustomProvider;
1933
+ /**
1934
+ * Preset configurations for common OpenAI-compatible providers.
1935
+ * Users can use these as starting points and customize as needed.
1936
+ */
1937
+ declare const PROVIDER_PRESETS: {
1938
+ /** LiteLLM proxy - requires useChatCompletions */
1939
+ readonly litellm: (baseUrl: string | undefined, modelIds: string[]) => CustomProvider;
1940
+ };
1941
+
1942
+ export { type AiSdkTool, type BaseServerConfig, type BaseUrls, type ClientCapabilityOptions, type CompatibleProtocol, type CoreAssistantMessage, type CoreMessage, type CoreToolMessage, type CoreUserMessage, type CreateModelOptions, type CustomProvider, type ElicitationCallback, type ElicitationCallbackRequest, type ElicitationHandler, type EvalRunResult, EvalSuite, type EvalSuiteConfig, type EvalSuiteResult, EvalTest, type EvalTestConfig, type EvalTestRunOptions, type ExecuteToolArguments, type HttpServerConfig, type IterationResult, type LLMConfig, type LLMProvider, type LatencyBreakdown, type ListToolsResult, MCPAuthError, MCPClientManager, type MCPClientManagerConfig, type MCPClientManagerOptions, type MCPConnectionStatus, MCPError, type MCPGetPromptResult, type MCPListTasksResult, type MCPPrompt, type MCPPromptListResult, type MCPReadResourceResult, type MCPResource, type MCPResourceListResult, type MCPResourceTemplate, type MCPResourceTemplateListResult, type MCPServerConfig, type MCPServerSummary, type MCPTask, type MCPTaskStatus, PROVIDER_PRESETS, type ParsedLLMString, type ProgressEvent, type ProgressHandler, type PromptOptions, PromptResult, type PromptResultData, type ProviderLanguageModel, type RpcLogEvent, type RpcLogger, type ServerSummary, type StdioServerConfig, type TaskOptions, TestAgent, type TestAgentConfig, type TestResult, type TokenUsage, type Tool, type ToolCall, type ToolExecuteOptions, createCustomProvider, createModelFromString, isAuthError, isChatGPTAppTool, isMCPAuthError, isMcpAppTool, matchAnyToolCall, matchNoToolCalls, matchToolArgument, matchToolArgumentWith, matchToolCallCount, matchToolCallWithArgs, matchToolCallWithPartialArgs, matchToolCalls, matchToolCallsSubset, parseLLMString, parseModelIds, scrubMetaAndStructuredContentFromToolResult, scrubMetaFromToolResult };