dsh-aiyayi 1.5.16 → 1.5.17

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/CHANGELOG.md CHANGED
@@ -2,12 +2,20 @@
2
2
 
3
3
  > **维护约定**:新版本发布时在顶部加条目。本文件由 README 正文拆出(2026-11-09 重构):版本条目与踩坑记录原文照录,数字、时间、日期一律不改(量化保真是本插件的规矩)。版本事实以 npm registry 为准。
4
4
  >
5
- > **npm 发布一览(2026-11-10 核对 registry)**:latest = **1.5.15**(2026-11-10 发布)。已发布:1.0.0、…、1.5.7、**1.5.14**、**1.5.15**;跳号 1.3.0、1.4.1、1.4.2、1.5.0、1.5.1、1.5.2、1.5.3、**1.5.8–1.5.13** 从未发布到 npm(本地开发线:1.5.8–1.5.11 飞书桥接、1.5.12 思考纪律约束、1.5.13 内置技能同步+feishu-setup 骨架);1.5.14 已发布(坑 #58–#67 修复);1.5.15 已发布(扫码接入改造)。
5
+ > **npm 发布一览(2026-11-10 核对 registry)**:latest = **1.5.17**(2026-11-10 发布)。已发布:1.0.0、…、1.5.7、**1.5.14**、**1.5.15**、**1.5.16**、**1.5.17**;跳号 1.3.0、1.4.1、1.4.2、1.5.0、1.5.1、1.5.2、1.5.3、**1.5.8–1.5.13** 从未发布到 npm(本地开发线:1.5.8–1.5.11 飞书桥接、1.5.12 思考纪律约束、1.5.13 内置技能同步+feishu-setup 骨架);1.5.14 已发布(坑 #58–#67 修复);1.5.15 已发布(扫码接入改造);1.5.16 已发布(feishu-setup 技能脚本入包);1.5.17 已发布(坑 #68 重入保护修复)。
6
6
  >
7
7
  > **环境标识约定(2026-11-10 新增)**:写版本条目/坑条目时,**顺手记录当时的 智能体工具-智能体模式-模型供应商-模型**(如 **DSH-创造模式-loomy讯飞-GLM5.3FLASH**),写在条目内(紧跟 git 记录行、或坑条目首行),方便回溯该条目是在哪套智能体/模型环境下产出与验证的。
8
8
 
9
9
  ---
10
10
 
11
+ ## 1.5.17(2026-11-10 修复:坑 #68 宿主 append 重入保护)
12
+
13
+ - 环境:DSH-创造模式-DeepSeek Harness 执行智能体(娅伊派出,模型名未确证)
14
+ - git:本次 commit(2026-11-10,阿依娅伊)1.5.17:坑 #68 修复——宿主 dsh-session append 重入保护导致插件服务进程 fatal load failure 退出码 1
15
+ - 坑 #68(2026-11-10 实锤,插件服务进程退出码 1 + `dsh: fatal load failure` 堆栈):宿主 `Session.append` 有重入保护——一次 publish 尚未结束时,任何新的 `Session.append` 都抛 `session append cannot reenter while another append is being published`。触发链:插件 effect 回调(`turn/end` / `agent/inbox/spliced` 事件)里 `await agent.followup(...)`(= `ReactLoopInbox.splice` → `mutate` → `Session.append`)在宿主当前 publish 尚未收尾时同步重入 append → 抛错 → 宿主升级为 fatal load failure → 进程退出码 1。原代码 fire-and-forget 无 `.catch()`,unhandled rejection 沿 effect 回调传播为宿主 fatal。修法:① `yieldHostPublication()`——投递前 `Promise.resolve()` + `setTimeout(0)` 让出宏任务,跳出宿主 publish 窗口;② `safeDeliverToSession()`——包 try/catch,append 失败只记 `ctx.logger.warn` 不逃逸;③ effect 回调两处 fire-and-forget 补 `.catch(error => ctx.logger.warn(...))`;④ 三处引导/接入注入分支(skip / onboard / maybeGuideNewSession)全部改用 `safeDeliverToSession`。`lib/feishu.js` +51/-5 行。
16
+
17
+ ---
18
+
11
19
  ## 1.5.16(2026-11-10 发版:feishu-setup 技能脚本入包)
12
20
 
13
21
  - 环境:DSH-创造模式-DeepSeek Harness 执行智能体(娅伊派出,模型名未确证)
package/lib/feishu.js CHANGED
@@ -59,6 +59,42 @@ export const inject = [
59
59
  /** 本包根目录(feishu.js 在 lib/ 下,上一级就是包根)。 */
60
60
  const PKG_DIR = join(dirname(fileURLToPath(import.meta.url)), '..')
61
61
 
62
+ /**
63
+ * 坑 #68(2026-11-10 致命崩溃):宿主 dsh-session 的 append 有重入保护——
64
+ * 一次 publish 尚未结束时,任何新的 Session.append 都会抛
65
+ * `session append cannot reenter while another append is being published`,
66
+ * 宿主把这个错误升级为 fatal load failure、进程直接退出码 1。
67
+ *
68
+ * 触发链:turn/end 事件就发在宿主「本回合 append 发布完成」的收尾处;插件 effect 回调里
69
+ * 同步/重入式地 `await agent.followup(...)`(= ReactLoopInbox.splice → mutate → 又一次
70
+ * Session.append)→ 宿主 publish 尚未收尾时重入 append → 抛错。同理 agent/inbox/spliced
71
+ * 也走 append,onboard 意图注入(maybeOnboardIntent)有相同风险。
72
+ *
73
+ * 两个修法结合(缺一不可):
74
+ * 1) `await yieldHostPublication()`——投递前让出宏任务,跳出宿主当前 publish 窗口;
75
+ * 2) `safeDeliverToSession()` 包一层 catch——即使 append 再次失败(比如宿主又进了
76
+ * 新一轮 publish),rejection 也不能逃逸成宿主 fatal(原代码 fire-and-forget 没 catch,
77
+ * unhandled rejection 沿 effect 回调链传播 → 宿主 fatal load failure)。
78
+ * 注入是纯提示类文本,失败只记日志,不影响主流程。
79
+ */
80
+ async function yieldHostPublication() {
81
+ // 微任务 + 一个短宏任务,确保宿主的 publish 宏任务链已经收尾。
82
+ await Promise.resolve()
83
+ await new Promise((resolve) => setTimeout(resolve, 0))
84
+ }
85
+
86
+ /** deliverToSession 的「失败不逃逸」包装:任何 append 错误就地 catch,只记日志。 */
87
+ async function safeDeliverToSession(ctx, root, sessionId, messageId, text) {
88
+ try {
89
+ await yieldHostPublication()
90
+ await deliverToSession(ctx, sessionId, messageId, text)
91
+ } catch (error) {
92
+ ctx.logger.warn(
93
+ `aiyayi-feishu: 消息投递失败(宿主 append 可能仍在发布,已跳过): ${String(error)}`,
94
+ )
95
+ }
96
+ }
97
+
62
98
  /**
63
99
  * 主入口:宿主级服务插件。
64
100
  * @param {object} ctx - Cordis 上下文。
@@ -79,11 +115,18 @@ export function apply(ctx, config) {
79
115
  ctx.on('session/event', (session, event) => {
80
116
  try {
81
117
  if (event.type === 'agent/inbox/spliced') {
82
- maybeOnboardIntent(ctx, root, session, event)
118
+ // 坑 #68:async 函数结果必须 .catch 掉(原 fire-and-forget 无 catch,
119
+ // 内部 await 抛错 → unhandled rejection 沿 effect 回调传播 → 宿主 fatal)。
120
+ maybeOnboardIntent(ctx, root, session, event).catch((error) => {
121
+ ctx.logger.warn(`aiyayi-feishu: 接入意图处理失败: ${String(error)}`)
122
+ })
83
123
  return
84
124
  }
85
125
  if (event.type === 'turn/end') {
86
- maybeGuideNewSession(ctx, root, session)
126
+ // 坑 #68:同上,且内部已包 yieldHostPublication + safeDeliverToSession。
127
+ maybeGuideNewSession(ctx, root, session).catch((error) => {
128
+ ctx.logger.warn(`aiyayi-feishu: 接入引导处理失败: ${String(error)}`)
129
+ })
87
130
  }
88
131
  } catch (error) {
89
132
  ctx.logger.warn(`aiyayi-feishu: 接入引导处理失败: ${String(error)}`)
@@ -568,8 +611,9 @@ async function maybeOnboardIntent(ctx, root, session, event) {
568
611
  ctx.logger.info(`aiyayi-feishu: 会话 ${sessionId} 放弃接入,已清除待接入目标`)
569
612
  }
570
613
  markGuided(root, sessionId)
571
- await deliverToSession(
614
+ await safeDeliverToSession(
572
615
  ctx,
616
+ root,
573
617
  sessionId,
574
618
  null,
575
619
  `${GUIDE_PREFIX}好的,不接入也没关系。需要时随时说「接入飞书」,我会再给你扫码步骤。`,
@@ -580,8 +624,9 @@ async function maybeOnboardIntent(ctx, root, session, event) {
580
624
  writePendingBind(root, { sessionId, createdAt: Date.now() })
581
625
  markGuided(root, sessionId)
582
626
  ctx.logger.info(`aiyayi-feishu: 会话 ${sessionId} 请求接入飞书,已记待接入目标`)
583
- await deliverToSession(
627
+ await safeDeliverToSession(
584
628
  ctx,
629
+ root,
585
630
  sessionId,
586
631
  null,
587
632
  `${GUIDE_PREFIX}已记录接入目标,现在只差最后一步。请在手机上安装飞书 app(各大应用商店可下载),然后:1) 在 open.feishu.cn 扫码登录后打开机器人页面;2) 或在飞书 app 内直接搜索机器人名称发起单聊;3) 进入与机器人的单聊即自动接入本会话,之后随时可在手机飞书找我。如不想接入,回复「不用」跳过。`,
@@ -607,8 +652,9 @@ async function maybeGuideNewSession(ctx, root, session) {
607
652
  markGuided(root, sessionId)
608
653
  guidedSet.add(sessionId)
609
654
  ctx.logger.info(`aiyayi-feishu: 会话 ${sessionId} 未绑定飞书,注入接入引导`)
610
- await deliverToSession(
655
+ await safeDeliverToSession(
611
656
  ctx,
657
+ root,
612
658
  sessionId,
613
659
  null,
614
660
  `${GUIDE_PREFIX}(提示)本会话还没接入飞书聊天机器人。建议接入,这样在手机上也能随时找我:先在手机安装飞书 app(各大应用商店可下载),然后在 open.feishu.cn 扫码找到机器人,或直接在飞书里搜索机器人名称发起单聊——进入与机器人的单聊即自动接入本会话。如果不需要,回复「不用」即可跳过,我不会再提示。`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-aiyayi",
3
- "version": "1.5.16",
3
+ "version": "1.5.17",
4
4
  "license": "MIT",
5
5
  "author": "阿依娅伊 <aiyayi@local>",
6
6
  "keywords": [