dsh-memento 0.4.2 → 0.4.3
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/ARCHITECTURE.md +177 -177
- package/CHANGELOG.md +111 -104
- package/client/client.js +241 -241
- package/index.mjs +1743 -1739
- package/lib/constants.mjs +68 -68
- package/lib/store.mjs +717 -717
- package/package.json +153 -153
- package/types.d.ts +238 -237
package/lib/constants.mjs
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
// lib/constants.mjs — dsh-memento 词汇表与协议常量(零 DSH 依赖)。
|
|
2
|
-
//
|
|
3
|
-
// 本文件只放协议级常量(词汇、错误码、存储格式版本)。部署可调参数一律走
|
|
4
|
-
// index.mjs 的 Schemastery Config,绝不在此写死 tunable。
|
|
5
|
-
|
|
6
|
-
/** 记忆轨道(双轨分家):user=用户画像,agent=环境事实/约定/教训。 */
|
|
7
|
-
export const TRACKS = /** @type {readonly ['user', 'agent']} */ (['user', 'agent'])
|
|
8
|
-
|
|
9
|
-
/** 分层作用域:user-global 跨工作区,workspace 按会话 cwd。 */
|
|
10
|
-
export const SCOPES = /** @type {readonly ['user-global', 'workspace']} */ (['user-global', 'workspace'])
|
|
11
|
-
|
|
12
|
-
/** 写策略(Config.writePolicy):ask=用户审批,auto=放行但记录审批来源,off=拒绝。 */
|
|
13
|
-
export const WRITE_POLICIES = ['ask', 'auto', 'off']
|
|
14
|
-
|
|
15
|
-
/** 审批请求里标识本插件记忆写动作的工具名(审批 answerer 据此认领请求)。 */
|
|
16
|
-
export const TOOL_NAME = 'memory'
|
|
17
|
-
|
|
18
|
-
/** 审批 reason 前缀(含方括号):answerer 只认领带本前缀的 memory 写请求,防止误伤同工具名的其它请求。 */
|
|
19
|
-
export const REQUEST_MARKER = '[dsh-memento]'
|
|
20
|
-
|
|
21
|
-
/** 记忆库 schema 版本(单调递增;旧版逐级迁移,新版响亮拒绝)。v2 = proposals 提案表;v3 = agent_key + 召回排序列;v4 = tags + version(协议 v1 条目规范)。 */
|
|
22
|
-
export const SCHEMA_VERSION = 4
|
|
23
|
-
|
|
24
|
-
/** 数据库文件名(位于 $DSH_HOME/dsh-memento/ 下)。 */
|
|
25
|
-
export const DEFAULT_DB_NAME = 'memory.db'
|
|
26
|
-
|
|
27
|
-
/** 条目默认来源标注(seed 写 source: 'claude' 时除外)。 */
|
|
28
|
-
export const DEFAULT_SOURCE = 'dsh-memento'
|
|
29
|
-
|
|
30
|
-
/** Provider 层查询返回硬上限:显式 limit 的钳制天花板(防模型/面板拉爆上下文)。 */
|
|
31
|
-
export const MAX_QUERY_LIMIT = 1000
|
|
32
|
-
|
|
33
|
-
/** 面板审计路由的返回上限:只读抽屉的审计尾展示天花板(协议常量,非部署 tunable)。 */
|
|
34
|
-
export const PANEL_AUDIT_CEILING = 200
|
|
35
|
-
|
|
36
|
-
/** /memory export 文档的 schema 标记(export 与 import 共用;import 只认本标记)。 */
|
|
37
|
-
export const EXPORT_SCHEMA = 'memory-export-v1'
|
|
38
|
-
|
|
39
|
-
/** /memory import 单次导入条目数上限:防一次性灌入海量条目把审批载荷撑爆(协议常量)。 */
|
|
40
|
-
export const MAX_IMPORT_ENTRIES = 1000
|
|
41
|
-
|
|
42
|
-
/** consolidate 单次整合的定位子串数上限(协议写语义,Provider 与协议核心共用)。 */
|
|
43
|
-
export const MAX_CONSOLIDATE_MATCHES = 20
|
|
44
|
-
|
|
45
|
-
/** 结构化错误码:工具与面板据此分支,模型据此决定"整合后重试"还是"放弃"。 */
|
|
46
|
-
export const ERROR_CODES = {
|
|
47
|
-
DISABLED: 'MEMORY_DISABLED',
|
|
48
|
-
INVALID_INPUT: 'INVALID_INPUT',
|
|
49
|
-
NO_AGENT: 'WRITE_REQUIRES_AGENT',
|
|
50
|
-
BUDGET_EXCEEDED: 'BUDGET_EXCEEDED',
|
|
51
|
-
ENTRY_NOT_FOUND: 'ENTRY_NOT_FOUND',
|
|
52
|
-
AMBIGUOUS_MATCH: 'AMBIGUOUS_MATCH',
|
|
53
|
-
WRITE_DENIED: 'WRITE_DENIED',
|
|
54
|
-
PROPOSAL_NOT_FOUND: 'PROPOSAL_NOT_FOUND',
|
|
55
|
-
STORE_CORRUPT: 'STORE_CORRUPT',
|
|
56
|
-
STORE_UNSUPPORTED_VERSION: 'STORE_UNSUPPORTED_VERSION',
|
|
57
|
-
ADAPTER_NOT_FOUND: 'ADAPTER_NOT_FOUND',
|
|
58
|
-
ADAPTER_PAYLOAD: 'ADAPTER_PAYLOAD',
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** 会话事件名(SessionEventMap 声明合并的词汇表;运行时按已知类型自适应派发)。 */
|
|
62
|
-
export const SESSION_EVENTS = {
|
|
63
|
-
added: 'memory/added',
|
|
64
|
-
updated: 'memory/updated',
|
|
65
|
-
removed: 'memory/removed',
|
|
66
|
-
recalled: 'memory/recalled',
|
|
67
|
-
snapshot: 'memory/snapshot',
|
|
68
|
-
}
|
|
1
|
+
// lib/constants.mjs — dsh-memento 词汇表与协议常量(零 DSH 依赖)。
|
|
2
|
+
//
|
|
3
|
+
// 本文件只放协议级常量(词汇、错误码、存储格式版本)。部署可调参数一律走
|
|
4
|
+
// index.mjs 的 Schemastery Config,绝不在此写死 tunable。
|
|
5
|
+
|
|
6
|
+
/** 记忆轨道(双轨分家):user=用户画像,agent=环境事实/约定/教训。 */
|
|
7
|
+
export const TRACKS = /** @type {readonly ['user', 'agent']} */ (['user', 'agent'])
|
|
8
|
+
|
|
9
|
+
/** 分层作用域:user-global 跨工作区,workspace 按会话 cwd。 */
|
|
10
|
+
export const SCOPES = /** @type {readonly ['user-global', 'workspace']} */ (['user-global', 'workspace'])
|
|
11
|
+
|
|
12
|
+
/** 写策略(Config.writePolicy):ask=用户审批,auto=放行但记录审批来源,off=拒绝。 */
|
|
13
|
+
export const WRITE_POLICIES = ['ask', 'auto', 'off']
|
|
14
|
+
|
|
15
|
+
/** 审批请求里标识本插件记忆写动作的工具名(审批 answerer 据此认领请求)。 */
|
|
16
|
+
export const TOOL_NAME = 'memory'
|
|
17
|
+
|
|
18
|
+
/** 审批 reason 前缀(含方括号):answerer 只认领带本前缀的 memory 写请求,防止误伤同工具名的其它请求。 */
|
|
19
|
+
export const REQUEST_MARKER = '[dsh-memento]'
|
|
20
|
+
|
|
21
|
+
/** 记忆库 schema 版本(单调递增;旧版逐级迁移,新版响亮拒绝)。v2 = proposals 提案表;v3 = agent_key + 召回排序列;v4 = tags + version(协议 v1 条目规范)。 */
|
|
22
|
+
export const SCHEMA_VERSION = 4
|
|
23
|
+
|
|
24
|
+
/** 数据库文件名(位于 $DSH_HOME/dsh-memento/ 下)。 */
|
|
25
|
+
export const DEFAULT_DB_NAME = 'memory.db'
|
|
26
|
+
|
|
27
|
+
/** 条目默认来源标注(seed 写 source: 'claude' 时除外)。 */
|
|
28
|
+
export const DEFAULT_SOURCE = 'dsh-memento'
|
|
29
|
+
|
|
30
|
+
/** Provider 层查询返回硬上限:显式 limit 的钳制天花板(防模型/面板拉爆上下文)。 */
|
|
31
|
+
export const MAX_QUERY_LIMIT = 1000
|
|
32
|
+
|
|
33
|
+
/** 面板审计路由的返回上限:只读抽屉的审计尾展示天花板(协议常量,非部署 tunable)。 */
|
|
34
|
+
export const PANEL_AUDIT_CEILING = 200
|
|
35
|
+
|
|
36
|
+
/** /memory export 文档的 schema 标记(export 与 import 共用;import 只认本标记)。 */
|
|
37
|
+
export const EXPORT_SCHEMA = 'memory-export-v1'
|
|
38
|
+
|
|
39
|
+
/** /memory import 单次导入条目数上限:防一次性灌入海量条目把审批载荷撑爆(协议常量)。 */
|
|
40
|
+
export const MAX_IMPORT_ENTRIES = 1000
|
|
41
|
+
|
|
42
|
+
/** consolidate 单次整合的定位子串数上限(协议写语义,Provider 与协议核心共用)。 */
|
|
43
|
+
export const MAX_CONSOLIDATE_MATCHES = 20
|
|
44
|
+
|
|
45
|
+
/** 结构化错误码:工具与面板据此分支,模型据此决定"整合后重试"还是"放弃"。 */
|
|
46
|
+
export const ERROR_CODES = {
|
|
47
|
+
DISABLED: 'MEMORY_DISABLED',
|
|
48
|
+
INVALID_INPUT: 'INVALID_INPUT',
|
|
49
|
+
NO_AGENT: 'WRITE_REQUIRES_AGENT',
|
|
50
|
+
BUDGET_EXCEEDED: 'BUDGET_EXCEEDED',
|
|
51
|
+
ENTRY_NOT_FOUND: 'ENTRY_NOT_FOUND',
|
|
52
|
+
AMBIGUOUS_MATCH: 'AMBIGUOUS_MATCH',
|
|
53
|
+
WRITE_DENIED: 'WRITE_DENIED',
|
|
54
|
+
PROPOSAL_NOT_FOUND: 'PROPOSAL_NOT_FOUND',
|
|
55
|
+
STORE_CORRUPT: 'STORE_CORRUPT',
|
|
56
|
+
STORE_UNSUPPORTED_VERSION: 'STORE_UNSUPPORTED_VERSION',
|
|
57
|
+
ADAPTER_NOT_FOUND: 'ADAPTER_NOT_FOUND',
|
|
58
|
+
ADAPTER_PAYLOAD: 'ADAPTER_PAYLOAD',
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** 会话事件名(SessionEventMap 声明合并的词汇表;运行时按已知类型自适应派发)。 */
|
|
62
|
+
export const SESSION_EVENTS = {
|
|
63
|
+
added: 'memory/added',
|
|
64
|
+
updated: 'memory/updated',
|
|
65
|
+
removed: 'memory/removed',
|
|
66
|
+
recalled: 'memory/recalled',
|
|
67
|
+
snapshot: 'memory/snapshot',
|
|
68
|
+
}
|