@pumped-fn/agent-sdk-just-bash 1.0.0
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 +21 -0
- package/README.md +21 -0
- package/dist/index.cjs +40 -0
- package/dist/index.d.cts +16 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +40 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pumped-fn
|
|
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,21 @@
|
|
|
1
|
+
# @pumped-fn/agent-sdk-just-bash
|
|
2
|
+
|
|
3
|
+
`just-bash` sandbox provider for `@pumped-fn/agent-sdk`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { createScope } from "@pumped-fn/lite"
|
|
7
|
+
import { sandbox } from "@pumped-fn/agent-sdk-just-bash"
|
|
8
|
+
|
|
9
|
+
const scope = createScope({
|
|
10
|
+
tags: [
|
|
11
|
+
sandbox({
|
|
12
|
+
options: {
|
|
13
|
+
files: { "/workspace/README.md": "ship it" },
|
|
14
|
+
cwd: "/workspace",
|
|
15
|
+
},
|
|
16
|
+
}),
|
|
17
|
+
],
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`sandbox()` returns a lazy `agent.sandbox` tag. The `Bash` runtime is created only when a sandbox capability is first used, and the flow can be run with any other `agent-sdk` sandbox tag instead.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let just_bash = require("just-bash");
|
|
3
|
+
let _pumped_fn_agent_sdk = require("@pumped-fn/agent-sdk");
|
|
4
|
+
let node_path_posix = require("node:path/posix");
|
|
5
|
+
//#region src/index.ts
|
|
6
|
+
function sandbox(options = {}) {
|
|
7
|
+
return (0, _pumped_fn_agent_sdk.sandbox)(createSandbox(options));
|
|
8
|
+
}
|
|
9
|
+
function createSandbox(options = {}) {
|
|
10
|
+
let bash;
|
|
11
|
+
const run = () => {
|
|
12
|
+
bash ??= options.bash ?? options.create?.() ?? new just_bash.Bash(options.options);
|
|
13
|
+
return bash;
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
async readFile(path) {
|
|
17
|
+
const result = await run().exec(`cat ${quote(path)}`);
|
|
18
|
+
if (result.exitCode !== 0) throw new Error(result.stderr.trim() || `readFile failed for ${path}`);
|
|
19
|
+
return result.stdout;
|
|
20
|
+
},
|
|
21
|
+
async writeFile(path, content) {
|
|
22
|
+
const result = await run().exec(`mkdir -p ${quote((0, node_path_posix.dirname)(path))} && cat > ${quote(path)}`, { stdin: content });
|
|
23
|
+
if (result.exitCode !== 0) throw new Error(result.stderr.trim() || `writeFile failed for ${path}`);
|
|
24
|
+
},
|
|
25
|
+
async exec(command, args = []) {
|
|
26
|
+
const result = await run().exec([command, ...args].map(quote).join(" "));
|
|
27
|
+
return {
|
|
28
|
+
stdout: result.stdout,
|
|
29
|
+
stderr: result.stderr,
|
|
30
|
+
exitCode: result.exitCode
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function quote(value) {
|
|
36
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.createSandbox = createSandbox;
|
|
40
|
+
exports.sandbox = sandbox;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Bash } from "just-bash";
|
|
2
|
+
import { Sandbox } from "@pumped-fn/agent-sdk";
|
|
3
|
+
import { Lite } from "@pumped-fn/lite";
|
|
4
|
+
|
|
5
|
+
//#region src/index.d.ts
|
|
6
|
+
type BashOptions = ConstructorParameters<typeof Bash>[0];
|
|
7
|
+
interface JustBashOptions {
|
|
8
|
+
bash?: Bash;
|
|
9
|
+
create?: () => Bash;
|
|
10
|
+
options?: BashOptions;
|
|
11
|
+
}
|
|
12
|
+
declare function sandbox(options?: JustBashOptions): Lite.Tagged<Sandbox>;
|
|
13
|
+
declare function createSandbox(options?: JustBashOptions): Sandbox;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { BashOptions, JustBashOptions, createSandbox, sandbox };
|
|
16
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;KAKY,WAAA,GAAc,qBAAqB,QAAQ,IAAA;AAAA,UAEtC,eAAA;EACf,IAAA,GAAO,IAAA;EACP,MAAA,SAAe,IAAA;EACf,OAAA,GAAU,WAAA;AAAA;AAAA,iBAGI,OAAA,CAAQ,OAAA,GAAS,eAAA,GAAuB,IAAA,CAAK,MAAA,CAAO,OAAA;AAAA,iBAIpD,aAAA,CAAc,OAAA,GAAS,eAAA,GAAuB,OAAO"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Bash } from "just-bash";
|
|
2
|
+
import { Sandbox } from "@pumped-fn/agent-sdk";
|
|
3
|
+
import { Lite } from "@pumped-fn/lite";
|
|
4
|
+
|
|
5
|
+
//#region src/index.d.ts
|
|
6
|
+
type BashOptions = ConstructorParameters<typeof Bash>[0];
|
|
7
|
+
interface JustBashOptions {
|
|
8
|
+
bash?: Bash;
|
|
9
|
+
create?: () => Bash;
|
|
10
|
+
options?: BashOptions;
|
|
11
|
+
}
|
|
12
|
+
declare function sandbox(options?: JustBashOptions): Lite.Tagged<Sandbox>;
|
|
13
|
+
declare function createSandbox(options?: JustBashOptions): Sandbox;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { BashOptions, JustBashOptions, createSandbox, sandbox };
|
|
16
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;KAKY,WAAA,GAAc,qBAAqB,QAAQ,IAAA;AAAA,UAEtC,eAAA;EACf,IAAA,GAAO,IAAA;EACP,MAAA,SAAe,IAAA;EACf,OAAA,GAAU,WAAA;AAAA;AAAA,iBAGI,OAAA,CAAQ,OAAA,GAAS,eAAA,GAAuB,IAAA,CAAK,MAAA,CAAO,OAAA;AAAA,iBAIpD,aAAA,CAAc,OAAA,GAAS,eAAA,GAAuB,OAAO"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Bash } from "just-bash";
|
|
2
|
+
import { sandbox as sandbox$1 } from "@pumped-fn/agent-sdk";
|
|
3
|
+
import { dirname } from "node:path/posix";
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
function sandbox(options = {}) {
|
|
6
|
+
return sandbox$1(createSandbox(options));
|
|
7
|
+
}
|
|
8
|
+
function createSandbox(options = {}) {
|
|
9
|
+
let bash;
|
|
10
|
+
const run = () => {
|
|
11
|
+
bash ??= options.bash ?? options.create?.() ?? new Bash(options.options);
|
|
12
|
+
return bash;
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
async readFile(path) {
|
|
16
|
+
const result = await run().exec(`cat ${quote(path)}`);
|
|
17
|
+
if (result.exitCode !== 0) throw new Error(result.stderr.trim() || `readFile failed for ${path}`);
|
|
18
|
+
return result.stdout;
|
|
19
|
+
},
|
|
20
|
+
async writeFile(path, content) {
|
|
21
|
+
const result = await run().exec(`mkdir -p ${quote(dirname(path))} && cat > ${quote(path)}`, { stdin: content });
|
|
22
|
+
if (result.exitCode !== 0) throw new Error(result.stderr.trim() || `writeFile failed for ${path}`);
|
|
23
|
+
},
|
|
24
|
+
async exec(command, args = []) {
|
|
25
|
+
const result = await run().exec([command, ...args].map(quote).join(" "));
|
|
26
|
+
return {
|
|
27
|
+
stdout: result.stdout,
|
|
28
|
+
stderr: result.stderr,
|
|
29
|
+
exitCode: result.exitCode
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function quote(value) {
|
|
35
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { createSandbox, sandbox };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["agentSandbox"],"sources":["../src/index.ts"],"sourcesContent":["import { Bash } from \"just-bash\"\nimport { sandbox as agentSandbox, type Sandbox } from \"@pumped-fn/agent-sdk\"\nimport type { Lite } from \"@pumped-fn/lite\"\nimport { dirname } from \"node:path/posix\"\n\nexport type BashOptions = ConstructorParameters<typeof Bash>[0]\n\nexport interface JustBashOptions {\n bash?: Bash\n create?: () => Bash\n options?: BashOptions\n}\n\nexport function sandbox(options: JustBashOptions = {}): Lite.Tagged<Sandbox> {\n return agentSandbox(createSandbox(options))\n}\n\nexport function createSandbox(options: JustBashOptions = {}): Sandbox {\n let bash: Bash | undefined\n const run = () => {\n bash ??= options.bash ?? options.create?.() ?? new Bash(options.options)\n return bash\n }\n return {\n async readFile(path) {\n const result = await run().exec(`cat ${quote(path)}`)\n if (result.exitCode !== 0) throw new Error(result.stderr.trim() || `readFile failed for ${path}`)\n return result.stdout\n },\n async writeFile(path, content) {\n const result = await run().exec(`mkdir -p ${quote(dirname(path))} && cat > ${quote(path)}`, { stdin: content })\n if (result.exitCode !== 0) throw new Error(result.stderr.trim() || `writeFile failed for ${path}`)\n },\n async exec(command, args = []) {\n const result = await run().exec([command, ...args].map(quote).join(\" \"))\n return {\n stdout: result.stdout,\n stderr: result.stderr,\n exitCode: result.exitCode,\n }\n },\n }\n}\n\nfunction quote(value: string): string {\n return `'${value.replace(/'/g, \"'\\\\''\")}'`\n}\n"],"mappings":";;;;AAaA,SAAgB,QAAQ,UAA2B,CAAC,GAAyB;CAC3E,OAAOA,UAAa,cAAc,OAAO,CAAC;AAC5C;AAEA,SAAgB,cAAc,UAA2B,CAAC,GAAY;CACpE,IAAI;CACJ,MAAM,YAAY;EAChB,SAAS,QAAQ,QAAQ,QAAQ,SAAS,KAAK,IAAI,KAAK,QAAQ,OAAO;EACvE,OAAO;CACT;CACA,OAAO;EACL,MAAM,SAAS,MAAM;GACnB,MAAM,SAAS,MAAM,IAAI,EAAE,KAAK,OAAO,MAAM,IAAI,GAAG;GACpD,IAAI,OAAO,aAAa,GAAG,MAAM,IAAI,MAAM,OAAO,OAAO,KAAK,KAAK,uBAAuB,MAAM;GAChG,OAAO,OAAO;EAChB;EACA,MAAM,UAAU,MAAM,SAAS;GAC7B,MAAM,SAAS,MAAM,IAAI,EAAE,KAAK,YAAY,MAAM,QAAQ,IAAI,CAAC,EAAE,YAAY,MAAM,IAAI,KAAK,EAAE,OAAO,QAAQ,CAAC;GAC9G,IAAI,OAAO,aAAa,GAAG,MAAM,IAAI,MAAM,OAAO,OAAO,KAAK,KAAK,wBAAwB,MAAM;EACnG;EACA,MAAM,KAAK,SAAS,OAAO,CAAC,GAAG;GAC7B,MAAM,SAAS,MAAM,IAAI,EAAE,KAAK,CAAC,SAAS,GAAG,IAAI,EAAE,IAAI,KAAK,EAAE,KAAK,GAAG,CAAC;GACvE,OAAO;IACL,QAAQ,OAAO;IACf,QAAQ,OAAO;IACf,UAAU,OAAO;GACnB;EACF;CACF;AACF;AAEA,SAAS,MAAM,OAAuB;CACpC,OAAO,IAAI,MAAM,QAAQ,MAAM,OAAO,EAAE;AAC1C"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pumped-fn/agent-sdk-just-bash",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "just-bash sandbox provider for @pumped-fn/agent-sdk",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.cjs",
|
|
8
|
+
"module": "./dist/index.mjs",
|
|
9
|
+
"types": "./dist/index.d.cts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": {
|
|
13
|
+
"types": "./dist/index.d.mts",
|
|
14
|
+
"default": "./dist/index.mjs"
|
|
15
|
+
},
|
|
16
|
+
"require": {
|
|
17
|
+
"types": "./dist/index.d.cts",
|
|
18
|
+
"default": "./dist/index.cjs"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsdown --config-loader tsx",
|
|
32
|
+
"typecheck": "tsgo --noEmit",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"test:watch": "vitest"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@pumped-fn/agent-sdk": "^1.0.0",
|
|
38
|
+
"@pumped-fn/lite": "^3.1.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"just-bash": "catalog:"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@pumped-fn/agent-sdk": "workspace:*",
|
|
45
|
+
"@pumped-fn/lite": "workspace:*",
|
|
46
|
+
"@types/node": "catalog:",
|
|
47
|
+
"@typescript/native-preview": "catalog:",
|
|
48
|
+
"tsdown": "catalog:",
|
|
49
|
+
"typescript": "catalog:",
|
|
50
|
+
"vite": "catalog:",
|
|
51
|
+
"vitest": "catalog:"
|
|
52
|
+
},
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"directory": "packages/agent-sdk-just-bash",
|
|
57
|
+
"url": "git+https://github.com/pumped-fn/pumped-fn.git"
|
|
58
|
+
}
|
|
59
|
+
}
|