sandersyao/dsh-session-persistence-mysql0

@sandersyao/dsh-session-persistence-mysql

基于 MySQL 的 DeepSeek Harness 持久化会话后端插件。

AI 分析

核心用途是将 DSH 的会话数据持久化保存到 MySQL 数据库中,替代默认的本地文件存储。适合需要高可靠、集中式会话存储的多用户或生产环境。

套件
@sandersyao/dsh-session-persistence-mysql
版本
0.1.1-rc.2
授權
MIT
最近更新
2026年9月1日

安裝

此插件尚未提供可驗證的 bundle,或相容性檢查未通過。請先閱讀倉庫說明。 閱讀完整 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).

EnvDefaultPurpose
MYSQL_HOST / MYSQL_PORT127.0.0.1 / 3306Write (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_REQUIREDfalseReserved for TLS enforcement (deferred; may be provided by a cloud provider).
MYSQL_POOL_SIZE / MYSQL_POOL_QUEUE_LIMIT10 / 0Pool sizing.
MYSQL_WRITE_BATCH_DELAY_MS200Batching window passed to the coordinator.
MYSQL_PREPARED_CACHE_SIZE5Unpublished-session LRU size.
MYSQL_PACK_CHUNKStrueFold assistant/chunk runs into packed rows.
MYSQL_SCHEMA_AUTO_MIGRATEtrueAuto-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 (default test) overrides MYSQL_DATABASE during tests, and MYSQL_ROOT_PASSWORD is used only by the test harness to create/grant the test DB. See docs/MANUAL_TEST_PLAN.md.