@stardustlc/dsh-docker 0.2.0 → 0.3.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 stardustlc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.en.md CHANGED
@@ -6,10 +6,14 @@
6
6
 
7
7
  DSH (DeepSeek Harness) container-management plugin: runs the docker CLI through the official subprocess service with shell-free argv arrays, six tools including image listing, an approval gate on `docker_exec`, and **zero runtime dependencies**.
8
8
 
9
- ![npm version](https://img.shields.io/npm/v/dsh-docker?label=npm&color=blue) ![npm downloads](https://img.shields.io/npm/dm/dsh-docker) ![license](https://img.shields.io/npm/l/dsh-docker) ![stars](https://img.shields.io/github/stars/STARDUSTLC666/dsh-docker?style=social)
9
+ ![npm version](https://img.shields.io/npm/v/@stardustlc/dsh-docker?label=npm&color=blue) ![npm downloads](https://img.shields.io/npm/dm/@stardustlc/dsh-docker) ![license](https://img.shields.io/npm/l/@stardustlc/dsh-docker) ![stars](https://img.shields.io/github/stars/STARDUSTLC666/dsh-docker?style=social)
10
10
 
11
11
  [![Awesome DSH Plugin](https://awesome-dsh-plugin.com/badge.svg)](https://awesome-dsh-plugin.com)
12
12
 
13
+ ## Compatibility
14
+
15
+ Verified against source-run `@deepseek-ai/dsh@0.1.2-alpha.4` on 2026-09-02. Built for the cordis patch-bundle plugin model (`cordis.patch.yml` + `dsh.bundle.patch`). No runtime imports of `@deepseek-ai/*` internals.
16
+
13
17
  ## Installation
14
18
 
15
19
  ```bash
@@ -18,6 +22,15 @@ dsh plugin --profile web add @stardustlc/dsh-docker
18
22
 
19
23
  Requires Docker installed locally (`docker version` should work); use `dockerPath` when it is not on PATH.
20
24
 
25
+ ## Uninstall
26
+
27
+ ```bash
28
+ dsh plugin --profile web remove @stardustlc/dsh-docker
29
+ ```
30
+
31
+ Then restart the web service. To clean up fully, also remove the plugin entry from your profile `cordis.patch.yml` if you overrode it.
32
+
33
+
21
34
  ## Configuration
22
35
 
23
36
  ```yaml
package/README.md CHANGED
@@ -6,10 +6,14 @@
6
6
 
7
7
  DSH(DeepSeek Harness)容器管理插件:走官方 subprocess 服务跑 docker CLI,argv 数组无 shell 注入,`docker_exec` 默认审批门,**零运行时依赖**。
8
8
 
9
- ![npm version](https://img.shields.io/npm/v/dsh-docker?label=npm&color=blue) ![npm downloads](https://img.shields.io/npm/dm/dsh-docker) ![license](https://img.shields.io/npm/l/dsh-docker) ![stars](https://img.shields.io/github/stars/STARDUSTLC666/dsh-docker?style=social)
9
+ ![npm version](https://img.shields.io/npm/v/@stardustlc/dsh-docker?label=npm&color=blue) ![npm downloads](https://img.shields.io/npm/dm/@stardustlc/dsh-docker) ![license](https://img.shields.io/npm/l/@stardustlc/dsh-docker) ![stars](https://img.shields.io/github/stars/STARDUSTLC666/dsh-docker?style=social)
10
10
 
11
11
  [![Awesome DSH Plugin](https://awesome-dsh-plugin.com/badge.svg)](https://awesome-dsh-plugin.com)
12
12
 
13
+ ## 兼容性
14
+
15
+ 在 `@deepseek-ai/dsh@0.1.2-alpha.4` 源码模式下验证(2026-09-02)。遵循 cordis 组合包补丁模型(`cordis.patch.yml` + `dsh.bundle.patch`),运行时不 import 任何 `@deepseek-ai/*` 内部模块。
16
+
13
17
  ## 安装
14
18
 
15
19
  ```bash
@@ -18,6 +22,15 @@ dsh plugin --profile web add @stardustlc/dsh-docker
18
22
 
19
23
  需要本机装有 Docker(`docker version` 能出结果即可);不在 PATH 上时用 `dockerPath` 指定。
20
24
 
25
+ ## 卸载
26
+
27
+ ```bash
28
+ dsh plugin --profile web remove @stardustlc/dsh-docker
29
+ ```
30
+
31
+ 卸载后重启 Web 服务。如需彻底清理,可再手动删除自己 profile `cordis.patch.yml` 中覆盖的插件行。
32
+
33
+
21
34
  ## 配置
22
35
 
23
36
  ```yaml
package/lib/index.d.ts CHANGED
@@ -11,29 +11,35 @@ import { type DockerConfig } from './config.js';
11
11
  import { type SubprocessSpawnLike } from './exec.js';
12
12
  import { type DockerToolDefinition } from './tools.js';
13
13
  /** cordis 服务注入:apply 里要用 ctx.subprocess 与 ctx.tools。 */
14
+ export declare const name = "docker";
14
15
  export declare const inject: string[];
15
- /** 审批服务最小面。 */
16
- export interface DockerApproval {
17
- request(options: {
18
- agent?: unknown;
19
- toolName?: unknown;
20
- callId?: unknown;
21
- reason: string;
22
- signal?: unknown;
23
- }): Promise<'allowed-once' | 'cancelled' | 'unavailable' | string>;
16
+ /** Harness `tools/pre-execute` 的决策结果。 */
17
+ type DockerPreToolDecision = {
18
+ kind: 'allow';
19
+ } | {
20
+ kind: 'deny';
21
+ reason: string;
22
+ } | {
23
+ kind: 'ask';
24
+ reason?: string;
25
+ };
26
+ /** 审批策略需要读取的 alpha.4 工具执行字段。 */
27
+ interface DockerToolExecution {
28
+ readonly name: string;
29
+ readonly arguments: unknown;
24
30
  }
31
+ /** Harness `tools/pre-execute` waterfall 监听器。 */
32
+ type DockerPreExecuteListener = (exec: DockerToolExecution, next: () => Promise<DockerPreToolDecision>) => Promise<DockerPreToolDecision>;
25
33
  /** 插件所需的最小 ctx 面。 */
26
34
  export interface DockerPluginContext {
27
35
  subprocess: {
28
36
  spawn: SubprocessSpawnLike;
29
37
  };
30
38
  tools: {
31
- register(definition: DockerToolDefinition, options?: {
32
- prepend?: boolean;
33
- }): () => void;
39
+ register(definition: DockerToolDefinition): () => void;
34
40
  };
35
- get?(name: 'approval'): DockerApproval | undefined;
36
- on?(event: string, listener: () => void): () => void;
41
+ on(event: 'tools/pre-execute', listener: DockerPreExecuteListener): () => void;
42
+ on(event: 'dispose', listener: () => void): () => void;
37
43
  }
38
44
  /**
39
45
  * 插件入口:解析配置、封装执行器、注册六工具;docker_exec 注入审批门。
package/lib/index.js CHANGED
@@ -11,6 +11,7 @@ import { resolveConfig } from './config.js';
11
11
  import { createSubprocessRunner } from './exec.js';
12
12
  import { buildDockerTools } from './tools.js';
13
13
  /** cordis 服务注入:apply 里要用 ctx.subprocess 与 ctx.tools。 */
14
+ export const name = 'docker';
14
15
  export const inject = ['subprocess', 'tools'];
15
16
  /**
16
17
  * 插件入口:解析配置、封装执行器、注册六工具;docker_exec 注入审批门。
@@ -26,42 +27,27 @@ export function apply(ctx, config) {
26
27
  }
27
28
  const runner = createSubprocessRunner(ctx.subprocess.spawn, cfg.graceMs, cfg.timeoutMs);
28
29
  const tools = buildDockerTools(cfg, runner);
29
- const disposers = [];
30
- for (const definition of tools) {
31
- if (definition.name === 'docker_exec' && cfg.execApproval) {
32
- definition.gate = async (exec, next) => {
33
- const approval = ctx.get?.('approval');
34
- if (approval === undefined) {
35
- return { kind: 'deny', reason: 'docker_exec 需要确认,但当前环境没有审批通道(如 headless)。如确定安全,可在配置中设置 execApproval: false 后直接执行。' };
36
- }
37
- const record = (typeof exec === 'object' && exec !== null ? exec : {});
38
- const args = (typeof record.args === 'object' && record.args !== null ? record.args : {});
39
- const command = typeof args.command === 'string' ? args.command : '';
40
- const container = typeof args.container === 'string' ? args.container : '';
41
- const outcome = await approval.request({
42
- agent: record.agent,
43
- toolName: record.name,
44
- callId: record.callId,
45
- reason: '在容器 ' + container + ' 内执行:' + command.slice(0, 200),
46
- signal: record.signal,
47
- });
48
- if (outcome === 'allowed-once')
49
- return next();
50
- if (outcome === 'cancelled')
51
- return { kind: 'deny', reason: '容器内执行确认被取消,命令未执行。' };
52
- if (outcome === 'unavailable')
53
- return { kind: 'deny', reason: '容器内执行确认不可用(没有可用的审批界面),命令未执行。' };
54
- return { kind: 'deny', reason: '容器内执行未获批准:要么你拒绝了,要么当前会话处于 Full Access(审批策略 never)。若在 Full Access:切到 Read Only / Write 再执行,或关闭 execApproval(自行承担风险)。' };
30
+ if (cfg.execApproval) {
31
+ ctx.on('tools/pre-execute', async (exec, next) => {
32
+ if (exec.name !== 'docker_exec')
33
+ return next();
34
+ const args = (typeof exec.arguments === 'object' && exec.arguments !== null ? exec.arguments : {});
35
+ const command = typeof args.command === 'string' ? args.command : '';
36
+ const container = typeof args.container === 'string' ? args.container : '';
37
+ return {
38
+ kind: 'ask',
39
+ reason: 'docker_exec 需要确认:在容器 ' + (container || '(未指定)') + ' 内执行:' + command.slice(0, 200) + (command.length > 200 ? '…' : ''),
55
40
  };
56
- }
57
- disposers.push(ctx.tools.register(definition, { prepend: true }));
58
- }
59
- if (typeof ctx.on === 'function') {
60
- ctx.on('dispose', () => {
61
- for (const dispose of disposers)
62
- dispose();
63
41
  });
64
42
  }
43
+ const disposers = [];
44
+ for (const definition of tools) {
45
+ disposers.push(ctx.tools.register(definition));
46
+ }
47
+ ctx.on('dispose', () => {
48
+ for (const dispose of disposers)
49
+ dispose();
50
+ });
65
51
  }
66
52
  export * from './args.js';
67
53
  export * from './config.js';
package/lib/tools.d.ts CHANGED
@@ -17,7 +17,6 @@ export interface DockerToolDefinition {
17
17
  render(args: unknown, value: unknown): ContentBlock[];
18
18
  };
19
19
  execute(args: unknown, exec: unknown): Promise<unknown>;
20
- gate?(exec: unknown, next: () => Promise<unknown>): Promise<unknown>;
21
20
  timeoutMs?: number;
22
21
  }
23
22
  /** 构建五个工具定义。 */
package/lib/tools.js CHANGED
@@ -209,9 +209,6 @@ export function buildDockerTools(config, runner) {
209
209
  const result = await runChecked(runner, execArgs(cfg.dockerPath, container, command), timeout, 'docker exec');
210
210
  return { container, exitCode: result.exitCode, stdout: result.stdout };
211
211
  },
212
- gate(exec, next) {
213
- return next();
214
- },
215
212
  timeoutMs: timeout,
216
213
  };
217
214
  const dockerManage = {
@@ -239,5 +236,39 @@ export function buildDockerTools(config, runner) {
239
236
  },
240
237
  timeoutMs: timeout,
241
238
  };
242
- return [dockerPs, dockerLogs, dockerImages, dockerInspect, dockerExec, dockerManage];
239
+ const dockerHealth = {
240
+ name: 'docker_health',
241
+ description: 'dsh-docker 自检:验证 docker CLI 与守护进程是否可用(执行 docker version),并汇总安全配置(exec 审批门、超时)。遇到问题时先运行本工具定位。',
242
+ parameters: compileParameters({}),
243
+ output: {
244
+ schema: { type: 'object', additionalProperties: true },
245
+ render: (_args, value) => {
246
+ const rec = asRecord(value);
247
+ const checks = Array.isArray(rec.checks) ? rec.checks : [];
248
+ const lines = ['dsh-docker 自检' + (rec.ok === true ? ':正常。' : ':发现问题。')];
249
+ for (const item of checks) {
250
+ const c = asRecord(item);
251
+ lines.push('- ' + c.name + ':' + (c.ok === true ? '✅' : '❌ ' + String(c.detail ?? '')));
252
+ }
253
+ return [{ type: 'text', text: lines.join('\n') }];
254
+ },
255
+ },
256
+ async execute() {
257
+ const checks = [];
258
+ let ok = true;
259
+ try {
260
+ const result = await runChecked(runner, [cfg.dockerPath, 'version', '--format', '{{.Server.Version}}'], 15000, 'docker version');
261
+ checks.push({ name: 'docker daemon', ok: true, detail: 'server ' + result.stdout.trim() });
262
+ }
263
+ catch (error) {
264
+ ok = false;
265
+ checks.push({ name: 'docker daemon', ok: false, detail: error instanceof Error ? error.message : String(error) });
266
+ }
267
+ checks.push({ name: 'exec 审批门', ok: true, detail: cfg.execApproval === true ? '开启' : '关闭' });
268
+ checks.push({ name: '超时配置', ok: true, detail: 'timeoutMs=' + cfg.timeoutMs + ', graceMs=' + cfg.graceMs });
269
+ return { ok, plugin: 'dsh-docker', checks };
270
+ },
271
+ timeoutMs: 20000,
272
+ };
273
+ return [dockerPs, dockerLogs, dockerImages, dockerInspect, dockerExec, dockerManage, dockerHealth];
243
274
  }
package/package.json CHANGED
@@ -1,60 +1,59 @@
1
- {
2
- "name": "@stardustlc/dsh-docker",
3
- "version": "0.2.0",
4
- "description": "DSH 容器管理插件:docker_ps/logs/images/inspect/exec/manage 六工具,走官方 subprocess 服务跑 docker CLI、argv 无 shell 注入、exec 审批门、零运行时依赖。",
5
- "type": "module",
6
- "main": "lib/index.js",
7
- "types": "lib/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./lib/index.d.ts",
11
- "default": "./lib/index.js"
12
- },
13
- "./cordis.patch.yml": "./cordis.patch.yml",
14
- "./package.json": "./package.json"
15
- },
16
- "files": [
17
- "lib",
18
- "cordis.patch.yml",
19
- "README.md",
20
- "README.en.md"
21
- ],
22
- "scripts": {
23
- "build": "tsc -p tsconfig.json",
24
- "prepare": "tsc -p tsconfig.json",
25
- "typecheck": "tsc -p tsconfig.json --noEmit",
26
- "test": "pnpm run build && node --test \"test/*.test.mjs\"",
27
- "prepublishOnly": "pnpm run build"
28
- },
29
- "dsh": {
30
- "bundle": {
31
- "patch": "./cordis.patch.yml"
32
- }
33
- },
34
- "keywords": [
35
- "dsh",
36
- "deepseek-harness",
37
- "plugin",
38
- "docker",
39
- "container",
40
- "devops"
41
- ],
42
- "license": "MIT",
43
- "engines": {
44
- "node": ">=20"
45
- },
46
- "devDependencies": {
47
- "@types/node": "^24.0.0",
48
- "typescript": "^5.6.0"
49
- },
50
- "repository": {
51
- "type": "git",
52
- "url": "git+https://github.com/STARDUSTLC666/dsh-docker.git"
53
- },
54
- "bugs": {
55
- "url": "https://github.com/STARDUSTLC666/dsh-docker/issues"
56
- },
57
- "homepage": "https://github.com/STARDUSTLC666/dsh-docker#readme",
58
- "author": "stardustlc",
59
- "packageManager": "pnpm@11.7.0"
60
- }
1
+ {
2
+ "name": "@stardustlc/dsh-docker",
3
+ "version": "0.3.1",
4
+ "description": "DSH 容器管理插件:docker_ps/logs/images/inspect/exec/manage 六工具,走官方 subprocess 服务跑 docker CLI、argv 无 shell 注入、exec 审批门、零运行时依赖。",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "types": "lib/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./lib/index.d.ts",
11
+ "default": "./lib/index.js"
12
+ },
13
+ "./cordis.patch.yml": "./cordis.patch.yml",
14
+ "./package.json": "./package.json"
15
+ },
16
+ "files": [
17
+ "lib",
18
+ "cordis.patch.yml",
19
+ "README.md",
20
+ "README.en.md"
21
+ ],
22
+ "scripts": {
23
+ "build": "tsc -p tsconfig.json",
24
+ "typecheck": "tsc -p tsconfig.json --noEmit",
25
+ "test": "pnpm run build && node --test \"test/*.test.mjs\"",
26
+ "prepublishOnly": "pnpm run build"
27
+ },
28
+ "dsh": {
29
+ "bundle": {
30
+ "patch": "./cordis.patch.yml"
31
+ }
32
+ },
33
+ "keywords": [
34
+ "dsh",
35
+ "deepseek-harness",
36
+ "plugin",
37
+ "docker",
38
+ "container",
39
+ "devops"
40
+ ],
41
+ "license": "MIT",
42
+ "engines": {
43
+ "node": ">=22"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^24.0.0",
47
+ "typescript": "^5.6.0"
48
+ },
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/STARDUSTLC666/dsh-docker.git"
52
+ },
53
+ "bugs": {
54
+ "url": "https://github.com/STARDUSTLC666/dsh-docker/issues"
55
+ },
56
+ "homepage": "https://github.com/STARDUSTLC666/dsh-docker#readme",
57
+ "author": "stardustlc",
58
+ "packageManager": "pnpm@11.7.0"
59
+ }