@michengai/dsh-archive-manager 0.1.4 → 0.1.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 (2) hide show
  1. package/lib/workspace.js +85 -2
  2. package/package.json +1 -1
package/lib/workspace.js CHANGED
@@ -17,7 +17,7 @@ import { sessionDir } from "@deepseek-ai/dsh-spill-local";
17
17
  *
18
18
  * 所有可失败的持久化清理都先于不可逆的物理删除。此前任一步失败时,
19
19
  * 转录仍保留,可重试删除;物理删除失败时记录残留路径供人工排查。
20
- * `unarchiveSession` 与 `deleteSession` 通过 Typert Remote 暴露给浏览器。
20
+ * `unarchiveSession` 与 `deleteSession` 通过 Typert Remote 暴露给浏览器,并注册到 typert.local,避免生产环境只靠 SRC 扫描时 404。
21
21
  */
22
22
  function markRemoteMethod(instance, method) {
23
23
  // Simulate the TS decorator pipeline `@Remote(method)` for one method:
@@ -33,17 +33,100 @@ function markRemoteMethod(instance, method) {
33
33
  };
34
34
  Remote(method)(void 0, context);
35
35
  }
36
+ const sessionIdSchema = {
37
+ parse(value) {
38
+ if (typeof value !== "string" || value.length === 0) throw new TypeError(`sessionId must be a non-empty string, got ${String(value)}`);
39
+ return value;
40
+ }
41
+ };
42
+ const archivedSetSchema = {
43
+ parse(value) {
44
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError("result must be an object");
45
+ const ids = value.archivedSessionIds;
46
+ if (!Array.isArray(ids) || ids.some((id) => typeof id !== "string")) throw new TypeError("archivedSessionIds must be a string array");
47
+ return value;
48
+ }
49
+ };
50
+ const deletedSchema = {
51
+ parse(value) {
52
+ if (typeof value !== "object" || value === null || Array.isArray(value) || value.deleted !== true) throw new TypeError("deleted must be true");
53
+ return value;
54
+ }
55
+ };
56
+ /**
57
+ * Host 严格描述符。网关优先读 typert.local,避免 SRC 扫描缓存
58
+ * 或协议包双份导致 /api/workspaceRegistry/deleteSession 在生产环境 404。
59
+ */
60
+ const ARCHIVE_MANAGER_INVOCATIONS = [
61
+ {
62
+ id: "@michengai/dsh-archive-manager#workspaceRegistry/unarchiveSession",
63
+ service: "workspaceRegistry",
64
+ namespace: "workspaceRegistry",
65
+ method: "unarchiveSession",
66
+ invocation: { kind: "direct" },
67
+ parameters: [{
68
+ name: "sessionId",
69
+ wire: "sessionId",
70
+ source: "json",
71
+ codec: { mode: "strict", typeSymbol: "@deepseek-ai/dsh-session/types#SessionId", schema: sessionIdSchema }
72
+ }],
73
+ result: {
74
+ mode: "strict",
75
+ typeSymbol: "@michengai/dsh-archive-manager/types#ArchivedSessionIds",
76
+ schema: archivedSetSchema
77
+ },
78
+ sourceLocation: { file: "@michengai/dsh-archive-manager/lib/workspace.js", line: 1, column: 1 }
79
+ },
80
+ {
81
+ id: "@michengai/dsh-archive-manager#workspaceRegistry/deleteSession",
82
+ service: "workspaceRegistry",
83
+ namespace: "workspaceRegistry",
84
+ method: "deleteSession",
85
+ invocation: { kind: "direct" },
86
+ parameters: [{
87
+ name: "sessionId",
88
+ wire: "sessionId",
89
+ source: "json",
90
+ codec: { mode: "strict", typeSymbol: "@deepseek-ai/dsh-session/types#SessionId", schema: sessionIdSchema }
91
+ }],
92
+ result: {
93
+ mode: "strict",
94
+ typeSymbol: "@michengai/dsh-archive-manager/types#Deleted",
95
+ schema: deletedSchema
96
+ },
97
+ sourceLocation: { file: "@michengai/dsh-archive-manager/lib/workspace.js", line: 1, column: 1 }
98
+ }
99
+ ];
100
+ const ARCHIVE_MANAGER_TYPERT = {
101
+ package: "@michengai/dsh-archive-manager",
102
+ face: "host",
103
+ schemas: [],
104
+ model: { services: [], events: [], objects: [] },
105
+ invocations: ARCHIVE_MANAGER_INVOCATIONS
106
+ };
107
+ function registerHostRemote(ctx) {
108
+ const existing = ctx.get("typert");
109
+ if (existing !== undefined) {
110
+ existing.register(ARCHIVE_MANAGER_TYPERT);
111
+ return;
112
+ }
113
+ ctx.inject(["typert"], (typertCtx) => {
114
+ typertCtx.typert.register(ARCHIVE_MANAGER_TYPERT);
115
+ });
116
+ }
36
117
  var ArchiveWorkspaceRegistry = class extends WorkspaceRegistry {
37
118
  static inject = [
38
119
  "storageDomain",
39
120
  "sessionPersistence",
40
- "sessionProjectionCache"
121
+ "sessionProjectionCache",
122
+ "typert"
41
123
  ];
42
124
  constructor(ctx) {
43
125
  super(ctx);
44
126
  this.typertRemote = bindTypertRemote(this, this.name);
45
127
  markRemoteMethod(this, "unarchiveSession");
46
128
  markRemoteMethod(this, "deleteSession");
129
+ registerHostRemote(this.ctx);
47
130
  }
48
131
  /**
49
132
  * Move one session out of the registry-global archive set, restoring its
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michengai/dsh-archive-manager",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "NPM-installable DSH Web plugin for managing archived sessions.",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.21.0",