sandersyao/dsh-storage-mysql0

@sandersyao/dsh-storage-mysql

基于 MySQL 的 DeepSeek Harness 存储中心(ctx.storage)后端插件。

AI 分析

核心用途是将 DSH 的领域存储数据路由至 MySQL 数据库。适合需要将应用数据、配置等统一存储在关系型数据库中以方便备份和扩展的开发者。

包名
@sandersyao/dsh-storage-mysql
版本
0.1.0
许可证
MIT
最近更新
2026年9月3日

安装

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:sandersyao/dsh-storage-mysql

Install & usage

import { apply, Config, inject, name } from '@sandersyao/dsh-storage-mysql'
// Route the storage-domain facility to this backend:
//   ctx.plugin({ apply, Config, inject, name }, { connection: { tablePrefix: 'dsh_storage_' } })
// With storage-domain config { backend: 'mysql' }, ctx.storage.domain is MySQL-backed.

Easiest path is the bundle patch (see below): add the package and its cordis.patch.yml keeps the default storage-json backend and simply points storage-domain.backend at mysql — the json backend stays available for per-domain routes.

Configuration

Connection details come from environment variables / a .env file (see .env.example). Independent STORAGE_* win; they fall back to the shared MYSQL_* — reuse the same connection when co-existing with dsh-session-persistence-mysql / dsh-credentials-mysql, or configure independently. The plugin Config is optional (only non-secret overrides); credentials never live in code or config.

EnvFallbackDefaultPurpose
STORAGE_HOSTMYSQL_HOST127.0.0.1Host.
STORAGE_PORTMYSQL_PORT3306Port.
STORAGE_USERMYSQL_USER— (required)Least-privilege DB user.
STORAGE_PASSWORDMYSQL_PASSWORD— (required)Password.
STORAGE_DATABASEMYSQL_DATABASE— (required)Target database.
STORAGE_TABLE_PREFIXMYSQL_TABLE_PREFIX— (required)Table prefix, validated ^[A-Za-z0-9_]+$; base names distinct from session/credentials.
STORAGE_SSL_REQUIREDMYSQL_SSL_REQUIREDfalseTLS (deferred).
STORAGE_POOL_SIZEMYSQL_POOL_SIZE10Pool sizing.
STORAGE_SCHEMA_AUTO_MIGRATEMYSQL_SCHEMA_AUTO_MIGRATEtrueAuto-migrate schema on startup.

Test isolation. Automated tests run against a separate database (STORAGE_TEST_DATABASE, default test); MYSQL_ROOT_PASSWORD is used only by the test harness to create/grant it.