dsh-lark-bot 0.6.0 → 0.7.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/README.md +38 -90
- package/SECURITY.md +2 -3
- package/cordis.patch.yml +23 -5
- package/dist/cli.js +191 -997
- package/dist/cli.js.map +1 -1
- package/dist/notify.js +2 -7
- package/dist/notify.js.map +1 -1
- package/dist/plugin.d.ts +677 -90
- package/dist/plugin.js +5544 -705
- package/dist/plugin.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,107 +28,53 @@
|
|
|
28
28
|
|
|
29
29
|
## 快速开始 | Quick Start(普通用户先看这里 | for end users)
|
|
30
30
|
|
|
31
|
-
### 1.
|
|
31
|
+
### 1. 安装(唯一路径)| Install (the only path)
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
本项目以 **dsh 标准 profile bundle** 交付:一行命令把它装进一个 dsh profile,dsh 启动时以
|
|
34
|
+
标准插件方式加载桥接引擎(`dsh.bundle.patch` 已声明,`dsh plugin add` 可直接安装)。
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
This project ships as a **standard dsh profile bundle**: one command installs it into a dsh
|
|
37
|
+
profile, and dsh loads the bridge engine as a standard plugin on boot (the package declares
|
|
38
|
+
`dsh.bundle.patch`, so `dsh plugin add` works directly).
|
|
36
39
|
|
|
37
40
|
```bash
|
|
38
|
-
#
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
# 或飞书命名版本 | or the Feishu-named edition
|
|
42
|
-
npm install -g dsh-feishu-bot
|
|
41
|
+
# 唯一安装命令(无需先全局安装任何东西)| the only install command (no prior global install)
|
|
42
|
+
npx dsh-lark-bot@latest setup --profile dsh-lark
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
After installation, the commands are `dsh-lark-bot` and `dsh-feishu-bot` respectively.
|
|
45
|
+
`setup` 会自动完成:发现本机 dsh → 预批准 pnpm 构建策略 → 执行标准的
|
|
46
|
+
`dsh plugin --profile dsh-lark add dsh-lark-bot`。
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
`setup` automatically: locates your dsh install → pre-approves pnpm's build policy → runs the
|
|
49
|
+
standard `dsh plugin --profile dsh-lark add dsh-lark-bot`.
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
`dsh.bundle.patch`):
|
|
51
|
+
### 2. 启动并扫码绑定 | Start and bind with one scan
|
|
53
52
|
|
|
54
53
|
```bash
|
|
55
|
-
dsh
|
|
54
|
+
dsh --profile dsh-lark
|
|
56
55
|
```
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
The profile then mounts `dsh-lark-bot/plugin` on boot — it exposes `ctx.larkBridge`
|
|
63
|
-
(status / start / restart / stop of the standalone bridge service) without blocking boot; set
|
|
64
|
-
`DSH_LARK_AUTOSTART=1` to start the bridge when the profile boots. The SDK / ACP runtimes also
|
|
65
|
-
auto-mount the `lark_notify` tool (see below).
|
|
57
|
+
首次启动会在终端打印二维码:用飞书 / Lark App 扫码创建或选择 PersonalAgent 应用,绑定后
|
|
58
|
+
dsh-lark-bot 的桥接引擎即在 dsh 进程内运行(飞书通道、会话/工作区、卡片、通知回调),
|
|
59
|
+
私聊直接发消息,群聊 / 话题里 `@bot`。常驻与守护由 dsh 自己负责。
|
|
66
60
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
On first boot the terminal prints a QR code: scan it with the Feishu / Lark app to create or
|
|
62
|
+
choose a PersonalAgent app. After binding, the bridge engine runs **inside the dsh process**
|
|
63
|
+
(Feishu channel, sessions/workspaces, cards, notify callback); message it directly in private
|
|
64
|
+
chat, or use `@bot` in groups/topics. dsh owns the daemon lifecycle.
|
|
70
65
|
|
|
71
|
-
|
|
72
|
-
> `ERR_PNPM_IGNORED_BUILDS` (e.g. protobufjs), add `allowBuilds:\n protobufjs: true` to the
|
|
73
|
-
> profile's `pnpm-workspace.yaml` and retry — the same handling as the official
|
|
74
|
-
> `dsh-lark-channel`.
|
|
75
|
-
|
|
76
|
-
### 2. 启动后台服务并绑定飞书 | Start the background service and bind Feishu
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
dsh-lark-bot start
|
|
80
|
-
```
|
|
66
|
+
已有 PersonalAgent 应用时可在 profile 环境变量中直接提供凭据跳过扫码(见「配置」):
|
|
81
67
|
|
|
82
|
-
|
|
68
|
+
With an existing PersonalAgent app, provide credentials via profile env to skip the QR step
|
|
69
|
+
(see Configuration):
|
|
83
70
|
|
|
84
71
|
```bash
|
|
85
|
-
|
|
72
|
+
DSH_LARK_APP_ID=cli_xxx DSH_LARK_APP_SECRET=<secret> DSH_LARK_TENANT=feishu \
|
|
73
|
+
dsh --profile dsh-lark
|
|
86
74
|
```
|
|
87
75
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
`start` automatically installs a **background service** locally: it joins the OS autostart
|
|
91
|
-
list and restarts automatically whenever the process exits, crashes or errors. On first launch:
|
|
92
|
-
|
|
93
|
-
1. 在终端显示二维码。
|
|
94
|
-
2. 用飞书 / Lark App 扫码。
|
|
95
|
-
3. 选择或创建 PersonalAgent 应用。
|
|
96
|
-
4. 绑定成功后,bot 会向你的私聊发送欢迎卡片。
|
|
97
|
-
5. 私聊直接发消息;群聊或话题里 `@bot`。
|
|
98
|
-
|
|
99
|
-
1. A QR code is shown in the terminal.
|
|
100
|
-
2. Scan it with the Feishu / Lark app.
|
|
101
|
-
3. Choose or create a PersonalAgent app.
|
|
102
|
-
4. Once bound, the bot sends a welcome card to your private chat.
|
|
103
|
-
5. Message it directly in private chat; use `@bot` in group chats or topics.
|
|
104
|
-
|
|
105
|
-
绑定完成后 bot 转入后台运行,终端可以随时关闭。
|
|
106
|
-
|
|
107
|
-
After binding, the bot runs in the background; you can close the terminal anytime.
|
|
108
|
-
|
|
109
|
-
如果你已经有 PersonalAgent 应用,也可以跳过扫码:
|
|
110
|
-
|
|
111
|
-
If you already have a PersonalAgent app, you can skip the QR step:
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
dsh-lark-bot start \
|
|
115
|
-
--app-id cli_xxx \
|
|
116
|
-
--app-secret <secret> \
|
|
117
|
-
--tenant feishu
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### 3. 服务管理命令 | Service management commands
|
|
121
|
-
|
|
122
|
-
| 命令 Command | 作用 Description |
|
|
123
|
-
| :--- | :--- |
|
|
124
|
-
| `dsh-lark-bot start` | 安装后台服务、加入开机自启并启动(首次运行会先扫码绑定)<br>Install the background service, enable autostart and start it (first run prompts QR binding) |
|
|
125
|
-
| `dsh-lark-bot status` | 查看服务状态(退出码 0=运行中,1=未运行)<br>Show service status (exit code 0=running, 1=not running) |
|
|
126
|
-
| `dsh-lark-bot restart` | 重启后台服务(保留开机自启)<br>Restart the background service (keeps autostart) |
|
|
127
|
-
| `dsh-lark-bot stop` | 停止后台服务并移出开机自启<br>Stop the background service and remove autostart |
|
|
128
|
-
|
|
129
|
-
后台服务的运行日志写入 `~/.dsh-lark/profiles/<profile>/logs/bot.log`。
|
|
130
|
-
|
|
131
|
-
Background service logs are written to `~/.dsh-lark/profiles/<profile>/logs/bot.log`.
|
|
76
|
+
> 卸载:`dsh plugin --profile dsh-lark remove dsh-lark-bot`。
|
|
77
|
+
> Uninstall: `dsh plugin --profile dsh-lark remove dsh-lark-bot`.
|
|
132
78
|
|
|
133
79
|
### 4. 基本使用 | Basic usage
|
|
134
80
|
|
|
@@ -268,11 +214,14 @@ logs and troubleshooting.
|
|
|
268
214
|
|
|
269
215
|
## 目标 | Goals
|
|
270
216
|
|
|
271
|
-
-
|
|
217
|
+
- **一条命令安装部署**:`npx dsh-lark-bot@latest setup --profile dsh-lark` 装进 dsh profile,
|
|
218
|
+
随后 `dsh --profile dsh-lark` 启动并扫码,桥接引擎作为标准插件在 dsh 进程内运行。
|
|
272
219
|
- **飞书原生体验**:流式卡片、交互按钮、图片 / 文件,全程双语(文档评论为规划中能力)。
|
|
273
220
|
- **完整工作区管理**:多项目隔离、git worktree、项目级规则注入、上下文持久化。
|
|
274
221
|
|
|
275
|
-
- **One-command
|
|
222
|
+
- **One-command install & deploy**: `npx dsh-lark-bot@latest setup --profile dsh-lark`, then
|
|
223
|
+
`dsh --profile dsh-lark` and scan once — the bridge engine runs as a standard plugin inside
|
|
224
|
+
the dsh process.
|
|
276
225
|
- **Native Feishu experience**: streaming cards, interactive buttons, images / files, doc comments.
|
|
277
226
|
- **Full workspace management**: multi-project isolation, git worktrees, per-project rules, persistent context.
|
|
278
227
|
|
|
@@ -420,11 +369,11 @@ Common issues:
|
|
|
420
369
|
is reachable; with an existing App ID/Secret you can skip scanning via `--app-id` /
|
|
421
370
|
`--app-secret`.
|
|
422
371
|
|
|
423
|
-
|
|
424
|
-
|
|
372
|
+
桥接引擎日志写入 `~/.dsh-lark/profiles/<profile>/logs/bot.log`(JSON Lines);dsh 宿主日志走
|
|
373
|
+
dsh 自己的日志体系。
|
|
425
374
|
|
|
426
|
-
|
|
427
|
-
|
|
375
|
+
The bridge engine logs to `~/.dsh-lark/profiles/<profile>/logs/bot.log` (JSON Lines); the dsh
|
|
376
|
+
host uses its own logging.
|
|
428
377
|
|
|
429
378
|
## 开发 | Development
|
|
430
379
|
|
|
@@ -527,12 +476,11 @@ The core idea: **decouple the Feishu channel from the agent backend**. The bridg
|
|
|
527
476
|
| `src/card/` | 流式卡片状态与渲染<br>Streaming card state & rendering |
|
|
528
477
|
| `src/bot/` | 运行注册、消息排队、审批/问答注册表<br>Run registry, queueing, approval/question registries |
|
|
529
478
|
| `src/commands/` | 斜杠命令(/cd /ws /new …)<br>Slash commands |
|
|
530
|
-
| `src/cli/` | CLI
|
|
479
|
+
| `src/cli/` | CLI 入口:`setup`(唯一安装命令)/ `doctor`(诊断)/ 隐藏 `run`<br>CLI entry: setup / doctor / hidden run |
|
|
531
480
|
| `src/config/` | profile / 配置 / 访问白名单 / dsh 配置管理<br>Profile, config, access & dsh config management |
|
|
532
481
|
| `src/core/` | 结构化日志<br>Structured logging |
|
|
533
482
|
| `src/media/` | 附件下载与文本注入<br>Attachment download & text injection |
|
|
534
483
|
| `src/platform/` | 跨平台原子写入<br>Cross-platform atomic writes |
|
|
535
|
-
| `src/service/` | 后台服务管理(systemd / launchd / 计划任务 / 便携 supervisor)<br>Background service management |
|
|
536
484
|
| `docs/` | 架构、路线图等文档<br>Architecture, roadmap & docs |
|
|
537
485
|
| `reference/` | 参考研究用的克隆仓库(不提交)<br>Cloned reference repos (not committed) |
|
|
538
486
|
|
package/SECURITY.md
CHANGED
|
@@ -40,9 +40,8 @@
|
|
|
40
40
|
|
|
41
41
|
- 本地配置 `~/.dsh-lark/config.json` 以 `0600` 权限写入。
|
|
42
42
|
- 飞书凭据明文保存在本机配置文件;日志与卡片不输出真实密钥。
|
|
43
|
-
-
|
|
44
|
-
|
|
45
|
-
只引用该文件,不内联密钥。
|
|
43
|
+
- 桥接引擎在 dsh 宿主进程内运行,凭据与 `DSH_LARK_*` 环境直接随 dsh 进程提供,无独立服务
|
|
44
|
+
环境快照文件;敏感值不进日志与卡片。
|
|
46
45
|
- 后台运行日志写入 `~/.dsh-lark/profiles/<profile>/logs/bot.log`(JSON Lines,密钥字段脱敏后输出)。
|
|
47
46
|
- 聊天命令管理的 dsh 配置按官方存储协议写入:`~/.dsh/settings.yaml`(只存 `apiKeyEnv`
|
|
48
47
|
引用,不落字面密钥)与 `~/.dsh/.credentials.yaml`(目录 0700、文件 0600)。bot 永不回显
|
package/cordis.patch.yml
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
# dsh-lark-bot as a profile bundle.
|
|
2
2
|
|
|
3
|
-
# Installed with `dsh plugin --profile <name> add dsh-lark-bot
|
|
4
|
-
#
|
|
5
|
-
# `
|
|
6
|
-
#
|
|
3
|
+
# Installed with `dsh plugin --profile <name> add dsh-lark-bot` (or the
|
|
4
|
+
# single `dsh-lark-bot setup` command), dsh appends this package to the profile's
|
|
5
|
+
# `dsh.profile.bundles` and applies this patch on boot:
|
|
6
|
+
# - `dsh-lark-bot/plugin` starts the full bridge engine IN-PROCESS (Feishu
|
|
7
|
+
# channel, workspace/session layers, notify server, nested dsh SDK
|
|
8
|
+
# runtime) and exposes `ctx.larkBridge` (status / stop).
|
|
9
|
+
# - `dsh-lark-bot/notify` mounts the `lark_notify` tool for the host agent.
|
|
10
|
+
# First boot without credentials prints a QR code for one-time binding.
|
|
11
|
+
# Set DSH_LARK_DISABLED=1 to keep the engine stopped.
|
|
7
12
|
|
|
8
13
|
- insert:
|
|
9
14
|
- id: dsh-lark-bot
|
|
10
15
|
name: 'dsh-lark-bot/plugin'
|
|
11
16
|
config:
|
|
12
|
-
|
|
17
|
+
home: !!js process.env.DSH_LARK_HOME
|
|
18
|
+
tenant: !!js process.env.DSH_LARK_TENANT ?? 'feishu'
|
|
19
|
+
appId: !!js process.env.DSH_LARK_APP_ID
|
|
20
|
+
appSecret: !!js process.env.DSH_LARK_APP_SECRET
|
|
21
|
+
workspace: !!js process.env.DSH_LARK_WORKSPACE
|
|
22
|
+
adapter: !!js process.env.DSH_LARK_ADAPTER
|
|
23
|
+
model: !!js process.env.DSH_LARK_MODEL
|
|
24
|
+
disabled: !!js process.env.DSH_LARK_DISABLED === '1'
|
|
25
|
+
|
|
26
|
+
- id: lark-notify
|
|
27
|
+
name: 'dsh-lark-bot/notify'
|
|
28
|
+
config:
|
|
29
|
+
endpoint: !!js process.env.DSH_LARK_NOTIFY_URL
|
|
30
|
+
token: !!js process.env.DSH_LARK_NOTIFY_TOKEN
|