yao/agent/sandbox/executor.go
Max cd5cf32a20 Enhance Sandbox Integration and CI Workflow for AI Tests
- Added steps to pull necessary Docker images for sandbox testing in both CI workflows.
- Updated the AI test execution to utilize sandbox configurations, ensuring proper environment setup.
- Introduced sandbox initialization in the Assistant's Stream method, allowing for execution of coding agents like Claude and Cursor.
- Enhanced context management to support sandbox execution, improving flexibility in handling agent operations.
2026-01-30 17:41:06 +08:00

49 lines
1.3 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,
SkillsDir: opts.SkillsDir,
ConnectorHost: opts.ConnectorHost,
ConnectorKey: opts.ConnectorKey,
Model: opts.Model,
}
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)
}
}