cvm-server 0.16.0-next.1 → 0.16.0-next.3

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/main.cjs CHANGED
@@ -43,7 +43,7 @@ function n(T2) {
43
43
  function t(T2) {
44
44
  return T2 === null;
45
45
  }
46
- function S$1(T2) {
46
+ function S(T2) {
47
47
  return T2 !== null && typeof T2 == "object" && "type" in T2 && T2.type === "array";
48
48
  }
49
49
  function I$1(T2) {
@@ -59,15 +59,15 @@ function c(T2) {
59
59
  return T2 !== null && typeof T2 == "object" && "type" in T2 && T2.type === "object-ref";
60
60
  }
61
61
  function u(T2) {
62
- return _$1(T2) ? T2 : E$2(T2) || n(T2) ? T2.toString() : t(T2) ? "null" : I$1(T2) ? "undefined" : S$1(T2) ? `[array:${T2.elements.length}]` : i(T2) ? "[object Object]" : String(T2);
62
+ return _$1(T2) ? T2 : E$2(T2) || n(T2) ? T2.toString() : t(T2) ? "null" : I$1(T2) ? "undefined" : S(T2) ? `[array:${T2.elements.length}]` : i(T2) ? "[object Object]" : String(T2);
63
63
  }
64
64
  function M$2(T2) {
65
- return n(T2) ? T2 : t(T2) || I$1(T2) ? false : E$2(T2) ? T2 !== 0 : _$1(T2) ? T2 !== "" : S$1(T2) || i(T2) ? true : !!T2;
65
+ return n(T2) ? T2 : t(T2) || I$1(T2) ? false : E$2(T2) ? T2 !== 0 : _$1(T2) ? T2 !== "" : S(T2) || i(T2) ? true : !!T2;
66
66
  }
67
67
  function y$1(T2) {
68
- return _$1(T2) ? "string" : E$2(T2) ? "number" : n(T2) ? "boolean" : t(T2) ? "null" : I$1(T2) ? "undefined" : S$1(T2) || L$1(T2) ? "array" : i(T2) || c(T2) ? "object" : "unknown";
68
+ return _$1(T2) ? "string" : E$2(T2) ? "number" : n(T2) ? "boolean" : t(T2) ? "null" : I$1(T2) ? "undefined" : S(T2) || L$1(T2) ? "array" : i(T2) || c(T2) ? "object" : "unknown";
69
69
  }
70
- function F$1(T2) {
70
+ function F$2(T2) {
71
71
  if (E$2(T2)) return T2;
72
72
  if (n(T2)) return T2 ? 1 : 0;
73
73
  if (t(T2)) return 0;
@@ -76,9 +76,9 @@ function F$1(T2) {
76
76
  const R2 = T2.trim();
77
77
  return R2 === "" ? 0 : Number(R2);
78
78
  }
79
- return S$1(T2) ? NaN : Number(T2);
79
+ return S(T2) ? NaN : Number(T2);
80
80
  }
81
- function Y$1(T2 = [], R2) {
81
+ function Y$2(T2 = [], R2) {
82
82
  return R2 ? { type: "array", elements: T2, properties: R2 } : { type: "array", elements: T2 };
83
83
  }
84
84
  function s() {
@@ -87,14 +87,14 @@ function s() {
87
87
  function b$2(T2 = {}) {
88
88
  return { type: "object", properties: T2 };
89
89
  }
90
- const f$2 = require("pino"), G$2 = require("fs"), D$2 = require("path");
90
+ const f$2 = require("pino"), G$2 = require("fs"), D$1 = require("path");
91
91
  let r = null;
92
- function U$1() {
92
+ function U$2() {
93
93
  if (!r) {
94
94
  const T2 = process.env.CVM_LOG_LEVEL || "info", R2 = process.env.CVM_LOG_FILE || ".cvm/cvm-debug.log";
95
95
  let N2;
96
96
  try {
97
- const A2 = D$2.dirname(R2);
97
+ const A2 = D$1.dirname(R2);
98
98
  G$2.existsSync(A2) || G$2.mkdirSync(A2, { recursive: true }), N2 = f$2.destination(R2);
99
99
  } catch {
100
100
  N2 = process.stdout;
@@ -107,11 +107,11 @@ function U$1() {
107
107
  }
108
108
  const g = new Proxy({}, {
109
109
  get(T2, R2) {
110
- return U$1()[R2];
110
+ return U$2()[R2];
111
111
  }
112
112
  });
113
- var d$3 = Object.defineProperty;
114
- var y = (t2, e, i2) => e in t2 ? d$3(t2, e, { enumerable: true, configurable: true, writable: true, value: i2 }) : t2[e] = i2;
113
+ var d$2 = Object.defineProperty;
114
+ var y = (t2, e, i2) => e in t2 ? d$2(t2, e, { enumerable: true, configurable: true, writable: true, value: i2 }) : t2[e] = i2;
115
115
  var h$1 = (t2, e, i2) => y(t2, typeof e != "symbol" ? e + "" : e, i2);
116
116
  function P(t2) {
117
117
  const e = [], i2 = [];
@@ -238,7 +238,7 @@ const k = (t2, e, { compileExpression: i2, compileStatement: s2 }) => {
238
238
  const l = e.currentAddress();
239
239
  e.patchJumps(m.endTargets, l);
240
240
  }
241
- }, A$1 = (t2, e, { compileExpression: i2, compileStatement: s2 }) => {
241
+ }, A$2 = (t2, e, { compileExpression: i2, compileStatement: s2 }) => {
242
242
  const a2 = e.currentAddress();
243
243
  i2(t2.expression);
244
244
  const m = {
@@ -345,7 +345,7 @@ const k = (t2, e, { compileExpression: i2, compileStatement: s2 }) => {
345
345
  const g2 = e.currentAddress();
346
346
  e.patchJumps(p2.breakTargets || [], g2), e.patchJumps(p2.continueTargets || [], l);
347
347
  }
348
- }, U = (t2, e, { compileExpression: i2, compileStatement: s2 }) => {
348
+ }, U$1 = (t2, e, { compileExpression: i2, compileStatement: s2 }) => {
349
349
  const a2 = e.generateTempVar();
350
350
  i2(t2.expression), e.emit(P$1.STORE, a2);
351
351
  const c2 = [], m = [];
@@ -444,7 +444,7 @@ const k = (t2, e, { compileExpression: i2, compileStatement: s2 }) => {
444
444
  s2.breakTargets = s2.breakTargets || [], s2.breakTargets.push(a2);
445
445
  } else
446
446
  i2.reportError(t2, "break statement not in loop");
447
- }, F = (t2, e, i2) => {
447
+ }, F$1 = (t2, e, i2) => {
448
448
  const s2 = e.findLoopContext();
449
449
  if (s2 && s2.startAddress !== void 0) {
450
450
  const a2 = e.emit(P$1.CONTINUE, -1);
@@ -453,22 +453,22 @@ const k = (t2, e, { compileExpression: i2, compileStatement: s2 }) => {
453
453
  i2.reportError(t2, "continue statement not in loop");
454
454
  }, L = {
455
455
  [r__namespace.SyntaxKind.IfStatement]: k,
456
- [r__namespace.SyntaxKind.WhileStatement]: A$1,
456
+ [r__namespace.SyntaxKind.WhileStatement]: A$2,
457
457
  [r__namespace.SyntaxKind.ForOfStatement]: I,
458
458
  [r__namespace.SyntaxKind.ForInStatement]: R,
459
459
  [r__namespace.SyntaxKind.ForStatement]: C$1,
460
- [r__namespace.SyntaxKind.SwitchStatement]: U,
460
+ [r__namespace.SyntaxKind.SwitchStatement]: U$1,
461
461
  [r__namespace.SyntaxKind.Block]: _,
462
462
  [r__namespace.SyntaxKind.VariableStatement]: b$1,
463
463
  [r__namespace.SyntaxKind.ExpressionStatement]: N,
464
464
  [r__namespace.SyntaxKind.ReturnStatement]: O,
465
465
  [r__namespace.SyntaxKind.BreakStatement]: K,
466
- [r__namespace.SyntaxKind.ContinueStatement]: F
466
+ [r__namespace.SyntaxKind.ContinueStatement]: F$1
467
467
  }, J$1 = (t2, e, i2) => {
468
468
  e.emit(P$1.PUSH, t2.text);
469
469
  }, H = (t2, e, i2) => {
470
470
  e.emit(P$1.PUSH, Number(t2.text));
471
- }, D$1 = (t2, e, i2) => {
471
+ }, D = (t2, e, i2) => {
472
472
  e.emit(P$1.PUSH, true);
473
473
  }, M$1 = (t2, e, i2) => {
474
474
  e.emit(P$1.PUSH, false);
@@ -479,15 +479,15 @@ const k = (t2, e, { compileExpression: i2, compileStatement: s2 }) => {
479
479
  e.emit(P$1.LOAD_REGEX, { pattern: c2, flags: m });
480
480
  }, q$1 = (t2, e, i2) => {
481
481
  t2.text === "undefined" ? e.emit(P$1.PUSH_UNDEFINED) : e.emit(P$1.LOAD, t2.text);
482
- }, B$1 = (t2, e, { compileExpression: i2 }) => {
482
+ }, B = (t2, e, { compileExpression: i2 }) => {
483
483
  e.emit(P$1.ARRAY_NEW), t2.elements.forEach((s2) => {
484
484
  i2(s2), e.emit(P$1.ARRAY_PUSH);
485
485
  });
486
486
  }, V = (t2, e, { compileExpression: i2 }) => {
487
487
  i2(t2.expression);
488
- }, $$1 = (t2, e, { compileExpression: i2 }) => {
488
+ }, $$2 = (t2, e, { compileExpression: i2 }) => {
489
489
  t2.name.text === "length" ? (i2(t2.expression), e.emit(P$1.LENGTH)) : (i2(t2.expression), e.emit(P$1.PUSH, t2.name.text), e.emit(P$1.PROPERTY_GET));
490
- }, j = (t2, e, { compileExpression: i2, reportError: s2 }) => {
490
+ }, j$1 = (t2, e, { compileExpression: i2, reportError: s2 }) => {
491
491
  i2(t2.expression), t2.argumentExpression ? i2(t2.argumentExpression) : s2(t2, "Element access requires an index expression"), e.emit(P$1.ARRAY_GET);
492
492
  }, v$1 = (t2, e, { compileExpression: i2 }) => {
493
493
  switch (t2.operator) {
@@ -507,7 +507,7 @@ const k = (t2, e, { compileExpression: i2, compileStatement: s2 }) => {
507
507
  r__namespace.isIdentifier(t2.operand) && (e.emit(P$1.PUSH, t2.operand.text), e.emit(P$1.DEC, false));
508
508
  break;
509
509
  }
510
- }, Y = (t2, e, { compileExpression: i2 }) => {
510
+ }, Y$1 = (t2, e, { compileExpression: i2 }) => {
511
511
  switch (t2.operator) {
512
512
  case r__namespace.SyntaxKind.PlusPlusToken:
513
513
  r__namespace.isIdentifier(t2.operand) && (e.emit(P$1.PUSH, t2.operand.text), e.emit(P$1.INC, true));
@@ -575,7 +575,7 @@ const k = (t2, e, { compileExpression: i2, compileStatement: s2 }) => {
575
575
  e.patchJump(a2, m);
576
576
  }, W$1 = (t2, e, { compileExpression: i2 }) => {
577
577
  i2(t2.expression), e.emit(P$1.TYPEOF);
578
- }, Q$1 = (t2, e, { compileExpression: i2, reportError: s2 }) => {
578
+ }, Q = (t2, e, { compileExpression: i2, reportError: s2 }) => {
579
579
  if (r__namespace.isPropertyAccessExpression(t2.expression) && r__namespace.isIdentifier(t2.expression.expression) && t2.expression.expression.text === "fs") {
580
580
  const a2 = t2.expression.name.text;
581
581
  if (a2 === "listFiles")
@@ -682,18 +682,18 @@ const k = (t2, e, { compileExpression: i2, compileStatement: s2 }) => {
682
682
  }, ee$1 = {
683
683
  [r__namespace.SyntaxKind.StringLiteral]: J$1,
684
684
  [r__namespace.SyntaxKind.NumericLiteral]: H,
685
- [r__namespace.SyntaxKind.TrueKeyword]: D$1,
685
+ [r__namespace.SyntaxKind.TrueKeyword]: D,
686
686
  [r__namespace.SyntaxKind.FalseKeyword]: M$1,
687
687
  [r__namespace.SyntaxKind.NullKeyword]: G$1,
688
688
  [r__namespace.SyntaxKind.RegularExpressionLiteral]: w,
689
689
  [r__namespace.SyntaxKind.Identifier]: q$1,
690
- [r__namespace.SyntaxKind.ArrayLiteralExpression]: B$1,
690
+ [r__namespace.SyntaxKind.ArrayLiteralExpression]: B,
691
691
  [r__namespace.SyntaxKind.BinaryExpression]: z,
692
692
  [r__namespace.SyntaxKind.PrefixUnaryExpression]: v$1,
693
- [r__namespace.SyntaxKind.PostfixUnaryExpression]: Y,
694
- [r__namespace.SyntaxKind.CallExpression]: Q$1,
695
- [r__namespace.SyntaxKind.PropertyAccessExpression]: $$1,
696
- [r__namespace.SyntaxKind.ElementAccessExpression]: j,
693
+ [r__namespace.SyntaxKind.PostfixUnaryExpression]: Y$1,
694
+ [r__namespace.SyntaxKind.CallExpression]: Q,
695
+ [r__namespace.SyntaxKind.PropertyAccessExpression]: $$2,
696
+ [r__namespace.SyntaxKind.ElementAccessExpression]: j$1,
697
697
  [r__namespace.SyntaxKind.ConditionalExpression]: X$1,
698
698
  [r__namespace.SyntaxKind.TypeOfExpression]: W$1,
699
699
  [r__namespace.SyntaxKind.ParenthesizedExpression]: V,
@@ -778,8 +778,8 @@ function ie$1(t2) {
778
778
  errors: e
779
779
  };
780
780
  }
781
- var d$2 = Object.defineProperty;
782
- var h = (s2, t2, n2) => t2 in s2 ? d$2(s2, t2, { enumerable: true, configurable: true, writable: true, value: n2 }) : s2[t2] = n2;
781
+ var d$1 = Object.defineProperty;
782
+ var h = (s2, t2, n2) => t2 in s2 ? d$1(s2, t2, { enumerable: true, configurable: true, writable: true, value: n2 }) : s2[t2] = n2;
783
783
  var a = (s2, t2, n2) => h(s2, typeof t2 != "symbol" ? t2 + "" : t2, n2);
784
784
  class p {
785
785
  constructor(t2) {
@@ -1042,7 +1042,7 @@ var b = (e, t2, r2) => X(e, typeof t2 != "symbol" ? t2 + "" : t2, r2);
1042
1042
  function Z(e) {
1043
1043
  return !!(e && typeof e == "object" && "type" in e && "message" in e);
1044
1044
  }
1045
- function d$1(e, t2) {
1045
+ function d(e, t2) {
1046
1046
  return e.stack.length < 1 ? {
1047
1047
  type: "RuntimeError",
1048
1048
  message: "Stack underflow",
@@ -1055,14 +1055,14 @@ const f2 = Z, ee = {
1055
1055
  stackIn: 2,
1056
1056
  stackOut: 1,
1057
1057
  execute: (e, t2) => {
1058
- const r2 = d$1(e, t2.op);
1058
+ const r2 = d(e, t2.op);
1059
1059
  if (f2(r2)) return r2;
1060
- const o = d$1(e, t2.op);
1060
+ const o = d(e, t2.op);
1061
1061
  if (f2(o)) return o;
1062
1062
  if (_$1(o) || _$1(r2))
1063
1063
  e.stack.push(u(o) + u(r2));
1064
1064
  else {
1065
- const c2 = F$1(o), s2 = F$1(r2);
1065
+ const c2 = F$2(o), s2 = F$2(r2);
1066
1066
  e.stack.push(c2 + s2);
1067
1067
  }
1068
1068
  }
@@ -1071,11 +1071,11 @@ const f2 = Z, ee = {
1071
1071
  stackIn: 2,
1072
1072
  stackOut: 1,
1073
1073
  execute: (e, t2) => {
1074
- const r2 = d$1(e, t2.op);
1074
+ const r2 = d(e, t2.op);
1075
1075
  if (f2(r2)) return r2;
1076
- const o = d$1(e, t2.op);
1076
+ const o = d(e, t2.op);
1077
1077
  if (f2(o)) return o;
1078
- const c2 = F$1(o), s2 = F$1(r2);
1078
+ const c2 = F$2(o), s2 = F$2(r2);
1079
1079
  e.stack.push(c2 - s2);
1080
1080
  }
1081
1081
  },
@@ -1083,11 +1083,11 @@ const f2 = Z, ee = {
1083
1083
  stackIn: 2,
1084
1084
  stackOut: 1,
1085
1085
  execute: (e, t2) => {
1086
- const r2 = d$1(e, t2.op);
1086
+ const r2 = d(e, t2.op);
1087
1087
  if (f2(r2)) return r2;
1088
- const o = d$1(e, t2.op);
1088
+ const o = d(e, t2.op);
1089
1089
  if (f2(o)) return o;
1090
- const c2 = F$1(o), s2 = F$1(r2);
1090
+ const c2 = F$2(o), s2 = F$2(r2);
1091
1091
  e.stack.push(c2 * s2);
1092
1092
  }
1093
1093
  },
@@ -1095,11 +1095,11 @@ const f2 = Z, ee = {
1095
1095
  stackIn: 2,
1096
1096
  stackOut: 1,
1097
1097
  execute: (e, t2) => {
1098
- const r2 = d$1(e, t2.op);
1098
+ const r2 = d(e, t2.op);
1099
1099
  if (f2(r2)) return r2;
1100
- const o = d$1(e, t2.op);
1100
+ const o = d(e, t2.op);
1101
1101
  if (f2(o)) return o;
1102
- const c2 = F$1(o), s2 = F$1(r2);
1102
+ const c2 = F$2(o), s2 = F$2(r2);
1103
1103
  if (s2 === 0)
1104
1104
  return {
1105
1105
  type: "DivisionByZero",
@@ -1114,11 +1114,11 @@ const f2 = Z, ee = {
1114
1114
  stackIn: 2,
1115
1115
  stackOut: 1,
1116
1116
  execute: (e, t2) => {
1117
- const r2 = d$1(e, t2.op);
1117
+ const r2 = d(e, t2.op);
1118
1118
  if (f2(r2)) return r2;
1119
- const o = d$1(e, t2.op);
1119
+ const o = d(e, t2.op);
1120
1120
  if (f2(o)) return o;
1121
- const c2 = F$1(o), s2 = F$1(r2);
1121
+ const c2 = F$2(o), s2 = F$2(r2);
1122
1122
  e.stack.push(c2 % s2);
1123
1123
  }
1124
1124
  },
@@ -1126,9 +1126,9 @@ const f2 = Z, ee = {
1126
1126
  stackIn: 1,
1127
1127
  stackOut: 1,
1128
1128
  execute: (e, t2) => {
1129
- const r2 = d$1(e, t2.op);
1129
+ const r2 = d(e, t2.op);
1130
1130
  if (f2(r2)) return r2;
1131
- const o = F$1(r2);
1131
+ const o = F$2(r2);
1132
1132
  e.stack.push(-o);
1133
1133
  }
1134
1134
  },
@@ -1136,9 +1136,9 @@ const f2 = Z, ee = {
1136
1136
  stackIn: 1,
1137
1137
  stackOut: 1,
1138
1138
  execute: (e, t2) => {
1139
- const r2 = d$1(e, t2.op);
1139
+ const r2 = d(e, t2.op);
1140
1140
  if (f2(r2)) return r2;
1141
- const o = F$1(r2);
1141
+ const o = F$2(r2);
1142
1142
  e.stack.push(o);
1143
1143
  }
1144
1144
  }
@@ -1363,7 +1363,7 @@ const f2 = Z, ee = {
1363
1363
  opcode: t2.op
1364
1364
  };
1365
1365
  o = c2.data;
1366
- } else if (S$1(r2))
1366
+ } else if (S(r2))
1367
1367
  o = r2;
1368
1368
  else
1369
1369
  return {
@@ -1418,9 +1418,9 @@ const f2 = Z, ee = {
1418
1418
  }
1419
1419
  };
1420
1420
  function v(e, t2, r2) {
1421
- const o = d$1(e, t2.op);
1421
+ const o = d(e, t2.op);
1422
1422
  if (f2(o)) return o;
1423
- const c2 = d$1(e, t2.op);
1423
+ const c2 = d(e, t2.op);
1424
1424
  if (f2(c2)) return c2;
1425
1425
  const s2 = r2(c2, o);
1426
1426
  e.stack.push(s2);
@@ -1437,7 +1437,7 @@ const ne = {
1437
1437
  if (L$1(r2) || c(r2))
1438
1438
  return L$1(r2) && L$1(o) || c(r2) && c(o) ? r2.id === o.id : false;
1439
1439
  {
1440
- const c2 = F$1(r2), s2 = F$1(o);
1440
+ const c2 = F$2(r2), s2 = F$2(o);
1441
1441
  return !isNaN(c2) && !isNaN(s2) ? c2 === s2 : u(r2) === u(o);
1442
1442
  }
1443
1443
  })
@@ -1453,7 +1453,7 @@ const ne = {
1453
1453
  if (L$1(r2) || c(r2))
1454
1454
  return L$1(r2) && L$1(o) || c(r2) && c(o) ? r2.id !== o.id : true;
1455
1455
  {
1456
- const c2 = F$1(r2), s2 = F$1(o);
1456
+ const c2 = F$2(r2), s2 = F$2(o);
1457
1457
  return !isNaN(c2) && !isNaN(s2) ? c2 !== s2 : u(r2) !== u(o);
1458
1458
  }
1459
1459
  })
@@ -1462,7 +1462,7 @@ const ne = {
1462
1462
  stackIn: 2,
1463
1463
  stackOut: 1,
1464
1464
  execute: (e, t2) => v(e, t2, (r2, o) => {
1465
- const c2 = F$1(r2), s2 = F$1(o);
1465
+ const c2 = F$2(r2), s2 = F$2(o);
1466
1466
  return c2 < s2;
1467
1467
  })
1468
1468
  },
@@ -1470,7 +1470,7 @@ const ne = {
1470
1470
  stackIn: 2,
1471
1471
  stackOut: 1,
1472
1472
  execute: (e, t2) => v(e, t2, (r2, o) => {
1473
- const c2 = F$1(r2), s2 = F$1(o);
1473
+ const c2 = F$2(r2), s2 = F$2(o);
1474
1474
  return c2 > s2;
1475
1475
  })
1476
1476
  },
@@ -1478,7 +1478,7 @@ const ne = {
1478
1478
  stackIn: 2,
1479
1479
  stackOut: 1,
1480
1480
  execute: (e, t2) => v(e, t2, (r2, o) => {
1481
- const c2 = F$1(r2), s2 = F$1(o);
1481
+ const c2 = F$2(r2), s2 = F$2(o);
1482
1482
  return c2 <= s2;
1483
1483
  })
1484
1484
  },
@@ -1486,7 +1486,7 @@ const ne = {
1486
1486
  stackIn: 2,
1487
1487
  stackOut: 1,
1488
1488
  execute: (e, t2) => v(e, t2, (r2, o) => {
1489
- const c2 = F$1(r2), s2 = F$1(o);
1489
+ const c2 = F$2(r2), s2 = F$2(o);
1490
1490
  return c2 >= s2;
1491
1491
  })
1492
1492
  },
@@ -1505,9 +1505,9 @@ const ne = {
1505
1505
  stackIn: 2,
1506
1506
  stackOut: 1,
1507
1507
  execute: (e, t2) => {
1508
- const r2 = d$1(e, t2.op);
1508
+ const r2 = d(e, t2.op);
1509
1509
  if (f2(r2)) return r2;
1510
- const o = d$1(e, t2.op);
1510
+ const o = d(e, t2.op);
1511
1511
  if (f2(o)) return o;
1512
1512
  const c2 = M$2(o) ? r2 : o;
1513
1513
  e.stack.push(c2);
@@ -1517,9 +1517,9 @@ const ne = {
1517
1517
  stackIn: 2,
1518
1518
  stackOut: 1,
1519
1519
  execute: (e, t2) => {
1520
- const r2 = d$1(e, t2.op);
1520
+ const r2 = d(e, t2.op);
1521
1521
  if (f2(r2)) return r2;
1522
- const o = d$1(e, t2.op);
1522
+ const o = d(e, t2.op);
1523
1523
  if (f2(o)) return o;
1524
1524
  const c2 = M$2(o) ? o : r2;
1525
1525
  e.stack.push(c2);
@@ -1529,7 +1529,7 @@ const ne = {
1529
1529
  stackIn: 1,
1530
1530
  stackOut: 1,
1531
1531
  execute: (e, t2) => {
1532
- const r2 = d$1(e, t2.op);
1532
+ const r2 = d(e, t2.op);
1533
1533
  if (f2(r2)) return r2;
1534
1534
  const o = !M$2(r2);
1535
1535
  e.stack.push(o);
@@ -1544,7 +1544,7 @@ const ne = {
1544
1544
  stackIn: 0,
1545
1545
  stackOut: 1,
1546
1546
  execute: (e, t2) => {
1547
- const r2 = Y$1(), o = e.heap.allocate("array", r2);
1547
+ const r2 = Y$2(), o = e.heap.allocate("array", r2);
1548
1548
  e.stack.push(o);
1549
1549
  }
1550
1550
  },
@@ -1568,7 +1568,7 @@ const ne = {
1568
1568
  opcode: t2.op
1569
1569
  };
1570
1570
  c2 = s2.data;
1571
- } else if (S$1(o))
1571
+ } else if (S(o))
1572
1572
  c2 = o;
1573
1573
  else
1574
1574
  return {
@@ -1609,7 +1609,7 @@ const ne = {
1609
1609
  const u$1 = i2.data, y2 = u(r2), E3 = u$1.properties[y2] ?? s();
1610
1610
  e.stack.push(E3);
1611
1611
  return;
1612
- } else if (S$1(o))
1612
+ } else if (S(o))
1613
1613
  c$1 = o;
1614
1614
  else if (_$1(o)) {
1615
1615
  let i2;
@@ -1679,7 +1679,7 @@ const ne = {
1679
1679
  const u$1 = i2.data, y2 = u(o);
1680
1680
  u$1.properties[y2] = r2, e.stack.push(c$1);
1681
1681
  return;
1682
- } else if (S$1(c$1))
1682
+ } else if (S(c$1))
1683
1683
  s2 = c$1;
1684
1684
  else
1685
1685
  return {
@@ -1733,7 +1733,7 @@ const ne = {
1733
1733
  opcode: t2.op
1734
1734
  };
1735
1735
  o = c2.data;
1736
- } else if (S$1(r2))
1736
+ } else if (S(r2))
1737
1737
  o = r2;
1738
1738
  else
1739
1739
  return {
@@ -1765,7 +1765,7 @@ const ne = {
1765
1765
  pc: e.pc,
1766
1766
  opcode: t2.op
1767
1767
  };
1768
- const s2 = c$1.data, p2 = Y$1();
1768
+ const s2 = c$1.data, p2 = Y$2();
1769
1769
  for (const i2 of s2.elements)
1770
1770
  if (c(i2)) {
1771
1771
  const u$1 = e.heap.get(i2.id);
@@ -1800,7 +1800,7 @@ const ne = {
1800
1800
  pc: e.pc,
1801
1801
  opcode: t2.op
1802
1802
  };
1803
- const s2 = c$1.data, p2 = Y$1();
1803
+ const s2 = c$1.data, p2 = Y$2();
1804
1804
  for (const i2 of s2.elements)
1805
1805
  if (c(i2)) {
1806
1806
  const u$1 = e.heap.get(i2.id);
@@ -1831,7 +1831,7 @@ const ne = {
1831
1831
  pc: e.pc,
1832
1832
  opcode: t2.op
1833
1833
  };
1834
- const a2 = e.heap.get(c2.id).data, i2 = E$2(o) ? o : 0, u2 = r2 === void 0 ? a2.elements.length : E$2(r2) ? r2 : a2.elements.length, y2 = i2 < 0 ? Math.max(0, a2.elements.length + i2) : i2, E3 = u2 < 0 ? Math.max(0, a2.elements.length + u2) : u2, Y2 = a2.elements.slice(y2, E3), z2 = Y$1(Y2), B2 = e.heap.allocate("array", z2);
1834
+ const a2 = e.heap.get(c2.id).data, i2 = E$2(o) ? o : 0, u2 = r2 === void 0 ? a2.elements.length : E$2(r2) ? r2 : a2.elements.length, y2 = i2 < 0 ? Math.max(0, a2.elements.length + i2) : i2, E3 = u2 < 0 ? Math.max(0, a2.elements.length + u2) : u2, Y2 = a2.elements.slice(y2, E3), z2 = Y$2(Y2), B2 = e.heap.allocate("array", z2);
1835
1835
  e.stack.push(B2);
1836
1836
  }
1837
1837
  },
@@ -1893,7 +1893,7 @@ function M(e, t2) {
1893
1893
  if (typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e && typeof e == "object" && e.type === "array" && Array.isArray(e.elements))
1894
1894
  return e;
1895
1895
  if (Array.isArray(e)) {
1896
- const r2 = Y$1();
1896
+ const r2 = Y$2();
1897
1897
  return r2.elements = e.map((o) => M(o, t2)), t2.allocate("array", r2);
1898
1898
  }
1899
1899
  if (e && typeof e == "object" && e.type === "object" && e.properties)
@@ -1912,9 +1912,9 @@ const ie = {
1912
1912
  stackIn: 2,
1913
1913
  stackOut: 1,
1914
1914
  execute: (e, t2) => {
1915
- const r2 = d$1(e, t2.op);
1915
+ const r2 = d(e, t2.op);
1916
1916
  if (f2(r2)) return r2;
1917
- const o = d$1(e, t2.op);
1917
+ const o = d(e, t2.op);
1918
1918
  if (f2(o)) return o;
1919
1919
  e.stack.push(u(o) + u(r2));
1920
1920
  }
@@ -1923,7 +1923,7 @@ const ie = {
1923
1923
  stackIn: 1,
1924
1924
  stackOut: 1,
1925
1925
  execute: (e, t2) => {
1926
- const r2 = d$1(e, t2.op);
1926
+ const r2 = d(e, t2.op);
1927
1927
  if (f2(r2)) return r2;
1928
1928
  if (!_$1(r2))
1929
1929
  return {
@@ -1939,11 +1939,11 @@ const ie = {
1939
1939
  stackIn: 1,
1940
1940
  stackOut: 1,
1941
1941
  execute: (e, t2) => {
1942
- const r2 = d$1(e, t2.op);
1942
+ const r2 = d(e, t2.op);
1943
1943
  if (f2(r2)) return r2;
1944
1944
  if (_$1(r2))
1945
1945
  e.stack.push(r2.length);
1946
- else if (S$1(r2))
1946
+ else if (S(r2))
1947
1947
  e.stack.push(r2.elements.length);
1948
1948
  else if (L$1(r2)) {
1949
1949
  const o = e.heap.get(r2.id);
@@ -1969,7 +1969,7 @@ const ie = {
1969
1969
  stackIn: 1,
1970
1970
  stackOut: 1,
1971
1971
  execute: (e, t2) => {
1972
- const r2 = d$1(e, t2.op);
1972
+ const r2 = d(e, t2.op);
1973
1973
  if (f2(r2)) return r2;
1974
1974
  if (!_$1(r2))
1975
1975
  return {
@@ -1990,7 +1990,7 @@ const ie = {
1990
1990
  stackIn: 1,
1991
1991
  stackOut: 1,
1992
1992
  execute: (e, t2) => {
1993
- const r2 = d$1(e, t2.op);
1993
+ const r2 = d(e, t2.op);
1994
1994
  if (f2(r2)) return r2;
1995
1995
  e.stack.push(y$1(r2));
1996
1996
  }
@@ -2008,10 +2008,10 @@ const ie = {
2008
2008
  pc: e.pc,
2009
2009
  opcode: t2.op
2010
2010
  };
2011
- const o = e.variables.get(r2) ?? 0, c2 = F$1(o) + 1;
2011
+ const o = e.variables.get(r2) ?? 0, c2 = F$2(o) + 1;
2012
2012
  e.variables.set(r2, c2);
2013
2013
  const s2 = t2.arg === true;
2014
- e.stack.push(s2 ? F$1(o) : c2);
2014
+ e.stack.push(s2 ? F$2(o) : c2);
2015
2015
  }
2016
2016
  },
2017
2017
  [P$1.DEC]: {
@@ -2026,10 +2026,10 @@ const ie = {
2026
2026
  pc: e.pc,
2027
2027
  opcode: t2.op
2028
2028
  };
2029
- const o = e.variables.get(r2) ?? 0, c2 = F$1(o) - 1;
2029
+ const o = e.variables.get(r2) ?? 0, c2 = F$2(o) - 1;
2030
2030
  e.variables.set(r2, c2);
2031
2031
  const s2 = t2.arg === true;
2032
- e.stack.push(s2 ? F$1(o) : c2);
2032
+ e.stack.push(s2 ? F$2(o) : c2);
2033
2033
  }
2034
2034
  }
2035
2035
  }, le = {
@@ -2113,7 +2113,7 @@ const ie = {
2113
2113
  filter: i2.properties.filter
2114
2114
  };
2115
2115
  }
2116
- } else e.stack.length >= 2 && typeof c$1 == "object" && c$1 !== null && !S$1(c$1) && (o = e.stack.pop()), r2 = e.stack.pop();
2116
+ } else e.stack.length >= 2 && typeof c$1 == "object" && c$1 !== null && !S(c$1) && (o = e.stack.pop()), r2 = e.stack.pop();
2117
2117
  if (!_$1(r2))
2118
2118
  return {
2119
2119
  type: "RuntimeError",
@@ -2129,7 +2129,7 @@ const ie = {
2129
2129
  opcode: t2.op
2130
2130
  };
2131
2131
  const s2 = e.fileSystem.listFiles(r2, o);
2132
- if (S$1(s2)) {
2132
+ if (S(s2)) {
2133
2133
  const p2 = e.heap.allocate("array", s2);
2134
2134
  e.stack.push(p2);
2135
2135
  } else
@@ -2258,7 +2258,7 @@ const ie = {
2258
2258
  };
2259
2259
  let c2;
2260
2260
  r2 === "" ? c2 = o.split("") : c2 = o.split(r2);
2261
- const s2 = Y$1(c2), p2 = e.heap.allocate("array", s2);
2261
+ const s2 = Y$2(c2), p2 = e.heap.allocate("array", s2);
2262
2262
  e.stack.push(p2);
2263
2263
  }
2264
2264
  },
@@ -2578,27 +2578,27 @@ const ie = {
2578
2578
  }
2579
2579
  }
2580
2580
  };
2581
- function A(e, t2) {
2581
+ function A$1(e, t2) {
2582
2582
  if (L$1(e)) {
2583
2583
  const r2 = t2.get(e.id);
2584
- return r2 && r2.type === "array" ? r2.data.elements.map((c2) => A(c2, t2)) : null;
2584
+ return r2 && r2.type === "array" ? r2.data.elements.map((c2) => A$1(c2, t2)) : null;
2585
2585
  }
2586
2586
  if (c(e)) {
2587
2587
  const r2 = t2.get(e.id);
2588
2588
  if (r2 && r2.type === "object") {
2589
2589
  const o = r2.data, c2 = {};
2590
2590
  for (const [s2, p2] of Object.entries(o.properties))
2591
- c2[s2] = A(p2, t2);
2591
+ c2[s2] = A$1(p2, t2);
2592
2592
  return c2;
2593
2593
  }
2594
2594
  return null;
2595
2595
  }
2596
- if (S$1(e))
2597
- return e.elements.map((r2) => A(r2, t2));
2596
+ if (S(e))
2597
+ return e.elements.map((r2) => A$1(r2, t2));
2598
2598
  if (i(e)) {
2599
2599
  const r2 = {};
2600
2600
  for (const [o, c2] of Object.entries(e.properties))
2601
- r2[o] = A(c2, t2);
2601
+ r2[o] = A$1(c2, t2);
2602
2602
  return r2;
2603
2603
  }
2604
2604
  if (!I$1(e))
@@ -2617,11 +2617,11 @@ const de = {
2617
2617
  stackIn: 3,
2618
2618
  stackOut: 1,
2619
2619
  execute: (e, t2) => {
2620
- const r2 = d$1(e, t2.op);
2620
+ const r2 = d(e, t2.op);
2621
2621
  if (f2(r2)) return r2;
2622
- const o = d$1(e, t2.op);
2622
+ const o = d(e, t2.op);
2623
2623
  if (f2(o)) return o;
2624
- const c$1 = d$1(e, t2.op);
2624
+ const c$1 = d(e, t2.op);
2625
2625
  if (f2(c$1)) return c$1;
2626
2626
  let s2;
2627
2627
  if (c(c$1)) {
@@ -2651,9 +2651,9 @@ const de = {
2651
2651
  stackIn: 2,
2652
2652
  stackOut: 1,
2653
2653
  execute: (e, t$1) => {
2654
- const r2 = d$1(e, t$1.op);
2654
+ const r2 = d(e, t$1.op);
2655
2655
  if (f2(r2)) return r2;
2656
- const o = d$1(e, t$1.op);
2656
+ const o = d(e, t$1.op);
2657
2657
  if (f2(o)) return o;
2658
2658
  if (t(o) || I$1(o))
2659
2659
  return {
@@ -2687,9 +2687,9 @@ const de = {
2687
2687
  stackIn: 1,
2688
2688
  stackOut: 1,
2689
2689
  execute: (e, t2) => {
2690
- const r2 = d$1(e, t2.op);
2690
+ const r2 = d(e, t2.op);
2691
2691
  if (f2(r2)) return r2;
2692
- const o = A(r2, e.heap);
2692
+ const o = A$1(r2, e.heap);
2693
2693
  e.stack.push(JSON.stringify(o));
2694
2694
  }
2695
2695
  },
@@ -2697,7 +2697,7 @@ const de = {
2697
2697
  stackIn: 1,
2698
2698
  stackOut: 1,
2699
2699
  execute: (e, t2) => {
2700
- const r2 = d$1(e, t2.op);
2700
+ const r2 = d(e, t2.op);
2701
2701
  if (f2(r2)) return r2;
2702
2702
  if (c(r2)) {
2703
2703
  const o = e.heap.get(r2.id);
@@ -2718,7 +2718,7 @@ const de = {
2718
2718
  stackIn: 1,
2719
2719
  stackOut: 0,
2720
2720
  execute: (e, t2) => {
2721
- const r2 = d$1(e, t2.op);
2721
+ const r2 = d(e, t2.op);
2722
2722
  if (f2(r2)) return r2;
2723
2723
  if (c(r2)) {
2724
2724
  const o = e.heap.get(r2.id);
@@ -2943,9 +2943,9 @@ const de = {
2943
2943
  stackOut: 1,
2944
2944
  // Produces boolean result
2945
2945
  execute: (e, t2) => {
2946
- const r2 = d$1(e, t2.op);
2946
+ const r2 = d(e, t2.op);
2947
2947
  if (f2(r2)) return r2;
2948
- const o = d$1(e, t2.op);
2948
+ const o = d(e, t2.op);
2949
2949
  if (f2(o)) return o;
2950
2950
  if (typeof r2 != "string")
2951
2951
  return {
@@ -2996,9 +2996,9 @@ const de = {
2996
2996
  stackOut: 1,
2997
2997
  // Produces array reference or null
2998
2998
  execute: (e, t2) => {
2999
- const r2 = d$1(e, t2.op);
2999
+ const r2 = d(e, t2.op);
3000
3000
  if (f2(r2)) return r2;
3001
- const o = d$1(e, t2.op);
3001
+ const o = d(e, t2.op);
3002
3002
  if (f2(o)) return o;
3003
3003
  if (typeof o != "string")
3004
3004
  return {
@@ -3058,11 +3058,11 @@ const de = {
3058
3058
  stackOut: 1,
3059
3059
  // Produces new string
3060
3060
  execute: (e, t2) => {
3061
- const r2 = d$1(e, t2.op);
3061
+ const r2 = d(e, t2.op);
3062
3062
  if (f2(r2)) return r2;
3063
- const o = d$1(e, t2.op);
3063
+ const o = d(e, t2.op);
3064
3064
  if (f2(o)) return o;
3065
- const c$1 = d$1(e, t2.op);
3065
+ const c$1 = d(e, t2.op);
3066
3066
  if (f2(c$1)) return c$1;
3067
3067
  if (typeof c$1 != "string")
3068
3068
  return {
@@ -3268,7 +3268,7 @@ class G {
3268
3268
  return this.execute(o, s2, c2 || t2.fileSystem);
3269
3269
  }
3270
3270
  }
3271
- class $ {
3271
+ let $$1 = class $ {
3272
3272
  constructor() {
3273
3273
  b(this, "sandboxPaths", []);
3274
3274
  const t2 = process.env.CVM_SANDBOX_PATHS, r2 = process.env.CVM_SANDBOX_ROOT;
@@ -3281,7 +3281,7 @@ class $ {
3281
3281
  );
3282
3282
  }
3283
3283
  listFiles(t2, r2 = {}) {
3284
- const o = Y$1();
3284
+ const o = Y$2();
3285
3285
  if (!this.isPathAllowed(t2))
3286
3286
  return o;
3287
3287
  try {
@@ -3339,14 +3339,14 @@ class $ {
3339
3339
  return false;
3340
3340
  }
3341
3341
  }
3342
- }
3343
- new $();
3342
+ };
3343
+ new $$1();
3344
3344
  class ve {
3345
3345
  constructor(t2, r2) {
3346
3346
  b(this, "vms", /* @__PURE__ */ new Map());
3347
3347
  b(this, "storage");
3348
3348
  b(this, "fileSystem");
3349
- t2 ? this.storage = t2 : this.storage = E2.create(), this.fileSystem = r2 || new $();
3349
+ t2 ? this.storage = t2 : this.storage = E2.create(), this.fileSystem = r2 || new $$1();
3350
3350
  }
3351
3351
  /**
3352
3352
  * Initialize the VMManager (connect to database)
@@ -3637,109 +3637,130 @@ class ve {
3637
3637
  return t2;
3638
3638
  }
3639
3639
  }
3640
- var T = Object.defineProperty;
3641
- var S = (m, r2, t2) => r2 in m ? T(m, r2, { enumerable: true, configurable: true, writable: true, value: t2 }) : m[r2] = t2;
3642
- var d = (m, r2, t2) => S(m, typeof r2 != "symbol" ? r2 + "" : r2, t2);
3643
- const B = /^\d{2}-[a-z0-9]+(-[a-z0-9]+)*$/;
3644
- function D(m, r2) {
3645
- const t2 = m.split(`
3646
- `), e = [];
3647
- let s2 = "", c2 = -1;
3648
- const l = [], h2 = /* @__PURE__ */ new Set();
3640
+ var U = Object.defineProperty;
3641
+ var A = (h2, r2, e) => r2 in h2 ? U(h2, r2, { enumerable: true, configurable: true, writable: true, value: e }) : h2[r2] = e;
3642
+ var $2 = (h2, r2, e) => A(h2, typeof r2 != "symbol" ? r2 + "" : r2, e);
3643
+ const F = /^\d{2}-[a-z0-9]+(-[a-z0-9]+)*$/;
3644
+ function j(h2) {
3645
+ const r2 = h2.split(`
3646
+ `);
3647
+ let e = 0;
3648
+ for (; e < r2.length; ) {
3649
+ if (r2[e].trim().startsWith("<files>")) {
3650
+ const t2 = [];
3651
+ for (e++; e < r2.length && !r2[e].trim().startsWith("</files>"); ) {
3652
+ const s2 = r2[e].trim().match(/^-\s+(.+)/);
3653
+ if (s2) {
3654
+ const c2 = s2[1].trim();
3655
+ c2 && t2.push(c2);
3656
+ }
3657
+ e++;
3658
+ }
3659
+ return t2;
3660
+ }
3661
+ e++;
3662
+ }
3663
+ return [];
3664
+ }
3665
+ function T(h2, r2, e) {
3666
+ const t2 = h2.split(`
3667
+ `), s2 = [];
3668
+ let c2 = "", m = -1;
3669
+ const y2 = [], g2 = /* @__PURE__ */ new Set();
3649
3670
  let n2 = 0;
3650
3671
  for (; n2 < t2.length; ) {
3651
3672
  if (t2[n2].trim().startsWith("<mission>")) {
3652
- c2 = n2;
3673
+ m = n2;
3653
3674
  const a2 = t2[n2].trim().replace("<mission>", "").replace("</mission>", "").trim();
3654
3675
  if (t2[n2].trim().endsWith("</mission>")) {
3655
- s2 = a2, n2++;
3676
+ c2 = a2, n2++;
3656
3677
  break;
3657
3678
  }
3658
- const o = [];
3659
- for (a2 && o.push(a2), n2++; n2 < t2.length && !t2[n2].trim().startsWith("</mission>"); )
3660
- o.push(t2[n2]), n2++;
3661
- n2 < t2.length && n2++, s2 = o.join(`
3679
+ const i2 = [];
3680
+ for (a2 && i2.push(a2), n2++; n2 < t2.length && !t2[n2].trim().startsWith("</mission>"); )
3681
+ i2.push(t2[n2]), n2++;
3682
+ n2 < t2.length && n2++, c2 = i2.join(`
3662
3683
  `).trim();
3663
3684
  break;
3664
3685
  }
3665
3686
  n2++;
3666
3687
  }
3667
- for (c2 === -1 ? e.push({ line: 0, message: "Missing <mission> tag" }) : s2 || e.push({ line: c2 + 1, message: "<mission> tag is empty" }); n2 < t2.length; ) {
3688
+ for (m === -1 ? ((e == null ? void 0 : e.requireMission) !== false && s2.push({ line: 0, message: "Missing <mission> tag" }), n2 = 0) : c2 || s2.push({ line: m + 1, message: "<mission> tag is empty" }); n2 < t2.length; ) {
3668
3689
  const a2 = t2[n2].trim().match(/^<block\s+id="([^"]+)">/);
3669
3690
  if (!a2) {
3670
3691
  n2++;
3671
3692
  continue;
3672
3693
  }
3673
- const o = a2[1], p2 = n2;
3674
- B.test(o) || e.push({ line: n2 + 1, message: `Block id "${o}" must be NN-kebab-case format` }), h2.has(o) && e.push({ line: n2 + 1, message: `Duplicate block id "${o}"` }), h2.add(o);
3675
- let k2 = "", x = "", E3 = [], v2 = [], f3 = -1, $2 = false, I2 = false, M2 = false;
3694
+ const i2 = a2[1], p2 = n2;
3695
+ F.test(i2) || s2.push({ line: n2 + 1, message: `Block id "${i2}" must be NN-kebab-case format` }), g2.has(i2) && s2.push({ line: n2 + 1, message: `Duplicate block id "${i2}"` }), g2.add(i2);
3696
+ let k2 = "", u2 = "", d2 = [], w2 = [], E3 = -1, l = false, x = false, N2 = false;
3676
3697
  for (n2++; n2 < t2.length; ) {
3677
- const g2 = t2[n2].trim();
3678
- if (g2.startsWith("</block>")) {
3679
- f3 = n2, n2++;
3698
+ const v2 = t2[n2].trim();
3699
+ if (v2.startsWith("</block>")) {
3700
+ E3 = n2, n2++;
3680
3701
  break;
3681
3702
  }
3682
- const b2 = g2.match(/^##\s+TDDAB-\d+:\s+(.+)/);
3683
- if (b2) {
3684
- k2 = b2[1], n2++;
3703
+ const S2 = v2.match(/^##\s+TDDAB-\d+:\s+(.+)/);
3704
+ if (S2) {
3705
+ k2 = S2[1], n2++;
3685
3706
  continue;
3686
3707
  }
3687
- if (g2.startsWith("<intro>")) {
3688
- $2 = true;
3689
- const u2 = [], w2 = g2.replace("<intro>", "").replace("</intro>", "").trim();
3690
- if (g2.includes("</intro>")) {
3691
- x = w2, n2++;
3708
+ if (v2.startsWith("<intro>")) {
3709
+ l = true;
3710
+ const f3 = [], M2 = v2.replace("<intro>", "").replace("</intro>", "").trim();
3711
+ if (v2.includes("</intro>")) {
3712
+ u2 = M2, n2++;
3692
3713
  continue;
3693
3714
  }
3694
- for (w2 && u2.push(w2), n2++; n2 < t2.length && !t2[n2].trim().startsWith("</intro>"); )
3695
- u2.push(t2[n2]), n2++;
3696
- n2 < t2.length && n2++, x = u2.join(`
3715
+ for (M2 && f3.push(M2), n2++; n2 < t2.length && !t2[n2].trim().startsWith("</intro>"); )
3716
+ f3.push(t2[n2]), n2++;
3717
+ n2 < t2.length && n2++, u2 = f3.join(`
3697
3718
  `).trim();
3698
3719
  continue;
3699
3720
  }
3700
- if (g2.startsWith("<red>")) {
3701
- for (I2 = true, n2++; n2 < t2.length && !t2[n2].trim().startsWith("</red>"); ) {
3702
- const u2 = t2[n2].trim().match(/^-\s*test:\s*(.+)/);
3703
- u2 && E3.push(u2[1].trim()), n2++;
3721
+ if (v2.startsWith("<red>")) {
3722
+ for (x = true, n2++; n2 < t2.length && !t2[n2].trim().startsWith("</red>"); ) {
3723
+ const f3 = t2[n2].trim().match(/^-\s*test:\s*(.+)/);
3724
+ f3 && d2.push(f3[1].trim()), n2++;
3704
3725
  }
3705
3726
  n2 < t2.length && n2++;
3706
3727
  continue;
3707
3728
  }
3708
- if (g2.startsWith("<success>")) {
3709
- for (M2 = true, n2++; n2 < t2.length && !t2[n2].trim().startsWith("</success>"); ) {
3710
- const u2 = t2[n2].trim().match(/^-\s*\[\s*\]\s*(.+)/);
3711
- u2 && v2.push(u2[1].trim()), n2++;
3729
+ if (v2.startsWith("<success>")) {
3730
+ for (N2 = true, n2++; n2 < t2.length && !t2[n2].trim().startsWith("</success>"); ) {
3731
+ const f3 = t2[n2].trim().match(/^-\s*\[\s*\]\s*(.+)/);
3732
+ f3 && w2.push(f3[1].trim()), n2++;
3712
3733
  }
3713
3734
  n2 < t2.length && n2++;
3714
3735
  continue;
3715
3736
  }
3716
3737
  n2++;
3717
3738
  }
3718
- f3 === -1 && (e.push({ line: p2 + 1, message: `Block "${o}" never closed with </block>` }), f3 = t2.length - 1), $2 ? x || e.push({ line: p2 + 1, message: `Block "${o}" has empty <intro>` }) : e.push({ line: p2 + 1, message: `Block "${o}" missing <intro> tag` }), I2 ? E3.length === 0 && e.push({ line: p2 + 1, message: `Block "${o}" has <red> but no "- test:" lines` }) : e.push({ line: p2 + 1, message: `Block "${o}" missing <red> tag` }), M2 ? v2.length === 0 && e.push({ line: p2 + 1, message: `Block "${o}" has <success> but no "- [ ]" items` }) : e.push({ line: p2 + 1, message: `Block "${o}" missing <success> tag` }), l.push({
3719
- id: o,
3739
+ E3 === -1 && (s2.push({ line: p2 + 1, message: `Block "${i2}" never closed with </block>` }), E3 = t2.length - 1), l ? u2 || s2.push({ line: p2 + 1, message: `Block "${i2}" has empty <intro>` }) : s2.push({ line: p2 + 1, message: `Block "${i2}" missing <intro> tag` }), x ? d2.length === 0 && s2.push({ line: p2 + 1, message: `Block "${i2}" has <red> but no "- test:" lines` }) : s2.push({ line: p2 + 1, message: `Block "${i2}" missing <red> tag` }), N2 ? w2.length === 0 && s2.push({ line: p2 + 1, message: `Block "${i2}" has <success> but no "- [ ]" items` }) : s2.push({ line: p2 + 1, message: `Block "${i2}" missing <success> tag` }), y2.push({
3740
+ id: i2,
3720
3741
  title: k2,
3721
- intro: x,
3722
- redTests: E3,
3723
- success: v2,
3742
+ intro: u2,
3743
+ redTests: d2,
3744
+ success: w2,
3724
3745
  startLine: p2 + 1,
3725
- endLine: f3 + 1
3746
+ endLine: E3 + 1
3726
3747
  });
3727
3748
  }
3728
- return l.length === 0 && !e.some((a2) => a2.message.includes("block")) && e.push({ line: 0, message: "No <block> tags found" }), e.length > 0 ? { valid: false, plan: null, errors: e } : {
3749
+ return y2.length === 0 && (e == null ? void 0 : e.requireBlocks) !== false && !s2.some((a2) => a2.message.includes("block")) && s2.push({ line: 0, message: "No <block> tags found" }), s2.length > 0 ? { valid: false, plan: null, errors: s2 } : {
3729
3750
  valid: true,
3730
- plan: { mission: s2, blocks: l, sourceFile: r2 },
3751
+ plan: { mission: c2, blocks: y2, sourceFile: r2 },
3731
3752
  errors: []
3732
3753
  };
3733
3754
  }
3734
3755
  const J = {
3735
3756
  "@planexecutor": "planexecutor.ts"
3736
3757
  };
3737
- class Q {
3758
+ class Y {
3738
3759
  constructor(r2 = "0.0.1") {
3739
- d(this, "server");
3740
- d(this, "transport", null);
3741
- d(this, "vmManager");
3742
- d(this, "version");
3760
+ $2(this, "server");
3761
+ $2(this, "transport", null);
3762
+ $2(this, "vmManager");
3763
+ $2(this, "version");
3743
3764
  this.version = r2, this.vmManager = new ve(), this.server = new mcp_js.McpServer({
3744
3765
  name: "cvm-server",
3745
3766
  version: this.version
@@ -3753,19 +3774,36 @@ class Q {
3753
3774
  }
3754
3775
  setupTools() {
3755
3776
  this.server.tool(
3777
+ "server_info",
3778
+ {},
3779
+ async () => {
3780
+ const r2 = await this.vmManager.listPrograms(), e = await this.vmManager.listExecutions();
3781
+ return {
3782
+ content: [{
3783
+ type: "text",
3784
+ text: JSON.stringify({
3785
+ name: "cvm-server",
3786
+ version: this.version,
3787
+ programs: r2.length,
3788
+ executions: e.length
3789
+ }, null, 2)
3790
+ }]
3791
+ };
3792
+ }
3793
+ ), this.server.tool(
3756
3794
  "load",
3757
3795
  {
3758
3796
  programId: zod.z.string(),
3759
3797
  source: zod.z.string()
3760
3798
  },
3761
- async ({ programId: r2, source: t2 }) => {
3799
+ async ({ programId: r2, source: e }) => {
3762
3800
  try {
3763
- return await this.vmManager.loadProgram(r2, t2), {
3801
+ return await this.vmManager.loadProgram(r2, e), {
3764
3802
  content: [{ type: "text", text: `Program loaded successfully: ${r2}` }]
3765
3803
  };
3766
- } catch (e) {
3804
+ } catch (t2) {
3767
3805
  return {
3768
- content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : "Unknown error"}` }],
3806
+ content: [{ type: "text", text: `Error: ${t2 instanceof Error ? t2.message : "Unknown error"}` }],
3769
3807
  isError: true
3770
3808
  };
3771
3809
  }
@@ -3776,35 +3814,35 @@ class Q {
3776
3814
  programId: zod.z.string(),
3777
3815
  filePath: zod.z.string()
3778
3816
  },
3779
- async ({ programId: r2, filePath: t2 }) => {
3817
+ async ({ programId: r2, filePath: e }) => {
3780
3818
  try {
3781
- let e;
3782
- const s2 = J[t2];
3819
+ let t2;
3820
+ const s2 = J[e];
3783
3821
  if (s2) {
3784
- const l = r$2.dirname(url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("main.cjs", document.baseURI).href));
3785
- e = r$2.join(l, "programs", s2);
3822
+ const m = r$2.dirname(url.fileURLToPath(typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === "SCRIPT" && _documentCurrentScript.src || new URL("main.cjs", document.baseURI).href));
3823
+ t2 = r$2.join(m, "programs", s2);
3786
3824
  } else
3787
- e = r$2.resolve(t2);
3788
- const c2 = await promises.readFile(e, "utf-8");
3825
+ t2 = r$2.resolve(e);
3826
+ const c2 = await promises.readFile(t2, "utf-8");
3789
3827
  return await this.vmManager.loadProgram(r2, c2), {
3790
- content: [{ type: "text", text: `Program loaded successfully from ${t2}: ${r2}` }]
3828
+ content: [{ type: "text", text: `Program loaded successfully from ${e}: ${r2}` }]
3791
3829
  };
3792
- } catch (e) {
3793
- if (e instanceof Error) {
3794
- const s2 = e;
3830
+ } catch (t2) {
3831
+ if (t2 instanceof Error) {
3832
+ const s2 = t2;
3795
3833
  if (s2.code === "ENOENT")
3796
3834
  return {
3797
- content: [{ type: "text", text: `Error: File not found: ${t2}` }],
3835
+ content: [{ type: "text", text: `Error: File not found: ${e}` }],
3798
3836
  isError: true
3799
3837
  };
3800
3838
  if (s2.code === "EACCES")
3801
3839
  return {
3802
- content: [{ type: "text", text: `Error: Permission denied: ${t2}` }],
3840
+ content: [{ type: "text", text: `Error: Permission denied: ${e}` }],
3803
3841
  isError: true
3804
3842
  };
3805
3843
  }
3806
3844
  return {
3807
- content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : "Unknown error"}` }],
3845
+ content: [{ type: "text", text: `Error: ${t2 instanceof Error ? t2.message : "Unknown error"}` }],
3808
3846
  isError: true
3809
3847
  };
3810
3848
  }
@@ -3816,10 +3854,10 @@ class Q {
3816
3854
  executionId: zod.z.string(),
3817
3855
  setCurrent: zod.z.boolean().optional()
3818
3856
  },
3819
- async ({ programId: r2, executionId: t2, setCurrent: e = true }) => {
3857
+ async ({ programId: r2, executionId: e, setCurrent: t2 = true }) => {
3820
3858
  try {
3821
- return await this.vmManager.startExecution(r2, t2), e && await this.vmManager.setCurrentExecutionId(t2), {
3822
- content: [{ type: "text", text: `Execution started: ${t2}${e ? " (set as current)" : ""}` }]
3859
+ return await this.vmManager.startExecution(r2, e), t2 && await this.vmManager.setCurrentExecutionId(e), {
3860
+ content: [{ type: "text", text: `Execution started: ${e}${t2 ? " (set as current)" : ""}` }]
3823
3861
  };
3824
3862
  } catch (s2) {
3825
3863
  return {
@@ -3835,30 +3873,30 @@ class Q {
3835
3873
  },
3836
3874
  async ({ executionId: r2 }) => {
3837
3875
  try {
3838
- let t2 = r2;
3839
- if (!t2) {
3876
+ let e = r2;
3877
+ if (!e) {
3840
3878
  const s2 = await this.vmManager.getCurrentExecutionId();
3841
3879
  if (!s2)
3842
3880
  return {
3843
3881
  content: [{ type: "text", text: "No current execution set. Use list_executions to see available executions." }]
3844
3882
  };
3845
- t2 = s2;
3883
+ e = s2;
3846
3884
  }
3847
- const e = await this.vmManager.getNext(t2);
3848
- return e.type === "completed" ? {
3849
- content: [{ type: "text", text: e.result !== void 0 ? `Execution completed with result: ${JSON.stringify(e.result)}` : "Execution completed" }]
3850
- } : e.type === "waiting" ? {
3851
- content: [{ type: "text", text: e.message || "Waiting for input" }]
3852
- } : e.type === "error" ? {
3853
- content: [{ type: "text", text: `Error: ${e.error}` }],
3885
+ const t2 = await this.vmManager.getNext(e);
3886
+ return t2.type === "completed" ? {
3887
+ content: [{ type: "text", text: t2.result !== void 0 ? `Execution completed with result: ${JSON.stringify(t2.result)}` : "Execution completed" }]
3888
+ } : t2.type === "waiting" ? {
3889
+ content: [{ type: "text", text: t2.message || "Waiting for input" }]
3890
+ } : t2.type === "error" ? {
3891
+ content: [{ type: "text", text: `Error: ${t2.error}` }],
3854
3892
  isError: true
3855
3893
  } : {
3856
3894
  content: [{ type: "text", text: "Unexpected state" }],
3857
3895
  isError: true
3858
3896
  };
3859
- } catch (t2) {
3897
+ } catch (e) {
3860
3898
  return {
3861
- content: [{ type: "text", text: `Error: ${t2 instanceof Error ? t2.message : "Unknown error"}` }],
3899
+ content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : "Unknown error"}` }],
3862
3900
  isError: true
3863
3901
  };
3864
3902
  }
@@ -3869,24 +3907,24 @@ class Q {
3869
3907
  executionId: zod.z.string().optional(),
3870
3908
  result: zod.z.string()
3871
3909
  },
3872
- async ({ executionId: r2, result: t2 }) => {
3910
+ async ({ executionId: r2, result: e }) => {
3873
3911
  try {
3874
- let e = r2;
3875
- if (!e) {
3912
+ let t2 = r2;
3913
+ if (!t2) {
3876
3914
  const s2 = await this.vmManager.getCurrentExecutionId();
3877
3915
  if (!s2)
3878
3916
  return {
3879
3917
  content: [{ type: "text", text: "Error: No current execution set" }],
3880
3918
  isError: true
3881
3919
  };
3882
- e = s2;
3920
+ t2 = s2;
3883
3921
  }
3884
- return await this.vmManager.reportCCResult(e, t2), {
3922
+ return await this.vmManager.reportCCResult(t2, e), {
3885
3923
  content: [{ type: "text", text: "Execution resumed" }]
3886
3924
  };
3887
- } catch (e) {
3925
+ } catch (t2) {
3888
3926
  return {
3889
- content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : "Unknown error"}` }],
3927
+ content: [{ type: "text", text: `Error: ${t2 instanceof Error ? t2.message : "Unknown error"}` }],
3890
3928
  isError: true
3891
3929
  };
3892
3930
  }
@@ -3898,23 +3936,23 @@ class Q {
3898
3936
  },
3899
3937
  async ({ executionId: r2 }) => {
3900
3938
  try {
3901
- let t2 = r2;
3902
- if (!t2) {
3939
+ let e = r2;
3940
+ if (!e) {
3903
3941
  const s2 = await this.vmManager.getCurrentExecutionId();
3904
3942
  if (!s2)
3905
3943
  return {
3906
3944
  content: [{ type: "text", text: "Error: No current execution set" }],
3907
3945
  isError: true
3908
3946
  };
3909
- t2 = s2;
3947
+ e = s2;
3910
3948
  }
3911
- const e = await this.vmManager.getExecutionStatus(t2);
3949
+ const t2 = await this.vmManager.getExecutionStatus(e);
3912
3950
  return {
3913
- content: [{ type: "text", text: JSON.stringify(e, null, 2) }]
3951
+ content: [{ type: "text", text: JSON.stringify(t2, null, 2) }]
3914
3952
  };
3915
- } catch (t2) {
3953
+ } catch (e) {
3916
3954
  return {
3917
- content: [{ type: "text", text: `Error: ${t2 instanceof Error ? t2.message : "Unknown error"}` }],
3955
+ content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : "Unknown error"}` }],
3918
3956
  isError: true
3919
3957
  };
3920
3958
  }
@@ -3924,12 +3962,12 @@ class Q {
3924
3962
  {},
3925
3963
  async () => {
3926
3964
  try {
3927
- const r2 = await this.vmManager.listExecutions(), t2 = await this.vmManager.getCurrentExecutionId(), e = r2.map((s2) => ({
3965
+ const r2 = await this.vmManager.listExecutions(), e = await this.vmManager.getCurrentExecutionId(), t2 = r2.map((s2) => ({
3928
3966
  executionId: s2.id,
3929
3967
  programId: s2.programId,
3930
3968
  state: s2.state,
3931
3969
  created: s2.created,
3932
- isCurrent: s2.id === t2,
3970
+ isCurrent: s2.id === e,
3933
3971
  summary: {
3934
3972
  currentPrompt: s2.state === "AWAITING_COGNITIVE_RESULT" ? s2.ccPrompt : void 0,
3935
3973
  tasksCompleted: 0
@@ -3937,7 +3975,7 @@ class Q {
3937
3975
  }
3938
3976
  }));
3939
3977
  return {
3940
- content: [{ type: "text", text: JSON.stringify(e, null, 2) }]
3978
+ content: [{ type: "text", text: JSON.stringify(t2, null, 2) }]
3941
3979
  };
3942
3980
  } catch (r2) {
3943
3981
  return {
@@ -3953,29 +3991,29 @@ class Q {
3953
3991
  },
3954
3992
  async ({ executionId: r2 }) => {
3955
3993
  try {
3956
- let t2 = r2;
3957
- if (!t2) {
3958
- const l = await this.vmManager.getCurrentExecutionId();
3959
- if (!l)
3994
+ let e = r2;
3995
+ if (!e) {
3996
+ const m = await this.vmManager.getCurrentExecutionId();
3997
+ if (!m)
3960
3998
  return {
3961
3999
  content: [{ type: "text", text: "Error: No current execution set" }],
3962
4000
  isError: true
3963
4001
  };
3964
- t2 = l;
4002
+ e = m;
3965
4003
  }
3966
- const e = await this.vmManager.getExecutionWithAttempts(t2), s2 = await this.vmManager.getCurrentExecutionId(), c2 = {
3967
- executionId: e.id,
3968
- programId: e.programId,
3969
- state: e.state,
3970
- created: e.created,
3971
- isCurrent: e.id === s2,
3972
- currentTask: e.state === "AWAITING_COGNITIVE_RESULT" ? {
3973
- prompt: e.ccPrompt,
3974
- attempts: e.attempts || 1,
3975
- firstAttemptAt: e.firstAttemptAt || e.created,
3976
- lastAttemptAt: e.lastAttemptAt || e.created
4004
+ const t2 = await this.vmManager.getExecutionWithAttempts(e), s2 = await this.vmManager.getCurrentExecutionId(), c2 = {
4005
+ executionId: t2.id,
4006
+ programId: t2.programId,
4007
+ state: t2.state,
4008
+ created: t2.created,
4009
+ isCurrent: t2.id === s2,
4010
+ currentTask: t2.state === "AWAITING_COGNITIVE_RESULT" ? {
4011
+ prompt: t2.ccPrompt,
4012
+ attempts: t2.attempts || 1,
4013
+ firstAttemptAt: t2.firstAttemptAt || t2.created,
4014
+ lastAttemptAt: t2.lastAttemptAt || t2.created
3977
4015
  } : void 0,
3978
- variables: e.variables,
4016
+ variables: t2.variables,
3979
4017
  stats: {
3980
4018
  tasksCompleted: 0
3981
4019
  // TODO: Track this
@@ -3984,9 +4022,9 @@ class Q {
3984
4022
  return {
3985
4023
  content: [{ type: "text", text: JSON.stringify(c2, null, 2) }]
3986
4024
  };
3987
- } catch (t2) {
4025
+ } catch (e) {
3988
4026
  return {
3989
- content: [{ type: "text", text: `Error: ${t2 instanceof Error ? t2.message : "Unknown error"}` }],
4027
+ content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : "Unknown error"}` }],
3990
4028
  isError: true
3991
4029
  };
3992
4030
  }
@@ -4001,9 +4039,9 @@ class Q {
4001
4039
  return await this.vmManager.setCurrentExecutionId(r2), {
4002
4040
  content: [{ type: "text", text: `Current execution set to: ${r2}` }]
4003
4041
  };
4004
- } catch (t2) {
4042
+ } catch (e) {
4005
4043
  return {
4006
- content: [{ type: "text", text: `Error: ${t2 instanceof Error ? t2.message : "Unknown error"}` }],
4044
+ content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : "Unknown error"}` }],
4007
4045
  isError: true
4008
4046
  };
4009
4047
  }
@@ -4014,10 +4052,10 @@ class Q {
4014
4052
  executionId: zod.z.string(),
4015
4053
  confirmToken: zod.z.string().optional()
4016
4054
  },
4017
- async ({ executionId: r2, confirmToken: t2 }) => {
4055
+ async ({ executionId: r2, confirmToken: e }) => {
4018
4056
  try {
4019
- const e = `delete-${r2}-${Date.now()}`;
4020
- return t2 ? t2 && t2.startsWith(`delete-${r2}-`) ? (await this.vmManager.deleteExecution(r2), {
4057
+ const t2 = `delete-${r2}-${Date.now()}`;
4058
+ return e ? e && e.startsWith(`delete-${r2}-`) ? (await this.vmManager.deleteExecution(r2), {
4021
4059
  content: [{ type: "text", text: `Execution deleted: ${r2}` }]
4022
4060
  }) : {
4023
4061
  content: [{ type: "text", text: "Invalid confirmation token" }],
@@ -4028,13 +4066,13 @@ class Q {
4028
4066
  text: JSON.stringify({
4029
4067
  confirmationRequired: true,
4030
4068
  message: `To delete execution '${r2}', call this tool again with the confirmation token`,
4031
- token: e
4069
+ token: t2
4032
4070
  }, null, 2)
4033
4071
  }]
4034
4072
  };
4035
- } catch (e) {
4073
+ } catch (t2) {
4036
4074
  return {
4037
- content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : "Unknown error"}` }],
4075
+ content: [{ type: "text", text: `Error: ${t2 instanceof Error ? t2.message : "Unknown error"}` }],
4038
4076
  isError: true
4039
4077
  };
4040
4078
  }
@@ -4049,13 +4087,13 @@ class Q {
4049
4087
  return {
4050
4088
  content: [{ type: "text", text: "No programs loaded" }]
4051
4089
  };
4052
- const t2 = r2.map((e) => ({
4053
- programId: e.id,
4054
- name: e.name,
4055
- created: e.created
4090
+ const e = r2.map((t2) => ({
4091
+ programId: t2.id,
4092
+ name: t2.name,
4093
+ created: t2.created
4056
4094
  }));
4057
4095
  return {
4058
- content: [{ type: "text", text: JSON.stringify(t2, null, 2) }]
4096
+ content: [{ type: "text", text: JSON.stringify(e, null, 2) }]
4059
4097
  };
4060
4098
  } catch (r2) {
4061
4099
  return {
@@ -4070,10 +4108,10 @@ class Q {
4070
4108
  programId: zod.z.string(),
4071
4109
  confirmToken: zod.z.string().optional()
4072
4110
  },
4073
- async ({ programId: r2, confirmToken: t2 }) => {
4111
+ async ({ programId: r2, confirmToken: e }) => {
4074
4112
  try {
4075
- const e = `delete-${r2}-${Date.now()}`;
4076
- return t2 ? t2 && t2.startsWith(`delete-${r2}-`) ? (await this.vmManager.deleteProgram(r2), {
4113
+ const t2 = `delete-${r2}-${Date.now()}`;
4114
+ return e ? e && e.startsWith(`delete-${r2}-`) ? (await this.vmManager.deleteProgram(r2), {
4077
4115
  content: [{ type: "text", text: `Program deleted: ${r2}` }]
4078
4116
  }) : {
4079
4117
  content: [{ type: "text", text: "Invalid confirmation token" }],
@@ -4084,13 +4122,13 @@ class Q {
4084
4122
  text: JSON.stringify({
4085
4123
  confirmationRequired: true,
4086
4124
  message: `To delete program '${r2}', call this tool again with the confirmation token`,
4087
- token: e
4125
+ token: t2
4088
4126
  }, null, 2)
4089
4127
  }]
4090
4128
  };
4091
- } catch (e) {
4129
+ } catch (t2) {
4092
4130
  return {
4093
- content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : "Unknown error"}` }],
4131
+ content: [{ type: "text", text: `Error: ${t2 instanceof Error ? t2.message : "Unknown error"}` }],
4094
4132
  isError: true
4095
4133
  };
4096
4134
  }
@@ -4101,14 +4139,14 @@ class Q {
4101
4139
  programId: zod.z.string(),
4102
4140
  executionId: zod.z.string().optional()
4103
4141
  },
4104
- async ({ programId: r2, executionId: t2 }) => {
4142
+ async ({ programId: r2, executionId: e }) => {
4105
4143
  try {
4106
4144
  return {
4107
- content: [{ type: "text", text: `Execution started: ${await this.vmManager.restartExecution(r2, t2)} (set as current)` }]
4145
+ content: [{ type: "text", text: `Execution started: ${await this.vmManager.restartExecution(r2, e)} (set as current)` }]
4108
4146
  };
4109
- } catch (e) {
4147
+ } catch (t2) {
4110
4148
  return {
4111
- content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : "Unknown error"}` }],
4149
+ content: [{ type: "text", text: `Error: ${t2 instanceof Error ? t2.message : "Unknown error"}` }],
4112
4150
  isError: true
4113
4151
  };
4114
4152
  }
@@ -4118,48 +4156,110 @@ class Q {
4118
4156
  { filePath: zod.z.string() },
4119
4157
  async ({ filePath: r2 }) => {
4120
4158
  try {
4121
- const t2 = r$2.resolve(r2), e = await promises.readFile(t2, "utf-8"), s2 = D(e, r2);
4122
- if (!s2.valid)
4123
- return {
4124
- content: [{ type: "text", text: `Plan validation failed:
4125
- ${s2.errors.map((o) => `line ${o.line}: ${o.message}`).join(`
4159
+ const e = r$2.resolve(r2), t2 = await promises.readFile(e, "utf-8"), s2 = j(t2);
4160
+ let c2;
4161
+ if (s2.length === 0) {
4162
+ const g2 = T(t2, r2);
4163
+ if (!g2.valid)
4164
+ return {
4165
+ content: [{ type: "text", text: `Plan validation failed:
4166
+ ${g2.errors.map((i2) => `line ${i2.line}: ${i2.message}`).join(`
4126
4167
  `)}` }],
4127
- isError: true
4168
+ isError: true
4169
+ };
4170
+ const n2 = g2.plan;
4171
+ c2 = {
4172
+ mission: n2.mission,
4173
+ sourceFile: n2.sourceFile,
4174
+ blocks: n2.blocks.map((a2) => ({
4175
+ id: a2.id,
4176
+ title: a2.title,
4177
+ intro: a2.intro,
4178
+ red: a2.redTests.map((i2) => "- " + i2).join(`
4179
+ `),
4180
+ success: a2.success.map((i2) => "- [ ] " + i2).join(`
4181
+ `),
4182
+ planRef: `See ${n2.sourceFile} lines ${a2.startLine}-${a2.endLine}`
4183
+ }))
4128
4184
  };
4129
- const c2 = s2.plan, l = {
4130
- mission: c2.mission,
4131
- sourceFile: c2.sourceFile,
4132
- blocks: c2.blocks.map((a2) => ({
4133
- id: a2.id,
4134
- title: a2.title,
4135
- intro: a2.intro,
4136
- red: a2.redTests.map((o) => "- " + o).join(`
4185
+ } else {
4186
+ const g2 = r$2.dirname(e), n2 = T(t2, r2, { requireBlocks: false });
4187
+ if (!n2.valid)
4188
+ return {
4189
+ content: [{ type: "text", text: `Index plan validation failed:
4190
+ ${n2.errors.map((d2) => `line ${d2.line}: ${d2.message}`).join(`
4191
+ `)}` }],
4192
+ isError: true
4193
+ };
4194
+ const a2 = n2.plan.mission, i2 = [], p2 = /* @__PURE__ */ new Set(), k2 = [e];
4195
+ for (const u2 of s2) {
4196
+ const d2 = r$2.resolve(g2, u2);
4197
+ let w2;
4198
+ try {
4199
+ w2 = await promises.readFile(d2, "utf-8");
4200
+ } catch {
4201
+ return {
4202
+ content: [{ type: "text", text: `Error: Sub-file not found: ${u2}` }],
4203
+ isError: true
4204
+ };
4205
+ }
4206
+ const E3 = T(w2, u2, { requireMission: false });
4207
+ if (!E3.valid) {
4208
+ const l = E3.errors.map((x) => `${u2} line ${x.line}: ${x.message}`).join(`
4209
+ `);
4210
+ return {
4211
+ content: [{ type: "text", text: `Plan validation failed in ${u2}:
4212
+ ${l}` }],
4213
+ isError: true
4214
+ };
4215
+ }
4216
+ k2.push(d2);
4217
+ for (const l of E3.plan.blocks) {
4218
+ if (p2.has(l.id))
4219
+ return {
4220
+ content: [{ type: "text", text: `Error: Duplicate block id "${l.id}" in ${u2}` }],
4221
+ isError: true
4222
+ };
4223
+ p2.add(l.id), i2.push({
4224
+ id: l.id,
4225
+ title: l.title,
4226
+ intro: l.intro,
4227
+ red: l.redTests.map((x) => "- " + x).join(`
4137
4228
  `),
4138
- success: a2.success.map((o) => "- [ ] " + o).join(`
4229
+ success: l.success.map((x) => "- [ ] " + x).join(`
4139
4230
  `),
4140
- planRef: `See ${c2.sourceFile} lines ${a2.startLine}-${a2.endLine}`
4141
- }))
4142
- }, h2 = r$2.resolve(process.env.CVM_DATA_DIR || ".cvm");
4143
- await promises.mkdir(h2, { recursive: true });
4144
- const n2 = r$2.resolve(h2, "uplan.json");
4231
+ planRef: `See ${d2} lines ${l.startLine}-${l.endLine}`
4232
+ });
4233
+ }
4234
+ }
4235
+ c2 = {
4236
+ mission: a2,
4237
+ sourceFile: e,
4238
+ sourceFiles: k2,
4239
+ blocks: i2
4240
+ };
4241
+ }
4242
+ const m = r$2.resolve(process.env.CVM_DATA_DIR || ".cvm");
4243
+ await promises.mkdir(m, { recursive: true });
4244
+ const y2 = r$2.resolve(m, "uplan.json");
4145
4245
  try {
4146
- await promises.rename(n2, n2 + ".bak");
4246
+ await promises.rename(y2, y2 + ".bak");
4147
4247
  } catch {
4148
4248
  }
4149
- return await promises.writeFile(n2, JSON.stringify(l, null, 2), "utf-8"), {
4249
+ return await promises.writeFile(y2, JSON.stringify(c2, null, 2), "utf-8"), {
4150
4250
  content: [{
4151
4251
  type: "text",
4152
4252
  text: JSON.stringify({
4153
4253
  valid: true,
4154
4254
  blocks: c2.blocks.length,
4155
- path: n2,
4156
- blockIds: c2.blocks.map((a2) => a2.id)
4255
+ path: y2,
4256
+ blockIds: c2.blocks.map((g2) => g2.id)
4157
4257
  }, null, 2)
4158
4258
  }]
4159
4259
  };
4160
- } catch (t2) {
4260
+ } catch (e) {
4161
4261
  return {
4162
- content: [{ type: "text", text: `Error: ${t2 instanceof Error ? t2.message : "Unknown error"}` }],
4262
+ content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : "Unknown error"}` }],
4163
4263
  isError: true
4164
4264
  };
4165
4265
  }
@@ -4251,7 +4351,7 @@ async function main() {
4251
4351
  } else {
4252
4352
  g.info("[CVM] Using MongoDB storage");
4253
4353
  }
4254
- cvmServer = new Q(version);
4354
+ cvmServer = new Y(version);
4255
4355
  await cvmServer.start();
4256
4356
  g.info("CVM Server is running and ready to accept MCP connections");
4257
4357
  process.on("SIGINT", async () => {