ChannelRouter to enforce policy and concurrency, while the ConnectorSupervisor manages the lifecycle of individual platform adapters.
Connector Framework
The connector framework is built around a provider-adapter pattern. Each external service is implemented as aConnectorAdapter that handles the translation between Palyra’s internal message envelopes and the third-party API payloads.
Key Components
| Component | Responsibility |
|---|---|
ConnectorAdapter | Trait defining how to send outbound messages and report availability. crates/palyra-connectors/src/connectors/echo.rs#34-76 |
ConnectorSupervisor | Manages the lifecycle, restarts, and health monitoring of active connector instances. crates/palyra-connectors/src/lib.rs#7-11 |
ConnectorInstanceRecord | Persistence model for a configured connector, including auth profiles and readiness state. crates/palyra-connectors/src/connectors/echo.rs#105-123 |
InboundMessage | A normalized representation of a message received from an external platform. crates/palyra-daemon/src/channel_router.rs#215-227 |
System Entity Mapping
The following diagram illustrates how high-level connector concepts map to specific code entities within thepalyra-connectors and palyra-daemon crates.
Sources: crates/palyra-connectors/src/lib.rs#1-12, crates/palyra-daemon/src/channel_router.rs#215-230
Channel Router and Policy
TheChannelRouter acts as the central traffic controller for all inbound and outbound communication. It is responsible for enforcing ChannelRoutingRule configurations, which determine which users can interact with the daemon and how conversations are isolated.
Routing and Pairing Logic
- Concurrency Control: The router enforces
concurrency_limitper channel to prevent overwhelming the daemon’s reasoning engine. crates/palyra-daemon/src/channel_router.rs#174-174 - Direct Message (DM) Policy: Supports three modes:
Deny,Allow, andPairing. crates/palyra-daemon/src/channel_router.rs#57-61 - Pairing Workflow: When
DirectMessagePolicy::Pairingis active, users must provide aPairingCodeRecordto establish a session. crates/palyra-daemon/src/channel_router.rs#85-91 - Broadcast Strategy: Controls whether the daemon can use mass mentions like
@everyoneor@here. crates/palyra-daemon/src/channel_router.rs#28-32
Message Lifecycle
When a message enters the system, it passes through a validation and routing pipeline before reaching the agent runtime. Sources: crates/palyra-connectors/src/connectors/echo.rs#43-75, crates/palyra-daemon/src/channel_router.rs#215-240Supported Connectors
- Discord: A full-featured integration supporting webhooks, slash commands, and complex embeds.
- Echo: An internal testing connector used for simulating message flows and verifying idempotency. crates/palyra-connectors/src/connectors/echo.rs#21-24
- Slack/Telegram: Standard adapters following the
ConnectorKindspecification.