@axiom-lattice/microsandbox-service 3.0.1 → 3.0.2
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 +17 -0
- package/README.md +1 -1
- package/package.json +2 -2
- package/src/__tests__/fileApiContract.test.ts +130 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @axiom-lattice/microsandbox-service
|
|
2
2
|
|
|
3
|
+
## 3.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c9b8df8: Remediate the security advisories in the Wiz report of 2026-11-10 by pinning
|
|
8
|
+
transitive dependencies to their first patched releases (axios, protobufjs,
|
|
9
|
+
hono and @hono/node-server, fast-uri, fastify 5.12, fast-xml-parser, dompurify,
|
|
10
|
+
mermaid, js-yaml, lodash, minimatch, postcss, rollup, tar, ws, and others),
|
|
11
|
+
using selector-scoped workspace overrides so incompatible major lines stay
|
|
12
|
+
apart.
|
|
13
|
+
|
|
14
|
+
Companion changes for the new versions: Fastify 5.12 types the error handler's
|
|
15
|
+
argument as `unknown`; `@hono/node-server` 1.19.15 destroys the socket from a
|
|
16
|
+
drain timer, so the Fastify inject mock socket gets a `destroySoon` shim;
|
|
17
|
+
react-sdk loads jsPDF's ESM-only browser build lazily; react-sdk moves to
|
|
18
|
+
react-router 7.18 and sandbox-console to Vite 6.4 / Vitest 4.
|
|
19
|
+
|
|
3
20
|
## 3.0.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -176,7 +176,7 @@ Create a resident service and resolve its endpoint:
|
|
|
176
176
|
curl -X PUT http://127.0.0.1:4002/api/sandboxes/plugin-weather \
|
|
177
177
|
-H 'content-type: application/json' \
|
|
178
178
|
-d '{
|
|
179
|
-
"image": "kioko12520/sandbox:0.
|
|
179
|
+
"image": "kioko12520/sandbox:0.2.0",
|
|
180
180
|
"entrypoint": ["node", "/root/.agents/.plugin-host/server.js"],
|
|
181
181
|
"exposePorts": [8080]
|
|
182
182
|
}'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axiom-lattice/microsandbox-service",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"main": "dist/index.mjs",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@fastify/sensible": "^6.0.3",
|
|
31
31
|
"@fastify/swagger": "^9.5.1",
|
|
32
32
|
"@fastify/swagger-ui": "^5.2.3",
|
|
33
|
-
"fastify": "^5.5
|
|
33
|
+
"fastify": "^5.12.5",
|
|
34
34
|
"microsandbox": "^0.6.2",
|
|
35
35
|
"zod": "4.6.7"
|
|
36
36
|
},
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import fastify, { type FastifyInstance } from "fastify";
|
|
2
|
+
import { registerSandboxRoutes } from "../routes/sandbox";
|
|
3
|
+
import type { RuntimeService } from "../types/runtime-service";
|
|
4
|
+
|
|
5
|
+
const FILE_PATH = "/root/a.txt";
|
|
6
|
+
const CONTENT = "hello";
|
|
7
|
+
const BINARY_BASE64 = Buffer.from([0, 1, 2, 0xff, 0xfe]).toString("base64");
|
|
8
|
+
|
|
9
|
+
function fakeRuntime(): RuntimeService {
|
|
10
|
+
const noop = jest.fn();
|
|
11
|
+
return {
|
|
12
|
+
ensureSandbox: noop,
|
|
13
|
+
startSandbox: noop,
|
|
14
|
+
stopSandbox: noop,
|
|
15
|
+
killSandbox: noop,
|
|
16
|
+
deleteSandbox: noop,
|
|
17
|
+
listSandboxes: noop,
|
|
18
|
+
getSandbox: noop,
|
|
19
|
+
getStatus: noop,
|
|
20
|
+
getEndpoint: noop,
|
|
21
|
+
resolveProxyTarget: noop,
|
|
22
|
+
readFile: jest.fn(async (_sandboxName: string, path: string) => ({
|
|
23
|
+
path,
|
|
24
|
+
content: CONTENT,
|
|
25
|
+
})),
|
|
26
|
+
writeFile: jest.fn(async (_sandboxName: string, path: string) => ({ path })),
|
|
27
|
+
deleteFile: jest.fn(async (_sandboxName: string, path: string) => ({ path })),
|
|
28
|
+
listPath: jest.fn(async (_sandboxName: string, path: string) => ({
|
|
29
|
+
entries: [{ path: `${path}/child.txt`, type: "file" }],
|
|
30
|
+
})),
|
|
31
|
+
findFiles: noop,
|
|
32
|
+
searchInFile: noop,
|
|
33
|
+
replaceInFile: noop,
|
|
34
|
+
uploadFile: jest.fn(async (_sandboxName: string, path: string) => ({ path })),
|
|
35
|
+
downloadFile: jest.fn(async (_sandboxName: string, path: string) => ({
|
|
36
|
+
path,
|
|
37
|
+
contentBase64: BINARY_BASE64,
|
|
38
|
+
})),
|
|
39
|
+
execCommand: noop,
|
|
40
|
+
getSandboxLogs: noop,
|
|
41
|
+
} as unknown as RuntimeService;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function makeApp(): Promise<FastifyInstance> {
|
|
45
|
+
const app = fastify({ logger: false });
|
|
46
|
+
registerSandboxRoutes(app, fakeRuntime());
|
|
47
|
+
await app.ready();
|
|
48
|
+
return app;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function request(method: "GET" | "POST", url: string, payload?: Record<string, unknown>) {
|
|
52
|
+
const app = await makeApp();
|
|
53
|
+
try {
|
|
54
|
+
return await app.inject({ method, url, payload });
|
|
55
|
+
} finally {
|
|
56
|
+
await app.close();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
describe("sandbox file API contract (microsandbox)", () => {
|
|
61
|
+
it("read returns the canonical envelope", async () => {
|
|
62
|
+
const res = await request("POST", "/api/files/read", {
|
|
63
|
+
sandboxName: "sb",
|
|
64
|
+
path: FILE_PATH,
|
|
65
|
+
});
|
|
66
|
+
expect(res.statusCode).toBe(200);
|
|
67
|
+
expect(res.json()).toEqual({
|
|
68
|
+
success: true,
|
|
69
|
+
data: { path: FILE_PATH, content: CONTENT },
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("write returns the canonical envelope", async () => {
|
|
74
|
+
const res = await request("POST", "/api/files/write", {
|
|
75
|
+
sandboxName: "sb",
|
|
76
|
+
path: FILE_PATH,
|
|
77
|
+
content: CONTENT,
|
|
78
|
+
});
|
|
79
|
+
expect(res.json()).toEqual({ success: true, data: { path: FILE_PATH } });
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("delete returns the canonical envelope", async () => {
|
|
83
|
+
const res = await request("POST", "/api/files/delete", {
|
|
84
|
+
sandboxName: "sb",
|
|
85
|
+
path: FILE_PATH,
|
|
86
|
+
});
|
|
87
|
+
expect(res.json()).toEqual({ success: true, data: { path: FILE_PATH } });
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("list returns the canonical envelope", async () => {
|
|
91
|
+
const res = await request("POST", "/api/files/list", {
|
|
92
|
+
sandboxName: "sb",
|
|
93
|
+
path: "/root",
|
|
94
|
+
});
|
|
95
|
+
expect(res.json()).toEqual({
|
|
96
|
+
success: true,
|
|
97
|
+
data: { entries: [{ path: "/root/child.txt", type: "file" }] },
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("upload returns the canonical envelope", async () => {
|
|
102
|
+
const res = await request("POST", "/api/files/upload", {
|
|
103
|
+
sandboxName: "sb",
|
|
104
|
+
path: "/root/blob.bin",
|
|
105
|
+
contentBase64: BINARY_BASE64,
|
|
106
|
+
});
|
|
107
|
+
expect(res.json()).toEqual({
|
|
108
|
+
success: true,
|
|
109
|
+
data: { path: "/root/blob.bin" },
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("download returns the canonical binary base64 envelope", async () => {
|
|
114
|
+
const res = await request(
|
|
115
|
+
"GET",
|
|
116
|
+
`/api/files/download?sandboxName=sb&path=${encodeURIComponent("/root/blob.bin")}`
|
|
117
|
+
);
|
|
118
|
+
expect(res.json()).toEqual({
|
|
119
|
+
success: true,
|
|
120
|
+
data: { path: "/root/blob.bin", contentBase64: BINARY_BASE64 },
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("rejects malformed delete bodies", async () => {
|
|
125
|
+
const res = await request("POST", "/api/files/delete", {
|
|
126
|
+
sandboxName: "sb",
|
|
127
|
+
});
|
|
128
|
+
expect(res.statusCode).toBe(400);
|
|
129
|
+
});
|
|
130
|
+
});
|