dsh-channel-feishu 0.9.4 → 0.9.5

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/index.js +23 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -82,7 +82,7 @@ dsh plugin add dsh-channel-feishu
82
82
 
83
83
  ```bash
84
84
  dsh plugin add https://github.com/Poy-Coder/dsh-channel-feishu
85
- dsh plugin add https://github.com/Poy-Coder/dsh-channel-feishu/releases/download/v0.9.4/dsh-channel-feishu-0.9.4.tgz
85
+ dsh plugin add https://github.com/Poy-Coder/dsh-channel-feishu/releases/download/v0.9.5/dsh-channel-feishu-0.9.5.tgz
86
86
  ```
87
87
 
88
88
  依赖必须用扁平结构装(非 ASCII 目录下 pnpm 的软链会把路径写坏):
package/index.js CHANGED
@@ -2175,14 +2175,21 @@ export async function handleInboundEvent(ctx, config, data, seen) {
2175
2175
  const inbound = provider().parseInbound(data)
2176
2176
  if (!inbound) return
2177
2177
  const eventId = inbound.dedupeKey
2178
- if (eventId) {
2179
- if (seen.has(eventId)) return
2178
+ if (eventId && seen.has(eventId)) return
2179
+ // Mark an event only once it is settled. Marking before delivery loses the
2180
+ // message for good: a restart between the write and the followup leaves the id
2181
+ // "seen", so Feishu's redelivery is dropped silently.
2182
+ const markSeen = () => {
2183
+ if (!eventId) return
2180
2184
  seen.add(eventId)
2181
2185
  if (seen.size > INBOUND_DEDUPE_LIMIT) seen.delete(seen.values().next().value)
2182
2186
  persistSeenEvents(config, seen)
2183
2187
  }
2184
2188
 
2185
- if (inbound.senderType === 'app') return
2189
+ if (inbound.senderType === 'app') {
2190
+ markSeen()
2191
+ return
2192
+ }
2186
2193
 
2187
2194
  const senderId = inbound.senderId
2188
2195
  const allowed = Array.isArray(config.allowedUsers)
@@ -2191,6 +2198,7 @@ export async function handleInboundEvent(ctx, config, data, seen) {
2191
2198
  if (allowed.length > 0 && !allowed.includes(senderId)) {
2192
2199
  warnTo(ctx, `ignored message from ${senderId}: not in allowedUsers`)
2193
2200
  log({ event: 'inbound', result: 'dropped', reason: 'sender not in allowedUsers', senderId })
2201
+ markSeen()
2194
2202
  return
2195
2203
  }
2196
2204
 
@@ -2198,6 +2206,7 @@ export async function handleInboundEvent(ctx, config, data, seen) {
2198
2206
  if (inbound.unsupported) {
2199
2207
  warnTo(ctx, `ignored unsupported message_type=${inbound.unsupported}`)
2200
2208
  log({ event: 'inbound', result: 'dropped', reason: `non-text message_type=${inbound.unsupported}`, senderId })
2209
+ markSeen()
2201
2210
  return
2202
2211
  }
2203
2212
 
@@ -2249,6 +2258,7 @@ export async function handleInboundEvent(ctx, config, data, seen) {
2249
2258
 
2250
2259
  if (!text) {
2251
2260
  log({ event: 'inbound', result: 'dropped', reason: 'empty text', senderId, chatId })
2261
+ markSeen()
2252
2262
  return
2253
2263
  }
2254
2264
  // Control phrases are consumed here, never delivered to the model.
@@ -2259,12 +2269,16 @@ export async function handleInboundEvent(ctx, config, data, seen) {
2259
2269
  const command = parseSlashCommand(text)
2260
2270
  if (command) {
2261
2271
  await handleSlashCommand(ctx, config, { ...command, chatId, senderId })
2272
+ markSeen()
2262
2273
  return
2263
2274
  }
2264
2275
 
2265
2276
  // A pending question owns the next reply in its chat: a numbered, labelled or
2266
2277
  // free-text answer settles the tool call instead of starting a new turn.
2267
- if (consumeQuestionTextAnswer(ctx, config, { chatId, senderId, text })) return
2278
+ if (consumeQuestionTextAnswer(ctx, config, { chatId, senderId, text })) {
2279
+ markSeen()
2280
+ return
2281
+ }
2268
2282
 
2269
2283
  let sessionId = currentSessionId(config)
2270
2284
  if (!sessionId) {
@@ -2275,6 +2289,7 @@ export async function handleInboundEvent(ctx, config, data, seen) {
2275
2289
  event: 'inbound', result: 'dropped',
2276
2290
  reason: 'no sessionId configured (set sessionMode: create to bootstrap one)', senderId, chatId,
2277
2291
  })
2292
+ markSeen()
2278
2293
  return
2279
2294
  }
2280
2295
  // Fresh install: the bundle row carries no sessionId. Create the channel's
@@ -2282,6 +2297,7 @@ export async function handleInboundEvent(ctx, config, data, seen) {
2282
2297
  // instead of dropping it — otherwise a new install looks connected but deaf.
2283
2298
  log({ event: 'inbound', result: 'bootstrap', reason: 'no session yet; creating one', senderId, chatId })
2284
2299
  await switchToNewSession(ctx, config, { chatId, senderId, firstMessage: text })
2300
+ markSeen()
2285
2301
  return
2286
2302
  }
2287
2303
 
@@ -2289,6 +2305,7 @@ export async function handleInboundEvent(ctx, config, data, seen) {
2289
2305
  if (!resolved.agent) {
2290
2306
  warnTo(ctx, `inbound message dropped for session "${sessionId}": ${resolved.reason}`)
2291
2307
  log({ event: 'inbound', result: 'dropped', reason: resolved.reason, senderId, chatId, sessionId })
2308
+ markSeen()
2292
2309
  return
2293
2310
  }
2294
2311
 
@@ -2313,6 +2330,8 @@ export async function handleInboundEvent(ctx, config, data, seen) {
2313
2330
  content: [{ type: 'text', text: inboundUserText(text) }],
2314
2331
  source: { kind: 'user' },
2315
2332
  })
2333
+ // Delivered: only now is it safe to remember the event and drop redeliveries.
2334
+ markSeen()
2316
2335
  rememberChat(config, sessionId, { chatId, senderId })
2317
2336
  // Acknowledge on the user's own message: the cheapest "I got it" there is.
2318
2337
  if (config.reactions !== false && inbound.messageId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-channel-feishu",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
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",