websocketruntime

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const ProtocolVersion = 1

Variables

View Source
var (
	ErrUnexpectedMessage  = errors.New("websocket runtime message is unexpected")
	ErrUnsupportedVersion = errors.New("websocket runtime version is unsupported")
)

Functions

func DecodePayload

func DecodePayload[T any](envelope Envelope) (T, error)

Types

type ArtifactEntry

type ArtifactEntry struct {
	Path          string            `json:"path"`
	Kind          ArtifactEntryKind `json:"kind"`
	Mode          int64             `json:"mode,omitempty"`
	ContentBase64 string            `json:"content_base64,omitempty"`
}

type ArtifactEntryKind

type ArtifactEntryKind string
const (
	ArtifactEntryKindFile ArtifactEntryKind = "file"
	ArtifactEntryKindDir  ArtifactEntryKind = "dir"
)

type ArtifactSyncRequest

type ArtifactSyncRequest struct {
	TargetRoot  string          `json:"target_root"`
	RemovePaths []string        `json:"remove_paths,omitempty"`
	Entries     []ArtifactEntry `json:"entries,omitempty"`
}

type CommandOpenRequest

type CommandOpenRequest struct {
	Command string `json:"command"`
}

type Envelope

type Envelope struct {
	Version   int             `json:"version"`
	Type      MessageType     `json:"type"`
	RequestID string          `json:"request_id,omitempty"`
	Operation Operation       `json:"operation,omitempty"`
	Payload   json.RawMessage `json:"payload,omitempty"`
	Error     *ErrorPayload   `json:"error,omitempty"`
}

func ParseEnvelope

func ParseEnvelope(raw []byte) (Envelope, error)

type ErrorClass

type ErrorClass string
const (
	ErrorClassAuth             ErrorClass = "auth"
	ErrorClassMisconfiguration ErrorClass = "misconfiguration"
	ErrorClassTransient        ErrorClass = "transient"
	ErrorClassUnsupported      ErrorClass = "unsupported"
	ErrorClassInternal         ErrorClass = "internal"
)

func (ErrorClass) IsValid

func (c ErrorClass) IsValid() bool

type ErrorCode

type ErrorCode string
const (
	ErrorCodeInvalidRequest       ErrorCode = "invalid_request"
	ErrorCodeProtocolVersion      ErrorCode = "protocol_version"
	ErrorCodeWorkspace            ErrorCode = "workspace"
	ErrorCodeArtifactSync         ErrorCode = "artifact_sync"
	ErrorCodePreflight            ErrorCode = "preflight"
	ErrorCodeSessionNotFound      ErrorCode = "session_not_found"
	ErrorCodeProcessStart         ErrorCode = "process_start"
	ErrorCodeProcessSignal        ErrorCode = "process_signal"
	ErrorCodeTransportUnavailable ErrorCode = "transport_unavailable"
	ErrorCodeUnauthorized         ErrorCode = "unauthorized"
	ErrorCodeUnsupported          ErrorCode = "unsupported"
	ErrorCodeInternal             ErrorCode = "internal"
)

type ErrorPayload

type ErrorPayload struct {
	Code      ErrorCode      `json:"code"`
	Class     ErrorClass     `json:"class"`
	Message   string         `json:"message"`
	Retryable bool           `json:"retryable"`
	Details   map[string]any `json:"details,omitempty"`
}

type Hello

type Hello struct {
	SupportedVersions []int       `json:"supported_versions,omitempty"`
	Capabilities      []Operation `json:"capabilities,omitempty"`
}

type HelloAck

type HelloAck struct {
	SelectedVersion int         `json:"selected_version"`
	Capabilities    []Operation `json:"capabilities,omitempty"`
}

type MessageType

type MessageType string
const (
	MessageTypeHello    MessageType = "hello"
	MessageTypeHelloAck MessageType = "hello_ack"
	MessageTypeRequest  MessageType = "request"
	MessageTypeResponse MessageType = "response"
	MessageTypeEvent    MessageType = "event"
)

func (MessageType) IsValid

func (t MessageType) IsValid() bool

type Operation

type Operation string
const (
	OperationProbe            Operation = "probe"
	OperationPreflight        Operation = "preflight"
	OperationWorkspacePrepare Operation = "workspace_prepare"
	OperationWorkspaceReset   Operation = "workspace_reset"
	OperationArtifactSync     Operation = "artifact_sync"
	OperationCommandOpen      Operation = "command_open"
	OperationSessionInput     Operation = "session_input"
	OperationSessionSignal    Operation = "session_signal"
	OperationSessionClose     Operation = "session_close"
	OperationProcessStart     Operation = "process_start"
	OperationProcessStatus    Operation = "process_status"
	OperationSessionOutput    Operation = "session_output"
	OperationSessionExit      Operation = "session_exit"
)

func (Operation) IsValid

func (o Operation) IsValid() bool

type PreflightRequest

type PreflightRequest struct {
	WorkingDirectory string   `json:"working_directory"`
	AgentCommand     string   `json:"agent_command"`
	Environment      []string `json:"environment,omitempty"`
}

type PreparedRepo

type PreparedRepo struct {
	Name             string `json:"name"`
	RepositoryURL    string `json:"repository_url"`
	DefaultBranch    string `json:"default_branch"`
	BranchName       string `json:"branch_name"`
	WorkspaceDirname string `json:"workspace_dirname"`
	HeadCommit       string `json:"head_commit"`
	Path             string `json:"path"`
}

type ProbeResponse

type ProbeResponse struct {
	CheckedAt       string         `json:"checked_at"`
	Output          string         `json:"output"`
	Resources       map[string]any `json:"resources,omitempty"`
	DetectedOS      string         `json:"detected_os,omitempty"`
	DetectedArch    string         `json:"detected_arch,omitempty"`
	DetectionStatus string         `json:"detection_status,omitempty"`
}

type ProcessStartRequest

type ProcessStartRequest struct {
	Command          string   `json:"command"`
	Args             []string `json:"args,omitempty"`
	WorkingDirectory string   `json:"working_directory,omitempty"`
	Environment      []string `json:"environment,omitempty"`
}

type ProcessStatusRequest

type ProcessStatusRequest struct {
	SessionID string `json:"session_id"`
}

type ProcessStatusResponse

type ProcessStatusResponse struct {
	SessionID string `json:"session_id"`
	Running   bool   `json:"running"`
	ExitCode  *int   `json:"exit_code,omitempty"`
}

type SessionCloseRequest

type SessionCloseRequest struct {
	SessionID string `json:"session_id"`
}

type SessionExitEvent

type SessionExitEvent struct {
	SessionID string `json:"session_id"`
	ExitCode  int    `json:"exit_code"`
}

type SessionInputRequest

type SessionInputRequest struct {
	SessionID  string `json:"session_id"`
	DataBase64 string `json:"data_base64,omitempty"`
	CloseStdin bool   `json:"close_stdin,omitempty"`
}

type SessionOutputEvent

type SessionOutputEvent struct {
	SessionID  string `json:"session_id"`
	Stream     string `json:"stream"`
	DataBase64 string `json:"data_base64,omitempty"`
}

type SessionResponse

type SessionResponse struct {
	SessionID string `json:"session_id"`
}

type SessionSignalRequest

type SessionSignalRequest struct {
	SessionID string `json:"session_id"`
	Signal    string `json:"signal,omitempty"`
}

type WorkspacePrepareRequest

type WorkspacePrepareRequest struct {
	WorkspaceRoot    string          `json:"workspace_root"`
	OrganizationSlug string          `json:"organization_slug"`
	ProjectSlug      string          `json:"project_slug"`
	AgentName        string          `json:"agent_name,omitempty"`
	TicketIdentifier string          `json:"ticket_identifier"`
	MachineID        string          `json:"machine_id,omitempty"`
	RunID            string          `json:"run_id,omitempty"`
	TicketID         string          `json:"ticket_id,omitempty"`
	Repos            []WorkspaceRepo `json:"repos,omitempty"`
}

type WorkspacePrepareResponse

type WorkspacePrepareResponse struct {
	Path       string         `json:"path"`
	BranchName string         `json:"branch_name"`
	Repos      []PreparedRepo `json:"repos,omitempty"`
}

type WorkspaceRepo

type WorkspaceRepo struct {
	Name             string             `json:"name"`
	RepositoryURL    string             `json:"repository_url"`
	DefaultBranch    string             `json:"default_branch,omitempty"`
	WorkspaceDirname *string            `json:"workspace_dirname,omitempty"`
	BranchName       *string            `json:"branch_name,omitempty"`
	HTTPBasicAuth    *WorkspaceRepoAuth `json:"http_basic_auth,omitempty"`
}

type WorkspaceRepoAuth

type WorkspaceRepoAuth struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type WorkspaceResetRequest

type WorkspaceResetRequest struct {
	Path string `json:"path"`
}

Jump to

Keyboard shortcuts

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