Skip to main content
This page documents the gRPC service definitions and the protocol-first code generation pipeline used in Palyra. The system relies on Protocol Buffers (v3) to define the contract between the core daemon (palyrad), the browser daemon (palyra-browserd), and various clients (CLI, Web Console, and Desktop Companion).

Overview and Pipeline

Palyra uses a contract-first design where all cross-process communication is defined in .proto files located in schemas/proto/palyra/v1/. These definitions are used to generate type-safe stubs for Rust, Kotlin, and Swift to ensure synchronization across the multi-language workspace.

Build and Validation Pipeline

The generation and validation of these stubs are managed by a suite of scripts that ensure the generated code is always in sync with the schema definitions.
  1. Schema Validation: protoc is used to verify the structural integrity of all .proto files scripts/protocol/validate-proto.ps1#43-66.
  2. Stub Generation: The generate-stubs.ps1 script parses the proto files to create simplified language-specific stubs in schemas/generated/ scripts/protocol/generate-stubs.ps1#82-91.
  3. Compilation Check: Each generated stub is compiled using its respective compiler (rustc, kotlinc, swiftc) to ensure the generated code is valid scripts/protocol/validate-rust-stubs.ps1#25-29, scripts/protocol/validate-kotlin-stubs.ps1#25-29, scripts/protocol/validate-swift-stubs.ps1#22-26.

Data Flow: Schema to Implementation

The following diagram illustrates how a service definition in gateway.proto transitions from a schema to a functional entity in the codebase. Protocol Entity Mapping Sources: schemas/proto/palyra/v1/gateway.proto#7-29, schemas/proto/palyra/v1/browser.proto#7-42, schemas/generated/rust/protocol_stubs.rs#154-179

Service Definitions

GatewayService

The primary interface for palyrad. It handles session lifecycles, agent management, and the core execution stream.
RPC MethodInputOutputDescription
RunStreamstream RunStreamRequeststream RunStreamEventThe bidirectional heart of orchestration schemas/proto/palyra/v1/gateway.proto#9-10.
RouteMessageRouteMessageRequestRouteMessageResponseEntry point for external channel messages schemas/proto/palyra/v1/gateway.proto#16.
ListSessionsListSessionsRequestListSessionsResponseQueries active and historical orchestrator sessions schemas/proto/palyra/v1/gateway.proto#13.
CreateAgentCreateAgentRequestCreateAgentResponsePersists a new agent configuration schemas/proto/palyra/v1/gateway.proto#19.
Sources: schemas/proto/palyra/v1/gateway.proto#7-29

ApprovalsService & VaultService

These services manage sensitive human-in-the-loop (HITL) flows and encrypted secret storage. Sources: schemas/proto/palyra/v1/gateway.proto#31-106

BrowserService

Implemented by palyra-browserd, this service provides high-level browser automation primitives. Browser Action Interaction Sources: schemas/proto/palyra/v1/browser.proto#7-33, schemas/proto/palyra/v1/browser.proto#76-107 Key functionalities include:

AuthService

Manages authentication profiles and credentials used by agents to interact with external platforms. Sources: schemas/generated/rust/protocol_stubs.rs#7-59

Common Message Types

The palyra.common.v1 package defines shared types used across all services to maintain consistency.

Tool Call Lifecycle Messages

The gRPC layer facilitates the tool execution protocol through specific messages:
  1. ToolProposal: Sent by an agent to request execution schemas/proto/palyra/v1/common.proto#144-151.
  2. ToolApprovalRequest: Generated if a policy or risk level requires human intervention schemas/proto/palyra/v1/common.proto#208-218.
  3. ToolResult: The final output or error from the tool execution schemas/proto/palyra/v1/common.proto#231-238.
Sources: schemas/proto/palyra/v1/common.proto#1-250