@michengai/dsh-archive-manager 1.3.5 → 1.3.7
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 +14 -0
- package/CHANGELOG.zh-CN.md +14 -0
- package/README.de.md +3 -3
- package/README.en.md +3 -3
- package/README.es.md +3 -3
- package/README.fr.md +3 -3
- package/README.ja.md +3 -3
- package/README.md +3 -3
- package/README.pt.md +3 -3
- package/README.ru.md +3 -3
- package/README.zh-CN.md +3 -3
- package/lib/cache-rebuild-client.js +2 -1
- package/lib/cache-rebuild-contract.js +5 -1
- package/lib/client.js +6 -5
- package/lib/workspace.js +77 -8
- package/package.json +26 -26
package/lib/workspace.js
CHANGED
|
@@ -414,6 +414,18 @@ function bindArchiveManagerRemote(ctx) {
|
|
|
414
414
|
};
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
|
+
const missingCacheSources = /* @__PURE__ */ new WeakMap();
|
|
418
|
+
function isSessionNotFoundError(error, sessionId) {
|
|
419
|
+
if (!error || typeof error !== "object") return false;
|
|
420
|
+
const name = "name" in error ? String(error.name) : "";
|
|
421
|
+
if (name === "SessionPersistenceNotFoundError") return true;
|
|
422
|
+
const code = "code" in error ? String(error.code) : "";
|
|
423
|
+
if (code === "ENOENT") return true;
|
|
424
|
+
const message = "message" in error ? String(error.message) : "";
|
|
425
|
+
if (sessionId && message.includes(`session "${sessionId}" not found`)) return true;
|
|
426
|
+
if (message.endsWith("not found") && message.includes("session")) return true;
|
|
427
|
+
return false;
|
|
428
|
+
}
|
|
417
429
|
var ArchiveWorkspaceRegistry = class extends WorkspaceRegistry {
|
|
418
430
|
static inject = [
|
|
419
431
|
"storageDomain",
|
|
@@ -642,14 +654,44 @@ var ArchiveWorkspaceRegistry = class extends WorkspaceRegistry {
|
|
|
642
654
|
const cache = this.ctx.get("sessionProjectionCache");
|
|
643
655
|
if (!cache) throw new Error("Official session projection cache is unavailable");
|
|
644
656
|
const items = [];
|
|
645
|
-
const
|
|
657
|
+
const index = this.headers;
|
|
658
|
+
const headers = index?.size ? Array.from(index.values()) : await this.listStoredHeaders();
|
|
659
|
+
const missing = missingCacheSources.get(Reflect.get(this, symbols.original) ?? this);
|
|
646
660
|
for (const header of headers) {
|
|
647
|
-
if (await this.cacheRebuildEligible(header)
|
|
648
|
-
|
|
661
|
+
if (!await this.cacheRebuildEligible(header) || this.usableSessionListCache(header)) continue;
|
|
662
|
+
const identity = cacheIdentity(header);
|
|
663
|
+
if (missing?.get(header.id) === identity) {
|
|
664
|
+
let shouldContinue = false;
|
|
665
|
+
try {
|
|
666
|
+
const sourceMissing = await this.cacheSourceMissing(header.id, identity);
|
|
667
|
+
if (sourceMissing === true) shouldContinue = true;
|
|
668
|
+
else if (sourceMissing === void 0 && !await this.readSessionHeaderDirect(header.id)) shouldContinue = true;
|
|
669
|
+
} catch {
|
|
670
|
+
}
|
|
671
|
+
if (shouldContinue) continue;
|
|
672
|
+
missing.delete(header.id);
|
|
649
673
|
}
|
|
674
|
+
items.push({ sessionId: header.id, identity });
|
|
650
675
|
}
|
|
651
676
|
return { count: items.length, items };
|
|
652
677
|
}
|
|
678
|
+
markMissingCacheSource(sessionId, identity) {
|
|
679
|
+
const registry = Reflect.get(this, symbols.original) ?? this;
|
|
680
|
+
const previous = missingCacheSources.get(registry) ?? /* @__PURE__ */ new Map();
|
|
681
|
+
previous.set(sessionId, identity);
|
|
682
|
+
missingCacheSources.set(registry, previous);
|
|
683
|
+
}
|
|
684
|
+
/** stat 也会对坏头部返回空;仅在宿主工件查找明确返回空时才算缺源。 */
|
|
685
|
+
async cacheSourceMissing(sessionId, identity) {
|
|
686
|
+
const persistence = this.ctx.sessionPersistence;
|
|
687
|
+
if (typeof persistence?.findLog !== "function") return void 0;
|
|
688
|
+
const missing = await persistence.findLog(sessionId) === void 0;
|
|
689
|
+
const expectedIdentity = identity ?? (this.headers?.get(sessionId) ? cacheIdentity(this.headers.get(sessionId)) : void 0);
|
|
690
|
+
if (missing && expectedIdentity) {
|
|
691
|
+
this.markMissingCacheSource(sessionId, expectedIdentity);
|
|
692
|
+
}
|
|
693
|
+
return missing;
|
|
694
|
+
}
|
|
653
695
|
/** 定向读取持久化头部,优先单会话 stat 避免全量枚举,无 stat 时安全回退。 */
|
|
654
696
|
async readSessionHeaderDirect(sessionId) {
|
|
655
697
|
const persistence = this.ctx.sessionPersistence;
|
|
@@ -666,24 +708,51 @@ var ArchiveWorkspaceRegistry = class extends WorkspaceRegistry {
|
|
|
666
708
|
const result = { rebuiltSessionIds: [], skippedSessionIds: [], failures: [] };
|
|
667
709
|
for (const item of [...new Map(items.map((row) => [row.sessionId, row])).values()]) {
|
|
668
710
|
await this.enqueueOperation(async () => {
|
|
711
|
+
let stage = "lookup";
|
|
669
712
|
try {
|
|
670
713
|
const cache = this.ctx.get("sessionProjectionCache");
|
|
671
|
-
|
|
672
|
-
|
|
714
|
+
const readHeader = async () => {
|
|
715
|
+
const header2 = await this.readSessionHeaderDirect(item.sessionId);
|
|
716
|
+
if (header2) return header2;
|
|
717
|
+
const missing = await this.cacheSourceMissing(item.sessionId, item.identity);
|
|
718
|
+
if (missing === false) throw new Error("The source log exists, but its session header could not be read.");
|
|
719
|
+
if (missing) (result.missingSourceSessionIds ??= []).push(item.sessionId);
|
|
720
|
+
return void 0;
|
|
721
|
+
};
|
|
722
|
+
if (!cache) {
|
|
723
|
+
stage = "save";
|
|
724
|
+
throw new Error("Official session projection cache is unavailable");
|
|
725
|
+
}
|
|
726
|
+
const header = await readHeader();
|
|
673
727
|
if (!header || cacheIdentity(header) !== item.identity || !await this.cacheRebuildEligible(header) || this.usableSessionListCache(header)) {
|
|
674
728
|
result.skippedSessionIds.push(item.sessionId);
|
|
675
729
|
return;
|
|
676
730
|
}
|
|
677
|
-
|
|
678
|
-
|
|
731
|
+
stage = "read";
|
|
732
|
+
let source;
|
|
733
|
+
try {
|
|
734
|
+
source = await this.readStoredProjectionSource(this.ctx.sessionPersistence, item.sessionId);
|
|
735
|
+
} catch (readError) {
|
|
736
|
+
const confirmed = await this.cacheSourceMissing(item.sessionId, item.identity);
|
|
737
|
+
if (confirmed === true || confirmed !== false && isSessionNotFoundError(readError, item.sessionId)) {
|
|
738
|
+
this.markMissingCacheSource(item.sessionId, item.identity);
|
|
739
|
+
(result.missingSourceSessionIds ??= []).push(item.sessionId);
|
|
740
|
+
result.skippedSessionIds.push(item.sessionId);
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
throw readError;
|
|
744
|
+
}
|
|
745
|
+
stage = "lookup";
|
|
746
|
+
const current = await readHeader();
|
|
679
747
|
if (!current || cacheIdentity(current) !== item.identity || cacheIdentity(source.meta) !== item.identity || !await this.cacheRebuildEligible(current)) {
|
|
680
748
|
result.skippedSessionIds.push(item.sessionId);
|
|
681
749
|
return;
|
|
682
750
|
}
|
|
751
|
+
stage = "save";
|
|
683
752
|
await confirmColdCacheWrite(cache, source);
|
|
684
753
|
result.rebuiltSessionIds.push(item.sessionId);
|
|
685
754
|
} catch (error) {
|
|
686
|
-
result.failures.push({ sessionId: item.sessionId,
|
|
755
|
+
result.failures.push({ sessionId: item.sessionId, stage, message: errorMessage(error).slice(0, 500) });
|
|
687
756
|
}
|
|
688
757
|
});
|
|
689
758
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michengai/dsh-archive-manager",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.7",
|
|
4
4
|
"description": "归档、恢复、收藏和永久删除会话,并诊断损坏的会话日志。 · Archive, restore, favorite, and permanently delete sessions, and diagnose damaged session logs.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@11.22.0",
|
|
@@ -75,31 +75,31 @@
|
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@deepseek-ai/cordis": "4.1.0",
|
|
78
|
-
"@deepseek-ai/dsh-api-gateway": "0.2.2-rc.
|
|
79
|
-
"@deepseek-ai/dsh-client-connection": "0.2.2-rc.
|
|
80
|
-
"@deepseek-ai/dsh-client-locale": "0.2.2-rc.
|
|
81
|
-
"@deepseek-ai/dsh-client-store": "0.2.2-rc.
|
|
82
|
-
"@deepseek-ai/dsh-client-ui-conversation": "0.2.2-rc.
|
|
83
|
-
"@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.
|
|
84
|
-
"@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.
|
|
85
|
-
"@deepseek-ai/dsh-client-ui-sidebar": "0.2.2-rc.
|
|
86
|
-
"@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.
|
|
87
|
-
"@deepseek-ai/dsh-client-ui-workspace": "0.2.2-rc.
|
|
88
|
-
"@deepseek-ai/dsh-error": "0.2.2-rc.
|
|
89
|
-
"@deepseek-ai/dsh-host-webserver": "0.2.2-rc.
|
|
90
|
-
"@deepseek-ai/dsh-scope": "0.2.2-rc.
|
|
91
|
-
"@deepseek-ai/dsh-session": "0.2.2-rc.
|
|
92
|
-
"@deepseek-ai/dsh-session-format-catalog": "0.2.2-rc.
|
|
93
|
-
"@deepseek-ai/dsh-session-persistence": "0.2.2-rc.
|
|
94
|
-
"@deepseek-ai/dsh-session-projection": "0.2.2-rc.
|
|
95
|
-
"@deepseek-ai/dsh-session-projection-cache": "0.2.2-rc.
|
|
96
|
-
"@deepseek-ai/dsh-spill": "0.2.2-rc.
|
|
97
|
-
"@deepseek-ai/dsh-spill-local": "0.2.2-rc.
|
|
98
|
-
"@deepseek-ai/dsh-storage": "0.2.2-rc.
|
|
99
|
-
"@deepseek-ai/dsh-storage-domain": "0.2.2-rc.
|
|
100
|
-
"@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.
|
|
101
|
-
"@deepseek-ai/dsh-typert-registry": "0.2.2-rc.
|
|
102
|
-
"@deepseek-ai/dsh-workspace": "0.2.2-rc.
|
|
78
|
+
"@deepseek-ai/dsh-api-gateway": "0.2.2-rc.3",
|
|
79
|
+
"@deepseek-ai/dsh-client-connection": "0.2.2-rc.3",
|
|
80
|
+
"@deepseek-ai/dsh-client-locale": "0.2.2-rc.3",
|
|
81
|
+
"@deepseek-ai/dsh-client-store": "0.2.2-rc.3",
|
|
82
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.2.2-rc.3",
|
|
83
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.3",
|
|
84
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.3",
|
|
85
|
+
"@deepseek-ai/dsh-client-ui-sidebar": "0.2.2-rc.3",
|
|
86
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.3",
|
|
87
|
+
"@deepseek-ai/dsh-client-ui-workspace": "0.2.2-rc.3",
|
|
88
|
+
"@deepseek-ai/dsh-error": "0.2.2-rc.3",
|
|
89
|
+
"@deepseek-ai/dsh-host-webserver": "0.2.2-rc.3",
|
|
90
|
+
"@deepseek-ai/dsh-scope": "0.2.2-rc.3",
|
|
91
|
+
"@deepseek-ai/dsh-session": "0.2.2-rc.3",
|
|
92
|
+
"@deepseek-ai/dsh-session-format-catalog": "0.2.2-rc.3",
|
|
93
|
+
"@deepseek-ai/dsh-session-persistence": "0.2.2-rc.3",
|
|
94
|
+
"@deepseek-ai/dsh-session-projection": "0.2.2-rc.3",
|
|
95
|
+
"@deepseek-ai/dsh-session-projection-cache": "0.2.2-rc.3",
|
|
96
|
+
"@deepseek-ai/dsh-spill": "0.2.2-rc.3",
|
|
97
|
+
"@deepseek-ai/dsh-spill-local": "0.2.2-rc.3",
|
|
98
|
+
"@deepseek-ai/dsh-storage": "0.2.2-rc.3",
|
|
99
|
+
"@deepseek-ai/dsh-storage-domain": "0.2.2-rc.3",
|
|
100
|
+
"@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.3",
|
|
101
|
+
"@deepseek-ai/dsh-typert-registry": "0.2.2-rc.3",
|
|
102
|
+
"@deepseek-ai/dsh-workspace": "0.2.2-rc.3",
|
|
103
103
|
"@types/node": "^22.20.4",
|
|
104
104
|
"@types/react": "^18.3.31",
|
|
105
105
|
"@types/react-dom": "^18.0.0",
|