@zhin.js/plugin-code-runner 3.0.5 → 3.0.7
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/commands/run/[language:string].js +15 -0
- package/package.json +6 -6
- package/plugin.js +8 -0
- package/plugin.ts +0 -8
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
+
import { defineCommand } from '@zhin.js/command';
|
|
3
|
+
import { formatResult, runCode } from "../../lib/run-code.js";
|
|
4
|
+
export default defineCommand({
|
|
5
|
+
description: '在沙箱中运行代码片段(/code-runner run <语言> <代码>)',
|
|
6
|
+
async execute({ params, args }) {
|
|
7
|
+
const language = String(params.language ?? '');
|
|
8
|
+
// code 原来是第二动态段,约定式命令只支持单动态文件参数,改从 args 取
|
|
9
|
+
const code = args.join(' ').trim();
|
|
10
|
+
if (!code)
|
|
11
|
+
return '请提供要运行的代码,例如:/code-runner run javascript alert(1+1)';
|
|
12
|
+
const result = await runCode(language, code);
|
|
13
|
+
return formatResult(result);
|
|
14
|
+
},
|
|
15
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/plugin-code-runner",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.7",
|
|
4
4
|
"description": "Sandboxed code execution plugin for Zhin.js (Plugin Runtime)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"./package.json": "./package.json"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
|
-
"plugin.
|
|
17
|
+
"plugin.js",
|
|
18
18
|
"schema.json",
|
|
19
19
|
"commands",
|
|
20
20
|
"src",
|
|
@@ -38,18 +38,18 @@
|
|
|
38
38
|
},
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@zhin.js/command": "1.0.
|
|
41
|
+
"@zhin.js/command": "1.0.4",
|
|
42
42
|
"@zhin.js/plugin-runtime": "1.1.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"typescript": "^6.0.3",
|
|
46
46
|
"vitest": "^4.1.10",
|
|
47
47
|
"zod": "^4.4.3",
|
|
48
|
-
"@zhin.js/agent": "1.0.
|
|
48
|
+
"@zhin.js/agent": "1.0.8"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"zod": "^4.0.0",
|
|
52
|
-
"@zhin.js/agent": "1.0.
|
|
52
|
+
"@zhin.js/agent": "1.0.8"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"@zhin.js/agent": {
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"zhin": {
|
|
75
75
|
"protocol": 1,
|
|
76
76
|
"type": "plugin",
|
|
77
|
-
"entry": "./plugin.
|
|
77
|
+
"entry": "./plugin.js",
|
|
78
78
|
"engine": "^1.0.0",
|
|
79
79
|
"runtime": "trusted",
|
|
80
80
|
"features": [
|
package/plugin.js
ADDED