workspaceexec

package
v0.1.57 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 24 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 workspaceexec implements the native execution surface of a workspace. Transport and UI clients do not need OS-specific file or resource shell scripts.

Index

Constants

View Source
const MaxFileBytes = 4 << 20
View Source
const TerminalVersion = 1
View Source
const Version = 1

Variables

View Source
var ErrTerminalInputInterrupted = errors.New("terminal input interrupted before delivery")

No PTY bytes or receipt were written: replaying this same input is safe.

Functions

func Executable

func Executable(name string) (string, error)

Types

type Content

type Content struct {
	Path    string `json:"path"`
	Content string `json:"content"`
	Size    int    `json:"size"`
}

type ExecRequest

type ExecRequest struct {
	Argv      []string `json:"argv"`
	Directory string   `json:"directory,omitempty"`
	Input     string   `json:"input,omitempty"`
	TimeoutMS int      `json:"timeoutMs,omitempty"`
}

type ExecResult

type ExecResult struct {
	Stdout    string `json:"stdout"`
	Stderr    string `json:"stderr"`
	ExitCode  int    `json:"exitCode"`
	Truncated bool   `json:"truncated,omitempty"`
}

type File

type File struct {
	Name       string `json:"name"`
	Path       string `json:"path"`
	Type       string `json:"type"`
	Size       int64  `json:"size"`
	ModifiedAt string `json:"modifiedAt"`
	Ignored    bool   `json:"isIgnored"`
}

type Info

type Info struct {
	Hostname  string `json:"hostname"`
	OS        string `json:"os"`
	Arch      string `json:"arch"`
	Home      string `json:"home"`
	Directory string `json:"directory"`
	PID       int    `json:"pid"`
}

type Resources

type Resources struct {
	CPUs     int    `json:"cpus"`
	MemoryMB uint64 `json:"memoryMb"`
	DiskMB   uint64 `json:"diskMb"`
}

type Service

type Service struct {
	Root string

	Terminals *Terminals
	// contains filtered or unexported fields
}

func New

func New(root string) *Service

func (*Service) BusyPath

func (s *Service) BusyPath(path string) bool

func (*Service) Delete

func (s *Service) Delete(path string) error

func (*Service) Exec

func (s *Service) Exec(ctx context.Context, req ExecRequest, output func(string, []byte)) (ExecResult, error)

func (*Service) Files

func (s *Service) Files(ctx context.Context, path, query string) ([]File, error)

func (*Service) Info

func (s *Service) Info() Info

func (*Service) Path

func (s *Service) Path(path string) (string, error)

func (*Service) Read

func (s *Service) Read(path string) (Content, error)

func (*Service) Resources

func (s *Service) Resources(ctx context.Context) (Resources, error)

func (*Service) SetMutationGuard

func (s *Service) SetMutationGuard(gate *sync.Mutex, check func(string) error)

SetMutationGuard shares admission with turns and project transactions. Configure it before serving requests; the release lasts until a command/terminal exits.

func (*Service) Write

func (s *Service) Write(path, content string) error

type Terminal

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

func (*Terminal) Close

func (t *Terminal) Close()

func (*Terminal) Input

func (t *Terminal) Input(ctx context.Context, input TerminalInput) error

func (*Terminal) Resize

func (t *Terminal) Resize(columns, rows int) error

func (*Terminal) State

func (t *Terminal) State() TerminalState

func (*Terminal) Subscribe

func (t *Terminal) Subscribe(after uint64) ([]TerminalEvent, <-chan TerminalEvent, func())

type TerminalEvent

type TerminalEvent struct {
	Sequence uint64         `json:"sequence"`
	Kind     string         `json:"kind"`
	Data     string         `json:"data,omitempty"` // Base64 preserves partial UTF-8 and arbitrary terminal bytes.
	State    *TerminalState `json:"state,omitempty"`
}

type TerminalInput

type TerminalInput struct {
	Writer   string `json:"writer"`
	Sequence uint64 `json:"sequence"`
	Data     string `json:"data"`
}

type TerminalRequest

type TerminalRequest struct {
	ID        string `json:"id"`
	Directory string `json:"directory,omitempty"`
	Columns   int    `json:"columns"`
	Rows      int    `json:"rows"`
}

type TerminalState

type TerminalState struct {
	ID        string `json:"id"`
	Directory string `json:"directory"`
	Title     string `json:"title"`
	Columns   int    `json:"columns"`
	Rows      int    `json:"rows"`
	Running   bool   `json:"running"`
	ExitCode  *int   `json:"exitCode,omitempty"`
	CreatedAt string `json:"createdAt"`
}

type Terminals

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

func NewTerminals

func NewTerminals(s *Service) *Terminals

func (*Terminals) Busy

func (m *Terminals) Busy() bool

func (*Terminals) Close

func (m *Terminals) Close()

func (*Terminals) Get

func (m *Terminals) Get(id string) (*Terminal, error)

func (*Terminals) List

func (m *Terminals) List(directory string) []TerminalState

func (*Terminals) Open

func (m *Terminals) Open(req TerminalRequest) (TerminalState, error)

func (*Terminals) Remove

func (m *Terminals) Remove(id string) error

Jump to

Keyboard shortcuts

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