@hydraharness/harness-native-command 0.1.1-rc.5

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 DeepSeek
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.md ADDED
@@ -0,0 +1,25 @@
1
+ # @hydraharness/harness-native-command
2
+
3
+ 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.
4
+
5
+ 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 ([`@hydraharness/harness-host-apiproxy`](../../host/apiproxy/README.md) `host.openPath`). The `NativeCommandRunner` type is their injectable command boundary.
6
+
7
+ It is a **library, not a service or plugin**: no `ctx`, registers nothing, holds no state, emits no events.
8
+
9
+ ## Surface
10
+
11
+ ```ts
12
+ import { runNativeCommand, type NativeCommandRunner } from '@hydraharness/harness-native-command'
13
+ ```
14
+
15
+ ## Model Experience
16
+
17
+ None, as this is host-side subprocess plumbing; nothing here reaches a model request.
18
+
19
+ #### KV Cache effect
20
+
21
+ None; this package neither assembles nor sends a provider request.
22
+
23
+ ## Known Limitations and Deferred Work
24
+
25
+ - **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 `@hydraharness/harness-output-retention` bounding before pointing this at commands with meaningful output volume.
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 @hydraharness/harness-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 };
@@ -0,0 +1,24 @@
1
+ //#region lib/types/invariant.js
2
+ /**
3
+ * Package-owned invariant companion for `@hydraharness/harness-native-command`.
4
+ * @module @hydraharness/harness-native-command/invariant
5
+ */
6
+ const PACKAGE_NAME = "@hydraharness/harness-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 @hydraharness/harness-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 `@hydraharness/harness-native-command`.
3
+ * @module @hydraharness/harness-native-command/invariant
4
+ */
5
+ import type { Context } from '@hydraharness/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": "@hydraharness/harness-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.1.1-rc.5",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/MaiHongPhong1902/Hydra-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": "MIT",
34
+ "peerDependencies": {
35
+ "@hydraharness/harness-invariants": "^0.1.1-rc.5",
36
+ "@hydraharness/cordis": "^4.0.2"
37
+ },
38
+ "devDependencies": {
39
+ "@hydraharness/harness-invariants": "^0.1.1-rc.5",
40
+ "@hydraharness/cordis": "^4.0.2"
41
+ }
42
+ }