@aigne/example-workflow-code-execution 1.8.0 → 1.10.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/README.md +2 -3
- package/index.ts +13 -6
- package/package.json +6 -6
- package/{usage.ts → usages.ts} +2 -2
- /package/{LICENSE → LICENSE.md} +0 -0
package/README.md
CHANGED
|
@@ -26,7 +26,6 @@ class sandbox processing
|
|
|
26
26
|
|
|
27
27
|
Workflow of a code-execution between user and coder using a sandbox:
|
|
28
28
|
|
|
29
|
-
|
|
30
29
|
```mermaid
|
|
31
30
|
sequenceDiagram
|
|
32
31
|
|
|
@@ -104,12 +103,12 @@ const model = new OpenAIChatModel({
|
|
|
104
103
|
});
|
|
105
104
|
|
|
106
105
|
const sandbox = FunctionAgent.from({
|
|
107
|
-
name: "
|
|
106
|
+
name: "evaluateJs",
|
|
108
107
|
description: "A js sandbox for running javascript code",
|
|
109
108
|
inputSchema: z.object({
|
|
110
109
|
code: z.string().describe("The code to run"),
|
|
111
110
|
}),
|
|
112
|
-
|
|
111
|
+
process: async (input: { code: string }) => {
|
|
113
112
|
const { code } = input;
|
|
114
113
|
// biome-ignore lint/security/noGlobalEval: <explanation>
|
|
115
114
|
const result = eval(code);
|
package/index.ts
CHANGED
|
@@ -8,15 +8,22 @@ import { z } from "zod";
|
|
|
8
8
|
const model = await loadModel();
|
|
9
9
|
|
|
10
10
|
const sandbox = FunctionAgent.from({
|
|
11
|
-
name: "
|
|
12
|
-
description:
|
|
11
|
+
name: "evaluateJs",
|
|
12
|
+
description: `
|
|
13
|
+
This agent generates a JavaScript code snippet that is suitable to be passed directly into Node.js's 'eval' function. Follow these constraints:
|
|
14
|
+
- Do NOT use any top-level 'return' statements, as the code is not inside a function.
|
|
15
|
+
- The code can define variables or perform calculations.
|
|
16
|
+
- To return a value from the code, make sure the final line is an expression (not a statement) whose value will be the result.
|
|
17
|
+
- Do NOT wrap the code in a function or IIFE unless explicitly instructed.
|
|
18
|
+
- The code should be self-contained and valid JavaScript.`,
|
|
19
|
+
|
|
13
20
|
inputSchema: z.object({
|
|
14
|
-
|
|
21
|
+
jsCode: z.string().describe("JavaScript code snippet to evaluate"),
|
|
15
22
|
}),
|
|
16
|
-
|
|
17
|
-
const {
|
|
23
|
+
process: async (input: { jsCode: string }) => {
|
|
24
|
+
const { jsCode } = input;
|
|
18
25
|
// biome-ignore lint/security/noGlobalEval: <explanation>
|
|
19
|
-
const result = eval(
|
|
26
|
+
const result = eval(jsCode);
|
|
20
27
|
return { result };
|
|
21
28
|
},
|
|
22
29
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/example-workflow-code-execution",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "A demonstration of using AIGNE Framework to build a code-execution workflow",
|
|
5
5
|
"author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
|
|
6
6
|
"homepage": "https://github.com/AIGNE-io/aigne-framework/tree/main/examples/workflow-code-execution",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"README.md"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"openai": "^4.
|
|
20
|
-
"zod": "^3.24.
|
|
21
|
-
"@aigne/
|
|
22
|
-
"@aigne/
|
|
19
|
+
"openai": "^4.97.0",
|
|
20
|
+
"zod": "^3.24.4",
|
|
21
|
+
"@aigne/cli": "^1.9.0",
|
|
22
|
+
"@aigne/core": "^1.14.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@aigne/test-utils": "^0.
|
|
25
|
+
"@aigne/test-utils": "^0.2.0"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"start": "bun run index.ts",
|
package/{usage.ts → usages.ts}
RENAMED
|
@@ -11,12 +11,12 @@ const model = new OpenAIChatModel({
|
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
const sandbox = FunctionAgent.from({
|
|
14
|
-
name: "
|
|
14
|
+
name: "evaluateJs",
|
|
15
15
|
description: "A js sandbox for running javascript code",
|
|
16
16
|
inputSchema: z.object({
|
|
17
17
|
code: z.string().describe("The code to run"),
|
|
18
18
|
}),
|
|
19
|
-
|
|
19
|
+
process: async (input: { code: string }) => {
|
|
20
20
|
const { code } = input;
|
|
21
21
|
// biome-ignore lint/security/noGlobalEval: <explanation>
|
|
22
22
|
const result = eval(code);
|
/package/{LICENSE → LICENSE.md}
RENAMED
|
File without changes
|