# qybaihe/mu architecture

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

- Interactive diagram: https://gitdiagram.com/qybaihe/mu
- Repository: https://github.com/qybaihe/mu

## Overview

mu is a coding agent with desktop and command-line surfaces; its central workflow is user input, model/tool work, bounded judgments that affect agent decisions, and a completed turn. The README also describes context and lesson management, browser and file-related decision points, teamwork, and hosted or local judges. The tree supports the desktop renderer, Kyrn runtime, bridges, persistence, and judge-related components; source excerpts are partial, so some documented subsystem wiring is intentionally left unspecified.

Main entry points: [`desktop/packages/desktop/src/process/agent/kyrn/harness.ts`](https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/agent/kyrn/harness.ts) (Turn harness), [`desktop/packages/desktop/src/process/agent/kyrn/KyrnAgent.ts`](https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/agent/kyrn/KyrnAgent.ts) (Kyrn agent), [`desktop/packages/desktop/src/process/agent/kyrn/localJudge.ts`](https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/agent/kyrn/localJudge.ts) (Judge orchestration), [`desktop/packages/desktop/src/renderer`](https://github.com/qybaihe/mu/tree/main/desktop/packages/desktop/src/renderer) (Desktop renderer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_renderer["Desktop renderer"]
  node_sendbox["Chat input<br/>[index.tsx]"]
  node_mobile["Mobile client<br/>[ChatScreen.tsx]"]
end

subgraph group_runtime["Agent runtime"]
  node_bridge["Application bridge"]
  node_kyrn["Kyrn agent<br/>[KyrnAgent.ts]"]
  node_harness["Turn harness<br/>[harness.ts]"]
  node_session["Conversation session"]
  node_toolserver["Built-in tools"]
  node_skills["Skills service<br/>[index.ts]"]
end

subgraph group_judgment["Judgment kernel"]
  node_judge["Judge orchestration<br/>[localJudge.ts]"]
  node_localmodel["Local Laya judge<br/>[judge.ts]"]
  node_hosted["Hosted judges<br/>[localJudge.ts]"]
  node_lessons["Lesson memory<br/>[lessons.ts]"]
end

subgraph group_services["State and integrations"]
  node_api["Model clients<br/>[ClientFactory.ts]"]
  node_database[("Conversation database<br/>[schema.ts]")]
  node_settings["Agent settings<br/>[settings.ts]"]
end

node_user(("User"))
node_model(("Model provider"))
node_tools(("Tool processes"))
node_judgeproviders(("Judge providers"))

node_user -->|"enters request"| node_sendbox
node_sendbox -->|"submits input"| node_renderer
node_user -->|"sends message"| node_mobile
node_renderer -->|"invokes RPC"| node_bridge
node_mobile -->|"connects to agent"| node_kyrn
node_bridge -->|"dispatches requests"| node_kyrn
node_kyrn -->|"runs turn"| node_harness
node_harness -->|"requests model"| node_api
node_api -->|"sends prompts"| node_model
node_model -->|"returns response"| node_harness
node_harness -->|"dispatches tools"| node_toolserver
node_toolserver -->|"runs operations"| node_tools
node_harness -->|"asks decisions"| node_judge
node_judge -.->|"uses local judge"| node_localmodel
node_judge -.->|"uses hosted judge"| node_hosted
node_hosted -.->|"sends questions"| node_judgeproviders
node_harness -->|"recalls and captures"| node_lessons
node_harness -->|"loads relevant skills"| node_skills
node_session -->|"persists conversations"| node_database
node_kyrn -->|"reads configuration"| node_settings

click node_renderer "https://github.com/qybaihe/mu/tree/main/desktop/packages/desktop/src/renderer"
click node_sendbox "https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/renderer/components/chat/SendBox/index.tsx"
click node_mobile "https://github.com/qybaihe/mu/blob/main/desktop/mobile/src/components/chat/ChatScreen.tsx"
click node_bridge "https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/bridge/applicationBridge.ts"
click node_kyrn "https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/agent/kyrn/KyrnAgent.ts"
click node_harness "https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/agent/kyrn/harness.ts"
click node_session "https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/agent/kyrn/conversationSession.ts"
click node_toolserver "https://github.com/qybaihe/mu/tree/main/desktop/packages/desktop/src/process/resources/builtinMcp"
click node_skills "https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/services/skills/index.ts"
click node_judge "https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/agent/kyrn/localJudge.ts"
click node_localmodel "https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/services/localJudgeOnnx/judge.ts"
click node_hosted "https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/common/kyrn/localJudge.ts"
click node_lessons "https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/agent/kyrn/lessons.ts"
click node_api "https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/common/api/ClientFactory.ts"
click node_database "https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/services/database/schema.ts"
click node_settings "https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/agent/kyrn/settings.ts"

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_renderer,node_sendbox,node_mobile,node_user toneBlue
class node_bridge,node_kyrn,node_harness,node_session,node_toolserver,node_skills toneAmber
class node_judge,node_localmodel,node_hosted,node_lessons toneMint
class node_api,node_database,node_settings toneRose
class node_model,node_tools,node_judgeproviders toneIndigo
```

## Components

### User interfaces

- [Desktop renderer](https://github.com/qybaihe/mu/tree/main/desktop/packages/desktop/src/renderer): `desktop/packages/desktop/src/renderer`
- [Chat input](https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/renderer/components/chat/SendBox/index.tsx): `desktop/packages/desktop/src/renderer/components/chat/SendBox/index.tsx`
- [Mobile client](https://github.com/qybaihe/mu/blob/main/desktop/mobile/src/components/chat/ChatScreen.tsx): `desktop/mobile/src/components/chat/ChatScreen.tsx`

### Agent runtime

- [Application bridge](https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/bridge/applicationBridge.ts): `desktop/packages/desktop/src/process/bridge/applicationBridge.ts`
- [Kyrn agent](https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/agent/kyrn/KyrnAgent.ts): `desktop/packages/desktop/src/process/agent/kyrn/KyrnAgent.ts`
- [Turn harness](https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/agent/kyrn/harness.ts): `desktop/packages/desktop/src/process/agent/kyrn/harness.ts`
- [Conversation session](https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/agent/kyrn/conversationSession.ts): `desktop/packages/desktop/src/process/agent/kyrn/conversationSession.ts`
- [Built-in tools](https://github.com/qybaihe/mu/tree/main/desktop/packages/desktop/src/process/resources/builtinMcp): `desktop/packages/desktop/src/process/resources/builtinMcp`
- [Skills service](https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/services/skills/index.ts): `desktop/packages/desktop/src/process/services/skills/index.ts`

### Judgment kernel

- [Judge orchestration](https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/agent/kyrn/localJudge.ts): `desktop/packages/desktop/src/process/agent/kyrn/localJudge.ts`
- [Local Laya judge](https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/services/localJudgeOnnx/judge.ts): `desktop/packages/desktop/src/process/services/localJudgeOnnx/judge.ts`
- [Hosted judges](https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/common/kyrn/localJudge.ts): `desktop/packages/desktop/src/common/kyrn/localJudge.ts`
- [Lesson memory](https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/agent/kyrn/lessons.ts): `desktop/packages/desktop/src/process/agent/kyrn/lessons.ts`

### State and integrations

- [Model clients](https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/common/api/ClientFactory.ts): `desktop/packages/desktop/src/common/api/ClientFactory.ts`
- [Conversation database](https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/services/database/schema.ts): `desktop/packages/desktop/src/process/services/database/schema.ts`
- [Agent settings](https://github.com/qybaihe/mu/blob/main/desktop/packages/desktop/src/process/agent/kyrn/settings.ts): `desktop/packages/desktop/src/process/agent/kyrn/settings.ts`

### Other components

- **User**
- **Model provider**
- **Tool processes**
- **Judge providers**

## Connections

- User → Chat input: enters request
- Chat input → Desktop renderer: submits input
- User → Mobile client: sends message
- Desktop renderer → Application bridge: invokes RPC
- Mobile client → Kyrn agent: connects to agent
- Application bridge → Kyrn agent: dispatches requests
- Kyrn agent → Turn harness: runs turn
- Turn harness → Model clients: requests model
- Model clients → Model provider: sends prompts
- Model provider → Turn harness: returns response
- Turn harness → Built-in tools: dispatches tools
- Built-in tools → Tool processes: runs operations
- Turn harness → Judge orchestration: asks decisions
- Judge orchestration → Local Laya judge: uses local judge
- Judge orchestration → Hosted judges: uses hosted judge
- Hosted judges → Judge providers: sends questions
- Turn harness → Lesson memory: recalls and captures
- Turn harness → Skills service: loads relevant skills
- Conversation session → Conversation database: persists conversations
- Kyrn agent → Agent settings: reads configuration
