@@ -272,9 +272,9 @@ func SplitArg(hasArg string) (prefix, arg string) {
272
272
// - toolName: "toolName with ${var1} as arg1 and ${var2} as arg2"
273
273
// - input: `{"var1": "value1", "var2": "value2"}`
274
274
// result: toolName, "", map[string]any{"arg1": "value1", "arg2": "value2"}, nil
275
- func ParseCredentialArgs (toolName string , input string ) (string , string , map [string ]any , error ) {
275
+ func ParseCredentialArgs (toolName string , input string ) (string , string , string , map [string ]any , error ) {
276
276
if toolName == "" {
277
- return "" , "" , nil , nil
277
+ return "" , "" , "" , nil , nil
278
278
}
279
279
280
280
inputMap := make (map [string ]any )
@@ -287,12 +287,12 @@ func ParseCredentialArgs(toolName string, input string) (string, string, map[str
287
287
288
288
fields , err := shlex .Split (toolName )
289
289
if err != nil {
290
- return "" , "" , nil , err
290
+ return "" , "" , "" , nil , err
291
291
}
292
292
293
293
// If it's just the tool name, return it
294
294
if len (fields ) == 1 {
295
- return toolName , "" , nil , nil
295
+ return toolName , "" , "" , nil , nil
296
296
}
297
297
298
298
// Next field is "as" if there is an alias, otherwise it should be "with"
@@ -301,25 +301,39 @@ func ParseCredentialArgs(toolName string, input string) (string, string, map[str
301
301
fields = fields [1 :]
302
302
if fields [0 ] == "as" {
303
303
if len (fields ) < 2 {
304
- return "" , "" , nil , fmt .Errorf ("expected alias after 'as'" )
304
+ return "" , "" , "" , nil , fmt .Errorf ("expected alias after 'as'" )
305
305
}
306
306
alias = fields [1 ]
307
307
fields = fields [2 :]
308
308
}
309
309
310
310
if len (fields ) == 0 { // Nothing left, so just return
311
- return originalName , alias , nil , nil
311
+ return originalName , alias , "" , nil , nil
312
+ }
313
+
314
+ var checkParam string
315
+ if fields [0 ] == "checked" {
316
+ if len (fields ) < 3 || fields [1 ] != "with" {
317
+ return "" , "" , "" , nil , fmt .Errorf ("expected 'checked with some_value' but got %v" , fields )
318
+ }
319
+
320
+ checkParam = fields [2 ]
321
+ fields = fields [3 :]
322
+ }
323
+
324
+ if len (fields ) == 0 { // Nothing left, so just return
325
+ return originalName , alias , checkParam , nil , nil
312
326
}
313
327
314
328
// Next we should have "with" followed by the args
315
329
if fields [0 ] != "with" {
316
- return "" , "" , nil , fmt .Errorf ("expected 'with' but got %s" , fields [0 ])
330
+ return "" , "" , "" , nil , fmt .Errorf ("expected 'with' but got %s" , fields [0 ])
317
331
}
318
332
fields = fields [1 :]
319
333
320
334
// If there are no args, return an error
321
335
if len (fields ) == 0 {
322
- return "" , "" , nil , fmt .Errorf ("expected args after 'with'" )
336
+ return "" , "" , "" , nil , fmt .Errorf ("expected args after 'with'" )
323
337
}
324
338
325
339
args := make (map [string ]any )
@@ -332,22 +346,22 @@ func ParseCredentialArgs(toolName string, input string) (string, string, map[str
332
346
prev = "value"
333
347
case "value" :
334
348
if field != "as" {
335
- return "" , "" , nil , fmt .Errorf ("expected 'as' but got %s" , field )
349
+ return "" , "" , "" , nil , fmt .Errorf ("expected 'as' but got %s" , field )
336
350
}
337
351
prev = "as"
338
352
case "as" :
339
353
args [field ] = argValue
340
354
prev = "name"
341
355
case "name" :
342
356
if field != "and" {
343
- return "" , "" , nil , fmt .Errorf ("expected 'and' but got %s" , field )
357
+ return "" , "" , "" , nil , fmt .Errorf ("expected 'and' but got %s" , field )
344
358
}
345
359
prev = "and"
346
360
}
347
361
}
348
362
349
363
if prev == "and" {
350
- return "" , "" , nil , fmt .Errorf ("expected arg name after 'and'" )
364
+ return "" , "" , "" , nil , fmt .Errorf ("expected arg name after 'and'" )
351
365
}
352
366
353
367
// Check and see if any of the arg values are references to an input
@@ -360,7 +374,7 @@ func ParseCredentialArgs(toolName string, input string) (string, string, map[str
360
374
}
361
375
}
362
376
363
- return originalName , alias , args , nil
377
+ return originalName , alias , checkParam , args , nil
364
378
}
365
379
366
380
func (t Tool ) GetToolRefsFromNames (names []string ) (result []ToolReference , _ error ) {
0 commit comments