cvm-server 0.12.0 → 0.13.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.
Files changed (3) hide show
  1. package/README.md +183 -157
  2. package/main.cjs +738 -424
  3. package/package.json +1 -1
package/main.cjs CHANGED
@@ -3,7 +3,7 @@ const mcp_js = require("@modelcontextprotocol/sdk/server/mcp.js");
3
3
  const stdio_js = require("@modelcontextprotocol/sdk/server/stdio.js");
4
4
  const zod = require("zod");
5
5
  const s$1 = require("typescript");
6
- const b$2 = require("fs");
6
+ const x$2 = require("fs");
7
7
  const r = require("path");
8
8
  const mongodb = require("mongodb");
9
9
  const promises = require("fs/promises");
@@ -27,14 +27,14 @@ function _interopNamespaceDefault(e2) {
27
27
  return Object.freeze(n2);
28
28
  }
29
29
  const s__namespace = /* @__PURE__ */ _interopNamespaceDefault(s$1);
30
- const b__namespace = /* @__PURE__ */ _interopNamespaceDefault(b$2);
30
+ const x__namespace = /* @__PURE__ */ _interopNamespaceDefault(x$2);
31
31
  const r__namespace = /* @__PURE__ */ _interopNamespaceDefault(r);
32
32
  const dotenv__namespace = /* @__PURE__ */ _interopNamespaceDefault(dotenv);
33
33
  var E$1 = Object.defineProperty;
34
- var f$2 = (e2, t2, i2) => t2 in e2 ? E$1(e2, t2, { enumerable: true, configurable: true, writable: true, value: i2 }) : e2[t2] = i2;
35
- var u$2 = (e2, t2, i2) => f$2(e2, typeof t2 != "symbol" ? t2 + "" : t2, i2);
36
- var n = /* @__PURE__ */ ((e2) => (e2.PUSH = "PUSH", e2.PUSH_UNDEFINED = "PUSH_UNDEFINED", e2.POP = "POP", e2.DUP = "DUP", e2.DUP2 = "DUP2", e2.SWAP = "SWAP", e2.LOAD = "LOAD", e2.STORE = "STORE", e2.CONCAT = "CONCAT", e2.ARRAY_NEW = "ARRAY_NEW", e2.ARRAY_PUSH = "ARRAY_PUSH", e2.ARRAY_GET = "ARRAY_GET", e2.ARRAY_SET = "ARRAY_SET", e2.ARRAY_LEN = "ARRAY_LEN", e2.ARRAY_MAP_PROP = "ARRAY_MAP_PROP", e2.ARRAY_FILTER_PROP = "ARRAY_FILTER_PROP", e2.STRING_LEN = "STRING_LEN", e2.STRING_SUBSTRING = "STRING_SUBSTRING", e2.STRING_INDEXOF = "STRING_INDEXOF", e2.STRING_SPLIT = "STRING_SPLIT", e2.STRING_SLICE = "STRING_SLICE", e2.STRING_CHARAT = "STRING_CHARAT", e2.STRING_TOUPPERCASE = "STRING_TOUPPERCASE", e2.STRING_TOLOWERCASE = "STRING_TOLOWERCASE", e2.LENGTH = "LENGTH", e2.TO_STRING = "TO_STRING", e2.JSON_PARSE = "JSON_PARSE", e2.TYPEOF = "TYPEOF", e2.ADD = "ADD", e2.SUB = "SUB", e2.MUL = "MUL", e2.DIV = "DIV", e2.MOD = "MOD", e2.UNARY_MINUS = "UNARY_MINUS", e2.UNARY_PLUS = "UNARY_PLUS", e2.INC = "INC", e2.DEC = "DEC", e2.EQ = "EQ", e2.NEQ = "NEQ", e2.LT = "LT", e2.GT = "GT", e2.LTE = "LTE", e2.GTE = "GTE", e2.EQ_STRICT = "EQ_STRICT", e2.NEQ_STRICT = "NEQ_STRICT", e2.JUMP = "JUMP", e2.JUMP_IF = "JUMP_IF", e2.JUMP_IF_FALSE = "JUMP_IF_FALSE", e2.JUMP_IF_TRUE = "JUMP_IF_TRUE", e2.CALL = "CALL", e2.RETURN = "RETURN", e2.AND = "AND", e2.OR = "OR", e2.NOT = "NOT", e2.BREAK = "BREAK", e2.CONTINUE = "CONTINUE", e2.ITER_START = "ITER_START", e2.ITER_NEXT = "ITER_NEXT", e2.ITER_END = "ITER_END", e2.FS_LIST_FILES = "FS_LIST_FILES", e2.FS_READ_FILE = "FS_READ_FILE", e2.FS_WRITE_FILE = "FS_WRITE_FILE", e2.OBJECT_CREATE = "OBJECT_CREATE", e2.PROPERTY_GET = "PROPERTY_GET", e2.PROPERTY_SET = "PROPERTY_SET", e2.JSON_STRINGIFY = "JSON_STRINGIFY", e2.GET = "GET", e2.SET = "SET", e2.CC = "CC", e2.PRINT = "PRINT", e2.HALT = "HALT", e2))(n || {});
37
- function R(e2) {
34
+ var _ = (e2, t2, i2) => t2 in e2 ? E$1(e2, t2, { enumerable: true, configurable: true, writable: true, value: i2 }) : e2[t2] = i2;
35
+ var x$1 = (e2, t2, i2) => _(e2, typeof t2 != "symbol" ? t2 + "" : t2, i2);
36
+ var n = /* @__PURE__ */ ((e2) => (e2.PUSH = "PUSH", e2.PUSH_UNDEFINED = "PUSH_UNDEFINED", e2.POP = "POP", e2.DUP = "DUP", e2.DUP2 = "DUP2", e2.SWAP = "SWAP", e2.LOAD = "LOAD", e2.STORE = "STORE", e2.CONCAT = "CONCAT", e2.ARRAY_NEW = "ARRAY_NEW", e2.ARRAY_PUSH = "ARRAY_PUSH", e2.ARRAY_GET = "ARRAY_GET", e2.ARRAY_SET = "ARRAY_SET", e2.ARRAY_LEN = "ARRAY_LEN", e2.ARRAY_MAP_PROP = "ARRAY_MAP_PROP", e2.ARRAY_FILTER_PROP = "ARRAY_FILTER_PROP", e2.ARRAY_SLICE = "ARRAY_SLICE", e2.ARRAY_JOIN = "ARRAY_JOIN", e2.ARRAY_INDEX_OF = "ARRAY_INDEX_OF", e2.STRING_LEN = "STRING_LEN", e2.STRING_SUBSTRING = "STRING_SUBSTRING", e2.STRING_INDEXOF = "STRING_INDEXOF", e2.STRING_SPLIT = "STRING_SPLIT", e2.STRING_SLICE = "STRING_SLICE", e2.STRING_CHARAT = "STRING_CHARAT", e2.STRING_TOUPPERCASE = "STRING_TOUPPERCASE", e2.STRING_TOLOWERCASE = "STRING_TOLOWERCASE", e2.STRING_INCLUDES = "STRING_INCLUDES", e2.STRING_ENDS_WITH = "STRING_ENDS_WITH", e2.STRING_STARTS_WITH = "STRING_STARTS_WITH", e2.STRING_TRIM = "STRING_TRIM", e2.STRING_TRIM_START = "STRING_TRIM_START", e2.STRING_TRIM_END = "STRING_TRIM_END", e2.STRING_REPLACE = "STRING_REPLACE", e2.STRING_REPLACE_ALL = "STRING_REPLACE_ALL", e2.STRING_LAST_INDEX_OF = "STRING_LAST_INDEX_OF", e2.STRING_REPEAT = "STRING_REPEAT", e2.STRING_PAD_START = "STRING_PAD_START", e2.STRING_PAD_END = "STRING_PAD_END", e2.LENGTH = "LENGTH", e2.TO_STRING = "TO_STRING", e2.JSON_PARSE = "JSON_PARSE", e2.TYPEOF = "TYPEOF", e2.ADD = "ADD", e2.SUB = "SUB", e2.MUL = "MUL", e2.DIV = "DIV", e2.MOD = "MOD", e2.UNARY_MINUS = "UNARY_MINUS", e2.UNARY_PLUS = "UNARY_PLUS", e2.INC = "INC", e2.DEC = "DEC", e2.EQ = "EQ", e2.NEQ = "NEQ", e2.LT = "LT", e2.GT = "GT", e2.LTE = "LTE", e2.GTE = "GTE", e2.EQ_STRICT = "EQ_STRICT", e2.NEQ_STRICT = "NEQ_STRICT", e2.JUMP = "JUMP", e2.JUMP_IF = "JUMP_IF", e2.JUMP_IF_FALSE = "JUMP_IF_FALSE", e2.JUMP_IF_TRUE = "JUMP_IF_TRUE", e2.CALL = "CALL", e2.RETURN = "RETURN", e2.AND = "AND", e2.OR = "OR", e2.NOT = "NOT", e2.BREAK = "BREAK", e2.CONTINUE = "CONTINUE", e2.ITER_START = "ITER_START", e2.ITER_NEXT = "ITER_NEXT", e2.ITER_END = "ITER_END", e2.FS_LIST_FILES = "FS_LIST_FILES", e2.FS_READ_FILE = "FS_READ_FILE", e2.FS_WRITE_FILE = "FS_WRITE_FILE", e2.OBJECT_CREATE = "OBJECT_CREATE", e2.PROPERTY_GET = "PROPERTY_GET", e2.PROPERTY_SET = "PROPERTY_SET", e2.JSON_STRINGIFY = "JSON_STRINGIFY", e2.GET = "GET", e2.SET = "SET", e2.CC = "CC", e2.PRINT = "PRINT", e2.HALT = "HALT", e2))(n || {});
37
+ function f$3(e2) {
38
38
  const t2 = [], i2 = [];
39
39
  let r2 = false;
40
40
  const a2 = s__namespace.createSourceFile(
@@ -43,12 +43,12 @@ function R(e2) {
43
43
  s__namespace.ScriptTarget.Latest,
44
44
  true
45
45
  );
46
- function m2(o2) {
47
- if (s__namespace.isFunctionDeclaration(o2) && o2.name && o2.name.text === "main" && (r2 = true, o2.parameters.length > 0 && t2.push("main() must not have parameters")), s__namespace.isCallExpression(o2) && s__namespace.isIdentifier(o2.expression)) {
48
- const S = o2.expression.text;
49
- ["setTimeout", "fetch", "require", "import"].includes(S) && t2.push(`Unsupported function: ${S}`);
46
+ function m2(T2) {
47
+ if (s__namespace.isFunctionDeclaration(T2) && T2.name && T2.name.text === "main" && (r2 = true, T2.parameters.length > 0 && t2.push("main() must not have parameters")), s__namespace.isCallExpression(T2) && s__namespace.isIdentifier(T2.expression)) {
48
+ const l2 = T2.expression.text;
49
+ ["setTimeout", "fetch", "require", "import"].includes(l2) && t2.push(`Unsupported function: ${l2}`);
50
50
  }
51
- s__namespace.forEachChild(o2, m2);
51
+ s__namespace.forEachChild(T2, m2);
52
52
  }
53
53
  return m2(a2), r2 || t2.push("Program must have a main() function"), t2.length === 0 && i2.push({ op: n.HALT }), {
54
54
  bytecode: i2,
@@ -56,10 +56,10 @@ function R(e2) {
56
56
  hasMain: r2
57
57
  };
58
58
  }
59
- let p$2 = class p {
59
+ class I {
60
60
  constructor() {
61
- u$2(this, "bytecode", []);
62
- u$2(this, "contextStack", []);
61
+ x$1(this, "bytecode", []);
62
+ x$1(this, "contextStack", []);
63
63
  }
64
64
  /**
65
65
  * Emit an instruction and return its index
@@ -133,76 +133,76 @@ let p$2 = class p {
133
133
  getUnclosedContexts() {
134
134
  return [...this.contextStack];
135
135
  }
136
- };
137
- const A$1 = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
136
+ }
137
+ const A = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
138
138
  i2(e2.expression);
139
139
  const a2 = t2.emit(n.JUMP_IF_FALSE, -1), m2 = {
140
140
  type: "if",
141
141
  endTargets: []
142
142
  };
143
143
  if (e2.elseStatement ? m2.elseTarget = a2 : m2.endTargets.push(a2), t2.pushContext(m2), r2(e2.thenStatement), e2.elseStatement) {
144
- const S = t2.emit(n.JUMP, -1);
145
- m2.endTargets.push(S);
146
- const c2 = t2.currentAddress();
147
- t2.patchJump(a2, c2), r2(e2.elseStatement);
148
- }
149
- const o2 = t2.popContext();
150
- if (o2) {
144
+ const l2 = t2.emit(n.JUMP, -1);
145
+ m2.endTargets.push(l2);
151
146
  const S = t2.currentAddress();
152
- t2.patchJumps(o2.endTargets, S);
147
+ t2.patchJump(a2, S), r2(e2.elseStatement);
153
148
  }
154
- }, P$1 = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
149
+ const T2 = t2.popContext();
150
+ if (T2) {
151
+ const l2 = t2.currentAddress();
152
+ t2.patchJumps(T2.endTargets, l2);
153
+ }
154
+ }, o$1 = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
155
155
  const a2 = t2.currentAddress();
156
156
  i2(e2.expression);
157
- const o2 = {
157
+ const T2 = {
158
158
  type: "loop",
159
159
  breakTargets: [t2.emit(n.JUMP_IF_FALSE, -1)],
160
160
  continueTargets: [],
161
161
  endTargets: [],
162
162
  startAddress: a2
163
163
  };
164
- t2.pushContext(o2), r2(e2.statement), t2.emit(n.JUMP, a2);
165
- const S = t2.popContext();
166
- if (S) {
167
- const c2 = t2.currentAddress();
168
- t2.patchJumps(S.breakTargets || [], c2);
164
+ t2.pushContext(T2), r2(e2.statement), t2.emit(n.JUMP, a2);
165
+ const l2 = t2.popContext();
166
+ if (l2) {
167
+ const S = t2.currentAddress();
168
+ t2.patchJumps(l2.breakTargets || [], S);
169
169
  }
170
- }, h$1 = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
170
+ }, N = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
171
171
  const a2 = e2.initializer, m2 = e2.expression;
172
- let o2;
172
+ let T2;
173
173
  if (s__namespace.isVariableDeclarationList(a2))
174
- o2 = a2.declarations[0].name.getText();
174
+ T2 = a2.declarations[0].name.getText();
175
175
  else if (s__namespace.isIdentifier(a2))
176
- o2 = a2.text;
176
+ T2 = a2.text;
177
177
  else
178
178
  throw new Error("Unsupported for-of variable declaration");
179
179
  i2(m2), t2.emit(n.ITER_START);
180
- const S = t2.currentAddress();
180
+ const l2 = t2.currentAddress();
181
181
  t2.emit(n.ITER_NEXT);
182
- const c2 = t2.emit(n.JUMP_IF_FALSE, -1);
183
- t2.emit(n.STORE, o2);
184
- const l2 = {
182
+ const S = t2.emit(n.JUMP_IF_FALSE, -1);
183
+ t2.emit(n.STORE, T2);
184
+ const c2 = {
185
185
  type: "foreach",
186
- breakTargets: [c2],
186
+ breakTargets: [S],
187
187
  continueTargets: [],
188
188
  endTargets: [],
189
- startAddress: S,
190
- iterVariable: o2
189
+ startAddress: l2,
190
+ iterVariable: T2
191
191
  };
192
- t2.pushContext(l2), r2(e2.statement), t2.emit(n.JUMP, S);
193
- const T = t2.popContext();
194
- if (T) {
195
- const x2 = t2.currentAddress();
196
- t2.patchJumps(T.breakTargets || [], x2), t2.emit(n.ITER_END);
192
+ t2.pushContext(c2), r2(e2.statement), t2.emit(n.JUMP, l2);
193
+ const R = t2.popContext();
194
+ if (R) {
195
+ const u2 = t2.currentAddress();
196
+ t2.patchJumps(R.breakTargets || [], u2), t2.emit(n.ITER_END);
197
197
  }
198
- }, I = (e2, t2, { compileStatement: i2 }) => {
198
+ }, P$1 = (e2, t2, { compileStatement: i2 }) => {
199
199
  e2.statements.forEach((r2) => {
200
200
  i2(r2);
201
201
  });
202
- }, _$1 = (e2, t2, { compileExpression: i2 }) => {
202
+ }, g = (e2, t2, { compileExpression: i2 }) => {
203
203
  const r2 = e2.declarationList.declarations[0];
204
204
  r2.initializer && (i2(r2.initializer), t2.emit(n.STORE, r2.name.getText()));
205
- }, g = (e2, t2, { compileExpression: i2 }) => {
205
+ }, h$1 = (e2, t2, { compileExpression: i2 }) => {
206
206
  const r2 = e2.expression;
207
207
  if (s__namespace.isBinaryExpression(r2)) {
208
208
  const a2 = r2.operatorToken.kind;
@@ -245,9 +245,9 @@ const A$1 = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
245
245
  s__namespace.isCallExpression(r2) && s__namespace.isPropertyAccessExpression(r2.expression) && r2.expression.expression.getText() === "console" && r2.expression.name.getText() === "log" ? (r2.arguments.forEach((a2) => {
246
246
  i2(a2);
247
247
  }), t2.emit(n.PRINT)) : s__namespace.isCallExpression(r2) && s__namespace.isIdentifier(r2.expression) && r2.expression.text === "CC" ? (r2.arguments.length > 0 && i2(r2.arguments[0]), t2.emit(n.CC), t2.emit(n.POP)) : s__namespace.isCallExpression(r2) && s__namespace.isPropertyAccessExpression(r2.expression) && r2.expression.name.getText() === "push" ? (i2(r2.expression.expression), r2.arguments.length > 0 && i2(r2.arguments[0]), t2.emit(n.ARRAY_PUSH)) : (s__namespace.isPostfixUnaryExpression(r2) || s__namespace.isPrefixUnaryExpression(r2), i2(r2), t2.emit(n.POP));
248
- }, y$1 = (e2, t2, { compileExpression: i2 }) => {
248
+ }, U = (e2, t2, { compileExpression: i2 }) => {
249
249
  e2.expression ? i2(e2.expression) : t2.emit(n.PUSH, null), t2.emit(n.RETURN);
250
- }, N = (e2, t2, i2) => {
250
+ }, p$2 = (e2, t2, i2) => {
251
251
  const r2 = t2.findLoopContext();
252
252
  if (r2) {
253
253
  r2.type === "foreach" && t2.emit(n.ITER_END);
@@ -255,46 +255,46 @@ const A$1 = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
255
255
  r2.breakTargets = r2.breakTargets || [], r2.breakTargets.push(a2);
256
256
  } else
257
257
  i2.reportError(e2, "break statement not in loop");
258
- }, U = (e2, t2, i2) => {
258
+ }, y$1 = (e2, t2, i2) => {
259
259
  const r2 = t2.findLoopContext();
260
260
  if (r2 && r2.startAddress !== void 0) {
261
261
  const a2 = t2.emit(n.CONTINUE, r2.startAddress);
262
262
  r2.continueTargets = r2.continueTargets || [], r2.continueTargets.push(a2);
263
263
  } else
264
264
  i2.reportError(e2, "continue statement not in loop");
265
- }, k = {
266
- [s__namespace.SyntaxKind.IfStatement]: A$1,
267
- [s__namespace.SyntaxKind.WhileStatement]: P$1,
268
- [s__namespace.SyntaxKind.ForOfStatement]: h$1,
269
- [s__namespace.SyntaxKind.Block]: I,
270
- [s__namespace.SyntaxKind.VariableStatement]: _$1,
271
- [s__namespace.SyntaxKind.ExpressionStatement]: g,
272
- [s__namespace.SyntaxKind.ReturnStatement]: y$1,
273
- [s__namespace.SyntaxKind.BreakStatement]: N,
274
- [s__namespace.SyntaxKind.ContinueStatement]: U
275
- }, L = (e2, t2, i2) => {
265
+ }, L = {
266
+ [s__namespace.SyntaxKind.IfStatement]: A,
267
+ [s__namespace.SyntaxKind.WhileStatement]: o$1,
268
+ [s__namespace.SyntaxKind.ForOfStatement]: N,
269
+ [s__namespace.SyntaxKind.Block]: P$1,
270
+ [s__namespace.SyntaxKind.VariableStatement]: g,
271
+ [s__namespace.SyntaxKind.ExpressionStatement]: h$1,
272
+ [s__namespace.SyntaxKind.ReturnStatement]: U,
273
+ [s__namespace.SyntaxKind.BreakStatement]: p$2,
274
+ [s__namespace.SyntaxKind.ContinueStatement]: y$1
275
+ }, k = (e2, t2, i2) => {
276
276
  t2.emit(n.PUSH, e2.text);
277
- }, F$1 = (e2, t2, i2) => {
277
+ }, G = (e2, t2, i2) => {
278
278
  t2.emit(n.PUSH, Number(e2.text));
279
- }, K$1 = (e2, t2, i2) => {
279
+ }, D$1 = (e2, t2, i2) => {
280
280
  t2.emit(n.PUSH, true);
281
- }, b$1 = (e2, t2, i2) => {
281
+ }, F$1 = (e2, t2, i2) => {
282
282
  t2.emit(n.PUSH, false);
283
- }, D$1 = (e2, t2, i2) => {
283
+ }, K = (e2, t2, i2) => {
284
284
  t2.emit(n.PUSH, null);
285
- }, d$3 = (e2, t2, i2) => {
285
+ }, H = (e2, t2, i2) => {
286
286
  e2.text === "undefined" ? t2.emit(n.PUSH_UNDEFINED) : t2.emit(n.LOAD, e2.text);
287
- }, G$1 = (e2, t2, { compileExpression: i2 }) => {
287
+ }, b$2 = (e2, t2, { compileExpression: i2 }) => {
288
288
  t2.emit(n.ARRAY_NEW), e2.elements.forEach((r2) => {
289
289
  i2(r2), t2.emit(n.ARRAY_PUSH);
290
290
  });
291
- }, H$1 = (e2, t2, { compileExpression: i2 }) => {
292
- i2(e2.expression);
293
291
  }, M$2 = (e2, t2, { compileExpression: i2 }) => {
292
+ i2(e2.expression);
293
+ }, Y = (e2, t2, { compileExpression: i2 }) => {
294
294
  e2.name.text === "length" ? (i2(e2.expression), t2.emit(n.LENGTH)) : (i2(e2.expression), t2.emit(n.PUSH, e2.name.text), t2.emit(n.PROPERTY_GET));
295
- }, Y = (e2, t2, { compileExpression: i2, reportError: r2 }) => {
295
+ }, J = (e2, t2, { compileExpression: i2, reportError: r2 }) => {
296
296
  i2(e2.expression), e2.argumentExpression ? i2(e2.argumentExpression) : r2(e2, "Element access requires an index expression"), t2.emit(n.ARRAY_GET);
297
- }, J = (e2, t2, { compileExpression: i2 }) => {
297
+ }, w$1 = (e2, t2, { compileExpression: i2 }) => {
298
298
  switch (e2.operator) {
299
299
  case s__namespace.SyntaxKind.ExclamationToken:
300
300
  i2(e2.operand), t2.emit(n.NOT);
@@ -312,7 +312,7 @@ const A$1 = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
312
312
  s__namespace.isIdentifier(e2.operand) && (t2.emit(n.PUSH, e2.operand.text), t2.emit(n.DEC, false));
313
313
  break;
314
314
  }
315
- }, w = (e2, t2, { compileExpression: i2 }) => {
315
+ }, B$1 = (e2, t2, { compileExpression: i2 }) => {
316
316
  switch (e2.operator) {
317
317
  case s__namespace.SyntaxKind.PlusPlusToken:
318
318
  s__namespace.isIdentifier(e2.operand) && (t2.emit(n.PUSH, e2.operand.text), t2.emit(n.INC, true));
@@ -321,7 +321,7 @@ const A$1 = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
321
321
  s__namespace.isIdentifier(e2.operand) && (t2.emit(n.PUSH, e2.operand.text), t2.emit(n.DEC, true));
322
322
  break;
323
323
  }
324
- }, B$1 = (e2, t2, { compileExpression: i2 }) => {
324
+ }, q = (e2, t2, { compileExpression: i2 }) => {
325
325
  const r2 = e2.operatorToken.kind;
326
326
  switch (i2(e2.left), i2(e2.right), r2) {
327
327
  case s__namespace.SyntaxKind.PlusToken:
@@ -370,17 +370,17 @@ const A$1 = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
370
370
  t2.emit(n.OR);
371
371
  break;
372
372
  }
373
- }, q = (e2, t2, { compileExpression: i2 }) => {
373
+ }, W$1 = (e2, t2, { compileExpression: i2 }) => {
374
374
  i2(e2.condition);
375
375
  const r2 = t2.emit(n.JUMP_IF_FALSE, -1);
376
376
  i2(e2.whenTrue);
377
377
  const a2 = t2.emit(n.JUMP, -1), m2 = t2.currentAddress();
378
378
  t2.patchJump(r2, m2), i2(e2.whenFalse);
379
- const o2 = t2.currentAddress();
380
- t2.patchJump(a2, o2);
379
+ const T2 = t2.currentAddress();
380
+ t2.patchJump(a2, T2);
381
381
  }, C$1 = (e2, t2, { compileExpression: i2 }) => {
382
382
  i2(e2.expression), t2.emit(n.TYPEOF);
383
- }, O$1 = (e2, t2, { compileExpression: i2, reportError: r2 }) => {
383
+ }, V = (e2, t2, { compileExpression: i2, reportError: r2 }) => {
384
384
  if (s__namespace.isPropertyAccessExpression(e2.expression) && s__namespace.isIdentifier(e2.expression.expression) && e2.expression.expression.text === "fs") {
385
385
  const a2 = e2.expression.name.text;
386
386
  if (a2 === "listFiles")
@@ -410,7 +410,9 @@ const A$1 = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
410
410
  else if (a2 === "split")
411
411
  i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_SPLIT);
412
412
  else if (a2 === "slice")
413
- i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), e2.arguments.length > 1 && i2(e2.arguments[1]), t2.emit(n.STRING_SLICE);
413
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), e2.arguments.length > 1 ? i2(e2.arguments[1]) : t2.emit(n.PUSH_UNDEFINED), t2.emit(n.STRING_SLICE);
414
+ else if (a2 === "join")
415
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ","), t2.emit(n.ARRAY_JOIN);
414
416
  else if (a2 === "charAt")
415
417
  i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), t2.emit(n.STRING_CHARAT);
416
418
  else if (a2 === "toUpperCase")
@@ -419,11 +421,37 @@ const A$1 = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
419
421
  i2(e2.expression.expression), t2.emit(n.STRING_TOLOWERCASE);
420
422
  else if (a2 === "toString")
421
423
  i2(e2.expression.expression), t2.emit(n.TO_STRING);
424
+ else if (a2 === "includes")
425
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_INCLUDES);
426
+ else if (a2 === "endsWith")
427
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_ENDS_WITH);
428
+ else if (a2 === "startsWith")
429
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_STARTS_WITH);
430
+ else if (a2 === "trim")
431
+ i2(e2.expression.expression), t2.emit(n.STRING_TRIM);
432
+ else if (a2 === "trimStart")
433
+ i2(e2.expression.expression), t2.emit(n.STRING_TRIM_START);
434
+ else if (a2 === "trimEnd")
435
+ i2(e2.expression.expression), t2.emit(n.STRING_TRIM_END);
436
+ else if (a2 === "replace")
437
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), e2.arguments.length > 1 ? i2(e2.arguments[1]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_REPLACE);
438
+ else if (a2 === "replaceAll")
439
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), e2.arguments.length > 1 ? i2(e2.arguments[1]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_REPLACE_ALL);
440
+ else if (a2 === "lastIndexOf")
441
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, ""), t2.emit(n.STRING_LAST_INDEX_OF);
442
+ else if (a2 === "repeat")
443
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), t2.emit(n.STRING_REPEAT);
444
+ else if (a2 === "padStart")
445
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), e2.arguments.length > 1 ? i2(e2.arguments[1]) : t2.emit(n.PUSH, " "), t2.emit(n.STRING_PAD_START);
446
+ else if (a2 === "padEnd")
447
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH, 0), e2.arguments.length > 1 ? i2(e2.arguments[1]) : t2.emit(n.PUSH, " "), t2.emit(n.STRING_PAD_END);
448
+ else if (a2 === "push")
449
+ i2(e2.expression.expression), e2.arguments.length > 0 ? i2(e2.arguments[0]) : t2.emit(n.PUSH_UNDEFINED), t2.emit(n.ARRAY_PUSH);
422
450
  else
423
451
  throw new Error(`Method call '${a2}' is not supported`);
424
452
  } else
425
453
  throw new Error("Unsupported call expression");
426
- }, V = (e2, t2, { compileExpression: i2 }) => {
454
+ }, O = (e2, t2, { compileExpression: i2 }) => {
427
455
  t2.emit(n.OBJECT_CREATE);
428
456
  for (const r2 of e2.properties)
429
457
  if (s__namespace.isPropertyAssignment(r2)) {
@@ -440,82 +468,82 @@ const A$1 = (e2, t2, { compileExpression: i2, compileStatement: r2 }) => {
440
468
  t2.emit(n.PUSH, a2), t2.emit(n.LOAD, a2), t2.emit(n.PROPERTY_SET);
441
469
  } else
442
470
  throw new Error("Unsupported property type in object literal");
443
- }, W$1 = {
444
- [s__namespace.SyntaxKind.StringLiteral]: L,
445
- [s__namespace.SyntaxKind.NumericLiteral]: F$1,
446
- [s__namespace.SyntaxKind.TrueKeyword]: K$1,
447
- [s__namespace.SyntaxKind.FalseKeyword]: b$1,
448
- [s__namespace.SyntaxKind.NullKeyword]: D$1,
449
- [s__namespace.SyntaxKind.Identifier]: d$3,
450
- [s__namespace.SyntaxKind.ArrayLiteralExpression]: G$1,
451
- [s__namespace.SyntaxKind.BinaryExpression]: B$1,
452
- [s__namespace.SyntaxKind.PrefixUnaryExpression]: J,
453
- [s__namespace.SyntaxKind.PostfixUnaryExpression]: w,
454
- [s__namespace.SyntaxKind.CallExpression]: O$1,
455
- [s__namespace.SyntaxKind.PropertyAccessExpression]: M$2,
456
- [s__namespace.SyntaxKind.ElementAccessExpression]: Y,
457
- [s__namespace.SyntaxKind.ConditionalExpression]: q,
471
+ }, Q$1 = {
472
+ [s__namespace.SyntaxKind.StringLiteral]: k,
473
+ [s__namespace.SyntaxKind.NumericLiteral]: G,
474
+ [s__namespace.SyntaxKind.TrueKeyword]: D$1,
475
+ [s__namespace.SyntaxKind.FalseKeyword]: F$1,
476
+ [s__namespace.SyntaxKind.NullKeyword]: K,
477
+ [s__namespace.SyntaxKind.Identifier]: H,
478
+ [s__namespace.SyntaxKind.ArrayLiteralExpression]: b$2,
479
+ [s__namespace.SyntaxKind.BinaryExpression]: q,
480
+ [s__namespace.SyntaxKind.PrefixUnaryExpression]: w$1,
481
+ [s__namespace.SyntaxKind.PostfixUnaryExpression]: B$1,
482
+ [s__namespace.SyntaxKind.CallExpression]: V,
483
+ [s__namespace.SyntaxKind.PropertyAccessExpression]: Y,
484
+ [s__namespace.SyntaxKind.ElementAccessExpression]: J,
485
+ [s__namespace.SyntaxKind.ConditionalExpression]: W$1,
458
486
  [s__namespace.SyntaxKind.TypeOfExpression]: C$1,
459
- [s__namespace.SyntaxKind.ParenthesizedExpression]: H$1,
460
- [s__namespace.SyntaxKind.ObjectLiteralExpression]: V
487
+ [s__namespace.SyntaxKind.ParenthesizedExpression]: M$2,
488
+ [s__namespace.SyntaxKind.ObjectLiteralExpression]: O
461
489
  };
462
- function j$2(e2) {
463
- const t2 = [], i2 = R(e2);
490
+ function X(e2) {
491
+ const t2 = [], i2 = f$3(e2);
464
492
  if (i2.errors.length > 0)
465
493
  return {
466
494
  success: false,
467
495
  bytecode: [],
468
- errors: i2.errors.map((c2) => ({
469
- message: c2,
496
+ errors: i2.errors.map((S) => ({
497
+ message: S,
470
498
  line: 0,
471
499
  character: 0
472
500
  }))
473
501
  };
474
- const r2 = new p$2(), a2 = s__namespace.createSourceFile("program.ts", e2, s__namespace.ScriptTarget.Latest, true), m2 = {
475
- compileStatement: o2,
476
- compileExpression: S,
477
- reportError: (c2, l2) => {
478
- const { line: T, character: x2 } = a2.getLineAndCharacterOfPosition(c2.getStart());
502
+ const r2 = new I(), a2 = s__namespace.createSourceFile("program.ts", e2, s__namespace.ScriptTarget.Latest, true), m2 = {
503
+ compileStatement: T2,
504
+ compileExpression: l2,
505
+ reportError: (S, c2) => {
506
+ const { line: R, character: u2 } = a2.getLineAndCharacterOfPosition(S.getStart());
479
507
  throw t2.push({
480
- message: l2,
481
- line: T + 1,
508
+ message: c2,
509
+ line: R + 1,
482
510
  // TypeScript uses 0-based lines
483
- character: x2 + 1
511
+ character: u2 + 1
484
512
  // TypeScript uses 0-based columns
485
- }), new Error(l2);
513
+ }), new Error(c2);
486
514
  }
487
515
  };
488
- function o2(c2) {
489
- const l2 = k[c2.kind];
490
- if (l2)
491
- l2(c2, r2, m2);
516
+ function T2(S) {
517
+ const c2 = L[S.kind];
518
+ if (c2)
519
+ c2(S, r2, m2);
492
520
  else {
493
- const { line: T, character: x2 } = a2.getLineAndCharacterOfPosition(c2.getStart());
521
+ const { line: R, character: u2 } = a2.getLineAndCharacterOfPosition(S.getStart());
494
522
  t2.push({
495
- message: `Unsupported statement: ${s__namespace.SyntaxKind[c2.kind]}`,
496
- line: T + 1,
497
- character: x2 + 1
523
+ message: `Unsupported statement: ${s__namespace.SyntaxKind[S.kind]}`,
524
+ line: R + 1,
525
+ character: u2 + 1
498
526
  });
499
527
  }
500
528
  }
501
- function S(c2) {
502
- const l2 = W$1[c2.kind];
503
- if (l2)
504
- l2(c2, r2, m2);
529
+ function l2(S) {
530
+ const c2 = Q$1[S.kind];
531
+ if (c2)
532
+ c2(S, r2, m2);
505
533
  else {
506
- const { line: T, character: x2 } = a2.getLineAndCharacterOfPosition(c2.getStart());
534
+ const { line: R, character: u2 } = a2.getLineAndCharacterOfPosition(S.getStart());
507
535
  t2.push({
508
- message: `Unsupported expression: ${s__namespace.SyntaxKind[c2.kind]}`,
509
- line: T + 1,
510
- character: x2 + 1
536
+ message: `Unsupported expression: ${s__namespace.SyntaxKind[S.kind]}`,
537
+ line: R + 1,
538
+ character: u2 + 1
511
539
  });
512
540
  }
513
541
  }
514
- return a2.forEachChild((c2) => {
515
- var l2;
516
- s__namespace.isFunctionDeclaration(c2) && ((l2 = c2.name) == null ? void 0 : l2.text) === "main" && c2.body && c2.body.statements.forEach((T) => {
542
+ return a2.forEachChild((S) => {
543
+ var c2;
544
+ s__namespace.isFunctionDeclaration(S) && ((c2 = S.name) == null ? void 0 : c2.text) === "main" && S.body && S.body.statements.forEach((R) => {
517
545
  try {
518
- o2(T);
546
+ T2(R);
519
547
  } catch {
520
548
  }
521
549
  });
@@ -534,7 +562,7 @@ function i$1(r2) {
534
562
  function e(r2) {
535
563
  return typeof r2 == "boolean";
536
564
  }
537
- function f$1(r2) {
565
+ function f$2(r2) {
538
566
  return r2 === null;
539
567
  }
540
568
  function o(r2) {
@@ -549,22 +577,22 @@ function y(r2) {
549
577
  function u$1(r2) {
550
578
  return r2 !== null && typeof r2 == "object" && "type" in r2 && r2.type === "array-ref";
551
579
  }
552
- function b(r2) {
580
+ function b$1(r2) {
553
581
  return r2 !== null && typeof r2 == "object" && "type" in r2 && r2.type === "object-ref";
554
582
  }
555
583
  function p$1(r2) {
556
- return t(r2) ? r2 : i$1(r2) || e(r2) ? r2.toString() : f$1(r2) ? "null" : c(r2) ? "undefined" : o(r2) ? `[array:${r2.elements.length}]` : y(r2) ? "[object Object]" : String(r2);
584
+ return t(r2) ? r2 : i$1(r2) || e(r2) ? r2.toString() : f$2(r2) ? "null" : c(r2) ? "undefined" : o(r2) ? `[array:${r2.elements.length}]` : y(r2) ? "[object Object]" : String(r2);
557
585
  }
558
586
  function j$1(r2) {
559
- return e(r2) ? r2 : f$1(r2) || c(r2) ? false : i$1(r2) ? r2 !== 0 : t(r2) ? r2 !== "" : o(r2) || y(r2) ? true : !!r2;
587
+ return e(r2) ? r2 : f$2(r2) || c(r2) ? false : i$1(r2) ? r2 !== 0 : t(r2) ? r2 !== "" : o(r2) || y(r2) ? true : !!r2;
560
588
  }
561
- function d$2(r2) {
562
- return t(r2) ? "string" : i$1(r2) ? "number" : e(r2) ? "boolean" : f$1(r2) ? "null" : c(r2) ? "undefined" : o(r2) || u$1(r2) ? "array" : y(r2) || b(r2) ? "object" : "unknown";
589
+ function d$1(r2) {
590
+ return t(r2) ? "string" : i$1(r2) ? "number" : e(r2) ? "boolean" : f$2(r2) ? "null" : c(r2) ? "undefined" : o(r2) || u$1(r2) ? "array" : y(r2) || b$1(r2) ? "object" : "unknown";
563
591
  }
564
592
  function m(r2) {
565
593
  if (i$1(r2)) return r2;
566
594
  if (e(r2)) return r2 ? 1 : 0;
567
- if (f$1(r2)) return 0;
595
+ if (f$2(r2)) return 0;
568
596
  if (c(r2)) return NaN;
569
597
  if (t(r2)) {
570
598
  const n2 = r2.trim();
@@ -581,10 +609,10 @@ function C() {
581
609
  function M$1(r2 = {}) {
582
610
  return { type: "object", properties: r2 };
583
611
  }
584
- var d$1 = Object.defineProperty;
585
- var h = (s2, t2, n2) => t2 in s2 ? d$1(s2, t2, { enumerable: true, configurable: true, writable: true, value: n2 }) : s2[t2] = n2;
612
+ var d = Object.defineProperty;
613
+ var h = (s2, t2, n2) => t2 in s2 ? d(s2, t2, { enumerable: true, configurable: true, writable: true, value: n2 }) : s2[t2] = n2;
586
614
  var a = (s2, t2, n2) => h(s2, typeof t2 != "symbol" ? t2 + "" : t2, n2);
587
- class p2 {
615
+ class p {
588
616
  constructor(t2) {
589
617
  a(this, "connected", false);
590
618
  a(this, "programsDir");
@@ -596,7 +624,7 @@ class p2 {
596
624
  return r__namespace.join(this.dataDir, "metadata.json");
597
625
  }
598
626
  async connect() {
599
- await b$2.promises.mkdir(this.dataDir, { recursive: true }), await b$2.promises.mkdir(this.programsDir, { recursive: true }), await b$2.promises.mkdir(this.executionsDir, { recursive: true }), await b$2.promises.mkdir(this.outputsDir, { recursive: true }), this.connected = true;
627
+ await x$2.promises.mkdir(this.dataDir, { recursive: true }), await x$2.promises.mkdir(this.programsDir, { recursive: true }), await x$2.promises.mkdir(this.executionsDir, { recursive: true }), await x$2.promises.mkdir(this.outputsDir, { recursive: true }), this.connected = true;
600
628
  }
601
629
  async disconnect() {
602
630
  this.connected = false;
@@ -607,13 +635,13 @@ class p2 {
607
635
  async saveProgram(t2) {
608
636
  if (!this.connected) throw new Error("Not connected");
609
637
  const n2 = r__namespace.join(this.programsDir, `${t2.id}.json`), e2 = JSON.stringify(t2, null, 2);
610
- await b$2.promises.writeFile(n2, e2, "utf-8");
638
+ await x$2.promises.writeFile(n2, e2, "utf-8");
611
639
  }
612
640
  async getProgram(t2) {
613
641
  if (!this.connected) throw new Error("Not connected");
614
642
  const n2 = r__namespace.join(this.programsDir, `${t2}.json`);
615
643
  try {
616
- const e2 = await b$2.promises.readFile(n2, "utf-8"), o2 = JSON.parse(e2);
644
+ const e2 = await x$2.promises.readFile(n2, "utf-8"), o2 = JSON.parse(e2);
617
645
  return o2.created = new Date(o2.created), o2.updated && (o2.updated = new Date(o2.updated)), o2;
618
646
  } catch (e2) {
619
647
  if (e2.code === "ENOENT")
@@ -624,13 +652,13 @@ class p2 {
624
652
  async saveExecution(t2) {
625
653
  if (!this.connected) throw new Error("Not connected");
626
654
  const n2 = r__namespace.join(this.executionsDir, `${t2.id}.json`), e2 = JSON.stringify(t2, null, 2);
627
- await b$2.promises.writeFile(n2, e2, "utf-8");
655
+ await x$2.promises.writeFile(n2, e2, "utf-8");
628
656
  }
629
657
  async getExecution(t2) {
630
658
  if (!this.connected) throw new Error("Not connected");
631
659
  const n2 = r__namespace.join(this.executionsDir, `${t2}.json`);
632
660
  try {
633
- const e2 = await b$2.promises.readFile(n2, "utf-8"), o2 = JSON.parse(e2);
661
+ const e2 = await x$2.promises.readFile(n2, "utf-8"), o2 = JSON.parse(e2);
634
662
  return o2.created = new Date(o2.created), o2.updated && (o2.updated = new Date(o2.updated)), o2;
635
663
  } catch (e2) {
636
664
  if (e2.code === "ENOENT")
@@ -643,13 +671,13 @@ class p2 {
643
671
  const e2 = r__namespace.join(this.outputsDir, `${t2}.output`), o2 = n2.join(`
644
672
  `) + `
645
673
  `;
646
- await b$2.promises.appendFile(e2, o2, "utf-8");
674
+ await x$2.promises.appendFile(e2, o2, "utf-8");
647
675
  }
648
676
  async getOutput(t2) {
649
677
  if (!this.connected) throw new Error("Not connected");
650
678
  const n2 = r__namespace.join(this.outputsDir, `${t2}.output`);
651
679
  try {
652
- return (await b$2.promises.readFile(n2, "utf-8")).split(`
680
+ return (await x$2.promises.readFile(n2, "utf-8")).split(`
653
681
  `).filter((o2) => o2.length > 0);
654
682
  } catch (e2) {
655
683
  if (e2.code === "ENOENT")
@@ -659,7 +687,7 @@ class p2 {
659
687
  }
660
688
  async listExecutions() {
661
689
  if (!this.connected) throw new Error("Not connected");
662
- const t2 = await b$2.promises.readdir(this.executionsDir), n2 = [];
690
+ const t2 = await x$2.promises.readdir(this.executionsDir), n2 = [];
663
691
  for (const e2 of t2)
664
692
  if (e2.endsWith(".json")) {
665
693
  const o2 = e2.slice(0, -5), i2 = await this.getExecution(o2);
@@ -670,7 +698,7 @@ class p2 {
670
698
  async getCurrentExecutionId() {
671
699
  if (!this.connected) throw new Error("Not connected");
672
700
  try {
673
- const t2 = await b$2.promises.readFile(this.metadataFile, "utf-8");
701
+ const t2 = await x$2.promises.readFile(this.metadataFile, "utf-8");
674
702
  return JSON.parse(t2).currentExecutionId || null;
675
703
  } catch (t2) {
676
704
  if (t2.code === "ENOENT")
@@ -681,19 +709,19 @@ class p2 {
681
709
  async setCurrentExecutionId(t2) {
682
710
  if (!this.connected) throw new Error("Not connected");
683
711
  const n2 = { currentExecutionId: t2 };
684
- await b$2.promises.writeFile(this.metadataFile, JSON.stringify(n2, null, 2), "utf-8");
712
+ await x$2.promises.writeFile(this.metadataFile, JSON.stringify(n2, null, 2), "utf-8");
685
713
  }
686
714
  async deleteExecution(t2) {
687
715
  if (!this.connected) throw new Error("Not connected");
688
716
  const n2 = r__namespace.join(this.executionsDir, `${t2}.json`);
689
717
  try {
690
- await b$2.promises.unlink(n2);
718
+ await x$2.promises.unlink(n2);
691
719
  } catch (i2) {
692
720
  if (i2.code !== "ENOENT") throw i2;
693
721
  }
694
722
  const e2 = r__namespace.join(this.outputsDir, `${t2}.output`);
695
723
  try {
696
- await b$2.promises.unlink(e2);
724
+ await x$2.promises.unlink(e2);
697
725
  } catch (i2) {
698
726
  if (i2.code !== "ENOENT") throw i2;
699
727
  }
@@ -701,7 +729,7 @@ class p2 {
701
729
  }
702
730
  async listPrograms() {
703
731
  if (!this.connected) throw new Error("Not connected");
704
- const t2 = await b$2.promises.readdir(this.programsDir), n2 = [];
732
+ const t2 = await x$2.promises.readdir(this.programsDir), n2 = [];
705
733
  for (const e2 of t2)
706
734
  if (e2.endsWith(".json")) {
707
735
  const o2 = e2.slice(0, -5), i2 = await this.getProgram(o2);
@@ -713,13 +741,13 @@ class p2 {
713
741
  if (!this.connected) throw new Error("Not connected");
714
742
  const n2 = r__namespace.join(this.programsDir, `${t2}.json`);
715
743
  try {
716
- await b$2.promises.unlink(n2);
744
+ await x$2.promises.unlink(n2);
717
745
  } catch (e2) {
718
746
  if (e2.code !== "ENOENT") throw e2;
719
747
  }
720
748
  }
721
749
  }
722
- class f {
750
+ let f$1 = class f {
723
751
  constructor(t2) {
724
752
  a(this, "client");
725
753
  a(this, "db", null);
@@ -821,28 +849,28 @@ class f {
821
849
  async deleteProgram(t2) {
822
850
  await this.getCollection("programs").deleteOne({ id: t2 });
823
851
  }
824
- }
852
+ };
825
853
  class E {
826
854
  static create(t2) {
827
855
  const n2 = (t2 == null ? void 0 : t2.type) || process.env.CVM_STORAGE_TYPE || "file";
828
856
  switch (n2) {
829
857
  case "file": {
830
858
  const e2 = (t2 == null ? void 0 : t2.dataDir) || process.env.CVM_DATA_DIR || ".cvm";
831
- return new p2(e2);
859
+ return new p(e2);
832
860
  }
833
861
  case "mongodb": {
834
862
  const e2 = (t2 == null ? void 0 : t2.mongoUri) || process.env.MONGODB_URI || "mongodb://localhost:27017/cvm";
835
- return new f(e2);
863
+ return new f$1(e2);
836
864
  }
837
865
  default:
838
866
  throw new Error(`Unsupported storage type: ${n2}`);
839
867
  }
840
868
  }
841
869
  }
842
- var H = Object.defineProperty;
843
- var D = (e2, t2, r2) => t2 in e2 ? H(e2, t2, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[t2] = r2;
844
- var _ = (e2, t2, r2) => D(e2, typeof t2 != "symbol" ? t2 + "" : t2, r2);
845
- function z(e2) {
870
+ var W = Object.defineProperty;
871
+ var B = (e2, t2, r2) => t2 in e2 ? W(e2, t2, { enumerable: true, configurable: true, writable: true, value: r2 }) : e2[t2] = r2;
872
+ var b = (e2, t2, r2) => B(e2, typeof t2 != "symbol" ? t2 + "" : t2, r2);
873
+ function Q(e2) {
846
874
  return !!(e2 && typeof e2 == "object" && "type" in e2 && "message" in e2);
847
875
  }
848
876
  function l(e2, t2) {
@@ -853,15 +881,15 @@ function l(e2, t2) {
853
881
  opcode: t2 || n.POP
854
882
  } : e2.stack.pop();
855
883
  }
856
- const d = z, B = {
884
+ const f2 = Q, Z = {
857
885
  [n.ADD]: {
858
886
  stackIn: 2,
859
887
  stackOut: 1,
860
888
  execute: (e2, t$1) => {
861
889
  const r2 = l(e2, t$1.op);
862
- if (d(r2)) return r2;
890
+ if (f2(r2)) return r2;
863
891
  const o2 = l(e2, t$1.op);
864
- if (d(o2)) return o2;
892
+ if (f2(o2)) return o2;
865
893
  if (t(o2) || t(r2))
866
894
  e2.stack.push(p$1(o2) + p$1(r2));
867
895
  else {
@@ -875,9 +903,9 @@ const d = z, B = {
875
903
  stackOut: 1,
876
904
  execute: (e2, t2) => {
877
905
  const r2 = l(e2, t2.op);
878
- if (d(r2)) return r2;
906
+ if (f2(r2)) return r2;
879
907
  const o2 = l(e2, t2.op);
880
- if (d(o2)) return o2;
908
+ if (f2(o2)) return o2;
881
909
  const s2 = m(o2), c2 = m(r2);
882
910
  e2.stack.push(s2 - c2);
883
911
  }
@@ -887,9 +915,9 @@ const d = z, B = {
887
915
  stackOut: 1,
888
916
  execute: (e2, t2) => {
889
917
  const r2 = l(e2, t2.op);
890
- if (d(r2)) return r2;
918
+ if (f2(r2)) return r2;
891
919
  const o2 = l(e2, t2.op);
892
- if (d(o2)) return o2;
920
+ if (f2(o2)) return o2;
893
921
  const s2 = m(o2), c2 = m(r2);
894
922
  e2.stack.push(s2 * c2);
895
923
  }
@@ -899,9 +927,9 @@ const d = z, B = {
899
927
  stackOut: 1,
900
928
  execute: (e2, t2) => {
901
929
  const r2 = l(e2, t2.op);
902
- if (d(r2)) return r2;
930
+ if (f2(r2)) return r2;
903
931
  const o2 = l(e2, t2.op);
904
- if (d(o2)) return o2;
932
+ if (f2(o2)) return o2;
905
933
  const s2 = m(o2), c2 = m(r2);
906
934
  if (c2 === 0)
907
935
  return {
@@ -918,9 +946,9 @@ const d = z, B = {
918
946
  stackOut: 1,
919
947
  execute: (e2, t2) => {
920
948
  const r2 = l(e2, t2.op);
921
- if (d(r2)) return r2;
949
+ if (f2(r2)) return r2;
922
950
  const o2 = l(e2, t2.op);
923
- if (d(o2)) return o2;
951
+ if (f2(o2)) return o2;
924
952
  const s2 = m(o2), c2 = m(r2);
925
953
  e2.stack.push(s2 % c2);
926
954
  }
@@ -930,7 +958,7 @@ const d = z, B = {
930
958
  stackOut: 1,
931
959
  execute: (e2, t2) => {
932
960
  const r2 = l(e2, t2.op);
933
- if (d(r2)) return r2;
961
+ if (f2(r2)) return r2;
934
962
  const o2 = m(r2);
935
963
  e2.stack.push(-o2);
936
964
  }
@@ -940,12 +968,12 @@ const d = z, B = {
940
968
  stackOut: 1,
941
969
  execute: (e2, t2) => {
942
970
  const r2 = l(e2, t2.op);
943
- if (d(r2)) return r2;
971
+ if (f2(r2)) return r2;
944
972
  const o2 = m(r2);
945
973
  e2.stack.push(o2);
946
974
  }
947
975
  }
948
- }, W = {
976
+ }, ee = {
949
977
  [n.PUSH]: {
950
978
  stackIn: 0,
951
979
  stackOut: 1,
@@ -991,7 +1019,7 @@ const d = z, B = {
991
1019
  e2.stack.push(o2), e2.stack.push(r2), e2.stack.push(o2), e2.stack.push(r2);
992
1020
  }
993
1021
  }
994
- }, X = {
1022
+ }, re = {
995
1023
  [n.PRINT]: {
996
1024
  stackIn: 1,
997
1025
  stackOut: 0,
@@ -1010,7 +1038,7 @@ const d = z, B = {
1010
1038
  e2.ccPrompt = p$1(r2), e2.status = "waiting_cc";
1011
1039
  }
1012
1040
  }
1013
- }, K = {
1041
+ }, te = {
1014
1042
  [n.HALT]: {
1015
1043
  stackIn: 0,
1016
1044
  stackOut: 0,
@@ -1125,7 +1153,7 @@ const d = z, B = {
1125
1153
  opcode: n.CALL
1126
1154
  })
1127
1155
  }
1128
- }, Q = {
1156
+ }, oe = {
1129
1157
  [n.LOAD]: {
1130
1158
  stackIn: 0,
1131
1159
  stackOut: 1,
@@ -1142,7 +1170,7 @@ const d = z, B = {
1142
1170
  e2.variables.set(t2.arg, r2);
1143
1171
  }
1144
1172
  }
1145
- }, Z = {
1173
+ }, se = {
1146
1174
  [n.ITER_START]: {
1147
1175
  stackIn: 1,
1148
1176
  stackOut: 0,
@@ -1155,7 +1183,7 @@ const d = z, B = {
1155
1183
  pc: e2.pc,
1156
1184
  opcode: t2.op
1157
1185
  };
1158
- let o$1;
1186
+ let o$12;
1159
1187
  if (u$1(r2)) {
1160
1188
  const s2 = e2.heap.get(r2.id);
1161
1189
  if (!s2 || s2.type !== "array")
@@ -1165,9 +1193,9 @@ const d = z, B = {
1165
1193
  pc: e2.pc,
1166
1194
  opcode: t2.op
1167
1195
  };
1168
- o$1 = s2.data;
1196
+ o$12 = s2.data;
1169
1197
  } else if (o(r2))
1170
- o$1 = r2;
1198
+ o$12 = r2;
1171
1199
  else
1172
1200
  return {
1173
1201
  type: "TypeError",
@@ -1183,9 +1211,9 @@ const d = z, B = {
1183
1211
  opcode: t2.op
1184
1212
  };
1185
1213
  e2.iterators.push({
1186
- array: o$1,
1214
+ array: o$12,
1187
1215
  index: 0,
1188
- length: o$1.elements.length
1216
+ length: o$12.elements.length
1189
1217
  });
1190
1218
  }
1191
1219
  },
@@ -1220,25 +1248,25 @@ const d = z, B = {
1220
1248
  }
1221
1249
  }
1222
1250
  };
1223
- function O(e2, t2, r2) {
1251
+ function T(e2, t2, r2) {
1224
1252
  const o2 = l(e2, t2.op);
1225
- if (d(o2)) return o2;
1253
+ if (f2(o2)) return o2;
1226
1254
  const s2 = l(e2, t2.op);
1227
- if (d(s2)) return s2;
1255
+ if (f2(s2)) return s2;
1228
1256
  const c2 = r2(s2, o2);
1229
1257
  e2.stack.push(c2);
1230
1258
  }
1231
- const ee = {
1259
+ const ce = {
1232
1260
  [n.EQ]: {
1233
1261
  stackIn: 2,
1234
1262
  stackOut: 1,
1235
- execute: (e2, t2) => O(e2, t2, (r2, o2) => {
1236
- if (f$1(r2) && c(o2) || c(r2) && f$1(o2))
1263
+ execute: (e2, t2) => T(e2, t2, (r2, o2) => {
1264
+ if (f$2(r2) && c(o2) || c(r2) && f$2(o2))
1237
1265
  return true;
1238
1266
  if (c(r2) && c(o2))
1239
1267
  return true;
1240
- if (u$1(r2) || b(r2))
1241
- return u$1(r2) && u$1(o2) || b(r2) && b(o2) ? r2.id === o2.id : false;
1268
+ if (u$1(r2) || b$1(r2))
1269
+ return u$1(r2) && u$1(o2) || b$1(r2) && b$1(o2) ? r2.id === o2.id : false;
1242
1270
  {
1243
1271
  const s2 = m(r2), c2 = m(o2);
1244
1272
  return !isNaN(s2) && !isNaN(c2) ? s2 === c2 : p$1(r2) === p$1(o2);
@@ -1248,13 +1276,13 @@ const ee = {
1248
1276
  [n.NEQ]: {
1249
1277
  stackIn: 2,
1250
1278
  stackOut: 1,
1251
- execute: (e2, t2) => O(e2, t2, (r2, o2) => {
1252
- if (f$1(r2) && c(o2) || c(r2) && f$1(o2))
1279
+ execute: (e2, t2) => T(e2, t2, (r2, o2) => {
1280
+ if (f$2(r2) && c(o2) || c(r2) && f$2(o2))
1253
1281
  return false;
1254
1282
  if (c(r2) && c(o2))
1255
1283
  return false;
1256
- if (u$1(r2) || b(r2))
1257
- return u$1(r2) && u$1(o2) || b(r2) && b(o2) ? r2.id !== o2.id : true;
1284
+ if (u$1(r2) || b$1(r2))
1285
+ return u$1(r2) && u$1(o2) || b$1(r2) && b$1(o2) ? r2.id !== o2.id : true;
1258
1286
  {
1259
1287
  const s2 = m(r2), c2 = m(o2);
1260
1288
  return !isNaN(s2) && !isNaN(c2) ? s2 !== c2 : p$1(r2) !== p$1(o2);
@@ -1264,7 +1292,7 @@ const ee = {
1264
1292
  [n.LT]: {
1265
1293
  stackIn: 2,
1266
1294
  stackOut: 1,
1267
- execute: (e2, t2) => O(e2, t2, (r2, o2) => {
1295
+ execute: (e2, t2) => T(e2, t2, (r2, o2) => {
1268
1296
  const s2 = m(r2), c2 = m(o2);
1269
1297
  return s2 < c2;
1270
1298
  })
@@ -1272,7 +1300,7 @@ const ee = {
1272
1300
  [n.GT]: {
1273
1301
  stackIn: 2,
1274
1302
  stackOut: 1,
1275
- execute: (e2, t2) => O(e2, t2, (r2, o2) => {
1303
+ execute: (e2, t2) => T(e2, t2, (r2, o2) => {
1276
1304
  const s2 = m(r2), c2 = m(o2);
1277
1305
  return s2 > c2;
1278
1306
  })
@@ -1280,7 +1308,7 @@ const ee = {
1280
1308
  [n.LTE]: {
1281
1309
  stackIn: 2,
1282
1310
  stackOut: 1,
1283
- execute: (e2, t2) => O(e2, t2, (r2, o2) => {
1311
+ execute: (e2, t2) => T(e2, t2, (r2, o2) => {
1284
1312
  const s2 = m(r2), c2 = m(o2);
1285
1313
  return s2 <= c2;
1286
1314
  })
@@ -1288,7 +1316,7 @@ const ee = {
1288
1316
  [n.GTE]: {
1289
1317
  stackIn: 2,
1290
1318
  stackOut: 1,
1291
- execute: (e2, t2) => O(e2, t2, (r2, o2) => {
1319
+ execute: (e2, t2) => T(e2, t2, (r2, o2) => {
1292
1320
  const s2 = m(r2), c2 = m(o2);
1293
1321
  return s2 >= c2;
1294
1322
  })
@@ -1296,22 +1324,22 @@ const ee = {
1296
1324
  [n.EQ_STRICT]: {
1297
1325
  stackIn: 2,
1298
1326
  stackOut: 1,
1299
- execute: (e2, t2) => O(e2, t2, (r2, o2) => u$1(r2) && u$1(o2) || b(r2) && b(o2) ? r2.id === o2.id : r2 === o2)
1327
+ execute: (e2, t2) => T(e2, t2, (r2, o2) => u$1(r2) && u$1(o2) || b$1(r2) && b$1(o2) ? r2.id === o2.id : r2 === o2)
1300
1328
  },
1301
1329
  [n.NEQ_STRICT]: {
1302
1330
  stackIn: 2,
1303
1331
  stackOut: 1,
1304
- execute: (e2, t2) => O(e2, t2, (r2, o2) => u$1(r2) && u$1(o2) || b(r2) && b(o2) ? r2.id !== o2.id : r2 !== o2)
1332
+ execute: (e2, t2) => T(e2, t2, (r2, o2) => u$1(r2) && u$1(o2) || b$1(r2) && b$1(o2) ? r2.id !== o2.id : r2 !== o2)
1305
1333
  }
1306
- }, re = {
1334
+ }, ne = {
1307
1335
  [n.AND]: {
1308
1336
  stackIn: 2,
1309
1337
  stackOut: 1,
1310
1338
  execute: (e2, t2) => {
1311
1339
  const r2 = l(e2, t2.op);
1312
- if (d(r2)) return r2;
1340
+ if (f2(r2)) return r2;
1313
1341
  const o2 = l(e2, t2.op);
1314
- if (d(o2)) return o2;
1342
+ if (f2(o2)) return o2;
1315
1343
  const s2 = j$1(o2) ? r2 : o2;
1316
1344
  e2.stack.push(s2);
1317
1345
  }
@@ -1321,9 +1349,9 @@ const ee = {
1321
1349
  stackOut: 1,
1322
1350
  execute: (e2, t2) => {
1323
1351
  const r2 = l(e2, t2.op);
1324
- if (d(r2)) return r2;
1352
+ if (f2(r2)) return r2;
1325
1353
  const o2 = l(e2, t2.op);
1326
- if (d(o2)) return o2;
1354
+ if (f2(o2)) return o2;
1327
1355
  const s2 = j$1(o2) ? o2 : r2;
1328
1356
  e2.stack.push(s2);
1329
1357
  }
@@ -1333,12 +1361,12 @@ const ee = {
1333
1361
  stackOut: 1,
1334
1362
  execute: (e2, t2) => {
1335
1363
  const r2 = l(e2, t2.op);
1336
- if (d(r2)) return r2;
1364
+ if (f2(r2)) return r2;
1337
1365
  const o2 = !j$1(r2);
1338
1366
  e2.stack.push(o2);
1339
1367
  }
1340
1368
  }
1341
- }, te = {
1369
+ }, pe = {
1342
1370
  /**
1343
1371
  * ARRAY_NEW: Creates a new empty array on the heap
1344
1372
  * Stack: [] -> [array-ref]
@@ -1359,10 +1387,10 @@ const ee = {
1359
1387
  stackIn: 2,
1360
1388
  stackOut: 1,
1361
1389
  execute: (e2, t2) => {
1362
- const r2 = e2.stack.pop(), o$1 = e2.stack.pop();
1390
+ const r2 = e2.stack.pop(), o$12 = e2.stack.pop();
1363
1391
  let s2;
1364
- if (u$1(o$1)) {
1365
- const c2 = e2.heap.get(o$1.id);
1392
+ if (u$1(o$12)) {
1393
+ const c2 = e2.heap.get(o$12.id);
1366
1394
  if (!c2 || c2.type !== "array")
1367
1395
  return {
1368
1396
  type: "RuntimeError",
@@ -1371,8 +1399,8 @@ const ee = {
1371
1399
  opcode: t2.op
1372
1400
  };
1373
1401
  s2 = c2.data;
1374
- } else if (o(o$1))
1375
- s2 = o$1;
1402
+ } else if (o(o$12))
1403
+ s2 = o$12;
1376
1404
  else
1377
1405
  return {
1378
1406
  type: "RuntimeError",
@@ -1380,49 +1408,49 @@ const ee = {
1380
1408
  pc: e2.pc,
1381
1409
  opcode: t2.op
1382
1410
  };
1383
- s2.elements.push(r2), e2.stack.push(o$1);
1411
+ s2.elements.push(r2), e2.stack.push(o$12);
1384
1412
  }
1385
1413
  },
1386
1414
  [n.ARRAY_GET]: {
1387
1415
  stackIn: 2,
1388
1416
  stackOut: 1,
1389
1417
  execute: (e2, t$1) => {
1390
- var u2;
1391
- const r2 = e2.stack.pop(), o$1 = e2.stack.pop();
1418
+ var a2;
1419
+ const r2 = e2.stack.pop(), o$12 = e2.stack.pop();
1392
1420
  let s2;
1393
- if (u$1(o$1)) {
1394
- const a2 = e2.heap.get(o$1.id);
1395
- if (!a2 || a2.type !== "array")
1421
+ if (u$1(o$12)) {
1422
+ const u2 = e2.heap.get(o$12.id);
1423
+ if (!u2 || u2.type !== "array")
1396
1424
  return {
1397
1425
  type: "RuntimeError",
1398
1426
  message: "Invalid array reference",
1399
1427
  pc: e2.pc,
1400
1428
  opcode: t$1.op
1401
1429
  };
1402
- s2 = a2.data;
1403
- } else if (b(o$1)) {
1404
- const a2 = e2.heap.get(o$1.id);
1405
- if (!a2 || a2.type !== "object")
1430
+ s2 = u2.data;
1431
+ } else if (b$1(o$12)) {
1432
+ const u2 = e2.heap.get(o$12.id);
1433
+ if (!u2 || u2.type !== "object")
1406
1434
  return {
1407
1435
  type: "RuntimeError",
1408
1436
  message: "Invalid object reference",
1409
1437
  pc: e2.pc,
1410
1438
  opcode: t$1.op
1411
1439
  };
1412
- const i2 = a2.data, E2 = p$1(r2), x2 = i2.properties[E2] ?? C();
1413
- e2.stack.push(x2);
1440
+ const i2 = u2.data, y2 = p$1(r2), E2 = i2.properties[y2] ?? C();
1441
+ e2.stack.push(E2);
1414
1442
  return;
1415
- } else if (o(o$1))
1416
- s2 = o$1;
1417
- else if (t(o$1)) {
1418
- let a2;
1443
+ } else if (o(o$12))
1444
+ s2 = o$12;
1445
+ else if (t(o$12)) {
1446
+ let u2;
1419
1447
  if (i$1(r2))
1420
- a2 = r2;
1448
+ u2 = r2;
1421
1449
  else if (t(r2)) {
1422
1450
  const i2 = parseInt(r2, 10);
1423
- !isNaN(i2) && i2.toString() === r2 && (a2 = i2);
1451
+ !isNaN(i2) && i2.toString() === r2 && (u2 = i2);
1424
1452
  }
1425
- a2 !== void 0 && a2 >= 0 && a2 < o$1.length ? e2.stack.push(o$1[a2]) : e2.stack.push(C());
1453
+ u2 !== void 0 && u2 >= 0 && u2 < o$12.length ? e2.stack.push(o$12[u2]) : e2.stack.push(C());
1426
1454
  return;
1427
1455
  } else
1428
1456
  return {
@@ -1435,11 +1463,11 @@ const ee = {
1435
1463
  if (i$1(r2))
1436
1464
  c2 = r2;
1437
1465
  else if (t(r2)) {
1438
- const a2 = parseInt(r2, 10);
1439
- if (!isNaN(a2) && a2.toString() === r2 && a2 >= 0)
1440
- c2 = a2;
1466
+ const u2 = parseInt(r2, 10);
1467
+ if (!isNaN(u2) && u2.toString() === r2 && u2 >= 0)
1468
+ c2 = u2;
1441
1469
  else {
1442
- const i2 = ((u2 = s2.properties) == null ? void 0 : u2[r2]) ?? C();
1470
+ const i2 = ((a2 = s2.properties) == null ? void 0 : a2[r2]) ?? C();
1443
1471
  e2.stack.push(i2);
1444
1472
  return;
1445
1473
  }
@@ -1450,37 +1478,37 @@ const ee = {
1450
1478
  pc: e2.pc,
1451
1479
  opcode: t$1.op
1452
1480
  };
1453
- const p3 = s2.elements[c2] ?? C();
1454
- e2.stack.push(p3);
1481
+ const p2 = s2.elements[c2] ?? C();
1482
+ e2.stack.push(p2);
1455
1483
  }
1456
1484
  },
1457
1485
  [n.ARRAY_SET]: {
1458
1486
  stackIn: 3,
1459
1487
  stackOut: 1,
1460
1488
  execute: (e2, t$1) => {
1461
- const r2 = e2.stack.pop(), o$1 = e2.stack.pop(), s2 = e2.stack.pop();
1489
+ const r2 = e2.stack.pop(), o$12 = e2.stack.pop(), s2 = e2.stack.pop();
1462
1490
  let c2;
1463
1491
  if (u$1(s2)) {
1464
- const a2 = e2.heap.get(s2.id);
1465
- if (!a2 || a2.type !== "array")
1492
+ const u2 = e2.heap.get(s2.id);
1493
+ if (!u2 || u2.type !== "array")
1466
1494
  return {
1467
1495
  type: "RuntimeError",
1468
1496
  message: "Invalid array reference",
1469
1497
  pc: e2.pc,
1470
1498
  opcode: t$1.op
1471
1499
  };
1472
- c2 = a2.data;
1473
- } else if (b(s2)) {
1474
- const a2 = e2.heap.get(s2.id);
1475
- if (!a2 || a2.type !== "object")
1500
+ c2 = u2.data;
1501
+ } else if (b$1(s2)) {
1502
+ const u2 = e2.heap.get(s2.id);
1503
+ if (!u2 || u2.type !== "object")
1476
1504
  return {
1477
1505
  type: "RuntimeError",
1478
1506
  message: "Invalid object reference",
1479
1507
  pc: e2.pc,
1480
1508
  opcode: t$1.op
1481
1509
  };
1482
- const i2 = a2.data, E2 = p$1(o$1);
1483
- i2.properties[E2] = r2, e2.stack.push(s2);
1510
+ const i2 = u2.data, y2 = p$1(o$12);
1511
+ i2.properties[y2] = r2, e2.stack.push(s2);
1484
1512
  return;
1485
1513
  } else if (o(s2))
1486
1514
  c2 = s2;
@@ -1491,15 +1519,15 @@ const ee = {
1491
1519
  pc: e2.pc,
1492
1520
  opcode: t$1.op
1493
1521
  };
1494
- let p3;
1495
- if (i$1(o$1))
1496
- p3 = o$1;
1497
- else if (t(o$1)) {
1498
- const a2 = parseInt(o$1, 10);
1499
- if (!isNaN(a2) && a2.toString() === o$1 && a2 >= 0)
1500
- p3 = a2;
1522
+ let p2;
1523
+ if (i$1(o$12))
1524
+ p2 = o$12;
1525
+ else if (t(o$12)) {
1526
+ const u2 = parseInt(o$12, 10);
1527
+ if (!isNaN(u2) && u2.toString() === o$12 && u2 >= 0)
1528
+ p2 = u2;
1501
1529
  else {
1502
- c2.properties || (c2.properties = {}), c2.properties[o$1] = r2, e2.stack.push(s2);
1530
+ c2.properties || (c2.properties = {}), c2.properties[o$12] = r2, e2.stack.push(s2);
1503
1531
  return;
1504
1532
  }
1505
1533
  } else
@@ -1509,15 +1537,15 @@ const ee = {
1509
1537
  pc: e2.pc,
1510
1538
  opcode: t$1.op
1511
1539
  };
1512
- const u2 = Math.floor(p3);
1513
- if (u2 < 0)
1540
+ const a2 = Math.floor(p2);
1541
+ if (a2 < 0)
1514
1542
  return {
1515
1543
  type: "RuntimeError",
1516
1544
  message: "ARRAY_SET: Negative index not allowed",
1517
1545
  pc: e2.pc,
1518
1546
  opcode: t$1.op
1519
1547
  };
1520
- c2.elements[u2] = r2, e2.stack.push(s2);
1548
+ c2.elements[a2] = r2, e2.stack.push(s2);
1521
1549
  }
1522
1550
  },
1523
1551
  [n.ARRAY_LEN]: {
@@ -1525,7 +1553,7 @@ const ee = {
1525
1553
  stackOut: 1,
1526
1554
  execute: (e2, t2) => {
1527
1555
  const r2 = e2.stack.pop();
1528
- let o$1;
1556
+ let o$12;
1529
1557
  if (u$1(r2)) {
1530
1558
  const s2 = e2.heap.get(r2.id);
1531
1559
  if (!s2 || s2.type !== "array")
@@ -1535,9 +1563,9 @@ const ee = {
1535
1563
  pc: e2.pc,
1536
1564
  opcode: t2.op
1537
1565
  };
1538
- o$1 = s2.data;
1566
+ o$12 = s2.data;
1539
1567
  } else if (o(r2))
1540
- o$1 = r2;
1568
+ o$12 = r2;
1541
1569
  else
1542
1570
  return {
1543
1571
  type: "RuntimeError",
@@ -1545,7 +1573,7 @@ const ee = {
1545
1573
  pc: e2.pc,
1546
1574
  opcode: t2.op
1547
1575
  };
1548
- e2.stack.push(o$1.elements.length);
1576
+ e2.stack.push(o$12.elements.length);
1549
1577
  }
1550
1578
  },
1551
1579
  [n.ARRAY_MAP_PROP]: {
@@ -1568,19 +1596,19 @@ const ee = {
1568
1596
  pc: e2.pc,
1569
1597
  opcode: t2.op
1570
1598
  };
1571
- const c2 = s$12.data, p3 = s();
1572
- for (const a2 of c2.elements)
1573
- if (b(a2)) {
1574
- const i2 = e2.heap.get(a2.id);
1599
+ const c2 = s$12.data, p2 = s();
1600
+ for (const u2 of c2.elements)
1601
+ if (b$1(u2)) {
1602
+ const i2 = e2.heap.get(u2.id);
1575
1603
  if (i2 && i2.type === "object") {
1576
- const E2 = i2.data, x2 = p$1(r2);
1577
- p3.elements.push(E2.properties[x2] || null);
1604
+ const y2 = i2.data, E2 = p$1(r2);
1605
+ p2.elements.push(y2.properties[E2] || null);
1578
1606
  } else
1579
- p3.elements.push(null);
1607
+ p2.elements.push(null);
1580
1608
  } else
1581
- p3.elements.push(null);
1582
- const u2 = e2.heap.allocate("array", p3);
1583
- e2.stack.push(u2);
1609
+ p2.elements.push(null);
1610
+ const a2 = e2.heap.allocate("array", p2);
1611
+ e2.stack.push(a2);
1584
1612
  }
1585
1613
  },
1586
1614
  [n.ARRAY_FILTER_PROP]: {
@@ -1603,17 +1631,90 @@ const ee = {
1603
1631
  pc: e2.pc,
1604
1632
  opcode: t2.op
1605
1633
  };
1606
- const c2 = s$12.data, p3 = s();
1607
- for (const a2 of c2.elements)
1608
- if (b(a2)) {
1609
- const i2 = e2.heap.get(a2.id);
1634
+ const c2 = s$12.data, p2 = s();
1635
+ for (const u2 of c2.elements)
1636
+ if (b$1(u2)) {
1637
+ const i2 = e2.heap.get(u2.id);
1610
1638
  if (i2 && i2.type === "object") {
1611
- const E2 = i2.data, x2 = p$1(r2);
1612
- x2 in E2.properties && E2.properties[x2] && p3.elements.push(a2);
1639
+ const y2 = i2.data, E2 = p$1(r2);
1640
+ E2 in y2.properties && y2.properties[E2] && p2.elements.push(u2);
1613
1641
  }
1614
1642
  }
1615
- const u2 = e2.heap.allocate("array", p3);
1616
- e2.stack.push(u2);
1643
+ const a2 = e2.heap.allocate("array", p2);
1644
+ e2.stack.push(a2);
1645
+ }
1646
+ },
1647
+ [n.ARRAY_SLICE]: {
1648
+ stackIn: 3,
1649
+ // array, start, end
1650
+ stackOut: 1,
1651
+ execute: (e2, t2) => {
1652
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop(), s$12 = e2.stack.pop();
1653
+ if (!((L2) => {
1654
+ if (!u$1(L2))
1655
+ return false;
1656
+ const U2 = e2.heap.get(L2.id);
1657
+ return U2 !== void 0 && U2.type === "array";
1658
+ })(s$12))
1659
+ return {
1660
+ type: "RuntimeError",
1661
+ message: "ARRAY_SLICE requires an array",
1662
+ pc: e2.pc,
1663
+ opcode: t2.op
1664
+ };
1665
+ const a2 = e2.heap.get(s$12.id).data, u2 = i$1(o2) ? o2 : 0, i2 = r2 === void 0 ? a2.elements.length : i$1(r2) ? r2 : a2.elements.length, y2 = u2 < 0 ? Math.max(0, a2.elements.length + u2) : u2, E2 = i2 < 0 ? Math.max(0, a2.elements.length + i2) : i2, Y2 = a2.elements.slice(y2, E2), J2 = s(Y2), z = e2.heap.allocate("array", J2);
1666
+ e2.stack.push(z);
1667
+ }
1668
+ },
1669
+ [n.ARRAY_JOIN]: {
1670
+ stackIn: 2,
1671
+ // array, separator
1672
+ stackOut: 1,
1673
+ // string
1674
+ execute: (e2, t$1) => {
1675
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
1676
+ if (!((y2) => {
1677
+ if (!u$1(y2))
1678
+ return false;
1679
+ const E2 = e2.heap.get(y2.id);
1680
+ return E2 !== void 0 && E2.type === "array";
1681
+ })(o2))
1682
+ return {
1683
+ type: "RuntimeError",
1684
+ message: "ARRAY_JOIN requires an array",
1685
+ pc: e2.pc,
1686
+ opcode: t$1.op
1687
+ };
1688
+ const p2 = e2.heap.get(o2.id).data, a2 = t(r2) ? r2 : String(r2), i2 = p2.elements.map((y2) => y2 === null ? "null" : y2 === void 0 || c(y2) ? "undefined" : String(y2)).join(a2);
1689
+ e2.stack.push(i2);
1690
+ }
1691
+ },
1692
+ [n.ARRAY_INDEX_OF]: {
1693
+ stackIn: 2,
1694
+ // array, searchElement
1695
+ stackOut: 1,
1696
+ // number (index or -1)
1697
+ execute: (e2, t2) => {
1698
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
1699
+ if (!((a2) => {
1700
+ if (!u$1(a2))
1701
+ return false;
1702
+ const u2 = e2.heap.get(a2.id);
1703
+ return u2 !== void 0 && u2.type === "array";
1704
+ })(o2))
1705
+ return {
1706
+ type: "RuntimeError",
1707
+ message: "ARRAY_INDEX_OF requires an array",
1708
+ pc: e2.pc,
1709
+ opcode: t2.op
1710
+ };
1711
+ const p2 = e2.heap.get(o2.id).data;
1712
+ for (let a2 = 0; a2 < p2.elements.length; a2++)
1713
+ if (p2.elements[a2] === r2) {
1714
+ e2.stack.push(a2);
1715
+ return;
1716
+ }
1717
+ e2.stack.push(-1);
1617
1718
  }
1618
1719
  }
1619
1720
  };
@@ -1637,15 +1738,15 @@ function M(e2, t2) {
1637
1738
  return null;
1638
1739
  }
1639
1740
  }
1640
- const oe = {
1741
+ const ae = {
1641
1742
  [n.CONCAT]: {
1642
1743
  stackIn: 2,
1643
1744
  stackOut: 1,
1644
1745
  execute: (e2, t2) => {
1645
1746
  const r2 = l(e2, t2.op);
1646
- if (d(r2)) return r2;
1747
+ if (f2(r2)) return r2;
1647
1748
  const o2 = l(e2, t2.op);
1648
- if (d(o2)) return o2;
1749
+ if (f2(o2)) return o2;
1649
1750
  e2.stack.push(p$1(o2) + p$1(r2));
1650
1751
  }
1651
1752
  },
@@ -1654,7 +1755,7 @@ const oe = {
1654
1755
  stackOut: 1,
1655
1756
  execute: (e2, t$1) => {
1656
1757
  const r2 = l(e2, t$1.op);
1657
- if (d(r2)) return r2;
1758
+ if (f2(r2)) return r2;
1658
1759
  if (!t(r2))
1659
1760
  return {
1660
1761
  type: "RuntimeError",
@@ -1670,7 +1771,7 @@ const oe = {
1670
1771
  stackOut: 1,
1671
1772
  execute: (e2, t$1) => {
1672
1773
  const r2 = l(e2, t$1.op);
1673
- if (d(r2)) return r2;
1774
+ if (f2(r2)) return r2;
1674
1775
  if (t(r2))
1675
1776
  e2.stack.push(r2.length);
1676
1777
  else if (o(r2))
@@ -1700,7 +1801,7 @@ const oe = {
1700
1801
  stackOut: 1,
1701
1802
  execute: (e2, t$1) => {
1702
1803
  const r2 = l(e2, t$1.op);
1703
- if (d(r2)) return r2;
1804
+ if (f2(r2)) return r2;
1704
1805
  if (!t(r2))
1705
1806
  return {
1706
1807
  type: "RuntimeError",
@@ -1721,11 +1822,11 @@ const oe = {
1721
1822
  stackOut: 1,
1722
1823
  execute: (e2, t2) => {
1723
1824
  const r2 = l(e2, t2.op);
1724
- if (d(r2)) return r2;
1725
- e2.stack.push(d$2(r2));
1825
+ if (f2(r2)) return r2;
1826
+ e2.stack.push(d$1(r2));
1726
1827
  }
1727
1828
  }
1728
- }, se = {
1829
+ }, ue = {
1729
1830
  [n.INC]: {
1730
1831
  stackIn: 1,
1731
1832
  stackOut: 1,
@@ -1762,7 +1863,7 @@ const oe = {
1762
1863
  e2.stack.push(c2 ? m(o2) : s2);
1763
1864
  }
1764
1865
  }
1765
- }, ce = {
1866
+ }, ie = {
1766
1867
  [n.RETURN]: {
1767
1868
  stackIn: 0,
1768
1869
  stackOut: 0,
@@ -1830,9 +1931,9 @@ const oe = {
1830
1931
  pc: e2.pc,
1831
1932
  opcode: t$1.op
1832
1933
  };
1833
- let r2, o$1 = {};
1934
+ let r2, o$12 = {};
1834
1935
  const s2 = e2.stack[e2.stack.length - 1];
1835
- if (e2.stack.length >= 2 && typeof s2 == "object" && s2 !== null && !o(s2) && (o$1 = e2.stack.pop()), r2 = e2.stack.pop(), !t(r2))
1936
+ if (e2.stack.length >= 2 && typeof s2 == "object" && s2 !== null && !o(s2) && (o$12 = e2.stack.pop()), r2 = e2.stack.pop(), !t(r2))
1836
1937
  return {
1837
1938
  type: "RuntimeError",
1838
1939
  message: "FS_LIST_FILES requires a string path",
@@ -1846,10 +1947,10 @@ const oe = {
1846
1947
  pc: e2.pc,
1847
1948
  opcode: t$1.op
1848
1949
  };
1849
- const c2 = e2.fileSystem.listFiles(r2, o$1);
1950
+ const c2 = e2.fileSystem.listFiles(r2, o$12);
1850
1951
  if (o(c2)) {
1851
- const p3 = e2.heap.allocate("array", c2);
1852
- e2.stack.push(p3);
1952
+ const p2 = e2.heap.allocate("array", c2);
1953
+ e2.stack.push(p2);
1853
1954
  } else
1854
1955
  e2.stack.push(c2);
1855
1956
  }
@@ -1926,8 +2027,8 @@ const oe = {
1926
2027
  };
1927
2028
  const r2 = e2.stack.length;
1928
2029
  let o2, s2, c2;
1929
- const p3 = e2.stack[r2 - 1], u2 = e2.stack[r2 - 2];
1930
- if (r2 >= 3 && typeof p3 == "number" && typeof u2 == "number" ? (c2 = e2.stack.pop(), s2 = e2.stack.pop(), o2 = e2.stack.pop()) : (s2 = e2.stack.pop(), o2 = e2.stack.pop(), c2 = void 0), !t(o2))
2030
+ const p2 = e2.stack[r2 - 1], a2 = e2.stack[r2 - 2];
2031
+ if (r2 >= 3 && typeof p2 == "number" && typeof a2 == "number" ? (c2 = e2.stack.pop(), s2 = e2.stack.pop(), o2 = e2.stack.pop()) : (s2 = e2.stack.pop(), o2 = e2.stack.pop(), c2 = void 0), !t(o2))
1931
2032
  return {
1932
2033
  type: "RuntimeError",
1933
2034
  message: "STRING_SUBSTRING requires a string",
@@ -1941,8 +2042,8 @@ const oe = {
1941
2042
  pc: e2.pc,
1942
2043
  opcode: t$1.op
1943
2044
  };
1944
- const a2 = o2.length;
1945
- s2 < 0 && (s2 = Math.max(0, a2 + s2)), c2 !== void 0 && c2 < 0 && (c2 = Math.max(0, a2 + c2));
2045
+ const u2 = o2.length;
2046
+ s2 < 0 && (s2 = Math.max(0, u2 + s2)), c2 !== void 0 && c2 < 0 && (c2 = Math.max(0, u2 + c2));
1946
2047
  const i2 = c2 !== void 0 ? o2.substring(s2, c2) : o2.substring(s2);
1947
2048
  e2.stack.push(i2);
1948
2049
  }
@@ -1976,8 +2077,8 @@ const oe = {
1976
2077
  };
1977
2078
  let s$12;
1978
2079
  r2 === "" ? s$12 = o2.split("") : s$12 = o2.split(r2);
1979
- const c2 = s(s$12), p3 = e2.heap.allocate("array", c2);
1980
- e2.stack.push(p3);
2080
+ const c2 = s(s$12), p2 = e2.heap.allocate("array", c2);
2081
+ e2.stack.push(p2);
1981
2082
  }
1982
2083
  },
1983
2084
  [n.STRING_SLICE]: {
@@ -1994,8 +2095,8 @@ const oe = {
1994
2095
  };
1995
2096
  const r2 = e2.stack.length;
1996
2097
  let o2, s2, c2;
1997
- const p3 = e2.stack.length >= 1 ? e2.stack[r2 - 1] : void 0, u2 = e2.stack.length >= 2 ? e2.stack[r2 - 2] : void 0;
1998
- if (r2 >= 3 && typeof p3 == "number" && typeof u2 == "number" ? (c2 = e2.stack.pop(), s2 = e2.stack.pop(), o2 = e2.stack.pop()) : (s2 = e2.stack.pop(), o2 = e2.stack.pop(), c2 = void 0), !t(o2))
2098
+ const p2 = e2.stack.length >= 1 ? e2.stack[r2 - 1] : void 0, a2 = e2.stack.length >= 2 ? e2.stack[r2 - 2] : void 0;
2099
+ if (r2 >= 3 && typeof p2 == "number" && typeof a2 == "number" ? (c2 = e2.stack.pop(), s2 = e2.stack.pop(), o2 = e2.stack.pop()) : (s2 = e2.stack.pop(), o2 = e2.stack.pop(), c2 = void 0), !t(o2))
1999
2100
  return {
2000
2101
  type: "RuntimeError",
2001
2102
  message: "STRING_SLICE requires a string",
@@ -2009,8 +2110,8 @@ const oe = {
2009
2110
  pc: e2.pc,
2010
2111
  opcode: t$1.op
2011
2112
  };
2012
- const a2 = c2 !== void 0 ? o2.slice(s2, c2) : o2.slice(s2);
2013
- e2.stack.push(a2);
2113
+ const u2 = c2 !== void 0 ? o2.slice(s2, c2) : o2.slice(s2);
2114
+ e2.stack.push(u2);
2014
2115
  }
2015
2116
  },
2016
2117
  [n.STRING_CHARAT]: {
@@ -2081,35 +2182,248 @@ const oe = {
2081
2182
  const o2 = p$1(r2);
2082
2183
  e2.stack.push(o2);
2083
2184
  }
2185
+ },
2186
+ [n.STRING_INCLUDES]: {
2187
+ stackIn: 2,
2188
+ // string, searchString
2189
+ stackOut: 1,
2190
+ // boolean
2191
+ execute: (e2, t$1) => {
2192
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2193
+ if (!t(o2))
2194
+ return {
2195
+ type: "RuntimeError",
2196
+ message: "STRING_INCLUDES requires a string",
2197
+ pc: e2.pc,
2198
+ opcode: t$1.op
2199
+ };
2200
+ const s2 = String(r2);
2201
+ e2.stack.push(o2.includes(s2));
2202
+ }
2203
+ },
2204
+ [n.STRING_ENDS_WITH]: {
2205
+ stackIn: 2,
2206
+ stackOut: 1,
2207
+ execute: (e2, t$1) => {
2208
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2209
+ if (!t(o2))
2210
+ return {
2211
+ type: "RuntimeError",
2212
+ message: "STRING_ENDS_WITH requires a string",
2213
+ pc: e2.pc,
2214
+ opcode: t$1.op
2215
+ };
2216
+ const s2 = String(r2);
2217
+ e2.stack.push(o2.endsWith(s2));
2218
+ }
2219
+ },
2220
+ [n.STRING_STARTS_WITH]: {
2221
+ stackIn: 2,
2222
+ stackOut: 1,
2223
+ execute: (e2, t$1) => {
2224
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2225
+ if (!t(o2))
2226
+ return {
2227
+ type: "RuntimeError",
2228
+ message: "STRING_STARTS_WITH requires a string",
2229
+ pc: e2.pc,
2230
+ opcode: t$1.op
2231
+ };
2232
+ const s2 = String(r2);
2233
+ e2.stack.push(o2.startsWith(s2));
2234
+ }
2235
+ },
2236
+ [n.STRING_TRIM]: {
2237
+ stackIn: 1,
2238
+ stackOut: 1,
2239
+ execute: (e2, t$1) => {
2240
+ const r2 = e2.stack.pop();
2241
+ if (!t(r2))
2242
+ return {
2243
+ type: "RuntimeError",
2244
+ message: "STRING_TRIM requires a string",
2245
+ pc: e2.pc,
2246
+ opcode: t$1.op
2247
+ };
2248
+ e2.stack.push(r2.trim());
2249
+ }
2250
+ },
2251
+ [n.STRING_TRIM_START]: {
2252
+ stackIn: 1,
2253
+ stackOut: 1,
2254
+ execute: (e2, t$1) => {
2255
+ const r2 = e2.stack.pop();
2256
+ if (!t(r2))
2257
+ return {
2258
+ type: "RuntimeError",
2259
+ message: "STRING_TRIM_START requires a string",
2260
+ pc: e2.pc,
2261
+ opcode: t$1.op
2262
+ };
2263
+ e2.stack.push(r2.trimStart());
2264
+ }
2265
+ },
2266
+ [n.STRING_TRIM_END]: {
2267
+ stackIn: 1,
2268
+ stackOut: 1,
2269
+ execute: (e2, t$1) => {
2270
+ const r2 = e2.stack.pop();
2271
+ if (!t(r2))
2272
+ return {
2273
+ type: "RuntimeError",
2274
+ message: "STRING_TRIM_END requires a string",
2275
+ pc: e2.pc,
2276
+ opcode: t$1.op
2277
+ };
2278
+ e2.stack.push(r2.trimEnd());
2279
+ }
2280
+ },
2281
+ [n.STRING_REPLACE]: {
2282
+ stackIn: 3,
2283
+ // string, search, replacement
2284
+ stackOut: 1,
2285
+ execute: (e2, t$1) => {
2286
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop(), s2 = e2.stack.pop();
2287
+ if (!t(s2))
2288
+ return {
2289
+ type: "RuntimeError",
2290
+ message: "STRING_REPLACE requires a string",
2291
+ pc: e2.pc,
2292
+ opcode: t$1.op
2293
+ };
2294
+ const c2 = String(o2), p2 = String(r2), a2 = s2.indexOf(c2), u2 = a2 === -1 ? s2 : s2.substring(0, a2) + p2 + s2.substring(a2 + c2.length);
2295
+ e2.stack.push(u2);
2296
+ }
2297
+ },
2298
+ [n.STRING_REPLACE_ALL]: {
2299
+ stackIn: 3,
2300
+ stackOut: 1,
2301
+ execute: (e2, t$1) => {
2302
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop(), s2 = e2.stack.pop();
2303
+ if (!t(s2))
2304
+ return {
2305
+ type: "RuntimeError",
2306
+ message: "STRING_REPLACE_ALL requires a string",
2307
+ pc: e2.pc,
2308
+ opcode: t$1.op
2309
+ };
2310
+ const c2 = String(o2), p2 = String(r2), a2 = s2.split(c2).join(p2);
2311
+ e2.stack.push(a2);
2312
+ }
2313
+ },
2314
+ [n.STRING_LAST_INDEX_OF]: {
2315
+ stackIn: 2,
2316
+ stackOut: 1,
2317
+ execute: (e2, t$1) => {
2318
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2319
+ if (!t(o2))
2320
+ return {
2321
+ type: "RuntimeError",
2322
+ message: "STRING_LAST_INDEX_OF requires a string",
2323
+ pc: e2.pc,
2324
+ opcode: t$1.op
2325
+ };
2326
+ const s2 = String(r2);
2327
+ e2.stack.push(o2.lastIndexOf(s2));
2328
+ }
2329
+ },
2330
+ [n.STRING_REPEAT]: {
2331
+ stackIn: 2,
2332
+ stackOut: 1,
2333
+ execute: (e2, t$1) => {
2334
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop();
2335
+ if (!t(o2))
2336
+ return {
2337
+ type: "RuntimeError",
2338
+ message: "STRING_REPEAT requires a string",
2339
+ pc: e2.pc,
2340
+ opcode: t$1.op
2341
+ };
2342
+ if (!i$1(r2) || r2 < 0)
2343
+ return {
2344
+ type: "RuntimeError",
2345
+ message: "STRING_REPEAT requires non-negative number",
2346
+ pc: e2.pc,
2347
+ opcode: t$1.op
2348
+ };
2349
+ e2.stack.push(o2.repeat(Math.floor(r2)));
2350
+ }
2351
+ },
2352
+ [n.STRING_PAD_START]: {
2353
+ stackIn: 3,
2354
+ // string, targetLength, padString
2355
+ stackOut: 1,
2356
+ execute: (e2, t$1) => {
2357
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop(), s2 = e2.stack.pop();
2358
+ if (!t(s2))
2359
+ return {
2360
+ type: "RuntimeError",
2361
+ message: "STRING_PAD_START requires a string",
2362
+ pc: e2.pc,
2363
+ opcode: t$1.op
2364
+ };
2365
+ if (!i$1(o2))
2366
+ return {
2367
+ type: "RuntimeError",
2368
+ message: "STRING_PAD_START requires number for length",
2369
+ pc: e2.pc,
2370
+ opcode: t$1.op
2371
+ };
2372
+ const c2 = t(r2) ? r2 : String(r2);
2373
+ e2.stack.push(s2.padStart(o2, c2 || " "));
2374
+ }
2375
+ },
2376
+ [n.STRING_PAD_END]: {
2377
+ stackIn: 3,
2378
+ stackOut: 1,
2379
+ execute: (e2, t$1) => {
2380
+ const r2 = e2.stack.pop(), o2 = e2.stack.pop(), s2 = e2.stack.pop();
2381
+ if (!t(s2))
2382
+ return {
2383
+ type: "RuntimeError",
2384
+ message: "STRING_PAD_END requires a string",
2385
+ pc: e2.pc,
2386
+ opcode: t$1.op
2387
+ };
2388
+ if (!i$1(o2))
2389
+ return {
2390
+ type: "RuntimeError",
2391
+ message: "STRING_PAD_END requires number for length",
2392
+ pc: e2.pc,
2393
+ opcode: t$1.op
2394
+ };
2395
+ const c2 = t(r2) ? r2 : String(r2);
2396
+ e2.stack.push(s2.padEnd(o2, c2 || " "));
2397
+ }
2084
2398
  }
2085
2399
  };
2086
- function j(e2, t2) {
2400
+ function P(e2, t2) {
2087
2401
  if (u$1(e2)) {
2088
2402
  const r2 = t2.get(e2.id);
2089
- return r2 && r2.type === "array" ? r2.data.elements.map((s2) => j(s2, t2)) : null;
2403
+ return r2 && r2.type === "array" ? r2.data.elements.map((s2) => P(s2, t2)) : null;
2090
2404
  }
2091
- if (b(e2)) {
2405
+ if (b$1(e2)) {
2092
2406
  const r2 = t2.get(e2.id);
2093
2407
  if (r2 && r2.type === "object") {
2094
2408
  const o2 = r2.data, s2 = {};
2095
- for (const [c2, p3] of Object.entries(o2.properties))
2096
- s2[c2] = j(p3, t2);
2409
+ for (const [c2, p2] of Object.entries(o2.properties))
2410
+ s2[c2] = P(p2, t2);
2097
2411
  return s2;
2098
2412
  }
2099
2413
  return null;
2100
2414
  }
2101
2415
  if (o(e2))
2102
- return e2.elements.map((r2) => j(r2, t2));
2416
+ return e2.elements.map((r2) => P(r2, t2));
2103
2417
  if (y(e2)) {
2104
2418
  const r2 = {};
2105
2419
  for (const [o2, s2] of Object.entries(e2.properties))
2106
- r2[o2] = j(s2, t2);
2420
+ r2[o2] = P(s2, t2);
2107
2421
  return r2;
2108
2422
  }
2109
2423
  if (!c(e2))
2110
2424
  return e2;
2111
2425
  }
2112
- const ne = {
2426
+ const de = {
2113
2427
  [n.OBJECT_CREATE]: {
2114
2428
  stackIn: 0,
2115
2429
  stackOut: 1,
@@ -2123,33 +2437,33 @@ const ne = {
2123
2437
  stackOut: 1,
2124
2438
  execute: (e2, t2) => {
2125
2439
  const r2 = l(e2, t2.op);
2126
- if (d(r2)) return r2;
2440
+ if (f2(r2)) return r2;
2127
2441
  const o2 = l(e2, t2.op);
2128
- if (d(o2)) return o2;
2442
+ if (f2(o2)) return o2;
2129
2443
  const s2 = l(e2, t2.op);
2130
- if (d(s2)) return s2;
2444
+ if (f2(s2)) return s2;
2131
2445
  let c2;
2132
- if (b(s2)) {
2133
- const u2 = e2.heap.get(s2.id);
2134
- if (!u2 || u2.type !== "object")
2446
+ if (b$1(s2)) {
2447
+ const a2 = e2.heap.get(s2.id);
2448
+ if (!a2 || a2.type !== "object")
2135
2449
  return {
2136
2450
  type: "RuntimeError",
2137
2451
  message: "Invalid object reference",
2138
2452
  pc: e2.pc,
2139
2453
  opcode: t2.op
2140
2454
  };
2141
- c2 = u2.data;
2455
+ c2 = a2.data;
2142
2456
  } else if (y(s2))
2143
2457
  c2 = s2;
2144
2458
  else
2145
2459
  return {
2146
2460
  type: "RuntimeError",
2147
- message: `Cannot set property '${o2}' on ${d$2(s2)}`,
2461
+ message: `Cannot set property '${o2}' on ${d$1(s2)}`,
2148
2462
  pc: e2.pc,
2149
2463
  opcode: t2.op
2150
2464
  };
2151
- const p3 = p$1(o2);
2152
- c2.properties[p3] = r2, e2.stack.push(s2);
2465
+ const p2 = p$1(o2);
2466
+ c2.properties[p2] = r2, e2.stack.push(s2);
2153
2467
  }
2154
2468
  },
2155
2469
  [n.PROPERTY_GET]: {
@@ -2157,27 +2471,27 @@ const ne = {
2157
2471
  stackOut: 1,
2158
2472
  execute: (e2, t2) => {
2159
2473
  const r2 = l(e2, t2.op);
2160
- if (d(r2)) return r2;
2474
+ if (f2(r2)) return r2;
2161
2475
  const o2 = l(e2, t2.op);
2162
- if (d(o2)) return o2;
2163
- if (f$1(o2) || c(o2))
2476
+ if (f2(o2)) return o2;
2477
+ if (f$2(o2) || c(o2))
2164
2478
  return {
2165
2479
  type: "RuntimeError",
2166
- message: `Cannot read property '${r2}' of ${d$2(o2)}`,
2480
+ message: `Cannot read property '${r2}' of ${d$1(o2)}`,
2167
2481
  pc: e2.pc,
2168
2482
  opcode: t2.op
2169
2483
  };
2170
2484
  let s2 = null;
2171
- if (b(o2)) {
2172
- const p3 = e2.heap.get(o2.id);
2173
- if (!p3 || p3.type !== "object")
2485
+ if (b$1(o2)) {
2486
+ const p2 = e2.heap.get(o2.id);
2487
+ if (!p2 || p2.type !== "object")
2174
2488
  return {
2175
2489
  type: "RuntimeError",
2176
2490
  message: "Invalid object reference",
2177
2491
  pc: e2.pc,
2178
2492
  opcode: t2.op
2179
2493
  };
2180
- s2 = p3.data;
2494
+ s2 = p2.data;
2181
2495
  } else if (y(o2))
2182
2496
  s2 = o2;
2183
2497
  else {
@@ -2193,12 +2507,12 @@ const ne = {
2193
2507
  stackOut: 1,
2194
2508
  execute: (e2, t2) => {
2195
2509
  const r2 = l(e2, t2.op);
2196
- if (d(r2)) return r2;
2197
- const o2 = j(r2, e2.heap);
2510
+ if (f2(r2)) return r2;
2511
+ const o2 = P(r2, e2.heap);
2198
2512
  e2.stack.push(JSON.stringify(o2));
2199
2513
  }
2200
2514
  }
2201
- }, pe = {
2515
+ }, le = {
2202
2516
  [n.GET]: {
2203
2517
  stackIn: 2,
2204
2518
  stackOut: 1,
@@ -2214,17 +2528,17 @@ const ne = {
2214
2528
  pc: e2.pc,
2215
2529
  opcode: t$1.op
2216
2530
  };
2217
- const p3 = c2.data;
2218
- let u2;
2531
+ const p2 = c2.data;
2532
+ let a2;
2219
2533
  if (i$1(r2))
2220
- u2 = r2;
2534
+ a2 = r2;
2221
2535
  else if (t(r2)) {
2222
2536
  const i2 = parseInt(r2, 10);
2223
2537
  if (!isNaN(i2) && i2.toString() === r2 && i2 >= 0)
2224
- u2 = i2;
2538
+ a2 = i2;
2225
2539
  else {
2226
- const E2 = ((s2 = p3.properties) == null ? void 0 : s2[r2]) ?? C();
2227
- e2.stack.push(E2);
2540
+ const y2 = ((s2 = p2.properties) == null ? void 0 : s2[r2]) ?? C();
2541
+ e2.stack.push(y2);
2228
2542
  return;
2229
2543
  }
2230
2544
  } else
@@ -2234,10 +2548,10 @@ const ne = {
2234
2548
  pc: e2.pc,
2235
2549
  opcode: t$1.op
2236
2550
  };
2237
- const a2 = p3.elements[u2] ?? C();
2238
- e2.stack.push(a2);
2551
+ const u2 = p2.elements[a2] ?? C();
2552
+ e2.stack.push(u2);
2239
2553
  return;
2240
- } else if (b(o2)) {
2554
+ } else if (b$1(o2)) {
2241
2555
  const c2 = e2.heap.get(o2.id);
2242
2556
  if (!c2 || c2.type !== "object")
2243
2557
  return {
@@ -2246,16 +2560,16 @@ const ne = {
2246
2560
  pc: e2.pc,
2247
2561
  opcode: t$1.op
2248
2562
  };
2249
- const p3 = c2.data, u2 = p$1(r2), a2 = p3.properties[u2] ?? C();
2250
- e2.stack.push(a2);
2563
+ const p2 = c2.data, a2 = p$1(r2), u2 = p2.properties[a2] ?? C();
2564
+ e2.stack.push(u2);
2251
2565
  return;
2252
2566
  } else if (t(o2)) {
2253
2567
  let c2;
2254
2568
  if (i$1(r2))
2255
2569
  c2 = r2;
2256
2570
  else if (t(r2)) {
2257
- const p3 = parseInt(r2, 10);
2258
- !isNaN(p3) && p3.toString() === r2 && (c2 = p3);
2571
+ const p2 = parseInt(r2, 10);
2572
+ !isNaN(p2) && p2.toString() === r2 && (c2 = p2);
2259
2573
  }
2260
2574
  c2 !== void 0 && c2 >= 0 && c2 < o2.length ? e2.stack.push(o2[c2]) : e2.stack.push(C());
2261
2575
  return;
@@ -2282,16 +2596,16 @@ const ne = {
2282
2596
  pc: e2.pc,
2283
2597
  opcode: t$1.op
2284
2598
  };
2285
- const p3 = c2.data;
2286
- let u2;
2599
+ const p2 = c2.data;
2600
+ let a2;
2287
2601
  if (i$1(o2))
2288
- u2 = o2;
2602
+ a2 = o2;
2289
2603
  else if (t(o2)) {
2290
2604
  const i2 = parseInt(o2, 10);
2291
2605
  if (!isNaN(i2) && i2.toString() === o2 && i2 >= 0)
2292
- u2 = i2;
2606
+ a2 = i2;
2293
2607
  else {
2294
- p3.properties || (p3.properties = {}), p3.properties[o2] = r2, e2.stack.push(s2);
2608
+ p2.properties || (p2.properties = {}), p2.properties[o2] = r2, e2.stack.push(s2);
2295
2609
  return;
2296
2610
  }
2297
2611
  } else
@@ -2301,17 +2615,17 @@ const ne = {
2301
2615
  pc: e2.pc,
2302
2616
  opcode: t$1.op
2303
2617
  };
2304
- const a2 = Math.floor(u2);
2305
- if (a2 < 0)
2618
+ const u2 = Math.floor(a2);
2619
+ if (u2 < 0)
2306
2620
  return {
2307
2621
  type: "RuntimeError",
2308
2622
  message: "SET: Negative index not allowed",
2309
2623
  pc: e2.pc,
2310
2624
  opcode: t$1.op
2311
2625
  };
2312
- p3.elements[a2] = r2, e2.stack.push(s2);
2626
+ p2.elements[u2] = r2, e2.stack.push(s2);
2313
2627
  return;
2314
- } else if (b(s2)) {
2628
+ } else if (b$1(s2)) {
2315
2629
  const c2 = e2.heap.get(s2.id);
2316
2630
  if (!c2 || c2.type !== "object")
2317
2631
  return {
@@ -2320,8 +2634,8 @@ const ne = {
2320
2634
  pc: e2.pc,
2321
2635
  opcode: t$1.op
2322
2636
  };
2323
- const p3 = c2.data, u2 = p$1(o2);
2324
- p3.properties[u2] = r2, e2.stack.push(s2);
2637
+ const p2 = c2.data, a2 = p$1(o2);
2638
+ p2.properties[a2] = r2, e2.stack.push(s2);
2325
2639
  return;
2326
2640
  } else
2327
2641
  return {
@@ -2333,11 +2647,6 @@ const ne = {
2333
2647
  }
2334
2648
  }
2335
2649
  }, F = {
2336
- ...B,
2337
- ...W,
2338
- ...X,
2339
- ...K,
2340
- ...Q,
2341
2650
  ...Z,
2342
2651
  ...ee,
2343
2652
  ...re,
@@ -2346,9 +2655,14 @@ const ne = {
2346
2655
  ...se,
2347
2656
  ...ce,
2348
2657
  ...ne,
2349
- ...pe
2658
+ ...pe,
2659
+ ...ae,
2660
+ ...ue,
2661
+ ...ie,
2662
+ ...de,
2663
+ ...le
2350
2664
  };
2351
- function P() {
2665
+ function j() {
2352
2666
  const e2 = /* @__PURE__ */ new Map();
2353
2667
  let t2 = 1;
2354
2668
  return {
@@ -2365,7 +2679,7 @@ function P() {
2365
2679
  }
2366
2680
  };
2367
2681
  }
2368
- class A {
2682
+ class w {
2369
2683
  createInitialState() {
2370
2684
  return {
2371
2685
  pc: 0,
@@ -2374,7 +2688,7 @@ class A {
2374
2688
  status: "running",
2375
2689
  output: [],
2376
2690
  iterators: [],
2377
- heap: P()
2691
+ heap: j()
2378
2692
  };
2379
2693
  }
2380
2694
  executeInstruction(t2, r2) {
@@ -2406,15 +2720,15 @@ class A {
2406
2720
  output: (r2 == null ? void 0 : r2.output) ?? [],
2407
2721
  iterators: (r2 == null ? void 0 : r2.iterators) ?? [],
2408
2722
  fileSystem: o2,
2409
- heap: (r2 == null ? void 0 : r2.heap) ?? P(),
2723
+ heap: (r2 == null ? void 0 : r2.heap) ?? j(),
2410
2724
  ...r2
2411
2725
  };
2412
2726
  for (; s2.status === "running" && s2.pc < t2.length; ) {
2413
- const c2 = t2[s2.pc], p3 = F[c2.op];
2414
- if (p3) {
2415
- const u2 = this.validateStack(p3, c2, s2);
2416
- if (u2) {
2417
- s2.status = "error", s2.error = u2.message;
2727
+ const c2 = t2[s2.pc], p2 = F[c2.op];
2728
+ if (p2) {
2729
+ const a2 = this.validateStack(p2, c2, s2);
2730
+ if (a2) {
2731
+ s2.status = "error", s2.error = a2.message;
2418
2732
  break;
2419
2733
  }
2420
2734
  if ((c2.op === n.JUMP || c2.op === n.JUMP_IF_FALSE || c2.op === n.JUMP_IF || c2.op === n.JUMP_IF_TRUE || c2.op === n.BREAK || c2.op === n.CONTINUE) && c2.arg !== void 0 && c2.arg >= t2.length) {
@@ -2423,17 +2737,17 @@ class A {
2423
2737
  s2.error = `Invalid ${i2} target: ${c2.arg}`;
2424
2738
  break;
2425
2739
  }
2426
- const a2 = p3.execute(s2, c2);
2427
- if (a2) {
2740
+ const u2 = p2.execute(s2, c2);
2741
+ if (u2) {
2428
2742
  const i2 = s2.pc + 1;
2429
2743
  if (i2 < t2.length && t2[i2].op === n.CC) {
2430
- s2.ccPrompt = `ERROR: ${a2.message}. How should I proceed?`, s2.status = "waiting_cc", s2.pc = i2;
2744
+ s2.ccPrompt = `ERROR: ${u2.message}. How should I proceed?`, s2.status = "waiting_cc", s2.pc = i2;
2431
2745
  break;
2432
2746
  }
2433
- s2.status = "error", s2.error = a2.message;
2747
+ s2.status = "error", s2.error = u2.message;
2434
2748
  break;
2435
2749
  }
2436
- p3.controlsPC || s2.pc++;
2750
+ p2.controlsPC || s2.pc++;
2437
2751
  continue;
2438
2752
  }
2439
2753
  s2.status = "error", s2.error = `Unknown opcode: ${n[c2.op]}`;
@@ -2454,9 +2768,9 @@ class A {
2454
2768
  return this.execute(o2, c2, s2 || t2.fileSystem);
2455
2769
  }
2456
2770
  }
2457
- class G {
2771
+ class D {
2458
2772
  constructor() {
2459
- _(this, "sandboxPaths", []);
2773
+ b(this, "sandboxPaths", []);
2460
2774
  const t2 = process.env.CVM_SANDBOX_PATHS, r2 = process.env.CVM_SANDBOX_ROOT;
2461
2775
  t2 ? this.sandboxPaths = t2.split(",").map((o2) => r__namespace.resolve(o2.trim())) : r2 && (this.sandboxPaths = [r__namespace.resolve(r2)]);
2462
2776
  }
@@ -2488,10 +2802,10 @@ class G {
2488
2802
  }
2489
2803
  listFilesRecursive(t2, r2, o2, s2, c2 = 0) {
2490
2804
  try {
2491
- const p3 = b__namespace.readdirSync(r2, { withFileTypes: true });
2492
- for (const u2 of p3) {
2493
- const a2 = r__namespace.join(r2, u2.name), i2 = r__namespace.relative(t2, a2);
2494
- u2.isSymbolicLink() || s2.filter && !this.matchesPattern(i2, s2.filter) || (o2.push(a2), u2.isDirectory() && s2.recursive && this.listFilesRecursive(t2, a2, o2, s2, c2 + 1));
2805
+ const p2 = x__namespace.readdirSync(r2, { withFileTypes: true });
2806
+ for (const a2 of p2) {
2807
+ const u2 = r__namespace.join(r2, a2.name), i2 = r__namespace.relative(t2, u2);
2808
+ a2.isSymbolicLink() || s2.filter && !this.matchesPattern(i2, s2.filter) || (o2.push(u2), a2.isDirectory() && s2.recursive && this.listFilesRecursive(t2, u2, o2, s2, c2 + 1));
2495
2809
  }
2496
2810
  } catch {
2497
2811
  }
@@ -2500,8 +2814,8 @@ class G {
2500
2814
  if (!this.isPathAllowed(t2))
2501
2815
  return null;
2502
2816
  try {
2503
- const r2 = r__namespace.resolve(t2), o2 = b__namespace.lstatSync(r2);
2504
- return o2.isSymbolicLink() || !o2.isFile() ? null : b__namespace.readFileSync(r2, "utf-8");
2817
+ const r2 = r__namespace.resolve(t2), o2 = x__namespace.lstatSync(r2);
2818
+ return o2.isSymbolicLink() || !o2.isFile() ? null : x__namespace.readFileSync(r2, "utf-8");
2505
2819
  } catch {
2506
2820
  return null;
2507
2821
  }
@@ -2514,25 +2828,25 @@ class G {
2514
2828
  if (!this.isPathAllowed(s2))
2515
2829
  return false;
2516
2830
  try {
2517
- if (b__namespace.lstatSync(o2).isSymbolicLink())
2831
+ if (x__namespace.lstatSync(o2).isSymbolicLink())
2518
2832
  return false;
2519
2833
  } catch (c2) {
2520
2834
  if (c2.code !== "ENOENT")
2521
2835
  return false;
2522
2836
  }
2523
- return b__namespace.mkdirSync(s2, { recursive: true }), b__namespace.writeFileSync(o2, r2, "utf-8"), true;
2837
+ return x__namespace.mkdirSync(s2, { recursive: true }), x__namespace.writeFileSync(o2, r2, "utf-8"), true;
2524
2838
  } catch {
2525
2839
  return false;
2526
2840
  }
2527
2841
  }
2528
2842
  }
2529
- new G();
2530
- class fe {
2843
+ new D();
2844
+ class he {
2531
2845
  constructor(t2, r2) {
2532
- _(this, "vms", /* @__PURE__ */ new Map());
2533
- _(this, "storage");
2534
- _(this, "fileSystem");
2535
- t2 ? this.storage = t2 : this.storage = E.create(), this.fileSystem = r2 || new G();
2846
+ b(this, "vms", /* @__PURE__ */ new Map());
2847
+ b(this, "storage");
2848
+ b(this, "fileSystem");
2849
+ t2 ? this.storage = t2 : this.storage = E.create(), this.fileSystem = r2 || new D();
2536
2850
  }
2537
2851
  /**
2538
2852
  * Initialize the VMManager (connect to database)
@@ -2550,7 +2864,7 @@ class fe {
2550
2864
  * Load and compile a program from source code
2551
2865
  */
2552
2866
  async loadProgram(t2, r2) {
2553
- const o2 = j$2(r2);
2867
+ const o2 = X(r2);
2554
2868
  if (!o2.success)
2555
2869
  throw new Error(`Compilation failed: ${o2.errors.join(", ")}`);
2556
2870
  const s2 = {
@@ -2579,7 +2893,7 @@ class fe {
2579
2893
  created: /* @__PURE__ */ new Date()
2580
2894
  };
2581
2895
  await this.storage.saveExecution(s2);
2582
- const c2 = new A();
2896
+ const c2 = new w();
2583
2897
  this.vms.set(r2, c2);
2584
2898
  }
2585
2899
  /**
@@ -2595,30 +2909,30 @@ class fe {
2595
2909
  if (!o2)
2596
2910
  throw new Error(`Program not found: ${r2.programId}`);
2597
2911
  let s2 = this.vms.get(t2);
2598
- s2 || (s2 = new A(), this.vms.set(t2, s2));
2912
+ s2 || (s2 = new w(), this.vms.set(t2, s2));
2599
2913
  const c2 = r2.state === "READY" ? {
2600
2914
  pc: 0,
2601
2915
  stack: [],
2602
2916
  variables: /* @__PURE__ */ new Map(),
2603
2917
  output: []
2604
- } : this.deserializeVMState(r2), p3 = s2.execute(o2.bytecode, c2, this.fileSystem);
2605
- p3.output.length > 0 && await this.storage.appendOutput(t2, p3.output);
2606
- const u2 = this.serializeVMState(p3);
2607
- if (Object.assign(r2, u2), p3.status === "complete")
2608
- return r2.state = "COMPLETED", p3.returnValue !== void 0 && (r2.returnValue = p3.returnValue), await this.storage.saveExecution(r2), this.vms.delete(t2), {
2918
+ } : this.deserializeVMState(r2), p2 = s2.execute(o2.bytecode, c2, this.fileSystem);
2919
+ p2.output.length > 0 && await this.storage.appendOutput(t2, p2.output);
2920
+ const a2 = this.serializeVMState(p2);
2921
+ if (Object.assign(r2, a2), p2.status === "complete")
2922
+ return r2.state = "COMPLETED", p2.returnValue !== void 0 && (r2.returnValue = p2.returnValue), await this.storage.saveExecution(r2), this.vms.delete(t2), {
2609
2923
  type: "completed",
2610
2924
  message: "Execution completed",
2611
- result: p3.returnValue
2925
+ result: p2.returnValue
2612
2926
  };
2613
- if (p3.status === "waiting_cc")
2614
- return r2.state = "AWAITING_COGNITIVE_RESULT", r2.ccPrompt = p3.ccPrompt, await this.storage.saveExecution(r2), {
2927
+ if (p2.status === "waiting_cc")
2928
+ return r2.state = "AWAITING_COGNITIVE_RESULT", r2.ccPrompt = p2.ccPrompt, await this.storage.saveExecution(r2), {
2615
2929
  type: "waiting",
2616
- message: p3.ccPrompt || "Waiting for input"
2930
+ message: p2.ccPrompt || "Waiting for input"
2617
2931
  };
2618
- if (p3.status === "error")
2619
- return r2.state = "ERROR", r2.error = p3.error, await this.storage.saveExecution(r2), this.vms.delete(t2), {
2932
+ if (p2.status === "error")
2933
+ return r2.state = "ERROR", r2.error = p2.error, await this.storage.saveExecution(r2), this.vms.delete(t2), {
2620
2934
  type: "error",
2621
- error: p3.error
2935
+ error: p2.error
2622
2936
  };
2623
2937
  }
2624
2938
  if (r2.state === "COMPLETED")
@@ -2649,17 +2963,17 @@ class fe {
2649
2963
  if (!s2)
2650
2964
  throw new Error(`Program not found: ${o2.programId}`);
2651
2965
  let c2 = this.vms.get(t2);
2652
- c2 || (c2 = new A(), this.vms.set(t2, c2));
2653
- const p3 = {
2966
+ c2 || (c2 = new w(), this.vms.set(t2, c2));
2967
+ const p2 = {
2654
2968
  ...this.deserializeVMState(o2),
2655
2969
  status: "waiting_cc",
2656
2970
  output: [],
2657
2971
  // Start with empty output for resumed execution
2658
2972
  ccPrompt: void 0
2659
- }, u2 = c2.resume(p3, r2, s2.bytecode, this.fileSystem);
2660
- u2.output.length > 0 && await this.storage.appendOutput(t2, u2.output);
2661
- const a2 = this.serializeVMState(u2);
2662
- Object.assign(o2, a2), u2.status === "complete" ? (o2.state = "COMPLETED", u2.returnValue !== void 0 && (o2.returnValue = u2.returnValue), this.vms.delete(t2)) : u2.status === "error" ? (o2.state = "ERROR", o2.error = u2.error, this.vms.delete(t2)) : u2.status === "waiting_cc" ? (o2.state = "AWAITING_COGNITIVE_RESULT", o2.ccPrompt = u2.ccPrompt) : o2.state = "RUNNING", await this.storage.saveExecution(o2);
2973
+ }, a2 = c2.resume(p2, r2, s2.bytecode, this.fileSystem);
2974
+ a2.output.length > 0 && await this.storage.appendOutput(t2, a2.output);
2975
+ const u2 = this.serializeVMState(a2);
2976
+ Object.assign(o2, u2), a2.status === "complete" ? (o2.state = "COMPLETED", a2.returnValue !== void 0 && (o2.returnValue = a2.returnValue), this.vms.delete(t2)) : a2.status === "error" ? (o2.state = "ERROR", o2.error = a2.error, this.vms.delete(t2)) : a2.status === "waiting_cc" ? (o2.state = "AWAITING_COGNITIVE_RESULT", o2.ccPrompt = a2.ccPrompt) : o2.state = "RUNNING", await this.storage.saveExecution(o2);
2663
2977
  }
2664
2978
  /**
2665
2979
  * Get current execution status
@@ -2738,7 +3052,7 @@ class fe {
2738
3052
  * Serialize heap to storage format
2739
3053
  */
2740
3054
  serializeHeap(t2) {
2741
- const r2 = (s2, c2) => u$1(c2) || b(c2) ? { $ref: c2.id } : c2, o2 = {};
3055
+ const r2 = (s2, c2) => u$1(c2) || b$1(c2) ? { $ref: c2.id } : c2, o2 = {};
2742
3056
  return t2.objects.forEach((s2, c2) => {
2743
3057
  o2[c2] = {
2744
3058
  type: s2.type,
@@ -2754,7 +3068,7 @@ class fe {
2754
3068
  * Deserialize heap from storage format
2755
3069
  */
2756
3070
  deserializeHeap(t2) {
2757
- const r2 = P();
3071
+ const r2 = j();
2758
3072
  r2.nextId = t2.nextId;
2759
3073
  for (const o2 in t2.objects) {
2760
3074
  const s2 = parseInt(o2, 10), c2 = t2.objects[s2];
@@ -2794,7 +3108,7 @@ class fe {
2794
3108
  pc: t2.pc || 0,
2795
3109
  stack: t2.stack || [],
2796
3110
  variables: new Map(Object.entries(t2.variables || {})),
2797
- heap: t2.heap ? this.deserializeHeap(t2.heap) : P(),
3111
+ heap: t2.heap ? this.deserializeHeap(t2.heap) : j(),
2798
3112
  iterators: t2.iterators || [],
2799
3113
  status: t2.status || "running",
2800
3114
  error: t2.error || null,
@@ -2828,7 +3142,7 @@ class $ {
2828
3142
  i(this, "transport", null);
2829
3143
  i(this, "vmManager");
2830
3144
  i(this, "version");
2831
- this.version = e2, this.vmManager = new fe(), this.server = new mcp_js.McpServer({
3145
+ this.version = e2, this.vmManager = new he(), this.server = new mcp_js.McpServer({
2832
3146
  name: "cvm-server",
2833
3147
  version: this.version
2834
3148
  }), this.setupTools();
@@ -3306,7 +3620,7 @@ async function main() {
3306
3620
  ];
3307
3621
  for (const packageJsonPath of possiblePaths) {
3308
3622
  try {
3309
- const packageJson = JSON.parse(b$2.readFileSync(packageJsonPath, "utf-8"));
3623
+ const packageJson = JSON.parse(x$2.readFileSync(packageJsonPath, "utf-8"));
3310
3624
  if (packageJson.name === "cvm-server" && packageJson.version) {
3311
3625
  version = packageJson.version;
3312
3626
  break;