@bonginkan/maria 3.6.1 → 3.6.2
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/bin/maria.cjs +316 -896
- package/dist/bin/maria.cjs.map +1 -1
- package/dist/cli.cjs +222 -860
- package/dist/cli.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/maria.cjs
CHANGED
|
@@ -42,7 +42,7 @@ function getVersion() {
|
|
|
42
42
|
const packageJson2 = getPackageJson();
|
|
43
43
|
_cachedVersion = packageJson2.version;
|
|
44
44
|
return _cachedVersion;
|
|
45
|
-
} catch (
|
|
45
|
+
} catch (error) {
|
|
46
46
|
_cachedVersion = "latest";
|
|
47
47
|
return _cachedVersion;
|
|
48
48
|
}
|
|
@@ -100,8 +100,8 @@ function getPackageJson() {
|
|
|
100
100
|
const packageJsonContent = (0, import_fs.readFileSync)(packageJsonPath, "utf-8");
|
|
101
101
|
_cachedPackageJson = JSON.parse(packageJsonContent);
|
|
102
102
|
return _cachedPackageJson;
|
|
103
|
-
} catch (
|
|
104
|
-
throw new Error(`Failed to read package.json: ${
|
|
103
|
+
} catch (error) {
|
|
104
|
+
throw new Error(`Failed to read package.json: ${error}`);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
var import_fs, import_path, _cachedVersion, _cachedPackageJson, VERSION;
|
|
@@ -2376,10 +2376,10 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
2376
2376
|
});
|
|
2377
2377
|
return promise;
|
|
2378
2378
|
}
|
|
2379
|
-
function WritableStreamDealWithRejection(stream,
|
|
2379
|
+
function WritableStreamDealWithRejection(stream, error) {
|
|
2380
2380
|
const state = stream._state;
|
|
2381
2381
|
if (state === "writable") {
|
|
2382
|
-
WritableStreamStartErroring(stream,
|
|
2382
|
+
WritableStreamStartErroring(stream, error);
|
|
2383
2383
|
return;
|
|
2384
2384
|
}
|
|
2385
2385
|
WritableStreamFinishErroring(stream);
|
|
@@ -2430,10 +2430,10 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
2430
2430
|
stream._inFlightWriteRequest._resolve(void 0);
|
|
2431
2431
|
stream._inFlightWriteRequest = void 0;
|
|
2432
2432
|
}
|
|
2433
|
-
function WritableStreamFinishInFlightWriteWithError(stream,
|
|
2434
|
-
stream._inFlightWriteRequest._reject(
|
|
2433
|
+
function WritableStreamFinishInFlightWriteWithError(stream, error) {
|
|
2434
|
+
stream._inFlightWriteRequest._reject(error);
|
|
2435
2435
|
stream._inFlightWriteRequest = void 0;
|
|
2436
|
-
WritableStreamDealWithRejection(stream,
|
|
2436
|
+
WritableStreamDealWithRejection(stream, error);
|
|
2437
2437
|
}
|
|
2438
2438
|
function WritableStreamFinishInFlightClose(stream) {
|
|
2439
2439
|
stream._inFlightCloseRequest._resolve(void 0);
|
|
@@ -2452,14 +2452,14 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
2452
2452
|
defaultWriterClosedPromiseResolve(writer);
|
|
2453
2453
|
}
|
|
2454
2454
|
}
|
|
2455
|
-
function WritableStreamFinishInFlightCloseWithError(stream,
|
|
2456
|
-
stream._inFlightCloseRequest._reject(
|
|
2455
|
+
function WritableStreamFinishInFlightCloseWithError(stream, error) {
|
|
2456
|
+
stream._inFlightCloseRequest._reject(error);
|
|
2457
2457
|
stream._inFlightCloseRequest = void 0;
|
|
2458
2458
|
if (stream._pendingAbortRequest !== void 0) {
|
|
2459
|
-
stream._pendingAbortRequest._reject(
|
|
2459
|
+
stream._pendingAbortRequest._reject(error);
|
|
2460
2460
|
stream._pendingAbortRequest = void 0;
|
|
2461
2461
|
}
|
|
2462
|
-
WritableStreamDealWithRejection(stream,
|
|
2462
|
+
WritableStreamDealWithRejection(stream, error);
|
|
2463
2463
|
}
|
|
2464
2464
|
function WritableStreamCloseQueuedOrInFlight(stream) {
|
|
2465
2465
|
if (stream._closeRequest === void 0 && stream._inFlightCloseRequest === void 0) {
|
|
@@ -2676,18 +2676,18 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
2676
2676
|
}
|
|
2677
2677
|
return WritableStreamDefaultWriterClose(writer);
|
|
2678
2678
|
}
|
|
2679
|
-
function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer,
|
|
2679
|
+
function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error) {
|
|
2680
2680
|
if (writer._closedPromiseState === "pending") {
|
|
2681
|
-
defaultWriterClosedPromiseReject(writer,
|
|
2681
|
+
defaultWriterClosedPromiseReject(writer, error);
|
|
2682
2682
|
} else {
|
|
2683
|
-
defaultWriterClosedPromiseResetToRejected(writer,
|
|
2683
|
+
defaultWriterClosedPromiseResetToRejected(writer, error);
|
|
2684
2684
|
}
|
|
2685
2685
|
}
|
|
2686
|
-
function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer,
|
|
2686
|
+
function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error) {
|
|
2687
2687
|
if (writer._readyPromiseState === "pending") {
|
|
2688
|
-
defaultWriterReadyPromiseReject(writer,
|
|
2688
|
+
defaultWriterReadyPromiseReject(writer, error);
|
|
2689
2689
|
} else {
|
|
2690
|
-
defaultWriterReadyPromiseResetToRejected(writer,
|
|
2690
|
+
defaultWriterReadyPromiseResetToRejected(writer, error);
|
|
2691
2691
|
}
|
|
2692
2692
|
}
|
|
2693
2693
|
function WritableStreamDefaultWriterGetDesiredSize(writer) {
|
|
@@ -2922,9 +2922,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
2922
2922
|
WritableStreamDefaultControllerProcessWrite(controller, value);
|
|
2923
2923
|
}
|
|
2924
2924
|
}
|
|
2925
|
-
function WritableStreamDefaultControllerErrorIfNeeded(controller,
|
|
2925
|
+
function WritableStreamDefaultControllerErrorIfNeeded(controller, error) {
|
|
2926
2926
|
if (controller._controlledWritableStream._state === "writable") {
|
|
2927
|
-
WritableStreamDefaultControllerError(controller,
|
|
2927
|
+
WritableStreamDefaultControllerError(controller, error);
|
|
2928
2928
|
}
|
|
2929
2929
|
}
|
|
2930
2930
|
function WritableStreamDefaultControllerProcessClose(controller) {
|
|
@@ -2967,10 +2967,10 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
2967
2967
|
const desiredSize = WritableStreamDefaultControllerGetDesiredSize(controller);
|
|
2968
2968
|
return desiredSize <= 0;
|
|
2969
2969
|
}
|
|
2970
|
-
function WritableStreamDefaultControllerError(controller,
|
|
2970
|
+
function WritableStreamDefaultControllerError(controller, error) {
|
|
2971
2971
|
const stream = controller._controlledWritableStream;
|
|
2972
2972
|
WritableStreamDefaultControllerClearAlgorithms(controller);
|
|
2973
|
-
WritableStreamStartErroring(stream,
|
|
2973
|
+
WritableStreamStartErroring(stream, error);
|
|
2974
2974
|
}
|
|
2975
2975
|
function streamBrandCheckException$2(name2) {
|
|
2976
2976
|
return new TypeError(`WritableStream.prototype.${name2} can only be used on a WritableStream`);
|
|
@@ -3114,12 +3114,12 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
3114
3114
|
let abortAlgorithm;
|
|
3115
3115
|
if (signal !== void 0) {
|
|
3116
3116
|
abortAlgorithm = () => {
|
|
3117
|
-
const
|
|
3117
|
+
const error = signal.reason !== void 0 ? signal.reason : new DOMException2("Aborted", "AbortError");
|
|
3118
3118
|
const actions = [];
|
|
3119
3119
|
if (!preventAbort) {
|
|
3120
3120
|
actions.push(() => {
|
|
3121
3121
|
if (dest._state === "writable") {
|
|
3122
|
-
return WritableStreamAbort(dest,
|
|
3122
|
+
return WritableStreamAbort(dest, error);
|
|
3123
3123
|
}
|
|
3124
3124
|
return promiseResolvedWith(void 0);
|
|
3125
3125
|
});
|
|
@@ -3127,12 +3127,12 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
3127
3127
|
if (!preventCancel) {
|
|
3128
3128
|
actions.push(() => {
|
|
3129
3129
|
if (source._state === "readable") {
|
|
3130
|
-
return ReadableStreamCancel(source,
|
|
3130
|
+
return ReadableStreamCancel(source, error);
|
|
3131
3131
|
}
|
|
3132
3132
|
return promiseResolvedWith(void 0);
|
|
3133
3133
|
});
|
|
3134
3134
|
}
|
|
3135
|
-
shutdownWithAction(() => Promise.all(actions.map((action) => action())), true,
|
|
3135
|
+
shutdownWithAction(() => Promise.all(actions.map((action) => action())), true, error);
|
|
3136
3136
|
};
|
|
3137
3137
|
if (signal.aborted) {
|
|
3138
3138
|
abortAlgorithm();
|
|
@@ -3235,25 +3235,25 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
3235
3235
|
return null;
|
|
3236
3236
|
}
|
|
3237
3237
|
}
|
|
3238
|
-
function shutdown(isError,
|
|
3238
|
+
function shutdown(isError, error) {
|
|
3239
3239
|
if (shuttingDown) {
|
|
3240
3240
|
return;
|
|
3241
3241
|
}
|
|
3242
3242
|
shuttingDown = true;
|
|
3243
3243
|
if (dest._state === "writable" && !WritableStreamCloseQueuedOrInFlight(dest)) {
|
|
3244
|
-
uponFulfillment(waitForWritesToFinish(), () => finalize(isError,
|
|
3244
|
+
uponFulfillment(waitForWritesToFinish(), () => finalize(isError, error));
|
|
3245
3245
|
} else {
|
|
3246
|
-
finalize(isError,
|
|
3246
|
+
finalize(isError, error);
|
|
3247
3247
|
}
|
|
3248
3248
|
}
|
|
3249
|
-
function finalize(isError,
|
|
3249
|
+
function finalize(isError, error) {
|
|
3250
3250
|
WritableStreamDefaultWriterRelease(writer);
|
|
3251
3251
|
ReadableStreamReaderGenericRelease(reader2);
|
|
3252
3252
|
if (signal !== void 0) {
|
|
3253
3253
|
signal.removeEventListener("abort", abortAlgorithm);
|
|
3254
3254
|
}
|
|
3255
3255
|
if (isError) {
|
|
3256
|
-
reject(
|
|
3256
|
+
reject(error);
|
|
3257
3257
|
} else {
|
|
3258
3258
|
resolve2(void 0);
|
|
3259
3259
|
}
|
|
@@ -4648,8 +4648,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
4648
4648
|
const stream = controller._controlledTransformStream;
|
|
4649
4649
|
const readableController = stream._readable._readableStreamController;
|
|
4650
4650
|
ReadableStreamDefaultControllerClose(readableController);
|
|
4651
|
-
const
|
|
4652
|
-
TransformStreamErrorWritableAndUnblockWrite(stream,
|
|
4651
|
+
const error = new TypeError("TransformStream terminated");
|
|
4652
|
+
TransformStreamErrorWritableAndUnblockWrite(stream, error);
|
|
4653
4653
|
}
|
|
4654
4654
|
function TransformStreamDefaultSinkWriteAlgorithm(stream, chunk) {
|
|
4655
4655
|
const controller = stream._transformStreamController;
|
|
@@ -4807,11 +4807,11 @@ var require_streams = __commonJS({
|
|
|
4807
4807
|
};
|
|
4808
4808
|
Object.assign(globalThis, require("stream/web"));
|
|
4809
4809
|
process2.emitWarning = emitWarning;
|
|
4810
|
-
} catch (
|
|
4810
|
+
} catch (error) {
|
|
4811
4811
|
process2.emitWarning = emitWarning;
|
|
4812
|
-
throw
|
|
4812
|
+
throw error;
|
|
4813
4813
|
}
|
|
4814
|
-
} catch (
|
|
4814
|
+
} catch (error) {
|
|
4815
4815
|
Object.assign(globalThis, require_ponyfill_es2018());
|
|
4816
4816
|
}
|
|
4817
4817
|
}
|
|
@@ -4835,7 +4835,7 @@ var require_streams = __commonJS({
|
|
|
4835
4835
|
});
|
|
4836
4836
|
};
|
|
4837
4837
|
}
|
|
4838
|
-
} catch (
|
|
4838
|
+
} catch (error) {
|
|
4839
4839
|
}
|
|
4840
4840
|
}
|
|
4841
4841
|
});
|
|
@@ -5725,15 +5725,15 @@ async function consumeBody(data2) {
|
|
|
5725
5725
|
try {
|
|
5726
5726
|
for await (const chunk of body) {
|
|
5727
5727
|
if (data2.size > 0 && accumBytes + chunk.length > data2.size) {
|
|
5728
|
-
const
|
|
5729
|
-
body.destroy(
|
|
5730
|
-
throw
|
|
5728
|
+
const error = new FetchError(`content size at ${data2.url} over limit: ${data2.size}`, "max-size");
|
|
5729
|
+
body.destroy(error);
|
|
5730
|
+
throw error;
|
|
5731
5731
|
}
|
|
5732
5732
|
accumBytes += chunk.length;
|
|
5733
5733
|
accum.push(chunk);
|
|
5734
5734
|
}
|
|
5735
|
-
} catch (
|
|
5736
|
-
const error_ =
|
|
5735
|
+
} catch (error) {
|
|
5736
|
+
const error_ = error instanceof FetchBaseError ? error : new FetchError(`Invalid response body while trying to fetch ${data2.url}: ${error.message}`, "system", error);
|
|
5737
5737
|
throw error_;
|
|
5738
5738
|
}
|
|
5739
5739
|
if (body.readableEnded === true || body._readableState.ended === true) {
|
|
@@ -5742,8 +5742,8 @@ async function consumeBody(data2) {
|
|
|
5742
5742
|
return import_node_buffer.Buffer.from(accum.join(""));
|
|
5743
5743
|
}
|
|
5744
5744
|
return import_node_buffer.Buffer.concat(accum, accumBytes);
|
|
5745
|
-
} catch (
|
|
5746
|
-
throw new FetchError(`Could not create Buffer from response body for ${data2.url}: ${
|
|
5745
|
+
} catch (error) {
|
|
5746
|
+
throw new FetchError(`Could not create Buffer from response body for ${data2.url}: ${error.message}`, "system", error);
|
|
5747
5747
|
}
|
|
5748
5748
|
} else {
|
|
5749
5749
|
throw new FetchError(`Premature close of server response while trying to fetch ${data2.url}`);
|
|
@@ -5801,8 +5801,8 @@ var init_body = __esm({
|
|
|
5801
5801
|
this.size = size;
|
|
5802
5802
|
if (body instanceof import_node_stream.default) {
|
|
5803
5803
|
body.on("error", (error_) => {
|
|
5804
|
-
const
|
|
5805
|
-
this[INTERNALS].error =
|
|
5804
|
+
const error = error_ instanceof FetchBaseError ? error_ : new FetchError(`Invalid response body while trying to fetch ${this.url}: ${error_.message}`, "system", error_);
|
|
5805
|
+
this[INTERNALS].error = error;
|
|
5806
5806
|
});
|
|
5807
5807
|
}
|
|
5808
5808
|
}
|
|
@@ -5990,16 +5990,16 @@ var init_headers = __esm({
|
|
|
5990
5990
|
import_node_http = __toESM(require("http"), 1);
|
|
5991
5991
|
validateHeaderName = typeof import_node_http.default.validateHeaderName === "function" ? import_node_http.default.validateHeaderName : (name2) => {
|
|
5992
5992
|
if (!/^[\^`\-\w!#$%&'*+.|~]+$/.test(name2)) {
|
|
5993
|
-
const
|
|
5994
|
-
Object.defineProperty(
|
|
5995
|
-
throw
|
|
5993
|
+
const error = new TypeError(`Header name must be a valid HTTP token [${name2}]`);
|
|
5994
|
+
Object.defineProperty(error, "code", { value: "ERR_INVALID_HTTP_TOKEN" });
|
|
5995
|
+
throw error;
|
|
5996
5996
|
}
|
|
5997
5997
|
};
|
|
5998
5998
|
validateHeaderValue = typeof import_node_http.default.validateHeaderValue === "function" ? import_node_http.default.validateHeaderValue : (name2, value) => {
|
|
5999
5999
|
if (/[^\t\u0020-\u007E\u0080-\u00FF]/.test(value)) {
|
|
6000
|
-
const
|
|
6001
|
-
Object.defineProperty(
|
|
6002
|
-
throw
|
|
6000
|
+
const error = new TypeError(`Invalid character in header content ["${name2}"]`);
|
|
6001
|
+
Object.defineProperty(error, "code", { value: "ERR_INVALID_CHAR" });
|
|
6002
|
+
throw error;
|
|
6003
6003
|
}
|
|
6004
6004
|
};
|
|
6005
6005
|
Headers = class _Headers extends URLSearchParams {
|
|
@@ -6711,15 +6711,15 @@ async function fetch2(url, options_) {
|
|
|
6711
6711
|
const { signal } = request;
|
|
6712
6712
|
let response2 = null;
|
|
6713
6713
|
const abort = () => {
|
|
6714
|
-
const
|
|
6715
|
-
reject(
|
|
6714
|
+
const error = new AbortError("The operation was aborted.");
|
|
6715
|
+
reject(error);
|
|
6716
6716
|
if (request.body && request.body instanceof import_node_stream2.default.Readable) {
|
|
6717
|
-
request.body.destroy(
|
|
6717
|
+
request.body.destroy(error);
|
|
6718
6718
|
}
|
|
6719
6719
|
if (!response2 || !response2.body) {
|
|
6720
6720
|
return;
|
|
6721
6721
|
}
|
|
6722
|
-
response2.body.emit("error",
|
|
6722
|
+
response2.body.emit("error", error);
|
|
6723
6723
|
};
|
|
6724
6724
|
if (signal && signal.aborted) {
|
|
6725
6725
|
abort();
|
|
@@ -6739,13 +6739,13 @@ async function fetch2(url, options_) {
|
|
|
6739
6739
|
signal.removeEventListener("abort", abortAndFinalize);
|
|
6740
6740
|
}
|
|
6741
6741
|
};
|
|
6742
|
-
request_.on("error", (
|
|
6743
|
-
reject(new FetchError(`request to ${request.url} failed, reason: ${
|
|
6742
|
+
request_.on("error", (error) => {
|
|
6743
|
+
reject(new FetchError(`request to ${request.url} failed, reason: ${error.message}`, "system", error));
|
|
6744
6744
|
finalize();
|
|
6745
6745
|
});
|
|
6746
|
-
fixResponseChunkedTransferBadEnding(request_, (
|
|
6746
|
+
fixResponseChunkedTransferBadEnding(request_, (error) => {
|
|
6747
6747
|
if (response2 && response2.body) {
|
|
6748
|
-
response2.body.destroy(
|
|
6748
|
+
response2.body.destroy(error);
|
|
6749
6749
|
}
|
|
6750
6750
|
});
|
|
6751
6751
|
if (process.version < "v14") {
|
|
@@ -6756,9 +6756,9 @@ async function fetch2(url, options_) {
|
|
|
6756
6756
|
});
|
|
6757
6757
|
s2.prependListener("close", (hadError) => {
|
|
6758
6758
|
if (response2 && endedWithEventsCount < s2._eventsCount && !hadError) {
|
|
6759
|
-
const
|
|
6760
|
-
|
|
6761
|
-
response2.body.emit("error",
|
|
6759
|
+
const error = new Error("Premature close");
|
|
6760
|
+
error.code = "ERR_STREAM_PREMATURE_CLOSE";
|
|
6761
|
+
response2.body.emit("error", error);
|
|
6762
6762
|
}
|
|
6763
6763
|
});
|
|
6764
6764
|
});
|
|
@@ -6839,9 +6839,9 @@ async function fetch2(url, options_) {
|
|
|
6839
6839
|
signal.removeEventListener("abort", abortAndFinalize);
|
|
6840
6840
|
});
|
|
6841
6841
|
}
|
|
6842
|
-
let body = (0, import_node_stream2.pipeline)(response_, new import_node_stream2.PassThrough(), (
|
|
6843
|
-
if (
|
|
6844
|
-
reject(
|
|
6842
|
+
let body = (0, import_node_stream2.pipeline)(response_, new import_node_stream2.PassThrough(), (error) => {
|
|
6843
|
+
if (error) {
|
|
6844
|
+
reject(error);
|
|
6845
6845
|
}
|
|
6846
6846
|
});
|
|
6847
6847
|
if (process.version < "v12.10") {
|
|
@@ -6867,9 +6867,9 @@ async function fetch2(url, options_) {
|
|
|
6867
6867
|
finishFlush: import_node_zlib.default.Z_SYNC_FLUSH
|
|
6868
6868
|
};
|
|
6869
6869
|
if (codings === "gzip" || codings === "x-gzip") {
|
|
6870
|
-
body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createGunzip(zlibOptions), (
|
|
6871
|
-
if (
|
|
6872
|
-
reject(
|
|
6870
|
+
body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createGunzip(zlibOptions), (error) => {
|
|
6871
|
+
if (error) {
|
|
6872
|
+
reject(error);
|
|
6873
6873
|
}
|
|
6874
6874
|
});
|
|
6875
6875
|
response2 = new Response(body, responseOptions);
|
|
@@ -6877,22 +6877,22 @@ async function fetch2(url, options_) {
|
|
|
6877
6877
|
return;
|
|
6878
6878
|
}
|
|
6879
6879
|
if (codings === "deflate" || codings === "x-deflate") {
|
|
6880
|
-
const raw = (0, import_node_stream2.pipeline)(response_, new import_node_stream2.PassThrough(), (
|
|
6881
|
-
if (
|
|
6882
|
-
reject(
|
|
6880
|
+
const raw = (0, import_node_stream2.pipeline)(response_, new import_node_stream2.PassThrough(), (error) => {
|
|
6881
|
+
if (error) {
|
|
6882
|
+
reject(error);
|
|
6883
6883
|
}
|
|
6884
6884
|
});
|
|
6885
6885
|
raw.once("data", (chunk) => {
|
|
6886
6886
|
if ((chunk[0] & 15) === 8) {
|
|
6887
|
-
body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createInflate(), (
|
|
6888
|
-
if (
|
|
6889
|
-
reject(
|
|
6887
|
+
body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createInflate(), (error) => {
|
|
6888
|
+
if (error) {
|
|
6889
|
+
reject(error);
|
|
6890
6890
|
}
|
|
6891
6891
|
});
|
|
6892
6892
|
} else {
|
|
6893
|
-
body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createInflateRaw(), (
|
|
6894
|
-
if (
|
|
6895
|
-
reject(
|
|
6893
|
+
body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createInflateRaw(), (error) => {
|
|
6894
|
+
if (error) {
|
|
6895
|
+
reject(error);
|
|
6896
6896
|
}
|
|
6897
6897
|
});
|
|
6898
6898
|
}
|
|
@@ -6908,9 +6908,9 @@ async function fetch2(url, options_) {
|
|
|
6908
6908
|
return;
|
|
6909
6909
|
}
|
|
6910
6910
|
if (codings === "br") {
|
|
6911
|
-
body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createBrotliDecompress(), (
|
|
6912
|
-
if (
|
|
6913
|
-
reject(
|
|
6911
|
+
body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createBrotliDecompress(), (error) => {
|
|
6912
|
+
if (error) {
|
|
6913
|
+
reject(error);
|
|
6914
6914
|
}
|
|
6915
6915
|
});
|
|
6916
6916
|
response2 = new Response(body, responseOptions);
|
|
@@ -6935,9 +6935,9 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
|
6935
6935
|
request.on("socket", (socket) => {
|
|
6936
6936
|
const onSocketClose = () => {
|
|
6937
6937
|
if (isChunkedTransfer && !properLastChunkReceived) {
|
|
6938
|
-
const
|
|
6939
|
-
|
|
6940
|
-
errorCallback(
|
|
6938
|
+
const error = new Error("Premature close");
|
|
6939
|
+
error.code = "ERR_STREAM_PREMATURE_CLOSE";
|
|
6940
|
+
errorCallback(error);
|
|
6941
6941
|
}
|
|
6942
6942
|
};
|
|
6943
6943
|
const onData = (buf) => {
|
|
@@ -7005,11 +7005,11 @@ var init_base_provider = __esm({
|
|
|
7005
7005
|
latencyMs,
|
|
7006
7006
|
timestamp: Date.now()
|
|
7007
7007
|
};
|
|
7008
|
-
} catch (
|
|
7008
|
+
} catch (error) {
|
|
7009
7009
|
return {
|
|
7010
7010
|
ok: false,
|
|
7011
7011
|
latencyMs: Date.now() - startTime,
|
|
7012
|
-
reason:
|
|
7012
|
+
reason: error instanceof Error ? error.message : "Unknown error",
|
|
7013
7013
|
timestamp: Date.now()
|
|
7014
7014
|
};
|
|
7015
7015
|
}
|
|
@@ -7038,9 +7038,9 @@ var init_base_provider = __esm({
|
|
|
7038
7038
|
);
|
|
7039
7039
|
}
|
|
7040
7040
|
return response2.json();
|
|
7041
|
-
} catch (
|
|
7041
|
+
} catch (error) {
|
|
7042
7042
|
clearTimeout(timeoutId);
|
|
7043
|
-
throw
|
|
7043
|
+
throw error;
|
|
7044
7044
|
}
|
|
7045
7045
|
}
|
|
7046
7046
|
// Helper method for streaming requests
|
|
@@ -7067,9 +7067,9 @@ var init_base_provider = __esm({
|
|
|
7067
7067
|
);
|
|
7068
7068
|
}
|
|
7069
7069
|
return this.parseStreamResponse(response2);
|
|
7070
|
-
} catch (
|
|
7070
|
+
} catch (error) {
|
|
7071
7071
|
clearTimeout(timeoutId);
|
|
7072
|
-
throw
|
|
7072
|
+
throw error;
|
|
7073
7073
|
}
|
|
7074
7074
|
}
|
|
7075
7075
|
// Default stream parsing - override in subclasses for provider-specific logic
|
|
@@ -7112,10 +7112,10 @@ var init_base_provider = __esm({
|
|
|
7112
7112
|
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
|
7113
7113
|
try {
|
|
7114
7114
|
return await operation();
|
|
7115
|
-
} catch (
|
|
7116
|
-
lastError =
|
|
7117
|
-
if (this.isNonRetryableError(
|
|
7118
|
-
throw
|
|
7115
|
+
} catch (error) {
|
|
7116
|
+
lastError = error;
|
|
7117
|
+
if (this.isNonRetryableError(error)) {
|
|
7118
|
+
throw error;
|
|
7119
7119
|
}
|
|
7120
7120
|
if (attempt < maxRetries - 1) {
|
|
7121
7121
|
const delay = Math.pow(2, attempt) * 1e3;
|
|
@@ -7126,8 +7126,8 @@ var init_base_provider = __esm({
|
|
|
7126
7126
|
throw lastError;
|
|
7127
7127
|
}
|
|
7128
7128
|
// Check if error should not be retried
|
|
7129
|
-
isNonRetryableError(
|
|
7130
|
-
const message =
|
|
7129
|
+
isNonRetryableError(error) {
|
|
7130
|
+
const message = error?.message?.toLowerCase() || "";
|
|
7131
7131
|
return message.includes("invalid api key") || message.includes("unauthorized") || message.includes("forbidden") || message.includes("not found");
|
|
7132
7132
|
}
|
|
7133
7133
|
};
|
|
@@ -7255,10 +7255,10 @@ var init_manager = __esm({
|
|
|
7255
7255
|
async ([id, provider2]) => {
|
|
7256
7256
|
try {
|
|
7257
7257
|
health[id] = await provider2.health();
|
|
7258
|
-
} catch (
|
|
7258
|
+
} catch (error) {
|
|
7259
7259
|
health[id] = {
|
|
7260
7260
|
ok: false,
|
|
7261
|
-
reason:
|
|
7261
|
+
reason: error instanceof Error ? error.message : "Unknown error",
|
|
7262
7262
|
timestamp: Date.now()
|
|
7263
7263
|
};
|
|
7264
7264
|
}
|
|
@@ -7281,10 +7281,10 @@ var init_manager = __esm({
|
|
|
7281
7281
|
if (health.ok) {
|
|
7282
7282
|
this.availableProviders.add(id);
|
|
7283
7283
|
}
|
|
7284
|
-
} catch (
|
|
7284
|
+
} catch (error) {
|
|
7285
7285
|
this.healthCache.set(id, {
|
|
7286
7286
|
ok: false,
|
|
7287
|
-
reason:
|
|
7287
|
+
reason: error instanceof Error ? error.message : "Health check failed",
|
|
7288
7288
|
timestamp: Date.now()
|
|
7289
7289
|
});
|
|
7290
7290
|
}
|
|
@@ -7345,10 +7345,10 @@ var init_manager = __esm({
|
|
|
7345
7345
|
const health = await provider2.health();
|
|
7346
7346
|
this.healthCache.set(id, health);
|
|
7347
7347
|
return health;
|
|
7348
|
-
} catch (
|
|
7348
|
+
} catch (error) {
|
|
7349
7349
|
const health = {
|
|
7350
7350
|
ok: false,
|
|
7351
|
-
reason:
|
|
7351
|
+
reason: error instanceof Error ? error.message : "Health check failed",
|
|
7352
7352
|
timestamp: now
|
|
7353
7353
|
};
|
|
7354
7354
|
this.healthCache.set(id, health);
|
|
@@ -7858,14 +7858,13 @@ var init_provider_selector = __esm({
|
|
|
7858
7858
|
import_chalk2 = __toESM(require("chalk"), 1);
|
|
7859
7859
|
import_inquirer = __toESM(require("inquirer"), 1);
|
|
7860
7860
|
init_providers();
|
|
7861
|
-
init_manager();
|
|
7862
7861
|
ProviderSelector = class {
|
|
7863
7862
|
config;
|
|
7864
7863
|
modernProviderManager;
|
|
7865
7864
|
legacyProviderManager;
|
|
7866
7865
|
constructor(_config) {
|
|
7867
7866
|
this.config = _config;
|
|
7868
|
-
this.modernProviderManager = new
|
|
7867
|
+
this.modernProviderManager = new UnifiedAIProviderManager();
|
|
7869
7868
|
this.legacyProviderManager = new UnifiedAIProviderManager2(_config);
|
|
7870
7869
|
}
|
|
7871
7870
|
async initialize() {
|
|
@@ -8165,8 +8164,8 @@ async function importReactComponent(specifier) {
|
|
|
8165
8164
|
try {
|
|
8166
8165
|
const _module = await safeDynamicImport(specifier);
|
|
8167
8166
|
return _module;
|
|
8168
|
-
} catch (
|
|
8169
|
-
console.warn(`Failed to load React component ${specifier}:`,
|
|
8167
|
+
} catch (error) {
|
|
8168
|
+
console.warn(`Failed to load React component ${specifier}:`, error);
|
|
8170
8169
|
throw new Error(
|
|
8171
8170
|
`React component ${specifier} is not available in this environment`
|
|
8172
8171
|
);
|
|
@@ -8186,604 +8185,61 @@ var init_import_helper = __esm({
|
|
|
8186
8185
|
}
|
|
8187
8186
|
});
|
|
8188
8187
|
|
|
8189
|
-
// src/config/
|
|
8190
|
-
function
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
if (source[key2] === void 0) continue;
|
|
8194
|
-
const sourceValue = source[key2];
|
|
8195
|
-
const targetValue = result[key2];
|
|
8196
|
-
if (Array.isArray(sourceValue)) {
|
|
8197
|
-
result[key2] = [...sourceValue];
|
|
8198
|
-
} else if (sourceValue && typeof sourceValue === "object" && targetValue && typeof targetValue === "object" && !Array.isArray(targetValue)) {
|
|
8199
|
-
result[key2] = deepMerge(targetValue, sourceValue);
|
|
8200
|
-
} else {
|
|
8201
|
-
result[key2] = sourceValue;
|
|
8202
|
-
}
|
|
8188
|
+
// src/config/loader.ts
|
|
8189
|
+
async function loadEnvironmentConfig() {
|
|
8190
|
+
if (environmentLoaded) {
|
|
8191
|
+
return;
|
|
8203
8192
|
}
|
|
8204
|
-
|
|
8205
|
-
}
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
"
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
|
|
8225
|
-
|
|
8226
|
-
"claude-3-5-sonnet-20241022"
|
|
8227
|
-
],
|
|
8228
|
-
google: ["gemini-2.0-flash-exp", "gemini-1.5-pro", "gemini-1.5-flash"],
|
|
8229
|
-
groq: [
|
|
8230
|
-
"llama-3.1-70b-versatile",
|
|
8231
|
-
"llama-3.1-8b-instant",
|
|
8232
|
-
"mixtral-8x7b-32768"
|
|
8233
|
-
],
|
|
8234
|
-
grok: ["grok-beta", "grok-vision-beta"],
|
|
8235
|
-
lmstudio: ["*"],
|
|
8236
|
-
// Local models - accept any
|
|
8237
|
-
ollama: ["*"],
|
|
8238
|
-
// Local models - accept any
|
|
8239
|
-
vllm: ["*"]
|
|
8240
|
-
// Local models - accept any
|
|
8241
|
-
};
|
|
8242
|
-
ConfigValidationError = class extends Error {
|
|
8243
|
-
constructor(message, field, value, suggestion) {
|
|
8244
|
-
super(message);
|
|
8245
|
-
this.field = field;
|
|
8246
|
-
this.value = value;
|
|
8247
|
-
this.suggestion = suggestion;
|
|
8248
|
-
this.name = "ConfigValidationError";
|
|
8249
|
-
}
|
|
8250
|
-
};
|
|
8251
|
-
ConfigLoadError = class extends Error {
|
|
8252
|
-
constructor(message, cause) {
|
|
8253
|
-
super(message);
|
|
8254
|
-
this.cause = cause;
|
|
8255
|
-
this.name = "ConfigLoadError";
|
|
8256
|
-
}
|
|
8257
|
-
};
|
|
8258
|
-
PriorityModeSchema = import_zod.z.enum(["privacy-first", "performance", "cost-effective", "auto"]).default("privacy-first");
|
|
8259
|
-
ApiKeysSchema = import_zod.z.object({
|
|
8260
|
-
OPENAI_API_KEY: import_zod.z.string().optional(),
|
|
8261
|
-
ANTHROPIC_API_KEY: import_zod.z.string().optional(),
|
|
8262
|
-
GOOGLE_API_KEY: import_zod.z.string().optional(),
|
|
8263
|
-
GROQ_API_KEY: import_zod.z.string().optional(),
|
|
8264
|
-
GROK_API_KEY: import_zod.z.string().optional()
|
|
8265
|
-
}).partial().default({});
|
|
8266
|
-
LocalProvidersSchema = import_zod.z.object({
|
|
8267
|
-
lmstudio: import_zod.z.boolean().default(false),
|
|
8268
|
-
ollama: import_zod.z.boolean().default(false),
|
|
8269
|
-
vllm: import_zod.z.boolean().default(false)
|
|
8270
|
-
}).default({ lmstudio: false, ollama: false, vllm: false });
|
|
8271
|
-
ProviderConfigSchema = import_zod.z.object({
|
|
8272
|
-
enabled: import_zod.z.boolean().default(false),
|
|
8273
|
-
apiKey: import_zod.z.string().optional(),
|
|
8274
|
-
apiBase: import_zod.z.string().url().optional(),
|
|
8275
|
-
models: import_zod.z.record(import_zod.z.any()).default({})
|
|
8276
|
-
}).default({ enabled: false, models: Record });
|
|
8277
|
-
ConfigSchema = import_zod.z.object({
|
|
8278
|
-
priority: PriorityModeSchema,
|
|
8279
|
-
providers: import_zod.z.record(ProviderConfigSchema).default({}),
|
|
8280
|
-
autoStart: import_zod.z.boolean().default(true),
|
|
8281
|
-
healthMonitoring: import_zod.z.boolean().default(true),
|
|
8282
|
-
language: import_zod.z.string().default("auto"),
|
|
8283
|
-
offlineMode: import_zod.z.boolean().default(false),
|
|
8284
|
-
// Extended configuration
|
|
8285
|
-
model: import_zod.z.string().default("gpt-5-mini"),
|
|
8286
|
-
provider: import_zod.z.string().default("openai"),
|
|
8287
|
-
apiKeys: ApiKeysSchema.optional(),
|
|
8288
|
-
localProviders: LocalProvidersSchema.optional(),
|
|
8289
|
-
enabledProviders: import_zod.z.array(import_zod.z.string()).optional(),
|
|
8290
|
-
// Advanced settings
|
|
8291
|
-
maxRetries: import_zod.z.number().min(0).max(10).default(3),
|
|
8292
|
-
timeout: import_zod.z.number().min(1e3).max(3e5).default(3e4),
|
|
8293
|
-
// 30s default
|
|
8294
|
-
concurrentRequests: import_zod.z.number().min(1).max(20).default(5),
|
|
8295
|
-
cacheEnabled: import_zod.z.boolean().default(true),
|
|
8296
|
-
logLevel: import_zod.z.enum(["error", "warn", "info", "debug"]).default("info"),
|
|
8297
|
-
telemetryEnabled: import_zod.z.boolean().default(true)
|
|
8298
|
-
}).strip();
|
|
8299
|
-
ConfigManagerV2 = class _ConfigManagerV2 {
|
|
8300
|
-
config;
|
|
8301
|
-
sourceMap;
|
|
8302
|
-
constructor(initialConfig = {}, source = "defaults") {
|
|
8303
|
-
try {
|
|
8304
|
-
this.config = this.validateAndTransform(this.loadDefaultConfig());
|
|
8305
|
-
this.sourceMap = this.initializeSourceMap();
|
|
8306
|
-
if (Object.keys(initialConfig).length > 0) {
|
|
8307
|
-
this.mergeAndValidate(initialConfig, source);
|
|
8308
|
-
}
|
|
8309
|
-
} catch (error2) {
|
|
8310
|
-
throw new ConfigLoadError(
|
|
8311
|
-
`Failed to initialize ConfigManager: ${error2 instanceof Error ? error2.message : "Unknown error"}`,
|
|
8312
|
-
error2 instanceof Error ? error2 : void 0
|
|
8313
|
-
);
|
|
8314
|
-
}
|
|
8315
|
-
}
|
|
8316
|
-
// Utility function for parsing boolean values from environment variables
|
|
8317
|
-
static parseBool(value, defaultValue = false) {
|
|
8318
|
-
if (!value) return defaultValue;
|
|
8319
|
-
return /^(1|true|yes|on)$/i.test(value.trim());
|
|
8320
|
-
}
|
|
8321
|
-
static parseNumber(value, defaultValue) {
|
|
8322
|
-
if (!value) return defaultValue;
|
|
8323
|
-
const parsed = parseInt(value, 10);
|
|
8324
|
-
return isNaN(parsed) ? defaultValue : parsed;
|
|
8325
|
-
}
|
|
8326
|
-
loadDefaultConfig() {
|
|
8327
|
-
return {
|
|
8328
|
-
priority: "privacy-first",
|
|
8329
|
-
providers: {},
|
|
8330
|
-
autoStart: true,
|
|
8331
|
-
healthMonitoring: true,
|
|
8332
|
-
language: "auto",
|
|
8333
|
-
offlineMode: false,
|
|
8334
|
-
model: "gpt-5-mini",
|
|
8335
|
-
provider: "openai",
|
|
8336
|
-
maxRetries: 3,
|
|
8337
|
-
timeout: 3e4,
|
|
8338
|
-
concurrentRequests: 5,
|
|
8339
|
-
cacheEnabled: true,
|
|
8340
|
-
logLevel: "info",
|
|
8341
|
-
telemetryEnabled: true
|
|
8342
|
-
};
|
|
8343
|
-
}
|
|
8344
|
-
initializeSourceMap() {
|
|
8345
|
-
const keys = Object.keys(this.config);
|
|
8346
|
-
return keys.reduce(
|
|
8347
|
-
(map, key2) => ({ ...map, [key2]: "defaults" }),
|
|
8348
|
-
{}
|
|
8349
|
-
);
|
|
8350
|
-
}
|
|
8351
|
-
// Validate and transform configuration using Zod schema
|
|
8352
|
-
validateAndTransform(config2) {
|
|
8353
|
-
try {
|
|
8354
|
-
const validated = ConfigSchema.parse(config2);
|
|
8355
|
-
this.validateProviderModelConsistency(validated);
|
|
8356
|
-
return validated;
|
|
8357
|
-
} catch (innerError) {
|
|
8358
|
-
if (error instanceof import_zod.z.ZodError) {
|
|
8359
|
-
const firstError = error.errors[0];
|
|
8360
|
-
throw new ConfigValidationError(
|
|
8361
|
-
`Configuration validation failed: ${firstError.message}`,
|
|
8362
|
-
firstError.path.join("."),
|
|
8363
|
-
firstError.received,
|
|
8364
|
-
this.getSuggestionForError(firstError)
|
|
8365
|
-
);
|
|
8366
|
-
}
|
|
8367
|
-
throw error;
|
|
8368
|
-
}
|
|
8369
|
-
}
|
|
8370
|
-
// Custom provider/model consistency validation
|
|
8371
|
-
validateProviderModelConsistency(config2) {
|
|
8372
|
-
const { provider: provider2, model } = config2;
|
|
8373
|
-
if (provider2 && model) {
|
|
8374
|
-
const allowedModels = PROVIDER_MODELS[provider2];
|
|
8375
|
-
if (allowedModels && !allowedModels.includes("*") && !allowedModels.includes(model)) {
|
|
8376
|
-
throw new ConfigValidationError(
|
|
8377
|
-
`Model "${model}" is not supported by provider "${provider2}"`,
|
|
8378
|
-
"model",
|
|
8379
|
-
model,
|
|
8380
|
-
`Available models for ${provider2}: ${allowedModels.join(", ")}`
|
|
8381
|
-
);
|
|
8382
|
-
}
|
|
8383
|
-
}
|
|
8384
|
-
}
|
|
8385
|
-
// Provide helpful suggestions for validation errors
|
|
8386
|
-
getSuggestionForError(error2) {
|
|
8387
|
-
switch (error2.code) {
|
|
8388
|
-
case "invalid_enum_value":
|
|
8389
|
-
return `Valid options: ${error2.options.join(", ")}`;
|
|
8390
|
-
case "too_small":
|
|
8391
|
-
return `Minimum value: ${error2.minimum}`;
|
|
8392
|
-
case "too_big":
|
|
8393
|
-
return `Maximum value: ${error2.maximum}`;
|
|
8394
|
-
case "invalid_type":
|
|
8395
|
-
return `Expected ${error2.expected}, got ${error2.received}`;
|
|
8396
|
-
case "invalid_string":
|
|
8397
|
-
if (error2.validation === "url") {
|
|
8398
|
-
return "Must be a valid URL (e.g., https://api.example.com)";
|
|
8399
|
-
}
|
|
8400
|
-
return "Invalid string format";
|
|
8401
|
-
default:
|
|
8402
|
-
return "Please check the configuration documentation";
|
|
8403
|
-
}
|
|
8404
|
-
}
|
|
8405
|
-
// Phase 2: Advanced merge with validation and source tracking
|
|
8406
|
-
mergeAndValidate(newConfig, source = "defaults") {
|
|
8407
|
-
try {
|
|
8408
|
-
const mergedConfig = deepMerge(
|
|
8409
|
-
this.config,
|
|
8410
|
-
newConfig
|
|
8411
|
-
);
|
|
8412
|
-
const validatedConfig = this.validateAndTransform(mergedConfig);
|
|
8413
|
-
this.updateSourceMap(newConfig, source);
|
|
8414
|
-
this.config = validatedConfig;
|
|
8415
|
-
} catch (error2) {
|
|
8416
|
-
throw new ConfigValidationError(
|
|
8417
|
-
`Failed to merge configuration: ${error2 instanceof Error ? error2.message : "Unknown error"}`,
|
|
8418
|
-
"merge",
|
|
8419
|
-
newConfig,
|
|
8420
|
-
"Check configuration format and values"
|
|
8421
|
-
);
|
|
8422
|
-
}
|
|
8423
|
-
}
|
|
8424
|
-
updateSourceMap(newConfig, source) {
|
|
8425
|
-
for (const key2 of Object.keys(newConfig)) {
|
|
8426
|
-
if (key2 in this.sourceMap) {
|
|
8427
|
-
this.sourceMap[key2] = source;
|
|
8428
|
-
}
|
|
8429
|
-
}
|
|
8430
|
-
}
|
|
8431
|
-
get(key2, defaultValue) {
|
|
8432
|
-
const value = this.config[key2];
|
|
8433
|
-
return value !== void 0 ? value : defaultValue;
|
|
8434
|
-
}
|
|
8435
|
-
// Type-safe set method with validation
|
|
8436
|
-
set(key2, value, source = "manual") {
|
|
8437
|
-
try {
|
|
8438
|
-
const updatedConfig = { ...this.config, [key2]: value };
|
|
8439
|
-
const validatedConfig = this.validateAndTransform(updatedConfig);
|
|
8440
|
-
this.config = validatedConfig;
|
|
8441
|
-
this.sourceMap[key2] = source;
|
|
8442
|
-
} catch (innerError) {
|
|
8443
|
-
throw new ConfigValidationError(
|
|
8444
|
-
`Failed to set ${String(key2)}: ${error instanceof Error ? error.message : "Invalid value"}`,
|
|
8445
|
-
String(key2),
|
|
8446
|
-
value,
|
|
8447
|
-
error instanceof ConfigValidationError ? error.suggestion : void 0
|
|
8448
|
-
);
|
|
8449
|
-
}
|
|
8450
|
-
}
|
|
8451
|
-
// Bulk update with validation
|
|
8452
|
-
update(updates, source = "manual") {
|
|
8453
|
-
this.mergeAndValidate(updates, source);
|
|
8454
|
-
}
|
|
8455
|
-
// Get configuration source information
|
|
8456
|
-
getSource(key2) {
|
|
8457
|
-
return this.sourceMap[key2];
|
|
8458
|
-
}
|
|
8459
|
-
// Get all source mappings
|
|
8460
|
-
getSourceMap() {
|
|
8461
|
-
return { ...this.sourceMap };
|
|
8462
|
-
}
|
|
8463
|
-
// Validate current configuration
|
|
8464
|
-
validate() {
|
|
8465
|
-
try {
|
|
8466
|
-
this.validateAndTransform(this.config);
|
|
8467
|
-
return { isValid: true, errors: [] };
|
|
8468
|
-
} catch (error2) {
|
|
8469
|
-
const errors = [];
|
|
8470
|
-
if (error2 instanceof ConfigValidationError) {
|
|
8471
|
-
errors.push(`${error2.field}: ${error2.message}`);
|
|
8472
|
-
} else {
|
|
8473
|
-
errors.push(
|
|
8474
|
-
error2 instanceof Error ? error2.message : "Unknown validation error"
|
|
8475
|
-
);
|
|
8476
|
-
}
|
|
8477
|
-
return { isValid: false, errors };
|
|
8478
|
-
}
|
|
8479
|
-
}
|
|
8480
|
-
getAll(options) {
|
|
8481
|
-
const configCopy = { ...this.config };
|
|
8482
|
-
if (options?.maskSensitive && configCopy.apiKeys) {
|
|
8483
|
-
configCopy.apiKeys = Object.fromEntries(
|
|
8484
|
-
Object.entries(configCopy.apiKeys).map(([key2, value]) => [
|
|
8485
|
-
key2,
|
|
8486
|
-
value ? "***MASKED***" : value
|
|
8487
|
-
])
|
|
8488
|
-
);
|
|
8489
|
-
}
|
|
8490
|
-
const result = options?.includeSourceMap ? { config: configCopy, sources: this.sourceMap } : configCopy;
|
|
8491
|
-
if (options?.format) {
|
|
8492
|
-
switch (options.format) {
|
|
8493
|
-
case "json":
|
|
8494
|
-
return JSON.stringify(result, null, 2);
|
|
8495
|
-
case "yaml":
|
|
8496
|
-
return this.toYamlLike(result);
|
|
8497
|
-
default:
|
|
8498
|
-
return result;
|
|
8499
|
-
}
|
|
8500
|
-
}
|
|
8501
|
-
return result;
|
|
8502
|
-
}
|
|
8503
|
-
toYamlLike(obj, indent = 0) {
|
|
8504
|
-
const spaces = " ".repeat(indent);
|
|
8505
|
-
let result = "";
|
|
8506
|
-
for (const [key2, value] of Object.entries(obj)) {
|
|
8507
|
-
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
8508
|
-
result += `${spaces}${key2}:
|
|
8509
|
-
${this.toYamlLike(value, indent + 1)}`;
|
|
8510
|
-
} else if (Array.isArray(value)) {
|
|
8511
|
-
result += `${spaces}${key2}:
|
|
8512
|
-
`;
|
|
8513
|
-
for (const _item of value) {
|
|
8514
|
-
result += `${spaces} - ${_item}
|
|
8515
|
-
`;
|
|
8516
|
-
}
|
|
8517
|
-
} else {
|
|
8518
|
-
result += `${spaces}${key2}: ${value}
|
|
8519
|
-
`;
|
|
8520
|
-
}
|
|
8521
|
-
}
|
|
8522
|
-
return result;
|
|
8523
|
-
}
|
|
8524
|
-
// Phase 2: Enhanced environment loading with comprehensive hierarchy
|
|
8525
|
-
static fromEnvironment() {
|
|
8526
|
-
const envConfig = {
|
|
8527
|
-
priority: process.env["MARIA_PRIORITY"] || void 0,
|
|
8528
|
-
provider: process.env["MARIA_PROVIDER"] || process.env["PROVIDER"] || void 0,
|
|
8529
|
-
model: process.env["MARIA_MODEL"] || process.env["MODEL"] || void 0,
|
|
8530
|
-
language: process.env["MARIA_LANGUAGE"] || process.env["LANGUAGE"] || void 0,
|
|
8531
|
-
offlineMode: _ConfigManagerV2.parseBool(process.env["MARIA_OFFLINE_MODE"]),
|
|
8532
|
-
apiKeys: {
|
|
8533
|
-
OPENAI_API_KEY: process.env["OPENAI_API_KEY"] || void 0,
|
|
8534
|
-
ANTHROPIC_API_KEY: process.env["ANTHROPIC_API_KEY"] || void 0,
|
|
8535
|
-
GOOGLE_API_KEY: process.env["GOOGLE_AI_API_KEY"] || process.env["GOOGLE_API_KEY"] || process.env["GEMINI_API_KEY"] || void 0,
|
|
8536
|
-
GROQ_API_KEY: process.env["GROQ_API_KEY"] || void 0,
|
|
8537
|
-
GROK_API_KEY: process.env["GROK_API_KEY"] || process.env["XAI_API_KEY"] || void 0
|
|
8538
|
-
},
|
|
8539
|
-
localProviders: {
|
|
8540
|
-
lmstudio: _ConfigManagerV2.parseBool(
|
|
8541
|
-
process.env["LMSTUDIO_ENABLED"],
|
|
8542
|
-
true
|
|
8543
|
-
),
|
|
8544
|
-
ollama: _ConfigManagerV2.parseBool(process.env["OLLAMA_ENABLED"], true),
|
|
8545
|
-
vllm: _ConfigManagerV2.parseBool(process.env["VLLM_ENABLED"], true)
|
|
8546
|
-
},
|
|
8547
|
-
autoStart: _ConfigManagerV2.parseBool(
|
|
8548
|
-
process.env["AUTO_START_LLMS"],
|
|
8549
|
-
true
|
|
8550
|
-
),
|
|
8551
|
-
healthMonitoring: _ConfigManagerV2.parseBool(
|
|
8552
|
-
process.env["HEALTH_MONITORING"],
|
|
8553
|
-
true
|
|
8554
|
-
),
|
|
8555
|
-
// Advanced environment settings
|
|
8556
|
-
maxRetries: _ConfigManagerV2.parseNumber(process.env["MARIA_MAX_RETRIES"]),
|
|
8557
|
-
timeout: _ConfigManagerV2.parseNumber(process.env["MARIA_TIMEOUT"]),
|
|
8558
|
-
concurrentRequests: _ConfigManagerV2.parseNumber(
|
|
8559
|
-
process.env["MARIA_CONCURRENT_REQUESTS"]
|
|
8560
|
-
),
|
|
8561
|
-
cacheEnabled: _ConfigManagerV2.parseBool(
|
|
8562
|
-
process.env["MARIA_CACHE_ENABLED"]
|
|
8563
|
-
),
|
|
8564
|
-
logLevel: process.env["MARIA_LOG_LEVEL"] || process.env["LOG_LEVEL"] || void 0,
|
|
8565
|
-
telemetryEnabled: _ConfigManagerV2.parseBool(
|
|
8566
|
-
process.env["MARIA_TELEMETRY"],
|
|
8567
|
-
true
|
|
8568
|
-
)
|
|
8569
|
-
};
|
|
8570
|
-
const cleanedConfig = _ConfigManagerV2.removeUndefined(envConfig);
|
|
8571
|
-
return new _ConfigManagerV2(cleanedConfig, "env");
|
|
8572
|
-
}
|
|
8573
|
-
// Configuration hierarchy: defaults < file < env < CLI
|
|
8574
|
-
static async loadHierarchical(options = {}) {
|
|
8575
|
-
try {
|
|
8576
|
-
const manager = new _ConfigManagerV2({}, "defaults");
|
|
8577
|
-
try {
|
|
8578
|
-
const fileConfig = await _ConfigManagerV2.loadFromFile(
|
|
8579
|
-
options.configPath
|
|
8580
|
-
);
|
|
8581
|
-
if (fileConfig) {
|
|
8582
|
-
manager.mergeAndValidate(fileConfig, "file");
|
|
8583
|
-
}
|
|
8584
|
-
} catch (innerError) {
|
|
8585
|
-
console.warn(
|
|
8586
|
-
`Warning: Could not load config file - ${error instanceof Error ? error.message : "Unknown error"}`
|
|
8587
|
-
);
|
|
8588
|
-
}
|
|
8589
|
-
const envManager = _ConfigManagerV2.fromEnvironment();
|
|
8590
|
-
manager.mergeAndValidate(envManager.config, "env");
|
|
8591
|
-
if (options.cliOptions && Object.keys(options.cliOptions).length > 0) {
|
|
8592
|
-
manager.mergeAndValidate(options.cliOptions, "cli");
|
|
8593
|
-
}
|
|
8594
|
-
return manager;
|
|
8595
|
-
} catch (error2) {
|
|
8596
|
-
throw new ConfigLoadError(
|
|
8597
|
-
`Failed to load hierarchical configuration: ${error2 instanceof Error ? error2.message : "Unknown error"}`,
|
|
8598
|
-
error2 instanceof Error ? error2 : void 0
|
|
8599
|
-
);
|
|
8600
|
-
}
|
|
8601
|
-
}
|
|
8602
|
-
static removeUndefined(obj) {
|
|
8603
|
-
const result = {};
|
|
8604
|
-
for (const [key2, value] of Object.entries(obj)) {
|
|
8605
|
-
if (value !== void 0) {
|
|
8606
|
-
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
8607
|
-
const nested = _ConfigManagerV2.removeUndefined(value);
|
|
8608
|
-
if (Object.keys(nested).length > 0) {
|
|
8609
|
-
result[key2] = nested;
|
|
8610
|
-
}
|
|
8611
|
-
} else {
|
|
8612
|
-
result[key2] = value;
|
|
8613
|
-
}
|
|
8614
|
-
}
|
|
8615
|
-
}
|
|
8616
|
-
return result;
|
|
8617
|
-
}
|
|
8618
|
-
static async loadFromFile(configPath) {
|
|
8619
|
-
const { importNodeBuiltin: importNodeBuiltin2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
|
|
8620
|
-
const fs7 = await importNodeBuiltin2("fs");
|
|
8621
|
-
const _path = await importNodeBuiltin2("_path");
|
|
8622
|
-
const os5 = await importNodeBuiltin2("os");
|
|
8623
|
-
const targetPath = configPath || _path.join(os5.homedir(), ".maria", "config.json");
|
|
8624
|
-
try {
|
|
8625
|
-
const data2 = await fs7.promises.readFile(targetPath, "utf-8");
|
|
8626
|
-
return JSON.parse(data2);
|
|
8627
|
-
} catch (innerError) {
|
|
8628
|
-
if (error?.code === "ENOENT") {
|
|
8629
|
-
return null;
|
|
8630
|
-
}
|
|
8631
|
-
throw new ConfigLoadError(
|
|
8632
|
-
`Failed to load config from ${targetPath}: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
8633
|
-
error instanceof Error ? error : void 0
|
|
8634
|
-
);
|
|
8635
|
-
}
|
|
8636
|
-
}
|
|
8637
|
-
async save(configPath, options) {
|
|
8638
|
-
const { importNodeBuiltin: importNodeBuiltin2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
|
|
8639
|
-
const fs7 = await importNodeBuiltin2("fs");
|
|
8640
|
-
const _path = await importNodeBuiltin2("_path");
|
|
8641
|
-
const os5 = await importNodeBuiltin2("os");
|
|
8642
|
-
const targetPath = configPath || _path.join(os5.homedir(), ".maria", "config.json");
|
|
8643
|
-
try {
|
|
8644
|
-
if (options?.backup) {
|
|
8645
|
-
try {
|
|
8646
|
-
await fs7.promises.access(targetPath);
|
|
8647
|
-
const backupPath = `${targetPath}.backup.${Date.now()}`;
|
|
8648
|
-
await fs7.promises.copyFile(targetPath, backupPath);
|
|
8649
|
-
} catch {
|
|
8650
|
-
}
|
|
8651
|
-
}
|
|
8652
|
-
await fs7.promises.mkdir(_path.dirname(targetPath), { recursive: true });
|
|
8653
|
-
const dataToSave = this.getAll({
|
|
8654
|
-
maskSensitive: options?.maskSensitive ?? true,
|
|
8655
|
-
includeSourceMap: options?.includeSourceMap ?? false
|
|
8656
|
-
});
|
|
8657
|
-
await fs7.promises.writeFile(
|
|
8658
|
-
targetPath,
|
|
8659
|
-
JSON.stringify(dataToSave, null, 2),
|
|
8660
|
-
{ mode: 384 }
|
|
8661
|
-
);
|
|
8662
|
-
console.log(`\u2705 Configuration saved to ${targetPath}`);
|
|
8663
|
-
} catch (error2) {
|
|
8664
|
-
throw new ConfigLoadError(
|
|
8665
|
-
`Failed to save configuration to ${targetPath}: ${error2 instanceof Error ? error2.message : "Unknown error"}`,
|
|
8666
|
-
error2 instanceof Error ? error2 : void 0
|
|
8667
|
-
);
|
|
8668
|
-
}
|
|
8669
|
-
}
|
|
8670
|
-
// Enhanced loading with automatic fallback chain
|
|
8671
|
-
static async load(configPath) {
|
|
8672
|
-
try {
|
|
8673
|
-
return await _ConfigManagerV2.loadHierarchical({ configPath });
|
|
8674
|
-
} catch (innerError) {
|
|
8675
|
-
console.warn(
|
|
8676
|
-
"Hierarchical config loading failed, falling back to environment:",
|
|
8677
|
-
error
|
|
8678
|
-
);
|
|
8679
|
-
return _ConfigManagerV2.fromEnvironment();
|
|
8680
|
-
}
|
|
8681
|
-
}
|
|
8682
|
-
// Export configuration in various formats
|
|
8683
|
-
async export(format, outputPath) {
|
|
8684
|
-
const config2 = this.getAll({ maskSensitive: false });
|
|
8685
|
-
let content;
|
|
8686
|
-
switch (format) {
|
|
8687
|
-
case "json":
|
|
8688
|
-
content = JSON.stringify(config2, null, 2);
|
|
8689
|
-
break;
|
|
8690
|
-
case "yaml":
|
|
8691
|
-
content = this.toYamlLike(config2);
|
|
8692
|
-
break;
|
|
8693
|
-
case "env":
|
|
8694
|
-
content = this.toEnvFormat(config2);
|
|
8695
|
-
break;
|
|
8696
|
-
default:
|
|
8697
|
-
throw new Error(`Unsupported export format: ${format}`);
|
|
8698
|
-
}
|
|
8699
|
-
if (outputPath) {
|
|
8700
|
-
const { importNodeBuiltin: importNodeBuiltin2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
|
|
8701
|
-
const fs7 = await importNodeBuiltin2("fs");
|
|
8702
|
-
const _path = await importNodeBuiltin2(
|
|
8703
|
-
"_path"
|
|
8704
|
-
);
|
|
8705
|
-
await fs7.promises.mkdir(_path.dirname(outputPath), { recursive: true });
|
|
8706
|
-
await fs7.promises.writeFile(outputPath, content, "utf-8");
|
|
8707
|
-
console.log(`\u2705 Configuration exported to ${outputPath}`);
|
|
8708
|
-
}
|
|
8709
|
-
return content;
|
|
8710
|
-
}
|
|
8711
|
-
toEnvFormat(config2) {
|
|
8712
|
-
const envVars = [];
|
|
8713
|
-
const flatten = (obj, prefix = "") => {
|
|
8714
|
-
for (const [key2, value] of Object.entries(obj)) {
|
|
8715
|
-
const envKey = prefix ? `${prefix}_${key2.toUpperCase()}` : key2.toUpperCase();
|
|
8716
|
-
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
8717
|
-
flatten(value, envKey);
|
|
8718
|
-
} else if (Array.isArray(value)) {
|
|
8719
|
-
envVars.push(`${envKey}=${value.join(",")}`);
|
|
8720
|
-
} else {
|
|
8721
|
-
envVars.push(`${envKey}=${value}`);
|
|
8722
|
-
}
|
|
8723
|
-
}
|
|
8724
|
-
};
|
|
8725
|
-
flatten(config2, "MARIA");
|
|
8726
|
-
return envVars.join("\n");
|
|
8727
|
-
}
|
|
8728
|
-
// Configuration diff and merge preview
|
|
8729
|
-
previewMerge(newConfig) {
|
|
8730
|
-
const changes = [];
|
|
8731
|
-
const warnings = [];
|
|
8732
|
-
try {
|
|
8733
|
-
const mergedConfig = deepMerge(this.config, newConfig);
|
|
8734
|
-
const compareObjects = (current, updated, _path = "") => {
|
|
8735
|
-
const allKeys = /* @__PURE__ */ new Set([
|
|
8736
|
-
...Object.keys(current || object),
|
|
8737
|
-
...Object.keys(updated || object)
|
|
8738
|
-
]);
|
|
8739
|
-
for (const key2 of allKeys) {
|
|
8740
|
-
const fieldPath = _path ? `${_path}.${key2}` : key2;
|
|
8741
|
-
const currentValue = current?.[key2];
|
|
8742
|
-
const updatedValue = updated?.[key2];
|
|
8743
|
-
if (currentValue === void 0 && updatedValue !== void 0) {
|
|
8744
|
-
changes.push({
|
|
8745
|
-
field: fieldPath,
|
|
8746
|
-
current: void 0,
|
|
8747
|
-
new: updatedValue,
|
|
8748
|
-
action: "add"
|
|
8749
|
-
});
|
|
8750
|
-
} else if (currentValue !== void 0 && updatedValue === void 0) {
|
|
8751
|
-
changes.push({
|
|
8752
|
-
field: fieldPath,
|
|
8753
|
-
current: currentValue,
|
|
8754
|
-
new: void 0,
|
|
8755
|
-
action: "remove"
|
|
8756
|
-
});
|
|
8757
|
-
} else if (JSON.stringify(currentValue) !== JSON.stringify(updatedValue)) {
|
|
8758
|
-
if (typeof currentValue === "object" && typeof updatedValue === "object") {
|
|
8759
|
-
compareObjects(currentValue, updatedValue, fieldPath);
|
|
8760
|
-
} else {
|
|
8761
|
-
changes.push({
|
|
8762
|
-
field: fieldPath,
|
|
8763
|
-
current: currentValue,
|
|
8764
|
-
new: updatedValue,
|
|
8765
|
-
action: "update"
|
|
8766
|
-
});
|
|
8767
|
-
}
|
|
8768
|
-
}
|
|
8769
|
-
}
|
|
8770
|
-
};
|
|
8771
|
-
compareObjects(this.config, mergedConfig);
|
|
8772
|
-
try {
|
|
8773
|
-
this.validateAndTransform(mergedConfig);
|
|
8774
|
-
} catch (error2) {
|
|
8775
|
-
if (error2 instanceof ConfigValidationError) {
|
|
8776
|
-
warnings.push(`Validation warning: ${error2.message}`);
|
|
8193
|
+
try {
|
|
8194
|
+
const { importNodeBuiltin: importNodeBuiltin2, safeDynamicImport: safeDynamicImport2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
|
|
8195
|
+
const fs7 = await safeDynamicImport2("fs-extra").catch(
|
|
8196
|
+
() => importNodeBuiltin2("fs")
|
|
8197
|
+
);
|
|
8198
|
+
const _path = await importNodeBuiltin2("_path");
|
|
8199
|
+
const _envPath = _path.join(process.cwd(), ".env.local");
|
|
8200
|
+
if (await fs7.pathExists(_envPath)) {
|
|
8201
|
+
const _envContent = await fs7.readFile(_envPath, "utf-8");
|
|
8202
|
+
console.log("Loading environment from:", _envPath);
|
|
8203
|
+
environmentLoaded = true;
|
|
8204
|
+
const _lines = _envContent.split("\n");
|
|
8205
|
+
for (const line of _lines) {
|
|
8206
|
+
const _trimmed = line.trim();
|
|
8207
|
+
if (_trimmed && !_trimmed.startsWith("#")) {
|
|
8208
|
+
const _equalIndex = _trimmed.indexOf("=");
|
|
8209
|
+
if (_equalIndex > 0) {
|
|
8210
|
+
const _key = _trimmed.substring(0, _equalIndex).trim();
|
|
8211
|
+
const _value = _trimmed.substring(_equalIndex + 1).trim();
|
|
8212
|
+
if (_key && _value && !process.env[_key]) {
|
|
8213
|
+
const _cleanValue = _value.replace(/^["']|["']$/g, "");
|
|
8214
|
+
process.env[_key] = _cleanValue;
|
|
8777
8215
|
}
|
|
8778
8216
|
}
|
|
8779
|
-
} catch (innerError) {
|
|
8780
|
-
warnings.push(
|
|
8781
|
-
`Merge preview failed: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
8782
|
-
);
|
|
8783
8217
|
}
|
|
8784
|
-
return { changes, warnings };
|
|
8785
8218
|
}
|
|
8786
|
-
}
|
|
8219
|
+
}
|
|
8220
|
+
} catch (_error) {
|
|
8221
|
+
}
|
|
8222
|
+
}
|
|
8223
|
+
var environmentLoaded;
|
|
8224
|
+
var init_loader = __esm({
|
|
8225
|
+
"src/config/loader.ts"() {
|
|
8226
|
+
"use strict";
|
|
8227
|
+
environmentLoaded = false;
|
|
8228
|
+
}
|
|
8229
|
+
});
|
|
8230
|
+
|
|
8231
|
+
// src/config/models.ts
|
|
8232
|
+
var init_models = __esm({
|
|
8233
|
+
"src/config/models.ts"() {
|
|
8234
|
+
"use strict";
|
|
8235
|
+
}
|
|
8236
|
+
});
|
|
8237
|
+
|
|
8238
|
+
// src/config/index.ts
|
|
8239
|
+
var init_config2 = __esm({
|
|
8240
|
+
"src/config/index.ts"() {
|
|
8241
|
+
"use strict";
|
|
8242
|
+
init_models();
|
|
8787
8243
|
}
|
|
8788
8244
|
});
|
|
8789
8245
|
|
|
@@ -12218,8 +11674,8 @@ var init_SessionStateMachine = __esm({
|
|
|
12218
11674
|
this.controller = void 0;
|
|
12219
11675
|
return this.to("Completed");
|
|
12220
11676
|
}
|
|
12221
|
-
fail(
|
|
12222
|
-
this._ctx.meta = { ...this._ctx.meta || {}, error
|
|
11677
|
+
fail(error) {
|
|
11678
|
+
this._ctx.meta = { ...this._ctx.meta || {}, error };
|
|
12223
11679
|
this.inflight = false;
|
|
12224
11680
|
this.clearDeadline();
|
|
12225
11681
|
this.controller = void 0;
|
|
@@ -12253,32 +11709,32 @@ var init_SessionStateMachine = __esm({
|
|
|
12253
11709
|
});
|
|
12254
11710
|
|
|
12255
11711
|
// src/services/interactive-session/types/errors.ts
|
|
12256
|
-
function isSessionError(
|
|
12257
|
-
return
|
|
11712
|
+
function isSessionError(error) {
|
|
11713
|
+
return error instanceof SessionError;
|
|
12258
11714
|
}
|
|
12259
|
-
function isRecoverableError(
|
|
12260
|
-
if (isSessionError(
|
|
12261
|
-
return
|
|
11715
|
+
function isRecoverableError(error) {
|
|
11716
|
+
if (isSessionError(error)) {
|
|
11717
|
+
return error.recoverable;
|
|
12262
11718
|
}
|
|
12263
11719
|
return false;
|
|
12264
11720
|
}
|
|
12265
|
-
function toSessionError(
|
|
12266
|
-
if (isSessionError(
|
|
12267
|
-
return
|
|
11721
|
+
function toSessionError(error) {
|
|
11722
|
+
if (isSessionError(error)) {
|
|
11723
|
+
return error;
|
|
12268
11724
|
}
|
|
12269
|
-
if (
|
|
12270
|
-
if (
|
|
12271
|
-
return new UserCancelError(
|
|
11725
|
+
if (error instanceof Error) {
|
|
11726
|
+
if (error.message.includes("cancel") || error.message.includes("abort")) {
|
|
11727
|
+
return new UserCancelError(error.message);
|
|
12272
11728
|
}
|
|
12273
|
-
if (
|
|
12274
|
-
return new DeadlineError(
|
|
11729
|
+
if (error.message.includes("timeout") || error.message.includes("deadline")) {
|
|
11730
|
+
return new DeadlineError(error.message, 15e3);
|
|
12275
11731
|
}
|
|
12276
|
-
if (
|
|
12277
|
-
return new NetworkError(
|
|
11732
|
+
if (error.message.includes("network") || error.message.includes("fetch")) {
|
|
11733
|
+
return new NetworkError(error.message);
|
|
12278
11734
|
}
|
|
12279
|
-
return new InternalError(
|
|
11735
|
+
return new InternalError(error.message, error);
|
|
12280
11736
|
}
|
|
12281
|
-
return new InternalError(String(
|
|
11737
|
+
return new InternalError(String(error), error);
|
|
12282
11738
|
}
|
|
12283
11739
|
var SessionError, UserCancelError, DeadlineError, InternalError, NetworkError;
|
|
12284
11740
|
var init_errors = __esm({
|
|
@@ -12356,8 +11812,8 @@ var init_SessionManager = __esm({
|
|
|
12356
11812
|
while (this.running) {
|
|
12357
11813
|
try {
|
|
12358
11814
|
await this.runTurn();
|
|
12359
|
-
} catch (
|
|
12360
|
-
const sessionError = toSessionError(
|
|
11815
|
+
} catch (error) {
|
|
11816
|
+
const sessionError = toSessionError(error);
|
|
12361
11817
|
this.display.error(`Session error: ${sessionError.message}`);
|
|
12362
11818
|
if (!isRecoverableError(sessionError)) {
|
|
12363
11819
|
this.display.error("Fatal error, ending session");
|
|
@@ -12444,12 +11900,12 @@ var init_SessionManager = __esm({
|
|
|
12444
11900
|
);
|
|
12445
11901
|
}
|
|
12446
11902
|
this.fsm.send({ type: "STREAM_DONE" });
|
|
12447
|
-
} catch (
|
|
11903
|
+
} catch (error) {
|
|
12448
11904
|
if (this.currentSpinnerId) {
|
|
12449
11905
|
this.display.stopSpinner(this.currentSpinnerId);
|
|
12450
11906
|
this.currentSpinnerId = void 0;
|
|
12451
11907
|
}
|
|
12452
|
-
const sessionError = toSessionError(
|
|
11908
|
+
const sessionError = toSessionError(error);
|
|
12453
11909
|
metric.errorCode = sessionError.code;
|
|
12454
11910
|
if (sessionError instanceof DeadlineError) {
|
|
12455
11911
|
metric.deadline = true;
|
|
@@ -12478,11 +11934,11 @@ var init_SessionManager = __esm({
|
|
|
12478
11934
|
return null;
|
|
12479
11935
|
}
|
|
12480
11936
|
return input4.trim();
|
|
12481
|
-
} catch (
|
|
11937
|
+
} catch (error) {
|
|
12482
11938
|
if (this.fsm.signal?.aborted) {
|
|
12483
11939
|
throw new DeadlineError("Input timeout", this.options.deadlineMs);
|
|
12484
11940
|
}
|
|
12485
|
-
throw
|
|
11941
|
+
throw error;
|
|
12486
11942
|
}
|
|
12487
11943
|
}
|
|
12488
11944
|
/**
|
|
@@ -12763,9 +12219,9 @@ var init_ChalkAdapter = __esm({
|
|
|
12763
12219
|
if (signal?.aborted) break;
|
|
12764
12220
|
process.stdout.write(chunk);
|
|
12765
12221
|
}
|
|
12766
|
-
} catch (
|
|
12222
|
+
} catch (error) {
|
|
12767
12223
|
if (!signal?.aborted) {
|
|
12768
|
-
throw
|
|
12224
|
+
throw error;
|
|
12769
12225
|
}
|
|
12770
12226
|
} finally {
|
|
12771
12227
|
process.stdout.write("\n");
|
|
@@ -14934,8 +14390,8 @@ var init_SlashCommandHandler = __esm({
|
|
|
14934
14390
|
return await this.executeWithTimeout(command, context2, options.timeout);
|
|
14935
14391
|
}
|
|
14936
14392
|
return await command.execute(context2);
|
|
14937
|
-
} catch (
|
|
14938
|
-
if (
|
|
14393
|
+
} catch (error) {
|
|
14394
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
14939
14395
|
return {
|
|
14940
14396
|
success: false,
|
|
14941
14397
|
error: "Command execution timed out",
|
|
@@ -14944,7 +14400,7 @@ var init_SlashCommandHandler = __esm({
|
|
|
14944
14400
|
}
|
|
14945
14401
|
return {
|
|
14946
14402
|
success: false,
|
|
14947
|
-
error:
|
|
14403
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
14948
14404
|
messages: []
|
|
14949
14405
|
};
|
|
14950
14406
|
}
|
|
@@ -14963,9 +14419,9 @@ var init_SlashCommandHandler = __esm({
|
|
|
14963
14419
|
const result = await command.execute(contextWithSignal);
|
|
14964
14420
|
clearTimeout(timeoutId);
|
|
14965
14421
|
return result;
|
|
14966
|
-
} catch (
|
|
14422
|
+
} catch (error) {
|
|
14967
14423
|
clearTimeout(timeoutId);
|
|
14968
|
-
throw
|
|
14424
|
+
throw error;
|
|
14969
14425
|
}
|
|
14970
14426
|
}
|
|
14971
14427
|
/**
|
|
@@ -15206,10 +14662,10 @@ var init_MemoryService = __esm({
|
|
|
15206
14662
|
}
|
|
15207
14663
|
});
|
|
15208
14664
|
this.warmupInBackground();
|
|
15209
|
-
} catch (
|
|
14665
|
+
} catch (error) {
|
|
15210
14666
|
this._initialized = false;
|
|
15211
14667
|
this._initializationPromise = null;
|
|
15212
|
-
throw new Error(`Memory system initialization failed: ${
|
|
14668
|
+
throw new Error(`Memory system initialization failed: ${error}`);
|
|
15213
14669
|
}
|
|
15214
14670
|
}
|
|
15215
14671
|
/**
|
|
@@ -15221,8 +14677,8 @@ var init_MemoryService = __esm({
|
|
|
15221
14677
|
try {
|
|
15222
14678
|
this._engine?.loadInitialContext();
|
|
15223
14679
|
this._engine?.preloadCache();
|
|
15224
|
-
} catch (
|
|
15225
|
-
console.warn("Memory warmup warning:",
|
|
14680
|
+
} catch (error) {
|
|
14681
|
+
console.warn("Memory warmup warning:", error);
|
|
15226
14682
|
}
|
|
15227
14683
|
});
|
|
15228
14684
|
}
|
|
@@ -15344,60 +14800,60 @@ var init_MemoryService = __esm({
|
|
|
15344
14800
|
});
|
|
15345
14801
|
|
|
15346
14802
|
// src/services/interactive-session/services/ConfigService.ts
|
|
15347
|
-
var fs2, path2,
|
|
14803
|
+
var fs2, path2, import_zod, SessionConfigSchema, ConfigService;
|
|
15348
14804
|
var init_ConfigService = __esm({
|
|
15349
14805
|
"src/services/interactive-session/services/ConfigService.ts"() {
|
|
15350
14806
|
"use strict";
|
|
15351
14807
|
fs2 = __toESM(require("fs/promises"), 1);
|
|
15352
14808
|
path2 = __toESM(require("path"), 1);
|
|
15353
|
-
|
|
15354
|
-
SessionConfigSchema =
|
|
15355
|
-
ui:
|
|
15356
|
-
theme:
|
|
15357
|
-
colors:
|
|
15358
|
-
primary:
|
|
15359
|
-
success:
|
|
15360
|
-
warning:
|
|
15361
|
-
error:
|
|
15362
|
-
info:
|
|
14809
|
+
import_zod = require("zod");
|
|
14810
|
+
SessionConfigSchema = import_zod.z.object({
|
|
14811
|
+
ui: import_zod.z.object({
|
|
14812
|
+
theme: import_zod.z.enum(["default", "dark", "light", "solarized"]).default("default"),
|
|
14813
|
+
colors: import_zod.z.object({
|
|
14814
|
+
primary: import_zod.z.string().default("#00A8E8"),
|
|
14815
|
+
success: import_zod.z.string().default("#00C851"),
|
|
14816
|
+
warning: import_zod.z.string().default("#FFB300"),
|
|
14817
|
+
error: import_zod.z.string().default("#FF3547"),
|
|
14818
|
+
info: import_zod.z.string().default("#33B5E5")
|
|
15363
14819
|
}).default({}),
|
|
15364
|
-
spinner:
|
|
15365
|
-
style:
|
|
15366
|
-
color:
|
|
14820
|
+
spinner: import_zod.z.object({
|
|
14821
|
+
style: import_zod.z.enum(["dots", "line", "star", "square"]).default("dots"),
|
|
14822
|
+
color: import_zod.z.string().default("cyan")
|
|
15367
14823
|
}).default({}),
|
|
15368
|
-
showTimestamps:
|
|
15369
|
-
showDebugInfo:
|
|
14824
|
+
showTimestamps: import_zod.z.boolean().default(false),
|
|
14825
|
+
showDebugInfo: import_zod.z.boolean().default(false)
|
|
15370
14826
|
}).default({}),
|
|
15371
|
-
behavior:
|
|
15372
|
-
autoApproval:
|
|
15373
|
-
confirmBeforeExit:
|
|
15374
|
-
historySize:
|
|
15375
|
-
commandTimeout:
|
|
14827
|
+
behavior: import_zod.z.object({
|
|
14828
|
+
autoApproval: import_zod.z.boolean().default(false),
|
|
14829
|
+
confirmBeforeExit: import_zod.z.boolean().default(true),
|
|
14830
|
+
historySize: import_zod.z.number().min(0).max(1e4).default(1e3),
|
|
14831
|
+
commandTimeout: import_zod.z.number().min(0).default(3e4),
|
|
15376
14832
|
// 30秒
|
|
15377
|
-
retryAttempts:
|
|
15378
|
-
streamingEnabled:
|
|
14833
|
+
retryAttempts: import_zod.z.number().min(0).max(10).default(3),
|
|
14834
|
+
streamingEnabled: import_zod.z.boolean().default(true)
|
|
15379
14835
|
}).default({}),
|
|
15380
|
-
memory:
|
|
15381
|
-
enablePersistence:
|
|
15382
|
-
maxMemoryUsage:
|
|
14836
|
+
memory: import_zod.z.object({
|
|
14837
|
+
enablePersistence: import_zod.z.boolean().default(false),
|
|
14838
|
+
maxMemoryUsage: import_zod.z.number().min(0).default(512),
|
|
15383
14839
|
// MB
|
|
15384
|
-
cacheSize:
|
|
14840
|
+
cacheSize: import_zod.z.number().min(0).default(100),
|
|
15385
14841
|
// MB
|
|
15386
|
-
gcInterval:
|
|
14842
|
+
gcInterval: import_zod.z.number().min(0).default(3e5)
|
|
15387
14843
|
// 5分
|
|
15388
14844
|
}).default({}),
|
|
15389
|
-
shortcuts:
|
|
14845
|
+
shortcuts: import_zod.z.record(import_zod.z.string()).default({
|
|
15390
14846
|
clear: "cls",
|
|
15391
14847
|
quit: "exit",
|
|
15392
14848
|
h: "help",
|
|
15393
14849
|
s: "status",
|
|
15394
14850
|
m: "models"
|
|
15395
14851
|
}),
|
|
15396
|
-
advanced:
|
|
15397
|
-
debugMode:
|
|
15398
|
-
verboseLogging:
|
|
15399
|
-
experimentalFeatures:
|
|
15400
|
-
telemetryEnabled:
|
|
14852
|
+
advanced: import_zod.z.object({
|
|
14853
|
+
debugMode: import_zod.z.boolean().default(false),
|
|
14854
|
+
verboseLogging: import_zod.z.boolean().default(false),
|
|
14855
|
+
experimentalFeatures: import_zod.z.boolean().default(false),
|
|
14856
|
+
telemetryEnabled: import_zod.z.boolean().default(false)
|
|
15401
14857
|
}).default({})
|
|
15402
14858
|
});
|
|
15403
14859
|
ConfigService = class {
|
|
@@ -15435,7 +14891,7 @@ var init_ConfigService = __esm({
|
|
|
15435
14891
|
try {
|
|
15436
14892
|
const configFile = await fs2.readFile(this._configPath, "utf-8");
|
|
15437
14893
|
return JSON.parse(configFile);
|
|
15438
|
-
} catch (
|
|
14894
|
+
} catch (error) {
|
|
15439
14895
|
return {};
|
|
15440
14896
|
}
|
|
15441
14897
|
}
|
|
@@ -15446,7 +14902,7 @@ var init_ConfigService = __esm({
|
|
|
15446
14902
|
try {
|
|
15447
14903
|
const configFile = await fs2.readFile(this._userConfigPath, "utf-8");
|
|
15448
14904
|
return JSON.parse(configFile);
|
|
15449
|
-
} catch (
|
|
14905
|
+
} catch (error) {
|
|
15450
14906
|
return {};
|
|
15451
14907
|
}
|
|
15452
14908
|
}
|
|
@@ -15471,11 +14927,11 @@ var init_ConfigService = __esm({
|
|
|
15471
14927
|
validateConfig() {
|
|
15472
14928
|
try {
|
|
15473
14929
|
SessionConfigSchema.parse(this._config);
|
|
15474
|
-
} catch (
|
|
15475
|
-
if (
|
|
15476
|
-
throw new Error(`Configuration validation failed: ${
|
|
14930
|
+
} catch (error) {
|
|
14931
|
+
if (error instanceof import_zod.z.ZodError) {
|
|
14932
|
+
throw new Error(`Configuration validation failed: ${error.message}`);
|
|
15477
14933
|
}
|
|
15478
|
-
throw
|
|
14934
|
+
throw error;
|
|
15479
14935
|
}
|
|
15480
14936
|
}
|
|
15481
14937
|
/**
|
|
@@ -15554,8 +15010,8 @@ var init_ConfigService = __esm({
|
|
|
15554
15010
|
"utf-8"
|
|
15555
15011
|
);
|
|
15556
15012
|
this._isDirty = false;
|
|
15557
|
-
} catch (
|
|
15558
|
-
throw new Error(`Failed to save configuration: ${
|
|
15013
|
+
} catch (error) {
|
|
15014
|
+
throw new Error(`Failed to save configuration: ${error}`);
|
|
15559
15015
|
}
|
|
15560
15016
|
}
|
|
15561
15017
|
/**
|
|
@@ -15566,8 +15022,8 @@ var init_ConfigService = __esm({
|
|
|
15566
15022
|
clearTimeout(this._saveDebounceTimer);
|
|
15567
15023
|
}
|
|
15568
15024
|
this._saveDebounceTimer = setTimeout(() => {
|
|
15569
|
-
this.save().catch((
|
|
15570
|
-
console.error("Auto-save failed:",
|
|
15025
|
+
this.save().catch((error) => {
|
|
15026
|
+
console.error("Auto-save failed:", error);
|
|
15571
15027
|
});
|
|
15572
15028
|
}, 5e3);
|
|
15573
15029
|
}
|
|
@@ -15822,8 +15278,8 @@ var init_RouterService = __esm({
|
|
|
15822
15278
|
),
|
|
15823
15279
|
metadata: analysis2.metadata
|
|
15824
15280
|
};
|
|
15825
|
-
} catch (
|
|
15826
|
-
console.warn("Intelligent routing failed:",
|
|
15281
|
+
} catch (error) {
|
|
15282
|
+
console.warn("Intelligent routing failed:", error);
|
|
15827
15283
|
return {
|
|
15828
15284
|
type: "conversation",
|
|
15829
15285
|
confidence: 0.3
|
|
@@ -16046,11 +15502,11 @@ var init_RouterService = __esm({
|
|
|
16046
15502
|
});
|
|
16047
15503
|
|
|
16048
15504
|
// src/services/interactive-session/services/ValidationService.ts
|
|
16049
|
-
var
|
|
15505
|
+
var import_zod2, ValidationService;
|
|
16050
15506
|
var init_ValidationService = __esm({
|
|
16051
15507
|
"src/services/interactive-session/services/ValidationService.ts"() {
|
|
16052
15508
|
"use strict";
|
|
16053
|
-
|
|
15509
|
+
import_zod2 = require("zod");
|
|
16054
15510
|
ValidationService = class {
|
|
16055
15511
|
_config;
|
|
16056
15512
|
_customRules = /* @__PURE__ */ new Map();
|
|
@@ -16082,23 +15538,23 @@ var init_ValidationService = __esm({
|
|
|
16082
15538
|
initializeSchemas() {
|
|
16083
15539
|
this._schemas.set(
|
|
16084
15540
|
"command",
|
|
16085
|
-
|
|
16086
|
-
name:
|
|
16087
|
-
args:
|
|
16088
|
-
flags:
|
|
15541
|
+
import_zod2.z.object({
|
|
15542
|
+
name: import_zod2.z.string().min(1).max(50),
|
|
15543
|
+
args: import_zod2.z.array(import_zod2.z.string()).max(this._config.maxCommandArgs),
|
|
15544
|
+
flags: import_zod2.z.record(import_zod2.z.string()).optional()
|
|
16089
15545
|
})
|
|
16090
15546
|
);
|
|
16091
15547
|
this._schemas.set(
|
|
16092
15548
|
"filePath",
|
|
16093
|
-
|
|
15549
|
+
import_zod2.z.string().min(1).max(this._config.maxFilePathLength).refine((path7) => !this.containsPathTraversal(path7), {
|
|
16094
15550
|
message: "Path traversal detected"
|
|
16095
15551
|
})
|
|
16096
15552
|
);
|
|
16097
|
-
this._schemas.set("url",
|
|
16098
|
-
this._schemas.set("email",
|
|
15553
|
+
this._schemas.set("url", import_zod2.z.string().url());
|
|
15554
|
+
this._schemas.set("email", import_zod2.z.string().email());
|
|
16099
15555
|
this._schemas.set(
|
|
16100
15556
|
"configValue",
|
|
16101
|
-
|
|
15557
|
+
import_zod2.z.union([import_zod2.z.string(), import_zod2.z.number(), import_zod2.z.boolean(), import_zod2.z.record(import_zod2.z.any())])
|
|
16102
15558
|
);
|
|
16103
15559
|
}
|
|
16104
15560
|
/**
|
|
@@ -16201,11 +15657,11 @@ var init_ValidationService = __esm({
|
|
|
16201
15657
|
valid: true,
|
|
16202
15658
|
value: result
|
|
16203
15659
|
};
|
|
16204
|
-
} catch (
|
|
16205
|
-
if (
|
|
15660
|
+
} catch (error) {
|
|
15661
|
+
if (error instanceof import_zod2.z.ZodError) {
|
|
16206
15662
|
return {
|
|
16207
15663
|
valid: false,
|
|
16208
|
-
errors:
|
|
15664
|
+
errors: error.errors.map((e2) => ({
|
|
16209
15665
|
field: e2.path.join("."),
|
|
16210
15666
|
message: e2.message,
|
|
16211
15667
|
code: e2.code,
|
|
@@ -16250,11 +15706,11 @@ var init_ValidationService = __esm({
|
|
|
16250
15706
|
valid: true,
|
|
16251
15707
|
value: result
|
|
16252
15708
|
};
|
|
16253
|
-
} catch (
|
|
16254
|
-
if (
|
|
15709
|
+
} catch (error) {
|
|
15710
|
+
if (error instanceof import_zod2.z.ZodError) {
|
|
16255
15711
|
return {
|
|
16256
15712
|
valid: false,
|
|
16257
|
-
errors:
|
|
15713
|
+
errors: error.errors.map((e2) => ({
|
|
16258
15714
|
field: "path",
|
|
16259
15715
|
message: e2.message,
|
|
16260
15716
|
code: e2.code,
|
|
@@ -16301,7 +15757,7 @@ var init_ValidationService = __esm({
|
|
|
16301
15757
|
valid: true,
|
|
16302
15758
|
value: result
|
|
16303
15759
|
};
|
|
16304
|
-
} catch (
|
|
15760
|
+
} catch (error) {
|
|
16305
15761
|
return {
|
|
16306
15762
|
valid: false,
|
|
16307
15763
|
errors: [
|
|
@@ -16326,7 +15782,7 @@ var init_ValidationService = __esm({
|
|
|
16326
15782
|
valid: true,
|
|
16327
15783
|
value: result
|
|
16328
15784
|
};
|
|
16329
|
-
} catch (
|
|
15785
|
+
} catch (error) {
|
|
16330
15786
|
return {
|
|
16331
15787
|
valid: false,
|
|
16332
15788
|
errors: [
|
|
@@ -19164,9 +18620,9 @@ var init_CommandRegistry = __esm({
|
|
|
19164
18620
|
});
|
|
19165
18621
|
clearTimeout(timer);
|
|
19166
18622
|
return result;
|
|
19167
|
-
} catch (
|
|
18623
|
+
} catch (error) {
|
|
19168
18624
|
clearTimeout(timer);
|
|
19169
|
-
throw
|
|
18625
|
+
throw error;
|
|
19170
18626
|
}
|
|
19171
18627
|
}
|
|
19172
18628
|
return registration.handler.execute(context2);
|
|
@@ -19405,9 +18861,9 @@ var init_SpinnerManager = __esm({
|
|
|
19405
18861
|
const result = await fn();
|
|
19406
18862
|
this.stop(spinnerId, "success");
|
|
19407
18863
|
return result;
|
|
19408
|
-
} catch (
|
|
18864
|
+
} catch (error) {
|
|
19409
18865
|
this.stop(spinnerId, "fail");
|
|
19410
|
-
throw
|
|
18866
|
+
throw error;
|
|
19411
18867
|
}
|
|
19412
18868
|
}
|
|
19413
18869
|
/**
|
|
@@ -19799,9 +19255,9 @@ var init_DisplayManager = __esm({
|
|
|
19799
19255
|
process.on("exit", cleanup);
|
|
19800
19256
|
process.on("SIGINT", cleanup);
|
|
19801
19257
|
process.on("SIGTERM", cleanup);
|
|
19802
|
-
process.on("uncaughtException", (
|
|
19258
|
+
process.on("uncaughtException", (error) => {
|
|
19803
19259
|
cleanup();
|
|
19804
|
-
console.error("Uncaught exception:",
|
|
19260
|
+
console.error("Uncaught exception:", error);
|
|
19805
19261
|
process.exit(1);
|
|
19806
19262
|
});
|
|
19807
19263
|
}
|
|
@@ -20349,10 +19805,10 @@ export { generated };`;
|
|
|
20349
19805
|
requiresInput: false
|
|
20350
19806
|
// Important: prevent re-dispatch
|
|
20351
19807
|
};
|
|
20352
|
-
} catch (
|
|
19808
|
+
} catch (error) {
|
|
20353
19809
|
return {
|
|
20354
19810
|
ok: false,
|
|
20355
|
-
message: import_chalk11.default.red(`Code generation failed: ${
|
|
19811
|
+
message: import_chalk11.default.red(`Code generation failed: ${error}`)
|
|
20356
19812
|
};
|
|
20357
19813
|
}
|
|
20358
19814
|
}
|
|
@@ -21079,9 +20535,9 @@ var init_SessionOrchestrator = __esm({
|
|
|
21079
20535
|
await this.setupCommandRegistry();
|
|
21080
20536
|
await this.initializeSessionManager();
|
|
21081
20537
|
this._initialized = true;
|
|
21082
|
-
} catch (
|
|
20538
|
+
} catch (error) {
|
|
21083
20539
|
await this.cleanup();
|
|
21084
|
-
throw new Error(`SessionOrchestrator initialization failed: ${
|
|
20540
|
+
throw new Error(`SessionOrchestrator initialization failed: ${error}`);
|
|
21085
20541
|
}
|
|
21086
20542
|
}
|
|
21087
20543
|
/**
|
|
@@ -21225,9 +20681,9 @@ var init_SessionOrchestrator = __esm({
|
|
|
21225
20681
|
if (this._sessionManager) {
|
|
21226
20682
|
await this._sessionManager.start();
|
|
21227
20683
|
}
|
|
21228
|
-
} catch (
|
|
20684
|
+
} catch (error) {
|
|
21229
20685
|
this._running = false;
|
|
21230
|
-
throw
|
|
20686
|
+
throw error;
|
|
21231
20687
|
}
|
|
21232
20688
|
}
|
|
21233
20689
|
/**
|
|
@@ -21244,8 +20700,8 @@ var init_SessionOrchestrator = __esm({
|
|
|
21244
20700
|
}
|
|
21245
20701
|
await this.showGoodbye();
|
|
21246
20702
|
await this.cleanup();
|
|
21247
|
-
} catch (
|
|
21248
|
-
console.error("Error during session stop:",
|
|
20703
|
+
} catch (error) {
|
|
20704
|
+
console.error("Error during session stop:", error);
|
|
21249
20705
|
}
|
|
21250
20706
|
}
|
|
21251
20707
|
/**
|
|
@@ -21429,10 +20885,10 @@ var init_interactive_session = __esm({
|
|
|
21429
20885
|
message: `Command ${command} is being migrated to the new system`
|
|
21430
20886
|
};
|
|
21431
20887
|
}
|
|
21432
|
-
} catch (
|
|
20888
|
+
} catch (error) {
|
|
21433
20889
|
return {
|
|
21434
20890
|
ok: false,
|
|
21435
|
-
message: `Error executing command: ${
|
|
20891
|
+
message: `Error executing command: ${error}`
|
|
21436
20892
|
};
|
|
21437
20893
|
}
|
|
21438
20894
|
}
|
|
@@ -21516,7 +20972,7 @@ var init_package = __esm({
|
|
|
21516
20972
|
"package.json"() {
|
|
21517
20973
|
package_default = {
|
|
21518
20974
|
name: "@bonginkan/maria",
|
|
21519
|
-
version: "3.6.
|
|
20975
|
+
version: "3.6.2",
|
|
21520
20976
|
description: "\u{1F680} MARIA v3.6.0 - Premier Enterprise AI Development Platform. Revolutionary multimodal intelligence featuring advanced orchestration, production-grade telemetry, and sophisticated workflow templates. Delivers 93% performance enhancement with real-time TUI monitoring, ML-powered model selection, quantum-resistant security architecture, and comprehensive observability. Battle-tested for enterprise deployment with exceptional reliability.",
|
|
21521
20977
|
keywords: [
|
|
21522
20978
|
"ai",
|
|
@@ -21950,8 +21406,8 @@ var init_conversation_persistence = __esm({
|
|
|
21950
21406
|
try {
|
|
21951
21407
|
const configDir = path3.dirname(this.sessionFile);
|
|
21952
21408
|
await import_fs2.promises.mkdir(configDir, { recursive: true });
|
|
21953
|
-
} catch (
|
|
21954
|
-
console.warn("Failed to create config directory:",
|
|
21409
|
+
} catch (error) {
|
|
21410
|
+
console.warn("Failed to create config directory:", error);
|
|
21955
21411
|
}
|
|
21956
21412
|
}
|
|
21957
21413
|
/**
|
|
@@ -21998,8 +21454,8 @@ var init_conversation_persistence = __esm({
|
|
|
21998
21454
|
}
|
|
21999
21455
|
};
|
|
22000
21456
|
await import_fs2.promises.writeFile(this.sessionFile, JSON.stringify(session, null, 2));
|
|
22001
|
-
} catch (
|
|
22002
|
-
console.warn("Failed to save conversation history:",
|
|
21457
|
+
} catch (error) {
|
|
21458
|
+
console.warn("Failed to save conversation history:", error);
|
|
22003
21459
|
}
|
|
22004
21460
|
}
|
|
22005
21461
|
/**
|
|
@@ -22025,7 +21481,7 @@ var init_conversation_persistence = __esm({
|
|
|
22025
21481
|
newestMessage: messages[messages.length - 1]?.timestamp,
|
|
22026
21482
|
fileSize: stats.size
|
|
22027
21483
|
};
|
|
22028
|
-
} catch (
|
|
21484
|
+
} catch (error) {
|
|
22029
21485
|
return {
|
|
22030
21486
|
totalMessages: 0
|
|
22031
21487
|
};
|
|
@@ -22228,10 +21684,10 @@ var init_chat_context_service = __esm({
|
|
|
22228
21684
|
};
|
|
22229
21685
|
await fs4.writeFile(sessionFile, JSON.stringify(sessionData, null, 2));
|
|
22230
21686
|
this.emit("session-persisted", sessionFile);
|
|
22231
|
-
} catch (
|
|
21687
|
+
} catch (error) {
|
|
22232
21688
|
this.emit(
|
|
22233
21689
|
"persist-error",
|
|
22234
|
-
|
|
21690
|
+
error instanceof Error ? error : new Error(String(error))
|
|
22235
21691
|
);
|
|
22236
21692
|
}
|
|
22237
21693
|
}
|
|
@@ -22931,14 +22387,14 @@ var init_telemetry_collector = __esm({
|
|
|
22931
22387
|
/**
|
|
22932
22388
|
* Track errors
|
|
22933
22389
|
*/
|
|
22934
|
-
trackError(
|
|
22390
|
+
trackError(error, context2) {
|
|
22935
22391
|
this.addEvent({
|
|
22936
22392
|
timestamp: Date.now(),
|
|
22937
22393
|
eventType: "error_occurred",
|
|
22938
22394
|
sessionId: this.sessionId,
|
|
22939
22395
|
data: {
|
|
22940
|
-
message:
|
|
22941
|
-
stack:
|
|
22396
|
+
message: error.message,
|
|
22397
|
+
stack: error.stack,
|
|
22942
22398
|
...context2
|
|
22943
22399
|
}
|
|
22944
22400
|
});
|
|
@@ -22965,8 +22421,8 @@ var init_telemetry_collector = __esm({
|
|
|
22965
22421
|
} else {
|
|
22966
22422
|
this.storeLocally(eventsToFlush);
|
|
22967
22423
|
}
|
|
22968
|
-
} catch (
|
|
22969
|
-
console.error("[Telemetry] Failed to flush events:",
|
|
22424
|
+
} catch (error) {
|
|
22425
|
+
console.error("[Telemetry] Failed to flush events:", error);
|
|
22970
22426
|
this.events.unshift(...eventsToFlush);
|
|
22971
22427
|
}
|
|
22972
22428
|
}
|
|
@@ -24019,7 +23475,7 @@ var init_ai_response_service = __esm({
|
|
|
24019
23475
|
await this.modernProviderManager.initialize();
|
|
24020
23476
|
}
|
|
24021
23477
|
this.initialized = true;
|
|
24022
|
-
} catch (
|
|
23478
|
+
} catch (error) {
|
|
24023
23479
|
try {
|
|
24024
23480
|
await this.legacyProviderFactory.initializeFromEnvironment();
|
|
24025
23481
|
this.initialized = true;
|
|
@@ -24040,7 +23496,7 @@ var init_ai_response_service = __esm({
|
|
|
24040
23496
|
} else {
|
|
24041
23497
|
try {
|
|
24042
23498
|
return await this.modernProviderManager.pick(DEFAULT_PROVIDER2);
|
|
24043
|
-
} catch (
|
|
23499
|
+
} catch (error) {
|
|
24044
23500
|
return this.legacyProviderFactory.getActiveProvider();
|
|
24045
23501
|
}
|
|
24046
23502
|
}
|
|
@@ -24324,7 +23780,7 @@ I'm here to assist you effectively!`;
|
|
|
24324
23780
|
});
|
|
24325
23781
|
|
|
24326
23782
|
// src/shared/adapters/LegacySlashCommandAdapter.ts
|
|
24327
|
-
var LegacySlashCommandAdapter,
|
|
23783
|
+
var LegacySlashCommandAdapter, SlashCommandHandler2;
|
|
24328
23784
|
var init_LegacySlashCommandAdapter = __esm({
|
|
24329
23785
|
"src/shared/adapters/LegacySlashCommandAdapter.ts"() {
|
|
24330
23786
|
"use strict";
|
|
@@ -24365,10 +23821,10 @@ var init_LegacySlashCommandAdapter = __esm({
|
|
|
24365
23821
|
error: result.error,
|
|
24366
23822
|
messages: result.messages || []
|
|
24367
23823
|
};
|
|
24368
|
-
} catch (
|
|
23824
|
+
} catch (error) {
|
|
24369
23825
|
return {
|
|
24370
23826
|
success: false,
|
|
24371
|
-
error:
|
|
23827
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
24372
23828
|
messages: []
|
|
24373
23829
|
};
|
|
24374
23830
|
}
|
|
@@ -24388,10 +23844,10 @@ var init_LegacySlashCommandAdapter = __esm({
|
|
|
24388
23844
|
success: true,
|
|
24389
23845
|
messages: [{ role: "assistant", content: result }]
|
|
24390
23846
|
};
|
|
24391
|
-
} catch (
|
|
23847
|
+
} catch (error) {
|
|
24392
23848
|
return {
|
|
24393
23849
|
success: false,
|
|
24394
|
-
error:
|
|
23850
|
+
error: error instanceof Error ? error.message : "Command execution failed",
|
|
24395
23851
|
messages: []
|
|
24396
23852
|
};
|
|
24397
23853
|
}
|
|
@@ -24406,7 +23862,7 @@ var init_LegacySlashCommandAdapter = __esm({
|
|
|
24406
23862
|
return this.handler;
|
|
24407
23863
|
}
|
|
24408
23864
|
};
|
|
24409
|
-
|
|
23865
|
+
SlashCommandHandler2 = LegacySlashCommandAdapter;
|
|
24410
23866
|
}
|
|
24411
23867
|
});
|
|
24412
23868
|
|
|
@@ -27309,7 +26765,7 @@ async function readConfig() {
|
|
|
27309
26765
|
return _config;
|
|
27310
26766
|
}
|
|
27311
26767
|
var import_fs3, import_path2, import_toml, import_os, _CONFIG_FILE, _GLOBAL_CONFIG_PATH;
|
|
27312
|
-
var
|
|
26768
|
+
var init_config3 = __esm({
|
|
27313
26769
|
"src/utils/config.ts"() {
|
|
27314
26770
|
"use strict";
|
|
27315
26771
|
import_fs3 = require("fs");
|
|
@@ -27336,7 +26792,7 @@ var init_code_generation_service = __esm({
|
|
|
27336
26792
|
init_google_ai_provider();
|
|
27337
26793
|
init_lmstudio_provider();
|
|
27338
26794
|
init_default_provider();
|
|
27339
|
-
|
|
26795
|
+
init_config3();
|
|
27340
26796
|
fs6 = __toESM(require("fs/promises"), 1);
|
|
27341
26797
|
path6 = __toESM(require("path"), 1);
|
|
27342
26798
|
logger2 = logger;
|
|
@@ -27984,7 +27440,7 @@ async function initializeServices() {
|
|
|
27984
27440
|
conversationPersistence = new ConversationPersistence();
|
|
27985
27441
|
chatContext = ChatContextService.getInstance();
|
|
27986
27442
|
aiResponseService = new AIResponseService();
|
|
27987
|
-
slashCommandHandler =
|
|
27443
|
+
slashCommandHandler = SlashCommandHandler2.getInstance();
|
|
27988
27444
|
providerManager = new UnifiedAIProviderManager2();
|
|
27989
27445
|
try {
|
|
27990
27446
|
await providerManager.initialize();
|
|
@@ -28034,8 +27490,8 @@ async function initializeServices() {
|
|
|
28034
27490
|
sessionMemory.push(msg);
|
|
28035
27491
|
}
|
|
28036
27492
|
return true;
|
|
28037
|
-
} catch (
|
|
28038
|
-
console.error(import_chalk15.default.red("\u274C Service initialization failed:"),
|
|
27493
|
+
} catch (error) {
|
|
27494
|
+
console.error(import_chalk15.default.red("\u274C Service initialization failed:"), error);
|
|
28039
27495
|
return false;
|
|
28040
27496
|
}
|
|
28041
27497
|
}
|
|
@@ -28156,10 +27612,10 @@ async function startInteractiveSession() {
|
|
|
28156
27612
|
const errorMessage = result.message || result._message || "Command failed";
|
|
28157
27613
|
console.log(import_chalk15.default.red(`\u274C ${errorMessage}`));
|
|
28158
27614
|
}
|
|
28159
|
-
} catch (
|
|
27615
|
+
} catch (error) {
|
|
28160
27616
|
console.error(
|
|
28161
27617
|
import_chalk15.default.red("\u274C Command error:"),
|
|
28162
|
-
|
|
27618
|
+
error?.message || error
|
|
28163
27619
|
);
|
|
28164
27620
|
}
|
|
28165
27621
|
}
|
|
@@ -28245,10 +27701,10 @@ async function startInteractiveSession() {
|
|
|
28245
27701
|
console.log();
|
|
28246
27702
|
continue;
|
|
28247
27703
|
}
|
|
28248
|
-
} catch (
|
|
27704
|
+
} catch (error) {
|
|
28249
27705
|
console.error(
|
|
28250
27706
|
import_chalk15.default.red("\u274C SlashCommand error:"),
|
|
28251
|
-
|
|
27707
|
+
error?.message || error
|
|
28252
27708
|
);
|
|
28253
27709
|
console.log();
|
|
28254
27710
|
continue;
|
|
@@ -28290,7 +27746,7 @@ async function startInteractiveSession() {
|
|
|
28290
27746
|
if (conversationPersistence) {
|
|
28291
27747
|
await conversationPersistence.addMessage(assistantMessage);
|
|
28292
27748
|
}
|
|
28293
|
-
} catch (
|
|
27749
|
+
} catch (error) {
|
|
28294
27750
|
console.log(
|
|
28295
27751
|
import_chalk15.default.gray(
|
|
28296
27752
|
"\u26A0\uFE0F Persistent memory save failed, using session memory only"
|
|
@@ -28299,22 +27755,22 @@ async function startInteractiveSession() {
|
|
|
28299
27755
|
}
|
|
28300
27756
|
}
|
|
28301
27757
|
console.log();
|
|
28302
|
-
} catch (
|
|
28303
|
-
if (
|
|
27758
|
+
} catch (error) {
|
|
27759
|
+
if (error?.code === "ABORT_ERR" || error?.name === "AbortError") {
|
|
28304
27760
|
console.log(import_chalk15.default.cyan("\n\nGoodbye! \u{1F44B}"));
|
|
28305
27761
|
await stopAll();
|
|
28306
27762
|
return;
|
|
28307
27763
|
}
|
|
28308
27764
|
console.error(
|
|
28309
27765
|
import_chalk15.default.red("\u274C An error occurred:"),
|
|
28310
|
-
|
|
27766
|
+
error?.message || error
|
|
28311
27767
|
);
|
|
28312
27768
|
}
|
|
28313
27769
|
}
|
|
28314
27770
|
}
|
|
28315
27771
|
function createCLI() {
|
|
28316
27772
|
const program2 = new import_commander.Command();
|
|
28317
|
-
program2.name("maria").description(
|
|
27773
|
+
program2.name("maria").description(`\u{1F680} MARIA v${packageJson.version} - Intelligent AI Assistant`).version(packageJson.version).option("--v3-session", "Use v3 session architecture").option("--no-interactive", "Disable interactive mode for CI/CD").action(async (options) => {
|
|
28318
27774
|
const { displayFinalStartupScreen: displayFinalStartupScreen2 } = await Promise.resolve().then(() => (init_startup_display(), startup_display_exports));
|
|
28319
27775
|
displayFinalStartupScreen2();
|
|
28320
27776
|
const useV3 = options.v3Session || process.env.MARIA_USE_V3_SESSION === "1";
|
|
@@ -28386,7 +27842,7 @@ var init_cli = __esm({
|
|
|
28386
27842
|
init_ai_response_service();
|
|
28387
27843
|
init_LegacySlashCommandAdapter();
|
|
28388
27844
|
init_interactive_cli();
|
|
28389
|
-
|
|
27845
|
+
init_providers();
|
|
28390
27846
|
init_env_loader();
|
|
28391
27847
|
init_version();
|
|
28392
27848
|
packageJson = { version: getVersion() };
|
|
@@ -28441,7 +27897,7 @@ var init_maria_ai = __esm({
|
|
|
28441
27897
|
import_commander2 = require("commander");
|
|
28442
27898
|
init_startup_display();
|
|
28443
27899
|
init_provider_selector();
|
|
28444
|
-
|
|
27900
|
+
init_config2();
|
|
28445
27901
|
init_IntelligentRouterService();
|
|
28446
27902
|
init_interactive_session();
|
|
28447
27903
|
init_package();
|
|
@@ -28451,7 +27907,7 @@ var init_maria_ai = __esm({
|
|
|
28451
27907
|
router;
|
|
28452
27908
|
session;
|
|
28453
27909
|
constructor() {
|
|
28454
|
-
this.config = new
|
|
27910
|
+
this.config = new ConfigManager();
|
|
28455
27911
|
this.providerSelector = new ProviderSelector(this.config);
|
|
28456
27912
|
}
|
|
28457
27913
|
async initialize() {
|
|
@@ -28478,8 +27934,8 @@ var init_maria_ai = __esm({
|
|
|
28478
27934
|
);
|
|
28479
27935
|
this.session = createInteractiveSession(this);
|
|
28480
27936
|
await this.session.start();
|
|
28481
|
-
} catch (
|
|
28482
|
-
console.error(import_chalk16.default.red("\n\u274C Initialization failed:"),
|
|
27937
|
+
} catch (error) {
|
|
27938
|
+
console.error(import_chalk16.default.red("\n\u274C Initialization failed:"), error);
|
|
28483
27939
|
process.exit(1);
|
|
28484
27940
|
}
|
|
28485
27941
|
}
|
|
@@ -28528,52 +27984,16 @@ function checkNodeVersion() {
|
|
|
28528
27984
|
}
|
|
28529
27985
|
}
|
|
28530
27986
|
|
|
28531
|
-
// src/config/loader.ts
|
|
28532
|
-
var environmentLoaded = false;
|
|
28533
|
-
async function loadEnvironmentConfig() {
|
|
28534
|
-
if (environmentLoaded) {
|
|
28535
|
-
return;
|
|
28536
|
-
}
|
|
28537
|
-
try {
|
|
28538
|
-
const { importNodeBuiltin: importNodeBuiltin2, safeDynamicImport: safeDynamicImport2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
|
|
28539
|
-
const fs7 = await safeDynamicImport2("fs-extra").catch(
|
|
28540
|
-
() => importNodeBuiltin2("fs")
|
|
28541
|
-
);
|
|
28542
|
-
const _path = await importNodeBuiltin2("_path");
|
|
28543
|
-
const _envPath = _path.join(process.cwd(), ".env.local");
|
|
28544
|
-
if (await fs7.pathExists(_envPath)) {
|
|
28545
|
-
const _envContent = await fs7.readFile(_envPath, "utf-8");
|
|
28546
|
-
console.log("Loading environment from:", _envPath);
|
|
28547
|
-
environmentLoaded = true;
|
|
28548
|
-
const _lines = _envContent.split("\n");
|
|
28549
|
-
for (const line of _lines) {
|
|
28550
|
-
const _trimmed = line.trim();
|
|
28551
|
-
if (_trimmed && !_trimmed.startsWith("#")) {
|
|
28552
|
-
const _equalIndex = _trimmed.indexOf("=");
|
|
28553
|
-
if (_equalIndex > 0) {
|
|
28554
|
-
const _key = _trimmed.substring(0, _equalIndex).trim();
|
|
28555
|
-
const _value = _trimmed.substring(_equalIndex + 1).trim();
|
|
28556
|
-
if (_key && _value && !process.env[_key]) {
|
|
28557
|
-
const _cleanValue = _value.replace(/^["']|["']$/g, "");
|
|
28558
|
-
process.env[_key] = _cleanValue;
|
|
28559
|
-
}
|
|
28560
|
-
}
|
|
28561
|
-
}
|
|
28562
|
-
}
|
|
28563
|
-
}
|
|
28564
|
-
} catch (_error) {
|
|
28565
|
-
}
|
|
28566
|
-
}
|
|
28567
|
-
|
|
28568
27987
|
// src/bin/maria.ts
|
|
27988
|
+
init_loader();
|
|
28569
27989
|
async function main() {
|
|
28570
27990
|
await loadEnvironmentConfig();
|
|
28571
27991
|
checkNodeVersion();
|
|
28572
27992
|
const program2 = createCLI2();
|
|
28573
27993
|
program2.parse(process.argv);
|
|
28574
27994
|
}
|
|
28575
|
-
process.on("uncaughtException", (
|
|
28576
|
-
console.error("\u274C Uncaught Exception:",
|
|
27995
|
+
process.on("uncaughtException", (error) => {
|
|
27996
|
+
console.error("\u274C Uncaught Exception:", error.message);
|
|
28577
27997
|
process.exit(1);
|
|
28578
27998
|
});
|
|
28579
27999
|
process.on("unhandledRejection", (reason, promise) => {
|
|
@@ -28588,8 +28008,8 @@ process.on("SIGTERM", () => {
|
|
|
28588
28008
|
console.log("\n\u{1F44B} Goodbye!");
|
|
28589
28009
|
process.exit(0);
|
|
28590
28010
|
});
|
|
28591
|
-
main().catch((
|
|
28592
|
-
console.error("\u274C Failed to start:",
|
|
28011
|
+
main().catch((error) => {
|
|
28012
|
+
console.error("\u274C Failed to start:", error);
|
|
28593
28013
|
process.exit(1);
|
|
28594
28014
|
});
|
|
28595
28015
|
//# sourceMappingURL=maria.cjs.map
|