stratagate-dsh 0.2.60 → 0.2.61
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 +10 -30
- package/LICENSE +21 -21
- package/README.zh-CN.md +43 -43
- package/dist/client.js +4 -4
- package/dist/index.js +18 -156
- package/dist/index.js.map +1 -1
- package/docs/ARCHITECTURE.md +29 -29
- package/docs/DSH.md +13 -14
- package/docs/DSH.zh-CN.md +11 -12
- package/docs/EXTERNAL_MEMORY_IMPORT.zh-CN.md +54 -54
- package/package.json +23 -23
- package/screenshots.json +4 -4
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -48,20 +48,20 @@ A completed user/assistant pair is one turn. The default block boundary is 12 co
|
|
|
48
48
|
|
|
49
49
|
Hosts may attach a `threadId` to each turn. Open tails, Block boundaries, neighboring extraction context, turn ranges, and decay pointers are then isolated by thread. Persisted Blocks remain available as provenance for long-term cards, while host integrations must inject only the active thread's short-term Block context.
|
|
50
50
|
|
|
51
|
-
When the boundary is reached:
|
|
52
|
-
|
|
53
|
-
1. One atomic sealing transaction moves the source messages into permanent L5 and writes deterministic L4 and L3.
|
|
54
|
-
2. The sealed Block is marked model-pending. It is provenance, but it is excluded from decay and cannot replace native conversation history.
|
|
55
|
-
3. A background summarizer produces and validates L0-L2 plus a conservative `shouldExtract` decision.
|
|
56
|
-
4. Event extraction completes with either validated Events or an explicit valid empty result.
|
|
57
|
-
5. Only then is the Block marked ready: its pointer starts at L5, it may replace native history, and it decays toward L0 as newer ready Blocks enter the same thread.
|
|
51
|
+
When the boundary is reached:
|
|
52
|
+
|
|
53
|
+
1. One atomic sealing transaction moves the source messages into permanent L5 and writes deterministic L4 and L3.
|
|
54
|
+
2. The sealed Block is marked model-pending. It is provenance, but it is excluded from decay and cannot replace native conversation history.
|
|
55
|
+
3. A background summarizer produces and validates L0-L2 plus a conservative `shouldExtract` decision.
|
|
56
|
+
4. Event extraction completes with either validated Events or an explicit valid empty result.
|
|
57
|
+
5. Only then is the Block marked ready: its pointer starts at L5, it may replace native history, and it decays toward L0 as newer ready Blocks enter the same thread.
|
|
58
58
|
|
|
59
59
|
The block weight is:
|
|
60
60
|
|
|
61
61
|
```text
|
|
62
62
|
w(age) = exp(-lambda_block * age)
|
|
63
63
|
|
|
64
|
-
age = latest ready Block position - pointer anchor Block position
|
|
64
|
+
age = latest ready Block position - pointer anchor Block position
|
|
65
65
|
lambda_block = 0.30 by default
|
|
66
66
|
```
|
|
67
67
|
|
|
@@ -78,13 +78,13 @@ L3 may remove only:
|
|
|
78
78
|
|
|
79
79
|
Short repeated natural-language messages are retained. L3 never performs semantic paraphrasing.
|
|
80
80
|
|
|
81
|
-
## Event extraction
|
|
82
|
-
|
|
83
|
-
After L0-L2 validates, a candidate Block is extracted independently; a later Block is not required. The extractor receives:
|
|
81
|
+
## Event extraction
|
|
82
|
+
|
|
83
|
+
After L0-L2 validates, a candidate Block is extracted independently; a later Block is not required. The extractor receives:
|
|
84
84
|
|
|
85
85
|
- target block `N`, including its L5 source and legal evidence IDs;
|
|
86
86
|
- previous block `N-1` L2 keypoints for context, if it exists;
|
|
87
|
-
- the nearest available later ready Block's L2 keypoints for context, if one exists;
|
|
87
|
+
- the nearest available later ready Block's L2 keypoints for context, if one exists;
|
|
88
88
|
- a compact timeline of existing event IDs, titles, and temporal fields.
|
|
89
89
|
|
|
90
90
|
The target is the only legal source of new facts and quotations. Neighbor blocks are context-only and must not contribute events or source references. Source message IDs are checked against the target block. The reference implementation falls back to all target messages when an extractor returns no valid source ID; stricter adapters may reject the card instead.
|
|
@@ -144,12 +144,12 @@ Applications that manage their own model loop may use `claimNextElementProjectio
|
|
|
144
144
|
|
|
145
145
|
## Hybrid retrieval
|
|
146
146
|
|
|
147
|
-
Event and fact-level element search use two inspectable ranking sources:
|
|
148
|
-
|
|
149
|
-
1. BM25 over field-weighted lexical tokens, including overlapping Han bigrams;
|
|
150
|
-
2. structured rankings from fields such as participant, event type, time range, element name, and element type.
|
|
151
|
-
|
|
152
|
-
Reciprocal-rank fusion combines the available rankings. A non-empty query with no lexical or structured match returns an empty result rather than all candidates. Element search returns the matched fact plus its element ID, validity interval, and event provenance; callers expand the full element card only when needed. The reference path does not use embeddings or vector similarity.
|
|
147
|
+
Event and fact-level element search use two inspectable ranking sources:
|
|
148
|
+
|
|
149
|
+
1. BM25 over field-weighted lexical tokens, including overlapping Han bigrams;
|
|
150
|
+
2. structured rankings from fields such as participant, event type, time range, element name, and element type.
|
|
151
|
+
|
|
152
|
+
Reciprocal-rank fusion combines the available rankings. A non-empty query with no lexical or structured match returns an empty result rather than all candidates. Element search returns the matched fact plus its element ID, validity interval, and event provenance; callers expand the full element card only when needed. The reference path does not use embeddings or vector similarity.
|
|
153
153
|
|
|
154
154
|
Integration tool responses intentionally expose compact search cards. They retain stable IDs, summaries,
|
|
155
155
|
timestamps, and evidence references while leaving narrative/quotes/source-message lists and full graph
|
|
@@ -220,19 +220,19 @@ If the retrieval budget ends without sufficient evidence, the caller should pass
|
|
|
220
220
|
|
|
221
221
|
Every namespace has a monotonically increasing revision. A write supplies the revision it loaded; SQLite commits the new revision and all related rows in one immediate transaction. A stale process receives `StorageConflictError` rather than overwriting newer state.
|
|
222
222
|
|
|
223
|
-
External model calls are never made inside a database transaction:
|
|
224
|
-
|
|
225
|
-
1. a completed raw turn is committed immediately;
|
|
226
|
-
2. every complete Block is sealed atomically with real L3-L5 before any model call;
|
|
227
|
-
3. summarization first claims a persisted job, runs outside the transaction, and commits validated L0-L2 or a failed job with bounded retry metadata;
|
|
228
|
-
4. extraction first commits a running job, calls the extractor, then atomically commits either the event cards, a valid empty result, or a failed job state;
|
|
229
|
-
5. element projection follows the same claim/call/complete boundary after its source events are durable;
|
|
230
|
-
6. failed model jobs retry at most three total attempts with exponential backoff; completed empty extraction is terminal and is not retried.
|
|
223
|
+
External model calls are never made inside a database transaction:
|
|
224
|
+
|
|
225
|
+
1. a completed raw turn is committed immediately;
|
|
226
|
+
2. every complete Block is sealed atomically with real L3-L5 before any model call;
|
|
227
|
+
3. summarization first claims a persisted job, runs outside the transaction, and commits validated L0-L2 or a failed job with bounded retry metadata;
|
|
228
|
+
4. extraction first commits a running job, calls the extractor, then atomically commits either the event cards, a valid empty result, or a failed job state;
|
|
229
|
+
5. element projection follows the same claim/call/complete boundary after its source events are durable;
|
|
230
|
+
6. failed model jobs retry at most three total attempts with exponential backoff; completed empty extraction is terminal and is not retried.
|
|
231
231
|
|
|
232
232
|
The adapter preserves these invariants:
|
|
233
233
|
|
|
234
|
-
- blocks and L5 messages are append-only, including when every derived task fails;
|
|
235
|
-
- model-pending Blocks are excluded from decay and native-history replacement;
|
|
234
|
+
- blocks and L5 messages are append-only, including when every derived task fails;
|
|
235
|
+
- model-pending Blocks are excluded from decay and native-history replacement;
|
|
236
236
|
- card provenance references an existing source block and message set;
|
|
237
237
|
- search hits do not increment adoption state;
|
|
238
238
|
- supersession retains the old event;
|
|
@@ -241,4 +241,4 @@ The adapter preserves these invariants:
|
|
|
241
241
|
- forget is reversible unless an application explicitly implements irreversible deletion;
|
|
242
242
|
- usage receipts are idempotent for one answer turn through a unique `receiptId`.
|
|
243
243
|
|
|
244
|
-
SQLite schema v10 includes durable external-memory import jobs and per-candidate progress, in addition to the normalized Block processing state, summary/extraction retry jobs, graph, element, provenance, receipt, decay-anchor, and lift-source data introduced earlier. Opening a schema-v1 through v9 database migrates it in one transaction and preserves existing namespaces, Blocks, Events, jobs, and receipts. Existing pre-v9 Blocks are treated as ready because their persisted L0-L5 layers were already accepted by the older engine. Schema-v5 turn anchors are converted to per-thread Block positions; schema-v6 lift timestamps retain an unknown legacy source. Pre-v5 Blocks retain no inferred thread ownership, so they remain archival provenance without being attached to a new session. SQLite uses WAL, foreign keys, and per-namespace optimistic concurrency. It does not provide encryption at rest. Search still uses the reference in-memory ranking after hydration, so enabling persistence does not silently change retrieval semantics. Database-native lexical/vector indexes and a Postgres implementation remain separate future work.
|
|
244
|
+
SQLite schema v10 includes durable external-memory import jobs and per-candidate progress, in addition to the normalized Block processing state, summary/extraction retry jobs, graph, element, provenance, receipt, decay-anchor, and lift-source data introduced earlier. Opening a schema-v1 through v9 database migrates it in one transaction and preserves existing namespaces, Blocks, Events, jobs, and receipts. Existing pre-v9 Blocks are treated as ready because their persisted L0-L5 layers were already accepted by the older engine. Schema-v5 turn anchors are converted to per-thread Block positions; schema-v6 lift timestamps retain an unknown legacy source. Pre-v5 Blocks retain no inferred thread ownership, so they remain archival provenance without being attached to a new session. SQLite uses WAL, foreign keys, and per-namespace optimistic concurrency. It does not provide encryption at rest. Search still uses the reference in-memory ranking after hydration, so enabling persistence does not silently change retrieval semantics. Database-native lexical/vector indexes and a Postgres implementation remain separate future work.
|
package/docs/DSH.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# StrataGate for DeepSeek Harness
|
|
2
2
|
|
|
3
|
-
[English](../README.md) · [简体中文](DSH.zh-CN.md)
|
|
3
|
+
[English](../README.md) · [简体中文](DSH.zh-CN.md)
|
|
4
4
|
|
|
5
5
|
Automatic, local-first cross-session memory for DeepSeek Harness. StrataGate remembers user preferences, project decisions, completed conversations, and tool results, then checks recalled evidence and can expand it back to the original messages before the agent answers. No separate memory server is required.
|
|
6
6
|
|
|
@@ -10,11 +10,11 @@ The plugin adapts DSH session events to the existing StrataGate memory engine; i
|
|
|
10
10
|
|
|
11
11
|
### Knowledge graph and event timeline
|
|
12
12
|
|
|
13
|
-

|
|
13
|
+

|
|
14
14
|
|
|
15
15
|
### Layered short-term memory
|
|
16
16
|
|
|
17
|
-

|
|
17
|
+

|
|
18
18
|
|
|
19
19
|
## How it is designed
|
|
20
20
|
|
|
@@ -80,7 +80,7 @@ Removing the plugin does not delete that database.
|
|
|
80
80
|
- Subagent turns are not ingested by default; subagents in the same project can still read project memory.
|
|
81
81
|
- Each DSH turn has a durable ingestion receipt, so replay or retry cannot store it twice.
|
|
82
82
|
- StrataGate performs Block summarization, Event extraction, versioned Knowledge Graph projection, search, Evidence Gate, and use-only reinforcement.
|
|
83
|
-
- When a Block reaches its boundary, StrataGate first seals durable L3-L5 without touching the DSH surface. Only after validated L0-L2 and Event processing make the Block ready does the plugin use native surface `replace`; pending or failed Blocks keep their original conversation messages. Later decay, manual lift, or λ changes update only ready checkpoints. Unsealed open-tail messages and complete tool-call/result chains remain native DSH messages.
|
|
83
|
+
- When a Block reaches its boundary, StrataGate first seals durable L3-L5 without touching the DSH surface. Only after validated L0-L2 and Event processing make the Block ready does the plugin use native surface `replace`; pending or failed Blocks keep their original conversation messages. Later decay, manual lift, or λ changes update only ready checkpoints. Unsealed open-tail messages and complete tool-call/result chains remain native DSH messages.
|
|
84
84
|
- Before every main-model call, dynamic system context injects only up to four project-scoped activated Events and four active Graph nodes. It never serializes the current conversation, open tail, sealed Blocks, or tool calls into that prompt.
|
|
85
85
|
|
|
86
86
|
Activated memory uses the current human message plus the latest two open-tail turns from the current session as its query. Existing BM25 search remains the lexical relevance gate; pinned and safety memory are the only exceptions. Existing memory weights provide a second ranking, and RRF fuses the relevance and weight rankings. The activated section has a fixed budget of about 900 tokens, so it does not grow with the database.
|
|
@@ -131,9 +131,9 @@ Open DSH Settings and select **StrataGate-AgentMemory**. The page provides:
|
|
|
131
131
|
- manual Block expansion and a two-step external-memory import flow;
|
|
132
132
|
- a Usage Audit chain from a recorded answer turn, through the Evidence Gate verdict and selected memories, back to source messages.
|
|
133
133
|
|
|
134
|
-
Events, graph facts, and source messages cannot be edited, deleted, or approved in the UI. The UI can still change memory state in three explicit ways: manually expand a Block, import memory exported by another AI, and use Advanced Settings to change the completed turns per Block or the global Block decay coefficient λ. When the Block size changes, the UI explains their relationship and suggests a λ that preserves the decay rate per conversation turn; the user decides whether to adopt it. Saved settings immediately apply to every existing workspace, become the defaults for future workspaces, and survive restarts. Existing sealed Blocks are never repartitioned.
|
|
135
|
-
|
|
136
|
-
The UI validates and previews pasted `stratagate.external-memory.v2` JSON before writing. Malformed input uses a model-backed recovery fallback whose candidates always require review. Exact duplicates are ignored deterministically; the configured model adjudicates other candidates against Top-K local Events as add, merge, supersede, conflict, or ignore. Analysis jobs persist per-candidate progress in SQLite, resume after the import page is reopened, and let users choose the action for low-confidence decisions. High-confidence decisions remain automatic, and a committed import can be undone as one batch. Common token and credential patterns are redacted in message content and structured tool traces before they leave the local server. The SQLite database remains the source of truth.
|
|
134
|
+
Events, graph facts, and source messages cannot be edited, deleted, or approved in the UI. The UI can still change memory state in three explicit ways: manually expand a Block, import memory exported by another AI, and use Advanced Settings to change the completed turns per Block or the global Block decay coefficient λ. When the Block size changes, the UI explains their relationship and suggests a λ that preserves the decay rate per conversation turn; the user decides whether to adopt it. Saved settings immediately apply to every existing workspace, become the defaults for future workspaces, and survive restarts. Existing sealed Blocks are never repartitioned.
|
|
135
|
+
|
|
136
|
+
The UI validates and previews pasted `stratagate.external-memory.v2` JSON before writing. Malformed input uses a model-backed recovery fallback whose candidates always require review. Exact duplicates are ignored deterministically; the configured model adjudicates other candidates against Top-K local Events as add, merge, supersede, conflict, or ignore. Analysis jobs persist per-candidate progress in SQLite, resume after the import page is reopened, and let users choose the action for low-confidence decisions. High-confidence decisions remain automatic, and a committed import can be undone as one batch. Common token and credential patterns are redacted in message content and structured tool traces before they leave the local server. The SQLite database remains the source of truth.
|
|
137
137
|
|
|
138
138
|
## Configuration
|
|
139
139
|
|
|
@@ -145,13 +145,12 @@ config:
|
|
|
145
145
|
globalNamespace: global
|
|
146
146
|
blockTurnSize: 6
|
|
147
147
|
blockDecayLambda: 0.3
|
|
148
|
-
ingestSubagents: false
|
|
149
|
-
maxOutputTokens: 10000
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
# Optional: use a dedicated model for memory processing.
|
|
148
|
+
ingestSubagents: false
|
|
149
|
+
maxOutputTokens: 10000
|
|
150
|
+
structuredReasoningEffort: auto # auto | force-off
|
|
151
|
+
# Optional: use a dedicated model for memory processing.
|
|
153
152
|
# provider: deepseek
|
|
154
|
-
# model: deepseek-chat
|
|
153
|
+
# model: deepseek-chat
|
|
155
154
|
```
|
|
156
155
|
|
|
157
156
|
`blockTurnSize` and `blockDecayLambda` are initial fallbacks. Once changed in **Advanced Settings**, persisted UI values take precedence. λ defaults to `0.3`; smaller values forget more slowly and consume more tokens, and values above `0.4` are not recommended.
|
|
@@ -172,7 +171,7 @@ For diagnostics, the five most recent successful memory-model responses are reta
|
|
|
172
171
|
|
|
173
172
|
## Compatibility and permissions
|
|
174
173
|
|
|
175
|
-
Release gates exercise DSH `0.1.2-rc.1` on Node `24`, plus the core package on Node `22.19` and `24`. The published peer range accepts compatible DSH releases from `0.1.2-rc.1` up to, but not including, `0.2.0`.
|
|
174
|
+
Release gates exercise DSH `0.1.2-rc.1` on Node `24`, plus the core package on Node `22.19` and `24`. The published peer range accepts compatible DSH releases from `0.1.2-rc.1` up to, but not including, `0.2.0`.
|
|
176
175
|
|
|
177
176
|
The package declares local filesystem read/write and Harness tool registration. It does not request direct network, subprocess, shell, Python, or credential access. Model calls still flow through DSH's existing LLM service.
|
|
178
177
|
|
package/docs/DSH.zh-CN.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# StrataGate for DeepSeek Harness
|
|
2
2
|
|
|
3
|
-
[English](DSH.md) · [简体中文](../README.zh-CN.md)
|
|
3
|
+
[English](DSH.md) · [简体中文](../README.zh-CN.md)
|
|
4
4
|
|
|
5
5
|
面向 DeepSeek Harness 的自动、本地优先跨会话记忆。StrataGate 能够记住用户偏好、项目决策、已完成的对话和工具结果;Agent 回答前会检查找回的证据,并可将其展开追溯到原始消息。无需单独部署记忆服务器。
|
|
6
6
|
|
|
@@ -80,7 +80,7 @@ DSH_HOME/stratagate/memory.db
|
|
|
80
80
|
- 默认不保存子 Agent 的对话轮次;同一项目中的子 Agent 仍然可以读取项目记忆。
|
|
81
81
|
- 每个 DSH 对话轮次都有持久化的写入回执,因此重放或重试不会导致重复保存。
|
|
82
82
|
- StrataGate 会执行 Block 摘要、Event 提取、版本化 Knowledge Graph 投影、搜索、Evidence Gate(证据门控)以及仅在使用后触发的强化。
|
|
83
|
-
- Block 到达边界时,StrataGate 先持久化真实的 L3–L5,不修改 DSH surface。只有 L0–L2 校验通过且 Event 处理完成、Block 进入可衰减状态后,插件才使用原生 surface `replace`;待处理或失败的 Block 始终保留原始会话消息。后续衰减、手动提升或 λ 调整也只更新已就绪 checkpoint。尚未封存的 open tail 与完整工具调用/结果链继续作为 DSH 原生消息保留。
|
|
83
|
+
- Block 到达边界时,StrataGate 先持久化真实的 L3–L5,不修改 DSH surface。只有 L0–L2 校验通过且 Event 处理完成、Block 进入可衰减状态后,插件才使用原生 surface `replace`;待处理或失败的 Block 始终保留原始会话消息。后续衰减、手动提升或 λ 调整也只更新已就绪 checkpoint。尚未封存的 open tail 与完整工具调用/结果链继续作为 DSH 原生消息保留。
|
|
84
84
|
- 每次主模型调用前,动态系统上下文只注入最多 4 条项目级激活 Event 和 4 个 active Graph Node,不再序列化 Current conversation、open tail、已封 Block 或 tool calls。
|
|
85
85
|
|
|
86
86
|
激活查询由当前人类消息和当前会话 open tail 的最近两个 turn 组成。现有 BM25 搜索继续作为词面相关性门槛,只有 pinned 和 safety 记忆可以例外进入候选;现有记忆权重提供第二路排序,再由 RRF 融合相关性与权重排序。激活区固定使用约 900 tokens 的预算,不会随数据库增大而增长。
|
|
@@ -128,9 +128,9 @@ ID、`blockId`、角色、轮次和有界摘录。`narrative`、`quotes`、来
|
|
|
128
128
|
- 手动展开 Block,以及分两步导入其他 AI 的记忆;
|
|
129
129
|
- Usage Audit(使用审计)链路:从已记录的回答轮次出发,经由 Evidence Gate 的判断与选中的记忆,追溯到来源消息。
|
|
130
130
|
|
|
131
|
-
界面不允许直接编辑、删除或批准 Event、图谱事实和来源消息,但可以通过三种明确操作改变记忆状态:手动展开 Block、导入其他 AI 的记忆,以及在“高级设置”中修改每个 Block 包含的完整对话轮数或全局 Block 衰减系数 λ。修改轮数时,界面会解释两者关系并给出保持单位对话衰减速度的建议 λ,是否采用由用户决定。保存后设置立即应用到所有已有工作区,同时成为新工作区默认值,并在重启后保持;已封存 Block 不会重新切分。
|
|
132
|
-
|
|
133
|
-
当前界面会在写入前校验并预览粘贴的 `stratagate.external-memory.v2` JSON:不合格内容会进入模型兜底恢复,恢复候选全部需要人工确认。完全重复项会被确定性忽略,其余候选由当前模型结合 Top-K 本地 Event 判断新增、合并、取代、冲突或忽略。分析任务和逐条进度持久化到 SQLite,关闭并重新打开页面后会恢复进度;高置信度判断自动采用,低置信度项可由用户选择具体动作;提交后可按批次撤销。消息内容和结构化工具轨迹中的常见令牌及凭证格式,会在离开本地服务器前被脱敏。SQLite 数据库始终是唯一可信数据源。
|
|
131
|
+
界面不允许直接编辑、删除或批准 Event、图谱事实和来源消息,但可以通过三种明确操作改变记忆状态:手动展开 Block、导入其他 AI 的记忆,以及在“高级设置”中修改每个 Block 包含的完整对话轮数或全局 Block 衰减系数 λ。修改轮数时,界面会解释两者关系并给出保持单位对话衰减速度的建议 λ,是否采用由用户决定。保存后设置立即应用到所有已有工作区,同时成为新工作区默认值,并在重启后保持;已封存 Block 不会重新切分。
|
|
132
|
+
|
|
133
|
+
当前界面会在写入前校验并预览粘贴的 `stratagate.external-memory.v2` JSON:不合格内容会进入模型兜底恢复,恢复候选全部需要人工确认。完全重复项会被确定性忽略,其余候选由当前模型结合 Top-K 本地 Event 判断新增、合并、取代、冲突或忽略。分析任务和逐条进度持久化到 SQLite,关闭并重新打开页面后会恢复进度;高置信度判断自动采用,低置信度项可由用户选择具体动作;提交后可按批次撤销。消息内容和结构化工具轨迹中的常见令牌及凭证格式,会在离开本地服务器前被脱敏。SQLite 数据库始终是唯一可信数据源。
|
|
134
134
|
|
|
135
135
|
## 配置
|
|
136
136
|
|
|
@@ -142,13 +142,12 @@ config:
|
|
|
142
142
|
globalNamespace: global
|
|
143
143
|
blockTurnSize: 6
|
|
144
144
|
blockDecayLambda: 0.3
|
|
145
|
-
ingestSubagents: false
|
|
146
|
-
maxOutputTokens: 10000
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
# 可选:为记忆处理指定专用模型。
|
|
145
|
+
ingestSubagents: false
|
|
146
|
+
maxOutputTokens: 10000
|
|
147
|
+
structuredReasoningEffort: auto # auto | force-off
|
|
148
|
+
# 可选:为记忆处理指定专用模型。
|
|
150
149
|
# provider: deepseek
|
|
151
|
-
# model: deepseek-chat
|
|
150
|
+
# model: deepseek-chat
|
|
152
151
|
```
|
|
153
152
|
|
|
154
153
|
配置文件中的 `blockTurnSize` 和 `blockDecayLambda` 是初始后备值;一旦在“高级设置”中修改,持久化的界面值优先生效。λ 默认值为 `0.3`;数字越小,记忆遗忘越慢、消耗 token 越多,不建议大于 `0.4`。
|
|
@@ -169,7 +168,7 @@ config:
|
|
|
169
168
|
|
|
170
169
|
## 兼容性与权限
|
|
171
170
|
|
|
172
|
-
发布门禁会在 Node `24` 上测试 DSH `0.1.2-rc.1`,并在 Node `22.19` 和 `24` 上测试核心包。发布包声明的 peer 版本范围接受从 `0.1.2-rc.1` 开始、低于 `0.2.0` 的兼容 DSH 版本。
|
|
171
|
+
发布门禁会在 Node `24` 上测试 DSH `0.1.2-rc.1`,并在 Node `22.19` 和 `24` 上测试核心包。发布包声明的 peer 版本范围接受从 `0.1.2-rc.1` 开始、低于 `0.2.0` 的兼容 DSH 版本。
|
|
173
172
|
|
|
174
173
|
该包申请本地文件系统读写权限和 Harness 工具注册权限,不申请直接网络访问、子进程、Shell、Python 或凭证访问权限。模型调用仍通过 DSH 现有的 LLM 服务进行。
|
|
175
174
|
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
# 外部 AI 记忆导入
|
|
2
|
-
|
|
3
|
-
StrataGate 提供 `importExternalMemory()` 编排外部记忆迁移:
|
|
4
|
-
|
|
5
|
-
```text
|
|
6
|
-
外部 AI JSON
|
|
7
|
-
↓ extractor(候选 Event)
|
|
8
|
-
每个候选 Event → searchEvents()(确定性 BM25,Top-K)
|
|
9
|
-
↓ decider(ADD / MERGE / SUPERSEDE / CONFLICT / IGNORE)
|
|
10
|
-
写入新的规范 Event,保留来源和 supersedes/conflicts 关系
|
|
11
|
-
↓
|
|
12
|
-
只为新 Event 创建元素/知识图谱投影任务
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## 最小接入
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
import {
|
|
19
|
-
EXTERNAL_MEMORY_EXPORT_PROMPT_ZH_CN,
|
|
20
|
-
StrataGate,
|
|
21
|
-
externalMemoryJsonExtractor,
|
|
22
|
-
} from '@diqier/stratagate';
|
|
23
|
-
|
|
24
|
-
// 把 EXTERNAL_MEMORY_EXPORT_PROMPT_ZH_CN 交给外部 AI,并把它返回的 JSON 放入 text。
|
|
25
|
-
const result = await memory.importExternalMemory({
|
|
26
|
-
text,
|
|
27
|
-
extractor: externalMemoryJsonExtractor,
|
|
28
|
-
topK: 5,
|
|
29
|
-
decider: async ({ candidate, matches }) => {
|
|
30
|
-
// 这里通常调用你的 LLM;它只能从 matches 中选择 existingEventIds。
|
|
31
|
-
// 返回的 MERGE/SUPERSEDE 会创建新 Event,不会覆盖旧 Event。
|
|
32
|
-
return {
|
|
33
|
-
action: matches.length === 0 ? 'ADD' : 'MERGE',
|
|
34
|
-
existingEventIds: matches.slice(0, 1).map(({ event }) => event.id),
|
|
35
|
-
mergedCandidate: candidate,
|
|
36
|
-
};
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
`decider` 的 `matches` 已经被限制为 `topK` 条;即使模型返回其它事件 ID,库也会丢弃这些越界引用。`IGNORE` 只留下审计记录,不会写入 Event。`CONFLICT` 会在新旧事件两侧建立对称的 `conflictsWithEventIds`。
|
|
42
|
-
|
|
43
|
-
## 给外部 AI 的提示词
|
|
44
|
-
|
|
45
|
-
直接使用导出的 `EXTERNAL_MEMORY_EXPORT_PROMPT_ZH_CN`。它要求外部 AI 只输出 `stratagate.external-memory.v2` JSON,并区分 `memoryKind`(instruction/preference/fact/event)与 `category`,同时特别约束时间:
|
|
46
|
-
|
|
47
|
-
- `mentionedAt`(被提及时间)与 `happenedStart/happenedEnd`(实际发生/计划时间)分开;
|
|
48
|
-
- 没有明确时间或可靠参照时,不填写日期,不把当前时间、导出时间或聊天顺序当作事件时间;
|
|
49
|
-
- 保留 `originalText`,用 `precision` 和 `basis` 标记粒度与依据;
|
|
50
|
-
- “上周”等相对时间只有在能依据已知消息时间唯一换算时才转换,否则保持 `unknown`。
|
|
51
|
-
|
|
52
|
-
如果外部 AI 仍然返回 Markdown 代码块,`parseExternalMemoryExport()` 会自动去除围栏;其它非 JSON 文本会被拒绝,避免把模型解释误写进记忆。
|
|
53
|
-
|
|
54
|
-
用于第二阶段裁决的系统提示词可使用 `EXTERNAL_MEMORY_DECIDER_PROMPT_ZH_CN`。它明确规定了五种写入动作的边界,并要求模型只能引用本次 Top-K 结果中的事件 ID。
|
|
1
|
+
# 外部 AI 记忆导入
|
|
2
|
+
|
|
3
|
+
StrataGate 提供 `importExternalMemory()` 编排外部记忆迁移:
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
外部 AI JSON
|
|
7
|
+
↓ extractor(候选 Event)
|
|
8
|
+
每个候选 Event → searchEvents()(确定性 BM25,Top-K)
|
|
9
|
+
↓ decider(ADD / MERGE / SUPERSEDE / CONFLICT / IGNORE)
|
|
10
|
+
写入新的规范 Event,保留来源和 supersedes/conflicts 关系
|
|
11
|
+
↓
|
|
12
|
+
只为新 Event 创建元素/知识图谱投影任务
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 最小接入
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import {
|
|
19
|
+
EXTERNAL_MEMORY_EXPORT_PROMPT_ZH_CN,
|
|
20
|
+
StrataGate,
|
|
21
|
+
externalMemoryJsonExtractor,
|
|
22
|
+
} from '@diqier/stratagate';
|
|
23
|
+
|
|
24
|
+
// 把 EXTERNAL_MEMORY_EXPORT_PROMPT_ZH_CN 交给外部 AI,并把它返回的 JSON 放入 text。
|
|
25
|
+
const result = await memory.importExternalMemory({
|
|
26
|
+
text,
|
|
27
|
+
extractor: externalMemoryJsonExtractor,
|
|
28
|
+
topK: 5,
|
|
29
|
+
decider: async ({ candidate, matches }) => {
|
|
30
|
+
// 这里通常调用你的 LLM;它只能从 matches 中选择 existingEventIds。
|
|
31
|
+
// 返回的 MERGE/SUPERSEDE 会创建新 Event,不会覆盖旧 Event。
|
|
32
|
+
return {
|
|
33
|
+
action: matches.length === 0 ? 'ADD' : 'MERGE',
|
|
34
|
+
existingEventIds: matches.slice(0, 1).map(({ event }) => event.id),
|
|
35
|
+
mergedCandidate: candidate,
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`decider` 的 `matches` 已经被限制为 `topK` 条;即使模型返回其它事件 ID,库也会丢弃这些越界引用。`IGNORE` 只留下审计记录,不会写入 Event。`CONFLICT` 会在新旧事件两侧建立对称的 `conflictsWithEventIds`。
|
|
42
|
+
|
|
43
|
+
## 给外部 AI 的提示词
|
|
44
|
+
|
|
45
|
+
直接使用导出的 `EXTERNAL_MEMORY_EXPORT_PROMPT_ZH_CN`。它要求外部 AI 只输出 `stratagate.external-memory.v2` JSON,并区分 `memoryKind`(instruction/preference/fact/event)与 `category`,同时特别约束时间:
|
|
46
|
+
|
|
47
|
+
- `mentionedAt`(被提及时间)与 `happenedStart/happenedEnd`(实际发生/计划时间)分开;
|
|
48
|
+
- 没有明确时间或可靠参照时,不填写日期,不把当前时间、导出时间或聊天顺序当作事件时间;
|
|
49
|
+
- 保留 `originalText`,用 `precision` 和 `basis` 标记粒度与依据;
|
|
50
|
+
- “上周”等相对时间只有在能依据已知消息时间唯一换算时才转换,否则保持 `unknown`。
|
|
51
|
+
|
|
52
|
+
如果外部 AI 仍然返回 Markdown 代码块,`parseExternalMemoryExport()` 会自动去除围栏;其它非 JSON 文本会被拒绝,避免把模型解释误写进记忆。
|
|
53
|
+
|
|
54
|
+
用于第二阶段裁决的系统提示词可使用 `EXTERNAL_MEMORY_DECIDER_PROMPT_ZH_CN`。它明确规定了五种写入动作的边界,并要求模型只能引用本次 Top-K 结果中的事件 ID。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stratagate-dsh",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.61",
|
|
4
4
|
"description": "Recent conversations stay vivid. Older ones fade into summaries, not oblivion. StrataGate gives DeepSeek Harness six-layer, time-decaying memory, while lasting events and relationships settle into a knowledge graph. Bring your memories from other AIs with you—no need to start over.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"patch": "./cordis.patch.yml"
|
|
37
37
|
},
|
|
38
38
|
"client": {
|
|
39
|
-
"inject": [
|
|
40
|
-
"@deepseek-ai/dsh-client-ui-conversation"
|
|
39
|
+
"inject": [
|
|
40
|
+
"@deepseek-ai/dsh-client-ui-conversation"
|
|
41
41
|
],
|
|
42
42
|
"platform": "web"
|
|
43
43
|
}
|
|
@@ -110,8 +110,8 @@
|
|
|
110
110
|
"dispose": "supported"
|
|
111
111
|
},
|
|
112
112
|
"compatibility": {
|
|
113
|
-
"dshVersions": [
|
|
114
|
-
"0.1.2-rc.1"
|
|
113
|
+
"dshVersions": [
|
|
114
|
+
"0.1.2-rc.1"
|
|
115
115
|
]
|
|
116
116
|
},
|
|
117
117
|
"permissions": [
|
|
@@ -143,26 +143,26 @@
|
|
|
143
143
|
"engines": {
|
|
144
144
|
"node": "^22.19.0 || >=24.0.0"
|
|
145
145
|
},
|
|
146
|
-
"peerDependencies": {
|
|
147
|
-
"@deepseek-ai/cordis": "^4.0.1",
|
|
148
|
-
"@deepseek-ai/dsh-agent-default-model": ">=0.1.2-rc.1 <0.2.0",
|
|
149
|
-
"@deepseek-ai/dsh-client-ui-conversation": ">=0.1.2-rc.1 <0.2.0",
|
|
150
|
-
"@deepseek-ai/dsh-llm": ">=0.1.2-rc.1 <0.2.0",
|
|
151
|
-
"@deepseek-ai/dsh-session": ">=0.1.2-rc.1 <0.2.0",
|
|
152
|
-
"@deepseek-ai/dsh-settings": ">=0.1.2-rc.1 <0.2.0",
|
|
153
|
-
"@deepseek-ai/dsh-system-prompt": ">=0.1.2-rc.1 <0.2.0",
|
|
154
|
-
"@deepseek-ai/dsh-tools": ">=0.1.2-rc.1 <0.2.0",
|
|
146
|
+
"peerDependencies": {
|
|
147
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
148
|
+
"@deepseek-ai/dsh-agent-default-model": ">=0.1.2-rc.1 <0.2.0",
|
|
149
|
+
"@deepseek-ai/dsh-client-ui-conversation": ">=0.1.2-rc.1 <0.2.0",
|
|
150
|
+
"@deepseek-ai/dsh-llm": ">=0.1.2-rc.1 <0.2.0",
|
|
151
|
+
"@deepseek-ai/dsh-session": ">=0.1.2-rc.1 <0.2.0",
|
|
152
|
+
"@deepseek-ai/dsh-settings": ">=0.1.2-rc.1 <0.2.0",
|
|
153
|
+
"@deepseek-ai/dsh-system-prompt": ">=0.1.2-rc.1 <0.2.0",
|
|
154
|
+
"@deepseek-ai/dsh-tools": ">=0.1.2-rc.1 <0.2.0",
|
|
155
155
|
"@deepseek-ai/schemastery": "^3.18.1"
|
|
156
156
|
},
|
|
157
|
-
"devDependencies": {
|
|
158
|
-
"@deepseek-ai/cordis": "^4.0.1",
|
|
159
|
-
"@deepseek-ai/dsh-agent-default-model": "0.1.2-rc.1",
|
|
160
|
-
"@deepseek-ai/dsh-client-ui-conversation": "0.1.2-rc.1",
|
|
161
|
-
"@deepseek-ai/dsh-llm": "0.1.2-rc.1",
|
|
162
|
-
"@deepseek-ai/dsh-session": "0.1.2-rc.1",
|
|
163
|
-
"@deepseek-ai/dsh-settings": "0.1.2-rc.1",
|
|
164
|
-
"@deepseek-ai/dsh-system-prompt": "0.1.2-rc.1",
|
|
165
|
-
"@deepseek-ai/dsh-tools": "0.1.2-rc.1",
|
|
157
|
+
"devDependencies": {
|
|
158
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
159
|
+
"@deepseek-ai/dsh-agent-default-model": "0.1.2-rc.1",
|
|
160
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.1.2-rc.1",
|
|
161
|
+
"@deepseek-ai/dsh-llm": "0.1.2-rc.1",
|
|
162
|
+
"@deepseek-ai/dsh-session": "0.1.2-rc.1",
|
|
163
|
+
"@deepseek-ai/dsh-settings": "0.1.2-rc.1",
|
|
164
|
+
"@deepseek-ai/dsh-system-prompt": "0.1.2-rc.1",
|
|
165
|
+
"@deepseek-ai/dsh-tools": "0.1.2-rc.1",
|
|
166
166
|
"@deepseek-ai/schemastery": "^3.18.1",
|
|
167
167
|
"@types/node": "^22.0.0",
|
|
168
168
|
"cytoscape": "^3.34.1",
|
package/screenshots.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[
|
|
2
|
-
"docs/assets/stratagate-knowledge-graph.png",
|
|
3
|
-
"docs/assets/stratagate-short-term-memory.png"
|
|
4
|
-
]
|
|
1
|
+
[
|
|
2
|
+
"docs/assets/stratagate-knowledge-graph.png",
|
|
3
|
+
"docs/assets/stratagate-short-term-memory.png"
|
|
4
|
+
]
|