palyra CLI, implemented in the palyra-cli crate, is the primary operator interface for managing local and remote Palyra runtimes. It provides a unified command-line surface for system bootstrapping, diagnostic health checks, real-time agent interaction via the Agent Control Protocol (ACP), and administrative governance of routines, approvals, and security policies.
Command Architecture
The CLI is built usingclap for robust argument parsing and sub-command nesting. The entry point resides in crates/palyra-cli/src/lib.rs, which dispatches to specific command handlers in crates/palyra-cli/src/commands/.
Root Command Tree
The CLI categorizes operations into several major families:- Lifecycle:
setup(aliasinit),onboarding,configure,update,uninstall. - Diagnostics:
doctor,health,status,logs,system,support-bundle. - Agent Operations:
acp,tui,agent,agents,sessions,approvals. - Automation:
routines,cron,hooks,webhooks. - Resources:
memory,plugins,skills,secrets,config,models. - Infrastructure:
gateway(aliasdaemon),node,nodes,pairing,browser.
CLI Execution Flow
The following diagram maps the transition from user input to the internalRootCommandContext and subsequent execution.
CLI Entry Point to Context Mapping
Sources: crates/palyra-cli/src/lib.rs#76-90, crates/palyra-cli/src/app/mod.rs#28-39, crates/palyra-cli/src/app/mod.rs#124-130
Connection and Transport
The CLI interacts with the Palyra Daemon (palyrad) via two primary protocols:
- gRPC (Tonic): Used for high-performance streaming (e.g.,
RunStream) and administrative tasks (e.g.,ApprovalsService). - HTTP (Reqwest): Used for RESTful admin APIs, onboarding probes, and webhook management.
RootCommandContext resolves connection details by merging CLI flags, environment variables (e.g., PALYRA_DAEMON_URL), and profile configuration from cli/profiles.toml crates/palyra-cli/src/app/mod.rs#23-26.
| Transport | Implementation | Primary Use Case |
|---|---|---|
| gRPC | gateway_v1::gateway_service_client | Agent execution, Health probes, Approvals |
| HTTP | reqwest::blocking::Client | Setup, Discord onboarding, Webhook config |
Major Subsystems
Setup and Diagnostics
The CLI manages the initial bootstrap of the environment through thesetup command and provides a comprehensive diagnostic suite via doctor.
- Setup: Supports
localandremotemodes, including a guidedoperator_wizard. - Doctor: A diagnostic framework that checks configuration validity, connectivity, and sandbox health.
ACP Bridge and TUI
The Agent Control Protocol (ACP) bridge allows external tools (like IDEs) to communicate with Palyra agents viastdio. The CLI also provides a ratatui-based TUI for a native terminal-based chat experience.
- ACP: Handles
stdiomultiplexing and session branching. - TUI: Provides real-time transcript rendering and tool execution visibility.
Automation and Governance
Administrative commands manage the background lifecycle of the daemon:- Routines: Unified management of schedules and event-driven triggers.
- Approvals: A specialized gRPC-backed interface for reviewing and deciding on sensitive tool executions crates/palyra-cli/src/commands/approvals.rs#7-10.
Platform Parity and Testing
The CLI ensures a consistent experience across Windows, macOS, and Linux through a dedicated parity framework.- CliParityMatrix: A configuration-driven matrix used to verify that help text and command behavior remain consistent across platforms.
- Snapshot Testing: Automated tests compare actual CLI help output against platform-specific snapshots crates/palyra-cli/tests/help_snapshots.rs#75-77.
Sub-pages Reference
- Setup, Onboarding, and Doctor
- ACP Bridge, TUI, and Session Management
- Routines, Cron, and Approvals CLI
- CLI Platform Parity and Testing