Skip to main content
The Palyra CLI (palyra) serves as the primary operator interface for managing both local and remote gateway runtimes. It is built using a deeply nested clap command structure that maps high-level operator intents to gRPC or HTTP/Admin API calls.

CLI Architecture and Command Parsing

The CLI is structured around the Cli struct, which utilizes the clap crate for declarative argument parsing and help generation. The command surface is partitioned into logical domains (e.g., auth, memory, skills) to match the backend’s micro-service architecture.

Root Options and Context

Every command execution is wrapped in a RootOptions context. This context manages global flags such as --config, --profile, and --state-root, which are used to locate the palyra.toml configuration and initialize the transport layer crates/palyra-cli/src/lib.rs#60-100.

Data Flow: Command to Gateway

The CLI typically follows a “Request-Dispatch-Emit” pattern:
  1. Parsing: clap parses arguments into a Command enum crates/palyra-cli/src/args/mod.rs#1-44.
  2. Dispatch: The run_command function (in lib.rs) dispatches to specific command modules crates/palyra-cli/src/commands/mod.rs#1-50.
  3. Execution: The command module establishes a gRPC connection (via tonic) or an Admin API connection (via reqwest) crates/palyra-cli/src/commands/system.rs#15-22.
  4. Output: Results are formatted as human-readable text or structured JSON/NDJSON based on the --output-format flag crates/palyra-cli/src/output/skills.rs#4-23.

Code Entity Mapping: Command Dispatch

The following diagram illustrates how the CLI translates a user string into a code execution path. CLI Dispatch Pipeline Sources: crates/palyra-cli/src/lib.rs#76-90, crates/palyra-cli/src/commands/memory.rs#4-22, crates/palyra-cli/src/commands/system.rs#10-22.

Core Command Surface

Setup and Onboarding

The setup (alias init) and onboarding commands manage the initial bootstrap of the environment. This includes generating TLS certificates, initializing the SQLite journal, and configuring the RootFileConfig crates/palyra-cli/src/commands/operator_wizard.rs#239-250.

Memory and RAG Operations

The memory command interacts with the MemoryServiceClient to manage the RAG (Retrieval-Augmented Generation) subsystem.

Skills and Plugin Management

The skills command manages the lifecycle of WASM-based plugins and tool definitions. Skill Packaging Data Flow Sources: crates/palyra-cli/src/commands/skills.rs#59-67, crates/palyra-cli/src/commands/skills.rs#117-128.

System and Diagnostics


ACP and Agent Control Protocol

The acp command facilitates communication between external tools (like IDE extensions) and the Palyra gateway.

TUI (Terminal User Interface)

The tui command launches a ratatui-based interactive session. It utilizes the operator_client to provide a real-time view of agent runs, session transcripts, and approval requests crates/palyra-cli/src/commands/tui.rs#1-44.

Cross-Platform Parity and Testing

Palyra maintains strict CLI parity between Unix-like systems and Windows. This is enforced via the CliParityMatrix.

CliParityMatrix

The CliParityMatrix defines a set of commands and their expected help outputs across platforms. It ensures that flags, aliases, and descriptions remain synchronized crates/palyra-cli/src/cli_parity.rs#1-20.

Snapshot Testing

The system uses snapshot files (e.g., root-help-unix.txt) to detect regressions in the command surface. Sources: crates/palyra-cli/tests/help_snapshots/root-help-unix.txt#1-54, crates/palyra-cli/tests/help_snapshots/root-help-windows.txt#1-54.