@@ -272,9 +272,9 @@ func SplitArg(hasArg string) (prefix, arg string) {
272272// - toolName: "toolName with ${var1} as arg1 and ${var2} as arg2"
273273// - input: `{"var1": "value1", "var2": "value2"}`
274274// 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 ) {
276276 if toolName == "" {
277- return "" , "" , nil , nil
277+ return "" , "" , "" , nil , nil
278278 }
279279
280280 inputMap := make (map [string ]any )
@@ -287,12 +287,12 @@ func ParseCredentialArgs(toolName string, input string) (string, string, map[str
287287
288288 fields , err := shlex .Split (toolName )
289289 if err != nil {
290- return "" , "" , nil , err
290+ return "" , "" , "" , nil , err
291291 }
292292
293293 // If it's just the tool name, return it
294294 if len (fields ) == 1 {
295- return toolName , "" , nil , nil
295+ return toolName , "" , "" , nil , nil
296296 }
297297
298298 // Next field is "as" if there is an alias, otherwise it should be "with"
@@ -301,25 +301,40 @@ func ParseCredentialArgs(toolName string, input string) (string, string, map[str
301301 fields = fields [1 :]
302302 if fields [0 ] == "as" {
303303 if len (fields ) < 2 {
304- return "" , "" , nil , fmt .Errorf ("expected alias after 'as'" )
304+ return "" , "" , "" , nil , fmt .Errorf ("expected alias after 'as'" )
305305 }
306306 alias = fields [1 ]
307307 fields = fields [2 :]
308308 }
309309
310310 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+
325+ if len (fields ) == 0 { // Nothing left, so just return
326+ return originalName , alias , checkParam , nil , nil
312327 }
313328
314329 // Next we should have "with" followed by the args
315330 if fields [0 ] != "with" {
316- return "" , "" , nil , fmt .Errorf ("expected 'with' but got %s" , fields [0 ])
331+ return "" , "" , "" , nil , fmt .Errorf ("expected 'with' but got %s" , fields [0 ])
317332 }
318333 fields = fields [1 :]
319334
320335 // If there are no args, return an error
321336 if len (fields ) == 0 {
322- return "" , "" , nil , fmt .Errorf ("expected args after 'with'" )
337+ return "" , "" , "" , nil , fmt .Errorf ("expected args after 'with'" )
323338 }
324339
325340 args := make (map [string ]any )
@@ -332,22 +347,22 @@ func ParseCredentialArgs(toolName string, input string) (string, string, map[str
332347 prev = "value"
333348 case "value" :
334349 if field != "as" {
335- return "" , "" , nil , fmt .Errorf ("expected 'as' but got %s" , field )
350+ return "" , "" , "" , nil , fmt .Errorf ("expected 'as' but got %s" , field )
336351 }
337352 prev = "as"
338353 case "as" :
339354 args [field ] = argValue
340355 prev = "name"
341356 case "name" :
342357 if field != "and" {
343- return "" , "" , nil , fmt .Errorf ("expected 'and' but got %s" , field )
358+ return "" , "" , "" , nil , fmt .Errorf ("expected 'and' but got %s" , field )
344359 }
345360 prev = "and"
346361 }
347362 }
348363
349364 if prev == "and" {
350- return "" , "" , nil , fmt .Errorf ("expected arg name after 'and'" )
365+ return "" , "" , "" , nil , fmt .Errorf ("expected arg name after 'and'" )
351366 }
352367
353368 // Check and see if any of the arg values are references to an input
@@ -360,7 +375,7 @@ func ParseCredentialArgs(toolName string, input string) (string, string, map[str
360375 }
361376 }
362377
363- return originalName , alias , args , nil
378+ return originalName , alias , checkParam , args , nil
364379}
365380
366381func (t Tool ) GetToolRefsFromNames (names []string ) (result []ToolReference , _ error ) {
0 commit comments