sandersyao/dsh-session-persistence-mysql0

@sandersyao/dsh-session-persistence-mysql

MySQL durable session persistence backend for the DeepSeek Harness

AI 分析

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

パッケージ
@sandersyao/dsh-session-persistence-mysql
バージョン
0.1.1-rc.2
ライセンス
MIT
最終更新
2026/09/01

インストール

検証済み bundle がないか、互換性チェックに失敗しています。先にリポジトリの説明を読んでください。 README 全文を読む ↗

ドキュメント

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.