Skip to main content
The Connector Framework provides a protocol-agnostic abstraction for integrating Palyra with external chat platforms (Discord, Slack, etc.). It manages the lifecycle of connections, message persistence, and delivery reliability. The ChannelRouter sits atop this framework, implementing concurrency policies, message filtering, and session isolation.

System Architecture

The framework is divided into a core logic layer (palyra-connector-core), a collection of platform-specific adapters (palyra-connectors), and a management layer within the daemon (ChannelPlatform).

Component Interaction

The following diagram illustrates how an inbound message flows from a platform adapter through the supervisor and into the gRPC-backed router. Data Flow: Inbound Message Processing Sources: crates/palyra-connector-core/src/supervisor.rs#128-134, crates/palyra-daemon/src/channels.rs#125-132

Connector Supervisor and Storage

The ConnectorSupervisor is the central orchestrator for all connector instances. It uses a ConnectorStore (backed by SQLite) to persist message state, ensuring that outbound messages are not lost during restarts.

Key Responsibilities

Reliability and Dead Letter Queue

If a message fails to deliver after the maximum number of retries (default 5), it is moved to a Dead Letter Queue (DLQ). Sources: crates/palyra-connector-core/src/supervisor.rs#194-214, crates/palyra-connectors/src/lib.rs#2-12

ChannelRouter and Concurrency Policies

The ChannelRouter (implemented in palyra-daemon) defines how Palyra interacts with specific channels. It handles security, session management, and rate limiting.

Concurrency Policies

The router manages how multiple simultaneous requests to the same channel are handled via concurrency_limit crates/palyra-daemon/src/channel_router.rs#174-174. While the codebase supports various strategies, the primary mechanism is the ChannelRoutingRule.

Routing Rules

Each channel can be configured with a ChannelRoutingRule crates/palyra-daemon/src/channel_router.rs#161-175:
FieldDescription
mention_patternsRegex/Strings that trigger the agent.
isolate_session_by_senderIf true, every user in a channel gets a private session.
direct_message_policyControls DM access: Deny, Allow, or Pairing.
broadcast_strategyControls @everyone / @here usage: Deny, MentionOnly, Allow.

Broadcast Strategies

The BroadcastStrategy enum crates/palyra-daemon/src/channel_router.rs#28-32 prevents agents from accidentally spamming entire servers:
  • Deny: All mass mentions are stripped.
  • MentionOnly: Only specific mentions are allowed.
  • Allow: Full broadcast capability.
Sources: crates/palyra-daemon/src/channel_router.rs#161-192, crates/palyra-daemon/src/channel_router.rs#28-53

Protocol Abstraction

The framework uses a clean separation between the daemon’s internal logic and the external platform protocols.

palyra-connector-core

Contains the traits and base structures:

palyra-connectors

Contains the concrete adapters: Sources: crates/palyra-connectors/Cargo.toml#14-16, crates/palyra-connectors/src/connectors/echo.rs#34-42

Management and Observability

The framework exposes detailed status via the Admin API.

Channel Operations Snapshot

The build_channel_operations_snapshot function aggregates data for the dashboard, including crates/palyra-daemon/src/transport/http/handlers/admin/channels/mod.rs#55-147:
  • Saturation State: Categorizes channel health as healthy, paused, rate_limited, backpressure, or dead_lettered.
  • Queue Metrics: Counts for pending_outbox, due_outbox, and claimed_outbox.
  • Error Tracking: Surfaces the last_permission_failure or last_auth_failure by scanning error logs and DLQ records.

CLI Integration

The palyra channels command provides administrative access to these features: Sources: crates/palyra-daemon/src/transport/http/handlers/admin/channels/mod.rs#29-53, crates/palyra-cli/src/commands/channels/mod.rs#61-205