# tresnanda/kybern architecture

> Architecture diagram of the GitHub repository tresnanda/kybern, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tresnanda/kybern
- Repository: https://github.com/tresnanda/kybern

## Overview

Kybern is a local-first studio for running autonomous coding agents in parallel, with desktop, remote-daemon, and mobile clients. The main workflow is to select a project and agent, run isolated work, inspect streaming turns and diffs, and review or manage results. The graph includes the documented agent, worktree, mobile, and remote capabilities, plus client transport and state layers. Edges use README statements or shown source relationships; unsampled implementation details are not inferred.

Main entry points: [`crates/kybern-daemon/src/orchestrator.rs`](https://github.com/tresnanda/kybern/blob/main/crates/kybern-daemon/src/orchestrator.rs) (Agent Orchestrator), [`apps/gpuix/src/App.tsx`](https://github.com/tresnanda/kybern/blob/main/apps/gpuix/src/App.tsx) (Desktop Workspace), [`packages/kybern-client/src/client.ts`](https://github.com/tresnanda/kybern/blob/main/packages/kybern-client/src/client.ts) (Client Transport), [`apps/mobile/src/state/runtime.ts`](https://github.com/tresnanda/kybern/blob/main/apps/mobile/src/state/runtime.ts) (Mobile Runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop Studio"]
  node_desktop_app["Desktop Workspace<br/>[App.tsx]"]
  node_desktop_state["Workspace State<br/>[state.ts]"]
  node_composer["Agent Composer<br/>[store.ts]"]
  node_transcript["Transcript &amp; Diffs<br/>[store.ts]"]
  node_review["Pull Request Review<br/>[useReview.ts]"]
  node_nav["Navigation State<br/>[store.ts]"]
  node_os["Platform Services<br/>[os.ts]"]
  node_environment["Environment Selection<br/>[environment.ts]"]
end

subgraph group_daemon["Daemon Runtime"]
  node_daemon["Agent Orchestrator<br/>[orchestrator.rs]"]
  node_tasks["Task Orchestration<br/>[tasks.rs]"]
  node_daemon_state["Daemon State<br/>[state.rs]"]
  node_auth["Authentication<br/>[auth.rs]"]
  node_network_access["Remote Access<br/>[client_grant.rs]"]
  node_agent_drivers["Agent Drivers<br/>[account_auth.rs]"]
  node_store[("Persistent Store<br/>[tasks.rs]")]
end

subgraph group_clients["Client Applications"]
  node_mobile_app["Mobile Companion<br/>[tasks.tsx]"]
  node_mobile_tasks["Mobile Tasks<br/>[Tasks.tsx]"]
  node_mobile_runtime["Mobile Runtime<br/>[runtime.ts]"]
  node_machine_storage[("Paired Machines<br/>[storage.ts]")]
  node_cli["Command Line<br/>[lib.rs]"]
end

subgraph group_shared["Shared Protocol"]
  node_client_transport["Client Transport<br/>[client.ts]"]
  node_wire_types["Wire Types<br/>[types.ts]"]
  node_protocol_auth["Protocol Authentication<br/>[auth.rs]"]
end

node_user(("Engineer"))
node_mobile_user(("Phone User"))
node_coding_agents(("Coding Agents"))
node_git_worktrees[("Git Worktrees")]
node_remote_host["Remote Host"]

node_user -->|"uses"| node_desktop_app
node_desktop_app -->|"configures agents"| node_composer
node_composer -->|"starts sessions"| node_daemon
node_daemon -->|"runs protocols"| node_agent_drivers
node_daemon -->|"isolates work"| node_git_worktrees
node_daemon -->|"persists turns"| node_store
node_daemon -.->|"coordinates tasks"| node_tasks
node_desktop_app -.->|"hosts workspace"| node_desktop_state
node_desktop_state -->|"opens stream"| node_transcript
node_desktop_app -.->|"presents navigation"| node_nav
node_desktop_app -.->|"selects environment"| node_environment
node_transcript -->|"uses clipboard"| node_os
node_desktop_app -.->|"supports review"| node_review
node_desktop_app -->|"connects remotely"| node_client_transport
node_remote_host -->|"hosts workloads"| node_daemon
node_user -->|"pairs device"| node_mobile_app
node_mobile_app -->|"shows tasks"| node_mobile_tasks
node_mobile_tasks -->|"loads and controls"| node_mobile_runtime
node_mobile_runtime -->|"saves pairing"| node_machine_storage
node_mobile_runtime -.->|"uses transport"| node_client_transport
node_mobile_user -->|"monitors work"| node_mobile_app
node_client_transport -->|"sends requests"| node_daemon
node_daemon -.->|"checks credentials"| node_protocol_auth
node_client_transport -.->|"uses protocol types"| node_wire_types
node_user -->|"runs headless"| node_cli

click node_desktop_app "https://github.com/tresnanda/kybern/blob/main/apps/gpuix/src/App.tsx"
click node_desktop_state "https://github.com/tresnanda/kybern/blob/main/apps/gpuix/src/state.ts"
click node_composer "https://github.com/tresnanda/kybern/blob/main/apps/gpuix/src/composer/store.ts"
click node_transcript "https://github.com/tresnanda/kybern/blob/main/apps/gpuix/src/transcript/store.ts"
click node_review "https://github.com/tresnanda/kybern/blob/main/apps/gpuix/src/pulls/useReview.ts"
click node_nav "https://github.com/tresnanda/kybern/blob/main/apps/gpuix/src/nav/store.ts"
click node_os "https://github.com/tresnanda/kybern/blob/main/apps/gpuix/src/platform/os.ts"
click node_environment "https://github.com/tresnanda/kybern/blob/main/apps/gpuix/src/shell/environment.ts"
click node_daemon "https://github.com/tresnanda/kybern/blob/main/crates/kybern-daemon/src/orchestrator.rs"
click node_tasks "https://github.com/tresnanda/kybern/blob/main/crates/kybern-daemon/src/orchestrator/tasks.rs"
click node_daemon_state "https://github.com/tresnanda/kybern/blob/main/crates/kybern-daemon/src/state.rs"
click node_auth "https://github.com/tresnanda/kybern/blob/main/crates/kybern-daemon/src/auth.rs"
click node_network_access "https://github.com/tresnanda/kybern/blob/main/crates/kybern-daemon/src/network/client_grant.rs"
click node_agent_drivers "https://github.com/tresnanda/kybern/blob/main/crates/kybern-drivers/src/account_auth.rs"
click node_store "https://github.com/tresnanda/kybern/blob/main/crates/kybern-store/src/tasks.rs"
click node_mobile_app "https://github.com/tresnanda/kybern/blob/main/apps/mobile/app/tasks.tsx"
click node_mobile_tasks "https://github.com/tresnanda/kybern/blob/main/apps/mobile/src/features/Tasks.tsx"
click node_mobile_runtime "https://github.com/tresnanda/kybern/blob/main/apps/mobile/src/state/runtime.ts"
click node_machine_storage "https://github.com/tresnanda/kybern/blob/main/apps/mobile/src/machines/storage.ts"
click node_client_transport "https://github.com/tresnanda/kybern/blob/main/packages/kybern-client/src/client.ts"
click node_wire_types "https://github.com/tresnanda/kybern/blob/main/packages/kybern-client/src/types.ts"
click node_protocol_auth "https://github.com/tresnanda/kybern/blob/main/crates/kybern-protocol/src/auth.rs"
click node_cli "https://github.com/tresnanda/kybern/blob/main/crates/kybern-cli/src/lib.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_desktop_app,node_desktop_state,node_composer,node_transcript,node_review,node_nav,node_os,node_environment,node_mobile_user toneBlue
class node_daemon,node_tasks,node_daemon_state,node_auth,node_network_access,node_agent_drivers,node_store,node_git_worktrees toneAmber
class node_mobile_app,node_mobile_tasks,node_mobile_runtime,node_machine_storage,node_cli toneMint
class node_client_transport,node_wire_types,node_protocol_auth toneRose
class node_user,node_coding_agents,node_remote_host toneIndigo
```

## Components

### Desktop Studio

- [Desktop Workspace](https://github.com/tresnanda/kybern/blob/main/apps/gpuix/src/App.tsx): `apps/gpuix/src/App.tsx`
- [Workspace State](https://github.com/tresnanda/kybern/blob/main/apps/gpuix/src/state.ts): `apps/gpuix/src/state.ts`
- [Agent Composer](https://github.com/tresnanda/kybern/blob/main/apps/gpuix/src/composer/store.ts): `apps/gpuix/src/composer/store.ts`
- [Transcript & Diffs](https://github.com/tresnanda/kybern/blob/main/apps/gpuix/src/transcript/store.ts): `apps/gpuix/src/transcript/store.ts`
- [Pull Request Review](https://github.com/tresnanda/kybern/blob/main/apps/gpuix/src/pulls/useReview.ts): `apps/gpuix/src/pulls/useReview.ts`
- [Navigation State](https://github.com/tresnanda/kybern/blob/main/apps/gpuix/src/nav/store.ts): `apps/gpuix/src/nav/store.ts`
- [Platform Services](https://github.com/tresnanda/kybern/blob/main/apps/gpuix/src/platform/os.ts): `apps/gpuix/src/platform/os.ts`
- [Environment Selection](https://github.com/tresnanda/kybern/blob/main/apps/gpuix/src/shell/environment.ts): `apps/gpuix/src/shell/environment.ts`

### Daemon Runtime

- [Agent Orchestrator](https://github.com/tresnanda/kybern/blob/main/crates/kybern-daemon/src/orchestrator.rs): `crates/kybern-daemon/src/orchestrator.rs`
- [Task Orchestration](https://github.com/tresnanda/kybern/blob/main/crates/kybern-daemon/src/orchestrator/tasks.rs): `crates/kybern-daemon/src/orchestrator/tasks.rs`
- [Daemon State](https://github.com/tresnanda/kybern/blob/main/crates/kybern-daemon/src/state.rs): `crates/kybern-daemon/src/state.rs`
- [Authentication](https://github.com/tresnanda/kybern/blob/main/crates/kybern-daemon/src/auth.rs): `crates/kybern-daemon/src/auth.rs`
- [Remote Access](https://github.com/tresnanda/kybern/blob/main/crates/kybern-daemon/src/network/client_grant.rs): `crates/kybern-daemon/src/network/client_grant.rs`
- [Agent Drivers](https://github.com/tresnanda/kybern/blob/main/crates/kybern-drivers/src/account_auth.rs): `crates/kybern-drivers/src/account_auth.rs`
- [Persistent Store](https://github.com/tresnanda/kybern/blob/main/crates/kybern-store/src/tasks.rs): `crates/kybern-store/src/tasks.rs`

### Client Applications

- [Mobile Companion](https://github.com/tresnanda/kybern/blob/main/apps/mobile/app/tasks.tsx): `apps/mobile/app/tasks.tsx`
- [Mobile Tasks](https://github.com/tresnanda/kybern/blob/main/apps/mobile/src/features/Tasks.tsx): `apps/mobile/src/features/Tasks.tsx`
- [Mobile Runtime](https://github.com/tresnanda/kybern/blob/main/apps/mobile/src/state/runtime.ts): `apps/mobile/src/state/runtime.ts`
- [Paired Machines](https://github.com/tresnanda/kybern/blob/main/apps/mobile/src/machines/storage.ts): `apps/mobile/src/machines/storage.ts`
- [Command Line](https://github.com/tresnanda/kybern/blob/main/crates/kybern-cli/src/lib.rs): `crates/kybern-cli/src/lib.rs`

### Shared Protocol

- [Client Transport](https://github.com/tresnanda/kybern/blob/main/packages/kybern-client/src/client.ts): `packages/kybern-client/src/client.ts`
- [Wire Types](https://github.com/tresnanda/kybern/blob/main/packages/kybern-client/src/types.ts): `packages/kybern-client/src/types.ts`
- [Protocol Authentication](https://github.com/tresnanda/kybern/blob/main/crates/kybern-protocol/src/auth.rs): `crates/kybern-protocol/src/auth.rs`

### Other components

- **Engineer**
- **Phone User**
- **Coding Agents**
- **Git Worktrees**
- **Remote Host**

## Connections

- Engineer → Desktop Workspace: uses (evidence: `README.md`)
- Desktop Workspace → Agent Composer: configures agents (evidence: `README.md`)
- Agent Composer → Agent Orchestrator: starts sessions (evidence: `README.md`)
- Agent Orchestrator → Agent Drivers: runs protocols (evidence: `README.md`)
- Agent Orchestrator → Git Worktrees: isolates work (evidence: `README.md`)
- Agent Orchestrator → Persistent Store: persists turns (evidence: `README.md`)
- Agent Orchestrator → Task Orchestration: coordinates tasks
- Desktop Workspace → Workspace State: hosts workspace
- Workspace State → Transcript & Diffs: opens stream (evidence: `apps/gpuix/src/state.ts`)
- Desktop Workspace → Navigation State: presents navigation
- Desktop Workspace → Environment Selection: selects environment (evidence: `apps/gpuix/src/App.tsx`)
- Transcript & Diffs → Platform Services: uses clipboard (evidence: `apps/gpuix/src/transcript/store.ts`)
- Desktop Workspace → Pull Request Review: supports review
- Desktop Workspace → Client Transport: connects remotely (evidence: `README.md`)
- Remote Host → Agent Orchestrator: hosts workloads (evidence: `README.md`)
- Engineer → Mobile Companion: pairs device (evidence: `README.md`)
- Mobile Companion → Mobile Tasks: shows tasks (evidence: `apps/mobile/app/tasks.tsx`)
- Mobile Tasks → Mobile Runtime: loads and controls (evidence: `apps/mobile/src/features/Tasks.tsx`)
- Mobile Runtime → Paired Machines: saves pairing (evidence: `apps/mobile/src/state/runtime.ts`)
- Mobile Runtime → Client Transport: uses transport
- Phone User → Mobile Companion: monitors work (evidence: `README.md`)
- Client Transport → Agent Orchestrator: sends requests (evidence: `README.md`)
- Agent Orchestrator → Protocol Authentication: checks credentials
- Client Transport → Wire Types: uses protocol types (evidence: `packages/kybern-client/src/client.ts`)
- Engineer → Command Line: runs headless (evidence: `README.md`)
