dsh-agent-db-studio: A Unified GUI and Agent DeepSeek Harness Database Management Plugin

Introduction

DeepSeek Harness (DSH) supports plugin-based extensibility, and the community offers a number of plugins for specific use cases. To address the need of “letting an agent take over database operations while humans retain visibility and control via a web panel,” junrui-li provides dsh-agent-db-studio: it breaks database operations down into 20 db_* tools exposed to the model, mandates ticket-based approval for all write operations, limits the web panel to observation and control, and enforces data masking before results leave the engine. Below is an overview of its architecture, capabilities, and usage.

What It Is

This is a DSH plugin that integrates a database engine into the DSH Host process (Node implementation, node:sqlite for persistence, external connections to MySQL / Redis). It exposes 20 tools to the Agent and simultaneously provides a web panel for connection management, SQL editing, ticket approval, execution history, and masking policy configuration. The panel and the engine share the same origin; the browser never receives connection passwords, and masking is completed before data leaves the engine.

Core Features

Agent Tools

The plugin registers 20 tools with the Agent, covering metadata queries, data queries, semantic-layer retrieval, and write operations. Four of the semantic-layer tools are always registered for NL2SQL business-glossary retrieval. See the README for the full tool list and guard policies.

  • db_status: Engine status, connection count, write mode, pending ticket count, masking AI availability, semantic-layer status.
  • db_list_connections: List connections; passwords are never returned.
  • db_list_databases: List databases or Redis dbs.
  • db_list_tables: List tables and views.
  • db_describe_*: Inspect table structure, indexes, and DDL.
  • db_query: Execute read-only queries (SELECT, etc.) with an EXPLAIN-based slow-SQL gate before execution.
  • db_execute: Execute write operations (routed through ticket approval by default).
  • db_redis_command: Redis commands (write commands always require approval).
  • db_undo_last: Undo the most recent reversible write execution (requires the write window and approval).
  • db_list_semantic_domains: List semantic business domains.
  • db_search_semantics: Retrieve semantic assets by keyword and structured scoring.
  • db_get_semantic_asset: Read a semantic asset file (directory/body, supports truncation).
  • db_get_table_card: Get the semantic card and join paths for a table.

Ticket Approval

Write operations are not executed directly by default; instead, a ticket is submitted. A ticket contains the SQL, contextual notes, estimated affected rows (EXPLAIN estimate + risk level + per-statement table/has-WHERE info). On the panel, a human can approve and execute (single synchronous transaction, full rollback on failure), reject, or cancel. A single ticket may contain multiple SQL statements (separated by ;); upon approval they are executed sequentially within the same transaction, and any failure triggers a full rollback. The Agent has no approval tool whatsoever—the approval entry point exists only on the panel.

Security Model

The plugin implements a set of security guards at the engine layer:

  • Read-only enforcement: The engine performs a lexical scan of the leading keyword; anything other than SELECT/SHOW/DESC/EXPLAIN/USE/SET is rejected with a 403. The same check applies when creating a ticket.
  • Missing-WHERE rejection: UPDATE/DELETE statements lacking a top-level WHERE are rejected outright.
  • Write window: Beyond allowWrites: true, there is a session-level “write window.” The panel can temporarily open the gate, which auto-closes on a timer; once closed, write executions return 403.
  • Passwords never leave the process: Read endpoints return only hasPassword. The engine and Host share the same process, so the browser cannot obtain the password.
  • Masking before egress: All query results are masked before they leave the engine. There is no unmask endpoint, and the tool layer exposes no masking/unmasking parameters.
  • Pre-change snapshot + undo: A snapshot is captured before any reversible write execution; db_undo_last performs the inverse restore (also subject to the write window and approval).

Data Masking

Once “masking mode” is enabled for a connection, all query results on that connection are masked before leaving the engine. The Agent tools, the panel, and ticket execution results all receive masked values. Five built-in masking types (name, phone number, national ID, bank card number, email) are mandatory and cannot be removed.

Detection is three-layered, additive—any layer that matches triggers masking:

  1. Configuration layer: masking.fields saved after AI/rule analysis.
  2. Column-name heuristic layer: If a result column’s original name matches a built-in naming pattern → corresponding type.
  3. Value-level fallback layer: Phone-number regex, national ID GB 11643 check-digit validation, bank card Luhn check.

The algorithms follow common national/industry practices, e.g., names retain the first character with the rest replaced by *, and phone numbers show the first 3 digits + **** + last 4 digits. Masking policies can be maintained on a tree-structured page in the panel, supporting per database → table → field configuration. The five built-in mandatory types are locked. Disabling masking does not delete the policy; re-enabling it picks up where it left off.

NL2SQL / Business Semantic Layer

The semantic layer is stored in dbs.db (not markdown on disk). Domains can be created, tables linked, and body text edited directly in the panel—the Agent can retrieve them immediately. The panel provides a “Semantic Layer” tab where you can create domains, import content, link data tables, and edit body text.

The panel registers 4 semantic-layer tools:

  • db_list_semantic_domains: List business domains.
  • db_search_semantics: LIKE + structured scoring retrieval of semantic assets.
  • db_get_semantic_asset: Read a semantic asset file.
  • db_get_table_card: Get the semantic card and join paths for a table.

The system prompt includes an NL2SQL workflow hint (≤1500 characters): when answering business questions, first consult the semantic-layer assets, use only tables/columns that appear in the cards, defer to the assets for metric definitions, and clarify with the user when the definition is ambiguous.

The panel also supports AI distillation (disabled by default; enabled when semanticDistillHours > 0): it filters read-only queries from execution history, replaces SQL literals with ?, and asks the model to “pick and organize,” producing candidate files. Only after a human checks and approves them are they written to disk. The scheduled task only produces candidates and never writes files automatically.

Web Panel

The panel entry point is accessible from the “Data Management” icon in the left sidebar or the “Data Management” card in the DSH right sidebar. The central panel has five views at the top: Workspace, Tickets, History, Masking Policies, and Semantic Layer.

  • Workspace: Supports independent tabs per connection, draggable result-pane resizing, connection management (create/edit/delete/test), a metadata tree (database → tables/views), an SQL editor (keyword/table-name/field-name autocompletion with fuzzy matching), a results grid (NULL values grayed out, row count/duration/truncation indicators, row selection), export (selected rows or full result set, supports INSERT/JSON/Excel, large result sets go through an export ticket), and a Redis browser (SCAN pagination, type/TTL/value).
  • Tickets: List with status filtering; detail view shows full SQL, contextual notes, estimated affected rows, actual affected rows, duration, errors, and a timeline. Actions include approve & execute, reject, and cancel.
  • History: SQL execution history, filterable by connection, status, keyword, and time range. Supports pagination (default 500 rows/page). Details include the EXPLAIN plan and the agent’s purpose summary, with an option to load into the editor.
  • Masking Policies: Tree-structured maintenance, supporting per database → table → field configuration. The five built-in mandatory types are locked.
  • Semantic Layer: Create domains, import content, link data tables, and edit body text. Creating a new domain auto-generates 4 files; saving triggers an index rebuild.

Installation & Configuration

Requirements

  • Node ≥ 24 (node:sqlite STRICT tables).
  • DSH version >= 0.2.0 < 0.3.0.
  • No Python required, no additional service process needed.

Installing the Plugin

Use DSH’s built-in dsh CLI within the profile directory:

# Local install (run from the parent directory of the repo)
dsh plugin --profile desktop add ./dsh-agent-db-studio

# Or install from a git repository
dsh plugin --profile desktop add git+https://github.com/junrui-li/dsh-agent-db-studio.git

# Or install directly by npm package name
dsh plugin --profile desktop add dsh-agent-db-studio

On first use, the profile is initialized automatically, and the plugin is installed into the DSH profile as a bundle. You can also ask the Agent in a DSH session to call plugin_manager(action="install_bundle", target="<absolute repo path or install spec>") to install it (requires granting full-access approval).

When installing from a git repository, if pnpm ≥ 10, the initial add will fail because it refuses to run the prepare script of the git dependency. Follow the prompt to add the package key to the profile’s pnpm-workspace.yaml, then re-run add:

allowBuilds:
  dsh-agent-db-studio: true

The prepare script only concatenates src/client/parts/*.js into dist/client/index.js; a local-path install does not depend on it—the plugin will rebuild it on demand upon activation.

Configuration

Configuration is managed via cordis.patch.yml (the plugin has no settings page). Commonly used fields:

  • allowWrites: When enabled, write tools are registered.
  • writeMode: ticket (ticket approval) or direct (execute immediately after the DSH approval dialog).
  • maxRows: Maximum rows per query.
  • timeout: Query timeout duration.
  • undoMaxRows / undoKeep: Limits related to undo.
  • semanticLayerPath: Source directory for semantic-layer document import.
  • semanticMaxChars: Maximum character count for semantic asset text.
  • semanticRefreshHours: Semantic-layer index refresh interval.
  • semanticDistillHours: AI distillation task interval (>0 to enable).

After modifying the configuration, use plugin_manager set_bundle to reload via off→on (do NOT use remove_bundle + install_bundle, as that triggers a dependency reinstall and may affect other plugins).

The data directory defaults to <repo>/server/data (dbs.db, semantic-index.db, undo/, exports/). It contains plaintext connection passwords; .gitignore already excludes server/data/ and all *.db files—never commit them to a repository.

Typical Usage

  1. After installing the plugin, open the “Data Management” panel from the DSH right sidebar or the left sidebar.
  2. In the Workspace, add a MySQL or Redis connection. After saving, the corresponding tab opens automatically.
  3. Expand databases/tables in the metadata tree to view columns, indexes, and DDL, or click “Exact Row Count.”
  4. Type a query in the SQL editor (supports autocompletion and fuzzy matching) and press Ctrl+Enter to execute.
  5. If a write operation is needed, the Agent submits a ticket. Review and approve/reject it in the panel’s ticket list.
  6. Configure masking rules for fields in the Masking Policies section. Once masking mode is enabled, query results are automatically masked.
  7. Create business domains in the Semantic Layer, link tables and query examples. The Agent will preferentially use the metric definitions from semantic assets when answering questions.

Use Cases & Caveats

Well suited for scenarios where you need an agent to autonomously query a database while maintaining human auditability and controllability—for example, internal data analysts, operations staff, or customer support agents answering business data questions.

Note: The plugin runs with the current DSH process privileges. Review the source code and license before installing. The data directory contains plaintext connection passwords—do not commit it to a public repository.

Summary

dsh-agent-db-studio provides a complete “Agent + Web Panel” database management solution: the Agent queries and modifies data through 20 tools, write operations are mandatorily routed through ticket approval, masking and security guards are enforced at the engine layer, and the panel is limited to observation and control. It fills the “data management” gap in the DSH plugin ecosystem and is well suited for teams that need agent involvement in database operations while prioritizing security and auditability.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye