@polka-codes/cli-shared 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 +3376 -192
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -9179,8 +9179,8 @@ var require_retry = __commonJS((exports) => {
|
|
|
9179
9179
|
}
|
|
9180
9180
|
const delay2 = getNextRetryDelay(config3);
|
|
9181
9181
|
err.config.retryConfig.currentRetryAttempt += 1;
|
|
9182
|
-
const backoff2 = config3.retryBackoff ? config3.retryBackoff(err, delay2) : new Promise((
|
|
9183
|
-
setTimeout(
|
|
9182
|
+
const backoff2 = config3.retryBackoff ? config3.retryBackoff(err, delay2) : new Promise((resolve3) => {
|
|
9183
|
+
setTimeout(resolve3, delay2);
|
|
9184
9184
|
});
|
|
9185
9185
|
if (config3.onRetryAttempt) {
|
|
9186
9186
|
await config3.onRetryAttempt(err);
|
|
@@ -10054,8 +10054,8 @@ var require_helpers = __commonJS((exports) => {
|
|
|
10054
10054
|
function req(url2, opts = {}) {
|
|
10055
10055
|
const href = typeof url2 === "string" ? url2 : url2.href;
|
|
10056
10056
|
const req2 = (href.startsWith("https:") ? https : http).request(url2, opts);
|
|
10057
|
-
const promise2 = new Promise((
|
|
10058
|
-
req2.once("response",
|
|
10057
|
+
const promise2 = new Promise((resolve3, reject) => {
|
|
10058
|
+
req2.once("response", resolve3).once("error", reject).end();
|
|
10059
10059
|
});
|
|
10060
10060
|
req2.then = promise2.then.bind(promise2);
|
|
10061
10061
|
return req2;
|
|
@@ -10224,7 +10224,7 @@ var require_parse_proxy_response = __commonJS((exports) => {
|
|
|
10224
10224
|
var debug_1 = __importDefault(require_src2());
|
|
10225
10225
|
var debug = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
|
|
10226
10226
|
function parseProxyResponse(socket) {
|
|
10227
|
-
return new Promise((
|
|
10227
|
+
return new Promise((resolve3, reject) => {
|
|
10228
10228
|
let buffersLength = 0;
|
|
10229
10229
|
const buffers = [];
|
|
10230
10230
|
function read() {
|
|
@@ -10293,7 +10293,7 @@ var require_parse_proxy_response = __commonJS((exports) => {
|
|
|
10293
10293
|
}
|
|
10294
10294
|
debug("got proxy server response: %o %o", firstLine, headers);
|
|
10295
10295
|
cleanup();
|
|
10296
|
-
|
|
10296
|
+
resolve3({
|
|
10297
10297
|
connect: {
|
|
10298
10298
|
statusCode,
|
|
10299
10299
|
statusText,
|
|
@@ -10527,7 +10527,7 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
10527
10527
|
return new originalPromise(executor);
|
|
10528
10528
|
}
|
|
10529
10529
|
function promiseResolvedWith(value) {
|
|
10530
|
-
return newPromise((
|
|
10530
|
+
return newPromise((resolve3) => resolve3(value));
|
|
10531
10531
|
}
|
|
10532
10532
|
function promiseRejectedWith(reason) {
|
|
10533
10533
|
return originalPromiseReject(reason);
|
|
@@ -10682,8 +10682,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
10682
10682
|
return new TypeError("Cannot " + name17 + " a stream using a released reader");
|
|
10683
10683
|
}
|
|
10684
10684
|
function defaultReaderClosedPromiseInitialize(reader) {
|
|
10685
|
-
reader._closedPromise = newPromise((
|
|
10686
|
-
reader._closedPromise_resolve =
|
|
10685
|
+
reader._closedPromise = newPromise((resolve3, reject) => {
|
|
10686
|
+
reader._closedPromise_resolve = resolve3;
|
|
10687
10687
|
reader._closedPromise_reject = reject;
|
|
10688
10688
|
});
|
|
10689
10689
|
}
|
|
@@ -10846,8 +10846,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
10846
10846
|
}
|
|
10847
10847
|
let resolvePromise;
|
|
10848
10848
|
let rejectPromise;
|
|
10849
|
-
const promise2 = newPromise((
|
|
10850
|
-
resolvePromise =
|
|
10849
|
+
const promise2 = newPromise((resolve3, reject) => {
|
|
10850
|
+
resolvePromise = resolve3;
|
|
10851
10851
|
rejectPromise = reject;
|
|
10852
10852
|
});
|
|
10853
10853
|
const readRequest = {
|
|
@@ -10943,8 +10943,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
10943
10943
|
const reader = this._reader;
|
|
10944
10944
|
let resolvePromise;
|
|
10945
10945
|
let rejectPromise;
|
|
10946
|
-
const promise2 = newPromise((
|
|
10947
|
-
resolvePromise =
|
|
10946
|
+
const promise2 = newPromise((resolve3, reject) => {
|
|
10947
|
+
resolvePromise = resolve3;
|
|
10948
10948
|
rejectPromise = reject;
|
|
10949
10949
|
});
|
|
10950
10950
|
const readRequest = {
|
|
@@ -11941,8 +11941,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
11941
11941
|
}
|
|
11942
11942
|
let resolvePromise;
|
|
11943
11943
|
let rejectPromise;
|
|
11944
|
-
const promise2 = newPromise((
|
|
11945
|
-
resolvePromise =
|
|
11944
|
+
const promise2 = newPromise((resolve3, reject) => {
|
|
11945
|
+
resolvePromise = resolve3;
|
|
11946
11946
|
rejectPromise = reject;
|
|
11947
11947
|
});
|
|
11948
11948
|
const readIntoRequest = {
|
|
@@ -12218,10 +12218,10 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
12218
12218
|
wasAlreadyErroring = true;
|
|
12219
12219
|
reason = undefined;
|
|
12220
12220
|
}
|
|
12221
|
-
const promise2 = newPromise((
|
|
12221
|
+
const promise2 = newPromise((resolve3, reject) => {
|
|
12222
12222
|
stream._pendingAbortRequest = {
|
|
12223
12223
|
_promise: undefined,
|
|
12224
|
-
_resolve:
|
|
12224
|
+
_resolve: resolve3,
|
|
12225
12225
|
_reject: reject,
|
|
12226
12226
|
_reason: reason,
|
|
12227
12227
|
_wasAlreadyErroring: wasAlreadyErroring
|
|
@@ -12238,9 +12238,9 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
12238
12238
|
if (state === "closed" || state === "errored") {
|
|
12239
12239
|
return promiseRejectedWith(new TypeError(`The stream (in ${state} state) is not in the writable state and cannot be closed`));
|
|
12240
12240
|
}
|
|
12241
|
-
const promise2 = newPromise((
|
|
12241
|
+
const promise2 = newPromise((resolve3, reject) => {
|
|
12242
12242
|
const closeRequest = {
|
|
12243
|
-
_resolve:
|
|
12243
|
+
_resolve: resolve3,
|
|
12244
12244
|
_reject: reject
|
|
12245
12245
|
};
|
|
12246
12246
|
stream._closeRequest = closeRequest;
|
|
@@ -12253,9 +12253,9 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
12253
12253
|
return promise2;
|
|
12254
12254
|
}
|
|
12255
12255
|
function WritableStreamAddWriteRequest(stream) {
|
|
12256
|
-
const promise2 = newPromise((
|
|
12256
|
+
const promise2 = newPromise((resolve3, reject) => {
|
|
12257
12257
|
const writeRequest = {
|
|
12258
|
-
_resolve:
|
|
12258
|
+
_resolve: resolve3,
|
|
12259
12259
|
_reject: reject
|
|
12260
12260
|
};
|
|
12261
12261
|
stream._writeRequests.push(writeRequest);
|
|
@@ -12820,8 +12820,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
12820
12820
|
return new TypeError("Cannot " + name17 + " a stream using a released writer");
|
|
12821
12821
|
}
|
|
12822
12822
|
function defaultWriterClosedPromiseInitialize(writer) {
|
|
12823
|
-
writer._closedPromise = newPromise((
|
|
12824
|
-
writer._closedPromise_resolve =
|
|
12823
|
+
writer._closedPromise = newPromise((resolve3, reject) => {
|
|
12824
|
+
writer._closedPromise_resolve = resolve3;
|
|
12825
12825
|
writer._closedPromise_reject = reject;
|
|
12826
12826
|
writer._closedPromiseState = "pending";
|
|
12827
12827
|
});
|
|
@@ -12857,8 +12857,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
12857
12857
|
writer._closedPromiseState = "resolved";
|
|
12858
12858
|
}
|
|
12859
12859
|
function defaultWriterReadyPromiseInitialize(writer) {
|
|
12860
|
-
writer._readyPromise = newPromise((
|
|
12861
|
-
writer._readyPromise_resolve =
|
|
12860
|
+
writer._readyPromise = newPromise((resolve3, reject) => {
|
|
12861
|
+
writer._readyPromise_resolve = resolve3;
|
|
12862
12862
|
writer._readyPromise_reject = reject;
|
|
12863
12863
|
});
|
|
12864
12864
|
writer._readyPromiseState = "pending";
|
|
@@ -12945,7 +12945,7 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
12945
12945
|
source._disturbed = true;
|
|
12946
12946
|
let shuttingDown = false;
|
|
12947
12947
|
let currentWrite = promiseResolvedWith(undefined);
|
|
12948
|
-
return newPromise((
|
|
12948
|
+
return newPromise((resolve3, reject) => {
|
|
12949
12949
|
let abortAlgorithm;
|
|
12950
12950
|
if (signal !== undefined) {
|
|
12951
12951
|
abortAlgorithm = () => {
|
|
@@ -13090,7 +13090,7 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
13090
13090
|
if (isError) {
|
|
13091
13091
|
reject(error48);
|
|
13092
13092
|
} else {
|
|
13093
|
-
|
|
13093
|
+
resolve3(undefined);
|
|
13094
13094
|
}
|
|
13095
13095
|
return null;
|
|
13096
13096
|
}
|
|
@@ -13359,8 +13359,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
13359
13359
|
let branch1;
|
|
13360
13360
|
let branch2;
|
|
13361
13361
|
let resolveCancelPromise;
|
|
13362
|
-
const cancelPromise = newPromise((
|
|
13363
|
-
resolveCancelPromise =
|
|
13362
|
+
const cancelPromise = newPromise((resolve3) => {
|
|
13363
|
+
resolveCancelPromise = resolve3;
|
|
13364
13364
|
});
|
|
13365
13365
|
function pullAlgorithm() {
|
|
13366
13366
|
if (reading) {
|
|
@@ -13450,8 +13450,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
13450
13450
|
let branch1;
|
|
13451
13451
|
let branch2;
|
|
13452
13452
|
let resolveCancelPromise;
|
|
13453
|
-
const cancelPromise = newPromise((
|
|
13454
|
-
resolveCancelPromise =
|
|
13453
|
+
const cancelPromise = newPromise((resolve3) => {
|
|
13454
|
+
resolveCancelPromise = resolve3;
|
|
13455
13455
|
});
|
|
13456
13456
|
function forwardReaderError(thisReader) {
|
|
13457
13457
|
uponRejection(thisReader._closedPromise, (r) => {
|
|
@@ -14196,8 +14196,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
14196
14196
|
const writableHighWaterMark = ExtractHighWaterMark(writableStrategy, 1);
|
|
14197
14197
|
const writableSizeAlgorithm = ExtractSizeAlgorithm(writableStrategy);
|
|
14198
14198
|
let startPromise_resolve;
|
|
14199
|
-
const startPromise = newPromise((
|
|
14200
|
-
startPromise_resolve =
|
|
14199
|
+
const startPromise = newPromise((resolve3) => {
|
|
14200
|
+
startPromise_resolve = resolve3;
|
|
14201
14201
|
});
|
|
14202
14202
|
InitializeTransformStream(this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
|
|
14203
14203
|
SetUpTransformStreamDefaultControllerFromTransformer(this, transformer);
|
|
@@ -14284,8 +14284,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
14284
14284
|
if (stream._backpressureChangePromise !== undefined) {
|
|
14285
14285
|
stream._backpressureChangePromise_resolve();
|
|
14286
14286
|
}
|
|
14287
|
-
stream._backpressureChangePromise = newPromise((
|
|
14288
|
-
stream._backpressureChangePromise_resolve =
|
|
14287
|
+
stream._backpressureChangePromise = newPromise((resolve3) => {
|
|
14288
|
+
stream._backpressureChangePromise_resolve = resolve3;
|
|
14289
14289
|
});
|
|
14290
14290
|
stream._backpressure = backpressure;
|
|
14291
14291
|
}
|
|
@@ -14443,8 +14443,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
14443
14443
|
return controller._finishPromise;
|
|
14444
14444
|
}
|
|
14445
14445
|
const readable = stream._readable;
|
|
14446
|
-
controller._finishPromise = newPromise((
|
|
14447
|
-
controller._finishPromise_resolve =
|
|
14446
|
+
controller._finishPromise = newPromise((resolve3, reject) => {
|
|
14447
|
+
controller._finishPromise_resolve = resolve3;
|
|
14448
14448
|
controller._finishPromise_reject = reject;
|
|
14449
14449
|
});
|
|
14450
14450
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -14470,8 +14470,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
14470
14470
|
return controller._finishPromise;
|
|
14471
14471
|
}
|
|
14472
14472
|
const readable = stream._readable;
|
|
14473
|
-
controller._finishPromise = newPromise((
|
|
14474
|
-
controller._finishPromise_resolve =
|
|
14473
|
+
controller._finishPromise = newPromise((resolve3, reject) => {
|
|
14474
|
+
controller._finishPromise_resolve = resolve3;
|
|
14475
14475
|
controller._finishPromise_reject = reject;
|
|
14476
14476
|
});
|
|
14477
14477
|
const flushPromise = controller._flushAlgorithm();
|
|
@@ -14501,8 +14501,8 @@ var require_ponyfill_es2018 = __commonJS((exports, module) => {
|
|
|
14501
14501
|
return controller._finishPromise;
|
|
14502
14502
|
}
|
|
14503
14503
|
const writable = stream._writable;
|
|
14504
|
-
controller._finishPromise = newPromise((
|
|
14505
|
-
controller._finishPromise_resolve =
|
|
14504
|
+
controller._finishPromise = newPromise((resolve3, reject) => {
|
|
14505
|
+
controller._finishPromise_resolve = resolve3;
|
|
14506
14506
|
controller._finishPromise_reject = reject;
|
|
14507
14507
|
});
|
|
14508
14508
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -15363,7 +15363,7 @@ var init_multipart_parser = __esm(() => {
|
|
|
15363
15363
|
|
|
15364
15364
|
// ../../node_modules/node-fetch/src/body.js
|
|
15365
15365
|
import Stream, { PassThrough } from "node:stream";
|
|
15366
|
-
import { types as
|
|
15366
|
+
import { types as types4, deprecate, promisify } from "node:util";
|
|
15367
15367
|
import { Buffer as Buffer4 } from "node:buffer";
|
|
15368
15368
|
|
|
15369
15369
|
class Body {
|
|
@@ -15375,7 +15375,7 @@ class Body {
|
|
|
15375
15375
|
body = null;
|
|
15376
15376
|
} else if (isURLSearchParameters(body)) {
|
|
15377
15377
|
body = Buffer4.from(body.toString());
|
|
15378
|
-
} else if (isBlob(body)) {} else if (Buffer4.isBuffer(body)) {} else if (
|
|
15378
|
+
} else if (isBlob(body)) {} else if (Buffer4.isBuffer(body)) {} else if (types4.isAnyArrayBuffer(body)) {
|
|
15379
15379
|
body = Buffer4.from(body);
|
|
15380
15380
|
} else if (ArrayBuffer.isView(body)) {
|
|
15381
15381
|
body = Buffer4.from(body.buffer, body.byteOffset, body.byteLength);
|
|
@@ -15521,7 +15521,7 @@ var pipeline, INTERNALS, clone2 = (instance, highWaterMark) => {
|
|
|
15521
15521
|
if (isBlob(body)) {
|
|
15522
15522
|
return body.type || null;
|
|
15523
15523
|
}
|
|
15524
|
-
if (Buffer4.isBuffer(body) ||
|
|
15524
|
+
if (Buffer4.isBuffer(body) || types4.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
|
|
15525
15525
|
return null;
|
|
15526
15526
|
}
|
|
15527
15527
|
if (body instanceof FormData2) {
|
|
@@ -15578,7 +15578,7 @@ var init_body = __esm(() => {
|
|
|
15578
15578
|
});
|
|
15579
15579
|
|
|
15580
15580
|
// ../../node_modules/node-fetch/src/headers.js
|
|
15581
|
-
import { types as
|
|
15581
|
+
import { types as types5 } from "node:util";
|
|
15582
15582
|
import http from "node:http";
|
|
15583
15583
|
function fromRawHeaders(headers = []) {
|
|
15584
15584
|
return new Headers2(headers.reduce((result, value, index, array2) => {
|
|
@@ -15620,7 +15620,7 @@ var init_headers = __esm(() => {
|
|
|
15620
15620
|
for (const [name17, values] of Object.entries(raw)) {
|
|
15621
15621
|
result.push(...values.map((value) => [name17, value]));
|
|
15622
15622
|
}
|
|
15623
|
-
} else if (init == null) {} else if (typeof init === "object" && !
|
|
15623
|
+
} else if (init == null) {} else if (typeof init === "object" && !types5.isBoxedPrimitive(init)) {
|
|
15624
15624
|
const method = init[Symbol.iterator];
|
|
15625
15625
|
if (method == null) {
|
|
15626
15626
|
result.push(...Object.entries(init));
|
|
@@ -15629,7 +15629,7 @@ var init_headers = __esm(() => {
|
|
|
15629
15629
|
throw new TypeError("Header pairs must be iterable");
|
|
15630
15630
|
}
|
|
15631
15631
|
result = [...init].map((pair) => {
|
|
15632
|
-
if (typeof pair !== "object" ||
|
|
15632
|
+
if (typeof pair !== "object" || types5.isBoxedPrimitive(pair)) {
|
|
15633
15633
|
throw new TypeError("Each header pair must be an iterable object");
|
|
15634
15634
|
}
|
|
15635
15635
|
return [...pair];
|
|
@@ -16224,7 +16224,7 @@ import zlib from "node:zlib";
|
|
|
16224
16224
|
import Stream2, { PassThrough as PassThrough2, pipeline as pump } from "node:stream";
|
|
16225
16225
|
import { Buffer as Buffer5 } from "node:buffer";
|
|
16226
16226
|
async function fetch2(url2, options_) {
|
|
16227
|
-
return new Promise((
|
|
16227
|
+
return new Promise((resolve3, reject) => {
|
|
16228
16228
|
const request = new Request(url2, options_);
|
|
16229
16229
|
const { parsedURL, options } = getNodeRequestOptions(request);
|
|
16230
16230
|
if (!supportedSchemas.has(parsedURL.protocol)) {
|
|
@@ -16233,7 +16233,7 @@ async function fetch2(url2, options_) {
|
|
|
16233
16233
|
if (parsedURL.protocol === "data:") {
|
|
16234
16234
|
const data = dist_default(request.url);
|
|
16235
16235
|
const response2 = new Response2(data, { headers: { "Content-Type": data.typeFull } });
|
|
16236
|
-
|
|
16236
|
+
resolve3(response2);
|
|
16237
16237
|
return;
|
|
16238
16238
|
}
|
|
16239
16239
|
const send = (parsedURL.protocol === "https:" ? https : http2).request;
|
|
@@ -16355,7 +16355,7 @@ async function fetch2(url2, options_) {
|
|
|
16355
16355
|
if (responseReferrerPolicy) {
|
|
16356
16356
|
requestOptions.referrerPolicy = responseReferrerPolicy;
|
|
16357
16357
|
}
|
|
16358
|
-
|
|
16358
|
+
resolve3(fetch2(new Request(locationURL, requestOptions)));
|
|
16359
16359
|
finalize2();
|
|
16360
16360
|
return;
|
|
16361
16361
|
}
|
|
@@ -16388,7 +16388,7 @@ async function fetch2(url2, options_) {
|
|
|
16388
16388
|
const codings = headers.get("Content-Encoding");
|
|
16389
16389
|
if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
|
|
16390
16390
|
response = new Response2(body, responseOptions);
|
|
16391
|
-
|
|
16391
|
+
resolve3(response);
|
|
16392
16392
|
return;
|
|
16393
16393
|
}
|
|
16394
16394
|
const zlibOptions = {
|
|
@@ -16402,7 +16402,7 @@ async function fetch2(url2, options_) {
|
|
|
16402
16402
|
}
|
|
16403
16403
|
});
|
|
16404
16404
|
response = new Response2(body, responseOptions);
|
|
16405
|
-
|
|
16405
|
+
resolve3(response);
|
|
16406
16406
|
return;
|
|
16407
16407
|
}
|
|
16408
16408
|
if (codings === "deflate" || codings === "x-deflate") {
|
|
@@ -16426,12 +16426,12 @@ async function fetch2(url2, options_) {
|
|
|
16426
16426
|
});
|
|
16427
16427
|
}
|
|
16428
16428
|
response = new Response2(body, responseOptions);
|
|
16429
|
-
|
|
16429
|
+
resolve3(response);
|
|
16430
16430
|
});
|
|
16431
16431
|
raw.once("end", () => {
|
|
16432
16432
|
if (!response) {
|
|
16433
16433
|
response = new Response2(body, responseOptions);
|
|
16434
|
-
|
|
16434
|
+
resolve3(response);
|
|
16435
16435
|
}
|
|
16436
16436
|
});
|
|
16437
16437
|
return;
|
|
@@ -16443,11 +16443,11 @@ async function fetch2(url2, options_) {
|
|
|
16443
16443
|
}
|
|
16444
16444
|
});
|
|
16445
16445
|
response = new Response2(body, responseOptions);
|
|
16446
|
-
|
|
16446
|
+
resolve3(response);
|
|
16447
16447
|
return;
|
|
16448
16448
|
}
|
|
16449
16449
|
response = new Response2(body, responseOptions);
|
|
16450
|
-
|
|
16450
|
+
resolve3(response);
|
|
16451
16451
|
});
|
|
16452
16452
|
writeToStream(request_, request).catch(reject);
|
|
16453
16453
|
});
|
|
@@ -22359,7 +22359,7 @@ var require_jwtaccess = __commonJS((exports) => {
|
|
|
22359
22359
|
}
|
|
22360
22360
|
}
|
|
22361
22361
|
fromStreamAsync(inputStream) {
|
|
22362
|
-
return new Promise((
|
|
22362
|
+
return new Promise((resolve3, reject) => {
|
|
22363
22363
|
if (!inputStream) {
|
|
22364
22364
|
reject(new Error("Must pass in a stream containing the service account auth settings."));
|
|
22365
22365
|
}
|
|
@@ -22368,7 +22368,7 @@ var require_jwtaccess = __commonJS((exports) => {
|
|
|
22368
22368
|
try {
|
|
22369
22369
|
const data = JSON.parse(s2);
|
|
22370
22370
|
this.fromJSON(data);
|
|
22371
|
-
|
|
22371
|
+
resolve3();
|
|
22372
22372
|
} catch (err) {
|
|
22373
22373
|
reject(err);
|
|
22374
22374
|
}
|
|
@@ -22554,7 +22554,7 @@ var require_jwtclient = __commonJS((exports) => {
|
|
|
22554
22554
|
}
|
|
22555
22555
|
}
|
|
22556
22556
|
fromStreamAsync(inputStream) {
|
|
22557
|
-
return new Promise((
|
|
22557
|
+
return new Promise((resolve3, reject) => {
|
|
22558
22558
|
if (!inputStream) {
|
|
22559
22559
|
throw new Error("Must pass in a stream containing the service account auth settings.");
|
|
22560
22560
|
}
|
|
@@ -22563,7 +22563,7 @@ var require_jwtclient = __commonJS((exports) => {
|
|
|
22563
22563
|
try {
|
|
22564
22564
|
const data = JSON.parse(s2);
|
|
22565
22565
|
this.fromJSON(data);
|
|
22566
|
-
|
|
22566
|
+
resolve3();
|
|
22567
22567
|
} catch (e2) {
|
|
22568
22568
|
reject(e2);
|
|
22569
22569
|
}
|
|
@@ -22663,7 +22663,7 @@ var require_refreshclient = __commonJS((exports) => {
|
|
|
22663
22663
|
}
|
|
22664
22664
|
}
|
|
22665
22665
|
async fromStreamAsync(inputStream) {
|
|
22666
|
-
return new Promise((
|
|
22666
|
+
return new Promise((resolve3, reject) => {
|
|
22667
22667
|
if (!inputStream) {
|
|
22668
22668
|
return reject(new Error("Must pass in a stream containing the user refresh token."));
|
|
22669
22669
|
}
|
|
@@ -22672,7 +22672,7 @@ var require_refreshclient = __commonJS((exports) => {
|
|
|
22672
22672
|
try {
|
|
22673
22673
|
const data = JSON.parse(s2);
|
|
22674
22674
|
this.fromJSON(data);
|
|
22675
|
-
return
|
|
22675
|
+
return resolve3();
|
|
22676
22676
|
} catch (err) {
|
|
22677
22677
|
return reject(err);
|
|
22678
22678
|
}
|
|
@@ -24028,7 +24028,7 @@ var require_pluggable_auth_handler = __commonJS((exports) => {
|
|
|
24028
24028
|
this.outputFile = options.outputFile;
|
|
24029
24029
|
}
|
|
24030
24030
|
retrieveResponseFromExecutable(envMap) {
|
|
24031
|
-
return new Promise((
|
|
24031
|
+
return new Promise((resolve3, reject) => {
|
|
24032
24032
|
const child = childProcess.spawn(this.commandComponents[0], this.commandComponents.slice(1), {
|
|
24033
24033
|
env: { ...process.env, ...Object.fromEntries(envMap) }
|
|
24034
24034
|
});
|
|
@@ -24050,7 +24050,7 @@ var require_pluggable_auth_handler = __commonJS((exports) => {
|
|
|
24050
24050
|
try {
|
|
24051
24051
|
const responseJson = JSON.parse(output);
|
|
24052
24052
|
const response = new executable_response_1.ExecutableResponse(responseJson);
|
|
24053
|
-
return
|
|
24053
|
+
return resolve3(response);
|
|
24054
24054
|
} catch (error48) {
|
|
24055
24055
|
if (error48 instanceof executable_response_1.ExecutableResponseError) {
|
|
24056
24056
|
return reject(error48);
|
|
@@ -24701,7 +24701,7 @@ var require_googleauth = __commonJS((exports) => {
|
|
|
24701
24701
|
}
|
|
24702
24702
|
}
|
|
24703
24703
|
fromStreamAsync(inputStream, options) {
|
|
24704
|
-
return new Promise((
|
|
24704
|
+
return new Promise((resolve3, reject) => {
|
|
24705
24705
|
if (!inputStream) {
|
|
24706
24706
|
throw new Error("Must pass in a stream containing the Google auth settings.");
|
|
24707
24707
|
}
|
|
@@ -24711,7 +24711,7 @@ var require_googleauth = __commonJS((exports) => {
|
|
|
24711
24711
|
try {
|
|
24712
24712
|
const data = JSON.parse(chunks.join(""));
|
|
24713
24713
|
const r2 = this._cacheClientFromJSON(data, options);
|
|
24714
|
-
return
|
|
24714
|
+
return resolve3(r2);
|
|
24715
24715
|
} catch (err) {
|
|
24716
24716
|
if (!this.keyFilename)
|
|
24717
24717
|
throw err;
|
|
@@ -24721,7 +24721,7 @@ var require_googleauth = __commonJS((exports) => {
|
|
|
24721
24721
|
});
|
|
24722
24722
|
this.cachedCredential = client;
|
|
24723
24723
|
this.setGapicJWTValues(client);
|
|
24724
|
-
return
|
|
24724
|
+
return resolve3(client);
|
|
24725
24725
|
}
|
|
24726
24726
|
} catch (err) {
|
|
24727
24727
|
return reject(err);
|
|
@@ -24742,16 +24742,16 @@ var require_googleauth = __commonJS((exports) => {
|
|
|
24742
24742
|
return false;
|
|
24743
24743
|
}
|
|
24744
24744
|
async getDefaultServiceProjectId() {
|
|
24745
|
-
return new Promise((
|
|
24745
|
+
return new Promise((resolve3) => {
|
|
24746
24746
|
(0, child_process_1.exec)("gcloud config config-helper --format json", (err, stdout) => {
|
|
24747
24747
|
if (!err && stdout) {
|
|
24748
24748
|
try {
|
|
24749
24749
|
const projectId = JSON.parse(stdout).configuration.properties.core.project;
|
|
24750
|
-
|
|
24750
|
+
resolve3(projectId);
|
|
24751
24751
|
return;
|
|
24752
24752
|
} catch (e2) {}
|
|
24753
24753
|
}
|
|
24754
|
-
|
|
24754
|
+
resolve3(null);
|
|
24755
24755
|
});
|
|
24756
24756
|
});
|
|
24757
24757
|
}
|
|
@@ -35104,6 +35104,2290 @@ var require_mimeScore = __commonJS((exports, module) => {
|
|
|
35104
35104
|
};
|
|
35105
35105
|
});
|
|
35106
35106
|
|
|
35107
|
+
// ../../node_modules/sql.js/dist/sql-wasm.js
|
|
35108
|
+
var require_sql_wasm = __commonJS((exports, module) => {
|
|
35109
|
+
var __dirname = "/Users/xiliangchen/projects/polka-codes/node_modules/sql.js/dist";
|
|
35110
|
+
var initSqlJsPromise = undefined;
|
|
35111
|
+
var initSqlJs = function(moduleConfig) {
|
|
35112
|
+
if (initSqlJsPromise) {
|
|
35113
|
+
return initSqlJsPromise;
|
|
35114
|
+
}
|
|
35115
|
+
initSqlJsPromise = new Promise(function(resolveModule, reject) {
|
|
35116
|
+
var Module = typeof moduleConfig !== "undefined" ? moduleConfig : {};
|
|
35117
|
+
var originalOnAbortFunction = Module["onAbort"];
|
|
35118
|
+
Module["onAbort"] = function(errorThatCausedAbort) {
|
|
35119
|
+
reject(new Error(errorThatCausedAbort));
|
|
35120
|
+
if (originalOnAbortFunction) {
|
|
35121
|
+
originalOnAbortFunction(errorThatCausedAbort);
|
|
35122
|
+
}
|
|
35123
|
+
};
|
|
35124
|
+
Module["postRun"] = Module["postRun"] || [];
|
|
35125
|
+
Module["postRun"].push(function() {
|
|
35126
|
+
resolveModule(Module);
|
|
35127
|
+
});
|
|
35128
|
+
module = undefined;
|
|
35129
|
+
var f3;
|
|
35130
|
+
f3 ||= typeof Module != "undefined" ? Module : {};
|
|
35131
|
+
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";
|
|
35132
|
+
f3.onRuntimeInitialized = function() {
|
|
35133
|
+
function a(g, l) {
|
|
35134
|
+
switch (typeof l) {
|
|
35135
|
+
case "boolean":
|
|
35136
|
+
dc(g, l ? 1 : 0);
|
|
35137
|
+
break;
|
|
35138
|
+
case "number":
|
|
35139
|
+
ec(g, l);
|
|
35140
|
+
break;
|
|
35141
|
+
case "string":
|
|
35142
|
+
fc(g, l, -1, -1);
|
|
35143
|
+
break;
|
|
35144
|
+
case "object":
|
|
35145
|
+
if (l === null)
|
|
35146
|
+
lb(g);
|
|
35147
|
+
else if (l.length != null) {
|
|
35148
|
+
var n = da(l, ea);
|
|
35149
|
+
gc(g, n, l.length, -1);
|
|
35150
|
+
fa(n);
|
|
35151
|
+
} else
|
|
35152
|
+
va(g, "Wrong API use : tried to return a value of an unknown type (" + l + ").", -1);
|
|
35153
|
+
break;
|
|
35154
|
+
default:
|
|
35155
|
+
lb(g);
|
|
35156
|
+
}
|
|
35157
|
+
}
|
|
35158
|
+
function b(g, l) {
|
|
35159
|
+
for (var n = [], r2 = 0;r2 < g; r2 += 1) {
|
|
35160
|
+
var t2 = m2(l + 4 * r2, "i32"), y = hc(t2);
|
|
35161
|
+
if (y === 1 || y === 2)
|
|
35162
|
+
t2 = ic(t2);
|
|
35163
|
+
else if (y === 3)
|
|
35164
|
+
t2 = jc(t2);
|
|
35165
|
+
else if (y === 4) {
|
|
35166
|
+
y = t2;
|
|
35167
|
+
t2 = kc(y);
|
|
35168
|
+
y = lc(y);
|
|
35169
|
+
for (var L = new Uint8Array(t2), J = 0;J < t2; J += 1)
|
|
35170
|
+
L[J] = p[y + J];
|
|
35171
|
+
t2 = L;
|
|
35172
|
+
} else
|
|
35173
|
+
t2 = null;
|
|
35174
|
+
n.push(t2);
|
|
35175
|
+
}
|
|
35176
|
+
return n;
|
|
35177
|
+
}
|
|
35178
|
+
function c(g, l) {
|
|
35179
|
+
this.Qa = g;
|
|
35180
|
+
this.db = l;
|
|
35181
|
+
this.Oa = 1;
|
|
35182
|
+
this.lb = [];
|
|
35183
|
+
}
|
|
35184
|
+
function d(g, l) {
|
|
35185
|
+
this.db = l;
|
|
35186
|
+
l = ha(g) + 1;
|
|
35187
|
+
this.eb = ia(l);
|
|
35188
|
+
if (this.eb === null)
|
|
35189
|
+
throw Error("Unable to allocate memory for the SQL string");
|
|
35190
|
+
u(g, x2, this.eb, l);
|
|
35191
|
+
this.kb = this.eb;
|
|
35192
|
+
this.Za = this.pb = null;
|
|
35193
|
+
}
|
|
35194
|
+
function e2(g) {
|
|
35195
|
+
this.filename = "dbfile_" + (4294967295 * Math.random() >>> 0);
|
|
35196
|
+
if (g != null) {
|
|
35197
|
+
var l = this.filename, n = "/", r2 = l;
|
|
35198
|
+
n && (n = typeof n == "string" ? n : ja(n), r2 = l ? ka(n + "/" + l) : n);
|
|
35199
|
+
l = la(true, true);
|
|
35200
|
+
r2 = ma(r2, l);
|
|
35201
|
+
if (g) {
|
|
35202
|
+
if (typeof g == "string") {
|
|
35203
|
+
n = Array(g.length);
|
|
35204
|
+
for (var t2 = 0, y = g.length;t2 < y; ++t2)
|
|
35205
|
+
n[t2] = g.charCodeAt(t2);
|
|
35206
|
+
g = n;
|
|
35207
|
+
}
|
|
35208
|
+
na(r2, l | 146);
|
|
35209
|
+
n = oa(r2, 577);
|
|
35210
|
+
pa(n, g, 0, g.length, 0);
|
|
35211
|
+
qa(n);
|
|
35212
|
+
na(r2, l);
|
|
35213
|
+
}
|
|
35214
|
+
}
|
|
35215
|
+
this.handleError(q(this.filename, h2));
|
|
35216
|
+
this.db = m2(h2, "i32");
|
|
35217
|
+
ob(this.db);
|
|
35218
|
+
this.fb = {};
|
|
35219
|
+
this.Sa = {};
|
|
35220
|
+
}
|
|
35221
|
+
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", [
|
|
35222
|
+
"number",
|
|
35223
|
+
"number"
|
|
35224
|
+
]), 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"]);
|
|
35225
|
+
c.prototype.bind = function(g) {
|
|
35226
|
+
if (!this.Qa)
|
|
35227
|
+
throw "Statement closed";
|
|
35228
|
+
this.reset();
|
|
35229
|
+
return Array.isArray(g) ? this.Cb(g) : g != null && typeof g === "object" ? this.Db(g) : true;
|
|
35230
|
+
};
|
|
35231
|
+
c.prototype.step = function() {
|
|
35232
|
+
if (!this.Qa)
|
|
35233
|
+
throw "Statement closed";
|
|
35234
|
+
this.Oa = 1;
|
|
35235
|
+
var g = sc(this.Qa);
|
|
35236
|
+
switch (g) {
|
|
35237
|
+
case 100:
|
|
35238
|
+
return true;
|
|
35239
|
+
case 101:
|
|
35240
|
+
return false;
|
|
35241
|
+
default:
|
|
35242
|
+
throw this.db.handleError(g);
|
|
35243
|
+
}
|
|
35244
|
+
};
|
|
35245
|
+
c.prototype.wb = function(g) {
|
|
35246
|
+
g == null && (g = this.Oa, this.Oa += 1);
|
|
35247
|
+
return wc(this.Qa, g);
|
|
35248
|
+
};
|
|
35249
|
+
c.prototype.Gb = function(g) {
|
|
35250
|
+
g == null && (g = this.Oa, this.Oa += 1);
|
|
35251
|
+
g = sb(this.Qa, g);
|
|
35252
|
+
if (typeof BigInt !== "function")
|
|
35253
|
+
throw Error("BigInt is not supported");
|
|
35254
|
+
return BigInt(g);
|
|
35255
|
+
};
|
|
35256
|
+
c.prototype.Hb = function(g) {
|
|
35257
|
+
g == null && (g = this.Oa, this.Oa += 1);
|
|
35258
|
+
return sb(this.Qa, g);
|
|
35259
|
+
};
|
|
35260
|
+
c.prototype.getBlob = function(g) {
|
|
35261
|
+
g == null && (g = this.Oa, this.Oa += 1);
|
|
35262
|
+
var l = yc(this.Qa, g);
|
|
35263
|
+
g = xc(this.Qa, g);
|
|
35264
|
+
for (var n = new Uint8Array(l), r2 = 0;r2 < l; r2 += 1)
|
|
35265
|
+
n[r2] = p[g + r2];
|
|
35266
|
+
return n;
|
|
35267
|
+
};
|
|
35268
|
+
c.prototype.get = function(g, l) {
|
|
35269
|
+
l = l || {};
|
|
35270
|
+
g != null && this.bind(g) && this.step();
|
|
35271
|
+
g = [];
|
|
35272
|
+
for (var n = vc(this.Qa), r2 = 0;r2 < n; r2 += 1)
|
|
35273
|
+
switch (zc(this.Qa, r2)) {
|
|
35274
|
+
case 1:
|
|
35275
|
+
var t2 = l.useBigInt ? this.Gb(r2) : this.wb(r2);
|
|
35276
|
+
g.push(t2);
|
|
35277
|
+
break;
|
|
35278
|
+
case 2:
|
|
35279
|
+
g.push(this.wb(r2));
|
|
35280
|
+
break;
|
|
35281
|
+
case 3:
|
|
35282
|
+
g.push(this.Hb(r2));
|
|
35283
|
+
break;
|
|
35284
|
+
case 4:
|
|
35285
|
+
g.push(this.getBlob(r2));
|
|
35286
|
+
break;
|
|
35287
|
+
default:
|
|
35288
|
+
g.push(null);
|
|
35289
|
+
}
|
|
35290
|
+
return g;
|
|
35291
|
+
};
|
|
35292
|
+
c.prototype.getColumnNames = function() {
|
|
35293
|
+
for (var g = [], l = uc(this.Qa), n = 0;n < l; n += 1)
|
|
35294
|
+
g.push(Ac(this.Qa, n));
|
|
35295
|
+
return g;
|
|
35296
|
+
};
|
|
35297
|
+
c.prototype.getAsObject = function(g, l) {
|
|
35298
|
+
g = this.get(g, l);
|
|
35299
|
+
l = this.getColumnNames();
|
|
35300
|
+
for (var n = {}, r2 = 0;r2 < l.length; r2 += 1)
|
|
35301
|
+
n[l[r2]] = g[r2];
|
|
35302
|
+
return n;
|
|
35303
|
+
};
|
|
35304
|
+
c.prototype.getSQL = function() {
|
|
35305
|
+
return pb(this.Qa);
|
|
35306
|
+
};
|
|
35307
|
+
c.prototype.getNormalizedSQL = function() {
|
|
35308
|
+
return nc(this.Qa);
|
|
35309
|
+
};
|
|
35310
|
+
c.prototype.run = function(g) {
|
|
35311
|
+
g != null && this.bind(g);
|
|
35312
|
+
this.step();
|
|
35313
|
+
return this.reset();
|
|
35314
|
+
};
|
|
35315
|
+
c.prototype.sb = function(g, l) {
|
|
35316
|
+
l == null && (l = this.Oa, this.Oa += 1);
|
|
35317
|
+
g = ra(g);
|
|
35318
|
+
var n = da(g, ea);
|
|
35319
|
+
this.lb.push(n);
|
|
35320
|
+
this.db.handleError(oc(this.Qa, l, n, g.length - 1, 0));
|
|
35321
|
+
};
|
|
35322
|
+
c.prototype.Bb = function(g, l) {
|
|
35323
|
+
l == null && (l = this.Oa, this.Oa += 1);
|
|
35324
|
+
var n = da(g, ea);
|
|
35325
|
+
this.lb.push(n);
|
|
35326
|
+
this.db.handleError(rb(this.Qa, l, n, g.length, 0));
|
|
35327
|
+
};
|
|
35328
|
+
c.prototype.rb = function(g, l) {
|
|
35329
|
+
l == null && (l = this.Oa, this.Oa += 1);
|
|
35330
|
+
this.db.handleError((g === (g | 0) ? qc : pc)(this.Qa, l, g));
|
|
35331
|
+
};
|
|
35332
|
+
c.prototype.Eb = function(g) {
|
|
35333
|
+
g == null && (g = this.Oa, this.Oa += 1);
|
|
35334
|
+
rb(this.Qa, g, 0, 0, 0);
|
|
35335
|
+
};
|
|
35336
|
+
c.prototype.tb = function(g, l) {
|
|
35337
|
+
l == null && (l = this.Oa, this.Oa += 1);
|
|
35338
|
+
switch (typeof g) {
|
|
35339
|
+
case "string":
|
|
35340
|
+
this.sb(g, l);
|
|
35341
|
+
return;
|
|
35342
|
+
case "number":
|
|
35343
|
+
this.rb(g, l);
|
|
35344
|
+
return;
|
|
35345
|
+
case "bigint":
|
|
35346
|
+
this.sb(g.toString(), l);
|
|
35347
|
+
return;
|
|
35348
|
+
case "boolean":
|
|
35349
|
+
this.rb(g + 0, l);
|
|
35350
|
+
return;
|
|
35351
|
+
case "object":
|
|
35352
|
+
if (g === null) {
|
|
35353
|
+
this.Eb(l);
|
|
35354
|
+
return;
|
|
35355
|
+
}
|
|
35356
|
+
if (g.length != null) {
|
|
35357
|
+
this.Bb(g, l);
|
|
35358
|
+
return;
|
|
35359
|
+
}
|
|
35360
|
+
}
|
|
35361
|
+
throw "Wrong API use : tried to bind a value of an unknown type (" + g + ").";
|
|
35362
|
+
};
|
|
35363
|
+
c.prototype.Db = function(g) {
|
|
35364
|
+
var l = this;
|
|
35365
|
+
Object.keys(g).forEach(function(n) {
|
|
35366
|
+
var r2 = rc(l.Qa, n);
|
|
35367
|
+
r2 !== 0 && l.tb(g[n], r2);
|
|
35368
|
+
});
|
|
35369
|
+
return true;
|
|
35370
|
+
};
|
|
35371
|
+
c.prototype.Cb = function(g) {
|
|
35372
|
+
for (var l = 0;l < g.length; l += 1)
|
|
35373
|
+
this.tb(g[l], l + 1);
|
|
35374
|
+
return true;
|
|
35375
|
+
};
|
|
35376
|
+
c.prototype.reset = function() {
|
|
35377
|
+
this.freemem();
|
|
35378
|
+
return Cc(this.Qa) === 0 && Bc(this.Qa) === 0;
|
|
35379
|
+
};
|
|
35380
|
+
c.prototype.freemem = function() {
|
|
35381
|
+
for (var g;(g = this.lb.pop()) !== undefined; )
|
|
35382
|
+
fa(g);
|
|
35383
|
+
};
|
|
35384
|
+
c.prototype.free = function() {
|
|
35385
|
+
this.freemem();
|
|
35386
|
+
var g = Dc(this.Qa) === 0;
|
|
35387
|
+
delete this.db.fb[this.Qa];
|
|
35388
|
+
this.Qa = 0;
|
|
35389
|
+
return g;
|
|
35390
|
+
};
|
|
35391
|
+
d.prototype.next = function() {
|
|
35392
|
+
if (this.eb === null)
|
|
35393
|
+
return { done: true };
|
|
35394
|
+
this.Za !== null && (this.Za.free(), this.Za = null);
|
|
35395
|
+
if (!this.db.db)
|
|
35396
|
+
throw this.mb(), Error("Database closed");
|
|
35397
|
+
var g = sa(), l = z2(4);
|
|
35398
|
+
ta(h2);
|
|
35399
|
+
ta(l);
|
|
35400
|
+
try {
|
|
35401
|
+
this.db.handleError(qb(this.db.db, this.kb, -1, h2, l));
|
|
35402
|
+
this.kb = m2(l, "i32");
|
|
35403
|
+
var n = m2(h2, "i32");
|
|
35404
|
+
if (n === 0)
|
|
35405
|
+
return this.mb(), { done: true };
|
|
35406
|
+
this.Za = new c(n, this.db);
|
|
35407
|
+
this.db.fb[n] = this.Za;
|
|
35408
|
+
return { value: this.Za, done: false };
|
|
35409
|
+
} catch (r2) {
|
|
35410
|
+
throw this.pb = ua(this.kb), this.mb(), r2;
|
|
35411
|
+
} finally {
|
|
35412
|
+
wa(g);
|
|
35413
|
+
}
|
|
35414
|
+
};
|
|
35415
|
+
d.prototype.mb = function() {
|
|
35416
|
+
fa(this.eb);
|
|
35417
|
+
this.eb = null;
|
|
35418
|
+
};
|
|
35419
|
+
d.prototype.getRemainingSQL = function() {
|
|
35420
|
+
return this.pb !== null ? this.pb : ua(this.kb);
|
|
35421
|
+
};
|
|
35422
|
+
typeof Symbol === "function" && typeof Symbol.iterator === "symbol" && (d.prototype[Symbol.iterator] = function() {
|
|
35423
|
+
return this;
|
|
35424
|
+
});
|
|
35425
|
+
e2.prototype.run = function(g, l) {
|
|
35426
|
+
if (!this.db)
|
|
35427
|
+
throw "Database closed";
|
|
35428
|
+
if (l) {
|
|
35429
|
+
g = this.prepare(g, l);
|
|
35430
|
+
try {
|
|
35431
|
+
g.step();
|
|
35432
|
+
} finally {
|
|
35433
|
+
g.free();
|
|
35434
|
+
}
|
|
35435
|
+
} else
|
|
35436
|
+
this.handleError(v(this.db, g, 0, 0, h2));
|
|
35437
|
+
return this;
|
|
35438
|
+
};
|
|
35439
|
+
e2.prototype.exec = function(g, l, n) {
|
|
35440
|
+
if (!this.db)
|
|
35441
|
+
throw "Database closed";
|
|
35442
|
+
var r2 = sa(), t2 = null;
|
|
35443
|
+
try {
|
|
35444
|
+
var y = xa(g), L = z2(4);
|
|
35445
|
+
for (g = [];m2(y, "i8") !== 0; ) {
|
|
35446
|
+
ta(h2);
|
|
35447
|
+
ta(L);
|
|
35448
|
+
this.handleError(qb(this.db, y, -1, h2, L));
|
|
35449
|
+
var J = m2(h2, "i32");
|
|
35450
|
+
y = m2(L, "i32");
|
|
35451
|
+
if (J !== 0) {
|
|
35452
|
+
var I = null;
|
|
35453
|
+
t2 = new c(J, this);
|
|
35454
|
+
for (l != null && t2.bind(l);t2.step(); )
|
|
35455
|
+
I === null && (I = { columns: t2.getColumnNames(), values: [] }, g.push(I)), I.values.push(t2.get(null, n));
|
|
35456
|
+
t2.free();
|
|
35457
|
+
}
|
|
35458
|
+
}
|
|
35459
|
+
return g;
|
|
35460
|
+
} catch (M) {
|
|
35461
|
+
throw t2 && t2.free(), M;
|
|
35462
|
+
} finally {
|
|
35463
|
+
wa(r2);
|
|
35464
|
+
}
|
|
35465
|
+
};
|
|
35466
|
+
e2.prototype.each = function(g, l, n, r2, t2) {
|
|
35467
|
+
typeof l === "function" && (r2 = n, n = l, l = undefined);
|
|
35468
|
+
g = this.prepare(g, l);
|
|
35469
|
+
try {
|
|
35470
|
+
for (;g.step(); )
|
|
35471
|
+
n(g.getAsObject(null, t2));
|
|
35472
|
+
} finally {
|
|
35473
|
+
g.free();
|
|
35474
|
+
}
|
|
35475
|
+
if (typeof r2 === "function")
|
|
35476
|
+
return r2();
|
|
35477
|
+
};
|
|
35478
|
+
e2.prototype.prepare = function(g, l) {
|
|
35479
|
+
ta(h2);
|
|
35480
|
+
this.handleError(G(this.db, g, -1, h2, 0));
|
|
35481
|
+
g = m2(h2, "i32");
|
|
35482
|
+
if (g === 0)
|
|
35483
|
+
throw "Nothing to prepare";
|
|
35484
|
+
var n = new c(g, this);
|
|
35485
|
+
l != null && n.bind(l);
|
|
35486
|
+
return this.fb[g] = n;
|
|
35487
|
+
};
|
|
35488
|
+
e2.prototype.iterateStatements = function(g) {
|
|
35489
|
+
return new d(g, this);
|
|
35490
|
+
};
|
|
35491
|
+
e2.prototype["export"] = function() {
|
|
35492
|
+
Object.values(this.fb).forEach(function(l) {
|
|
35493
|
+
l.free();
|
|
35494
|
+
});
|
|
35495
|
+
Object.values(this.Sa).forEach(A2);
|
|
35496
|
+
this.Sa = {};
|
|
35497
|
+
this.handleError(w(this.db));
|
|
35498
|
+
var g = ya(this.filename);
|
|
35499
|
+
this.handleError(q(this.filename, h2));
|
|
35500
|
+
this.db = m2(h2, "i32");
|
|
35501
|
+
ob(this.db);
|
|
35502
|
+
return g;
|
|
35503
|
+
};
|
|
35504
|
+
e2.prototype.close = function() {
|
|
35505
|
+
this.db !== null && (Object.values(this.fb).forEach(function(g) {
|
|
35506
|
+
g.free();
|
|
35507
|
+
}), 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);
|
|
35508
|
+
};
|
|
35509
|
+
e2.prototype.handleError = function(g) {
|
|
35510
|
+
if (g === 0)
|
|
35511
|
+
return null;
|
|
35512
|
+
g = tc(this.db);
|
|
35513
|
+
throw Error(g);
|
|
35514
|
+
};
|
|
35515
|
+
e2.prototype.getRowsModified = function() {
|
|
35516
|
+
return C(this.db);
|
|
35517
|
+
};
|
|
35518
|
+
e2.prototype.create_function = function(g, l) {
|
|
35519
|
+
Object.prototype.hasOwnProperty.call(this.Sa, g) && (A2(this.Sa[g]), delete this.Sa[g]);
|
|
35520
|
+
var n = Aa(function(r2, t2, y) {
|
|
35521
|
+
t2 = b(t2, y);
|
|
35522
|
+
try {
|
|
35523
|
+
var L = l.apply(null, t2);
|
|
35524
|
+
} catch (J) {
|
|
35525
|
+
va(r2, J, -1);
|
|
35526
|
+
return;
|
|
35527
|
+
}
|
|
35528
|
+
a(r2, L);
|
|
35529
|
+
}, "viii");
|
|
35530
|
+
this.Sa[g] = n;
|
|
35531
|
+
this.handleError(tb(this.db, g, l.length, 1, 0, n, 0, 0, 0));
|
|
35532
|
+
return this;
|
|
35533
|
+
};
|
|
35534
|
+
e2.prototype.create_aggregate = function(g, l) {
|
|
35535
|
+
var n = l.init || function() {
|
|
35536
|
+
return null;
|
|
35537
|
+
}, r2 = l.finalize || function(I) {
|
|
35538
|
+
return I;
|
|
35539
|
+
}, t2 = l.step;
|
|
35540
|
+
if (!t2)
|
|
35541
|
+
throw "An aggregate function must have a step function in " + g;
|
|
35542
|
+
var y = {};
|
|
35543
|
+
Object.hasOwnProperty.call(this.Sa, g) && (A2(this.Sa[g]), delete this.Sa[g]);
|
|
35544
|
+
l = g + "__finalize";
|
|
35545
|
+
Object.hasOwnProperty.call(this.Sa, l) && (A2(this.Sa[l]), delete this.Sa[l]);
|
|
35546
|
+
var L = Aa(function(I, M, Ra) {
|
|
35547
|
+
var X = ub(I, 1);
|
|
35548
|
+
Object.hasOwnProperty.call(y, X) || (y[X] = n());
|
|
35549
|
+
M = b(M, Ra);
|
|
35550
|
+
M = [y[X]].concat(M);
|
|
35551
|
+
try {
|
|
35552
|
+
y[X] = t2.apply(null, M);
|
|
35553
|
+
} catch (Fc) {
|
|
35554
|
+
delete y[X], va(I, Fc, -1);
|
|
35555
|
+
}
|
|
35556
|
+
}, "viii"), J = Aa(function(I) {
|
|
35557
|
+
var M = ub(I, 1);
|
|
35558
|
+
try {
|
|
35559
|
+
var Ra = r2(y[M]);
|
|
35560
|
+
} catch (X) {
|
|
35561
|
+
delete y[M];
|
|
35562
|
+
va(I, X, -1);
|
|
35563
|
+
return;
|
|
35564
|
+
}
|
|
35565
|
+
a(I, Ra);
|
|
35566
|
+
delete y[M];
|
|
35567
|
+
}, "vi");
|
|
35568
|
+
this.Sa[g] = L;
|
|
35569
|
+
this.Sa[l] = J;
|
|
35570
|
+
this.handleError(tb(this.db, g, t2.length - 1, 1, 0, 0, L, J, 0));
|
|
35571
|
+
return this;
|
|
35572
|
+
};
|
|
35573
|
+
e2.prototype.updateHook = function(g) {
|
|
35574
|
+
this.Ya && (vb(this.db, 0, 0), A2(this.Ya), this.Ya = undefined);
|
|
35575
|
+
g && (this.Ya = Aa(function(l, n, r2, t2, y) {
|
|
35576
|
+
switch (n) {
|
|
35577
|
+
case 18:
|
|
35578
|
+
l = "insert";
|
|
35579
|
+
break;
|
|
35580
|
+
case 23:
|
|
35581
|
+
l = "update";
|
|
35582
|
+
break;
|
|
35583
|
+
case 9:
|
|
35584
|
+
l = "delete";
|
|
35585
|
+
break;
|
|
35586
|
+
default:
|
|
35587
|
+
throw "unknown operationCode in updateHook callback: " + n;
|
|
35588
|
+
}
|
|
35589
|
+
r2 = r2 ? B(x2, r2) : "";
|
|
35590
|
+
t2 = t2 ? B(x2, t2) : "";
|
|
35591
|
+
if (y > Number.MAX_SAFE_INTEGER)
|
|
35592
|
+
throw "rowId too big to fit inside a Number";
|
|
35593
|
+
g(l, r2, t2, Number(y));
|
|
35594
|
+
}, "viiiij"), vb(this.db, this.Ya, 0));
|
|
35595
|
+
};
|
|
35596
|
+
f3.Database = e2;
|
|
35597
|
+
};
|
|
35598
|
+
var Ba = { ...f3 }, Ca = "./this.program", Da = (a, b) => {
|
|
35599
|
+
throw b;
|
|
35600
|
+
}, D = "", Ea, Fa;
|
|
35601
|
+
if (ca) {
|
|
35602
|
+
var fs4 = __require("fs");
|
|
35603
|
+
__require("path");
|
|
35604
|
+
D = __dirname + "/";
|
|
35605
|
+
Fa = (a) => {
|
|
35606
|
+
a = Ga(a) ? new URL(a) : a;
|
|
35607
|
+
return fs4.readFileSync(a);
|
|
35608
|
+
};
|
|
35609
|
+
Ea = async (a) => {
|
|
35610
|
+
a = Ga(a) ? new URL(a) : a;
|
|
35611
|
+
return fs4.readFileSync(a, undefined);
|
|
35612
|
+
};
|
|
35613
|
+
!f3.thisProgram && 1 < process.argv.length && (Ca = process.argv[1].replace(/\\/g, "/"));
|
|
35614
|
+
process.argv.slice(2);
|
|
35615
|
+
typeof module != "undefined" && (module.exports = f3);
|
|
35616
|
+
Da = (a, b) => {
|
|
35617
|
+
process.exitCode = a;
|
|
35618
|
+
throw b;
|
|
35619
|
+
};
|
|
35620
|
+
} else if (aa || ba)
|
|
35621
|
+
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) => {
|
|
35622
|
+
var b = new XMLHttpRequest;
|
|
35623
|
+
b.open("GET", a, false);
|
|
35624
|
+
b.responseType = "arraybuffer";
|
|
35625
|
+
b.send(null);
|
|
35626
|
+
return new Uint8Array(b.response);
|
|
35627
|
+
}), Ea = async (a) => {
|
|
35628
|
+
if (Ga(a))
|
|
35629
|
+
return new Promise((c, d) => {
|
|
35630
|
+
var e2 = new XMLHttpRequest;
|
|
35631
|
+
e2.open("GET", a, true);
|
|
35632
|
+
e2.responseType = "arraybuffer";
|
|
35633
|
+
e2.onload = () => {
|
|
35634
|
+
e2.status == 200 || e2.status == 0 && e2.response ? c(e2.response) : d(e2.status);
|
|
35635
|
+
};
|
|
35636
|
+
e2.onerror = d;
|
|
35637
|
+
e2.send(null);
|
|
35638
|
+
});
|
|
35639
|
+
var b = await fetch(a, { credentials: "same-origin" });
|
|
35640
|
+
if (b.ok)
|
|
35641
|
+
return b.arrayBuffer();
|
|
35642
|
+
throw Error(b.status + " : " + b.url);
|
|
35643
|
+
};
|
|
35644
|
+
var Ha = f3.print || console.log.bind(console), Ia = f3.printErr || console.error.bind(console);
|
|
35645
|
+
Object.assign(f3, Ba);
|
|
35646
|
+
Ba = null;
|
|
35647
|
+
f3.thisProgram && (Ca = f3.thisProgram);
|
|
35648
|
+
var Ja = f3.wasmBinary, Ka, La = false, Ma, p, x2, Na, E, F2, Oa, H, Pa, Ga = (a) => a.startsWith("file://");
|
|
35649
|
+
function Qa() {
|
|
35650
|
+
var a = Ka.buffer;
|
|
35651
|
+
f3.HEAP8 = p = new Int8Array(a);
|
|
35652
|
+
f3.HEAP16 = Na = new Int16Array(a);
|
|
35653
|
+
f3.HEAPU8 = x2 = new Uint8Array(a);
|
|
35654
|
+
f3.HEAPU16 = new Uint16Array(a);
|
|
35655
|
+
f3.HEAP32 = E = new Int32Array(a);
|
|
35656
|
+
f3.HEAPU32 = F2 = new Uint32Array(a);
|
|
35657
|
+
f3.HEAPF32 = Oa = new Float32Array(a);
|
|
35658
|
+
f3.HEAPF64 = Pa = new Float64Array(a);
|
|
35659
|
+
f3.HEAP64 = H = new BigInt64Array(a);
|
|
35660
|
+
f3.HEAPU64 = new BigUint64Array(a);
|
|
35661
|
+
}
|
|
35662
|
+
var K = 0, Sa = null;
|
|
35663
|
+
function Ta(a) {
|
|
35664
|
+
f3.onAbort?.(a);
|
|
35665
|
+
a = "Aborted(" + a + ")";
|
|
35666
|
+
Ia(a);
|
|
35667
|
+
La = true;
|
|
35668
|
+
throw new WebAssembly.RuntimeError(a + ". Build with -sASSERTIONS for more info.");
|
|
35669
|
+
}
|
|
35670
|
+
var Ua;
|
|
35671
|
+
async function Va(a) {
|
|
35672
|
+
if (!Ja)
|
|
35673
|
+
try {
|
|
35674
|
+
var b = await Ea(a);
|
|
35675
|
+
return new Uint8Array(b);
|
|
35676
|
+
} catch {}
|
|
35677
|
+
if (a == Ua && Ja)
|
|
35678
|
+
a = new Uint8Array(Ja);
|
|
35679
|
+
else if (Fa)
|
|
35680
|
+
a = Fa(a);
|
|
35681
|
+
else
|
|
35682
|
+
throw "both async and sync fetching of the wasm failed";
|
|
35683
|
+
return a;
|
|
35684
|
+
}
|
|
35685
|
+
async function Wa(a, b) {
|
|
35686
|
+
try {
|
|
35687
|
+
var c = await Va(a);
|
|
35688
|
+
return await WebAssembly.instantiate(c, b);
|
|
35689
|
+
} catch (d) {
|
|
35690
|
+
Ia(`failed to asynchronously prepare wasm: ${d}`), Ta(d);
|
|
35691
|
+
}
|
|
35692
|
+
}
|
|
35693
|
+
async function Xa(a) {
|
|
35694
|
+
var b = Ua;
|
|
35695
|
+
if (!Ja && typeof WebAssembly.instantiateStreaming == "function" && !Ga(b) && !ca)
|
|
35696
|
+
try {
|
|
35697
|
+
var c = fetch(b, { credentials: "same-origin" });
|
|
35698
|
+
return await WebAssembly.instantiateStreaming(c, a);
|
|
35699
|
+
} catch (d) {
|
|
35700
|
+
Ia(`wasm streaming compile failed: ${d}`), Ia("falling back to ArrayBuffer instantiation");
|
|
35701
|
+
}
|
|
35702
|
+
return Wa(b, a);
|
|
35703
|
+
}
|
|
35704
|
+
|
|
35705
|
+
class Ya {
|
|
35706
|
+
name = "ExitStatus";
|
|
35707
|
+
constructor(a) {
|
|
35708
|
+
this.message = `Program terminated with exit(${a})`;
|
|
35709
|
+
this.status = a;
|
|
35710
|
+
}
|
|
35711
|
+
}
|
|
35712
|
+
var Za = (a) => {
|
|
35713
|
+
for (;0 < a.length; )
|
|
35714
|
+
a.shift()(f3);
|
|
35715
|
+
}, $a = [], ab = [], bb = () => {
|
|
35716
|
+
var a = f3.preRun.shift();
|
|
35717
|
+
ab.unshift(a);
|
|
35718
|
+
};
|
|
35719
|
+
function m2(a, b = "i8") {
|
|
35720
|
+
b.endsWith("*") && (b = "*");
|
|
35721
|
+
switch (b) {
|
|
35722
|
+
case "i1":
|
|
35723
|
+
return p[a];
|
|
35724
|
+
case "i8":
|
|
35725
|
+
return p[a];
|
|
35726
|
+
case "i16":
|
|
35727
|
+
return Na[a >> 1];
|
|
35728
|
+
case "i32":
|
|
35729
|
+
return E[a >> 2];
|
|
35730
|
+
case "i64":
|
|
35731
|
+
return H[a >> 3];
|
|
35732
|
+
case "float":
|
|
35733
|
+
return Oa[a >> 2];
|
|
35734
|
+
case "double":
|
|
35735
|
+
return Pa[a >> 3];
|
|
35736
|
+
case "*":
|
|
35737
|
+
return F2[a >> 2];
|
|
35738
|
+
default:
|
|
35739
|
+
Ta(`invalid type for getValue: ${b}`);
|
|
35740
|
+
}
|
|
35741
|
+
}
|
|
35742
|
+
var cb = f3.noExitRuntime || true;
|
|
35743
|
+
function ta(a) {
|
|
35744
|
+
var b = "i32";
|
|
35745
|
+
b.endsWith("*") && (b = "*");
|
|
35746
|
+
switch (b) {
|
|
35747
|
+
case "i1":
|
|
35748
|
+
p[a] = 0;
|
|
35749
|
+
break;
|
|
35750
|
+
case "i8":
|
|
35751
|
+
p[a] = 0;
|
|
35752
|
+
break;
|
|
35753
|
+
case "i16":
|
|
35754
|
+
Na[a >> 1] = 0;
|
|
35755
|
+
break;
|
|
35756
|
+
case "i32":
|
|
35757
|
+
E[a >> 2] = 0;
|
|
35758
|
+
break;
|
|
35759
|
+
case "i64":
|
|
35760
|
+
H[a >> 3] = BigInt(0);
|
|
35761
|
+
break;
|
|
35762
|
+
case "float":
|
|
35763
|
+
Oa[a >> 2] = 0;
|
|
35764
|
+
break;
|
|
35765
|
+
case "double":
|
|
35766
|
+
Pa[a >> 3] = 0;
|
|
35767
|
+
break;
|
|
35768
|
+
case "*":
|
|
35769
|
+
F2[a >> 2] = 0;
|
|
35770
|
+
break;
|
|
35771
|
+
default:
|
|
35772
|
+
Ta(`invalid type for setValue: ${b}`);
|
|
35773
|
+
}
|
|
35774
|
+
}
|
|
35775
|
+
var db2 = typeof TextDecoder != "undefined" ? new TextDecoder : undefined, B = (a, b = 0, c = NaN) => {
|
|
35776
|
+
var d = b + c;
|
|
35777
|
+
for (c = b;a[c] && !(c >= d); )
|
|
35778
|
+
++c;
|
|
35779
|
+
if (16 < c - b && a.buffer && db2)
|
|
35780
|
+
return db2.decode(a.subarray(b, c));
|
|
35781
|
+
for (d = "";b < c; ) {
|
|
35782
|
+
var e2 = a[b++];
|
|
35783
|
+
if (e2 & 128) {
|
|
35784
|
+
var h2 = a[b++] & 63;
|
|
35785
|
+
if ((e2 & 224) == 192)
|
|
35786
|
+
d += String.fromCharCode((e2 & 31) << 6 | h2);
|
|
35787
|
+
else {
|
|
35788
|
+
var k = a[b++] & 63;
|
|
35789
|
+
e2 = (e2 & 240) == 224 ? (e2 & 15) << 12 | h2 << 6 | k : (e2 & 7) << 18 | h2 << 12 | k << 6 | a[b++] & 63;
|
|
35790
|
+
65536 > e2 ? d += String.fromCharCode(e2) : (e2 -= 65536, d += String.fromCharCode(55296 | e2 >> 10, 56320 | e2 & 1023));
|
|
35791
|
+
}
|
|
35792
|
+
} else
|
|
35793
|
+
d += String.fromCharCode(e2);
|
|
35794
|
+
}
|
|
35795
|
+
return d;
|
|
35796
|
+
}, ua = (a, b) => a ? B(x2, a, b) : "", eb = (a, b) => {
|
|
35797
|
+
for (var c = 0, d = a.length - 1;0 <= d; d--) {
|
|
35798
|
+
var e2 = a[d];
|
|
35799
|
+
e2 === "." ? a.splice(d, 1) : e2 === ".." ? (a.splice(d, 1), c++) : c && (a.splice(d, 1), c--);
|
|
35800
|
+
}
|
|
35801
|
+
if (b)
|
|
35802
|
+
for (;c; c--)
|
|
35803
|
+
a.unshift("..");
|
|
35804
|
+
return a;
|
|
35805
|
+
}, ka = (a) => {
|
|
35806
|
+
var b = a.charAt(0) === "/", c = a.slice(-1) === "/";
|
|
35807
|
+
(a = eb(a.split("/").filter((d) => !!d), !b).join("/")) || b || (a = ".");
|
|
35808
|
+
a && c && (a += "/");
|
|
35809
|
+
return (b ? "/" : "") + a;
|
|
35810
|
+
}, fb = (a) => {
|
|
35811
|
+
var b = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);
|
|
35812
|
+
a = b[0];
|
|
35813
|
+
b = b[1];
|
|
35814
|
+
if (!a && !b)
|
|
35815
|
+
return ".";
|
|
35816
|
+
b &&= b.slice(0, -1);
|
|
35817
|
+
return a + b;
|
|
35818
|
+
}, gb = (a) => a && a.match(/([^\/]+|\/)\/*$/)[1], hb = () => {
|
|
35819
|
+
if (ca) {
|
|
35820
|
+
var a = __require("crypto");
|
|
35821
|
+
return (b) => a.randomFillSync(b);
|
|
35822
|
+
}
|
|
35823
|
+
return (b) => crypto.getRandomValues(b);
|
|
35824
|
+
}, ib = (a) => {
|
|
35825
|
+
(ib = hb())(a);
|
|
35826
|
+
}, jb = (...a) => {
|
|
35827
|
+
for (var b = "", c = false, d = a.length - 1;-1 <= d && !c; d--) {
|
|
35828
|
+
c = 0 <= d ? a[d] : "/";
|
|
35829
|
+
if (typeof c != "string")
|
|
35830
|
+
throw new TypeError("Arguments to path.resolve must be strings");
|
|
35831
|
+
if (!c)
|
|
35832
|
+
return "";
|
|
35833
|
+
b = c + "/" + b;
|
|
35834
|
+
c = c.charAt(0) === "/";
|
|
35835
|
+
}
|
|
35836
|
+
b = eb(b.split("/").filter((e2) => !!e2), !c).join("/");
|
|
35837
|
+
return (c ? "/" : "") + b || ".";
|
|
35838
|
+
}, kb = [], ha = (a) => {
|
|
35839
|
+
for (var b = 0, c = 0;c < a.length; ++c) {
|
|
35840
|
+
var d = a.charCodeAt(c);
|
|
35841
|
+
127 >= d ? b++ : 2047 >= d ? b += 2 : 55296 <= d && 57343 >= d ? (b += 4, ++c) : b += 3;
|
|
35842
|
+
}
|
|
35843
|
+
return b;
|
|
35844
|
+
}, u = (a, b, c, d) => {
|
|
35845
|
+
if (!(0 < d))
|
|
35846
|
+
return 0;
|
|
35847
|
+
var e2 = c;
|
|
35848
|
+
d = c + d - 1;
|
|
35849
|
+
for (var h2 = 0;h2 < a.length; ++h2) {
|
|
35850
|
+
var k = a.charCodeAt(h2);
|
|
35851
|
+
if (55296 <= k && 57343 >= k) {
|
|
35852
|
+
var q = a.charCodeAt(++h2);
|
|
35853
|
+
k = 65536 + ((k & 1023) << 10) | q & 1023;
|
|
35854
|
+
}
|
|
35855
|
+
if (127 >= k) {
|
|
35856
|
+
if (c >= d)
|
|
35857
|
+
break;
|
|
35858
|
+
b[c++] = k;
|
|
35859
|
+
} else {
|
|
35860
|
+
if (2047 >= k) {
|
|
35861
|
+
if (c + 1 >= d)
|
|
35862
|
+
break;
|
|
35863
|
+
b[c++] = 192 | k >> 6;
|
|
35864
|
+
} else {
|
|
35865
|
+
if (65535 >= k) {
|
|
35866
|
+
if (c + 2 >= d)
|
|
35867
|
+
break;
|
|
35868
|
+
b[c++] = 224 | k >> 12;
|
|
35869
|
+
} else {
|
|
35870
|
+
if (c + 3 >= d)
|
|
35871
|
+
break;
|
|
35872
|
+
b[c++] = 240 | k >> 18;
|
|
35873
|
+
b[c++] = 128 | k >> 12 & 63;
|
|
35874
|
+
}
|
|
35875
|
+
b[c++] = 128 | k >> 6 & 63;
|
|
35876
|
+
}
|
|
35877
|
+
b[c++] = 128 | k & 63;
|
|
35878
|
+
}
|
|
35879
|
+
}
|
|
35880
|
+
b[c] = 0;
|
|
35881
|
+
return c - e2;
|
|
35882
|
+
}, ra = (a, b) => {
|
|
35883
|
+
var c = Array(ha(a) + 1);
|
|
35884
|
+
a = u(a, c, 0, c.length);
|
|
35885
|
+
b && (c.length = a);
|
|
35886
|
+
return c;
|
|
35887
|
+
}, mb = [];
|
|
35888
|
+
function nb(a, b) {
|
|
35889
|
+
mb[a] = { input: [], output: [], cb: b };
|
|
35890
|
+
wb(a, xb);
|
|
35891
|
+
}
|
|
35892
|
+
var xb = { open(a) {
|
|
35893
|
+
var b = mb[a.node.rdev];
|
|
35894
|
+
if (!b)
|
|
35895
|
+
throw new N(43);
|
|
35896
|
+
a.tty = b;
|
|
35897
|
+
a.seekable = false;
|
|
35898
|
+
}, close(a) {
|
|
35899
|
+
a.tty.cb.fsync(a.tty);
|
|
35900
|
+
}, fsync(a) {
|
|
35901
|
+
a.tty.cb.fsync(a.tty);
|
|
35902
|
+
}, read(a, b, c, d) {
|
|
35903
|
+
if (!a.tty || !a.tty.cb.xb)
|
|
35904
|
+
throw new N(60);
|
|
35905
|
+
for (var e2 = 0, h2 = 0;h2 < d; h2++) {
|
|
35906
|
+
try {
|
|
35907
|
+
var k = a.tty.cb.xb(a.tty);
|
|
35908
|
+
} catch (q) {
|
|
35909
|
+
throw new N(29);
|
|
35910
|
+
}
|
|
35911
|
+
if (k === undefined && e2 === 0)
|
|
35912
|
+
throw new N(6);
|
|
35913
|
+
if (k === null || k === undefined)
|
|
35914
|
+
break;
|
|
35915
|
+
e2++;
|
|
35916
|
+
b[c + h2] = k;
|
|
35917
|
+
}
|
|
35918
|
+
e2 && (a.node.atime = Date.now());
|
|
35919
|
+
return e2;
|
|
35920
|
+
}, write(a, b, c, d) {
|
|
35921
|
+
if (!a.tty || !a.tty.cb.qb)
|
|
35922
|
+
throw new N(60);
|
|
35923
|
+
try {
|
|
35924
|
+
for (var e2 = 0;e2 < d; e2++)
|
|
35925
|
+
a.tty.cb.qb(a.tty, b[c + e2]);
|
|
35926
|
+
} catch (h2) {
|
|
35927
|
+
throw new N(29);
|
|
35928
|
+
}
|
|
35929
|
+
d && (a.node.mtime = a.node.ctime = Date.now());
|
|
35930
|
+
return e2;
|
|
35931
|
+
} }, yb = { xb() {
|
|
35932
|
+
a: {
|
|
35933
|
+
if (!kb.length) {
|
|
35934
|
+
var a = null;
|
|
35935
|
+
if (ca) {
|
|
35936
|
+
var b = Buffer.alloc(256), c = 0, d = process.stdin.fd;
|
|
35937
|
+
try {
|
|
35938
|
+
c = fs4.readSync(d, b, 0, 256);
|
|
35939
|
+
} catch (e2) {
|
|
35940
|
+
if (e2.toString().includes("EOF"))
|
|
35941
|
+
c = 0;
|
|
35942
|
+
else
|
|
35943
|
+
throw e2;
|
|
35944
|
+
}
|
|
35945
|
+
0 < c && (a = b.slice(0, c).toString("utf-8"));
|
|
35946
|
+
} else
|
|
35947
|
+
typeof window != "undefined" && typeof window.prompt == "function" && (a = window.prompt("Input: "), a !== null && (a += `
|
|
35948
|
+
`));
|
|
35949
|
+
if (!a) {
|
|
35950
|
+
a = null;
|
|
35951
|
+
break a;
|
|
35952
|
+
}
|
|
35953
|
+
kb = ra(a, true);
|
|
35954
|
+
}
|
|
35955
|
+
a = kb.shift();
|
|
35956
|
+
}
|
|
35957
|
+
return a;
|
|
35958
|
+
}, qb(a, b) {
|
|
35959
|
+
b === null || b === 10 ? (Ha(B(a.output)), a.output = []) : b != 0 && a.output.push(b);
|
|
35960
|
+
}, fsync(a) {
|
|
35961
|
+
0 < a.output?.length && (Ha(B(a.output)), a.output = []);
|
|
35962
|
+
}, Tb() {
|
|
35963
|
+
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] };
|
|
35964
|
+
}, Ub() {
|
|
35965
|
+
return 0;
|
|
35966
|
+
}, Vb() {
|
|
35967
|
+
return [24, 80];
|
|
35968
|
+
} }, zb = { qb(a, b) {
|
|
35969
|
+
b === null || b === 10 ? (Ia(B(a.output)), a.output = []) : b != 0 && a.output.push(b);
|
|
35970
|
+
}, fsync(a) {
|
|
35971
|
+
0 < a.output?.length && (Ia(B(a.output)), a.output = []);
|
|
35972
|
+
} }, O = { Wa: null, Xa() {
|
|
35973
|
+
return O.createNode(null, "/", 16895, 0);
|
|
35974
|
+
}, createNode(a, b, c, d) {
|
|
35975
|
+
if ((c & 61440) === 24576 || (c & 61440) === 4096)
|
|
35976
|
+
throw new N(63);
|
|
35977
|
+
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 } });
|
|
35978
|
+
c = Bb(a, b, c, d);
|
|
35979
|
+
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);
|
|
35980
|
+
c.atime = c.mtime = c.ctime = Date.now();
|
|
35981
|
+
a && (a.Na[b] = c, a.atime = a.mtime = a.ctime = c.atime);
|
|
35982
|
+
return c;
|
|
35983
|
+
}, Sb(a) {
|
|
35984
|
+
return a.Na ? a.Na.subarray ? a.Na.subarray(0, a.Ra) : new Uint8Array(a.Na) : new Uint8Array(0);
|
|
35985
|
+
}, La: { Ta(a) {
|
|
35986
|
+
var b = {};
|
|
35987
|
+
b.dev = (a.mode & 61440) === 8192 ? a.id : 1;
|
|
35988
|
+
b.ino = a.id;
|
|
35989
|
+
b.mode = a.mode;
|
|
35990
|
+
b.nlink = 1;
|
|
35991
|
+
b.uid = 0;
|
|
35992
|
+
b.gid = 0;
|
|
35993
|
+
b.rdev = a.rdev;
|
|
35994
|
+
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;
|
|
35995
|
+
b.atime = new Date(a.atime);
|
|
35996
|
+
b.mtime = new Date(a.mtime);
|
|
35997
|
+
b.ctime = new Date(a.ctime);
|
|
35998
|
+
b.blksize = 4096;
|
|
35999
|
+
b.blocks = Math.ceil(b.size / b.blksize);
|
|
36000
|
+
return b;
|
|
36001
|
+
}, Ua(a, b) {
|
|
36002
|
+
for (var c of ["mode", "atime", "mtime", "ctime"])
|
|
36003
|
+
b[c] != null && (a[c] = b[c]);
|
|
36004
|
+
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)));
|
|
36005
|
+
}, lookup() {
|
|
36006
|
+
throw O.vb;
|
|
36007
|
+
}, hb(a, b, c, d) {
|
|
36008
|
+
return O.createNode(a, b, c, d);
|
|
36009
|
+
}, rename(a, b, c) {
|
|
36010
|
+
try {
|
|
36011
|
+
var d = Q(b, c);
|
|
36012
|
+
} catch (h2) {}
|
|
36013
|
+
if (d) {
|
|
36014
|
+
if (P(a.mode))
|
|
36015
|
+
for (var e2 in d.Na)
|
|
36016
|
+
throw new N(55);
|
|
36017
|
+
Cb(d);
|
|
36018
|
+
}
|
|
36019
|
+
delete a.parent.Na[a.name];
|
|
36020
|
+
b.Na[c] = a;
|
|
36021
|
+
a.name = c;
|
|
36022
|
+
b.ctime = b.mtime = a.parent.ctime = a.parent.mtime = Date.now();
|
|
36023
|
+
}, unlink(a, b) {
|
|
36024
|
+
delete a.Na[b];
|
|
36025
|
+
a.ctime = a.mtime = Date.now();
|
|
36026
|
+
}, rmdir(a, b) {
|
|
36027
|
+
var c = Q(a, b), d;
|
|
36028
|
+
for (d in c.Na)
|
|
36029
|
+
throw new N(55);
|
|
36030
|
+
delete a.Na[b];
|
|
36031
|
+
a.ctime = a.mtime = Date.now();
|
|
36032
|
+
}, readdir(a) {
|
|
36033
|
+
return [".", "..", ...Object.keys(a.Na)];
|
|
36034
|
+
}, symlink(a, b, c) {
|
|
36035
|
+
a = O.createNode(a, b, 41471, 0);
|
|
36036
|
+
a.link = c;
|
|
36037
|
+
return a;
|
|
36038
|
+
}, readlink(a) {
|
|
36039
|
+
if ((a.mode & 61440) !== 40960)
|
|
36040
|
+
throw new N(28);
|
|
36041
|
+
return a.link;
|
|
36042
|
+
} }, Ma: { read(a, b, c, d, e2) {
|
|
36043
|
+
var h2 = a.node.Na;
|
|
36044
|
+
if (e2 >= a.node.Ra)
|
|
36045
|
+
return 0;
|
|
36046
|
+
a = Math.min(a.node.Ra - e2, d);
|
|
36047
|
+
if (8 < a && h2.subarray)
|
|
36048
|
+
b.set(h2.subarray(e2, e2 + a), c);
|
|
36049
|
+
else
|
|
36050
|
+
for (d = 0;d < a; d++)
|
|
36051
|
+
b[c + d] = h2[e2 + d];
|
|
36052
|
+
return a;
|
|
36053
|
+
}, write(a, b, c, d, e2, h2) {
|
|
36054
|
+
b.buffer === p.buffer && (h2 = false);
|
|
36055
|
+
if (!d)
|
|
36056
|
+
return 0;
|
|
36057
|
+
a = a.node;
|
|
36058
|
+
a.mtime = a.ctime = Date.now();
|
|
36059
|
+
if (b.subarray && (!a.Na || a.Na.subarray)) {
|
|
36060
|
+
if (h2)
|
|
36061
|
+
return a.Na = b.subarray(c, c + d), a.Ra = d;
|
|
36062
|
+
if (a.Ra === 0 && e2 === 0)
|
|
36063
|
+
return a.Na = b.slice(c, c + d), a.Ra = d;
|
|
36064
|
+
if (e2 + d <= a.Ra)
|
|
36065
|
+
return a.Na.set(b.subarray(c, c + d), e2), d;
|
|
36066
|
+
}
|
|
36067
|
+
h2 = e2 + d;
|
|
36068
|
+
var k = a.Na ? a.Na.length : 0;
|
|
36069
|
+
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));
|
|
36070
|
+
if (a.Na.subarray && b.subarray)
|
|
36071
|
+
a.Na.set(b.subarray(c, c + d), e2);
|
|
36072
|
+
else
|
|
36073
|
+
for (h2 = 0;h2 < d; h2++)
|
|
36074
|
+
a.Na[e2 + h2] = b[c + h2];
|
|
36075
|
+
a.Ra = Math.max(a.Ra, e2 + d);
|
|
36076
|
+
return d;
|
|
36077
|
+
}, Va(a, b, c) {
|
|
36078
|
+
c === 1 ? b += a.position : c === 2 && (a.node.mode & 61440) === 32768 && (b += a.node.Ra);
|
|
36079
|
+
if (0 > b)
|
|
36080
|
+
throw new N(28);
|
|
36081
|
+
return b;
|
|
36082
|
+
}, ib(a, b, c, d, e2) {
|
|
36083
|
+
if ((a.node.mode & 61440) !== 32768)
|
|
36084
|
+
throw new N(43);
|
|
36085
|
+
a = a.node.Na;
|
|
36086
|
+
if (e2 & 2 || !a || a.buffer !== p.buffer) {
|
|
36087
|
+
e2 = true;
|
|
36088
|
+
d = 65536 * Math.ceil(b / 65536);
|
|
36089
|
+
var h2 = Db(65536, d);
|
|
36090
|
+
h2 && x2.fill(0, h2, h2 + d);
|
|
36091
|
+
d = h2;
|
|
36092
|
+
if (!d)
|
|
36093
|
+
throw new N(48);
|
|
36094
|
+
if (a) {
|
|
36095
|
+
if (0 < c || c + b < a.length)
|
|
36096
|
+
a.subarray ? a = a.subarray(c, c + b) : a = Array.prototype.slice.call(a, c, c + b);
|
|
36097
|
+
p.set(a, d);
|
|
36098
|
+
}
|
|
36099
|
+
} else
|
|
36100
|
+
e2 = false, d = a.byteOffset;
|
|
36101
|
+
return { Kb: d, Ab: e2 };
|
|
36102
|
+
}, jb(a, b, c, d) {
|
|
36103
|
+
O.Ma.write(a, b, 0, d, c, false);
|
|
36104
|
+
return 0;
|
|
36105
|
+
} } }, la = (a, b) => {
|
|
36106
|
+
var c = 0;
|
|
36107
|
+
a && (c |= 365);
|
|
36108
|
+
b && (c |= 146);
|
|
36109
|
+
return c;
|
|
36110
|
+
}, Eb = null, Fb = {}, Gb = [], Hb = 1, R = null, Ib = false, Jb = true, Kb = {}, N = class {
|
|
36111
|
+
name = "ErrnoError";
|
|
36112
|
+
constructor(a) {
|
|
36113
|
+
this.Pa = a;
|
|
36114
|
+
}
|
|
36115
|
+
}, Lb = class {
|
|
36116
|
+
gb = {};
|
|
36117
|
+
node = null;
|
|
36118
|
+
get flags() {
|
|
36119
|
+
return this.gb.flags;
|
|
36120
|
+
}
|
|
36121
|
+
set flags(a) {
|
|
36122
|
+
this.gb.flags = a;
|
|
36123
|
+
}
|
|
36124
|
+
get position() {
|
|
36125
|
+
return this.gb.position;
|
|
36126
|
+
}
|
|
36127
|
+
set position(a) {
|
|
36128
|
+
this.gb.position = a;
|
|
36129
|
+
}
|
|
36130
|
+
}, Mb = class {
|
|
36131
|
+
La = {};
|
|
36132
|
+
Ma = {};
|
|
36133
|
+
ab = null;
|
|
36134
|
+
constructor(a, b, c, d) {
|
|
36135
|
+
a ||= this;
|
|
36136
|
+
this.parent = a;
|
|
36137
|
+
this.Xa = a.Xa;
|
|
36138
|
+
this.id = Hb++;
|
|
36139
|
+
this.name = b;
|
|
36140
|
+
this.mode = c;
|
|
36141
|
+
this.rdev = d;
|
|
36142
|
+
this.atime = this.mtime = this.ctime = Date.now();
|
|
36143
|
+
}
|
|
36144
|
+
get read() {
|
|
36145
|
+
return (this.mode & 365) === 365;
|
|
36146
|
+
}
|
|
36147
|
+
set read(a) {
|
|
36148
|
+
a ? this.mode |= 365 : this.mode &= -366;
|
|
36149
|
+
}
|
|
36150
|
+
get write() {
|
|
36151
|
+
return (this.mode & 146) === 146;
|
|
36152
|
+
}
|
|
36153
|
+
set write(a) {
|
|
36154
|
+
a ? this.mode |= 146 : this.mode &= -147;
|
|
36155
|
+
}
|
|
36156
|
+
};
|
|
36157
|
+
function S2(a, b = {}) {
|
|
36158
|
+
if (!a)
|
|
36159
|
+
throw new N(44);
|
|
36160
|
+
b.nb ?? (b.nb = true);
|
|
36161
|
+
a.charAt(0) === "/" || (a = "//" + a);
|
|
36162
|
+
var c = 0;
|
|
36163
|
+
a:
|
|
36164
|
+
for (;40 > c; c++) {
|
|
36165
|
+
a = a.split("/").filter((q) => !!q);
|
|
36166
|
+
for (var d = Eb, e2 = "/", h2 = 0;h2 < a.length; h2++) {
|
|
36167
|
+
var k = h2 === a.length - 1;
|
|
36168
|
+
if (k && b.parent)
|
|
36169
|
+
break;
|
|
36170
|
+
if (a[h2] !== ".")
|
|
36171
|
+
if (a[h2] === "..")
|
|
36172
|
+
e2 = fb(e2), d = d.parent;
|
|
36173
|
+
else {
|
|
36174
|
+
e2 = ka(e2 + "/" + a[h2]);
|
|
36175
|
+
try {
|
|
36176
|
+
d = Q(d, a[h2]);
|
|
36177
|
+
} catch (q) {
|
|
36178
|
+
if (q?.Pa === 44 && k && b.Jb)
|
|
36179
|
+
return { path: e2 };
|
|
36180
|
+
throw q;
|
|
36181
|
+
}
|
|
36182
|
+
!d.ab || k && !b.nb || (d = d.ab.root);
|
|
36183
|
+
if ((d.mode & 61440) === 40960 && (!k || b.$a)) {
|
|
36184
|
+
if (!d.La.readlink)
|
|
36185
|
+
throw new N(52);
|
|
36186
|
+
d = d.La.readlink(d);
|
|
36187
|
+
d.charAt(0) === "/" || (d = fb(e2) + "/" + d);
|
|
36188
|
+
a = d + "/" + a.slice(h2 + 1).join("/");
|
|
36189
|
+
continue a;
|
|
36190
|
+
}
|
|
36191
|
+
}
|
|
36192
|
+
}
|
|
36193
|
+
return { path: e2, node: d };
|
|
36194
|
+
}
|
|
36195
|
+
throw new N(32);
|
|
36196
|
+
}
|
|
36197
|
+
function ja(a) {
|
|
36198
|
+
for (var b;; ) {
|
|
36199
|
+
if (a === a.parent)
|
|
36200
|
+
return a = a.Xa.zb, b ? a[a.length - 1] !== "/" ? `${a}/${b}` : a + b : a;
|
|
36201
|
+
b = b ? `${a.name}/${b}` : a.name;
|
|
36202
|
+
a = a.parent;
|
|
36203
|
+
}
|
|
36204
|
+
}
|
|
36205
|
+
function Nb(a, b) {
|
|
36206
|
+
for (var c = 0, d = 0;d < b.length; d++)
|
|
36207
|
+
c = (c << 5) - c + b.charCodeAt(d) | 0;
|
|
36208
|
+
return (a + c >>> 0) % R.length;
|
|
36209
|
+
}
|
|
36210
|
+
function Cb(a) {
|
|
36211
|
+
var b = Nb(a.parent.id, a.name);
|
|
36212
|
+
if (R[b] === a)
|
|
36213
|
+
R[b] = a.bb;
|
|
36214
|
+
else
|
|
36215
|
+
for (b = R[b];b; ) {
|
|
36216
|
+
if (b.bb === a) {
|
|
36217
|
+
b.bb = a.bb;
|
|
36218
|
+
break;
|
|
36219
|
+
}
|
|
36220
|
+
b = b.bb;
|
|
36221
|
+
}
|
|
36222
|
+
}
|
|
36223
|
+
function Q(a, b) {
|
|
36224
|
+
var c = P(a.mode) ? (c = Ob(a, "x")) ? c : a.La.lookup ? 0 : 2 : 54;
|
|
36225
|
+
if (c)
|
|
36226
|
+
throw new N(c);
|
|
36227
|
+
for (c = R[Nb(a.id, b)];c; c = c.bb) {
|
|
36228
|
+
var d = c.name;
|
|
36229
|
+
if (c.parent.id === a.id && d === b)
|
|
36230
|
+
return c;
|
|
36231
|
+
}
|
|
36232
|
+
return a.La.lookup(a, b);
|
|
36233
|
+
}
|
|
36234
|
+
function Bb(a, b, c, d) {
|
|
36235
|
+
a = new Mb(a, b, c, d);
|
|
36236
|
+
b = Nb(a.parent.id, a.name);
|
|
36237
|
+
a.bb = R[b];
|
|
36238
|
+
return R[b] = a;
|
|
36239
|
+
}
|
|
36240
|
+
function P(a) {
|
|
36241
|
+
return (a & 61440) === 16384;
|
|
36242
|
+
}
|
|
36243
|
+
function Pb(a) {
|
|
36244
|
+
var b = ["r", "w", "rw"][a & 3];
|
|
36245
|
+
a & 512 && (b += "w");
|
|
36246
|
+
return b;
|
|
36247
|
+
}
|
|
36248
|
+
function Ob(a, b) {
|
|
36249
|
+
if (Jb)
|
|
36250
|
+
return 0;
|
|
36251
|
+
if (!b.includes("r") || a.mode & 292) {
|
|
36252
|
+
if (b.includes("w") && !(a.mode & 146) || b.includes("x") && !(a.mode & 73))
|
|
36253
|
+
return 2;
|
|
36254
|
+
} else
|
|
36255
|
+
return 2;
|
|
36256
|
+
return 0;
|
|
36257
|
+
}
|
|
36258
|
+
function Qb(a, b) {
|
|
36259
|
+
if (!P(a.mode))
|
|
36260
|
+
return 54;
|
|
36261
|
+
try {
|
|
36262
|
+
return Q(a, b), 20;
|
|
36263
|
+
} catch (c) {}
|
|
36264
|
+
return Ob(a, "wx");
|
|
36265
|
+
}
|
|
36266
|
+
function Rb(a, b, c) {
|
|
36267
|
+
try {
|
|
36268
|
+
var d = Q(a, b);
|
|
36269
|
+
} catch (e2) {
|
|
36270
|
+
return e2.Pa;
|
|
36271
|
+
}
|
|
36272
|
+
if (a = Ob(a, "wx"))
|
|
36273
|
+
return a;
|
|
36274
|
+
if (c) {
|
|
36275
|
+
if (!P(d.mode))
|
|
36276
|
+
return 54;
|
|
36277
|
+
if (d === d.parent || ja(d) === "/")
|
|
36278
|
+
return 10;
|
|
36279
|
+
} else if (P(d.mode))
|
|
36280
|
+
return 31;
|
|
36281
|
+
return 0;
|
|
36282
|
+
}
|
|
36283
|
+
function Sb(a) {
|
|
36284
|
+
if (!a)
|
|
36285
|
+
throw new N(63);
|
|
36286
|
+
return a;
|
|
36287
|
+
}
|
|
36288
|
+
function T(a) {
|
|
36289
|
+
a = Gb[a];
|
|
36290
|
+
if (!a)
|
|
36291
|
+
throw new N(8);
|
|
36292
|
+
return a;
|
|
36293
|
+
}
|
|
36294
|
+
function Tb(a, b = -1) {
|
|
36295
|
+
a = Object.assign(new Lb, a);
|
|
36296
|
+
if (b == -1)
|
|
36297
|
+
a: {
|
|
36298
|
+
for (b = 0;4096 >= b; b++)
|
|
36299
|
+
if (!Gb[b])
|
|
36300
|
+
break a;
|
|
36301
|
+
throw new N(33);
|
|
36302
|
+
}
|
|
36303
|
+
a.fd = b;
|
|
36304
|
+
return Gb[b] = a;
|
|
36305
|
+
}
|
|
36306
|
+
function Ub(a, b = -1) {
|
|
36307
|
+
a = Tb(a, b);
|
|
36308
|
+
a.Ma?.Rb?.(a);
|
|
36309
|
+
return a;
|
|
36310
|
+
}
|
|
36311
|
+
function Vb(a, b, c) {
|
|
36312
|
+
var d = a?.Ma.Ua;
|
|
36313
|
+
a = d ? a : b;
|
|
36314
|
+
d ??= b.La.Ua;
|
|
36315
|
+
Sb(d);
|
|
36316
|
+
d(a, c);
|
|
36317
|
+
}
|
|
36318
|
+
var Ab = { open(a) {
|
|
36319
|
+
a.Ma = Fb[a.node.rdev].Ma;
|
|
36320
|
+
a.Ma.open?.(a);
|
|
36321
|
+
}, Va() {
|
|
36322
|
+
throw new N(70);
|
|
36323
|
+
} };
|
|
36324
|
+
function wb(a, b) {
|
|
36325
|
+
Fb[a] = { Ma: b };
|
|
36326
|
+
}
|
|
36327
|
+
function Wb(a, b) {
|
|
36328
|
+
var c = b === "/";
|
|
36329
|
+
if (c && Eb)
|
|
36330
|
+
throw new N(10);
|
|
36331
|
+
if (!c && b) {
|
|
36332
|
+
var d = S2(b, { nb: false });
|
|
36333
|
+
b = d.path;
|
|
36334
|
+
d = d.node;
|
|
36335
|
+
if (d.ab)
|
|
36336
|
+
throw new N(10);
|
|
36337
|
+
if (!P(d.mode))
|
|
36338
|
+
throw new N(54);
|
|
36339
|
+
}
|
|
36340
|
+
b = { type: a, Wb: {}, zb: b, Ib: [] };
|
|
36341
|
+
a = a.Xa(b);
|
|
36342
|
+
a.Xa = b;
|
|
36343
|
+
b.root = a;
|
|
36344
|
+
c ? Eb = a : d && (d.ab = b, d.Xa && d.Xa.Ib.push(b));
|
|
36345
|
+
}
|
|
36346
|
+
function Xb(a, b, c) {
|
|
36347
|
+
var d = S2(a, { parent: true }).node;
|
|
36348
|
+
a = gb(a);
|
|
36349
|
+
if (!a)
|
|
36350
|
+
throw new N(28);
|
|
36351
|
+
if (a === "." || a === "..")
|
|
36352
|
+
throw new N(20);
|
|
36353
|
+
var e2 = Qb(d, a);
|
|
36354
|
+
if (e2)
|
|
36355
|
+
throw new N(e2);
|
|
36356
|
+
if (!d.La.hb)
|
|
36357
|
+
throw new N(63);
|
|
36358
|
+
return d.La.hb(d, a, b, c);
|
|
36359
|
+
}
|
|
36360
|
+
function ma(a, b = 438) {
|
|
36361
|
+
return Xb(a, b & 4095 | 32768, 0);
|
|
36362
|
+
}
|
|
36363
|
+
function U(a, b = 511) {
|
|
36364
|
+
return Xb(a, b & 1023 | 16384, 0);
|
|
36365
|
+
}
|
|
36366
|
+
function Yb(a, b, c) {
|
|
36367
|
+
typeof c == "undefined" && (c = b, b = 438);
|
|
36368
|
+
Xb(a, b | 8192, c);
|
|
36369
|
+
}
|
|
36370
|
+
function Zb(a, b) {
|
|
36371
|
+
if (!jb(a))
|
|
36372
|
+
throw new N(44);
|
|
36373
|
+
var c = S2(b, { parent: true }).node;
|
|
36374
|
+
if (!c)
|
|
36375
|
+
throw new N(44);
|
|
36376
|
+
b = gb(b);
|
|
36377
|
+
var d = Qb(c, b);
|
|
36378
|
+
if (d)
|
|
36379
|
+
throw new N(d);
|
|
36380
|
+
if (!c.La.symlink)
|
|
36381
|
+
throw new N(63);
|
|
36382
|
+
c.La.symlink(c, b, a);
|
|
36383
|
+
}
|
|
36384
|
+
function $b(a) {
|
|
36385
|
+
var b = S2(a, { parent: true }).node;
|
|
36386
|
+
a = gb(a);
|
|
36387
|
+
var c = Q(b, a), d = Rb(b, a, true);
|
|
36388
|
+
if (d)
|
|
36389
|
+
throw new N(d);
|
|
36390
|
+
if (!b.La.rmdir)
|
|
36391
|
+
throw new N(63);
|
|
36392
|
+
if (c.ab)
|
|
36393
|
+
throw new N(10);
|
|
36394
|
+
b.La.rmdir(b, a);
|
|
36395
|
+
Cb(c);
|
|
36396
|
+
}
|
|
36397
|
+
function za(a) {
|
|
36398
|
+
var b = S2(a, { parent: true }).node;
|
|
36399
|
+
if (!b)
|
|
36400
|
+
throw new N(44);
|
|
36401
|
+
a = gb(a);
|
|
36402
|
+
var c = Q(b, a), d = Rb(b, a, false);
|
|
36403
|
+
if (d)
|
|
36404
|
+
throw new N(d);
|
|
36405
|
+
if (!b.La.unlink)
|
|
36406
|
+
throw new N(63);
|
|
36407
|
+
if (c.ab)
|
|
36408
|
+
throw new N(10);
|
|
36409
|
+
b.La.unlink(b, a);
|
|
36410
|
+
Cb(c);
|
|
36411
|
+
}
|
|
36412
|
+
function ac(a, b) {
|
|
36413
|
+
a = S2(a, { $a: !b }).node;
|
|
36414
|
+
return Sb(a.La.Ta)(a);
|
|
36415
|
+
}
|
|
36416
|
+
function bc(a, b, c, d) {
|
|
36417
|
+
Vb(a, b, { mode: c & 4095 | b.mode & -4096, ctime: Date.now(), Fb: d });
|
|
36418
|
+
}
|
|
36419
|
+
function na(a, b) {
|
|
36420
|
+
a = typeof a == "string" ? S2(a, { $a: true }).node : a;
|
|
36421
|
+
bc(null, a, b);
|
|
36422
|
+
}
|
|
36423
|
+
function cc(a, b, c) {
|
|
36424
|
+
if (P(b.mode))
|
|
36425
|
+
throw new N(31);
|
|
36426
|
+
if ((b.mode & 61440) !== 32768)
|
|
36427
|
+
throw new N(28);
|
|
36428
|
+
var d = Ob(b, "w");
|
|
36429
|
+
if (d)
|
|
36430
|
+
throw new N(d);
|
|
36431
|
+
Vb(a, b, { size: c, timestamp: Date.now() });
|
|
36432
|
+
}
|
|
36433
|
+
function oa(a, b, c = 438) {
|
|
36434
|
+
if (a === "")
|
|
36435
|
+
throw new N(44);
|
|
36436
|
+
if (typeof b == "string") {
|
|
36437
|
+
var d = { r: 0, "r+": 2, w: 577, "w+": 578, a: 1089, "a+": 1090 }[b];
|
|
36438
|
+
if (typeof d == "undefined")
|
|
36439
|
+
throw Error(`Unknown file open mode: ${b}`);
|
|
36440
|
+
b = d;
|
|
36441
|
+
}
|
|
36442
|
+
c = b & 64 ? c & 4095 | 32768 : 0;
|
|
36443
|
+
if (typeof a == "object")
|
|
36444
|
+
d = a;
|
|
36445
|
+
else {
|
|
36446
|
+
var e2 = a.endsWith("/");
|
|
36447
|
+
a = S2(a, { $a: !(b & 131072), Jb: true });
|
|
36448
|
+
d = a.node;
|
|
36449
|
+
a = a.path;
|
|
36450
|
+
}
|
|
36451
|
+
var h2 = false;
|
|
36452
|
+
if (b & 64)
|
|
36453
|
+
if (d) {
|
|
36454
|
+
if (b & 128)
|
|
36455
|
+
throw new N(20);
|
|
36456
|
+
} else {
|
|
36457
|
+
if (e2)
|
|
36458
|
+
throw new N(31);
|
|
36459
|
+
d = Xb(a, c | 511, 0);
|
|
36460
|
+
h2 = true;
|
|
36461
|
+
}
|
|
36462
|
+
if (!d)
|
|
36463
|
+
throw new N(44);
|
|
36464
|
+
(d.mode & 61440) === 8192 && (b &= -513);
|
|
36465
|
+
if (b & 65536 && !P(d.mode))
|
|
36466
|
+
throw new N(54);
|
|
36467
|
+
if (!h2 && (e2 = d ? (d.mode & 61440) === 40960 ? 32 : P(d.mode) && (Pb(b) !== "r" || b & 576) ? 31 : Ob(d, Pb(b)) : 44))
|
|
36468
|
+
throw new N(e2);
|
|
36469
|
+
b & 512 && !h2 && (e2 = d, e2 = typeof e2 == "string" ? S2(e2, { $a: true }).node : e2, cc(null, e2, 0));
|
|
36470
|
+
b &= -131713;
|
|
36471
|
+
e2 = Tb({ node: d, path: ja(d), flags: b, seekable: true, position: 0, Ma: d.Ma, Lb: [], error: false });
|
|
36472
|
+
e2.Ma.open && e2.Ma.open(e2);
|
|
36473
|
+
h2 && na(d, c & 511);
|
|
36474
|
+
!f3.logReadFiles || b & 1 || a in Kb || (Kb[a] = 1);
|
|
36475
|
+
return e2;
|
|
36476
|
+
}
|
|
36477
|
+
function qa(a) {
|
|
36478
|
+
if (a.fd === null)
|
|
36479
|
+
throw new N(8);
|
|
36480
|
+
a.ob && (a.ob = null);
|
|
36481
|
+
try {
|
|
36482
|
+
a.Ma.close && a.Ma.close(a);
|
|
36483
|
+
} catch (b) {
|
|
36484
|
+
throw b;
|
|
36485
|
+
} finally {
|
|
36486
|
+
Gb[a.fd] = null;
|
|
36487
|
+
}
|
|
36488
|
+
a.fd = null;
|
|
36489
|
+
}
|
|
36490
|
+
function mc(a, b, c) {
|
|
36491
|
+
if (a.fd === null)
|
|
36492
|
+
throw new N(8);
|
|
36493
|
+
if (!a.seekable || !a.Ma.Va)
|
|
36494
|
+
throw new N(70);
|
|
36495
|
+
if (c != 0 && c != 1 && c != 2)
|
|
36496
|
+
throw new N(28);
|
|
36497
|
+
a.position = a.Ma.Va(a, b, c);
|
|
36498
|
+
a.Lb = [];
|
|
36499
|
+
}
|
|
36500
|
+
function Ec(a, b, c, d, e2) {
|
|
36501
|
+
if (0 > d || 0 > e2)
|
|
36502
|
+
throw new N(28);
|
|
36503
|
+
if (a.fd === null)
|
|
36504
|
+
throw new N(8);
|
|
36505
|
+
if ((a.flags & 2097155) === 1)
|
|
36506
|
+
throw new N(8);
|
|
36507
|
+
if (P(a.node.mode))
|
|
36508
|
+
throw new N(31);
|
|
36509
|
+
if (!a.Ma.read)
|
|
36510
|
+
throw new N(28);
|
|
36511
|
+
var h2 = typeof e2 != "undefined";
|
|
36512
|
+
if (!h2)
|
|
36513
|
+
e2 = a.position;
|
|
36514
|
+
else if (!a.seekable)
|
|
36515
|
+
throw new N(70);
|
|
36516
|
+
b = a.Ma.read(a, b, c, d, e2);
|
|
36517
|
+
h2 || (a.position += b);
|
|
36518
|
+
return b;
|
|
36519
|
+
}
|
|
36520
|
+
function pa(a, b, c, d, e2) {
|
|
36521
|
+
if (0 > d || 0 > e2)
|
|
36522
|
+
throw new N(28);
|
|
36523
|
+
if (a.fd === null)
|
|
36524
|
+
throw new N(8);
|
|
36525
|
+
if ((a.flags & 2097155) === 0)
|
|
36526
|
+
throw new N(8);
|
|
36527
|
+
if (P(a.node.mode))
|
|
36528
|
+
throw new N(31);
|
|
36529
|
+
if (!a.Ma.write)
|
|
36530
|
+
throw new N(28);
|
|
36531
|
+
a.seekable && a.flags & 1024 && mc(a, 0, 2);
|
|
36532
|
+
var h2 = typeof e2 != "undefined";
|
|
36533
|
+
if (!h2)
|
|
36534
|
+
e2 = a.position;
|
|
36535
|
+
else if (!a.seekable)
|
|
36536
|
+
throw new N(70);
|
|
36537
|
+
b = a.Ma.write(a, b, c, d, e2, undefined);
|
|
36538
|
+
h2 || (a.position += b);
|
|
36539
|
+
return b;
|
|
36540
|
+
}
|
|
36541
|
+
function ya(a) {
|
|
36542
|
+
var b = "binary";
|
|
36543
|
+
if (b !== "utf8" && b !== "binary")
|
|
36544
|
+
throw Error(`Invalid encoding type "${b}"`);
|
|
36545
|
+
var c;
|
|
36546
|
+
var d = oa(a, d || 0);
|
|
36547
|
+
a = ac(a).size;
|
|
36548
|
+
var e2 = new Uint8Array(a);
|
|
36549
|
+
Ec(d, e2, 0, a, 0);
|
|
36550
|
+
b === "utf8" ? c = B(e2) : b === "binary" && (c = e2);
|
|
36551
|
+
qa(d);
|
|
36552
|
+
return c;
|
|
36553
|
+
}
|
|
36554
|
+
function V(a, b, c) {
|
|
36555
|
+
a = ka("/dev/" + a);
|
|
36556
|
+
var d = la(!!b, !!c);
|
|
36557
|
+
V.yb ?? (V.yb = 64);
|
|
36558
|
+
var e2 = V.yb++ << 8 | 0;
|
|
36559
|
+
wb(e2, { open(h2) {
|
|
36560
|
+
h2.seekable = false;
|
|
36561
|
+
}, close() {
|
|
36562
|
+
c?.buffer?.length && c(10);
|
|
36563
|
+
}, read(h2, k, q, w) {
|
|
36564
|
+
for (var v = 0, C = 0;C < w; C++) {
|
|
36565
|
+
try {
|
|
36566
|
+
var G = b();
|
|
36567
|
+
} catch (pb) {
|
|
36568
|
+
throw new N(29);
|
|
36569
|
+
}
|
|
36570
|
+
if (G === undefined && v === 0)
|
|
36571
|
+
throw new N(6);
|
|
36572
|
+
if (G === null || G === undefined)
|
|
36573
|
+
break;
|
|
36574
|
+
v++;
|
|
36575
|
+
k[q + C] = G;
|
|
36576
|
+
}
|
|
36577
|
+
v && (h2.node.atime = Date.now());
|
|
36578
|
+
return v;
|
|
36579
|
+
}, write(h2, k, q, w) {
|
|
36580
|
+
for (var v = 0;v < w; v++)
|
|
36581
|
+
try {
|
|
36582
|
+
c(k[q + v]);
|
|
36583
|
+
} catch (C) {
|
|
36584
|
+
throw new N(29);
|
|
36585
|
+
}
|
|
36586
|
+
w && (h2.node.mtime = h2.node.ctime = Date.now());
|
|
36587
|
+
return v;
|
|
36588
|
+
} });
|
|
36589
|
+
Yb(a, d, e2);
|
|
36590
|
+
}
|
|
36591
|
+
var W = {};
|
|
36592
|
+
function Gc(a, b, c) {
|
|
36593
|
+
if (b.charAt(0) === "/")
|
|
36594
|
+
return b;
|
|
36595
|
+
a = a === -100 ? "/" : T(a).path;
|
|
36596
|
+
if (b.length == 0) {
|
|
36597
|
+
if (!c)
|
|
36598
|
+
throw new N(44);
|
|
36599
|
+
return a;
|
|
36600
|
+
}
|
|
36601
|
+
return a + "/" + b;
|
|
36602
|
+
}
|
|
36603
|
+
function Hc(a, b) {
|
|
36604
|
+
E[a >> 2] = b.dev;
|
|
36605
|
+
E[a + 4 >> 2] = b.mode;
|
|
36606
|
+
F2[a + 8 >> 2] = b.nlink;
|
|
36607
|
+
E[a + 12 >> 2] = b.uid;
|
|
36608
|
+
E[a + 16 >> 2] = b.gid;
|
|
36609
|
+
E[a + 20 >> 2] = b.rdev;
|
|
36610
|
+
H[a + 24 >> 3] = BigInt(b.size);
|
|
36611
|
+
E[a + 32 >> 2] = 4096;
|
|
36612
|
+
E[a + 36 >> 2] = b.blocks;
|
|
36613
|
+
var c = b.atime.getTime(), d = b.mtime.getTime(), e2 = b.ctime.getTime();
|
|
36614
|
+
H[a + 40 >> 3] = BigInt(Math.floor(c / 1000));
|
|
36615
|
+
F2[a + 48 >> 2] = c % 1000 * 1e6;
|
|
36616
|
+
H[a + 56 >> 3] = BigInt(Math.floor(d / 1000));
|
|
36617
|
+
F2[a + 64 >> 2] = d % 1000 * 1e6;
|
|
36618
|
+
H[a + 72 >> 3] = BigInt(Math.floor(e2 / 1000));
|
|
36619
|
+
F2[a + 80 >> 2] = e2 % 1000 * 1e6;
|
|
36620
|
+
H[a + 88 >> 3] = BigInt(b.ino);
|
|
36621
|
+
return 0;
|
|
36622
|
+
}
|
|
36623
|
+
var Ic = undefined, Jc = () => {
|
|
36624
|
+
var a = E[+Ic >> 2];
|
|
36625
|
+
Ic += 4;
|
|
36626
|
+
return a;
|
|
36627
|
+
}, 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) => {
|
|
36628
|
+
Ma = a;
|
|
36629
|
+
cb || 0 < Kc || (f3.onExit?.(a), La = true);
|
|
36630
|
+
Da(a, new Ya(a));
|
|
36631
|
+
}, Pc = (a) => {
|
|
36632
|
+
if (!La)
|
|
36633
|
+
try {
|
|
36634
|
+
if (a(), !(cb || 0 < Kc))
|
|
36635
|
+
try {
|
|
36636
|
+
Ma = a = Ma, Oc(a);
|
|
36637
|
+
} catch (b) {
|
|
36638
|
+
b instanceof Ya || b == "unwind" || Da(1, b);
|
|
36639
|
+
}
|
|
36640
|
+
} catch (b) {
|
|
36641
|
+
b instanceof Ya || b == "unwind" || Da(1, b);
|
|
36642
|
+
}
|
|
36643
|
+
}, Qc = {}, Sc = () => {
|
|
36644
|
+
if (!Rc) {
|
|
36645
|
+
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;
|
|
36646
|
+
for (b in Qc)
|
|
36647
|
+
Qc[b] === undefined ? delete a[b] : a[b] = Qc[b];
|
|
36648
|
+
var c = [];
|
|
36649
|
+
for (b in a)
|
|
36650
|
+
c.push(`${b}=${a[b]}`);
|
|
36651
|
+
Rc = c;
|
|
36652
|
+
}
|
|
36653
|
+
return Rc;
|
|
36654
|
+
}, Rc, xa = (a) => {
|
|
36655
|
+
var b = ha(a) + 1, c = z2(b);
|
|
36656
|
+
u(a, x2, c, b);
|
|
36657
|
+
return c;
|
|
36658
|
+
}, Tc = (a, b, c, d) => {
|
|
36659
|
+
var e2 = { string: (v) => {
|
|
36660
|
+
var C = 0;
|
|
36661
|
+
v !== null && v !== undefined && v !== 0 && (C = xa(v));
|
|
36662
|
+
return C;
|
|
36663
|
+
}, array: (v) => {
|
|
36664
|
+
var C = z2(v.length);
|
|
36665
|
+
p.set(v, C);
|
|
36666
|
+
return C;
|
|
36667
|
+
} };
|
|
36668
|
+
a = f3["_" + a];
|
|
36669
|
+
var h2 = [], k = 0;
|
|
36670
|
+
if (d)
|
|
36671
|
+
for (var q = 0;q < d.length; q++) {
|
|
36672
|
+
var w = e2[c[q]];
|
|
36673
|
+
w ? (k === 0 && (k = sa()), h2[q] = w(d[q])) : h2[q] = d[q];
|
|
36674
|
+
}
|
|
36675
|
+
c = a(...h2);
|
|
36676
|
+
return c = function(v) {
|
|
36677
|
+
k !== 0 && wa(k);
|
|
36678
|
+
return b === "string" ? v ? B(x2, v) : "" : b === "boolean" ? !!v : v;
|
|
36679
|
+
}(c);
|
|
36680
|
+
}, ea = 0, da = (a, b) => {
|
|
36681
|
+
b = b == 1 ? z2(a.length) : ia(a.length);
|
|
36682
|
+
a.subarray || a.slice || (a = new Uint8Array(a));
|
|
36683
|
+
x2.set(a, b);
|
|
36684
|
+
return b;
|
|
36685
|
+
}, Uc, Vc = [], Y, A2 = (a) => {
|
|
36686
|
+
Uc.delete(Y.get(a));
|
|
36687
|
+
Y.set(a, null);
|
|
36688
|
+
Vc.push(a);
|
|
36689
|
+
}, Aa = (a, b) => {
|
|
36690
|
+
if (!Uc) {
|
|
36691
|
+
Uc = new WeakMap;
|
|
36692
|
+
var c = Y.length;
|
|
36693
|
+
if (Uc)
|
|
36694
|
+
for (var d = 0;d < 0 + c; d++) {
|
|
36695
|
+
var e2 = Y.get(d);
|
|
36696
|
+
e2 && Uc.set(e2, d);
|
|
36697
|
+
}
|
|
36698
|
+
}
|
|
36699
|
+
if (c = Uc.get(a) || 0)
|
|
36700
|
+
return c;
|
|
36701
|
+
if (Vc.length)
|
|
36702
|
+
c = Vc.pop();
|
|
36703
|
+
else {
|
|
36704
|
+
try {
|
|
36705
|
+
Y.grow(1);
|
|
36706
|
+
} catch (w) {
|
|
36707
|
+
if (!(w instanceof RangeError))
|
|
36708
|
+
throw w;
|
|
36709
|
+
throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";
|
|
36710
|
+
}
|
|
36711
|
+
c = Y.length - 1;
|
|
36712
|
+
}
|
|
36713
|
+
try {
|
|
36714
|
+
Y.set(c, a);
|
|
36715
|
+
} catch (w) {
|
|
36716
|
+
if (!(w instanceof TypeError))
|
|
36717
|
+
throw w;
|
|
36718
|
+
if (typeof WebAssembly.Function == "function") {
|
|
36719
|
+
var h2 = WebAssembly.Function;
|
|
36720
|
+
d = { i: "i32", j: "i64", f: "f32", d: "f64", e: "externref", p: "i32" };
|
|
36721
|
+
e2 = { parameters: [], results: b[0] == "v" ? [] : [d[b[0]]] };
|
|
36722
|
+
for (var k = 1;k < b.length; ++k)
|
|
36723
|
+
e2.parameters.push(d[b[k]]);
|
|
36724
|
+
b = new h2(e2, a);
|
|
36725
|
+
} else {
|
|
36726
|
+
d = [1];
|
|
36727
|
+
e2 = b.slice(0, 1);
|
|
36728
|
+
b = b.slice(1);
|
|
36729
|
+
k = { i: 127, p: 127, j: 126, f: 125, d: 124, e: 111 };
|
|
36730
|
+
d.push(96);
|
|
36731
|
+
var q = b.length;
|
|
36732
|
+
128 > q ? d.push(q) : d.push(q % 128 | 128, q >> 7);
|
|
36733
|
+
for (h2 of b)
|
|
36734
|
+
d.push(k[h2]);
|
|
36735
|
+
e2 == "v" ? d.push(0) : d.push(1, k[e2]);
|
|
36736
|
+
b = [0, 97, 115, 109, 1, 0, 0, 0, 1];
|
|
36737
|
+
h2 = d.length;
|
|
36738
|
+
128 > h2 ? b.push(h2) : b.push(h2 % 128 | 128, h2 >> 7);
|
|
36739
|
+
b.push(...d);
|
|
36740
|
+
b.push(2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0);
|
|
36741
|
+
b = new WebAssembly.Module(new Uint8Array(b));
|
|
36742
|
+
b = new WebAssembly.Instance(b, { e: { f: a } }).exports.f;
|
|
36743
|
+
}
|
|
36744
|
+
Y.set(c, b);
|
|
36745
|
+
}
|
|
36746
|
+
Uc.set(a, c);
|
|
36747
|
+
return c;
|
|
36748
|
+
};
|
|
36749
|
+
R = Array(4096);
|
|
36750
|
+
Wb(O, "/");
|
|
36751
|
+
U("/tmp");
|
|
36752
|
+
U("/home");
|
|
36753
|
+
U("/home/web_user");
|
|
36754
|
+
(function() {
|
|
36755
|
+
U("/dev");
|
|
36756
|
+
wb(259, { read: () => 0, write: (d, e2, h2, k) => k, Va: () => 0 });
|
|
36757
|
+
Yb("/dev/null", 259);
|
|
36758
|
+
nb(1280, yb);
|
|
36759
|
+
nb(1536, zb);
|
|
36760
|
+
Yb("/dev/tty", 1280);
|
|
36761
|
+
Yb("/dev/tty1", 1536);
|
|
36762
|
+
var a = new Uint8Array(1024), b = 0, c = () => {
|
|
36763
|
+
b === 0 && (ib(a), b = a.byteLength);
|
|
36764
|
+
return a[--b];
|
|
36765
|
+
};
|
|
36766
|
+
V("random", c);
|
|
36767
|
+
V("urandom", c);
|
|
36768
|
+
U("/dev/shm");
|
|
36769
|
+
U("/dev/shm/tmp");
|
|
36770
|
+
})();
|
|
36771
|
+
(function() {
|
|
36772
|
+
U("/proc");
|
|
36773
|
+
var a = U("/proc/self");
|
|
36774
|
+
U("/proc/self/fd");
|
|
36775
|
+
Wb({ Xa() {
|
|
36776
|
+
var b = Bb(a, "fd", 16895, 73);
|
|
36777
|
+
b.Ma = { Va: O.Ma.Va };
|
|
36778
|
+
b.La = { lookup(c, d) {
|
|
36779
|
+
c = +d;
|
|
36780
|
+
var e2 = T(c);
|
|
36781
|
+
c = { parent: null, Xa: { zb: "fake" }, La: { readlink: () => e2.path }, id: c + 1 };
|
|
36782
|
+
return c.parent = c;
|
|
36783
|
+
}, readdir() {
|
|
36784
|
+
return Array.from(Gb.entries()).filter(([, c]) => c).map(([c]) => c.toString());
|
|
36785
|
+
} };
|
|
36786
|
+
return b;
|
|
36787
|
+
} }, "/proc/self/fd");
|
|
36788
|
+
})();
|
|
36789
|
+
O.vb = new N(44);
|
|
36790
|
+
O.vb.stack = "<generic error, no stack>";
|
|
36791
|
+
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) {
|
|
36792
|
+
try {
|
|
36793
|
+
return a = a ? B(x2, a) : "", na(a, b), 0;
|
|
36794
|
+
} catch (c) {
|
|
36795
|
+
if (typeof W == "undefined" || c.name !== "ErrnoError")
|
|
36796
|
+
throw c;
|
|
36797
|
+
return -c.Pa;
|
|
36798
|
+
}
|
|
36799
|
+
}, L: function(a, b, c) {
|
|
36800
|
+
try {
|
|
36801
|
+
b = b ? B(x2, b) : "";
|
|
36802
|
+
b = Gc(a, b);
|
|
36803
|
+
if (c & -8)
|
|
36804
|
+
return -28;
|
|
36805
|
+
var d = S2(b, { $a: true }).node;
|
|
36806
|
+
if (!d)
|
|
36807
|
+
return -44;
|
|
36808
|
+
a = "";
|
|
36809
|
+
c & 4 && (a += "r");
|
|
36810
|
+
c & 2 && (a += "w");
|
|
36811
|
+
c & 1 && (a += "x");
|
|
36812
|
+
return a && Ob(d, a) ? -2 : 0;
|
|
36813
|
+
} catch (e2) {
|
|
36814
|
+
if (typeof W == "undefined" || e2.name !== "ErrnoError")
|
|
36815
|
+
throw e2;
|
|
36816
|
+
return -e2.Pa;
|
|
36817
|
+
}
|
|
36818
|
+
}, j: function(a, b) {
|
|
36819
|
+
try {
|
|
36820
|
+
var c = T(a);
|
|
36821
|
+
bc(c, c.node, b, false);
|
|
36822
|
+
return 0;
|
|
36823
|
+
} catch (d) {
|
|
36824
|
+
if (typeof W == "undefined" || d.name !== "ErrnoError")
|
|
36825
|
+
throw d;
|
|
36826
|
+
return -d.Pa;
|
|
36827
|
+
}
|
|
36828
|
+
}, h: function(a) {
|
|
36829
|
+
try {
|
|
36830
|
+
var b = T(a);
|
|
36831
|
+
Vb(b, b.node, { timestamp: Date.now(), Fb: false });
|
|
36832
|
+
return 0;
|
|
36833
|
+
} catch (c) {
|
|
36834
|
+
if (typeof W == "undefined" || c.name !== "ErrnoError")
|
|
36835
|
+
throw c;
|
|
36836
|
+
return -c.Pa;
|
|
36837
|
+
}
|
|
36838
|
+
}, b: function(a, b, c) {
|
|
36839
|
+
Ic = c;
|
|
36840
|
+
try {
|
|
36841
|
+
var d = T(a);
|
|
36842
|
+
switch (b) {
|
|
36843
|
+
case 0:
|
|
36844
|
+
var e2 = Jc();
|
|
36845
|
+
if (0 > e2)
|
|
36846
|
+
break;
|
|
36847
|
+
for (;Gb[e2]; )
|
|
36848
|
+
e2++;
|
|
36849
|
+
return Ub(d, e2).fd;
|
|
36850
|
+
case 1:
|
|
36851
|
+
case 2:
|
|
36852
|
+
return 0;
|
|
36853
|
+
case 3:
|
|
36854
|
+
return d.flags;
|
|
36855
|
+
case 4:
|
|
36856
|
+
return e2 = Jc(), d.flags |= e2, 0;
|
|
36857
|
+
case 12:
|
|
36858
|
+
return e2 = Jc(), Na[e2 + 0 >> 1] = 2, 0;
|
|
36859
|
+
case 13:
|
|
36860
|
+
case 14:
|
|
36861
|
+
return 0;
|
|
36862
|
+
}
|
|
36863
|
+
return -28;
|
|
36864
|
+
} catch (h2) {
|
|
36865
|
+
if (typeof W == "undefined" || h2.name !== "ErrnoError")
|
|
36866
|
+
throw h2;
|
|
36867
|
+
return -h2.Pa;
|
|
36868
|
+
}
|
|
36869
|
+
}, g: function(a, b) {
|
|
36870
|
+
try {
|
|
36871
|
+
var c = T(a), d = c.node, e2 = c.Ma.Ta;
|
|
36872
|
+
a = e2 ? c : d;
|
|
36873
|
+
e2 ??= d.La.Ta;
|
|
36874
|
+
Sb(e2);
|
|
36875
|
+
var h2 = e2(a);
|
|
36876
|
+
return Hc(b, h2);
|
|
36877
|
+
} catch (k) {
|
|
36878
|
+
if (typeof W == "undefined" || k.name !== "ErrnoError")
|
|
36879
|
+
throw k;
|
|
36880
|
+
return -k.Pa;
|
|
36881
|
+
}
|
|
36882
|
+
}, H: function(a, b) {
|
|
36883
|
+
b = -9007199254740992 > b || 9007199254740992 < b ? NaN : Number(b);
|
|
36884
|
+
try {
|
|
36885
|
+
if (isNaN(b))
|
|
36886
|
+
return 61;
|
|
36887
|
+
var c = T(a);
|
|
36888
|
+
if (0 > b || (c.flags & 2097155) === 0)
|
|
36889
|
+
throw new N(28);
|
|
36890
|
+
cc(c, c.node, b);
|
|
36891
|
+
return 0;
|
|
36892
|
+
} catch (d) {
|
|
36893
|
+
if (typeof W == "undefined" || d.name !== "ErrnoError")
|
|
36894
|
+
throw d;
|
|
36895
|
+
return -d.Pa;
|
|
36896
|
+
}
|
|
36897
|
+
}, G: function(a, b) {
|
|
36898
|
+
try {
|
|
36899
|
+
if (b === 0)
|
|
36900
|
+
return -28;
|
|
36901
|
+
var c = ha("/") + 1;
|
|
36902
|
+
if (b < c)
|
|
36903
|
+
return -68;
|
|
36904
|
+
u("/", x2, a, b);
|
|
36905
|
+
return c;
|
|
36906
|
+
} catch (d) {
|
|
36907
|
+
if (typeof W == "undefined" || d.name !== "ErrnoError")
|
|
36908
|
+
throw d;
|
|
36909
|
+
return -d.Pa;
|
|
36910
|
+
}
|
|
36911
|
+
}, K: function(a, b) {
|
|
36912
|
+
try {
|
|
36913
|
+
return a = a ? B(x2, a) : "", Hc(b, ac(a, true));
|
|
36914
|
+
} catch (c) {
|
|
36915
|
+
if (typeof W == "undefined" || c.name !== "ErrnoError")
|
|
36916
|
+
throw c;
|
|
36917
|
+
return -c.Pa;
|
|
36918
|
+
}
|
|
36919
|
+
}, C: function(a, b, c) {
|
|
36920
|
+
try {
|
|
36921
|
+
return b = b ? B(x2, b) : "", b = Gc(a, b), U(b, c), 0;
|
|
36922
|
+
} catch (d) {
|
|
36923
|
+
if (typeof W == "undefined" || d.name !== "ErrnoError")
|
|
36924
|
+
throw d;
|
|
36925
|
+
return -d.Pa;
|
|
36926
|
+
}
|
|
36927
|
+
}, J: function(a, b, c, d) {
|
|
36928
|
+
try {
|
|
36929
|
+
b = b ? B(x2, b) : "";
|
|
36930
|
+
var e2 = d & 256;
|
|
36931
|
+
b = Gc(a, b, d & 4096);
|
|
36932
|
+
return Hc(c, e2 ? ac(b, true) : ac(b));
|
|
36933
|
+
} catch (h2) {
|
|
36934
|
+
if (typeof W == "undefined" || h2.name !== "ErrnoError")
|
|
36935
|
+
throw h2;
|
|
36936
|
+
return -h2.Pa;
|
|
36937
|
+
}
|
|
36938
|
+
}, x: function(a, b, c, d) {
|
|
36939
|
+
Ic = d;
|
|
36940
|
+
try {
|
|
36941
|
+
b = b ? B(x2, b) : "";
|
|
36942
|
+
b = Gc(a, b);
|
|
36943
|
+
var e2 = d ? Jc() : 0;
|
|
36944
|
+
return oa(b, c, e2).fd;
|
|
36945
|
+
} catch (h2) {
|
|
36946
|
+
if (typeof W == "undefined" || h2.name !== "ErrnoError")
|
|
36947
|
+
throw h2;
|
|
36948
|
+
return -h2.Pa;
|
|
36949
|
+
}
|
|
36950
|
+
}, v: function(a, b, c, d) {
|
|
36951
|
+
try {
|
|
36952
|
+
b = b ? B(x2, b) : "";
|
|
36953
|
+
b = Gc(a, b);
|
|
36954
|
+
if (0 >= d)
|
|
36955
|
+
return -28;
|
|
36956
|
+
var e2 = S2(b).node;
|
|
36957
|
+
if (!e2)
|
|
36958
|
+
throw new N(44);
|
|
36959
|
+
if (!e2.La.readlink)
|
|
36960
|
+
throw new N(28);
|
|
36961
|
+
var h2 = e2.La.readlink(e2);
|
|
36962
|
+
var k = Math.min(d, ha(h2)), q = p[c + k];
|
|
36963
|
+
u(h2, x2, c, d + 1);
|
|
36964
|
+
p[c + k] = q;
|
|
36965
|
+
return k;
|
|
36966
|
+
} catch (w) {
|
|
36967
|
+
if (typeof W == "undefined" || w.name !== "ErrnoError")
|
|
36968
|
+
throw w;
|
|
36969
|
+
return -w.Pa;
|
|
36970
|
+
}
|
|
36971
|
+
}, u: function(a) {
|
|
36972
|
+
try {
|
|
36973
|
+
return a = a ? B(x2, a) : "", $b(a), 0;
|
|
36974
|
+
} catch (b) {
|
|
36975
|
+
if (typeof W == "undefined" || b.name !== "ErrnoError")
|
|
36976
|
+
throw b;
|
|
36977
|
+
return -b.Pa;
|
|
36978
|
+
}
|
|
36979
|
+
}, f: function(a, b) {
|
|
36980
|
+
try {
|
|
36981
|
+
return a = a ? B(x2, a) : "", Hc(b, ac(a));
|
|
36982
|
+
} catch (c) {
|
|
36983
|
+
if (typeof W == "undefined" || c.name !== "ErrnoError")
|
|
36984
|
+
throw c;
|
|
36985
|
+
return -c.Pa;
|
|
36986
|
+
}
|
|
36987
|
+
}, r: function(a, b, c) {
|
|
36988
|
+
try {
|
|
36989
|
+
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;
|
|
36990
|
+
} catch (d) {
|
|
36991
|
+
if (typeof W == "undefined" || d.name !== "ErrnoError")
|
|
36992
|
+
throw d;
|
|
36993
|
+
return -d.Pa;
|
|
36994
|
+
}
|
|
36995
|
+
}, q: function(a, b, c) {
|
|
36996
|
+
try {
|
|
36997
|
+
b = b ? B(x2, b) : "";
|
|
36998
|
+
b = Gc(a, b, true);
|
|
36999
|
+
var d = Date.now(), e2, h2;
|
|
37000
|
+
if (c) {
|
|
37001
|
+
var k = F2[c >> 2] + 4294967296 * E[c + 4 >> 2], q = E[c + 8 >> 2];
|
|
37002
|
+
q == 1073741823 ? e2 = d : q == 1073741822 ? e2 = null : e2 = 1000 * k + q / 1e6;
|
|
37003
|
+
c += 16;
|
|
37004
|
+
k = F2[c >> 2] + 4294967296 * E[c + 4 >> 2];
|
|
37005
|
+
q = E[c + 8 >> 2];
|
|
37006
|
+
q == 1073741823 ? h2 = d : q == 1073741822 ? h2 = null : h2 = 1000 * k + q / 1e6;
|
|
37007
|
+
} else
|
|
37008
|
+
h2 = e2 = d;
|
|
37009
|
+
if ((h2 ?? e2) !== null) {
|
|
37010
|
+
a = e2;
|
|
37011
|
+
var w = S2(b, { $a: true }).node;
|
|
37012
|
+
Sb(w.La.Ua)(w, { atime: a, mtime: h2 });
|
|
37013
|
+
}
|
|
37014
|
+
return 0;
|
|
37015
|
+
} catch (v) {
|
|
37016
|
+
if (typeof W == "undefined" || v.name !== "ErrnoError")
|
|
37017
|
+
throw v;
|
|
37018
|
+
return -v.Pa;
|
|
37019
|
+
}
|
|
37020
|
+
}, m: () => Ta(""), l: () => {
|
|
37021
|
+
cb = false;
|
|
37022
|
+
Kc = 0;
|
|
37023
|
+
}, A: function(a, b) {
|
|
37024
|
+
a = -9007199254740992 > a || 9007199254740992 < a ? NaN : Number(a);
|
|
37025
|
+
a = new Date(1000 * a);
|
|
37026
|
+
E[b >> 2] = a.getSeconds();
|
|
37027
|
+
E[b + 4 >> 2] = a.getMinutes();
|
|
37028
|
+
E[b + 8 >> 2] = a.getHours();
|
|
37029
|
+
E[b + 12 >> 2] = a.getDate();
|
|
37030
|
+
E[b + 16 >> 2] = a.getMonth();
|
|
37031
|
+
E[b + 20 >> 2] = a.getFullYear() - 1900;
|
|
37032
|
+
E[b + 24 >> 2] = a.getDay();
|
|
37033
|
+
var c = a.getFullYear();
|
|
37034
|
+
E[b + 28 >> 2] = (c % 4 !== 0 || c % 100 === 0 && c % 400 !== 0 ? Mc : Lc)[a.getMonth()] + a.getDate() - 1 | 0;
|
|
37035
|
+
E[b + 36 >> 2] = -(60 * a.getTimezoneOffset());
|
|
37036
|
+
c = new Date(a.getFullYear(), 6, 1).getTimezoneOffset();
|
|
37037
|
+
var d = new Date(a.getFullYear(), 0, 1).getTimezoneOffset();
|
|
37038
|
+
E[b + 32 >> 2] = (c != d && a.getTimezoneOffset() == Math.min(d, c)) | 0;
|
|
37039
|
+
}, y: function(a, b, c, d, e2, h2, k) {
|
|
37040
|
+
e2 = -9007199254740992 > e2 || 9007199254740992 < e2 ? NaN : Number(e2);
|
|
37041
|
+
try {
|
|
37042
|
+
if (isNaN(e2))
|
|
37043
|
+
return 61;
|
|
37044
|
+
var q = T(d);
|
|
37045
|
+
if ((b & 2) !== 0 && (c & 2) === 0 && (q.flags & 2097155) !== 2)
|
|
37046
|
+
throw new N(2);
|
|
37047
|
+
if ((q.flags & 2097155) === 1)
|
|
37048
|
+
throw new N(2);
|
|
37049
|
+
if (!q.Ma.ib)
|
|
37050
|
+
throw new N(43);
|
|
37051
|
+
if (!a)
|
|
37052
|
+
throw new N(28);
|
|
37053
|
+
var w = q.Ma.ib(q, a, e2, b, c);
|
|
37054
|
+
var v = w.Kb;
|
|
37055
|
+
E[h2 >> 2] = w.Ab;
|
|
37056
|
+
F2[k >> 2] = v;
|
|
37057
|
+
return 0;
|
|
37058
|
+
} catch (C) {
|
|
37059
|
+
if (typeof W == "undefined" || C.name !== "ErrnoError")
|
|
37060
|
+
throw C;
|
|
37061
|
+
return -C.Pa;
|
|
37062
|
+
}
|
|
37063
|
+
}, z: function(a, b, c, d, e2, h2) {
|
|
37064
|
+
h2 = -9007199254740992 > h2 || 9007199254740992 < h2 ? NaN : Number(h2);
|
|
37065
|
+
try {
|
|
37066
|
+
var k = T(e2);
|
|
37067
|
+
if (c & 2) {
|
|
37068
|
+
c = h2;
|
|
37069
|
+
if ((k.node.mode & 61440) !== 32768)
|
|
37070
|
+
throw new N(43);
|
|
37071
|
+
if (!(d & 2)) {
|
|
37072
|
+
var q = x2.slice(a, a + b);
|
|
37073
|
+
k.Ma.jb && k.Ma.jb(k, q, c, b, d);
|
|
37074
|
+
}
|
|
37075
|
+
}
|
|
37076
|
+
} catch (w) {
|
|
37077
|
+
if (typeof W == "undefined" || w.name !== "ErrnoError")
|
|
37078
|
+
throw w;
|
|
37079
|
+
return -w.Pa;
|
|
37080
|
+
}
|
|
37081
|
+
}, n: (a, b) => {
|
|
37082
|
+
Nc[a] && (clearTimeout(Nc[a].id), delete Nc[a]);
|
|
37083
|
+
if (!b)
|
|
37084
|
+
return 0;
|
|
37085
|
+
var c = setTimeout(() => {
|
|
37086
|
+
delete Nc[a];
|
|
37087
|
+
Pc(() => Wc(a, performance.now()));
|
|
37088
|
+
}, b);
|
|
37089
|
+
Nc[a] = {
|
|
37090
|
+
id: c,
|
|
37091
|
+
Xb: b
|
|
37092
|
+
};
|
|
37093
|
+
return 0;
|
|
37094
|
+
}, B: (a, b, c, d) => {
|
|
37095
|
+
var e2 = new Date().getFullYear(), h2 = new Date(e2, 0, 1).getTimezoneOffset();
|
|
37096
|
+
e2 = new Date(e2, 6, 1).getTimezoneOffset();
|
|
37097
|
+
F2[a >> 2] = 60 * Math.max(h2, e2);
|
|
37098
|
+
E[b >> 2] = Number(h2 != e2);
|
|
37099
|
+
b = (k) => {
|
|
37100
|
+
var q = Math.abs(k);
|
|
37101
|
+
return `UTC${0 <= k ? "-" : "+"}${String(Math.floor(q / 60)).padStart(2, "0")}${String(q % 60).padStart(2, "0")}`;
|
|
37102
|
+
};
|
|
37103
|
+
a = b(h2);
|
|
37104
|
+
b = b(e2);
|
|
37105
|
+
e2 < h2 ? (u(a, x2, c, 17), u(b, x2, d, 17)) : (u(a, x2, d, 17), u(b, x2, c, 17));
|
|
37106
|
+
}, d: () => Date.now(), s: () => 2147483648, c: () => performance.now(), o: (a) => {
|
|
37107
|
+
var b = x2.length;
|
|
37108
|
+
a >>>= 0;
|
|
37109
|
+
if (2147483648 < a)
|
|
37110
|
+
return false;
|
|
37111
|
+
for (var c = 1;4 >= c; c *= 2) {
|
|
37112
|
+
var d = b * (1 + 0.2 / c);
|
|
37113
|
+
d = Math.min(d, a + 100663296);
|
|
37114
|
+
a: {
|
|
37115
|
+
d = (Math.min(2147483648, 65536 * Math.ceil(Math.max(a, d) / 65536)) - Ka.buffer.byteLength + 65535) / 65536 | 0;
|
|
37116
|
+
try {
|
|
37117
|
+
Ka.grow(d);
|
|
37118
|
+
Qa();
|
|
37119
|
+
var e2 = 1;
|
|
37120
|
+
break a;
|
|
37121
|
+
} catch (h2) {}
|
|
37122
|
+
e2 = undefined;
|
|
37123
|
+
}
|
|
37124
|
+
if (e2)
|
|
37125
|
+
return true;
|
|
37126
|
+
}
|
|
37127
|
+
return false;
|
|
37128
|
+
}, E: (a, b) => {
|
|
37129
|
+
var c = 0;
|
|
37130
|
+
Sc().forEach((d, e2) => {
|
|
37131
|
+
var h2 = b + c;
|
|
37132
|
+
e2 = F2[a + 4 * e2 >> 2] = h2;
|
|
37133
|
+
for (h2 = 0;h2 < d.length; ++h2)
|
|
37134
|
+
p[e2++] = d.charCodeAt(h2);
|
|
37135
|
+
p[e2] = 0;
|
|
37136
|
+
c += d.length + 1;
|
|
37137
|
+
});
|
|
37138
|
+
return 0;
|
|
37139
|
+
}, F: (a, b) => {
|
|
37140
|
+
var c = Sc();
|
|
37141
|
+
F2[a >> 2] = c.length;
|
|
37142
|
+
var d = 0;
|
|
37143
|
+
c.forEach((e2) => d += e2.length + 1);
|
|
37144
|
+
F2[b >> 2] = d;
|
|
37145
|
+
return 0;
|
|
37146
|
+
}, e: function(a) {
|
|
37147
|
+
try {
|
|
37148
|
+
var b = T(a);
|
|
37149
|
+
qa(b);
|
|
37150
|
+
return 0;
|
|
37151
|
+
} catch (c) {
|
|
37152
|
+
if (typeof W == "undefined" || c.name !== "ErrnoError")
|
|
37153
|
+
throw c;
|
|
37154
|
+
return c.Pa;
|
|
37155
|
+
}
|
|
37156
|
+
}, p: function(a, b) {
|
|
37157
|
+
try {
|
|
37158
|
+
var c = T(a);
|
|
37159
|
+
p[b] = c.tty ? 2 : P(c.mode) ? 3 : (c.mode & 61440) === 40960 ? 7 : 4;
|
|
37160
|
+
Na[b + 2 >> 1] = 0;
|
|
37161
|
+
H[b + 8 >> 3] = BigInt(0);
|
|
37162
|
+
H[b + 16 >> 3] = BigInt(0);
|
|
37163
|
+
return 0;
|
|
37164
|
+
} catch (d) {
|
|
37165
|
+
if (typeof W == "undefined" || d.name !== "ErrnoError")
|
|
37166
|
+
throw d;
|
|
37167
|
+
return d.Pa;
|
|
37168
|
+
}
|
|
37169
|
+
}, w: function(a, b, c, d) {
|
|
37170
|
+
try {
|
|
37171
|
+
a: {
|
|
37172
|
+
var e2 = T(a);
|
|
37173
|
+
a = b;
|
|
37174
|
+
for (var h2, k = b = 0;k < c; k++) {
|
|
37175
|
+
var q = F2[a >> 2], w = F2[a + 4 >> 2];
|
|
37176
|
+
a += 8;
|
|
37177
|
+
var v = Ec(e2, p, q, w, h2);
|
|
37178
|
+
if (0 > v) {
|
|
37179
|
+
var C = -1;
|
|
37180
|
+
break a;
|
|
37181
|
+
}
|
|
37182
|
+
b += v;
|
|
37183
|
+
if (v < w)
|
|
37184
|
+
break;
|
|
37185
|
+
typeof h2 != "undefined" && (h2 += v);
|
|
37186
|
+
}
|
|
37187
|
+
C = b;
|
|
37188
|
+
}
|
|
37189
|
+
F2[d >> 2] = C;
|
|
37190
|
+
return 0;
|
|
37191
|
+
} catch (G) {
|
|
37192
|
+
if (typeof W == "undefined" || G.name !== "ErrnoError")
|
|
37193
|
+
throw G;
|
|
37194
|
+
return G.Pa;
|
|
37195
|
+
}
|
|
37196
|
+
}, D: function(a, b, c, d) {
|
|
37197
|
+
b = -9007199254740992 > b || 9007199254740992 < b ? NaN : Number(b);
|
|
37198
|
+
try {
|
|
37199
|
+
if (isNaN(b))
|
|
37200
|
+
return 61;
|
|
37201
|
+
var e2 = T(a);
|
|
37202
|
+
mc(e2, b, c);
|
|
37203
|
+
H[d >> 3] = BigInt(e2.position);
|
|
37204
|
+
e2.ob && b === 0 && c === 0 && (e2.ob = null);
|
|
37205
|
+
return 0;
|
|
37206
|
+
} catch (h2) {
|
|
37207
|
+
if (typeof W == "undefined" || h2.name !== "ErrnoError")
|
|
37208
|
+
throw h2;
|
|
37209
|
+
return h2.Pa;
|
|
37210
|
+
}
|
|
37211
|
+
}, I: function(a) {
|
|
37212
|
+
try {
|
|
37213
|
+
var b = T(a);
|
|
37214
|
+
return b.Ma?.fsync ? b.Ma.fsync(b) : 0;
|
|
37215
|
+
} catch (c) {
|
|
37216
|
+
if (typeof W == "undefined" || c.name !== "ErrnoError")
|
|
37217
|
+
throw c;
|
|
37218
|
+
return c.Pa;
|
|
37219
|
+
}
|
|
37220
|
+
}, t: function(a, b, c, d) {
|
|
37221
|
+
try {
|
|
37222
|
+
a: {
|
|
37223
|
+
var e2 = T(a);
|
|
37224
|
+
a = b;
|
|
37225
|
+
for (var h2, k = b = 0;k < c; k++) {
|
|
37226
|
+
var q = F2[a >> 2], w = F2[a + 4 >> 2];
|
|
37227
|
+
a += 8;
|
|
37228
|
+
var v = pa(e2, p, q, w, h2);
|
|
37229
|
+
if (0 > v) {
|
|
37230
|
+
var C = -1;
|
|
37231
|
+
break a;
|
|
37232
|
+
}
|
|
37233
|
+
b += v;
|
|
37234
|
+
if (v < w)
|
|
37235
|
+
break;
|
|
37236
|
+
typeof h2 != "undefined" && (h2 += v);
|
|
37237
|
+
}
|
|
37238
|
+
C = b;
|
|
37239
|
+
}
|
|
37240
|
+
F2[d >> 2] = C;
|
|
37241
|
+
return 0;
|
|
37242
|
+
} catch (G) {
|
|
37243
|
+
if (typeof W == "undefined" || G.name !== "ErrnoError")
|
|
37244
|
+
throw G;
|
|
37245
|
+
return G.Pa;
|
|
37246
|
+
}
|
|
37247
|
+
}, k: Oc }, Z2;
|
|
37248
|
+
(async function() {
|
|
37249
|
+
function a(c) {
|
|
37250
|
+
Z2 = c.exports;
|
|
37251
|
+
Ka = Z2.M;
|
|
37252
|
+
Qa();
|
|
37253
|
+
Y = Z2.O;
|
|
37254
|
+
K--;
|
|
37255
|
+
f3.monitorRunDependencies?.(K);
|
|
37256
|
+
K == 0 && Sa && (c = Sa, Sa = null, c());
|
|
37257
|
+
return Z2;
|
|
37258
|
+
}
|
|
37259
|
+
K++;
|
|
37260
|
+
f3.monitorRunDependencies?.(K);
|
|
37261
|
+
var b = { a: Xc };
|
|
37262
|
+
if (f3.instantiateWasm)
|
|
37263
|
+
return new Promise((c) => {
|
|
37264
|
+
f3.instantiateWasm(b, (d, e2) => {
|
|
37265
|
+
a(d, e2);
|
|
37266
|
+
c(d.exports);
|
|
37267
|
+
});
|
|
37268
|
+
});
|
|
37269
|
+
Ua ??= f3.locateFile ? f3.locateFile("sql-wasm.wasm", D) : D + "sql-wasm.wasm";
|
|
37270
|
+
return a((await Xa(b)).instance);
|
|
37271
|
+
})();
|
|
37272
|
+
f3._sqlite3_free = (a) => (f3._sqlite3_free = Z2.P)(a);
|
|
37273
|
+
f3._sqlite3_value_text = (a) => (f3._sqlite3_value_text = Z2.Q)(a);
|
|
37274
|
+
f3._sqlite3_prepare_v2 = (a, b, c, d, e2) => (f3._sqlite3_prepare_v2 = Z2.R)(a, b, c, d, e2);
|
|
37275
|
+
f3._sqlite3_step = (a) => (f3._sqlite3_step = Z2.S)(a);
|
|
37276
|
+
f3._sqlite3_reset = (a) => (f3._sqlite3_reset = Z2.T)(a);
|
|
37277
|
+
f3._sqlite3_exec = (a, b, c, d, e2) => (f3._sqlite3_exec = Z2.U)(a, b, c, d, e2);
|
|
37278
|
+
f3._sqlite3_finalize = (a) => (f3._sqlite3_finalize = Z2.V)(a);
|
|
37279
|
+
f3._sqlite3_column_name = (a, b) => (f3._sqlite3_column_name = Z2.W)(a, b);
|
|
37280
|
+
f3._sqlite3_column_text = (a, b) => (f3._sqlite3_column_text = Z2.X)(a, b);
|
|
37281
|
+
f3._sqlite3_column_type = (a, b) => (f3._sqlite3_column_type = Z2.Y)(a, b);
|
|
37282
|
+
f3._sqlite3_errmsg = (a) => (f3._sqlite3_errmsg = Z2.Z)(a);
|
|
37283
|
+
f3._sqlite3_clear_bindings = (a) => (f3._sqlite3_clear_bindings = Z2._)(a);
|
|
37284
|
+
f3._sqlite3_value_blob = (a) => (f3._sqlite3_value_blob = Z2.$)(a);
|
|
37285
|
+
f3._sqlite3_value_bytes = (a) => (f3._sqlite3_value_bytes = Z2.aa)(a);
|
|
37286
|
+
f3._sqlite3_value_double = (a) => (f3._sqlite3_value_double = Z2.ba)(a);
|
|
37287
|
+
f3._sqlite3_value_int = (a) => (f3._sqlite3_value_int = Z2.ca)(a);
|
|
37288
|
+
f3._sqlite3_value_type = (a) => (f3._sqlite3_value_type = Z2.da)(a);
|
|
37289
|
+
f3._sqlite3_result_blob = (a, b, c, d) => (f3._sqlite3_result_blob = Z2.ea)(a, b, c, d);
|
|
37290
|
+
f3._sqlite3_result_double = (a, b) => (f3._sqlite3_result_double = Z2.fa)(a, b);
|
|
37291
|
+
f3._sqlite3_result_error = (a, b, c) => (f3._sqlite3_result_error = Z2.ga)(a, b, c);
|
|
37292
|
+
f3._sqlite3_result_int = (a, b) => (f3._sqlite3_result_int = Z2.ha)(a, b);
|
|
37293
|
+
f3._sqlite3_result_int64 = (a, b) => (f3._sqlite3_result_int64 = Z2.ia)(a, b);
|
|
37294
|
+
f3._sqlite3_result_null = (a) => (f3._sqlite3_result_null = Z2.ja)(a);
|
|
37295
|
+
f3._sqlite3_result_text = (a, b, c, d) => (f3._sqlite3_result_text = Z2.ka)(a, b, c, d);
|
|
37296
|
+
f3._sqlite3_aggregate_context = (a, b) => (f3._sqlite3_aggregate_context = Z2.la)(a, b);
|
|
37297
|
+
f3._sqlite3_column_count = (a) => (f3._sqlite3_column_count = Z2.ma)(a);
|
|
37298
|
+
f3._sqlite3_data_count = (a) => (f3._sqlite3_data_count = Z2.na)(a);
|
|
37299
|
+
f3._sqlite3_column_blob = (a, b) => (f3._sqlite3_column_blob = Z2.oa)(a, b);
|
|
37300
|
+
f3._sqlite3_column_bytes = (a, b) => (f3._sqlite3_column_bytes = Z2.pa)(a, b);
|
|
37301
|
+
f3._sqlite3_column_double = (a, b) => (f3._sqlite3_column_double = Z2.qa)(a, b);
|
|
37302
|
+
f3._sqlite3_bind_blob = (a, b, c, d, e2) => (f3._sqlite3_bind_blob = Z2.ra)(a, b, c, d, e2);
|
|
37303
|
+
f3._sqlite3_bind_double = (a, b, c) => (f3._sqlite3_bind_double = Z2.sa)(a, b, c);
|
|
37304
|
+
f3._sqlite3_bind_int = (a, b, c) => (f3._sqlite3_bind_int = Z2.ta)(a, b, c);
|
|
37305
|
+
f3._sqlite3_bind_text = (a, b, c, d, e2) => (f3._sqlite3_bind_text = Z2.ua)(a, b, c, d, e2);
|
|
37306
|
+
f3._sqlite3_bind_parameter_index = (a, b) => (f3._sqlite3_bind_parameter_index = Z2.va)(a, b);
|
|
37307
|
+
f3._sqlite3_sql = (a) => (f3._sqlite3_sql = Z2.wa)(a);
|
|
37308
|
+
f3._sqlite3_normalized_sql = (a) => (f3._sqlite3_normalized_sql = Z2.xa)(a);
|
|
37309
|
+
f3._sqlite3_changes = (a) => (f3._sqlite3_changes = Z2.ya)(a);
|
|
37310
|
+
f3._sqlite3_close_v2 = (a) => (f3._sqlite3_close_v2 = Z2.za)(a);
|
|
37311
|
+
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);
|
|
37312
|
+
f3._sqlite3_update_hook = (a, b, c) => (f3._sqlite3_update_hook = Z2.Ba)(a, b, c);
|
|
37313
|
+
f3._sqlite3_open = (a, b) => (f3._sqlite3_open = Z2.Ca)(a, b);
|
|
37314
|
+
var ia = f3._malloc = (a) => (ia = f3._malloc = Z2.Da)(a), fa = f3._free = (a) => (fa = f3._free = Z2.Ea)(a);
|
|
37315
|
+
f3._RegisterExtensionFunctions = (a) => (f3._RegisterExtensionFunctions = Z2.Fa)(a);
|
|
37316
|
+
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)();
|
|
37317
|
+
f3.stackSave = () => sa();
|
|
37318
|
+
f3.stackRestore = (a) => wa(a);
|
|
37319
|
+
f3.stackAlloc = (a) => z2(a);
|
|
37320
|
+
f3.cwrap = (a, b, c, d) => {
|
|
37321
|
+
var e2 = !c || c.every((h2) => h2 === "number" || h2 === "boolean");
|
|
37322
|
+
return b !== "string" && e2 && !d ? f3["_" + a] : (...h2) => Tc(a, b, c, h2);
|
|
37323
|
+
};
|
|
37324
|
+
f3.addFunction = Aa;
|
|
37325
|
+
f3.removeFunction = A2;
|
|
37326
|
+
f3.UTF8ToString = ua;
|
|
37327
|
+
f3.ALLOC_NORMAL = ea;
|
|
37328
|
+
f3.allocate = da;
|
|
37329
|
+
f3.allocateUTF8OnStack = xa;
|
|
37330
|
+
function Yc() {
|
|
37331
|
+
function a() {
|
|
37332
|
+
f3.calledRun = true;
|
|
37333
|
+
if (!La) {
|
|
37334
|
+
if (!f3.noFSInit && !Ib) {
|
|
37335
|
+
var b, c;
|
|
37336
|
+
Ib = true;
|
|
37337
|
+
d ??= f3.stdin;
|
|
37338
|
+
b ??= f3.stdout;
|
|
37339
|
+
c ??= f3.stderr;
|
|
37340
|
+
d ? V("stdin", d) : Zb("/dev/tty", "/dev/stdin");
|
|
37341
|
+
b ? V("stdout", null, b) : Zb("/dev/tty", "/dev/stdout");
|
|
37342
|
+
c ? V("stderr", null, c) : Zb("/dev/tty1", "/dev/stderr");
|
|
37343
|
+
oa("/dev/stdin", 0);
|
|
37344
|
+
oa("/dev/stdout", 1);
|
|
37345
|
+
oa("/dev/stderr", 1);
|
|
37346
|
+
}
|
|
37347
|
+
Z2.N();
|
|
37348
|
+
Jb = false;
|
|
37349
|
+
f3.onRuntimeInitialized?.();
|
|
37350
|
+
if (f3.postRun)
|
|
37351
|
+
for (typeof f3.postRun == "function" && (f3.postRun = [f3.postRun]);f3.postRun.length; ) {
|
|
37352
|
+
var d = f3.postRun.shift();
|
|
37353
|
+
$a.unshift(d);
|
|
37354
|
+
}
|
|
37355
|
+
Za($a);
|
|
37356
|
+
}
|
|
37357
|
+
}
|
|
37358
|
+
if (0 < K)
|
|
37359
|
+
Sa = Yc;
|
|
37360
|
+
else {
|
|
37361
|
+
if (f3.preRun)
|
|
37362
|
+
for (typeof f3.preRun == "function" && (f3.preRun = [f3.preRun]);f3.preRun.length; )
|
|
37363
|
+
bb();
|
|
37364
|
+
Za(ab);
|
|
37365
|
+
0 < K ? Sa = Yc : f3.setStatus ? (f3.setStatus("Running..."), setTimeout(() => {
|
|
37366
|
+
setTimeout(() => f3.setStatus(""), 1);
|
|
37367
|
+
a();
|
|
37368
|
+
}, 1)) : a();
|
|
37369
|
+
}
|
|
37370
|
+
}
|
|
37371
|
+
if (f3.preInit)
|
|
37372
|
+
for (typeof f3.preInit == "function" && (f3.preInit = [f3.preInit]);0 < f3.preInit.length; )
|
|
37373
|
+
f3.preInit.pop()();
|
|
37374
|
+
Yc();
|
|
37375
|
+
return Module;
|
|
37376
|
+
});
|
|
37377
|
+
return initSqlJsPromise;
|
|
37378
|
+
};
|
|
37379
|
+
if (typeof exports === "object" && typeof module === "object") {
|
|
37380
|
+
module.exports = initSqlJs;
|
|
37381
|
+
module.exports.default = initSqlJs;
|
|
37382
|
+
} else if (typeof define === "function" && define["amd"]) {
|
|
37383
|
+
define([], function() {
|
|
37384
|
+
return initSqlJs;
|
|
37385
|
+
});
|
|
37386
|
+
} else if (typeof exports === "object") {
|
|
37387
|
+
exports["Module"] = initSqlJs;
|
|
37388
|
+
}
|
|
37389
|
+
});
|
|
37390
|
+
|
|
35107
37391
|
// src/config.ts
|
|
35108
37392
|
import { existsSync, readFileSync } from "node:fs";
|
|
35109
37393
|
import { readFile } from "node:fs/promises";
|
|
@@ -48641,6 +50925,57 @@ function date4(params) {
|
|
|
48641
50925
|
|
|
48642
50926
|
// ../../node_modules/zod/v4/classic/external.js
|
|
48643
50927
|
config(en_default());
|
|
50928
|
+
// ../core/src/config/base.ts
|
|
50929
|
+
var baseModelConfigSchema = exports_external.object({
|
|
50930
|
+
provider: exports_external.string().optional(),
|
|
50931
|
+
model: exports_external.string().optional(),
|
|
50932
|
+
parameters: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
|
|
50933
|
+
});
|
|
50934
|
+
var baseApprovalConfigSchema = exports_external.object({
|
|
50935
|
+
level: exports_external.enum(["none", "destructive", "commits", "all"]).optional(),
|
|
50936
|
+
autoApprove: exports_external.boolean().optional(),
|
|
50937
|
+
maxCost: exports_external.number().positive().optional()
|
|
50938
|
+
});
|
|
50939
|
+
var providerConfigSchema = exports_external.object({
|
|
50940
|
+
apiKey: exports_external.string().optional(),
|
|
50941
|
+
defaultModel: exports_external.string().optional(),
|
|
50942
|
+
defaultParameters: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
|
|
50943
|
+
location: exports_external.string().optional(),
|
|
50944
|
+
project: exports_external.string().optional(),
|
|
50945
|
+
keyFile: exports_external.string().optional(),
|
|
50946
|
+
baseUrl: exports_external.string().optional(),
|
|
50947
|
+
name: exports_external.string().optional()
|
|
50948
|
+
});
|
|
50949
|
+
var modelConfigSchema = baseModelConfigSchema.extend({
|
|
50950
|
+
budget: exports_external.number().positive().optional(),
|
|
50951
|
+
rules: exports_external.union([exports_external.string(), exports_external.array(exports_external.string()).optional()]).optional()
|
|
50952
|
+
});
|
|
50953
|
+
var toolConfigSchema = exports_external.union([
|
|
50954
|
+
exports_external.boolean(),
|
|
50955
|
+
baseModelConfigSchema
|
|
50956
|
+
]);
|
|
50957
|
+
|
|
50958
|
+
// ../core/src/config/memory.ts
|
|
50959
|
+
var memoryConfigSchema = exports_external.object({
|
|
50960
|
+
enabled: exports_external.boolean().optional().default(true),
|
|
50961
|
+
type: exports_external.enum(["sqlite", "memory"]).optional().default("sqlite"),
|
|
50962
|
+
path: exports_external.string().optional().default("~/.config/polka-codes/memory.sqlite")
|
|
50963
|
+
}).strict().optional();
|
|
50964
|
+
var DEFAULT_MEMORY_CONFIG = {
|
|
50965
|
+
enabled: true,
|
|
50966
|
+
type: "sqlite",
|
|
50967
|
+
path: "~/.config/polka-codes/memory.sqlite"
|
|
50968
|
+
};
|
|
50969
|
+
function resolveHomePath(path) {
|
|
50970
|
+
if (path.startsWith("~")) {
|
|
50971
|
+
const home = process.env.HOME || process.env.USERPROFILE || ".";
|
|
50972
|
+
if (home === ".") {
|
|
50973
|
+
throw new Error("Cannot resolve home directory: HOME and USERPROFILE environment variables are not set");
|
|
50974
|
+
}
|
|
50975
|
+
return `${home}${path.slice(1)}`;
|
|
50976
|
+
}
|
|
50977
|
+
return path;
|
|
50978
|
+
}
|
|
48644
50979
|
// ../core/src/config.ts
|
|
48645
50980
|
var ruleSchema = exports_external.union([
|
|
48646
50981
|
exports_external.string(),
|
|
@@ -48654,20 +50989,10 @@ var ruleSchema = exports_external.union([
|
|
|
48654
50989
|
branch: exports_external.string().optional()
|
|
48655
50990
|
}).strict()
|
|
48656
50991
|
]);
|
|
48657
|
-
var providerConfigSchema = exports_external.object({
|
|
48658
|
-
apiKey: exports_external.string().optional(),
|
|
48659
|
-
defaultModel: exports_external.string().optional(),
|
|
48660
|
-
defaultParameters: exports_external.record(exports_external.string(), exports_external.any()).optional(),
|
|
48661
|
-
location: exports_external.string().optional(),
|
|
48662
|
-
project: exports_external.string().optional(),
|
|
48663
|
-
keyFile: exports_external.string().optional(),
|
|
48664
|
-
baseUrl: exports_external.string().optional(),
|
|
48665
|
-
name: exports_external.string().optional()
|
|
48666
|
-
});
|
|
48667
50992
|
var providerModelSchema = exports_external.object({
|
|
48668
50993
|
provider: exports_external.string().optional(),
|
|
48669
50994
|
model: exports_external.string().optional(),
|
|
48670
|
-
parameters: exports_external.record(exports_external.string(), exports_external.
|
|
50995
|
+
parameters: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
|
|
48671
50996
|
budget: exports_external.number().positive().optional(),
|
|
48672
50997
|
rules: exports_external.array(ruleSchema).optional().or(exports_external.string()).optional()
|
|
48673
50998
|
});
|
|
@@ -48680,7 +51005,7 @@ var scriptSchema = exports_external.union([
|
|
|
48680
51005
|
exports_external.object({
|
|
48681
51006
|
workflow: exports_external.string(),
|
|
48682
51007
|
description: exports_external.string().optional(),
|
|
48683
|
-
input: exports_external.record(exports_external.string(), exports_external.
|
|
51008
|
+
input: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
|
|
48684
51009
|
}).strict(),
|
|
48685
51010
|
exports_external.object({
|
|
48686
51011
|
script: exports_external.string(),
|
|
@@ -48759,7 +51084,7 @@ var configSchema = exports_external.object({
|
|
|
48759
51084
|
providers: exports_external.record(exports_external.string(), providerConfigSchema).optional(),
|
|
48760
51085
|
defaultProvider: exports_external.string().optional(),
|
|
48761
51086
|
defaultModel: exports_external.string().optional(),
|
|
48762
|
-
defaultParameters: exports_external.record(exports_external.string(), exports_external.
|
|
51087
|
+
defaultParameters: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
|
|
48763
51088
|
maxMessageCount: exports_external.number().int().positive().optional(),
|
|
48764
51089
|
budget: exports_external.number().positive().optional(),
|
|
48765
51090
|
retryCount: exports_external.number().int().min(0).optional(),
|
|
@@ -48773,7 +51098,8 @@ var configSchema = exports_external.object({
|
|
|
48773
51098
|
mcpServers: exports_external.record(exports_external.string(), mcpServerConfigSchema).optional(),
|
|
48774
51099
|
rules: exports_external.array(ruleSchema).optional().or(exports_external.string()).optional(),
|
|
48775
51100
|
excludeFiles: exports_external.array(exports_external.string()).optional(),
|
|
48776
|
-
agent: agentSchema
|
|
51101
|
+
agent: agentSchema,
|
|
51102
|
+
memory: memoryConfigSchema
|
|
48777
51103
|
}).strict().nullish();
|
|
48778
51104
|
// ../core/src/skills/constants.ts
|
|
48779
51105
|
var SKILL_LIMITS = {
|
|
@@ -49246,14 +51572,40 @@ var readBinaryFile_default = {
|
|
|
49246
51572
|
// ../core/src/tools/readFile.ts
|
|
49247
51573
|
var toolInfo6 = {
|
|
49248
51574
|
name: "readFile",
|
|
49249
|
-
description:
|
|
51575
|
+
description: `Request to read the contents of one or multiple files at the specified paths.
|
|
51576
|
+
|
|
51577
|
+
When to use:
|
|
51578
|
+
- Examining file contents you don't know
|
|
51579
|
+
- Analyzing code, reviewing text files, extracting configuration info
|
|
51580
|
+
- Reading multiple files at once (use comma-separated paths)
|
|
51581
|
+
- Understanding file structure before editing
|
|
51582
|
+
|
|
51583
|
+
When NOT to use:
|
|
51584
|
+
- For file existence checks: Use listFiles instead
|
|
51585
|
+
- For searching within files: Use grep instead
|
|
51586
|
+
- For file name searches: Use searchFiles instead
|
|
51587
|
+
- Prefer this tool over executeCommand with cat/head/tail
|
|
51588
|
+
|
|
51589
|
+
Features:
|
|
51590
|
+
- Supports comma-separated paths for multiple files
|
|
51591
|
+
- Line numbers included for easy reference
|
|
51592
|
+
- Optional offset/limit for partial file reading
|
|
51593
|
+
- Automatically handles different file types
|
|
51594
|
+
|
|
51595
|
+
IMPORTANT:
|
|
51596
|
+
- Line numbers are included for easy reference
|
|
51597
|
+
- Use offset/limit for large files to read specific sections`,
|
|
49250
51598
|
parameters: exports_external.object({
|
|
49251
51599
|
path: exports_external.preprocess((val) => {
|
|
49252
51600
|
if (!val)
|
|
49253
51601
|
return [];
|
|
49254
|
-
|
|
49255
|
-
|
|
51602
|
+
if (Array.isArray(val)) {
|
|
51603
|
+
return val.filter((s) => typeof s === "string" && s.length > 0);
|
|
51604
|
+
}
|
|
51605
|
+
return val.split(",").filter((s) => s.length > 0);
|
|
49256
51606
|
}, exports_external.array(exports_external.string())).describe("The path of the file to read").meta({ usageValue: "Comma separated paths here" }),
|
|
51607
|
+
offset: exports_external.number().optional().describe("Skip first N lines (for partial file reading)").meta({ usageValue: "100" }),
|
|
51608
|
+
limit: exports_external.number().optional().describe("Read at most N lines (for partial file reading)").meta({ usageValue: "50" }),
|
|
49257
51609
|
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)" })
|
|
49258
51610
|
}).meta({
|
|
49259
51611
|
examples: [
|
|
@@ -49268,6 +51620,14 @@ var toolInfo6 = {
|
|
|
49268
51620
|
input: {
|
|
49269
51621
|
path: "src/main.js,src/index.js"
|
|
49270
51622
|
}
|
|
51623
|
+
},
|
|
51624
|
+
{
|
|
51625
|
+
description: "Read partial file (lines 100-150)",
|
|
51626
|
+
input: {
|
|
51627
|
+
path: "src/large-file.ts",
|
|
51628
|
+
offset: 100,
|
|
51629
|
+
limit: 50
|
|
51630
|
+
}
|
|
49271
51631
|
}
|
|
49272
51632
|
]
|
|
49273
51633
|
})
|
|
@@ -49276,15 +51636,39 @@ var handler6 = async (provider, args) => {
|
|
|
49276
51636
|
if (!provider.readFile) {
|
|
49277
51637
|
return createProviderErrorResponse("read file");
|
|
49278
51638
|
}
|
|
49279
|
-
const
|
|
51639
|
+
const parsed = toolInfo6.parameters.safeParse(args);
|
|
51640
|
+
if (!parsed.success) {
|
|
51641
|
+
return {
|
|
51642
|
+
success: false,
|
|
51643
|
+
message: {
|
|
51644
|
+
type: "error-text",
|
|
51645
|
+
value: `Invalid arguments for readFile: ${parsed.error.message}`
|
|
51646
|
+
}
|
|
51647
|
+
};
|
|
51648
|
+
}
|
|
51649
|
+
const { path: paths, offset, limit, includeIgnored } = parsed.data;
|
|
49280
51650
|
const resp = [];
|
|
49281
51651
|
for (const path of paths) {
|
|
49282
51652
|
const fileContent = await provider.readFile(path, includeIgnored ?? false);
|
|
49283
51653
|
if (!fileContent) {
|
|
49284
51654
|
resp.push(createFileElement("read_file_file_content", path, undefined, { file_not_found: "true" }));
|
|
49285
|
-
|
|
49286
|
-
resp.push(createFileElement("read_file_file_content", path, fileContent));
|
|
51655
|
+
continue;
|
|
49287
51656
|
}
|
|
51657
|
+
let lines = fileContent.split(`
|
|
51658
|
+
`);
|
|
51659
|
+
const start = offset ?? 0;
|
|
51660
|
+
const end = limit ? start + limit : lines.length;
|
|
51661
|
+
if (offset !== undefined || limit !== undefined) {
|
|
51662
|
+
lines = lines.slice(start, end);
|
|
51663
|
+
}
|
|
51664
|
+
const lineOffset = offset ?? 0;
|
|
51665
|
+
const numberedContent = lines.map((line, i) => {
|
|
51666
|
+
const lineNumber = lineOffset + i + 1;
|
|
51667
|
+
const paddedNumber = String(lineNumber).padStart(6, " ");
|
|
51668
|
+
return `${paddedNumber}→${line}`;
|
|
51669
|
+
}).join(`
|
|
51670
|
+
`);
|
|
51671
|
+
resp.push(createFileElement("read_file_file_content", path, numberedContent));
|
|
49288
51672
|
}
|
|
49289
51673
|
return {
|
|
49290
51674
|
success: true,
|
|
@@ -49481,7 +51865,43 @@ var replaceInFile = (fileContent, diff) => {
|
|
|
49481
51865
|
// ../core/src/tools/replaceInFile.ts
|
|
49482
51866
|
var toolInfo9 = {
|
|
49483
51867
|
name: "replaceInFile",
|
|
49484
|
-
description:
|
|
51868
|
+
description: `Request to replace sections of content in an existing file using
|
|
51869
|
+
SEARCH/REPLACE blocks.
|
|
51870
|
+
|
|
51871
|
+
When to use:
|
|
51872
|
+
- Making targeted changes to specific parts of a file
|
|
51873
|
+
- Replacing variable names, function signatures, imports
|
|
51874
|
+
- Fixing bugs in existing code
|
|
51875
|
+
- When you know the exact content to replace
|
|
51876
|
+
|
|
51877
|
+
When NOT to use:
|
|
51878
|
+
- For creating new files: Use writeToFile instead
|
|
51879
|
+
- For completely replacing file contents: Use writeToFile instead
|
|
51880
|
+
- When you don't know the exact content: Read file first
|
|
51881
|
+
|
|
51882
|
+
SEARCH/REPLACE FORMAT:
|
|
51883
|
+
<<<<<<< SEARCH
|
|
51884
|
+
[exact content to find]
|
|
51885
|
+
=======
|
|
51886
|
+
[new content to replace with]
|
|
51887
|
+
>>>>>>> REPLACE
|
|
51888
|
+
|
|
51889
|
+
Critical rules:
|
|
51890
|
+
1. SEARCH content must match EXACTLY (character-for-character including whitespace)
|
|
51891
|
+
2. Each block replaces only first occurrence
|
|
51892
|
+
3. Include just enough lines for uniqueness (not too many, not too few)
|
|
51893
|
+
4. Keep blocks concise (don't include long unchanged sections)
|
|
51894
|
+
5. List blocks in order they appear in file
|
|
51895
|
+
6. Use multiple blocks for multiple independent changes
|
|
51896
|
+
|
|
51897
|
+
Special operations:
|
|
51898
|
+
- Move code: Two blocks (delete from original + insert at new location)
|
|
51899
|
+
- Delete code: Empty REPLACE section
|
|
51900
|
+
|
|
51901
|
+
IMPORTANT CONSTRAINTS:
|
|
51902
|
+
- SEARCH text must match file content exactly
|
|
51903
|
+
- Each block is independent (doesn't affect other blocks)
|
|
51904
|
+
- Cannot use for appending or inserting without SEARCH context`,
|
|
49485
51905
|
parameters: exports_external.object({
|
|
49486
51906
|
path: exports_external.string().describe("The path of the file to modify").meta({ usageValue: "File path here" }),
|
|
49487
51907
|
diff: exports_external.string().describe(`One or more SEARCH/REPLACE blocks following this exact format:
|
|
@@ -49507,7 +51927,7 @@ Critical rules:
|
|
|
49507
51927
|
* Each line must be complete. Never truncate lines mid-way through as this can cause matching failures.
|
|
49508
51928
|
4. Special operations:
|
|
49509
51929
|
* To move code: Use two SEARCH/REPLACE blocks (one to delete from original + one to insert at new location)
|
|
49510
|
-
* To delete code:
|
|
51930
|
+
* To delete code: Empty REPLACE section`).meta({ usageValue: "Search and replace blocks here" })
|
|
49511
51931
|
}).meta({
|
|
49512
51932
|
examples: [
|
|
49513
51933
|
{
|
|
@@ -49835,7 +52255,27 @@ var UpdateTodoItemOutputSchema = exports_external.object({
|
|
|
49835
52255
|
// ../core/src/tools/writeToFile.ts
|
|
49836
52256
|
var toolInfo12 = {
|
|
49837
52257
|
name: "writeToFile",
|
|
49838
|
-
description:
|
|
52258
|
+
description: `Request to write content to a file at the specified path.
|
|
52259
|
+
|
|
52260
|
+
When to use:
|
|
52261
|
+
- Creating new files
|
|
52262
|
+
- Completely replacing file contents
|
|
52263
|
+
- When you have the complete intended content
|
|
52264
|
+
|
|
52265
|
+
When NOT to use:
|
|
52266
|
+
- For modifying existing files: Use replaceInFile instead
|
|
52267
|
+
- For appending content: Use executeCommand with echo >> instead
|
|
52268
|
+
- For targeted edits: Use replaceInFile instead
|
|
52269
|
+
|
|
52270
|
+
Features:
|
|
52271
|
+
- Automatically creates any directories needed
|
|
52272
|
+
- Overwrites existing files completely
|
|
52273
|
+
- Must provide complete file content (no truncation)
|
|
52274
|
+
|
|
52275
|
+
IMPORTANT CONSTRAINT:
|
|
52276
|
+
- Always provide COMPLETE intended content (no omissions)
|
|
52277
|
+
- Ensure no incorrect escape sequences (<, >, &)
|
|
52278
|
+
- Ensure no unwanted CDATA tags in content`,
|
|
49839
52279
|
parameters: exports_external.object({
|
|
49840
52280
|
path: exports_external.string().describe("The path of the file to write to").meta({ usageValue: "File path here" }),
|
|
49841
52281
|
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" })
|
|
@@ -49876,10 +52316,7 @@ var handler12 = async (provider, args) => {
|
|
|
49876
52316
|
}
|
|
49877
52317
|
};
|
|
49878
52318
|
}
|
|
49879
|
-
|
|
49880
|
-
const trimmedContent = content.trim();
|
|
49881
|
-
if (trimmedContent.startsWith("<![CDATA[") && trimmedContent.endsWith("]]>"))
|
|
49882
|
-
content = trimmedContent.slice(9, -3);
|
|
52319
|
+
const { path, content } = parsed.data;
|
|
49883
52320
|
await provider.writeFile(path, content);
|
|
49884
52321
|
return {
|
|
49885
52322
|
success: true,
|
|
@@ -53028,9 +55465,9 @@ class ZodUnion2 extends ZodType2 {
|
|
|
53028
55465
|
return this._def.options;
|
|
53029
55466
|
}
|
|
53030
55467
|
}
|
|
53031
|
-
ZodUnion2.create = (
|
|
55468
|
+
ZodUnion2.create = (types3, params) => {
|
|
53032
55469
|
return new ZodUnion2({
|
|
53033
|
-
options:
|
|
55470
|
+
options: types3,
|
|
53034
55471
|
typeName: ZodFirstPartyTypeKind2.ZodUnion,
|
|
53035
55472
|
...processCreateParams(params)
|
|
53036
55473
|
});
|
|
@@ -55524,15 +57961,15 @@ var primitiveMappings = {
|
|
|
55524
57961
|
function parseUnionDef(def, refs) {
|
|
55525
57962
|
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
55526
57963
|
if (options.every((x) => (x._def.typeName in primitiveMappings) && (!x._def.checks || !x._def.checks.length))) {
|
|
55527
|
-
const
|
|
57964
|
+
const types3 = options.reduce((types22, x) => {
|
|
55528
57965
|
const type = primitiveMappings[x._def.typeName];
|
|
55529
57966
|
return type && !types22.includes(type) ? [...types22, type] : types22;
|
|
55530
57967
|
}, []);
|
|
55531
57968
|
return {
|
|
55532
|
-
type:
|
|
57969
|
+
type: types3.length > 1 ? types3 : types3[0]
|
|
55533
57970
|
};
|
|
55534
57971
|
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
55535
|
-
const
|
|
57972
|
+
const types3 = options.reduce((acc, x) => {
|
|
55536
57973
|
const type = typeof x._def.value;
|
|
55537
57974
|
switch (type) {
|
|
55538
57975
|
case "string":
|
|
@@ -55551,8 +57988,8 @@ function parseUnionDef(def, refs) {
|
|
|
55551
57988
|
return acc;
|
|
55552
57989
|
}
|
|
55553
57990
|
}, []);
|
|
55554
|
-
if (
|
|
55555
|
-
const uniqueTypes =
|
|
57991
|
+
if (types3.length === options.length) {
|
|
57992
|
+
const uniqueTypes = types3.filter((x, i, a) => a.indexOf(x) === i);
|
|
55556
57993
|
return {
|
|
55557
57994
|
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
55558
57995
|
enum: options.reduce((acc, x) => {
|
|
@@ -59733,7 +62170,7 @@ var uiMessagesSchema = lazyValidator(() => zodSchema(exports_external.array(expo
|
|
|
59733
62170
|
var WorkflowInputDefinitionSchema = exports_external.object({
|
|
59734
62171
|
id: exports_external.string(),
|
|
59735
62172
|
description: exports_external.string().nullish(),
|
|
59736
|
-
default: exports_external.
|
|
62173
|
+
default: exports_external.unknown().nullish()
|
|
59737
62174
|
});
|
|
59738
62175
|
var WorkflowStepDefinitionSchema = exports_external.object({
|
|
59739
62176
|
id: exports_external.string(),
|
|
@@ -59741,7 +62178,7 @@ var WorkflowStepDefinitionSchema = exports_external.object({
|
|
|
59741
62178
|
task: exports_external.string(),
|
|
59742
62179
|
output: exports_external.string().nullish(),
|
|
59743
62180
|
expected_outcome: exports_external.string().nullish(),
|
|
59744
|
-
outputSchema: exports_external.
|
|
62181
|
+
outputSchema: exports_external.unknown().nullish(),
|
|
59745
62182
|
timeout: exports_external.number().positive().nullish()
|
|
59746
62183
|
});
|
|
59747
62184
|
var WhileLoopStepSchema = exports_external.object({
|
|
@@ -60290,9 +62727,9 @@ var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
|
|
|
60290
62727
|
var freeProcess = moduleExports2 && _freeGlobal_default.process;
|
|
60291
62728
|
var nodeUtil = function() {
|
|
60292
62729
|
try {
|
|
60293
|
-
var
|
|
60294
|
-
if (
|
|
60295
|
-
return
|
|
62730
|
+
var types4 = freeModule2 && freeModule2.require && freeModule2.require("util").types;
|
|
62731
|
+
if (types4) {
|
|
62732
|
+
return types4;
|
|
60296
62733
|
}
|
|
60297
62734
|
return freeProcess && freeProcess.binding && freeProcess.binding("util");
|
|
60298
62735
|
} catch (e) {}
|
|
@@ -60839,7 +63276,12 @@ function getGlobalConfigPath(home = homedir()) {
|
|
|
60839
63276
|
function loadConfigAtPath(path) {
|
|
60840
63277
|
try {
|
|
60841
63278
|
return readConfig(path);
|
|
60842
|
-
} catch (
|
|
63279
|
+
} catch (error48) {
|
|
63280
|
+
if (error48 instanceof ZodError) {
|
|
63281
|
+
console.warn(`Config validation failed for ${path}: ${error48.message}`);
|
|
63282
|
+
} else {
|
|
63283
|
+
console.debug(`Could not load config from ${path}: ${error48 instanceof Error ? error48.message : String(error48)}`);
|
|
63284
|
+
}
|
|
60843
63285
|
return;
|
|
60844
63286
|
}
|
|
60845
63287
|
}
|
|
@@ -60867,7 +63309,7 @@ function mergeConfigs(configs) {
|
|
|
60867
63309
|
merged.rules = mergeArray(accRules, configRules);
|
|
60868
63310
|
merged.excludeFiles = mergeArray(acc.excludeFiles, config3.excludeFiles);
|
|
60869
63311
|
return merged;
|
|
60870
|
-
});
|
|
63312
|
+
}, {});
|
|
60871
63313
|
return mergedConfig;
|
|
60872
63314
|
}
|
|
60873
63315
|
async function resolveRules(rules) {
|
|
@@ -60988,14 +63430,103 @@ var readConfig = (path) => {
|
|
|
60988
63430
|
var readLocalConfig = (path) => {
|
|
60989
63431
|
try {
|
|
60990
63432
|
return readConfig(path ?? localConfigFileName);
|
|
60991
|
-
} catch (
|
|
63433
|
+
} catch (error48) {
|
|
63434
|
+
if (error48 instanceof ZodError) {
|
|
63435
|
+
console.warn(`Local config validation failed for ${path ?? localConfigFileName}: ${error48.message}`);
|
|
63436
|
+
} else {
|
|
63437
|
+
console.debug(`Could not load local config from ${path ?? localConfigFileName}: ${error48 instanceof Error ? error48.message : String(error48)}`);
|
|
63438
|
+
}
|
|
60992
63439
|
return;
|
|
60993
63440
|
}
|
|
60994
63441
|
};
|
|
63442
|
+
// src/memory-manager.ts
|
|
63443
|
+
class MemoryManager {
|
|
63444
|
+
store;
|
|
63445
|
+
constructor(store) {
|
|
63446
|
+
this.store = store;
|
|
63447
|
+
}
|
|
63448
|
+
async readMemory(topic) {
|
|
63449
|
+
return this.store.readMemory(topic);
|
|
63450
|
+
}
|
|
63451
|
+
async updateMemory(operation, topic, content, metadata) {
|
|
63452
|
+
return this.store.updateMemory(operation, topic, content, metadata);
|
|
63453
|
+
}
|
|
63454
|
+
async queryMemory(query = {}, options) {
|
|
63455
|
+
const finalQuery = {
|
|
63456
|
+
...query
|
|
63457
|
+
};
|
|
63458
|
+
const operation = options?.operation;
|
|
63459
|
+
if ((operation === "select" || !operation) && !finalQuery.limit) {
|
|
63460
|
+
finalQuery.limit = 1000;
|
|
63461
|
+
}
|
|
63462
|
+
return this.store.queryMemory(finalQuery, options);
|
|
63463
|
+
}
|
|
63464
|
+
async batchUpdateMemory(operations) {
|
|
63465
|
+
return this.store.batchUpdateMemory(operations);
|
|
63466
|
+
}
|
|
63467
|
+
async getStats() {
|
|
63468
|
+
return this.store.getStats();
|
|
63469
|
+
}
|
|
63470
|
+
async close() {
|
|
63471
|
+
await this.store.close();
|
|
63472
|
+
}
|
|
63473
|
+
async transaction(callback) {
|
|
63474
|
+
const storeWithTransaction = this.store;
|
|
63475
|
+
if (typeof storeWithTransaction.transaction === "function") {
|
|
63476
|
+
return storeWithTransaction.transaction(callback);
|
|
63477
|
+
}
|
|
63478
|
+
return callback();
|
|
63479
|
+
}
|
|
63480
|
+
}
|
|
63481
|
+
// src/project-scope.ts
|
|
63482
|
+
import { existsSync as existsSync2 } from "node:fs";
|
|
63483
|
+
import { dirname, normalize, resolve as resolve2, sep } from "node:path";
|
|
63484
|
+
function detectProjectScope(cwd) {
|
|
63485
|
+
const projectPath = findProjectRoot(cwd);
|
|
63486
|
+
if (!projectPath) {
|
|
63487
|
+
return "global";
|
|
63488
|
+
}
|
|
63489
|
+
const normalizedPath = normalizePath(projectPath);
|
|
63490
|
+
return `project:${normalizedPath}`;
|
|
63491
|
+
}
|
|
63492
|
+
function findProjectRoot(dir) {
|
|
63493
|
+
if (!existsSync2(dir)) {
|
|
63494
|
+
return null;
|
|
63495
|
+
}
|
|
63496
|
+
const primaryMarkers = [".git", "package.json"];
|
|
63497
|
+
const secondaryMarkers = [
|
|
63498
|
+
"Cargo.toml",
|
|
63499
|
+
"go.mod",
|
|
63500
|
+
"pyproject.toml",
|
|
63501
|
+
"requirements.txt",
|
|
63502
|
+
"setup.py",
|
|
63503
|
+
"Gemfile",
|
|
63504
|
+
"pom.xml",
|
|
63505
|
+
"build.gradle"
|
|
63506
|
+
];
|
|
63507
|
+
for (const marker16 of primaryMarkers) {
|
|
63508
|
+
if (existsSync2(resolve2(dir, marker16))) {
|
|
63509
|
+
return dir;
|
|
63510
|
+
}
|
|
63511
|
+
}
|
|
63512
|
+
for (const marker16 of secondaryMarkers) {
|
|
63513
|
+
if (existsSync2(resolve2(dir, marker16))) {
|
|
63514
|
+
return dir;
|
|
63515
|
+
}
|
|
63516
|
+
}
|
|
63517
|
+
const parent = dirname(dir);
|
|
63518
|
+
if (parent === dir) {
|
|
63519
|
+
return null;
|
|
63520
|
+
}
|
|
63521
|
+
return findProjectRoot(parent);
|
|
63522
|
+
}
|
|
63523
|
+
function normalizePath(path) {
|
|
63524
|
+
return normalize(path).split(sep).join("/");
|
|
63525
|
+
}
|
|
60995
63526
|
// src/provider.ts
|
|
60996
63527
|
import { spawn as spawn2 } from "node:child_process";
|
|
60997
63528
|
import { mkdir, readFile as readFile2, rename, unlink, writeFile } from "node:fs/promises";
|
|
60998
|
-
import { dirname, normalize, resolve as
|
|
63529
|
+
import { dirname as dirname2, normalize as normalize2, resolve as resolve4 } from "node:path";
|
|
60999
63530
|
|
|
61000
63531
|
// ../../node_modules/@ai-sdk/google-vertex/dist/index.mjs
|
|
61001
63532
|
var import_google_auth_library = __toESM(require_src7(), 1);
|
|
@@ -63074,12 +65605,12 @@ function isPlainObject3(value) {
|
|
|
63074
65605
|
}
|
|
63075
65606
|
return Object.getPrototypeOf(value) === proto;
|
|
63076
65607
|
}
|
|
63077
|
-
function
|
|
65608
|
+
function deepMerge2(...objects) {
|
|
63078
65609
|
const output = {};
|
|
63079
65610
|
for (const obj of objects) {
|
|
63080
65611
|
for (const [key, value] of Object.entries(obj)) {
|
|
63081
65612
|
const prevValue = output[key];
|
|
63082
|
-
output[key] = isPlainObject3(prevValue) && isPlainObject3(value) ?
|
|
65613
|
+
output[key] = isPlainObject3(prevValue) && isPlainObject3(value) ? deepMerge2(prevValue, value) : value;
|
|
63083
65614
|
}
|
|
63084
65615
|
}
|
|
63085
65616
|
return output;
|
|
@@ -63089,7 +65620,7 @@ function makeTheme(...themes) {
|
|
|
63089
65620
|
defaultTheme,
|
|
63090
65621
|
...themes.filter((theme) => theme != null)
|
|
63091
65622
|
];
|
|
63092
|
-
return
|
|
65623
|
+
return deepMerge2(...themesToMerge);
|
|
63093
65624
|
}
|
|
63094
65625
|
|
|
63095
65626
|
// ../../node_modules/@inquirer/core/dist/lib/use-prefix.js
|
|
@@ -63967,13 +66498,13 @@ class ScreenManager {
|
|
|
63967
66498
|
// ../../node_modules/@inquirer/core/dist/lib/promise-polyfill.js
|
|
63968
66499
|
class PromisePolyfill extends Promise {
|
|
63969
66500
|
static withResolver() {
|
|
63970
|
-
let
|
|
66501
|
+
let resolve3;
|
|
63971
66502
|
let reject;
|
|
63972
66503
|
const promise2 = new Promise((res, rej) => {
|
|
63973
|
-
|
|
66504
|
+
resolve3 = res;
|
|
63974
66505
|
reject = rej;
|
|
63975
66506
|
});
|
|
63976
|
-
return { promise: promise2, resolve:
|
|
66507
|
+
return { promise: promise2, resolve: resolve3, reject };
|
|
63977
66508
|
}
|
|
63978
66509
|
}
|
|
63979
66510
|
|
|
@@ -64007,7 +66538,7 @@ function createPrompt(view) {
|
|
|
64007
66538
|
output
|
|
64008
66539
|
});
|
|
64009
66540
|
const screen = new ScreenManager(rl);
|
|
64010
|
-
const { promise: promise2, resolve:
|
|
66541
|
+
const { promise: promise2, resolve: resolve3, reject } = PromisePolyfill.withResolver();
|
|
64011
66542
|
const cancel = () => reject(new CancelPromptError);
|
|
64012
66543
|
if (signal) {
|
|
64013
66544
|
const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
|
|
@@ -64034,7 +66565,7 @@ function createPrompt(view) {
|
|
|
64034
66565
|
cycle(() => {
|
|
64035
66566
|
try {
|
|
64036
66567
|
const nextView = view(config3, (value) => {
|
|
64037
|
-
setImmediate(() =>
|
|
66568
|
+
setImmediate(() => resolve3(value));
|
|
64038
66569
|
});
|
|
64039
66570
|
if (nextView === undefined) {
|
|
64040
66571
|
const callerFilename = callSites[1]?.getFileName();
|
|
@@ -64357,7 +66888,7 @@ function lookup(path) {
|
|
|
64357
66888
|
}
|
|
64358
66889
|
return $types[extension2] || false;
|
|
64359
66890
|
}
|
|
64360
|
-
function populateMaps(extensions,
|
|
66891
|
+
function populateMaps(extensions, types6) {
|
|
64361
66892
|
Object.keys(db).forEach(function forEachMimeType(type) {
|
|
64362
66893
|
var mime = db[type];
|
|
64363
66894
|
var exts = mime.extensions;
|
|
@@ -64367,10 +66898,10 @@ function populateMaps(extensions, types5) {
|
|
|
64367
66898
|
extensions[type] = exts;
|
|
64368
66899
|
for (var i2 = 0;i2 < exts.length; i2++) {
|
|
64369
66900
|
var extension2 = exts[i2];
|
|
64370
|
-
|
|
64371
|
-
const legacyType = _preferredTypeLegacy(extension2,
|
|
64372
|
-
if (legacyType !==
|
|
64373
|
-
$_extensionConflicts.push([extension2, legacyType,
|
|
66901
|
+
types6[extension2] = _preferredType(extension2, types6[extension2], type);
|
|
66902
|
+
const legacyType = _preferredTypeLegacy(extension2, types6[extension2], type);
|
|
66903
|
+
if (legacyType !== types6[extension2]) {
|
|
66904
|
+
$_extensionConflicts.push([extension2, legacyType, types6[extension2]]);
|
|
64374
66905
|
}
|
|
64375
66906
|
}
|
|
64376
66907
|
});
|
|
@@ -64411,7 +66942,7 @@ function checkRipgrep() {
|
|
|
64411
66942
|
// src/utils/listFiles.ts
|
|
64412
66943
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
64413
66944
|
import { promises as fs3 } from "node:fs";
|
|
64414
|
-
import { join as join2, relative, resolve as
|
|
66945
|
+
import { join as join2, relative, resolve as resolve3 } from "node:path";
|
|
64415
66946
|
var DEFAULT_IGNORES = [
|
|
64416
66947
|
"__pycache__",
|
|
64417
66948
|
".DS_Store",
|
|
@@ -64454,9 +66985,9 @@ async function listFiles(dirPath, recursive, maxCount, cwd, excludeFiles, includ
|
|
|
64454
66985
|
const processedDirs = new Set;
|
|
64455
66986
|
const queue = [
|
|
64456
66987
|
{
|
|
64457
|
-
path:
|
|
66988
|
+
path: resolve3(dirPath),
|
|
64458
66989
|
patterns: rootPatterns,
|
|
64459
|
-
relPath: relative(cwd,
|
|
66990
|
+
relPath: relative(cwd, resolve3(dirPath)).replace(/\\/g, "/") || "."
|
|
64460
66991
|
}
|
|
64461
66992
|
];
|
|
64462
66993
|
while (queue.length > 0) {
|
|
@@ -64537,7 +67068,7 @@ async function searchFiles(path, regex2, filePattern, cwd, excludeFiles) {
|
|
|
64537
67068
|
}
|
|
64538
67069
|
}
|
|
64539
67070
|
args.push(regex2, path);
|
|
64540
|
-
return new Promise((
|
|
67071
|
+
return new Promise((resolve4, reject) => {
|
|
64541
67072
|
const results = [];
|
|
64542
67073
|
const rg = spawn("rg", args, {
|
|
64543
67074
|
cwd,
|
|
@@ -64556,7 +67087,7 @@ async function searchFiles(path, regex2, filePattern, cwd, excludeFiles) {
|
|
|
64556
67087
|
reject(new Error(`Ripgrep process exited with code ${code}`));
|
|
64557
67088
|
return;
|
|
64558
67089
|
}
|
|
64559
|
-
|
|
67090
|
+
resolve4(results);
|
|
64560
67091
|
});
|
|
64561
67092
|
});
|
|
64562
67093
|
}
|
|
@@ -64571,12 +67102,59 @@ class InMemoryStore {
|
|
|
64571
67102
|
this.#data = data;
|
|
64572
67103
|
}
|
|
64573
67104
|
}
|
|
67105
|
+
function isIMemoryStore(store) {
|
|
67106
|
+
return "readMemory" in store && "updateMemory" in store;
|
|
67107
|
+
}
|
|
64574
67108
|
var getProvider = (options = {}) => {
|
|
64575
67109
|
const ig = import_ignore2.default().add(options.excludeFiles ?? []);
|
|
64576
67110
|
const memoryStore = options.memoryStore ?? new InMemoryStore;
|
|
64577
67111
|
const todoItemStore = options.todoItemStore ?? new InMemoryStore;
|
|
64578
67112
|
const defaultMemoryTopic = ":default:";
|
|
64579
67113
|
const searchModel = options.getModel?.("search");
|
|
67114
|
+
const readMemoryKV = async (topic) => {
|
|
67115
|
+
if (!isIMemoryStore(memoryStore)) {
|
|
67116
|
+
const data = await memoryStore.read() ?? {};
|
|
67117
|
+
return data[topic];
|
|
67118
|
+
}
|
|
67119
|
+
return memoryStore.readMemory(topic);
|
|
67120
|
+
};
|
|
67121
|
+
const updateMemoryKV = async (operation, topic, content) => {
|
|
67122
|
+
if (!isIMemoryStore(memoryStore)) {
|
|
67123
|
+
const data = await memoryStore.read() ?? {};
|
|
67124
|
+
switch (operation) {
|
|
67125
|
+
case "append":
|
|
67126
|
+
if (content === undefined) {
|
|
67127
|
+
throw new Error("Content is required for append operation.");
|
|
67128
|
+
}
|
|
67129
|
+
data[topic] = `${data[topic] || ""}
|
|
67130
|
+
${content}`;
|
|
67131
|
+
break;
|
|
67132
|
+
case "replace":
|
|
67133
|
+
if (content === undefined) {
|
|
67134
|
+
throw new Error("Content is required for replace operation.");
|
|
67135
|
+
}
|
|
67136
|
+
data[topic] = content;
|
|
67137
|
+
break;
|
|
67138
|
+
case "remove":
|
|
67139
|
+
delete data[topic];
|
|
67140
|
+
break;
|
|
67141
|
+
}
|
|
67142
|
+
await memoryStore.write(data);
|
|
67143
|
+
return;
|
|
67144
|
+
}
|
|
67145
|
+
await memoryStore.updateMemory(operation, topic, content);
|
|
67146
|
+
};
|
|
67147
|
+
const listMemoryTopicsKV = async () => {
|
|
67148
|
+
if (!isIMemoryStore(memoryStore)) {
|
|
67149
|
+
const data = await memoryStore.read() ?? {};
|
|
67150
|
+
return Object.keys(data);
|
|
67151
|
+
}
|
|
67152
|
+
const entries = await memoryStore.queryMemory({});
|
|
67153
|
+
if (Array.isArray(entries)) {
|
|
67154
|
+
return entries.map((e2) => e2.name);
|
|
67155
|
+
}
|
|
67156
|
+
return [];
|
|
67157
|
+
};
|
|
64580
67158
|
const provider2 = {
|
|
64581
67159
|
listTodoItems: async (id, status) => {
|
|
64582
67160
|
const todoItems = await todoItemStore.read() ?? [];
|
|
@@ -64675,35 +67253,14 @@ var getProvider = (options = {}) => {
|
|
|
64675
67253
|
}
|
|
64676
67254
|
},
|
|
64677
67255
|
listMemoryTopics: async () => {
|
|
64678
|
-
|
|
64679
|
-
return Object.keys(memory);
|
|
67256
|
+
return listMemoryTopicsKV();
|
|
64680
67257
|
},
|
|
64681
67258
|
readMemory: async (topic = defaultMemoryTopic) => {
|
|
64682
|
-
|
|
64683
|
-
return memory[topic];
|
|
67259
|
+
return readMemoryKV(topic);
|
|
64684
67260
|
},
|
|
64685
67261
|
updateMemory: async (operation, topic, content) => {
|
|
64686
67262
|
const memoryTopic = topic ?? defaultMemoryTopic;
|
|
64687
|
-
|
|
64688
|
-
switch (operation) {
|
|
64689
|
-
case "append":
|
|
64690
|
-
if (content === undefined) {
|
|
64691
|
-
throw new Error("Content is required for append operation.");
|
|
64692
|
-
}
|
|
64693
|
-
memory[memoryTopic] = `${memory[memoryTopic] || ""}
|
|
64694
|
-
${content}`;
|
|
64695
|
-
break;
|
|
64696
|
-
case "replace":
|
|
64697
|
-
if (content === undefined) {
|
|
64698
|
-
throw new Error("Content is required for replace operation.");
|
|
64699
|
-
}
|
|
64700
|
-
memory[memoryTopic] = content;
|
|
64701
|
-
break;
|
|
64702
|
-
case "remove":
|
|
64703
|
-
delete memory[memoryTopic];
|
|
64704
|
-
break;
|
|
64705
|
-
}
|
|
64706
|
-
await memoryStore.write(memory);
|
|
67263
|
+
await updateMemoryKV(operation, memoryTopic, content);
|
|
64707
67264
|
},
|
|
64708
67265
|
readFile: async (path, includeIgnored) => {
|
|
64709
67266
|
if (!includeIgnored && ig.ignores(path)) {
|
|
@@ -64719,7 +67276,7 @@ ${content}`;
|
|
|
64719
67276
|
if (ig.ignores(path)) {
|
|
64720
67277
|
throw new Error(`Not allow to access file ${path}`);
|
|
64721
67278
|
}
|
|
64722
|
-
await mkdir(
|
|
67279
|
+
await mkdir(dirname2(path), { recursive: true });
|
|
64723
67280
|
return await writeFile(path, content, "utf8");
|
|
64724
67281
|
},
|
|
64725
67282
|
removeFile: async (path) => {
|
|
@@ -64740,7 +67297,7 @@ ${content}`;
|
|
|
64740
67297
|
readBinaryFile: async (url2) => {
|
|
64741
67298
|
if (url2.startsWith("file://")) {
|
|
64742
67299
|
const filePath = decodeURIComponent(url2.substring("file://".length));
|
|
64743
|
-
const resolvedPath =
|
|
67300
|
+
const resolvedPath = normalize2(resolve4(process.cwd(), filePath));
|
|
64744
67301
|
if (!resolvedPath.startsWith(process.cwd())) {
|
|
64745
67302
|
throw new Error(`Access to file path "${filePath}" is restricted.`);
|
|
64746
67303
|
}
|
|
@@ -64763,7 +67320,7 @@ ${content}`;
|
|
|
64763
67320
|
};
|
|
64764
67321
|
},
|
|
64765
67322
|
executeCommand: (command, _needApprove) => {
|
|
64766
|
-
return new Promise((
|
|
67323
|
+
return new Promise((resolve5, reject) => {
|
|
64767
67324
|
options.command?.onStarted(command);
|
|
64768
67325
|
const child = spawn2(command, [], {
|
|
64769
67326
|
shell: true,
|
|
@@ -64788,7 +67345,7 @@ ${content}`;
|
|
|
64788
67345
|
try {
|
|
64789
67346
|
const summary = await options.summarizeOutput(stdoutText, stderrText);
|
|
64790
67347
|
if (summary) {
|
|
64791
|
-
|
|
67348
|
+
resolve5({
|
|
64792
67349
|
summary,
|
|
64793
67350
|
stdout: stdoutText,
|
|
64794
67351
|
stderr: stderrText,
|
|
@@ -64800,7 +67357,7 @@ ${content}`;
|
|
|
64800
67357
|
console.error("Summarization failed:", _e);
|
|
64801
67358
|
}
|
|
64802
67359
|
}
|
|
64803
|
-
|
|
67360
|
+
resolve5({
|
|
64804
67361
|
stdout: stdoutText,
|
|
64805
67362
|
stderr: stderrText,
|
|
64806
67363
|
exitCode: code ?? 0
|
|
@@ -64870,6 +67427,634 @@ ${content}`;
|
|
|
64870
67427
|
}
|
|
64871
67428
|
return provider2;
|
|
64872
67429
|
};
|
|
67430
|
+
// src/sqlite-memory-store.ts
|
|
67431
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
67432
|
+
import { randomUUID } from "node:crypto";
|
|
67433
|
+
import { existsSync as existsSync3 } from "node:fs";
|
|
67434
|
+
import { mkdir as mkdir2, readFile as readFile3, rename as rename2, writeFile as writeFile2 } from "node:fs/promises";
|
|
67435
|
+
import { dirname as dirname3, resolve as resolve5 } from "node:path";
|
|
67436
|
+
var import_sql = __toESM(require_sql_wasm(), 1);
|
|
67437
|
+
|
|
67438
|
+
class FileLock {
|
|
67439
|
+
lockfilePath;
|
|
67440
|
+
static LOCK_TIMEOUT = 30000;
|
|
67441
|
+
constructor(dbPath) {
|
|
67442
|
+
this.lockfilePath = `${dbPath}.lock`;
|
|
67443
|
+
}
|
|
67444
|
+
async acquire(retries = 10, delay2 = 100) {
|
|
67445
|
+
for (let i2 = 0;i2 < retries; i2++) {
|
|
67446
|
+
try {
|
|
67447
|
+
const lockData = JSON.stringify({
|
|
67448
|
+
pid: process.pid,
|
|
67449
|
+
acquiredAt: Date.now()
|
|
67450
|
+
});
|
|
67451
|
+
await writeFile2(this.lockfilePath, lockData, {
|
|
67452
|
+
flag: "wx",
|
|
67453
|
+
mode: 384
|
|
67454
|
+
});
|
|
67455
|
+
return;
|
|
67456
|
+
} catch (error48) {
|
|
67457
|
+
const errorCode = error48?.code;
|
|
67458
|
+
if (errorCode === "EEXIST") {
|
|
67459
|
+
try {
|
|
67460
|
+
const lockContent = await readFile3(this.lockfilePath, "utf-8");
|
|
67461
|
+
const lockData = JSON.parse(lockContent);
|
|
67462
|
+
if (!lockData || typeof lockData.acquiredAt !== "number" || lockData.acquiredAt <= 0) {
|
|
67463
|
+
console.warn(`[FileLock] Lock file has invalid acquiredAt, treating as stale`);
|
|
67464
|
+
await rename2(this.lockfilePath, `${this.lockfilePath}.invalid.${Date.now()}`);
|
|
67465
|
+
continue;
|
|
67466
|
+
}
|
|
67467
|
+
const lockAge = Date.now() - lockData.acquiredAt;
|
|
67468
|
+
if (lockAge > FileLock.LOCK_TIMEOUT) {
|
|
67469
|
+
console.warn(`[FileLock] Breaking stale lock (age: ${lockAge}ms)`);
|
|
67470
|
+
await rename2(this.lockfilePath, `${this.lockfilePath}.stale.${Date.now()}`);
|
|
67471
|
+
continue;
|
|
67472
|
+
}
|
|
67473
|
+
} catch (readError) {
|
|
67474
|
+
if (readError instanceof SyntaxError) {
|
|
67475
|
+
console.warn(`[FileLock] Lock file contains invalid JSON, treating as stale`);
|
|
67476
|
+
await rename2(this.lockfilePath, `${this.lockfilePath}.corrupt.${Date.now()}`);
|
|
67477
|
+
continue;
|
|
67478
|
+
}
|
|
67479
|
+
}
|
|
67480
|
+
if (i2 < retries - 1) {
|
|
67481
|
+
await new Promise((resolve6) => setTimeout(resolve6, delay2));
|
|
67482
|
+
} else {
|
|
67483
|
+
throw new Error(`Cannot acquire lock after ${retries} retries (file: ${this.lockfilePath})`);
|
|
67484
|
+
}
|
|
67485
|
+
} else {
|
|
67486
|
+
throw error48;
|
|
67487
|
+
}
|
|
67488
|
+
}
|
|
67489
|
+
}
|
|
67490
|
+
}
|
|
67491
|
+
async release() {
|
|
67492
|
+
try {
|
|
67493
|
+
await rename2(this.lockfilePath, `${this.lockfilePath}.released.${Date.now()}`);
|
|
67494
|
+
} catch (error48) {
|
|
67495
|
+
const errorCode = error48.code;
|
|
67496
|
+
if (errorCode !== "ENOENT") {
|
|
67497
|
+
console.warn(`[FileLock] Error releasing lock: ${error48 instanceof Error ? error48.message : String(error48)}`);
|
|
67498
|
+
}
|
|
67499
|
+
}
|
|
67500
|
+
}
|
|
67501
|
+
}
|
|
67502
|
+
|
|
67503
|
+
class ReentrantMutex {
|
|
67504
|
+
queue = [];
|
|
67505
|
+
locked = false;
|
|
67506
|
+
lockCount = 0;
|
|
67507
|
+
owner = null;
|
|
67508
|
+
async acquire(owner) {
|
|
67509
|
+
if (this.locked && this.owner === owner) {
|
|
67510
|
+
this.lockCount++;
|
|
67511
|
+
return () => this.release(owner);
|
|
67512
|
+
}
|
|
67513
|
+
while (this.locked) {
|
|
67514
|
+
await new Promise((resolve6) => this.queue.push(resolve6));
|
|
67515
|
+
}
|
|
67516
|
+
this.locked = true;
|
|
67517
|
+
this.owner = owner;
|
|
67518
|
+
this.lockCount = 1;
|
|
67519
|
+
return () => this.release(owner);
|
|
67520
|
+
}
|
|
67521
|
+
release(owner) {
|
|
67522
|
+
if (this.owner !== owner) {
|
|
67523
|
+
return;
|
|
67524
|
+
}
|
|
67525
|
+
this.lockCount--;
|
|
67526
|
+
if (this.lockCount === 0) {
|
|
67527
|
+
this.locked = false;
|
|
67528
|
+
this.owner = null;
|
|
67529
|
+
const next = this.queue.shift();
|
|
67530
|
+
if (next) {
|
|
67531
|
+
next();
|
|
67532
|
+
}
|
|
67533
|
+
}
|
|
67534
|
+
}
|
|
67535
|
+
}
|
|
67536
|
+
var SqlJs = null;
|
|
67537
|
+
var SqlJsInitPromise = null;
|
|
67538
|
+
async function getSqlJs() {
|
|
67539
|
+
if (SqlJs) {
|
|
67540
|
+
return SqlJs;
|
|
67541
|
+
}
|
|
67542
|
+
if (SqlJsInitPromise) {
|
|
67543
|
+
return SqlJsInitPromise;
|
|
67544
|
+
}
|
|
67545
|
+
SqlJsInitPromise = import_sql.default({});
|
|
67546
|
+
SqlJs = await SqlJsInitPromise;
|
|
67547
|
+
return SqlJs;
|
|
67548
|
+
}
|
|
67549
|
+
var transactionOwnerStorage = new AsyncLocalStorage2;
|
|
67550
|
+
|
|
67551
|
+
class SQLiteMemoryStore {
|
|
67552
|
+
db = null;
|
|
67553
|
+
dbPromise = null;
|
|
67554
|
+
config;
|
|
67555
|
+
currentScope;
|
|
67556
|
+
inTransaction = false;
|
|
67557
|
+
transactionMutex = new ReentrantMutex;
|
|
67558
|
+
fileLock;
|
|
67559
|
+
getDbPath() {
|
|
67560
|
+
return this.config.path || DEFAULT_MEMORY_CONFIG.path;
|
|
67561
|
+
}
|
|
67562
|
+
getFileLock() {
|
|
67563
|
+
if (!this.fileLock) {
|
|
67564
|
+
const dbPath = this.resolvePath(this.getDbPath());
|
|
67565
|
+
this.fileLock = new FileLock(dbPath);
|
|
67566
|
+
}
|
|
67567
|
+
return this.fileLock;
|
|
67568
|
+
}
|
|
67569
|
+
static SORT_COLUMNS = {
|
|
67570
|
+
created: "created_at",
|
|
67571
|
+
updated: "updated_at",
|
|
67572
|
+
accessed: "last_accessed",
|
|
67573
|
+
name: "name"
|
|
67574
|
+
};
|
|
67575
|
+
static ALLOWED_SORT_ORDERS = ["asc", "desc"];
|
|
67576
|
+
static ALLOWED_PRIORITIES = ["low", "medium", "high", "critical"];
|
|
67577
|
+
constructor(config3, scope) {
|
|
67578
|
+
this.config = config3;
|
|
67579
|
+
this.currentScope = scope;
|
|
67580
|
+
}
|
|
67581
|
+
async initializeDatabase() {
|
|
67582
|
+
if (this.dbPromise) {
|
|
67583
|
+
return this.dbPromise;
|
|
67584
|
+
}
|
|
67585
|
+
this.dbPromise = (async () => {
|
|
67586
|
+
if (this.db) {
|
|
67587
|
+
return this.db;
|
|
67588
|
+
}
|
|
67589
|
+
const dbPath = this.resolvePath(this.getDbPath());
|
|
67590
|
+
try {
|
|
67591
|
+
const dir = dirname3(dbPath);
|
|
67592
|
+
if (!existsSync3(dir)) {
|
|
67593
|
+
await mkdir2(dir, { recursive: true, mode: 448 });
|
|
67594
|
+
}
|
|
67595
|
+
let dbData;
|
|
67596
|
+
if (existsSync3(dbPath)) {
|
|
67597
|
+
const lock = this.getFileLock();
|
|
67598
|
+
await lock.acquire();
|
|
67599
|
+
try {
|
|
67600
|
+
try {
|
|
67601
|
+
dbData = await readFile3(dbPath);
|
|
67602
|
+
if (dbData.length >= 16) {
|
|
67603
|
+
const header = String.fromCharCode(...dbData.subarray(0, 15));
|
|
67604
|
+
if (header !== "SQLite format 3") {
|
|
67605
|
+
console.warn("[SQLiteMemoryStore] Invalid SQLite database header, will recreate");
|
|
67606
|
+
dbData = undefined;
|
|
67607
|
+
}
|
|
67608
|
+
}
|
|
67609
|
+
} catch (error48) {
|
|
67610
|
+
const errorCode = error48?.code;
|
|
67611
|
+
if (errorCode === "ENOENT") {
|
|
67612
|
+
dbData = undefined;
|
|
67613
|
+
} else {
|
|
67614
|
+
throw new Error(`Failed to read database file at ${dbPath}: ${error48 instanceof Error ? error48.message : String(error48)}`);
|
|
67615
|
+
}
|
|
67616
|
+
}
|
|
67617
|
+
} finally {
|
|
67618
|
+
await lock.release();
|
|
67619
|
+
}
|
|
67620
|
+
}
|
|
67621
|
+
const SqlJs2 = await getSqlJs();
|
|
67622
|
+
const db2 = new SqlJs2.Database(dbData);
|
|
67623
|
+
this.configurePragmas(db2);
|
|
67624
|
+
this.checkIntegrity(db2);
|
|
67625
|
+
this.initializeSchema(db2);
|
|
67626
|
+
this.db = db2;
|
|
67627
|
+
return db2;
|
|
67628
|
+
} catch (error48) {
|
|
67629
|
+
console.error("[SQLiteMemoryStore] Initialization failed:", error48);
|
|
67630
|
+
if (existsSync3(dbPath)) {
|
|
67631
|
+
const backupPath = `${dbPath}.corrupted.${Date.now()}`;
|
|
67632
|
+
console.warn(`[SQLiteMemoryStore] Backing up corrupted database to: ${backupPath}`);
|
|
67633
|
+
try {
|
|
67634
|
+
await rename2(dbPath, backupPath);
|
|
67635
|
+
} catch (backupError) {
|
|
67636
|
+
console.error("[SQLiteMemoryStore] Failed to backup corrupted database:", backupError);
|
|
67637
|
+
this.dbPromise = null;
|
|
67638
|
+
throw backupError;
|
|
67639
|
+
}
|
|
67640
|
+
this.dbPromise = null;
|
|
67641
|
+
return this.initializeDatabase();
|
|
67642
|
+
}
|
|
67643
|
+
this.dbPromise = null;
|
|
67644
|
+
throw error48;
|
|
67645
|
+
}
|
|
67646
|
+
})();
|
|
67647
|
+
return this.dbPromise;
|
|
67648
|
+
}
|
|
67649
|
+
async saveDatabase() {
|
|
67650
|
+
if (!this.db) {
|
|
67651
|
+
return;
|
|
67652
|
+
}
|
|
67653
|
+
const lock = this.getFileLock();
|
|
67654
|
+
await lock.acquire();
|
|
67655
|
+
try {
|
|
67656
|
+
const dbPath = this.resolvePath(this.getDbPath());
|
|
67657
|
+
const tempPath = `${dbPath}.tmp`;
|
|
67658
|
+
const data = this.db.export();
|
|
67659
|
+
await writeFile2(tempPath, data, { mode: 384 });
|
|
67660
|
+
await rename2(tempPath, dbPath);
|
|
67661
|
+
} finally {
|
|
67662
|
+
await lock.release();
|
|
67663
|
+
}
|
|
67664
|
+
}
|
|
67665
|
+
configurePragmas(db2) {
|
|
67666
|
+
db2.run("PRAGMA synchronous = NORMAL");
|
|
67667
|
+
db2.run("PRAGMA busy_timeout = 5000");
|
|
67668
|
+
db2.run("PRAGMA foreign_keys = ON");
|
|
67669
|
+
db2.run("PRAGMA temp_store = MEMORY");
|
|
67670
|
+
}
|
|
67671
|
+
checkIntegrity(db2) {
|
|
67672
|
+
try {
|
|
67673
|
+
const results = db2.exec("SELECT 1");
|
|
67674
|
+
if (results.length === 0) {
|
|
67675
|
+
throw new Error("Database query returned no results");
|
|
67676
|
+
}
|
|
67677
|
+
} catch (error48) {
|
|
67678
|
+
console.error("[SQLiteMemoryStore] Integrity check failed:", error48);
|
|
67679
|
+
throw new Error("Database is corrupted");
|
|
67680
|
+
}
|
|
67681
|
+
}
|
|
67682
|
+
initializeSchema(db2) {
|
|
67683
|
+
db2.run(`
|
|
67684
|
+
CREATE TABLE IF NOT EXISTS memory_entries (
|
|
67685
|
+
id TEXT PRIMARY KEY,
|
|
67686
|
+
name TEXT NOT NULL CHECK(length(name) > 0),
|
|
67687
|
+
scope TEXT NOT NULL CHECK(scope IN ('global') OR scope LIKE 'project:%'),
|
|
67688
|
+
content TEXT NOT NULL CHECK(length(content) > 0),
|
|
67689
|
+
entry_type TEXT NOT NULL CHECK(length(entry_type) > 0),
|
|
67690
|
+
status TEXT CHECK(status IS NULL OR length(status) > 0),
|
|
67691
|
+
priority TEXT CHECK(priority IS NULL OR priority IN ('low', 'medium', 'high', 'critical')),
|
|
67692
|
+
tags TEXT CHECK(tags IS NULL OR length(tags) > 0),
|
|
67693
|
+
metadata TEXT CHECK(metadata IS NULL OR json_valid(metadata)),
|
|
67694
|
+
created_at INTEGER NOT NULL CHECK(created_at > 0),
|
|
67695
|
+
updated_at INTEGER NOT NULL CHECK(updated_at > 0),
|
|
67696
|
+
last_accessed INTEGER NOT NULL CHECK(last_accessed > 0),
|
|
67697
|
+
UNIQUE(name, scope)
|
|
67698
|
+
)
|
|
67699
|
+
`);
|
|
67700
|
+
db2.run("CREATE INDEX IF NOT EXISTS idx_memory_entries_scope_type ON memory_entries(scope, entry_type)");
|
|
67701
|
+
db2.run("CREATE INDEX IF NOT EXISTS idx_memory_entries_updated ON memory_entries(updated_at)");
|
|
67702
|
+
}
|
|
67703
|
+
async getDatabase() {
|
|
67704
|
+
if (!this.db) {
|
|
67705
|
+
this.db = await this.initializeDatabase();
|
|
67706
|
+
}
|
|
67707
|
+
return this.db;
|
|
67708
|
+
}
|
|
67709
|
+
resolvePath(path) {
|
|
67710
|
+
const resolved = resolveHomePath(path);
|
|
67711
|
+
return resolve5(resolved);
|
|
67712
|
+
}
|
|
67713
|
+
generateUUID() {
|
|
67714
|
+
return randomUUID();
|
|
67715
|
+
}
|
|
67716
|
+
now() {
|
|
67717
|
+
return Date.now();
|
|
67718
|
+
}
|
|
67719
|
+
async transaction(callback) {
|
|
67720
|
+
let owner = transactionOwnerStorage.getStore();
|
|
67721
|
+
if (!owner) {
|
|
67722
|
+
owner = Symbol("transaction");
|
|
67723
|
+
}
|
|
67724
|
+
const release = await this.transactionMutex.acquire(owner);
|
|
67725
|
+
return transactionOwnerStorage.run(owner, async () => {
|
|
67726
|
+
try {
|
|
67727
|
+
const db2 = await this.getDatabase();
|
|
67728
|
+
const shouldBegin = !this.inTransaction;
|
|
67729
|
+
try {
|
|
67730
|
+
if (shouldBegin) {
|
|
67731
|
+
db2.run("BEGIN TRANSACTION");
|
|
67732
|
+
this.inTransaction = true;
|
|
67733
|
+
}
|
|
67734
|
+
const result = await callback();
|
|
67735
|
+
if (shouldBegin) {
|
|
67736
|
+
db2.run("COMMIT");
|
|
67737
|
+
this.inTransaction = false;
|
|
67738
|
+
try {
|
|
67739
|
+
await this.saveDatabase();
|
|
67740
|
+
} catch (saveError) {
|
|
67741
|
+
console.error("[SQLiteMemoryStore] Failed to save database after commit, closing:", saveError);
|
|
67742
|
+
await this.close(true);
|
|
67743
|
+
throw saveError;
|
|
67744
|
+
}
|
|
67745
|
+
}
|
|
67746
|
+
return result;
|
|
67747
|
+
} catch (error48) {
|
|
67748
|
+
if (this.inTransaction) {
|
|
67749
|
+
try {
|
|
67750
|
+
db2.run("ROLLBACK");
|
|
67751
|
+
} catch (rollbackError) {
|
|
67752
|
+
console.error("[SQLiteMemoryStore] ROLLBACK failed:", rollbackError);
|
|
67753
|
+
}
|
|
67754
|
+
this.inTransaction = false;
|
|
67755
|
+
}
|
|
67756
|
+
throw error48;
|
|
67757
|
+
}
|
|
67758
|
+
} finally {
|
|
67759
|
+
release();
|
|
67760
|
+
}
|
|
67761
|
+
});
|
|
67762
|
+
}
|
|
67763
|
+
async readMemory(topic) {
|
|
67764
|
+
const db2 = await this.getDatabase();
|
|
67765
|
+
const scope = this.currentScope;
|
|
67766
|
+
const stmt = db2.prepare("SELECT content FROM memory_entries WHERE name = ? AND scope = ?");
|
|
67767
|
+
stmt.bind([topic, scope]);
|
|
67768
|
+
if (stmt.step()) {
|
|
67769
|
+
const row = stmt.getAsObject();
|
|
67770
|
+
const content = row.content;
|
|
67771
|
+
stmt.free();
|
|
67772
|
+
return content;
|
|
67773
|
+
}
|
|
67774
|
+
stmt.free();
|
|
67775
|
+
return;
|
|
67776
|
+
}
|
|
67777
|
+
async updateMemoryInternal(db2, operation, topic, content, metadata) {
|
|
67778
|
+
const scope = this.currentScope;
|
|
67779
|
+
const now = this.now();
|
|
67780
|
+
const createdAt = metadata?.created_at ?? now;
|
|
67781
|
+
const updatedAt = metadata?.updated_at ?? now;
|
|
67782
|
+
const lastAccessed = metadata?.last_accessed ?? now;
|
|
67783
|
+
if (operation === "remove") {
|
|
67784
|
+
const stmt2 = db2.prepare("DELETE FROM memory_entries WHERE name = ? AND scope = ?");
|
|
67785
|
+
stmt2.run([topic, scope]);
|
|
67786
|
+
stmt2.free();
|
|
67787
|
+
return;
|
|
67788
|
+
}
|
|
67789
|
+
const stmt = db2.prepare("SELECT content, entry_type, status, priority, tags FROM memory_entries WHERE name = ? AND scope = ?");
|
|
67790
|
+
stmt.bind([topic, scope]);
|
|
67791
|
+
let existing;
|
|
67792
|
+
if (stmt.step()) {
|
|
67793
|
+
const row = stmt.getAsObject();
|
|
67794
|
+
existing = {
|
|
67795
|
+
content: row.content,
|
|
67796
|
+
entry_type: row.entry_type,
|
|
67797
|
+
status: row.status,
|
|
67798
|
+
priority: row.priority,
|
|
67799
|
+
tags: row.tags
|
|
67800
|
+
};
|
|
67801
|
+
stmt.free();
|
|
67802
|
+
} else {
|
|
67803
|
+
existing = undefined;
|
|
67804
|
+
stmt.free();
|
|
67805
|
+
}
|
|
67806
|
+
let finalContent;
|
|
67807
|
+
let entry_type;
|
|
67808
|
+
let status;
|
|
67809
|
+
let priority;
|
|
67810
|
+
let tags;
|
|
67811
|
+
if (existing) {
|
|
67812
|
+
if (operation === "append") {
|
|
67813
|
+
if (!content) {
|
|
67814
|
+
throw new Error("Content is required for append operation.");
|
|
67815
|
+
}
|
|
67816
|
+
finalContent = `${existing.content}
|
|
67817
|
+
${content}`;
|
|
67818
|
+
} else {
|
|
67819
|
+
if (!content) {
|
|
67820
|
+
throw new Error("Content is required for replace operation.");
|
|
67821
|
+
}
|
|
67822
|
+
finalContent = content;
|
|
67823
|
+
}
|
|
67824
|
+
entry_type = metadata?.entry_type || existing.entry_type;
|
|
67825
|
+
status = (metadata?.status || existing.status) ?? undefined;
|
|
67826
|
+
priority = (metadata?.priority || existing.priority) ?? undefined;
|
|
67827
|
+
tags = (metadata?.tags || existing.tags) ?? undefined;
|
|
67828
|
+
} else {
|
|
67829
|
+
if (!content) {
|
|
67830
|
+
throw new Error("Content is required for new memory entries.");
|
|
67831
|
+
}
|
|
67832
|
+
finalContent = content;
|
|
67833
|
+
entry_type = metadata?.entry_type || "note";
|
|
67834
|
+
status = metadata?.status;
|
|
67835
|
+
priority = metadata?.priority;
|
|
67836
|
+
tags = metadata?.tags;
|
|
67837
|
+
}
|
|
67838
|
+
const upsertStmt = db2.prepare(`
|
|
67839
|
+
INSERT INTO memory_entries (id, name, scope, content, entry_type, status, priority, tags, created_at, updated_at, last_accessed)
|
|
67840
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
67841
|
+
ON CONFLICT(name, scope) DO UPDATE SET
|
|
67842
|
+
content = excluded.content,
|
|
67843
|
+
entry_type = excluded.entry_type,
|
|
67844
|
+
status = excluded.status,
|
|
67845
|
+
priority = excluded.priority,
|
|
67846
|
+
tags = excluded.tags,
|
|
67847
|
+
updated_at = excluded.updated_at,
|
|
67848
|
+
last_accessed = excluded.last_accessed
|
|
67849
|
+
`);
|
|
67850
|
+
upsertStmt.run([
|
|
67851
|
+
this.generateUUID(),
|
|
67852
|
+
topic,
|
|
67853
|
+
scope,
|
|
67854
|
+
finalContent,
|
|
67855
|
+
entry_type,
|
|
67856
|
+
status ?? null,
|
|
67857
|
+
priority ?? null,
|
|
67858
|
+
tags ?? null,
|
|
67859
|
+
createdAt,
|
|
67860
|
+
updatedAt,
|
|
67861
|
+
lastAccessed
|
|
67862
|
+
]);
|
|
67863
|
+
upsertStmt.free();
|
|
67864
|
+
}
|
|
67865
|
+
async updateMemory(operation, topic, content, metadata) {
|
|
67866
|
+
return this.transaction(async () => {
|
|
67867
|
+
const db2 = await this.getDatabase();
|
|
67868
|
+
await this.updateMemoryInternal(db2, operation, topic, content, metadata);
|
|
67869
|
+
});
|
|
67870
|
+
}
|
|
67871
|
+
async queryMemory(query = {}, options = {}) {
|
|
67872
|
+
if (options.operation === "delete") {
|
|
67873
|
+
return this.transaction(async () => {
|
|
67874
|
+
const db3 = await this.getDatabase();
|
|
67875
|
+
const { sql: sql2, params: params2 } = this.buildQuery(query);
|
|
67876
|
+
const deleteSql = `DELETE FROM memory_entries WHERE id IN (SELECT id FROM (${sql2}))`;
|
|
67877
|
+
const stmt2 = db3.prepare(deleteSql);
|
|
67878
|
+
stmt2.bind(params2);
|
|
67879
|
+
stmt2.step();
|
|
67880
|
+
stmt2.free();
|
|
67881
|
+
return db3.getRowsModified();
|
|
67882
|
+
});
|
|
67883
|
+
}
|
|
67884
|
+
const db2 = await this.getDatabase();
|
|
67885
|
+
const { sql, params } = this.buildQuery(query);
|
|
67886
|
+
if (options.operation === "count") {
|
|
67887
|
+
const countSql = `SELECT COUNT(*) as count FROM (${sql})`;
|
|
67888
|
+
const stmt2 = db2.prepare(countSql);
|
|
67889
|
+
stmt2.bind(params);
|
|
67890
|
+
let count = 0;
|
|
67891
|
+
if (stmt2.step()) {
|
|
67892
|
+
const row = stmt2.getAsObject();
|
|
67893
|
+
count = row.count;
|
|
67894
|
+
}
|
|
67895
|
+
stmt2.free();
|
|
67896
|
+
return count;
|
|
67897
|
+
}
|
|
67898
|
+
const stmt = db2.prepare(sql);
|
|
67899
|
+
stmt.bind(params);
|
|
67900
|
+
const entries = [];
|
|
67901
|
+
while (stmt.step()) {
|
|
67902
|
+
entries.push(stmt.getAsObject());
|
|
67903
|
+
}
|
|
67904
|
+
stmt.free();
|
|
67905
|
+
return entries;
|
|
67906
|
+
}
|
|
67907
|
+
buildQuery(query) {
|
|
67908
|
+
const conditions = [];
|
|
67909
|
+
const params = [];
|
|
67910
|
+
let sql = "SELECT * FROM memory_entries WHERE 1=1";
|
|
67911
|
+
const scope = query.scope === "auto" ? this.currentScope : query.scope;
|
|
67912
|
+
if (scope === "global") {
|
|
67913
|
+
conditions.push(`scope = ?`);
|
|
67914
|
+
params.push("global");
|
|
67915
|
+
} else if (scope === "project" || !scope && this.currentScope !== "global") {
|
|
67916
|
+
conditions.push(`scope = ?`);
|
|
67917
|
+
params.push(this.currentScope);
|
|
67918
|
+
}
|
|
67919
|
+
if (query.name) {
|
|
67920
|
+
if (!query.name.trim()) {
|
|
67921
|
+
throw new Error("Name cannot be empty");
|
|
67922
|
+
}
|
|
67923
|
+
conditions.push(`name = ?`);
|
|
67924
|
+
params.push(query.name.trim());
|
|
67925
|
+
}
|
|
67926
|
+
if (query.type) {
|
|
67927
|
+
if (!query.type.trim()) {
|
|
67928
|
+
throw new Error("Type cannot be empty");
|
|
67929
|
+
}
|
|
67930
|
+
conditions.push(`entry_type = ?`);
|
|
67931
|
+
params.push(query.type.trim());
|
|
67932
|
+
}
|
|
67933
|
+
if (query.status) {
|
|
67934
|
+
conditions.push(`status = ?`);
|
|
67935
|
+
params.push(query.status);
|
|
67936
|
+
}
|
|
67937
|
+
if (query.priority) {
|
|
67938
|
+
if (!SQLiteMemoryStore.ALLOWED_PRIORITIES.includes(query.priority)) {
|
|
67939
|
+
throw new Error(`Invalid priority: ${query.priority}`);
|
|
67940
|
+
}
|
|
67941
|
+
conditions.push(`priority = ?`);
|
|
67942
|
+
params.push(query.priority);
|
|
67943
|
+
}
|
|
67944
|
+
if (query.tags) {
|
|
67945
|
+
const tags = Array.isArray(query.tags) ? query.tags : [query.tags];
|
|
67946
|
+
for (const tag of tags) {
|
|
67947
|
+
const trimmed = tag.trim();
|
|
67948
|
+
if (!trimmed) {
|
|
67949
|
+
throw new Error("Tags cannot be empty");
|
|
67950
|
+
}
|
|
67951
|
+
const escaped = trimmed.replace(/[\\_%]/g, "\\$&");
|
|
67952
|
+
conditions.push(`(tags = ? OR tags LIKE ? ESCAPE '\\' OR tags LIKE ? ESCAPE '\\' OR tags LIKE ? ESCAPE '\\')`);
|
|
67953
|
+
params.push(trimmed, `${escaped},%`, `%,${escaped}`, `%,${escaped},%`);
|
|
67954
|
+
}
|
|
67955
|
+
}
|
|
67956
|
+
if (query.search) {
|
|
67957
|
+
const searchTerm = query.search.trim();
|
|
67958
|
+
conditions.push(`(content LIKE ? ESCAPE '\\' OR name LIKE ? ESCAPE '\\')`);
|
|
67959
|
+
const searchPattern = `%${searchTerm.replace(/[\\_%]/g, "\\$&")}%`;
|
|
67960
|
+
params.push(searchPattern, searchPattern);
|
|
67961
|
+
}
|
|
67962
|
+
if (query.createdAfter) {
|
|
67963
|
+
conditions.push(`created_at >= ?`);
|
|
67964
|
+
params.push(query.createdAfter);
|
|
67965
|
+
}
|
|
67966
|
+
if (query.createdBefore) {
|
|
67967
|
+
conditions.push(`created_at <= ?`);
|
|
67968
|
+
params.push(query.createdBefore);
|
|
67969
|
+
}
|
|
67970
|
+
if (query.updatedAfter) {
|
|
67971
|
+
conditions.push(`updated_at >= ?`);
|
|
67972
|
+
params.push(query.updatedAfter);
|
|
67973
|
+
}
|
|
67974
|
+
if (query.updatedBefore) {
|
|
67975
|
+
conditions.push(`updated_at <= ?`);
|
|
67976
|
+
params.push(query.updatedBefore);
|
|
67977
|
+
}
|
|
67978
|
+
if (conditions.length > 0) {
|
|
67979
|
+
sql += ` AND ${conditions.join(" AND ")}`;
|
|
67980
|
+
}
|
|
67981
|
+
if (query.sortBy) {
|
|
67982
|
+
const column = SQLiteMemoryStore.SORT_COLUMNS[query.sortBy];
|
|
67983
|
+
if (!column) {
|
|
67984
|
+
throw new Error(`Invalid sortBy: ${query.sortBy}`);
|
|
67985
|
+
}
|
|
67986
|
+
const order = query.sortOrder || "desc";
|
|
67987
|
+
if (!SQLiteMemoryStore.ALLOWED_SORT_ORDERS.includes(order)) {
|
|
67988
|
+
throw new Error(`Invalid sortOrder: ${order}`);
|
|
67989
|
+
}
|
|
67990
|
+
sql += ` ORDER BY ${column} ${order.toUpperCase()}`;
|
|
67991
|
+
}
|
|
67992
|
+
if (query.limit) {
|
|
67993
|
+
const limit = Number(query.limit);
|
|
67994
|
+
if (Number.isNaN(limit) || limit < 1 || limit > 1e4) {
|
|
67995
|
+
throw new Error("Limit must be between 1 and 10000");
|
|
67996
|
+
}
|
|
67997
|
+
sql += ` LIMIT ?`;
|
|
67998
|
+
params.push(limit);
|
|
67999
|
+
}
|
|
68000
|
+
if (query.offset) {
|
|
68001
|
+
const offset = Number(query.offset);
|
|
68002
|
+
if (Number.isNaN(offset) || offset < 0) {
|
|
68003
|
+
throw new Error("Offset must be >= 0");
|
|
68004
|
+
}
|
|
68005
|
+
sql += ` OFFSET ?`;
|
|
68006
|
+
params.push(offset);
|
|
68007
|
+
}
|
|
68008
|
+
return { sql, params };
|
|
68009
|
+
}
|
|
68010
|
+
async batchUpdateMemory(operations) {
|
|
68011
|
+
return this.transaction(async () => {
|
|
68012
|
+
const db2 = await this.getDatabase();
|
|
68013
|
+
for (const op of operations) {
|
|
68014
|
+
await this.updateMemoryInternal(db2, op.operation, op.name, op.content, op.metadata);
|
|
68015
|
+
}
|
|
68016
|
+
});
|
|
68017
|
+
}
|
|
68018
|
+
async close(skipSave = false) {
|
|
68019
|
+
const db2 = this.db;
|
|
68020
|
+
if (db2) {
|
|
68021
|
+
try {
|
|
68022
|
+
if (!skipSave) {
|
|
68023
|
+
await this.saveDatabase();
|
|
68024
|
+
}
|
|
68025
|
+
} finally {
|
|
68026
|
+
if (this.db === db2) {
|
|
68027
|
+
db2.close();
|
|
68028
|
+
this.db = null;
|
|
68029
|
+
}
|
|
68030
|
+
}
|
|
68031
|
+
}
|
|
68032
|
+
this.dbPromise = null;
|
|
68033
|
+
}
|
|
68034
|
+
async getStats() {
|
|
68035
|
+
const db2 = await this.getDatabase();
|
|
68036
|
+
const results = db2.exec("SELECT COUNT(*) as count FROM memory_entries");
|
|
68037
|
+
const totalEntries = results[0]?.values[0]?.[0] || 0;
|
|
68038
|
+
const typeResults = db2.exec("SELECT entry_type, COUNT(*) as count FROM memory_entries GROUP BY entry_type");
|
|
68039
|
+
const entriesByType = {};
|
|
68040
|
+
if (typeResults.length > 0) {
|
|
68041
|
+
for (const row of typeResults[0].values) {
|
|
68042
|
+
entriesByType[row[0]] = row[1];
|
|
68043
|
+
}
|
|
68044
|
+
}
|
|
68045
|
+
const dbPath = this.resolvePath(this.getDbPath());
|
|
68046
|
+
let databaseSize = 0;
|
|
68047
|
+
try {
|
|
68048
|
+
const stats = await import("node:fs/promises").then((fs4) => fs4.stat(dbPath));
|
|
68049
|
+
databaseSize = stats.size;
|
|
68050
|
+
} catch {}
|
|
68051
|
+
return {
|
|
68052
|
+
totalEntries,
|
|
68053
|
+
entriesByType,
|
|
68054
|
+
databaseSize
|
|
68055
|
+
};
|
|
68056
|
+
}
|
|
68057
|
+
}
|
|
64873
68058
|
// src/utils/eventHandler.ts
|
|
64874
68059
|
import { Console } from "node:console";
|
|
64875
68060
|
|
|
@@ -65363,40 +68548,36 @@ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
|
65363
68548
|
var source_default = chalk;
|
|
65364
68549
|
|
|
65365
68550
|
// src/utils/parameterSimplifier.ts
|
|
65366
|
-
function
|
|
65367
|
-
return
|
|
65368
|
-
}
|
|
65369
|
-
|
|
65370
|
-
|
|
65371
|
-
|
|
65372
|
-
|
|
65373
|
-
|
|
65374
|
-
|
|
65375
|
-
function listFilesSimplifier(params) {
|
|
65376
|
-
const maxCount = params.maxCount;
|
|
65377
|
-
return {
|
|
65378
|
-
path: params.path,
|
|
65379
|
-
recursive: params.recursive,
|
|
65380
|
-
...maxCount !== 2000 && { maxCount }
|
|
68551
|
+
function createSimplifier(keepFields) {
|
|
68552
|
+
return (params) => {
|
|
68553
|
+
const result = {};
|
|
68554
|
+
for (const field of keepFields) {
|
|
68555
|
+
if (params[field] !== undefined) {
|
|
68556
|
+
result[field] = params[field];
|
|
68557
|
+
}
|
|
68558
|
+
}
|
|
68559
|
+
return result;
|
|
65381
68560
|
};
|
|
65382
68561
|
}
|
|
65383
|
-
function
|
|
65384
|
-
return
|
|
65385
|
-
}
|
|
65386
|
-
function executeCommandSimplifier(params) {
|
|
65387
|
-
return { command: params.command, requiresApproval: params.requiresApproval };
|
|
65388
|
-
}
|
|
65389
|
-
function updateMemorySimplifier(params) {
|
|
65390
|
-
return { operation: params.operation, topic: params.topic };
|
|
68562
|
+
function createCustomSimplifier(transform2) {
|
|
68563
|
+
return transform2;
|
|
65391
68564
|
}
|
|
65392
68565
|
var SIMPLIFIERS = {
|
|
65393
|
-
replaceInFile:
|
|
65394
|
-
writeToFile:
|
|
65395
|
-
readFile:
|
|
65396
|
-
|
|
65397
|
-
|
|
65398
|
-
|
|
65399
|
-
|
|
68566
|
+
replaceInFile: createSimplifier(["path"]),
|
|
68567
|
+
writeToFile: createSimplifier(["path"]),
|
|
68568
|
+
readFile: createSimplifier(["path", "includeIgnored"]),
|
|
68569
|
+
executeCommand: createSimplifier(["command", "requiresApproval"]),
|
|
68570
|
+
updateMemory: createSimplifier(["operation", "topic"]),
|
|
68571
|
+
searchFiles: createCustomSimplifier((params) => ({ ...params })),
|
|
68572
|
+
listFiles: createCustomSimplifier((params) => {
|
|
68573
|
+
const DEFAULT_MAX_COUNT = 2000;
|
|
68574
|
+
const maxCount = params.maxCount;
|
|
68575
|
+
return {
|
|
68576
|
+
path: params.path,
|
|
68577
|
+
recursive: params.recursive,
|
|
68578
|
+
...maxCount !== DEFAULT_MAX_COUNT && { maxCount }
|
|
68579
|
+
};
|
|
68580
|
+
})
|
|
65400
68581
|
};
|
|
65401
68582
|
function simplifyToolParameters(toolName, params) {
|
|
65402
68583
|
if (params === undefined || params === null) {
|
|
@@ -65630,7 +68811,7 @@ Tool error:`, event.tool));
|
|
|
65630
68811
|
// src/utils/readMultiline.ts
|
|
65631
68812
|
import readline3 from "node:readline";
|
|
65632
68813
|
function readMultiline(prompt = "Enter text (Ctrl+D to finish):") {
|
|
65633
|
-
return new Promise((
|
|
68814
|
+
return new Promise((resolve6) => {
|
|
65634
68815
|
console.log(prompt);
|
|
65635
68816
|
const rl = readline3.createInterface({
|
|
65636
68817
|
input: process.stdin,
|
|
@@ -65642,7 +68823,7 @@ function readMultiline(prompt = "Enter text (Ctrl+D to finish):") {
|
|
|
65642
68823
|
lines.push(line);
|
|
65643
68824
|
});
|
|
65644
68825
|
rl.on("close", () => {
|
|
65645
|
-
|
|
68826
|
+
resolve6(lines.join(`
|
|
65646
68827
|
`));
|
|
65647
68828
|
});
|
|
65648
68829
|
});
|
|
@@ -65664,7 +68845,10 @@ export {
|
|
|
65664
68845
|
listFiles,
|
|
65665
68846
|
getProvider,
|
|
65666
68847
|
getGlobalConfigPath,
|
|
68848
|
+
detectProjectScope,
|
|
65667
68849
|
configSchema,
|
|
65668
68850
|
checkRipgrep,
|
|
68851
|
+
SQLiteMemoryStore,
|
|
68852
|
+
MemoryManager,
|
|
65669
68853
|
InMemoryStore
|
|
65670
68854
|
};
|