@deepseek-ai/dsh-native-command 0.0.1-rc.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 +28 -0
- package/README.i18n.yaml +6 -0
- package/README.md +27 -0
- package/README.zh.md +27 -0
- package/lib/index.js +38 -0
- package/lib/invariant.js +24 -0
- package/lib/types/index.d.ts +21 -0
- package/lib/types/invariant.d.ts +16 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, DeepSeek
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.i18n.yaml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
|
|
2
|
+
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
|
+
# after editing either side, bring the other along and re-record with:
|
|
4
|
+
# pnpm run verify-translation-pairing --write packages/util/native-command/README.md
|
|
5
|
+
README.md: dd9d1ddaf817b2ff77ec0cd01710053e918b4296
|
|
6
|
+
README.zh.md: 3ff8a392f2c511295adb0bf5f62b6e0527cbaea6
|
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# dsh-native-command
|
|
2
|
+
|
|
3
|
+
English | [中文](README.zh.md)
|
|
4
|
+
|
|
5
|
+
A **zero-dependency no-shell `execFile` runner** shared by host-native OS integrations: one `runNativeCommand(command, args, signal)` call spawns the executable directly (never a shell string), captures utf8 stdout/stderr, propagates the caller's abort into child termination, and hides the transient console window on Windows. Failures reject with the exit `code` and both captured streams attached, so callers classify (missing tool, cancelled, real failure) without re-running anything.
|
|
6
|
+
|
|
7
|
+
Its two consumers are the host-side native integrations: the [`directory-picker-native`](../../host/directory-picker-native/README.md) backend's OS chooser commands and the gateway's open-with-default-application hand-off ([`dsh-host-apiproxy`](../../host/apiproxy/README.md) `host.openPath`). The `NativeCommandRunner` type is their injectable command boundary.
|
|
8
|
+
|
|
9
|
+
It is a **library, not a service or plugin**: no `ctx`, registers nothing, holds no state, emits no events.
|
|
10
|
+
|
|
11
|
+
## Surface
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { runNativeCommand, type NativeCommandRunner } from '@deepseek-ai/dsh-native-command'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Model Experience
|
|
18
|
+
|
|
19
|
+
None, as this is host-side subprocess plumbing; nothing here reaches a model request.
|
|
20
|
+
|
|
21
|
+
#### KV Cache effect
|
|
22
|
+
|
|
23
|
+
None; this package neither assembles nor sends a provider request.
|
|
24
|
+
|
|
25
|
+
## Known Limitations and Deferred Work
|
|
26
|
+
|
|
27
|
+
- **No output bounding** — both streams buffer unbounded in memory; every current caller invokes small native tools whose output is a path or an error line. Adopt `dsh-retention` bounding before pointing this at commands with meaningful output volume.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# dsh-native-command
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 中文
|
|
4
|
+
|
|
5
|
+
宿主原生 OS 集成共享的**零依赖免 shell `execFile` 运行器**:一次 `runNativeCommand(command, args, signal)` 调用直接 spawn 可执行文件(绝不拼 shell 字符串),以 utf8 捕获 stdout/stderr,把调用方的 abort 传播为子进程终止,并在 Windows 上隐藏瞬时控制台窗口。失败时,调用会以错误拒绝;该错误附带退出 `code` 与两路已捕获输出,调用方无需重跑即可分类(工具缺失、已取消、真实失败)。
|
|
6
|
+
|
|
7
|
+
它的两个消费方都是宿主侧原生集成:[`directory-picker-native`](../../host/directory-picker-native/README.md) 后端的 OS 选择器命令,以及网关将路径交由默认应用打开的操作([`dsh-host-apiproxy`](../../host/apiproxy/README.md) 的 `host.openPath`)。`NativeCommandRunner` 类型是这些调用方的可注入命令边界。
|
|
8
|
+
|
|
9
|
+
它是**库,不是服务或插件**:没有 `ctx`、不注册任何东西、不持有状态、不发事件。
|
|
10
|
+
|
|
11
|
+
## 接口面
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { runNativeCommand, type NativeCommandRunner } from '@deepseek-ai/dsh-native-command'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 模型体验
|
|
18
|
+
|
|
19
|
+
无;这是宿主侧子进程管道,这里没有任何东西进入模型请求。
|
|
20
|
+
|
|
21
|
+
#### KV Cache 影响
|
|
22
|
+
|
|
23
|
+
无;该包既不组装也不发送提供方请求。
|
|
24
|
+
|
|
25
|
+
## 已知限制与暂缓事项
|
|
26
|
+
|
|
27
|
+
- **不做输出限量**——两路流在内存中无界缓冲;当前每个调用方只运行输出为一个路径或一行错误的小型原生工具。把它指向输出量可观的命令之前,先接入 `dsh-retention` 限量。
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
//#region lib/types/index.js
|
|
3
|
+
/**
|
|
4
|
+
* Shared no-shell `execFile` runner for host-native OS integrations (the
|
|
5
|
+
* native directory chooser, the open-with-default-application hand-off):
|
|
6
|
+
* utf8 stdio capture, abort propagation, Windows console hide. A library,
|
|
7
|
+
* not a plugin — no ctx, no state, no events.
|
|
8
|
+
* @module @deepseek-ai/dsh-native-command
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Run a host command with utf8 stdio, abort propagation, and Windows hide.
|
|
12
|
+
* @param command - executable path or PATH name.
|
|
13
|
+
* @param args - argv (never a shell string).
|
|
14
|
+
* @param signal - caller/connection lifetime; abort terminates the child.
|
|
15
|
+
* @returns captured stdout/stderr on exit 0.
|
|
16
|
+
*/
|
|
17
|
+
const runNativeCommand = (command, args, signal) => new Promise((resolve, reject) => {
|
|
18
|
+
execFile(command, [...args], {
|
|
19
|
+
encoding: "utf8",
|
|
20
|
+
signal,
|
|
21
|
+
windowsHide: true
|
|
22
|
+
}, (error, stdout, stderr) => {
|
|
23
|
+
if (error !== null) {
|
|
24
|
+
reject(Object.assign(new Error(error.message, { cause: error }), {
|
|
25
|
+
code: error.code,
|
|
26
|
+
stdout,
|
|
27
|
+
stderr
|
|
28
|
+
}));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
resolve({
|
|
32
|
+
stdout,
|
|
33
|
+
stderr
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
//#endregion
|
|
38
|
+
export { runNativeCommand };
|
package/lib/invariant.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region lib/types/invariant.js
|
|
2
|
+
/**
|
|
3
|
+
* Package-owned invariant companion for `@deepseek-ai/dsh-native-command`.
|
|
4
|
+
* @module @deepseek-ai/dsh-native-command/invariant
|
|
5
|
+
*/
|
|
6
|
+
const PACKAGE_NAME = "@deepseek-ai/dsh-native-command";
|
|
7
|
+
/** Cordis companion plugin name. */
|
|
8
|
+
const name = "native-command-invariant";
|
|
9
|
+
/** Service required before the companion can reserve package ownership. */
|
|
10
|
+
const inject = ["invariants"];
|
|
11
|
+
/**
|
|
12
|
+
* No runtime invariant: each run is one stateless child-process round trip
|
|
13
|
+
* with no owned event stream or mutable runtime data; behavior is enforced by
|
|
14
|
+
* unit tests.
|
|
15
|
+
*/
|
|
16
|
+
const install = () => {};
|
|
17
|
+
/**
|
|
18
|
+
* Register this package's invariant companion.
|
|
19
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
20
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
21
|
+
*/
|
|
22
|
+
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
23
|
+
//#endregion
|
|
24
|
+
export { apply, inject, name };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared no-shell `execFile` runner for host-native OS integrations (the
|
|
3
|
+
* native directory chooser, the open-with-default-application hand-off):
|
|
4
|
+
* utf8 stdio capture, abort propagation, Windows console hide. A library,
|
|
5
|
+
* not a plugin — no ctx, no state, no events.
|
|
6
|
+
* @module @deepseek-ai/dsh-native-command
|
|
7
|
+
*/
|
|
8
|
+
/** Testable command boundary; native implementations never invoke a shell. */
|
|
9
|
+
export type NativeCommandRunner = (command: string, args: readonly string[], signal: AbortSignal) => Promise<{
|
|
10
|
+
stdout: string;
|
|
11
|
+
stderr: string;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Run a host command with utf8 stdio, abort propagation, and Windows hide.
|
|
15
|
+
* @param command - executable path or PATH name.
|
|
16
|
+
* @param args - argv (never a shell string).
|
|
17
|
+
* @param signal - caller/connection lifetime; abort terminates the child.
|
|
18
|
+
* @returns captured stdout/stderr on exit 0.
|
|
19
|
+
*/
|
|
20
|
+
export declare const runNativeCommand: NativeCommandRunner;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Package-owned invariant companion for `@deepseek-ai/dsh-native-command`.
|
|
3
|
+
* @module @deepseek-ai/dsh-native-command/invariant
|
|
4
|
+
*/
|
|
5
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
+
/** Cordis companion plugin name. */
|
|
7
|
+
export declare const name = "native-command-invariant";
|
|
8
|
+
/** Service required before the companion can reserve package ownership. */
|
|
9
|
+
export declare const inject: string[];
|
|
10
|
+
/**
|
|
11
|
+
* Register this package's invariant companion.
|
|
12
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
13
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
14
|
+
*/
|
|
15
|
+
export declare const apply: (ctx: Context) => Promise<() => void>;
|
|
16
|
+
//# sourceMappingURL=invariant.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@deepseek-ai/dsh-native-command",
|
|
3
|
+
"description": "Zero-dependency no-shell execFile runner for host-native OS integrations: utf8 stdio capture, abort propagation, Windows hide",
|
|
4
|
+
"version": "0.0.1-rc.1",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "restricted"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
|
|
11
|
+
"directory": "packages/util/native-command"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "lib/index.js",
|
|
15
|
+
"types": "lib/types/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/types/index.d.ts",
|
|
19
|
+
"default": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./invariant": {
|
|
22
|
+
"types": "./lib/types/invariant.d.ts",
|
|
23
|
+
"default": "./lib/invariant.js"
|
|
24
|
+
},
|
|
25
|
+
"./src/*": "./src/*",
|
|
26
|
+
"./package.json": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"lib/index.js",
|
|
30
|
+
"lib/invariant.js",
|
|
31
|
+
"lib/types/**/*.d.ts"
|
|
32
|
+
],
|
|
33
|
+
"license": "BSD-3-Clause",
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@deepseek-ai/cordis": "^4.0.1-rc.1",
|
|
36
|
+
"@deepseek-ai/dsh-invariants": "^0.0.1-rc.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@deepseek-ai/cordis": "^4.0.1-rc.1",
|
|
40
|
+
"@deepseek-ai/dsh-invariants": "^0.0.1-rc.1"
|
|
41
|
+
}
|
|
42
|
+
}
|