@bonginkan/maria 3.6.1 → 3.6.3

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.
@@ -42,7 +42,7 @@ function getVersion() {
42
42
  const packageJson2 = getPackageJson();
43
43
  _cachedVersion = packageJson2.version;
44
44
  return _cachedVersion;
45
- } catch (error2) {
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 (error2) {
104
- throw new Error(`Failed to read package.json: ${error2}`);
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;
@@ -462,11 +462,10 @@ var init_startup_display = __esm({
462
462
  });
463
463
 
464
464
  // src/providers/config.ts
465
- var USE_LEGACY_PROVIDERS2, DEFAULT_PROVIDER2, DEFAULT_MODEL2;
465
+ var DEFAULT_PROVIDER2, DEFAULT_MODEL2;
466
466
  var init_config = __esm({
467
467
  "src/providers/config.ts"() {
468
468
  "use strict";
469
- USE_LEGACY_PROVIDERS2 = process.env.USE_LEGACY_PROVIDERS === "true";
470
469
  DEFAULT_PROVIDER2 = process.env.MARIA_PROVIDER ?? "openai";
471
470
  DEFAULT_MODEL2 = process.env.MARIA_MODEL ?? "gpt-4o-mini";
472
471
  }
@@ -2376,10 +2375,10 @@ var require_ponyfill_es2018 = __commonJS({
2376
2375
  });
2377
2376
  return promise;
2378
2377
  }
2379
- function WritableStreamDealWithRejection(stream, error2) {
2378
+ function WritableStreamDealWithRejection(stream, error) {
2380
2379
  const state = stream._state;
2381
2380
  if (state === "writable") {
2382
- WritableStreamStartErroring(stream, error2);
2381
+ WritableStreamStartErroring(stream, error);
2383
2382
  return;
2384
2383
  }
2385
2384
  WritableStreamFinishErroring(stream);
@@ -2430,10 +2429,10 @@ var require_ponyfill_es2018 = __commonJS({
2430
2429
  stream._inFlightWriteRequest._resolve(void 0);
2431
2430
  stream._inFlightWriteRequest = void 0;
2432
2431
  }
2433
- function WritableStreamFinishInFlightWriteWithError(stream, error2) {
2434
- stream._inFlightWriteRequest._reject(error2);
2432
+ function WritableStreamFinishInFlightWriteWithError(stream, error) {
2433
+ stream._inFlightWriteRequest._reject(error);
2435
2434
  stream._inFlightWriteRequest = void 0;
2436
- WritableStreamDealWithRejection(stream, error2);
2435
+ WritableStreamDealWithRejection(stream, error);
2437
2436
  }
2438
2437
  function WritableStreamFinishInFlightClose(stream) {
2439
2438
  stream._inFlightCloseRequest._resolve(void 0);
@@ -2452,14 +2451,14 @@ var require_ponyfill_es2018 = __commonJS({
2452
2451
  defaultWriterClosedPromiseResolve(writer);
2453
2452
  }
2454
2453
  }
2455
- function WritableStreamFinishInFlightCloseWithError(stream, error2) {
2456
- stream._inFlightCloseRequest._reject(error2);
2454
+ function WritableStreamFinishInFlightCloseWithError(stream, error) {
2455
+ stream._inFlightCloseRequest._reject(error);
2457
2456
  stream._inFlightCloseRequest = void 0;
2458
2457
  if (stream._pendingAbortRequest !== void 0) {
2459
- stream._pendingAbortRequest._reject(error2);
2458
+ stream._pendingAbortRequest._reject(error);
2460
2459
  stream._pendingAbortRequest = void 0;
2461
2460
  }
2462
- WritableStreamDealWithRejection(stream, error2);
2461
+ WritableStreamDealWithRejection(stream, error);
2463
2462
  }
2464
2463
  function WritableStreamCloseQueuedOrInFlight(stream) {
2465
2464
  if (stream._closeRequest === void 0 && stream._inFlightCloseRequest === void 0) {
@@ -2676,18 +2675,18 @@ var require_ponyfill_es2018 = __commonJS({
2676
2675
  }
2677
2676
  return WritableStreamDefaultWriterClose(writer);
2678
2677
  }
2679
- function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error2) {
2678
+ function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error) {
2680
2679
  if (writer._closedPromiseState === "pending") {
2681
- defaultWriterClosedPromiseReject(writer, error2);
2680
+ defaultWriterClosedPromiseReject(writer, error);
2682
2681
  } else {
2683
- defaultWriterClosedPromiseResetToRejected(writer, error2);
2682
+ defaultWriterClosedPromiseResetToRejected(writer, error);
2684
2683
  }
2685
2684
  }
2686
- function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error2) {
2685
+ function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error) {
2687
2686
  if (writer._readyPromiseState === "pending") {
2688
- defaultWriterReadyPromiseReject(writer, error2);
2687
+ defaultWriterReadyPromiseReject(writer, error);
2689
2688
  } else {
2690
- defaultWriterReadyPromiseResetToRejected(writer, error2);
2689
+ defaultWriterReadyPromiseResetToRejected(writer, error);
2691
2690
  }
2692
2691
  }
2693
2692
  function WritableStreamDefaultWriterGetDesiredSize(writer) {
@@ -2922,9 +2921,9 @@ var require_ponyfill_es2018 = __commonJS({
2922
2921
  WritableStreamDefaultControllerProcessWrite(controller, value);
2923
2922
  }
2924
2923
  }
2925
- function WritableStreamDefaultControllerErrorIfNeeded(controller, error2) {
2924
+ function WritableStreamDefaultControllerErrorIfNeeded(controller, error) {
2926
2925
  if (controller._controlledWritableStream._state === "writable") {
2927
- WritableStreamDefaultControllerError(controller, error2);
2926
+ WritableStreamDefaultControllerError(controller, error);
2928
2927
  }
2929
2928
  }
2930
2929
  function WritableStreamDefaultControllerProcessClose(controller) {
@@ -2967,10 +2966,10 @@ var require_ponyfill_es2018 = __commonJS({
2967
2966
  const desiredSize = WritableStreamDefaultControllerGetDesiredSize(controller);
2968
2967
  return desiredSize <= 0;
2969
2968
  }
2970
- function WritableStreamDefaultControllerError(controller, error2) {
2969
+ function WritableStreamDefaultControllerError(controller, error) {
2971
2970
  const stream = controller._controlledWritableStream;
2972
2971
  WritableStreamDefaultControllerClearAlgorithms(controller);
2973
- WritableStreamStartErroring(stream, error2);
2972
+ WritableStreamStartErroring(stream, error);
2974
2973
  }
2975
2974
  function streamBrandCheckException$2(name2) {
2976
2975
  return new TypeError(`WritableStream.prototype.${name2} can only be used on a WritableStream`);
@@ -3114,12 +3113,12 @@ var require_ponyfill_es2018 = __commonJS({
3114
3113
  let abortAlgorithm;
3115
3114
  if (signal !== void 0) {
3116
3115
  abortAlgorithm = () => {
3117
- const error2 = signal.reason !== void 0 ? signal.reason : new DOMException2("Aborted", "AbortError");
3116
+ const error = signal.reason !== void 0 ? signal.reason : new DOMException2("Aborted", "AbortError");
3118
3117
  const actions = [];
3119
3118
  if (!preventAbort) {
3120
3119
  actions.push(() => {
3121
3120
  if (dest._state === "writable") {
3122
- return WritableStreamAbort(dest, error2);
3121
+ return WritableStreamAbort(dest, error);
3123
3122
  }
3124
3123
  return promiseResolvedWith(void 0);
3125
3124
  });
@@ -3127,12 +3126,12 @@ var require_ponyfill_es2018 = __commonJS({
3127
3126
  if (!preventCancel) {
3128
3127
  actions.push(() => {
3129
3128
  if (source._state === "readable") {
3130
- return ReadableStreamCancel(source, error2);
3129
+ return ReadableStreamCancel(source, error);
3131
3130
  }
3132
3131
  return promiseResolvedWith(void 0);
3133
3132
  });
3134
3133
  }
3135
- shutdownWithAction(() => Promise.all(actions.map((action) => action())), true, error2);
3134
+ shutdownWithAction(() => Promise.all(actions.map((action) => action())), true, error);
3136
3135
  };
3137
3136
  if (signal.aborted) {
3138
3137
  abortAlgorithm();
@@ -3235,25 +3234,25 @@ var require_ponyfill_es2018 = __commonJS({
3235
3234
  return null;
3236
3235
  }
3237
3236
  }
3238
- function shutdown(isError, error2) {
3237
+ function shutdown(isError, error) {
3239
3238
  if (shuttingDown) {
3240
3239
  return;
3241
3240
  }
3242
3241
  shuttingDown = true;
3243
3242
  if (dest._state === "writable" && !WritableStreamCloseQueuedOrInFlight(dest)) {
3244
- uponFulfillment(waitForWritesToFinish(), () => finalize(isError, error2));
3243
+ uponFulfillment(waitForWritesToFinish(), () => finalize(isError, error));
3245
3244
  } else {
3246
- finalize(isError, error2);
3245
+ finalize(isError, error);
3247
3246
  }
3248
3247
  }
3249
- function finalize(isError, error2) {
3248
+ function finalize(isError, error) {
3250
3249
  WritableStreamDefaultWriterRelease(writer);
3251
3250
  ReadableStreamReaderGenericRelease(reader2);
3252
3251
  if (signal !== void 0) {
3253
3252
  signal.removeEventListener("abort", abortAlgorithm);
3254
3253
  }
3255
3254
  if (isError) {
3256
- reject(error2);
3255
+ reject(error);
3257
3256
  } else {
3258
3257
  resolve2(void 0);
3259
3258
  }
@@ -4648,8 +4647,8 @@ var require_ponyfill_es2018 = __commonJS({
4648
4647
  const stream = controller._controlledTransformStream;
4649
4648
  const readableController = stream._readable._readableStreamController;
4650
4649
  ReadableStreamDefaultControllerClose(readableController);
4651
- const error2 = new TypeError("TransformStream terminated");
4652
- TransformStreamErrorWritableAndUnblockWrite(stream, error2);
4650
+ const error = new TypeError("TransformStream terminated");
4651
+ TransformStreamErrorWritableAndUnblockWrite(stream, error);
4653
4652
  }
4654
4653
  function TransformStreamDefaultSinkWriteAlgorithm(stream, chunk) {
4655
4654
  const controller = stream._transformStreamController;
@@ -4807,11 +4806,11 @@ var require_streams = __commonJS({
4807
4806
  };
4808
4807
  Object.assign(globalThis, require("stream/web"));
4809
4808
  process2.emitWarning = emitWarning;
4810
- } catch (error2) {
4809
+ } catch (error) {
4811
4810
  process2.emitWarning = emitWarning;
4812
- throw error2;
4811
+ throw error;
4813
4812
  }
4814
- } catch (error2) {
4813
+ } catch (error) {
4815
4814
  Object.assign(globalThis, require_ponyfill_es2018());
4816
4815
  }
4817
4816
  }
@@ -4835,7 +4834,7 @@ var require_streams = __commonJS({
4835
4834
  });
4836
4835
  };
4837
4836
  }
4838
- } catch (error2) {
4837
+ } catch (error) {
4839
4838
  }
4840
4839
  }
4841
4840
  });
@@ -5725,15 +5724,15 @@ async function consumeBody(data2) {
5725
5724
  try {
5726
5725
  for await (const chunk of body) {
5727
5726
  if (data2.size > 0 && accumBytes + chunk.length > data2.size) {
5728
- const error2 = new FetchError(`content size at ${data2.url} over limit: ${data2.size}`, "max-size");
5729
- body.destroy(error2);
5730
- throw error2;
5727
+ const error = new FetchError(`content size at ${data2.url} over limit: ${data2.size}`, "max-size");
5728
+ body.destroy(error);
5729
+ throw error;
5731
5730
  }
5732
5731
  accumBytes += chunk.length;
5733
5732
  accum.push(chunk);
5734
5733
  }
5735
- } catch (error2) {
5736
- const error_ = error2 instanceof FetchBaseError ? error2 : new FetchError(`Invalid response body while trying to fetch ${data2.url}: ${error2.message}`, "system", error2);
5734
+ } catch (error) {
5735
+ const error_ = error instanceof FetchBaseError ? error : new FetchError(`Invalid response body while trying to fetch ${data2.url}: ${error.message}`, "system", error);
5737
5736
  throw error_;
5738
5737
  }
5739
5738
  if (body.readableEnded === true || body._readableState.ended === true) {
@@ -5742,8 +5741,8 @@ async function consumeBody(data2) {
5742
5741
  return import_node_buffer.Buffer.from(accum.join(""));
5743
5742
  }
5744
5743
  return import_node_buffer.Buffer.concat(accum, accumBytes);
5745
- } catch (error2) {
5746
- throw new FetchError(`Could not create Buffer from response body for ${data2.url}: ${error2.message}`, "system", error2);
5744
+ } catch (error) {
5745
+ throw new FetchError(`Could not create Buffer from response body for ${data2.url}: ${error.message}`, "system", error);
5747
5746
  }
5748
5747
  } else {
5749
5748
  throw new FetchError(`Premature close of server response while trying to fetch ${data2.url}`);
@@ -5801,8 +5800,8 @@ var init_body = __esm({
5801
5800
  this.size = size;
5802
5801
  if (body instanceof import_node_stream.default) {
5803
5802
  body.on("error", (error_) => {
5804
- const error2 = error_ instanceof FetchBaseError ? error_ : new FetchError(`Invalid response body while trying to fetch ${this.url}: ${error_.message}`, "system", error_);
5805
- this[INTERNALS].error = error2;
5803
+ const error = error_ instanceof FetchBaseError ? error_ : new FetchError(`Invalid response body while trying to fetch ${this.url}: ${error_.message}`, "system", error_);
5804
+ this[INTERNALS].error = error;
5806
5805
  });
5807
5806
  }
5808
5807
  }
@@ -5990,16 +5989,16 @@ var init_headers = __esm({
5990
5989
  import_node_http = __toESM(require("http"), 1);
5991
5990
  validateHeaderName = typeof import_node_http.default.validateHeaderName === "function" ? import_node_http.default.validateHeaderName : (name2) => {
5992
5991
  if (!/^[\^`\-\w!#$%&'*+.|~]+$/.test(name2)) {
5993
- const error2 = new TypeError(`Header name must be a valid HTTP token [${name2}]`);
5994
- Object.defineProperty(error2, "code", { value: "ERR_INVALID_HTTP_TOKEN" });
5995
- throw error2;
5992
+ const error = new TypeError(`Header name must be a valid HTTP token [${name2}]`);
5993
+ Object.defineProperty(error, "code", { value: "ERR_INVALID_HTTP_TOKEN" });
5994
+ throw error;
5996
5995
  }
5997
5996
  };
5998
5997
  validateHeaderValue = typeof import_node_http.default.validateHeaderValue === "function" ? import_node_http.default.validateHeaderValue : (name2, value) => {
5999
5998
  if (/[^\t\u0020-\u007E\u0080-\u00FF]/.test(value)) {
6000
- const error2 = new TypeError(`Invalid character in header content ["${name2}"]`);
6001
- Object.defineProperty(error2, "code", { value: "ERR_INVALID_CHAR" });
6002
- throw error2;
5999
+ const error = new TypeError(`Invalid character in header content ["${name2}"]`);
6000
+ Object.defineProperty(error, "code", { value: "ERR_INVALID_CHAR" });
6001
+ throw error;
6003
6002
  }
6004
6003
  };
6005
6004
  Headers = class _Headers extends URLSearchParams {
@@ -6711,15 +6710,15 @@ async function fetch2(url, options_) {
6711
6710
  const { signal } = request;
6712
6711
  let response2 = null;
6713
6712
  const abort = () => {
6714
- const error2 = new AbortError("The operation was aborted.");
6715
- reject(error2);
6713
+ const error = new AbortError("The operation was aborted.");
6714
+ reject(error);
6716
6715
  if (request.body && request.body instanceof import_node_stream2.default.Readable) {
6717
- request.body.destroy(error2);
6716
+ request.body.destroy(error);
6718
6717
  }
6719
6718
  if (!response2 || !response2.body) {
6720
6719
  return;
6721
6720
  }
6722
- response2.body.emit("error", error2);
6721
+ response2.body.emit("error", error);
6723
6722
  };
6724
6723
  if (signal && signal.aborted) {
6725
6724
  abort();
@@ -6739,13 +6738,13 @@ async function fetch2(url, options_) {
6739
6738
  signal.removeEventListener("abort", abortAndFinalize);
6740
6739
  }
6741
6740
  };
6742
- request_.on("error", (error2) => {
6743
- reject(new FetchError(`request to ${request.url} failed, reason: ${error2.message}`, "system", error2));
6741
+ request_.on("error", (error) => {
6742
+ reject(new FetchError(`request to ${request.url} failed, reason: ${error.message}`, "system", error));
6744
6743
  finalize();
6745
6744
  });
6746
- fixResponseChunkedTransferBadEnding(request_, (error2) => {
6745
+ fixResponseChunkedTransferBadEnding(request_, (error) => {
6747
6746
  if (response2 && response2.body) {
6748
- response2.body.destroy(error2);
6747
+ response2.body.destroy(error);
6749
6748
  }
6750
6749
  });
6751
6750
  if (process.version < "v14") {
@@ -6756,9 +6755,9 @@ async function fetch2(url, options_) {
6756
6755
  });
6757
6756
  s2.prependListener("close", (hadError) => {
6758
6757
  if (response2 && endedWithEventsCount < s2._eventsCount && !hadError) {
6759
- const error2 = new Error("Premature close");
6760
- error2.code = "ERR_STREAM_PREMATURE_CLOSE";
6761
- response2.body.emit("error", error2);
6758
+ const error = new Error("Premature close");
6759
+ error.code = "ERR_STREAM_PREMATURE_CLOSE";
6760
+ response2.body.emit("error", error);
6762
6761
  }
6763
6762
  });
6764
6763
  });
@@ -6839,9 +6838,9 @@ async function fetch2(url, options_) {
6839
6838
  signal.removeEventListener("abort", abortAndFinalize);
6840
6839
  });
6841
6840
  }
6842
- let body = (0, import_node_stream2.pipeline)(response_, new import_node_stream2.PassThrough(), (error2) => {
6843
- if (error2) {
6844
- reject(error2);
6841
+ let body = (0, import_node_stream2.pipeline)(response_, new import_node_stream2.PassThrough(), (error) => {
6842
+ if (error) {
6843
+ reject(error);
6845
6844
  }
6846
6845
  });
6847
6846
  if (process.version < "v12.10") {
@@ -6867,9 +6866,9 @@ async function fetch2(url, options_) {
6867
6866
  finishFlush: import_node_zlib.default.Z_SYNC_FLUSH
6868
6867
  };
6869
6868
  if (codings === "gzip" || codings === "x-gzip") {
6870
- body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createGunzip(zlibOptions), (error2) => {
6871
- if (error2) {
6872
- reject(error2);
6869
+ body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createGunzip(zlibOptions), (error) => {
6870
+ if (error) {
6871
+ reject(error);
6873
6872
  }
6874
6873
  });
6875
6874
  response2 = new Response(body, responseOptions);
@@ -6877,22 +6876,22 @@ async function fetch2(url, options_) {
6877
6876
  return;
6878
6877
  }
6879
6878
  if (codings === "deflate" || codings === "x-deflate") {
6880
- const raw = (0, import_node_stream2.pipeline)(response_, new import_node_stream2.PassThrough(), (error2) => {
6881
- if (error2) {
6882
- reject(error2);
6879
+ const raw = (0, import_node_stream2.pipeline)(response_, new import_node_stream2.PassThrough(), (error) => {
6880
+ if (error) {
6881
+ reject(error);
6883
6882
  }
6884
6883
  });
6885
6884
  raw.once("data", (chunk) => {
6886
6885
  if ((chunk[0] & 15) === 8) {
6887
- body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createInflate(), (error2) => {
6888
- if (error2) {
6889
- reject(error2);
6886
+ body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createInflate(), (error) => {
6887
+ if (error) {
6888
+ reject(error);
6890
6889
  }
6891
6890
  });
6892
6891
  } else {
6893
- body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createInflateRaw(), (error2) => {
6894
- if (error2) {
6895
- reject(error2);
6892
+ body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createInflateRaw(), (error) => {
6893
+ if (error) {
6894
+ reject(error);
6896
6895
  }
6897
6896
  });
6898
6897
  }
@@ -6908,9 +6907,9 @@ async function fetch2(url, options_) {
6908
6907
  return;
6909
6908
  }
6910
6909
  if (codings === "br") {
6911
- body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createBrotliDecompress(), (error2) => {
6912
- if (error2) {
6913
- reject(error2);
6910
+ body = (0, import_node_stream2.pipeline)(body, import_node_zlib.default.createBrotliDecompress(), (error) => {
6911
+ if (error) {
6912
+ reject(error);
6914
6913
  }
6915
6914
  });
6916
6915
  response2 = new Response(body, responseOptions);
@@ -6935,9 +6934,9 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
6935
6934
  request.on("socket", (socket) => {
6936
6935
  const onSocketClose = () => {
6937
6936
  if (isChunkedTransfer && !properLastChunkReceived) {
6938
- const error2 = new Error("Premature close");
6939
- error2.code = "ERR_STREAM_PREMATURE_CLOSE";
6940
- errorCallback(error2);
6937
+ const error = new Error("Premature close");
6938
+ error.code = "ERR_STREAM_PREMATURE_CLOSE";
6939
+ errorCallback(error);
6941
6940
  }
6942
6941
  };
6943
6942
  const onData = (buf) => {
@@ -7005,11 +7004,11 @@ var init_base_provider = __esm({
7005
7004
  latencyMs,
7006
7005
  timestamp: Date.now()
7007
7006
  };
7008
- } catch (error2) {
7007
+ } catch (error) {
7009
7008
  return {
7010
7009
  ok: false,
7011
7010
  latencyMs: Date.now() - startTime,
7012
- reason: error2 instanceof Error ? error2.message : "Unknown error",
7011
+ reason: error instanceof Error ? error.message : "Unknown error",
7013
7012
  timestamp: Date.now()
7014
7013
  };
7015
7014
  }
@@ -7038,9 +7037,9 @@ var init_base_provider = __esm({
7038
7037
  );
7039
7038
  }
7040
7039
  return response2.json();
7041
- } catch (error2) {
7040
+ } catch (error) {
7042
7041
  clearTimeout(timeoutId);
7043
- throw error2;
7042
+ throw error;
7044
7043
  }
7045
7044
  }
7046
7045
  // Helper method for streaming requests
@@ -7067,9 +7066,9 @@ var init_base_provider = __esm({
7067
7066
  );
7068
7067
  }
7069
7068
  return this.parseStreamResponse(response2);
7070
- } catch (error2) {
7069
+ } catch (error) {
7071
7070
  clearTimeout(timeoutId);
7072
- throw error2;
7071
+ throw error;
7073
7072
  }
7074
7073
  }
7075
7074
  // Default stream parsing - override in subclasses for provider-specific logic
@@ -7112,10 +7111,10 @@ var init_base_provider = __esm({
7112
7111
  for (let attempt = 0; attempt < maxRetries; attempt++) {
7113
7112
  try {
7114
7113
  return await operation();
7115
- } catch (error2) {
7116
- lastError = error2;
7117
- if (this.isNonRetryableError(error2)) {
7118
- throw error2;
7114
+ } catch (error) {
7115
+ lastError = error;
7116
+ if (this.isNonRetryableError(error)) {
7117
+ throw error;
7119
7118
  }
7120
7119
  if (attempt < maxRetries - 1) {
7121
7120
  const delay = Math.pow(2, attempt) * 1e3;
@@ -7126,8 +7125,8 @@ var init_base_provider = __esm({
7126
7125
  throw lastError;
7127
7126
  }
7128
7127
  // Check if error should not be retried
7129
- isNonRetryableError(error2) {
7130
- const message = error2?.message?.toLowerCase() || "";
7128
+ isNonRetryableError(error) {
7129
+ const message = error?.message?.toLowerCase() || "";
7131
7130
  return message.includes("invalid api key") || message.includes("unauthorized") || message.includes("forbidden") || message.includes("not found");
7132
7131
  }
7133
7132
  };
@@ -7246,6 +7245,29 @@ var init_manager = __esm({
7246
7245
  getAvailableProviders() {
7247
7246
  return Array.from(this.availableProviders);
7248
7247
  }
7248
+ /**
7249
+ * Get list of available models (legacy compatibility)
7250
+ */
7251
+ getAvailableModels() {
7252
+ const models = [];
7253
+ for (const providerId of this.availableProviders) {
7254
+ switch (providerId) {
7255
+ case "openai":
7256
+ models.push("gpt-4o", "gpt-4o-mini", "gpt-3.5-turbo");
7257
+ break;
7258
+ case "anthropic":
7259
+ models.push("claude-3-5-sonnet-20241022", "claude-3-5-haiku-20241022");
7260
+ break;
7261
+ case "google":
7262
+ models.push("gemini-2.5-pro", "gemini-2.5-flash");
7263
+ break;
7264
+ case "grok":
7265
+ models.push("grok-4", "grok-beta");
7266
+ break;
7267
+ }
7268
+ }
7269
+ return models;
7270
+ }
7249
7271
  /**
7250
7272
  * Get comprehensive health status for all providers
7251
7273
  */
@@ -7255,10 +7277,10 @@ var init_manager = __esm({
7255
7277
  async ([id, provider2]) => {
7256
7278
  try {
7257
7279
  health[id] = await provider2.health();
7258
- } catch (error2) {
7280
+ } catch (error) {
7259
7281
  health[id] = {
7260
7282
  ok: false,
7261
- reason: error2 instanceof Error ? error2.message : "Unknown error",
7283
+ reason: error instanceof Error ? error.message : "Unknown error",
7262
7284
  timestamp: Date.now()
7263
7285
  };
7264
7286
  }
@@ -7281,10 +7303,10 @@ var init_manager = __esm({
7281
7303
  if (health.ok) {
7282
7304
  this.availableProviders.add(id);
7283
7305
  }
7284
- } catch (error2) {
7306
+ } catch (error) {
7285
7307
  this.healthCache.set(id, {
7286
7308
  ok: false,
7287
- reason: error2 instanceof Error ? error2.message : "Health check failed",
7309
+ reason: error instanceof Error ? error.message : "Health check failed",
7288
7310
  timestamp: Date.now()
7289
7311
  });
7290
7312
  }
@@ -7345,10 +7367,10 @@ var init_manager = __esm({
7345
7367
  const health = await provider2.health();
7346
7368
  this.healthCache.set(id, health);
7347
7369
  return health;
7348
- } catch (error2) {
7370
+ } catch (error) {
7349
7371
  const health = {
7350
7372
  ok: false,
7351
- reason: error2 instanceof Error ? error2.message : "Health check failed",
7373
+ reason: error instanceof Error ? error.message : "Health check failed",
7352
7374
  timestamp: now
7353
7375
  };
7354
7376
  this.healthCache.set(id, health);
@@ -7491,242 +7513,12 @@ var init_manager = __esm({
7491
7513
  }
7492
7514
  });
7493
7515
 
7494
- // src/providers/legacy-adapter.ts
7495
- var LegacyAIProviderFactory2, ModernToLegacyProviderShim, TemplateProviderShim;
7496
- var init_legacy_adapter = __esm({
7497
- "src/providers/legacy-adapter.ts"() {
7498
- "use strict";
7499
- init_manager();
7500
- LegacyAIProviderFactory2 = class _LegacyAIProviderFactory {
7501
- static instance;
7502
- manager;
7503
- currentProviderType = "template";
7504
- constructor() {
7505
- this.manager = new UnifiedAIProviderManager2();
7506
- }
7507
- static getInstance() {
7508
- if (!_LegacyAIProviderFactory.instance) {
7509
- _LegacyAIProviderFactory.instance = new _LegacyAIProviderFactory();
7510
- }
7511
- return _LegacyAIProviderFactory.instance;
7512
- }
7513
- /**
7514
- * Initialize providers from environment (legacy interface)
7515
- */
7516
- async initializeFromEnvironment() {
7517
- await this.manager.initialize();
7518
- }
7519
- /**
7520
- * Initialize a specific provider (legacy interface)
7521
- */
7522
- async initializeProvider(type, config2) {
7523
- }
7524
- /**
7525
- * Get provider (legacy interface)
7526
- * Returns a shim that adapts modern provider to legacy interface
7527
- */
7528
- getProvider(type) {
7529
- const providerType = type || this.currentProviderType;
7530
- const providerId = this.mapLegacyToModernType(providerType);
7531
- const modernProvider = this.manager.getProvider(providerId);
7532
- if (!modernProvider) {
7533
- if (providerType === "template") {
7534
- return new TemplateProviderShim();
7535
- }
7536
- return void 0;
7537
- }
7538
- return new ModernToLegacyProviderShim(modernProvider);
7539
- }
7540
- /**
7541
- * Get active provider (legacy interface)
7542
- */
7543
- async getActiveProvider() {
7544
- try {
7545
- const modernProvider = await this.manager.pick();
7546
- return new ModernToLegacyProviderShim(modernProvider);
7547
- } catch {
7548
- return new TemplateProviderShim();
7549
- }
7550
- }
7551
- /**
7552
- * Set active provider (legacy interface)
7553
- */
7554
- setActiveProvider(type) {
7555
- this.currentProviderType = type;
7556
- const providerId = this.mapLegacyToModernType(type);
7557
- try {
7558
- this.manager.setActiveProvider(providerId);
7559
- } catch {
7560
- }
7561
- }
7562
- /**
7563
- * Get available providers (legacy interface)
7564
- */
7565
- getAvailableProviders() {
7566
- const modernProviders = this.manager.getAvailableProviders();
7567
- return modernProviders.map((id) => this.mapModernToLegacyType(id)).filter((type) => type !== null);
7568
- }
7569
- /**
7570
- * Clear providers (legacy interface)
7571
- */
7572
- clearProviders() {
7573
- this.manager = new UnifiedAIProviderManager2();
7574
- this.currentProviderType = "template";
7575
- }
7576
- /**
7577
- * Map legacy provider types to modern provider IDs
7578
- */
7579
- mapLegacyToModernType(legacyType) {
7580
- const mapping = {
7581
- openai: "openai",
7582
- anthropic: "anthropic",
7583
- groq: "groq",
7584
- ollama: "ollama",
7585
- template: "openai"
7586
- // Default fallback
7587
- };
7588
- return mapping[legacyType] || "openai";
7589
- }
7590
- /**
7591
- * Map modern provider IDs to legacy provider types
7592
- */
7593
- mapModernToLegacyType(modernId) {
7594
- const mapping = {
7595
- openai: "openai",
7596
- anthropic: "anthropic",
7597
- google: null,
7598
- // Not supported in legacy
7599
- groq: "groq",
7600
- grok: null,
7601
- // Not supported in legacy
7602
- ollama: "ollama",
7603
- lmstudio: null,
7604
- // Not supported in legacy
7605
- vllm: null
7606
- // Not supported in legacy
7607
- };
7608
- return mapping[modernId] || null;
7609
- }
7610
- };
7611
- ModernToLegacyProviderShim = class {
7612
- constructor(modernProvider) {
7613
- this.modernProvider = modernProvider;
7614
- }
7615
- get name() {
7616
- return this.modernProvider.name;
7617
- }
7618
- async initialize(config2) {
7619
- }
7620
- async generateCompletion(request) {
7621
- const prompt = this.convertMessagesToPrompt(request.messages || []);
7622
- const modernRequest = {
7623
- model: request.model,
7624
- temperature: request.temperature,
7625
- maxTokens: request.maxTokens,
7626
- stream: false
7627
- };
7628
- const modernResponse = await this.modernProvider.complete(
7629
- prompt,
7630
- modernRequest
7631
- );
7632
- return {
7633
- content: modernResponse.content,
7634
- model: modernResponse.model || request.model || "unknown",
7635
- usage: modernResponse.usage,
7636
- finishReason: modernResponse.finishReason
7637
- };
7638
- }
7639
- async streamCompletion(request, onChunk) {
7640
- const prompt = this.convertMessagesToPrompt(request.messages || []);
7641
- const modernRequest = {
7642
- model: request.model,
7643
- temperature: request.temperature,
7644
- maxTokens: request.maxTokens,
7645
- stream: true
7646
- };
7647
- const stream = await this.modernProvider.stream(prompt, modernRequest);
7648
- let fullContent = "";
7649
- for await (const chunk of stream) {
7650
- fullContent += chunk.content;
7651
- onChunk(chunk.content);
7652
- }
7653
- return {
7654
- content: fullContent,
7655
- model: request.model || "unknown",
7656
- finishReason: "stop"
7657
- };
7658
- }
7659
- isAvailable() {
7660
- return true;
7661
- }
7662
- getAvailableModels() {
7663
- return [];
7664
- }
7665
- /**
7666
- * Convert legacy message format to simple prompt
7667
- */
7668
- convertMessagesToPrompt(messages) {
7669
- return messages.map((msg) => `${msg.role}: ${msg.content}`).join("\n");
7670
- }
7671
- };
7672
- TemplateProviderShim = class {
7673
- name = "Template Provider";
7674
- async initialize(_config) {
7675
- }
7676
- async generateCompletion(request) {
7677
- const prompt = request.messages?.map((m2) => m2.content).join(" ") || "No input";
7678
- const templateResponse = this.generateTemplateResponse(prompt);
7679
- return {
7680
- content: templateResponse,
7681
- model: "template",
7682
- finishReason: "stop"
7683
- };
7684
- }
7685
- async streamCompletion(request, onChunk) {
7686
- const response2 = await this.generateCompletion(request);
7687
- const chunks = this.chunkText(response2.content, 20);
7688
- for (const chunk of chunks) {
7689
- onChunk(chunk);
7690
- await this.delay(50);
7691
- }
7692
- return response2;
7693
- }
7694
- isAvailable() {
7695
- return true;
7696
- }
7697
- getAvailableModels() {
7698
- return ["template"];
7699
- }
7700
- generateTemplateResponse(prompt) {
7701
- const responses = [
7702
- `I understand you're asking about: ${prompt}. Here's a helpful response based on the available information.`,
7703
- `Regarding "${prompt}" - I can provide some guidance on this topic.`,
7704
- `Thank you for your question about "${prompt}". Let me help you with that.`
7705
- ];
7706
- return responses[Math.floor(Math.random() * responses.length)];
7707
- }
7708
- chunkText(text, wordsPerChunk) {
7709
- const words = text.split(" ");
7710
- const chunks = [];
7711
- for (let i2 = 0; i2 < words.length; i2 += wordsPerChunk) {
7712
- chunks.push(words.slice(i2, i2 + wordsPerChunk).join(" ") + " ");
7713
- }
7714
- return chunks;
7715
- }
7716
- delay(ms) {
7717
- return new Promise((resolve2) => setTimeout(resolve2, ms));
7718
- }
7719
- };
7720
- }
7721
- });
7722
-
7723
7516
  // src/providers/index.ts
7724
7517
  var init_providers = __esm({
7725
7518
  "src/providers/index.ts"() {
7726
7519
  "use strict";
7727
7520
  init_config();
7728
7521
  init_manager();
7729
- init_legacy_adapter();
7730
7522
  }
7731
7523
  });
7732
7524
 
@@ -7858,22 +7650,17 @@ var init_provider_selector = __esm({
7858
7650
  import_chalk2 = __toESM(require("chalk"), 1);
7859
7651
  import_inquirer = __toESM(require("inquirer"), 1);
7860
7652
  init_providers();
7861
- init_manager();
7862
7653
  ProviderSelector = class {
7863
7654
  config;
7864
7655
  modernProviderManager;
7865
7656
  legacyProviderManager;
7866
7657
  constructor(_config) {
7867
7658
  this.config = _config;
7868
- this.modernProviderManager = new UnifiedAIProviderManager2();
7659
+ this.modernProviderManager = new UnifiedAIProviderManager();
7869
7660
  this.legacyProviderManager = new UnifiedAIProviderManager2(_config);
7870
7661
  }
7871
7662
  async initialize() {
7872
- if (USE_LEGACY_PROVIDERS2) {
7873
- await this.legacyProviderManager.initialize();
7874
- } else {
7875
- await this.modernProviderManager.initialize();
7876
- }
7663
+ await this.modernProviderManager.initialize();
7877
7664
  }
7878
7665
  async selectProvider() {
7879
7666
  const providers = await this.getAvailableProviders();
@@ -8165,8 +7952,8 @@ async function importReactComponent(specifier) {
8165
7952
  try {
8166
7953
  const _module = await safeDynamicImport(specifier);
8167
7954
  return _module;
8168
- } catch (error2) {
8169
- console.warn(`Failed to load React component ${specifier}:`, error2);
7955
+ } catch (error) {
7956
+ console.warn(`Failed to load React component ${specifier}:`, error);
8170
7957
  throw new Error(
8171
7958
  `React component ${specifier} is not available in this environment`
8172
7959
  );
@@ -8186,604 +7973,61 @@ var init_import_helper = __esm({
8186
7973
  }
8187
7974
  });
8188
7975
 
8189
- // src/config/config-manager.ts
8190
- function deepMerge(target, source) {
8191
- const result = { ...target };
8192
- for (const key2 in source) {
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
- }
7976
+ // src/config/loader.ts
7977
+ async function loadEnvironmentConfig() {
7978
+ if (environmentLoaded) {
7979
+ return;
8203
7980
  }
8204
- return result;
8205
- }
8206
- var import_zod, PROVIDER_MODELS, ConfigValidationError, ConfigLoadError, PriorityModeSchema, ApiKeysSchema, LocalProvidersSchema, ProviderConfigSchema, ConfigSchema, ConfigManagerV2;
8207
- var init_config_manager = __esm({
8208
- "src/config/config-manager.ts"() {
8209
- "use strict";
8210
- import_zod = require("zod");
8211
- PROVIDER_MODELS = {
8212
- openai: [
8213
- "gpt-5-mini-2025-08-07",
8214
- "gpt-5-mini",
8215
- "gpt-5",
8216
- "gpt-4o",
8217
- "gpt-4o-mini",
8218
- "gpt-4-turbo",
8219
- "o1-preview",
8220
- "o1-mini"
8221
- ],
8222
- anthropic: [
8223
- "claude-3-opus-20240229",
8224
- "claude-3-sonnet-20240229",
8225
- "claude-3-haiku-20240307",
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}`);
7981
+ try {
7982
+ const { importNodeBuiltin: importNodeBuiltin2, safeDynamicImport: safeDynamicImport2 } = await Promise.resolve().then(() => (init_import_helper(), import_helper_exports));
7983
+ const fs7 = await safeDynamicImport2("fs-extra").catch(
7984
+ () => importNodeBuiltin2("fs")
7985
+ );
7986
+ const _path = await importNodeBuiltin2("_path");
7987
+ const _envPath = _path.join(process.cwd(), ".env.local");
7988
+ if (await fs7.pathExists(_envPath)) {
7989
+ const _envContent = await fs7.readFile(_envPath, "utf-8");
7990
+ console.log("Loading environment from:", _envPath);
7991
+ environmentLoaded = true;
7992
+ const _lines = _envContent.split("\n");
7993
+ for (const line of _lines) {
7994
+ const _trimmed = line.trim();
7995
+ if (_trimmed && !_trimmed.startsWith("#")) {
7996
+ const _equalIndex = _trimmed.indexOf("=");
7997
+ if (_equalIndex > 0) {
7998
+ const _key = _trimmed.substring(0, _equalIndex).trim();
7999
+ const _value = _trimmed.substring(_equalIndex + 1).trim();
8000
+ if (_key && _value && !process.env[_key]) {
8001
+ const _cleanValue = _value.replace(/^["']|["']$/g, "");
8002
+ process.env[_key] = _cleanValue;
8777
8003
  }
8778
8004
  }
8779
- } catch (innerError) {
8780
- warnings.push(
8781
- `Merge preview failed: ${error instanceof Error ? error.message : "Unknown error"}`
8782
- );
8783
8005
  }
8784
- return { changes, warnings };
8785
8006
  }
8786
- };
8007
+ }
8008
+ } catch (_error) {
8009
+ }
8010
+ }
8011
+ var environmentLoaded;
8012
+ var init_loader = __esm({
8013
+ "src/config/loader.ts"() {
8014
+ "use strict";
8015
+ environmentLoaded = false;
8016
+ }
8017
+ });
8018
+
8019
+ // src/config/models.ts
8020
+ var init_models = __esm({
8021
+ "src/config/models.ts"() {
8022
+ "use strict";
8023
+ }
8024
+ });
8025
+
8026
+ // src/config/index.ts
8027
+ var init_config2 = __esm({
8028
+ "src/config/index.ts"() {
8029
+ "use strict";
8030
+ init_models();
8787
8031
  }
8788
8032
  });
8789
8033
 
@@ -12218,8 +11462,8 @@ var init_SessionStateMachine = __esm({
12218
11462
  this.controller = void 0;
12219
11463
  return this.to("Completed");
12220
11464
  }
12221
- fail(error2) {
12222
- this._ctx.meta = { ...this._ctx.meta || {}, error: error2 };
11465
+ fail(error) {
11466
+ this._ctx.meta = { ...this._ctx.meta || {}, error };
12223
11467
  this.inflight = false;
12224
11468
  this.clearDeadline();
12225
11469
  this.controller = void 0;
@@ -12253,32 +11497,32 @@ var init_SessionStateMachine = __esm({
12253
11497
  });
12254
11498
 
12255
11499
  // src/services/interactive-session/types/errors.ts
12256
- function isSessionError(error2) {
12257
- return error2 instanceof SessionError;
11500
+ function isSessionError(error) {
11501
+ return error instanceof SessionError;
12258
11502
  }
12259
- function isRecoverableError(error2) {
12260
- if (isSessionError(error2)) {
12261
- return error2.recoverable;
11503
+ function isRecoverableError(error) {
11504
+ if (isSessionError(error)) {
11505
+ return error.recoverable;
12262
11506
  }
12263
11507
  return false;
12264
11508
  }
12265
- function toSessionError(error2) {
12266
- if (isSessionError(error2)) {
12267
- return error2;
11509
+ function toSessionError(error) {
11510
+ if (isSessionError(error)) {
11511
+ return error;
12268
11512
  }
12269
- if (error2 instanceof Error) {
12270
- if (error2.message.includes("cancel") || error2.message.includes("abort")) {
12271
- return new UserCancelError(error2.message);
11513
+ if (error instanceof Error) {
11514
+ if (error.message.includes("cancel") || error.message.includes("abort")) {
11515
+ return new UserCancelError(error.message);
12272
11516
  }
12273
- if (error2.message.includes("timeout") || error2.message.includes("deadline")) {
12274
- return new DeadlineError(error2.message, 15e3);
11517
+ if (error.message.includes("timeout") || error.message.includes("deadline")) {
11518
+ return new DeadlineError(error.message, 15e3);
12275
11519
  }
12276
- if (error2.message.includes("network") || error2.message.includes("fetch")) {
12277
- return new NetworkError(error2.message);
11520
+ if (error.message.includes("network") || error.message.includes("fetch")) {
11521
+ return new NetworkError(error.message);
12278
11522
  }
12279
- return new InternalError(error2.message, error2);
11523
+ return new InternalError(error.message, error);
12280
11524
  }
12281
- return new InternalError(String(error2), error2);
11525
+ return new InternalError(String(error), error);
12282
11526
  }
12283
11527
  var SessionError, UserCancelError, DeadlineError, InternalError, NetworkError;
12284
11528
  var init_errors = __esm({
@@ -12356,8 +11600,8 @@ var init_SessionManager = __esm({
12356
11600
  while (this.running) {
12357
11601
  try {
12358
11602
  await this.runTurn();
12359
- } catch (error2) {
12360
- const sessionError = toSessionError(error2);
11603
+ } catch (error) {
11604
+ const sessionError = toSessionError(error);
12361
11605
  this.display.error(`Session error: ${sessionError.message}`);
12362
11606
  if (!isRecoverableError(sessionError)) {
12363
11607
  this.display.error("Fatal error, ending session");
@@ -12444,12 +11688,12 @@ var init_SessionManager = __esm({
12444
11688
  );
12445
11689
  }
12446
11690
  this.fsm.send({ type: "STREAM_DONE" });
12447
- } catch (error2) {
11691
+ } catch (error) {
12448
11692
  if (this.currentSpinnerId) {
12449
11693
  this.display.stopSpinner(this.currentSpinnerId);
12450
11694
  this.currentSpinnerId = void 0;
12451
11695
  }
12452
- const sessionError = toSessionError(error2);
11696
+ const sessionError = toSessionError(error);
12453
11697
  metric.errorCode = sessionError.code;
12454
11698
  if (sessionError instanceof DeadlineError) {
12455
11699
  metric.deadline = true;
@@ -12478,11 +11722,11 @@ var init_SessionManager = __esm({
12478
11722
  return null;
12479
11723
  }
12480
11724
  return input4.trim();
12481
- } catch (error2) {
11725
+ } catch (error) {
12482
11726
  if (this.fsm.signal?.aborted) {
12483
11727
  throw new DeadlineError("Input timeout", this.options.deadlineMs);
12484
11728
  }
12485
- throw error2;
11729
+ throw error;
12486
11730
  }
12487
11731
  }
12488
11732
  /**
@@ -12763,9 +12007,9 @@ var init_ChalkAdapter = __esm({
12763
12007
  if (signal?.aborted) break;
12764
12008
  process.stdout.write(chunk);
12765
12009
  }
12766
- } catch (error2) {
12010
+ } catch (error) {
12767
12011
  if (!signal?.aborted) {
12768
- throw error2;
12012
+ throw error;
12769
12013
  }
12770
12014
  } finally {
12771
12015
  process.stdout.write("\n");
@@ -14934,8 +14178,8 @@ var init_SlashCommandHandler = __esm({
14934
14178
  return await this.executeWithTimeout(command, context2, options.timeout);
14935
14179
  }
14936
14180
  return await command.execute(context2);
14937
- } catch (error2) {
14938
- if (error2 instanceof Error && error2.name === "AbortError") {
14181
+ } catch (error) {
14182
+ if (error instanceof Error && error.name === "AbortError") {
14939
14183
  return {
14940
14184
  success: false,
14941
14185
  error: "Command execution timed out",
@@ -14944,7 +14188,7 @@ var init_SlashCommandHandler = __esm({
14944
14188
  }
14945
14189
  return {
14946
14190
  success: false,
14947
- error: error2 instanceof Error ? error2.message : "Unknown error",
14191
+ error: error instanceof Error ? error.message : "Unknown error",
14948
14192
  messages: []
14949
14193
  };
14950
14194
  }
@@ -14963,9 +14207,9 @@ var init_SlashCommandHandler = __esm({
14963
14207
  const result = await command.execute(contextWithSignal);
14964
14208
  clearTimeout(timeoutId);
14965
14209
  return result;
14966
- } catch (error2) {
14210
+ } catch (error) {
14967
14211
  clearTimeout(timeoutId);
14968
- throw error2;
14212
+ throw error;
14969
14213
  }
14970
14214
  }
14971
14215
  /**
@@ -15206,10 +14450,10 @@ var init_MemoryService = __esm({
15206
14450
  }
15207
14451
  });
15208
14452
  this.warmupInBackground();
15209
- } catch (error2) {
14453
+ } catch (error) {
15210
14454
  this._initialized = false;
15211
14455
  this._initializationPromise = null;
15212
- throw new Error(`Memory system initialization failed: ${error2}`);
14456
+ throw new Error(`Memory system initialization failed: ${error}`);
15213
14457
  }
15214
14458
  }
15215
14459
  /**
@@ -15221,8 +14465,8 @@ var init_MemoryService = __esm({
15221
14465
  try {
15222
14466
  this._engine?.loadInitialContext();
15223
14467
  this._engine?.preloadCache();
15224
- } catch (error2) {
15225
- console.warn("Memory warmup warning:", error2);
14468
+ } catch (error) {
14469
+ console.warn("Memory warmup warning:", error);
15226
14470
  }
15227
14471
  });
15228
14472
  }
@@ -15344,60 +14588,60 @@ var init_MemoryService = __esm({
15344
14588
  });
15345
14589
 
15346
14590
  // src/services/interactive-session/services/ConfigService.ts
15347
- var fs2, path2, import_zod2, SessionConfigSchema, ConfigService;
14591
+ var fs2, path2, import_zod, SessionConfigSchema, ConfigService;
15348
14592
  var init_ConfigService = __esm({
15349
14593
  "src/services/interactive-session/services/ConfigService.ts"() {
15350
14594
  "use strict";
15351
14595
  fs2 = __toESM(require("fs/promises"), 1);
15352
14596
  path2 = __toESM(require("path"), 1);
15353
- import_zod2 = require("zod");
15354
- SessionConfigSchema = import_zod2.z.object({
15355
- ui: import_zod2.z.object({
15356
- theme: import_zod2.z.enum(["default", "dark", "light", "solarized"]).default("default"),
15357
- colors: import_zod2.z.object({
15358
- primary: import_zod2.z.string().default("#00A8E8"),
15359
- success: import_zod2.z.string().default("#00C851"),
15360
- warning: import_zod2.z.string().default("#FFB300"),
15361
- error: import_zod2.z.string().default("#FF3547"),
15362
- info: import_zod2.z.string().default("#33B5E5")
14597
+ import_zod = require("zod");
14598
+ SessionConfigSchema = import_zod.z.object({
14599
+ ui: import_zod.z.object({
14600
+ theme: import_zod.z.enum(["default", "dark", "light", "solarized"]).default("default"),
14601
+ colors: import_zod.z.object({
14602
+ primary: import_zod.z.string().default("#00A8E8"),
14603
+ success: import_zod.z.string().default("#00C851"),
14604
+ warning: import_zod.z.string().default("#FFB300"),
14605
+ error: import_zod.z.string().default("#FF3547"),
14606
+ info: import_zod.z.string().default("#33B5E5")
15363
14607
  }).default({}),
15364
- spinner: import_zod2.z.object({
15365
- style: import_zod2.z.enum(["dots", "line", "star", "square"]).default("dots"),
15366
- color: import_zod2.z.string().default("cyan")
14608
+ spinner: import_zod.z.object({
14609
+ style: import_zod.z.enum(["dots", "line", "star", "square"]).default("dots"),
14610
+ color: import_zod.z.string().default("cyan")
15367
14611
  }).default({}),
15368
- showTimestamps: import_zod2.z.boolean().default(false),
15369
- showDebugInfo: import_zod2.z.boolean().default(false)
14612
+ showTimestamps: import_zod.z.boolean().default(false),
14613
+ showDebugInfo: import_zod.z.boolean().default(false)
15370
14614
  }).default({}),
15371
- behavior: import_zod2.z.object({
15372
- autoApproval: import_zod2.z.boolean().default(false),
15373
- confirmBeforeExit: import_zod2.z.boolean().default(true),
15374
- historySize: import_zod2.z.number().min(0).max(1e4).default(1e3),
15375
- commandTimeout: import_zod2.z.number().min(0).default(3e4),
14615
+ behavior: import_zod.z.object({
14616
+ autoApproval: import_zod.z.boolean().default(false),
14617
+ confirmBeforeExit: import_zod.z.boolean().default(true),
14618
+ historySize: import_zod.z.number().min(0).max(1e4).default(1e3),
14619
+ commandTimeout: import_zod.z.number().min(0).default(3e4),
15376
14620
  // 30秒
15377
- retryAttempts: import_zod2.z.number().min(0).max(10).default(3),
15378
- streamingEnabled: import_zod2.z.boolean().default(true)
14621
+ retryAttempts: import_zod.z.number().min(0).max(10).default(3),
14622
+ streamingEnabled: import_zod.z.boolean().default(true)
15379
14623
  }).default({}),
15380
- memory: import_zod2.z.object({
15381
- enablePersistence: import_zod2.z.boolean().default(false),
15382
- maxMemoryUsage: import_zod2.z.number().min(0).default(512),
14624
+ memory: import_zod.z.object({
14625
+ enablePersistence: import_zod.z.boolean().default(false),
14626
+ maxMemoryUsage: import_zod.z.number().min(0).default(512),
15383
14627
  // MB
15384
- cacheSize: import_zod2.z.number().min(0).default(100),
14628
+ cacheSize: import_zod.z.number().min(0).default(100),
15385
14629
  // MB
15386
- gcInterval: import_zod2.z.number().min(0).default(3e5)
14630
+ gcInterval: import_zod.z.number().min(0).default(3e5)
15387
14631
  // 5分
15388
14632
  }).default({}),
15389
- shortcuts: import_zod2.z.record(import_zod2.z.string()).default({
14633
+ shortcuts: import_zod.z.record(import_zod.z.string()).default({
15390
14634
  clear: "cls",
15391
14635
  quit: "exit",
15392
14636
  h: "help",
15393
14637
  s: "status",
15394
14638
  m: "models"
15395
14639
  }),
15396
- advanced: import_zod2.z.object({
15397
- debugMode: import_zod2.z.boolean().default(false),
15398
- verboseLogging: import_zod2.z.boolean().default(false),
15399
- experimentalFeatures: import_zod2.z.boolean().default(false),
15400
- telemetryEnabled: import_zod2.z.boolean().default(false)
14640
+ advanced: import_zod.z.object({
14641
+ debugMode: import_zod.z.boolean().default(false),
14642
+ verboseLogging: import_zod.z.boolean().default(false),
14643
+ experimentalFeatures: import_zod.z.boolean().default(false),
14644
+ telemetryEnabled: import_zod.z.boolean().default(false)
15401
14645
  }).default({})
15402
14646
  });
15403
14647
  ConfigService = class {
@@ -15435,7 +14679,7 @@ var init_ConfigService = __esm({
15435
14679
  try {
15436
14680
  const configFile = await fs2.readFile(this._configPath, "utf-8");
15437
14681
  return JSON.parse(configFile);
15438
- } catch (error2) {
14682
+ } catch (error) {
15439
14683
  return {};
15440
14684
  }
15441
14685
  }
@@ -15446,7 +14690,7 @@ var init_ConfigService = __esm({
15446
14690
  try {
15447
14691
  const configFile = await fs2.readFile(this._userConfigPath, "utf-8");
15448
14692
  return JSON.parse(configFile);
15449
- } catch (error2) {
14693
+ } catch (error) {
15450
14694
  return {};
15451
14695
  }
15452
14696
  }
@@ -15471,11 +14715,11 @@ var init_ConfigService = __esm({
15471
14715
  validateConfig() {
15472
14716
  try {
15473
14717
  SessionConfigSchema.parse(this._config);
15474
- } catch (error2) {
15475
- if (error2 instanceof import_zod2.z.ZodError) {
15476
- throw new Error(`Configuration validation failed: ${error2.message}`);
14718
+ } catch (error) {
14719
+ if (error instanceof import_zod.z.ZodError) {
14720
+ throw new Error(`Configuration validation failed: ${error.message}`);
15477
14721
  }
15478
- throw error2;
14722
+ throw error;
15479
14723
  }
15480
14724
  }
15481
14725
  /**
@@ -15554,8 +14798,8 @@ var init_ConfigService = __esm({
15554
14798
  "utf-8"
15555
14799
  );
15556
14800
  this._isDirty = false;
15557
- } catch (error2) {
15558
- throw new Error(`Failed to save configuration: ${error2}`);
14801
+ } catch (error) {
14802
+ throw new Error(`Failed to save configuration: ${error}`);
15559
14803
  }
15560
14804
  }
15561
14805
  /**
@@ -15566,8 +14810,8 @@ var init_ConfigService = __esm({
15566
14810
  clearTimeout(this._saveDebounceTimer);
15567
14811
  }
15568
14812
  this._saveDebounceTimer = setTimeout(() => {
15569
- this.save().catch((error2) => {
15570
- console.error("Auto-save failed:", error2);
14813
+ this.save().catch((error) => {
14814
+ console.error("Auto-save failed:", error);
15571
14815
  });
15572
14816
  }, 5e3);
15573
14817
  }
@@ -15822,8 +15066,8 @@ var init_RouterService = __esm({
15822
15066
  ),
15823
15067
  metadata: analysis2.metadata
15824
15068
  };
15825
- } catch (error2) {
15826
- console.warn("Intelligent routing failed:", error2);
15069
+ } catch (error) {
15070
+ console.warn("Intelligent routing failed:", error);
15827
15071
  return {
15828
15072
  type: "conversation",
15829
15073
  confidence: 0.3
@@ -16046,11 +15290,11 @@ var init_RouterService = __esm({
16046
15290
  });
16047
15291
 
16048
15292
  // src/services/interactive-session/services/ValidationService.ts
16049
- var import_zod3, ValidationService;
15293
+ var import_zod2, ValidationService;
16050
15294
  var init_ValidationService = __esm({
16051
15295
  "src/services/interactive-session/services/ValidationService.ts"() {
16052
15296
  "use strict";
16053
- import_zod3 = require("zod");
15297
+ import_zod2 = require("zod");
16054
15298
  ValidationService = class {
16055
15299
  _config;
16056
15300
  _customRules = /* @__PURE__ */ new Map();
@@ -16082,23 +15326,23 @@ var init_ValidationService = __esm({
16082
15326
  initializeSchemas() {
16083
15327
  this._schemas.set(
16084
15328
  "command",
16085
- import_zod3.z.object({
16086
- name: import_zod3.z.string().min(1).max(50),
16087
- args: import_zod3.z.array(import_zod3.z.string()).max(this._config.maxCommandArgs),
16088
- flags: import_zod3.z.record(import_zod3.z.string()).optional()
15329
+ import_zod2.z.object({
15330
+ name: import_zod2.z.string().min(1).max(50),
15331
+ args: import_zod2.z.array(import_zod2.z.string()).max(this._config.maxCommandArgs),
15332
+ flags: import_zod2.z.record(import_zod2.z.string()).optional()
16089
15333
  })
16090
15334
  );
16091
15335
  this._schemas.set(
16092
15336
  "filePath",
16093
- import_zod3.z.string().min(1).max(this._config.maxFilePathLength).refine((path7) => !this.containsPathTraversal(path7), {
15337
+ import_zod2.z.string().min(1).max(this._config.maxFilePathLength).refine((path7) => !this.containsPathTraversal(path7), {
16094
15338
  message: "Path traversal detected"
16095
15339
  })
16096
15340
  );
16097
- this._schemas.set("url", import_zod3.z.string().url());
16098
- this._schemas.set("email", import_zod3.z.string().email());
15341
+ this._schemas.set("url", import_zod2.z.string().url());
15342
+ this._schemas.set("email", import_zod2.z.string().email());
16099
15343
  this._schemas.set(
16100
15344
  "configValue",
16101
- import_zod3.z.union([import_zod3.z.string(), import_zod3.z.number(), import_zod3.z.boolean(), import_zod3.z.record(import_zod3.z.any())])
15345
+ 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
15346
  );
16103
15347
  }
16104
15348
  /**
@@ -16201,11 +15445,11 @@ var init_ValidationService = __esm({
16201
15445
  valid: true,
16202
15446
  value: result
16203
15447
  };
16204
- } catch (error2) {
16205
- if (error2 instanceof import_zod3.z.ZodError) {
15448
+ } catch (error) {
15449
+ if (error instanceof import_zod2.z.ZodError) {
16206
15450
  return {
16207
15451
  valid: false,
16208
- errors: error2.errors.map((e2) => ({
15452
+ errors: error.errors.map((e2) => ({
16209
15453
  field: e2.path.join("."),
16210
15454
  message: e2.message,
16211
15455
  code: e2.code,
@@ -16250,11 +15494,11 @@ var init_ValidationService = __esm({
16250
15494
  valid: true,
16251
15495
  value: result
16252
15496
  };
16253
- } catch (error2) {
16254
- if (error2 instanceof import_zod3.z.ZodError) {
15497
+ } catch (error) {
15498
+ if (error instanceof import_zod2.z.ZodError) {
16255
15499
  return {
16256
15500
  valid: false,
16257
- errors: error2.errors.map((e2) => ({
15501
+ errors: error.errors.map((e2) => ({
16258
15502
  field: "path",
16259
15503
  message: e2.message,
16260
15504
  code: e2.code,
@@ -16301,7 +15545,7 @@ var init_ValidationService = __esm({
16301
15545
  valid: true,
16302
15546
  value: result
16303
15547
  };
16304
- } catch (error2) {
15548
+ } catch (error) {
16305
15549
  return {
16306
15550
  valid: false,
16307
15551
  errors: [
@@ -16326,7 +15570,7 @@ var init_ValidationService = __esm({
16326
15570
  valid: true,
16327
15571
  value: result
16328
15572
  };
16329
- } catch (error2) {
15573
+ } catch (error) {
16330
15574
  return {
16331
15575
  valid: false,
16332
15576
  errors: [
@@ -19164,9 +18408,9 @@ var init_CommandRegistry = __esm({
19164
18408
  });
19165
18409
  clearTimeout(timer);
19166
18410
  return result;
19167
- } catch (error2) {
18411
+ } catch (error) {
19168
18412
  clearTimeout(timer);
19169
- throw error2;
18413
+ throw error;
19170
18414
  }
19171
18415
  }
19172
18416
  return registration.handler.execute(context2);
@@ -19405,9 +18649,9 @@ var init_SpinnerManager = __esm({
19405
18649
  const result = await fn();
19406
18650
  this.stop(spinnerId, "success");
19407
18651
  return result;
19408
- } catch (error2) {
18652
+ } catch (error) {
19409
18653
  this.stop(spinnerId, "fail");
19410
- throw error2;
18654
+ throw error;
19411
18655
  }
19412
18656
  }
19413
18657
  /**
@@ -19799,9 +19043,9 @@ var init_DisplayManager = __esm({
19799
19043
  process.on("exit", cleanup);
19800
19044
  process.on("SIGINT", cleanup);
19801
19045
  process.on("SIGTERM", cleanup);
19802
- process.on("uncaughtException", (error2) => {
19046
+ process.on("uncaughtException", (error) => {
19803
19047
  cleanup();
19804
- console.error("Uncaught exception:", error2);
19048
+ console.error("Uncaught exception:", error);
19805
19049
  process.exit(1);
19806
19050
  });
19807
19051
  }
@@ -20349,10 +19593,10 @@ export { generated };`;
20349
19593
  requiresInput: false
20350
19594
  // Important: prevent re-dispatch
20351
19595
  };
20352
- } catch (error2) {
19596
+ } catch (error) {
20353
19597
  return {
20354
19598
  ok: false,
20355
- message: import_chalk11.default.red(`Code generation failed: ${error2}`)
19599
+ message: import_chalk11.default.red(`Code generation failed: ${error}`)
20356
19600
  };
20357
19601
  }
20358
19602
  }
@@ -21079,9 +20323,9 @@ var init_SessionOrchestrator = __esm({
21079
20323
  await this.setupCommandRegistry();
21080
20324
  await this.initializeSessionManager();
21081
20325
  this._initialized = true;
21082
- } catch (error2) {
20326
+ } catch (error) {
21083
20327
  await this.cleanup();
21084
- throw new Error(`SessionOrchestrator initialization failed: ${error2}`);
20328
+ throw new Error(`SessionOrchestrator initialization failed: ${error}`);
21085
20329
  }
21086
20330
  }
21087
20331
  /**
@@ -21225,9 +20469,9 @@ var init_SessionOrchestrator = __esm({
21225
20469
  if (this._sessionManager) {
21226
20470
  await this._sessionManager.start();
21227
20471
  }
21228
- } catch (error2) {
20472
+ } catch (error) {
21229
20473
  this._running = false;
21230
- throw error2;
20474
+ throw error;
21231
20475
  }
21232
20476
  }
21233
20477
  /**
@@ -21244,8 +20488,8 @@ var init_SessionOrchestrator = __esm({
21244
20488
  }
21245
20489
  await this.showGoodbye();
21246
20490
  await this.cleanup();
21247
- } catch (error2) {
21248
- console.error("Error during session stop:", error2);
20491
+ } catch (error) {
20492
+ console.error("Error during session stop:", error);
21249
20493
  }
21250
20494
  }
21251
20495
  /**
@@ -21429,10 +20673,10 @@ var init_interactive_session = __esm({
21429
20673
  message: `Command ${command} is being migrated to the new system`
21430
20674
  };
21431
20675
  }
21432
- } catch (error2) {
20676
+ } catch (error) {
21433
20677
  return {
21434
20678
  ok: false,
21435
- message: `Error executing command: ${error2}`
20679
+ message: `Error executing command: ${error}`
21436
20680
  };
21437
20681
  }
21438
20682
  }
@@ -21516,7 +20760,7 @@ var init_package = __esm({
21516
20760
  "package.json"() {
21517
20761
  package_default = {
21518
20762
  name: "@bonginkan/maria",
21519
- version: "3.6.1",
20763
+ version: "3.6.3",
21520
20764
  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
20765
  keywords: [
21522
20766
  "ai",
@@ -21950,8 +21194,8 @@ var init_conversation_persistence = __esm({
21950
21194
  try {
21951
21195
  const configDir = path3.dirname(this.sessionFile);
21952
21196
  await import_fs2.promises.mkdir(configDir, { recursive: true });
21953
- } catch (error2) {
21954
- console.warn("Failed to create config directory:", error2);
21197
+ } catch (error) {
21198
+ console.warn("Failed to create config directory:", error);
21955
21199
  }
21956
21200
  }
21957
21201
  /**
@@ -21998,8 +21242,8 @@ var init_conversation_persistence = __esm({
21998
21242
  }
21999
21243
  };
22000
21244
  await import_fs2.promises.writeFile(this.sessionFile, JSON.stringify(session, null, 2));
22001
- } catch (error2) {
22002
- console.warn("Failed to save conversation history:", error2);
21245
+ } catch (error) {
21246
+ console.warn("Failed to save conversation history:", error);
22003
21247
  }
22004
21248
  }
22005
21249
  /**
@@ -22025,7 +21269,7 @@ var init_conversation_persistence = __esm({
22025
21269
  newestMessage: messages[messages.length - 1]?.timestamp,
22026
21270
  fileSize: stats.size
22027
21271
  };
22028
- } catch (error2) {
21272
+ } catch (error) {
22029
21273
  return {
22030
21274
  totalMessages: 0
22031
21275
  };
@@ -22228,10 +21472,10 @@ var init_chat_context_service = __esm({
22228
21472
  };
22229
21473
  await fs4.writeFile(sessionFile, JSON.stringify(sessionData, null, 2));
22230
21474
  this.emit("session-persisted", sessionFile);
22231
- } catch (error2) {
21475
+ } catch (error) {
22232
21476
  this.emit(
22233
21477
  "persist-error",
22234
- error2 instanceof Error ? error2 : new Error(String(error2))
21478
+ error instanceof Error ? error : new Error(String(error))
22235
21479
  );
22236
21480
  }
22237
21481
  }
@@ -22931,14 +22175,14 @@ var init_telemetry_collector = __esm({
22931
22175
  /**
22932
22176
  * Track errors
22933
22177
  */
22934
- trackError(error2, context2) {
22178
+ trackError(error, context2) {
22935
22179
  this.addEvent({
22936
22180
  timestamp: Date.now(),
22937
22181
  eventType: "error_occurred",
22938
22182
  sessionId: this.sessionId,
22939
22183
  data: {
22940
- message: error2.message,
22941
- stack: error2.stack,
22184
+ message: error.message,
22185
+ stack: error.stack,
22942
22186
  ...context2
22943
22187
  }
22944
22188
  });
@@ -22965,8 +22209,8 @@ var init_telemetry_collector = __esm({
22965
22209
  } else {
22966
22210
  this.storeLocally(eventsToFlush);
22967
22211
  }
22968
- } catch (error2) {
22969
- console.error("[Telemetry] Failed to flush events:", error2);
22212
+ } catch (error) {
22213
+ console.error("[Telemetry] Failed to flush events:", error);
22970
22214
  this.events.unshift(...eventsToFlush);
22971
22215
  }
22972
22216
  }
@@ -23995,15 +23239,13 @@ var init_ai_response_service = __esm({
23995
23239
  _conversationPersistence;
23996
23240
  telemetry;
23997
23241
  initialized = false;
23998
- // v2.0 Provider System
23999
- modernProviderManager;
24000
- legacyProviderFactory;
23242
+ // V2.0 Provider System (Modern Only)
23243
+ providerManager;
24001
23244
  constructor() {
24002
23245
  this.chatContext = ChatContextService.getInstance();
24003
23246
  this._conversationPersistence = new ConversationPersistence();
24004
23247
  this.telemetry = TelemetryCollector.getInstance();
24005
- this.modernProviderManager = new UnifiedAIProviderManager2();
24006
- this.legacyProviderFactory = LegacyAIProviderFactory2.getInstance();
23248
+ this.providerManager = new UnifiedAIProviderManager2();
24007
23249
  this.initializeProviders().catch(console.error);
24008
23250
  }
24009
23251
  /**
@@ -24013,18 +23255,9 @@ var init_ai_response_service = __esm({
24013
23255
  async initializeProviders() {
24014
23256
  if (this.initialized) return;
24015
23257
  try {
24016
- if (USE_LEGACY_PROVIDERS2) {
24017
- await this.legacyProviderFactory.initializeFromEnvironment();
24018
- } else {
24019
- await this.modernProviderManager.initialize();
24020
- }
23258
+ await this.providerManager.initialize();
24021
23259
  this.initialized = true;
24022
- } catch (error2) {
24023
- try {
24024
- await this.legacyProviderFactory.initializeFromEnvironment();
24025
- this.initialized = true;
24026
- } catch (fallbackError) {
24027
- }
23260
+ } catch (error) {
24028
23261
  }
24029
23262
  }
24030
23263
  /**
@@ -24035,14 +23268,10 @@ var init_ai_response_service = __esm({
24035
23268
  if (!this.initialized) {
24036
23269
  await this.initializeProviders();
24037
23270
  }
24038
- if (USE_LEGACY_PROVIDERS2) {
24039
- return this.legacyProviderFactory.getActiveProvider();
24040
- } else {
24041
- try {
24042
- return await this.modernProviderManager.pick(DEFAULT_PROVIDER2);
24043
- } catch (error2) {
24044
- return this.legacyProviderFactory.getActiveProvider();
24045
- }
23271
+ try {
23272
+ return await this.providerManager.pick(DEFAULT_PROVIDER2);
23273
+ } catch (error) {
23274
+ throw new Error(`Provider initialization failed: ${error instanceof Error ? error.message : "Unknown error"}`);
24046
23275
  }
24047
23276
  }
24048
23277
  /**
@@ -24324,7 +23553,7 @@ I'm here to assist you effectively!`;
24324
23553
  });
24325
23554
 
24326
23555
  // src/shared/adapters/LegacySlashCommandAdapter.ts
24327
- var LegacySlashCommandAdapter, SlashCommandHandler;
23556
+ var LegacySlashCommandAdapter, SlashCommandHandler2;
24328
23557
  var init_LegacySlashCommandAdapter = __esm({
24329
23558
  "src/shared/adapters/LegacySlashCommandAdapter.ts"() {
24330
23559
  "use strict";
@@ -24365,10 +23594,10 @@ var init_LegacySlashCommandAdapter = __esm({
24365
23594
  error: result.error,
24366
23595
  messages: result.messages || []
24367
23596
  };
24368
- } catch (error2) {
23597
+ } catch (error) {
24369
23598
  return {
24370
23599
  success: false,
24371
- error: error2 instanceof Error ? error2.message : "Unknown error",
23600
+ error: error instanceof Error ? error.message : "Unknown error",
24372
23601
  messages: []
24373
23602
  };
24374
23603
  }
@@ -24388,10 +23617,10 @@ var init_LegacySlashCommandAdapter = __esm({
24388
23617
  success: true,
24389
23618
  messages: [{ role: "assistant", content: result }]
24390
23619
  };
24391
- } catch (error2) {
23620
+ } catch (error) {
24392
23621
  return {
24393
23622
  success: false,
24394
- error: error2 instanceof Error ? error2.message : "Command execution failed",
23623
+ error: error instanceof Error ? error.message : "Command execution failed",
24395
23624
  messages: []
24396
23625
  };
24397
23626
  }
@@ -24406,7 +23635,7 @@ var init_LegacySlashCommandAdapter = __esm({
24406
23635
  return this.handler;
24407
23636
  }
24408
23637
  };
24409
- SlashCommandHandler = LegacySlashCommandAdapter;
23638
+ SlashCommandHandler2 = LegacySlashCommandAdapter;
24410
23639
  }
24411
23640
  });
24412
23641
 
@@ -27309,7 +26538,7 @@ async function readConfig() {
27309
26538
  return _config;
27310
26539
  }
27311
26540
  var import_fs3, import_path2, import_toml, import_os, _CONFIG_FILE, _GLOBAL_CONFIG_PATH;
27312
- var init_config2 = __esm({
26541
+ var init_config3 = __esm({
27313
26542
  "src/utils/config.ts"() {
27314
26543
  "use strict";
27315
26544
  import_fs3 = require("fs");
@@ -27336,7 +26565,7 @@ var init_code_generation_service = __esm({
27336
26565
  init_google_ai_provider();
27337
26566
  init_lmstudio_provider();
27338
26567
  init_default_provider();
27339
- init_config2();
26568
+ init_config3();
27340
26569
  fs6 = __toESM(require("fs/promises"), 1);
27341
26570
  path6 = __toESM(require("path"), 1);
27342
26571
  logger2 = logger;
@@ -27984,7 +27213,7 @@ async function initializeServices() {
27984
27213
  conversationPersistence = new ConversationPersistence();
27985
27214
  chatContext = ChatContextService.getInstance();
27986
27215
  aiResponseService = new AIResponseService();
27987
- slashCommandHandler = SlashCommandHandler.getInstance();
27216
+ slashCommandHandler = SlashCommandHandler2.getInstance();
27988
27217
  providerManager = new UnifiedAIProviderManager2();
27989
27218
  try {
27990
27219
  await providerManager.initialize();
@@ -28034,8 +27263,8 @@ async function initializeServices() {
28034
27263
  sessionMemory.push(msg);
28035
27264
  }
28036
27265
  return true;
28037
- } catch (error2) {
28038
- console.error(import_chalk15.default.red("\u274C Service initialization failed:"), error2);
27266
+ } catch (error) {
27267
+ console.error(import_chalk15.default.red("\u274C Service initialization failed:"), error);
28039
27268
  return false;
28040
27269
  }
28041
27270
  }
@@ -28156,10 +27385,10 @@ async function startInteractiveSession() {
28156
27385
  const errorMessage = result.message || result._message || "Command failed";
28157
27386
  console.log(import_chalk15.default.red(`\u274C ${errorMessage}`));
28158
27387
  }
28159
- } catch (error2) {
27388
+ } catch (error) {
28160
27389
  console.error(
28161
27390
  import_chalk15.default.red("\u274C Command error:"),
28162
- error2?.message || error2
27391
+ error?.message || error
28163
27392
  );
28164
27393
  }
28165
27394
  }
@@ -28245,10 +27474,10 @@ async function startInteractiveSession() {
28245
27474
  console.log();
28246
27475
  continue;
28247
27476
  }
28248
- } catch (error2) {
27477
+ } catch (error) {
28249
27478
  console.error(
28250
27479
  import_chalk15.default.red("\u274C SlashCommand error:"),
28251
- error2?.message || error2
27480
+ error?.message || error
28252
27481
  );
28253
27482
  console.log();
28254
27483
  continue;
@@ -28290,7 +27519,7 @@ async function startInteractiveSession() {
28290
27519
  if (conversationPersistence) {
28291
27520
  await conversationPersistence.addMessage(assistantMessage);
28292
27521
  }
28293
- } catch (error2) {
27522
+ } catch (error) {
28294
27523
  console.log(
28295
27524
  import_chalk15.default.gray(
28296
27525
  "\u26A0\uFE0F Persistent memory save failed, using session memory only"
@@ -28299,22 +27528,22 @@ async function startInteractiveSession() {
28299
27528
  }
28300
27529
  }
28301
27530
  console.log();
28302
- } catch (error2) {
28303
- if (error2?.code === "ABORT_ERR" || error2?.name === "AbortError") {
27531
+ } catch (error) {
27532
+ if (error?.code === "ABORT_ERR" || error?.name === "AbortError") {
28304
27533
  console.log(import_chalk15.default.cyan("\n\nGoodbye! \u{1F44B}"));
28305
27534
  await stopAll();
28306
27535
  return;
28307
27536
  }
28308
27537
  console.error(
28309
27538
  import_chalk15.default.red("\u274C An error occurred:"),
28310
- error2?.message || error2
27539
+ error?.message || error
28311
27540
  );
28312
27541
  }
28313
27542
  }
28314
27543
  }
28315
27544
  function createCLI() {
28316
27545
  const program2 = new import_commander.Command();
28317
- program2.name("maria").description("\u{1F680} MARIA v3.0.0 - 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) => {
27546
+ 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
27547
  const { displayFinalStartupScreen: displayFinalStartupScreen2 } = await Promise.resolve().then(() => (init_startup_display(), startup_display_exports));
28319
27548
  displayFinalStartupScreen2();
28320
27549
  const useV3 = options.v3Session || process.env.MARIA_USE_V3_SESSION === "1";
@@ -28386,7 +27615,7 @@ var init_cli = __esm({
28386
27615
  init_ai_response_service();
28387
27616
  init_LegacySlashCommandAdapter();
28388
27617
  init_interactive_cli();
28389
- init_manager();
27618
+ init_providers();
28390
27619
  init_env_loader();
28391
27620
  init_version();
28392
27621
  packageJson = { version: getVersion() };
@@ -28441,7 +27670,7 @@ var init_maria_ai = __esm({
28441
27670
  import_commander2 = require("commander");
28442
27671
  init_startup_display();
28443
27672
  init_provider_selector();
28444
- init_config_manager();
27673
+ init_config2();
28445
27674
  init_IntelligentRouterService();
28446
27675
  init_interactive_session();
28447
27676
  init_package();
@@ -28451,7 +27680,7 @@ var init_maria_ai = __esm({
28451
27680
  router;
28452
27681
  session;
28453
27682
  constructor() {
28454
- this.config = new ConfigManagerV2();
27683
+ this.config = new ConfigManager();
28455
27684
  this.providerSelector = new ProviderSelector(this.config);
28456
27685
  }
28457
27686
  async initialize() {
@@ -28478,8 +27707,8 @@ var init_maria_ai = __esm({
28478
27707
  );
28479
27708
  this.session = createInteractiveSession(this);
28480
27709
  await this.session.start();
28481
- } catch (error2) {
28482
- console.error(import_chalk16.default.red("\n\u274C Initialization failed:"), error2);
27710
+ } catch (error) {
27711
+ console.error(import_chalk16.default.red("\n\u274C Initialization failed:"), error);
28483
27712
  process.exit(1);
28484
27713
  }
28485
27714
  }
@@ -28528,52 +27757,16 @@ function checkNodeVersion() {
28528
27757
  }
28529
27758
  }
28530
27759
 
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
27760
  // src/bin/maria.ts
27761
+ init_loader();
28569
27762
  async function main() {
28570
27763
  await loadEnvironmentConfig();
28571
27764
  checkNodeVersion();
28572
27765
  const program2 = createCLI2();
28573
27766
  program2.parse(process.argv);
28574
27767
  }
28575
- process.on("uncaughtException", (error2) => {
28576
- console.error("\u274C Uncaught Exception:", error2.message);
27768
+ process.on("uncaughtException", (error) => {
27769
+ console.error("\u274C Uncaught Exception:", error.message);
28577
27770
  process.exit(1);
28578
27771
  });
28579
27772
  process.on("unhandledRejection", (reason, promise) => {
@@ -28588,8 +27781,8 @@ process.on("SIGTERM", () => {
28588
27781
  console.log("\n\u{1F44B} Goodbye!");
28589
27782
  process.exit(0);
28590
27783
  });
28591
- main().catch((error2) => {
28592
- console.error("\u274C Failed to start:", error2);
27784
+ main().catch((error) => {
27785
+ console.error("\u274C Failed to start:", error);
28593
27786
  process.exit(1);
28594
27787
  });
28595
27788
  //# sourceMappingURL=maria.cjs.map