Skip to main content
The Palyra CLI provides a comprehensive suite of tools for initializing, reconfiguring, and diagnosing the environment. These systems are designed to be safe (using backups and dry-runs), interactive (via a terminal wizard), and automatable (via JSON output and non-interactive flags).

1. Doctor Diagnostic Pipeline

The doctor command is the primary diagnostic and recovery tool for Palyra. It evaluates the health of the local installation, configuration validity, and connectivity to remote services.

Core Components

Diagnostic Flow

The doctor pipeline operates in several modes: Diagnostics (read-only), RepairPreview, and RepairApply crates/palyra-cli/src/commands/doctor/recovery.rs#66-74. It checks for:
  1. Config Integrity: Validates palyra.toml versioning and schema crates/palyra-cli/src/commands/doctor/recovery.rs#182-191.
  2. Auth Registries: Ensures auth_profiles.toml is not corrupted and root keys are normalized crates/palyra-cli/src/commands/doctor/recovery.rs#195-205.
  3. Sandbox/Browser: Verifies encryption keys for browserd and existence of state directories crates/palyra-cli/src/commands/doctor/recovery.rs#192-194.

Data Flow: Doctor Recovery

Title: Doctor Diagnostic and Repair Lifecycle Sources: crates/palyra-cli/src/commands/doctor.rs#8-10, crates/palyra-cli/src/commands/doctor/recovery.rs#76-83, crates/palyra-cli/src/commands/doctor/recovery.rs#105-118, crates/palyra-cli/src/commands/doctor/recovery.rs#141-155

2. Setup and Onboarding Wizard

The Onboarding Wizard handles the initial bootstrap of a Palyra installation. It is invoked via palyra setup --wizard or palyra onboarding wizard crates/palyra-cli/src/commands/operator_wizard.rs#240-247.

Wizard Engine (WizardBackend)

The system uses a generic WizardBackend trait to support different interaction modes:

Onboarding Flows

The wizard supports three primary flows defined in WizardFlowKind crates/palyra-cli/src/commands/operator_wizard.rs#65-69:
  1. Quickstart: Minimal prompts, optimized for local setup with OpenAI or Anthropic crates/palyra-cli/src/commands/operator_wizard.rs#74-74.
  2. Manual: Detailed configuration of ports, TLS paths, and specific bind profiles (e.g., public-tls) crates/palyra-cli/src/commands/operator_wizard.rs#75-75.
  3. Remote: Configures the local CLI to communicate with an existing remote daemon crates/palyra-cli/src/commands/operator_wizard.rs#76-76.

Implementation: Wizard Steps

Title: Onboarding Wizard Logic Flow Sources: crates/palyra-cli/src/commands/wizard.rs#29-39, crates/palyra-cli/src/commands/wizard.rs#98-105, crates/palyra-cli/src/commands/operator_wizard.rs#169-195, crates/palyra-cli/src/commands/operator_wizard.rs#198-216

3. Configuration and Migration

The configure command allows users to modify an existing installation safely. It reuses the same underlying wizard engine as the onboarding flow but targets specific sections of the configuration crates/palyra-cli/src/commands/operator_wizard.rs#219-226.

Configuration Sections

Users can target specific sections for reconfiguration:
  • workspace: Workspace root and default models.
  • auth-model: Provider keys and model selection.
  • gateway: Ports and binding profiles.
  • channels: Integration settings for Discord/Slack.

Migration Safety

When the wizard or configure command modifies a file, it implements a backup rotation strategy. It maintains up to 5 backups (defined by CONFIGURE_BACKUPS) of palyra.toml before applying changes crates/palyra-cli/src/commands/operator_wizard.rs#17-17.

Summary and Health Check

At the end of a setup or configuration run, the system performs a post-flight health check and emits an OnboardingSummary (for setup) or ConfigureSummary (for configuration) crates/palyra-cli/src/commands/operator_wizard.rs#198-216, crates/palyra-cli/src/commands/operator_wizard.rs#229-238.
FieldDescription
statuscomplete or failed
config_pathAbsolute path to the written palyra.toml
health_statusResult of post-setup diagnostics (ConfigReady, RemoteVerified, etc.)
risk_eventsList of security risks acknowledged by the user (e.g., public binding)
restart_requiredBoolean indicating if the daemon needs a restart to apply changes
Sources: crates/palyra-cli/src/commands/operator_wizard.rs#102-110, crates/palyra-cli/src/commands/operator_wizard.rs#191-191, crates/palyra-cli/src/commands/operator_wizard.rs#224-224, crates/palyra-cli/src/commands/operator_wizard.rs#234-234