@modusensus/dsh-mneme 0.7.21 → 0.7.23

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.en.md CHANGED
@@ -7,7 +7,7 @@ English | [简体中文](README.md)
7
7
  [![npm version](https://img.shields.io/npm/v/@modusensus/dsh-mneme?color=blue&label=npm)](https://www.npmjs.com/package/@modusensus/dsh-mneme)
8
8
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
9
9
  [![Awesome](https://awesome-dsh-plugin.com/badge.svg)](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin)
10
- [![tests](https://img.shields.io/badge/tests-685%20passed-success)](https://github.com/modusensus/dsh-mneme)
10
+ [![tests](https://img.shields.io/badge/tests-712%20passed-success)](https://github.com/modusensus/dsh-mneme)
11
11
 
12
12
  > A cross-session memory plugin for DeepSeek Harness: it lets the Agent remember you, remember your projects, and organize memories automatically. **Mneme** (Μνήμη) — named after Mnemosyne, the Greek goddess of memory who presides over memory and dreams, just as autoDream consolidates memories in the background.
13
13
 
@@ -58,15 +58,15 @@ English | [简体中文](README.md)
58
58
 
59
59
  #### dreamMaxTokens Tuning Guide
60
60
 
61
- The default `8192` covers ordinary memory stores. When the **memory volume is large** (tens of thousands of characters or more), the decision list and summary may exceed the default budget; scale it up by size:
61
+ The default `32768` reserves headroom for reasoning models, where reasoning alone may consume 8k+ tokens before any body output. For **larger memory stores** scale it up by size:
62
62
 
63
63
  | Memory store size | Recommended `dreamMaxTokens` |
64
64
  |-----------|----------------------|
65
- | Ordinary (<10k chars) | `8192` (default) |
65
+ | Ordinary (<10k chars) | `32768` (default) |
66
66
  | Medium (10k–50k chars) | `65536` |
67
67
  | Large (>50k chars) | `131072` (cap) |
68
68
 
69
- > With **reasoning models** (e.g. DeepSeek-R1-like), the model may spend the entire budget on reasoning and return an empty body (the log shows `no json array in llm output`). In that case, setting `dreamReasoningEffort` to `low` suppresses reasoning overhead and leaves the budget for the body output; the sleep side has the corresponding `sleepReasoningEffort`. The default `none` omits the field entirely, fully honoring the model's own default behavior identical to earlier versions.
69
+ > With **reasoning models** (e.g. DeepSeek-R1-like), the model may spend the entire budget on reasoning and return an empty body (the log shows `no json array in llm output`). Resolution order: set `dreamReasoningEffort` to `low` to suppress reasoning overhead (when the provider rejects the parameter it is stripped automatically and retried once — the rejection reason lands in `llm_audit`; some models, e.g. v4-flash-ga, reject every effort tier); ② if the retry still returns an empty body under the model's default reasoning behavior, raise `dreamMaxTokens` (reasoning and body share this budget) or route `dreamProvider`/`dreamModel` to a non-reasoning model. The sleep side has the corresponding `sleepReasoningEffort`.
70
70
 
71
71
  ### Sleep Mode: System-Level Sleep 💤 (v0.4.0, opt-in)
72
72
 
@@ -166,6 +166,8 @@ Every **background LLM call** (autoDream consolidation + summary, autoSummarize
166
166
 
167
167
  | Version | Highlights |
168
168
  |------|------|
169
+ | **v0.7.23** | Root-caused "memory consolidation keeps failing": a legal empty decision array `[]` from consolidation is no longer treated as a failure (CONSOLIDATION_PROMPT explicitly allows "no output when nothing needs changing", so a model with a healthy, non-redundant memory legitimately returns `[]` — yet `validateDecisions` hard-rejected it as `decision list must be a non-empty array`, failing the whole run and flooding the audit with failures; **model-agnostic** — ChatGPT/Claude hit the same trap; fix: empty array short-circuits to `ok:true` no-op instead of tripping the implicit-keep coverage check). Plus: empty-body fix part 2 (`dreamMaxTokens` default 8192→32768 so thinking models don't burn the whole budget on reasoning) + skipInvalid splice residue bug (length equality ≠ content equality, skipped decisions leaked into apply/audit); 712 tests green |
170
+ | **v0.7.22** | Restored the v0.6.9 skipInvalid tolerant-validation path (issue #89 regression, lost in the v0.7.11 rewrite): `dreamSkipInvalid` (default true) skips individual invalid decisions, applies the valid subset, and marks the run degraded; `allowCrossTypeMerge` (default false) explicitly relaxes cross-type merging — weak models (e.g. qwen3.8-flash) with jittery schema compliance no longer fail the whole batch and burn LLM calls. Strict mode and the sleep path behave unchanged; global caps/coverage floors still reject the whole run (running over cap = broken model, not minor schema drift). New `dreamMinIntervalMinutes` (0–10080, default 0 = unlimited) minimum autoDream trigger interval — failed/degraded runs also consume the interval (throttling exists to stop back-to-back failing calls); feature_flags whitelist now 34 keys; 696 tests green |
169
171
  | **v0.7.21** | Fixed autoDream/sleep effort fallback being dead code on the stream path (the catch-based retry from v0.7.16 never fired): dsh-llm rc.1 turns adapter-stage failures (incl. `UNSUPPORTED_REASONING_EFFORT`) into a terminal error finish chunk instead of a throw; `streamText` now captures the finish-chunk failure cause (`describeStreamFailure` normalizes `{code,message}`) + `withEffortFallback` gains a `getStreamError` accessor (retries without effort when rejected) + `runAuditedLlm` supports `spec.streamError` (audit `error_message` carries the real cause; `run.error` stays a stable `"llm failed"`); 688 tests green |
170
172
  | **v0.7.20** | Heat model restored (issue #87): v0.7.0 self-evolving memory back (`src/heat.js` power-law decay `H=1/(1+λΔt)^α` + per-type half-lives), sleep demotion dual protection (cold time-window + heat<0.05 + importance<5), touchRecalled gating back on `heatEnabled`, entity heat projection (ego node heat → size/opacity), recall_runs recording on by default; **default OFF** (matches v0.7.12 behavior out of the box) + feature_flags whitelist rollback switch + lightMode linkage + sleep demotion audit counts exposed (workbench can show "N demoted") + phase-two frontend (/list heat projection, HeatBadge three-tier badge, self-gated status heat-distribution card, order=heat page-local sort, all self-gated); better-sidebar fix (issue #88: soft integration moved to an inner dynamic sub-plugin, no more startup failure without bs); 685 tests green |
171
173
  | **v0.7.18** | Ecosystem step one + query convergence: better-sidebar soft integration (inject declaration + optional peer `dsh-better-sidebar` + registerTab reusing the four views, safe skip when absent; narrow-container `@container` adaptation) + `/list?deposited=only` view (receipt_chain ∪ source=dream) + deposited/archived filter chips in the library + status-page dashboard (server totals + view-all jumps) + drawer restore for archived memories; 667 tests green |
@@ -219,6 +221,7 @@ Every **background LLM call** (autoDream consolidation + summary, autoSummarize
219
221
  | v0.7.18 | ✅ Done | Ecosystem step one + query convergence | better-sidebar soft integration (inject declaration + optional peer + registerTab reusing the four views, safe skip when absent; narrow-container `@container`) + `/list?deposited=only` view + deposited/archived filter chips + status-page dashboard + drawer restore; 667 tests green |
220
222
  | v0.7.20 | ✅ Done | Heat restore + phase-two frontend + better-sidebar fix | Heat model fully restored (issue #87, backported from v0.7.10: power-law decay + TYPE_DECAY + sleep heat-combined dual protection + entity heat projection) + acceptance checklist landed (heatEnabled default OFF / feature_flags 31 keys / lightMode linkage / sleep demotion audit / updated_at⊥last_accessed_at contract) + phase-two frontend (/list heat projection, HeatBadge three-tier, order=heat page-local sort) + better-sidebar fix (issue #88: inner dynamic sub-plugin); 685 tests green |
221
223
  | v0.7.21 | ✅ Done | effort-fallback stream fix | Catch-based effort fallback was dead code on the stream path (dsh-llm rc.1 turns adapter failures into a terminal error finish chunk instead of a throw) → `streamText` captures the finish-chunk cause (`describeStreamFailure`) + `withEffortFallback` gains a `getStreamError` accessor (retries without effort when rejected) + `runAuditedLlm` supports `spec.streamError` (real cause in audit); 688 tests green |
224
+ | v0.7.22 | ✅ Done | skipInvalid tolerant-validation restore (issue #89) + autoDream throttle | Restored v0.6.9 skipInvalid dual-track structure (lost in the v0.7.11 rewrite): `dreamSkipInvalid` skips individual invalid decisions + applies the valid subset + marks the run degraded; `allowCrossTypeMerge` explicitly relaxes cross-type merging; weak models (qwen3.8-flash) with jittery schema compliance no longer fail the whole batch. New `dreamMinIntervalMinutes` (0–10080, default 0) minimum trigger interval — failed/degraded runs also consume it. Strict mode / sleep path unchanged; feature_flags whitelist 34 keys; 696 tests green |
222
225
  | **v0.8.0** | 🚧 Planned (late Sep) | Graph enhancement | Interest-drift visualization + scope isolation (issue #17) + cross-workspace sharing |
223
226
 
224
227
  > All new capabilities ship as **toggleable features** (enabled/disabled via configuration), conservatively on by default and never breaking existing behavior. The `failure_memories` table and the autoDream decision engine have already paved the way for future reflective growth.
@@ -289,7 +292,7 @@ It works out of the box with the defaults. To adjust, override in `~/.dsh/profil
289
292
  | `dreamThresholdChars` | `5000` | Total character threshold that triggers consolidation |
290
293
  | `dreamDelayMs` | `2000` | Asynchronous consolidation delay (debounce) |
291
294
  | `dreamProvider` / `dreamModel` | empty | Explicit dream LLM route — config wins over the agent's default model (config-first, v0.7.16); left empty, the agent's default model is used |
292
- | `dreamMaxTokens` | `8192` | Maximum tokens per dream LLM call (cap 131072; increase for large memory stores — see the tuning guide below) |
295
+ | `dreamMaxTokens` | `32768` | Maximum tokens per dream LLM call (cap 131072; reasoning and body share this budget on reasoning models raise it when the body comes back empty, see the tuning guide below) |
293
296
  | `dreamReasoningEffort` | `none` | Reasoning-effort passthrough for the dream LLM: `low` / `medium` / `high` / `none` (`none` = omit the field and use the model default; set `low` when a reasoning model exhausts its budget on reasoning and produces an empty body) |
294
297
  | `apiToken` | empty | Optional API auth token; once set, write operations and key endpoints require `Authorization: Bearer <apiToken>` |
295
298
  | `embedProvider` | `openai` | Semantic backend: `openai` (default, v0.1-compatible) / `local` (ONNX offline) / `ollama` |
@@ -438,7 +441,7 @@ src/
438
441
  lib/
439
442
  ├── client.js # Web 面板(手写 ModuleLoader bundle)
440
443
  └── *.js # src 的同步分发产物
441
- test/ # 662 node:test tests (audit + three-axis stress invariants)
444
+ test/ # 712 node:test tests (audit + three-axis stress invariants)
442
445
  scripts/ # e2e-dsh.js 端到端演示 · stress-dsh.js 三轴线压测 · sync-lib.js 同步
443
446
  ```
444
447
 
@@ -447,7 +450,7 @@ scripts/ # e2e-dsh.js 端到端演示 · stress-dsh.js 三轴线压
447
450
  ```bash
448
451
  cd dsh-mneme
449
452
  npm install # 安装 peer 依赖(以 devDependencies 形式,用于本地测试)
450
- npm test # 运行 662 个测试
453
+ npm test # 运行 712 个测试
451
454
  npm run stress # 三轴线压测:长会话检索 / 冲突仲裁 / 多 Agent 并发(离线 mock LLM)
452
455
  npm run sync # 把 src/ 同步到 lib/(发布时由 prepack 钩子自动执行)
453
456
  ```
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![npm version](https://img.shields.io/npm/v/@modusensus/dsh-mneme?color=blue&label=npm)](https://www.npmjs.com/package/@modusensus/dsh-mneme)
6
6
  [![license](https://img.shields.io/badge/license-MIT-green)](LICENSE)
7
7
  [![Awesome](https://awesome-dsh-plugin.com/badge.svg)](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin)
8
- [![tests](https://img.shields.io/badge/tests-685%20passed-success)](https://github.com/modusensus/dsh-mneme)
8
+ [![tests](https://img.shields.io/badge/tests-712%20passed-success)](https://github.com/modusensus/dsh-mneme)
9
9
  [![CI](https://img.shields.io/github/actions/workflow/status/modusensus/dsh-mneme/ci.yml)](https://github.com/modusensus/dsh-mneme/actions)
10
10
  [![node](https://img.shields.io/badge/node-24%2B-blue)](https://nodejs.org)
11
11
  [![npm downloads](https://img.shields.io/npm/dm/@modusensus/dsh-mneme?color=blue&label=downloads)](https://www.npmjs.com/package/@modusensus/dsh-mneme)
@@ -81,15 +81,15 @@ dsh web
81
81
 
82
82
  #### dreamMaxTokens 调优指南
83
83
 
84
- 默认 `8192` 已覆盖常规记忆库。当**记忆量大**(数万字符以上)时,决策清单与摘要可能超过默认预算,建议按规模调大:
84
+ 默认 `32768` 已为思考型模型预留推理+正文的双重预算(部分思考型模型仅推理就可能消耗 8k+ token)。当**记忆量大**(数万字符以上)时按规模继续调大:
85
85
 
86
86
  | 记忆库规模 | 建议 `dreamMaxTokens` |
87
87
  |-----------|----------------------|
88
- | 常规(<1 万字) | `8192`(默认) |
88
+ | 常规(<1 万字) | `32768`(默认) |
89
89
  | 中等(1 万-5 万字) | `65536` |
90
90
  | 大型(5 万字以上) | `131072`(上限) |
91
91
 
92
- > 若使用**思考型模型**(如 deepseek-v4-flash / DeepSeek-R1 类),模型可能把全部预算花在 reasoning 上导致正文为空(日志出现 `no json array in llm output`,v0.7.16 已修复)。此时把 `dreamReasoningEffort` 设为 `low` 显式压低思考(`none` 默认不传该字段,完全沿用模型自身默认,行为与旧版本一致);即使被方舟拒绝该参数,v0.7.16 起也会自动去掉重试一次。sleep 侧对应 `sleepReasoningEffort`。
92
+ > 若使用**思考型模型**(如 deepseek-v4-flash / DeepSeek-R1 类),模型可能把全部预算花在 reasoning 上导致正文为空(日志出现 `no json array in llm output`)。处理顺序:① `dreamReasoningEffort` 设为 `low` 显式压低思考(被方舟拒绝该参数时自动去掉重试一次,拒绝原因会记入 llm_audit——部分模型如 v4-flash-ga 不支持任何 effort 档位);② 重试走模型默认思考行为后正文仍为空的,调大 `dreamMaxTokens`(reasoning 与正文共享该预算)或配置 `dreamProvider`/`dreamModel` 指向非思考模型。sleep 侧对应 `sleepReasoningEffort`。
93
93
 
94
94
  ### Sleep Mode 系统级睡眠 💤(v0.4.0,opt-in)
95
95
 
@@ -207,6 +207,8 @@ v0.3.0 起新增**记忆基因**层:从记忆里抽取**命名实体**、**带
207
207
 
208
208
  | 版本 | 亮点 |
209
209
  |------|------|
210
+ | **v0.7.23** | 记忆沉淀「反复失败」根治:consolidation 合法空数组 `[]` 不再误判 failed(CONSOLIDATION_PROMPT 允许「无问题无需输出」,模型无冗余时合法返回 `[]`——此前 `validateDecisions` 硬判 non-empty → 整单 failed、审计反复失败,且与模型无关,ChatGPT/Claude 同样踩中;修复:空数组显式短路 `ok:true` no-op)+ 空体修复第二段(`dreamMaxTokens` 默认 8192→32768,思考模型推理烧光预算的根治余量,设置面板可调)+ skipInvalid splice 残留 bug(长度相等≠内容一致,被跳决策残留);712 测试全绿 |
211
+ | **v0.7.22** | 恢复 v0.6.9 的 skipInvalid 宽容校验路径(issue #89 回归,v0.7.11 重写丢失):`dreamSkipInvalid`(默认 true)单条非法决策跳过 + 合法子集应用 + run 记 degraded,`allowCrossTypeMerge`(默认 false)显式放宽跨类型合并——弱模型(如 qwen3.8-flash)决策合规抖动不再整单拒绝白烧 LLM 调用;严格模式/sleep 路径行为不变,全局上限/覆盖率下限仍整单拒绝(刷爆上限=模型坏了,非轻微 schema 漂移);新增 `dreamMinIntervalMinutes`(0-10080,默认 0=不限)autoDream 最小触发间隔,失败/degraded run 也占用间隔(节流防失败调用连发);feature_flags 白名单 34 键;696 测试全绿 |
210
212
  | **v0.7.21** | 修复 autoDream/sleep 的 effort 回退在流式路径失效(v0.7.16 的 catch 式回退是死代码):dsh-llm rc.1 把 adapter 阶段异常(含 `UNSUPPORTED_REASONING_EFFORT`)转成终态 error finish chunk 不再抛出;`streamText` 现捕获 finish-chunk 失败原因(新增 `describeStreamFailure` 归一化 `{code,message}`)+ `withEffortFallback` 增加 `getStreamError` 访问器(effort 被拒时去掉重试一次)+ `runAuditedLlm` 支持 `spec.streamError`(audit 行 `error_message` 携带真实原因,`run.error` 稳定 `"llm failed"` 不变);688 测试全绿 |
211
213
  | **v0.7.20** | heat 热度模型回归(issue #87):找回 v0.7.0 自进化记忆(`src/heat.js` 幂律衰减 `H=1/(1+λΔt)^α` + per-type 差异化半衰期)、sleep 降级热联合双保护(时间窗冷 + heat<0.05 + importance<5)、touchRecalled 门控改回 `heatEnabled`、实体热投影(ego 节点 heat → 前端大小/明暗)、recall_runs 默认记录;**默认关**(默认=与 v0.7.12 行为一致)+ feature_flags 白名单回滚开关 + lightMode 联动 + sleep 降级审计计数暴露(工作动态可展示"降级 N 条")+ 阶段二前端(/list heat 投影、HeatBadge 三档徽章、状态页热度分布卡、order=heat 页内排序,全部自门控);better-sidebar 修复(issue #88:软集成改内层动态子插件,无 bs 环境不再启动失败);685 测试全绿 |
212
214
  | **v0.7.18** | 生态第一步 + 查询收敛:better-sidebar 软集成(inject 声明 + optional peer `dsh-better-sidebar` + registerTab 复用四视图,未装安全跳过;窄容器 `@container` 适配)+ `/list?deposited=only` 沉淀视图(receipt_chain ∪ source=dream)+ 记忆库沉淀/已归档筛选 chip + 状态页仪表盘化(统计 + 查看全部跳转预置筛选)+ 抽屉归档记忆「恢复」;667 测试全绿 |
@@ -291,6 +293,8 @@ v0.3.0 起新增**记忆基因**层:从记忆里抽取**命名实体**、**带
291
293
  | **v0.7.18** | ✅ 完成 | 生态第一步 + 查询收敛 | better-sidebar 软集成(inject 声明 + optional peer `dsh-better-sidebar` + registerTab 复用四视图,未装安全跳过;窄容器 `@container` 适配)+ `/list?deposited=only` 沉淀视图(receipt_chain ∪ source=dream)+ 记忆库沉淀/已归档筛选 chip + 状态页仪表盘化(统计 + 查看全部跳转预置筛选)+ 抽屉归档记忆「恢复」;667 测试全绿 |
292
294
  | **v0.7.20** | ✅ 完成 | heat 回归 + 阶段二前端 + better-sidebar 修复 | heat 热度模型完整找回(issue #87,v0.7.10 移植:幂律衰减 + TYPE_DECAY + sleep 热联合双保护 + 实体热投影)+ 验收清单落地(heatEnabled 默认关 / feature_flags 31 键 / lightMode 联动 / sleep 降级审计暴露 / updated_at⊥last_accessed_at 契约)+ 阶段二前端(/list heat 投影、HeatBadge 三档、order=heat 页内排序)+ better-sidebar 修复(issue #88:内层动态子插件);685 测试全绿 |
293
295
  | **v0.7.21** | ✅ 完成 | effort 回退流式修复 | autoDream/sleep 的 catch 式 effort 回退在流式路径是死代码(dsh-llm rc.1 把 adapter 异常转成终态 error finish chunk 不再抛出)→ `streamText` 捕获 finish-chunk 失败原因(`describeStreamFailure` 归一化)+ `withEffortFallback` 增加 `getStreamError` 访问器(effort 被拒去重试)+ `runAuditedLlm` 支持 `spec.streamError`(audit 记真实原因);688 测试全绿 |
296
+ | **v0.7.23** | ✅ 完成 | 记忆沉淀「反复失败」根治 + 空体第二段 + skipInvalid splice 修复 | consolidation 合法空数组 `[]` no-op(CONSOLIDATION_PROMPT 允许无问题无需输出;此前 validateDecisions 硬判 non-empty → 整单 failed,模型无关、ChatGPT/Claude 同样踩中;修复:空数组显式短路 ok,不再触发隐式 keep 覆盖率误判);`dreamMaxTokens` 默认 8192→32768(思考模型推理烧光预算根治余量);skipInvalid splice 残留 bug(长度相等≠内容一致,被跳决策残留进 apply);712 测试全绿 |
297
+ | **v0.7.22** | ✅ 完成 | skipInvalid 宽容校验回归(issue #89)+ autoDream 节流 | 恢复 v0.6.9 的 skipInvalid 双轨结构(v0.7.11 重写丢失):`dreamSkipInvalid` 单条非法决策跳过 + 合法子集应用 + run 记 degraded,`allowCrossTypeMerge` 显式放宽跨类型合并;弱模型(qwen3.8-flash)决策合规抖动不再整单拒绝;新增 `dreamMinIntervalMinutes`(0-10080,默认 0=不限)最小触发间隔,失败/degraded run 也占用间隔;严格模式/sleep 路径行为不变;feature_flags 白名单 34 键;696 测试全绿 |
294
298
  | **v0.8.0** | 🚧 计划中(9 月末) | 图谱增强 | 兴趣漂移可视化 + scope 隔离(issue #17)+ 跨 workspace 记忆共享 |
295
299
 
296
300
  > 新能力一律做成**可开关的功能**(配置启用/关闭),默认保守开启、不破坏现有行为。`failure_memories` 表与 autoDream 决策引擎已为后续反思性成长铺好路。
@@ -361,7 +365,7 @@ dsh web
361
365
  | `dreamThresholdChars` | `5000` | 触发整理的总字符阈值 |
362
366
  | `dreamDelayMs` | `2000` | 整理异步延迟(去抖) |
363
367
  | `dreamProvider` / `dreamModel` | 空 | dream 的 LLM 路由覆盖(显式配置优先于 agent 默认模型;留空则回退到 agent 默认模型) |
364
- | `dreamMaxTokens` | `8192` | dream LLM 调用最大 token 数(上限 131072;大记忆量建议调大,见下方调优指南) |
368
+ | `dreamMaxTokens` | `32768` | dream LLM 调用最大 token 数(上限 131072;思考型模型的 reasoning 与正文共享该预算,正文为空时优先调大,见下方调优指南) |
365
369
  | `dreamReasoningEffort` | `none` | dream LLM 推理强度透传:`low` / `medium` / `high` / `none`(`none`=不传该字段,沿用模型默认;思考型模型(如 deepseek-v4-flash)想压低思考可设 `low`;被方舟拒绝该参数时 v0.7.16 起自动去掉重试一次) |
366
370
  | `apiToken` | 空 | 可选 API 鉴权 token;设置后写操作与密钥接口要求 `Authorization: Bearer <apiToken>` |
367
371
  | `embedProvider` | `openai` | 语义后端:`openai`(默认,兼容 v0.1)/ `local`(ONNX 离线)/ `ollama` |
@@ -525,7 +529,7 @@ src/
525
529
  ├── api.js # HTTP 路由(Web 面板数据通道)
526
530
  └── index.js # 插件接线
527
531
  lib/ # src 的同步分发产物(npm run sync;发布前由 root prepack 的 check-sync.js 校验一致性;唯一手写例外 lib/client.js——Web 面板 bundle,sync 不覆盖)
528
- test/ # 662 个 node:test 测试(审计与三轴线压测不变量;src↔lib 一致性由 scripts/check-sync.js 发布闸门校验)
532
+ test/ # 712 个 node:test 测试(审计与三轴线压测不变量;src↔lib 一致性由 scripts/check-sync.js 发布闸门校验)
529
533
  scripts/ # e2e-dsh.js 端到端演示 · stress-dsh.js 三轴线压测 · sync-lib.js 同步 · check-sync.js 发布闸门 · benchmark-recall.js 召回基准
530
534
  ```
531
535
 
@@ -534,7 +538,7 @@ scripts/ # e2e-dsh.js 端到端演示 · stress-dsh.js 三轴线压
534
538
  ```bash
535
539
  cd dsh-mneme
536
540
  npm install # 安装 peer 依赖(以 devDependencies 形式,用于本地测试)
537
- npm test # 运行 662 个测试
541
+ npm test # 运行 712 个测试
538
542
  npm run stress # 三轴线压测:长会话检索 / 冲突仲裁 / 多 Agent 并发(离线 mock LLM)
539
543
  npm run sync # 把 src/ 同步到 lib/(发布时由 prepack 钩子自动执行)
540
544
  ```
package/bin/cli.mjs CHANGED
File without changes
package/lib/config.js CHANGED
@@ -47,9 +47,14 @@ export const Config = z.object({
47
47
  dreamThresholdCount: z.natural().min(1).max(1000).default(10),
48
48
  dreamThresholdChars: z.natural().min(100).max(100000).default(5000),
49
49
  dreamDelayMs: z.natural().min(0).max(60000).default(2000),
50
+ // autoDream 触发最小间隔(分钟,0 = 不限制,Issue #89 请求 2):高频写入
51
+ // 场景下防止巩固调用(含失败重试)连发刷爆配额。间隔从每次实际开跑时刻
52
+ // 起算,失败/degraded 的 run 也占用间隔;间隔内的触发请求静默跳过,下一次
53
+ // 写入事件会重新评估。
54
+ dreamMinIntervalMinutes: z.natural().min(0).max(10080).default(0),
50
55
  dreamProvider: z.string(),
51
56
  dreamModel: z.string(),
52
- dreamMaxTokens: z.natural().min(256).max(131072).default(8192),
57
+ dreamMaxTokens: z.natural().min(256).max(131072).default(32768),
53
58
  // Pass-through reasoning effort for dream's LLM calls. 'none' (default)
54
59
  // omits the field so the provider's own default applies; low/medium/high
55
60
  // are forwarded verbatim. Useful to cap reasoning spend on thinking-type
@@ -74,6 +79,13 @@ export const Config = z.object({
74
79
  // → 整单拒绝,防止残缺输出被隐式 keep 洗白成 ok 后再被真实 apply。0-1,
75
80
  // 默认 0.5(至少显式覆盖一半 snapshot)。
76
81
  dreamMinExplicitCoverage: z.number().min(0).max(1).default(0.5),
82
+ // Issue #89:v0.6.9(Issue #26)的宽容路径回归。默认跳过单条非法决策
83
+ // (未知 id / 跨类型合并等)、应用合法子集、run 记 degraded;设 false 恢复
84
+ // 整单拒绝的严格模式。全局上限与覆盖率下限不受此开关影响、始终整单拒绝。
85
+ dreamSkipInvalid: z.boolean().default(true),
86
+ // 显式开启后放宽跨类型合并检查(类型边界由用户自行承担);配合
87
+ // dreamSkipInvalid 理解:关闭 skipInvalid 时跨类型 merge 直接整单拒绝。
88
+ allowCrossTypeMerge: z.boolean().default(false),
77
89
  // Rule version for dream adjudication: when this bumps, older dream_runs
78
90
  // degrade to historical evidence (their receipts no longer drive live
79
91
  // decisions). Default 0 = no versioning in use yet.
@@ -7,120 +7,153 @@ const EPISTEMIC_PRIORITY = { observation: 3, inferred: 2, subjective: 1 };
7
7
 
8
8
  /**
9
9
  * Validate a dream decision list against a snapshot of eligible memories.
10
- * @param decisions - LLM-produced decision list.
10
+ * @param decisions - LLM-produced decision list. In skipInvalid mode, invalid
11
+ * entries are spliced out of this array in place (the caller reuses the same
12
+ * reference downstream for apply/audit); implicit keeps are appended here too.
11
13
  * @param snapshot - Map<id, memory> of eligible (non-archived, non-summary) entries.
12
- * @returns {{ok: boolean, errors: string[]}}
14
+ * @returns {{ok: boolean, errors: string[], skipped?: Array<{index, action, ids, error}>}}
13
15
  */
14
16
  export function validateDecisions(decisions, snapshot, options = {}) {
15
17
  const errors = [];
18
+ // Issue #89 回归修复(v0.6.9 / Issue #26 的 skipInvalid 路径原样移植,该路径
19
+ // 在 v0.7.11 重写中丢失):skipInvalid 开启时,单条非法决策只跳过该条(记录
20
+ // 到 skipped、不 claim 任何 id),合法子集照常应用,调用方据此把 run 记为
21
+ // degraded。全局信号(update/create 上限、显式覆盖率下限)依旧整单拒绝——
22
+ // 刷爆上限或覆盖率不达标的输出是模型坏了,不是轻微 schema 漂移。
23
+ const skipped = [];
24
+ const survivors = [];
25
+ const skipInvalid = options.skipInvalid === true;
16
26
  const maxUpdatePerRun = options.maxUpdatePerRun ?? 2;
17
27
  const minAgeHours = options.minAgeHours ?? 24;
18
- if (!Array.isArray(decisions) || decisions.length === 0) {
19
- return { ok: false, errors: ["decision list must be a non-empty array"] };
28
+ if (!Array.isArray(decisions)) {
29
+ return { ok: false, errors: ["decision list must be an array"] };
30
+ }
31
+ // 空决策 = 模型完整评估后确认无需操作(CONSOLIDATION_PROMPT 明确允许"无问题的
32
+ // 条目无需输出")。合法 JSON [] 不是空体(那是无输出/截断),也不是"残缺输出"
33
+ // ——显式短路直接 ok,避免隐式 keep 的覆盖率检查把 0% 误判为模型坏了。与
34
+ // sleep 的空模式(skipped no-op)语义对齐:下游 applied=0、audit 记 ok。
35
+ if (decisions.length === 0) {
36
+ return { ok: true, errors: [], skipped: [] };
20
37
  }
21
38
  const claimed = new Set();
22
39
  for (const [index, d] of decisions.entries()) {
23
40
  const at = `decision[${index}]`;
41
+ // 单条校验错误先进 local:skipInvalid 模式下整条跳过,严格模式下才并入
42
+ // 全局 errors(沿用 v0.6.9 的双轨结构)。
43
+ const local = [];
44
+ const ids = d && d.action === "conflict" ? [d.winner, d.loser] : (d?.ids ?? []);
24
45
  if (!d || typeof d !== "object" || !ACTIONS.has(d.action)) {
25
- errors.push(`${at}: invalid action ${JSON.stringify(d?.action)}`);
26
- continue;
27
- }
28
- const ids = d.action === "conflict" ? [d.winner, d.loser] : (d.ids ?? []);
29
- if (d.action === "conflict") {
46
+ local.push(`${at}: invalid action ${JSON.stringify(d?.action)}`);
47
+ } else if (d.action === "conflict") {
30
48
  if (!d.winner || !d.loser || d.winner === d.loser) {
31
- errors.push(`${at}: conflict needs distinct winner and loser`);
32
- continue;
49
+ local.push(`${at}: conflict needs distinct winner and loser`);
33
50
  }
34
51
  } else if (d.action === "create") {
35
52
  // Mint a fresh memory (sleep pattern discovery). Claims no existing id,
36
53
  // so it skips the claiming loop below; evidence is optional provenance
37
54
  // (already filtered to real ids by the caller) and is stored in content.
38
55
  if (typeof d.title !== "string" || !d.title.trim()) {
39
- errors.push(`${at}: create needs non-empty title`);
40
- continue;
56
+ local.push(`${at}: create needs non-empty title`);
41
57
  }
42
58
  if (typeof d.content !== "string" || !d.content.trim()) {
43
- errors.push(`${at}: create needs non-empty content`);
44
- continue;
59
+ local.push(`${at}: create needs non-empty content`);
45
60
  }
46
61
  if (d.importance !== undefined && (!Number.isInteger(d.importance) || d.importance < 1 || d.importance > 5)) {
47
- errors.push(`${at}: create importance must be an integer 1-5 when provided`);
62
+ local.push(`${at}: create importance must be an integer 1-5 when provided`);
48
63
  }
49
64
  if (typeof d.type !== "string" || !d.type.trim()) {
50
- errors.push(`${at}: create needs non-empty type`);
65
+ local.push(`${at}: create needs non-empty type`);
51
66
  }
52
- continue;
53
67
  } else if (!Array.isArray(d.ids) || d.ids.length === 0) {
54
- errors.push(`${at}: ${d.action} needs non-empty ids`);
55
- continue;
68
+ local.push(`${at}: ${d.action} needs non-empty ids`);
56
69
  }
57
70
  // update-specific field validation runs BEFORE claiming ids, so a failing
58
71
  // update never pollutes the claimed set (which drives the "every id must
59
72
  // appear in a decision" check below).
60
- if (d.action === "update") {
73
+ if (local.length === 0 && d?.action === "update") {
61
74
  // 只能更新单条
62
75
  if (!Array.isArray(d.ids) || d.ids.length !== 1) {
63
- errors.push(`${at}: update must target exactly one id`);
64
- continue;
65
- }
66
- // 必须产生实际变化
67
- const mem = snapshot.get(d.ids[0]);
68
- const hasChange = (d.title !== undefined && d.title !== mem?.title)
69
- || (d.content !== undefined && d.content !== mem?.content)
70
- || (d.importance !== undefined && d.importance !== mem?.importance);
71
- if (!hasChange) {
72
- errors.push(`${at}: update must change at least one field`);
73
- continue;
74
- }
75
- // 不能更新 summary
76
- if (mem?.type === "summary") {
77
- errors.push(`${at}: cannot update summary via update action`);
78
- continue;
79
- }
80
- // 保护期:新建记忆不可立即被 update(可配置)
81
- const ageHours = (Date.now() - new Date(mem?.created_at).getTime()) / 3600000;
82
- if (ageHours < minAgeHours) {
83
- errors.push(`${at}: memory too young (< ${minAgeHours}h)`);
84
- continue;
76
+ local.push(`${at}: update must target exactly one id`);
77
+ } else {
78
+ // 必须产生实际变化
79
+ const mem = snapshot.get(d.ids[0]);
80
+ const hasChange = (d.title !== undefined && d.title !== mem?.title)
81
+ || (d.content !== undefined && d.content !== mem?.content)
82
+ || (d.importance !== undefined && d.importance !== mem?.importance);
83
+ if (!hasChange) {
84
+ local.push(`${at}: update must change at least one field`);
85
+ } else if (mem?.type === "summary") {
86
+ // 不能更新 summary
87
+ local.push(`${at}: cannot update summary via update action`);
88
+ } else {
89
+ // 保护期:新建记忆不可立即被 update(可配置)
90
+ const ageHours = (Date.now() - new Date(mem?.created_at).getTime()) / 3600000;
91
+ if (ageHours < minAgeHours) {
92
+ local.push(`${at}: memory too young (< ${minAgeHours}h)`);
93
+ }
94
+ }
85
95
  }
86
96
  }
87
- for (const id of ids) {
88
- const mem = snapshot.get(id);
89
- if (!mem) {
90
- errors.push(`${at}: unknown id ${JSON.stringify(id)}`);
91
- } else if (mem.archived || mem.type === "summary") {
92
- errors.push(`${at}: id ${JSON.stringify(id)} is archived or summary (not eligible)`);
97
+ if (local.length === 0 && d && d.action !== "create") {
98
+ // seen 捕获同一条决策内的重复 id;claimed 只含先前存活决策的 id
99
+ // (被跳过的决策不 claim,其目标留给其它合法决策/隐式 keep)。
100
+ const seen = new Set();
101
+ for (const id of ids) {
102
+ const mem = snapshot.get(id);
103
+ if (!mem) {
104
+ local.push(`${at}: unknown id ${JSON.stringify(id)}`);
105
+ } else if (mem.archived || mem.type === "summary") {
106
+ local.push(`${at}: id ${JSON.stringify(id)} is archived or summary (not eligible)`);
107
+ }
108
+ if (claimed.has(id) || seen.has(id)) {
109
+ local.push(`${at}: id ${JSON.stringify(id)} claimed by multiple decisions`);
110
+ }
111
+ seen.add(id);
93
112
  }
94
- if (claimed.has(id)) {
95
- errors.push(`${at}: id ${JSON.stringify(id)} claimed by multiple decisions`);
113
+ if (local.length === 0 && d.action === "merge") {
114
+ if (!d.keepSource || !d.ids.includes(d.keepSource)) {
115
+ local.push(`${at}: merge keepSource must be one of ids`);
116
+ }
117
+ if (typeof d.title !== "string" || !d.title.trim() || typeof d.content !== "string" || !d.content.trim()) {
118
+ local.push(`${at}: merge needs non-empty title and content`);
119
+ }
120
+ if (d.importance !== undefined && (!Number.isInteger(d.importance) || d.importance < 1 || d.importance > 5)) {
121
+ local.push(`${at}: merge importance must be an integer 1-5 when provided`);
122
+ }
123
+ // Merging across types would blur preference/project/decision boundaries
124
+ // in the injected context; the snapshot carries each entry's type.
125
+ // Issue #26 (P1):默认禁止跨类型合并。用户显式开启 allowCrossTypeMerge
126
+ // 后放宽该检查,类型边界由用户自行承担。
127
+ const mergeTypes = new Set(d.ids.map((id) => snapshot.get(id)?.type));
128
+ if (mergeTypes.size > 1 && options.allowCrossTypeMerge !== true) {
129
+ local.push(`${at}: merge ids span multiple types (${[...mergeTypes].join(", ")})`);
130
+ }
96
131
  }
97
- claimed.add(id);
98
132
  }
99
- if (d.action === "merge") {
100
- if (!d.keepSource || !d.ids.includes(d.keepSource)) {
101
- errors.push(`${at}: merge keepSource must be one of ids`);
102
- }
103
- if (typeof d.title !== "string" || !d.title.trim() || typeof d.content !== "string" || !d.content.trim()) {
104
- errors.push(`${at}: merge needs non-empty title and content`);
105
- }
106
- if (d.importance !== undefined && (!Number.isInteger(d.importance) || d.importance < 1 || d.importance > 5)) {
107
- errors.push(`${at}: merge importance must be an integer 1-5 when provided`);
108
- }
109
- // Merging across types would blur preference/project/decision boundaries
110
- // in the injected context; the snapshot carries each entry's type.
111
- const mergeTypes = new Set(d.ids.map((id) => snapshot.get(id)?.type));
112
- if (mergeTypes.size > 1) {
113
- errors.push(`${at}: merge ids span multiple types (${[...mergeTypes].join(", ")})`);
133
+ if (local.length > 0) {
134
+ if (skipInvalid) {
135
+ // 单条非法 跳过该决策,不 claim id(其目标记忆留给其它合法决策/隐式
136
+ // keep),并记录到 skipped 供调用方日志/审计。信息性跳过绝不写入全局
137
+ // errors,否则会误触发下方的整单拒绝。
138
+ skipped.push({ index, action: d?.action, ids, error: local.join("; ") });
139
+ } else {
140
+ errors.push(...local);
114
141
  }
142
+ continue;
143
+ }
144
+ if (d.action !== "create") {
145
+ for (const id of ids) claimed.add(id);
115
146
  }
147
+ survivors.push(d);
116
148
  }
117
- // Cap update churn: too many edits in one cycle signals a runaway model
118
- const updateCount = decisions.filter((d) => d.action === "update").length;
149
+ // Cap update churn: too many edits in one cycle signals a runaway model.
150
+ // 全局信号——skipInvalid 模式下依旧整单拒绝(见函数头注释)。
151
+ const updateCount = survivors.filter((d) => d.action === "update").length;
119
152
  if (updateCount > maxUpdatePerRun) {
120
153
  errors.push(`too many update decisions: ${updateCount} > ${maxUpdatePerRun}`);
121
154
  }
122
155
  // Cap pattern minting per run (sleepMaxPatternPerRun passes through here).
123
- const createCount = decisions.filter((d) => d.action === "create").length;
156
+ const createCount = survivors.filter((d) => d.action === "create").length;
124
157
  const maxCreatePerRun = options.maxCreatePerRun ?? 5;
125
158
  if (createCount > maxCreatePerRun) {
126
159
  errors.push(`too many create decisions: ${createCount} > ${maxCreatePerRun}`);
@@ -137,25 +170,31 @@ export function validateDecisions(decisions, snapshot, options = {}) {
137
170
  // snapshot(claimed.size / snapshot.size < dreamMinExplicitCoverage)时整单拒绝,
138
171
  // 而不是用 keep 把绝大部分 snapshot 全部"通过"。
139
172
  if (errors.length > 0) {
140
- return { ok: false, errors };
173
+ return { ok: false, errors, skipped };
141
174
  }
142
175
  const minCoverage = options.dreamMinExplicitCoverage ?? 0.5;
143
176
  if (options.dreamImplicitKeep !== false) {
144
177
  const coverage = snapshot.size > 0 ? claimed.size / snapshot.size : 1;
145
178
  if (coverage < minCoverage) {
146
179
  errors.push(`explicit decision coverage ${Math.round(coverage * 100)}% < minimum ${Math.round(minCoverage * 100)}%`);
147
- return { ok: false, errors };
180
+ return { ok: false, errors, skipped };
148
181
  }
149
182
  for (const id of snapshot.keys()) {
150
- if (!claimed.has(id)) decisions.push({ action: "keep", ids: [id] });
183
+ if (!claimed.has(id)) survivors.push({ action: "keep", ids: [id] });
151
184
  }
152
185
  } else {
153
186
  for (const id of snapshot.keys()) {
154
187
  if (!claimed.has(id)) errors.push(`memory ${JSON.stringify(id)} missing from decisions`);
155
188
  }
156
- if (errors.length > 0) return { ok: false, errors };
189
+ if (errors.length > 0) return { ok: false, errors, skipped };
157
190
  }
158
- return { ok: true, errors };
191
+ // 调用方下游(apply/audit)复用同一 decisions 引用:就地同步为 survivors——
192
+ // 在 skipInvalid 模式下去掉被跳过的非法决策;在隐式 keep 下追加补齐的 keep。
193
+ // 不能以 survivors.length !== decisions.length 作为是否 splice 的判据:
194
+ // 当"被跳过的非法决策数 == 隐式补齐的 keep 数"时长度回到相等但内容已变,
195
+ // 被跳过的决策会残留进 apply/audit。一律无条件 splice 最安全。
196
+ decisions.splice(0, decisions.length, ...survivors);
197
+ return { ok: true, errors, skipped };
159
198
  }
160
199
 
161
200
  /** Marker thrown when a decision target changed since the run snapshot. */
package/lib/dream.js CHANGED
@@ -468,12 +468,15 @@ async function maintainIndexAfterDream(decisions, service, semantic) {
468
468
  if (embedder.modelHash) vectorIndex.markModel?.(embedder.modelHash, embedder.dimension);
469
469
  }
470
470
 
471
- export function createDreamScheduler({ onRun, thresholdCount = 10, thresholdChars = 5000, delayMs = 2000, logger, semantic = null }) {
471
+ export function createDreamScheduler({ onRun, thresholdCount = 10, thresholdChars = 5000, delayMs = 2000, minIntervalMs = 0, logger, semantic = null }) {
472
472
  let pendingTimer = null;
473
473
  let running = false;
474
474
  let disposed = false;
475
475
  let baseline = { count: 0, chars: 0 };
476
476
  let inFlight = null;
477
+ // Issue #89(请求 2):上一次实际开跑时刻。失败/degraded 的 run 也占用
478
+ // 最小间隔——节流的目的正是防止失败调用连发;间隔内的触发静默跳过。
479
+ let lastRunAt = 0;
477
480
 
478
481
  function shouldTrigger(service) {
479
482
  const memories = service.all().filter((m) => !m.archived && m.type !== "summary");
@@ -486,11 +489,14 @@ export function createDreamScheduler({ onRun, thresholdCount = 10, thresholdChar
486
489
 
487
490
  function maybeSchedule(service) {
488
491
  if (disposed || running || pendingTimer) return false;
492
+ // Issue #89(请求 2):最小触发间隔闸门。
493
+ if (minIntervalMs > 0 && Date.now() - lastRunAt < minIntervalMs) return false;
489
494
  const { trigger, count, chars } = shouldTrigger(service);
490
495
  if (!trigger) return false;
491
496
  pendingTimer = setTimeout(() => {
492
497
  pendingTimer = null;
493
498
  running = true;
499
+ lastRunAt = Date.now();
494
500
  // Defer the onRun invocation so a synchronous throw cannot escape the
495
501
  // timer callback (which would crash the process) and skip the teardown.
496
502
  // Errors are logged, never swallowed silently. inFlight lets dispose()
@@ -704,18 +710,26 @@ export function createDreamScheduler({ onRun, thresholdCount = 10, thresholdChar
704
710
  logger?.warn?.(`dsh-mneme dream: no json array in llm output (raw length ${decisionText?.length ?? 0}; head: ${head})`);
705
711
  return finish({ ok: false, error: "no json array in llm output", summary: false });
706
712
  }
707
- const { ok, errors } = validateDecisions(decisions, snapshot, {
713
+ const { ok, errors, skipped } = validateDecisions(decisions, snapshot, {
708
714
  maxUpdatePerRun: config.reflectionUpdateMaxPerRun,
709
715
  minAgeHours: config.reflectionUpdateMinAgeHours,
710
716
  // v0.4.4 fix:显式透传,用户配 dreamImplicitKeep:false 时严格模式必须
711
717
  // 真正生效,dreamMinExplicitCoverage 决定隐式 keep 下的覆盖率下限。
712
718
  dreamImplicitKeep: config.dreamImplicitKeep,
713
- dreamMinExplicitCoverage: config.dreamMinExplicitCoverage
719
+ dreamMinExplicitCoverage: config.dreamMinExplicitCoverage,
720
+ // Issue #89:v0.6.9(Issue #26)的宽容路径在 v0.7.11 重写中丢失——单条
721
+ // 非法决策重新只跳过该条、合法子集照常应用(run 记为 degraded)。
722
+ skipInvalid: config.dreamSkipInvalid !== false,
723
+ allowCrossTypeMerge: config.allowCrossTypeMerge === true
714
724
  });
715
725
  if (!ok) {
716
726
  logger?.warn?.(`dsh-mneme dream: invalid decisions: ${errors.join("; ")}`);
717
727
  return finish({ ok: false, error: `invalid decisions: ${errors.length} errors`, summary: false });
718
728
  }
729
+ const skippedInvalid = skipped.length > 0;
730
+ if (skippedInvalid) {
731
+ logger?.warn?.(`dsh-mneme dream: ${skipped.length} invalid decision(s) skipped (run degrades): ${skipped.map((s) => s.error).join("; ")}`);
732
+ }
719
733
 
720
734
  // Capture pre-update snapshots so the audit records what each update changed.
721
735
  const updateSnapshots = {};
@@ -872,9 +886,11 @@ export function createDreamScheduler({ onRun, thresholdCount = 10, thresholdChar
872
886
  // run. ok:false keeps the scheduler from moving the baseline.
873
887
  // ok — either real changes landed, or a fresh summary was stored
874
888
  // (all-keep + summary is a substantive summary refresh).
875
- // degraded — real consolidation landed but the summary came back empty/
876
- // missing: the store was absorbed (ok for the baseline) but
877
- // the run did not produce its full output (marked, not faked).
889
+ // degraded — real consolidation landed but the run did not produce its
890
+ // full output: the summary came back empty/missing, or
891
+ // skipInvalid dropped individually-invalid decisions
892
+ // (Issue #89 — marked, not faked). The valid subset was
893
+ // absorbed (ok for the baseline).
878
894
  let status;
879
895
  let okResult;
880
896
  if (partial) {
@@ -884,7 +900,7 @@ export function createDreamScheduler({ onRun, thresholdCount = 10, thresholdChar
884
900
  status = summaryStored ? "ok" : "noop";
885
901
  okResult = summaryStored;
886
902
  } else {
887
- status = summaryStored ? "ok" : "degraded";
903
+ status = summaryStored && !skippedInvalid ? "ok" : "degraded";
888
904
  okResult = true;
889
905
  }
890
906
  return finish({
package/lib/index.js CHANGED
@@ -21,7 +21,10 @@ import { join } from "node:path";
21
21
  import { homedir } from "node:os";
22
22
 
23
23
  export const name = "dsh-mneme";
24
- export const inject = ["tools", "systemPrompt", "webServer", "llm", "agentDefaultModel", "commands"];
24
+ // webServer 为可选依赖(headless/无 UI 宿主兼容):从 inject 声明中去掉,cordis
25
+ // 不再等待它激活;运行时 ctx.webServer 为空则跳过 API 注册(下方 if 守卫),
26
+ // 记忆工具/注入/dream 全部照常工作。
27
+ export const inject = ["tools", "systemPrompt", "llm", "agentDefaultModel", "commands"];
25
28
  export { Config };
26
29
 
27
30
  // Arrow (not function declaration): cordis 4 treats any apply with a
@@ -283,6 +286,7 @@ export const apply = (ctx, config) => {
283
286
  thresholdCount: cfg.dreamThresholdCount,
284
287
  thresholdChars: cfg.dreamThresholdChars,
285
288
  delayMs: cfg.dreamDelayMs,
289
+ minIntervalMs: (cfg.dreamMinIntervalMinutes ?? 0) * 60000,
286
290
  logger: ctx.logger,
287
291
  semantic: { embedder, vectorIndex },
288
292
  onRun: () => (dream ? dream.runDream(ctx, service, cfg) : Promise.resolve({ ok: true, skipped: true }))
package/lib/settings.js CHANGED
@@ -58,6 +58,9 @@ const FEATURE_FLAG_BOOLEANS = [
58
58
  "bm25SearchEnabled",
59
59
  "conflictFreezeEnabled",
60
60
  "trustEpistemicWeighting",
61
+ // Issue #89:宽容校验回归(默认开)+ 跨类型合并显式放宽(默认关)。
62
+ "dreamSkipInvalid",
63
+ "allowCrossTypeMerge",
61
64
  // 嵌套对象开关:config.js 里是 memoryQualityFilter / llmAudit 对象的 enabled
62
65
  // 子字段。kv 按点号键平铺存("memoryQualityFilter.enabled": false),index.js
63
66
  // 合并时展开回嵌套对象,api.js 的 effective 从对象子字段取值。
@@ -70,7 +73,9 @@ const FEATURE_FLAG_INT_RANGES = {
70
73
  distillRateLimitRetries: [0, 10],
71
74
  distillRateLimitBaseDelayMs: [100, 60000],
72
75
  distillMaxChars: [1000, 200000],
73
- codingBoostFactor: [1, 5]
76
+ codingBoostFactor: [1, 5],
77
+ dreamMinIntervalMinutes: [0, 10080],
78
+ dreamMaxTokens: [256, 131072]
74
79
  };
75
80
  // 自由字符串开关(与 config.js 的 z.string() 同名同型):trim 后 ≤200 字符,
76
81
  // 空串合法(= 跟随主对话模型/默认路径,面板显示 placeholder)。
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@modusensus/dsh-mneme",
3
3
  "description": "Cross-session memory plugin for DeepSeek Harness with autoDream consolidation: SQLite store, Markdown mirrors, 7 model tools, automatic injection, session summarization, user profile/rules, custom slash commands, vector (semantic) search, and a Web GUI panel",
4
- "version": "0.7.21",
4
+ "version": "0.7.23",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",