Documentation
¶
Overview ¶
Package protocol defines wire protocol message types matching @pocketmux/shared.
All struct field names use msgpack tags matching the camelCase names from the TypeScript protocol types. This ensures cross-language compatibility.
Index ¶
- Constants
- func Encode(msg Message) ([]byte, error)
- func IsEvent(msg Message) bool
- func IsRequest(msg Message) bool
- type AttachRequest
- type AttachedEvent
- type CreateSessionRequest
- type DetachRequest
- type DetachedEvent
- type ErrorEvent
- type InputRequest
- type KillSessionRequest
- type ListSessionsRequest
- type Message
- type OutputCompressor
- type OutputEvent
- type PaneClosedEvent
- type PaneSize
- type PingRequest
- type PongEvent
- type ResizeRequest
- type SessionCreatedEvent
- type SessionEndedEvent
- type SessionsEvent
- type TmuxPane
- type TmuxSession
- type TmuxWindow
Constants ¶
const MaxMessageSize = 1 << 20 // 1 MiB
MaxMessageSize is the maximum size in bytes for an incoming protocol message. Terminal I/O data is typically < 4KB. This limit provides defense-in-depth against malicious or malformed messages causing memory exhaustion. The WebRTC DataChannel has its own limits, but validating here catches issues regardless of transport.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AttachRequest ¶
type AttachRequest struct {
Type string `msgpack:"type"`
PaneID string `msgpack:"paneId"`
Cols int `msgpack:"cols"`
Rows int `msgpack:"rows"`
Reattach bool `msgpack:"reattach,omitempty"`
Compression string `msgpack:"compression,omitempty"`
}
AttachRequest attaches to a specific pane with the given terminal dimensions.
func (*AttachRequest) MessageType ¶
func (m *AttachRequest) MessageType() string
type AttachedEvent ¶
type AttachedEvent struct {
Type string `msgpack:"type"`
PaneID string `msgpack:"paneId"`
Compression string `msgpack:"compression,omitempty"`
}
AttachedEvent confirms successful pane attachment.
func (*AttachedEvent) MessageType ¶
func (m *AttachedEvent) MessageType() string
type CreateSessionRequest ¶ added in v0.2.0
type CreateSessionRequest struct {
Type string `msgpack:"type"`
}
CreateSessionRequest requests creation of a new tmux session.
func (*CreateSessionRequest) MessageType ¶ added in v0.2.0
func (m *CreateSessionRequest) MessageType() string
type DetachRequest ¶
type DetachRequest struct {
Type string `msgpack:"type"`
}
DetachRequest detaches from the currently attached pane.
func (*DetachRequest) MessageType ¶
func (m *DetachRequest) MessageType() string
type DetachedEvent ¶
type DetachedEvent struct {
Type string `msgpack:"type"`
}
DetachedEvent confirms pane detachment.
func (*DetachedEvent) MessageType ¶
func (m *DetachedEvent) MessageType() string
type ErrorEvent ¶
type ErrorEvent struct {
Type string `msgpack:"type"`
Code string `msgpack:"code"`
Message string `msgpack:"message"`
}
ErrorEvent reports an error to the mobile client.
func (*ErrorEvent) MessageType ¶
func (m *ErrorEvent) MessageType() string
type InputRequest ¶
InputRequest sends terminal input data (raw bytes) to the attached pane.
func (*InputRequest) MessageType ¶
func (m *InputRequest) MessageType() string
type KillSessionRequest ¶
KillSessionRequest kills a tmux session by ID.
func (*KillSessionRequest) MessageType ¶
func (m *KillSessionRequest) MessageType() string
type ListSessionsRequest ¶
type ListSessionsRequest struct {
Type string `msgpack:"type"`
}
ListSessionsRequest requests the full session tree from the host.
func (*ListSessionsRequest) MessageType ¶
func (m *ListSessionsRequest) MessageType() string
type Message ¶
type Message interface {
MessageType() string
}
Message is implemented by all protocol messages.
type OutputCompressor ¶ added in v0.0.4
type OutputCompressor struct {
// contains filtered or unexported fields
}
OutputCompressor wraps a stateful flate.Writer for compressing terminal output across multiple messages. The LZ77 sliding window persists between Compress() calls, allowing repeated patterns (ANSI escapes, shell prompts, common paths) to compress increasingly well over time.
func NewOutputCompressor ¶ added in v0.0.4
func NewOutputCompressor() *OutputCompressor
NewOutputCompressor creates a new stateful compressor using deflate level 6.
func (*OutputCompressor) Close ¶ added in v0.0.4
func (c *OutputCompressor) Close() error
Close releases resources held by the compressor.
func (*OutputCompressor) Compress ¶ added in v0.0.4
func (c *OutputCompressor) Compress(data []byte) ([]byte, error)
Compress compresses data through the stateful deflate stream. Uses sync flush to emit a sync marker so the decompressor can produce output immediately without waiting for more data. Returns a copy of the compressed bytes (the internal buffer is reused across calls).
type OutputEvent ¶
OutputEvent sends terminal output data (raw bytes) from the attached pane.
func (*OutputEvent) MessageType ¶
func (m *OutputEvent) MessageType() string
type PaneClosedEvent ¶
PaneClosedEvent reports that a specific pane has exited.
func (*PaneClosedEvent) MessageType ¶
func (m *PaneClosedEvent) MessageType() string
type PingRequest ¶
type PingRequest struct {
Type string `msgpack:"type"`
}
PingRequest is a latency measurement request.
func (*PingRequest) MessageType ¶
func (m *PingRequest) MessageType() string
type PongEvent ¶
PongEvent responds to a ping with latency measurement.
func (*PongEvent) MessageType ¶
type ResizeRequest ¶
type ResizeRequest struct {
Type string `msgpack:"type"`
Cols int `msgpack:"cols"`
Rows int `msgpack:"rows"`
}
ResizeRequest resizes the attached pane to the given dimensions.
func (*ResizeRequest) MessageType ¶
func (m *ResizeRequest) MessageType() string
type SessionCreatedEvent ¶ added in v0.2.0
type SessionCreatedEvent struct {
Type string `msgpack:"type"`
Session TmuxSession `msgpack:"session"`
}
SessionCreatedEvent reports that a new tmux session was created.
func (*SessionCreatedEvent) MessageType ¶ added in v0.2.0
func (m *SessionCreatedEvent) MessageType() string
type SessionEndedEvent ¶
SessionEndedEvent reports a session was killed or exited.
func (*SessionEndedEvent) MessageType ¶
func (m *SessionEndedEvent) MessageType() string
type SessionsEvent ¶
type SessionsEvent struct {
Type string `msgpack:"type"`
Sessions []TmuxSession `msgpack:"sessions"`
AgentVersion string `msgpack:"agentVersion,omitempty"`
UpdateAvailable string `msgpack:"updateAvailable,omitempty"` // latest version if update available, empty otherwise
}
SessionsEvent returns the full session tree. AgentVersion and UpdateAvailable are optional fields added for update notifications to the mobile app.
func (*SessionsEvent) MessageType ¶
func (m *SessionsEvent) MessageType() string
type TmuxPane ¶
type TmuxPane struct {
ID string `msgpack:"id"`
Index int `msgpack:"index"`
Active bool `msgpack:"active"`
Size PaneSize `msgpack:"size"`
Title string `msgpack:"title"`
CurrentCommand string `msgpack:"currentCommand"`
}
TmuxPane represents a pane within a tmux window.
type TmuxSession ¶
type TmuxSession struct {
ID string `msgpack:"id"`
Name string `msgpack:"name"`
// CreatedAt is a Unix timestamp in seconds.
CreatedAt int64 `msgpack:"createdAt"`
Windows []TmuxWindow `msgpack:"windows"`
// LastActivityAt is a Unix timestamp in seconds.
LastActivityAt int64 `msgpack:"lastActivityAt"`
Attached bool `msgpack:"attached"`
}
TmuxSession represents a tmux session with its window tree.