# xcisxc29/dsh-wechat architecture

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

- Interactive diagram: https://gitdiagram.com/xcisxc29/dsh-wechat
- Repository: https://github.com/xcisxc29/dsh-wechat

## Overview

This is a DSH desktop plugin that lets a WeChat user operate DSH sessions and exchange messages and media through Tencent’s iLink gateway. The principal path is phone message → channel polling → host routing to a DSH session → response back to WeChat. The graph also preserves login/settings, session controls, attachments, agent tool activity and remote approval/question handling. Several core modules are indexed but not excerpted; their internal relationships are omitted unless the README or shown source supports them.

Main entry points: [`packages/bundle/src/host.ts`](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/bundle/src/host.ts) (Plugin host), [`packages/core/src/channel.ts`](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/channel.ts) (Long-poll channel), [`packages/core/src/media.ts`](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/media.ts) (Media transfer), [`packages/core/src/http.ts`](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/http.ts) (iLink HTTP)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_plugin["DSH plugin host"]
  node_host["Plugin host<br/>[host.ts]"]
  node_settings["Settings routes<br/>[routes.ts]"]
  node_services["DSH services<br/>[services.ts]"]
  node_interaction["Question parsing<br/>[interactions.ts]"]
  node_kind["Media classification<br/>[media-kind.ts]"]
end

subgraph group_channel["WeChat channel"]
  node_channel["Long-poll channel<br/>[channel.ts]"]
  node_login["QR login<br/>[login.ts]"]
end

subgraph group_core["Core protocol"]
  node_http["iLink HTTP<br/>[http.ts]"]
  node_crypto["Media encryption<br/>[crypto.ts]"]
  node_media["Media transfer<br/>[media.ts]"]
  node_silk["Voice conversion<br/>[silk.ts]"]
  node_thumbnail["Media thumbnails<br/>[thumbnail.ts]"]
  node_render["Message rendering<br/>[render.ts]"]
  node_state[("Channel state<br/>[state.ts]")]
  node_types["iLink wire types<br/>[types.ts]"]
end

subgraph group_sessions["Sessions and interaction"]
  node_router["Session router<br/>[router.ts]"]
  node_index["Session index<br/>[session-index.ts]"]
  node_approval["Remote approvals<br/>[host.ts]"]
  node_tools["Tool activity<br/>[host.ts]"]
end

node_user(("WeChat user"))
node_gateway["DSH agent"]
node_tencent["Tencent iLink"]

node_user -->|"sends messages"| node_channel
node_channel -->|"polls and sends"| node_tencent
node_channel -.->|"delivers inbound"| node_host
node_host -.->|"routes prompts"| node_router
node_router -->|"ensures sessions"| node_gateway
node_router -.->|"saves bindings"| node_state
node_host -.->|"uses host services"| node_gateway
node_host -->|"parses replies"| node_interaction
node_host -->|"classifies media"| node_kind
node_host -->|"uploads attachments"| node_media
node_host -->|"renders session rows"| node_render
node_host -->|"persists channel state"| node_state
node_host -.->|"serves settings"| node_settings
node_host -->|"handles prompts"| node_approval
node_host -->|"reports tool activity"| node_tools
node_login -->|"requests login"| node_http
node_channel -->|"calls API"| node_http
node_channel -->|"detects media items"| node_media
node_media -.->|"requests media endpoints"| node_http
node_media -->|"parses media keys"| node_crypto
node_media -->|"converts voice"| node_silk
node_silk -.->|"uses thumbnail support"| node_thumbnail
node_host -.->|"reads session data"| node_index
node_http -->|"uses protocol types"| node_types

click node_host "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/bundle/src/host.ts"
click node_settings "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/bundle/src/routes.ts"
click node_services "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/bundle/src/services.ts"
click node_interaction "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/bundle/src/interactions.ts"
click node_kind "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/bundle/src/media-kind.ts"
click node_channel "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/channel.ts"
click node_login "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/login.ts"
click node_http "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/http.ts"
click node_crypto "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/crypto.ts"
click node_media "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/media.ts"
click node_silk "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/silk.ts"
click node_thumbnail "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/thumbnail.ts"
click node_render "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/render.ts"
click node_state "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/state.ts"
click node_router "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/router.ts"
click node_index "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/session-index.ts"
click node_approval "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/bundle/src/host.ts"
click node_tools "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/bundle/src/host.ts"
click node_types "https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/types.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_host,node_settings,node_services,node_interaction,node_kind,node_user toneBlue
class node_channel,node_login toneAmber
class node_http,node_crypto,node_media,node_silk,node_thumbnail,node_render,node_state,node_types toneMint
class node_router,node_index,node_approval,node_tools toneRose
class node_gateway,node_tencent toneIndigo
```

## Components

### DSH plugin host

- [Plugin host](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/bundle/src/host.ts): `packages/bundle/src/host.ts`
- [Settings routes](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/bundle/src/routes.ts): `packages/bundle/src/routes.ts`
- [DSH services](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/bundle/src/services.ts): `packages/bundle/src/services.ts`
- [Question parsing](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/bundle/src/interactions.ts): `packages/bundle/src/interactions.ts`
- [Media classification](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/bundle/src/media-kind.ts): `packages/bundle/src/media-kind.ts`

### WeChat channel

- [Long-poll channel](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/channel.ts): `packages/core/src/channel.ts`
- [QR login](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/login.ts): `packages/core/src/login.ts`

### Core protocol

- [iLink HTTP](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/http.ts): `packages/core/src/http.ts`
- [Media encryption](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/crypto.ts): `packages/core/src/crypto.ts`
- [Media transfer](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/media.ts): `packages/core/src/media.ts`
- [Voice conversion](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/silk.ts): `packages/core/src/silk.ts`
- [Media thumbnails](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/thumbnail.ts): `packages/core/src/thumbnail.ts`
- [Message rendering](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/render.ts): `packages/core/src/render.ts`
- [Channel state](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/state.ts): `packages/core/src/state.ts`
- [iLink wire types](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/types.ts): `packages/core/src/types.ts`

### Sessions and interaction

- [Session router](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/router.ts): `packages/core/src/router.ts`
- [Session index](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/core/src/session-index.ts): `packages/core/src/session-index.ts`
- [Remote approvals](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/bundle/src/host.ts): `packages/bundle/src/host.ts`
- [Tool activity](https://github.com/xcisxc29/dsh-wechat/blob/main/packages/bundle/src/host.ts): `packages/bundle/src/host.ts`

### Other components

- **WeChat user**
- **DSH agent**
- **Tencent iLink**

## Connections

- WeChat user → Long-poll channel: sends messages (evidence: `README.md`)
- Long-poll channel → Tencent iLink: polls and sends (evidence: `packages/core/src/channel.ts`)
- Long-poll channel → Plugin host: delivers inbound
- Plugin host → Session router: routes prompts
- Session router → DSH agent: ensures sessions (evidence: `packages/core/src/router.ts`)
- Session router → Channel state: saves bindings (evidence: `packages/core/src/state.ts`)
- Plugin host → DSH agent: uses host services
- Plugin host → Question parsing: parses replies (evidence: `packages/bundle/src/host.ts`)
- Plugin host → Media classification: classifies media (evidence: `packages/bundle/src/host.ts`)
- Plugin host → Media transfer: uploads attachments (evidence: `packages/bundle/src/host.ts`)
- Plugin host → Message rendering: renders session rows (evidence: `packages/bundle/src/host.ts`)
- Plugin host → Channel state: persists channel state (evidence: `packages/bundle/src/host.ts`)
- Plugin host → Settings routes: serves settings (evidence: `packages/bundle/src/host.ts`)
- Plugin host → Remote approvals: handles prompts (evidence: `packages/bundle/src/host.ts`)
- Plugin host → Tool activity: reports tool activity (evidence: `packages/bundle/src/host.ts`)
- QR login → iLink HTTP: requests login (evidence: `packages/core/src/login.ts`)
- Long-poll channel → iLink HTTP: calls API (evidence: `packages/core/src/channel.ts`)
- Long-poll channel → Media transfer: detects media items (evidence: `packages/core/src/channel.ts`)
- Media transfer → iLink HTTP: requests media endpoints (evidence: `packages/core/src/media.ts`)
- Media transfer → Media encryption: parses media keys (evidence: `packages/core/src/media.ts`)
- Media transfer → Voice conversion: converts voice (evidence: `packages/core/src/media.ts`)
- Voice conversion → Media thumbnails: uses thumbnail support (evidence: `packages/core/src/silk.ts`)
- Plugin host → Session index: reads session data
- iLink HTTP → iLink wire types: uses protocol types (evidence: `packages/core/src/http.ts`)
