sandbox

package
v1.0.0-beta.36 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

func NewClient(baseURL string) *Client

NewClient creates a sandbox client pointing at baseURL. Returns nil if baseURL is empty, which callers treat as "sandbox disabled".

func (*Client) CreateWorktree

func (c *Client) CreateWorktree(ctx context.Context, taskID string) (*WorktreeInfo, error)

CreateWorktree asks the sandbox server to create an isolated git worktree.

func (*Client) DeleteWorktree

func (c *Client) DeleteWorktree(ctx context.Context, taskID string) error

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) GitCommit

func (c *Client) GitCommit(ctx context.Context, taskID, message string) (*CommitResult, error)

GitCommit stages all changes and creates a commit.

func (*Client) GitDiff

func (c *Client) GitDiff(ctx context.Context, taskID string) (string, error)

GitDiff returns the output of `git diff` (staged + unstaged).

func (*Client) GitStatus

func (c *Client) GitStatus(ctx context.Context, taskID string) (string, error)

GitStatus returns the output of `git status --porcelain` inside the worktree.

func (*Client) Health

func (c *Client) Health(ctx context.Context) error

Health pings the sandbox server.

func (*Client) ListDir

func (c *Client) ListDir(ctx context.Context, taskID, path string) ([]FileEntry, error)

ListDir lists the entries in directory path inside the taskID worktree.

func (*Client) ReadFile

func (c *Client) ReadFile(ctx context.Context, taskID, path string) (string, error)

ReadFile returns the contents of path inside the taskID worktree.

func (*Client) Search

func (c *Client) Search(ctx context.Context, taskID, pattern, fileGlob string) ([]SearchMatch, error)

Search runs a regex search for pattern inside the taskID worktree.

func (*Client) WriteFile

func (c *Client) WriteFile(ctx context.Context, taskID, path, content string) error

WriteFile writes content to path inside the taskID 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.

Jump to

Keyboard shortcuts

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