@yejiming/dsh-data-agent 0.0.6 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@yejiming/dsh-data-agent",
3
- "description": "Data Agent for the dsh web GUI: session-scoped database connections (MySQL/PostgreSQL/SQLite), the sqlcmd tool, the data-agent agent preset, and the database conversation-view tab",
4
- "version": "0.0.6",
3
+ "description": "Data Agent for DSH Web and TUI: shared database connections, a masked TUI form, secure credential references, SQL tools, and the data-agent preset",
4
+ "version": "0.0.9",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -28,6 +28,10 @@
28
28
  "types": "./lib/types/tool.d.ts",
29
29
  "default": "./lib/tool.js"
30
30
  },
31
+ "./command": {
32
+ "types": "./lib/types/command.d.ts",
33
+ "default": "./lib/command.js"
34
+ },
31
35
  "./invariant": {
32
36
  "types": "./lib/types/invariant.d.ts",
33
37
  "default": "./lib/invariant.js"
@@ -48,6 +52,7 @@
48
52
  "inject": [
49
53
  "@deepseek-ai/dsh-client-locale",
50
54
  "@deepseek-ai/dsh-client-runtime",
55
+ "@deepseek-ai/dsh-client-ui-tool",
51
56
  "@deepseek-ai/dsh-client-ui-conversation"
52
57
  ],
53
58
  "platform": "web"
@@ -67,36 +72,88 @@
67
72
  ],
68
73
  "license": "MIT",
69
74
  "dependencies": {
70
- "schemastery": "^3.18.0"
75
+ "echarts": "^6.1.0",
76
+ "schemastery": "^3.18.0",
77
+ "zod": "^4.4.3"
71
78
  },
72
79
  "peerDependencies": {
73
80
  "@deepseek-ai/cordis": "^4.0.1",
81
+ "@deepseek-ai/dsh-agent": "^0.1.0-rc.6",
74
82
  "@deepseek-ai/dsh-client-locale": "^0.1.0-rc.6",
75
83
  "@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.6",
76
84
  "@deepseek-ai/dsh-client-ui-conversation": "^0.1.0-rc.6",
77
85
  "@deepseek-ai/dsh-client-ui-primitives": "^0.1.0-rc.6",
78
86
  "@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.6",
87
+ "@deepseek-ai/dsh-client-ui-tool": "^0.1.0-rc.6",
88
+ "@deepseek-ai/dsh-commands": "^0.1.0-rc.6",
89
+ "@deepseek-ai/dsh-credentials": "^0.1.0-rc.6",
79
90
  "@deepseek-ai/dsh-host-webserver": "^0.1.0-rc.6",
80
91
  "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
92
+ "@deepseek-ai/dsh-storage": "^0.1.0-rc.6",
93
+ "@deepseek-ai/dsh-storage-domain": "^0.1.0-rc.6",
94
+ "@deepseek-ai/dsh-storage-json": "^0.1.0-rc.6",
81
95
  "@deepseek-ai/dsh-subprocess": "^0.1.0-rc.6",
82
96
  "@deepseek-ai/dsh-tools": "^0.1.0-rc.6",
83
- "react": "^18.2.0"
97
+ "@deepseek-ai/dsh-user-questions": "^0.1.0-rc.6",
98
+ "react": "^18.2.0 || ^19.0.0"
99
+ },
100
+ "peerDependenciesMeta": {
101
+ "@deepseek-ai/dsh-client-locale": {
102
+ "optional": true
103
+ },
104
+ "@deepseek-ai/dsh-client-runtime": {
105
+ "optional": true
106
+ },
107
+ "@deepseek-ai/dsh-client-ui-conversation": {
108
+ "optional": true
109
+ },
110
+ "@deepseek-ai/dsh-client-ui-primitives": {
111
+ "optional": true
112
+ },
113
+ "@deepseek-ai/dsh-client-ui-slots": {
114
+ "optional": true
115
+ },
116
+ "@deepseek-ai/dsh-host-webserver": {
117
+ "optional": true
118
+ },
119
+ "@deepseek-ai/dsh-user-questions": {
120
+ "optional": true
121
+ },
122
+ "react": {
123
+ "optional": true
124
+ },
125
+ "@deepseek-ai/dsh-client-ui-tool": {
126
+ "optional": true
127
+ }
84
128
  },
85
129
  "devDependencies": {
86
130
  "@deepseek-ai/cordis": "^4.0.1",
131
+ "@deepseek-ai/dsh-agent": "^0.1.0-rc.6",
87
132
  "@deepseek-ai/dsh-client-locale": "^0.1.0-rc.6",
88
133
  "@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.6",
89
134
  "@deepseek-ai/dsh-client-ui-conversation": "^0.1.0-rc.6",
90
135
  "@deepseek-ai/dsh-client-ui-primitives": "^0.1.0-rc.6",
91
136
  "@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.6",
137
+ "@deepseek-ai/dsh-client-ui-tool": "0.1.0-rc.6",
138
+ "@deepseek-ai/dsh-commands": "^0.1.0-rc.6",
139
+ "@deepseek-ai/dsh-credentials": "^0.1.0-rc.6",
92
140
  "@deepseek-ai/dsh-host-webserver": "^0.1.0-rc.6",
93
141
  "@deepseek-ai/dsh-invariants": "^0.1.0-rc.6",
142
+ "@deepseek-ai/dsh-storage": "^0.1.0-rc.6",
143
+ "@deepseek-ai/dsh-storage-domain": "^0.1.0-rc.6",
144
+ "@deepseek-ai/dsh-storage-json": "^0.1.0-rc.6",
94
145
  "@deepseek-ai/dsh-subprocess": "^0.1.0-rc.6",
146
+ "@deepseek-ai/dsh-subprocess-local": "0.1.0-rc.6",
95
147
  "@deepseek-ai/dsh-tools": "^0.1.0-rc.6",
148
+ "@deepseek-ai/dsh-user-questions": "^0.1.0-rc.6",
149
+ "@testing-library/dom": "^10.4.1",
150
+ "@testing-library/react": "^16.3.2",
96
151
  "@types/node": "^25.0.0",
97
152
  "@types/react": "~18.3.1",
153
+ "jsdom": "^30.0.1",
98
154
  "lightningcss": "^1.32.0",
99
155
  "react": "^18.2.0",
156
+ "react-dom": "^18.3.1",
100
157
  "schemastery": "^3.18.0",
101
158
  "tsdown": "^0.22.2",
102
159
  "typescript": "^6.0.3",
@@ -8,15 +8,14 @@
8
8
  # the registries themselves, the sandbox and approval stack, persistence, and
9
9
  # the model route.
10
10
  #
11
- # A preset composes what an agent HAS instead of subtracting from a shared
12
- # default: every model-facing tool row absent from this file is simply not
13
- # registered for agents on this preset. The database row below registers
14
- # sql-query / sql-write / sqlcmd and the fs row registers read / write / edit;
15
- # bash, glob/grep, str_replace_editor, skill, todo, goal, plan, web, subagent,
16
- # workflow, tasks, and the rest are all absent, i.e. disabled.
11
+ # The database row below registers sql-query / sql-write / sql-cmd and the
12
+ # editor row registers DSH's native str_replace_editor. The final row installs
13
+ # a deny restriction for the host/community tools visible at preset mount, so
14
+ # describe_image, ssh_*, bash, web, etc. stay unavailable while the four/five
15
+ # tools owned by this standing scope remain visible to joined agents.
17
16
  #
18
- # All three rows only CONSUME host services (the tools registry, subprocess,
19
- # the dataAgentConnections connection store), so no `isolate` realm is needed.
17
+ # All four rows only CONSUME host services (the tools/commands registries,
18
+ # filesystem, subprocess, and dataAgentConnections).
20
19
 
21
20
  # ── identity ────────────────────────────────────────────────────────────────
22
21
 
@@ -27,23 +26,40 @@
27
26
  config:
28
27
  text: >-
29
28
  你是数据工程师 Agent。工作目录 {{cwd}}。可用工具:sql-query(只读 SQL,返回结构化
30
- JSON 结果)、sql-write(写/管理 SQL,单条自动提交)、sqlcmd(原始客户端输出,兼容
31
- SHOW TABLES、DESCRIBE users 等命令)、read、write、edit(读写改本地文件)。工作流:
32
- 先用 sql-query 探查表结构与样例数据(禁止臆造表名与列名),把 SQL 写入 .sql 文件
33
- (write/edit),再用 sql-query 执行只读查询或 sql-write 执行写入并核对结果;
34
- 结果可疑时缩小查询范围重试。每次数据库工具调用只允许一条 SQL 语句。
29
+ JSON 结果)、sql-write(写/管理 SQL,单条自动提交)、sql-cmd(原始客户端输出,兼容
30
+ SHOW TABLES、DESCRIBE users 等命令)、str_replace_editor(查看、创建和修改本地文件)。
31
+ Web 界面可用时另有 render-analysis:把一次调用渲染成一份版本化分析报告(1-6 个只读
32
+ 数据集、1-8 metric/line/bar/pie/scatter/table 视图,同一数据集可被多个视图通过
33
+ datasetId 复用)。是否生成分析由你自主判断:先用 sql-query 探查表结构与样例数据并
34
+ 核对事实(禁止臆造表名与列名);schema 探查、单标量或原始明细等无视觉增益的查询
35
+ 直接回答、不强制画图;简单关系可生成一个主图,涉及多指标、时间或分群的复杂问题可
36
+ 生成 3-6 个互补视图。聚合、Top N、排序必须写在 SQL 中,line/time 数据需 ORDER BY。
37
+ 工作流:先用 str_replace_editor 把 SQL 写入 .sql 文件,再用 sql-query 执行只读查询或
38
+ sql-write 执行写入并核对结果;结果可疑时缩小查询范围重试。每次数据库工具调用
39
+ 只允许一条 SQL 语句。
35
40
 
36
41
  # ── filesystem ──────────────────────────────────────────────────────────────
37
42
 
38
- # The project's own fs tools: read / write / edit (no search tools here).
39
- - id: tool-fs
40
- name: '@deepseek-ai/dsh-tool-fs'
43
+ # DSH's native all-in-one file editor (no separate read/write/edit tools).
44
+ - id: tool-str-replace-editor
45
+ name: '@deepseek-ai/dsh-tool-str-replace-editor'
46
+ config:
47
+ maxOutputChars: 16000
41
48
 
42
49
  # ── database ────────────────────────────────────────────────────────────────
43
50
 
44
51
  # This package's database tool half; injects the host's subprocess service and
45
52
  # the dataAgentConnections connection store (see the data-agent host row).
46
53
  # Registers sql-query (structured read), sql-write (explicit write), and the
47
- # legacy sqlcmd raw-terminal tool.
48
- - id: tool-sqlcmd
54
+ # sql-cmd raw-terminal compatibility tool. When the host provides the webServer
55
+ # service (Web profile), it additionally registers render-analysis directly
56
+ # in this standing preset scope, so blank-session preset switches see it too.
57
+ - id: tool-sql-cmd
49
58
  name: '@yejiming/dsh-data-agent/tool'
59
+
60
+ # Human command surface consumed by dsh-tui and any other command adapter.
61
+ # It is preset-scoped, recordInput=false, and adds no model-visible tools. It
62
+ # also masks every host-global inherited model tool at the standing preset
63
+ # scope. Sibling str_replace_editor/database registrations remain visible.
64
+ - id: database-command
65
+ name: '@yejiming/dsh-data-agent/command'
@@ -1,3 +1,3 @@
1
1
  name: 数据模式
2
- description: 数据工程师 Agent:连接 MySQL/PostgreSQL/SQLite 数据库,用 sql-query/sql-write/sqlcmdread/write/edit 工具探查 schema、编写并执行 SQL
2
+ description: 数据工程师 Agent:连接 MySQL/PostgreSQL/SQLite 数据库,用 sql-query/sql-write/sql-cmdDSH 原生 str_replace_editor 探查 schema、编写并执行 SQL;Web 界面还可由 Agent 自主调用 render-analysis 生成单图或多视图分析报告。
3
3
  order: 4
@@ -1,86 +0,0 @@
1
- import { c as buildIntrospectTemplate, l as buildStructuredQueryTemplate, s as buildClientTemplate } from "./defaults-Bac6QvNt.js";
2
- //#region src/query.ts
3
- /** Read one collected stream from offset 0. */
4
- function readCaptured(reader) {
5
- if (reader === void 0) return {
6
- text: "",
7
- truncated: false
8
- };
9
- const read = reader.readFrom(0);
10
- return {
11
- text: read.text,
12
- truncated: read.lossy
13
- };
14
- }
15
- /**
16
- * Run one SQL text through the type's CLI client. The SQL is written to the
17
- * child's stdin (`{ data }` batch disposition) so it never appears in argv;
18
- * passwords travel in the env entries built by the template.
19
- *
20
- * Failure classification:
21
- * - the caller's external signal (e.g. the tool exec signal) aborts → the
22
- * abort reason propagates;
23
- * - the internal timeout fires → an Error naming the deadline is thrown;
24
- * - the executable cannot be resolved → an Error naming the command is thrown;
25
- * - the process runs to completion → `{ exitCode, stdout, stderr, truncated }`
26
- * is returned even for a non-zero exit (the caller decides what that means).
27
- * @param ctx - context exposing the subprocess service.
28
- * @param connection - the stored connection (password included).
29
- * @param sql - the SQL text (or client command) to run.
30
- * @param options - timeouts, caps, client overrides.
31
- * @param externalSignal - caller-owned cancellation (the tool exec signal).
32
- * @param introspect - use the machine-readable introspection flag set.
33
- * @returns the captured outcome.
34
- */
35
- async function runClientQuery(ctx, connection, sql, options, externalSignal, introspect = false) {
36
- const template = options.mode === "structured" ? buildStructuredQueryTemplate(connection.type, connection, options.clients[connection.type]) : options.mode === "introspect" || introspect ? buildIntrospectTemplate(connection.type, connection, options.clients[connection.type]) : buildClientTemplate(connection.type, connection, options.clients[connection.type]);
37
- const controller = new AbortController();
38
- const timer = setTimeout(() => controller.abort(/* @__PURE__ */ new Error(`查询超过 ${options.timeoutMs}ms 未完成,已终止客户端进程`)), options.timeoutMs);
39
- const onExternalAbort = () => {
40
- controller.abort(externalSignal.reason);
41
- };
42
- if (externalSignal.aborted) controller.abort(externalSignal.reason);
43
- else externalSignal.addEventListener("abort", onExternalAbort, { once: true });
44
- try {
45
- let executable;
46
- try {
47
- executable = await ctx.subprocess.resolveExecutable(template.command, template.env, controller.signal);
48
- } catch (error) {
49
- controller.signal.throwIfAborted();
50
- throw new Error(`无法解析数据库客户端 "${template.command}"(${error instanceof Error ? error.message : String(error)});请确认客户端已安装,或在 data-agent 插件配置的 clients 中覆盖命令名/路径`);
51
- }
52
- const handle = ctx.subprocess.spawn({
53
- argv: [executable, ...template.args],
54
- cwd: process.cwd(),
55
- stdio: {
56
- stdin: { data: `${template.stdinPrefix}${sql}\n` },
57
- stdout: { maxBytes: options.maxResultChars },
58
- stderr: { maxBytes: options.maxResultChars }
59
- },
60
- graceMs: options.graceMs ?? 5e3,
61
- signal: controller.signal,
62
- env: template.env
63
- });
64
- let outcome;
65
- try {
66
- outcome = await handle.done;
67
- } catch (error) {
68
- controller.signal.throwIfAborted();
69
- throw new Error(`启动数据库客户端失败:${error instanceof Error ? error.message : String(error)}`);
70
- }
71
- if (controller.signal.aborted) controller.signal.throwIfAborted();
72
- const stdout = readCaptured(handle.collected.stdout);
73
- const stderr = readCaptured(handle.collected.stderr);
74
- return {
75
- exitCode: outcome.exitCode,
76
- stdout: stdout.text,
77
- stderr: stderr.text,
78
- truncated: stdout.truncated || stderr.truncated
79
- };
80
- } finally {
81
- clearTimeout(timer);
82
- externalSignal.removeEventListener("abort", onExternalAbort);
83
- }
84
- }
85
- //#endregion
86
- export { runClientQuery as t };