dsh-layers-hippocampus 1.7.2 → 1.7.4

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.
@@ -1,6 +1,6 @@
1
1
  # @local/dsh-memory — 分层长期记忆 Host 插件
2
2
 
3
- > 版本:**1.7.2** | 全量用例:**555/555** | 运行时依赖:**零**
3
+ > 版本:**1.7.4** | 全量用例:**591/591** | 运行时依赖:**零**
4
4
 
5
5
  给 DSH 智能体一份"活得比会话久"的记忆:**追加式原始日志是唯一真相源**,标签索引、日记、活跃集合全部是可丢弃、可重建的读模型,语义摘要独立于原始日志生死。
6
6
 
@@ -681,7 +681,7 @@ window.__ModuleLoader__.load({
681
681
 
682
682
  运行器带**看门狗**:默认 **60s**(`MEM_TEST_TIMEOUT_MS` 可调)仍未退出,就打印**卡住时正在导入/执行的文件、最后完成的测试名与完成数、活动资源、尚未触发的定时器**,然后 `process.exit(1)`。它不会用 `process.exit(0)` 掩盖超时——挂起即失败。`MEM_TEST_TRACE=1` 可看文件级进度,`MEM_TEST_ONLY=<子串>` 只跑一组。
683
683
 
684
- 555 个用例(87 个文件)覆盖:
684
+ 591 个用例(92 个文件)覆盖:
685
685
 
686
686
  - 索引与标签:重建 digest 一致、行号漂移防护(eventId 不变、行号变)、同义合并、活跃集 cap 挤出、规则变更不改清单、空活跃集降级、top-k 有界有序去重。
687
687
  - 衰减与删除:30 天半衰期、reinforce 移动锚点(不存字段)、仅文本粗筛、标签过滤、维护代切换且旧代可读、boot 检查、压缩不丢记录、并发维护串行化、四阶段删除、archive 可回滚 vs purge 不可、strict 巩固暂停与恢复、任务重放幂等、错误 id 零变更。
package/index.js CHANGED
@@ -45,10 +45,21 @@ import { isLowValley, nextLowValleyStart, windowInfo } from './src/priceWindow.j
45
45
  import { DreamTimer } from './src/dreamTimer.js';
46
46
  import { probeCompression, resolveEngine } from './src/compression.js';
47
47
  import { LIVE_COMPACT_DEFAULTS, liveCompactSession } from './src/context/liveCompact.js';
48
+
49
+ // v1.7.4: how long a host-measured pressure reading may be reused while deciding
50
+ // whether a handoff marker still tells the truth. Requests are seconds apart, so five
51
+ // minutes is generous — and a stale reading is never used to CLEAR something.
52
+ const HANDOFF_PRESSURE_FRESH_MS = 5 * 60 * 1000;
53
+ // v1.7.3 (module 1): physical context pruning. No host compaction, no model call —
54
+ // the turn is REPLACED with a pointer that keeps the event id.
55
+ import { smartPruneSession, FOLD_MIN_CHARS, FOLD_MAX_NODES } from './src/context/smartPrune.js';
48
56
  import { snippet } from './src/util.js';
49
57
  import { dimensionOf, groupByDimension, stripPhysiology, containsPhysiology } from './src/semantic/dimensions.js';
50
58
  import { isSecretRecord } from './src/privacy.js';
51
59
  import { MEMORY_API, registerMemoryRoutes } from './src/webRoutes.js';
60
+ // v1.7.4: bounded graph projection + the recent activity ring the panel flashes.
61
+ import { trimGraph } from './src/graph.js';
62
+ import { ActivityStore } from './src/activity.js';
52
63
 
53
64
  export const name = 'memory';
54
65
  export const inject = ['tools', 'systemPrompt'];
@@ -68,7 +79,7 @@ export { resolveConfig, DEFAULT_CONFIG };
68
79
  * of letting a raw 404 reach the user.
69
80
  */
70
81
  export const CAPABILITIES = Object.freeze({
71
- version: '1.7.2',
82
+ version: '1.7.4',
72
83
  spaces: true,
73
84
  memories: true,
74
85
  transferConsent: true,
@@ -251,6 +262,7 @@ export function createRuntime({ ctx = null, config, options, clock, raw = null,
251
262
  policy: options.policy,
252
263
  config: owner.config,
253
264
  spaceId: path.basename(childDir),
265
+ activity: activityFor(path.basename(childDir)),
254
266
  ...multiSpaceExtras(),
255
267
  }),
256
268
  }),
@@ -260,8 +272,31 @@ export function createRuntime({ ctx = null, config, options, clock, raw = null,
260
272
  dedupe: orchestrator.dedupe ?? null,
261
273
  };
262
274
  };
275
+ // v1.7.4 activity ring: ONE store per physical space, created lazily. The file is
276
+ // opt-in (`ui.graphActivityPersist`) and lives inside that space's OWN state/
277
+ // directory, so two spaces never share a ring. `runtime` does not exist yet while
278
+ // the first Memory is built, hence the small live-config reference. Tags only —
279
+ // ActivityStore strips sensitive:/privacy: and caps both arrays.
280
+ let runtimeRef = null;
281
+ const activityStores = new Map();
282
+ const activityConfig = () => runtimeRef?.config ?? config;
283
+ const activityFilePath = (spaceId) => {
284
+ if (activityConfig().ui?.graphActivityPersist !== true) return null;
285
+ const root = activityConfig().dataDir;
286
+ const dir = !spaceId || spaceId === 'default' ? root : path.join(root, 'spaces', String(spaceId));
287
+ return path.join(dir, 'state', 'activity.json');
288
+ };
289
+ const activityFor = (spaceId) => {
290
+ const key = spaceId === null || spaceId === undefined || spaceId === '' ? 'default' : String(spaceId);
291
+ let store = activityStores.get(key);
292
+ if (!store) {
293
+ store = new ActivityStore({ limit: 64, file: activityFilePath(key === 'default' ? null : key), clock });
294
+ activityStores.set(key, store);
295
+ }
296
+ return store;
297
+ };
263
298
  // `let` (not const): a failed bootstrap can be retried by rebuilding the facade.
264
- let memory = new Memory({ dataDir: config.dataDir, policy: options.policy, config: options.config, clock, ...multiSpaceExtras() });
299
+ let memory = new Memory({ dataDir: config.dataDir, policy: options.policy, config: options.config, clock, activity: activityFor(null), ...multiSpaceExtras() });
265
300
  // v1.5.6: engine warnings (currently MEM_E_AUTO_TAG_MISS) go to the Host log.
266
301
  memory.setWarnHook?.((code, message, details) => {
267
302
  ctx?.logger?.warn?.(`hippocampus: ${code} ${message}`, details);
@@ -271,6 +306,11 @@ export function createRuntime({ ctx = null, config, options, clock, raw = null,
271
306
  const runtime = {
272
307
  config,
273
308
  memory,
309
+ // v1.7.4: recent recall/capture hints. One ring per physical space; `activity`
310
+ // is the default-space store handed to the Memory facade above.
311
+ activity: activityFor(null),
312
+ activityStores,
313
+ activityFor,
274
314
  logger: ctx?.logger ?? null,
275
315
  /** Raw (unresolved) config: re-merging a patch must not bake in defaults. */
276
316
  rawConfig: cloneRaw(raw ?? config),
@@ -300,6 +340,15 @@ export function createRuntime({ ctx = null, config, options, clock, raw = null,
300
340
  /** Set by apply(): persists config patches through configEditor. */
301
341
  persist: null,
302
342
  };
343
+ runtimeRef = runtime;
344
+
345
+ /** Rebind the rings to the current dataDir / persistence flag (cosmetic state). */
346
+ runtime.resetActivityStores = () => {
347
+ activityStores.clear();
348
+ runtime.activity = activityFor(null);
349
+ runtime.activityStores = activityStores;
350
+ if (runtime.memory) runtime.memory.activity = runtime.activity;
351
+ };
303
352
 
304
353
  const migrationRunner = new MigrationRunner({
305
354
  stateFile: path.join(config.dataDir, 'state', 'migration.json'),
@@ -952,8 +1001,23 @@ export function createRuntime({ ctx = null, config, options, clock, raw = null,
952
1001
  // current preset is readable here even when no change event ever fired.
953
1002
  runtime.syncAgentPreset();
954
1003
  if (runtime.phase === 'ready') {
955
- const handoff = memory.handoffState();
956
1004
  const usage = memory.sessionUsage();
1005
+ // v1.7.4: the marker must expire with the pressure that wrote it. This used to be
1006
+ // checked only on the fail-fast path, so "[交接标记] 上下文已接近原生窗口上限" was
1007
+ // injected on every turn even at 10% usage, and the model handed off early.
1008
+ let handoff = memory.handoffState();
1009
+ try {
1010
+ // Only a FRESH host measurement may expire the marker (see guardRequest); the
1011
+ // local usage counter is empty in the real host, so it must not be trusted here.
1012
+ const pressure = runtime.lastPressure;
1013
+ const fresh =
1014
+ pressure && Number.isFinite(pressure.ratio) && memory.clock.now() - pressure.at <= HANDOFF_PRESSURE_FRESH_MS;
1015
+ if (handoff.active && fresh) {
1016
+ handoff = memory.maintainHandoffMarker({ ratio: pressure.ratio, usage })?.marker ?? handoff;
1017
+ }
1018
+ } catch {
1019
+ /* prompt assembly must never fail because of marker upkeep */
1020
+ }
957
1021
  const sessionId = usage?.sessionId ?? 'anonymous';
958
1022
  // SessionStart OR rollover resets the dedup pool: the new session may receive
959
1023
  // the same handoff summary / tags that the old one already saw.
@@ -1168,11 +1232,81 @@ export function createRuntime({ ctx = null, config, options, clock, raw = null,
1168
1232
  }
1169
1233
  hostProbes.updatedAt = memory.clock.now();
1170
1234
 
1171
- // ---- 3. fail fast on a request that CANNOT fit -------------------------
1172
- const state = memory.context.nativeState({
1235
+ // ---- 2.5 physical pruning (v1.7.3, module 1) --------------------------
1236
+ // At the configured share of the REAL window we fold the oldest verbose turns
1237
+ // into pointers BEFORE measuring again. This is what makes the plugin usable
1238
+ // without the host's compaction engine: the surface shrinks, the log does not.
1239
+ const pruneConfig = runtime.config?.context?.smartPrune ?? {};
1240
+ let state = memory.context.nativeState({
1173
1241
  usedTokens: hostProbes.usedTokens ?? undefined,
1174
1242
  reservedTokens: hostProbes.reservedTokens ?? undefined,
1175
1243
  });
1244
+ const pruneThreshold = Number.isFinite(pruneConfig.threshold) ? pruneConfig.threshold : 0.85;
1245
+ if (pruneConfig.enabled !== false && session && state.projectedRatio >= pruneThreshold) {
1246
+ try {
1247
+ runtime.lastSmartPrune = {
1248
+ source: 'hippocampus',
1249
+ at: memory.clock.now(),
1250
+ threshold: pruneThreshold,
1251
+ ratioBefore: state.projectedRatio,
1252
+ ...smartPruneSession(session, {
1253
+ keepRecentTurns: pruneConfig.keepRecentTurns ?? 3,
1254
+ minChars: pruneConfig.minChars ?? FOLD_MIN_CHARS,
1255
+ maxNodes: pruneConfig.maxNodes ?? FOLD_MAX_NODES,
1256
+ logger: runtime.logger,
1257
+ // The pointer must name something a reader can actually resolve. The raw
1258
+ // store keys its turns deterministically (`turn_<seq>_<role>`), so the fold
1259
+ // points at the raw turn instead of an opaque number.
1260
+ describe: ({ seq, event }) => {
1261
+ let role = null;
1262
+ try {
1263
+ role = turnFromSessionEvent(event)?.role ?? null;
1264
+ } catch {
1265
+ role = null;
1266
+ }
1267
+ return {
1268
+ turnId: role ? `turn_${seq}_${role}` : `turn_${seq}`,
1269
+ tool: event?.type === 'tool/result' ? (event?.data?.name ?? null) : null,
1270
+ };
1271
+ },
1272
+ }),
1273
+ };
1274
+ if (runtime.lastSmartPrune.folded > 0) {
1275
+ // The surface changed, so the measurement must be taken again — and the
1276
+ // probe is refreshed too, because the host may not have re-measured yet.
1277
+ try {
1278
+ const after = typeof tokenMeter?.contextPressure === 'function' ? tokenMeter.contextPressure(session) : null;
1279
+ const values = [after?.pressureTokens, after?.projectedTokens].filter((value) => Number.isFinite(value));
1280
+ if (values.length > 0) hostProbes.usedTokens = Math.max(...values);
1281
+ } catch {
1282
+ /* a stale probe only costs one extra fold attempt */
1283
+ }
1284
+ state = memory.context.nativeState({
1285
+ usedTokens: hostProbes.usedTokens ?? undefined,
1286
+ reservedTokens: hostProbes.reservedTokens ?? undefined,
1287
+ });
1288
+ runtime.lastSmartPrune.ratioAfter = state.projectedRatio;
1289
+ }
1290
+ } catch (error) {
1291
+ runtime.logger?.warn?.(`hippocampus: smart prune failed: ${asMemoryError(error).code}`);
1292
+ }
1293
+ }
1294
+
1295
+ // v1.7.4: marker upkeep on EVERY request, not only on the fail-fast path below —
1296
+ // that asymmetry is exactly why a marker outlived the pressure that created it.
1297
+ // This is the ONE place that owns a host-true measurement, so it is also what the
1298
+ // next prompt assembly reuses (runtime.lastPressure).
1299
+ try {
1300
+ runtime.lastPressure = { ratio: state.projectedRatio, tokens: state.tokens, at: memory.clock.now() };
1301
+ runtime.lastHandoffMaintenance = memory.maintainHandoffMarker({
1302
+ ratio: state.projectedRatio,
1303
+ usage: { sessionId: session?.id ?? null, tokens: state.tokens },
1304
+ });
1305
+ } catch {
1306
+ /* advisory only: never block a request on marker upkeep */
1307
+ }
1308
+
1309
+ // ---- 3. fail fast on a request that CANNOT fit -------------------------
1176
1310
  if (!state.hardExceeded) return state;
1177
1311
  // Try to hand off first: even though it cannot shrink THIS request, it leaves a
1178
1312
  // distilled tail for the next one instead of repeating the same failure.
@@ -1197,6 +1331,7 @@ export function createRuntime({ ctx = null, config, options, clock, raw = null,
1197
1331
  ratio: state.ratio,
1198
1332
  handoff: handoff?.handoff?.summaryEventId ?? null,
1199
1333
  liveCompact: runtime.lastLiveCompact ?? null,
1334
+ smartPrune: runtime.lastSmartPrune ?? null,
1200
1335
  },
1201
1336
  );
1202
1337
  };
@@ -1287,6 +1422,36 @@ export function createRuntime({ ctx = null, config, options, clock, raw = null,
1287
1422
  * Reads during startup. A migration has a source of truth that is still valid:
1288
1423
  * the legacy directory. Serving from it beats both an empty answer and a stall.
1289
1424
  */
1425
+ /**
1426
+ * v1.7.4: the panel's glow feed, recorded at the RUNTIME boundary on purpose.
1427
+ *
1428
+ * `memory.recall()` does not necessarily run on this facade: with multi-space it
1429
+ * routes through `spaces.run()`, and a cross-space recall fans out to per-space
1430
+ * `Memory` instances. A hook inside `Memory#_recallLocal` therefore only fires for
1431
+ * whichever instance happened to serve the call — in a two-space profile the
1432
+ * default ring stayed empty and the graph never lit up. Recording here means one
1433
+ * place, one store per answering space, and the same payload shape for every path.
1434
+ * Tags only: ActivityStore strips `sensitive:` / `privacy:` before they can reach
1435
+ * the panel, and a broken ring must never affect the recall result itself.
1436
+ */
1437
+ const noteRecallActivity = (result, spaceId = null) => {
1438
+ try {
1439
+ const tags = [];
1440
+ const eventIds = [];
1441
+ for (const hit of result?.hits ?? []) {
1442
+ for (const tag of hit?.tags ?? []) {
1443
+ const value = typeof tag === 'string' ? tag : tag?.tag;
1444
+ if (typeof value === 'string' && value) tags.push(value);
1445
+ }
1446
+ if (typeof hit?.eventId === 'string' && hit.eventId) eventIds.push(hit.eventId);
1447
+ }
1448
+ if (tags.length === 0 && eventIds.length === 0) return;
1449
+ runtime.activityFor(spaceId ?? result?.spaceId ?? null).record({ kind: 'recall', tags, eventIds, source: 'recall' });
1450
+ } catch {
1451
+ // A hint is cosmetic; recall itself must never fail because of it.
1452
+ }
1453
+ };
1454
+
1290
1455
  runtime.recall = async (query) => {
1291
1456
  if (runtime.phase === 'ready') {
1292
1457
  runtime.recordToolCall();
@@ -1301,9 +1466,13 @@ export function createRuntime({ ctx = null, config, options, clock, raw = null,
1301
1466
  runtime.multiSpaceAvailable?.() &&
1302
1467
  memory.spaces.status().ids.length > 1
1303
1468
  ) {
1304
- return memory.recallAcrossSpaces(query ?? {});
1469
+ const result = await memory.recallAcrossSpaces(query ?? {});
1470
+ noteRecallActivity(result, null);
1471
+ return result;
1305
1472
  }
1306
- return memory.recall(query);
1473
+ const result = await memory.recall(query);
1474
+ noteRecallActivity(result, query && typeof query === 'object' ? query.targetSpaceId ?? null : null);
1475
+ return result;
1307
1476
  }
1308
1477
  if (runtime.legacy) {
1309
1478
  runtime.recordToolCall();
@@ -1507,15 +1676,18 @@ export function createRuntime({ ctx = null, config, options, clock, raw = null,
1507
1676
  return {
1508
1677
  ok: false,
1509
1678
  ...view,
1510
- graph: { available: false, nodes: [], edges: [], totalEdges: 0, limit: runtime.config.graphMaxEdges },
1679
+ graph: { available: false, nodes: [], edges: [], totalEdges: 0, limit: runtime.config.graphMaxEdges, maxNodes: runtime.config.graphMaxNodes },
1511
1680
  tagTree: { available: false, ghosts: [] },
1512
1681
  };
1513
1682
  }
1514
1683
  try {
1515
- const { spaceId: selected, graph, tagTree } = await memory.graphForSpace({
1684
+ const { spaceId: selected, graph: rawGraph, tagTree } = await memory.graphForSpace({
1516
1685
  targetSpaceId: spaceId ?? undefined,
1517
1686
  limit: runtime.config.graphMaxEdges,
1518
1687
  });
1688
+ // v1.7.4: the cache keeps its full projection; the ROUTE gets a bounded copy so
1689
+ // one huge graph can never stall the panel. trimGraph is pure.
1690
+ const graph = trimGraph(rawGraph, { maxNodes: runtime.config.graphMaxNodes, maxEdges: runtime.config.graphMaxEdges });
1519
1691
  return { ok: true, phase: runtime.phase, state: runtime.phase, spaceId: selected, graph, tagTree };
1520
1692
  } catch (error) {
1521
1693
  return {
@@ -1523,12 +1695,23 @@ export function createRuntime({ ctx = null, config, options, clock, raw = null,
1523
1695
  ...view,
1524
1696
  spaceId,
1525
1697
  error: asMemoryError(error).toJSON(),
1526
- graph: { available: false, nodes: [], edges: [], limit: runtime.config.graphMaxEdges },
1698
+ graph: { available: false, nodes: [], edges: [], limit: runtime.config.graphMaxEdges, maxNodes: runtime.config.graphMaxNodes },
1527
1699
  tagTree: { available: false, ghosts: [] },
1528
1700
  };
1529
1701
  }
1530
1702
  };
1531
1703
 
1704
+ /**
1705
+ * v1.7.4 activity route payload: the default or named space's recent ring.
1706
+ * `since` is an exclusive seq cursor, so the panel polls for just the new flips.
1707
+ * Read-only and store-independent: a hint never blocks on bootstrap.
1708
+ */
1709
+ runtime.activityPayload = ({ spaceId = null, since = 0, limit = 64 } = {}) => {
1710
+ const store = runtime.activityFor(spaceId);
1711
+ const recent = store.recent({ since, limit });
1712
+ return { ok: true, spaceId: spaceId ?? 'default', items: recent.items, cursor: recent.cursor, now: recent.now };
1713
+ };
1714
+
1532
1715
  /** Global SpaceSelector data source (root router: every physical space). */
1533
1716
  runtime.spaceList = () =>
1534
1717
  runtime.phase === 'ready'
@@ -1774,7 +1957,13 @@ export function createRuntime({ ctx = null, config, options, clock, raw = null,
1774
1957
  * needs a restart.
1775
1958
  */
1776
1959
  runtime.applyConfig = (next) => {
1960
+ const previous = runtime.config;
1777
1961
  runtime.config = next;
1962
+ // v1.7.4: the rings' file binding depends on dataDir + ui.graphActivityPersist.
1963
+ // Rebinding is enough; the hint history itself is disposable.
1964
+ const rebindActivity =
1965
+ (previous.ui?.graphActivityPersist === true) !== (next.ui?.graphActivityPersist === true) ||
1966
+ path.resolve(previous.dataDir) !== path.resolve(next.dataDir);
1778
1967
  // Retrieval reads `memory.policy` on every call. The resolved policy is
1779
1968
  // deep-frozen, so replace it with a shallow copy carrying the new topK
1780
1969
  // instead of mutating a frozen object (which throws in strict mode).
@@ -1791,6 +1980,7 @@ export function createRuntime({ ctx = null, config, options, clock, raw = null,
1791
1980
  // facade (and every open child space) instead of waiting for a reload: the
1792
1981
  // settings page promises "保存后立即生效".
1793
1982
  if (liveMemory) liveMemory.applyLiveConfig(toMemoryOptions(next).config);
1983
+ if (rebindActivity) runtime.resetActivityStores();
1794
1984
  emit({ type: 'config', config: uiConfig(next) });
1795
1985
  return next;
1796
1986
  };
@@ -1877,10 +2067,13 @@ export function createRuntime({ ctx = null, config, options, clock, raw = null,
1877
2067
  } catch {
1878
2068
  /* the old store is read-mostly */
1879
2069
  }
1880
- memory = new Memory({ dataDir: next.dataDir, policy: nextOptions.policy, config: nextOptions.config, clock, ...multiSpaceExtras() });
2070
+ memory = new Memory({ dataDir: next.dataDir, policy: nextOptions.policy, config: nextOptions.config, clock, activity: activityFor(null), ...multiSpaceExtras() });
1881
2071
  runtime.memory = memory;
1882
2072
  runtime.config = next;
1883
2073
  runtime.rawConfig = merged;
2074
+ // The rings are bound to physical dirs; after the swap they must follow the new
2075
+ // dataDir (hints are cosmetic, so dropping the old in-memory ring is fine).
2076
+ runtime.resetActivityStores();
1884
2077
  await memory.init();
1885
2078
  if (runtime.scheduler) memory.attachScheduler(runtime.scheduler);
1886
2079
  // The runner still points at the OLD state file; rebase it on the new dataDir
@@ -1946,7 +2139,7 @@ export function createRuntime({ ctx = null, config, options, clock, raw = null,
1946
2139
  } catch {
1947
2140
  /* a half-open store must not block the rebuild */
1948
2141
  }
1949
- memory = new Memory({ dataDir: config.dataDir, policy: options.policy, config: options.config, clock, ...multiSpaceExtras() });
2142
+ memory = new Memory({ dataDir: config.dataDir, policy: options.policy, config: options.config, clock, activity: runtime.activity, ...multiSpaceExtras() });
1950
2143
  runtime.memory = memory;
1951
2144
  memory.setHandoffPresetProvider?.(() => runtime.agentPreset);
1952
2145
  emit({ type: 'retry', phase: runtime.phase });
@@ -2097,6 +2290,9 @@ export function createRuntime({ ctx = null, config, options, clock, raw = null,
2097
2290
  // "a handoff summary exists and this conversation has not seen it yet"
2098
2291
  // (inside noteColdStart). A delegated sub-agent also lands here — it merely
2099
2292
  // arms its OWN entry, and the user's conversation arms its own on first turn.
2293
+ // v1.7.4: a new conversation starts with no pressure history; reusing the old
2294
+ // reading would let it clear a marker that belongs to a different conversation.
2295
+ runtime.lastPressure = null;
2100
2296
  runtime.noteColdStart({ agentId: payload?.agent?.id ?? null, source: 'agent-created' });
2101
2297
  // Track the mode this session actually runs in (a session may be created with
2102
2298
  // a preset without emitting a change event).
@@ -2251,6 +2447,9 @@ function uiConfig(config) {
2251
2447
  dreamIdleMinutes: config.dreamIdleMinutes,
2252
2448
  enableReflection: config.enableReflection,
2253
2449
  graphMaxEdges: config.graphMaxEdges,
2450
+ graphMaxNodes: config.graphMaxNodes,
2451
+ // v1.7.4 presentation knobs (glow / canvas tint) + optional activity persistence.
2452
+ ui: config.ui,
2254
2453
  storageBudgetMb: config.storageBudgetMb,
2255
2454
  maxRecallTopK: config.maxRecallTopK,
2256
2455
  retrieval: { topK: config.retrieval.topK },
@@ -2660,6 +2859,13 @@ export async function apply(ctx, rawConfig = {}) {
2660
2859
  max_tokens: { type: 'number', description: 'deep_raw only: result token budget, default from raw.maxResultTokens' },
2661
2860
  hash: { type: 'string', description: 'deep_raw only: restore one raw turn verbatim by sha256 (from [Slimmed] hash_…)' },
2662
2861
  regex: { type: 'boolean', description: 'deep_raw only: treat text as a restricted regular expression' },
2862
+ allow_sensitive: {
2863
+ type: 'boolean',
2864
+ description:
2865
+ 'Include records tagged sensitive:* (api_key / credential / pii). Omitted by default: they are ' +
2866
+ 'PHYSICALLY excluded and only a count appears in notes (sensitive-withheld:N). ' +
2867
+ 'Only pass this when the user has explicitly asked you to handle the secret.',
2868
+ },
2663
2869
  include_secret: {
2664
2870
  type: 'boolean',
2665
2871
  description:
@@ -2673,7 +2879,10 @@ export async function apply(ctx, rawConfig = {}) {
2673
2879
  if (args.mode === 'deep_raw') {
2674
2880
  if (runtime.phase !== 'ready') return errorJson(runtime.notReady('deep_raw'));
2675
2881
  if (typeof args.hash === 'string' && args.hash.trim()) {
2676
- const restored = await runtime.memory.deepRaw({ hash: args.hash.trim() });
2882
+ const restored = await runtime.memory.deepRaw({
2883
+ hash: args.hash.trim(),
2884
+ allowSensitive: args.allow_sensitive === true,
2885
+ });
2677
2886
  return JSON.stringify({ ok: true, ...restored });
2678
2887
  }
2679
2888
  // A missing window is NOT pre-validated here: the engine decides. A
@@ -2687,6 +2896,7 @@ export async function apply(ctx, rawConfig = {}) {
2687
2896
  limit,
2688
2897
  regex: args.regex === true,
2689
2898
  maxTokens: args.max_tokens,
2899
+ allowSensitive: args.allow_sensitive === true,
2690
2900
  });
2691
2901
  runtime.touch();
2692
2902
  runtime.recordToolCall({ landed: (result.hits ?? []).length > 0 });
@@ -2698,6 +2908,7 @@ export async function apply(ctx, rawConfig = {}) {
2698
2908
  topK: Math.min(args.top_k ?? config.retrieval.topK, config.maxRecallTopK),
2699
2909
  targetSpaceId: args.target_space_id,
2700
2910
  includeSecret: args.include_secret === true,
2911
+ allowSensitive: args.allow_sensitive === true,
2701
2912
  });
2702
2913
  runtime.recordToolCall({
2703
2914
  landed: (result.hits ?? []).length > 0 || (result.ghostHints ?? []).length > 0,
package/package.json CHANGED
@@ -1,75 +1,75 @@
1
- {
2
- "name": "dsh-layers-hippocampus",
3
- "version": "1.7.2",
4
- "private": false,
5
- "description": "Layered long-term memory for DeepSeek Harness: append-only event log, rebuildable tag index, day diaries, independent semantic layer, L2.5 trend quarantine, offline knowledge graph and a Web UI panel.",
6
- "type": "module",
7
- "main": "index.js",
8
- "license": "MIT",
9
- "author": "382quaii",
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/382quaii/dsh-Layers-Hippocampus.git"
13
- },
14
- "homepage": "https://github.com/382quaii/dsh-Layers-Hippocampus#readme",
15
- "bugs": {
16
- "url": "https://github.com/382quaii/dsh-Layers-Hippocampus/issues"
17
- },
18
- "keywords": [
19
- "deepseek",
20
- "harness",
21
- "dsh",
22
- "dsh-plugin",
23
- "memory",
24
- "long-term-memory",
25
- "knowledge-graph",
26
- "ai-agent"
27
- ],
28
- "engines": {
29
- "node": ">=22"
30
- },
31
- "publishConfig": {
32
- "registry": "https://registry.npmjs.org/",
33
- "access": "public"
34
- },
35
- "exports": {
36
- ".": "./index.js",
37
- "./package.json": "./package.json",
38
- "./client": "./ui/client.js",
39
- "./cordis.patch.yml": "./cordis.patch.yml",
40
- "./locale/*.json": "./locale/*.json",
41
- "./icon": "./icon.svg",
42
- "./src/*": "./src/*"
43
- },
44
- "files": [
45
- "index.js",
46
- "src/**/*.js",
47
- "ui/**/*.js",
48
- "cordis.patch.yml",
49
- "locale/*.json",
50
- "icon.svg",
51
- "screenshots.json",
52
- "assets/*.png",
53
- "README.md",
54
- "LICENSE",
55
- "CHANGELOG.md",
56
- "docs/ARCHITECTURE.zh.md",
57
- "docs/PUBLISHING.md",
58
- "market/**/*.yml",
59
- "market/*.md"
60
- ],
61
- "scripts": {
62
- "test": "node test/run.mjs",
63
- "bench": "node scripts/bench-protocol.mjs",
64
- "repair-handoff": "node scripts/repair-handoff.mjs",
65
- "check": "node --check index.js && node --check ui/client.js && node test/run.mjs"
66
- },
67
- "dsh": {
68
- "bundle": {
69
- "patch": "./cordis.patch.yml"
70
- },
71
- "client": {
72
- "platform": "web"
73
- }
74
- }
75
- }
1
+ {
2
+ "name": "dsh-layers-hippocampus",
3
+ "version": "1.7.4",
4
+ "private": false,
5
+ "description": "Layered long-term memory for DeepSeek Harness: append-only event log, rebuildable tag index, day diaries, independent semantic layer, L2.5 trend quarantine, offline knowledge graph and a Web UI panel.",
6
+ "type": "module",
7
+ "main": "index.js",
8
+ "license": "MIT",
9
+ "author": "382quaii",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/382quaii/dsh-Layers-Hippocampus.git"
13
+ },
14
+ "homepage": "https://github.com/382quaii/dsh-Layers-Hippocampus#readme",
15
+ "bugs": {
16
+ "url": "https://github.com/382quaii/dsh-Layers-Hippocampus/issues"
17
+ },
18
+ "keywords": [
19
+ "deepseek",
20
+ "harness",
21
+ "dsh",
22
+ "dsh-plugin",
23
+ "memory",
24
+ "long-term-memory",
25
+ "knowledge-graph",
26
+ "ai-agent"
27
+ ],
28
+ "engines": {
29
+ "node": ">=22"
30
+ },
31
+ "publishConfig": {
32
+ "registry": "https://registry.npmjs.org/",
33
+ "access": "public"
34
+ },
35
+ "exports": {
36
+ ".": "./index.js",
37
+ "./package.json": "./package.json",
38
+ "./client": "./ui/client.js",
39
+ "./cordis.patch.yml": "./cordis.patch.yml",
40
+ "./locale/*.json": "./locale/*.json",
41
+ "./icon": "./icon.svg",
42
+ "./src/*": "./src/*"
43
+ },
44
+ "files": [
45
+ "index.js",
46
+ "src/**/*.js",
47
+ "ui/**/*.js",
48
+ "cordis.patch.yml",
49
+ "locale/*.json",
50
+ "icon.svg",
51
+ "screenshots.json",
52
+ "assets/*.png",
53
+ "README.md",
54
+ "LICENSE",
55
+ "CHANGELOG.md",
56
+ "docs/ARCHITECTURE.zh.md",
57
+ "docs/PUBLISHING.md",
58
+ "market/**/*.yml",
59
+ "market/*.md"
60
+ ],
61
+ "scripts": {
62
+ "test": "node test/run.mjs",
63
+ "bench": "node scripts/bench-protocol.mjs",
64
+ "repair-handoff": "node scripts/repair-handoff.mjs",
65
+ "check": "node --check index.js && node --check ui/client.js && node test/run.mjs"
66
+ },
67
+ "dsh": {
68
+ "bundle": {
69
+ "patch": "./cordis.patch.yml"
70
+ },
71
+ "client": {
72
+ "platform": "web"
73
+ }
74
+ }
75
+ }