Documentation
¶
Overview ¶
Package daemon provides the AgentComms daemon configuration.
Package daemon provides the AgentComms daemon that serves as the communication hub.
Index ¶
- Constants
- func DefaultSocketPath() string
- func IsDaemonRunning(socketPath string) bool
- type AgentConfig
- type AgentInfo
- type AgentMessageParams
- type AgentMessageResult
- type AgentsResult
- type ChannelInfo
- type ChannelMapping
- type ChannelsResult
- type ChatConfig
- type ChatSender
- type Client
- func (c *Client) AgentMessage(_ context.Context, fromAgentID, toAgentID, message string) (*AgentMessageResult, error)
- func (c *Client) Agents(_ context.Context) (*AgentsResult, error)
- func (c *Client) Channels(_ context.Context) (*ChannelsResult, error)
- func (c *Client) Close() error
- func (c *Client) Connect() error
- func (c *Client) Events(_ context.Context, agentID string, limit int) (*EventsResult, error)
- func (c *Client) EventsSince(_ context.Context, agentID, sinceID string, limit int) (*EventsResult, error)
- func (c *Client) Interrupt(_ context.Context, agentID, reason string) (*InterruptResult, error)
- func (c *Client) IsConnected() bool
- func (c *Client) Ping(_ context.Context) error
- func (c *Client) Reply(_ context.Context, channelID, message, agentID string) (*ReplyResult, error)
- func (c *Client) Send(_ context.Context, agentID, message string) (*SendResult, error)
- func (c *Client) Status(_ context.Context) (*StatusResult, error)
- type Config
- type Daemon
- type DaemonConfig
- type DiscordConfig
- type ErrorInfo
- type EventInfo
- type EventsParams
- type EventsResult
- type InterruptParams
- type InterruptResult
- type PingResult
- type ReplyParams
- type ReplyResult
- type Request
- type Response
- type SendParams
- type SendResult
- type Server
- type ServerConfig
- type StatusResult
- type TelegramConfig
- type WhatsAppConfig
Constants ¶
const ( ErrCodeInvalidRequest = -32600 ErrCodeMethodNotFound = -32601 ErrCodeInvalidParams = -32602 ErrCodeInternal = -32603 ErrCodeNotFound = -32604 )
Error codes.
const ( MethodPing = "ping" MethodStatus = "status" MethodAgents = "agents" MethodSend = "send" MethodInterrupt = "interrupt" MethodEvents = "events" MethodReply = "reply" MethodChannels = "channels" MethodAgentMessage = "agent_message" )
Method names.
Variables ¶
This section is empty.
Functions ¶
func DefaultSocketPath ¶
func DefaultSocketPath() string
DefaultSocketPath returns the default socket path.
func IsDaemonRunning ¶
IsDaemonRunning checks if the daemon is running by attempting to connect.
Types ¶
type AgentConfig ¶
type AgentConfig struct {
// ID is the unique agent identifier.
ID string `yaml:"id"`
// Type is the agent type (tmux, process).
Type string `yaml:"type"`
// TmuxSession is the tmux session name (for type=tmux).
TmuxSession string `yaml:"tmux_session"`
// TmuxPane is the tmux pane identifier (for type=tmux).
TmuxPane string `yaml:"tmux_pane"`
}
AgentConfig defines an agent and its tmux target.
type AgentInfo ¶
type AgentInfo struct {
ID string `json:"id"`
Type string `json:"type"`
Target string `json:"target"` // e.g., "tmux:session:pane"
Status string `json:"status"` // "online" or "offline"
}
AgentInfo contains information about a registered agent.
type AgentMessageParams ¶
type AgentMessageParams struct {
// FromAgentID is the source agent sending the message.
FromAgentID string `json:"from_agent_id"`
// ToAgentID is the destination agent to receive the message.
ToAgentID string `json:"to_agent_id"`
// Message is the text content to send.
Message string `json:"message"`
}
AgentMessageParams are the parameters for the agent_message method. This sends a message FROM one agent TO another agent.
type AgentMessageResult ¶
type AgentMessageResult struct {
EventID string `json:"event_id"`
Delivered bool `json:"delivered"`
}
AgentMessageResult is the response for the agent_message method.
type AgentsResult ¶
type AgentsResult struct {
Agents []AgentInfo `json:"agents"`
}
AgentsResult is the response for the agents method.
type ChannelInfo ¶
type ChannelInfo struct {
ChannelID string `json:"channel_id"`
AgentID string `json:"agent_id"`
Provider string `json:"provider"`
}
ChannelInfo contains information about a mapped channel.
type ChannelMapping ¶
type ChannelMapping struct {
// ChannelID is the full channel identifier (provider:chatid).
ChannelID string `yaml:"channel_id"`
// AgentID is the target agent ID.
AgentID string `yaml:"agent_id"`
}
ChannelMapping maps a chat channel to an agent. ChannelID format: "provider:chatid" (e.g., "discord:123456789")
type ChannelsResult ¶
type ChannelsResult struct {
Channels []ChannelInfo `json:"channels"`
}
ChannelsResult is the response for the channels method.
type ChatConfig ¶
type ChatConfig struct {
// Discord configuration (optional).
Discord *DiscordConfig `yaml:"discord"`
// Telegram configuration (optional).
Telegram *TelegramConfig `yaml:"telegram"`
// WhatsApp configuration (optional).
WhatsApp *WhatsAppConfig `yaml:"whatsapp"`
// Channels maps chat channels to agents.
Channels []ChannelMapping `yaml:"channels"`
}
ChatConfig holds configuration for all chat providers.
type ChatSender ¶
ChatSender is the interface for sending outbound chat messages.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides access to the daemon via Unix socket.
func DefaultClient ¶
func DefaultClient() *Client
DefaultClient creates a client using the default socket path.
func (*Client) AgentMessage ¶
func (c *Client) AgentMessage(_ context.Context, fromAgentID, toAgentID, message string) (*AgentMessageResult, error)
AgentMessage sends a message from one agent to another.
func (*Client) Agents ¶
func (c *Client) Agents(_ context.Context) (*AgentsResult, error)
Agents returns the list of registered agents.
func (*Client) Channels ¶
func (c *Client) Channels(_ context.Context) (*ChannelsResult, error)
Channels returns the list of mapped channels.
func (*Client) EventsSince ¶
func (c *Client) EventsSince(_ context.Context, agentID, sinceID string, limit int) (*EventsResult, error)
EventsSince returns events after a specific event ID.
func (*Client) IsConnected ¶
IsConnected returns true if connected to the daemon.
type Config ¶
type Config struct {
// DataDir is the directory for storing data (default: ~/.agentcomms).
DataDir string
// SocketPath is the Unix socket path for IPC.
SocketPath string
// Logger is the structured logger.
Logger *slog.Logger
}
Config holds daemon configuration.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default daemon configuration.
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon is the AgentComms communication hub.
func (*Daemon) Chat ¶
func (d *Daemon) Chat() *transport.ChatTransport
Chat returns the chat transport for outbound messages.
type DaemonConfig ¶
type DaemonConfig struct {
// DataDir overrides the default data directory.
DataDir string `yaml:"data_dir"`
// LogLevel sets the logging level (debug, info, warn, error).
LogLevel string `yaml:"log_level"`
// Agents defines the available agents.
Agents []AgentConfig `yaml:"agents"`
// Chat holds chat provider configuration (omnichat).
Chat *ChatConfig `yaml:"chat"`
}
DaemonConfig holds the daemon configuration loaded from config.yaml.
func DefaultDaemonConfig ¶
func DefaultDaemonConfig() *DaemonConfig
DefaultDaemonConfig returns a DaemonConfig with sensible defaults.
func LoadDaemonConfig ¶
func LoadDaemonConfig(dataDir string) (*DaemonConfig, error)
LoadDaemonConfig loads configuration from the config file. It looks for config.yaml in the data directory.
func (*DaemonConfig) FindAgentByChannel ¶
func (c *DaemonConfig) FindAgentByChannel(channelID string) (string, bool)
FindAgentByChannel returns the agent ID for a chat channel. channelID format: "provider:chatid" (e.g., "discord:123456789")
func (*DaemonConfig) GetAgent ¶
func (c *DaemonConfig) GetAgent(id string) (*AgentConfig, bool)
GetAgent returns the agent config by ID.
func (*DaemonConfig) HasChatProviders ¶
func (c *DaemonConfig) HasChatProviders() bool
HasChatProviders returns true if any chat provider is configured.
func (*DaemonConfig) Validate ¶
func (c *DaemonConfig) Validate() error
Validate checks the configuration for errors.
type DiscordConfig ¶
type DiscordConfig struct {
// Token is the Discord bot token.
Token string `yaml:"token"`
// GuildID is the Discord guild (server) ID for filtering.
GuildID string `yaml:"guild_id"`
}
DiscordConfig holds Discord-specific configuration.
type EventInfo ¶
type EventInfo struct {
ID string `json:"id"`
AgentID string `json:"agent_id"`
ChannelID string `json:"channel_id"`
Type string `json:"type"`
Role string `json:"role"`
Timestamp time.Time `json:"timestamp"`
Status string `json:"status"`
Payload map[string]any `json:"payload"`
}
EventInfo contains information about an event.
type EventsParams ¶
type EventsParams struct {
AgentID string `json:"agent_id"`
Limit int `json:"limit,omitempty"`
Since string `json:"since,omitempty"` // Event ID to start after
}
EventsParams are the parameters for the events method.
type EventsResult ¶
type EventsResult struct {
Events []EventInfo `json:"events"`
}
EventsResult is the response for the events method.
type InterruptParams ¶
type InterruptParams struct {
AgentID string `json:"agent_id"`
Reason string `json:"reason,omitempty"`
}
InterruptParams are the parameters for the interrupt method.
type InterruptResult ¶
InterruptResult is the response for the interrupt method.
type PingResult ¶
type PingResult struct {
Pong bool `json:"pong"`
}
PingResult is the response for the ping method.
type ReplyParams ¶
type ReplyParams struct {
// ChannelID is the target channel (format: "provider:chatid").
ChannelID string `json:"channel_id"`
// Message is the text to send.
Message string `json:"message"`
// AgentID is the agent sending the message (for event tracking).
AgentID string `json:"agent_id,omitempty"`
}
ReplyParams are the parameters for the reply method. This sends a message FROM an agent TO a chat channel.
type ReplyResult ¶
ReplyResult is the response for the reply method.
type Request ¶
type Request struct {
// ID is a unique request identifier for correlation.
ID string `json:"id"`
// Method is the RPC method name.
Method string `json:"method"`
// Params contains method-specific parameters.
Params json.RawMessage `json:"params,omitempty"`
}
Request represents a client request to the daemon.
func NewRequest ¶
NewRequest creates a new request with the given method and params.
func (*Request) ParseParams ¶
ParseParams unmarshals request params into the target struct.
type Response ¶
type Response struct {
// ID matches the request ID.
ID string `json:"id"`
// Result contains the method result (on success).
Result json.RawMessage `json:"result,omitempty"`
// Error contains error details (on failure).
Error *ErrorInfo `json:"error,omitempty"`
}
Response represents a daemon response to a client.
func NewErrorResponse ¶
NewErrorResponse creates an error response.
func NewResponse ¶
NewResponse creates a successful response.
func (*Response) ParseResult ¶
ParseResult unmarshals response result into the target struct.
type SendParams ¶
SendParams are the parameters for the send method.
type SendResult ¶
SendResult is the response for the send method.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server handles IPC requests over a Unix socket.
type ServerConfig ¶
type ServerConfig struct {
SocketPath string
Client *ent.Client
Router *router.Router
DaemonCfg *DaemonConfig
ChatSender ChatSender
Providers []string
Logger *slog.Logger
}
ServerConfig holds server configuration.
type StatusResult ¶
type StatusResult struct {
Running bool `json:"running"`
StartedAt time.Time `json:"started_at"`
Agents int `json:"agents"`
Providers []string `json:"providers"`
}
StatusResult is the response for the status method.
type TelegramConfig ¶
type TelegramConfig struct {
// Token is the Telegram bot token.
Token string `yaml:"token"`
}
TelegramConfig holds Telegram-specific configuration.
type WhatsAppConfig ¶
type WhatsAppConfig struct {
// DBPath is the SQLite database path for session storage.
DBPath string `yaml:"db_path"`
}
WhatsAppConfig holds WhatsApp-specific configuration.