Documentation
¶
Overview ¶
SPDX-License-Identifier: GPL-2.0-only
SPDX-License-Identifier: GPL-2.0-only
SPDX-License-Identifier: GPL-2.0-only
SPDX-License-Identifier: GPL-2.0-only
SPDX-License-Identifier: GPL-2.0-only
SPDX-License-Identifier: GPL-2.0-only
SPDX-License-Identifier: GPL-2.0-only
SPDX-License-Identifier: GPL-2.0-only
SPDX-License-Identifier: GPL-2.0-only
Index ¶
- type Hub
- func (h *Hub) BroadcastMessage(channelID int64, channelName string, channelType string, msg db.Message, ...)
- func (h *Hub) BroadcastPresence(username string, online bool, state string)
- func (h *Hub) BroadcastToRole(role string, data []byte, database *db.DB)
- func (h *Hub) ClearState(username string)
- func (h *Hub) ClientCount() int
- func (h *Hub) GetState(username string) string
- func (h *Hub) Register(client *WSClient)
- func (h *Hub) SetState(username, state string)
- func (h *Hub) Unregister(client *WSClient)
- type IdentityToken
- type MCPSession
- type PresenceHandler
- type Server
- type SessionManager
- func (sm *SessionManager) AttachPresence(token string) (<-chan struct{}, error)
- func (sm *SessionManager) CreateIdentityToken() string
- func (sm *SessionManager) DisconnectPresence(token string)
- func (sm *SessionManager) GetSession(mcpSessionID string) (*MCPSession, error)
- func (sm *SessionManager) Identify(token, username, password string) (string, error)
- func (sm *SessionManager) IsUserOnline(username string) bool
- func (sm *SessionManager) Register(token, username, password string) (string, error)
- type SharkfinMCP
- type WSClient
- type WSHandler
- type WebhookEvent
- type WebhookPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub manages connected WebSocket clients and broadcasts events.
func (*Hub) BroadcastMessage ¶
func (h *Hub) BroadcastMessage(channelID int64, channelName string, channelType string, msg db.Message, mentions []string, threadID *int64, database *db.DB)
BroadcastMessage sends a message.new event to all connected members of a channel.
func (*Hub) BroadcastPresence ¶
BroadcastPresence sends a presence event to all connected clients.
func (*Hub) BroadcastToRole ¶ added in v0.1.0
BroadcastToRole sends a pre-encoded event to all connected clients whose user has the given role.
func (*Hub) ClearState ¶ added in v0.1.0
ClearState removes the state entry for a user.
func (*Hub) ClientCount ¶
ClientCount returns the number of connected clients.
func (*Hub) Unregister ¶
Unregister removes a client from the hub.
type IdentityToken ¶
type IdentityToken struct {
Token string
Username string // empty until identified
Identified bool
MCPSessionID string
PresenceDone chan struct{} // closed when presence should disconnect
HasPresence bool
CreatedAt time.Time
}
IdentityToken tracks the lifecycle of an identity token.
type MCPSession ¶
MCPSession links an MCP session ID to a token and user.
type PresenceHandler ¶
type PresenceHandler struct {
// contains filtered or unexported fields
}
PresenceHandler handles WebSocket presence connections. On connect: creates an identity token and sends it as the first message. Keeps the connection alive with ping/pong. When the client disconnects (or pong times out), the user is marked offline.
func NewPresenceHandler ¶
func NewPresenceHandler(sessions *SessionManager, hub *Hub, pongTimeout time.Duration) *PresenceHandler
NewPresenceHandler creates a new presence handler.
func (*PresenceHandler) ServeHTTP ¶
func (h *PresenceHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the sharkfind HTTP server.
func (*Server) DB ¶ added in v0.1.0
DB returns the server's database handle. Intended for test access.
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager manages identity tokens, MCP sessions, and presence state.
func NewSessionManager ¶
func NewSessionManager(database *db.DB) *SessionManager
NewSessionManager creates a new session manager.
func (*SessionManager) AttachPresence ¶
func (sm *SessionManager) AttachPresence(token string) (<-chan struct{}, error)
AttachPresence links a presence connection to a token. Returns a channel that is closed when the presence should disconnect.
func (*SessionManager) CreateIdentityToken ¶
func (sm *SessionManager) CreateIdentityToken() string
CreateIdentityToken generates a new pending identity token.
func (*SessionManager) DisconnectPresence ¶
func (sm *SessionManager) DisconnectPresence(token string)
DisconnectPresence removes the presence for a token and marks the user offline.
func (*SessionManager) GetSession ¶
func (sm *SessionManager) GetSession(mcpSessionID string) (*MCPSession, error)
GetSession returns the MCP session for a given session ID.
func (*SessionManager) Identify ¶
func (sm *SessionManager) Identify(token, username, password string) (string, error)
Identify associates a token with an existing user. Returns an MCP session ID.
func (*SessionManager) IsUserOnline ¶
func (sm *SessionManager) IsUserOnline(username string) bool
IsUserOnline returns true if the user has an active presence connection.
type SharkfinMCP ¶
type SharkfinMCP struct {
// contains filtered or unexported fields
}
SharkfinMCP wraps an mcp-go MCPServer with Sharkfin's business logic.
func NewSharkfinMCP ¶
func NewSharkfinMCP(sm *SessionManager, database *db.DB, hub *Hub) *SharkfinMCP
NewSharkfinMCP creates the MCP server and registers all tools.
func (*SharkfinMCP) Server ¶
func (s *SharkfinMCP) Server() *server.MCPServer
Server returns the underlying mcp-go MCPServer.
type WSClient ¶
type WSClient struct {
// contains filtered or unexported fields
}
WSClient represents a connected WebSocket client.
type WSHandler ¶
type WSHandler struct {
// contains filtered or unexported fields
}
WSHandler handles WebSocket connections for non-MCP clients.
func NewWSHandler ¶
func NewWSHandler(sessions *SessionManager, database *db.DB, hub *Hub, pongTimeout time.Duration) *WSHandler
NewWSHandler creates a new WebSocket handler.
type WebhookEvent ¶
type WebhookEvent struct {
ChannelName string
ChannelType string
From string
MessageID int64
SentAt time.Time
Recipients []string
}
WebhookEvent contains the data needed to fire webhooks for a message.
type WebhookPayload ¶
type WebhookPayload struct {
Event string `json:"event"`
Recipient string `json:"recipient"`
Channel string `json:"channel"`
ChannelType string `json:"channel_type"`
From string `json:"from"`
MessageID int64 `json:"message_id"`
SentAt string `json:"sent_at"`
}
WebhookPayload is the JSON body POSTed to the webhook URL.