Documentation
¶
Index ¶
- type ExecOptions
- type ExecResult
- type Factory
- type FileChangeEvent
- type FileChangeListener
- type FileInfo
- type GlobOptions
- type LocalFS
- func (lfs *LocalFS) Glob(ctx context.Context, pattern string, opts *GlobOptions) ([]string, error)
- func (lfs *LocalFS) IsInside(path string) bool
- func (lfs *LocalFS) Read(ctx context.Context, path string) (string, error)
- func (lfs *LocalFS) Resolve(path string) string
- func (lfs *LocalFS) Stat(ctx context.Context, path string) (FileInfo, error)
- func (lfs *LocalFS) Temp(name string) string
- func (lfs *LocalFS) Write(ctx context.Context, path string, content string) error
- type LocalSandbox
- func (ls *LocalSandbox) Dispose() error
- func (ls *LocalSandbox) Exec(ctx context.Context, cmd string, opts *ExecOptions) (*ExecResult, error)
- func (ls *LocalSandbox) FS() SandboxFS
- func (ls *LocalSandbox) Kind() string
- func (ls *LocalSandbox) Unwatch(watchID string) error
- func (ls *LocalSandbox) Watch(paths []string, listener FileChangeListener) (string, error)
- func (ls *LocalSandbox) WorkDir() string
- type LocalSandboxConfig
- type MockFS
- func (mfs *MockFS) Glob(ctx context.Context, pattern string, opts *GlobOptions) ([]string, error)
- func (mfs *MockFS) IsInside(path string) bool
- func (mfs *MockFS) Read(ctx context.Context, path string) (string, error)
- func (mfs *MockFS) Resolve(path string) string
- func (mfs *MockFS) Stat(ctx context.Context, path string) (FileInfo, error)
- func (mfs *MockFS) Temp(name string) string
- func (mfs *MockFS) Write(ctx context.Context, path string, content string) error
- type MockSandbox
- func (ms *MockSandbox) Dispose() error
- func (ms *MockSandbox) Exec(ctx context.Context, cmd string, opts *ExecOptions) (*ExecResult, error)
- func (ms *MockSandbox) FS() SandboxFS
- func (ms *MockSandbox) Kind() string
- func (ms *MockSandbox) Unwatch(watchID string) error
- func (ms *MockSandbox) Watch(paths []string, listener FileChangeListener) (string, error)
- func (ms *MockSandbox) WorkDir() string
- type RemoteClient
- type RemoteClientConfig
- type RemoteFS
- func (rfs *RemoteFS) Glob(ctx context.Context, pattern string, opts *GlobOptions) ([]string, error)
- func (rfs *RemoteFS) IsInside(path string) bool
- func (rfs *RemoteFS) Read(ctx context.Context, path string) (string, error)
- func (rfs *RemoteFS) Resolve(path string) string
- func (rfs *RemoteFS) Stat(ctx context.Context, path string) (FileInfo, error)
- func (rfs *RemoteFS) Temp(name string) string
- func (rfs *RemoteFS) Write(ctx context.Context, path string, content string) error
- type RemoteResponse
- type RemoteSandbox
- func (rs *RemoteSandbox) Dispose() error
- func (rs *RemoteSandbox) Exec(ctx context.Context, cmd string, opts *ExecOptions) (*ExecResult, error)
- func (rs *RemoteSandbox) FS() SandboxFS
- func (rs *RemoteSandbox) Kind() string
- func (rs *RemoteSandbox) SessionID() string
- func (rs *RemoteSandbox) SetSessionID(id string)
- func (rs *RemoteSandbox) Unwatch(watchID string) error
- func (rs *RemoteSandbox) Watch(paths []string, listener FileChangeListener) (string, error)
- func (rs *RemoteSandbox) WorkDir() string
- type RemoteSandboxConfig
- type Sandbox
- type SandboxFS
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecOptions ¶
ExecOptions 命令执行选项
type FileChangeEvent ¶
FileChangeEvent 文件变更事件
type FileChangeListener ¶
type FileChangeListener func(event FileChangeEvent)
FileChangeListener 文件变更监听器
type GlobOptions ¶
GlobOptions Glob选项
type LocalFS ¶
type LocalFS struct {
// contains filtered or unexported fields
}
LocalFS 本地文件系统实现
type LocalSandbox ¶
type LocalSandbox struct {
// contains filtered or unexported fields
}
LocalSandbox 本地沙箱实现
func NewLocalSandbox ¶
func NewLocalSandbox(config *LocalSandboxConfig) (*LocalSandbox, error)
NewLocalSandbox 创建本地沙箱
func (*LocalSandbox) Exec ¶
func (ls *LocalSandbox) Exec(ctx context.Context, cmd string, opts *ExecOptions) (*ExecResult, error)
Exec 执行命令
func (*LocalSandbox) Watch ¶
func (ls *LocalSandbox) Watch(paths []string, listener FileChangeListener) (string, error)
Watch 监听文件变更
type LocalSandboxConfig ¶
type LocalSandboxConfig struct {
WorkDir string
EnforceBoundary bool
AllowPaths []string
WatchFiles bool
}
LocalSandboxConfig 本地沙箱配置
type MockFS ¶
type MockFS struct {
// contains filtered or unexported fields
}
MockFS 模拟文件系统
type MockSandbox ¶
type MockSandbox struct {
// contains filtered or unexported fields
}
MockSandbox 模拟沙箱(用于测试)
func (*MockSandbox) Dispose ¶
func (ms *MockSandbox) Dispose() error
func (*MockSandbox) Exec ¶
func (ms *MockSandbox) Exec(ctx context.Context, cmd string, opts *ExecOptions) (*ExecResult, error)
func (*MockSandbox) FS ¶
func (ms *MockSandbox) FS() SandboxFS
func (*MockSandbox) Kind ¶
func (ms *MockSandbox) Kind() string
func (*MockSandbox) Unwatch ¶
func (ms *MockSandbox) Unwatch(watchID string) error
func (*MockSandbox) Watch ¶
func (ms *MockSandbox) Watch(paths []string, listener FileChangeListener) (string, error)
func (*MockSandbox) WorkDir ¶
func (ms *MockSandbox) WorkDir() string
type RemoteClient ¶
type RemoteClient struct {
// contains filtered or unexported fields
}
RemoteClient 远程沙箱客户端
func NewRemoteClient ¶
func NewRemoteClient(config *RemoteClientConfig) *RemoteClient
NewRemoteClient 创建远程客户端
func (*RemoteClient) Call ¶
func (rc *RemoteClient) Call(ctx context.Context, method, path string, body interface{}) (*RemoteResponse, error)
Call 调用远程 API
type RemoteClientConfig ¶
type RemoteClientConfig struct {
BaseURL string
APIKey string
APISecret string
Timeout time.Duration
Headers map[string]string
}
RemoteClientConfig 远程客户端配置
type RemoteFS ¶
type RemoteFS struct {
// contains filtered or unexported fields
}
RemoteFS 远程文件系统
type RemoteResponse ¶
RemoteResponse 远程响应
type RemoteSandbox ¶
type RemoteSandbox struct {
// contains filtered or unexported fields
}
RemoteSandbox 远程沙箱基础实现
func NewRemoteSandbox ¶
func NewRemoteSandbox(config *RemoteSandboxConfig) (*RemoteSandbox, error)
NewRemoteSandbox 创建远程沙箱
func (*RemoteSandbox) Exec ¶
func (rs *RemoteSandbox) Exec(ctx context.Context, cmd string, opts *ExecOptions) (*ExecResult, error)
Exec 执行命令 (需要子类实现具体的 API 调用)
func (*RemoteSandbox) SetSessionID ¶
func (rs *RemoteSandbox) SetSessionID(id string)
SetSessionID 设置会话 ID
func (*RemoteSandbox) Unwatch ¶
func (rs *RemoteSandbox) Unwatch(watchID string) error
Unwatch 取消监听 (远程沙箱通常不支持)
func (*RemoteSandbox) Watch ¶
func (rs *RemoteSandbox) Watch(paths []string, listener FileChangeListener) (string, error)
Watch 监听文件变化 (远程沙箱通常不支持)
type RemoteSandboxConfig ¶
type RemoteSandboxConfig struct {
BaseURL string
APIKey string
APISecret string
WorkDir string
Image string // 沙箱镜像
Region string // 区域
Timeout time.Duration // 超时时间
Environment map[string]string // 环境变量
Properties map[string]interface{}
}
RemoteSandboxConfig 远程沙箱配置
type Sandbox ¶
type Sandbox interface {
// Kind 返回沙箱类型
Kind() string
// WorkDir 返回工作目录
WorkDir() string
// FS 返回文件系统接口
FS() SandboxFS
// Exec 执行命令
Exec(ctx context.Context, cmd string, opts *ExecOptions) (*ExecResult, error)
// Watch 监听文件变更
Watch(paths []string, listener FileChangeListener) (watchID string, err error)
// Unwatch 取消监听
Unwatch(watchID string) error
// Dispose 释放资源
Dispose() error
}
Sandbox 沙箱接口
type SandboxFS ¶
type SandboxFS interface {
// Resolve 解析路径为绝对路径
Resolve(path string) string
// IsInside 检查路径是否在沙箱内
IsInside(path string) bool
// Read 读取文件内容
Read(ctx context.Context, path string) (string, error)
// Write 写入文件内容
Write(ctx context.Context, path string, content string) error
// Temp 生成临时文件路径
Temp(name string) string
// Stat 获取文件状态
Stat(ctx context.Context, path string) (FileInfo, error)
// Glob 文件匹配
Glob(ctx context.Context, pattern string, opts *GlobOptions) ([]string, error)
}
SandboxFS 沙箱文件系统接口
Click to show internal directories.
Click to hide internal directories.