@wezzard/mcp-relay 0.17.0 → 0.17.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-relay",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "Runs an agent's code on fresh, isolated VMs, several at once, each run recorded with evidence",
5
5
  "author": {
6
6
  "name": "WeZZard"
@@ -966,9 +966,9 @@
966
966
  "src/guest/image-evidence.ts": "9c5daaed5b33b9912021a91fd79a2e6d5be42c75d37761772a3bd2645d20a55e",
967
967
  "src/guest/receiver.ts": "92fc8d3bfe95ed56d43cfe5b46eb196034ade5e4e9f58ed202465531458f697d",
968
968
  "src/image-presentation.ts": "64ca29a3444a04606cb783c81ac2d0f3136f9a9ac730ae9074156f0a63256c76",
969
- "src/images.ts": "734a30ba34cd80ef0b5c3791232f13b170b06d6d74c4b843d39566d2e09136d0",
970
- "src/machine-service.ts": "e6464c58882b9886af88e49645fdadb5beac46299dd358d9b022be942dcff0bb",
971
- "src/manager.ts": "62fd73c86d66f0135f6fa718f6f307ce0c2b3dbb7fe9a3b95275219b54b2de4e",
969
+ "src/images.ts": "415bfb37966a60ef3e407236295b9aeeb314f7fb33de55a6ada512cff6661908",
970
+ "src/machine-service.ts": "9bb169564572304488cf7f33db959186ec2a4f9be9685b84b270cf4cd6f3aee9",
971
+ "src/manager.ts": "03d6c94034378f04089d2af9a0a1bdef2cec028a16d5009019c7c397211ab758",
972
972
  "src/owner-lock.ts": "a99cbaba67b4aff0e646dc5d5967db4497ba6dbda83fb1838c55f0bf0f6e0367",
973
973
  "src/package.ts": "a52ed791813922e3ace9144706ddde8313a67d8580a3acd54a0799de3ebe44d2",
974
974
  "src/probe.ts": "40a123f725aad7c22fe63707dd2de99646cb1f307d7d660927e8ca2b973e9ce0",
package/dist/doctor.mjs CHANGED
@@ -48,6 +48,7 @@ async function command(argv, options = {}) {
48
48
  // src/machine-service.ts
49
49
  import { isIP } from "node:net";
50
50
  import { createHash as createHash2 } from "node:crypto";
51
+ import { open, rm } from "node:fs/promises";
51
52
  var MachineServiceError = class extends Error {
52
53
  constructor(message, status, responseBody, options) {
53
54
  super(message, options);
@@ -77,6 +78,7 @@ function expectMachineService(health, origin) {
77
78
  if (health.service === SERVICE_NAME) return;
78
79
  throw new Error(`The service at ${origin} answers as ${JSON.stringify(health.service ?? null)}, not ${SERVICE_NAME}. This relay speaks only machine-service's /machines API: install machine-service, which replaced vm-service.`);
79
80
  }
81
+ var PULL_IDLE_MS = 12e4;
80
82
  var AcquireIndeterminateError = class extends MachineServiceError {
81
83
  constructor(purpose, cause) {
82
84
  super(`Acquisition outcome unknown for purpose '${purpose}'; reconcile GET /machines before retrying or ending the enclosure`, void 0, void 0, { cause });
@@ -205,18 +207,39 @@ var MachineService = class {
205
207
  */
206
208
  async pushBytes(vm, body, options = {}) {
207
209
  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);
210
+ 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.buffer, body.bytes.byteOffset, body.bytes.byteLength) }, options, this.maxResponseBytes);
209
211
  const answer = this.json(response.path, response.text);
210
212
  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
213
  return answer;
212
214
  }
213
- /** Pull one file as bytes, `GET /machines/<name>/files`; refused unless the bytes match the digest the instance states (DC-31). */
215
+ /**
216
+ * Pull one file as bytes, `GET /machines/<name>/files`, into `to`, which
217
+ * must not exist. The bytes stream to disk as they are hashed, so a file of
218
+ * any size needs no memory of its size, and the pull is abandoned only when
219
+ * no byte arrives for its timeout. The file is removed unless the bytes
220
+ * match the digest the instance states (DC-31).
221
+ */
214
222
  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;
223
+ const hash2 = createHash2("sha256"), file = await open(body.to, "wx", 384);
224
+ let bytes = 0;
225
+ try {
226
+ const response = await this.fetchBounded(this.filesPath(vm, body.remote_path, body.lease_id), { method: "GET" }, { ...options, timeoutMs: options.timeoutMs ?? PULL_IDLE_MS }, Number.MAX_SAFE_INTEGER, { idle: true, sink: async (chunk) => {
227
+ hash2.update(chunk);
228
+ bytes += chunk.byteLength;
229
+ await file.write(chunk);
230
+ } });
231
+ if (response.contentType !== "application/octet-stream") throw new MachineServiceError(`machine-service ${response.path}: expected one file, got ${response.contentType ?? "no content type"}`);
232
+ const digest = hash2.digest("hex");
233
+ 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"}`);
234
+ await file.sync();
235
+ await file.close();
236
+ return { sha256: digest, bytes };
237
+ } catch (error) {
238
+ await file.close().catch(() => {
239
+ });
240
+ await rm(body.to, { force: true });
241
+ throw error;
242
+ }
220
243
  }
221
244
  filesPath(vm, remote, lease_id) {
222
245
  const query = new URLSearchParams({ ...lease_id ? { lease_id } : {}, path: remote });
@@ -241,14 +264,20 @@ var MachineService = class {
241
264
  throw new MachineServiceError(`machine-service ${path}: invalid JSON response`, void 0, void 0, { cause });
242
265
  }
243
266
  }
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) {
267
+ /**
268
+ * One request whose answer is read up to `maxBytes`; an error answer is read
269
+ * up to 4 KiB and thrown with its status. With `sink`, a successful answer is
270
+ * handed over chunk by chunk instead of kept; with `idle`, the timeout counts
271
+ * from the last chunk rather than from the start.
272
+ */
273
+ async fetchBounded(path, init, options, maxBytes, stream = {}) {
246
274
  options.signal?.throwIfAborted();
247
275
  const timeoutMs = positive(options.timeoutMs ?? this.timeoutMs, "timeoutMs");
248
276
  const controller = new AbortController();
249
277
  const abort = () => controller.abort(options.signal?.reason);
250
278
  options.signal?.addEventListener("abort", abort, { once: true });
251
- const timer = setTimeout(() => controller.abort(new MachineServiceError(`machine-service ${path} timed out after ${timeoutMs}ms`)), timeoutMs);
279
+ const expire = () => controller.abort(new MachineServiceError(`machine-service ${path} timed out after ${timeoutMs}ms${stream.idle ? " without a byte" : ""}`));
280
+ let timer = setTimeout(expire, timeoutMs);
252
281
  try {
253
282
  const response = await fetch(`${this.baseUrl}${path}`, {
254
283
  method: init.method,
@@ -268,6 +297,15 @@ var MachineService = class {
268
297
  for (; ; ) {
269
298
  const { value, done } = await reader.read();
270
299
  if (done) break;
300
+ if (stream.idle) {
301
+ clearTimeout(timer);
302
+ timer = setTimeout(expire, timeoutMs);
303
+ }
304
+ if (response.ok && stream.sink) {
305
+ size += value.byteLength;
306
+ await stream.sink(value);
307
+ continue;
308
+ }
271
309
  const remaining = bound - size;
272
310
  chunks.push(value.subarray(0, remaining));
273
311
  size += Math.min(value.byteLength, remaining);
@@ -288,7 +326,7 @@ var MachineService = class {
288
326
  } catch (cause) {
289
327
  if (controller.signal.aborted) throw controller.signal.reason;
290
328
  if (cause instanceof MachineServiceError) throw cause;
291
- throw new MachineServiceError(`machine-service ${path}: request failed`, void 0, void 0, { cause });
329
+ throw new MachineServiceError(`machine-service ${path}: request failed${cause instanceof Error ? `: ${cause.message}` : ""}`, void 0, void 0, { cause });
292
330
  } finally {
293
331
  clearTimeout(timer);
294
332
  options.signal?.removeEventListener("abort", abort);
@@ -298,7 +336,7 @@ var MachineService = class {
298
336
 
299
337
  // src/registry.ts
300
338
  import { randomUUID as randomUUID2 } from "node:crypto";
301
- import { link, lstat, mkdir, open, readFile, realpath, rename, unlink } from "node:fs/promises";
339
+ import { link, lstat, mkdir, open as open2, readFile, realpath, rename, unlink } from "node:fs/promises";
302
340
  import { readFileSync as readFileSync2, statSync as statSync2 } from "node:fs";
303
341
  import { homedir as homedir3 } from "node:os";
304
342
 
@@ -648,7 +686,7 @@ var Registry = class {
648
686
  const updated = transform(original);
649
687
  if (original === updated) return false;
650
688
  temporary = join3(dirname2(target), `.${target.split("/").at(-1)}.${token}.tmp`);
651
- const handle = await open(temporary, "wx", before.mode & 511);
689
+ const handle = await open2(temporary, "wx", before.mode & 511);
652
690
  try {
653
691
  await handle.chmod(before.mode & 511);
654
692
  await handle.writeFile(updated, "utf8");
@@ -664,7 +702,7 @@ var Registry = class {
664
702
  lock.check();
665
703
  await rename(temporary, target);
666
704
  temporary = void 0;
667
- const dir = await open(dirname2(target), "r");
705
+ const dir = await open2(dirname2(target), "r");
668
706
  try {
669
707
  await dir.sync();
670
708
  } finally {
@@ -691,7 +729,7 @@ var Registry = class {
691
729
  if (!errno(error, "ENOENT")) throw error;
692
730
  }
693
731
  const temporary = join3(dirname2(target), `.registry.${randomUUID2()}.tmp`);
694
- const handle = await open(temporary, "wx", 384);
732
+ const handle = await open2(temporary, "wx", 384);
695
733
  try {
696
734
  try {
697
735
  await handle.chmod(384);
@@ -706,7 +744,7 @@ var Registry = class {
706
744
  } catch (error) {
707
745
  if (!errno(error, "EEXIST")) throw error;
708
746
  }
709
- const dir = await open(dirname2(target), "r");
747
+ const dir = await open2(dirname2(target), "r");
710
748
  try {
711
749
  await dir.sync();
712
750
  } finally {
@@ -1,6 +1,6 @@
1
1
  {
2
- "server.mjs": "f8c52e4e41d9588b0a4725ec6f95c890c68701cf0f33984797ce9d33d6b3d448",
2
+ "server.mjs": "7de81a14e4248abfef15cffa78109dfd86a5c84bfdd7ccbacbacebab2954fa80",
3
3
  "receiver.mjs": "8b5b6fdd6cb789cdc4060e367a155cb42e7cf34187044c899789bf76b7bb0e14",
4
- "doctor.mjs": "ca11eaf0d83041fd9c64ccff8800424f6411db50028a09faf5bc2c8ff3bafd33",
4
+ "doctor.mjs": "f40afe5454bf4367ed50357c6fc20886eae69cbb391085bb853322ea29ab88ae",
5
5
  "review-data.mjs": "da7b6b35d060e09cfc445df4febda02a1a0c0f23d9b854866aed8d604cbb3993"
6
6
  }
package/dist/server.mjs CHANGED
@@ -17184,7 +17184,7 @@ var StdioServerTransport = class {
17184
17184
 
17185
17185
  // src/manager.ts
17186
17186
  import { randomUUID as randomUUID6 } from "node:crypto";
17187
- import { mkdir as mkdir10, readFile as readFile9, readdir as readdir7, rm as rm4, cp, access, statfs, writeFile as writeFile4 } from "node:fs/promises";
17187
+ import { mkdir as mkdir10, readFile as readFile9, readdir as readdir7, rm as rm5, cp, access, statfs } from "node:fs/promises";
17188
17188
  import { join as join13, resolve as resolve9 } from "node:path";
17189
17189
 
17190
17190
  // src/config.ts
@@ -17749,6 +17749,7 @@ init_evidence_package();
17749
17749
  // src/machine-service.ts
17750
17750
  import { isIP as isIP2 } from "node:net";
17751
17751
  import { createHash as createHash3 } from "node:crypto";
17752
+ import { open as open2, rm } from "node:fs/promises";
17752
17753
  var MachineServiceError = class extends Error {
17753
17754
  constructor(message3, status, responseBody, options) {
17754
17755
  super(message3, options);
@@ -17778,6 +17779,7 @@ function expectMachineService(health, origin) {
17778
17779
  if (health.service === SERVICE_NAME) return;
17779
17780
  throw new Error(`The service at ${origin} answers as ${JSON.stringify(health.service ?? null)}, not ${SERVICE_NAME}. This relay speaks only machine-service's /machines API: install machine-service, which replaced vm-service.`);
17780
17781
  }
17782
+ var PULL_IDLE_MS = 12e4;
17781
17783
  var AcquireIndeterminateError = class extends MachineServiceError {
17782
17784
  constructor(purpose, cause) {
17783
17785
  super(`Acquisition outcome unknown for purpose '${purpose}'; reconcile GET /machines before retrying or ending the enclosure`, void 0, void 0, { cause });
@@ -17906,18 +17908,39 @@ var MachineService = class {
17906
17908
  */
17907
17909
  async pushBytes(vm, body, options = {}) {
17908
17910
  const sha256 = createHash3("sha256").update(body.bytes).digest("hex");
17909
- 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);
17911
+ 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.buffer, body.bytes.byteOffset, body.bytes.byteLength) }, options, this.maxResponseBytes);
17910
17912
  const answer = this.json(response.path, response.text);
17911
17913
  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`);
17912
17914
  return answer;
17913
17915
  }
17914
- /** Pull one file as bytes, `GET /machines/<name>/files`; refused unless the bytes match the digest the instance states (DC-31). */
17916
+ /**
17917
+ * Pull one file as bytes, `GET /machines/<name>/files`, into `to`, which
17918
+ * must not exist. The bytes stream to disk as they are hashed, so a file of
17919
+ * any size needs no memory of its size, and the pull is abandoned only when
17920
+ * no byte arrives for its timeout. The file is removed unless the bytes
17921
+ * match the digest the instance states (DC-31).
17922
+ */
17915
17923
  async pullBytes(vm, body, options = {}) {
17916
- const response = await this.fetchBounded(this.filesPath(vm, body.remote_path, body.lease_id), { method: "GET" }, options, body.maxBytes);
17917
- if (response.contentType !== "application/octet-stream") throw new MachineServiceError(`machine-service ${response.path}: expected one file, got ${response.contentType ?? "no content type"}`);
17918
- const digest = createHash3("sha256").update(response.bytes).digest("hex");
17919
- 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"}`);
17920
- return response.bytes;
17924
+ const hash3 = createHash3("sha256"), file = await open2(body.to, "wx", 384);
17925
+ let bytes = 0;
17926
+ try {
17927
+ const response = await this.fetchBounded(this.filesPath(vm, body.remote_path, body.lease_id), { method: "GET" }, { ...options, timeoutMs: options.timeoutMs ?? PULL_IDLE_MS }, Number.MAX_SAFE_INTEGER, { idle: true, sink: async (chunk) => {
17928
+ hash3.update(chunk);
17929
+ bytes += chunk.byteLength;
17930
+ await file.write(chunk);
17931
+ } });
17932
+ if (response.contentType !== "application/octet-stream") throw new MachineServiceError(`machine-service ${response.path}: expected one file, got ${response.contentType ?? "no content type"}`);
17933
+ const digest = hash3.digest("hex");
17934
+ 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"}`);
17935
+ await file.sync();
17936
+ await file.close();
17937
+ return { sha256: digest, bytes };
17938
+ } catch (error2) {
17939
+ await file.close().catch(() => {
17940
+ });
17941
+ await rm(body.to, { force: true });
17942
+ throw error2;
17943
+ }
17921
17944
  }
17922
17945
  filesPath(vm, remote, lease_id) {
17923
17946
  const query = new URLSearchParams({ ...lease_id ? { lease_id } : {}, path: remote });
@@ -17942,14 +17965,20 @@ var MachineService = class {
17942
17965
  throw new MachineServiceError(`machine-service ${path}: invalid JSON response`, void 0, void 0, { cause });
17943
17966
  }
17944
17967
  }
17945
- /** One request whose answer is read up to `maxBytes`; an error answer is read up to 4 KiB and thrown with its status. */
17946
- async fetchBounded(path, init, options, maxBytes) {
17968
+ /**
17969
+ * One request whose answer is read up to `maxBytes`; an error answer is read
17970
+ * up to 4 KiB and thrown with its status. With `sink`, a successful answer is
17971
+ * handed over chunk by chunk instead of kept; with `idle`, the timeout counts
17972
+ * from the last chunk rather than from the start.
17973
+ */
17974
+ async fetchBounded(path, init, options, maxBytes, stream = {}) {
17947
17975
  options.signal?.throwIfAborted();
17948
17976
  const timeoutMs2 = positive(options.timeoutMs ?? this.timeoutMs, "timeoutMs");
17949
17977
  const controller = new AbortController();
17950
17978
  const abort = () => controller.abort(options.signal?.reason);
17951
17979
  options.signal?.addEventListener("abort", abort, { once: true });
17952
- const timer = setTimeout(() => controller.abort(new MachineServiceError(`machine-service ${path} timed out after ${timeoutMs2}ms`)), timeoutMs2);
17980
+ const expire = () => controller.abort(new MachineServiceError(`machine-service ${path} timed out after ${timeoutMs2}ms${stream.idle ? " without a byte" : ""}`));
17981
+ let timer = setTimeout(expire, timeoutMs2);
17953
17982
  try {
17954
17983
  const response = await fetch(`${this.baseUrl}${path}`, {
17955
17984
  method: init.method,
@@ -17969,6 +17998,15 @@ var MachineService = class {
17969
17998
  for (; ; ) {
17970
17999
  const { value, done } = await reader.read();
17971
18000
  if (done) break;
18001
+ if (stream.idle) {
18002
+ clearTimeout(timer);
18003
+ timer = setTimeout(expire, timeoutMs2);
18004
+ }
18005
+ if (response.ok && stream.sink) {
18006
+ size += value.byteLength;
18007
+ await stream.sink(value);
18008
+ continue;
18009
+ }
17972
18010
  const remaining = bound - size;
17973
18011
  chunks.push(value.subarray(0, remaining));
17974
18012
  size += Math.min(value.byteLength, remaining);
@@ -17989,7 +18027,7 @@ var MachineService = class {
17989
18027
  } catch (cause) {
17990
18028
  if (controller.signal.aborted) throw controller.signal.reason;
17991
18029
  if (cause instanceof MachineServiceError) throw cause;
17992
- throw new MachineServiceError(`machine-service ${path}: request failed`, void 0, void 0, { cause });
18030
+ throw new MachineServiceError(`machine-service ${path}: request failed${cause instanceof Error ? `: ${cause.message}` : ""}`, void 0, void 0, { cause });
17993
18031
  } finally {
17994
18032
  clearTimeout(timer);
17995
18033
  options.signal?.removeEventListener("abort", abort);
@@ -18002,7 +18040,7 @@ import { homedir as homedir4 } from "node:os";
18002
18040
 
18003
18041
  // src/registry.ts
18004
18042
  import { randomUUID } from "node:crypto";
18005
- import { link, lstat, mkdir as mkdir2, open as open2, readFile as readFile3, realpath, rename as rename2, unlink } from "node:fs/promises";
18043
+ import { link, lstat, mkdir as mkdir2, open as open3, readFile as readFile3, realpath, rename as rename2, unlink } from "node:fs/promises";
18006
18044
  import { readFileSync as readFileSync2, statSync as statSync2 } from "node:fs";
18007
18045
  import { homedir as homedir3 } from "node:os";
18008
18046
  import { spawn as spawn2 } from "node:child_process";
@@ -18184,7 +18222,7 @@ var Registry = class {
18184
18222
  const updated = transform2(original);
18185
18223
  if (original === updated) return false;
18186
18224
  temporary = join5(dirname3(target), `.${target.split("/").at(-1)}.${token2}.tmp`);
18187
- const handle = await open2(temporary, "wx", before.mode & 511);
18225
+ const handle = await open3(temporary, "wx", before.mode & 511);
18188
18226
  try {
18189
18227
  await handle.chmod(before.mode & 511);
18190
18228
  await handle.writeFile(updated, "utf8");
@@ -18200,7 +18238,7 @@ var Registry = class {
18200
18238
  lock.check();
18201
18239
  await rename2(temporary, target);
18202
18240
  temporary = void 0;
18203
- const dir = await open2(dirname3(target), "r");
18241
+ const dir = await open3(dirname3(target), "r");
18204
18242
  try {
18205
18243
  await dir.sync();
18206
18244
  } finally {
@@ -18227,7 +18265,7 @@ var Registry = class {
18227
18265
  if (!errno(error2, "ENOENT")) throw error2;
18228
18266
  }
18229
18267
  const temporary = join5(dirname3(target), `.registry.${randomUUID()}.tmp`);
18230
- const handle = await open2(temporary, "wx", 384);
18268
+ const handle = await open3(temporary, "wx", 384);
18231
18269
  try {
18232
18270
  try {
18233
18271
  await handle.chmod(384);
@@ -18242,7 +18280,7 @@ var Registry = class {
18242
18280
  } catch (error2) {
18243
18281
  if (!errno(error2, "EEXIST")) throw error2;
18244
18282
  }
18245
- const dir = await open2(dirname3(target), "r");
18283
+ const dir = await open3(dirname3(target), "r");
18246
18284
  try {
18247
18285
  await dir.sync();
18248
18286
  } finally {
@@ -18317,7 +18355,7 @@ var Registry = class {
18317
18355
  };
18318
18356
 
18319
18357
  // src/transfer.ts
18320
- import { copyFile, mkdir as mkdir5, readFile as readFile5, lstat as lstat3, mkdtemp, rm, open as open5, link as link2 } from "node:fs/promises";
18358
+ import { copyFile, mkdir as mkdir5, readFile as readFile5, lstat as lstat3, mkdtemp, rm as rm2, open as open6, link as link2 } from "node:fs/promises";
18321
18359
  import { constants as constants3, linkSync } from "node:fs";
18322
18360
  import { dirname as dirname6, join as join7, resolve as resolve5, relative as relative4, isAbsolute as isAbsolute4 } from "node:path";
18323
18361
  import { tmpdir } from "node:os";
@@ -18326,11 +18364,11 @@ import { randomUUID as randomUUID3 } from "node:crypto";
18326
18364
  // src/util.ts
18327
18365
  import { spawn as spawn3 } from "node:child_process";
18328
18366
  import { createHash as createHash4, randomUUID as randomUUID2 } from "node:crypto";
18329
- import { mkdir as mkdir3, rename as rename3, lstat as lstat2, readdir as readdir2, open as open3 } from "node:fs/promises";
18367
+ import { mkdir as mkdir3, rename as rename3, lstat as lstat2, readdir as readdir2, open as open4 } from "node:fs/promises";
18330
18368
  import { dirname as dirname4, join as join6, resolve as resolve4, relative as relative3, isAbsolute as isAbsolute3 } from "node:path";
18331
18369
  var hash = (bytes) => createHash4("sha256").update(bytes).digest("hex");
18332
18370
  async function hashFile(path) {
18333
- const file = await open3(path, "r");
18371
+ const file = await open4(path, "r");
18334
18372
  try {
18335
18373
  const digest = createHash4("sha256"), chunk = Buffer.alloc(8 * 1024 * 1024);
18336
18374
  let bytes = 0;
@@ -18348,7 +18386,7 @@ async function hashFile(path) {
18348
18386
  async function jsonFile(path, value) {
18349
18387
  await mkdir3(dirname4(path), { recursive: true, mode: 448 });
18350
18388
  const tmp = `${path}.${randomUUID2()}.tmp`;
18351
- const file = await open3(tmp, "wx", 384);
18389
+ const file = await open4(tmp, "wx", 384);
18352
18390
  try {
18353
18391
  await file.writeFile(JSON.stringify(value, null, 2) + "\n");
18354
18392
  await file.sync();
@@ -18356,7 +18394,7 @@ async function jsonFile(path, value) {
18356
18394
  await file.close();
18357
18395
  }
18358
18396
  await rename3(tmp, path);
18359
- const directory2 = await open3(dirname4(path), "r");
18397
+ const directory2 = await open4(dirname4(path), "r");
18360
18398
  try {
18361
18399
  await directory2.sync();
18362
18400
  } finally {
@@ -18420,7 +18458,7 @@ async function command(argv, options = {}) {
18420
18458
  }
18421
18459
 
18422
18460
  // src/archive.ts
18423
- import { open as open4, mkdir as mkdir4 } from "node:fs/promises";
18461
+ import { open as open5, mkdir as mkdir4 } from "node:fs/promises";
18424
18462
  import { constants as constants2 } from "node:fs";
18425
18463
  import { createHash as createHash5 } from "node:crypto";
18426
18464
  import { dirname as dirname5 } from "node:path";
@@ -18449,7 +18487,7 @@ function archiveChunks(files, maxArgvBytes = 64 * 1024) {
18449
18487
  return chunks;
18450
18488
  }
18451
18489
  async function unpackArchive(archive, directory2, requested, options = {}) {
18452
- const input = await open4(archive, constants2.O_RDONLY | constants2.O_NOFOLLOW);
18490
+ const input = await open5(archive, constants2.O_RDONLY | constants2.O_NOFOLLOW);
18453
18491
  const unpacked = [];
18454
18492
  try {
18455
18493
  const buffer = Buffer.alloc(8 * 1024 * 1024);
@@ -18495,7 +18533,7 @@ async function unpackArchive(archive, directory2, requested, options = {}) {
18495
18533
  const bytes = head.bytes;
18496
18534
  const target = within(directory2, fact.path);
18497
18535
  await mkdir4(dirname5(target), { recursive: true, mode: 448 });
18498
- const output = await open4(target, constants2.O_WRONLY | constants2.O_CREAT | constants2.O_EXCL | constants2.O_NOFOLLOW, 384);
18536
+ const output = await open5(target, constants2.O_WRONLY | constants2.O_CREAT | constants2.O_EXCL | constants2.O_NOFOLLOW, 384);
18499
18537
  const digest = createHash5("sha256");
18500
18538
  try {
18501
18539
  for (let left = bytes; left > 0; ) {
@@ -18817,7 +18855,7 @@ var Transfer = class {
18817
18855
  const info = await lstat3(path);
18818
18856
  if (!info.isFile()) throw new ImageTransferError("unsafe-path", "Expected a regular local image");
18819
18857
  if (info.size !== identity.bytes) throw new ImageTransferError("integrity-failed", "Local image size conflicts with original");
18820
- const fd = await open5(path, constants3.O_RDONLY | constants3.O_NOFOLLOW | constants3.O_NONBLOCK);
18858
+ const fd = await open6(path, constants3.O_RDONLY | constants3.O_NOFOLLOW | constants3.O_NONBLOCK);
18821
18859
  try {
18822
18860
  const same = (s) => s.isFile() && s.dev === info.dev && s.ino === info.ino && s.size === info.size && s.mtimeMs === info.mtimeMs && s.ctimeMs === info.ctimeMs;
18823
18861
  if (!same(await fd.stat())) throw new ImageTransferError("integrity-failed", "Local image changed before verification");
@@ -18897,7 +18935,7 @@ var Transfer = class {
18897
18935
  const clean = async () => {
18898
18936
  try {
18899
18937
  await assertHostPath(approvedLocalRoot, staging);
18900
- await rm(staging, { recursive: true, force: true });
18938
+ await rm2(staging, { recursive: true, force: true });
18901
18939
  } catch {
18902
18940
  }
18903
18941
  };
@@ -18995,7 +19033,7 @@ var Transfer = class {
18995
19033
  await this.checked([this.node, "-e", REMOVE_FRAME, guestRoot, frame]);
18996
19034
  } finally {
18997
19035
  await assertHostPath(tempRoot, hostDirectory);
18998
- await rm(hostDirectory, { recursive: true, force: true });
19036
+ await rm2(hostDirectory, { recursive: true, force: true });
18999
19037
  }
19000
19038
  }
19001
19039
  }
@@ -19020,7 +19058,7 @@ var Transfer = class {
19020
19058
  }
19021
19059
  if (written) {
19022
19060
  await assertHostPath(localRoot, path);
19023
- await rm(path, { force: true });
19061
+ await rm2(path, { force: true });
19024
19062
  }
19025
19063
  }
19026
19064
  return false;
@@ -19076,7 +19114,7 @@ var Transfer = class {
19076
19114
  await this.checked([this.node, "-e", REMOVE_FRAME, guestRoot, archive]);
19077
19115
  } finally {
19078
19116
  await assertHostPath(localRoot, staging);
19079
- await rm(staging, { recursive: true, force: true });
19117
+ await rm2(staging, { recursive: true, force: true });
19080
19118
  }
19081
19119
  }
19082
19120
  }
@@ -19229,7 +19267,7 @@ var VmTransport = class {
19229
19267
 
19230
19268
  // src/package.ts
19231
19269
  import { createHash as createHash6 } from "node:crypto";
19232
- import { lstat as lstat4, readFile as readFile6, readdir as readdir3, mkdir as mkdir6, writeFile as writeFile3, rm as rm2 } from "node:fs/promises";
19270
+ import { lstat as lstat4, readFile as readFile6, readdir as readdir3, mkdir as mkdir6, writeFile as writeFile3, rm as rm3 } from "node:fs/promises";
19233
19271
  import { dirname as dirname7, join as join9, resolve as resolve6, parse as parse4 } from "node:path";
19234
19272
  var generated = ["OPENING.txt", "manifest.json"];
19235
19273
  var hash2 = (bytes) => createHash6("sha256").update(bytes).digest("hex");
@@ -19624,7 +19662,7 @@ async function deliverPackage(rootDir, options) {
19624
19662
  })));
19625
19663
  return await verifyDeliveredPackage(root);
19626
19664
  } catch (error2) {
19627
- for (const path of created.reverse()) await rm2(join9(root, path), { force: true });
19665
+ for (const path of created.reverse()) await rm3(join9(root, path), { force: true });
19628
19666
  throw error2;
19629
19667
  }
19630
19668
  }
@@ -19701,7 +19739,7 @@ async function probeLocal(run = command, platform = process.platform) {
19701
19739
  // src/owner-lock.ts
19702
19740
  import { spawn as spawn4 } from "node:child_process";
19703
19741
  import { constants as constants4 } from "node:fs";
19704
- import { open as open6 } from "node:fs/promises";
19742
+ import { open as open7 } from "node:fs/promises";
19705
19743
  var OwnerLockError = class extends Error {
19706
19744
  constructor(message3, options) {
19707
19745
  super(message3, options);
@@ -19726,7 +19764,7 @@ async function acquireOwnerLock(path, options = {}) {
19726
19764
  const executable = options.pythonExecutable === void 0 ? pythonExecutable() : nonblank(options.pythonExecutable, "pythonExecutable");
19727
19765
  const signal = options.signal;
19728
19766
  signal?.throwIfAborted();
19729
- const file = await open6(path, constants4.O_RDWR | constants4.O_CREAT | constants4.O_NOFOLLOW, 384);
19767
+ const file = await open7(path, constants4.O_RDWR | constants4.O_CREAT | constants4.O_NOFOLLOW, 384);
19730
19768
  try {
19731
19769
  if (!(await file.stat()).isFile()) throw new OwnerLockError("Owner lock must be a regular file");
19732
19770
  signal?.throwIfAborted();
@@ -27628,7 +27666,7 @@ function acquisitionCapabilities(value) {
27628
27666
  }
27629
27667
 
27630
27668
  // src/images.ts
27631
- import { mkdir as mkdir8, lstat as lstat6, open as open7, readdir as readdir5, rm as rm3 } from "node:fs/promises";
27669
+ import { mkdir as mkdir8, lstat as lstat6, open as open8, readdir as readdir5, rm as rm4 } from "node:fs/promises";
27632
27670
  import { constants as constants5, linkSync as linkSync2 } from "node:fs";
27633
27671
  import { join as join11, dirname as dirname8, extname } from "node:path";
27634
27672
  import { randomUUID as randomUUID5 } from "node:crypto";
@@ -28139,7 +28177,7 @@ async function readBounded(root, path, limit, signal) {
28139
28177
  const before = await lstat6(path);
28140
28178
  if (!before.isFile()) fail("unsafe-path", "Image evidence must be a regular file.");
28141
28179
  if (before.size < 1 || before.size > limit) fail("integrity-failed", "Image evidence exceeds its size bound.");
28142
- const fd = await open7(path, constants5.O_RDONLY | constants5.O_NOFOLLOW | constants5.O_NONBLOCK);
28180
+ const fd = await open8(path, constants5.O_RDONLY | constants5.O_NOFOLLOW | constants5.O_NONBLOCK);
28143
28181
  try {
28144
28182
  const same = (s) => s.isFile() && s.dev === before.dev && s.ino === before.ino && s.size === before.size && s.mtimeMs === before.mtimeMs && s.ctimeMs === before.ctimeMs;
28145
28183
  if (!same(await fd.stat())) fail("integrity-failed", "Image evidence changed before reading.");
@@ -28185,7 +28223,7 @@ async function publish(root, path, bytes, signal) {
28185
28223
  await hostPath(root, path, true);
28186
28224
  guard(signal);
28187
28225
  const temporary = join11(dirname8(path), `.image-${randomUUID5()}.tmp`);
28188
- const fd = await open7(temporary, "wx", 384);
28226
+ const fd = await open8(temporary, "wx", 384);
28189
28227
  try {
28190
28228
  try {
28191
28229
  await fd.writeFile(bytes);
@@ -28204,9 +28242,9 @@ async function publish(root, path, bytes, signal) {
28204
28242
  }
28205
28243
  } finally {
28206
28244
  await hostPath(root, temporary, true);
28207
- await rm3(temporary, { force: true });
28245
+ await rm4(temporary, { force: true });
28208
28246
  }
28209
- const directory2 = await open7(dirname8(path), "r");
28247
+ const directory2 = await open8(dirname8(path), "r");
28210
28248
  try {
28211
28249
  await directory2.sync();
28212
28250
  } finally {
@@ -28359,7 +28397,7 @@ var ImageStore = class {
28359
28397
  const request = await optional2(() => readMetadata(recording.path, join11(recording.path, "host", "requests", `${target.executionId}.json`), options.signal));
28360
28398
  if (!request) fail("unauthorized-reference", "Execution does not belong to this enclosure.");
28361
28399
  if (request.sessionId !== target.sessionId || request.executionId !== target.executionId) fail("integrity-failed", "Execution identity does not match its recording.");
28362
- if (request.capture === false) return { status: "not-requested", diagnostic: "The image lists no capture software (cua-driver), so this run took no snapshots." };
28400
+ if (request.capture === false) return { status: "not-requested", diagnostic: "This lease's runs take no snapshots: its image lists no capture software (cua-driver), or its durable machine's cua-driver daemon cannot record the screen, as relay_stage's `snapshots.reason` says; so this run took none." };
28363
28401
  const group = request.snapshots?.group;
28364
28402
  const requested = !request.diagnostic && (target.phase === "before" ? !group || group.phase === "first" : !group || group.phase === "last");
28365
28403
  if (!requested) return { status: "not-requested", diagnostic: "The declared snapshot plan does not capture this phase." };
@@ -28868,7 +28906,6 @@ var MIN_RENEWAL_MS = 0.1 * 36e5;
28868
28906
  var DEFAULT_AFTER_INTERVAL_MS = 500;
28869
28907
  var CAPTURE_SOFTWARE = ["bundle:com.trycua.driver", "dpkg:cua-driver"];
28870
28908
  var durableRoot = (workspace, purpose) => join13(workspace, "work", `mcp-relay-${purpose}`);
28871
- var PULL_MAX_BYTES = 2 * 1024 * 1024 * 1024 - 1;
28872
28909
  var DOWNLOAD_BOUND = 64;
28873
28910
  var DOWNLOAD_RETRY_DELAYS_MS = [1e3, 3e3];
28874
28911
  var CAPACITY_RETRY_MS = 15e3;
@@ -29404,9 +29441,8 @@ var Guest = class {
29404
29441
  pull: async (name, remote_path, local_path, options) => {
29405
29442
  if (!durable) return this.vm.pull(name, { remote_path, local_path, ...identity() }, options);
29406
29443
  if (!this.vm.pullBytes) throw new Error("Backend lacks byte transfers; upgrade machine-service");
29407
- const bytes = await this.vm.pullBytes(name, { remote_path, maxBytes: PULL_MAX_BYTES, ...identity() }, options);
29408
- await rm4(local_path, { force: true });
29409
- await writeFile4(local_path, bytes, { flag: "wx", mode: 384 });
29444
+ await rm5(local_path, { force: true });
29445
+ await this.vm.pullBytes(name, { remote_path, to: local_path, ...identity() }, options);
29410
29446
  return { vm: name, pulled: remote_path, to: local_path };
29411
29447
  }
29412
29448
  };
@@ -30164,7 +30200,7 @@ VM state: ${JSON.stringify(this.status())}`, { cause: error2 });
30164
30200
  for (let attempt = 1; !files; attempt++) {
30165
30201
  try {
30166
30202
  await assertHostPath(e.hostRoot, folder, true);
30167
- await rm4(folder, { recursive: true, force: true });
30203
+ await rm5(folder, { recursive: true, force: true });
30168
30204
  files = await this.transfer().pullArchive(e.guestRoot, e.guestRoot, requested, folder, e.hostRoot, { present: true, once: true, signal: bounded3 });
30169
30205
  } catch (error2) {
30170
30206
  const transient2 = !bounded3.aborted && transientTransfer(error2);
@@ -30226,7 +30262,7 @@ VM state: ${JSON.stringify(this.status())}`, { cause: error2 });
30226
30262
  async removeStepFolders(recording) {
30227
30263
  const steps = join13(recording, "host", "steps");
30228
30264
  await assertHostPath(recording, steps, true);
30229
- await rm4(steps, { recursive: true, force: true });
30265
+ await rm5(steps, { recursive: true, force: true });
30230
30266
  }
30231
30267
  /** A lifecycle operation's gate (AD-5): every download ends before the guest state is touched; the queue opens again after. */
30232
30268
  async drained(fn) {
@@ -30671,7 +30707,7 @@ function validateRelayInput(value) {
30671
30707
  }
30672
30708
 
30673
30709
  // src/surface.ts
30674
- import { mkdir as mkdir11, writeFile as writeFile5 } from "node:fs/promises";
30710
+ import { mkdir as mkdir11, writeFile as writeFile4 } from "node:fs/promises";
30675
30711
  import { join as join14 } from "node:path";
30676
30712
  import { tmpdir as tmpdir2 } from "node:os";
30677
30713
  import { randomUUID as randomUUID7 } from "node:crypto";
@@ -30785,7 +30821,7 @@ async function renderRelayResult(value, resultRoot = join14(tmpdir2(), "mcp-rela
30785
30821
  if (text5 !== full) {
30786
30822
  await mkdir11(resultRoot, { recursive: true, mode: 448 });
30787
30823
  const path = join14(resultRoot, `${randomUUID7()}.json`);
30788
- await writeFile5(path, full, { mode: 384 });
30824
+ await writeFile4(path, full, { mode: 384 });
30789
30825
  return { text: `${text5}
30790
30826
  [Truncated. Full result: ${path}]`, details: { resultPath: path }, resultPath: path };
30791
30827
  }
@@ -30866,7 +30902,7 @@ async function relayCall(host, raw, options = {}) {
30866
30902
 
30867
30903
  // src/server.ts
30868
30904
  var SERVER_NAME = "relay";
30869
- var SERVER_VERSION = true ? "0.17.0" : JSON.parse(readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf8")).version;
30905
+ var SERVER_VERSION = true ? "0.17.1" : JSON.parse(readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf8")).version;
30870
30906
  var STATUS_TOOL = "relay_status";
30871
30907
  var PLUGIN_TOOL_PREFIX = "mcp__plugin_mcp-relay_relay__";
30872
30908
  var message2 = (error2) => error2 instanceof Error ? error2.message : String(error2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wezzard/mcp-relay",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "type": "module",
5
5
  "description": "MCP server and Claude Code plugin. Runs an agent's code on fresh, isolated VMs, several at once, each run recorded with evidence",
6
6
  "license": "MIT",
package/pi-mcp.json CHANGED
@@ -1 +1 @@
1
- {"mcpServers":{"relay":{"command":"npx","args":["-y","@wezzard/mcp-relay@0.17.0"],"lifecycle":"lazy-keep-alive","requestTimeoutMs":3900000,"directTools":true,"toolPrefix":"none"}}}
1
+ {"mcpServers":{"relay":{"command":"npx","args":["-y","@wezzard/mcp-relay@0.17.1"],"lifecycle":"lazy-keep-alive","requestTimeoutMs":3900000,"directTools":true,"toolPrefix":"none"}}}