Documentation
¶
Overview ¶
Package sandbox provides an HTTP client for the sandbox server. The sandbox server runs file, git, and command operations inside an isolated container so that agent-generated code never touches the host process.
Ported from semspec/tools/sandbox with task_id mapped to agent loop_id.
Index ¶
- type Client
- func (c *Client) CreateWorktree(ctx context.Context, taskID string) (*WorktreeInfo, error)
- func (c *Client) DeleteWorktree(ctx context.Context, taskID string) error
- func (c *Client) Exec(ctx context.Context, taskID, command string, timeoutMs int) (*ExecResult, error)
- func (c *Client) GitCommit(ctx context.Context, taskID, message string) (*CommitResult, error)
- func (c *Client) GitDiff(ctx context.Context, taskID string) (string, error)
- func (c *Client) GitStatus(ctx context.Context, taskID string) (string, error)
- func (c *Client) Health(ctx context.Context) error
- func (c *Client) ListDir(ctx context.Context, taskID, path string) ([]FileEntry, error)
- func (c *Client) ReadFile(ctx context.Context, taskID, path string) (string, error)
- func (c *Client) Search(ctx context.Context, taskID, pattern, fileGlob string) ([]SearchMatch, error)
- func (c *Client) WriteFile(ctx context.Context, taskID, path, content string) error
- type CommitResult
- type ExecResult
- type FileEntry
- type SearchMatch
- type WorktreeInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client communicates with the sandbox server via HTTP. All operations are scoped to a task ID that maps to a git worktree on the server side. In semteams this is typically the agent loop_id.
func NewClient ¶
NewClient creates a sandbox client pointing at baseURL. Returns nil if baseURL is empty, which callers treat as "sandbox disabled".
func (*Client) CreateWorktree ¶
CreateWorktree asks the sandbox server to create an isolated git worktree.
func (*Client) DeleteWorktree ¶
DeleteWorktree removes the worktree associated with taskID.
func (*Client) Exec ¶
func (c *Client) Exec(ctx context.Context, taskID, command string, timeoutMs int) (*ExecResult, error)
Exec runs command inside the taskID worktree with a server-side timeout of timeoutMs milliseconds.
func (*Client) GitStatus ¶
GitStatus returns the output of `git status --porcelain` inside the worktree.
type CommitResult ¶
type CommitResult struct {
Status string `json:"status"`
Hash string `json:"hash,omitempty"`
FilesChanged int `json:"files_changed,omitempty"`
}
CommitResult holds the outcome of a git commit inside the sandbox.
type ExecResult ¶
type ExecResult struct {
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
ExitCode int `json:"exit_code"`
TimedOut bool `json:"timed_out"`
Classification string `json:"classification,omitempty"`
}
ExecResult holds the outcome of a command executed inside the sandbox.
type FileEntry ¶
type FileEntry struct {
Name string `json:"name"`
IsDir bool `json:"is_dir"`
Size int64 `json:"size"`
}
FileEntry represents a single filesystem entry.
type SearchMatch ¶
type SearchMatch struct {
File string `json:"file"`
Line int `json:"line"`
Text string `json:"text"`
}
SearchMatch represents a single search result.
type WorktreeInfo ¶
type WorktreeInfo struct {
Status string `json:"status"`
Path string `json:"path"`
Branch string `json:"branch"`
}
WorktreeInfo describes a newly created isolated workspace.