@alexlikevibe/lark-channel-bridge 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +372 -0
- package/README.zh.md +372 -0
- package/bin/lark-channel-bridge.mjs +2 -0
- package/dist/cli.js +15073 -0
- package/dist/index.d.ts +161 -0
- package/dist/index.js +604 -0
- package/package.json +87 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lark Channel Bridge contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
# lark-channel-bridge
|
|
2
|
+
|
|
3
|
+
A lightweight bot that bridges Feishu / Lark messenger with your local Claude Code or Codex CLI. Run one command, scan a QR code to bind a PersonalAgent app, and talk to your local coding agent from chat.
|
|
4
|
+
|
|
5
|
+
[中文 README](./README.zh.md)
|
|
6
|
+
|
|
7
|
+
For a product walkthrough, see the [Feishu document](https://larkcommunity.feishu.cn/docx/OaRIdFIRFoLM3xxTmKwcetHqn5e).
|
|
8
|
+
|
|
9
|
+
## What it does
|
|
10
|
+
|
|
11
|
+
- Forwards Feishu / Lark messages to local Claude Code or Codex CLI. Send a DM directly, or `@bot` in a group.
|
|
12
|
+
- **Streaming card**: text replies and tool calls update on one Lark card in real time.
|
|
13
|
+
- **COT process messages**: optionally send a process message with agent progress text and tool calls, then send the final answer separately.
|
|
14
|
+
- **Session continuity**: each chat, topic, or document comment thread keeps its own session.
|
|
15
|
+
- **Queueing and batching**: messages sent in quick succession are handled together; messages sent during a run are queued for the next turn, while commands like `/new`, `/cd`, `/ws use`, and `/stop` can interrupt the current task.
|
|
16
|
+
- **Multiple workspaces**: use `/cd` to switch the current project, and `/ws` to save and reuse common project directories.
|
|
17
|
+
- **Images and files**: send them to the bot directly, and the bridge downloads them locally for the agent.
|
|
18
|
+
- **Interactive cards**: `/help`, `/ws list`, and `/status` return cards with clickable buttons.
|
|
19
|
+
|
|
20
|
+
## Prerequisites
|
|
21
|
+
|
|
22
|
+
- Node.js **>= 20.12.0**
|
|
23
|
+
- At least one local agent installed and logged in:
|
|
24
|
+
- Claude Code: `claude`, see https://docs.anthropic.com/en/docs/claude-code/quickstart
|
|
25
|
+
- Codex CLI: `codex`, see https://developers.openai.com/codex/cli
|
|
26
|
+
- Pi: `pi`, see https://pi.dev
|
|
27
|
+
- A Feishu / Lark **PersonalAgent** app. The first-run QR wizard can create and bind one for you.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm i -g @alexlikevibe/lark-channel-bridge
|
|
33
|
+
# or
|
|
34
|
+
pnpm add -g @alexlikevibe/lark-channel-bridge
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## First run
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
lark-channel-bridge run
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The first run opens a QR-code wizard:
|
|
44
|
+
|
|
45
|
+
1. A QR code renders in your terminal.
|
|
46
|
+
2. Scan it with the Feishu / Lark app.
|
|
47
|
+
3. Pick or create a PersonalAgent app.
|
|
48
|
+
4. If prompted, choose which agent to initialize.
|
|
49
|
+
5. Config is written to `~/.lark-channel/config.json`.
|
|
50
|
+
|
|
51
|
+
You do not need to choose a project directory up front. The bridge creates a profile-managed default working directory; after startup, send `/cd <path>` in Feishu / Lark to switch to a real project.
|
|
52
|
+
|
|
53
|
+
If you already have a PersonalAgent app, pass `--app-id` during initialization to skip app creation. The command prompts for the App Secret.
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
lark-channel-bridge run --app-id cli_xxx
|
|
57
|
+
# or initialize and start the background service directly
|
|
58
|
+
lark-channel-bridge start --app-id cli_xxx
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
For Lark global apps, add `--tenant lark`.
|
|
62
|
+
|
|
63
|
+
## Background service
|
|
64
|
+
|
|
65
|
+
Use `run` for first-run setup and foreground debugging. After the bot can send and receive messages, stop the foreground process with `Ctrl-C`, then use an OS-managed service for background operation:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
lark-channel-bridge start
|
|
69
|
+
lark-channel-bridge status
|
|
70
|
+
lark-channel-bridge stop
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Install globally before using service commands. The daemon's launchd plist / systemd unit / Windows task records the bridge CLI path; if that path comes from an npm temp cache through `npx`, the daemon can break when the cache is cleaned. `run` is fine through `npx` as a one-shot foreground process.
|
|
74
|
+
|
|
75
|
+
Service commands install a per-profile service:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
lark-channel-bridge start [--profile <name>]
|
|
79
|
+
lark-channel-bridge stop [--profile <name>]
|
|
80
|
+
lark-channel-bridge restart [--profile <name>]
|
|
81
|
+
lark-channel-bridge status [--profile <name>]
|
|
82
|
+
lark-channel-bridge unregister [--profile <name>]
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Platform mapping:
|
|
86
|
+
- **macOS**: launchd user agent `ai.lark-channel-bridge.bot.<profile>`
|
|
87
|
+
- **Linux**: systemd user unit `lark-channel-bridge.bot.<profile>.service`
|
|
88
|
+
- **Windows**: Task Scheduler task `LarkChannelBridge.Bot.<profile>`, launched through a `.cmd` wrapper
|
|
89
|
+
|
|
90
|
+
Daemon logs are under `~/.lark-channel/profiles/<profile>/logs/daemon/`.
|
|
91
|
+
|
|
92
|
+
Daemon services do not inherit arbitrary variables from the shell that ran `start`. For provider API keys or proxy settings needed by daemon-mode agents, create daemon env files:
|
|
93
|
+
|
|
94
|
+
```env
|
|
95
|
+
# ~/.lark-channel/daemon.env # shared by all profiles
|
|
96
|
+
# ~/.lark-channel/profiles/<profile>/daemon.env # overrides per profile
|
|
97
|
+
ZAI_CODING_CN_API_KEY=xxx
|
|
98
|
+
HTTPS_PROXY=http://127.0.0.1:7890
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Restart the service after editing these files. Env files only provide credentials/settings; they do not select the provider or model. If multiple provider keys are present, the underlying agent CLI and the profile model preference still decide what to use.
|
|
102
|
+
|
|
103
|
+
### Multiple profiles: Claude, Codex, and Pi
|
|
104
|
+
|
|
105
|
+
By default, the bridge starts with the currently selected profile. Use `profile use <name>` to change it. Each profile keeps its own app credentials, sessions, working directories, and logs. Create multiple profiles only when you need to connect multiple PersonalAgent apps, or run Claude, Codex, and Pi as separate bots:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
lark-channel-bridge start --profile claude --agent claude
|
|
109
|
+
lark-channel-bridge start --profile codex --agent codex
|
|
110
|
+
lark-channel-bridge start --profile pi --agent pi
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
For example, to restart only the Codex bot:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
lark-channel-bridge restart --profile codex
|
|
117
|
+
lark-channel-bridge status --profile codex
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Commands
|
|
121
|
+
|
|
122
|
+
### Host CLI
|
|
123
|
+
|
|
124
|
+
```text
|
|
125
|
+
lark-channel-bridge run [--profile <name>] [--agent claude|codex|pi] [--workspace <path>] [-c <config>]
|
|
126
|
+
lark-channel-bridge migrate [--profile <name>] [--agent claude|codex|pi]
|
|
127
|
+
lark-channel-bridge ps
|
|
128
|
+
lark-channel-bridge kill <id|#>
|
|
129
|
+
lark-channel-bridge --help
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
`profile use <name>` changes the profile used by later default starts. Use these profile management commands when running separate Claude / Codex bots, connecting multiple PersonalAgent apps, or doing scripted deployment:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
lark-channel-bridge profile create claude --agent claude
|
|
136
|
+
lark-channel-bridge profile create codex --agent codex
|
|
137
|
+
lark-channel-bridge profile create pi --agent pi
|
|
138
|
+
lark-channel-bridge profile list
|
|
139
|
+
lark-channel-bridge profile use <name>
|
|
140
|
+
lark-channel-bridge profile remove <name>
|
|
141
|
+
lark-channel-bridge profile remove <name> --purge --yes
|
|
142
|
+
lark-channel-bridge profile export <name> [--output ./profile.json] [--force]
|
|
143
|
+
lark-channel-bridge profile export <name> --include-secrets --yes
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
`profile remove` archives local state by default, including the active profile. If other profiles remain, the bridge switches to the next one; if it was the last profile, the root config is cleared so the same name can be created again. `--purge --yes` permanently deletes local state. `profile export` redacts app secrets by default; `--include-secrets --yes` includes sensitive config.
|
|
147
|
+
|
|
148
|
+
If a profile was created with the wrong agent kind, stop or unregister any matching background service first, then run `profile remove <name>` and recreate it with the intended `--agent`.
|
|
149
|
+
|
|
150
|
+
### Slash commands inside Feishu / Lark
|
|
151
|
+
|
|
152
|
+
| Command | Effect |
|
|
153
|
+
|---|---|
|
|
154
|
+
| `/new`, `/reset` | Clear the current session |
|
|
155
|
+
| `/cd <path>` | Switch working directory and reset the session |
|
|
156
|
+
| `/ws list` | List named workspaces |
|
|
157
|
+
| `/ws save <name>` | Save the current working directory as a named workspace |
|
|
158
|
+
| `/ws use <name>` | Switch to a named workspace |
|
|
159
|
+
| `/ws remove <name>` | Delete a named workspace |
|
|
160
|
+
| `/resume` | Resume compatible history for the same agent, working directory, and permission mode |
|
|
161
|
+
| `/status` | Show profile, agent, working directory, session, lark-cli identity, and run state |
|
|
162
|
+
| `/config` | Adjust presentation preferences, access settings, and lark-cli identity policy |
|
|
163
|
+
| `/invite user @name` | Allow a user to use the bot in DMs |
|
|
164
|
+
| `/invite admin @name` | Add an access-control admin |
|
|
165
|
+
| `/invite group` | Allow the current group to use the bot |
|
|
166
|
+
| `/invite all group` | Allow all groups the bot has joined |
|
|
167
|
+
| `/remove user @name`, `/remove admin @name`, `/remove group` | Remove access entries |
|
|
168
|
+
| `/stop` | Stop the current run, including the card stop button |
|
|
169
|
+
| `/timeout [N\|off\|default]` | Set or clear the current session idle watchdog |
|
|
170
|
+
| `/ps` | List local bridge processes |
|
|
171
|
+
| `/exit <id\|#>` | Stop a bridge process |
|
|
172
|
+
| `/reconnect` | Force a WebSocket reconnect |
|
|
173
|
+
| `/doctor [description]` | Run low-sensitive diagnostics |
|
|
174
|
+
| `/help` | Help card |
|
|
175
|
+
|
|
176
|
+
DMs do not require an @ mention. Groups and topic groups require `@bot` by default; `@all` is ignored. Cloud-doc comments in supported document types run when the bot is mentioned.
|
|
177
|
+
|
|
178
|
+
## Reply Display and COT
|
|
179
|
+
|
|
180
|
+
`/config` controls three presentation settings:
|
|
181
|
+
|
|
182
|
+
- **Message reply mode**: `message card` streams the final reply; `plain text` sends once after the run finishes.
|
|
183
|
+
- **Tool-call display**: controls whether tool blocks appear in the final card / markdown reply.
|
|
184
|
+
- **COT process message**: `off` sends only the final reply; `brief` first sends a COT message with agent progress text and tool summaries; `detailed` also includes tool args and truncated output.
|
|
185
|
+
|
|
186
|
+
When COT is enabled, the bridge splits the process view and final answer into two messages. The COT message is for tracing what the agent did; the final answer is still generated from the agent's raw text, without heuristic bridge-side filtering. If an agent emits final-answer text as ordinary stream text, that text can also appear in the COT process message.
|
|
187
|
+
|
|
188
|
+
## lark-cli identity policy
|
|
189
|
+
|
|
190
|
+
Each profile uses a profile-local lark-cli directory at `~/.lark-channel/profiles/<profile>/lark-cli`. The agent process receives `LARKSUITE_CLI_CONFIG_DIR` for that directory, so personal authorization in one profile is not shared with another profile.
|
|
191
|
+
|
|
192
|
+
The default policy is `bot-only`: lark-cli uses the app/bot identity and does not access personal resources. When a user authorizes personal resources such as calendar, mail, or drive, the current profile can switch to `user-default`, which keeps app identity available and also allows the authorized user identity. Owner/admin users can inspect or change this policy in `/config`; `/status` shows the current summary as `lark-cli: app` or `lark-cli: user-ready`.
|
|
193
|
+
|
|
194
|
+
## Working directories
|
|
195
|
+
|
|
196
|
+
Each profile may define a default working directory through `workspaces.default`. New profiles may be created with `--workspace <path>`; if omitted, the bridge creates a profile-managed default working directory.
|
|
197
|
+
|
|
198
|
+
This is a profile-field snippet. Do not replace the whole `config.json` with it; edit the matching profile's `workspaces` field.
|
|
199
|
+
|
|
200
|
+
```json
|
|
201
|
+
{
|
|
202
|
+
"workspaces": {
|
|
203
|
+
"default": "/Users/me/.lark-channel-workspaces/claude/default"
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
The bridge checks that a selected directory exists, is a directory, and is not an overly broad location such as `/`, the home root, a system directory, or a temp root. The working directory is only the current directory for an agent run. It is not a filesystem sandbox; actual file access still depends on the local agent process and its permission mode.
|
|
209
|
+
|
|
210
|
+
## Permission modes
|
|
211
|
+
|
|
212
|
+
The recommended user-facing profile config is `permissions.defaultAccess` and `permissions.maxAccess`. New profiles default to `full` for both values so the bridge can keep local tools, authorization flows, file writes, and other agent features fully usable. To tighten a profile, set one or both values to `workspace` or `read-only`; stricter modes can limit local tool execution, login/authorization flows, file writes, and similar capabilities.
|
|
213
|
+
|
|
214
|
+
This is a profile-field snippet. Do not replace the whole `config.json` with it; edit the matching profile's `permissions` field.
|
|
215
|
+
|
|
216
|
+
```json
|
|
217
|
+
{
|
|
218
|
+
"permissions": {
|
|
219
|
+
"defaultAccess": "full",
|
|
220
|
+
"maxAccess": "full"
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Mode mapping:
|
|
226
|
+
|
|
227
|
+
| Bridge access | Claude permission mode | Codex mode | Pi mode |
|
|
228
|
+
|---|---|---|---|
|
|
229
|
+
| `full` | `bypassPermissions` | `danger-full-access` | unrestricted |
|
|
230
|
+
| `workspace` | `acceptEdits` | `workspace-write` | unrestricted |
|
|
231
|
+
| `read-only` | `plan` | `read-only` | `--tools read,grep,find,ls` |
|
|
232
|
+
|
|
233
|
+
Pi has no built-in workspace-scoped sandbox: `workspace` and `full` behave identically for Pi (no `--tools` restriction). Users wanting filesystem/network confinement for Pi should containerize it themselves — see https://pi.dev for Pi's own documentation.
|
|
234
|
+
|
|
235
|
+
The legacy `sandbox` field is still readable for old configs. After the bridge saves the profile, it migrates that setting to canonical `permissions`.
|
|
236
|
+
|
|
237
|
+
## Data directories
|
|
238
|
+
|
|
239
|
+
| Path | Content |
|
|
240
|
+
|---|---|
|
|
241
|
+
| `~/.lark-channel/config.json` | Root config with profiles and active profile |
|
|
242
|
+
| `~/.lark-channel/active-profile` | Last selected profile |
|
|
243
|
+
| `~/.lark-channel/profiles/<profile>/sessions.json` | Session state |
|
|
244
|
+
| `~/.lark-channel/profiles/<profile>/sessions.json.catalog.json` | Agent-aware session catalog |
|
|
245
|
+
| `~/.lark-channel/profiles/<profile>/workspaces.json` | Current and named workspace bindings |
|
|
246
|
+
| `~/.lark-channel/profiles/<profile>/secrets.enc` | Profile-local encrypted secrets |
|
|
247
|
+
| `~/.lark-channel/profiles/<profile>/lark-cli/` | Profile-local lark-cli directory |
|
|
248
|
+
| `~/.lark-channel/profiles/<profile>/media/` | Attachment cache |
|
|
249
|
+
| `~/.lark-channel/profiles/<profile>/logs/` | Structured run logs |
|
|
250
|
+
| `~/.lark-channel/registry/processes.json` | Local process registry |
|
|
251
|
+
| `~/.lark-channel/registry/locks/` | Profile and app locks |
|
|
252
|
+
|
|
253
|
+
Set `LARK_CHANNEL_HOME=/path/to/state` to move all local bridge state. `LARK_CHANNEL_LOG_DAYS` overrides log retention.
|
|
254
|
+
|
|
255
|
+
## Access control
|
|
256
|
+
|
|
257
|
+
**Chat access is private by default: out of the box, only *you* can use the bot in DMs and groups.** "You" = whoever created / owns the Feishu app (the person who scanned the QR to set it up). The bot figures out who the app owner is automatically from Feishu, so **solo chat use needs zero configuration** — you can DM it and `@`-mention it in any group, and everyone else's chat messages are silently ignored (no "permission denied" reply, which would only confirm the bot exists). Cloud-doc comments are document-scoped; see below.
|
|
258
|
+
|
|
259
|
+
To let other people or groups in, add them to one of three lists:
|
|
260
|
+
|
|
261
|
+
| List | Controls | Add | Remove |
|
|
262
|
+
|------|----------|-----|--------|
|
|
263
|
+
| **Allowed users** | who can DM the bot | `/invite user @them` | `/remove user @them` |
|
|
264
|
+
| **Allowed chats** | which groups the bot answers in (for **everyone** in them) | `/invite group` (current group) / `/invite all group` (every group the bot is in) | `/remove group` (current group) |
|
|
265
|
+
| **Admins** | who can change settings, and use the bot in any group | `/invite admin @them` | `/remove admin @them` |
|
|
266
|
+
|
|
267
|
+
> `/invite` and `/remove` can only be run by **you (the creator) and admins**. The `@` in the command points at the *target person* (not the bot) — the bot resolves the mention to their identity, so you never deal with raw IDs.
|
|
268
|
+
|
|
269
|
+
### Two identities that bypass everything
|
|
270
|
+
|
|
271
|
+
- **You (the creator)**: subject to no list at all — DMs, any group, every command. You **can never lock yourself out**: even if the lists get messed up, DM the bot and send `/config` to get back in. Transfer the app's ownership in the Feishu console and the bot follows the new owner automatically.
|
|
272
|
+
- **Admins**: can DM, run management commands like `/config`, and **bypass the allowed-chats list** — the bot answers them in any group, listed or not. Good for teammates who co-maintain the bot.
|
|
273
|
+
|
|
274
|
+
### Common setups
|
|
275
|
+
|
|
276
|
+
- **Just me** → nothing to do; this is the default.
|
|
277
|
+
- **Let a teammate DM the bot** → `/invite user @them`
|
|
278
|
+
- **Open a work group to everyone in it** → send `/invite group` inside that group
|
|
279
|
+
- **First-time setup, onboard every group the bot is already in** → `/invite all group` pulls them all into the list at once; trim with `/remove group` afterwards
|
|
280
|
+
- **Add a co-admin** → `/invite admin @them`
|
|
281
|
+
|
|
282
|
+
### Worth knowing
|
|
283
|
+
|
|
284
|
+
- Changes take effect on the **next message** — no restart needed.
|
|
285
|
+
- **In groups you must `@` the bot first** (DMs don't need it). That's a separate toggle (`/config` → "require @ in groups"), independent of the lists above.
|
|
286
|
+
- Strangers get pure silence — no reply at all. The one exception: if someone `@`-mentions the bot in a group that hasn't been opened up, the bot posts a friendly one-liner telling them an admin can run `/invite group` to enable it.
|
|
287
|
+
- Cloud-doc comments are document-scoped: anyone who can comment in a supported document and mention the bot can trigger a reply.
|
|
288
|
+
|
|
289
|
+
### Advanced: editing the config file directly
|
|
290
|
+
|
|
291
|
+
If you'd rather not do it inside Feishu, `/invite` and `/config` write the matching profile's `access` field in `~/.lark-channel/config.json`. Empty lists mean nobody from that list, not open access. This is a profile-field snippet; do not replace the whole `config.json` with it:
|
|
292
|
+
|
|
293
|
+
```json
|
|
294
|
+
{
|
|
295
|
+
"schemaVersion": 2,
|
|
296
|
+
"profiles": {
|
|
297
|
+
"claude": {
|
|
298
|
+
"agentKind": "claude",
|
|
299
|
+
"access": {
|
|
300
|
+
"allowedUsers": ["ou_xxxxxxxxxxxxx"],
|
|
301
|
+
"allowedChats": ["oc_xxxxxxxxxxxxx"],
|
|
302
|
+
"admins": ["ou_xxxxxxxxxxxxx"],
|
|
303
|
+
"requireMentionInGroup": true
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
`allowedUsers` / `admins` take user `open_id`s; `allowedChats` takes group `chat_id`s. The easiest way to find an ID by hand: have the person message the bot (or `@` it in the group), then check the active profile's log:
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
grep '"event":"enter"' ~/.lark-channel/profiles/<profile>/logs/bridge-$(date +%Y%m%d).jsonl | tail -5
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Each line carries `chatId` (group / DM id) and `senderId` (user `open_id`). After a manual edit, **restart the bridge** or send `/reconnect` from an allowed admin context to apply it. For day-to-day tweaks `/invite` / `/config` are easier; direct edits are mainly for deployment scripts that pre-seed access.
|
|
317
|
+
|
|
318
|
+
## Cloud-doc comments
|
|
319
|
+
|
|
320
|
+
Cloud-doc comments do not need a separate workspace binding or document allowlist. In supported document comments, mention the bot and the bridge replies in the same thread. Comment runs reuse the document session key and fall back to the user home directory when no document cwd was previously recorded.
|
|
321
|
+
|
|
322
|
+
## FAQ
|
|
323
|
+
|
|
324
|
+
**The bot stays silent or the local CLI never replies.** Usually the local `claude`, `codex`, or `pi` CLI is not logged in, or the current session points to a working directory that no longer exists. Send `/status` to inspect; `/new` often fixes it by starting a fresh session.
|
|
325
|
+
|
|
326
|
+
**The agent subprocess looks frozen (card stuck on the last frame).** The bridge supports an idle watchdog: if the agent emits nothing for N minutes, the process is killed and the card is annotated with the auto-termination reason. Disabled by default. Enable with `/config` globally, or `/timeout 10` for the current session; `/timeout off` disables it for the session; `/timeout default` clears the session override.
|
|
327
|
+
|
|
328
|
+
**The agent says it cannot see an image I sent.** Upgrade to the latest version. Releases before 0.1.0 had a filename-dedup bug.
|
|
329
|
+
|
|
330
|
+
## Testing and CI
|
|
331
|
+
|
|
332
|
+
Local checks:
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
pnpm test
|
|
336
|
+
pnpm typecheck
|
|
337
|
+
pnpm build
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
`pnpm test` includes unit, integration, and process-level adapter tests. CI runs on macOS, Ubuntu, and Windows with `pnpm install --frozen-lockfile`, `pnpm test`, `pnpm typecheck`, and `pnpm build`.
|
|
341
|
+
|
|
342
|
+
## Optional telemetry
|
|
343
|
+
|
|
344
|
+
By default the bridge reports **nothing**: no metrics, no logs leave your machine, and it pulls in zero telemetry dependencies. The hook below is inert unless you opt in.
|
|
345
|
+
|
|
346
|
+
To wire up your own monitoring, point an environment variable at a module that default-exports (or exports `createAdapter`) an `AdapterFactory`:
|
|
347
|
+
|
|
348
|
+
```bash
|
|
349
|
+
LARK_CHANNEL_TELEMETRY_MODULE=your-telemetry-package lark-channel-bridge start
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
That module receives every `log.*` event plus error/metric hooks and forwards them wherever you like. The interface is exported from the package root:
|
|
353
|
+
|
|
354
|
+
```ts
|
|
355
|
+
import type { AdapterFactory, TelemetryAdapter, TelemetryEvent } from 'lark-channel-bridge';
|
|
356
|
+
|
|
357
|
+
const createAdapter: AdapterFactory = (meta) => ({
|
|
358
|
+
emit(event) {/* ship event */},
|
|
359
|
+
recordError(err, ctx) {/* ship exception */},
|
|
360
|
+
recordMetric(name, value, tags) {/* ship metric */},
|
|
361
|
+
flush(timeoutMs) {/* drain buffered events */},
|
|
362
|
+
});
|
|
363
|
+
export default createAdapter;
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
A missing module, a bad factory, or a throwing adapter all degrade to noop — telemetry can never stop the bridge from starting or break logging.
|
|
367
|
+
|
|
368
|
+
## License
|
|
369
|
+
|
|
370
|
+
[MIT](./LICENSE)
|
|
371
|
+
|
|
372
|
+
<img src="./assets/feedback-group-qr.png" alt="Feedback group QR code" width="360">
|