diff --git a/package.json b/package.json index ae3bc54..707e34a 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,6 @@ "moment": "^2.29.4", "moment-timezone": "^0.5.43", "openai": "^3.3.0", - "vm2": "^3.9.19", "zod": "^3.21.4", "zod-to-json-schema": "^3.21.2" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a436169..c1a4041 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: autoInstallPeers: true @@ -23,9 +23,6 @@ dependencies: openai: specifier: ^3.3.0 version: 3.3.0 - vm2: - specifier: ^3.9.19 - version: 3.9.19 zod: specifier: ^3.21.4 version: 3.21.4 @@ -925,11 +922,13 @@ packages: /acorn-walk@8.2.0: resolution: {integrity: sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==} engines: {node: '>=0.4.0'} + dev: true /acorn@8.9.0: resolution: {integrity: sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ==} engines: {node: '>=0.4.0'} hasBin: true + dev: true /agent-base@6.0.2: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} @@ -3939,15 +3938,6 @@ packages: - terser dev: true - /vm2@3.9.19: - resolution: {integrity: sha512-J637XF0DHDMV57R6JyVsTak7nIL8gy5KH4r1HiwWLf/4GBbb5MKL5y7LpmF4A8E2nR6XmzpmMFQ7V7ppPTmUQg==} - engines: {node: '>=6.0'} - hasBin: true - dependencies: - acorn: 8.9.0 - acorn-walk: 8.2.0 - dev: false - /watchpack@2.4.0: resolution: {integrity: sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==} engines: {node: '>=10.13.0'} diff --git a/tools/javaScriptInterpreter.test.ts b/tools/javaScriptInterpreter.test.ts index 786d421..1b303e6 100644 --- a/tools/javaScriptInterpreter.test.ts +++ b/tools/javaScriptInterpreter.test.ts @@ -1,34 +1,34 @@ -import { createJavaScriptInterpreter } from "./javaScriptInterpreter"; -import { expect, it } from 'vitest'; +// import { createJavaScriptInterpreter } from "./javaScriptInterpreter"; +// import { expect, it } from 'vitest'; -it('should interpret JavaScript code correctly', () => { - const [javaScriptInterpreter] = createJavaScriptInterpreter(); - const result = javaScriptInterpreter({ - code: ` - 1 + 1 - `, - }); - expect(result).toBe(2); -}); +// it('should interpret JavaScript code correctly', () => { +// const [javaScriptInterpreter] = createJavaScriptInterpreter(); +// const result = javaScriptInterpreter({ +// code: ` +// 1 + 1 +// `, +// }); +// expect(result).toBe(2); +// }); -it('should timeout for long running scripts', () => { - const [javaScriptInterpreter] = createJavaScriptInterpreter(); - const result = javaScriptInterpreter({ - code: ` - while (true) {} - `, - }); +// it('should timeout for long running scripts', () => { +// const [javaScriptInterpreter] = createJavaScriptInterpreter(); +// const result = javaScriptInterpreter({ +// code: ` +// while (true) {} +// `, +// }); - expect(result).toBe("Failed to execute script: Script execution timed out after 5000ms") -}); +// expect(result).toBe("Failed to execute script: Script execution timed out after 5000ms") +// }); -it('should not have access to Node.js environment', () => { - const [javaScriptInterpreter] = createJavaScriptInterpreter(); - const result = javaScriptInterpreter({ - code: ` - process.exit(1) - `, - }); +// it('should not have access to Node.js environment', () => { +// const [javaScriptInterpreter] = createJavaScriptInterpreter(); +// const result = javaScriptInterpreter({ +// code: ` +// process.exit(1) +// `, +// }); - expect(result).toBe("Failed to execute script: process is not defined") -}); +// expect(result).toBe("Failed to execute script: process is not defined") +// }); diff --git a/tools/javaScriptInterpreter.ts b/tools/javaScriptInterpreter.ts index 5905f27..ec23a6a 100644 --- a/tools/javaScriptInterpreter.ts +++ b/tools/javaScriptInterpreter.ts @@ -1,28 +1,28 @@ -import { z } from "zod"; -import { VM } from "vm2"; -import { Tool } from "./tool"; +// import { z } from "zod"; +// import { VM } from "vm2"; +// import { Tool } from "./tool"; -function createJavaScriptInterpreter() { - const paramsSchema = z.object({ - code: z.string(), - }); - const name = "javaScriptInterpreter"; - const description = "Useful for running JavaScript code in sandbox. Input is a string of JavaScript code, output is the result of the code."; +// function createJavaScriptInterpreter() { +// const paramsSchema = z.object({ +// code: z.string(), +// }); +// const name = "javaScriptInterpreter"; +// const description = "Useful for running JavaScript code in sandbox. Input is a string of JavaScript code, output is the result of the code."; - const execute = (params: z.infer) => { - const { code } = params; - const vm = new VM({ - timeout: 5000, - sandbox: {}, - }); - try { - return vm.run(code); - } catch (error) { - return `Failed to execute script: ${error.message}`; - } - }; +// const execute = (params: z.infer) => { +// const { code } = params; +// const vm = new VM({ +// timeout: 5000, +// sandbox: {}, +// }); +// try { +// return vm.run(code); +// } catch (error) { +// return `Failed to execute script: ${error.message}`; +// } +// }; - return new Tool>(paramsSchema, name, description, execute).tool; -} +// return new Tool>(paramsSchema, name, description, execute).tool; +// } -export { createJavaScriptInterpreter }; +// export { createJavaScriptInterpreter };