@240xu/dsh-message-ops 0.11.3 → 0.11.4

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
@@ -89,6 +89,16 @@ dsh plugin --profile web add file:C:/path/to/dsh-message-ops
89
89
  | POST | `/api/message-ops/session/restore` | `{trashId}` 从回收站恢复目录与投影/工作区元数据 |
90
90
  | POST | `/api/message-ops/session/purge` | `{trashId}` 永久删除(唯一 destructive 操作) |
91
91
 
92
+ ### 0.11.4 · turn 游标对齐真正生效(会话损坏 P0 续)
93
+
94
+ - **`alignLiveTurnCursor` 此前从未执行**:插件 `export const inject = []`
95
+ (tools 是可选增强,故意不声明硬依赖),因此 `ctx.agents` **属性恒为 undefined**,
96
+ 旧实现只读属性 → 恒返回 false。合成 turn 占用编号后宿主 idle agent 的
97
+ `phase.lastTurn` 不推进,下一条真实消息复用同一 turn 号,日志落成
98
+ `turn/start does not open the expected turn`,整份会话不可加载。
99
+ 改为属性优先、`ctx.get("agents")` 兜底(与 `resolveSession` 同取法)。
100
+ - 回归测试:`ctx.agents` 缺失必须走 `ctx.get`;游标已领先时不得回退。
101
+
92
102
  ### 0.11.3 · 区间编码、回填落盘与会话损坏修复
93
103
 
94
104
  - **`sourceEventSeqs` 区间语义修正(数据正确性)**:宿主用 `encodeSeqRanges` 把连续
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@240xu/dsh-message-ops",
3
- "version": "0.11.3",
3
+ "version": "0.11.4",
4
4
  "description": "DSH web 插件:消息级回滚 / 删除 / 恢复(补 dsh 官方没有的部分)。分支与导出用官方内置能力。",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/ops-core.js CHANGED
@@ -239,7 +239,15 @@ export function deriveTurnStep(events) {
239
239
  /** 合成 turn 落盘后,把宿主 idle agent 的 turn 游标对齐到该 turn(否则下一条真实消息会重号)。 */
240
240
  export function alignLiveTurnCursor(ctx, session, turn) {
241
241
  if (!Number.isSafeInteger(turn) || turn < 1 || !session || typeof session.id !== "string") return false;
242
- const agent = ctx && ctx.agents && typeof ctx.agents.get === "function" ? ctx.agents.get(session.id) : undefined;
242
+ // 0.11.4:插件 `inject` 故意留空(tools 是可选增强),因此 `ctx.agents`
243
+ // **属性访问恒为 undefined** —— 旧实现只写 `ctx.agents`,这条对齐从来没执行过。
244
+ // 实测 `ctx.get("agents")` 在 HTTP 请求期可解析(同 resolveSession 的取法),
245
+ // 故属性优先、ctx.get 兜底。
246
+ let agents = null;
247
+ try { if (ctx && ctx.agents) agents = ctx.agents; } catch { /* getter threw */ }
248
+ if (!agents) { try { agents = ctx && typeof ctx.get === "function" ? ctx.get("agents") : null; } catch { /* absent */ } }
249
+ let agent = null;
250
+ try { agent = agents && typeof agents.get === "function" ? agents.get(session.id) : null; } catch { /* registry miss */ }
243
251
  if (!agent || agent.phase?.kind !== "idle" || typeof agent.setPhase !== "function") return false;
244
252
  const lastTurn = Number.isSafeInteger(agent.phase.lastTurn) ? agent.phase.lastTurn : 0;
245
253
  if (lastTurn >= turn) return false;