workspacecord 1.1.2 → 1.1.4
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/{archive-manager-XM3UPOY2.js → archive-manager-FJU7YEEH.js} +4 -4
- package/dist/{attachment-cli-IGQBB6YJ.js → attachment-cli-AT4HXAGU.js} +2 -2
- package/dist/{chunk-54DP53ZK.js → chunk-5EMN2IL5.js} +29 -3
- package/dist/{chunk-L2ZJXV6H.js → chunk-66B64WL3.js} +1 -1
- package/dist/{chunk-QWPKAUSV.js → chunk-C4L34VJK.js} +8287 -7421
- package/dist/chunk-JR4B4L7I.js +5301 -0
- package/dist/{chunk-UEX7U2KW.js → chunk-MJ5JKFGS.js} +911 -232
- package/dist/{chunk-ZAQV2RZS.js → chunk-NNTMVOTM.js} +1054 -1310
- package/dist/{chunk-COXPTYH5.js → chunk-PWMEOBXG.js} +4 -4
- package/dist/{chunk-I6EOCCQV.js → chunk-SNPFYUQ3.js} +713 -628
- package/dist/{chunk-GMYN4SYT.js → chunk-SV7EHL3B.js} +3 -3
- package/dist/cli-framework-YF3LPLMT.js +18 -0
- package/dist/cli.js +10 -10
- package/dist/{codex-launcher-VDQ5VZPT.js → codex-launcher-CLGG4CVY.js} +1 -1
- package/dist/{codex-provider-NYI7KBGO.js → codex-provider-VLOS5QB6.js} +18 -4
- package/dist/{config-cli-RQR2ZRQ5.js → config-cli-7G5YWKJU.js} +2 -2
- package/dist/{panel-adapter-QTDL3S6O.js → panel-adapter-CLI4WDII.js} +4 -4
- package/dist/{project-cli-6P6ZWDR6.js → project-cli-ALKDLRMZ.js} +2 -2
- package/dist/{project-registry-OEVPECMS.js → project-registry-ZO3KSS25.js} +2 -2
- package/dist/sdk-C3D6X4EB.js +55 -0
- package/dist/{session-local-registration-RIO5EPZ5.js → session-local-registration-RL2A3QZB.js} +3 -3
- package/dist/{setup-KOS7SRSL.js → setup-GP3MML2R.js} +1 -1
- package/package.json +3 -3
- package/dist/chunk-RK6EIZOL.js +0 -589
- package/dist/cli-framework-SQM2465A.js +0 -18
- package/dist/sdk-V7A7IF7F.js +0 -43
|
@@ -319,8 +319,8 @@ var require_legacy_streams = __commonJS({
|
|
|
319
319
|
options = options || {};
|
|
320
320
|
var keys = Object.keys(options);
|
|
321
321
|
for (var index = 0, length = keys.length; index < length; index++) {
|
|
322
|
-
var
|
|
323
|
-
this[
|
|
322
|
+
var key2 = keys[index];
|
|
323
|
+
this[key2] = options[key2];
|
|
324
324
|
}
|
|
325
325
|
if (this.encoding) this.setEncoding(this.encoding);
|
|
326
326
|
if (this.start !== void 0) {
|
|
@@ -367,8 +367,8 @@ var require_legacy_streams = __commonJS({
|
|
|
367
367
|
options = options || {};
|
|
368
368
|
var keys = Object.keys(options);
|
|
369
369
|
for (var index = 0, length = keys.length; index < length; index++) {
|
|
370
|
-
var
|
|
371
|
-
this[
|
|
370
|
+
var key2 = keys[index];
|
|
371
|
+
this[key2] = options[key2];
|
|
372
372
|
}
|
|
373
373
|
if (this.start !== void 0) {
|
|
374
374
|
if ("number" !== typeof this.start) {
|
|
@@ -406,8 +406,8 @@ var require_clone = __commonJS({
|
|
|
406
406
|
var copy = { __proto__: getPrototypeOf(obj) };
|
|
407
407
|
else
|
|
408
408
|
var copy = /* @__PURE__ */ Object.create(null);
|
|
409
|
-
Object.getOwnPropertyNames(obj).forEach(function(
|
|
410
|
-
Object.defineProperty(copy,
|
|
409
|
+
Object.getOwnPropertyNames(obj).forEach(function(key2) {
|
|
410
|
+
Object.defineProperty(copy, key2, Object.getOwnPropertyDescriptor(obj, key2));
|
|
411
411
|
});
|
|
412
412
|
return copy;
|
|
413
413
|
}
|
|
@@ -914,15 +914,15 @@ var require_err = __commonJS({
|
|
|
914
914
|
if (Array.isArray(err.errors)) {
|
|
915
915
|
_err.aggregateErrors = err.errors.map((err2) => errSerializer(err2));
|
|
916
916
|
}
|
|
917
|
-
for (const
|
|
918
|
-
if (_err[
|
|
919
|
-
const val = err[
|
|
917
|
+
for (const key2 in err) {
|
|
918
|
+
if (_err[key2] === void 0) {
|
|
919
|
+
const val = err[key2];
|
|
920
920
|
if (isErrorLike(val)) {
|
|
921
|
-
if (
|
|
922
|
-
_err[
|
|
921
|
+
if (key2 !== "cause" && !Object.prototype.hasOwnProperty.call(val, seen)) {
|
|
922
|
+
_err[key2] = errSerializer(val);
|
|
923
923
|
}
|
|
924
924
|
} else {
|
|
925
|
-
_err[
|
|
925
|
+
_err[key2] = val;
|
|
926
926
|
}
|
|
927
927
|
}
|
|
928
928
|
}
|
|
@@ -957,15 +957,15 @@ var require_err_with_cause = __commonJS({
|
|
|
957
957
|
if (isErrorLike(err.cause) && !Object.prototype.hasOwnProperty.call(err.cause, seen)) {
|
|
958
958
|
_err.cause = errWithCauseSerializer(err.cause);
|
|
959
959
|
}
|
|
960
|
-
for (const
|
|
961
|
-
if (_err[
|
|
962
|
-
const val = err[
|
|
960
|
+
for (const key2 in err) {
|
|
961
|
+
if (_err[key2] === void 0) {
|
|
962
|
+
const val = err[key2];
|
|
963
963
|
if (isErrorLike(val)) {
|
|
964
964
|
if (!Object.prototype.hasOwnProperty.call(val, seen)) {
|
|
965
|
-
_err[
|
|
965
|
+
_err[key2] = errWithCauseSerializer(val);
|
|
966
966
|
}
|
|
967
967
|
} else {
|
|
968
|
-
_err[
|
|
968
|
+
_err[key2] = val;
|
|
969
969
|
}
|
|
970
970
|
}
|
|
971
971
|
}
|
|
@@ -1205,9 +1205,9 @@ var require_redact = __commonJS({
|
|
|
1205
1205
|
}
|
|
1206
1206
|
if (typeof obj === "object") {
|
|
1207
1207
|
const cloned = Object.create(Object.getPrototypeOf(obj));
|
|
1208
|
-
for (const
|
|
1209
|
-
if (Object.prototype.hasOwnProperty.call(obj,
|
|
1210
|
-
cloned[
|
|
1208
|
+
for (const key2 in obj) {
|
|
1209
|
+
if (Object.prototype.hasOwnProperty.call(obj, key2)) {
|
|
1210
|
+
cloned[key2] = deepClone(obj[key2]);
|
|
1211
1211
|
}
|
|
1212
1212
|
}
|
|
1213
1213
|
return cloned;
|
|
@@ -1260,14 +1260,14 @@ var require_redact = __commonJS({
|
|
|
1260
1260
|
function setValue(obj, parts, value) {
|
|
1261
1261
|
let current = obj;
|
|
1262
1262
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
1263
|
-
const
|
|
1264
|
-
if (typeof current !== "object" || current === null || !(
|
|
1263
|
+
const key2 = parts[i];
|
|
1264
|
+
if (typeof current !== "object" || current === null || !(key2 in current)) {
|
|
1265
1265
|
return false;
|
|
1266
1266
|
}
|
|
1267
|
-
if (typeof current[
|
|
1267
|
+
if (typeof current[key2] !== "object" || current[key2] === null) {
|
|
1268
1268
|
return false;
|
|
1269
1269
|
}
|
|
1270
|
-
current = current[
|
|
1270
|
+
current = current[key2];
|
|
1271
1271
|
}
|
|
1272
1272
|
const lastKey = parts[parts.length - 1];
|
|
1273
1273
|
if (lastKey === "*") {
|
|
@@ -1276,9 +1276,9 @@ var require_redact = __commonJS({
|
|
|
1276
1276
|
current[i] = value;
|
|
1277
1277
|
}
|
|
1278
1278
|
} else if (typeof current === "object" && current !== null) {
|
|
1279
|
-
for (const
|
|
1280
|
-
if (Object.prototype.hasOwnProperty.call(current,
|
|
1281
|
-
current[
|
|
1279
|
+
for (const key2 in current) {
|
|
1280
|
+
if (Object.prototype.hasOwnProperty.call(current, key2)) {
|
|
1281
|
+
current[key2] = value;
|
|
1282
1282
|
}
|
|
1283
1283
|
}
|
|
1284
1284
|
}
|
|
@@ -1292,14 +1292,14 @@ var require_redact = __commonJS({
|
|
|
1292
1292
|
function removeKey(obj, parts) {
|
|
1293
1293
|
let current = obj;
|
|
1294
1294
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
1295
|
-
const
|
|
1296
|
-
if (typeof current !== "object" || current === null || !(
|
|
1295
|
+
const key2 = parts[i];
|
|
1296
|
+
if (typeof current !== "object" || current === null || !(key2 in current)) {
|
|
1297
1297
|
return false;
|
|
1298
1298
|
}
|
|
1299
|
-
if (typeof current[
|
|
1299
|
+
if (typeof current[key2] !== "object" || current[key2] === null) {
|
|
1300
1300
|
return false;
|
|
1301
1301
|
}
|
|
1302
|
-
current = current[
|
|
1302
|
+
current = current[key2];
|
|
1303
1303
|
}
|
|
1304
1304
|
const lastKey = parts[parts.length - 1];
|
|
1305
1305
|
if (lastKey === "*") {
|
|
@@ -1308,9 +1308,9 @@ var require_redact = __commonJS({
|
|
|
1308
1308
|
current[i] = void 0;
|
|
1309
1309
|
}
|
|
1310
1310
|
} else if (typeof current === "object" && current !== null) {
|
|
1311
|
-
for (const
|
|
1312
|
-
if (Object.prototype.hasOwnProperty.call(current,
|
|
1313
|
-
delete current[
|
|
1311
|
+
for (const key2 in current) {
|
|
1312
|
+
if (Object.prototype.hasOwnProperty.call(current, key2)) {
|
|
1313
|
+
delete current[key2];
|
|
1314
1314
|
}
|
|
1315
1315
|
}
|
|
1316
1316
|
}
|
|
@@ -1395,19 +1395,19 @@ var require_redact = __commonJS({
|
|
|
1395
1395
|
} else if (typeof current === "object" && current !== null) {
|
|
1396
1396
|
if (remove) {
|
|
1397
1397
|
const keysToDelete = [];
|
|
1398
|
-
for (const
|
|
1399
|
-
if (Object.prototype.hasOwnProperty.call(current,
|
|
1400
|
-
keysToDelete.push(
|
|
1398
|
+
for (const key2 in current) {
|
|
1399
|
+
if (Object.prototype.hasOwnProperty.call(current, key2)) {
|
|
1400
|
+
keysToDelete.push(key2);
|
|
1401
1401
|
}
|
|
1402
1402
|
}
|
|
1403
|
-
for (const
|
|
1404
|
-
delete current[
|
|
1403
|
+
for (const key2 of keysToDelete) {
|
|
1404
|
+
delete current[key2];
|
|
1405
1405
|
}
|
|
1406
1406
|
} else {
|
|
1407
|
-
for (const
|
|
1408
|
-
const keyPath = [...parentParts,
|
|
1409
|
-
const actualCensor = typeof censor === "function" ? censor(current[
|
|
1410
|
-
current[
|
|
1407
|
+
for (const key2 in current) {
|
|
1408
|
+
const keyPath = [...parentParts, key2];
|
|
1409
|
+
const actualCensor = typeof censor === "function" ? censor(current[key2], keyPath) : censor;
|
|
1410
|
+
current[key2] = actualCensor;
|
|
1411
1411
|
}
|
|
1412
1412
|
}
|
|
1413
1413
|
}
|
|
@@ -1427,9 +1427,9 @@ var require_redact = __commonJS({
|
|
|
1427
1427
|
traverse(current[i], pathLength + 1);
|
|
1428
1428
|
}
|
|
1429
1429
|
} else if (typeof current === "object" && current !== null) {
|
|
1430
|
-
for (const
|
|
1431
|
-
pathArray[pathLength] =
|
|
1432
|
-
traverse(current[
|
|
1430
|
+
for (const key2 in current) {
|
|
1431
|
+
pathArray[pathLength] = key2;
|
|
1432
|
+
traverse(current[key2], pathLength + 1);
|
|
1433
1433
|
}
|
|
1434
1434
|
}
|
|
1435
1435
|
} else if (pathLength < beforeWildcard.length) {
|
|
@@ -1516,12 +1516,12 @@ var require_redact = __commonJS({
|
|
|
1516
1516
|
return cloned2;
|
|
1517
1517
|
}
|
|
1518
1518
|
const cloned = Object.create(Object.getPrototypeOf(source));
|
|
1519
|
-
for (const
|
|
1520
|
-
if (Object.prototype.hasOwnProperty.call(source,
|
|
1521
|
-
if (pathMap.has(
|
|
1522
|
-
cloned[
|
|
1519
|
+
for (const key2 in source) {
|
|
1520
|
+
if (Object.prototype.hasOwnProperty.call(source, key2)) {
|
|
1521
|
+
if (pathMap.has(key2) || pathMap.has("*")) {
|
|
1522
|
+
cloned[key2] = cloneSelectively(source[key2], pathMap.get(key2) || pathMap.get("*"));
|
|
1523
1523
|
} else {
|
|
1524
|
-
cloned[
|
|
1524
|
+
cloned[key2] = source[key2];
|
|
1525
1525
|
}
|
|
1526
1526
|
}
|
|
1527
1527
|
}
|
|
@@ -2768,7 +2768,7 @@ var require_thread_stream = __commonJS({
|
|
|
2768
2768
|
var { version } = require_package();
|
|
2769
2769
|
var { EventEmitter: EventEmitter2 } = __require("events");
|
|
2770
2770
|
var { Worker } = __require("worker_threads");
|
|
2771
|
-
var { join:
|
|
2771
|
+
var { join: join5 } = __require("path");
|
|
2772
2772
|
var { pathToFileURL } = __require("url");
|
|
2773
2773
|
var { wait } = require_wait();
|
|
2774
2774
|
var {
|
|
@@ -2804,7 +2804,7 @@ var require_thread_stream = __commonJS({
|
|
|
2804
2804
|
function createWorker(stream, opts) {
|
|
2805
2805
|
const { filename, workerData } = opts;
|
|
2806
2806
|
const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
|
|
2807
|
-
const toExecute = bundlerOverrides["thread-stream-worker"] ||
|
|
2807
|
+
const toExecute = bundlerOverrides["thread-stream-worker"] || join5(__dirname, "lib", "worker.js");
|
|
2808
2808
|
const worker = new Worker(toExecute, {
|
|
2809
2809
|
...opts.workerOpts,
|
|
2810
2810
|
trackUnmanagedFds: false,
|
|
@@ -3193,9 +3193,9 @@ var require_transport = __commonJS({
|
|
|
3193
3193
|
"../../node_modules/.pnpm/pino@10.3.1/node_modules/pino/lib/transport.js"(exports, module) {
|
|
3194
3194
|
"use strict";
|
|
3195
3195
|
var { createRequire } = __require("module");
|
|
3196
|
-
var { existsSync:
|
|
3196
|
+
var { existsSync: existsSync4 } = __require("fs");
|
|
3197
3197
|
var getCallers = require_caller();
|
|
3198
|
-
var { join:
|
|
3198
|
+
var { join: join5, isAbsolute: isAbsolute2, sep } = __require("path");
|
|
3199
3199
|
var { fileURLToPath } = __require("url");
|
|
3200
3200
|
var sleep = require_atomic_sleep();
|
|
3201
3201
|
var onExit = require_on_exit_leak_free();
|
|
@@ -3267,7 +3267,7 @@ var require_transport = __commonJS({
|
|
|
3267
3267
|
return false;
|
|
3268
3268
|
}
|
|
3269
3269
|
}
|
|
3270
|
-
return isAbsolute2(path5) && !
|
|
3270
|
+
return isAbsolute2(path5) && !existsSync4(path5);
|
|
3271
3271
|
}
|
|
3272
3272
|
function stripQuotes(value) {
|
|
3273
3273
|
const first = value[0];
|
|
@@ -3348,7 +3348,7 @@ var require_transport = __commonJS({
|
|
|
3348
3348
|
throw new Error("only one of target or targets can be specified");
|
|
3349
3349
|
}
|
|
3350
3350
|
if (targets) {
|
|
3351
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
3351
|
+
target = bundlerOverrides["pino-worker"] || join5(__dirname, "worker.js");
|
|
3352
3352
|
options.targets = targets.filter((dest) => dest.target).map((dest) => {
|
|
3353
3353
|
return {
|
|
3354
3354
|
...dest,
|
|
@@ -3366,7 +3366,7 @@ var require_transport = __commonJS({
|
|
|
3366
3366
|
});
|
|
3367
3367
|
});
|
|
3368
3368
|
} else if (pipeline) {
|
|
3369
|
-
target = bundlerOverrides["pino-worker"] ||
|
|
3369
|
+
target = bundlerOverrides["pino-worker"] || join5(__dirname, "worker.js");
|
|
3370
3370
|
options.pipelines = [pipeline.map((dest) => {
|
|
3371
3371
|
return {
|
|
3372
3372
|
...dest,
|
|
@@ -3389,7 +3389,7 @@ var require_transport = __commonJS({
|
|
|
3389
3389
|
return origin;
|
|
3390
3390
|
}
|
|
3391
3391
|
if (origin === "pino/file") {
|
|
3392
|
-
return
|
|
3392
|
+
return join5(__dirname, "..", "file.js");
|
|
3393
3393
|
}
|
|
3394
3394
|
let fixTarget2;
|
|
3395
3395
|
for (const filePath of callers) {
|
|
@@ -3529,15 +3529,15 @@ var require_tools = __commonJS({
|
|
|
3529
3529
|
}
|
|
3530
3530
|
const wildcardStringifier = stringifiers[wildcardFirstSym];
|
|
3531
3531
|
let propStr = "";
|
|
3532
|
-
for (const
|
|
3533
|
-
value = obj[
|
|
3534
|
-
if (Object.prototype.hasOwnProperty.call(obj,
|
|
3535
|
-
if (serializers[
|
|
3536
|
-
value = serializers[
|
|
3537
|
-
} else if (
|
|
3532
|
+
for (const key2 in obj) {
|
|
3533
|
+
value = obj[key2];
|
|
3534
|
+
if (Object.prototype.hasOwnProperty.call(obj, key2) && value !== void 0) {
|
|
3535
|
+
if (serializers[key2]) {
|
|
3536
|
+
value = serializers[key2](value);
|
|
3537
|
+
} else if (key2 === errorKey && serializers.err) {
|
|
3538
3538
|
value = serializers.err(value);
|
|
3539
3539
|
}
|
|
3540
|
-
const stringifier = stringifiers[
|
|
3540
|
+
const stringifier = stringifiers[key2] || wildcardStringifier;
|
|
3541
3541
|
switch (typeof value) {
|
|
3542
3542
|
case "undefined":
|
|
3543
3543
|
case "function":
|
|
@@ -3557,7 +3557,7 @@ var require_tools = __commonJS({
|
|
|
3557
3557
|
value = (stringifier || stringify2)(value, stringifySafe);
|
|
3558
3558
|
}
|
|
3559
3559
|
if (value === void 0) continue;
|
|
3560
|
-
const strKey = asString(
|
|
3560
|
+
const strKey = asString(key2);
|
|
3561
3561
|
propStr += "," + strKey + ":" + value;
|
|
3562
3562
|
}
|
|
3563
3563
|
}
|
|
@@ -3602,14 +3602,14 @@ var require_tools = __commonJS({
|
|
|
3602
3602
|
const serializers = instance[serializersSym];
|
|
3603
3603
|
const formatter = instance[formattersSym].bindings;
|
|
3604
3604
|
bindings = formatter(bindings);
|
|
3605
|
-
for (const
|
|
3606
|
-
value = bindings[
|
|
3607
|
-
const valid = (
|
|
3605
|
+
for (const key2 in bindings) {
|
|
3606
|
+
value = bindings[key2];
|
|
3607
|
+
const valid = (key2.length < 5 || key2 !== "level" && key2 !== "serializers" && key2 !== "formatters" && key2 !== "customLevels") && bindings.hasOwnProperty(key2) && value !== void 0;
|
|
3608
3608
|
if (valid === true) {
|
|
3609
|
-
value = serializers[
|
|
3610
|
-
value = (stringifiers[
|
|
3609
|
+
value = serializers[key2] ? serializers[key2](value) : value;
|
|
3610
|
+
value = (stringifiers[key2] || wildcardStringifier || stringify2)(value, stringifySafe);
|
|
3611
3611
|
if (value === void 0) continue;
|
|
3612
|
-
data += ',"' +
|
|
3612
|
+
data += ',"' + key2 + '":' + value;
|
|
3613
3613
|
}
|
|
3614
3614
|
}
|
|
3615
3615
|
return data;
|
|
@@ -3845,12 +3845,12 @@ var require_levels = __commonJS({
|
|
|
3845
3845
|
const useOnlyCustomLevelsVal = this[useOnlyCustomLevelsSym];
|
|
3846
3846
|
const levelComparison = this[levelCompSym];
|
|
3847
3847
|
const hook = this[hooksSym].logMethod;
|
|
3848
|
-
for (const
|
|
3849
|
-
if (levelComparison(values[
|
|
3850
|
-
this[
|
|
3848
|
+
for (const key2 in values) {
|
|
3849
|
+
if (levelComparison(values[key2], levelVal) === false) {
|
|
3850
|
+
this[key2] = noop;
|
|
3851
3851
|
continue;
|
|
3852
3852
|
}
|
|
3853
|
-
this[
|
|
3853
|
+
this[key2] = isStandardLevel(key2, useOnlyCustomLevelsVal) ? levelMethods[key2](hook) : genLog(values[key2], hook);
|
|
3854
3854
|
}
|
|
3855
3855
|
this.emit(
|
|
3856
3856
|
"level-change",
|
|
@@ -3902,7 +3902,7 @@ var require_levels = __commonJS({
|
|
|
3902
3902
|
function assertDefaultLevelFound(defaultLevel, customLevels, useOnlyCustomLevels) {
|
|
3903
3903
|
if (typeof defaultLevel === "number") {
|
|
3904
3904
|
const values = [].concat(
|
|
3905
|
-
Object.keys(customLevels || {}).map((
|
|
3905
|
+
Object.keys(customLevels || {}).map((key2) => customLevels[key2]),
|
|
3906
3906
|
useOnlyCustomLevels ? [] : Object.keys(nums).map((level) => +level),
|
|
3907
3907
|
Infinity
|
|
3908
3908
|
);
|
|
@@ -4171,7 +4171,7 @@ var require_proto = __commonJS({
|
|
|
4171
4171
|
if (mixin) {
|
|
4172
4172
|
obj = mixinMergeStrategy(obj, mixin(obj, num, this));
|
|
4173
4173
|
}
|
|
4174
|
-
const
|
|
4174
|
+
const s2 = this[asJsonSym](obj, msg, num, t);
|
|
4175
4175
|
const stream = this[streamSym];
|
|
4176
4176
|
if (stream[needsMetadataGsym] === true) {
|
|
4177
4177
|
stream.lastLevel = num;
|
|
@@ -4180,7 +4180,7 @@ var require_proto = __commonJS({
|
|
|
4180
4180
|
stream.lastTime = t.slice(this[timeSliceIndexSym]);
|
|
4181
4181
|
stream.lastLogger = this;
|
|
4182
4182
|
}
|
|
4183
|
-
stream.write(streamWriteHook ? streamWriteHook(
|
|
4183
|
+
stream.write(streamWriteHook ? streamWriteHook(s2) : s2);
|
|
4184
4184
|
}
|
|
4185
4185
|
function flush(cb) {
|
|
4186
4186
|
if (cb != null && typeof cb !== "function") {
|
|
@@ -4280,28 +4280,28 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
4280
4280
|
}
|
|
4281
4281
|
return value === void 0 ? true : value;
|
|
4282
4282
|
}
|
|
4283
|
-
function getBooleanOption(options,
|
|
4283
|
+
function getBooleanOption(options, key2) {
|
|
4284
4284
|
let value;
|
|
4285
|
-
if (hasOwnProperty.call(options,
|
|
4286
|
-
value = options[
|
|
4285
|
+
if (hasOwnProperty.call(options, key2)) {
|
|
4286
|
+
value = options[key2];
|
|
4287
4287
|
if (typeof value !== "boolean") {
|
|
4288
|
-
throw new TypeError(`The "${
|
|
4288
|
+
throw new TypeError(`The "${key2}" argument must be of type boolean`);
|
|
4289
4289
|
}
|
|
4290
4290
|
}
|
|
4291
4291
|
return value === void 0 ? true : value;
|
|
4292
4292
|
}
|
|
4293
|
-
function getPositiveIntegerOption(options,
|
|
4293
|
+
function getPositiveIntegerOption(options, key2) {
|
|
4294
4294
|
let value;
|
|
4295
|
-
if (hasOwnProperty.call(options,
|
|
4296
|
-
value = options[
|
|
4295
|
+
if (hasOwnProperty.call(options, key2)) {
|
|
4296
|
+
value = options[key2];
|
|
4297
4297
|
if (typeof value !== "number") {
|
|
4298
|
-
throw new TypeError(`The "${
|
|
4298
|
+
throw new TypeError(`The "${key2}" argument must be of type number`);
|
|
4299
4299
|
}
|
|
4300
4300
|
if (!Number.isInteger(value)) {
|
|
4301
|
-
throw new TypeError(`The "${
|
|
4301
|
+
throw new TypeError(`The "${key2}" argument must be an integer`);
|
|
4302
4302
|
}
|
|
4303
4303
|
if (value < 1) {
|
|
4304
|
-
throw new RangeError(`The "${
|
|
4304
|
+
throw new RangeError(`The "${key2}" argument must be >= 1`);
|
|
4305
4305
|
}
|
|
4306
4306
|
}
|
|
4307
4307
|
return value === void 0 ? Infinity : value;
|
|
@@ -4353,12 +4353,12 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
4353
4353
|
const comparator = typeof deterministic === "function" ? deterministic : void 0;
|
|
4354
4354
|
const maximumDepth = getPositiveIntegerOption(options, "maximumDepth");
|
|
4355
4355
|
const maximumBreadth = getPositiveIntegerOption(options, "maximumBreadth");
|
|
4356
|
-
function stringifyFnReplacer(
|
|
4357
|
-
let value = parent[
|
|
4356
|
+
function stringifyFnReplacer(key2, parent, stack, replacer, spacer, indentation) {
|
|
4357
|
+
let value = parent[key2];
|
|
4358
4358
|
if (typeof value === "object" && value !== null && typeof value.toJSON === "function") {
|
|
4359
|
-
value = value.toJSON(
|
|
4359
|
+
value = value.toJSON(key2);
|
|
4360
4360
|
}
|
|
4361
|
-
value = replacer.call(parent,
|
|
4361
|
+
value = replacer.call(parent, key2, value);
|
|
4362
4362
|
switch (typeof value) {
|
|
4363
4363
|
case "string":
|
|
4364
4364
|
return strEscape(value);
|
|
@@ -4370,7 +4370,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
4370
4370
|
return circularValue;
|
|
4371
4371
|
}
|
|
4372
4372
|
let res = "";
|
|
4373
|
-
let
|
|
4373
|
+
let join5 = ",";
|
|
4374
4374
|
const originalIndentation = indentation;
|
|
4375
4375
|
if (Array.isArray(value)) {
|
|
4376
4376
|
if (value.length === 0) {
|
|
@@ -4384,7 +4384,7 @@ var require_safe_stable_stringify = __commonJS({
|
|
|
4384
4384
|
indentation += spacer;
|
|
4385
4385
|
res += `
|
|
4386
4386
|
${indentation}`;
|
|
4387
|
-
|
|
4387
|
+
join5 = `,
|
|
4388
4388
|
${indentation}`;
|
|
4389
4389
|
}
|
|
4390
4390
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -4392,13 +4392,13 @@ ${indentation}`;
|
|
|
4392
4392
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
4393
4393
|
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
4394
4394
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
4395
|
-
res +=
|
|
4395
|
+
res += join5;
|
|
4396
4396
|
}
|
|
4397
4397
|
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
4398
4398
|
res += tmp !== void 0 ? tmp : "null";
|
|
4399
4399
|
if (value.length - 1 > maximumBreadth) {
|
|
4400
4400
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
4401
|
-
res += `${
|
|
4401
|
+
res += `${join5}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
4402
4402
|
}
|
|
4403
4403
|
if (spacer !== "") {
|
|
4404
4404
|
res += `
|
|
@@ -4419,7 +4419,7 @@ ${originalIndentation}`;
|
|
|
4419
4419
|
let separator = "";
|
|
4420
4420
|
if (spacer !== "") {
|
|
4421
4421
|
indentation += spacer;
|
|
4422
|
-
|
|
4422
|
+
join5 = `,
|
|
4423
4423
|
${indentation}`;
|
|
4424
4424
|
whitespace = " ";
|
|
4425
4425
|
}
|
|
@@ -4429,17 +4429,17 @@ ${indentation}`;
|
|
|
4429
4429
|
}
|
|
4430
4430
|
stack.push(value);
|
|
4431
4431
|
for (let i = 0; i < maximumPropertiesToStringify; i++) {
|
|
4432
|
-
const
|
|
4433
|
-
const tmp = stringifyFnReplacer(
|
|
4432
|
+
const key3 = keys[i];
|
|
4433
|
+
const tmp = stringifyFnReplacer(key3, value, stack, replacer, spacer, indentation);
|
|
4434
4434
|
if (tmp !== void 0) {
|
|
4435
|
-
res += `${separator}${strEscape(
|
|
4436
|
-
separator =
|
|
4435
|
+
res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
|
|
4436
|
+
separator = join5;
|
|
4437
4437
|
}
|
|
4438
4438
|
}
|
|
4439
4439
|
if (keyLength > maximumBreadth) {
|
|
4440
4440
|
const removedKeys = keyLength - maximumBreadth;
|
|
4441
4441
|
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
4442
|
-
separator =
|
|
4442
|
+
separator = join5;
|
|
4443
4443
|
}
|
|
4444
4444
|
if (spacer !== "" && separator.length > 1) {
|
|
4445
4445
|
res = `
|
|
@@ -4464,9 +4464,9 @@ ${originalIndentation}`;
|
|
|
4464
4464
|
return fail ? fail(value) : void 0;
|
|
4465
4465
|
}
|
|
4466
4466
|
}
|
|
4467
|
-
function stringifyArrayReplacer(
|
|
4467
|
+
function stringifyArrayReplacer(key2, value, stack, replacer, spacer, indentation) {
|
|
4468
4468
|
if (typeof value === "object" && value !== null && typeof value.toJSON === "function") {
|
|
4469
|
-
value = value.toJSON(
|
|
4469
|
+
value = value.toJSON(key2);
|
|
4470
4470
|
}
|
|
4471
4471
|
switch (typeof value) {
|
|
4472
4472
|
case "string":
|
|
@@ -4480,7 +4480,7 @@ ${originalIndentation}`;
|
|
|
4480
4480
|
}
|
|
4481
4481
|
const originalIndentation = indentation;
|
|
4482
4482
|
let res = "";
|
|
4483
|
-
let
|
|
4483
|
+
let join5 = ",";
|
|
4484
4484
|
if (Array.isArray(value)) {
|
|
4485
4485
|
if (value.length === 0) {
|
|
4486
4486
|
return "[]";
|
|
@@ -4493,7 +4493,7 @@ ${originalIndentation}`;
|
|
|
4493
4493
|
indentation += spacer;
|
|
4494
4494
|
res += `
|
|
4495
4495
|
${indentation}`;
|
|
4496
|
-
|
|
4496
|
+
join5 = `,
|
|
4497
4497
|
${indentation}`;
|
|
4498
4498
|
}
|
|
4499
4499
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
@@ -4501,13 +4501,13 @@ ${indentation}`;
|
|
|
4501
4501
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
4502
4502
|
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
4503
4503
|
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
4504
|
-
res +=
|
|
4504
|
+
res += join5;
|
|
4505
4505
|
}
|
|
4506
4506
|
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
4507
4507
|
res += tmp !== void 0 ? tmp : "null";
|
|
4508
4508
|
if (value.length - 1 > maximumBreadth) {
|
|
4509
4509
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
4510
|
-
res += `${
|
|
4510
|
+
res += `${join5}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
4511
4511
|
}
|
|
4512
4512
|
if (spacer !== "") {
|
|
4513
4513
|
res += `
|
|
@@ -4520,16 +4520,16 @@ ${originalIndentation}`;
|
|
|
4520
4520
|
let whitespace = "";
|
|
4521
4521
|
if (spacer !== "") {
|
|
4522
4522
|
indentation += spacer;
|
|
4523
|
-
|
|
4523
|
+
join5 = `,
|
|
4524
4524
|
${indentation}`;
|
|
4525
4525
|
whitespace = " ";
|
|
4526
4526
|
}
|
|
4527
4527
|
let separator = "";
|
|
4528
|
-
for (const
|
|
4529
|
-
const tmp = stringifyArrayReplacer(
|
|
4528
|
+
for (const key3 of replacer) {
|
|
4529
|
+
const tmp = stringifyArrayReplacer(key3, value[key3], stack, replacer, spacer, indentation);
|
|
4530
4530
|
if (tmp !== void 0) {
|
|
4531
|
-
res += `${separator}${strEscape(
|
|
4532
|
-
separator =
|
|
4531
|
+
res += `${separator}${strEscape(key3)}:${whitespace}${tmp}`;
|
|
4532
|
+
separator = join5;
|
|
4533
4533
|
}
|
|
4534
4534
|
}
|
|
4535
4535
|
if (spacer !== "" && separator.length > 1) {
|
|
@@ -4555,7 +4555,7 @@ ${originalIndentation}`;
|
|
|
4555
4555
|
return fail ? fail(value) : void 0;
|
|
4556
4556
|
}
|
|
4557
4557
|
}
|
|
4558
|
-
function stringifyIndent(
|
|
4558
|
+
function stringifyIndent(key2, value, stack, spacer, indentation) {
|
|
4559
4559
|
switch (typeof value) {
|
|
4560
4560
|
case "string":
|
|
4561
4561
|
return strEscape(value);
|
|
@@ -4564,9 +4564,9 @@ ${originalIndentation}`;
|
|
|
4564
4564
|
return "null";
|
|
4565
4565
|
}
|
|
4566
4566
|
if (typeof value.toJSON === "function") {
|
|
4567
|
-
value = value.toJSON(
|
|
4567
|
+
value = value.toJSON(key2);
|
|
4568
4568
|
if (typeof value !== "object") {
|
|
4569
|
-
return stringifyIndent(
|
|
4569
|
+
return stringifyIndent(key2, value, stack, spacer, indentation);
|
|
4570
4570
|
}
|
|
4571
4571
|
if (value === null) {
|
|
4572
4572
|
return "null";
|
|
@@ -4587,20 +4587,20 @@ ${originalIndentation}`;
|
|
|
4587
4587
|
indentation += spacer;
|
|
4588
4588
|
let res2 = `
|
|
4589
4589
|
${indentation}`;
|
|
4590
|
-
const
|
|
4590
|
+
const join6 = `,
|
|
4591
4591
|
${indentation}`;
|
|
4592
4592
|
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
4593
4593
|
let i = 0;
|
|
4594
4594
|
for (; i < maximumValuesToStringify - 1; i++) {
|
|
4595
4595
|
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
4596
4596
|
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
4597
|
-
res2 +=
|
|
4597
|
+
res2 += join6;
|
|
4598
4598
|
}
|
|
4599
4599
|
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
4600
4600
|
res2 += tmp !== void 0 ? tmp : "null";
|
|
4601
4601
|
if (value.length - 1 > maximumBreadth) {
|
|
4602
4602
|
const removedKeys = value.length - maximumBreadth - 1;
|
|
4603
|
-
res2 += `${
|
|
4603
|
+
res2 += `${join6}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
4604
4604
|
}
|
|
4605
4605
|
res2 += `
|
|
4606
4606
|
${originalIndentation}`;
|
|
@@ -4616,33 +4616,33 @@ ${originalIndentation}`;
|
|
|
4616
4616
|
return '"[Object]"';
|
|
4617
4617
|
}
|
|
4618
4618
|
indentation += spacer;
|
|
4619
|
-
const
|
|
4619
|
+
const join5 = `,
|
|
4620
4620
|
${indentation}`;
|
|
4621
4621
|
let res = "";
|
|
4622
4622
|
let separator = "";
|
|
4623
4623
|
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
4624
4624
|
if (isTypedArrayWithEntries(value)) {
|
|
4625
|
-
res += stringifyTypedArray(value,
|
|
4625
|
+
res += stringifyTypedArray(value, join5, maximumBreadth);
|
|
4626
4626
|
keys = keys.slice(value.length);
|
|
4627
4627
|
maximumPropertiesToStringify -= value.length;
|
|
4628
|
-
separator =
|
|
4628
|
+
separator = join5;
|
|
4629
4629
|
}
|
|
4630
4630
|
if (deterministic) {
|
|
4631
4631
|
keys = sort(keys, comparator);
|
|
4632
4632
|
}
|
|
4633
4633
|
stack.push(value);
|
|
4634
4634
|
for (let i = 0; i < maximumPropertiesToStringify; i++) {
|
|
4635
|
-
const
|
|
4636
|
-
const tmp = stringifyIndent(
|
|
4635
|
+
const key3 = keys[i];
|
|
4636
|
+
const tmp = stringifyIndent(key3, value[key3], stack, spacer, indentation);
|
|
4637
4637
|
if (tmp !== void 0) {
|
|
4638
|
-
res += `${separator}${strEscape(
|
|
4639
|
-
separator =
|
|
4638
|
+
res += `${separator}${strEscape(key3)}: ${tmp}`;
|
|
4639
|
+
separator = join5;
|
|
4640
4640
|
}
|
|
4641
4641
|
}
|
|
4642
4642
|
if (keyLength > maximumBreadth) {
|
|
4643
4643
|
const removedKeys = keyLength - maximumBreadth;
|
|
4644
4644
|
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
4645
|
-
separator =
|
|
4645
|
+
separator = join5;
|
|
4646
4646
|
}
|
|
4647
4647
|
if (separator !== "") {
|
|
4648
4648
|
res = `
|
|
@@ -4667,7 +4667,7 @@ ${originalIndentation}`;
|
|
|
4667
4667
|
return fail ? fail(value) : void 0;
|
|
4668
4668
|
}
|
|
4669
4669
|
}
|
|
4670
|
-
function stringifySimple(
|
|
4670
|
+
function stringifySimple(key2, value, stack) {
|
|
4671
4671
|
switch (typeof value) {
|
|
4672
4672
|
case "string":
|
|
4673
4673
|
return strEscape(value);
|
|
@@ -4676,9 +4676,9 @@ ${originalIndentation}`;
|
|
|
4676
4676
|
return "null";
|
|
4677
4677
|
}
|
|
4678
4678
|
if (typeof value.toJSON === "function") {
|
|
4679
|
-
value = value.toJSON(
|
|
4679
|
+
value = value.toJSON(key2);
|
|
4680
4680
|
if (typeof value !== "object") {
|
|
4681
|
-
return stringifySimple(
|
|
4681
|
+
return stringifySimple(key2, value, stack);
|
|
4682
4682
|
}
|
|
4683
4683
|
if (value === null) {
|
|
4684
4684
|
return "null";
|
|
@@ -4734,10 +4734,10 @@ ${originalIndentation}`;
|
|
|
4734
4734
|
}
|
|
4735
4735
|
stack.push(value);
|
|
4736
4736
|
for (let i = 0; i < maximumPropertiesToStringify; i++) {
|
|
4737
|
-
const
|
|
4738
|
-
const tmp = stringifySimple(
|
|
4737
|
+
const key3 = keys[i];
|
|
4738
|
+
const tmp = stringifySimple(key3, value[key3], stack);
|
|
4739
4739
|
if (tmp !== void 0) {
|
|
4740
|
-
res += `${separator}${strEscape(
|
|
4740
|
+
res += `${separator}${strEscape(key3)}:${tmp}`;
|
|
4741
4741
|
separator = ",";
|
|
4742
4742
|
}
|
|
4743
4743
|
}
|
|
@@ -4905,7 +4905,7 @@ var require_multistream = __commonJS({
|
|
|
4905
4905
|
}
|
|
4906
4906
|
function remove(id) {
|
|
4907
4907
|
const { streams } = this;
|
|
4908
|
-
const index = streams.findIndex((
|
|
4908
|
+
const index = streams.findIndex((s2) => s2.id === id);
|
|
4909
4909
|
if (index >= 0) {
|
|
4910
4910
|
streams.splice(index, 1);
|
|
4911
4911
|
streams.sort(compareByLevel);
|
|
@@ -5779,8 +5779,8 @@ function getProperty(object, path5, value) {
|
|
|
5779
5779
|
return value;
|
|
5780
5780
|
}
|
|
5781
5781
|
for (let index = 0; index < pathArray.length; index++) {
|
|
5782
|
-
const
|
|
5783
|
-
object = object[
|
|
5782
|
+
const key2 = pathArray[index];
|
|
5783
|
+
object = object[key2];
|
|
5784
5784
|
if (object === void 0 || object === null) {
|
|
5785
5785
|
if (index !== pathArray.length - 1) {
|
|
5786
5786
|
return value;
|
|
@@ -5800,15 +5800,15 @@ function setProperty(object, path5, value) {
|
|
|
5800
5800
|
return object;
|
|
5801
5801
|
}
|
|
5802
5802
|
for (let index = 0; index < pathArray.length; index++) {
|
|
5803
|
-
const
|
|
5803
|
+
const key2 = pathArray[index];
|
|
5804
5804
|
if (index === pathArray.length - 1) {
|
|
5805
|
-
object[
|
|
5806
|
-
} else if (!isObject(object[
|
|
5805
|
+
object[key2] = value;
|
|
5806
|
+
} else if (!isObject(object[key2])) {
|
|
5807
5807
|
const nextKey = pathArray[index + 1];
|
|
5808
5808
|
const shouldCreateArray = typeof nextKey === "number";
|
|
5809
|
-
object[
|
|
5809
|
+
object[key2] = shouldCreateArray ? [] : {};
|
|
5810
5810
|
}
|
|
5811
|
-
object = object[
|
|
5811
|
+
object = object[key2];
|
|
5812
5812
|
}
|
|
5813
5813
|
return root;
|
|
5814
5814
|
}
|
|
@@ -5821,16 +5821,16 @@ function deleteProperty(object, path5) {
|
|
|
5821
5821
|
return false;
|
|
5822
5822
|
}
|
|
5823
5823
|
for (let index = 0; index < pathArray.length; index++) {
|
|
5824
|
-
const
|
|
5824
|
+
const key2 = pathArray[index];
|
|
5825
5825
|
if (index === pathArray.length - 1) {
|
|
5826
|
-
const existed = Object.hasOwn(object,
|
|
5826
|
+
const existed = Object.hasOwn(object, key2);
|
|
5827
5827
|
if (!existed) {
|
|
5828
5828
|
return false;
|
|
5829
5829
|
}
|
|
5830
|
-
delete object[
|
|
5830
|
+
delete object[key2];
|
|
5831
5831
|
return true;
|
|
5832
5832
|
}
|
|
5833
|
-
object = object[
|
|
5833
|
+
object = object[key2];
|
|
5834
5834
|
if (!isObject(object)) {
|
|
5835
5835
|
return false;
|
|
5836
5836
|
}
|
|
@@ -5844,11 +5844,11 @@ function hasProperty(object, path5) {
|
|
|
5844
5844
|
if (pathArray.length === 0) {
|
|
5845
5845
|
return false;
|
|
5846
5846
|
}
|
|
5847
|
-
for (const
|
|
5848
|
-
if (!isObject(object) || !(
|
|
5847
|
+
for (const key2 of pathArray) {
|
|
5848
|
+
if (!isObject(object) || !(key2 in object)) {
|
|
5849
5849
|
return false;
|
|
5850
5850
|
}
|
|
5851
|
-
object = object[
|
|
5851
|
+
object = object[key2];
|
|
5852
5852
|
}
|
|
5853
5853
|
return true;
|
|
5854
5854
|
}
|
|
@@ -5938,26 +5938,26 @@ var Configstore = class {
|
|
|
5938
5938
|
get size() {
|
|
5939
5939
|
return Object.keys(this.all).length;
|
|
5940
5940
|
}
|
|
5941
|
-
get(
|
|
5942
|
-
return getProperty(this.all,
|
|
5941
|
+
get(key2) {
|
|
5942
|
+
return getProperty(this.all, key2);
|
|
5943
5943
|
}
|
|
5944
|
-
set(
|
|
5944
|
+
set(key2, value) {
|
|
5945
5945
|
const config2 = this.all;
|
|
5946
|
-
if (typeof
|
|
5947
|
-
for (const k of Object.keys(
|
|
5948
|
-
setProperty(config2, k,
|
|
5946
|
+
if (typeof key2 === "object" && arguments.length === 1) {
|
|
5947
|
+
for (const k of Object.keys(key2)) {
|
|
5948
|
+
setProperty(config2, k, key2[k]);
|
|
5949
5949
|
}
|
|
5950
5950
|
} else {
|
|
5951
|
-
setProperty(config2,
|
|
5951
|
+
setProperty(config2, key2, value);
|
|
5952
5952
|
}
|
|
5953
5953
|
this.all = config2;
|
|
5954
5954
|
}
|
|
5955
|
-
has(
|
|
5956
|
-
return hasProperty(this.all,
|
|
5955
|
+
has(key2) {
|
|
5956
|
+
return hasProperty(this.all, key2);
|
|
5957
5957
|
}
|
|
5958
|
-
delete(
|
|
5958
|
+
delete(key2) {
|
|
5959
5959
|
const config2 = this.all;
|
|
5960
|
-
deleteProperty(config2,
|
|
5960
|
+
deleteProperty(config2, key2);
|
|
5961
5961
|
this.all = config2;
|
|
5962
5962
|
}
|
|
5963
5963
|
clear() {
|
|
@@ -5969,9 +5969,35 @@ var Configstore = class {
|
|
|
5969
5969
|
};
|
|
5970
5970
|
|
|
5971
5971
|
// ../core/src/global-config.ts
|
|
5972
|
-
import { existsSync, readFileSync } from "fs";
|
|
5972
|
+
import { existsSync, readFileSync, statSync } from "fs";
|
|
5973
5973
|
import { join } from "path";
|
|
5974
5974
|
import { homedir } from "os";
|
|
5975
|
+
var EXTERNAL_CONFIG_MAX_BYTES = 1 * 1024 * 1024;
|
|
5976
|
+
var EXTERNAL_CONFIG_TTL_MS = 5e3;
|
|
5977
|
+
var externalConfigCache = /* @__PURE__ */ new Map();
|
|
5978
|
+
function readExternalJson(path5) {
|
|
5979
|
+
const now = Date.now();
|
|
5980
|
+
const cached = externalConfigCache.get(path5);
|
|
5981
|
+
if (cached && now - cached.at < EXTERNAL_CONFIG_TTL_MS) {
|
|
5982
|
+
return cached.value;
|
|
5983
|
+
}
|
|
5984
|
+
let value = null;
|
|
5985
|
+
try {
|
|
5986
|
+
if (existsSync(path5)) {
|
|
5987
|
+
const { size } = statSync(path5);
|
|
5988
|
+
if (size <= EXTERNAL_CONFIG_MAX_BYTES) {
|
|
5989
|
+
const parsed = JSON.parse(readFileSync(path5, "utf-8"));
|
|
5990
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
5991
|
+
value = parsed;
|
|
5992
|
+
}
|
|
5993
|
+
}
|
|
5994
|
+
}
|
|
5995
|
+
} catch {
|
|
5996
|
+
value = null;
|
|
5997
|
+
}
|
|
5998
|
+
externalConfigCache.set(path5, { at: now, value });
|
|
5999
|
+
return value;
|
|
6000
|
+
}
|
|
5975
6001
|
var SENSITIVE_KEYS = /* @__PURE__ */ new Set(["DISCORD_TOKEN", "ANTHROPIC_API_KEY", "CODEX_API_KEY"]);
|
|
5976
6002
|
var VALID_KEYS = /* @__PURE__ */ new Set([
|
|
5977
6003
|
"DISCORD_TOKEN",
|
|
@@ -6047,11 +6073,11 @@ function getStore() {
|
|
|
6047
6073
|
}
|
|
6048
6074
|
return store;
|
|
6049
6075
|
}
|
|
6050
|
-
function validateConfigValue(
|
|
6051
|
-
if (!VALID_KEYS.has(
|
|
6052
|
-
return `Unknown config key: ${
|
|
6076
|
+
function validateConfigValue(key2, value) {
|
|
6077
|
+
if (!VALID_KEYS.has(key2)) {
|
|
6078
|
+
return `Unknown config key: ${key2}. Valid keys: ${Array.from(VALID_KEYS).join(", ")}`;
|
|
6053
6079
|
}
|
|
6054
|
-
switch (
|
|
6080
|
+
switch (key2) {
|
|
6055
6081
|
case "CODEX_SANDBOX_MODE":
|
|
6056
6082
|
if (!CODEX_SANDBOX_MODES.has(value)) {
|
|
6057
6083
|
return `Invalid value for CODEX_SANDBOX_MODE. Expected one of: ${Array.from(CODEX_SANDBOX_MODES).join(", ")}`;
|
|
@@ -6075,7 +6101,7 @@ function validateConfigValue(key, value) {
|
|
|
6075
6101
|
case "TEXT_CHUNK_LIMIT": {
|
|
6076
6102
|
const n = Number(value);
|
|
6077
6103
|
if (!Number.isInteger(n) || n < 1 || n > 2e3) {
|
|
6078
|
-
return `Invalid value for ${
|
|
6104
|
+
return `Invalid value for ${key2}. Expected an integer between 1 and 2000`;
|
|
6079
6105
|
}
|
|
6080
6106
|
break;
|
|
6081
6107
|
}
|
|
@@ -6109,7 +6135,7 @@ function validateConfigValue(key, value) {
|
|
|
6109
6135
|
case "HEALTH_CHECK_IDLE_THRESHOLD_MS": {
|
|
6110
6136
|
const n = Number(value);
|
|
6111
6137
|
if (!Number.isInteger(n) || n < 0) {
|
|
6112
|
-
return `Invalid value for ${
|
|
6138
|
+
return `Invalid value for ${key2}. Expected a non-negative integer`;
|
|
6113
6139
|
}
|
|
6114
6140
|
break;
|
|
6115
6141
|
}
|
|
@@ -6122,7 +6148,7 @@ function validateConfigValue(key, value) {
|
|
|
6122
6148
|
case "MAX_ACTIVE_SESSIONS": {
|
|
6123
6149
|
const n = Number(value);
|
|
6124
6150
|
if (!Number.isInteger(n) || n <= 0) {
|
|
6125
|
-
return `Invalid value for ${
|
|
6151
|
+
return `Invalid value for ${key2}. Expected a positive integer`;
|
|
6126
6152
|
}
|
|
6127
6153
|
break;
|
|
6128
6154
|
}
|
|
@@ -6168,68 +6194,59 @@ function validateConfigValue(key, value) {
|
|
|
6168
6194
|
}
|
|
6169
6195
|
return null;
|
|
6170
6196
|
}
|
|
6171
|
-
function maskSensitive(
|
|
6172
|
-
if (!SENSITIVE_KEYS.has(
|
|
6197
|
+
function maskSensitive(key2, value) {
|
|
6198
|
+
if (!SENSITIVE_KEYS.has(key2)) return value;
|
|
6173
6199
|
if (value.length <= 8) return "********";
|
|
6174
6200
|
return `${value.slice(0, 4)}********${value.slice(-4)}`;
|
|
6175
6201
|
}
|
|
6176
|
-
function readAnthropicConfig(
|
|
6202
|
+
function readAnthropicConfig(key2) {
|
|
6177
6203
|
const path5 = join(homedir(), ".claude", "settings.json");
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
return env2.ANTHROPIC_BASE_URL;
|
|
6188
|
-
}
|
|
6189
|
-
}
|
|
6190
|
-
} catch {
|
|
6204
|
+
const config2 = readExternalJson(path5);
|
|
6205
|
+
if (!config2) return void 0;
|
|
6206
|
+
const env2 = config2.env && typeof config2.env === "object" ? config2.env : {};
|
|
6207
|
+
if (key2 === "ANTHROPIC_API_KEY") {
|
|
6208
|
+
const token = env2.ANTHROPIC_AUTH_TOKEN ?? env2.ANTHROPIC_API_KEY;
|
|
6209
|
+
return typeof token === "string" ? token : void 0;
|
|
6210
|
+
}
|
|
6211
|
+
if (key2 === "ANTHROPIC_BASE_URL") {
|
|
6212
|
+
return typeof env2.ANTHROPIC_BASE_URL === "string" ? env2.ANTHROPIC_BASE_URL : void 0;
|
|
6191
6213
|
}
|
|
6192
6214
|
return void 0;
|
|
6193
6215
|
}
|
|
6194
|
-
function readCodexConfig(
|
|
6216
|
+
function readCodexConfig(key2) {
|
|
6195
6217
|
const path5 = join(homedir(), ".codex", "config.json");
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
if (key === "CODEX_BASE_URL" && config2.base_url) {
|
|
6204
|
-
return config2.base_url;
|
|
6205
|
-
}
|
|
6206
|
-
}
|
|
6207
|
-
} catch {
|
|
6218
|
+
const config2 = readExternalJson(path5);
|
|
6219
|
+
if (!config2) return void 0;
|
|
6220
|
+
if (key2 === "CODEX_API_KEY" && typeof config2.api_key === "string") {
|
|
6221
|
+
return config2.api_key;
|
|
6222
|
+
}
|
|
6223
|
+
if (key2 === "CODEX_BASE_URL" && typeof config2.base_url === "string") {
|
|
6224
|
+
return config2.base_url;
|
|
6208
6225
|
}
|
|
6209
6226
|
return void 0;
|
|
6210
6227
|
}
|
|
6211
|
-
function getConfigValue(
|
|
6212
|
-
const storeValue = getStore().get(
|
|
6228
|
+
function getConfigValue(key2) {
|
|
6229
|
+
const storeValue = getStore().get(key2);
|
|
6213
6230
|
if (storeValue !== void 0) {
|
|
6214
6231
|
return storeValue;
|
|
6215
6232
|
}
|
|
6216
|
-
const envValue = process.env[
|
|
6233
|
+
const envValue = process.env[key2];
|
|
6217
6234
|
if (envValue !== void 0) {
|
|
6218
6235
|
return envValue;
|
|
6219
6236
|
}
|
|
6220
|
-
if (
|
|
6221
|
-
return readAnthropicConfig(
|
|
6237
|
+
if (key2 === "ANTHROPIC_API_KEY" || key2 === "ANTHROPIC_BASE_URL") {
|
|
6238
|
+
return readAnthropicConfig(key2);
|
|
6222
6239
|
}
|
|
6223
|
-
if (
|
|
6224
|
-
return readCodexConfig(
|
|
6240
|
+
if (key2 === "CODEX_API_KEY" || key2 === "CODEX_BASE_URL") {
|
|
6241
|
+
return readCodexConfig(key2);
|
|
6225
6242
|
}
|
|
6226
6243
|
return void 0;
|
|
6227
6244
|
}
|
|
6228
|
-
function setConfigValue(
|
|
6229
|
-
getStore().set(
|
|
6245
|
+
function setConfigValue(key2, value) {
|
|
6246
|
+
getStore().set(key2, value);
|
|
6230
6247
|
}
|
|
6231
|
-
function deleteConfigValue(
|
|
6232
|
-
getStore().delete(
|
|
6248
|
+
function deleteConfigValue(key2) {
|
|
6249
|
+
getStore().delete(key2);
|
|
6233
6250
|
}
|
|
6234
6251
|
function getAllConfig() {
|
|
6235
6252
|
return getStore().all ?? {};
|
|
@@ -6241,39 +6258,39 @@ function getConfigPath() {
|
|
|
6241
6258
|
// ../core/src/config.ts
|
|
6242
6259
|
import { homedir as homedir2 } from "os";
|
|
6243
6260
|
import { join as join2 } from "path";
|
|
6244
|
-
function required(
|
|
6245
|
-
const value = getConfigValue(
|
|
6261
|
+
function required(key2) {
|
|
6262
|
+
const value = getConfigValue(key2);
|
|
6246
6263
|
if (!value) {
|
|
6247
6264
|
if (process.env.NODE_ENV === "test" || process.env.VITEST === "true") {
|
|
6248
|
-
return `test-${
|
|
6265
|
+
return `test-${key2.toLowerCase()}`;
|
|
6249
6266
|
}
|
|
6250
|
-
console.error(`ERROR: ${
|
|
6267
|
+
console.error(`ERROR: ${key2} is not configured.`);
|
|
6251
6268
|
console.error("Run \x1B[36mworkspacecord config setup\x1B[0m to configure.");
|
|
6252
6269
|
process.exit(1);
|
|
6253
6270
|
}
|
|
6254
6271
|
return value;
|
|
6255
6272
|
}
|
|
6256
|
-
function optional(
|
|
6257
|
-
return getConfigValue(
|
|
6273
|
+
function optional(key2, fallback) {
|
|
6274
|
+
return getConfigValue(key2) ?? fallback;
|
|
6258
6275
|
}
|
|
6259
|
-
function optionalList(
|
|
6260
|
-
const value = getConfigValue(
|
|
6276
|
+
function optionalList(key2, fallback = []) {
|
|
6277
|
+
const value = getConfigValue(key2);
|
|
6261
6278
|
if (!value) return fallback;
|
|
6262
6279
|
return value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
6263
6280
|
}
|
|
6264
|
-
function optionalInt(
|
|
6265
|
-
const value = getConfigValue(
|
|
6281
|
+
function optionalInt(key2, fallback) {
|
|
6282
|
+
const value = getConfigValue(key2);
|
|
6266
6283
|
if (!value) return fallback;
|
|
6267
6284
|
const n = parseInt(value, 10);
|
|
6268
6285
|
return Number.isNaN(n) ? fallback : n;
|
|
6269
6286
|
}
|
|
6270
|
-
function optionalBool(
|
|
6271
|
-
const value = getConfigValue(
|
|
6287
|
+
function optionalBool(key2, fallback) {
|
|
6288
|
+
const value = getConfigValue(key2);
|
|
6272
6289
|
if (!value) return fallback;
|
|
6273
6290
|
return value === "true" || value === "1";
|
|
6274
6291
|
}
|
|
6275
|
-
function optionalEnum(
|
|
6276
|
-
const value = getConfigValue(
|
|
6292
|
+
function optionalEnum(key2, fallback, allowed) {
|
|
6293
|
+
const value = getConfigValue(key2);
|
|
6277
6294
|
if (!value) return fallback;
|
|
6278
6295
|
return allowed.includes(value) ? value : fallback;
|
|
6279
6296
|
}
|
|
@@ -6304,6 +6321,15 @@ var config = {
|
|
|
6304
6321
|
codexNetworkAccessEnabled: optionalBool("CODEX_NETWORK_ACCESS_ENABLED", true),
|
|
6305
6322
|
codexWebSearchMode: optionalEnum("CODEX_WEB_SEARCH", "live", ["disabled", "cached", "live"]),
|
|
6306
6323
|
codexReasoningEffort: optionalEnum("CODEX_REASONING_EFFORT", "", ["", "minimal", "low", "medium", "high", "xhigh"]),
|
|
6324
|
+
/**
|
|
6325
|
+
* Reasoning effort applied to Monitor-mode evaluation passes (across both providers).
|
|
6326
|
+
* - Codex: forwarded to `modelReasoningEffort` on the monitor thread.
|
|
6327
|
+
* - Claude: if set to 'high' or 'xhigh', switches the monitor to `monitorClaudeModel` (default: claude-opus-4-7).
|
|
6328
|
+
* Empty string = inherit from the worker settings.
|
|
6329
|
+
*/
|
|
6330
|
+
monitorReasoningEffort: optionalEnum("MONITOR_REASONING_EFFORT", "high", ["", "minimal", "low", "medium", "high", "xhigh"]),
|
|
6331
|
+
/** Claude model used for monitor passes when `monitorReasoningEffort` is high/xhigh. */
|
|
6332
|
+
monitorClaudeModel: optional("MONITOR_CLAUDE_MODEL", "claude-opus-4-7"),
|
|
6307
6333
|
codexBaseUrl: optional("CODEX_BASE_URL", ""),
|
|
6308
6334
|
codexApiKey: optional("CODEX_API_KEY", ""),
|
|
6309
6335
|
codexPath: optional("CODEX_PATH", ""),
|
|
@@ -6315,7 +6341,26 @@ var config = {
|
|
|
6315
6341
|
healthReportEnabled: optionalBool("HEALTH_REPORT_ENABLED", true),
|
|
6316
6342
|
healthCheckStuckThresholdMs: optionalInt("HEALTH_CHECK_STUCK_THRESHOLD_MS", 18e5),
|
|
6317
6343
|
healthCheckIdleThresholdMs: optionalInt("HEALTH_CHECK_IDLE_THRESHOLD_MS", 72e5),
|
|
6318
|
-
hookSecret: optional("HOOK_SECRET", "")
|
|
6344
|
+
hookSecret: optional("HOOK_SECRET", ""),
|
|
6345
|
+
/**
|
|
6346
|
+
* 重启后 Monitor run 自动续跑策略:
|
|
6347
|
+
* - `abandon-only`(默认):只把 running 的 run 标记为 abandoned,不自动续跑
|
|
6348
|
+
* - `resume-with-goal`:session 仍在 monitor 模式且保存了 goal → 重新拉起 monitor 循环
|
|
6349
|
+
*/
|
|
6350
|
+
monitorAutoResumePolicy: optionalEnum(
|
|
6351
|
+
"MONITOR_AUTO_RESUME_POLICY",
|
|
6352
|
+
"abandon-only",
|
|
6353
|
+
["abandon-only", "resume-with-goal"]
|
|
6354
|
+
),
|
|
6355
|
+
/**
|
|
6356
|
+
* 重启后 pending 人工门控的处理策略:
|
|
6357
|
+
* - `invalidate-all`(默认):全部标记为 invalidated,Discord 消息置灰
|
|
6358
|
+
* - `resume-pending`:保留 pending,按剩余时间重建 5 分钟超时,用户可继续审批
|
|
6359
|
+
*/
|
|
6360
|
+
gateRestartPolicy: optionalEnum("GATE_RESTART_POLICY", "invalidate-all", [
|
|
6361
|
+
"invalidate-all",
|
|
6362
|
+
"resume-pending"
|
|
6363
|
+
])
|
|
6319
6364
|
};
|
|
6320
6365
|
if (config.anthropicApiKey) process.env.ANTHROPIC_API_KEY = config.anthropicApiKey;
|
|
6321
6366
|
if (config.anthropicBaseUrl) process.env.ANTHROPIC_BASE_URL = config.anthropicBaseUrl;
|
|
@@ -6339,10 +6384,10 @@ function resolvePath(p) {
|
|
|
6339
6384
|
return isAbsolute(p) ? p : resolve(process.cwd(), p);
|
|
6340
6385
|
}
|
|
6341
6386
|
function formatDuration(ms) {
|
|
6342
|
-
const
|
|
6343
|
-
if (
|
|
6344
|
-
const m = Math.floor(
|
|
6345
|
-
if (m < 60) return `${m}m ${
|
|
6387
|
+
const s2 = Math.floor(ms / 1e3);
|
|
6388
|
+
if (s2 < 60) return `${s2}s`;
|
|
6389
|
+
const m = Math.floor(s2 / 60);
|
|
6390
|
+
if (m < 60) return `${m}m ${s2 % 60}s`;
|
|
6346
6391
|
const h = Math.floor(m / 60);
|
|
6347
6392
|
return `${h}h ${m % 60}m`;
|
|
6348
6393
|
}
|
|
@@ -6353,9 +6398,9 @@ function formatRelative(ts) {
|
|
|
6353
6398
|
if (diff < 864e5) return `${Math.floor(diff / 36e5)}h ago`;
|
|
6354
6399
|
return `${Math.floor(diff / 864e5)}d ago`;
|
|
6355
6400
|
}
|
|
6356
|
-
function truncate(
|
|
6357
|
-
if (
|
|
6358
|
-
return
|
|
6401
|
+
function truncate(s2, max) {
|
|
6402
|
+
if (s2.length <= max) return s2;
|
|
6403
|
+
return s2.slice(0, max - 1) + "\u2026";
|
|
6359
6404
|
}
|
|
6360
6405
|
function isUserAllowed(userId, allowedUsers, allowAll) {
|
|
6361
6406
|
if (allowAll) return true;
|
|
@@ -6430,8 +6475,628 @@ var Store = class {
|
|
|
6430
6475
|
}
|
|
6431
6476
|
};
|
|
6432
6477
|
|
|
6478
|
+
// ../core/src/schema.ts
|
|
6479
|
+
function pushIssue(issues, path5, message) {
|
|
6480
|
+
issues.push({ path: path5, message });
|
|
6481
|
+
}
|
|
6482
|
+
var s = {
|
|
6483
|
+
string(options = {}) {
|
|
6484
|
+
return {
|
|
6485
|
+
parse(input, path5, issues) {
|
|
6486
|
+
if (input === void 0 || input === null) {
|
|
6487
|
+
if (options.optional) return options.default;
|
|
6488
|
+
pushIssue(issues, path5, "expected string, got " + describe(input));
|
|
6489
|
+
return options.default;
|
|
6490
|
+
}
|
|
6491
|
+
if (typeof input !== "string") {
|
|
6492
|
+
pushIssue(issues, path5, "expected string, got " + describe(input));
|
|
6493
|
+
return options.default;
|
|
6494
|
+
}
|
|
6495
|
+
return input;
|
|
6496
|
+
}
|
|
6497
|
+
};
|
|
6498
|
+
},
|
|
6499
|
+
number(options = {}) {
|
|
6500
|
+
return {
|
|
6501
|
+
parse(input, path5, issues) {
|
|
6502
|
+
if (input === void 0 || input === null) {
|
|
6503
|
+
if (options.optional) return options.default;
|
|
6504
|
+
pushIssue(issues, path5, "expected number, got " + describe(input));
|
|
6505
|
+
return options.default;
|
|
6506
|
+
}
|
|
6507
|
+
if (typeof input !== "number" || !Number.isFinite(input)) {
|
|
6508
|
+
pushIssue(issues, path5, "expected finite number, got " + describe(input));
|
|
6509
|
+
return options.default;
|
|
6510
|
+
}
|
|
6511
|
+
if (options.integer && !Number.isInteger(input)) {
|
|
6512
|
+
pushIssue(issues, path5, "expected integer, got " + input);
|
|
6513
|
+
return options.default;
|
|
6514
|
+
}
|
|
6515
|
+
return input;
|
|
6516
|
+
}
|
|
6517
|
+
};
|
|
6518
|
+
},
|
|
6519
|
+
boolean(options = {}) {
|
|
6520
|
+
return {
|
|
6521
|
+
parse(input, path5, issues) {
|
|
6522
|
+
if (input === void 0 || input === null) {
|
|
6523
|
+
if (options.optional) return options.default;
|
|
6524
|
+
pushIssue(issues, path5, "expected boolean, got " + describe(input));
|
|
6525
|
+
return options.default;
|
|
6526
|
+
}
|
|
6527
|
+
if (typeof input !== "boolean") {
|
|
6528
|
+
pushIssue(issues, path5, "expected boolean, got " + describe(input));
|
|
6529
|
+
return options.default;
|
|
6530
|
+
}
|
|
6531
|
+
return input;
|
|
6532
|
+
}
|
|
6533
|
+
};
|
|
6534
|
+
},
|
|
6535
|
+
literal(values, options = {}) {
|
|
6536
|
+
return {
|
|
6537
|
+
parse(input, path5, issues) {
|
|
6538
|
+
if (input === void 0 || input === null) {
|
|
6539
|
+
if (options.optional) return options.default;
|
|
6540
|
+
pushIssue(issues, path5, "expected one of [" + values.join(", ") + "], got " + describe(input));
|
|
6541
|
+
return options.default;
|
|
6542
|
+
}
|
|
6543
|
+
if (typeof input !== "string" || !values.includes(input)) {
|
|
6544
|
+
pushIssue(issues, path5, "expected one of [" + values.join(", ") + "], got " + describe(input));
|
|
6545
|
+
return options.default;
|
|
6546
|
+
}
|
|
6547
|
+
return input;
|
|
6548
|
+
}
|
|
6549
|
+
};
|
|
6550
|
+
},
|
|
6551
|
+
array(item, options = {}) {
|
|
6552
|
+
return {
|
|
6553
|
+
parse(input, path5, issues) {
|
|
6554
|
+
if (input === void 0 || input === null) {
|
|
6555
|
+
if (options.optional) return options.default;
|
|
6556
|
+
pushIssue(issues, path5, "expected array, got " + describe(input));
|
|
6557
|
+
return options.default ?? [];
|
|
6558
|
+
}
|
|
6559
|
+
if (!Array.isArray(input)) {
|
|
6560
|
+
pushIssue(issues, path5, "expected array, got " + describe(input));
|
|
6561
|
+
return options.default ?? [];
|
|
6562
|
+
}
|
|
6563
|
+
const out = [];
|
|
6564
|
+
for (let i = 0; i < input.length; i++) {
|
|
6565
|
+
const parsed = item.parse(input[i], `${path5}[${i}]`, issues);
|
|
6566
|
+
if (parsed !== void 0) out.push(parsed);
|
|
6567
|
+
}
|
|
6568
|
+
return out;
|
|
6569
|
+
}
|
|
6570
|
+
};
|
|
6571
|
+
},
|
|
6572
|
+
unknown() {
|
|
6573
|
+
return {
|
|
6574
|
+
parse(input) {
|
|
6575
|
+
return input;
|
|
6576
|
+
}
|
|
6577
|
+
};
|
|
6578
|
+
},
|
|
6579
|
+
record(value, options = {}) {
|
|
6580
|
+
return {
|
|
6581
|
+
parse(input, path5, issues) {
|
|
6582
|
+
if (input === void 0 || input === null) {
|
|
6583
|
+
if (options.optional) return void 0;
|
|
6584
|
+
pushIssue(issues, path5, "expected object, got " + describe(input));
|
|
6585
|
+
return void 0;
|
|
6586
|
+
}
|
|
6587
|
+
if (typeof input !== "object" || Array.isArray(input)) {
|
|
6588
|
+
pushIssue(issues, path5, "expected object, got " + describe(input));
|
|
6589
|
+
return void 0;
|
|
6590
|
+
}
|
|
6591
|
+
const out = {};
|
|
6592
|
+
for (const [key2, raw] of Object.entries(input)) {
|
|
6593
|
+
const parsed = value.parse(raw, `${path5}.${key2}`, issues);
|
|
6594
|
+
if (parsed !== void 0) out[key2] = parsed;
|
|
6595
|
+
}
|
|
6596
|
+
return out;
|
|
6597
|
+
}
|
|
6598
|
+
};
|
|
6599
|
+
}
|
|
6600
|
+
};
|
|
6601
|
+
function describe(v) {
|
|
6602
|
+
if (v === null) return "null";
|
|
6603
|
+
if (v === void 0) return "undefined";
|
|
6604
|
+
if (Array.isArray(v)) return "array";
|
|
6605
|
+
return typeof v;
|
|
6606
|
+
}
|
|
6607
|
+
function formatIssues(issues, limit = 5) {
|
|
6608
|
+
if (issues.length === 0) return "";
|
|
6609
|
+
const shown = issues.slice(0, limit).map((i) => ` - ${i.path}: ${i.message}`);
|
|
6610
|
+
const suffix = issues.length > limit ? `
|
|
6611
|
+
...and ${issues.length - limit} more` : "";
|
|
6612
|
+
return shown.join("\n") + suffix;
|
|
6613
|
+
}
|
|
6614
|
+
|
|
6615
|
+
// ../core/src/persistence-schema.ts
|
|
6616
|
+
var PROVIDER_NAMES = ["claude", "codex"];
|
|
6617
|
+
var SESSION_MODES = ["auto", "plan", "normal", "monitor"];
|
|
6618
|
+
var SESSION_TYPES = ["persistent", "subagent"];
|
|
6619
|
+
var CLAUDE_PERM = ["bypass", "normal"];
|
|
6620
|
+
var CODEX_SANDBOX = ["read-only", "workspace-write", "danger-full-access"];
|
|
6621
|
+
var CODEX_APPROVAL = ["never", "on-request", "on-failure", "untrusted"];
|
|
6622
|
+
var CODEX_WEB_SEARCH = ["disabled", "cached", "live"];
|
|
6623
|
+
var DISCOVERY_SOURCES = ["discord", "claude-hook", "codex-log", "sync"];
|
|
6624
|
+
var WORKFLOW_STATUSES = [
|
|
6625
|
+
"idle",
|
|
6626
|
+
"worker_running",
|
|
6627
|
+
"retrying",
|
|
6628
|
+
"monitor_review",
|
|
6629
|
+
"awaiting_human",
|
|
6630
|
+
"completed",
|
|
6631
|
+
"blocked",
|
|
6632
|
+
"error"
|
|
6633
|
+
];
|
|
6634
|
+
function isObject2(v) {
|
|
6635
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
6636
|
+
}
|
|
6637
|
+
function parseWorkflowState(raw, path5, issues) {
|
|
6638
|
+
const defaults = {
|
|
6639
|
+
status: "idle",
|
|
6640
|
+
iteration: 0,
|
|
6641
|
+
updatedAt: Date.now()
|
|
6642
|
+
};
|
|
6643
|
+
if (!isObject2(raw)) {
|
|
6644
|
+
return defaults;
|
|
6645
|
+
}
|
|
6646
|
+
const status = s.literal(WORKFLOW_STATUSES, { default: "idle" }).parse(
|
|
6647
|
+
raw.status,
|
|
6648
|
+
`${path5}.status`,
|
|
6649
|
+
issues
|
|
6650
|
+
);
|
|
6651
|
+
const iteration = s.number({ integer: true, default: 0 }).parse(
|
|
6652
|
+
raw.iteration,
|
|
6653
|
+
`${path5}.iteration`,
|
|
6654
|
+
issues
|
|
6655
|
+
);
|
|
6656
|
+
const updatedAt = s.number({ default: Date.now() }).parse(
|
|
6657
|
+
raw.updatedAt,
|
|
6658
|
+
`${path5}.updatedAt`,
|
|
6659
|
+
issues
|
|
6660
|
+
);
|
|
6661
|
+
const workflow = { status, iteration, updatedAt };
|
|
6662
|
+
if (typeof raw.lastHook === "string") workflow.lastHook = raw.lastHook;
|
|
6663
|
+
if (typeof raw.lastWorkerSummary === "string") workflow.lastWorkerSummary = raw.lastWorkerSummary;
|
|
6664
|
+
if (typeof raw.lastMonitorRationale === "string") workflow.lastMonitorRationale = raw.lastMonitorRationale;
|
|
6665
|
+
if (typeof raw.awaitingHumanReason === "string") workflow.awaitingHumanReason = raw.awaitingHumanReason;
|
|
6666
|
+
if (isObject2(raw.lastWorkerReport)) {
|
|
6667
|
+
workflow.lastWorkerReport = raw.lastWorkerReport;
|
|
6668
|
+
}
|
|
6669
|
+
if (isObject2(raw.lastMonitorDecision)) {
|
|
6670
|
+
workflow.lastMonitorDecision = raw.lastMonitorDecision;
|
|
6671
|
+
}
|
|
6672
|
+
if (isObject2(raw.nextProofContract)) {
|
|
6673
|
+
workflow.nextProofContract = raw.nextProofContract;
|
|
6674
|
+
}
|
|
6675
|
+
return workflow;
|
|
6676
|
+
}
|
|
6677
|
+
function parseSessionPersistData(raw, index, issues) {
|
|
6678
|
+
if (!isObject2(raw)) {
|
|
6679
|
+
issues.push({ path: `sessions[${index}]`, message: "expected object, got " + typeof raw });
|
|
6680
|
+
return void 0;
|
|
6681
|
+
}
|
|
6682
|
+
const path5 = `sessions[${index}]`;
|
|
6683
|
+
const id = s.string().parse(raw.id, `${path5}.id`, issues);
|
|
6684
|
+
const channelId = s.string().parse(raw.channelId, `${path5}.channelId`, issues);
|
|
6685
|
+
const categoryId = s.string().parse(raw.categoryId, `${path5}.categoryId`, issues);
|
|
6686
|
+
const projectName = s.string().parse(raw.projectName, `${path5}.projectName`, issues);
|
|
6687
|
+
const agentLabel = s.string().parse(raw.agentLabel, `${path5}.agentLabel`, issues);
|
|
6688
|
+
const directory = s.string().parse(raw.directory, `${path5}.directory`, issues);
|
|
6689
|
+
if (!id || !channelId || !categoryId || !projectName || !agentLabel || !directory) {
|
|
6690
|
+
return void 0;
|
|
6691
|
+
}
|
|
6692
|
+
const provider = s.literal(PROVIDER_NAMES, { default: "claude" }).parse(
|
|
6693
|
+
raw.provider,
|
|
6694
|
+
`${path5}.provider`,
|
|
6695
|
+
issues
|
|
6696
|
+
);
|
|
6697
|
+
const mode = s.literal(SESSION_MODES, { default: "auto" }).parse(
|
|
6698
|
+
raw.mode,
|
|
6699
|
+
`${path5}.mode`,
|
|
6700
|
+
issues
|
|
6701
|
+
);
|
|
6702
|
+
const type = s.literal(SESSION_TYPES, { default: "persistent" }).parse(
|
|
6703
|
+
raw.type,
|
|
6704
|
+
`${path5}.type`,
|
|
6705
|
+
issues
|
|
6706
|
+
);
|
|
6707
|
+
const now = Date.now();
|
|
6708
|
+
const session = {
|
|
6709
|
+
id,
|
|
6710
|
+
channelId,
|
|
6711
|
+
categoryId,
|
|
6712
|
+
projectName,
|
|
6713
|
+
agentLabel,
|
|
6714
|
+
provider,
|
|
6715
|
+
type,
|
|
6716
|
+
mode,
|
|
6717
|
+
directory,
|
|
6718
|
+
subagentDepth: s.number({ integer: true, default: 0 }).parse(raw.subagentDepth, `${path5}.subagentDepth`, issues),
|
|
6719
|
+
verbose: s.boolean({ default: false }).parse(raw.verbose, `${path5}.verbose`, issues),
|
|
6720
|
+
workflowState: parseWorkflowState(raw.workflowState, `${path5}.workflowState`, issues),
|
|
6721
|
+
createdAt: s.number({ default: now }).parse(raw.createdAt, `${path5}.createdAt`, issues),
|
|
6722
|
+
lastActivity: s.number({ default: now }).parse(raw.lastActivity, `${path5}.lastActivity`, issues),
|
|
6723
|
+
messageCount: s.number({ integer: true, default: 0 }).parse(raw.messageCount, `${path5}.messageCount`, issues),
|
|
6724
|
+
totalCost: s.number({ default: 0 }).parse(raw.totalCost, `${path5}.totalCost`, issues),
|
|
6725
|
+
currentTurn: s.number({ integer: true, default: 0 }).parse(raw.currentTurn, `${path5}.currentTurn`, issues),
|
|
6726
|
+
humanResolved: s.boolean({ default: false }).parse(raw.humanResolved, `${path5}.humanResolved`, issues)
|
|
6727
|
+
};
|
|
6728
|
+
if (typeof raw.providerSessionId === "string") session.providerSessionId = raw.providerSessionId;
|
|
6729
|
+
if (typeof raw.model === "string") session.model = raw.model;
|
|
6730
|
+
if (typeof raw.parentChannelId === "string") session.parentChannelId = raw.parentChannelId;
|
|
6731
|
+
if (typeof raw.agentPersona === "string") session.agentPersona = raw.agentPersona;
|
|
6732
|
+
if (typeof raw.monitorGoal === "string") session.monitorGoal = raw.monitorGoal;
|
|
6733
|
+
if (typeof raw.monitorProviderSessionId === "string") session.monitorProviderSessionId = raw.monitorProviderSessionId;
|
|
6734
|
+
if (typeof raw.currentInteractionMessageId === "string") session.currentInteractionMessageId = raw.currentInteractionMessageId;
|
|
6735
|
+
if (typeof raw.statusCardMessageId === "string") session.statusCardMessageId = raw.statusCardMessageId;
|
|
6736
|
+
if (typeof raw.lastInboundMessageId === "string") session.lastInboundMessageId = raw.lastInboundMessageId;
|
|
6737
|
+
if (typeof raw.lastObservedState === "string") session.lastObservedState = raw.lastObservedState;
|
|
6738
|
+
if (typeof raw.lastObservedEventKey === "string") session.lastObservedEventKey = raw.lastObservedEventKey;
|
|
6739
|
+
if (typeof raw.lastObservedAt === "number") session.lastObservedAt = raw.lastObservedAt;
|
|
6740
|
+
if (typeof raw.lastObservedCwd === "string") session.lastObservedCwd = raw.lastObservedCwd;
|
|
6741
|
+
if (typeof raw.activeHumanGateId === "string") session.activeHumanGateId = raw.activeHumanGateId;
|
|
6742
|
+
if (typeof raw.remoteHumanControl === "boolean") session.remoteHumanControl = raw.remoteHumanControl;
|
|
6743
|
+
if (typeof raw.claudePermissionMode === "string" && CLAUDE_PERM.includes(raw.claudePermissionMode)) {
|
|
6744
|
+
session.claudePermissionMode = raw.claudePermissionMode;
|
|
6745
|
+
}
|
|
6746
|
+
if (typeof raw.codexSandboxMode === "string" && CODEX_SANDBOX.includes(raw.codexSandboxMode)) {
|
|
6747
|
+
session.codexSandboxMode = raw.codexSandboxMode;
|
|
6748
|
+
}
|
|
6749
|
+
if (typeof raw.codexApprovalPolicy === "string" && CODEX_APPROVAL.includes(raw.codexApprovalPolicy)) {
|
|
6750
|
+
session.codexApprovalPolicy = raw.codexApprovalPolicy;
|
|
6751
|
+
}
|
|
6752
|
+
if (typeof raw.codexBypass === "boolean") session.codexBypass = raw.codexBypass;
|
|
6753
|
+
if (typeof raw.codexNetworkAccessEnabled === "boolean") session.codexNetworkAccessEnabled = raw.codexNetworkAccessEnabled;
|
|
6754
|
+
if (typeof raw.codexWebSearchMode === "string" && CODEX_WEB_SEARCH.includes(raw.codexWebSearchMode)) {
|
|
6755
|
+
session.codexWebSearchMode = raw.codexWebSearchMode;
|
|
6756
|
+
}
|
|
6757
|
+
if (typeof raw.discoverySource === "string" && DISCOVERY_SOURCES.includes(raw.discoverySource)) {
|
|
6758
|
+
session.discoverySource = raw.discoverySource;
|
|
6759
|
+
}
|
|
6760
|
+
return session;
|
|
6761
|
+
}
|
|
6762
|
+
function parseMcpServer(raw) {
|
|
6763
|
+
if (!isObject2(raw)) return void 0;
|
|
6764
|
+
if (typeof raw.name !== "string" || typeof raw.command !== "string") return void 0;
|
|
6765
|
+
const server = { name: raw.name, command: raw.command };
|
|
6766
|
+
if (Array.isArray(raw.args)) {
|
|
6767
|
+
server.args = raw.args.filter((a) => typeof a === "string");
|
|
6768
|
+
}
|
|
6769
|
+
return server;
|
|
6770
|
+
}
|
|
6771
|
+
function parseRegisteredProject(raw, index, issues) {
|
|
6772
|
+
if (!isObject2(raw)) {
|
|
6773
|
+
issues.push({ path: `projects[${index}]`, message: "expected object, got " + typeof raw });
|
|
6774
|
+
return void 0;
|
|
6775
|
+
}
|
|
6776
|
+
const path5 = `projects[${index}]`;
|
|
6777
|
+
const id = s.string().parse(raw.id, `${path5}.id`, issues);
|
|
6778
|
+
const name = s.string().parse(raw.name, `${path5}.name`, issues);
|
|
6779
|
+
const projectPath = s.string().parse(raw.path, `${path5}.path`, issues);
|
|
6780
|
+
if (!id || !name || !projectPath) return void 0;
|
|
6781
|
+
const now = Date.now();
|
|
6782
|
+
const project = {
|
|
6783
|
+
id,
|
|
6784
|
+
name,
|
|
6785
|
+
path: projectPath,
|
|
6786
|
+
skills: {},
|
|
6787
|
+
mcpServers: [],
|
|
6788
|
+
createdAt: s.number({ default: now }).parse(raw.createdAt, `${path5}.createdAt`, issues),
|
|
6789
|
+
updatedAt: s.number({ default: now }).parse(raw.updatedAt, `${path5}.updatedAt`, issues)
|
|
6790
|
+
};
|
|
6791
|
+
if (isObject2(raw.skills)) {
|
|
6792
|
+
for (const [key2, value] of Object.entries(raw.skills)) {
|
|
6793
|
+
if (typeof value === "string") project.skills[key2] = value;
|
|
6794
|
+
}
|
|
6795
|
+
}
|
|
6796
|
+
if (Array.isArray(raw.mcpServers)) {
|
|
6797
|
+
for (const item of raw.mcpServers) {
|
|
6798
|
+
const parsed = parseMcpServer(item);
|
|
6799
|
+
if (parsed) project.mcpServers.push(parsed);
|
|
6800
|
+
}
|
|
6801
|
+
}
|
|
6802
|
+
if (typeof raw.discordCategoryId === "string") project.discordCategoryId = raw.discordCategoryId;
|
|
6803
|
+
if (typeof raw.discordCategoryName === "string") project.discordCategoryName = raw.discordCategoryName;
|
|
6804
|
+
if (typeof raw.historyChannelId === "string") project.historyChannelId = raw.historyChannelId;
|
|
6805
|
+
if (typeof raw.controlChannelId === "string") project.controlChannelId = raw.controlChannelId;
|
|
6806
|
+
if (typeof raw.personality === "string") project.personality = raw.personality;
|
|
6807
|
+
return project;
|
|
6808
|
+
}
|
|
6809
|
+
|
|
6810
|
+
// ../core/src/repository/json-repo.ts
|
|
6811
|
+
var DEFAULT_DEBOUNCE_MS = 1e3;
|
|
6812
|
+
var NULL_INDEX_KEY = "__json_repo_null__";
|
|
6813
|
+
function indexKey(value) {
|
|
6814
|
+
if (value === void 0 || value === null) return NULL_INDEX_KEY;
|
|
6815
|
+
if (typeof value === "string") return `s:${value}`;
|
|
6816
|
+
if (typeof value === "number") return `n:${value}`;
|
|
6817
|
+
if (typeof value === "boolean") return `b:${value ? 1 : 0}`;
|
|
6818
|
+
return `o:${String(value)}`;
|
|
6819
|
+
}
|
|
6820
|
+
var JsonFileRepository = class {
|
|
6821
|
+
store;
|
|
6822
|
+
idField;
|
|
6823
|
+
indexes;
|
|
6824
|
+
parse;
|
|
6825
|
+
serialize;
|
|
6826
|
+
debounceMs;
|
|
6827
|
+
entries = /* @__PURE__ */ new Map();
|
|
6828
|
+
/** 索引字段 → 索引值 key → 持有该值的主键集合 */
|
|
6829
|
+
indexMaps = /* @__PURE__ */ new Map();
|
|
6830
|
+
saveTimer = null;
|
|
6831
|
+
writeChain = Promise.resolve();
|
|
6832
|
+
dirty = false;
|
|
6833
|
+
constructor(options) {
|
|
6834
|
+
this.store = new Store(options.filename);
|
|
6835
|
+
this.idField = options.idField;
|
|
6836
|
+
this.indexes = options.indexes ?? [];
|
|
6837
|
+
this.parse = options.parse;
|
|
6838
|
+
this.serialize = options.serialize;
|
|
6839
|
+
this.debounceMs = options.debounceMs ?? DEFAULT_DEBOUNCE_MS;
|
|
6840
|
+
for (const idx of this.indexes) this.indexMaps.set(idx.field, /* @__PURE__ */ new Map());
|
|
6841
|
+
}
|
|
6842
|
+
async init() {
|
|
6843
|
+
const raw = await this.store.read();
|
|
6844
|
+
if (!Array.isArray(raw)) return;
|
|
6845
|
+
for (let i = 0; i < raw.length; i++) {
|
|
6846
|
+
const parsed = this.parse ? this.parse(raw[i], i) : raw[i];
|
|
6847
|
+
if (!parsed) continue;
|
|
6848
|
+
const id = parsed[this.idField];
|
|
6849
|
+
if (typeof id !== "string") continue;
|
|
6850
|
+
this.entries.set(id, parsed);
|
|
6851
|
+
this.addToIndexes(id, parsed);
|
|
6852
|
+
}
|
|
6853
|
+
}
|
|
6854
|
+
get(id) {
|
|
6855
|
+
return this.entries.get(id);
|
|
6856
|
+
}
|
|
6857
|
+
find(options = {}) {
|
|
6858
|
+
let candidates;
|
|
6859
|
+
if (options.where) {
|
|
6860
|
+
const whereEntries = Object.entries(options.where);
|
|
6861
|
+
const indexedEntry = whereEntries.find(
|
|
6862
|
+
([field]) => this.indexMaps.has(field)
|
|
6863
|
+
);
|
|
6864
|
+
if (indexedEntry) {
|
|
6865
|
+
const [field, value] = indexedEntry;
|
|
6866
|
+
const idSet = this.indexMaps.get(field)?.get(indexKey(value));
|
|
6867
|
+
if (!idSet || idSet.size === 0) return [];
|
|
6868
|
+
const seed = [];
|
|
6869
|
+
for (const id of idSet) {
|
|
6870
|
+
const entity = this.entries.get(id);
|
|
6871
|
+
if (entity) seed.push(entity);
|
|
6872
|
+
}
|
|
6873
|
+
candidates = seed;
|
|
6874
|
+
} else {
|
|
6875
|
+
candidates = this.entries.values();
|
|
6876
|
+
}
|
|
6877
|
+
let result2 = Array.from(candidates).filter(
|
|
6878
|
+
(item) => whereEntries.every(([key2, value]) => item[key2] === value)
|
|
6879
|
+
);
|
|
6880
|
+
if (options.sort) result2.sort(options.sort);
|
|
6881
|
+
if (options.limit !== void 0) result2 = result2.slice(0, options.limit);
|
|
6882
|
+
return result2;
|
|
6883
|
+
}
|
|
6884
|
+
let result = Array.from(this.entries.values());
|
|
6885
|
+
if (options.sort) result.sort(options.sort);
|
|
6886
|
+
if (options.limit !== void 0) result = result.slice(0, options.limit);
|
|
6887
|
+
return result;
|
|
6888
|
+
}
|
|
6889
|
+
getAll() {
|
|
6890
|
+
return Array.from(this.entries.values());
|
|
6891
|
+
}
|
|
6892
|
+
size() {
|
|
6893
|
+
return this.entries.size;
|
|
6894
|
+
}
|
|
6895
|
+
async save(entity) {
|
|
6896
|
+
const id = entity[this.idField];
|
|
6897
|
+
if (typeof id !== "string") {
|
|
6898
|
+
throw new Error(`Repository.save: id field "${this.idField}" missing or non-string`);
|
|
6899
|
+
}
|
|
6900
|
+
const existing = this.entries.get(id);
|
|
6901
|
+
if (existing && existing !== entity) {
|
|
6902
|
+
this.removeFromIndexes(id, existing);
|
|
6903
|
+
} else if (existing) {
|
|
6904
|
+
this.removeFromIndexes(id, existing);
|
|
6905
|
+
}
|
|
6906
|
+
this.entries.set(id, entity);
|
|
6907
|
+
this.addToIndexes(id, entity);
|
|
6908
|
+
this.scheduleWrite();
|
|
6909
|
+
}
|
|
6910
|
+
async saveMany(entities) {
|
|
6911
|
+
for (const entity of entities) {
|
|
6912
|
+
const id = entity[this.idField];
|
|
6913
|
+
if (typeof id !== "string") continue;
|
|
6914
|
+
const existing = this.entries.get(id);
|
|
6915
|
+
if (existing) this.removeFromIndexes(id, existing);
|
|
6916
|
+
this.entries.set(id, entity);
|
|
6917
|
+
this.addToIndexes(id, entity);
|
|
6918
|
+
}
|
|
6919
|
+
this.scheduleWrite();
|
|
6920
|
+
}
|
|
6921
|
+
async update(id, patch) {
|
|
6922
|
+
const current = this.entries.get(id);
|
|
6923
|
+
if (!current) return void 0;
|
|
6924
|
+
this.removeFromIndexes(id, current);
|
|
6925
|
+
const next = { ...current, ...patch };
|
|
6926
|
+
this.entries.set(id, next);
|
|
6927
|
+
this.addToIndexes(id, next);
|
|
6928
|
+
this.scheduleWrite();
|
|
6929
|
+
return next;
|
|
6930
|
+
}
|
|
6931
|
+
async delete(id) {
|
|
6932
|
+
const existing = this.entries.get(id);
|
|
6933
|
+
if (!existing) return false;
|
|
6934
|
+
this.removeFromIndexes(id, existing);
|
|
6935
|
+
this.entries.delete(id);
|
|
6936
|
+
this.scheduleWrite();
|
|
6937
|
+
return true;
|
|
6938
|
+
}
|
|
6939
|
+
async clear() {
|
|
6940
|
+
this.entries.clear();
|
|
6941
|
+
for (const map of this.indexMaps.values()) map.clear();
|
|
6942
|
+
this.scheduleWrite();
|
|
6943
|
+
}
|
|
6944
|
+
async flush() {
|
|
6945
|
+
if (this.saveTimer) {
|
|
6946
|
+
clearTimeout(this.saveTimer);
|
|
6947
|
+
this.saveTimer = null;
|
|
6948
|
+
}
|
|
6949
|
+
if (this.dirty) {
|
|
6950
|
+
this.writeChain = this.writeChain.catch(() => {
|
|
6951
|
+
}).then(() => this.writeNow());
|
|
6952
|
+
}
|
|
6953
|
+
await this.writeChain;
|
|
6954
|
+
}
|
|
6955
|
+
/**
|
|
6956
|
+
* 调用方在直接 mutate entity 字段后,显式触发一次索引重建 + 持久化调度。
|
|
6957
|
+
* 典型场景:session 对象被多处代码引用,就地改 providerSessionId 后需要重建二级索引。
|
|
6958
|
+
*/
|
|
6959
|
+
reindex(id) {
|
|
6960
|
+
const entity = this.entries.get(id);
|
|
6961
|
+
if (!entity) return;
|
|
6962
|
+
this.removeFromIndexes(id, entity);
|
|
6963
|
+
this.addToIndexes(id, entity);
|
|
6964
|
+
this.scheduleWrite();
|
|
6965
|
+
}
|
|
6966
|
+
// ─── Index maintenance ────────────────────────────────────────────────────
|
|
6967
|
+
addToIndexes(id, entity) {
|
|
6968
|
+
for (const idx of this.indexes) {
|
|
6969
|
+
const raw = idx.extract ? idx.extract(entity) : entity[idx.field];
|
|
6970
|
+
const key2 = indexKey(raw);
|
|
6971
|
+
const map = this.indexMaps.get(idx.field);
|
|
6972
|
+
if (!map) continue;
|
|
6973
|
+
let set = map.get(key2);
|
|
6974
|
+
if (!set) {
|
|
6975
|
+
set = /* @__PURE__ */ new Set();
|
|
6976
|
+
map.set(key2, set);
|
|
6977
|
+
}
|
|
6978
|
+
set.add(id);
|
|
6979
|
+
}
|
|
6980
|
+
}
|
|
6981
|
+
removeFromIndexes(id, entity) {
|
|
6982
|
+
for (const idx of this.indexes) {
|
|
6983
|
+
const raw = idx.extract ? idx.extract(entity) : entity[idx.field];
|
|
6984
|
+
const key2 = indexKey(raw);
|
|
6985
|
+
const map = this.indexMaps.get(idx.field);
|
|
6986
|
+
if (!map) continue;
|
|
6987
|
+
const set = map.get(key2);
|
|
6988
|
+
if (!set) continue;
|
|
6989
|
+
set.delete(id);
|
|
6990
|
+
if (set.size === 0) map.delete(key2);
|
|
6991
|
+
}
|
|
6992
|
+
}
|
|
6993
|
+
// ─── Internals ────────────────────────────────────────────────────────────
|
|
6994
|
+
scheduleWrite() {
|
|
6995
|
+
this.dirty = true;
|
|
6996
|
+
if (this.debounceMs === 0) {
|
|
6997
|
+
this.writeChain = this.writeChain.catch(() => {
|
|
6998
|
+
}).then(() => this.writeNow());
|
|
6999
|
+
return;
|
|
7000
|
+
}
|
|
7001
|
+
if (this.saveTimer) return;
|
|
7002
|
+
this.saveTimer = setTimeout(() => {
|
|
7003
|
+
this.saveTimer = null;
|
|
7004
|
+
if (!this.dirty) return;
|
|
7005
|
+
this.writeChain = this.writeChain.catch(() => {
|
|
7006
|
+
}).then(() => this.writeNow());
|
|
7007
|
+
}, this.debounceMs);
|
|
7008
|
+
this.saveTimer.unref?.();
|
|
7009
|
+
}
|
|
7010
|
+
async writeNow() {
|
|
7011
|
+
this.dirty = false;
|
|
7012
|
+
const snapshot = [];
|
|
7013
|
+
for (const entity of this.entries.values()) {
|
|
7014
|
+
snapshot.push(this.serialize ? this.serialize(entity) : entity);
|
|
7015
|
+
}
|
|
7016
|
+
try {
|
|
7017
|
+
await this.store.write(snapshot);
|
|
7018
|
+
} catch (err) {
|
|
7019
|
+
console.error(`[JsonFileRepository] write failed: ${err.message}`);
|
|
7020
|
+
}
|
|
7021
|
+
}
|
|
7022
|
+
};
|
|
7023
|
+
|
|
7024
|
+
// ../core/src/repository/sqlite-repo.ts
|
|
7025
|
+
import { existsSync as existsSync3 } from "fs";
|
|
7026
|
+
import { mkdirSync } from "fs";
|
|
7027
|
+
import { dirname as dirname2, join as join4 } from "path";
|
|
7028
|
+
|
|
6433
7029
|
// ../core/src/event-bus.ts
|
|
6434
7030
|
import { EventEmitter } from "events";
|
|
7031
|
+
function key(eventType) {
|
|
7032
|
+
return eventType;
|
|
7033
|
+
}
|
|
7034
|
+
var EventBus = class extends EventEmitter {
|
|
7035
|
+
#middleware = [];
|
|
7036
|
+
constructor() {
|
|
7037
|
+
super({ captureRejections: false });
|
|
7038
|
+
this.setMaxListeners(Infinity);
|
|
7039
|
+
}
|
|
7040
|
+
/**
|
|
7041
|
+
* Emit an event. Automatically generates traceId, timestamp, and source.
|
|
7042
|
+
* Middleware runs before any handlers. Middleware errors are logged but
|
|
7043
|
+
* do not stop propagation.
|
|
7044
|
+
*/
|
|
7045
|
+
emit(eventType, payload, source = "unknown") {
|
|
7046
|
+
const event = {
|
|
7047
|
+
type: key(eventType),
|
|
7048
|
+
payload,
|
|
7049
|
+
traceId: crypto.randomUUID(),
|
|
7050
|
+
timestamp: Date.now(),
|
|
7051
|
+
source
|
|
7052
|
+
};
|
|
7053
|
+
const middlewarePromises = this.#middleware.map(async (fn) => {
|
|
7054
|
+
try {
|
|
7055
|
+
await fn(event);
|
|
7056
|
+
} catch (err) {
|
|
7057
|
+
console.error("[EventBus] middleware error:", err);
|
|
7058
|
+
}
|
|
7059
|
+
});
|
|
7060
|
+
void Promise.allSettled(middlewarePromises);
|
|
7061
|
+
return super.emit(key(eventType), event);
|
|
7062
|
+
}
|
|
7063
|
+
/** Register a handler for the given event type. */
|
|
7064
|
+
on(eventType, handler) {
|
|
7065
|
+
return super.on(key(eventType), handler);
|
|
7066
|
+
}
|
|
7067
|
+
/** Register a one-shot handler for the given event type. */
|
|
7068
|
+
once(eventType, handler) {
|
|
7069
|
+
return super.once(key(eventType), handler);
|
|
7070
|
+
}
|
|
7071
|
+
/** Remove a previously registered handler. */
|
|
7072
|
+
off(eventType, handler) {
|
|
7073
|
+
return super.off(key(eventType), handler);
|
|
7074
|
+
}
|
|
7075
|
+
/**
|
|
7076
|
+
* Register middleware that runs before every handler.
|
|
7077
|
+
* Middleware receives the raw AppEvent and can mutate it.
|
|
7078
|
+
* Errors are caught and logged — they do not stop propagation.
|
|
7079
|
+
*/
|
|
7080
|
+
middleware(fn) {
|
|
7081
|
+
this.#middleware.push(fn);
|
|
7082
|
+
}
|
|
7083
|
+
};
|
|
7084
|
+
|
|
7085
|
+
// ../core/src/domain-events.ts
|
|
7086
|
+
var SessionErrored = "session.errored";
|
|
7087
|
+
var SessionAwaitingHuman = "session.awaiting_human";
|
|
7088
|
+
var SessionCreated = "session.created";
|
|
7089
|
+
var SessionEnded = "session.ended";
|
|
7090
|
+
var SessionModeChanged = "session.mode_changed";
|
|
7091
|
+
var MonitorRunStarted = "monitor.run.started";
|
|
7092
|
+
var MonitorRunEnded = "monitor.run.ended";
|
|
7093
|
+
var GateCreated = "gate.created";
|
|
7094
|
+
var GateResolved = "gate.resolved";
|
|
7095
|
+
var _domainBus = null;
|
|
7096
|
+
function getDomainBus() {
|
|
7097
|
+
if (!_domainBus) _domainBus = new EventBus();
|
|
7098
|
+
return _domainBus;
|
|
7099
|
+
}
|
|
6435
7100
|
|
|
6436
7101
|
// ../core/src/logger.ts
|
|
6437
7102
|
var import_pino = __toESM(require_pino(), 1);
|
|
@@ -6444,7 +7109,7 @@ var ServiceBus = class {
|
|
|
6444
7109
|
#services = [];
|
|
6445
7110
|
#started = /* @__PURE__ */ new Set();
|
|
6446
7111
|
register(service) {
|
|
6447
|
-
if (this.#services.some((
|
|
7112
|
+
if (this.#services.some((s2) => s2.name === service.name)) {
|
|
6448
7113
|
throw new Error(`Service "${service.name}" is already registered`);
|
|
6449
7114
|
}
|
|
6450
7115
|
this.#services.push(service);
|
|
@@ -6523,6 +7188,20 @@ export {
|
|
|
6523
7188
|
formatUptime,
|
|
6524
7189
|
getDataDir,
|
|
6525
7190
|
Store,
|
|
7191
|
+
formatIssues,
|
|
7192
|
+
parseSessionPersistData,
|
|
7193
|
+
parseRegisteredProject,
|
|
7194
|
+
JsonFileRepository,
|
|
7195
|
+
SessionErrored,
|
|
7196
|
+
SessionAwaitingHuman,
|
|
7197
|
+
SessionCreated,
|
|
7198
|
+
SessionEnded,
|
|
7199
|
+
SessionModeChanged,
|
|
7200
|
+
MonitorRunStarted,
|
|
7201
|
+
MonitorRunEnded,
|
|
7202
|
+
GateCreated,
|
|
7203
|
+
GateResolved,
|
|
7204
|
+
getDomainBus,
|
|
6526
7205
|
ServiceBus,
|
|
6527
7206
|
intervalService
|
|
6528
7207
|
};
|