@stardustlc/dsh-docker 0.3.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/README.en.md CHANGED
@@ -6,13 +6,13 @@
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
13
  ## Compatibility
14
14
 
15
- Verified against `@deepseek-ai/dsh@0.1.1-rc.2` on 2026-08-26. Built for the cordis patch-bundle plugin model (`cordis.patch.yml` + `dsh.bundle.patch`). No runtime imports of `@deepseek-ai/*` internals.
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
16
 
17
17
  ## Installation
18
18
 
@@ -83,4 +83,4 @@ pnpm test # build + 24 tests
83
83
 
84
84
  ## License
85
85
 
86
- MIT
86
+ MIT
package/README.md CHANGED
@@ -6,13 +6,13 @@
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
13
  ## 兼容性
14
14
 
15
- 在 `@deepseek-ai/dsh@0.1.1-rc.2` 上验证(2026-08-26)。遵循 cordis 组合包补丁模型(`cordis.patch.yml` + `dsh.bundle.patch`),运行时不 import 任何 `@deepseek-ai/*` 内部模块。
15
+ 在 `@deepseek-ai/dsh@0.1.2-alpha.4` 源码模式下验证(2026-09-02)。遵循 cordis 组合包补丁模型(`cordis.patch.yml` + `dsh.bundle.patch`),运行时不 import 任何 `@deepseek-ai/*` 内部模块。
16
16
 
17
17
  ## 安装
18
18
 
@@ -83,4 +83,4 @@ pnpm test # 构建 + 24 个测试
83
83
 
84
84
  ## License
85
85
 
86
- MIT
86
+ MIT
package/lib/index.d.ts CHANGED
@@ -13,28 +13,33 @@ import { type DockerToolDefinition } from './tools.js';
13
13
  /** cordis 服务注入:apply 里要用 ctx.subprocess 与 ctx.tools。 */
14
14
  export declare const name = "docker";
15
15
  export declare const inject: string[];
16
- /** 审批服务最小面。 */
17
- export interface DockerApproval {
18
- request(options: {
19
- agent?: unknown;
20
- toolName?: unknown;
21
- callId?: unknown;
22
- reason: string;
23
- signal?: unknown;
24
- }): 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;
25
30
  }
31
+ /** Harness `tools/pre-execute` waterfall 监听器。 */
32
+ type DockerPreExecuteListener = (exec: DockerToolExecution, next: () => Promise<DockerPreToolDecision>) => Promise<DockerPreToolDecision>;
26
33
  /** 插件所需的最小 ctx 面。 */
27
34
  export interface DockerPluginContext {
28
35
  subprocess: {
29
36
  spawn: SubprocessSpawnLike;
30
37
  };
31
38
  tools: {
32
- register(definition: DockerToolDefinition, options?: {
33
- prepend?: boolean;
34
- }): () => void;
39
+ register(definition: DockerToolDefinition): () => void;
35
40
  };
36
- get?(name: 'approval'): DockerApproval | undefined;
37
- on?(event: string, listener: () => void): () => void;
41
+ on(event: 'tools/pre-execute', listener: DockerPreExecuteListener): () => void;
42
+ on(event: 'dispose', listener: () => void): () => void;
38
43
  }
39
44
  /**
40
45
  * 插件入口:解析配置、封装执行器、注册六工具;docker_exec 注入审批门。
package/lib/index.js CHANGED
@@ -27,42 +27,27 @@ export function apply(ctx, config) {
27
27
  }
28
28
  const runner = createSubprocessRunner(ctx.subprocess.spawn, cfg.graceMs, cfg.timeoutMs);
29
29
  const tools = buildDockerTools(cfg, runner);
30
- const disposers = [];
31
- for (const definition of tools) {
32
- if (definition.name === 'docker_exec' && cfg.execApproval) {
33
- definition.gate = async (exec, next) => {
34
- const approval = ctx.get?.('approval');
35
- if (approval === undefined) {
36
- return { kind: 'deny', reason: 'docker_exec 需要确认,但当前环境没有审批通道(如 headless)。如确定安全,可在配置中设置 execApproval: false 后直接执行。' };
37
- }
38
- const record = (typeof exec === 'object' && exec !== null ? exec : {});
39
- const args = (typeof record.args === 'object' && record.args !== null ? record.args : {});
40
- const command = typeof args.command === 'string' ? args.command : '';
41
- const container = typeof args.container === 'string' ? args.container : '';
42
- const outcome = await approval.request({
43
- agent: record.agent,
44
- toolName: record.name,
45
- callId: record.callId,
46
- reason: '在容器 ' + container + ' 内执行:' + command.slice(0, 200),
47
- signal: record.signal,
48
- });
49
- if (outcome === 'allowed-once')
50
- return next();
51
- if (outcome === 'cancelled')
52
- return { kind: 'deny', reason: '容器内执行确认被取消,命令未执行。' };
53
- if (outcome === 'unavailable')
54
- return { kind: 'deny', reason: '容器内执行确认不可用(没有可用的审批界面),命令未执行。' };
55
- 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 ? '…' : ''),
56
40
  };
57
- }
58
- disposers.push(ctx.tools.register(definition, { prepend: true }));
59
- }
60
- if (typeof ctx.on === 'function') {
61
- ctx.on('dispose', () => {
62
- for (const dispose of disposers)
63
- dispose();
64
41
  });
65
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
+ });
66
51
  }
67
52
  export * from './args.js';
68
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 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stardustlc/dsh-docker",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "DSH 容器管理插件:docker_ps/logs/images/inspect/exec/manage 六工具,走官方 subprocess 服务跑 docker CLI、argv 无 shell 注入、exec 审批门、零运行时依赖。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",