Core SDK
Signatures and descriptions are generated from the published module's GoDoc.
import "github.com/abox-dev/sdk/packages/go-sdk"Package agentbox provides the official Go client for AgentBox sandboxes.
Create a client, start a sandbox, and run a command:
client, err := agentbox.NewClient()
if err != nil {
log.Fatal(err)
}
sandbox, err := client.Sandboxes.Create(ctx, nil)
if err != nil {
log.Fatal(err)
}
defer sandbox.Kill(context.Background())
result, err := sandbox.Commands.Run(ctx, "echo", &agentbox.CommandOptions{
Args: []string{"Hello from AgentBox"},
})Index
- Constants
- func IAMTokenPlaceholder(name string) (string, error)
- func IAMTokenPlaceholders(names ...string) (map[string]string, error)
- func ValidateIAMTokenName(name string) error
- func WaitForFile(path string) string
- func WaitForPort(port int) string
- func WaitForProcess(process string) string
- func WaitForTimeout(timeout time.Duration) string
- func WaitForURL(value string, status int) string
- type APIError
- type AptInstallOptions
- type AuthenticationError
- type BuildError
- type BuildLogEntry
- type BuildStatusReason
- type Client
- type ClientOption
- func WithAPIKey(apiKey string) ClientOption
- func WithAPIURL(value string) ClientOption
- func WithDebug(enabled bool) ClientOption
- func WithDomain(domain string) ClientOption
- func WithHTTPClient(client *http.Client) ClientOption
- func WithHeaders(headers http.Header) ClientOption
- func WithLogger(logger *slog.Logger) ClientOption
- func WithProxy(value string) ClientOption
- func WithRequestTimeout(timeout time.Duration) ClientOption
- func WithSandboxURL(value string) ClientOption
- type CommandExitError
- type CommandHandle
- func (handle *CommandHandle) CloseStdin(ctx context.Context) error
- func (handle *CommandHandle) Kill(ctx context.Context) error
- func (handle *CommandHandle) PID(ctx context.Context) (uint32, error)
- func (handle *CommandHandle) Wait(ctx context.Context) (CommandResult, error)
- func (handle *CommandHandle) Write(ctx context.Context, data []byte) (int, error)
- type CommandOptions
- type CommandResult
- type CommandService
- func (service *CommandService) Connect(ctx context.Context, pid uint32, tag string) (*CommandHandle, error)
- func (service *CommandService) Kill(ctx context.Context, pid uint32, tag string) error
- func (service *CommandService) List(ctx context.Context) ([]ProcessInfo, error)
- func (service *CommandService) Run(ctx context.Context, command string, options *CommandOptions) (CommandResult, error)
- func (service *CommandService) Start(ctx context.Context, command string, options *CommandOptions) (*CommandHandle, error)
- func (service *CommandService) Terminate(ctx context.Context, pid uint32, tag string) error
- type ConnectSandboxOptions
- type CopyOptions
- type CreateSandboxOptions
- type EntryInfo
- type FileEvent
- type FileNotFoundError
- type FileService
- func (service *FileService) Exists(ctx context.Context, path string) (bool, error)
- func (service *FileService) List(ctx context.Context, path string, depth uint32) ([]EntryInfo, error)
- func (service *FileService) MakeDir(ctx context.Context, path string) (*EntryInfo, error)
- func (service *FileService) Read(ctx context.Context, path, user string) (io.ReadCloser, error)
- func (service *FileService) ReadBytes(ctx context.Context, path, user string) ([]byte, error)
- func (service *FileService) ReadText(ctx context.Context, path, user string) (string, error)
- func (service *FileService) ReadTo(ctx context.Context, path, user string, writer io.Writer) (int64, error)
- func (service *FileService) Remove(ctx context.Context, path string) error
- func (service *FileService) Rename(ctx context.Context, source, destination string) (*EntryInfo, error)
- func (service *FileService) SignedReadURL(path, user string, expiration time.Time) (string, error)
- func (service *FileService) SignedWriteURL(path, user string, expiration time.Time) (string, error)
- func (service *FileService) Stat(ctx context.Context, path string) (*EntryInfo, error)
- func (service *FileService) Watch(ctx context.Context, path string, options *WatchOptions) (*WatchHandle, error)
- func (service *FileService) Write(ctx context.Context, path string, reader io.Reader, options *WriteFileOptions) (*EntryInfo, error)
- func (service *FileService) WriteBatch(ctx context.Context, files []WriteFile, user string) ([]EntryInfo, error)
- func (service *FileService) WriteBytes(ctx context.Context, path string, data []byte, options *WriteFileOptions) (*EntryInfo, error)
- func (service *FileService) WriteText(ctx context.Context, path, text string, options *WriteFileOptions) (*EntryInfo, error)
- type FileType
- type FileUploadError
- type ForkOptions
- type ForkResult
- type GitCloneOptions
- type InvalidArgumentError
- type ListSandboxOptions
- type ListedSandbox
- type MetricsOptions
- type NotEnoughSpaceError
- type PTYOptions
- type PTYService
- func (service *PTYService) Connect(ctx context.Context, pid uint32, tag string) (*CommandHandle, error)
- func (service *PTYService) Create(ctx context.Context, command string, options *PTYOptions) (*CommandHandle, error)
- func (service *PTYService) Input(ctx context.Context, handle *CommandHandle, data []byte) error
- func (service *PTYService) Kill(ctx context.Context, handle *CommandHandle) error
- func (service *PTYService) Resize(ctx context.Context, handle *CommandHandle, cols, rows uint32) error
- type PackageInstallOptions
- type Page
- type PauseOptions
- type ProcessInfo
- type RateLimitError
- type Sandbox
- func (sandbox *Sandbox) CreateSnapshot(ctx context.Context, name string) (*SnapshotInfo, error)
- func (sandbox *Sandbox) Fork(ctx context.Context, options *ForkOptions) ([]ForkResult, error)
- func (sandbox Sandbox) GoString() string
- func (sandbox *Sandbox) Host(port int) string
- func (sandbox *Sandbox) Info(ctx context.Context) (*SandboxInfo, error)
- func (sandbox *Sandbox) IsRunning(ctx context.Context) (bool, error)
- func (sandbox *Sandbox) KeepAlive(ctx context.Context, duration time.Duration) error
- func (sandbox *Sandbox) Kill(ctx context.Context) (bool, error)
- func (sandbox *Sandbox) Logs(ctx context.Context, options *SandboxLogOptions) (Page[SandboxLogEntry], error)
- func (sandbox *Sandbox) Metrics(ctx context.Context, options *MetricsOptions) ([]SandboxMetric, error)
- func (sandbox *Sandbox) Pause(ctx context.Context, options *PauseOptions) error
- func (sandbox *Sandbox) Request(ctx context.Context, port int, method, path string, body io.Reader, direct bool) (*http.Response, error)
- func (sandbox *Sandbox) RequestTimeout() time.Duration
- func (sandbox *Sandbox) RequestWithOptions(ctx context.Context, port int, method, path string, body io.Reader, options *SandboxRequestOptions) (*http.Response, error)
- func (sandbox *Sandbox) SetTimeout(ctx context.Context, timeout time.Duration) error
- func (sandbox Sandbox) String() string
- func (sandbox *Sandbox) UpdateNetwork(ctx context.Context, config SandboxNetworkConfig, allowInternetAccess *bool) error
- type SandboxError
- type SandboxIAM
- type SandboxIAMToken
- type SandboxIAMTokens
- type SandboxInfo
- type SandboxLifecycle
- type SandboxLogEntry
- type SandboxLogOptions
- type SandboxMetadata
- type SandboxMetric
- type SandboxNetworkConfig
- type SandboxNetworkRule
- type SandboxNetworkTransform
- type SandboxNotFoundError
- type SandboxRequestOptions
- type SandboxService
- func (service *SandboxService) Connect(ctx context.Context, id string, options *ConnectSandboxOptions) (*Sandbox, error)
- func (service *SandboxService) Create(ctx context.Context, options *CreateSandboxOptions) (*Sandbox, error)
- func (service *SandboxService) DeleteSnapshot(ctx context.Context, snapshotID string) (bool, error)
- func (service *SandboxService) Info(ctx context.Context, id string) (*SandboxInfo, error)
- func (service *SandboxService) Kill(ctx context.Context, id string) (bool, error)
- func (service *SandboxService) List(ctx context.Context, options *ListSandboxOptions) (Page[ListedSandbox], error)
- func (service *SandboxService) Logs(ctx context.Context, id string, options *SandboxLogOptions) (Page[SandboxLogEntry], error)
- func (service *SandboxService) Metrics(ctx context.Context, sandboxIDs ...string) (map[string]SandboxMetric, error)
- func (service *SandboxService) Snapshots(ctx context.Context, options *SnapshotListOptions) (Page[SnapshotInfo], error)
- type SandboxState
- type SnapshotInfo
- type SnapshotListOptions
- type TeamUser
- type TemplateBuild
- type TemplateBuildInfo
- type TemplateBuildOptions
- type TemplateBuildRef
- type TemplateBuildStatus
- type TemplateBuilder
- func NewTemplate(contextPath string, ignore ...string) *TemplateBuilder
- func (builder *TemplateBuilder) AptInstall(options AptInstallOptions, packages ...string) *TemplateBuilder
- func (builder *TemplateBuilder) BunInstall(options PackageInstallOptions, packages ...string) *TemplateBuilder
- func (builder *TemplateBuilder) Copy(source, destination string, options *CopyOptions) *TemplateBuilder
- func (builder *TemplateBuilder) Dockerfile() string
- func (builder *TemplateBuilder) Env(values map[string]string) *TemplateBuilder
- func (builder *TemplateBuilder) FromAWSRegistry(image, accessKeyID, secretAccessKey, region string) *TemplateBuilder
- func (builder *TemplateBuilder) FromAlpine(variant string) *TemplateBuilder
- func (builder *TemplateBuilder) FromArch(variant string) *TemplateBuilder
- func (builder *TemplateBuilder) FromBase() *TemplateBuilder
- func (builder *TemplateBuilder) FromBun(variant string) *TemplateBuilder
- func (builder *TemplateBuilder) FromDebian(variant string) *TemplateBuilder
- func (builder *TemplateBuilder) FromDockerfile(contentOrPath string) *TemplateBuilder
- func (builder *TemplateBuilder) FromFedora(variant string) *TemplateBuilder
- func (builder *TemplateBuilder) FromGCPRegistry(image, serviceAccountJSON string) *TemplateBuilder
- func (builder *TemplateBuilder) FromImage(image string) *TemplateBuilder
- func (builder *TemplateBuilder) FromNode(variant string) *TemplateBuilder
- func (builder *TemplateBuilder) FromPython(version string) *TemplateBuilder
- func (builder *TemplateBuilder) FromRegistry(image, username, password string) *TemplateBuilder
- func (builder *TemplateBuilder) FromTemplate(template string) *TemplateBuilder
- func (builder *TemplateBuilder) FromUbuntu(variant string) *TemplateBuilder
- func (builder *TemplateBuilder) GitClone(repository string, options *GitCloneOptions) *TemplateBuilder
- func (builder *TemplateBuilder) JSON() ([]byte, error)
- func (builder *TemplateBuilder) MakeDir(paths ...string) *TemplateBuilder
- func (builder *TemplateBuilder) NPMInstall(options PackageInstallOptions, packages ...string) *TemplateBuilder
- func (builder *TemplateBuilder) PipInstall(packages ...string) *TemplateBuilder
- func (builder *TemplateBuilder) Ready(command string) *TemplateBuilder
- func (builder *TemplateBuilder) Remove(paths ...string) *TemplateBuilder
- func (builder *TemplateBuilder) Rename(source, destination string) *TemplateBuilder
- func (builder *TemplateBuilder) Run(commands ...string) *TemplateBuilder
- func (builder *TemplateBuilder) RunAs(user string, commands ...string) *TemplateBuilder
- func (builder *TemplateBuilder) SkipCache() *TemplateBuilder
- func (builder *TemplateBuilder) Start(command, readyCommand string) *TemplateBuilder
- func (builder *TemplateBuilder) Symlink(source, destination string) *TemplateBuilder
- func (builder *TemplateBuilder) User(user string) *TemplateBuilder
- func (builder *TemplateBuilder) Workdir(path string) *TemplateBuilder
- type TemplateError
- type TemplateInfo
- type TemplateInfoOptions
- type TemplateListOptions
- type TemplateLogOptions
- type TemplateService
- func (service *TemplateService) AssignTags(ctx context.Context, target string, tags []string) (string, error)
- func (service *TemplateService) Build(ctx context.Context, builder *TemplateBuilder, name string, options *TemplateBuildOptions) (*TemplateBuildRef, error)
- func (service *TemplateService) BuildInBackground(ctx context.Context, builder *TemplateBuilder, name string, options *TemplateBuildOptions) (*TemplateBuildRef, error)
- func (service *TemplateService) BuildLogs(ctx context.Context, templateID, buildID string, options *TemplateLogOptions) (Page[BuildLogEntry], error)
- func (service *TemplateService) BuildStatus(ctx context.Context, templateID, buildID string, logsOffset int) (*TemplateBuildInfo, error)
- func (service *TemplateService) Delete(ctx context.Context, templateID string) error
- func (service *TemplateService) Exists(ctx context.Context, alias string) (bool, error)
- func (service *TemplateService) Info(ctx context.Context, templateID string, options *TemplateInfoOptions) (*TemplateWithBuilds, error)
- func (service *TemplateService) List(ctx context.Context, options *TemplateListOptions) (Page[TemplateInfo], error)
- func (service *TemplateService) RemoveTags(ctx context.Context, name string, tags []string) error
- func (service *TemplateService) SetPublic(ctx context.Context, templateID string, public bool) ([]string, error)
- func (service *TemplateService) Tags(ctx context.Context, templateID string) ([]TemplateTag, error)
- type TemplateStep
- type TemplateTag
- type TemplateWithBuilds
- type TimeoutError
- type WatchHandle
- type WatchOptions
- type WriteFile
- type WriteFileOptions
Constants
Version is the AgentBox SDK release version.
const Version = "0.1.4"func IAMTokenPlaceholder
func IAMTokenPlaceholder(name string) (string, error)IAMTokenPlaceholder returns the value the egress proxy replaces with a freshly minted workload token.
func IAMTokenPlaceholders
func IAMTokenPlaceholders(names ...string) (map[string]string, error)IAMTokenPlaceholders returns placeholders for the supplied registered names.
func ValidateIAMTokenName
func ValidateIAMTokenName(name string) errorValidateIAMTokenName verifies that name can be embedded in the workload-token placeholder grammar understood by the AgentBox egress proxy.
func WaitForFile
func WaitForFile(path string) stringWaitForFile returns a readiness command that waits for a filesystem path.
func WaitForPort
func WaitForPort(port int) stringWaitForPort returns a readiness command that waits for a listening port.
func WaitForProcess
func WaitForProcess(process string) stringWaitForProcess returns a readiness command that waits for a named process.
func WaitForTimeout
func WaitForTimeout(timeout time.Duration) stringWaitForTimeout waits a fixed duration before marking a service ready.
func WaitForURL
func WaitForURL(value string, status int) stringWaitForURL returns a readiness command that waits for an HTTP status.
type APIError
APIError describes a non-successful HTTP or Connect response.
type APIError struct {
StatusCode int
Code string
Message string
Cause error
}func (*APIError) Error
func (e *APIError) Error() stringError formats the AgentBox API failure.
func (*APIError) Unwrap
func (e *APIError) Unwrap() errorUnwrap returns the underlying request error, if any.
type AptInstallOptions
AptInstallOptions configures apt-get.
type AptInstallOptions struct{ NoInstallRecommends, FixMissing bool }type AuthenticationError
AuthenticationError reports missing or invalid credentials.
type AuthenticationError struct{ APIError }func (*AuthenticationError) Error
func (e *AuthenticationError) Error() stringError formats the authentication failure.
func (*AuthenticationError) Unwrap
func (e *AuthenticationError) Unwrap() errorUnwrap returns the underlying authentication error, if any.
type BuildError
BuildError reports a failed template build.
type BuildError struct{ APIError }func (*BuildError) Error
func (e *BuildError) Error() stringError formats the template build failure.
func (*BuildError) Unwrap
func (e *BuildError) Unwrap() errorUnwrap returns the underlying template build error, if any.
type BuildLogEntry
BuildLogEntry is one structured template build log record.
type BuildLogEntry struct {
ID *string `json:"id,omitzero"`
Level string `json:"level"`
Message string `json:"message"`
Step *string `json:"step,omitzero"`
Timestamp time.Time `json:"timestamp"`
}type BuildStatusReason
BuildStatusReason explains a terminal template build status.
type BuildStatusReason struct {
LogEntries *[]BuildLogEntry `json:"logEntries,omitzero"`
Message string `json:"message"`
Step *string `json:"step,omitzero"`
}type Client
Client is an AgentBox control-plane client.
type Client struct {
Sandboxes *SandboxService
Templates *TemplateService
// contains filtered or unexported fields
}Example
client, err := agentbox.NewClient()
if err != nil {
log.Fatal(err)
}
sandbox, err := client.Sandboxes.Create(context.Background(), nil)
if err != nil {
log.Fatal(err)
}
defer sandbox.Kill(context.Background())
_, _ = sandbox.Commands.Run(context.Background(), "echo", &agentbox.CommandOptions{Args: []string{"hello"}})func NewClient
func NewClient(options ...ClientOption) (*Client, error)NewClient creates a client. Configuration defaults to AGENTBOX_* environment variables and can be overridden with options.
type ClientOption
ClientOption configures a Client.
type ClientOption func(*clientConfig) errorfunc WithAPIKey
func WithAPIKey(apiKey string) ClientOptionWithAPIKey sets the AgentBox API key. By default AGENTBOX_API_KEY is used.
func WithAPIURL
func WithAPIURL(value string) ClientOptionWithAPIURL overrides the control-plane API URL.
func WithDebug
func WithDebug(enabled bool) ClientOptionWithDebug enables local envd routing.
func WithDomain
func WithDomain(domain string) ClientOptionWithDomain sets the AgentBox runtime domain.
func WithHTTPClient
func WithHTTPClient(client *http.Client) ClientOptionWithHTTPClient supplies the HTTP client used for every request. Its Timeout applies to complete streaming requests as well as unary requests; leave it at zero and use contexts or operation options for long-lived streams.
func WithHeaders
func WithHeaders(headers http.Header) ClientOptionWithHeaders adds headers to control-plane requests.
func WithLogger
func WithLogger(logger *slog.Logger) ClientOptionWithLogger enables structured request and lifecycle logging.
func WithProxy
func WithProxy(value string) ClientOptionWithProxy sets an HTTP or HTTPS proxy for SDK requests.
func WithRequestTimeout
func WithRequestTimeout(timeout time.Duration) ClientOptionWithRequestTimeout sets the default unary request timeout. Zero disables it.
func WithSandboxURL
func WithSandboxURL(value string) ClientOptionWithSandboxURL overrides the sandbox proxy URL.
type CommandExitError
CommandExitError reports a process that completed with a non-zero exit code.
type CommandExitError struct {
Result CommandResult
Message string
}func (*CommandExitError) Error
func (e *CommandExitError) Error() stringError describes the non-zero command exit code.
type CommandHandle
CommandHandle represents a streaming process. Wait can be called without draining the output channels and always returns the complete collected output.
type CommandHandle struct {
Stdout <-chan []byte
Stderr <-chan []byte
PTY <-chan []byte
Done <-chan struct{}
// contains filtered or unexported fields
}func (*CommandHandle) CloseStdin
func (handle *CommandHandle) CloseStdin(ctx context.Context) errorCloseStdin signals EOF to a non-PTY process.
func (*CommandHandle) Kill
func (handle *CommandHandle) Kill(ctx context.Context) errorKill sends SIGKILL to this process.
func (*CommandHandle) PID
func (handle *CommandHandle) PID(ctx context.Context) (uint32, error)PID waits for and returns the process identifier.
func (*CommandHandle) Wait
func (handle *CommandHandle) Wait(ctx context.Context) (CommandResult, error)Wait waits for completion and returns collected output.
func (*CommandHandle) Write
func (handle *CommandHandle) Write(ctx context.Context, data []byte) (int, error)Write writes bytes to process stdin.
type CommandOptions
CommandOptions configures a command process.
type CommandOptions struct {
Args []string
Env map[string]string
Cwd string
Tag string
Stdin bool
OnStdout func([]byte)
OnStderr func([]byte)
}type CommandResult
CommandResult contains collected process output.
type CommandResult struct {
PID uint32
ExitCode int
Stdout []byte
Stderr []byte
Status string
}type CommandService
CommandService executes and manages sandbox processes.
type CommandService struct {
// contains filtered or unexported fields
}func (*CommandService) Connect
func (service *CommandService) Connect(ctx context.Context, pid uint32, tag string) (*CommandHandle, error)Connect attaches to an existing process by PID or tag.
func (*CommandService) Kill
func (service *CommandService) Kill(ctx context.Context, pid uint32, tag string) errorKill sends SIGKILL to a process.
func (*CommandService) List
func (service *CommandService) List(ctx context.Context) ([]ProcessInfo, error)List returns currently running processes.
func (*CommandService) Run
func (service *CommandService) Run(ctx context.Context, command string, options *CommandOptions) (CommandResult, error)Run executes a foreground command and collects its output.
func (*CommandService) Start
func (service *CommandService) Start(ctx context.Context, command string, options *CommandOptions) (*CommandHandle, error)Start starts a process and streams output through the returned handle.
func (*CommandService) Terminate
func (service *CommandService) Terminate(ctx context.Context, pid uint32, tag string) errorTerminate sends SIGTERM to a process.
type ConnectSandboxOptions
ConnectSandboxOptions configures connecting or resuming a sandbox.
type ConnectSandboxOptions struct{ Timeout time.Duration }type CopyOptions
CopyOptions configures a COPY template layer.
type CopyOptions struct {
User string
Mode os.FileMode
ForceUpload bool
ResolveSymlinks bool
Gzip *bool
}type CreateSandboxOptions
CreateSandboxOptions configures a new sandbox.
type CreateSandboxOptions struct {
Template string
Timeout time.Duration
AutoPause *bool
AutoPauseMemory *bool
AutoResume *bool
Secure *bool
AllowInternetAccess *bool
Env map[string]string
Metadata map[string]string
Network *SandboxNetworkConfig
IAM *SandboxIAM
}type EntryInfo
EntryInfo describes a sandbox filesystem entry.
type EntryInfo struct {
Name string
Type FileType
Path string
Size int64
Mode uint32
Permissions string
Owner string
Group string
ModifiedAt time.Time
SymlinkTarget string
Metadata map[string]string
}type FileEvent
FileEvent describes a filesystem change.
type FileEvent struct {
Name string
Type string
Entry *EntryInfo
}type FileNotFoundError
FileNotFoundError reports a missing sandbox file.
type FileNotFoundError struct{ APIError }func (*FileNotFoundError) Error
func (e *FileNotFoundError) Error() stringError formats the missing-file failure.
func (*FileNotFoundError) Unwrap
func (e *FileNotFoundError) Unwrap() errorUnwrap returns the underlying missing-file error, if any.
type FileService
FileService reads and mutates sandbox files.
type FileService struct {
// contains filtered or unexported fields
}func (*FileService) Exists
func (service *FileService) Exists(ctx context.Context, path string) (bool, error)Exists reports whether path exists.
func (*FileService) List
func (service *FileService) List(ctx context.Context, path string, depth uint32) ([]EntryInfo, error)List lists path recursively up to depth.
func (*FileService) MakeDir
func (service *FileService) MakeDir(ctx context.Context, path string) (*EntryInfo, error)MakeDir creates a directory.
func (*FileService) Read
func (service *FileService) Read(ctx context.Context, path, user string) (io.ReadCloser, error)Read opens a streaming file response. The caller must close it.
func (*FileService) ReadBytes
func (service *FileService) ReadBytes(ctx context.Context, path, user string) ([]byte, error)ReadBytes reads a complete file.
func (*FileService) ReadText
func (service *FileService) ReadText(ctx context.Context, path, user string) (string, error)ReadText reads a UTF-8 file as a string.
func (*FileService) ReadTo
func (service *FileService) ReadTo(ctx context.Context, path, user string, writer io.Writer) (int64, error)ReadTo streams a file into writer.
func (*FileService) Remove
func (service *FileService) Remove(ctx context.Context, path string) errorRemove recursively removes a filesystem entry.
func (*FileService) Rename
func (service *FileService) Rename(ctx context.Context, source, destination string) (*EntryInfo, error)Rename moves a filesystem entry.
func (*FileService) SignedReadURL
func (service *FileService) SignedReadURL(path, user string, expiration time.Time) (string, error)SignedReadURL creates a directly usable download URL.
func (*FileService) SignedWriteURL
func (service *FileService) SignedWriteURL(path, user string, expiration time.Time) (string, error)SignedWriteURL creates a directly usable upload URL.
func (*FileService) Stat
func (service *FileService) Stat(ctx context.Context, path string) (*EntryInfo, error)Stat returns information about a path.
func (*FileService) Watch
func (service *FileService) Watch(ctx context.Context, path string, options *WatchOptions) (*WatchHandle, error)Watch watches a directory until context cancellation or Close.
func (*FileService) Write
func (service *FileService) Write(ctx context.Context, path string, reader io.Reader, options *WriteFileOptions) (*EntryInfo, error)Write uploads a file from reader.
func (*FileService) WriteBatch
func (service *FileService) WriteBatch(ctx context.Context, files []WriteFile, user string) ([]EntryInfo, error)WriteBatch writes files in order and stops at the first failure.
func (*FileService) WriteBytes
func (service *FileService) WriteBytes(ctx context.Context, path string, data []byte, options *WriteFileOptions) (*EntryInfo, error)WriteBytes uploads bytes.
func (*FileService) WriteText
func (service *FileService) WriteText(ctx context.Context, path, text string, options *WriteFileOptions) (*EntryInfo, error)WriteText uploads a string.
type FileType
FileType identifies a filesystem entry kind.
type FileType stringconst (
// FileTypeFile identifies a regular file.
FileTypeFile FileType = "file"
// FileTypeDirectory identifies a directory.
FileTypeDirectory FileType = "dir"
// FileTypeSymlink identifies a symbolic link.
FileTypeSymlink FileType = "symlink"
)type FileUploadError
FileUploadError reports a failed template file upload.
type FileUploadError struct{ APIError }func (*FileUploadError) Error
func (e *FileUploadError) Error() stringError formats the file upload failure.
func (*FileUploadError) Unwrap
func (e *FileUploadError) Unwrap() errorUnwrap returns the underlying file upload error, if any.
type ForkOptions
ForkOptions configures sandbox forks.
type ForkOptions struct {
Count int
Timeout time.Duration
}type ForkResult
ForkResult is one ordered fork outcome. Exactly one of Sandbox or Err is set.
type ForkResult struct {
Sandbox *Sandbox
Err error
}type GitCloneOptions
GitCloneOptions configures a git clone layer.
type GitCloneOptions struct {
Path, Branch, User string
Depth int
}type InvalidArgumentError
InvalidArgumentError reports invalid SDK input.
type InvalidArgumentError struct {
Message string
Cause error
}func (*InvalidArgumentError) Error
func (e *InvalidArgumentError) Error() stringError formats the invalid argument failure.
func (*InvalidArgumentError) Unwrap
func (e *InvalidArgumentError) Unwrap() errorUnwrap returns the underlying validation error, if any.
type ListSandboxOptions
ListSandboxOptions filters one sandbox list page.
type ListSandboxOptions struct {
Metadata map[string]string
States []SandboxState
NextToken string
Limit int
}type ListedSandbox
ListedSandbox is a compact sandbox list entry.
type ListedSandbox struct {
Alias *string `json:"alias,omitzero"`
CPUCount int32 `json:"cpuCount"`
DiskSizeMB int32 `json:"diskSizeMB"`
EndAt time.Time `json:"endAt"`
EnvdVersion string `json:"envdVersion"`
MemoryMB int32 `json:"memoryMB"`
Metadata *SandboxMetadata `json:"metadata,omitzero"`
SandboxID string `json:"sandboxID"`
StartedAt time.Time `json:"startedAt"`
State SandboxState `json:"state"`
TemplateID string `json:"templateID"`
}type MetricsOptions
MetricsOptions selects a metrics interval.
type MetricsOptions struct{ Start, End time.Time }type NotEnoughSpaceError
NotEnoughSpaceError reports exhausted sandbox storage.
type NotEnoughSpaceError struct{ APIError }func (*NotEnoughSpaceError) Error
func (e *NotEnoughSpaceError) Error() stringError formats the storage-capacity failure.
func (*NotEnoughSpaceError) Unwrap
func (e *NotEnoughSpaceError) Unwrap() errorUnwrap returns the underlying storage error, if any.
type PTYOptions
PTYOptions configures an interactive terminal.
type PTYOptions struct {
Args []string
Env map[string]string
Cwd string
Tag string
Cols uint32
Rows uint32
OnPTY func([]byte)
}type PTYService
PTYService manages pseudo-terminal processes.
type PTYService struct {
// contains filtered or unexported fields
}func (*PTYService) Connect
func (service *PTYService) Connect(ctx context.Context, pid uint32, tag string) (*CommandHandle, error)Connect attaches to an existing PTY process.
func (*PTYService) Create
func (service *PTYService) Create(ctx context.Context, command string, options *PTYOptions) (*CommandHandle, error)Create starts a process attached to a pseudo-terminal.
func (*PTYService) Input
func (service *PTYService) Input(ctx context.Context, handle *CommandHandle, data []byte) errorInput sends terminal input.
func (*PTYService) Kill
func (service *PTYService) Kill(ctx context.Context, handle *CommandHandle) errorKill stops the terminal process.
func (*PTYService) Resize
func (service *PTYService) Resize(ctx context.Context, handle *CommandHandle, cols, rows uint32) errorResize changes terminal dimensions.
type PackageInstallOptions
PackageInstallOptions configures npm/bun installs.
type PackageInstallOptions struct{ Global, Dev bool }type Page
Page contains one page and an optional opaque continuation token.
type Page[T any] struct {
Items []T
NextToken string
}type PauseOptions
PauseOptions configures snapshot behavior while pausing.
type PauseOptions struct{ Memory *bool }type ProcessInfo
ProcessInfo describes a running envd process.
type ProcessInfo struct {
PID uint32
Tag string
Command string
Args []string
Env map[string]string
Cwd string
}type RateLimitError
RateLimitError reports an exhausted API quota.
type RateLimitError struct{ APIError }func (*RateLimitError) Error
func (e *RateLimitError) Error() stringError formats the rate-limit failure.
func (*RateLimitError) Unwrap
func (e *RateLimitError) Unwrap() errorUnwrap returns the underlying rate-limit error, if any.
type Sandbox
Sandbox is a connected AgentBox sandbox.
type Sandbox struct {
ID string
TemplateID string
Alias string
Domain string
EnvdVersion string
Commands *CommandService
PTY *PTYService
Files *FileService
// contains filtered or unexported fields
}func (*Sandbox) CreateSnapshot
func (sandbox *Sandbox) CreateSnapshot(ctx context.Context, name string) (*SnapshotInfo, error)CreateSnapshot stores this sandbox as a template snapshot.
func (*Sandbox) Fork
func (sandbox *Sandbox) Fork(ctx context.Context, options *ForkOptions) ([]ForkResult, error)Fork creates one or more sandboxes from this sandbox's current state.
func (Sandbox) GoString
func (sandbox Sandbox) GoString() stringGoString returns a credential-free sandbox description for %#v formatting.
func (*Sandbox) Host
func (sandbox *Sandbox) Host(port int) stringHost returns the public hostname for a port exposed by the sandbox.
func (*Sandbox) Info
func (sandbox *Sandbox) Info(ctx context.Context) (*SandboxInfo, error)Info returns information about this sandbox.
func (*Sandbox) IsRunning
func (sandbox *Sandbox) IsRunning(ctx context.Context) (bool, error)IsRunning reports whether envd is reachable. A 502 response means the sandbox is no longer running.
func (*Sandbox) KeepAlive
func (sandbox *Sandbox) KeepAlive(ctx context.Context, duration time.Duration) errorKeepAlive extends the sandbox lifetime. A zero duration uses the server default.
func (*Sandbox) Kill
func (sandbox *Sandbox) Kill(ctx context.Context) (bool, error)Kill permanently stops this sandbox. It returns false when it was not found.
func (*Sandbox) Logs
func (sandbox *Sandbox) Logs(ctx context.Context, options *SandboxLogOptions) (Page[SandboxLogEntry], error)Logs returns one page of sandbox logs.
func (*Sandbox) Metrics
func (sandbox *Sandbox) Metrics(ctx context.Context, options *MetricsOptions) ([]SandboxMetric, error)Metrics returns sandbox metrics for the requested interval.
func (*Sandbox) Pause
func (sandbox *Sandbox) Pause(ctx context.Context, options *PauseOptions) errorPause pauses the sandbox, optionally retaining memory.
func (*Sandbox) Request
func (sandbox *Sandbox) Request(ctx context.Context, port int, method, path string, body io.Reader, direct bool) (*http.Response, error)Request performs an authenticated request against a service inside the sandbox. Direct bypasses the stable proxy hostname while retaining AgentBox routing headers.
func (*Sandbox) RequestTimeout
func (sandbox *Sandbox) RequestTimeout() time.DurationRequestTimeout returns the default unary request timeout configured on the client.
func (*Sandbox) RequestWithOptions
func (sandbox *Sandbox) RequestWithOptions(ctx context.Context, port int, method, path string, body io.Reader, options *SandboxRequestOptions) (*http.Response, error)RequestWithOptions performs an authenticated request with custom headers.
func (*Sandbox) SetTimeout
func (sandbox *Sandbox) SetTimeout(ctx context.Context, timeout time.Duration) errorSetTimeout changes the sandbox expiration timeout from now.
func (Sandbox) String
func (sandbox Sandbox) String() stringString returns a credential-free sandbox description.
func (*Sandbox) UpdateNetwork
func (sandbox *Sandbox) UpdateNetwork(ctx context.Context, config SandboxNetworkConfig, allowInternetAccess *bool) errorUpdateNetwork atomically replaces sandbox egress rules.
type SandboxError
SandboxError is the base error for sandbox operations.
type SandboxError struct{ APIError }func (*SandboxError) Error
func (e *SandboxError) Error() stringError formats the sandbox operation failure.
func (*SandboxError) Unwrap
func (e *SandboxError) Unwrap() errorUnwrap returns the underlying sandbox operation error, if any.
type SandboxIAM
SandboxIAM configures workload identity tokens.
type SandboxIAM struct {
Tokens *SandboxIAMTokens `json:"tokens,omitzero"`
}type SandboxIAMToken
SandboxIAMToken configures one workload identity token.
type SandboxIAMToken struct {
Audience string `json:"audience"`
TokenType string `json:"tokenType"`
}type SandboxIAMTokens
SandboxIAMTokens contains named workload identity token definitions.
type SandboxIAMTokens map[string]SandboxIAMTokentype SandboxInfo
SandboxInfo contains current sandbox state and configuration.
type SandboxInfo struct {
Alias *string `json:"alias,omitzero"`
AllowInternetAccess *bool `json:"allowInternetAccess,omitzero"`
CPUCount int32 `json:"cpuCount"`
DiskSizeMB int32 `json:"diskSizeMB"`
Domain *string `json:"domain,omitzero"`
EndAt time.Time `json:"endAt"`
EnvdVersion string `json:"envdVersion"`
Lifecycle *SandboxLifecycle `json:"lifecycle,omitzero"`
MemoryMB int32 `json:"memoryMB"`
Metadata *SandboxMetadata `json:"metadata,omitzero"`
Network *SandboxNetworkConfig `json:"network,omitzero"`
SandboxID string `json:"sandboxID"`
StartedAt time.Time `json:"startedAt"`
State SandboxState `json:"state"`
TemplateID string `json:"templateID"`
}type SandboxLifecycle
SandboxLifecycle describes timeout and auto-resume behavior.
type SandboxLifecycle struct {
AutoResume bool `json:"autoResume"`
OnTimeout string `json:"onTimeout"`
}type SandboxLogEntry
SandboxLogEntry is one structured sandbox log record.
type SandboxLogEntry struct {
Fields map[string]string `json:"fields"`
ID *string `json:"id,omitzero"`
Level string `json:"level"`
Message string `json:"message"`
Timestamp time.Time `json:"timestamp"`
}type SandboxLogOptions
SandboxLogOptions filters one page of sandbox logs.
type SandboxLogOptions struct {
Cursor string
Timestamp int64
Limit int
Direction string
Level string
Search string
}type SandboxMetadata
SandboxMetadata contains user-defined sandbox metadata.
type SandboxMetadata map[string]stringtype SandboxMetric
SandboxMetric is one timestamped resource-usage sample.
type SandboxMetric struct {
CPUCount int32 `json:"cpuCount"`
CPUUsedPct float32 `json:"cpuUsedPct"`
DiskTotal int64 `json:"diskTotal"`
DiskUsed int64 `json:"diskUsed"`
MemCache int64 `json:"memCache"`
MemTotal int64 `json:"memTotal"`
MemUsed int64 `json:"memUsed"`
TimestampUnix int64 `json:"timestampUnix"`
}type SandboxNetworkConfig
SandboxNetworkConfig configures sandbox egress and public traffic.
type SandboxNetworkConfig struct {
AllowOut *[]string `json:"allowOut,omitzero"`
AllowPublicTraffic *bool `json:"allowPublicTraffic,omitzero"`
DenyOut *[]string `json:"denyOut,omitzero"`
MaskRequestHost *string `json:"maskRequestHost,omitzero"`
Rules *map[string][]SandboxNetworkRule `json:"rules,omitzero"`
}type SandboxNetworkRule
SandboxNetworkRule applies request transformations to matching traffic.
type SandboxNetworkRule struct {
Transform *SandboxNetworkTransform `json:"transform,omitzero"`
}type SandboxNetworkTransform
SandboxNetworkTransform describes headers injected into matching requests.
type SandboxNetworkTransform struct {
Headers *map[string]string `json:"headers,omitzero"`
}type SandboxNotFoundError
SandboxNotFoundError reports a missing or expired sandbox.
type SandboxNotFoundError struct{ APIError }func (*SandboxNotFoundError) Error
func (e *SandboxNotFoundError) Error() stringError formats the missing-sandbox failure.
func (*SandboxNotFoundError) Unwrap
func (e *SandboxNotFoundError) Unwrap() errorUnwrap returns the underlying missing-sandbox error, if any.
type SandboxRequestOptions
SandboxRequestOptions configures a request to a service inside a sandbox.
type SandboxRequestOptions struct {
Direct bool
Headers http.Header
ContentType string
}type SandboxService
SandboxService manages sandboxes owned by a client.
type SandboxService struct {
// contains filtered or unexported fields
}func (*SandboxService) Connect
func (service *SandboxService) Connect(ctx context.Context, id string, options *ConnectSandboxOptions) (*Sandbox, error)Connect connects to or resumes a sandbox.
func (*SandboxService) Create
func (service *SandboxService) Create(ctx context.Context, options *CreateSandboxOptions) (*Sandbox, error)Create starts and connects to a sandbox.
func (*SandboxService) DeleteSnapshot
func (service *SandboxService) DeleteSnapshot(ctx context.Context, snapshotID string) (bool, error)DeleteSnapshot deletes a snapshot. It returns false when it did not exist.
func (*SandboxService) Info
func (service *SandboxService) Info(ctx context.Context, id string) (*SandboxInfo, error)Info returns current sandbox state and configuration.
func (*SandboxService) Kill
func (service *SandboxService) Kill(ctx context.Context, id string) (bool, error)Kill permanently stops a sandbox. It returns false when it did not exist.
func (*SandboxService) List
func (service *SandboxService) List(ctx context.Context, options *ListSandboxOptions) (Page[ListedSandbox], error)List returns one list page. The continuation token is read from X-Next-Token.
func (*SandboxService) Logs
func (service *SandboxService) Logs(ctx context.Context, id string, options *SandboxLogOptions) (Page[SandboxLogEntry], error)Logs returns one page of structured sandbox logs.
func (*SandboxService) Metrics
func (service *SandboxService) Metrics(ctx context.Context, sandboxIDs ...string) (map[string]SandboxMetric, error)Metrics returns the latest metrics for the requested sandbox IDs.
func (*SandboxService) Snapshots
func (service *SandboxService) Snapshots(ctx context.Context, options *SnapshotListOptions) (Page[SnapshotInfo], error)Snapshots returns one page of snapshots.
type SandboxState
SandboxState is the lifecycle state of a sandbox.
type SandboxState stringconst (
// SandboxRunning indicates that a sandbox accepts requests.
SandboxRunning SandboxState = "running"
// SandboxPaused indicates that a sandbox is suspended.
SandboxPaused SandboxState = "paused"
)type SnapshotInfo
SnapshotInfo identifies a saved sandbox snapshot.
type SnapshotInfo struct {
Names []string `json:"names"`
SnapshotID string `json:"snapshotID"`
}type SnapshotListOptions
SnapshotListOptions filters and paginates snapshots.
type SnapshotListOptions struct {
SandboxID string
Name string
NextToken string
Limit int
}type TeamUser
TeamUser identifies the user who created a template.
type TeamUser struct {
ID string `json:"id"`
}type TemplateBuild
TemplateBuild describes one historical template build.
type TemplateBuild struct {
BuildID string `json:"buildID"`
CPUCount int32 `json:"cpuCount"`
CreatedAt time.Time `json:"createdAt"`
DiskSizeMB *int32 `json:"diskSizeMB,omitzero"`
EnvdVersion *string `json:"envdVersion,omitzero"`
FinishedAt *time.Time `json:"finishedAt,omitzero"`
MemoryMB int32 `json:"memoryMB"`
Status TemplateBuildStatus `json:"status"`
UpdatedAt time.Time `json:"updatedAt"`
}type TemplateBuildInfo
TemplateBuildInfo contains the latest status and logs for a build.
type TemplateBuildInfo struct {
BuildID string `json:"buildID"`
LogEntries []BuildLogEntry `json:"logEntries"`
Logs []string `json:"logs"`
Reason *BuildStatusReason `json:"reason,omitzero"`
Status TemplateBuildStatus `json:"status"`
TemplateID string `json:"templateID"`
}type TemplateBuildOptions
TemplateBuildOptions configures resources, tags, caching, and build polling.
type TemplateBuildOptions struct {
Tags []string
CPUCount, MemoryMB int
SkipCache bool
PollInterval time.Duration
OnLog func(BuildLogEntry)
}type TemplateBuildRef
TemplateBuildRef identifies a started template build.
type TemplateBuildRef struct {
Name string
Tags []string
TemplateID, BuildID string
}type TemplateBuildStatus
TemplateBuildStatus is a template build state.
type TemplateBuildStatus stringconst (
// BuildWaiting indicates that a template build is queued.
BuildWaiting TemplateBuildStatus = "waiting"
// BuildBuilding indicates that a template build is in progress.
BuildBuilding TemplateBuildStatus = "building"
// BuildReady indicates that a template build completed successfully.
BuildReady TemplateBuildStatus = "ready"
// BuildFailed indicates that a template build failed.
BuildFailed TemplateBuildStatus = "error"
)type TemplateBuilder
TemplateBuilder builds a declarative template definition.
type TemplateBuilder struct {
// contains filtered or unexported fields
}Example
template := agentbox.NewTemplate(".").FromPython("3.13").Copy("requirements.txt", "/app/", nil).PipInstall().Workdir("/app")
_, _ = template.JSON()func NewTemplate
func NewTemplate(contextPath string, ignore ...string) *TemplateBuilderNewTemplate starts a template definition. Empty contextPath uses the current directory.
func (*TemplateBuilder) AptInstall
func (builder *TemplateBuilder) AptInstall(options AptInstallOptions, packages ...string) *TemplateBuilderAptInstall installs Debian packages as root.
func (*TemplateBuilder) BunInstall
func (builder *TemplateBuilder) BunInstall(options PackageInstallOptions, packages ...string) *TemplateBuilderBunInstall installs Bun packages with the requested scope.
func (*TemplateBuilder) Copy
func (builder *TemplateBuilder) Copy(source, destination string, options *CopyOptions) *TemplateBuilderCopy adds a file or directory from the context.
func (*TemplateBuilder) Dockerfile
func (builder *TemplateBuilder) Dockerfile() stringDockerfile returns a human-readable equivalent definition.
func (*TemplateBuilder) Env
func (builder *TemplateBuilder) Env(values map[string]string) *TemplateBuilderEnv sets environment variables for subsequent template steps.
func (*TemplateBuilder) FromAWSRegistry
func (builder *TemplateBuilder) FromAWSRegistry(image, accessKeyID, secretAccessKey, region string) *TemplateBuilderFromAWSRegistry selects an AWS ECR image.
func (*TemplateBuilder) FromAlpine
func (builder *TemplateBuilder) FromAlpine(variant string) *TemplateBuilderFromAlpine selects an official Alpine image, defaulting to version 3.24.
func (*TemplateBuilder) FromArch
func (builder *TemplateBuilder) FromArch(variant string) *TemplateBuilderFromArch selects an official Arch Linux image.
func (*TemplateBuilder) FromBase
func (builder *TemplateBuilder) FromBase() *TemplateBuilderFromBase selects the default AgentBox base image.
func (*TemplateBuilder) FromBun
func (builder *TemplateBuilder) FromBun(variant string) *TemplateBuilderFromBun selects an official Bun image.
func (*TemplateBuilder) FromDebian
func (builder *TemplateBuilder) FromDebian(variant string) *TemplateBuilderFromDebian selects an official Debian image, defaulting to stable.
func (*TemplateBuilder) FromDockerfile
func (builder *TemplateBuilder) FromDockerfile(contentOrPath string) *TemplateBuilderFromDockerfile parses common FROM/RUN/COPY/ENV/WORKDIR/USER directives.
func (*TemplateBuilder) FromFedora
func (builder *TemplateBuilder) FromFedora(variant string) *TemplateBuilderFromFedora selects an official Fedora image, defaulting to version 44.
func (*TemplateBuilder) FromGCPRegistry
func (builder *TemplateBuilder) FromGCPRegistry(image, serviceAccountJSON string) *TemplateBuilderFromGCPRegistry selects a GCP Artifact Registry image.
func (*TemplateBuilder) FromImage
func (builder *TemplateBuilder) FromImage(image string) *TemplateBuilderFromImage selects an OCI image.
func (*TemplateBuilder) FromNode
func (builder *TemplateBuilder) FromNode(variant string) *TemplateBuilderFromNode selects an official Node.js image, defaulting to the LTS variant.
func (*TemplateBuilder) FromPython
func (builder *TemplateBuilder) FromPython(version string) *TemplateBuilderFromPython selects an official Python image.
func (*TemplateBuilder) FromRegistry
func (builder *TemplateBuilder) FromRegistry(image, username, password string) *TemplateBuilderFromRegistry selects a password-authenticated OCI registry image.
func (*TemplateBuilder) FromTemplate
func (builder *TemplateBuilder) FromTemplate(template string) *TemplateBuilderFromTemplate selects another AgentBox template.
func (*TemplateBuilder) FromUbuntu
func (builder *TemplateBuilder) FromUbuntu(variant string) *TemplateBuilderFromUbuntu selects an official Ubuntu image, defaulting to latest.
func (*TemplateBuilder) GitClone
func (builder *TemplateBuilder) GitClone(repository string, options *GitCloneOptions) *TemplateBuilderGitClone clones a Git repository into the template filesystem.
func (*TemplateBuilder) JSON
func (builder *TemplateBuilder) JSON() ([]byte, error)JSON returns the build request representation without computed copy hashes.
func (*TemplateBuilder) MakeDir
func (builder *TemplateBuilder) MakeDir(paths ...string) *TemplateBuilderMakeDir creates directories and their missing parents.
func (*TemplateBuilder) NPMInstall
func (builder *TemplateBuilder) NPMInstall(options PackageInstallOptions, packages ...string) *TemplateBuilderNPMInstall installs npm packages with the requested scope.
func (*TemplateBuilder) PipInstall
func (builder *TemplateBuilder) PipInstall(packages ...string) *TemplateBuilderPipInstall installs Python packages as root.
func (*TemplateBuilder) Ready
func (builder *TemplateBuilder) Ready(command string) *TemplateBuilderReady replaces the readiness command for the template.
func (*TemplateBuilder) Remove
func (builder *TemplateBuilder) Remove(paths ...string) *TemplateBuilderRemove recursively removes paths from the template filesystem.
func (*TemplateBuilder) Rename
func (builder *TemplateBuilder) Rename(source, destination string) *TemplateBuilderRename moves a path in the template filesystem.
func (*TemplateBuilder) Run
func (builder *TemplateBuilder) Run(commands ...string) *TemplateBuilderRun adds shell commands executed as the current build user.
func (*TemplateBuilder) RunAs
func (builder *TemplateBuilder) RunAs(user string, commands ...string) *TemplateBuilderRunAs adds shell commands executed as user. An empty user inherits the current build user, as Run does.
func (*TemplateBuilder) SkipCache
func (builder *TemplateBuilder) SkipCache() *TemplateBuilderSkipCache forces this and all subsequent layers.
func (*TemplateBuilder) Start
func (builder *TemplateBuilder) Start(command, readyCommand string) *TemplateBuilderStart configures the sandbox start command and readiness command.
func (*TemplateBuilder) Symlink
func (builder *TemplateBuilder) Symlink(source, destination string) *TemplateBuilderSymlink creates a symbolic link.
func (*TemplateBuilder) User
func (builder *TemplateBuilder) User(user string) *TemplateBuilderUser sets the user for subsequent template steps.
func (*TemplateBuilder) Workdir
func (builder *TemplateBuilder) Workdir(path string) *TemplateBuilderWorkdir sets the working directory for subsequent template steps.
type TemplateError
TemplateError reports an invalid or incompatible template.
type TemplateError struct{ APIError }func (*TemplateError) Error
func (e *TemplateError) Error() stringError formats the template operation failure.
func (*TemplateError) Unwrap
func (e *TemplateError) Unwrap() errorUnwrap returns the underlying template operation error, if any.
type TemplateInfo
TemplateInfo is a compact template list entry.
type TemplateInfo struct {
BuildCount int32 `json:"buildCount"`
BuildID string `json:"buildID"`
BuildStatus TemplateBuildStatus `json:"buildStatus"`
CPUCount int32 `json:"cpuCount"`
CreatedAt time.Time `json:"createdAt"`
CreatedBy *TeamUser `json:"createdBy,omitzero"`
DiskSizeMB int32 `json:"diskSizeMB"`
EnvdVersion string `json:"envdVersion"`
LastSpawnedAt *time.Time `json:"lastSpawnedAt,omitzero"`
MemoryMB int32 `json:"memoryMB"`
Names []string `json:"names"`
Public bool `json:"public"`
SpawnCount int64 `json:"spawnCount"`
TemplateID string `json:"templateID"`
UpdatedAt time.Time `json:"updatedAt"`
}type TemplateInfoOptions
TemplateInfoOptions paginates a template's build history.
type TemplateInfoOptions struct {
NextToken string
Limit int
}type TemplateListOptions
TemplateListOptions configures template pagination and team filtering.
type TemplateListOptions struct {
TeamID, NextToken string
Limit int
}type TemplateLogOptions
TemplateLogOptions configures template log pagination and filtering.
type TemplateLogOptions struct {
Cursor string
Timestamp int64
Limit int
Direction, Level, Source string
}type TemplateService
TemplateService manages AgentBox templates.
type TemplateService struct {
// contains filtered or unexported fields
}func (*TemplateService) AssignTags
func (service *TemplateService) AssignTags(ctx context.Context, target string, tags []string) (string, error)AssignTags assigns tags to a template target and returns the selected build ID.
func (*TemplateService) Build
func (service *TemplateService) Build(ctx context.Context, builder *TemplateBuilder, name string, options *TemplateBuildOptions) (*TemplateBuildRef, error)Build starts a build and waits for a terminal state.
func (*TemplateService) BuildInBackground
func (service *TemplateService) BuildInBackground(ctx context.Context, builder *TemplateBuilder, name string, options *TemplateBuildOptions) (*TemplateBuildRef, error)BuildInBackground uploads COPY contexts and starts a build.
func (*TemplateService) BuildLogs
func (service *TemplateService) BuildLogs(ctx context.Context, templateID, buildID string, options *TemplateLogOptions) (Page[BuildLogEntry], error)BuildLogs returns one page of structured build logs.
func (*TemplateService) BuildStatus
func (service *TemplateService) BuildStatus(ctx context.Context, templateID, buildID string, logsOffset int) (*TemplateBuildInfo, error)BuildStatus returns the current build state and logs after logsOffset.
func (*TemplateService) Delete
func (service *TemplateService) Delete(ctx context.Context, templateID string) errorDelete removes a template.
func (*TemplateService) Exists
func (service *TemplateService) Exists(ctx context.Context, alias string) (bool, error)Exists reports whether a template alias exists or is reserved.
func (*TemplateService) Info
func (service *TemplateService) Info(ctx context.Context, templateID string, options *TemplateInfoOptions) (*TemplateWithBuilds, error)Info returns a template and its build history.
func (*TemplateService) List
func (service *TemplateService) List(ctx context.Context, options *TemplateListOptions) (Page[TemplateInfo], error)List returns one template page.
func (*TemplateService) RemoveTags
func (service *TemplateService) RemoveTags(ctx context.Context, name string, tags []string) errorRemoveTags removes tags from a named template.
func (*TemplateService) SetPublic
func (service *TemplateService) SetPublic(ctx context.Context, templateID string, public bool) ([]string, error)SetPublic changes template visibility and returns its names.
func (*TemplateService) Tags
func (service *TemplateService) Tags(ctx context.Context, templateID string) ([]TemplateTag, error)Tags lists tags assigned to a template.
type TemplateStep
TemplateStep is one layer in a template build.
type TemplateStep struct {
Type string `json:"type"`
Args []string `json:"args"`
Force bool `json:"force"`
FilesHash string `json:"filesHash,omitempty"`
ForceUpload bool `json:"forceUpload,omitempty"`
ResolveSymlinks bool `json:"resolveSymlinks,omitempty"`
Gzip bool `json:"gzip,omitempty"`
}type TemplateTag
TemplateTag associates a template tag with a build.
type TemplateTag struct {
Tag, BuildID string
CreatedAt time.Time
}type TemplateWithBuilds
TemplateWithBuilds contains a template and its build history.
type TemplateWithBuilds struct {
Builds []TemplateBuild `json:"builds"`
CreatedAt time.Time `json:"createdAt"`
LastSpawnedAt *time.Time `json:"lastSpawnedAt,omitzero"`
Names []string `json:"names"`
Public bool `json:"public"`
SpawnCount int64 `json:"spawnCount"`
TemplateID string `json:"templateID"`
UpdatedAt time.Time `json:"updatedAt"`
}type TimeoutError
TimeoutError reports a request, execution, or sandbox timeout.
type TimeoutError struct{ APIError }func (*TimeoutError) Error
func (e *TimeoutError) Error() stringError formats the timeout failure.
func (*TimeoutError) Unwrap
func (e *TimeoutError) Unwrap() errorUnwrap returns the underlying timeout error, if any.
type WatchHandle
WatchHandle owns a directory watch stream.
type WatchHandle struct {
Events <-chan FileEvent
// contains filtered or unexported fields
}func (*WatchHandle) Close
func (handle *WatchHandle) Close() errorClose stops the watcher.
type WatchOptions
WatchOptions configures recursive and enriched filesystem events.
type WatchOptions struct{ Recursive, IncludeEntry, AllowNetworkMounts bool }type WriteFile
WriteFile describes one batch upload.
type WriteFile struct {
Path string
Data io.Reader
Metadata map[string]string
}type WriteFileOptions
WriteFileOptions configures file ownership, metadata, and upload timeout.
type WriteFileOptions struct {
User string
Metadata map[string]string
// RequestTimeout limits the complete streaming upload. Zero leaves the
// upload bounded only by ctx and a custom HTTP client timeout.
RequestTimeout time.Duration
}Generated by gomarkdoc