Skip to content

Commit f6247fe

Browse files
authored
remove isolate vm (#1299)
1 parent 613699f commit f6247fe

File tree

3 files changed

+36
-178
lines changed

3 files changed

+36
-178
lines changed
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
import { addLog } from '../../../../common/system/log';
2-
const ivm = require('isolated-vm');
1+
// import { addLog } from '../../../../common/system/log';
2+
// const ivm = require('isolated-vm');
33

4-
export const runJsCode = ({
5-
code,
6-
variables
7-
}: {
8-
code: string;
9-
variables: Record<string, any>;
10-
}) => {
11-
const isolate = new ivm.Isolate({ memoryLimit: 16 });
12-
const context = isolate.createContextSync();
13-
const jail = context.global;
4+
// export const runJsCode = ({
5+
// code,
6+
// variables
7+
// }: {
8+
// code: string;
9+
// variables: Record<string, any>;
10+
// }) => {
11+
// const isolate = new ivm.Isolate({ memoryLimit: 16 });
12+
// const context = isolate.createContextSync();
13+
// const jail = context.global;
1414

15-
return new Promise((resolve, reject) => {
16-
// custom log function
17-
jail.setSync('responseData', function (args: any): any {
18-
if (typeof args === 'object') {
19-
resolve(args);
20-
} else {
21-
reject('Not an invalid response');
22-
}
23-
});
15+
// return new Promise((resolve, reject) => {
16+
// // custom log function
17+
// jail.setSync('responseData', function (args: any): any {
18+
// if (typeof args === 'object') {
19+
// resolve(args);
20+
// } else {
21+
// reject('Not an invalid response');
22+
// }
23+
// });
2424

25-
// Add global variables
26-
jail.setSync('variables', new ivm.ExternalCopy(variables).copyInto());
25+
// // Add global variables
26+
// jail.setSync('variables', new ivm.ExternalCopy(variables).copyInto());
2727

28-
try {
29-
const scriptCode = `
30-
${code}
31-
responseData(main(variables))`;
32-
context.evalSync(scriptCode, { timeout: 2000 });
33-
} catch (err) {
34-
addLog.error('Error during script execution:', err);
35-
reject(err);
36-
}
37-
});
38-
};
28+
// try {
29+
// const scriptCode = `
30+
// ${code}
31+
// responseData(main(variables))`;
32+
// context.evalSync(scriptCode, { timeout: 2000 });
33+
// } catch (err) {
34+
// addLog.error('Error during script execution:', err);
35+
// reject(err);
36+
// }
37+
// });
38+
// };

packages/service/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"encoding": "^0.1.13",
1616
"file-type": "^19.0.0",
1717
"iconv-lite": "^0.6.3",
18-
"isolated-vm": "4.7.2",
1918
"joplin-turndown-plugin-gfm": "^1.0.12",
2019
"js-tiktoken": "^1.0.7",
2120
"json5": "^2.2.3",

pnpm-lock.yaml

Lines changed: 2 additions & 143 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)