cmd

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConnectProtocolVersion = "1"
)

Variables

View Source
var (
	ErrBaseURLEmpty          = core.ErrBaseURLEmpty
	ErrInvalidBaseURL        = core.ErrInvalidBaseURL
	ErrPathEmpty             = errors.New("sandbox/cmd: path is required")
	ErrCommandEmpty          = errors.New("sandbox/cmd: cmd is required")
	ErrProcessNil            = errors.New("sandbox/cmd: process is required")
	ErrWatcherIDEmpty        = errors.New("sandbox/cmd: watcherID is required")
	ErrCmdIDEmpty            = errors.New("sandbox/cmd: cmdID is required")
	ErrPortInvalid           = errors.New("sandbox/cmd: port must be greater than 0")
	ErrProcessSelectorEmpty  = errors.New("sandbox/cmd: process selector requires pid or tag")
	ErrProcessSelectorAmbig  = errors.New("sandbox/cmd: process selector requires exactly one of pid or tag")
	ErrProcessInputEmpty     = errors.New("sandbox/cmd: process input requires stdin or pty")
	ErrPTYRequired           = errors.New("sandbox/cmd: pty is required")
	ErrMultipartFilesEmpty   = errors.New("sandbox/cmd: multipart upload requires at least one part")
	ErrStreamInputFramesZero = errors.New("sandbox/cmd: stream input requires at least one frame")
)

Functions

This section is empty.

Types

type AgentRunRequest

type AgentRunRequest struct {
	Cmd       string            `json:"cmd"`
	Args      []string          `json:"args,omitempty"`
	CWD       string            `json:"cwd,omitempty"`
	Env       map[string]string `json:"env,omitempty"`
	TimeoutMS *int64            `json:"timeoutMs,omitempty"`
	Stdin     *string           `json:"stdin,omitempty"`
}

type AgentRunResponse

type AgentRunResponse struct {
	Stdout     string `json:"stdout"`
	Stderr     string `json:"stderr"`
	ExitCode   int    `json:"exit_code"`
	DurationMS int64  `json:"duration_ms"`
	Error      string `json:"error,omitempty"`
}

type CloseStdinRequest

type CloseStdinRequest struct {
	Process ProcessSelector `json:"process"`
}

type ComposeFilesRequest

type ComposeFilesRequest struct {
	SourcePaths []string `json:"source_paths"`
	Destination string   `json:"destination"`
}

type ConfigureRequest

type ConfigureRequest struct {
	Envs map[string]string `json:"envs,omitempty"`
}

type ConnectFrame

type ConnectFrame struct {
	Flags   byte
	Payload json.RawMessage
}

func (*ConnectFrame) Decode

func (f *ConnectFrame) Decode(out any) error

func (*ConnectFrame) IsEnd

func (f *ConnectFrame) IsEnd() bool

type ConnectRequest

type ConnectRequest struct {
	Process ProcessSelector `json:"process"`
}

type ConnectStream

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

func (*ConnectStream) Close

func (s *ConnectStream) Close() error

func (*ConnectStream) NextFrame

func (s *ConnectStream) NextFrame() (*ConnectFrame, error)

func (*ConnectStream) NextJSON

func (s *ConnectStream) NextJSON(out any) (*ConnectFrame, error)

func (*ConnectStream) Response

func (s *ConnectStream) Response() *http.Response

type CreateWatcherRequest

type CreateWatcherRequest struct {
	Path      string `json:"path"`
	Recursive *bool  `json:"recursive,omitempty"`
}

type CreateWatcherResponse

type CreateWatcherResponse struct {
	WatcherID string `json:"watcherId"`
}

type DownloadRequest

type DownloadRequest struct {
	Path string
}

type EntryInfo

type EntryInfo struct {
	Name          string   `json:"name"`
	Type          FileType `json:"type"`
	Path          string   `json:"path"`
	Size          int64    `json:"size"`
	Mode          int64    `json:"mode"`
	Permissions   string   `json:"permissions"`
	Owner         string   `json:"owner"`
	Group         string   `json:"group"`
	ModifiedTime  string   `json:"modifiedTime"`
	SymlinkTarget *string  `json:"symlinkTarget,omitempty"`
}

type EventType

type EventType string
const (
	EventTypeUnspecified EventType = "EVENT_TYPE_UNSPECIFIED"
	EventTypeCreate      EventType = "EVENT_TYPE_CREATE"
	EventTypeWrite       EventType = "EVENT_TYPE_WRITE"
	EventTypeRemove      EventType = "EVENT_TYPE_REMOVE"
	EventTypeRename      EventType = "EVENT_TYPE_RENAME"
	EventTypeChmod       EventType = "EVENT_TYPE_CHMOD"
)

type FileRequest

type FileRequest struct {
	Path string
}

type FileType

type FileType string
const (
	FileTypeUnspecified FileType = "FILE_TYPE_UNSPECIFIED"
	FileTypeFile        FileType = "FILE_TYPE_FILE"
	FileTypeDirectory   FileType = "FILE_TYPE_DIRECTORY"
	FileTypeSymlink     FileType = "FILE_TYPE_SYMLINK"
)

type FilesContentRequest

type FilesContentRequest struct {
	Path      string
	MaxTokens *int
}

type FilesContentResponse

type FilesContentResponse struct {
	Type      string `json:"type"`
	Content   string `json:"content,omitempty"`
	Truncated bool   `json:"truncated,omitempty"`
	MIMEType  string `json:"mime_type,omitempty"`
	Data      string `json:"data,omitempty"`
}

type FilesystemEvent

type FilesystemEvent struct {
	Name string    `json:"name"`
	Type EventType `json:"type"`
}

type FilesystemWatchFrame

type FilesystemWatchFrame struct {
	Start      *struct{}        `json:"start,omitempty"`
	Keepalive  *struct{}        `json:"keepalive,omitempty"`
	Filesystem *FilesystemEvent `json:"filesystem,omitempty"`
}

type FilesystemWatchStream

type FilesystemWatchStream struct {
	*ConnectStream
}

func (*FilesystemWatchStream) Next

type FsEditRequest

type FsEditRequest struct {
	Path    string `json:"path"`
	OldText string `json:"oldText"`
	NewText string `json:"newText"`
}

type FsEditResponse

type FsEditResponse struct {
	Message string `json:"message"`
}

type GetResultRequest

type GetResultRequest struct {
	CmdID string `json:"cmdId"`
}

type GetResultResponse

type GetResultResponse struct {
	ExitCode      int    `json:"exitCode"`
	Stdout        string `json:"stdout"`
	Stderr        string `json:"stderr"`
	StartedAtUnix int64  `json:"startedAtUnix"`
}

type GetWatcherEventsRequest

type GetWatcherEventsRequest struct {
	WatcherID string `json:"watcherId"`
	Limit     *int   `json:"limit,omitempty"`
}

type GetWatcherEventsResponse

type GetWatcherEventsResponse struct {
	Events []FilesystemEvent `json:"events"`
}

type ListDirRequest

type ListDirRequest struct {
	Path  string `json:"path"`
	Depth *int   `json:"depth,omitempty"`
}

type ListDirResponse

type ListDirResponse struct {
	Entries []EntryInfo `json:"entries"`
}

type MakeDirRequest

type MakeDirRequest struct {
	Path string `json:"path"`
}

type MakeDirResponse

type MakeDirResponse struct {
	Entry EntryInfo `json:"entry"`
}

type MetricsResponse

type MetricsResponse struct {
	TS          int64   `json:"ts"`
	CPUCount    int     `json:"cpu_count"`
	CPUUsedPct  float64 `json:"cpu_used_pct"`
	MemTotal    int64   `json:"mem_total"`
	MemUsed     int64   `json:"mem_used"`
	MemTotalMiB int64   `json:"mem_total_mib"`
	MemUsedMiB  int64   `json:"mem_used_mib"`
	MemCache    int64   `json:"mem_cache"`
	DiskUsed    int64   `json:"disk_used"`
	DiskTotal   int64   `json:"disk_total"`
}

type MoveRequest

type MoveRequest struct {
	Source      string `json:"source"`
	Destination string `json:"destination"`
}

type MoveResponse

type MoveResponse struct {
	Entry EntryInfo `json:"entry"`
}

type MultipartFile

type MultipartFile struct {
	FieldName   string
	FileName    string
	ContentType string
	Data        []byte
}

type PortEntry

type PortEntry struct {
	Port        int    `json:"port"`
	Protocol    string `json:"protocol"`
	Address     string `json:"address"`
	PID         *int   `json:"pid,omitempty"`
	ProcessName string `json:"process_name,omitempty"`
}

type ProcessConfig

type ProcessConfig struct {
	Cmd  string            `json:"cmd"`
	Args []string          `json:"args,omitempty"`
	Envs map[string]string `json:"envs,omitempty"`
	CWD  *string           `json:"cwd,omitempty"`
}

type ProcessDataEvent

type ProcessDataEvent struct {
	Stdout string `json:"stdout,omitempty"`
	Stderr string `json:"stderr,omitempty"`
	PTY    string `json:"pty,omitempty"`
}

type ProcessEndEvent

type ProcessEndEvent struct {
	Exited bool    `json:"exited"`
	Status string  `json:"status"`
	Error  *string `json:"error"`
}

type ProcessEvent

type ProcessEvent struct {
	Start     *ProcessStartEvent `json:"start,omitempty"`
	Data      *ProcessDataEvent  `json:"data,omitempty"`
	End       *ProcessEndEvent   `json:"end,omitempty"`
	Keepalive *struct{}          `json:"keepalive,omitempty"`
}

type ProcessInfo

type ProcessInfo struct {
	PID    int           `json:"pid"`
	Config ProcessConfig `json:"config"`
	Tag    string        `json:"tag,omitempty"`
	CmdID  string        `json:"cmdId,omitempty"`
}

type ProcessInput

type ProcessInput struct {
	Stdin string `json:"stdin,omitempty"`
	PTY   string `json:"pty,omitempty"`
}

func (ProcessInput) Validate

func (i ProcessInput) Validate() error

type ProcessListResponse

type ProcessListResponse struct {
	Processes []ProcessInfo `json:"processes"`
}

type ProcessSelector

type ProcessSelector struct {
	PID int    `json:"pid,omitempty"`
	Tag string `json:"tag,omitempty"`
}

func (ProcessSelector) Validate

func (s ProcessSelector) Validate() error

type ProcessStartEvent

type ProcessStartEvent struct {
	PID   int    `json:"pid"`
	CmdID string `json:"cmdId"`
}

type ProcessStartRequest

type ProcessStartRequest struct {
	Process   *ProcessConfig `json:"process"`
	TimeoutMS *int64         `json:"timeoutMs,omitempty"`
	Tag       string         `json:"tag,omitempty"`
	Stdin     *bool          `json:"stdin,omitempty"`
	PTY       *PtyConfig     `json:"pty,omitempty"`
}

type ProcessStream

type ProcessStream struct {
	*ConnectStream
}

func (*ProcessStream) Next

func (s *ProcessStream) Next() (*ProcessStreamFrame, error)

type ProcessStreamFrame

type ProcessStreamFrame struct {
	Event ProcessEvent `json:"event"`
}

type ProxyRequest

type ProxyRequest struct {
	Method  string
	Port    int
	Path    string
	Body    io.Reader
	Headers http.Header
}

type PtyConfig

type PtyConfig struct {
	Size PtySize `json:"size"`
}

type PtySize

type PtySize struct {
	Cols int `json:"cols"`
	Rows int `json:"rows"`
}

type RemoveRequest

type RemoveRequest struct {
	Path string `json:"path"`
}

type RemoveWatcherRequest

type RemoveWatcherRequest struct {
	WatcherID string `json:"watcherId"`
}

type RequestOptions

type RequestOptions struct {
	Username            string
	Signature           string
	SignatureExpiration *int64
	Range               string
	Headers             http.Header
}

type RestEntryInfo

type RestEntryInfo struct {
	Path string        `json:"path"`
	Name string        `json:"name"`
	Type RestEntryType `json:"type"`
}

type RestEntryType

type RestEntryType string
const (
	RestEntryTypeFile      RestEntryType = "file"
	RestEntryTypeDirectory RestEntryType = "directory"
)

type SendInputRequest

type SendInputRequest struct {
	Process ProcessSelector `json:"process"`
	Input   ProcessInput    `json:"input"`
}

type SendSignalRequest

type SendSignalRequest struct {
	Process ProcessSelector `json:"process"`
	Signal  string          `json:"signal"`
}

type Service

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

func NewService

func NewService(baseURL, accessToken string) (*Service, error)

func (*Service) BaseURL

func (c *Service) BaseURL() string

func (*Service) CloseStdin

func (c *Service) CloseStdin(ctx context.Context, req *CloseStdinRequest, opts *RequestOptions) error

func (*Service) ComposeFiles

func (c *Service) ComposeFiles(ctx context.Context, req *ComposeFilesRequest, opts *RequestOptions) (*RestEntryInfo, error)

func (*Service) Configure

func (c *Service) Configure(ctx context.Context, req *ConfigureRequest) error

func (*Service) Connect

func (c *Service) Connect(ctx context.Context, req *ConnectRequest, opts *RequestOptions) (*ProcessStream, error)

func (*Service) CreateWatcher

func (c *Service) CreateWatcher(ctx context.Context, req *CreateWatcherRequest, opts *RequestOptions) (*CreateWatcherResponse, error)

func (*Service) Download

func (c *Service) Download(ctx context.Context, req *DownloadRequest, opts *RequestOptions) (*http.Response, error)

func (*Service) Edit

func (c *Service) Edit(ctx context.Context, req *FsEditRequest, opts *RequestOptions) (*FsEditResponse, error)

func (*Service) Envs

func (c *Service) Envs(ctx context.Context) (map[string]string, error)

func (*Service) FilesContent

func (c *Service) FilesContent(ctx context.Context, req *FilesContentRequest, opts *RequestOptions) (*FilesContentResponse, error)

func (*Service) GetResult

func (c *Service) GetResult(ctx context.Context, req *GetResultRequest, opts *RequestOptions) (*GetResultResponse, error)

func (*Service) GetWatcherEvents

func (*Service) ListDir

func (c *Service) ListDir(ctx context.Context, req *ListDirRequest, opts *RequestOptions) (*ListDirResponse, error)

func (*Service) ListProcesses

func (c *Service) ListProcesses(ctx context.Context, opts *RequestOptions) (*ProcessListResponse, error)

func (*Service) MakeDir

func (c *Service) MakeDir(ctx context.Context, req *MakeDirRequest, opts *RequestOptions) (*MakeDirResponse, error)

func (*Service) Metrics

func (c *Service) Metrics(ctx context.Context) (*MetricsResponse, error)

func (*Service) Move

func (c *Service) Move(ctx context.Context, req *MoveRequest, opts *RequestOptions) (*MoveResponse, error)

func (*Service) Ports

func (c *Service) Ports(ctx context.Context) ([]PortEntry, error)

func (*Service) Proxy

func (c *Service) Proxy(ctx context.Context, req *ProxyRequest) (*http.Response, error)

func (*Service) ReadFile

func (c *Service) ReadFile(ctx context.Context, req *FileRequest, opts *RequestOptions) (*http.Response, error)

func (*Service) Remove

func (c *Service) Remove(ctx context.Context, req *RemoveRequest, opts *RequestOptions) error

func (*Service) RemoveWatcher

func (c *Service) RemoveWatcher(ctx context.Context, req *RemoveWatcherRequest, opts *RequestOptions) error

func (*Service) Run

func (*Service) SendInput

func (c *Service) SendInput(ctx context.Context, req *SendInputRequest, opts *RequestOptions) error

func (*Service) SendSignal

func (c *Service) SendSignal(ctx context.Context, req *SendSignalRequest, opts *RequestOptions) error

func (*Service) Start

func (*Service) Stat

func (c *Service) Stat(ctx context.Context, req *StatRequest, opts *RequestOptions) (*StatResponse, error)

func (*Service) StreamInput

func (c *Service) StreamInput(ctx context.Context, frames []StreamInputFrame, opts *RequestOptions) (*ConnectFrame, error)

func (*Service) Update

func (c *Service) Update(ctx context.Context, req *UpdateRequest, opts *RequestOptions) error

func (*Service) UploadBytes

func (c *Service) UploadBytes(ctx context.Context, req *UploadBytesRequest, opts *RequestOptions) ([]RestEntryInfo, error)

func (*Service) UploadJSON

func (c *Service) UploadJSON(ctx context.Context, entry *WriteFileEntry, opts *RequestOptions) ([]RestEntryInfo, error)

func (*Service) UploadMultipart

func (c *Service) UploadMultipart(ctx context.Context, req *UploadMultipartRequest, opts *RequestOptions) ([]RestEntryInfo, error)

func (*Service) WatchDir

func (*Service) WriteBatch

func (*Service) WriteFile

func (c *Service) WriteFile(ctx context.Context, req *UploadBytesRequest, opts *RequestOptions) error

type Signal

type Signal string
const (
	SignalUnspecified Signal = "SIGNAL_UNSPECIFIED"
	SignalSIGTERM     Signal = "SIGNAL_SIGTERM"
	SignalSIGKILL     Signal = "SIGNAL_SIGKILL"
	SignalSIGINT      Signal = "SIGINT"
	SignalSIGHUP      Signal = "SIGHUP"
)

type StatRequest

type StatRequest struct {
	Path string `json:"path"`
}

type StatResponse

type StatResponse struct {
	Entry EntryInfo `json:"entry"`
}

type StreamInputData

type StreamInputData struct {
	Input ProcessInput `json:"input"`
}

type StreamInputFrame

type StreamInputFrame struct {
	Start     *StreamInputStart `json:"start,omitempty"`
	Data      *StreamInputData  `json:"data,omitempty"`
	Keepalive *struct{}         `json:"keepalive,omitempty"`
}

type StreamInputStart

type StreamInputStart struct {
	Process ProcessSelector `json:"process"`
}

type UpdateRequest

type UpdateRequest struct {
	Process ProcessSelector `json:"process"`
	PTY     *PtyConfig      `json:"pty"`
}

type UploadBytesRequest

type UploadBytesRequest struct {
	Path         string
	Data         []byte
	GzipCompress bool
}

type UploadMultipartRequest

type UploadMultipartRequest struct {
	Path  string
	Parts []MultipartFile
}

type WatchDirRequest

type WatchDirRequest struct {
	Path      string `json:"path"`
	Recursive *bool  `json:"recursive,omitempty"`
}

type WriteFileEntry

type WriteFileEntry struct {
	Path    string `json:"path"`
	Content string `json:"content,omitempty"`
	Data    string `json:"data,omitempty"`
	Mode    *int   `json:"mode,omitempty"`
}

type WriteFilesBatchResponse

type WriteFilesBatchResponse struct {
	Files []WriteFilesBatchResult `json:"files"`
}

type WriteFilesBatchResult

type WriteFilesBatchResult struct {
	Path         string `json:"path"`
	BytesWritten int64  `json:"bytes_written"`
}

type WriteFilesRequest

type WriteFilesRequest struct {
	Files []WriteFileEntry `json:"files"`
}

Jump to

Keyboard shortcuts

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