-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessage.go
More file actions
54 lines (42 loc) · 2.07 KB
/
message.go
File metadata and controls
54 lines (42 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package relay
// -----------------------------------------------------------------------------
// Message Types
// -----------------------------------------------------------------------------
// MessageType identifies the type of message in the protocol.
// Both agents and clients use these message types.
type MessageType string
// Message types for the protocol.
const (
// Control messages
MessageTypeRegister MessageType = "register" // Agent/client registration
MessageTypeHeartbeat MessageType = "heartbeat" // Keep-alive ping/pong
// Session lifecycle
MessageTypeSessionOpen MessageType = "session:open" // Request to open a new session
MessageTypeSessionClose MessageType = "session:close" // Request to close a session
MessageTypeSessionReady MessageType = "session:ready" // Confirmation that session is ready
// Session data
MessageTypeSessionData MessageType = "session:data" // Raw data for a session
// PTY-specific messages
MessageTypePTYResize MessageType = "pty:resize" // Terminal resize event
// Error handling
MessageTypeError MessageType = "error" // Error response
)
// Message is the universal envelope for all messages between server, agents, and clients.
// It provides a uniform structure that supports multiple sessions per connection.
type Message struct {
// Type identifies what kind of message this is.
Type MessageType `json:"type"`
// SessionID identifies which session this message belongs to.
// Empty for control messages like register/heartbeat.
SessionID SessionID `json:"session_id,omitempty"`
// Payload contains the message-specific data.
// For session data, this is the raw bytes being transmitted.
// For control messages, this may be JSON-encoded metadata.
Payload []byte `json:"payload,omitempty"`
// Metadata contains optional key-value pairs for extensibility.
// Used for things like error codes, PTY dimensions, tunnel targets, etc.
Metadata map[string]string `json:"metadata,omitempty"`
}
// AgentMessage is an alias for Message for backwards compatibility.
// Deprecated: Use Message directly.
type AgentMessage = Message