api

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const MaxTerminalChunkSize = 64 * 1024

MaxTerminalChunkSize is the maximum size of a single TerminalOutput message. Larger PTY reads are split into multiple messages.

Variables

View Source
var ErrStreamClosed = errors.New("rpc stream closed")

Functions

This section is empty.

Types

type AgentEventEnvelope

type AgentEventEnvelope struct {
	SessionID string
	Event     agent.AgentEvent
}

type AgentEventReceiver

type AgentEventReceiver interface {
	Recv() (*AgentEventEnvelope, error)
	Close() error
}

func NewAgentEventReceiver

func NewAgentEventReceiver(ch <-chan *AgentEventEnvelope, closeFn func() error) AgentEventReceiver

type AgentEventSender

type AgentEventSender interface {
	Send(*AgentEventEnvelope) error
	Close() error
}

type AgentEventService

type AgentEventService interface {
	StreamAgentEvents(ctx context.Context, req *StreamAgentEventsRequest) (AgentEventReceiver, error)
}

type Capabilities

type Capabilities struct {
	Snapshots         bool
	Rollback          bool
	Pause             bool
	StreamingProgress bool
	TierRouting       bool
}

type ContentBlock

type ContentBlock struct {
	Type              string
	Text              string
	TextSignature     string
	Thinking          string
	ThinkingSignature string
	Redacted          bool
	ImageData         string
	ImageMimeType     string
	ToolCallID        string
	ToolCallName      string
	ToolCallArguments map[string]any
	ThoughtSignature  string
}

type CreateSessionRequest

type CreateSessionRequest struct {
	BaseSnapshot string
	SessionID    string
	Quota        int64
	Labels       map[string]string
}

type CreateSessionResponse

type CreateSessionResponse struct {
	Session            *Session
	ServerCapabilities Capabilities
}

type CreateSnapshotRequest

type CreateSnapshotRequest struct {
	SessionID string
	Name      string
}

type CreateSnapshotResponse

type CreateSnapshotResponse struct {
	SnapshotID string
	TurnNumber int
	SpaceUsed  int64
}

type DestroySessionRequest

type DestroySessionRequest struct {
	SessionID string
}

type DestroySessionResponse

type DestroySessionResponse struct{}

type ExecuteToolRequest

type ExecuteToolRequest struct {
	SessionID  string
	ToolCallID string
	ToolName   string
	Params     map[string]any
	Resources  *ResourceSpec
}

type ExecuteToolResponse

type ExecuteToolResponse struct {
	SessionID     string
	ToolCallID    string
	ToolName      string
	Content       string
	ContentBlocks []ContentBlock
	SnapshotID    string
	ExitCode      *int
	Tier          int
	Duration      time.Duration
}

type ExecuteToolStreamMessage

type ExecuteToolStreamMessage struct {
	Progress *ToolProgress
	Response *ExecuteToolResponse
}

type ExecuteToolStreamReceiver

type ExecuteToolStreamReceiver interface {
	Recv() (*ExecuteToolStreamMessage, error)
	Close() error
}

func NewExecuteToolStream

func NewExecuteToolStream(messages ...*ExecuteToolStreamMessage) ExecuteToolStreamReceiver

func NewExecuteToolStreamChannel

func NewExecuteToolStreamChannel(ch <-chan *ExecuteToolStreamMessage, closeFn func() error) ExecuteToolStreamReceiver

func NewExecuteToolStreamChannelWithErr

func NewExecuteToolStreamChannelWithErr(ch <-chan *ExecuteToolStreamMessage, errCh <-chan error, closeFn func() error) ExecuteToolStreamReceiver

type GetProcessStatusRequest

type GetProcessStatusRequest struct {
	SessionID string
	ProcessID string
}

type GetProcessStatusResponse

type GetProcessStatusResponse struct {
	Status   ProcessStatus
	ExitCode *int
}

type GetSessionRequest

type GetSessionRequest struct {
	SessionID string
}

type GetSessionResponse

type GetSessionResponse struct {
	Session *Session
}

type HealthCheckRequest

type HealthCheckRequest struct{}

type HealthCheckResponse

type HealthCheckResponse struct {
	Status       string
	PoolState    string
	SessionCount int
	ActiveTools  int
	Uptime       time.Duration
	Errors       []string
}

type KillProcessRequest

type KillProcessRequest struct {
	SessionID string
	ProcessID string
	Signal    int
}

type KillProcessResponse

type KillProcessResponse struct{}

type LaunchProcessRequest

type LaunchProcessRequest struct {
	SessionID  string
	Binary     string
	Args       []string
	Env        map[string]string
	ExposePort int
}

type LaunchProcessResponse

type LaunchProcessResponse struct {
	ProcessID string
	Address   string
	Status    ProcessStatus
}

type ListSnapshotsRequest

type ListSnapshotsRequest struct {
	SessionID string
}

type ListSnapshotsResponse

type ListSnapshotsResponse struct {
	Snapshots []Snapshot
}

type PauseSessionRequest

type PauseSessionRequest struct {
	SessionID string
}

type PauseSessionResponse

type PauseSessionResponse struct{}

type ProcessStatus

type ProcessStatus string
const (
	ProcessStatusStarting ProcessStatus = "starting"
	ProcessStatusRunning  ProcessStatus = "running"
	ProcessStatusExited   ProcessStatus = "exited"
)

type ResourceSpec

type ResourceSpec struct {
	CPUs  float64
	MemMB int
}

type ResumeSessionRequest

type ResumeSessionRequest struct {
	SessionID string
}

type ResumeSessionResponse

type ResumeSessionResponse struct{}

type RollbackSessionRequest

type RollbackSessionRequest struct {
	SessionID  string
	SnapshotID string
}

type RollbackSessionResponse

type RollbackSessionResponse struct{}

type SandboxService

Service interfaces used by client/server adapters.

type Session

type Session struct {
	ID         string
	State      string
	Mountpoint string
	TurnCount  int
	SnapCount  int
	Created    time.Time
	Labels     map[string]string
	SpaceUsed  int64
}

type Snapshot

type Snapshot struct {
	Name      string
	Dataset   string
	Used      int64
	Refer     int64
	CreatedAt time.Time
	Holds     int
}

type StreamAgentEventsRequest

type StreamAgentEventsRequest struct {
	SessionID string
}

Event streaming contracts.

type StreamTerminalRequest

type StreamTerminalRequest struct {
	SessionID string
}

StreamTerminalRequest is the initial attach request from a client.

type TerminalAttached

type TerminalAttached struct {
	Rows       int    `json:"rows"`
	Cols       int    `json:"cols"`
	Scrollback []byte `json:"scrollback,omitempty"`
}

TerminalAttached is sent after successful subscription, including current dimensions and scrollback history for replay.

type TerminalClientMessage

type TerminalClientMessage struct {
	Input  *TerminalInput  `json:"input,omitempty"`
	Resize *TerminalResize `json:"resize,omitempty"`
}

TerminalClientMessage is a message from the client to the terminal server.

type TerminalDetached

type TerminalDetached struct {
	Reason string `json:"reason"` // "session_ended", "kicked", "error"
}

TerminalDetached is sent when the session ends or the client is kicked.

type TerminalInput

type TerminalInput struct {
	Data []byte `json:"data"`
}

TerminalInput carries raw keystrokes from the client to the PTY.

type TerminalOutput

type TerminalOutput struct {
	Data []byte `json:"data"`
}

TerminalOutput carries raw PTY output (including ANSI sequences) to the client.

type TerminalResize

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

TerminalResize carries terminal dimension changes from the client.

type TerminalServerMessage

type TerminalServerMessage struct {
	Attached *TerminalAttached `json:"attached,omitempty"`
	Output   *TerminalOutput   `json:"output,omitempty"`
	Detached *TerminalDetached `json:"detached,omitempty"`
}

TerminalServerMessage is a message from the terminal server to the client.

type TerminalService

type TerminalService interface {
	StreamTerminal(ctx context.Context, req *StreamTerminalRequest) (TerminalStreamHandle, error)
}

TerminalService handles bidirectional terminal streaming. It is a separate service from SandboxService — terminal streaming targets browser debug UIs, while SandboxService targets the agent loop.

type TerminalStreamHandle

type TerminalStreamHandle interface {
	Send(*TerminalClientMessage) error
	Recv() (*TerminalServerMessage, error)
	Close() error
}

TerminalStreamHandle is the client-facing handle for a terminal stream. Callers use Send for input/resize and Recv for output/attached/detached.

func NewTerminalStreamHandle

func NewTerminalStreamHandle(
	toClient <-chan *TerminalServerMessage,
	fromClient chan<- *TerminalClientMessage,
	ctx context.Context,
	cancel context.CancelFunc,
) TerminalStreamHandle

NewTerminalStreamHandle creates a TerminalStreamHandle from channels. The ctx/cancel control the stream lifecycle: cancelling ctx causes the backing goroutines to exit, which closes toClient (triggering EOF on Recv).

type ToolProgress

type ToolProgress struct {
	Content string
	IsError bool
}

type TurnCompleteRequest

type TurnCompleteRequest struct {
	SessionID string
}

type TurnCompleteResponse

type TurnCompleteResponse struct {
	SnapshotID string
	TurnNumber int
	SpaceUsed  int64
}

Jump to

Keyboard shortcuts

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