cvm-server 0.15.3 → 0.16.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/main.cjs +449 -297
- package/package.json +14 -2
- package/programs/planexecutor.ts +123 -0
package/main.cjs
CHANGED
|
@@ -7,8 +7,8 @@ const N$1 = require("fs");
|
|
|
7
7
|
const r$2 = require("path");
|
|
8
8
|
const mongodb = require("mongodb");
|
|
9
9
|
const promises = require("fs/promises");
|
|
10
|
-
const dotenv = require("dotenv");
|
|
11
10
|
const url = require("url");
|
|
11
|
+
const dotenv = require("dotenv");
|
|
12
12
|
var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;
|
|
13
13
|
function _interopNamespaceDefault(e) {
|
|
14
14
|
const n2 = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -30,88 +30,88 @@ const r__namespace = /* @__PURE__ */ _interopNamespaceDefault(r$1);
|
|
|
30
30
|
const N__namespace = /* @__PURE__ */ _interopNamespaceDefault(N$1);
|
|
31
31
|
const r__namespace$1 = /* @__PURE__ */ _interopNamespaceDefault(r$2);
|
|
32
32
|
const dotenv__namespace = /* @__PURE__ */ _interopNamespaceDefault(dotenv);
|
|
33
|
-
var P$1 = /* @__PURE__ */ ((
|
|
34
|
-
function _$1(
|
|
35
|
-
return typeof
|
|
33
|
+
var P$1 = /* @__PURE__ */ ((T2) => (T2.PUSH = "PUSH", T2.PUSH_UNDEFINED = "PUSH_UNDEFINED", T2.POP = "POP", T2.DUP = "DUP", T2.DUP2 = "DUP2", T2.SWAP = "SWAP", T2.LOAD = "LOAD", T2.STORE = "STORE", T2.CONCAT = "CONCAT", T2.ARRAY_NEW = "ARRAY_NEW", T2.ARRAY_PUSH = "ARRAY_PUSH", T2.ARRAY_GET = "ARRAY_GET", T2.ARRAY_SET = "ARRAY_SET", T2.ARRAY_LEN = "ARRAY_LEN", T2.ARRAY_MAP_PROP = "ARRAY_MAP_PROP", T2.ARRAY_FILTER_PROP = "ARRAY_FILTER_PROP", T2.ARRAY_SLICE = "ARRAY_SLICE", T2.ARRAY_JOIN = "ARRAY_JOIN", T2.ARRAY_INDEX_OF = "ARRAY_INDEX_OF", T2.STRING_LEN = "STRING_LEN", T2.STRING_SUBSTRING = "STRING_SUBSTRING", T2.STRING_INDEXOF = "STRING_INDEXOF", T2.STRING_SPLIT = "STRING_SPLIT", T2.STRING_SLICE = "STRING_SLICE", T2.STRING_CHARAT = "STRING_CHARAT", T2.STRING_TOUPPERCASE = "STRING_TOUPPERCASE", T2.STRING_TOLOWERCASE = "STRING_TOLOWERCASE", T2.STRING_INCLUDES = "STRING_INCLUDES", T2.STRING_ENDS_WITH = "STRING_ENDS_WITH", T2.STRING_STARTS_WITH = "STRING_STARTS_WITH", T2.STRING_TRIM = "STRING_TRIM", T2.STRING_TRIM_START = "STRING_TRIM_START", T2.STRING_TRIM_END = "STRING_TRIM_END", T2.STRING_REPLACE = "STRING_REPLACE", T2.STRING_REPLACE_ALL = "STRING_REPLACE_ALL", T2.STRING_LAST_INDEX_OF = "STRING_LAST_INDEX_OF", T2.STRING_REPEAT = "STRING_REPEAT", T2.STRING_PAD_START = "STRING_PAD_START", T2.STRING_PAD_END = "STRING_PAD_END", T2.LOAD_REGEX = "LOAD_REGEX", T2.REGEX_TEST = "REGEX_TEST", T2.STRING_MATCH = "STRING_MATCH", T2.STRING_REPLACE_REGEX = "STRING_REPLACE_REGEX", T2.LENGTH = "LENGTH", T2.TO_STRING = "TO_STRING", T2.JSON_PARSE = "JSON_PARSE", T2.TYPEOF = "TYPEOF", T2.ADD = "ADD", T2.SUB = "SUB", T2.MUL = "MUL", T2.DIV = "DIV", T2.MOD = "MOD", T2.UNARY_MINUS = "UNARY_MINUS", T2.UNARY_PLUS = "UNARY_PLUS", T2.INC = "INC", T2.DEC = "DEC", T2.EQ = "EQ", T2.NEQ = "NEQ", T2.LT = "LT", T2.GT = "GT", T2.LTE = "LTE", T2.GTE = "GTE", T2.EQ_STRICT = "EQ_STRICT", T2.NEQ_STRICT = "NEQ_STRICT", T2.JUMP = "JUMP", T2.JUMP_IF = "JUMP_IF", T2.JUMP_IF_FALSE = "JUMP_IF_FALSE", T2.JUMP_IF_TRUE = "JUMP_IF_TRUE", T2.CALL = "CALL", T2.RETURN = "RETURN", T2.AND = "AND", T2.OR = "OR", T2.NOT = "NOT", T2.BREAK = "BREAK", T2.CONTINUE = "CONTINUE", T2.ITER_START = "ITER_START", T2.ITER_NEXT = "ITER_NEXT", T2.ITER_END = "ITER_END", T2.OBJECT_ITER_START = "OBJECT_ITER_START", T2.OBJECT_ITER_NEXT = "OBJECT_ITER_NEXT", T2.FS_LIST_FILES = "FS_LIST_FILES", T2.FS_READ_FILE = "FS_READ_FILE", T2.FS_WRITE_FILE = "FS_WRITE_FILE", T2.OBJECT_CREATE = "OBJECT_CREATE", T2.PROPERTY_GET = "PROPERTY_GET", T2.PROPERTY_SET = "PROPERTY_SET", T2.OBJECT_KEYS = "OBJECT_KEYS", T2.JSON_STRINGIFY = "JSON_STRINGIFY", T2.GET = "GET", T2.SET = "SET", T2.CC = "CC", T2.PRINT = "PRINT", T2.HALT = "HALT", T2))(P$1 || {});
|
|
34
|
+
function _$1(T2) {
|
|
35
|
+
return typeof T2 == "string";
|
|
36
36
|
}
|
|
37
|
-
function E$2(
|
|
38
|
-
return typeof
|
|
37
|
+
function E$2(T2) {
|
|
38
|
+
return typeof T2 == "number";
|
|
39
39
|
}
|
|
40
|
-
function n(
|
|
41
|
-
return typeof
|
|
40
|
+
function n(T2) {
|
|
41
|
+
return typeof T2 == "boolean";
|
|
42
42
|
}
|
|
43
|
-
function t(
|
|
44
|
-
return
|
|
43
|
+
function t(T2) {
|
|
44
|
+
return T2 === null;
|
|
45
45
|
}
|
|
46
|
-
function S(
|
|
47
|
-
return
|
|
46
|
+
function S$1(T2) {
|
|
47
|
+
return T2 !== null && typeof T2 == "object" && "type" in T2 && T2.type === "array";
|
|
48
48
|
}
|
|
49
|
-
function I$1(
|
|
50
|
-
return
|
|
49
|
+
function I$1(T2) {
|
|
50
|
+
return T2 !== null && typeof T2 == "object" && "type" in T2 && T2.type === "undefined";
|
|
51
51
|
}
|
|
52
|
-
function i
|
|
53
|
-
return
|
|
52
|
+
function i(T2) {
|
|
53
|
+
return T2 !== null && typeof T2 == "object" && "type" in T2 && T2.type === "object";
|
|
54
54
|
}
|
|
55
|
-
function L$1(
|
|
56
|
-
return
|
|
55
|
+
function L$1(T2) {
|
|
56
|
+
return T2 !== null && typeof T2 == "object" && "type" in T2 && T2.type === "array-ref";
|
|
57
57
|
}
|
|
58
|
-
function c(
|
|
59
|
-
return
|
|
58
|
+
function c(T2) {
|
|
59
|
+
return T2 !== null && typeof T2 == "object" && "type" in T2 && T2.type === "object-ref";
|
|
60
60
|
}
|
|
61
|
-
function u
|
|
62
|
-
return _$1(
|
|
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);
|
|
63
63
|
}
|
|
64
|
-
function M$2(
|
|
65
|
-
return n(
|
|
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;
|
|
66
66
|
}
|
|
67
|
-
function y$1(
|
|
68
|
-
return _$1(
|
|
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";
|
|
69
69
|
}
|
|
70
|
-
function F$1(
|
|
71
|
-
if (E$2(
|
|
72
|
-
if (n(
|
|
73
|
-
if (t(
|
|
74
|
-
if (I$1(
|
|
75
|
-
if (_$1(
|
|
76
|
-
const R2 =
|
|
70
|
+
function F$1(T2) {
|
|
71
|
+
if (E$2(T2)) return T2;
|
|
72
|
+
if (n(T2)) return T2 ? 1 : 0;
|
|
73
|
+
if (t(T2)) return 0;
|
|
74
|
+
if (I$1(T2)) return NaN;
|
|
75
|
+
if (_$1(T2)) {
|
|
76
|
+
const R2 = T2.trim();
|
|
77
77
|
return R2 === "" ? 0 : Number(R2);
|
|
78
78
|
}
|
|
79
|
-
return S(
|
|
79
|
+
return S$1(T2) ? NaN : Number(T2);
|
|
80
80
|
}
|
|
81
|
-
function Y$1(
|
|
82
|
-
return R2 ? { type: "array", elements:
|
|
81
|
+
function Y$1(T2 = [], R2) {
|
|
82
|
+
return R2 ? { type: "array", elements: T2, properties: R2 } : { type: "array", elements: T2 };
|
|
83
83
|
}
|
|
84
84
|
function s() {
|
|
85
85
|
return { type: "undefined" };
|
|
86
86
|
}
|
|
87
|
-
function b$2(
|
|
88
|
-
return { type: "object", properties:
|
|
87
|
+
function b$2(T2 = {}) {
|
|
88
|
+
return { type: "object", properties: T2 };
|
|
89
89
|
}
|
|
90
|
-
const f$2 = require("pino"), G$2 = require("fs"), D$
|
|
90
|
+
const f$2 = require("pino"), G$2 = require("fs"), D$2 = require("path");
|
|
91
91
|
let r = null;
|
|
92
92
|
function U$1() {
|
|
93
93
|
if (!r) {
|
|
94
|
-
const
|
|
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$
|
|
97
|
+
const A2 = D$2.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;
|
|
101
101
|
}
|
|
102
102
|
r = f$2({
|
|
103
|
-
level:
|
|
104
|
-
}, N2), r.info("LogLevel: " +
|
|
103
|
+
level: T2
|
|
104
|
+
}, N2), r.info("LogLevel: " + T2);
|
|
105
105
|
}
|
|
106
106
|
return r;
|
|
107
107
|
}
|
|
108
108
|
const g = new Proxy({}, {
|
|
109
|
-
get(
|
|
109
|
+
get(T2, R2) {
|
|
110
110
|
return U$1()[R2];
|
|
111
111
|
}
|
|
112
112
|
});
|
|
113
|
-
var d$
|
|
114
|
-
var y = (t2, e, i2) => e in t2 ? d$
|
|
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;
|
|
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 = [];
|
|
@@ -280,14 +280,14 @@ const k = (t2, e, { compileExpression: i2, compileStatement: s2 }) => {
|
|
|
280
280
|
let o = null;
|
|
281
281
|
try {
|
|
282
282
|
s2(t2.statement);
|
|
283
|
-
} catch (
|
|
284
|
-
g.trace(`FOR-OF: Error compiling loop body for var ${m}: ${
|
|
283
|
+
} catch (x) {
|
|
284
|
+
g.trace(`FOR-OF: Error compiling loop body for var ${m}: ${x}`), o = x;
|
|
285
285
|
}
|
|
286
286
|
o || e.emit(P$1.JUMP, l);
|
|
287
287
|
const u2 = e.popContext();
|
|
288
288
|
if (u2) {
|
|
289
|
-
const
|
|
290
|
-
g.trace(`FOR-OF: Patching breakTargets ${JSON.stringify(u2.breakTargets)} to ${
|
|
289
|
+
const x = e.currentAddress();
|
|
290
|
+
g.trace(`FOR-OF: Patching breakTargets ${JSON.stringify(u2.breakTargets)} to ${x} for var ${m}`), e.emit(P$1.ITER_END), e.patchJumps(u2.breakTargets || [], x), e.patchJumps(u2.continueTargets || [], l);
|
|
291
291
|
} else
|
|
292
292
|
g.trace(`FOR-OF: NO CONTEXT TO PATCH for var ${m}!`);
|
|
293
293
|
if (o)
|
|
@@ -353,8 +353,8 @@ const k = (t2, e, { compileExpression: i2, compileStatement: s2 }) => {
|
|
|
353
353
|
if (t2.caseBlock.clauses.forEach((o, u2) => {
|
|
354
354
|
if (r__namespace.isCaseClause(o)) {
|
|
355
355
|
e.emit(P$1.LOAD, a2), i2(o.expression), e.emit(P$1.EQ_STRICT);
|
|
356
|
-
const
|
|
357
|
-
m.push(
|
|
356
|
+
const x = e.emit(P$1.JUMP_IF_TRUE, -1);
|
|
357
|
+
m.push(x);
|
|
358
358
|
} else r__namespace.isDefaultClause(o) && (l = e.emit(P$1.JUMP, -1));
|
|
359
359
|
}), l === null) {
|
|
360
360
|
const o = e.emit(P$1.JUMP, -1);
|
|
@@ -363,20 +363,20 @@ const k = (t2, e, { compileExpression: i2, compileStatement: s2 }) => {
|
|
|
363
363
|
let p2 = 0;
|
|
364
364
|
t2.caseBlock.clauses.forEach((o, u2) => {
|
|
365
365
|
if (r__namespace.isCaseClause(o)) {
|
|
366
|
-
const
|
|
367
|
-
e.patchJumps([m[p2]],
|
|
366
|
+
const x = e.currentAddress();
|
|
367
|
+
e.patchJumps([m[p2]], x), p2++, o.statements.forEach((f3) => {
|
|
368
368
|
if (r__namespace.isBreakStatement(f3)) {
|
|
369
|
-
const
|
|
370
|
-
c2.push(
|
|
369
|
+
const T2 = e.emit(P$1.JUMP, -1);
|
|
370
|
+
c2.push(T2);
|
|
371
371
|
} else
|
|
372
372
|
s2(f3);
|
|
373
373
|
});
|
|
374
374
|
} else if (r__namespace.isDefaultClause(o)) {
|
|
375
|
-
const
|
|
376
|
-
l !== null && e.patchJumps([l],
|
|
375
|
+
const x = e.currentAddress();
|
|
376
|
+
l !== null && e.patchJumps([l], x), o.statements.forEach((f3) => {
|
|
377
377
|
if (r__namespace.isBreakStatement(f3)) {
|
|
378
|
-
const
|
|
379
|
-
c2.push(
|
|
378
|
+
const T2 = e.emit(P$1.JUMP, -1);
|
|
379
|
+
c2.push(T2);
|
|
380
380
|
} else
|
|
381
381
|
s2(f3);
|
|
382
382
|
});
|
|
@@ -464,11 +464,11 @@ const k = (t2, e, { compileExpression: i2, compileStatement: s2 }) => {
|
|
|
464
464
|
[r__namespace.SyntaxKind.ReturnStatement]: O,
|
|
465
465
|
[r__namespace.SyntaxKind.BreakStatement]: K,
|
|
466
466
|
[r__namespace.SyntaxKind.ContinueStatement]: F
|
|
467
|
-
}, J = (t2, e, i2) => {
|
|
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 = (t2, e, i2) => {
|
|
471
|
+
}, D$1 = (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,13 +479,13 @@ 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 = (t2, e, { compileExpression: i2 }) => {
|
|
482
|
+
}, B$1 = (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
|
-
}, $$
|
|
488
|
+
}, $$1 = (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
490
|
}, j = (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);
|
|
@@ -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 = (t2, e, { compileExpression: i2, reportError: s2 }) => {
|
|
578
|
+
}, Q$1 = (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")
|
|
@@ -680,19 +680,19 @@ const k = (t2, e, { compileExpression: i2, compileStatement: s2 }) => {
|
|
|
680
680
|
} else
|
|
681
681
|
throw new Error("Unsupported property type in object literal");
|
|
682
682
|
}, ee$1 = {
|
|
683
|
-
[r__namespace.SyntaxKind.StringLiteral]: J,
|
|
683
|
+
[r__namespace.SyntaxKind.StringLiteral]: J$1,
|
|
684
684
|
[r__namespace.SyntaxKind.NumericLiteral]: H,
|
|
685
|
-
[r__namespace.SyntaxKind.TrueKeyword]: D,
|
|
685
|
+
[r__namespace.SyntaxKind.TrueKeyword]: D$1,
|
|
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,
|
|
690
|
+
[r__namespace.SyntaxKind.ArrayLiteralExpression]: B$1,
|
|
691
691
|
[r__namespace.SyntaxKind.BinaryExpression]: z,
|
|
692
692
|
[r__namespace.SyntaxKind.PrefixUnaryExpression]: v$1,
|
|
693
693
|
[r__namespace.SyntaxKind.PostfixUnaryExpression]: Y,
|
|
694
|
-
[r__namespace.SyntaxKind.CallExpression]: Q,
|
|
695
|
-
[r__namespace.SyntaxKind.PropertyAccessExpression]: $$
|
|
694
|
+
[r__namespace.SyntaxKind.CallExpression]: Q$1,
|
|
695
|
+
[r__namespace.SyntaxKind.PropertyAccessExpression]: $$1,
|
|
696
696
|
[r__namespace.SyntaxKind.ElementAccessExpression]: j,
|
|
697
697
|
[r__namespace.SyntaxKind.ConditionalExpression]: X$1,
|
|
698
698
|
[r__namespace.SyntaxKind.TypeOfExpression]: W$1,
|
|
@@ -716,10 +716,10 @@ function ie$1(t2) {
|
|
|
716
716
|
compileStatement: m,
|
|
717
717
|
compileExpression: l,
|
|
718
718
|
reportError: (o, u2) => {
|
|
719
|
-
const { line:
|
|
719
|
+
const { line: x, character: f3 } = a2.getLineAndCharacterOfPosition(o.getStart());
|
|
720
720
|
throw e.push({
|
|
721
721
|
message: u2,
|
|
722
|
-
line:
|
|
722
|
+
line: x + 1,
|
|
723
723
|
// TypeScript uses 0-based lines
|
|
724
724
|
character: f3 + 1
|
|
725
725
|
// TypeScript uses 0-based columns
|
|
@@ -727,38 +727,38 @@ function ie$1(t2) {
|
|
|
727
727
|
}
|
|
728
728
|
};
|
|
729
729
|
function m(o) {
|
|
730
|
-
const { line: u2, character:
|
|
730
|
+
const { line: u2, character: x } = a2.getLineAndCharacterOfPosition(o.getStart()), f3 = r__namespace.SyntaxKind[o.kind];
|
|
731
731
|
g.debug("Compiling statement", { line: u2 + 1, kind: f3 });
|
|
732
|
-
const
|
|
733
|
-
|
|
732
|
+
const T2 = L[o.kind];
|
|
733
|
+
T2 ? (g.trace("Visiting statement", { kind: f3, pc: s2.currentAddress() }), T2(o, s2, c2), g.trace("Completed statement", { kind: f3, pc: s2.currentAddress() })) : (e.push({
|
|
734
734
|
message: `Unsupported statement: ${r__namespace.SyntaxKind[o.kind]}`,
|
|
735
735
|
line: u2 + 1,
|
|
736
|
-
character:
|
|
736
|
+
character: x + 1
|
|
737
737
|
}), g.debug("Unsupported statement", { kind: f3, line: u2 + 1 }));
|
|
738
738
|
}
|
|
739
739
|
function l(o) {
|
|
740
|
-
const { line: u2, character:
|
|
740
|
+
const { line: u2, character: x } = a2.getLineAndCharacterOfPosition(o.getStart()), f3 = r__namespace.SyntaxKind[o.kind];
|
|
741
741
|
g.debug("Compiling expression", { line: u2 + 1, kind: f3 });
|
|
742
|
-
const
|
|
743
|
-
|
|
742
|
+
const T2 = ee$1[o.kind];
|
|
743
|
+
T2 ? (g.trace("Visiting expression", { kind: f3, pc: s2.currentAddress() }), T2(o, s2, c2), g.trace("Completed expression", { kind: f3, pc: s2.currentAddress() })) : (e.push({
|
|
744
744
|
message: `Unsupported expression: ${r__namespace.SyntaxKind[o.kind]}`,
|
|
745
745
|
line: u2 + 1,
|
|
746
|
-
character:
|
|
746
|
+
character: x + 1
|
|
747
747
|
}), g.debug("Unsupported expression", { kind: f3, line: u2 + 1 }));
|
|
748
748
|
}
|
|
749
749
|
a2.forEachChild((o) => {
|
|
750
750
|
var u2;
|
|
751
|
-
r__namespace.isFunctionDeclaration(o) && ((u2 = o.name) == null ? void 0 : u2.text) === "main" && o.body && (g.debug("Found main function", { statementCount: o.body.statements.length }), o.body.statements.forEach((
|
|
751
|
+
r__namespace.isFunctionDeclaration(o) && ((u2 = o.name) == null ? void 0 : u2.text) === "main" && o.body && (g.debug("Found main function", { statementCount: o.body.statements.length }), o.body.statements.forEach((x, f3) => {
|
|
752
752
|
g.trace("Compiling main statement", {
|
|
753
753
|
statementIndex: f3 + 1,
|
|
754
754
|
totalStatements: o.body.statements.length
|
|
755
755
|
});
|
|
756
756
|
try {
|
|
757
|
-
m(
|
|
758
|
-
} catch (
|
|
757
|
+
m(x);
|
|
758
|
+
} catch (T2) {
|
|
759
759
|
g.debug("Error in statement", {
|
|
760
760
|
statementIndex: f3 + 1,
|
|
761
|
-
error: String(
|
|
761
|
+
error: String(T2)
|
|
762
762
|
});
|
|
763
763
|
}
|
|
764
764
|
}));
|
|
@@ -778,8 +778,8 @@ function ie$1(t2) {
|
|
|
778
778
|
errors: e
|
|
779
779
|
};
|
|
780
780
|
}
|
|
781
|
-
var d$
|
|
782
|
-
var h = (s2, t2, n2) => t2 in s2 ? d$
|
|
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;
|
|
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(e, t2) {
|
|
1045
|
+
function d$1(e, t2) {
|
|
1046
1046
|
return e.stack.length < 1 ? {
|
|
1047
1047
|
type: "RuntimeError",
|
|
1048
1048
|
message: "Stack underflow",
|
|
@@ -1055,12 +1055,12 @@ const f2 = Z, ee = {
|
|
|
1055
1055
|
stackIn: 2,
|
|
1056
1056
|
stackOut: 1,
|
|
1057
1057
|
execute: (e, t2) => {
|
|
1058
|
-
const r2 = d(e, t2.op);
|
|
1058
|
+
const r2 = d$1(e, t2.op);
|
|
1059
1059
|
if (f2(r2)) return r2;
|
|
1060
|
-
const o = d(e, t2.op);
|
|
1060
|
+
const o = d$1(e, t2.op);
|
|
1061
1061
|
if (f2(o)) return o;
|
|
1062
1062
|
if (_$1(o) || _$1(r2))
|
|
1063
|
-
e.stack.push(u
|
|
1063
|
+
e.stack.push(u(o) + u(r2));
|
|
1064
1064
|
else {
|
|
1065
1065
|
const c2 = F$1(o), s2 = F$1(r2);
|
|
1066
1066
|
e.stack.push(c2 + s2);
|
|
@@ -1071,9 +1071,9 @@ const f2 = Z, ee = {
|
|
|
1071
1071
|
stackIn: 2,
|
|
1072
1072
|
stackOut: 1,
|
|
1073
1073
|
execute: (e, t2) => {
|
|
1074
|
-
const r2 = d(e, t2.op);
|
|
1074
|
+
const r2 = d$1(e, t2.op);
|
|
1075
1075
|
if (f2(r2)) return r2;
|
|
1076
|
-
const o = d(e, t2.op);
|
|
1076
|
+
const o = d$1(e, t2.op);
|
|
1077
1077
|
if (f2(o)) return o;
|
|
1078
1078
|
const c2 = F$1(o), s2 = F$1(r2);
|
|
1079
1079
|
e.stack.push(c2 - s2);
|
|
@@ -1083,9 +1083,9 @@ const f2 = Z, ee = {
|
|
|
1083
1083
|
stackIn: 2,
|
|
1084
1084
|
stackOut: 1,
|
|
1085
1085
|
execute: (e, t2) => {
|
|
1086
|
-
const r2 = d(e, t2.op);
|
|
1086
|
+
const r2 = d$1(e, t2.op);
|
|
1087
1087
|
if (f2(r2)) return r2;
|
|
1088
|
-
const o = d(e, t2.op);
|
|
1088
|
+
const o = d$1(e, t2.op);
|
|
1089
1089
|
if (f2(o)) return o;
|
|
1090
1090
|
const c2 = F$1(o), s2 = F$1(r2);
|
|
1091
1091
|
e.stack.push(c2 * s2);
|
|
@@ -1095,9 +1095,9 @@ const f2 = Z, ee = {
|
|
|
1095
1095
|
stackIn: 2,
|
|
1096
1096
|
stackOut: 1,
|
|
1097
1097
|
execute: (e, t2) => {
|
|
1098
|
-
const r2 = d(e, t2.op);
|
|
1098
|
+
const r2 = d$1(e, t2.op);
|
|
1099
1099
|
if (f2(r2)) return r2;
|
|
1100
|
-
const o = d(e, t2.op);
|
|
1100
|
+
const o = d$1(e, t2.op);
|
|
1101
1101
|
if (f2(o)) return o;
|
|
1102
1102
|
const c2 = F$1(o), s2 = F$1(r2);
|
|
1103
1103
|
if (s2 === 0)
|
|
@@ -1114,9 +1114,9 @@ const f2 = Z, ee = {
|
|
|
1114
1114
|
stackIn: 2,
|
|
1115
1115
|
stackOut: 1,
|
|
1116
1116
|
execute: (e, t2) => {
|
|
1117
|
-
const r2 = d(e, t2.op);
|
|
1117
|
+
const r2 = d$1(e, t2.op);
|
|
1118
1118
|
if (f2(r2)) return r2;
|
|
1119
|
-
const o = d(e, t2.op);
|
|
1119
|
+
const o = d$1(e, t2.op);
|
|
1120
1120
|
if (f2(o)) return o;
|
|
1121
1121
|
const c2 = F$1(o), s2 = F$1(r2);
|
|
1122
1122
|
e.stack.push(c2 % s2);
|
|
@@ -1126,7 +1126,7 @@ const f2 = Z, ee = {
|
|
|
1126
1126
|
stackIn: 1,
|
|
1127
1127
|
stackOut: 1,
|
|
1128
1128
|
execute: (e, t2) => {
|
|
1129
|
-
const r2 = d(e, t2.op);
|
|
1129
|
+
const r2 = d$1(e, t2.op);
|
|
1130
1130
|
if (f2(r2)) return r2;
|
|
1131
1131
|
const o = F$1(r2);
|
|
1132
1132
|
e.stack.push(-o);
|
|
@@ -1136,7 +1136,7 @@ const f2 = Z, ee = {
|
|
|
1136
1136
|
stackIn: 1,
|
|
1137
1137
|
stackOut: 1,
|
|
1138
1138
|
execute: (e, t2) => {
|
|
1139
|
-
const r2 = d(e, t2.op);
|
|
1139
|
+
const r2 = d$1(e, t2.op);
|
|
1140
1140
|
if (f2(r2)) return r2;
|
|
1141
1141
|
const o = F$1(r2);
|
|
1142
1142
|
e.stack.push(o);
|
|
@@ -1194,7 +1194,7 @@ const f2 = Z, ee = {
|
|
|
1194
1194
|
stackOut: 0,
|
|
1195
1195
|
execute: (e) => {
|
|
1196
1196
|
const t2 = e.stack.pop();
|
|
1197
|
-
t2 !== void 0 && e.output.push(u
|
|
1197
|
+
t2 !== void 0 && e.output.push(u(t2));
|
|
1198
1198
|
}
|
|
1199
1199
|
},
|
|
1200
1200
|
[P$1.CC]: {
|
|
@@ -1204,7 +1204,7 @@ const f2 = Z, ee = {
|
|
|
1204
1204
|
// CC pauses execution
|
|
1205
1205
|
execute: (e, t2) => {
|
|
1206
1206
|
const r2 = e.stack.pop();
|
|
1207
|
-
e.ccPrompt = u
|
|
1207
|
+
e.ccPrompt = u(r2), e.status = "waiting_cc";
|
|
1208
1208
|
}
|
|
1209
1209
|
}
|
|
1210
1210
|
}, oe = {
|
|
@@ -1363,7 +1363,7 @@ const f2 = Z, ee = {
|
|
|
1363
1363
|
opcode: t2.op
|
|
1364
1364
|
};
|
|
1365
1365
|
o = c2.data;
|
|
1366
|
-
} else if (S(r2))
|
|
1366
|
+
} else if (S$1(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(e, t2.op);
|
|
1421
|
+
const o = d$1(e, t2.op);
|
|
1422
1422
|
if (f2(o)) return o;
|
|
1423
|
-
const c2 = d(e, t2.op);
|
|
1423
|
+
const c2 = d$1(e, t2.op);
|
|
1424
1424
|
if (f2(c2)) return c2;
|
|
1425
1425
|
const s2 = r2(c2, o);
|
|
1426
1426
|
e.stack.push(s2);
|
|
@@ -1438,7 +1438,7 @@ const ne = {
|
|
|
1438
1438
|
return L$1(r2) && L$1(o) || c(r2) && c(o) ? r2.id === o.id : false;
|
|
1439
1439
|
{
|
|
1440
1440
|
const c2 = F$1(r2), s2 = F$1(o);
|
|
1441
|
-
return !isNaN(c2) && !isNaN(s2) ? c2 === s2 : u
|
|
1441
|
+
return !isNaN(c2) && !isNaN(s2) ? c2 === s2 : u(r2) === u(o);
|
|
1442
1442
|
}
|
|
1443
1443
|
})
|
|
1444
1444
|
},
|
|
@@ -1454,7 +1454,7 @@ const ne = {
|
|
|
1454
1454
|
return L$1(r2) && L$1(o) || c(r2) && c(o) ? r2.id !== o.id : true;
|
|
1455
1455
|
{
|
|
1456
1456
|
const c2 = F$1(r2), s2 = F$1(o);
|
|
1457
|
-
return !isNaN(c2) && !isNaN(s2) ? c2 !== s2 : u
|
|
1457
|
+
return !isNaN(c2) && !isNaN(s2) ? c2 !== s2 : u(r2) !== u(o);
|
|
1458
1458
|
}
|
|
1459
1459
|
})
|
|
1460
1460
|
},
|
|
@@ -1505,9 +1505,9 @@ const ne = {
|
|
|
1505
1505
|
stackIn: 2,
|
|
1506
1506
|
stackOut: 1,
|
|
1507
1507
|
execute: (e, t2) => {
|
|
1508
|
-
const r2 = d(e, t2.op);
|
|
1508
|
+
const r2 = d$1(e, t2.op);
|
|
1509
1509
|
if (f2(r2)) return r2;
|
|
1510
|
-
const o = d(e, t2.op);
|
|
1510
|
+
const o = d$1(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(e, t2.op);
|
|
1520
|
+
const r2 = d$1(e, t2.op);
|
|
1521
1521
|
if (f2(r2)) return r2;
|
|
1522
|
-
const o = d(e, t2.op);
|
|
1522
|
+
const o = d$1(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(e, t2.op);
|
|
1532
|
+
const r2 = d$1(e, t2.op);
|
|
1533
1533
|
if (f2(r2)) return r2;
|
|
1534
1534
|
const o = !M$2(r2);
|
|
1535
1535
|
e.stack.push(o);
|
|
@@ -1568,7 +1568,7 @@ const ne = {
|
|
|
1568
1568
|
opcode: t2.op
|
|
1569
1569
|
};
|
|
1570
1570
|
c2 = s2.data;
|
|
1571
|
-
} else if (S(o))
|
|
1571
|
+
} else if (S$1(o))
|
|
1572
1572
|
c2 = o;
|
|
1573
1573
|
else
|
|
1574
1574
|
return {
|
|
@@ -1606,10 +1606,10 @@ const ne = {
|
|
|
1606
1606
|
pc: e.pc,
|
|
1607
1607
|
opcode: t2.op
|
|
1608
1608
|
};
|
|
1609
|
-
const
|
|
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(o))
|
|
1612
|
+
} else if (S$1(o))
|
|
1613
1613
|
c$1 = o;
|
|
1614
1614
|
else if (_$1(o)) {
|
|
1615
1615
|
let i2;
|
|
@@ -1676,10 +1676,10 @@ const ne = {
|
|
|
1676
1676
|
pc: e.pc,
|
|
1677
1677
|
opcode: t2.op
|
|
1678
1678
|
};
|
|
1679
|
-
const
|
|
1680
|
-
|
|
1679
|
+
const u$1 = i2.data, y2 = u(o);
|
|
1680
|
+
u$1.properties[y2] = r2, e.stack.push(c$1);
|
|
1681
1681
|
return;
|
|
1682
|
-
} else if (S(c$1))
|
|
1682
|
+
} else if (S$1(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(r2))
|
|
1736
|
+
} else if (S$1(r2))
|
|
1737
1737
|
o = r2;
|
|
1738
1738
|
else
|
|
1739
1739
|
return {
|
|
@@ -1768,9 +1768,9 @@ const ne = {
|
|
|
1768
1768
|
const s2 = c$1.data, p2 = Y$1();
|
|
1769
1769
|
for (const i2 of s2.elements)
|
|
1770
1770
|
if (c(i2)) {
|
|
1771
|
-
const
|
|
1772
|
-
if (
|
|
1773
|
-
const y2 =
|
|
1771
|
+
const u$1 = e.heap.get(i2.id);
|
|
1772
|
+
if (u$1 && u$1.type === "object") {
|
|
1773
|
+
const y2 = u$1.data, E3 = u(r2);
|
|
1774
1774
|
p2.elements.push(y2.properties[E3] || null);
|
|
1775
1775
|
} else
|
|
1776
1776
|
p2.elements.push(null);
|
|
@@ -1803,9 +1803,9 @@ const ne = {
|
|
|
1803
1803
|
const s2 = c$1.data, p2 = Y$1();
|
|
1804
1804
|
for (const i2 of s2.elements)
|
|
1805
1805
|
if (c(i2)) {
|
|
1806
|
-
const
|
|
1807
|
-
if (
|
|
1808
|
-
const y2 =
|
|
1806
|
+
const u$1 = e.heap.get(i2.id);
|
|
1807
|
+
if (u$1 && u$1.type === "object") {
|
|
1808
|
+
const y2 = u$1.data, E3 = u(r2);
|
|
1809
1809
|
E3 in y2.properties && y2.properties[E3] && p2.elements.push(i2);
|
|
1810
1810
|
}
|
|
1811
1811
|
}
|
|
@@ -1912,18 +1912,18 @@ const ie = {
|
|
|
1912
1912
|
stackIn: 2,
|
|
1913
1913
|
stackOut: 1,
|
|
1914
1914
|
execute: (e, t2) => {
|
|
1915
|
-
const r2 = d(e, t2.op);
|
|
1915
|
+
const r2 = d$1(e, t2.op);
|
|
1916
1916
|
if (f2(r2)) return r2;
|
|
1917
|
-
const o = d(e, t2.op);
|
|
1917
|
+
const o = d$1(e, t2.op);
|
|
1918
1918
|
if (f2(o)) return o;
|
|
1919
|
-
e.stack.push(u
|
|
1919
|
+
e.stack.push(u(o) + u(r2));
|
|
1920
1920
|
}
|
|
1921
1921
|
},
|
|
1922
1922
|
[P$1.STRING_LEN]: {
|
|
1923
1923
|
stackIn: 1,
|
|
1924
1924
|
stackOut: 1,
|
|
1925
1925
|
execute: (e, t2) => {
|
|
1926
|
-
const r2 = d(e, t2.op);
|
|
1926
|
+
const r2 = d$1(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(e, t2.op);
|
|
1942
|
+
const r2 = d$1(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(r2))
|
|
1946
|
+
else if (S$1(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(e, t2.op);
|
|
1972
|
+
const r2 = d$1(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(e, t2.op);
|
|
1993
|
+
const r2 = d$1(e, t2.op);
|
|
1994
1994
|
if (f2(r2)) return r2;
|
|
1995
1995
|
e.stack.push(y$1(r2));
|
|
1996
1996
|
}
|
|
@@ -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(c$1) && (o = e.stack.pop()), r2 = e.stack.pop();
|
|
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();
|
|
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(s2)) {
|
|
2132
|
+
if (S$1(s2)) {
|
|
2133
2133
|
const p2 = e.heap.allocate("array", s2);
|
|
2134
2134
|
e.stack.push(p2);
|
|
2135
2135
|
} else
|
|
@@ -2189,7 +2189,7 @@ const ie = {
|
|
|
2189
2189
|
pc: e.pc,
|
|
2190
2190
|
opcode: t2.op
|
|
2191
2191
|
};
|
|
2192
|
-
const c2 = u
|
|
2192
|
+
const c2 = u(r2), s2 = e.fileSystem.writeFile(o, c2);
|
|
2193
2193
|
e.stack.push(s2);
|
|
2194
2194
|
}
|
|
2195
2195
|
},
|
|
@@ -2360,7 +2360,7 @@ const ie = {
|
|
|
2360
2360
|
pc: e.pc,
|
|
2361
2361
|
opcode: t2.op
|
|
2362
2362
|
};
|
|
2363
|
-
const o = u
|
|
2363
|
+
const o = u(r2);
|
|
2364
2364
|
e.stack.push(o);
|
|
2365
2365
|
}
|
|
2366
2366
|
},
|
|
@@ -2593,9 +2593,9 @@ function A(e, t2) {
|
|
|
2593
2593
|
}
|
|
2594
2594
|
return null;
|
|
2595
2595
|
}
|
|
2596
|
-
if (S(e))
|
|
2596
|
+
if (S$1(e))
|
|
2597
2597
|
return e.elements.map((r2) => A(r2, t2));
|
|
2598
|
-
if (i
|
|
2598
|
+
if (i(e)) {
|
|
2599
2599
|
const r2 = {};
|
|
2600
2600
|
for (const [o, c2] of Object.entries(e.properties))
|
|
2601
2601
|
r2[o] = A(c2, t2);
|
|
@@ -2617,11 +2617,11 @@ const de = {
|
|
|
2617
2617
|
stackIn: 3,
|
|
2618
2618
|
stackOut: 1,
|
|
2619
2619
|
execute: (e, t2) => {
|
|
2620
|
-
const r2 = d(e, t2.op);
|
|
2620
|
+
const r2 = d$1(e, t2.op);
|
|
2621
2621
|
if (f2(r2)) return r2;
|
|
2622
|
-
const o = d(e, t2.op);
|
|
2622
|
+
const o = d$1(e, t2.op);
|
|
2623
2623
|
if (f2(o)) return o;
|
|
2624
|
-
const c$1 = d(e, t2.op);
|
|
2624
|
+
const c$1 = d$1(e, t2.op);
|
|
2625
2625
|
if (f2(c$1)) return c$1;
|
|
2626
2626
|
let s2;
|
|
2627
2627
|
if (c(c$1)) {
|
|
@@ -2634,7 +2634,7 @@ const de = {
|
|
|
2634
2634
|
opcode: t2.op
|
|
2635
2635
|
};
|
|
2636
2636
|
s2 = a2.data;
|
|
2637
|
-
} else if (i
|
|
2637
|
+
} else if (i(c$1))
|
|
2638
2638
|
s2 = c$1;
|
|
2639
2639
|
else
|
|
2640
2640
|
return {
|
|
@@ -2643,7 +2643,7 @@ const de = {
|
|
|
2643
2643
|
pc: e.pc,
|
|
2644
2644
|
opcode: t2.op
|
|
2645
2645
|
};
|
|
2646
|
-
const p2 = u
|
|
2646
|
+
const p2 = u(o);
|
|
2647
2647
|
s2.properties[p2] = r2, e.stack.push(c$1);
|
|
2648
2648
|
}
|
|
2649
2649
|
},
|
|
@@ -2651,9 +2651,9 @@ const de = {
|
|
|
2651
2651
|
stackIn: 2,
|
|
2652
2652
|
stackOut: 1,
|
|
2653
2653
|
execute: (e, t$1) => {
|
|
2654
|
-
const r2 = d(e, t$1.op);
|
|
2654
|
+
const r2 = d$1(e, t$1.op);
|
|
2655
2655
|
if (f2(r2)) return r2;
|
|
2656
|
-
const o = d(e, t$1.op);
|
|
2656
|
+
const o = d$1(e, t$1.op);
|
|
2657
2657
|
if (f2(o)) return o;
|
|
2658
2658
|
if (t(o) || I$1(o))
|
|
2659
2659
|
return {
|
|
@@ -2673,13 +2673,13 @@ const de = {
|
|
|
2673
2673
|
opcode: t$1.op
|
|
2674
2674
|
};
|
|
2675
2675
|
c$1 = p2.data;
|
|
2676
|
-
} else if (i
|
|
2676
|
+
} else if (i(o))
|
|
2677
2677
|
c$1 = o;
|
|
2678
2678
|
else {
|
|
2679
2679
|
e.stack.push(s());
|
|
2680
2680
|
return;
|
|
2681
2681
|
}
|
|
2682
|
-
const s$1 = c$1.properties[u
|
|
2682
|
+
const s$1 = c$1.properties[u(r2)];
|
|
2683
2683
|
e.stack.push(s$1 ?? s());
|
|
2684
2684
|
}
|
|
2685
2685
|
},
|
|
@@ -2687,7 +2687,7 @@ const de = {
|
|
|
2687
2687
|
stackIn: 1,
|
|
2688
2688
|
stackOut: 1,
|
|
2689
2689
|
execute: (e, t2) => {
|
|
2690
|
-
const r2 = d(e, t2.op);
|
|
2690
|
+
const r2 = d$1(e, t2.op);
|
|
2691
2691
|
if (f2(r2)) return r2;
|
|
2692
2692
|
const o = A(r2, e.heap);
|
|
2693
2693
|
e.stack.push(JSON.stringify(o));
|
|
@@ -2697,7 +2697,7 @@ const de = {
|
|
|
2697
2697
|
stackIn: 1,
|
|
2698
2698
|
stackOut: 1,
|
|
2699
2699
|
execute: (e, t2) => {
|
|
2700
|
-
const r2 = d(e, t2.op);
|
|
2700
|
+
const r2 = d$1(e, t2.op);
|
|
2701
2701
|
if (f2(r2)) return r2;
|
|
2702
2702
|
if (c(r2)) {
|
|
2703
2703
|
const o = e.heap.get(r2.id);
|
|
@@ -2706,7 +2706,7 @@ const de = {
|
|
|
2706
2706
|
e.stack.push(p2);
|
|
2707
2707
|
} else
|
|
2708
2708
|
e.stack.push(null);
|
|
2709
|
-
} else if (i
|
|
2709
|
+
} else if (i(r2)) {
|
|
2710
2710
|
const o = Object.keys(r2.properties), c2 = e.heap.allocate("array", { type: "array", elements: o });
|
|
2711
2711
|
e.stack.push(c2);
|
|
2712
2712
|
} else
|
|
@@ -2718,7 +2718,7 @@ const de = {
|
|
|
2718
2718
|
stackIn: 1,
|
|
2719
2719
|
stackOut: 0,
|
|
2720
2720
|
execute: (e, t2) => {
|
|
2721
|
-
const r2 = d(e, t2.op);
|
|
2721
|
+
const r2 = d$1(e, t2.op);
|
|
2722
2722
|
if (f2(r2)) return r2;
|
|
2723
2723
|
if (c(r2)) {
|
|
2724
2724
|
const o = e.heap.get(r2.id);
|
|
@@ -2737,7 +2737,7 @@ const de = {
|
|
|
2737
2737
|
index: 0,
|
|
2738
2738
|
length: 0
|
|
2739
2739
|
});
|
|
2740
|
-
} else if (i
|
|
2740
|
+
} else if (i(r2)) {
|
|
2741
2741
|
const o = Object.keys(r2.properties);
|
|
2742
2742
|
e.iterators.push({
|
|
2743
2743
|
array: null,
|
|
@@ -2815,7 +2815,7 @@ const de = {
|
|
|
2815
2815
|
pc: e.pc,
|
|
2816
2816
|
opcode: t2.op
|
|
2817
2817
|
};
|
|
2818
|
-
const p2 = s$1.data, a2 = u
|
|
2818
|
+
const p2 = s$1.data, a2 = u(r2), i2 = p2.properties[a2] ?? s();
|
|
2819
2819
|
e.stack.push(i2);
|
|
2820
2820
|
return;
|
|
2821
2821
|
} else if (_$1(o)) {
|
|
@@ -2889,7 +2889,7 @@ const de = {
|
|
|
2889
2889
|
pc: e.pc,
|
|
2890
2890
|
opcode: t2.op
|
|
2891
2891
|
};
|
|
2892
|
-
const p2 = s2.data, a2 = u
|
|
2892
|
+
const p2 = s2.data, a2 = u(o);
|
|
2893
2893
|
p2.properties[a2] = r2, e.stack.push(c$1);
|
|
2894
2894
|
return;
|
|
2895
2895
|
} else
|
|
@@ -2943,9 +2943,9 @@ const de = {
|
|
|
2943
2943
|
stackOut: 1,
|
|
2944
2944
|
// Produces boolean result
|
|
2945
2945
|
execute: (e, t2) => {
|
|
2946
|
-
const r2 = d(e, t2.op);
|
|
2946
|
+
const r2 = d$1(e, t2.op);
|
|
2947
2947
|
if (f2(r2)) return r2;
|
|
2948
|
-
const o = d(e, t2.op);
|
|
2948
|
+
const o = d$1(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(e, t2.op);
|
|
2999
|
+
const r2 = d$1(e, t2.op);
|
|
3000
3000
|
if (f2(r2)) return r2;
|
|
3001
|
-
const o = d(e, t2.op);
|
|
3001
|
+
const o = d$1(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(e, t2.op);
|
|
3061
|
+
const r2 = d$1(e, t2.op);
|
|
3062
3062
|
if (f2(r2)) return r2;
|
|
3063
|
-
const o = d(e, t2.op);
|
|
3063
|
+
const o = d$1(e, t2.op);
|
|
3064
3064
|
if (f2(o)) return o;
|
|
3065
|
-
const c$1 = d(e, t2.op);
|
|
3065
|
+
const c$1 = d$1(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
|
-
|
|
3271
|
+
class $ {
|
|
3272
3272
|
constructor() {
|
|
3273
3273
|
b(this, "sandboxPaths", []);
|
|
3274
3274
|
const t2 = process.env.CVM_SANDBOX_PATHS, r2 = process.env.CVM_SANDBOX_ROOT;
|
|
@@ -3339,14 +3339,14 @@ let $$1 = class $ {
|
|
|
3339
3339
|
return false;
|
|
3340
3340
|
}
|
|
3341
3341
|
}
|
|
3342
|
-
}
|
|
3343
|
-
new
|
|
3342
|
+
}
|
|
3343
|
+
new $();
|
|
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 $();
|
|
3350
3350
|
}
|
|
3351
3351
|
/**
|
|
3352
3352
|
* Initialize the VMManager (connect to database)
|
|
@@ -3637,16 +3637,110 @@ class ve {
|
|
|
3637
3637
|
return t2;
|
|
3638
3638
|
}
|
|
3639
3639
|
}
|
|
3640
|
-
var
|
|
3641
|
-
var
|
|
3642
|
-
var
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
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();
|
|
3649
|
+
let n2 = 0;
|
|
3650
|
+
for (; n2 < t2.length; ) {
|
|
3651
|
+
if (t2[n2].trim().startsWith("<mission>")) {
|
|
3652
|
+
c2 = n2;
|
|
3653
|
+
const a2 = t2[n2].trim().replace("<mission>", "").replace("</mission>", "").trim();
|
|
3654
|
+
if (t2[n2].trim().endsWith("</mission>")) {
|
|
3655
|
+
s2 = a2, n2++;
|
|
3656
|
+
break;
|
|
3657
|
+
}
|
|
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(`
|
|
3662
|
+
`).trim();
|
|
3663
|
+
break;
|
|
3664
|
+
}
|
|
3665
|
+
n2++;
|
|
3666
|
+
}
|
|
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; ) {
|
|
3668
|
+
const a2 = t2[n2].trim().match(/^<block\s+id="([^"]+)">/);
|
|
3669
|
+
if (!a2) {
|
|
3670
|
+
n2++;
|
|
3671
|
+
continue;
|
|
3672
|
+
}
|
|
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;
|
|
3676
|
+
for (n2++; n2 < t2.length; ) {
|
|
3677
|
+
const g2 = t2[n2].trim();
|
|
3678
|
+
if (g2.startsWith("</block>")) {
|
|
3679
|
+
f3 = n2, n2++;
|
|
3680
|
+
break;
|
|
3681
|
+
}
|
|
3682
|
+
const b2 = g2.match(/^##\s+TDDAB-\d+:\s+(.+)/);
|
|
3683
|
+
if (b2) {
|
|
3684
|
+
k2 = b2[1], n2++;
|
|
3685
|
+
continue;
|
|
3686
|
+
}
|
|
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++;
|
|
3692
|
+
continue;
|
|
3693
|
+
}
|
|
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(`
|
|
3697
|
+
`).trim();
|
|
3698
|
+
continue;
|
|
3699
|
+
}
|
|
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++;
|
|
3704
|
+
}
|
|
3705
|
+
n2 < t2.length && n2++;
|
|
3706
|
+
continue;
|
|
3707
|
+
}
|
|
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++;
|
|
3712
|
+
}
|
|
3713
|
+
n2 < t2.length && n2++;
|
|
3714
|
+
continue;
|
|
3715
|
+
}
|
|
3716
|
+
n2++;
|
|
3717
|
+
}
|
|
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,
|
|
3720
|
+
title: k2,
|
|
3721
|
+
intro: x,
|
|
3722
|
+
redTests: E3,
|
|
3723
|
+
success: v2,
|
|
3724
|
+
startLine: p2 + 1,
|
|
3725
|
+
endLine: f3 + 1
|
|
3726
|
+
});
|
|
3727
|
+
}
|
|
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 } : {
|
|
3729
|
+
valid: true,
|
|
3730
|
+
plan: { mission: s2, blocks: l, sourceFile: r2 },
|
|
3731
|
+
errors: []
|
|
3732
|
+
};
|
|
3733
|
+
}
|
|
3734
|
+
const J = {
|
|
3735
|
+
"@planexecutor": "planexecutor.ts"
|
|
3736
|
+
};
|
|
3737
|
+
class Q {
|
|
3738
|
+
constructor(r2 = "0.0.1") {
|
|
3739
|
+
d(this, "server");
|
|
3740
|
+
d(this, "transport", null);
|
|
3741
|
+
d(this, "vmManager");
|
|
3742
|
+
d(this, "version");
|
|
3743
|
+
this.version = r2, this.vmManager = new ve(), this.server = new mcp_js.McpServer({
|
|
3650
3744
|
name: "cvm-server",
|
|
3651
3745
|
version: this.version
|
|
3652
3746
|
}), this.setupTools();
|
|
@@ -3664,14 +3758,14 @@ class $2 {
|
|
|
3664
3758
|
programId: zod.z.string(),
|
|
3665
3759
|
source: zod.z.string()
|
|
3666
3760
|
},
|
|
3667
|
-
async ({ programId:
|
|
3761
|
+
async ({ programId: r2, source: t2 }) => {
|
|
3668
3762
|
try {
|
|
3669
|
-
return await this.vmManager.loadProgram(
|
|
3670
|
-
content: [{ type: "text", text: `Program loaded successfully: ${
|
|
3763
|
+
return await this.vmManager.loadProgram(r2, t2), {
|
|
3764
|
+
content: [{ type: "text", text: `Program loaded successfully: ${r2}` }]
|
|
3671
3765
|
};
|
|
3672
|
-
} catch (
|
|
3766
|
+
} catch (e) {
|
|
3673
3767
|
return {
|
|
3674
|
-
content: [{ type: "text", text: `Error: ${
|
|
3768
|
+
content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : "Unknown error"}` }],
|
|
3675
3769
|
isError: true
|
|
3676
3770
|
};
|
|
3677
3771
|
}
|
|
@@ -3682,28 +3776,35 @@ class $2 {
|
|
|
3682
3776
|
programId: zod.z.string(),
|
|
3683
3777
|
filePath: zod.z.string()
|
|
3684
3778
|
},
|
|
3685
|
-
async ({ programId:
|
|
3779
|
+
async ({ programId: r2, filePath: t2 }) => {
|
|
3686
3780
|
try {
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3781
|
+
let e;
|
|
3782
|
+
const s2 = J[t2];
|
|
3783
|
+
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);
|
|
3786
|
+
} else
|
|
3787
|
+
e = r$2.resolve(t2);
|
|
3788
|
+
const c2 = await promises.readFile(e, "utf-8");
|
|
3789
|
+
return await this.vmManager.loadProgram(r2, c2), {
|
|
3790
|
+
content: [{ type: "text", text: `Program loaded successfully from ${t2}: ${r2}` }]
|
|
3690
3791
|
};
|
|
3691
|
-
} catch (
|
|
3692
|
-
if (
|
|
3693
|
-
const
|
|
3694
|
-
if (
|
|
3792
|
+
} catch (e) {
|
|
3793
|
+
if (e instanceof Error) {
|
|
3794
|
+
const s2 = e;
|
|
3795
|
+
if (s2.code === "ENOENT")
|
|
3695
3796
|
return {
|
|
3696
|
-
content: [{ type: "text", text: `Error: File not found: ${
|
|
3797
|
+
content: [{ type: "text", text: `Error: File not found: ${t2}` }],
|
|
3697
3798
|
isError: true
|
|
3698
3799
|
};
|
|
3699
|
-
if (
|
|
3800
|
+
if (s2.code === "EACCES")
|
|
3700
3801
|
return {
|
|
3701
|
-
content: [{ type: "text", text: `Error: Permission denied: ${
|
|
3802
|
+
content: [{ type: "text", text: `Error: Permission denied: ${t2}` }],
|
|
3702
3803
|
isError: true
|
|
3703
3804
|
};
|
|
3704
3805
|
}
|
|
3705
3806
|
return {
|
|
3706
|
-
content: [{ type: "text", text: `Error: ${
|
|
3807
|
+
content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : "Unknown error"}` }],
|
|
3707
3808
|
isError: true
|
|
3708
3809
|
};
|
|
3709
3810
|
}
|
|
@@ -3715,14 +3816,14 @@ class $2 {
|
|
|
3715
3816
|
executionId: zod.z.string(),
|
|
3716
3817
|
setCurrent: zod.z.boolean().optional()
|
|
3717
3818
|
},
|
|
3718
|
-
async ({ programId:
|
|
3819
|
+
async ({ programId: r2, executionId: t2, setCurrent: e = true }) => {
|
|
3719
3820
|
try {
|
|
3720
|
-
return await this.vmManager.startExecution(
|
|
3721
|
-
content: [{ type: "text", text: `Execution started: ${
|
|
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)" : ""}` }]
|
|
3722
3823
|
};
|
|
3723
|
-
} catch (
|
|
3824
|
+
} catch (s2) {
|
|
3724
3825
|
return {
|
|
3725
|
-
content: [{ type: "text", text: `Error: ${
|
|
3826
|
+
content: [{ type: "text", text: `Error: ${s2 instanceof Error ? s2.message : "Unknown error"}` }],
|
|
3726
3827
|
isError: true
|
|
3727
3828
|
};
|
|
3728
3829
|
}
|
|
@@ -3732,32 +3833,32 @@ class $2 {
|
|
|
3732
3833
|
{
|
|
3733
3834
|
executionId: zod.z.string().optional()
|
|
3734
3835
|
},
|
|
3735
|
-
async ({ executionId:
|
|
3836
|
+
async ({ executionId: r2 }) => {
|
|
3736
3837
|
try {
|
|
3737
|
-
let
|
|
3738
|
-
if (!
|
|
3739
|
-
const
|
|
3740
|
-
if (!
|
|
3838
|
+
let t2 = r2;
|
|
3839
|
+
if (!t2) {
|
|
3840
|
+
const s2 = await this.vmManager.getCurrentExecutionId();
|
|
3841
|
+
if (!s2)
|
|
3741
3842
|
return {
|
|
3742
3843
|
content: [{ type: "text", text: "No current execution set. Use list_executions to see available executions." }]
|
|
3743
3844
|
};
|
|
3744
|
-
|
|
3845
|
+
t2 = s2;
|
|
3745
3846
|
}
|
|
3746
|
-
const
|
|
3747
|
-
return
|
|
3748
|
-
content: [{ type: "text", text:
|
|
3749
|
-
} :
|
|
3750
|
-
content: [{ type: "text", text:
|
|
3751
|
-
} :
|
|
3752
|
-
content: [{ type: "text", text: `Error: ${
|
|
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}` }],
|
|
3753
3854
|
isError: true
|
|
3754
3855
|
} : {
|
|
3755
3856
|
content: [{ type: "text", text: "Unexpected state" }],
|
|
3756
3857
|
isError: true
|
|
3757
3858
|
};
|
|
3758
|
-
} catch (
|
|
3859
|
+
} catch (t2) {
|
|
3759
3860
|
return {
|
|
3760
|
-
content: [{ type: "text", text: `Error: ${
|
|
3861
|
+
content: [{ type: "text", text: `Error: ${t2 instanceof Error ? t2.message : "Unknown error"}` }],
|
|
3761
3862
|
isError: true
|
|
3762
3863
|
};
|
|
3763
3864
|
}
|
|
@@ -3768,24 +3869,24 @@ class $2 {
|
|
|
3768
3869
|
executionId: zod.z.string().optional(),
|
|
3769
3870
|
result: zod.z.string()
|
|
3770
3871
|
},
|
|
3771
|
-
async ({ executionId:
|
|
3872
|
+
async ({ executionId: r2, result: t2 }) => {
|
|
3772
3873
|
try {
|
|
3773
|
-
let
|
|
3774
|
-
if (!
|
|
3775
|
-
const
|
|
3776
|
-
if (!
|
|
3874
|
+
let e = r2;
|
|
3875
|
+
if (!e) {
|
|
3876
|
+
const s2 = await this.vmManager.getCurrentExecutionId();
|
|
3877
|
+
if (!s2)
|
|
3777
3878
|
return {
|
|
3778
3879
|
content: [{ type: "text", text: "Error: No current execution set" }],
|
|
3779
3880
|
isError: true
|
|
3780
3881
|
};
|
|
3781
|
-
|
|
3882
|
+
e = s2;
|
|
3782
3883
|
}
|
|
3783
|
-
return await this.vmManager.reportCCResult(
|
|
3884
|
+
return await this.vmManager.reportCCResult(e, t2), {
|
|
3784
3885
|
content: [{ type: "text", text: "Execution resumed" }]
|
|
3785
3886
|
};
|
|
3786
|
-
} catch (
|
|
3887
|
+
} catch (e) {
|
|
3787
3888
|
return {
|
|
3788
|
-
content: [{ type: "text", text: `Error: ${
|
|
3889
|
+
content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : "Unknown error"}` }],
|
|
3789
3890
|
isError: true
|
|
3790
3891
|
};
|
|
3791
3892
|
}
|
|
@@ -3795,25 +3896,25 @@ class $2 {
|
|
|
3795
3896
|
{
|
|
3796
3897
|
executionId: zod.z.string().optional()
|
|
3797
3898
|
},
|
|
3798
|
-
async ({ executionId:
|
|
3899
|
+
async ({ executionId: r2 }) => {
|
|
3799
3900
|
try {
|
|
3800
|
-
let
|
|
3801
|
-
if (!
|
|
3802
|
-
const
|
|
3803
|
-
if (!
|
|
3901
|
+
let t2 = r2;
|
|
3902
|
+
if (!t2) {
|
|
3903
|
+
const s2 = await this.vmManager.getCurrentExecutionId();
|
|
3904
|
+
if (!s2)
|
|
3804
3905
|
return {
|
|
3805
3906
|
content: [{ type: "text", text: "Error: No current execution set" }],
|
|
3806
3907
|
isError: true
|
|
3807
3908
|
};
|
|
3808
|
-
|
|
3909
|
+
t2 = s2;
|
|
3809
3910
|
}
|
|
3810
|
-
const
|
|
3911
|
+
const e = await this.vmManager.getExecutionStatus(t2);
|
|
3811
3912
|
return {
|
|
3812
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
3913
|
+
content: [{ type: "text", text: JSON.stringify(e, null, 2) }]
|
|
3813
3914
|
};
|
|
3814
|
-
} catch (
|
|
3915
|
+
} catch (t2) {
|
|
3815
3916
|
return {
|
|
3816
|
-
content: [{ type: "text", text: `Error: ${
|
|
3917
|
+
content: [{ type: "text", text: `Error: ${t2 instanceof Error ? t2.message : "Unknown error"}` }],
|
|
3817
3918
|
isError: true
|
|
3818
3919
|
};
|
|
3819
3920
|
}
|
|
@@ -3823,24 +3924,24 @@ class $2 {
|
|
|
3823
3924
|
{},
|
|
3824
3925
|
async () => {
|
|
3825
3926
|
try {
|
|
3826
|
-
const
|
|
3827
|
-
executionId:
|
|
3828
|
-
programId:
|
|
3829
|
-
state:
|
|
3830
|
-
created:
|
|
3831
|
-
isCurrent:
|
|
3927
|
+
const r2 = await this.vmManager.listExecutions(), t2 = await this.vmManager.getCurrentExecutionId(), e = r2.map((s2) => ({
|
|
3928
|
+
executionId: s2.id,
|
|
3929
|
+
programId: s2.programId,
|
|
3930
|
+
state: s2.state,
|
|
3931
|
+
created: s2.created,
|
|
3932
|
+
isCurrent: s2.id === t2,
|
|
3832
3933
|
summary: {
|
|
3833
|
-
currentPrompt:
|
|
3934
|
+
currentPrompt: s2.state === "AWAITING_COGNITIVE_RESULT" ? s2.ccPrompt : void 0,
|
|
3834
3935
|
tasksCompleted: 0
|
|
3835
3936
|
// TODO: Track this in future
|
|
3836
3937
|
}
|
|
3837
3938
|
}));
|
|
3838
3939
|
return {
|
|
3839
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
3940
|
+
content: [{ type: "text", text: JSON.stringify(e, null, 2) }]
|
|
3840
3941
|
};
|
|
3841
|
-
} catch (
|
|
3942
|
+
} catch (r2) {
|
|
3842
3943
|
return {
|
|
3843
|
-
content: [{ type: "text", text: `Error: ${
|
|
3944
|
+
content: [{ type: "text", text: `Error: ${r2 instanceof Error ? r2.message : "Unknown error"}` }],
|
|
3844
3945
|
isError: true
|
|
3845
3946
|
};
|
|
3846
3947
|
}
|
|
@@ -3850,31 +3951,31 @@ class $2 {
|
|
|
3850
3951
|
{
|
|
3851
3952
|
executionId: zod.z.string().optional()
|
|
3852
3953
|
},
|
|
3853
|
-
async ({ executionId:
|
|
3954
|
+
async ({ executionId: r2 }) => {
|
|
3854
3955
|
try {
|
|
3855
|
-
let
|
|
3856
|
-
if (!
|
|
3857
|
-
const
|
|
3858
|
-
if (!
|
|
3956
|
+
let t2 = r2;
|
|
3957
|
+
if (!t2) {
|
|
3958
|
+
const l = await this.vmManager.getCurrentExecutionId();
|
|
3959
|
+
if (!l)
|
|
3859
3960
|
return {
|
|
3860
3961
|
content: [{ type: "text", text: "Error: No current execution set" }],
|
|
3861
3962
|
isError: true
|
|
3862
3963
|
};
|
|
3863
|
-
|
|
3964
|
+
t2 = l;
|
|
3864
3965
|
}
|
|
3865
|
-
const
|
|
3866
|
-
executionId:
|
|
3867
|
-
programId:
|
|
3868
|
-
state:
|
|
3869
|
-
created:
|
|
3870
|
-
isCurrent:
|
|
3871
|
-
currentTask:
|
|
3872
|
-
prompt:
|
|
3873
|
-
attempts:
|
|
3874
|
-
firstAttemptAt:
|
|
3875
|
-
lastAttemptAt:
|
|
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
|
|
3876
3977
|
} : void 0,
|
|
3877
|
-
variables:
|
|
3978
|
+
variables: e.variables,
|
|
3878
3979
|
stats: {
|
|
3879
3980
|
tasksCompleted: 0
|
|
3880
3981
|
// TODO: Track this
|
|
@@ -3883,9 +3984,9 @@ class $2 {
|
|
|
3883
3984
|
return {
|
|
3884
3985
|
content: [{ type: "text", text: JSON.stringify(c2, null, 2) }]
|
|
3885
3986
|
};
|
|
3886
|
-
} catch (
|
|
3987
|
+
} catch (t2) {
|
|
3887
3988
|
return {
|
|
3888
|
-
content: [{ type: "text", text: `Error: ${
|
|
3989
|
+
content: [{ type: "text", text: `Error: ${t2 instanceof Error ? t2.message : "Unknown error"}` }],
|
|
3889
3990
|
isError: true
|
|
3890
3991
|
};
|
|
3891
3992
|
}
|
|
@@ -3895,14 +3996,14 @@ class $2 {
|
|
|
3895
3996
|
{
|
|
3896
3997
|
executionId: zod.z.string()
|
|
3897
3998
|
},
|
|
3898
|
-
async ({ executionId:
|
|
3999
|
+
async ({ executionId: r2 }) => {
|
|
3899
4000
|
try {
|
|
3900
|
-
return await this.vmManager.setCurrentExecutionId(
|
|
3901
|
-
content: [{ type: "text", text: `Current execution set to: ${
|
|
4001
|
+
return await this.vmManager.setCurrentExecutionId(r2), {
|
|
4002
|
+
content: [{ type: "text", text: `Current execution set to: ${r2}` }]
|
|
3902
4003
|
};
|
|
3903
|
-
} catch (
|
|
4004
|
+
} catch (t2) {
|
|
3904
4005
|
return {
|
|
3905
|
-
content: [{ type: "text", text: `Error: ${
|
|
4006
|
+
content: [{ type: "text", text: `Error: ${t2 instanceof Error ? t2.message : "Unknown error"}` }],
|
|
3906
4007
|
isError: true
|
|
3907
4008
|
};
|
|
3908
4009
|
}
|
|
@@ -3913,11 +4014,11 @@ class $2 {
|
|
|
3913
4014
|
executionId: zod.z.string(),
|
|
3914
4015
|
confirmToken: zod.z.string().optional()
|
|
3915
4016
|
},
|
|
3916
|
-
async ({ executionId:
|
|
4017
|
+
async ({ executionId: r2, confirmToken: t2 }) => {
|
|
3917
4018
|
try {
|
|
3918
|
-
const
|
|
3919
|
-
return
|
|
3920
|
-
content: [{ type: "text", text: `Execution deleted: ${
|
|
4019
|
+
const e = `delete-${r2}-${Date.now()}`;
|
|
4020
|
+
return t2 ? t2 && t2.startsWith(`delete-${r2}-`) ? (await this.vmManager.deleteExecution(r2), {
|
|
4021
|
+
content: [{ type: "text", text: `Execution deleted: ${r2}` }]
|
|
3921
4022
|
}) : {
|
|
3922
4023
|
content: [{ type: "text", text: "Invalid confirmation token" }],
|
|
3923
4024
|
isError: true
|
|
@@ -3926,14 +4027,14 @@ class $2 {
|
|
|
3926
4027
|
type: "text",
|
|
3927
4028
|
text: JSON.stringify({
|
|
3928
4029
|
confirmationRequired: true,
|
|
3929
|
-
message: `To delete execution '${
|
|
3930
|
-
token:
|
|
4030
|
+
message: `To delete execution '${r2}', call this tool again with the confirmation token`,
|
|
4031
|
+
token: e
|
|
3931
4032
|
}, null, 2)
|
|
3932
4033
|
}]
|
|
3933
4034
|
};
|
|
3934
|
-
} catch (
|
|
4035
|
+
} catch (e) {
|
|
3935
4036
|
return {
|
|
3936
|
-
content: [{ type: "text", text: `Error: ${
|
|
4037
|
+
content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : "Unknown error"}` }],
|
|
3937
4038
|
isError: true
|
|
3938
4039
|
};
|
|
3939
4040
|
}
|
|
@@ -3943,22 +4044,22 @@ class $2 {
|
|
|
3943
4044
|
{},
|
|
3944
4045
|
async () => {
|
|
3945
4046
|
try {
|
|
3946
|
-
const
|
|
3947
|
-
if (
|
|
4047
|
+
const r2 = await this.vmManager.listPrograms();
|
|
4048
|
+
if (r2.length === 0)
|
|
3948
4049
|
return {
|
|
3949
4050
|
content: [{ type: "text", text: "No programs loaded" }]
|
|
3950
4051
|
};
|
|
3951
|
-
const
|
|
3952
|
-
programId:
|
|
3953
|
-
name:
|
|
3954
|
-
created:
|
|
4052
|
+
const t2 = r2.map((e) => ({
|
|
4053
|
+
programId: e.id,
|
|
4054
|
+
name: e.name,
|
|
4055
|
+
created: e.created
|
|
3955
4056
|
}));
|
|
3956
4057
|
return {
|
|
3957
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
4058
|
+
content: [{ type: "text", text: JSON.stringify(t2, null, 2) }]
|
|
3958
4059
|
};
|
|
3959
|
-
} catch (
|
|
4060
|
+
} catch (r2) {
|
|
3960
4061
|
return {
|
|
3961
|
-
content: [{ type: "text", text: `Error: ${
|
|
4062
|
+
content: [{ type: "text", text: `Error: ${r2 instanceof Error ? r2.message : "Unknown error"}` }],
|
|
3962
4063
|
isError: true
|
|
3963
4064
|
};
|
|
3964
4065
|
}
|
|
@@ -3969,11 +4070,11 @@ class $2 {
|
|
|
3969
4070
|
programId: zod.z.string(),
|
|
3970
4071
|
confirmToken: zod.z.string().optional()
|
|
3971
4072
|
},
|
|
3972
|
-
async ({ programId:
|
|
4073
|
+
async ({ programId: r2, confirmToken: t2 }) => {
|
|
3973
4074
|
try {
|
|
3974
|
-
const
|
|
3975
|
-
return
|
|
3976
|
-
content: [{ type: "text", text: `Program deleted: ${
|
|
4075
|
+
const e = `delete-${r2}-${Date.now()}`;
|
|
4076
|
+
return t2 ? t2 && t2.startsWith(`delete-${r2}-`) ? (await this.vmManager.deleteProgram(r2), {
|
|
4077
|
+
content: [{ type: "text", text: `Program deleted: ${r2}` }]
|
|
3977
4078
|
}) : {
|
|
3978
4079
|
content: [{ type: "text", text: "Invalid confirmation token" }],
|
|
3979
4080
|
isError: true
|
|
@@ -3982,14 +4083,14 @@ class $2 {
|
|
|
3982
4083
|
type: "text",
|
|
3983
4084
|
text: JSON.stringify({
|
|
3984
4085
|
confirmationRequired: true,
|
|
3985
|
-
message: `To delete program '${
|
|
3986
|
-
token:
|
|
4086
|
+
message: `To delete program '${r2}', call this tool again with the confirmation token`,
|
|
4087
|
+
token: e
|
|
3987
4088
|
}, null, 2)
|
|
3988
4089
|
}]
|
|
3989
4090
|
};
|
|
3990
|
-
} catch (
|
|
4091
|
+
} catch (e) {
|
|
3991
4092
|
return {
|
|
3992
|
-
content: [{ type: "text", text: `Error: ${
|
|
4093
|
+
content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : "Unknown error"}` }],
|
|
3993
4094
|
isError: true
|
|
3994
4095
|
};
|
|
3995
4096
|
}
|
|
@@ -4000,10 +4101,61 @@ class $2 {
|
|
|
4000
4101
|
programId: zod.z.string(),
|
|
4001
4102
|
executionId: zod.z.string().optional()
|
|
4002
4103
|
},
|
|
4003
|
-
async ({ programId:
|
|
4104
|
+
async ({ programId: r2, executionId: t2 }) => {
|
|
4004
4105
|
try {
|
|
4005
4106
|
return {
|
|
4006
|
-
content: [{ type: "text", text: `Execution started: ${await this.vmManager.restartExecution(
|
|
4107
|
+
content: [{ type: "text", text: `Execution started: ${await this.vmManager.restartExecution(r2, t2)} (set as current)` }]
|
|
4108
|
+
};
|
|
4109
|
+
} catch (e) {
|
|
4110
|
+
return {
|
|
4111
|
+
content: [{ type: "text", text: `Error: ${e instanceof Error ? e.message : "Unknown error"}` }],
|
|
4112
|
+
isError: true
|
|
4113
|
+
};
|
|
4114
|
+
}
|
|
4115
|
+
}
|
|
4116
|
+
), this.server.tool(
|
|
4117
|
+
"parsePlan",
|
|
4118
|
+
{ filePath: zod.z.string() },
|
|
4119
|
+
async ({ filePath: r2 }) => {
|
|
4120
|
+
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(`
|
|
4126
|
+
`)}` }],
|
|
4127
|
+
isError: true
|
|
4128
|
+
};
|
|
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(`
|
|
4137
|
+
`),
|
|
4138
|
+
success: a2.success.map((o) => "- [ ] " + o).join(`
|
|
4139
|
+
`),
|
|
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");
|
|
4145
|
+
try {
|
|
4146
|
+
await promises.rename(n2, n2 + ".bak");
|
|
4147
|
+
} catch {
|
|
4148
|
+
}
|
|
4149
|
+
return await promises.writeFile(n2, JSON.stringify(l, null, 2), "utf-8"), {
|
|
4150
|
+
content: [{
|
|
4151
|
+
type: "text",
|
|
4152
|
+
text: JSON.stringify({
|
|
4153
|
+
valid: true,
|
|
4154
|
+
blocks: c2.blocks.length,
|
|
4155
|
+
path: n2,
|
|
4156
|
+
blockIds: c2.blocks.map((a2) => a2.id)
|
|
4157
|
+
}, null, 2)
|
|
4158
|
+
}]
|
|
4007
4159
|
};
|
|
4008
4160
|
} catch (t2) {
|
|
4009
4161
|
return {
|
|
@@ -4014,8 +4166,8 @@ class $2 {
|
|
|
4014
4166
|
}
|
|
4015
4167
|
);
|
|
4016
4168
|
}
|
|
4017
|
-
async start(
|
|
4018
|
-
await this.vmManager.initialize(), this.transport =
|
|
4169
|
+
async start(r2) {
|
|
4170
|
+
await this.vmManager.initialize(), this.transport = r2 || new stdio_js.StdioServerTransport(), await this.server.connect(this.transport);
|
|
4019
4171
|
}
|
|
4020
4172
|
async stop() {
|
|
4021
4173
|
this.transport && (await this.transport.close(), this.transport = null), await this.vmManager.dispose();
|
|
@@ -4099,7 +4251,7 @@ async function main() {
|
|
|
4099
4251
|
} else {
|
|
4100
4252
|
g.info("[CVM] Using MongoDB storage");
|
|
4101
4253
|
}
|
|
4102
|
-
cvmServer = new
|
|
4254
|
+
cvmServer = new Q(version);
|
|
4103
4255
|
await cvmServer.start();
|
|
4104
4256
|
g.info("CVM Server is running and ready to accept MCP connections");
|
|
4105
4257
|
process.on("SIGINT", async () => {
|