@multiplayer-app/sandbox 7.0.0-push-ecr.0 → 7.0.1
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 +14 -11
- package/dist/cli.js +14 -10
- package/dist/cli.js.map +2 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/index.js +13 -9
- package/dist/index.js.map +2 -2
- package/dist/socket-client.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -21,10 +21,12 @@ for the public worker endpoint. Create one with the control plane's
|
|
|
21
21
|
defaults to the machine hostname; set it explicitly when multiple workers could
|
|
22
22
|
report the same hostname.
|
|
23
23
|
`SANDBOX_URL` is optional and defaults to
|
|
24
|
-
`https://api.sandbox.filingramp.com/v0`; set it explicitly for local or
|
|
25
|
-
self-hosted control planes. Its pathname
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
`https://api.sandbox.filingramp.com/v0/gapi`; set it explicitly for local or
|
|
25
|
+
self-hosted control planes. Its pathname is the sole source of the worker
|
|
26
|
+
socket path — `/workers/ws` is appended to it verbatim, so the full base
|
|
27
|
+
(including the `/gapi` segment) must be included: `/v0/gapi` selects the
|
|
28
|
+
public authenticated worker endpoint, while `/internal/v0/gapi` selects the
|
|
29
|
+
private tokenless endpoint.
|
|
28
30
|
|
|
29
31
|
The sandbox worker exposes probes on `SANDBOX_HEALTH_PORT` (default `3000`)
|
|
30
32
|
under `API_PREFIX` (default `/v0/api`): `GET /v0/api/healthz` is its
|
|
@@ -42,23 +44,24 @@ WORKER_TOKEN=<token> sandbox start
|
|
|
42
44
|
|
|
43
45
|
For a trusted deployment on the same Kubernetes cluster or private Docker
|
|
44
46
|
Compose network, leave `WORKER_TOKEN` unset and set
|
|
45
|
-
`SANDBOX_URL=http://builder-
|
|
46
|
-
`/internal/v0/
|
|
47
|
-
exposed by the public ingress. A client URL such as
|
|
48
|
-
`https://api.sandbox.filingramp.com/v0` resolves to
|
|
49
|
-
requires a valid, user-created API key as
|
|
47
|
+
`SANDBOX_URL=http://builder-gateway-service:3000/internal/v0/gapi`. This
|
|
48
|
+
resolves to `/internal/v0/gapi/workers/ws`, which does not require a token and
|
|
49
|
+
must not be exposed by the public ingress. A client URL such as
|
|
50
|
+
`https://api.sandbox.filingramp.com/v0/gapi` resolves to
|
|
51
|
+
`/v0/gapi/workers/ws`, which requires a valid, user-created API key as
|
|
52
|
+
`WORKER_TOKEN`.
|
|
50
53
|
|
|
51
54
|
The published runtime bundles the repository's internal `builder-types` and
|
|
52
55
|
`logger` libraries, so installing the CLI does not require those workspace
|
|
53
56
|
packages to be published separately.
|
|
54
57
|
|
|
55
58
|
The worker ID defaults to the hostname and the control-plane URL defaults to
|
|
56
|
-
`https://api.sandbox.filingramp.com/v0`. Both can be overridden with environment
|
|
59
|
+
`https://api.sandbox.filingramp.com/v0/gapi`. Both can be overridden with environment
|
|
57
60
|
variables or flags:
|
|
58
61
|
|
|
59
62
|
```sh
|
|
60
63
|
sandbox start --token <token> --worker-id worker-eu-01 \
|
|
61
|
-
--sandbox-url http://localhost:3011/v0 --max-vms 5
|
|
64
|
+
--sandbox-url http://localhost:3011/v0/gapi --max-vms 5
|
|
62
65
|
```
|
|
63
66
|
|
|
64
67
|
## Run as a Docker container
|
package/dist/cli.js
CHANGED
|
@@ -28,7 +28,7 @@ var import_config5 = require("dotenv/config");
|
|
|
28
28
|
var import_commander = require("commander");
|
|
29
29
|
|
|
30
30
|
// package.json
|
|
31
|
-
var version = "7.0.
|
|
31
|
+
var version = "7.0.1";
|
|
32
32
|
|
|
33
33
|
// src/config.ts
|
|
34
34
|
var import_os2 = __toESM(require("os"));
|
|
@@ -207,22 +207,23 @@ function parseArnList(raw) {
|
|
|
207
207
|
const arns = raw.split(",").map((s) => s.trim()).filter(Boolean);
|
|
208
208
|
return arns.length ? arns : void 0;
|
|
209
209
|
}
|
|
210
|
-
function resolveSandboxEndpoint(rawUrl
|
|
210
|
+
function resolveSandboxEndpoint(rawUrl) {
|
|
211
211
|
const url = new URL(rawUrl);
|
|
212
|
-
const basePath = url.pathname.replace(/\/+$/, "")
|
|
212
|
+
const basePath = url.pathname.replace(/\/+$/, "");
|
|
213
213
|
return {
|
|
214
214
|
// Socket.IO treats a URL pathname as a namespace, so connect to the origin
|
|
215
|
-
// and pass the derived HTTP transport path separately.
|
|
215
|
+
// and pass the derived HTTP transport path separately. SANDBOX_URL's pathname is the
|
|
216
|
+
// sole source of truth for the socket path — it must include whatever base the control
|
|
217
|
+
// plane expects (e.g. "/v0/gapi" or "/internal/v0/gapi"), and "/workers/ws" is appended.
|
|
216
218
|
sandboxUrl: url.origin,
|
|
217
|
-
workerSocketPath:
|
|
219
|
+
workerSocketPath: `${basePath}/workers/ws`
|
|
218
220
|
};
|
|
219
221
|
}
|
|
220
222
|
function loadWorkerConfigFromEnv(env = process.env) {
|
|
221
223
|
const workerId = env.WORKER_ID?.trim() || import_os2.default.hostname();
|
|
222
224
|
const token = env.WORKER_TOKEN?.trim() || void 0;
|
|
223
225
|
const sandboxEndpoint = resolveSandboxEndpoint(
|
|
224
|
-
env.SANDBOX_URL ?? "https://api.sandbox.filingramp.com/v0"
|
|
225
|
-
env.WORKER_SOCKET_PATH
|
|
226
|
+
env.SANDBOX_URL ?? "https://api.sandbox.filingramp.com/v0/gapi"
|
|
226
227
|
);
|
|
227
228
|
return {
|
|
228
229
|
workerId,
|
|
@@ -337,7 +338,7 @@ var import_os3 = require("os");
|
|
|
337
338
|
// ../logger/src/config.ts
|
|
338
339
|
var NODE_ENV = process.env.NODE_ENV || "development";
|
|
339
340
|
var isProduction = NODE_ENV === "production";
|
|
340
|
-
var APP_NAME = process.env.npm_package_name?.split("/").pop() || "
|
|
341
|
+
var APP_NAME = process.env.APP_NAME || process.env.npm_package_name?.split("/").pop() || "unknown-app";
|
|
341
342
|
var LOG_LEVEL = process.env.LOG_LEVEL || (isProduction ? "info" : "debug");
|
|
342
343
|
|
|
343
344
|
// ../logger/src/logger.ts
|
|
@@ -3561,7 +3562,10 @@ function connectToSandbox(config, executor) {
|
|
|
3561
3562
|
socket.off(WorkerEvent.REATTACH);
|
|
3562
3563
|
});
|
|
3563
3564
|
socket.on("connect_error", (error) => {
|
|
3564
|
-
src_default.error({
|
|
3565
|
+
src_default.error({
|
|
3566
|
+
err: error,
|
|
3567
|
+
sandboxUrl: config.sandboxUrl
|
|
3568
|
+
}, "sandbox connection error");
|
|
3565
3569
|
});
|
|
3566
3570
|
registerCommandHandlers(socket, executor);
|
|
3567
3571
|
return socket;
|
|
@@ -3892,7 +3896,7 @@ ${signal} received; shutting down sandbox worker...`);
|
|
|
3892
3896
|
process.once("SIGTERM", () => {
|
|
3893
3897
|
void stop("SIGTERM");
|
|
3894
3898
|
});
|
|
3895
|
-
|
|
3899
|
+
src_default.info(`Starting sandbox worker ${config.workerId} \u2192 ${config.sandboxUrl}`);
|
|
3896
3900
|
});
|
|
3897
3901
|
program.command("detect").description("probe this host and report which micro-VM engines it can run").action(() => {
|
|
3898
3902
|
const probes = probeEngines(loadWorkerConfigFromEnv({ ...process.env, WORKER_ID: "-", WORKER_TOKEN: "-" }));
|