# cloveric/cc-telegram-bridge architecture

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

- Interactive diagram: https://gitdiagram.com/cloveric/cc-telegram-bridge
- Repository: https://github.com/cloveric/cc-telegram-bridge

## Overview

TaroCub runs local coding-agent CLIs as durable chat bots, primarily in Feishu/Lark, with Telegram retained as an optional channel. The main workflow is an incoming Lark message being normalized, handled as a command or agent turn, executed through the bridge and selected engine, then delivered back to the chat. The product also includes file and voice handling, scheduling, multi-bot routing, durable state, audit/timeline records, and an operator console. Edges reflect README claims and sampled source references; unsampled subsystem details and some internal wiring are not asserted.

Main entry points: [`src/lark/message-handler.ts`](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/lark/message-handler.ts) (Lark message handler), [`src/lark/service.ts`](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/lark/service.ts) (Lark service), [`src/service.ts`](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/service.ts) (Telegram channel), [`src/runtime/bridge.ts`](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/runtime/bridge.ts) (Agent bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_channels["Chat channels"]
  node_lark["Lark service<br/>[service.ts]"]
  node_normalize["Message normalization"]
  node_lark_handler["Lark message handler<br/>[message-handler.ts]"]
  node_telegram["Telegram channel<br/>[service.ts]"]
end

subgraph group_agent["Agent execution"]
  node_bridge["Agent bridge<br/>[bridge.ts]"]
  node_engine_adapters["Engine adapters<br/>[adapter.ts]"]
end

subgraph group_capabilities["Bot capabilities"]
  node_files_voice["Files and voice<br/>[files.ts]"]
  node_cron["Scheduled tasks<br/>[cron-scheduler.ts]"]
  node_multi_bot["Multi-bot routing<br/>[bus-handler.ts]"]
  node_web_console["Web console<br/>[App.tsx]"]
end

subgraph group_state["Durable state"]
  node_sessions[("Sessions<br/>[session-store.ts]")]
  node_runtime_state[("Runtime state<br/>[runtime-state.ts]")]
  node_audit[("Audit and timeline<br/>[audit-log.ts]")]
  node_file_workflows[("File workflows<br/>[file-workflow.ts]")]
end

subgraph group_operations["Operations"]
  node_entrypoint["Application entrypoint<br/>[index.ts]"]
  node_instance_config["Instance configuration<br/>[instance-config.ts]"]
end

node_user(("Chat user"))
node_local_agents{{"Local agent CLIs"}}
node_lark_api{{"Feishu/Lark platform"}}
node_telegram_api{{"Telegram platform"}}

node_user -->|"messages"| node_lark
node_lark -.->|"normalizes"| node_normalize
node_lark -->|"dispatches"| node_lark_handler
node_lark_handler -->|"uses"| node_normalize
node_lark_handler -->|"runs turns"| node_bridge
node_bridge -->|"invokes"| node_engine_adapters
node_engine_adapters -->|"runs locally"| node_local_agents
node_lark -->|"connects"| node_lark_api
node_lark_handler -->|"handles media"| node_files_voice
node_files_voice -->|"prepares attachments"| node_file_workflows
node_lark_handler -->|"resumes sessions"| node_sessions
node_lark -->|"schedules tasks"| node_cron
node_lark_handler -->|"records events"| node_audit
node_lark_handler -->|"tracks turns"| node_runtime_state
node_lark_handler -->|"loads settings"| node_instance_config
node_user -.->|"messages"| node_telegram
node_telegram -.->|"connects"| node_telegram_api
node_telegram -.->|"runs agent turns"| node_bridge
node_entrypoint -->|"starts service"| node_lark
node_entrypoint -->|"starts service"| node_telegram
node_multi_bot -->|"handles requests"| node_bridge
node_web_console -.->|"operator interface"| node_user

click node_lark "https://github.com/cloveric/cc-telegram-bridge/blob/main/src/lark/service.ts"
click node_normalize "https://github.com/cloveric/cc-telegram-bridge/blob/main/src/lark/message-normalizer.ts"
click node_lark_handler "https://github.com/cloveric/cc-telegram-bridge/blob/main/src/lark/message-handler.ts"
click node_telegram "https://github.com/cloveric/cc-telegram-bridge/blob/main/src/service.ts"
click node_bridge "https://github.com/cloveric/cc-telegram-bridge/blob/main/src/runtime/bridge.ts"
click node_engine_adapters "https://github.com/cloveric/cc-telegram-bridge/blob/main/src/codex/adapter.ts"
click node_files_voice "https://github.com/cloveric/cc-telegram-bridge/blob/main/src/lark/files.ts"
click node_cron "https://github.com/cloveric/cc-telegram-bridge/blob/main/src/runtime/cron-scheduler.ts"
click node_multi_bot "https://github.com/cloveric/cc-telegram-bridge/blob/main/src/bus/bus-handler.ts"
click node_web_console "https://github.com/cloveric/cc-telegram-bridge/blob/main/web/src/App.tsx"
click node_sessions "https://github.com/cloveric/cc-telegram-bridge/blob/main/src/state/session-store.ts"
click node_runtime_state "https://github.com/cloveric/cc-telegram-bridge/blob/main/src/state/runtime-state.ts"
click node_audit "https://github.com/cloveric/cc-telegram-bridge/blob/main/src/state/audit-log.ts"
click node_file_workflows "https://github.com/cloveric/cc-telegram-bridge/blob/main/src/runtime/file-workflow.ts"
click node_entrypoint "https://github.com/cloveric/cc-telegram-bridge/blob/main/src/index.ts"
click node_instance_config "https://github.com/cloveric/cc-telegram-bridge/blob/main/src/telegram/instance-config.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_lark,node_normalize,node_lark_handler,node_telegram,node_user toneBlue
class node_bridge,node_engine_adapters toneAmber
class node_files_voice,node_cron,node_multi_bot,node_web_console toneMint
class node_sessions,node_runtime_state,node_audit,node_file_workflows toneRose
class node_entrypoint,node_instance_config,node_local_agents,node_lark_api,node_telegram_api toneIndigo
```

## Components

### Chat channels

- [Lark service](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/lark/service.ts): `src/lark/service.ts`
- [Message normalization](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/lark/message-normalizer.ts): `src/lark/message-normalizer.ts`
- [Lark message handler](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/lark/message-handler.ts): `src/lark/message-handler.ts`
- [Telegram channel](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/service.ts): `src/service.ts`

### Agent execution

- [Agent bridge](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/runtime/bridge.ts): `src/runtime/bridge.ts`
- [Engine adapters](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/codex/adapter.ts): `src/codex/adapter.ts`

### Bot capabilities

- [Files and voice](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/lark/files.ts): `src/lark/files.ts`
- [Scheduled tasks](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/runtime/cron-scheduler.ts): `src/runtime/cron-scheduler.ts`
- [Multi-bot routing](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/bus/bus-handler.ts): `src/bus/bus-handler.ts`
- [Web console](https://github.com/cloveric/cc-telegram-bridge/blob/main/web/src/App.tsx): `web/src/App.tsx`

### Durable state

- [Sessions](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/state/session-store.ts): `src/state/session-store.ts`
- [Runtime state](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/state/runtime-state.ts): `src/state/runtime-state.ts`
- [Audit and timeline](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/state/audit-log.ts): `src/state/audit-log.ts`
- [File workflows](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/runtime/file-workflow.ts): `src/runtime/file-workflow.ts`

### Operations

- [Application entrypoint](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/index.ts): `src/index.ts`
- [Instance configuration](https://github.com/cloveric/cc-telegram-bridge/blob/main/src/telegram/instance-config.ts): `src/telegram/instance-config.ts`

### Other components

- **Chat user**
- **Local agent CLIs**
- **Feishu/Lark platform**
- **Telegram platform**

## Connections

- Chat user → Lark service: messages (evidence: `README.md`)
- Lark service → Message normalization: normalizes (evidence: `src/lark/service.ts`)
- Lark service → Lark message handler: dispatches (evidence: `src/lark/service.ts`)
- Lark message handler → Message normalization: uses (evidence: `src/lark/message-handler.ts`)
- Lark message handler → Agent bridge: runs turns (evidence: `README.md`)
- Agent bridge → Engine adapters: invokes (evidence: `src/service.ts`)
- Engine adapters → Local agent CLIs: runs locally (evidence: `README.md`)
- Lark service → Feishu/Lark platform: connects (evidence: `README.md`)
- Lark message handler → Files and voice: handles media (evidence: `src/lark/message-handler.ts`)
- Files and voice → File workflows: prepares attachments (evidence: `src/lark/files.ts`)
- Lark message handler → Sessions: resumes sessions (evidence: `src/lark/message-handler.ts`)
- Lark service → Scheduled tasks: schedules tasks (evidence: `src/lark/service.ts`)
- Lark message handler → Audit and timeline: records events (evidence: `src/lark/message-handler.ts`)
- Lark message handler → Runtime state: tracks turns
- Lark message handler → Instance configuration: loads settings (evidence: `src/lark/message-handler.ts`)
- Chat user → Telegram channel: messages (evidence: `README.md`)
- Telegram channel → Telegram platform: connects (evidence: `README.md`)
- Telegram channel → Agent bridge: runs agent turns (evidence: `README.md`)
- Application entrypoint → Lark service: starts service (evidence: `src/index.ts`)
- Application entrypoint → Telegram channel: starts service (evidence: `src/index.ts`)
- Multi-bot routing → Agent bridge: handles requests (evidence: `src/bus/bus-handler.ts`)
- Web console → Chat user: operator interface
