> ## Documentation Index
> Fetch the complete documentation index at: https://docs-code.palyra.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Browser Extension and Mobile Apps

<details>
  <summary>Relevant source files</summary>

  The following files were used as context for generating this wiki page:

  * apps/android/README.md
  * apps/desktop/src-tauri/src/features/onboarding/connectors/discord/mod.rs
  * apps/desktop/src-tauri/src/features/onboarding/connectors/discord/summary.rs
  * apps/desktop/ui/src/components/HealthStrip.tsx
  * apps/desktop/ui/src/components/ProcessMonitorCard.tsx
  * apps/desktop/ui/src/components/QuickFactsCard.tsx
  * apps/ios/README.md
  * apps/web/src/console/components/ui/ConfirmActionDialog.tsx
  * apps/web/src/console/hooks/useSupportDomain.ts
  * apps/web/src/console/sections/AccessSection.tsx
  * apps/web/src/console/sections/ChannelsSection.tsx
  * apps/web/src/consoleApi/channels/core.ts
  * apps/web/src/consoleApi/channels/discord.ts
  * apps/web/src/features/channels/connectors/discord/components/DiscordConnectorActionsPanel.tsx
  * apps/web/src/features/channels/connectors/discord/components/DiscordOnboardingPanel.tsx
  * apps/web/src/features/channels/connectors/discord/controller.ts
  * apps/web/src/features/channels/core/api.ts
  * apps/web/src/features/channels/core/domain.ts
  * apps/web/src/features/channels/core/useChannelCoreState.ts
</details>

This section details the Palyra peripheral application ecosystem, focusing on the Manifest V3 browser extension and the mobile application stubs for Android and iOS. These components extend the daemon's reach into the user's active browsing context and mobile notification surfaces.

## Browser Extension

The Palyra Browser Extension is a Manifest V3 compliant component designed to provide the `palyra-daemon` with high-fidelity DOM snapshots and relay capabilities. It operates with a loopback-only security posture, ensuring that it only communicates with a locally running or explicitly paired Palyra instance.

### Core Architecture and Data Flow

The extension serves as a bridge between the browser's internal state (DOM, tabs, cookies) and the `palyra-browserd` service. It uses a relay dispatch mechanism to handle requests from the agent.

#### Implementation Details

* **Manifest V3**: Utilizes service workers for background processing and fine-grained permission scoping.
* **DOM Snapshotting**: Captures the current state of the active tab, including computed styles and accessibility trees, to provide context to the LLM.
* **Relay Dispatch**: Routes commands from the `BrowserService` gRPC interface to the specific browser tab.

#### Security Posture

The extension enforces a strict security model:

1. **Loopback-Only**: By default, the extension only accepts connections from `127.0.0.1` to prevent cross-site request forgery (CSRF) or unauthorized remote control.
2. **Pairing Flow**: Remote instances must undergo a pairing handshake, involving a PIN or QR code, which is managed via the `AccessSection` in the Web Console [apps/web/src/console/sections/AccessSection.tsx#65-167](http://apps/web/src/console/sections/AccessSection.tsx#65-167).
3. **SSRF Protection**: Integration with the daemon's egress proxy ensures that the extension cannot be used as a proxy to scan internal networks.

### Pairing and Trust

Devices, including browsers running the extension, must be enrolled in the Palyra Inventory. The pairing process is orchestrated through the `useSupportDomain` hook [apps/web/src/console/hooks/useSupportDomain.ts#26-121](http://apps/web/src/console/hooks/useSupportDomain.ts#26-121).

**Browser Trust Lifecycle**

1. **Discovery**: The extension detects a Palyra daemon via a local handshake.
2. **Pairing Request**: The user initiates pairing, creating a `NodePairingRequestView` [apps/web/src/console/sections/AccessSection.tsx#73-73](http://apps/web/src/console/sections/AccessSection.tsx#73-73).
3. **Approval**: The operator approves the request in the Access section [apps/web/src/console/sections/AccessSection.tsx#148-151](http://apps/web/src/console/sections/AccessSection.tsx#148-151).
4. **Active Session**: The extension receives a certificate and enters the "trusted" state.

### Code Entity Mapping: Browser Service

The following diagram bridges the logical browser service concepts to the implementation entities.

**Browser Extension Logic to Code Mapping**

```mermaid theme={null}
graph TD
    subgraph "Browser Extension (MV3)"
        A["Content Script"] -- "DOM Snapshot" --> B["Background Service Worker"]
        B -- "Relay Dispatch" --> C["Local WebSocket/gRPC"]
    end

    subgraph "Code Entity Space"
        C1["palyra.browser.v1.BrowserService"]
        C2["BrowserService gRPC Stub"]
        C3["QuickFactsCard (UI)"]
    end

    B -- "reports to" --> C1
    C1 -- "consumed by" --> C2
    C2 -- "status reflected in" --> C3
```

Sources: [apps/desktop/ui/src/components/QuickFactsCard.tsx#62-70](http://apps/desktop/ui/src/components/QuickFactsCard.tsx#62-70), [apps/web/src/console/hooks/useSupportDomain.ts#72-74](http://apps/web/src/console/hooks/useSupportDomain.ts#72-74)

## Mobile Application Stubs

Palyra includes stubs for Android and iOS applications, located in `apps/android/` and `apps/ios/`. These are currently designed as thin clients for the Web Console with native notification support.

### Features and Capabilities

* **A2UI Rendering**: Mobile apps use the same Adaptive Agent UI (A2UI) renderer as the web console to display run streams and tool outputs.
* **Push Notifications**: Integration with the `ChannelRouter` to receive alerts for "AskEachTime" tool approvals or high-priority routine completions.
* **Identity Integration**: Mobile devices use the `palyra-identity` crate logic to maintain mTLS connections to the daemon, similar to the CLI pairing flow.

### Implementation Status

| Feature          | Android            | iOS               |
| :--------------- | :----------------- | :---------------- |
| gRPC Stubs       | Generated (Kotlin) | Generated (Swift) |
| mTLS Auth        | Supported          | Supported         |
| A2UI WebView     | Functional         | Functional        |
| Background Relay | Experimental       | Experimental      |

Sources: [apps/android/README.md#1-10](http://apps/android/README.md#1-10), [apps/ios/README.md#1-10](http://apps/ios/README.md#1-10)

## Integration with Channel Connectors

The browser extension and mobile apps often interact with the `ChannelRouter` when the agent requires human intervention (e.g., via Discord or Slack).

### Discord Onboarding and Verification

The mobile and web interfaces provide specialized panels for managing these connections, such as the `DiscordOnboardingPanel` [apps/web/src/features/channels/connectors/discord/components/DiscordOnboardingPanel.tsx](). Operators can trigger test messages to verify that the mobile relay or browser notifications are correctly routed [apps/web/src/features/channels/connectors/discord/components/DiscordConnectorActionsPanel.tsx#23-55](http://apps/web/src/features/channels/connectors/discord/components/DiscordConnectorActionsPanel.tsx#23-55).

**Channel Dispatch Flow**

```mermaid theme={null}
sequenceDiagram
    participant A as Agent (palyra-daemon)
    participant CR as ChannelRouter
    participant DC as DiscordConnector
    participant MA as Mobile App / Extension

    A->>CR: Dispatch Message (Approval Required)
    CR->>DC: Route to Discord [apps/web/src/consoleApi/channels/discord.ts:10-29]
    CR->>MA: Push Notification / Extension Alert
    MA->>A: User Approves (via A2UI)
```

Sources: [apps/web/src/consoleApi/channels/discord.ts#10-29](http://apps/web/src/consoleApi/channels/discord.ts#10-29), [apps/web/src/features/channels/connectors/discord/components/DiscordConnectorActionsPanel.tsx#78-84](http://apps/web/src/features/channels/connectors/discord/components/DiscordConnectorActionsPanel.tsx#78-84)

## Monitoring and Health

The health of the browser service and peripheral apps is monitored by the desktop supervisor and reported in the `ControlCenterSnapshot` [apps/desktop/ui/src/components/HealthStrip.tsx#97-117](http://apps/desktop/ui/src/components/HealthStrip.tsx#97-117).

Key health metrics include:

* **Browser Health**: Indicates if the extension is connected and responsive [apps/desktop/ui/src/components/QuickFactsCard.tsx#62-68](http://apps/desktop/ui/src/components/QuickFactsCard.tsx#62-68).
* **Last Error**: Captures the last failure reported by the browser relay [apps/desktop/ui/src/components/QuickFactsCard.tsx#72-77](http://apps/desktop/ui/src/components/QuickFactsCard.tsx#72-77).
* **Device Trust State**: Tracks if the mobile or browser device is still considered "trusted" by the inventory [apps/web/src/console/sections/AccessSection.tsx#98-100](http://apps/web/src/console/sections/AccessSection.tsx#98-100).

Sources: [apps/desktop/ui/src/components/HealthStrip.tsx#97-117](http://apps/desktop/ui/src/components/HealthStrip.tsx#97-117), [apps/desktop/ui/src/components/QuickFactsCard.tsx#62-77](http://apps/desktop/ui/src/components/QuickFactsCard.tsx#62-77), [apps/web/src/console/sections/AccessSection.tsx#98-100](http://apps/web/src/console/sections/AccessSection.tsx#98-100)
