@larkup/sandbox 0.1.11 → 0.1.12
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/CHANGELOG.md +6 -0
- package/dist/remote-exec.js +33 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @larkup/sandbox
|
|
2
2
|
|
|
3
|
+
## 0.1.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Improve compound clinical-data analysis with reliable multi-file routing, safer aggregation validation, complete artifact evidence, robust generated Python repair, captured analysis charts, and clearer PDF endpoint synthesis.
|
|
8
|
+
|
|
3
9
|
## 0.1.11
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/remote-exec.js
CHANGED
|
@@ -36,6 +36,37 @@ function shellSingleQuote(value) {
|
|
|
36
36
|
function writeBase64FileScript(name, base64) {
|
|
37
37
|
return `base64 -d > ${shellSingleQuote(name)} <<'${HEREDOC_DELIMITER}'\n${base64}\n${HEREDOC_DELIMITER}`;
|
|
38
38
|
}
|
|
39
|
+
/** Add the same headless chart capture contract used by the local sandbox. */
|
|
40
|
+
function executionSource(request) {
|
|
41
|
+
if (request.language !== 'python')
|
|
42
|
+
return request.code;
|
|
43
|
+
const encodedCode = Buffer.from(request.code, 'utf8').toString('base64');
|
|
44
|
+
return `import base64, os
|
|
45
|
+
os.makedirs(${JSON.stringify(OUTPUT_DIR)}, exist_ok=True)
|
|
46
|
+
_larkup_figure_count = [0]
|
|
47
|
+
try:
|
|
48
|
+
import matplotlib
|
|
49
|
+
matplotlib.use('Agg')
|
|
50
|
+
import matplotlib.pyplot as plt
|
|
51
|
+
def _larkup_save_figures(*args, **kwargs):
|
|
52
|
+
for number in plt.get_fignums():
|
|
53
|
+
figure = plt.figure(number)
|
|
54
|
+
filename = os.path.join(${JSON.stringify(OUTPUT_DIR)}, f'chart_{_larkup_figure_count[0]}.png')
|
|
55
|
+
figure.savefig(filename, dpi=150, bbox_inches='tight', facecolor='white')
|
|
56
|
+
_larkup_figure_count[0] += 1
|
|
57
|
+
plt.close('all')
|
|
58
|
+
plt.show = _larkup_save_figures
|
|
59
|
+
except ImportError:
|
|
60
|
+
pass
|
|
61
|
+
_larkup_encoded_code = ${JSON.stringify(encodedCode)}
|
|
62
|
+
exec(compile(base64.b64decode(_larkup_encoded_code), 'analysis.py', 'exec'), globals(), globals())
|
|
63
|
+
try:
|
|
64
|
+
if 'plt' in globals() and plt.get_fignums():
|
|
65
|
+
plt.show()
|
|
66
|
+
except Exception:
|
|
67
|
+
pass
|
|
68
|
+
`;
|
|
69
|
+
}
|
|
39
70
|
/** Builds the POSIX shell script a remote adapter hands to its provider's exec call. */
|
|
40
71
|
export function buildExecutionScript(request, filesAlreadyStaged = false) {
|
|
41
72
|
const lines = [
|
|
@@ -55,7 +86,7 @@ export function buildExecutionScript(request, filesAlreadyStaged = false) {
|
|
|
55
86
|
const scriptName = request.language === 'python' ? 'run.py' : 'run.js';
|
|
56
87
|
const runner = request.language === 'python' ? 'python3' : 'node';
|
|
57
88
|
if (!filesAlreadyStaged) {
|
|
58
|
-
const codeBase64 = Buffer.from(request
|
|
89
|
+
const codeBase64 = Buffer.from(executionSource(request), 'utf8').toString('base64');
|
|
59
90
|
lines.push(writeBase64FileScript(scriptName, codeBase64));
|
|
60
91
|
}
|
|
61
92
|
lines.push(`${runner} ${shellSingleQuote(scriptName)}`);
|
|
@@ -72,7 +103,7 @@ function executionFiles(request) {
|
|
|
72
103
|
return { path: `${WORKDIR}/${file.name}`, data };
|
|
73
104
|
});
|
|
74
105
|
const scriptName = request.language === 'python' ? 'run.py' : 'run.js';
|
|
75
|
-
files.push({ path: `${WORKDIR}/${scriptName}`, data: request
|
|
106
|
+
files.push({ path: `${WORKDIR}/${scriptName}`, data: executionSource(request) });
|
|
76
107
|
return files;
|
|
77
108
|
}
|
|
78
109
|
function extractArtifactMarker(stdout) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@larkup/sandbox",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"e2b": "^2.39.0",
|
|
47
47
|
"@vercel/sandbox": "^3.0.0",
|
|
48
48
|
"modal": "^0.11.0",
|
|
49
|
-
"@daytona/sdk": "^0.
|
|
49
|
+
"@daytona/sdk": "^0.226.1",
|
|
50
50
|
"@browserbasehq/sdk": "^2.17.0",
|
|
51
51
|
"playwright-core": "^1.62.1",
|
|
52
52
|
"@fly/sprites": "^0.2.0",
|
|
53
|
-
"@northflank/js-client": "^0.
|
|
53
|
+
"@northflank/js-client": "^0.12.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@types/dockerode": "^4.0.1",
|