@@ -56,7 +56,7 @@ class ToolboxClient {
56
56
constructor (
57
57
url : string ,
58
58
session ?: AxiosInstance | null ,
59
- clientHeaders ?: ClientHeadersConfig | null
59
+ clientHeaders ?: ClientHeadersConfig | null ,
60
60
) {
61
61
this . #baseUrl = url ;
62
62
this . #session = session || axios . create ( { baseURL : this . #baseUrl} ) ;
@@ -72,7 +72,7 @@ class ToolboxClient {
72
72
Object . entries ( this . #clientHeaders) . map ( async ( [ key , value ] ) => {
73
73
const resolved = await resolveValue ( value ) ;
74
74
return [ key , String ( resolved ) ] ;
75
- } )
75
+ } ) ,
76
76
) ;
77
77
return Object . fromEntries ( resolvedEntries ) ;
78
78
}
@@ -129,7 +129,7 @@ class ToolboxClient {
129
129
toolName : string ,
130
130
toolSchema : ToolSchemaFromManifest ,
131
131
authTokenGetters : AuthTokenGetters = { } ,
132
- boundParams : BoundParams = { }
132
+ boundParams : BoundParams = { } ,
133
133
) : {
134
134
tool : ReturnType < typeof ToolboxTool > ;
135
135
usedAuthKeys : Set < string > ;
@@ -153,7 +153,7 @@ class ToolboxClient {
153
153
identifyAuthRequirements (
154
154
authParams ,
155
155
toolSchema . authRequired || [ ] ,
156
- authTokenGetters ? Object . keys ( authTokenGetters ) : [ ]
156
+ authTokenGetters ? Object . keys ( authTokenGetters ) : [ ] ,
157
157
) ;
158
158
159
159
const paramZodSchema = createZodSchemaFromParams ( params ) ;
@@ -168,7 +168,7 @@ class ToolboxClient {
168
168
remainingAuthnParams ,
169
169
remainingAuthzTokens ,
170
170
currBoundParams ,
171
- this . #clientHeaders
171
+ this . #clientHeaders,
172
172
) ;
173
173
174
174
const usedBoundKeys = new Set ( Object . keys ( currBoundParams ) ) ;
@@ -193,7 +193,7 @@ class ToolboxClient {
193
193
async loadTool (
194
194
name : string ,
195
195
authTokenGetters : AuthTokenGetters | null = { } ,
196
- boundParams : BoundParams | null = { }
196
+ boundParams : BoundParams | null = { } ,
197
197
) : Promise < ReturnType < typeof ToolboxTool > > {
198
198
const apiPath = `/api/tool/${ name } ` ;
199
199
const manifest = await this . #fetchAndParseManifest( apiPath ) ;
@@ -207,20 +207,20 @@ class ToolboxClient {
207
207
name ,
208
208
specificToolSchema ,
209
209
authTokenGetters || undefined ,
210
- boundParams || { }
210
+ boundParams || { } ,
211
211
) ;
212
212
213
213
const providedAuthKeys = new Set (
214
- authTokenGetters ? Object . keys ( authTokenGetters ) : [ ]
214
+ authTokenGetters ? Object . keys ( authTokenGetters ) : [ ] ,
215
215
) ;
216
216
const providedBoundKeys = new Set (
217
- boundParams ? Object . keys ( boundParams ) : [ ]
217
+ boundParams ? Object . keys ( boundParams ) : [ ] ,
218
218
) ;
219
219
const unusedAuth = [ ...providedAuthKeys ] . filter (
220
- key => ! usedAuthKeys . has ( key )
220
+ key => ! usedAuthKeys . has ( key ) ,
221
221
) ;
222
222
const unusedBound = [ ...providedBoundKeys ] . filter (
223
- key => ! usedBoundKeys . has ( key )
223
+ key => ! usedBoundKeys . has ( key ) ,
224
224
) ;
225
225
226
226
const errorMessages : string [ ] = [ ] ;
@@ -229,13 +229,13 @@ class ToolboxClient {
229
229
}
230
230
if ( unusedBound . length > 0 ) {
231
231
errorMessages . push (
232
- `unused bound parameters: ${ unusedBound . join ( ', ' ) } `
232
+ `unused bound parameters: ${ unusedBound . join ( ', ' ) } ` ,
233
233
) ;
234
234
}
235
235
236
236
if ( errorMessages . length > 0 ) {
237
237
throw new Error (
238
- `Validation failed for tool '${ name } ': ${ errorMessages . join ( '; ' ) } .`
238
+ `Validation failed for tool '${ name } ': ${ errorMessages . join ( '; ' ) } .` ,
239
239
) ;
240
240
}
241
241
return tool ;
@@ -259,7 +259,7 @@ class ToolboxClient {
259
259
name ?: string ,
260
260
authTokenGetters : AuthTokenGetters | null = { } ,
261
261
boundParams : BoundParams | null = { } ,
262
- strict = false
262
+ strict = false ,
263
263
) : Promise < Array < ReturnType < typeof ToolboxTool > > > {
264
264
const toolsetName = name || '' ;
265
265
const apiPath = `/api/toolset/${ toolsetName } ` ;
@@ -270,40 +270,40 @@ class ToolboxClient {
270
270
const overallUsedAuthKeys : Set < string > = new Set ( ) ;
271
271
const overallUsedBoundParams : Set < string > = new Set ( ) ;
272
272
const providedAuthKeys = new Set (
273
- authTokenGetters ? Object . keys ( authTokenGetters ) : [ ]
273
+ authTokenGetters ? Object . keys ( authTokenGetters ) : [ ] ,
274
274
) ;
275
275
const providedBoundKeys = new Set (
276
- boundParams ? Object . keys ( boundParams ) : [ ]
276
+ boundParams ? Object . keys ( boundParams ) : [ ] ,
277
277
) ;
278
278
279
279
for ( const [ toolName , toolSchema ] of Object . entries ( manifest . tools ) ) {
280
280
const { tool, usedAuthKeys, usedBoundKeys} = this . #createToolInstance(
281
281
toolName ,
282
282
toolSchema ,
283
283
authTokenGetters || { } ,
284
- boundParams || { }
284
+ boundParams || { } ,
285
285
) ;
286
286
tools . push ( tool ) ;
287
287
288
288
if ( strict ) {
289
289
const unusedAuth = [ ...providedAuthKeys ] . filter (
290
- key => ! usedAuthKeys . has ( key )
290
+ key => ! usedAuthKeys . has ( key ) ,
291
291
) ;
292
292
const unusedBound = [ ...providedBoundKeys ] . filter (
293
- key => ! usedBoundKeys . has ( key )
293
+ key => ! usedBoundKeys . has ( key ) ,
294
294
) ;
295
295
const errorMessages : string [ ] = [ ] ;
296
296
if ( unusedAuth . length > 0 ) {
297
297
errorMessages . push ( `unused auth tokens: ${ unusedAuth . join ( ', ' ) } ` ) ;
298
298
}
299
299
if ( unusedBound . length > 0 ) {
300
300
errorMessages . push (
301
- `unused bound parameters: ${ unusedBound . join ( ', ' ) } `
301
+ `unused bound parameters: ${ unusedBound . join ( ', ' ) } ` ,
302
302
) ;
303
303
}
304
304
if ( errorMessages . length > 0 ) {
305
305
throw new Error (
306
- `Validation failed for tool '${ toolName } ': ${ errorMessages . join ( '; ' ) } .`
306
+ `Validation failed for tool '${ toolName } ': ${ errorMessages . join ( '; ' ) } .` ,
307
307
) ;
308
308
}
309
309
} else {
@@ -314,25 +314,25 @@ class ToolboxClient {
314
314
315
315
if ( ! strict ) {
316
316
const unusedAuth = [ ...providedAuthKeys ] . filter (
317
- key => ! overallUsedAuthKeys . has ( key )
317
+ key => ! overallUsedAuthKeys . has ( key ) ,
318
318
) ;
319
319
const unusedBound = [ ...providedBoundKeys ] . filter (
320
- key => ! overallUsedBoundParams . has ( key )
320
+ key => ! overallUsedBoundParams . has ( key ) ,
321
321
) ;
322
322
const errorMessages : string [ ] = [ ] ;
323
323
if ( unusedAuth . length > 0 ) {
324
324
errorMessages . push (
325
- `unused auth tokens could not be applied to any tool: ${ unusedAuth . join ( ', ' ) } `
325
+ `unused auth tokens could not be applied to any tool: ${ unusedAuth . join ( ', ' ) } ` ,
326
326
) ;
327
327
}
328
328
if ( unusedBound . length > 0 ) {
329
329
errorMessages . push (
330
- `unused bound parameters could not be applied to any tool: ${ unusedBound . join ( ', ' ) } `
330
+ `unused bound parameters could not be applied to any tool: ${ unusedBound . join ( ', ' ) } ` ,
331
331
) ;
332
332
}
333
333
if ( errorMessages . length > 0 ) {
334
334
throw new Error (
335
- `Validation failed for toolset '${ name || 'default' } ': ${ errorMessages . join ( '; ' ) } .`
335
+ `Validation failed for toolset '${ name || 'default' } ': ${ errorMessages . join ( '; ' ) } .` ,
336
336
) ;
337
337
}
338
338
}
0 commit comments