Skip to main content
This page provides a high-level overview of the communication contracts and data schemas that enable interoperability between the Palyra daemon (palyrad), various client applications (Web, Desktop, CLI), and external nodes. Palyra utilizes a combination of Protobuf for structured RPC/streaming and JSON Envelopes for flexible UI rendering and message exchange.

Overview of Contract Architecture

Palyra’s architecture relies on strictly defined schemas to ensure type safety across Rust, Kotlin, and Swift. The system is divided into three primary layers:
  1. Protobuf Layer: Defines gRPC services and message structures for high-performance daemon-to-client and daemon-to-node communication.
  2. JSON Envelope Layer: Defines the structure of messages, configurations, and UI patches transmitted over HTTP or WebSockets.
  3. A2UI (Agent-to-User Interface) Protocol: A specialized JSON-based protocol for dynamic UI updates, allowing agents to “render” components in the user’s dashboard.

Protocol Generation and Validation

The codebase includes a suite of scripts to ensure that generated code stays in sync with schema definitions.
ComponentPathDescription
Proto Definitionsschemas/proto/palyra/v1/Source of truth for all gRPC/Protobuf contracts.
Rust Stubsschemas/generated/rust/protocol_stubs.rsGenerated types for the Daemon and CLI.
Kotlin Stubsschemas/generated/kotlin/ProtocolStubs.ktGenerated types for Android/JVM clients.
Swift Stubsschemas/generated/swift/ProtocolStubs.swiftGenerated types for iOS/macOS clients.
JSON Schemasschemas/json/envelopes/JSON Schema files for message and UI validation.
Sources: scripts/protocol/generate-stubs.ps1#82-87, schemas/generated/rust/protocol_stubs.rs#1-5, schemas/generated/swift/ProtocolStubs.swift#1-3

Protobuf Service Definitions

The core functionality of Palyra is exposed via gRPC services defined in the schemas/proto/ directory. These services handle everything from the main execution gateway to secret management and browser automation.

Key Services

For detailed documentation on every RPC method and message structure, see Protobuf Service Definitions. Sources: schemas/proto/palyra/v1/gateway.proto#7-51, schemas/proto/palyra/v1/browser.proto#7-42

JSON Envelopes and A2UI Protocol

While Protobuf handles the “pipes,” JSON Envelopes handle the “content,” especially for web-based interactions and configuration portability.

A2UI (Agent-to-User Interface)

The A2UI protocol allows the daemon to send UI “patches” to the web dashboard. Instead of sending a full page, the daemon sends PatchOperation sets (Add, Replace, Remove) crates/palyra-a2ui/src/lib.rs#29-41. This enables real-time, granular updates to the “Canvas” without full re-renders.

Envelope Schemas

All JSON data follows strict versioned schemas to ensure the frontend can safely parse incoming messages.

Protocol Validation (Natural Language to Code)

The diagram below illustrates how a conceptual UI update (Natural Language Space) is transformed into a validated PatchDocument (Code Entity Space). Diagram: A2UI Update Flow For details on A2UI patch mechanics, JSON schema validation, and normalization, see JSON Envelopes and A2UI Protocol. Sources: crates/palyra-a2ui/src/lib.rs#29-47, schemas/json/envelopes/a2ui-envelope.v1.json#132-149

Cross-Language Type Mapping

The protocol generation pipeline ensures that domain concepts are represented consistently across the stack. This mapping is vital for features like VaultService, where secrets must be handled with identical logic in Rust and Swift. Diagram: Cross-Language Entity Mapping
ConceptRust EntitySwift EntityKotlin Entity
Auth Profilepalyra_auth_v1::AuthProfilePalyraAuthV1.AuthProfilePalyraAuthV1.AuthProfile
Browser Sessionpalyra_browser_v1::BrowserSessionSummaryPalyraBrowserV1.BrowserSessionSummaryPalyraBrowserV1.BrowserSessionSummary
Gateway Healthpalyra_gateway_v1::HealthRequestPalyraGatewayV1.HealthRequestPalyraGatewayV1.HealthRequest
Sources: schemas/generated/rust/protocol_stubs.rs#17, schemas/generated/swift/ProtocolStubs.swift#16, schemas/generated/kotlin/ProtocolStubs.kt#9

Child Pages