@polka-codes/runner 0.9.88 → 0.9.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +3203 -79
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -17900,7 +17900,7 @@ var init_multipart_parser = __esm(() => {
|
|
|
17900
17900
|
|
|
17901
17901
|
// ../../node_modules/node-fetch/src/body.js
|
|
17902
17902
|
import Stream, { PassThrough } from "node:stream";
|
|
17903
|
-
import { types as
|
|
17903
|
+
import { types as types4, deprecate, promisify } from "node:util";
|
|
17904
17904
|
import { Buffer as Buffer4 } from "node:buffer";
|
|
17905
17905
|
|
|
17906
17906
|
class Body {
|
|
@@ -17912,7 +17912,7 @@ class Body {
|
|
|
17912
17912
|
body = null;
|
|
17913
17913
|
} else if (isURLSearchParameters(body)) {
|
|
17914
17914
|
body = Buffer4.from(body.toString());
|
|
17915
|
-
} else if (isBlob(body)) {} else if (Buffer4.isBuffer(body)) {} else if (
|
|
17915
|
+
} else if (isBlob(body)) {} else if (Buffer4.isBuffer(body)) {} else if (types4.isAnyArrayBuffer(body)) {
|
|
17916
17916
|
body = Buffer4.from(body);
|
|
17917
17917
|
} else if (ArrayBuffer.isView(body)) {
|
|
17918
17918
|
body = Buffer4.from(body.buffer, body.byteOffset, body.byteLength);
|
|
@@ -18058,7 +18058,7 @@ var pipeline, INTERNALS, clone2 = (instance, highWaterMark) => {
|
|
|
18058
18058
|
if (isBlob(body)) {
|
|
18059
18059
|
return body.type || null;
|
|
18060
18060
|
}
|
|
18061
|
-
if (Buffer4.isBuffer(body) ||
|
|
18061
|
+
if (Buffer4.isBuffer(body) || types4.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
|
|
18062
18062
|
return null;
|
|
18063
18063
|
}
|
|
18064
18064
|
if (body instanceof FormData2) {
|
|
@@ -18115,7 +18115,7 @@ var init_body = __esm(() => {
|
|
|
18115
18115
|
});
|
|
18116
18116
|
|
|
18117
18117
|
// ../../node_modules/node-fetch/src/headers.js
|
|
18118
|
-
import { types as
|
|
18118
|
+
import { types as types5 } from "node:util";
|
|
18119
18119
|
import http from "node:http";
|
|
18120
18120
|
function fromRawHeaders(headers = []) {
|
|
18121
18121
|
return new Headers2(headers.reduce((result, value, index, array2) => {
|
|
@@ -18157,7 +18157,7 @@ var init_headers = __esm(() => {
|
|
|
18157
18157
|
for (const [name17, values] of Object.entries(raw)) {
|
|
18158
18158
|
result.push(...values.map((value) => [name17, value]));
|
|
18159
18159
|
}
|
|
18160
|
-
} else if (init == null) {} else if (typeof init === "object" && !
|
|
18160
|
+
} else if (init == null) {} else if (typeof init === "object" && !types5.isBoxedPrimitive(init)) {
|
|
18161
18161
|
const method = init[Symbol.iterator];
|
|
18162
18162
|
if (method == null) {
|
|
18163
18163
|
result.push(...Object.entries(init));
|
|
@@ -18166,7 +18166,7 @@ var init_headers = __esm(() => {
|
|
|
18166
18166
|
throw new TypeError("Header pairs must be iterable");
|
|
18167
18167
|
}
|
|
18168
18168
|
result = [...init].map((pair) => {
|
|
18169
|
-
if (typeof pair !== "object" ||
|
|
18169
|
+
if (typeof pair !== "object" || types5.isBoxedPrimitive(pair)) {
|
|
18170
18170
|
throw new TypeError("Each header pair must be an iterable object");
|
|
18171
18171
|
}
|
|
18172
18172
|
return [...pair];
|
|
@@ -37641,6 +37641,2290 @@ var require_mimeScore = __commonJS((exports, module) => {
|
|
|
37641
37641
|
};
|
|
37642
37642
|
});
|
|
37643
37643
|
|
|
37644
|
+
// ../../node_modules/sql.js/dist/sql-wasm.js
|
|
37645
|
+
var require_sql_wasm = __commonJS((exports, module) => {
|
|
37646
|
+
var __dirname = "/Users/xiliangchen/projects/polka-codes/node_modules/sql.js/dist";
|
|
37647
|
+
var initSqlJsPromise = undefined;
|
|
37648
|
+
var initSqlJs = function(moduleConfig) {
|
|
37649
|
+
if (initSqlJsPromise) {
|
|
37650
|
+
return initSqlJsPromise;
|
|
37651
|
+
}
|
|
37652
|
+
initSqlJsPromise = new Promise(function(resolveModule, reject) {
|
|
37653
|
+
var Module = typeof moduleConfig !== "undefined" ? moduleConfig : {};
|
|
37654
|
+
var originalOnAbortFunction = Module["onAbort"];
|
|
37655
|
+
Module["onAbort"] = function(errorThatCausedAbort) {
|
|
37656
|
+
reject(new Error(errorThatCausedAbort));
|
|
37657
|
+
if (originalOnAbortFunction) {
|
|
37658
|
+
originalOnAbortFunction(errorThatCausedAbort);
|
|
37659
|
+
}
|
|
37660
|
+
};
|
|
37661
|
+
Module["postRun"] = Module["postRun"] || [];
|
|
37662
|
+
Module["postRun"].push(function() {
|
|
37663
|
+
resolveModule(Module);
|
|
37664
|
+
});
|
|
37665
|
+
module = undefined;
|
|
37666
|
+
var f3;
|
|
37667
|
+
f3 ||= typeof Module != "undefined" ? Module : {};
|
|
37668
|
+
var aa = typeof window == "object", ba = typeof WorkerGlobalScope != "undefined", ca = typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string" && process.type != "renderer";
|
|
37669
|
+
f3.onRuntimeInitialized = function() {
|
|
37670
|
+
function a(g, l) {
|
|
37671
|
+
switch (typeof l) {
|
|
37672
|
+
case "boolean":
|
|
37673
|
+
dc(g, l ? 1 : 0);
|
|
37674
|
+
break;
|
|
37675
|
+
case "number":
|
|
37676
|
+
ec(g, l);
|
|
37677
|
+
break;
|
|
37678
|
+
case "string":
|
|
37679
|
+
fc(g, l, -1, -1);
|
|
37680
|
+
break;
|
|
37681
|
+
case "object":
|
|
37682
|
+
if (l === null)
|
|
37683
|
+
lb(g);
|
|
37684
|
+
else if (l.length != null) {
|
|
37685
|
+
var n = da(l, ea);
|
|
37686
|
+
gc(g, n, l.length, -1);
|
|
37687
|
+
fa(n);
|
|
37688
|
+
} else
|
|
37689
|
+
va(g, "Wrong API use : tried to return a value of an unknown type (" + l + ").", -1);
|
|
37690
|
+
break;
|
|
37691
|
+
default:
|
|
37692
|
+
lb(g);
|
|
37693
|
+
}
|
|
37694
|
+
}
|
|
37695
|
+
function b(g, l) {
|
|
37696
|
+
for (var n = [], r2 = 0;r2 < g; r2 += 1) {
|
|
37697
|
+
var t2 = m2(l + 4 * r2, "i32"), y = hc(t2);
|
|
37698
|
+
if (y === 1 || y === 2)
|
|
37699
|
+
t2 = ic(t2);
|
|
37700
|
+
else if (y === 3)
|
|
37701
|
+
t2 = jc(t2);
|
|
37702
|
+
else if (y === 4) {
|
|
37703
|
+
y = t2;
|
|
37704
|
+
t2 = kc(y);
|
|
37705
|
+
y = lc(y);
|
|
37706
|
+
for (var L = new Uint8Array(t2), J = 0;J < t2; J += 1)
|
|
37707
|
+
L[J] = p[y + J];
|
|
37708
|
+
t2 = L;
|
|
37709
|
+
} else
|
|
37710
|
+
t2 = null;
|
|
37711
|
+
n.push(t2);
|
|
37712
|
+
}
|
|
37713
|
+
return n;
|
|
37714
|
+
}
|
|
37715
|
+
function c(g, l) {
|
|
37716
|
+
this.Qa = g;
|
|
37717
|
+
this.db = l;
|
|
37718
|
+
this.Oa = 1;
|
|
37719
|
+
this.lb = [];
|
|
37720
|
+
}
|
|
37721
|
+
function d(g, l) {
|
|
37722
|
+
this.db = l;
|
|
37723
|
+
l = ha(g) + 1;
|
|
37724
|
+
this.eb = ia(l);
|
|
37725
|
+
if (this.eb === null)
|
|
37726
|
+
throw Error("Unable to allocate memory for the SQL string");
|
|
37727
|
+
u(g, x2, this.eb, l);
|
|
37728
|
+
this.kb = this.eb;
|
|
37729
|
+
this.Za = this.pb = null;
|
|
37730
|
+
}
|
|
37731
|
+
function e2(g) {
|
|
37732
|
+
this.filename = "dbfile_" + (4294967295 * Math.random() >>> 0);
|
|
37733
|
+
if (g != null) {
|
|
37734
|
+
var l = this.filename, n = "/", r2 = l;
|
|
37735
|
+
n && (n = typeof n == "string" ? n : ja(n), r2 = l ? ka(n + "/" + l) : n);
|
|
37736
|
+
l = la(true, true);
|
|
37737
|
+
r2 = ma(r2, l);
|
|
37738
|
+
if (g) {
|
|
37739
|
+
if (typeof g == "string") {
|
|
37740
|
+
n = Array(g.length);
|
|
37741
|
+
for (var t2 = 0, y = g.length;t2 < y; ++t2)
|
|
37742
|
+
n[t2] = g.charCodeAt(t2);
|
|
37743
|
+
g = n;
|
|
37744
|
+
}
|
|
37745
|
+
na(r2, l | 146);
|
|
37746
|
+
n = oa(r2, 577);
|
|
37747
|
+
pa(n, g, 0, g.length, 0);
|
|
37748
|
+
qa(n);
|
|
37749
|
+
na(r2, l);
|
|
37750
|
+
}
|
|
37751
|
+
}
|
|
37752
|
+
this.handleError(q(this.filename, h2));
|
|
37753
|
+
this.db = m2(h2, "i32");
|
|
37754
|
+
ob(this.db);
|
|
37755
|
+
this.fb = {};
|
|
37756
|
+
this.Sa = {};
|
|
37757
|
+
}
|
|
37758
|
+
var h2 = z2(4), k = f3.cwrap, q = k("sqlite3_open", "number", ["string", "number"]), w = k("sqlite3_close_v2", "number", ["number"]), v = k("sqlite3_exec", "number", ["number", "string", "number", "number", "number"]), C = k("sqlite3_changes", "number", ["number"]), G = k("sqlite3_prepare_v2", "number", ["number", "string", "number", "number", "number"]), pb = k("sqlite3_sql", "string", ["number"]), nc = k("sqlite3_normalized_sql", "string", ["number"]), qb = k("sqlite3_prepare_v2", "number", ["number", "number", "number", "number", "number"]), oc = k("sqlite3_bind_text", "number", ["number", "number", "number", "number", "number"]), rb = k("sqlite3_bind_blob", "number", ["number", "number", "number", "number", "number"]), pc = k("sqlite3_bind_double", "number", ["number", "number", "number"]), qc = k("sqlite3_bind_int", "number", ["number", "number", "number"]), rc = k("sqlite3_bind_parameter_index", "number", ["number", "string"]), sc = k("sqlite3_step", "number", ["number"]), tc = k("sqlite3_errmsg", "string", ["number"]), uc = k("sqlite3_column_count", "number", ["number"]), vc = k("sqlite3_data_count", "number", ["number"]), wc = k("sqlite3_column_double", "number", ["number", "number"]), sb = k("sqlite3_column_text", "string", ["number", "number"]), xc = k("sqlite3_column_blob", "number", ["number", "number"]), yc = k("sqlite3_column_bytes", "number", [
|
|
37759
|
+
"number",
|
|
37760
|
+
"number"
|
|
37761
|
+
]), zc = k("sqlite3_column_type", "number", ["number", "number"]), Ac = k("sqlite3_column_name", "string", ["number", "number"]), Bc = k("sqlite3_reset", "number", ["number"]), Cc = k("sqlite3_clear_bindings", "number", ["number"]), Dc = k("sqlite3_finalize", "number", ["number"]), tb = k("sqlite3_create_function_v2", "number", "number string number number number number number number number".split(" ")), hc = k("sqlite3_value_type", "number", ["number"]), kc = k("sqlite3_value_bytes", "number", ["number"]), jc = k("sqlite3_value_text", "string", ["number"]), lc = k("sqlite3_value_blob", "number", ["number"]), ic = k("sqlite3_value_double", "number", ["number"]), ec = k("sqlite3_result_double", "", ["number", "number"]), lb = k("sqlite3_result_null", "", ["number"]), fc = k("sqlite3_result_text", "", ["number", "string", "number", "number"]), gc = k("sqlite3_result_blob", "", ["number", "number", "number", "number"]), dc = k("sqlite3_result_int", "", ["number", "number"]), va = k("sqlite3_result_error", "", ["number", "string", "number"]), ub = k("sqlite3_aggregate_context", "number", ["number", "number"]), ob = k("RegisterExtensionFunctions", "number", ["number"]), vb = k("sqlite3_update_hook", "number", ["number", "number", "number"]);
|
|
37762
|
+
c.prototype.bind = function(g) {
|
|
37763
|
+
if (!this.Qa)
|
|
37764
|
+
throw "Statement closed";
|
|
37765
|
+
this.reset();
|
|
37766
|
+
return Array.isArray(g) ? this.Cb(g) : g != null && typeof g === "object" ? this.Db(g) : true;
|
|
37767
|
+
};
|
|
37768
|
+
c.prototype.step = function() {
|
|
37769
|
+
if (!this.Qa)
|
|
37770
|
+
throw "Statement closed";
|
|
37771
|
+
this.Oa = 1;
|
|
37772
|
+
var g = sc(this.Qa);
|
|
37773
|
+
switch (g) {
|
|
37774
|
+
case 100:
|
|
37775
|
+
return true;
|
|
37776
|
+
case 101:
|
|
37777
|
+
return false;
|
|
37778
|
+
default:
|
|
37779
|
+
throw this.db.handleError(g);
|
|
37780
|
+
}
|
|
37781
|
+
};
|
|
37782
|
+
c.prototype.wb = function(g) {
|
|
37783
|
+
g == null && (g = this.Oa, this.Oa += 1);
|
|
37784
|
+
return wc(this.Qa, g);
|
|
37785
|
+
};
|
|
37786
|
+
c.prototype.Gb = function(g) {
|
|
37787
|
+
g == null && (g = this.Oa, this.Oa += 1);
|
|
37788
|
+
g = sb(this.Qa, g);
|
|
37789
|
+
if (typeof BigInt !== "function")
|
|
37790
|
+
throw Error("BigInt is not supported");
|
|
37791
|
+
return BigInt(g);
|
|
37792
|
+
};
|
|
37793
|
+
c.prototype.Hb = function(g) {
|
|
37794
|
+
g == null && (g = this.Oa, this.Oa += 1);
|
|
37795
|
+
return sb(this.Qa, g);
|
|
37796
|
+
};
|
|
37797
|
+
c.prototype.getBlob = function(g) {
|
|
37798
|
+
g == null && (g = this.Oa, this.Oa += 1);
|
|
37799
|
+
var l = yc(this.Qa, g);
|
|
37800
|
+
g = xc(this.Qa, g);
|
|
37801
|
+
for (var n = new Uint8Array(l), r2 = 0;r2 < l; r2 += 1)
|
|
37802
|
+
n[r2] = p[g + r2];
|
|
37803
|
+
return n;
|
|
37804
|
+
};
|
|
37805
|
+
c.prototype.get = function(g, l) {
|
|
37806
|
+
l = l || {};
|
|
37807
|
+
g != null && this.bind(g) && this.step();
|
|
37808
|
+
g = [];
|
|
37809
|
+
for (var n = vc(this.Qa), r2 = 0;r2 < n; r2 += 1)
|
|
37810
|
+
switch (zc(this.Qa, r2)) {
|
|
37811
|
+
case 1:
|
|
37812
|
+
var t2 = l.useBigInt ? this.Gb(r2) : this.wb(r2);
|
|
37813
|
+
g.push(t2);
|
|
37814
|
+
break;
|
|
37815
|
+
case 2:
|
|
37816
|
+
g.push(this.wb(r2));
|
|
37817
|
+
break;
|
|
37818
|
+
case 3:
|
|
37819
|
+
g.push(this.Hb(r2));
|
|
37820
|
+
break;
|
|
37821
|
+
case 4:
|
|
37822
|
+
g.push(this.getBlob(r2));
|
|
37823
|
+
break;
|
|
37824
|
+
default:
|
|
37825
|
+
g.push(null);
|
|
37826
|
+
}
|
|
37827
|
+
return g;
|
|
37828
|
+
};
|
|
37829
|
+
c.prototype.getColumnNames = function() {
|
|
37830
|
+
for (var g = [], l = uc(this.Qa), n = 0;n < l; n += 1)
|
|
37831
|
+
g.push(Ac(this.Qa, n));
|
|
37832
|
+
return g;
|
|
37833
|
+
};
|
|
37834
|
+
c.prototype.getAsObject = function(g, l) {
|
|
37835
|
+
g = this.get(g, l);
|
|
37836
|
+
l = this.getColumnNames();
|
|
37837
|
+
for (var n = {}, r2 = 0;r2 < l.length; r2 += 1)
|
|
37838
|
+
n[l[r2]] = g[r2];
|
|
37839
|
+
return n;
|
|
37840
|
+
};
|
|
37841
|
+
c.prototype.getSQL = function() {
|
|
37842
|
+
return pb(this.Qa);
|
|
37843
|
+
};
|
|
37844
|
+
c.prototype.getNormalizedSQL = function() {
|
|
37845
|
+
return nc(this.Qa);
|
|
37846
|
+
};
|
|
37847
|
+
c.prototype.run = function(g) {
|
|
37848
|
+
g != null && this.bind(g);
|
|
37849
|
+
this.step();
|
|
37850
|
+
return this.reset();
|
|
37851
|
+
};
|
|
37852
|
+
c.prototype.sb = function(g, l) {
|
|
37853
|
+
l == null && (l = this.Oa, this.Oa += 1);
|
|
37854
|
+
g = ra(g);
|
|
37855
|
+
var n = da(g, ea);
|
|
37856
|
+
this.lb.push(n);
|
|
37857
|
+
this.db.handleError(oc(this.Qa, l, n, g.length - 1, 0));
|
|
37858
|
+
};
|
|
37859
|
+
c.prototype.Bb = function(g, l) {
|
|
37860
|
+
l == null && (l = this.Oa, this.Oa += 1);
|
|
37861
|
+
var n = da(g, ea);
|
|
37862
|
+
this.lb.push(n);
|
|
37863
|
+
this.db.handleError(rb(this.Qa, l, n, g.length, 0));
|
|
37864
|
+
};
|
|
37865
|
+
c.prototype.rb = function(g, l) {
|
|
37866
|
+
l == null && (l = this.Oa, this.Oa += 1);
|
|
37867
|
+
this.db.handleError((g === (g | 0) ? qc : pc)(this.Qa, l, g));
|
|
37868
|
+
};
|
|
37869
|
+
c.prototype.Eb = function(g) {
|
|
37870
|
+
g == null && (g = this.Oa, this.Oa += 1);
|
|
37871
|
+
rb(this.Qa, g, 0, 0, 0);
|
|
37872
|
+
};
|
|
37873
|
+
c.prototype.tb = function(g, l) {
|
|
37874
|
+
l == null && (l = this.Oa, this.Oa += 1);
|
|
37875
|
+
switch (typeof g) {
|
|
37876
|
+
case "string":
|
|
37877
|
+
this.sb(g, l);
|
|
37878
|
+
return;
|
|
37879
|
+
case "number":
|
|
37880
|
+
this.rb(g, l);
|
|
37881
|
+
return;
|
|
37882
|
+
case "bigint":
|
|
37883
|
+
this.sb(g.toString(), l);
|
|
37884
|
+
return;
|
|
37885
|
+
case "boolean":
|
|
37886
|
+
this.rb(g + 0, l);
|
|
37887
|
+
return;
|
|
37888
|
+
case "object":
|
|
37889
|
+
if (g === null) {
|
|
37890
|
+
this.Eb(l);
|
|
37891
|
+
return;
|
|
37892
|
+
}
|
|
37893
|
+
if (g.length != null) {
|
|
37894
|
+
this.Bb(g, l);
|
|
37895
|
+
return;
|
|
37896
|
+
}
|
|
37897
|
+
}
|
|
37898
|
+
throw "Wrong API use : tried to bind a value of an unknown type (" + g + ").";
|
|
37899
|
+
};
|
|
37900
|
+
c.prototype.Db = function(g) {
|
|
37901
|
+
var l = this;
|
|
37902
|
+
Object.keys(g).forEach(function(n) {
|
|
37903
|
+
var r2 = rc(l.Qa, n);
|
|
37904
|
+
r2 !== 0 && l.tb(g[n], r2);
|
|
37905
|
+
});
|
|
37906
|
+
return true;
|
|
37907
|
+
};
|
|
37908
|
+
c.prototype.Cb = function(g) {
|
|
37909
|
+
for (var l = 0;l < g.length; l += 1)
|
|
37910
|
+
this.tb(g[l], l + 1);
|
|
37911
|
+
return true;
|
|
37912
|
+
};
|
|
37913
|
+
c.prototype.reset = function() {
|
|
37914
|
+
this.freemem();
|
|
37915
|
+
return Cc(this.Qa) === 0 && Bc(this.Qa) === 0;
|
|
37916
|
+
};
|
|
37917
|
+
c.prototype.freemem = function() {
|
|
37918
|
+
for (var g;(g = this.lb.pop()) !== undefined; )
|
|
37919
|
+
fa(g);
|
|
37920
|
+
};
|
|
37921
|
+
c.prototype.free = function() {
|
|
37922
|
+
this.freemem();
|
|
37923
|
+
var g = Dc(this.Qa) === 0;
|
|
37924
|
+
delete this.db.fb[this.Qa];
|
|
37925
|
+
this.Qa = 0;
|
|
37926
|
+
return g;
|
|
37927
|
+
};
|
|
37928
|
+
d.prototype.next = function() {
|
|
37929
|
+
if (this.eb === null)
|
|
37930
|
+
return { done: true };
|
|
37931
|
+
this.Za !== null && (this.Za.free(), this.Za = null);
|
|
37932
|
+
if (!this.db.db)
|
|
37933
|
+
throw this.mb(), Error("Database closed");
|
|
37934
|
+
var g = sa(), l = z2(4);
|
|
37935
|
+
ta(h2);
|
|
37936
|
+
ta(l);
|
|
37937
|
+
try {
|
|
37938
|
+
this.db.handleError(qb(this.db.db, this.kb, -1, h2, l));
|
|
37939
|
+
this.kb = m2(l, "i32");
|
|
37940
|
+
var n = m2(h2, "i32");
|
|
37941
|
+
if (n === 0)
|
|
37942
|
+
return this.mb(), { done: true };
|
|
37943
|
+
this.Za = new c(n, this.db);
|
|
37944
|
+
this.db.fb[n] = this.Za;
|
|
37945
|
+
return { value: this.Za, done: false };
|
|
37946
|
+
} catch (r2) {
|
|
37947
|
+
throw this.pb = ua(this.kb), this.mb(), r2;
|
|
37948
|
+
} finally {
|
|
37949
|
+
wa(g);
|
|
37950
|
+
}
|
|
37951
|
+
};
|
|
37952
|
+
d.prototype.mb = function() {
|
|
37953
|
+
fa(this.eb);
|
|
37954
|
+
this.eb = null;
|
|
37955
|
+
};
|
|
37956
|
+
d.prototype.getRemainingSQL = function() {
|
|
37957
|
+
return this.pb !== null ? this.pb : ua(this.kb);
|
|
37958
|
+
};
|
|
37959
|
+
typeof Symbol === "function" && typeof Symbol.iterator === "symbol" && (d.prototype[Symbol.iterator] = function() {
|
|
37960
|
+
return this;
|
|
37961
|
+
});
|
|
37962
|
+
e2.prototype.run = function(g, l) {
|
|
37963
|
+
if (!this.db)
|
|
37964
|
+
throw "Database closed";
|
|
37965
|
+
if (l) {
|
|
37966
|
+
g = this.prepare(g, l);
|
|
37967
|
+
try {
|
|
37968
|
+
g.step();
|
|
37969
|
+
} finally {
|
|
37970
|
+
g.free();
|
|
37971
|
+
}
|
|
37972
|
+
} else
|
|
37973
|
+
this.handleError(v(this.db, g, 0, 0, h2));
|
|
37974
|
+
return this;
|
|
37975
|
+
};
|
|
37976
|
+
e2.prototype.exec = function(g, l, n) {
|
|
37977
|
+
if (!this.db)
|
|
37978
|
+
throw "Database closed";
|
|
37979
|
+
var r2 = sa(), t2 = null;
|
|
37980
|
+
try {
|
|
37981
|
+
var y = xa(g), L = z2(4);
|
|
37982
|
+
for (g = [];m2(y, "i8") !== 0; ) {
|
|
37983
|
+
ta(h2);
|
|
37984
|
+
ta(L);
|
|
37985
|
+
this.handleError(qb(this.db, y, -1, h2, L));
|
|
37986
|
+
var J = m2(h2, "i32");
|
|
37987
|
+
y = m2(L, "i32");
|
|
37988
|
+
if (J !== 0) {
|
|
37989
|
+
var I = null;
|
|
37990
|
+
t2 = new c(J, this);
|
|
37991
|
+
for (l != null && t2.bind(l);t2.step(); )
|
|
37992
|
+
I === null && (I = { columns: t2.getColumnNames(), values: [] }, g.push(I)), I.values.push(t2.get(null, n));
|
|
37993
|
+
t2.free();
|
|
37994
|
+
}
|
|
37995
|
+
}
|
|
37996
|
+
return g;
|
|
37997
|
+
} catch (M) {
|
|
37998
|
+
throw t2 && t2.free(), M;
|
|
37999
|
+
} finally {
|
|
38000
|
+
wa(r2);
|
|
38001
|
+
}
|
|
38002
|
+
};
|
|
38003
|
+
e2.prototype.each = function(g, l, n, r2, t2) {
|
|
38004
|
+
typeof l === "function" && (r2 = n, n = l, l = undefined);
|
|
38005
|
+
g = this.prepare(g, l);
|
|
38006
|
+
try {
|
|
38007
|
+
for (;g.step(); )
|
|
38008
|
+
n(g.getAsObject(null, t2));
|
|
38009
|
+
} finally {
|
|
38010
|
+
g.free();
|
|
38011
|
+
}
|
|
38012
|
+
if (typeof r2 === "function")
|
|
38013
|
+
return r2();
|
|
38014
|
+
};
|
|
38015
|
+
e2.prototype.prepare = function(g, l) {
|
|
38016
|
+
ta(h2);
|
|
38017
|
+
this.handleError(G(this.db, g, -1, h2, 0));
|
|
38018
|
+
g = m2(h2, "i32");
|
|
38019
|
+
if (g === 0)
|
|
38020
|
+
throw "Nothing to prepare";
|
|
38021
|
+
var n = new c(g, this);
|
|
38022
|
+
l != null && n.bind(l);
|
|
38023
|
+
return this.fb[g] = n;
|
|
38024
|
+
};
|
|
38025
|
+
e2.prototype.iterateStatements = function(g) {
|
|
38026
|
+
return new d(g, this);
|
|
38027
|
+
};
|
|
38028
|
+
e2.prototype["export"] = function() {
|
|
38029
|
+
Object.values(this.fb).forEach(function(l) {
|
|
38030
|
+
l.free();
|
|
38031
|
+
});
|
|
38032
|
+
Object.values(this.Sa).forEach(A2);
|
|
38033
|
+
this.Sa = {};
|
|
38034
|
+
this.handleError(w(this.db));
|
|
38035
|
+
var g = ya(this.filename);
|
|
38036
|
+
this.handleError(q(this.filename, h2));
|
|
38037
|
+
this.db = m2(h2, "i32");
|
|
38038
|
+
ob(this.db);
|
|
38039
|
+
return g;
|
|
38040
|
+
};
|
|
38041
|
+
e2.prototype.close = function() {
|
|
38042
|
+
this.db !== null && (Object.values(this.fb).forEach(function(g) {
|
|
38043
|
+
g.free();
|
|
38044
|
+
}), Object.values(this.Sa).forEach(A2), this.Sa = {}, this.Ya && (A2(this.Ya), this.Ya = undefined), this.handleError(w(this.db)), za("/" + this.filename), this.db = null);
|
|
38045
|
+
};
|
|
38046
|
+
e2.prototype.handleError = function(g) {
|
|
38047
|
+
if (g === 0)
|
|
38048
|
+
return null;
|
|
38049
|
+
g = tc(this.db);
|
|
38050
|
+
throw Error(g);
|
|
38051
|
+
};
|
|
38052
|
+
e2.prototype.getRowsModified = function() {
|
|
38053
|
+
return C(this.db);
|
|
38054
|
+
};
|
|
38055
|
+
e2.prototype.create_function = function(g, l) {
|
|
38056
|
+
Object.prototype.hasOwnProperty.call(this.Sa, g) && (A2(this.Sa[g]), delete this.Sa[g]);
|
|
38057
|
+
var n = Aa(function(r2, t2, y) {
|
|
38058
|
+
t2 = b(t2, y);
|
|
38059
|
+
try {
|
|
38060
|
+
var L = l.apply(null, t2);
|
|
38061
|
+
} catch (J) {
|
|
38062
|
+
va(r2, J, -1);
|
|
38063
|
+
return;
|
|
38064
|
+
}
|
|
38065
|
+
a(r2, L);
|
|
38066
|
+
}, "viii");
|
|
38067
|
+
this.Sa[g] = n;
|
|
38068
|
+
this.handleError(tb(this.db, g, l.length, 1, 0, n, 0, 0, 0));
|
|
38069
|
+
return this;
|
|
38070
|
+
};
|
|
38071
|
+
e2.prototype.create_aggregate = function(g, l) {
|
|
38072
|
+
var n = l.init || function() {
|
|
38073
|
+
return null;
|
|
38074
|
+
}, r2 = l.finalize || function(I) {
|
|
38075
|
+
return I;
|
|
38076
|
+
}, t2 = l.step;
|
|
38077
|
+
if (!t2)
|
|
38078
|
+
throw "An aggregate function must have a step function in " + g;
|
|
38079
|
+
var y = {};
|
|
38080
|
+
Object.hasOwnProperty.call(this.Sa, g) && (A2(this.Sa[g]), delete this.Sa[g]);
|
|
38081
|
+
l = g + "__finalize";
|
|
38082
|
+
Object.hasOwnProperty.call(this.Sa, l) && (A2(this.Sa[l]), delete this.Sa[l]);
|
|
38083
|
+
var L = Aa(function(I, M, Ra) {
|
|
38084
|
+
var X = ub(I, 1);
|
|
38085
|
+
Object.hasOwnProperty.call(y, X) || (y[X] = n());
|
|
38086
|
+
M = b(M, Ra);
|
|
38087
|
+
M = [y[X]].concat(M);
|
|
38088
|
+
try {
|
|
38089
|
+
y[X] = t2.apply(null, M);
|
|
38090
|
+
} catch (Fc) {
|
|
38091
|
+
delete y[X], va(I, Fc, -1);
|
|
38092
|
+
}
|
|
38093
|
+
}, "viii"), J = Aa(function(I) {
|
|
38094
|
+
var M = ub(I, 1);
|
|
38095
|
+
try {
|
|
38096
|
+
var Ra = r2(y[M]);
|
|
38097
|
+
} catch (X) {
|
|
38098
|
+
delete y[M];
|
|
38099
|
+
va(I, X, -1);
|
|
38100
|
+
return;
|
|
38101
|
+
}
|
|
38102
|
+
a(I, Ra);
|
|
38103
|
+
delete y[M];
|
|
38104
|
+
}, "vi");
|
|
38105
|
+
this.Sa[g] = L;
|
|
38106
|
+
this.Sa[l] = J;
|
|
38107
|
+
this.handleError(tb(this.db, g, t2.length - 1, 1, 0, 0, L, J, 0));
|
|
38108
|
+
return this;
|
|
38109
|
+
};
|
|
38110
|
+
e2.prototype.updateHook = function(g) {
|
|
38111
|
+
this.Ya && (vb(this.db, 0, 0), A2(this.Ya), this.Ya = undefined);
|
|
38112
|
+
g && (this.Ya = Aa(function(l, n, r2, t2, y) {
|
|
38113
|
+
switch (n) {
|
|
38114
|
+
case 18:
|
|
38115
|
+
l = "insert";
|
|
38116
|
+
break;
|
|
38117
|
+
case 23:
|
|
38118
|
+
l = "update";
|
|
38119
|
+
break;
|
|
38120
|
+
case 9:
|
|
38121
|
+
l = "delete";
|
|
38122
|
+
break;
|
|
38123
|
+
default:
|
|
38124
|
+
throw "unknown operationCode in updateHook callback: " + n;
|
|
38125
|
+
}
|
|
38126
|
+
r2 = r2 ? B(x2, r2) : "";
|
|
38127
|
+
t2 = t2 ? B(x2, t2) : "";
|
|
38128
|
+
if (y > Number.MAX_SAFE_INTEGER)
|
|
38129
|
+
throw "rowId too big to fit inside a Number";
|
|
38130
|
+
g(l, r2, t2, Number(y));
|
|
38131
|
+
}, "viiiij"), vb(this.db, this.Ya, 0));
|
|
38132
|
+
};
|
|
38133
|
+
f3.Database = e2;
|
|
38134
|
+
};
|
|
38135
|
+
var Ba = { ...f3 }, Ca = "./this.program", Da = (a, b) => {
|
|
38136
|
+
throw b;
|
|
38137
|
+
}, D = "", Ea, Fa;
|
|
38138
|
+
if (ca) {
|
|
38139
|
+
var fs4 = __require("fs");
|
|
38140
|
+
__require("path");
|
|
38141
|
+
D = __dirname + "/";
|
|
38142
|
+
Fa = (a) => {
|
|
38143
|
+
a = Ga(a) ? new URL(a) : a;
|
|
38144
|
+
return fs4.readFileSync(a);
|
|
38145
|
+
};
|
|
38146
|
+
Ea = async (a) => {
|
|
38147
|
+
a = Ga(a) ? new URL(a) : a;
|
|
38148
|
+
return fs4.readFileSync(a, undefined);
|
|
38149
|
+
};
|
|
38150
|
+
!f3.thisProgram && 1 < process.argv.length && (Ca = process.argv[1].replace(/\\/g, "/"));
|
|
38151
|
+
process.argv.slice(2);
|
|
38152
|
+
typeof module != "undefined" && (module.exports = f3);
|
|
38153
|
+
Da = (a, b) => {
|
|
38154
|
+
process.exitCode = a;
|
|
38155
|
+
throw b;
|
|
38156
|
+
};
|
|
38157
|
+
} else if (aa || ba)
|
|
38158
|
+
ba ? D = self.location.href : typeof document != "undefined" && document.currentScript && (D = document.currentScript.src), D = D.startsWith("blob:") ? "" : D.slice(0, D.replace(/[?#].*/, "").lastIndexOf("/") + 1), ba && (Fa = (a) => {
|
|
38159
|
+
var b = new XMLHttpRequest;
|
|
38160
|
+
b.open("GET", a, false);
|
|
38161
|
+
b.responseType = "arraybuffer";
|
|
38162
|
+
b.send(null);
|
|
38163
|
+
return new Uint8Array(b.response);
|
|
38164
|
+
}), Ea = async (a) => {
|
|
38165
|
+
if (Ga(a))
|
|
38166
|
+
return new Promise((c, d) => {
|
|
38167
|
+
var e2 = new XMLHttpRequest;
|
|
38168
|
+
e2.open("GET", a, true);
|
|
38169
|
+
e2.responseType = "arraybuffer";
|
|
38170
|
+
e2.onload = () => {
|
|
38171
|
+
e2.status == 200 || e2.status == 0 && e2.response ? c(e2.response) : d(e2.status);
|
|
38172
|
+
};
|
|
38173
|
+
e2.onerror = d;
|
|
38174
|
+
e2.send(null);
|
|
38175
|
+
});
|
|
38176
|
+
var b = await fetch(a, { credentials: "same-origin" });
|
|
38177
|
+
if (b.ok)
|
|
38178
|
+
return b.arrayBuffer();
|
|
38179
|
+
throw Error(b.status + " : " + b.url);
|
|
38180
|
+
};
|
|
38181
|
+
var Ha = f3.print || console.log.bind(console), Ia = f3.printErr || console.error.bind(console);
|
|
38182
|
+
Object.assign(f3, Ba);
|
|
38183
|
+
Ba = null;
|
|
38184
|
+
f3.thisProgram && (Ca = f3.thisProgram);
|
|
38185
|
+
var Ja = f3.wasmBinary, Ka, La = false, Ma, p, x2, Na, E, F2, Oa, H, Pa, Ga = (a) => a.startsWith("file://");
|
|
38186
|
+
function Qa() {
|
|
38187
|
+
var a = Ka.buffer;
|
|
38188
|
+
f3.HEAP8 = p = new Int8Array(a);
|
|
38189
|
+
f3.HEAP16 = Na = new Int16Array(a);
|
|
38190
|
+
f3.HEAPU8 = x2 = new Uint8Array(a);
|
|
38191
|
+
f3.HEAPU16 = new Uint16Array(a);
|
|
38192
|
+
f3.HEAP32 = E = new Int32Array(a);
|
|
38193
|
+
f3.HEAPU32 = F2 = new Uint32Array(a);
|
|
38194
|
+
f3.HEAPF32 = Oa = new Float32Array(a);
|
|
38195
|
+
f3.HEAPF64 = Pa = new Float64Array(a);
|
|
38196
|
+
f3.HEAP64 = H = new BigInt64Array(a);
|
|
38197
|
+
f3.HEAPU64 = new BigUint64Array(a);
|
|
38198
|
+
}
|
|
38199
|
+
var K = 0, Sa = null;
|
|
38200
|
+
function Ta(a) {
|
|
38201
|
+
f3.onAbort?.(a);
|
|
38202
|
+
a = "Aborted(" + a + ")";
|
|
38203
|
+
Ia(a);
|
|
38204
|
+
La = true;
|
|
38205
|
+
throw new WebAssembly.RuntimeError(a + ". Build with -sASSERTIONS for more info.");
|
|
38206
|
+
}
|
|
38207
|
+
var Ua;
|
|
38208
|
+
async function Va(a) {
|
|
38209
|
+
if (!Ja)
|
|
38210
|
+
try {
|
|
38211
|
+
var b = await Ea(a);
|
|
38212
|
+
return new Uint8Array(b);
|
|
38213
|
+
} catch {}
|
|
38214
|
+
if (a == Ua && Ja)
|
|
38215
|
+
a = new Uint8Array(Ja);
|
|
38216
|
+
else if (Fa)
|
|
38217
|
+
a = Fa(a);
|
|
38218
|
+
else
|
|
38219
|
+
throw "both async and sync fetching of the wasm failed";
|
|
38220
|
+
return a;
|
|
38221
|
+
}
|
|
38222
|
+
async function Wa(a, b) {
|
|
38223
|
+
try {
|
|
38224
|
+
var c = await Va(a);
|
|
38225
|
+
return await WebAssembly.instantiate(c, b);
|
|
38226
|
+
} catch (d) {
|
|
38227
|
+
Ia(`failed to asynchronously prepare wasm: ${d}`), Ta(d);
|
|
38228
|
+
}
|
|
38229
|
+
}
|
|
38230
|
+
async function Xa(a) {
|
|
38231
|
+
var b = Ua;
|
|
38232
|
+
if (!Ja && typeof WebAssembly.instantiateStreaming == "function" && !Ga(b) && !ca)
|
|
38233
|
+
try {
|
|
38234
|
+
var c = fetch(b, { credentials: "same-origin" });
|
|
38235
|
+
return await WebAssembly.instantiateStreaming(c, a);
|
|
38236
|
+
} catch (d) {
|
|
38237
|
+
Ia(`wasm streaming compile failed: ${d}`), Ia("falling back to ArrayBuffer instantiation");
|
|
38238
|
+
}
|
|
38239
|
+
return Wa(b, a);
|
|
38240
|
+
}
|
|
38241
|
+
|
|
38242
|
+
class Ya {
|
|
38243
|
+
name = "ExitStatus";
|
|
38244
|
+
constructor(a) {
|
|
38245
|
+
this.message = `Program terminated with exit(${a})`;
|
|
38246
|
+
this.status = a;
|
|
38247
|
+
}
|
|
38248
|
+
}
|
|
38249
|
+
var Za = (a) => {
|
|
38250
|
+
for (;0 < a.length; )
|
|
38251
|
+
a.shift()(f3);
|
|
38252
|
+
}, $a = [], ab = [], bb = () => {
|
|
38253
|
+
var a = f3.preRun.shift();
|
|
38254
|
+
ab.unshift(a);
|
|
38255
|
+
};
|
|
38256
|
+
function m2(a, b = "i8") {
|
|
38257
|
+
b.endsWith("*") && (b = "*");
|
|
38258
|
+
switch (b) {
|
|
38259
|
+
case "i1":
|
|
38260
|
+
return p[a];
|
|
38261
|
+
case "i8":
|
|
38262
|
+
return p[a];
|
|
38263
|
+
case "i16":
|
|
38264
|
+
return Na[a >> 1];
|
|
38265
|
+
case "i32":
|
|
38266
|
+
return E[a >> 2];
|
|
38267
|
+
case "i64":
|
|
38268
|
+
return H[a >> 3];
|
|
38269
|
+
case "float":
|
|
38270
|
+
return Oa[a >> 2];
|
|
38271
|
+
case "double":
|
|
38272
|
+
return Pa[a >> 3];
|
|
38273
|
+
case "*":
|
|
38274
|
+
return F2[a >> 2];
|
|
38275
|
+
default:
|
|
38276
|
+
Ta(`invalid type for getValue: ${b}`);
|
|
38277
|
+
}
|
|
38278
|
+
}
|
|
38279
|
+
var cb = f3.noExitRuntime || true;
|
|
38280
|
+
function ta(a) {
|
|
38281
|
+
var b = "i32";
|
|
38282
|
+
b.endsWith("*") && (b = "*");
|
|
38283
|
+
switch (b) {
|
|
38284
|
+
case "i1":
|
|
38285
|
+
p[a] = 0;
|
|
38286
|
+
break;
|
|
38287
|
+
case "i8":
|
|
38288
|
+
p[a] = 0;
|
|
38289
|
+
break;
|
|
38290
|
+
case "i16":
|
|
38291
|
+
Na[a >> 1] = 0;
|
|
38292
|
+
break;
|
|
38293
|
+
case "i32":
|
|
38294
|
+
E[a >> 2] = 0;
|
|
38295
|
+
break;
|
|
38296
|
+
case "i64":
|
|
38297
|
+
H[a >> 3] = BigInt(0);
|
|
38298
|
+
break;
|
|
38299
|
+
case "float":
|
|
38300
|
+
Oa[a >> 2] = 0;
|
|
38301
|
+
break;
|
|
38302
|
+
case "double":
|
|
38303
|
+
Pa[a >> 3] = 0;
|
|
38304
|
+
break;
|
|
38305
|
+
case "*":
|
|
38306
|
+
F2[a >> 2] = 0;
|
|
38307
|
+
break;
|
|
38308
|
+
default:
|
|
38309
|
+
Ta(`invalid type for setValue: ${b}`);
|
|
38310
|
+
}
|
|
38311
|
+
}
|
|
38312
|
+
var db2 = typeof TextDecoder != "undefined" ? new TextDecoder : undefined, B = (a, b = 0, c = NaN) => {
|
|
38313
|
+
var d = b + c;
|
|
38314
|
+
for (c = b;a[c] && !(c >= d); )
|
|
38315
|
+
++c;
|
|
38316
|
+
if (16 < c - b && a.buffer && db2)
|
|
38317
|
+
return db2.decode(a.subarray(b, c));
|
|
38318
|
+
for (d = "";b < c; ) {
|
|
38319
|
+
var e2 = a[b++];
|
|
38320
|
+
if (e2 & 128) {
|
|
38321
|
+
var h2 = a[b++] & 63;
|
|
38322
|
+
if ((e2 & 224) == 192)
|
|
38323
|
+
d += String.fromCharCode((e2 & 31) << 6 | h2);
|
|
38324
|
+
else {
|
|
38325
|
+
var k = a[b++] & 63;
|
|
38326
|
+
e2 = (e2 & 240) == 224 ? (e2 & 15) << 12 | h2 << 6 | k : (e2 & 7) << 18 | h2 << 12 | k << 6 | a[b++] & 63;
|
|
38327
|
+
65536 > e2 ? d += String.fromCharCode(e2) : (e2 -= 65536, d += String.fromCharCode(55296 | e2 >> 10, 56320 | e2 & 1023));
|
|
38328
|
+
}
|
|
38329
|
+
} else
|
|
38330
|
+
d += String.fromCharCode(e2);
|
|
38331
|
+
}
|
|
38332
|
+
return d;
|
|
38333
|
+
}, ua = (a, b) => a ? B(x2, a, b) : "", eb = (a, b) => {
|
|
38334
|
+
for (var c = 0, d = a.length - 1;0 <= d; d--) {
|
|
38335
|
+
var e2 = a[d];
|
|
38336
|
+
e2 === "." ? a.splice(d, 1) : e2 === ".." ? (a.splice(d, 1), c++) : c && (a.splice(d, 1), c--);
|
|
38337
|
+
}
|
|
38338
|
+
if (b)
|
|
38339
|
+
for (;c; c--)
|
|
38340
|
+
a.unshift("..");
|
|
38341
|
+
return a;
|
|
38342
|
+
}, ka = (a) => {
|
|
38343
|
+
var b = a.charAt(0) === "/", c = a.slice(-1) === "/";
|
|
38344
|
+
(a = eb(a.split("/").filter((d) => !!d), !b).join("/")) || b || (a = ".");
|
|
38345
|
+
a && c && (a += "/");
|
|
38346
|
+
return (b ? "/" : "") + a;
|
|
38347
|
+
}, fb = (a) => {
|
|
38348
|
+
var b = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);
|
|
38349
|
+
a = b[0];
|
|
38350
|
+
b = b[1];
|
|
38351
|
+
if (!a && !b)
|
|
38352
|
+
return ".";
|
|
38353
|
+
b &&= b.slice(0, -1);
|
|
38354
|
+
return a + b;
|
|
38355
|
+
}, gb = (a) => a && a.match(/([^\/]+|\/)\/*$/)[1], hb = () => {
|
|
38356
|
+
if (ca) {
|
|
38357
|
+
var a = __require("crypto");
|
|
38358
|
+
return (b) => a.randomFillSync(b);
|
|
38359
|
+
}
|
|
38360
|
+
return (b) => crypto.getRandomValues(b);
|
|
38361
|
+
}, ib = (a) => {
|
|
38362
|
+
(ib = hb())(a);
|
|
38363
|
+
}, jb = (...a) => {
|
|
38364
|
+
for (var b = "", c = false, d = a.length - 1;-1 <= d && !c; d--) {
|
|
38365
|
+
c = 0 <= d ? a[d] : "/";
|
|
38366
|
+
if (typeof c != "string")
|
|
38367
|
+
throw new TypeError("Arguments to path.resolve must be strings");
|
|
38368
|
+
if (!c)
|
|
38369
|
+
return "";
|
|
38370
|
+
b = c + "/" + b;
|
|
38371
|
+
c = c.charAt(0) === "/";
|
|
38372
|
+
}
|
|
38373
|
+
b = eb(b.split("/").filter((e2) => !!e2), !c).join("/");
|
|
38374
|
+
return (c ? "/" : "") + b || ".";
|
|
38375
|
+
}, kb = [], ha = (a) => {
|
|
38376
|
+
for (var b = 0, c = 0;c < a.length; ++c) {
|
|
38377
|
+
var d = a.charCodeAt(c);
|
|
38378
|
+
127 >= d ? b++ : 2047 >= d ? b += 2 : 55296 <= d && 57343 >= d ? (b += 4, ++c) : b += 3;
|
|
38379
|
+
}
|
|
38380
|
+
return b;
|
|
38381
|
+
}, u = (a, b, c, d) => {
|
|
38382
|
+
if (!(0 < d))
|
|
38383
|
+
return 0;
|
|
38384
|
+
var e2 = c;
|
|
38385
|
+
d = c + d - 1;
|
|
38386
|
+
for (var h2 = 0;h2 < a.length; ++h2) {
|
|
38387
|
+
var k = a.charCodeAt(h2);
|
|
38388
|
+
if (55296 <= k && 57343 >= k) {
|
|
38389
|
+
var q = a.charCodeAt(++h2);
|
|
38390
|
+
k = 65536 + ((k & 1023) << 10) | q & 1023;
|
|
38391
|
+
}
|
|
38392
|
+
if (127 >= k) {
|
|
38393
|
+
if (c >= d)
|
|
38394
|
+
break;
|
|
38395
|
+
b[c++] = k;
|
|
38396
|
+
} else {
|
|
38397
|
+
if (2047 >= k) {
|
|
38398
|
+
if (c + 1 >= d)
|
|
38399
|
+
break;
|
|
38400
|
+
b[c++] = 192 | k >> 6;
|
|
38401
|
+
} else {
|
|
38402
|
+
if (65535 >= k) {
|
|
38403
|
+
if (c + 2 >= d)
|
|
38404
|
+
break;
|
|
38405
|
+
b[c++] = 224 | k >> 12;
|
|
38406
|
+
} else {
|
|
38407
|
+
if (c + 3 >= d)
|
|
38408
|
+
break;
|
|
38409
|
+
b[c++] = 240 | k >> 18;
|
|
38410
|
+
b[c++] = 128 | k >> 12 & 63;
|
|
38411
|
+
}
|
|
38412
|
+
b[c++] = 128 | k >> 6 & 63;
|
|
38413
|
+
}
|
|
38414
|
+
b[c++] = 128 | k & 63;
|
|
38415
|
+
}
|
|
38416
|
+
}
|
|
38417
|
+
b[c] = 0;
|
|
38418
|
+
return c - e2;
|
|
38419
|
+
}, ra = (a, b) => {
|
|
38420
|
+
var c = Array(ha(a) + 1);
|
|
38421
|
+
a = u(a, c, 0, c.length);
|
|
38422
|
+
b && (c.length = a);
|
|
38423
|
+
return c;
|
|
38424
|
+
}, mb = [];
|
|
38425
|
+
function nb(a, b) {
|
|
38426
|
+
mb[a] = { input: [], output: [], cb: b };
|
|
38427
|
+
wb(a, xb);
|
|
38428
|
+
}
|
|
38429
|
+
var xb = { open(a) {
|
|
38430
|
+
var b = mb[a.node.rdev];
|
|
38431
|
+
if (!b)
|
|
38432
|
+
throw new N(43);
|
|
38433
|
+
a.tty = b;
|
|
38434
|
+
a.seekable = false;
|
|
38435
|
+
}, close(a) {
|
|
38436
|
+
a.tty.cb.fsync(a.tty);
|
|
38437
|
+
}, fsync(a) {
|
|
38438
|
+
a.tty.cb.fsync(a.tty);
|
|
38439
|
+
}, read(a, b, c, d) {
|
|
38440
|
+
if (!a.tty || !a.tty.cb.xb)
|
|
38441
|
+
throw new N(60);
|
|
38442
|
+
for (var e2 = 0, h2 = 0;h2 < d; h2++) {
|
|
38443
|
+
try {
|
|
38444
|
+
var k = a.tty.cb.xb(a.tty);
|
|
38445
|
+
} catch (q) {
|
|
38446
|
+
throw new N(29);
|
|
38447
|
+
}
|
|
38448
|
+
if (k === undefined && e2 === 0)
|
|
38449
|
+
throw new N(6);
|
|
38450
|
+
if (k === null || k === undefined)
|
|
38451
|
+
break;
|
|
38452
|
+
e2++;
|
|
38453
|
+
b[c + h2] = k;
|
|
38454
|
+
}
|
|
38455
|
+
e2 && (a.node.atime = Date.now());
|
|
38456
|
+
return e2;
|
|
38457
|
+
}, write(a, b, c, d) {
|
|
38458
|
+
if (!a.tty || !a.tty.cb.qb)
|
|
38459
|
+
throw new N(60);
|
|
38460
|
+
try {
|
|
38461
|
+
for (var e2 = 0;e2 < d; e2++)
|
|
38462
|
+
a.tty.cb.qb(a.tty, b[c + e2]);
|
|
38463
|
+
} catch (h2) {
|
|
38464
|
+
throw new N(29);
|
|
38465
|
+
}
|
|
38466
|
+
d && (a.node.mtime = a.node.ctime = Date.now());
|
|
38467
|
+
return e2;
|
|
38468
|
+
} }, yb = { xb() {
|
|
38469
|
+
a: {
|
|
38470
|
+
if (!kb.length) {
|
|
38471
|
+
var a = null;
|
|
38472
|
+
if (ca) {
|
|
38473
|
+
var b = Buffer.alloc(256), c = 0, d = process.stdin.fd;
|
|
38474
|
+
try {
|
|
38475
|
+
c = fs4.readSync(d, b, 0, 256);
|
|
38476
|
+
} catch (e2) {
|
|
38477
|
+
if (e2.toString().includes("EOF"))
|
|
38478
|
+
c = 0;
|
|
38479
|
+
else
|
|
38480
|
+
throw e2;
|
|
38481
|
+
}
|
|
38482
|
+
0 < c && (a = b.slice(0, c).toString("utf-8"));
|
|
38483
|
+
} else
|
|
38484
|
+
typeof window != "undefined" && typeof window.prompt == "function" && (a = window.prompt("Input: "), a !== null && (a += `
|
|
38485
|
+
`));
|
|
38486
|
+
if (!a) {
|
|
38487
|
+
a = null;
|
|
38488
|
+
break a;
|
|
38489
|
+
}
|
|
38490
|
+
kb = ra(a, true);
|
|
38491
|
+
}
|
|
38492
|
+
a = kb.shift();
|
|
38493
|
+
}
|
|
38494
|
+
return a;
|
|
38495
|
+
}, qb(a, b) {
|
|
38496
|
+
b === null || b === 10 ? (Ha(B(a.output)), a.output = []) : b != 0 && a.output.push(b);
|
|
38497
|
+
}, fsync(a) {
|
|
38498
|
+
0 < a.output?.length && (Ha(B(a.output)), a.output = []);
|
|
38499
|
+
}, Tb() {
|
|
38500
|
+
return { Ob: 25856, Qb: 5, Nb: 191, Pb: 35387, Mb: [3, 28, 127, 21, 4, 0, 1, 0, 17, 19, 26, 0, 18, 15, 23, 22, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] };
|
|
38501
|
+
}, Ub() {
|
|
38502
|
+
return 0;
|
|
38503
|
+
}, Vb() {
|
|
38504
|
+
return [24, 80];
|
|
38505
|
+
} }, zb = { qb(a, b) {
|
|
38506
|
+
b === null || b === 10 ? (Ia(B(a.output)), a.output = []) : b != 0 && a.output.push(b);
|
|
38507
|
+
}, fsync(a) {
|
|
38508
|
+
0 < a.output?.length && (Ia(B(a.output)), a.output = []);
|
|
38509
|
+
} }, O = { Wa: null, Xa() {
|
|
38510
|
+
return O.createNode(null, "/", 16895, 0);
|
|
38511
|
+
}, createNode(a, b, c, d) {
|
|
38512
|
+
if ((c & 61440) === 24576 || (c & 61440) === 4096)
|
|
38513
|
+
throw new N(63);
|
|
38514
|
+
O.Wa || (O.Wa = { dir: { node: { Ta: O.La.Ta, Ua: O.La.Ua, lookup: O.La.lookup, hb: O.La.hb, rename: O.La.rename, unlink: O.La.unlink, rmdir: O.La.rmdir, readdir: O.La.readdir, symlink: O.La.symlink }, stream: { Va: O.Ma.Va } }, file: { node: { Ta: O.La.Ta, Ua: O.La.Ua }, stream: { Va: O.Ma.Va, read: O.Ma.read, write: O.Ma.write, ib: O.Ma.ib, jb: O.Ma.jb } }, link: { node: { Ta: O.La.Ta, Ua: O.La.Ua, readlink: O.La.readlink }, stream: {} }, ub: { node: { Ta: O.La.Ta, Ua: O.La.Ua }, stream: Ab } });
|
|
38515
|
+
c = Bb(a, b, c, d);
|
|
38516
|
+
P(c.mode) ? (c.La = O.Wa.dir.node, c.Ma = O.Wa.dir.stream, c.Na = {}) : (c.mode & 61440) === 32768 ? (c.La = O.Wa.file.node, c.Ma = O.Wa.file.stream, c.Ra = 0, c.Na = null) : (c.mode & 61440) === 40960 ? (c.La = O.Wa.link.node, c.Ma = O.Wa.link.stream) : (c.mode & 61440) === 8192 && (c.La = O.Wa.ub.node, c.Ma = O.Wa.ub.stream);
|
|
38517
|
+
c.atime = c.mtime = c.ctime = Date.now();
|
|
38518
|
+
a && (a.Na[b] = c, a.atime = a.mtime = a.ctime = c.atime);
|
|
38519
|
+
return c;
|
|
38520
|
+
}, Sb(a) {
|
|
38521
|
+
return a.Na ? a.Na.subarray ? a.Na.subarray(0, a.Ra) : new Uint8Array(a.Na) : new Uint8Array(0);
|
|
38522
|
+
}, La: { Ta(a) {
|
|
38523
|
+
var b = {};
|
|
38524
|
+
b.dev = (a.mode & 61440) === 8192 ? a.id : 1;
|
|
38525
|
+
b.ino = a.id;
|
|
38526
|
+
b.mode = a.mode;
|
|
38527
|
+
b.nlink = 1;
|
|
38528
|
+
b.uid = 0;
|
|
38529
|
+
b.gid = 0;
|
|
38530
|
+
b.rdev = a.rdev;
|
|
38531
|
+
P(a.mode) ? b.size = 4096 : (a.mode & 61440) === 32768 ? b.size = a.Ra : (a.mode & 61440) === 40960 ? b.size = a.link.length : b.size = 0;
|
|
38532
|
+
b.atime = new Date(a.atime);
|
|
38533
|
+
b.mtime = new Date(a.mtime);
|
|
38534
|
+
b.ctime = new Date(a.ctime);
|
|
38535
|
+
b.blksize = 4096;
|
|
38536
|
+
b.blocks = Math.ceil(b.size / b.blksize);
|
|
38537
|
+
return b;
|
|
38538
|
+
}, Ua(a, b) {
|
|
38539
|
+
for (var c of ["mode", "atime", "mtime", "ctime"])
|
|
38540
|
+
b[c] != null && (a[c] = b[c]);
|
|
38541
|
+
b.size !== undefined && (b = b.size, a.Ra != b && (b == 0 ? (a.Na = null, a.Ra = 0) : (c = a.Na, a.Na = new Uint8Array(b), c && a.Na.set(c.subarray(0, Math.min(b, a.Ra))), a.Ra = b)));
|
|
38542
|
+
}, lookup() {
|
|
38543
|
+
throw O.vb;
|
|
38544
|
+
}, hb(a, b, c, d) {
|
|
38545
|
+
return O.createNode(a, b, c, d);
|
|
38546
|
+
}, rename(a, b, c) {
|
|
38547
|
+
try {
|
|
38548
|
+
var d = Q(b, c);
|
|
38549
|
+
} catch (h2) {}
|
|
38550
|
+
if (d) {
|
|
38551
|
+
if (P(a.mode))
|
|
38552
|
+
for (var e2 in d.Na)
|
|
38553
|
+
throw new N(55);
|
|
38554
|
+
Cb(d);
|
|
38555
|
+
}
|
|
38556
|
+
delete a.parent.Na[a.name];
|
|
38557
|
+
b.Na[c] = a;
|
|
38558
|
+
a.name = c;
|
|
38559
|
+
b.ctime = b.mtime = a.parent.ctime = a.parent.mtime = Date.now();
|
|
38560
|
+
}, unlink(a, b) {
|
|
38561
|
+
delete a.Na[b];
|
|
38562
|
+
a.ctime = a.mtime = Date.now();
|
|
38563
|
+
}, rmdir(a, b) {
|
|
38564
|
+
var c = Q(a, b), d;
|
|
38565
|
+
for (d in c.Na)
|
|
38566
|
+
throw new N(55);
|
|
38567
|
+
delete a.Na[b];
|
|
38568
|
+
a.ctime = a.mtime = Date.now();
|
|
38569
|
+
}, readdir(a) {
|
|
38570
|
+
return [".", "..", ...Object.keys(a.Na)];
|
|
38571
|
+
}, symlink(a, b, c) {
|
|
38572
|
+
a = O.createNode(a, b, 41471, 0);
|
|
38573
|
+
a.link = c;
|
|
38574
|
+
return a;
|
|
38575
|
+
}, readlink(a) {
|
|
38576
|
+
if ((a.mode & 61440) !== 40960)
|
|
38577
|
+
throw new N(28);
|
|
38578
|
+
return a.link;
|
|
38579
|
+
} }, Ma: { read(a, b, c, d, e2) {
|
|
38580
|
+
var h2 = a.node.Na;
|
|
38581
|
+
if (e2 >= a.node.Ra)
|
|
38582
|
+
return 0;
|
|
38583
|
+
a = Math.min(a.node.Ra - e2, d);
|
|
38584
|
+
if (8 < a && h2.subarray)
|
|
38585
|
+
b.set(h2.subarray(e2, e2 + a), c);
|
|
38586
|
+
else
|
|
38587
|
+
for (d = 0;d < a; d++)
|
|
38588
|
+
b[c + d] = h2[e2 + d];
|
|
38589
|
+
return a;
|
|
38590
|
+
}, write(a, b, c, d, e2, h2) {
|
|
38591
|
+
b.buffer === p.buffer && (h2 = false);
|
|
38592
|
+
if (!d)
|
|
38593
|
+
return 0;
|
|
38594
|
+
a = a.node;
|
|
38595
|
+
a.mtime = a.ctime = Date.now();
|
|
38596
|
+
if (b.subarray && (!a.Na || a.Na.subarray)) {
|
|
38597
|
+
if (h2)
|
|
38598
|
+
return a.Na = b.subarray(c, c + d), a.Ra = d;
|
|
38599
|
+
if (a.Ra === 0 && e2 === 0)
|
|
38600
|
+
return a.Na = b.slice(c, c + d), a.Ra = d;
|
|
38601
|
+
if (e2 + d <= a.Ra)
|
|
38602
|
+
return a.Na.set(b.subarray(c, c + d), e2), d;
|
|
38603
|
+
}
|
|
38604
|
+
h2 = e2 + d;
|
|
38605
|
+
var k = a.Na ? a.Na.length : 0;
|
|
38606
|
+
k >= h2 || (h2 = Math.max(h2, k * (1048576 > k ? 2 : 1.125) >>> 0), k != 0 && (h2 = Math.max(h2, 256)), k = a.Na, a.Na = new Uint8Array(h2), 0 < a.Ra && a.Na.set(k.subarray(0, a.Ra), 0));
|
|
38607
|
+
if (a.Na.subarray && b.subarray)
|
|
38608
|
+
a.Na.set(b.subarray(c, c + d), e2);
|
|
38609
|
+
else
|
|
38610
|
+
for (h2 = 0;h2 < d; h2++)
|
|
38611
|
+
a.Na[e2 + h2] = b[c + h2];
|
|
38612
|
+
a.Ra = Math.max(a.Ra, e2 + d);
|
|
38613
|
+
return d;
|
|
38614
|
+
}, Va(a, b, c) {
|
|
38615
|
+
c === 1 ? b += a.position : c === 2 && (a.node.mode & 61440) === 32768 && (b += a.node.Ra);
|
|
38616
|
+
if (0 > b)
|
|
38617
|
+
throw new N(28);
|
|
38618
|
+
return b;
|
|
38619
|
+
}, ib(a, b, c, d, e2) {
|
|
38620
|
+
if ((a.node.mode & 61440) !== 32768)
|
|
38621
|
+
throw new N(43);
|
|
38622
|
+
a = a.node.Na;
|
|
38623
|
+
if (e2 & 2 || !a || a.buffer !== p.buffer) {
|
|
38624
|
+
e2 = true;
|
|
38625
|
+
d = 65536 * Math.ceil(b / 65536);
|
|
38626
|
+
var h2 = Db(65536, d);
|
|
38627
|
+
h2 && x2.fill(0, h2, h2 + d);
|
|
38628
|
+
d = h2;
|
|
38629
|
+
if (!d)
|
|
38630
|
+
throw new N(48);
|
|
38631
|
+
if (a) {
|
|
38632
|
+
if (0 < c || c + b < a.length)
|
|
38633
|
+
a.subarray ? a = a.subarray(c, c + b) : a = Array.prototype.slice.call(a, c, c + b);
|
|
38634
|
+
p.set(a, d);
|
|
38635
|
+
}
|
|
38636
|
+
} else
|
|
38637
|
+
e2 = false, d = a.byteOffset;
|
|
38638
|
+
return { Kb: d, Ab: e2 };
|
|
38639
|
+
}, jb(a, b, c, d) {
|
|
38640
|
+
O.Ma.write(a, b, 0, d, c, false);
|
|
38641
|
+
return 0;
|
|
38642
|
+
} } }, la = (a, b) => {
|
|
38643
|
+
var c = 0;
|
|
38644
|
+
a && (c |= 365);
|
|
38645
|
+
b && (c |= 146);
|
|
38646
|
+
return c;
|
|
38647
|
+
}, Eb = null, Fb = {}, Gb = [], Hb = 1, R = null, Ib = false, Jb = true, Kb = {}, N = class {
|
|
38648
|
+
name = "ErrnoError";
|
|
38649
|
+
constructor(a) {
|
|
38650
|
+
this.Pa = a;
|
|
38651
|
+
}
|
|
38652
|
+
}, Lb = class {
|
|
38653
|
+
gb = {};
|
|
38654
|
+
node = null;
|
|
38655
|
+
get flags() {
|
|
38656
|
+
return this.gb.flags;
|
|
38657
|
+
}
|
|
38658
|
+
set flags(a) {
|
|
38659
|
+
this.gb.flags = a;
|
|
38660
|
+
}
|
|
38661
|
+
get position() {
|
|
38662
|
+
return this.gb.position;
|
|
38663
|
+
}
|
|
38664
|
+
set position(a) {
|
|
38665
|
+
this.gb.position = a;
|
|
38666
|
+
}
|
|
38667
|
+
}, Mb = class {
|
|
38668
|
+
La = {};
|
|
38669
|
+
Ma = {};
|
|
38670
|
+
ab = null;
|
|
38671
|
+
constructor(a, b, c, d) {
|
|
38672
|
+
a ||= this;
|
|
38673
|
+
this.parent = a;
|
|
38674
|
+
this.Xa = a.Xa;
|
|
38675
|
+
this.id = Hb++;
|
|
38676
|
+
this.name = b;
|
|
38677
|
+
this.mode = c;
|
|
38678
|
+
this.rdev = d;
|
|
38679
|
+
this.atime = this.mtime = this.ctime = Date.now();
|
|
38680
|
+
}
|
|
38681
|
+
get read() {
|
|
38682
|
+
return (this.mode & 365) === 365;
|
|
38683
|
+
}
|
|
38684
|
+
set read(a) {
|
|
38685
|
+
a ? this.mode |= 365 : this.mode &= -366;
|
|
38686
|
+
}
|
|
38687
|
+
get write() {
|
|
38688
|
+
return (this.mode & 146) === 146;
|
|
38689
|
+
}
|
|
38690
|
+
set write(a) {
|
|
38691
|
+
a ? this.mode |= 146 : this.mode &= -147;
|
|
38692
|
+
}
|
|
38693
|
+
};
|
|
38694
|
+
function S2(a, b = {}) {
|
|
38695
|
+
if (!a)
|
|
38696
|
+
throw new N(44);
|
|
38697
|
+
b.nb ?? (b.nb = true);
|
|
38698
|
+
a.charAt(0) === "/" || (a = "//" + a);
|
|
38699
|
+
var c = 0;
|
|
38700
|
+
a:
|
|
38701
|
+
for (;40 > c; c++) {
|
|
38702
|
+
a = a.split("/").filter((q) => !!q);
|
|
38703
|
+
for (var d = Eb, e2 = "/", h2 = 0;h2 < a.length; h2++) {
|
|
38704
|
+
var k = h2 === a.length - 1;
|
|
38705
|
+
if (k && b.parent)
|
|
38706
|
+
break;
|
|
38707
|
+
if (a[h2] !== ".")
|
|
38708
|
+
if (a[h2] === "..")
|
|
38709
|
+
e2 = fb(e2), d = d.parent;
|
|
38710
|
+
else {
|
|
38711
|
+
e2 = ka(e2 + "/" + a[h2]);
|
|
38712
|
+
try {
|
|
38713
|
+
d = Q(d, a[h2]);
|
|
38714
|
+
} catch (q) {
|
|
38715
|
+
if (q?.Pa === 44 && k && b.Jb)
|
|
38716
|
+
return { path: e2 };
|
|
38717
|
+
throw q;
|
|
38718
|
+
}
|
|
38719
|
+
!d.ab || k && !b.nb || (d = d.ab.root);
|
|
38720
|
+
if ((d.mode & 61440) === 40960 && (!k || b.$a)) {
|
|
38721
|
+
if (!d.La.readlink)
|
|
38722
|
+
throw new N(52);
|
|
38723
|
+
d = d.La.readlink(d);
|
|
38724
|
+
d.charAt(0) === "/" || (d = fb(e2) + "/" + d);
|
|
38725
|
+
a = d + "/" + a.slice(h2 + 1).join("/");
|
|
38726
|
+
continue a;
|
|
38727
|
+
}
|
|
38728
|
+
}
|
|
38729
|
+
}
|
|
38730
|
+
return { path: e2, node: d };
|
|
38731
|
+
}
|
|
38732
|
+
throw new N(32);
|
|
38733
|
+
}
|
|
38734
|
+
function ja(a) {
|
|
38735
|
+
for (var b;; ) {
|
|
38736
|
+
if (a === a.parent)
|
|
38737
|
+
return a = a.Xa.zb, b ? a[a.length - 1] !== "/" ? `${a}/${b}` : a + b : a;
|
|
38738
|
+
b = b ? `${a.name}/${b}` : a.name;
|
|
38739
|
+
a = a.parent;
|
|
38740
|
+
}
|
|
38741
|
+
}
|
|
38742
|
+
function Nb(a, b) {
|
|
38743
|
+
for (var c = 0, d = 0;d < b.length; d++)
|
|
38744
|
+
c = (c << 5) - c + b.charCodeAt(d) | 0;
|
|
38745
|
+
return (a + c >>> 0) % R.length;
|
|
38746
|
+
}
|
|
38747
|
+
function Cb(a) {
|
|
38748
|
+
var b = Nb(a.parent.id, a.name);
|
|
38749
|
+
if (R[b] === a)
|
|
38750
|
+
R[b] = a.bb;
|
|
38751
|
+
else
|
|
38752
|
+
for (b = R[b];b; ) {
|
|
38753
|
+
if (b.bb === a) {
|
|
38754
|
+
b.bb = a.bb;
|
|
38755
|
+
break;
|
|
38756
|
+
}
|
|
38757
|
+
b = b.bb;
|
|
38758
|
+
}
|
|
38759
|
+
}
|
|
38760
|
+
function Q(a, b) {
|
|
38761
|
+
var c = P(a.mode) ? (c = Ob(a, "x")) ? c : a.La.lookup ? 0 : 2 : 54;
|
|
38762
|
+
if (c)
|
|
38763
|
+
throw new N(c);
|
|
38764
|
+
for (c = R[Nb(a.id, b)];c; c = c.bb) {
|
|
38765
|
+
var d = c.name;
|
|
38766
|
+
if (c.parent.id === a.id && d === b)
|
|
38767
|
+
return c;
|
|
38768
|
+
}
|
|
38769
|
+
return a.La.lookup(a, b);
|
|
38770
|
+
}
|
|
38771
|
+
function Bb(a, b, c, d) {
|
|
38772
|
+
a = new Mb(a, b, c, d);
|
|
38773
|
+
b = Nb(a.parent.id, a.name);
|
|
38774
|
+
a.bb = R[b];
|
|
38775
|
+
return R[b] = a;
|
|
38776
|
+
}
|
|
38777
|
+
function P(a) {
|
|
38778
|
+
return (a & 61440) === 16384;
|
|
38779
|
+
}
|
|
38780
|
+
function Pb(a) {
|
|
38781
|
+
var b = ["r", "w", "rw"][a & 3];
|
|
38782
|
+
a & 512 && (b += "w");
|
|
38783
|
+
return b;
|
|
38784
|
+
}
|
|
38785
|
+
function Ob(a, b) {
|
|
38786
|
+
if (Jb)
|
|
38787
|
+
return 0;
|
|
38788
|
+
if (!b.includes("r") || a.mode & 292) {
|
|
38789
|
+
if (b.includes("w") && !(a.mode & 146) || b.includes("x") && !(a.mode & 73))
|
|
38790
|
+
return 2;
|
|
38791
|
+
} else
|
|
38792
|
+
return 2;
|
|
38793
|
+
return 0;
|
|
38794
|
+
}
|
|
38795
|
+
function Qb(a, b) {
|
|
38796
|
+
if (!P(a.mode))
|
|
38797
|
+
return 54;
|
|
38798
|
+
try {
|
|
38799
|
+
return Q(a, b), 20;
|
|
38800
|
+
} catch (c) {}
|
|
38801
|
+
return Ob(a, "wx");
|
|
38802
|
+
}
|
|
38803
|
+
function Rb(a, b, c) {
|
|
38804
|
+
try {
|
|
38805
|
+
var d = Q(a, b);
|
|
38806
|
+
} catch (e2) {
|
|
38807
|
+
return e2.Pa;
|
|
38808
|
+
}
|
|
38809
|
+
if (a = Ob(a, "wx"))
|
|
38810
|
+
return a;
|
|
38811
|
+
if (c) {
|
|
38812
|
+
if (!P(d.mode))
|
|
38813
|
+
return 54;
|
|
38814
|
+
if (d === d.parent || ja(d) === "/")
|
|
38815
|
+
return 10;
|
|
38816
|
+
} else if (P(d.mode))
|
|
38817
|
+
return 31;
|
|
38818
|
+
return 0;
|
|
38819
|
+
}
|
|
38820
|
+
function Sb(a) {
|
|
38821
|
+
if (!a)
|
|
38822
|
+
throw new N(63);
|
|
38823
|
+
return a;
|
|
38824
|
+
}
|
|
38825
|
+
function T(a) {
|
|
38826
|
+
a = Gb[a];
|
|
38827
|
+
if (!a)
|
|
38828
|
+
throw new N(8);
|
|
38829
|
+
return a;
|
|
38830
|
+
}
|
|
38831
|
+
function Tb(a, b = -1) {
|
|
38832
|
+
a = Object.assign(new Lb, a);
|
|
38833
|
+
if (b == -1)
|
|
38834
|
+
a: {
|
|
38835
|
+
for (b = 0;4096 >= b; b++)
|
|
38836
|
+
if (!Gb[b])
|
|
38837
|
+
break a;
|
|
38838
|
+
throw new N(33);
|
|
38839
|
+
}
|
|
38840
|
+
a.fd = b;
|
|
38841
|
+
return Gb[b] = a;
|
|
38842
|
+
}
|
|
38843
|
+
function Ub(a, b = -1) {
|
|
38844
|
+
a = Tb(a, b);
|
|
38845
|
+
a.Ma?.Rb?.(a);
|
|
38846
|
+
return a;
|
|
38847
|
+
}
|
|
38848
|
+
function Vb(a, b, c) {
|
|
38849
|
+
var d = a?.Ma.Ua;
|
|
38850
|
+
a = d ? a : b;
|
|
38851
|
+
d ??= b.La.Ua;
|
|
38852
|
+
Sb(d);
|
|
38853
|
+
d(a, c);
|
|
38854
|
+
}
|
|
38855
|
+
var Ab = { open(a) {
|
|
38856
|
+
a.Ma = Fb[a.node.rdev].Ma;
|
|
38857
|
+
a.Ma.open?.(a);
|
|
38858
|
+
}, Va() {
|
|
38859
|
+
throw new N(70);
|
|
38860
|
+
} };
|
|
38861
|
+
function wb(a, b) {
|
|
38862
|
+
Fb[a] = { Ma: b };
|
|
38863
|
+
}
|
|
38864
|
+
function Wb(a, b) {
|
|
38865
|
+
var c = b === "/";
|
|
38866
|
+
if (c && Eb)
|
|
38867
|
+
throw new N(10);
|
|
38868
|
+
if (!c && b) {
|
|
38869
|
+
var d = S2(b, { nb: false });
|
|
38870
|
+
b = d.path;
|
|
38871
|
+
d = d.node;
|
|
38872
|
+
if (d.ab)
|
|
38873
|
+
throw new N(10);
|
|
38874
|
+
if (!P(d.mode))
|
|
38875
|
+
throw new N(54);
|
|
38876
|
+
}
|
|
38877
|
+
b = { type: a, Wb: {}, zb: b, Ib: [] };
|
|
38878
|
+
a = a.Xa(b);
|
|
38879
|
+
a.Xa = b;
|
|
38880
|
+
b.root = a;
|
|
38881
|
+
c ? Eb = a : d && (d.ab = b, d.Xa && d.Xa.Ib.push(b));
|
|
38882
|
+
}
|
|
38883
|
+
function Xb(a, b, c) {
|
|
38884
|
+
var d = S2(a, { parent: true }).node;
|
|
38885
|
+
a = gb(a);
|
|
38886
|
+
if (!a)
|
|
38887
|
+
throw new N(28);
|
|
38888
|
+
if (a === "." || a === "..")
|
|
38889
|
+
throw new N(20);
|
|
38890
|
+
var e2 = Qb(d, a);
|
|
38891
|
+
if (e2)
|
|
38892
|
+
throw new N(e2);
|
|
38893
|
+
if (!d.La.hb)
|
|
38894
|
+
throw new N(63);
|
|
38895
|
+
return d.La.hb(d, a, b, c);
|
|
38896
|
+
}
|
|
38897
|
+
function ma(a, b = 438) {
|
|
38898
|
+
return Xb(a, b & 4095 | 32768, 0);
|
|
38899
|
+
}
|
|
38900
|
+
function U(a, b = 511) {
|
|
38901
|
+
return Xb(a, b & 1023 | 16384, 0);
|
|
38902
|
+
}
|
|
38903
|
+
function Yb(a, b, c) {
|
|
38904
|
+
typeof c == "undefined" && (c = b, b = 438);
|
|
38905
|
+
Xb(a, b | 8192, c);
|
|
38906
|
+
}
|
|
38907
|
+
function Zb(a, b) {
|
|
38908
|
+
if (!jb(a))
|
|
38909
|
+
throw new N(44);
|
|
38910
|
+
var c = S2(b, { parent: true }).node;
|
|
38911
|
+
if (!c)
|
|
38912
|
+
throw new N(44);
|
|
38913
|
+
b = gb(b);
|
|
38914
|
+
var d = Qb(c, b);
|
|
38915
|
+
if (d)
|
|
38916
|
+
throw new N(d);
|
|
38917
|
+
if (!c.La.symlink)
|
|
38918
|
+
throw new N(63);
|
|
38919
|
+
c.La.symlink(c, b, a);
|
|
38920
|
+
}
|
|
38921
|
+
function $b(a) {
|
|
38922
|
+
var b = S2(a, { parent: true }).node;
|
|
38923
|
+
a = gb(a);
|
|
38924
|
+
var c = Q(b, a), d = Rb(b, a, true);
|
|
38925
|
+
if (d)
|
|
38926
|
+
throw new N(d);
|
|
38927
|
+
if (!b.La.rmdir)
|
|
38928
|
+
throw new N(63);
|
|
38929
|
+
if (c.ab)
|
|
38930
|
+
throw new N(10);
|
|
38931
|
+
b.La.rmdir(b, a);
|
|
38932
|
+
Cb(c);
|
|
38933
|
+
}
|
|
38934
|
+
function za(a) {
|
|
38935
|
+
var b = S2(a, { parent: true }).node;
|
|
38936
|
+
if (!b)
|
|
38937
|
+
throw new N(44);
|
|
38938
|
+
a = gb(a);
|
|
38939
|
+
var c = Q(b, a), d = Rb(b, a, false);
|
|
38940
|
+
if (d)
|
|
38941
|
+
throw new N(d);
|
|
38942
|
+
if (!b.La.unlink)
|
|
38943
|
+
throw new N(63);
|
|
38944
|
+
if (c.ab)
|
|
38945
|
+
throw new N(10);
|
|
38946
|
+
b.La.unlink(b, a);
|
|
38947
|
+
Cb(c);
|
|
38948
|
+
}
|
|
38949
|
+
function ac(a, b) {
|
|
38950
|
+
a = S2(a, { $a: !b }).node;
|
|
38951
|
+
return Sb(a.La.Ta)(a);
|
|
38952
|
+
}
|
|
38953
|
+
function bc(a, b, c, d) {
|
|
38954
|
+
Vb(a, b, { mode: c & 4095 | b.mode & -4096, ctime: Date.now(), Fb: d });
|
|
38955
|
+
}
|
|
38956
|
+
function na(a, b) {
|
|
38957
|
+
a = typeof a == "string" ? S2(a, { $a: true }).node : a;
|
|
38958
|
+
bc(null, a, b);
|
|
38959
|
+
}
|
|
38960
|
+
function cc(a, b, c) {
|
|
38961
|
+
if (P(b.mode))
|
|
38962
|
+
throw new N(31);
|
|
38963
|
+
if ((b.mode & 61440) !== 32768)
|
|
38964
|
+
throw new N(28);
|
|
38965
|
+
var d = Ob(b, "w");
|
|
38966
|
+
if (d)
|
|
38967
|
+
throw new N(d);
|
|
38968
|
+
Vb(a, b, { size: c, timestamp: Date.now() });
|
|
38969
|
+
}
|
|
38970
|
+
function oa(a, b, c = 438) {
|
|
38971
|
+
if (a === "")
|
|
38972
|
+
throw new N(44);
|
|
38973
|
+
if (typeof b == "string") {
|
|
38974
|
+
var d = { r: 0, "r+": 2, w: 577, "w+": 578, a: 1089, "a+": 1090 }[b];
|
|
38975
|
+
if (typeof d == "undefined")
|
|
38976
|
+
throw Error(`Unknown file open mode: ${b}`);
|
|
38977
|
+
b = d;
|
|
38978
|
+
}
|
|
38979
|
+
c = b & 64 ? c & 4095 | 32768 : 0;
|
|
38980
|
+
if (typeof a == "object")
|
|
38981
|
+
d = a;
|
|
38982
|
+
else {
|
|
38983
|
+
var e2 = a.endsWith("/");
|
|
38984
|
+
a = S2(a, { $a: !(b & 131072), Jb: true });
|
|
38985
|
+
d = a.node;
|
|
38986
|
+
a = a.path;
|
|
38987
|
+
}
|
|
38988
|
+
var h2 = false;
|
|
38989
|
+
if (b & 64)
|
|
38990
|
+
if (d) {
|
|
38991
|
+
if (b & 128)
|
|
38992
|
+
throw new N(20);
|
|
38993
|
+
} else {
|
|
38994
|
+
if (e2)
|
|
38995
|
+
throw new N(31);
|
|
38996
|
+
d = Xb(a, c | 511, 0);
|
|
38997
|
+
h2 = true;
|
|
38998
|
+
}
|
|
38999
|
+
if (!d)
|
|
39000
|
+
throw new N(44);
|
|
39001
|
+
(d.mode & 61440) === 8192 && (b &= -513);
|
|
39002
|
+
if (b & 65536 && !P(d.mode))
|
|
39003
|
+
throw new N(54);
|
|
39004
|
+
if (!h2 && (e2 = d ? (d.mode & 61440) === 40960 ? 32 : P(d.mode) && (Pb(b) !== "r" || b & 576) ? 31 : Ob(d, Pb(b)) : 44))
|
|
39005
|
+
throw new N(e2);
|
|
39006
|
+
b & 512 && !h2 && (e2 = d, e2 = typeof e2 == "string" ? S2(e2, { $a: true }).node : e2, cc(null, e2, 0));
|
|
39007
|
+
b &= -131713;
|
|
39008
|
+
e2 = Tb({ node: d, path: ja(d), flags: b, seekable: true, position: 0, Ma: d.Ma, Lb: [], error: false });
|
|
39009
|
+
e2.Ma.open && e2.Ma.open(e2);
|
|
39010
|
+
h2 && na(d, c & 511);
|
|
39011
|
+
!f3.logReadFiles || b & 1 || a in Kb || (Kb[a] = 1);
|
|
39012
|
+
return e2;
|
|
39013
|
+
}
|
|
39014
|
+
function qa(a) {
|
|
39015
|
+
if (a.fd === null)
|
|
39016
|
+
throw new N(8);
|
|
39017
|
+
a.ob && (a.ob = null);
|
|
39018
|
+
try {
|
|
39019
|
+
a.Ma.close && a.Ma.close(a);
|
|
39020
|
+
} catch (b) {
|
|
39021
|
+
throw b;
|
|
39022
|
+
} finally {
|
|
39023
|
+
Gb[a.fd] = null;
|
|
39024
|
+
}
|
|
39025
|
+
a.fd = null;
|
|
39026
|
+
}
|
|
39027
|
+
function mc(a, b, c) {
|
|
39028
|
+
if (a.fd === null)
|
|
39029
|
+
throw new N(8);
|
|
39030
|
+
if (!a.seekable || !a.Ma.Va)
|
|
39031
|
+
throw new N(70);
|
|
39032
|
+
if (c != 0 && c != 1 && c != 2)
|
|
39033
|
+
throw new N(28);
|
|
39034
|
+
a.position = a.Ma.Va(a, b, c);
|
|
39035
|
+
a.Lb = [];
|
|
39036
|
+
}
|
|
39037
|
+
function Ec(a, b, c, d, e2) {
|
|
39038
|
+
if (0 > d || 0 > e2)
|
|
39039
|
+
throw new N(28);
|
|
39040
|
+
if (a.fd === null)
|
|
39041
|
+
throw new N(8);
|
|
39042
|
+
if ((a.flags & 2097155) === 1)
|
|
39043
|
+
throw new N(8);
|
|
39044
|
+
if (P(a.node.mode))
|
|
39045
|
+
throw new N(31);
|
|
39046
|
+
if (!a.Ma.read)
|
|
39047
|
+
throw new N(28);
|
|
39048
|
+
var h2 = typeof e2 != "undefined";
|
|
39049
|
+
if (!h2)
|
|
39050
|
+
e2 = a.position;
|
|
39051
|
+
else if (!a.seekable)
|
|
39052
|
+
throw new N(70);
|
|
39053
|
+
b = a.Ma.read(a, b, c, d, e2);
|
|
39054
|
+
h2 || (a.position += b);
|
|
39055
|
+
return b;
|
|
39056
|
+
}
|
|
39057
|
+
function pa(a, b, c, d, e2) {
|
|
39058
|
+
if (0 > d || 0 > e2)
|
|
39059
|
+
throw new N(28);
|
|
39060
|
+
if (a.fd === null)
|
|
39061
|
+
throw new N(8);
|
|
39062
|
+
if ((a.flags & 2097155) === 0)
|
|
39063
|
+
throw new N(8);
|
|
39064
|
+
if (P(a.node.mode))
|
|
39065
|
+
throw new N(31);
|
|
39066
|
+
if (!a.Ma.write)
|
|
39067
|
+
throw new N(28);
|
|
39068
|
+
a.seekable && a.flags & 1024 && mc(a, 0, 2);
|
|
39069
|
+
var h2 = typeof e2 != "undefined";
|
|
39070
|
+
if (!h2)
|
|
39071
|
+
e2 = a.position;
|
|
39072
|
+
else if (!a.seekable)
|
|
39073
|
+
throw new N(70);
|
|
39074
|
+
b = a.Ma.write(a, b, c, d, e2, undefined);
|
|
39075
|
+
h2 || (a.position += b);
|
|
39076
|
+
return b;
|
|
39077
|
+
}
|
|
39078
|
+
function ya(a) {
|
|
39079
|
+
var b = "binary";
|
|
39080
|
+
if (b !== "utf8" && b !== "binary")
|
|
39081
|
+
throw Error(`Invalid encoding type "${b}"`);
|
|
39082
|
+
var c;
|
|
39083
|
+
var d = oa(a, d || 0);
|
|
39084
|
+
a = ac(a).size;
|
|
39085
|
+
var e2 = new Uint8Array(a);
|
|
39086
|
+
Ec(d, e2, 0, a, 0);
|
|
39087
|
+
b === "utf8" ? c = B(e2) : b === "binary" && (c = e2);
|
|
39088
|
+
qa(d);
|
|
39089
|
+
return c;
|
|
39090
|
+
}
|
|
39091
|
+
function V(a, b, c) {
|
|
39092
|
+
a = ka("/dev/" + a);
|
|
39093
|
+
var d = la(!!b, !!c);
|
|
39094
|
+
V.yb ?? (V.yb = 64);
|
|
39095
|
+
var e2 = V.yb++ << 8 | 0;
|
|
39096
|
+
wb(e2, { open(h2) {
|
|
39097
|
+
h2.seekable = false;
|
|
39098
|
+
}, close() {
|
|
39099
|
+
c?.buffer?.length && c(10);
|
|
39100
|
+
}, read(h2, k, q, w) {
|
|
39101
|
+
for (var v = 0, C = 0;C < w; C++) {
|
|
39102
|
+
try {
|
|
39103
|
+
var G = b();
|
|
39104
|
+
} catch (pb) {
|
|
39105
|
+
throw new N(29);
|
|
39106
|
+
}
|
|
39107
|
+
if (G === undefined && v === 0)
|
|
39108
|
+
throw new N(6);
|
|
39109
|
+
if (G === null || G === undefined)
|
|
39110
|
+
break;
|
|
39111
|
+
v++;
|
|
39112
|
+
k[q + C] = G;
|
|
39113
|
+
}
|
|
39114
|
+
v && (h2.node.atime = Date.now());
|
|
39115
|
+
return v;
|
|
39116
|
+
}, write(h2, k, q, w) {
|
|
39117
|
+
for (var v = 0;v < w; v++)
|
|
39118
|
+
try {
|
|
39119
|
+
c(k[q + v]);
|
|
39120
|
+
} catch (C) {
|
|
39121
|
+
throw new N(29);
|
|
39122
|
+
}
|
|
39123
|
+
w && (h2.node.mtime = h2.node.ctime = Date.now());
|
|
39124
|
+
return v;
|
|
39125
|
+
} });
|
|
39126
|
+
Yb(a, d, e2);
|
|
39127
|
+
}
|
|
39128
|
+
var W = {};
|
|
39129
|
+
function Gc(a, b, c) {
|
|
39130
|
+
if (b.charAt(0) === "/")
|
|
39131
|
+
return b;
|
|
39132
|
+
a = a === -100 ? "/" : T(a).path;
|
|
39133
|
+
if (b.length == 0) {
|
|
39134
|
+
if (!c)
|
|
39135
|
+
throw new N(44);
|
|
39136
|
+
return a;
|
|
39137
|
+
}
|
|
39138
|
+
return a + "/" + b;
|
|
39139
|
+
}
|
|
39140
|
+
function Hc(a, b) {
|
|
39141
|
+
E[a >> 2] = b.dev;
|
|
39142
|
+
E[a + 4 >> 2] = b.mode;
|
|
39143
|
+
F2[a + 8 >> 2] = b.nlink;
|
|
39144
|
+
E[a + 12 >> 2] = b.uid;
|
|
39145
|
+
E[a + 16 >> 2] = b.gid;
|
|
39146
|
+
E[a + 20 >> 2] = b.rdev;
|
|
39147
|
+
H[a + 24 >> 3] = BigInt(b.size);
|
|
39148
|
+
E[a + 32 >> 2] = 4096;
|
|
39149
|
+
E[a + 36 >> 2] = b.blocks;
|
|
39150
|
+
var c = b.atime.getTime(), d = b.mtime.getTime(), e2 = b.ctime.getTime();
|
|
39151
|
+
H[a + 40 >> 3] = BigInt(Math.floor(c / 1000));
|
|
39152
|
+
F2[a + 48 >> 2] = c % 1000 * 1e6;
|
|
39153
|
+
H[a + 56 >> 3] = BigInt(Math.floor(d / 1000));
|
|
39154
|
+
F2[a + 64 >> 2] = d % 1000 * 1e6;
|
|
39155
|
+
H[a + 72 >> 3] = BigInt(Math.floor(e2 / 1000));
|
|
39156
|
+
F2[a + 80 >> 2] = e2 % 1000 * 1e6;
|
|
39157
|
+
H[a + 88 >> 3] = BigInt(b.ino);
|
|
39158
|
+
return 0;
|
|
39159
|
+
}
|
|
39160
|
+
var Ic = undefined, Jc = () => {
|
|
39161
|
+
var a = E[+Ic >> 2];
|
|
39162
|
+
Ic += 4;
|
|
39163
|
+
return a;
|
|
39164
|
+
}, Kc = 0, Lc = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335], Mc = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334], Nc = {}, Oc = (a) => {
|
|
39165
|
+
Ma = a;
|
|
39166
|
+
cb || 0 < Kc || (f3.onExit?.(a), La = true);
|
|
39167
|
+
Da(a, new Ya(a));
|
|
39168
|
+
}, Pc = (a) => {
|
|
39169
|
+
if (!La)
|
|
39170
|
+
try {
|
|
39171
|
+
if (a(), !(cb || 0 < Kc))
|
|
39172
|
+
try {
|
|
39173
|
+
Ma = a = Ma, Oc(a);
|
|
39174
|
+
} catch (b) {
|
|
39175
|
+
b instanceof Ya || b == "unwind" || Da(1, b);
|
|
39176
|
+
}
|
|
39177
|
+
} catch (b) {
|
|
39178
|
+
b instanceof Ya || b == "unwind" || Da(1, b);
|
|
39179
|
+
}
|
|
39180
|
+
}, Qc = {}, Sc = () => {
|
|
39181
|
+
if (!Rc) {
|
|
39182
|
+
var a = { USER: "web_user", LOGNAME: "web_user", PATH: "/", PWD: "/", HOME: "/home/web_user", LANG: (typeof navigator == "object" && navigator.languages && navigator.languages[0] || "C").replace("-", "_") + ".UTF-8", _: Ca || "./this.program" }, b;
|
|
39183
|
+
for (b in Qc)
|
|
39184
|
+
Qc[b] === undefined ? delete a[b] : a[b] = Qc[b];
|
|
39185
|
+
var c = [];
|
|
39186
|
+
for (b in a)
|
|
39187
|
+
c.push(`${b}=${a[b]}`);
|
|
39188
|
+
Rc = c;
|
|
39189
|
+
}
|
|
39190
|
+
return Rc;
|
|
39191
|
+
}, Rc, xa = (a) => {
|
|
39192
|
+
var b = ha(a) + 1, c = z2(b);
|
|
39193
|
+
u(a, x2, c, b);
|
|
39194
|
+
return c;
|
|
39195
|
+
}, Tc = (a, b, c, d) => {
|
|
39196
|
+
var e2 = { string: (v) => {
|
|
39197
|
+
var C = 0;
|
|
39198
|
+
v !== null && v !== undefined && v !== 0 && (C = xa(v));
|
|
39199
|
+
return C;
|
|
39200
|
+
}, array: (v) => {
|
|
39201
|
+
var C = z2(v.length);
|
|
39202
|
+
p.set(v, C);
|
|
39203
|
+
return C;
|
|
39204
|
+
} };
|
|
39205
|
+
a = f3["_" + a];
|
|
39206
|
+
var h2 = [], k = 0;
|
|
39207
|
+
if (d)
|
|
39208
|
+
for (var q = 0;q < d.length; q++) {
|
|
39209
|
+
var w = e2[c[q]];
|
|
39210
|
+
w ? (k === 0 && (k = sa()), h2[q] = w(d[q])) : h2[q] = d[q];
|
|
39211
|
+
}
|
|
39212
|
+
c = a(...h2);
|
|
39213
|
+
return c = function(v) {
|
|
39214
|
+
k !== 0 && wa(k);
|
|
39215
|
+
return b === "string" ? v ? B(x2, v) : "" : b === "boolean" ? !!v : v;
|
|
39216
|
+
}(c);
|
|
39217
|
+
}, ea = 0, da = (a, b) => {
|
|
39218
|
+
b = b == 1 ? z2(a.length) : ia(a.length);
|
|
39219
|
+
a.subarray || a.slice || (a = new Uint8Array(a));
|
|
39220
|
+
x2.set(a, b);
|
|
39221
|
+
return b;
|
|
39222
|
+
}, Uc, Vc = [], Y, A2 = (a) => {
|
|
39223
|
+
Uc.delete(Y.get(a));
|
|
39224
|
+
Y.set(a, null);
|
|
39225
|
+
Vc.push(a);
|
|
39226
|
+
}, Aa = (a, b) => {
|
|
39227
|
+
if (!Uc) {
|
|
39228
|
+
Uc = new WeakMap;
|
|
39229
|
+
var c = Y.length;
|
|
39230
|
+
if (Uc)
|
|
39231
|
+
for (var d = 0;d < 0 + c; d++) {
|
|
39232
|
+
var e2 = Y.get(d);
|
|
39233
|
+
e2 && Uc.set(e2, d);
|
|
39234
|
+
}
|
|
39235
|
+
}
|
|
39236
|
+
if (c = Uc.get(a) || 0)
|
|
39237
|
+
return c;
|
|
39238
|
+
if (Vc.length)
|
|
39239
|
+
c = Vc.pop();
|
|
39240
|
+
else {
|
|
39241
|
+
try {
|
|
39242
|
+
Y.grow(1);
|
|
39243
|
+
} catch (w) {
|
|
39244
|
+
if (!(w instanceof RangeError))
|
|
39245
|
+
throw w;
|
|
39246
|
+
throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";
|
|
39247
|
+
}
|
|
39248
|
+
c = Y.length - 1;
|
|
39249
|
+
}
|
|
39250
|
+
try {
|
|
39251
|
+
Y.set(c, a);
|
|
39252
|
+
} catch (w) {
|
|
39253
|
+
if (!(w instanceof TypeError))
|
|
39254
|
+
throw w;
|
|
39255
|
+
if (typeof WebAssembly.Function == "function") {
|
|
39256
|
+
var h2 = WebAssembly.Function;
|
|
39257
|
+
d = { i: "i32", j: "i64", f: "f32", d: "f64", e: "externref", p: "i32" };
|
|
39258
|
+
e2 = { parameters: [], results: b[0] == "v" ? [] : [d[b[0]]] };
|
|
39259
|
+
for (var k = 1;k < b.length; ++k)
|
|
39260
|
+
e2.parameters.push(d[b[k]]);
|
|
39261
|
+
b = new h2(e2, a);
|
|
39262
|
+
} else {
|
|
39263
|
+
d = [1];
|
|
39264
|
+
e2 = b.slice(0, 1);
|
|
39265
|
+
b = b.slice(1);
|
|
39266
|
+
k = { i: 127, p: 127, j: 126, f: 125, d: 124, e: 111 };
|
|
39267
|
+
d.push(96);
|
|
39268
|
+
var q = b.length;
|
|
39269
|
+
128 > q ? d.push(q) : d.push(q % 128 | 128, q >> 7);
|
|
39270
|
+
for (h2 of b)
|
|
39271
|
+
d.push(k[h2]);
|
|
39272
|
+
e2 == "v" ? d.push(0) : d.push(1, k[e2]);
|
|
39273
|
+
b = [0, 97, 115, 109, 1, 0, 0, 0, 1];
|
|
39274
|
+
h2 = d.length;
|
|
39275
|
+
128 > h2 ? b.push(h2) : b.push(h2 % 128 | 128, h2 >> 7);
|
|
39276
|
+
b.push(...d);
|
|
39277
|
+
b.push(2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0);
|
|
39278
|
+
b = new WebAssembly.Module(new Uint8Array(b));
|
|
39279
|
+
b = new WebAssembly.Instance(b, { e: { f: a } }).exports.f;
|
|
39280
|
+
}
|
|
39281
|
+
Y.set(c, b);
|
|
39282
|
+
}
|
|
39283
|
+
Uc.set(a, c);
|
|
39284
|
+
return c;
|
|
39285
|
+
};
|
|
39286
|
+
R = Array(4096);
|
|
39287
|
+
Wb(O, "/");
|
|
39288
|
+
U("/tmp");
|
|
39289
|
+
U("/home");
|
|
39290
|
+
U("/home/web_user");
|
|
39291
|
+
(function() {
|
|
39292
|
+
U("/dev");
|
|
39293
|
+
wb(259, { read: () => 0, write: (d, e2, h2, k) => k, Va: () => 0 });
|
|
39294
|
+
Yb("/dev/null", 259);
|
|
39295
|
+
nb(1280, yb);
|
|
39296
|
+
nb(1536, zb);
|
|
39297
|
+
Yb("/dev/tty", 1280);
|
|
39298
|
+
Yb("/dev/tty1", 1536);
|
|
39299
|
+
var a = new Uint8Array(1024), b = 0, c = () => {
|
|
39300
|
+
b === 0 && (ib(a), b = a.byteLength);
|
|
39301
|
+
return a[--b];
|
|
39302
|
+
};
|
|
39303
|
+
V("random", c);
|
|
39304
|
+
V("urandom", c);
|
|
39305
|
+
U("/dev/shm");
|
|
39306
|
+
U("/dev/shm/tmp");
|
|
39307
|
+
})();
|
|
39308
|
+
(function() {
|
|
39309
|
+
U("/proc");
|
|
39310
|
+
var a = U("/proc/self");
|
|
39311
|
+
U("/proc/self/fd");
|
|
39312
|
+
Wb({ Xa() {
|
|
39313
|
+
var b = Bb(a, "fd", 16895, 73);
|
|
39314
|
+
b.Ma = { Va: O.Ma.Va };
|
|
39315
|
+
b.La = { lookup(c, d) {
|
|
39316
|
+
c = +d;
|
|
39317
|
+
var e2 = T(c);
|
|
39318
|
+
c = { parent: null, Xa: { zb: "fake" }, La: { readlink: () => e2.path }, id: c + 1 };
|
|
39319
|
+
return c.parent = c;
|
|
39320
|
+
}, readdir() {
|
|
39321
|
+
return Array.from(Gb.entries()).filter(([, c]) => c).map(([c]) => c.toString());
|
|
39322
|
+
} };
|
|
39323
|
+
return b;
|
|
39324
|
+
} }, "/proc/self/fd");
|
|
39325
|
+
})();
|
|
39326
|
+
O.vb = new N(44);
|
|
39327
|
+
O.vb.stack = "<generic error, no stack>";
|
|
39328
|
+
var Xc = { a: (a, b, c, d) => Ta(`Assertion failed: ${a ? B(x2, a) : ""}, at: ` + [b ? b ? B(x2, b) : "" : "unknown filename", c, d ? d ? B(x2, d) : "" : "unknown function"]), i: function(a, b) {
|
|
39329
|
+
try {
|
|
39330
|
+
return a = a ? B(x2, a) : "", na(a, b), 0;
|
|
39331
|
+
} catch (c) {
|
|
39332
|
+
if (typeof W == "undefined" || c.name !== "ErrnoError")
|
|
39333
|
+
throw c;
|
|
39334
|
+
return -c.Pa;
|
|
39335
|
+
}
|
|
39336
|
+
}, L: function(a, b, c) {
|
|
39337
|
+
try {
|
|
39338
|
+
b = b ? B(x2, b) : "";
|
|
39339
|
+
b = Gc(a, b);
|
|
39340
|
+
if (c & -8)
|
|
39341
|
+
return -28;
|
|
39342
|
+
var d = S2(b, { $a: true }).node;
|
|
39343
|
+
if (!d)
|
|
39344
|
+
return -44;
|
|
39345
|
+
a = "";
|
|
39346
|
+
c & 4 && (a += "r");
|
|
39347
|
+
c & 2 && (a += "w");
|
|
39348
|
+
c & 1 && (a += "x");
|
|
39349
|
+
return a && Ob(d, a) ? -2 : 0;
|
|
39350
|
+
} catch (e2) {
|
|
39351
|
+
if (typeof W == "undefined" || e2.name !== "ErrnoError")
|
|
39352
|
+
throw e2;
|
|
39353
|
+
return -e2.Pa;
|
|
39354
|
+
}
|
|
39355
|
+
}, j: function(a, b) {
|
|
39356
|
+
try {
|
|
39357
|
+
var c = T(a);
|
|
39358
|
+
bc(c, c.node, b, false);
|
|
39359
|
+
return 0;
|
|
39360
|
+
} catch (d) {
|
|
39361
|
+
if (typeof W == "undefined" || d.name !== "ErrnoError")
|
|
39362
|
+
throw d;
|
|
39363
|
+
return -d.Pa;
|
|
39364
|
+
}
|
|
39365
|
+
}, h: function(a) {
|
|
39366
|
+
try {
|
|
39367
|
+
var b = T(a);
|
|
39368
|
+
Vb(b, b.node, { timestamp: Date.now(), Fb: false });
|
|
39369
|
+
return 0;
|
|
39370
|
+
} catch (c) {
|
|
39371
|
+
if (typeof W == "undefined" || c.name !== "ErrnoError")
|
|
39372
|
+
throw c;
|
|
39373
|
+
return -c.Pa;
|
|
39374
|
+
}
|
|
39375
|
+
}, b: function(a, b, c) {
|
|
39376
|
+
Ic = c;
|
|
39377
|
+
try {
|
|
39378
|
+
var d = T(a);
|
|
39379
|
+
switch (b) {
|
|
39380
|
+
case 0:
|
|
39381
|
+
var e2 = Jc();
|
|
39382
|
+
if (0 > e2)
|
|
39383
|
+
break;
|
|
39384
|
+
for (;Gb[e2]; )
|
|
39385
|
+
e2++;
|
|
39386
|
+
return Ub(d, e2).fd;
|
|
39387
|
+
case 1:
|
|
39388
|
+
case 2:
|
|
39389
|
+
return 0;
|
|
39390
|
+
case 3:
|
|
39391
|
+
return d.flags;
|
|
39392
|
+
case 4:
|
|
39393
|
+
return e2 = Jc(), d.flags |= e2, 0;
|
|
39394
|
+
case 12:
|
|
39395
|
+
return e2 = Jc(), Na[e2 + 0 >> 1] = 2, 0;
|
|
39396
|
+
case 13:
|
|
39397
|
+
case 14:
|
|
39398
|
+
return 0;
|
|
39399
|
+
}
|
|
39400
|
+
return -28;
|
|
39401
|
+
} catch (h2) {
|
|
39402
|
+
if (typeof W == "undefined" || h2.name !== "ErrnoError")
|
|
39403
|
+
throw h2;
|
|
39404
|
+
return -h2.Pa;
|
|
39405
|
+
}
|
|
39406
|
+
}, g: function(a, b) {
|
|
39407
|
+
try {
|
|
39408
|
+
var c = T(a), d = c.node, e2 = c.Ma.Ta;
|
|
39409
|
+
a = e2 ? c : d;
|
|
39410
|
+
e2 ??= d.La.Ta;
|
|
39411
|
+
Sb(e2);
|
|
39412
|
+
var h2 = e2(a);
|
|
39413
|
+
return Hc(b, h2);
|
|
39414
|
+
} catch (k) {
|
|
39415
|
+
if (typeof W == "undefined" || k.name !== "ErrnoError")
|
|
39416
|
+
throw k;
|
|
39417
|
+
return -k.Pa;
|
|
39418
|
+
}
|
|
39419
|
+
}, H: function(a, b) {
|
|
39420
|
+
b = -9007199254740992 > b || 9007199254740992 < b ? NaN : Number(b);
|
|
39421
|
+
try {
|
|
39422
|
+
if (isNaN(b))
|
|
39423
|
+
return 61;
|
|
39424
|
+
var c = T(a);
|
|
39425
|
+
if (0 > b || (c.flags & 2097155) === 0)
|
|
39426
|
+
throw new N(28);
|
|
39427
|
+
cc(c, c.node, b);
|
|
39428
|
+
return 0;
|
|
39429
|
+
} catch (d) {
|
|
39430
|
+
if (typeof W == "undefined" || d.name !== "ErrnoError")
|
|
39431
|
+
throw d;
|
|
39432
|
+
return -d.Pa;
|
|
39433
|
+
}
|
|
39434
|
+
}, G: function(a, b) {
|
|
39435
|
+
try {
|
|
39436
|
+
if (b === 0)
|
|
39437
|
+
return -28;
|
|
39438
|
+
var c = ha("/") + 1;
|
|
39439
|
+
if (b < c)
|
|
39440
|
+
return -68;
|
|
39441
|
+
u("/", x2, a, b);
|
|
39442
|
+
return c;
|
|
39443
|
+
} catch (d) {
|
|
39444
|
+
if (typeof W == "undefined" || d.name !== "ErrnoError")
|
|
39445
|
+
throw d;
|
|
39446
|
+
return -d.Pa;
|
|
39447
|
+
}
|
|
39448
|
+
}, K: function(a, b) {
|
|
39449
|
+
try {
|
|
39450
|
+
return a = a ? B(x2, a) : "", Hc(b, ac(a, true));
|
|
39451
|
+
} catch (c) {
|
|
39452
|
+
if (typeof W == "undefined" || c.name !== "ErrnoError")
|
|
39453
|
+
throw c;
|
|
39454
|
+
return -c.Pa;
|
|
39455
|
+
}
|
|
39456
|
+
}, C: function(a, b, c) {
|
|
39457
|
+
try {
|
|
39458
|
+
return b = b ? B(x2, b) : "", b = Gc(a, b), U(b, c), 0;
|
|
39459
|
+
} catch (d) {
|
|
39460
|
+
if (typeof W == "undefined" || d.name !== "ErrnoError")
|
|
39461
|
+
throw d;
|
|
39462
|
+
return -d.Pa;
|
|
39463
|
+
}
|
|
39464
|
+
}, J: function(a, b, c, d) {
|
|
39465
|
+
try {
|
|
39466
|
+
b = b ? B(x2, b) : "";
|
|
39467
|
+
var e2 = d & 256;
|
|
39468
|
+
b = Gc(a, b, d & 4096);
|
|
39469
|
+
return Hc(c, e2 ? ac(b, true) : ac(b));
|
|
39470
|
+
} catch (h2) {
|
|
39471
|
+
if (typeof W == "undefined" || h2.name !== "ErrnoError")
|
|
39472
|
+
throw h2;
|
|
39473
|
+
return -h2.Pa;
|
|
39474
|
+
}
|
|
39475
|
+
}, x: function(a, b, c, d) {
|
|
39476
|
+
Ic = d;
|
|
39477
|
+
try {
|
|
39478
|
+
b = b ? B(x2, b) : "";
|
|
39479
|
+
b = Gc(a, b);
|
|
39480
|
+
var e2 = d ? Jc() : 0;
|
|
39481
|
+
return oa(b, c, e2).fd;
|
|
39482
|
+
} catch (h2) {
|
|
39483
|
+
if (typeof W == "undefined" || h2.name !== "ErrnoError")
|
|
39484
|
+
throw h2;
|
|
39485
|
+
return -h2.Pa;
|
|
39486
|
+
}
|
|
39487
|
+
}, v: function(a, b, c, d) {
|
|
39488
|
+
try {
|
|
39489
|
+
b = b ? B(x2, b) : "";
|
|
39490
|
+
b = Gc(a, b);
|
|
39491
|
+
if (0 >= d)
|
|
39492
|
+
return -28;
|
|
39493
|
+
var e2 = S2(b).node;
|
|
39494
|
+
if (!e2)
|
|
39495
|
+
throw new N(44);
|
|
39496
|
+
if (!e2.La.readlink)
|
|
39497
|
+
throw new N(28);
|
|
39498
|
+
var h2 = e2.La.readlink(e2);
|
|
39499
|
+
var k = Math.min(d, ha(h2)), q = p[c + k];
|
|
39500
|
+
u(h2, x2, c, d + 1);
|
|
39501
|
+
p[c + k] = q;
|
|
39502
|
+
return k;
|
|
39503
|
+
} catch (w) {
|
|
39504
|
+
if (typeof W == "undefined" || w.name !== "ErrnoError")
|
|
39505
|
+
throw w;
|
|
39506
|
+
return -w.Pa;
|
|
39507
|
+
}
|
|
39508
|
+
}, u: function(a) {
|
|
39509
|
+
try {
|
|
39510
|
+
return a = a ? B(x2, a) : "", $b(a), 0;
|
|
39511
|
+
} catch (b) {
|
|
39512
|
+
if (typeof W == "undefined" || b.name !== "ErrnoError")
|
|
39513
|
+
throw b;
|
|
39514
|
+
return -b.Pa;
|
|
39515
|
+
}
|
|
39516
|
+
}, f: function(a, b) {
|
|
39517
|
+
try {
|
|
39518
|
+
return a = a ? B(x2, a) : "", Hc(b, ac(a));
|
|
39519
|
+
} catch (c) {
|
|
39520
|
+
if (typeof W == "undefined" || c.name !== "ErrnoError")
|
|
39521
|
+
throw c;
|
|
39522
|
+
return -c.Pa;
|
|
39523
|
+
}
|
|
39524
|
+
}, r: function(a, b, c) {
|
|
39525
|
+
try {
|
|
39526
|
+
return b = b ? B(x2, b) : "", b = Gc(a, b), c === 0 ? za(b) : c === 512 ? $b(b) : Ta("Invalid flags passed to unlinkat"), 0;
|
|
39527
|
+
} catch (d) {
|
|
39528
|
+
if (typeof W == "undefined" || d.name !== "ErrnoError")
|
|
39529
|
+
throw d;
|
|
39530
|
+
return -d.Pa;
|
|
39531
|
+
}
|
|
39532
|
+
}, q: function(a, b, c) {
|
|
39533
|
+
try {
|
|
39534
|
+
b = b ? B(x2, b) : "";
|
|
39535
|
+
b = Gc(a, b, true);
|
|
39536
|
+
var d = Date.now(), e2, h2;
|
|
39537
|
+
if (c) {
|
|
39538
|
+
var k = F2[c >> 2] + 4294967296 * E[c + 4 >> 2], q = E[c + 8 >> 2];
|
|
39539
|
+
q == 1073741823 ? e2 = d : q == 1073741822 ? e2 = null : e2 = 1000 * k + q / 1e6;
|
|
39540
|
+
c += 16;
|
|
39541
|
+
k = F2[c >> 2] + 4294967296 * E[c + 4 >> 2];
|
|
39542
|
+
q = E[c + 8 >> 2];
|
|
39543
|
+
q == 1073741823 ? h2 = d : q == 1073741822 ? h2 = null : h2 = 1000 * k + q / 1e6;
|
|
39544
|
+
} else
|
|
39545
|
+
h2 = e2 = d;
|
|
39546
|
+
if ((h2 ?? e2) !== null) {
|
|
39547
|
+
a = e2;
|
|
39548
|
+
var w = S2(b, { $a: true }).node;
|
|
39549
|
+
Sb(w.La.Ua)(w, { atime: a, mtime: h2 });
|
|
39550
|
+
}
|
|
39551
|
+
return 0;
|
|
39552
|
+
} catch (v) {
|
|
39553
|
+
if (typeof W == "undefined" || v.name !== "ErrnoError")
|
|
39554
|
+
throw v;
|
|
39555
|
+
return -v.Pa;
|
|
39556
|
+
}
|
|
39557
|
+
}, m: () => Ta(""), l: () => {
|
|
39558
|
+
cb = false;
|
|
39559
|
+
Kc = 0;
|
|
39560
|
+
}, A: function(a, b) {
|
|
39561
|
+
a = -9007199254740992 > a || 9007199254740992 < a ? NaN : Number(a);
|
|
39562
|
+
a = new Date(1000 * a);
|
|
39563
|
+
E[b >> 2] = a.getSeconds();
|
|
39564
|
+
E[b + 4 >> 2] = a.getMinutes();
|
|
39565
|
+
E[b + 8 >> 2] = a.getHours();
|
|
39566
|
+
E[b + 12 >> 2] = a.getDate();
|
|
39567
|
+
E[b + 16 >> 2] = a.getMonth();
|
|
39568
|
+
E[b + 20 >> 2] = a.getFullYear() - 1900;
|
|
39569
|
+
E[b + 24 >> 2] = a.getDay();
|
|
39570
|
+
var c = a.getFullYear();
|
|
39571
|
+
E[b + 28 >> 2] = (c % 4 !== 0 || c % 100 === 0 && c % 400 !== 0 ? Mc : Lc)[a.getMonth()] + a.getDate() - 1 | 0;
|
|
39572
|
+
E[b + 36 >> 2] = -(60 * a.getTimezoneOffset());
|
|
39573
|
+
c = new Date(a.getFullYear(), 6, 1).getTimezoneOffset();
|
|
39574
|
+
var d = new Date(a.getFullYear(), 0, 1).getTimezoneOffset();
|
|
39575
|
+
E[b + 32 >> 2] = (c != d && a.getTimezoneOffset() == Math.min(d, c)) | 0;
|
|
39576
|
+
}, y: function(a, b, c, d, e2, h2, k) {
|
|
39577
|
+
e2 = -9007199254740992 > e2 || 9007199254740992 < e2 ? NaN : Number(e2);
|
|
39578
|
+
try {
|
|
39579
|
+
if (isNaN(e2))
|
|
39580
|
+
return 61;
|
|
39581
|
+
var q = T(d);
|
|
39582
|
+
if ((b & 2) !== 0 && (c & 2) === 0 && (q.flags & 2097155) !== 2)
|
|
39583
|
+
throw new N(2);
|
|
39584
|
+
if ((q.flags & 2097155) === 1)
|
|
39585
|
+
throw new N(2);
|
|
39586
|
+
if (!q.Ma.ib)
|
|
39587
|
+
throw new N(43);
|
|
39588
|
+
if (!a)
|
|
39589
|
+
throw new N(28);
|
|
39590
|
+
var w = q.Ma.ib(q, a, e2, b, c);
|
|
39591
|
+
var v = w.Kb;
|
|
39592
|
+
E[h2 >> 2] = w.Ab;
|
|
39593
|
+
F2[k >> 2] = v;
|
|
39594
|
+
return 0;
|
|
39595
|
+
} catch (C) {
|
|
39596
|
+
if (typeof W == "undefined" || C.name !== "ErrnoError")
|
|
39597
|
+
throw C;
|
|
39598
|
+
return -C.Pa;
|
|
39599
|
+
}
|
|
39600
|
+
}, z: function(a, b, c, d, e2, h2) {
|
|
39601
|
+
h2 = -9007199254740992 > h2 || 9007199254740992 < h2 ? NaN : Number(h2);
|
|
39602
|
+
try {
|
|
39603
|
+
var k = T(e2);
|
|
39604
|
+
if (c & 2) {
|
|
39605
|
+
c = h2;
|
|
39606
|
+
if ((k.node.mode & 61440) !== 32768)
|
|
39607
|
+
throw new N(43);
|
|
39608
|
+
if (!(d & 2)) {
|
|
39609
|
+
var q = x2.slice(a, a + b);
|
|
39610
|
+
k.Ma.jb && k.Ma.jb(k, q, c, b, d);
|
|
39611
|
+
}
|
|
39612
|
+
}
|
|
39613
|
+
} catch (w) {
|
|
39614
|
+
if (typeof W == "undefined" || w.name !== "ErrnoError")
|
|
39615
|
+
throw w;
|
|
39616
|
+
return -w.Pa;
|
|
39617
|
+
}
|
|
39618
|
+
}, n: (a, b) => {
|
|
39619
|
+
Nc[a] && (clearTimeout(Nc[a].id), delete Nc[a]);
|
|
39620
|
+
if (!b)
|
|
39621
|
+
return 0;
|
|
39622
|
+
var c = setTimeout(() => {
|
|
39623
|
+
delete Nc[a];
|
|
39624
|
+
Pc(() => Wc(a, performance.now()));
|
|
39625
|
+
}, b);
|
|
39626
|
+
Nc[a] = {
|
|
39627
|
+
id: c,
|
|
39628
|
+
Xb: b
|
|
39629
|
+
};
|
|
39630
|
+
return 0;
|
|
39631
|
+
}, B: (a, b, c, d) => {
|
|
39632
|
+
var e2 = new Date().getFullYear(), h2 = new Date(e2, 0, 1).getTimezoneOffset();
|
|
39633
|
+
e2 = new Date(e2, 6, 1).getTimezoneOffset();
|
|
39634
|
+
F2[a >> 2] = 60 * Math.max(h2, e2);
|
|
39635
|
+
E[b >> 2] = Number(h2 != e2);
|
|
39636
|
+
b = (k) => {
|
|
39637
|
+
var q = Math.abs(k);
|
|
39638
|
+
return `UTC${0 <= k ? "-" : "+"}${String(Math.floor(q / 60)).padStart(2, "0")}${String(q % 60).padStart(2, "0")}`;
|
|
39639
|
+
};
|
|
39640
|
+
a = b(h2);
|
|
39641
|
+
b = b(e2);
|
|
39642
|
+
e2 < h2 ? (u(a, x2, c, 17), u(b, x2, d, 17)) : (u(a, x2, d, 17), u(b, x2, c, 17));
|
|
39643
|
+
}, d: () => Date.now(), s: () => 2147483648, c: () => performance.now(), o: (a) => {
|
|
39644
|
+
var b = x2.length;
|
|
39645
|
+
a >>>= 0;
|
|
39646
|
+
if (2147483648 < a)
|
|
39647
|
+
return false;
|
|
39648
|
+
for (var c = 1;4 >= c; c *= 2) {
|
|
39649
|
+
var d = b * (1 + 0.2 / c);
|
|
39650
|
+
d = Math.min(d, a + 100663296);
|
|
39651
|
+
a: {
|
|
39652
|
+
d = (Math.min(2147483648, 65536 * Math.ceil(Math.max(a, d) / 65536)) - Ka.buffer.byteLength + 65535) / 65536 | 0;
|
|
39653
|
+
try {
|
|
39654
|
+
Ka.grow(d);
|
|
39655
|
+
Qa();
|
|
39656
|
+
var e2 = 1;
|
|
39657
|
+
break a;
|
|
39658
|
+
} catch (h2) {}
|
|
39659
|
+
e2 = undefined;
|
|
39660
|
+
}
|
|
39661
|
+
if (e2)
|
|
39662
|
+
return true;
|
|
39663
|
+
}
|
|
39664
|
+
return false;
|
|
39665
|
+
}, E: (a, b) => {
|
|
39666
|
+
var c = 0;
|
|
39667
|
+
Sc().forEach((d, e2) => {
|
|
39668
|
+
var h2 = b + c;
|
|
39669
|
+
e2 = F2[a + 4 * e2 >> 2] = h2;
|
|
39670
|
+
for (h2 = 0;h2 < d.length; ++h2)
|
|
39671
|
+
p[e2++] = d.charCodeAt(h2);
|
|
39672
|
+
p[e2] = 0;
|
|
39673
|
+
c += d.length + 1;
|
|
39674
|
+
});
|
|
39675
|
+
return 0;
|
|
39676
|
+
}, F: (a, b) => {
|
|
39677
|
+
var c = Sc();
|
|
39678
|
+
F2[a >> 2] = c.length;
|
|
39679
|
+
var d = 0;
|
|
39680
|
+
c.forEach((e2) => d += e2.length + 1);
|
|
39681
|
+
F2[b >> 2] = d;
|
|
39682
|
+
return 0;
|
|
39683
|
+
}, e: function(a) {
|
|
39684
|
+
try {
|
|
39685
|
+
var b = T(a);
|
|
39686
|
+
qa(b);
|
|
39687
|
+
return 0;
|
|
39688
|
+
} catch (c) {
|
|
39689
|
+
if (typeof W == "undefined" || c.name !== "ErrnoError")
|
|
39690
|
+
throw c;
|
|
39691
|
+
return c.Pa;
|
|
39692
|
+
}
|
|
39693
|
+
}, p: function(a, b) {
|
|
39694
|
+
try {
|
|
39695
|
+
var c = T(a);
|
|
39696
|
+
p[b] = c.tty ? 2 : P(c.mode) ? 3 : (c.mode & 61440) === 40960 ? 7 : 4;
|
|
39697
|
+
Na[b + 2 >> 1] = 0;
|
|
39698
|
+
H[b + 8 >> 3] = BigInt(0);
|
|
39699
|
+
H[b + 16 >> 3] = BigInt(0);
|
|
39700
|
+
return 0;
|
|
39701
|
+
} catch (d) {
|
|
39702
|
+
if (typeof W == "undefined" || d.name !== "ErrnoError")
|
|
39703
|
+
throw d;
|
|
39704
|
+
return d.Pa;
|
|
39705
|
+
}
|
|
39706
|
+
}, w: function(a, b, c, d) {
|
|
39707
|
+
try {
|
|
39708
|
+
a: {
|
|
39709
|
+
var e2 = T(a);
|
|
39710
|
+
a = b;
|
|
39711
|
+
for (var h2, k = b = 0;k < c; k++) {
|
|
39712
|
+
var q = F2[a >> 2], w = F2[a + 4 >> 2];
|
|
39713
|
+
a += 8;
|
|
39714
|
+
var v = Ec(e2, p, q, w, h2);
|
|
39715
|
+
if (0 > v) {
|
|
39716
|
+
var C = -1;
|
|
39717
|
+
break a;
|
|
39718
|
+
}
|
|
39719
|
+
b += v;
|
|
39720
|
+
if (v < w)
|
|
39721
|
+
break;
|
|
39722
|
+
typeof h2 != "undefined" && (h2 += v);
|
|
39723
|
+
}
|
|
39724
|
+
C = b;
|
|
39725
|
+
}
|
|
39726
|
+
F2[d >> 2] = C;
|
|
39727
|
+
return 0;
|
|
39728
|
+
} catch (G) {
|
|
39729
|
+
if (typeof W == "undefined" || G.name !== "ErrnoError")
|
|
39730
|
+
throw G;
|
|
39731
|
+
return G.Pa;
|
|
39732
|
+
}
|
|
39733
|
+
}, D: function(a, b, c, d) {
|
|
39734
|
+
b = -9007199254740992 > b || 9007199254740992 < b ? NaN : Number(b);
|
|
39735
|
+
try {
|
|
39736
|
+
if (isNaN(b))
|
|
39737
|
+
return 61;
|
|
39738
|
+
var e2 = T(a);
|
|
39739
|
+
mc(e2, b, c);
|
|
39740
|
+
H[d >> 3] = BigInt(e2.position);
|
|
39741
|
+
e2.ob && b === 0 && c === 0 && (e2.ob = null);
|
|
39742
|
+
return 0;
|
|
39743
|
+
} catch (h2) {
|
|
39744
|
+
if (typeof W == "undefined" || h2.name !== "ErrnoError")
|
|
39745
|
+
throw h2;
|
|
39746
|
+
return h2.Pa;
|
|
39747
|
+
}
|
|
39748
|
+
}, I: function(a) {
|
|
39749
|
+
try {
|
|
39750
|
+
var b = T(a);
|
|
39751
|
+
return b.Ma?.fsync ? b.Ma.fsync(b) : 0;
|
|
39752
|
+
} catch (c) {
|
|
39753
|
+
if (typeof W == "undefined" || c.name !== "ErrnoError")
|
|
39754
|
+
throw c;
|
|
39755
|
+
return c.Pa;
|
|
39756
|
+
}
|
|
39757
|
+
}, t: function(a, b, c, d) {
|
|
39758
|
+
try {
|
|
39759
|
+
a: {
|
|
39760
|
+
var e2 = T(a);
|
|
39761
|
+
a = b;
|
|
39762
|
+
for (var h2, k = b = 0;k < c; k++) {
|
|
39763
|
+
var q = F2[a >> 2], w = F2[a + 4 >> 2];
|
|
39764
|
+
a += 8;
|
|
39765
|
+
var v = pa(e2, p, q, w, h2);
|
|
39766
|
+
if (0 > v) {
|
|
39767
|
+
var C = -1;
|
|
39768
|
+
break a;
|
|
39769
|
+
}
|
|
39770
|
+
b += v;
|
|
39771
|
+
if (v < w)
|
|
39772
|
+
break;
|
|
39773
|
+
typeof h2 != "undefined" && (h2 += v);
|
|
39774
|
+
}
|
|
39775
|
+
C = b;
|
|
39776
|
+
}
|
|
39777
|
+
F2[d >> 2] = C;
|
|
39778
|
+
return 0;
|
|
39779
|
+
} catch (G) {
|
|
39780
|
+
if (typeof W == "undefined" || G.name !== "ErrnoError")
|
|
39781
|
+
throw G;
|
|
39782
|
+
return G.Pa;
|
|
39783
|
+
}
|
|
39784
|
+
}, k: Oc }, Z2;
|
|
39785
|
+
(async function() {
|
|
39786
|
+
function a(c) {
|
|
39787
|
+
Z2 = c.exports;
|
|
39788
|
+
Ka = Z2.M;
|
|
39789
|
+
Qa();
|
|
39790
|
+
Y = Z2.O;
|
|
39791
|
+
K--;
|
|
39792
|
+
f3.monitorRunDependencies?.(K);
|
|
39793
|
+
K == 0 && Sa && (c = Sa, Sa = null, c());
|
|
39794
|
+
return Z2;
|
|
39795
|
+
}
|
|
39796
|
+
K++;
|
|
39797
|
+
f3.monitorRunDependencies?.(K);
|
|
39798
|
+
var b = { a: Xc };
|
|
39799
|
+
if (f3.instantiateWasm)
|
|
39800
|
+
return new Promise((c) => {
|
|
39801
|
+
f3.instantiateWasm(b, (d, e2) => {
|
|
39802
|
+
a(d, e2);
|
|
39803
|
+
c(d.exports);
|
|
39804
|
+
});
|
|
39805
|
+
});
|
|
39806
|
+
Ua ??= f3.locateFile ? f3.locateFile("sql-wasm.wasm", D) : D + "sql-wasm.wasm";
|
|
39807
|
+
return a((await Xa(b)).instance);
|
|
39808
|
+
})();
|
|
39809
|
+
f3._sqlite3_free = (a) => (f3._sqlite3_free = Z2.P)(a);
|
|
39810
|
+
f3._sqlite3_value_text = (a) => (f3._sqlite3_value_text = Z2.Q)(a);
|
|
39811
|
+
f3._sqlite3_prepare_v2 = (a, b, c, d, e2) => (f3._sqlite3_prepare_v2 = Z2.R)(a, b, c, d, e2);
|
|
39812
|
+
f3._sqlite3_step = (a) => (f3._sqlite3_step = Z2.S)(a);
|
|
39813
|
+
f3._sqlite3_reset = (a) => (f3._sqlite3_reset = Z2.T)(a);
|
|
39814
|
+
f3._sqlite3_exec = (a, b, c, d, e2) => (f3._sqlite3_exec = Z2.U)(a, b, c, d, e2);
|
|
39815
|
+
f3._sqlite3_finalize = (a) => (f3._sqlite3_finalize = Z2.V)(a);
|
|
39816
|
+
f3._sqlite3_column_name = (a, b) => (f3._sqlite3_column_name = Z2.W)(a, b);
|
|
39817
|
+
f3._sqlite3_column_text = (a, b) => (f3._sqlite3_column_text = Z2.X)(a, b);
|
|
39818
|
+
f3._sqlite3_column_type = (a, b) => (f3._sqlite3_column_type = Z2.Y)(a, b);
|
|
39819
|
+
f3._sqlite3_errmsg = (a) => (f3._sqlite3_errmsg = Z2.Z)(a);
|
|
39820
|
+
f3._sqlite3_clear_bindings = (a) => (f3._sqlite3_clear_bindings = Z2._)(a);
|
|
39821
|
+
f3._sqlite3_value_blob = (a) => (f3._sqlite3_value_blob = Z2.$)(a);
|
|
39822
|
+
f3._sqlite3_value_bytes = (a) => (f3._sqlite3_value_bytes = Z2.aa)(a);
|
|
39823
|
+
f3._sqlite3_value_double = (a) => (f3._sqlite3_value_double = Z2.ba)(a);
|
|
39824
|
+
f3._sqlite3_value_int = (a) => (f3._sqlite3_value_int = Z2.ca)(a);
|
|
39825
|
+
f3._sqlite3_value_type = (a) => (f3._sqlite3_value_type = Z2.da)(a);
|
|
39826
|
+
f3._sqlite3_result_blob = (a, b, c, d) => (f3._sqlite3_result_blob = Z2.ea)(a, b, c, d);
|
|
39827
|
+
f3._sqlite3_result_double = (a, b) => (f3._sqlite3_result_double = Z2.fa)(a, b);
|
|
39828
|
+
f3._sqlite3_result_error = (a, b, c) => (f3._sqlite3_result_error = Z2.ga)(a, b, c);
|
|
39829
|
+
f3._sqlite3_result_int = (a, b) => (f3._sqlite3_result_int = Z2.ha)(a, b);
|
|
39830
|
+
f3._sqlite3_result_int64 = (a, b) => (f3._sqlite3_result_int64 = Z2.ia)(a, b);
|
|
39831
|
+
f3._sqlite3_result_null = (a) => (f3._sqlite3_result_null = Z2.ja)(a);
|
|
39832
|
+
f3._sqlite3_result_text = (a, b, c, d) => (f3._sqlite3_result_text = Z2.ka)(a, b, c, d);
|
|
39833
|
+
f3._sqlite3_aggregate_context = (a, b) => (f3._sqlite3_aggregate_context = Z2.la)(a, b);
|
|
39834
|
+
f3._sqlite3_column_count = (a) => (f3._sqlite3_column_count = Z2.ma)(a);
|
|
39835
|
+
f3._sqlite3_data_count = (a) => (f3._sqlite3_data_count = Z2.na)(a);
|
|
39836
|
+
f3._sqlite3_column_blob = (a, b) => (f3._sqlite3_column_blob = Z2.oa)(a, b);
|
|
39837
|
+
f3._sqlite3_column_bytes = (a, b) => (f3._sqlite3_column_bytes = Z2.pa)(a, b);
|
|
39838
|
+
f3._sqlite3_column_double = (a, b) => (f3._sqlite3_column_double = Z2.qa)(a, b);
|
|
39839
|
+
f3._sqlite3_bind_blob = (a, b, c, d, e2) => (f3._sqlite3_bind_blob = Z2.ra)(a, b, c, d, e2);
|
|
39840
|
+
f3._sqlite3_bind_double = (a, b, c) => (f3._sqlite3_bind_double = Z2.sa)(a, b, c);
|
|
39841
|
+
f3._sqlite3_bind_int = (a, b, c) => (f3._sqlite3_bind_int = Z2.ta)(a, b, c);
|
|
39842
|
+
f3._sqlite3_bind_text = (a, b, c, d, e2) => (f3._sqlite3_bind_text = Z2.ua)(a, b, c, d, e2);
|
|
39843
|
+
f3._sqlite3_bind_parameter_index = (a, b) => (f3._sqlite3_bind_parameter_index = Z2.va)(a, b);
|
|
39844
|
+
f3._sqlite3_sql = (a) => (f3._sqlite3_sql = Z2.wa)(a);
|
|
39845
|
+
f3._sqlite3_normalized_sql = (a) => (f3._sqlite3_normalized_sql = Z2.xa)(a);
|
|
39846
|
+
f3._sqlite3_changes = (a) => (f3._sqlite3_changes = Z2.ya)(a);
|
|
39847
|
+
f3._sqlite3_close_v2 = (a) => (f3._sqlite3_close_v2 = Z2.za)(a);
|
|
39848
|
+
f3._sqlite3_create_function_v2 = (a, b, c, d, e2, h2, k, q, w) => (f3._sqlite3_create_function_v2 = Z2.Aa)(a, b, c, d, e2, h2, k, q, w);
|
|
39849
|
+
f3._sqlite3_update_hook = (a, b, c) => (f3._sqlite3_update_hook = Z2.Ba)(a, b, c);
|
|
39850
|
+
f3._sqlite3_open = (a, b) => (f3._sqlite3_open = Z2.Ca)(a, b);
|
|
39851
|
+
var ia = f3._malloc = (a) => (ia = f3._malloc = Z2.Da)(a), fa = f3._free = (a) => (fa = f3._free = Z2.Ea)(a);
|
|
39852
|
+
f3._RegisterExtensionFunctions = (a) => (f3._RegisterExtensionFunctions = Z2.Fa)(a);
|
|
39853
|
+
var Db = (a, b) => (Db = Z2.Ga)(a, b), Wc = (a, b) => (Wc = Z2.Ha)(a, b), wa = (a) => (wa = Z2.Ia)(a), z2 = (a) => (z2 = Z2.Ja)(a), sa = () => (sa = Z2.Ka)();
|
|
39854
|
+
f3.stackSave = () => sa();
|
|
39855
|
+
f3.stackRestore = (a) => wa(a);
|
|
39856
|
+
f3.stackAlloc = (a) => z2(a);
|
|
39857
|
+
f3.cwrap = (a, b, c, d) => {
|
|
39858
|
+
var e2 = !c || c.every((h2) => h2 === "number" || h2 === "boolean");
|
|
39859
|
+
return b !== "string" && e2 && !d ? f3["_" + a] : (...h2) => Tc(a, b, c, h2);
|
|
39860
|
+
};
|
|
39861
|
+
f3.addFunction = Aa;
|
|
39862
|
+
f3.removeFunction = A2;
|
|
39863
|
+
f3.UTF8ToString = ua;
|
|
39864
|
+
f3.ALLOC_NORMAL = ea;
|
|
39865
|
+
f3.allocate = da;
|
|
39866
|
+
f3.allocateUTF8OnStack = xa;
|
|
39867
|
+
function Yc() {
|
|
39868
|
+
function a() {
|
|
39869
|
+
f3.calledRun = true;
|
|
39870
|
+
if (!La) {
|
|
39871
|
+
if (!f3.noFSInit && !Ib) {
|
|
39872
|
+
var b, c;
|
|
39873
|
+
Ib = true;
|
|
39874
|
+
d ??= f3.stdin;
|
|
39875
|
+
b ??= f3.stdout;
|
|
39876
|
+
c ??= f3.stderr;
|
|
39877
|
+
d ? V("stdin", d) : Zb("/dev/tty", "/dev/stdin");
|
|
39878
|
+
b ? V("stdout", null, b) : Zb("/dev/tty", "/dev/stdout");
|
|
39879
|
+
c ? V("stderr", null, c) : Zb("/dev/tty1", "/dev/stderr");
|
|
39880
|
+
oa("/dev/stdin", 0);
|
|
39881
|
+
oa("/dev/stdout", 1);
|
|
39882
|
+
oa("/dev/stderr", 1);
|
|
39883
|
+
}
|
|
39884
|
+
Z2.N();
|
|
39885
|
+
Jb = false;
|
|
39886
|
+
f3.onRuntimeInitialized?.();
|
|
39887
|
+
if (f3.postRun)
|
|
39888
|
+
for (typeof f3.postRun == "function" && (f3.postRun = [f3.postRun]);f3.postRun.length; ) {
|
|
39889
|
+
var d = f3.postRun.shift();
|
|
39890
|
+
$a.unshift(d);
|
|
39891
|
+
}
|
|
39892
|
+
Za($a);
|
|
39893
|
+
}
|
|
39894
|
+
}
|
|
39895
|
+
if (0 < K)
|
|
39896
|
+
Sa = Yc;
|
|
39897
|
+
else {
|
|
39898
|
+
if (f3.preRun)
|
|
39899
|
+
for (typeof f3.preRun == "function" && (f3.preRun = [f3.preRun]);f3.preRun.length; )
|
|
39900
|
+
bb();
|
|
39901
|
+
Za(ab);
|
|
39902
|
+
0 < K ? Sa = Yc : f3.setStatus ? (f3.setStatus("Running..."), setTimeout(() => {
|
|
39903
|
+
setTimeout(() => f3.setStatus(""), 1);
|
|
39904
|
+
a();
|
|
39905
|
+
}, 1)) : a();
|
|
39906
|
+
}
|
|
39907
|
+
}
|
|
39908
|
+
if (f3.preInit)
|
|
39909
|
+
for (typeof f3.preInit == "function" && (f3.preInit = [f3.preInit]);0 < f3.preInit.length; )
|
|
39910
|
+
f3.preInit.pop()();
|
|
39911
|
+
Yc();
|
|
39912
|
+
return Module;
|
|
39913
|
+
});
|
|
39914
|
+
return initSqlJsPromise;
|
|
39915
|
+
};
|
|
39916
|
+
if (typeof exports === "object" && typeof module === "object") {
|
|
39917
|
+
module.exports = initSqlJs;
|
|
39918
|
+
module.exports.default = initSqlJs;
|
|
39919
|
+
} else if (typeof define === "function" && define["amd"]) {
|
|
39920
|
+
define([], function() {
|
|
39921
|
+
return initSqlJs;
|
|
39922
|
+
});
|
|
39923
|
+
} else if (typeof exports === "object") {
|
|
39924
|
+
exports["Module"] = initSqlJs;
|
|
39925
|
+
}
|
|
39926
|
+
});
|
|
39927
|
+
|
|
37644
39928
|
// ../../node_modules/ws/lib/constants.js
|
|
37645
39929
|
var require_constants = __commonJS((exports, module) => {
|
|
37646
39930
|
var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
|
|
@@ -40499,7 +42783,7 @@ var {
|
|
|
40499
42783
|
Help
|
|
40500
42784
|
} = import__.default;
|
|
40501
42785
|
// package.json
|
|
40502
|
-
var version = "0.9.
|
|
42786
|
+
var version = "0.9.90";
|
|
40503
42787
|
|
|
40504
42788
|
// src/runner.ts
|
|
40505
42789
|
import { execSync } from "node:child_process";
|
|
@@ -54123,6 +56407,57 @@ function date4(params) {
|
|
|
54123
56407
|
|
|
54124
56408
|
// ../../node_modules/zod/v4/classic/external.js
|
|
54125
56409
|
config(en_default());
|
|
56410
|
+
// ../core/src/config/base.ts
|
|
56411
|
+
var baseModelConfigSchema = exports_external.object({
|
|
56412
|
+
provider: exports_external.string().optional(),
|
|
56413
|
+
model: exports_external.string().optional(),
|
|
56414
|
+
parameters: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
|
|
56415
|
+
});
|
|
56416
|
+
var baseApprovalConfigSchema = exports_external.object({
|
|
56417
|
+
level: exports_external.enum(["none", "destructive", "commits", "all"]).optional(),
|
|
56418
|
+
autoApprove: exports_external.boolean().optional(),
|
|
56419
|
+
maxCost: exports_external.number().positive().optional()
|
|
56420
|
+
});
|
|
56421
|
+
var providerConfigSchema = exports_external.object({
|
|
56422
|
+
apiKey: exports_external.string().optional(),
|
|
56423
|
+
defaultModel: exports_external.string().optional(),
|
|
56424
|
+
defaultParameters: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
|
|
56425
|
+
location: exports_external.string().optional(),
|
|
56426
|
+
project: exports_external.string().optional(),
|
|
56427
|
+
keyFile: exports_external.string().optional(),
|
|
56428
|
+
baseUrl: exports_external.string().optional(),
|
|
56429
|
+
name: exports_external.string().optional()
|
|
56430
|
+
});
|
|
56431
|
+
var modelConfigSchema = baseModelConfigSchema.extend({
|
|
56432
|
+
budget: exports_external.number().positive().optional(),
|
|
56433
|
+
rules: exports_external.union([exports_external.string(), exports_external.array(exports_external.string()).optional()]).optional()
|
|
56434
|
+
});
|
|
56435
|
+
var toolConfigSchema = exports_external.union([
|
|
56436
|
+
exports_external.boolean(),
|
|
56437
|
+
baseModelConfigSchema
|
|
56438
|
+
]);
|
|
56439
|
+
|
|
56440
|
+
// ../core/src/config/memory.ts
|
|
56441
|
+
var memoryConfigSchema = exports_external.object({
|
|
56442
|
+
enabled: exports_external.boolean().optional().default(true),
|
|
56443
|
+
type: exports_external.enum(["sqlite", "memory"]).optional().default("sqlite"),
|
|
56444
|
+
path: exports_external.string().optional().default("~/.config/polka-codes/memory.sqlite")
|
|
56445
|
+
}).strict().optional();
|
|
56446
|
+
var DEFAULT_MEMORY_CONFIG = {
|
|
56447
|
+
enabled: true,
|
|
56448
|
+
type: "sqlite",
|
|
56449
|
+
path: "~/.config/polka-codes/memory.sqlite"
|
|
56450
|
+
};
|
|
56451
|
+
function resolveHomePath(path) {
|
|
56452
|
+
if (path.startsWith("~")) {
|
|
56453
|
+
const home = process.env.HOME || process.env.USERPROFILE || ".";
|
|
56454
|
+
if (home === ".") {
|
|
56455
|
+
throw new Error("Cannot resolve home directory: HOME and USERPROFILE environment variables are not set");
|
|
56456
|
+
}
|
|
56457
|
+
return `${home}${path.slice(1)}`;
|
|
56458
|
+
}
|
|
56459
|
+
return path;
|
|
56460
|
+
}
|
|
54126
56461
|
// ../core/src/config.ts
|
|
54127
56462
|
var ruleSchema = exports_external.union([
|
|
54128
56463
|
exports_external.string(),
|
|
@@ -54136,20 +56471,10 @@ var ruleSchema = exports_external.union([
|
|
|
54136
56471
|
branch: exports_external.string().optional()
|
|
54137
56472
|
}).strict()
|
|
54138
56473
|
]);
|
|
54139
|
-
var providerConfigSchema = exports_external.object({
|
|
54140
|
-
apiKey: exports_external.string().optional(),
|
|
54141
|
-
defaultModel: exports_external.string().optional(),
|
|
54142
|
-
defaultParameters: exports_external.record(exports_external.string(), exports_external.any()).optional(),
|
|
54143
|
-
location: exports_external.string().optional(),
|
|
54144
|
-
project: exports_external.string().optional(),
|
|
54145
|
-
keyFile: exports_external.string().optional(),
|
|
54146
|
-
baseUrl: exports_external.string().optional(),
|
|
54147
|
-
name: exports_external.string().optional()
|
|
54148
|
-
});
|
|
54149
56474
|
var providerModelSchema = exports_external.object({
|
|
54150
56475
|
provider: exports_external.string().optional(),
|
|
54151
56476
|
model: exports_external.string().optional(),
|
|
54152
|
-
parameters: exports_external.record(exports_external.string(), exports_external.
|
|
56477
|
+
parameters: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
|
|
54153
56478
|
budget: exports_external.number().positive().optional(),
|
|
54154
56479
|
rules: exports_external.array(ruleSchema).optional().or(exports_external.string()).optional()
|
|
54155
56480
|
});
|
|
@@ -54162,7 +56487,7 @@ var scriptSchema = exports_external.union([
|
|
|
54162
56487
|
exports_external.object({
|
|
54163
56488
|
workflow: exports_external.string(),
|
|
54164
56489
|
description: exports_external.string().optional(),
|
|
54165
|
-
input: exports_external.record(exports_external.string(), exports_external.
|
|
56490
|
+
input: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
|
|
54166
56491
|
}).strict(),
|
|
54167
56492
|
exports_external.object({
|
|
54168
56493
|
script: exports_external.string(),
|
|
@@ -54241,7 +56566,7 @@ var configSchema = exports_external.object({
|
|
|
54241
56566
|
providers: exports_external.record(exports_external.string(), providerConfigSchema).optional(),
|
|
54242
56567
|
defaultProvider: exports_external.string().optional(),
|
|
54243
56568
|
defaultModel: exports_external.string().optional(),
|
|
54244
|
-
defaultParameters: exports_external.record(exports_external.string(), exports_external.
|
|
56569
|
+
defaultParameters: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
|
|
54245
56570
|
maxMessageCount: exports_external.number().int().positive().optional(),
|
|
54246
56571
|
budget: exports_external.number().positive().optional(),
|
|
54247
56572
|
retryCount: exports_external.number().int().min(0).optional(),
|
|
@@ -54255,7 +56580,8 @@ var configSchema = exports_external.object({
|
|
|
54255
56580
|
mcpServers: exports_external.record(exports_external.string(), mcpServerConfigSchema).optional(),
|
|
54256
56581
|
rules: exports_external.array(ruleSchema).optional().or(exports_external.string()).optional(),
|
|
54257
56582
|
excludeFiles: exports_external.array(exports_external.string()).optional(),
|
|
54258
|
-
agent: agentSchema
|
|
56583
|
+
agent: agentSchema,
|
|
56584
|
+
memory: memoryConfigSchema
|
|
54259
56585
|
}).strict().nullish();
|
|
54260
56586
|
// ../core/src/skills/constants.ts
|
|
54261
56587
|
var SKILL_LIMITS = {
|
|
@@ -54728,14 +57054,40 @@ var readBinaryFile_default = {
|
|
|
54728
57054
|
// ../core/src/tools/readFile.ts
|
|
54729
57055
|
var toolInfo6 = {
|
|
54730
57056
|
name: "readFile",
|
|
54731
|
-
description:
|
|
57057
|
+
description: `Request to read the contents of one or multiple files at the specified paths.
|
|
57058
|
+
|
|
57059
|
+
When to use:
|
|
57060
|
+
- Examining file contents you don't know
|
|
57061
|
+
- Analyzing code, reviewing text files, extracting configuration info
|
|
57062
|
+
- Reading multiple files at once (use comma-separated paths)
|
|
57063
|
+
- Understanding file structure before editing
|
|
57064
|
+
|
|
57065
|
+
When NOT to use:
|
|
57066
|
+
- For file existence checks: Use listFiles instead
|
|
57067
|
+
- For searching within files: Use grep instead
|
|
57068
|
+
- For file name searches: Use searchFiles instead
|
|
57069
|
+
- Prefer this tool over executeCommand with cat/head/tail
|
|
57070
|
+
|
|
57071
|
+
Features:
|
|
57072
|
+
- Supports comma-separated paths for multiple files
|
|
57073
|
+
- Line numbers included for easy reference
|
|
57074
|
+
- Optional offset/limit for partial file reading
|
|
57075
|
+
- Automatically handles different file types
|
|
57076
|
+
|
|
57077
|
+
IMPORTANT:
|
|
57078
|
+
- Line numbers are included for easy reference
|
|
57079
|
+
- Use offset/limit for large files to read specific sections`,
|
|
54732
57080
|
parameters: exports_external.object({
|
|
54733
57081
|
path: exports_external.preprocess((val) => {
|
|
54734
57082
|
if (!val)
|
|
54735
57083
|
return [];
|
|
54736
|
-
|
|
54737
|
-
|
|
57084
|
+
if (Array.isArray(val)) {
|
|
57085
|
+
return val.filter((s) => typeof s === "string" && s.length > 0);
|
|
57086
|
+
}
|
|
57087
|
+
return val.split(",").filter((s) => s.length > 0);
|
|
54738
57088
|
}, exports_external.array(exports_external.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" }),
|
|
57089
|
+
offset: exports_external.number().optional().describe("Skip first N lines (for partial file reading)").meta({ usageValue: "100" }),
|
|
57090
|
+
limit: exports_external.number().optional().describe("Read at most N lines (for partial file reading)").meta({ usageValue: "50" }),
|
|
54739
57091
|
includeIgnored: exports_external.preprocess(preprocessBoolean, exports_external.boolean().nullish().default(false)).describe("Whether to include ignored files. Use true to include files ignored by .gitignore.").meta({ usageValue: "true or false (optional)" })
|
|
54740
57092
|
}).meta({
|
|
54741
57093
|
examples: [
|
|
@@ -54750,6 +57102,14 @@ var toolInfo6 = {
|
|
|
54750
57102
|
input: {
|
|
54751
57103
|
path: "src/main.js,src/index.js"
|
|
54752
57104
|
}
|
|
57105
|
+
},
|
|
57106
|
+
{
|
|
57107
|
+
description: "Read partial file (lines 100-150)",
|
|
57108
|
+
input: {
|
|
57109
|
+
path: "src/large-file.ts",
|
|
57110
|
+
offset: 100,
|
|
57111
|
+
limit: 50
|
|
57112
|
+
}
|
|
54753
57113
|
}
|
|
54754
57114
|
]
|
|
54755
57115
|
})
|
|
@@ -54758,15 +57118,39 @@ var handler6 = async (provider, args) => {
|
|
|
54758
57118
|
if (!provider.readFile) {
|
|
54759
57119
|
return createProviderErrorResponse("read file");
|
|
54760
57120
|
}
|
|
54761
|
-
const
|
|
57121
|
+
const parsed = toolInfo6.parameters.safeParse(args);
|
|
57122
|
+
if (!parsed.success) {
|
|
57123
|
+
return {
|
|
57124
|
+
success: false,
|
|
57125
|
+
message: {
|
|
57126
|
+
type: "error-text",
|
|
57127
|
+
value: `Invalid arguments for readFile: ${parsed.error.message}`
|
|
57128
|
+
}
|
|
57129
|
+
};
|
|
57130
|
+
}
|
|
57131
|
+
const { path: paths, offset, limit, includeIgnored } = parsed.data;
|
|
54762
57132
|
const resp = [];
|
|
54763
57133
|
for (const path of paths) {
|
|
54764
57134
|
const fileContent = await provider.readFile(path, includeIgnored ?? false);
|
|
54765
57135
|
if (!fileContent) {
|
|
54766
57136
|
resp.push(createFileElement("read_file_file_content", path, undefined, { file_not_found: "true" }));
|
|
54767
|
-
|
|
54768
|
-
resp.push(createFileElement("read_file_file_content", path, fileContent));
|
|
57137
|
+
continue;
|
|
54769
57138
|
}
|
|
57139
|
+
let lines = fileContent.split(`
|
|
57140
|
+
`);
|
|
57141
|
+
const start = offset ?? 0;
|
|
57142
|
+
const end = limit ? start + limit : lines.length;
|
|
57143
|
+
if (offset !== undefined || limit !== undefined) {
|
|
57144
|
+
lines = lines.slice(start, end);
|
|
57145
|
+
}
|
|
57146
|
+
const lineOffset = offset ?? 0;
|
|
57147
|
+
const numberedContent = lines.map((line, i) => {
|
|
57148
|
+
const lineNumber = lineOffset + i + 1;
|
|
57149
|
+
const paddedNumber = String(lineNumber).padStart(6, " ");
|
|
57150
|
+
return `${paddedNumber}→${line}`;
|
|
57151
|
+
}).join(`
|
|
57152
|
+
`);
|
|
57153
|
+
resp.push(createFileElement("read_file_file_content", path, numberedContent));
|
|
54770
57154
|
}
|
|
54771
57155
|
return {
|
|
54772
57156
|
success: true,
|
|
@@ -54963,7 +57347,43 @@ var replaceInFile = (fileContent, diff) => {
|
|
|
54963
57347
|
// ../core/src/tools/replaceInFile.ts
|
|
54964
57348
|
var toolInfo9 = {
|
|
54965
57349
|
name: "replaceInFile",
|
|
54966
|
-
description:
|
|
57350
|
+
description: `Request to replace sections of content in an existing file using
|
|
57351
|
+
SEARCH/REPLACE blocks.
|
|
57352
|
+
|
|
57353
|
+
When to use:
|
|
57354
|
+
- Making targeted changes to specific parts of a file
|
|
57355
|
+
- Replacing variable names, function signatures, imports
|
|
57356
|
+
- Fixing bugs in existing code
|
|
57357
|
+
- When you know the exact content to replace
|
|
57358
|
+
|
|
57359
|
+
When NOT to use:
|
|
57360
|
+
- For creating new files: Use writeToFile instead
|
|
57361
|
+
- For completely replacing file contents: Use writeToFile instead
|
|
57362
|
+
- When you don't know the exact content: Read file first
|
|
57363
|
+
|
|
57364
|
+
SEARCH/REPLACE FORMAT:
|
|
57365
|
+
<<<<<<< SEARCH
|
|
57366
|
+
[exact content to find]
|
|
57367
|
+
=======
|
|
57368
|
+
[new content to replace with]
|
|
57369
|
+
>>>>>>> REPLACE
|
|
57370
|
+
|
|
57371
|
+
Critical rules:
|
|
57372
|
+
1. SEARCH content must match EXACTLY (character-for-character including whitespace)
|
|
57373
|
+
2. Each block replaces only first occurrence
|
|
57374
|
+
3. Include just enough lines for uniqueness (not too many, not too few)
|
|
57375
|
+
4. Keep blocks concise (don't include long unchanged sections)
|
|
57376
|
+
5. List blocks in order they appear in file
|
|
57377
|
+
6. Use multiple blocks for multiple independent changes
|
|
57378
|
+
|
|
57379
|
+
Special operations:
|
|
57380
|
+
- Move code: Two blocks (delete from original + insert at new location)
|
|
57381
|
+
- Delete code: Empty REPLACE section
|
|
57382
|
+
|
|
57383
|
+
IMPORTANT CONSTRAINTS:
|
|
57384
|
+
- SEARCH text must match file content exactly
|
|
57385
|
+
- Each block is independent (doesn't affect other blocks)
|
|
57386
|
+
- Cannot use for appending or inserting without SEARCH context`,
|
|
54967
57387
|
parameters: exports_external.object({
|
|
54968
57388
|
path: exports_external.string().describe("The path of the file to modify").meta({ usageValue: "File path here" }),
|
|
54969
57389
|
diff: exports_external.string().describe(`One or more SEARCH/REPLACE blocks following this exact format:
|
|
@@ -54989,7 +57409,7 @@ Critical rules:
|
|
|
54989
57409
|
* Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.
|
|
54990
57410
|
4. Special operations:
|
|
54991
57411
|
* To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
|
|
54992
|
-
* To delete code:
|
|
57412
|
+
* To delete code: Empty REPLACE section`).meta({ usageValue: "Search and replace blocks here" })
|
|
54993
57413
|
}).meta({
|
|
54994
57414
|
examples: [
|
|
54995
57415
|
{
|
|
@@ -55317,7 +57737,27 @@ var UpdateTodoItemOutputSchema = exports_external.object({
|
|
|
55317
57737
|
// ../core/src/tools/writeToFile.ts
|
|
55318
57738
|
var toolInfo12 = {
|
|
55319
57739
|
name: "writeToFile",
|
|
55320
|
-
description:
|
|
57740
|
+
description: `Request to write content to a file at the specified path.
|
|
57741
|
+
|
|
57742
|
+
When to use:
|
|
57743
|
+
- Creating new files
|
|
57744
|
+
- Completely replacing file contents
|
|
57745
|
+
- When you have the complete intended content
|
|
57746
|
+
|
|
57747
|
+
When NOT to use:
|
|
57748
|
+
- For modifying existing files: Use replaceInFile instead
|
|
57749
|
+
- For appending content: Use executeCommand with echo >> instead
|
|
57750
|
+
- For targeted edits: Use replaceInFile instead
|
|
57751
|
+
|
|
57752
|
+
Features:
|
|
57753
|
+
- Automatically creates any directories needed
|
|
57754
|
+
- Overwrites existing files completely
|
|
57755
|
+
- Must provide complete file content (no truncation)
|
|
57756
|
+
|
|
57757
|
+
IMPORTANT CONSTRAINT:
|
|
57758
|
+
- Always provide COMPLETE intended content (no omissions)
|
|
57759
|
+
- Ensure no incorrect escape sequences (<, >, &)
|
|
57760
|
+
- Ensure no unwanted CDATA tags in content`,
|
|
55321
57761
|
parameters: exports_external.object({
|
|
55322
57762
|
path: exports_external.string().describe("The path of the file to write to").meta({ usageValue: "File path here" }),
|
|
55323
57763
|
content: exports_external.string().describe("The content to write to the file. ALWAYS provide the COMPLETE intended content of the file, without any truncation or omissions. You MUST include ALL parts of the file, even if they haven't been modified.").meta({ usageValue: "Your file content here" })
|
|
@@ -55358,10 +57798,7 @@ var handler12 = async (provider, args) => {
|
|
|
55358
57798
|
}
|
|
55359
57799
|
};
|
|
55360
57800
|
}
|
|
55361
|
-
|
|
55362
|
-
const trimmedContent = content.trim();
|
|
55363
|
-
if (trimmedContent.startsWith("<![CDATA[") && trimmedContent.endsWith("]]>"))
|
|
55364
|
-
content = trimmedContent.slice(9, -3);
|
|
57801
|
+
const { path, content } = parsed.data;
|
|
55365
57802
|
await provider.writeFile(path, content);
|
|
55366
57803
|
return {
|
|
55367
57804
|
success: true,
|
|
@@ -58510,9 +60947,9 @@ class ZodUnion2 extends ZodType2 {
|
|
|
58510
60947
|
return this._def.options;
|
|
58511
60948
|
}
|
|
58512
60949
|
}
|
|
58513
|
-
ZodUnion2.create = (
|
|
60950
|
+
ZodUnion2.create = (types3, params) => {
|
|
58514
60951
|
return new ZodUnion2({
|
|
58515
|
-
options:
|
|
60952
|
+
options: types3,
|
|
58516
60953
|
typeName: ZodFirstPartyTypeKind2.ZodUnion,
|
|
58517
60954
|
...processCreateParams(params)
|
|
58518
60955
|
});
|
|
@@ -61006,15 +63443,15 @@ var primitiveMappings = {
|
|
|
61006
63443
|
function parseUnionDef(def, refs) {
|
|
61007
63444
|
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
61008
63445
|
if (options.every((x) => (x._def.typeName in primitiveMappings) && (!x._def.checks || !x._def.checks.length))) {
|
|
61009
|
-
const
|
|
63446
|
+
const types3 = options.reduce((types22, x) => {
|
|
61010
63447
|
const type = primitiveMappings[x._def.typeName];
|
|
61011
63448
|
return type && !types22.includes(type) ? [...types22, type] : types22;
|
|
61012
63449
|
}, []);
|
|
61013
63450
|
return {
|
|
61014
|
-
type:
|
|
63451
|
+
type: types3.length > 1 ? types3 : types3[0]
|
|
61015
63452
|
};
|
|
61016
63453
|
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
61017
|
-
const
|
|
63454
|
+
const types3 = options.reduce((acc, x) => {
|
|
61018
63455
|
const type = typeof x._def.value;
|
|
61019
63456
|
switch (type) {
|
|
61020
63457
|
case "string":
|
|
@@ -61033,8 +63470,8 @@ function parseUnionDef(def, refs) {
|
|
|
61033
63470
|
return acc;
|
|
61034
63471
|
}
|
|
61035
63472
|
}, []);
|
|
61036
|
-
if (
|
|
61037
|
-
const uniqueTypes =
|
|
63473
|
+
if (types3.length === options.length) {
|
|
63474
|
+
const uniqueTypes = types3.filter((x, i, a) => a.indexOf(x) === i);
|
|
61038
63475
|
return {
|
|
61039
63476
|
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
61040
63477
|
enum: options.reduce((acc, x) => {
|
|
@@ -65215,7 +67652,7 @@ var uiMessagesSchema = lazyValidator(() => zodSchema(exports_external.array(expo
|
|
|
65215
67652
|
var WorkflowInputDefinitionSchema = exports_external.object({
|
|
65216
67653
|
id: exports_external.string(),
|
|
65217
67654
|
description: exports_external.string().nullish(),
|
|
65218
|
-
default: exports_external.
|
|
67655
|
+
default: exports_external.unknown().nullish()
|
|
65219
67656
|
});
|
|
65220
67657
|
var WorkflowStepDefinitionSchema = exports_external.object({
|
|
65221
67658
|
id: exports_external.string(),
|
|
@@ -65223,7 +67660,7 @@ var WorkflowStepDefinitionSchema = exports_external.object({
|
|
|
65223
67660
|
task: exports_external.string(),
|
|
65224
67661
|
output: exports_external.string().nullish(),
|
|
65225
67662
|
expected_outcome: exports_external.string().nullish(),
|
|
65226
|
-
outputSchema: exports_external.
|
|
67663
|
+
outputSchema: exports_external.unknown().nullish(),
|
|
65227
67664
|
timeout: exports_external.number().positive().nullish()
|
|
65228
67665
|
});
|
|
65229
67666
|
var WhileLoopStepSchema = exports_external.object({
|
|
@@ -65772,9 +68209,9 @@ var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
|
|
|
65772
68209
|
var freeProcess = moduleExports2 && _freeGlobal_default.process;
|
|
65773
68210
|
var nodeUtil = function() {
|
|
65774
68211
|
try {
|
|
65775
|
-
var
|
|
65776
|
-
if (
|
|
65777
|
-
return
|
|
68212
|
+
var types4 = freeModule2 && freeModule2.require && freeModule2.require("util").types;
|
|
68213
|
+
if (types4) {
|
|
68214
|
+
return types4;
|
|
65778
68215
|
}
|
|
65779
68216
|
return freeProcess && freeProcess.binding && freeProcess.binding("util");
|
|
65780
68217
|
} catch (e) {}
|
|
@@ -66342,7 +68779,7 @@ function mergeConfigs(configs) {
|
|
|
66342
68779
|
merged.rules = mergeArray(accRules, configRules);
|
|
66343
68780
|
merged.excludeFiles = mergeArray(acc.excludeFiles, config3.excludeFiles);
|
|
66344
68781
|
return merged;
|
|
66345
|
-
});
|
|
68782
|
+
}, {});
|
|
66346
68783
|
return mergedConfig;
|
|
66347
68784
|
}
|
|
66348
68785
|
async function resolveRules(rules) {
|
|
@@ -68542,12 +70979,12 @@ function isPlainObject3(value) {
|
|
|
68542
70979
|
}
|
|
68543
70980
|
return Object.getPrototypeOf(value) === proto;
|
|
68544
70981
|
}
|
|
68545
|
-
function
|
|
70982
|
+
function deepMerge2(...objects) {
|
|
68546
70983
|
const output = {};
|
|
68547
70984
|
for (const obj of objects) {
|
|
68548
70985
|
for (const [key, value] of Object.entries(obj)) {
|
|
68549
70986
|
const prevValue = output[key];
|
|
68550
|
-
output[key] = isPlainObject3(prevValue) && isPlainObject3(value) ?
|
|
70987
|
+
output[key] = isPlainObject3(prevValue) && isPlainObject3(value) ? deepMerge2(prevValue, value) : value;
|
|
68551
70988
|
}
|
|
68552
70989
|
}
|
|
68553
70990
|
return output;
|
|
@@ -68557,7 +70994,7 @@ function makeTheme(...themes) {
|
|
|
68557
70994
|
defaultTheme,
|
|
68558
70995
|
...themes.filter((theme) => theme != null)
|
|
68559
70996
|
];
|
|
68560
|
-
return
|
|
70997
|
+
return deepMerge2(...themesToMerge);
|
|
68561
70998
|
}
|
|
68562
70999
|
|
|
68563
71000
|
// ../../node_modules/@inquirer/core/dist/lib/use-prefix.js
|
|
@@ -69825,7 +72262,7 @@ function lookup(path) {
|
|
|
69825
72262
|
}
|
|
69826
72263
|
return $types[extension2] || false;
|
|
69827
72264
|
}
|
|
69828
|
-
function populateMaps(extensions,
|
|
72265
|
+
function populateMaps(extensions, types6) {
|
|
69829
72266
|
Object.keys(db).forEach(function forEachMimeType(type) {
|
|
69830
72267
|
var mime = db[type];
|
|
69831
72268
|
var exts = mime.extensions;
|
|
@@ -69835,10 +72272,10 @@ function populateMaps(extensions, types5) {
|
|
|
69835
72272
|
extensions[type] = exts;
|
|
69836
72273
|
for (var i2 = 0;i2 < exts.length; i2++) {
|
|
69837
72274
|
var extension2 = exts[i2];
|
|
69838
|
-
|
|
69839
|
-
const legacyType = _preferredTypeLegacy(extension2,
|
|
69840
|
-
if (legacyType !==
|
|
69841
|
-
$_extensionConflicts.push([extension2, legacyType,
|
|
72275
|
+
types6[extension2] = _preferredType(extension2, types6[extension2], type);
|
|
72276
|
+
const legacyType = _preferredTypeLegacy(extension2, types6[extension2], type);
|
|
72277
|
+
if (legacyType !== types6[extension2]) {
|
|
72278
|
+
$_extensionConflicts.push([extension2, legacyType, types6[extension2]]);
|
|
69842
72279
|
}
|
|
69843
72280
|
}
|
|
69844
72281
|
});
|
|
@@ -70039,12 +72476,59 @@ class InMemoryStore {
|
|
|
70039
72476
|
this.#data = data;
|
|
70040
72477
|
}
|
|
70041
72478
|
}
|
|
72479
|
+
function isIMemoryStore(store) {
|
|
72480
|
+
return "readMemory" in store && "updateMemory" in store;
|
|
72481
|
+
}
|
|
70042
72482
|
var getProvider = (options = {}) => {
|
|
70043
72483
|
const ig = import_ignore2.default().add(options.excludeFiles ?? []);
|
|
70044
72484
|
const memoryStore = options.memoryStore ?? new InMemoryStore;
|
|
70045
72485
|
const todoItemStore = options.todoItemStore ?? new InMemoryStore;
|
|
70046
72486
|
const defaultMemoryTopic = ":default:";
|
|
70047
72487
|
const searchModel = options.getModel?.("search");
|
|
72488
|
+
const readMemoryKV = async (topic) => {
|
|
72489
|
+
if (!isIMemoryStore(memoryStore)) {
|
|
72490
|
+
const data = await memoryStore.read() ?? {};
|
|
72491
|
+
return data[topic];
|
|
72492
|
+
}
|
|
72493
|
+
return memoryStore.readMemory(topic);
|
|
72494
|
+
};
|
|
72495
|
+
const updateMemoryKV = async (operation, topic, content) => {
|
|
72496
|
+
if (!isIMemoryStore(memoryStore)) {
|
|
72497
|
+
const data = await memoryStore.read() ?? {};
|
|
72498
|
+
switch (operation) {
|
|
72499
|
+
case "append":
|
|
72500
|
+
if (content === undefined) {
|
|
72501
|
+
throw new Error("Content is required for append operation.");
|
|
72502
|
+
}
|
|
72503
|
+
data[topic] = `${data[topic] || ""}
|
|
72504
|
+
${content}`;
|
|
72505
|
+
break;
|
|
72506
|
+
case "replace":
|
|
72507
|
+
if (content === undefined) {
|
|
72508
|
+
throw new Error("Content is required for replace operation.");
|
|
72509
|
+
}
|
|
72510
|
+
data[topic] = content;
|
|
72511
|
+
break;
|
|
72512
|
+
case "remove":
|
|
72513
|
+
delete data[topic];
|
|
72514
|
+
break;
|
|
72515
|
+
}
|
|
72516
|
+
await memoryStore.write(data);
|
|
72517
|
+
return;
|
|
72518
|
+
}
|
|
72519
|
+
await memoryStore.updateMemory(operation, topic, content);
|
|
72520
|
+
};
|
|
72521
|
+
const listMemoryTopicsKV = async () => {
|
|
72522
|
+
if (!isIMemoryStore(memoryStore)) {
|
|
72523
|
+
const data = await memoryStore.read() ?? {};
|
|
72524
|
+
return Object.keys(data);
|
|
72525
|
+
}
|
|
72526
|
+
const entries = await memoryStore.queryMemory({});
|
|
72527
|
+
if (Array.isArray(entries)) {
|
|
72528
|
+
return entries.map((e2) => e2.name);
|
|
72529
|
+
}
|
|
72530
|
+
return [];
|
|
72531
|
+
};
|
|
70048
72532
|
const provider2 = {
|
|
70049
72533
|
listTodoItems: async (id, status) => {
|
|
70050
72534
|
const todoItems = await todoItemStore.read() ?? [];
|
|
@@ -70143,35 +72627,14 @@ var getProvider = (options = {}) => {
|
|
|
70143
72627
|
}
|
|
70144
72628
|
},
|
|
70145
72629
|
listMemoryTopics: async () => {
|
|
70146
|
-
|
|
70147
|
-
return Object.keys(memory);
|
|
72630
|
+
return listMemoryTopicsKV();
|
|
70148
72631
|
},
|
|
70149
72632
|
readMemory: async (topic = defaultMemoryTopic) => {
|
|
70150
|
-
|
|
70151
|
-
return memory[topic];
|
|
72633
|
+
return readMemoryKV(topic);
|
|
70152
72634
|
},
|
|
70153
72635
|
updateMemory: async (operation, topic, content) => {
|
|
70154
72636
|
const memoryTopic = topic ?? defaultMemoryTopic;
|
|
70155
|
-
|
|
70156
|
-
switch (operation) {
|
|
70157
|
-
case "append":
|
|
70158
|
-
if (content === undefined) {
|
|
70159
|
-
throw new Error("Content is required for append operation.");
|
|
70160
|
-
}
|
|
70161
|
-
memory[memoryTopic] = `${memory[memoryTopic] || ""}
|
|
70162
|
-
${content}`;
|
|
70163
|
-
break;
|
|
70164
|
-
case "replace":
|
|
70165
|
-
if (content === undefined) {
|
|
70166
|
-
throw new Error("Content is required for replace operation.");
|
|
70167
|
-
}
|
|
70168
|
-
memory[memoryTopic] = content;
|
|
70169
|
-
break;
|
|
70170
|
-
case "remove":
|
|
70171
|
-
delete memory[memoryTopic];
|
|
70172
|
-
break;
|
|
70173
|
-
}
|
|
70174
|
-
await memoryStore.write(memory);
|
|
72637
|
+
await updateMemoryKV(operation, memoryTopic, content);
|
|
70175
72638
|
},
|
|
70176
72639
|
readFile: async (path, includeIgnored) => {
|
|
70177
72640
|
if (!includeIgnored && ig.ignores(path)) {
|
|
@@ -70338,6 +72801,667 @@ ${content}`;
|
|
|
70338
72801
|
}
|
|
70339
72802
|
return provider2;
|
|
70340
72803
|
};
|
|
72804
|
+
// ../cli-shared/src/sqlite-memory-store.ts
|
|
72805
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
72806
|
+
import { randomUUID } from "node:crypto";
|
|
72807
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
72808
|
+
import { mkdir as mkdir2, readFile as readFile3, rename as rename2, writeFile as writeFile2 } from "node:fs/promises";
|
|
72809
|
+
import { dirname as dirname2, resolve as resolve4 } from "node:path";
|
|
72810
|
+
var import_sql = __toESM(require_sql_wasm(), 1);
|
|
72811
|
+
|
|
72812
|
+
class FileLock {
|
|
72813
|
+
lockfilePath;
|
|
72814
|
+
static LOCK_TIMEOUT = 30000;
|
|
72815
|
+
constructor(dbPath) {
|
|
72816
|
+
this.lockfilePath = `${dbPath}.lock`;
|
|
72817
|
+
}
|
|
72818
|
+
async acquire(retries = 10, delay2 = 100) {
|
|
72819
|
+
for (let i2 = 0;i2 < retries; i2++) {
|
|
72820
|
+
try {
|
|
72821
|
+
const lockData = JSON.stringify({
|
|
72822
|
+
pid: process.pid,
|
|
72823
|
+
acquiredAt: Date.now()
|
|
72824
|
+
});
|
|
72825
|
+
await writeFile2(this.lockfilePath, lockData, {
|
|
72826
|
+
flag: "wx",
|
|
72827
|
+
mode: 384
|
|
72828
|
+
});
|
|
72829
|
+
return;
|
|
72830
|
+
} catch (error48) {
|
|
72831
|
+
const errorCode = error48?.code;
|
|
72832
|
+
if (errorCode === "EEXIST") {
|
|
72833
|
+
try {
|
|
72834
|
+
const lockContent = await readFile3(this.lockfilePath, "utf-8");
|
|
72835
|
+
const lockData = JSON.parse(lockContent);
|
|
72836
|
+
if (!lockData || typeof lockData.acquiredAt !== "number" || lockData.acquiredAt <= 0) {
|
|
72837
|
+
console.warn(`[FileLock] Lock file has invalid acquiredAt, treating as stale`);
|
|
72838
|
+
await rename2(this.lockfilePath, `${this.lockfilePath}.invalid.${Date.now()}`);
|
|
72839
|
+
continue;
|
|
72840
|
+
}
|
|
72841
|
+
const lockAge = Date.now() - lockData.acquiredAt;
|
|
72842
|
+
if (lockAge > FileLock.LOCK_TIMEOUT) {
|
|
72843
|
+
console.warn(`[FileLock] Breaking stale lock (age: ${lockAge}ms)`);
|
|
72844
|
+
await rename2(this.lockfilePath, `${this.lockfilePath}.stale.${Date.now()}`);
|
|
72845
|
+
continue;
|
|
72846
|
+
}
|
|
72847
|
+
} catch (readError) {
|
|
72848
|
+
if (readError instanceof SyntaxError) {
|
|
72849
|
+
console.warn(`[FileLock] Lock file contains invalid JSON, treating as stale`);
|
|
72850
|
+
await rename2(this.lockfilePath, `${this.lockfilePath}.corrupt.${Date.now()}`);
|
|
72851
|
+
continue;
|
|
72852
|
+
}
|
|
72853
|
+
}
|
|
72854
|
+
if (i2 < retries - 1) {
|
|
72855
|
+
await new Promise((resolve5) => setTimeout(resolve5, delay2));
|
|
72856
|
+
} else {
|
|
72857
|
+
throw new Error(`Cannot acquire lock after ${retries} retries (file: ${this.lockfilePath})`);
|
|
72858
|
+
}
|
|
72859
|
+
} else {
|
|
72860
|
+
throw error48;
|
|
72861
|
+
}
|
|
72862
|
+
}
|
|
72863
|
+
}
|
|
72864
|
+
}
|
|
72865
|
+
async release() {
|
|
72866
|
+
try {
|
|
72867
|
+
await rename2(this.lockfilePath, `${this.lockfilePath}.released.${Date.now()}`);
|
|
72868
|
+
} catch (error48) {
|
|
72869
|
+
const errorCode = error48.code;
|
|
72870
|
+
if (errorCode !== "ENOENT") {
|
|
72871
|
+
console.warn(`[FileLock] Error releasing lock: ${error48 instanceof Error ? error48.message : String(error48)}`);
|
|
72872
|
+
}
|
|
72873
|
+
}
|
|
72874
|
+
}
|
|
72875
|
+
}
|
|
72876
|
+
|
|
72877
|
+
class ReentrantMutex {
|
|
72878
|
+
queue = [];
|
|
72879
|
+
locked = false;
|
|
72880
|
+
lockCount = 0;
|
|
72881
|
+
owner = null;
|
|
72882
|
+
async acquire(owner) {
|
|
72883
|
+
if (this.locked && this.owner === owner) {
|
|
72884
|
+
this.lockCount++;
|
|
72885
|
+
return () => this.release(owner);
|
|
72886
|
+
}
|
|
72887
|
+
while (this.locked) {
|
|
72888
|
+
await new Promise((resolve5) => this.queue.push(resolve5));
|
|
72889
|
+
}
|
|
72890
|
+
this.locked = true;
|
|
72891
|
+
this.owner = owner;
|
|
72892
|
+
this.lockCount = 1;
|
|
72893
|
+
return () => this.release(owner);
|
|
72894
|
+
}
|
|
72895
|
+
release(owner) {
|
|
72896
|
+
if (this.owner !== owner) {
|
|
72897
|
+
return;
|
|
72898
|
+
}
|
|
72899
|
+
this.lockCount--;
|
|
72900
|
+
if (this.lockCount === 0) {
|
|
72901
|
+
this.locked = false;
|
|
72902
|
+
this.owner = null;
|
|
72903
|
+
const next = this.queue.shift();
|
|
72904
|
+
if (next) {
|
|
72905
|
+
next();
|
|
72906
|
+
}
|
|
72907
|
+
}
|
|
72908
|
+
}
|
|
72909
|
+
}
|
|
72910
|
+
var SqlJs = null;
|
|
72911
|
+
var SqlJsInitPromise = null;
|
|
72912
|
+
async function getSqlJs() {
|
|
72913
|
+
if (SqlJs) {
|
|
72914
|
+
return SqlJs;
|
|
72915
|
+
}
|
|
72916
|
+
if (SqlJsInitPromise) {
|
|
72917
|
+
return SqlJsInitPromise;
|
|
72918
|
+
}
|
|
72919
|
+
SqlJsInitPromise = import_sql.default({});
|
|
72920
|
+
SqlJs = await SqlJsInitPromise;
|
|
72921
|
+
return SqlJs;
|
|
72922
|
+
}
|
|
72923
|
+
var transactionOwnerStorage = new AsyncLocalStorage2;
|
|
72924
|
+
|
|
72925
|
+
class SQLiteMemoryStore {
|
|
72926
|
+
db = null;
|
|
72927
|
+
dbPromise = null;
|
|
72928
|
+
config;
|
|
72929
|
+
currentScope;
|
|
72930
|
+
inTransaction = false;
|
|
72931
|
+
transactionMutex = new ReentrantMutex;
|
|
72932
|
+
fileLock;
|
|
72933
|
+
getDbPath() {
|
|
72934
|
+
return this.config.path || DEFAULT_MEMORY_CONFIG.path;
|
|
72935
|
+
}
|
|
72936
|
+
getFileLock() {
|
|
72937
|
+
if (!this.fileLock) {
|
|
72938
|
+
const dbPath = this.resolvePath(this.getDbPath());
|
|
72939
|
+
this.fileLock = new FileLock(dbPath);
|
|
72940
|
+
}
|
|
72941
|
+
return this.fileLock;
|
|
72942
|
+
}
|
|
72943
|
+
static SORT_COLUMNS = {
|
|
72944
|
+
created: "created_at",
|
|
72945
|
+
updated: "updated_at",
|
|
72946
|
+
accessed: "last_accessed",
|
|
72947
|
+
name: "name"
|
|
72948
|
+
};
|
|
72949
|
+
static ALLOWED_SORT_ORDERS = ["asc", "desc"];
|
|
72950
|
+
static ALLOWED_PRIORITIES = ["low", "medium", "high", "critical"];
|
|
72951
|
+
constructor(config3, scope) {
|
|
72952
|
+
this.config = config3;
|
|
72953
|
+
this.currentScope = scope;
|
|
72954
|
+
}
|
|
72955
|
+
async initializeDatabase() {
|
|
72956
|
+
if (this.dbPromise) {
|
|
72957
|
+
return this.dbPromise;
|
|
72958
|
+
}
|
|
72959
|
+
this.dbPromise = (async () => {
|
|
72960
|
+
if (this.db) {
|
|
72961
|
+
return this.db;
|
|
72962
|
+
}
|
|
72963
|
+
const dbPath = this.resolvePath(this.getDbPath());
|
|
72964
|
+
try {
|
|
72965
|
+
const dir = dirname2(dbPath);
|
|
72966
|
+
if (!existsSync2(dir)) {
|
|
72967
|
+
await mkdir2(dir, { recursive: true, mode: 448 });
|
|
72968
|
+
}
|
|
72969
|
+
let dbData;
|
|
72970
|
+
if (existsSync2(dbPath)) {
|
|
72971
|
+
const lock = this.getFileLock();
|
|
72972
|
+
await lock.acquire();
|
|
72973
|
+
try {
|
|
72974
|
+
try {
|
|
72975
|
+
dbData = await readFile3(dbPath);
|
|
72976
|
+
if (dbData.length >= 16) {
|
|
72977
|
+
const header = String.fromCharCode(...dbData.subarray(0, 15));
|
|
72978
|
+
if (header !== "SQLite format 3") {
|
|
72979
|
+
console.warn("[SQLiteMemoryStore] Invalid SQLite database header, will recreate");
|
|
72980
|
+
dbData = undefined;
|
|
72981
|
+
}
|
|
72982
|
+
}
|
|
72983
|
+
} catch (error48) {
|
|
72984
|
+
const errorCode = error48?.code;
|
|
72985
|
+
if (errorCode === "ENOENT") {
|
|
72986
|
+
dbData = undefined;
|
|
72987
|
+
} else {
|
|
72988
|
+
throw new Error(`Failed to read database file at ${dbPath}: ${error48 instanceof Error ? error48.message : String(error48)}`);
|
|
72989
|
+
}
|
|
72990
|
+
}
|
|
72991
|
+
} finally {
|
|
72992
|
+
await lock.release();
|
|
72993
|
+
}
|
|
72994
|
+
}
|
|
72995
|
+
const SqlJs2 = await getSqlJs();
|
|
72996
|
+
const db2 = new SqlJs2.Database(dbData);
|
|
72997
|
+
this.configurePragmas(db2);
|
|
72998
|
+
this.checkIntegrity(db2);
|
|
72999
|
+
this.initializeSchema(db2);
|
|
73000
|
+
this.db = db2;
|
|
73001
|
+
return db2;
|
|
73002
|
+
} catch (error48) {
|
|
73003
|
+
console.error("[SQLiteMemoryStore] Initialization failed:", error48);
|
|
73004
|
+
if (existsSync2(dbPath)) {
|
|
73005
|
+
const backupPath = `${dbPath}.corrupted.${Date.now()}`;
|
|
73006
|
+
console.warn(`[SQLiteMemoryStore] Backing up corrupted database to: ${backupPath}`);
|
|
73007
|
+
try {
|
|
73008
|
+
await rename2(dbPath, backupPath);
|
|
73009
|
+
} catch (backupError) {
|
|
73010
|
+
console.error("[SQLiteMemoryStore] Failed to backup corrupted database:", backupError);
|
|
73011
|
+
this.dbPromise = null;
|
|
73012
|
+
throw backupError;
|
|
73013
|
+
}
|
|
73014
|
+
this.dbPromise = null;
|
|
73015
|
+
return this.initializeDatabase();
|
|
73016
|
+
}
|
|
73017
|
+
this.dbPromise = null;
|
|
73018
|
+
throw error48;
|
|
73019
|
+
}
|
|
73020
|
+
})();
|
|
73021
|
+
return this.dbPromise;
|
|
73022
|
+
}
|
|
73023
|
+
async saveDatabase() {
|
|
73024
|
+
if (!this.db) {
|
|
73025
|
+
return;
|
|
73026
|
+
}
|
|
73027
|
+
const lock = this.getFileLock();
|
|
73028
|
+
await lock.acquire();
|
|
73029
|
+
try {
|
|
73030
|
+
const dbPath = this.resolvePath(this.getDbPath());
|
|
73031
|
+
const tempPath = `${dbPath}.tmp`;
|
|
73032
|
+
const data = this.db.export();
|
|
73033
|
+
await writeFile2(tempPath, data, { mode: 384 });
|
|
73034
|
+
await rename2(tempPath, dbPath);
|
|
73035
|
+
} finally {
|
|
73036
|
+
await lock.release();
|
|
73037
|
+
}
|
|
73038
|
+
}
|
|
73039
|
+
configurePragmas(db2) {
|
|
73040
|
+
db2.run("PRAGMA synchronous = NORMAL");
|
|
73041
|
+
db2.run("PRAGMA busy_timeout = 5000");
|
|
73042
|
+
db2.run("PRAGMA foreign_keys = ON");
|
|
73043
|
+
db2.run("PRAGMA temp_store = MEMORY");
|
|
73044
|
+
}
|
|
73045
|
+
checkIntegrity(db2) {
|
|
73046
|
+
try {
|
|
73047
|
+
const results = db2.exec("SELECT 1");
|
|
73048
|
+
if (results.length === 0) {
|
|
73049
|
+
throw new Error("Database query returned no results");
|
|
73050
|
+
}
|
|
73051
|
+
} catch (error48) {
|
|
73052
|
+
console.error("[SQLiteMemoryStore] Integrity check failed:", error48);
|
|
73053
|
+
throw new Error("Database is corrupted");
|
|
73054
|
+
}
|
|
73055
|
+
}
|
|
73056
|
+
initializeSchema(db2) {
|
|
73057
|
+
db2.run(`
|
|
73058
|
+
CREATE TABLE IF NOT EXISTS memory_entries (
|
|
73059
|
+
id TEXT PRIMARY KEY,
|
|
73060
|
+
name TEXT NOT NULL CHECK(length(name) > 0),
|
|
73061
|
+
scope TEXT NOT NULL CHECK(scope IN ('global') OR scope LIKE 'project:%'),
|
|
73062
|
+
content TEXT NOT NULL CHECK(length(content) > 0),
|
|
73063
|
+
entry_type TEXT NOT NULL CHECK(length(entry_type) > 0),
|
|
73064
|
+
status TEXT CHECK(status IS NULL OR length(status) > 0),
|
|
73065
|
+
priority TEXT CHECK(priority IS NULL OR priority IN ('low', 'medium', 'high', 'critical')),
|
|
73066
|
+
tags TEXT CHECK(tags IS NULL OR length(tags) > 0),
|
|
73067
|
+
metadata TEXT CHECK(metadata IS NULL OR json_valid(metadata)),
|
|
73068
|
+
created_at INTEGER NOT NULL CHECK(created_at > 0),
|
|
73069
|
+
updated_at INTEGER NOT NULL CHECK(updated_at > 0),
|
|
73070
|
+
last_accessed INTEGER NOT NULL CHECK(last_accessed > 0),
|
|
73071
|
+
UNIQUE(name, scope)
|
|
73072
|
+
)
|
|
73073
|
+
`);
|
|
73074
|
+
db2.run("CREATE INDEX IF NOT EXISTS idx_memory_entries_scope_type ON memory_entries(scope, entry_type)");
|
|
73075
|
+
db2.run("CREATE INDEX IF NOT EXISTS idx_memory_entries_updated ON memory_entries(updated_at)");
|
|
73076
|
+
}
|
|
73077
|
+
async getDatabase() {
|
|
73078
|
+
if (!this.db) {
|
|
73079
|
+
this.db = await this.initializeDatabase();
|
|
73080
|
+
}
|
|
73081
|
+
return this.db;
|
|
73082
|
+
}
|
|
73083
|
+
resolvePath(path) {
|
|
73084
|
+
const resolved = resolveHomePath(path);
|
|
73085
|
+
return resolve4(resolved);
|
|
73086
|
+
}
|
|
73087
|
+
generateUUID() {
|
|
73088
|
+
return randomUUID();
|
|
73089
|
+
}
|
|
73090
|
+
now() {
|
|
73091
|
+
return Date.now();
|
|
73092
|
+
}
|
|
73093
|
+
async transaction(callback) {
|
|
73094
|
+
let owner = transactionOwnerStorage.getStore();
|
|
73095
|
+
if (!owner) {
|
|
73096
|
+
owner = Symbol("transaction");
|
|
73097
|
+
}
|
|
73098
|
+
const release = await this.transactionMutex.acquire(owner);
|
|
73099
|
+
return transactionOwnerStorage.run(owner, async () => {
|
|
73100
|
+
try {
|
|
73101
|
+
const db2 = await this.getDatabase();
|
|
73102
|
+
const shouldBegin = !this.inTransaction;
|
|
73103
|
+
try {
|
|
73104
|
+
if (shouldBegin) {
|
|
73105
|
+
db2.run("BEGIN TRANSACTION");
|
|
73106
|
+
this.inTransaction = true;
|
|
73107
|
+
}
|
|
73108
|
+
const result = await callback();
|
|
73109
|
+
if (shouldBegin) {
|
|
73110
|
+
db2.run("COMMIT");
|
|
73111
|
+
this.inTransaction = false;
|
|
73112
|
+
try {
|
|
73113
|
+
await this.saveDatabase();
|
|
73114
|
+
} catch (saveError) {
|
|
73115
|
+
console.error("[SQLiteMemoryStore] Failed to save database after commit, closing:", saveError);
|
|
73116
|
+
await this.close(true);
|
|
73117
|
+
throw saveError;
|
|
73118
|
+
}
|
|
73119
|
+
}
|
|
73120
|
+
return result;
|
|
73121
|
+
} catch (error48) {
|
|
73122
|
+
if (this.inTransaction) {
|
|
73123
|
+
try {
|
|
73124
|
+
db2.run("ROLLBACK");
|
|
73125
|
+
} catch (rollbackError) {
|
|
73126
|
+
console.error("[SQLiteMemoryStore] ROLLBACK failed:", rollbackError);
|
|
73127
|
+
}
|
|
73128
|
+
this.inTransaction = false;
|
|
73129
|
+
}
|
|
73130
|
+
throw error48;
|
|
73131
|
+
}
|
|
73132
|
+
} finally {
|
|
73133
|
+
release();
|
|
73134
|
+
}
|
|
73135
|
+
});
|
|
73136
|
+
}
|
|
73137
|
+
async readMemory(topic) {
|
|
73138
|
+
const db2 = await this.getDatabase();
|
|
73139
|
+
const scope = this.currentScope;
|
|
73140
|
+
const stmt = db2.prepare("SELECT content FROM memory_entries WHERE name = ? AND scope = ?");
|
|
73141
|
+
stmt.bind([topic, scope]);
|
|
73142
|
+
if (stmt.step()) {
|
|
73143
|
+
const row = stmt.getAsObject();
|
|
73144
|
+
const content = row.content;
|
|
73145
|
+
stmt.free();
|
|
73146
|
+
return content;
|
|
73147
|
+
}
|
|
73148
|
+
stmt.free();
|
|
73149
|
+
return;
|
|
73150
|
+
}
|
|
73151
|
+
async updateMemoryInternal(db2, operation, topic, content, metadata) {
|
|
73152
|
+
const scope = this.currentScope;
|
|
73153
|
+
const now = this.now();
|
|
73154
|
+
const createdAt = metadata?.created_at ?? now;
|
|
73155
|
+
const updatedAt = metadata?.updated_at ?? now;
|
|
73156
|
+
const lastAccessed = metadata?.last_accessed ?? now;
|
|
73157
|
+
if (operation === "remove") {
|
|
73158
|
+
const stmt2 = db2.prepare("DELETE FROM memory_entries WHERE name = ? AND scope = ?");
|
|
73159
|
+
stmt2.run([topic, scope]);
|
|
73160
|
+
stmt2.free();
|
|
73161
|
+
return;
|
|
73162
|
+
}
|
|
73163
|
+
const stmt = db2.prepare("SELECT content, entry_type, status, priority, tags FROM memory_entries WHERE name = ? AND scope = ?");
|
|
73164
|
+
stmt.bind([topic, scope]);
|
|
73165
|
+
let existing;
|
|
73166
|
+
if (stmt.step()) {
|
|
73167
|
+
const row = stmt.getAsObject();
|
|
73168
|
+
existing = {
|
|
73169
|
+
content: row.content,
|
|
73170
|
+
entry_type: row.entry_type,
|
|
73171
|
+
status: row.status,
|
|
73172
|
+
priority: row.priority,
|
|
73173
|
+
tags: row.tags
|
|
73174
|
+
};
|
|
73175
|
+
stmt.free();
|
|
73176
|
+
} else {
|
|
73177
|
+
existing = undefined;
|
|
73178
|
+
stmt.free();
|
|
73179
|
+
}
|
|
73180
|
+
let finalContent;
|
|
73181
|
+
let entry_type;
|
|
73182
|
+
let status;
|
|
73183
|
+
let priority;
|
|
73184
|
+
let tags;
|
|
73185
|
+
if (existing) {
|
|
73186
|
+
if (operation === "append") {
|
|
73187
|
+
if (!content) {
|
|
73188
|
+
throw new Error("Content is required for append operation.");
|
|
73189
|
+
}
|
|
73190
|
+
finalContent = `${existing.content}
|
|
73191
|
+
${content}`;
|
|
73192
|
+
} else {
|
|
73193
|
+
if (!content) {
|
|
73194
|
+
throw new Error("Content is required for replace operation.");
|
|
73195
|
+
}
|
|
73196
|
+
finalContent = content;
|
|
73197
|
+
}
|
|
73198
|
+
entry_type = metadata?.entry_type || existing.entry_type;
|
|
73199
|
+
status = (metadata?.status || existing.status) ?? undefined;
|
|
73200
|
+
priority = (metadata?.priority || existing.priority) ?? undefined;
|
|
73201
|
+
tags = (metadata?.tags || existing.tags) ?? undefined;
|
|
73202
|
+
} else {
|
|
73203
|
+
if (!content) {
|
|
73204
|
+
throw new Error("Content is required for new memory entries.");
|
|
73205
|
+
}
|
|
73206
|
+
finalContent = content;
|
|
73207
|
+
entry_type = metadata?.entry_type || "note";
|
|
73208
|
+
status = metadata?.status;
|
|
73209
|
+
priority = metadata?.priority;
|
|
73210
|
+
tags = metadata?.tags;
|
|
73211
|
+
}
|
|
73212
|
+
const upsertStmt = db2.prepare(`
|
|
73213
|
+
INSERT INTO memory_entries (id, name, scope, content, entry_type, status, priority, tags, created_at, updated_at, last_accessed)
|
|
73214
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
73215
|
+
ON CONFLICT(name, scope) DO UPDATE SET
|
|
73216
|
+
content = excluded.content,
|
|
73217
|
+
entry_type = excluded.entry_type,
|
|
73218
|
+
status = excluded.status,
|
|
73219
|
+
priority = excluded.priority,
|
|
73220
|
+
tags = excluded.tags,
|
|
73221
|
+
updated_at = excluded.updated_at,
|
|
73222
|
+
last_accessed = excluded.last_accessed
|
|
73223
|
+
`);
|
|
73224
|
+
upsertStmt.run([
|
|
73225
|
+
this.generateUUID(),
|
|
73226
|
+
topic,
|
|
73227
|
+
scope,
|
|
73228
|
+
finalContent,
|
|
73229
|
+
entry_type,
|
|
73230
|
+
status ?? null,
|
|
73231
|
+
priority ?? null,
|
|
73232
|
+
tags ?? null,
|
|
73233
|
+
createdAt,
|
|
73234
|
+
updatedAt,
|
|
73235
|
+
lastAccessed
|
|
73236
|
+
]);
|
|
73237
|
+
upsertStmt.free();
|
|
73238
|
+
}
|
|
73239
|
+
async updateMemory(operation, topic, content, metadata) {
|
|
73240
|
+
return this.transaction(async () => {
|
|
73241
|
+
const db2 = await this.getDatabase();
|
|
73242
|
+
await this.updateMemoryInternal(db2, operation, topic, content, metadata);
|
|
73243
|
+
});
|
|
73244
|
+
}
|
|
73245
|
+
async queryMemory(query = {}, options = {}) {
|
|
73246
|
+
if (options.operation === "delete") {
|
|
73247
|
+
return this.transaction(async () => {
|
|
73248
|
+
const db3 = await this.getDatabase();
|
|
73249
|
+
const { sql: sql2, params: params2 } = this.buildQuery(query);
|
|
73250
|
+
const deleteSql = `DELETE FROM memory_entries WHERE id IN (SELECT id FROM (${sql2}))`;
|
|
73251
|
+
const stmt2 = db3.prepare(deleteSql);
|
|
73252
|
+
stmt2.bind(params2);
|
|
73253
|
+
stmt2.step();
|
|
73254
|
+
stmt2.free();
|
|
73255
|
+
return db3.getRowsModified();
|
|
73256
|
+
});
|
|
73257
|
+
}
|
|
73258
|
+
const db2 = await this.getDatabase();
|
|
73259
|
+
const { sql, params } = this.buildQuery(query);
|
|
73260
|
+
if (options.operation === "count") {
|
|
73261
|
+
const countSql = `SELECT COUNT(*) as count FROM (${sql})`;
|
|
73262
|
+
const stmt2 = db2.prepare(countSql);
|
|
73263
|
+
stmt2.bind(params);
|
|
73264
|
+
let count = 0;
|
|
73265
|
+
if (stmt2.step()) {
|
|
73266
|
+
const row = stmt2.getAsObject();
|
|
73267
|
+
count = row.count;
|
|
73268
|
+
}
|
|
73269
|
+
stmt2.free();
|
|
73270
|
+
return count;
|
|
73271
|
+
}
|
|
73272
|
+
const stmt = db2.prepare(sql);
|
|
73273
|
+
stmt.bind(params);
|
|
73274
|
+
const entries = [];
|
|
73275
|
+
while (stmt.step()) {
|
|
73276
|
+
entries.push(stmt.getAsObject());
|
|
73277
|
+
}
|
|
73278
|
+
stmt.free();
|
|
73279
|
+
return entries;
|
|
73280
|
+
}
|
|
73281
|
+
buildQuery(query) {
|
|
73282
|
+
const conditions = [];
|
|
73283
|
+
const params = [];
|
|
73284
|
+
let sql = "SELECT * FROM memory_entries WHERE 1=1";
|
|
73285
|
+
const scope = query.scope === "auto" ? this.currentScope : query.scope;
|
|
73286
|
+
if (scope === "global") {
|
|
73287
|
+
conditions.push(`scope = ?`);
|
|
73288
|
+
params.push("global");
|
|
73289
|
+
} else if (scope === "project" || !scope && this.currentScope !== "global") {
|
|
73290
|
+
conditions.push(`scope = ?`);
|
|
73291
|
+
params.push(this.currentScope);
|
|
73292
|
+
}
|
|
73293
|
+
if (query.name) {
|
|
73294
|
+
if (!query.name.trim()) {
|
|
73295
|
+
throw new Error("Name cannot be empty");
|
|
73296
|
+
}
|
|
73297
|
+
conditions.push(`name = ?`);
|
|
73298
|
+
params.push(query.name.trim());
|
|
73299
|
+
}
|
|
73300
|
+
if (query.type) {
|
|
73301
|
+
if (!query.type.trim()) {
|
|
73302
|
+
throw new Error("Type cannot be empty");
|
|
73303
|
+
}
|
|
73304
|
+
conditions.push(`entry_type = ?`);
|
|
73305
|
+
params.push(query.type.trim());
|
|
73306
|
+
}
|
|
73307
|
+
if (query.status) {
|
|
73308
|
+
conditions.push(`status = ?`);
|
|
73309
|
+
params.push(query.status);
|
|
73310
|
+
}
|
|
73311
|
+
if (query.priority) {
|
|
73312
|
+
if (!SQLiteMemoryStore.ALLOWED_PRIORITIES.includes(query.priority)) {
|
|
73313
|
+
throw new Error(`Invalid priority: ${query.priority}`);
|
|
73314
|
+
}
|
|
73315
|
+
conditions.push(`priority = ?`);
|
|
73316
|
+
params.push(query.priority);
|
|
73317
|
+
}
|
|
73318
|
+
if (query.tags) {
|
|
73319
|
+
const tags = Array.isArray(query.tags) ? query.tags : [query.tags];
|
|
73320
|
+
for (const tag of tags) {
|
|
73321
|
+
const trimmed = tag.trim();
|
|
73322
|
+
if (!trimmed) {
|
|
73323
|
+
throw new Error("Tags cannot be empty");
|
|
73324
|
+
}
|
|
73325
|
+
const escaped = trimmed.replace(/[\\_%]/g, "\\$&");
|
|
73326
|
+
conditions.push(`(tags = ? OR tags LIKE ? ESCAPE '\\' OR tags LIKE ? ESCAPE '\\' OR tags LIKE ? ESCAPE '\\')`);
|
|
73327
|
+
params.push(trimmed, `${escaped},%`, `%,${escaped}`, `%,${escaped},%`);
|
|
73328
|
+
}
|
|
73329
|
+
}
|
|
73330
|
+
if (query.search) {
|
|
73331
|
+
const searchTerm = query.search.trim();
|
|
73332
|
+
conditions.push(`(content LIKE ? ESCAPE '\\' OR name LIKE ? ESCAPE '\\')`);
|
|
73333
|
+
const searchPattern = `%${searchTerm.replace(/[\\_%]/g, "\\$&")}%`;
|
|
73334
|
+
params.push(searchPattern, searchPattern);
|
|
73335
|
+
}
|
|
73336
|
+
if (query.createdAfter) {
|
|
73337
|
+
conditions.push(`created_at >= ?`);
|
|
73338
|
+
params.push(query.createdAfter);
|
|
73339
|
+
}
|
|
73340
|
+
if (query.createdBefore) {
|
|
73341
|
+
conditions.push(`created_at <= ?`);
|
|
73342
|
+
params.push(query.createdBefore);
|
|
73343
|
+
}
|
|
73344
|
+
if (query.updatedAfter) {
|
|
73345
|
+
conditions.push(`updated_at >= ?`);
|
|
73346
|
+
params.push(query.updatedAfter);
|
|
73347
|
+
}
|
|
73348
|
+
if (query.updatedBefore) {
|
|
73349
|
+
conditions.push(`updated_at <= ?`);
|
|
73350
|
+
params.push(query.updatedBefore);
|
|
73351
|
+
}
|
|
73352
|
+
if (conditions.length > 0) {
|
|
73353
|
+
sql += ` AND ${conditions.join(" AND ")}`;
|
|
73354
|
+
}
|
|
73355
|
+
if (query.sortBy) {
|
|
73356
|
+
const column = SQLiteMemoryStore.SORT_COLUMNS[query.sortBy];
|
|
73357
|
+
if (!column) {
|
|
73358
|
+
throw new Error(`Invalid sortBy: ${query.sortBy}`);
|
|
73359
|
+
}
|
|
73360
|
+
const order = query.sortOrder || "desc";
|
|
73361
|
+
if (!SQLiteMemoryStore.ALLOWED_SORT_ORDERS.includes(order)) {
|
|
73362
|
+
throw new Error(`Invalid sortOrder: ${order}`);
|
|
73363
|
+
}
|
|
73364
|
+
sql += ` ORDER BY ${column} ${order.toUpperCase()}`;
|
|
73365
|
+
}
|
|
73366
|
+
if (query.limit) {
|
|
73367
|
+
const limit = Number(query.limit);
|
|
73368
|
+
if (Number.isNaN(limit) || limit < 1 || limit > 1e4) {
|
|
73369
|
+
throw new Error("Limit must be between 1 and 10000");
|
|
73370
|
+
}
|
|
73371
|
+
sql += ` LIMIT ?`;
|
|
73372
|
+
params.push(limit);
|
|
73373
|
+
}
|
|
73374
|
+
if (query.offset) {
|
|
73375
|
+
const offset = Number(query.offset);
|
|
73376
|
+
if (Number.isNaN(offset) || offset < 0) {
|
|
73377
|
+
throw new Error("Offset must be >= 0");
|
|
73378
|
+
}
|
|
73379
|
+
sql += ` OFFSET ?`;
|
|
73380
|
+
params.push(offset);
|
|
73381
|
+
}
|
|
73382
|
+
return { sql, params };
|
|
73383
|
+
}
|
|
73384
|
+
async batchUpdateMemory(operations) {
|
|
73385
|
+
return this.transaction(async () => {
|
|
73386
|
+
const db2 = await this.getDatabase();
|
|
73387
|
+
for (const op of operations) {
|
|
73388
|
+
await this.updateMemoryInternal(db2, op.operation, op.name, op.content, op.metadata);
|
|
73389
|
+
}
|
|
73390
|
+
});
|
|
73391
|
+
}
|
|
73392
|
+
async close(skipSave = false) {
|
|
73393
|
+
const db2 = this.db;
|
|
73394
|
+
if (db2) {
|
|
73395
|
+
try {
|
|
73396
|
+
if (!skipSave) {
|
|
73397
|
+
await this.saveDatabase();
|
|
73398
|
+
}
|
|
73399
|
+
} finally {
|
|
73400
|
+
if (this.db === db2) {
|
|
73401
|
+
db2.close();
|
|
73402
|
+
this.db = null;
|
|
73403
|
+
}
|
|
73404
|
+
}
|
|
73405
|
+
}
|
|
73406
|
+
this.dbPromise = null;
|
|
73407
|
+
}
|
|
73408
|
+
async getStats() {
|
|
73409
|
+
const db2 = await this.getDatabase();
|
|
73410
|
+
const results = db2.exec("SELECT COUNT(*) as count FROM memory_entries");
|
|
73411
|
+
const totalEntries = results[0]?.values[0]?.[0] || 0;
|
|
73412
|
+
const typeResults = db2.exec("SELECT entry_type, COUNT(*) as count FROM memory_entries GROUP BY entry_type");
|
|
73413
|
+
const entriesByType = {};
|
|
73414
|
+
if (typeResults.length > 0) {
|
|
73415
|
+
for (const row of typeResults[0].values) {
|
|
73416
|
+
entriesByType[row[0]] = row[1];
|
|
73417
|
+
}
|
|
73418
|
+
}
|
|
73419
|
+
const dbPath = this.resolvePath(this.getDbPath());
|
|
73420
|
+
let databaseSize = 0;
|
|
73421
|
+
try {
|
|
73422
|
+
const stats = await import("node:fs/promises").then((fs4) => fs4.stat(dbPath));
|
|
73423
|
+
databaseSize = stats.size;
|
|
73424
|
+
} catch {}
|
|
73425
|
+
return {
|
|
73426
|
+
totalEntries,
|
|
73427
|
+
entriesByType,
|
|
73428
|
+
databaseSize
|
|
73429
|
+
};
|
|
73430
|
+
}
|
|
73431
|
+
}
|
|
73432
|
+
// ../cli-shared/src/utils/parameterSimplifier.ts
|
|
73433
|
+
function createSimplifier(keepFields) {
|
|
73434
|
+
return (params) => {
|
|
73435
|
+
const result = {};
|
|
73436
|
+
for (const field of keepFields) {
|
|
73437
|
+
if (params[field] !== undefined) {
|
|
73438
|
+
result[field] = params[field];
|
|
73439
|
+
}
|
|
73440
|
+
}
|
|
73441
|
+
return result;
|
|
73442
|
+
};
|
|
73443
|
+
}
|
|
73444
|
+
function createCustomSimplifier(transform2) {
|
|
73445
|
+
return transform2;
|
|
73446
|
+
}
|
|
73447
|
+
var SIMPLIFIERS = {
|
|
73448
|
+
replaceInFile: createSimplifier(["path"]),
|
|
73449
|
+
writeToFile: createSimplifier(["path"]),
|
|
73450
|
+
readFile: createSimplifier(["path", "includeIgnored"]),
|
|
73451
|
+
executeCommand: createSimplifier(["command", "requiresApproval"]),
|
|
73452
|
+
updateMemory: createSimplifier(["operation", "topic"]),
|
|
73453
|
+
searchFiles: createCustomSimplifier((params) => ({ ...params })),
|
|
73454
|
+
listFiles: createCustomSimplifier((params) => {
|
|
73455
|
+
const DEFAULT_MAX_COUNT = 2000;
|
|
73456
|
+
const maxCount = params.maxCount;
|
|
73457
|
+
return {
|
|
73458
|
+
path: params.path,
|
|
73459
|
+
recursive: params.recursive,
|
|
73460
|
+
...maxCount !== DEFAULT_MAX_COUNT && { maxCount }
|
|
73461
|
+
};
|
|
73462
|
+
})
|
|
73463
|
+
};
|
|
73464
|
+
|
|
70341
73465
|
// ../cli-shared/src/utils/eventHandler.ts
|
|
70342
73466
|
var taskToolCallStats = new Map;
|
|
70343
73467
|
var globalToolCallStats = new Map;
|