@chenhw7/dsh-memory 0.1.1 → 0.1.2

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 (65) hide show
  1. package/README.md +26 -2
  2. package/README.zh-CN.md +25 -1
  3. package/cordis.patch.yml +10 -0
  4. package/lib/brand.d.ts +7 -0
  5. package/lib/brand.d.ts.map +1 -1
  6. package/lib/brand.js +7 -0
  7. package/lib/brand.js.map +1 -1
  8. package/lib/client/index.js +826 -0
  9. package/lib/context/conflict.d.ts +59 -0
  10. package/lib/context/conflict.d.ts.map +1 -0
  11. package/lib/context/conflict.js +75 -0
  12. package/lib/context/conflict.js.map +1 -0
  13. package/lib/context/index.d.ts +11 -2
  14. package/lib/context/index.d.ts.map +1 -1
  15. package/lib/context/index.js +36 -9
  16. package/lib/context/index.js.map +1 -1
  17. package/lib/context/policy.d.ts +23 -2
  18. package/lib/context/policy.d.ts.map +1 -1
  19. package/lib/context/policy.js +77 -1
  20. package/lib/context/policy.js.map +1 -1
  21. package/lib/index.d.ts +50 -4
  22. package/lib/index.d.ts.map +1 -1
  23. package/lib/index.js +22 -3
  24. package/lib/index.js.map +1 -1
  25. package/lib/invariant.d.ts.map +1 -1
  26. package/lib/remote/index.d.ts +146 -0
  27. package/lib/remote/index.d.ts.map +1 -0
  28. package/lib/remote/index.js +257 -0
  29. package/lib/remote/index.js.map +1 -0
  30. package/lib/remote/typert.remote-client.d.ts +75 -0
  31. package/lib/remote/typert.remote-client.js +86 -0
  32. package/lib/remote/types.d.ts +9 -0
  33. package/lib/remote/types.d.ts.map +1 -0
  34. package/lib/remote/types.js +9 -0
  35. package/lib/remote/types.js.map +1 -0
  36. package/lib/review/accumulator.d.ts +18 -5
  37. package/lib/review/accumulator.d.ts.map +1 -1
  38. package/lib/review/accumulator.js +52 -14
  39. package/lib/review/accumulator.js.map +1 -1
  40. package/lib/review/dedup.d.ts +79 -0
  41. package/lib/review/dedup.d.ts.map +1 -0
  42. package/lib/review/dedup.js +171 -0
  43. package/lib/review/dedup.js.map +1 -0
  44. package/lib/review/extract.d.ts +28 -8
  45. package/lib/review/extract.d.ts.map +1 -1
  46. package/lib/review/extract.js +161 -23
  47. package/lib/review/extract.js.map +1 -1
  48. package/lib/review/index.d.ts +10 -0
  49. package/lib/review/index.d.ts.map +1 -1
  50. package/lib/review/index.js +55 -11
  51. package/lib/review/index.js.map +1 -1
  52. package/lib/scanner.d.ts +16 -0
  53. package/lib/scanner.d.ts.map +1 -1
  54. package/lib/scanner.js +25 -2
  55. package/lib/scanner.js.map +1 -1
  56. package/lib/store/index.d.ts +49 -0
  57. package/lib/store/index.d.ts.map +1 -1
  58. package/lib/store/index.js +238 -15
  59. package/lib/store/index.js.map +1 -1
  60. package/lib/tool/index.d.ts.map +1 -1
  61. package/lib/tool/index.js +173 -3
  62. package/lib/tool/index.js.map +1 -1
  63. package/lib/types.d.ts +60 -4
  64. package/lib/types.d.ts.map +1 -1
  65. package/package.json +39 -17
package/README.md CHANGED
@@ -237,7 +237,7 @@ All settings are editable from the dsh frontend settings page (the `memory` name
237
237
 
238
238
  | Setting | Default | Meaning |
239
239
  |---|---|---|
240
- | `memoryMode` | `policy-only` | `full`: inject memory content + guidance. `policy-only`: inject guidance only, model searches on demand. `custom`: inject user-defined policy text. `off`: no injection. |
240
+ | `memoryMode` | `policy-only` | `full`: inject memory content + guidance. `policy-only`: inject guidance only, model searches on demand. `custom`: inject user-defined policy text. `off`: no injection. `index`: inject an existence index (one line per entry) so the model can see what is stored and route to `memory_get`/`memory_search`. |
241
241
  | `memoryPolicyCustomText` | — | Custom policy text used when `memoryMode` is `custom`. |
242
242
  | `reviewEnabled` | `true` | Enable automatic periodic review extraction. |
243
243
  | `reviewCandidateThreshold` | `10` | Number of candidate messages before an LLM extraction runs. |
@@ -245,7 +245,31 @@ All settings are editable from the dsh frontend settings page (the `memory` name
245
245
  | `flushOnDispose` | `true` | Extract remaining context when a session is disposed. |
246
246
  | `memoryCharLimit` | `5000` | Per-scope character limit for injected memory content. |
247
247
 
248
- Example `$DSH_HOME/settings.yaml`:
248
+ ### Extraction & Dedup Settings
249
+
250
+ These settings control the automatic extraction pipeline and the dedup judge. They live in the `memory-review` plugin config (set via the composition layer, not the `memory` settings namespace):
251
+
252
+ | Setting | Default | Meaning |
253
+ |---|---|---|
254
+ | `extractionModelProvider` | `""` (session route) | Override the LLM provider for extraction/judge calls. Empty = use the session's conversational model (the default — extraction reuses the same model the user is chatting with, no extra keys or billing channel). |
255
+ | `extractionModelModel` | `""` (session route) | Override the model name for extraction/judge calls. Empty = use the session's conversational model. Set both fields to route extraction to a cheaper/faster model. |
256
+ | `extractionBudget` | `20` | Max extraction + judge calls per session. `0` = unlimited. |
257
+ | `judgeEnabled` | `true` | Run the LLM dedup judge on prefilter hits. When `false`, prefilter hits merge directly (cheaper, but may false-merge same-template different-topic pairs). |
258
+
259
+ By default, extraction and the dedup judge use the **same model the user is chatting with** — the session's provider/model route. To run them on a dedicated cheaper model, set `extractionModelProvider` and `extractionModelModel` in the review plugin's composition config.
260
+
261
+ Example composition config for a dedicated extraction model:
262
+
263
+ ```yaml
264
+ memory-review:
265
+ config:
266
+ extractionModelProvider: deepseek
267
+ extractionModelModel: deepseek-chat
268
+ extractionBudget: 20
269
+ judgeEnabled: true
270
+ ```
271
+
272
+ Example `$DSH_HOME/settings.yaml` (memory namespace):
249
273
 
250
274
  ```yaml
251
275
  memory:
package/README.zh-CN.md CHANGED
@@ -205,7 +205,7 @@ dsh web
205
205
 
206
206
  | 设置 | 默认值 | 说明 |
207
207
  |---|---|---|
208
- | `memoryMode` | `policy-only` | `full`:注入记忆内容 + 指引;`policy-only`:只注入指引,模型按需搜索;`custom`:注入用户自定义策略文本;`off`:不注入。 |
208
+ | `memoryMode` | `policy-only` | `full`:注入记忆内容 + 指引;`policy-only`:只注入指引,模型按需搜索;`custom`:注入用户自定义策略文本;`off`:不注入;`index`:注入存在性索引(每个条目一行),模型可看见存了什么并路由到 `memory_get`/`memory_search`。 |
209
209
  | `memoryPolicyCustomText` | — | 当 `memoryMode` 为 `custom` 时使用的自定义策略文本。 |
210
210
  | `reviewEnabled` | `true` | 启用自动周期性 review 提取。 |
211
211
  | `reviewCandidateThreshold` | `10` | 触发 LLM 提取前的候选消息数。 |
@@ -213,6 +213,30 @@ dsh web
213
213
  | `flushOnDispose` | `true` | 会话销毁时提取剩余上下文。 |
214
214
  | `memoryCharLimit` | `5000` | 每个作用域注入记忆内容的字符上限。 |
215
215
 
216
+ ### 提取与去重设置
217
+
218
+ 以下设置控制自动提取管线和去重裁决,位于 `memory-review` 插件配置中(通过组合层设置,不在 `memory` 设置命名空间里):
219
+
220
+ | 设置 | 默认值 | 说明 |
221
+ |---|---|---|
222
+ | `extractionModelProvider` | `""`(会话路由) | 覆盖提取/裁决调用的 LLM provider。留空 = 使用会话的对话模型(默认行为——提取复用用户正在聊天的模型,无需额外 key 或计费通道)。 |
223
+ | `extractionModelModel` | `""`(会话路由) | 覆盖提取/裁决调用的模型名。留空 = 使用会话的对话模型。两者都设置可将提取路由到更廉价/更快的模型。 |
224
+ | `extractionBudget` | `20` | 每会话最大提取 + 裁决调用次数。`0` = 无限。 |
225
+ | `judgeEnabled` | `true` | 对预过滤命中运行 LLM 去重裁决。设为 `false` 时预过滤命中直接合并(更廉价,但可能误合并"同模板不同主题"对)。 |
226
+
227
+ 默认情况下,提取和去重裁决使用**与用户对话相同的模型**——即会话的 provider/model 路由。若要在专用廉价模型上运行,在 review 插件的组合配置中设置 `extractionModelProvider` 和 `extractionModelModel`。
228
+
229
+ 专用提取模型的组合配置示例:
230
+
231
+ ```yaml
232
+ memory-review:
233
+ config:
234
+ extractionModelProvider: deepseek
235
+ extractionModelModel: deepseek-chat
236
+ extractionBudget: 20
237
+ judgeEnabled: true
238
+ ```
239
+
216
240
  `$DSH_HOME/settings.yaml` 配置示例:
217
241
 
218
242
  ```yaml
package/cordis.patch.yml CHANGED
@@ -13,6 +13,12 @@
13
13
  # Row order carries no load semantics; the grouping is for readers.
14
14
 
15
15
  - insert:
16
+ # Root entry: lets the host client-module scanner discover dsh.client.
17
+ # No host-side code runs; this is a no-op plugin that exists solely so
18
+ # the scanner can resolve this package's package.json from a root spec.
19
+ - id: memory-root
20
+ name: '@chenhw7/dsh-memory'
21
+
16
22
  # Memory store provider — opens the 'memory' domain, registers ctx.memory.
17
23
  # Requires the storage-domain facility (provided by dsh-web-app; headless
18
24
  # users must add storage-domain themselves — see README).
@@ -30,3 +36,7 @@
30
36
  # System-prompt section injection + frontend settings namespace.
31
37
  - id: memory-context
32
38
  name: '@chenhw7/dsh-memory/context'
39
+
40
+ # @Remote service for the memory management UI (§3.8).
41
+ - id: memory-remote
42
+ name: '@chenhw7/dsh-memory/remote-service'
package/lib/brand.d.ts CHANGED
@@ -7,4 +7,11 @@ export type MemoryId = Branded<'MemoryId'>;
7
7
  * @returns a fresh branded id.
8
8
  */
9
9
  export declare function MemoryId(id?: string): MemoryId;
10
+ /** Identifies one audit-record entry in the audit table. */
11
+ export type AuditId = Branded<'AuditId'>;
12
+ /**
13
+ * Mint a new unique audit id.
14
+ * @returns a fresh branded id.
15
+ */
16
+ export declare function AuditId(id?: string): AuditId;
10
17
  //# sourceMappingURL=brand.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../src/brand.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAGrD,wDAAwD;AACxD,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAE1C;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,EAAE,GAAE,MAAqB,GAAG,QAAQ,CAE5D"}
1
+ {"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../src/brand.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAGrD,wDAAwD;AACxD,MAAM,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAE1C;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,EAAE,GAAE,MAAqB,GAAG,QAAQ,CAE5D;AAED,4DAA4D;AAC5D,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAExC;;;GAGG;AACH,wBAAgB,OAAO,CAAC,EAAE,GAAE,MAAqB,GAAG,OAAO,CAE1D"}
package/lib/brand.js CHANGED
@@ -7,4 +7,11 @@ import { randomUUID } from 'node:crypto';
7
7
  export function MemoryId(id = randomUUID()) {
8
8
  return id;
9
9
  }
10
+ /**
11
+ * Mint a new unique audit id.
12
+ * @returns a fresh branded id.
13
+ */
14
+ export function AuditId(id = randomUUID()) {
15
+ return id;
16
+ }
10
17
  //# sourceMappingURL=brand.js.map
package/lib/brand.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"brand.js","sourceRoot":"","sources":["../src/brand.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAG/E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAKxC;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa,UAAU,EAAE;IAChD,OAAO,EAAc,CAAA;AACvB,CAAC"}
1
+ {"version":3,"file":"brand.js","sourceRoot":"","sources":["../src/brand.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAG/E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAKxC;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,EAAE,GAAW,UAAU,EAAE;IAChD,OAAO,EAAc,CAAA;AACvB,CAAC;AAKD;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,EAAE,GAAW,UAAU,EAAE;IAC/C,OAAO,EAAa,CAAA;AACtB,CAAC"}