- Added functionality to build and manage MCP configuration for sandbox environments, allowing for dynamic tool execution. - Enhanced the Assistant's Stream method to skip MCP tool calls in sandbox mode, with internal handling by Claude CLI. - Introduced unit tests for MCP configuration building and skills directory resolution, ensuring robust integration. - Updated sandbox manager to create IPC sessions and manage tool exposure dynamically, improving interaction with external agents. - Enhanced documentation to reflect new features and integration points for MCP and skills within the sandbox.
50 lines
1.4 KiB
Go
50 lines
1.4 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, // MCP tools to expose via IPC
|
|
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)
|
|
}
|
|
}
|