refactor(session): separate persistence plugin entrypoints
This commit is contained in:
1 parent
0d8fbdd956
commit
669c1ceaab
24 files changed
+374
-54
No files matched your search
@@ -63,6 +63,7 @@
|
||||
"@deepseek-ai/dsh-schedule": "workspace:*",
|
||||
"@deepseek-ai/dsh-sdk-app": "workspace:*",
|
||||
"@deepseek-ai/dsh-sdk-minimal": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-persistence-sqlite": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-projection": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-reference": "workspace:*",
|
||||
"@deepseek-ai/dsh-skill": "workspace:*",
|
||||
|
||||
+15
-1
@@ -3269,7 +3269,7 @@ export type SessionLogCompressionLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
||||
|
||||
## `@deepseek-ai/dsh-session-persistence-jsonl`
|
||||
|
||||
- `source`: [`packages/session/session-persistence-jsonl/src/index.ts:95`](../packages/session/session-persistence-jsonl/src/index.ts)
|
||||
- `source`: [`packages/session/session-persistence-jsonl/src/index.ts:108`](../packages/session/session-persistence-jsonl/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Plugin config for the JSONL backend's root, physical encoding, and listing concurrency. */
|
||||
@@ -3297,6 +3297,20 @@ export type JsonlCompression = 'zstd' | 'none'
|
||||
```
|
||||
<!-- END GENERATED config-catalog:@deepseek-ai/dsh-session-persistence-jsonl -->
|
||||
|
||||
<!-- BEGIN GENERATED config-catalog:@deepseek-ai/dsh-session-persistence-sqlite -->
|
||||
<a id="deepseek-aidsh-session-persistence-sqlite"></a>
|
||||
|
||||
## `@deepseek-ai/dsh-session-persistence-sqlite`
|
||||
|
||||
- `refs`: [`JsonlConfigOptions`](#deepseek-aidsh-session-persistence-jsonl)
|
||||
- `source`: [`packages/session/session-persistence-sqlite/src/index.ts:13`](../packages/session/session-persistence-sqlite/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Storage root and JSONL settings used when importing legacy Sessions. */
|
||||
export type Config = JsonlConfigOptions
|
||||
```
|
||||
<!-- END GENERATED config-catalog:@deepseek-ai/dsh-session-persistence-sqlite -->
|
||||
|
||||
<!-- BEGIN GENERATED config-catalog:@deepseek-ai/dsh-session-projection-cache -->
|
||||
<a id="deepseek-aidsh-session-projection-cache"></a>
|
||||
|
||||
|
||||
@@ -3271,7 +3271,7 @@ export type SessionLogCompressionLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
||||
|
||||
## `@deepseek-ai/dsh-session-persistence-jsonl`
|
||||
|
||||
- `source`: [`packages/session/session-persistence-jsonl/src/index.ts:95`](../packages/session/session-persistence-jsonl/src/index.ts)
|
||||
- `source`: [`packages/session/session-persistence-jsonl/src/index.ts:108`](../packages/session/session-persistence-jsonl/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Plugin config for the JSONL backend's root, physical encoding, and listing concurrency. */
|
||||
@@ -3299,6 +3299,20 @@ export type JsonlCompression = 'zstd' | 'none'
|
||||
```
|
||||
<!-- END GENERATED config-catalog:@deepseek-ai/dsh-session-persistence-jsonl -->
|
||||
|
||||
<!-- BEGIN GENERATED config-catalog:@deepseek-ai/dsh-session-persistence-sqlite -->
|
||||
<a id="deepseek-aidsh-session-persistence-sqlite"></a>
|
||||
|
||||
## `@deepseek-ai/dsh-session-persistence-sqlite`
|
||||
|
||||
- `refs`: [`JsonlConfigOptions`](#deepseek-aidsh-session-persistence-jsonl)
|
||||
- `source`: [`packages/session/session-persistence-sqlite/src/index.ts:13`](../packages/session/session-persistence-sqlite/src/index.ts)
|
||||
|
||||
```ts config-catalog
|
||||
/** Storage root and JSONL settings used when importing legacy Sessions. */
|
||||
export type Config = JsonlConfigOptions
|
||||
```
|
||||
<!-- END GENERATED config-catalog:@deepseek-ai/dsh-session-persistence-sqlite -->
|
||||
|
||||
<!-- BEGIN GENERATED config-catalog:@deepseek-ai/dsh-session-projection-cache -->
|
||||
<a id="deepseek-aidsh-session-projection-cache"></a>
|
||||
|
||||
|
||||
@@ -73,9 +73,9 @@ Application listeners are outside this package matrix. Desktop Host subscribes t
|
||||
| `schedule/resolve-agent` | `waterfall` | [`packages/schedule/schedule/src/index.ts:72`](../packages/schedule/schedule/src/index.ts) | [`schedule`](../packages/schedule/schedule) (`waterfall`) | `server` |
|
||||
| `session-telemetry/record` | `waterfall` | [`packages/session/session-telemetry/src/index.ts:44`](../packages/session/session-telemetry/src/index.ts) | [`session-telemetry`](../packages/session/session-telemetry) (`waterfall`) | - |
|
||||
| `session/created` | `emit` | [`packages/core/session/src/index.ts:56`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | `server`, `session-controller`, [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry) |
|
||||
| `session/disposed` | `emit` | [`packages/core/session/src/index.ts:65`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`agent-loop`](../packages/core/agent-loop), `file-upload`, `forge-session`, [`office-kit`](../packages/document/office-kit), `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-title`](../packages/session/session-title), `ui-trajectory`, [`workspace-changes`](../packages/deliverables/workspace-changes) |
|
||||
| `session/event` | `emit` | [`packages/core/session/src/index.ts:79`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`acp`](../packages/acp/acp), [`agent-instructions`](../packages/context/agent-instructions), [`agent-loop`](../packages/core/agent-loop), [`agent-preset-registry`](../packages/preset/agent-preset-registry), `claude-code-mods`, `client-ui-forge`, [`compaction-basic`](../packages/compaction/compaction-basic), [`file-reference-local`](../packages/context/file-reference-local), `file-upload`, `forge-session`, [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), [`loader-smoke`](../packages/test-support/loader-smoke), `product-analytics`, [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), `server`, `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-telemetry-otel`](../packages/session/session-telemetry-otel), [`session-title`](../packages/session/session-title), [`subagent`](../packages/subagent/subagent), [`timeline`](../packages/experimental/timeline), [`token-meter`](../packages/llm/token-meter), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tool-jobs`](../packages/jobs/tool-jobs), [`tool-office`](../packages/document/tool-office), `ui-session-status`, `ui-trajectory`, [`user-questions`](../packages/interaction/user-questions), [`workspace-changes`](../packages/deliverables/workspace-changes) |
|
||||
| `session/flush` | `parallel` | [`packages/core/session/src/index.ts:87`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-telemetry`](../packages/session/session-telemetry) |
|
||||
| `session/disposed` | `emit` | [`packages/core/session/src/index.ts:65`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`agent-loop`](../packages/core/agent-loop), `file-upload`, `forge-session`, [`office-kit`](../packages/document/office-kit), `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-persistence-sqlite`](../packages/session/session-persistence-sqlite), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-title`](../packages/session/session-title), `ui-trajectory`, [`workspace-changes`](../packages/deliverables/workspace-changes) |
|
||||
| `session/event` | `emit` | [`packages/core/session/src/index.ts:79`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`acp`](../packages/acp/acp), [`agent-instructions`](../packages/context/agent-instructions), [`agent-loop`](../packages/core/agent-loop), [`agent-preset-registry`](../packages/preset/agent-preset-registry), `claude-code-mods`, `client-ui-forge`, [`compaction-basic`](../packages/compaction/compaction-basic), [`file-reference-local`](../packages/context/file-reference-local), `file-upload`, `forge-session`, [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), [`loader-smoke`](../packages/test-support/loader-smoke), `product-analytics`, [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), `server`, `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-persistence-sqlite`](../packages/session/session-persistence-sqlite), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-telemetry-otel`](../packages/session/session-telemetry-otel), [`session-title`](../packages/session/session-title), [`subagent`](../packages/subagent/subagent), [`timeline`](../packages/experimental/timeline), [`token-meter`](../packages/llm/token-meter), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tool-jobs`](../packages/jobs/tool-jobs), [`tool-office`](../packages/document/tool-office), `ui-session-status`, `ui-trajectory`, [`user-questions`](../packages/interaction/user-questions), [`workspace-changes`](../packages/deliverables/workspace-changes) |
|
||||
| `session/flush` | `parallel` | [`packages/core/session/src/index.ts:87`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-persistence-sqlite`](../packages/session/session-persistence-sqlite), [`session-telemetry`](../packages/session/session-telemetry) |
|
||||
| `settings/document-updated` | `emit` | [`packages/settings/settings/src/types.ts:75`](../packages/settings/settings/src/types.ts) | [`settings`](../packages/settings/settings) (`emit`) | `remotes` |
|
||||
| `skills/change` | `emit` | [`packages/skill/skill/src/index.ts:299`](../packages/skill/skill/src/index.ts) | [`skill`](../packages/skill/skill) (`events.dispatch`) | - |
|
||||
| `subagent/end` | `emit` | [`packages/subagent/subagent/src/index.ts:166`](../packages/subagent/subagent/src/index.ts) | [`subagent`](../packages/subagent/subagent) (`events.dispatch`) | [`hooks-claude-code`](../packages/experimental/hooks-claude-code), `server` |
|
||||
|
||||
@@ -75,9 +75,9 @@
|
||||
| `schedule/resolve-agent` | `waterfall` | [`packages/schedule/schedule/src/index.ts:72`](../packages/schedule/schedule/src/index.ts) | [`schedule`](../packages/schedule/schedule) (`waterfall`) | `server` |
|
||||
| `session-telemetry/record` | `waterfall` | [`packages/session/session-telemetry/src/index.ts:44`](../packages/session/session-telemetry/src/index.ts) | [`session-telemetry`](../packages/session/session-telemetry) (`waterfall`) | - |
|
||||
| `session/created` | `emit` | [`packages/core/session/src/index.ts:56`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | `server`, `session-controller`, [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry) |
|
||||
| `session/disposed` | `emit` | [`packages/core/session/src/index.ts:65`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`agent-loop`](../packages/core/agent-loop), `file-upload`, `forge-session`, [`office-kit`](../packages/document/office-kit), `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-title`](../packages/session/session-title), `ui-trajectory`, [`workspace-changes`](../packages/deliverables/workspace-changes) |
|
||||
| `session/event` | `emit` | [`packages/core/session/src/index.ts:79`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`acp`](../packages/acp/acp), [`agent-instructions`](../packages/context/agent-instructions), [`agent-loop`](../packages/core/agent-loop), [`agent-preset-registry`](../packages/preset/agent-preset-registry), `claude-code-mods`, `client-ui-forge`, [`compaction-basic`](../packages/compaction/compaction-basic), [`file-reference-local`](../packages/context/file-reference-local), `file-upload`, `forge-session`, [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), [`loader-smoke`](../packages/test-support/loader-smoke), `product-analytics`, [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), `server`, `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-telemetry-otel`](../packages/session/session-telemetry-otel), [`session-title`](../packages/session/session-title), [`subagent`](../packages/subagent/subagent), [`timeline`](../packages/experimental/timeline), [`token-meter`](../packages/llm/token-meter), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tool-jobs`](../packages/jobs/tool-jobs), [`tool-office`](../packages/document/tool-office), `ui-session-status`, `ui-trajectory`, [`user-questions`](../packages/interaction/user-questions), [`workspace-changes`](../packages/deliverables/workspace-changes) |
|
||||
| `session/flush` | `parallel` | [`packages/core/session/src/index.ts:87`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-telemetry`](../packages/session/session-telemetry) |
|
||||
| `session/disposed` | `emit` | [`packages/core/session/src/index.ts:65`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`agent-loop`](../packages/core/agent-loop), `file-upload`, `forge-session`, [`office-kit`](../packages/document/office-kit), `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-persistence-sqlite`](../packages/session/session-persistence-sqlite), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-title`](../packages/session/session-title), `ui-trajectory`, [`workspace-changes`](../packages/deliverables/workspace-changes) |
|
||||
| `session/event` | `emit` | [`packages/core/session/src/index.ts:79`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`acp`](../packages/acp/acp), [`agent-instructions`](../packages/context/agent-instructions), [`agent-loop`](../packages/core/agent-loop), [`agent-preset-registry`](../packages/preset/agent-preset-registry), `claude-code-mods`, `client-ui-forge`, [`compaction-basic`](../packages/compaction/compaction-basic), [`file-reference-local`](../packages/context/file-reference-local), `file-upload`, `forge-session`, [`goal`](../packages/goal/goal), [`goal-round-driver`](../packages/goal/goal-round-driver), [`headless`](../packages/bundle/headless), [`loader-smoke`](../packages/test-support/loader-smoke), `product-analytics`, [`ptc-runtime-node`](../packages/ptc-runtime/ptc-runtime-node), `server`, `session-controller`, [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-persistence-sqlite`](../packages/session/session-persistence-sqlite), [`session-projection`](../packages/session/session-projection), [`session-projection-cache`](../packages/session/session-projection-cache), [`session-telemetry`](../packages/session/session-telemetry), [`session-telemetry-otel`](../packages/session/session-telemetry-otel), [`session-title`](../packages/session/session-title), [`subagent`](../packages/subagent/subagent), [`timeline`](../packages/experimental/timeline), [`token-meter`](../packages/llm/token-meter), [`tool-executor-ptc`](../packages/core/tool-executor-ptc), [`tool-jobs`](../packages/jobs/tool-jobs), [`tool-office`](../packages/document/tool-office), `ui-session-status`, `ui-trajectory`, [`user-questions`](../packages/interaction/user-questions), [`workspace-changes`](../packages/deliverables/workspace-changes) |
|
||||
| `session/flush` | `parallel` | [`packages/core/session/src/index.ts:87`](../packages/core/session/src/index.ts) | [`session`](../packages/core/session) (`events.dispatch`) | [`session-persistence-jsonl`](../packages/session/session-persistence-jsonl), [`session-persistence-sqlite`](../packages/session/session-persistence-sqlite), [`session-telemetry`](../packages/session/session-telemetry) |
|
||||
| `settings/document-updated` | `emit` | [`packages/settings/settings/src/types.ts:75`](../packages/settings/settings/src/types.ts) | [`settings`](../packages/settings/settings) (`emit`) | `remotes` |
|
||||
| `skills/change` | `emit` | [`packages/skill/skill/src/index.ts:299`](../packages/skill/skill/src/index.ts) | [`skill`](../packages/skill/skill) (`events.dispatch`) | - |
|
||||
| `subagent/end` | `emit` | [`packages/subagent/subagent/src/index.ts:166`](../packages/subagent/subagent/src/index.ts) | [`subagent`](../packages/subagent/subagent) (`events.dispatch`) | [`hooks-claude-code`](../packages/experimental/hooks-claude-code), `server` |
|
||||
|
||||
@@ -33,7 +33,7 @@ export const IMAGE_HOME_DIRECTORY = 'home'
|
||||
* logs stay plaintext.
|
||||
*/
|
||||
export const PLATFORM_ENTRY_CONFIG: Readonly<Record<string, Readonly<Record<string, unknown>>>> = {
|
||||
'session-persistence-jsonl': { storage: 'jsonl', compression: 'none' },
|
||||
'session-persistence-jsonl': { compression: 'none' },
|
||||
}
|
||||
|
||||
/** Working directories the host tree expects to exist, empty. */
|
||||
|
||||
@@ -394,6 +394,7 @@ Every package below exports a Cordis plugin that a bundle patch can name in a Lo
|
||||
| `@deepseek-ai/dsh-session-checkpoint-policy` | no | Semantic session durability checkpoints before model requests and tool side effects |
|
||||
| `@deepseek-ai/dsh-session-log-deepseek` | yes | Incremental lossless session-log request extension for the official DeepSeek LLM API |
|
||||
| `@deepseek-ai/dsh-session-persistence-jsonl` | yes | JSONL durable session persistence backend for the DeepSeek Harness |
|
||||
| `@deepseek-ai/dsh-session-persistence-sqlite` | yes | SQLite Session event storage backend for the DeepSeek Harness |
|
||||
| `@deepseek-ai/dsh-session-projection` | no | Session-projection seam: the merge-extensible projection type table, the provider contract, and the ctx.sessionProjections registry serving whole current values of log-derived per-session state |
|
||||
| `@deepseek-ai/dsh-session-projection-cache` | yes | Persisted projection cache (ctx.sessionProjectionCache): durable per-session checkpoint records on the session_projcache storage domain (per-record layout), throttled write-behind, and the cached listing read |
|
||||
| `@deepseek-ai/dsh-session-stats` | no | Whole-log conversation counts and wall times projection (sessionStats) for the DeepSeek Harness |
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
en: 7be50f4cafe40dab
|
||||
zh: a6f06f187e686c05
|
||||
/session-durable-session-data-plane/packages/persistence:
|
||||
en: cbe033c3f37b8aa7
|
||||
zh: 69aa84f0712d0111
|
||||
en: cde30f2c79c348ff
|
||||
zh: c469cbe220d7df01
|
||||
/session-durable-session-data-plane/packages/projection:
|
||||
en: 706441e1ab2fa853
|
||||
zh: a7fa44caab3ddada
|
||||
|
||||
@@ -37,6 +37,7 @@ The group splits into four families: durable storage (persistence seam, backends
|
||||
| [`session-format-catalog/`](session-format-catalog/README.md) | Generated static catalog of shipped adjacent migrations | library — no ctx key |
|
||||
| [`session-persistence/`](session-persistence/README.md) | Defines the durable session-storage service and the shared write coordination every backend composes | `ctx.sessionPersistence` |
|
||||
| [`session-persistence-jsonl/`](session-persistence-jsonl/README.md) | Shipped backend: immutable canonical generation filenames per Session with exclusive successor publication, optionally Zstandard-compressed | registers on `ctx.sessionPersistence` |
|
||||
| [`session-persistence-sqlite/`](session-persistence-sqlite/README.md) | Optional SQLite provider with first-open JSONL import | registers on `ctx.sessionPersistence` |
|
||||
| [`session-checkpoint-policy/`](session-checkpoint-policy/README.md) | Makes model requests, top-level tool side effects, and completed steps durable before the next action | wraps `ctx.llm` and `ctx.tools` |
|
||||
| [`session-log-deepseek/`](session-log-deepseek/README.md) | Uploads the incremental canonical log as optional official DeepSeek request metadata | contributes `dsh_session_log` |
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ session 组让对话持久保存,恢复已发布的日志格式,并使已提
|
||||
| [`session-format-catalog/`](session-format-catalog/README.zh.md) | 自动生成的已交付相邻迁移静态目录 | 库,不使用 ctx key |
|
||||
| [`session-persistence/`](session-persistence/README.zh.md) | 定义持久会话存储服务,以及每个后端组合的共享写入协调机制 | `ctx.sessionPersistence` |
|
||||
| [`session-persistence-jsonl/`](session-persistence-jsonl/README.zh.md) | 随产品交付的后端:逐 Session 使用不可变规范 generation 文件名并排他发布后继;可选 Zstandard 压缩 | 注册到 `ctx.sessionPersistence` |
|
||||
| [`session-persistence-sqlite/`](session-persistence-sqlite/README.zh.md) | 可选 SQLite 提供方,在首次打开时导入 JSONL | 注册到 `ctx.sessionPersistence` |
|
||||
| [`session-checkpoint-policy/`](session-checkpoint-policy/README.zh.md) | 让模型请求、顶层工具副作用与已完成步骤在下一步动作前持久化 | 包装 `ctx.llm` 与 `ctx.tools` |
|
||||
| [`session-log-deepseek/`](session-log-deepseek/README.zh.md) | 把增量规范日志作为可选的官方 DeepSeek 请求元数据上传 | 贡献 `dsh_session_log` |
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
en: d6112142a705ec43
|
||||
zh: f0914d9e37216f97
|
||||
/deepseek-ai-dsh-session-persistence-jsonl/use-this-package/when-to-choose-it:
|
||||
en: 37c10302bbbde268
|
||||
zh: 3d5c027bac868efd
|
||||
en: 18c781c0f9fb9edc
|
||||
zh: 1232b4b1be24289f
|
||||
/deepseek-ai-dsh-session-persistence-jsonl/use-this-package/minimal-configuration:
|
||||
en: b6c2f0f11f2fa9cf
|
||||
zh: 9fac03fcbe5bbad4
|
||||
@@ -36,8 +36,8 @@
|
||||
en: a35407bb25671e7e
|
||||
zh: 6a00f9510c85adcb
|
||||
/deepseek-ai-dsh-session-persistence-jsonl/understand-the-implementation/design-concept:
|
||||
en: a422bd0f74a5b31a
|
||||
zh: edc47e9530c87f67
|
||||
en: 93aaee9b27c4e532
|
||||
zh: 010a92d51074dfdf
|
||||
/deepseek-ai-dsh-session-persistence-jsonl/understand-the-implementation/physical-encoding:
|
||||
en: 5aaf80115840318f
|
||||
zh: 0b0fb2b2e085a111
|
||||
|
||||
@@ -29,7 +29,7 @@ Mount this backend when a composition needs durable sessions backed by per-sessi
|
||||
|
||||
### When to choose it
|
||||
|
||||
Choose this backend when consumers benefit from one artifact per session — navigation, external tooling, or a raw line-readable log. It is the sole first-party Session-persistence provider. The backend keeps sessions under a deployment-controlled root: project-local, shared, temporary, or centralized.
|
||||
Choose this backend when consumers benefit from one artifact per session — navigation, external tooling, or a raw line-readable log. The [SQLite provider](../session-persistence-sqlite/README.md) offers database storage with legacy JSONL import. The backend keeps sessions under a deployment-controlled root: project-local, shared, temporary, or centralized.
|
||||
|
||||
### Minimal configuration
|
||||
|
||||
@@ -104,7 +104,7 @@ This section explains the physical encoding and write path; the observable contr
|
||||
|
||||
### Design concept
|
||||
|
||||
The backend owns its complete storage runtime (`src/storage.ts`): `JsonlSessionHandle` carries the per-handle mutation chain, the routed live-event buffer with its fixed batching window and single-flight drain, monotonic reads, and idempotent close; a tracker holds the in-process single-writer claims, the open-handle set teardown sweeps, and the created-but-unmaterialized pending sessions the backend's own session listeners route into. Historical body reads share one per-session Decode/Migrate preparation, and a bounded revision-keyed memo lets an immediate observe-to-resume handoff reuse that parse; the backend deep-freezes each event graph once before memoization, so later handle reads reuse it without copying or freezing. Only a write open publishes the prepared successor. The package exposes plugin exports and configuration types — the concrete class is private, so consumers couple to `ctx.sessionPersistence`, and the shared seam suites (`runPersistenceContract`/`runLiveWritePathContract`) pin its observable behavior. Physical revisions combine device, inode, size, and nanosecond timestamps for the preparation memo, stable-read retries, and publication checks. Historical public revisions add a SHA-256 fingerprint of sorted selected paths and their physical revisions; lock files and retained unselected generations do not contribute.
|
||||
The backend owns its complete storage runtime (`src/storage.ts`): `JsonlSessionHandle` carries the per-handle mutation chain, the routed live-event buffer with its fixed batching window and single-flight drain, monotonic reads, and idempotent close; a tracker holds the in-process single-writer claims, the open-handle set teardown sweeps, and the created-but-unmaterialized pending sessions the backend's own session listeners route into. Historical body reads share one per-session Decode/Migrate preparation, and a bounded revision-keyed memo lets an immediate observe-to-resume handoff reuse that parse; the backend deep-freezes each event graph once before memoization, so later handle reads reuse it without copying or freezing. Only a write open publishes the prepared successor. The package exports its plugin, configuration types, and `JsonlSessionPersistence` for SQLite-owned historical reads; application consumers continue using `ctx.sessionPersistence`, and the shared seam suites (`runPersistenceContract`/`runLiveWritePathContract`) pin its observable behavior. Physical revisions combine device, inode, size, and nanosecond timestamps for the preparation memo, stable-read retries, and publication checks. Historical public revisions add a SHA-256 fingerprint of sorted selected paths and their physical revisions; lock files and retained unselected generations do not contribute.
|
||||
|
||||
### Physical encoding
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ kind: "package-reference"
|
||||
|
||||
### 何时选择
|
||||
|
||||
当消费方受益于每会话一份产物——导航、外部工具或可逐行读取的原始日志——时选择此后端。它是唯一的第一方会话持久化提供方。后端把会话保存在部署控制的根下:项目本地、共享、临时或集中式。
|
||||
当消费方受益于每会话一份产物——导航、外部工具或可逐行读取的原始日志——时选择此后端。[SQLite 提供方](../session-persistence-sqlite/README.zh.md)提供数据库存储,并支持导入旧 JSONL。后端把会话保存在部署控制的根下:项目本地、共享、临时或集中式。
|
||||
|
||||
### 最小配置
|
||||
|
||||
@@ -104,7 +104,7 @@ kind: "package-reference"
|
||||
|
||||
### 设计理念
|
||||
|
||||
该后端拥有自己完整的存储运行时(`src/storage.ts`):`JsonlSessionHandle` 承载逐句柄修改链、带固定批处理窗口与 single-flight 排空的已路由实时事件缓冲、单调读取与幂等 close;一个 tracker 持有进程内单写者认领、teardown 清扫所遍历的打开句柄集合,以及后端自己的会话监听器所路由进的已创建但未实体化待定会话。历史正文读取共享每个 Session 唯一的一次 Decode/Migrate preparation,按 revision 为键的有界 memo 让紧接的观察到恢复交接复用该解析;backend 在 memo 化前只对每个 event graph 深度冻结一次,因此后续 handle read 无需复制或再次冻结。只有写 open 才发布准备好的后继。本包暴露插件导出与配置类型——具体类是私有的,因此消费方只耦合 `ctx.sessionPersistence`,其可观察行为由共享 seam 测试套件(`runPersistenceContract`/`runLiveWritePathContract`)钉住。物理修订号组合 device、inode、size 与纳秒时间戳,供准备缓存、稳定读取重试及发布检查使用。历史格式的公开修订号还加入所选路径排序后及其物理修订号的 SHA-256 指纹;锁文件与保留但未被选中的代际不参与计算。
|
||||
该后端拥有自己完整的存储运行时(`src/storage.ts`):`JsonlSessionHandle` 承载逐句柄修改链、带固定批处理窗口与 single-flight 排空的已路由实时事件缓冲、单调读取与幂等 close;一个 tracker 持有进程内单写者认领、teardown 清扫所遍历的打开句柄集合,以及后端自己的会话监听器所路由进的已创建但未实体化待定会话。历史正文读取共享每个 Session 唯一的一次 Decode/Migrate preparation,按 revision 为键的有界 memo 让紧接的观察到恢复交接复用该解析;backend 在 memo 化前只对每个 event graph 深度冻结一次,因此后续 handle read 无需复制或再次冻结。只有写 open 才发布准备好的后继。本包暴露插件、配置类型和供 SQLite 后端复用历史读取的 `JsonlSessionPersistence`;应用消费方继续使用 `ctx.sessionPersistence`,其可观察行为由共享 seam 测试套件(`runPersistenceContract`/`runLiveWritePathContract`)钉住。物理修订号组合 device、inode、size 与纳秒时间戳,供准备缓存、稳定读取重试及发布检查使用。历史格式的公开修订号还加入所选路径排序后及其物理修订号的 SHA-256 指纹;锁文件与保留但未被选中的代际不参与计算。
|
||||
|
||||
### 物理编码
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
"@deepseek-ai/dsh-session-format": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-format-catalog": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-format-v3-to-v4": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-persistence-sqlite": "workspace:*",
|
||||
"@deepseek-ai/node-addon-system": "workspace:~",
|
||||
"@deepseek-ai/schemastery": "workspace:~",
|
||||
"koffi": "3.1.1",
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
*/
|
||||
|
||||
import { Context, type Fiber } from '@deepseek-ai/cordis'
|
||||
import '@deepseek-ai/dsh-session-persistence'
|
||||
import { TracePersistence } from '@deepseek-ai/dsh-session-persistence-sqlite'
|
||||
import z from '@deepseek-ai/schemastery'
|
||||
import {
|
||||
createSessionFormatCatalogWithChildren,
|
||||
@@ -23,6 +21,7 @@ import { scheduler } from 'node:timers/promises'
|
||||
import { createHash, randomBytes } from 'node:crypto'
|
||||
import pLimit, { type LimitFunction } from 'p-limit'
|
||||
import {
|
||||
SessionPersistence,
|
||||
SessionFormatUnsupportedError,
|
||||
SessionPersistenceCorruptionError,
|
||||
SessionAlreadyExistsError, SessionPersistenceNotFoundError,
|
||||
@@ -60,8 +59,17 @@ import {
|
||||
type PreparedJsonlMigration,
|
||||
} from './generation.ts'
|
||||
|
||||
type JsonlBackend = ConstructorParameters<typeof TracePersistence>[3]
|
||||
type PreparedLegacySession = Awaited<ReturnType<JsonlBackend['prepare']>>
|
||||
/** Logical JSONL history retained until its destination commits under write ownership. */
|
||||
interface LegacySessionSnapshot {
|
||||
readonly header: SessionHeader
|
||||
readonly inheritedEventCount: SessionLogOffsetType
|
||||
readonly events: readonly SessionEvent[]
|
||||
}
|
||||
|
||||
/** Prepared legacy history whose related sources are checked before destination publication. */
|
||||
interface PreparedLegacySession extends LegacySessionSnapshot {
|
||||
commit(publish: (snapshot: LegacySessionSnapshot) => Promise<void>): Promise<void>
|
||||
}
|
||||
|
||||
export type { JsonlCompression } from './format.ts'
|
||||
|
||||
@@ -98,8 +106,6 @@ const DEFAULT_LIST_CONCURRENCY = 3
|
||||
|
||||
/** Plugin config for the JSONL backend's root, physical encoding, and listing concurrency. */
|
||||
export interface Config {
|
||||
/** Storage for Sessions; defaults to JSONL. SQLite explicitly enables legacy import. */
|
||||
storage?: 'sqlite' | 'jsonl'
|
||||
/**
|
||||
* Root directory for all session files. Required (no default): a default of
|
||||
* `process.cwd()` would scatter session files as the process's cwd changes
|
||||
@@ -312,17 +318,12 @@ function waitWithAbort<T>(operation: Promise<T>, signal?: AbortSignal): Promise<
|
||||
}
|
||||
|
||||
/**
|
||||
* Existing JSONL storage used to read historical Sessions during SQLite import.
|
||||
* JSONL Session persistence with historical-format migration.
|
||||
* Sessions materialize lazily: a created session is
|
||||
* visible to this process immediately, reaches disk on its first append or
|
||||
* flush, and never existed if the process crashes before that.
|
||||
*/
|
||||
class JsonlSessionPersistence implements JsonlBackend {
|
||||
/** Process-local identity used by persistence observation caches. */
|
||||
readonly identity: symbol = Symbol('sessionPersistence')
|
||||
/** Backend label for diagnostics and effects. */
|
||||
readonly name = 'session-persistence-jsonl'
|
||||
|
||||
export class JsonlSessionPersistence extends SessionPersistence {
|
||||
private root: string
|
||||
private compression: JsonlCompression
|
||||
/**
|
||||
@@ -357,7 +358,14 @@ class JsonlSessionPersistence implements JsonlBackend {
|
||||
/** One joinable decode/migration operation per selected historical Session file revision. */
|
||||
private readonly migrationPreparations = new Map<SessionId, MigrationPreparation>()
|
||||
|
||||
constructor(private readonly ctx: Context, public config: Config, private readonly tracker: JsonlBackendTracker) {
|
||||
/**
|
||||
* @param ctx - context used for scoped diagnostics and filesystem reads.
|
||||
* @param config - JSONL root, physical encoding, and listing concurrency.
|
||||
* @param tracker - handle bookkeeping; omitted creates bookkeeping for legacy reads.
|
||||
*/
|
||||
constructor(ctx: Context, public config: Config,
|
||||
private readonly tracker = new JsonlBackendTracker('session-persistence-jsonl')) {
|
||||
super(ctx)
|
||||
/* v8 ignore next 5 -- generated catalog and Session source share one build-time version owner. */
|
||||
if (sessionFormatCatalog.currentVersion !== SESSION_FORMAT_VERSION) {
|
||||
throw new Error(
|
||||
@@ -389,7 +397,12 @@ class JsonlSessionPersistence implements JsonlBackend {
|
||||
return { kind: 'jsonl', path: logPath(this.root, meta.cwd, meta.id, this.compression) }
|
||||
}
|
||||
|
||||
/** Prepare existing logical history for SQLite while the caller retains Session ownership. */
|
||||
/**
|
||||
* Prepare logical history while the caller retains Session write ownership.
|
||||
* @param id - stored Session identity.
|
||||
* @param signal - optional cancellation for decoding and destination publication.
|
||||
* @returns history and a commit operation that validates related sources before publication.
|
||||
*/
|
||||
async prepare(id: SessionId, signal?: AbortSignal): Promise<PreparedLegacySession> {
|
||||
await this.ensureRootEncoding()
|
||||
signal?.throwIfAborted()
|
||||
@@ -403,7 +416,11 @@ class JsonlSessionPersistence implements JsonlBackend {
|
||||
} }
|
||||
}
|
||||
|
||||
/** Whether a legacy artifact already occupies this Session identity. */
|
||||
/**
|
||||
* Check whether a JSONL artifact occupies the Session identity.
|
||||
* @param id - stored Session identity.
|
||||
* @returns whether the artifact exists.
|
||||
*/
|
||||
async hasStoredJsonl(id: SessionId): Promise<boolean> {
|
||||
await this.ensureRootEncoding()
|
||||
return await this.findLog(id) !== undefined
|
||||
@@ -740,7 +757,7 @@ class JsonlSessionPersistence implements JsonlBackend {
|
||||
const sources = await children()
|
||||
const related = await prepareCatalogFacts(id, sources, this.compression, signal)
|
||||
for (const failure of related.failures) {
|
||||
this.ctx.logger.warn(`${this.name}: session "${id}" catalog retained a child with unknown descriptor (raw log: ${failure.path}): ${String(failure.error)}`)
|
||||
this.ctx.logger.warn(`${name}: session "${id}" catalog retained a child with unknown descriptor (raw log: ${failure.path}): ${String(failure.error)}`)
|
||||
}
|
||||
const membership = sources.map(source => source.path).sort()
|
||||
validateRelatedSources = async () => {
|
||||
@@ -995,7 +1012,7 @@ class JsonlSessionPersistence implements JsonlBackend {
|
||||
async truncateTornTail(header: SessionHeader, truncateTo: number): Promise<void> {
|
||||
this.coldLogMemo.delete(header.id)
|
||||
await this.repair(header, truncateTo)
|
||||
this.ctx.logger.warn(`${this.name}: session "${header.id}" recovered from a torn tail; incomplete tail bytes were discarded`)
|
||||
this.ctx.logger.warn(`${name}: session "${header.id}" recovered from a torn tail; incomplete tail bytes were discarded`)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1892,7 +1909,6 @@ export const name = 'session-persistence-jsonl'
|
||||
|
||||
/** Loader schema for the backend's root, physical encoding, and listing concurrency. */
|
||||
export const Config: z<Config> = z.object({
|
||||
storage: z.union([z.const('sqlite'), z.const('jsonl')]).default('jsonl'),
|
||||
root: z.string().required(),
|
||||
compression: JsonlCompressionSchema,
|
||||
listConcurrency: z.natural().min(1).default(DEFAULT_LIST_CONCURRENCY),
|
||||
@@ -1916,13 +1932,8 @@ export async function apply(ctx: Context, config: Config): Promise<void> {
|
||||
service = ctx.plugin({
|
||||
name: 'session-persistence-jsonl-service',
|
||||
apply(serviceCtx: Context) {
|
||||
const legacy = new JsonlSessionPersistence(serviceCtx, config, tracker)
|
||||
if (config.storage !== 'sqlite') {
|
||||
tracker.install(segments.ctx)
|
||||
serviceCtx.provide('sessionPersistence', legacy)
|
||||
return
|
||||
}
|
||||
new TracePersistence(serviceCtx, segments.ctx, config.root, legacy)
|
||||
tracker.install(segments.ctx)
|
||||
new JsonlSessionPersistence(serviceCtx, config, tracker)
|
||||
},
|
||||
})
|
||||
yield service.dispose
|
||||
|
||||
@@ -40,9 +40,6 @@
|
||||
},
|
||||
{
|
||||
"path": "../session-format-v3-to-v4"
|
||||
},
|
||||
{
|
||||
"path": "../session-persistence-sqlite"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
|
||||
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
|
||||
# After editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/session/session-persistence-sqlite/README.md
|
||||
/:
|
||||
en: 41aded9a1a358caf
|
||||
zh: a26bdb1b0a5bb29f
|
||||
/deepseek-ai-dsh-session-persistence-sqlite:
|
||||
en: 22cf683fb8ec6976
|
||||
zh: c4c0244b1b7340bd
|
||||
/deepseek-ai-dsh-session-persistence-sqlite/summary:
|
||||
en: 0c2d3cfbff915c15
|
||||
zh: ccf1f73680574484
|
||||
/deepseek-ai-dsh-session-persistence-sqlite/table-of-contents:
|
||||
en: b563e4ec4727d0de
|
||||
zh: 0b283b30acc898ed
|
||||
/deepseek-ai-dsh-session-persistence-sqlite/use-this-package:
|
||||
en: 9cda015eba91ac02
|
||||
zh: 0646d4625a15535c
|
||||
/deepseek-ai-dsh-session-persistence-sqlite/understand-the-implementation:
|
||||
en: 0fedbac9938c1c3b
|
||||
zh: 9be02ab1175bd7b2
|
||||
/deepseek-ai-dsh-session-persistence-sqlite/further-exploration:
|
||||
en: 133df48b9cd05d67
|
||||
zh: 7024d007a0b10082
|
||||
/deepseek-ai-dsh-session-persistence-sqlite/model-experience:
|
||||
en: 215e7ba838619b7b
|
||||
zh: a311da3843709f90
|
||||
/deepseek-ai-dsh-session-persistence-sqlite/model-experience/persisted-history:
|
||||
en: 010d35cf2ef5b758
|
||||
zh: d57e7bc5d6d92a3d
|
||||
/deepseek-ai-dsh-session-persistence-sqlite/model-experience/persisted-history/what-the-model-sees:
|
||||
en: 3950e76b8ae1b1b4
|
||||
zh: dc32341e2f212a52
|
||||
/deepseek-ai-dsh-session-persistence-sqlite/model-experience/persisted-history/token-effect:
|
||||
en: ee6aa5668004664c
|
||||
zh: 71f1056c8821e043
|
||||
/deepseek-ai-dsh-session-persistence-sqlite/model-experience/persisted-history/kv-cache-effect:
|
||||
en: 2917f1a38ac3fede
|
||||
zh: 586b1ea29d200336
|
||||
/deepseek-ai-dsh-session-persistence-sqlite/known-limitations-and-deferred-work:
|
||||
en: 565ba240c0d04b6c
|
||||
zh: 702d48592c9cd883
|
||||
/deepseek-ai-dsh-session-persistence-sqlite/known-limitations-and-deferred-work/dev-note:
|
||||
en: b836f01bd0bceb4a
|
||||
zh: 25e979141fbe5501
|
||||
@@ -0,0 +1,96 @@
|
||||
---
|
||||
description: "Use SQLite for durable Sessions and import existing JSONL history when opening it."
|
||||
kind: "package-reference"
|
||||
---
|
||||
|
||||
# @deepseek-ai/dsh-session-persistence-sqlite
|
||||
|
||||
English | [中文](README.zh.md)
|
||||
|
||||
## Summary
|
||||
|
||||
Save new Sessions in SQLite and import old JSONL history on first open. Consumers keep using the existing Session persistence API. The source JSONL files remain on disk.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Use this package](#use-this-package)
|
||||
- [Understand the implementation](#understand-the-implementation)
|
||||
- [Further Exploration](#further-exploration)
|
||||
- [Model Experience](#model-experience)
|
||||
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
|
||||
|
||||
-----
|
||||
|
||||
<a id="use-this-package"></a>
|
||||
## Use this package
|
||||
|
||||
Select this provider in the global `$DSH_HOME/cordis.patch.yml` for profiles based on `dsh-base`:
|
||||
|
||||
```yaml
|
||||
- id: session-persistence-jsonl
|
||||
disabled: true
|
||||
- insert:
|
||||
- id: session-persistence-sqlite
|
||||
name: '@deepseek-ai/dsh-session-persistence-sqlite'
|
||||
config:
|
||||
root: !!js dshHomePath('sessions')
|
||||
```
|
||||
|
||||
The standalone `sdk-minimal` profile calls its JSONL entry `sessions`; use that id in its profile patch. The selected provider registers `ctx.sessionPersistence`. The default shipped composition remains JSONL.
|
||||
|
||||
| Field | Default | Meaning |
|
||||
|---|---|---|
|
||||
| `root` | required | Session root; the database is `<root>/.segments/sessions.sqlite` |
|
||||
| `compression` | `zstd` | Encoding used by the legacy JSONL reader; SQLite events are uncompressed JSON |
|
||||
| `listConcurrency` | `3` | Maximum concurrent legacy metadata reads |
|
||||
|
||||
<a id="understand-the-implementation"></a>
|
||||
## Understand the implementation
|
||||
|
||||
<details>
|
||||
<summary>Storage and migration</summary>
|
||||
|
||||
The SQLite plugin depends on the JSONL package for history reading and adjacent version migration. Its isolated JSONL reader does not replace the application's SQLite persistence service. `stat()` and `list()` inspect metadata; opening a legacy Session imports its complete logical history into one root Segment. Concurrent readers join the import, and write access retains the existing single-writer ownership rules. Source files stay unchanged.
|
||||
|
||||
Provider startup and disposal live in [the plugin entry](src/index.ts); [migration](src/migration.ts) coordinates import, and [persistence](src/persistence.ts) serves the existing API.
|
||||
|
||||
</details>
|
||||
|
||||
<a id="further-exploration"></a>
|
||||
## Further Exploration
|
||||
|
||||
- [Session persistence API](../session-persistence/README.md)
|
||||
- [JSONL storage](../session-persistence-jsonl/README.md)
|
||||
- [Historical format migration](../session-format-catalog/README.md)
|
||||
|
||||
<a id="model-experience"></a>
|
||||
## Model Experience
|
||||
|
||||
### Persisted history
|
||||
|
||||
#### What the model sees
|
||||
|
||||
This plugin adds no request content. Session consumers read the stored logical event history through `ctx.sessionPersistence`.
|
||||
|
||||
#### Token effect
|
||||
|
||||
There is no direct token effect.
|
||||
|
||||
#### KV Cache effect
|
||||
|
||||
The storage medium does not alter the logical event history or add a model-request prefix.
|
||||
|
||||
## Known Limitations and Deferred Work
|
||||
|
||||
<a id="known-limitations-and-deferred-work"></a>
|
||||
|
||||
- Selecting JSONL again does not export SQLite history back into the retained JSONL files.
|
||||
|
||||
### Dev Note
|
||||
|
||||
<details>
|
||||
<summary>Working context for maintainers</summary>
|
||||
|
||||
None.
|
||||
|
||||
</details>
|
||||
@@ -0,0 +1,96 @@
|
||||
---
|
||||
description: "使用 SQLite 持久化会话,并在打开时导入已有 JSONL 历史。"
|
||||
kind: "package-reference"
|
||||
---
|
||||
|
||||
# @deepseek-ai/dsh-session-persistence-sqlite
|
||||
|
||||
[English](README.md) | 中文
|
||||
|
||||
## 概述
|
||||
|
||||
将新会话存入 SQLite,并在首次打开旧 JSONL 会话时导入历史。调用方继续使用原有会话持久化 API。源 JSONL 文件保留在磁盘上。
|
||||
|
||||
## 目录
|
||||
|
||||
- [使用本包](#use-this-package)
|
||||
- [理解实现](#understand-the-implementation)
|
||||
- [延伸阅读](#further-exploration)
|
||||
- [模型体验](#model-experience)
|
||||
- [已知限制与后续工作](#known-limitations-and-deferred-work)
|
||||
|
||||
-----
|
||||
|
||||
<a id="use-this-package"></a>
|
||||
## 使用本包
|
||||
|
||||
对于基于 `dsh-base` 的配置方案,在全局 `$DSH_HOME/cordis.patch.yml` 中选择此提供者:
|
||||
|
||||
```yaml
|
||||
- id: session-persistence-jsonl
|
||||
disabled: true
|
||||
- insert:
|
||||
- id: session-persistence-sqlite
|
||||
name: '@deepseek-ai/dsh-session-persistence-sqlite'
|
||||
config:
|
||||
root: !!js dshHomePath('sessions')
|
||||
```
|
||||
|
||||
独立的 `sdk-minimal` 配置方案将 JSONL 加载项命名为 `sessions`;在其方案补丁中使用这个 id。所选提供者注册 `ctx.sessionPersistence`。默认发布的配置仍使用 JSONL。
|
||||
|
||||
| 字段 | 默认值 | 含义 |
|
||||
|---|---|---|
|
||||
| `root` | 必填 | 会话根目录;数据库位于 `<root>/.segments/sessions.sqlite` |
|
||||
| `compression` | `zstd` | 旧 JSONL 读取器使用的编码;SQLite 事件是未压缩的 JSON |
|
||||
| `listConcurrency` | `3` | 旧历史元数据读取的最大并发数 |
|
||||
|
||||
<a id="understand-the-implementation"></a>
|
||||
## 理解实现
|
||||
|
||||
<details>
|
||||
<summary>存储与迁移</summary>
|
||||
|
||||
SQLite 插件依赖 JSONL 包来读取历史并完成相邻版本迁移。隔离的 JSONL 读取器不会替换应用的 SQLite 持久化服务。`stat()` 和 `list()` 查看元数据;打开旧会话时,将完整逻辑历史导入一个根 Segment。并发读取者共享导入过程,写访问沿用单写入者所有权规则。源文件保持不变。
|
||||
|
||||
提供者启动与卸载位于[插件入口](src/index.ts);[迁移](src/migration.ts)协调导入,[持久化](src/persistence.ts)提供原有 API。
|
||||
|
||||
</details>
|
||||
|
||||
<a id="further-exploration"></a>
|
||||
## 延伸阅读
|
||||
|
||||
- [会话持久化 API](../session-persistence/README.zh.md)
|
||||
- [JSONL 存储](../session-persistence-jsonl/README.zh.md)
|
||||
- [历史格式迁移](../session-format-catalog/README.zh.md)
|
||||
|
||||
<a id="model-experience"></a>
|
||||
## 模型体验
|
||||
|
||||
### 持久化历史
|
||||
|
||||
#### 模型看到什么
|
||||
|
||||
此插件不添加请求内容。会话使用方通过 `ctx.sessionPersistence` 读取保存的逻辑事件历史。
|
||||
|
||||
#### Token 影响
|
||||
|
||||
没有直接 Token 影响。
|
||||
|
||||
#### KV Cache 影响
|
||||
|
||||
存储介质不会改变逻辑事件历史,也不会添加模型请求前缀。
|
||||
|
||||
## 已知限制与后续工作
|
||||
|
||||
<a id="known-limitations-and-deferred-work"></a>
|
||||
|
||||
- 重新选择 JSONL 不会把 SQLite 历史导出到保留的 JSONL 文件。
|
||||
|
||||
### 开发备注
|
||||
|
||||
<details>
|
||||
<summary>维护者工作上下文</summary>
|
||||
|
||||
无。
|
||||
|
||||
</details>
|
||||
@@ -40,6 +40,7 @@
|
||||
"@deepseek-ai/dsh-session-persistence": "workspace:*"
|
||||
},
|
||||
"dependencies": {
|
||||
"@deepseek-ai/dsh-session-persistence-jsonl": "workspace:*",
|
||||
"@deepseek-ai/dsh-brand": "workspace:*",
|
||||
"@deepseek-ai/dsh-llm": "workspace:*",
|
||||
"@deepseek-ai/dsh-session-format": "workspace:*",
|
||||
|
||||
@@ -1,4 +1,39 @@
|
||||
/** SQLite Session persistence and event storage. @module */
|
||||
export { SqliteLogs } from './sqlite.ts'
|
||||
export type { SqliteLogsOptions } from './sqlite.ts'
|
||||
import { Context, type Fiber } from '@deepseek-ai/cordis'
|
||||
import { Config as JsonlConfig, JsonlSessionPersistence } from '@deepseek-ai/dsh-session-persistence-jsonl'
|
||||
import type { Config as JsonlConfigOptions } from '@deepseek-ai/dsh-session-persistence-jsonl'
|
||||
import { TracePersistence } from './persistence.ts'
|
||||
|
||||
export { TracePersistence } from './persistence.ts'
|
||||
|
||||
/** Loader label for the SQLite Session persistence provider. */
|
||||
export const name = 'session-persistence-sqlite'
|
||||
|
||||
/** Storage root and JSONL settings used when importing legacy Sessions. */
|
||||
export type Config = JsonlConfigOptions
|
||||
|
||||
/** Validate the storage root and legacy JSONL reader settings. */
|
||||
export const Config = JsonlConfig
|
||||
|
||||
/**
|
||||
* Provide SQLite persistence and retain storage resources through consumer unload.
|
||||
* @param ctx - plugin context owning the provider and its resources.
|
||||
* @param config - storage root and legacy JSONL reader settings.
|
||||
* @returns resolves after the persistence service is registered.
|
||||
*/
|
||||
export async function apply(ctx: Context, config: Config): Promise<void> {
|
||||
let service!: Fiber
|
||||
ctx.effect(function* () {
|
||||
const resources = ctx.plugin({ name: 'session-segment-resources', apply() {} })
|
||||
yield resources.dispose
|
||||
service = ctx.plugin({
|
||||
name: 'session-persistence-sqlite-service',
|
||||
apply(serviceCtx: Context) {
|
||||
const legacy = new JsonlSessionPersistence(serviceCtx.isolate('sessionPersistence'), config)
|
||||
new TracePersistence(serviceCtx, resources.ctx, config.root, legacy)
|
||||
},
|
||||
})
|
||||
yield service.dispose
|
||||
}, 'session-persistence-sqlite resources')
|
||||
await service.await()
|
||||
}
|
||||
@@ -8,6 +8,9 @@
|
||||
"src"
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"path": "../session-persistence-jsonl"
|
||||
},
|
||||
{
|
||||
"path": "../../../vendor/cosmokit"
|
||||
},
|
||||
|
||||
Generated
+6
-3
@@ -462,6 +462,9 @@ importers:
|
||||
'@deepseek-ai/dsh-sdk-minimal':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/bundle/sdk-minimal
|
||||
'@deepseek-ai/dsh-session-persistence-sqlite':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/session/session-persistence-sqlite
|
||||
'@deepseek-ai/dsh-session-projection':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/session/session-projection
|
||||
@@ -16073,9 +16076,6 @@ importers:
|
||||
'@deepseek-ai/dsh-session-format-v3-to-v4':
|
||||
specifier: workspace:*
|
||||
version: link:../session-format-v3-to-v4
|
||||
'@deepseek-ai/dsh-session-persistence-sqlite':
|
||||
specifier: workspace:*
|
||||
version: link:../session-persistence-sqlite
|
||||
'@deepseek-ai/node-addon-system':
|
||||
specifier: workspace:~
|
||||
version: link:../../../native/system/packages/entry
|
||||
@@ -16116,6 +16116,9 @@ importers:
|
||||
'@deepseek-ai/dsh-session-format-v3-to-v4':
|
||||
specifier: workspace:*
|
||||
version: link:../session-format-v3-to-v4
|
||||
'@deepseek-ai/dsh-session-persistence-jsonl':
|
||||
specifier: workspace:*
|
||||
version: link:../session-persistence-jsonl
|
||||
'@deepseek-ai/node-addon-system':
|
||||
specifier: workspace:~
|
||||
version: link:../../../native/system/packages/entry
|
||||
|
||||
@@ -31,6 +31,7 @@ export const PRODUCT_PACKAGE_POLICY: Readonly<Record<string, ProductPackagePolic
|
||||
'packages/ssh/sandbox-ssh': { category: 'optional', reason: 'Remote confinement provider selected in an SSH composition.' },
|
||||
'packages/ssh/subprocess-ssh': { category: 'optional', reason: 'Remote process provider selected in an SSH composition.' },
|
||||
'packages/storage/storage-sqlite': { category: 'optional', reason: 'Persistent storage requires an explicit database path and backend selection.' },
|
||||
'packages/session/session-persistence-sqlite': { category: 'optional', reason: 'Selected through global or profile Cordis patches; imports retained JSONL history on first open.' },
|
||||
'packages/subagent/subagent-acp': { category: 'optional', reason: 'Requires a configured external ACP agent command.' },
|
||||
'packages/subagent/subagent-claude-code': { category: 'optional', reason: 'Separately installed native Claude Code agent integration.' },
|
||||
'packages/subagent/subagent-codex': { category: 'optional', reason: 'Separately installed native Codex agent integration.' },
|
||||
|
||||
Reference in new issue
Block a user