dsh-channel-feishu 0.9.7 → 0.9.9

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 CHANGED
@@ -5,6 +5,24 @@
5
5
 
6
6
  用的是你自己在飞书开放平台新建的自建应用(独立机器人),不和别的通道共用事件。
7
7
 
8
+ ## 为什么这么设计
9
+
10
+ 常见的 IM 桥接是「群机器人 + webhook」:消息先转发到某个中间服务,再把回复贴回群里。这条通道反着做,几个取舍是有意的:
11
+
12
+ - **一个应用只服务一个人**:自建应用 + 独立机器人,事件走长连接直达你本机,不经第三方中继,飞书侧也只是一条普通私聊;
13
+ - **会话是主体,聊天窗口只是入口**:一条通道绑定一个 DSH 会话,上下文、工具调用、产物都留在本地会话里,换设备、重开 app 都不丢;
14
+ - **要你拍板时发卡片,不靠解析自然语言**:结构化问答卡点选即回传,避免「回复 1 表示同意」这类靠猜的交互;
15
+ - **附件落在工作区**:图片和文件直接进 `<workspacePath>/attachments/`,Agent 用本地路径读取,不用去临时目录里翻;
16
+ - **无人值守优先**:会话激活即切权限预设,长任务不会卡在授权确认上;问答卡的回调也在通道内闭环,不需要开网页。
17
+
18
+ 代价是它只适合「一个人、一台机器、一个长期会话」的用法——这正是下面这条边界的由来。
19
+
20
+ ## 当前版本不支持群聊
21
+
22
+ 0.9.x 只支持**单聊**(你和机器人一对一)。把机器人拉进群不会工作:群消息的会话绑定关系不成立,插件按单聊逻辑处理会直接丢弃。
23
+
24
+ 群聊要解决的是另一个问题——群里谁在跟 Agent 说话、上下文怎么隔离、多人同时提问怎么排队。这些等实际反馈,不在当前版本里做。
25
+
8
26
  ## 它提供什么
9
27
 
10
28
  - **双向通道**:飞书私聊 → DSH 会话;一轮结束把答复自动发回原聊天,不需要模型调工具
@@ -25,7 +43,7 @@ dsh plugin add dsh-channel-feishu
25
43
 
26
44
  ```bash
27
45
  dsh plugin add https://github.com/Poy-Coder/dsh-channel-feishu
28
- dsh plugin add https://github.com/Poy-Coder/dsh-channel-feishu/releases/download/v0.9.7/dsh-channel-feishu-0.9.7.tgz
46
+ dsh plugin add https://github.com/Poy-Coder/dsh-channel-feishu/releases/download/v0.9.9/dsh-channel-feishu-0.9.9.tgz
29
47
  ```
30
48
 
31
49
  依赖必须用扁平结构装(非 ASCII 目录下 pnpm 的软链会把路径写坏):`pnpm install --node-linker=hoisted`。
@@ -146,6 +164,12 @@ owner 记在通道状态文件里,删掉状态文件里的 `owner` 字段即
146
164
  - 常见 `result`:`delivered`、`bootstrap`(自动建会话)、`owner-bound`、`dropped`(附 `reason`)、
147
165
  `card-sent`、`answered`、`card-update-failed`。
148
166
 
167
+ ## 路线图
168
+
169
+ - **多 IM**:通道层已经按 provider 抽开(`providers/registry.js`),接微信/企业微信只需实现同一份 provider 契约,会话与问答卡逻辑不用重写;
170
+ - **扫码配置**:目标是「扫一下就把 `appId` / `appSecret` / `defaultChatId` 写进凭据文件」,替掉现在跑 `scripts/setup.mjs` 这一步;
171
+ - **群聊**:视反馈决定,不在 0.9.x 范围内。
172
+
149
173
  ## 常见问题
150
174
 
151
175
  | 现象 | 处理 |
package/index.js CHANGED
@@ -2239,6 +2239,19 @@ export async function handleInboundEvent(ctx, config, data, seen) {
2239
2239
  return
2240
2240
  }
2241
2241
 
2242
+ // This channel is one conversation per bot: a group brings several speakers
2243
+ // into one session, which the current design does not model.
2244
+ if (inbound.chatType && inbound.chatType !== 'p2p') {
2245
+ log({
2246
+ event: 'inbound', result: 'dropped',
2247
+ reason: `chat_type=${inbound.chatType} (group chat is not supported)`,
2248
+ senderId: inbound.senderId, chatId: inbound.chatId,
2249
+ })
2250
+ warnTo(ctx, `ignored ${inbound.chatType} message: group chat is not supported`)
2251
+ markSeen()
2252
+ return
2253
+ }
2254
+
2242
2255
  const senderId = inbound.senderId
2243
2256
  const allowed = Array.isArray(config.allowedUsers)
2244
2257
  ? config.allowedUsers.map((value) => String(value)).filter(Boolean)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-channel-feishu",
3
- "version": "0.9.7",
3
+ "version": "0.9.9",
4
4
  "type": "module",
5
5
  "description": "Feishu/Lark (飞书) channel for DeepSeek Harness: a chat bound to a DSH session, with streaming cards and attachments.",
6
6
  "license": "MIT",
@@ -588,6 +588,10 @@ export async function downloadMessageFile(base, token, messageId, fileKey, fileN
588
588
  const message = event?.message
589
589
  const sender = event?.sender
590
590
  if (!message || !sender) return null
591
+ // The SDK dispatcher hands over the event body, not the envelope, so
592
+ // `header.event_id` is usually absent. `message_id` is stable across
593
+ // redeliveries and is what dedupe needs to survive a restart.
594
+ const dedupeKey = String(event?.header?.event_id ?? event?.event_id ?? message.message_id ?? '')
591
595
  const messageType = String(message.message_type ?? '')
592
596
  const mentions = message.mentions
593
597
  let text = ''
@@ -607,8 +611,9 @@ export async function downloadMessageFile(base, token, messageId, fileKey, fileN
607
611
  if (file.fileKey) files = [file]
608
612
  } else {
609
613
  return {
610
- dedupeKey: String(event?.header?.event_id ?? ''),
614
+ dedupeKey,
611
615
  chatId: String(message.chat_id ?? ''),
616
+ chatType: String(message.chat_type ?? ''),
612
617
  senderId: String(sender.sender_id?.open_id ?? ''),
613
618
  senderType: String(sender.sender_type ?? ''),
614
619
  messageId: String(message.message_id ?? ''),
@@ -619,8 +624,9 @@ export async function downloadMessageFile(base, token, messageId, fileKey, fileN
619
624
  }
620
625
  }
621
626
  return {
622
- dedupeKey: String(event?.header?.event_id ?? ''),
627
+ dedupeKey,
623
628
  chatId: String(message.chat_id ?? ''),
629
+ chatType: String(message.chat_type ?? ''),
624
630
  senderId: String(sender.sender_id?.open_id ?? ''),
625
631
  senderType: String(sender.sender_type ?? ''),
626
632
  messageId: String(message.message_id ?? ''),