dsh-prime-memory 0.20.0-beta.2 → 0.20.0-beta.21
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/CHANGELOG.md +192 -3
- package/ENGINEERING-NOTES.md +17 -0
- package/dist/client.js +1158 -405
- package/dist/config.d.ts +0 -120
- package/dist/config.js +1 -21
- package/dist/contract.d.ts +111 -56
- package/dist/hooks/recall.d.ts +4 -1
- package/dist/hooks/recall.js +7 -1
- package/dist/index.d.ts +0 -78
- package/dist/index.js +14 -21
- package/dist/metadata-validators.d.ts +5 -0
- package/dist/metadata-validators.js +11 -1
- package/dist/pipeline/recluster.js +1 -1
- package/dist/pipeline/ruminate.d.ts +11 -1
- package/dist/pipeline/ruminate.js +18 -1
- package/dist/room-review.d.ts +196 -0
- package/dist/room-review.js +281 -0
- package/dist/stats.d.ts +23 -34
- package/dist/stats.js +268 -201
- package/dist/store/l1.d.ts +34 -0
- package/dist/store/l1.js +68 -1
- package/dist/store/recall-usage.d.ts +43 -0
- package/dist/store/recall-usage.js +149 -0
- package/dist/store/rooms-registry.d.ts +66 -0
- package/dist/store/rooms-registry.js +250 -0
- package/dist/store/session-modes.d.ts +0 -8
- package/dist/store/session-modes.js +0 -52
- package/dist/store/sqlite.d.ts +4 -0
- package/dist/store/sqlite.js +20 -0
- package/dist/tools/index.d.ts +4 -1
- package/dist/tools/index.js +232 -1
- package/dist/types.d.ts +4 -0
- package/dsh.plugin.json +1 -1
- package/package.json +1 -1
- package/dist/hooks/long-task.d.ts +0 -31
- package/dist/hooks/long-task.js +0 -93
- package/dist/store/context-usage.d.ts +0 -28
- package/dist/store/context-usage.js +0 -47
- package/dist/store/todo-ref.d.ts +0 -41
- package/dist/store/todo-ref.js +0 -65
package/dist/stats.d.ts
CHANGED
|
@@ -3,15 +3,13 @@ import { type MemoryConfig } from './config.js';
|
|
|
3
3
|
import { type RecallSessionStats } from './hooks/recall.js';
|
|
4
4
|
import type { RebuildController } from './pipeline/rebuild.js';
|
|
5
5
|
import type { RuminateController } from './pipeline/ruminate.js';
|
|
6
|
+
import type { RoomRegistryStore } from './store/rooms-registry.js';
|
|
7
|
+
import type { RecallUsageStore } from './store/recall-usage.js';
|
|
6
8
|
import { type LiveSettingsHandle } from './settings.js';
|
|
7
9
|
import type { GraphStore } from './store/graph-store.js';
|
|
8
10
|
import type { L0Store } from './store/l0.js';
|
|
9
11
|
import type { L1Store } from './store/l1.js';
|
|
10
12
|
import type { PersonaStore } from './store/persona.js';
|
|
11
|
-
import type { SlotStore } from './store/slots.js';
|
|
12
|
-
import type { ContextUsageStore } from './store/context-usage.js';
|
|
13
|
-
import type { TodoRefStore } from './store/todo-ref.js';
|
|
14
|
-
import type { MemoryRunner } from './pipeline/runner.js';
|
|
15
13
|
import type { SceneStore } from './store/scenes.js';
|
|
16
14
|
import type { SessionModeStore } from './store/session-modes.js';
|
|
17
15
|
import type { EmbeddingManager } from './store/embedding-source.js';
|
|
@@ -27,7 +25,7 @@ export interface MemoryStatusSource {
|
|
|
27
25
|
pending(): number;
|
|
28
26
|
}
|
|
29
27
|
/**
|
|
30
|
-
* 端点全集运行时清单(
|
|
28
|
+
* 端点全集运行时清单(与 tests/contract-keys.test.ts 的 ENDPOINTS 及
|
|
31
29
|
* contract.ts 类型映射表三方对齐,漂移由键集 diff 测试暴露)。
|
|
32
30
|
* 注意:本清单同时是 HTTP 前缀路由 `/dsh-memory/rpc/<短名>` 的**放行白名单**
|
|
33
31
|
* (见下方 SHORT_ENDPOINTS),漏一条 = 该端点在面板里静默消失(404 被客户端
|
|
@@ -71,29 +69,6 @@ export interface SessionInfoSource {
|
|
|
71
69
|
}
|
|
72
70
|
import type { MemoryOccupancy, UiRecord } from './contract.js';
|
|
73
71
|
export type { MemoryStats } from './contract.js';
|
|
74
|
-
/** 注册状态 RPC(web 侧 connection 服务可选,缺失时跳过,不影响插件主体)。 */
|
|
75
|
-
/** 长任务端点依赖(可选:未装配时端点返 enabled:false,不报错)。 */
|
|
76
|
-
export interface LongTaskEndpointDeps {
|
|
77
|
-
runner: MemoryRunner;
|
|
78
|
-
slots: SlotStore;
|
|
79
|
-
contextUsage: ContextUsageStore;
|
|
80
|
-
todoRef: TodoRefStore;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* 尾部 turn 压缩:把 (水位线, maxCapturedTurn] 内最近的最近 N 轮强制蒸馏入记忆
|
|
84
|
-
* (force 跳过阈值;L1 去重与水位线双重防重)。off 档会话保持完全隐身(不压缩)。
|
|
85
|
-
* 无锚点老数据只在首次压缩(无水位线)时纳入——宁少收不重蒸。
|
|
86
|
-
*/
|
|
87
|
-
export declare function compressTailTurns(sessionId: string, turns: number, io: {
|
|
88
|
-
modes: SessionModeStore;
|
|
89
|
-
l0: L0Store;
|
|
90
|
-
runner: MemoryRunner;
|
|
91
|
-
logger: MemoryLogger;
|
|
92
|
-
}): Promise<{
|
|
93
|
-
enqueued: number;
|
|
94
|
-
fromTurn: number | null;
|
|
95
|
-
toTurn: number | null;
|
|
96
|
-
}>;
|
|
97
72
|
/** registerMemoryRpc 形参中需要落入端点 deps 的部分。 */
|
|
98
73
|
interface MemoryRpcSources {
|
|
99
74
|
status?: MemoryStatusSource;
|
|
@@ -103,8 +78,8 @@ interface MemoryRpcSources {
|
|
|
103
78
|
rebuild?: RebuildController;
|
|
104
79
|
embedManager?: EmbeddingManager;
|
|
105
80
|
sessionInfo?: SessionInfoSource;
|
|
106
|
-
/**
|
|
107
|
-
|
|
81
|
+
/** Room 注册表(未装配 = rooms-get 不带 registry,rooms-export 不可用)。 */
|
|
82
|
+
roomRegistry?: RoomRegistryStore;
|
|
108
83
|
}
|
|
109
84
|
/** 端点 deps 的注入面(ctx/cfg/stores/logger 由调用方绑定,其余由此处决定)。 */
|
|
110
85
|
export type EndpointDepsInput = Omit<EndpointDeps, 'ctx' | 'cfg' | 'stores' | 'logger'>;
|
|
@@ -120,6 +95,8 @@ export declare function registerMemoryRpc(ctx: Context, cfg: MemoryConfig, store
|
|
|
120
95
|
scenes: Record<MemoryFamily, SceneStore>;
|
|
121
96
|
persona: Record<MemoryFamily, PersonaStore>;
|
|
122
97
|
state: StateStore;
|
|
98
|
+
/** 召回使用统计(可选)。 */
|
|
99
|
+
usage?: RecallUsageStore;
|
|
123
100
|
/** 记忆后端(后台边界);未装配时回退为包 l1 的进程内实现。 */
|
|
124
101
|
backend?: MemoryBackend;
|
|
125
102
|
/** 图谱存储(可选:未装配时图谱端点返空,不报错)。 */
|
|
@@ -127,14 +104,16 @@ export declare function registerMemoryRpc(ctx: Context, cfg: MemoryConfig, store
|
|
|
127
104
|
}, logger: MemoryLogger, status?: MemoryStatusSource, live?: LiveSettingsHandle, modes?: SessionModeStore, dataDir?: string, rebuild?: RebuildController, embedManager?: EmbeddingManager, sessionInfo?: SessionInfoSource,
|
|
128
105
|
/** 反刍控制器(存储降级时为 undefined):经 buildEndpointDeps 落入 deps.ruminate。 */
|
|
129
106
|
ruminate?: RuminateController,
|
|
130
|
-
/**
|
|
131
|
-
|
|
107
|
+
/** Room 分类管理依赖(注册表;缺省 = rooms-get 不带 registry、rooms-export 恒 404 语义)。 */
|
|
108
|
+
roomRegistry?: RoomRegistryStore): void;
|
|
132
109
|
export interface EndpointDeps {
|
|
133
110
|
ctx: Context;
|
|
134
111
|
cfg: MemoryConfig;
|
|
135
112
|
stores: {
|
|
136
113
|
l0: L0Store;
|
|
137
114
|
l1: L1Store;
|
|
115
|
+
/** 召回使用统计(可选:未装配 = 列表不带 usage/usageSummary)。 */
|
|
116
|
+
usage?: RecallUsageStore;
|
|
138
117
|
scenes: Record<MemoryFamily, SceneStore>;
|
|
139
118
|
persona: Record<MemoryFamily, PersonaStore>;
|
|
140
119
|
state: StateStore;
|
|
@@ -151,12 +130,14 @@ export interface EndpointDeps {
|
|
|
151
130
|
ruminate?: RuminateController;
|
|
152
131
|
embedManager?: EmbeddingManager;
|
|
153
132
|
sessionInfo?: SessionInfoSource;
|
|
154
|
-
/**
|
|
155
|
-
|
|
133
|
+
/** Room 注册表(未装配 = rooms-get 不带 registry,rooms-export 不可用)。 */
|
|
134
|
+
roomRegistry?: RoomRegistryStore;
|
|
156
135
|
}
|
|
157
136
|
/** 端点分发表(导出供测试直调:可精确注入 rebuild/ruminate 等可选控制器,验证 deps 接线)。 */
|
|
158
137
|
export declare function handleEndpoint(endpoint: string, payload: unknown, deps: EndpointDeps): Promise<unknown>;
|
|
159
138
|
/** 浏览器卡片字段(比 MemoryRecord 精简,去掉大 metadata;Hall 从 metadata 提取)。 */
|
|
139
|
+
/** 老化权重(与读路径 applyDecayWeight 同式):max(0.5, 0.5^(Δ天/半衰期));半衰期 ≤0 = 关 → null。 */
|
|
140
|
+
export declare function agingWeightOf(updatedAtMs: number | undefined, halfLifeDays: number, now?: number): number | null;
|
|
160
141
|
export declare function hitToUiRecord(r: {
|
|
161
142
|
id: string;
|
|
162
143
|
content: string;
|
|
@@ -173,4 +154,12 @@ export declare function hitToUiRecord(r: {
|
|
|
173
154
|
family?: string;
|
|
174
155
|
/** 退场判据:`valid_to` 闭合即已退场(软删)。由 `listL1`/`getByIds` 透传。 */
|
|
175
156
|
validTo?: number;
|
|
157
|
+
}, extra?: {
|
|
158
|
+
agingWeight?: number | null;
|
|
159
|
+
usage?: {
|
|
160
|
+
attempts: number;
|
|
161
|
+
used: number;
|
|
162
|
+
lastAttemptAt: number | null;
|
|
163
|
+
lastUsedAt: number | null;
|
|
164
|
+
} | null;
|
|
176
165
|
}): UiRecord;
|