1+ import { config } from "dotenv" ;
12import type { ModelName } from "./providers" ;
23import type { ProviderConfig } from "./providers/types" ;
3- import type { AgentResponse , AgentsExecutionResult , ToolCallStats } from "./chunks/types" ;
4+ import type {
5+ AgentResponse ,
6+ AgentsExecutionResult ,
7+ ToolCallStats ,
8+ } from "./chunks/types" ;
49import { createProvider } from "./providers" ;
510
11+ config ( ) ;
12+
613export type { ModelName , Models } from "./providers" ;
714
815export {
@@ -19,26 +26,30 @@ export {
1926
2027/**
2128 * Creates a new AgentsClient instance for executing prompts against MCP servers.
22- *
29+ *
2330 * @template T - The type of model names to use
2431 * @param mcpServer - The MCP server configuration
2532 * @param models - Array of model names to execute
2633 * @param config - Optional provider configuration (API keys, silent mode, etc.)
2734 * @returns A configured AgentsClient instance
28- *
35+ *
2936 * @example
3037 * ```typescript
3138 * const client = client(mcpServer, ["claude-3-haiku-20240307", "gpt-4"], {
3239 * silent: true,
3340 * anthropicApiKey: process.env.ANTHROPIC_API_KEY
3441 * });
35- *
42+ *
3643 * const result = await client
3744 * .prompt("What tools are available?")
3845 * .execute();
3946 * ```
4047 */
41- export function client < T extends ModelName > ( mcpServer : McpServer , models : T [ ] , config : ProviderConfig = { } ) : AgentsClient < T > {
48+ export function client < T extends ModelName > (
49+ mcpServer : McpServer ,
50+ models : T [ ] ,
51+ config : ProviderConfig = { }
52+ ) : AgentsClient < T > {
4253 return new AgentsClient ( mcpServer , models , config ) ;
4354}
4455
@@ -48,7 +59,17 @@ export class McpServer {
4859 public name : string ;
4960 public type : string ;
5061
51- constructor ( { url, authorizationToken, name, type } : { url : string ; authorizationToken : string ; name : string ; type : string } ) {
62+ constructor ( {
63+ url,
64+ authorizationToken,
65+ name,
66+ type,
67+ } : {
68+ url : string ;
69+ authorizationToken : string ;
70+ name : string ;
71+ type : string ;
72+ } ) {
5273 this . url = url ;
5374 this . authorizationToken = authorizationToken ;
5475 this . name = name ;
@@ -89,7 +110,9 @@ export class AgentsResult<T extends ModelName = ModelName> {
89110 const successfulExecutions = Object . keys ( this . responses ) . length ;
90111 const failedExecutions = this . models . length - successfulExecutions ;
91112
92- const allTools = ( Object . values ( this . responses ) as AgentResponse [ ] ) . flatMap ( ( r ) => r . usedTools ) ;
113+ const allTools = ( Object . values ( this . responses ) as AgentResponse [ ] ) . flatMap (
114+ ( r ) => r . usedTools
115+ ) ;
93116 const toolCounts = allTools . reduce (
94117 ( acc , tool ) => {
95118 acc [ tool ] = ( acc [ tool ] || 0 ) + 1 ;
@@ -129,13 +152,18 @@ export class AgentsResult<T extends ModelName = ModelName> {
129152 }
130153
131154 stats [ toolName ] . callCount += ( calls as any [ ] ) . length ;
132- stats [ toolName ] . lastCalled = Math . max ( stats [ toolName ] . lastCalled || 0 , response . metadata ?. timestamp || 0 ) ;
155+ stats [ toolName ] . lastCalled = Math . max (
156+ stats [ toolName ] . lastCalled || 0 ,
157+ response . metadata ?. timestamp || 0
158+ ) ;
133159 } ) ;
134160 } ) ;
135161
136162 return Object . values ( stats ) . map ( ( stat ) => ( {
137163 ...stat ,
138- averageDuration : stat . totalDuration ? stat . totalDuration / stat . callCount : undefined ,
164+ averageDuration : stat . totalDuration
165+ ? stat . totalDuration / stat . callCount
166+ : undefined ,
139167 } ) ) ;
140168 }
141169
@@ -202,7 +230,12 @@ export class AgentsClient<T extends ModelName = ModelName> {
202230 const executionStartTime = Date . now ( ) ;
203231
204232 this . executionPromises = this . models . map ( async ( model ) => {
205- const provider = createProvider ( model , this . mcpServer ! , this . promptText , this . config ) ;
233+ const provider = createProvider (
234+ model ,
235+ this . mcpServer ! ,
236+ this . promptText ,
237+ this . config
238+ ) ;
206239 const result = await provider . stream ( model ) ;
207240
208241 this . usedTools [ model ] = result . usedTools ;
@@ -231,6 +264,12 @@ export class AgentsClient<T extends ModelName = ModelName> {
231264 { } as Record < T , AgentResponse >
232265 ) ;
233266
234- return new AgentsResult ( responsesMap , executionStartTime , executionEndTime , this . models , this ) ;
267+ return new AgentsResult (
268+ responsesMap ,
269+ executionStartTime ,
270+ executionEndTime ,
271+ this . models ,
272+ this
273+ ) ;
235274 }
236275}
0 commit comments