Add Claude CLI argument mapping for sandbox arguments
- Introduce a whitelist mapping for `package.yao` sandbox arguments to corresponding Claude CLI flags, allowing selective argument passing. - Update `BuildCommandWithContinuation` to iterate over the whitelist and append valid arguments to the Claude CLI command. This change enhances the flexibility of argument handling in the Claude CLI, ensuring only specified arguments are processed.
This commit is contained in:
parent
31a75f0161
commit
2a839ff94e
1 changed files with 14 additions and 3 deletions
|
|
@ -49,6 +49,14 @@ When working with GitHub and a token is provided:
|
|||
3. Do NOT use curl to call GitHub API directly - always prefer gh CLI
|
||||
`
|
||||
|
||||
// claudeArgWhitelist maps package.yao sandbox.arguments keys to Claude CLI flags.
|
||||
// Only keys listed here are passed through; everything else is ignored.
|
||||
var claudeArgWhitelist = map[string]string{
|
||||
"max_turns": "--max-turns", // Maximum conversation turns
|
||||
"disallowed_tools": "--disallowed-tools", // Comma-separated tool blacklist (e.g. "WebSearch,WebFetch")
|
||||
"allowed_tools": "--allowedTools", // Comma-separated tool whitelist (e.g. "Bash,Read,Write")
|
||||
}
|
||||
|
||||
// BuildCommand builds the Claude CLI command and environment variables
|
||||
// Uses stdin with --input-format stream-json for unlimited prompt length
|
||||
// isContinuation: if true, uses --continue to resume previous session (only sends last user message)
|
||||
|
|
@ -109,10 +117,13 @@ func BuildCommandWithContinuation(messages []agentContext.Message, opts *Options
|
|||
claudeArgs = append(claudeArgs, "--continue")
|
||||
}
|
||||
|
||||
// Add max_turns if specified
|
||||
// Pass through whitelisted arguments to Claude CLI flags.
|
||||
// Map: package.yao arguments key → Claude CLI flag
|
||||
if opts != nil && opts.Arguments != nil {
|
||||
if maxTurns, ok := opts.Arguments["max_turns"]; ok {
|
||||
claudeArgs = append(claudeArgs, "--max-turns", fmt.Sprintf("%v", maxTurns))
|
||||
for key, flag := range claudeArgWhitelist {
|
||||
if val, ok := opts.Arguments[key]; ok {
|
||||
claudeArgs = append(claudeArgs, flag, fmt.Sprintf("%v", val))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue