@wezzard/mcp-relay 0.14.1 → 0.15.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/dist/server.mjs CHANGED
@@ -6,11 +6,20 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __esm = (fn, res) => function __init() {
10
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
+ var __esm = (fn, res, err) => function __init() {
10
+ if (err) throw err[0];
11
+ try {
12
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
13
+ } catch (e) {
14
+ throw err = [e], e;
15
+ }
11
16
  };
12
17
  var __commonJS = (cb, mod) => function __require() {
13
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18
+ try {
19
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
20
+ } catch (e) {
21
+ throw mod = 0, e;
22
+ }
14
23
  };
15
24
  var __export = (target, all) => {
16
25
  for (var name in all)
@@ -472,7 +481,7 @@ var require_codegen = __commonJS({
472
481
  return `break${label};` + _n;
473
482
  }
474
483
  };
475
- var Throw = class extends Node {
484
+ var Throw2 = class extends Node {
476
485
  constructor(error2) {
477
486
  super();
478
487
  this.error = error2;
@@ -917,7 +926,7 @@ var require_codegen = __commonJS({
917
926
  }
918
927
  // `throw` statement
919
928
  throw(error2) {
920
- return this._leafNode(new Throw(error2));
929
+ return this._leafNode(new Throw2(error2));
921
930
  }
922
931
  // start self-balancing block
923
932
  block(body, nodeCount) {
@@ -8361,8 +8370,8 @@ function $constructor(name, initializer3, proto, params) {
8361
8370
  }
8362
8371
  }
8363
8372
  }
8364
- const Parent = params?.Parent ?? Object;
8365
- class Definition extends Parent {
8373
+ const Parent2 = params?.Parent ?? Object;
8374
+ class Definition extends Parent2 {
8366
8375
  }
8367
8376
  Object.defineProperty(Definition, "name", { value: name });
8368
8377
  function _(def) {
@@ -12716,7 +12725,7 @@ var nonoptionalProcessor = (schema, ctx, _json, params) => {
12716
12725
  const seen = ctx.seen.get(schema);
12717
12726
  seen.ref = def.innerType;
12718
12727
  };
12719
- var UNREPRESENTABLE_DEFAULT = Symbol();
12728
+ var UNREPRESENTABLE_DEFAULT = /* @__PURE__ */ Symbol();
12720
12729
  function serializeDefaultValue(value, schema, ctx, json2, params) {
12721
12730
  let unrepresentable = false;
12722
12731
  const serialized = JSON.stringify(value, (_, val) => {
@@ -15401,9 +15410,6 @@ function isTerminal(status) {
15401
15410
  return status === "completed" || status === "failed" || status === "cancelled";
15402
15411
  }
15403
15412
 
15404
- // node_modules/zod-to-json-schema/dist/esm/Options.js
15405
- var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
15406
-
15407
15413
  // node_modules/zod-to-json-schema/dist/esm/parsers/string.js
15408
15414
  var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
15409
15415
 
@@ -17566,12 +17572,12 @@ var Session = class {
17566
17572
  * persisted before transmission; a transport loss leaves the submission
17567
17573
  * inspectable as uncertain, never replayed.
17568
17574
  */
17569
- async exec(argv2, options = {}) {
17575
+ async exec(argv, options = {}) {
17570
17576
  const executionId = formatId(allocateId("execution"));
17571
17577
  const submission = {
17572
17578
  executionId,
17573
17579
  sessionId: this.sessionId,
17574
- argv: argv2,
17580
+ argv,
17575
17581
  submittedAt: (/* @__PURE__ */ new Date()).toISOString(),
17576
17582
  state: "pending"
17577
17583
  };
@@ -17581,7 +17587,7 @@ var Session = class {
17581
17587
  attemptId: "attempt-1",
17582
17588
  kind: "exec",
17583
17589
  executionId,
17584
- argv: argv2,
17590
+ argv,
17585
17591
  cwd: options.cwd,
17586
17592
  step: options.step,
17587
17593
  snapshots: options.snapshots
@@ -17607,11 +17613,11 @@ var Session = class {
17607
17613
  const upload = await this.transport.upload(localPath, { remotePath });
17608
17614
  const executionId = formatId(allocateId("execution"));
17609
17615
  const interpreter = language2 === "python" ? "python3" : language2 === "typescript" ? "tsx" : "node";
17610
- const argv2 = [interpreter, ...options.interpreterArgs ?? [], remotePath];
17616
+ const argv = [interpreter, ...options.interpreterArgs ?? [], remotePath];
17611
17617
  const submission = {
17612
17618
  executionId,
17613
17619
  sessionId: this.sessionId,
17614
- argv: argv2,
17620
+ argv,
17615
17621
  submittedAt: (/* @__PURE__ */ new Date()).toISOString(),
17616
17622
  state: "pending",
17617
17623
  script: {
@@ -17629,7 +17635,7 @@ var Session = class {
17629
17635
  executionId,
17630
17636
  remotePath,
17631
17637
  language: language2,
17632
- argv: argv2,
17638
+ argv,
17633
17639
  cwd: options.cwd,
17634
17640
  step: options.step,
17635
17641
  snapshots: options.snapshots,
@@ -17747,6 +17753,8 @@ var VmServiceError = class extends Error {
17747
17753
  this.responseBody = responseBody;
17748
17754
  this.name = "VmServiceError";
17749
17755
  }
17756
+ status;
17757
+ responseBody;
17750
17758
  /** The host is at capacity, such as its limit on running macOS VMs: nothing was reserved, and the same acquisition may be asked again (DC-22). */
17751
17759
  capacity = false;
17752
17760
  };
@@ -17768,6 +17776,7 @@ var AcquireIndeterminateError = class extends VmServiceError {
17768
17776
  this.purpose = purpose;
17769
17777
  this.name = "AcquireIndeterminateError";
17770
17778
  }
17779
+ purpose;
17771
17780
  };
17772
17781
  function positive(value, label) {
17773
17782
  if (!Number.isSafeInteger(value) || value <= 0 || value > 2147483647) throw new TypeError(`${label} must be a positive bounded integer`);
@@ -18322,20 +18331,20 @@ async function inventory(root) {
18322
18331
  await walk(root);
18323
18332
  return result2;
18324
18333
  }
18325
- async function command(argv2, options = {}) {
18334
+ async function command(argv, options = {}) {
18326
18335
  options.signal?.throwIfAborted();
18327
18336
  return new Promise((resolve11, reject) => {
18328
- const child = spawn3(argv2[0], argv2.slice(1), { cwd: options.cwd, env: options.env, stdio: ["ignore", "pipe", "pipe"], signal: options.signal });
18337
+ const child = spawn3(argv[0], argv.slice(1), { cwd: options.cwd, env: options.env, stdio: ["ignore", "pipe", "pipe"], signal: options.signal });
18329
18338
  let stdout = "", stderr = "", size = 0;
18330
18339
  let failure2;
18331
18340
  const timer = setTimeout(() => {
18332
- failure2 = new Error(`Command timed out: ${argv2[0]}`);
18341
+ failure2 = new Error(`Command timed out: ${argv[0]}`);
18333
18342
  child.kill("SIGKILL");
18334
18343
  }, options.timeoutMs ?? 1e4);
18335
18344
  const consume = (channel, chunk) => {
18336
18345
  size += chunk.length;
18337
18346
  if (size > (options.maxBytes ?? 128 * 1024)) {
18338
- failure2 = new Error(`Command output exceeded limit: ${argv2[0]}`);
18347
+ failure2 = new Error(`Command output exceeded limit: ${argv[0]}`);
18339
18348
  child.kill("SIGKILL");
18340
18349
  return;
18341
18350
  }
@@ -18473,6 +18482,7 @@ var ImageTransferError = class extends Error {
18473
18482
  this.code = code;
18474
18483
  this.name = "ImageTransferError";
18475
18484
  }
18485
+ code;
18476
18486
  };
18477
18487
  function imagePath(root, target) {
18478
18488
  for (const path of [root, target]) {
@@ -18564,6 +18574,10 @@ var Transfer = class {
18564
18574
  this.node = node2;
18565
18575
  this.options = options;
18566
18576
  }
18577
+ vm;
18578
+ name;
18579
+ node;
18580
+ options;
18567
18581
  async copy(operation, transfer, validate2) {
18568
18582
  for (let attempt = 1; ; attempt++) {
18569
18583
  await validate2();
@@ -18582,8 +18596,8 @@ var Transfer = class {
18582
18596
  }
18583
18597
  }
18584
18598
  }
18585
- async checked(argv2, timeoutMs2, signal) {
18586
- const framed = argv2[0] === this.node && argv2[1] === "-e" ? [argv2[0], argv2[1], `try { ${argv2[2]} } catch(error) { console.error(error instanceof Error ? error.message : String(error)); process.exitCode=1; }`, ...argv2.slice(3)] : argv2;
18599
+ async checked(argv, timeoutMs2, signal) {
18600
+ const framed = argv[0] === this.node && argv[1] === "-e" ? [argv[0], argv[1], `try { ${argv[2]} } catch(error) { console.error(error instanceof Error ? error.message : String(error)); process.exitCode=1; }`, ...argv.slice(3)] : argv;
18587
18601
  for (let attempt = 1; ; attempt++) {
18588
18602
  const result2 = await (signal ? this.vm.exec(this.name, framed, timeoutMs2, { signal, ...timeoutMs2 ? { timeoutMs: timeoutMs2 } : {} }) : this.vm.exec(this.name, framed, timeoutMs2));
18589
18603
  if (result2.code === 0) return result2.stdout;
@@ -18974,8 +18988,8 @@ var Transfer = class {
18974
18988
  await assertHostPath(localRoot, local);
18975
18989
  const staging = await mkdtemp(join7(local, ".relay-archive-"));
18976
18990
  try {
18977
- const argv2 = [this.node, "-e", ARCHIVE, remote, approvedRoot, archive, guestRoot, options.present ? "present" : "all", ...chunk.map((file) => file.path)];
18978
- const fact = JSON.parse(await this.checked(argv2, scanTimeoutMs(2 * (bytes ?? 0)), options.signal));
18991
+ const argv = [this.node, "-e", ARCHIVE, remote, approvedRoot, archive, guestRoot, options.present ? "present" : "all", ...chunk.map((file) => file.path)];
18992
+ const fact = JSON.parse(await this.checked(argv, scanTimeoutMs(2 * (bytes ?? 0)), options.signal));
18979
18993
  const size = fact?.bytes;
18980
18994
  if (fact?.path !== archive || !Number.isSafeInteger(size) || bytes !== void 0 && size !== bytes) throw new Error("Invalid remote archive fact");
18981
18995
  const staged = join7(staging, "archive");
@@ -19095,6 +19109,10 @@ var VmTransport = class {
19095
19109
  this.hostRoot = hostRoot;
19096
19110
  this.cuaDriver = cuaDriver;
19097
19111
  }
19112
+ transfer;
19113
+ guestRoot;
19114
+ hostRoot;
19115
+ cuaDriver;
19098
19116
  because = "";
19099
19117
  timeoutMs = 12e4;
19100
19118
  diagnostic = false;
@@ -19107,7 +19125,8 @@ var VmTransport = class {
19107
19125
  if (!this.because.trim()) throw new Error("Run execution intent is required");
19108
19126
  if (!/^[A-Za-z0-9][A-Za-z0-9_.-]{0,159}$/.test(request.executionId)) throw new Error("Invalid execution identity");
19109
19127
  this.response = void 0;
19110
- const payload = { ...request, because: this.because, timeoutMs: this.timeoutMs, ...this.diagnostic ? { diagnostic: true } : {}, ...this.capture ? {} : { capture: false } };
19128
+ const { kind: _kind, argv: _argv, ...framed } = request;
19129
+ const payload = { ...framed, because: this.because, timeoutMs: this.timeoutMs, ...this.diagnostic ? { diagnostic: true } : {}, ...this.capture ? {} : { capture: false } };
19111
19130
  const local = join8(this.hostRoot, "requests", `${request.executionId}.json`);
19112
19131
  const remote = join8(this.guestRoot, "requests", `${request.executionId}.json`);
19113
19132
  await assertHostPath(this.hostRoot, local, true);
@@ -19403,12 +19422,12 @@ async function analyze(root, options, files) {
19403
19422
  const actionReceipts = receipts.filter((r) => (r.actionId === id2 || executionId && r.executionId === executionId) && (r.actionId === void 0 || r.actionId === id2) && (r.executionId === void 0 || executionId === void 0 || r.executionId === executionId));
19404
19423
  execution2 = reconcileOutcome(execution2, actionReceipts);
19405
19424
  const completion = completions.get(id2);
19406
- const argv2 = events.find((e) => e.kind === "execution-start" && executionId && e.executionId === executionId && Array.isArray(e.argv))?.argv;
19425
+ const argv = events.find((e) => e.kind === "execution-start" && executionId && e.executionId === executionId && Array.isArray(e.argv))?.argv;
19407
19426
  details.set(stepId2, {
19408
19427
  at: source.writtenAt ?? before?.capturedAt,
19409
19428
  beforeAt: before?.capturedAt,
19410
19429
  afterAt: after?.capturedAt,
19411
- ...argv2?.every((w) => typeof w === "string") ? { argv: argv2 } : {},
19430
+ ...argv?.every((w) => typeof w === "string") ? { argv } : {},
19412
19431
  output: commandOutput(actionReceipts.find((r) => commandOutput(r)) ?? completion?.toolOutcome?.value)
19413
19432
  });
19414
19433
  const originalObserved = refusal?.diagnostic ?? completion?.diagnostic ?? (completion?.toolOutcome ? JSON.stringify(completion.toolOutcome) : void 0);
@@ -19591,13 +19610,13 @@ async function verifyDeliveredPackage(rootDir) {
19591
19610
 
19592
19611
  // src/probe.ts
19593
19612
  async function probeLocal(run = command, platform = process.platform) {
19594
- async function observe(argv2, parse7) {
19613
+ async function observe(argv, parse7) {
19595
19614
  try {
19596
- const result2 = await run(argv2);
19615
+ const result2 = await run(argv);
19597
19616
  if (result2.code) throw new Error(result2.stderr || `exit ${result2.code}`);
19598
- return { value: parse7(result2.stdout), source: argv2.join(" ") };
19617
+ return { value: parse7(result2.stdout), source: argv.join(" ") };
19599
19618
  } catch (error2) {
19600
- return { value: null, source: argv2.join(" "), diagnostic: String(error2) };
19619
+ return { value: null, source: argv.join(" "), diagnostic: String(error2) };
19601
19620
  }
19602
19621
  }
19603
19622
  const permissions = await observe(["cua-driver", "permissions", "status", "--json"], JSON.parse);
@@ -19755,6 +19774,7 @@ __export(settings_exports, {
19755
19774
  // node_modules/typebox/build/guard/guard.mjs
19756
19775
  var guard_exports = {};
19757
19776
  __export(guard_exports, {
19777
+ CodePointCount: () => CodePointCount2,
19758
19778
  Counted: () => Counted,
19759
19779
  Entries: () => Entries,
19760
19780
  EntriesRegExp: () => EntriesRegExp,
@@ -19795,16 +19815,13 @@ __export(guard_exports, {
19795
19815
  Values: () => Values
19796
19816
  });
19797
19817
 
19798
- // node_modules/typebox/build/guard/string.mjs
19818
+ // node_modules/typebox/build/guard/unicode/unicode_segment.mjs
19799
19819
  function IsBetween(value, min, max) {
19800
19820
  return value >= min && value <= max;
19801
19821
  }
19802
19822
  function IsZeroWidthJoiner(value) {
19803
19823
  return value === 8205;
19804
19824
  }
19805
- function IsHighSurrogate(value) {
19806
- return IsBetween(value, 55296, 56319);
19807
- }
19808
19825
  function IsRegionalIndicator(value) {
19809
19826
  return IsBetween(value, 127462, 127487);
19810
19827
  }
@@ -19842,64 +19859,30 @@ function NextGraphemeClusterIndex(value, clusterStart) {
19842
19859
  }
19843
19860
  return clusterEnd;
19844
19861
  }
19845
- function IsGraphemeCodePoint(value) {
19846
- return value >= 768 && // above special range
19847
- (IsHighSurrogate(value) || IsCombiningMark(value) || IsVariationSelector(value) || IsZeroWidthJoiner(value));
19848
- }
19849
19862
  function GraphemeCount(value) {
19850
- let count = 0;
19851
- let index = 0;
19863
+ let count = 0, index = 0;
19852
19864
  while (index < value.length) {
19853
19865
  index = NextGraphemeClusterIndex(value, index);
19854
19866
  count++;
19855
19867
  }
19856
19868
  return count;
19857
19869
  }
19858
- function IsMinLengthSegmented(value, minLength) {
19859
- let count = 0;
19860
- let index = 0;
19870
+
19871
+ // node_modules/typebox/build/guard/unicode/unicode.mjs
19872
+ function CodePointCount(value) {
19873
+ let result2 = 0, index = 0, prev = 0;
19861
19874
  while (index < value.length) {
19862
- index = NextGraphemeClusterIndex(value, index);
19863
- if (++count >= minLength)
19864
- return true;
19875
+ const next = value.charCodeAt(index++) >> 10;
19876
+ result2 += +((prev << 8 | next) !== 13879);
19877
+ prev = next;
19865
19878
  }
19866
- return false;
19879
+ return result2;
19867
19880
  }
19868
- function IsMaxLengthSegmented(value, maxLength) {
19869
- let count = 0;
19870
- let index = 0;
19871
- while (index < value.length) {
19872
- index = NextGraphemeClusterIndex(value, index);
19873
- if (++count > maxLength)
19874
- return false;
19875
- }
19876
- return true;
19881
+ function IsMaxLength(value, maxLength) {
19882
+ return value.length <= maxLength || value.length <= maxLength << 1 && CodePointCount(value) <= maxLength;
19877
19883
  }
19878
19884
  function IsMinLength(value, minLength) {
19879
- if (minLength === 0)
19880
- return true;
19881
- if (value.length < minLength)
19882
- return false;
19883
- let index = 0;
19884
- while (true) {
19885
- if (IsGraphemeCodePoint(value.charCodeAt(index))) {
19886
- return IsMinLengthSegmented(value, minLength);
19887
- }
19888
- if (++index >= minLength)
19889
- return true;
19890
- }
19891
- }
19892
- function IsMaxLength(value, maxLength) {
19893
- if (value.length <= maxLength)
19894
- return true;
19895
- let index = 0;
19896
- while (true) {
19897
- if (IsGraphemeCodePoint(value.charCodeAt(index))) {
19898
- return IsMaxLengthSegmented(value, maxLength);
19899
- }
19900
- if (++index > maxLength)
19901
- return false;
19902
- }
19885
+ return value.length >= minLength << 1 || value.length >= minLength && CodePointCount(value) >= minLength;
19903
19886
  }
19904
19887
 
19905
19888
  // node_modules/typebox/build/guard/guard.mjs
@@ -19990,11 +19973,14 @@ function IsValueLike(value) {
19990
19973
  function GraphemeCount2(value) {
19991
19974
  return GraphemeCount(value);
19992
19975
  }
19993
- function IsMaxLength2(value, length) {
19994
- return IsMaxLength(value, length);
19976
+ function CodePointCount2(value) {
19977
+ return CodePointCount(value);
19978
+ }
19979
+ function IsMaxLength2(value, maxLength) {
19980
+ return IsMaxLength(value, maxLength);
19995
19981
  }
19996
- function IsMinLength2(value, length) {
19997
- return IsMinLength(value, length);
19982
+ function IsMinLength2(value, minLength) {
19983
+ return IsMinLength(value, minLength);
19998
19984
  }
19999
19985
  function Every(value, offset, callback) {
20000
19986
  return value.every((item, index) => index < offset || callback(item, index));
@@ -20146,6 +20132,7 @@ var guard_default = guard_exports;
20146
20132
  var settings = {
20147
20133
  immutableTypes: false,
20148
20134
  maxErrors: 8,
20135
+ maxParseErrors: 1,
20149
20136
  maxInstantiationCount: 128,
20150
20137
  useAcceleration: true,
20151
20138
  exactOptionalPropertyTypes: false,
@@ -20156,6 +20143,7 @@ var settings = {
20156
20143
  function Reset() {
20157
20144
  settings.immutableTypes = false;
20158
20145
  settings.maxErrors = 8;
20146
+ settings.maxParseErrors = 1;
20159
20147
  settings.maxInstantiationCount = 128;
20160
20148
  settings.useAcceleration = true;
20161
20149
  settings.exactOptionalPropertyTypes = false;
@@ -20575,23 +20563,22 @@ function InstanceKeys(value) {
20575
20563
  function IsIEEE754(value) {
20576
20564
  return typeof value === "number";
20577
20565
  }
20578
- var ByteMarker;
20579
- (function(ByteMarker2) {
20580
- ByteMarker2[ByteMarker2["Array"] = 0] = "Array";
20581
- ByteMarker2[ByteMarker2["BigInt"] = 1] = "BigInt";
20582
- ByteMarker2[ByteMarker2["Boolean"] = 2] = "Boolean";
20583
- ByteMarker2[ByteMarker2["Date"] = 3] = "Date";
20584
- ByteMarker2[ByteMarker2["Constructor"] = 4] = "Constructor";
20585
- ByteMarker2[ByteMarker2["Function"] = 5] = "Function";
20586
- ByteMarker2[ByteMarker2["Null"] = 6] = "Null";
20587
- ByteMarker2[ByteMarker2["Number"] = 7] = "Number";
20588
- ByteMarker2[ByteMarker2["Object"] = 8] = "Object";
20589
- ByteMarker2[ByteMarker2["RegExp"] = 9] = "RegExp";
20590
- ByteMarker2[ByteMarker2["String"] = 10] = "String";
20591
- ByteMarker2[ByteMarker2["Symbol"] = 11] = "Symbol";
20592
- ByteMarker2[ByteMarker2["TypeArray"] = 12] = "TypeArray";
20593
- ByteMarker2[ByteMarker2["Undefined"] = 13] = "Undefined";
20594
- })(ByteMarker || (ByteMarker = {}));
20566
+ var ByteMarker = {
20567
+ Array: 0,
20568
+ BigInt: 1,
20569
+ Boolean: 2,
20570
+ Date: 3,
20571
+ Constructor: 4,
20572
+ Function: 5,
20573
+ Null: 6,
20574
+ Number: 7,
20575
+ Object: 8,
20576
+ RegExp: 9,
20577
+ String: 10,
20578
+ Symbol: 11,
20579
+ TypeArray: 12,
20580
+ Undefined: 13
20581
+ };
20595
20582
  var Accumulator = BigInt("14695981039346656037");
20596
20583
  var [Prime, Size] = [BigInt("1099511628211"), BigInt(
20597
20584
  "18446744073709551616"
@@ -20758,7 +20745,7 @@ function en_US(error2) {
20758
20745
  return `must not have duplicate items`;
20759
20746
  case "~refine":
20760
20747
  return error2.params.message;
20761
- // deno-coverage-ignore - unreachable
20748
+ // deno-coverage-ignore-start - unreachable
20762
20749
  default:
20763
20750
  return "an unknown validation error occurred";
20764
20751
  }
@@ -22626,8 +22613,14 @@ function TryRestInferable(type) {
22626
22613
  function TryInferable(type) {
22627
22614
  return IsInfer(type) ? Inferrable(type.name, type.extends) : void 0;
22628
22615
  }
22629
- function TryInferResults(rest, right, result2 = []) {
22630
- return guard_exports.ShiftLeft(rest, (head, tail) => Match3(ExtendsLeft({}, head, right), () => TryInferResults(tail, right, [...result2, head]), () => void 0), () => result2);
22616
+ function TryInferResults(rest, right) {
22617
+ const result2 = [];
22618
+ for (const head of rest) {
22619
+ if (!IsExtendsTrueLike(ExtendsLeft({}, head, right)))
22620
+ return void 0;
22621
+ result2.push(head);
22622
+ }
22623
+ return result2;
22631
22624
  }
22632
22625
  function InferTupleResult(inferred, name, left, right) {
22633
22626
  const results = TryInferResults(left, right);
@@ -22671,9 +22664,18 @@ function ExtendsTupleToTuple(inferred, left, right) {
22671
22664
  const reversed = Reversed(instantiatedRight);
22672
22665
  return Elements(inferred, reversed, ApplyReverse(left, reversed), ApplyReverse(instantiatedRight, reversed));
22673
22666
  }
22667
+ function ExtendsTupleToArrayReduce(inferred, left, right) {
22668
+ for (const head of left) {
22669
+ const result2 = ExtendsLeft(inferred, head, right);
22670
+ if (!IsExtendsTrueLike(result2))
22671
+ return result2;
22672
+ inferred = result2.inferred;
22673
+ }
22674
+ return ExtendsTrue(inferred);
22675
+ }
22674
22676
  function ExtendsTupleToArray(inferred, left, right) {
22675
22677
  const inferrable = TryInferable(right);
22676
- return IsInferable(inferrable) ? InferUnionResult(inferred, inferrable["name"], left, inferrable["type"]) : guard_exports.ShiftLeft(left, (head, tail) => Match3(ExtendsLeft(inferred, head, right), (inferred2) => ExtendsTupleToArray(inferred2, tail, right), () => ExtendsFalse()), () => ExtendsTrue(inferred));
22678
+ return IsInferable(inferrable) ? InferUnionResult(inferred, inferrable["name"], left, inferrable["type"]) : ExtendsTupleToArrayReduce(inferred, left, right);
22677
22679
  }
22678
22680
  function ExtendsTuple(inferred, left, right) {
22679
22681
  const instantiatedLeft = InstantiateElements(inferred, State([], []), left);
@@ -24700,10 +24702,7 @@ function CheckRefine(_stack, _context, schema, value) {
24700
24702
  }
24701
24703
  function ErrorRefine(_stack, context, schemaPath, instancePath, schema, value) {
24702
24704
  return guard_exports.EveryAll(schema["~refine"], 0, (refinement, index) => {
24703
- return refinement.check(value) || context.AddError("~refine", schemaPath, instancePath, {
24704
- index,
24705
- message: refinement.error(value)
24706
- });
24705
+ return refinement.check(value) || context.AddError("~refine", schemaPath, instancePath, { index, message: refinement.error(value) });
24707
24706
  });
24708
24707
  }
24709
24708
 
@@ -24832,6 +24831,11 @@ function ErrorAdditionalItems(stack, context, schemaPath, instancePath, schema,
24832
24831
  return isAdditionalItems;
24833
24832
  }
24834
24833
 
24834
+ // node_modules/typebox/build/schema/engine/_pathing.mjs
24835
+ function EncodeFragment(fragment) {
24836
+ return fragment.replace(/~/g, "~0").replace(/\//g, "~1");
24837
+ }
24838
+
24835
24839
  // node_modules/typebox/build/schema/engine/_regexp.mjs
24836
24840
  function UnicodeRegExp(pattern) {
24837
24841
  return new RegExp(pattern, "u");
@@ -24862,7 +24866,7 @@ function ErrorAdditionalProperties(stack, context, schemaPath, instancePath, sch
24862
24866
  const additionalProperties = [];
24863
24867
  const isAdditionalProperties = guard_exports.EveryAll(guard_exports.Keys(value), 0, (key, _index) => {
24864
24868
  const nextSchemaPath = `${schemaPath}/additionalProperties`;
24865
- const nextInstancePath = `${instancePath}/${key}`;
24869
+ const nextInstancePath = `${instancePath}/${EncodeFragment(key)}`;
24866
24870
  const isAdditionalProperty = regexp.test(key) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema.additionalProperties, value[key]) && context.AddKey(key);
24867
24871
  if (!isAdditionalProperty)
24868
24872
  additionalProperties.push(key);
@@ -24961,7 +24965,7 @@ function CheckDependencies(stack, context, schema, value) {
24961
24965
  function ErrorDependencies(stack, context, schemaPath, instancePath, schema, value) {
24962
24966
  const isLength = guard_exports.IsEqual(guard_exports.Keys(value).length, 0);
24963
24967
  const isEvery = guard_exports.EveryAll(guard_exports.Entries(schema.dependencies), 0, ([key, schema2]) => {
24964
- const nextSchemaPath = `${schemaPath}/dependencies/${key}`;
24968
+ const nextSchemaPath = `${schemaPath}/dependencies/${EncodeFragment(key)}`;
24965
24969
  return !guard_exports.HasPropertyKey(value, key) || (guard_exports.IsArray(schema2) ? schema2.every((dependency) => guard_exports.HasPropertyKey(value, dependency) || context.AddError("dependencies", schemaPath, instancePath, { property: key, dependencies: schema2 })) : ErrorSchema(stack, context, nextSchemaPath, instancePath, schema2, value));
24966
24970
  });
24967
24971
  return isLength || isEvery;
@@ -24994,7 +24998,7 @@ function CheckDependentSchemas(stack, context, schema, value) {
24994
24998
  function ErrorDependentSchemas(stack, context, schemaPath, instancePath, schema, value) {
24995
24999
  const isLength = guard_exports.IsEqual(guard_exports.Keys(value).length, 0);
24996
25000
  const isEvery = guard_exports.EveryAll(guard_exports.Entries(schema.dependentSchemas), 0, ([key, schema2]) => {
24997
- const nextSchemaPath = `${schemaPath}/dependentSchemas/${key}`;
25001
+ const nextSchemaPath = `${schemaPath}/dependentSchemas/${EncodeFragment(key)}`;
24998
25002
  return !guard_exports.HasPropertyKey(value, key) || ErrorSchema(stack, context, nextSchemaPath, instancePath, schema2, value);
24999
25003
  });
25000
25004
  return isLength || isEvery;
@@ -25017,80 +25021,68 @@ __export(pointer_exports, {
25017
25021
  Indices: () => Indices,
25018
25022
  Set: () => Set3
25019
25023
  });
25020
- function AssertNotRoot(indices) {
25021
- if (indices.length === 0)
25022
- throw Error("Cannot set root");
25023
- }
25024
- function AssertCanSet(value) {
25025
- if (!guard_exports.IsObject(value))
25026
- throw Error("Cannot set value");
25027
- }
25028
- function AssertIndex(index) {
25029
- if (guard_exports.IsUnsafePropertyKey(index))
25030
- throw Error("Pointer contains unsafe property key");
25024
+ function Throw(message3) {
25025
+ throw Error(message3);
25031
25026
  }
25032
- function AssertIndices(indices) {
25033
- for (const index of indices)
25034
- AssertIndex(index);
25027
+ function ThrowUnsafePropertyKey() {
25028
+ Throw("Pointer contains unsafe property key");
25035
25029
  }
25036
- function IsNumericIndex(index) {
25037
- return /^(0|[1-9]\d*)$/.test(index);
25038
- }
25039
- function TakeIndexRight(indices) {
25040
- return [
25041
- indices.slice(0, indices.length - 1),
25042
- indices.slice(indices.length - 1)[0]
25043
- ];
25044
- }
25045
- function HasIndex(index, value) {
25046
- return guard_exports.IsObject(value) && guard_exports.HasPropertyKey(value, index);
25047
- }
25048
- function GetIndex(index, value) {
25049
- return guard_exports.IsObject(value) && !guard_exports.IsUnsafePropertyKey(index) ? value[index] : void 0;
25050
- }
25051
- function GetIndices(indices, value) {
25052
- return indices.reduce((value2, index) => GetIndex(index, value2), value);
25030
+ function ThrowCannotSetRoot() {
25031
+ Throw("Cannot set value");
25053
25032
  }
25054
25033
  function Indices(pointer) {
25055
- if (guard_exports.IsEqual(pointer.length, 0))
25056
- return [];
25057
25034
  const indices = pointer.split("/").map((index) => index.replace(/~1/g, "/").replace(/~0/g, "~"));
25058
- return indices.length > 0 && indices[0] === "" ? indices.slice(1) : indices;
25035
+ return indices[0] === "" ? indices.slice(1) : indices;
25059
25036
  }
25060
25037
  function Has(value, pointer) {
25061
25038
  let current = value;
25062
- return Indices(pointer).every((index) => {
25063
- if (!HasIndex(index, current))
25039
+ for (const index of Indices(pointer)) {
25040
+ if (!guard_exports.IsObject(current) || !guard_exports.HasPropertyKey(current, index))
25064
25041
  return false;
25065
25042
  current = current[index];
25066
- return true;
25067
- });
25043
+ }
25044
+ return true;
25068
25045
  }
25069
25046
  function Get3(value, pointer) {
25070
- const indices = Indices(pointer);
25071
- return GetIndices(indices, value);
25047
+ let current = value;
25048
+ for (const index of Indices(pointer)) {
25049
+ if (!guard_exports.IsObject(current) || guard_exports.IsUnsafePropertyKey(index))
25050
+ return void 0;
25051
+ current = current[index];
25052
+ }
25053
+ return current;
25054
+ }
25055
+ function Parent(value, indices, last) {
25056
+ let current = value;
25057
+ for (const index of indices) {
25058
+ if (guard_exports.IsUnsafePropertyKey(index))
25059
+ ThrowUnsafePropertyKey();
25060
+ current = guard_exports.IsObject(current) ? current[index] : void 0;
25061
+ }
25062
+ if (guard_exports.IsUnsafePropertyKey(last))
25063
+ ThrowUnsafePropertyKey();
25064
+ if (!guard_exports.IsObject(current))
25065
+ ThrowCannotSetRoot();
25066
+ return current;
25072
25067
  }
25073
25068
  function Set3(value, pointer, next) {
25074
25069
  const indices = Indices(pointer);
25075
- AssertNotRoot(indices);
25076
- AssertIndices(indices);
25077
- const [head, index] = TakeIndexRight(indices);
25078
- const parent = GetIndices(head, value);
25079
- AssertCanSet(parent);
25080
- parent[index] = next;
25070
+ const last = indices.pop();
25071
+ if (guard_exports.IsUndefined(last))
25072
+ ThrowCannotSetRoot();
25073
+ Parent(value, indices, last)[last] = next;
25081
25074
  return value;
25082
25075
  }
25083
25076
  function Delete(value, pointer) {
25084
25077
  const indices = Indices(pointer);
25085
- AssertNotRoot(indices);
25086
- AssertIndices(indices);
25087
- const [head, index] = TakeIndexRight(indices);
25088
- const parent = GetIndices(head, value);
25089
- AssertCanSet(parent);
25090
- if (guard_exports.IsArray(parent) && IsNumericIndex(index)) {
25091
- parent.splice(+index, 1);
25078
+ const last = indices.pop();
25079
+ if (guard_exports.IsUndefined(last))
25080
+ ThrowCannotSetRoot();
25081
+ const parent = Parent(value, indices, last);
25082
+ if (guard_exports.IsArray(parent) && /^(0|[1-9]\d*)$/.test(last)) {
25083
+ parent.splice(Number(last), 1);
25092
25084
  } else {
25093
- delete parent[index];
25085
+ delete parent[last];
25094
25086
  }
25095
25087
  return value;
25096
25088
  }
@@ -25332,10 +25324,10 @@ function CheckDynamicRef(stack, context, schema, value) {
25332
25324
  const nextStack = target ? { ...stack, pendingResource: true } : stack;
25333
25325
  return IsSchema2(target) && CheckSchema(nextStack, context, target, value);
25334
25326
  }
25335
- function ErrorDynamicRef(stack, context, _schemaPath, instancePath, schema, value) {
25327
+ function ErrorDynamicRef(stack, context, schemaPath, instancePath, schema, value) {
25336
25328
  const target = resolve_exports.DynamicRef(stack, schema) ?? false;
25337
25329
  const nextStack = target ? { ...stack, pendingResource: true } : stack;
25338
- return IsSchema2(target) && ErrorSchema(nextStack, context, "#", instancePath, target, value);
25330
+ return IsSchema2(target) && ErrorSchema(nextStack, context, schemaPath, instancePath, target, value);
25339
25331
  }
25340
25332
 
25341
25333
  // node_modules/typebox/build/schema/engine/enum.mjs
@@ -25828,19 +25820,14 @@ function IsIriReference(value) {
25828
25820
  }
25829
25821
 
25830
25822
  // node_modules/typebox/build/format/iri.mjs
25831
- var IpvFutureMatchMaxLength = 2048;
25832
- var IpvFutureMatch = /\[[vV][0-9a-fA-F]+\.[^\]]+\]/;
25833
25823
  var InvalidIriChars2 = /[\x00-\x20<>\^`{|}\\]/;
25834
25824
  var InvalidPercentEncoding = /%(?![0-9a-fA-F]{2})/;
25835
- function NarrowIpvFuture(value) {
25836
- return value.length < IpvFutureMatchMaxLength ? value.replace(IpvFutureMatch, "[::1]") : value;
25837
- }
25838
25825
  function IsIri(value) {
25839
25826
  if (InvalidIriChars2.test(value))
25840
25827
  return false;
25841
25828
  if (InvalidPercentEncoding.test(value))
25842
25829
  return false;
25843
- return URL.canParse(NarrowIpvFuture(value));
25830
+ return URL.canParse(value);
25844
25831
  }
25845
25832
 
25846
25833
  // node_modules/typebox/build/format/json_pointer_uri_fragment.mjs
@@ -26163,10 +26150,10 @@ function CheckPatternProperties(stack, context, schema, value) {
26163
26150
  }
26164
26151
  function ErrorPatternProperties(stack, context, schemaPath, instancePath, schema, value) {
26165
26152
  return guard_exports.EveryAll(guard_exports.Entries(schema.patternProperties), 0, ([pattern, schema2]) => {
26166
- const nextSchemaPath = `${schemaPath}/patternProperties/${pattern}`;
26153
+ const nextSchemaPath = `${schemaPath}/patternProperties/${EncodeFragment(pattern)}`;
26167
26154
  const regexp = UnicodeRegExp(pattern);
26168
26155
  return guard_exports.EveryAll(guard_exports.Entries(value), 0, ([key, value2]) => {
26169
- const nextInstancePath = `${instancePath}/${key}`;
26156
+ const nextInstancePath = `${instancePath}/${EncodeFragment(key)}`;
26170
26157
  const notKey = !regexp.test(key);
26171
26158
  return notKey || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema2, value2) && context.AddKey(key);
26172
26159
  });
@@ -26207,8 +26194,8 @@ function CheckProperties(stack, context, schema, value) {
26207
26194
  function ErrorProperties(stack, context, schemaPath, instancePath, schema, value) {
26208
26195
  const required2 = IsRequired(schema) ? schema.required : [];
26209
26196
  const isProperties = guard_exports.EveryAll(guard_exports.Entries(schema.properties), 0, ([key, schema2]) => {
26210
- const nextSchemaPath = `${schemaPath}/properties/${key}`;
26211
- const nextInstancePath = `${instancePath}/${key}`;
26197
+ const nextSchemaPath = `${schemaPath}/properties/${EncodeFragment(key)}`;
26198
+ const nextInstancePath = `${instancePath}/${EncodeFragment(key)}`;
26212
26199
  const isProperty = () => !guard_exports.HasPropertyKey(value, key) || ErrorSchemaPushStack(stack, context, nextSchemaPath, nextInstancePath, schema2, value[key]) && context.AddKey(key);
26213
26200
  return IsExactOptional(required2, key) ? isProperty() : InexactOptionalCheck(value, key) || isProperty();
26214
26201
  });
@@ -26222,7 +26209,7 @@ function CheckPropertyNames(stack, context, schema, value) {
26222
26209
  function ErrorPropertyNames(stack, context, schemaPath, instancePath, schema, value) {
26223
26210
  const propertyNames = [];
26224
26211
  const isPropertyNames = guard_exports.EveryAll(guard_exports.Keys(value), 0, (key, _index) => {
26225
- const nextInstancePath = `${instancePath}/${key}`;
26212
+ const nextInstancePath = `${instancePath}/${EncodeFragment(key)}`;
26226
26213
  const nextSchemaPath = `${schemaPath}/propertyNames`;
26227
26214
  const isPropertyName = ErrorSchema(stack, context, nextSchemaPath, nextInstancePath, schema.propertyNames, key);
26228
26215
  if (!isPropertyName)
@@ -26238,10 +26225,10 @@ function CheckRecursiveRef(stack, context, schema, value) {
26238
26225
  const nextStack = target ? { ...stack, pendingResource: true } : stack;
26239
26226
  return IsSchema2(target) && CheckSchema(nextStack, context, target, value);
26240
26227
  }
26241
- function ErrorRecursiveRef(stack, context, _schemaPath, instancePath, schema, value) {
26228
+ function ErrorRecursiveRef(stack, context, schemaPath, instancePath, schema, value) {
26242
26229
  const target = resolve_exports.RecursiveRef(stack, schema) ?? false;
26243
26230
  const nextStack = target ? { ...stack, pendingResource: true } : stack;
26244
- return IsSchema2(target) && ErrorSchema(nextStack, context, "#", instancePath, target, value);
26231
+ return IsSchema2(target) && ErrorSchema(nextStack, context, schemaPath, instancePath, target, value);
26245
26232
  }
26246
26233
 
26247
26234
  // node_modules/typebox/build/schema/engine/ref.mjs
@@ -26254,11 +26241,11 @@ function CheckRef(stack, context, schema, value) {
26254
26241
  context.Merge([nextContext]);
26255
26242
  return valid;
26256
26243
  }
26257
- function ErrorRef(stack, context, _schemaPath, instancePath, schema, value) {
26244
+ function ErrorRef(stack, context, schemaPath, instancePath, schema, value) {
26258
26245
  const result2 = resolve_exports.Ref(stack, schema);
26259
26246
  const target = result2.schema ?? false;
26260
26247
  const nextContext = new ErrorContext();
26261
- const valid = IsSchema2(target) && ErrorSchema(result2.stack, nextContext, "#", instancePath, target, value);
26248
+ const valid = IsSchema2(target) && ErrorSchema(result2.stack, nextContext, schemaPath, instancePath, target, value);
26262
26249
  if (valid)
26263
26250
  context.Merge([nextContext]);
26264
26251
  if (!valid)
@@ -26374,7 +26361,7 @@ function CheckSchemaPushStack(stack, context, schema, value) {
26374
26361
  }
26375
26362
  function CheckSchema(stack, context, schema, value) {
26376
26363
  const current = NextStack(stack, schema);
26377
- const result2 = IsSchemaBoolean(schema) ? CheckSchemaBoolean(current, context, schema, value) : (!IsType(schema) || CheckType(current, context, schema, value)) && (!(guard_exports.IsObject(value) && !guard_exports.IsArray(value)) || (!IsRequired(schema) || CheckRequired(current, context, schema, value)) && (!IsAdditionalProperties(schema) || CheckAdditionalProperties(current, context, schema, value)) && (!IsDependencies(schema) || CheckDependencies(current, context, schema, value)) && (!IsDependentRequired(schema) || CheckDependentRequired(current, context, schema, value)) && (!IsDependentSchemas(schema) || CheckDependentSchemas(current, context, schema, value)) && (!IsPatternProperties(schema) || CheckPatternProperties(current, context, schema, value)) && (!IsProperties(schema) || CheckProperties(current, context, schema, value)) && (!IsPropertyNames(schema) || CheckPropertyNames(current, context, schema, value)) && (!IsMinProperties(schema) || CheckMinProperties(current, context, schema, value)) && (!IsMaxProperties(schema) || CheckMaxProperties(current, context, schema, value))) && (!guard_exports.IsArray(value) || (!IsAdditionalItems(schema) || CheckAdditionalItems(current, context, schema, value)) && (!IsContains(schema) || CheckContains(current, context, schema, value)) && (!IsItems(schema) || CheckItems(current, context, schema, value)) && (!IsMaxContains(schema) || CheckMaxContains(current, context, schema, value)) && (!IsMaxItems(schema) || CheckMaxItems(current, context, schema, value)) && (!IsMinContains(schema) || CheckMinContains(current, context, schema, value)) && (!IsMinItems(schema) || CheckMinItems(current, context, schema, value)) && (!IsPrefixItems(schema) || CheckPrefixItems(current, context, schema, value)) && (!IsUniqueItems(schema) || CheckUniqueItems(current, context, schema, value))) && (!guard_exports.IsString(value) || (!IsMaxLength3(schema) || CheckMaxLength(current, context, schema, value)) && (!IsMinLength3(schema) || CheckMinLength(current, context, schema, value)) && (!IsFormat(schema) || CheckFormat(current, context, schema, value)) && (!IsPattern(schema) || CheckPattern(current, context, schema, value))) && (!(guard_exports.IsNumber(value) || guard_exports.IsBigInt(value)) || (!IsExclusiveMaximum(schema) || CheckExclusiveMaximum(current, context, schema, value)) && (!IsExclusiveMinimum(schema) || CheckExclusiveMinimum(current, context, schema, value)) && (!IsMaximum(schema) || CheckMaximum(current, context, schema, value)) && (!IsMinimum(schema) || CheckMinimum(current, context, schema, value)) && (!IsMultipleOf2(schema) || CheckMultipleOf(current, context, schema, value))) && (!IsRef2(schema) || CheckRef(current, context, schema, value)) && (!IsRecursiveRef(schema) || CheckRecursiveRef(current, context, schema, value)) && (!IsDynamicRef(schema) || CheckDynamicRef(current, context, schema, value)) && (!IsConst(schema) || CheckConst(current, context, schema, value)) && (!IsEnum2(schema) || CheckEnum(current, context, schema, value)) && (!IsIf(schema) || CheckIf(current, context, schema, value)) && (!IsNot(schema) || CheckNot(current, context, schema, value)) && (!IsAllOf(schema) || CheckAllOf(current, context, schema, value)) && (!IsAnyOf(schema) || CheckAnyOf(current, context, schema, value)) && (!IsOneOf(schema) || CheckOneOf(current, context, schema, value)) && (!IsUnevaluatedItems(schema) || (!guard_exports.IsArray(value) || CheckUnevaluatedItems(current, context, schema, value))) && (!IsUnevaluatedProperties(schema) || (!guard_exports.IsObject(value) || CheckUnevaluatedProperties(current, context, schema, value))) && (!IsRefine2(schema) || CheckRefine(current, context, schema, value));
26364
+ const result2 = IsSchemaBoolean(schema) ? CheckSchemaBoolean(current, context, schema, value) : (!IsType(schema) || CheckType(current, context, schema, value)) && (!(guard_exports.IsObject(value) && !guard_exports.IsArray(value)) || (!IsRequired(schema) || CheckRequired(current, context, schema, value)) && (!IsAdditionalProperties(schema) || CheckAdditionalProperties(current, context, schema, value)) && (!IsDependencies(schema) || CheckDependencies(current, context, schema, value)) && (!IsDependentRequired(schema) || CheckDependentRequired(current, context, schema, value)) && (!IsDependentSchemas(schema) || CheckDependentSchemas(current, context, schema, value)) && (!IsPatternProperties(schema) || CheckPatternProperties(current, context, schema, value)) && (!IsProperties(schema) || CheckProperties(current, context, schema, value)) && (!IsPropertyNames(schema) || CheckPropertyNames(current, context, schema, value)) && (!IsMinProperties(schema) || CheckMinProperties(current, context, schema, value)) && (!IsMaxProperties(schema) || CheckMaxProperties(current, context, schema, value))) && (!guard_exports.IsArray(value) || (!IsAdditionalItems(schema) || CheckAdditionalItems(current, context, schema, value)) && (!IsContains(schema) || CheckContains(current, context, schema, value)) && (!IsItems(schema) || CheckItems(current, context, schema, value)) && (!IsMinContains(schema) || CheckMinContains(current, context, schema, value)) && (!IsMaxContains(schema) || CheckMaxContains(current, context, schema, value)) && (!IsMinItems(schema) || CheckMinItems(current, context, schema, value)) && (!IsMaxItems(schema) || CheckMaxItems(current, context, schema, value)) && (!IsPrefixItems(schema) || CheckPrefixItems(current, context, schema, value)) && (!IsUniqueItems(schema) || CheckUniqueItems(current, context, schema, value))) && (!guard_exports.IsString(value) || (!IsMinLength3(schema) || CheckMinLength(current, context, schema, value)) && (!IsMaxLength3(schema) || CheckMaxLength(current, context, schema, value)) && (!IsFormat(schema) || CheckFormat(current, context, schema, value)) && (!IsPattern(schema) || CheckPattern(current, context, schema, value))) && (!(guard_exports.IsNumber(value) || guard_exports.IsBigInt(value)) || (!IsExclusiveMinimum(schema) || CheckExclusiveMinimum(current, context, schema, value)) && (!IsExclusiveMaximum(schema) || CheckExclusiveMaximum(current, context, schema, value)) && (!IsMinimum(schema) || CheckMinimum(current, context, schema, value)) && (!IsMaximum(schema) || CheckMaximum(current, context, schema, value)) && (!IsMultipleOf2(schema) || CheckMultipleOf(current, context, schema, value))) && (!IsRef2(schema) || CheckRef(current, context, schema, value)) && (!IsRecursiveRef(schema) || CheckRecursiveRef(current, context, schema, value)) && (!IsDynamicRef(schema) || CheckDynamicRef(current, context, schema, value)) && (!IsConst(schema) || CheckConst(current, context, schema, value)) && (!IsEnum2(schema) || CheckEnum(current, context, schema, value)) && (!IsIf(schema) || CheckIf(current, context, schema, value)) && (!IsNot(schema) || CheckNot(current, context, schema, value)) && (!IsAllOf(schema) || CheckAllOf(current, context, schema, value)) && (!IsAnyOf(schema) || CheckAnyOf(current, context, schema, value)) && (!IsOneOf(schema) || CheckOneOf(current, context, schema, value)) && (!IsUnevaluatedItems(schema) || (!guard_exports.IsArray(value) || CheckUnevaluatedItems(current, context, schema, value))) && (!IsUnevaluatedProperties(schema) || (!guard_exports.IsObject(value) || CheckUnevaluatedProperties(current, context, schema, value))) && (!IsRefine2(schema) || CheckRefine(current, context, schema, value));
26378
26365
  return result2;
26379
26366
  }
26380
26367
  function ErrorSchemaPushStack(stack, context, schemaPath, instancePath, schema, value) {
@@ -26384,7 +26371,7 @@ function ErrorSchema(stack, context, schemaPath, instancePath, schema, value) {
26384
26371
  if (context.AtCapacity())
26385
26372
  return false;
26386
26373
  const current = NextStack(stack, schema);
26387
- const result2 = IsSchemaBoolean(schema) ? ErrorSchemaBoolean(current, context, schemaPath, instancePath, schema, value) : !!(+(!IsType(schema) || ErrorType(current, context, schemaPath, instancePath, schema, value)) & +(!(guard_exports.IsObject(value) && !guard_exports.IsArray(value)) || !!(+(!IsRequired(schema) || ErrorRequired(current, context, schemaPath, instancePath, schema, value)) & +(!IsAdditionalProperties(schema) || ErrorAdditionalProperties(current, context, schemaPath, instancePath, schema, value)) & +(!IsDependencies(schema) || ErrorDependencies(current, context, schemaPath, instancePath, schema, value)) & +(!IsDependentRequired(schema) || ErrorDependentRequired(current, context, schemaPath, instancePath, schema, value)) & +(!IsDependentSchemas(schema) || ErrorDependentSchemas(current, context, schemaPath, instancePath, schema, value)) & +(!IsPatternProperties(schema) || ErrorPatternProperties(current, context, schemaPath, instancePath, schema, value)) & +(!IsProperties(schema) || ErrorProperties(current, context, schemaPath, instancePath, schema, value)) & +(!IsPropertyNames(schema) || ErrorPropertyNames(current, context, schemaPath, instancePath, schema, value)) & +(!IsMinProperties(schema) || ErrorMinProperties(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaxProperties(schema) || ErrorMaxProperties(current, context, schemaPath, instancePath, schema, value)))) & +(!guard_exports.IsArray(value) || !!(+(!IsAdditionalItems(schema) || ErrorAdditionalItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsContains(schema) || ErrorContains(current, context, schemaPath, instancePath, schema, value)) & +(!IsItems(schema) || ErrorItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaxContains(schema) || ErrorMaxContains(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaxItems(schema) || ErrorMaxItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsMinContains(schema) || ErrorMinContains(current, context, schemaPath, instancePath, schema, value)) & +(!IsMinItems(schema) || ErrorMinItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsPrefixItems(schema) || ErrorPrefixItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsUniqueItems(schema) || ErrorUniqueItems(current, context, schemaPath, instancePath, schema, value)))) & +(!guard_exports.IsString(value) || !!(+(!IsMaxLength3(schema) || ErrorMaxLength(current, context, schemaPath, instancePath, schema, value)) & +(!IsMinLength3(schema) || ErrorMinLength(current, context, schemaPath, instancePath, schema, value)) & +(!IsFormat(schema) || ErrorFormat(current, context, schemaPath, instancePath, schema, value)) & +(!IsPattern(schema) || ErrorPattern(current, context, schemaPath, instancePath, schema, value)))) & +(!(guard_exports.IsNumber(value) || guard_exports.IsBigInt(value)) || !!(+(!IsExclusiveMaximum(schema) || ErrorExclusiveMaximum(current, context, schemaPath, instancePath, schema, value)) & +(!IsExclusiveMinimum(schema) || ErrorExclusiveMinimum(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaximum(schema) || ErrorMaximum(current, context, schemaPath, instancePath, schema, value)) & +(!IsMinimum(schema) || ErrorMinimum(current, context, schemaPath, instancePath, schema, value)) & +(!IsMultipleOf2(schema) || ErrorMultipleOf(current, context, schemaPath, instancePath, schema, value)))) & +(!IsRef2(schema) || ErrorRef(current, context, schemaPath, instancePath, schema, value)) & +(!IsRecursiveRef(schema) || ErrorRecursiveRef(current, context, schemaPath, instancePath, schema, value)) & +(!IsDynamicRef(schema) || ErrorDynamicRef(current, context, schemaPath, instancePath, schema, value)) & +(!IsConst(schema) || ErrorConst(current, context, schemaPath, instancePath, schema, value)) & +(!IsEnum2(schema) || ErrorEnum(current, context, schemaPath, instancePath, schema, value)) & +(!IsIf(schema) || ErrorIf(current, context, schemaPath, instancePath, schema, value)) & +(!IsNot(schema) || ErrorNot(current, context, schemaPath, instancePath, schema, value)) & +(!IsAllOf(schema) || ErrorAllOf(current, context, schemaPath, instancePath, schema, value)) & +(!IsAnyOf(schema) || ErrorAnyOf(current, context, schemaPath, instancePath, schema, value)) & +(!IsOneOf(schema) || ErrorOneOf(current, context, schemaPath, instancePath, schema, value)) & +(!IsUnevaluatedItems(schema) || (!guard_exports.IsArray(value) || ErrorUnevaluatedItems(current, context, schemaPath, instancePath, schema, value))) & +(!IsUnevaluatedProperties(schema) || (!guard_exports.IsObject(value) || ErrorUnevaluatedProperties(current, context, schemaPath, instancePath, schema, value)))) && (!IsRefine2(schema) || ErrorRefine(current, context, schemaPath, instancePath, schema, value));
26374
+ const result2 = IsSchemaBoolean(schema) ? ErrorSchemaBoolean(current, context, schemaPath, instancePath, schema, value) : !!(+(!IsType(schema) || ErrorType(current, context, schemaPath, instancePath, schema, value)) & +(!(guard_exports.IsObject(value) && !guard_exports.IsArray(value)) || !!(+(!IsRequired(schema) || ErrorRequired(current, context, schemaPath, instancePath, schema, value)) & +(!IsAdditionalProperties(schema) || ErrorAdditionalProperties(current, context, schemaPath, instancePath, schema, value)) & +(!IsDependencies(schema) || ErrorDependencies(current, context, schemaPath, instancePath, schema, value)) & +(!IsDependentRequired(schema) || ErrorDependentRequired(current, context, schemaPath, instancePath, schema, value)) & +(!IsDependentSchemas(schema) || ErrorDependentSchemas(current, context, schemaPath, instancePath, schema, value)) & +(!IsPatternProperties(schema) || ErrorPatternProperties(current, context, schemaPath, instancePath, schema, value)) & +(!IsProperties(schema) || ErrorProperties(current, context, schemaPath, instancePath, schema, value)) & +(!IsPropertyNames(schema) || ErrorPropertyNames(current, context, schemaPath, instancePath, schema, value)) & +(!IsMinProperties(schema) || ErrorMinProperties(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaxProperties(schema) || ErrorMaxProperties(current, context, schemaPath, instancePath, schema, value)))) & +(!guard_exports.IsArray(value) || !!(+(!IsAdditionalItems(schema) || ErrorAdditionalItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsContains(schema) || ErrorContains(current, context, schemaPath, instancePath, schema, value)) & +(!IsItems(schema) || ErrorItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsMinContains(schema) || ErrorMinContains(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaxContains(schema) || ErrorMaxContains(current, context, schemaPath, instancePath, schema, value)) & +(!IsMinItems(schema) || ErrorMinItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaxItems(schema) || ErrorMaxItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsPrefixItems(schema) || ErrorPrefixItems(current, context, schemaPath, instancePath, schema, value)) & +(!IsUniqueItems(schema) || ErrorUniqueItems(current, context, schemaPath, instancePath, schema, value)))) & +(!guard_exports.IsString(value) || !!(+(!IsMinLength3(schema) || ErrorMinLength(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaxLength3(schema) || ErrorMaxLength(current, context, schemaPath, instancePath, schema, value)) & +(!IsFormat(schema) || ErrorFormat(current, context, schemaPath, instancePath, schema, value)) & +(!IsPattern(schema) || ErrorPattern(current, context, schemaPath, instancePath, schema, value)))) & +(!(guard_exports.IsNumber(value) || guard_exports.IsBigInt(value)) || !!(+(!IsExclusiveMinimum(schema) || ErrorExclusiveMinimum(current, context, schemaPath, instancePath, schema, value)) & +(!IsExclusiveMaximum(schema) || ErrorExclusiveMaximum(current, context, schemaPath, instancePath, schema, value)) & +(!IsMinimum(schema) || ErrorMinimum(current, context, schemaPath, instancePath, schema, value)) & +(!IsMaximum(schema) || ErrorMaximum(current, context, schemaPath, instancePath, schema, value)) & +(!IsMultipleOf2(schema) || ErrorMultipleOf(current, context, schemaPath, instancePath, schema, value)))) & +(!IsRef2(schema) || ErrorRef(current, context, schemaPath, instancePath, schema, value)) & +(!IsRecursiveRef(schema) || ErrorRecursiveRef(current, context, schemaPath, instancePath, schema, value)) & +(!IsDynamicRef(schema) || ErrorDynamicRef(current, context, schemaPath, instancePath, schema, value)) & +(!IsConst(schema) || ErrorConst(current, context, schemaPath, instancePath, schema, value)) & +(!IsEnum2(schema) || ErrorEnum(current, context, schemaPath, instancePath, schema, value)) & +(!IsIf(schema) || ErrorIf(current, context, schemaPath, instancePath, schema, value)) & +(!IsNot(schema) || ErrorNot(current, context, schemaPath, instancePath, schema, value)) & +(!IsAllOf(schema) || ErrorAllOf(current, context, schemaPath, instancePath, schema, value)) & +(!IsAnyOf(schema) || ErrorAnyOf(current, context, schemaPath, instancePath, schema, value)) & +(!IsOneOf(schema) || ErrorOneOf(current, context, schemaPath, instancePath, schema, value)) & +(!IsUnevaluatedItems(schema) || (!guard_exports.IsArray(value) || ErrorUnevaluatedItems(current, context, schemaPath, instancePath, schema, value))) & +(!IsUnevaluatedProperties(schema) || (!guard_exports.IsObject(value) || ErrorUnevaluatedProperties(current, context, schemaPath, instancePath, schema, value)))) && (!IsRefine2(schema) || ErrorRefine(current, context, schemaPath, instancePath, schema, value));
26388
26375
  return result2;
26389
26376
  }
26390
26377
 
@@ -26403,6 +26390,18 @@ function Errors(...args) {
26403
26390
  return [result2, localized];
26404
26391
  }
26405
26392
 
26393
+ // node_modules/typebox/build/system/settings/internal.mjs
26394
+ var TempMaxErrors = 0;
26395
+ function EnableParseErrors() {
26396
+ const settings2 = Get();
26397
+ TempMaxErrors = settings2.maxErrors;
26398
+ settings2.maxErrors = settings2.maxParseErrors;
26399
+ }
26400
+ function DisableParseErrors() {
26401
+ const settings2 = Get();
26402
+ settings2.maxErrors = TempMaxErrors;
26403
+ }
26404
+
26406
26405
  // node_modules/typebox/build/schema/check.mjs
26407
26406
  function Check(...args) {
26408
26407
  const [context, schema, value] = arguments_exports.Match(args, {
@@ -26482,7 +26481,7 @@ function FromObject10(context, type, value) {
26482
26481
  return value;
26483
26482
  const additionalProperties = GetAdditionalProperties(type);
26484
26483
  for (const key of guard_exports.Keys(value)) {
26485
- if (guard_exports.HasPropertyKey(type.properties, key)) {
26484
+ if (guard_exports.HasPropertyKey(type.properties, key) && IsSchema(type.properties[key])) {
26486
26485
  value[key] = FromType19(context, type.properties[key], value[key]);
26487
26486
  continue;
26488
26487
  }
@@ -26574,6 +26573,9 @@ function FromProperties4(properties) {
26574
26573
  result2[key] = FromType20(properties[key]);
26575
26574
  return result2;
26576
26575
  }
26576
+ function FromRecordKey(type) {
26577
+ return String2({ pattern: RecordPattern(type) });
26578
+ }
26577
26579
  function FromPriorityTypes(types) {
26578
26580
  return FromTypes6(Priority(types));
26579
26581
  }
@@ -26581,7 +26583,7 @@ function FromTypes6(types) {
26581
26583
  return types.map((type) => FromType20(type));
26582
26584
  }
26583
26585
  function FromType20(type) {
26584
- const next = IsArray2(type) ? _Array_(FromType20(type.items), ArrayOptions(type)) : IsIntersect(type) ? Intersect(FromTypes6(type.allOf)) : IsUnion(type) ? Union(FromPriorityTypes(type.anyOf)) : IsObject2(type) ? _Object_(FromProperties4(type.properties)) : IsRecord(type) ? Record(RecordKey(type), FromType20(RecordValue(type))) : IsTuple(type) ? Tuple(FromTypes6(type.items)) : type;
26586
+ const next = IsArray2(type) ? _Array_(FromType20(type.items), ArrayOptions(type)) : IsIntersect(type) ? Intersect(FromTypes6(type.allOf)) : IsUnion(type) ? Union(FromPriorityTypes(type.anyOf)) : IsObject2(type) ? _Object_(FromProperties4(type.properties)) : IsRecord(type) ? Record(FromRecordKey(type), FromType20(RecordValue(type))) : IsTuple(type) ? Tuple(FromTypes6(type.items)) : type;
26585
26587
  return Modifiers(type, next);
26586
26588
  }
26587
26589
  function UnionPrioritySort(type) {
@@ -27294,8 +27296,11 @@ var ParseError = class extends AssertError {
27294
27296
  }
27295
27297
  };
27296
27298
  function Assert3(context, type, value) {
27299
+ EnableParseErrors();
27300
+ const errors = Errors2(context, type, value);
27301
+ DisableParseErrors();
27297
27302
  if (!Check2(context, type, value))
27298
- throw new ParseError(value, Errors2(context, type, value));
27303
+ throw new ParseError(value, errors);
27299
27304
  return value;
27300
27305
  }
27301
27306
  var Parser = Pipeline([
@@ -27996,7 +28001,7 @@ async function prepareImage(bytes, mimeType) {
27996
28001
  // src/guest/image-evidence.ts
27997
28002
  var safeId = (value) => typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9_.-]{0,159}$/.test(value);
27998
28003
  function afterRequested(request) {
27999
- return !(request?.kind === "exec" && request.diagnostic === true) && request?.capture !== false && !["first", "member"].includes(request?.snapshots?.group?.phase ?? "");
28004
+ return request?.diagnostic !== true && request?.capture !== false && !["first", "member"].includes(request?.snapshots?.group?.phase ?? "");
28000
28005
  }
28001
28006
  function validateImageEvidence(value, request, authoritativeSnapshots) {
28002
28007
  const fail2 = () => {
@@ -28035,6 +28040,7 @@ var ImageError = class extends Error {
28035
28040
  super(message3);
28036
28041
  this.code = code;
28037
28042
  }
28043
+ code;
28038
28044
  };
28039
28045
  function fail(code, message3) {
28040
28046
  throw new ImageError(code, message3);
@@ -28162,6 +28168,7 @@ var ImageStore = class {
28162
28168
  constructor(options) {
28163
28169
  this.options = options;
28164
28170
  }
28171
+ options;
28165
28172
  get binding() {
28166
28173
  const o = this.options;
28167
28174
  return hash(JSON.stringify([o.owner, o.enclosure, o.backend]));
@@ -28489,6 +28496,7 @@ var DownloadQueue = class {
28489
28496
  constructor(options) {
28490
28497
  this.options = options;
28491
28498
  }
28499
+ options;
28492
28500
  state = "open";
28493
28501
  /** Set after a transient failure: the worker takes nothing until a relay operation reaches the guest (AD-4). */
28494
28502
  paused = false;
@@ -28729,6 +28737,7 @@ async function refreshEvidenceState(incoming, destination, archiveRoot, options
28729
28737
  }
28730
28738
 
28731
28739
  // src/manager.ts
28740
+ var SCRIPT_EXTENSIONS = { shell: "sh", javascript: "js", typescript: "ts", python: "py" };
28732
28741
  var RENEWAL_WINDOW_MS = 15 * 6e4;
28733
28742
  var MIN_RENEWAL_MS = 0.1 * 36e5;
28734
28743
  var DEFAULT_AFTER_INTERVAL_MS = 500;
@@ -28736,6 +28745,8 @@ var CAPTURE_SOFTWARE = ["bundle:com.trycua.driver", "dpkg:cua-driver"];
28736
28745
  var DOWNLOAD_BOUND = 64;
28737
28746
  var DOWNLOAD_RETRY_DELAYS_MS = [1e3, 3e3];
28738
28747
  var CAPACITY_RETRY_MS = 15e3;
28748
+ var CAPTURE_READY_WAIT_MS = 12e4;
28749
+ var CAPTURE_READY_RETRY_MS = 2e3;
28739
28750
  var TASK = /^[a-z0-9][a-z0-9-]{0,35}$/;
28740
28751
  var GUEST_NAME = /^[a-z0-9][a-z0-9-]{0,47}$/;
28741
28752
  var downloadKey = (target) => `${target.sessionId}/${target.executionId}`;
@@ -28745,7 +28756,7 @@ async function settleEach(work) {
28745
28756
  const failed = (await Promise.allSettled(work)).find((result2) => result2.status === "rejected");
28746
28757
  if (failed) throw failed.reason;
28747
28758
  }
28748
- var instructions = "This server offers fifteen tools for guests, VMs that run the work you choose to run there: relay_search, relay_probe, relay_acquisition_capabilities, relay_acquire, relay_stage, the run tools relay_command and relay_script, relay_image, relay_extract, relay_finish, relay_release, relay_console_resolve, relay_console_open, relay_console_cancel and relay_status. relay_command runs one command; relay_script runs a JavaScript, TypeScript or Python script, given inline or as a project file, and the script drives whatever the image lists, such as cua-driver, Playwright or Chrome DevTools, through their own libraries or command lines. Staging needs only Node.js in the guest, and a run takes before and after snapshots only when the image lists capture software (cua-driver). Evidence is automatic, and a run's after-image is returned as pending and downloaded in the background, so call relay_image with the imageId when you need to see it. Acquire one guest for each machine your work needs; several guests may run at once, up to the session's limit that relay_status reports. relay_acquire answers each guest's name, `guest`, and every call that acts on a guest names it with `guest`. Calls on different guests run at the same time; calls on one guest keep their order. Work each guest in order: relay_probe, then relay_acquire, then relay_stage, then relay_command or relay_script, then relay_image or relay_extract as needed, then relay_finish or relay_release; finishing or releasing one guest leaves the others running. Always call relay_finish or relay_release explicitly for every guest before you return an answer; ending the session never finishes a guest: it pauses lease renewal and keeps the VMs or, where the relay is set up to, releases them, and the backend's own expiry is the last-resort safeguard. A refused, uncertain or nonzero operation keeps the VM so you can diagnose and submit a corrected operation; never replay input whose effect is uncertain. A tool result, an attached image or a verified evidence package, is evidence for a human reviewer, never the review itself. The relay never targets a physical or local display and offers no video or spawn API. Every tool's text result is capped at 50 KiB / 2000 lines; a larger result is retained whole in a local file the result names.";
28759
+ var instructions = "This server offers fourteen tools for guests, VMs that run the work you choose to run there: relay_search, relay_probe, relay_acquisition_capabilities, relay_acquire, relay_stage, the run tool relay_script, relay_image, relay_extract, relay_finish, relay_release, relay_console_resolve, relay_console_open, relay_console_cancel and relay_status. relay_script runs a shell, JavaScript, TypeScript or Python script, given inline or as a project file; a command is a shell script, and the script drives whatever the image lists, such as cua-driver, Playwright or Chrome DevTools, through their own libraries or command lines. Staging needs only Node.js in the guest, and a run takes before and after snapshots only when the image lists capture software (cua-driver). Evidence is automatic, and a run's after-image is returned as pending and downloaded in the background, so call relay_image with the imageId when you need to see it. Acquire one guest for each machine your work needs; several guests may run at once, up to the session's limit that relay_status reports. relay_acquire answers each guest's name, `guest`, and every call that acts on a guest names it with `guest`. Calls on different guests run at the same time; calls on one guest keep their order. Work each guest in order: relay_probe, then relay_acquire, then relay_stage, then relay_script, then relay_image or relay_extract as needed, then relay_finish or relay_release; finishing or releasing one guest leaves the others running. Always call relay_finish or relay_release explicitly for every guest before you return an answer; ending the session never finishes a guest: it pauses lease renewal and keeps the VMs or, where the relay is set up to, releases them, and the backend's own expiry is the last-resort safeguard. A refused, uncertain or nonzero operation keeps the VM so you can diagnose and submit a corrected operation; never replay input whose effect is uncertain. A tool result, an attached image or a verified evidence package, is evidence for a human reviewer, never the review itself. The relay never targets a physical or local display and offers no video or spawn API. Every tool's text result is capped at 50 KiB / 2000 lines; a larger result is retained whole in a local file the result names.";
28749
28760
  var NO_OWNED_LEASE = "This session owns no lease: it holds no guest, so nothing was released. Each server process has its own session identity (a new random one unless MCP_RELAY_SESSION sets it); a lease acquired under another identity is not visible here. Restart the server with that MCP_RELAY_SESSION to reconcile and release it, or let the backend TTL expire it.";
28750
28761
  var RelayManager = class {
28751
28762
  constructor(options) {
@@ -28763,14 +28774,15 @@ var RelayManager = class {
28763
28774
  this.registry = options.registry ?? new Registry(this.environment ? { managedRoot: this.environment.profile.relayStateDir } : {});
28764
28775
  this.root = join13(this.environment?.profile.relayStateDir ?? options.stateRoot ?? relayStateRoot(), hash(options.sessionId).slice(0, 32));
28765
28776
  this.channel = {
28766
- exec: async (name, argv2, timeoutMs2 = 18e4, options2) => {
28767
- const result2 = await this.vm.exec(name, { argv: argv2, timeout: Math.ceil(timeoutMs2 / 1e3) }, { timeoutMs: options2?.timeoutMs ?? timeoutMs2 + 3e4, signal: options2?.signal });
28777
+ exec: async (name, argv, timeoutMs2 = 18e4, options2) => {
28778
+ const result2 = await this.vm.exec(name, { argv, timeout: Math.ceil(timeoutMs2 / 1e3) }, { timeoutMs: options2?.timeoutMs ?? timeoutMs2 + 3e4, signal: options2?.signal });
28768
28779
  return { stdout: result2.output, stderr: result2.output, code: result2.rc };
28769
28780
  },
28770
28781
  push: (name, local_path, remote_path) => this.vm.push(name, { local_path, remote_path }),
28771
28782
  pull: (name, remote_path, local_path, options2) => this.vm.pull(name, { remote_path, local_path }, options2)
28772
28783
  };
28773
28784
  }
28785
+ options;
28774
28786
  vm;
28775
28787
  environment;
28776
28788
  tartHome;
@@ -29214,6 +29226,8 @@ var Guest = class {
29214
29226
  this.restored = !record3;
29215
29227
  this.downloads = new DownloadQueue({ bound: m.options.downloadBound ?? DOWNLOAD_BOUND, record: (job) => this.recordDownload(job) });
29216
29228
  }
29229
+ m;
29230
+ name;
29217
29231
  /** `guests/<name>` in the session's state directory: the guest's `lease.json` and `owner.lock`. */
29218
29232
  dir;
29219
29233
  enclosure;
@@ -29335,15 +29349,17 @@ var Guest = class {
29335
29349
  async probe() {
29336
29350
  const e = this.current();
29337
29351
  const checks = [];
29338
- for (const [name, language2, argv2] of [["node", "javascript", [e.node ?? "node", "--version"]], ["tsx", "typescript", ["tsx", "--version"]], ["python3", "python", ["python3", "--version"]]]) {
29352
+ for (const [name, language2, argv] of [["node", "javascript", [e.node ?? "node", "--version"]], ["tsx", "typescript", ["tsx", "--version"]], ["python3", "python", ["python3", "--version"]], ["sh", "shell", ["/bin/sh", "-c", "exit 0"]]]) {
29339
29353
  const required2 = name === "node";
29340
29354
  try {
29341
- const r = await this.m.channel.exec(e.lease.vm, [...argv2], 1e4);
29355
+ const r = await this.m.channel.exec(e.lease.vm, [...argv], 1e4);
29342
29356
  checks.push({ name, language: language2, required: required2, ...r, ready: r.code === 0 });
29343
29357
  } catch (error2) {
29344
29358
  checks.push({ name, language: language2, required: required2, ready: false, diagnostic: String(error2) });
29345
29359
  }
29346
29360
  }
29361
+ const tsx = checks[1], nodeVersion = /^v(\d+)\.(\d+)/.exec(String(checks[0].stdout ?? ""));
29362
+ if (!tsx.ready && nodeVersion && (Number(nodeVersion[1]) > 22 || Number(nodeVersion[1]) === 22 && Number(nodeVersion[2]) >= 6)) Object.assign(tsx, { ready: true, runsWith: "Node.js type stripping" });
29347
29363
  let software;
29348
29364
  try {
29349
29365
  const catalog = await this.m.vm.applications({ timeoutMs: 1e4 });
@@ -29354,7 +29370,7 @@ var Guest = class {
29354
29370
  software = { image: e.image, diagnostic: `The image catalog could not be read: ${message(error2)}` };
29355
29371
  }
29356
29372
  const snapshots2 = e.capture === void 0 && !e.staged ? { taken: null, reason: "Decided at relay_stage: runs take snapshots only when the image lists capture software (cua-driver)." } : this.snapshotFacts(e);
29357
- const facts = { scope: "guest", guest: this.name, observedAt: (/* @__PURE__ */ new Date()).toISOString(), owned: this.status(), checks, software, snapshots: snapshots2, note: "A ready runtime means its --version exited 0. Listed software is what the catalog says the image holds; it never proves that a program runs, that a browser renders on the display or that capture works.", captureVerified: false, browserVerified: false };
29373
+ const facts = { scope: "guest", guest: this.name, observedAt: (/* @__PURE__ */ new Date()).toISOString(), owned: this.status(), checks, software, snapshots: snapshots2, note: "A ready runtime means its --version, or for /bin/sh `exit 0`, exited 0. Listed software is what the catalog says the image holds; it never proves that a program runs, that a browser renders on the display or that capture works.", captureVerified: false, browserVerified: false };
29358
29374
  await this.log("guest-readiness", void 0, facts);
29359
29375
  return facts;
29360
29376
  }
@@ -29669,7 +29685,7 @@ VM state: ${JSON.stringify(this.status())}`, { cause: error2 });
29669
29685
  const e = this.current();
29670
29686
  if (e.delivered) throw new Error("Evidence already sealed; release this VM explicitly");
29671
29687
  if (input.resetRecording || e.pendingReset) await this.resetRecording();
29672
- if (e.staged && (input.workspace || input.files?.length)) throw new Error("Runtime already staged; use relay_command with diagnostic: true for repairs, or stage with only corrected executable paths");
29688
+ if (e.staged && (input.workspace || input.files?.length)) throw new Error("Runtime already staged; use a shell relay_script with diagnostic: true for repairs, or stage with only corrected executable paths");
29673
29689
  const project = resolve9(this.m.options.project);
29674
29690
  const files = [];
29675
29691
  for (const file of input.files ?? []) files.push({ local: await this.m.projectPath(file.local, "files[].local"), path: file.path });
@@ -29687,8 +29703,10 @@ VM state: ${JSON.stringify(this.status())}`, { cause: error2 });
29687
29703
  } catch (error2) {
29688
29704
  throw new Error(`relay_stage needs Node.js in the guest to run the relay's own code, and \`${node2} --version\` failed: ${error2 instanceof Error ? error2.message : String(error2)}. The relay pushes no runtime, so an image without Node.js cannot be staged; choose an image that lists Node.js (relay_search), or name the guest's Node.js with nodePath.`, { cause: error2 });
29689
29705
  }
29706
+ const cuaDriver = input.cuaDriver ?? e.cuaDriver ?? (e.lease.image_kind === "macos" ? "/Applications/CuaDriver.app/Contents/MacOS/cua-driver" : "cua-driver");
29707
+ if (e.capture !== false) await this.awaitCapture(transfer, e, node2, cuaDriver, signal);
29690
29708
  e.node = node2;
29691
- e.cuaDriver = input.cuaDriver ?? e.cuaDriver ?? (e.lease.image_kind === "macos" ? "/Applications/CuaDriver.app/Contents/MacOS/cua-driver" : "cua-driver");
29709
+ e.cuaDriver = cuaDriver;
29692
29710
  await this.save();
29693
29711
  if (e.staged) {
29694
29712
  await this.session?.close();
@@ -29727,6 +29745,37 @@ VM state: ${JSON.stringify(this.status())}`, { cause: error2 });
29727
29745
  await this.log("capture-software", void 0, { image: e.image, capture, ids: CAPTURE_SOFTWARE });
29728
29746
  return capture;
29729
29747
  }
29748
+ /**
29749
+ * Waits until the guest's cua-driver takes a screenshot, as each run's
29750
+ * snapshots do (DC-24). The image starts its daemon at login, which can
29751
+ * follow the guest's readiness, so the first runs would otherwise be refused.
29752
+ */
29753
+ async awaitCapture(transfer, e, node2, cuaDriver, signal) {
29754
+ const probe = join13(e.guestRoot, "state", ".stage-capture-probe.png");
29755
+ const waitMs = this.m.options.captureReadyWaitMs ?? CAPTURE_READY_WAIT_MS, retryMs = this.m.options.captureReadyRetryMs ?? CAPTURE_READY_RETRY_MS;
29756
+ const since = Date.now();
29757
+ await transfer.checked(["/bin/mkdir", "-p", join13(e.guestRoot, "state")], void 0, signal);
29758
+ for (let attempt = 1; ; attempt++) {
29759
+ try {
29760
+ await transfer.checked([cuaDriver, "call", "get_desktop_state", "--json", JSON.stringify({ screenshot_out_file: probe })], 6e4, signal);
29761
+ await transfer.checked([node2, "-e", 'require("node:fs").rmSync(process.argv[1], { force: true })', probe], void 0, signal);
29762
+ if (attempt > 1) await this.log("capture-ready", void 0, { waitedMs: Date.now() - since, attempts: attempt });
29763
+ return;
29764
+ } catch (error2) {
29765
+ if (signal?.aborted) throw error2;
29766
+ const waited = Date.now() - since;
29767
+ if (waited + retryMs > waitMs) throw new Error(`relay_stage waited ${Math.round(waited / 1e3)} s for ${e.image}'s cua-driver to take a screenshot, which each run's before and after snapshots need, and it never did: ${message(error2)}. Diagnose or start it with a shell relay_script and diagnostic: true, such as \`${cuaDriver} serve\` on Linux, then call relay_stage again.`, { cause: error2 });
29768
+ await new Promise((done) => {
29769
+ const timer = setTimeout(done, retryMs);
29770
+ signal?.addEventListener("abort", () => {
29771
+ clearTimeout(timer);
29772
+ done();
29773
+ }, { once: true });
29774
+ });
29775
+ if (signal?.aborted) throw error2;
29776
+ }
29777
+ }
29778
+ }
29730
29779
  /** What a lease's runs record: snapshots when its image lists cua-driver, none otherwise. */
29731
29780
  snapshotFacts(e) {
29732
29781
  return e.capture === false ? { taken: false, reason: `${e.image} lists no capture software (cua-driver), so runs take no snapshots and their records have none.` } : { taken: true, reason: e.capture ? `${e.image} lists cua-driver, so each run takes before and after snapshots.` : "This lease predates the capture decision, so each run takes before and after snapshots." };
@@ -29735,11 +29784,11 @@ VM state: ${JSON.stringify(this.status())}`, { cause: error2 });
29735
29784
  const e = this.current();
29736
29785
  const timeoutMs2 = input.timeoutMs ?? 12e4;
29737
29786
  if (!Number.isSafeInteger(timeoutMs2) || timeoutMs2 < 1 || timeoutMs2 > 36e5) throw new Error("timeoutMs must be an integer from 1 to 3600000");
29738
- if (input.diagnostic && input.kind !== "exec") throw new Error("diagnostic is only supported for relay_command");
29787
+ if (input.diagnostic && input.language !== "shell") throw new Error("Only a shell script may be diagnostic, because a diagnostic run goes through vm-service without the receiver");
29739
29788
  if (e.delivered) throw new Error("Evidence already sealed; release this VM explicitly");
29740
29789
  if (input.diagnostic) return this.diagnostic(input, timeoutMs2, signal);
29741
- if (e.pendingReset) throw new Error("Recording reset is pending; retry stage to reconcile it, or use relay_command with diagnostic: true");
29742
- if (!e.staged || !this.session || !this.transport) throw new Error("Use relay_stage before a run, or relay_command with diagnostic: true for setup diagnosis and repair");
29790
+ if (e.pendingReset) throw new Error("Recording reset is pending; retry stage to reconcile it, or use a shell relay_script with diagnostic: true");
29791
+ if (!e.staged || !this.session || !this.transport) throw new Error("Use relay_stage before a run, or a shell relay_script with diagnostic: true for setup diagnosis and repair");
29743
29792
  const record3 = this.derive(e, input);
29744
29793
  await this.save();
29745
29794
  this.transport.because = record3.because;
@@ -29748,20 +29797,14 @@ VM state: ${JSON.stringify(this.status())}`, { cause: error2 });
29748
29797
  this.transport.signal = signal;
29749
29798
  const options = { step: record3.step, snapshots: record3.snapshots, cwd: join13(e.guestRoot, "workspace") };
29750
29799
  let result2;
29751
- if (input.kind === "exec") {
29752
- if (!input.argv?.length) throw new Error("relay_command requires argv");
29753
- result2 = await this.session.exec(input.argv, options);
29754
- } else if (input.kind === "script") {
29755
- if (!input.language) throw new Error("relay_script requires language");
29756
- if (input.inline) {
29757
- if (typeof input.code !== "string" || input.localPath !== void 0) throw new Error("relay_script with inline: true takes the script as code, and no localPath");
29758
- result2 = await this.session.runCode(input.code, input.language, options);
29759
- } else {
29760
- if (!input.localPath || input.code !== void 0) throw new Error("relay_script with inline: false takes the script file as localPath, and no code");
29761
- const local = await this.m.projectPath(input.localPath, "localPath");
29762
- result2 = await this.session.runScript(local, join13(e.guestRoot, "scripts", `${randomUUID6()}.${input.language === "python" ? "py" : input.language === "typescript" ? "ts" : "js"}`), input.language, options);
29763
- }
29764
- } else throw new Error("Unknown operation kind");
29800
+ if (input.inline) {
29801
+ if (typeof input.code !== "string" || input.localPath !== void 0) throw new Error("relay_script with inline: true takes the script as code, and no localPath");
29802
+ result2 = await this.session.runCode(input.code, input.language, options);
29803
+ } else {
29804
+ if (!input.localPath || input.code !== void 0) throw new Error("relay_script with inline: false takes the script file as localPath, and no code");
29805
+ const local = await this.m.projectPath(input.localPath, "localPath");
29806
+ result2 = await this.session.runScript(local, join13(e.guestRoot, "scripts", `${randomUUID6()}.${SCRIPT_EXTENSIONS[input.language]}`), input.language, options);
29807
+ }
29765
29808
  const outcome = result2.outcome;
29766
29809
  if (outcome.kind !== "completed" || outcome.exitStatus.code !== 0 || outcome.exitStatus.signal) {
29767
29810
  await this.log("execution-failed", record3.because, result2);
@@ -29776,19 +29819,20 @@ VM state: ${JSON.stringify(this.status())}`, { cause: error2 });
29776
29819
  }
29777
29820
  /**
29778
29821
  * The step record for a run, from the call itself: a title such as
29779
- * `exec node -e …`, an expected result, an input mode, a default
29822
+ * `shell ls -al`, `code (python)` or `script check.py`, an expected result, an input mode, a default
29780
29823
  * after-snapshot wait and a reason. Anything the caller gave overrides it.
29781
29824
  */
29782
29825
  derive(e, input) {
29783
29826
  const seq = e.runSeq = (e.runSeq ?? 0) + 1;
29784
29827
  const stepId2 = (prefix) => `${prefix.replace(/[^A-Za-z0-9_.-]+/g, "-").replace(/^[^A-Za-z0-9]+/, "").slice(0, 100) || "run"}-${seq}`;
29785
- const title = input.step?.title ?? (input.kind === "exec" ? `exec ${(input.argv ?? []).map((arg, index) => index === 0 ? arg.split("/").at(-1) : arg).join(" ")}` : input.inline ? `code (${input.language ?? "unknown"})` : `script ${input.localPath?.split("/").at(-1) ?? ""}`).slice(0, 500);
29828
+ const firstLine = input.code?.split("\n").find((line) => line.trim())?.trim();
29829
+ const title = input.step?.title ?? (input.inline ? input.language === "shell" && firstLine ? `shell ${firstLine}` : `code (${input.language})` : `script ${input.localPath?.split("/").at(-1) ?? ""}`).slice(0, 500);
29786
29830
  const snapshots2 = { ...input.snapshots ?? {} };
29787
29831
  const group = snapshots2.group;
29788
29832
  if (!group ? snapshots2.afterIntervalMs === void 0 : group.phase === "last" && group.afterIntervalMs === void 0 && snapshots2.afterIntervalMs === void 0) Object.assign(snapshots2, { afterIntervalMs: DEFAULT_AFTER_INTERVAL_MS });
29789
29833
  return {
29790
29834
  because: input.because ?? `Relay ${title} (no reason given)`.slice(0, 4e3),
29791
- step: { id: input.step?.id ?? stepId2(input.kind === "exec" ? "exec" : input.inline ? "code" : "script"), title: title || input.kind, expected: input.step?.expected ?? "Exits with status 0", inputMode: input.step?.inputMode ?? "ordinary" },
29835
+ step: { id: input.step?.id ?? stepId2(input.inline ? "code" : "script"), title: title || "script", expected: input.step?.expected ?? "Exits with status 0", inputMode: input.step?.inputMode ?? "ordinary" },
29792
29836
  snapshots: snapshots2
29793
29837
  };
29794
29838
  }
@@ -30116,15 +30160,17 @@ VM state: ${JSON.stringify(this.status())}`, { cause: error2 });
30116
30160
  }
30117
30161
  async diagnostic(input, timeoutMs2, signal) {
30118
30162
  const e = this.current();
30119
- if (!input.argv?.length || input.snapshots?.group) throw new Error("Diagnostic exec requires argv and cannot join a snapshot group");
30163
+ if (input.language !== "shell" || input.snapshots?.group) throw new Error("A diagnostic run is a shell script and cannot join a snapshot group");
30164
+ const script = input.inline ? input.code : await readFile9(await this.m.projectPath(input.localPath ?? "", "localPath"), "utf8");
30165
+ if (typeof script !== "string") throw new Error("relay_script with inline: true takes the script as code, and no localPath");
30120
30166
  const executionId = `diagnostic-${randomUUID6()}`;
30121
30167
  const { guest: _guest, ...requested } = input;
30122
- const request = { executionId, at: (/* @__PURE__ */ new Date()).toISOString(), evidenceMode: "diagnostic", timeoutMs: timeoutMs2, ...requested };
30168
+ const argv = e.staged ? ["/bin/sh", "-c", 'cd "$1" || exit; shift; exec "$@"', "relay-diagnostic", join13(e.guestRoot, "workspace"), "/bin/sh", "-c", script] : ["/bin/sh", "-c", script];
30169
+ const request = { executionId, at: (/* @__PURE__ */ new Date()).toISOString(), evidenceMode: "diagnostic", timeoutMs: timeoutMs2, ...requested, argv };
30123
30170
  await jsonFile(join13(e.hostRoot, "host", "diagnostics", `${executionId}.request.json`), request);
30124
30171
  let result2;
30125
30172
  try {
30126
- const argv2 = e.staged ? ["/bin/sh", "-c", 'cd "$1" || exit; shift; exec "$@"', "relay-diagnostic", join13(e.guestRoot, "workspace"), ...input.argv] : input.argv;
30127
- const r = await this.m.channel.exec(e.lease.vm, argv2, timeoutMs2, { signal });
30173
+ const r = await this.m.channel.exec(e.lease.vm, argv, timeoutMs2, { signal });
30128
30174
  result2 = { executionId, outcome: { kind: "completed", exitStatus: { code: r.code, signal: null } }, output: r.stdout, outputStreams: "stdout and stderr combined" };
30129
30175
  } catch (error2) {
30130
30176
  result2 = { executionId, outcome: { kind: "uncertain", diagnostic: String(error2) }, output: "", outputStreams: "stdout and stderr combined" };
@@ -30308,8 +30354,7 @@ var imageTarget = typebox_exports.Union([
30308
30354
  typebox_exports.Object({ source: typebox_exports.Literal("application"), name: typebox_exports.String({ minLength: 1, maxLength: 101 }), path: typebox_exports.Optional(typebox_exports.String({ minLength: 1, maxLength: 4096 })) }, closed2),
30309
30355
  typebox_exports.Object({ source: typebox_exports.Literal("reference"), imageId: typebox_exports.String({ pattern: "^image-[a-f0-9]{64}$" }) }, closed2)
30310
30356
  ]);
30311
- var argv = typebox_exports.Array(typebox_exports.String(), { minItems: 1, maxItems: 256 });
30312
- var language = StringEnum(["javascript", "typescript", "python"]);
30357
+ var language = StringEnum(["shell", "javascript", "typescript", "python"]);
30313
30358
  var timeoutMs = typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, maximum: 36e5, description: "Execution timeout in milliseconds, default 120000, maximum 3600000. Independent of snapshot delay and lease TTL." }));
30314
30359
  var runBase = { action: typebox_exports.Literal("run"), guest, reason: optionalReason, step: typebox_exports.Optional(step), snapshots: typebox_exports.Optional(snapshots), timeoutMs };
30315
30360
  var relayContract = typebox_exports.Union([
@@ -30338,15 +30383,14 @@ var relayContract = typebox_exports.Union([
30338
30383
  nodePath: typebox_exports.Optional(typebox_exports.String({ description: "Guest Node executable, default node; use image nvm path if needed." })),
30339
30384
  cuaDriver: typebox_exports.Optional(typebox_exports.String({ description: "Guest CUA executable; OS default when omitted." }))
30340
30385
  }, closed2),
30341
- typebox_exports.Object({ ...runBase, kind: typebox_exports.Literal("exec"), argv, diagnostic: typebox_exports.Optional(typebox_exports.Boolean({ description: "Explicit command diagnosis or repair without screenshot evidence, including before staging. Commands and outcomes remain recorded. Never claim visual verification." })) }, closed2),
30342
- // One branch for relay_script: `inline` selects which of `code` and `localPath` the call gives, checked in validateRelayInput.
30386
+ // The one run branch, relay_script (DC-26): `inline` selects which of `code` and `localPath` the call gives, and `diagnostic` needs `shell`, both checked in validateRelayInput.
30343
30387
  typebox_exports.Object({
30344
30388
  ...runBase,
30345
- kind: typebox_exports.Literal("script"),
30346
30389
  language,
30347
30390
  inline: typebox_exports.Boolean({ description: "true: the script is `code`, given inline. false: the script is the host file `localPath`. Give exactly the one that inline names." }),
30348
30391
  code: typebox_exports.Optional(typebox_exports.String({ maxLength: 1048576, description: "With inline: true, the script itself, up to 1 MiB." })),
30349
- localPath: typebox_exports.Optional(typebox_exports.String({ minLength: 1, description: "With inline: false, a host script file in the project folder: relative to it, or absolute inside it; no symlinks." }))
30392
+ localPath: typebox_exports.Optional(typebox_exports.String({ minLength: 1, description: "With inline: false, a host script file in the project folder: relative to it, or absolute inside it; no symlinks." })),
30393
+ diagnostic: typebox_exports.Optional(typebox_exports.Boolean({ description: "Shell scripts only: explicit diagnosis or repair without screenshot evidence, including before staging. The script and its outcome remain recorded. Never claim visual verification." }))
30350
30394
  }, closed2),
30351
30395
  typebox_exports.Object({ action: typebox_exports.Literal("image"), guest, target: imageTarget }, closed2),
30352
30396
  typebox_exports.Object({ action: typebox_exports.Literal("extract"), guest, names: typebox_exports.Array(typebox_exports.String()) }, closed2),
@@ -30364,28 +30408,25 @@ for (const branch of relayContract.anyOf) {
30364
30408
  var parameterObject = typebox_exports.Object({
30365
30409
  action: StringEnum(["search", "probe", "acquire", "stage", "run", "image", "extract", "finish", "release", "acquisition-capabilities", "console-resolve", "console-open", "console-cancel"]),
30366
30410
  ...projected
30367
- }, { ...closed2, anyOf: relayContract.anyOf, description: "Select exactly one action. Each closed branch defines allowed fields. Run selects a kind; console-open requires reason, expected and userRequested=true. No default action." });
30411
+ }, { ...closed2, anyOf: relayContract.anyOf, description: "Select exactly one action. Each closed branch defines allowed fields. Run takes a script; console-open requires reason, expected and userRequested=true. No default action." });
30368
30412
  var relayParameters = typebox_exports.Unsafe(parameterObject);
30369
- function branchFor(action, kind) {
30370
- const found = relayContract.anyOf.find((branch) => {
30371
- const properties = branch.properties;
30372
- if (properties.action.const !== action) return false;
30373
- return kind === void 0 ? properties.kind === void 0 : properties.kind?.const === kind;
30374
- });
30375
- if (!found) throw new Error(`No contract branch for action ${action}${kind ? ` kind ${kind}` : ""}`);
30413
+ function branchFor(action) {
30414
+ const found = relayContract.anyOf.find((branch) => branch.properties.action.const === action);
30415
+ if (!found) throw new Error(`No contract branch for action ${action}`);
30376
30416
  return found;
30377
30417
  }
30378
- function toolInputSchema(action, kind) {
30379
- const raw = JSON.parse(JSON.stringify(branchFor(action, kind)));
30380
- const { action: _action, kind: _kind, ...properties } = raw.properties;
30381
- const required2 = (raw.required ?? []).filter((key) => key !== "action" && key !== "kind");
30418
+ function toolInputSchema(action) {
30419
+ const raw = JSON.parse(JSON.stringify(branchFor(action)));
30420
+ const { action: _action, ...properties } = raw.properties;
30421
+ const required2 = (raw.required ?? []).filter((key) => key !== "action");
30382
30422
  return { type: raw.type, properties, ...required2.length ? { required: required2 } : {}, additionalProperties: raw.additionalProperties ?? false };
30383
30423
  }
30384
30424
  function validateRelayInput(value) {
30385
- if (!Check2(relayContract, value)) throw new Error("Invalid relay input: action is required; a call that acts on a guest names it with guest, the name relay_acquire answered; console-open requires nonblank reason. Supply only the fields for the selected action and run kind.");
30425
+ if (!Check2(relayContract, value)) throw new Error("Invalid relay input: action is required; a call that acts on a guest names it with guest, the name relay_acquire answered; console-open requires nonblank reason. Supply only the fields for the selected action.");
30386
30426
  if (value.action === "probe" && value.scope === "guest" && value.guest === void 0) throw new Error('Invalid relay input: relay_probe with scope "guest" names the guest to probe with guest, the name relay_acquire answered.');
30387
- if (value.action === "run" && value.kind === "exec" && value.diagnostic && value.snapshots?.group) throw new Error("Diagnostic commands cannot join snapshot groups.");
30388
- if (value.action === "run" && value.kind === "script") {
30427
+ if (value.action === "run") {
30428
+ if (value.diagnostic && value.language !== "shell") throw new Error("Invalid relay input: only a shell script may be diagnostic, because a diagnostic run goes through vm-service without the receiver.");
30429
+ if (value.diagnostic && value.snapshots?.group) throw new Error("Diagnostic scripts cannot join snapshot groups.");
30389
30430
  const given = value.inline ? value.code : value.localPath, other = value.inline ? value.localPath : value.code;
30390
30431
  if (given === void 0 || other !== void 0) throw new Error(value.inline ? "Invalid relay input: relay_script with inline: true takes the script as code, and no localPath." : "Invalid relay input: relay_script with inline: false takes the script file as localPath, and no code.");
30391
30432
  }
@@ -30398,7 +30439,6 @@ import { tmpdir as tmpdir2 } from "node:os";
30398
30439
  import { randomUUID as randomUUID7 } from "node:crypto";
30399
30440
  var readOnly = { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false };
30400
30441
  var acts = (openWorld, destructive = false) => ({ readOnlyHint: false, destructiveHint: destructive, idempotentHint: false, openWorldHint: openWorld });
30401
- var runShared = "Evidence is automatic, as for relay_command, whose optional `reason`, `step`, `snapshots` and `timeoutMs` it shares.";
30402
30442
  var relayTools = [
30403
30443
  {
30404
30444
  name: "relay_search",
@@ -30412,7 +30452,7 @@ var relayTools = [
30412
30452
  action: "probe",
30413
30453
  title: "Probe host and guest readiness",
30414
30454
  annotations: readOnly,
30415
- description: 'Read-only host and service facts, used to pick an image; it reports current owned state on its own, so call it again after context compaction rather than trusting earlier messages. Default `scope: "host"` reports host permissions and activity, VM service availability, and every guest this session holds with its state, not guest readiness. `scope: "guest"` with `guest` (an already-acquired guest) reports whether Node.js, which staging requires, is available, and, as facts, whether each relay_script language\'s runtime runs (`node`, `tsx`, `python3`), the software the image lists in the catalog, and whether this lease\'s runs take snapshots, without installing or starting anything, and never claims capture readiness. Acquire one guest for each machine the work needs; several may run at once. Continue each guest in order: relay_acquire, relay_stage, relay_command or relay_script, relay_image/relay_extract, then relay_finish or relay_release, called explicitly for every guest before you return.'
30455
+ description: 'Read-only host and service facts, used to pick an image; it reports current owned state on its own, so call it again after context compaction rather than trusting earlier messages. Default `scope: "host"` reports host permissions and activity, VM service availability, and every guest this session holds with its state, not guest readiness. `scope: "guest"` with `guest` (an already-acquired guest) reports whether Node.js, which staging requires, is available, and, as facts, whether each relay_script language\'s runtime runs (`/bin/sh`, `node`, `tsx`, `python3`), the software the image lists in the catalog, and whether this lease\'s runs take snapshots, without installing or starting anything, and never claims capture readiness. Acquire one guest for each machine the work needs; several may run at once. Continue each guest in order: relay_acquire, relay_stage, relay_script, relay_image/relay_extract, then relay_finish or relay_release, called explicitly for every guest before you return.'
30416
30456
  },
30417
30457
  {
30418
30458
  name: "relay_acquisition_capabilities",
@@ -30426,30 +30466,21 @@ var relayTools = [
30426
30466
  action: "acquire",
30427
30467
  title: "Acquire a VM",
30428
30468
  annotations: acts(false),
30429
- description: "Acquire one fresh VM, a guest, and start its ownership heartbeat. The result's `guest` is the guest's name in this session, such as `login-test-1`; every later call on this guest names it with `guest`. Requires `task` (a short slug), `image` (a key from relay_probe or relay_search) and `extractions`: every output you intend to bring home, declared before any work (`[]` is allowed; nothing is extracted automatically). Optional `ttlHours` (default 4), `env` (a credential pack, never baked into images), `fullWorkspace` (opt in to deliver the whole workspace) and `vnc` (default false; only prepares console-sharing capacity, never opens a viewer). Acquire one guest for each machine the work needs: several guests may run at once, each with its own lease, evidence and finish, up to the session's limit (relay_status reports `maxGuests`, MCP_RELAY_MAX_GUESTS, default 4); an acquisition beyond it is refused with the names of the guests held. When the host is at capacity, such as at its limit on running macOS VMs, the acquisition waits for it, asking again every 15 s for up to MCP_RELAY_CAPACITY_WAIT (30 minutes by default), and the result's `waitedForCapacityMs` says how long it waited; once the wait runs out it is refused with the backend's reason and the time waited. The backend's other refusals pass through at once. Continue with relay_stage, relay_command or relay_script, relay_image/relay_extract, then relay_finish or relay_release explicitly before you return; a failed step keeps the VM for repair rather than replaying uncertain input."
30469
+ description: "Acquire one fresh VM, a guest, and start its ownership heartbeat. The result's `guest` is the guest's name in this session, such as `login-test-1`; every later call on this guest names it with `guest`. Requires `task` (a short slug), `image` (a key from relay_probe or relay_search) and `extractions`: every output you intend to bring home, declared before any work (`[]` is allowed; nothing is extracted automatically). Optional `ttlHours` (default 4), `env` (a credential pack, never baked into images), `fullWorkspace` (opt in to deliver the whole workspace) and `vnc` (default false; only prepares console-sharing capacity, never opens a viewer). Acquire one guest for each machine the work needs: several guests may run at once, each with its own lease, evidence and finish, up to the session's limit (relay_status reports `maxGuests`, MCP_RELAY_MAX_GUESTS, default 4); an acquisition beyond it is refused with the names of the guests held. When the host is at capacity, such as at its limit on running macOS VMs, the acquisition waits for it, asking again every 15 s for up to MCP_RELAY_CAPACITY_WAIT (30 minutes by default), and the result's `waitedForCapacityMs` says how long it waited; once the wait runs out it is refused with the backend's reason and the time waited. The backend's other refusals pass through at once. Continue with relay_stage, relay_script, relay_image/relay_extract, then relay_finish or relay_release explicitly before you return; a failed step keeps the VM for repair rather than replaying uncertain input."
30430
30470
  },
30431
30471
  {
30432
30472
  name: "relay_stage",
30433
30473
  action: "stage",
30434
30474
  title: "Stage the guest runtime",
30435
30475
  annotations: acts(false),
30436
- description: "Push and hash-check the guest runtime, plus an optional workspace and support files (`files`, landing under `support/`), onto the acquired guest that `guest` names. `workspace` and each `files[].local` lie in the project folder, relative to it or absolute inside it, with no symlinks. Staging needs only Node.js in the guest (`nodePath`, default `node`); an image without it is refused, because the relay pushes no runtime. Runs take before and after snapshots only when the image lists capture software (cua-driver); otherwise their records have none, and the result's `snapshots` says which. `cuaDriver` names the guest cua-driver the snapshots use. A failed stage can be retried; once staged, only corrected executable paths may be resubmitted, and staging does not prove capture readiness. `resetRecording: true` archives the current recording's evidence and starts a fresh recording on the same VM; it refuses while a receiver lock is held."
30437
- },
30438
- {
30439
- name: "relay_command",
30440
- action: "run",
30441
- kind: "exec",
30442
- title: "Run a guest command",
30443
- annotations: acts(true),
30444
- description: "Run one guest command (`argv`) as one recorded operation; never hide several interactions in one call. Evidence is automatic: the relay records a step derived from the command and, when the image lists cua-driver, snapshots the display before and after. Optional `reason` (intent, never authorization), `step` (`id`, `title`, `expected`, `inputMode`) and `snapshots.afterIntervalMs` (default 500 ms) enrich or tune the record; consecutive keystrokes may form an explicit text group with `snapshots.group` (`first`/`member`/`last`). `timeoutMs` bounds execution (default 120000, up to 3600000). The result carries the outcome and bounded stdout/stderr; it names the after-snapshot as `pending` with its `imageId` while the image downloads in the background, so call relay_image with that `imageId` to see it. A refused, uncertain or nonzero result keeps the VM; never replay input whose effect is uncertain. `diagnostic: true` records a diagnosis or repair without snapshots, even before relay_stage; it is never visual verification, and its result has one `output` field with stdout and stderr combined."
30476
+ description: "Push and hash-check the guest runtime, plus an optional workspace and support files (`files`, landing under `support/`), onto the acquired guest that `guest` names. `workspace` and each `files[].local` lie in the project folder, relative to it or absolute inside it, with no symlinks. Staging needs only Node.js in the guest (`nodePath`, default `node`); an image without it is refused, because the relay pushes no runtime. Runs take before and after snapshots only when the image lists capture software (cua-driver); otherwise their records have none, and the result's `snapshots` says which. When the image lists cua-driver, staging waits up to 120 s for it to take a screenshot, since the image starts its daemon at login, and refuses if it never does. `cuaDriver` names the guest cua-driver the snapshots use. A failed stage can be retried; once staged, only corrected executable paths may be resubmitted, and staging does not prove capture readiness. `resetRecording: true` archives the current recording's evidence and starts a fresh recording on the same VM; it refuses while a receiver lock is held."
30445
30477
  },
30446
30478
  {
30447
30479
  name: "relay_script",
30448
30480
  action: "run",
30449
- kind: "script",
30450
30481
  title: "Run a guest script",
30451
30482
  annotations: acts(true),
30452
- description: `Run one guest script as this call's single recorded operation; the script drives whatever the image lists, such as cua-driver, Playwright or Chrome DevTools, through their own libraries or command lines. ${runShared} Requires \`language\` (\`javascript\`, \`typescript\` or \`python\`) and \`inline\`: with \`inline: true\` give the script itself as \`code\` (up to 1 MiB); with \`inline: false\` give \`localPath\`, a host file in the project folder (relative to it or absolute inside it, with no symlinks). Give exactly the one \`inline\` names; any other call is refused. It runs in the staged workspace: JavaScript with the guest's Node.js, TypeScript with \`tsx\` and Python with \`python3\` from the guest's PATH (relay_probe scope=guest reports which run).`
30483
+ description: "Run one guest script as one recorded operation; never hide several interactions in one call. A command is a shell script. The script drives whatever the image lists, such as cua-driver, Playwright or Chrome DevTools, through their own libraries or command lines, and its exit status says whether it succeeded, so a script that calls cua-driver checks the driver's answer itself. Requires `language` (`shell`, `javascript`, `typescript` or `python`) and `inline`: with `inline: true` give the script itself as `code` (up to 1 MiB); with `inline: false` give `localPath`, a host file in the project folder (relative to it or absolute inside it, with no symlinks). Give exactly the one `inline` names; any other call is refused. It runs in the staged workspace: shell with `/bin/sh`, JavaScript with the guest's Node.js, TypeScript with `tsx` from the guest's PATH or else the guest Node.js's own type stripping (22.6 or later), and Python with `python3` from the guest's PATH (relay_probe scope=guest reports which run); a missing runtime refuses the run before it starts. Evidence is automatic: the relay records a step derived from the call and, when the image lists cua-driver, snapshots the display before and after. Optional `reason` (intent, never authorization), `step` (`id`, `title`, `expected`, `inputMode`) and `snapshots.afterIntervalMs` (default 500 ms) enrich or tune the record; consecutive keystrokes may form an explicit text group with `snapshots.group` (`first`/`member`/`last`). `timeoutMs` bounds execution (default 120000, up to 3600000). The result carries the outcome and bounded stdout/stderr; it names the after-snapshot as `pending` with its `imageId` while the image downloads in the background, so call relay_image with that `imageId` to see it. A refused, uncertain or nonzero result keeps the VM; never replay input whose effect is uncertain. `diagnostic: true`, for shell scripts only, records a diagnosis or repair without snapshots, even before relay_stage, running the script as `/bin/sh -c`; it is never visual verification, and its result has one `output` field with stdout and stderr combined."
30453
30484
  },
30454
30485
  {
30455
30486
  name: "relay_image",
@@ -30502,12 +30533,12 @@ var relayTools = [
30502
30533
  }
30503
30534
  ];
30504
30535
  function relayToolInputSchema(tool) {
30505
- return toolInputSchema(tool.action, tool.kind);
30536
+ return toolInputSchema(tool.action);
30506
30537
  }
30507
30538
  function relayToolInput(name, args) {
30508
30539
  const tool = relayTools.find((candidate) => candidate.name === name);
30509
30540
  if (!tool) throw new Error(`Unknown relay tool: ${name}`);
30510
- return { action: tool.action, ...tool.kind ? { kind: tool.kind } : {}, ...args };
30541
+ return { action: tool.action, ...args };
30511
30542
  }
30512
30543
  var relayResultKind = "relay-image-result-v1";
30513
30544
  async function renderRelayResult(value, resultRoot = join14(tmpdir2(), "mcp-relay-results"), indent = 2) {
@@ -30597,7 +30628,7 @@ async function relayCall(host, raw, options = {}) {
30597
30628
 
30598
30629
  // src/server.ts
30599
30630
  var SERVER_NAME = "relay";
30600
- var SERVER_VERSION = true ? "0.14.1" : JSON.parse(readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf8")).version;
30631
+ var SERVER_VERSION = true ? "0.15.0" : JSON.parse(readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf8")).version;
30601
30632
  var STATUS_TOOL = "relay_status";
30602
30633
  var PLUGIN_TOOL_PREFIX = "mcp__plugin_mcp-relay_relay__";
30603
30634
  var message2 = (error2) => error2 instanceof Error ? error2.message : String(error2);