Skip to main content
The Palyra CLI provides two primary interfaces for high-level agent interaction and integration: a Terminal User Interface (TUI) for human operators and an Agent Control Protocol (ACP) bridge for programmatic or legacy agent communication. These components act as clients to the palyrad Gateway gRPC service, abstracting the complexities of session management and stream handling.

Terminal User Interface (TUI)

The TUI is a ratatui-based operator client that allows for interactive chat sessions, tool approval workflows, and session management directly from the terminal. It is launched via the palyra tui command crates/palyra-cli/src/commands/tui.rs#3-26.

Core Implementation

The TUI is built around the App struct, which maintains the UI state, and the OperatorRuntime, which handles gRPC communication with the daemon crates/palyra-cli/src/tui/mod.rs#107-130.

UI States and Navigation

The TUI operates in several modes defined by the Mode enum, including Chat, Picker (for selecting agents/models), Settings, and Approval crates/palyra-cli/src/tui/mod.rs#45-52.
ModePurpose
ChatPrimary interaction interface for sending prompts and viewing transcripts.
ApprovalIntercepts tool calls requiring manual operator confirmation.
PickerInteractive lists for switching between agents, sessions, or model profiles.
SettingsToggles for UI preferences like showing “thinking” blocks or tool details.
Sources: crates/palyra-cli/src/tui/mod.rs#39-130, crates/palyra-cli/src/client/operator.rs#15-69

TUI Architecture Diagram

The following diagram illustrates the relationship between the TUI frontend entities and the underlying runtime clients. “TUI Component Map” Sources: crates/palyra-cli/src/tui/mod.rs#107-130, crates/palyra-cli/src/client/operator.rs#15-35, crates/palyra-cli/src/client/runtime.rs#9-12

Agent Control Protocol (ACP) Bridge

The ACP Bridge allows Palyra to act as a host for agents following the Agent Control Protocol. It maps ACP JSON-RPC notifications and requests (typically over stdio) into Palyra’s gRPC-based RunStream protocol crates/palyra-cli/src/acp_bridge.rs#7-18.

Session Binding

The bridge maintains a BridgeState that maps ACP SessionIds to Palyra’s internal ULID-based session identifiers crates/palyra-cli/src/acp_bridge.rs#31-42. This allows legacy agents to maintain state across multiple turns while the bridge handles the ResolveSession logic with the daemon crates/palyra-cli/src/acp_bridge.rs#163-170.

Data Flow and Transformation

When an ACP agent sends a prompt, the PalyraAcpAgent implementation:
  1. Resolves or creates a Palyra session using session_overrides crates/palyra-cli/src/acp_bridge.rs#163-170.
  2. Converts ACP ContentBlocks (text or resources) into a unified prompt string crates/palyra-cli/src/acp_bridge.rs#190-210.
  3. Opens a ManagedRunStream via the OperatorRuntime crates/palyra-cli/src/client/operator.rs#137-146.
  4. Streams events back to the ACP client as SessionUpdate notifications crates/palyra-cli/src/acp_bridge.rs#100-116.

ACP to gRPC Bridge Mapping

“ACP to gRPC Entity Mapping” Sources: crates/palyra-cli/src/acp_bridge.rs#81-116, crates/palyra-cli/src/client/operator.rs#137-175, crates/palyra-cli/src/client/runtime.rs#203-210

Session and Agent Management

The CLI provides a suite of commands for managing the entities that the TUI and ACP Bridge interact with.

Session Commands

Managed in crates/palyra-cli/src/commands/sessions.rs, these commands interface with the OperatorRuntime to perform CRUD and lifecycle operations on sessions crates/palyra-cli/src/commands/sessions.rs#45-47.

Agent Commands

Managed in crates/palyra-cli/src/commands/agents.rs, these commands handle agent identity and environment bindings crates/palyra-cli/src/commands/agents.rs#29-31. Sources: crates/palyra-cli/src/commands/sessions.rs#3-44, crates/palyra-cli/src/commands/agents.rs#3-31, crates/palyra-cli/src/commands/agent.rs#75-109