sandersyao/dsh-session-persistence-mysql ↗★ 0
@sandersyao/dsh-session-persistence-mysql
MySQL durable session persistence backend for the DeepSeek Harness
AI Analysis
核心用途是将 DSH 的会话数据持久化保存到 MySQL 数据库中,替代默认的本地文件存储。适合需要高可靠、集中式会话存储的多用户或生产环境。
Install
This plugin has no verified bundle, or compatibility checks failed. Read the repository notes first. Read the full README ↗
README
Read the full README ↗Install & usage
import { MysqlSessionPersistence } from '@sandersyao/dsh-session-persistence-mysql'
await ctx.plugin(MysqlSessionPersistence, {
connection: { tablePrefix: process.env.MYSQL_TABLE_PREFIX },
})
// ctx.sessionPersistence is now MySQL-backed.
Configuration
Credentials, table prefix and pool tuning come from environment variables / a .env file (see .env.example). The plugin Config is fully optional — environment is the source of truth for credentials (never hard-code a password).
| Env | Default | Purpose |
|---|---|---|
MYSQL_HOST / MYSQL_PORT | 127.0.0.1 / 3306 | Write (primary) host. |
MYSQL_USER / MYSQL_PASSWORD | — (required) | Least-privilege DB user. |
MYSQL_DATABASE | — (required) | Target database. |
MYSQL_TABLE_PREFIX | — (required) | Table prefix; validated against ^[A-Za-z0-9_]+$. |
MYSQL_READ_HOST / MYSQL_READ_USER / MYSQL_READ_PASSWORD | (empty) | Read replica for read/write split; empty reuses the write connection (same-store mode). |
MYSQL_SSL_REQUIRED | false | Reserved for TLS enforcement (deferred; may be provided by a cloud provider). |
MYSQL_POOL_SIZE / MYSQL_POOL_QUEUE_LIMIT | 10 / 0 | Pool sizing. |
MYSQL_WRITE_BATCH_DELAY_MS | 200 | Batching window passed to the coordinator. |
MYSQL_PREPARED_CACHE_SIZE | 5 | Unpublished-session LRU size. |
MYSQL_PACK_CHUNKS | true | Fold assistant/chunk runs into packed rows. |
MYSQL_SCHEMA_AUTO_MIGRATE | true | Auto-migrate schema on startup; false only validates. |
ENCRYPTION_KEY | (empty) | Reserved for application-level field encryption (deferred; empty = plaintext). |
Test isolation. Automated tests (
vitest) run against a separate database to avoid touching the production one:MYSQL_TEST_DATABASE(defaulttest) overridesMYSQL_DATABASEduring tests, andMYSQL_ROOT_PASSWORDis used only by the test harness to create/grant the test DB. Seedocs/MANUAL_TEST_PLAN.md.