@240xu/dsh-message-ops 0.11.4 → 0.11.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.
- package/README.md +10 -0
- package/package.json +1 -1
- package/src/index.js +9 -3
- package/src/ops-core.js +13 -2
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.5 · restore 进度落盘 + `turnAligned` 可观测
|
|
93
|
+
|
|
94
|
+
- **磁盘 restore 漏写 `restoredSourceSeqs`(数据正确性)**:`buildRestoreNoticeEvent`
|
|
95
|
+
只写 `restoresSeq`,而 `restoreProgress` 靠 `restoredSourceSeqs` 累计已重放项。
|
|
96
|
+
结果每次恢复都被判 `legacy`(`complete:true` 但 `restoredSeqs` 恒空)→ 进度不可见,
|
|
97
|
+
且下一轮 `excludeSeqs` 为空 → **同一区间被反复重放**(实测 008f3759 两轮各 209 条)。
|
|
98
|
+
磁盘路径改为把 `plan.replayable.map(i => i.seq)` 落进 notice;discard 时不写。
|
|
99
|
+
- `/revert` 与 `/restore` 响应新增 `turnAligned`:live 路径应为 `true`,
|
|
100
|
+
disk/store-miss 路径没有内存 agent,`false` 属正常。便于运行时确认游标对齐是否生效。
|
|
101
|
+
|
|
92
102
|
### 0.11.4 · turn 游标对齐真正生效(会话损坏 P0 续)
|
|
93
103
|
|
|
94
104
|
- **`alignLiveTurnCursor` 此前从未执行**:插件 `export const inject = []`
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -667,11 +667,14 @@ async function opsCommit(targetCtx, mode, sessionId, seq) {
|
|
|
667
667
|
const event = applySurfaceReplace(session, plan.startSeq, plan.endSeq, plan.shadowedSeqs, text, turnStep);
|
|
668
668
|
// 必须闭合:否则引擎内存里 turn 永远开着 → isRunning 恒真 → 后续操作全被 409
|
|
669
669
|
closeWindow()
|
|
670
|
-
|
|
670
|
+
const aligned = win.synthetic ? alignLiveTurnCursor(targetCtx, session, win.turn) : false;
|
|
671
671
|
flushSessions(targetCtx, session);
|
|
672
672
|
return {
|
|
673
673
|
ok: true, mode, seq,
|
|
674
674
|
syntheticTurn: win.synthetic === true,
|
|
675
|
+
// 0.11.4:暴露对齐结果。live 路径必须 true;disk 路径(store-miss)没有
|
|
676
|
+
// 内存 agent,false 属正常。若 live 也 false,下一条真实消息就会重号。
|
|
677
|
+
turnAligned: aligned,
|
|
675
678
|
shadowedCount: plan.shadowedSeqs.length,
|
|
676
679
|
eventSeq: event && event.seq != null ? event.seq : null,
|
|
677
680
|
};
|
|
@@ -748,8 +751,8 @@ async function opsRestore(targetCtx, sessionId, restoreSeq, upToSeq, discard) {
|
|
|
748
751
|
flush: () => { flushSessions(targetCtx, acq.session); },
|
|
749
752
|
});
|
|
750
753
|
for (const post of noticeWindowPostamble(win)) acq.session.append(post.kind, post.data);
|
|
751
|
-
|
|
752
|
-
return { ok: true, ...result, discarded: plan.discard === true, upToSeq: plan.upToSeq, restoredSourceSeqs: plan.replayable.map((i) => i.seq), range: { startSeq: plan.startSeq, endSeq: plan.endSeq } };
|
|
754
|
+
const aligned = win.synthetic ? alignLiveTurnCursor(targetCtx, acq.session, win.turn) : false;
|
|
755
|
+
return { ok: true, ...result, turnAligned: aligned, discarded: plan.discard === true, upToSeq: plan.upToSeq, restoredSourceSeqs: plan.replayable.map((i) => i.seq), range: { startSeq: plan.startSeq, endSeq: plan.endSeq } };
|
|
753
756
|
} catch (err) {
|
|
754
757
|
for (const post of noticeWindowPostamble(win)) {
|
|
755
758
|
try { acq.session.append(post.kind, post.data); } catch { /* postamble 被引擎拒:维持原错误上抛 */ }
|
|
@@ -774,6 +777,9 @@ async function opsRestore(targetCtx, sessionId, restoreSeq, upToSeq, discard) {
|
|
|
774
777
|
: restoreNoticeText(plan),
|
|
775
778
|
restoreSeq: plan.restoreSeq,
|
|
776
779
|
discard: plan.discard === true,
|
|
780
|
+
// 0.11.4:把本轮实际重放的源 seq 落进 notice,restoreProgress 才能累计进度、
|
|
781
|
+
// 下一轮 excludeSeqs 才不会重复重放同一批消息(详见 ops-core 该函数注释)。
|
|
782
|
+
restoredSourceSeqs: plan.discard ? [] : plan.replayable.map((i) => i.seq),
|
|
777
783
|
}));
|
|
778
784
|
let offset = 0;
|
|
779
785
|
for (const item of plan.discard ? [] : plan.replayable) {
|
package/src/ops-core.js
CHANGED
|
@@ -947,8 +947,18 @@ export function buildMarkerEvent({ seq, time, turnStep, text, startSeq, endSeq,
|
|
|
947
947
|
};
|
|
948
948
|
}
|
|
949
949
|
|
|
950
|
-
/**
|
|
951
|
-
|
|
950
|
+
/**
|
|
951
|
+
* 磁盘恢复说明事件(restoresSeq → dock 移除该行;surfaceOp 恒 "append")。
|
|
952
|
+
*
|
|
953
|
+
* 0.11.4:必须写入 `restoredSourceSeqs`。`restoreProgress` 靠它累计「已重放哪些
|
|
954
|
+
* 源 seq」来算 pending/complete;旧实现只写 `restoresSeq`,于是每次恢复都被判
|
|
955
|
+
* `legacy`(`complete:true` 但 `restoredSeqs` 恒空)→ 进度不可见,且下一轮
|
|
956
|
+
* `excludeSeqs` 为空 → 同一区间被**反复重放**(实测 008f3759 两轮各 209 条)。
|
|
957
|
+
*/
|
|
958
|
+
export function buildRestoreNoticeEvent({ seq, time, turnStep, text, restoreSeq, discard, restoredSourceSeqs, version = 4 }) {
|
|
959
|
+
const restored = Array.isArray(restoredSourceSeqs)
|
|
960
|
+
? [...new Set(restoredSourceSeqs.filter((q) => Number.isSafeInteger(q)))]
|
|
961
|
+
: [];
|
|
952
962
|
return {
|
|
953
963
|
type: "system/message",
|
|
954
964
|
seq,
|
|
@@ -958,6 +968,7 @@ export function buildRestoreNoticeEvent({ seq, time, turnStep, text, restoreSeq,
|
|
|
958
968
|
step: turnStep.step,
|
|
959
969
|
message: { id: randomUUID(), role: "system", source: messageSource("system", version), content: [{ type: "text", text }] },
|
|
960
970
|
restoresSeq: restoreSeq,
|
|
971
|
+
...(restored.length > 0 ? { restoredSourceSeqs: restored } : {}),
|
|
961
972
|
...(discard ? { discarded: true } : {}),
|
|
962
973
|
},
|
|
963
974
|
surfaceOp: "append",
|