LobeHub provides a robust infrastructure for bridging AI agents to external communication platforms and remote execution environments. This system allows agents to operate as "bots" on platforms like WeChat, Discord, or Slack, and enables "Heterogeneous Agents" to run in local desktop environments while communicating with the cloud-hosted chat interface.
The integration layer is built around a "Gateway" pattern. For remote devices and desktop integrations, the GatewayConnectionService manages persistent connections, while the deviceGateway handles the routing of tool calls and message APIs between the LobeHub server and remote clients. The system also includes a database-backed provider system for managing bot credentials and settings across various messaging platforms.
The following diagrams illustrate how natural language concepts map to specific code entities within the platform integration and bot management systems.
Conceptual Bridge: Platform Integration
Sources: apps/server/src/routers/lambda/device.ts13-18 apps/desktop/src/main/controllers/GatewayConnectionCtr.ts151-166 apps/desktop/src/main/controllers/GitCtr.ts56-58
Conceptual Bridge: Bot Channel Persistence
Sources: packages/database/src/schemas/agentBotProvider.ts84-105 packages/database/src/schemas/index.ts2
The core of the remote integration is the DeviceGateway and its corresponding client-side controller.
The DeviceGateway class is responsible for communicating with the LobeHub Gateway (typically a Cloudflare Worker). It handles:
executeToolCall requests from the AI Agent to a specific remote device apps/server/src/services/deviceGateway/index.ts107-115The GatewayConnectionCtr acts as the IPC bridge within the Electron application. It manages the lifecycle of "Platform Tasks" (e.g., running background agents) apps/desktop/src/main/controllers/GatewayConnectionCtr.ts151-158
Key functionalities include:
lh notify) that allows background agents to push updates (findings, decisions, final answers) back to the LobeHub UI as a single message bubble apps/desktop/src/main/controllers/GatewayConnectionCtr.ts48-72readFile, writeFile, and runCommand to the appropriate local controllers apps/desktop/src/main/controllers/GatewayConnectionCtr.ts107-115Sources: apps/server/src/services/deviceGateway/index.ts86-193 apps/desktop/src/main/controllers/GatewayConnectionCtr.ts41-160
The system persists bot integration configurations in the agent_bot_providers table. This allows an agent to be associated with multiple messaging platforms (adapters).
agent_bot_providers TableThis table stores the mapping between LobeHub agents and external platform applications packages/database/src/schemas/agentBotProvider.ts84-96
| Column | Type | Description |
|---|---|---|
agent_id | text | Reference to the agents.id packages/database/src/schemas/agentBotProvider.ts86 |
platform | varchar(50) | Adapter type: wechat, qq, feishu, discord, slack, telegram packages/database/src/schemas/agentBotProvider.ts89 |
application_id | varchar(255) | The unique ID of the bot on the external platform packages/database/src/schemas/agentBotProvider.ts90 |
credentials | text | Encrypted API keys or tokens for the platform packages/database/src/schemas/agentBotProvider.ts91 |
settings | jsonb | Platform-specific configuration (e.g., webhook URLs, command prefixes) packages/database/src/schemas/agentBotProvider.ts92 |
Sources: packages/database/src/schemas/agentBotProvider.ts84-105 docs/development/database-schema.dbml84-105
Heterogeneous agents are external processes (like CLI-based AI tools) that are bridged into the LobeHub interface via the gateway.
Sources: apps/desktop/src/main/controllers/GatewayConnectionCtr.ts48-73 apps/server/src/routers/lambda/device.ts99-130
LobeHub provides deep integration with the local development environment, specifically for Git-based workflows, surfaced through the channel management UI.
The GitController exposes repository management features to the agent:
getGitBranch, listGitBranches, and checkoutGitBranch apps/desktop/src/main/controllers/GitCtr.ts65-130listGitWorktrees and addGitWorktree apps/desktop/src/main/controllers/GitCtr.ts94-161pullGitBranch and pushGitBranch operations apps/desktop/src/main/controllers/GitCtr.ts164-171The integration is surfaced in the UI through specialized components in the Chat Input:
Sources: apps/desktop/src/main/controllers/GitCtr.ts56-177 src/features/ChatInput/ControlBar/WorkingDirectoryPicker.tsx222-255
The system uses a TRPC-based router (deviceRouter) to handle incoming requests and route them to the gateway service.
| Route | Function | Description |
|---|---|---|
checkCapability | deviceGateway.executeToolCall | Probes if a platform (OpenClaw/Hermes) is available on a device apps/server/src/routers/lambda/device.ts107-115 |
gitBranch | deviceGateway.gitBranch | Retrieves current branch info from a remote device apps/server/src/routers/lambda/device.ts138-148 |
workspaceFileProcedure | assertWorkspaceRootApproved | Security guard ensuring file mutations stay within approved directories apps/server/src/routers/lambda/device.ts87-91 |
Sources: apps/server/src/routers/lambda/device.ts93-193 apps/server/src/services/deviceGateway/index.ts71-82
Channel and device management strings are localized using the device namespace.
locales/en-US/device.json contains keys for working directory management, git status, and worktree operations locales/en-US/device.json1-94locales/zh-CN/device.json provides the same mappings for simplified Chinese locales/zh-CN/device.json1-94Sources: locales/en-US/device.json1-94 packages/locales/src/default/device.ts1-101
Refresh this wiki