Environment Prerequisites
Palyra is a polyglot codebase primarily using Rust for the core daemon and CLI, and TypeScript/React for the web and desktop interfaces.Required Toolchain
- Rust: Latest stable (via
rustup). - Node.js & npm: Required for
apps/webandapps/desktop/ui. - Just or Make: Command runners for workspace automation.
- Protoc: Protocol Buffer compiler for stub generation.
Development Bootstrap Flow
The development setup is designed to be self-correcting via thepalyra doctor command, which performs strict environment validation before allowing build operations.
1. Initial Setup
The quickest way to prepare the environment is using the providedMakefile or justfile.
dev target executes the following sequence:
- Environment Validation: Runs
palyra doctor --strictto ensure all system dependencies (likeprotoc,cargo, andnpm) are present Makefile#7-11, justfile#7-11. - UI Preparation: Ensures the desktop UI artifacts are initialized via
scripts/test/ensure-desktop-ui.shMakefile#94-95, justfile#44-45. - Workspace Build: Performs a locked build of all Cargo members Makefile#38-40, justfile#112-114.
2. Web Workspace Materialization
Palyra uses a custom toolvp (Version Porter) to manage JS dependencies. After the initial build, run:
vp install to materialize the root JS workspace Makefile#80-81, justfile#30-31.
Data Flow: Development Bootstrap
The following diagram illustrates how the bootstrap targets interact with the codebase entities to reach a “Ready” state. Title: Development Bootstrap Lifecycle Sources: Makefile#7-19, justfile#7-22, crates/palyra-cli/src/commands/setup.rsOnboarding & Configuration Wizard
Palyra includes a sophisticated onboarding engine located incrates/palyra-cli/src/commands/operator_wizard.rs. This engine handles both fresh installations (palyra setup) and safe reconfigurations (palyra configure).
Wizard Flow Kinds
The wizard supports three primary flows defined inWizardFlowKind crates/palyra-cli/src/commands/operator_wizard.rs#65-69:
- Quickstart: Minimal prompts, uses defaults for ports and model selections (e.g.,
gpt-4o-mini) crates/palyra-cli/src/commands/operator_wizard.rs#18. - Manual: Granular control over
bind_profile, TLS paths, and specific model providers. - Remote: Configures a local CLI to communicate with a remote daemon, including SSH tunneling or verified HTTPS setup crates/palyra-cli/src/commands/operator_wizard.rs#97-100.
Key Implementation Entities
OnboardingMutationPlan: A struct that aggregates all pending changes (ports, auth methods, TLS paths) before they are committed to disk crates/palyra-cli/src/commands/operator_wizard.rs#169-195.WizardBackend: Trait abstraction forInteractiveWizardBackend(CLI prompts) andNonInteractiveWizardBackend(automated/CI) crates/palyra-cli/src/commands/operator_wizard.rs#10-13.ConfigureSectionArg: Allows theconfigurecommand to target specific subsystems likeauth-model,gateway, orskillscrates/palyra-cli/tests/help_snapshots/configure-help.txt#8-9.
System Mapping: Onboarding Logic
This diagram maps the CLI arguments to the internal mutation logic. Title: Onboarding Logic Mapping Sources: crates/palyra-cli/src/commands/operator_wizard.rs#24-30, crates/palyra-cli/src/commands/operator_wizard.rs#169-195, crates/palyra-cli/src/args/onboarding.rs#34-89Environment Variables
The CLI and Daemon respect several environment variables for overriding local paths and secrets. These are frequently used in tests to isolate the environment crates/palyra-cli/tests/wizard_cli.rs#12-21.| Variable | Description |
|---|---|
PALYRA_STATE_ROOT | Directory for databases, logs, and persistent state. |
PALYRA_VAULT_DIR | Directory where the encrypted secret vault is stored. |
PALYRA_VAULT_BACKEND | Type of vault storage (e.g., encrypted_file). |
OPENAI_API_KEY | Used during quickstart onboarding to seed the vault. |
ANTHROPIC_API_KEY | Alternative provider key for onboarding crates/palyra-cli/tests/wizard_cli.rs#159. |
Workspace Automation (Makefile/Justfile)
The workspace provides comprehensive targets for testing, linting, and security auditing.Testing Targets
test: Runs all workspace tests, ensuring the desktop UI is ready Makefile#34-36.deterministic-core: Runs a subset of tests that are guaranteed to be deterministic Makefile#97-98.deterministic-soak: Executes long-running stability tests for components like the Discord connector and the daemon’s access record backfill scripts/test/run-deterministic-soak.ps1#9-11.cli-regression: Runs workflow-level regression tests for the CLI Makefile#103-104.
Security & Hygiene Targets
security: Aggregated target runningcargo audit,cargo deny, and custom scripts to check for high-risk patterns Makefile#56-61.protocol: Validates.protofiles and regenerates Rust/TypeScript stubs Makefile#29-32.fuzz-build: Compiles all fuzzing targets (e.g.,a2ui_json_parser,webhook_payload_parser) Makefile#147-160.
Formatting & Linting
fmt: Runscargo fmtacross the entire workspace Makefile#1-2.lint: Runscargo clippywith all targets and treats warnings as errors Makefile#20-21.