dsh-layered-memory 0.8.7 → 0.8.8
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 +27 -4
- package/README.md +27 -4
- package/dist/client.js +3016 -3293
- package/dist/config.d.ts +50 -4
- package/dist/config.js +8 -0
- package/dist/contract.d.ts +615 -0
- package/dist/contract.js +1 -0
- package/dist/hooks/recall.d.ts +2 -18
- package/dist/index.d.ts +40 -4
- package/dist/index.js +6 -3
- package/dist/llm-usage.d.ts +2 -1
- package/dist/llm.d.ts +30 -4
- package/dist/llm.js +76 -9
- package/dist/pipeline/rebuild.d.ts +2 -21
- package/dist/pipeline/runner.d.ts +3 -3
- package/dist/pipeline/runner.js +38 -10
- package/dist/settings.d.ts +18 -29
- package/dist/settings.js +81 -1
- package/dist/stats.d.ts +2 -26
- package/dist/stats.js +80 -21
- package/dist/store/cost-ledger.d.ts +78 -0
- package/dist/store/cost-ledger.js +173 -0
- package/dist/store/download-queue.d.ts +2 -20
- package/dist/store/embedding-source.d.ts +2 -52
- package/dist/store/runtime-installer.d.ts +2 -13
- package/dist/store/sqlite.d.ts +11 -61
- package/dist/store/sqlite.js +15 -150
- package/dist/token-cost.d.ts +3 -72
- package/package.json +8 -4
package/dist/config.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* 默认数据目录:$DSH_HOME/memory(用官方 dshHomePath 解析,DSH_HOME 缺省 ~/.dsh)。
|
|
5
5
|
*/
|
|
6
6
|
import Schema from '@deepseek-ai/schemastery';
|
|
7
|
+
import type { StaticFallbackEntry } from './contract.js';
|
|
7
8
|
import type { ExtractMode } from './types.js';
|
|
8
9
|
/**
|
|
9
10
|
* 蒸馏思考档位全词汇表(唯一事实源):'' = 自动(模型默认档 → high),
|
|
@@ -96,10 +97,19 @@ export interface MemoryConfig {
|
|
|
96
97
|
provider: string;
|
|
97
98
|
/** 蒸馏用的模型;留空用当前默认选择。 */
|
|
98
99
|
model: string;
|
|
100
|
+
/** 回退链(#31):主路由失败(报错/掐断/网络异常/空输出)后按序降级的备用路由,
|
|
101
|
+
* 条目顺序即优先级。与主路由完全相同的条目自动跳过;provider/model 缺失的条目剔除;
|
|
102
|
+
* 条目 reasoningEffort 非空时覆盖全局档位(未配置运行时链 distillChain 时,
|
|
103
|
+
* 旧档位键 reasoningEffort 的整体接管——含给条目盖章——仍对存量值生效);
|
|
104
|
+
* 空数组(缺省)= 单路由行为不变。 */
|
|
105
|
+
fallbacks?: StaticFallbackEntry[];
|
|
99
106
|
/** 单次蒸馏调用的输出 token 上限(推理模型的 reasoning 与正文共享该预算)。 */
|
|
100
107
|
maxTokens: number;
|
|
101
108
|
/** 蒸馏调用的思考档位;空串不传(跟随模型默认)。 */
|
|
102
109
|
reasoningEffort: string;
|
|
110
|
+
/** 运行时主路由显式档位(distillChain[0].reasoningEffort 经 effectiveCfg 注入);
|
|
111
|
+
* 非静态 schema——'' = 跟随全局静态 reasoningEffort,仅供链模式传递主路由档位。 */
|
|
112
|
+
primaryEffort?: string;
|
|
103
113
|
temperature: number;
|
|
104
114
|
/** 单次蒸馏调用的用户 prompt 字符预算(≈token 数,按中文 1 字≈1 token 保守估算)。 */
|
|
105
115
|
maxInputChars: number;
|
|
@@ -175,7 +185,7 @@ export declare const memorySchema: Schema<Schemastery.ObjectS<{
|
|
|
175
185
|
timeoutMs: Schema<number, number>;
|
|
176
186
|
includePersona: Schema<boolean, boolean>;
|
|
177
187
|
includeSceneNav: Schema<boolean, boolean>;
|
|
178
|
-
strategy: Schema<"
|
|
188
|
+
strategy: Schema<"hybrid" | "keyword" | "embedding", "hybrid" | "keyword" | "embedding">;
|
|
179
189
|
scoreThreshold: Schema<number, number>;
|
|
180
190
|
decayHalfLifeDays: Schema<number, number>;
|
|
181
191
|
}>, Schemastery.ObjectT<{
|
|
@@ -186,7 +196,7 @@ export declare const memorySchema: Schema<Schemastery.ObjectS<{
|
|
|
186
196
|
timeoutMs: Schema<number, number>;
|
|
187
197
|
includePersona: Schema<boolean, boolean>;
|
|
188
198
|
includeSceneNav: Schema<boolean, boolean>;
|
|
189
|
-
strategy: Schema<"
|
|
199
|
+
strategy: Schema<"hybrid" | "keyword" | "embedding", "hybrid" | "keyword" | "embedding">;
|
|
190
200
|
scoreThreshold: Schema<number, number>;
|
|
191
201
|
decayHalfLifeDays: Schema<number, number>;
|
|
192
202
|
}>>;
|
|
@@ -216,6 +226,15 @@ export declare const memorySchema: Schema<Schemastery.ObjectS<{
|
|
|
216
226
|
llm: Schema<Schemastery.ObjectS<{
|
|
217
227
|
provider: Schema<string, string>;
|
|
218
228
|
model: Schema<string, string>;
|
|
229
|
+
fallbacks: Schema<({
|
|
230
|
+
provider?: string | null | undefined;
|
|
231
|
+
model?: string | null | undefined;
|
|
232
|
+
reasoningEffort?: "" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | null | undefined;
|
|
233
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<{
|
|
234
|
+
provider: Schema<string, string>;
|
|
235
|
+
model: Schema<string, string>;
|
|
236
|
+
reasoningEffort: Schema<"" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max", "" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max">;
|
|
237
|
+
}>[]>;
|
|
219
238
|
maxTokens: Schema<number, number>;
|
|
220
239
|
reasoningEffort: Schema<"" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max", "" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max">;
|
|
221
240
|
temperature: Schema<number, number>;
|
|
@@ -224,6 +243,15 @@ export declare const memorySchema: Schema<Schemastery.ObjectS<{
|
|
|
224
243
|
}>, Schemastery.ObjectT<{
|
|
225
244
|
provider: Schema<string, string>;
|
|
226
245
|
model: Schema<string, string>;
|
|
246
|
+
fallbacks: Schema<({
|
|
247
|
+
provider?: string | null | undefined;
|
|
248
|
+
model?: string | null | undefined;
|
|
249
|
+
reasoningEffort?: "" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | null | undefined;
|
|
250
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<{
|
|
251
|
+
provider: Schema<string, string>;
|
|
252
|
+
model: Schema<string, string>;
|
|
253
|
+
reasoningEffort: Schema<"" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max", "" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max">;
|
|
254
|
+
}>[]>;
|
|
227
255
|
maxTokens: Schema<number, number>;
|
|
228
256
|
reasoningEffort: Schema<"" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max", "" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max">;
|
|
229
257
|
temperature: Schema<number, number>;
|
|
@@ -288,7 +316,7 @@ export declare const memorySchema: Schema<Schemastery.ObjectS<{
|
|
|
288
316
|
timeoutMs: Schema<number, number>;
|
|
289
317
|
includePersona: Schema<boolean, boolean>;
|
|
290
318
|
includeSceneNav: Schema<boolean, boolean>;
|
|
291
|
-
strategy: Schema<"
|
|
319
|
+
strategy: Schema<"hybrid" | "keyword" | "embedding", "hybrid" | "keyword" | "embedding">;
|
|
292
320
|
scoreThreshold: Schema<number, number>;
|
|
293
321
|
decayHalfLifeDays: Schema<number, number>;
|
|
294
322
|
}>, Schemastery.ObjectT<{
|
|
@@ -299,7 +327,7 @@ export declare const memorySchema: Schema<Schemastery.ObjectS<{
|
|
|
299
327
|
timeoutMs: Schema<number, number>;
|
|
300
328
|
includePersona: Schema<boolean, boolean>;
|
|
301
329
|
includeSceneNav: Schema<boolean, boolean>;
|
|
302
|
-
strategy: Schema<"
|
|
330
|
+
strategy: Schema<"hybrid" | "keyword" | "embedding", "hybrid" | "keyword" | "embedding">;
|
|
303
331
|
scoreThreshold: Schema<number, number>;
|
|
304
332
|
decayHalfLifeDays: Schema<number, number>;
|
|
305
333
|
}>>;
|
|
@@ -329,6 +357,15 @@ export declare const memorySchema: Schema<Schemastery.ObjectS<{
|
|
|
329
357
|
llm: Schema<Schemastery.ObjectS<{
|
|
330
358
|
provider: Schema<string, string>;
|
|
331
359
|
model: Schema<string, string>;
|
|
360
|
+
fallbacks: Schema<({
|
|
361
|
+
provider?: string | null | undefined;
|
|
362
|
+
model?: string | null | undefined;
|
|
363
|
+
reasoningEffort?: "" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | null | undefined;
|
|
364
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<{
|
|
365
|
+
provider: Schema<string, string>;
|
|
366
|
+
model: Schema<string, string>;
|
|
367
|
+
reasoningEffort: Schema<"" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max", "" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max">;
|
|
368
|
+
}>[]>;
|
|
332
369
|
maxTokens: Schema<number, number>;
|
|
333
370
|
reasoningEffort: Schema<"" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max", "" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max">;
|
|
334
371
|
temperature: Schema<number, number>;
|
|
@@ -337,6 +374,15 @@ export declare const memorySchema: Schema<Schemastery.ObjectS<{
|
|
|
337
374
|
}>, Schemastery.ObjectT<{
|
|
338
375
|
provider: Schema<string, string>;
|
|
339
376
|
model: Schema<string, string>;
|
|
377
|
+
fallbacks: Schema<({
|
|
378
|
+
provider?: string | null | undefined;
|
|
379
|
+
model?: string | null | undefined;
|
|
380
|
+
reasoningEffort?: "" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max" | null | undefined;
|
|
381
|
+
} & import("@deepseek-ai/cosmokit").Dict)[], Schemastery.ObjectT<{
|
|
382
|
+
provider: Schema<string, string>;
|
|
383
|
+
model: Schema<string, string>;
|
|
384
|
+
reasoningEffort: Schema<"" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max", "" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max">;
|
|
385
|
+
}>[]>;
|
|
340
386
|
maxTokens: Schema<number, number>;
|
|
341
387
|
reasoningEffort: Schema<"" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max", "" | "off" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max">;
|
|
342
388
|
temperature: Schema<number, number>;
|
package/dist/config.js
CHANGED
|
@@ -11,6 +11,7 @@ import { dshHomePath } from '@deepseek-ai/dsh-home-paths';
|
|
|
11
11
|
* schema(config/settings)、运行时解析(settings.resolveSettings)与 RPC
|
|
12
12
|
* 写入门(stats.settings-set)共用,勿在别处再抄字面量表。
|
|
13
13
|
*/
|
|
14
|
+
// satisfies 反向锁定:词汇表扩词必须同步契约的 EffortChoice 联合(host 与 TS 化的 client 共用)
|
|
14
15
|
export const EFFORT_CHOICES = ['', 'off', 'none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
|
|
15
16
|
export const memorySchema = Schema.object({
|
|
16
17
|
dataDir: Schema.string().default(''),
|
|
@@ -68,6 +69,13 @@ export const memorySchema = Schema.object({
|
|
|
68
69
|
llm: Schema.object({
|
|
69
70
|
provider: Schema.string().default(''),
|
|
70
71
|
model: Schema.string().default(''),
|
|
72
|
+
// 回退链(#31):主路由失败后按序降级;每条路由各享全额 timeoutMs(慢 TTFT 模型的
|
|
73
|
+
// 回退位正是要给它留足首包时间,共享预算会让回退链失效);条目档位经能力钳制后发送
|
|
74
|
+
fallbacks: Schema.array(Schema.object({
|
|
75
|
+
provider: Schema.string().default(''),
|
|
76
|
+
model: Schema.string().default(''),
|
|
77
|
+
reasoningEffort: Schema.union([...EFFORT_CHOICES]).default(''),
|
|
78
|
+
})).default([]),
|
|
71
79
|
// 推理模型(如 v4-flash)的 reasoning 计入输出预算:预算不足会被思考吃光导致正文 0 字符。
|
|
72
80
|
// 0.8.0 起各蒸馏层显式传分层预算(见 llm.ts LAYER_MAX_TOKENS_*),本值为未分层调用的兜底总闸
|
|
73
81
|
maxTokens: Schema.number().min(1024).max(1_000_000).default(65_536),
|