dsh-remember 0.1.0 → 0.3.1

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.
@@ -0,0 +1,198 @@
1
+ //#region src/typert.ts
2
+ const codec = (name, parse) => ({
3
+ mode: "strict",
4
+ typeSymbol: `dsh-remember#${name}`,
5
+ create: () => ({ parse })
6
+ });
7
+ function requireObject(value, subject) {
8
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${subject} must be an object`);
9
+ return value;
10
+ }
11
+ function optionalString(value, subject) {
12
+ if (value === void 0) return void 0;
13
+ if (typeof value !== "string") throw new TypeError(`${subject} must be a string`);
14
+ return value;
15
+ }
16
+ function requireString(value, subject) {
17
+ if (typeof value !== "string" || value.length === 0) throw new TypeError(`${subject} must be a non-empty string`);
18
+ return value;
19
+ }
20
+ function numberOr(value, fallback) {
21
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
22
+ }
23
+ function stringRecord(value) {
24
+ return value === void 0 ? {} : { ...requireObject(value, "record") };
25
+ }
26
+ const statusCodec = codec("MemoryStatus", (value) => {
27
+ const record = requireObject(value, "memory status");
28
+ return {
29
+ phase: typeof record.phase === "string" ? record.phase : "idle",
30
+ detail: typeof record.detail === "string" ? record.detail : "",
31
+ summaryPreview: typeof record.summaryPreview === "string" ? record.summaryPreview : "",
32
+ updatedAt: numberOr(record.updatedAt, 0)
33
+ };
34
+ });
35
+ const configSnapshotCodec = codec("ConfigSnapshot", (value) => {
36
+ const record = requireObject(value, "config snapshot");
37
+ return {
38
+ value: stringRecord(record.value),
39
+ base: stringRecord(record.base),
40
+ user: stringRecord(record.user),
41
+ revision: numberOr(record.revision, 0)
42
+ };
43
+ });
44
+ const viewCodec = codec("MemoryView", (value) => {
45
+ const record = requireObject(value, "memory view");
46
+ return {
47
+ blobs: typeof record.blobs === "string" ? record.blobs : "",
48
+ records: typeof record.records === "string" ? record.records : "[]",
49
+ translatedStale: record.translatedStale === true,
50
+ translating: record.translating === true,
51
+ updatedAt: numberOr(record.updatedAt, 0)
52
+ };
53
+ });
54
+ const configPatchCodec = codec("ConfigPatch", (value) => {
55
+ const patch = requireObject(value, "config patch");
56
+ const entries = Object.entries(patch);
57
+ for (const [key, entry] of entries) if (entry !== null && typeof entry === "object" && !Array.isArray(entry)) throw new TypeError(`config field "${key}" must be a scalar, array, or null`);
58
+ return { ...patch };
59
+ });
60
+ const commandRequestCodec = codec("CommandRequest", (value) => {
61
+ const record = requireObject(value, "command request");
62
+ const request = {
63
+ action: requireString(record.action, "command action"),
64
+ force: record.force === true
65
+ };
66
+ const path = optionalString(record.path, "command path");
67
+ if (path !== void 0) request.path = path;
68
+ const arg = optionalString(record.arg, "command arg");
69
+ if (arg !== void 0) request.arg = arg;
70
+ const payload = optionalString(record.payload, "command payload");
71
+ if (payload !== void 0) request.payload = payload;
72
+ return request;
73
+ });
74
+ const commandResultCodec = codec("CommandResult", (value) => {
75
+ const record = requireObject(value, "command result");
76
+ const result = {
77
+ ok: record.ok === true,
78
+ detail: typeof record.detail === "string" ? record.detail : ""
79
+ };
80
+ if (record.bundle !== void 0) {
81
+ const bundle = requireObject(record.bundle, "command bundle");
82
+ result.bundle = {
83
+ name: requireString(bundle.name, "bundle name"),
84
+ data: requireString(bundle.data, "bundle data")
85
+ };
86
+ }
87
+ if (record.view !== void 0) result.view = viewCodec.create().parse(record.view);
88
+ return result;
89
+ });
90
+ /** Wires of the `memory` namespace, in service order. */
91
+ const MEMORY_INVOCATIONS = [
92
+ {
93
+ id: "dsh-remember#memory/getStatus",
94
+ service: "memory",
95
+ namespace: "memory",
96
+ method: "getStatus",
97
+ invocation: { kind: "direct" },
98
+ parameters: [],
99
+ result: statusCodec,
100
+ description: "Current scheduler phase, status detail, and summary preview."
101
+ },
102
+ {
103
+ id: "dsh-remember#memory/getConfig",
104
+ service: "memory",
105
+ namespace: "memory",
106
+ method: "getConfig",
107
+ invocation: { kind: "direct" },
108
+ parameters: [],
109
+ result: configSnapshotCodec,
110
+ description: "Effective plugin config with the base/user layers and a revision."
111
+ },
112
+ {
113
+ id: "dsh-remember#memory/updateConfig",
114
+ service: "memory",
115
+ namespace: "memory",
116
+ method: "updateConfig",
117
+ invocation: { kind: "direct" },
118
+ parameters: [{
119
+ name: "patch",
120
+ wire: "patch",
121
+ source: "json",
122
+ codec: configPatchCodec
123
+ }],
124
+ result: configSnapshotCodec,
125
+ description: "Validate and persist a config patch, returning the new snapshot."
126
+ },
127
+ {
128
+ id: "dsh-remember#memory/unsetConfig",
129
+ service: "memory",
130
+ namespace: "memory",
131
+ method: "unsetConfig",
132
+ invocation: { kind: "direct" },
133
+ parameters: [{
134
+ name: "field",
135
+ wire: "field",
136
+ source: "json",
137
+ codec: codec("ConfigField", (value) => requireString(value, "config field"))
138
+ }],
139
+ result: configSnapshotCodec,
140
+ description: "Reset one config field to the loader base value."
141
+ },
142
+ {
143
+ id: "dsh-remember#memory/getView",
144
+ service: "memory",
145
+ namespace: "memory",
146
+ method: "getView",
147
+ invocation: { kind: "direct" },
148
+ parameters: [],
149
+ result: viewCodec,
150
+ description: "Memory artifact snapshot for the viewer page."
151
+ },
152
+ {
153
+ id: "dsh-remember#memory/runCommand",
154
+ service: "memory",
155
+ namespace: "memory",
156
+ method: "runCommand",
157
+ invocation: { kind: "direct" },
158
+ parameters: [{
159
+ name: "request",
160
+ wire: "request",
161
+ source: "json",
162
+ codec: commandRequestCodec
163
+ }],
164
+ result: commandResultCodec,
165
+ description: "Run one user action (cycle, scheduling, folder, transfer, translate)."
166
+ }
167
+ ];
168
+ const SERVICE_DOC = {
169
+ description: "Memory subsystem of dsh-remember: config, status, viewer data, and user actions.",
170
+ summary: "Reads and edits the memory plugin state from the browser.",
171
+ tags: ["memory", "settings"],
172
+ key: "memory",
173
+ exportName: "MemoryService",
174
+ members: MEMORY_INVOCATIONS.map((invocation) => ({
175
+ kind: "method",
176
+ name: invocation.method,
177
+ signature: `${invocation.method}(${invocation.parameters.map((parameter) => `${parameter.name}: unknown`).join(", ")})`,
178
+ summary: invocation.description
179
+ })),
180
+ types: []
181
+ };
182
+ /** The manifest the Typert loader registers for this package. */
183
+ const TYPERT = {
184
+ package: "dsh-remember",
185
+ face: "host",
186
+ schemas: [],
187
+ invocations: MEMORY_INVOCATIONS,
188
+ model: {
189
+ services: [SERVICE_DOC],
190
+ events: [],
191
+ objects: []
192
+ },
193
+ events: [],
194
+ objects: []
195
+ };
196
+
197
+ //#endregion
198
+ export { MEMORY_INVOCATIONS, TYPERT };
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "Memory (dsh-remember)",
4
+ "description": "Cross-session long-term memory: idle sessions are extracted and consolidated into a searchable file library, recalled through prompt injection with citation tracking."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "记忆 (dsh-remember)",
4
+ "description": "跨会话长期记忆:自动提炼空闲会话、整理成可检索的记忆库,按需注入摘要,并记录引用来源。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-remember",
3
- "version": "0.1.0",
4
- "description": "Cross-session long-term memory for the DeepSeek Harness: a two-phase extraction/consolidation pipeline over a file-based memory workspace, recall injection, a citation feedback loop, lease-based job semantics, plus a settings page, a sidebar status panel and a memory viewer.",
3
+ "version": "0.3.1",
4
+ "description": "Cross-session long-term memory for the DeepSeek Harness: idle sessions are extracted and consolidated into a searchable file-based memory workspace, then recalled through prompt injection with citation tracking, a settings page, a sidebar status entry and a memory viewer.",
5
5
  "keywords": [
6
6
  "deepseek-harness",
7
7
  "dsh",
@@ -23,12 +23,21 @@
23
23
  "main": "lib/index.js",
24
24
  "exports": {
25
25
  ".": "./lib/index.js",
26
- "./client": "./lib/client.js"
26
+ "./client": "./lib/client.js",
27
+ "./typert": "./lib/typert.host.js",
28
+ "./package.json": "./package.json",
29
+ "./locale/*.json": "./locale/*.json"
27
30
  },
28
31
  "files": [
29
32
  "lib",
30
- "cordis.patch.yml"
33
+ "cordis.patch.yml",
34
+ "CHANGELOG.md",
35
+ "icon.svg",
36
+ "locale/*.json"
31
37
  ],
38
+ "engines": {
39
+ "dsh": ">=0.2.0-rc.1 <0.3.0-0"
40
+ },
32
41
  "dsh": {
33
42
  "bundle": {
34
43
  "patch": "./cordis.patch.yml"
@@ -38,7 +47,7 @@
38
47
  "inject": [
39
48
  "slots",
40
49
  "locale",
41
- "settingsScope"
50
+ "remote"
42
51
  ]
43
52
  }
44
53
  },
@@ -57,5 +66,6 @@
57
66
  },
58
67
  "publishConfig": {
59
68
  "access": "public"
60
- }
69
+ },
70
+ "icon": "icon.svg"
61
71
  }