Protocol Architecture Overview
The communication backbone is defined inschemas/proto, organized by versioned packages. These schemas serve as the single source of truth for the Daemon, CLI, and mobile/desktop clients.
Component Interaction Diagram
The following diagram illustrates how the generated contracts bridge different language spaces within the Palyra ecosystem. “Contract Distribution and Stub Generation” Sources: scripts/protocol/generate-stubs.ps1#82-91, schemas/proto/palyra/v1/common.proto#1-10.Protobuf Service Definitions
The core services are defined using Protobuf to provide high-performance, versioned RPC interfaces. Key services include:- GatewayService: The primary entry point for agent execution and session management schemas/proto/palyra/v1/gateway.proto#7-29.
- BrowserService: Governs headless browser orchestration, including navigation, DOM inspection, and tab management schemas/proto/palyra/v1/browser.proto#7-42.
- Common Definitions: Shared types such as
CanonicalId(ULID-based) andMessageEnvelopewhich are used across all services schemas/proto/palyra/v1/common.proto#6-11.
Cross-Language Stub Generation
Palyra ensures that clients in different languages remain synchronized with the daemon through a centralized generation pipeline. The scriptscripts/protocol/generate-stubs.ps1 parses the .proto files and emits native code structures for:
| Language | Output File | Usage |
|---|---|---|
| Rust | schemas/generated/rust/protocol_stubs.rs | Internal daemon logic and CLI schemas/generated/rust/protocol_stubs.rs#1-7 |
| Kotlin | schemas/generated/kotlin/ProtocolStubs.kt | Android and JVM-based integrations schemas/generated/kotlin/ProtocolStubs.kt#1-4 |
| Swift | schemas/generated/swift/ProtocolStubs.swift | iOS, macOS, and Safari Extension schemas/generated/swift/ProtocolStubs.swift#1-3 |
Code Entity Mapping
This diagram shows how Protobuf definitions map to generated code entities across languages. “Protobuf to Native Code Mapping” Sources: schemas/proto/palyra/v1/browser.proto#7-20, schemas/generated/rust/protocol_stubs.rs#167-176, schemas/generated/kotlin/ProtocolStubs.kt#126-138, schemas/generated/swift/ProtocolStubs.swift#273-280.Protocol Validation and CI Enforcement
To prevent breaking changes, the repository includes a suite of validation scripts that are executed during CI.- Schema Validation:
validate-proto.ps1ensures all.protofiles are syntactically correct and can be compiled into a descriptor set scripts/protocol/validate-proto.ps1#48-66. - Stub Coherence:
check-generated-stubs.ps1verifies that the generated code inschemas/generatedmatches the current source definitions. If they differ, the CI build fails scripts/protocol/check-generated-stubs.ps1#14-21. - Compilation Checks: Language-specific scripts like
validate-kotlin-stubs.ps1andvalidate-swift-stubs.shattempt to compile the generated stubs usingkotlincandswiftcrespectively to ensure no invalid code was produced scripts/protocol/validate-kotlin-stubs.ps1#25-29, scripts/protocol/validate-swift-stubs.sh#20-21.
- schemas/proto/palyra/v1/gateway.proto#1-29
- schemas/proto/palyra/v1/browser.proto#1-42
- schemas/proto/palyra/v1/common.proto#1-110
- scripts/protocol/generate-stubs.ps1#1-100
- scripts/protocol/validate-proto.ps1#1-72
- scripts/protocol/check-generated-stubs.ps1#1-24
- schemas/generated/rust/protocol_stubs.rs#1-179
- schemas/generated/kotlin/ProtocolStubs.kt#1-140
- schemas/generated/swift/ProtocolStubs.swift#1-285