palyrad daemon is the central orchestrator of the Palyra platform. It manages the lifecycle of AI agent interactions, enforces security policies, maintains long-term memory via a journaled store, and provides the transport layer for both human operators and automated connectors.
Overview and Gateway State
At the heart of the daemon is theGatewayRuntimeState, which acts as the shared memory and coordination point for all active processes. It holds references to the model providers, the policy engine, the tool execution environment, and the active session registry.
Core Components
- GatewayRuntimeState: The primary shared state container used by gRPC and HTTP services crates/palyra-daemon/src/gateway.rs#74-76.
- RunStateMachine: Manages the lifecycle of a single “Run” (an interaction turn), handling transitions from
AcceptedtoRunning,PendingApproval, orCompletedcrates/palyra-daemon/src/gateway.rs#77-77. - JournalStore: A SQLite-backed persistence layer that records every event (the “Orchestrator Tape”) for auditability and state recovery crates/palyra-daemon/src/journal.rs#63-63.
System Architecture Diagram
This diagram illustrates the flow from external inputs through the core daemon’s internal subsystems. Sources: crates/palyra-daemon/src/gateway.rs#40-82, crates/palyra-daemon/src/lib.rs#73-83Major Subsystems
The daemon’s functionality is partitioned into several specialized subsystems, each documented in detail in child pages.Gateway and Session Orchestration
The Orchestrator is responsible for the “Run Loop.” When a message is received viaRouteMessage, the daemon initializes a RunStateMachine. It pulls context from the JournalStore, queries the LLM via the ModelProvider, and executes tools if proposed.
- Key Entity:
OrchestratorTapeRecordcrates/palyra-daemon/src/gateway.rs#69-69. - For details, see Gateway and Session Orchestration.
Journal Store and Persistence
All interactions are persisted in a hash-chained audit log. This ensures that the agent’s “memory” and the operator’s audit trail are immutable and verifiable. It also handles RAG (Retrieval-Augmented Generation) via theMemoryEmbeddingProvider.
- Key Entity:
JournalStorecrates/palyra-daemon/src/journal.rs#63-63. - For details, see Journal Store and Persistence.
HTTP Transport and Admin API
The daemon exposes an Axum-based HTTP server providing RESTful endpoints for the Web Console and administrative tasks. This includes/admin/v1/ for system management and /console/v1/ for operator interactions.
- Key Entity:
build_routercrates/palyra-daemon/src/transport/http/router.rs#17-17. - For details, see HTTP Transport Layer and Admin/Console API.
gRPC and QUIC Transport
For high-performance, bidirectional streaming (such as real-time log tailing or CLI interactions), the daemon uses gRPC over both TCP and QUIC. It supports mTLS for secure node-to-node communication.- Key Entity:
GatewayAuthConfigcrates/palyra-daemon/src/transport/grpc/auth.rs#162-164. - For details, see gRPC and QUIC Transport.
Cron and Background Tasks
The daemon includes a built-in scheduler for recurring tasks, such as periodic skill audits, memory maintenance (vacuuming), and scheduled agent routines.- Key Entity:
spawn_scheduler_loopcrates/palyra-daemon/src/cron.rs#72-72. - For details, see Cron Scheduler and Background Tasks.
Usage Governance
To prevent runaway costs or resource exhaustion, theUsageGovernance subsystem tracks token usage and enforces budget limits per session or principal.
- Key Entity:
OrchestratorUsageDeltacrates/palyra-daemon/src/gateway.rs#70-70. - For details, see Usage Governance and Budget Controls.
Code Entity Map: Request Flow
The following diagram bridges the natural language concept of a “Request” to the specific code entities and files that handle it withinpalyrad.
Sources: crates/palyra-daemon/src/gateway.rs#56-82, crates/palyra-daemon/src/model_provider.rs#176-181, crates/palyra-daemon/src/journal.rs#232-248
Configuration
The daemon is configured via a TOML file (typicallypalyra.toml). The schema is defined by the RootFileConfig struct, which includes sections for gateway, model_provider, storage, and identity.
| Config Section | Purpose | Code Reference |
|---|---|---|
daemon | Network binding and ports | crates/palyra-common/src/daemon_config_schema.rs#92-95 |
gateway | gRPC/QUIC and TLS settings | crates/palyra-common/src/daemon_config_schema.rs#99-112 |
model_provider | LLM API keys and model selection | crates/palyra-common/src/daemon_config_schema.rs#195-212 |
memory | Retention policies and RAG limits | crates/palyra-common/src/daemon_config_schema.rs#145-151 |