Skip to main content
The Palyra CLI (palyra) is the primary interface for operators to manage both local and remote runtimes. It serves as a unified entry point for bootstrapping installations, performing diagnostics, managing automation routines, and interacting with the core daemon via gRPC and REST transports. The CLI is built using clap for command-line argument parsing and uses a hierarchical dispatch pattern to route commands to specific handler functions located in the crates/palyra-cli/src/commands/ directory.

CLI Architecture & Dispatch Flow

The CLI follows a strict separation between argument definition (args/) and execution logic (commands/).
  1. Parsing: clap parses the command line into the Cli struct defined in crates/palyra-cli/src/args/mod.rs.
  2. Context Resolution: The app::current_root_context() is used to resolve configuration paths, state roots, and identity crates/palyra-cli/src/commands/memory.rs#5-6.
  3. Dispatch: The main function (via lib.rs) matches the parsed CliCommand and calls the corresponding run_ function crates/palyra-cli/src/lib.rs#77-90.
  4. Transport: Commands either perform local filesystem operations (e.g., backup, setup) or connect to the daemon using AgentConnection for gRPC or ConsoleApiClient for REST crates/palyra-cli/src/commands/memory.rs#16-21, crates/palyra-cli/src/commands/system.rs#16-17.

Command Dispatch Mapping

Command FamilyPrimary PurposeImplementation Module
setup / initBootstrap and installationcommands::setup, commands::init
gateway / daemonRuntime lifecycle & statuscommands::gateway, commands::daemon
acpAgent Control Protocol bridgecommands::acp
doctorDiagnostics and repaircommands::doctor
routines / cronAutomation and schedulingcommands::routines, commands::cron
memoryVector/lexical search managementcommands::memory
skillsWASM plugin managementcommands::skills
systemHeartbeat and event logscommands::system
Sources: crates/palyra-cli/src/args/mod.rs#1-44, crates/palyra-cli/src/commands/mod.rs#1-50, crates/palyra-cli/tests/help_snapshots/root-help-unix.txt#1-54

Core Command Reference

Setup & Onboarding

The setup command (aliased to init) is the entry point for creating a new Palyra installation. It supports local and remote modes and can trigger a wizard for interactive configuration crates/palyra-cli/src/args/mod.rs#144-152.

Gateway & Daemon

Provides administrative access to the palyrad process.
  • gateway status: Checks connectivity across HTTP and gRPC surfaces crates/palyra-cli/src/args/mod.rs#172-185.
  • gateway usage-cost: Aggregates token usage from the journal.
  • gateway admin-status: Detailed health metrics requiring an admin token.
Interacts with the MemoryService to manage the daemon’s long-term memory. Memory Command Flow

Skills & Plugins

Manages the lifecycle of WASM-based skills.

System & Diagnostics

Observability tools for the runtime.

Backup & Recovery

Handles portable state management.

CLI Entity Mapping

This diagram maps CLI user-facing concepts to the internal code structures and protocols. Sources: crates/palyra-cli/src/lib.rs#15-59, crates/palyra-cli/src/commands/system.rs#16-21, crates/palyra-cli/src/commands/memory.rs#25-34

Global Options & Environment

The CLI supports global flags that modify the behavior of all subcommands:
OptionEnvironment VariableDescription
--configPALYRA_CONFIGPath to palyra.toml
--profilePALYRA_PROFILESelects a specific configuration profile
--state-rootPALYRA_STATE_ROOTOverride for data/identity storage
--output-formatN/Atext, json, or ndjson crates/palyra-cli/tests/help_snapshots/root-help-unix.txt#73-75
-v, -vvRUST_LOGIncreases verbosity (debug, trace) crates/palyra-cli/tests/help_snapshots/root-help-unix.txt#66-67
Sources: crates/palyra-cli/src/args/mod.rs#59-80, crates/palyra-cli/tests/help_snapshots/root-help-unix.txt#59-80