- Add OAuth 2.1 identity provider with PKCE S256 (ory/fosite) - Add RFC 7591 dynamic client registration for MCP clients - Add RFC 8414 OAuth metadata discovery endpoint - Add branded OAuth login/authorize pages with SynapBus design - Add SYNAPBUS_BASE_URL env var for remote/LAN deployments - Add OAuth bearer token authentication for MCP connections - Add dead letter queue with Web UI management page - Add channel leave, member list, and improved channel management - Add agent auth middleware for MCP-authenticated requests - Add console printer for structured server startup output - Hide human accounts from agent management UI - Fix SSE through middleware (Flush/Unwrap support) - Fix graceful shutdown by closing SSE clients before server stop - Fix localhost/127.0.0.1 redirect URI normalization for OAuth - Remove agent self-registration MCP tools (manage via Web UI only) - Update README with OAuth setup guide and MCP client config example Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
67 lines
2.4 KiB
Go
67 lines
2.4 KiB
Go
// Package messaging provides core messaging types and services for SynapBus.
|
|
package messaging
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
)
|
|
|
|
// Message status constants.
|
|
const (
|
|
StatusPending = "pending"
|
|
StatusProcessing = "processing"
|
|
StatusDone = "done"
|
|
StatusFailed = "failed"
|
|
)
|
|
|
|
// Message represents a single message in the system.
|
|
type Message struct {
|
|
ID int64 `json:"id"`
|
|
ConversationID int64 `json:"conversation_id"`
|
|
FromAgent string `json:"from_agent"`
|
|
ToAgent string `json:"to_agent,omitempty"`
|
|
ChannelID *int64 `json:"channel_id,omitempty"`
|
|
ReplyTo *int64 `json:"reply_to,omitempty"`
|
|
Body string `json:"body"`
|
|
Priority int `json:"priority"`
|
|
Status string `json:"status"`
|
|
Metadata json.RawMessage `json:"metadata"`
|
|
ClaimedBy string `json:"claimed_by,omitempty"`
|
|
ClaimedAt *time.Time `json:"claimed_at,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// Conversation groups related messages into a thread.
|
|
type Conversation struct {
|
|
ID int64 `json:"id"`
|
|
Subject string `json:"subject"`
|
|
CreatedBy string `json:"created_by"`
|
|
ChannelID *int64 `json:"channel_id,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// DeadLetter represents an undeliverable message captured when an agent is deleted.
|
|
type DeadLetter struct {
|
|
ID int64 `json:"id"`
|
|
OwnerID int64 `json:"owner_id"`
|
|
OriginalMessageID int64 `json:"original_message_id"`
|
|
ToAgent string `json:"to_agent"`
|
|
FromAgent string `json:"from_agent"`
|
|
Body string `json:"body"`
|
|
Subject string `json:"subject"`
|
|
Priority int `json:"priority"`
|
|
Metadata json.RawMessage `json:"metadata,omitempty"`
|
|
Acknowledged bool `json:"acknowledged"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// InboxState tracks per-agent, per-conversation read position.
|
|
type InboxState struct {
|
|
AgentName string `json:"agent_name"`
|
|
ConversationID int64 `json:"conversation_id"`
|
|
LastReadMessageID int64 `json:"last_read_message_id"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|