parseBashTool converts raw bash tool configuration to BashToolConfig
(val any)
| 399 | |
| 400 | // parseBashTool converts raw bash tool configuration to BashToolConfig |
| 401 | func 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 |
| 441 | func parsePlaywrightTool(val any) *PlaywrightToolConfig { |