@pellux/goodvibes-sdk 0.18.19 → 0.18.20
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/tools/repl/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/tools/repl/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAGnF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAmBjD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAsMD,wBAAgB,cAAc,CAC5B,aAAa,EAAE,iBAAiB,EAChC,sBAAsB,EAAE,sBAAsB,EAC9C,OAAO,EAAE,eAAe,GACvB,IAAI,CA6EN"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
|
-
import { mkdtempSync, rmSync } from 'node:fs';
|
|
4
3
|
import ts from 'typescript';
|
|
5
4
|
import { executeSandboxCommand } from '../../runtime/sandbox/backend.js';
|
|
6
5
|
import {} from '../../runtime/sandbox/manager.js';
|
|
@@ -81,33 +80,16 @@ async function evalTypeScript(expression, bindings, configManager, sandboxSessio
|
|
|
81
80
|
}).outputText;
|
|
82
81
|
return evalJavaScriptInSandbox(transpiled, bindings, launchPlan, configManager, sandboxSessionRegistry, sessionId);
|
|
83
82
|
}
|
|
84
|
-
function evalPython(expression, workspaceRoot,
|
|
85
|
-
const replTempBase = join(workspaceRoot, '.goodvibes', surfaceRoot, 'repl-temp');
|
|
86
|
-
mkdirSync(replTempBase, { recursive: true });
|
|
87
|
-
const tempRoot = mkdtempSync(join(replTempBase, 'gv-repl-py-'));
|
|
88
|
-
const venvPath = join(tempRoot, 'venv');
|
|
89
|
-
const pythonLaunchPlan = launchPlan.backend === 'local' ? {
|
|
90
|
-
...createLocalExecPlan(tempRoot),
|
|
91
|
-
workspaceRoot: tempRoot,
|
|
92
|
-
} : launchPlan;
|
|
93
|
-
const create = sessionId
|
|
94
|
-
? sandboxSessionRegistry.execute(sessionId, 'python3', ['-m', 'venv', venvPath], configManager, { cwd: tempRoot })
|
|
95
|
-
: executeSandboxCommand(pythonLaunchPlan, 'python3', ['-m', 'venv', venvPath], { cwd: tempRoot });
|
|
96
|
-
if (create.status !== 0) {
|
|
97
|
-
rmSync(tempRoot, { recursive: true, force: true });
|
|
98
|
-
throw new Error(create.stderr || create.stdout || 'Failed to create ephemeral Python venv.');
|
|
99
|
-
}
|
|
100
|
-
const pythonBin = join(venvPath, 'bin', 'python');
|
|
83
|
+
function evalPython(expression, workspaceRoot, configManager, sandboxSessionRegistry, launchPlan, sessionId) {
|
|
101
84
|
const run = sessionId
|
|
102
|
-
? sandboxSessionRegistry.execute(sessionId,
|
|
103
|
-
cwd:
|
|
85
|
+
? sandboxSessionRegistry.execute(sessionId, 'python3', ['-I', '-S', '-c', `import json\nresult = (${expression})\nprint(json.dumps(result))`], configManager, {
|
|
86
|
+
cwd: workspaceRoot,
|
|
104
87
|
timeoutMs: 5000,
|
|
105
88
|
})
|
|
106
|
-
: executeSandboxCommand(
|
|
107
|
-
cwd:
|
|
89
|
+
: executeSandboxCommand(launchPlan, 'python3', ['-I', '-S', '-c', `import json\nresult = (${expression})\nprint(json.dumps(result))`], {
|
|
90
|
+
cwd: workspaceRoot,
|
|
108
91
|
timeoutMs: 5000,
|
|
109
92
|
});
|
|
110
|
-
rmSync(tempRoot, { recursive: true, force: true });
|
|
111
93
|
if (run.status !== 0) {
|
|
112
94
|
throw new Error((run.stderr || run.stdout || 'Python eval failed.').trim());
|
|
113
95
|
}
|
|
@@ -217,7 +199,7 @@ export function createReplTool(configManager, sandboxSessionRegistry, options) {
|
|
|
217
199
|
rendered = await evalTypeScript(input.expression, input.bindings ?? {}, configManager, sandboxSessionRegistry, sandboxSession.launchPlan ?? localExecPlan, sandboxSession.id);
|
|
218
200
|
break;
|
|
219
201
|
case 'python':
|
|
220
|
-
rendered = evalPython(input.expression, input.workspaceRoot,
|
|
202
|
+
rendered = evalPython(input.expression, input.workspaceRoot, configManager, sandboxSessionRegistry, sandboxSession.launchPlan ?? localExecPlan, sandboxSession.id);
|
|
221
203
|
break;
|
|
222
204
|
case 'sql':
|
|
223
205
|
rendered = await evalSql(input.expression, configManager, sandboxSessionRegistry, sandboxSession.launchPlan ?? localExecPlan, sandboxSession.id);
|
package/package.json
CHANGED