MCPcopy Create free account
hub / github.com/github/gh-aw / parseBashTool

Function parseBashTool

pkg/workflow/tools_parser.go:401–438  ·  view source on GitHub ↗

parseBashTool converts raw bash tool configuration to BashToolConfig

(val any)

Source from the content-addressed store, hash-verified

399
400// parseBashTool converts raw bash tool configuration to BashToolConfig
401func parseBashTool(val any) *BashToolConfig {
402 if val == nil {
403 // nil is no longer supported - return nil to indicate invalid configuration
404 // The compiler will handle this as a validation error
405 toolsParserLog.Print("Bash tool configured with nil value (unsupported)")
406 return nil
407 }
408
409 // Handle boolean values
410 if boolVal, ok := val.(bool); ok {
411 if boolVal {
412 // bash: true means all commands allowed
413 toolsParserLog.Print("Bash tool enabled with all commands allowed")
414 return &BashToolConfig{}
415 }
416 // bash: false means explicitly disabled
417 toolsParserLog.Print("Bash tool explicitly disabled")
418 return &BashToolConfig{
419 AllowedCommands: []string{}, // Empty slice indicates explicitly disabled
420 }
421 }
422
423 // Handle array of allowed commands
424 if cmdArray, ok := val.([]any); ok {
425 config := &BashToolConfig{
426 AllowedCommands: make([]string, 0, len(cmdArray)),
427 }
428 for _, item := range cmdArray {
429 if str, ok := item.(string); ok {
430 config.AllowedCommands = append(config.AllowedCommands, str)
431 }
432 }
433 return config
434 }
435
436 // Invalid configuration
437 return nil
438}
439
440// parsePlaywrightTool converts raw playwright tool configuration to PlaywrightToolConfig
441func parsePlaywrightTool(val any) *PlaywrightToolConfig {

Callers 2

NewToolsFunction · 0.85

Calls 1

PrintMethod · 0.80

Tested by 1