Documentation
¶
Index ¶
- func GenerateOrLoadSecret(store *RelayStore, envSecret string) ([]byte, error)
- func IssueWingJWT(secret []byte, userID, publicKey, machineID string) (string, time.Time, error)
- func SeedDefaultSkills(store *RelayStore) error
- func SeedSpacesFromIndex(store *RelayStore, idx *embedding.SpaceIndex, embedderName string) (int, error)
- func StartSidebarRefresh(store *RelayStore, interval time.Duration)
- type AnchorEmbedding
- type BandwidthMeter
- type ChatRegistry
- type ChatSession
- type ConnectedWing
- type DeviceCodeRow
- type ExportAnchor
- type ExportComment
- type ExportPost
- type ExportVote
- type PTYRegistry
- func (r *PTYRegistry) Add(s *PTYSession) bool
- func (r *PTYRegistry) CountForUser(userID string) int
- func (r *PTYRegistry) Get(id string) *PTYSession
- func (r *PTYRegistry) IsTombstoned(id string) bool
- func (r *PTYRegistry) ListForUser(userID string) []*PTYSession
- func (r *PTYRegistry) Remove(id string)
- func (r *PTYRegistry) SyncFromWing(wingID, userID string, sessions []ws.SessionInfo, removeStale bool)
- type PTYSession
- type PostAnchor
- type PostParams
- type RelayStore
- func (s *RelayStore) AnchorConnectivity() (map[string]map[string]int, error)
- func (s *RelayStore) AnchorMasses() (map[string]float64, error)
- func (s *RelayStore) AnchorSlugsForPosts(postIDs []string) (map[string][]string, error)
- func (s *RelayStore) AppendAudit(userID, event string, detail *string) error
- func (s *RelayStore) AssignPostAnchors(postID string, assignments []PostAnchor) error
- func (s *RelayStore) CheckRateLimit(userID, action string, isPro bool) (bool, error)
- func (s *RelayStore) ClaimDeviceCode(code, userID string) error
- func (s *RelayStore) Close() error
- func (s *RelayStore) CommentCountsForPosts(postIDs []string) (map[string]int, error)
- func (s *RelayStore) ConsumeMagicLink(token string) (string, error)
- func (s *RelayStore) CountPostsByAnchor(anchorID string) (int, error)
- func (s *RelayStore) CreateComment(c *SocialComment) error
- func (s *RelayStore) CreateDeviceCode(code, userCode, deviceID string, expiresAt time.Time) error
- func (s *RelayStore) CreateDeviceCodeWithKey(code, userCode, deviceID, publicKey string, expiresAt time.Time) error
- func (s *RelayStore) CreateDeviceToken(token, userID, deviceID string, expiresAt *time.Time) error
- func (s *RelayStore) CreateLocalUser() (*SocialUser, string, error)
- func (s *RelayStore) CreateMagicLink(id, email, token string, expiresAt time.Time) error
- func (s *RelayStore) CreateSession(token, socialUserID string, expiresAt time.Time) error
- func (s *RelayStore) CreateSkill(...) error
- func (s *RelayStore) CreateSocialEmbedding(e *SocialEmbedding) error
- func (s *RelayStore) CreateSocialUserDev() (*SocialUser, error)
- func (s *RelayStore) CreateUser(id string) error
- func (s *RelayStore) DB() *sql.DB
- func (s *RelayStore) DecayMasses() error
- func (s *RelayStore) DeleteSession(token string) error
- func (s *RelayStore) DeleteSkill(name string) error
- func (s *RelayStore) DeleteToken(token string) error
- func (s *RelayStore) DequeueTask(taskID string) error
- func (s *RelayStore) EnqueueTask(t *ws.QueuedTask) error
- func (s *RelayStore) ExportPosts() ([]ExportPost, error)
- func (s *RelayStore) ExportVotesAndComments(since time.Time) ([]ExportVote, []ExportComment, error)
- func (s *RelayStore) GetDeviceCode(code string) (*DeviceCodeRow, error)
- func (s *RelayStore) GetDeviceCodeByUserCode(userCode string) (*DeviceCodeRow, error)
- func (s *RelayStore) GetOrCreateSocialUserByEmail(email string) (*SocialUser, error)
- func (s *RelayStore) GetRelayConfig(key string) (string, error)
- func (s *RelayStore) GetSession(token string) (*SocialUser, error)
- func (s *RelayStore) GetSkill(name string) (*SkillRow, error)
- func (s *RelayStore) GetSocialEmbedding(id string) (*SocialEmbedding, error)
- func (s *RelayStore) GetSocialEmbeddingByLink(link string) (*SocialEmbedding, error)
- func (s *RelayStore) GetSocialEmbeddingBySlug(slug string) (*SocialEmbedding, error)
- func (s *RelayStore) GetSocialUser(id string) (*SocialUser, error)
- func (s *RelayStore) GetSocialUserByProvider(provider, providerID string) (*SocialUser, error)
- func (s *RelayStore) GetUpvoteCount(postID string) (int, error)
- func (s *RelayStore) ListAllPosts(sort string, limit int) ([]*SocialEmbedding, error)
- func (s *RelayStore) ListAnchors() ([]*SocialEmbedding, error)
- func (s *RelayStore) ListAnchorsForEmbedder(embedderName string) ([]AnchorEmbedding, error)
- func (s *RelayStore) ListCommentsByPost(postID string) ([]*SocialComment, error)
- func (s *RelayStore) ListPendingTasks(userID string) ([]*ws.QueuedTask, error)
- func (s *RelayStore) ListPostsByAnchor(anchorID, sort string, limit int) ([]*SocialEmbedding, error)
- func (s *RelayStore) ListSkills(category string) ([]*SkillRow, error)
- func (s *RelayStore) RefreshUpvotes24h() error
- func (s *RelayStore) SearchSkills(query string) ([]*SkillRow, error)
- func (s *RelayStore) SetRelayConfig(key, value string) error
- func (s *RelayStore) SumDecayedMassByAnchor(anchorID string) (float64, error)
- func (s *RelayStore) ToggleUpvote(userID, postID string) (bool, error)
- func (s *RelayStore) TopPostsByAnchor() (map[string]topPost, error)
- func (s *RelayStore) UpdateAnchorCentroid(anchorID string, centroid512 []byte) error
- func (s *RelayStore) UpdateAnchorEffective(anchorID string, effective512 []byte) error
- func (s *RelayStore) UpsertAnchorEmbedding(anchorID, embedderName string, centroid512 []byte) error
- func (s *RelayStore) UpsertSocialUser(u *SocialUser) error
- func (s *RelayStore) Upvote(userID, postID string) error
- func (s *RelayStore) UserUpvotesForPosts(userID string, postIDs []string) (map[string]bool, error)
- func (s *RelayStore) ValidateToken(token string) (userID string, deviceID string, err error)
- type Server
- type ServerConfig
- type SkillRow
- type SocialComment
- type SocialEmbedding
- type SocialUser
- type WingClaims
- type WingEvent
- type WingRegistry
- func (r *WingRegistry) Add(w *ConnectedWing)
- func (r *WingRegistry) CountForUser(userID string) int
- func (r *WingRegistry) FindByID(wingID string) *ConnectedWing
- func (r *WingRegistry) FindByIdentity(identity string) *ConnectedWing
- func (r *WingRegistry) FindForUser(userID string) *ConnectedWing
- func (r *WingRegistry) ListForUser(userID string) []*ConnectedWing
- func (r *WingRegistry) RegisterDirRequest(reqID string, ch chan *ws.DirResults)
- func (r *WingRegistry) RegisterSessionRequest(reqID string, ch chan *ws.SessionsSync)
- func (r *WingRegistry) Remove(id string)
- func (r *WingRegistry) ResolveDirRequest(reqID string, results *ws.DirResults)
- func (r *WingRegistry) ResolveSessionRequest(reqID string, results *ws.SessionsSync)
- func (r *WingRegistry) Subscribe(userID string, ch chan WingEvent)
- func (r *WingRegistry) Touch(wingID string)
- func (r *WingRegistry) UnregisterDirRequest(reqID string)
- func (r *WingRegistry) UnregisterSessionRequest(reqID string)
- func (r *WingRegistry) Unsubscribe(userID string, ch chan WingEvent)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateOrLoadSecret ¶
func GenerateOrLoadSecret(store *RelayStore, envSecret string) ([]byte, error)
GenerateOrLoadSecret returns the JWT signing secret. Priority: envSecret (from WT_JWT_SECRET) > relay_config DB > auto-generate.
func IssueWingJWT ¶
IssueWingJWT creates a signed JWT for a wing connection.
func SeedDefaultSkills ¶
func SeedDefaultSkills(store *RelayStore) error
func SeedSpacesFromIndex ¶
func SeedSpacesFromIndex(store *RelayStore, idx *embedding.SpaceIndex, embedderName string) (int, error)
SeedSpacesFromIndex upserts anchors from a SpaceIndex with real embeddings. It writes centroids to both the legacy embedding_512 column and the new anchor_embeddings table.
func StartSidebarRefresh ¶
func StartSidebarRefresh(store *RelayStore, interval time.Duration)
StartSidebarRefresh launches a background goroutine that recomputes the sidebar cache every interval. Does an initial compute synchronously.
Types ¶
type AnchorEmbedding ¶
AnchorEmbedding holds an anchor's centroid for a specific embedder.
type BandwidthMeter ¶
type BandwidthMeter struct {
// contains filtered or unexported fields
}
BandwidthMeter applies per-user rate limiting on relay traffic and periodically syncs usage to the DB.
func NewBandwidthMeter ¶
func NewBandwidthMeter(bytesPerSec int, burst int, db *sql.DB) *BandwidthMeter
NewBandwidthMeter creates a meter with the given sustained rate (bytes/sec) and burst (bytes).
type ChatRegistry ¶
type ChatRegistry struct {
// contains filtered or unexported fields
}
ChatRegistry tracks active chat sessions.
func NewChatRegistry ¶
func NewChatRegistry() *ChatRegistry
func (*ChatRegistry) Add ¶
func (r *ChatRegistry) Add(s *ChatSession)
func (*ChatRegistry) CountForUser ¶
func (r *ChatRegistry) CountForUser(userID string) int
CountForUser returns the number of chat sessions for a given user.
func (*ChatRegistry) Get ¶
func (r *ChatRegistry) Get(id string) *ChatSession
func (*ChatRegistry) ListForUser ¶
func (r *ChatRegistry) ListForUser(userID string) []*ChatSession
ListForUser returns all chat sessions for a given user.
func (*ChatRegistry) Remove ¶
func (r *ChatRegistry) Remove(id string)
type ChatSession ¶
type ChatSession struct {
ID string
WingID string
UserID string
Agent string
Status string // "active", "exited"
BrowserConn *websocket.Conn
// contains filtered or unexported fields
}
ChatSession tracks a browser <-> wing chat connection through the relay.
type ConnectedWing ¶
type ConnectedWing struct {
ID string
UserID string
MachineID string
Platform string // runtime.GOOS from wing
PublicKey string
Agents []string
Skills []string
Labels []string
Identities []string
Projects []ws.WingProject
Conn *websocket.Conn
LastSeen time.Time
}
ConnectedWing represents a wing connected via WebSocket.
type DeviceCodeRow ¶
type ExportAnchor ¶
type ExportComment ¶
type ExportComment struct {
Link string `json:"link"`
UserID string `json:"user_id"`
ParentID *string `json:"parent_id,omitempty"`
Content string `json:"content"`
IsBot bool `json:"is_bot"`
CreatedAt string `json:"created_at"`
}
ExportComment holds a comment keyed by link for sync.
type ExportPost ¶
type ExportPost struct {
Text string `json:"text"`
Title *string `json:"title,omitempty"`
Link *string `json:"link,omitempty"`
Mass int `json:"mass"`
PublishedAt *string `json:"published_at,omitempty"`
Embedding512 []byte `json:"embedding_512"`
EmbedderName string `json:"embedder_name"`
Anchors []ExportAnchor `json:"anchors"`
}
ExportPost holds a post with its embedding and anchor assignments for sync.
type ExportVote ¶
type ExportVote struct {
Link string `json:"link"`
UserID string `json:"user_id"`
CreatedAt string `json:"created_at"`
}
ExportVote holds a vote keyed by link for sync.
type PTYRegistry ¶
type PTYRegistry struct {
// contains filtered or unexported fields
}
PTYRegistry tracks active PTY sessions.
func NewPTYRegistry ¶
func NewPTYRegistry() *PTYRegistry
func (*PTYRegistry) Add ¶
func (r *PTYRegistry) Add(s *PTYSession) bool
func (*PTYRegistry) CountForUser ¶
func (r *PTYRegistry) CountForUser(userID string) int
CountForUser returns the number of PTY sessions for a given user.
func (*PTYRegistry) Get ¶
func (r *PTYRegistry) Get(id string) *PTYSession
func (*PTYRegistry) IsTombstoned ¶ added in v0.7.34
func (r *PTYRegistry) IsTombstoned(id string) bool
IsTombstoned returns true if the session was recently deleted.
func (*PTYRegistry) ListForUser ¶
func (r *PTYRegistry) ListForUser(userID string) []*PTYSession
ListForUser returns all PTY sessions for a given user.
func (*PTYRegistry) Remove ¶
func (r *PTYRegistry) Remove(id string)
func (*PTYRegistry) SyncFromWing ¶ added in v0.7.32
func (r *PTYRegistry) SyncFromWing(wingID, userID string, sessions []ws.SessionInfo, removeStale bool)
SyncFromWing reconciles the registry with the wing's authoritative session list. When removeStale is true (on-demand requests), removes sessions the wing no longer reports. When false (heartbeat), only adds missing sessions.
type PTYSession ¶
type PTYSession struct {
ID string
WingID string
UserID string
Agent string
CWD string // working directory for this session
Status string // "active", "detached", "exited"
BrowserConn *websocket.Conn
// contains filtered or unexported fields
}
PTYSession tracks a browser <-> wing PTY connection through the relay.
type PostAnchor ¶
type PostParams ¶
type RelayStore ¶
type RelayStore struct {
// contains filtered or unexported fields
}
func OpenRelay ¶
func OpenRelay(dsn string) (*RelayStore, error)
func (*RelayStore) AnchorConnectivity ¶
func (s *RelayStore) AnchorConnectivity() (map[string]map[string]int, error)
AnchorConnectivity returns a connectivity matrix: slug -> {slug -> shared_post_count}. Two anchors are connected when they share posts via post_anchors. Only considers posts from the last 30 days.
func (*RelayStore) AnchorMasses ¶
func (s *RelayStore) AnchorMasses() (map[string]float64, error)
AnchorMasses returns slug -> sum(decayed_mass) for all anchors with posts.
func (*RelayStore) AnchorSlugsForPosts ¶
func (s *RelayStore) AnchorSlugsForPosts(postIDs []string) (map[string][]string, error)
AnchorSlugsForPosts returns a map of postID -> []slug for the given post IDs.
func (*RelayStore) AppendAudit ¶
func (s *RelayStore) AppendAudit(userID, event string, detail *string) error
func (*RelayStore) AssignPostAnchors ¶
func (s *RelayStore) AssignPostAnchors(postID string, assignments []PostAnchor) error
func (*RelayStore) CheckRateLimit ¶
func (s *RelayStore) CheckRateLimit(userID, action string, isPro bool) (bool, error)
func (*RelayStore) ClaimDeviceCode ¶
func (s *RelayStore) ClaimDeviceCode(code, userID string) error
func (*RelayStore) Close ¶
func (s *RelayStore) Close() error
func (*RelayStore) CommentCountsForPosts ¶
func (s *RelayStore) CommentCountsForPosts(postIDs []string) (map[string]int, error)
CommentCountsForPosts returns a map of postID -> comment count.
func (*RelayStore) ConsumeMagicLink ¶
func (s *RelayStore) ConsumeMagicLink(token string) (string, error)
func (*RelayStore) CountPostsByAnchor ¶
func (s *RelayStore) CountPostsByAnchor(anchorID string) (int, error)
func (*RelayStore) CreateComment ¶
func (s *RelayStore) CreateComment(c *SocialComment) error
func (*RelayStore) CreateDeviceCode ¶
func (s *RelayStore) CreateDeviceCode(code, userCode, deviceID string, expiresAt time.Time) error
func (*RelayStore) CreateDeviceCodeWithKey ¶
func (s *RelayStore) CreateDeviceCodeWithKey(code, userCode, deviceID, publicKey string, expiresAt time.Time) error
func (*RelayStore) CreateDeviceToken ¶
func (s *RelayStore) CreateDeviceToken(token, userID, deviceID string, expiresAt *time.Time) error
func (*RelayStore) CreateLocalUser ¶ added in v0.7.4
func (s *RelayStore) CreateLocalUser() (*SocialUser, string, error)
CreateLocalUser creates the local-mode user and a non-expiring device token. Returns the social user, device token string, and whether the user already existed.
func (*RelayStore) CreateMagicLink ¶
func (s *RelayStore) CreateMagicLink(id, email, token string, expiresAt time.Time) error
func (*RelayStore) CreateSession ¶
func (s *RelayStore) CreateSession(token, socialUserID string, expiresAt time.Time) error
func (*RelayStore) CreateSkill ¶
func (s *RelayStore) CreateSkill(name, description, category, agent, tags, content, sha256, publisher, sourceURL string, weight int) error
func (*RelayStore) CreateSocialEmbedding ¶
func (s *RelayStore) CreateSocialEmbedding(e *SocialEmbedding) error
func (*RelayStore) CreateSocialUserDev ¶
func (s *RelayStore) CreateSocialUserDev() (*SocialUser, error)
CreateSocialUserDev creates a dev-mode social user if one doesn't exist.
func (*RelayStore) CreateUser ¶
func (s *RelayStore) CreateUser(id string) error
func (*RelayStore) DB ¶
func (s *RelayStore) DB() *sql.DB
DB returns the underlying database connection.
func (*RelayStore) DecayMasses ¶
func (s *RelayStore) DecayMasses() error
func (*RelayStore) DeleteSession ¶
func (s *RelayStore) DeleteSession(token string) error
func (*RelayStore) DeleteSkill ¶
func (s *RelayStore) DeleteSkill(name string) error
func (*RelayStore) DeleteToken ¶
func (s *RelayStore) DeleteToken(token string) error
func (*RelayStore) DequeueTask ¶
func (s *RelayStore) DequeueTask(taskID string) error
DequeueTask deletes a task from the queue after dispatch.
func (*RelayStore) EnqueueTask ¶
func (s *RelayStore) EnqueueTask(t *ws.QueuedTask) error
EnqueueTask stores a task in the offline queue. The payload is opaque JSON forwarded to the wing as-is — the relay never inspects it.
func (*RelayStore) ExportPosts ¶
func (s *RelayStore) ExportPosts() ([]ExportPost, error)
ExportPosts returns all visible posts with their embeddings and anchor assignments.
func (*RelayStore) ExportVotesAndComments ¶
func (s *RelayStore) ExportVotesAndComments(since time.Time) ([]ExportVote, []ExportComment, error)
ExportVotesAndComments returns votes and comments since the given time, keyed by post link.
func (*RelayStore) GetDeviceCode ¶
func (s *RelayStore) GetDeviceCode(code string) (*DeviceCodeRow, error)
func (*RelayStore) GetDeviceCodeByUserCode ¶
func (s *RelayStore) GetDeviceCodeByUserCode(userCode string) (*DeviceCodeRow, error)
GetDeviceCodeByUserCode finds a device code by user_code.
func (*RelayStore) GetOrCreateSocialUserByEmail ¶
func (s *RelayStore) GetOrCreateSocialUserByEmail(email string) (*SocialUser, error)
func (*RelayStore) GetRelayConfig ¶
func (s *RelayStore) GetRelayConfig(key string) (string, error)
GetRelayConfig reads a value from the relay_config table.
func (*RelayStore) GetSession ¶
func (s *RelayStore) GetSession(token string) (*SocialUser, error)
func (*RelayStore) GetSocialEmbedding ¶
func (s *RelayStore) GetSocialEmbedding(id string) (*SocialEmbedding, error)
func (*RelayStore) GetSocialEmbeddingByLink ¶
func (s *RelayStore) GetSocialEmbeddingByLink(link string) (*SocialEmbedding, error)
func (*RelayStore) GetSocialEmbeddingBySlug ¶
func (s *RelayStore) GetSocialEmbeddingBySlug(slug string) (*SocialEmbedding, error)
func (*RelayStore) GetSocialUser ¶
func (s *RelayStore) GetSocialUser(id string) (*SocialUser, error)
func (*RelayStore) GetSocialUserByProvider ¶
func (s *RelayStore) GetSocialUserByProvider(provider, providerID string) (*SocialUser, error)
func (*RelayStore) GetUpvoteCount ¶
func (s *RelayStore) GetUpvoteCount(postID string) (int, error)
func (*RelayStore) ListAllPosts ¶
func (s *RelayStore) ListAllPosts(sort string, limit int) ([]*SocialEmbedding, error)
ListAllPosts returns all visible posts ordered by the given sort. sort: "hot" (default, live decay), "new", "week", "month", "year".
func (*RelayStore) ListAnchors ¶
func (s *RelayStore) ListAnchors() ([]*SocialEmbedding, error)
func (*RelayStore) ListAnchorsForEmbedder ¶
func (s *RelayStore) ListAnchorsForEmbedder(embedderName string) ([]AnchorEmbedding, error)
ListAnchorsForEmbedder returns visible anchors with centroids for the given embedder.
func (*RelayStore) ListCommentsByPost ¶
func (s *RelayStore) ListCommentsByPost(postID string) ([]*SocialComment, error)
func (*RelayStore) ListPendingTasks ¶
func (s *RelayStore) ListPendingTasks(userID string) ([]*ws.QueuedTask, error)
ListPendingTasks returns queued tasks for a user that haven't been dispatched.
func (*RelayStore) ListPostsByAnchor ¶
func (s *RelayStore) ListPostsByAnchor(anchorID, sort string, limit int) ([]*SocialEmbedding, error)
func (*RelayStore) ListSkills ¶
func (s *RelayStore) ListSkills(category string) ([]*SkillRow, error)
func (*RelayStore) RefreshUpvotes24h ¶
func (s *RelayStore) RefreshUpvotes24h() error
func (*RelayStore) SearchSkills ¶
func (s *RelayStore) SearchSkills(query string) ([]*SkillRow, error)
func (*RelayStore) SetRelayConfig ¶
func (s *RelayStore) SetRelayConfig(key, value string) error
SetRelayConfig writes a value to the relay_config table.
func (*RelayStore) SumDecayedMassByAnchor ¶
func (s *RelayStore) SumDecayedMassByAnchor(anchorID string) (float64, error)
func (*RelayStore) ToggleUpvote ¶
func (s *RelayStore) ToggleUpvote(userID, postID string) (bool, error)
ToggleUpvote inserts if not exists, deletes if exists. Returns true if now upvoted.
func (*RelayStore) TopPostsByAnchor ¶
func (s *RelayStore) TopPostsByAnchor() (map[string]topPost, error)
TopPostsByAnchor returns a map of anchorID -> top post (title + text + link) by highest decayed_mass.
func (*RelayStore) UpdateAnchorCentroid ¶
func (s *RelayStore) UpdateAnchorCentroid(anchorID string, centroid512 []byte) error
func (*RelayStore) UpdateAnchorEffective ¶
func (s *RelayStore) UpdateAnchorEffective(anchorID string, effective512 []byte) error
func (*RelayStore) UpsertAnchorEmbedding ¶
func (s *RelayStore) UpsertAnchorEmbedding(anchorID, embedderName string, centroid512 []byte) error
UpsertAnchorEmbedding inserts or updates a per-embedder centroid for an anchor.
func (*RelayStore) UpsertSocialUser ¶
func (s *RelayStore) UpsertSocialUser(u *SocialUser) error
func (*RelayStore) Upvote ¶
func (s *RelayStore) Upvote(userID, postID string) error
func (*RelayStore) UserUpvotesForPosts ¶
UserUpvotesForPosts returns the set of post IDs the user has upvoted from the given list.
func (*RelayStore) ValidateToken ¶
func (s *RelayStore) ValidateToken(token string) (userID string, deviceID string, err error)
type Server ¶
type Server struct {
Store *RelayStore
Embedder embedding.Embedder
Config ServerConfig
DevTemplateDir string // if set, re-read templates from disk on each request
DevMode bool // if set, auto-claim device codes with test-user
LocalMode bool // if set, bypass auth — single-user, zero-config
Wings *WingRegistry
PTY *PTYRegistry
Chat *ChatRegistry
Bandwidth *BandwidthMeter
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(store *RelayStore, cfg ServerConfig) *Server
func (*Server) SetLocalUser ¶ added in v0.7.4
func (s *Server) SetLocalUser(u *SocialUser)
type ServerConfig ¶
type ServerConfig struct {
BaseURL string
AppHost string // e.g. "app.wingthing.ai" — serve SPA at root
WSHost string // e.g. "ws.wingthing.ai" — WebSocket only
JWTSecret string // base64-encoded; overrides DB-stored secret
GitHubClientID string
GitHubClientSecret string
SMTPHost string
SMTPPort string
SMTPUser string
SMTPPass string
SMTPFrom string
}
type SocialComment ¶
type SocialEmbedding ¶
type SocialEmbedding struct {
ID string
UserID string
Link *string
Text string
Title *string
Centerpoint *string
Slug *string
Embedding []byte // raw float32 blob
Embedding512 []byte
Centroid512 []byte
Effective512 []byte
Kind string // "post", "subscription", "anchor", "antispam"
Visible bool
Mass int
Upvotes24h int
DecayedMass float64
Swallowed bool
CreatedAt time.Time
UpdatedAt time.Time
PublishedAt *time.Time
}
func CreatePost ¶
func CreatePost(store *RelayStore, emb embedding.Embedder, p PostParams) (*SocialEmbedding, error)
CreatePost embeds text, assigns to anchors by cosine similarity, and stores the post. URL dedup: if Link is non-empty and already exists, returns the existing post (no duplicate). It uses per-embedder centroids from anchor_embeddings when available, falling back to the legacy embedding_512 column on social_embeddings.
type SocialUser ¶
type WingClaims ¶
type WingClaims struct {
jwt.RegisteredClaims
PublicKey string `json:"pub,omitempty"`
MachineID string `json:"machine,omitempty"`
}
WingClaims are the JWT claims for a wing connection.
func ValidateWingJWT ¶
func ValidateWingJWT(secret []byte, tokenString string) (*WingClaims, error)
ValidateWingJWT verifies a JWT and returns the claims.
type WingEvent ¶ added in v0.7.5
type WingEvent struct {
Type string `json:"type"` // "wing.online" or "wing.offline"
WingID string `json:"wing_id"`
MachineID string `json:"machine_id"`
Platform string `json:"platform,omitempty"`
Agents []string `json:"agents,omitempty"`
Labels []string `json:"labels,omitempty"`
PublicKey string `json:"public_key,omitempty"`
Projects []ws.WingProject `json:"projects,omitempty"`
}
WingEvent is sent to dashboard subscribers when a wing connects or disconnects.
type WingRegistry ¶
type WingRegistry struct {
// contains filtered or unexported fields
}
WingRegistry tracks all connected wings.
func NewWingRegistry ¶
func NewWingRegistry() *WingRegistry
func (*WingRegistry) Add ¶
func (r *WingRegistry) Add(w *ConnectedWing)
func (*WingRegistry) CountForUser ¶
func (r *WingRegistry) CountForUser(userID string) int
CountForUser returns the number of wings connected for a given user.
func (*WingRegistry) FindByID ¶
func (r *WingRegistry) FindByID(wingID string) *ConnectedWing
func (*WingRegistry) FindByIdentity ¶
func (r *WingRegistry) FindByIdentity(identity string) *ConnectedWing
func (*WingRegistry) FindForUser ¶
func (r *WingRegistry) FindForUser(userID string) *ConnectedWing
func (*WingRegistry) ListForUser ¶
func (r *WingRegistry) ListForUser(userID string) []*ConnectedWing
ListForUser returns all wings connected for a given user.
func (*WingRegistry) RegisterDirRequest ¶ added in v0.6.3
func (r *WingRegistry) RegisterDirRequest(reqID string, ch chan *ws.DirResults)
func (*WingRegistry) RegisterSessionRequest ¶ added in v0.7.32
func (r *WingRegistry) RegisterSessionRequest(reqID string, ch chan *ws.SessionsSync)
func (*WingRegistry) Remove ¶
func (r *WingRegistry) Remove(id string)
func (*WingRegistry) ResolveDirRequest ¶ added in v0.6.3
func (r *WingRegistry) ResolveDirRequest(reqID string, results *ws.DirResults)
func (*WingRegistry) ResolveSessionRequest ¶ added in v0.7.32
func (r *WingRegistry) ResolveSessionRequest(reqID string, results *ws.SessionsSync)
func (*WingRegistry) Subscribe ¶ added in v0.7.5
func (r *WingRegistry) Subscribe(userID string, ch chan WingEvent)
func (*WingRegistry) Touch ¶
func (r *WingRegistry) Touch(wingID string)
func (*WingRegistry) UnregisterDirRequest ¶ added in v0.6.3
func (r *WingRegistry) UnregisterDirRequest(reqID string)
func (*WingRegistry) UnregisterSessionRequest ¶ added in v0.7.32
func (r *WingRegistry) UnregisterSessionRequest(reqID string)
func (*WingRegistry) Unsubscribe ¶ added in v0.7.5
func (r *WingRegistry) Unsubscribe(userID string, ch chan WingEvent)