Documentation
¶
Index ¶
- Constants
- Variables
- type Agent
- type AgentJoinedPayload
- type AgentLeftPayload
- type Client
- type FileChange
- type FileChangedPayload
- type Hub
- type Manager
- func (m *Manager) GetActiveAgents(ctx context.Context, sessionID uuid.UUID) ([]Agent, error)
- func (m *Manager) GetFileVersion(ctx context.Context, sessionID uuid.UUID, filePath string) (int, error)
- func (m *Manager) GetMessages(ctx context.Context, sessionID uuid.UUID, limit int) ([]Message, error)
- func (m *Manager) JoinSession(ctx context.Context, sessionID uuid.UUID, agentID, agentName string) (*Agent, error)
- func (m *Manager) LeaveSession(ctx context.Context, sessionID uuid.UUID, agentID string) error
- func (m *Manager) RecordFileChange(ctx context.Context, sessionID uuid.UUID, ...) (*FileChange, error)
- func (m *Manager) SendMessage(ctx context.Context, sessionID uuid.UUID, from, to, body string, ...) (*Message, error)
- func (m *Manager) SubscribeToEvents(ctx context.Context, sessionID uuid.UUID) *redis.PubSub
- func (m *Manager) UpdatePresence(ctx context.Context, sessionID uuid.UUID, agentID string, currentFile string, ...) error
- type Message
- type MessagePayload
- type PresenceUpdatePayload
- type WSMessage
Constants ¶
const ( AgentStatusActive = "active" AgentStatusIdle = "idle" AgentStatusDisconnected = "disconnected" )
AgentStatus constants
const ( MessageTypeDirect = "direct" MessageTypeBroadcast = "broadcast" MessageTypeSystem = "system" )
MessageType constants
const ( ChangeTypeCreated = "created" ChangeTypeModified = "modified" ChangeTypeDeleted = "deleted" )
ChangeType constants
const ( WSMessageTypeAgentJoined = "agent_joined" WSMessageTypeAgentLeft = "agent_left" WSMessageTypeMessage = "message" WSMessageTypeFileChanged = "file_changed" WSMessageTypePresenceUpdate = "presence_update" WSMessageTypePing = "ping" WSMessageTypePong = "pong" )
WSMessageType constants
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
ID string `json:"id"` // Agent identifier (e.g., "agent_a")
Name string `json:"name"` // Human-readable name
SessionID uuid.UUID `json:"session_id"` // Session this agent is connected to
Status string `json:"status"` // "active", "idle", "disconnected"
CurrentFile string `json:"current_file"` // File currently being edited (nullable)
LastActivity time.Time `json:"last_activity"`
ConnectedAt time.Time `json:"connected_at"`
}
Agent represents a connected agent in a collaborative session
type AgentJoinedPayload ¶
type AgentJoinedPayload struct {
Agent Agent `json:"agent"`
}
AgentJoinedPayload is sent when an agent joins
type AgentLeftPayload ¶
type AgentLeftPayload struct {
AgentID string `json:"agent_id"`
Timestamp time.Time `json:"timestamp"`
}
AgentLeftPayload is sent when an agent disconnects
type Client ¶
type Client struct {
SessionID uuid.UUID
AgentID string
AgentName string
Conn *websocket.Conn
Manager *Manager
// contains filtered or unexported fields
}
Client represents a WebSocket client (agent connection)
func NewClient ¶
func NewClient(sessionID uuid.UUID, agentID, agentName string, conn *websocket.Conn, manager *Manager) *Client
NewClient creates a new WebSocket client
type FileChange ¶
type FileChange struct {
SessionID uuid.UUID `json:"session_id"`
File string `json:"file"`
ChangedBy string `json:"changed_by"` // Agent ID
ChangeType string `json:"change_type"` // "created", "modified", "deleted"
Version int `json:"version"` // Incremental version number
Timestamp time.Time `json:"timestamp"`
}
FileChange represents a file modification event
type FileChangedPayload ¶
type FileChangedPayload struct {
Change FileChange `json:"change"`
}
FileChangedPayload is sent when a file is modified
type Hub ¶
type Hub struct {
Manager *Manager
// contains filtered or unexported fields
}
Hub manages all active WebSocket connections
func (*Hub) BroadcastToSession ¶
BroadcastToSession sends a message to all clients in a session
func (*Hub) RegisterClient ¶
RegisterClient registers a new WebSocket client
func (*Hub) UnregisterClient ¶
UnregisterClient unregisters a WebSocket client
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles multi-agent collaboration
func (*Manager) GetActiveAgents ¶
GetActiveAgents returns all active agents for a session
func (*Manager) GetFileVersion ¶
func (m *Manager) GetFileVersion(ctx context.Context, sessionID uuid.UUID, filePath string) (int, error)
GetFileVersion returns the current version of a file
func (*Manager) GetMessages ¶
func (m *Manager) GetMessages(ctx context.Context, sessionID uuid.UUID, limit int) ([]Message, error)
GetMessages retrieves recent messages for a session
func (*Manager) JoinSession ¶
func (m *Manager) JoinSession(ctx context.Context, sessionID uuid.UUID, agentID, agentName string) (*Agent, error)
JoinSession registers an agent as active in a session
func (*Manager) LeaveSession ¶
LeaveSession removes an agent from a session
func (*Manager) RecordFileChange ¶
func (m *Manager) RecordFileChange(ctx context.Context, sessionID uuid.UUID, filePath, agentID, changeType, checksum string, sizeBytes int64) (*FileChange, error)
RecordFileChange records a file modification
func (*Manager) SendMessage ¶
func (m *Manager) SendMessage(ctx context.Context, sessionID uuid.UUID, from, to, body string, msgType string) (*Message, error)
SendMessage sends a message from one agent to another (or broadcast)
func (*Manager) SubscribeToEvents ¶
SubscribeToEvents subscribes to session events
type Message ¶
type Message struct {
ID uuid.UUID `json:"id"`
SessionID uuid.UUID `json:"session_id"`
Type string `json:"type"` // "direct", "broadcast", "system"
From string `json:"from"` // Agent ID
To string `json:"to"` // Agent ID (empty for broadcast)
Body string `json:"body"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
Message represents a message between agents
type MessagePayload ¶
type MessagePayload struct {
Message Message `json:"message"`
}
MessagePayload wraps a message