cloud

package
v0.35.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AliyunConfig

type AliyunConfig struct {
	// MCP 服务端点
	MCPEndpoint string

	// 认证信息
	AccessKeyID     string
	AccessKeySecret string
	SecurityToken   string

	// 沙箱配置
	Region      string // 默认 cn-hangzhou
	WorkDir     string // 允许的工作目录
	Image       string // Ubuntu/其他镜像
	Timeout     time.Duration
	Environment map[string]string

	// OSS 配置 (可选)
	OSSEndpoint string
	OSSBucket   string
}

AliyunConfig 阿里云沙箱配置

type AliyunFS

type AliyunFS struct {
	// contains filtered or unexported fields
}

AliyunFS 阿里云文件系统实现

func (*AliyunFS) Glob

func (afs *AliyunFS) Glob(ctx context.Context, pattern string, opts *sandbox.GlobOptions) ([]string, error)

Glob 匹配文件

func (*AliyunFS) IsInside

func (afs *AliyunFS) IsInside(path string) bool

IsInside 检查路径是否在沙箱内

func (*AliyunFS) Read

func (afs *AliyunFS) Read(ctx context.Context, path string) (string, error)

Read 读取文件

func (*AliyunFS) Resolve

func (afs *AliyunFS) Resolve(path string) string

Resolve 解析路径为绝对路径

func (*AliyunFS) Stat

func (afs *AliyunFS) Stat(ctx context.Context, path string) (sandbox.FileInfo, error)

Stat 获取文件信息

func (*AliyunFS) Temp

func (afs *AliyunFS) Temp(name string) string

Temp 生成临时文件路径

func (*AliyunFS) Write

func (afs *AliyunFS) Write(ctx context.Context, path string, content string) error

Write 写入文件

type AliyunSandbox

type AliyunSandbox struct {
	*sandbox.RemoteSandbox
	// contains filtered or unexported fields
}

AliyunSandbox 阿里云 AgentBay 沙箱

func NewAliyunSandbox

func NewAliyunSandbox(config *AliyunConfig) (*AliyunSandbox, error)

NewAliyunSandbox 创建阿里云沙箱

func (*AliyunSandbox) Dispose

func (as *AliyunSandbox) Dispose() error

Dispose 清理资源

func (*AliyunSandbox) Exec

Exec 执行 Shell 命令

func (*AliyunSandbox) FS

func (as *AliyunSandbox) FS() sandbox.SandboxFS

FS 返回文件系统接口

func (*AliyunSandbox) Kind

func (as *AliyunSandbox) Kind() string

Kind 返回沙箱类型

type MCPCallParams

type MCPCallParams struct {
	Name      string         `json:"name"`
	Arguments map[string]any `json:"arguments,omitempty"`
}

MCPCallParams 工具调用参数

type MCPClient

type MCPClient struct {
	// contains filtered or unexported fields
}

MCPClient MCP 协议客户端

func NewMCPClient

func NewMCPClient(config *MCPClientConfig) *MCPClient

NewMCPClient 创建 MCP 客户端

func (*MCPClient) CallTool

func (mc *MCPClient) CallTool(ctx context.Context, toolName string, params map[string]any) (json.RawMessage, error)

CallTool 调用 MCP 工具

func (*MCPClient) ListTools

func (mc *MCPClient) ListTools(ctx context.Context) ([]MCPTool, error)

ListTools 列出可用工具

type MCPClientConfig

type MCPClientConfig struct {
	Endpoint        string
	AccessKeyID     string
	AccessKeySecret string
	SecurityToken   string
	Timeout         time.Duration
}

MCPClientConfig MCP 客户端配置

type MCPError

type MCPError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    any    `json:"data,omitempty"`
}

MCPError MCP 错误

type MCPRequest

type MCPRequest struct {
	JSONRPC string        `json:"jsonrpc"`
	Method  string        `json:"method"`
	ID      int64         `json:"id"`
	Params  MCPCallParams `json:"params,omitempty"`
}

MCPRequest MCP 请求

type MCPResponse

type MCPResponse struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      int64           `json:"id"`
	Result  json.RawMessage `json:"result,omitempty"`
	Error   *MCPError       `json:"error,omitempty"`
}

MCPResponse MCP 响应

type MCPTool

type MCPTool struct {
	Name        string         `json:"name"`
	Description string         `json:"description"`
	InputSchema map[string]any `json:"inputSchema"`
}

MCPTool MCP 工具定义

type VolcengineConfig

type VolcengineConfig struct {
	// API 配置
	Endpoint  string
	AccessKey string
	SecretKey string

	// 沙箱配置
	Region      string
	WorkDir     string
	Image       string
	Timeout     time.Duration
	Environment map[string]string

	// 计算资源配置
	CPU    int // vCPU 核数
	Memory int // 内存 MB
}

VolcengineConfig 火山引擎沙箱配置

type VolcengineFS

type VolcengineFS struct {
	// contains filtered or unexported fields
}

VolcengineFS 火山引擎文件系统

func (*VolcengineFS) Glob

func (vfs *VolcengineFS) Glob(ctx context.Context, pattern string, opts *sandbox.GlobOptions) ([]string, error)

Glob 匹配文件

func (*VolcengineFS) IsInside

func (vfs *VolcengineFS) IsInside(path string) bool

IsInside 检查路径是否在沙箱内

func (*VolcengineFS) Read

func (vfs *VolcengineFS) Read(ctx context.Context, path string) (string, error)

Read 读取文件

func (*VolcengineFS) Resolve

func (vfs *VolcengineFS) Resolve(path string) string

Resolve 解析路径为绝对路径

func (*VolcengineFS) Stat

func (vfs *VolcengineFS) Stat(ctx context.Context, path string) (sandbox.FileInfo, error)

Stat 获取文件信息

func (*VolcengineFS) Temp

func (vfs *VolcengineFS) Temp(name string) string

Temp 生成临时文件路径

func (*VolcengineFS) Write

func (vfs *VolcengineFS) Write(ctx context.Context, path string, content string) error

Write 写入文件

type VolcengineSandbox

type VolcengineSandbox struct {
	*sandbox.RemoteSandbox
	// contains filtered or unexported fields
}

VolcengineSandbox 火山引擎沙箱

func NewVolcengineSandbox

func NewVolcengineSandbox(config *VolcengineConfig) (*VolcengineSandbox, error)

NewVolcengineSandbox 创建火山引擎沙箱

func (*VolcengineSandbox) Dispose

func (vs *VolcengineSandbox) Dispose() error

Dispose 清理资源

func (*VolcengineSandbox) Exec

Exec 执行命令

func (*VolcengineSandbox) FS

FS 返回文件系统接口

func (*VolcengineSandbox) Kind

func (vs *VolcengineSandbox) Kind() string

Kind 返回沙箱类型

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL