@wezzard/mcp-relay 0.16.0 → 0.17.0
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/.claude-plugin/plugin.json +1 -1
- package/README.md +27 -7
- package/agents/vm-relay-operator.md +3 -2
- package/dist/build-info.json +6 -4
- package/dist/doctor.mjs +69 -22
- package/dist/integrity.json +2 -2
- package/dist/server.mjs +382 -152
- package/package.json +1 -1
- package/pi-mcp.json +1 -1
package/README.md
CHANGED
|
@@ -7,11 +7,10 @@ it for both Claude Code and pi, the latter loaded through `pi-mcp-adapter`. It
|
|
|
7
7
|
is an MCP server: fourteen `relay_*` tools, each with its own schema, title
|
|
8
8
|
and annotations, and the server's `instructions`. The user command, status,
|
|
9
9
|
ships as one small command file per host (see "Commands"). There is no skill and no hook. Together they offer recorded,
|
|
10
|
-
snapshot-evidenced scripts, commands included as shell scripts, in a fresh, dedicated VM
|
|
11
|
-
the agent chooses to run there; a script drives the desktop or a browser
|
|
12
|
-
through the software the image lists, such as cua-driver or Playwright. Nothing here executes local computer-use, spawns
|
|
13
|
-
subagents,
|
|
14
|
-
browsers.
|
|
10
|
+
snapshot-evidenced scripts, commands included as shell scripts, in a fresh, dedicated VM or on a
|
|
11
|
+
durable machine, a real Mac leased whole, for any work the agent chooses to run there; a script drives the desktop or a browser
|
|
12
|
+
through the software the image lists, such as cua-driver or Playwright. Nothing here executes local computer-use on the relay's own host, spawns
|
|
13
|
+
subagents, records video, or attaches to existing browsers.
|
|
15
14
|
|
|
16
15
|
The project was named mcp-vm-relay before v0.12.0. The npm package is now
|
|
17
16
|
`@wezzard/mcp-relay`, the plugin and its marketplace are `mcp-relay`, and every
|
|
@@ -302,6 +301,26 @@ Failed or uncertain launches retain ownership; resolve or cancel the attempt
|
|
|
302
301
|
rather than replaying it. Console tests use mocked backends; no live viewer,
|
|
303
302
|
installation or platform acceptance is claimed here.
|
|
304
303
|
|
|
304
|
+
## Durable machines
|
|
305
|
+
|
|
306
|
+
`relay_acquire` takes `machine` in place of `image` to lease a durable machine,
|
|
307
|
+
a real Mac that machine-service exposes, such as `Build-Mac-1`. Every other
|
|
308
|
+
tool works on it as on a VM ([docs/durable-machines.md](docs/durable-machines.md)).
|
|
309
|
+
|
|
310
|
+
- The relay finds the instance that owns the machine as `machctl list` does:
|
|
311
|
+
the loopback instance, then every `machine-service` registration of the
|
|
312
|
+
Consul agent at `CONSUL_HTTP_ADDR` (default `http://127.0.0.1:8500`). A Mac
|
|
313
|
+
without its own Consul agent points `CONSUL_HTTP_ADDR` at one, for example
|
|
314
|
+
through an SSH tunnel.
|
|
315
|
+
- Every call carries the lease's `lease_id`, files go as bytes, and the relay
|
|
316
|
+
stages under the lease's workspace, which machine-service removes at release.
|
|
317
|
+
- Runs take snapshots only while the Mac's cua-driver daemon (`CuaDriver.app`,
|
|
318
|
+
`com.trycua.driver`) holds Screen Recording, read with
|
|
319
|
+
`cua-driver permissions status --json` in the lease. machine-service's own
|
|
320
|
+
permissions are not read, and it needs no Screen Recording grant.
|
|
321
|
+
- A durable machine is on the home network and not isolated from it, a CI job
|
|
322
|
+
may share its desktop, and it has no console.
|
|
323
|
+
|
|
305
324
|
## Selected environments
|
|
306
325
|
|
|
307
326
|
Set `VM_ENVIRONMENT_FILE` to a profile, at `schemaVersion` 2 with
|
|
@@ -352,7 +371,8 @@ keeps the VM for a retry after space is freed.
|
|
|
352
371
|
|
|
353
372
|
- `MCP_RELAY_PROJECT`: the project directory (the plugin passes Claude Code's). Evidence lands under `relay-evidence/<task>/` there. Every host file the relay reads, `relay_stage`'s `workspace` and `files[].local` and `relay_script`'s `localPath`, lies in this folder: a relative path resolves against it, an absolute path must already lie in it, and a path through a symlink is refused.
|
|
354
373
|
- `MCP_RELAY_SESSION`: an explicit session identity. By default each server process takes a fresh random one; a stable identity lets a restarted server reconcile and reattach the guests of the same identity.
|
|
355
|
-
- `MCP_RELAY_URL`: the loopback machine-service origin, default `http://localhost:6240`. Non-loopback servers
|
|
374
|
+
- `MCP_RELAY_URL`: the loopback machine-service origin, default `http://localhost:6240`. Non-loopback servers and redirects are refused; a durable machine's instance on another Mac is reached only when Consul lists it.
|
|
375
|
+
- `CONSUL_HTTP_ADDR`: the Consul agent that lists machine-service instances, for durable machines; default `http://127.0.0.1:8500`.
|
|
356
376
|
- `MCP_RELAY_GUEST_NETWORK`: the network every guest is acquired on, `nat` (the default) or `internet`. With `internet`, machine-service gives a guest that reaches the internet and reaches neither this host nor any private network; an application that hosts agents sets it. The agent cannot choose it: `relay_acquire` takes no network. Any other value stops the server at startup and refuses every acquisition, and a machine-service that cannot give `internet` refuses the acquisition with its own reason, never falling back to `nat`.
|
|
357
377
|
- `MCP_RELAY_ON_EXIT`: what the end of a session does to its guests, `pause` (the default: renewal pauses and the VMs are kept for an explicit finish or release) or `release` (every guest is released, then the server exits). An application that owns its tasks' machines, such as The Desk, sets `release`. Any other value stops the server at startup.
|
|
358
378
|
- `MCP_RELAY_CAPACITY_WAIT`: how many seconds `relay_acquire` waits when the host is at capacity, such as at machine-service's limit of two running macOS VMs, asking again every 15 s; default 1800, and 0 for not at all. Any other value stops the server at startup.
|
|
@@ -362,7 +382,7 @@ keeps the VM for a retry after space is freed.
|
|
|
362
382
|
- `MCP_RELAY_SHUTDOWN_GRACE_MS`: how long a session end waits for an in-flight operation, and with `MCP_RELAY_ON_EXIT=release` for the guests' releases, before cancelling it; default 120000.
|
|
363
383
|
- `MCP_RELAY_PYTHON`: the Python 3 used for the registry lock; default `python3` on PATH.
|
|
364
384
|
- `VM_ENVIRONMENT_FILE`: a selected environment profile; it overrides the URL, state directory and registry above and binds the Tart store.
|
|
365
|
-
- Guest files go to `/var/tmp/<UTC-timestamp>-mcp-relay-<task
|
|
385
|
+
- Guest files go to `/var/tmp/<UTC-timestamp>-mcp-relay-<task>/` on a VM and to `<lease workspace>/work/mcp-relay-<task>/` on a durable machine, with the runtime in `receiver.mjs`, support in `support/` and work in `workspace/`.
|
|
366
386
|
|
|
367
387
|
## Development
|
|
368
388
|
|
|
@@ -5,8 +5,9 @@ tools: mcp__plugin_mcp-relay_relay__relay_search, mcp__plugin_mcp-relay_relay__r
|
|
|
5
5
|
model: sonnet
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
-
Work in a dedicated fresh VM
|
|
9
|
-
|
|
8
|
+
Work in a dedicated fresh VM, or on a durable machine (a real Mac named with
|
|
9
|
+
`machine`), through the relay's MCP tools. Probe first to pick the image the
|
|
10
|
+
task needs, or use the durable machine the task names. Acquire one
|
|
10
11
|
guest for each machine the task needs, and declare every output you will bring
|
|
11
12
|
home as an extraction before any work. relay_acquire answers the guest's name,
|
|
12
13
|
`guest`; name it in every later call on that guest. Several guests may run at
|
package/dist/build-info.json
CHANGED
|
@@ -954,9 +954,11 @@
|
|
|
954
954
|
"node_modules/zod/v4/mini/parse.js": "b87374f4e821d583f699d83e4b74ac59e4a5a782c510959187a0ba209145d76b",
|
|
955
955
|
"node_modules/zod/v4/mini/schemas.js": "5614339bbec6b9be13ed1809e1215fe44d78e99f5f0eee848c0bb3b25dc1c9b6",
|
|
956
956
|
"src/archive.ts": "469ca411558db5696c8790d8a7132108d6705d4316c5a31a149f7472ddbef0ec",
|
|
957
|
+
"src/capture-gate.ts": "6757d7329b62e5b093323eddc779ee13722a0da24ab659649a23a2e70c4fbd56",
|
|
957
958
|
"src/config.ts": "3fbc475596ec0a1b6122ea963bf2769420a8a2a0e62fda55e66018fb3a6d53b3",
|
|
958
959
|
"src/console.ts": "d8258173a24449c2a394289b14983b9575c5ce753ab267d4e13213f3abfcb72d",
|
|
959
960
|
"src/core.ts": "dd889fda6af982ab47b40b346e7fbc41a213b6d258d3d5fe56cd8c5373221159",
|
|
961
|
+
"src/discovery.ts": "80db010052e9a37a00c5f5c1bb525fc95d8026c68ef9cd307eab0e4ec1d48920",
|
|
960
962
|
"src/doctor.ts": "8249e9fa78b679e9ef7fd30f617bf07848961346101d3b64c42f779cfb042671",
|
|
961
963
|
"src/downloads.ts": "4f37b5bb4fac96f9260a3a87c83bacf715b9add5ae9926d3fe0994000c70a8dd",
|
|
962
964
|
"src/environment.ts": "5770e966e49d78ae069614078c667f94e70074b150f83111049529ff613aa215",
|
|
@@ -965,18 +967,18 @@
|
|
|
965
967
|
"src/guest/receiver.ts": "92fc8d3bfe95ed56d43cfe5b46eb196034ade5e4e9f58ed202465531458f697d",
|
|
966
968
|
"src/image-presentation.ts": "64ca29a3444a04606cb783c81ac2d0f3136f9a9ac730ae9074156f0a63256c76",
|
|
967
969
|
"src/images.ts": "734a30ba34cd80ef0b5c3791232f13b170b06d6d74c4b843d39566d2e09136d0",
|
|
968
|
-
"src/machine-service.ts": "
|
|
969
|
-
"src/manager.ts": "
|
|
970
|
+
"src/machine-service.ts": "e6464c58882b9886af88e49645fdadb5beac46299dd358d9b022be942dcff0bb",
|
|
971
|
+
"src/manager.ts": "62fd73c86d66f0135f6fa718f6f307ce0c2b3dbb7fe9a3b95275219b54b2de4e",
|
|
970
972
|
"src/owner-lock.ts": "a99cbaba67b4aff0e646dc5d5967db4497ba6dbda83fb1838c55f0bf0f6e0367",
|
|
971
973
|
"src/package.ts": "a52ed791813922e3ace9144706ddde8313a67d8580a3acd54a0799de3ebe44d2",
|
|
972
974
|
"src/probe.ts": "40a123f725aad7c22fe63707dd2de99646cb1f307d7d660927e8ca2b973e9ce0",
|
|
973
975
|
"src/registry.ts": "87478f1ceef0f06df9b28c064a817383ff153bdadd70e6d58b4a7ed464f66146",
|
|
974
976
|
"src/review-data.ts": "2e873eb23612fd4502d84e65322006345f4e97bb679109b23dc4d26683200c19",
|
|
975
|
-
"src/schema.ts": "
|
|
977
|
+
"src/schema.ts": "7f68a85c9593fc2ad1455efd6e757c43f8ed591293fd820f1a08408db17c1912",
|
|
976
978
|
"src/search-diagnostics.ts": "cea037618c56f075d51155101ad1cc0314bfa67b174bdb070191e0ea5ea04679",
|
|
977
979
|
"src/search.ts": "8aaf544fcb27e7e018bd976e1ba7d3c70c047aeda3182b3dce91873a901a245e",
|
|
978
980
|
"src/server.ts": "bff4c09c29890aa62175ead36d9cfd6f8fa7334d2ee0929b51a0371d38c5df1c",
|
|
979
|
-
"src/surface.ts": "
|
|
981
|
+
"src/surface.ts": "25681325cb01dfb04524bca8e0e5f3d4b4795d3db814384c7d1e9a8ec831eb16",
|
|
980
982
|
"src/transfer.ts": "f27d65c0b42f9933e6a7f950f56111b84c644e8739bab44805aebfb54d77e320",
|
|
981
983
|
"src/transport.ts": "35df20b321f52c4a371f1e29923e957e7c85d58001e2864f0fd13c2c2838945f",
|
|
982
984
|
"src/typebox.ts": "7f071fbc67548c7d3701272dabe88a217812e12e41dfad76974ff08169fa1a7e",
|
package/dist/doctor.mjs
CHANGED
|
@@ -47,6 +47,7 @@ async function command(argv, options = {}) {
|
|
|
47
47
|
|
|
48
48
|
// src/machine-service.ts
|
|
49
49
|
import { isIP } from "node:net";
|
|
50
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
50
51
|
var MachineServiceError = class extends Error {
|
|
51
52
|
constructor(message, status, responseBody, options) {
|
|
52
53
|
super(message, options);
|
|
@@ -69,7 +70,7 @@ function capacityRefusal(error) {
|
|
|
69
70
|
}
|
|
70
71
|
if (!body || typeof body !== "object") return false;
|
|
71
72
|
const { error: reason, outcome } = body;
|
|
72
|
-
return typeof reason === "string" &&
|
|
73
|
+
return typeof reason === "string" && /^(macOS VM limit reached|durable machine leased|durable machine unavailable)/.test(reason) && outcome !== "uncertain";
|
|
73
74
|
}
|
|
74
75
|
var SERVICE_NAME = "machine-service";
|
|
75
76
|
function expectMachineService(health, origin) {
|
|
@@ -91,8 +92,16 @@ function positive(value, label) {
|
|
|
91
92
|
function record(value) {
|
|
92
93
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
93
94
|
}
|
|
95
|
+
function named(value) {
|
|
96
|
+
const fields = value;
|
|
97
|
+
if (record(value) && fields.kind === "durable" && typeof fields.vm !== "string" && typeof fields.name === "string") fields.vm = fields.name;
|
|
98
|
+
return value;
|
|
99
|
+
}
|
|
94
100
|
function isLease(value) {
|
|
95
101
|
if (!record(value)) return false;
|
|
102
|
+
if (named(value).kind === "durable") {
|
|
103
|
+
return ["vm", "purpose", "lease_id", "workspace"].every((k) => typeof value[k] === "string" && value[k] !== "") && value.image === null && value.image_kind === null && value.state === "leased" && ["created_at", "ttl_expires_at"].every((k) => typeof value[k] === "number" && Number.isFinite(value[k]));
|
|
104
|
+
}
|
|
96
105
|
return ["vm", "purpose", "image"].every((k) => typeof value[k] === "string" && value[k] !== "") && ["macos", "linux"].includes(String(value.image_kind)) && ["pending", "provisioning", "running", "releasing"].includes(String(value.state)) && ["created_at", "ttl_expires_at"].every((k) => typeof value[k] === "number" && Number.isFinite(value[k])) && ["cpu", "memory_mb", "disk_gb", "grace_until"].every((k) => value[k] === null || typeof value[k] === "number") && ["env", "ip"].every((k) => value[k] === null || typeof value[k] === "string") && typeof value.warned === "boolean";
|
|
97
106
|
}
|
|
98
107
|
var MachineService = class {
|
|
@@ -108,8 +117,8 @@ var MachineService = class {
|
|
|
108
117
|
if (options.environment && url.origin !== new URL(options.environment.profile.vmServiceUrl).origin) throw new TypeError("Backend endpoint does not match the selected environment");
|
|
109
118
|
const host = url.hostname.replace(/^\[|\]$/g, "");
|
|
110
119
|
const loopback = host === "localhost" || host === "::1" || isIP(host) === 4 && host.startsWith("127.");
|
|
111
|
-
if (!loopback || !["http:", "https:"].includes(url.protocol) || url.username || url.password || url.search || url.hash || url.pathname !== "/") {
|
|
112
|
-
throw new TypeError("machine-service baseUrl must be a loopback HTTP(S) origin without credentials, path, query or fragment");
|
|
120
|
+
if (!loopback && !options.listed || !["http:", "https:"].includes(url.protocol) || url.username || url.password || url.search || url.hash || url.pathname !== "/") {
|
|
121
|
+
throw new TypeError("machine-service baseUrl must be a loopback HTTP(S) origin, or one Consul lists as machine-service, without credentials, path, query or fragment");
|
|
113
122
|
}
|
|
114
123
|
this.baseUrl = url.origin;
|
|
115
124
|
this.timeoutMs = positive(options.timeoutMs ?? 66e4, "timeoutMs");
|
|
@@ -119,8 +128,10 @@ var MachineService = class {
|
|
|
119
128
|
health(options = {}) {
|
|
120
129
|
return this.request("/health", void 0, options);
|
|
121
130
|
}
|
|
122
|
-
list(options = {}) {
|
|
123
|
-
|
|
131
|
+
async list(options = {}) {
|
|
132
|
+
const list = await this.request("/machines", void 0, options);
|
|
133
|
+
if (record(list.machines)) Object.values(list.machines).forEach(named);
|
|
134
|
+
return list;
|
|
124
135
|
}
|
|
125
136
|
images(options = {}) {
|
|
126
137
|
return this.request("/images", void 0, options);
|
|
@@ -147,8 +158,8 @@ var MachineService = class {
|
|
|
147
158
|
throw new MachineServiceError(`Console API unavailable or request outcome unknown${error instanceof MachineServiceError && error.status ? ` (HTTP ${error.status})` : ""}; resolve before another open`, error instanceof MachineServiceError ? error.status : void 0);
|
|
148
159
|
}
|
|
149
160
|
}
|
|
150
|
-
get(vm, options = {}) {
|
|
151
|
-
return this.request(this.path(vm), void 0, options);
|
|
161
|
+
async get(vm, options = {}) {
|
|
162
|
+
return named(await this.request(this.path(vm), void 0, options));
|
|
152
163
|
}
|
|
153
164
|
/**
|
|
154
165
|
* Cancellation before dispatch prevents allocation. Once dispatched we deliberately
|
|
@@ -181,17 +192,57 @@ var MachineService = class {
|
|
|
181
192
|
pull(vm, body, options = {}) {
|
|
182
193
|
return this.request(this.path(vm, "pull"), body, options);
|
|
183
194
|
}
|
|
184
|
-
heartbeat(vm, body = {}, options = {}) {
|
|
185
|
-
return this.request(this.path(vm, "heartbeat"), body, options);
|
|
195
|
+
async heartbeat(vm, body = {}, options = {}) {
|
|
196
|
+
return named(await this.request(this.path(vm, "heartbeat"), body, options));
|
|
186
197
|
}
|
|
187
198
|
release(vm, body = {}, options = {}) {
|
|
188
199
|
return this.request(this.path(vm, "release"), body, options);
|
|
189
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* Push one file as bytes, `PUT /machines/<name>/files` (FD-4): the instance
|
|
203
|
+
* checks the digest before it writes, so a client on another Mac needs no
|
|
204
|
+
* host path the instance could read (DC-31).
|
|
205
|
+
*/
|
|
206
|
+
async pushBytes(vm, body, options = {}) {
|
|
207
|
+
const sha256 = createHash2("sha256").update(body.bytes).digest("hex");
|
|
208
|
+
const response = await this.fetchBounded(this.filesPath(vm, body.remote_path, body.lease_id), { method: "PUT", headers: { "Content-Type": "application/octet-stream", "X-Content-SHA256": sha256 }, body: new Uint8Array(body.bytes) }, options, this.maxResponseBytes);
|
|
209
|
+
const answer = this.json(response.path, response.text);
|
|
210
|
+
if (answer.sha256 !== sha256 || answer.bytes !== body.bytes.length) throw new MachineServiceError(`machine-service ${response.path}: the instance stored ${answer.bytes} bytes with SHA-256 ${answer.sha256}, not what was sent`);
|
|
211
|
+
return answer;
|
|
212
|
+
}
|
|
213
|
+
/** Pull one file as bytes, `GET /machines/<name>/files`; refused unless the bytes match the digest the instance states (DC-31). */
|
|
214
|
+
async pullBytes(vm, body, options = {}) {
|
|
215
|
+
const response = await this.fetchBounded(this.filesPath(vm, body.remote_path, body.lease_id), { method: "GET" }, options, body.maxBytes);
|
|
216
|
+
if (response.contentType !== "application/octet-stream") throw new MachineServiceError(`machine-service ${response.path}: expected one file, got ${response.contentType ?? "no content type"}`);
|
|
217
|
+
const digest = createHash2("sha256").update(response.bytes).digest("hex");
|
|
218
|
+
if (!response.sha256 || digest !== response.sha256.toLowerCase()) throw new MachineServiceError(`machine-service ${response.path}: the bytes' SHA-256 ${digest} differs from the stated ${response.sha256 ?? "none"}`);
|
|
219
|
+
return response.bytes;
|
|
220
|
+
}
|
|
221
|
+
filesPath(vm, remote, lease_id) {
|
|
222
|
+
const query = new URLSearchParams({ ...lease_id ? { lease_id } : {}, path: remote });
|
|
223
|
+
return `${this.path(vm, "files")}?${query}`;
|
|
224
|
+
}
|
|
190
225
|
path(vm, action) {
|
|
191
226
|
if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(vm)) throw new TypeError("Invalid VM name");
|
|
192
227
|
return `/machines/${encodeURIComponent(vm)}${action ? `/${action}` : ""}`;
|
|
193
228
|
}
|
|
194
229
|
async request(path, body, options) {
|
|
230
|
+
const response = await this.fetchBounded(path, {
|
|
231
|
+
method: body === void 0 ? "GET" : "POST",
|
|
232
|
+
headers: body === void 0 ? {} : { "Content-Type": "application/json" },
|
|
233
|
+
...body === void 0 ? {} : { body: JSON.stringify(body) }
|
|
234
|
+
}, options, this.maxResponseBytes);
|
|
235
|
+
return this.json(path, response.text);
|
|
236
|
+
}
|
|
237
|
+
json(path, text) {
|
|
238
|
+
try {
|
|
239
|
+
return JSON.parse(text);
|
|
240
|
+
} catch (cause) {
|
|
241
|
+
throw new MachineServiceError(`machine-service ${path}: invalid JSON response`, void 0, void 0, { cause });
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/** One request whose answer is read up to `maxBytes`; an error answer is read up to 4 KiB and thrown with its status. */
|
|
245
|
+
async fetchBounded(path, init, options, maxBytes) {
|
|
195
246
|
options.signal?.throwIfAborted();
|
|
196
247
|
const timeoutMs = positive(options.timeoutMs ?? this.timeoutMs, "timeoutMs");
|
|
197
248
|
const controller = new AbortController();
|
|
@@ -200,17 +251,17 @@ var MachineService = class {
|
|
|
200
251
|
const timer = setTimeout(() => controller.abort(new MachineServiceError(`machine-service ${path} timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
201
252
|
try {
|
|
202
253
|
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
203
|
-
method:
|
|
204
|
-
headers: { ...
|
|
205
|
-
...body === void 0 ? {} : { body:
|
|
254
|
+
method: init.method,
|
|
255
|
+
headers: { ...init.headers, ...this.environment ? { "X-VM-Environment-Fingerprint": this.environment.identity.fingerprint } : {} },
|
|
256
|
+
...init.body === void 0 ? {} : { body: init.body },
|
|
206
257
|
signal: controller.signal,
|
|
207
258
|
redirect: "error"
|
|
208
|
-
// Do not let a
|
|
259
|
+
// Do not let a service redirect to another host.
|
|
209
260
|
});
|
|
210
261
|
const reader = response.body?.getReader();
|
|
211
262
|
const chunks = [];
|
|
212
263
|
let size = 0;
|
|
213
|
-
const bound = response.ok ?
|
|
264
|
+
const bound = response.ok ? maxBytes : Math.min(4096, maxBytes);
|
|
214
265
|
let truncated = false;
|
|
215
266
|
if (reader) {
|
|
216
267
|
try {
|
|
@@ -230,14 +281,10 @@ var MachineService = class {
|
|
|
230
281
|
reader.releaseLock();
|
|
231
282
|
}
|
|
232
283
|
}
|
|
233
|
-
const
|
|
284
|
+
const bytes = Buffer.concat(chunks), text = bytes.toString("utf8");
|
|
234
285
|
if (!response.ok) throw new MachineServiceError(`machine-service ${path}: HTTP ${response.status}: ${text}${truncated ? " [truncated]" : ""}`, response.status, text);
|
|
235
286
|
if (truncated) throw new MachineServiceError(`machine-service ${path}: response exceeds ${bound} bytes`);
|
|
236
|
-
|
|
237
|
-
return JSON.parse(text);
|
|
238
|
-
} catch (cause) {
|
|
239
|
-
throw new MachineServiceError(`machine-service ${path}: invalid JSON response`, void 0, void 0, { cause });
|
|
240
|
-
}
|
|
287
|
+
return { path, bytes, text, contentType: response.headers.get("content-type") ?? void 0, sha256: response.headers.get("x-content-sha256") ?? void 0 };
|
|
241
288
|
} catch (cause) {
|
|
242
289
|
if (controller.signal.aborted) throw controller.signal.reason;
|
|
243
290
|
if (cause instanceof MachineServiceError) throw cause;
|
|
@@ -261,7 +308,7 @@ import { isAbsolute as isAbsolute2, join as join2, normalize } from "node:path";
|
|
|
261
308
|
|
|
262
309
|
// src/environment.ts
|
|
263
310
|
import { accessSync, constants, lstatSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
264
|
-
import { createHash as
|
|
311
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
265
312
|
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
266
313
|
import { homedir } from "node:os";
|
|
267
314
|
import { isIP as isIP2 } from "node:net";
|
|
@@ -354,7 +401,7 @@ function loadEnvironment(path, env = process.env, home = env.HOME ?? homedir())
|
|
|
354
401
|
for (const other of mutable) if (key !== other && overlaps(value, profile[other])) throw new Error("Environment mutable roots must be disjoint");
|
|
355
402
|
}
|
|
356
403
|
const ordered = Object.fromEntries(Object.keys(profile).sort().map((k) => [k, profile[k]]));
|
|
357
|
-
const fingerprint =
|
|
404
|
+
const fingerprint = createHash3("sha256").update(JSON.stringify(ordered), "utf8").digest("hex");
|
|
358
405
|
const identity = Object.freeze({
|
|
359
406
|
id: profile.id,
|
|
360
407
|
fingerprint,
|
package/dist/integrity.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"server.mjs": "
|
|
2
|
+
"server.mjs": "f8c52e4e41d9588b0a4725ec6f95c890c68701cf0f33984797ce9d33d6b3d448",
|
|
3
3
|
"receiver.mjs": "8b5b6fdd6cb789cdc4060e367a155cb42e7cf34187044c899789bf76b7bb0e14",
|
|
4
|
-
"doctor.mjs": "
|
|
4
|
+
"doctor.mjs": "ca11eaf0d83041fd9c64ccff8800424f6411db50028a09faf5bc2c8ff3bafd33",
|
|
5
5
|
"review-data.mjs": "da7b6b35d060e09cfc445df4febda02a1a0c0f23d9b854866aed8d604cbb3993"
|
|
6
6
|
}
|