Skip to content

Commit e8e492d

Browse files
jcorteslcaresia
authored andcommitted
[Components] e2b - Run code action (#14621)
1 parent 17ea684 commit e8e492d

File tree

4 files changed

+107
-8
lines changed

4 files changed

+107
-8
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import app from "../../e2b.app.mjs";
2+
3+
export default {
4+
key: "e2b-run-code",
5+
name: "Run Code",
6+
description: "Run or interpret code using the E2B service. [See the documentation](https://www.npmjs.com/package/e2b).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
code: {
12+
type: "string",
13+
label: "Code",
14+
description: "The code that will be interpreted by the E2B service. Eg. `print('Hello, World!')`.",
15+
},
16+
},
17+
async run({ $ }) {
18+
const {
19+
app,
20+
code,
21+
} = this;
22+
23+
const response = await app.runCode(code);
24+
25+
$.export("$summary", "Successfully interpreted code.");
26+
27+
return response;
28+
},
29+
};

components/e2b/e2b.app.mjs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1+
import { Sandbox } from "@e2b/code-interpreter";
2+
13
export default {
24
type: "app",
35
app: "e2b",
4-
propDefinitions: {},
56
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
7+
getSandbox() {
8+
process.env.E2B_API_KEY = this.$auth.api_key;
9+
return Sandbox.create();
10+
},
11+
async runCode(code) {
12+
const sandbox = await this.getSandbox();
13+
return sandbox.runCode(code);
914
},
1015
},
11-
};
16+
};

components/e2b/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/e2b",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream E2B Components",
55
"main": "e2b.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@e2b/code-interpreter": "^1.0.3"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 63 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)