- Implement secure config file location (/tmp/.yao/proxy.json) instead of user-visible /workspace/
- Add generic options map support for backend-specific parameters (e.g., thinking for Volcengine GLM-4.7)
- Add secrets support for passing sensitive env vars (e.g., GITHUB_TOKEN) to sandbox container
- Remove excessive debug logs, keep critical ones with log.Printf("[Sandbox]...")
- Fix test assertions for system prompt passing via CLI args instead of env var
- Update i18n messages for sandbox loading states
Co-authored-by: Cursor <cursoragent@cursor.com>
53 lines
1.6 KiB
Go
53 lines
1.6 KiB
Go
package sandbox
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/yaoapp/yao/agent/sandbox/claude"
|
|
infraSandbox "github.com/yaoapp/yao/sandbox"
|
|
)
|
|
|
|
// New creates a new Executor based on the command type
|
|
func New(manager *infraSandbox.Manager, opts *Options) (Executor, error) {
|
|
if opts == nil {
|
|
return nil, fmt.Errorf("options is required")
|
|
}
|
|
|
|
if !IsValidCommand(opts.Command) {
|
|
return nil, fmt.Errorf("unsupported command type: %s, supported: %v", opts.Command, CommandTypes)
|
|
}
|
|
|
|
// Set default image if not specified
|
|
if opts.Image == "" {
|
|
opts.Image = DefaultImage(opts.Command)
|
|
}
|
|
|
|
switch opts.Command {
|
|
case "claude":
|
|
// Convert to claude.Options
|
|
claudeOpts := &claude.Options{
|
|
Command: opts.Command,
|
|
Image: opts.Image,
|
|
MaxMemory: opts.MaxMemory,
|
|
MaxCPU: opts.MaxCPU,
|
|
Timeout: opts.Timeout,
|
|
Arguments: opts.Arguments,
|
|
UserID: opts.UserID,
|
|
ChatID: opts.ChatID,
|
|
MCPConfig: opts.MCPConfig,
|
|
MCPTools: opts.MCPTools,
|
|
SkillsDir: opts.SkillsDir,
|
|
SystemPrompt: opts.SystemPrompt, // Required for Claude CLI execution
|
|
ConnectorHost: opts.ConnectorHost,
|
|
ConnectorKey: opts.ConnectorKey,
|
|
Model: opts.Model,
|
|
ConnectorOptions: opts.ConnectorOptions, // Extra options like thinking, max_tokens
|
|
Secrets: opts.Secrets, // Secrets for container env vars
|
|
}
|
|
return claude.NewExecutor(manager, claudeOpts)
|
|
case "cursor":
|
|
return nil, fmt.Errorf("cursor executor not implemented yet")
|
|
default:
|
|
return nil, fmt.Errorf("unsupported command type: %s", opts.Command)
|
|
}
|
|
}
|