diff --git a/components/e2b/actions/run-code/run-code.mjs b/components/e2b/actions/run-code/run-code.mjs new file mode 100644 index 0000000000000..ad2280fcd842d --- /dev/null +++ b/components/e2b/actions/run-code/run-code.mjs @@ -0,0 +1,29 @@ +import app from "../../e2b.app.mjs"; + +export default { + key: "e2b-run-code", + name: "Run Code", + description: "Run or interpret code using the E2B service. [See the documentation](https://www.npmjs.com/package/e2b).", + version: "0.0.1", + type: "action", + props: { + app, + code: { + type: "string", + label: "Code", + description: "The code that will be interpreted by the E2B service. Eg. `print('Hello, World!')`.", + }, + }, + async run({ $ }) { + const { + app, + code, + } = this; + + const response = await app.runCode(code); + + $.export("$summary", "Successfully interpreted code."); + + return response; + }, +}; diff --git a/components/e2b/e2b.app.mjs b/components/e2b/e2b.app.mjs index e9b33901125ac..75f0dfd9efaf7 100644 --- a/components/e2b/e2b.app.mjs +++ b/components/e2b/e2b.app.mjs @@ -1,11 +1,16 @@ +import { Sandbox } from "@e2b/code-interpreter"; + export default { type: "app", app: "e2b", - propDefinitions: {}, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + getSandbox() { + process.env.E2B_API_KEY = this.$auth.api_key; + return Sandbox.create(); + }, + async runCode(code) { + const sandbox = await this.getSandbox(); + return sandbox.runCode(code); }, }, -}; \ No newline at end of file +}; diff --git a/components/e2b/package.json b/components/e2b/package.json index 4aede9412cf6a..2387f95e4cef5 100644 --- a/components/e2b/package.json +++ b/components/e2b/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/e2b", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream E2B Components", "main": "e2b.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@e2b/code-interpreter": "^1.0.3" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 48e44a6b26ac2..c28b27dcd2650 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3005,7 +3005,10 @@ importers: specifiers: {} components/e2b: - specifiers: {} + specifiers: + '@e2b/code-interpreter': ^1.0.3 + dependencies: + '@e2b/code-interpreter': 1.0.3 components/e_conomic: specifiers: {} @@ -16406,6 +16409,10 @@ packages: resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} dev: true + /@bufbuild/protobuf/1.10.0: + resolution: {integrity: sha512-QDdVFLoN93Zjg36NoQPZfsVH9tZew7wKDKyV5qRdj8ntT4wQCOradQjRaTdwMhWUYsgKsvCINKKm87FdEk96Ag==} + dev: false + /@colors/colors/1.5.0: resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==} engines: {node: '>=0.1.90'} @@ -16416,6 +16423,24 @@ packages: engines: {node: '>=0.1.90'} dev: false + /@connectrpc/connect-web/1.6.1_vw5phdcb2eqdev6wdcwiheqqle: + resolution: {integrity: sha512-GVfxQOmt3TtgTaKeXLS/EA2IHa3nHxwe2BCHT7X0Q/0hohM+nP5DDnIItGEjGrGdt3LTTqWqE4s70N4h+qIMlQ==} + peerDependencies: + '@bufbuild/protobuf': ^1.10.0 + '@connectrpc/connect': 1.6.1 + dependencies: + '@bufbuild/protobuf': 1.10.0 + '@connectrpc/connect': 1.6.1_@bufbuild+protobuf@1.10.0 + dev: false + + /@connectrpc/connect/1.6.1_@bufbuild+protobuf@1.10.0: + resolution: {integrity: sha512-KchMDNtU4CDTdkyf0qG7ugJ6qHTOR/aI7XebYn3OTCNagaDYWiZUVKgRgwH79yeMkpNgvEUaXSK7wKjaBK9b/Q==} + peerDependencies: + '@bufbuild/protobuf': ^1.10.0 + dependencies: + '@bufbuild/protobuf': 1.10.0 + dev: false + /@csstools/css-parser-algorithms/2.3.2_qabfbasg4cggam7o7issvon7wi: resolution: {integrity: sha512-sLYGdAdEY2x7TSw9FtmdaTrh2wFtRJO5VMbBrA8tEqEod7GEggFmxTSK9XqExib3yMuYNcvcTdCZIP6ukdjAIA==} engines: {node: ^14 || ^16 || >=18} @@ -16486,6 +16511,13 @@ packages: which: 4.0.0 dev: true + /@e2b/code-interpreter/1.0.3: + resolution: {integrity: sha512-/dfMagUEytQtwqkab+0glMPCpPvOwhGaUZvOscT/YvxJxaYPswwjIWb3TXa9DeV25XYw//72syT2wo6rGnnCKw==} + engines: {node: '>=18'} + dependencies: + e2b: 1.0.4 + dev: false + /@eslint-community/eslint-utils/4.4.0_eslint@8.15.0: resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -23993,6 +24025,10 @@ packages: resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} dev: false + /compare-versions/6.1.1: + resolution: {integrity: sha512-4hm4VPpIecmlg59CHXnRDnqGplJFrbLG4aFEl5vl6cK1u76ws3LLvX7ikFnTDl5vo39sjWD6AaDPYodJp/NNHg==} + dev: false + /component-emitter/1.3.0: resolution: {integrity: sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==} dev: false @@ -25131,6 +25167,18 @@ packages: stream-shift: 1.0.1 dev: false + /e2b/1.0.4: + resolution: {integrity: sha512-/syWwMNNwnGULcivy6kYISJpJrq/ASy9BN9CW/EJ8hM2TESUXvHNAoagnIHXt6sJl/SjgIG12M/jI/G7XhLQRw==} + engines: {node: '>=18'} + dependencies: + '@bufbuild/protobuf': 1.10.0 + '@connectrpc/connect': 1.6.1_@bufbuild+protobuf@1.10.0 + '@connectrpc/connect-web': 1.6.1_vw5phdcb2eqdev6wdcwiheqqle + compare-versions: 6.1.1 + openapi-fetch: 0.9.8 + platform: 1.3.6 + dev: false + /eastasianwidth/0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} dev: true @@ -32060,10 +32108,20 @@ packages: - debug dev: false + /openapi-fetch/0.9.8: + resolution: {integrity: sha512-zM6elH0EZStD/gSiNlcPrzXcVQ/pZo3BDvC6CDwRDUt1dDzxlshpmQnpD6cZaJ39THaSmwVCxxRrPKNM1hHrDg==} + dependencies: + openapi-typescript-helpers: 0.0.8 + dev: false + /openapi-types/12.1.3: resolution: {integrity: sha512-N4YtSYJqghVu4iek2ZUvcN/0aqH1kRDuNqzcycDxhOUpg7GdvLa2F3DgS6yBNhInhv2r/6I0Flkn7CqL8+nIcw==} dev: false + /openapi-typescript-helpers/0.0.8: + resolution: {integrity: sha512-1eNjQtbfNi5Z/kFhagDIaIRj6qqDzhjNJKz8cmMW0CVdGwT6e1GLbAfgI0d28VTJa1A8jz82jm/4dG8qNoNS8g==} + dev: false + /opencollective-postinstall/2.0.3: resolution: {integrity: sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q==} hasBin: true @@ -32658,6 +32716,10 @@ packages: find-up: 6.3.0 dev: true + /platform/1.3.6: + resolution: {integrity: sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==} + dev: false + /playwright-core/1.41.2: resolution: {integrity: sha512-VaTvwCA4Y8kxEe+kfm2+uUUw5Lubf38RxF7FpBxLPmGe5sdNkSg5e3ChEigaGrX7qdqT3pt2m/98LiyvU2x6CA==} engines: {node: '>=16'}