@aexhq/tool-bash 7.0.1 → 8.0.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.md +2 -3
- package/dist/index.d.ts +1 -9
- package/dist/index.js +2 -9
- package/dist/packages/tool-bash/runtime/run.d.ts +8 -0
- package/dist/packages/tool-bash/runtime/run.js +19 -0
- package/dist/packages/tool-bash/src/index.d.ts +7 -0
- package/dist/packages/tool-bash/src/index.js +10 -0
- package/dist/shared/tool-runtime.d.ts +5 -0
- package/dist/shared/tool-runtime.js +10 -0
- package/package.json +18 -4
- /package/dist/{schema.d.ts → packages/tool-bash/src/schema.d.ts} +0 -0
- /package/dist/{schema.js → packages/tool-bash/src/schema.js} +0 -0
package/README.md
CHANGED
|
@@ -11,8 +11,7 @@ const tools = [bash({ env: workspace })];
|
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
Requires bash and a writable workspace. The chosen Environment prepares and executes the
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
The factory requires an explicit `env` and accepts no other options.
|
|
14
|
+
exact published package through its `./runtime` export. The Environment owns isolation and resource grants.
|
|
15
|
+
Omit `env` to run in the registering Node application; pass `{ env: workspace }` for an isolated prepared Environment. The factory accepts no configuration options.
|
|
17
16
|
|
|
18
17
|
Run `npm test --workspace @aexhq/tool-bash` from the repository root.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
export declare const bash: (
|
|
2
|
-
readonly env: import("@aexhq/brain").Environment;
|
|
3
|
-
} & Record<never, never>) => import("@aexhq/brain").PlacedTool<{
|
|
4
|
-
command: string;
|
|
5
|
-
}, {
|
|
6
|
-
exit_code: number;
|
|
7
|
-
stdout: string;
|
|
8
|
-
stderr: string;
|
|
9
|
-
}>;
|
|
1
|
+
export declare const bash: typeof import("./packages/tool-bash/src/index.js")["bash"];
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export const bash = tool({
|
|
4
|
-
name: "bash",
|
|
5
|
-
description: "Run a Bash command in the session Environment workspace.",
|
|
6
|
-
input: inputSchema,
|
|
7
|
-
output: outputSchema,
|
|
8
|
-
implementation: Object.freeze({ type: "aex_official_tool", version: 1, name: "bash" }),
|
|
9
|
-
});
|
|
1
|
+
import { bindTool } from "@aexhq/brain";
|
|
2
|
+
export const bash = bindTool({"definition":{"name":"bash","description":"Run a Bash command in the session Environment workspace.","inputSchema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"command":{"type":"string","minLength":1}},"required":["command"]},"outputSchema":{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"exit_code":{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991},"stdout":{"type":"string"},"stderr":{"type":"string"}},"required":["exit_code","stdout","stderr"],"additionalProperties":false}}}, {"type":"node_package","package":"@aexhq/tool-bash","version":"8.0.1","entry":"./runtime","export":"bash"}, { url: new URL("./packages/tool-bash/src/index.js", import.meta.url), export: "bash" });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { inputSchema } from "../src/schema.js";
|
|
3
|
+
import type { RuntimeContext } from "../../../shared/tool-runtime.js";
|
|
4
|
+
export declare function run(input: z.output<typeof inputSchema>, context: RuntimeContext): Promise<{
|
|
5
|
+
exit_code: number;
|
|
6
|
+
stdout: string;
|
|
7
|
+
stderr: string;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
export async function run(input, context) {
|
|
4
|
+
try {
|
|
5
|
+
const { stdout, stderr } = await promisify(execFile)("bash", ["-lc", input.command], {
|
|
6
|
+
signal: context.signal,
|
|
7
|
+
cwd: context.workspace,
|
|
8
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
9
|
+
});
|
|
10
|
+
return { exit_code: 0, stdout, stderr };
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
const failure = error;
|
|
14
|
+
if (typeof failure.code === "number") {
|
|
15
|
+
return { exit_code: failure.code, stdout: failure.stdout ?? "", stderr: failure.stderr ?? "" };
|
|
16
|
+
}
|
|
17
|
+
throw new Error(failure.stderr?.trim() || failure.message || "bash failed");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { tool } from "@aexhq/brain";
|
|
2
|
+
import { run } from "../runtime/run.js";
|
|
3
|
+
import { inputSchema, outputSchema } from "./schema.js";
|
|
4
|
+
export const bash = tool({
|
|
5
|
+
name: "bash",
|
|
6
|
+
description: "Run a Bash command in the session Environment workspace.",
|
|
7
|
+
input: inputSchema,
|
|
8
|
+
output: outputSchema,
|
|
9
|
+
run: async (input, context) => context.finish(await run(input, { workspace: process.cwd(), signal: context.signal })),
|
|
10
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isAbsolute, relative, resolve } from "node:path";
|
|
2
|
+
export function workspacePath(workspace, requested) {
|
|
3
|
+
const root = resolve(workspace);
|
|
4
|
+
const target = resolve(root, requested);
|
|
5
|
+
const within = relative(root, target);
|
|
6
|
+
if (within === ".." || within.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) || isAbsolute(within)) {
|
|
7
|
+
throw new Error(`${requested} is outside the Environment workspace`);
|
|
8
|
+
}
|
|
9
|
+
return target;
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aexhq/tool-bash",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.1",
|
|
4
4
|
"description": "Run a Bash command in the session Environment workspace.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://aex.dev",
|
|
@@ -23,23 +23,37 @@
|
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
24
|
"import": "./dist/index.js"
|
|
25
25
|
},
|
|
26
|
-
"./package.json": "./package.json"
|
|
26
|
+
"./package.json": "./package.json",
|
|
27
|
+
"./runtime": {
|
|
28
|
+
"types": "./dist/packages/tool-bash/src/index.d.ts",
|
|
29
|
+
"import": "./dist/packages/tool-bash/src/index.js"
|
|
30
|
+
}
|
|
27
31
|
},
|
|
28
32
|
"files": [
|
|
29
33
|
"dist",
|
|
30
34
|
"README.md"
|
|
31
35
|
],
|
|
32
36
|
"scripts": {
|
|
33
|
-
"build": "node ../../tools/clean-dist.mjs && tsc -p tsconfig.json &&
|
|
37
|
+
"build": "node ../../tools/clean-dist.mjs && tsc -p tsconfig.json && node ../../tools/build-tool-runtime.mjs",
|
|
34
38
|
"test": "npm run build && node --test test/*.test.mjs",
|
|
35
39
|
"prepack": "npm run build"
|
|
36
40
|
},
|
|
37
41
|
"dependencies": {
|
|
38
|
-
"@aexhq/brain": "0.
|
|
42
|
+
"@aexhq/brain": "0.31.0",
|
|
39
43
|
"zod": "4.4.3"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
46
|
"@types/node": "^24.3.0",
|
|
43
47
|
"typescript": "^5.9.2"
|
|
48
|
+
},
|
|
49
|
+
"brain": {
|
|
50
|
+
"tools": {
|
|
51
|
+
".": {
|
|
52
|
+
"runtime": "./runtime",
|
|
53
|
+
"exports": [
|
|
54
|
+
"bash"
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
}
|
|
44
58
|
}
|
|
45
59
|
}
|
|
File without changes
|
|
File without changes
|