stratagate-dsh 0.2.84 → 0.2.87
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 +17 -0
- package/README.md +2 -1
- package/README.zh-CN.md +4 -1
- package/cordis.patch.yml +2 -0
- package/dist/client.js +3 -3
- package/dist/index.d.ts +41 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +41 -1
- package/dist/plugin.js +1365 -388
- package/dist/plugin.js.map +1 -1
- package/dist/repair-profile.js +1 -0
- package/dist/repair-profile.js.map +1 -1
- package/docs/DSH.md +43 -3
- package/docs/DSH.zh-CN.md +18 -3
- package/package.json +31 -30
package/dist/repair-profile.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/repair-profile.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { existsSync, lstatSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'\nimport { randomUUID } from 'node:crypto'\nimport { basename, dirname, join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst PROFILE_PACKAGES = [\n '@deepseek-ai/cordis',\n '@deepseek-ai/cosmokit',\n '@deepseek-ai/dsh-agent',\n '@deepseek-ai/dsh-agent-default-model',\n '@deepseek-ai/dsh-brand',\n '@deepseek-ai/dsh-client-ui-conversation',\n '@deepseek-ai/dsh-code-runtime',\n '@deepseek-ai/dsh-invariants',\n '@deepseek-ai/dsh-llm',\n '@deepseek-ai/dsh-scope',\n '@deepseek-ai/dsh-session',\n '@deepseek-ai/dsh-session-format',\n '@deepseek-ai/dsh-session-format-catalog',\n '@deepseek-ai/dsh-session-format-v0-to-v1',\n '@deepseek-ai/dsh-session-projection',\n '@deepseek-ai/dsh-settings',\n '@deepseek-ai/dsh-system-prompt',\n '@deepseek-ai/dsh-timeout',\n '@deepseek-ai/dsh-tools',\n '@deepseek-ai/dsh-typert-protocol',\n '@deepseek-ai/dsh-user-approval',\n '@deepseek-ai/dsh-util-crypto',\n '@deepseek-ai/dsh-util-values',\n '@deepseek-ai/schemastery',\n] as const\n\nfunction profileDirectory(start: string): string {\n let directory = start\n for (;;) {\n const manifestPath = join(directory, 'package.json')\n if (existsSync(manifestPath)) {\n try {\n const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as { dsh?: { profile?: unknown } }\n if (manifest.dsh?.profile && typeof manifest.dsh.profile === 'object') return directory\n } catch {}\n }\n const parent = dirname(directory)\n if (parent === directory) {\n throw new Error('stratagate-dsh-repair must run inside an installed DSH profile')\n }\n directory = parent\n }\n}\n\nfunction main(): void {\n const profile = profileDirectory(dirname(fileURLToPath(import.meta.url)))\n const modules = join(profile, 'node_modules')\n const candidates = PROFILE_PACKAGES\n .map((name) => ({ name, source: join(modules, ...name.split('/')) }))\n .filter(({ source }) => {\n try {\n lstatSync(source)\n return true\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false\n throw error\n }\n })\n if (candidates.length === 0) {\n process.stdout.write('StrataGate profile runtime is already isolated; no DSH peer residue found.\\n')\n return\n }\n\n const backup = join(profile, '.stratagate-runtime-backups', `${Date.now()}-${process.pid}-${randomUUID()}`)\n const moved: Array<{ name: string; source: string; target: string }> = []\n try {\n for (const candidate of candidates) {\n const target = join(backup, 'node_modules', ...candidate.name.split('/'))\n mkdirSync(dirname(target), { recursive: true })\n renameSync(candidate.source, target)\n moved.push({ ...candidate, target })\n }\n const receipt = {\n schema: 'stratagate-dsh-profile-runtime-repair/v1',\n profile,\n createdAt: new Date().toISOString(),\n packages: moved.map(({ name, source, target }) => ({ name, source, target })),\n recovery: `While DSH is stopped, move the listed targets back to their source paths if this repair must be reversed.`,\n }\n writeFileSync(join(backup, 'receipt.json'), `${JSON.stringify(receipt, null, 2)}\\n`, { flag: 'wx', mode: 0o600 })\n } catch (error) {\n for (const item of moved.reverse()) {\n if (existsSync(item.target) && !existsSync(item.source)) renameSync(item.target, item.source)\n }\n throw error\n }\n process.stdout.write(`Quarantined ${moved.length} stale DSH profile package(s) to ${backup}\\n`)\n}\n\ntry {\n main()\n} catch (error) {\n process.stderr.write(`${error instanceof Error ? error.stack ?? error.message : String(error)}\\n`)\n process.exitCode = 1\n}\n"],"mappings":";;;AACA,SAAS,YAAY,WAAW,WAAW,cAAc,YAAY,qBAAqB;AAC1F,SAAS,kBAAkB;AAC3B,SAAmB,SAAS,YAAY;AACxC,SAAS,qBAAqB;AAE9B,IAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,iBAAiB,OAAuB;AAC/C,MAAI,YAAY;AAChB,aAAS;AACP,UAAM,eAAe,KAAK,WAAW,cAAc;AACnD,QAAI,WAAW,YAAY,GAAG;AAC5B,UAAI;AACF,cAAM,WAAW,KAAK,MAAM,aAAa,cAAc,MAAM,CAAC;AAC9D,YAAI,SAAS,KAAK,WAAW,OAAO,SAAS,IAAI,YAAY,SAAU,QAAO;AAAA,MAChF,QAAQ;AAAA,MAAC;AAAA,IACX;AACA,UAAM,SAAS,QAAQ,SAAS;AAChC,QAAI,WAAW,WAAW;AACxB,YAAM,IAAI,MAAM,gEAAgE;AAAA,IAClF;AACA,gBAAY;AAAA,EACd;AACF;AAEA,SAAS,OAAa;AACpB,QAAM,UAAU,iBAAiB,QAAQ,cAAc,YAAY,GAAG,CAAC,CAAC;AACxE,QAAM,UAAU,KAAK,SAAS,cAAc;AAC5C,QAAM,aAAa,iBAChB,IAAI,CAAC,UAAU,EAAE,MAAM,QAAQ,KAAK,SAAS,GAAG,KAAK,MAAM,GAAG,CAAC,EAAE,EAAE,EACn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AAoC,MAAM;AAAA,CAAI;AAChG;AAEA,IAAI;AACF,OAAK;AACP,SAAS,OAAO;AACd,UAAQ,OAAO,MAAM,GAAG,iBAAiB,QAAQ,MAAM,SAAS,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,CAAI;AACjG,UAAQ,WAAW;AACrB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/repair-profile.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { existsSync, lstatSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs'\nimport { randomUUID } from 'node:crypto'\nimport { basename, dirname, join } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst PROFILE_PACKAGES = [\n '@deepseek-ai/cordis',\n '@deepseek-ai/cosmokit',\n '@deepseek-ai/dsh-agent',\n '@deepseek-ai/dsh-agent-default-model',\n '@deepseek-ai/dsh-brand',\n '@deepseek-ai/dsh-client-ui-conversation',\n '@deepseek-ai/dsh-code-runtime',\n '@deepseek-ai/dsh-invariants',\n '@deepseek-ai/dsh-llm',\n '@deepseek-ai/dsh-native-command',\n '@deepseek-ai/dsh-scope',\n '@deepseek-ai/dsh-session',\n '@deepseek-ai/dsh-session-format',\n '@deepseek-ai/dsh-session-format-catalog',\n '@deepseek-ai/dsh-session-format-v0-to-v1',\n '@deepseek-ai/dsh-session-projection',\n '@deepseek-ai/dsh-settings',\n '@deepseek-ai/dsh-system-prompt',\n '@deepseek-ai/dsh-timeout',\n '@deepseek-ai/dsh-tools',\n '@deepseek-ai/dsh-typert-protocol',\n '@deepseek-ai/dsh-user-approval',\n '@deepseek-ai/dsh-util-crypto',\n '@deepseek-ai/dsh-util-values',\n '@deepseek-ai/schemastery',\n] as const\n\nfunction profileDirectory(start: string): string {\n let directory = start\n for (;;) {\n const manifestPath = join(directory, 'package.json')\n if (existsSync(manifestPath)) {\n try {\n const manifest = JSON.parse(readFileSync(manifestPath, 'utf8')) as { dsh?: { profile?: unknown } }\n if (manifest.dsh?.profile && typeof manifest.dsh.profile === 'object') return directory\n } catch {}\n }\n const parent = dirname(directory)\n if (parent === directory) {\n throw new Error('stratagate-dsh-repair must run inside an installed DSH profile')\n }\n directory = parent\n }\n}\n\nfunction main(): void {\n const profile = profileDirectory(dirname(fileURLToPath(import.meta.url)))\n const modules = join(profile, 'node_modules')\n const candidates = PROFILE_PACKAGES\n .map((name) => ({ name, source: join(modules, ...name.split('/')) }))\n .filter(({ source }) => {\n try {\n lstatSync(source)\n return true\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false\n throw error\n }\n })\n if (candidates.length === 0) {\n process.stdout.write('StrataGate profile runtime is already isolated; no DSH peer residue found.\\n')\n return\n }\n\n const backup = join(profile, '.stratagate-runtime-backups', `${Date.now()}-${process.pid}-${randomUUID()}`)\n const moved: Array<{ name: string; source: string; target: string }> = []\n try {\n for (const candidate of candidates) {\n const target = join(backup, 'node_modules', ...candidate.name.split('/'))\n mkdirSync(dirname(target), { recursive: true })\n renameSync(candidate.source, target)\n moved.push({ ...candidate, target })\n }\n const receipt = {\n schema: 'stratagate-dsh-profile-runtime-repair/v1',\n profile,\n createdAt: new Date().toISOString(),\n packages: moved.map(({ name, source, target }) => ({ name, source, target })),\n recovery: `While DSH is stopped, move the listed targets back to their source paths if this repair must be reversed.`,\n }\n writeFileSync(join(backup, 'receipt.json'), `${JSON.stringify(receipt, null, 2)}\\n`, { flag: 'wx', mode: 0o600 })\n } catch (error) {\n for (const item of moved.reverse()) {\n if (existsSync(item.target) && !existsSync(item.source)) renameSync(item.target, item.source)\n }\n throw error\n }\n process.stdout.write(`Quarantined ${moved.length} stale DSH profile package(s) to ${backup}\\n`)\n}\n\ntry {\n main()\n} catch (error) {\n process.stderr.write(`${error instanceof Error ? error.stack ?? error.message : String(error)}\\n`)\n process.exitCode = 1\n}\n"],"mappings":";;;AACA,SAAS,YAAY,WAAW,WAAW,cAAc,YAAY,qBAAqB;AAC1F,SAAS,kBAAkB;AAC3B,SAAmB,SAAS,YAAY;AACx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ic context contains only compact Event and fact fields from other convers
|
|
|
89
89
|
|
|
90
90
|
Every explicit retrieval creates an independent batch. The model passes its `batch_id` to `memory_assess`, then closes that same batch with `memory_record_use`. It passes the exact `evidence_refs` from that batch used in its answer, or `[]` when it used none. Selected Event evidence is reinforced once; an empty list writes a zero-increment receipt with the real batch ID.
|
|
91
91
|
|
|
92
|
+
### Agent-recorded memory
|
|
93
|
+
|
|
94
|
+
`memory_remember` lets the agent record facts proactively: explicit user preferences or
|
|
95
|
+
corrections, decisions, durable project facts, or anything the user asks to remember.
|
|
96
|
+
Recordings enter the same long-term Event pipeline as conversation-derived memory, with
|
|
97
|
+
two differences:
|
|
98
|
+
|
|
99
|
+
- **Isolated storage.** Agent-recorded Events live in dedicated `agent_events` tables that
|
|
100
|
+
mirror the Event model but are physically separate from the passive conversation tables.
|
|
101
|
+
Their provenance cites the **real conversation messages** of the recording session — the
|
|
102
|
+
open-tail user/assistant messages when available, otherwise the latest sealed Block of
|
|
103
|
+
that thread — so no fabricated user message is ever created. Only when a session has no
|
|
104
|
+
ingested messages at all does a synthetic `agent-memory:` provenance Block get created.
|
|
105
|
+
- **Pre-write resolution.** Before writing, StrataGate searches existing memory (both pools)
|
|
106
|
+
for duplicates and conflicts. Exact and near duplicates reinforce the existing card instead
|
|
107
|
+
of writing a new one. Ambiguous lexical overlap triggers one synchronous model adjudication
|
|
108
|
+
reusing the external-memory decision contract: `ADD`, `MERGE`, `SUPERSEDE` (high confidence
|
|
109
|
+
only — low-confidence merge/supersede is downgraded to a non-destructive conflict mark),
|
|
110
|
+
`CONFLICT` (symmetric back-links), or `IGNORE`. The tool result reports `action`, `gate`,
|
|
111
|
+
and `reason`. Facts with no meaningful overlap write directly without a model call.
|
|
112
|
+
|
|
113
|
+
Everything else is ordinary Event behavior: agent recordings project into the Knowledge
|
|
114
|
+
Graph, persist across sessions, decay and reinforce through the same turn-based lifecycle
|
|
115
|
+
(`memory_assess` → `memory_record_use`), and can be forgotten through that lifecycle.
|
|
116
|
+
Retrieval gives each pool its own top-k lane — the passive pool and the agent pool are
|
|
117
|
+
ranked independently, then fused with weighted RRF, so neither pool can crowd the other
|
|
118
|
+
out of the result window. The agent lane's share is the configurable
|
|
119
|
+
`agentMemoryRetrievalWeight` (default `1` = equal footing; `0` = recordings stay stored but
|
|
120
|
+
never surface; higher values boost agent recordings), and cards carry
|
|
121
|
+
`source: 'agent-recorded'`. The memory dashboard lists them under
|
|
122
|
+
`/api/stratagate/agent-memories` (query parameters `session` and `includeArchived=true`).
|
|
123
|
+
The feature can be disabled entirely with `agentMemoryEnabled: false`, which also
|
|
124
|
+
unregisters the tool.
|
|
125
|
+
|
|
92
126
|
The plugin registers these tools:
|
|
93
127
|
|
|
94
128
|
```text
|
|
@@ -96,7 +130,7 @@ memory_search_events memory_expand_event
|
|
|
96
130
|
memory_search_graph memory_expand_graph_node
|
|
97
131
|
memory_search_raw memory_get_blocks
|
|
98
132
|
memory_expand_block memory_assess
|
|
99
|
-
memory_record_use
|
|
133
|
+
memory_record_use memory_remember
|
|
100
134
|
memory_profile_update
|
|
101
135
|
```
|
|
102
136
|
|
|
@@ -149,6 +183,8 @@ config:
|
|
|
149
183
|
blockTurnSize: 6
|
|
150
184
|
blockDecayLambda: 0.3
|
|
151
185
|
ingestSubagents: false
|
|
186
|
+
agentMemoryEnabled: true
|
|
187
|
+
agentMemoryRetrievalWeight: 1
|
|
152
188
|
maxOutputTokens: 10000
|
|
153
189
|
structuredTaskTimeoutMs: 120000
|
|
154
190
|
structuredReasoningEffort: auto # auto | force-off
|
|
@@ -165,6 +201,8 @@ config:
|
|
|
165
201
|
|
|
166
202
|
`blockDecayLambda` controls decay by the distance between a Block's pointer anchor and the latest sealed Block in the same DSH session. It defaults to `0.3`. Smaller values decay more slowly; values above `0.4` are not recommended. Turns in the open tail do not increase Block age.
|
|
167
203
|
|
|
204
|
+
`agentMemoryEnabled` (default `true`) controls agent-recorded memory (see above); disabling it also unregisters `memory_remember`. `agentMemoryRetrievalWeight` (default `1`, range `0`–`5`) sets the agent lane's share in merged retrieval. Recordings are stored in the same SQLite database as the rest of StrataGate data.
|
|
205
|
+
|
|
168
206
|
If `provider` and `model` are omitted, memory processing uses the session's latest request route, then the DSH default model as fallback. They must be configured as a pair.
|
|
169
207
|
|
|
170
208
|
## Privacy and failure behavior
|
|
@@ -175,9 +213,11 @@ For diagnostics, the five most recent successful memory-model responses are reta
|
|
|
175
213
|
|
|
176
214
|
## Compatibility and permissions
|
|
177
215
|
|
|
178
|
-
Release gates exercise the complete DSH `0.1.2-rc.1` family, `@deepseek-ai/dsh@0.1.5-rc.1`,
|
|
216
|
+
Release gates exercise the complete DSH `0.1.2-rc.1` family, `@deepseek-ai/dsh@0.1.5-rc.1`, `@deepseek-ai/dsh@0.1.6-alpha.1`, and `@deepseek-ai/dsh@0.1.7-rc.1` on Node `24`, on both Linux and Windows. The 0.1.5 CLI's real dependency tree resolves its internal DSH packages to `0.1.5-rc.2`; the 0.1.6 and 0.1.7 CLIs resolve the tested internal DSH and Session Format packages to their respective versions. The 0.1.7 host also supplies Cordis `4.0.4` and Schemastery `3.18.4`. The plugin declares these packages as optional, exact-version peers so the host supplies one coherent runtime instead of npm installing a second copy. Other `0.1.x` versions are not implicitly supported.
|
|
217
|
+
|
|
218
|
+
DSH core packages are host-provided optional peers. After upgrading a profile that once installed those peers locally, run `dsh plugin --profile <name> exec stratagate-dsh-repair` before starting it. The command moves only the known DSH runtime packages into `.stratagate-runtime-backups` inside that profile and writes a recovery receipt; it does not delete them or touch session data. At startup, a bootstrap resolver also forces StrataGate's own imports through the installation-owned module fallback, then verifies the resolved DSH core family and stops with an actionable error for an unknown host family. On DSH `0.1.5` through `0.1.7`, v0 sessions containing the retired `stratagate/memory-citations` event are copied to a validated v1 generation before the host continues its migration chain. The original v0 log is never modified; a `stratagate-legacy-citations-v1.json` receipt records source/target hashes and recovery instructions.
|
|
179
219
|
|
|
180
|
-
DSH
|
|
220
|
+
DSH 0.1.7 stores plugin configuration in the profile and presents live controls through config forms. StrataGate's chat settings use those forms on 0.1.7 and the older settings service on earlier supported hosts. Changing the structured reasoning effort takes effect on subsequent memory-model calls without a plugin restart.
|
|
181
221
|
|
|
182
222
|
DSH 0.1.6's official DeepSeek profile may enable Session Log request metadata by default, so the Host can include original Session Events in the `dsh_session_log` request field. This metadata is outside the model messages, system prompt, and tool schema and does not indicate that StrataGate compression was bypassed. StrataGate does not alter this DSH-wide setting; users who want it disabled should set `session-log-deepseek.enabled=false` through DSH configuration.
|
|
183
223
|
|
package/docs/DSH.zh-CN.md
CHANGED
|
@@ -89,6 +89,15 @@ DSH_HOME/stratagate/memory.db
|
|
|
89
89
|
|
|
90
90
|
每次主动检索都会创建独立批次。模型先把该批次的 `batch_id` 传给 `memory_assess`,再用 `memory_record_use` 结算同一批次。模型需要传入回答中实际使用且属于该批次的 `evidence_refs`;若一条也没有使用,则传入 `[]`。被选中的 Event 证据会强化一次,空数组会写入一条包含真实批次 ID 的零强化回执。
|
|
91
91
|
|
|
92
|
+
### Agent 主动记忆
|
|
93
|
+
|
|
94
|
+
`memory_remember` 让 agent 主动记录值得记忆的事实:用户明确的偏好或纠正、决定、持久的项目事实,以及用户要求记住的内容。记录会进入与对话派生记忆相同的长期 Event 管线,但有两点不同:
|
|
95
|
+
|
|
96
|
+
- **隔离存储。** agent 记录的 Event 存放在专属的 `agent_events` 隔离表中,数据模型与普通 Event 完全一致,但与被动对话表物理分离。其溯源直接引用**记录会话中的真实对话消息** —— 优先取 open tail 中的 user/assistant 消息,其次取该会话最新封存 Block 的消息 —— 绝不生成虚构的 user 消息。仅当会话中没有任何已摄取消息时,才会创建合成的 `agent-memory:` 溯源 Block。
|
|
97
|
+
- **写入前消解。** 写入前,StrataGate 会先在两个池中检索重复与冲突:精确或高度近似的重复会强化既有卡片而不新写;词面重叠模糊的记录会触发一次同步模型仲裁,复用外部记忆导入的决策契约 —— `ADD`、`MERGE`、`SUPERSEDE`(仅高置信度;低置信度的合并/取代会降级为非破坏性的冲突标记)、`CONFLICT`(双向回链)或 `IGNORE`。工具结果会回报 `action`、`gate` 与 `reason`。与既有记忆没有实质重叠的事实直接写入,不调用模型。
|
|
98
|
+
|
|
99
|
+
其余行为与普通 Event 一致:agent 记录会投影进 Knowledge Graph,跨会话持久保存,走同样的 turn 衰减与引用强化生命周期(`memory_assess` → `memory_record_use`),也可以通过该生命周期遗忘。检索为两个池各开一条独立的 top-k 通道 —— 被动池与 agent 池分别独立排序,再按加权 RRF 融合,任何一方都无法把另一方挤出结果窗口。agent 通道的占比由 `agentMemoryRetrievalWeight` 配置(默认 `1` = 平权;`0` = 记录保留但不再浮现;更大值提升 agent 记录的排序权重),卡片带 `source: 'agent-recorded'` 标记。记忆面板通过 `/api/stratagate/agent-memories`(查询参数 `session` 与 `includeArchived=true`)展示这些记录。可用 `agentMemoryEnabled: false` 整体关闭该功能,同时注销对应工具。
|
|
100
|
+
|
|
92
101
|
插件注册以下工具:
|
|
93
102
|
|
|
94
103
|
```text
|
|
@@ -96,7 +105,7 @@ memory_search_events memory_expand_event
|
|
|
96
105
|
memory_search_graph memory_expand_graph_node
|
|
97
106
|
memory_search_raw memory_get_blocks
|
|
98
107
|
memory_expand_block memory_assess
|
|
99
|
-
memory_record_use
|
|
108
|
+
memory_record_use memory_remember
|
|
100
109
|
memory_profile_update
|
|
101
110
|
```
|
|
102
111
|
|
|
@@ -146,6 +155,8 @@ config:
|
|
|
146
155
|
blockTurnSize: 6
|
|
147
156
|
blockDecayLambda: 0.3
|
|
148
157
|
ingestSubagents: false
|
|
158
|
+
agentMemoryEnabled: true
|
|
159
|
+
agentMemoryRetrievalWeight: 1
|
|
149
160
|
maxOutputTokens: 10000
|
|
150
161
|
structuredTaskTimeoutMs: 120000
|
|
151
162
|
structuredReasoningEffort: auto # auto | force-off
|
|
@@ -162,6 +173,8 @@ config:
|
|
|
162
173
|
|
|
163
174
|
`blockDecayLambda` 按当前 Block 锚点与同一 DSH 会话中最新已封存 Block 的距离控制衰减。默认值为 `0.3`;数字越小衰减越慢,不建议大于 `0.4`。open tail 中尚未封存的轮次不会增加 Block age。
|
|
164
175
|
|
|
176
|
+
`agentMemoryEnabled`(默认 `true`)控制 Agent 主动记忆(见上文);关闭后同时注销 `memory_remember`。`agentMemoryRetrievalWeight`(默认 `1`,范围 `0`–`5`)设置 agent 通道在融合检索中的占比。记录与其他 StrataGate 数据一样保存在同一个 SQLite 数据库中。
|
|
177
|
+
|
|
165
178
|
如果省略 `provider` 和 `model`,记忆处理会优先使用会话最近一次请求的路由,并以 DSH 默认模型作为后备。这两个配置项必须同时设置。
|
|
166
179
|
|
|
167
180
|
## 隐私与故障处理
|
|
@@ -172,9 +185,11 @@ config:
|
|
|
172
185
|
|
|
173
186
|
## 兼容性与权限
|
|
174
187
|
|
|
175
|
-
发布门禁会在 Node `24`、Linux 和 Windows 上测试完整的 DSH `0.1.2-rc.1`
|
|
188
|
+
发布门禁会在 Node `24`、Linux 和 Windows 上测试完整的 DSH `0.1.2-rc.1` 依赖族,以及 `@deepseek-ai/dsh@0.1.5-rc.1`、`@deepseek-ai/dsh@0.1.6-alpha.1` 和 `@deepseek-ai/dsh@0.1.7-rc.1`。0.1.5 CLI 的真实依赖树会把内部 DSH 包解析为 `0.1.5-rc.2`;0.1.6 和 0.1.7 CLI 的受测内部 DSH 与 Session Format 包分别解析为对应版本。0.1.7 宿主还提供 Cordis `4.0.4` 和 Schemastery `3.18.4`。插件将这些包声明为可选且精确版本的 peer,由宿主提供一套一致的运行时,避免 npm 在插件目录再安装第二套核心包;不会笼统承诺其他 `0.1.x` 版本。
|
|
189
|
+
|
|
190
|
+
DSH 核心包现在都是由宿主提供的可选 peer。若某个 profile 曾在本地安装这些 peer,升级后、启动前运行 `dsh plugin --profile <名称> exec stratagate-dsh-repair`。该命令只会把已知 DSH 运行时包移动到 profile 内的 `.stratagate-runtime-backups` 并写入恢复收据,不会删除包或触碰会话数据。启动时 bootstrap 还会把 StrataGate 自身的 DSH 导入定向到宿主维护的共享模块回退目录,再检查实际解析出的 DSH 核心族;未知宿主会立即给出明确错误并停止,而不是让正文区域空白。对于 DSH `0.1.5` 至 `0.1.7`,含已废弃 `stratagate/memory-citations` 事件的 v0 会话会先复制成经过校验的 v1 代际,再由宿主继续其迁移链;原始 v0 日志不会被修改,并写入 `stratagate-legacy-citations-v1.json` 记录源/目标哈希和恢复说明。
|
|
176
191
|
|
|
177
|
-
DSH
|
|
192
|
+
DSH 0.1.7 将插件配置保存在 profile 中,并通过配置表单提供实时控制。StrataGate 聊天界面中的设置在 0.1.7 使用配置表单,在之前受支持的宿主上继续使用旧设置服务。调整结构化任务的推理力度后,后续记忆模型调用会直接使用新值,无需重启插件。
|
|
178
193
|
|
|
179
194
|
DSH 0.1.6 的官方 DeepSeek profile 默认可能启用 Session Log 请求元数据,因此宿主可能把原始 Session Event 放入 `dsh_session_log` 请求字段。该元数据不属于模型 messages、system prompt 或 tool schema,不能据此判断 StrataGate 压缩失效。StrataGate 不会修改这一 DSH 全局设置;需要关闭的用户应通过 DSH 配置设置 `session-log-deepseek.enabled=false`。
|
|
180
195
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stratagate-dsh",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.87",
|
|
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",
|
|
@@ -116,7 +116,9 @@
|
|
|
116
116
|
"compatibility": {
|
|
117
117
|
"dshVersions": [
|
|
118
118
|
"0.1.2-rc.1",
|
|
119
|
-
"0.1.5-rc.1"
|
|
119
|
+
"0.1.5-rc.1",
|
|
120
|
+
"0.1.6-alpha.1",
|
|
121
|
+
"0.1.7-rc.1"
|
|
120
122
|
]
|
|
121
123
|
},
|
|
122
124
|
"permissions": [
|
|
@@ -149,19 +151,19 @@
|
|
|
149
151
|
"node": "^22.19.0 || >=24.0.0"
|
|
150
152
|
},
|
|
151
153
|
"peerDependencies": {
|
|
152
|
-
"@deepseek-ai/cordis": "4.0.2",
|
|
153
|
-
"@deepseek-ai/dsh-agent-default-model": "0.1.2-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1",
|
|
154
|
-
"@deepseek-ai/dsh-client-ui-conversation": "0.1.2-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1",
|
|
155
|
-
"@deepseek-ai/dsh-llm": "0.1.2-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1",
|
|
156
|
-
"@deepseek-ai/dsh-native-command": "0.1.2-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1",
|
|
157
|
-
"@deepseek-ai/dsh-session": "0.1.2-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1",
|
|
158
|
-
"@deepseek-ai/dsh-session-format": "0.1.5-rc.2 || 0.1.6-alpha.1",
|
|
159
|
-
"@deepseek-ai/dsh-session-format-catalog": "0.1.5-rc.2 || 0.1.6-alpha.1",
|
|
160
|
-
"@deepseek-ai/dsh-session-format-v0-to-v1": "0.1.5-rc.2 || 0.1.6-alpha.1",
|
|
161
|
-
"@deepseek-ai/dsh-settings": "0.1.2-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1",
|
|
162
|
-
"@deepseek-ai/dsh-system-prompt": "0.1.2-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1",
|
|
163
|
-
"@deepseek-ai/dsh-tools": "0.1.2-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1",
|
|
164
|
-
"@deepseek-ai/schemastery": "3.18.2"
|
|
154
|
+
"@deepseek-ai/cordis": "4.0.2 || 4.0.4",
|
|
155
|
+
"@deepseek-ai/dsh-agent-default-model": "0.1.2-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1 || 0.1.7-rc.1",
|
|
156
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.1.2-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1 || 0.1.7-rc.1",
|
|
157
|
+
"@deepseek-ai/dsh-llm": "0.1.2-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1 || 0.1.7-rc.1",
|
|
158
|
+
"@deepseek-ai/dsh-native-command": "0.1.2-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1 || 0.1.7-rc.1",
|
|
159
|
+
"@deepseek-ai/dsh-session": "0.1.2-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1 || 0.1.7-rc.1",
|
|
160
|
+
"@deepseek-ai/dsh-session-format": "0.1.5-rc.2 || 0.1.6-alpha.1 || 0.1.7-rc.1",
|
|
161
|
+
"@deepseek-ai/dsh-session-format-catalog": "0.1.5-rc.2 || 0.1.6-alpha.1 || 0.1.7-rc.1",
|
|
162
|
+
"@deepseek-ai/dsh-session-format-v0-to-v1": "0.1.5-rc.2 || 0.1.6-alpha.1 || 0.1.7-rc.1",
|
|
163
|
+
"@deepseek-ai/dsh-settings": "0.1.2-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1 || 0.1.7-rc.1",
|
|
164
|
+
"@deepseek-ai/dsh-system-prompt": "0.1.2-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1 || 0.1.7-rc.1",
|
|
165
|
+
"@deepseek-ai/dsh-tools": "0.1.2-rc.1 || 0.1.5-rc.2 || 0.1.6-alpha.1 || 0.1.7-rc.1",
|
|
166
|
+
"@deepseek-ai/schemastery": "3.18.2 || 3.18.4"
|
|
165
167
|
},
|
|
166
168
|
"peerDependenciesMeta": {
|
|
167
169
|
"@deepseek-ai/cordis": {
|
|
@@ -205,21 +207,20 @@
|
|
|
205
207
|
}
|
|
206
208
|
},
|
|
207
209
|
"devDependencies": {
|
|
208
|
-
"@deepseek-ai/cordis": "4.0.
|
|
209
|
-
"@deepseek-ai/dsh": "0.1.
|
|
210
|
-
"@deepseek-ai/dsh-agent-default-model": "0.1.
|
|
211
|
-
"@deepseek-ai/dsh-client-ui-conversation": "0.1.
|
|
212
|
-
"@deepseek-ai/dsh-llm": "0.1.
|
|
213
|
-
"@deepseek-ai/dsh-native-command": "0.1.
|
|
214
|
-
"@deepseek-ai/dsh-session": "0.1.
|
|
215
|
-
"@deepseek-ai/dsh-session-format": "0.1.
|
|
216
|
-
"@deepseek-ai/dsh-session-format-catalog": "0.1.
|
|
217
|
-
"@deepseek-ai/dsh-session-format-v0-to-v1": "0.1.
|
|
218
|
-
"@deepseek-ai/dsh-settings": "0.1.
|
|
219
|
-
"@deepseek-ai/dsh-
|
|
220
|
-
"@deepseek-ai/dsh-
|
|
221
|
-
"@deepseek-ai/
|
|
222
|
-
"@deepseek-ai/schemastery": "3.18.2",
|
|
210
|
+
"@deepseek-ai/cordis": "4.0.4",
|
|
211
|
+
"@deepseek-ai/dsh": "0.1.7-rc.1",
|
|
212
|
+
"@deepseek-ai/dsh-agent-default-model": "0.1.7-rc.1",
|
|
213
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.1.7-rc.1",
|
|
214
|
+
"@deepseek-ai/dsh-llm": "0.1.7-rc.1",
|
|
215
|
+
"@deepseek-ai/dsh-native-command": "0.1.7-rc.1",
|
|
216
|
+
"@deepseek-ai/dsh-session": "0.1.7-rc.1",
|
|
217
|
+
"@deepseek-ai/dsh-session-format": "0.1.7-rc.1",
|
|
218
|
+
"@deepseek-ai/dsh-session-format-catalog": "0.1.7-rc.1",
|
|
219
|
+
"@deepseek-ai/dsh-session-format-v0-to-v1": "0.1.7-rc.1",
|
|
220
|
+
"@deepseek-ai/dsh-settings": "0.1.7-rc.1",
|
|
221
|
+
"@deepseek-ai/dsh-system-prompt": "0.1.7-rc.1",
|
|
222
|
+
"@deepseek-ai/dsh-tools": "0.1.7-rc.1",
|
|
223
|
+
"@deepseek-ai/schemastery": "3.18.4",
|
|
223
224
|
"@types/node": "^22.0.0",
|
|
224
225
|
"cytoscape": "^3.34.1",
|
|
225
226
|
"cytoscape-fcose": "^2.2.0",
|