@wfm-cn/dsh-storage 0.0.0-stage → 0.3.0
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 +23 -0
- package/LICENSE +21 -0
- package/README.md +137 -2
- package/cordis.patch.yml +3 -0
- package/lib/backends/database.js +578 -0
- package/lib/backfill.js +331 -0
- package/lib/client/index.js +79 -0
- package/lib/client/panel.js +299 -0
- package/lib/client/toast.js +66 -0
- package/lib/client.js +1 -0
- package/lib/compaction.js +108 -0
- package/lib/config.js +171 -0
- package/lib/ddl.js +323 -0
- package/lib/generated/mysql/browser.js +17 -0
- package/lib/generated/mysql/client.js +34 -0
- package/lib/generated/mysql/commonInputTypes.js +10 -0
- package/lib/generated/mysql/enums.js +10 -0
- package/lib/generated/mysql/internal/class.js +49 -0
- package/lib/generated/mysql/internal/prismaNamespace.js +146 -0
- package/lib/generated/mysql/internal/prismaNamespaceBrowser.js +117 -0
- package/lib/generated/mysql/models/AiChatHistory.js +1 -0
- package/lib/generated/mysql/models/AiMessage.js +1 -0
- package/lib/generated/mysql/models.js +1 -0
- package/lib/generated/postgresql/browser.js +17 -0
- package/lib/generated/postgresql/client.js +34 -0
- package/lib/generated/postgresql/commonInputTypes.js +10 -0
- package/lib/generated/postgresql/enums.js +10 -0
- package/lib/generated/postgresql/internal/class.js +49 -0
- package/lib/generated/postgresql/internal/prismaNamespace.js +131 -0
- package/lib/generated/postgresql/internal/prismaNamespaceBrowser.js +102 -0
- package/lib/generated/postgresql/models/AiChatHistory.js +1 -0
- package/lib/generated/postgresql/models/AiMessage.js +1 -0
- package/lib/generated/postgresql/models.js +1 -0
- package/lib/generated/sqlite/browser.js +17 -0
- package/lib/generated/sqlite/client.js +34 -0
- package/lib/generated/sqlite/commonInputTypes.js +10 -0
- package/lib/generated/sqlite/enums.js +10 -0
- package/lib/generated/sqlite/internal/class.js +49 -0
- package/lib/generated/sqlite/internal/prismaNamespace.js +128 -0
- package/lib/generated/sqlite/internal/prismaNamespaceBrowser.js +99 -0
- package/lib/generated/sqlite/models/AiChatHistory.js +1 -0
- package/lib/generated/sqlite/models/AiMessage.js +1 -0
- package/lib/generated/sqlite/models.js +1 -0
- package/lib/generated/sqlserver/browser.js +17 -0
- package/lib/generated/sqlserver/client.js +34 -0
- package/lib/generated/sqlserver/commonInputTypes.js +10 -0
- package/lib/generated/sqlserver/enums.js +10 -0
- package/lib/generated/sqlserver/internal/class.js +49 -0
- package/lib/generated/sqlserver/internal/prismaNamespace.js +119 -0
- package/lib/generated/sqlserver/internal/prismaNamespaceBrowser.js +90 -0
- package/lib/generated/sqlserver/models/AiChatHistory.js +1 -0
- package/lib/generated/sqlserver/models/AiMessage.js +1 -0
- package/lib/generated/sqlserver/models.js +1 -0
- package/lib/health.js +180 -0
- package/lib/index.js +681 -0
- package/lib/memory-tools.js +365 -0
- package/lib/notify.js +56 -0
- package/lib/projector.js +191 -0
- package/lib/status-route.js +172 -0
- package/lib/types/backends/database.d.ts +78 -0
- package/lib/types/backfill.d.ts +67 -0
- package/lib/types/client/index.d.ts +12 -0
- package/lib/types/client/panel.d.ts +79 -0
- package/lib/types/client/toast.d.ts +38 -0
- package/lib/types/compaction.d.ts +3 -0
- package/lib/types/config.d.ts +52 -0
- package/lib/types/ddl.d.ts +49 -0
- package/lib/types/generated/mysql/browser.d.ts +14 -0
- package/lib/types/generated/mysql/client.d.ts +33 -0
- package/lib/types/generated/mysql/commonInputTypes.d.ts +396 -0
- package/lib/types/generated/mysql/enums.d.ts +1 -0
- package/lib/types/generated/mysql/internal/class.d.ts +143 -0
- package/lib/types/generated/mysql/internal/prismaNamespace.d.ts +709 -0
- package/lib/types/generated/mysql/internal/prismaNamespaceBrowser.d.ts +112 -0
- package/lib/types/generated/mysql/models/AiChatHistory.d.ts +1258 -0
- package/lib/types/generated/mysql/models/AiMessage.d.ts +1359 -0
- package/lib/types/generated/mysql/models.d.ts +3 -0
- package/lib/types/generated/postgresql/browser.d.ts +14 -0
- package/lib/types/generated/postgresql/client.d.ts +33 -0
- package/lib/types/generated/postgresql/commonInputTypes.d.ts +392 -0
- package/lib/types/generated/postgresql/enums.d.ts +1 -0
- package/lib/types/generated/postgresql/internal/class.d.ts +143 -0
- package/lib/types/generated/postgresql/internal/prismaNamespace.d.ts +728 -0
- package/lib/types/generated/postgresql/internal/prismaNamespaceBrowser.d.ts +95 -0
- package/lib/types/generated/postgresql/models/AiChatHistory.d.ts +1373 -0
- package/lib/types/generated/postgresql/models/AiMessage.d.ts +1496 -0
- package/lib/types/generated/postgresql/models.d.ts +3 -0
- package/lib/types/generated/sqlite/browser.d.ts +14 -0
- package/lib/types/generated/sqlite/client.d.ts +33 -0
- package/lib/types/generated/sqlite/commonInputTypes.d.ts +373 -0
- package/lib/types/generated/sqlite/enums.d.ts +1 -0
- package/lib/types/generated/sqlite/internal/class.d.ts +143 -0
- package/lib/types/generated/sqlite/internal/prismaNamespace.d.ts +705 -0
- package/lib/types/generated/sqlite/internal/prismaNamespaceBrowser.d.ts +92 -0
- package/lib/types/generated/sqlite/models/AiChatHistory.d.ts +1371 -0
- package/lib/types/generated/sqlite/models/AiMessage.d.ts +1493 -0
- package/lib/types/generated/sqlite/models.d.ts +3 -0
- package/lib/types/generated/sqlserver/browser.d.ts +14 -0
- package/lib/types/generated/sqlserver/client.d.ts +33 -0
- package/lib/types/generated/sqlserver/commonInputTypes.d.ts +333 -0
- package/lib/types/generated/sqlserver/enums.d.ts +1 -0
- package/lib/types/generated/sqlserver/internal/class.d.ts +143 -0
- package/lib/types/generated/sqlserver/internal/prismaNamespace.d.ts +669 -0
- package/lib/types/generated/sqlserver/internal/prismaNamespaceBrowser.d.ts +80 -0
- package/lib/types/generated/sqlserver/models/AiChatHistory.d.ts +1257 -0
- package/lib/types/generated/sqlserver/models/AiMessage.d.ts +1375 -0
- package/lib/types/generated/sqlserver/models.d.ts +3 -0
- package/lib/types/health.d.ts +52 -0
- package/lib/types/index.d.ts +91 -0
- package/lib/types/memory-tools.d.ts +168 -0
- package/lib/types/notify.d.ts +35 -0
- package/lib/types/projector.d.ts +51 -0
- package/lib/types/status-route.d.ts +48 -0
- package/lib/types/types.d.ts +58 -0
- package/lib/types.js +8 -0
- package/package.json +127 -4
- package/preview.png +0 -0
- package/prisma/schema.mysql.prisma +78 -0
- package/prisma/schema.postgresql.prisma +70 -0
- package/prisma/schema.sqlite.prisma +70 -0
- package/prisma/schema.sqlserver.prisma +76 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0 (2026-11-06)
|
|
4
|
+
|
|
5
|
+
Fork of [`@amaster.ai/dsh-storage`](https://github.com/TGYD-helige/dsh-plugins) 0.1.40 (MIT), published as `@wfm-cn/dsh-storage`. Table schema and deterministic primary-key hashing are unchanged from upstream 0.1.40 — an existing upstream-written database is taken over with zero migration and zero duplication.
|
|
6
|
+
|
|
7
|
+
### Fixed (vs upstream 0.1.40)
|
|
8
|
+
|
|
9
|
+
- **MySQL adapter connection failure (critical)**: upstream constructed the mariadb driver adapter from a URL string, which always ended in a pool timeout. The adapter now receives discrete params (host/port/user/password/database) parsed from the config. (`src/backends/database.ts`)
|
|
10
|
+
- **Timezone**: timestamps were written as bare UTC values. New `timezone` config (default `'+08:00'`) is passed to the driver at connect time; rows land in the configured zone.
|
|
11
|
+
|
|
12
|
+
### Added (vs upstream 0.1.40)
|
|
13
|
+
|
|
14
|
+
- **Settings panel**: configure the mirror in the DSH settings UI (provider/host/port/user/password/database/timezone). Persists to `~/.dsh/dsh-storage.json`; the backend watches the file and rebuilds connections without a restart. (`src/client/`)
|
|
15
|
+
- **Test connection**: three-state check (ok + tables ready / ok + tables missing / failed with a human-readable reason) over a real RPC probe. (`src/health.ts`)
|
|
16
|
+
- **One-click table creation**: embedded DDL for MySQL and SQLite executed over the same driver-adapter path (no prisma CLI, no network); PostgreSQL/SQL Server fall back to the packaged-schema `prisma db push` route. (`src/ddl.ts`)
|
|
17
|
+
- **Health monitoring + notifications**: startup self-check and 30s periodic probe with exponential-backoff retries (1s→60s) that never drop the queue; toast notifications on down/up transitions. (`src/health.ts`, `src/notify.ts`, `src/status-route.ts`)
|
|
18
|
+
- **Gap backfill**: after an outage, the panel replays locally-logged session events through the same projector; deterministic ids make replay idempotent. (`src/backfill.ts`)
|
|
19
|
+
|
|
20
|
+
### Notes
|
|
21
|
+
|
|
22
|
+
- Registration renamed: `cordis.patch.yml` now registers `@wfm-cn/dsh-storage` (id stays `storage-mirror`).
|
|
23
|
+
- Known limitations documented in README: pg/mssql table creation needs the prisma CLI; out-of-order events below the database watermark are not backfilled; backfill/live interleave can skew `ai_chat_histories` message counts.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-plugins contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,138 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @wfm-cn/dsh-storage
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
DSH(DeepSeek Harness)会话存储镜像插件:把 `session/event` 事件流实时投影到关系数据库(`ai_messages` / `ai_chat_histories` 两张表,支持 MySQL / PostgreSQL / SQLite / SQL Server),**不替换** DSH 本地持久化——本地文件仍是权威数据源,本插件只做镜像。
|
|
6
|
+
|
|
7
|
+
本包是 [`@amaster.ai/dsh-storage`](https://github.com/TGYD-helige/dsh-plugins) 0.1.40(MIT)的 fork,修复了上游的 MySQL 建连 bug 并新增设置面板、健康监控与断档补传。表结构与确定性主键算法与上游完全一致,可零迁移直接接管上游写入过的库。
|
|
8
|
+
|
|
9
|
+
## 主要功能
|
|
10
|
+
|
|
11
|
+
- **设置页面板**:DSH 设置页内配置数据库(类型/主机/端口/用户/密码/库名/时区),保存即生效(写入 `~/.dsh/dsh-storage.json`,后端热重建连接),无需编辑 yaml、无需重启。
|
|
12
|
+
- **测试连接**:面板一键测试,三态结果——🟢 连接成功且表就绪 / 🟡 连接成功但表不存在(引导一键建表)/ 🔴 连接失败(给出人话错误:地址不通、密码错、库不存在等)。
|
|
13
|
+
- **一键建表**:MySQL/SQLite 内嵌 DDL 直接执行;PostgreSQL/SQL Server 走打包 schema 的 `prisma db push` 路线(见"已知限制")。
|
|
14
|
+
- **健康监控 + 通知**:启动自检 + 30s 周期探测;状态好→坏时右上角弹出 `⚠️ 会话同步中断:<原因>`(仅一次,不骚扰);坏→好时弹 `✅ 同步已恢复` 并可一键补传。写入失败按 1s 起指数退避(至 60s)自动重试,队列数据不丢。
|
|
15
|
+
- **断档补传**:镜像中断期间本地 session 日志仍完整;面板"补传"按钮对比本地会话与库内数据的时间差,将缺失事件重放入库。补传与主键确定性哈希配合,重复执行不会产生重复行。
|
|
16
|
+
|
|
17
|
+
## 相对上游 0.1.40 的修复
|
|
18
|
+
|
|
19
|
+
1. **MySQL 建连 bug(关键修复)**:上游 mysql provider 用 URL 字符串直接构造 mariadb 适配器,必然连接池超时。本包将 URL 拆解为离散参数(host/port/user/password/database)传给 `PrismaMariaDb` 适配器。
|
|
20
|
+
2. **时区配置化**:新增 `timezone` 配置项(默认 `'+08:00'`),建连时传给驱动;时间戳按配置时区写入,读库无需心算偏移。
|
|
21
|
+
|
|
22
|
+
## 安全提示:密码为明文存储
|
|
23
|
+
|
|
24
|
+
数据库密码以**明文**保存在 `~/.dsh/dsh-storage.json` 中(与 DSH 自身配置文件同权限级别)。请:
|
|
25
|
+
|
|
26
|
+
- 强烈建议为镜像创建**专用最小权限账号**:仅需目标库的 `SELECT / INSERT / UPDATE / CREATE`(建表后可收回 `CREATE`)权限,不要使用 root 等高权限账号;
|
|
27
|
+
- 确保该文件的读取权限仅限当前用户(`chmod 600`)。
|
|
28
|
+
|
|
29
|
+
## 安装
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
dsh plugin --profile <profile> add @wfm-cn/dsh-storage
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
运行时 peer 依赖:`@prisma/client`(**Prisma 7**)及所用数据库的驱动适配器:
|
|
36
|
+
|
|
37
|
+
| Provider | Adapter peer |
|
|
38
|
+
| --- | --- |
|
|
39
|
+
| `mysql` | `@prisma/adapter-mariadb` |
|
|
40
|
+
| `postgresql` | `@prisma/adapter-pg` |
|
|
41
|
+
| `sqlite` | `@prisma/adapter-libsql` |
|
|
42
|
+
| `sqlserver` | `@prisma/adapter-mssql` |
|
|
43
|
+
|
|
44
|
+
PrismaClient 已按 provider 预生成并随包发布,使用方**无需 `prisma generate`**。建表可用面板"建表"按钮(MySQL/SQLite 内嵌 DDL),或手动:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
npx prisma db push --schema node_modules/@wfm-cn/dsh-storage/prisma/schema.mysql.prisma --url "mysql://user:pass@host:3306/agent"
|
|
48
|
+
# schema.postgresql.prisma / schema.sqlite.prisma / schema.sqlserver.prisma 同理
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 配置
|
|
52
|
+
|
|
53
|
+
推荐方式:安装后在 DSH 设置页的「会话存储镜像」面板中配置并启用(持久化为 `~/.dsh/dsh-storage.json`)。
|
|
54
|
+
|
|
55
|
+
配置项一览(`dsh-storage.json`):
|
|
56
|
+
|
|
57
|
+
| 字段 | 说明 | 默认 |
|
|
58
|
+
| --- | --- | --- |
|
|
59
|
+
| `enabled` | 是否启用同步 | `false` |
|
|
60
|
+
| `provider` | `mysql` \| `postgresql` \| `sqlite` \| `sqlserver` | `mysql` |
|
|
61
|
+
| `host` / `port` | 主机与端口(sqlite 忽略) | `127.0.0.1` / 3306 |
|
|
62
|
+
| `user` / `password` | 账号(见上方安全提示)/ 明文密码 | 空 |
|
|
63
|
+
| `database` | 库名;sqlite 时为文件路径 | 空 |
|
|
64
|
+
| `timezone` | 写入时间戳所用时区,IANA 命名偏移(如 `'+08:00'`、`'-05:00'`) | `'+08:00'` |
|
|
65
|
+
|
|
66
|
+
插件注册段(`cordis.patch.yml`,通常由 plugin 安装器维护):
|
|
67
|
+
|
|
68
|
+
```yaml
|
|
69
|
+
- insert:
|
|
70
|
+
- id: storage-mirror
|
|
71
|
+
name: '@wfm-cn/dsh-storage'
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 从 @amaster.ai/dsh-storage 切换
|
|
75
|
+
|
|
76
|
+
表结构、主键哈希算法与上游 0.1.40 完全一致——**同样的表、同样的确定性 id,零迁移、零重复**。步骤:
|
|
77
|
+
|
|
78
|
+
1. 备份 `~/.dsh/profiles/<profile>/cordis.patch.yml`;
|
|
79
|
+
2. 停用并卸载 `@amaster.ai/dsh-storage`(DSH 插件管理操作);
|
|
80
|
+
3. 若 `cordis.patch.yml` 中仍有手写的 storage-mirror 配置块,删除之;
|
|
81
|
+
4. 安装本包:`dsh plugin --profile <profile> add @wfm-cn/dsh-storage`(本地路径亦可:`dsh plugin add /path/to/dsh-storage`);
|
|
82
|
+
5. 重启 DSH;
|
|
83
|
+
6. 设置页面板:填入原有数据库参数(与旧插件写入的是同一个库,直接沿用),测试连接 → 建表检查(表已存在应显示绿)→ 启用;
|
|
84
|
+
7. 验证:行数与切换前一致、`SELECT COUNT(*) = COUNT(DISTINCT id) FROM ai_messages`(无重复)、新消息持续入库、新行 `created_at` ≈ 本地北京时间。
|
|
85
|
+
|
|
86
|
+
详细操作手册见 [`scripts/switch-from-amaster.md`](scripts/switch-from-amaster.md)。
|
|
87
|
+
|
|
88
|
+
## 数据模型
|
|
89
|
+
|
|
90
|
+
- **`ai_messages`** — 用户/模型消息行,含 `thoughts`、`tokens`、`tool_calls`、`agent_id`、`metadata` JSON 列与软删除。`tool/result` 按调用 ID 更新对应模型行的 `tool_calls` 条目,不产生 `type=tool` 行。消息行主键为 `(session_id, message id)` 的确定性哈希,重复投影按 upsert 原位更新,不产生重复行。与上游一致,无 `user_id` 列(租户信息在 `session_id` 中)。
|
|
91
|
+
- **`ai_chat_histories`** — 会话级汇总(消息数、token 总量、首/末消息时间)。归档操作(`ctx.get('dshStorage').archiveSession(sessionId)`)可将当前消息事务性地挂到历史行下,归档后的汇总仍可查询。
|
|
92
|
+
|
|
93
|
+
镜像为无抛出缝隙:数据库错误带 `[dsh-storage]` 前缀记日志,绝不逃逸进 agent 循环;本地 DSH 持久化始终是权威数据源。成功的原生压缩事件同时写入 `utility_compressor` 快照消息(source 兼容的 `Content[]`)。完整投影语义(工具结果合并、thoughts 签名、压缩快照续读等)与上游 0.1.40 一致,详见上游文档。
|
|
94
|
+
|
|
95
|
+
## AI 记忆查询工具(Phase 2)
|
|
96
|
+
|
|
97
|
+
插件在宿主 `tools` 服务上注册两个只读的模型工具(host-side,无需客户端配合),让 AI 能检索/回忆镜像到数据库的历史对话(跨设备记忆):
|
|
98
|
+
|
|
99
|
+
- **`memory_search`** — `{ query, device?: 'all'|'current', limit?, since? }`:关键词(SQL LIKE OR 语义,通配符已转义)搜索 `ai_messages` 用户+模型行,返回 `{session_id, device, type, created_at, snippet(≤160)}`,按时间倒序。
|
|
100
|
+
- **`memory_read`** — `{ session_id, around?, limit? }`:按 `created_at` 返回该会话的对话上下文(`around` 时为该时刻及之前的窗口,恢复正序),每条内容截断 ≤500 字符。
|
|
101
|
+
|
|
102
|
+
两个工具复用同步配置(`$DSH_HOME/dsh-storage.json`):同步未配置/未启用时返回友好错误提示(引导到「会话存储」面板)。每次调用创建一次性只读连接(仅 SELECT),用完即释放;所有用户输入参数化绑定(显式 argTypes,兼容 adapter 7.9.1/7.10+),LIKE 通配符用 `ESCAPE '~'` 转义。
|
|
103
|
+
|
|
104
|
+
## 已知限制
|
|
105
|
+
|
|
106
|
+
- **PostgreSQL / SQL Server 建表需要 prisma CLI**:面板"建表"按钮的嵌入式 DDL 仅覆盖 MySQL 与 SQLite;pg/mssql 走 `prisma db push` 路线,失败时会明确提示需要 prisma CLI(或用上文的 `npx prisma db push` 手动建表)。
|
|
107
|
+
- **乱序事件的水位盲区**:补传的缺口检测以库内最新消息行为水位。若某事件因乱序晚到且早于水位,该事件不会被补传捕捉(确定性主键保证它不重复,但可能缺失)。实践中事件按序到达,影响范围有限。
|
|
108
|
+
- **补传与实时镜像交错时的汇总回归**:`ai_chat_histories` 的消息计数在补传重放与实时写入交错时可能偏移(行级 upsert 幂等,`ai_messages` 本身不受影响)。极端情况下计数偏差可用补传完成后的会话最后一条事件自愈。
|
|
109
|
+
- 升级上游版本前请先比对 prisma schema:本包表结构对应上游 0.1.40。
|
|
110
|
+
|
|
111
|
+
## Compatibility
|
|
112
|
+
|
|
113
|
+
事件载荷依赖 pre-release 的 dsh API;升级 dsh 前请检查 `src/` 中的 `TODO(verify)` 标记。固定版本组合见根仓库 compat matrix(上游)。
|
|
114
|
+
|
|
115
|
+
## License
|
|
116
|
+
|
|
117
|
+
MIT。fork 自 [@amaster.ai/dsh-storage](https://github.com/TGYD-helige/dsh-plugins) 0.1.40(MIT),上游版权声明保留于 [LICENSE](LICENSE)。
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
# English
|
|
122
|
+
|
|
123
|
+
A session storage mirror plugin for DSH (DeepSeek Harness): projects the `session/event` stream into MySQL/PostgreSQL/SQLite/SQL Server (`ai_messages` / `ai_chat_histories`) without replacing dsh's local persistence — local files stay authoritative; this is a mirror.
|
|
124
|
+
|
|
125
|
+
This package is a fork of [`@amaster.ai/dsh-storage`](https://github.com/TGYD-helige/dsh-plugins) 0.1.40 (MIT). Fixes vs upstream:
|
|
126
|
+
|
|
127
|
+
1. **MySQL adapter bug (critical)**: upstream built the mariadb adapter from a URL string, which always pool-times out. This fork passes discrete params (host/port/user/password/database) to `PrismaMariaDb`.
|
|
128
|
+
2. **Configurable timezone**: new `timezone` config (default `'+08:00'`) passed to the driver at connect time.
|
|
129
|
+
|
|
130
|
+
Additions: settings panel (configure in the DSH UI, hot-reload without restart), three-state test connection, one-click table creation (embedded DDL for MySQL/SQLite), health monitoring with toast notifications (down/up transitions, exponential-backoff retries that never drop the queue), and gap backfill that replays locally-logged events idempotently after an outage.
|
|
131
|
+
|
|
132
|
+
**Security note**: the database password is stored in plaintext in `~/.dsh/dsh-storage.json`. Use a dedicated least-privilege account (SELECT/INSERT/UPDATE/CREATE on the target database only) and `chmod 600` the file.
|
|
133
|
+
|
|
134
|
+
**Switching from @amaster.ai/dsh-storage**: same tables, same deterministic ids, zero migration — uninstall the old plugin, install this one, restart DSH, configure the same database in the panel, verify `SELECT COUNT(*) = COUNT(DISTINCT id) FROM ai_messages`. Full runbook: [`scripts/switch-from-amaster.md`](scripts/switch-from-amaster.md).
|
|
135
|
+
|
|
136
|
+
**Known limitations**: pg/mssql table creation requires the prisma CLI (embedded DDL covers MySQL/SQLite only); out-of-order events older than the database watermark are not backfilled; backfill/live interleave can skew `ai_chat_histories` message counts (message rows themselves stay idempotent). Schema corresponds to upstream 0.1.40 — diff schemas before adopting later upstream versions.
|
|
137
|
+
|
|
138
|
+
MIT license; upstream copyright attribution retained in [LICENSE](LICENSE).
|
package/cordis.patch.yml
ADDED