@@ -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,39 @@ 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+ if len (fields ) == 0 { // Nothing left, so just return
325+ return originalName , alias , checkParam , nil , nil
312326 }
313327
314328 // Next we should have "with" followed by the args
315329 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 ])
317331 }
318332 fields = fields [1 :]
319333
320334 // If there are no args, return an error
321335 if len (fields ) == 0 {
322- return "" , "" , nil , fmt .Errorf ("expected args after 'with'" )
336+ return "" , "" , "" , nil , fmt .Errorf ("expected args after 'with'" )
323337 }
324338
325339 args := make (map [string ]any )
@@ -332,22 +346,22 @@ func ParseCredentialArgs(toolName string, input string) (string, string, map[str
332346 prev = "value"
333347 case "value" :
334348 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 )
336350 }
337351 prev = "as"
338352 case "as" :
339353 args [field ] = argValue
340354 prev = "name"
341355 case "name" :
342356 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 )
344358 }
345359 prev = "and"
346360 }
347361 }
348362
349363 if prev == "and" {
350- return "" , "" , nil , fmt .Errorf ("expected arg name after 'and'" )
364+ return "" , "" , "" , nil , fmt .Errorf ("expected arg name after 'and'" )
351365 }
352366
353367 // 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
360374 }
361375 }
362376
363- return originalName , alias , args , nil
377+ return originalName , alias , checkParam , args , nil
364378}
365379
366380func (t Tool ) GetToolRefsFromNames (names []string ) (result []ToolReference , _ error ) {
0 commit comments